Skip to content

Commit 3d0c5f1

Browse files
magnus-karlssonborkmann
authored andcommitted
i40e: add support for AF_XDP need_wakeup feature
This patch adds support for the need_wakeup feature of AF_XDP. If the application has told the kernel that it might sleep using the new bind flag XDP_USE_NEED_WAKEUP, the driver will then set this flag if it has no more buffers on the NIC Rx ring and yield to the application. For Tx, it will set the flag if it has no outstanding Tx completion interrupts and return to the application. Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 77cd0d7 commit 3d0c5f1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎drivers/net/ethernet/intel/i40e/i40e_xsk.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,15 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
626626

627627
i40e_finalize_xdp_rx(rx_ring, xdp_xmit);
628628
i40e_update_rx_stats(rx_ring, total_rx_bytes, total_rx_packets);
629+
630+
if (xsk_umem_uses_need_wakeup(rx_ring->xsk_umem)) {
631+
if (failure || rx_ring->next_to_clean == rx_ring->next_to_use)
632+
xsk_set_rx_need_wakeup(rx_ring->xsk_umem);
633+
else
634+
xsk_clear_rx_need_wakeup(rx_ring->xsk_umem);
635+
636+
return (int)total_rx_packets;
637+
}
629638
return failure ? budget : (int)total_rx_packets;
630639
}
631640

@@ -681,6 +690,8 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)
681690
i40e_xdp_ring_update_tail(xdp_ring);
682691

683692
xsk_umem_consume_tx_done(xdp_ring->xsk_umem);
693+
if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem))
694+
xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem);
684695
}
685696

686697
return !!budget && work_done;
@@ -759,6 +770,13 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,
759770
i40e_update_tx_stats(tx_ring, completed_frames, total_bytes);
760771

761772
out_xmit:
773+
if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) {
774+
if (tx_ring->next_to_clean == tx_ring->next_to_use)
775+
xsk_set_tx_need_wakeup(tx_ring->xsk_umem);
776+
else
777+
xsk_clear_tx_need_wakeup(tx_ring->xsk_umem);
778+
}
779+
762780
xmit_done = i40e_xmit_zc(tx_ring, budget);
763781

764782
return work_done && xmit_done;

0 commit comments

Comments
 (0)