|
|
@@ -1,12 +1,20 @@
|
|
|
+From e9229ffd550b2d8c4997c67a501dbc3919fd4e26 Mon Sep 17 00:00:00 2001
|
|
|
From: Felix Fietkau <[email protected]>
|
|
|
-Date: Wed, 26 Aug 2020 17:02:30 +0200
|
|
|
+Date: Thu, 22 Apr 2021 22:21:02 -0700
|
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: implement dynamic interrupt
|
|
|
moderation
|
|
|
|
|
|
Reduces the number of interrupts under load
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
+[Ilya: add documentation for new struct fields]
|
|
|
+Signed-off-by: Ilya Lipnitskiy <[email protected]>
|
|
|
+Signed-off-by: David S. Miller <[email protected]>
|
|
|
---
|
|
|
+ drivers/net/ethernet/mediatek/Kconfig | 1 +
|
|
|
+ drivers/net/ethernet/mediatek/mtk_eth_soc.c | 96 +++++++++++++++++++--
|
|
|
+ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 41 +++++++--
|
|
|
+ 3 files changed, 124 insertions(+), 14 deletions(-)
|
|
|
|
|
|
--- a/drivers/net/ethernet/mediatek/Kconfig
|
|
|
+++ b/drivers/net/ethernet/mediatek/Kconfig
|
|
|
@@ -35,7 +43,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
|
|
|
while (done < budget) {
|
|
|
struct net_device *netdev;
|
|
|
-@@ -1311,6 +1312,7 @@ static int mtk_poll_rx(struct napi_struc
|
|
|
+@@ -1312,6 +1313,7 @@ static int mtk_poll_rx(struct napi_struc
|
|
|
else
|
|
|
skb_checksum_none_assert(skb);
|
|
|
skb->protocol = eth_type_trans(skb, netdev);
|
|
|
@@ -43,7 +51,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
|
|
|
if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX &&
|
|
|
(trxd.rxd2 & RX_DMA_VTAG))
|
|
|
-@@ -1342,6 +1344,12 @@ rx_done:
|
|
|
+@@ -1344,6 +1346,12 @@ rx_done:
|
|
|
mtk_update_rx_cpu_idx(eth);
|
|
|
}
|
|
|
|
|
|
@@ -56,7 +64,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
return done;
|
|
|
}
|
|
|
|
|
|
-@@ -1434,6 +1442,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
|
|
|
+@@ -1436,6 +1444,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
|
|
|
static int mtk_poll_tx(struct mtk_eth *eth, int budget)
|
|
|
{
|
|
|
struct mtk_tx_ring *ring = ð->tx_ring;
|
|
|
@@ -64,7 +72,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
unsigned int done[MTK_MAX_DEVS];
|
|
|
unsigned int bytes[MTK_MAX_DEVS];
|
|
|
int total = 0, i;
|
|
|
-@@ -1451,8 +1460,14 @@ static int mtk_poll_tx(struct mtk_eth *e
|
|
|
+@@ -1453,8 +1462,14 @@ static int mtk_poll_tx(struct mtk_eth *e
|
|
|
continue;
|
|
|
netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
|
|
|
total += done[i];
|
|
|
@@ -79,7 +87,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
if (mtk_queue_stopped(eth) &&
|
|
|
(atomic_read(&ring->free_count) > ring->thresh))
|
|
|
mtk_wake_queue(eth);
|
|
|
-@@ -2127,6 +2142,7 @@ static irqreturn_t mtk_handle_irq_rx(int
|
|
|
+@@ -2129,6 +2144,7 @@ static irqreturn_t mtk_handle_irq_rx(int
|
|
|
{
|
|
|
struct mtk_eth *eth = _eth;
|
|
|
|
|
|
@@ -87,7 +95,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
if (likely(napi_schedule_prep(ð->rx_napi))) {
|
|
|
__napi_schedule(ð->rx_napi);
|
|
|
mtk_rx_irq_disable(eth, MTK_RX_DONE_INT);
|
|
|
-@@ -2139,6 +2155,7 @@ static irqreturn_t mtk_handle_irq_tx(int
|
|
|
+@@ -2141,6 +2157,7 @@ static irqreturn_t mtk_handle_irq_tx(int
|
|
|
{
|
|
|
struct mtk_eth *eth = _eth;
|
|
|
|
|
|
@@ -95,7 +103,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
if (likely(napi_schedule_prep(ð->tx_napi))) {
|
|
|
__napi_schedule(ð->tx_napi);
|
|
|
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
|
|
|
-@@ -2323,6 +2340,9 @@ static int mtk_stop(struct net_device *d
|
|
|
+@@ -2325,6 +2342,9 @@ static int mtk_stop(struct net_device *d
|
|
|
napi_disable(ð->tx_napi);
|
|
|
napi_disable(ð->rx_napi);
|
|
|
|
|
|
@@ -105,7 +113,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
|
|
|
mtk_stop_dma(eth, MTK_QDMA_GLO_CFG);
|
|
|
mtk_stop_dma(eth, MTK_PDMA_GLO_CFG);
|
|
|
-@@ -2375,6 +2395,64 @@ err_disable_clks:
|
|
|
+@@ -2377,6 +2397,64 @@ err_disable_clks:
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -170,7 +178,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
static int mtk_hw_init(struct mtk_eth *eth)
|
|
|
{
|
|
|
int i, val, ret;
|
|
|
-@@ -2396,9 +2474,6 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
|
+@@ -2398,9 +2476,6 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
|
goto err_disable_pm;
|
|
|
}
|
|
|
|
|
|
@@ -180,12 +188,13 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
/* disable delay and normal interrupt */
|
|
|
mtk_tx_irq_disable(eth, ~0);
|
|
|
mtk_rx_irq_disable(eth, ~0);
|
|
|
-@@ -2437,11 +2512,10 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
|
+@@ -2439,11 +2514,11 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
|
/* Enable RX VLan Offloading */
|
|
|
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
|
|
|
|
|
|
- /* enable interrupt delay for RX */
|
|
|
- mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT);
|
|
|
++ /* set interrupt delays based on current Net DIM sample */
|
|
|
+ mtk_dim_rx(ð->rx_dim.work);
|
|
|
+ mtk_dim_tx(ð->tx_dim.work);
|
|
|
|
|
|
@@ -194,7 +203,7 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
mtk_tx_irq_disable(eth, ~0);
|
|
|
mtk_rx_irq_disable(eth, ~0);
|
|
|
|
|
|
-@@ -2946,6 +3020,13 @@ static int mtk_probe(struct platform_dev
|
|
|
+@@ -2948,6 +3023,13 @@ static int mtk_probe(struct platform_dev
|
|
|
spin_lock_init(ð->page_lock);
|
|
|
spin_lock_init(ð->tx_irq_lock);
|
|
|
spin_lock_init(ð->rx_irq_lock);
|
|
|
@@ -260,7 +269,30 @@ Signed-off-by: Felix Fietkau <[email protected]>
|
|
|
|
|
|
/* QDMA Interrupt grouping registers */
|
|
|
#define MTK_QDMA_INT_GRP1 0x1a20
|
|
|
-@@ -905,6 +911,18 @@ struct mtk_eth {
|
|
|
+@@ -843,6 +849,7 @@ struct mtk_sgmii {
|
|
|
+ * @page_lock: Make sure that register operations are atomic
|
|
|
+ * @tx_irq__lock: Make sure that IRQ register operations are atomic
|
|
|
+ * @rx_irq__lock: Make sure that IRQ register operations are atomic
|
|
|
++ * @dim_lock: Make sure that Net DIM operations are atomic
|
|
|
+ * @dummy_dev: we run 2 netdevs on 1 physical DMA ring and need a
|
|
|
+ * dummy for NAPI to work
|
|
|
+ * @netdev: The netdev instances
|
|
|
+@@ -861,6 +868,14 @@ struct mtk_sgmii {
|
|
|
+ * @rx_ring_qdma: Pointer to the memory holding info about the QDMA RX ring
|
|
|
+ * @tx_napi: The TX NAPI struct
|
|
|
+ * @rx_napi: The RX NAPI struct
|
|
|
++ * @rx_events: Net DIM RX event counter
|
|
|
++ * @rx_packets: Net DIM RX packet counter
|
|
|
++ * @rx_bytes: Net DIM RX byte counter
|
|
|
++ * @rx_dim: Net DIM RX context
|
|
|
++ * @tx_events: Net DIM TX event counter
|
|
|
++ * @tx_packets: Net DIM TX packet counter
|
|
|
++ * @tx_bytes: Net DIM TX byte counter
|
|
|
++ * @tx_dim: Net DIM TX context
|
|
|
+ * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring
|
|
|
+ * @phy_scratch_ring: physical address of scratch_ring
|
|
|
+ * @scratch_head: The scratch memory that scratch_ring points to.
|
|
|
+@@ -905,6 +920,18 @@ struct mtk_eth {
|
|
|
|
|
|
const struct mtk_soc_data *soc;
|
|
|
|