patch 'net/ngbe: fix missed link interrupt' has been queued to stable release 21.11.1

Kevin Traynor ktraynor at redhat.com
Mon Feb 21 16:36:09 CET 2022


Hi,

FYI, your patch has been queued to stable release 21.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/26/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/3698c17f425d80d0c3694f0f4996cb57e459c485

Thanks.

Kevin

---
>From 3698c17f425d80d0c3694f0f4996cb57e459c485 Mon Sep 17 00:00:00 2001
From: Jiawen Wu <jiawenwu at trustnetic.com>
Date: Wed, 9 Feb 2022 18:42:03 +0800
Subject: [PATCH] net/ngbe: fix missed link interrupt

[ upstream commit 0360c23f648116b3101795e551b60fbba881247a ]

When the port is started and stopped continuously and quickly, one
interrupt cannot be handled in time, which will cause subsequent
interrupts to be lost, so that link status will cannot be updated.

Fixes: b9246b8fa280 ("net/ngbe: support link update")

Signed-off-by: Jiawen Wu <jiawenwu at trustnetic.com>
---
 drivers/net/ngbe/ngbe_ethdev.c | 119 +++++++++++----------------------
 drivers/net/ngbe/ngbe_ethdev.h |   1 +
 2 files changed, 41 insertions(+), 79 deletions(-)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 180489ce38..8e31234442 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -90,5 +90,4 @@ static int ngbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev);
 static int ngbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static void ngbe_dev_interrupt_handler(void *param);
-static void ngbe_dev_interrupt_delayed_handler(void *param);
 static void ngbe_configure_msix(struct rte_eth_dev *dev);
 
@@ -944,4 +943,7 @@ ngbe_dev_start(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
+	/* Stop the link setup handler before resetting the HW. */
+	rte_eal_alarm_cancel(ngbe_dev_setup_link_alarm_handler, dev);
+
 	/* disable uio/vfio intr/eventfd mapping */
 	rte_intr_disable(intr_handle);
@@ -1133,4 +1135,6 @@ ngbe_dev_stop(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
+	rte_eal_alarm_cancel(ngbe_dev_setup_link_alarm_handler, dev);
+
 	if ((hw->sub_system_id & NGBE_OEM_MASK) == NGBE_LY_M88E1512_SFP ||
 		(hw->sub_system_id & NGBE_OEM_MASK) == NGBE_LY_YT8521S_SFP) {
@@ -1802,4 +1806,22 @@ ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 }
 
+void
+ngbe_dev_setup_link_alarm_handler(void *param)
+{
+	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
+	u32 speed;
+	bool autoneg = false;
+
+	speed = hw->phy.autoneg_advertised;
+	if (!speed)
+		hw->mac.get_link_capabilities(hw, &speed, &autoneg);
+
+	hw->mac.setup_link(hw, speed, true);
+
+	intr->flags &= ~NGBE_FLAG_NEED_LINK_CONFIG;
+}
+
 /* return 0 means link status changed, -1 means not changed */
 int
@@ -1839,6 +1861,14 @@ ngbe_dev_link_update_share(struct rte_eth_dev *dev,
 	}
 
-	if (!link_up)
+	if (!link_up) {
+		if (hw->phy.media_type == ngbe_media_type_fiber &&
+			hw->phy.type != ngbe_phy_mvl_sfi) {
+			intr->flags |= NGBE_FLAG_NEED_LINK_CONFIG;
+			rte_eal_alarm_set(10,
+				ngbe_dev_setup_link_alarm_handler, dev);
+		}
+
 		return rte_eth_linkstatus_set(dev, &link);
+	}
 
 	intr->flags &= ~NGBE_FLAG_NEED_LINK_CONFIG;
@@ -2063,7 +2093,4 @@ ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
 	struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
 
-	/* clear all cause mask */
-	ngbe_disable_intr(hw);
-
 	/* read-on-clear nic registers here */
 	eicr = ((u32 *)hw->isb_mem)[NGBE_ISB_MISC];
@@ -2085,4 +2112,6 @@ ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
 		intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE;
 
+	((u32 *)hw->isb_mem)[NGBE_ISB_MISC] = 0;
+
 	return 0;
 }
@@ -2137,5 +2166,4 @@ ngbe_dev_interrupt_action(struct rte_eth_dev *dev)
 {
 	struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
-	int64_t timeout;
 
 	PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
@@ -2152,83 +2180,16 @@ ngbe_dev_interrupt_action(struct rte_eth_dev *dev)
 		rte_eth_linkstatus_get(dev, &link);
 
-		ngbe_dev_link_update(dev, 0);
-
-		/* likely to up */
-		if (link.link_status != RTE_ETH_LINK_UP)
-			/* handle it 1 sec later, wait it being stable */
-			timeout = NGBE_LINK_UP_CHECK_TIMEOUT;
-		/* likely to down */
-		else
-			/* handle it 4 sec later, wait it being stable */
-			timeout = NGBE_LINK_DOWN_CHECK_TIMEOUT;
-
-		ngbe_dev_link_status_print(dev);
-		if (rte_eal_alarm_set(timeout * 1000,
-				      ngbe_dev_interrupt_delayed_handler,
-				      (void *)dev) < 0) {
-			PMD_DRV_LOG(ERR, "Error setting alarm");
-		} else {
-			/* remember original mask */
-			intr->mask_misc_orig = intr->mask_misc;
-			/* only disable lsc interrupt */
-			intr->mask_misc &= ~NGBE_ICRMISC_PHY;
-
-			intr->mask_orig = intr->mask;
-			/* only disable all misc interrupts */
-			intr->mask &= ~(1ULL << NGBE_MISC_VEC_ID);
-		}
-	}
-
-	PMD_DRV_LOG(DEBUG, "enable intr immediately");
-	ngbe_enable_intr(dev);
-
-	return 0;
-}
-
-/**
- * Interrupt handler which shall be registered for alarm callback for delayed
- * handling specific interrupt to wait for the stable nic state. As the
- * NIC interrupt state is not stable for ngbe after link is just down,
- * it needs to wait 4 seconds to get the stable status.
- *
- * @param param
- *  The address of parameter (struct rte_eth_dev *) registered before.
- */
-static void
-ngbe_dev_interrupt_delayed_handler(void *param)
-{
-	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
-	struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
-	struct ngbe_hw *hw = ngbe_dev_hw(dev);
-	uint32_t eicr;
-
-	ngbe_disable_intr(hw);
-
-	eicr = ((u32 *)hw->isb_mem)[NGBE_ISB_MISC];
-	if (eicr & NGBE_ICRMISC_VFMBX)
-		ngbe_pf_mbx_process(dev);
-
-	if (intr->flags & NGBE_FLAG_NEED_LINK_UPDATE) {
 		ngbe_dev_link_update(dev, 0);
 		intr->flags &= ~NGBE_FLAG_NEED_LINK_UPDATE;
 		ngbe_dev_link_status_print(dev);
-		rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL);
+		if (dev->data->dev_link.link_speed != link.link_speed)
+			rte_eth_dev_callback_process(dev,
+				RTE_ETH_EVENT_INTR_LSC, NULL);
 	}
 
-	if (intr->flags & NGBE_FLAG_MACSEC) {
-		rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
-					      NULL);
-		intr->flags &= ~NGBE_FLAG_MACSEC;
-	}
-
-	/* restore original mask */
-	intr->mask_misc = intr->mask_misc_orig;
-	intr->mask_misc_orig = 0;
-	intr->mask = intr->mask_orig;
-	intr->mask_orig = 0;
-
-	PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
+	PMD_DRV_LOG(DEBUG, "enable intr immediately");
 	ngbe_enable_intr(dev);
+
+	return 0;
 }
 
diff --git a/drivers/net/ngbe/ngbe_ethdev.h b/drivers/net/ngbe/ngbe_ethdev.h
index bb96f6a5e7..8d500fd38c 100644
--- a/drivers/net/ngbe/ngbe_ethdev.h
+++ b/drivers/net/ngbe/ngbe_ethdev.h
@@ -342,4 +342,5 @@ void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
 void ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
 						  int mask);
+void ngbe_dev_setup_link_alarm_handler(void *param);
 void ngbe_read_stats_registers(struct ngbe_hw *hw,
 			   struct ngbe_hw_stats *hw_stats);
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-02-21 15:22:48.440338631 +0000
+++ 0180-net-ngbe-fix-missed-link-interrupt.patch	2022-02-21 15:22:44.355704721 +0000
@@ -1 +1 @@
-From 0360c23f648116b3101795e551b60fbba881247a Mon Sep 17 00:00:00 2001
+From 3698c17f425d80d0c3694f0f4996cb57e459c485 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 0360c23f648116b3101795e551b60fbba881247a ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org



More information about the stable mailing list