mirror-linux/drivers/net
Vladimir Oltean ec6cd79c4e net: mscc: ocelot: fix stats region batching
[ Upstream commit 6acc72a43e ]

The blamed commit changed struct ocelot_stat_layout :: "u32 offset" to
"u32 reg".

However, "u32 reg" is not quite a register address, but an enum
ocelot_reg, which in itself encodes an enum ocelot_target target in the
upper bits, and an index into the ocelot->map[target][] array in the
lower bits.

So, whereas the previous code comparison between stats_layout[i].offset
and last + 1 was correct (because those "offsets" at the time were
32-bit relative addresses), the new code, comparing layout[i].reg to
last + 4 is not correct, because the "reg" here is an enum/index, not an
actual register address.

What we want to compare are indeed register addresses, but to do that,
we need to actually go through the same motions as
__ocelot_bulk_read_ix() itself.

With this bug, all statistics counters are deemed by
ocelot_prepare_stats_regions() as constituting their own region.
(Truncated) log on VSC9959 (Felix) below (prints added by me):

Before:

region of 1 contiguous counters starting with SYS:STAT:CNT[0x000]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x001]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x002]
...
region of 1 contiguous counters starting with SYS:STAT:CNT[0x041]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x042]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x080]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x081]
...
region of 1 contiguous counters starting with SYS:STAT:CNT[0x0ac]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x100]
region of 1 contiguous counters starting with SYS:STAT:CNT[0x101]
...
region of 1 contiguous counters starting with SYS:STAT:CNT[0x111]

After:

region of 67 contiguous counters starting with SYS:STAT:CNT[0x000]
region of 45 contiguous counters starting with SYS:STAT:CNT[0x080]
region of 18 contiguous counters starting with SYS:STAT:CNT[0x100]

Since commit d87b1c08f3 ("net: mscc: ocelot: use bulk reads for
stats") intended bulking as a performance improvement, and since now,
with trivial-sized regions, performance is even worse than without
bulking at all, this could easily qualify as a performance regression.

Fixes: d4c3676507 ("net: mscc: ocelot: keep ocelot_stat_layout by reg address, not offset")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Colin Foster <colin.foster@in-advantage.com>
Tested-by: Colin Foster <colin.foster@in-advantage.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-06 12:10:37 +02:00
..
appletalk
arcnet
bonding bonding: restore bond's IFF_SLAVE flag if a non-eth dev enslave fails 2023-03-22 13:33:51 +01:00
caif
can can: esd_usb: Make use of can_change_state() and relocate checking skb for NULL 2023-03-10 09:33:06 +01:00
dsa net: dsa: mt7530: move setting ssc_delta to PHY_INTERFACE_MODE_TRGMII case 2023-03-30 12:49:11 +02:00
ethernet net: mscc: ocelot: fix stats region batching 2023-04-06 12:10:37 +02:00
fddi
fjes
hamradio hamradio: baycom_epp: Fix return type of baycom_send_packet() 2022-12-31 13:33:00 +01:00
hippi
hyperv hv_netvsc: Check status in SEND_RNDIS_PKT completion message 2023-03-10 09:33:53 +01:00
ieee802154 ca8210: fix mac_len negative array access 2023-03-30 12:49:16 +02:00
ipa net: ipa: generic command param fix 2023-03-10 09:33:02 +01:00
ipvlan ipvlan: Make skb->skb_iif track skb->dev for l3s mode 2023-03-22 13:33:44 +01:00
mctp mctp: serial: Fix starting value for frame check sequence 2022-12-31 13:32:56 +01:00
mdio net: mdio: thunder: Add missing fwnode_handle_put() 2023-03-30 12:49:11 +02:00
netdevsim
pcs
phy net: mdio: fix owner field for mdio buses registered using device-tree 2023-03-30 12:49:05 +02:00
plip
ppp use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00
pse-pd
slip
team
usb net: usb: qmi_wwan: add Telit 0x1080 composition 2023-03-30 12:49:19 +02:00
vmxnet3 vmxnet3: move rss code block under eop descriptor 2023-02-22 12:59:46 +01:00
vxlan vxlan: Fix memory leaks in error path 2023-01-12 12:02:25 +01:00
wan net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs 2023-02-01 08:34:17 +01:00
wireguard
wireless wifi: ath11k: allow system suspend to survive ath11k 2023-03-10 09:34:22 +01:00
wwan net: wwan: t7xx: Fix Runtime PM initialization 2023-02-09 11:28:05 +01:00
xen-netback
Kconfig
LICENSE.SRC
Makefile
Space.c
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c
loopback.c
macsec.c
macvlan.c
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tap.c tap: tap_open(): correctly initialize socket uid 2023-03-10 09:33:01 +01:00
thunderbolt.c
tun.c tun: tun_chr_open(): correctly initialize socket uid 2023-03-10 09:33:01 +01:00
veth.c veth: Fix use after free in XDP_REDIRECT 2023-03-22 13:33:49 +01:00
virtio_net.c virtio-net: Keep stop() to follow mirror sequence of open() 2023-02-09 11:28:11 +01:00
vrf.c net: vrf: determine the dst using the original ifindex for multicast 2023-01-12 12:01:57 +01:00
vsockmon.c
xen-netfront.c