]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: cadence: macb: add EEE LPI statistics counters
authorNicolai Buchwitz <nb@tipi-net.de>
Wed, 4 Mar 2026 10:54:28 +0000 (11:54 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Mar 2026 02:56:47 +0000 (18:56 -0800)
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: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Reviewed-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260304105432.631186-2-nb@tipi-net.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cadence/macb.h

index 87414a2ddf6e3ad912b0d3c8e5e1954fe623f265..19aa98d01c8ccd302f54d0795b7b3582a1d35fa4 100644 (file)
 #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)