netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/4] net: hns3: fixes for -net
@ 2021-07-19  9:13 Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox Guangbin Huang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Guangbin Huang @ 2021-07-19  9:13 UTC (permalink / raw)
  To: davem, kuba, fengchengwen
  Cc: netdev, linux-kernel, salil.mehta, lipeng321, huangguangbin2

This series includes some bugfixes for the HNS3 ethernet driver.

Chengwen Feng (1):
  net: hns3: fix possible mismatches resp of mailbox

Jian Shen (2):
  net: hns3: disable port VLAN filter when support function level VLAN
    filter control
  net: hns3: fix rx VLAN offload state inconsistent issue

Peng Li (1):
  net: hns3: add match_id to check mailbox response from PF to VF

 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h       |  7 +++++--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   |  8 ++++++--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c    |  1 +
 .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 10 ++++++++++
 .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c  | 19 +++++++++++++++++++
 5 files changed, 41 insertions(+), 4 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox
  2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
@ 2021-07-19  9:13 ` Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 2/4] net: hns3: add match_id to check mailbox response from PF to VF Guangbin Huang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guangbin Huang @ 2021-07-19  9:13 UTC (permalink / raw)
  To: davem, kuba, fengchengwen
  Cc: netdev, linux-kernel, salil.mehta, lipeng321, huangguangbin2

From: Chengwen Feng <fengchengwen@huawei.com>

Currently, the mailbox synchronous communication between VF and PF use
the following fields to maintain communication:
1. Origin_mbx_msg which was combined by message code and subcode, used
to match request and response.
2. Received_resp which means whether received response.

There may possible mismatches of the following situation:
1. VF sends message A with code=1 subcode=1.
2. PF was blocked about 500ms when processing the message A.
3. VF will detect message A timeout because it can't get the response
within 500ms.
4. VF sends message B with code=1 subcode=1 which equal message A.
5. PF processes the first message A and send the response message to
VF.
6. VF will identify the response matched the message B because the
code/subcode is the same. This will lead to mismatch of request and
response.

To fix the above bug, we use the following scheme:
1. The message sent from VF was labelled with match_id which was a
unique 16-bit non-zero value.
2. The response sent from PF will label with match_id which got from
the request.
3. The VF uses the match_id to match request and response message.

As for PF driver, it only needs to copy the match_id from request to
response.

Fixes: dde1a86e93ca ("net: hns3: Add mailbox support to PF driver")
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h        | 6 ++++--
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
index 0a6cda309b24..56b573e47072 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
@@ -143,7 +143,8 @@ struct hclge_mbx_vf_to_pf_cmd {
 	u8 mbx_need_resp;
 	u8 rsv1[1];
 	u8 msg_len;
-	u8 rsv2[3];
+	u8 rsv2;
+	u16 match_id;
 	struct hclge_vf_to_pf_msg msg;
 };
 
@@ -153,7 +154,8 @@ struct hclge_mbx_pf_to_vf_cmd {
 	u8 dest_vfid;
 	u8 rsv[3];
 	u8 msg_len;
-	u8 rsv1[3];
+	u8 rsv1;
+	u16 match_id;
 	struct hclge_pf_to_vf_msg msg;
 };
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index e10a2c36b706..c0a478ae9583 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -47,6 +47,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport,
 
 	resp_pf_to_vf->dest_vfid = vf_to_pf_req->mbx_src_vfid;
 	resp_pf_to_vf->msg_len = vf_to_pf_req->msg_len;
+	resp_pf_to_vf->match_id = vf_to_pf_req->match_id;
 
 	resp_pf_to_vf->msg.code = HCLGE_MBX_PF_VF_RESP;
 	resp_pf_to_vf->msg.vf_mbx_msg_code = vf_to_pf_req->msg.code;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/4] net: hns3: add match_id to check mailbox response from PF to VF
  2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox Guangbin Huang
@ 2021-07-19  9:13 ` Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 3/4] net: hns3: disable port VLAN filter when support function level VLAN filter control Guangbin Huang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guangbin Huang @ 2021-07-19  9:13 UTC (permalink / raw)
  To: davem, kuba, fengchengwen
  Cc: netdev, linux-kernel, salil.mehta, lipeng321, huangguangbin2

From: Peng Li <lipeng321@huawei.com>

When VF need response from PF, VF will wait (1us - 1s) to receive
the response, or it will wait timeout and the VF action fails.
If VF do not receive response in 1st action because timeout,
the 2nd action may receive response for the 1st action, and get
incorrect response data.VF must reciveve the right response from
PF,or it will cause unexpected error.

This patch adds match_id to check mailbox response from PF to VF,
to make sure VF get the right response:
1. The message sent from VF was labelled with match_id which was a
unique 16-bit non-zero value.
2. The response sent from PF will label with match_id which got from
the request.
3. The VF uses the match_id to match request and response message.

This scheme depends on PF driver supports match_id, if PF driver doesn't
support then VF will uses the original scheme.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h       |  1 +
 .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c  | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
index 56b573e47072..aa86a81c8f4a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
@@ -98,6 +98,7 @@ struct hclgevf_mbx_resp_status {
 	u32 origin_mbx_msg;
 	bool received_resp;
 	int resp_status;
+	u16 match_id;
 	u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
 };
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
index 9b17735b9f4c..772b2f8acd2e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
@@ -13,6 +13,7 @@ static int hclgevf_resp_to_errno(u16 resp_code)
 	return resp_code ? -resp_code : 0;
 }
 
+#define HCLGEVF_MBX_MATCH_ID_START	1
 static void hclgevf_reset_mbx_resp_status(struct hclgevf_dev *hdev)
 {
 	/* this function should be called with mbx_resp.mbx_mutex held
@@ -21,6 +22,10 @@ static void hclgevf_reset_mbx_resp_status(struct hclgevf_dev *hdev)
 	hdev->mbx_resp.received_resp  = false;
 	hdev->mbx_resp.origin_mbx_msg = 0;
 	hdev->mbx_resp.resp_status    = 0;
+	hdev->mbx_resp.match_id++;
+	/* Update match_id and ensure the value of match_id is not zero */
+	if (hdev->mbx_resp.match_id == 0)
+		hdev->mbx_resp.match_id = HCLGEVF_MBX_MATCH_ID_START;
 	memset(hdev->mbx_resp.additional_info, 0, HCLGE_MBX_MAX_RESP_DATA_SIZE);
 }
 
@@ -115,6 +120,7 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,
 	if (need_resp) {
 		mutex_lock(&hdev->mbx_resp.mbx_mutex);
 		hclgevf_reset_mbx_resp_status(hdev);
+		req->match_id = hdev->mbx_resp.match_id;
 		status = hclgevf_cmd_send(&hdev->hw, &desc, 1);
 		if (status) {
 			dev_err(&hdev->pdev->dev,
@@ -211,6 +217,19 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
 				resp->additional_info[i] = *temp;
 				temp++;
 			}
+
+			/* If match_id is not zero, it means PF support
+			 * match_id. If the match_id is right, VF get the
+			 * right response, otherwise ignore the response.
+			 * Driver will clear hdev->mbx_resp when send
+			 * next message which need response.
+			 */
+			if (req->match_id) {
+				if (req->match_id == resp->match_id)
+					resp->received_resp = true;
+			} else {
+				resp->received_resp = true;
+			}
 			break;
 		case HCLGE_MBX_LINK_STAT_CHANGE:
 		case HCLGE_MBX_ASSERTING_RESET:
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 3/4] net: hns3: disable port VLAN filter when support function level VLAN filter control
  2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 2/4] net: hns3: add match_id to check mailbox response from PF to VF Guangbin Huang
@ 2021-07-19  9:13 ` Guangbin Huang
  2021-07-19  9:13 ` [PATCH net 4/4] net: hns3: fix rx VLAN offload state inconsistent issue Guangbin Huang
  2021-07-20 11:50 ` [PATCH net 0/4] net: hns3: fixes for -net patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Guangbin Huang @ 2021-07-19  9:13 UTC (permalink / raw)
  To: davem, kuba, fengchengwen
  Cc: netdev, linux-kernel, salil.mehta, lipeng321, huangguangbin2

From: Jian Shen <shenjian15@huawei.com>

For hardware limitation, port VLAN filter is port level, and
effective for all the functions of the port. So if not support
port VLAN bypass, it's necessary to disable the port VLAN filter,
in order to support function level VLAN filter control.

Fixes: 2ba306627f59 ("net: hns3: add support for modify VLAN filter state")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index dd3354a57c62..ebeaf12e409b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -9552,13 +9552,17 @@ static int hclge_set_vport_vlan_filter(struct hclge_vport *vport, bool enable)
 	if (ret)
 		return ret;
 
-	if (test_bit(HNAE3_DEV_SUPPORT_PORT_VLAN_BYPASS_B, ae_dev->caps))
+	if (test_bit(HNAE3_DEV_SUPPORT_PORT_VLAN_BYPASS_B, ae_dev->caps)) {
 		ret = hclge_set_port_vlan_filter_bypass(hdev, vport->vport_id,
 							!enable);
-	else if (!vport->vport_id)
+	} else if (!vport->vport_id) {
+		if (test_bit(HNAE3_DEV_SUPPORT_VLAN_FLTR_MDF_B, ae_dev->caps))
+			enable = false;
+
 		ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
 						 HCLGE_FILTER_FE_INGRESS,
 						 enable, 0);
+	}
 
 	return ret;
 }
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 4/4] net: hns3: fix rx VLAN offload state inconsistent issue
  2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
                   ` (2 preceding siblings ...)
  2021-07-19  9:13 ` [PATCH net 3/4] net: hns3: disable port VLAN filter when support function level VLAN filter control Guangbin Huang
@ 2021-07-19  9:13 ` Guangbin Huang
  2021-07-20 11:50 ` [PATCH net 0/4] net: hns3: fixes for -net patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Guangbin Huang @ 2021-07-19  9:13 UTC (permalink / raw)
  To: davem, kuba, fengchengwen
  Cc: netdev, linux-kernel, salil.mehta, lipeng321, huangguangbin2

From: Jian Shen <shenjian15@huawei.com>

Currently, VF doesn't enable rx VLAN offload when initializating,
and PF does it for VFs. If user disable the rx VLAN offload for
VF with ethtool -K, and reload the VF driver, it may cause the
rx VLAN offload state being inconsistent between hardware and
software.

Fixes it by enabling rx VLAN offload when VF initializing.

Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 52eaf82b7cd7..8784d61e833f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2641,6 +2641,16 @@ static int hclgevf_rss_init_hw(struct hclgevf_dev *hdev)
 
 static int hclgevf_init_vlan_config(struct hclgevf_dev *hdev)
 {
+	struct hnae3_handle *nic = &hdev->nic;
+	int ret;
+
+	ret = hclgevf_en_hw_strip_rxvtag(nic, true);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"failed to enable rx vlan offload, ret = %d\n", ret);
+		return ret;
+	}
+
 	return hclgevf_set_vlan_filter(&hdev->nic, htons(ETH_P_8021Q), 0,
 				       false);
 }
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/4] net: hns3: fixes for -net
  2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
                   ` (3 preceding siblings ...)
  2021-07-19  9:13 ` [PATCH net 4/4] net: hns3: fix rx VLAN offload state inconsistent issue Guangbin Huang
@ 2021-07-20 11:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-20 11:50 UTC (permalink / raw)
  To: Guangbin Huang
  Cc: davem, kuba, fengchengwen, netdev, linux-kernel, salil.mehta, lipeng321

Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Mon, 19 Jul 2021 17:13:04 +0800 you wrote:
> This series includes some bugfixes for the HNS3 ethernet driver.
> 
> Chengwen Feng (1):
>   net: hns3: fix possible mismatches resp of mailbox
> 
> Jian Shen (2):
>   net: hns3: disable port VLAN filter when support function level VLAN
>     filter control
>   net: hns3: fix rx VLAN offload state inconsistent issue
> 
> [...]

Here is the summary with links:
  - [net,1/4] net: hns3: fix possible mismatches resp of mailbox
    https://git.kernel.org/netdev/net/c/1b713d14dc3c
  - [net,2/4] net: hns3: add match_id to check mailbox response from PF to VF
    https://git.kernel.org/netdev/net/c/4671042f1ef0
  - [net,3/4] net: hns3: disable port VLAN filter when support function level VLAN filter control
    https://git.kernel.org/netdev/net/c/184cd221a863
  - [net,4/4] net: hns3: fix rx VLAN offload state inconsistent issue
    https://git.kernel.org/netdev/net/c/bbfd4506f962

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-20 11:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  9:13 [PATCH net 0/4] net: hns3: fixes for -net Guangbin Huang
2021-07-19  9:13 ` [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox Guangbin Huang
2021-07-19  9:13 ` [PATCH net 2/4] net: hns3: add match_id to check mailbox response from PF to VF Guangbin Huang
2021-07-19  9:13 ` [PATCH net 3/4] net: hns3: disable port VLAN filter when support function level VLAN filter control Guangbin Huang
2021-07-19  9:13 ` [PATCH net 4/4] net: hns3: fix rx VLAN offload state inconsistent issue Guangbin Huang
2021-07-20 11:50 ` [PATCH net 0/4] net: hns3: fixes for -net patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).