Wangxun Fixes
Subsystems (2)
cover Wangxun Fixes
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
Zaiyu Wang (18):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3705 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1751 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2595 +++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 279 ++ drivers/net/txgbe/base/txgbe_hw.c | 52 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 12 +- drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 42 +- drivers/net/txgbe/base/txgbe_regs.h | 10 +- drivers/net/txgbe/base/txgbe_type.h | 39 +- drivers/net/txgbe/txgbe_ethdev.c | 390 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +- drivers/net/txgbe/txgbe_logs.h | 7 + drivers/net/txgbe/txgbe_rxtx.c | 39 +- drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 +- 26 files changed, 9233 insertions(+), 402 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH 1/18 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH 2/18 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH 3/18 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
PATCH 4/18 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
Fix this behavior by:
- doing nothing when we set/unset allmulti if promiscuous mode is on
- restorting the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
PATCH 5/18 net/txgbe: fix inaccuracy in TX rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To fix this issue, there are some changes:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +1 -0
@@ -1670,6 +1670,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,21 );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
PATCH 6/18 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1
PATCH 7/18 net/txgbe: fix Tx desc free logic
In reply to Zaiyu WangOn some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
--- drivers/net/txgbe/txgbe_rxtx.c | 9 ++++++++- drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +8 -1
@@ -100,7 +100,9 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq)volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
@@ -652,6 +654,11 @@ txgbe_xmit_cleanup(struct txgbe_tx_queue *txq)/* we have caught up to head, no work left to do */ if (desc_to_clean_to == head)return -(1 ); +else if (desc_to_clean_to > head && head > last_desc_cleaned) +return -(1 ); +else if (last_desc_cleaned > desc_to_clean_to && + (head > last_desc_cleaned || head < desc_to_clean_to)) +return -(1 ); }else {if (!(status &rte_cpu_to_le_32 (TXGBE_TXD_DD ))) { PMD_TX_FREE_LOG(DEBUG,
drivers/net/txgbe/txgbe_rxtx_vec_common.h +5 -2
@@ -94,8 +94,11 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq) txq->tx_next_dd - txq->tx_free_thresh;if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) + +volatile uint16_t head = (uint16_t )*txq->headwb_mem; +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
Signature · 1 line
2.21.0.windows.1
PATCH 8/18 net/txgbe: fix link flow control registers for Amber-Lite
In reply to Zaiyu WangThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
--- drivers/net/txgbe/base/txgbe_hw.c | 5 +++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/txgbe_ethdev.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +5 -0
@@ -394,6 +394,11 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );
drivers/net/txgbe/base/txgbe_regs.h +2 -0
@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)
drivers/net/txgbe/txgbe_ethdev.c +8 -2
@@ -2331,8 +2331,14 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { + hw_stats->rx_xon_packets =rd32 (hw,TXGBE_PBRXLNKXON_AML ); + hw_stats->rx_xoff_packets =rd32 (hw,TXGBE_PBRXLNKXOFF_AML ); + }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF );
Signature · 1 line
2.21.0.windows.1
RE: [PATCH 08/18] net/txgbe: fix link flow control registers for Amber-Lite
Quoted 56 lines
-----Original Message-----
From: Zaiyu Wang <[email protected]>
Sent: Thursday, April 23, 2026 11:40 AM
To: [email protected]
Cc: Zaiyu Wang <[email protected]>; [email protected]; Jiawen Wu <[email protected]>
Subject: [PATCH 08/18] net/txgbe: fix link flow control registers for Amber-LiteThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
Signed-off-by Zaiyu Wang <[email protected]>--- drivers/net/txgbe/base/txgbe_hw.c | 5 +++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/txgbe_ethdev.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-)drivers/net/txgbe/base/txgbe_hw.c +5
-0@@ -394,6 +394,11 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );drivers/net/txgbe/base/txgbe_regs.h +2
-0@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)drivers/net/txgbe/txgbe_ethdev.c +0
-0
drivers/net/txgbe/txgbe_ethdev.c txgbe_read_stats_registers(struct txgbe_hw *hw, · line 2337
Quoted 9 lines
drivers/net/txgbe/txgbe_ethdev.c +4
-2@@ -2331,8 +2331,14 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { + hw_stats->rx_xon_packets =rd32 (hw,TXGBE_PBRXLNKXON_AML ); + hw_stats->rx_xoff_packets =rd32 (hw,TXGBE_PBRXLNKXOFF_AML );
What happens to these counters after .stats_reset()?
Quoted 10 lines
drivers/net/txgbe/txgbe_ethdev.c +4
-1+ }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF ); --2.21.0.windows.1
PATCH 9/18 net/txgbe: fix link flow control config for Sapphire
In reply to Zaiyu WangSP chips have a hardware bug preventing XON flow control support, so the driver disables it.
--- drivers/net/txgbe/base/txgbe_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +4 -2
@@ -1035,8 +1035,10 @@ s32 txgbe_fc_enable(struct txgbe_hw *hw)for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {if ((hw->fc.current_mode & txgbe_fc_tx_pause) && hw->fc.high_water[i]) { - fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]) | -TXGBE_FCWTRLO_XON ; + fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]); +/* SP doesn't support xon */ +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) + fcrtl |=TXGBE_FCWTRLO_XON ; fcrth =TXGBE_FCWTRHI_TH (hw->fc.high_water[i]) |TXGBE_FCWTRHI_XOFF ; }else {
Signature · 1 line
2.21.0.windows.1
PATCH 10/18 net/txgbe: fix a mass of unknown interrupts
In reply to Zaiyu WangWhen RSC is enabled, Rx ring IVAR is set to configure ITR. It causes Rx ring interrupts report on the default msix_vector. Thus a mass of unknown interrupts occupy CPU.
Fix the issue by setting ring IVAR only when the rxq interrupt is enabled.
--- drivers/net/txgbe/txgbe_rxtx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +17 -13
@@ -4354,6 +4354,8 @@ static int txgbe_set_rsc(struct rte_eth_dev *dev) {struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_eth_dev_info dev_info = {0 };bool rsc_capable = false;
@@ -4404,8 +4406,6 @@ txgbe_set_rsc(struct rte_eth_dev *dev)rd32 (hw,TXGBE_RXCFG (rxq->reg_idx));uint32_t psrtype =rd32 (hw,TXGBE_POOLRSS (rxq->reg_idx)); -uint32_t eitr = -rd32 (hw,TXGBE_ITR (rxq->reg_idx));/* * txgbe PMD doesn't support header-split at the moment.
@@ -4424,6 +4424,9 @@ txgbe_set_rsc(struct rte_eth_dev *dev) srrctl |=txgbe_get_rscctl_maxdesc (rxq->mb_pool); psrtype |=TXGBE_POOLRSS_L4HDR ; +wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); +wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); +/* * RSC: Set ITR interval corresponding to 2K ints/s. *
@@ -4437,19 +4440,20 @@ txgbe_set_rsc(struct rte_eth_dev *dev)* For a sparse streaming case this setting will yield * at most 500us latency for a single RSC aggregation. */ - eitr &= ~TXGBE_ITR_IVAL_MASK ; - eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); - eitr |=TXGBE_ITR_WRDSA ; +if (rte_intr_dp_is_en (intr_handle)) { +uint32_t eitr =rd32 (hw,TXGBE_ITR (rxq->reg_idx)); -wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); -wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); -wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); + eitr &= ~TXGBE_ITR_IVAL_MASK ; + eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); + eitr |=TXGBE_ITR_WRDSA ; +wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); -/* -* RSC requires the mapping of the queue to the -* interrupt vector. -*/ -txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); +/* +* RSC requires the mapping of the queue to the +* interrupt vector. +*/ +txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); + } } dev->data->lro =1 ;
Signature · 1 line
2.21.0.windows.1
PATCH 11/18 net/txgbe: fix traffic class priority configuration
In reply to Zaiyu WangAfter applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc off
The old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Fix both issues, ensuring that tc-prio mapping works as expected.
--- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_regs.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/txgbe/base/txgbe_dcb_hw.c +1 -1
@@ -154,7 +154,7 @@ s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,for (i =0 ; i <TXGBE_DCB_UP_MAX ; i++) reg |=TXGBE_DCBUP2TC_MAP (i, map[i]); -wr32 (hw,TXGBE_PBRXUP2TC , reg); +wr32 (hw,TXGBE_PBTXUP2TC , reg);/* Configure traffic class credits and priority */ for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {
drivers/net/txgbe/base/txgbe_regs.h +2 -3
@@ -503,9 +503,8 @@#define TXGBE_PBRXCTL 0x019000#define TXGBE_PBRXCTL_ST MS(0, 0x1)#define TXGBE_PBRXCTL_ENA MS(31, 0x1) -#define TXGBE_PBRXUP2TC 0x019008#define TXGBE_PBTXUP2TC 0x01C800 -#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 3 * (tc), 0x7) +#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 4 * (tc), 0x7)#define TXGBE_DCBUP2TC_DEC (tc, r) RS(r, 3 * (tc), 0x7)#define TXGBE_PBRXSIZE (tc) (0x019020 + (tc) * 4)#define TXGBE_PBRXSIZE_KB (v) LS(v, 10, 0x3FF)
@@ -1703,7 +1702,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_RDM_PF_HIDE (_i) (0x12090 + ((_i) * 4))#define TXGBE_RPUP2TC 0x019008 -#define TXGBE_RPUP2TC_UP_SHIFT 3 +#define TXGBE_RPUP2TC_UP_SHIFT 4#define TXGBE_RPUP2TC_UP_MASK 0x7#define TXGBE_RDM_DCACHE_CTL 0x0120A8
Signature · 1 line
2.21.0.windows.1
PATCH 12/18 net/txgbe: fix link stability for 25G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_aml.c | 107 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 2466 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1749 ++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 279 +++ drivers/net/txgbe/base/txgbe_hw.c | 35 +- drivers/net/txgbe/base/txgbe_osdep.h | 8 - drivers/net/txgbe/base/txgbe_phy.h | 1 - drivers/net/txgbe/base/txgbe_regs.h | 2 + drivers/net/txgbe/base/txgbe_type.h | 12 + drivers/net/txgbe/txgbe_ethdev.c | 83 +- drivers/net/txgbe/txgbe_ethdev.h | 4 + drivers/net/txgbe/txgbe_logs.h | 7 + 14 files changed, 4694 insertions(+), 66 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
drivers/net/txgbe/base/meson.build +1 -0
@@ -12,4 +12,5 @@ base_sources = files( 'txgbe_mng.c', 'txgbe_phy.c', 'txgbe_vf.c', + 'txgbe_e56.c', )
drivers/net/txgbe/base/txgbe_aml.c +83 -24
171 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml.h +4 -2
@@ -16,7 +16,9 @@ s32 txgbe_get_link_capabilities_aml(struct txgbe_hw *hw, u32 *speed, bool *autoneg);u32 txgbe_get_media_type_aml (struct txgbe_hw *hw);void txgbe_wait_for_link_up_aml (struct txgbe_hw *hw,u32 speed); -s32 txgbe_setup_mac_link_aml (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml (struct txgbe_hw *hw);#endif /* _TXGBE_AML_H_ */
drivers/net/txgbe/base/txgbe_e56.c new file +2466 -0
2,466 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h new file +1749 -0
347 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h new file +279 -0
279 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +82 -1
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
RE: [PATCH 12/18] net/txgbe: fix link stability for 25G NIC
Quoted 83 lines
drivers/net/txgbe/base/txgbe_aml.c +52
-14@@ -197,33 +204,80 @@ s32 txgbe_setup_mac_link_aml(struct txgbe_hw *hw,if (status)return status; +/* setup the highest link when no autoneg */ +if (!autoneg) { +if (speed &TXGBE_LINK_SPEED_25GB_FULL ) + speed =TXGBE_LINK_SPEED_25GB_FULL ; +else if (speed &TXGBE_LINK_SPEED_10GB_FULL ) + speed =TXGBE_LINK_SPEED_10GB_FULL ; + } + speed &= link_capabilities;if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - value =rd32 (hw,TXGBE_GPIOEXT ); -if (value & (TXGBE_SFP1_MOD_ABS_LS |TXGBE_SFP1_RX_LOS_LS )) +if (txgbe_gpio_ext_check (hw,TXGBE_SFP1_MOD_ABS_LS | +TXGBE_SFP1_RX_LOS_LS )) { +DEBUGOUT ("RX LOS" );return status; + } - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) { +DEBUGOUT ("check phy link_up" ); +break ; + } +msleep (250 ); + } -if (link_up && speed ==TXGBE_LINK_SPEED_25GB_FULL ) +if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) hw->cur_fec_link =txgbe_phy_fec_get (hw);if (link_speed == speed && link_up && - !(speed ==TXGBE_LINK_SPEED_25GB_FULL && - !(hw->fec_mode & hw->cur_fec_link))) -return status; + !(speed ==TXGBE_LINK_SPEED_25GB_FULL && + !(hw->fec_mode & hw->cur_fec_link))) + goto out; -if (speed &TXGBE_LINK_SPEED_25GB_FULL ) - speed =0x10 ; -else if (speed &TXGBE_LINK_SPEED_10GB_FULL ) - speed =0x08 ; +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +rte_spinlock_unlock (&hw->phy_lock); + +if (ret_status ==TXGBE_ERR_PHY_INIT_NOT_DONE ) + goto out; - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); +if (ret_status ==TXGBE_ERR_TIMEOUT ) { + hw->link_valid = false; + *need_reset = true; + goto out; + }else { + hw->link_valid = true; + } + +if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + }else { +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) {
drivers/net/txgbe/base/txgbe_aml.c s32 txgbe_setup_mac_link_aml(struct txgbe_hw *hw, · line 281
Quoted 10 lines
drivers/net/txgbe/base/txgbe_aml.c +9
-0+PMD_DRV_LOG (DEBUG ,"MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +PMD_DRV_LOG (DEBUG ,"MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +PMD_DRV_LOG (DEBUG ,"Link reconfiguration required. Reset scheduled in 2000ms." ); + }
DEBUGOUT() and PMD_DRV_LOG(DEBUG, ...) can be unified in this function.
PATCH 13/18 net/txgbe: fix link stability for 40G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/txgbe_aml40.c | 70 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 1391 ++++++++++++++++++++++++-- drivers/net/txgbe/txgbe_ethdev.c | 4 +- 4 files changed, 1375 insertions(+), 96 deletions(-)
drivers/net/txgbe/base/txgbe_aml40.c +55 -15
@@ -13,6 +13,7 @@#include "txgbe_hw.h" #include "txgbe_aml.h" #include "txgbe_aml40.h" +#include "txgbe_e56.h" void txgbe_init_ops_aml40 (struct txgbe_hw *hw) {
@@ -24,6 +25,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)/* PHY */ phy->get_media_type = txgbe_get_media_type_aml40; + phy->setup_link_core = txgbe_setup_phy_link_aml40;/* LINK */ mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
@@ -52,6 +54,13 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,if (link_up_wait_to_complete) {for (i =0 ; i < hw->mac.max_link_up_time; i++) { +if (!hw->link_valid) { + *link_up = false; + +msleep (100 ); +continue ; + } +if (!(links_reg &TXGBE_PORTSTAT_UP )) { *link_up = false; }else {
@@ -68,6 +77,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } +if (!hw->link_valid) + *link_up = false; +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G )
@@ -107,20 +119,24 @@ u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)return txgbe_media_type_fiber_qsfp; } -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw, -u32 speed, -bool autoneg_wait_to_complete) +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset) {bool autoneg = false;s32 status =0 ; +s32 ret_status =0 ;u32 link_speed =TXGBE_LINK_SPEED_UNKNOWN ;bool link_up = false; +int i;u32 link_capabilities =TXGBE_LINK_SPEED_UNKNOWN ; +u32 value; -if (hw->phy.sfp_type == txgbe_sfp_type_not_present) { -DEBUGOUT ("SFP not detected, skip setup mac link" ); -return 0 ; - } + *need_reset = false; + +if (hw->phy.sfp_type == txgbe_sfp_type_not_present) + hw->phy.identify_sfp (hw);/* Check to see if speed passed in is supported. */ status = hw->mac.get_link_capabilities(hw,
@@ -132,18 +148,43 @@ s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) +break ; +msleep (250 ); + }if (link_speed == speed && link_up) -return status; + goto out; -if (speed &TXGBE_LINK_SPEED_40GB_FULL ) - speed =0x20 ; +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +rte_spinlock_unlock (&hw->phy_lock); - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); +if (ret_status ==TXGBE_ERR_TIMEOUT ) + hw->link_valid = false; + +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) { +PMD_DRV_LOG (DEBUG ,"MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +PMD_DRV_LOG (DEBUG ,"MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +PMD_DRV_LOG (DEBUG ,"Link reconfiguration required. Reset scheduled in 2000ms." ); + }return status; }
@@ -159,6 +200,5 @@ void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw) mac->flap_tx_laser = txgbe_flap_tx_laser_multispeed_fiber; - mac->setup_link = txgbe_setup_mac_link_aml40; mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed; }
drivers/net/txgbe/base/txgbe_aml40.h +4 -2
@@ -14,7 +14,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw,s32 txgbe_get_link_capabilities_aml40 (struct txgbe_hw *hw,u32 *speed,bool *autoneg);u32 txgbe_get_media_type_aml40 (struct txgbe_hw *hw); -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml40 (struct txgbe_hw *hw);#endif /* _TXGBE_AML40_H_ */
drivers/net/txgbe/base/txgbe_e56.c +1314 -77
1,516 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2054,7 +2054,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw);rte_eal_alarm_cancel (txgbe_dev_detect_sfp, dev);
@@ -3200,7 +3200,7 @@ txgbe_dev_setup_link_thread_handler(void *param)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);rte_thread_detach (rte_thread_self ()); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)txgbe_dev_setup_link_alarm_handler_aml (hw);else txgbe_dev_setup_link_alarm_handler (dev);
Signature · 1 line
2.21.0.windows.1
PATCH 14/18 net/txgbe: fix link stability for Amber-Lite backplane mode
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 65 +- drivers/net/txgbe/base/txgbe_aml40.c | 43 +- drivers/net/txgbe/base/txgbe_e56.c | 28 +- drivers/net/txgbe/base/txgbe_e56.h | 2 + drivers/net/txgbe/base/txgbe_e56_bp.c | 2595 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_hw.c | 6 + drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 21 + drivers/net/txgbe/base/txgbe_phy.h | 19 + drivers/net/txgbe/base/txgbe_type.h | 25 +- drivers/net/txgbe/txgbe_ethdev.c | 109 +- drivers/net/txgbe/txgbe_ethdev.h | 2 +- 15 files changed, 2893 insertions(+), 33 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c
drivers/net/txgbe/base/meson.build +1 -0
@@ -13,4 +13,5 @@ base_sources = files( 'txgbe_phy.c', 'txgbe_vf.c', 'txgbe_e56.c', + 'txgbe_e56_bp.c', )
drivers/net/txgbe/base/txgbe.h +2 -0
@@ -13,5 +13,7 @@#include "txgbe_hw.h" #include "txgbe_vf.h" #include "txgbe_dcb.h" +#include "txgbe_e56.h" +#include "txgbe_e56_bp.h" #endif /* _TXGBE_H_ */
drivers/net/txgbe/base/txgbe_aml.c +54 -11
102 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml40.c +39 -4
73 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.c +15 -13
@@ -49,7 +49,7 @@ int compare(const void *a, const void *b) }s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up) +bool *link_up) {u32 rdata =0 ;u32 links_reg =0 ;
@@ -97,7 +97,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ; }else if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) {if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || - hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1) { + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S25G_TX_FFE_CFG_DAC_MAIN ; pre1 =S25G_TX_FFE_CFG_DAC_PRE1 ; pre2 =S25G_TX_FFE_CFG_DAC_PRE2 ;
@@ -115,7 +116,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ;if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || - hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) { + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S40G_TX_FFE_CFG_MAIN ; pre1 =S40G_TX_FFE_CFG_PRE1 ; pre2 =S40G_TX_FFE_CFG_PRE2 ;
@@ -1490,7 +1492,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1522,7 +1524,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (((rdata >> (i *8 )) &0x3f ) ==0x21 ) {break ; }if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1593,7 +1595,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) addr =E56PHY_CTRL_FSM_RX_STAT_0_ADDR ; rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1639,7 +1641,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (((rdata >> (i *8 )) &0x3f ) ==0x21 ) {break ; }if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1905,7 +1907,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -1968,7 +1970,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)EPHY_XFLD (E56G__RXS0_ANA_OVRDEN_1 , ovrd_en_ana_bbcdr_ultrafine_i) =1 ;wr32_ephy (hw, addr, rdata); }else { -DEBUGOUT ("ERROR: (SECOND_CODE <= CMVAR_SEC_LOW_TH) temperature tracking occurs Error condition\n" ); +DEBUGOUT ("ERROR: (SECOND_CODE <= CMVAR_SEC_LOW_TH) temperature tracking occurs Error condition" ); } }else if (SECOND_CODE >=CMVAR_SEC_HIGH_TH ) {if (ULTRAFINE_CODE >CMVAR_UFINE_MIN ) {
@@ -2008,7 +2010,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)EPHY_XFLD (E56G__RXS0_ANA_OVRDEN_1 , ovrd_en_ana_bbcdr_ultrafine_i) =1 ;wr32_ephy (hw, addr, rdata); }else { -DEBUGOUT ("ERROR: (SECOND_CODE >= CMVAR_SEC_HIGH_TH) temperature tracking occurs Error condition\n" ); +DEBUGOUT ("ERROR: (SECOND_CODE >= CMVAR_SEC_HIGH_TH) temperature tracking occurs Error condition" ); } } }
@@ -2081,7 +2083,7 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -3121,7 +3123,7 @@ static int txgbe_e56_disable_rx40G(struct txgbe_hw *hw) rdata =rd32_ephy (hw, addr);usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
@@ -3227,7 +3229,7 @@ static int txgbe_e56_disable_rx(struct txgbe_hw *hw)break ;usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
drivers/net/txgbe/base/txgbe_e56.h +2 -0
@@ -1742,6 +1742,8 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed);int txgbe_e56_get_temp (struct txgbe_hw *hw,int *temp);int txgbe_set_link_to_amlite (struct txgbe_hw *hw,u32 speed);int txgbe_e56_reconfig_rx (struct txgbe_hw *hw,u32 speed); +s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, +bool *link_up);s32 txgbe_e56_fec_set (struct txgbe_hw *hw);s32 txgbe_e56_fec_polling (struct txgbe_hw *hw,bool *link_up);u32 txgbe_e56_tx_ffe_cfg (struct txgbe_hw *hw,u32 speed);
drivers/net/txgbe/base/txgbe_e56_bp.c new file +2595 -0
2,595 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_hw.c +6 -0
@@ -4069,6 +4069,12 @@ s32 txgbe_reset_pipeline_raptor(struct txgbe_hw *hw)return err; } +bool txgbe_is_backplane (struct txgbe_hw *hw) +{ +return hw->phy.get_media_type (hw) == txgbe_media_type_backplane ? + true : false; +} +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask) {u32 gpio_ext =rd32 (hw,TXGBE_GPIOEXT );
drivers/net/txgbe/base/txgbe_hw.h +2 -2
@@ -118,6 +118,6 @@ s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw);bool txgbe_verify_lesm_fw_enabled_raptor (struct txgbe_hw *hw);s32 txgbe_fmgr_cmd_op (struct txgbe_hw *hw,u32 cmd,u32 cmd_addr);s32 txgbe_flash_read_dword (struct txgbe_hw *hw,u32 addr,u32 *data); -s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up); +bool txgbe_is_backplane (struct txgbe_hw *hw); +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask);#endif /* _TXGBE_HW_H_ */
drivers/net/txgbe/base/txgbe_osdep.h +4 -0
@@ -154,6 +154,10 @@ static inline u64 REVERT_BIT_MASK64(u64 mask) ((mask &0xFFFFFFFF00000000 ) >>32 ); } +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define IOMEM #define BIT (nr) (1UL << (nr))
drivers/net/txgbe/base/txgbe_phy.c +21 -0
@@ -2503,6 +2503,27 @@ void txgbe_set_phy_temp(struct txgbe_hw *hw) } } +int txgbe_is_dac_cable (struct txgbe_hw *hw) +{ +if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core1 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) +return true; + +return false; +} + +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw) +{ +if (!(txgbe_is_dac_cable (hw) ||txgbe_is_backplane (hw))) +return false; + +return hw->devarg.auto_neg ? true : false; +} +/** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure
drivers/net/txgbe/base/txgbe_phy.h +19 -0
@@ -105,6 +105,8 @@#define VR_AN_INTR_CMPLT MS16(0, 0x1)#define VR_AN_INTR_LINK MS16(1, 0x1)#define VR_AN_INTR_PG_RCV MS16(2, 0x1) +#define TXGBE_E56_AN_TXDIS MS16(3, 0x1) +#define TXGBE_E56_AN_PG_RCV MS16(4, 0x1)#define VR_AN_KR_MODE_CL 0x078003#define VR_AN_KR_MODE_CL_PDET MS16(0, 0x1)#define VR_XS_OR_PCS_MMD_DIGI_CTL1 0x038000
@@ -428,6 +430,21 @@#define TXGBE_BP_M_NAUTO 0#define TXGBE_BP_M_AUTO 1 +#define kr_read_poll (op, val, cond, sleep_us, \ + times, args...) \ +({ \ + unsigned long __sleep_us = (sleep_us); \ + u32 __times = (times); \ + u32 i; \ + for (i = 0; i < __times; i++) { \ + (val) = op(args); \ + if (cond) \ + break; \ + usleep(__sleep_us);\ + } \ + (cond) ? 0 : -1; \ +}) +#ifndef CL72_KRTR_PRBS_MODE_EN #define CL72_KRTR_PRBS_MODE_EN 0xFFFF/* open kr prbs check */ #endif
@@ -490,6 +507,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 value);void txgbe_bp_mode_set (struct txgbe_hw *hw);void txgbe_set_phy_temp (struct txgbe_hw *hw);void txgbe_bp_down_event (struct txgbe_hw *hw); +int txgbe_is_dac_cable (struct txgbe_hw *hw); +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw);s32 txgbe_kr_handle (struct txgbe_hw *hw);#endif /* _TXGBE_PHY_H_ */
drivers/net/txgbe/base/txgbe_type.h +24 -1
@@ -719,6 +719,7 @@ struct txgbe_phy_info {u32 addr;u32 id;enum txgbe_sfp_type sfp_type; +u32 fiber_suppport_speed;bool sfp_setup_needed;u32 revision;u32 media_type;
@@ -740,6 +741,7 @@ struct txgbe_phy_info {u16 ffe_pre2;u16 ffe_post;u16 fec_mode;
Lines of this file are not shown. View the raw message.
drivers/net/txgbe/txgbe_ethdev.c +108 -1
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH 15/18 net/txgbe: fix FEC mode configuration on 25G NIC
In reply to Zaiyu WangThe 25G NIC offers off, RS, Base-R, and auto FEC modes. When reconfiguring the PHY, the FEC mode must match on both sides; otherwise, the link cannot come up. The current driver fails to maintain this requirement, causing link instability.
Add proper FEC mode handling during PHY reconfiguration to guarantee link establishment.
--- drivers/net/txgbe/base/txgbe_aml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_aml.c +12 -1
@@ -282,6 +282,14 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw, !(hw->fec_mode & hw->cur_fec_link))) goto out; +if (speed ==TXGBE_LINK_SPEED_25GB_FULL && + link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + +if (link_up) + goto out; + } +rte_spinlock_lock (&hw->phy_lock); ret_status =txgbe_set_link_to_amlite (hw, speed);rte_spinlock_unlock (&hw->phy_lock);
@@ -360,7 +368,10 @@ static s32 txgbe_setup_mac_link_multispeed_fiber_aml(struct txgbe_hw *hw,/* If we already have link at this speed, just jump out */ txgbe_e56_check_phy_link (hw, &link_speed, &link_up); -if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up) + hw->cur_fec_link =txgbe_phy_fec_get (hw); + +if ((link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) && link_up && + hw->fec_mode & hw->cur_fec_link) goto out;/* Allow module to change analog characteristics (10G -> 25G) */
Signature · 1 line
2.21.0.windows.1
PATCH 16/18 net/txgbe: fix SFP module identification
In reply to Zaiyu WangSome optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
--- drivers/net/txgbe/base/txgbe_hw.c | 2 - drivers/net/txgbe/base/txgbe_phy.c | 339 ++++++++++------------------ drivers/net/txgbe/base/txgbe_phy.h | 18 +- drivers/net/txgbe/base/txgbe_type.h | 2 + 4 files changed, 132 insertions(+), 229 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +0 -2
@@ -2907,8 +2907,6 @@ s32 txgbe_init_ops_generic(struct txgbe_hw *hw) phy->read_i2c_eeprom = txgbe_read_i2c_eeprom; phy->write_i2c_eeprom = txgbe_write_i2c_eeprom; 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; phy->set_link_hostif = txgbe_hic_ephy_set_link;
drivers/net/txgbe/base/txgbe_phy.c +117 -222
469 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_phy.h +13 -5
@@ -261,7 +261,9 @@#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE0 0xA5#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE1 0xA6
@@ -289,6 +291,9 @@#define TXGBE_SFF_4x10GBASESR_CAP 0x11#define TXGBE_SFF_40GBASEPSM4_PARALLEL 0x12#define TXGBE_SFF_40GBASE_SWMD4_CAP 0x1f +#define TXGBE_SFF_COPPER_5M 0x5 +#define TXGBE_SFF_COPPER_3M 0x3 +#define TXGBE_SFF_COPPER_1M 0x1#define TXGBE_SFF_DA_SPEC_ACTIVE_LIMITING 0x4#define TXGBE_SFF_25GAUI_C2M_AOC_BER_5 0x1
@@ -296,6 +301,11 @@#define TXGBE_SFF_25GAUI_C2M_AOC_BER_12 0x18#define TXGBE_SFF_25GAUI_C2M_ACC_BER_12 0x19 +#define TXGBE_ETHERNET_COMP_OFFSET 0x83 +#define TXGBE_SFF_ETHERNET_40G_CR4 MS(3, 0x1) +#define TXGBE_SFF_ETHERNET_40G_SR4 MS(2, 0x1) +#define TXGBE_SFF_ETHERNET_40G_LR4 MS(1, 0x1) +#define TXGBE_SFF_SOFT_RS_SELECT_MASK 0x8#define TXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define TXGBE_SFF_SOFT_RS_SELECT_1G 0x0
@@ -490,14 +500,12 @@ 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, -u8 dev_addr,u8 *data);s32 txgbe_write_i2c_byte (struct txgbe_hw *hw,u8 byte_offset,u8 dev_addr,u8 data); -s32 txgbe_write_i2c_byte_unlocked (struct txgbe_hw *hw,u8 byte_offset, -u8 dev_addr,u8 data);s32 txgbe_read_i2c_sff8472 (struct txgbe_hw *hw,u8 byte_offset, -u8 *sff8472_data); +u8 *sff8472_data); +s32 txgbe_read_i2c_sff8636 (struct txgbe_hw *hw,u8 page ,u8 byte_offset, +u8 *sff8636_data);s32 txgbe_read_i2c_eeprom (struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset,
drivers/net/txgbe/base/txgbe_type.h +2 -0
@@ -702,6 +702,8 @@ struct txgbe_phy_info { u8 dev_addr, u8 data);s32 (*read_i2c_sff8472)(struct txgbe_hw *hw,u8 byte_offset,u8 *sff8472_data); +s32 (*read_i2c_sff8636)(struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 (*read_i2c_eeprom)(struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
Signature · 1 line
2.21.0.windows.1
PATCH 17/18 net/txgbe: fix get module info operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/base/txgbe_phy.h | 6 +- drivers/net/txgbe/txgbe_ethdev.c | 116 ++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 27 deletions(-)
drivers/net/txgbe/base/txgbe_phy.h +5 -1
@@ -257,11 +257,15 @@#define TXGBE_SFF_CABLE_DA_PASSIVE 0x4#define TXGBE_SFF_CABLE_DA_ACTIVE 0x8#define TXGBE_SFF_CABLE_SPEC_COMP 0x3C +#define TXGBE_SFF_DDM_IMPLEMENTED 0x40#define TXGBE_SFF_SFF_8472_SWAP 0x5C#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 -#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_SFF_REVISION_ADDR 0x01 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F + +#define TXGBE_MODULE_QSFP_MAX_LEN 640#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D
drivers/net/txgbe/txgbe_ethdev.c +90 -26
131 lines not on this page · raw message
Signature · 1 line
2.21.0.windows.1
PATCH 18/18 net/txgbe: fix get eeprom operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/txgbe_ethdev.c | 67 ++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +60 -7
@@ -5452,23 +5452,76 @@ txgbe_get_module_eeprom(struct rte_eth_dev *dev,uint8_t databyte =0xFF ;uint8_t *data = info->data;uint32_t i =0 ; +bool is_sfp = false; +u32 value; +u8 identifier =0 ; +u16 offset; +u8 page =0 ; + +if (hw->mac.type == txgbe_mac_aml40) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_PRST_LS ) +return -EIO ; + } + +if (hw->mac.type == txgbe_mac_aml) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_ABS_LS ) +return -EIO ; + }if (info->length ==0 )return -EINVAL ; -for (i = info->offset; i < info->offset + info->length; i++) { -if (i <RTE_ETH_MODULE_SFF_8079_LEN ) - status = hw->phy.read_i2c_eeprom (hw, i, &databyte); -else - status = hw->phy.read_i2c_sff8472 (hw, i, &databyte); + status = hw->mac.acquire_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +if (status) +return -EBUSY ; -if (status !=0 ) -return -EIO ; + status = hw->phy.read_i2c_eeprom (hw, +TXGBE_SFF_IDENTIFIER , + &identifier); +if (status !=0 ) + goto ERROR_IO; +if (identifier ==TXGBE_SFF_IDENTIFIER_SFP ) + is_sfp = true; + +memset (data,0 , info->length); + +for (i = info->offset; i < info->offset + info->length; i++) { +if (is_sfp) { +if (i <RTE_ETH_MODULE_SFF_8079_LEN ) + status = hw->phy.read_i2c_eeprom (hw, i, + &databyte); +else + status = hw->phy.read_i2c_sff8472 (hw, i, + &databyte); + +if (status !=0 ) + goto ERROR_IO; + }else { + offset = i; +while (offset >=RTE_ETH_MODULE_SFF_8436_LEN ) { + offset -=RTE_ETH_MODULE_SFF_8436_LEN /2 ; + page++; + } +if (page ==0 || !(data[0x2 ] &0x4 )) { + status = hw->phy.read_i2c_sff8636 (hw, page, offset, + &databyte); +if (status !=0 ) + goto ERROR_IO; + } + } data[i - info->offset] = databyte; } + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY );return 0 ; + +ERROR_IO: +PMD_DRV_LOG (ERR ,"I2C IO ERROR." ); + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +return -EIO ; }bool
Signature · 1 line
2.21.0.windows.1
Re: [PATCH 18/18] net/txgbe: fix get eeprom operation
Quoted 7 lines · On Thu, 23 Apr 2026 11:40:23 +0800 Zaiyu Wang <[email protected]> wrote:
The original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
Signed-off-by Zaiyu Wang <[email protected]>
Build errors. Must fix.
clang -Idrivers/libtmp_rte_net_txgbe.a.p -Idrivers -I../drivers -Idrivers/net/txgbe -I../drivers/net/txgbe -Idrivers/net/txgbe/base -I../drivers/net/txgbe/base -Ilib/ethdev -I../lib/ethdev -Ilib/eal/common -I../lib/eal/common -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -I../kernel/linux -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/argparse -I../lib/argparse -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Ilib/pci -I../lib/pci -Idrivers/bus/vdev -I../drivers/bus/vdev -Ilib/hash -I../lib/hash -Ilib/rcu -I../lib/rcu -Ilib/security -I../lib/security -Ilib/cryptodev -I../lib/cryptodev -Xclang -fcolor-diagnostics -pipe -D
_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wvla -Wcast-qual -Wcomma -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -Wno-format-truncation -Wno-address-of-packed-member -Wno-vla -Wno-shadow -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.txgbe -DRTE_ANNOTATE_LOCKS -Wthread-safety -MD -MQ drivers/libtmp_rte_net_txgbe.a.p/net_txgbe_base_txgbe_e56_bp.c.o -MF drivers/libtmp_rte_net_txgbe.a.p/net_txgbe_base_txgbe_e56_bp.c.o.d -o drivers/libtmp_rte_net_txgbe.a.p/net_txgbe_base_txgbe_e56_bp.c.o -c ../drivers/net/txgbe/base/txgbe_e56_bp.c../drivers/net/txgbe/base/txgbe_e56_bp.c:352:13: error: variable 'CMVAR_SEC_LOW_TH' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
352 | } else if (speed == 25) {
| ^~~~~~~~~~~../drivers/net/txgbe/base/txgbe_e56_bp.c:376:21: note: uninitialized use occurs here
376 | if (SECOND_CODE <= CMVAR_SEC_LOW_TH) {
| ^~~~~~~~~~~~~~~~../drivers/net/txgbe/base/txgbe_e56_bp.c:352:9: note: remove the 'if' if its condition is always true
352 | } else if (speed == 25) {
| ^~~~~~~~~~~~~~~~../drivers/net/txgbe/base/txgbe_e56_bp.c:322:22: note: initialize the variable 'CMVAR_SEC_LOW_TH' to silence this warning
322 | int CMVAR_SEC_LOW_TH;
| ^
| = 0
1 error generated.
v2 cover Wangxun Fixes
In reply to Zaiyu WangThis series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3774 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1744 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 278 ++ drivers/net/txgbe/base/txgbe_hw.c | 52 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 10 +- drivers/net/txgbe/base/txgbe_type.h | 39 +- drivers/net/txgbe/txgbe_ethdev.c | 390 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +- drivers/net/txgbe/txgbe_rxtx.c | 95 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9327 insertions(+), 419 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH v2 1/20 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v2 2/20 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v2 3/20 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v2 4/20 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
Fix this behavior by:
- doing nothing when we set/unset allmulti if promiscuous mode is on
- restorting the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
PATCH v2 5/20 net/txgbe: fix inaccuracy in TX rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To fix this issue, there are some changes:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +1 -0
@@ -1670,6 +1670,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,21 );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
PATCH v2 6/20 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1
PATCH v2 7/20 net/txgbe: fix Tx desc free logic
In reply to Zaiyu WangOn some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
--- drivers/net/txgbe/txgbe_rxtx.c | 9 ++++++++- drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +8 -1
@@ -100,7 +100,9 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq)volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
@@ -652,6 +654,11 @@ txgbe_xmit_cleanup(struct txgbe_tx_queue *txq)/* we have caught up to head, no work left to do */ if (desc_to_clean_to == head)return -(1 ); +else if (desc_to_clean_to > head && head > last_desc_cleaned) +return -(1 ); +else if (last_desc_cleaned > desc_to_clean_to && + (head > last_desc_cleaned || head < desc_to_clean_to)) +return -(1 ); }else {if (!(status &rte_cpu_to_le_32 (TXGBE_TXD_DD ))) { PMD_TX_FREE_LOG(DEBUG,
drivers/net/txgbe/txgbe_rxtx_vec_common.h +5 -2
@@ -94,8 +94,11 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq) txq->tx_next_dd - txq->tx_free_thresh;if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) + +volatile uint16_t head = (uint16_t )*txq->headwb_mem; +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
Signature · 1 line
2.21.0.windows.1
PATCH v2 8/20 net/txgbe: fix link flow control registers for Amber-Lite
In reply to Zaiyu WangThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
--- drivers/net/txgbe/base/txgbe_hw.c | 5 +++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/txgbe_ethdev.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +5 -0
@@ -394,6 +394,11 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );
drivers/net/txgbe/base/txgbe_regs.h +2 -0
@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)
drivers/net/txgbe/txgbe_ethdev.c +8 -2
@@ -2331,8 +2331,14 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { + hw_stats->rx_xon_packets =rd32 (hw,TXGBE_PBRXLNKXON_AML ); + hw_stats->rx_xoff_packets =rd32 (hw,TXGBE_PBRXLNKXOFF_AML ); + }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF );
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v2 08/20] net/txgbe: fix link flow control registers for Amber-Lite
Quoted 9 lines · On Wed, 29 Apr 2026 18:25:02 +0800 Zaiyu Wang <[email protected]> wrote:
The flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
Fixes fb6eb170dfa2 ("net/txgbe: add basic link configuration for Amber-Lite")Signed-off-by Zaiyu Wang <[email protected]>---
AI review warning:
Warning: txgbe_ethdev.c, in the AML branch added in txgbe_read_stats_registers(), uses assignment instead of accumulation:

if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {
hw_stats->rx_xon_packets = rd32(hw, TXGBE_PBRXLNKXON_AML);
hw_stats->rx_xoff_packets = rd32(hw, TXGBE_PBRXLNKXOFF_AML);
} else {
hw_stats->rx_xon_packets += rd32(hw, TXGBE_PBRXLNKXON);The AML registers are write-clearable (cleared with wr32(reg, 0) in txgbe_clear_hw_cntrs) rather than read-on-clear. Reads return the absolute count from the hardware. txgbe_dev_stats_reset() zeros hw_stats but does not clear the hardware register, so on the next stats_get() the counters will jump back to the absolute hardware value rather than restarting from zero. The AML path needs the same offset-tracking pattern that UPDATE_QP_COUNTER_32bit uses (or the AML registers need to be cleared in stats_reset).
PATCH v2 9/20 net/txgbe: fix link flow control config for Sapphire
In reply to Zaiyu WangSP chips have a hardware bug preventing XON flow control support, so the driver disables it.
--- drivers/net/txgbe/base/txgbe_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +4 -2
@@ -1035,8 +1035,10 @@ s32 txgbe_fc_enable(struct txgbe_hw *hw)for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {if ((hw->fc.current_mode & txgbe_fc_tx_pause) && hw->fc.high_water[i]) { - fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]) | -TXGBE_FCWTRLO_XON ; + fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]); +/* SP doesn't support xon */ +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) + fcrtl |=TXGBE_FCWTRLO_XON ; fcrth =TXGBE_FCWTRHI_TH (hw->fc.high_water[i]) |TXGBE_FCWTRHI_XOFF ; }else {
Signature · 1 line
2.21.0.windows.1
PATCH v2 10/20 net/txgbe: fix a mass of unknown interrupts
In reply to Zaiyu WangWhen RSC is enabled, Rx ring IVAR is set to configure ITR. It causes Rx ring interrupts report on the default msix_vector. Thus a mass of unknown interrupts occupy CPU.
Fix the issue by setting ring IVAR only when the rxq interrupt is enabled.
--- drivers/net/txgbe/txgbe_rxtx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +17 -13
@@ -4354,6 +4354,8 @@ static int txgbe_set_rsc(struct rte_eth_dev *dev) {struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_eth_dev_info dev_info = {0 };bool rsc_capable = false;
@@ -4404,8 +4406,6 @@ txgbe_set_rsc(struct rte_eth_dev *dev)rd32 (hw,TXGBE_RXCFG (rxq->reg_idx));uint32_t psrtype =rd32 (hw,TXGBE_POOLRSS (rxq->reg_idx)); -uint32_t eitr = -rd32 (hw,TXGBE_ITR (rxq->reg_idx));/* * txgbe PMD doesn't support header-split at the moment.
@@ -4424,6 +4424,9 @@ txgbe_set_rsc(struct rte_eth_dev *dev) srrctl |=txgbe_get_rscctl_maxdesc (rxq->mb_pool); psrtype |=TXGBE_POOLRSS_L4HDR ; +wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); +wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); +/* * RSC: Set ITR interval corresponding to 2K ints/s. *
@@ -4437,19 +4440,20 @@ txgbe_set_rsc(struct rte_eth_dev *dev)* For a sparse streaming case this setting will yield * at most 500us latency for a single RSC aggregation. */ - eitr &= ~TXGBE_ITR_IVAL_MASK ; - eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); - eitr |=TXGBE_ITR_WRDSA ; +if (rte_intr_dp_is_en (intr_handle)) { +uint32_t eitr =rd32 (hw,TXGBE_ITR (rxq->reg_idx)); -wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); -wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); -wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); + eitr &= ~TXGBE_ITR_IVAL_MASK ; + eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); + eitr |=TXGBE_ITR_WRDSA ; +wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); -/* -* RSC requires the mapping of the queue to the -* interrupt vector. -*/ -txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); +/* +* RSC requires the mapping of the queue to the +* interrupt vector. +*/ +txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); + } } dev->data->lro =1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v2 11/20 net/txgbe: fix traffic class priority configuration
In reply to Zaiyu WangAfter applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc off
The old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Fix both issues, ensuring that tc-prio mapping works as expected.
--- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_regs.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/txgbe/base/txgbe_dcb_hw.c +1 -1
@@ -154,7 +154,7 @@ s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,for (i =0 ; i <TXGBE_DCB_UP_MAX ; i++) reg |=TXGBE_DCBUP2TC_MAP (i, map[i]); -wr32 (hw,TXGBE_PBRXUP2TC , reg); +wr32 (hw,TXGBE_PBTXUP2TC , reg);/* Configure traffic class credits and priority */ for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {
drivers/net/txgbe/base/txgbe_regs.h +2 -3
@@ -503,9 +503,8 @@#define TXGBE_PBRXCTL 0x019000#define TXGBE_PBRXCTL_ST MS(0, 0x1)#define TXGBE_PBRXCTL_ENA MS(31, 0x1) -#define TXGBE_PBRXUP2TC 0x019008#define TXGBE_PBTXUP2TC 0x01C800 -#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 3 * (tc), 0x7) +#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 4 * (tc), 0x7)#define TXGBE_DCBUP2TC_DEC (tc, r) RS(r, 3 * (tc), 0x7)#define TXGBE_PBRXSIZE (tc) (0x019020 + (tc) * 4)#define TXGBE_PBRXSIZE_KB (v) LS(v, 10, 0x3FF)
@@ -1703,7 +1702,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_RDM_PF_HIDE (_i) (0x12090 + ((_i) * 4))#define TXGBE_RPUP2TC 0x019008 -#define TXGBE_RPUP2TC_UP_SHIFT 3 +#define TXGBE_RPUP2TC_UP_SHIFT 4#define TXGBE_RPUP2TC_UP_MASK 0x7#define TXGBE_RDM_DCACHE_CTL 0x0120A8
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v2 11/20] net/txgbe: fix traffic class priority configuration
Quoted 10 lines · On Wed, 29 Apr 2026 18:25:05 +0800 Zaiyu Wang <[email protected]> wrote:
After applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc offThe old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Quoted 7 lines
Fix both issues, ensuring that tc-prio mapping works as expected.
Fixes 8bdc7882f376 ("net/txgbe: support DCB")Signed-off-by Zaiyu Wang <[email protected]>---
AI review spotted issues:
Error: The fix is incomplete. The same priority-to-TC layout is also written in drivers/net/txgbe/txgbe_rxtx.c around line 3380 in txgbe_vmdq_dcb_configure():
for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
/* * mapping is done with 3 bits per priority, * so shift by i*3 each time */ queue_mapping |= ((cfg->dcb_tc[i] & 0x07) << (i * 3));
wr32(hw, TXGBE_RPUP2TC, queue_mapping);
This writes the same TXGBE_RPUP2TC register (0x019008) the patch is fixing, using a hardcoded i*3 shift and a comment claiming 3 bits per priority. After this patch, txgbe_dcb_config_rx_arbiter_raptor() encodes priorities at 4-bit positions (via the updated TXGBE_RPUP2TC_UP_SHIFT=4), but txgbe_vmdq_dcb_configure() still uses 3-bit positions. The VMDQ+DCB path will produce a wrong tc-prio mapping. txgbe_vmdq_dcb_configure() needs the same fix (use TXGBE_RPUP2TC_UP_SHIFT and update the comment).
Warning: TXGBE_DCBUP2TC_DEC and TXGBE_DCBUP2TC_MAP are now inconsistent. After this patch:
#define TXGBE_DCBUP2TC_MAP(tc, v) LS(v, 4 * (tc), 0x7)
#define TXGBE_DCBUP2TC_DEC(tc, r) RS(r, 3 * (tc), 0x7)
DEC will not decode what MAP encoded for any tc > 0. TXGBE_DCBUP2TC_DEC isn't currently used in tree, so this is not a runtime bug, but it's a latent trap. Either update DEC to also use 4*(tc), or remove DEC since it has no callers.
RE: [PATCH v2 11/20] net/txgbe: fix traffic class priority configuration
Quoted 44 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, April 29, 2026 11:12 PM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]; Jiawen Wu <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; [email protected]; Jiawen Wu <[email protected]>; Ferruh Yigit <[email protected]>
Subject: Re: [PATCH v2 11/20] net/txgbe: fix traffic class priority configurationQuoted 10 lines · On Wed, 29 Apr 2026 18:25:05 +0800 Zaiyu Wang <[email protected]> wrote:
After applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc offThe old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.Quoted 7 lines
Fix both issues, ensuring that tc-prio mapping works as expected.
Fixes 8bdc7882f376 ("net/txgbe: support DCB")Signed-off-by Zaiyu Wang <[email protected]>---
AI review spotted issues:
Error: The fix is incomplete. The same priority-to-TC layout is also written in
drivers/net/txgbe/txgbe_rxtx.caround line 3380 intxgbe_vmdq_dcb_configure():
for (i = 0; i <RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)/* * mapping is done with 3 bits per priority, * so shift by i*3 each time */ queue_mapping |= ((cfg->dcb_tc[i] & 0x07) << (i * 3));
Quoted 16 lines
wr32(hw, TXGBE_RPUP2TC, queue_mapping);
This writes the sameTXGBE_RPUP2TCregister (0x019008) the patch is fixing, using a hardcoded i*3 shift and a comment claiming 3 bits per priority. After this patch,txgbe_dcb_config_rx_arbiter_raptor()encodes priorities at 4-bit positions (via the updated TXGBE_RPUP2TC_UP_SHIFT=4), buttxgbe_vmdq_dcb_configure()still uses 3-bit positions. The VMDQ+DCB path will produce a wrong tc-prio mapping.txgbe_vmdq_dcb_configure()needs the same fix (useTXGBE_RPUP2TC_UP_SHIFTand update the comment).
Warning:TXGBE_DCBUP2TC_DECandTXGBE_DCBUP2TC_MAPare now
inconsistent. After this patch:
#defineTXGBE_DCBUP2TC_MAP(tc, v)LS(v, 4 * (tc), 0x7)
#defineTXGBE_DCBUP2TC_DEC(tc, r)RS(r, 3 * (tc), 0x7)
DEC will not decode what MAP encoded for any tc > 0.TXGBE_DCBUP2TC_DECisn't currently used in tree, so this is not a runtime bug, but it's a latent trap. Either update DEC to also use 4*(tc), or remove DEC since it has no callers.
Hi Stephen,
Thank you for the thorough AI‑assisted review. I really appreciate it.
I have addressed all the issues you raised, and an updated patch set will be sent shortly.
PATCH v2 12/20 net/txgbe: fix link stability for 25G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_aml.c | 107 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 2489 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1742 +++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 275 +++ drivers/net/txgbe/base/txgbe_hw.c | 35 +- drivers/net/txgbe/base/txgbe_phy.h | 1 - drivers/net/txgbe/base/txgbe_regs.h | 2 + drivers/net/txgbe/base/txgbe_type.h | 12 + drivers/net/txgbe/txgbe_ethdev.c | 83 +- drivers/net/txgbe/txgbe_ethdev.h | 4 + 12 files changed, 4699 insertions(+), 58 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
drivers/net/txgbe/base/meson.build +1 -0
@@ -12,4 +12,5 @@ base_sources = files( 'txgbe_mng.c', 'txgbe_phy.c', 'txgbe_vf.c', + 'txgbe_e56.c', )
drivers/net/txgbe/base/txgbe_aml.c +83 -24
171 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml.h +4 -2
@@ -16,7 +16,9 @@ s32 txgbe_get_link_capabilities_aml(struct txgbe_hw *hw, u32 *speed, bool *autoneg);u32 txgbe_get_media_type_aml (struct txgbe_hw *hw);void txgbe_wait_for_link_up_aml (struct txgbe_hw *hw,u32 speed); -s32 txgbe_setup_mac_link_aml (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml (struct txgbe_hw *hw);#endif /* _TXGBE_AML_H_ */
drivers/net/txgbe/base/txgbe_e56.c new file +2489 -0
2,489 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h new file +1742 -0
324 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h new file +275 -0
275 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +82 -1
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 12/20] net/txgbe: fix link stability for 25G NIC
Quoted 9 lines · On Wed, 29 Apr 2026 18:25:06 +0800 Zaiyu Wang <[email protected]> wrote:
The link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
Fixes ead3616f630d ("net/txgbe: support PHY configuration via SW-FW mailbox")Signed-off-by Zaiyu Wang <[email protected]>---
AI review feedback spotted some things:
Review of this patch is partial; the patch adds 2,489 lines in a new txgbe_e56.c file plus 1,742-line and 275-line headers, and a full per-function trace was not completed. From what I have looked at:
Info: drivers/net/txgbe/base/txgbe_e56.c defines a generic file-scope helper named compare for qsort. Even though it's static, the name is unhelpfully generic; consider txgbe_e56_int_cmp or similar.
Warning: txgbe_setup_phy_link_aml(): when txgbe_set_link_to_amlite() returns TXGBE_ERR_TIMEOUT the function falls through to the out: label, which then reads TXGBE_PORTSTAT and re-checks link_up. But in the timeout path link_up is whatever the earlier check_phy_link loop left it as, and the function clears hw->link_valid only in this branch — yet check_phy_link reads if (!hw->link_valid) *link_up = false;. After clearing link_valid, no further check_phy_link is called before the out: block reads link_up, so the logic still works, but it's fragile. Worth a comment or restructure.
PATCH v2 13/20 net/txgbe: fix link stability for 40G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/txgbe_aml40.c | 70 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 1471 ++++++++++++++++++++++++-- drivers/net/txgbe/txgbe_ethdev.c | 4 +- 4 files changed, 1438 insertions(+), 113 deletions(-)
drivers/net/txgbe/base/txgbe_aml40.c +55 -15
@@ -13,6 +13,7 @@#include "txgbe_hw.h" #include "txgbe_aml.h" #include "txgbe_aml40.h" +#include "txgbe_e56.h" void txgbe_init_ops_aml40 (struct txgbe_hw *hw) {
@@ -24,6 +25,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)/* PHY */ phy->get_media_type = txgbe_get_media_type_aml40; + phy->setup_link_core = txgbe_setup_phy_link_aml40;/* LINK */ mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
@@ -52,6 +54,13 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,if (link_up_wait_to_complete) {for (i =0 ; i < hw->mac.max_link_up_time; i++) { +if (!hw->link_valid) { + *link_up = false; + +msleep (100 ); +continue ; + } +if (!(links_reg &TXGBE_PORTSTAT_UP )) { *link_up = false; }else {
@@ -68,6 +77,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } +if (!hw->link_valid) + *link_up = false; +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G )
@@ -107,20 +119,24 @@ u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)return txgbe_media_type_fiber_qsfp; } -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw, -u32 speed, -bool autoneg_wait_to_complete) +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset) {bool autoneg = false;s32 status =0 ; +s32 ret_status =0 ;u32 link_speed =TXGBE_LINK_SPEED_UNKNOWN ;bool link_up = false; +int i;u32 link_capabilities =TXGBE_LINK_SPEED_UNKNOWN ; +u32 value; -if (hw->phy.sfp_type == txgbe_sfp_type_not_present) { -DEBUGOUT ("SFP not detected, skip setup mac link" ); -return 0 ; - } + *need_reset = false; + +if (hw->phy.sfp_type == txgbe_sfp_type_not_present) + hw->phy.identify_sfp (hw);/* Check to see if speed passed in is supported. */ status = hw->mac.get_link_capabilities(hw,
@@ -132,18 +148,43 @@ s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) +break ; +msleep (250 ); + }if (link_speed == speed && link_up) -return status; + goto out; -if (speed &TXGBE_LINK_SPEED_40GB_FULL ) - speed =0x20 ; +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +rte_spinlock_unlock (&hw->phy_lock); - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); +if (ret_status ==TXGBE_ERR_TIMEOUT ) + hw->link_valid = false; + +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) { +DEBUGOUT ("MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +DEBUGOUT ("MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +DEBUGOUT ("Link reconfiguration required. Reset scheduled in 2000ms." ); + }return status; }
@@ -159,6 +200,5 @@ void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw) mac->flap_tx_laser = txgbe_flap_tx_laser_multispeed_fiber; - mac->setup_link = txgbe_setup_mac_link_aml40; mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed; }
drivers/net/txgbe/base/txgbe_aml40.h +4 -2
@@ -14,7 +14,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw,s32 txgbe_get_link_capabilities_aml40 (struct txgbe_hw *hw,u32 *speed,bool *autoneg);u32 txgbe_get_media_type_aml40 (struct txgbe_hw *hw); -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml40 (struct txgbe_hw *hw);#endif /* _TXGBE_AML40_H_ */
drivers/net/txgbe/base/txgbe_e56.c +1377 -94
1,556 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2054,7 +2054,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw);rte_eal_alarm_cancel (txgbe_dev_detect_sfp, dev);
@@ -3200,7 +3200,7 @@ txgbe_dev_setup_link_thread_handler(void *param)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);rte_thread_detach (rte_thread_self ()); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)txgbe_dev_setup_link_alarm_handler_aml (hw);else txgbe_dev_setup_link_alarm_handler (dev);
Signature · 1 line
2.21.0.windows.1
PATCH v2 14/20 net/txgbe: fix link stability for Amber-Lite backplane mode
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 65 +- drivers/net/txgbe/base/txgbe_aml40.c | 43 +- drivers/net/txgbe/base/txgbe_e56.c | 22 +- drivers/net/txgbe/base/txgbe_e56.h | 2 + drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 3 + drivers/net/txgbe/base/txgbe_hw.c | 6 + drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 21 + drivers/net/txgbe/base/txgbe_phy.h | 22 + drivers/net/txgbe/base/txgbe_type.h | 25 +- drivers/net/txgbe/txgbe_ethdev.c | 109 +- drivers/net/txgbe/txgbe_ethdev.h | 2 +- 16 files changed, 2894 insertions(+), 30 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c
drivers/net/txgbe/base/meson.build +1 -0
@@ -13,4 +13,5 @@ base_sources = files( 'txgbe_phy.c', 'txgbe_vf.c', 'txgbe_e56.c', + 'txgbe_e56_bp.c', )
drivers/net/txgbe/base/txgbe.h +2 -0
@@ -13,5 +13,7 @@#include "txgbe_hw.h" #include "txgbe_vf.h" #include "txgbe_dcb.h" +#include "txgbe_e56.h" +#include "txgbe_e56_bp.h" #endif /* _TXGBE_H_ */
drivers/net/txgbe/base/txgbe_aml.c +54 -11
102 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml40.c +39 -4
73 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.c +12 -10
@@ -49,7 +49,7 @@ int compare(const void *a, const void *b) }s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up) +bool *link_up) {u32 rdata =0 ;u32 links_reg =0 ;
@@ -97,7 +97,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ; }else if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) {if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || - hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1) { + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S25G_TX_FFE_CFG_DAC_MAIN ; pre1 =S25G_TX_FFE_CFG_DAC_PRE1 ; pre2 =S25G_TX_FFE_CFG_DAC_PRE2 ;
@@ -115,7 +116,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ;if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || - hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) { + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S40G_TX_FFE_CFG_MAIN ; pre1 =S40G_TX_FFE_CFG_PRE1 ; pre2 =S40G_TX_FFE_CFG_PRE2 ;
@@ -1504,7 +1506,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1539,7 +1541,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1616,7 +1618,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) addr =E56PHY_CTRL_FSM_RX_STAT_0_ADDR ; rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1663,7 +1665,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1932,7 +1934,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -3191,7 +3193,7 @@ static int txgbe_e56_disable_rx40G(struct txgbe_hw *hw) rdata =rd32_ephy (hw, addr);usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
@@ -3297,7 +3299,7 @@ static int txgbe_e56_disable_rx(struct txgbe_hw *hw)break ;usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
drivers/net/txgbe/base/txgbe_e56.h +2 -0
@@ -1735,6 +1735,8 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed);int txgbe_e56_get_temp (struct txgbe_hw *hw,int *temp);int txgbe_set_link_to_amlite (struct txgbe_hw *hw,u32 speed);int txgbe_e56_reconfig_rx (struct txgbe_hw *hw,u32 speed); +s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, +bool *link_up);s32 txgbe_e56_fec_set (struct txgbe_hw *hw);s32 txgbe_e56_fec_polling (struct txgbe_hw *hw,bool *link_up);u32 txgbe_e56_tx_ffe_cfg (struct txgbe_hw *hw,u32 speed);
drivers/net/txgbe/base/txgbe_e56_bp.c new file +2593 -0
2,593 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h +3 -0
@@ -272,4 +272,7 @@ typedef union {#define E56PHY_CMS_ANA_OVRDVAL_10_ADDR (E56PHY_CMS_BASE_ADDR + 0xD8)#define E56PHY_CMS_ANA_OVRDVAL_7_ANA_LCPLL_LF_LPF_SETCODE_CALIB_I 8, 4 +int txgbe_e56_set_phy_link_mode (struct txgbe_hw *hw, +u8 bp_link_mode,u32 need_restart); +int handle_e56_bkp_an73_flow (struct txgbe_hw *hw);#endif
drivers/net/txgbe/base/txgbe_hw.c +6 -0
@@ -4069,6 +4069,12 @@ s32 txgbe_reset_pipeline_raptor(struct txgbe_hw *hw)return err; } +bool txgbe_is_backplane (struct txgbe_hw *hw) +{ +return hw->phy.get_media_type (hw) == txgbe_media_type_backplane ? + true : false; +} +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask) {u32 gpio_ext =rd32 (hw,TXGBE_GPIOEXT );
drivers/net/txgbe/base/txgbe_hw.h +2 -2
@@ -118,6 +118,6 @@ s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw);bool txgbe_verify_lesm_fw_enabled_raptor (struct txgbe_hw *hw);s32 txgbe_fmgr_cmd_op (struct txgbe_hw *hw,u32 cmd,u32 cmd_addr);s32 txgbe_flash_read_dword (struct txgbe_hw *hw,u32 addr,u32 *data); -s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up); +bool txgbe_is_backplane (struct txgbe_hw *hw); +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask);#endif /* _TXGBE_HW_H_ */
drivers/net/txgbe/base/txgbe_osdep.h +4 -0
@@ -162,6 +162,10 @@ static inline u64 REVERT_BIT_MASK64(u64 mask) ((mask &0xFFFFFFFF00000000 ) >>32 ); } +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define IOMEM #define BIT (nr) (1UL << (nr))
drivers/net/txgbe/base/txgbe_phy.c +21 -0
@@ -2503,6 +2503,27 @@ void txgbe_set_phy_temp(struct txgbe_hw *hw) } } +int txgbe_is_dac_cable (struct txgbe_hw *hw) +{ +if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core1 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) +return true; + +return false; +} + +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw) +{ +if (!(txgbe_is_dac_cable (hw) ||txgbe_is_backplane (hw))) +return false; + +return hw->devarg.auto_neg ? true : false; +} +/** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure
drivers/net/txgbe/base/txgbe_phy.h +22 -0
@@ -105,6 +105,8 @@#define VR_AN_INTR_CMPLT MS16(0, 0x1)#define VR_AN_INTR_LINK MS16(1, 0x1)#define VR_AN_INTR_PG_RCV MS16(2, 0x1) +#define TXGBE_E56_AN_TXDIS MS16(3, 0x1) +#define TXGBE_E56_AN_PG_RCV MS16(4, 0x1)#define VR_AN_KR_MODE_CL 0x078003#define VR_AN_KR_MODE_CL_PDET MS16(0, 0x1)#define VR_XS_OR_PCS_MMD_DIGI_CTL1 0x038000
@@ -428,6 +430,24 @@#define TXGBE_BP_M_NAUTO 0#define TXGBE_BP_M_AUTO 1 +#define kr_read_poll (op, val, cond, sleep_us, \ + times, args...) \ +({ \ + unsigned long __sleep_us = (sleep_us); \ + u32 __times = (times); \ + u32 i; \ + int __cond = 0; \ + for (i = 0; i < __times; i++) { \ + (val) = op(args); \ + if (cond) { \ + __cond = 1; \ + break; \ + } \ + usleep(__sleep_us);\ + } \ + (__cond) ? 0 : -1; \ +}) +#ifndef CL72_KRTR_PRBS_MODE_EN #define CL72_KRTR_PRBS_MODE_EN 0xFFFF/* open kr prbs check */ #endif
@@ -490,6 +510,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 value);void txgbe_bp_mode_set (struct txgbe_hw *hw);void txgbe_set_phy_temp (struct txgbe_hw *hw);void txgbe_bp_down_event (struct txgbe_hw *hw); +int txgbe_is_dac_cable (struct txgbe_hw *hw); +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw);s32 txgbe_kr_handle (struct txgbe_hw *hw);#endif /* _TXGBE_PHY_H_ */
drivers/net/txgbe/base/txgbe_type.h +24 -1
@@ -719,6 +719,7 @@ struct txgbe_phy_info {u32 addr;u32 id;enum txgbe_sfp_type sfp_type; +u32 fiber_suppport_speed;bool sfp_setup_needed;u32 revision;u32 media_type;
@@ -740,6 +741,7 @@ struct txgbe_phy_info {u16 ffe_pre2;u16 ffe_post;u16 fec_mode; +u16 bp_capa; };#define TXGBE_DEVARG_BP_AUTO "auto_neg"
@@ -895,7 +897,28 @@ struct txgbe_hw {u32 cur_fec_link;int temperature;u32 bp_link_mode; -}; +bool dac_sfp; +bool bypass_ctle; +u32 curbp_link_mode; +bool an_done; +u32 fsm; +u64 bp_event_interval; +}; +
Lines of this file are not shown. View the raw message.
drivers/net/txgbe/txgbe_ethdev.c +108 -1
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH v2 15/20 net/txgbe: fix FEC mode configuration on 25G NIC
In reply to Zaiyu WangThe 25G NIC offers off, RS, Base-R, and auto FEC modes. When reconfiguring the PHY, the FEC mode must match on both sides; otherwise, the link cannot come up. The current driver fails to maintain this requirement, causing link instability.
Add proper FEC mode handling during PHY reconfiguration to guarantee link establishment.
--- drivers/net/txgbe/base/txgbe_aml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_aml.c +12 -1
@@ -282,6 +282,14 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw, !(hw->fec_mode & hw->cur_fec_link))) goto out; +if (speed ==TXGBE_LINK_SPEED_25GB_FULL && + link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + +if (link_up) + goto out; + } +rte_spinlock_lock (&hw->phy_lock); ret_status =txgbe_set_link_to_amlite (hw, speed);rte_spinlock_unlock (&hw->phy_lock);
@@ -360,7 +368,10 @@ static s32 txgbe_setup_mac_link_multispeed_fiber_aml(struct txgbe_hw *hw,/* If we already have link at this speed, just jump out */ txgbe_e56_check_phy_link (hw, &link_speed, &link_up); -if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up) + hw->cur_fec_link =txgbe_phy_fec_get (hw); + +if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up && + hw->fec_mode & hw->cur_fec_link) goto out;/* Allow module to change analog characteristics (10G -> 25G) */
Signature · 1 line
2.21.0.windows.1
PATCH v2 16/20 net/txgbe: fix SFP module identification
In reply to Zaiyu WangSome optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
--- drivers/net/txgbe/base/txgbe_hw.c | 2 - drivers/net/txgbe/base/txgbe_phy.c | 339 ++++++++++------------------ drivers/net/txgbe/base/txgbe_phy.h | 18 +- drivers/net/txgbe/base/txgbe_type.h | 2 + 4 files changed, 132 insertions(+), 229 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +0 -2
@@ -2907,8 +2907,6 @@ s32 txgbe_init_ops_generic(struct txgbe_hw *hw) phy->read_i2c_eeprom = txgbe_read_i2c_eeprom; phy->write_i2c_eeprom = txgbe_write_i2c_eeprom; 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; phy->set_link_hostif = txgbe_hic_ephy_set_link;
drivers/net/txgbe/base/txgbe_phy.c +117 -222
469 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_phy.h +13 -5
@@ -261,7 +261,9 @@#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE0 0xA5#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE1 0xA6
@@ -289,6 +291,9 @@#define TXGBE_SFF_4x10GBASESR_CAP 0x11#define TXGBE_SFF_40GBASEPSM4_PARALLEL 0x12#define TXGBE_SFF_40GBASE_SWMD4_CAP 0x1f +#define TXGBE_SFF_COPPER_5M 0x5 +#define TXGBE_SFF_COPPER_3M 0x3 +#define TXGBE_SFF_COPPER_1M 0x1#define TXGBE_SFF_DA_SPEC_ACTIVE_LIMITING 0x4#define TXGBE_SFF_25GAUI_C2M_AOC_BER_5 0x1
@@ -296,6 +301,11 @@#define TXGBE_SFF_25GAUI_C2M_AOC_BER_12 0x18#define TXGBE_SFF_25GAUI_C2M_ACC_BER_12 0x19 +#define TXGBE_ETHERNET_COMP_OFFSET 0x83 +#define TXGBE_SFF_ETHERNET_40G_CR4 MS(3, 0x1) +#define TXGBE_SFF_ETHERNET_40G_SR4 MS(2, 0x1) +#define TXGBE_SFF_ETHERNET_40G_LR4 MS(1, 0x1) +#define TXGBE_SFF_SOFT_RS_SELECT_MASK 0x8#define TXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define TXGBE_SFF_SOFT_RS_SELECT_1G 0x0
@@ -493,14 +503,12 @@ 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, -u8 dev_addr,u8 *data);s32 txgbe_write_i2c_byte (struct txgbe_hw *hw,u8 byte_offset,u8 dev_addr,u8 data); -s32 txgbe_write_i2c_byte_unlocked (struct txgbe_hw *hw,u8 byte_offset, -u8 dev_addr,u8 data);s32 txgbe_read_i2c_sff8472 (struct txgbe_hw *hw,u8 byte_offset, -u8 *sff8472_data); +u8 *sff8472_data); +s32 txgbe_read_i2c_sff8636 (struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 txgbe_read_i2c_eeprom (struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset,
drivers/net/txgbe/base/txgbe_type.h +2 -0
@@ -702,6 +702,8 @@ struct txgbe_phy_info { u8 dev_addr, u8 data);s32 (*read_i2c_sff8472)(struct txgbe_hw *hw,u8 byte_offset,u8 *sff8472_data); +s32 (*read_i2c_sff8636)(struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 (*read_i2c_eeprom)(struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
Signature · 1 line
2.21.0.windows.1
PATCH v2 17/20 net/txgbe: fix get module info operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/base/txgbe_phy.h | 6 +- drivers/net/txgbe/txgbe_ethdev.c | 116 ++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 27 deletions(-)
drivers/net/txgbe/base/txgbe_phy.h +5 -1
@@ -257,11 +257,15 @@#define TXGBE_SFF_CABLE_DA_PASSIVE 0x4#define TXGBE_SFF_CABLE_DA_ACTIVE 0x8#define TXGBE_SFF_CABLE_SPEC_COMP 0x3C +#define TXGBE_SFF_DDM_IMPLEMENTED 0x40#define TXGBE_SFF_SFF_8472_SWAP 0x5C#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 -#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_SFF_REVISION_ADDR 0x01 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F + +#define TXGBE_MODULE_QSFP_MAX_LEN 640#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D
drivers/net/txgbe/txgbe_ethdev.c +90 -26
131 lines not on this page · raw message
Signature · 1 line
2.21.0.windows.1
PATCH v2 18/20 net/txgbe: fix get eeprom operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/txgbe_ethdev.c | 67 ++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +60 -7
@@ -5452,23 +5452,76 @@ txgbe_get_module_eeprom(struct rte_eth_dev *dev,uint8_t databyte =0xFF ;uint8_t *data = info->data;uint32_t i =0 ; +bool is_sfp = false; +u32 value; +u8 identifier =0 ; +u16 offset; +u8 page =0 ; + +if (hw->mac.type == txgbe_mac_aml40) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_PRST_LS ) +return -EIO ; + } + +if (hw->mac.type == txgbe_mac_aml) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_ABS_LS ) +return -EIO ; + }if (info->length ==0 )return -EINVAL ; -for (i = info->offset; i < info->offset + info->length; i++) { -if (i <RTE_ETH_MODULE_SFF_8079_LEN ) - status = hw->phy.read_i2c_eeprom (hw, i, &databyte); -else - status = hw->phy.read_i2c_sff8472 (hw, i, &databyte); + status = hw->mac.acquire_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +if (status) +return -EBUSY ; -if (status !=0 ) -return -EIO ; + status = hw->phy.read_i2c_eeprom (hw, +TXGBE_SFF_IDENTIFIER , + &identifier); +if (status !=0 ) + goto ERROR_IO; +if (identifier ==TXGBE_SFF_IDENTIFIER_SFP ) + is_sfp = true; + +memset (data,0 , info->length); + +for (i = info->offset; i < info->offset + info->length; i++) { +if (is_sfp) { +if (i <RTE_ETH_MODULE_SFF_8079_LEN ) + status = hw->phy.read_i2c_eeprom (hw, i, + &databyte); +else + status = hw->phy.read_i2c_sff8472 (hw, i, + &databyte); + +if (status !=0 ) + goto ERROR_IO; + }else { + offset = i; +while (offset >=RTE_ETH_MODULE_SFF_8436_LEN ) { + offset -=RTE_ETH_MODULE_SFF_8436_LEN /2 ; + page++; + } +if (page ==0 || !(data[0x2 ] &0x4 )) { + status = hw->phy.read_i2c_sff8636 (hw, page, offset, + &databyte); +if (status !=0 ) + goto ERROR_IO; + } + } data[i - info->offset] = databyte; } + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY );return 0 ; + +ERROR_IO: +PMD_DRV_LOG (ERR ,"I2C IO ERROR." ); + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +return -EIO ; }bool
Signature · 1 line
2.21.0.windows.1
PATCH v2 19/20 net/txgbe: fix to reset Tx write-back pointer
In reply to Zaiyu WangThe write-back pointer was not reset when the Tx queue was reset. This leads to the wrong Tx desc free logic. Move the resetting of pointer into txq->ops->reset(txq).
--- drivers/net/txgbe/txgbe_rxtx.c | 45 +++++++++++++---------- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 ++++ 3 files changed, 33 insertions(+), 20 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +25 -20
@@ -2320,6 +2320,12 @@ txgbe_reset_tx_queue(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
@@ -2419,7 +2425,7 @@ txgbe_get_tx_port_offloads(struct rte_eth_dev *dev)return tx_offload_capa; } -static int +static void txgbe_setup_headwb_resources (struct rte_eth_dev *dev,void *tx_queue,unsigned int socket_id)
@@ -2427,33 +2433,33 @@ txgbe_setup_headwb_resources(struct rte_eth_dev *dev,struct txgbe_hw *hw =TXGBE_DEV_HW (dev);const struct rte_memzone *headwb;struct txgbe_tx_queue *txq = tx_queue; -u8 i, headwb_size =0 ; +u8 headwb_size =0 ; -if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) { - txq->headwb_mem =NULL ; -return 0 ; - } +if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) + goto out; + +if (!hw->devarg.tx_headwb) + goto out; - headwb_size = hw->devarg.tx_headwb_size; + headwb_size = txq->headwb_size; headwb =rte_eth_dma_zone_reserve (dev,"tx_headwb_mem" , txq->queue_id,sizeof (u32) * headwb_size,TXGBE_ALIGN , socket_id);if (headwb ==NULL ) { -DEBUGOUT ("Fail to setup headwb resources: no mem" ); -txgbe_tx_queue_release (txq); -return -ENOMEM ; +PMD_DRV_LOG (INFO , +"Failed to allocate headwb memory for Tx queue %u, change to SP mode" , + txq->queue_id); + goto out; } txq->headwb = headwb; txq->headwb_dma =TMZ_PADDR (headwb); txq->headwb_mem = (uint32_t *)TMZ_VADDR (headwb); +return ; -/* Zero out headwb_mem memory */ -for (i =0 ; i < headwb_size; i++) - txq->headwb_mem[i] =0 ; - -return 0 ; +out: + txq->headwb_mem =NULL ; }int __rte_cold
@@ -2549,6 +2555,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; + txq->headwb_size = hw->devarg.tx_headwb_size;#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY );
@@ -2584,8 +2591,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,/* set up scalar TX function as appropriate */ txgbe_set_tx_function (dev, txq); -if (hw->devarg.tx_headwb) - err =txgbe_setup_headwb_resources (dev, txq, socket_id); +txgbe_setup_headwb_resources (dev, txq, socket_id); txq->ops->reset (txq); txq->desc_error =0 ;
@@ -4765,15 +4771,14 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); -if ((hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) && - hw->devarg.tx_headwb) { +if (txq->headwb_mem) {uint32_t txdctl;wr32 (hw,TXGBE_PX_TR_HEAD_ADDRL (txq->reg_idx), (uint32_t )(txq->headwb_dma &BIT_MASK32 ));wr32 (hw,TXGBE_PX_TR_HEAD_ADDRH (txq->reg_idx), (uint32_t )(txq->headwb_dma >>32 )); -if (hw->devarg.tx_headwb_size ==16 ) +if (txq->headwb_size ==16 ) txdctl =TXGBE_PX_TR_CFG_HEAD_WB |TXGBE_PX_TR_CFG_HEAD_WB_64BYTE ;else
drivers/net/txgbe/txgbe_rxtx.h +1 -0
@@ -416,6 +416,7 @@ struct txgbe_tx_queue {uint64_t desc_error;bool resetting;const struct rte_memzone *headwb; +uint16_t headwb_size;uint64_t headwb_dma;volatile uint32_t *headwb_mem; };
drivers/net/txgbe/txgbe_rxtx_vec_common.h +7 -0
@@ -255,6 +255,13 @@ _txgbe_reset_tx_queue_vec(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; + +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
Signature · 1 line
2.21.0.windows.1
PATCH v2 20/20 net/txgbe: fix to enable Tx desc check
In reply to Zaiyu WangNow lib security is enabled by default, and cannot be disabled if the driver is intended to be used. So Tdm_desc_chk is always unable to enable. Remove this restriction, and just enable the corresponding queue check.
--- drivers/net/txgbe/txgbe_rxtx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +6 -5
@@ -4771,6 +4771,12 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); +#ifdef RTE_LIBRTE_SECURITY + if (!(txq->using_ipsec)) +#endif +wr32m (hw,TXGBE_TDM_DESC_CHK (txq->reg_idx /32 ), +BIT (txq->reg_idx %32 ),BIT (txq->reg_idx %32 )); +if (txq->headwb_mem) {uint32_t txdctl;
@@ -4788,11 +4794,6 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev) } } -#ifndef RTE_LIB_SECURITY -for (i =0 ; i <4 ; i++) -wr32 (hw,TXGBE_TDM_DESC_CHK (i),0xFFFFFFFF ); -#endif -/* Device configured with multiple TX queues. */ txgbe_dev_mq_tx_configure (dev); }
Signature · 1 line
2.21.0.windows.1
v3 cover Wangxun Fixes
In reply to Zaiyu WangThis series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---
Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3774 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1744 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 278 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 11 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 414 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +- drivers/net/txgbe/txgbe_rxtx.c | 102 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9350 insertions(+), 434 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH v3 1/20 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v3 2/20 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v3 3/20 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v3 4/20 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
Fix this behavior by:
- doing nothing when we set/unset allmulti if promiscuous mode is on
- restorting the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
PATCH v3 5/20 net/txgbe: fix inaccuracy in TX rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To fix this issue, there are some changes:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +1 -0
@@ -1670,6 +1670,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,21 );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
PATCH v3 6/20 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1
PATCH v3 7/20 net/txgbe: fix Tx desc free logic
In reply to Zaiyu WangOn some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
--- drivers/net/txgbe/txgbe_rxtx.c | 9 ++++++++- drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +8 -1
@@ -100,7 +100,9 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq)volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
@@ -652,6 +654,11 @@ txgbe_xmit_cleanup(struct txgbe_tx_queue *txq)/* we have caught up to head, no work left to do */ if (desc_to_clean_to == head)return -(1 ); +else if (desc_to_clean_to > head && head > last_desc_cleaned) +return -(1 ); +else if (last_desc_cleaned > desc_to_clean_to && + (head > last_desc_cleaned || head < desc_to_clean_to)) +return -(1 ); }else {if (!(status &rte_cpu_to_le_32 (TXGBE_TXD_DD ))) { PMD_TX_FREE_LOG(DEBUG,
drivers/net/txgbe/txgbe_rxtx_vec_common.h +5 -2
@@ -94,8 +94,11 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq) txq->tx_next_dd - txq->tx_free_thresh;if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) + +volatile uint16_t head = (uint16_t )*txq->headwb_mem; +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
Signature · 1 line
2.21.0.windows.1
PATCH v3 8/20 net/txgbe: fix link flow control registers for Amber-Lite
In reply to Zaiyu WangThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
--- drivers/net/txgbe/base/txgbe_hw.c | 7 ++++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/base/txgbe_type.h | 4 ++++ drivers/net/txgbe/txgbe_ethdev.c | 34 +++++++++++++++++++---------- 4 files changed, 36 insertions(+), 11 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +7 -0
@@ -394,6 +394,13 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + hw->last_stats.rx_xon_packets =0 ; + hw->last_stats.rx_xoff_packets =0 ; + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );
drivers/net/txgbe/base/txgbe_regs.h +2 -0
@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)
drivers/net/txgbe/base/txgbe_type.h +4 -0
@@ -876,6 +876,10 @@ struct txgbe_hw {u64 tx_qp_bytes;u64 rx_qp_mc_packets; } qp_last[TXGBE_MAX_QP ]; +struct { +u64 rx_xon_packets; +u64 rx_xoff_packets; + } last_stats;rte_spinlock_t phy_lock;/*amlite: new SW-FW mbox */
drivers/net/txgbe/txgbe_ethdev.c +23 -11
@@ -2264,16 +2264,18 @@ txgbe_dev_reset(struct rte_eth_dev *dev)return ret; } +#define TXGBE_UPDATE_COUNTER_32BIT_GENERIC (reg, last, count, reset) \ + do { \ + uint32_t current = rd32(hw, reg); \ + if ((current) < (last)) \ + current += 0x100000000ULL; \ + if (reset) \ + (last) = current; \ + (count) = (uint32_t)((current) - (last)); \ + } while (0) +#define UPDATE_QP_COUNTER_32bit (reg, last_counter, counter) \ - { \ - uint32_t current_counter = rd32(hw, reg); \ - if (current_counter < last_counter) \ - current_counter += 0x100000000LL; \ - if (!hw->offset_loaded) \ - last_counter = current_counter; \ - counter = current_counter - last_counter; \ - counter &= 0xFFFFFFFFLL; \ - } + TXGBE_UPDATE_COUNTER_32BIT_GENERIC(reg, last_counter, counter, !hw->offset_loaded)#define UPDATE_QP_COUNTER_36bit (reg_lsb, reg_msb, last_counter, counter) \ { \
@@ -2331,8 +2333,18 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXON_AML , + hw->last_stats.rx_xon_packets, + hw_stats->rx_xon_packets, !hw->offset_loaded); +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXOFF_AML , + hw->last_stats.rx_xoff_packets, + hw_stats->rx_xoff_packets, !hw->offset_loaded); + }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF );
Signature · 1 line
2.21.0.windows.1
PATCH v3 9/20 net/txgbe: fix link flow control config for Sapphire
In reply to Zaiyu WangSP chips have a hardware bug preventing XON flow control support, so the driver disables it.
--- drivers/net/txgbe/base/txgbe_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +4 -2
@@ -1037,8 +1037,10 @@ s32 txgbe_fc_enable(struct txgbe_hw *hw)for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {if ((hw->fc.current_mode & txgbe_fc_tx_pause) && hw->fc.high_water[i]) { - fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]) | -TXGBE_FCWTRLO_XON ; + fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]); +/* SP doesn't support xon */ +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) + fcrtl |=TXGBE_FCWTRLO_XON ; fcrth =TXGBE_FCWTRHI_TH (hw->fc.high_water[i]) |TXGBE_FCWTRHI_XOFF ; }else {
Signature · 1 line
2.21.0.windows.1
PATCH v3 10/20 net/txgbe: fix a mass of unknown interrupts
In reply to Zaiyu WangWhen RSC is enabled, Rx ring IVAR is set to configure ITR. It causes Rx ring interrupts report on the default msix_vector. Thus a mass of unknown interrupts occupy CPU.
Fix the issue by setting ring IVAR only when the rxq interrupt is enabled.
--- drivers/net/txgbe/txgbe_rxtx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +17 -13
@@ -4354,6 +4354,8 @@ static int txgbe_set_rsc(struct rte_eth_dev *dev) {struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_eth_dev_info dev_info = {0 };bool rsc_capable = false;
@@ -4404,8 +4406,6 @@ txgbe_set_rsc(struct rte_eth_dev *dev)rd32 (hw,TXGBE_RXCFG (rxq->reg_idx));uint32_t psrtype =rd32 (hw,TXGBE_POOLRSS (rxq->reg_idx)); -uint32_t eitr = -rd32 (hw,TXGBE_ITR (rxq->reg_idx));/* * txgbe PMD doesn't support header-split at the moment.
@@ -4424,6 +4424,9 @@ txgbe_set_rsc(struct rte_eth_dev *dev) srrctl |=txgbe_get_rscctl_maxdesc (rxq->mb_pool); psrtype |=TXGBE_POOLRSS_L4HDR ; +wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); +wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); +/* * RSC: Set ITR interval corresponding to 2K ints/s. *
@@ -4437,19 +4440,20 @@ txgbe_set_rsc(struct rte_eth_dev *dev)* For a sparse streaming case this setting will yield * at most 500us latency for a single RSC aggregation. */ - eitr &= ~TXGBE_ITR_IVAL_MASK ; - eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); - eitr |=TXGBE_ITR_WRDSA ; +if (rte_intr_dp_is_en (intr_handle)) { +uint32_t eitr =rd32 (hw,TXGBE_ITR (rxq->reg_idx)); -wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); -wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); -wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); + eitr &= ~TXGBE_ITR_IVAL_MASK ; + eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); + eitr |=TXGBE_ITR_WRDSA ; +wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); -/* -* RSC requires the mapping of the queue to the -* interrupt vector. -*/ -txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); +/* +* RSC requires the mapping of the queue to the +* interrupt vector. +*/ +txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); + } } dev->data->lro =1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v3 11/20 net/txgbe: fix traffic class priority configuration
In reply to Zaiyu WangAfter applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc off
The old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Fix both issues, ensuring that tc-prio mapping works as expected. Additionally, remove the stale and inconsistent TXGBE_DCBUP2TC_DEC macro as it has no callers.
--- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_regs.h | 6 ++---- drivers/net/txgbe/txgbe_rxtx.c | 7 ++----- 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/txgbe/base/txgbe_dcb_hw.c +1 -1
@@ -154,7 +154,7 @@ s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,for (i =0 ; i <TXGBE_DCB_UP_MAX ; i++) reg |=TXGBE_DCBUP2TC_MAP (i, map[i]); -wr32 (hw,TXGBE_PBRXUP2TC , reg); +wr32 (hw,TXGBE_PBTXUP2TC , reg);/* Configure traffic class credits and priority */ for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {
drivers/net/txgbe/base/txgbe_regs.h +2 -4
@@ -503,10 +503,8 @@#define TXGBE_PBRXCTL 0x019000#define TXGBE_PBRXCTL_ST MS(0, 0x1)#define TXGBE_PBRXCTL_ENA MS(31, 0x1) -#define TXGBE_PBRXUP2TC 0x019008#define TXGBE_PBTXUP2TC 0x01C800 -#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 3 * (tc), 0x7) -#define TXGBE_DCBUP2TC_DEC (tc, r) RS(r, 3 * (tc), 0x7) +#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 4 * (tc), 0x7)#define TXGBE_PBRXSIZE (tc) (0x019020 + (tc) * 4)#define TXGBE_PBRXSIZE_KB (v) LS(v, 10, 0x3FF)
@@ -1703,7 +1701,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_RDM_PF_HIDE (_i) (0x12090 + ((_i) * 4))#define TXGBE_RPUP2TC 0x019008 -#define TXGBE_RPUP2TC_UP_SHIFT 3 +#define TXGBE_RPUP2TC_UP_SHIFT 4#define TXGBE_RPUP2TC_UP_MASK 0x7#define TXGBE_RDM_DCACHE_CTL 0x0120A8
drivers/net/txgbe/txgbe_rxtx.c +2 -5
@@ -3385,11 +3385,8 @@ txgbe_vmdq_dcb_configure(struct rte_eth_dev *dev) queue_mapping =0 ;for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) -/* -* mapping is done with 3 bits per priority, -* so shift by i*3 each time -*/ - queue_mapping |= ((cfg->dcb_tc[i] &0x07 ) << (i *3 )); + queue_mapping |= ((cfg->dcb_tc[i] &TXGBE_RPUP2TC_UP_MASK ) << + (i *TXGBE_RPUP2TC_UP_SHIFT ));wr32 (hw,TXGBE_RPUP2TC , queue_mapping);
Signature · 1 line
2.21.0.windows.1
PATCH v3 12/20 net/txgbe: fix link stability for 25G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_aml.c | 107 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 2489 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1742 +++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 275 +++ drivers/net/txgbe/base/txgbe_hw.c | 35 +- drivers/net/txgbe/base/txgbe_phy.h | 1 - drivers/net/txgbe/base/txgbe_regs.h | 2 + drivers/net/txgbe/base/txgbe_type.h | 12 + drivers/net/txgbe/txgbe_ethdev.c | 83 +- drivers/net/txgbe/txgbe_ethdev.h | 4 + 12 files changed, 4699 insertions(+), 58 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
drivers/net/txgbe/base/meson.build +1 -0
@@ -12,4 +12,5 @@ base_sources = files( 'txgbe_mng.c', 'txgbe_phy.c', 'txgbe_vf.c', + 'txgbe_e56.c', )
drivers/net/txgbe/base/txgbe_aml.c +83 -24
171 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml.h +4 -2
@@ -16,7 +16,9 @@ s32 txgbe_get_link_capabilities_aml(struct txgbe_hw *hw, u32 *speed, bool *autoneg);u32 txgbe_get_media_type_aml (struct txgbe_hw *hw);void txgbe_wait_for_link_up_aml (struct txgbe_hw *hw,u32 speed); -s32 txgbe_setup_mac_link_aml (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml (struct txgbe_hw *hw);#endif /* _TXGBE_AML_H_ */
drivers/net/txgbe/base/txgbe_e56.c new file +2489 -0
2,489 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h new file +1742 -0
324 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h new file +275 -0
275 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +82 -1
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH v3 13/20 net/txgbe: fix link stability for 40G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/txgbe_aml40.c | 70 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 1471 ++++++++++++++++++++++++-- drivers/net/txgbe/txgbe_ethdev.c | 4 +- 4 files changed, 1438 insertions(+), 113 deletions(-)
drivers/net/txgbe/base/txgbe_aml40.c +55 -15
@@ -13,6 +13,7 @@#include "txgbe_hw.h" #include "txgbe_aml.h" #include "txgbe_aml40.h" +#include "txgbe_e56.h" void txgbe_init_ops_aml40 (struct txgbe_hw *hw) {
@@ -24,6 +25,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)/* PHY */ phy->get_media_type = txgbe_get_media_type_aml40; + phy->setup_link_core = txgbe_setup_phy_link_aml40;/* LINK */ mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
@@ -52,6 +54,13 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,if (link_up_wait_to_complete) {for (i =0 ; i < hw->mac.max_link_up_time; i++) { +if (!hw->link_valid) { + *link_up = false; + +msleep (100 ); +continue ; + } +if (!(links_reg &TXGBE_PORTSTAT_UP )) { *link_up = false; }else {
@@ -68,6 +77,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } +if (!hw->link_valid) + *link_up = false; +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G )
@@ -107,20 +119,24 @@ u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)return txgbe_media_type_fiber_qsfp; } -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw, -u32 speed, -bool autoneg_wait_to_complete) +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset) {bool autoneg = false;s32 status =0 ; +s32 ret_status =0 ;u32 link_speed =TXGBE_LINK_SPEED_UNKNOWN ;bool link_up = false; +int i;u32 link_capabilities =TXGBE_LINK_SPEED_UNKNOWN ; +u32 value; -if (hw->phy.sfp_type == txgbe_sfp_type_not_present) { -DEBUGOUT ("SFP not detected, skip setup mac link" ); -return 0 ; - } + *need_reset = false; + +if (hw->phy.sfp_type == txgbe_sfp_type_not_present) + hw->phy.identify_sfp (hw);/* Check to see if speed passed in is supported. */ status = hw->mac.get_link_capabilities(hw,
@@ -132,18 +148,43 @@ s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) +break ; +msleep (250 ); + }if (link_speed == speed && link_up) -return status; + goto out; -if (speed &TXGBE_LINK_SPEED_40GB_FULL ) - speed =0x20 ; +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +rte_spinlock_unlock (&hw->phy_lock); - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); +if (ret_status ==TXGBE_ERR_TIMEOUT ) + hw->link_valid = false; + +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) { +DEBUGOUT ("MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +DEBUGOUT ("MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +DEBUGOUT ("Link reconfiguration required. Reset scheduled in 2000ms." ); + }return status; }
@@ -159,6 +200,5 @@ void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw) mac->flap_tx_laser = txgbe_flap_tx_laser_multispeed_fiber; - mac->setup_link = txgbe_setup_mac_link_aml40; mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed; }
drivers/net/txgbe/base/txgbe_aml40.h +4 -2
@@ -14,7 +14,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw,s32 txgbe_get_link_capabilities_aml40 (struct txgbe_hw *hw,u32 *speed,bool *autoneg);u32 txgbe_get_media_type_aml40 (struct txgbe_hw *hw); -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml40 (struct txgbe_hw *hw);#endif /* _TXGBE_AML40_H_ */
drivers/net/txgbe/base/txgbe_e56.c +1377 -94
1,556 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2054,7 +2054,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw);rte_eal_alarm_cancel (txgbe_dev_detect_sfp, dev);
@@ -3206,7 +3206,7 @@ txgbe_dev_setup_link_thread_handler(void *param)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);rte_thread_detach (rte_thread_self ()); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)txgbe_dev_setup_link_alarm_handler_aml (hw);else txgbe_dev_setup_link_alarm_handler (dev);
Signature · 1 line
2.21.0.windows.1
PATCH v3 14/20 net/txgbe: fix link stability for Amber-Lite backplane mode
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 65 +- drivers/net/txgbe/base/txgbe_aml40.c | 43 +- drivers/net/txgbe/base/txgbe_e56.c | 22 +- drivers/net/txgbe/base/txgbe_e56.h | 2 + drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 3 + drivers/net/txgbe/base/txgbe_hw.c | 6 + drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 21 + drivers/net/txgbe/base/txgbe_phy.h | 22 + drivers/net/txgbe/base/txgbe_type.h | 25 +- drivers/net/txgbe/txgbe_ethdev.c | 109 +- drivers/net/txgbe/txgbe_ethdev.h | 2 +- 16 files changed, 2894 insertions(+), 30 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c
drivers/net/txgbe/base/meson.build +1 -0
@@ -13,4 +13,5 @@ base_sources = files( 'txgbe_phy.c', 'txgbe_vf.c', 'txgbe_e56.c', + 'txgbe_e56_bp.c', )
drivers/net/txgbe/base/txgbe.h +2 -0
@@ -13,5 +13,7 @@#include "txgbe_hw.h" #include "txgbe_vf.h" #include "txgbe_dcb.h" +#include "txgbe_e56.h" +#include "txgbe_e56_bp.h" #endif /* _TXGBE_H_ */
drivers/net/txgbe/base/txgbe_aml.c +54 -11
102 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml40.c +39 -4
73 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.c +12 -10
@@ -49,7 +49,7 @@ int txgbe_e56_int_cmp(const void *a, const void *b) }s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up) +bool *link_up) {u32 rdata =0 ;u32 links_reg =0 ;
@@ -97,7 +97,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ; }else if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) {if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || - hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1) { + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S25G_TX_FFE_CFG_DAC_MAIN ; pre1 =S25G_TX_FFE_CFG_DAC_PRE1 ; pre2 =S25G_TX_FFE_CFG_DAC_PRE2 ;
@@ -115,7 +116,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ;if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || - hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) { + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S40G_TX_FFE_CFG_MAIN ; pre1 =S40G_TX_FFE_CFG_PRE1 ; pre2 =S40G_TX_FFE_CFG_PRE2 ;
@@ -1504,7 +1506,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1539,7 +1541,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1616,7 +1618,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) addr =E56PHY_CTRL_FSM_RX_STAT_0_ADDR ; rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1663,7 +1665,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1932,7 +1934,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -3191,7 +3193,7 @@ static int txgbe_e56_disable_rx40G(struct txgbe_hw *hw) rdata =rd32_ephy (hw, addr);usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
@@ -3297,7 +3299,7 @@ static int txgbe_e56_disable_rx(struct txgbe_hw *hw)break ;usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
drivers/net/txgbe/base/txgbe_e56.h +2 -0
@@ -1735,6 +1735,8 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed);int txgbe_e56_get_temp (struct txgbe_hw *hw,int *temp);int txgbe_set_link_to_amlite (struct txgbe_hw *hw,u32 speed);int txgbe_e56_reconfig_rx (struct txgbe_hw *hw,u32 speed); +s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, +bool *link_up);s32 txgbe_e56_fec_set (struct txgbe_hw *hw);s32 txgbe_e56_fec_polling (struct txgbe_hw *hw,bool *link_up);u32 txgbe_e56_tx_ffe_cfg (struct txgbe_hw *hw,u32 speed);
drivers/net/txgbe/base/txgbe_e56_bp.c new file +2593 -0
2,593 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h +3 -0
@@ -272,4 +272,7 @@ typedef union {#define E56PHY_CMS_ANA_OVRDVAL_10_ADDR (E56PHY_CMS_BASE_ADDR + 0xD8)#define E56PHY_CMS_ANA_OVRDVAL_7_ANA_LCPLL_LF_LPF_SETCODE_CALIB_I 8, 4 +int txgbe_e56_set_phy_link_mode (struct txgbe_hw *hw, +u8 bp_link_mode,u32 need_restart); +int handle_e56_bkp_an73_flow (struct txgbe_hw *hw);#endif
drivers/net/txgbe/base/txgbe_hw.c +6 -0
@@ -4071,6 +4071,12 @@ s32 txgbe_reset_pipeline_raptor(struct txgbe_hw *hw)return err; } +bool txgbe_is_backplane (struct txgbe_hw *hw) +{ +return hw->phy.get_media_type (hw) == txgbe_media_type_backplane ? + true : false; +} +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask) {u32 gpio_ext =rd32 (hw,TXGBE_GPIOEXT );
drivers/net/txgbe/base/txgbe_hw.h +2 -2
@@ -118,6 +118,6 @@ s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw);bool txgbe_verify_lesm_fw_enabled_raptor (struct txgbe_hw *hw);s32 txgbe_fmgr_cmd_op (struct txgbe_hw *hw,u32 cmd,u32 cmd_addr);s32 txgbe_flash_read_dword (struct txgbe_hw *hw,u32 addr,u32 *data); -s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up); +bool txgbe_is_backplane (struct txgbe_hw *hw); +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask);#endif /* _TXGBE_HW_H_ */
drivers/net/txgbe/base/txgbe_osdep.h +4 -0
@@ -162,6 +162,10 @@ static inline u64 REVERT_BIT_MASK64(u64 mask) ((mask &0xFFFFFFFF00000000 ) >>32 ); } +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define IOMEM #define BIT (nr) (1UL << (nr))
drivers/net/txgbe/base/txgbe_phy.c +21 -0
@@ -2503,6 +2503,27 @@ void txgbe_set_phy_temp(struct txgbe_hw *hw) } } +int txgbe_is_dac_cable (struct txgbe_hw *hw) +{ +if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core1 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) +return true; + +return false; +} + +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw) +{ +if (!(txgbe_is_dac_cable (hw) ||txgbe_is_backplane (hw))) +return false; + +return hw->devarg.auto_neg ? true : false; +} +/** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure
drivers/net/txgbe/base/txgbe_phy.h +22 -0
@@ -105,6 +105,8 @@#define VR_AN_INTR_CMPLT MS16(0, 0x1)#define VR_AN_INTR_LINK MS16(1, 0x1)#define VR_AN_INTR_PG_RCV MS16(2, 0x1) +#define TXGBE_E56_AN_TXDIS MS16(3, 0x1) +#define TXGBE_E56_AN_PG_RCV MS16(4, 0x1)#define VR_AN_KR_MODE_CL 0x078003#define VR_AN_KR_MODE_CL_PDET MS16(0, 0x1)#define VR_XS_OR_PCS_MMD_DIGI_CTL1 0x038000
@@ -428,6 +430,24 @@#define TXGBE_BP_M_NAUTO 0#define TXGBE_BP_M_AUTO 1 +#define kr_read_poll (op, val, cond, sleep_us, \ + times, args...) \ +({ \ + unsigned long __sleep_us = (sleep_us); \ + u32 __times = (times); \ + u32 i; \ + int __cond = 0; \ + for (i = 0; i < __times; i++) { \ + (val) = op(args); \ + if (cond) { \ + __cond = 1; \ + break; \ + } \ + usleep(__sleep_us);\ + } \ + (__cond) ? 0 : -1; \ +}) +#ifndef CL72_KRTR_PRBS_MODE_EN #define CL72_KRTR_PRBS_MODE_EN 0xFFFF/* open kr prbs check */ #endif
@@ -490,6 +510,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 value);void txgbe_bp_mode_set (struct txgbe_hw *hw);void txgbe_set_phy_temp (struct txgbe_hw *hw);void txgbe_bp_down_event (struct txgbe_hw *hw); +int txgbe_is_dac_cable (struct txgbe_hw *hw); +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw);s32 txgbe_kr_handle (struct txgbe_hw *hw);#endif /* _TXGBE_PHY_H_ */
drivers/net/txgbe/base/txgbe_type.h +24 -1
@@ -719,6 +719,7 @@ struct txgbe_phy_info {u32 addr;u32 id;enum txgbe_sfp_type sfp_type; +u32 fiber_suppport_speed;bool sfp_setup_needed;u32 revision;u32 media_type;
@@ -740,6 +741,7 @@ struct txgbe_phy_info {u16 ffe_pre2;u16 ffe_post;u16 fec_mode; +u16 bp_capa; };#define TXGBE_DEVARG_BP_AUTO "auto_neg"
@@ -899,7 +901,28 @@ struct txgbe_hw {u32 cur_fec_link;int temperature;u32 bp_link_mode; -}; +bool dac_sfp; +bool bypass_ctle; +u32 curbp_link_mode; +bool an_done; +u32 fsm; +u64 bp_event_interval; +}; +
Lines of this file are not shown. View the raw message.
drivers/net/txgbe/txgbe_ethdev.c +108 -1
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH v3 15/20 net/txgbe: fix FEC mode configuration on 25G NIC
In reply to Zaiyu WangThe 25G NIC offers off, RS, Base-R, and auto FEC modes. When reconfiguring the PHY, the FEC mode must match on both sides; otherwise, the link cannot come up. The current driver fails to maintain this requirement, causing link instability.
Add proper FEC mode handling during PHY reconfiguration to guarantee link establishment.
--- drivers/net/txgbe/base/txgbe_aml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_aml.c +12 -1
@@ -282,6 +282,14 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw, !(hw->fec_mode & hw->cur_fec_link))) goto out; +if (speed ==TXGBE_LINK_SPEED_25GB_FULL && + link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + +if (link_up) + goto out; + } +rte_spinlock_lock (&hw->phy_lock); ret_status =txgbe_set_link_to_amlite (hw, speed);rte_spinlock_unlock (&hw->phy_lock);
@@ -360,7 +368,10 @@ static s32 txgbe_setup_mac_link_multispeed_fiber_aml(struct txgbe_hw *hw,/* If we already have link at this speed, just jump out */ txgbe_e56_check_phy_link (hw, &link_speed, &link_up); -if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up) + hw->cur_fec_link =txgbe_phy_fec_get (hw); + +if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up && + hw->fec_mode & hw->cur_fec_link) goto out;/* Allow module to change analog characteristics (10G -> 25G) */
Signature · 1 line
2.21.0.windows.1
PATCH v3 16/20 net/txgbe: fix SFP module identification
In reply to Zaiyu WangSome optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
--- drivers/net/txgbe/base/txgbe_hw.c | 2 - drivers/net/txgbe/base/txgbe_phy.c | 339 ++++++++++------------------ drivers/net/txgbe/base/txgbe_phy.h | 18 +- drivers/net/txgbe/base/txgbe_type.h | 2 + 4 files changed, 132 insertions(+), 229 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +0 -2
@@ -2909,8 +2909,6 @@ s32 txgbe_init_ops_generic(struct txgbe_hw *hw) phy->read_i2c_eeprom = txgbe_read_i2c_eeprom; phy->write_i2c_eeprom = txgbe_write_i2c_eeprom; 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; phy->set_link_hostif = txgbe_hic_ephy_set_link;
drivers/net/txgbe/base/txgbe_phy.c +117 -222
469 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_phy.h +13 -5
@@ -261,7 +261,9 @@#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE0 0xA5#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE1 0xA6
@@ -289,6 +291,9 @@#define TXGBE_SFF_4x10GBASESR_CAP 0x11#define TXGBE_SFF_40GBASEPSM4_PARALLEL 0x12#define TXGBE_SFF_40GBASE_SWMD4_CAP 0x1f +#define TXGBE_SFF_COPPER_5M 0x5 +#define TXGBE_SFF_COPPER_3M 0x3 +#define TXGBE_SFF_COPPER_1M 0x1#define TXGBE_SFF_DA_SPEC_ACTIVE_LIMITING 0x4#define TXGBE_SFF_25GAUI_C2M_AOC_BER_5 0x1
@@ -296,6 +301,11 @@#define TXGBE_SFF_25GAUI_C2M_AOC_BER_12 0x18#define TXGBE_SFF_25GAUI_C2M_ACC_BER_12 0x19 +#define TXGBE_ETHERNET_COMP_OFFSET 0x83 +#define TXGBE_SFF_ETHERNET_40G_CR4 MS(3, 0x1) +#define TXGBE_SFF_ETHERNET_40G_SR4 MS(2, 0x1) +#define TXGBE_SFF_ETHERNET_40G_LR4 MS(1, 0x1) +#define TXGBE_SFF_SOFT_RS_SELECT_MASK 0x8#define TXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define TXGBE_SFF_SOFT_RS_SELECT_1G 0x0
@@ -493,14 +503,12 @@ 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, -u8 dev_addr,u8 *data);s32 txgbe_write_i2c_byte (struct txgbe_hw *hw,u8 byte_offset,u8 dev_addr,u8 data); -s32 txgbe_write_i2c_byte_unlocked (struct txgbe_hw *hw,u8 byte_offset, -u8 dev_addr,u8 data);s32 txgbe_read_i2c_sff8472 (struct txgbe_hw *hw,u8 byte_offset, -u8 *sff8472_data); +u8 *sff8472_data); +s32 txgbe_read_i2c_sff8636 (struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 txgbe_read_i2c_eeprom (struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset,
drivers/net/txgbe/base/txgbe_type.h +2 -0
@@ -702,6 +702,8 @@ struct txgbe_phy_info { u8 dev_addr, u8 data);s32 (*read_i2c_sff8472)(struct txgbe_hw *hw,u8 byte_offset,u8 *sff8472_data); +s32 (*read_i2c_sff8636)(struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 (*read_i2c_eeprom)(struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
Signature · 1 line
2.21.0.windows.1
PATCH v3 17/20 net/txgbe: fix get module info operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/base/txgbe_phy.h | 6 +- drivers/net/txgbe/txgbe_ethdev.c | 116 ++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 27 deletions(-)
drivers/net/txgbe/base/txgbe_phy.h +5 -1
@@ -257,11 +257,15 @@#define TXGBE_SFF_CABLE_DA_PASSIVE 0x4#define TXGBE_SFF_CABLE_DA_ACTIVE 0x8#define TXGBE_SFF_CABLE_SPEC_COMP 0x3C +#define TXGBE_SFF_DDM_IMPLEMENTED 0x40#define TXGBE_SFF_SFF_8472_SWAP 0x5C#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 -#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_SFF_REVISION_ADDR 0x01 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F + +#define TXGBE_MODULE_QSFP_MAX_LEN 640#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D
drivers/net/txgbe/txgbe_ethdev.c +90 -26
131 lines not on this page · raw message
Signature · 1 line
2.21.0.windows.1
PATCH v3 18/20 net/txgbe: fix get eeprom operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/txgbe_ethdev.c | 67 ++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +60 -7
@@ -5458,23 +5458,76 @@ txgbe_get_module_eeprom(struct rte_eth_dev *dev,uint8_t databyte =0xFF ;uint8_t *data = info->data;uint32_t i =0 ; +bool is_sfp = false; +u32 value; +u8 identifier =0 ; +u16 offset; +u8 page =0 ; + +if (hw->mac.type == txgbe_mac_aml40) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_PRST_LS ) +return -EIO ; + } + +if (hw->mac.type == txgbe_mac_aml) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_ABS_LS ) +return -EIO ; + }if (info->length ==0 )return -EINVAL ; -for (i = info->offset; i < info->offset + info->length; i++) { -if (i <RTE_ETH_MODULE_SFF_8079_LEN ) - status = hw->phy.read_i2c_eeprom (hw, i, &databyte); -else - status = hw->phy.read_i2c_sff8472 (hw, i, &databyte); + status = hw->mac.acquire_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +if (status) +return -EBUSY ; -if (status !=0 ) -return -EIO ; + status = hw->phy.read_i2c_eeprom (hw, +TXGBE_SFF_IDENTIFIER , + &identifier); +if (status !=0 ) + goto ERROR_IO; +if (identifier ==TXGBE_SFF_IDENTIFIER_SFP ) + is_sfp = true; + +memset (data,0 , info->length); + +for (i = info->offset; i < info->offset + info->length; i++) { +if (is_sfp) { +if (i <RTE_ETH_MODULE_SFF_8079_LEN ) + status = hw->phy.read_i2c_eeprom (hw, i, + &databyte); +else + status = hw->phy.read_i2c_sff8472 (hw, i, + &databyte); + +if (status !=0 ) + goto ERROR_IO; + }else { + offset = i; +while (offset >=RTE_ETH_MODULE_SFF_8436_LEN ) { + offset -=RTE_ETH_MODULE_SFF_8436_LEN /2 ; + page++; + } +if (page ==0 || !(data[0x2 ] &0x4 )) { + status = hw->phy.read_i2c_sff8636 (hw, page, offset, + &databyte); +if (status !=0 ) + goto ERROR_IO; + } + } data[i - info->offset] = databyte; } + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY );return 0 ; + +ERROR_IO: +PMD_DRV_LOG (ERR ,"I2C IO ERROR." ); + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +return -EIO ; }bool
Signature · 1 line
2.21.0.windows.1
PATCH v3 19/20 net/txgbe: fix to reset Tx write-back pointer
In reply to Zaiyu WangThe write-back pointer was not reset when the Tx queue was reset. This leads to the wrong Tx desc free logic. Move the resetting of pointer into txq->ops->reset(txq).
--- drivers/net/txgbe/txgbe_rxtx.c | 45 +++++++++++++---------- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 ++++ 3 files changed, 33 insertions(+), 20 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +25 -20
@@ -2320,6 +2320,12 @@ txgbe_reset_tx_queue(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
@@ -2419,7 +2425,7 @@ txgbe_get_tx_port_offloads(struct rte_eth_dev *dev)return tx_offload_capa; } -static int +static void txgbe_setup_headwb_resources (struct rte_eth_dev *dev,void *tx_queue,unsigned int socket_id)
@@ -2427,33 +2433,33 @@ txgbe_setup_headwb_resources(struct rte_eth_dev *dev,struct txgbe_hw *hw =TXGBE_DEV_HW (dev);const struct rte_memzone *headwb;struct txgbe_tx_queue *txq = tx_queue; -u8 i, headwb_size =0 ; +u8 headwb_size =0 ; -if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) { - txq->headwb_mem =NULL ; -return 0 ; - } +if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) + goto out; + +if (!hw->devarg.tx_headwb) + goto out; - headwb_size = hw->devarg.tx_headwb_size; + headwb_size = txq->headwb_size; headwb =rte_eth_dma_zone_reserve (dev,"tx_headwb_mem" , txq->queue_id,sizeof (u32) * headwb_size,TXGBE_ALIGN , socket_id);if (headwb ==NULL ) { -DEBUGOUT ("Fail to setup headwb resources: no mem" ); -txgbe_tx_queue_release (txq); -return -ENOMEM ; +PMD_DRV_LOG (INFO , +"Failed to allocate headwb memory for Tx queue %u, change to SP mode" , + txq->queue_id); + goto out; } txq->headwb = headwb; txq->headwb_dma =TMZ_PADDR (headwb); txq->headwb_mem = (uint32_t *)TMZ_VADDR (headwb); +return ; -/* Zero out headwb_mem memory */ -for (i =0 ; i < headwb_size; i++) - txq->headwb_mem[i] =0 ; - -return 0 ; +out: + txq->headwb_mem =NULL ; }int __rte_cold
@@ -2549,6 +2555,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; + txq->headwb_size = hw->devarg.tx_headwb_size;#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY );
@@ -2584,8 +2591,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,/* set up scalar TX function as appropriate */ txgbe_set_tx_function (dev, txq); -if (hw->devarg.tx_headwb) - err =txgbe_setup_headwb_resources (dev, txq, socket_id); +txgbe_setup_headwb_resources (dev, txq, socket_id); txq->ops->reset (txq); txq->desc_error =0 ;
@@ -4762,15 +4768,14 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); -if ((hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) && - hw->devarg.tx_headwb) { +if (txq->headwb_mem) {uint32_t txdctl;wr32 (hw,TXGBE_PX_TR_HEAD_ADDRL (txq->reg_idx), (uint32_t )(txq->headwb_dma &BIT_MASK32 ));wr32 (hw,TXGBE_PX_TR_HEAD_ADDRH (txq->reg_idx), (uint32_t )(txq->headwb_dma >>32 )); -if (hw->devarg.tx_headwb_size ==16 ) +if (txq->headwb_size ==16 ) txdctl =TXGBE_PX_TR_CFG_HEAD_WB |TXGBE_PX_TR_CFG_HEAD_WB_64BYTE ;else
drivers/net/txgbe/txgbe_rxtx.h +1 -0
@@ -416,6 +416,7 @@ struct txgbe_tx_queue {uint64_t desc_error;bool resetting;const struct rte_memzone *headwb; +uint16_t headwb_size;uint64_t headwb_dma;volatile uint32_t *headwb_mem; };
drivers/net/txgbe/txgbe_rxtx_vec_common.h +7 -0
@@ -255,6 +255,13 @@ _txgbe_reset_tx_queue_vec(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; + +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
Signature · 1 line
2.21.0.windows.1
PATCH v3 20/20 net/txgbe: fix to enable Tx desc check
In reply to Zaiyu WangNow lib security is enabled by default, and cannot be disabled if the driver is intended to be used. So Tdm_desc_chk is always unable to enable. Remove this restriction, and just enable the corresponding queue check.
--- drivers/net/txgbe/txgbe_rxtx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +6 -5
@@ -4768,6 +4768,12 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); +#ifdef RTE_LIBRTE_SECURITY + if (!(txq->using_ipsec)) +#endif +wr32m (hw,TXGBE_TDM_DESC_CHK (txq->reg_idx /32 ), +BIT (txq->reg_idx %32 ),BIT (txq->reg_idx %32 )); +if (txq->headwb_mem) {uint32_t txdctl;
@@ -4785,11 +4791,6 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev) } } -#ifndef RTE_LIB_SECURITY -for (i =0 ; i <4 ; i++) -wr32 (hw,TXGBE_TDM_DESC_CHK (i),0xFFFFFFFF ); -#endif -/* Device configured with multiple TX queues. */ txgbe_dev_mq_tx_configure (dev); }
Signature · 1 line
2.21.0.windows.1
Quoted 55 lines · On Sat, 9 May 2026 19:28:02 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc checkdrivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3774 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1744 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 278 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 11 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 414 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +-
Quoted 9 lines
drivers/net/txgbe/txgbe_rxtx.c | 102 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9350 insertions(+), 434 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Review will be delayed because of DPDK summit this week.
Quoted 55 lines · On Sat, 9 May 2026 19:28:02 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc checkdrivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3774 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1744 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 278 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 11 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 414 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +-
Quoted 9 lines
drivers/net/txgbe/txgbe_rxtx.c | 102 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9350 insertions(+), 434 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
New files missing SPDX headers must fix.
Quoted 79 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Sunday, May 10, 2026 1:07 AM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3 00/20] Wangxun FixesQuoted 32 lines · On Sat, 9 May 2026 19:28:02 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in TX rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get eeprom operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc checkQuoted 11 lines
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3774+++++++++++++++++++++
Quoted 12 lines
drivers/net/txgbe/base/txgbe_e56.h | 1744 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2593 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 278 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 11 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 414 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +-Quoted 9 lines
drivers/net/txgbe/txgbe_rxtx.c | 102 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9350 insertions(+), 434 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Quoted 2 lines
New files missing SPDX headers must fix.
Hi Stephen,
Thanks for catching this. Apologies for the oversight.
I've now gone through the relevant devtools checks and an updated patch set will be sent shortly.
v4 cover Wangxun Fixes
In reply to Zaiyu WangThis series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v4:
- Fixed issues identified by devtools scripts
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---
Zaiyu Wang (20):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in Tx rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get EEPROM operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 187 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 113 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3778 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1748 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 282 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 360 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 11 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 414 ++- drivers/net/txgbe/txgbe_ethdev.h | 6 +- drivers/net/txgbe/txgbe_rxtx.c | 102 +- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 14 +- 26 files changed, 9366 insertions(+), 434 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH v4 1/20 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v4 2/20 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v4 3/20 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 03/20] net/ngbe: add missing CDR config for YT PHY
Quoted 11 lines · On Mon, 11 May 2026 18:35:45 +0800 Zaiyu Wang <[email protected]> wrote:
According to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
Fixes f1268369403d ("net/ngbe: support autoneg on/off for external PHY SFI mode")Signed-off-by Zaiyu Wang <[email protected]>---
Semi-automated AI review feedback.
# DPDK Patch Review - net/ngbe: add missing CDR config for YT PHY
## Summary
This patch adds Clock Data Recovery (CDR) configuration for YT8531S PHY in Force mode (auto-negotiation disabled). No errors found.
---
## CORRECTNESS BUGS
None identified.
---
## WARNINGS
### 1. Missing error checks on PHY register writes **File:** drivers/net/ngbe/base/ngbe_phy_yt.c **Lines:** 267-268
The two ngbe_write_phy_reg_sds_ext_yt() calls do not check return values. If these PHY register writes fail, the link may be unstable (the exact problem this patch aims to fix), but the function will silently continue.
**Current code:**
```c /* force mode need to config cdr */ ngbe_write_phy_reg_sds_ext_yt(hw, 0x3, 0, 0x1434); ngbe_write_phy_reg_sds_ext_yt(hw, 0xe, 0, 0x163); value = YT_BCR_RESET | YT_BCR_DUPLEX; ```
**Suggested fix:**
```c /* force mode need to config cdr */ s32 ret; ret = ngbe_write_phy_reg_sds_ext_yt(hw, 0x3, 0, 0x1434); if (ret != 0) return ret; ret = ngbe_write_phy_reg_sds_ext_yt(hw, 0xe, 0, 0x163); if (ret != 0) return ret; value = YT_BCR_RESET | YT_BCR_DUPLEX; ```
Note: This assumes ngbe_write_phy_reg_sds_ext_yt() returns 0 on success, negative on failure (standard DPDK convention). The existing code pattern in the function does not check errors on PHY writes in the auto-negotiation path either (lines 264-265), so this may be intentional design. However, for a fix addressing link stability, propagating write failures would be more robust.
---
## INFO
### 1. Magic numbers in PHY register writes
**File:** drivers/net/ngbe/base/ngbe_phy_yt.c
**Lines:** 267-268
The CDR configuration uses literal hex values 0x1434 and 0x163 without named constants or comments explaining their meaning. This is vendor-specific configuration. Consider adding a comment referencing the PHY vendor documentation or datasheet section, or defining named constants if these values are used elsewhere.
Example:
```c /* CDR config per YT8531S datasheet section X.Y for Force mode */ #define YT_CDR_CONFIG_REG3 0x1434 #define YT_CDR_CONFIG_REGE 0x163 ngbe_write_phy_reg_sds_ext_yt(hw, 0x3, 0, YT_CDR_CONFIG_REG3); ngbe_write_phy_reg_sds_ext_yt(hw, 0xe, 0, YT_CDR_CONFIG_REGE); ```
This is a style suggestion, not a requirement, and may be deferred if the vendor documentation is not publicly available or these values are unique to this use case.
RE: [PATCH v4 03/20] net/ngbe: add missing CDR config for YT PHY
Quoted 1 line
Semi-automated AI review feedback.
Thank you for the review. Based on the feedback, I have made the following adjustments:
Quoted 5 lines
# DPDK Patch Review - net/ngbe: add missing CDR config for YT PHY ## WARNINGS
### 1. Missing error checks on PHY register writes
No code change.
In the long-term operation of the Wangxun Emerald Gigabit Ethernet controllers supported by the ngbe driver, PHY register read/write failures are virtually never observed. Consequently, ngbe_write_phy_reg_sds_ext_yt() effectively always returns 0. We currently have no plan to add return value checks for PHY register access routines, and we believe the existing approach is sufficiently robust in practice.
Quoted 5 lines
---
## INFO
### 1. Magic numbers in PHY register writes
No code change.
These values were provided by the PHY vendor (Motorcomm) and the bit definitions are not documented in publicly available register description.
Replacing them with macros such as YT_CONFIG_REG_XXX would merely introduce meaningless names without improving understandability. Therefore we prefer to keep the raw vendor values as they are.
PATCH v4 4/20 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
To resolve this, the following changes are made:
- do nothing when we set/unset allmulti if promiscuous mode is on
- restore the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 04/20] net/ngbe: fix VF promiscuous and allmulticast
Quoted 9 lines · On Mon, 11 May 2026 18:35:46 +0800 Zaiyu Wang <[email protected]> wrote:
The configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
To resolve this, the following changes are made:
- do nothing when we set/unset allmulti if promiscuous mode is on
- restore the proper mode (none or allmulti) when we disable promiscuous mode
Quoted 5 lines
Fixes 7744e90805b5 ("net/ngbe: add promiscuous and allmulticast ops for VF device")Signed-off-by Zaiyu Wang <[email protected]>---
Worth mentioning, but IMHO this is case of AI being overly pedantic. Patch is OK as is.
# Review of DPDK Patch: net/ngbe: fix VF promiscuous and allmulticast
## Summary
This patch fixes a mode conflict issue in the ngbe VF driver between promiscuous and allmulticast modes. The overall approach is correct: it prevents mode conflicts by making allmulticast operations no-ops when promiscuous mode is active, and restores the appropriate mode when disabling promiscuous.
## Errors
None identified.
## Warnings
### 1. Implicit comparison in existing code (line 1226)
**Issue:** The existing code uses if (dev->data->promiscuous == 1) which mixes explicit and implicit styles. The patch changes this to if (dev->data->promiscuous) which is implicit.
**Why it matters:** DPDK coding standards require explicit comparisons for integers (!= 0 or == 0).
**Suggested fix:**
```c
/* Line 1226 - be consistent with explicit comparison */
if (dev->data->promiscuous != 0)
return 0;
/* Line 1250 - same issue */
if (dev->data->promiscuous != 0)
return 0;
```Note: While the patch changes == 1 to implicit, the proper fix is to use != 0 since promiscuous is an integer field, not a boolean type.
### 2. Error propagation pattern inconsistency
**Issue:** The function ngbevf_dev_promiscuous_disable() returns 0 early when allmulticast check causes mode selection, but this early return bypasses the switch statement's error handling for the actual mode update call.
**Context:** This is not a bug in the patch itself—the early returns in ngbevf_dev_allmulticast_enable() and ngbevf_dev_allmulticast_disable() when promiscuous mode is active are correct (those are intentional no-ops). The mode variable change in ngbevf_dev_promiscuous_disable() correctly passes through to the existing switch statement for error handling.
No change needed—this comment is for clarity only.
## Info
### Code structure observation
The logic correctly handles the mode transitions:
- When disabling promiscuous mode, it checks all_multicast flag and sets the appropriate target mode (ALLMULTI if enabled, NONE otherwise)
- When enabling/disabling allmulticast while promiscuous is active, it returns early as a no-op (correct, since promiscuous overrides allmulticast)
This is a clean fix for the mode conflict issue described in the commit message.
---
## Final Recommendation
Address the implicit comparison style issue (Warning #1) to comply with DPDK coding standards. Change if (dev->data->promiscuous) to if (dev->data->promiscuous != 0) in both locations (lines 1226 and 1250).
RE: [PATCH v4 04/20] net/ngbe: fix VF promiscuous and allmulticast
Quoted 27 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, May 18, 2026 7:39 AM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]; Jiawen Wu <[email protected]>; [email protected]; [email protected]; Jiawen Wu <[email protected]>
Subject: Re: [PATCH v4 04/20] net/ngbe: fix VF promiscuous and allmulticastQuoted 13 lines · On Mon, 11 May 2026 18:35:46 +0800 Zaiyu Wang <[email protected]> wrote:
The configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
To resolve this, the following changes are made:
- do nothing when we set/unset allmulti if promiscuous mode is on
- restore the proper mode (none or allmulti) when we disable promiscuous modeFixes 7744e90805b5 ("net/ngbe: add promiscuous and allmulticast opsfor VF device")
Cc: [email protected]
Quoted 5 lines
Quoted 2 lines
Signed-off-by Zaiyu Wang <[email protected]>---
Worth mentioning, but IMHO this is case of AI being overly pedantic. Patch is OK as is.
Thanks.
PATCH v4 5/20 net/txgbe: fix inaccuracy in Tx rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To address this, the following changes are made:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +1 -0
@@ -1670,6 +1670,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,21 );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 05/20] net/txgbe: fix inaccuracy in Tx rate limiting
Quoted 8 lines · On Mon, 11 May 2026 18:35:47 +0800 Zaiyu Wang <[email protected]> wrote:
Amber-lite NIC's TX rate limiting has large deviations for small packets. To address this, the following changes are made:
1. Set
TDM_RL_ADJ(0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
Quoted 8 lines
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
Fixes a309ab43acf3 ("net/txgbe: support Tx queue rate limiting for Amber-Lite")Signed-off-by Zaiyu Wang <[email protected]>---
AI feedback on this one. Looks ok as is but worth looking at.
# DPDK Patch Review: net/txgbe: fix inaccuracy in Tx rate limiting
## Summary
This patch improves TX rate limiting accuracy for Amber-lite NIC by:
1. Setting TDM_RL_ADJ register to 21B (Ethernet framing overhead)
2. Removing the 105/100 compensation factor
## Review Findings
### **Errors**
None found.
### **Warnings**
**1. TDM_RL_ADJ write placement causes per-queue reconfiguration**
The TXGBE_TDM_RL_ADJ register write is inside the per-queue rate limit configuration loop, causing the same global register to be written every time any queue's rate limit is set. This register appears to be a global hardware adjustment parameter (affects all queues), not a per-queue setting.
**Suggested fix:** Move the register write outside the queue configuration context, ideally to device initialization or as a one-time setup when rate limiting is first enabled:
```c
/* Set once during device init or first rate limit config */
static bool rl_adj_initialized = false;
if (!rl_adj_initialized) {
wr32(hw, TXGBE_TDM_RL_ADJ, 21);
rl_adj_initialized = true;
}
wr32(hw, TXGBE_TDM_RL_QUEUE_IDX, queue_idx);
```Or better yet, move it to a device initialization function if this is a hardware parameter that should be set once at device start.
**2. Magic number 21 lacks explanation**
The value 21 is documented in the commit message but not in the code. Future maintainers will not see the breakdown (7B preamble + 1B SFD + 1B EFD + 12B IPG).
**Suggested fix:** Add a comment or define:
```c /* Ethernet framing overhead: 7B preamble + 1B SFD + 1B EFD + 12B IPG */ #define TXGBE_TDM_RL_ADJ_OVERHEAD 21 wr32(hw, TXGBE_TDM_RL_ADJ, TXGBE_TDM_RL_ADJ_OVERHEAD); ```
**3. Missing release notes update**
This is a fix that changes hardware behavior and improves accuracy. Users may observe different TX rates after upgrading. The change should be documented in release notes to inform users of the accuracy improvement.
**Suggested fix:** Add an entry to doc/guides/rel_notes/release_26_11.rst (or current release):
```rst * **net/txgbe: Improved TX rate limiting accuracy for Amber-lite NIC.** Fixed TX rate limiting accuracy for 64-byte packets from ~20% deviation to within ~5% by correcting hardware framing overhead configuration. ```
### **Info**
**1. Consider validating tx_rate is non-zero**
The code computes factor_int = link_speed / tx_rate. If tx_rate is somehow zero (due to caller error or invalid input), this would cause division by zero. The existing code may have validation elsewhere, but defensive programming would check this.
```c
if (tx_rate == 0) {
PMD_DRV_LOG(ERR, "TX rate cannot be zero");
return -EINVAL;
}
```**2. Variable scope: factor_fra could be declared at initialization**
The variable factor_fra is declared but not initialized, then assigned in both branches of the conditional. C99 style would allow:
```c
u32 factor_fra = (frac * 16384) / 10000;
if (factor_fra >= 8192)
factor_fra = 0;
```This is stylistic only; the existing code is correct.
RE: [PATCH v4 05/20] net/txgbe: fix inaccuracy in Tx rate limiting
Quoted 1 line
AI feedback on this one. Looks ok as is but worth looking at.
Thank you for the review. Based on the feedback, I have made the following adjustments:
Quoted 8 lines
# DPDK Patch Review: net/txgbe: fix inaccuracy in Tx rate limiting ### **Errors**
None found.
### **Warnings**
**1.
TDM_RL_ADJwrite placement causes per-queue reconfiguration**
No code changetxgbe_set_queue_rate_limit() is directly exposed as the eth_dev_ops.set_queue_rate_limit to upper-layer applications. We cannot expect applications to perform any additional setup before calling this interface, so the driver must reconfig.
Writing the same value to this register multiple times is harmless. Therefore I prefer to keep the current approach.
Quoted 6 lines
**2. Magic number 21 lacks explanation**
The value 21 is documented in the commit message but not in the code. Future maintainers will not see the breakdown (7B preamble + 1B SFD + 1B EFD + 12B IPG).
Quoted 7 lines
**Suggested fix:** Add a comment or define:
```c
/* Ethernet framing overhead: 7B preamble + 1B SFD + 1B EFD + 12B IPG */ #defineTXGBE_TDM_RL_ADJ_OVERHEAD21wr32(hw, TXGBE_TDM_RL_ADJ, TXGBE_TDM_RL_ADJ_OVERHEAD); ```
I have added a macro TXGBE_FRAME_OVERHEAD.
Quoted 25 lines
**3. Missing release notes update**
This is a fix that changes hardware behavior and improves accuracy. Users may observe different TX rates after upgrading. The change should be documented in release notes to inform users of the accuracy improvement.
**Suggested fix:** Add an entry to
doc/guides/rel_notes/release_26_11.rst(or current release):```rst * **net/txgbe: Improved TX rate limiting accuracy for Amber-lite NIC.** Fixed TX rate limiting accuracy for 64-byte packets from ~20% deviation to within ~5% by correcting hardware framing overhead configuration. ```### **Info**
**1. Consider validating
tx_rateis non-zero**The code computes
factor_int = link_speed / tx_rate. Iftx_rateis somehow zero (due to caller error or invalid input), this would cause division by zero. The existing code may have validation elsewhere, but defensive programming would check this.
Quoted 6 lines
```c
if (tx_rate == 0) {
PMD_DRV_LOG(ERR, "TX rate cannot be zero");
return -EINVAL;
}
```No code change
In this function, tx_rate == 0 is a valid input meaning "remove rate limiting and restore unlimited mode". No additional check is needed.>
Quoted 5 lines
**2. Variable scope:
factor_fracould be declared at initialization**The variable
factor_frais declared but not initialized, then assigned in both branches of the conditional. C99 style would allow:
Quoted 7 lines
```c u32 factor_fra = (frac * 16384) / 10000; if (factor_fra >= 8192) factor_fra = 0; ```This is stylistic only; the existing code is correct.
No code change
Just leave it as is.
PATCH v4 6/20 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1
PATCH v4 7/20 net/txgbe: fix Tx desc free logic
In reply to Zaiyu WangOn some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
--- drivers/net/txgbe/txgbe_rxtx.c | 9 ++++++++- drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +8 -1
@@ -100,7 +100,9 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq)volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
@@ -652,6 +654,11 @@ txgbe_xmit_cleanup(struct txgbe_tx_queue *txq)/* we have caught up to head, no work left to do */ if (desc_to_clean_to == head)return -(1 ); +else if (desc_to_clean_to > head && head > last_desc_cleaned) +return -(1 ); +else if (last_desc_cleaned > desc_to_clean_to && + (head > last_desc_cleaned || head < desc_to_clean_to)) +return -(1 ); }else {if (!(status &rte_cpu_to_le_32 (TXGBE_TXD_DD ))) { PMD_TX_FREE_LOG(DEBUG,
drivers/net/txgbe/txgbe_rxtx_vec_common.h +5 -2
@@ -94,8 +94,11 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq) txq->tx_next_dd - txq->tx_free_thresh;if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) + +volatile uint16_t head = (uint16_t )*txq->headwb_mem; +if (txq->tx_next_dd == head) +return 0 ; +else if (txq->tx_next_dd > head && head > tx_last_dd)return 0 ;else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd))
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 07/20] net/txgbe: fix Tx desc free logic
Quoted 19 lines · On Mon, 11 May 2026 18:35:49 +0800 Zaiyu Wang <[email protected]> wrote:
On some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
Quoted 5 lines
Fixes 8ada71d0bb7f ("net/txgbe: add Tx head write-back mode for Amber-Lite")Signed-off-by Zaiyu Wang <[email protected]>---
Lots of AI feedback on this one.
# Review of DPDK Patch: net/txgbe: fix Tx desc free logic
## Errors
### 1. Shared variable access without atomics (3 locations)
**Lines affected:**
- drivers/net/txgbe/txgbe_rxtx.c:101 (txgbe_tx_free_bufs)
- drivers/net/txgbe/txgbe_rxtx.c:655 (txgbe_xmit_cleanup)
- drivers/net/txgbe/txgbe_rxtx_vec_common.h:98 (txgbe_tx_free_bufs)
```c volatile uint16_t head = (uint16_t)*txq->headwb_mem; ```
**Problem:** The code reads a hardware-updated value (*txq->headwb_mem) using a volatile qualifier. The volatile keyword does NOT provide atomicity or memory ordering guarantees between the hardware and CPU. On some architectures, reading a uint16_t from DMA-accessible memory without proper barriers or atomic operations can result in torn reads, stale cached values, or reordering issues.
**Fix:** Use atomic load with appropriate memory ordering:
```c
uint16_t head = rte_atomic_load_explicit(
(uint16_t *)txq->headwb_mem,
rte_memory_order_acquire);
```The acquire ordering ensures that all descriptor writes by the hardware are visible to the CPU after reading the head pointer. This is critical for correctness in hardware write-back scenarios.
Note: The headwb_mem field type may need adjustment to be an rte_atomic type or cast appropriately.
---
### 2. Whitespace/indentation error in vec_common.h
**Line:** drivers/net/txgbe/txgbe_rxtx_vec_common.h:97-98
```c tx_last_dd -= txq->nb_tx_desc; volatile uint16_t head = (uint16_t)*txq->headwb_mem; ```
**Problem:** Inconsistent indentation. The volatile uint16_t head declaration is indented with tabs-only (correct), but it visually appears to be part of a removed block based on the diff context showing the previous line had different indentation.
**Fix:** Verify the indentation matches the surrounding code block. Based on the diff, this appears correct after the change, but confirm the tabs align with the function's indentation level.
---
## Warnings
### 1. Logic change correctness verification needed
The patch adds three new early-return conditions checking if head == tx_next_dd. While this appears correct (hardware hasn't advanced past the point we want to free to), the logic for wrap-around cases should be verified:
```c
if (txq->tx_next_dd == head)
return 0;
else if (txq->tx_next_dd > head && head > tx_last_dd)
return 0;
else if (tx_last_dd > txq->tx_next_dd &&
(head > tx_last_dd || head < txq->tx_next_dd))
return 0;
```**Concern:** The wrap-around logic assumes the ring wraps at nb_tx_desc. The condition tx_last_dd > txq->tx_next_dd handles the wrap case, but verify that:
- tx_last_dd calculation correctly wraps (it does: tx_last_dd -= txq->nb_tx_desc)
- The inequality checks are strict > not >= consistently
The existing code appears correct, but this is complex boundary logic that warrants testing, especially the second else if condition in wrap-around scenarios.
---
### 2. Missing const qualifier on read-only atomic load result
**All three locations:** The head variable is read from hardware but never modified:
```c volatile uint16_t head = (uint16_t)*txq->headwb_mem; ```
**Suggestion:** Once converted to atomic operations, declare as const:
```c const uint16_t head = rte_atomic_load_explicit(...); ```
This documents that head is never modified after the initial read and prevents accidental writes.
---
## Info
### 1. Consider helper function for repeated logic
The same boundary-check logic appears in three separate functions with only minor variations. Consider extracting it to a static inline helper:
```c
static inline bool
txgbe_hw_head_in_range(uint16_t hw_head, uint16_t start,
uint16_t end, uint16_t ring_size)
{
if (start == hw_head)
return false;
if (start > hw_head)
return hw_head <= end;
else /* wrap case */
return hw_head > end || hw_head < start;
}
```This would reduce code duplication and make the logic easier to test and maintain.
---
### 2. Comment explaining write-back head semantics
The commit message mentions "Tx head write-back mode" but the code lacks comments explaining the hardware behavior. Consider adding:
```c /* * In Amber-Lite NIC Tx head write-back mode, hardware periodically * updates *headwb_mem with the index of the next descriptor to process. * Descriptors before this head pointer are safe to free. */ const uint16_t head = rte_atomic_load_explicit(...); ```
---
## Summary
**Must fix (Errors):**
1. Replace volatile read with rte_atomic_load_explicit() with rte_memory_order_acquire ordering in all three locations
**Should fix (Warnings):**
1. Add const qualifier to the loaded head value after converting to atomics
2. Verify wrap-around boundary logic with testing (appears correct but is complex)
**Consider (Info):**
1. Extract repeated boundary-check logic to a helper function
2. Add comments documenting hardware write-back semantics
The core fix (adding the head == tx_next_dd check) appears correct and addresses the described bug. The primary issue is the use of volatile instead of proper atomic operations for accessing hardware-updated shared memory.
RE: [PATCH v4 07/20] net/txgbe: fix Tx desc free logic
Quoted 30 lines
Lots of AI feedback on this one.
# Review of DPDK Patch: net/txgbe: fix Tx desc free logic
## Errors
### 1. Shared variable access without atomics (3 locations)
**Lines affected:**
-drivers/net/txgbe/txgbe_rxtx.c:101(txgbe_tx_free_bufs)
-drivers/net/txgbe/txgbe_rxtx.c:655(txgbe_xmit_cleanup)
-drivers/net/txgbe/txgbe_rxtx_vec_common.h:98(txgbe_tx_free_bufs)```c volatile uint16_t head = (uint16_t)*txq->headwb_mem; ``` **Problem:** The code reads a hardware-updated value (`*txq->headwb_mem`) using a `volatile` qualifier. The `volatile` keyword does NOT provide atomicity or memory ordering guarantees between the hardware and CPU. On some architectures, reading a `uint16_t` from DMA-accessible memory without proper barriers or atomic operations can result in torn reads, stale cached values, or reordering issues. **Fix:** Use atomic load with appropriate memory ordering: ```c uint16_t head = rte_atomic_load_explicit( (uint16_t *)txq->headwb_mem, rte_memory_order_acquire);
Quoted 9 lines
```
The
acquireordering ensures that all descriptor writes by the hardware are visible to the CPU after reading the head pointer. This is critical for correctness in hardware write-back scenarios.Note: The
headwb_memfield type may need adjustment to be anrte_atomictype or cast appropriately.
Fixed. All three reads from headwb_mem now use rte_atomic_load_explicit with rte_memory_order_acquire, and the loaded value is declared const.
Quoted 11 lines
---
### 2. Whitespace/indentation error in
vec_common.h**Line:**
drivers/net/txgbe/txgbe_rxtx_vec_common.h:97-98```c
tx_last_dd -= txq->nb_tx_desc; volatile uint16_t head = (uint16_t)*txq->headwb_mem; ```
Quoted 8 lines
**Problem:** Inconsistent indentation. The
volatile uint16_t headdeclaration is indented with tabs-only (correct), but it visually appears to be part of a removed block based on the diff context showing the previous line had different indentation.**Fix:** Verify the indentation matches the surrounding code block. Based on the diff, this appears correct after the change, but confirm the tabs align with the function's indentation level.
Verified, the indentation is correct and matches the surrounding code.
Quoted 21 lines
---
## Warnings
### 1. Logic change correctness verification needed
The patch adds three new early-return conditions checking if
head == tx_next_dd. While this appears correct (hardware hasn't advanced past the point we want to free to), the logic for wrap-around cases should be verified:```c if (txq->tx_next_dd == head) return 0; else if (txq->tx_next_dd > head && head > tx_last_dd) return 0; else if (tx_last_dd > txq->tx_next_dd && (head > tx_last_dd || head < txq->tx_next_dd)) return 0; ```
Quoted 7 lines
**Concern:** The wrap-around logic assumes the ring wraps at
nb_tx_desc. The conditiontx_last_dd > txq->tx_next_ddhandles the wrap case, but verify that:
-tx_last_ddcalculation correctly wraps (it does:tx_last_dd -= txq->nb_tx_desc)
- The inequality checks are strict>not>=consistentlyThe existing code appears correct, but this is complex boundary logic that warrants testing, especially the second
else ifcondition in wrap-around scenarios.
The logic has been carefully reviewed and tested. The extracted helper function preserves the exact same conditions as the original code, so no behavioural change is introduced.
Quoted 14 lines
---
### 2. Missing const qualifier on read-only atomic load result
**All three locations:** The
headvariable is read from hardware but never modified:```c volatile uint16_t head = (uint16_t)*txq->headwb_mem; ``` **Suggestion:** Once converted to atomic operations, declare as `const`: ```c
Quoted 4 lines
const
uint16_thead =rte_atomic_load_explicit(...); ```This documents that
headis never modified after the initial read and prevents accidental writes.
Done, the loaded head value is now const.
Quoted 22 lines
---
## Info
### 1. Consider helper function for repeated logic
The same boundary-check logic appears in three separate functions with only minor variations. Consider extracting it to a static inline helper:
```c
static inline bool txgbe_hw_head_in_range(uint16_thw_head,uint16_tstart,uint16_t end, uint16_t ring_size) { if (start == hw_head) return false; if (start > hw_head) return hw_head <= end; else /* wrap case */ return hw_head > end || hw_head < start; } ```
Quoted 1 line
This would reduce code duplication and make the logic easier to test and maintain.
I have extracted the common boundary-check logic into a new static inline helper, txgbe_tx_headwb_desc_done(), placed in txgbe_rxtx.h. All three call sites now use this helper.
Quoted 8 lines
---
### 2. Comment explaining write-back head semantics
The commit message mentions "Tx head write-back mode" but the code lacks comments explaining the hardware behavior. Consider adding:
Quoted 7 lines
```c
/*
* In Amber-Lite NIC Tx head write-back mode, hardware periodically
* updates*headwb_memwith the index of the next descriptor to process.
* Descriptors before this head pointer are safe to free.
*/
constuint16_thead =rte_atomic_load_explicit(...); ```
Added a detailed comment for the helper function explaining the hardware behavior and the (last, next] interval semantics.
Quoted 22 lines
---
## Summary
**Must fix (Errors):**
1. Replacevolatileread withrte_atomic_load_explicit()withrte_memory_order_acquireordering in all three locations**Should fix (Warnings):**
1. Addconstqualifier to the loadedheadvalue after converting to atomics 2. Verify wrap-around boundary logic with testing (appears correct but is complex)**Consider (Info):**
1. Extract repeated boundary-check logic to a helper function 2. Add comments documenting hardware write-back semanticsThe core fix (adding the
head == tx_next_ddcheck) appears correct and addresses the described bug. The primary issue is the use ofvolatileinstead of proper atomic operations for accessing hardware-updated shared memory.
PATCH v4 8/20 net/txgbe: fix link flow control registers for Amber-Lite
In reply to Zaiyu WangThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
--- drivers/net/txgbe/base/txgbe_hw.c | 7 ++++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/base/txgbe_type.h | 4 ++++ drivers/net/txgbe/txgbe_ethdev.c | 34 +++++++++++++++++++---------- 4 files changed, 36 insertions(+), 11 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +7 -0
@@ -394,6 +394,13 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + hw->last_stats.rx_xon_packets =0 ; + hw->last_stats.rx_xoff_packets =0 ; + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );
drivers/net/txgbe/base/txgbe_regs.h +2 -0
@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)
drivers/net/txgbe/base/txgbe_type.h +4 -0
@@ -876,6 +876,10 @@ struct txgbe_hw {u64 tx_qp_bytes;u64 rx_qp_mc_packets; } qp_last[TXGBE_MAX_QP ]; +struct { +u64 rx_xon_packets; +u64 rx_xoff_packets; + } last_stats;rte_spinlock_t phy_lock;/*amlite: new SW-FW mbox */
drivers/net/txgbe/txgbe_ethdev.c +23 -11
@@ -2264,16 +2264,18 @@ txgbe_dev_reset(struct rte_eth_dev *dev)return ret; } +#define TXGBE_UPDATE_COUNTER_32BIT_GENERIC (reg, last, count, reset) \ + do { \ + uint32_t current = rd32(hw, reg); \ + if ((current) < (last)) \ + current += 0x100000000ULL; \ + if (reset) \ + (last) = current; \ + (count) = (uint32_t)((current) - (last)); \ + } while (0) +#define UPDATE_QP_COUNTER_32bit (reg, last_counter, counter) \ - { \ - uint32_t current_counter = rd32(hw, reg); \ - if (current_counter < last_counter) \ - current_counter += 0x100000000LL; \ - if (!hw->offset_loaded) \ - last_counter = current_counter; \ - counter = current_counter - last_counter; \ - counter &= 0xFFFFFFFFLL; \ - } + TXGBE_UPDATE_COUNTER_32BIT_GENERIC(reg, last_counter, counter, !hw->offset_loaded)#define UPDATE_QP_COUNTER_36bit (reg_lsb, reg_msb, last_counter, counter) \ { \
@@ -2331,8 +2333,18 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXON_AML , + hw->last_stats.rx_xon_packets, + hw_stats->rx_xon_packets, !hw->offset_loaded); +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXOFF_AML , + hw->last_stats.rx_xoff_packets, + hw_stats->rx_xoff_packets, !hw->offset_loaded); + }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF );
Signature · 1 line
2.21.0.windows.1
PATCH v4 9/20 net/txgbe: fix link flow control config for Sapphire
In reply to Zaiyu WangSP chips have a hardware bug preventing XON flow control support, so the driver disables it.
--- drivers/net/txgbe/base/txgbe_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +4 -2
@@ -1037,8 +1037,10 @@ s32 txgbe_fc_enable(struct txgbe_hw *hw)for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {if ((hw->fc.current_mode & txgbe_fc_tx_pause) && hw->fc.high_water[i]) { - fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]) | -TXGBE_FCWTRLO_XON ; + fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]); +/* SP doesn't support xon */ +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) + fcrtl |=TXGBE_FCWTRLO_XON ; fcrth =TXGBE_FCWTRHI_TH (hw->fc.high_water[i]) |TXGBE_FCWTRHI_XOFF ; }else {
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 09/20] net/txgbe: fix link flow control config for Sapphire
Quoted 8 lines · On Mon, 11 May 2026 18:35:51 +0800 Zaiyu Wang <[email protected]> wrote:
SP chips have a hardware bug preventing XON flow control support, so the driver disables it.
Fixes 69ce8c8a4ce3 ("net/txgbe: support flow control")Signed-off-by Zaiyu Wang <[email protected]>---
Comment vs code mismatch
# Review of Patch 9/20: net/txgbe: fix link flow control config for Sapphire
## Errors
None.
## Warnings
### W1: Conditional logic inverted (line 1042-1043)
The comment states "SP doesn't support xon" but the condition enables XON for txgbe_mac_aml and txgbe_mac_aml40, which are **not** SP chips based on typical wangxun naming. The logic appears inverted.
**Why this matters**: If SP chips are txgbe_mac_sp or similar (not aml/aml40), then XON is being enabled on the wrong hardware, causing the bug the patch claims to fix.
**Suggested fix**: Verify the hardware type constants. If SP chips are a different enum value, the condition should be:
```c
/* SP doesn't support xon */
if (hw->mac.type != txgbe_mac_sp && hw->mac.type != txgbe_mac_sp40)
fcrtl |= TXGBE_FCWTRLO_XON;
```Or if the current condition is correct, the comment should read "Only AML supports xon" to match the code.
### W2: Inconsistent capitalization in comment (line 1042)
Comment uses lowercase "xon" while the code uses uppercase XON in the macro name TXGBE_FCWTRLO_XON.
**Suggested fix**:
```c /* SP doesn't support XON */ ```
## Info
None.
---
**Summary**: The primary concern is the apparent mismatch between the comment and the conditional logic. The patch claims to disable XON for SP chips, but the condition enables it for aml/aml40. This requires verification that either the comment is wrong or the condition should be negated/use different constants.
RE: [PATCH v4 09/20] net/txgbe: fix link flow control config for Sapphire
Quoted 29 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, May 18, 2026 7:46 AM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]; Jiawen Wu <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; [email protected]; Jiawen Wu <[email protected]>; Ferruh Yigit <[email protected]>
Subject: Re: [PATCH v4 09/20] net/txgbe: fix link flow control config for SapphireQuoted 8 lines · On Mon, 11 May 2026 18:35:51 +0800 Zaiyu Wang <[email protected]> wrote:
SP chips have a hardware bug preventing XON flow control support, so the driver disables it.
Fixes 69ce8c8a4ce3 ("net/txgbe: support flow control")Signed-off-by Zaiyu Wang <[email protected]>---
Comment vs code mismatch
# Review of Patch 9/20: net/txgbe: fix link flow control config for Sapphire
Quoted 7 lines
## Errors
None.
## Warnings
### W1: Conditional logic inverted (line 1042-1043)
Fixed.
Quoted 1 line
### W2: Inconsistent capitalization in comment (line 1042)
Fixed.
PATCH v4 10/20 net/txgbe: fix a mass of unknown interrupts
In reply to Zaiyu WangWhen RSC is enabled, Rx ring IVAR is set to configure ITR. It causes Rx ring interrupts report on the default msix_vector. Thus a mass of unknown interrupts occupy CPU.
Fix the issue by setting ring IVAR only when the rxq interrupt is enabled.
--- drivers/net/txgbe/txgbe_rxtx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +17 -13
@@ -4354,6 +4354,8 @@ static int txgbe_set_rsc(struct rte_eth_dev *dev) {struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_eth_dev_info dev_info = {0 };bool rsc_capable = false;
@@ -4404,8 +4406,6 @@ txgbe_set_rsc(struct rte_eth_dev *dev)rd32 (hw,TXGBE_RXCFG (rxq->reg_idx));uint32_t psrtype =rd32 (hw,TXGBE_POOLRSS (rxq->reg_idx)); -uint32_t eitr = -rd32 (hw,TXGBE_ITR (rxq->reg_idx));/* * txgbe PMD doesn't support header-split at the moment.
@@ -4424,6 +4424,9 @@ txgbe_set_rsc(struct rte_eth_dev *dev) srrctl |=txgbe_get_rscctl_maxdesc (rxq->mb_pool); psrtype |=TXGBE_POOLRSS_L4HDR ; +wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); +wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); +/* * RSC: Set ITR interval corresponding to 2K ints/s. *
@@ -4437,19 +4440,20 @@ txgbe_set_rsc(struct rte_eth_dev *dev)* For a sparse streaming case this setting will yield * at most 500us latency for a single RSC aggregation. */ - eitr &= ~TXGBE_ITR_IVAL_MASK ; - eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); - eitr |=TXGBE_ITR_WRDSA ; +if (rte_intr_dp_is_en (intr_handle)) { +uint32_t eitr =rd32 (hw,TXGBE_ITR (rxq->reg_idx)); -wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); -wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); -wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); + eitr &= ~TXGBE_ITR_IVAL_MASK ; + eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); + eitr |=TXGBE_ITR_WRDSA ; +wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); -/* -* RSC requires the mapping of the queue to the -* interrupt vector. -*/ -txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); +/* +* RSC requires the mapping of the queue to the +* interrupt vector. +*/ +txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); + } } dev->data->lro =1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v4 11/20 net/txgbe: fix traffic class priority configuration
In reply to Zaiyu WangAfter applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc off
The old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Fix both issues, ensuring that tc-prio mapping works as expected. Additionally, remove the stale and inconsistent TXGBE_DCBUP2TC_DEC macro as it has no callers.
--- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_regs.h | 6 ++---- drivers/net/txgbe/txgbe_rxtx.c | 7 ++----- 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/txgbe/base/txgbe_dcb_hw.c +1 -1
@@ -154,7 +154,7 @@ s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,for (i =0 ; i <TXGBE_DCB_UP_MAX ; i++) reg |=TXGBE_DCBUP2TC_MAP (i, map[i]); -wr32 (hw,TXGBE_PBRXUP2TC , reg); +wr32 (hw,TXGBE_PBTXUP2TC , reg);/* Configure traffic class credits and priority */ for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {
drivers/net/txgbe/base/txgbe_regs.h +2 -4
@@ -503,10 +503,8 @@#define TXGBE_PBRXCTL 0x019000#define TXGBE_PBRXCTL_ST MS(0, 0x1)#define TXGBE_PBRXCTL_ENA MS(31, 0x1) -#define TXGBE_PBRXUP2TC 0x019008#define TXGBE_PBTXUP2TC 0x01C800 -#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 3 * (tc), 0x7) -#define TXGBE_DCBUP2TC_DEC (tc, r) RS(r, 3 * (tc), 0x7) +#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 4 * (tc), 0x7)#define TXGBE_PBRXSIZE (tc) (0x019020 + (tc) * 4)#define TXGBE_PBRXSIZE_KB (v) LS(v, 10, 0x3FF)
@@ -1703,7 +1701,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_RDM_PF_HIDE (_i) (0x12090 + ((_i) * 4))#define TXGBE_RPUP2TC 0x019008 -#define TXGBE_RPUP2TC_UP_SHIFT 3 +#define TXGBE_RPUP2TC_UP_SHIFT 4#define TXGBE_RPUP2TC_UP_MASK 0x7#define TXGBE_RDM_DCACHE_CTL 0x0120A8
drivers/net/txgbe/txgbe_rxtx.c +2 -5
@@ -3385,11 +3385,8 @@ txgbe_vmdq_dcb_configure(struct rte_eth_dev *dev) queue_mapping =0 ;for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) -/* -* mapping is done with 3 bits per priority, -* so shift by i*3 each time -*/ - queue_mapping |= ((cfg->dcb_tc[i] &0x07 ) << (i *3 )); + queue_mapping |= ((cfg->dcb_tc[i] &TXGBE_RPUP2TC_UP_MASK ) << + (i *TXGBE_RPUP2TC_UP_SHIFT ));wr32 (hw,TXGBE_RPUP2TC , queue_mapping);
Signature · 1 line
2.21.0.windows.1
PATCH v4 12/20 net/txgbe: fix link stability for 25G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_aml.c | 107 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 2493 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1746 +++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 279 +++ drivers/net/txgbe/base/txgbe_hw.c | 35 +- drivers/net/txgbe/base/txgbe_phy.h | 1 - drivers/net/txgbe/base/txgbe_regs.h | 2 + drivers/net/txgbe/base/txgbe_type.h | 12 + drivers/net/txgbe/txgbe_ethdev.c | 83 +- drivers/net/txgbe/txgbe_ethdev.h | 4 + 12 files changed, 4711 insertions(+), 58 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
drivers/net/txgbe/base/meson.build +1 -0
@@ -12,4 +12,5 @@ base_sources = files( 'txgbe_mng.c', 'txgbe_phy.c', 'txgbe_vf.c', + 'txgbe_e56.c', )
drivers/net/txgbe/base/txgbe_aml.c +83 -24
171 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml.h +4 -2
@@ -16,7 +16,9 @@ s32 txgbe_get_link_capabilities_aml(struct txgbe_hw *hw, u32 *speed, bool *autoneg);u32 txgbe_get_media_type_aml (struct txgbe_hw *hw);void txgbe_wait_for_link_up_aml (struct txgbe_hw *hw,u32 speed); -s32 txgbe_setup_mac_link_aml (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml (struct txgbe_hw *hw);#endif /* _TXGBE_AML_H_ */
drivers/net/txgbe/base/txgbe_e56.c new file +2493 -0
2,493 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h new file +1746 -0
320 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h new file +279 -0
279 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +82 -1
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v4 12/20] net/txgbe: fix link stability for 25G NIC
Quoted 9 lines · On Mon, 11 May 2026 18:35:54 +0800 Zaiyu Wang <[email protected]> wrote:
The link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
Fixes ead3616f630d ("net/txgbe: support PHY configuration via SW-FW mailbox")Signed-off-by Zaiyu Wang <[email protected]>---
Lots of AI review feedback here:
# Review of Patch 12/20: net/txgbe: fix link stability for 25G NIC
## Errors
### 1. Use-after-free potential in txgbe_e56_rxs_calib_adapt_seq (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_e56.c
**Location:** Lines ~1600-1650
The function calls txgbe_e56_rxs_osc_init_for_temp_track_range(hw, speed) which can return TXGBE_ERR_TIMEOUT. When the timeout path at line ~1115 is taken, it writes to E56PHY_PMD_CFG_0_ADDR to disable RX and then returns -1. However, the caller txgbe_e56_rxs_calib_adapt_seq continues execution and accesses PHY registers without verifying the hardware state is valid. If the initialization timed out, subsequent register accesses may be unreliable.
**Suggested fix:**
```c
status = txgbe_e56_rxs_osc_init_for_temp_track_range(hw, speed);
if (status != 0)
return status; /* Propagate timeout or error immediately */
```### 2. Resource leak: lock not released on error path (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_aml.c **Location:** Lines 241-247
In txgbe_setup_phy_link_aml, rte_spinlock_lock(&hw->phy_lock) is acquired at line 241. If txgbe_set_link_to_amlite returns TXGBE_ERR_PHY_INIT_NOT_DONE at line 246, the code jumps to out: at line 264 without releasing the spinlock. The lock is only released on the success path or TXGBE_ERR_TIMEOUT.
**Suggested fix:**
```c
rte_spinlock_lock(&hw->phy_lock);
ret_status = txgbe_set_link_to_amlite(hw, speed);
rte_spinlock_unlock(&hw->phy_lock); /* Always release before checking status */
if (ret_status == TXGBE_ERR_PHY_INIT_NOT_DONE)
goto out;
```### 3. Missing error propagation to caller (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_aml.c **Location:** Lines 280-283
In txgbe_setup_phy_link_aml, the function returns status which is initialized to 0 and never assigned a failure value, even when txgbe_set_link_to_amlite fails or link is not established. The function always returns success regardless of actual outcome.
**Suggested fix:**
```c
if (!link_up) {
*need_reset = true;
return TXGBE_ERR_TIMEOUT; /* Return error when link fails */
}
```### 4. Double error return value overwrite (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Lines 1090-1095, 1157-1162, 1197-1202, 1242-1247
In txgbe_e56_rxs_osc_init_for_temp_track_range, the pattern:
```c
if (timer++ > PHYINIT_TIMEOUT) {
DEBUGOUT("ERROR: ...");
break;
return -1; /* Unreachable: break exits the loop */
}
```The return -1 is unreachable. After break, execution continues to the next loop iteration check and then proceeds past the loop. The error is not propagated.
**Suggested fix:**
```c
if (timer++ > PHYINIT_TIMEOUT) {
DEBUGOUT("ERROR: Wait timeout");
return TXGBE_ERR_TIMEOUT; /* Remove break, return immediately */
}
```### 5. Error code dropped without propagation (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Lines 1828-1830
In txgbe_temp_track_seq:
```c
status = txgbe_e56_get_temp(hw, &temperature);
if (status)
return 0; /* Returns success when get_temp failed */
```Temperature reading failure is silently converted to success. The caller cannot distinguish between a successful temperature track and a failed temperature read.
**Suggested fix:**
```c
status = txgbe_e56_get_temp(hw, &temperature);
if (status)
return status; /* Propagate the error */
```### 6. Integer overflow in bit shift (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Lines 19-31 in set_fields_e56()
The function performs (1 << bit_low) where bit_low can be up to 31 (since bit fields in the code span 0-31). The literal 1 is int (signed 32-bit). When bit_low >= 31, 1 << 31 invokes undefined behavior (signed overflow).
**Suggested fix:**
```c
if (bit_high == bit_low) {
if (set_value == 0)
*src_data &= ~(1U << bit_low); /* Use 1U for unsigned */
else
*src_data |= (1U << bit_low);
} else {
for (i = bit_low; i <= bit_high; i++)
*src_data &= ~(1U << i);
*src_data |= (set_value << bit_low);
}
```### 7. Missing bounds check on array size calculation (CORRECTNESS) **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Line 1498 in txgbe_e56_rx_rd_second_code()
The code calls qsort(RXS_BBCDR_SECOND_ORDER_ST, array_size, sizeof(int), ...) where array_size = ARRAY_SIZE(RXS_BBCDR_SECOND_ORDER_ST). The array has 5 elements, but the calculation array_size = ARRAY_SIZE(...) trusts the macro. If N changes in the loop initialization (line 1489: N = 5), the array could overflow.
**Suggested fix:**
```c /* Ensure loop count matches array size */ BUILD_ASSERT(N <= ARRAY_SIZE(RXS_BBCDR_SECOND_ORDER_ST)); ```
## Warnings
### 1. Variables declared but may be read before initialization (STYLE) **File:** drivers/net/txgbe/base/txgbe_aml.c
**Location:** Lines 325-327, 355-357
Variables need_reset are declared immediately before use, which is acceptable C99 style. However, they are declared in the middle of a conditional block scope, which can reduce clarity when the same variable name is reused in different branches.
**Suggested improvement:**
Declare need_reset once at function scope for better readability, though the current usage is technically correct.
### 2. Missing documentation for complex algorithm (STYLE) **File:** drivers/net/txgbe/base/txgbe_e56.c
**Location:** Lines 902-1264 (txgbe_e56_rxs_osc_init_for_temp_track_range)
This 360-line function implements a complex PHY oscillator calibration sequence with numbered steps in comments (1, 2, 3...). The algorithm is critical for 25G link stability but lacks a high-level overview comment explaining the purpose, temperature dependency, and why specific register sequences are needed.
**Suggested improvement:**
Add a function-level Doxygen comment explaining the calibration procedure and referencing the hardware specification section.
### 3. Magic numbers without named constants (STYLE) **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Multiple locations (e.g., lines 505, 732, 1000)
Numerous magic numbers appear in register writes (e.g., 0x68c1, 0x3321, 0x973e, 0xccde at lines 2281-2284) without explanation. These appear to be RS-FEC configuration magic values but are not documented.
**Suggested improvement:**
Define named constants or add inline comments explaining what these values configure:
```c #define RS_FEC_CONFIG_VAL1 0x68c1 /* RS-FEC configuration register value */ ```
## Info
### 1. Deep nesting in calibration sequence **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Lines 1550-1750 (txgbe_e56_rxs_calib_adapt_seq)
The ADC calibration loop (16 iterations) has 5 levels of nesting. Consider extracting the calibration step into a helper function to improve readability.
### 2. Possible candidate for helper function **File:** drivers/net/txgbe/base/txgbe_e56.c **Location:** Lines 1950-2050 (repeated CTLE bypass pattern)
The code to override CTLE bypass for multiple lanes (RXS1, RXS2, RXS3) at lines 1999-2030 is repetitive. This pattern could be extracted into a helper function.
---
## Summary
**Critical Issues:** 7 Errors identified, primarily correctness bugs affecting resource management and error handling. **Style Issues:** 3 Warnings - documentation and code organization improvements.
**Observations:** 2 Info items - code structure suggestions.
The most serious issues are:
1. Lock leak on error path (Error #2)
2. Missing error propagation causing silent failures (Errors #3, #5)
3. Undefined behavior in bit operations (Error #6)
4. Unreachable error returns masking timeouts (Error #4)
============================================================
RE: [PATCH v4 12/20] net/txgbe: fix link stability for 25G NIC
Quoted 3 lines
## Errors
### 1. Use-after-free potential in
txgbe_e56_rxs_calib_adapt_seq(CORRECTNESS)
No code change.
The return value of txgbe_e56_rxs_osc_init_for_temp_track_range is only used for debugging; the hardware can still continue the subsequent configuration flow even after a timeout. Therefore, we use status |= to record the error for logging but do not abort the sequence.
Quoted 1 line
### 2. Resource leak: lock not released on error path (CORRECTNESS)
No code change.
The spinlock is correctly released on all paths, including the TXGBE_ERR_PHY_INIT_NOT_DONE branch. No change is needed.
Quoted 1 line
### 3. Missing error propagation to caller (CORRECTNESS)
Fixed. The function now returns TXGBE_ERR_TIMEOUT when the link fails to come up.
Quoted 1 line
### 4. Double error return value overwrite (CORRECTNESS)
Fixed by removing the break statements and letting the timeout errors return immediately.
Quoted 1 line
### 5. Error code dropped without propagation (CORRECTNESS)
No code change.
A failed temperature read does not affect the subsequent configuration flow; stopping the process would be too aggressive. The function intentionally continues, and the error is only for debug purposes.
Quoted 1 line
### 6. Integer overflow in bit shift (CORRECTNESS)
Fixed
Quoted 1 line
### 7. Missing bounds check on array size calculation (CORRECTNESS)
Fixed by introducing the RXS_READ_COUNT macro to keep the array size, loop bound, and median calculation always consistent.
Quoted 3 lines
## Warnings
### 1. Variables declared but may be read before initialization (STYLE)
Adjusted the declaration of need_reset to the function scope for improved readability.
Quoted 1 line
### 2. Missing documentation for complex algorithm (STYLE)
Acknowledged. Adding a high‑level comment for the complex calibration procedure is planned
Quoted 1 line
### 3. Magic numbers without named constants (STYLE)
No code change.
These values come directly from the hardware vendor and are located in the base/ layer, which we prefer not to modify without an official update. We will keep them as‑is.
Quoted 3 lines
## Info
### 1. Deep nesting in calibration sequence
Considering that this is the hardware configuration code located in base/, for now we will not make change to it.
Quoted 1 line
### 2. Possible candidate for helper function
Considering that this is the hardware configuration code located in base/, for now we will not make change to it.
PATCH v4 13/20 net/txgbe: fix link stability for 40G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/txgbe_aml40.c | 70 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 1471 ++++++++++++++++++++++++-- drivers/net/txgbe/txgbe_ethdev.c | 4 +- 4 files changed, 1438 insertions(+), 113 deletions(-)
drivers/net/txgbe/base/txgbe_aml40.c +55 -15
@@ -13,6 +13,7 @@#include "txgbe_hw.h" #include "txgbe_aml.h" #include "txgbe_aml40.h" +#include "txgbe_e56.h" void txgbe_init_ops_aml40 (struct txgbe_hw *hw) {
@@ -24,6 +25,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)/* PHY */ phy->get_media_type = txgbe_get_media_type_aml40; + phy->setup_link_core = txgbe_setup_phy_link_aml40;/* LINK */ mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
@@ -52,6 +54,13 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,if (link_up_wait_to_complete) {for (i =0 ; i < hw->mac.max_link_up_time; i++) { +if (!hw->link_valid) { + *link_up = false; + +msleep (100 ); +continue ; + } +if (!(links_reg &TXGBE_PORTSTAT_UP )) { *link_up = false; }else {
@@ -68,6 +77,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } +if (!hw->link_valid) + *link_up = false; +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G )
@@ -107,20 +119,24 @@ u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)return txgbe_media_type_fiber_qsfp; } -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw, -u32 speed, -bool autoneg_wait_to_complete) +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset) {bool autoneg = false;s32 status =0 ; +s32 ret_status =0 ;u32 link_speed =TXGBE_LINK_SPEED_UNKNOWN ;bool link_up = false; +int i;u32 link_capabilities =TXGBE_LINK_SPEED_UNKNOWN ; +u32 value; -if (hw->phy.sfp_type == txgbe_sfp_type_not_present) { -DEBUGOUT ("SFP not detected, skip setup mac link" ); -return 0 ; - } + *need_reset = false; + +if (hw->phy.sfp_type == txgbe_sfp_type_not_present) + hw->phy.identify_sfp (hw);/* Check to see if speed passed in is supported. */ status = hw->mac.get_link_capabilities(hw,
@@ -132,18 +148,43 @@ s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) +break ; +msleep (250 ); + }if (link_speed == speed && link_up) -return status; + goto out; -if (speed &TXGBE_LINK_SPEED_40GB_FULL ) - speed =0x20 ; +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +rte_spinlock_unlock (&hw->phy_lock); - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); +if (ret_status ==TXGBE_ERR_TIMEOUT ) + hw->link_valid = false; + +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) { +DEBUGOUT ("MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +DEBUGOUT ("MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +DEBUGOUT ("Link reconfiguration required. Reset scheduled in 2000ms." ); + }return status; }
@@ -159,6 +200,5 @@ void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw) mac->flap_tx_laser = txgbe_flap_tx_laser_multispeed_fiber; - mac->setup_link = txgbe_setup_mac_link_aml40; mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed; }
drivers/net/txgbe/base/txgbe_aml40.h +4 -2
@@ -14,7 +14,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw,s32 txgbe_get_link_capabilities_aml40 (struct txgbe_hw *hw,u32 *speed,bool *autoneg);u32 txgbe_get_media_type_aml40 (struct txgbe_hw *hw); -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml40 (struct txgbe_hw *hw);#endif /* _TXGBE_AML40_H_ */
drivers/net/txgbe/base/txgbe_e56.c +1377 -94
1,556 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2054,7 +2054,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw);rte_eal_alarm_cancel (txgbe_dev_detect_sfp, dev);
@@ -3206,7 +3206,7 @@ txgbe_dev_setup_link_thread_handler(void *param)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);rte_thread_detach (rte_thread_self ()); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)txgbe_dev_setup_link_alarm_handler_aml (hw);else txgbe_dev_setup_link_alarm_handler (dev);
Signature · 1 line
2.21.0.windows.1
PATCH v4 14/20 net/txgbe: fix link stability for Amber-Lite backplane mode
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 65 +- drivers/net/txgbe/base/txgbe_aml40.c | 43 +- drivers/net/txgbe/base/txgbe_e56.c | 22 +- drivers/net/txgbe/base/txgbe_e56.h | 2 + drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 3 + drivers/net/txgbe/base/txgbe_hw.c | 6 + drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 21 + drivers/net/txgbe/base/txgbe_phy.h | 22 + drivers/net/txgbe/base/txgbe_type.h | 25 +- drivers/net/txgbe/txgbe_ethdev.c | 109 +- drivers/net/txgbe/txgbe_ethdev.h | 2 +- 16 files changed, 2898 insertions(+), 30 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c
drivers/net/txgbe/base/meson.build +1 -0
@@ -13,4 +13,5 @@ base_sources = files( 'txgbe_phy.c', 'txgbe_vf.c', 'txgbe_e56.c', + 'txgbe_e56_bp.c', )
drivers/net/txgbe/base/txgbe.h +2 -0
@@ -13,5 +13,7 @@#include "txgbe_hw.h" #include "txgbe_vf.h" #include "txgbe_dcb.h" +#include "txgbe_e56.h" +#include "txgbe_e56_bp.h" #endif /* _TXGBE_H_ */
drivers/net/txgbe/base/txgbe_aml.c +54 -11
102 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml40.c +39 -4
73 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.c +12 -10
@@ -53,7 +53,7 @@ int txgbe_e56_int_cmp(const void *a, const void *b) }s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up) +bool *link_up) {u32 rdata =0 ;u32 links_reg =0 ;
@@ -101,7 +101,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ; }else if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) {if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || - hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1) { + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S25G_TX_FFE_CFG_DAC_MAIN ; pre1 =S25G_TX_FFE_CFG_DAC_PRE1 ; pre2 =S25G_TX_FFE_CFG_DAC_PRE2 ;
@@ -119,7 +120,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ;if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || - hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) { + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S40G_TX_FFE_CFG_MAIN ; pre1 =S40G_TX_FFE_CFG_PRE1 ; pre2 =S40G_TX_FFE_CFG_PRE2 ;
@@ -1508,7 +1510,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1543,7 +1545,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1620,7 +1622,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) addr =E56PHY_CTRL_FSM_RX_STAT_0_ADDR ; rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1667,7 +1669,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ;return -1 ; }
@@ -1936,7 +1938,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -3195,7 +3197,7 @@ static int txgbe_e56_disable_rx40G(struct txgbe_hw *hw) rdata =rd32_ephy (hw, addr);usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
@@ -3301,7 +3303,7 @@ static int txgbe_e56_disable_rx(struct txgbe_hw *hw)break ;usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
drivers/net/txgbe/base/txgbe_e56.h +2 -0
@@ -1739,6 +1739,8 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed);int txgbe_e56_get_temp (struct txgbe_hw *hw,int *temp);int txgbe_set_link_to_amlite (struct txgbe_hw *hw,u32 speed);int txgbe_e56_reconfig_rx (struct txgbe_hw *hw,u32 speed); +s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, +bool *link_up);s32 txgbe_e56_fec_set (struct txgbe_hw *hw);s32 txgbe_e56_fec_polling (struct txgbe_hw *hw,bool *link_up);u32 txgbe_e56_tx_ffe_cfg (struct txgbe_hw *hw,u32 speed);
drivers/net/txgbe/base/txgbe_e56_bp.c new file +2597 -0
2,597 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h +3 -0
@@ -276,4 +276,7 @@ typedef union {#define E56PHY_CMS_ANA_OVRDVAL_10_ADDR (E56PHY_CMS_BASE_ADDR + 0xD8)#define E56PHY_CMS_ANA_OVRDVAL_7_ANA_LCPLL_LF_LPF_SETCODE_CALIB_I 8, 4 +int txgbe_e56_set_phy_link_mode (struct txgbe_hw *hw, +u8 bp_link_mode,u32 need_restart); +int handle_e56_bkp_an73_flow (struct txgbe_hw *hw);#endif
drivers/net/txgbe/base/txgbe_hw.c +6 -0
@@ -4071,6 +4071,12 @@ s32 txgbe_reset_pipeline_raptor(struct txgbe_hw *hw)return err; } +bool txgbe_is_backplane (struct txgbe_hw *hw) +{ +return hw->phy.get_media_type (hw) == txgbe_media_type_backplane ? + true : false; +} +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask) {u32 gpio_ext =rd32 (hw,TXGBE_GPIOEXT );
drivers/net/txgbe/base/txgbe_hw.h +2 -2
@@ -118,6 +118,6 @@ s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw);bool txgbe_verify_lesm_fw_enabled_raptor (struct txgbe_hw *hw);s32 txgbe_fmgr_cmd_op (struct txgbe_hw *hw,u32 cmd,u32 cmd_addr);s32 txgbe_flash_read_dword (struct txgbe_hw *hw,u32 addr,u32 *data); -s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up); +bool txgbe_is_backplane (struct txgbe_hw *hw); +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask);#endif /* _TXGBE_HW_H_ */
drivers/net/txgbe/base/txgbe_osdep.h +4 -0
@@ -162,6 +162,10 @@ static inline u64 REVERT_BIT_MASK64(u64 mask) ((mask &0xFFFFFFFF00000000 ) >>32 ); } +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define IOMEM #define BIT (nr) (1UL << (nr))
drivers/net/txgbe/base/txgbe_phy.c +21 -0
@@ -2503,6 +2503,27 @@ void txgbe_set_phy_temp(struct txgbe_hw *hw) } } +int txgbe_is_dac_cable (struct txgbe_hw *hw) +{ +if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core1 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) +return true; + +return false; +} + +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw) +{ +if (!(txgbe_is_dac_cable (hw) ||txgbe_is_backplane (hw))) +return false; + +return hw->devarg.auto_neg ? true : false; +} +/** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure
drivers/net/txgbe/base/txgbe_phy.h +22 -0
@@ -105,6 +105,8 @@#define VR_AN_INTR_CMPLT MS16(0, 0x1)#define VR_AN_INTR_LINK MS16(1, 0x1)#define VR_AN_INTR_PG_RCV MS16(2, 0x1) +#define TXGBE_E56_AN_TXDIS MS16(3, 0x1) +#define TXGBE_E56_AN_PG_RCV MS16(4, 0x1)#define VR_AN_KR_MODE_CL 0x078003#define VR_AN_KR_MODE_CL_PDET MS16(0, 0x1)#define VR_XS_OR_PCS_MMD_DIGI_CTL1 0x038000
@@ -428,6 +430,24 @@#define TXGBE_BP_M_NAUTO 0#define TXGBE_BP_M_AUTO 1 +#define kr_read_poll (op, val, cond, sleep_us, \ + times, args...) \ +({ \ + unsigned long __sleep_us = (sleep_us); \ + u32 __times = (times); \ + u32 i; \ + int __cond = 0; \ + for (i = 0; i < __times; i++) { \ + (val) = op(args); \ + if (cond) { \ + __cond = 1; \ + break; \ + } \ + usleep(__sleep_us);\ + } \ + (__cond) ? 0 : -1; \ +}) +#ifndef CL72_KRTR_PRBS_MODE_EN #define CL72_KRTR_PRBS_MODE_EN 0xFFFF/* open kr prbs check */ #endif
@@ -490,6 +510,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 value);void txgbe_bp_mode_set (struct txgbe_hw *hw);void txgbe_set_phy_temp (struct txgbe_hw *hw);void txgbe_bp_down_event (struct txgbe_hw *hw); +int txgbe_is_dac_cable (struct txgbe_hw *hw); +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw);s32 txgbe_kr_handle (struct txgbe_hw *hw);#endif /* _TXGBE_PHY_H_ */
drivers/net/txgbe/base/txgbe_type.h +24 -1
@@ -719,6 +719,7 @@ struct txgbe_phy_info {u32 addr;u32 id;enum txgbe_sfp_type sfp_type; +u32 fiber_suppport_speed;bool sfp_setup_needed;u32 revision;u32 media_type;
@@ -740,6 +741,7 @@ struct txgbe_phy_info {u16 ffe_pre2;u16 ffe_post;u16 fec_mode; +u16 bp_capa; };#define TXGBE_DEVARG_BP_AUTO "auto_neg"
@@ -899,7 +901,28 @@ struct txgbe_hw {u32 cur_fec_link;int temperature;u32 bp_link_mode; -}; +bool dac_sfp; +bool bypass_ctle; +u32 curbp_link_mode; +bool an_done;
Lines of this file are not shown. View the raw message.
drivers/net/txgbe/txgbe_ethdev.c +108 -1
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v4 14/20] net/txgbe: fix link stability for Amber-Lite backplane mode
Quoted 9 lines · On Mon, 11 May 2026 18:35:56 +0800 Zaiyu Wang <[email protected]> wrote:
The link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
Fixes ead3616f630d ("net/txgbe: support PHY configuration via SW-FW mailbox")Signed-off-by Zaiyu Wang <[email protected]>---
Lots of AI feedback here:
# Review of DPDK Patch: net/txgbe: fix link stability for 40G NIC
## Summary
This patch re-adds direct PHY configuration flow to the txgbe driver to fix unstable link behavior on 40G NICs. The previous firmware-based configuration approach was causing link stability issues.
## ERRORS
### 1. Use-after-free risk in txgbe_setup_phy_link_aml40 **File:** drivers/net/txgbe/base/txgbe_aml40.c:157-159
```c
ret_status = txgbe_set_link_to_amlite(hw, speed);
rte_spinlock_unlock(&hw->phy_lock);
if (ret_status == TXGBE_ERR_TIMEOUT)
hw->link_valid = false;
```The spinlock is unlocked before checking ret_status, but if another thread modifies hw->link_valid between lines 158 and 160, the state becomes inconsistent. The assignment to hw->link_valid should occur before unlocking:
```c
ret_status = txgbe_set_link_to_amlite(hw, speed);
if (ret_status == TXGBE_ERR_TIMEOUT)
hw->link_valid = false;
rte_spinlock_unlock(&hw->phy_lock);
```### 2. Missing error propagation in txgbe_e56_rx_rd_second_code_40g **File:** drivers/net/txgbe/base/txgbe_e56.c:1816
The function declares status = 0 and returns status, but never assigns a failure value even when qsort is called on potentially invalid data. If the timeout in the preceding while loop is reached (line 1825), the SECOND_CODE array may contain incomplete data, but the function still returns success.
### 3. Missing bounds check before array access **File:** drivers/net/txgbe/base/txgbe_e56.c:1831
```c median = ((N + 1) / 2) - 1; *SECOND_CODE = RXS_BBCDR_SECOND_ORDER_ST[median]; ```
If N=5, median=2 which is valid. However, this code pattern is repeated multiple times (lines 244, 1831, etc.) with N as a constant, so it's safe. Nevertheless, adding RTE_VERIFY(median < ARRAY_SIZE(RXS_BBCDR_SECOND_ORDER_ST)) would make intent explicit.
**Not flagging this as an error** since N=5 is a fixed constant throughout.
### 4. Timeout return without cleanup in txgbe_e56_rxs_calib_adapt_seq_40G **File:** drivers/net/txgbe/base/txgbe_e56.c:2475-2481
```c
if (timer++ > PHYINIT_TIMEOUT) {
rdata = 0;
addr = E56PHY_PMD_CFG_0_ADDR;
rdata = rd32_ephy(hw, addr);
set_fields_e56(&rdata, E56PHY_PMD_CFG_0_RX_EN_CFG, 0x0);
wr32_ephy(hw, addr, rdata);
return TXGBE_ERR_TIMEOUT;
}
```The function has already configured many registers in the loop for (i = 0; i < 4; i++) (starting line 2393). When a timeout occurs on lane 0-2, the function returns immediately without restoring registers on the lanes that were successfully configured. This leaves the hardware in a partially configured state. The cleanup should disable all lanes, not just the one that timed out.
## WARNINGS
### 1. Hardcoded timeout in multiple locations
**File:** drivers/net/txgbe/base/txgbe_e56.c (multiple locations)
The PHYINIT_TIMEOUT constant is used consistently, but the delays vary (100µs, 500µs, 1000µs, 10ms). For the 500µs delay case (e.g., line 2478), PHYINIT_TIMEOUT iterations result in PHYINIT_TIMEOUT * 500µs total wait time. If PHYINIT_TIMEOUT is intended to be milliseconds, the timeout duration becomes inconsistent across different polling loops. Consider documenting what the timeout value represents (iterations? milliseconds?) and using consistent delay granularity.
### 2. Potentially unreachable code after loop **File:** drivers/net/txgbe/base/txgbe_e56.c:2656
```c
for (j = 0; j < 16; j++) {
// ... ADC adaptation loop
}
/* g. Repeat #a to #f total 16 times */
```The comment /* g. Repeat #a to #f total 16 times */ appears *after* the loop that already runs 16 times. This is documentation only, but could be confusing. The comment should be before the loop or removed.
### 3. Inconsistent use of msleep vs usec_delay **File:** drivers/net/txgbe/base/txgbe_e56.c
The patch uses msleep() for delays >= 10ms (lines 181, 3029) and usec_delay() for shorter delays (line 1826). However, line 3029 uses msleep(10) for 10ms, while line 2707 uses no delay after setting a register. Consider documenting the rationale for sleep vs busy-wait or using a consistent threshold.
### 4. Variable bypass_ctle hardcoded but declared as variable **File:** drivers/net/txgbe/base/txgbe_e56.c:2396
```c u32 bypass_ctle = true; ```
The variable bypass_ctle is declared as u32 but assigned a boolean value, and it's never modified. Either:
- Change to const bool bypass_ctle = true; (preferred)
- Or document why it's a runtime variable despite being hardcoded
### 5. Missing validation of speed parameter in initialization functions **File:** drivers/net/txgbe/base/txgbe_e56.c:2206
```c
if (speed == TXGBE_LINK_SPEED_10GB_FULL || speed == TXGBE_LINK_SPEED_40GB_FULL) {
CMVAR_SEC_LOW_TH = S10G_CMVAR_SEC_LOW_TH;
// ...
} else if (speed == TXGBE_LINK_SPEED_25GB_FULL) {
// ...
} else {
DEBUGOUT("Error Speed\n");
return 0; // Returns success despite error
}
```The function returns 0 (success) when an invalid speed is passed, but logs "Error Speed". This should return an error code like -EINVAL or TXGBE_ERR_PARAM.
## INFORMATIONAL
### 1. Large function complexity
The function txgbe_e56_rxs_calib_adapt_seq_40G spans ~280 lines with deeply nested loops (3-level nesting). Consider refactoring into smaller helper functions for each calibration stage (ADC offset, ADC gain, interleaver adaptation) to improve readability and maintainability.
### 2. Magic numbers without symbolic constants **File:** drivers/net/txgbe/base/txgbe_e56.c:2470
```c while (EPHY_XFLD(E56G__PMD_CTRL_FSM_RX_STAT_0, ctrl_fsm_rx0_st) != 0x21 || ```
The value 0x21 (POWERDN_ST) appears in multiple locations (lines 2470, 3145). This is already defined as E56PHY_RX_POWERDN_ST elsewhere. Use the symbolic constant consistently.
### 3. Duplicated initialization sequences
The 40G initialization in txgbe_e56_cfg_40g (lines 176-566) and the existing 10G/25G code share many similar register sequences. Consider extracting common configuration patterns into helper functions to reduce code duplication and maintenance burden.
### 4. Temperature check frequency
**File:** drivers/net/txgbe/base/txgbe_e56.c:2253-2256
The temperature tracking sequence comment states "must be run before the temperature drifts by >5degC" and recommends running every 100ms. However, the patch doesn't add timer-based periodic execution—it only runs during link setup. If temperature tracking is critical for stability, consider documenting that the caller must invoke this periodically.
---
## Positive Observations
1. The patch correctly adds hw->link_valid checks in txgbe_check_mac_link_aml40 to prevent reporting link up when PHY configuration fails (lines 57-60, 80-81).
2. Error paths in timeout scenarios attempt cleanup by disabling RX (e.g., line 2477).
3. The use of median filtering for SECOND_CODE (lines 1829-1831) reduces noise from asynchronous hardware updates—good defensive programming.
RE: [PATCH v4 14/20] net/txgbe: fix link stability for Amber-Lite backplane mode
Quoted 5 lines
Lots of AI feedback here:
# Review of DPDK Patch: net/txgbe: fix link stability for 40G NIC
Quoted 7 lines
## Summary
This patch re-adds direct PHY configuration flow to the txgbe driver to fix unstable link behavior on 40G NICs. The previous firmware-based configuration approach was causing link stability issues.## ERRORS
### 1. Use-after-free risk in
txgbe_setup_phy_link_aml40
Fixed.
Quoted 1 line
### 2. Missing error propagation in
txgbe_e56_rx_rd_second_code_40g
Fixed. This function has been changed to void type, as its configuration flow does not produce any error return value under normal operation.
Quoted 1 line
### 3. Missing bounds check before array access
Fixed by introducing the RXS_READ_COUNT macro to keep the array size, loop bound, and median calculation always consistent.
Quoted 1 line
### 4. Timeout return without cleanup in
txgbe_e56_rxs_calib_adapt_seq_40G
Not a error.
Quoted 3 lines
## WARNINGS
### 1. Hardcoded timeout in multiple locations
Added a comment at the definition of PHYINIT_TIMEOUT clarifying that it is a loop iteration limit, not a fixed time unit. The actual timeout duration depends on the usec_delay() or msleep() value used inside the polling loop.
Quoted 1 line
### 2. Potentially unreachable code after loop
Moved the comment before '}'.
Quoted 1 line
### 4. Variable
bypass_ctlehardcoded but declared as variable
Fixed.
Quoted 1 line
### 5. Missing validation of speed parameter in initialization functions
Fixed.
Quoted 5 lines
## INFORMATIONAL
### 1. Large function complexity
### 2. Magic numbers without symbolic constants
### 3. Duplicated initialization sequences The 40G initialization intxgbe_e56_cfg_40g
I prefer not to split the hardware configuration flow at this stage. The current structure closely follows the hardware vendor's recommended initialization sequence. Most magic numbers are directly from the hardware specification, we do not change them at this stage.
The hardware register requirements for different speeds are not fully identical. Merging them would risk subtle bugs.
Quoted 1 line
### 4. Temperature check frequency
This was indeed an omission after moving PHY configuration from firmware to the driver. Previously, temperature tracking was handled by firmware together with hardware setup. We have now added a new patch that implements periodic temperature tracking in the driver. The tracking sequence is invoked every 100ms as recommended. This patch will be submitted in the new version of this patchset.
PATCH v4 15/20 net/txgbe: fix FEC mode configuration on 25G NIC
In reply to Zaiyu WangThe 25G NIC offers off, RS, Base-R, and auto FEC modes. When reconfiguring the PHY, the FEC mode must match on both sides; otherwise, the link cannot come up. The current driver fails to maintain this requirement, causing link instability.
Add proper FEC mode handling during PHY reconfiguration to guarantee link establishment.
--- drivers/net/txgbe/base/txgbe_aml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_aml.c +12 -1
@@ -282,6 +282,14 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw, !(hw->fec_mode & hw->cur_fec_link))) goto out; +if (speed ==TXGBE_LINK_SPEED_25GB_FULL && + link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + +if (link_up) + goto out; + } +rte_spinlock_lock (&hw->phy_lock); ret_status =txgbe_set_link_to_amlite (hw, speed);rte_spinlock_unlock (&hw->phy_lock);
@@ -360,7 +368,10 @@ static s32 txgbe_setup_mac_link_multispeed_fiber_aml(struct txgbe_hw *hw,/* If we already have link at this speed, just jump out */ txgbe_e56_check_phy_link (hw, &link_speed, &link_up); -if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up) + hw->cur_fec_link =txgbe_phy_fec_get (hw); + +if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up && + hw->fec_mode & hw->cur_fec_link) goto out;/* Allow module to change analog characteristics (10G -> 25G) */
Signature · 1 line
2.21.0.windows.1
PATCH v4 16/20 net/txgbe: fix SFP module identification
In reply to Zaiyu WangSome optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
--- drivers/net/txgbe/base/txgbe_hw.c | 2 - drivers/net/txgbe/base/txgbe_phy.c | 339 ++++++++++------------------ drivers/net/txgbe/base/txgbe_phy.h | 18 +- drivers/net/txgbe/base/txgbe_type.h | 2 + 4 files changed, 132 insertions(+), 229 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +0 -2
@@ -2909,8 +2909,6 @@ s32 txgbe_init_ops_generic(struct txgbe_hw *hw) phy->read_i2c_eeprom = txgbe_read_i2c_eeprom; phy->write_i2c_eeprom = txgbe_write_i2c_eeprom; 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; phy->set_link_hostif = txgbe_hic_ephy_set_link;
drivers/net/txgbe/base/txgbe_phy.c +117 -222
469 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_phy.h +13 -5
@@ -261,7 +261,9 @@#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE0 0xA5#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE1 0xA6
@@ -289,6 +291,9 @@#define TXGBE_SFF_4x10GBASESR_CAP 0x11#define TXGBE_SFF_40GBASEPSM4_PARALLEL 0x12#define TXGBE_SFF_40GBASE_SWMD4_CAP 0x1f +#define TXGBE_SFF_COPPER_5M 0x5 +#define TXGBE_SFF_COPPER_3M 0x3 +#define TXGBE_SFF_COPPER_1M 0x1#define TXGBE_SFF_DA_SPEC_ACTIVE_LIMITING 0x4#define TXGBE_SFF_25GAUI_C2M_AOC_BER_5 0x1
@@ -296,6 +301,11 @@#define TXGBE_SFF_25GAUI_C2M_AOC_BER_12 0x18#define TXGBE_SFF_25GAUI_C2M_ACC_BER_12 0x19 +#define TXGBE_ETHERNET_COMP_OFFSET 0x83 +#define TXGBE_SFF_ETHERNET_40G_CR4 MS(3, 0x1) +#define TXGBE_SFF_ETHERNET_40G_SR4 MS(2, 0x1) +#define TXGBE_SFF_ETHERNET_40G_LR4 MS(1, 0x1) +#define TXGBE_SFF_SOFT_RS_SELECT_MASK 0x8#define TXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define TXGBE_SFF_SOFT_RS_SELECT_1G 0x0
@@ -493,14 +503,12 @@ 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, -u8 dev_addr,u8 *data);s32 txgbe_write_i2c_byte (struct txgbe_hw *hw,u8 byte_offset,u8 dev_addr,u8 data); -s32 txgbe_write_i2c_byte_unlocked (struct txgbe_hw *hw,u8 byte_offset, -u8 dev_addr,u8 data);s32 txgbe_read_i2c_sff8472 (struct txgbe_hw *hw,u8 byte_offset, -u8 *sff8472_data); +u8 *sff8472_data); +s32 txgbe_read_i2c_sff8636 (struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 txgbe_read_i2c_eeprom (struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset,
drivers/net/txgbe/base/txgbe_type.h +2 -0
@@ -702,6 +702,8 @@ struct txgbe_phy_info { u8 dev_addr, u8 data);s32 (*read_i2c_sff8472)(struct txgbe_hw *hw,u8 byte_offset,u8 *sff8472_data); +s32 (*read_i2c_sff8636)(struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 (*read_i2c_eeprom)(struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 16/20] net/txgbe: fix SFP module identification
Quoted 11 lines · On Mon, 11 May 2026 18:35:58 +0800 Zaiyu Wang <[email protected]> wrote:
Some optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
Fixes ab191e6d9189 ("net/txgbe: support new SFP/QSFP modules")Signed-off-by Zaiyu Wang <[email protected]>---
Lots of AI feedback here.
Note: not all this is required; like the request for extra release notes is AI being picky.
# Review of Patch 16/20: net/txgbe: fix SFP module identification
## Summary
This patch refactors SFP/QSFP module identification logic and adjusts I2C locking scope. The changes address module type detection and claim to fix race conditions.
---
## Errors
### 1. Resource leak in txgbe_identify_sfp_module() - multiple error paths missing unlock
**Error paths that acquire lock but fail to release on error:**
At line 836, hw->mac.acquire_swfw_sync() acquires TXGBE_MNGSEM_SWPHY. Several error paths after this point fail to release the lock:
```c
err = hw->phy.read_i2c_eeprom(hw, TXGBE_SFF_IDENTIFIER, &identifier);
if (err != 0) {
/* ... */
hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY); // OK - releases
return TXGBE_ERR_SFP_NOT_PRESENT;
}
if (identifier != TXGBE_SFF_IDENTIFIER_SFP) {
hw->phy.type = txgbe_phy_sfp_unsupported;
hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY); // OK - releases
return TXGBE_ERR_SFP_NOT_SUPPORTED;
}
err = hw->phy.read_i2c_eeprom(hw, ...);
/* Multiple read_i2c_eeprom calls follow */
```**After line 894**, there are at least **4 read_i2c_eeprom() calls** (lines ~895-930 in the context) that can fail with goto out; - but goto out; is removed in this patch. If any of these reads fail now, the function returns immediately **without releasing the lock acquired at line 836**.
Example at line 1000:
```c
err = hw->phy.read_i2c_eeprom(hw, TXGBE_SFF_CABLE_SPEC_COMP, &cable_spec);
if (err != 0)
goto out; /* This label is REMOVED - now falls through or returns */
```The old code had out: label that might have handled cleanup. The new code removes this pattern but doesn't add hw->mac.release_swfw_sync() calls before each early return.
**Impact:** Lock held indefinitely on I2C read failure, blocking other threads.
**Fix:** Add lock release before every early return after line 836:
```c
err = hw->phy.read_i2c_eeprom(hw, TXGBE_SFF_CABLE_SPEC_COMP, &cable_spec);
if (err != 0) {
hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
goto out;
}
```---
### 2. txgbe_write_i2c_byte() removes STOP condition - probable hardware protocol violation
**Line 1299 (old) vs 1299 (new):**
Old code:
```c wr32(hw, TXGBE_I2CDATA, byte_offset | TXGBE_I2CDATA_STOP); ```
New code:
```c wr32(hw, TXGBE_I2CDATA, byte_offset); ```
The TXGBE_I2CDATA_STOP flag is removed from the byte_offset write but remains only on the data write. This changes the I2C transaction sequence:
- Old: Write byte_offset with STOP, write data with STOP
- New: Write byte_offset (no STOP), write data with WRITE+STOP (via txgbe_i2c_stop())
**Analysis:** I2C writes to EEPROMs typically follow: START → device_addr+W → ACK → byte_offset → ACK → data → ACK → STOP. Removing STOP from the byte_offset phase may be correct if the hardware requires a combined write transaction, **but this is a functional change to I2C timing that is not explained in the commit message** and could break module writes.
**Impact:** Could cause I2C write failures or data corruption on SFP/QSFP EEPROMs.
**Fix:** Either:
1. Verify via hardware datasheet that single STOP at end is correct, document in commit message
2. Restore TXGBE_I2CDATA_STOP on byte_offset write
---
### 3. Removed validation logic without replacement - SFP vendor checking deleted
**Lines 1025-1070 (old code, removed):** The old txgbe_identify_qsfp_module() read vendor OUI bytes, checked for Intel vendor, and enforced "allow_any_sfp" policy. This entire block is deleted with no equivalent in the new code.
**Impact:**
- Unsupported vendor modules are now silently accepted (security/quality risk)
- hw->allow_unsupported_sfp flag is no longer checked (user configuration ignored)
- Warning messages for untested modules removed (users not informed of risks)
**This is a functional regression unless the validation moved elsewhere** (not evident in this patch).
**Fix:** Restore vendor OUI check or document why it's safe to remove.
---
## Warnings
### 1. txgbe_identify_qsfp_module() GPIO config runs unconditionally
**Lines 1098-1099:**
```c /* config GPIO before read i2c */ wr32(hw, TXGBE_GPIODATA, TXGBE_GPIOBIT_1); ```
This GPIO write now runs **even when media_type is not fiber_qsfp** (the media check is after the GPIO write at lines 1108-1111). The old code had this GPIO write inside the if (hw->mac.type == txgbe_mac_aml40) block, after the media check.
**Impact:** Unnecessary hardware access, potential side effects on non-QSFP ports.
**Fix:** Move GPIO config inside the if (hw->mac.type == txgbe_mac_aml40) block or add media_type check first.
---
### 2. Missing error propagation - txgbe_read_i2c_sff8636() page select failure ignored
**Line 1215:**
```c
hw->phy.write_i2c_byte(hw, TXGBE_SFF_QSFP_PAGE_SELECT,
TXGBE_I2C_EEPROM_DEV_ADDR,
page);
```The return value from write_i2c_byte() is discarded. If page select fails, the subsequent read at line 1218 will read from the **wrong page**, producing incorrect module data.
**Fix:**
```c
s32 err = hw->phy.write_i2c_byte(hw, TXGBE_SFF_QSFP_PAGE_SELECT,
TXGBE_I2C_EEPROM_DEV_ADDR, page);
if (err != 0)
return err;
```---
### 3. Implicit comparison on pointer
**Line 1123 (in txgbe_identify_qsfp_module):**
```c
if (err)
return -EBUSY;
```Should be explicit:
```c
if (err != 0)
return -EBUSY;
```---
### 4. Release notes likely required
This patch changes module detection logic and affects supported module types. API behavior changes (vendor validation removed, new module type support) typically require release notes under "Fixed Issues" or "Known Issues" if compatibility changes exist.
---
### 5. Function pointer assignments removed but functions still defined
**Lines 2912-2913 (txgbe_hw.c):**
```c phy->read_i2c_byte_unlocked = txgbe_read_i2c_byte_unlocked; phy->write_i2c_byte_unlocked = txgbe_write_i2c_byte_unlocked; ```
These assignments are removed, but the commit message doesn't indicate whether the *_unlocked functions are deleted or just unused. If the functions remain defined but unreferenced, they are dead code. If other drivers reference phy->read_i2c_byte_unlocked as a function pointer, this breaks them.
---
## Info
### 1. Simplified I2C locking approach is clearer
The removal of separate *_unlocked variants and the move to caller-managed locking (acquire once, multiple reads, release) is a good pattern that reduces lock churn.
---
### 2. New SFP type handling for 25G/40G modules
The patch adds proper detection for:
- 25G AOC modules (txgbe_sfp_type_25g_aoc_core0/1)
- 40G QSFP types with Ethernet compliance byte checks
This appears to address the "ambiguous classification" mentioned in the commit message.
---
### 3. Consistent use of read_i2c_sff8636() helper
The new txgbe_read_i2c_sff8636() helper centralizes page-select logic for QSFP modules, which is good for maintainability (despite the error handling issue noted above).
---
## Final Check Summary
**Errors (must fix):**
1. Lock leaks in txgbe_identify_sfp_module() on I2C read errors after line 836
2. TXGBE_I2CDATA_STOP removal in txgbe_write_i2c_byte() changes I2C protocol, not explained/verified
3. Vendor OUI validation removed without replacement - security/quality regression
**Warnings (should fix):**
1. GPIO config runs before media_type check
2. Page select error ignored in txgbe_read_i2c_sff8636()
3. Implicit comparison if (err)
4. Release notes likely needed for behavior changes
5. Unused function pointer assignments removed - check for dead code
RE: [PATCH v4 16/20] net/txgbe: fix SFP module identification
Quoted 4 lines
## Errors
### 1. Resource leak in
txgbe_identify_sfp_module()- multiple error paths missing unlock
No code change
The review is incorrect — all error paths after acquiring the lock do properly release it. There is no lock leak.
Quoted 1 line
### 2.
txgbe_write_i2c_byte()removes STOP condition - probable hardware
No code change
This change was ported from our out‑of‑tree Linux kernel driver. It was found that the previous write_i2c interface had problems, which caused ethtool -m to read some 40G optical module information incorrectly. Removing the intermediate STOP is intentional and fixes that issue.
Quoted 1 line
### 3. Removed validation logic without replacement - SFP vendor checking
No code change
The old code was inherited from the Intel driver. The restriction has been removed intentionally: the driver now supports all optical modules that comply with the relevant standards, without limiting to a specific vendor.
Quoted 3 lines
## Warnings
### 1.
txgbe_identify_qsfp_module()GPIO config runs unconditionally
No code change.
The function txgbe_identify_qsfp_module is only called for the Amber‑Lite 40G NIC. Among the three NIC types supported by txgbe (Sapphire 10G, Amber‑Lite 25G, Amber‑Lite 40G), only the 40G variant uses QSFP; the other two use SFP. Based on the aml40 hardware design, we need to configure the GPIO before using I2C.
Quoted 2 lines
### 2. Missing error propagation -
txgbe_read_i2c_sff8636()page select failure ignored
Fixed.
Quoted 1 line
### 3. Implicit comparison on pointer
Fixed.
Quoted 1 line
### 5. Function pointer assignments removed but functions still defined
Already verified.
PATCH v4 17/20 net/txgbe: fix get module info operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/base/txgbe_phy.h | 6 +- drivers/net/txgbe/txgbe_ethdev.c | 116 ++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 27 deletions(-)
drivers/net/txgbe/base/txgbe_phy.h +5 -1
@@ -257,11 +257,15 @@#define TXGBE_SFF_CABLE_DA_PASSIVE 0x4#define TXGBE_SFF_CABLE_DA_ACTIVE 0x8#define TXGBE_SFF_CABLE_SPEC_COMP 0x3C +#define TXGBE_SFF_DDM_IMPLEMENTED 0x40#define TXGBE_SFF_SFF_8472_SWAP 0x5C#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 -#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_SFF_REVISION_ADDR 0x01 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F + +#define TXGBE_MODULE_QSFP_MAX_LEN 640#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D
drivers/net/txgbe/txgbe_ethdev.c +90 -26
131 lines not on this page · raw message
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 17/20] net/txgbe: fix get module info operation
Quoted 9 lines · On Mon, 11 May 2026 18:35:59 +0800 Zaiyu Wang <[email protected]> wrote:
The original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
Fixes abf042d32b39 ("net/txgbe: add Amber-Lite 25G/40G NICs")Signed-off-by Zaiyu Wang <[email protected]>---
More errors spotted in AI review
=== Patch 17/20 ===
# DPDK Patch Review: net/txgbe: fix get module info operation
## Summary
This patch refactors the module information retrieval code for the txgbe driver. The changes add proper identifier detection for different SFP/QSFP module types and improve the I2C access flow.
---
## ERRORS
### 1. Resource leak on error path after lock acquisition **File:** drivers/net/txgbe/txgbe_ethdev.c **Location:** Lines 5368-5382
The code acquires a software semaphore (TXGBE_MNGSEM_SWPHY) at line 5368 but returns directly with -EIO at line 5382 without releasing the lock.
```c
status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
if (status)
return -EBUSY;
if (hw->mac.type == txgbe_mac_aml40) {
status = hw->phy.read_i2c_sff8636(hw, 0,
TXGBE_SFF_IDENTIFIER,
&identifier);
} else {
status = hw->phy.read_i2c_eeprom(hw,
TXGBE_SFF_IDENTIFIER,
&identifier);
}
if (status != 0)
goto ERROR_IO; /* GOOD - releases lock */
```However, the early returns at lines 5358-5365 before the lock is acquired would bypass the lock entirely if the pre-checks fail. While these don't leak the lock, they create an inconsistent state-checking flow.
**Suggested fix:** Move the presence checks after the lock acquisition to ensure consistent locking semantics:
```c
status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
if (status)
return -EBUSY;
/* Check module presence after acquiring lock */
if (hw->mac.type == txgbe_mac_aml40) {
value = rd32(hw, TXGBE_GPIOEXT);
if (value & TXGBE_SFP1_MOD_PRST_LS) {
status = -EIO;
goto ERROR_IO;
}
}
if (hw->mac.type == txgbe_mac_aml) {
value = rd32(hw, TXGBE_GPIOEXT);
if (value & TXGBE_SFP1_MOD_ABS_LS) {
status = -EIO;
goto ERROR_IO;
}
}
```---
## WARNINGS
### 1. Implicit comparison with zero
**File:** drivers/net/txgbe/txgbe_ethdev.c **Location:** Multiple occurrences (lines 5383, 5389, 5399, 5424)
The code uses if (status != 0) consistently, which is correct. However, there is one instance that needs verification:
```c if (status) return -EBUSY; ```
**Suggested fix:** For consistency with the rest of the function:
```c if (status != 0) return -EBUSY; ```
### 2. Mixed type usage: u8 vs uint8_t **File:** drivers/net/txgbe/txgbe_ethdev.c **Location:** Lines 5350-5351, others use uint8_t
```c u8 identifier = 0; u8 sff8636_rev = 0; ```
While u32 value; appears at line 5353, the rest of the function uses uint8_t and uint32_t. DPDK coding standards prefer explicit-width types with the _t suffix.
**Suggested fix:**
```c uint8_t identifier = 0; uint8_t sff8636_rev = 0; uint32_t value; ```
### 3. Unnecessary variable initialization
**File:** drivers/net/txgbe/txgbe_ethdev.c
**Location:** Lines 5350-5351
```c u8 identifier = 0; u8 sff8636_rev = 0; ```
Both variables are assigned before use via the read_i2c_* functions. Initializing to 0 defeats uninitialized-variable warnings.
**Suggested fix:**
```c uint8_t identifier; uint8_t sff8636_rev; ```
### 4. Release notes required
This patch fixes a bug (I2C access flow) and should be documented in the current release notes under "Fixed Issues" for the txgbe driver, per the contribution guidelines for bug fixes.
---
## INFO
### 1. Code organization improvement
The new code structure with a switch statement based on identifier is clearer than the original logic. This is a good refactoring that makes the code easier to maintain.
### 2. Error message clarity
The error messages "I2C IO ERROR" and "SFF Module Type not recognized" are informative. Consider whether these should include additional context (e.g., the identifier value for unrecognized types) to aid debugging.
---
## POSITIVE OBSERVATIONS
1. **Proper lock cleanup:** The ERROR_IO label correctly releases the semaphore before returning, which is the right pattern for error handling with acquired resources.
2. **Consistent error propagation:** The function properly returns -EIO, -EINVAL, and -EBUSY based on the failure type.
3. **Cc: [email protected] included:** Appropriate for a bug fix that should be backported.
---
## SUMMARY OF REQUIRED CHANGES
**Must fix (Errors):**
1. Move module presence checks after lock acquisition to ensure lock is held during all hardware access and properly released on all error paths
**Should fix (Warnings):**
1. Use explicit comparison status != 0 instead of implicit if (status)
2. Use uint8_t and uint32_t instead of u8 and u32
3. Remove unnecessary initialization of identifier and sff8636_rev
4. Add release notes entry for this bug fix
============================================================
RE: [PATCH v4 17/20] net/txgbe: fix get module info operation
Quoted 3 lines
## ERRORS
### 1. Resource leak on error path after lock acquisition
The AI review suggested moving the module presence checks inside the lock, which I believe is not necessary. The presence checks occur before acquiring the semaphore, so returning early cannot leak the lock. All error paths after lock acquisition do properly go through the ERROR_IO label and release the semaphore.
I've changed the pre-lock error from -EIO to - EINVAL to better distinguish "module not present" from actual I/O failures.
Quoted 5 lines
---
## WARNINGS
### 1. Implicit comparison with zero
Fixed.
Quoted 1 line
### 2. Mixed type usage:
u8vsuint8_t
Fixed.
Quoted 1 line
### 3. Unnecessary variable initialization
Fixed.
Quoted 6 lines
## INFO
### 2. Error message clarity
The error messages "I2C IO ERROR" and "SFF Module Type not recognized" are informative. Consider whether these should include additional context (e.g., the identifier value for unrecognized types) to aid debugging.
Added identifier value in error message.
PATCH v4 18/20 net/txgbe: fix get EEPROM operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/txgbe_ethdev.c | 67 ++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +60 -7
@@ -5458,23 +5458,76 @@ txgbe_get_module_eeprom(struct rte_eth_dev *dev,uint8_t databyte =0xFF ;uint8_t *data = info->data;uint32_t i =0 ; +bool is_sfp = false; +u32 value; +u8 identifier =0 ; +u16 offset; +u8 page =0 ; + +if (hw->mac.type == txgbe_mac_aml40) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_PRST_LS ) +return -EIO ; + } + +if (hw->mac.type == txgbe_mac_aml) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_ABS_LS ) +return -EIO ; + }if (info->length ==0 )return -EINVAL ; -for (i = info->offset; i < info->offset + info->length; i++) { -if (i <RTE_ETH_MODULE_SFF_8079_LEN ) - status = hw->phy.read_i2c_eeprom (hw, i, &databyte); -else - status = hw->phy.read_i2c_sff8472 (hw, i, &databyte); + status = hw->mac.acquire_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +if (status) +return -EBUSY ; -if (status !=0 ) -return -EIO ; + status = hw->phy.read_i2c_eeprom (hw, +TXGBE_SFF_IDENTIFIER , + &identifier); +if (status !=0 ) + goto ERROR_IO; +if (identifier ==TXGBE_SFF_IDENTIFIER_SFP ) + is_sfp = true; + +memset (data,0 , info->length); + +for (i = info->offset; i < info->offset + info->length; i++) { +if (is_sfp) { +if (i <RTE_ETH_MODULE_SFF_8079_LEN ) + status = hw->phy.read_i2c_eeprom (hw, i, + &databyte); +else + status = hw->phy.read_i2c_sff8472 (hw, i, + &databyte); + +if (status !=0 ) + goto ERROR_IO; + }else { + offset = i; +while (offset >=RTE_ETH_MODULE_SFF_8436_LEN ) { + offset -=RTE_ETH_MODULE_SFF_8436_LEN /2 ; + page++; + } +if (page ==0 || !(data[0x2 ] &0x4 )) { + status = hw->phy.read_i2c_sff8636 (hw, page, offset, + &databyte); +if (status !=0 ) + goto ERROR_IO; + } + } data[i - info->offset] = databyte; } + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY );return 0 ; + +ERROR_IO: +PMD_DRV_LOG (ERR ,"I2C IO ERROR." ); + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +return -EIO ; }bool
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 18/20] net/txgbe: fix get EEPROM operation
Quoted 9 lines · On Mon, 11 May 2026 18:36:00 +0800 Zaiyu Wang <[email protected]> wrote:
The original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
Fixes abf042d32b39 ("net/txgbe: add Amber-Lite 25G/40G NICs")Signed-off-by Zaiyu Wang <[email protected]>---
I agree with AI that u8, u16 should not be used except in base/ code.
# Review of Patch 18/20: net/txgbe: fix get EEPROM operation
## Errors
### 1. Wrong integer types used for kernel/hardware types
The code uses kernel-style type names (u32, u8, u16) instead of standard C types or DPDK types. This is inconsistent with DPDK coding standards which require standard C types.
**Location:**
```c u32 value; u8 identifier = 0; u16 offset; u8 page = 0; ```
**Fix:** Use standard C types:
```c uint32_t value; uint8_t identifier = 0; uint16_t offset; uint8_t page = 0; ```
### 2. Resource leak on error path
The function acquires a semaphore with hw->mac.acquire_swfw_sync() but fails to release it if info->length == 0 check fails.
**Location:**
```c
if (info->length == 0)
return -EINVAL;
status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
```**Fix:** The info->length == 0 check should be moved before the semaphore acquisition, OR the error path should release the semaphore:
```c
if (info->length == 0)
return -EINVAL;
status = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWPHY);
if (status)
return -EBUSY;
```This is actually correct as-is since the check happens before acquisition. **NOT AN ERROR.**
### 3. Implicit comparison for boolean
```c
if (identifier == TXGBE_SFF_IDENTIFIER_SFP)
is_sfp = true;
```This uses an integer comparison to set a boolean, which is fine. However, the boolean is_sfp is used directly in conditionals later, which is acceptable for bool types. **NOT AN ERROR.**
## Warnings
### 1. Missing bounds check on page calculation
The page variable is incremented in a loop without any upper bound check. While the loop is bounded by info->length, there's no verification that page doesn't exceed valid page numbers.
**Location:**
```c
while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) {
offset -= RTE_ETH_MODULE_SFF_8436_LEN / 2;
page++;
}
```**Suggestion:** Add bounds check on page number before use, or verify that info->length cannot cause page overflow:
```c
while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) {
offset -= RTE_ETH_MODULE_SFF_8436_LEN / 2;
page++;
}
if (page > MAX_VALID_PAGE) {
status = -EINVAL;
goto ERROR_IO;
}
```### 2. Buffer initialization redundancymemset(data, 0, info->length) clears the buffer, but then every byte is written in the loop. The memset may be needed for partial reads on error, but the error path returns without partial data, making this initialization unnecessary overhead.
**Location:**
```c
memset(data, 0, info->length);
for (i = info->offset; i < info->offset + info->length; i++) {
...
data[i - info->offset] = databyte;
}
```**Consideration:** If partial reads are acceptable (keeping what was read before error), the memset is appropriate. Otherwise, it's unnecessary.
### 3. Inconsistent coding style with bool keyword
The patch uses C99 bool type (bool is_sfp = false), which is good practice per guidelines. However, verify this is consistently available (requires <stdbool.h> which should be included).
### 4. Error path could leak partial data
On error, the function returns without clearing the potentially partially-filled buffer. If the caller expects zeroed data on error, this could be an information leak (though likely harmless in this context).
## Info
### 1. Magic number in condition
```c if (page == 0 || !(data[0x2] & 0x4)) ```
The 0x2 offset and 0x4 bitmask are magic numbers that should be defined as named constants for clarity.
**Suggestion:**
```c #define SFF8636_STATUS_OFFSET 0x2 #define SFF8636_FLAT_MEM_BIT 0x4 if (page == 0 || !(data[SFF8636_STATUS_OFFSET] & SFF8636_FLAT_MEM_BIT)) ```
### 2. Potential integer overflow in loop bound
```c for (i = info->offset; i < info->offset + info->length; i++) ```
If info->offset + info->length overflows (though unlikely with typical EEPROM sizes), the loop condition becomes incorrect. Consider bounds validation before the loop.
---
## Summary
**Critical issues:** 1 (wrong type names - must use C standard types)
**Important warnings:** 2 (missing page bounds check, potential partial data exposure)
**Style/clarity issues:** 2 (magic numbers, redundant memset)
The most important fix is changing the type declarations from u8/u16/u32 to uint8_t/uint16_t/uint32_t.
RE: [PATCH v4 18/20] net/txgbe: fix get EEPROM operation
Quoted 3 lines
I agree with AI that u8, u16 should not be used except in base/ code.
Fixed.
PATCH v4 19/20 net/txgbe: fix to reset Tx write-back pointer
In reply to Zaiyu WangThe write-back pointer was not reset when the Tx queue was reset. This leads to the wrong Tx desc free logic. Move the resetting of pointer into txq->ops->reset(txq).
--- drivers/net/txgbe/txgbe_rxtx.c | 45 +++++++++++++---------- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 ++++ 3 files changed, 33 insertions(+), 20 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +25 -20
@@ -2320,6 +2320,12 @@ txgbe_reset_tx_queue(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
@@ -2419,7 +2425,7 @@ txgbe_get_tx_port_offloads(struct rte_eth_dev *dev)return tx_offload_capa; } -static int +static void txgbe_setup_headwb_resources (struct rte_eth_dev *dev,void *tx_queue,unsigned int socket_id)
@@ -2427,33 +2433,33 @@ txgbe_setup_headwb_resources(struct rte_eth_dev *dev,struct txgbe_hw *hw =TXGBE_DEV_HW (dev);const struct rte_memzone *headwb;struct txgbe_tx_queue *txq = tx_queue; -u8 i, headwb_size =0 ; +u8 headwb_size =0 ; -if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) { - txq->headwb_mem =NULL ; -return 0 ; - } +if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) + goto out; + +if (!hw->devarg.tx_headwb) + goto out; - headwb_size = hw->devarg.tx_headwb_size; + headwb_size = txq->headwb_size; headwb =rte_eth_dma_zone_reserve (dev,"tx_headwb_mem" , txq->queue_id,sizeof (u32) * headwb_size,TXGBE_ALIGN , socket_id);if (headwb ==NULL ) { -DEBUGOUT ("Fail to setup headwb resources: no mem" ); -txgbe_tx_queue_release (txq); -return -ENOMEM ; +PMD_DRV_LOG (INFO , +"Failed to allocate headwb memory for Tx queue %u, change to SP mode" , + txq->queue_id); + goto out; } txq->headwb = headwb; txq->headwb_dma =TMZ_PADDR (headwb); txq->headwb_mem = (uint32_t *)TMZ_VADDR (headwb); +return ; -/* Zero out headwb_mem memory */ -for (i =0 ; i < headwb_size; i++) - txq->headwb_mem[i] =0 ; - -return 0 ; +out: + txq->headwb_mem =NULL ; }int __rte_cold
@@ -2549,6 +2555,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; + txq->headwb_size = hw->devarg.tx_headwb_size;#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY );
@@ -2584,8 +2591,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,/* set up scalar TX function as appropriate */ txgbe_set_tx_function (dev, txq); -if (hw->devarg.tx_headwb) - err =txgbe_setup_headwb_resources (dev, txq, socket_id); +txgbe_setup_headwb_resources (dev, txq, socket_id); txq->ops->reset (txq); txq->desc_error =0 ;
@@ -4762,15 +4768,14 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); -if ((hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) && - hw->devarg.tx_headwb) { +if (txq->headwb_mem) {uint32_t txdctl;wr32 (hw,TXGBE_PX_TR_HEAD_ADDRL (txq->reg_idx), (uint32_t )(txq->headwb_dma &BIT_MASK32 ));wr32 (hw,TXGBE_PX_TR_HEAD_ADDRH (txq->reg_idx), (uint32_t )(txq->headwb_dma >>32 )); -if (hw->devarg.tx_headwb_size ==16 ) +if (txq->headwb_size ==16 ) txdctl =TXGBE_PX_TR_CFG_HEAD_WB |TXGBE_PX_TR_CFG_HEAD_WB_64BYTE ;else
drivers/net/txgbe/txgbe_rxtx.h +1 -0
@@ -416,6 +416,7 @@ struct txgbe_tx_queue {uint64_t desc_error;bool resetting;const struct rte_memzone *headwb; +uint16_t headwb_size;uint64_t headwb_dma;volatile uint32_t *headwb_mem; };
drivers/net/txgbe/txgbe_rxtx_vec_common.h +7 -0
@@ -255,6 +255,13 @@ _txgbe_reset_tx_queue_vec(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; + +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
Signature · 1 line
2.21.0.windows.1
PATCH v4 20/20 net/txgbe: fix to enable Tx desc check
In reply to Zaiyu WangNow lib security is enabled by default, and cannot be disabled if the driver is intended to be used. So Tdm_desc_chk is always unable to enable. Remove this restriction, and just enable the corresponding queue check.
--- drivers/net/txgbe/txgbe_rxtx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +6 -5
@@ -4768,6 +4768,12 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); +#ifdef RTE_LIBRTE_SECURITY + if (!(txq->using_ipsec)) +#endif +wr32m (hw,TXGBE_TDM_DESC_CHK (txq->reg_idx /32 ), +BIT (txq->reg_idx %32 ),BIT (txq->reg_idx %32 )); +if (txq->headwb_mem) {uint32_t txdctl;
@@ -4785,11 +4791,6 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev) } } -#ifndef RTE_LIB_SECURITY -for (i =0 ; i <4 ; i++) -wr32 (hw,TXGBE_TDM_DESC_CHK (i),0xFFFFFFFF ); -#endif -/* Device configured with multiple TX queues. */ txgbe_dev_mq_tx_configure (dev); }
Signature · 1 line
2.21.0.windows.1
Re: [PATCH v4 20/20] net/txgbe: fix to enable Tx desc check
Quoted 9 lines · On Mon, 11 May 2026 18:36:02 +0800 Zaiyu Wang <[email protected]> wrote:
Now lib security is enabled by default, and cannot be disabled if the driver is intended to be used. So
Tdm_desc_chkis always unable to enable. Remove this restriction, and just enable the corresponding queue check.Fixes 0eabdfcd4af4 ("net/txgbe: enable Tx descriptor error interrupt")Signed-off-by Zaiyu Wang <[email protected]>---
Minor AI stuff here:
# Review of DPDK Patch: net/txgbe: fix to enable Tx desc check
## Summary
This patch modifies the Tx descriptor check logic in the txgbe driver to work correctly when security features are enabled. The change moves descriptor check setup from a global per-device operation to a per-queue operation.
## ERRORS
None found.
## WARNINGS
### 1. Bit manipulation should use RTE_BIT32() macro **File:** drivers/net/txgbe/txgbe_rxtx.c **Lines:** 4774, 4775
The code uses BIT() macro for bitmask generation. DPDK coding standards prefer RTE_BIT32() or RTE_BIT64() for clarity and portability.
**Current code:**
```c
wr32m(hw, TXGBE_TDM_DESC_CHK(txq->reg_idx / 32),
BIT(txq->reg_idx % 32), BIT(txq->reg_idx % 32));
```**Suggested fix:**
```c
wr32m(hw, TXGBE_TDM_DESC_CHK(txq->reg_idx / 32),
RTE_BIT32(txq->reg_idx % 32), RTE_BIT32(txq->reg_idx % 32));
```Verify that BIT() is defined in the driver's headers. If it's a legacy macro, consider using the DPDK standard RTE_BIT32() for consistency.
### 2. Conditional compilation without corresponding documentation update
**Context:** The patch changes the logic for when descriptor checks are enabled but there's no indication of release notes or documentation updates.
The original code disabled all descriptor checks when RTE_LIB_SECURITY was not defined. The new code enables descriptor checks per-queue unless the queue is using IPsec. This is a functional behavior change that should be documented.
**Suggested action:**
- Update release notes to describe the change in Tx descriptor check behavior
- Document that descriptor checks are now enabled per-queue based on IPsec usage rather than globally based on library compilation
## INFO
### 1. Potential logic optimization
The same bitmask value BIT(txq->reg_idx % 32) is used twice in the wr32m() call. Consider extracting it to a local variable for clarity:
```c uint32_t queue_bit = BIT(txq->reg_idx % 32); wr32m(hw, TXGBE_TDM_DESC_CHK(txq->reg_idx / 32), queue_bit, queue_bit); ```
This makes the intent clearer (setting the bit to 1) and slightly improves readability.
### 2. Parentheses around using_ipsec unnecessary **Line:** 4772
```c if (!(txq->using_ipsec)) ```
Could be written as:
```c if (!txq->using_ipsec) ```
The extra parentheses around using_ipsec are unnecessary since ! has higher precedence than most operators.
---
## OVERALL ASSESSMENT
The patch correctly addresses the issue where descriptor checks could not be enabled when the security library was compiled in. The logic change from global enable/disable to per-queue configuration based on IPsec usage is sound.
**Key improvements made:**
- Moves descriptor check setup into the per-queue loop
- Only disables checks for queues actually using IPsec
- Removes the blanket disable when security library is present
**Correctness:** No bugs detected. The resource management and control flow are correct.
**Style compliance:** Minor issues with macro usage; otherwise compliant.
RE: [PATCH v4 20/20] net/txgbe: fix to enable Tx desc check
Quoted 2 lines
Minor AI stuff here:
Thank you for the review. Based on the feedback, I have made the following adjustments:
Quoted 3 lines
## WARNINGS
### 1. Bit manipulation should use
RTE_BIT32()macro
Fixed.
Quoted 1 line
### 2. Conditional compilation without corresponding documentation update
No code change
This patch does not change the intended behavior of Tx desc check. Due to hardware limitation, IPsec and desc check cannot be enabled at the same time; the original design was to enable desc check by default when IPsec is not in use. The previous code had a bug that prevented this from working correctly, and this patch simply fixes that. Therefore a separate document update is not needed.
Quoted 4 lines
## INFO
### 1. Potential logic optimization
No code change
I chose not to extract the bitmask into a separate variable to keep the change minimal and the code concise.
Quoted 2 lines
### 2. Parentheses around
using_ipsecunnecessary
Fixed.
Quoted 3 lines · On Mon, 11 May 2026 18:35:42 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
Since these are fixes, they mostly standalone.
If you want I can cherrypick the ones that review cleanly; and you can then address the ones that have review feedback.
Quoted 13 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, May 18, 2026 10:54 PM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4 00/20] Wangxun FixesOn Mon, 11 May 2026 18:35:42 +0800
Zaiyu Wang <[email protected]> wrote:
Quoted 6 lines
Quoted 3 lines
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---Since these are fixes, they mostly standalone.
If you want I can cherrypick the ones that review cleanly; and you can
then
Quoted 2 lines
address the ones that have review feedback.
Hi Stephen,
Thank you so much for the detailed review and the very helpful feedback. Regarding your suggestion to cherry-pick the clean patches - if it's not too much trouble for you, that would be a great help.
Our company is currently evaluating AI-based tools. Next time I submit patches, I might be able to run them through our AI review first. That should help catch issues like these earlier and hopefully reduce your review burden.
v5 cover Wangxun Fixes
In reply to Zaiyu WangThis series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v5:
- Fixed issues identified by AI review
---
v4:
- Fixed issues identified by devtools scripts
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---
Zaiyu Wang (21):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in Tx rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get EEPROM operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
net/txgbe: fix temperature track for AML NIC
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 185 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 114 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3773 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1753 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 282 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 362 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 13 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 458 ++- drivers/net/txgbe/txgbe_ethdev.h | 7 +- drivers/net/txgbe/txgbe_rxtx.c | 107 +- drivers/net/txgbe/txgbe_rxtx.h | 36 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 16 +- 26 files changed, 9445 insertions(+), 445 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH v5 1/21 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v5 2/21 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v5 3/21 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v5 4/21 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
To resolve this, the following changes are made:
- do nothing when we set/unset allmulti if promiscuous mode is on
- restore the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
PATCH v5 5/21 net/txgbe: fix inaccuracy in Tx rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To address this, the following changes are made:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 3 +++ drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +3 -0
@@ -1670,6 +1670,9 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C +/* Ethernet framing overhead: 7B Ethernet preamble + 1B SFD + 1B EFD + 12B IPG */ +#define TXGBE_FRAME_OVERHEAD 21#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,TXGBE_FRAME_OVERHEAD );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
PATCH v5 6/21 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1
PATCH v5 7/21 net/txgbe: fix Tx desc free logic
In reply to Zaiyu WangOn some server environments, this driver caused TDM non-fatal errors or PCIe request errors during Tx operation
In Amber-Lite NIC's Tx head write-back mode, the hardware periodically writes back a head index pointing to the next descriptor it is adout to process in Tx ring. All descriptors before the head are considered processed by hardware and can be safely freed by the driver.
The root cause is that the driver can safely free a batch of descriptors only when the hardware's write-back head pointer has advanced beyond all descriptors in that batch, meaning they have all been processed by the hardware. If the driver frees a descriptor before the hardware has finished processing it, invalid memory access may occur, leading to the observed bug.
To fix the issue, correct the boundary check in all three Tx cleanup functions, each of which was missing the proper condition to prevent freeing unprocessed descriptors.
--- drivers/net/txgbe/txgbe_rxtx.c | 14 ++++----- drivers/net/txgbe/txgbe_rxtx.h | 35 +++++++++++++++++++++++ drivers/net/txgbe/txgbe_rxtx_vec_common.h | 9 +++--- 3 files changed, 45 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +6 -8
@@ -98,12 +98,10 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq)if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; +const uint16_t head =rte_atomic_load_explicit ((volatile uint16_t *)txq->headwb_mem, + rte_memory_order_acquire); -if (txq->tx_next_dd > head && head > tx_last_dd) -return 0 ; -else if (tx_last_dd > txq->tx_next_dd && - (head > tx_last_dd || head < txq->tx_next_dd)) +if (!txgbe_tx_headwb_desc_done (head, tx_last_dd, txq->tx_next_dd))return 0 ; }else {/* check DD bit on threshold descriptor */
@@ -645,12 +643,12 @@ txgbe_xmit_cleanup(struct txgbe_tx_queue *txq) status = txr[desc_to_clean_to].dw3;if (txq->headwb_mem) { -u32 head = *txq->headwb_mem; +const uint16_t head =rte_atomic_load_explicit ((volatile uint16_t *)txq->headwb_mem, + rte_memory_order_acquire);PMD_TX_FREE_LOG (DEBUG ,"queue[%02d]: headwb_mem = %03d, desc_to_clean_to = %03d" , txq->reg_idx, head, desc_to_clean_to); -/* we have caught up to head, no work left to do */ -if (desc_to_clean_to == head) +if (!txgbe_tx_headwb_desc_done (head, last_desc_cleaned, desc_to_clean_to))return -(1 ); }else {if (!(status &rte_cpu_to_le_32 (TXGBE_TXD_DD ))) {
drivers/net/txgbe/txgbe_rxtx.h +35 -0
@@ -426,6 +426,41 @@ struct txgbe_txq_ops {void (*reset)(struct txgbe_tx_queue *txq); }; +/** +* Check whether Tx descriptors in the range (last, next] are done +* in Tx head write-back mode. +* +* In head write-back mode, the hardware periodically updates *headwb_mem +* with the index of the next descriptor it will process. +* All descriptors before the head are considered processed by hardware and can +* be safely freed. The descriptor pointed to by head itself is not yet processed. +* +* @param head +* Current hardware head index read from headwb_mem. +* @param last +* The highest-index descriptor cleaned in the previous round +* (exclusive: descriptors at or before this index are already freed). +* @param next +* The highest-index descriptor to be cleaned in this round +* (inclusive: this descriptor is the target of the current cleanup). +* @return +* true if all descriptors in the range (last, next] have been completed +* by hardware and can be freed, false otherwise. +*/ +static inline bool +txgbe_tx_headwb_desc_done (uint16_t head,uint16_t last,uint16_t next) +{ +if (next == head) +return false; +else if (next > head && head > last) +return false; +/* wrap case */ +else if (last > next && (head > last || head < next)) +return false; + +return true; +} +/* Takes an ethdev and a queue and sets up the tx function to be used based on * the queue parameters. Used in tx_queue_setup by primary process and then * in dev_init by secondary process when attaching to an existing ethdev.
drivers/net/txgbe/txgbe_rxtx_vec_common.h +4 -5
@@ -94,11 +94,10 @@ txgbe_tx_free_bufs(struct txgbe_tx_queue *txq) txq->tx_next_dd - txq->tx_free_thresh;if (tx_last_dd >= txq->nb_tx_desc) tx_last_dd -= txq->nb_tx_desc; -volatile uint16_t head = (uint16_t )*txq->headwb_mem; -if (txq->tx_next_dd > head && head > tx_last_dd) -return 0 ; -else if (tx_last_dd > txq->tx_next_dd && - (head > tx_last_dd || head < txq->tx_next_dd)) +const uint16_t head =rte_atomic_load_explicit ((volatile uint16_t *)txq->headwb_mem, + rte_memory_order_acquire); + +if (!txgbe_tx_headwb_desc_done (head, tx_last_dd, txq->tx_next_dd))return 0 ; }else {/* check DD bit on threshold descriptor */
Signature · 1 line
2.21.0.windows.1
PATCH v5 8/21 net/txgbe: fix link flow control registers for Amber-Lite
In reply to Zaiyu WangThe flow control counter registers on AML NICs differ from those on SP NICs. Update the register offsets accordingly to ensure the counters work correctly.
--- drivers/net/txgbe/base/txgbe_hw.c | 7 ++++++ drivers/net/txgbe/base/txgbe_regs.h | 2 ++ drivers/net/txgbe/base/txgbe_type.h | 4 ++++ drivers/net/txgbe/txgbe_ethdev.c | 34 +++++++++++++++++++---------- 4 files changed, 36 insertions(+), 11 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +7 -0
@@ -394,6 +394,13 @@ s32 txgbe_clear_hw_cntrs(struct txgbe_hw *hw)rd32 (hw,TXGBE_PBTXLNKXON );rd32 (hw,TXGBE_PBTXLNKXOFF ); +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +wr32 (hw,TXGBE_PBRXLNKXON_AML ,0 ); +wr32 (hw,TXGBE_PBRXLNKXOFF_AML ,0 ); + hw->last_stats.rx_xon_packets =0 ; + hw->last_stats.rx_xoff_packets =0 ; + } +/* DMA Stats */ rd32 (hw,TXGBE_DMARXPKT );rd32 (hw,TXGBE_DMATXPKT );
drivers/net/txgbe/base/txgbe_regs.h +2 -0
@@ -1085,6 +1085,8 @@ enum txgbe_5tuple_protocol {#define TXGBE_PBRXDROP 0x019068#define TXGBE_PBRXLNKXOFF 0x011988#define TXGBE_PBRXLNKXON 0x011E0C +#define TXGBE_PBRXLNKXOFF_AML 0x011F80 +#define TXGBE_PBRXLNKXON_AML 0x011F84#define TXGBE_PBRXUPXON (up) (0x011E30 + (up) * 4)#define TXGBE_PBRXUPXOFF (up) (0x011E10 + (up) * 4)
drivers/net/txgbe/base/txgbe_type.h +4 -0
@@ -876,6 +876,10 @@ struct txgbe_hw {u64 tx_qp_bytes;u64 rx_qp_mc_packets; } qp_last[TXGBE_MAX_QP ]; +struct { +u64 rx_xon_packets; +u64 rx_xoff_packets; + } last_stats;rte_spinlock_t phy_lock;/*amlite: new SW-FW mbox */
drivers/net/txgbe/txgbe_ethdev.c +23 -11
@@ -2264,16 +2264,18 @@ txgbe_dev_reset(struct rte_eth_dev *dev)return ret; } +#define TXGBE_UPDATE_COUNTER_32BIT_GENERIC (reg, last, count, reset) \ + do { \ + uint32_t current = rd32(hw, reg); \ + if ((current) < (last)) \ + current += 0x100000000ULL; \ + if (reset) \ + (last) = current; \ + (count) = (uint32_t)((current) - (last)); \ + } while (0) +#define UPDATE_QP_COUNTER_32bit (reg, last_counter, counter) \ - { \ - uint32_t current_counter = rd32(hw, reg); \ - if (current_counter < last_counter) \ - current_counter += 0x100000000LL; \ - if (!hw->offset_loaded) \ - last_counter = current_counter; \ - counter = current_counter - last_counter; \ - counter &= 0xFFFFFFFFLL; \ - } + TXGBE_UPDATE_COUNTER_32BIT_GENERIC(reg, last_counter, counter, !hw->offset_loaded)#define UPDATE_QP_COUNTER_36bit (reg_lsb, reg_msb, last_counter, counter) \ { \
@@ -2331,8 +2333,18 @@ txgbe_read_stats_registers(struct txgbe_hw *hw, hw_stats->up[i].rx_up_dropped +=rd32 (hw,TXGBE_PBRXMISS (i)); } - hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); - hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) { +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXON_AML , + hw->last_stats.rx_xon_packets, + hw_stats->rx_xon_packets, !hw->offset_loaded); +TXGBE_UPDATE_COUNTER_32BIT_GENERIC (TXGBE_PBRXLNKXOFF_AML , + hw->last_stats.rx_xoff_packets, + hw_stats->rx_xoff_packets, !hw->offset_loaded); + }else { + hw_stats->rx_xon_packets +=rd32 (hw,TXGBE_PBRXLNKXON ); + hw_stats->rx_xoff_packets +=rd32 (hw,TXGBE_PBRXLNKXOFF ); + } hw_stats->tx_xon_packets +=rd32 (hw,TXGBE_PBTXLNKXON ); hw_stats->tx_xoff_packets +=rd32 (hw,TXGBE_PBTXLNKXOFF );
Signature · 1 line
2.21.0.windows.1
PATCH v5 9/21 net/txgbe: fix link flow control config for Sapphire
In reply to Zaiyu WangSP chips have a hardware bug preventing XON flow control support, so the driver disables it.
--- drivers/net/txgbe/base/txgbe_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +4 -2
@@ -1037,8 +1037,10 @@ s32 txgbe_fc_enable(struct txgbe_hw *hw)for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {if ((hw->fc.current_mode & txgbe_fc_tx_pause) && hw->fc.high_water[i]) { - fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]) | -TXGBE_FCWTRLO_XON ; + fcrtl =TXGBE_FCWTRLO_TH (hw->fc.low_water[i]); +/* Only AML support XON */ +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) + fcrtl |=TXGBE_FCWTRLO_XON ; fcrth =TXGBE_FCWTRHI_TH (hw->fc.high_water[i]) |TXGBE_FCWTRHI_XOFF ; }else {
Signature · 1 line
2.21.0.windows.1
PATCH v5 10/21 net/txgbe: fix a mass of unknown interrupts
In reply to Zaiyu WangWhen RSC is enabled, Rx ring IVAR is set to configure ITR. It causes Rx ring interrupts report on the default msix_vector. Thus a mass of unknown interrupts occupy CPU.
Fix the issue by setting ring IVAR only when the rxq interrupt is enabled.
--- drivers/net/txgbe/txgbe_rxtx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +17 -13
@@ -4345,6 +4345,8 @@ static int txgbe_set_rsc(struct rte_eth_dev *dev) {struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct txgbe_hw *hw =TXGBE_DEV_HW (dev);struct rte_eth_dev_info dev_info = {0 };bool rsc_capable = false;
@@ -4395,8 +4397,6 @@ txgbe_set_rsc(struct rte_eth_dev *dev)rd32 (hw,TXGBE_RXCFG (rxq->reg_idx));uint32_t psrtype =rd32 (hw,TXGBE_POOLRSS (rxq->reg_idx)); -uint32_t eitr = -rd32 (hw,TXGBE_ITR (rxq->reg_idx));/* * txgbe PMD doesn't support header-split at the moment.
@@ -4415,6 +4415,9 @@ txgbe_set_rsc(struct rte_eth_dev *dev) srrctl |=txgbe_get_rscctl_maxdesc (rxq->mb_pool); psrtype |=TXGBE_POOLRSS_L4HDR ; +wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); +wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); +/* * RSC: Set ITR interval corresponding to 2K ints/s. *
@@ -4428,19 +4431,20 @@ txgbe_set_rsc(struct rte_eth_dev *dev)* For a sparse streaming case this setting will yield * at most 500us latency for a single RSC aggregation. */ - eitr &= ~TXGBE_ITR_IVAL_MASK ; - eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); - eitr |=TXGBE_ITR_WRDSA ; +if (rte_intr_dp_is_en (intr_handle)) { +uint32_t eitr =rd32 (hw,TXGBE_ITR (rxq->reg_idx)); -wr32 (hw,TXGBE_RXCFG (rxq->reg_idx), srrctl); -wr32 (hw,TXGBE_POOLRSS (rxq->reg_idx), psrtype); -wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); + eitr &= ~TXGBE_ITR_IVAL_MASK ; + eitr |=TXGBE_ITR_IVAL_10G (TXGBE_QUEUE_ITR_INTERVAL_DEFAULT ); + eitr |=TXGBE_ITR_WRDSA ; +wr32 (hw,TXGBE_ITR (rxq->reg_idx), eitr); -/* -* RSC requires the mapping of the queue to the -* interrupt vector. -*/ -txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); +/* +* RSC requires the mapping of the queue to the +* interrupt vector. +*/ +txgbe_set_ivar_map (hw,0 , rxq->reg_idx, i); + } } dev->data->lro =1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v5 11/21 net/txgbe: fix traffic class priority configuration
In reply to Zaiyu WangAfter applying the following testpmd command, 802.1Q packets with specific priorities were not properly directed to the corresponding traffic classes:
port config 0 dcb vt off 4 pfc off
The old driver had two issues:
1. The hardware uses a 4-bit mapping register per traffic class for priority-to-TC mapping, but the driver incorrectly configured it as 3 bits.
2. The DCB TX configuration mistakenly wrote to the RX register.
Fix both issues, ensuring that tc-prio mapping works as expected. Additionally, remove the stale and inconsistent TXGBE_DCBUP2TC_DEC macro as it has no callers.
--- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_regs.h | 6 ++---- drivers/net/txgbe/txgbe_rxtx.c | 7 ++----- 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/txgbe/base/txgbe_dcb_hw.c +1 -1
@@ -154,7 +154,7 @@ s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,for (i =0 ; i <TXGBE_DCB_UP_MAX ; i++) reg |=TXGBE_DCBUP2TC_MAP (i, map[i]); -wr32 (hw,TXGBE_PBRXUP2TC , reg); +wr32 (hw,TXGBE_PBTXUP2TC , reg);/* Configure traffic class credits and priority */ for (i =0 ; i <TXGBE_DCB_TC_MAX ; i++) {
drivers/net/txgbe/base/txgbe_regs.h +2 -4
@@ -503,10 +503,8 @@#define TXGBE_PBRXCTL 0x019000#define TXGBE_PBRXCTL_ST MS(0, 0x1)#define TXGBE_PBRXCTL_ENA MS(31, 0x1) -#define TXGBE_PBRXUP2TC 0x019008#define TXGBE_PBTXUP2TC 0x01C800 -#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 3 * (tc), 0x7) -#define TXGBE_DCBUP2TC_DEC (tc, r) RS(r, 3 * (tc), 0x7) +#define TXGBE_DCBUP2TC_MAP (tc, v) LS(v, 4 * (tc), 0x7)#define TXGBE_PBRXSIZE (tc) (0x019020 + (tc) * 4)#define TXGBE_PBRXSIZE_KB (v) LS(v, 10, 0x3FF)
@@ -1705,7 +1703,7 @@ enum txgbe_5tuple_protocol {#define TXGBE_RDM_PF_HIDE (_i) (0x12090 + ((_i) * 4))#define TXGBE_RPUP2TC 0x019008 -#define TXGBE_RPUP2TC_UP_SHIFT 3 +#define TXGBE_RPUP2TC_UP_SHIFT 4#define TXGBE_RPUP2TC_UP_MASK 0x7#define TXGBE_RDM_DCACHE_CTL 0x0120A8
drivers/net/txgbe/txgbe_rxtx.c +2 -5
@@ -3376,11 +3376,8 @@ txgbe_vmdq_dcb_configure(struct rte_eth_dev *dev) queue_mapping =0 ;for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) -/* -* mapping is done with 3 bits per priority, -* so shift by i*3 each time -*/ - queue_mapping |= ((cfg->dcb_tc[i] &0x07 ) << (i *3 )); + queue_mapping |= ((cfg->dcb_tc[i] &TXGBE_RPUP2TC_UP_MASK ) << + (i *TXGBE_RPUP2TC_UP_SHIFT ));wr32 (hw,TXGBE_RPUP2TC , queue_mapping);
Signature · 1 line
2.21.0.windows.1
PATCH v5 12/21 net/txgbe: fix link stability for 25G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_aml.c | 105 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 2488 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1746 +++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 279 +++ drivers/net/txgbe/base/txgbe_hw.c | 35 +- drivers/net/txgbe/base/txgbe_phy.h | 1 - drivers/net/txgbe/base/txgbe_regs.h | 2 + drivers/net/txgbe/base/txgbe_type.h | 12 + drivers/net/txgbe/txgbe_ethdev.c | 83 +- drivers/net/txgbe/txgbe_ethdev.h | 4 + 12 files changed, 4703 insertions(+), 59 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
drivers/net/txgbe/base/meson.build +1 -0
@@ -12,4 +12,5 @@ base_sources = files( 'txgbe_mng.c', 'txgbe_phy.c', 'txgbe_vf.c', + 'txgbe_e56.c', )
drivers/net/txgbe/base/txgbe_aml.c +80 -25
177 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml.h +4 -2
@@ -16,7 +16,9 @@ s32 txgbe_get_link_capabilities_aml(struct txgbe_hw *hw, u32 *speed, bool *autoneg);u32 txgbe_get_media_type_aml (struct txgbe_hw *hw);void txgbe_wait_for_link_up_aml (struct txgbe_hw *hw,u32 speed); -s32 txgbe_setup_mac_link_aml (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml (struct txgbe_hw *hw);#endif /* _TXGBE_AML_H_ */
drivers/net/txgbe/base/txgbe_e56.c new file +2488 -0
2,488 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h new file +1746 -0
319 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h new file +279 -0
279 lines not on this page · raw message
drivers/net/txgbe/txgbe_ethdev.c +82 -1
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH v5 13/21 net/txgbe: fix link stability for 40G NIC
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/txgbe_aml40.c | 73 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_e56.c | 1473 ++++++++++++++++++++++++-- drivers/net/txgbe/base/txgbe_e56.h | 9 +- drivers/net/txgbe/txgbe_ethdev.c | 4 +- 5 files changed, 1447 insertions(+), 118 deletions(-)
drivers/net/txgbe/base/txgbe_aml40.c +56 -17
@@ -13,6 +13,7 @@#include "txgbe_hw.h" #include "txgbe_aml.h" #include "txgbe_aml40.h" +#include "txgbe_e56.h" void txgbe_init_ops_aml40 (struct txgbe_hw *hw) {
@@ -24,6 +25,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)/* PHY */ phy->get_media_type = txgbe_get_media_type_aml40; + phy->setup_link_core = txgbe_setup_phy_link_aml40;/* LINK */ mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
@@ -52,6 +54,13 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,if (link_up_wait_to_complete) {for (i =0 ; i < hw->mac.max_link_up_time; i++) { +if (!hw->link_valid) { + *link_up = false; + +msleep (100 ); +continue ; + } +if (!(links_reg &TXGBE_PORTSTAT_UP )) { *link_up = false; }else {
@@ -68,6 +77,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } +if (!hw->link_valid) + *link_up = false; +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G )
@@ -107,20 +119,24 @@ u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)return txgbe_media_type_fiber_qsfp; } -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw, -u32 speed, -bool autoneg_wait_to_complete) +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset) {bool autoneg = false;s32 status =0 ; +s32 ret_status =0 ;u32 link_speed =TXGBE_LINK_SPEED_UNKNOWN ;bool link_up = false; +int i;u32 link_capabilities =TXGBE_LINK_SPEED_UNKNOWN ; +u32 value; -if (hw->phy.sfp_type == txgbe_sfp_type_not_present) { -DEBUGOUT ("SFP not detected, skip setup mac link" ); -return 0 ; - } + *need_reset = false; + +if (hw->phy.sfp_type == txgbe_sfp_type_not_present) + hw->phy.identify_sfp (hw);/* Check to see if speed passed in is supported. */ status = hw->mac.get_link_capabilities(hw,
@@ -132,18 +148,42 @@ s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,if (speed ==TXGBE_LINK_SPEED_UNKNOWN )return TXGBE_ERR_LINK_SETUP ; - status = hw->mac.check_link (hw, &link_speed, &link_up, - autoneg_wait_to_complete); +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) +break ; +msleep (250 ); + }if (link_speed == speed && link_up) -return status; - -if (speed &TXGBE_LINK_SPEED_40GB_FULL ) - speed =0x20 ; - - status = hw->phy.set_link_hostif (hw, (u8 )speed, autoneg, true); + goto out; + +rte_spinlock_lock (&hw->phy_lock); + ret_status =txgbe_set_link_to_amlite (hw, speed); +if (ret_status ==TXGBE_ERR_TIMEOUT ) + hw->link_valid = false; +rte_spinlock_unlock (&hw->phy_lock); + +for (i =0 ; i <4 ; i++) { +txgbe_e56_check_phy_link (hw, &link_speed, &link_up); +if (link_up) + goto out; +msleep (250 ); + } -txgbe_wait_for_link_up_aml (hw, speed); +out: +if (link_up) { + value =rd32 (hw,TXGBE_PORTSTAT ); +if (!(value &TXGBE_PORTSTAT_UP )) { +DEBUGOUT ("MAC link 0x14404: 0x%x" , value); + *need_reset = true; + value =rd32 (hw,0x110b0 ); +DEBUGOUT ("MAC intr status 0x110b0: 0x%x" , value); + } + }else { + *need_reset = true; +DEBUGOUT ("Link reconfiguration required. Reset scheduled in 2000ms." ); + }return status; }
@@ -159,6 +199,5 @@ void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw) mac->flap_tx_laser = txgbe_flap_tx_laser_multispeed_fiber; - mac->setup_link = txgbe_setup_mac_link_aml40; mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed; }
drivers/net/txgbe/base/txgbe_aml40.h +4 -2
@@ -14,7 +14,9 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw,s32 txgbe_get_link_capabilities_aml40 (struct txgbe_hw *hw,u32 *speed,bool *autoneg);u32 txgbe_get_media_type_aml40 (struct txgbe_hw *hw); -s32 txgbe_setup_mac_link_aml40 (struct txgbe_hw *hw,u32 speed, -bool autoneg_wait_to_complete); +s32 txgbe_setup_phy_link_aml40 (struct txgbe_hw *hw, +u32 speed, +bool autoneg_wait_to_complete, +bool *need_reset);void txgbe_init_mac_link_ops_aml40 (struct txgbe_hw *hw);#endif /* _TXGBE_AML40_H_ */
drivers/net/txgbe/base/txgbe_e56.c +1378 -95
1,560 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.h +7 -2
@@ -438,7 +438,12 @@ typedef union {#define E56PHY_FETX_FFE_TRAIN_CFG_0_KRT_FETX_INIT_FFE_CFG_2 9, 8#define E56PHY_FETX_FFE_TRAIN_CFG_0_KRT_FETX_INIT_FFE_CFG_3 13, 12 -#define PHYINIT_TIMEOUT 1000/* PHY initialization timeout value in 0.5ms unit */ +/* PHYINIT_TIMEOUT, a loop iteration counter, not a fixed time unit. +* The actual timeout duration depends on the usec_delay() or msleep() +* value used inside the polling loop. For example, when usec_delay(500) +* is used, the total timeout is approximately PHYINIT_TIMEOUT * 500 us. +*/ +#define PHYINIT_TIMEOUT 1000#define E56G__BASEADDR 0x0
@@ -1729,7 +1734,7 @@ typedef union {void set_fields_e56 (unsigned int *src_data,unsigned int bit_high,unsigned int bit_low,unsigned int set_value); -int txgbe_e56_rx_rd_second_code_40g (struct txgbe_hw *hw,int *SECOND_CODE ,int lane); +void txgbe_e56_rx_rd_second_code_40g (struct txgbe_hw *hw,int *SECOND_CODE ,int lane);void txgbe_e56_rx_rd_second_code (struct txgbe_hw *hw,int *SECOND_CODE );u32 txgbe_e56_cfg_40g (struct txgbe_hw *hw);u32 txgbe_e56_cfg_25g (struct txgbe_hw *hw);
drivers/net/txgbe/txgbe_ethdev.c +2 -2
@@ -2054,7 +2054,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE (); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw);rte_eal_alarm_cancel (txgbe_dev_detect_sfp, dev);
@@ -3206,7 +3206,7 @@ txgbe_dev_setup_link_thread_handler(void *param)struct txgbe_hw *hw =TXGBE_DEV_HW (dev);rte_thread_detach (rte_thread_self ()); -if (hw->mac.type == txgbe_mac_aml) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)txgbe_dev_setup_link_alarm_handler_aml (hw);else txgbe_dev_setup_link_alarm_handler (dev);
Signature · 1 line
2.21.0.windows.1
PATCH v5 14/21 net/txgbe: fix link stability for Amber-Lite backplane mode
In reply to Zaiyu WangThe link was previously configured via firmware, but this approach resulted in unstable link behavior. To resolve the issue, re-add the PHY configuration flow directly into the driver.
--- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 65 +- drivers/net/txgbe/base/txgbe_aml40.c | 43 +- drivers/net/txgbe/base/txgbe_e56.c | 22 +- drivers/net/txgbe/base/txgbe_e56.h | 2 + drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 +++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 3 + drivers/net/txgbe/base/txgbe_hw.c | 6 + drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 21 + drivers/net/txgbe/base/txgbe_phy.h | 22 + drivers/net/txgbe/base/txgbe_type.h | 25 +- drivers/net/txgbe/txgbe_ethdev.c | 109 +- drivers/net/txgbe/txgbe_ethdev.h | 2 +- 16 files changed, 2898 insertions(+), 30 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c
drivers/net/txgbe/base/meson.build +1 -0
@@ -13,4 +13,5 @@ base_sources = files( 'txgbe_phy.c', 'txgbe_vf.c', 'txgbe_e56.c', + 'txgbe_e56_bp.c', )
drivers/net/txgbe/base/txgbe.h +2 -0
@@ -13,5 +13,7 @@#include "txgbe_hw.h" #include "txgbe_vf.h" #include "txgbe_dcb.h" +#include "txgbe_e56.h" +#include "txgbe_e56_bp.h" #endif /* _TXGBE_H_ */
drivers/net/txgbe/base/txgbe_aml.c +54 -11
102 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_aml40.c +39 -4
73 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56.c +12 -10
@@ -53,7 +53,7 @@ int txgbe_e56_int_cmp(const void *a, const void *b) }s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up) +bool *link_up) {u32 rdata =0 ;u32 links_reg =0 ;
@@ -101,7 +101,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ; }else if (speed ==TXGBE_LINK_SPEED_25GB_FULL ) {if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || - hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1) { + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S25G_TX_FFE_CFG_DAC_MAIN ; pre1 =S25G_TX_FFE_CFG_DAC_PRE1 ; pre2 =S25G_TX_FFE_CFG_DAC_PRE2 ;
@@ -119,7 +120,8 @@ u32 txgbe_e56_tx_ffe_cfg(struct txgbe_hw *hw, u32 speed) post =S10G_TX_FFE_CFG_POST ;if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || - hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) { + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1 || +txgbe_is_backplane (hw)) { ffe_main =S40G_TX_FFE_CFG_MAIN ; pre1 =S40G_TX_FFE_CFG_PRE1 ; pre2 =S40G_TX_FFE_CFG_PRE2 ;
@@ -1508,7 +1510,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );return -1 ; } }
@@ -1542,7 +1544,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );return -1 ; } }
@@ -1618,7 +1620,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed) addr =E56PHY_CTRL_FSM_RX_STAT_0_ADDR ; rdata =rd32_ephy (hw, addr);if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );return -1 ; } }
@@ -1664,7 +1666,7 @@ txgbe_e56_rxs_osc_init_for_temp_track_range(struct txgbe_hw *hw, u32 speed)if (((rdata >> (i *8 )) &0x3f ) ==0x21 )break ;if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );return -1 ; } }
@@ -1929,7 +1931,7 @@ int txgbe_temp_track_seq_40g(struct txgbe_hw *hw, u32 speed)CMVAR_UFINE_FMIN_WRAP =S25G_CMVAR_UFINE_FMIN_WRAP ;CMVAR_FINE_FMIN_WRAP =S25G_CMVAR_FINE_FMIN_WRAP ; }else { -DEBUGOUT ("Error Speed\n" ); +DEBUGOUT ("Error Speed" );return 0 ; }
@@ -3190,7 +3192,7 @@ static int txgbe_e56_disable_rx40G(struct txgbe_hw *hw) rdata =rd32_ephy (hw, addr);usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
@@ -3296,7 +3298,7 @@ static int txgbe_e56_disable_rx(struct txgbe_hw *hw)break ;usec_delay (100 );if (timer++ >PHYINIT_TIMEOUT ) { -DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!\n" ); +DEBUGOUT ("ERROR: Wait E56PHY_CTRL_FSM_RX_STAT_0_ADDR Timeout!" );break ; } }
drivers/net/txgbe/base/txgbe_e56.h +2 -0
@@ -1744,6 +1744,8 @@ int txgbe_temp_track_seq(struct txgbe_hw *hw, u32 speed);int txgbe_e56_get_temp (struct txgbe_hw *hw,int *temp);int txgbe_set_link_to_amlite (struct txgbe_hw *hw,u32 speed);int txgbe_e56_reconfig_rx (struct txgbe_hw *hw,u32 speed); +s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, +bool *link_up);s32 txgbe_e56_fec_set (struct txgbe_hw *hw);s32 txgbe_e56_fec_polling (struct txgbe_hw *hw,bool *link_up);u32 txgbe_e56_tx_ffe_cfg (struct txgbe_hw *hw,u32 speed);
drivers/net/txgbe/base/txgbe_e56_bp.c new file +2597 -0
2,597 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_e56_bp.h +3 -0
@@ -276,4 +276,7 @@ typedef union {#define E56PHY_CMS_ANA_OVRDVAL_10_ADDR (E56PHY_CMS_BASE_ADDR + 0xD8)#define E56PHY_CMS_ANA_OVRDVAL_7_ANA_LCPLL_LF_LPF_SETCODE_CALIB_I 8, 4 +int txgbe_e56_set_phy_link_mode (struct txgbe_hw *hw, +u8 bp_link_mode,u32 need_restart); +int handle_e56_bkp_an73_flow (struct txgbe_hw *hw);#endif
drivers/net/txgbe/base/txgbe_hw.c +6 -0
@@ -4071,6 +4071,12 @@ s32 txgbe_reset_pipeline_raptor(struct txgbe_hw *hw)return err; } +bool txgbe_is_backplane (struct txgbe_hw *hw) +{ +return hw->phy.get_media_type (hw) == txgbe_media_type_backplane ? + true : false; +} +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask) {u32 gpio_ext =rd32 (hw,TXGBE_GPIOEXT );
drivers/net/txgbe/base/txgbe_hw.h +2 -2
@@ -118,6 +118,6 @@ s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw);bool txgbe_verify_lesm_fw_enabled_raptor (struct txgbe_hw *hw);s32 txgbe_fmgr_cmd_op (struct txgbe_hw *hw,u32 cmd,u32 cmd_addr);s32 txgbe_flash_read_dword (struct txgbe_hw *hw,u32 addr,u32 *data); -s32 txgbe_e56_check_phy_link (struct txgbe_hw *hw,u32 *speed, -bool *link_up); +bool txgbe_is_backplane (struct txgbe_hw *hw); +bool txgbe_gpio_ext_check (struct txgbe_hw *hw,u8 gpio_ext_mask);#endif /* _TXGBE_HW_H_ */
drivers/net/txgbe/base/txgbe_osdep.h +4 -0
@@ -162,6 +162,10 @@ static inline u64 REVERT_BIT_MASK64(u64 mask) ((mask &0xFFFFFFFF00000000 ) >>32 ); } +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define IOMEM #define BIT (nr) (1UL << (nr))
drivers/net/txgbe/base/txgbe_phy.c +21 -0
@@ -2503,6 +2503,27 @@ void txgbe_set_phy_temp(struct txgbe_hw *hw) } } +int txgbe_is_dac_cable (struct txgbe_hw *hw) +{ +if (hw->phy.sfp_type == txgbe_sfp_type_da_cu_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_cu_core1 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core0 || + hw->phy.sfp_type == txgbe_sfp_type_da_act_lmt_core1 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 || + hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) +return true; + +return false; +} + +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw) +{ +if (!(txgbe_is_dac_cable (hw) ||txgbe_is_backplane (hw))) +return false; + +return hw->devarg.auto_neg ? true : false; +} +/** * txgbe_kr_handle - Handle the interrupt of auto-negotiation * @hw: pointer to hardware structure
drivers/net/txgbe/base/txgbe_phy.h +22 -0
@@ -105,6 +105,8 @@#define VR_AN_INTR_CMPLT MS16(0, 0x1)#define VR_AN_INTR_LINK MS16(1, 0x1)#define VR_AN_INTR_PG_RCV MS16(2, 0x1) +#define TXGBE_E56_AN_TXDIS MS16(3, 0x1) +#define TXGBE_E56_AN_PG_RCV MS16(4, 0x1)#define VR_AN_KR_MODE_CL 0x078003#define VR_AN_KR_MODE_CL_PDET MS16(0, 0x1)#define VR_XS_OR_PCS_MMD_DIGI_CTL1 0x038000
@@ -428,6 +430,24 @@#define TXGBE_BP_M_NAUTO 0#define TXGBE_BP_M_AUTO 1 +#define kr_read_poll (op, val, cond, sleep_us, \ + times, args...) \ +({ \ + unsigned long __sleep_us = (sleep_us); \ + u32 __times = (times); \ + u32 i; \ + int __cond = 0; \ + for (i = 0; i < __times; i++) { \ + (val) = op(args); \ + if (cond) { \ + __cond = 1; \ + break; \ + } \ + usleep(__sleep_us);\ + } \ + (__cond) ? 0 : -1; \ +}) +#ifndef CL72_KRTR_PRBS_MODE_EN #define CL72_KRTR_PRBS_MODE_EN 0xFFFF/* open kr prbs check */ #endif
@@ -490,6 +510,8 @@ void txgbe_autoc_write(struct txgbe_hw *hw, u64 value);void txgbe_bp_mode_set (struct txgbe_hw *hw);void txgbe_set_phy_temp (struct txgbe_hw *hw);void txgbe_bp_down_event (struct txgbe_hw *hw); +int txgbe_is_dac_cable (struct txgbe_hw *hw); +int txgbe_xpcs_an_enabled (struct txgbe_hw *hw);s32 txgbe_kr_handle (struct txgbe_hw *hw);#endif /* _TXGBE_PHY_H_ */
drivers/net/txgbe/base/txgbe_type.h +24 -1
@@ -719,6 +719,7 @@ struct txgbe_phy_info {u32 addr;u32 id;enum txgbe_sfp_type sfp_type; +u32 fiber_suppport_speed;bool sfp_setup_needed;u32 revision;u32 media_type;
@@ -740,6 +741,7 @@ struct txgbe_phy_info {u16 ffe_pre2;u16 ffe_post;u16 fec_mode; +u16 bp_capa; };#define TXGBE_DEVARG_BP_AUTO "auto_neg"
@@ -899,7 +901,28 @@ struct txgbe_hw {u32 cur_fec_link;int temperature;u32 bp_link_mode; -}; +bool dac_sfp; +bool bypass_ctle; +u32 curbp_link_mode; +bool an_done;
Lines of this file are not shown. View the raw message.
drivers/net/txgbe/txgbe_ethdev.c +108 -1
109 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.0.windows.1
Part of the diff is not shown here. View the raw message.
PATCH v5 15/21 net/txgbe: fix FEC mode configuration on 25G NIC
In reply to Zaiyu WangThe 25G NIC offers off, RS, Base-R, and auto FEC modes. When reconfiguring the PHY, the FEC mode must match on both sides; otherwise, the link cannot come up. The current driver fails to maintain this requirement, causing link instability.
Add proper FEC mode handling during PHY reconfiguration to guarantee link establishment.
--- drivers/net/txgbe/base/txgbe_aml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_aml.c +12 -1
@@ -282,6 +282,14 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw, !(hw->fec_mode & hw->cur_fec_link))) goto out; +if (speed ==TXGBE_LINK_SPEED_25GB_FULL && + link_speed ==TXGBE_LINK_SPEED_25GB_FULL ) { +txgbe_e56_fec_polling (hw, &link_up); + +if (link_up) + goto out; + } +rte_spinlock_lock (&hw->phy_lock); ret_status =txgbe_set_link_to_amlite (hw, speed);rte_spinlock_unlock (&hw->phy_lock);
@@ -360,7 +368,10 @@ static s32 txgbe_setup_mac_link_multispeed_fiber_aml(struct txgbe_hw *hw,/* If we already have link at this speed, just jump out */ txgbe_e56_check_phy_link (hw, &link_speed, &link_up); -if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up) + hw->cur_fec_link =txgbe_phy_fec_get (hw); + +if (link_speed ==TXGBE_LINK_SPEED_25GB_FULL && link_up && + hw->fec_mode & hw->cur_fec_link) goto out;/* Allow module to change analog characteristics (10G -> 25G) */
Signature · 1 line
2.21.0.windows.1
PATCH v5 16/21 net/txgbe: fix SFP module identification
In reply to Zaiyu WangSome optical modules were not correctly recognized due to ambiguous classification in the original detection flow. Rework the module identification logic to cover all module types. Also narrow the I2C lock scope to avoid potential race conditions during module access.
--- drivers/net/txgbe/base/txgbe_hw.c | 2 - drivers/net/txgbe/base/txgbe_phy.c | 341 ++++++++++------------------ drivers/net/txgbe/base/txgbe_phy.h | 18 +- drivers/net/txgbe/base/txgbe_type.h | 2 + 4 files changed, 134 insertions(+), 229 deletions(-)
drivers/net/txgbe/base/txgbe_hw.c +0 -2
@@ -2909,8 +2909,6 @@ s32 txgbe_init_ops_generic(struct txgbe_hw *hw) phy->read_i2c_eeprom = txgbe_read_i2c_eeprom; phy->write_i2c_eeprom = txgbe_write_i2c_eeprom; 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; phy->set_link_hostif = txgbe_hic_ephy_set_link;
drivers/net/txgbe/base/txgbe_phy.c +119 -222
471 lines not on this page · raw message
drivers/net/txgbe/base/txgbe_phy.h +13 -5
@@ -261,7 +261,9 @@#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE0 0xA5#define TXGBE_SFF_QSFP_VENDOR_OUI_BYTE1 0xA6
@@ -289,6 +291,9 @@#define TXGBE_SFF_4x10GBASESR_CAP 0x11#define TXGBE_SFF_40GBASEPSM4_PARALLEL 0x12#define TXGBE_SFF_40GBASE_SWMD4_CAP 0x1f +#define TXGBE_SFF_COPPER_5M 0x5 +#define TXGBE_SFF_COPPER_3M 0x3 +#define TXGBE_SFF_COPPER_1M 0x1#define TXGBE_SFF_DA_SPEC_ACTIVE_LIMITING 0x4#define TXGBE_SFF_25GAUI_C2M_AOC_BER_5 0x1
@@ -296,6 +301,11 @@#define TXGBE_SFF_25GAUI_C2M_AOC_BER_12 0x18#define TXGBE_SFF_25GAUI_C2M_ACC_BER_12 0x19 +#define TXGBE_ETHERNET_COMP_OFFSET 0x83 +#define TXGBE_SFF_ETHERNET_40G_CR4 MS(3, 0x1) +#define TXGBE_SFF_ETHERNET_40G_SR4 MS(2, 0x1) +#define TXGBE_SFF_ETHERNET_40G_LR4 MS(1, 0x1) +#define TXGBE_SFF_SOFT_RS_SELECT_MASK 0x8#define TXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define TXGBE_SFF_SOFT_RS_SELECT_1G 0x0
@@ -493,14 +503,12 @@ 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, -u8 dev_addr,u8 *data);s32 txgbe_write_i2c_byte (struct txgbe_hw *hw,u8 byte_offset,u8 dev_addr,u8 data); -s32 txgbe_write_i2c_byte_unlocked (struct txgbe_hw *hw,u8 byte_offset, -u8 dev_addr,u8 data);s32 txgbe_read_i2c_sff8472 (struct txgbe_hw *hw,u8 byte_offset, -u8 *sff8472_data); +u8 *sff8472_data); +s32 txgbe_read_i2c_sff8636 (struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 txgbe_read_i2c_eeprom (struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 txgbe_write_i2c_eeprom(struct txgbe_hw *hw, u8 byte_offset,
drivers/net/txgbe/base/txgbe_type.h +2 -0
@@ -702,6 +702,8 @@ struct txgbe_phy_info { u8 dev_addr, u8 data);s32 (*read_i2c_sff8472)(struct txgbe_hw *hw,u8 byte_offset,u8 *sff8472_data); +s32 (*read_i2c_sff8636)(struct txgbe_hw *hw,u8 page,u8 byte_offset, +u8 *sff8636_data);s32 (*read_i2c_eeprom)(struct txgbe_hw *hw,u8 byte_offset,u8 *eeprom_data); s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
Signature · 1 line
2.21.0.windows.1
PATCH v5 17/21 net/txgbe: fix get module info operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/base/txgbe_phy.h | 6 +- drivers/net/txgbe/txgbe_ethdev.c | 118 +++++++++++++++++++++++------ 2 files changed, 98 insertions(+), 26 deletions(-)
drivers/net/txgbe/base/txgbe_phy.h +5 -1
@@ -257,11 +257,15 @@#define TXGBE_SFF_CABLE_DA_PASSIVE 0x4#define TXGBE_SFF_CABLE_DA_ACTIVE 0x8#define TXGBE_SFF_CABLE_SPEC_COMP 0x3C +#define TXGBE_SFF_DDM_IMPLEMENTED 0x40#define TXGBE_SFF_SFF_8472_SWAP 0x5C#define TXGBE_SFF_SFF_8472_COMP 0x5E#define TXGBE_SFF_SFF_8472_OSCB 0x6E#define TXGBE_SFF_SFF_8472_ESCB 0x76 -#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F +#define TXGBE_SFF_SFF_REVISION_ADDR 0x01 +#define TXGBE_SFF_QSFP_PAGE_SELECT 0x7F + +#define TXGBE_MODULE_QSFP_MAX_LEN 640#define TXGBE_SFF_IDENTIFIER_QSFP 0x0C#define TXGBE_SFF_IDENTIFIER_QSFP_PLUS 0x0D
drivers/net/txgbe/txgbe_ethdev.c +93 -25
134 lines not on this page · raw message
Signature · 1 line
2.21.0.windows.1
PATCH v5 18/21 net/txgbe: fix get EEPROM operation
In reply to Zaiyu WangThe original I2C access flow in the module information retrieval process was flawed. Correct the implementation to properly fetch module info.
--- drivers/net/txgbe/txgbe_ethdev.c | 67 ++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +60 -7
@@ -5462,23 +5462,76 @@ txgbe_get_module_eeprom(struct rte_eth_dev *dev,uint8_t databyte =0xFF ;uint8_t *data = info->data;uint32_t i =0 ; +bool is_sfp = false; +uint32_t value; +uint8_t identifier =0 ; +uint16_t offset; +uint8_t page =0 ; + +if (hw->mac.type == txgbe_mac_aml40) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_PRST_LS ) +return -EIO ; + } + +if (hw->mac.type == txgbe_mac_aml) { + value =rd32 (hw,TXGBE_GPIOEXT ); +if (value &TXGBE_SFP1_MOD_ABS_LS ) +return -EIO ; + }if (info->length ==0 )return -EINVAL ; -for (i = info->offset; i < info->offset + info->length; i++) { -if (i <RTE_ETH_MODULE_SFF_8079_LEN ) - status = hw->phy.read_i2c_eeprom (hw, i, &databyte); -else - status = hw->phy.read_i2c_sff8472 (hw, i, &databyte); + status = hw->mac.acquire_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +if (status) +return -EBUSY ; -if (status !=0 ) -return -EIO ; + status = hw->phy.read_i2c_eeprom (hw, +TXGBE_SFF_IDENTIFIER , + &identifier); +if (status !=0 ) + goto ERROR_IO; + +if (identifier ==TXGBE_SFF_IDENTIFIER_SFP ) + is_sfp = true; +memset (data,0 , info->length); + +for (i = info->offset; i < info->offset + info->length; i++) { +if (is_sfp) { +if (i <RTE_ETH_MODULE_SFF_8079_LEN ) + status = hw->phy.read_i2c_eeprom (hw, i, + &databyte); +else + status = hw->phy.read_i2c_sff8472 (hw, i, + &databyte); + +if (status !=0 ) + goto ERROR_IO; + }else { + offset = i; +while (offset >=RTE_ETH_MODULE_SFF_8436_LEN ) { + offset -=RTE_ETH_MODULE_SFF_8436_LEN /2 ; + page++; + } +if (page ==0 || !(data[0x2 ] &0x4 )) { + status = hw->phy.read_i2c_sff8636 (hw, page, offset, + &databyte); +if (status !=0 ) + goto ERROR_IO; + } + } data[i - info->offset] = databyte; } + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY );return 0 ; + +ERROR_IO: +PMD_DRV_LOG (ERR ,"I2C IO ERROR." ); + hw->mac.release_swfw_sync (hw,TXGBE_MNGSEM_SWPHY ); +return -EIO ; }bool
Signature · 1 line
2.21.0.windows.1
PATCH v5 19/21 net/txgbe: fix to reset Tx write-back pointer
In reply to Zaiyu WangThe write-back pointer was not reset when the Tx queue was reset. This leads to the wrong Tx desc free logic. Move the resetting of pointer into txq->ops->reset(txq).
--- drivers/net/txgbe/txgbe_rxtx.c | 45 +++++++++++++---------- drivers/net/txgbe/txgbe_rxtx.h | 1 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 7 ++++ 3 files changed, 33 insertions(+), 20 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +25 -20
@@ -2311,6 +2311,12 @@ txgbe_reset_tx_queue(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
@@ -2410,7 +2416,7 @@ txgbe_get_tx_port_offloads(struct rte_eth_dev *dev)return tx_offload_capa; } -static int +static void txgbe_setup_headwb_resources (struct rte_eth_dev *dev,void *tx_queue,unsigned int socket_id)
@@ -2418,33 +2424,33 @@ txgbe_setup_headwb_resources(struct rte_eth_dev *dev,struct txgbe_hw *hw =TXGBE_DEV_HW (dev);const struct rte_memzone *headwb;struct txgbe_tx_queue *txq = tx_queue; -u8 i, headwb_size =0 ; +u8 headwb_size =0 ; -if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) { - txq->headwb_mem =NULL ; -return 0 ; - } +if (hw->mac.type != txgbe_mac_aml && hw->mac.type != txgbe_mac_aml40) + goto out; + +if (!hw->devarg.tx_headwb) + goto out; - headwb_size = hw->devarg.tx_headwb_size; + headwb_size = txq->headwb_size; headwb =rte_eth_dma_zone_reserve (dev,"tx_headwb_mem" , txq->queue_id,sizeof (u32) * headwb_size,TXGBE_ALIGN , socket_id);if (headwb ==NULL ) { -DEBUGOUT ("Fail to setup headwb resources: no mem" ); -txgbe_tx_queue_release (txq); -return -ENOMEM ; +PMD_DRV_LOG (INFO , +"Failed to allocate headwb memory for Tx queue %u, change to SP mode" , + txq->queue_id); + goto out; } txq->headwb = headwb; txq->headwb_dma =TMZ_PADDR (headwb); txq->headwb_mem = (uint32_t *)TMZ_VADDR (headwb); +return ; -/* Zero out headwb_mem memory */ -for (i =0 ; i < headwb_size; i++) - txq->headwb_mem[i] =0 ; - -return 0 ; +out: + txq->headwb_mem =NULL ; }int __rte_cold
@@ -2540,6 +2546,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->offloads = offloads; txq->ops = &def_txq_ops; txq->tx_deferred_start = tx_conf->tx_deferred_start; + txq->headwb_size = hw->devarg.tx_headwb_size;#ifdef RTE_LIB_SECURITY txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY );
@@ -2575,8 +2582,7 @@ txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,/* set up scalar TX function as appropriate */ txgbe_set_tx_function (dev, txq); -if (hw->devarg.tx_headwb) - err =txgbe_setup_headwb_resources (dev, txq, socket_id); +txgbe_setup_headwb_resources (dev, txq, socket_id); txq->ops->reset (txq); txq->desc_error =0 ;
@@ -4753,15 +4759,14 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); -if ((hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) && - hw->devarg.tx_headwb) { +if (txq->headwb_mem) {uint32_t txdctl;wr32 (hw,TXGBE_PX_TR_HEAD_ADDRL (txq->reg_idx), (uint32_t )(txq->headwb_dma &BIT_MASK32 ));wr32 (hw,TXGBE_PX_TR_HEAD_ADDRH (txq->reg_idx), (uint32_t )(txq->headwb_dma >>32 )); -if (hw->devarg.tx_headwb_size ==16 ) +if (txq->headwb_size ==16 ) txdctl =TXGBE_PX_TR_CFG_HEAD_WB |TXGBE_PX_TR_CFG_HEAD_WB_64BYTE ;else
drivers/net/txgbe/txgbe_rxtx.h +1 -0
@@ -416,6 +416,7 @@ struct txgbe_tx_queue {uint64_t desc_error;bool resetting;const struct rte_memzone *headwb; +uint16_t headwb_size;uint64_t headwb_dma;volatile uint32_t *headwb_mem; };
drivers/net/txgbe/txgbe_rxtx_vec_common.h +7 -0
@@ -251,6 +251,13 @@ _txgbe_reset_tx_queue_vec(struct txgbe_tx_queue *txq) txq->tx_next_dd = (uint16_t )(txq->tx_free_thresh -1 ); txq->tx_tail =0 ; + +/* Zero out headwb_mem memory */ +if (txq->headwb_mem) { +for (i =0 ; i < txq->headwb_size; i++) + txq->headwb_mem[i] =0 ; + } +/* * Always allow 1 descriptor to be un-allocated to avoid * a H/W race condition
Signature · 1 line
2.21.0.windows.1
PATCH v5 20/21 net/txgbe: fix to enable Tx desc check
In reply to Zaiyu WangNow lib security is enabled by default, and cannot be disabled if the driver is intended to be used. So Tdm_desc_chk is always unable to enable. Remove this restriction, and just enable the corresponding queue check.
--- drivers/net/txgbe/txgbe_rxtx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/txgbe/txgbe_rxtx.c +6 -5
@@ -4759,6 +4759,12 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev)wr32 (hw,TXGBE_TXRP (txq->reg_idx),0 );wr32 (hw,TXGBE_TXWP (txq->reg_idx),0 ); +#ifdef RTE_LIBRTE_SECURITY + if (!txq->using_ipsec) +#endif +wr32m (hw,TXGBE_TDM_DESC_CHK (txq->reg_idx /32 ), +RTE_BIT32 (txq->reg_idx %32 ),RTE_BIT32 (txq->reg_idx %32 )); +if (txq->headwb_mem) {uint32_t txdctl;
@@ -4776,11 +4782,6 @@ txgbe_dev_tx_init(struct rte_eth_dev *dev) } } -#ifndef RTE_LIB_SECURITY -for (i =0 ; i <4 ; i++) -wr32 (hw,TXGBE_TDM_DESC_CHK (i),0xFFFFFFFF ); -#endif -/* Device configured with multiple TX queues. */ txgbe_dev_mq_tx_configure (dev); }
Signature · 1 line
2.21.0.windows.1
PATCH v5 21/21 net/txgbe: fix temperature track for AML NIC
In reply to Zaiyu WangPreviously, temperature tracking for the amlite NIC was handled by firmware together with the hardware setup. However, the firmware-based PHY configuration has proven to be unstable.
Re-add the temperature tracking function directly in the driver and invoke it periodically to ensure the PHY remains calibrated. According to the hardware recommendation, the tracking sequence should be run at least every 100 ms to keep temperature drift within 5 °C. Considering the software and hardware overhead, a 2-second interval is used as a practical trade-off that still meets stability requirements while minimizing performance impact.
The periodic tracking is implemented using a timer in the driver, and the sequence itself is the same as the one originally performed during link setup.
--- drivers/net/txgbe/txgbe_ethdev.c | 44 +++++++++++++++++++++++++++++++- drivers/net/txgbe/txgbe_ethdev.h | 1 + 2 files changed, 44 insertions(+), 1 deletion(-)
drivers/net/txgbe/txgbe_ethdev.c +43 -1
@@ -2011,8 +2011,10 @@ txgbe_dev_start(struct rte_eth_dev *dev)txgbe_filter_restore (dev); hw->bp_event_interval =100 *1000 ; -if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) +if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {rte_eal_alarm_set (hw->bp_event_interval, txgbe_dev_e56_check_bp_event, dev); +rte_eal_alarm_set (1000 *1000 *2 , txgbe_dev_check_aml_temp_event, dev); + }if (tm_conf->root && !tm_conf->committed) PMD_DRV_LOG(WARNING,
@@ -2060,6 +2062,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40) {rte_eal_alarm_cancel (txgbe_dev_e56_check_bp_event, dev); +rte_eal_alarm_cancel (txgbe_dev_check_aml_temp_event, dev);rte_eal_alarm_cancel (txgbe_dev_setup_link_alarm_handler_aml, hw); }
@@ -2932,6 +2935,45 @@ txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)return NULL ; } +void txgbe_dev_check_aml_temp_event (void *param) +{ +struct rte_eth_dev *dev = (struct rte_eth_dev *)param; +struct txgbe_hw *hw =TXGBE_DEV_HW (dev); +uint32_t link_speed =0 , val =0 ; +s32 status =0 ; +int temp; + +if (hw ==NULL ) +return ; + + status =txgbe_e56_get_temp (hw, &temp); +if (status) + temp =DEFAULT_TEMP ; + +if (!(temp - hw->temperature >4 || + hw->temperature - temp >4 )) + goto out; + + hw->temperature = temp; + val =rd32 (hw,TXGBE_PORT ); +if (val &TXGBE_AMLITE_LED_LINK_40G ) + link_speed =TXGBE_LINK_SPEED_40GB_FULL ; +else if (val &TXGBE_AMLITE_LED_LINK_25G ) + link_speed =TXGBE_LINK_SPEED_25GB_FULL ; +else + link_speed =TXGBE_LINK_SPEED_10GB_FULL ; + +rte_spinlock_lock (&hw->phy_lock); +if (hw->mac.type == txgbe_mac_aml) +txgbe_temp_track_seq (hw, link_speed); +else if (hw->mac.type == txgbe_mac_aml40) +txgbe_temp_track_seq_40g (hw, link_speed); +rte_spinlock_unlock (&hw->phy_lock); + +out: +rte_eal_alarm_set (1000 *1000 *2 , txgbe_dev_check_aml_temp_event, dev); +} +void txgbe_dev_e56_check_bp_event (void *param) {struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
drivers/net/txgbe/txgbe_ethdev.h +1 -0
@@ -747,5 +747,6 @@ void txgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on);void txgbe_config_vlan_strip_on_all_queues (struct rte_eth_dev *dev,int mask); +void txgbe_dev_check_aml_temp_event (void *param);void txgbe_dev_e56_check_bp_event (void *param);#endif /* _TXGBE_ETHDEV_H_ */
Signature · 1 line
2.21.0.windows.1
Quoted 62 lines · On Wed, 27 May 2026 21:02:00 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v5:
- Fixed issues identified by AI review
---
v4:
- Fixed issues identified by devtools scripts
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---Zaiyu Wang (21):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in Tx rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get EEPROM operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
net/txgbe: fix temperature track for AML NICdrivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 185 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 114 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3773 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1753 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 282 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 362 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 13 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 458 ++- drivers/net/txgbe/txgbe_ethdev.h | 7 +-
Quoted 9 lines
drivers/net/txgbe/txgbe_rxtx.c | 107 +- drivers/net/txgbe/txgbe_rxtx.h | 36 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 16 +- 26 files changed, 9445 insertions(+), 445 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
More AI review feedback summary:
18/21 — get EEPROM (Error): page is declared once before the for loop and never reset, so after crossing the 256-byte boundary every subsequent iteration walks one page further into the module than it should. Plus two related issues: data[0x2] reads the output buffer not the module byte, and the skip branch leaves stale databyte carrying over from the previous iteration.
20/21 — Tx desc check (Error): #ifdef RTE_LIBRTE_SECURITY uses the pre-2020 macro name; the modern name is RTE_LIB_SECURITY (and the surrounding code in the same file uses it correctly). The IPsec guard is therefore always compiled out and the wr32m runs for every queue, including IPsec ones.
16/21 & 17/21 — whitespace: \t if (tab-then-space) on two lines. Checkpatch will catch it, but worth a pass.
17/21 — TXGBE_SFF_DDM_IMPLEMENTED: value 0x40 is correct as a bit-6 mask of byte 0x5C, but it is defined next to register-offset macros which makes it read as an offset.
14/21 — kr_read_poll macro: uses usleep() directly; everything else in the txgbe base layer uses usec_delay().
7/21 — type pun: the atomic load casts a volatile uint32_t * to volatile uint16_t *. Works on all DPDK platforms but is strict-aliasing-iffy; a u32 load with a u16 cast at the use site would be cleaner.
Longer full review:
Review of [PATCH v5 00/21] net/{txgbe,ngbe} fixes from Zaiyu Wang
This revision addresses the substantive issues raised on v4:
- 07/21: Tx desc free now uses a documented helper txgbe_tx_headwb_desc_done() that correctly handles the head==next boundary, and switches the headwb_mem read from a plain volatile access to rte_atomic_load_explicit(... acquire).
- 08/21: AML xon/xoff stats no longer use plain assignment. The counter now goes through the new TXGBE_UPDATE_COUNTER_32BIT_GENERIC macro with offset tracking, and txgbe_clear_hw_cntrs() write-clears the AML registers and zeroes hw->last_stats on reset.
- 11/21: traffic class priority is consistent across all three callers. TXGBE_RPUP2TC_UP_SHIFT is bumped to 4, TXGBE_DCBUP2TC_MAP is updated to match, txgbe_vmdq_dcb_configure() uses the macros instead of a hardcoded *3 shift, and the unused TXGBE_DCBUP2TC_DEC is removed. The bonus fix of redirecting txgbe_dcb_config_tx_data_arbiter_raptor() to TXGBE_PBTXUP2TC instead of TXGBE_PBRXUP2TC is welcome.
- 12/21: txgbe_setup_phy_link_aml() now sets link_up = false before 'goto out' on TXGBE_ERR_TIMEOUT, so the out: block correctly routes to *need_reset = true. The generic 'compare' qsort helper has been renamed to txgbe_e56_int_cmp().
Remaining findings on v5 below.
----------------------------------------------------------------
Patch 18/21 (net/txgbe: fix get EEPROM operation)
Error: page accumulation across loop iterations in txgbe_get_module_eeprom() will return wrong bytes for any QSFP read that crosses the 256-byte page boundary.
+ uint8_t page = 0;
...
+ for (i = info->offset; i < info->offset + info->length; i++) {
+ if (is_sfp) {
...
+ } else {
+ offset = i;
+ while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) {
+ offset -= RTE_ETH_MODULE_SFF_8436_LEN / 2;
+ page++;
+ }
+ if (page == 0 || !(data[0x2] & 0x4)) {
+ status = hw->phy.read_i2c_sff8636(hw, page, offset,
+ &databyte);'page' is declared once before the for loop and never reset, but the while loop only increments it. For i = 256 the math is correct (page=0 entering, page=1 leaving, offset=128). For i = 257 the loop enters with page=1 already set from the previous iteration and ends with page=2, offset=129 - it should still be page=1. Every subsequent iteration adds one more page, so the function reads bytes from ever-higher pages instead of staying on page 1, 2, 3, ...
Reset page (and rebuild offset) at each iteration:
uint16_t addr;
uint8_t page;
for (i = info->offset; i < info->offset + info->length; i++) {
...
} else {
page = 0;
addr = i;
while (addr >= RTE_ETH_MODULE_SFF_8436_LEN) {
addr -= RTE_ETH_MODULE_SFF_8436_LEN / 2;
page++;
}
...
}
}Two related concerns in the same block:
- The flat-memory check '!(data[0x2] & 0x4)' inspects byte 2 of the caller's output buffer rather than module byte 2. If info->offset > 2 the byte was never read, so the test reads the value left by memset (zero) and always evaluates to true. Read module byte 2 explicitly before the loop and stash it in a local.
- When the skip branch is taken (paged read on flat memory), the loop still does 'data[i - info->offset] = databyte', so the byte written is whatever databyte held from the previous iteration. Set databyte to 0 (or 0xff) before each iteration, or set the output byte directly inside the skip branch.
Patch 20/21 (net/txgbe: fix to enable Tx desc check)
Error: the new IPsec guard uses the wrong macro name and is always compiled out.
+#ifdef RTE_LIBRTE_SECURITY
+ if (!txq->using_ipsec)
+#endif
+ wr32m(hw, TXGBE_TDM_DESC_CHK(txq->reg_idx / 32),
+ RTE_BIT32(txq->reg_idx % 32), RTE_BIT32(txq->reg_idx % 32));
The DPDK build macro is RTE_LIB_SECURITY; RTE_LIBRTE_SECURITY is the pre-2020 name and is no longer defined anywhere in the tree (the rest of this same driver uses RTE_LIB_SECURITY in the surrounding code, including the deleted block this patch replaces). Result: the 'if (!txq->using_ipsec)' line is never preprocessed in, the wr32m runs for every queue unconditionally, and IPsec-enabled queues get the desc-check bit set even though the existing intent was to skip them.
Replace with RTE_LIB_SECURITY. Matches the existing pattern elsewhere in txgbe_rxtx.c (txgbe_rxtx.c:64, :444, :882, ...).
Patch 16/21 (net/txgbe: fix SFP module identification)
Warning: stray space in indentation of txgbe_read_i2c_sff8636() body.
+ s32 err = hw->phy.write_i2c_byte(hw, TXGBE_SFF_QSFP_PAGE_SELECT,
+ TXGBE_I2C_EEPROM_DEV_ADDR,
+ page);
+ if (err != 0)
+ return err;
The 'if' line is indented with tab+space instead of a single tab. checkpatch will flag this.
Info: this patch refactors away phy.read_i2c_byte_unlocked and phy.write_i2c_byte_unlocked and merges them into the existing phy.read_i2c_byte / phy.write_i2c_byte slots, which now no longer acquire the swfw semaphore. Patches 17 and 18 add explicit acquire/release around their own callers, which is correct, but it is worth double-checking that no other in-tree caller of phy.read_i2c_eeprom / phy.read_i2c_sff8472 / phy.read_i2c_byte runs without holding TXGBE_MNGSEM_SWPHY after this patch. The lock change and the callsite updates would arguably read better squashed together or at least kept adjacent in the series.
Patch 17/21 (net/txgbe: fix get module info operation)
Warning: stray space in indentation - same checkpatch issue as above.
+ if (hw->mac.type == txgbe_mac_aml) {
+ value = rd32(hw, TXGBE_GPIOEXT);
+ if (value & TXGBE_SFP1_MOD_ABS_LS) {'if' is tab+space indented; should be two tabs.
Info: TXGBE_SFF_DDM_IMPLEMENTED is added next to the SFP register offset definitions, but is then used as a bit mask of byte 0x5C:
#define TXGBE_SFF_DDM_IMPLEMENTED 0x40
#define TXGBE_SFF_SFF_8472_SWAP 0x5C
...
if (sff8472_rev == TXGBE_SFF_SFF_8472_UNSUP || page_swap ||
!(addr_mode & TXGBE_SFF_DDM_IMPLEMENTED)) {The value 0x40 is correct as bit 6 of the diagnostic-monitoring-type byte at offset 0x5C, but placing it alongside register offsets makes the macro look like an offset. Consider moving it into a bit-mask group or renaming the offset/mask pair to make the intent obvious (e.g. _ADDR vs _MASK suffix).
Patch 14/21 (net/txgbe: fix link stability for Amber-Lite)
Warning: the new kr_read_poll() macro in txgbe_phy.h uses usleep() directly, while the rest of the txgbe base layer uses the usec_delay() abstraction (which expands to rte_delay_us_block() on DPDK). Mixing the two is inconsistent and pulls in a POSIX dependency in a base/ file:
+#define kr_read_poll(op, val, cond, sleep_us, \
+ times, args...) \
+({ \
...
+ usleep(__sleep_us);\
...
+})Switch to usec_delay() to match txgbe_eeprom.c, txgbe_hw.c, and the rest of the same file.
Patch 7/21 (net/txgbe: fix Tx desc free logic)
Info: txq->headwb_mem is declared 'volatile uint32_t *', but the new atomic read reads it as 'volatile uint16_t *':
+ const uint16_t head = rte_atomic_load_explicit((volatile uint16_t *)txq->headwb_mem,
+ rte_memory_order_acquire);
This works on every architecture DPDK supports (lower 16 bits of an aligned 32-bit object are accessible as a 16-bit atomic and head fits in 16 bits), but it is a type pun on a hardware-written object and a strict-aliasing violation in pure C. A 32-bit atomic load with an explicit cast at use site would be cleaner:
uint32_t h = rte_atomic_load_explicit(txq->headwb_mem, rte_memory_order_acquire); const uint16_t head = (uint16_t)h;
Stephen Hemminger <[email protected]>
Quoted 295 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, May 27, 2026 11:22 PM
To: Zaiyu Wang <[email protected]>; Zaiyu Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v5 00/21] Wangxun FixesQuoted 62 lines · On Wed, 27 May 2026 21:02:00 +0800 Zaiyu Wang <[email protected]> wrote:
This series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v5:
- Fixed issues identified by AI review
---
v4:
- Fixed issues identified by devtools scripts
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---Zaiyu Wang (21):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in Tx rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get EEPROM operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
net/txgbe: fix temperature track for AML NICdrivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 185 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 114 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3773 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1753 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 282 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 362 +- drivers/net/txgbe/base/txgbe_phy.h | 45 +- drivers/net/txgbe/base/txgbe_regs.h | 13 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 458 ++- drivers/net/txgbe/txgbe_ethdev.h | 7 +-Quoted 9 lines
drivers/net/txgbe/txgbe_rxtx.c | 107 +- drivers/net/txgbe/txgbe_rxtx.h | 36 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 16 +- 26 files changed, 9445 insertions(+), 445 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.hMore AI review feedback summary:
18/21 — get EEPROM (Error): page is declared once before the for loop and never reset, so after crossing the 256-byte boundary every subsequent iteration walks one page further into the module than it should. Plus two related issues: data[0x2] reads the output buffer not the module byte, and the skip branch leaves stale databyte carrying over from the previous iteration.
20/21 — Tx desc check (Error): #ifdef
RTE_LIBRTE_SECURITYuses the
pre-2020 macro name; the modern name isRTE_LIB_SECURITY(and the surrounding code in the same file uses it correctly). The IPsec guard is therefore always compiled out and the wr32m runs for every queue, including IPsec ones.16/21 & 17/21 — whitespace: \t if (tab-then-space) on two lines. Checkpatch will catch it, but worth a pass.
17/21 —
TXGBE_SFF_DDM_IMPLEMENTED: value0x40is correct as a bit-6 mask of byte0x5C, but it is defined next to register-offset macros which makes it read as an offset.14/21 —
kr_read_pollmacro: usesusleep()directly; everything else in the txgbe base layer usesusec_delay().7/21 — type pun: the atomic load casts a volatile
uint32_t* to volatileuint16_t*. Works on all DPDK platforms but is strict-aliasing-iffy; a u32 load with a u16 cast at the use site would be cleaner.Longer full review:
Review of [PATCH v5 00/21] net/{txgbe,ngbe} fixes from Zaiyu Wang
This revision addresses the substantive issues raised on v4:
- 07/21: Tx desc free now uses a documented helper
txgbe_tx_headwb_desc_done()that correctly handles the head==next boundary, and switches theheadwb_memread from a plain volatile access to rte_atomic_load_explicit(... acquire).
- 08/21: AML xon/xoff stats no longer use plain assignment. The counter now goes through the newTXGBE_UPDATE_COUNTER_32BIT_GENERICmacro with offset tracking, andtxgbe_clear_hw_cntrs()write-clears the AML registers and zeroeshw->last_statson reset.
- 11/21: traffic class priority is consistent across all three callers.TXGBE_RPUP2TC_UP_SHIFTis bumped to 4,TXGBE_DCBUP2TC_MAPis updated to match,txgbe_vmdq_dcb_configure()uses the macros instead of a hardcoded *3 shift, and the unusedTXGBE_DCBUP2TC_DECis removed. The bonus fix of redirectingtxgbe_dcb_config_tx_data_arbiter_raptor()toTXGBE_PBTXUP2TCinstead ofTXGBE_PBRXUP2TCis welcome.
- 12/21:txgbe_setup_phy_link_aml()now setslink_up= false before 'goto out' onTXGBE_ERR_TIMEOUT, so the out: block correctly routes to*need_reset= true. The generic 'compare' qsort helper has been renamed totxgbe_e56_int_cmp().Remaining findings on v5 below.
----------------------------------------------------------------
Patch 18/21 (net/txgbe: fix get EEPROM operation)
Error: page accumulation across loop iterations in
txgbe_get_module_eeprom()will return wrong bytes for any QSFP read that crosses the 256-byte page boundary.+ uint8_t page = 0; ... + for (i = info->offset; i < info->offset + info->length; i++) { + if (is_sfp) { ... + } else { + offset = i; + while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) { + offset -= RTE_ETH_MODULE_SFF_8436_LEN / 2; + page++; + } + if (page == 0 || !(data[0x2] & 0x4)) { + status = hw->phy.read_i2c_sff8636(hw, page, offset, + &databyte);'page' is declared once before the for loop and never reset, but the while loop only increments it. For i = 256 the math is correct
(page=0 entering, page=1 leaving, offset=128). For i = 257 the loop enters with page=1 already set from the previous iteration and ends with page=2, offset=129 - it should still be page=1. Every subsequent iteration adds one more page, so the function reads bytes from ever-higher pages instead of staying on page 1, 2, 3, ...Reset page (and rebuild offset) at each iteration:
uint16_t addr; uint8_t page; for (i = info->offset; i < info->offset + info->length; i++) { ... } else { page = 0; addr = i; while (addr >= RTE_ETH_MODULE_SFF_8436_LEN) { addr -= RTE_ETH_MODULE_SFF_8436_LEN / 2; page++; } ... } }Two related concerns in the same block:
- The flat-memory check '!(data[0x2] &
0x4)' inspects byte 2 of the caller's output buffer rather than module byte 2. Ifinfo->offset> 2 the byte was never read, so the test reads the value left by memset (zero) and always evaluates to true. Read module byte 2 explicitly before the loop and stash it in a local.- When the skip branch is taken (paged read on flat memory), the loop still does 'data[i -
info->offset] = databyte', so the byte written is whatever databyte held from the previous iteration. Set databyte to 0 (or0xff) before each iteration, or set the output byte directly inside the skip branch.Patch 20/21 (net/txgbe: fix to enable Tx desc check)
Error: the new IPsec guard uses the wrong macro name and is always compiled out.
+#ifdef
RTE_LIBRTE_SECURITY
+ if (!txq->using_ipsec)
+#endif
+ wr32m(hw,TXGBE_TDM_DESC_CHK(txq->reg_idx / 32),
+RTE_BIT32(txq->reg_idx % 32),RTE_BIT32(txq->reg_idx % 32));The DPDK build macro is
RTE_LIB_SECURITY;RTE_LIBRTE_SECURITYis the
pre-2020 name and is no longer defined anywhere in the tree (the rest of this same driver usesRTE_LIB_SECURITYin the surrounding code, including the deleted block this patch replaces).
Result: the 'if (!txq->using_ipsec)' line is never preprocessed in, the wr32m runs for every queue unconditionally, and IPsec-enabled queues get the desc-check bit set even though the existing intent was to skip them.Replace with
RTE_LIB_SECURITY. Matches the existing pattern elsewhere intxgbe_rxtx.c(txgbe_rxtx.c:64, :444, :882, ...).Patch 16/21 (net/txgbe: fix SFP module identification)
Warning: stray space in indentation of
txgbe_read_i2c_sff8636()body.+ s32 err = hw->phy.write_i2c_byte(hw,
TXGBE_SFF_QSFP_PAGE_SELECT,
+TXGBE_I2C_EEPROM_DEV_ADDR,
+ page);
+ if (err != 0)
+ return err;The 'if' line is indented with tab+space instead of a single tab. checkpatch will flag this.
Info: this patch refactors away phy.read_i2c_byte_unlocked and phy.write_i2c_byte_unlocked and merges them into the existing phy.read_i2c_byte / phy.write_i2c_byte slots, which now no longer acquire the swfw semaphore. Patches 17 and 18 add explicit acquire/release around their own callers, which is correct, but it is worth double-checking that no other in-tree caller of phy.read_i2c_eeprom / phy.read_i2c_sff8472 / phy.read_i2c_byte runs without holding
TXGBE_MNGSEM_SWPHYafter this patch. The lock change and the callsite updates would arguably read better squashed together or at least kept adjacent in the series.Patch 17/21 (net/txgbe: fix get module info operation)
Warning: stray space in indentation - same checkpatch issue as above.
+ if (hw->mac.type == txgbe_mac_aml) { + value = rd32(hw, TXGBE_GPIOEXT); + if (value & TXGBE_SFP1_MOD_ABS_LS) {'if' is tab+space indented; should be two tabs.
Info:
TXGBE_SFF_DDM_IMPLEMENTEDis added next to the SFP register offset definitions, but is then used as a bit mask of byte0x5C:#define TXGBE_SFF_DDM_IMPLEMENTED 0x40 #define TXGBE_SFF_SFF_8472_SWAP 0x5C ... if (sff8472_rev == TXGBE_SFF_SFF_8472_UNSUP || page_swap || !(addr_mode & TXGBE_SFF_DDM_IMPLEMENTED)) {The value
0x40is correct as bit 6 of the diagnostic-monitoring-type byte at offset0x5C, but placing it alongside register offsets makes the macro look like an offset. Consider moving it into a bit-mask group or renaming the offset/mask pair to make the intent obvious (e.g._ADDRvs_MASKsuffix).Patch 14/21 (net/txgbe: fix link stability for Amber-Lite)
Warning: the new
kr_read_poll()macro intxgbe_phy.husesusleep()directly, while the rest of the txgbe base layer uses theusec_delay()abstraction (which expands torte_delay_us_block()on DPDK). Mixing the two is inconsistent and pulls in a POSIX dependency in a base/ file:+#define kr_read_poll(op, val, cond, sleep_us, \ + times, args...) \ +({ \ ... + usleep(__sleep_us);\ ... +})Switch to
usec_delay()to matchtxgbe_eeprom.c,txgbe_hw.c, and the rest of the same file.Patch 7/21 (net/txgbe: fix Tx desc free logic)
Info:
txq->headwb_memis declared 'volatileuint32_t*', but the new atomic read reads it as 'volatileuint16_t*':+ const
uint16_thead = rte_atomic_load_explicit((volatileuint16_t*)txq->headwb_mem,
+rte_memory_order_acquire);This works on every architecture DPDK supports (lower 16 bits of an aligned 32-bit object are accessible as a 16-bit atomic and head fits in 16 bits), but it is a type pun on a hardware-written object and a strict-aliasing violation in pure C. A 32-bit atomic load with an explicit cast at use site would be cleaner:
Quoted 7 lines
uint32_t h = rte_atomic_load_explicit(txq->headwb_mem, rte_memory_order_acquire); const uint16_t head = (uint16_t)h;Stephen Hemminger <[email protected]>
Thanks.
All the comments above have been addressed in v6.
v6 cover Wangxun Fixes
In reply to Zaiyu WangThis series fixes several issues found on Wangxun Emerald, Sapphire and Amber-lite NICs, with a focus on link-related problems.
---
v6:
- Fixed more issues identified by AI review
---
v5:
- Fixed issues identified by AI review
---
v4:
- Fixed issues identified by devtools scripts
---
v3:
- Addressed Stephen's comments
---
v2:
- Fixed compilation error and code style issues
---
Zaiyu Wang (21):
net/txgbe: remove duplicate xstats counters net/ngbe: remove duplicate xstats counters net/ngbe: add missing CDR config for YT PHY net/ngbe: fix VF promiscuous and allmulticast net/txgbe: fix inaccuracy in Tx rate limiting net/txgbe: fix link status check condition net/txgbe: fix Tx desc free logic
net/txgbe: fix link flow control registers for Amber-Lite net/txgbe: fix link flow control config for Sapphire net/txgbe: fix a mass of unknown interrupts net/txgbe: fix traffic class priority configuration net/txgbe: fix link stability for 25G NIC net/txgbe: fix link stability for 40G NIC net/txgbe: fix link stability for Amber-Lite backplane mode net/txgbe: fix FEC mode configuration on 25G NIC net/txgbe: fix SFP module identification net/txgbe: fix get module info operation net/txgbe: fix get EEPROM operation
net/txgbe: fix to reset Tx write-back pointer net/txgbe: fix to enable Tx desc check
net/txgbe: fix temperature track for AML NIC
drivers/net/ngbe/base/ngbe_phy_yt.c | 3 + drivers/net/ngbe/ngbe_ethdev.c | 5 - drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +- drivers/net/txgbe/base/meson.build | 2 + drivers/net/txgbe/base/txgbe.h | 2 + drivers/net/txgbe/base/txgbe_aml.c | 185 +- drivers/net/txgbe/base/txgbe_aml.h | 6 +- drivers/net/txgbe/base/txgbe_aml40.c | 114 +- drivers/net/txgbe/base/txgbe_aml40.h | 6 +- drivers/net/txgbe/base/txgbe_dcb_hw.c | 2 +- drivers/net/txgbe/base/txgbe_e56.c | 3773 +++++++++++++++++++++ drivers/net/txgbe/base/txgbe_e56.h | 1753 ++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.c | 2597 ++++++++++++++ drivers/net/txgbe/base/txgbe_e56_bp.h | 282 ++ drivers/net/txgbe/base/txgbe_hw.c | 54 +- drivers/net/txgbe/base/txgbe_hw.h | 4 +- drivers/net/txgbe/base/txgbe_osdep.h | 4 + drivers/net/txgbe/base/txgbe_phy.c | 362 +- drivers/net/txgbe/base/txgbe_phy.h | 46 +- drivers/net/txgbe/base/txgbe_regs.h | 13 +- drivers/net/txgbe/base/txgbe_type.h | 43 +- drivers/net/txgbe/txgbe_ethdev.c | 472 ++- drivers/net/txgbe/txgbe_ethdev.h | 7 +- drivers/net/txgbe/txgbe_rxtx.c | 109 +- drivers/net/txgbe/txgbe_rxtx.h | 36 + drivers/net/txgbe/txgbe_rxtx_vec_common.h | 17 +- 26 files changed, 9464 insertions(+), 444 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_e56.c create mode 100644 drivers/net/txgbe/base/txgbe_e56.h create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.c create mode 100644 drivers/net/txgbe/base/txgbe_e56_bp.h
Signature · 1 line
2.21.0.windows.1
PATCH v6 1/21 net/txgbe: remove duplicate xstats counters
Remove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/txgbe/txgbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/txgbe/txgbe_ethdev.c +0 -5
@@ -261,11 +261,6 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v6 2/21 net/ngbe: remove duplicate xstats counters
In reply to Zaiyu WangRemove four redundant counters (tx_xon_packets, rx_xon_packets, tx_xoff_packets and rx_xoff_packets) from xstats, as they were duplicates of tx_flow_control_xon_packets and others. Both sets were reading the same registers but being output twice under different names. After removing these entries, the flow control counters in DPDK now align with those in our Linux kernel driver.
--- drivers/net/ngbe/ngbe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ngbe/ngbe_ethdev.c +0 -5
@@ -227,11 +227,6 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = {HW_XSTAT (tx_size_1024_to_max_packets),/* Flow Control */ -HW_XSTAT (tx_xon_packets), -HW_XSTAT (rx_xon_packets), -HW_XSTAT (tx_xoff_packets), -HW_XSTAT (rx_xoff_packets), -HW_XSTAT_NAME (tx_xon_packets,"tx_flow_control_xon_packets" ),HW_XSTAT_NAME (rx_xon_packets,"rx_flow_control_xon_packets" ), HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
Signature · 1 line
2.21.0.windows.1
PATCH v6 3/21 net/ngbe: add missing CDR config for YT PHY
In reply to Zaiyu WangAccording to the PHY vendor, when YT8531S operates in UTP-to-Fiber or RGMII-to-Fiber mode with auto-negotiation disabled (Force mode), additional CDR (Clock Data Recovery) configuration is required to improve link connectivity. Without this config, link may be unstable or fail to establish.
--- drivers/net/ngbe/base/ngbe_phy_yt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ngbe/base/ngbe_phy_yt.c +3 -0
@@ -264,6 +264,9 @@ s32 ngbe_setup_phy_link_yt(struct ngbe_hw *hw, u32 speed, value =YT_BCR_RESET |YT_BCR_ANE |YT_BCR_RESTART_AN |YT_BCR_DUPLEX |YT_BCR_SPEED_SELECT1 ; }else { +/* force mode need to config cdr */ +ngbe_write_phy_reg_sds_ext_yt (hw,0x3 ,0 ,0x1434 ); +ngbe_write_phy_reg_sds_ext_yt (hw,0xe ,0 ,0x163 ); value =YT_BCR_RESET |YT_BCR_DUPLEX ;if (speed &NGBE_LINK_SPEED_1GB_FULL ) value |=YT_BCR_SPEED_SELECT1 ;
Signature · 1 line
2.21.0.windows.1
PATCH v6 4/21 net/ngbe: fix VF promiscuous and allmulticast
In reply to Zaiyu WangThe configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled.
To resolve this, the following changes are made:
- do nothing when we set/unset allmulti if promiscuous mode is on
- restore the proper mode (none or allmulti) when we disable promiscuous mode
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -2
@@ -1196,9 +1196,13 @@ static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct ngbe_hw *hw =ngbe_dev_hw (dev); +int mode =NGBEVF_XCAST_MODE_NONE ;int ret; -switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_NONE )) { +if (dev->data->all_multicast) + mode =NGBEVF_XCAST_MODE_ALLMULTI ; + +switch (hw->mac.update_xcast_mode (hw, mode)) {case 0 : ret =0 ;break ;
@@ -1219,7 +1223,7 @@ ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_ALLMULTI )) {
@@ -1243,6 +1247,9 @@ ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)struct ngbe_hw *hw =ngbe_dev_hw (dev);int ret; +if (dev->data->promiscuous) +return 0 ; +switch (hw->mac.update_xcast_mode (hw,NGBEVF_XCAST_MODE_MULTI )) {case 0 : ret =0 ;
Signature · 1 line
2.21.0.windows.1
PATCH v6 5/21 net/txgbe: fix inaccuracy in Tx rate limiting
In reply to Zaiyu WangAmber-lite NIC's TX rate limiting has large deviations for small packets. To address this, the following changes are made:
1. Set TDM_RL_ADJ (0x1820c) to 21B (includes 7B Ethernet preamble, 1B SFD, 1B EFD, and 12B IPG).
2) Remove the rate offset in the driver (e.g., 105 / 100, a rough compensation value from Linux kernel driver tests).
After these changes, accuracy deviation for 64B packets is within ~5%, while large packets show lower deviation.
--- drivers/net/txgbe/base/txgbe_regs.h | 3 +++ drivers/net/txgbe/txgbe_ethdev.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/txgbe/base/txgbe_regs.h +3 -0
@@ -1670,6 +1670,9 @@ enum txgbe_5tuple_protocol {#define TXGBE_TDM_FACTOR_INT_SHIFT 16#define TXGBE_TDM_FACTOR_FRA_SHIFT 2 +#define TXGBE_TDM_RL_ADJ 0x1820C +/* Ethernet framing overhead: 7B Ethernet preamble + 1B SFD + 1B EFD + 12B IPG */ +#define TXGBE_FRAME_OVERHEAD 21#define TXGBE_TDM_RL_VM_IDX 0x018218#define TXGBE_TDM_RL_VM_CFG 0x01821C#define TXGBE_TDM_RL_CFG 0x018400
drivers/net/txgbe/txgbe_ethdev.c +1 -1
@@ -4314,7 +4314,6 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,u16 frac; link_speed = dev->data->dev_link.link_speed; - tx_rate = tx_rate *105 /100 ;/* Calculate the rate factor values to set */ factor_int = link_speed / tx_rate; frac = (link_speed % tx_rate) *10000 / tx_rate;
@@ -4324,6 +4323,7 @@ txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, factor_fra =0 ; } +wr32 (hw,TXGBE_TDM_RL_ADJ ,TXGBE_FRAME_OVERHEAD );wr32 (hw,TXGBE_TDM_RL_QUEUE_IDX , queue_idx);wr32m (hw,TXGBE_TDM_RL_QUEUE_CFG ,TXGBE_TDM_FACTOR_INT_MASK , factor_int <<TXGBE_TDM_FACTOR_INT_SHIFT );
Signature · 1 line
2.21.0.windows.1
PATCH v6 6/21 net/txgbe: fix link status check condition
In reply to Zaiyu WangThe original code incorrectly used 'if (link_up)' instead of 'if (*link_up)', causing the condition to always evaluate to true because the pointer itself is non-NULL. This led to incorrect speed assignment.
--- drivers/net/txgbe/base/txgbe_aml.c | 2 +- drivers/net/txgbe/base/txgbe_aml40.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/txgbe/base/txgbe_aml.c +1 -1
@@ -67,7 +67,7 @@ s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {switch (links_reg &TXGBE_CFG_PORT_ST_AML_LINK_MASK ) {case TXGBE_CFG_PORT_ST_AML_LINK_25G : *speed =TXGBE_LINK_SPEED_25GB_FULL ;
drivers/net/txgbe/base/txgbe_aml40.c +1 -1
@@ -68,7 +68,7 @@ s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed, *link_up = false; } -if (link_up) { +if (*link_up) {if ((links_reg &TXGBE_CFG_PORT_ST_AML_LINK_40G ) ==TXGBE_CFG_PORT_ST_AML_LINK_40G ) *speed =TXGBE_LINK_SPEED_40GB_FULL ;
Signature · 1 line
2.21.0.windows.1