1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
from ipaddress import IPv4Address, AddressValueError
from vpp_object import VppObject
from vpp_papi import VppEnum
class AuthMethod:
v = {"rsa-sig": 1, "shared-key": 2}
@staticmethod
def value(key):
return AuthMethod.v[key]
class IDType:
v = {"ip4-addr": 1, "fqdn": 2, "ip6-addr": 5}
@staticmethod
def value(key):
return IDType.v[key]
class Profile(VppObject):
"""IKEv2 profile"""
def __init__(self, test, profile_name):
self.test = test
self.vapi = test.vapi
self.profile_name = profile_name
self.udp_encap = False
self.natt = True
def disable_natt(self):
self.natt = False
def add_auth(self, method, data, is_hex=False):
if isinstance(method, int):
m = method
elif isinstance(method, str):
m = AuthMethod.value(method)
else:
raise Exception("unsupported type {}".format(method))
self.auth = {"auth_method": m, "data": data, "is_hex": is_hex}
def add_local_id(self, id_type, data):
if isinstance# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Scripts require non-POSIX parts of bash
SHELL := /bin/bash
DPDK_BUILD_DIR ?= $(CURDIR)/_build
DPDK_INSTALL_DIR ?= $(CURDIR)/_install
DPDK_PKTMBUF_HEADROOM ?= 128
DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
DPDK_DEBUG ?= n
DPDK_CRYPTO_SW_PMD ?= n
DPDK_MLX5_PMD ?= n
B := $(DPDK_BUILD_DIR)
I := $(DPDK_INSTALL_DIR)
DPDK_VERSION ?= 17.02
PKG_SUFFIX ?= vpp2
DPDK_BASE_URL ?= http://fast.dpdk.org/rel
DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.xz
DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
DPDK_16.11_TARBALL_MD5_CKSUM := 06c1c577795360719d0b4fafaeee21e9
DPDK_17.02_TARBALL_MD5_CKSUM := 6b9f7387c35641f4e8dbba3e528f2376
DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
ifeq ($(DPDK_CRYPTO_SW_PMD),y)
AESNIMB_LIB_TARBALL := v0.44-gcm.2.tar.gz
AESNIMB_LIB_TARBALL_URL := http://github.com/01org/intel-ipsec-mb/archive/$(AESNIMB_LIB_TARBALL)
AESNIMB_LIB_SOURCE := $(B)/intel-ipsec-mb-0.44-gcm.2
ISA_L_CRYPTO_LIB_TARBALL := isa_l_crypto.tar.gz
ISA_L_CRYPTO_LIB_TARBALL_URL := http://github.com/01org/isa-l_crypto/archive/master.tar.gz
ISA_L_CRYPTO_LIB_SOURCE := $(B)/isa-l_crypto-master
endif
ifneq (,$(findstring clang,$(CC)))
DPDK_CC=clang
else ifneq (,$(findstring icc,$(CC)))
DPDK_CC=icc
else
DPDK_CC=gcc
endif
##############################################################################
# Intel x86_64
##############################################################################
ifeq ($(shell uname -m),x86_64)
DPDK_TARGET ?= x86_64-native-linuxapp-$(DPDK_CC)
DPDK_MACHINE ?= nhm
DPDK_TUNE ?= core-avx2
##############################################################################
# Cavium ThunderX
##############################################################################
else ifneq (,$(findstring thunder,$(shell cat /sys/bus/pci/devices/0000:00:01.0/uevent | grep cavium)))
export CROSS=""
DPDK_TARGET ?= arm64-thunderx-linuxapp-$(DPDK_CC)
DPDK_MACHINE ?= thunderx
DPDK_TUNE ?= generic
##############################################################################
# Unknown platofrm
##############################################################################
else
$(error unknown platform)
endif
JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
# compiler/linker custom arguments
DPDK_CPU_CFLAGS := -pie -fPIC
DPDK_EXTRA_LDFLAGS := -g
ifeq ($(DPDK_DEBUG),n)
DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE)
else
DPDK_EXTRA_CFLAGS := -g -O0
endif
ifeq ($(DPDK_CRYPTO_SW_PMD),y)
DPDK_EXTRA_CFLAGS += -I$(I)/include
DPDK_EXTRA_LDFLAGS += -L$(I)/lib
DPDK_MAKE_EXTRA_ARGS += AESNI_MULTI_BUFFER_LIB_PATH=$(AESNIMB_LIB_SOURCE)
endif
# assemble DPDK make arguments
DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
T=$(DPDK_TARGET) \
RTE_CONFIG_TEMPLATE=../custom-config \
EXTRA_CFLAGS="$(DPDK_EXTRA_CFLAGS)" \
EXTRA_LDFLAGS="$(DPDK_EXTRA_LDFLAGS)" \
CPU_CFLAGS="$(DPDK_CPU_CFLAGS)" \
DESTDIR=$(I) \
$(DPDK_MAKE_EXTRA_ARGS)
DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
define set
@if grep -q CONFIG_$1 $@ ; \
then sed -i -e 's/.*\(CONFIG_$1=\).*/\1$2/' $@ ; \
else echo CONFIG_$1=$2 >> $@ ; \
fi
endef
all: build
$(B)/custom-config: $(B)/.patch.ok Makefile
@echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
@cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
$(call set,RTE_MACHINE,$(DPDK_MACHINE))
@# modify options
$(call set,RTE_MAX_LCORE,256)
$(call set,RTE_PKTMBUF_HEADROOM,$(DPDK_PKTMBUF_HEADROOM))
$(call set,RTE_LIBEAL_USE_HPET,y)
$(call set,RTE_BUILD_COMBINE_LIBS,y)
$(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
$(call set,RTE_PCI_CONFIG,y)
$(call set,RTE_PCI_EXTENDED_TAG,"on")
$(call set,RTE_PCI_MAX_READ_REQUEST_SIZE,4096)
@# enable debug init for device drivers
$(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_E1000_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_VIRTIO_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_PMD_BOND,y)
$(call set,RTE_LIBRTE_IP_FRAG,y)
$(call set,RTE_LIBRTE_PMD_QAT,y)
$(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_SW_PMD))
$(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_SW_PMD))
$(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD))
@# not needed
$(call set,RTE_LIBRTE_TIMER,n)
$(call set,RTE_LIBRTE_CFGFILE,n)
$(call set,RTE_LIBRTE_LPM,n)
$(call set,RTE_LIBRTE_ACL,n)
$(call set,RTE_LIBRTE_POWER,n)
$(call set,RTE_LIBRTE_DISTRIBUTOR,n)
$(call set,RTE_LIBRTE_REORDER,n)
$(call set,RTE_LIBRTE_PORT,n)
$(call set,RTE_LIBRTE_TABLE,n)
$(call set,RTE_LIBRTE_PIPELINE,n)
$(call set,RTE_KNI_KMOD,n)
$(call set,RTE_EAL_IGB_UIO,n)
@rm -f .config.ok
$(CURDIR)/$(DPDK_TARBALL):
@if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
fi
@rm -f $(B)/.download.ok
$(CURDIR)/$(AESNIMB_LIB_TARBALL):
@if [ -e $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) ] ; \
then cp $(DPDK_DOWNLOAD_DIR)/$(AESNIMB_LIB_TARBALL) $(CURDIR) ; \
else curl -o $@ -LO $(AESNIMB_LIB_TARBALL_URL) ; \
fi
$(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL):
@if [ -e $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) ] ; \
then cp $(DPDK_DOWNLOAD_DIR)/$(ISA_L_CRYPTO_LIB_TARBALL) $(CURDIR) ; \
else curl -o $@ -LO $(ISA_L_CRYPTO_LIB_TARBALL_URL) ; \
fi
DPDK_DOWNLOADS = $(CURDIR)/$(DPDK_TARBALL)
ifeq ($(DPDK_CRYPTO_SW_PMD),y)
DPDK_DOWNLOADS += $(CURDIR)/$(AESNIMB_LIB_TARBALL)
DPDK_DOWNLOADS += $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
endif
$(B)/.download.ok: $(DPDK_DOWNLOADS)
@mkdir -p $(B)
@openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
@([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
( echo "Bad Checksum! Please remove $< and retry" && \
rm $(B)/$(DPDK_TARBALL).md5sum && false ))
@touch $@
.PHONY: download
download: $(B)/.download.ok
$(B)/.extract.ok: $(B)/.download.ok
@echo --- extracting $(DPDK_TARBALL) ---
@tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL)
ifeq ($(DPDK_CRYPTO_SW_PMD),y)
@echo --- extracting $(AESNIMB_LIB_TARBALL) ---
@tar --directory $(B) --extract --file $(CURDIR)/$(AESNIMB_LIB_TARBALL)
@echo --- extracting $(ISA_L_CRYPTO_LIB_TARBALL) ---
@tar --directory $(B) --extract --file $(CURDIR)/$(ISA_L_CRYPTO_LIB_TARBALL)
endif
@touch $@
.PHONY: extract
extract: $(B)/.extract.ok
$(B)/.patch.ok: $(B)/.extract.ok
ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
@echo --- patching ---
@for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
echo Applying patch: $$(basename $$f) ; \
patch -p1 -d $(DPDK_SOURCE) < $$f ; \
done
endif
@touch $@
.PHONY: patch
patch: $(B)/.patch.ok
$(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
@make $(DPDK_MAKE_ARGS) config
@touch $@
.PHONY: config
config: $(B)/.config.ok
$(B)/.build.ok: $(DPDK_SOURCE_FILES)
@if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
ifeq ($(DPDK_CRYPTO_SW_PMD),y)
# Build IPsec_MB library
mkdir -p $(I)/lib/
make -C $(AESNIMB_LIB_SOURCE) -j NO_GCM=y
cp $(AESNIMB_LIB_SOURCE)/lib |