1f1debd77SXiaolong Ye# SPDX-License-Identifier: BSD-3-Clause 2f1debd77SXiaolong Ye# Copyright(c) 2019 Intel Corporation 3f1debd77SXiaolong Ye 4b9d60b54SPallavi Kadamif is_windows 5b9d60b54SPallavi Kadam build = false 6b9d60b54SPallavi Kadam reason = 'not supported on Windows' 7b9d60b54SPallavi Kadam subdir_done() 8b9d60b54SPallavi Kadamendif 9b9d60b54SPallavi Kadam 10*4edbcc7bSLuca Boccassiif arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_32') 11*4edbcc7bSLuca Boccassi build = false 12*4edbcc7bSLuca Boccassi reason = 'not supported on 32-bit x86' 13*4edbcc7bSLuca Boccassi subdir_done() 14*4edbcc7bSLuca Boccassiendif 15*4edbcc7bSLuca Boccassi 16f1debd77SXiaolong Yesources = files('rte_eth_af_xdp.c') 17f1debd77SXiaolong Ye 18f76dc44dSAndrew Rybchenkolibxdp_ver = '>=1.2.2' 19f76dc44dSAndrew Rybchenkoxdp_dep = dependency('libxdp', version : libxdp_ver, required: false, method: 'pkg-config') 207be7dc6dSBruce Richardsonbpf_dep = dependency('libbpf', required: false, method: 'pkg-config') 21f1debd77SXiaolong Yeif not bpf_dep.found() 22f1debd77SXiaolong Ye bpf_dep = cc.find_library('bpf', required: false) 23f1debd77SXiaolong Yeendif 24f1debd77SXiaolong Ye 25fa4dfda5SCiara Loftusif cc.has_header('linux/if_xdp.h') 26fa4dfda5SCiara Loftus if xdp_dep.found() and cc.has_header('xdp/xsk.h') 27fa4dfda5SCiara Loftus cflags += ['-DRTE_NET_AF_XDP_LIBXDP'] 28fa4dfda5SCiara Loftus ext_deps += xdp_dep 2950b855fcSAndrew Rybchenko if bpf_dep.found() and cc.has_header('bpf/bpf.h') 30f1debd77SXiaolong Ye ext_deps += bpf_dep 31fa4dfda5SCiara Loftus else 32fa4dfda5SCiara Loftus build = false 33fa4dfda5SCiara Loftus reason = 'missing dependency, libbpf' 34fa4dfda5SCiara Loftus endif 35fa4dfda5SCiara Loftus elif bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('bpf/bpf.h') 36fa4dfda5SCiara Loftus # libxdp not found. Rely solely on libbpf for xsk functionality 37fa4dfda5SCiara Loftus # which is only available in versions <= v0.6.0. 38fa4dfda5SCiara Loftus bpf_ver_dep = dependency('libbpf', version : '<=0.6.0', 397be7dc6dSBruce Richardson required: false, method: 'pkg-config') 4074b46340SCiara Loftus if bpf_ver_dep.found() 41fa4dfda5SCiara Loftus ext_deps += bpf_dep 42f1debd77SXiaolong Ye else 43f1debd77SXiaolong Ye build = false 44f76dc44dSAndrew Rybchenko reason = 'missing dependency, "libxdp ' + libxdp_ver + '" or "libbpf <= v0.6.0"' 45fa4dfda5SCiara Loftus endif 46fa4dfda5SCiara Loftus else 47fa4dfda5SCiara Loftus build = false 48f76dc44dSAndrew Rybchenko reason = 'missing dependency, "libxdp ' + libxdp_ver + '" and "libbpf"' 49fa4dfda5SCiara Loftus endif 50fa4dfda5SCiara Loftuselse 51fa4dfda5SCiara Loftus build = false 52fa4dfda5SCiara Loftus reason = 'missing header, "linux/if_xdp.h"' 53f1debd77SXiaolong Yeendif 54e024c7e8SAndrew Rybchenko 55e024c7e8SAndrew Rybchenkoif build 56e024c7e8SAndrew Rybchenko xsk_check_prefix = ''' 57349e2ee7SShibin Koikkara Reeny#ifndef typeof 58349e2ee7SShibin Koikkara Reeny#define typeof __typeof__ 59349e2ee7SShibin Koikkara Reeny#endif 60349e2ee7SShibin Koikkara Reeny 61349e2ee7SShibin Koikkara Reeny#ifndef asm 62349e2ee7SShibin Koikkara Reeny#define asm __asm__ 63349e2ee7SShibin Koikkara Reeny#endif 64349e2ee7SShibin Koikkara Reeny 65e024c7e8SAndrew Rybchenko#ifdef RTE_NET_AF_XDP_LIBXDP 66e024c7e8SAndrew Rybchenko#include <xdp/xsk.h> 67e024c7e8SAndrew Rybchenko#else 68e024c7e8SAndrew Rybchenko#include <bpf/xsk.h> 69e024c7e8SAndrew Rybchenko#endif 70e024c7e8SAndrew Rybchenko ''' 71e024c7e8SAndrew Rybchenko 72e024c7e8SAndrew Rybchenko if cc.has_function('xsk_socket__create_shared', prefix : xsk_check_prefix, 73349e2ee7SShibin Koikkara Reeny dependencies : ext_deps, args: cflags) 74e024c7e8SAndrew Rybchenko cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM'] 75e024c7e8SAndrew Rybchenko endif 760ed0bc38SAndrew Rybchenko if cc.has_function('bpf_object__next_program', 770ed0bc38SAndrew Rybchenko prefix : '#include <bpf/libbpf.h>', 78349e2ee7SShibin Koikkara Reeny dependencies : bpf_dep, args: cflags) 790ed0bc38SAndrew Rybchenko cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] 800ed0bc38SAndrew Rybchenko endif 811eb1846bSCiara Loftus if cc.has_function('bpf_xdp_attach', 821eb1846bSCiara Loftus prefix : '#include <bpf/libbpf.h>', 83349e2ee7SShibin Koikkara Reeny dependencies : bpf_dep, args: cflags) 841eb1846bSCiara Loftus cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH'] 851eb1846bSCiara Loftus endif 869c132373SMaryam Tahhan if cc.has_function('xsk_socket__update_xskmap', prefix : xsk_check_prefix, 879c132373SMaryam Tahhan dependencies : ext_deps, args: cflags) 889c132373SMaryam Tahhan cflags += ['-DETH_AF_XDP_UPDATE_XSKMAP'] 899c132373SMaryam Tahhan endif 90e024c7e8SAndrew Rybchenkoendif 91b1ae367aSShijith Thotton 92d5d9e8feSThomas Monjalonrequire_iova_in_mbuf = false 93