On Mon, 8 Dec 2025 15:56:37 +0000 Yan Yanovsky <[email protected]> wrote:
> From 191d90eaab50c6855ee746361e7e735572f3b1ce Mon Sep 17 00:00:00 2001 > From: Yan Yanovsky <[email protected]> > 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 <[email protected]> > Minor cosmetic changes needed. > 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; > Unnecessary initialization > + /* 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++) { Suggest (but not required) to put definition here as: for (unsigned int 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, Do not put line continuation on the comment. Original indent is better. I.e line up args on first to same column > - XSK_RING_CONS__DEFAULT_NUM_DESCS, > - cq); > + > XSK_RING_CONS__DEFAULT_NUM_DESCS, > + cq); > } > + } > } > > #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG) Subject is repeated twice.

