From: Breno Leitao <leitao@debian.org>
To: Jakub Kicinski <kuba@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, David Wei <dw@davidwei.uk>,
Shuah Khan <shuah@kernel.org>, Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
gustavold@gmail.com, Joe Damato <joe@dama.to>
Subject: [PATCH net-next v4 3/4] net: add dev_dstats_rx_dropped_add() helper
Date: Wed, 18 Jun 2025 01:32:44 -0700 [thread overview]
Message-ID: <20250618-netdevsim_stat-v4-3-19fe0d35e28e@debian.org> (raw)
In-Reply-To: <20250618-netdevsim_stat-v4-0-19fe0d35e28e@debian.org>
Introduce the dev_dstats_rx_dropped_add() helper to allow incrementing
the rx_drops per-CPU statistic by an arbitrary value, rather than just
one. This is useful for drivers or code paths that need to account for
multiple dropped packets at once, such as when dropping entire queues.
Reviewed-by: Joe Damato <joe@dama.to>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
include/linux/netdevice.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9cbc4e54b7e4a..03c26bb0fbbef 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3016,6 +3016,16 @@ static inline void dev_dstats_rx_dropped(struct net_device *dev)
u64_stats_update_end(&dstats->syncp);
}
+static inline void dev_dstats_rx_dropped_add(struct net_device *dev,
+ unsigned int packets)
+{
+ struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
+
+ u64_stats_update_begin(&dstats->syncp);
+ u64_stats_add(&dstats->rx_drops, packets);
+ u64_stats_update_end(&dstats->syncp);
+}
+
static inline void dev_dstats_tx_add(struct net_device *dev,
unsigned int len)
{
--
2.47.1
next prev parent reply other threads:[~2025-06-18 8:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 8:32 [PATCH net-next v4 0/4] netdevsim: implement RX statistics using NETDEV_PCPU_STAT_DSTATS Breno Leitao
2025-06-18 8:32 ` [PATCH net-next v4 1/4] netdevsim: migrate to dstats stats collection Breno Leitao
2025-06-18 8:32 ` [PATCH net-next v4 2/4] netdevsim: collect statistics at RX side Breno Leitao
2025-06-18 8:32 ` Breno Leitao [this message]
2025-06-18 8:32 ` [PATCH net-next v4 4/4] netdevsim: account dropped packet length in stats on queue free Breno Leitao
2025-06-19 23:20 ` [PATCH net-next v4 0/4] netdevsim: implement RX statistics using NETDEV_PCPU_STAT_DSTATS patchwork-bot+netdevbpf
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=20250618-netdevsim_stat-v4-3-19fe0d35e28e@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=gustavold@gmail.com \
--cc=horms@kernel.org \
--cc=joe@dama.to \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).