Re: [PATCH net-next 09/10] net: sparx5: add ethtool configuration and statistics support
Hi Jacub, On Fri, 2021-04-16 at 14:26 -0700, Jakub Kicinski wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > On Fri, 16 Apr 2021 15:16:56 +0200 Steen Hegelund wrote: > > + "rx_in_bytes", > > + "rx_symbol_err", > > + "rx_pause", > > + "rx_unsup_opcode", > > + "rx_ok_bytes", > > + "rx_bad_bytes", > > + "rx_unicast", > > + "rx_multicast", > > + "rx_broadcast", > > + "rx_crc_err", > > + "rx_undersize", > > + "rx_fragments", > > + "rx_inrangelen_err", > > + "rx_outofrangelen_err", > > + "rx_oversize", > > + "rx_jabbers", > > + "rx_size64", > > + "rx_size65_127", > > + "rx_size128_255", > > + "rx_size256_511", > > + "rx_size512_1023", > > + "rx_size1024_1518", > > + "rx_size1519_max", > > + "pmac_rx_symbol_err", > > + "pmac_rx_pause", > > + "pmac_rx_unsup_opcode", > > + "pmac_rx_ok_bytes", > > + "pmac_rx_bad_bytes", > > + "pmac_rx_unicast", > > + "pmac_rx_multicast", > > + "pmac_rx_broadcast", > > + "pmac_rx_crc_err", > > + "pmac_rx_undersize", > > + "pmac_rx_fragments", > > + "pmac_rx_inrangelen_err", > > + "pmac_rx_outofrangelen_err", > > + "pmac_rx_oversize", > > + "pmac_rx_jabbers", > > + "pmac_rx_size64", > > + "pmac_rx_size65_127", > > + "pmac_rx_size128_255", > > + "pmac_rx_size256_511", > > + "pmac_rx_size512_1023", > > + "pmac_rx_size1024_1518", > > + "pmac_rx_size1519_max", > > + "rx_local_drop", > > + "rx_port_policer_drop", > > + "tx_out_bytes", > > + "tx_pause", > > + "tx_ok_bytes", > > + "tx_unicast", > > + "tx_multicast", > > + "tx_broadcast", > > + "tx_size64", > > + "tx_size65_127", > > + "tx_size128_255", > > + "tx_size256_511", > > + "tx_size512_1023", > > + "tx_size1024_1518", > > + "tx_size1519_max", > > + "tx_multi_coll", > > + "tx_late_coll", > > + "tx_xcoll", > > + "tx_defer", > > + "tx_xdefer", > > + "tx_backoff1", > > + "pmac_tx_pause", > > + "pmac_tx_ok_bytes", > > + "pmac_tx_unicast", > > + "pmac_tx_multicast", > > + "pmac_tx_broadcast", > > + "pmac_tx_size64", > > + "pmac_tx_size65_127", > > + "pmac_tx_size128_255", > > + "pmac_tx_size256_511", > > + "pmac_tx_size512_1023", > > + "pmac_tx_size1024_1518", > > + "pmac_tx_size1519_max", > > Please see > > https://patchwork.kernel.org/project/netdevbpf/list/?series=468795 > > (hopefully to be merged by the end of the week) and earlier patches for > pause and FEC stats. Anything that has a standardized interface is off > limits for the random ethtool -S grab bag. OK. I was not aware of that. Thanks for your comments. Best Regards Steen
Re: [PATCH net-next 09/10] net: sparx5: add ethtool configuration and statistics support
On Fri, 16 Apr 2021 15:16:56 +0200 Steen Hegelund wrote: > + "rx_in_bytes", > + "rx_symbol_err", > + "rx_pause", > + "rx_unsup_opcode", > + "rx_ok_bytes", > + "rx_bad_bytes", > + "rx_unicast", > + "rx_multicast", > + "rx_broadcast", > + "rx_crc_err", > + "rx_undersize", > + "rx_fragments", > + "rx_inrangelen_err", > + "rx_outofrangelen_err", > + "rx_oversize", > + "rx_jabbers", > + "rx_size64", > + "rx_size65_127", > + "rx_size128_255", > + "rx_size256_511", > + "rx_size512_1023", > + "rx_size1024_1518", > + "rx_size1519_max", > + "pmac_rx_symbol_err", > + "pmac_rx_pause", > + "pmac_rx_unsup_opcode", > + "pmac_rx_ok_bytes", > + "pmac_rx_bad_bytes", > + "pmac_rx_unicast", > + "pmac_rx_multicast", > + "pmac_rx_broadcast", > + "pmac_rx_crc_err", > + "pmac_rx_undersize", > + "pmac_rx_fragments", > + "pmac_rx_inrangelen_err", > + "pmac_rx_outofrangelen_err", > + "pmac_rx_oversize", > + "pmac_rx_jabbers", > + "pmac_rx_size64", > + "pmac_rx_size65_127", > + "pmac_rx_size128_255", > + "pmac_rx_size256_511", > + "pmac_rx_size512_1023", > + "pmac_rx_size1024_1518", > + "pmac_rx_size1519_max", > + "rx_local_drop", > + "rx_port_policer_drop", > + "tx_out_bytes", > + "tx_pause", > + "tx_ok_bytes", > + "tx_unicast", > + "tx_multicast", > + "tx_broadcast", > + "tx_size64", > + "tx_size65_127", > + "tx_size128_255", > + "tx_size256_511", > + "tx_size512_1023", > + "tx_size1024_1518", > + "tx_size1519_max", > + "tx_multi_coll", > + "tx_late_coll", > + "tx_xcoll", > + "tx_defer", > + "tx_xdefer", > + "tx_backoff1", > + "pmac_tx_pause", > + "pmac_tx_ok_bytes", > + "pmac_tx_unicast", > + "pmac_tx_multicast", > + "pmac_tx_broadcast", > + "pmac_tx_size64", > + "pmac_tx_size65_127", > + "pmac_tx_size128_255", > + "pmac_tx_size256_511", > + "pmac_tx_size512_1023", > + "pmac_tx_size1024_1518", > + "pmac_tx_size1519_max", Please see https://patchwork.kernel.org/project/netdevbpf/list/?series=468795 (hopefully to be merged by the end of the week) and earlier patches for pause and FEC stats. Anything that has a standardized interface is off limits for the random ethtool -S grab bag.
[PATCH net-next 09/10] net: sparx5: add ethtool configuration and statistics support
This adds statistic counters for the network interfaces provided by the driver. It also adds CPU port counters (which are not exposed by ethtool). This also adds support for configuring the network interface parameters via ethtool: speed, duplex, aneg etc. Signed-off-by: Steen Hegelund Signed-off-by: Bjarni Jonasson Signed-off-by: Lars Povlsen --- .../net/ethernet/microchip/sparx5/Makefile| 2 +- .../microchip/sparx5/sparx5_ethtool.c | 999 ++ .../ethernet/microchip/sparx5/sparx5_main.c | 4 + .../ethernet/microchip/sparx5/sparx5_main.h | 12 + .../ethernet/microchip/sparx5/sparx5_netdev.c | 2 + 5 files changed, 1018 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile index e7dea25eb479..5df99f9a12e9 100644 --- a/drivers/net/ethernet/microchip/sparx5/Makefile +++ b/drivers/net/ethernet/microchip/sparx5/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ sparx5_netdev.o sparx5_port.o sparx5_phylink.o sparx5_mactable.o sparx5_vlan.o \ - sparx5_switchdev.o sparx5_calendar.o + sparx5_switchdev.o sparx5_calendar.o sparx5_ethtool.o diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c new file mode 100644 index ..5cbde50533b9 --- /dev/null +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c @@ -0,0 +1,999 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Microchip Sparx5 Switch driver + * + * Copyright (c) 2021 Microchip Technology Inc. and its subsidiaries. + */ + +#include + +#include "sparx5_main_regs.h" +#include "sparx5_main.h" +#include "sparx5_port.h" + +/* Index of ANA_AC port counters */ +#define SPX5_PORT_POLICER_DROPS 0 + +/* Add a potentially wrapping 32 bit value to a 64 bit counter */ +static void sparx5_update_counter(u64 *cnt, u32 val) +{ + if (val < (*cnt & U32_MAX)) + *cnt += (u64)1 << 32; /* value has wrapped */ + + *cnt = (*cnt & ~(u64)U32_MAX) + val; +} + +/* Get a set of Queue System statistics */ +static void sparx5_xqs_prio_stats(struct sparx5 *sparx5, + u32 addr, + u64 *stats) +{ + int idx; + + for (idx = 0; idx < 2 * SPX5_PRIOS; ++idx, ++addr, ++stats) + sparx5_update_counter(stats, spx5_rd(sparx5, XQS_CNT(addr))); +} + +#define SPX5_STAT_GET(sname)portstats[spx5_stats_##sname] +#define SPX5_STAT_SUM(sname)(portstats[spx5_stats_##sname] + \ +portstats[spx5_stats_pmac_##sname]) +#define SPX5_STAT_XQS_PRIOS_COUNTER_SUM(sname)\ + (portstats[spx5_stats_green_p0_##sname] + \ + portstats[spx5_stats_green_p1_##sname] + \ + portstats[spx5_stats_green_p2_##sname] + \ + portstats[spx5_stats_green_p3_##sname] + \ + portstats[spx5_stats_green_p4_##sname] + \ + portstats[spx5_stats_green_p5_##sname] + \ + portstats[spx5_stats_green_p6_##sname] + \ + portstats[spx5_stats_green_p7_##sname] + \ + portstats[spx5_stats_yellow_p0_##sname] + \ + portstats[spx5_stats_yellow_p1_##sname] + \ + portstats[spx5_stats_yellow_p2_##sname] + \ + portstats[spx5_stats_yellow_p3_##sname] + \ + portstats[spx5_stats_yellow_p4_##sname] + \ + portstats[spx5_stats_yellow_p5_##sname] + \ + portstats[spx5_stats_yellow_p6_##sname] + \ + portstats[spx5_stats_yellow_p7_##sname]) + +enum sparx5_stats_entry { + spx5_stats_rx_in_bytes, + spx5_stats_rx_symbol_err, + spx5_stats_rx_pause, + spx5_stats_rx_unsup_opcode, + spx5_stats_rx_ok_bytes, + spx5_stats_rx_bad_bytes, + spx5_stats_rx_unicast, + spx5_stats_rx_multicast, + spx5_stats_rx_broadcast, + spx5_stats_rx_crc_err, + spx5_stats_rx_undersize, + spx5_stats_rx_fragments, + spx5_stats_rx_inrangelen_err, + spx5_stats_rx_outofrangelen_err, + spx5_stats_rx_oversize, + spx5_stats_rx_jabbers, + spx5_stats_rx_size64, + spx5_stats_rx_size65_127, + spx5_stats_rx_size128_255, + spx5_stats_rx_size256_511, + spx5_stats_rx_size512_1023, + spx5_stats_rx_size1024_1518, + spx5_stats_rx_size1519_max, + spx5_stats_pmac_rx_symbol_err, + spx5_stats_pmac_rx_pause, + spx5_stats_pmac_rx_unsup_opcode, + spx5_stats_pmac_rx_ok_bytes, + spx5_stats_pmac_rx_bad_bytes, + spx5_stats_pmac_rx_unicast, + spx5_stats_pmac_rx_multicast, + spx5_stats_pmac_rx_broadcast, + spx5_stats_pmac_rx_crc_err, + spx5_stats_pmac_rx_undersize, + spx5_stats_pmac_rx_fragments, + spx5_stats_pmac_rx_inrangelen_err, + spx5_stats_pmac_rx_outofrangelen_err, + spx5_stats_pmac_rx_o