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 vpp_find_path(XDP_INCLUDE_DIR NAMES xdp/xsk.h)
15 if (NOT XDP_INCLUDE_DIR)
16 message(WARNING "libxdp 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 XDP_LIB libxdp.a)
22 vpp_plugin_find_library(af_xdp BPF_LIB libbpf.a)
23 vpp_plugin_find_library(af_xdp ELF_LIB elf)
24 vpp_plugin_find_library(af_xdp Z_LIB z)
25 if (NOT XDP_LIB OR NOT BPF_LIB OR NOT ELF_LIB OR NOT Z_LIB)
26 message(WARNING "af_xdp plugin - missing libraries - af_xdp plugin disabled")
30 set(CMAKE_REQUIRED_FLAGS "-fPIC")
31 set(CMAKE_REQUIRED_INCLUDES "${XDP_INCLUDE_DIR}")
32 set(CMAKE_REQUIRED_LIBRARIES "${XDP_LIB}" "${BPF_LIB}" "${ELF_LIB}" "${Z_LIB}")
33 CHECK_C_SOURCE_COMPILES("
37 return xsk_socket__create (0, 0, 0, 0, 0, 0, 0);
38 }" XDP_COMPILES_CHECK)
39 if (NOT XDP_COMPILES_CHECK)
40 message(WARNING "af_xdp plugins - no working libxdp found - af_xdp plugin disabled")
44 include_directories(${XDP_INCLUDE_DIR})
74 SUPPORTED_OS_LIST Linux