Skip to content

Commit 8ce29c6

Browse files
Björn TöpelJeff Kirsher
authored andcommitted
i40e: tweak page counting for XDP_REDIRECT
This commit tweaks the page counting for XDP_REDIRECT to function properly. XDP_REDIRECT support will be added in a future commit. 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 <bjorn.topel@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 8f769dd commit 8ce29c6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,8 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,
15881588
bi->dma = dma;
15891589
bi->page = page;
15901590
bi->page_offset = i40e_rx_offset(rx_ring);
1591-
1592-
/* initialize pagecnt_bias to 1 representing we fully own page */
1593-
bi->pagecnt_bias = 1;
1591+
page_ref_add(page, USHRT_MAX - 1);
1592+
bi->pagecnt_bias = USHRT_MAX;
15941593

15951594
return true;
15961595
}
@@ -1956,8 +1955,8 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer)
19561955
* the pagecnt_bias and page count so that we fully restock the
19571956
* number of references the driver holds.
19581957
*/
1959-
if (unlikely(!pagecnt_bias)) {
1960-
page_ref_add(page, USHRT_MAX);
1958+
if (unlikely(pagecnt_bias == 1)) {
1959+
page_ref_add(page, USHRT_MAX - 1);
19611960
rx_buffer->pagecnt_bias = USHRT_MAX;
19621961
}
19631962

0 commit comments

Comments
 (0)