net: sfc: use ethtool string helpers
Subsystems (4)
PATCH 1/1 net: sfc: use ethtool string helpers
The latter is the preferred way to copy ethtool strings.
Avoids manually incrementing the pointer. Cleans up the code quite well.
--- drivers/net/ethernet/sfc/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/falcon/ethtool.c | 24 +++++-------- drivers/net/ethernet/sfc/falcon/nic.c | 7 ++-- drivers/net/ethernet/sfc/nic.c | 7 ++-- .../net/ethernet/sfc/siena/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/siena/nic.c | 7 ++-- 6 files changed, 40 insertions(+), 73 deletions(-)
drivers/net/ethernet/sfc/ethtool_common.c +13 -21
@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf ( + &strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EFX_MAX_TXQ_PER_CHANNEL ); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }
@@ -467,9 +461,7 @@ void efx_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_ptp_describe_stats (efx, strings);
drivers/net/ethernet/sfc/falcon/ethtool.c +8 -16
@@ -361,24 +361,18 @@ static size_t ef4_describe_per_queue_stats(struct ef4_nic *efx, u8 *strings)ef4_for_each_channel (channel, efx) {if (ef4_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EF4_TXQ_TYPES ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EF4_TXQ_TYPES ); } }ef4_for_each_channel (channel, efx) {if (ef4_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }return n_stats;
@@ -412,9 +406,7 @@ static void ef4_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EF4_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - ef4_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EF4_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, ef4_sw_stat_desc[i].name); strings += (ef4_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );break ;
drivers/net/ethernet/sfc/falcon/nic.c +2 -5
@@ -451,11 +451,8 @@ size_t ef4_nic_describe_stats(const struct ef4_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }
drivers/net/ethernet/sfc/nic.c +2 -5
@@ -306,11 +306,8 @@ size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }
drivers/net/ethernet/sfc/siena/ethtool_common.c +13 -21
@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf ( + &strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EFX_MAX_TXQ_PER_CHANNEL ); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }
@@ -467,9 +461,7 @@ void efx_siena_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_siena_ptp_describe_stats (efx, strings);
drivers/net/ethernet/sfc/siena/nic.c +2 -5
@@ -457,11 +457,8 @@ size_t efx_siena_describe_stats(const struct efx_hw_stat_desc *desc, size_t counfor_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }
Signature · 1 line
2.47.0
Quoted 24 lines · Rosen Penev
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 <[email protected]>--- drivers/net/ethernet/sfc/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/falcon/ethtool.c | 24 +++++-------- drivers/net/ethernet/sfc/falcon/nic.c | 7 ++-- drivers/net/ethernet/sfc/nic.c | 7 ++-- .../net/ethernet/sfc/siena/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/siena/nic.c | 7 ++-- 6 files changed, 40 insertions(+), 73 deletions(-)drivers/net/ethernet/sfc/ethtool_common.c +0
-1@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) {
drivers/net/ethernet/sfc/ethtool_common.c static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings) · line 408
Quoted 10 lines
drivers/net/ethernet/sfc/ethtool_common.c +3
-7-snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) + ethtool_sprintf( + &strings, "tx-%u.tx_packets",
This still fits after the opening parentheses above within 80 characters. I would prefer that style.
Martin
Quoted 213 lines
drivers/net/ethernet/sfc/ethtool_common.c +10
-13+ channel->tx_queue[0 ].queue / + EFX_MAX_TXQ_PER_CHANNEL); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }@@ -467,9 +461,7 @@ void efx_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_ptp_describe_stats (efx, strings);drivers/net/ethernet/sfc/falcon/ethtool.c +8
-16@@ -361,24 +361,18 @@ static size_t ef4_describe_per_queue_stats(struct ef4_nic *efx, u8 *strings)ef4_for_each_channel (channel, efx) {if (ef4_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EF4_TXQ_TYPES ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EF4_TXQ_TYPES ); } }ef4_for_each_channel (channel, efx) {if (ef4_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }return n_stats;@@ -412,9 +406,7 @@ static void ef4_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EF4_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - ef4_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EF4_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, ef4_sw_stat_desc[i].name); strings += (ef4_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );break ;drivers/net/ethernet/sfc/falcon/nic.c +2
-5@@ -451,11 +451,8 @@ size_t ef4_nic_describe_stats(const struct ef4_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }drivers/net/ethernet/sfc/nic.c +2
-5@@ -306,11 +306,8 @@ size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }drivers/net/ethernet/sfc/siena/ethtool_common.c +13
-21@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf ( + &strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EFX_MAX_TXQ_PER_CHANNEL ); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }@@ -467,9 +461,7 @@ void efx_siena_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_siena_ptp_describe_stats (efx, strings);drivers/net/ethernet/sfc/siena/nic.c +2
-5@@ -457,11 +457,8 @@ size_t efx_siena_describe_stats(const struct efx_hw_stat_desc *desc, size_t counfor_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }Signature · 1 line
2.47.0
Quoted 31 lines · Martin Habets
Quoted 29 lines · Rosen Penev
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 <[email protected]>--- drivers/net/ethernet/sfc/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/falcon/ethtool.c | 24 +++++-------- drivers/net/ethernet/sfc/falcon/nic.c | 7 ++-- drivers/net/ethernet/sfc/nic.c | 7 ++-- .../net/ethernet/sfc/siena/ethtool_common.c | 34 +++++++------------ drivers/net/ethernet/sfc/siena/nic.c | 7 ++-- 6 files changed, 40 insertions(+), 73 deletions(-)drivers/net/ethernet/sfc/ethtool_common.c +0
-6@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); -
Quoted 8 lines
drivers/net/ethernet/sfc/ethtool_common.c static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings) · line 408
Quoted 5 lines
drivers/net/ethernet/sfc/ethtool_common.c +3
-2- strings +=ETH_GSTRING_LEN ; - } +if (strings) + ethtool_sprintf( + &strings, "tx-%u.tx_packets",This still fits after the opening parentheses above within 80 characters. I would prefer that style.
clang-format did this as there's too much indentation. I sent a v2 where I reduced it by adding continue;
Quoted 216 lines
Martin
Quoted 213 lines
drivers/net/ethernet/sfc/ethtool_common.c +10
-13+ channel->tx_queue[0 ].queue / + EFX_MAX_TXQ_PER_CHANNEL); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }@@ -467,9 +461,7 @@ void efx_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_ptp_describe_stats (efx, strings);drivers/net/ethernet/sfc/falcon/ethtool.c +8
-16@@ -361,24 +361,18 @@ static size_t ef4_describe_per_queue_stats(struct ef4_nic *efx, u8 *strings)ef4_for_each_channel (channel, efx) {if (ef4_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EF4_TXQ_TYPES ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EF4_TXQ_TYPES ); } }ef4_for_each_channel (channel, efx) {if (ef4_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }return n_stats;@@ -412,9 +406,7 @@ static void ef4_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EF4_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - ef4_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EF4_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, ef4_sw_stat_desc[i].name); strings += (ef4_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );break ;drivers/net/ethernet/sfc/falcon/nic.c +2
-5@@ -451,11 +451,8 @@ size_t ef4_nic_describe_stats(const struct ef4_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }drivers/net/ethernet/sfc/nic.c +2
-5@@ -306,11 +306,8 @@ size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,for_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } }drivers/net/ethernet/sfc/siena/ethtool_common.c +13
-21@@ -403,24 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)efx_for_each_channel (channel, efx) {if (efx_channel_has_tx_queues (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-%u.tx_packets" , - channel->tx_queue[0 ].queue / -EFX_MAX_TXQ_PER_CHANNEL ); - - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf ( + &strings,"tx-%u.tx_packets" , + channel->tx_queue[0 ].queue / +EFX_MAX_TXQ_PER_CHANNEL ); } }efx_for_each_channel (channel, efx) {if (efx_channel_has_rx_queue (channel)) { n_stats++; -if (strings !=NULL ) { -snprintf (strings,ETH_GSTRING_LEN , -"rx-%d.rx_packets" , channel->channel); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings,"rx-%d.rx_packets" , + channel->channel); } }if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {@@ -428,11 +423,10 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)for (xdp =0 ; xdp < efx->xdp_tx_queue_count; xdp++) { n_stats++; -if (strings) { -snprintf (strings,ETH_GSTRING_LEN , -"tx-xdp-cpu-%hu.tx_packets" , xdp); - strings +=ETH_GSTRING_LEN ; - } +if (strings) +ethtool_sprintf (&strings, +"tx-xdp-cpu-%hu.tx_packets" , + xdp); } }@@ -467,9 +461,7 @@ void efx_siena_ethtool_get_strings(struct net_device *net_dev, strings += (efx->type->describe_stats (efx, strings) *ETH_GSTRING_LEN );for (i =0 ; i <EFX_ETHTOOL_SW_STAT_COUNT ; i++) -strscpy (strings + i *ETH_GSTRING_LEN , - efx_sw_stat_desc[i].name,ETH_GSTRING_LEN ); - strings +=EFX_ETHTOOL_SW_STAT_COUNT *ETH_GSTRING_LEN ; +ethtool_puts (&strings, efx_sw_stat_desc[i].name); strings += (efx_describe_per_queue_stats (efx, strings) *ETH_GSTRING_LEN );efx_siena_ptp_describe_stats (efx, strings);drivers/net/ethernet/sfc/siena/nic.c +2
-6@@ -457,11 +457,8 @@ size_t efx_siena_describe_stats(const struct efx_hw_stat_desc *desc, size_t counfor_each_set_bit (index, mask, count) {if (desc[index].name) { -if (names) { -strscpy (names, desc[index].name, -ETH_GSTRING_LEN ); - names +=ETH_GSTRING_LEN ; - } +if (names) +ethtool_puts (&names, desc[index].name); ++visible; } } --2.47.0