Skip to content

Commit ed93a39

Browse files
Björn TöpelJeff Kirsher
authored andcommitted
ixgbe: tweak page counting for XDP_REDIRECT
The current page counting scheme assumes that the reference count cannot decrease until the received frame is sent to the upper layers of the networking stack. This assumption does not hold for the XDP_REDIRECT action, since a page (pointed out by xdp_buff) can have its reference count decreased via the xdp_do_redirect call. To work around that, we now start off by a large page count and then don't allow a refcount less than two. Signed-off-by: Björn Töpel <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 2eb34ba commit ed93a39

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,8 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
16291629
bi->dma = dma;
16301630
bi->page = page;
16311631
bi->page_offset = ixgbe_rx_offset(rx_ring);
1632-
bi->pagecnt_bias = 1;
1632+
page_ref_add(page, USHRT_MAX - 1);
1633+
bi->pagecnt_bias = USHRT_MAX;
16331634
rx_ring->rx_stats.alloc_rx_page++;
16341635

16351636
return true;
@@ -2039,8 +2040,8 @@ static bool ixgbe_can_reuse_rx_page(struct ixgbe_rx_buffer *rx_buffer)
20392040
* the pagecnt_bias and page count so that we fully restock the
20402041
* number of references the driver holds.
20412042
*/
2042-
if (unlikely(!pagecnt_bias)) {
2043-
page_ref_add(page, USHRT_MAX);
2043+
if (unlikely(pagecnt_bias == 1)) {
2044+
page_ref_add(page, USHRT_MAX - 1);
20442045
rx_buffer->pagecnt_bias = USHRT_MAX;
20452046
}
20462047

0 commit comments

Comments
 (0)