aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/af_xdp/CMakeLists.txt
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-06-12 08:47:34 +0200
committerDamjan Marion <dmarion@me.com>2020-08-31 17:16:56 +0000
commit4a76d6f6da035220917097bc047b08bc58254803 (patch)
tree10399485df66c0ebeeaa32edbb7a1022b8baa9b3 /src/plugins/af_xdp/CMakeLists.txt
parentbfed7c047d2807f835cd7b9ef0330d314ac0ebc5 (diff)
af_xdp: AF_XDP input plugin
Type: feature Change-Id: I85aa4ad6b68c1aa0e51938002dc691a4b11c545c Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/plugins/af_xdp/CMakeLists.txt')
-rw-r--r--src/plugins/af_xdp/CMakeLists.txt71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/plugins/af_xdp/CMakeLists.txt b/src/plugins/af_xdp/CMakeLists.txt
new file mode 100644
index 00000000000..a56f250646c
--- /dev/null
+++ b/src/plugins/af_xdp/CMakeLists.txt
@@ -0,0 +1,71 @@
+# Copyright (c) 2018 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+find_path(BPF_INCLUDE_DIR NAMES bpf/xsk.h)
+if (NOT BPF_INCLUDE_DIR)
+ message(WARNING "libbpf headers not found - af_xdp plugin disabled")
+ return()
+endif()
+
+set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
+vpp_plugin_find_library(af_xdp BPF_LIB libbpf.a)
+vpp_plugin_find_library(af_xdp BPF_ELF_LIB elf)
+vpp_plugin_find_library(af_xdp BPF_Z_LIB z)
+if (NOT BPF_LIB OR NOT BPF_ELF_LIB OR NOT BPF_Z_LIB)
+ message(WARNING "af_xdp plugin - missing libraries - af_xdp plugin disabled")
+ return()
+endif()
+
+set(CMAKE_REQUIRED_FLAGS "-fPIC")
+set(CMAKE_REQUIRED_INCLUDES "${BPF_INCLUDE_DIR}")
+set(CMAKE_REQUIRED_LIBRARIES "${BPF_LIB}" "${BPF_ELF_LIB}" "${BPF_Z_LIB}")
+CHECK_C_SOURCE_COMPILES("
+#include <bpf/xsk.h>
+int main(void)
+{
+ return xsk_socket__create (0, 0, 0, 0, 0, 0, 0);
+}" BPF_COMPILES_CHECK)
+if (NOT BPF_COMPILES_CHECK)
+ message(WARNING "af_xdp plugins - no working libbpf found - af_xdp plugin disabled")
+ return()
+endif()
+
+include_directories(${BPF_INCLUDE_DIR})
+
+add_vpp_plugin(af_xdp
+ SOURCES
+ api.c
+ cli.c
+ device.c
+ format.c
+ unformat.c
+ plugin.c
+ input.c
+ output.c
+
+ MULTIARCH_SOURCES
+ input.c
+ output.c
+
+ API_FILES
+ af_xdp.api
+
+ API_TEST_SOURCES
+ unformat.c
+ test_api.c
+
+ LINK_LIBRARIES
+ ${BPF_LIB}
+ ${BPF_ELF_LIB}
+ ${BPF_Z_LIB}
+)