1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2019 Intel Corporation 3 4if is_windows 5 build = false 6 reason = 'not supported on Windows' 7 subdir_done() 8endif 9 10if arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_32') 11 build = false 12 reason = 'not supported on 32-bit x86' 13 subdir_done() 14endif 15 16sources = files('rte_eth_af_xdp.c') 17 18libxdp_ver = '>=1.2.2' 19xdp_dep = dependency('libxdp', version : libxdp_ver, required: false, method: 'pkg-config') 20bpf_dep = dependency('libbpf', required: false, method: 'pkg-config') 21if not bpf_dep.found() 22 bpf_dep = cc.find_library('bpf', required: false) 23endif 24 25if cc.has_header('linux/if_xdp.h') 26 if xdp_dep.found() and cc.has_header('xdp/xsk.h') 27 cflags += ['-DRTE_NET_AF_XDP_LIBXDP'] 28 ext_deps += xdp_dep 29 if bpf_dep.found() and cc.has_header('bpf/bpf.h') 30 ext_deps += bpf_dep 31 else 32 build = false 33 reason = 'missing dependency, libbpf' 34 endif 35 elif bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('bpf/bpf.h') 36 # libxdp not found. Rely solely on libbpf for xsk functionality 37 # which is only available in versions <= v0.6.0. 38 bpf_ver_dep = dependency('libbpf', version : '<=0.6.0', 39 required: false, method: 'pkg-config') 40 if bpf_ver_dep.found() 41 ext_deps += bpf_dep 42 else 43 build = false 44 reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"' 45 endif 46 else 47 build = false 48 reason = 'missing dependency, "libxdp ' + libxdp_ver + '" and "libbpf"' 49 endif 50else 51 build = false 52 reason = 'missing header, "linux/if_xdp.h"' 53endif 54 55if build 56 xsk_check_prefix = ''' 57#ifndef typeof 58#define typeof __typeof__ 59#endif 60 61#ifndef asm 62#define asm __asm__ 63#endif 64 65#ifdef RTE_NET_AF_XDP_LIBXDP 66#include <xdp/xsk.h> 67#else 68#include <bpf/xsk.h> 69#endif 70 ''' 71 72 if cc.has_function('xsk_socket__create_shared', prefix : xsk_check_prefix, 73 dependencies : ext_deps, args: cflags) 74 cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM'] 75 endif 76 if cc.has_function('bpf_object__next_program', 77 prefix : '#include <bpf/libbpf.h>', 78 dependencies : bpf_dep, args: cflags) 79 cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] 80 endif 81 if cc.has_function('bpf_xdp_attach', 82 prefix : '#include <bpf/libbpf.h>', 83 dependencies : bpf_dep, args: cflags) 84 cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH'] 85 endif 86 if cc.has_function('xsk_socket__update_xskmap', prefix : xsk_check_prefix, 87 dependencies : ext_deps, args: cflags) 88 cflags += ['-DETH_AF_XDP_UPDATE_XSKMAP'] 89 endif 90endif 91 92require_iova_in_mbuf = false 93