Skip to content

Commit 67d7ebd

Browse files
spliew89davem330
authored andcommitted
net: ag71xx: switch to napi_build_skb() to reuse skbuff_heads
napi_build_skb() reuses NAPI skbuff_head cache in order to save some cycles on freeing/allocating skbuff_heads on every new Rx or completed Tx. Use napi_consume_skb() to feed the cache with skbuff_heads of completed Tx, so it's never empty. The budget parameter is added to indicate NAPI context, as a value of zero can be passed in the case of netpoll. Signed-off-by: Sieng-Piaw Liew <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c2dd405 commit 67d7ebd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/net/ethernet/atheros/ag71xx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ static bool ag71xx_check_dma_stuck(struct ag71xx *ag)
786786
return false;
787787
}
788788

789-
static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
789+
static int ag71xx_tx_packets(struct ag71xx *ag, bool flush, int budget)
790790
{
791791
struct ag71xx_ring *ring = &ag->tx_ring;
792792
int sent = 0, bytes_compl = 0, n = 0;
@@ -825,7 +825,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
825825
if (!skb)
826826
continue;
827827

828-
dev_kfree_skb_any(skb);
828+
napi_consume_skb(skb, budget);
829829
ring->buf[i].tx.skb = NULL;
830830

831831
bytes_compl += ring->buf[i].tx.len;
@@ -970,7 +970,7 @@ static void ag71xx_fast_reset(struct ag71xx *ag)
970970
mii_reg = ag71xx_rr(ag, AG71XX_REG_MII_CFG);
971971
rx_ds = ag71xx_rr(ag, AG71XX_REG_RX_DESC);
972972

973-
ag71xx_tx_packets(ag, true);
973+
ag71xx_tx_packets(ag, true, 0);
974974

975975
reset_control_assert(ag->mac_reset);
976976
usleep_range(10, 20);
@@ -1657,7 +1657,7 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
16571657
ndev->stats.rx_packets++;
16581658
ndev->stats.rx_bytes += pktlen;
16591659

1660-
skb = build_skb(ring->buf[i].rx.rx_buf, ag71xx_buffer_size(ag));
1660+
skb = napi_build_skb(ring->buf[i].rx.rx_buf, ag71xx_buffer_size(ag));
16611661
if (!skb) {
16621662
skb_free_frag(ring->buf[i].rx.rx_buf);
16631663
goto next;
@@ -1703,7 +1703,7 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
17031703
int tx_done, rx_done;
17041704
u32 status;
17051705

1706-
tx_done = ag71xx_tx_packets(ag, false);
1706+
tx_done = ag71xx_tx_packets(ag, false, limit);
17071707

17081708
netif_dbg(ag, rx_status, ndev, "processing RX ring\n");
17091709
rx_done = ag71xx_rx_packets(ag, limit);

0 commit comments

Comments
 (0)