Skip to content

Commit 2a637c5

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
xdp: For Intel AF_XDP drivers add XDP frame_sz
Intel drivers implement native AF_XDP zerocopy in separate C-files, that have its own invocation of bpf_prog_run_xdp(). The setup of xdp_buff is also handled in separately from normal code path. This patch update XDP frame_sz for AF_XDP zerocopy drivers i40e, ice and ixgbe, as the code changes needed are very similar. Introduce a helper function xsk_umem_xdp_frame_sz() for calculating frame size. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Björn Töpel <[email protected]> Cc: [email protected] Cc: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/158945347511.97035.8536753731329475655.stgit@firesoul
1 parent d4ecdbf commit 2a637c5

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,14 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
531531
{
532532
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
533533
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
534+
struct xdp_umem *umem = rx_ring->xsk_umem;
534535
unsigned int xdp_res, xdp_xmit = 0;
535536
bool failure = false;
536537
struct sk_buff *skb;
537538
struct xdp_buff xdp;
538539

539540
xdp.rxq = &rx_ring->xdp_rxq;
541+
xdp.frame_sz = xsk_umem_xdp_frame_sz(umem);
540542

541543
while (likely(total_rx_packets < (unsigned int)budget)) {
542544
struct i40e_rx_buffer *bi;

drivers/net/ethernet/intel/ice/ice_xsk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,13 @@ int ice_clean_rx_irq_zc(struct ice_ring *rx_ring, int budget)
840840
{
841841
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
842842
u16 cleaned_count = ICE_DESC_UNUSED(rx_ring);
843+
struct xdp_umem *umem = rx_ring->xsk_umem;
843844
unsigned int xdp_xmit = 0;
844845
bool failure = false;
845846
struct xdp_buff xdp;
846847

847848
xdp.rxq = &rx_ring->xdp_rxq;
849+
xdp.frame_sz = xsk_umem_xdp_frame_sz(umem);
848850

849851
while (likely(total_rx_packets < (unsigned int)budget)) {
850852
union ice_32b_rx_flex_desc *rx_desc;

drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,14 @@ int ixgbe_clean_rx_irq_zc(struct ixgbe_q_vector *q_vector,
431431
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
432432
struct ixgbe_adapter *adapter = q_vector->adapter;
433433
u16 cleaned_count = ixgbe_desc_unused(rx_ring);
434+
struct xdp_umem *umem = rx_ring->xsk_umem;
434435
unsigned int xdp_res, xdp_xmit = 0;
435436
bool failure = false;
436437
struct sk_buff *skb;
437438
struct xdp_buff xdp;
438439

439440
xdp.rxq = &rx_ring->xdp_rxq;
441+
xdp.frame_sz = xsk_umem_xdp_frame_sz(umem);
440442

441443
while (likely(total_rx_packets < budget)) {
442444
union ixgbe_adv_rx_desc *rx_desc;

include/net/xdp_sock.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ static inline u64 xsk_umem_adjust_offset(struct xdp_umem *umem, u64 address,
236236
else
237237
return address + offset;
238238
}
239+
240+
static inline u32 xsk_umem_xdp_frame_sz(struct xdp_umem *umem)
241+
{
242+
return umem->chunk_size_nohr + umem->headroom;
243+
}
244+
239245
#else
240246
static inline int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
241247
{
@@ -366,6 +372,11 @@ static inline u64 xsk_umem_adjust_offset(struct xdp_umem *umem, u64 handle,
366372
return 0;
367373
}
368374

375+
static inline u32 xsk_umem_xdp_frame_sz(struct xdp_umem *umem)
376+
{
377+
return 0;
378+
}
379+
369380
static inline int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp)
370381
{
371382
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)