mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 06:31:58 +02:00
net: qlogic: 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. Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20241024195534.176410-1-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
2d7dfe2d0b
commit
a27646c42e
|
|
@ -648,18 +648,18 @@ netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
|
|||
static void
|
||||
netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
|
||||
{
|
||||
int index;
|
||||
const char *str;
|
||||
int i;
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_TEST:
|
||||
memcpy(data, *netxen_nic_gstrings_test,
|
||||
NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
|
||||
for (i = 0; i < NETXEN_NIC_TEST_LEN; i++)
|
||||
ethtool_puts(&data, netxen_nic_gstrings_test[i]);
|
||||
break;
|
||||
case ETH_SS_STATS:
|
||||
for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
netxen_nic_gstrings_stats[index].stat_string,
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < NETXEN_NIC_STATS_LEN; i++) {
|
||||
str = netxen_nic_gstrings_stats[i].stat_string;
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,16 +272,14 @@ static void qede_get_strings_stats_txq(struct qede_dev *edev,
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < QEDE_NUM_TQSTATS; i++) {
|
||||
for (i = 0; i < QEDE_NUM_TQSTATS; i++)
|
||||
if (txq->is_xdp)
|
||||
sprintf(*buf, "%d [XDP]: %s",
|
||||
QEDE_TXQ_XDP_TO_IDX(edev, txq),
|
||||
qede_tqstats_arr[i].string);
|
||||
ethtool_sprintf(buf, "%d [XDP]: %s",
|
||||
QEDE_TXQ_XDP_TO_IDX(edev, txq),
|
||||
qede_tqstats_arr[i].string);
|
||||
else
|
||||
sprintf(*buf, "%d_%d: %s", txq->index, txq->cos,
|
||||
qede_tqstats_arr[i].string);
|
||||
*buf += ETH_GSTRING_LEN;
|
||||
}
|
||||
ethtool_sprintf(buf, "%d_%d: %s", txq->index, txq->cos,
|
||||
qede_tqstats_arr[i].string);
|
||||
}
|
||||
|
||||
static void qede_get_strings_stats_rxq(struct qede_dev *edev,
|
||||
|
|
@ -289,11 +287,9 @@ static void qede_get_strings_stats_rxq(struct qede_dev *edev,
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < QEDE_NUM_RQSTATS; i++) {
|
||||
sprintf(*buf, "%d: %s", rxq->rxq_id,
|
||||
qede_rqstats_arr[i].string);
|
||||
*buf += ETH_GSTRING_LEN;
|
||||
}
|
||||
for (i = 0; i < QEDE_NUM_RQSTATS; i++)
|
||||
ethtool_sprintf(buf, "%d: %s", rxq->rxq_id,
|
||||
qede_rqstats_arr[i].string);
|
||||
}
|
||||
|
||||
static bool qede_is_irrelevant_stat(struct qede_dev *edev, int stat_index)
|
||||
|
|
@ -331,26 +327,26 @@ static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
|
|||
for (i = 0; i < QEDE_NUM_STATS; i++) {
|
||||
if (qede_is_irrelevant_stat(edev, i))
|
||||
continue;
|
||||
strcpy(buf, qede_stats_arr[i].string);
|
||||
buf += ETH_GSTRING_LEN;
|
||||
ethtool_puts(&buf, qede_stats_arr[i].string);
|
||||
}
|
||||
}
|
||||
|
||||
static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
|
||||
{
|
||||
struct qede_dev *edev = netdev_priv(dev);
|
||||
int i;
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
qede_get_strings_stats(edev, buf);
|
||||
break;
|
||||
case ETH_SS_PRIV_FLAGS:
|
||||
memcpy(buf, qede_private_arr,
|
||||
ETH_GSTRING_LEN * QEDE_PRI_FLAG_LEN);
|
||||
for (i = 0; i < QEDE_PRI_FLAG_LEN; i++)
|
||||
ethtool_puts(&buf, qede_private_arr[i]);
|
||||
break;
|
||||
case ETH_SS_TEST:
|
||||
memcpy(buf, qede_tests_str_arr,
|
||||
ETH_GSTRING_LEN * QEDE_ETHTOOL_TEST_MAX);
|
||||
for (i = 0; i < QEDE_ETHTOOL_TEST_MAX; i++)
|
||||
ethtool_puts(&buf, qede_tests_str_arr[i]);
|
||||
break;
|
||||
default:
|
||||
DP_VERBOSE(edev, QED_MSG_DEBUG,
|
||||
|
|
|
|||
|
|
@ -1196,60 +1196,56 @@ qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
|
|||
{
|
||||
struct qlcnic_adapter *adapter = netdev_priv(dev);
|
||||
int index, i, num_stats;
|
||||
const char *str;
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_TEST:
|
||||
memcpy(data, *qlcnic_gstrings_test,
|
||||
QLCNIC_TEST_LEN * ETH_GSTRING_LEN);
|
||||
for (i = 0; i < QLCNIC_TEST_LEN; i++)
|
||||
ethtool_puts(&data, qlcnic_gstrings_test[i]);
|
||||
break;
|
||||
case ETH_SS_STATS:
|
||||
num_stats = ARRAY_SIZE(qlcnic_tx_queue_stats_strings);
|
||||
for (i = 0; i < adapter->drv_tx_rings; i++) {
|
||||
for (i = 0; i < adapter->drv_tx_rings; i++)
|
||||
for (index = 0; index < num_stats; index++) {
|
||||
sprintf(data, "tx_queue_%d %s", i,
|
||||
qlcnic_tx_queue_stats_strings[index]);
|
||||
data += ETH_GSTRING_LEN;
|
||||
str = qlcnic_tx_queue_stats_strings[index];
|
||||
ethtool_sprintf(&data, "tx_queue_%d %s", i,
|
||||
str);
|
||||
}
|
||||
}
|
||||
|
||||
for (index = 0; index < QLCNIC_STATS_LEN; index++) {
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_gstrings_stats[index].stat_string,
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < QLCNIC_STATS_LEN; i++) {
|
||||
str = qlcnic_gstrings_stats[i].stat_string;
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
|
||||
if (qlcnic_83xx_check(adapter)) {
|
||||
num_stats = ARRAY_SIZE(qlcnic_83xx_tx_stats_strings);
|
||||
for (i = 0; i < num_stats; i++, index++)
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_83xx_tx_stats_strings[i],
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < num_stats; i++) {
|
||||
str = qlcnic_83xx_tx_stats_strings[i];
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
num_stats = ARRAY_SIZE(qlcnic_83xx_mac_stats_strings);
|
||||
for (i = 0; i < num_stats; i++, index++)
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_83xx_mac_stats_strings[i],
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < num_stats; i++) {
|
||||
str = qlcnic_83xx_mac_stats_strings[i];
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
num_stats = ARRAY_SIZE(qlcnic_83xx_rx_stats_strings);
|
||||
for (i = 0; i < num_stats; i++, index++)
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_83xx_rx_stats_strings[i],
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < num_stats; i++) {
|
||||
str = qlcnic_83xx_rx_stats_strings[i];
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
num_stats = ARRAY_SIZE(qlcnic_83xx_mac_stats_strings);
|
||||
for (i = 0; i < num_stats; i++, index++)
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_83xx_mac_stats_strings[i],
|
||||
ETH_GSTRING_LEN);
|
||||
for (i = 0; i < num_stats; i++) {
|
||||
str = qlcnic_83xx_mac_stats_strings[i];
|
||||
ethtool_puts(&data, str);
|
||||
}
|
||||
}
|
||||
if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED))
|
||||
return;
|
||||
num_stats = ARRAY_SIZE(qlcnic_device_gstrings_stats);
|
||||
for (i = 0; i < num_stats; index++, i++) {
|
||||
memcpy(data + index * ETH_GSTRING_LEN,
|
||||
qlcnic_device_gstrings_stats[i],
|
||||
ETH_GSTRING_LEN);
|
||||
}
|
||||
for (i = 0; i < num_stats; i++)
|
||||
ethtool_puts(&data, qlcnic_device_gstrings_stats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user