AF_XDP-interaction: Report warning when TX-kick via sendto fails

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
Jesper Dangaard Brouer
2022-01-14 13:26:24 +01:00
parent b1b465a32f
commit 49c1efadf8

View File

@ -527,16 +527,31 @@ error_exit:
return NULL; return NULL;
} }
static int kick_tx(struct xsk_socket_info *xsk)
{
int err = 0;
int ret;
ret = sendto(xsk_socket__fd(xsk->xsk), NULL, 0, MSG_DONTWAIT, NULL, 0);
if (ret < 0) { /* On error, -1 is returned, and errno is set */
fprintf(stderr, "WARN: %s() sendto() failed with errno:%d\n",
__func__, errno);
err = errno;
}
return err;
}
static void complete_tx(struct xsk_socket_info *xsk) static void complete_tx(struct xsk_socket_info *xsk)
{ {
unsigned int completed; unsigned int completed;
uint32_t idx_cq; uint32_t idx_cq;
int ret;
if (!xsk->outstanding_tx) if (!xsk->outstanding_tx)
return; return;
sendto(xsk_socket__fd(xsk->xsk), NULL, 0, MSG_DONTWAIT, NULL, 0); /* Notify kernel via sendto syscall that TX packet are avail */
kick_tx(xsk);
/* Collect/free completed TX buffers */ /* Collect/free completed TX buffers */
completed = xsk_ring_cons__peek(&xsk->cq, completed = xsk_ring_cons__peek(&xsk->cq,
@ -872,7 +887,7 @@ static void tx_pkt(struct config *cfg, struct xsk_socket_info *xsk)
xsk_ring_prod__submit(&xsk->tx, 1); xsk_ring_prod__submit(&xsk->tx, 1);
xsk->outstanding_tx++; xsk->outstanding_tx++;
} }
//complete_tx(xsk); complete_tx(xsk);
} }
/* Generate some fake packets (in umem area). Real system will deliver TX /* Generate some fake packets (in umem area). Real system will deliver TX