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 1773841BAB; Thu, 2 Feb 2023 10:26:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8318C42DAD; Thu, 2 Feb 2023 10:26:03 +0100 (CET) Received: from smtpbg154.qq.com (smtpbg154.qq.com [15.184.224.54]) by mails.dpdk.org (Postfix) with ESMTP id 3A32C42D8A for ; Thu, 2 Feb 2023 10:26:00 +0100 (CET) X-QQ-mid: bizesmtp85t1675329957tc1if03f Received: from wxdbg.localdomain.com ( [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 02 Feb 2023 17:25:56 +0800 (CST) X-QQ-SSF: 01400000002000H0Y000B00A0000000 X-QQ-FEAT: CR3LFp2JE4nJ2ULr/3gHnScwWTD6dFAtQpgyR4UWmCla18yf+qHrCM0epa8+r YP43ti5KNgSxnxbM+bNIiURjdEiYPBVIFODNYc9zy9mwVH3Gq1tmcKVY9in/bJ1CY1tYAkP OQZRn3HXmnuEOm0Oy4KbpWsj4qvLSu2ENu1x6ic3/0NL+u+01zxzr1DD01xwnnbzpdSE5N7 O4Su1H0Y1lJEc2pHJlyIIciqImVKobmld7PWjglKtBJA/Tp5dOUYxC+CnsjyhPubzPcM5qV Z7xRize9q9tcUwtmlBhDXHWZKs+sxj+Ld3C/dDW7dD2T2y1ud6acz06S92VN5zENdsET7NP ctWvPseyXsKzdp1bQ4d4mi3Auqs3d/2N98z8aPG/NoAPegA+y0LfAVpZEhcBvrSAxTQvFrj CJQBZSdcuRTEhj45BbDoog== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Subject: [PATCH v2 08/10] net/txgbe: add chip overheat support Date: Thu, 2 Feb 2023 17:21:30 +0800 Message-Id: <20230202092132.3271910-9-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230202092132.3271910-1-jiawenwu@trustnetic.com> References: <20230118060039.3074016-1-jiawenwu@trustnetic.com> <20230202092132.3271910-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvr:qybglogicsvr5 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 Support to handle overheat interrupt. Signed-off-by: Jiawen Wu --- doc/guides/rel_notes/release_23_03.rst | 4 ++++ drivers/net/txgbe/base/txgbe_hw.c | 1 + drivers/net/txgbe/base/txgbe_phy.c | 22 ++++++++++++++++++ drivers/net/txgbe/base/txgbe_phy.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 31 ++++++++++++++++++++++++++ drivers/net/txgbe/txgbe_ethdev.h | 1 + 6 files changed, 60 insertions(+) diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 9c61bdbdcb..e64cb2d974 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -59,6 +59,10 @@ New Features * Added chip overheat detection support. +* **Updated Wangxun txgbe driver.** + + * Added chip overheat detection support. + Removed Items ------------- diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 8966453a03..e7c9754d26 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -2684,6 +2684,7 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw) phy->identify_sfp = txgbe_identify_module; phy->read_i2c_byte_unlocked = txgbe_read_i2c_byte_unlocked; phy->write_i2c_byte_unlocked = txgbe_write_i2c_byte_unlocked; + phy->check_overtemp = txgbe_check_overtemp; phy->reset = txgbe_reset_phy; /* MAC */ diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c index 87935abdaa..f4cadcc510 100644 --- a/drivers/net/txgbe/base/txgbe_phy.c +++ b/drivers/net/txgbe/base/txgbe_phy.c @@ -1363,6 +1363,28 @@ static void txgbe_i2c_stop(struct txgbe_hw *hw) wr32(hw, TXGBE_I2CENA, 0); } +/** + * txgbe_check_overtemp - Checks if an overtemp occurred. + * @hw: pointer to hardware structure + * + * Checks if the temp alarm status was triggered due to overtemp + **/ +s32 txgbe_check_overtemp(struct txgbe_hw *hw) +{ + s32 status = 0; + u32 ts_state; + + /* Check that the temp alarm status was triggered */ + ts_state = rd32(hw, TXGBE_TS_ALARM_ST); + + if (ts_state & TXGBE_TS_ALARM_ST_DALARM) + status = TXGBE_ERR_UNDERTEMP; + else if (ts_state & TXGBE_TS_ALARM_ST_ALARM) + status = TXGBE_ERR_OVERTEMP; + + return status; +} + static void txgbe_set_sgmii_an37_ability(struct txgbe_hw *hw) { diff --git a/drivers/net/txgbe/base/txgbe_phy.h b/drivers/net/txgbe/base/txgbe_phy.h index 5093d83b97..4dfe18930c 100644 --- a/drivers/net/txgbe/base/txgbe_phy.h +++ b/drivers/net/txgbe/base/txgbe_phy.h @@ -447,6 +447,7 @@ s32 txgbe_identify_module(struct txgbe_hw *hw); s32 txgbe_identify_sfp_module(struct txgbe_hw *hw); s32 txgbe_identify_qsfp_module(struct txgbe_hw *hw); +s32 txgbe_check_overtemp(struct txgbe_hw *hw); s32 txgbe_read_i2c_byte(struct txgbe_hw *hw, u8 byte_offset, u8 dev_addr, u8 *data); s32 txgbe_read_i2c_byte_unlocked(struct txgbe_hw *hw, u8 byte_offset, diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 86ef979b29..ce7cf2506d 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -1542,6 +1542,7 @@ txgbe_dev_phy_intr_setup(struct rte_eth_dev *dev) wr32(hw, TXGBE_GPIOINTEN, gpie); intr->mask_misc |= TXGBE_ICRMISC_GPIO; intr->mask_misc |= TXGBE_ICRMISC_ANDONE; + intr->mask_misc |= TXGBE_ICRMISC_HEAT; } int @@ -2672,6 +2673,28 @@ txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev) return NULL; } +static void +txgbe_dev_overheat(struct rte_eth_dev *dev) +{ + struct txgbe_hw *hw = TXGBE_DEV_HW(dev); + s32 temp_state; + + temp_state = hw->phy.check_overtemp(hw); + if (!temp_state) + return; + + if (temp_state == TXGBE_ERR_UNDERTEMP) { + PMD_DRV_LOG(CRIT, "Network adapter has been started again, " + "since the temperature has been back to normal state."); + wr32m(hw, TXGBE_PBRXCTL, TXGBE_PBRXCTL_ENA, TXGBE_PBRXCTL_ENA); + txgbe_dev_set_link_up(dev); + } else if (temp_state == TXGBE_ERR_OVERTEMP) { + PMD_DRV_LOG(CRIT, "Network adapter has been stopped because it has over heated."); + wr32m(hw, TXGBE_PBRXCTL, TXGBE_PBRXCTL_ENA, 0); + txgbe_dev_set_link_down(dev); + } +} + void txgbe_dev_setup_link_alarm_handler(void *param) { @@ -2974,6 +2997,9 @@ txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev, if (eicr & TXGBE_ICRMISC_GPIO) intr->flags |= TXGBE_FLAG_PHY_INTERRUPT; + if (eicr & TXGBE_ICRMISC_HEAT) + intr->flags |= TXGBE_FLAG_OVERHEAT; + return 0; } @@ -3086,6 +3112,11 @@ txgbe_dev_interrupt_action(struct rte_eth_dev *dev, } } + if (intr->flags & TXGBE_FLAG_OVERHEAT) { + txgbe_dev_overheat(dev); + intr->flags &= ~TXGBE_FLAG_OVERHEAT; + } + PMD_DRV_LOG(DEBUG, "enable intr immediately"); txgbe_enable_intr(dev); rte_intr_enable(intr_handle); diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 6a18865e23..c59b6370bb 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -30,6 +30,7 @@ #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) +#define TXGBE_FLAG_OVERHEAT (uint32_t)(1 << 6) /* * Defines that were not part of txgbe_type.h as they are not used by the -- 2.27.0