misc: deprecate dpdk hqos
[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
35 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_config.h rte_config)
36 file(STRINGS ${DPDK_INCLUDE_DIR}/rte_version.h rte_version)
37
38 foreach(l ${rte_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 # AESNI libraries
87 ##############################################################################
88 if(DPDK_RTE_LIBRTE_PMD_AESNI_MB OR DPDK_RTE_LIBRTE_PMD_AESNI_GCM)
89   if(DPDK_IS_SHARED_LIB)
90     vpp_plugin_find_library(dpdk IPSECMB_LIB "libIPSec_MB.so")
91     list(APPEND DPDK_LINK_LIBRARIES "${IPSECMB_LIB}")
92   else()
93     vpp_plugin_find_library(dpdk IPSECMB_LIB "libIPSec_MB.a")
94     get_filename_component(IPSECMB_LIB_DIR ${IPSECMB_LIB} DIRECTORY)
95     string_append(DPDK_LINK_FLAGS "-L${IPSECMB_LIB_DIR}")
96     string_append(DPDK_LINK_FLAGS "-Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
97   endif()
98 endif()
99
100 ##############################################################################
101 # Mellanox libraries
102 ##############################################################################
103 if(DPDK_RTE_LIBRTE_MLX4_PMD OR DPDK_RTE_LIBRTE_MLX5_PMD)
104   vpp_plugin_find_library(dpdk MNL_LIB "mnl")
105   list(APPEND DPDK_LINK_LIBRARIES "${MNL_LIB}")
106   if (DPDK_RTE_IBVERBS_LINK_DLOPEN)
107     message(STATUS "DPDK depends on libmnl (Mellanox PMD requirement)")
108   else()
109     message(WARNING "unsupported DPDK configuration: DPDK Mellanox PMD requires RTE_IBVERBS_LINK_DLOPEN")
110   endif()
111 endif()
112
113 ##############################################################################
114 # DPDK plugin
115 ##############################################################################
116 add_vpp_plugin(dpdk
117   SOURCES
118   buffer.c
119   main.c
120   thread.c
121   device/cli.c
122   device/common.c
123   device/device.c
124   device/flow.c
125   device/format.c
126   device/init.c
127   device/node.c
128   ipsec/cli.c
129   ipsec/crypto_node.c
130   ipsec/esp_decrypt.c
131   ipsec/esp_encrypt.c
132   ipsec/ipsec.c
133
134   MULTIARCH_SOURCES
135   buffer.c
136   device/device.c
137   device/node.c
138   ipsec/crypto_node.c
139   ipsec/esp_decrypt.c
140   ipsec/esp_encrypt.c
141
142   INSTALL_HEADERS
143   device/dpdk.h
144   ipsec/ipsec.h
145
146   LINK_FLAGS
147   "${DPDK_LINK_FLAGS}"
148
149   LINK_LIBRARIES
150   ${DPDK_LINK_LIBRARIES}
151
152   COMPONENT
153   vpp-plugin-dpdk
154 )
155