Skip to content

Commit 9f9687b

Browse files
mfijalkogregkh
authored andcommitted
ice: xsk: drop power of 2 ring size restriction for AF_XDP
[ Upstream commit b3056ae ] We had multiple customers in the past months that reported commit 296f13f ("ice: xsk: Force rings to be sized to power of 2") makes them unable to use ring size of 8160 in conjunction with AF_XDP. Remove this restriction. Fixes: 296f13f ("ice: xsk: Force rings to be sized to power of 2") CC: Alasdair McWilliam <alasdair.mcwilliam@outlook.com> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 01c2475 commit 9f9687b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

drivers/net/ethernet/intel/ice/ice_xsk.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,6 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
392392
goto failure;
393393
}
394394

395-
if (!is_power_of_2(vsi->rx_rings[qid]->count) ||
396-
!is_power_of_2(vsi->tx_rings[qid]->count)) {
397-
netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n");
398-
pool_failure = -EINVAL;
399-
goto failure;
400-
}
401-
402395
if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi);
403396

404397
if (if_running) {
@@ -534,11 +527,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
534527
bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
535528
{
536529
u16 rx_thresh = ICE_RING_QUARTER(rx_ring);
537-
u16 batched, leftover, i, tail_bumps;
530+
u16 leftover, i, tail_bumps;
538531

539-
batched = ALIGN_DOWN(count, rx_thresh);
540-
tail_bumps = batched / rx_thresh;
541-
leftover = count & (rx_thresh - 1);
532+
tail_bumps = count / rx_thresh;
533+
leftover = count - (tail_bumps * rx_thresh);
542534

543535
for (i = 0; i < tail_bumps; i++)
544536
if (!__ice_alloc_rx_bufs_zc(rx_ring, rx_thresh))
@@ -1037,14 +1029,16 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi)
10371029
*/
10381030
void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring)
10391031
{
1040-
u16 count_mask = rx_ring->count - 1;
10411032
u16 ntc = rx_ring->next_to_clean;
10421033
u16 ntu = rx_ring->next_to_use;
10431034

1044-
for ( ; ntc != ntu; ntc = (ntc + 1) & count_mask) {
1035+
while (ntc != ntu) {
10451036
struct xdp_buff *xdp = *ice_xdp_buf(rx_ring, ntc);
10461037

10471038
xsk_buff_free(xdp);
1039+
ntc++;
1040+
if (ntc >= rx_ring->count)
1041+
ntc = 0;
10481042
}
10491043
}
10501044

0 commit comments

Comments
 (0)