Commit db2c7b35 authored by Ilya Lipnitskiy's avatar Ilya Lipnitskiy Committed by David S. Miller

net: ethernet: mtk_eth_soc: rework NAPI callbacks

Use napi_complete_done to communicate total TX and RX work done to NAPI.
Count total RX work up instead of remaining work down for clarity.
Remove unneeded local variables for clarity. Use do {} while instead of
goto for clarity.
Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 16769a89
...@@ -1496,7 +1496,6 @@ static void mtk_handle_status_irq(struct mtk_eth *eth) ...@@ -1496,7 +1496,6 @@ static void mtk_handle_status_irq(struct mtk_eth *eth)
static int mtk_napi_tx(struct napi_struct *napi, int budget) static int mtk_napi_tx(struct napi_struct *napi, int budget)
{ {
struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi); struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi);
u32 status, mask;
int tx_done = 0; int tx_done = 0;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
...@@ -1505,21 +1504,19 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget) ...@@ -1505,21 +1504,19 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
tx_done = mtk_poll_tx(eth, budget); tx_done = mtk_poll_tx(eth, budget);
if (unlikely(netif_msg_intr(eth))) { if (unlikely(netif_msg_intr(eth))) {
status = mtk_r32(eth, eth->tx_int_status_reg);
mask = mtk_r32(eth, eth->tx_int_mask_reg);
dev_info(eth->dev, dev_info(eth->dev,
"done tx %d, intr 0x%08x/0x%x\n", "done tx %d, intr 0x%08x/0x%x\n", tx_done,
tx_done, status, mask); mtk_r32(eth, eth->tx_int_status_reg),
mtk_r32(eth, eth->tx_int_mask_reg));
} }
if (tx_done == budget) if (tx_done == budget)
return budget; return budget;
status = mtk_r32(eth, eth->tx_int_status_reg); if (mtk_r32(eth, eth->tx_int_status_reg) & MTK_TX_DONE_INT)
if (status & MTK_TX_DONE_INT)
return budget; return budget;
if (napi_complete(napi)) if (napi_complete_done(napi, tx_done))
mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
return tx_done; return tx_done;
...@@ -1528,36 +1525,33 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget) ...@@ -1528,36 +1525,33 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
static int mtk_napi_rx(struct napi_struct *napi, int budget) static int mtk_napi_rx(struct napi_struct *napi, int budget)
{ {
struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi); struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi);
u32 status, mask; int rx_done_total = 0;
int rx_done = 0;
int remain_budget = budget;
mtk_handle_status_irq(eth); mtk_handle_status_irq(eth);
poll_again: do {
mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_STATUS); int rx_done;
rx_done = mtk_poll_rx(napi, remain_budget, eth);
if (unlikely(netif_msg_intr(eth))) { mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_STATUS);
status = mtk_r32(eth, MTK_PDMA_INT_STATUS); rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth);
mask = mtk_r32(eth, MTK_PDMA_INT_MASK); rx_done_total += rx_done;
dev_info(eth->dev,
"done rx %d, intr 0x%08x/0x%x\n",
rx_done, status, mask);
}
if (rx_done == remain_budget)
return budget;
status = mtk_r32(eth, MTK_PDMA_INT_STATUS); if (unlikely(netif_msg_intr(eth))) {
if (status & MTK_RX_DONE_INT) { dev_info(eth->dev,
remain_budget -= rx_done; "done rx %d, intr 0x%08x/0x%x\n", rx_done,
goto poll_again; mtk_r32(eth, MTK_PDMA_INT_STATUS),
} mtk_r32(eth, MTK_PDMA_INT_MASK));
}
if (rx_done_total == budget)
return budget;
} while (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT);
if (napi_complete(napi)) if (napi_complete_done(napi, rx_done_total))
mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
return rx_done + budget - remain_budget; return rx_done_total;
} }
static int mtk_tx_alloc(struct mtk_eth *eth) static int mtk_tx_alloc(struct mtk_eth *eth)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment