On Tue, Feb 08, 2022 at 03:34:49PM +0000, Vladimir Oltean wrote:
> On Tue, Feb 08, 2022 at 05:03:03PM +0200, Vladimir Oltean wrote:
> > > for (i = 0; i < ocelot->num_phys_ports; i++) {
> > > + unsigned int idx = 0;
> > > +
> >
> > This is a bug which causes ocelot->stats to be overwritten with the
> > statistics of port 0, for all ports. Either move the variable
> > declaration and initialization with 0 in the larger scope (outside the
> > "for" loop), or initialize idx with i * ocelot->num_stats.
>
> My analysis was slightly incorrect. Somehow I managed to fool myself
> into thinking that you had tested this in a limited scenario, hence the
> reason you didn't notice it's not working. But apparently you didn't
> test with traffic at all.
>
> So ocelot->stats isn't overwritten with the stats of port 0 for all
> ports. But rather, all ports write into the ocelot->stats space
> dedicated for port 0, effectively overwriting the stats of port 0 with
> the stats of the last port. And no one populates the ocelot->stats space
> for ports [1 .. last]. So no port has good statistics, I don't see a
> circumstance where testing could have misled you.
Both ethtool -S and debugfs show statistics that I'd expect in my test
setup. But yes, the port 0 stats would be especially curious.
EDIT: Just saw your message about these. Yes, port 0 is all messed up:
# ethtool -S eth0 | grep p00 | head
p00_rx_octets: 13602161426432
p00_rx_unicast: 4539780431872
p00_rx_multicast: 9028021256192
p00_rx_broadcast: 8980776615936
p00_rx_shorts: 0
p00_rx_fragments: 0
p00_rx_jabbers: 0
p00_rx_crc_align_errs: 0
p00_rx_sym_errs: 0
p00_rx_frames_below_65_octets: 4539780431872
(configuration - swp2 plugged into swp3, bridged with stp. swp1 into my
development machine, swp4-7 not up)
# pwd
/sys/class/net
# cat swp[123]/statistics/tx_bytes
44616
44668
52
# cat swp[123]/statistics/rx_bytes
34574
46
73272
# ethtool -S swp1 | head -n 5
NIC statistics:
tx_packets: 942
tx_bytes: 48984
rx_packets: 764
rx_bytes: 37808
# ethtool -S swp2 | head -n 5
NIC statistics:
tx_packets: 946
tx_bytes: 49192
rx_packets: 1
rx_bytes: 46
# ethtool -S swp3 | head -n 5
NIC statistics:
tx_packets: 1
tx_bytes: 52
rx_packets: 1699
rx_bytes: 80658
# ethtool -S swp4 | head -n 5
NIC statistics:
tx_packets: 0
tx_bytes: 0
rx_packets: 0
rx_bytes: 0
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1520 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
3: swp1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
4: swp2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
5: swp3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
6: swp4@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
7: swp5@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
8: swp6@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
9: swp7@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
10: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 24:76:25:76:35:37 brd ff:ff:ff:ff:ff:ff
Clearly my testing wasn't sufficient as there were still issues, but
there were reasonable signs of things working as expected on ports 1-4.
On Tue, Feb 08, 2022 at 08:07:42AM -0800, Colin Foster wrote:
> # ethtool -S swp1 | head -n 5
> NIC statistics:
> tx_packets: 942
> tx_bytes: 48984
> rx_packets: 764
> rx_bytes: 37808
> # ethtool -S swp2 | head -n 5
> NIC statistics:
> tx_packets: 946
> tx_bytes: 49192
> rx_packets: 1
> rx_bytes: 46
> # ethtool -S swp3 | head -n 5
> NIC statistics:
> tx_packets: 1
> tx_bytes: 52
> rx_packets: 1699
> rx_bytes: 80658
> # ethtool -S swp4 | head -n 5
> NIC statistics:
> tx_packets: 0
> tx_bytes: 0
> rx_packets: 0
> rx_bytes: 0
I understand what confused you now. These are software counters patched
in by dsa_slave_get_ethtool_stats(). They are in no way the counters
from felix_info :: stats_layout, please compare the strings!