🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24499

[PATCH net-next v2 0/3] net: wangxun: improve statistics support

#24499
From: Mengyuan Lou
Date: Mon, 30 Nov 2026 08:34
104 lines
14088 bytes
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
Technical Details
Message-ID: <20261130083407.78429-1-mengyuanlou@net-swift.com>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374030-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374030-linux-kernel-netdev=dewy.ru
From: mengyuanlou@net-swift.com (Mengyuan Lou)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 0/3] net: wangxun: improve statistics support
Date: Mon, 30 Nov 2026 16:34:04 +0800
Organization: Usenet Network
Message-ID: <20261130083407.78429-1-mengyuanlou@net-swift.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1378842"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:m3vBLaYLmjyhRTpI1WQ2/wuwJvg= sha256:D22tUN8aRz6QvS0D2ddvp4sIHICrxuDg/iRgaOTUIKM=
	sha1:ZdvCDbaLPHnvDa6GoyUhz+Tq3+Q= sha256:x5BEqoIfUwBTCpTDn6UC7vKdYG5q+y+GDU6sppRAnqA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DA49E125FCE; Mon, 30 Nov 2026 11:35:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.951
X-Spam-Status: No, score=-2.951 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id DcLZ0e40ZEeW;
	Mon, 30 Nov 2026 11:35:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374030-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=net-swift.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 006B2125FCC; Mon, 30 Nov 2026 11:35:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B870E297E1; Mon, 30 Nov 2026 08:35:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796027728;
	b=5AVIJ+opJ5Ao5bpKuZt0EPMdNG+QHQdGtdOMVvQyQ3qHKeo7Yk4VkXAUJAawQaNmIwUu
	 CIta4Jk/z5ya52eKKWHPVMJYXb7asq5u3vORD9s2IJCuMbHD+lK88iqGFGHCgboVxJ28A
	 NUzgC+u98CvEDbW7/bjJoqdiqmR9YEFFu50+aqr/JhqvcVqm94p05F/1OVIayUd90lrFm
	 jnowUP+02SKms+i4T3ZmqZo0UQ6kURWhbQZd3PovlxvGPrShUbtvICRVBq4WLrKS9vMo6
	 ap1hBKQy1HRgEV/43KUPfDdGvuiU+r+tTLTlnkGVtvMoGBs7GMFRe1AbY6XwKcQBrOg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796027728;
	h=X-Original-To:Received:DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP:
	 Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:
	 Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:
	 X-QQ-XMAILINFO:X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=ycNd7fBfDf1exRIp33gVSZ52uNyUJWrJwXgFRKs2gds=;
	b=Y8TGZb0T4k2wDiPnNEnhZh3unl0XnFuCr1rhjfepAweCbhTlV0NVNS6uDxa4GJ3aM/vy
	 GknUAK0sUNSjkF9dh8uddlS9NirTQVDKNGmcCPQWWmdELSSw5eOgKIizT0FsHZ4CmHnBQ
	 FufJZcn3VUdIwFImhkc7+BpoeaLHPx3/MbXNcyMTW9SS8snYYkosLrCjlvrtrYd6Xvn5R
	 biUPIP/Z9tUaRaF5LZ4ACBku6bMkIIhoLb1AYamwferWyOCg4eFh/GcJ54OpUoCgoG1Lp
	 zVETQwKC6Ulit4Z7eqykX+2Hu9xoNPfWd2sVj654ZTkiPSx0fHHYYEcxlFOyUGkQ8uw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=net-swift.com;
	spf=pass smtp.mailfrom=net-swift.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9481F606A32A;
	Mon, 30 Nov 2026 08:35:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.207.22.56
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796027728;
	b=R2v0xIEhedbwzat4OdQbt3A5MOaJuDaYQPpZT09lP/lCwoUICITMX5MyVI04MJrHfnkT
	 DJ9bPI136cI4brBc4saeCOiqT+USsZfy47cigv+YvwXpCFdy+Jg5NXQz8ZrK5fySaj6K3
	 n0fETtrD0inzgApPmOxOu9J6du8eT2Z1iG5zjzZuK7/UJaBDnFnc5kBKxncls7e2iqwII
	 3+Irkth3UvMOrDKsHmaRE5YMg9s2+E6tYx1ohYCF1d1B4CrilWWW6Pgph/7h5Nlve93Wn
	 Qv1v7fvzfpK+W95AHCLl4v9+dWzAwwilOKXAkrGYN4Q1P7nge2X+X3XPb22OBDuX/+g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796027728;
	h=DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP:Received:X-QQ-SSF:
	 X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:Cc:Subject:Date:
	 Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding:
	 X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=ycNd7fBfDf1exRIp33gVSZ52uNyUJWrJwXgFRKs2gds=;
	b=VnoNUgOGFeV5W6qN5Okz54ydHyYuKASgcH1zm+fZJGPiTCvvHRKiEw0t8brH2GmC0R7A
	 9fJEibQDta+BFOnFoW2eqGMIcCYS9068GwPlU0PAvm60Cmn7Vb9ysLVGNAhAWoGpi3jcH
	 yuSFrYPEP4XaDbs7sqvZoy7qdLJKCJpu7xBQyCGAAPYQvjp39U47eMP+2f0UTE+6p+KLN
	 UeZSGgnJ2t+SEvvdtK1No913FW+QMfhJuoyqn28gQIN3HGGDUkY8jWt/H4uUwONWguIIP
	 z+6ogZgMwFeyW9bIqwR9UE4rzzvqW/NW62EFTrik9AGaSo5EpZ3wd/Y5EeUVyoZHCCQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=net-swift.com;
	spf=pass smtp.mailfrom=net-swift.com;
	arc=none smtp.remote-ip=54.207.22.56
X-Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6278A606A336
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 08:35:24 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6278A606A336
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=net-swift.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=net-swift.com
X-QQ-mid: esmtpgz15t1796027651t4c85301f
X-QQ-Originating-IP: MTMzZVa+bd7X02guDBBAbKADZ2XwSrO6DrIHEi9ojvU=
X-Received: from localhost.localdomain ( [115.227.136.129])
	by bizesmtp.qq.com (ESMTP) with 
	id ; Mon, 30 Nov 2026 16:34:09 +0800 (CST)
X-QQ-SSF: 0000000000000000000000000000000
X-QQ-GoodBg: 0
X-BIZMAIL-ID: 3405237006340620166
X-EX-QQ-RecipientCnt: 10
X-Cc: jiawenwu@trustnetic.com,
	duanqiangwen@net-swift.com,
	linglingzhang@net-swift.com,
	andrew+netdev@lunn.ch,
	davem@davemloft.net,
	edumazet@google.com,
	kuba@kernel.org,
	pabeni@redhat.com,
	Mengyuan Lou <mengyuanlou@net-swift.com>
X-Mailer: git-send-email 2.30.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-QQ-SENDSIZE: 520
X-Feedback-ID: esmtpgz:net-swift.com:qybglogicsvrgz:qybglogicsvrgz5b-1
X-QQ-XMAILINFO: MbXH59/YT36JSXLDvxq/g7F+0nNJDK3PIBATACZKelAFiMkTPG+iZLMZ
	bCnDUSExFl/G05AMyVLJC1SVDPX6zwU2IsgfW5EMo0YMqeYkFDXp21cRPlDk2EodaqMRteQ
	NFbF3RgsFGgoBVA4Iq4Vpzz99Fz8xz9/QxXL0ip6HARjDvGT66w/aj7+4EEoddC6GDB59fp
	NDoxrSjplJll9MLy7QW1+Zxf50gHdW7HL5unyS20ROPe550LRRuqbnR6z4x4/jmcyXTPzZb
	P9CFiwDyYyBTRSzhsEOZFrfFAWf6IT2/SLoR0kXh2E3z77/NTogZi1bJTxWRD76UaBsYb4v
	D5pv5XGVLXQSeeoI0uywkcjlU6u1PeLcNIESjdwOFZAn/QH0EaS5TDfFmYAs0s1YzeyWYnN
	fY0nSFgTWUhSlpfXdZRP73kNrdLzBgrcEAo4X2mPfGHDuzjg8q9RR+eqkoegIzE1paiztp6
	IOsn6iqDxr5l8LHJ/nkLEQVWAu8afPRxe4U1DxiMPAJic4IAKA+J2dXceSVXz8o5RxhvzPj
	JHtgJdLSUXJnYXAY35V8x9BBRbr4yMY8/B86J5ag79YhyeZhBqJVtN8WFW5gJHGvWUB0hIi
	0AaAZ3EH4fUCsU+8XMGH4lVI5k+qj/n/SuXe4TrBtcTKtLMgO4yUmtIvb/ileqOgpxULNZ/
	Xb3bo6lfLnMkA2A1V42D5Ubf+m79IF6n45py2MFINA4tM1cGS6JIKgAndvIe0Tohu8/hNtk
	L3/HqiePzXbLAdSeE1JwcAr9tWqXWPF1r0j4wV8N3v/g2ywXx4sjGe9jVdO0BxuwxvXRJVR
	7tiIfyrvYrO13Az/ZXGtV1yEWocwwZ3D1Quuw2oLh08C1vDcSIMSCzhOkyfaAXdjDdoMz3T
	WxCpgdCGYUsPZhgj802yyD7OMMH8SZd9fmh4SwkK7SJUGcXOHzPqgPRDKJmG0a1t9AoDJQ0
	Ozi1jOAcNm5YiRwSuscs5zdn6LEL1tRSOnS4osMZTo7T3DuafBCYTvQK7TaWeLmQdEdqT3o
	hS2uW7o5n+E6DlmctosUeG9ZhWovNbfVkkSw99IWGcAIr72GeICvgf/yzD8cXwPnwc7OxHg
	U2Y5Zu55C/3FKwkr1onq0y9qJMNQsm9ZA==
X-QQ-XMRINFO: MSVp+SPm3vtSI1QTLgDHQqIV1w2oNKDqfg==
X-QQ-RECHKSPAM: 0