Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] net: wangxun: improve statistics support
@ 2026-11-30  8:34 Mengyuan Lou
  2026-11-30  8:34 ` [PATCH net-next v2 1/3] net: libwx: preserve queue stats across reconfiguration Mengyuan Lou
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mengyuan Lou @ 2026-11-30  8:34 UTC (permalink / raw)
  To: netdev
  Cc: jiawenwu, duanqiangwen, linglingzhang, andrew+netdev, davem,
	edumazet, kuba, pabeni, Mengyuan Lou

This series improves statistics support for the Wangxun drivers.

The legacy counters are aggregated from the queue rings, so they lose
their history whenever a queue vector is freed: an ethtool -L channel
change, enabling or disabling SR-IOV VFs, or a suspend/resume cycle, all
of which tear down and rebuild the queue vectors. The VF drivers neither
expose per-queue statistics through netdev-genl nor provide
ndo_get_stats64(), so ip -s link reports zero counters for them.

Patch 1 keeps the per-ring counters in qstats_base_* accumulators when a
queue vector is torn down. Folding a ring and clearing its pointer happen
under hw_stats_lock, and every read that pairs the rings with the base
values takes the same lock: wx_get_stats64() and wx_update_stats() hold it
across their ring walk, and wx_get_base_stats() takes it for the base
reads. A snapshot therefore cannot mix a ring with its retained value or
count a ring twice. The software aggregates are refreshed on every
update, but the hardware register reads are skipped while the device is
down or resetting, so retained values stay visible through ethtool -S
after queue teardown.

Patch 2 implements netdev_stat_ops in libwx and registers them for ngbe,
ngbevf, txgbe and txgbevf. The per-queue callbacks report the live rings;
get_base_stats() reports the counters retained by patch 1, so netdev-genl
totals keep including the traffic of queues that no longer exist, and a
plain sum over the current queues no longer adds up to them.

Patch 3 registers ndo_get_stats64() for ngbevf and txgbevf. A VF must not
read the PF-only statistics registers: they sit in the PF register block
where an access from a VF hangs the system, as commit 694de316f607
("net: libwx: fix VF illegal register access") records for WX_CFG_PORT_ST,
so wx_update_stats() skips them for a VF. The drivers record the role in
wx->is_vf instead of relying on pci_dev::is_virtfn, which is only set for
the VFs the host's SR-IOV implementation enumerates and stays clear for a
VF probed inside a guest.

Testing:

tools/testing/selftests/drivers/net/stats.py, run with NETIF set to the
interface under test. All four interfaces are on the same host, with the
VFs enabled through SR-IOV on it:

  enp6s0f0   (ngbe)     pass: 6, fail: 0, skip: 2
  enp4s0f0   (txgbe)    pass: 6, fail: 0, skip: 2
  enp6s0f0v0 (ngbevf)   pass: 4, fail: 1, skip: 3
  enp4s0f0v0 (txgbevf)  pass: 4, fail: 1, skip: 3

The skipped subtests are pause (VFs only) and the two FEC subtests (all
four), features the devices do not support. On the VFs the only failure is
procfs_downup_hammer, which starts by querying the channel counts: the VF
ethtool ops do not implement get_channels/set_channels, since ethtool -L
is not supported on a VF, so the subtest cannot run there. Every other
subtest, including qstat_by_ifindex, pkt_byte_sum, check_down and
procfs_hammer, passes on both VFs.

Changes in v2:
- Drop patch 1 ("net: libwx: fix suspend/resume for wxvf"): upstream
  as commit a6c3e4c1f7032 ("net: libwx: fix VF PM suspend/resume flow").
- Retain the ring counters across a queue teardown instead of only
  tolerating missing ring pointers: add the qstats_base_* accumulators,
  fold a ring into them in wx_free_q_vector(), and report them through
  get_base_stats(), ndo_get_stats64() and ethtool -S, rather than
  returning zero from get_base_stats().
- Split the per-ring seqcount into napi_syncp and xmit_syncp, and count
  the transmit queue stops, so every counter has a single writer under
  the matching lock.
- Report the RX checksum counters of the ring that received the packets
  instead of the device-wide values on every queue, and expose
  csum_unnecessary, which is the counter the driver actually maintains,
  in place of csum_complete.
- Merge the per-queue stat ops and the per-driver registration into a
  single patch.
- Drop the early return for VFs in wx_get_stats64() as asked by Breno:
  the PF-only register reads in wx_update_stats() are what a VF must
  skip, not the rest of the statistics.
- Track the device role in wx->is_vf, set by the VF drivers before the
  hardware is touched, and convert the libwx checks from
  pci_dev::is_virtfn, which a VF probed inside a guest does not have.
- Refresh the VF statistics on demand from the readers; the VF service
  task no longer calls wx_update_stats().
- Add the stats.py selftest results and the environment, as asked by
  Jakub.

Link to v1:
https://lore.kernel.org/netdev/20260731074958.19333-1-mengyuanlou@net-swift.com/

Mengyuan Lou (3):
  net: libwx: preserve queue stats across reconfiguration
  net: wangxun: expose queue stats via netdev-genl
  net: wangxun: expose VF stats through ndo_get_stats64

 .../net/ethernet/wangxun/libwx/wx_ethtool.c   |  21 +-
 drivers/net/ethernet/wangxun/libwx/wx_hw.c    |  80 +++---
 drivers/net/ethernet/wangxun/libwx/wx_lib.c   | 254 ++++++++++++++----
 drivers/net/ethernet/wangxun/libwx/wx_lib.h   |   1 +
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |  88 +++++-
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |   1 +
 .../net/ethernet/wangxun/ngbevf/ngbevf_main.c |   6 +
 drivers/net/ethernet/wangxun/txgbe/txgbe_main.c |   1 +
 .../ethernet/wangxun/txgbevf/txgbevf_main.c |   6 +
 9 files changed, 356 insertions(+), 102 deletions(-)

-- 
2.30.1

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

end of thread, other threads:[~2026-12-01  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  8:34 [PATCH net-next v2 0/3] net: wangxun: improve statistics support Mengyuan Lou
2026-11-30  8:34 ` [PATCH net-next v2 1/3] net: libwx: preserve queue stats across reconfiguration Mengyuan Lou
2026-12-01  8:36   ` netdev-bot+sashiko
2026-11-30  8:34 ` [PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl Mengyuan Lou
2026-12-01  8:36   ` netdev-bot+sashiko
2026-11-30  8:34 ` [PATCH net-next v2 3/3] net: wangxun: expose VF stats through ndo_get_stats64 Mengyuan Lou
2026-12-01  8:36   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox