From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F11CBA04A6; Wed, 9 Feb 2022 11:35:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB95141144; Wed, 9 Feb 2022 11:35:45 +0100 (CET) Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by mails.dpdk.org (Postfix) with ESMTP id CE70E4115B for ; Wed, 9 Feb 2022 11:35:42 +0100 (CET) X-QQ-mid: bizesmtp37t1644402937tny8hlc2 Received: from wxdbg.localdomain.com (unknown [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 09 Feb 2022 18:35:36 +0800 (CST) X-QQ-SSF: 01400000002000F0L000B00A0000000 X-QQ-FEAT: XjLdFDjXUO3vbIII7KArOthq6eGt8UHoXsMJpo7HzoOxf3BmP7VKlvTlyekLS Z0xxC7mZtQyvv354huo/fbmmvp73Gb69lXExFjPf2W4RgFpqCcUeIGei2t/kOM3wSW70fcG FpUwcWK1/0B44zTPVKcRyd1GiWjshZmCz8l4i2anqbNYpoK2Pqd+yxbpBQDKaBXcZBvTf0k xCydqptwNUL0j2U2mrNkSY6ziISBuOg0eTcH8hA+hd5GaKbuwz8sP5XuMhzwyoGYwHy6ogX e4YC9swHyPdF5IlXLXTQE5TfRk26s21GZl5/jyXAqFGtVNsNo57notO+ZRbnmnf8qKcLlJL Fe9OA4/VPoWt+9dabFSUw4S25j7fnawHpvx/iEeU85BEs/EE5U= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu , stable@dpdk.org Subject: [PATCH v2 02/12] net/ngbe: fix link interrupt sometimes lost Date: Wed, 9 Feb 2022 18:42:03 +0800 Message-Id: <20220209104213.602728-3-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220209104213.602728-1-jiawenwu@trustnetic.com> References: <20220209104213.602728-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/ngbe/ngbe_ethdev.c | 115 +++++++++++---------------------- drivers/net/ngbe/ngbe_ethdev.h | 1 + 2 files changed, 39 insertions(+), 77 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 @@ -89,7 +89,6 @@ static int ngbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev); 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); #define NGBE_SET_HWSTRIP(h, q) do {\ @@ -943,6 +942,9 @@ 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); @@ -1132,6 +1134,8 @@ 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) { /* gpio0 is used to power on/off control*/ @@ -1801,6 +1805,24 @@ ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev) return NULL; } +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 ngbe_dev_link_update_share(struct rte_eth_dev *dev, @@ -1838,8 +1860,16 @@ ngbe_dev_link_update_share(struct rte_eth_dev *dev, return rte_eth_linkstatus_set(dev, &link); } - 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; link.link_status = RTE_ETH_LINK_UP; @@ -2062,9 +2092,6 @@ ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev) struct ngbe_hw *hw = ngbe_dev_hw(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]; PMD_DRV_LOG(DEBUG, "eicr %x", eicr); @@ -2084,6 +2111,8 @@ ngbe_dev_interrupt_get_status(struct rte_eth_dev *dev) if (eicr & NGBE_ICRMISC_GPIO) intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE; + ((u32 *)hw->isb_mem)[NGBE_ISB_MISC] = 0; + return 0; } @@ -2136,7 +2165,6 @@ static int 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,31 +2180,11 @@ 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; - + intr->flags &= ~NGBE_FLAG_NEED_LINK_UPDATE; 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); - } + if (dev->data->dev_link.link_speed != link.link_speed) + rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_INTR_LSC, NULL); } PMD_DRV_LOG(DEBUG, "enable intr immediately"); @@ -2185,53 +2193,6 @@ ngbe_dev_interrupt_action(struct rte_eth_dev *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 (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); - ngbe_enable_intr(dev); -} - /** * Interrupt handler triggered by NIC for handling * specific interrupt. 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 @@ -341,6 +341,7 @@ void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on); 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.21.0.windows.1