Skip to content

Commit 141b795

Browse files
mfijalkogregkh
authored andcommitted
ice: xsk: Force rings to be sized to power of 2
[ Upstream commit 296f13f ] 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] Signed-off-by: Sasha Levin <[email protected]>
1 parent 9c34c33 commit 141b795

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
@@ -321,6 +321,13 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
321321
bool if_running, pool_present = !!pool;
322322
int ret = 0, pool_failure = 0;
323323

324+
if (!is_power_of_2(vsi->rx_rings[qid]->count) ||
325+
!is_power_of_2(vsi->tx_rings[qid]->count)) {
326+
netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n");
327+
pool_failure = -EINVAL;
328+
goto failure;
329+
}
330+
324331
if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi);
325332

326333
if (if_running) {
@@ -343,6 +350,7 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
343350
netdev_err(vsi->netdev, "ice_qp_ena error = %d\n", ret);
344351
}
345352

353+
failure:
346354
if (pool_failure) {
347355
netdev_err(vsi->netdev, "Could not %sable buffer pool, error = %d\n",
348356
pool_present ? "en" : "dis", pool_failure);

0 commit comments

Comments
 (0)