DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx
@ 2021-04-20  8:44 Ciara Loftus
  2021-04-20  8:44 ` [dpdk-dev] [PATCH 2/2] net/af_xdp: only use recvfrom if busy polling is enabled Ciara Loftus
  2021-04-20 10:15 ` [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx Ferruh Yigit
  0 siblings, 2 replies; 3+ messages in thread
From: Ciara Loftus @ 2021-04-20  8:44 UTC (permalink / raw)
  To: dev; +Cc: Ciara Loftus

The send() syscall on the tx path is not concerned with busy polling
and as such its invocation should not depend on whether or not it is
configured. Fix this by distinguishing the conditions necessary for
syscalls on the rx and tx paths individually.

Fixes: 055a393626ed ("net/af_xdp: prefer busy polling")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/compat.h         | 14 ++++++++++++--
 drivers/net/af_xdp/rte_eth_af_xdp.c |  4 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 545c8aa395..9de9454885 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -42,14 +42,24 @@ create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
 
 #ifdef XDP_USE_NEED_WAKEUP
 static int
-syscall_needed(struct xsk_ring_prod *q, uint32_t busy_budget)
+rx_syscall_needed(struct xsk_ring_prod *q, uint32_t busy_budget)
 {
 	return xsk_ring_prod__needs_wakeup(q) | busy_budget;
 }
+static int
+tx_syscall_needed(struct xsk_ring_prod *q)
+{
+	return xsk_ring_prod__needs_wakeup(q);
+}
 #else
 static int
-syscall_needed(struct xsk_ring_prod *q __rte_unused, uint32_t busy_budget)
+rx_syscall_needed(struct xsk_ring_prod *q __rte_unused, uint32_t busy_budget)
 {
 	return busy_budget;
 }
+static int
+tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
+{
+	return 1;
+}
 #endif
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 6e44a21c64..8c6cd224a8 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -273,7 +273,7 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
 
 	if (nb_pkts == 0) {
-		if (syscall_needed(&rxq->fq, rxq->busy_budget))
+		if (rx_syscall_needed(&rxq->fq, rxq->busy_budget))
 			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
 				MSG_DONTWAIT, NULL, NULL);
 
@@ -456,7 +456,7 @@ kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons *cq)
 
 	pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);
 
-	if (syscall_needed(&txq->tx, txq->pair->busy_budget))
+	if (tx_syscall_needed(&txq->tx))
 		while (send(xsk_socket__fd(txq->pair->xsk), NULL,
 			    0, MSG_DONTWAIT) < 0) {
 			/* some thing unexpected */
-- 
2.25.1


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

* [dpdk-dev] [PATCH 2/2] net/af_xdp: only use recvfrom if busy polling is enabled
  2021-04-20  8:44 [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx Ciara Loftus
@ 2021-04-20  8:44 ` Ciara Loftus
  2021-04-20 10:15 ` [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx Ferruh Yigit
  1 sibling, 0 replies; 3+ messages in thread
From: Ciara Loftus @ 2021-04-20  8:44 UTC (permalink / raw)
  To: dev; +Cc: Ciara Loftus

The recvfrom() syscall is only supported by AF_XDP sockets since
kernel 5.11. Only use it if busy polling is configured. We can
assume a kernel >= 5.11 is in use if busy polling is configured
so we can safely call recvfrom() in that case.

Fixes: 63e8989fe5a4 ("net/af_xdp: use recvfrom instead of poll syscall")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/compat.h         | 28 ++++++++++++++++++++++------
 drivers/net/af_xdp/rte_eth_af_xdp.c | 10 +++-------
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 9de9454885..52fd447b69 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -4,6 +4,7 @@
 
 #include <bpf/xsk.h>
 #include <linux/version.h>
+#include <poll.h>
 
 #if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
 	defined(RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM)
@@ -41,10 +42,22 @@ create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
 #endif
 
 #ifdef XDP_USE_NEED_WAKEUP
-static int
-rx_syscall_needed(struct xsk_ring_prod *q, uint32_t busy_budget)
+static void
+rx_syscall_handler(struct xsk_ring_prod *q, uint32_t busy_budget,
+		   struct pollfd *fds, struct xsk_socket *xsk)
 {
-	return xsk_ring_prod__needs_wakeup(q) | busy_budget;
+	/* we can assume a kernel >= 5.11 is in use if busy polling is enabled
+	 * and thus we can safely use the recvfrom() syscall which is only
+	 * supported for AF_XDP sockets in kernels >= 5.11.
+	 */
+	if (busy_budget) {
+		(void)recvfrom(xsk_socket__fd(xsk), NULL, 0,
+			MSG_DONTWAIT, NULL, NULL);
+		return;
+	}
+
+	if (xsk_ring_prod__needs_wakeup(q))
+		(void)poll(fds, 1, 1000);
 }
 static int
 tx_syscall_needed(struct xsk_ring_prod *q)
@@ -52,10 +65,13 @@ tx_syscall_needed(struct xsk_ring_prod *q)
 	return xsk_ring_prod__needs_wakeup(q);
 }
 #else
-static int
-rx_syscall_needed(struct xsk_ring_prod *q __rte_unused, uint32_t busy_budget)
+static void
+rx_syscall_handler(struct xsk_ring_prod *q __rte_unused, uint32_t busy_budget,
+		   struct pollfd *fds __rte_unused, struct xsk_socket *xsk)
 {
-	return busy_budget;
+	if (busy_budget)
+		(void)recvfrom(xsk_socket__fd(xsk), NULL, 0,
+			MSG_DONTWAIT, NULL, NULL);
 }
 static int
 tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 8c6cd224a8..0c91a40c4a 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -5,7 +5,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <poll.h>
 #include <netinet/in.h>
 #include <net/if.h>
 #include <sys/socket.h>
@@ -273,10 +272,8 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);
 
 	if (nb_pkts == 0) {
-		if (rx_syscall_needed(&rxq->fq, rxq->busy_budget))
-			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
-				MSG_DONTWAIT, NULL, NULL);
-
+		rx_syscall_handler(&rxq->fq, rxq->busy_budget, &rxq->fds[0],
+				   rxq->xsk);
 		return 0;
 	}
 
@@ -346,8 +343,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	if (nb_pkts == 0) {
 #if defined(XDP_USE_NEED_WAKEUP)
 		if (xsk_ring_prod__needs_wakeup(fq))
-			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
-				MSG_DONTWAIT, NULL, NULL);
+			(void)poll(rxq->fds, 1, 1000);
 #endif
 		return 0;
 	}
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx
  2021-04-20  8:44 [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx Ciara Loftus
  2021-04-20  8:44 ` [dpdk-dev] [PATCH 2/2] net/af_xdp: only use recvfrom if busy polling is enabled Ciara Loftus
@ 2021-04-20 10:15 ` Ferruh Yigit
  1 sibling, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2021-04-20 10:15 UTC (permalink / raw)
  To: Ciara Loftus, dev

On 4/20/2021 9:44 AM, Ciara Loftus wrote:
> The send() syscall on the tx path is not concerned with busy polling
> and as such its invocation should not depend on whether or not it is
> configured. Fix this by distinguishing the conditions necessary for
> syscalls on the rx and tx paths individually.
> 
> Fixes: 055a393626ed ("net/af_xdp: prefer busy polling")
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

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


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

end of thread, other threads:[~2021-04-20 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  8:44 [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx Ciara Loftus
2021-04-20  8:44 ` [dpdk-dev] [PATCH 2/2] net/af_xdp: only use recvfrom if busy polling is enabled Ciara Loftus
2021-04-20 10:15 ` [dpdk-dev] [PATCH 1/2] net/af_xdp: fix trigger for syscall on tx 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).