Skip to content

Commit 52187cb

Browse files
walking-machineSasha Levin
authored andcommitted
ice: remove af_xdp_zc_qps bitmap
[ Upstream commit adbf5a4 ] Referenced commit has introduced a bitmap to distinguish between ZC and copy-mode AF_XDP queues, because xsk_get_pool_from_qid() does not do this for us. The bitmap would be especially useful when restoring previous state after rebuild, if only it was not reallocated in the process. This leads to e.g. xdpsock dying after changing number of queues. Instead of preserving the bitmap during the rebuild, remove it completely and distinguish between ZC and copy-mode queues based on the presence of a device associated with the pool. Fixes: e102db7 ("ice: track AF_XDP ZC enabled queues in bitmap") Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20240603-net-2024-05-30-intel-net-fixes-v2-3-e3563aa89b0c@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9f453da commit 52187cb

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ struct ice_vsi {
388388
struct ice_tc_cfg tc_cfg;
389389
struct bpf_prog *xdp_prog;
390390
struct ice_tx_ring **xdp_rings; /* XDP ring array */
391-
unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */
392391
u16 num_xdp_txq; /* Used XDP queues */
393392
u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
394393

@@ -688,6 +687,25 @@ static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
688687
ring->flags |= ICE_TX_FLAGS_RING_XDP;
689688
}
690689

690+
/**
691+
* ice_get_xp_from_qid - get ZC XSK buffer pool bound to a queue ID
692+
* @vsi: pointer to VSI
693+
* @qid: index of a queue to look at XSK buff pool presence
694+
*
695+
* Return: A pointer to xsk_buff_pool structure if there is a buffer pool
696+
* attached and configured as zero-copy, NULL otherwise.
697+
*/
698+
static inline struct xsk_buff_pool *ice_get_xp_from_qid(struct ice_vsi *vsi,
699+
u16 qid)
700+
{
701+
struct xsk_buff_pool *pool = xsk_get_pool_from_qid(vsi->netdev, qid);
702+
703+
if (!ice_is_xdp_ena_vsi(vsi))
704+
return NULL;
705+
706+
return (pool && pool->dev) ? pool : NULL;
707+
}
708+
691709
/**
692710
* ice_xsk_pool - get XSK buffer pool bound to a ring
693711
* @ring: Rx ring to use
@@ -700,10 +718,7 @@ static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
700718
struct ice_vsi *vsi = ring->vsi;
701719
u16 qid = ring->q_index;
702720

703-
if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps))
704-
return NULL;
705-
706-
return xsk_get_pool_from_qid(vsi->netdev, qid);
721+
return ice_get_xp_from_qid(vsi, qid);
707722
}
708723

709724
/**
@@ -728,12 +743,7 @@ static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
728743
if (!ring)
729744
return;
730745

731-
if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) {
732-
ring->xsk_pool = NULL;
733-
return;
734-
}
735-
736-
ring->xsk_pool = xsk_get_pool_from_qid(vsi->netdev, qid);
746+
ring->xsk_pool = ice_get_xp_from_qid(vsi, qid);
737747
}
738748

739749
/**

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,8 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi)
117117
if (!vsi->q_vectors)
118118
goto err_vectors;
119119

120-
vsi->af_xdp_zc_qps = bitmap_zalloc(max_t(int, vsi->alloc_txq, vsi->alloc_rxq), GFP_KERNEL);
121-
if (!vsi->af_xdp_zc_qps)
122-
goto err_zc_qps;
123-
124120
return 0;
125121

126-
err_zc_qps:
127-
devm_kfree(dev, vsi->q_vectors);
128122
err_vectors:
129123
devm_kfree(dev, vsi->rxq_map);
130124
err_rxq_map:
@@ -320,8 +314,6 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi)
320314

321315
dev = ice_pf_to_dev(pf);
322316

323-
bitmap_free(vsi->af_xdp_zc_qps);
324-
vsi->af_xdp_zc_qps = NULL;
325317
/* free the ring and vector containers */
326318
devm_kfree(dev, vsi->q_vectors);
327319
vsi->q_vectors = NULL;

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ static int ice_xsk_pool_disable(struct ice_vsi *vsi, u16 qid)
281281
if (!pool)
282282
return -EINVAL;
283283

284-
clear_bit(qid, vsi->af_xdp_zc_qps);
285284
xsk_pool_dma_unmap(pool, ICE_RX_DMA_ATTR);
286285

287286
return 0;
@@ -312,8 +311,6 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
312311
if (err)
313312
return err;
314313

315-
set_bit(qid, vsi->af_xdp_zc_qps);
316-
317314
return 0;
318315
}
319316

@@ -361,11 +358,13 @@ ice_realloc_rx_xdp_bufs(struct ice_rx_ring *rx_ring, bool pool_present)
361358
int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc)
362359
{
363360
struct ice_rx_ring *rx_ring;
364-
unsigned long q;
361+
uint i;
362+
363+
ice_for_each_rxq(vsi, i) {
364+
rx_ring = vsi->rx_rings[i];
365+
if (!rx_ring->xsk_pool)
366+
continue;
365367

366-
for_each_set_bit(q, vsi->af_xdp_zc_qps,
367-
max_t(int, vsi->alloc_txq, vsi->alloc_rxq)) {
368-
rx_ring = vsi->rx_rings[q];
369368
if (ice_realloc_rx_xdp_bufs(rx_ring, zc))
370369
return -ENOMEM;
371370
}

0 commit comments

Comments
 (0)