DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] af_xdp kick_tx() Retries instead of endless loop
@ 2025-12-07 16:26 Yan Yanovsky
  0 siblings, 0 replies; only message in thread
From: Yan Yanovsky @ 2025-12-07 16:26 UTC (permalink / raw)
  To: dev; +Cc: ciara.loftus, qi.z.zhang

[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]

From 191d90eaab50c6855ee746361e7e735572f3b1ce Mon Sep 17 00:00:00 2001
From: Yan Yanovsky <yan.yanovsky@catonetworks.com>
Date: Sun, 7 Dec 2025 18:10:45 +0200
Subject: [PATCH] af_xdp kick_tx() Retries instead of endless loop
 Signed-off-by: Yan Yanovsky <yan.yanovsky@catonetworks.com>

---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index b6ec9bf490..dc34f1a29e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -80,6 +80,7 @@ RTE_LOG_REGISTER_DEFAULT(af_xdp_logtype, NOTICE);
 #define ETH_AF_XDP_ETH_OVERHEAD          (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)

 #define ETH_AF_XDP_MP_KEY "afxdp_mp_send_fds"
+#define MAX_TX_KICK_TRIES    10

 static int afxdp_dev_count;

@@ -480,22 +481,29 @@ static void
 kick_tx(struct pkt_tx_queue *txq, struct xsk_ring_cons *cq)
 {
      struct xsk_umem_info *umem = txq->umem;
+     int tries = 0;

+     /* Pull completion queue entries to free UMEM buffers */
      pull_umem_cq(umem, XSK_RING_CONS__DEFAULT_NUM_DESCS, cq);

-     if (tx_syscall_needed(&txq->tx))
-           while (send(xsk_socket__fd(txq->pair->xsk), NULL,
-                     0, MSG_DONTWAIT) < 0) {
-                 /* some thing unexpected */
-                 if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
-                       break;
+     if (!tx_syscall_needed(&txq->tx))
+           return;

-                 /* pull from completion queue to leave more space */
-                 if (errno == EAGAIN)
+     for (tries = 0; tries < MAX_TX_KICK_TRIES; tries++) {
+           if (send(xsk_socket__fd(txq->pair->xsk), NULL, 0,
+                       MSG_DONTWAIT) >= 0)
+                 break;
+           if (errno != EBUSY && errno != EAGAIN && errno != EINTR)
+                 break;
+
+           if (errno == EAGAIN) {
+                 /* Kernel TX ring has no space or UMEM completion queue
+                 *  is lagging behind. Try pulling CQ to free room. */\
                        pull_umem_cq(umem,
-                                  XSK_RING_CONS__DEFAULT_NUM_DESCS,
-                                  cq);
+                                   XSK_RING_CONS__DEFAULT_NUM_DESCS,
+                                   cq);
            }
+     }
 }

 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
--
2.39.5

[-- Attachment #2: Type: text/html, Size: 16682 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-07 16:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-07 16:26 [PATCH] af_xdp kick_tx() Retries instead of endless loop Yan Yanovsky

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