Skip to content

Commit 73b60f3

Browse files
committed
Upgrade DPDK to 20.11
- address memseg and mbuf changes - move to meson/ninja build system Signed-off-by: Saikrishna Edupuganti <[email protected]>
1 parent ae52fc5 commit 73b60f3

File tree

8 files changed

+29
-87
lines changed

8 files changed

+29
-87
lines changed

bessctl/conf/port/vhost/launch_vm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def run_forward(vm_id, num_nics):
175175
nics += ' 00:1{nic}.0'.format(nic=i)
176176

177177
scp(vm_id, os.path.join(bess_dir, 'bin/dpdk-devbind.py'), '')
178-
scp(vm_id, os.path.join(bess_dir, 'deps/dpdk-19.11.4/build/app/testpmd'), '')
178+
scp(vm_id, os.path.join(bess_dir, 'deps/dpdk-20.11/build/app/dpdk-testpmd'), '')
179179

180180
# virtio-pci devices should not be bound to any driver
181181
cmd = ssh_cmd(vm_id, 'sudo ./dpdk-devbind.py -u %s' % nics)

build.py

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ def cmd(cmd, quiet=False, shell=False):
8989
DEPS_DIR = '%s/deps' % BESS_DIR
9090

9191
DPDK_URL = 'https://fast.dpdk.org/rel'
92-
DPDK_VER = 'dpdk-19.11.4'
92+
DPDK_VER = 'dpdk-20.11'
9393
DPDK_TARGET = 'x86_64-native-linuxapp-gcc'
9494

9595
kernel_release = cmd('uname -r', quiet=True).strip()
9696

9797
DPDK_DIR = '%s/%s' % (DEPS_DIR, DPDK_VER)
98-
DPDK_CFLAGS = '"-g -w"'
99-
DPDK_CONFIG = '%s/build/.config' % DPDK_DIR
98+
DPDK_BUILD = '%s/build' % DPDK_DIR
10099

101100
extra_libs = set()
102101
cxx_flags = []
@@ -213,46 +212,6 @@ def is_kernel_header_installed():
213212
return os.path.isdir("/lib/modules/%s/build" % kernel_release)
214213

215214

216-
def check_kernel_headers():
217-
# If kernel header is not available, do not attempt to build
218-
# any components that require kernel.
219-
if not is_kernel_header_installed():
220-
set_config(DPDK_CONFIG, 'CONFIG_RTE_EAL_IGB_UIO', 'n')
221-
set_config(DPDK_CONFIG, 'CONFIG_RTE_KNI_KMOD', 'n')
222-
set_config(DPDK_CONFIG, 'CONFIG_RTE_LIBRTE_KNI', 'n')
223-
set_config(DPDK_CONFIG, 'CONFIG_RTE_LIBRTE_PMD_KNI', 'n')
224-
225-
226-
def check_bnx():
227-
if check_header('zlib.h', 'gcc') and check_c_lib('z'):
228-
extra_libs.add('z')
229-
else:
230-
print(' - "zlib1g-dev" is not available. Disabling BNX2X PMD...')
231-
set_config(DPDK_CONFIG, 'CONFIG_RTE_LIBRTE_BNX2X_PMD', 'n')
232-
233-
234-
def check_mlx():
235-
if check_header('infiniband/ib.h', 'gcc') and check_c_lib('mlx4') and \
236-
check_c_lib('mlx5'):
237-
extra_libs.add('ibverbs')
238-
extra_libs.add('mlx4')
239-
extra_libs.add('mlx5')
240-
else:
241-
print(' - "Mellanox OFED" is not available. '
242-
'Disabling MLX4 and MLX5 PMDs...')
243-
if check_header('infiniband/verbs.h', 'gcc'):
244-
print(' NOTE: "libibverbs-dev" does exist, but it does not '
245-
'work with MLX PMDs. Instead download OFED from '
246-
'http://www.melloanox.com')
247-
set_config(DPDK_CONFIG, 'CONFIG_RTE_LIBRTE_MLX4_PMD', 'n')
248-
set_config(DPDK_CONFIG, 'CONFIG_RTE_LIBRTE_MLX5_PMD', 'n')
249-
250-
251-
def generate_dpdk_extra_mk():
252-
with open('core/extra.dpdk.mk', 'w') as fp:
253-
fp.write('LIBS += %s\n' % ' '.join(['-l' + lib for lib in extra_libs]))
254-
255-
256215
def find_current_plugins():
257216
"return list of existing plugins"
258217
result = []
@@ -293,16 +252,14 @@ def download_dpdk(quiet=False):
293252

294253
def configure_dpdk():
295254
print('Configuring DPDK...')
296-
cmd('make -C %s config T=%s' % (DPDK_DIR, DPDK_TARGET))
297-
298-
check_kernel_headers()
299-
check_mlx()
300-
generate_dpdk_extra_mk()
255+
meson_opts = '--buildtype=debugoptimized'
301256

302257
arch = os.getenv('CPU')
303258
if arch:
304259
print(' - Building DPDK with -march=%s' % arch)
305-
set_config(DPDK_CONFIG, "CONFIG_RTE_MACHINE", arch)
260+
meson_opts += ' -Dmachine=%s' % arch
261+
262+
cmd('meson %s %s %s' % (meson_opts, DPDK_BUILD, DPDK_DIR))
306263

307264

308265
def makeflags():
@@ -342,10 +299,7 @@ def build_dpdk():
342299
cmd('patch -d %s -N -p1 < %s || true' % (DPDK_DIR, f), shell=True)
343300

344301
print('Building DPDK...')
345-
nproc = int(cmd('nproc', quiet=True))
346-
cmd('make -C %s EXTRA_CFLAGS=%s %s' % (DPDK_DIR,
347-
DPDK_CFLAGS,
348-
makeflags()))
302+
cmd('ninja -C %s install' % DPDK_BUILD)
349303

350304

351305
def generate_protobuf_files():

container_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import re
4040
import argparse
4141

42-
IMAGE = 'nefelinetworks/bess_build:latest' + os.getenv('TAG_SUFFIX', '')
42+
IMAGE = 'nefelinetworks/bess_build:' + os.getenv('TAG_SUFFIX', 'latest')
4343
BESS_DIR_HOST = os.path.dirname(os.path.abspath(__file__))
4444
BESS_DIR_CONTAINER = '/build/bess'
4545
BUILD_SCRIPT = './build.py'

core/Makefile

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,13 @@ endif
6161

6262
HAS_PKG_CONFIG := $(shell command -v $(PKG_CONFIG) 2>&1 >/dev/null && echo yes || echo no)
6363

64-
RTE_SDK ?= $(abspath ../deps/dpdk-19.11.4)
65-
RTE_TARGET ?= $(shell uname -m)-native-linuxapp-gcc
66-
DPDK_LIB ?= dpdk
67-
68-
ifneq ($(wildcard $(RTE_SDK)/$(RTE_TARGET)/*),)
69-
DPDK_INC_DIR := $(RTE_SDK)/$(RTE_TARGET)/include
70-
DPDK_LIB_DIR := $(RTE_SDK)/$(RTE_TARGET)/build/lib
71-
else ifneq ($(wildcard $(RTE_SDK)/build/*),)
72-
# if the user didn't do "make install" for DPDK
73-
DPDK_INC_DIR := $(RTE_SDK)/build/include
74-
DPDK_LIB_DIR := $(RTE_SDK)/build/lib
75-
else ifneq ($(MAKECMDGOALS),clean)
76-
$(error DPDK is not available. Make sure $(abspath $(RTE_SDK)) is available and built)
77-
endif
78-
7964
# We always want these libraries to be dynamically linked even when the
8065
# user requests a static build.
8166
ALWAYS_DYN_LIBS := -lpthread -ldl
8267
# These libraries are not supported by pkg-config.
8368
ALWAYS_LIBS := -lpcap -lgflags -lnuma
8469
# If pkg-config is available, we just need a list of the dependecies.
85-
PKG_CONFIG_DEPS := libglog protobuf grpc++ libunwind zlib
70+
PKG_CONFIG_DEPS := libdpdk libglog protobuf grpc++ libunwind zlib
8671
# If pkg-config is not available, we need to list the libs we depend on.
8772
NO_PKG_CONFIG_LIBS := -lglog -lgflags -lprotobuf -lgrpc++ -lunwind -lz
8873
# If pkg-config is not available and we're static linking, we also need
@@ -110,7 +95,7 @@ endif
11095
COREDIR := $(abspath .)
11196
CPU ?= native
11297
CXXFLAGS += -std=c++17 -g3 -ggdb3 -march=$(CPU) \
113-
-isystem $(DPDK_INC_DIR) -isystem $(COREDIR) \
98+
-isystem $(COREDIR) \
11499
-isystem $(dir $<).. -isystem $(COREDIR)/modules \
115100
-D_GNU_SOURCE \
116101
-Werror -Wall -Wextra -Wcast-align -Wno-error=deprecated-declarations \
@@ -133,7 +118,7 @@ ifeq "$(shell expr $(CXXCOMPILER) = g++)" "1"
133118
CXXFLAGS += -fno-gnu-unique
134119
endif
135120

136-
LDFLAGS += -rdynamic -L$(DPDK_LIB_DIR) -Wl,-rpath=$(DPDK_LIB_DIR) -pthread
121+
LDFLAGS += -rdynamic
137122
ifdef BESS_LINK_DYNAMIC
138123
LIBS_ALL_SHARED = -Wl,-call_shared
139124
LIBS_DL_SHARED =
@@ -158,7 +143,6 @@ else # Used static libraries
158143
endif
159144

160145
LIBS += -Wl,-non_shared \
161-
-Wl,--whole-archive -l$(DPDK_LIB) -Wl,--no-whole-archive \
162146
$(LIBS_ALL_SHARED) \
163147
$(PKG_LIBS) $(ALWAYS_LIBS) \
164148
$(LIBS_DL_SHARED) \

core/packet.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,14 @@ class alignas(64) Packet {
261261
const uint16_t buf_len_;
262262

263263
// offset 56:
264-
uint64_t _dummy6_; // rte_mbuf.timestamp
265-
266-
// 2nd cacheline - fields only used in slow path or on TX --------------
267-
// offset 64:
268-
uint64_t _dummy7_; // rte_mbuf.userdata
269-
270-
// offset 72:
271264
struct rte_mempool *pool_; // Pool from which mbuf was allocated.
272265

273-
// offset 80:
266+
// offset 60:
274267
Packet *next_; // Next segment. nullptr if not scattered.
275268

276269
// offset 88:
277270
uint64_t _dummy8; // rte_mbuf.tx_offload
271+
// TODO: Add struct rte_mbuf_ext_shared_info *shinfo;
278272
uint16_t _dummy9; // rte_mbuf.priv_size
279273
uint16_t _dummy10; // rte_mbuf.timesync
280274
uint32_t _dummy11; // rte_mbuf.seqn

core/packet_pool.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ DpdkPacketPool::DpdkPacketPool(size_t capacity, int socket_id)
241241

242242
static Packet *paddr_to_snb_memchunk(struct rte_mempool_memhdr *chunk,
243243
phys_addr_t paddr) {
244-
if (chunk->phys_addr == RTE_BAD_IOVA) {
244+
if (chunk->iova == RTE_BAD_IOVA) {
245245
return nullptr;
246246
}
247247

248-
if (chunk->phys_addr <= paddr && paddr < chunk->phys_addr + chunk->len) {
248+
if (chunk->iova <= paddr && paddr < chunk->iova + chunk->len) {
249249
uintptr_t vaddr;
250250

251-
vaddr = (uintptr_t)chunk->addr + paddr - chunk->phys_addr;
251+
vaddr = (uintptr_t)chunk->addr + paddr - chunk->iova;
252252
return reinterpret_cast<Packet *>(vaddr);
253253
}
254254

env/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ARG BESS_DPDK_BRANCH=master
2929
RUN cd /build/bess && \
3030
curl -s -L https://github.com/NetSys/bess/archive/${BESS_DPDK_BRANCH}.tar.gz | tar zx --strip-components=1 && \
3131
./build.py dpdk && \
32-
cp /build/bess/deps/dpdk-19.11.4/build/app/testpmd /usr/local/bin/ && \
32+
cp /build/bess/deps/dpdk-20.11/build/app/dpdk-testpmd /usr/local/bin/ && \
3333
rm -rf /build/bess
3434

3535
ENV CCACHE_DIR=/tmp/ccache

env/build-dep.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@
2323
- libgflags-dev
2424
- libgoogle-glog-dev
2525
- libgtest-dev
26-
- python
26+
- python3
27+
- python3-pip
28+
- python3-setuptools
2729
- pkg-config
2830

31+
- name: Install DPDK build system
32+
become: true
33+
pip:
34+
name:
35+
- meson
36+
- ninja
37+
executable: pip3
38+
2939
# pre-packaged meat for Bionic Beaver or higher
3040
- name: Install gRPC and its requirements (apt)
3141
apt: name={{item}}

0 commit comments

Comments
 (0)