mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Child <nnac123@linux.ibm.com>
To: Rosen Penev <rosenp@gmail.com>, netdev@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Naveen N Rao <naveen@kernel.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Haren Myneni <haren@linux.ibm.com>,
	Rick Lindsley <ricklind@linux.ibm.com>,
	Thomas Falcon <tlfalcon@linux.ibm.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>,
	"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"
	<linuxppc-dev@lists.ozlabs.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] ibmvnic: use ethtool string helpers
Date: Wed, 23 Oct 2024 13:58:00 -0500	[thread overview]
Message-ID: <bbeede5b-3568-4ae6-a844-88ff1e06359d@linux.ibm.com> (raw)
In-Reply-To: <20241022203240.391648-1-rosenp@gmail.com>



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@gmail.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@linux.ibm.com>

  reply	other threads:[~2024-10-23 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22 20:32 Rosen Penev
2024-10-23 18:58 ` Nick Child [this message]
2024-10-24 15:13 ` Simon Horman
2024-10-29 23:00 ` 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=bbeede5b-3568-4ae6-a844-88ff1e06359d@linux.ibm.com \
    --to=nnac123@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=christophe.leroy@csgroup.eu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=haren@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ricklind@linux.ibm.com \
    --cc=rosenp@gmail.com \
    --cc=tlfalcon@linux.ibm.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

all inboxes | Powered by JetHome®