From: Mingming Cao <mmc@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Mingming Cao <mmc@linux.ibm.com>,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
nnac123@linux.ibm.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, linuxppc-dev@lists.ozlabs.org,
horms@kernel.org, davemarq@linux.ibm.com, haren@linux.ibm.com,
ricklind@linux.ibm.com, bjking1@linux.ibm.com,
shaik.abdulla1@ibm.com, willemb@google.com
Subject: [PATCH net-next v9 11/13] ibmveth: Report per-queue statistics through netdev_stat_ops
Date: Tue, 1 Dec 2026 11:02:14 -0800 [thread overview]
Message-ID: <20261201190216.62407-12-mmc@linux.ibm.com> (raw)
In-Reply-To: <20261201190216.62407-1-mmc@linux.ibm.com>
ip -s link and ethtool -S only show device totals, so they cannot
show whether traffic is spread over the queues or which queue drops.
Implement netdev_stat_ops so qstats-get shows each queue: packets and
bytes, and for RX alloc_fail and PHYP's no-buffer drops as hw_drops
and hw_drop_overruns. This already covers today's TX queues.
RX alloc_fail counts failed skb allocations both when refilling
buffers and for copybreak, which then passes the frame up in its
pool buffer. Nothing counted the copybreak failures before.
An invalid buffer PHYP hands back carries no frame, so it is not a
hw_drop; it stays in ethtool -S as rx_invalid_buffer. A frame PHYP
delivered but the driver then dropped is rx_dropped, not a hw_drop.
TX hw_drops is left unset, because the TX drop count includes frames
rejected before they reached PHYP. Queues above the live count are
reported in the base stats, so the qstats total still matches
ndo_get_stats64 after the queue count goes down.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 75 +++++++++++++++++++++++++++++-
drivers/net/ethernet/ibm/ibmveth.h | 1 +
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 56b645ffb18c..f30d8ba23320 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -37,6 +37,7 @@
#include <asm/firmware.h>
#include <net/tcp.h>
#include <net/ip6_checksum.h>
+#include <net/netdev_queues.h>
#include "ibmveth.h"
@@ -2577,8 +2578,11 @@ static void ibmveth_poll_deliver_frame(struct napi_struct *napi,
}
new_skb = NULL;
- if (length < rx_copybreak)
+ if (length < rx_copybreak) {
new_skb = netdev_alloc_skb(netdev, length);
+ if (unlikely(!new_skb))
+ IBMVETH_STAT_INC(rxs->copybreak_no_mem);
+ }
if (new_skb) {
skb_copy_to_linear_data(new_skb, skb->data + offset, length);
@@ -2928,6 +2932,74 @@ static void ibmveth_get_stats64(struct net_device *dev,
}
}
+static void ibmveth_get_queue_stats_rx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_rx *stats)
+{
+ struct ibmveth_adapter *adapter = netdev_priv(dev);
+ u64 no_buffer;
+
+ stats->packets = READ_ONCE(adapter->rx_qstats[idx].packets);
+ stats->bytes = READ_ONCE(adapter->rx_qstats[idx].bytes);
+ /* Frames PHYP dropped for lack of a posted buffer: the last sample
+ * of the live page plus pages this queue already released.
+ */
+ no_buffer = ibmveth_rx_no_buffer_total(adapter, idx);
+ stats->hw_drops = no_buffer;
+ stats->hw_drop_overruns = no_buffer;
+ stats->alloc_fail =
+ READ_ONCE(adapter->rx_qstats[idx].replenish_no_mem) +
+ READ_ONCE(adapter->rx_qstats[idx].copybreak_no_mem);
+}
+
+static void ibmveth_get_queue_stats_tx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_tx *stats)
+{
+ struct ibmveth_adapter *adapter = netdev_priv(dev);
+
+ stats->packets = READ_ONCE(adapter->tx_qstats[idx].packets);
+ stats->bytes = READ_ONCE(adapter->tx_qstats[idx].bytes);
+ /* TX hw_drops left unset: dropped_packets includes
+ * software xmit rejects that never reached PHYP.
+ */
+}
+
+/**
+ * ibmveth_get_base_stats - account for traffic not on a live queue
+ * @dev: network device
+ * @rx: RX base statistics storage
+ * @tx: TX base statistics storage
+ *
+ * The core sums get_queue_stats_{rx,tx}() only below
+ * real_num_{rx,tx}_queues, while ibmveth_get_stats64() walks every
+ * slot. Report the slots at or above real_num here so the two agree
+ * after the queue count goes down.
+ *
+ * Every field the queue callbacks set must be set here too: the core
+ * drops a field from the device total if the base leaves it unset.
+ */
+static void ibmveth_get_base_stats(struct net_device *dev,
+ struct netdev_queue_stats_rx *rx,
+ struct netdev_queue_stats_tx *tx)
+{
+ rx->packets = 0;
+ rx->bytes = 0;
+ rx->alloc_fail = 0;
+ rx->hw_drops = 0;
+ rx->hw_drop_overruns = 0;
+ tx->packets = 0;
+ tx->bytes = 0;
+
+ netdev_stat_queue_sum(dev, dev->real_num_rx_queues,
+ IBMVETH_MAX_RX_QUEUES, rx,
+ dev->real_num_tx_queues, IBMVETH_MAX_QUEUES, tx);
+}
+
+static const struct netdev_stat_ops ibmveth_stat_ops = {
+ .get_queue_stats_rx = ibmveth_get_queue_stats_rx,
+ .get_queue_stats_tx = ibmveth_get_queue_stats_tx,
+ .get_base_stats = ibmveth_get_base_stats,
+};
+
static const struct net_device_ops ibmveth_netdev_ops = {
.ndo_open = ibmveth_open,
.ndo_stop = ibmveth_close,
@@ -3032,6 +3104,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
netdev->irq = dev->irq;
netdev->netdev_ops = &ibmveth_netdev_ops;
netdev->ethtool_ops = &netdev_ethtool_ops;
+ netdev->stat_ops = &ibmveth_stat_ops;
SET_NETDEV_DEV(netdev, &dev->dev);
netdev->hw_features = NETIF_F_SG;
if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) {
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index d6d28b75dd99..588209144de7 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -260,6 +260,7 @@ struct ibmveth_rx_queue_stats {
u64 replenish_no_mem;
u64 replenish_add_buff_failure;
u64 replenish_add_buff_success;
+ u64 copybreak_no_mem;
} ____cacheline_aligned_in_smp;
/* Per-queue TX counters; serialized by the stack's per-queue TX lock. */
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-12-01 19:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 19:02 [PATCH net-next v9 00/13] ibmveth: Add multi-queue RX support Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 01/13] ibmveth: Keep a buffer pool enabled after its allocation fails Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 02/13] ibmveth: Keep TX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 03/13] powerpc/pseries: Add hcall numbers for multi-queue virtual ethernet Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 04/13] ibmveth: Add RX queue handles Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 05/13] ibmveth: Register subordinate RX queues Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 06/13] ibmveth: Add subordinate RX queue interrupt control Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 07/13] ibmveth: Add the MQ RX buffer submit hypercall Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 08/13] ibmveth: Start every RX queue on open and resume Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 09/13] ibmveth: Keep RX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 10/13] ibmveth: Keep rx_no_buffer across ifdown/up Mingming Cao
2026-12-01 19:02 ` Mingming Cao [this message]
2026-12-01 19:02 ` [PATCH net-next v9 12/13] ibmveth: Enable multi-queue RX Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 13/13] ibmveth: Allow changing the RX queue count Mingming Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201190216.62407-12-mmc@linux.ibm.com \
--to=mmc@linux.ibm.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjking1@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=davemarq@linux.ibm.com \
--cc=edumazet@kernel.org \
--cc=haren@linux.ibm.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=nnac123@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pabeni@redhat.com \
--cc=ricklind@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=shaik.abdulla1@ibm.com \
--cc=sshegde@linux.ibm.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox