diff options
| author | Tony Nguyen <anthony.l.nguyen@intel.com> | 2018-03-16 18:34:05 -0400 |
|---|---|---|
| committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2018-03-23 18:20:57 -0400 |
| commit | be8333322effadce697bcee749c827d6e14b4d31 (patch) | |
| tree | 41272e26c393edd10788af454da52d332a76dc76 /drivers/net/ethernet/intel/ixgbevf | |
| parent | efecfd5f803d5957ccf003310bff432c6ebd653b (diff) | |
ixgbevf: Add support for meta data
Add support for XDP meta data when using build skb.
Based on commit 366a88fe2f40 ("bpf, ixgbe: add meta data support")
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbevf')
| -rw-r--r-- | drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 5167e81e0cf1..3d9033f26eff 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | |||
| @@ -889,6 +889,20 @@ struct sk_buff *ixgbevf_construct_skb(struct ixgbevf_ring *rx_ring, | |||
| 889 | #if L1_CACHE_BYTES < 128 | 889 | #if L1_CACHE_BYTES < 128 |
| 890 | prefetch(xdp->data + L1_CACHE_BYTES); | 890 | prefetch(xdp->data + L1_CACHE_BYTES); |
| 891 | #endif | 891 | #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 | */ | ||
| 892 | 906 | ||
| 893 | /* allocate a skb to store the frags */ | 907 | /* allocate a skb to store the frags */ |
| 894 | skb = napi_alloc_skb(&rx_ring->q_vector->napi, IXGBEVF_RX_HDR_SIZE); | 908 | 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, | |||
| 936 | struct xdp_buff *xdp, | 950 | struct xdp_buff *xdp, |
| 937 | union ixgbe_adv_rx_desc *rx_desc) | 951 | union ixgbe_adv_rx_desc *rx_desc) |
| 938 | { | 952 | { |
| 953 | unsigned int metasize = xdp->data - xdp->data_meta; | ||
| 939 | #if (PAGE_SIZE < 8192) | 954 | #if (PAGE_SIZE < 8192) |
| 940 | unsigned int truesize = ixgbevf_rx_pg_size(rx_ring) / 2; | 955 | unsigned int truesize = ixgbevf_rx_pg_size(rx_ring) / 2; |
| 941 | #else | 956 | #else |
| @@ -945,10 +960,14 @@ static struct sk_buff *ixgbevf_build_skb(struct ixgbevf_ring *rx_ring, | |||
| 945 | #endif | 960 | #endif |
| 946 | struct sk_buff *skb; | 961 | struct sk_buff *skb; |
| 947 | 962 | ||
| 948 | /* prefetch first cache line of first page */ | 963 | /* Prefetch first cache line of first page. If xdp->data_meta |
| 949 | prefetch(xdp->data); | 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); | ||
| 950 | #if L1_CACHE_BYTES < 128 | 969 | #if L1_CACHE_BYTES < 128 |
| 951 | prefetch(xdp->data + L1_CACHE_BYTES); | 970 | prefetch(xdp->data_meta + L1_CACHE_BYTES); |
| 952 | #endif | 971 | #endif |
| 953 | 972 | ||
| 954 | /* build an skb around the page buffer */ | 973 | /* build an skb around the page buffer */ |
| @@ -959,6 +978,8 @@ static struct sk_buff *ixgbevf_build_skb(struct ixgbevf_ring *rx_ring, | |||
| 959 | /* update pointers within the skb to store the data */ | 978 | /* update pointers within the skb to store the data */ |
| 960 | skb_reserve(skb, xdp->data - xdp->data_hard_start); | 979 | skb_reserve(skb, xdp->data - xdp->data_hard_start); |
| 961 | __skb_put(skb, xdp->data_end - xdp->data); | 980 | __skb_put(skb, xdp->data_end - xdp->data); |
| 981 | if (metasize) | ||
| 982 | skb_metadata_set(skb, metasize); | ||
| 962 | 983 | ||
| 963 | /* update buffer offset */ | 984 | /* update buffer offset */ |
| 964 | #if (PAGE_SIZE < 8192) | 985 | #if (PAGE_SIZE < 8192) |
| @@ -1126,7 +1147,7 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector, | |||
| 1126 | if (!skb) { | 1147 | if (!skb) { |
| 1127 | xdp.data = page_address(rx_buffer->page) + | 1148 | xdp.data = page_address(rx_buffer->page) + |
| 1128 | rx_buffer->page_offset; | 1149 | rx_buffer->page_offset; |
| 1129 | xdp_set_data_meta_invalid(&xdp); | 1150 | xdp.data_meta = xdp.data; |
| 1130 | xdp.data_hard_start = xdp.data - | 1151 | xdp.data_hard_start = xdp.data - |
| 1131 | ixgbevf_rx_offset(rx_ring); | 1152 | ixgbevf_rx_offset(rx_ring); |
| 1132 | xdp.data_end = xdp.data + size; | 1153 | xdp.data_end = xdp.data + size; |
