* [PATCH] net: fjes: use ethtool string helpers
@ 2024-10-29 23:27 Rosen Penev
2024-10-29 23:28 ` Rosen Penev
2024-11-01 2:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2024-10-29 23:27 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rosen Penev, Simon Horman, open list
The latter is the preferred way to copy ethtool strings.
Avoids manually incrementing the pointer.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v2: remove p variable and reduce indentation
drivers/net/fjes/fjes_ethtool.c | 64 ++++++++++++---------------------
1 file changed, 23 insertions(+), 41 deletions(-)
diff --git a/drivers/net/fjes/fjes_ethtool.c b/drivers/net/fjes/fjes_ethtool.c
index 19c99529566b..70c53f33d857 100644
--- a/drivers/net/fjes/fjes_ethtool.c
+++ b/drivers/net/fjes/fjes_ethtool.c
@@ -87,49 +87,31 @@ static void fjes_get_strings(struct net_device *netdev,
{
struct fjes_adapter *adapter = netdev_priv(netdev);
struct fjes_hw *hw = &adapter->hw;
- u8 *p = data;
int i;
- switch (stringset) {
- case ETH_SS_STATS:
- for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
- memcpy(p, fjes_gstrings_stats[i].stat_string,
- ETH_GSTRING_LEN);
- p += ETH_GSTRING_LEN;
- }
- for (i = 0; i < hw->max_epid; i++) {
- if (i == hw->my_epid)
- continue;
- sprintf(p, "ep%u_com_regist_buf_exec", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_com_unregist_buf_exec", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_send_intr_rx", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_send_intr_unshare", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_send_intr_zoneupdate", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_recv_intr_rx", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_recv_intr_unshare", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_recv_intr_stop", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_recv_intr_zoneupdate", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_tx_buffer_full", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_tx_dropped_not_shared", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_tx_dropped_ver_mismatch", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_tx_dropped_buf_size_mismatch", i);
- p += ETH_GSTRING_LEN;
- sprintf(p, "ep%u_tx_dropped_vlanid_mismatch", i);
- p += ETH_GSTRING_LEN;
- }
- break;
+ if (stringset != ETH_SS_STATS)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++)
+ ethtool_puts(&data, fjes_gstrings_stats[i].stat_string);
+
+ for (i = 0; i < hw->max_epid; i++) {
+ if (i == hw->my_epid)
+ continue;
+ ethtool_sprintf(&data, "ep%u_com_regist_buf_exec", i);
+ ethtool_sprintf(&data, "ep%u_com_unregist_buf_exec", i);
+ ethtool_sprintf(&data, "ep%u_send_intr_rx", i);
+ ethtool_sprintf(&data, "ep%u_send_intr_unshare", i);
+ ethtool_sprintf(&data, "ep%u_send_intr_zoneupdate", i);
+ ethtool_sprintf(&data, "ep%u_recv_intr_rx", i);
+ ethtool_sprintf(&data, "ep%u_recv_intr_unshare", i);
+ ethtool_sprintf(&data, "ep%u_recv_intr_stop", i);
+ ethtool_sprintf(&data, "ep%u_recv_intr_zoneupdate", i);
+ ethtool_sprintf(&data, "ep%u_tx_buffer_full", i);
+ ethtool_sprintf(&data, "ep%u_tx_dropped_not_shared", i);
+ ethtool_sprintf(&data, "ep%u_tx_dropped_ver_mismatch", i);
+ ethtool_sprintf(&data, "ep%u_tx_dropped_buf_size_mismatch", i);
+ ethtool_sprintf(&data, "ep%u_tx_dropped_vlanid_mismatch", i);
}
}
--
2.47.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fjes: use ethtool string helpers
2024-10-29 23:27 [PATCH] net: fjes: use ethtool string helpers Rosen Penev
@ 2024-10-29 23:28 ` Rosen Penev
2024-11-01 2:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Rosen Penev @ 2024-10-29 23:28 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, open list
On Tue, Oct 29, 2024 at 4:27 PM Rosen Penev <rosenp@gmail.com> wrote:
>
> The latter is the preferred way to copy ethtool strings.
>
> Avoids manually incrementing the pointer.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> v2: remove p variable and reduce indentation
agh, forgot to put net-next and v2.
> drivers/net/fjes/fjes_ethtool.c | 64 ++++++++++++---------------------
> 1 file changed, 23 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/fjes/fjes_ethtool.c b/drivers/net/fjes/fjes_ethtool.c
> index 19c99529566b..70c53f33d857 100644
> --- a/drivers/net/fjes/fjes_ethtool.c
> +++ b/drivers/net/fjes/fjes_ethtool.c
> @@ -87,49 +87,31 @@ static void fjes_get_strings(struct net_device *netdev,
> {
> struct fjes_adapter *adapter = netdev_priv(netdev);
> struct fjes_hw *hw = &adapter->hw;
> - u8 *p = data;
> int i;
>
> - switch (stringset) {
> - case ETH_SS_STATS:
> - for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
> - memcpy(p, fjes_gstrings_stats[i].stat_string,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> - for (i = 0; i < hw->max_epid; i++) {
> - if (i == hw->my_epid)
> - continue;
> - sprintf(p, "ep%u_com_regist_buf_exec", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_com_unregist_buf_exec", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_send_intr_rx", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_send_intr_unshare", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_send_intr_zoneupdate", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_recv_intr_rx", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_recv_intr_unshare", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_recv_intr_stop", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_recv_intr_zoneupdate", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_tx_buffer_full", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_tx_dropped_not_shared", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_tx_dropped_ver_mismatch", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_tx_dropped_buf_size_mismatch", i);
> - p += ETH_GSTRING_LEN;
> - sprintf(p, "ep%u_tx_dropped_vlanid_mismatch", i);
> - p += ETH_GSTRING_LEN;
> - }
> - break;
> + if (stringset != ETH_SS_STATS)
> + return;
> +
> + for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++)
> + ethtool_puts(&data, fjes_gstrings_stats[i].stat_string);
> +
> + for (i = 0; i < hw->max_epid; i++) {
> + if (i == hw->my_epid)
> + continue;
> + ethtool_sprintf(&data, "ep%u_com_regist_buf_exec", i);
> + ethtool_sprintf(&data, "ep%u_com_unregist_buf_exec", i);
> + ethtool_sprintf(&data, "ep%u_send_intr_rx", i);
> + ethtool_sprintf(&data, "ep%u_send_intr_unshare", i);
> + ethtool_sprintf(&data, "ep%u_send_intr_zoneupdate", i);
> + ethtool_sprintf(&data, "ep%u_recv_intr_rx", i);
> + ethtool_sprintf(&data, "ep%u_recv_intr_unshare", i);
> + ethtool_sprintf(&data, "ep%u_recv_intr_stop", i);
> + ethtool_sprintf(&data, "ep%u_recv_intr_zoneupdate", i);
> + ethtool_sprintf(&data, "ep%u_tx_buffer_full", i);
> + ethtool_sprintf(&data, "ep%u_tx_dropped_not_shared", i);
> + ethtool_sprintf(&data, "ep%u_tx_dropped_ver_mismatch", i);
> + ethtool_sprintf(&data, "ep%u_tx_dropped_buf_size_mismatch", i);
> + ethtool_sprintf(&data, "ep%u_tx_dropped_vlanid_mismatch", i);
> }
> }
>
> --
> 2.47.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fjes: use ethtool string helpers
2024-10-29 23:27 [PATCH] net: fjes: use ethtool string helpers Rosen Penev
2024-10-29 23:28 ` Rosen Penev
@ 2024-11-01 2:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-01 2:40 UTC (permalink / raw)
To: Rosen Penev
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 29 Oct 2024 16:27:21 -0700 you wrote:
> The latter is the preferred way to copy ethtool strings.
>
> Avoids manually incrementing the pointer.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
>
> [...]
Here is the summary with links:
- net: fjes: use ethtool string helpers
https://git.kernel.org/netdev/net-next/c/dbb9a7ef3478
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-01 2:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 23:27 [PATCH] net: fjes: use ethtool string helpers Rosen Penev
2024-10-29 23:28 ` Rosen Penev
2024-11-01 2:40 ` patchwork-bot+netdevbpf
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).