Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Mengyuan Lou
Mon, 30 Nov 2026 08:34
[PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl
Author: Mengyuan Lou
Date: Mon, 30 Nov 2026 08:34
Date: Mon, 30 Nov 2026 08:34
207 lines
17000 bytes
17000 bytes
Implement the netdev_stat_ops callbacks in libwx and register them for
the ngbe, ngbevf, txgbe and txgbevf netdevs, so that the queue statistics
already collected by the driver are available through the standard
netdev-genl interface instead of growing more driver-private ethtool -S
strings.
The per-queue callbacks read the live rings: packet and byte counters for
both directions, the RX allocation failure and checksum counters that
netdev-genl has attributes for, and the transmit queue stop and wake
counts. The tx_busy counter is not reported, as it counts packets
deferred because the ring was full rather than queue state changes.
get_base_stats() reports the counters retained when a queue vector is
torn down, and netdev-genl adds the live queue statistics on top of
them. A device total therefore keeps including the traffic of queues
that no longer exist and does not drop when the ring count is lowered,
while a plain sum over the current queues no longer adds up to that
total.
The PF-only hardware counters that have no netdev-genl attribute stay
available through ethtool -S, among them rdmdrop, which the driver
reports as rx_no_dma_resources; a VF does not read them at all. The error
counters and qmprc, as multicast, are also exported through
rtnl_link_stats64. csum_err is reported as RX csum_bad, which is the
counter that ethtool -S calls rx_csum_offload_errors.
Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
drivers/net/ethernet/wangxun/libwx/wx_lib.c | 90 +++++++++++++++++++
drivers/net/ethernet/wangxun/libwx/wx_lib.h | 1 +
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 +
.../net/ethernet/wangxun/ngbevf/ngbevf_main.c | 1 +
.../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 +
.../ethernet/wangxun/txgbevf/txgbevf_main.c | 1 +
6 files changed, 95 insertions(+)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index 2868232792588..0502b5d8e96e8 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -5,6 +5,7 @@
#include <net/ip6_checksum.h>
#include <net/page_pool/helpers.h>
#include <net/inet_ecn.h>
+#include <net/netdev_queues.h>
#include <linux/workqueue.h>
#include <linux/iopoll.h>
#include <linux/sctp.h>
@@ -3193,6 +3194,95 @@ void wx_get_stats64(struct net_device *netdev,
}
EXPORT_SYMBOL(wx_get_stats64);
+static void wx_get_queue_stats_rx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_rx *stats)
+{
+ struct wx_rx_ring_stats ring_stats;
+ struct wx *wx = netdev_priv(dev);
+ struct wx_ring *ring;
+
+ /* The ring pointer is published and cleared with RCU primitives, so
+ * a ring that a teardown has already cleared is simply skipped.
+ */
+ if (idx < 0 || idx >= READ_ONCE(wx->num_rx_queues))
+ return;
+
+ rcu_read_lock();
+ ring = rcu_dereference(wx->rx_ring[idx]);
+ if (!ring)
+ goto out;
+
+ wx_ring_get_rx_stats(ring, &ring_stats);
+ stats->packets = ring_stats.queue.packets;
+ stats->bytes = ring_stats.queue.bytes;
+ stats->alloc_fail = ring_stats.rx.alloc_rx_buff_failed;
+ stats->csum_unnecessary = ring_stats.rx.csum_unnecessary_cnt;
+ stats->csum_bad = ring_stats.rx.csum_err;
+
+out:
+ rcu_read_unlock();
+}
+
+static void wx_get_queue_stats_tx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_tx *stats)
+{
+ struct wx_tx_ring_stats ring_stats;
+ struct wx *wx = netdev_priv(dev);
+ struct wx_ring *ring;
+
+ if (idx < 0 || idx >= READ_ONCE(wx->num_tx_queues))
+ return;
+
+ rcu_read_lock();
+ ring = rcu_dereference(wx->tx_ring[idx]);
+ if (!ring)
+ goto out;
+
+ wx_ring_get_tx_stats(ring, &ring_stats);
+ stats->packets = ring_stats.queue.packets;
+ stats->bytes = ring_stats.queue.bytes;
+ stats->stop = ring_stats.tx.stop;
+ stats->wake = ring_stats.tx.wake;
+
+out:
+ rcu_read_unlock();
+}
+
+static void wx_get_base_stats(struct net_device *dev,
+ struct netdev_queue_stats_rx *rx,
+ struct netdev_queue_stats_tx *tx)
+{
+ struct wx *wx = netdev_priv(dev);
+
+ /* Read the retained values the same way as wx_get_stats64(), so that
+ * they cannot be updated while they are being gathered.
+ */
+ spin_lock(&wx->hw_stats_lock);
+ rx->bytes = wx->qstats_base_rx.bytes;
+ rx->packets = wx->qstats_base_rx.packets;
+ rx->alloc_fail = wx->qstats_base_rx_stats.alloc_rx_buff_failed;
+ rx->csum_unnecessary =
+ wx->qstats_base_rx_stats.csum_unnecessary_cnt;
+ rx->csum_bad = wx->qstats_base_rx_stats.csum_err;
+ tx->bytes = wx->qstats_base_tx.bytes;
+ tx->packets = wx->qstats_base_tx.packets;
+ tx->stop = wx->qstats_base_tx_stats.stop;
+ tx->wake = wx->qstats_base_tx_stats.wake;
+ spin_unlock(&wx->hw_stats_lock);
+}
+
+static const struct netdev_stat_ops wx_stat_ops = {
+ .get_queue_stats_rx = wx_get_queue_stats_rx,
+ .get_queue_stats_tx = wx_get_queue_stats_tx,
+ .get_base_stats = wx_get_base_stats,
+};
+
+void wx_set_stat_ops(struct net_device *netdev)
+{
+ netdev->stat_ops = &wx_stat_ops;
+}
+EXPORT_SYMBOL(wx_set_stat_ops);
+
int wx_set_features(struct net_device *netdev, netdev_features_t features)
{
netdev_features_t changed = netdev->features ^ features;
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.h b/drivers/net/ethernet/wangxun/libwx/wx_lib.h
index 9d85d399e17f4..f9ce79ba350b7 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.h
@@ -30,6 +30,7 @@ void wx_free_resources(struct wx *wx);
int wx_setup_resources(struct wx *wx);
void wx_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats);
+void wx_set_stat_ops(struct net_device *netdev);
int wx_set_features(struct net_device *netdev, netdev_features_t features);
netdev_features_t wx_fix_features(struct net_device *netdev,
netdev_features_t features);
diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
index bef7089d0e47e..cdfb6e61f70af 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
@@ -771,6 +771,7 @@ static int ngbe_probe(struct pci_dev *pdev,
wx->driver_name = ngbe_driver_name;
ngbe_set_ethtool_ops(netdev);
netdev->netdev_ops = &ngbe_netdev_ops;
+ wx_set_stat_ops(netdev);
netdev->features = NETIF_F_SG | NETIF_F_IP_CSUM |
NETIF_F_TSO | NETIF_F_TSO6 |
diff --git a/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c b/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
index c40b64564d41f..2df781150cc0e 100644
--- a/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
+++ b/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
@@ -190,6 +190,7 @@ static int ngbevf_probe(struct pci_dev *pdev,
wx->driver_name = KBUILD_MODNAME;
wx_set_ethtool_ops_vf(netdev);
netdev->netdev_ops = &ngbevf_netdev_ops;
+ wx_set_stat_ops(netdev);
/* setup the private structure */
err = ngbevf_sw_init(wx);
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index 3111409861590..f3c37609710d7 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
@@ -790,6 +790,7 @@ static int txgbe_probe(struct pci_dev *pdev,
wx->driver_name = txgbe_driver_name;
txgbe_set_ethtool_ops(netdev);
netdev->netdev_ops = &txgbe_netdev_ops;
+ wx_set_stat_ops(netdev);
netdev->udp_tunnel_nic_info = &txgbe_udp_tunnels;
/* setup the private structure */
diff --git a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
index f1784c0ed114d..984ccb52bd6de 100644
--- a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
+++ b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
@@ -255,6 +255,7 @@ static int txgbevf_probe(struct pci_dev *pdev,
wx->driver_name = KBUILD_MODNAME;
wx_set_ethtool_ops_vf(netdev);
netdev->netdev_ops = &txgbevf_netdev_ops;
+ wx_set_stat_ops(netdev);
/* setup the private structure */
err = txgbevf_sw_init(wx);
--
2.30.1
Re: [PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl
Author: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 08:36
Date: Tue, 01 Dec 2026 08:36
218 lines
15640 bytes
15640 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] wx_get_queue_stats_tx() and wx_get_base_stats() export TX
stop/wake counters through netdev-genl, but the two counters are not…
- [Low] The commit message says the PF-only hardware counters left in
ethtool -S "have no netdev-genl attribute" and names rdmdrop…
- [Low] wx_get_queue_stats_rx() and wx_get_base_stats() fill the netdev-
genl rx-alloc-fail attribute from rx_stats.alloc_rx_buff_failed.
--
net: wangxun: expose queue stats via netdev-genl
This patch implements netdev_stat_ops in libwx and registers them for the
ngbe, ngbevf, txgbe and txgbevf netdevs. Per-queue packet, byte, RX
allocation failure, checksum and TX stop/wake counters become available
through netdev-genl. get_base_stats() reports the counters kept when a
queue vector is torn down.
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 2868232792588..0502b5d8e96e8 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
[ ... ]
> @@ -3193,6 +3194,95 @@ void wx_get_stats64(struct net_device *netdev,
> }
> EXPORT_SYMBOL(wx_get_stats64);
>
> +static void wx_get_queue_stats_rx(struct net_device *dev, int idx,
> + struct netdev_queue_stats_rx *stats)
> +{
[ ... ]
> + wx_ring_get_rx_stats(ring, &ring_stats);
> + stats->packets = ring_stats.queue.packets;
> + stats->bytes = ring_stats.queue.bytes;
> + stats->alloc_fail = ring_stats.rx.alloc_rx_buff_failed;
[Severity: Low]
Does rx_stats.alloc_rx_buff_failed cover everything rx-alloc-fail is
defined to count?
netdev.yaml describes rx-alloc-fail as "Number of times skb or buffer
allocation failed on the Rx datapath". The only place that increments
alloc_rx_buff_failed is wx_clean_rx_irq(), when wx_build_skb() fails to
allocate an skb:
skb = wx_build_skb(rx_ring, rx_buffer, rx_desc);
/* exit if we failed to retrieve a buffer */
if (!skb) {
rx_stats.alloc_rx_buff_failed++;
break;
}
When a page pool refill fails in wx_alloc_mapped_page(), the function
returns without updating any counter:
page = page_pool_dev_alloc_pages(rx_ring->page_pool);
if (unlikely(!page))
return false;
wx_alloc_rx_buffers() then just stops refilling.
Under memory pressure, could rx-alloc-fail read 0 while ring refills are
failing? wx_get_base_stats() exports the same counter through
qstats_base_rx_stats.alloc_rx_buff_failed. The rest of the series does
not change this.
> + stats->csum_unnecessary = ring_stats.rx.csum_unnecessary_cnt;
> + stats->csum_bad = ring_stats.rx.csum_err;
> +
> +out:
> + rcu_read_unlock();
> +}
> +
> +static void wx_get_queue_stats_tx(struct net_device *dev, int idx,
> + struct netdev_queue_stats_tx *stats)
> +{
[ ... ]
> + wx_ring_get_tx_stats(ring, &ring_stats);
> + stats->packets = ring_stats.queue.packets;
> + stats->bytes = ring_stats.queue.bytes;
> + stats->stop = ring_stats.tx.stop;
> + stats->wake = ring_stats.tx.wake;
[Severity: Medium]
Can tx-wake end up larger than tx-stop here?
wx_maybe_stop_tx() always stops the queue with netif_stop_subqueue().
However, it only increments stop_queue when the re-check still finds too
few descriptors. On the reprieve path it counts a restart but not the
stop that came just before it:
netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
...
if (likely(wx_desc_unused(tx_ring) < size)) {
...
++tx_ring->tx_stats.stop_queue;
...
return -EBUSY;
}
/* A reprieve! - use start_queue because it doesn't call schedule */
netif_start_subqueue(tx_ring->netdev, tx_ring->queue_index);
...
++tx_ring->tx_stats.restart_queue;
wx_ring_get_tx_stats() then reports:
stats->tx.stop = ring->tx_stats.stop_queue;
stats->tx.wake = ring->tx_stats.restart_queue +
restart_queue_napi;
A race with TX completion can make the gap larger:
CPU1 (xmit) CPU2 (NAPI)
wx_maybe_stop_tx()
netif_stop_subqueue()
wx_clean_tx_irq()
__netif_subqueue_stopped()
netif_wake_subqueue()
++restart_queue_napi
wx_desc_unused() >= size
netif_start_subqueue()
++restart_queue
That is one real pause, zero counted stops and two counted wakes.
netdev.yaml defines tx-stop as the number of times the driver paused
accepting packets and tx-wake as the number of times it restarted, so
consumers would expect wake <= stop. For comparison, gve_tx_dqo.c counts a
stop before the reprieve check and a wake on the reprieve.
The earlier "net: libwx: preserve queue stats across reconfiguration"
commit chose this deliberately ("the reprieve path only adds a wake").
Once the counters are mapped to the tx-stop/tx-wake uAPI, though, the
pair no longer balances.
Would it make sense to count the stop unconditionally after
netif_stop_subqueue() in wx_maybe_stop_tx()?
The retained totals that wx_get_base_stats() reports in tx->stop and
tx->wake have the same asymmetry. The later "net: wangxun: expose VF
stats through ndo_get_stats64" commit in the series does not touch
wx_maybe_stop_tx() or the stat_ops.
> +
> +out:
> + rcu_read_unlock();
> +}
> +
> +static void wx_get_base_stats(struct net_device *dev,
> + struct netdev_queue_stats_rx *rx,
> + struct netdev_queue_stats_tx *tx)
> +{
> + struct wx *wx = netdev_priv(dev);
> +
> + /* Read the retained values the same way as wx_get_stats64(), so that
> + * they cannot be updated while they are being gathered.
> + */
> + spin_lock(&wx->hw_stats_lock);
> + rx->bytes = wx->qstats_base_rx.bytes;
> + rx->packets = wx->qstats_base_rx.packets;
> + rx->alloc_fail = wx->qstats_base_rx_stats.alloc_rx_buff_failed;
> + rx->csum_unnecessary =
> + wx->qstats_base_rx_stats.csum_unnecessary_cnt;
> + rx->csum_bad = wx->qstats_base_rx_stats.csum_err;
[Severity: Low]
The commit message says:
The PF-only hardware counters that have no netdev-genl attribute stay
available through ethtool -S, among them rdmdrop, which the driver
reports as rx_no_dma_resources;
Is that accurate for rdmdrop? wx_update_stats() adds in the
clear-on-read WX_RDM_DRP_PKT register:
hwstats->rdmdrop += rd32(wx, WX_RDM_DRP_PKT);
ethtool -S labels this counter rx_no_dma_resources.
netdev.yaml defines rx-hw-drop-overruns as "Number of packets dropped
due to transient lack of resources, such as buffer space, host
descriptors etc.". rx-hw-drops also covers packets that entered the
device but never left it.
include/net/netdev_queues.h allows get_base_stats() to report
device-level counters that belong to no queue. sfc and bnge already
report similar counters as hw_drop_overruns.
Could wx_get_base_stats() fill rx->hw_drop_overruns from rdmdrop on the
PF (!wx->is_vf)?
WX_RDM_DRP_PKT may also count drops on VF pools when SR-IOV is enabled.
If that is the reason to leave it out, could the commit message say so
instead? The rest of the series does not change this.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130083407.78429-1-mengyuanlou%40net-swift.com
Re: [PATCH net-next v2 2/3] net: wangxun: expose queue stats via netdev-genl
Author: mengyuanlou
Date: Wed, 02 Dec 2026 02:51
Date: Wed, 02 Dec 2026 02:51
249 lines
17963 bytes
17963 bytes
> 2026年12月1日 16:36,netdev-bot+sashiko@kernel.org 写道:
>
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 2
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] wx_get_queue_stats_tx() and wx_get_base_stats() export TX
> stop/wake counters through netdev-genl, but the two counters are not…
> - [Low] The commit message says the PF-only hardware counters left in
> ethtool -S "have no netdev-genl attribute" and names rdmdrop…
> - [Low] wx_get_queue_stats_rx() and wx_get_base_stats() fill the netdev-
> genl rx-alloc-fail attribute from rx_stats.alloc_rx_buff_failed.
>
> --
>
> net: wangxun: expose queue stats via netdev-genl
>
> This patch implements netdev_stat_ops in libwx and registers them for the
> ngbe, ngbevf, txgbe and txgbevf netdevs. Per-queue packet, byte, RX
> allocation failure, checksum and TX stop/wake counters become available
> through netdev-genl. get_base_stats() reports the counters kept when a
> queue vector is torn down.
>
>> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
>> index 2868232792588..0502b5d8e96e8 100644
>> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
>> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
>
> [ ... ]
>
>> @@ -3193,6 +3194,95 @@ void wx_get_stats64(struct net_device *netdev,
>> }
>> EXPORT_SYMBOL(wx_get_stats64);
>>
>> +static void wx_get_queue_stats_rx(struct net_device *dev, int idx,
>> + struct netdev_queue_stats_rx *stats)
>> +{
>
> [ ... ]
>
>> + wx_ring_get_rx_stats(ring, &ring_stats);
>> + stats->packets = ring_stats.queue.packets;
>> + stats->bytes = ring_stats.queue.bytes;
>> + stats->alloc_fail = ring_stats.rx.alloc_rx_buff_failed;
>
> [Severity: Low]
> Does rx_stats.alloc_rx_buff_failed cover everything rx-alloc-fail is
> defined to count?
>
> netdev.yaml describes rx-alloc-fail as "Number of times skb or buffer
> allocation failed on the Rx datapath". The only place that increments
> alloc_rx_buff_failed is wx_clean_rx_irq(), when wx_build_skb() fails to
> allocate an skb:
>
> skb = wx_build_skb(rx_ring, rx_buffer, rx_desc);
>
> /* exit if we failed to retrieve a buffer */
> if (!skb) {
> rx_stats.alloc_rx_buff_failed++;
> break;
> }
>
> When a page pool refill fails in wx_alloc_mapped_page(), the function
> returns without updating any counter:
>
> page = page_pool_dev_alloc_pages(rx_ring->page_pool);
> if (unlikely(!page))
> return false;
>
> wx_alloc_rx_buffers() then just stops refilling.
>
> Under memory pressure, could rx-alloc-fail read 0 while ring refills are
> failing? wx_get_base_stats() exports the same counter through
> qstats_base_rx_stats.alloc_rx_buff_failed. The rest of the series does
> not change this.
>
>> + stats->csum_unnecessary = ring_stats.rx.csum_unnecessary_cnt;
>> + stats->csum_bad = ring_stats.rx.csum_err;
>> +
>> +out:
>> + rcu_read_unlock();
>> +}
>> +
>> +static void wx_get_queue_stats_tx(struct net_device *dev, int idx,
>> + struct netdev_queue_stats_tx *stats)
>> +{
>
> [ ... ]
>
>> + wx_ring_get_tx_stats(ring, &ring_stats);
>> + stats->packets = ring_stats.queue.packets;
>> + stats->bytes = ring_stats.queue.bytes;
>> + stats->stop = ring_stats.tx.stop;
>> + stats->wake = ring_stats.tx.wake;
>
> [Severity: Medium]
> Can tx-wake end up larger than tx-stop here?
>
> wx_maybe_stop_tx() always stops the queue with netif_stop_subqueue().
> However, it only increments stop_queue when the re-check still finds too
> few descriptors. On the reprieve path it counts a restart but not the
> stop that came just before it:
>
> netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
> ...
> if (likely(wx_desc_unused(tx_ring) < size)) {
> ...
> ++tx_ring->tx_stats.stop_queue;
> ...
> return -EBUSY;
> }
u64_stats_update_begin(&tx_ring->xmit_syncp);
++tx_ring->tx_stats.stop_queue;
u64_stats_update_end(&tx_ring->xmit_syncp);
That’s right, tx_stats.stop_queue should not in "likely(wx_desc_unused(tx_ring) < size)" check.
>
> /* A reprieve! - use start_queue because it doesn't call schedule */
> netif_start_subqueue(tx_ring->netdev, tx_ring->queue_index);
> ...
> ++tx_ring->tx_stats.restart_queue;
>
> wx_ring_get_tx_stats() then reports:
>
> stats->tx.stop = ring->tx_stats.stop_queue;
> stats->tx.wake = ring->tx_stats.restart_queue +
> restart_queue_napi;
>
> A race with TX completion can make the gap larger:
>
> CPU1 (xmit) CPU2 (NAPI)
> wx_maybe_stop_tx()
> netif_stop_subqueue()
> wx_clean_tx_irq()
> __netif_subqueue_stopped()
> netif_wake_subqueue()
> ++restart_queue_napi
> wx_desc_unused() >= size
> netif_start_subqueue()
> ++restart_queue
>
> That is one real pause, zero counted stops and two counted wakes.
>
> netdev.yaml defines tx-stop as the number of times the driver paused
> accepting packets and tx-wake as the number of times it restarted, so
> consumers would expect wake <= stop. For comparison, gve_tx_dqo.c counts a
> stop before the reprieve check and a wake on the reprieve.
>
> The earlier "net: libwx: preserve queue stats across reconfiguration"
> commit chose this deliberately ("the reprieve path only adds a wake").
> Once the counters are mapped to the tx-stop/tx-wake uAPI, though, the
> pair no longer balances.
>
> Would it make sense to count the stop unconditionally after
> netif_stop_subqueue() in wx_maybe_stop_tx()?
>
> The retained totals that wx_get_base_stats() reports in tx->stop and
> tx->wake have the same asymmetry. The later "net: wangxun: expose VF
> stats through ndo_get_stats64" commit in the series does not touch
> wx_maybe_stop_tx() or the stat_ops.
>
>> +
>> +out:
>> + rcu_read_unlock();
>> +}
>> +
>> +static void wx_get_base_stats(struct net_device *dev,
>> + struct netdev_queue_stats_rx *rx,
>> + struct netdev_queue_stats_tx *tx)
>> +{
>> + struct wx *wx = netdev_priv(dev);
>> +
>> + /* Read the retained values the same way as wx_get_stats64(), so that
>> + * they cannot be updated while they are being gathered.
>> + */
>> + spin_lock(&wx->hw_stats_lock);
>> + rx->bytes = wx->qstats_base_rx.bytes;
>> + rx->packets = wx->qstats_base_rx.packets;
>> + rx->alloc_fail = wx->qstats_base_rx_stats.alloc_rx_buff_failed;
>> + rx->csum_unnecessary =
>> + wx->qstats_base_rx_stats.csum_unnecessary_cnt;
>> + rx->csum_bad = wx->qstats_base_rx_stats.csum_err;
>
> [Severity: Low]
> The commit message says:
>
> The PF-only hardware counters that have no netdev-genl attribute stay
> available through ethtool -S, among them rdmdrop, which the driver
> reports as rx_no_dma_resources;
>
> Is that accurate for rdmdrop? wx_update_stats() adds in the
> clear-on-read WX_RDM_DRP_PKT register:
>
> hwstats->rdmdrop += rd32(wx, WX_RDM_DRP_PKT);
>
> ethtool -S labels this counter rx_no_dma_resources.
>
> netdev.yaml defines rx-hw-drop-overruns as "Number of packets dropped
> due to transient lack of resources, such as buffer space, host
> descriptors etc.". rx-hw-drops also covers packets that entered the
> device but never left it.
>
> include/net/netdev_queues.h allows get_base_stats() to report
> device-level counters that belong to no queue. sfc and bnge already
> report similar counters as hw_drop_overruns.
>
> Could wx_get_base_stats() fill rx->hw_drop_overruns from rdmdrop on the
> PF (!wx->is_vf)?
>
> WX_RDM_DRP_PKT may also count drops on VF pools when SR-IOV is enabled.
> If that is the reason to leave it out, could the commit message say so
> instead? The rest of the series does not change this.
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130083407.78429-1-mengyuanlou%40net-swift.com
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads