Ethtool statistics counters cleanup for SJA1105 DSA driver
Vladimir Oltean
maintainercover Ethtool statistics counters cleanup for SJA1105 DSA driver
From: Vladimir Oltean <[email protected]>
This series removes some reported data from ethtool -S which were not counters at all, and reorganizes the code such that counters can be read individually and not just all at once.
Vladimir Oltean (2):
net: dsa: sja1105: stop reporting the queue levels in ethtool port
counters
net: dsa: sja1105: don't use burst SPI reads for port statistics
drivers/net/dsa/sja1105/sja1105.h | 14 +- drivers/net/dsa/sja1105/sja1105_ethtool.c | 1089 +++++++++++---------- drivers/net/dsa/sja1105/sja1105_spi.c | 15 +- 3 files changed, 598 insertions(+), 520 deletions(-)
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 1/2 net: dsa: sja1105: stop reporting the queue levels in ethtool port counters
From: Vladimir Oltean <[email protected]>
The queue levels are not counters, but instead they represent the occupancy of the MAC TX queues. Having these in ethtool port counters is not helpful, so remove them.
--- drivers/net/dsa/sja1105/sja1105.h | 1 - drivers/net/dsa/sja1105/sja1105_ethtool.c | 54 +---------------------- drivers/net/dsa/sja1105/sja1105_spi.c | 1 - 3 files changed, 2 insertions(+), 54 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +0 -1
@@ -65,7 +65,6 @@ struct sja1105_regs {u64 mac_hl1[SJA1105_NUM_PORTS ];u64 mac_hl2[SJA1105_NUM_PORTS ];u64 ether_stats[SJA1105_NUM_PORTS ]; -u64 qlevel[SJA1105_NUM_PORTS ]; };struct sja1105_info {
drivers/net/dsa/sja1105/sja1105_ethtool.c +2 -52
102 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +0 -1
@@ -464,7 +464,6 @@ static struct sja1105_regs sja1105pqrs_regs = { .rgmii_tx_clk = {0x100016, 0x10001C, 0x100022, 0x100028, 0x10002E}, .rmii_ref_clk = {0x100015, 0x10001B, 0x100021, 0x100027, 0x10002D}, .rmii_ext_tx_clk = {0x100017, 0x10001D, 0x100023, 0x100029, 0x10002F}, - .qlevel = {0x604, 0x614, 0x624, 0x634, 0x644}, .ptpegr_ts = {0xC0, 0xC4, 0xC8, 0xCC, 0xD0}, .ptpschtm = 0x13, /* Spans 0x13 to 0x14 */ .ptppinst = 0x15,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 2/2 net: dsa: sja1105: don't use burst SPI reads for port statistics
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The current internal sja1105 driver API is optimized for retrieving many statistics counters at once. But the switch does not do atomic snapshotting for them anyway.
In case we start reporting the hardware port counters through ndo_get_stats64 as well, not just ethtool, it would be good to be able to read individual port counters and not all of them.
Additionally, since Arnd Bergmann's commit ae1804de93f6 ("dsa: sja1105:
dynamically allocate stats structure"), sja1105_get_ethtool_stats allocates memory dynamically, since struct sja1105_port_status was deemed to consume too much stack memory. That is not ideal. The large structure is only needed because of the burst read. If we read statistics one by one, we can consume less memory, and we can avoid dynamic allocation.
Additionally, latency-sensitive interfaces such as PTP operations (for phc2sys) might suffer if the SPI mutex is being held for too long, which happens in the case of SPI burst reads. By reading counters one by one, we give a chance for higher priority processes to preempt and take the SPI bus mutex for accessing the PTP clock.
--- drivers/net/dsa/sja1105/sja1105.h | 13 +- drivers/net/dsa/sja1105/sja1105_ethtool.c | 1039 ++++++++++++--------- drivers/net/dsa/sja1105/sja1105_spi.c | 14 +- 3 files changed, 598 insertions(+), 468 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +9 -4
@@ -30,6 +30,14 @@ typedef enum {#include "sja1105_tas.h" #include "sja1105_ptp.h" +enum sja1105_stats_area { +MAC , +HL1 , +HL2 , +ETHER , + __MAX_SJA1105_STATS_AREA, +}; +/* Keeps the different addresses between E/T and P/Q/R/S */ struct sja1105_regs {u64 device_id;
@@ -61,10 +69,7 @@ struct sja1105_regs {u64 rgmii_tx_clk[SJA1105_NUM_PORTS ];u64 rmii_ref_clk[SJA1105_NUM_PORTS ];u64 rmii_ext_tx_clk[SJA1105_NUM_PORTS ]; -u64 mac[SJA1105_NUM_PORTS ]; -u64 mac_hl1[SJA1105_NUM_PORTS ]; -u64 mac_hl2[SJA1105_NUM_PORTS ]; -u64 ether_stats[SJA1105_NUM_PORTS ]; +u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_NUM_PORTS ]; };struct sja1105_info {
drivers/net/dsa/sja1105/sja1105_ethtool.c +582 -457
1,084 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +7 -7
@@ -416,9 +416,9 @@ static struct sja1105_regs sja1105et_regs = { .pad_mii_rx = {0x100801, 0x100803, 0x100805, 0x100807, 0x100809}, .rmii_pll1 = 0x10000A, .cgu_idiv = {0x10000B, 0x10000C, 0x10000D, 0x10000E, 0x10000F}, - .mac = {0x200, 0x202, 0x204, 0x206, 0x208}, - .mac_hl1 = {0x400, 0x410, 0x420, 0x430, 0x440}, - .mac_hl2 = {0x600, 0x610, 0x620, 0x630, 0x640}, + .stats[MAC] = {0x200, 0x202, 0x204, 0x206, 0x208}, + .stats[HL1] = {0x400, 0x410, 0x420, 0x430, 0x440}, + .stats[HL2] = {0x600, 0x610, 0x620, 0x630, 0x640},/* UM10944.pdf, Table 78, CGU Register overview */ .mii_tx_clk = {0x100013, 0x10001A, 0x100021, 0x100028, 0x10002F}, .mii_rx_clk = {0x100014, 0x10001B, 0x100022, 0x100029, 0x100030},
@@ -452,10 +452,10 @@ static struct sja1105_regs sja1105pqrs_regs = { .sgmii = 0x1F0000, .rmii_pll1 = 0x10000A, .cgu_idiv = {0x10000B, 0x10000C, 0x10000D, 0x10000E, 0x10000F}, - .mac = {0x200, 0x202, 0x204, 0x206, 0x208}, - .mac_hl1 = {0x400, 0x410, 0x420, 0x430, 0x440}, - .mac_hl2 = {0x600, 0x610, 0x620, 0x630, 0x640}, - .ether_stats = {0x1400, 0x1418, 0x1430, 0x1448, 0x1460}, + .stats[MAC] = {0x200, 0x202, 0x204, 0x206, 0x208}, + .stats[HL1] = {0x400, 0x410, 0x420, 0x430, 0x440}, + .stats[HL2] = {0x600, 0x610, 0x620, 0x630, 0x640}, + .stats[ETHER] = {0x1400, 0x1418, 0x1430, 0x1448, 0x1460},/* UM11040.pdf, Table 114 */ .mii_tx_clk = {0x100013, 0x100019, 0x10001F, 0x100025, 0x10002B}, .mii_rx_clk = {0x100014, 0x10001A, 0x100020, 0x100026, 0x10002C},
Signature · 1 line
2.25.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 6 lines · On Fri, 21 May 2021 16:16:06 +0300 you wrote:
From: Vladimir Oltean <[email protected]>
This series removes some reported data from ethtool -S which were not counters at all, and reorganizes the code such that counters can be read individually and not just all at once.
Quoted 6 lines
Vladimir Oltean (2):
net: dsa: sja1105: stop reporting the queue levels in ethtool port
counters
net: dsa: sja1105: don't use burst SPI reads for port statistics[...]
Here is the summary with links:
- [net-next,1/2] net: dsa: sja1105: stop reporting the queue levels in ethtool port counters
https://git.kernel.org/netdev/net-next/c/30a2e9c0f5cf - [net-next,2/2] net: dsa: sja1105: don't use burst SPI reads for port statistics https://git.kernel.org/netdev/net-next/c/039b167d68a3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html