DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/9] Wangxun bug fixes
@ 2023-06-14  2:34 Jiawen Wu
  2023-06-14  2:34 ` [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug Jiawen Wu
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu

Fix some bugs for txgbe and ngbe.

Jiawen Wu (9):
  net/txgbe: fix Tx failure with fiber hotplug
  net/txgbe: fix interrupt enable mask
  net/txgbe: fix issues caused by MNG veto bit setting
  net/txgbe: fix to set autoneg for 1G speed
  net/txgbe: fix device extended stats
  net/ngbe: fix device extended stats
  net/ngbe: fix issues caused by MNG veto bit setting
  net/ngbe: fix link status in no LSC mode
  net/ngbe: remove redundant codes

 drivers/net/ngbe/base/ngbe_hw.c      | 10 +++++---
 drivers/net/ngbe/base/ngbe_phy_rtl.c | 22 +++++++++++++++++
 drivers/net/ngbe/base/ngbe_phy_rtl.h |  2 ++
 drivers/net/ngbe/base/ngbe_phy_yt.c  | 16 ++++++------
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/ngbe_ethdev.c       | 32 +++---------------------
 drivers/net/ngbe/ngbe_ethdev.h       |  1 -
 drivers/net/txgbe/base/txgbe_hw.c    | 37 +++++++++++++---------------
 drivers/net/txgbe/base/txgbe_phy.c   | 22 +++++++++++------
 drivers/net/txgbe/base/txgbe_regs.h  | 14 ++++++++++-
 drivers/net/txgbe/base/txgbe_type.h  |  1 +
 drivers/net/txgbe/txgbe_ethdev.c     | 34 ++++++++++++++++++++++++-
 12 files changed, 124 insertions(+), 68 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 2/9] net/txgbe: fix interrupt enable mask Jiawen Wu
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

Under heavy traffic, unpluging and pluging fiber optic cables may cause Tx
failure. The reason is that there is still traffic passing through at PCS
VR reset, during txgbe_set_link_to_*. So totally disable Rx and Tx before
PCS VR reset to fix it.

Fixes: 01c3cf5c85a7 ("net/txgbe: add autoneg control read and write")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/base/txgbe_phy.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c
index f4cadcc510..1eb45b068a 100644
--- a/drivers/net/txgbe/base/txgbe_phy.c
+++ b/drivers/net/txgbe/base/txgbe_phy.c
@@ -1541,8 +1541,9 @@ txgbe_set_link_to_kx4(struct txgbe_hw *hw, bool autoneg)
 		goto out;
 	}
 
-	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE,
-			~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE, ~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACRXCFG, TXGBE_MACRXCFG_ENA, ~TXGBE_MACRXCFG_ENA);
+	hw->mac.disable_sec_tx_path(hw);
 
 	/* 2. Disable xpcs AN-73 */
 	if (!autoneg)
@@ -1756,8 +1757,9 @@ txgbe_set_link_to_kx(struct txgbe_hw *hw,
 		goto out;
 	}
 
-	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE,
-				~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE, ~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACRXCFG, TXGBE_MACRXCFG_ENA, ~TXGBE_MACRXCFG_ENA);
+	hw->mac.disable_sec_tx_path(hw);
 
 	/* 2. Disable xpcs AN-73 */
 	if (!autoneg)
@@ -1963,8 +1965,9 @@ txgbe_set_link_to_sfi(struct txgbe_hw *hw,
 		goto out;
 	}
 
-	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE,
-			~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACTXCFG, TXGBE_MACTXCFG_TXE, ~TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACRXCFG, TXGBE_MACRXCFG_ENA, ~TXGBE_MACRXCFG_ENA);
+	hw->mac.disable_sec_tx_path(hw);
 
 	/* 2. Disable xpcs AN-73 */
 	wr32_epcs(hw, SR_AN_CTRL, 0x0);
@@ -2315,6 +2318,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 autoc)
 			txgbe_set_sgmii_an37_ability(hw);
 	}
 
+	hw->mac.enable_sec_tx_path(hw);
+
 	if (speed == TXGBE_LINK_SPEED_10GB_FULL)
 		mactxcfg = TXGBE_MACTXCFG_SPEED_10G;
 	else if (speed == TXGBE_LINK_SPEED_1GB_FULL)
@@ -2324,6 +2329,7 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 autoc)
 	wr32m(hw, TXGBE_MACTXCFG,
 		TXGBE_MACTXCFG_SPEED_MASK | TXGBE_MACTXCFG_TXE,
 		mactxcfg | TXGBE_MACTXCFG_TXE);
+	wr32m(hw, TXGBE_MACRXCFG, TXGBE_MACRXCFG_ENA, TXGBE_MACRXCFG_ENA);
 }
 
 void txgbe_bp_down_event(struct txgbe_hw *hw)
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/9] net/txgbe: fix interrupt enable mask
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
  2023-06-14  2:34 ` [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 3/9] net/txgbe: fix issues caused by MNG veto bit setting Jiawen Wu
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

When using no LSC mode, GPIO interrupt can still cause
txgbe_dev_interrupt_delayed_handler() to be called, with
TXGBE_FLAG_NEED_LINK_UPDATE to be set. So add a LSC condition on
intr->mask_misc.

Fixes: 2fc745e6b606 ("net/txgbe: add interrupt operation")
Fixes: d3bb4a04eac1 ("net/txgbe: add SFP hotplug identification")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/txgbe_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index a3d7461951..5eff1a766e 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -3232,7 +3232,8 @@ txgbe_dev_interrupt_delayed_handler(void *param)
 	}
 
 	/* restore original mask */
-	intr->mask_misc |= TXGBE_ICRMISC_LSC;
+	if (dev->data->dev_conf.intr_conf.lsc == 1)
+		intr->mask_misc |= TXGBE_ICRMISC_LSC;
 
 	intr->mask = intr->mask_orig;
 	intr->mask_orig = 0;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/9] net/txgbe: fix issues caused by MNG veto bit setting
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
  2023-06-14  2:34 ` [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug Jiawen Wu
  2023-06-14  2:34 ` [PATCH 2/9] net/txgbe: fix interrupt enable mask Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 4/9] net/txgbe: fix to set autoneg for 1G speed Jiawen Wu
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

In the new firmware, MNG veto bit is set by default for new features.
It leads to several issues, so driver makes the following changes:
1. Change the way by sending reset command to firmware to LAN reset.
   So that MNG domain will not be reset.
2. Change the hardware flush register since the original register cannot
   be read temporarily after LAN reset.
3. Remove checking of MNG veto bit when handling Tx laser.
4. Workaround for GPIO interrupt lost.

Fixes: f58ae2fcfea6 ("net/txgbe: add HW init and reset operation")
Fixes: e4c515a7bc7e ("net/txgbe: add multi-speed link setup")
Fixes: d3bb4a04eac1 ("net/txgbe: add SFP hotplug identification")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/base/txgbe_hw.c   | 23 +++--------------------
 drivers/net/txgbe/base/txgbe_regs.h | 14 +++++++++++++-
 drivers/net/txgbe/txgbe_ethdev.c    | 27 +++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c
index e7c9754d26..2952c408fd 100644
--- a/drivers/net/txgbe/base/txgbe_hw.c
+++ b/drivers/net/txgbe/base/txgbe_hw.c
@@ -2988,10 +2988,6 @@ void txgbe_disable_tx_laser_multispeed_fiber(struct txgbe_hw *hw)
 {
 	u32 esdp_reg = rd32(hw, TXGBE_GPIODATA);
 
-	/* Blocked by MNG FW so bail */
-	if (txgbe_check_reset_blocked(hw))
-		return;
-
 	if (txgbe_close_notify(hw))
 		txgbe_led_off(hw, TXGBE_LEDCTL_UP | TXGBE_LEDCTL_10G |
 				TXGBE_LEDCTL_1G | TXGBE_LEDCTL_ACTIVE);
@@ -3039,10 +3035,6 @@ void txgbe_enable_tx_laser_multispeed_fiber(struct txgbe_hw *hw)
  **/
 void txgbe_flap_tx_laser_multispeed_fiber(struct txgbe_hw *hw)
 {
-	/* Blocked by MNG FW so bail */
-	if (txgbe_check_reset_blocked(hw))
-		return;
-
 	if (hw->mac.autotry_restart) {
 		txgbe_disable_tx_laser_multispeed_fiber(hw);
 		txgbe_enable_tx_laser_multispeed_fiber(hw);
@@ -3433,18 +3425,9 @@ s32 txgbe_reset_hw(struct txgbe_hw *hw)
 	autoc = hw->mac.autoc_read(hw);
 
 mac_reset_top:
-	/*
-	 * Issue global reset to the MAC.  Needs to be SW reset if link is up.
-	 * If link reset is used when link is up, it might reset the PHY when
-	 * mng is using it.  If link is down or the flag to force full link
-	 * reset is set, then perform link reset.
-	 */
-	if (txgbe_mng_present(hw)) {
-		txgbe_hic_reset(hw);
-	} else {
-		wr32(hw, TXGBE_RST, TXGBE_RST_LAN(hw->bus.lan_id));
-		txgbe_flush(hw);
-	}
+	/* Do LAN reset, the MNG domain will not be reset. */
+	wr32(hw, TXGBE_RST, TXGBE_RST_LAN(hw->bus.lan_id));
+	txgbe_flush(hw);
 	usec_delay(10);
 
 	txgbe_reset_misc(hw);
diff --git a/drivers/net/txgbe/base/txgbe_regs.h b/drivers/net/txgbe/base/txgbe_regs.h
index bc2854b01a..79290a7afe 100644
--- a/drivers/net/txgbe/base/txgbe_regs.h
+++ b/drivers/net/txgbe/base/txgbe_regs.h
@@ -1885,7 +1885,19 @@ po32m(struct txgbe_hw *hw, u32 reg, u32 mask, u32 expect, u32 *actual,
 }
 
 /* flush all write operations */
-#define txgbe_flush(hw) rd32(hw, 0x00100C)
+static inline void txgbe_flush(struct txgbe_hw *hw)
+{
+	switch (hw->mac.type) {
+	case txgbe_mac_raptor:
+		rd32(hw, TXGBE_PWR);
+		break;
+	case txgbe_mac_raptor_vf:
+		rd32(hw, TXGBE_VFSTATUS);
+		break;
+	default:
+		break;
+	}
+}
 
 #define rd32a(hw, reg, idx) ( \
 	rd32((hw), (reg) + ((idx) << 2)))
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 5eff1a766e..36c74d353d 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -1531,6 +1531,25 @@ txgbe_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void txgbe_reinit_gpio_intr(struct txgbe_hw *hw)
+{
+	u32 reg;
+
+	wr32(hw, TXGBE_GPIOINTMASK, 0xFF);
+	reg = rd32(hw, TXGBE_GPIORAWINTSTAT);
+
+	if (reg & TXGBE_GPIOBIT_2)
+		wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_2);
+
+	if (reg & TXGBE_GPIOBIT_3)
+		wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_3);
+
+	if (reg & TXGBE_GPIOBIT_6)
+		wr32(hw, TXGBE_GPIOEOI, TXGBE_GPIOBIT_6);
+
+	wr32(hw, TXGBE_GPIOINTMASK, 0);
+}
+
 static void
 txgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
 {
@@ -1680,6 +1699,10 @@ txgbe_dev_start(struct rte_eth_dev *dev)
 	hw->mac.get_link_status = true;
 	hw->dev_start = true;
 
+	/* workaround for GPIO intr lost when mng_veto bit is set */
+	if (txgbe_check_reset_blocked(hw))
+		txgbe_reinit_gpio_intr(hw);
+
 	/* configure PF module if SRIOV enabled */
 	txgbe_pf_host_configure(dev);
 
@@ -1897,6 +1920,10 @@ txgbe_dev_stop(struct rte_eth_dev *dev)
 	/* disable interrupts */
 	txgbe_disable_intr(hw);
 
+	/* workaround for GPIO intr lost when mng_veto bit is set */
+	if (txgbe_check_reset_blocked(hw))
+		txgbe_reinit_gpio_intr(hw);
+
 	/* reset the NIC */
 	txgbe_pf_reset_hw(hw);
 	hw->adapter_stopped = 0;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/9] net/txgbe: fix to set autoneg for 1G speed
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (2 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 3/9] net/txgbe: fix issues caused by MNG veto bit setting Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 5/9] net/txgbe: fix device extended stats Jiawen Wu
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

Autoneg was always on for 1G speed, fix to set autoneg off.

Fixes: 01c3cf5c85a7 ("net/txgbe: add autoneg control read and write")
Fixes: e4c515a7bc7e ("net/txgbe: add multi-speed link setup")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/base/txgbe_hw.c   | 14 ++++++++++++++
 drivers/net/txgbe/base/txgbe_phy.c  |  4 +++-
 drivers/net/txgbe/base/txgbe_type.h |  1 +
 drivers/net/txgbe/txgbe_ethdev.c    |  2 ++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c
index 2952c408fd..d19fd0065d 100644
--- a/drivers/net/txgbe/base/txgbe_hw.c
+++ b/drivers/net/txgbe/base/txgbe_hw.c
@@ -2273,10 +2273,24 @@ s32 txgbe_setup_mac_link_multispeed_fiber(struct txgbe_hw *hw,
 	}
 
 	if (speed & TXGBE_LINK_SPEED_1GB_FULL) {
+		u32 curr_autoneg;
+
 		speedcnt++;
 		if (highest_link_speed == TXGBE_LINK_SPEED_UNKNOWN)
 			highest_link_speed = TXGBE_LINK_SPEED_1GB_FULL;
 
+		status = hw->mac.check_link(hw, &link_speed, &link_up, false);
+		if (status != 0)
+			return status;
+
+		/* If we already have link at this speed, just jump out */
+		if (link_speed == TXGBE_LINK_SPEED_1GB_FULL) {
+			curr_autoneg = rd32_epcs(hw, SR_MII_MMD_CTL);
+			if (link_up && (hw->autoneg ==
+					!!(curr_autoneg & SR_MII_MMD_CTL_AN_EN)))
+				goto out;
+		}
+
 		/* Set the module link speed */
 		switch (hw->phy.media_type) {
 		case txgbe_media_type_fiber:
diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c
index 1eb45b068a..d87af656d5 100644
--- a/drivers/net/txgbe/base/txgbe_phy.c
+++ b/drivers/net/txgbe/base/txgbe_phy.c
@@ -1402,7 +1402,9 @@ txgbe_set_sgmii_an37_ability(struct txgbe_hw *hw)
 		wr32_epcs(hw, SR_MII_MMD_AN_CTL, 0x0105);
 	wr32_epcs(hw, SR_MII_MMD_DIGI_CTL, 0x0200);
 	value = rd32_epcs(hw, SR_MII_MMD_CTL);
-	value = (value & ~0x1200) | (0x1 << 12) | (0x1 << 9);
+	value = (value & ~0x1200) | (0x1 << 9);
+	if (hw->autoneg)
+		value |= SR_MII_MMD_CTL_AN_EN;
 	wr32_epcs(hw, SR_MII_MMD_CTL, value);
 }
 
diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h
index c3486b472f..75e839b7de 100644
--- a/drivers/net/txgbe/base/txgbe_type.h
+++ b/drivers/net/txgbe/base/txgbe_type.h
@@ -783,6 +783,7 @@ struct txgbe_hw {
 	bool allow_unsupported_sfp;
 	bool need_crosstalk_fix;
 	bool dev_start;
+	bool autoneg;
 	struct txgbe_devargs devarg;
 
 	uint64_t isb_dma;
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 36c74d353d..962667acdc 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -1821,6 +1821,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
 		speed = (TXGBE_LINK_SPEED_100M_FULL |
 			 TXGBE_LINK_SPEED_1GB_FULL |
 			 TXGBE_LINK_SPEED_10GB_FULL);
+		hw->autoneg = true;
 	} else {
 		if (*link_speeds & RTE_ETH_LINK_SPEED_10G)
 			speed |= TXGBE_LINK_SPEED_10GB_FULL;
@@ -1832,6 +1833,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
 			speed |= TXGBE_LINK_SPEED_1GB_FULL;
 		if (*link_speeds & RTE_ETH_LINK_SPEED_100M)
 			speed |= TXGBE_LINK_SPEED_100M_FULL;
+		hw->autoneg = false;
 	}
 
 	err = hw->mac.setup_link(hw, speed, link_up);
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/9] net/txgbe: fix device extended stats
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (3 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 4/9] net/txgbe: fix to set autoneg for 1G speed Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 6/9] net/ngbe: " Jiawen Wu
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

Fix to show tx_broadcast_packets and tx_multicast_packets counters.

Fixes: 91fe49c87d76 ("net/txgbe: support device xstats")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/txgbe_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 962667acdc..74765a469d 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -180,7 +180,9 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {
 	HW_XSTAT(tx_total_packets),
 	HW_XSTAT(rx_total_missed_packets),
 	HW_XSTAT(rx_broadcast_packets),
+	HW_XSTAT(tx_broadcast_packets),
 	HW_XSTAT(rx_multicast_packets),
+	HW_XSTAT(tx_multicast_packets),
 	HW_XSTAT(rx_management_packets),
 	HW_XSTAT(tx_management_packets),
 	HW_XSTAT(rx_management_dropped),
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/9] net/ngbe: fix device extended stats
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (4 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 5/9] net/txgbe: fix device extended stats Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 7/9] net/ngbe: fix issues caused by MNG veto bit setting Jiawen Wu
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

Fix to show tx_broadcast_packets and tx_multicast_packets counters.

Fixes: 8b433d04adc9 ("net/ngbe: support device xstats")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ngbe/ngbe_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index c32d954769..836ecfa2da 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -160,7 +160,9 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {
 	HW_XSTAT(tx_total_packets),
 	HW_XSTAT(rx_total_missed_packets),
 	HW_XSTAT(rx_broadcast_packets),
+	HW_XSTAT(tx_broadcast_packets),
 	HW_XSTAT(rx_multicast_packets),
+	HW_XSTAT(tx_multicast_packets),
 	HW_XSTAT(rx_management_packets),
 	HW_XSTAT(tx_management_packets),
 	HW_XSTAT(rx_management_dropped),
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 7/9] net/ngbe: fix issues caused by MNG veto bit setting
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (5 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 6/9] net/ngbe: " Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 8/9] net/ngbe: fix link status in no LSC mode Jiawen Wu
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

In the new firmware, MNG veto bit is set by default for new features. It
causes the PHY configuration not to be reset after LAN reset. So PHY power
will be down after stopping device. The internal PHY then cannot be
initialized successfully at device start. Add setting power on for internal
PHY to fix this issue.

Fixes: abea8974c7a6 ("net/ngbe: support link down/up")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ngbe/base/ngbe_phy_rtl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ngbe/base/ngbe_phy_rtl.c b/drivers/net/ngbe/base/ngbe_phy_rtl.c
index 9b323624ec..88bacec114 100644
--- a/drivers/net/ngbe/base/ngbe_phy_rtl.c
+++ b/drivers/net/ngbe/base/ngbe_phy_rtl.c
@@ -120,6 +120,8 @@ s32 ngbe_init_phy_rtl(struct ngbe_hw *hw)
 	hw->init_phy = true;
 	msec_delay(1);
 
+	hw->phy.set_phy_power(hw, true);
+
 	for (i = 0; i < 15; i++) {
 		if (!rd32m(hw, NGBE_STAT,
 			NGBE_STAT_GPHY_IN_RST(hw->bus.lan_id)))
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 8/9] net/ngbe: fix link status in no LSC mode
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (6 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 7/9] net/ngbe: fix issues caused by MNG veto bit setting Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-14  2:34 ` [PATCH 9/9] net/ngbe: remove redundant codes Jiawen Wu
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

When using no LSC mode, device link status is sometimes get incorrectly.
Introduce hw->lsc to fix this issue.

Fixes: 3d0af7066759 ("net/ngbe: setup PHY link")
Fixes: 3518df5774c7 ("net/ngbe: support device start/stop")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ngbe/base/ngbe_hw.c      | 10 +++++++---
 drivers/net/ngbe/base/ngbe_phy_rtl.c | 20 ++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_phy_rtl.h |  2 ++
 drivers/net/ngbe/base/ngbe_phy_yt.c  | 16 +++++++++-------
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/ngbe_ethdev.c       |  2 ++
 6 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c
index 283cdca367..27243d85c8 100644
--- a/drivers/net/ngbe/base/ngbe_hw.c
+++ b/drivers/net/ngbe/base/ngbe_hw.c
@@ -1541,11 +1541,15 @@ s32 ngbe_clear_vfta(struct ngbe_hw *hw)
 s32 ngbe_check_mac_link_em(struct ngbe_hw *hw, u32 *speed,
 			bool *link_up, bool link_up_wait_to_complete)
 {
-	u32 i, reg;
+	u32 i;
 	s32 status = 0;
 
-	reg = rd32(hw, NGBE_GPIOINTSTAT);
-	wr32(hw, NGBE_GPIOEOI, reg);
+	if (hw->lsc) {
+		u32 reg;
+
+		reg = rd32(hw, NGBE_GPIOINTSTAT);
+		wr32(hw, NGBE_GPIOEOI, reg);
+	}
 
 	if (link_up_wait_to_complete) {
 		for (i = 0; i < hw->mac.max_link_up_time; i++) {
diff --git a/drivers/net/ngbe/base/ngbe_phy_rtl.c b/drivers/net/ngbe/base/ngbe_phy_rtl.c
index 88bacec114..b0eb6c97c0 100644
--- a/drivers/net/ngbe/base/ngbe_phy_rtl.c
+++ b/drivers/net/ngbe/base/ngbe_phy_rtl.c
@@ -392,6 +392,26 @@ s32 ngbe_check_phy_link_rtl(struct ngbe_hw *hw, u32 *speed, bool *link_up)
 			*speed = NGBE_LINK_SPEED_10M_FULL;
 	}
 
+	if (hw->lsc)
+		return status;
+
+	/*
+	 * Because of the slow speed of getting link state, RTL_PHYSR
+	 * may still be up while the actual link state is down.
+	 * So we read RTL_GBSR to get accurate state when speed is 1G
+	 * in polling mode.
+	 */
+	if (*speed == NGBE_LINK_SPEED_1GB_FULL) {
+		status = hw->phy.read_reg(hw, RTL_GBSR,
+				RTL_DEV_ZERO, &phy_data);
+		phy_link = phy_data & RTL_GBSR_LRS;
+
+		/* Only need to detect link down */
+		if (!phy_link) {
+			*link_up = false;
+			*speed = NGBE_LINK_SPEED_UNKNOWN;
+		}
+	}
 	return status;
 }
 
diff --git a/drivers/net/ngbe/base/ngbe_phy_rtl.h b/drivers/net/ngbe/base/ngbe_phy_rtl.h
index b2fbc4f74d..6093ee7d5c 100644
--- a/drivers/net/ngbe/base/ngbe_phy_rtl.h
+++ b/drivers/net/ngbe/base/ngbe_phy_rtl.h
@@ -35,6 +35,8 @@
 #define   RTL_ANLPAR_LP			MS16(10, 0x3)
 #define RTL_GBCR			0x9
 #define   RTL_GBCR_1000F		MS16(9, 0x1)
+#define RTL_GBSR			0xA
+#define   RTL_GBSR_LRS			MS16(13, 0x1)
 /* Page 0xa42*/
 #define RTL_GSR				0x10
 #define   RTL_GSR_ST			MS16(0, 0x7)
diff --git a/drivers/net/ngbe/base/ngbe_phy_yt.c b/drivers/net/ngbe/base/ngbe_phy_yt.c
index 726d6c8ef5..754faadd6a 100644
--- a/drivers/net/ngbe/base/ngbe_phy_yt.c
+++ b/drivers/net/ngbe/base/ngbe_phy_yt.c
@@ -102,13 +102,15 @@ s32 ngbe_init_phy_yt(struct ngbe_hw *hw)
 {
 	rte_spinlock_init(&hw->phy_lock);
 
-	rte_spinlock_lock(&hw->phy_lock);
-	/* close sds area register */
-	ngbe_write_phy_reg_ext_yt(hw, YT_SMI_PHY, 0, 0);
-	/* enable interrupts */
-	ngbe_write_phy_reg_mdi(hw, YT_INTR, 0,
-				YT_INTR_ENA_MASK | YT_SDS_INTR_ENA_MASK);
-	rte_spinlock_unlock(&hw->phy_lock);
+	if (hw->lsc) {
+		rte_spinlock_lock(&hw->phy_lock);
+		/* close sds area register */
+		ngbe_write_phy_reg_ext_yt(hw, YT_SMI_PHY, 0, 0);
+		/* enable interrupts */
+		ngbe_write_phy_reg_mdi(hw, YT_INTR, 0,
+					YT_INTR_ENA_MASK | YT_SDS_INTR_ENA_MASK);
+		rte_spinlock_unlock(&hw->phy_lock);
+	}
 
 	hw->phy.set_phy_power(hw, false);
 
diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h
index 05804eeab7..37be288a74 100644
--- a/drivers/net/ngbe/base/ngbe_type.h
+++ b/drivers/net/ngbe/base/ngbe_type.h
@@ -431,6 +431,7 @@ struct ngbe_hw {
 	bool offset_loaded;
 	bool is_pf;
 	bool gpio_ctl;
+	bool lsc;
 	u32 led_conf;
 	bool init_phy;
 	rte_spinlock_t phy_lock;
diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 836ecfa2da..317ad6999c 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -1052,6 +1052,8 @@ ngbe_dev_start(struct rte_eth_dev *dev)
 	if (hw->is_pf && dev->data->dev_conf.lpbk_mode)
 		goto skip_link_setup;
 
+	hw->lsc = dev->data->dev_conf.intr_conf.lsc;
+
 	err = hw->mac.check_link(hw, &speed, &link_up, 0);
 	if (err != 0)
 		goto error;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 9/9] net/ngbe: remove redundant codes
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (7 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 8/9] net/ngbe: fix link status in no LSC mode Jiawen Wu
@ 2023-06-14  2:34 ` Jiawen Wu
  2023-06-19  2:23 ` [PATCH 0/9] Wangxun bug fixes Jiawen Wu
  2023-06-20 15:33 ` Ferruh Yigit
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-14  2:34 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu, stable

Remove redundant function ngbe_dev_setup_link_alarm_handler() and related
codes.

Fixes: b9246b8fa280 ("net/ngbe: support link update")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ngbe/ngbe_ethdev.c | 28 ----------------------------
 drivers/net/ngbe/ngbe_ethdev.h |  1 -
 2 files changed, 29 deletions(-)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 317ad6999c..af77081d9a 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -974,9 +974,6 @@ 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);
 
@@ -1172,8 +1169,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->gpio_ctl) {
 		/* gpio0 is used to power on/off control*/
 		wr32(hw, NGBE_GPIODATA, NGBE_GPIOBIT_0);
@@ -1895,24 +1890,6 @@ ngbe_dev_overheat(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
 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
@@ -1922,7 +1899,6 @@ ngbe_dev_link_update_share(struct rte_eth_dev *dev,
 	struct rte_eth_link link;
 	u32 link_speed = NGBE_LINK_SPEED_UNKNOWN;
 	u32 lan_speed = 0;
-	struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
 	bool link_up;
 	int err;
 	int wait = 1;
@@ -1936,9 +1912,6 @@ ngbe_dev_link_update_share(struct rte_eth_dev *dev,
 
 	hw->mac.get_link_status = true;
 
-	if (intr->flags & NGBE_FLAG_NEED_LINK_CONFIG)
-		return rte_eth_linkstatus_set(dev, &link);
-
 	/* check if it needs to wait to complete, if lsc interrupt is enabled */
 	if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
 		wait = 0;
@@ -1953,7 +1926,6 @@ ngbe_dev_link_update_share(struct rte_eth_dev *dev,
 	if (!link_up)
 		return rte_eth_linkstatus_set(dev, &link);
 
-	intr->flags &= ~NGBE_FLAG_NEED_LINK_CONFIG;
 	link.link_status = RTE_ETH_LINK_UP;
 	link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
 
diff --git a/drivers/net/ngbe/ngbe_ethdev.h b/drivers/net/ngbe/ngbe_ethdev.h
index 330f476f6f..3cde7c8750 100644
--- a/drivers/net/ngbe/ngbe_ethdev.h
+++ b/drivers/net/ngbe/ngbe_ethdev.h
@@ -342,7 +342,6 @@ 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.27.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 0/9] Wangxun bug fixes
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (8 preceding siblings ...)
  2023-06-14  2:34 ` [PATCH 9/9] net/ngbe: remove redundant codes Jiawen Wu
@ 2023-06-19  2:23 ` Jiawen Wu
  2023-06-20 15:33 ` Ferruh Yigit
  10 siblings, 0 replies; 12+ messages in thread
From: Jiawen Wu @ 2023-06-19  2:23 UTC (permalink / raw)
  To: dev

Hi,

> -----Original Message-----
> From: Jiawen Wu <jiawenwu@trustnetic.com>
> Sent: Wednesday, June 14, 2023 10:34 AM
> To: dev@dpdk.org
> Cc: Jiawen Wu <jiawenwu@trustnetic.com>
> Subject: [PATCH 0/9] Wangxun bug fixes
> 
> Fix some bugs for txgbe and ngbe.
> 
> Jiawen Wu (9):
>   net/txgbe: fix Tx failure with fiber hotplug
>   net/txgbe: fix interrupt enable mask
>   net/txgbe: fix issues caused by MNG veto bit setting
>   net/txgbe: fix to set autoneg for 1G speed
>   net/txgbe: fix device extended stats
>   net/ngbe: fix device extended stats
>   net/ngbe: fix issues caused by MNG veto bit setting
>   net/ngbe: fix link status in no LSC mode
>   net/ngbe: remove redundant codes
> 
>  drivers/net/ngbe/base/ngbe_hw.c      | 10 +++++---
>  drivers/net/ngbe/base/ngbe_phy_rtl.c | 22 +++++++++++++++++
>  drivers/net/ngbe/base/ngbe_phy_rtl.h |  2 ++
>  drivers/net/ngbe/base/ngbe_phy_yt.c  | 16 ++++++------
>  drivers/net/ngbe/base/ngbe_type.h    |  1 +
>  drivers/net/ngbe/ngbe_ethdev.c       | 32 +++---------------------
>  drivers/net/ngbe/ngbe_ethdev.h       |  1 -
>  drivers/net/txgbe/base/txgbe_hw.c    | 37 +++++++++++++---------------
>  drivers/net/txgbe/base/txgbe_phy.c   | 22 +++++++++++------
>  drivers/net/txgbe/base/txgbe_regs.h  | 14 ++++++++++-
>  drivers/net/txgbe/base/txgbe_type.h  |  1 +
>  drivers/net/txgbe/txgbe_ethdev.c     | 34 ++++++++++++++++++++++++-
>  12 files changed, 124 insertions(+), 68 deletions(-)
> 
> --
> 2.27.0
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] Wangxun bug fixes
  2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
                   ` (9 preceding siblings ...)
  2023-06-19  2:23 ` [PATCH 0/9] Wangxun bug fixes Jiawen Wu
@ 2023-06-20 15:33 ` Ferruh Yigit
  10 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2023-06-20 15:33 UTC (permalink / raw)
  To: Jiawen Wu; +Cc: dev

On 6/14/2023 3:34 AM, Jiawen Wu wrote:
> Fix some bugs for txgbe and ngbe.
> 
> Jiawen Wu (9):
>   net/txgbe: fix Tx failure with fiber hotplug
>   net/txgbe: fix interrupt enable mask
>   net/txgbe: fix issues caused by MNG veto bit setting
>   net/txgbe: fix to set autoneg for 1G speed
>   net/txgbe: fix device extended stats
>   net/ngbe: fix device extended stats
>   net/ngbe: fix issues caused by MNG veto bit setting
>   net/ngbe: fix link status in no LSC mode
>   net/ngbe: remove redundant codes
>

Series applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-20 15:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14  2:34 [PATCH 0/9] Wangxun bug fixes Jiawen Wu
2023-06-14  2:34 ` [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug Jiawen Wu
2023-06-14  2:34 ` [PATCH 2/9] net/txgbe: fix interrupt enable mask Jiawen Wu
2023-06-14  2:34 ` [PATCH 3/9] net/txgbe: fix issues caused by MNG veto bit setting Jiawen Wu
2023-06-14  2:34 ` [PATCH 4/9] net/txgbe: fix to set autoneg for 1G speed Jiawen Wu
2023-06-14  2:34 ` [PATCH 5/9] net/txgbe: fix device extended stats Jiawen Wu
2023-06-14  2:34 ` [PATCH 6/9] net/ngbe: " Jiawen Wu
2023-06-14  2:34 ` [PATCH 7/9] net/ngbe: fix issues caused by MNG veto bit setting Jiawen Wu
2023-06-14  2:34 ` [PATCH 8/9] net/ngbe: fix link status in no LSC mode Jiawen Wu
2023-06-14  2:34 ` [PATCH 9/9] net/ngbe: remove redundant codes Jiawen Wu
2023-06-19  2:23 ` [PATCH 0/9] Wangxun bug fixes Jiawen Wu
2023-06-20 15:33 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).