Skip to content

Commit be83333

Browse files
anguy11Jeff Kirsher
authored andcommitted
ixgbevf: Add support for meta data
Add support for XDP meta data when using build skb. Based on commit 366a88f ("bpf, ixgbe: add meta data support") Signed-off-by: Tony Nguyen <[email protected]> Acked-by: John Fastabend <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent efecfd5 commit be83333

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,20 @@ struct sk_buff *ixgbevf_construct_skb(struct ixgbevf_ring *rx_ring,
889889
#if L1_CACHE_BYTES < 128
890890
prefetch(xdp->data + L1_CACHE_BYTES);
891891
#endif
892+
/* Note, we get here by enabling legacy-rx via:
893+
*
894+
* ethtool --set-priv-flags <dev> legacy-rx on
895+
*
896+
* In this mode, we currently get 0 extra XDP headroom as
897+
* opposed to having legacy-rx off, where we process XDP
898+
* packets going to stack via ixgbevf_build_skb().
899+
*
900+
* For ixgbevf_construct_skb() mode it means that the
901+
* xdp->data_meta will always point to xdp->data, since
902+
* the helper cannot expand the head. Should this ever
903+
* changed in future for legacy-rx mode on, then lets also
904+
* add xdp->data_meta handling here.
905+
*/
892906

893907
/* allocate a skb to store the frags */
894908
skb = napi_alloc_skb(&rx_ring->q_vector->napi, IXGBEVF_RX_HDR_SIZE);
@@ -936,6 +950,7 @@ static struct sk_buff *ixgbevf_build_skb(struct ixgbevf_ring *rx_ring,
936950
struct xdp_buff *xdp,
937951
union ixgbe_adv_rx_desc *rx_desc)
938952
{
953+
unsigned int metasize = xdp->data - xdp->data_meta;
939954
#if (PAGE_SIZE < 8192)
940955
unsigned int truesize = ixgbevf_rx_pg_size(rx_ring) / 2;
941956
#else
@@ -945,10 +960,14 @@ static struct sk_buff *ixgbevf_build_skb(struct ixgbevf_ring *rx_ring,
945960
#endif
946961
struct sk_buff *skb;
947962

948-
/* prefetch first cache line of first page */
949-
prefetch(xdp->data);
963+
/* Prefetch first cache line of first page. If xdp->data_meta
964+
* is unused, this points to xdp->data, otherwise, we likely
965+
* have a consumer accessing first few bytes of meta data,
966+
* and then actual data.
967+
*/
968+
prefetch(xdp->data_meta);
950969
#if L1_CACHE_BYTES < 128
951-
prefetch(xdp->data + L1_CACHE_BYTES);
970+
prefetch(xdp->data_meta + L1_CACHE_BYTES);
952971
#endif
953972

954973
/* build an skb around the page buffer */
@@ -959,6 +978,8 @@ static struct sk_buff *ixgbevf_build_skb(struct ixgbevf_ring *rx_ring,
959978
/* update pointers within the skb to store the data */
960979
skb_reserve(skb, xdp->data - xdp->data_hard_start);
961980
__skb_put(skb, xdp->data_end - xdp->data);
981+
if (metasize)
982+
skb_metadata_set(skb, metasize);
962983

963984
/* update buffer offset */
964985
#if (PAGE_SIZE < 8192)
@@ -1126,7 +1147,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
11261147
if (!skb) {
11271148
xdp.data = page_address(rx_buffer->page) +
11281149
rx_buffer->page_offset;
1129-
xdp_set_data_meta_invalid(&xdp);
1150+
xdp.data_meta = xdp.data;
11301151
xdp.data_hard_start = xdp.data -
11311152
ixgbevf_rx_offset(rx_ring);
11321153
xdp.data_end = xdp.data + size;

0 commit comments

Comments
 (0)