610-v5.13-40-net-ethernet-mtk_eth_soc-use-napi_consume_skb.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From c30c4a82739090a2de4a4e3f245355ea4fb3ec14 Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <[email protected]>
  3. Date: Thu, 22 Apr 2021 22:20:57 -0700
  4. Subject: [PATCH] net: ethernet: mtk_eth_soc: use napi_consume_skb
  5. Should improve performance, since it can use bulk free
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. Signed-off-by: Ilya Lipnitskiy <[email protected]>
  8. Signed-off-by: David S. Miller <[email protected]>
  9. ---
  10. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 19 ++++++++++++-------
  11. 1 file changed, 12 insertions(+), 7 deletions(-)
  12. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  13. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. @@ -879,7 +879,8 @@ static int txd_to_idx(struct mtk_tx_ring
  15. return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
  16. }
  17. -static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf)
  18. +static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
  19. + bool napi)
  20. {
  21. if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
  22. if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) {
  23. @@ -911,8 +912,12 @@ static void mtk_tx_unmap(struct mtk_eth
  24. tx_buf->flags = 0;
  25. if (tx_buf->skb &&
  26. - (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC))
  27. - dev_kfree_skb_any(tx_buf->skb);
  28. + (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) {
  29. + if (napi)
  30. + napi_consume_skb(tx_buf->skb, napi);
  31. + else
  32. + dev_kfree_skb_any(tx_buf->skb);
  33. + }
  34. tx_buf->skb = NULL;
  35. }
  36. @@ -1090,7 +1095,7 @@ err_dma:
  37. tx_buf = mtk_desc_to_tx_buf(ring, itxd);
  38. /* unmap dma */
  39. - mtk_tx_unmap(eth, tx_buf);
  40. + mtk_tx_unmap(eth, tx_buf, false);
  41. itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
  42. if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
  43. @@ -1409,7 +1414,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
  44. done[mac]++;
  45. budget--;
  46. }
  47. - mtk_tx_unmap(eth, tx_buf);
  48. + mtk_tx_unmap(eth, tx_buf, true);
  49. ring->last_free = desc;
  50. atomic_inc(&ring->free_count);
  51. @@ -1446,7 +1451,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
  52. budget--;
  53. }
  54. - mtk_tx_unmap(eth, tx_buf);
  55. + mtk_tx_unmap(eth, tx_buf, true);
  56. desc = &ring->dma[cpu];
  57. ring->last_free = desc;
  58. @@ -1648,7 +1653,7 @@ static void mtk_tx_clean(struct mtk_eth
  59. if (ring->buf) {
  60. for (i = 0; i < MTK_DMA_SIZE; i++)
  61. - mtk_tx_unmap(eth, &ring->buf[i]);
  62. + mtk_tx_unmap(eth, &ring->buf[i], false);
  63. kfree(ring->buf);
  64. ring->buf = NULL;
  65. }