net/af_xdp: use libxdp if available
[dpdk.git] / drivers / net / af_xdp / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2019 Intel Corporation
3
4 if is_windows
5     build = false
6     reason = 'not supported on Windows'
7     subdir_done()
8 endif
9
10 sources = files('rte_eth_af_xdp.c')
11
12 xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pkg-config')
13 bpf_dep = dependency('libbpf', required: false, method: 'pkg-config')
14 if not bpf_dep.found()
15     bpf_dep = cc.find_library('bpf', required: false)
16 endif
17
18 if cc.has_header('linux/if_xdp.h')
19     if xdp_dep.found() and cc.has_header('xdp/xsk.h')
20         if bpf_dep.found() and cc.has_header('bpf/bpf.h')
21             cflags += ['-DRTE_NET_AF_XDP_LIBXDP']
22             cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
23             ext_deps += xdp_dep
24             ext_deps += bpf_dep
25         else
26             build = false
27             reason = 'missing dependency, libbpf'
28         endif
29     elif bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('bpf/bpf.h')
30         # libxdp not found. Rely solely on libbpf for xsk functionality
31         # which is only available in versions <= v0.6.0.
32         bpf_ver_dep = dependency('libbpf', version : '<=0.6.0',
33                                  required: false, method: 'pkg-config')
34         if bpf_ver_dep.found()
35             ext_deps += bpf_dep
36             bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0',
37                             required: false, method: 'pkg-config')
38             if bpf_shumem_ver_dep.found()
39                 cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM']
40             endif
41         else
42             build = false
43             reason = 'missing dependency, "libxdp" or "libbpf <= v0.6.0"'
44         endif
45     else
46         build = false
47         reason = 'missing dependency, "libxdp" and "libbpf"'
48     endif
49 else
50     build = false
51     reason = 'missing header, "linux/if_xdp.h"'
52 endif