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 # Find lib and include files
16 ##############################################################################
17 find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h)
18 vpp_plugin_find_library(dpdk DPDK_LIB "libdpdk.a")
20 if (NOT DPDK_INCLUDE_DIR)
21 message(WARNING "-- DPDK headers not found - dpdk plugin disabled")
26 vpp_plugin_find_library(dpdk DPDK_SHLIB "libdpdk.so")
27 set(DPDK_IS_SHARED_LIB 1)
28 message(WARNING "-- linking dpdk plugin against DPDK shared libs")
31 ##############################################################################
32 # Parse DPDK config and version header files
33 ##############################################################################
34 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_config.h rte_config)
35 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_version.h rte_version)
36 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_build_config.h rte_build_config)
38 foreach(l ${rte_config} ${rte_build_config} ${rte_version}})
39 if (l MATCHES "^#define[\t ]*RTE_")
40 STRING(REGEX REPLACE "^#define[\t ]*([A-Z1-9_]+)[\t ]*(.+)" "\\1;\\2" v "${l}")
43 set(DPDK_${name} ${value})
48 "${DPDK_RTE_VER_YEAR}.${DPDK_RTE_VER_MONTH}.${DPDK_RTE_VER_MINOR}")
50 ##############################################################################
51 # verify headroom size
52 ##############################################################################
53 if(NOT ${DPDK_RTE_PKTMBUF_HEADROOM} EQUAL ${PRE_DATA_SIZE})
56 "DPDK RTE_PKTMBUF_HEADROOM (${DPDK_RTE_PKTMBUF_HEADROOM}) "
57 "must be equal to PRE_DATA_SIZE (${PRE_DATA_SIZE})"
61 ##############################################################################
62 # static or dynamic linking
63 ##############################################################################
64 unset(DPDK_LINK_LIBRARIES)
65 unset(DPDK_LINK_FLAGS)
66 message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
67 include_directories (${DPDK_INCLUDE_DIR})
69 if(DPDK_IS_SHARED_LIB)
70 get_filename_component(DPDK_LIB_DIR ${DPDK_SHLIB} DIRECTORY)
71 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
72 list(APPEND DPDK_LINK_LIBRARIES ${DPDK_SHLIB})
74 get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
75 string_append(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR}")
76 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
79 ##############################################################################
81 ##############################################################################
82 vpp_plugin_find_library(dpdk NUMA_LIB "numa")
83 list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
85 ##############################################################################
87 ##############################################################################
88 if(DPDK_RTE_LIBRTE_MLX4_PMD OR DPDK_RTE_LIBRTE_MLX5_PMD)
89 if (DPDK_RTE_IBVERBS_LINK_DLOPEN)
90 message(STATUS "DPDK depends on libmnl (Mellanox PMD requirement)")
91 vpp_plugin_find_library(dpdk MNL_LIB "mnl")
92 list(APPEND DPDK_LINK_LIBRARIES "${MNL_LIB}")
94 message(WARNING "EXPERIMENTAL: DPDK plugin without dlopen mode")
95 vpp_plugin_find_library(dpdk IBVERBS_LIB "libibverbs.a")
96 vpp_plugin_find_library(dpdk MLX5_LIB "libmlx5.a")
97 vpp_plugin_find_library(dpdk MLX4_LIB "libmlx4.a")
98 vpp_plugin_find_library(dpdk CCAN_LIB "libccan.a")
99 vpp_plugin_find_library(dpdk RDMA_UTIL_LIB "rdma_util")
100 string_append(DPDK_LINK_FLAGS "-Wl,--whole-archive,${IBVERBS_LIB},${MLX5_LIB},${MLX4_LIB},${CCAN_LIB},${RDMA_UTIL_LIB},--no-whole-archive")
104 ##############################################################################
106 ##############################################################################
108 if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
109 set(DPDK_CRYPTODEV_SOURCE cryptodev_dp_api)
111 set(DPDK_CRYPTODEV_SOURCE cryptodev)
131 cryptodev/${DPDK_CRYPTODEV_SOURCE}.c
149 ${DPDK_LINK_LIBRARIES}