mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 20:24:02 -04:00
net: mana: refactor mana_get_strings() and mana_get_sset_count() to use switch
Refactor mana_get_strings() and mana_get_sset_count() from if/else to switch statements in preparation for adding ethtool private flags support which requires handling ETH_SS_PRIV_FLAGS. No functional change. Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Dipayaan Roy <dipayanroy@linux.microsoft.com> Link: https://patch.msgid.link/20260729063347.3388035-2-dipayanroy@linux.microsoft.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
63638bc3e2
commit
d52f807310
@@ -138,53 +138,70 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset)
|
||||
struct mana_port_context *apc = netdev_priv(ndev);
|
||||
unsigned int num_queues = apc->num_queues;
|
||||
|
||||
if (stringset != ETH_SS_STATS)
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
return ARRAY_SIZE(mana_eth_stats) +
|
||||
ARRAY_SIZE(mana_phy_stats) +
|
||||
ARRAY_SIZE(mana_hc_stats) +
|
||||
num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return ARRAY_SIZE(mana_eth_stats) + ARRAY_SIZE(mana_phy_stats) + ARRAY_SIZE(mana_hc_stats) +
|
||||
num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT);
|
||||
static void mana_get_strings_stats(struct mana_port_context *apc, u8 **data)
|
||||
{
|
||||
unsigned int num_queues = apc->num_queues;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mana_eth_stats); i++)
|
||||
ethtool_puts(data, mana_eth_stats[i].name);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mana_hc_stats); i++)
|
||||
ethtool_puts(data, mana_hc_stats[i].name);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mana_phy_stats); i++)
|
||||
ethtool_puts(data, mana_phy_stats[i].name);
|
||||
|
||||
for (i = 0; i < num_queues; i++) {
|
||||
ethtool_sprintf(data, "rx_%d_packets", i);
|
||||
ethtool_sprintf(data, "rx_%d_bytes", i);
|
||||
ethtool_sprintf(data, "rx_%d_xdp_drop", i);
|
||||
ethtool_sprintf(data, "rx_%d_xdp_tx", i);
|
||||
ethtool_sprintf(data, "rx_%d_xdp_redirect", i);
|
||||
ethtool_sprintf(data, "rx_%d_pkt_len0_err", i);
|
||||
for (j = 0; j < MANA_RXCOMP_OOB_NUM_PPI - 1; j++)
|
||||
ethtool_sprintf(data,
|
||||
"rx_%d_coalesced_cqe_%d",
|
||||
i,
|
||||
j + 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_queues; i++) {
|
||||
ethtool_sprintf(data, "tx_%d_packets", i);
|
||||
ethtool_sprintf(data, "tx_%d_bytes", i);
|
||||
ethtool_sprintf(data, "tx_%d_xdp_xmit", i);
|
||||
ethtool_sprintf(data, "tx_%d_tso_packets", i);
|
||||
ethtool_sprintf(data, "tx_%d_tso_bytes", i);
|
||||
ethtool_sprintf(data, "tx_%d_tso_inner_packets", i);
|
||||
ethtool_sprintf(data, "tx_%d_tso_inner_bytes", i);
|
||||
ethtool_sprintf(data, "tx_%d_long_pkt_fmt", i);
|
||||
ethtool_sprintf(data, "tx_%d_short_pkt_fmt", i);
|
||||
ethtool_sprintf(data, "tx_%d_csum_partial", i);
|
||||
ethtool_sprintf(data, "tx_%d_mana_map_err", i);
|
||||
}
|
||||
}
|
||||
|
||||
static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
|
||||
{
|
||||
struct mana_port_context *apc = netdev_priv(ndev);
|
||||
unsigned int num_queues = apc->num_queues;
|
||||
int i, j;
|
||||
|
||||
if (stringset != ETH_SS_STATS)
|
||||
return;
|
||||
for (i = 0; i < ARRAY_SIZE(mana_eth_stats); i++)
|
||||
ethtool_puts(&data, mana_eth_stats[i].name);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mana_hc_stats); i++)
|
||||
ethtool_puts(&data, mana_hc_stats[i].name);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mana_phy_stats); i++)
|
||||
ethtool_puts(&data, mana_phy_stats[i].name);
|
||||
|
||||
for (i = 0; i < num_queues; i++) {
|
||||
ethtool_sprintf(&data, "rx_%d_packets", i);
|
||||
ethtool_sprintf(&data, "rx_%d_bytes", i);
|
||||
ethtool_sprintf(&data, "rx_%d_xdp_drop", i);
|
||||
ethtool_sprintf(&data, "rx_%d_xdp_tx", i);
|
||||
ethtool_sprintf(&data, "rx_%d_xdp_redirect", i);
|
||||
ethtool_sprintf(&data, "rx_%d_pkt_len0_err", i);
|
||||
for (j = 0; j < MANA_RXCOMP_OOB_NUM_PPI - 1; j++)
|
||||
ethtool_sprintf(&data, "rx_%d_coalesced_cqe_%d", i, j + 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_queues; i++) {
|
||||
ethtool_sprintf(&data, "tx_%d_packets", i);
|
||||
ethtool_sprintf(&data, "tx_%d_bytes", i);
|
||||
ethtool_sprintf(&data, "tx_%d_xdp_xmit", i);
|
||||
ethtool_sprintf(&data, "tx_%d_tso_packets", i);
|
||||
ethtool_sprintf(&data, "tx_%d_tso_bytes", i);
|
||||
ethtool_sprintf(&data, "tx_%d_tso_inner_packets", i);
|
||||
ethtool_sprintf(&data, "tx_%d_tso_inner_bytes", i);
|
||||
ethtool_sprintf(&data, "tx_%d_long_pkt_fmt", i);
|
||||
ethtool_sprintf(&data, "tx_%d_short_pkt_fmt", i);
|
||||
ethtool_sprintf(&data, "tx_%d_csum_partial", i);
|
||||
ethtool_sprintf(&data, "tx_%d_mana_map_err", i);
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
mana_get_strings_stats(apc, &data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user