DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yan Yanovsky <yan.yanovsky@catonetworks.com>
To: "dev@dpdk.org" <dev@dpdk.org>,
	"qi.z.zhang@intel.com" <qi.z.zhang@intel.com>
Cc: "ciara.loftus@intel.com" <ciara.loftus@intel.com>
Subject: Subject: [PATCH v3] af_xdp kick_tx() Retries instead of endless loop
Date: Mon, 8 Dec 2025 15:56:37 +0000	[thread overview]
Message-ID: <VI1PR03MB4144B177CE39B84E0DE3F01FF7A2A@VI1PR03MB4144.eurprd03.prod.outlook.com> (raw)

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 v3] 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


             reply	other threads:[~2025-12-08 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 15:56 Yan Yanovsky [this message]
2025-12-08 19:02 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR03MB4144B177CE39B84E0DE3F01FF7A2A@VI1PR03MB4144.eurprd03.prod.outlook.com \
    --to=yan.yanovsky@catonetworks.com \
    --cc=ciara.loftus@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).