1 # Copyright (c) 2016 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 ##############################################################################
15 # Check if we want to use the system DPDK
16 ##############################################################################
17 option(VPP_USE_SYSTEM_DPDK "Use the system installation of DPDK." OFF)
18 if(VPP_USE_SYSTEM_DPDK)
19 find_package(PkgConfig REQUIRED)
20 pkg_check_modules(DPDK REQUIRED libdpdk)
21 message(WARNING "-- linking dpdk plugin against system libdpdk, version ${DPDK_VERSION}")
22 set(DPDK_LINK_FLAGS ${DPDK_LDFLAGS})
23 include_directories (${DPDK_INCLUDE_DIRS})
25 ##############################################################################
26 # Find lib and include files
27 ##############################################################################
28 vpp_find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h)
29 vpp_plugin_find_library(dpdk DPDK_LIB "libdpdk.a")
31 if (NOT DPDK_INCLUDE_DIR)
32 message(WARNING "-- DPDK headers not found - dpdk plugin disabled")
37 vpp_plugin_find_library(dpdk DPDK_SHLIB "libdpdk.so")
38 set(DPDK_IS_SHARED_LIB 1)
39 message(WARNING "-- linking dpdk plugin against DPDK shared libs")
42 ##############################################################################
43 # Parse DPDK config and version header files
44 ##############################################################################
45 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_config.h rte_config)
46 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_version.h rte_version)
47 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_build_config.h rte_build_config)
49 foreach(l ${rte_config} ${rte_build_config} ${rte_version}})
50 if (l MATCHES "^#define[\t ]*RTE_")
51 STRING(REGEX REPLACE "^#define[\t ]*([A-Z1-9_]+)[\t ]*(.+)" "\\1;\\2" v "${l}")
54 set(DPDK_${name} ${value})
59 "${DPDK_RTE_VER_YEAR}.${DPDK_RTE_VER_MONTH}.${DPDK_RTE_VER_MINOR}")
61 ##############################################################################
62 # verify headroom size
63 ##############################################################################
64 if(NOT ${DPDK_RTE_PKTMBUF_HEADROOM} EQUAL ${PRE_DATA_SIZE})
67 "DPDK RTE_PKTMBUF_HEADROOM (${DPDK_RTE_PKTMBUF_HEADROOM}) "
68 "must be equal to PRE_DATA_SIZE (${PRE_DATA_SIZE})"
72 ##############################################################################
73 # static or dynamic linking
74 ##############################################################################
75 unset(DPDK_LINK_LIBRARIES)
76 unset(DPDK_LINK_FLAGS)
77 message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
78 include_directories (${DPDK_INCLUDE_DIR})
80 if(DPDK_IS_SHARED_LIB)
81 get_filename_component(DPDK_LIB_DIR ${DPDK_SHLIB} DIRECTORY)
82 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
83 list(APPEND DPDK_LINK_LIBRARIES ${DPDK_SHLIB})
85 get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
86 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
87 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
90 ##############################################################################
92 ##############################################################################
93 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
94 vpp_plugin_find_library(dpdk NUMA_LIB "numa")
95 list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
98 ##############################################################################
100 ##############################################################################
101 if(DPDK_RTE_NET_MLX4 OR DPDK_RTE_NET_MLX5)
102 if (DPDK_RTE_IBVERBS_LINK_DLOPEN)
103 message(STATUS "DPDK depends on libmnl (Mellanox PMD requirement)")
104 vpp_plugin_find_library(dpdk MNL_LIB "mnl")
105 list(APPEND DPDK_LINK_LIBRARIES "${MNL_LIB}")
107 message(WARNING "EXPERIMENTAL: DPDK plugin without dlopen mode")
108 vpp_plugin_find_library(dpdk IBVERBS_LIB "libibverbs.a")
109 vpp_plugin_find_library(dpdk MLX5_LIB "libmlx5.a")
110 vpp_plugin_find_library(dpdk MLX4_LIB "libmlx4.a")
111 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${IBVERBS_LIB},${MLX5_LIB},${MLX4_LIB} -Wl,--no-whole-archive,--exclude-libs,ALL")
116 ##############################################################################
118 ##############################################################################
121 include_directories(${OPENSSL_INCLUDE_DIR})
123 set(DPDK_CRYPTODEV_OP_SOURCE cryptodev/cryptodev_op_data_path.c)
124 set(DPDK_CRYPTODEV_SOURCE cryptodev/cryptodev.c)
125 if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
126 set(DPDK_CRYPTODEV_RAW_SOURCE cryptodev/cryptodev_raw_data_path.c)
142 ${DPDK_CRYPTODEV_OP_SOURCE}
143 ${DPDK_CRYPTODEV_SOURCE}
144 ${DPDK_CRYPTODEV_RAW_SOURCE}
158 ${DPDK_LINK_LIBRARIES}
161 ${OPENSSL_CRYPTO_LIBRARIES}