DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error
@ 2022-02-18 11:20 Ciara Loftus
  2022-02-18 11:20 ` [PATCH 2/2] net/af_xdp: reserve fill queue before socket create Ciara Loftus
  2022-02-18 18:49 ` [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ferruh Yigit
  0 siblings, 2 replies; 4+ messages in thread
From: Ciara Loftus @ 2022-02-18 11:20 UTC (permalink / raw)
  To: dev; +Cc: Ciara Loftus, stable

The Rx queue setup can fail for many reasons eg. failure to setup the
custom program, failure to allocate or reserve fill queue buffers,
failure to configure busy polling etc. When a failure like one of these
occurs, if the xsk is already set up it should be deleted before
returning. This commit ensures this happens.

Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
Fixes: 288a85aef192 ("net/af_xdp: enable custom XDP program loading")
Fixes: 055a393626ed ("net/af_xdp: prefer busy polling")
Fixes: 01fa83c94d7e ("net/af_xdp: workaround custom program loading")
Cc: stable@dpdk.org

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 6ac710c6bd..5f493951f6 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1302,7 +1302,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 		if (ret) {
 			AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
 					internals->prog_path);
-			goto err;
+			goto out_umem;
 		}
 		internals->custom_prog_configured = 1;
 		cfg.libbpf_flags = XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
@@ -1319,7 +1319,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to create xsk socket.\n");
-		goto err;
+		goto out_umem;
 	}
 
 	/* insert the xsk into the xsks_map */
@@ -1331,7 +1331,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 					  &rxq->xsk_queue_idx, &fd, 0);
 		if (err) {
 			AF_XDP_LOG(ERR, "Failed to insert xsk in map.\n");
-			goto err;
+			goto out_xsk;
 		}
 	}
 
@@ -1339,7 +1339,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 	ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
 	if (ret) {
 		AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
-		goto err;
+		goto out_xsk;
 	}
 #endif
 
@@ -1347,20 +1347,21 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 		ret = configure_preferred_busy_poll(rxq);
 		if (ret) {
 			AF_XDP_LOG(ERR, "Failed configure busy polling.\n");
-			goto err;
+			goto out_xsk;
 		}
 	}
 
 	ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
 	if (ret) {
-		xsk_socket__delete(rxq->xsk);
 		AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
-		goto err;
+		goto out_xsk;
 	}
 
 	return 0;
 
-err:
+out_xsk:
+	xsk_socket__delete(rxq->xsk);
+out_umem:
 	if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0)
 		xdp_umem_destroy(rxq->umem);
 
-- 
2.25.1


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

* [PATCH 2/2] net/af_xdp: reserve fill queue before socket create
  2022-02-18 11:20 [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ciara Loftus
@ 2022-02-18 11:20 ` Ciara Loftus
  2022-02-18 18:49   ` Ferruh Yigit
  2022-02-18 18:49 ` [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ferruh Yigit
  1 sibling, 1 reply; 4+ messages in thread
From: Ciara Loftus @ 2022-02-18 11:20 UTC (permalink / raw)
  To: dev; +Cc: Ciara Loftus

Some zero copy AF_XDP drivers eg. ice require that there are addresses
already in the fill queue before the socket is created. Otherwise you may
see log messages such as:

XSK buffer pool does not provide enough addresses to fill 2047 buffers on
Rx ring 0

This commit ensures that the addresses are available before creating the
socket, instead of after.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 5f493951f6..309b96c9b4 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1284,6 +1284,20 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 		return -ENOMEM;
 	txq->umem = rxq->umem;
 
+#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
+	ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
+	if (ret) {
+		AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
+		goto out_umem;
+	}
+#endif
+
+	ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
+	if (ret) {
+		AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
+		goto out_umem;
+	}
+
 	cfg.rx_size = ring_size;
 	cfg.tx_size = ring_size;
 	cfg.libbpf_flags = 0;
@@ -1335,14 +1349,6 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 		}
 	}
 
-#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
-	ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
-	if (ret) {
-		AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n");
-		goto out_xsk;
-	}
-#endif
-
 	if (rxq->busy_budget) {
 		ret = configure_preferred_busy_poll(rxq);
 		if (ret) {
@@ -1351,12 +1357,6 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 		}
 	}
 
-	ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
-	if (ret) {
-		AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
-		goto out_xsk;
-	}
-
 	return 0;
 
 out_xsk:
-- 
2.25.1


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

* Re: [PATCH 2/2] net/af_xdp: reserve fill queue before socket create
  2022-02-18 11:20 ` [PATCH 2/2] net/af_xdp: reserve fill queue before socket create Ciara Loftus
@ 2022-02-18 18:49   ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-02-18 18:49 UTC (permalink / raw)
  To: Ciara Loftus, dev

On 2/18/2022 11:20 AM, Ciara Loftus wrote:
> Some zero copy AF_XDP drivers eg. ice require that there are addresses
> already in the fill queue before the socket is created. Otherwise you may
> see log messages such as:
> 
> XSK buffer pool does not provide enough addresses to fill 2047 buffers on
> Rx ring 0
> 

I confirm the above log is gone with the patch,
for the record I am seeing below instead now:
[  +0.346578] ice 0000:86:00.1: Registered XDP mem model MEM_TYPE_XSK_BUFF_POOL on Rx ring 0
[  +0.032472] device enp134s0f1 left promiscuous mode

> This commit ensures that the addresses are available before creating the
> socket, instead of after.
> 
> Signed-off-by: Ciara Loftus<ciara.loftus@intel.com>

Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error
  2022-02-18 11:20 [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ciara Loftus
  2022-02-18 11:20 ` [PATCH 2/2] net/af_xdp: reserve fill queue before socket create Ciara Loftus
@ 2022-02-18 18:49 ` Ferruh Yigit
  1 sibling, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-02-18 18:49 UTC (permalink / raw)
  To: Ciara Loftus, dev; +Cc: stable

On 2/18/2022 11:20 AM, Ciara Loftus wrote:
> The Rx queue setup can fail for many reasons eg. failure to setup the
> custom program, failure to allocate or reserve fill queue buffers,
> failure to configure busy polling etc. When a failure like one of these
> occurs, if the xsk is already set up it should be deleted before
> returning. This commit ensures this happens.
> 
> Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
> Fixes: 288a85aef192 ("net/af_xdp: enable custom XDP program loading")
> Fixes: 055a393626ed ("net/af_xdp: prefer busy polling")
> Fixes: 01fa83c94d7e ("net/af_xdp: workaround custom program loading")
> Cc:stable@dpdk.org
> 
> Signed-off-by: Ciara Loftus<ciara.loftus@intel.com>

Series applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2022-02-18 18:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 11:20 [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ciara Loftus
2022-02-18 11:20 ` [PATCH 2/2] net/af_xdp: reserve fill queue before socket create Ciara Loftus
2022-02-18 18:49   ` Ferruh Yigit
2022-02-18 18:49 ` [PATCH 1/2] net/af_xdp: ensure xsk is deleted on Rx queue setup error Ferruh Yigit

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).