1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 find_path(BPF_INCLUDE_DIR NAMES bpf/xsk.h)
15 if (NOT BPF_INCLUDE_DIR)
16 message(WARNING "libbpf headers not found - af_xdp plugin disabled")
20 set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
21 vpp_plugin_find_library(af_xdp BPF_LIB libbpf.a)
22 vpp_plugin_find_library(af_xdp BPF_ELF_LIB elf)
23 vpp_plugin_find_library(af_xdp BPF_Z_LIB z)
24 if (NOT BPF_LIB OR NOT BPF_ELF_LIB OR NOT BPF_Z_LIB)
25 message(WARNING "af_xdp plugin - missing libraries - af_xdp plugin disabled")
29 set(CMAKE_REQUIRED_FLAGS "-fPIC")
30 set(CMAKE_REQUIRED_INCLUDES "${BPF_INCLUDE_DIR}")
31 set(CMAKE_REQUIRED_LIBRARIES "${BPF_LIB}" "${BPF_ELF_LIB}" "${BPF_Z_LIB}")
32 CHECK_C_SOURCE_COMPILES("
36 return xsk_socket__create (0, 0, 0, 0, 0, 0, 0);
37 }" BPF_COMPILES_CHECK)
38 if (NOT BPF_COMPILES_CHECK)
39 message(WARNING "af_xdp plugins - no working libbpf found - af_xdp plugin disabled")
43 include_directories(${BPF_INCLUDE_DIR})