Skip to contentSkip to conversation

bugfix for link for hns3 PMD

PATCH In review Min Hu (Connor) 2 participants 4 messages Apr 25, 2021 – Apr 29, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover bugfix for link for hns3 PMD

This patch set contains two bugfixes for hns3 PMD.

Huisong Li (2):
net/hns3: fix link status when port is stopped
net/hns3: fix link speed when port is down

 drivers/net/hns3/hns3_ethdev.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 net/hns3: fix link status when port is stopped

From: Huisong Li <[email protected]>

When port is stopped, link down should be reported to user. For HNS3 PF driver, link status comes from link status of hardware. If the port supports NCSI feature, hardware MAC will not be disabled. At this case, even if the port is stopped, the link status is still Up. So driver should set link down when the port is stopped.

Fixes 59fad0f32135 ("net/hns3: support link update operation")
---
 drivers/net/hns3/hns3_ethdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/hns3/hns3_ethdev.c +10 -0
index 60267e1..1496bb0 100644
@@ -2894,6 +2894,15 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete)
 	struct rte_eth_link new_link;
 	int ret;
 
+	/* When port is stopped, report link down. */
+	if (eth_dev->data->dev_started == 0) {
+		new_link.link_autoneg = mac->link_autoneg;
+		new_link.link_duplex = mac->link_duplex;
+		new_link.link_speed = ETH_SPEED_NUM_NONE;
+		new_link.link_status = ETH_LINK_DOWN;
+		goto out;
+	}
+
 	do {
 		ret = hns3_update_port_link_info(eth_dev);
 		if (ret) {
@@ -2911,6 +2920,7 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete)
 	memset(&new_link, 0, sizeof(new_link));
 	hns3_setup_linkstatus(eth_dev, &new_link);
 
+out:
 	return rte_eth_linkstatus_set(eth_dev, &new_link);
 }
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 net/hns3: fix link speed when port is down

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

When the port is link down state, it is meaningless to display the port link speed. It should be an undefined state.

Fixes 59fad0f32135 ("net/hns3: support link update operation")
---
 drivers/net/hns3/hns3_ethdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/hns3/hns3_ethdev.c +5 -3
index 1496bb0..5f7b4ab 100644
@@ -2867,16 +2867,18 @@ hns3_setup_linkstatus(struct rte_eth_dev *eth_dev,
 	case ETH_SPEED_NUM_50G:
 	case ETH_SPEED_NUM_100G:
 	case ETH_SPEED_NUM_200G:
-		new_link->link_speed = mac->link_speed;
+		if (mac->link_status)
+			new_link->link_speed = mac->link_speed;
 		break;
 	default:
 		if (mac->link_status)
 			new_link->link_speed = ETH_SPEED_NUM_UNKNOWN;
-		else
-			new_link->link_speed = ETH_SPEED_NUM_NONE;
 		break;
 	}
 
+	if (!mac->link_status)
+		new_link->link_speed = ETH_SPEED_NUM_NONE;
+
 	new_link->link_duplex = mac->link_duplex;
 	new_link->link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link->link_autoneg = mac->link_autoneg;
Signature · 1 line
2.7.4
#3 lore raw
In reply to Min Hu (Connor)
Quoted 6 lines · Min Hu (Connor)

This patch set contains two bugfixes for hns3 PMD.

Huisong Li (2):
net/hns3: fix link status when port is stopped
net/hns3: fix link speed when port is down

Series applied to dpdk-next-net/main, thanks.