Message ID | 20211208140702.642741-4-alexandr.lobakin@intel.com (mailing list archive) |
---|---|
State | Awaiting Upstream |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: intel: napi_alloc_skb() vs metadata | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 16 of 16 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 34 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of > Alexander Lobakin > Sent: Wednesday, December 8, 2021 7:37 PM > To: intel-wired-lan@lists.osuosl.org > Cc: Song Liu <songliubraving@fb.com>; Alexei Starovoitov <ast@kernel.org>; > Andrii Nakryiko <andrii@kernel.org>; Daniel Borkmann > <daniel@iogearbox.net>; John Fastabend <john.fastabend@gmail.com>; > Jesper Dangaard Brouer <brouer@redhat.com>; Yonghong Song > <yhs@fb.com>; Jesper Dangaard Brouer <hawk@kernel.org>; KP Singh > <kpsingh@kernel.org>; Jakub Kicinski <kuba@kernel.org>; > netdev@vger.kernel.org; linux-kernel@vger.kernel.org; David S. Miller > <davem@davemloft.net>; Björn Töpel <bjorn@kernel.org>; > bpf@vger.kernel.org; Martin KaFai Lau <kafai@fb.com> > Subject: [Intel-wired-lan] [PATCH v4 net-next 3/9] ice: respect metadata in > legacy-rx/ice_construct_skb() > > 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> > --- > drivers/net/ethernet/intel/ice/ice_txrx.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > Tested-by: Kiran Bhandare <kiranx.bhandare@intel.com> A Contingent Worker at Intel
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c index bc3ba19dc88f..d724b6376c43 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c @@ -968,15 +968,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; @@ -988,8 +990,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;