Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: use napi_consume_skb
Browse files Browse the repository at this point in the history
Should improve performance, since it can use bulk free

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Felix Fietkau authored and David S. Miller committed Apr 23, 2021
1 parent 787082a commit c30c4a8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma)
return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
}

static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf)
static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
bool napi)
{
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) {
Expand Down Expand Up @@ -890,8 +891,12 @@ static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf)

tx_buf->flags = 0;
if (tx_buf->skb &&
(tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC))
dev_kfree_skb_any(tx_buf->skb);
(tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) {
if (napi)
napi_consume_skb(tx_buf->skb, napi);
else
dev_kfree_skb_any(tx_buf->skb);
}
tx_buf->skb = NULL;
}

Expand Down Expand Up @@ -1069,7 +1074,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
tx_buf = mtk_desc_to_tx_buf(ring, itxd);

/* unmap dma */
mtk_tx_unmap(eth, tx_buf);
mtk_tx_unmap(eth, tx_buf, false);

itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
Expand Down Expand Up @@ -1388,7 +1393,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget,
done[mac]++;
budget--;
}
mtk_tx_unmap(eth, tx_buf);
mtk_tx_unmap(eth, tx_buf, true);

ring->last_free = desc;
atomic_inc(&ring->free_count);
Expand Down Expand Up @@ -1425,7 +1430,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget,
budget--;
}

mtk_tx_unmap(eth, tx_buf);
mtk_tx_unmap(eth, tx_buf, true);

desc = &ring->dma[cpu];
ring->last_free = desc;
Expand Down Expand Up @@ -1627,7 +1632,7 @@ static void mtk_tx_clean(struct mtk_eth *eth)

if (ring->buf) {
for (i = 0; i < MTK_DMA_SIZE; i++)
mtk_tx_unmap(eth, &ring->buf[i]);
mtk_tx_unmap(eth, &ring->buf[i], false);
kfree(ring->buf);
ring->buf = NULL;
}
Expand Down

0 comments on commit c30c4a8

Please sign in to comment.