Skip to content

Commit 1d587fa

Browse files
vladimirolteankuba-moo
authored andcommitted
net: enetc: refactor bulk flipping of RX buffers to separate function
This small snippet of code ensures that we do something with the array of RX software buffer descriptor elements after passing the skb to the stack. In this case, we see if the other half of the page is reusable, and if so, we "turn around" the buffers, making them directly usable by enetc_refill_rx_ring() without going to enetc_new_page(). We will need to perform this kind of buffer flipping from a new code path, i.e. from XDP_PASS. Currently, enetc_build_skb() does it there buffer by buffer, but in a subsequent change we will stop using enetc_build_skb() for XDP_PASS. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Wei Fang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2768b2e commit 1d587fa

File tree

1 file changed

+11
-5
lines changed
  • drivers/net/ethernet/freescale/enetc

1 file changed

+11
-5
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,16 @@ static void enetc_xdp_drop(struct enetc_bdr *rx_ring, int rx_ring_first,
18501850
}
18511851
}
18521852

1853+
static void enetc_bulk_flip_buff(struct enetc_bdr *rx_ring, int rx_ring_first,
1854+
int rx_ring_last)
1855+
{
1856+
while (rx_ring_first != rx_ring_last) {
1857+
enetc_flip_rx_buff(rx_ring,
1858+
&rx_ring->rx_swbd[rx_ring_first]);
1859+
enetc_bdr_idx_inc(rx_ring, &rx_ring_first);
1860+
}
1861+
}
1862+
18531863
static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
18541864
struct napi_struct *napi, int work_limit,
18551865
struct bpf_prog *prog)
@@ -1965,11 +1975,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
19651975
enetc_xdp_drop(rx_ring, orig_i, i);
19661976
rx_ring->stats.xdp_redirect_failures++;
19671977
} else {
1968-
while (orig_i != i) {
1969-
enetc_flip_rx_buff(rx_ring,
1970-
&rx_ring->rx_swbd[orig_i]);
1971-
enetc_bdr_idx_inc(rx_ring, &orig_i);
1972-
}
1978+
enetc_bulk_flip_buff(rx_ring, orig_i, i);
19731979
xdp_redirect_frm_cnt++;
19741980
rx_ring->stats.xdp_redirect++;
19751981
}

0 commit comments

Comments
 (0)