DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/af_xdp: fix build warning for kernels < 5.4
@ 2021-05-10  8:47 Ciara Loftus
  2021-05-11 14:12 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Ciara Loftus @ 2021-05-10  8:47 UTC (permalink / raw)
  To: dev

Prior to this change, two implementations of rx_syscall_handler
existed although only one was needed (for the zero copy path which
is only available from kernel 5.4 and onwards). Remove the second
definition from compat.h and move the first definition back to where
it is called in the Rx function. Doing this removes a build warning
on kernels before 5.4 which complained about the second function
being defined but not used.

Fixes: 2aa51cdd559e ("net/af_xdp: fix trigger for syscall on Tx")

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

diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h
index 52fd447b69..3880dc7dd7 100644
--- a/drivers/net/af_xdp/compat.h
+++ b/drivers/net/af_xdp/compat.h
@@ -42,37 +42,12 @@ create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
 #endif
 
 #ifdef XDP_USE_NEED_WAKEUP
-static void
-rx_syscall_handler(struct xsk_ring_prod *q, uint32_t busy_budget,
-		   struct pollfd *fds, struct xsk_socket *xsk)
-{
-	/* 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)
 {
 	return xsk_ring_prod__needs_wakeup(q);
 }
 #else
-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)
-{
-	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 0c91a40c4a..dd429969a3 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -272,8 +272,18 @@ 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) {
-		rx_syscall_handler(&rxq->fq, rxq->busy_budget, &rxq->fds[0],
-				   rxq->xsk);
+		/* 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 (rxq->busy_budget) {
+			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
+				       MSG_DONTWAIT, NULL, NULL);
+		} else if (xsk_ring_prod__needs_wakeup(fq)) {
+			(void)poll(&rxq->fds[0], 1, 1000);
+		}
+
 		return 0;
 	}
 
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH] net/af_xdp: fix build warning for kernels < 5.4
  2021-05-10  8:47 [dpdk-dev] [PATCH] net/af_xdp: fix build warning for kernels < 5.4 Ciara Loftus
@ 2021-05-11 14:12 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2021-05-11 14:12 UTC (permalink / raw)
  To: Ciara Loftus; +Cc: dev

On 5/10/2021 9:47 AM, Ciara Loftus wrote:
> Prior to this change, two implementations of rx_syscall_handler
> existed although only one was needed (for the zero copy path which
> is only available from kernel 5.4 and onwards). Remove the second
> definition from compat.h and move the first definition back to where
> it is called in the Rx function. Doing this removes a build warning
> on kernels before 5.4 which complained about the second function
> being defined but not used.
> 
> Fixes: 2aa51cdd559e ("net/af_xdp: fix trigger for syscall on Tx")
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

Applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2021-05-11 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  8:47 [dpdk-dev] [PATCH] net/af_xdp: fix build warning for kernels < 5.4 Ciara Loftus
2021-05-11 14:12 ` 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).