Skip to contentSkip to conversation

bugfix for hns3 PMD

PATCH In review Min Hu (Connor) 3 participants 19 messages Apr 22, 2021 – Apr 27, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover bugfix for hns3 PMD

This patchset contains four bugfixes for hns3 PMD.

Chengwen Feng (4):
net/hns3: fix error mbx messages prompt errors net/hns3: fix PF miss link status notify message net/hns3: fix parse link fails code fail net/hns3: delete unused macro and struct of mbx module

 drivers/net/hns3/hns3_mbx.c | 18 +++++++++++-------
 drivers/net/hns3/hns3_mbx.h | 10 ----------
 2 files changed, 11 insertions(+), 17 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 net/hns3: fix error mbx messages prompt errors

From: Chengwen Feng <[email protected]>

The hns3_dev_handle_mbx_msg() could be called under both PF and VF, but the error messages show VF.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +1 -2
index eb202dd..3b35c02 100644
@@ -528,8 +528,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 			hns3_handle_promisc_info(hw, req->msg[1]);
 			break;
 		default:
-			hns3_err(hw,
-				 "VF received unsupported(%u) mbx msg from PF",
+			hns3_err(hw, "received unsupported(%u) mbx msg",
 				 req->msg[0]);
 			break;
 		}
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 net/hns3: fix PF miss link status notify message

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The opcode of the link status notification message reported by the firmware is zero, it will be filtered out because driver treats it as already processed message. As a result, the PF can't update the link status in a timely manner.

Because only VF can set opcode to zero when process mailbox message, so we add a judgment to make sure the PF messages will not filter out.

Fixes dbbbad23e380 ("net/hns3: fix VF handling LSC event in secondary process")
---
 drivers/net/hns3/hns3_mbx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/hns3/hns3_mbx.c +7 -3
index 3b35c02..ba04ac9 100644
@@ -438,16 +438,19 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw)
 void
 hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 {
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	struct hns3_cmq_ring *crq = &hw->cmq.crq;
 	struct hns3_mbx_pf_to_vf_cmd *req;
 	struct hns3_cmd_desc *desc;
+	bool handle_out;
 	uint8_t opcode;
 	uint16_t flag;
 
 	rte_spinlock_lock(&hw->cmq.crq.lock);
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY ||
-	    !rte_thread_is_intr()) {
+	handle_out = (rte_eal_process_type() != RTE_PROC_PRIMARY ||
+		      !rte_thread_is_intr()) && hns->is_vf;
+	if (handle_out) {
 		/*
 		 * Currently, any threads in the primary and secondary processes
 		 * could send mailbox sync request, so it will need to process
@@ -491,7 +494,8 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 			continue;
 		}
 
-		if (desc->opcode == 0) {
+		handle_out = hns->is_vf && desc->opcode == 0;
+		if (handle_out) {
 			/* Message already processed by other thread */
 			crq->desc[crq->next_to_use].flag = 0;
 			hns3_mbx_ring_ptr_move_crq(crq);
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 net/hns3: fix parse link fails code fail

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +3 -2
index ba04ac9..0550c9a 100644
@@ -346,12 +346,13 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
 static void
-hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw, void *data)
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	struct hns3_mbx_vf_to_pf_cmd *req = data;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 
Signature · 1 line
2.7.4
#4 lore raw

Re: [dpdk-dev] [PATCH 3/4] net/hns3: fix parse link fails code fail

Quoted 19 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..0550c9a 100644

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 349

Quoted 6 lines
drivers/net/hns3/hns3_mbx.c +1 -2
@@ -346,12 +346,13 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
 static void
-hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw, void *data)

Why not s/struct hns3_mbx_pf_to_vf_cmd/struct hns3_mbx_vf_to_pf_cmd/ but change to parameter to "void *", wouldn't it reduce the type check?

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +2 -0
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	struct hns3_mbx_vf_to_pf_cmd *req = data;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 
#5 lore raw

Re: [dpdk-dev] [PATCH 3/4] net/hns3: fix parse link fails code fail

Quoted 22 lines · Ferruh Yigit
Quoted 21 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..0550c9a 100644
@@ -346,12 +346,13 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
Quoted 8 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 349

Quoted 4 lines
drivers/net/hns3/hns3_mbx.c +1 -2
 static void
-hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw, void *data)

Why not s/struct hns3_mbx_pf_to_vf_cmd/struct hns3_mbx_vf_to_pf_cmd/ but change to parameter to "void *", wouldn't it reduce the type check?

Only this message needs to be converted using hns3_mbx_vf_to_pf_cmd. All other messages are processed using hns3_mbx_pf_to_vf_cmd. So here we simplifying fix it.

Beside we will refactor hns3_mbx module in later version because the PF and VF process logic is mixed.

thanks

Quoted 14 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 358

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +2 -0
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	struct hns3_mbx_vf_to_pf_cmd *req = data;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 

.

#6 lore raw

Re: [dpdk-dev] [PATCH 3/4] net/hns3: fix parse link fails code fail

Quoted 34 lines · fengchengwen
Quoted 22 lines · Ferruh Yigit
Quoted 21 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..0550c9a 100644
@@ -346,12 +346,13 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
Quoted 8 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 349

Quoted 4 lines
drivers/net/hns3/hns3_mbx.c +1 -2
 static void
-hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw, void *data)

Why not s/struct hns3_mbx_pf_to_vf_cmd/struct hns3_mbx_vf_to_pf_cmd/ but change to parameter to "void *", wouldn't it reduce the type check?

Quoted 4 lines

Only this message needs to be converted using hns3_mbx_vf_to_pf_cmd. All other messages are processed using hns3_mbx_pf_to_vf_cmd. So here we simplifying fix it.

There is a single caller of the function, which send parameter as "struct hns3_mbx_pf_to_vf_cmd *req", so what is the point of making the parameter as "void *" and inside the function cast it to "struct hns3_mbx_vf_to_pf_cmd *req = data;"?
Instead of defining parameter as "struct hns3_mbx_pf_to_vf_cmd *req".

Quoted 3 lines

Beside we will refactor hns3_mbx module in later version because the PF and VF process logic is mixed.

OK

Quoted 17 lines

thanks

Quoted 14 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 358

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +2 -0
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	struct hns3_mbx_vf_to_pf_cmd *req = data;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 

.

#7 lore raw

Re: [dpdk-dev] [PATCH 3/4] net/hns3: fix parse link fails code fail

Quoted 40 lines · Ferruh Yigit
Quoted 34 lines · fengchengwen
Quoted 22 lines · Ferruh Yigit
Quoted 21 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
---
 drivers/net/hns3/hns3_mbx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..0550c9a 100644
@@ -346,12 +346,13 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
Quoted 8 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 349

Quoted 4 lines
drivers/net/hns3/hns3_mbx.c +1 -2
 static void
-hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw, void *data)

Why not s/struct hns3_mbx_pf_to_vf_cmd/struct hns3_mbx_vf_to_pf_cmd/ but change to parameter to "void *", wouldn't it reduce the type check?

Quoted 4 lines

Only this message needs to be converted using hns3_mbx_vf_to_pf_cmd. All other messages are processed using hns3_mbx_pf_to_vf_cmd. So here we simplifying fix it.

Quoted 6 lines

There is a single caller of the function, which send parameter as "struct hns3_mbx_pf_to_vf_cmd *req", so what is the point of making the parameter as "void *" and inside the function cast it to "struct hns3_mbx_vf_to_pf_cmd *req = data;"?
Instead of defining parameter as "struct hns3_mbx_pf_to_vf_cmd *req".

We'll keep the original API interface and add comments in v2, thanks

Quoted 27 lines
Quoted 3 lines

Beside we will refactor hns3_mbx module in later version because the PF and VF process logic is mixed.

OK

Quoted 17 lines

thanks

Quoted 14 lines

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 358

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +2 -0
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	struct hns3_mbx_vf_to_pf_cmd *req = data;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 

.

.

#8 lore raw

PATCH v2 1/1 net/hns3: fix parse link fails code fail

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v2:
* kept original API interface.

---
 drivers/net/hns3/hns3_mbx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_mbx.c +9 -1
index eb202dd..755298f 100644
@@ -346,12 +346,20 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
 static void
+
 hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_pf_to_vf_cmd *cmd)
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	/*
+	 * This message is reported by the firmware and is reported in
+	 * 'struct hns3_mbx_vf_to_pf_cmd' format. Therefore, we should cast
+	 * the cmd to 'struct hns3_mbx_vf_to_pf_cmd' first.
+	 */
+	struct hns3_mbx_vf_to_pf_cmd *req = (struct hns3_mbx_vf_to_pf_cmd *)cmd;
+
 	if (!req->msg[LINK_STATUS_OFFSET])
 		hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]);
 
Signature · 1 line
2.7.4
#9 lore raw

Re: [dpdk-dev] [PATCH v2] net/hns3: fix parse link fails code fail

Quoted 30 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v2:
* kept original API interface.

---
 drivers/net/hns3/hns3_mbx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_mbx.c +2 -1
index eb202dd..755298f 100644
@@ -346,12 +346,20 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
 static void
+
 hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_pf_to_vf_cmd *cmd)
 {

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 362

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +7 -0
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
 
+	/*
+	 * This message is reported by the firmware and is reported in
+	 * 'struct hns3_mbx_vf_to_pf_cmd' format. Therefore, we should cast
+	 * the cmd to 'struct hns3_mbx_vf_to_pf_cmd' first.
+	 */
+	struct hns3_mbx_vf_to_pf_cmd *req = (struct hns3_mbx_vf_to_pf_cmd *)cmd;
+

Hi Connor,

I guess I am missing something obvious, why not get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place?

#10 lore raw

Re: [dpdk-dev] [PATCH v2] net/hns3: fix parse link fails code fail

Quoted 44 lines · Ferruh Yigit
Quoted 30 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v2:
* kept original API interface.

---
  drivers/net/hns3/hns3_mbx.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_mbx.c +2 -1
index eb202dd..755298f 100644
@@ -346,12 +346,20 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
  }
 
  static void
+
  hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_pf_to_vf_cmd *cmd)
  {

drivers/net/hns3/hns3_mbx.c hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) · line 362

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +7 -0
  #define LINK_STATUS_OFFSET     1
  #define LINK_FAIL_CODE_OFFSET  2
 
+	/*
+	 * This message is reported by the firmware and is reported in
+	 * 'struct hns3_mbx_vf_to_pf_cmd' format. Therefore, we should cast
+	 * the cmd to 'struct hns3_mbx_vf_to_pf_cmd' first.
+	 */
+	struct hns3_mbx_vf_to_pf_cmd *req = (struct hns3_mbx_vf_to_pf_cmd *)cmd;
+

Hi Connor,

Quoted 3 lines

I guess I am missing something obvious, why not get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place?
.

Hi, fixed in v3, thanks.

Quoted 1 line
#11 lore raw

PATCH v3 1/1 net/hns3: fix parse link fails code fail

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.

---
 drivers/net/hns3/hns3_mbx.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +9 -2
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 
 static void
 hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_vf_to_pf_cmd *req)
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 			hns3_handle_asserting_reset(hw, req);
 			break;
 		case HNS3_MBX_PUSH_LINK_STATUS:
-			hns3pf_handle_link_change_event(hw, req);
+			/*
+			 * This message is reported by the firmware and is
+			 * reported in 'struct hns3_mbx_vf_to_pf_cmd' format.
+			 * Therefore, we should cast the req variable to
+			 * 'struct hns3_mbx_vf_to_pf_cmd' and then process it.
+			 */
+			hns3pf_handle_link_change_event(hw,
+				(struct hns3_mbx_vf_to_pf_cmd *)req);
 			break;
 		case HNS3_MBX_PUSH_VLAN_INFO:
 			/*
Signature · 1 line
2.7.4
#12 lore raw

Re: [dpdk-dev] [PATCH v3] net/hns3: fix parse link fails code fail

Quoted 34 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.

---
 drivers/net/hns3/hns3_mbx.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +1 -1
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 
 static void
 hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_vf_to_pf_cmd *req)
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 521

Quoted 10 lines
drivers/net/hns3/hns3_mbx.c +6 -1
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 			hns3_handle_asserting_reset(hw, req);
 			break;
 		case HNS3_MBX_PUSH_LINK_STATUS:
-			hns3pf_handle_link_change_event(hw, req);
+			/*
+			 * This message is reported by the firmware and is
+			 * reported in 'struct hns3_mbx_vf_to_pf_cmd' format.
+			 * Therefore, we should cast the req variable to
+			 * 'struct hns3_mbx_vf_to_pf_cmd' and then process it.
+			 */

I am asking just to double check, the 'msg' type is different of 'hns3_mbx_pf_to_vf_cmd' & 'hns3_mbx_vf_to_pf_cmd', one is 'uint8_t', other is 'uint16_t', and 'msg' is used in the function 'hns3pf_handle_link_change_event()'. Is the 'msg' usage still correct after this change?

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 523

Quoted 2 lines
drivers/net/hns3/hns3_mbx.c +2 -0
+			hns3pf_handle_link_change_event(hw,
+				(struct hns3_mbx_vf_to_pf_cmd *)req);

Will it be more readable if 'desc->data' cast to "struct hns3_mbx_vf_to_pf_cmd *" (instead of 'req')? Up to you, I can proceed with this one if you prefer.

#13 lore raw

Re: [dpdk-dev] [PATCH v3] net/hns3: fix parse link fails code fail

Quoted 42 lines · Ferruh Yigit
Quoted 41 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.

---
  drivers/net/hns3/hns3_mbx.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +4 -2
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 
  static void
  hns3pf_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+				struct hns3_mbx_vf_to_pf_cmd *req)
  {
  #define LINK_STATUS_OFFSET     1
  #define LINK_FAIL_CODE_OFFSET  2
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
  			hns3_handle_asserting_reset(hw, req);
  			break;
  		case HNS3_MBX_PUSH_LINK_STATUS:
-			hns3pf_handle_link_change_event(hw, req);
+			/*
+			 * This message is reported by the firmware and is
+			 * reported in 'struct hns3_mbx_vf_to_pf_cmd' format.
Quoted 9 lines

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 521

Quoted 3 lines
drivers/net/hns3/hns3_mbx.c +3 -0
+			 * Therefore, we should cast the req variable to
+			 * 'struct hns3_mbx_vf_to_pf_cmd' and then process it.
+			 */

I am asking just to double check, the 'msg' type is different of 'hns3_mbx_pf_to_vf_cmd' & 'hns3_mbx_vf_to_pf_cmd', one is 'uint8_t', other is 'uint16_t', and 'msg' is used in the function 'hns3pf_handle_link_change_event()'. Is the 'msg' usage still correct after this change?

Hi, it is correct.
Currently, msg from PF or VF are all handled in the same handler(hns3_dev_handle_mbx_msg), we do different handling according to different msg.
In futrue, we will separate handler from PF and VF.

Quoted 6 lines

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 523

Quoted 2 lines
drivers/net/hns3/hns3_mbx.c +2 -0
+			hns3pf_handle_link_change_event(hw,
+				(struct hns3_mbx_vf_to_pf_cmd *)req);

Will it be more readable if 'desc->data' cast to "struct hns3_mbx_vf_to_pf_cmd *" (instead of 'req')? Up to you, I can proceed with this one if you prefer. .

OK, thanks Ferruh.

Quoted 1 line
#14 lore raw

Re: [dpdk-dev] [PATCH v3] net/hns3: fix parse link fails code fail

Quoted 55 lines · Min Hu (Connor)
Quoted 43 lines · Ferruh Yigit
Quoted 42 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.
---
  drivers/net/hns3/hns3_mbx.c | 11 +++++++++--

  1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t
 link_fail_code)

    static void hns3pf_handle_link_change_event(struct hns3_hw *hw, -                  struct hns3_mbx_pf_to_vf_cmd *req) +                struct hns3_mbx_vf_to_pf_cmd *req) {
  #define LINK_STATUS_OFFSET     1
  #define LINK_FAIL_CODE_OFFSET  2

drivers/net/hns3/hns3_mbx.c +0 -0
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
               hns3_handle_asserting_reset(hw, req);
               break;

          case HNS3_MBX_PUSH_LINK_STATUS:
-            hns3pf_handle_link_change_event(hw, req); +            /*
+             * This message is reported by the firmware and is +             * reported in 'struct hns3_mbx_vf_to_pf_cmd' format. +             * Therefore, we should cast the req variable to

Quoted 9 lines
Quoted 2 lines

+             * 'struct hns3_mbx_vf_to_pf_cmd' and then process it. +             */

I am asking just to double check, the 'msg' type is different of 'hns3_mbx_pf_to_vf_cmd' & 'hns3_mbx_vf_to_pf_cmd', one is 'uint8_t', other is 'uint16_t', and 'msg' is used in the function 'hns3pf_handle_link_change_event()'.
Is the 'msg' usage still correct after this change?

Quoted 6 lines

Hi, it is correct.
Currently, msg from PF or VF are all handled in the same handler(hns3_dev_handle_mbx_msg), we do different handling according to different msg.
In futrue, we will separate handler from PF and VF.

Let me clarify what I mean, 'msg' is accessed with an index like "req->msg[LINK_FAIL_CODE_OFFSET]", and the 'req->msg' type is different as you change the 'req' type. It changes 'uint8_t' -> 'uint16_t', which makes "req->msg[LINK_FAIL_CODE_OFFSET]" point completely different location, can you please confirm this is expected/correct?

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

+            hns3pf_handle_link_change_event(hw, +                (struct hns3_mbx_vf_to_pf_cmd *)req);

Will it be more readable if 'desc->data' cast to "struct hns3_mbx_vf_to_pf_cmd *" (instead of 'req')? Up to you, I can proceed with this one if you prefer. .

OK, thanks Ferruh.

So do you prefer to continue as it is, or will there be a change?

#15 lore raw

Re: [dpdk-dev] [PATCH v3] net/hns3: fix parse link fails code fail

Quoted 63 lines · Ferruh Yigit
Quoted 55 lines · Min Hu (Connor)
Quoted 43 lines · Ferruh Yigit
Quoted 42 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.

---
   drivers/net/hns3/hns3_mbx.c | 11 +++++++++--
   1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +5 -2
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t
 link_fail_code)
     static void
   hns3pf_handle_link_change_event(struct hns3_hw *hw,
-                  struct hns3_mbx_pf_to_vf_cmd *req)
+                struct hns3_mbx_vf_to_pf_cmd *req)
   {
   #define LINK_STATUS_OFFSET     1
   #define LINK_FAIL_CODE_OFFSET  2
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
               hns3_handle_asserting_reset(hw, req);
               break;
           case HNS3_MBX_PUSH_LINK_STATUS:
-            hns3pf_handle_link_change_event(hw, req);
+            /*
+             * This message is reported by the firmware and is
+             * reported in 'struct hns3_mbx_vf_to_pf_cmd' format.
+             * Therefore, we should cast the req variable to
Quoted 9 lines

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 521

Quoted 2 lines
drivers/net/hns3/hns3_mbx.c +2 -0
+             * 'struct hns3_mbx_vf_to_pf_cmd' and then process it.
+             */

I am asking just to double check, the 'msg' type is different of 'hns3_mbx_pf_to_vf_cmd' & 'hns3_mbx_vf_to_pf_cmd', one is 'uint8_t', other is 'uint16_t', and 'msg' is used in the function 'hns3pf_handle_link_change_event()'.
Is the 'msg' usage still correct after this change?

Quoted 6 lines

Hi, it is correct.
Currently, msg from PF or VF are all handled in the same handler(hns3_dev_handle_mbx_msg), we do different handling according to different msg.
In futrue, we will separate handler from PF and VF.

Quoted 6 lines

Let me clarify what I mean, 'msg' is accessed with an index like "req->msg[LINK_FAIL_CODE_OFFSET]", and the 'req->msg' type is different as you change the 'req' type. It changes 'uint8_t' -> 'uint16_t', which makes "req->msg[LINK_FAIL_CODE_OFFSET]" point completely different location, can you please confirm this is expected/correct?

Hi, it is corect, we have tested it.

Quoted 11 lines
Quoted 8 lines
Quoted 7 lines

drivers/net/hns3/hns3_mbx.c hns3_dev_handle_mbx_msg(struct hns3_hw *hw) · line 523

Quoted 3 lines
drivers/net/hns3/hns3_mbx.c +2 -0
+            hns3pf_handle_link_change_event(hw,
+                (struct hns3_mbx_vf_to_pf_cmd *)req);

Will it be more readable if 'desc->data' cast to "struct hns3_mbx_vf_to_pf_cmd *" (instead of 'req')? Up to you, I can proceed with this one if you prefer. .

OK, thanks Ferruh.

So do you prefer to continue as it is, or will there be a change?

continue as it is, thanks.

Quoted 2 lines

.

Applied
#16 lore raw

Re: [dpdk-dev] [PATCH v3] net/hns3: fix parse link fails code fail

Quoted 66 lines · Min Hu (Connor)
Quoted 63 lines · Ferruh Yigit
Quoted 61 lines · Min Hu (Connor)
Quoted 43 lines · Ferruh Yigit
Quoted 42 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

The link fails code should be parsed using the structure hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes 109e4dd1bd7a ("net/hns3: get link state change through mailbox")

---
v3:
* get the parameter as 'struct hns3_mbx_vf_to_pf_cmd' at first place.

v2:
* kept original API interface.
---
   drivers/net/hns3/hns3_mbx.c | 11 +++++++++--

   1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_mbx.c +0 -0
index ba04ac9..31ab130 100644
@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t
 link_fail_code)

     static void hns3pf_handle_link_change_event(struct hns3_hw *hw, -                  struct hns3_mbx_pf_to_vf_cmd *req) +                struct hns3_mbx_vf_to_pf_cmd *req) {
   #define LINK_STATUS_OFFSET     1
   #define LINK_FAIL_CODE_OFFSET  2

drivers/net/hns3/hns3_mbx.c +0 -0
@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
                hns3_handle_asserting_reset(hw, req);
                break;

           case HNS3_MBX_PUSH_LINK_STATUS:
-            hns3pf_handle_link_change_event(hw, req); +            /*
+             * This message is reported by the firmware and is +             * reported in 'struct hns3_mbx_vf_to_pf_cmd' format. +             * Therefore, we should cast the req variable to

Quoted 9 lines
Quoted 2 lines

+             * 'struct hns3_mbx_vf_to_pf_cmd' and then process it. +             */

I am asking just to double check, the 'msg' type is different of 'hns3_mbx_pf_to_vf_cmd' & 'hns3_mbx_vf_to_pf_cmd', one is 'uint8_t', other is 'uint16_t', and 'msg' is used in the function 'hns3pf_handle_link_change_event()'.
Is the 'msg' usage still correct after this change?

Hi, it is correct.
Currently, msg from PF or VF are all handled in the same handler(hns3_dev_handle_mbx_msg), we do different handling according to different msg.
In futrue, we will separate handler from PF and VF.

Quoted 7 lines
Quoted 6 lines

Let me clarify what I mean, 'msg' is accessed with an index like "req->msg[LINK_FAIL_CODE_OFFSET]", and the 'req->msg' type is different as you change the 'req' type. It changes 'uint8_t' -> 'uint16_t', which makes "req->msg[LINK_FAIL_CODE_OFFSET]" point completely different location, can you please confirm this is expected/correct?

Hi, it is corect, we have tested it.

Applied to dpdk-next-net/main, thanks.

#17 lore raw

PATCH 4/4 net/hns3: delete unused macro and struct of mbx module

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

In hns3_mbx.h, some macro and structure were defined in previous versions but never used.

Fixes 463e748964f5 ("net/hns3: support mailbox")
---
 drivers/net/hns3/hns3_mbx.h | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/hns3/hns3_mbx.h +0 -10
index 0e9194d..86d32e6 100644
@@ -5,8 +5,6 @@
 #ifndef _HNS3_MBX_H_
 #define _HNS3_MBX_H_
 
-#define HNS3_MBX_VF_MSG_DATA_NUM	16
-
 enum HNS3_MBX_OPCODE {
 	HNS3_MBX_RESET = 0x01,          /* (VF -> PF) assert reset */
 	HNS3_MBX_ASSERTING_RESET,       /* (PF -> VF) PF is asserting reset */
@@ -80,8 +78,6 @@ enum hns3_mbx_link_fail_subcode {
 
 #define HNS3_MBX_MAX_MSG_SIZE	16
 #define HNS3_MBX_MAX_RESP_DATA_SIZE	8
-#define HNS3_MBX_RING_MAP_BASIC_MSG_NUM	3
-#define HNS3_MBX_RING_NODE_VARIABLE_NUM	3
 
 enum {
 	HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0,
@@ -147,12 +143,6 @@ struct hns3_vf_bind_vector_msg {
 	struct hns3_ring_chain_param param[HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM];
 };
 
-struct hns3_vf_rst_cmd {
-	uint8_t dest_vfid;
-	uint8_t vf_rst;
-	uint8_t rsv[22];
-};
-
 struct hns3_pf_rst_done_cmd {
 	uint8_t pf_rst_done;
 	uint8_t rsv[23];
Signature · 1 line
2.7.4
#18 lore raw
In reply to Min Hu (Connor)
Quoted 8 lines · Min Hu (Connor)

This patchset contains four bugfixes for hns3 PMD.

Chengwen Feng (4):
net/hns3: fix error mbx messages prompt errors net/hns3: fix PF miss link status notify message net/hns3: fix parse link fails code fail net/hns3: delete unused macro and struct of mbx module

Except from 3/4,
Series applied to dpdk-next-net/main, thanks.

3/4 can be handled separately.