Skip to contentSkip to conversation

net/ice: fix link status recovery

PATCH Superseded Qiming Yang 2 participants 4 messages Nov 5, 2019 – Nov 12, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/ice: fix link status recovery

This patch fix a kernel driver link status issue by recovering link status when device stop.

Fixes e6161345d8a9 ("net/ice: support link status change")
---
 drivers/net/ice/ice_ethdev.c | 27 ++++++++++++++++++++++++++-
 drivers/net/ice/ice_ethdev.h |  1 +
 2 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +26 -1
index d746758..212e1c7 100644
@@ -2277,7 +2277,10 @@ ice_dev_stop(struct rte_eth_dev *dev)
 	/* Clear all queues and release mbufs */
 	ice_clear_queues(dev);
 
-	ice_dev_set_link_down(dev);
+	if (pf->init_link_status)
+		ice_dev_set_link_up(dev);
+	else
+		ice_dev_set_link_down(dev);
 
 	/* Clean datapath event and queue/vec mapping */
 	rte_intr_efd_disable(intr_handle);
@@ -2648,6 +2651,26 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void ice_get_init_link_status(struct rte_eth_dev *dev)
+{
+	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
+	struct ice_link_status link_status;
+	int ret;
+
+	ret = ice_aq_get_link_info(hw->port_info, enable_lse,
+				   &link_status, NULL);
+	if (ret != ICE_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Failed to get link info");
+		pf->init_link_status = false;
+		return;
+	}
+
+	if (link_status.link_info & ICE_AQ_LINK_UP)
+		pf->init_link_status = true;
+}
+
 static int
 ice_dev_start(struct rte_eth_dev *dev)
 {
@@ -2717,6 +2740,8 @@ ice_dev_start(struct rte_eth_dev *dev)
 	if (ret != ICE_SUCCESS)
 		PMD_DRV_LOG(WARNING, "Fail to set phy mask");
 
+	ice_get_init_link_status(dev);
+
 	ice_dev_set_link_up(dev);
 
 	/* Call get_link_info aq commond to enable/disable LSE */
drivers/net/ice/ice_ethdev.h +1 -0
index de67e59..27db4e7 100644
@@ -369,6 +369,7 @@ struct ice_pf {
 	struct ice_parser_list rss_parser_list;
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
+	bool init_link_status;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
Signature · 1 line
2.9.5
#1 lore raw
Quoted 1 line · Qiming Yang

This patch fix a kernel driver link status issue by recovering

s/fix/fixes

Quoted 1 line

link status when device stop.

s/stop/stops

Quoted 27 lines
Fixes e6161345d8a9 ("net/ice: support link status change")

---
drivers/net/ice/ice_ethdev.c | 27 ++++++++++++++++++++++++++- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
index d746758..212e1c7 100644
@@ -2277,7 +2277,10 @@ ice_dev_stop(struct rte_eth_dev *dev)
 	/* Clear all queues and release mbufs */
 	ice_clear_queues(dev);
 
-	ice_dev_set_link_down(dev);
+	if (pf->init_link_status)
+		ice_dev_set_link_up(dev);
+	else
+		ice_dev_set_link_down(dev);
 
 	/* Clean datapath event and queue/vec mapping */
 	rte_intr_efd_disable(intr_handle);

drivers/net/ice/ice_ethdev.c ice_rxq_intr_setup(struct rte_eth_dev *dev) · line 2654

Quoted 4 lines
drivers/net/ice/ice_ethdev.c +1 -0
@@ -2648,6 +2651,26 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void ice_get_init_link_status(struct rte_eth_dev *dev)

Put the return type in a single line.

Thanks,
Xiaolong

Quoted 46 lines
drivers/net/ice/ice_ethdev.c +19 -0
+{
+	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
+	struct ice_link_status link_status;
+	int ret;
+
+	ret = ice_aq_get_link_info(hw->port_info, enable_lse,
+				   &link_status, NULL);
+	if (ret != ICE_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Failed to get link info");
+		pf->init_link_status = false;
+		return;
+	}
+
+	if (link_status.link_info & ICE_AQ_LINK_UP)
+		pf->init_link_status = true;
+}
+

static int
ice_dev_start(struct rte_eth_dev *dev)
{

drivers/net/ice/ice_ethdev.c +2 -0
@@ -2717,6 +2740,8 @@ ice_dev_start(struct rte_eth_dev *dev)
 	if (ret != ICE_SUCCESS)
 		PMD_DRV_LOG(WARNING, "Fail to set phy mask");
 
+	ice_get_init_link_status(dev);
+
 	ice_dev_set_link_up(dev);
 
 	/* Call get_link_info aq commond to enable/disable LSE */
drivers/net/ice/ice_ethdev.h +1 -0
index de67e59..27db4e7 100644
@@ -369,6 +369,7 @@ struct ice_pf {
 	struct ice_parser_list rss_parser_list;
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
+	bool init_link_status;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
Signature · 1 line
2.9.5
#2 lore raw

PATCH v3 1/1 net/ice: fix link status recovery

In reply to Qiming Yang

This patch fixes a kernel driver link status issue by recovering link status when device stops.

Fixes e6161345d8a9 ("net/ice: support link status change")
---
 drivers/net/ice/ice_ethdev.c | 28 +++++++++++++++++++++++++++-
 drivers/net/ice/ice_ethdev.h |  1 +
 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +27 -1
index d746758..14ca5e6 100644
@@ -2277,7 +2277,10 @@ ice_dev_stop(struct rte_eth_dev *dev)
 	/* Clear all queues and release mbufs */
 	ice_clear_queues(dev);
 
-	ice_dev_set_link_down(dev);
+	if (pf->init_link_status)
+		ice_dev_set_link_up(dev);
+	else
+		ice_dev_set_link_down(dev);
 
 	/* Clean datapath event and queue/vec mapping */
 	rte_intr_efd_disable(intr_handle);
@@ -2648,6 +2651,27 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void
+ice_get_init_link_status(struct rte_eth_dev *dev)
+{
+	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
+	struct ice_link_status link_status;
+	int ret;
+
+	ret = ice_aq_get_link_info(hw->port_info, enable_lse,
+				   &link_status, NULL);
+	if (ret != ICE_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Failed to get link info");
+		pf->init_link_status = false;
+		return;
+	}
+
+	if (link_status.link_info & ICE_AQ_LINK_UP)
+		pf->init_link_status = true;
+}
+
 static int
 ice_dev_start(struct rte_eth_dev *dev)
 {
@@ -2717,6 +2741,8 @@ ice_dev_start(struct rte_eth_dev *dev)
 	if (ret != ICE_SUCCESS)
 		PMD_DRV_LOG(WARNING, "Fail to set phy mask");
 
+	ice_get_init_link_status(dev);
+
 	ice_dev_set_link_up(dev);
 
 	/* Call get_link_info aq commond to enable/disable LSE */
drivers/net/ice/ice_ethdev.h +1 -0
index de67e59..27db4e7 100644
@@ -369,6 +369,7 @@ struct ice_pf {
 	struct ice_parser_list rss_parser_list;
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
+	bool init_link_status;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
Signature · 1 line
2.9.5
Acked-by on v3 1/1 Applied
#3 lore raw
Quoted 12 lines · Qiming Yang

This patch fixes a kernel driver link status issue by recovering link status when device stops.

Fixes e6161345d8a9 ("net/ice: support link status change")

---
drivers/net/ice/ice_ethdev.c | 28 +++++++++++++++++++++++++++- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 28 insertions(+), 1 deletion(-)

Applied to dpdk-next-net-intel. Thanks.