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 E1BA3A0A02; Thu, 25 Mar 2021 06:52:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E50F140E98; Thu, 25 Mar 2021 06:52:02 +0100 (CET) Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by mails.dpdk.org (Postfix) with ESMTP id BF98B140EA9 for ; Thu, 25 Mar 2021 06:51:57 +0100 (CET) X-QQ-mid: bizesmtp19t1616651513tqqckmb4 Received: from wxdbg.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 25 Mar 2021 13:51:52 +0800 (CST) X-QQ-SSF: 01400000000000D0E000000A0000000 X-QQ-FEAT: Ry58bBY793vRrZzGoj4A4updbSlyynOkPsRjECef3CxthWH2+J0iRxMQnM6Je UdfNGxxCW+VsWt8z2jWw9y6dSFe0mTW88YBdb1zdsEpbXpUF7X+kV+PRJKwx7sB2Xk8LBjp aUa1YGcz2gBnTXpr2BNMTiMTwYAAaseurSAy1caqG56qkREDMkah7qHXjoGpfU3z0c7dlwo rjsKUZIt24p68EFNdcCRihF3zn3eDzlmzgnSm1wg/fotmYhpbLqsJzdDKtzGj29D6hJNgy1 t9WpKTnKSDiU+TaTGhNnlpCsK4khMNKKZ35Tgcn3V2tHIpTK5CW3y+y7PQgOIYYcDzAK3A6 nqF7gG1kevpQrW//em7O8TT2dQcZw== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 25 Mar 2021 13:51:39 +0800 Message-Id: <20210325055141.629963-6-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210325055141.629963-1-jiawenwu@trustnetic.com> References: <20210325055141.629963-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v3 5/7] net/txgbe: handle AN interrupt and link update 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 Sender: "dev" Read AN interrupt from misc, and do the AN configuration action. When link status is down, PHY power should be restarted to config KR mode again. Signed-off-by: Jiawen Wu --- drivers/net/txgbe/base/txgbe_hw.c | 4 +- drivers/net/txgbe/base/txgbe_phy.c | 14 +++++++ drivers/net/txgbe/base/txgbe_phy.h | 1 + drivers/net/txgbe/base/txgbe_type.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 58 +++++++++++++++++++++++++---- drivers/net/txgbe/txgbe_ethdev.h | 7 ++-- 6 files changed, 73 insertions(+), 12 deletions(-) diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 9a82a329a..917bd947f 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -2574,8 +2574,10 @@ s32 txgbe_init_phy_raptor(struct txgbe_hw *hw) txgbe_get_copper_link_capabilities; } - if (phy->media_type == txgbe_media_type_backplane) + if (phy->media_type == txgbe_media_type_backplane) { mac->kr_handle = txgbe_kr_handle; + mac->bp_down_event = txgbe_bp_down_event; + } /* Set necessary function pointers based on PHY type */ switch (hw->phy.type) { diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c index 140857121..5402a064f 100644 --- a/drivers/net/txgbe/base/txgbe_phy.c +++ b/drivers/net/txgbe/base/txgbe_phy.c @@ -2304,6 +2304,20 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 autoc) mactxcfg | TXGBE_MACTXCFG_TXE); } +void txgbe_bp_down_event(struct txgbe_hw *hw) +{ + if (!(hw->devarg.auto_neg == 1)) + return; + + BP_LOG("restart phy power.\n"); + wr32_epcs(hw, VR_AN_KR_MODE_CL, 0); + wr32_epcs(hw, SR_AN_CTRL, 0); + wr32_epcs(hw, VR_AN_INTR_MSK, 0); + + msleep(1050); + txgbe_set_link_to_kr(hw, 0); +} + /** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure diff --git a/drivers/net/txgbe/base/txgbe_phy.h b/drivers/net/txgbe/base/txgbe_phy.h index ad4a915f8..d2f2b2f8e 100644 --- a/drivers/net/txgbe/base/txgbe_phy.h +++ b/drivers/net/txgbe/base/txgbe_phy.h @@ -454,6 +454,7 @@ s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset, u8 eeprom_data); u64 txgbe_autoc_read(struct txgbe_hw *hw); void txgbe_autoc_write(struct txgbe_hw *hw, u64 value); +void txgbe_bp_down_event(struct txgbe_hw *hw); s32 txgbe_kr_handle(struct txgbe_hw *hw); #endif /* _TXGBE_PHY_H_ */ diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 0ce469212..363e70733 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -601,6 +601,7 @@ struct txgbe_mac_info { s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee); s32 (*kr_handle)(struct txgbe_hw *hw); + void (*bp_down_event)(struct txgbe_hw *hw); enum txgbe_mac_type type; u8 addr[ETH_ADDR_LEN]; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 50cfe1a84..b2946a196 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -106,6 +106,7 @@ static void txgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, static void txgbe_dev_link_status_print(struct rte_eth_dev *dev); static int txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on); static int txgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev); +static int txgbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev); static int txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev); static int txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev); static int txgbe_dev_interrupt_action(struct rte_eth_dev *dev, @@ -1507,6 +1508,7 @@ txgbe_dev_phy_intr_setup(struct rte_eth_dev *dev) gpie |= TXGBE_GPIOBIT_6; wr32(hw, TXGBE_GPIOINTEN, gpie); intr->mask_misc |= TXGBE_ICRMISC_GPIO; + intr->mask_misc |= TXGBE_ICRMISC_ANDONE; } int @@ -1740,7 +1742,8 @@ txgbe_dev_start(struct rte_eth_dev *dev) hw->mac.enable_tx_laser(hw); } - err = hw->mac.check_link(hw, &speed, &link_up, 0); + if ((hw->subsystem_device_id & 0xFF) != TXGBE_DEV_ID_KR_KX_KX4) + err = hw->mac.check_link(hw, &speed, &link_up, 0); if (err) goto error; dev->data->dev_link.link_status = link_up; @@ -1783,6 +1786,7 @@ txgbe_dev_start(struct rte_eth_dev *dev) skip_link_setup: if (rte_intr_allow_others(intr_handle)) { + txgbe_dev_misc_interrupt_setup(dev); /* check if lsc interrupt is enabled */ if (dev->data->dev_conf.intr_conf.lsc != 0) txgbe_dev_lsc_interrupt_setup(dev, TRUE); @@ -2700,7 +2704,10 @@ txgbe_dev_link_update_share(struct rte_eth_dev *dev, } if (link_up == 0) { - if (hw->phy.media_type == txgbe_media_type_fiber) { + if ((hw->subsystem_device_id & 0xFF) == + TXGBE_DEV_ID_KR_KX_KX4) { + hw->mac.bp_down_event(hw); + } else if (hw->phy.media_type == txgbe_media_type_fiber) { intr->flags |= TXGBE_FLAG_NEED_LINK_CONFIG; rte_eal_alarm_set(10, txgbe_dev_setup_link_alarm_handler, dev); @@ -2835,6 +2842,20 @@ txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on) return 0; } +static int +txgbe_dev_misc_interrupt_setup(struct rte_eth_dev *dev) +{ + struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev); + u64 mask; + + mask = TXGBE_ICR_MASK; + mask &= (1ULL << TXGBE_MISC_VEC_ID); + intr->mask |= mask; + intr->mask_misc |= TXGBE_ICRMISC_GPIO; + intr->mask_misc |= TXGBE_ICRMISC_ANDONE; + return 0; +} + /** * It clears the interrupt causes and enables the interrupt. * It will be called once only during nic initialized. @@ -2850,9 +2871,11 @@ static int txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) { struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev); + u64 mask; - intr->mask[0] |= TXGBE_ICR_MASK; - intr->mask[1] |= TXGBE_ICR_MASK; + mask = TXGBE_ICR_MASK; + mask &= ~((1ULL << TXGBE_RX_VEC_START) - 1); + intr->mask |= mask; return 0; } @@ -2908,6 +2931,9 @@ txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev) if (eicr & TXGBE_ICRMISC_LSC) intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE; + if (eicr & TXGBE_ICRMISC_ANDONE) + intr->flags |= TXGBE_FLAG_NEED_AN_CONFIG; + if (eicr & TXGBE_ICRMISC_VFMBX) intr->flags |= TXGBE_FLAG_MAILBOX; @@ -2985,6 +3011,13 @@ txgbe_dev_interrupt_action(struct rte_eth_dev *dev, intr->flags &= ~TXGBE_FLAG_PHY_INTERRUPT; } + if (intr->flags & TXGBE_FLAG_NEED_AN_CONFIG) { + if (hw->devarg.auto_neg == 1 && hw->devarg.poll == 0) { + hw->mac.kr_handle(hw); + intr->flags &= ~TXGBE_FLAG_NEED_AN_CONFIG; + } + } + if (intr->flags & TXGBE_FLAG_NEED_LINK_UPDATE) { struct rte_eth_link link; @@ -2998,6 +3031,11 @@ txgbe_dev_interrupt_action(struct rte_eth_dev *dev, /* handle it 1 sec later, wait it being stable */ timeout = TXGBE_LINK_UP_CHECK_TIMEOUT; /* likely to down */ + else if ((hw->subsystem_device_id & 0xFF) == + TXGBE_DEV_ID_KR_KX_KX4 && + hw->devarg.auto_neg == 1) + /* handle it 2 sec later for backplane AN73 */ + timeout = 2000; else /* handle it 4 sec later, wait it being stable */ timeout = TXGBE_LINK_DOWN_CHECK_TIMEOUT; @@ -3008,10 +3046,12 @@ txgbe_dev_interrupt_action(struct rte_eth_dev *dev, (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 &= ~TXGBE_ICRMISC_LSC; + + intr->mask_orig = intr->mask; + /* only disable all misc interrupts */ + intr->mask &= ~(1ULL << TXGBE_MISC_VEC_ID); } } @@ -3072,8 +3112,10 @@ txgbe_dev_interrupt_delayed_handler(void *param) } /* restore original mask */ - intr->mask_misc = intr->mask_misc_orig; - intr->mask_misc_orig = 0; + intr->mask_misc |= TXGBE_ICRMISC_LSC; + + intr->mask = intr->mask_orig; + intr->mask_orig = 0; PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr); txgbe_enable_intr(dev); diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 5d4d9434a..8d46e6bb5 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -28,6 +28,7 @@ #define TXGBE_FLAG_PHY_INTERRUPT (uint32_t)(1 << 2) #define TXGBE_FLAG_MACSEC (uint32_t)(1 << 3) #define TXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4) +#define TXGBE_FLAG_NEED_AN_CONFIG (uint32_t)(1 << 5) /* * Defines that were not part of txgbe_type.h as they are not used by the @@ -138,9 +139,9 @@ struct txgbe_rte_flow_rss_conf { struct txgbe_interrupt { uint32_t flags; uint32_t mask_misc; - /* to save original mask during delayed handler */ - uint32_t mask_misc_orig; - uint32_t mask[2]; + uint32_t mask_misc_orig; /* save mask during delayed handler */ + uint64_t mask; + uint64_t mask_orig; /* save mask during delayed handler */ }; #define TXGBE_NB_STAT_MAPPING 32 -- 2.27.0