Skip to content

Commit 296f13f

Browse files
mfijalkoborkmann
authored andcommitted
ice: xsk: Force rings to be sized to power of 2
With the upcoming introduction of batching to XSK data path, performance wise it will be the best to have the ring descriptor count to be aligned to power of 2. Check if ring sizes that user is going to attach the XSK socket fulfill the condition above. For Tx side, although check is being done against the Tx queue and in the end the socket will be attached to the XDP queue, it is fine since XDP queues get the ring->count setting from Tx queues. Suggested-by: Alexander Lobakin <[email protected]> Signed-off-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a4e1866 commit 296f13f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
327327
bool if_running, pool_present = !!pool;
328328
int ret = 0, pool_failure = 0;
329329

330+
if (!is_power_of_2(vsi->rx_rings[qid]->count) ||
331+
!is_power_of_2(vsi->tx_rings[qid]->count)) {
332+
netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n");
333+
pool_failure = -EINVAL;
334+
goto failure;
335+
}
336+
330337
if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi);
331338

332339
if (if_running) {
@@ -349,6 +356,7 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
349356
netdev_err(vsi->netdev, "ice_qp_ena error = %d\n", ret);
350357
}
351358

359+
failure:
352360
if (pool_failure) {
353361
netdev_err(vsi->netdev, "Could not %sable buffer pool, error = %d\n",
354362
pool_present ? "en" : "dis", pool_failure);

0 commit comments

Comments
 (0)