]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ice: respect metadata in legacy-rx/ice_construct_skb()
authorAlexander Lobakin <alexandr.lobakin@intel.com>
Wed, 8 Dec 2021 14:06:56 +0000 (15:06 +0100)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 31 Jan 2022 17:43:35 +0000 (09:43 -0800)
In "legacy-rx" mode represented by ice_construct_skb(), we can
still use XDP (and XDP metadata), but after XDP_PASS the metadata
will be lost as it doesn't get copied to the skb.
Copy it along with the frame headers. Account its size on skb
allocation, and when copying just treat it as a part of the frame
and do a pull after to "move" it to the "reserved" zone.
Point net_prefetch() to xdp->data_meta instead of data. This won't
change anything when the meta is not here, but will save some cache
misses otherwise.

Suggested-by: Jesper Dangaard Brouer <brouer@redhat.com>
Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Kiran Bhandare <kiranx.bhandare@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_txrx.c

index 3e38695f1c9d811182c2b23e4eaebe4b3b05fe7f..c2258bee8ecbc1c00de7049c3fb29fe3524d4585 100644 (file)
@@ -983,15 +983,17 @@ static struct sk_buff *
 ice_construct_skb(struct ice_rx_ring *rx_ring, struct ice_rx_buf *rx_buf,
                  struct xdp_buff *xdp)
 {
+       unsigned int metasize = xdp->data - xdp->data_meta;
        unsigned int size = xdp->data_end - xdp->data;
        unsigned int headlen;
        struct sk_buff *skb;
 
        /* prefetch first cache line of first page */
-       net_prefetch(xdp->data);
+       net_prefetch(xdp->data_meta);
 
        /* allocate a skb to store the frags */
-       skb = __napi_alloc_skb(&rx_ring->q_vector->napi, ICE_RX_HDR_SIZE,
+       skb = __napi_alloc_skb(&rx_ring->q_vector->napi,
+                              ICE_RX_HDR_SIZE + metasize,
                               GFP_ATOMIC | __GFP_NOWARN);
        if (unlikely(!skb))
                return NULL;
@@ -1003,8 +1005,13 @@ ice_construct_skb(struct ice_rx_ring *rx_ring, struct ice_rx_buf *rx_buf,
                headlen = eth_get_headlen(skb->dev, xdp->data, ICE_RX_HDR_SIZE);
 
        /* align pull length to size of long to optimize memcpy performance */
-       memcpy(__skb_put(skb, headlen), xdp->data, ALIGN(headlen,
-                                                        sizeof(long)));
+       memcpy(__skb_put(skb, headlen + metasize), xdp->data_meta,
+              ALIGN(headlen + metasize, sizeof(long)));
+
+       if (metasize) {
+               skb_metadata_set(skb, metasize);
+               __skb_pull(skb, metasize);
+       }
 
        /* if we exhaust the linear part then add what is left as a frag */
        size -= headlen;