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 HINTS
18 ${DPDK_INCLUDE_DIR_HINT})
19 find_library(DPDK_LIB NAMES libdpdk.a HINTS ${DPDK_LIB_DIR_HINT})
21 ##############################################################################
23 ##############################################################################
24 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_vars.c
27 #include <rte_version.h>
30 printf(\"VERSION=%s\\n\", strchr(rte_version(), ' ') + 1);
31 printf(\"RTE_PKTMBUF_HEADROOM=%u\\n\", RTE_PKTMBUF_HEADROOM);
32 #ifdef RTE_LIBRTE_PMD_AESNI_MB
33 printf(\"RTE_LIBRTE_PMD_AESNI_MB=%u\\n\", RTE_LIBRTE_PMD_AESNI_MB);
35 #ifdef RTE_LIBRTE_PMD_AESNI_GCM
36 printf(\"RTE_LIBRTE_PMD_AESNI_GCM=%u\\n\", RTE_LIBRTE_PMD_AESNI_GCM);
42 try_compile(DPDK_VARS_COMPILED
43 ${CMAKE_CURRENT_BINARY_DIR}
44 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_vars.c
46 -DINCLUDE_DIRECTORIES=${DPDK_INCLUDE_DIR}
47 COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_vars.bin
50 if(DPDK_VARS_COMPILED)
52 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
53 COMMAND ./dpdk_vars.bin
54 OUTPUT_VARIABLE DPDK_VARS
55 OUTPUT_STRIP_TRAILING_WHITESPACE
57 string(REPLACE "\n" ";" DPDK_VARS ${DPDK_VARS})
58 foreach(v ${DPDK_VARS})
59 string(REPLACE "=" ";" v ${v})
62 set(DPDK_${name} ${value})
67 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_vars.c
68 ${CMAKE_CURRENT_BINARY_DIR}/dpdk_vars.bin
71 if(NOT ${DPDK_RTE_PKTMBUF_HEADROOM} EQUAL ${PRE_DATA_SIZE})
74 "DPDK RTE_PKTMBUF_HEADROOM (${DPDK_RTE_PKTMBUF_HEADROOM}) "
75 "must be equal to PRE_DATA_SIZE (${PRE_DATA_SIZE})"
79 ##############################################################################
81 ##############################################################################
82 if(DPDK_INCLUDE_DIR AND DPDK_LIB)
83 include_directories (${DPDK_INCLUDE_DIR})
84 add_vpp_plugin(dpdk_plugin
106 vpp_library_set_multiarch_sources(dpdk_plugin
112 message("-- Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
113 get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
114 set(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR} -Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
115 if(DPDK_RTE_LIBRTE_PMD_AESNI_MB OR DPDK_RTE_LIBRTE_PMD_AESNI_GCM)
116 set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
117 message("-- DPDK depends on IPSec MB library")
119 set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lnuma")
120 set_target_properties(dpdk_plugin PROPERTIES LINK_FLAGS "${DPDK_LINK_FLAGS}")
122 message("-- DPDK not found - dpdk_plugin disabled")