From: Simon Horman <horms@kernel.org>
To: Rosen Penev <rosenp@gmail.com>
Cc: netdev@vger.kernel.org, Madalin Bucur <madalin.bucur@nxp.com>,
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>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
open list <linux-kernel@vger.kernel.org>,
"open list:FREESCALE QUICC ENGINE UCC ETHERNET DRIVER"
<linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH net-next] net: freescale: use ethtool string helpers
Date: Sat, 26 Oct 2024 16:07:00 +0100 [thread overview]
Message-ID: <20241026150700.GF1507976@kernel.org> (raw)
In-Reply-To: <CAKxU2N98hnVAE9WF72HhxzVEfhnRAgMykVgBErL9b3gupqqrxQ@mail.gmail.com>
On Fri, Oct 25, 2024 at 12:32:27PM -0700, Rosen Penev wrote:
> On Fri, Oct 25, 2024 at 5:57 AM Simon Horman <horms@kernel.org> wrote:
> >
> > On Thu, Oct 24, 2024 at 01:52:57PM -0700, Rosen Penev wrote:
> > > The latter is the preferred way to copy ethtool strings.
> > >
> > > Avoids manually incrementing the pointer. Cleans up the code quite well.
> > >
> > > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> >
> > ...
> >
> > > diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > index b0060cf96090..10c5fa4d23d2 100644
> > > --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
> > > @@ -243,38 +243,24 @@ static void dpaa_get_ethtool_stats(struct net_device *net_dev,
> > > static void dpaa_get_strings(struct net_device *net_dev, u32 stringset,
> > > u8 *data)
> > > {
> > > - unsigned int i, j, num_cpus, size;
> > > - char string_cpu[ETH_GSTRING_LEN];
> > > - u8 *strings;
> > > + unsigned int i, j, num_cpus;
> > >
> > > - memset(string_cpu, 0, sizeof(string_cpu));
> > > - strings = data;
> > > - num_cpus = num_online_cpus();
> > > - size = DPAA_STATS_GLOBAL_LEN * ETH_GSTRING_LEN;
> > > + num_cpus = num_online_cpus();
> > >
> > > for (i = 0; i < DPAA_STATS_PERCPU_LEN; i++) {
> > > - for (j = 0; j < num_cpus; j++) {
> > > - snprintf(string_cpu, ETH_GSTRING_LEN, "%s [CPU %d]",
> > > - dpaa_stats_percpu[i], j);
> > > - memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > - strings += ETH_GSTRING_LEN;
> > > - }
> > > - snprintf(string_cpu, ETH_GSTRING_LEN, "%s [TOTAL]",
> > > - dpaa_stats_percpu[i]);
> > > - memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > - strings += ETH_GSTRING_LEN;
> > > - }
> > > - for (j = 0; j < num_cpus; j++) {
> > > - snprintf(string_cpu, ETH_GSTRING_LEN,
> > > - "bpool [CPU %d]", j);
> > > - memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > - strings += ETH_GSTRING_LEN;
> > > + for (j = 0; j < num_cpus; j++)
> > > + ethtool_sprintf(&data, "%s [CPU %d]",
> > > + dpaa_stats_percpu[i], j);
> > > +
> > > + ethtool_sprintf(&data, "%s [TOTAL]", dpaa_stats_percpu[i]);
> > > }
> > > - snprintf(string_cpu, ETH_GSTRING_LEN, "bpool [TOTAL]");
> > > - memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> > > - strings += ETH_GSTRING_LEN;
> > > + for (i = 0; j < num_cpus; i++)
> >
> > Perhaps this should consistently use i, rather than i and j:
> >
> > for (i = 0; i < num_cpus; i++)
> >
> > Flagged by W=1 builds with clang-18.
> I really need to compile test this on a PPC system.
Depending on your aims and hardware availability,
cross compiling may be easier.
But in any case, I don't think this problem relates to PPC.
> >
> > > + ethtool_sprintf(&data, "bpool [CPU %d]", i);
> > > +
> > > + ethtool_puts(&data, "bpool [TOTAL]");
> > >
> > > - memcpy(strings, dpaa_stats_global, size);
> > > + for (i = 0; i < DPAA_STATS_GLOBAL_LEN; i++)
> > > + ethtool_puts(&data, dpaa_stats_global[i]);
> > > }
> > >
> > > static int dpaa_get_hash_opts(struct net_device *dev,
> >
> > ...
>
next prev parent reply other threads:[~2024-10-26 15:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 20:52 [PATCH net-next] net: freescale: use ethtool string helpers Rosen Penev
2024-10-25 12:57 ` Simon Horman
2024-10-25 19:32 ` Rosen Penev
2024-10-26 15:07 ` Simon Horman [this message]
2024-10-28 2:31 ` Michael Ellerman
2024-10-28 3:24 ` Rosen Penev
2024-10-25 14:56 ` kernel test robot
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=20241026150700.GF1507976@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rosenp@gmail.com \
--cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).