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})
24 ##############################################################################
25 # Find lib and include files
26 ##############################################################################
27 find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h)
28 vpp_plugin_find_library(dpdk DPDK_LIB "libdpdk.a")
30 if (NOT DPDK_INCLUDE_DIR)
31 message(WARNING "-- DPDK headers not found - dpdk plugin disabled")
36 vpp_plugin_find_library(dpdk DPDK_SHLIB "libdpdk.so")
37 set(DPDK_IS_SHARED_LIB 1)
38 message(WARNING "-- linking dpdk plugin against DPDK shared libs")
41 ##############################################################################
42 # Parse DPDK config and version header files
43 ##############################################################################
44 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_config.h rte_config)
45 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_version.h rte_version)
46 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_build_config.h rte_build_config)
48 foreach(l ${rte_config} ${rte_build_config} ${rte_version}})
49 if (l MATCHES "^#define[\t ]*RTE_")
50 STRING(REGEX REPLACE "^#define[\t ]*([A-Z1-9_]+)[\t ]*(.+)" "\\1;\\2" v "${l}")
53 set(DPDK_${name} ${value})
58 "${DPDK_RTE_VER_YEAR}.${DPDK_RTE_VER_MONTH}.${DPDK_RTE_VER_MINOR}")
60 ##############################################################################
61 # verify headroom size
62 ##############################################################################
63 if(NOT ${DPDK_RTE_PKTMBUF_HEADROOM} EQUAL ${PRE_DATA_SIZE})
66 "DPDK RTE_PKTMBUF_HEADROOM (${DPDK_RTE_PKTMBUF_HEADROOM}) "
67 "must be equal to PRE_DATA_SIZE (${PRE_DATA_SIZE})"
71 ##############################################################################
72 # static or dynamic linking
73 ##############################################################################
74 unset(DPDK_LINK_LIBRARIES)
75 unset(DPDK_LINK_FLAGS)
76 message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
77 include_directories (${DPDK_INCLUDE_DIR})
79 if(DPDK_IS_SHARED_LIB)
80 get_filename_component(DPDK_LIB_DIR ${DPDK_SHLIB} DIRECTORY)
81 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
82 list(APPEND DPDK_LINK_LIBRARIES ${DPDK_SHLIB})
84 get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
85 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
86 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
89 ##############################################################################
91 ##############################################################################
92 vpp_plugin_find_library(dpdk NUMA_LIB "numa")
93 list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
95 ##############################################################################
97 ##############################################################################
98 if(DPDK_RTE_LIBRTE_MLX4_PMD OR DPDK_RTE_LIBRTE_MLX5_PMD)
99 if (DPDK_RTE_IBVERBS_LINK_DLOPEN)
100 message(STATUS "DPDK depends on libmnl (Mellanox PMD requirement)")
101 vpp_plugin_find_library(dpdk MNL_LIB "mnl")
102 list(APPEND DPDK_LINK_LIBRARIES "${MNL_LIB}")
104 message(WARNING "EXPERIMENTAL: DPDK plugin without dlopen mode")
105 vpp_plugin_find_library(dpdk IBVERBS_LIB "libibverbs.a")
106 vpp_plugin_find_library(dpdk MLX5_LIB "libmlx5.a")
107 vpp_plugin_find_library(dpdk MLX4_LIB "libmlx4.a")
108 vpp_plugin_find_library(dpdk CCAN_LIB "libccan.a")
109 vpp_plugin_find_library(dpdk RDMA_UTIL_LIB "rdma_util")
110 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${IBVERBS_LIB},${MLX5_LIB},${MLX4_LIB},${CCAN_LIB},${RDMA_UTIL_LIB},--no-whole-archive")
115 ##############################################################################
117 ##############################################################################
119 if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
120 set(DPDK_CRYPTODEV_SOURCE cryptodev_dp_api)
122 set(DPDK_CRYPTODEV_SOURCE cryptodev)
137 cryptodev/${DPDK_CRYPTODEV_SOURCE}.c
151 ${DPDK_LINK_LIBRARIES}