X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Faf_xdp%2Fcompat.h;h=52fd447b69b6d3000259007fe983b27a436830c8;hb=cc9dbd9aacf12d2cd0bae3add60cd30ed64bee4d;hp=545c8aa395e076c76dad05a2b6276892f35f0477;hpb=055a393626ed25ccf92e7c685495a87f6fb6ab52;p=dpdk.git diff --git a/drivers/net/af_xdp/compat.h b/drivers/net/af_xdp/compat.h index 545c8aa395..52fd447b69 100644 --- a/drivers/net/af_xdp/compat.h +++ b/drivers/net/af_xdp/compat.h @@ -4,6 +4,7 @@ #include #include +#include #if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \ defined(RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM) @@ -41,15 +42,40 @@ 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 -syscall_needed(struct xsk_ring_prod *q, uint32_t busy_budget) +tx_syscall_needed(struct xsk_ring_prod *q) { - return xsk_ring_prod__needs_wakeup(q) | busy_budget; + 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 -syscall_needed(struct xsk_ring_prod *q __rte_unused, uint32_t busy_budget) +tx_syscall_needed(struct xsk_ring_prod *q __rte_unused) { - return busy_budget; + return 1; } #endif