Wangxun improvement
Subsystems (3)
Jiawen Wu
maintainerv7 cover Wangxun improvement
This patch series cleans up the code and enhances the implementation.
v7:
- Drop the patches about Tx timeout, pci_error_handlers and ngbe reset.
- Replace busy-wait reset flag with kernel mutex.
- Reorder timer and work sync cancellations.
- Add spin lock to protect wx_update_stats().
- Enhance the reading of the registers which are not clear-on-read.
v6: https://lore.kernel.org/all/[email protected]
- Remove changes to the reset process in patch 04/11.
- Remove the inappropriate comments in patch 09/11, and detail the commit message.
v5: https://lore.kernel.org/all/[email protected]
- Add patch 10/11 to handle Tx hang check with pause frame.
- Clear WX_STATE_DISABLED bit in wx_resume().
v4: https://lore.kernel.org/all/[email protected]
- Add an initial patch to remove netdev->ethtool->wol_enabled setting.
v3: https://lore.kernel.org/all/[email protected]
- Detail the commit log for improving ngbe reset flow.
- Correct the process of stopping the work queue.
v2: https://lore.kernel.org/all/[email protected]
- Split NCSI changes from the WOL patch.
- Properly return and handle error codes.
- Fix the typos.
- Remove the check for PCIe errors and subsequent error handling, because aer_recover_queue() does not want to be called by the ethernet driver. The discussion link:
https://lore.kernel.org/linux-acpi/[email protected]/T/
v1: https://lore.kernel.org/all/[email protected]
Jiawen Wu (9):
net: ngbe: remove netdev->ethtool->wol_enabled setting
net: ngbe: move the WOL functions to libwx
net: ngbe: remove redundant macros
net: wangxun: replace busy-wait reset flag with kernel mutex
net: wangxun: move ethtool_ops.set_channels into libwx
net: wangxun: reorder timer and work sync cancellations
net: wangxun: schedule hardware stats update in watchdog
net: libwx: wrap-around and reset qmprc counter
net: libwx: improve flow control setting
.../net/ethernet/wangxun/libwx/wx_ethtool.c | 37 ++++++++++- .../net/ethernet/wangxun/libwx/wx_ethtool.h | 4 ++ drivers/net/ethernet/wangxun/libwx/wx_hw.c | 66 +++++++++++++++++-- drivers/net/ethernet/wangxun/libwx/wx_type.h | 53 ++++++++++----- .../net/ethernet/wangxun/libwx/wx_vf_common.c | 9 ++- .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 57 ++-------------- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 52 ++++++++++++--- drivers/net/ethernet/wangxun/ngbe/ngbe_type.h | 17 ----- .../ethernet/wangxun/txgbe/txgbe_ethtool.c | 21 ++---- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 16 ++--- 10 files changed, 200 insertions(+), 132 deletions(-)
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 1/9 net: ngbe: remove netdev->ethtool->wol_enabled setting
netdev->ethtool->wol_enabled is set in ethtool core code, so remove the redundant setting in ngbe_set_wol().
--- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +1 -2
@@ -37,9 +37,8 @@ static int ngbe_set_wol(struct net_device *netdev, wx->wol =0 ;if (wol->wolopts &WAKE_MAGIC ) wx->wol =WX_PSR_WKUP_CTL_MAG ; - netdev->ethtool->wol_enabled = !!(wx->wol);wr32 (wx,WX_PSR_WKUP_CTL , wx->wol); -device_set_wakeup_enable (&pdev->dev, netdev->ethtool->wol_enabled); +device_set_wakeup_enable (&pdev->dev, !!(wx->wol));return 0 ; }
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 2/9 net: ngbe: move the WOL functions to libwx
In reply to Jiawen WuRemove duplicate-defined register macros, move the WOL implementation to the library module. So that the WOL functions can be reused in txgbe later.
--- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 33 +++++++++++++++++ .../net/ethernet/wangxun/libwx/wx_ethtool.h | 4 +++ .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 35 ++----------------- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 12 +++---- drivers/net/ethernet/wangxun/ngbe/ngbe_type.h | 14 -------- 5 files changed, 45 insertions(+), 53 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +33 -0
@@ -262,6 +262,39 @@ int wx_set_link_ksettings(struct net_device *netdev, }EXPORT_SYMBOL (wx_set_link_ksettings); +void wx_get_wol (struct net_device *netdev, +struct ethtool_wolinfo *wol) +{ +struct wx *wx =netdev_priv (netdev); + +if (!wx->wol_hw_supported) +return ; + wol->supported =WAKE_MAGIC ; + wol->wolopts =0 ; +if (wx->wol &WX_PSR_WKUP_CTL_MAG ) + wol->wolopts |=WAKE_MAGIC ; +} +EXPORT_SYMBOL (wx_get_wol); + +int wx_set_wol (struct net_device *netdev, +struct ethtool_wolinfo *wol) +{ +struct wx *wx =netdev_priv (netdev); +struct pci_dev *pdev = wx->pdev; + +if (!wx->wol_hw_supported) +return -EOPNOTSUPP ; + + wx->wol =0 ; +if (wol->wolopts &WAKE_MAGIC ) + wx->wol =WX_PSR_WKUP_CTL_MAG ; +wr32 (wx,WX_PSR_WKUP_CTL , wx->wol); +device_set_wakeup_enable (&pdev->dev, !!(wx->wol)); + +return 0 ; +} +EXPORT_SYMBOL (wx_set_wol); +void wx_get_pauseparam (struct net_device *netdev,struct ethtool_pauseparam *pause) {
drivers/net/ethernet/wangxun/libwx/wx_ethtool.h +4 -0
@@ -18,6 +18,10 @@ int wx_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd);int wx_set_link_ksettings (struct net_device *netdev,const struct ethtool_link_ksettings *cmd); +void wx_get_wol (struct net_device *netdev, +struct ethtool_wolinfo *wol); +int wx_set_wol (struct net_device *netdev, +struct ethtool_wolinfo *wol);void wx_get_pauseparam (struct net_device *netdev,struct ethtool_pauseparam *pause); int wx_set_pauseparam(struct net_device *netdev,
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +2 -33
@@ -12,37 +12,6 @@#include "ngbe_ethtool.h" #include "ngbe_type.h" -static void ngbe_get_wol (struct net_device *netdev, -struct ethtool_wolinfo *wol) -{ -struct wx *wx =netdev_priv (netdev); - -if (!wx->wol_hw_supported) -return ; - wol->supported =WAKE_MAGIC ; - wol->wolopts =0 ; -if (wx->wol &WX_PSR_WKUP_CTL_MAG ) - wol->wolopts |=WAKE_MAGIC ; -} - -static int ngbe_set_wol (struct net_device *netdev, -struct ethtool_wolinfo *wol) -{ -struct wx *wx =netdev_priv (netdev); -struct pci_dev *pdev = wx->pdev; - -if (!wx->wol_hw_supported) -return -EOPNOTSUPP ; - - wx->wol =0 ; -if (wol->wolopts &WAKE_MAGIC ) - wx->wol =WX_PSR_WKUP_CTL_MAG ; -wr32 (wx,WX_PSR_WKUP_CTL , wx->wol); -device_set_wakeup_enable (&pdev->dev, !!(wx->wol)); - -return 0 ; -} - static int ngbe_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, struct kernel_ethtool_ringparam *kernel_ring,
@@ -121,8 +90,8 @@ static const struct ethtool_ops ngbe_ethtool_ops = { .get_link_ksettings = wx_get_link_ksettings, .set_link_ksettings = wx_set_link_ksettings, .nway_reset = wx_nway_reset, - .get_wol = ngbe_get_wol, - .set_wol = ngbe_set_wol, + .get_wol = wx_get_wol, + .set_wol = wx_set_wol, .get_sset_count = wx_get_sset_count, .get_strings = wx_get_strings, .get_ethtool_stats = wx_get_ethtool_stats,
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +6 -6
@@ -58,14 +58,14 @@ static void ngbe_init_type_code(struct wx *wx) wx->mac.type = wx_mac_em; type_mask = (u16)(wx->subsystem_device_id &NGBE_OEM_MASK ); ncsi_mask = wx->subsystem_device_id &NGBE_NCSI_MASK ; - wol_mask = wx->subsystem_device_id &NGBE_WOL_MASK ; + wol_mask = wx->subsystem_device_id &WX_WOL_MASK ; val =rd32 (wx,WX_CFG_PORT_ST ); wx->mac_type = (val &BIT (7 )) >>7 ? em_mac_type_rgmii : em_mac_type_mdi; - wx->wol_hw_supported = (wol_mask ==NGBE_WOL_SUP ) ?1 :0 ; + wx->wol_hw_supported = (wol_mask ==WX_WOL_SUP ) ?1 :0 ; wx->ncsi_enabled = (ncsi_mask ==NGBE_NCSI_MASK || type_mask ==NGBE_SUBID_OCP_CARD ) ?1 :0 ;
@@ -520,9 +520,9 @@ static void ngbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)if (wufc) {wx_set_rx_mode (netdev);wx_configure_rx (wx); -wr32 (wx,NGBE_PSR_WKUP_CTL , wufc); +wr32 (wx,WX_PSR_WKUP_CTL , wufc); }else { -wr32 (wx,NGBE_PSR_WKUP_CTL ,0 ); +wr32 (wx,WX_PSR_WKUP_CTL ,0 ); }pci_wake_from_d3 (pdev, !!wufc); *enable_wake = !!wufc;
@@ -742,10 +742,10 @@ static int ngbe_probe(struct pci_dev *pdev, wx->wol =0 ;if (wx->wol_hw_supported) - wx->wol =NGBE_PSR_WKUP_CTL_MAG ; + wx->wol =WX_PSR_WKUP_CTL_MAG ; netdev->ethtool->wol_enabled = !!(wx->wol); -wr32 (wx,NGBE_PSR_WKUP_CTL , wx->wol); +wr32 (wx,WX_PSR_WKUP_CTL , wx->wol);device_set_wakeup_enable (&pdev->dev, wx->wol);/* Save off EEPROM version number and Option Rom version which
drivers/net/ethernet/wangxun/ngbe/ngbe_type.h +0 -14
@@ -39,8 +39,6 @@#define NGBE_NCSI_SUP 0x8000#define NGBE_NCSI_MASK 0x8000 -#define NGBE_WOL_SUP 0x4000 -#define NGBE_WOL_MASK 0x4000/**************** EM Registers ****************************/ /* chip control Registers */
@@ -93,18 +91,6 @@#define NGBE_CFG_LAN_SPEED 0x14440#define NGBE_CFG_PORT_ST 0x14404 -/* Wake up registers */ -#define NGBE_PSR_WKUP_CTL 0x15B80 -/* Wake Up Filter Control Bit */ -#define NGBE_PSR_WKUP_CTL_LNKC BIT(0)/* Link Status Change Wakeup Enable*/ -#define NGBE_PSR_WKUP_CTL_MAG BIT(1)/* Magic Packet Wakeup Enable */ -#define NGBE_PSR_WKUP_CTL_EX BIT(2)/* Directed Exact Wakeup Enable */ -#define NGBE_PSR_WKUP_CTL_MC BIT(3)/* Directed Multicast Wakeup Enable*/ -#define NGBE_PSR_WKUP_CTL_BC BIT(4)/* Broadcast Wakeup Enable */ -#define NGBE_PSR_WKUP_CTL_ARP BIT(5)/* ARP Request Packet Wakeup Enable*/ -#define NGBE_PSR_WKUP_CTL_IPV4 BIT(6)/* Directed IPv4 Pkt Wakeup Enable */ -#define NGBE_PSR_WKUP_CTL_IPV6 BIT(7)/* Directed IPv6 Pkt Wakeup Enable */ -#define NGBE_FW_EEPROM_CHECKSUM_CMD 0xE9#define NGBE_FW_NVM_DATA_OFFSET 3#define NGBE_FW_CMD_DEFAULT_CHECKSUM 0xFF/* checksum always 0xFF */
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 3/9 net: ngbe: remove redundant macros
In reply to Jiawen WuNGBE_NCSI_SUP and NGBE_NCSI_MASK are duplicate-defined, they can be replaced by the macros defined in libwx. Just remove them.
--- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 4 ++-- drivers/net/ethernet/wangxun/ngbe/ngbe_type.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +2 -2
@@ -57,7 +57,7 @@ static void ngbe_init_type_code(struct wx *wx) wx->mac.type = wx_mac_em; type_mask = (u16)(wx->subsystem_device_id &NGBE_OEM_MASK ); - ncsi_mask = wx->subsystem_device_id &NGBE_NCSI_MASK ; + ncsi_mask = wx->subsystem_device_id &WX_NCSI_MASK ; wol_mask = wx->subsystem_device_id &WX_WOL_MASK ; val =rd32 (wx,WX_CFG_PORT_ST );
@@ -66,7 +66,7 @@ static void ngbe_init_type_code(struct wx *wx) em_mac_type_mdi; wx->wol_hw_supported = (wol_mask ==WX_WOL_SUP ) ?1 :0 ; - wx->ncsi_enabled = (ncsi_mask ==NGBE_NCSI_MASK || + wx->ncsi_enabled = (ncsi_mask ==WX_NCSI_SUP || type_mask ==NGBE_SUBID_OCP_CARD ) ?1 :0 ;switch (type_mask) {
drivers/net/ethernet/wangxun/ngbe/ngbe_type.h +0 -3
@@ -37,9 +37,6 @@#define NGBE_OEM_MASK 0x00FF -#define NGBE_NCSI_SUP 0x8000 -#define NGBE_NCSI_MASK 0x8000 -/**************** EM Registers ****************************/ /* chip control Registers */ #define NGBE_MIS_PRB_CTL 0x10010
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 4/9 net: wangxun: replace busy-wait reset flag with kernel mutex
In reply to Jiawen WuReplace the busy-wait loop using test_and_set_bit(WX_STATE_RESETTING) with a proper per-device mutex to serialize reset operations.
The reset flag is reserved for other code paths (like watchdog), which need tocheck if a reset is in process.
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 1 + drivers/net/ethernet/wangxun/libwx/wx_type.h | 16 +--------------- .../net/ethernet/wangxun/libwx/wx_vf_common.c | 6 ++++-- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 6 +++--- .../net/ethernet/wangxun/txgbe/txgbe_ethtool.c | 6 +++--- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 10 +++------- 6 files changed, 15 insertions(+), 30 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +1 -0
@@ -2513,6 +2513,7 @@ int wx_sw_init(struct wx *wx)return -ENOMEM ; } +mutex_init (&wx->reset_lock);bitmap_zero (wx->state,WX_STATE_NBITS );bitmap_zero (wx->flags,WX_PF_FLAGS_NBITS ); wx->misc_irq_domain = false;
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -15
@@ -1400,6 +1400,7 @@ struct wx {struct timer_list service_timer;struct work_struct service_task; +struct mutex reset_lock;/* mutex for reset */ };#define WX_INTR_ALL (~0ULL)
@@ -1478,21 +1479,6 @@ static inline struct wx *phylink_to_wx(struct phylink_config *config) return container_of(config, struct wx, phylink_config); } -static inline int wx_set_state_reset (struct wx *wx) -{ -u8 timeout =50 ; - -while (test_and_set_bit (WX_STATE_RESETTING , wx->state)) { - timeout--; -if (!timeout) -return -EBUSY ; - -usleep_range (1000 ,2000 ); - } - -return 0 ; -} -static inline unsigned int wx_rx_pg_order (struct wx_ring *ring) {#if (PAGE_SIZE <8192 )
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +4 -2
@@ -339,14 +339,16 @@ static void wxvf_down(struct wx *wx)static void wxvf_reinit_locked (struct wx *wx) { -while (test_and_set_bit (WX_STATE_RESETTING , wx->state)) -usleep_range (1000 ,2000 ); +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state); +wxvf_down (wx);wx_free_irq (wx);wx_configure_vf (wx);wx_request_msix_irqs_vf (wx);wxvf_up_complete (wx);clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock); }static void wxvf_reset_subtask (struct wx *wx)
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +3 -3
@@ -32,9 +32,8 @@ static int ngbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count)return 0 ; - err =wx_set_state_reset (wx); -if (err) -return err; +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++)
@@ -65,6 +64,7 @@ static int ngbe_set_ringparam(struct net_device *netdev, clear_reset:clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock);return err; }
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +3 -3
@@ -56,9 +56,8 @@ static int txgbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count)return 0 ; - err =wx_set_state_reset (wx); -if (err) -return err; +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);if (!netif_running (wx->netdev)) {for (i =0 ; i < wx->num_tx_queues; i++)
@@ -88,6 +87,7 @@ static int txgbe_set_ringparam(struct net_device *netdev, clear_reset:clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock);return err; }
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +3 -7
@@ -598,20 +598,16 @@ int txgbe_setup_tc(struct net_device *dev, u8 tc)static void txgbe_reinit_locked (struct wx *wx) { -int err =0 ; -netif_trans_update (wx->netdev); - err =wx_set_state_reset (wx); -if (err) { -wx_err (wx,"wait device reset timeout\n" ); -return ; - } +mutex_lock (&wx->reset_lock); +set_bit (WX_STATE_RESETTING , wx->state);txgbe_down (wx);txgbe_up (wx);clear_bit (WX_STATE_RESETTING , wx->state); +mutex_unlock (&wx->reset_lock); }void txgbe_do_reset (struct net_device *netdev)
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 5/9 net: wangxun: move ethtool_ops.set_channels into libwx
In reply to Jiawen WuSince function ops wx->setup_tc() is set in txgbe and ngbe, ethtool_ops.set_channels can be implemented in libwx to reduce duplicated code.
--- drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 15 +-------------- .../net/ethernet/wangxun/txgbe/txgbe_ethtool.c | 15 +-------------- 3 files changed, 3 insertions(+), 29 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +1 -1
@@ -555,7 +555,7 @@ int wx_set_channels(struct net_device *dev, wx->ring_feature[RING_F_RSS ].limit = count; -return 0 ; +return wx->setup_tc (dev,netdev_get_num_tc (dev)); }EXPORT_SYMBOL (wx_set_channels);
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +1 -14
@@ -68,19 +68,6 @@ static int ngbe_set_ringparam(struct net_device *netdev,return err; } -static int ngbe_set_channels (struct net_device *dev, -struct ethtool_channels *ch) -{ -int err; - - err =wx_set_channels (dev, ch); -if (err <0 ) -return err; - -/* use setup TC to update any traffic class queue mapping */ -return ngbe_setup_tc (dev,netdev_get_num_tc (dev)); -} -static const struct ethtool_ops ngbe_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ |
@@ -104,7 +91,7 @@ static const struct ethtool_ops ngbe_ethtool_ops = { .get_coalesce = wx_get_coalesce, .set_coalesce = wx_set_coalesce, .get_channels = wx_get_channels, - .set_channels = ngbe_set_channels, + .set_channels = wx_set_channels, .get_rxfh_fields = wx_get_rxfh_fields, .set_rxfh_fields = wx_set_rxfh_fields, .get_rxfh_indir_size = wx_rss_indir_size,
drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +1 -14
@@ -91,19 +91,6 @@ static int txgbe_set_ringparam(struct net_device *netdev,return err; } -static int txgbe_set_channels (struct net_device *dev, -struct ethtool_channels *ch) -{ -int err; - - err =wx_set_channels (dev, ch); -if (err <0 ) -return err; - -/* use setup TC to update any traffic class queue mapping */ -return txgbe_setup_tc (dev,netdev_get_num_tc (dev)); -} -static int txgbe_get_ethtool_fdir_entry (struct txgbe *txgbe,struct ethtool_rxnfc *cmd) {
@@ -587,7 +574,7 @@ static const struct ethtool_ops txgbe_ethtool_ops = { .get_coalesce = wx_get_coalesce, .set_coalesce = wx_set_coalesce, .get_channels = wx_get_channels, - .set_channels = txgbe_set_channels, + .set_channels = wx_set_channels, .get_rxnfc = txgbe_get_rxnfc, .set_rxnfc = txgbe_set_rxnfc, .get_rx_ring_count = txgbe_get_rx_ring_count,
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 6/9 net: wangxun: reorder timer and work sync cancellations
In reply to Jiawen WuWhen removing the device, timer_delete_sync(&wx->service_timer) is called in .ndo_stop() after cancel_work_sync(&wx->service_task). This may cause new work to be queued after device down.
Move unregister_netdev() before cancel_work_sync(), and use timer_shutdown_sync() to prevent the timer from being re-armed.
--- drivers/net/ethernet/wangxun/libwx/wx_vf_common.c | 3 ++- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +2 -1
@@ -48,9 +48,10 @@ void wxvf_remove(struct pci_dev *pdev)struct wx *wx =pci_get_drvdata (pdev);struct net_device *netdev; -cancel_work_sync (&wx->service_task); netdev = wx->netdev;unregister_netdev (netdev); +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task);kfree (wx->vfinfo);kfree (wx->rss_key);kfree (wx->mac_table);
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +3 -2
@@ -946,12 +946,13 @@ static void txgbe_remove(struct pci_dev *pdev)struct txgbe *txgbe = wx->priv;struct net_device *netdev; -cancel_work_sync (&wx->service_task); - netdev = wx->netdev;wx_disable_sriov (wx);unregister_netdev (netdev); +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +txgbe_remove_phy (txgbe);wx_free_isb_resources (wx);
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 7/9 net: wangxun: schedule hardware stats update in watchdog
In reply to Jiawen WuHardware statistics should be updated periodically in the watchdog to prevent 32-bit registers from overflowing. This is also required for the upcoming pause frame accounting logic, which relies on regular statistics sampling.
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 9 +++++ drivers/net/ethernet/wangxun/libwx/wx_type.h | 1 + drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 36 ++++++++++++++++++- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + 4 files changed, 46 insertions(+), 1 deletion(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +9 -0
@@ -2513,6 +2513,7 @@ int wx_sw_init(struct wx *wx)return -ENOMEM ; } +spin_lock_init (&wx->hw_stats_lock);mutex_init (&wx->reset_lock);bitmap_zero (wx->state,WX_STATE_NBITS );bitmap_zero (wx->flags,WX_PF_FLAGS_NBITS );
@@ -2845,6 +2846,12 @@ void wx_update_stats(struct wx *wx)u64 restart_queue =0 , tx_busy =0 ;u32 i; +if (!netif_running (wx->netdev) || +test_bit (WX_STATE_RESETTING , wx->state)) +return ; + +spin_lock (&wx->hw_stats_lock); +/* gather some stats to the wx struct that are per queue */ for (i =0 ; i < wx->num_rx_queues; i++) {struct wx_ring *rx_ring = wx->rx_ring[i];
@@ -2913,6 +2920,8 @@ void wx_update_stats(struct wx *wx)for (i = wx->num_vfs * wx->num_rx_queues_per_pool; i < wx->mac.max_rx_queues; i++) hwstats->qmprc +=rd32 (wx,WX_PX_MPRC (i)); + +spin_unlock (&wx->hw_stats_lock); }EXPORT_SYMBOL (wx_update_stats);
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -0
@@ -1354,6 +1354,7 @@ struct wx {bool default_up;struct wx_hw_stats stats; +spinlock_t hw_stats_lock;/* spinlock for accessing to hw stats */ u64 tx_busy;u64 non_eop_descs;u64 restart_queue;
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +35 -1
@@ -138,6 +138,26 @@ static int ngbe_sw_init(struct wx *wx)return 0 ; } +/** +* ngbe_service_task - manages and runs subtasks +* @work: pointer to work_struct containing our data +**/ +static void ngbe_service_task (struct work_struct *work) +{ + struct wx *wx = container_of(work, struct wx, service_task); + +wx_update_stats (wx); + +wx_service_event_complete (wx); +} + +static void ngbe_init_service (struct wx *wx) +{ +timer_setup (&wx->service_timer, wx_service_timer,0 ); +INIT_WORK (&wx->service_task, ngbe_service_task); +clear_bit (WX_STATE_SERVICE_SCHED , wx->state); +} +/** * ngbe_irq_enable - Enable default interrupt generation settings * @wx: board private structure
@@ -368,6 +388,10 @@ static void ngbe_disable_device(struct wx *wx)wx_napi_disable_all (wx);netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev); + +timer_delete_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +if (wx->gpio_ctrl)ngbe_sfp_modules_txrx_powerctl (wx, false);wx_irq_disable (wx);
@@ -407,6 +431,7 @@ void ngbe_up(struct wx *wx)wx_napi_enable_all (wx);/* enable transmits */ netif_tx_start_all_queues (wx->netdev); +mod_timer (&wx->service_timer, jiffies);/* clear any pending interrupts, may auto mask */ rd32 (wx,WX_PX_IC (0 ));
@@ -770,9 +795,11 @@ static int ngbe_probe(struct pci_dev *pdev,eth_hw_addr_set (netdev, wx->mac.perm_addr);wx_mac_set_default_filter (wx, wx->mac.perm_addr); +ngbe_init_service (wx); + err =wx_init_interrupt_scheme (wx);if (err) - goto err_free_mac_table; + goto err_cancel_service;/* phy Interface Configuration */ err =ngbe_mdio_init (wx);
@@ -792,6 +819,9 @@ static int ngbe_probe(struct pci_dev *pdev,wx_control_hw (wx, false); err_clear_interrupt_scheme:wx_clear_interrupt_scheme (wx); +err_cancel_service: +timer_delete_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); err_free_mac_table:kfree (wx->rss_key);kfree (wx->mac_table);
@@ -820,6 +850,10 @@ static void ngbe_remove(struct pci_dev *pdev) netdev = wx->netdev;wx_disable_sriov (wx);unregister_netdev (netdev); + +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +phylink_destroy (wx->phylink);pci_release_selected_regions (pdev,pci_select_bars (pdev,IORESOURCE_MEM ));
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +1 -0
@@ -130,6 +130,7 @@ static void txgbe_service_task(struct work_struct *work)txgbe_module_detection_subtask (wx);txgbe_link_config_subtask (wx); +wx_update_stats (wx);wx_service_event_complete (wx); }
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 8/9 net: libwx: wrap-around and reset qmprc counter
In reply to Jiawen WuThe WX_PX_MPRC registers are not clear-on-read hardware counters. The previous implementation directly read and accumulated these 32-bit values into a 64-bit software counter. Now implement a rd32_wrap() helper function to calculate the delta counter to correct the statistic.
--- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 10 ++++++---- drivers/net/ethernet/wangxun/libwx/wx_type.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_hw.c +6 -4
@@ -2915,11 +2915,10 @@ void wx_update_stats(struct wx *wx) hwstats->fdirmiss +=rd32 (wx,WX_RDB_FDIR_MISS ); } -/* qmprc is not cleared on read, manual reset it */ - hwstats->qmprc =0 ;for (i = wx->num_vfs * wx->num_rx_queues_per_pool; i < wx->mac.max_rx_queues; i++) - hwstats->qmprc +=rd32 (wx,WX_PX_MPRC (i)); + hwstats->qmprc +=rd32_wrap (wx,WX_PX_MPRC (i), + &wx->last_stats.qmprc[i]);spin_unlock (&wx->hw_stats_lock); }
@@ -2936,8 +2935,11 @@ void wx_clear_hw_cntrs(struct wx *wx) {u16 i =0 ; -for (i =0 ; i < wx->mac.max_rx_queues; i++) +for (i = wx->num_vfs * wx->num_rx_queues_per_pool; + i < wx->mac.max_rx_queues; i++) {wr32 (wx,WX_PX_MPRC (i),0 ); + wx->last_stats.qmprc[i] =0 ; + }rd32 (wx,WX_RDM_PKT_CNT );rd32 (wx,WX_TDM_PKT_CNT );
drivers/net/ethernet/wangxun/libwx/wx_type.h +17 -0
@@ -1182,6 +1182,10 @@ struct wx_hw_stats {u64 fdirmiss; }; +struct wx_last_stats { +u32 qmprc[128 ]; +}; +enum wx_state {WX_STATE_RESETTING ,WX_STATE_SWFW_BUSY ,
@@ -1354,6 +1358,7 @@ struct wx {bool default_up;struct wx_hw_stats stats; +struct wx_last_stats last_stats;spinlock_t hw_stats_lock;/* spinlock for accessing to hw stats */ u64 tx_busy;u64 non_eop_descs;
@@ -1464,6 +1469,18 @@ wr32ptp(struct wx *wx, u32 reg, u32 value)return wr32 (wx, reg +0xB500 , value); } +static inline u32 +rd32_wrap (struct wx *wx,u32 reg,u32 *last) +{ +u32 val, delta; + + val =rd32 (wx, reg); + delta = val - *last; + *last = val; + +return delta; +} +/* On some domestic CPU platforms, sometimes IO is not synchronized with * flushing memory, here use readl() to flush PCI read and write. */
Signature · 1 line
2.48.1
Jiawen Wu
maintainerPATCH v7 9/9 net: libwx: improve flow control setting
In reply to Jiawen WuSave the current mode of flow control, and enhance the statistics of pause frames.
The received pause frames are divided into XON and XOFF to be counted. And due to the hardware defect of SP devices, XON packets cannot be trasmitted correctly, so Tx XON pause is disabled by default for those devices.
--- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 46 +++++++++++++++++-- drivers/net/ethernet/wangxun/libwx/wx_type.h | 19 +++++++- 3 files changed, 61 insertions(+), 6 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +1 -1
@@ -211,7 +211,7 @@ void wx_get_pause_stats(struct net_device *netdev, hwstats = &wx->stats; stats->tx_pause_frames = hwstats->lxontxc + hwstats->lxofftxc; - stats->rx_pause_frames = hwstats->lxonoffrxc; + stats->rx_pause_frames = hwstats->lxonrxc + hwstats->lxoffrxc; }EXPORT_SYMBOL (wx_get_pause_stats);
drivers/net/ethernet/wangxun/libwx/wx_hw.c +43 -3
82 lines not on this page · raw message
drivers/net/ethernet/wangxun/libwx/wx_type.h +17 -2
@@ -79,7 +79,10 @@#define WX_RX_LEN_ERROR_FRAMES_L 0x11978#define WX_RX_UNDERSIZE_FRAMES_GOOD 0x11938#define WX_RX_OVERSIZE_FRAMES_GOOD 0x1193C -#define WX_MAC_LXONOFFRXC 0x11E0C +#define WX_MAC_LXOFFRXC 0x11988 +#define WX_MAC_LXONRXC 0x11E0C +#define WX_MAC_LXOFFRXC_AML 0x11F80 +#define WX_MAC_LXONRXC_AML 0x11F84/*********************** Receive DMA registers **************************/ #define WX_RDM_VF_RE (_i) (0x12004 + ((_i) * 4))
@@ -1148,9 +1151,18 @@ enum wx_isb_idx { WX_ISB_MAX }; +/* Flow Control Settings */ +enum wx_fc_mode { + wx_fc_none =0 , + wx_fc_rx_pause, + wx_fc_tx_pause, + wx_fc_full +}; +struct wx_fc_info {u32 high_water;/* Flow Ctrl High-water */ u32 low_water;/* Flow Ctrl Low-water */ +enum wx_fc_mode mode;/* Flow Control Mode */ };/* Statistics counters collected by the MAC */
@@ -1167,7 +1179,8 @@ struct wx_hw_stats {u64 mptc;u64 roc;u64 ruc; -u64 lxonoffrxc; +u64 lxonrxc; +u64 lxoffrxc;u64 lxontxc;u64 lxofftxc;u64 o2bgptc;
@@ -1184,6 +1197,8 @@ struct wx_hw_stats {struct wx_last_stats {u32 qmprc[128 ]; +u32 lxoffrxc; +u32 lxonrxc; };enum wx_state {
Signature · 1 line
2.48.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 7 Apr 2026 10:56:07 +0800 you wrote:
This patch series cleans up the code and enhances the implementation.
v7:
- Drop the patches about Tx timeout,pci_error_handlersand ngbe reset.
- Replace busy-wait reset flag with kernel mutex.
- Reorder timer and work sync cancellations.
- Add spin lock to protectwx_update_stats().
- Enhance the reading of the registers which are not clear-on-read.[...]
Here is the summary with links:
- [net-next,v7,1/9] net: ngbe: remove netdev->ethtool->wol_enabled setting
https://git.kernel.org/netdev/net-next/c/4d19654dacef - [net-next,v7,2/9] net: ngbe: move the WOL functions to libwx https://git.kernel.org/netdev/net-next/c/752157d9eded - [net-next,v7,3/9] net: ngbe: remove redundant macros https://git.kernel.org/netdev/net-next/c/9bc29a87fbc6 - [net-next,v7,4/9] net: wangxun: replace busy-wait reset flag with kernel mutex https://git.kernel.org/netdev/net-next/c/d48df7e7c3fb - [net-next,v7,5/9] net: wangxun: move ethtool_ops.set_channels into libwx https://git.kernel.org/netdev/net-next/c/b736ebed937e - [net-next,v7,6/9] net: wangxun: reorder timer and work sync cancellations https://git.kernel.org/netdev/net-next/c/58f6303572ec - [net-next,v7,7/9] net: wangxun: schedule hardware stats update in watchdog https://git.kernel.org/netdev/net-next/c/dc33e52b8ce6 - [net-next,v7,8/9] net: libwx: wrap-around and reset qmprc counter https://git.kernel.org/netdev/net-next/c/1dd9b0dafd21 - [net-next,v7,9/9] net: libwx: improve flow control setting https://git.kernel.org/netdev/net-next/c/40637e4a4477
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html