[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bbeede5b-3568-4ae6-a844-88ff1e06359d@linux.ibm.com>
Date: Wed, 23 Oct 2024 13:58:00 -0500
From: Nick Child <nnac123@...ux.ibm.com>
To: Rosen Penev <rosenp@...il.com>, netdev@...r.kernel.org
Cc: Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin
<npiggin@...il.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Naveen N Rao <naveen@...nel.org>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Haren Myneni <haren@...ux.ibm.com>,
Rick Lindsley <ricklind@...ux.ibm.com>,
Thomas Falcon <tlfalcon@...ux.ibm.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"
<linuxppc-dev@...ts.ozlabs.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] ibmvnic: use ethtool string helpers
On 10/22/24 15:32, Rosen Penev wrote:
> They are the prefered way to copy ethtool strings.
>
> Avoids manually incrementing the data pointer.
>
> Signed-off-by: Rosen Penev <rosenp@...il.com>
> ---
> drivers/net/ethernet/ibm/ibmvnic.c | 30 +++++++++---------------------
> 1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index cca2ed6ad289..e95ae0d39948 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -3808,32 +3808,20 @@ static void ibmvnic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
> if (stringset != ETH_SS_STATS)
> return;
>
> - for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++, data += ETH_GSTRING_LEN)
> - memcpy(data, ibmvnic_stats[i].name, ETH_GSTRING_LEN);
> + for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++)
> + ethtool_puts(&data, ibmvnic_stats[i].name);
>
> for (i = 0; i < adapter->req_tx_queues; i++) {
> - snprintf(data, ETH_GSTRING_LEN, "tx%d_batched_packets", i);
> - data += ETH_GSTRING_LEN;
> -
> - snprintf(data, ETH_GSTRING_LEN, "tx%d_direct_packets", i);
> - data += ETH_GSTRING_LEN;
> -
> - snprintf(data, ETH_GSTRING_LEN, "tx%d_bytes", i);
> - data += ETH_GSTRING_LEN;
> -
> - snprintf(data, ETH_GSTRING_LEN, "tx%d_dropped_packets", i);
> - data += ETH_GSTRING_LEN;
> + ethtool_sprintf(&data, "tx%d_batched_packets", i);
> + ethtool_sprintf(&data, "tx%d_direct_packets", i);
> + ethtool_sprintf(&data, "tx%d_bytes", i);
> + ethtool_sprintf(&data, "tx%d_dropped_packets", i);
> }
>
> for (i = 0; i < adapter->req_rx_queues; i++) {
> - snprintf(data, ETH_GSTRING_LEN, "rx%d_packets", i);
> - data += ETH_GSTRING_LEN;
> -
> - snprintf(data, ETH_GSTRING_LEN, "rx%d_bytes", i);
> - data += ETH_GSTRING_LEN;
> -
> - snprintf(data, ETH_GSTRING_LEN, "rx%d_interrupts", i);
> - data += ETH_GSTRING_LEN;
> + ethtool_sprintf(&data, "rx%d_packets", i);
> + ethtool_sprintf(&data, "rx%d_bytes", i);
> + ethtool_sprintf(&data, "rx%d_interrupts", i);
> }
> }
>
Tested-by: Nick Child <nnac123@...ux.ibm.com>
Powered by blists - more mailing lists