Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mscc: ocelot: allow ocelot_stat_layout elements with no name

We will add support for pMAC counters and MAC merge layer counters,
which are only reported via the structured stats, and the current
ocelot_get_strings() stands in our way, because it expects that the
statistics should be placed in the data array at the same index as found
in the ocelot_stats_layout array.

That is not true. Statistics which don't have a name should not be
exported to the unstructured ethtool -S, so we need to have different
indices into the ocelot_stats_layout array (i) and into the data array
(data itself).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
1a733bbd 5f6c2d49

+2 -2
+2 -2
drivers/net/ethernet/mscc/ocelot_stats.c
··· 315 315 if (ocelot_stats_layout[i].name[0] == '\0') 316 316 continue; 317 317 318 - memcpy(data + i * ETH_GSTRING_LEN, ocelot_stats_layout[i].name, 319 - ETH_GSTRING_LEN); 318 + memcpy(data, ocelot_stats_layout[i].name, ETH_GSTRING_LEN); 319 + data += ETH_GSTRING_LEN; 320 320 } 321 321 } 322 322 EXPORT_SYMBOL(ocelot_get_strings);