All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhixing Chen <running910@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Qingfang Deng <qingfang.deng@linux.dev>,
	linux-ppp@vger.kernel.org, netdev@vger.kernel.org,
	Zhixing Chen <running910@gmail.com>
Subject: [PATCH net-next] ppp: reuse ppp_get_stats64() for ioctl stats
Date: Tue, 14 Jul 2026 17:19:41 +0800	[thread overview]
Message-ID: <20260714091941.33783-1-running910@gmail.com> (raw)

ppp_get_stats() open-codes the per-cpu tstats aggregation even though
ppp_get_stats64() already collects the packet, byte and error counters
needed by the legacy SIOCGPPPSTATS ioctl path.

Reuse ppp_get_stats64() when filling struct ppp_stats. This keeps the
ioctl stats path consistent with the netdev stats64 path and removes the
open-coded per-cpu stats aggregation from the ioctl path.

Signed-off-by: Zhixing Chen <running910@gmail.com>
---

This is meant as a small cleanup. The ioctl path and the netdev stats64
path already use the same underlying counters, so this just makes the
ioctl path reuse ppp_get_stats64() instead of open-coding the per-cpu
aggregation locally.

---
 drivers/net/ppp/ppp_generic.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 57c68efa5ff8..53e6d40193fd 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -3303,26 +3303,17 @@ find_compressor(int type)
 static void
 ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
 {
+	struct rtnl_link_stats64 stats64 = {};
 	struct slcompress *vj = ppp->vj;
-	int cpu;
 
 	memset(st, 0, sizeof(*st));
-	for_each_possible_cpu(cpu) {
-		struct pcpu_sw_netstats *p = per_cpu_ptr(ppp->dev->tstats, cpu);
-		u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
-
-		rx_packets = u64_stats_read(&p->rx_packets);
-		rx_bytes = u64_stats_read(&p->rx_bytes);
-		tx_packets = u64_stats_read(&p->tx_packets);
-		tx_bytes = u64_stats_read(&p->tx_bytes);
-
-		st->p.ppp_ipackets += rx_packets;
-		st->p.ppp_ibytes += rx_bytes;
-		st->p.ppp_opackets += tx_packets;
-		st->p.ppp_obytes += tx_bytes;
-	}
-	st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
-	st->p.ppp_oerrors = ppp->dev->stats.tx_errors;
+	ppp_get_stats64(ppp->dev, &stats64);
+	st->p.ppp_ipackets = stats64.rx_packets;
+	st->p.ppp_ibytes = stats64.rx_bytes;
+	st->p.ppp_opackets = stats64.tx_packets;
+	st->p.ppp_obytes = stats64.tx_bytes;
+	st->p.ppp_ierrors = stats64.rx_errors;
+	st->p.ppp_oerrors = stats64.tx_errors;
 	if (!vj)
 		return;
 	st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
-- 
2.34.1


                 reply	other threads:[~2026-07-14  9:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260714091941.33783-1-running910@gmail.com \
    --to=running910@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-ppp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qingfang.deng@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.