Skip to content

Commit eaa3832

Browse files
committed
net: cadence: macb: add RX LPI status change interrupt support
Wire the RXLPISBC interrupt (ISR bit 27) into the macb interrupt handler to track when the link partner enters or exits Low Power Idle. The GEM MAC fires RXLPISBC on each RX LPI status transition. The handler toggles rx_lpi_active state and emits a debug log on each change. The interrupt is enabled in mac_link_up and disabled in mac_link_down, gated on MACB_CAPS_EEE. This complements the existing TX LPI support and LPI statistics counters with active RX LPI state monitoring for diagnostics. Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
1 parent b20851c commit eaa3832

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

drivers/net/ethernet/cadence/macb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ struct macb {
13631363
/* EEE / LPI state */
13641364
bool eee_active;
13651365
bool tx_lpi_enabled;
1366+
bool rx_lpi_active;
13661367
struct delayed_work tx_lpi_work;
13671368
unsigned int tx_lpi_timer_ms; /* idle timeout before LPI */
13681369

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,16 @@ static void macb_mac_link_down(struct phylink_config *config, unsigned int mode,
803803
unsigned int q;
804804
u32 ctrl;
805805

806-
if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
807-
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
808-
queue_writel(queue, IDR,
809-
bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
806+
if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
807+
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
808+
u32 idr = bp->rx_intr_mask | MACB_TX_INT_FLAGS |
809+
MACB_BIT(HRESP);
810+
811+
if (bp->caps & MACB_CAPS_EEE)
812+
idr |= GEM_BIT(RXLPISBC);
813+
queue_writel(queue, IDR, idr);
814+
}
815+
}
810816

811817
/* Cancel any pending LPI entry */
812818
cancel_delayed_work(&bp->tx_lpi_work);
@@ -817,6 +823,7 @@ static void macb_mac_link_down(struct phylink_config *config, unsigned int mode,
817823

818824
bp->eee_active = false;
819825
bp->tx_lpi_enabled = false;
826+
bp->rx_lpi_active = false;
820827

821828
netif_tx_stop_all_queues(ndev);
822829
}
@@ -859,10 +866,14 @@ static void macb_mac_link_up(struct phylink_config *config,
859866
ctrl |= MACB_BIT(PAE);
860867

861868
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
869+
u32 ier = bp->rx_intr_mask | MACB_TX_INT_FLAGS |
870+
MACB_BIT(HRESP);
871+
872+
if (bp->caps & MACB_CAPS_EEE)
873+
ier |= GEM_BIT(RXLPISBC);
862874
queue->tx_head = 0;
863875
queue->tx_tail = 0;
864-
queue_writel(queue, IER,
865-
bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
876+
queue_writel(queue, IER, ier);
866877
}
867878
}
868879

@@ -2130,6 +2141,15 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
21302141
if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
21312142
queue_writel(queue, ISR, MACB_BIT(HRESP));
21322143
}
2144+
2145+
if (status & GEM_BIT(RXLPISBC)) {
2146+
bp->rx_lpi_active = !bp->rx_lpi_active;
2147+
netdev_dbg(dev, "EEE RX LPI %s\n",
2148+
bp->rx_lpi_active ? "enter" : "exit");
2149+
if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
2150+
queue_writel(queue, ISR,
2151+
GEM_BIT(RXLPISBC));
2152+
}
21332153
status = queue_readl(queue, ISR);
21342154
}
21352155

0 commit comments

Comments
 (0)