net/af_xdp: use BPF link for XDP programs
authorCiara Loftus <ciara.loftus@intel.com>
Fri, 22 Oct 2021 10:42:53 +0000 (10:42 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 2 Nov 2021 16:36:46 +0000 (17:36 +0100)
commitae70cc6e893bdc9e2b3cec290a964ec80a45372a
tree5eb427fe5d13347abfdf6cbaaba97706f9f727f0
parenta451287102fec4eecdb2938760a57334bccc204f
net/af_xdp: use BPF link for XDP programs

Since v0.4.0, if the underlying kernel supports it, libbpf uses 'bpf
link' to manage the programs on the interfaces of the xsks. This has two
repercussions for the PMD.

1. In the case where the PMD asks libbpf to load the default XDP
   program, the PMD no longer needs to remove it on teardown. This is
   because bpf link handles the unloading under the hood.
2. In the case where the PMD loads a custom program, libbpf expects this
   program to be linked via bpf link prior to creating the socket.

This patch introduces probes for the libbpf version and kernel support
for bpf link and orchestrates the loading and unloading of
programs according to the capabilities of the kernel and libbpf. The
libbpf version is checked with meson and pkg-config. The probe for
kernel support mirrors how it is implemented in libbpf. A bpf_link is
created and looked up on loopback device. If successful, bpf_link will
be used for the AF_XDP netdev.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
drivers/net/af_xdp/compat.h
drivers/net/af_xdp/meson.build
drivers/net/af_xdp/rte_eth_af_xdp.c