> On 4/30/26 4:49 AM, Wei Fang wrote:
> > Implement the ethtool private statistics interface to expose additional
> > port-level and MAC-level counters that are not covered by the standard
> > IEEE 802.3 statistics. The pMAC counters are only reported when the port
> > supports Frame Preemption (802.1Qbu/802.3br).
> >
> > Signed-off-by: Wei Fang <[email protected]>
> > ---
> >  drivers/net/dsa/netc/netc_ethtool.c   | 107
> ++++++++++++++++++++++++++
> >  drivers/net/dsa/netc/netc_main.c      |   3 +
> >  drivers/net/dsa/netc/netc_switch.h    |   9 +++
> >  drivers/net/dsa/netc/netc_switch_hw.h |  58 ++++++++++++++
> >  4 files changed, 177 insertions(+)
> >
> > diff --git a/drivers/net/dsa/netc/netc_ethtool.c
> b/drivers/net/dsa/netc/netc_ethtool.c
> > index ac8940b5a85c..8d04db534347 100644
> > --- a/drivers/net/dsa/netc/netc_ethtool.c
> > +++ b/drivers/net/dsa/netc/netc_ethtool.c
> > @@ -19,6 +19,56 @@ static const struct ethtool_rmon_hist_range
> netc_rmon_ranges[] = {
> >     { }
> >  };
> >
> > +static const struct netc_port_stat netc_port_counters[] = {
> > +   { NETC_PTGSLACR,        "port gate late arrival frames" },
> > +   { NETC_PSDFTCR, "port SDF transmit frames" },
> > +   { NETC_PSDFDDCR,        "port SDF drop duplicate frames" },
> > +   { NETC_PRXDCR,          "port rx discard frames" },
> > +   { NETC_PRXDCRRR,        "port rx discard read-reset" },
> > +   { NETC_PRXDCRR0,        "port rx discard reason 0" },
> > +   { NETC_PRXDCRR1,        "port rx discard reason 1" },
> > +   { NETC_PTXDCR,          "port tx discard frames" },
> > +   { NETC_PTXDCRRR,        "port tx discard read-reset" },
> > +   { NETC_PTXDCRR0,        "port tx discard reason 0" },
> > +   { NETC_PTXDCRR1,        "port tx discard reason 1" },
> > +   { NETC_BPDCR,           "bridge port discard frames" },
> > +   { NETC_BPDCRRR, "bridge port discard read-reset" },
> > +   { NETC_BPDCRR0, "bridge port discard reason 0" },
> > +   { NETC_BPDCRR1, "bridge port discard reason 1" },
> > +};
> > +
> > +static const struct netc_port_stat netc_emac_counters[] = {
> > +   { NETC_PM_ROCT(0),      "eMAC rx octets" },
> > +   { NETC_PM_RVLAN(0),     "eMAC rx VLAN frames" },
> > +   { NETC_PM_RERR(0),      "eMAC rx frame errors" },
> > +   { NETC_PM_RUCA(0),      "eMAC rx unicast frames" },
> > +   { NETC_PM_RDRP(0),      "eMAC rx dropped packets" },
> > +   { NETC_PM_RPKT(0),      "eMAC rx packets" },
> > +   { NETC_PM_TOCT(0),      "eMAC tx octets" },
> > +   { NETC_PM_TVLAN(0),     "eMAC tx VLAN frames" },
> > +   { NETC_PM_TFCS(0),      "eMAC tx FCS errors" },
> > +   { NETC_PM_TUCA(0),      "eMAC tx unicast frames" },
> > +   { NETC_PM_TPKT(0),      "eMAC tx packets" },
> > +   { NETC_PM_TUND(0),      "eMAC tx undersized packets" },
> > +   { NETC_PM_TIOCT(0),     "eMAC tx invalid octets" },
> > +};
> > +
> > +static const struct netc_port_stat netc_pmac_counters[] = {
> > +   { NETC_PM_ROCT(1),      "pMAC rx octets" },
> > +   { NETC_PM_RVLAN(1),     "pMAC rx VLAN frames" },
> > +   { NETC_PM_RERR(1),      "pMAC rx frame errors" },
> > +   { NETC_PM_RUCA(1),      "pMAC rx unicast frames" },
> > +   { NETC_PM_RDRP(1),      "pMAC rx dropped packets" },
> > +   { NETC_PM_RPKT(1),      "pMAC rx packets" },
> > +   { NETC_PM_TOCT(1),      "pMAC tx octets" },
> > +   { NETC_PM_TVLAN(1),     "pMAC tx VLAN frames" },
> > +   { NETC_PM_TFCS(1),      "pMAC tx FCS errors" },
> > +   { NETC_PM_TUCA(1),      "pMAC tx unicast frames" },
> > +   { NETC_PM_TPKT(1),      "pMAC tx packets" },
> > +   { NETC_PM_TUND(1),      "pMAC tx undersized packets" },
> > +   { NETC_PM_TIOCT(1),     "pMAC tx invalid octets" },
> > +};
> 
> Sashiko says:
> 
> Are these standard MAC and interface statistics being duplicated in the
> driver-private ethtool strings?
> The networking subsystem guidelines indicate that statistics which have
> a standard uAPI must not be duplicated in ethtool -S. Standard
> interfaces like struct rtnl_link_stats64 or struct ethtool_eth_mac_stats
> already exist for counters such as rx octets, rx packets, dropped
> packets, and FCS errors.
> Could these metrics be exposed through the standardized interfaces
> rather than adding them to the private string sets?
> 

I don't think it is an issue. For the NETC switch, its ports support preemption,
so each port has two MACs (express MAC and preemptive MAC). The driver-
private statistics can help users obtain statistics for each MAC, just like the
standard statistics of ethtool. However, rtnl_link_stats64 retrieves the 
combined
statistics of the two MACs.

In addition, ethtool_eth_mac_stats only has the FCS error counter for RX,
not TX. what I added to driver-private was TX's FCS error counter.

Reply via email to