Commit 237577e6 authored by Nicolai Buchwitz's avatar Nicolai Buchwitz Committed by Jakub Kicinski
Browse files

net: cadence: macb: add EEE LPI statistics counters



The GEM MAC provides four read-only, clear-on-read LPI statistics
registers at offsets 0x270-0x27c:

  GEM_RXLPI     (0x270): RX LPI transition count (16-bit)
  GEM_RXLPITIME (0x274): cumulative RX LPI time (24-bit)
  GEM_TXLPI     (0x278): TX LPI transition count (16-bit)
  GEM_TXLPITIME (0x27c): cumulative TX LPI time (24-bit)

Add register offset definitions, extend struct gem_stats with
corresponding u64 software accumulators, and register the four
counters in gem_statistics[] so they appear in ethtool -S output.
Because the hardware counters clear on read, the existing
macb_update_stats() path accumulates them into the u64 fields on
every stats poll, preventing loss between userspace reads.

These registers are present on SAMA5D2, SAME70, PIC32CZ, and RP1
variants of the Cadence GEM IP and have been confirmed on RP1 via
devmem reads.

Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@tuxon.dev>
Reviewed-by: default avatarThéo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: default avatarNicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260304105432.631186-2-nb@tipi-net.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d4d8c6e6
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -170,6 +170,10 @@
#define GEM_PCSANNPTX		0x021c /* PCS AN Next Page TX */
#define GEM_PCSANNPLP		0x0220 /* PCS AN Next Page LP */
#define GEM_PCSANEXTSTS		0x023c /* PCS AN Extended Status */
#define GEM_RXLPI		0x0270 /* RX LPI Transitions */
#define GEM_RXLPITIME		0x0274 /* RX LPI Time */
#define GEM_TXLPI		0x0278 /* TX LPI Transitions */
#define GEM_TXLPITIME		0x027c /* TX LPI Time */
#define GEM_DCFG1		0x0280 /* Design Config 1 */
#define GEM_DCFG2		0x0284 /* Design Config 2 */
#define GEM_DCFG3		0x0288 /* Design Config 3 */
@@ -1043,6 +1047,10 @@ struct gem_stats {
	u64	rx_ip_header_checksum_errors;
	u64	rx_tcp_checksum_errors;
	u64	rx_udp_checksum_errors;
	u64	rx_lpi_transitions;
	u64	rx_lpi_time;
	u64	tx_lpi_transitions;
	u64	tx_lpi_time;
};

/* Describes the name and offset of an individual statistic register, as
@@ -1142,6 +1150,10 @@ static const struct gem_statistic gem_statistics[] = {
			    GEM_BIT(NDS_RXERR)),
	GEM_STAT_TITLE_BITS(RXUDPCCNT, "rx_udp_checksum_errors",
			    GEM_BIT(NDS_RXERR)),
	GEM_STAT_TITLE(RXLPI, "rx_lpi_transitions"),
	GEM_STAT_TITLE(RXLPITIME, "rx_lpi_time"),
	GEM_STAT_TITLE(TXLPI, "tx_lpi_transitions"),
	GEM_STAT_TITLE(TXLPITIME, "tx_lpi_time"),
};

#define GEM_STATS_LEN ARRAY_SIZE(gem_statistics)