2017-04-11 08:34:37

by Sean Wang

[permalink] [raw]
Subject: [PATCH net-next] net: ethernet: mediatek: enhance TX path with recycling more SKBs in one poll

From: Sean Wang <[email protected]>

The patch adds the enhancement for recycling more TX completed SKBs in
one NAPI polling handler if NAPI budgets are still available and hardware
raises status bit shown for certain SKBs are aready done.

Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 14e1bd1..ac8f1b9 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1074,10 +1074,13 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi);
u32 status, mask;
int tx_done = 0;
+ int remain_budget = budget;

mtk_handle_status_irq(eth);
+
+poll_again:
mtk_w32(eth, MTK_TX_DONE_INT, MTK_QMTK_INT_STATUS);
- tx_done = mtk_poll_tx(eth, budget);
+ tx_done = mtk_poll_tx(eth, remain_budget);

if (unlikely(netif_msg_intr(eth))) {
status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
@@ -1087,17 +1090,19 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
tx_done, status, mask);
}

- if (tx_done == budget)
+ if (tx_done == remain_budget)
return budget;

status = mtk_r32(eth, MTK_QMTK_INT_STATUS);
- if (status & MTK_TX_DONE_INT)
- return budget;
+ if (status & MTK_TX_DONE_INT) {
+ remain_budget -= tx_done;
+ goto poll_again;
+ }

napi_complete(napi);
mtk_irq_enable(eth, MTK_QDMA_INT_MASK, MTK_TX_DONE_INT);

- return tx_done;
+ return tx_done + budget - remain_budget;
}

static int mtk_napi_rx(struct napi_struct *napi, int budget)
--
1.9.1


2017-04-11 14:49:28

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next] net: ethernet: mediatek: enhance TX path with recycling more SKBs in one poll

From: <[email protected]>
Date: Tue, 11 Apr 2017 16:34:27 +0800

> From: Sean Wang <[email protected]>
>
> The patch adds the enhancement for recycling more TX completed SKBs in
> one NAPI polling handler if NAPI budgets are still available and hardware
> raises status bit shown for certain SKBs are aready done.
>
> Signed-off-by: Sean Wang <[email protected]>

You should always, unconditionally, process all TX reclaim events
every NAPI poll, regardless of how much budget is left.

TX reclaim work is not counted against the NAPI budget, only RX work
should be.