dpdk: rebase cryptodev engine for dpdk 20.11
[vpp.git] / src / plugins / dpdk / CMakeLists.txt
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:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
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.
13
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")
19
20 if (NOT DPDK_INCLUDE_DIR)
21   message(WARNING "-- DPDK headers not found - dpdk plugin disabled")
22   return()
23 endif()
24
25 if (NOT DPDK_LIB)
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")
29 endif()
30
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)
37
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}")
41     list(GET v 0 name)
42     list(GET v 1 value)
43     set(DPDK_${name} ${value})
44   endif()
45 endforeach()
46
47 set(DPDK_VERSION
48     "${DPDK_RTE_VER_YEAR}.${DPDK_RTE_VER_MONTH}.${DPDK_RTE_VER_MINOR}")
49
50 ##############################################################################
51 # verify headroom size
52 ##############################################################################
53 if(NOT ${DPDK_RTE_PKTMBUF_HEADROOM} EQUAL ${PRE_DATA_SIZE})
54   message(
55     FATAL_ERROR
56     "DPDK RTE_PKTMBUF_HEADROOM (${DPDK_RTE_PKTMBUF_HEADROOM}) "
57      "must be equal to PRE_DATA_SIZE (${PRE_DATA_SIZE})"
58   )
59 endif()
60
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})
68
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})
73 else()
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")
77 endif()
78
79 ##############################################################################
80 # libnuma
81 ##############################################################################
82 vpp_plugin_find_library(dpdk NUMA_LIB "numa")
83 list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
84
85 ##############################################################################
86 # Mellanox libraries
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}")
93   else()
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")
101   endif()
102 endif()
103
104 ##############################################################################
105 # DPDK plugin
106 ##############################################################################
107
108 if (${DPDK_VERSION} VERSION_GREATER_EQUAL "20.8.0")
109   set(DPDK_CRYPTODEV_SOURCE cryptodev_dp_api)
110 else ()
111   set(DPDK_CRYPTODEV_SOURCE cryptodev)
112 endif ()
113
114 add_vpp_plugin(dpdk
115   SOURCES
116   buffer.c
117   main.c
118   thread.c
119   device/cli.c
120   device/common.c
121   device/device.c
122   device/flow.c
123   device/format.c
124   device/init.c
125   device/node.c
126   ipsec/cli.c
127   ipsec/crypto_node.c
128   ipsec/esp_decrypt.c
129   ipsec/esp_encrypt.c
130   ipsec/ipsec.c
131   cryptodev/${DPDK_CRYPTODEV_SOURCE}.c
132
133   MULTIARCH_SOURCES
134   buffer.c
135   device/device.c
136   device/node.c
137   ipsec/crypto_node.c
138   ipsec/esp_decrypt.c
139   ipsec/esp_encrypt.c
140
141   INSTALL_HEADERS
142   device/dpdk.h
143   ipsec/ipsec.h
144
145   LINK_FLAGS
146   "${DPDK_LINK_FLAGS}"
147
148   LINK_LIBRARIES
149   ${DPDK_LINK_LIBRARIES}
150
151   COMPONENT
152   vpp-plugin-dpdk
153 )