Skip to content

Commit adbf5a4

Browse files
walking-machinekuba-moo
authored andcommitted
ice: remove af_xdp_zc_qps bitmap
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>
1 parent cfa747a commit adbf5a4

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
@@ -409,7 +409,6 @@ struct ice_vsi {
409409
struct ice_tc_cfg tc_cfg;
410410
struct bpf_prog *xdp_prog;
411411
struct ice_tx_ring **xdp_rings; /* XDP ring array */
412-
unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */
413412
u16 num_xdp_txq; /* Used XDP queues */
414413
u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
415414

@@ -746,6 +745,25 @@ static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
746745
ring->flags |= ICE_TX_FLAGS_RING_XDP;
747746
}
748747

748+
/**
749+
* ice_get_xp_from_qid - get ZC XSK buffer pool bound to a queue ID
750+
* @vsi: pointer to VSI
751+
* @qid: index of a queue to look at XSK buff pool presence
752+
*
753+
* Return: A pointer to xsk_buff_pool structure if there is a buffer pool
754+
* attached and configured as zero-copy, NULL otherwise.
755+
*/
756+
static inline struct xsk_buff_pool *ice_get_xp_from_qid(struct ice_vsi *vsi,
757+
u16 qid)
758+
{
759+
struct xsk_buff_pool *pool = xsk_get_pool_from_qid(vsi->netdev, qid);
760+
761+
if (!ice_is_xdp_ena_vsi(vsi))
762+
return NULL;
763+
764+
return (pool && pool->dev) ? pool : NULL;
765+
}
766+
749767
/**
750768
* ice_xsk_pool - get XSK buffer pool bound to a ring
751769
* @ring: Rx ring to use
@@ -758,10 +776,7 @@ static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
758776
struct ice_vsi *vsi = ring->vsi;
759777
u16 qid = ring->q_index;
760778

761-
if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps))
762-
return NULL;
763-
764-
return xsk_get_pool_from_qid(vsi->netdev, qid);
779+
return ice_get_xp_from_qid(vsi, qid);
765780
}
766781

767782
/**
@@ -786,12 +801,7 @@ static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
786801
if (!ring)
787802
return;
788803

789-
if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) {
790-
ring->xsk_pool = NULL;
791-
return;
792-
}
793-
794-
ring->xsk_pool = xsk_get_pool_from_qid(vsi->netdev, qid);
804+
ring->xsk_pool = ice_get_xp_from_qid(vsi, qid);
795805
}
796806

797807
/**

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

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

117-
vsi->af_xdp_zc_qps = bitmap_zalloc(max_t(int, vsi->alloc_txq, vsi->alloc_rxq), GFP_KERNEL);
118-
if (!vsi->af_xdp_zc_qps)
119-
goto err_zc_qps;
120-
121117
return 0;
122118

123-
err_zc_qps:
124-
devm_kfree(dev, vsi->q_vectors);
125119
err_vectors:
126120
devm_kfree(dev, vsi->rxq_map);
127121
err_rxq_map:
@@ -309,8 +303,6 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi)
309303

310304
dev = ice_pf_to_dev(pf);
311305

312-
bitmap_free(vsi->af_xdp_zc_qps);
313-
vsi->af_xdp_zc_qps = NULL;
314306
/* free the ring and vector containers */
315307
devm_kfree(dev, vsi->q_vectors);
316308
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
@@ -269,7 +269,6 @@ static int ice_xsk_pool_disable(struct ice_vsi *vsi, u16 qid)
269269
if (!pool)
270270
return -EINVAL;
271271

272-
clear_bit(qid, vsi->af_xdp_zc_qps);
273272
xsk_pool_dma_unmap(pool, ICE_RX_DMA_ATTR);
274273

275274
return 0;
@@ -300,8 +299,6 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
300299
if (err)
301300
return err;
302301

303-
set_bit(qid, vsi->af_xdp_zc_qps);
304-
305302
return 0;
306303
}
307304

@@ -349,11 +346,13 @@ ice_realloc_rx_xdp_bufs(struct ice_rx_ring *rx_ring, bool pool_present)
349346
int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc)
350347
{
351348
struct ice_rx_ring *rx_ring;
352-
unsigned long q;
349+
uint i;
350+
351+
ice_for_each_rxq(vsi, i) {
352+
rx_ring = vsi->rx_rings[i];
353+
if (!rx_ring->xsk_pool)
354+
continue;
353355

354-
for_each_set_bit(q, vsi->af_xdp_zc_qps,
355-
max_t(int, vsi->alloc_txq, vsi->alloc_rxq)) {
356-
rx_ring = vsi->rx_rings[q];
357356
if (ice_realloc_rx_xdp_bufs(rx_ring, zc))
358357
return -ENOMEM;
359358
}

0 commit comments

Comments
 (0)