Commit df665ab1 authored by Rosen Penev's avatar Rosen Penev Committed by Jakub Kicinski

net: atlantic: use ethtool_sprintf

Allows simplifying get_strings and avoids manual pointer manipulation.
Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
Reviewed-by: default avatarJoe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20240807190303.6143-1-rosenp@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a3903684
...@@ -279,18 +279,16 @@ static void aq_ethtool_get_strings(struct net_device *ndev, ...@@ -279,18 +279,16 @@ static void aq_ethtool_get_strings(struct net_device *ndev,
for (i = 0; i < cfg->vecs; i++) { for (i = 0; i < cfg->vecs; i++) {
for (si = 0; si < rx_stat_cnt; si++) { for (si = 0; si < rx_stat_cnt; si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_ethtool_queue_rx_stat_names[si], aq_ethtool_queue_rx_stat_names[si],
tc_string, tc_string,
AQ_NIC_CFG_TCVEC2RING(cfg, tc, i)); AQ_NIC_CFG_TCVEC2RING(cfg, tc, i));
p += ETH_GSTRING_LEN;
} }
for (si = 0; si < tx_stat_cnt; si++) { for (si = 0; si < tx_stat_cnt; si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_ethtool_queue_tx_stat_names[si], aq_ethtool_queue_tx_stat_names[si],
tc_string, tc_string,
AQ_NIC_CFG_TCVEC2RING(cfg, tc, i)); AQ_NIC_CFG_TCVEC2RING(cfg, tc, i));
p += ETH_GSTRING_LEN;
} }
} }
} }
...@@ -305,20 +303,18 @@ static void aq_ethtool_get_strings(struct net_device *ndev, ...@@ -305,20 +303,18 @@ static void aq_ethtool_get_strings(struct net_device *ndev,
for (i = 0; i < max(rx_ring_cnt, tx_ring_cnt); i++) { for (i = 0; i < max(rx_ring_cnt, tx_ring_cnt); i++) {
for (si = 0; si < rx_stat_cnt; si++) { for (si = 0; si < rx_stat_cnt; si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_ethtool_queue_rx_stat_names[si], aq_ethtool_queue_rx_stat_names[si],
tc_string, tc_string,
i ? PTP_HWST_RING_IDX : ptp_ring_idx); i ? PTP_HWST_RING_IDX : ptp_ring_idx);
p += ETH_GSTRING_LEN;
} }
if (i >= tx_ring_cnt) if (i >= tx_ring_cnt)
continue; continue;
for (si = 0; si < tx_stat_cnt; si++) { for (si = 0; si < tx_stat_cnt; si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_ethtool_queue_tx_stat_names[si], aq_ethtool_queue_tx_stat_names[si],
tc_string, tc_string,
i ? PTP_HWST_RING_IDX : ptp_ring_idx); i ? PTP_HWST_RING_IDX : ptp_ring_idx);
p += ETH_GSTRING_LEN;
} }
} }
} }
...@@ -338,9 +334,8 @@ static void aq_ethtool_get_strings(struct net_device *ndev, ...@@ -338,9 +334,8 @@ static void aq_ethtool_get_strings(struct net_device *ndev,
for (si = 0; for (si = 0;
si < ARRAY_SIZE(aq_macsec_txsc_stat_names); si < ARRAY_SIZE(aq_macsec_txsc_stat_names);
si++) { si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_macsec_txsc_stat_names[si], i); aq_macsec_txsc_stat_names[si], i);
p += ETH_GSTRING_LEN;
} }
aq_txsc = &nic->macsec_cfg->aq_txsc[i]; aq_txsc = &nic->macsec_cfg->aq_txsc[i];
for (sa = 0; sa < MACSEC_NUM_AN; sa++) { for (sa = 0; sa < MACSEC_NUM_AN; sa++) {
...@@ -349,10 +344,9 @@ static void aq_ethtool_get_strings(struct net_device *ndev, ...@@ -349,10 +344,9 @@ static void aq_ethtool_get_strings(struct net_device *ndev,
for (si = 0; for (si = 0;
si < ARRAY_SIZE(aq_macsec_txsa_stat_names); si < ARRAY_SIZE(aq_macsec_txsa_stat_names);
si++) { si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_macsec_txsa_stat_names[si], aq_macsec_txsa_stat_names[si],
i, sa); i, sa);
p += ETH_GSTRING_LEN;
} }
} }
} }
...@@ -369,10 +363,9 @@ static void aq_ethtool_get_strings(struct net_device *ndev, ...@@ -369,10 +363,9 @@ static void aq_ethtool_get_strings(struct net_device *ndev,
for (si = 0; for (si = 0;
si < ARRAY_SIZE(aq_macsec_rxsa_stat_names); si < ARRAY_SIZE(aq_macsec_rxsa_stat_names);
si++) { si++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p,
aq_macsec_rxsa_stat_names[si], aq_macsec_rxsa_stat_names[si],
i, sa); i, sa);
p += ETH_GSTRING_LEN;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment