The caller of XDP_SETUP_PROG has already incremented refcnt in
__bpf_prog_get(), so drivers should only increment refcnt by
num_queues - 1.
To fix the issue, update netvsc_xdp_set() to add the correct number
to refcnt.
Hold a refcnt in netvsc_xdp_set()’s other caller, netvsc_attach().
And, do the same in netvsc_vf_setxdp(). Otherwise, every time when VF is
removed and added from the host side, the refcnt will be decreased by one,
which may cause page fault when unloading xdp program.
Fixes: 351e1581395f ("hv_netvsc: Add XDP support")
Signed-off-by: Haiyang Zhang <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
(cherry picked from commit 184367dce4f744bde54377203305ccc8889aa79f)
Signed-off-by: William Breathitt Gray <email address hidden>
This patch adds support of XDP in native mode for hv_netvsc driver, and
transparently sets the XDP program on the associated VF NIC as well.
Setting / unsetting XDP program on synthetic NIC (netvsc) propagates to
VF NIC automatically. Setting / unsetting XDP program on VF NIC directly
is not recommended, also not propagated to synthetic NIC, and may be
overwritten by setting of synthetic NIC.
The Azure/Hyper-V synthetic NIC receive buffer doesn't provide headroom
for XDP. We thought about re-use the RNDIS header space, but it's too
small. So we decided to copy the packets to a page buffer for XDP. And,
most of our VMs on Azure have Accelerated Network (SRIOV) enabled, so
most of the packets run on VF NIC. The synthetic NIC is considered as a
fallback data-path. So the data copy on netvsc won't impact performance
significantly.
XDP program cannot run with LRO (RSC) enabled, so you need to disable LRO
before running XDP:
ethtool -K eth0 lro off
XDP actions not yet supported: XDP_REDIRECT
Signed-off-by: Haiyang Zhang <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
(backported from commit 351e1581395fcc7fb952bbd7dda01238f69968fd)
[ vilhelmgray: context adjustments ]
[ vilhelmgray: drop changes for netvsc_resume() ]
Signed-off-by: William Breathitt Gray <email address hidden>
These assignments occur in multiple places. The patch refactor them
to a function for simplicity. It also puts the struct to heap area
for future expension.
Signed-off-by: Haiyang Zhang <email address hidden>
Reviewed-by: Michael Kelley <email address hidden>
[sl: fix up subject line]
Signed-off-by: Sasha Levin <email address hidden>
(backported from commit 7c9f335a3ff20557a92584199f3d35c7e992bbe5)
[ vilhelmgray: context adjustments and storing ring_size ]
Signed-off-by: William Breathitt Gray <email address hidden>
LRO/RSC in the vSwitch is a feature available in Windows Server 2019
hosts and later. It reduces the per packet processing overhead by
coalescing multiple TCP segments when possible. This patch adds netvsc
driver support for this feature.
Signed-off-by: Haiyang Zhang <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
(backported from commit c8e4eff4675f22ad1110141ed9e62102d4d77e1c)
[ vilhelmgray: context adjustments ]
[ vilhelmgray: remove drop incomplete packet from netvsc_receive() ]
Signed-off-by: William Breathitt Gray <email address hidden>
2d09ff6...
by
=?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <email address hidden>
Here, a new type of allocator support is added to the XDP return
API. A zero-copy allocated xdp_buff cannot be converted to an
xdp_frame. Instead is the buff has to be copied. This is not supported
at all in this commit.
Also, an opaque "handle" is added to xdp_buff. This can be used as a
context for the zero-copy allocator implementation.
Signed-off-by: Björn Töpel <email address hidden>
Signed-off-by: Daniel Borkmann <email address hidden>
(cherry picked from commit 02b55e5657c3a569fc681ba851e464cfa6b90d4f)
Signed-off-by: William Breathitt Gray <email address hidden>
When sending an xdp_frame through xdp_do_redirect call, then error
cases can happen where the xdp_frame needs to be dropped, and
returning an -errno code isn't sufficient/possible any-longer
(e.g. for cpumap case). This is already fully supported, by simply
calling xdp_return_frame.
This patch is an optimization, which provides xdp_return_frame_rx_napi,
which is a faster variant for these error cases. It take advantage of
the protection provided by XDP RX running under NAPI protection.
This change is mostly relevant for drivers using the page_pool
allocator as it can take advantage of this. (Tested with mlx5).
Like cpumap create queue for xdp frames that will be bulked. For now,
this patch simply invoke ndo_xdp_xmit foreach frame. This happens,
either when the map flush operation is envoked, or when the limit
DEV_MAP_BULK_SIZE is reached.
V5: Avoid memleak on error path in dev_map_update_elem()
Functionality is the same, but the ndo_xdp_xmit call is now
simply invoked from inside the devmap.c code.
V2: Fix compile issue reported by kbuild test robot <email address hidden>
V5: Cleanups requested by Daniel
- Newlines before func definition
- Use BUILD_BUG_ON checks
- Remove unnecessary use return value store in dev_map_enqueue