bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH intel-next] ice: xsk: check if Rx ring was filled up to the end
@ 2022-03-17 17:57 Maciej Fijalkowski
  2022-03-31 10:21 ` [Intel-wired-lan] " Nagaraju, Shwetha
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej Fijalkowski @ 2022-03-17 17:57 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: netdev, bpf, anthony.l.nguyen, kuba, davem, magnus.karlsson,
	alexandr.lobakin, Maciej Fijalkowski

__ice_alloc_rx_bufs_zc() checks if a number of the descriptors to be
allocated would cause the ring wrap. In that case, driver will issue two
calls to xsk_buff_alloc_batch() - one that will fill the ring up to the
end and the second one that will start with filling descriptors from the
beginning of the ring.

ice_fill_rx_descs() is a wrapper for taking care of what
xsk_buff_alloc_batch() gave back to the driver. It works in a best
effort approach, so for example when driver asks for 64 buffers,
ice_fill_rx_descs() could assign only 32. Such case needs to be checked
when ring is being filled up to the end, because in that situation ntu
might not reached the end of the ring.

Fix the ring wrap by checking if nb_buffs_extra has the expected value.
If not, bump ntu and go directly to tail update.

Fixes: 3876ff525de7 ("ice: xsk: Handle SW XDP ring wrap and bump tail more often")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_xsk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 88853a6ed931..6f15aa69cd5f 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -413,8 +413,8 @@ static u16 ice_fill_rx_descs(struct xsk_buff_pool *pool, struct xdp_buff **xdp,
  */
 static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 {
+	u32 nb_buffs_extra = 0, nb_buffs = 0;
 	union ice_32b_rx_flex_desc *rx_desc;
-	u32 nb_buffs_extra = 0, nb_buffs;
 	u16 ntu = rx_ring->next_to_use;
 	u16 total_count = count;
 	struct xdp_buff **xdp;
@@ -426,6 +426,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 		nb_buffs_extra = ice_fill_rx_descs(rx_ring->xsk_pool, xdp,
 						   rx_desc,
 						   rx_ring->count - ntu);
+		if (nb_buffs_extra != rx_ring->count - ntu) {
+			ntu += nb_buffs_extra;
+			goto exit;
+		}
 		rx_desc = ICE_RX_DESC(rx_ring, 0);
 		xdp = ice_xdp_buf(rx_ring, 0);
 		ntu = 0;
@@ -439,6 +443,7 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 	if (ntu == rx_ring->count)
 		ntu = 0;
 
+exit:
 	if (rx_ring->next_to_use != ntu)
 		ice_release_rx_desc(rx_ring, ntu);
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [Intel-wired-lan] [PATCH intel-next] ice: xsk: check if Rx ring was filled up to the end
  2022-03-17 17:57 [PATCH intel-next] ice: xsk: check if Rx ring was filled up to the end Maciej Fijalkowski
@ 2022-03-31 10:21 ` Nagaraju, Shwetha
  0 siblings, 0 replies; 2+ messages in thread
From: Nagaraju, Shwetha @ 2022-03-31 10:21 UTC (permalink / raw)
  To: Fijalkowski, Maciej, intel-wired-lan
  Cc: netdev, kuba, bpf, davem, Karlsson, Magnus



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Maciej Fijalkowski
> Sent: Thursday, March 17, 2022 11:27 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; kuba@kernel.org; bpf@vger.kernel.org;
> davem@davemloft.net; Karlsson, Magnus <magnus.karlsson@intel.com>
> Subject: [Intel-wired-lan] [PATCH intel-next] ice: xsk: check if Rx ring was
> filled up to the end
> 
> __ice_alloc_rx_bufs_zc() checks if a number of the descriptors to be
> allocated would cause the ring wrap. In that case, driver will issue two calls to
> xsk_buff_alloc_batch() - one that will fill the ring up to the end and the
> second one that will start with filling descriptors from the beginning of the
> ring.
> 
> ice_fill_rx_descs() is a wrapper for taking care of what
> xsk_buff_alloc_batch() gave back to the driver. It works in a best effort
> approach, so for example when driver asks for 64 buffers,
> ice_fill_rx_descs() could assign only 32. Such case needs to be checked when
> ring is being filled up to the end, because in that situation ntu might not
> reached the end of the ring.
> 
> Fix the ring wrap by checking if nb_buffs_extra has the expected value.
> If not, bump ntu and go directly to tail update.
> 
> Fixes: 3876ff525de7 ("ice: xsk: Handle SW XDP ring wrap and bump tail more
> often")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_xsk.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
Tested-by: Shwetha Nagaraju <Shwetha.nagaraju@intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-31 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 17:57 [PATCH intel-next] ice: xsk: check if Rx ring was filled up to the end Maciej Fijalkowski
2022-03-31 10:21 ` [Intel-wired-lan] " Nagaraju, Shwetha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).