Skip to content

Commit 30a5ebf

Browse files
sangjinhanapanda
authored andcommitted
Update DPDK version to 17.05 (#507)
* Update DPDK to 17.05 * Update outdated comments * Apply DPDK 17.05 internal change * Apply rte_mbuf layout changes * Add new and delete operators for 64B alignment * Fix layout issue in DPDK on 32bit systems * Set default decimal points for percentage * Add static assertions for rte_mbuf layout check
1 parent 47ee7c9 commit 30a5ebf

9 files changed

Lines changed: 203 additions & 182 deletions

File tree

.codecov.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
codecov:
22
branch: master # base branch for delta computation
33

4-
coverage:
5-
precision: 0
6-
round: nearest
7-
84
ignore: # files and folders to be ignored
95
- "*_test.cc$"
106
- "*_bench.cc$"

build.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
DEPS_DIR = '%s/deps' % BESS_DIR
1414

1515
DPDK_REPO = 'http://dpdk.org/browse/dpdk/snapshot'
16-
DPDK_VER = 'dpdk-17.02'
16+
DPDK_VER = 'dpdk-17.05'
1717

1818
arch = subprocess.check_output('uname -m', shell=True).strip()
1919
if arch == 'x86_64':
@@ -37,10 +37,8 @@
3737

3838

3939
def cmd(cmd):
40-
proc = subprocess.Popen(cmd,
41-
stdout=subprocess.PIPE,
42-
stderr=subprocess.STDOUT,
43-
shell=True)
40+
proc = subprocess.Popen(
41+
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
4442

4543
# err should be None
4644
out, err = proc.communicate()
@@ -53,10 +51,8 @@ def cmd(cmd):
5351

5452
def cmd_success(cmd):
5553
try:
56-
subprocess.check_call(cmd,
57-
stdout=subprocess.PIPE,
58-
stderr=subprocess.STDOUT,
59-
shell=True)
54+
subprocess.check_call(
55+
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
6056
return True
6157
except subprocess.CalledProcessError:
6258
return False
@@ -111,8 +107,7 @@ def check_c_lib(lib):
111107

112108
def required(header_file, lib_name, compiler):
113109
if not check_header(header_file, compiler):
114-
print('Error - #include <%s> failed. '
115-
'Did you install "%s" package?'
110+
print('Error - #include <%s> failed. Did you install "%s" package?'
116111
% (header_file, lib_name), file=sys.stderr)
117112
sys.exit(1)
118113

@@ -155,8 +150,7 @@ def check_bnx():
155150
global extra_libs
156151
extra_libs.add('z')
157152
else:
158-
print(' - "zlib1g-dev" is not available. '
159-
'Disabling BNX2X PMD...')
153+
print(' - "zlib1g-dev" is not available. Disabling BNX2X PMD...')
160154
set_config(DPDK_FINAL_CONFIG, 'CONFIG_RTE_LIBRTE_BNX2X_PMD', 'n')
161155

162156

@@ -180,8 +174,8 @@ def generate_dpdk_extra_mk():
180174
global extra_libs
181175

182176
with open('core/extra.dpdk.mk', 'w') as fp:
183-
fp.write('LIBS += %s\n' %
184-
' '.join(map(lambda lib: '-l' + lib, extra_libs)))
177+
fp.write(
178+
'LIBS += %s\n' % ' '.join(map(lambda lib: '-l' + lib, extra_libs)))
185179

186180

187181
def generate_extra_mk():
@@ -227,8 +221,8 @@ def build_dpdk():
227221
try:
228222
print('Decompressing DPDK...')
229223
cmd('mkdir -p %s' % DPDK_DIR)
230-
cmd('tar zxf %s -C %s --strip-components 1' %
231-
(DPDK_FILE, DPDK_DIR))
224+
cmd('tar zxf %s -C %s --strip-components 1' % (DPDK_FILE,
225+
DPDK_DIR))
232226
except:
233227
cmd('rm -rf %s' % (DPDK_DIR))
234228
raise
@@ -261,7 +255,7 @@ def build_bess():
261255

262256
print('Building BESS daemon...')
263257
cmd('bin/bessctl daemon stop 2> /dev/null || true')
264-
cmd('rm -f core/bessd') # force relink as DPDK might have been rebuilt
258+
cmd('rm -f core/bessd') # force relink as DPDK might have been rebuilt
265259
cmd('make -C core -j`nproc`')
266260
cmd('ln -f -s ../core/bessd bin/bessd')
267261

@@ -319,11 +313,18 @@ def update_benchmark_path(path):
319313
def main():
320314
os.chdir(BESS_DIR)
321315
parser = argparse.ArgumentParser(description='Build BESS')
322-
parser.add_argument('action', metavar='action', nargs='?', default='all',
323-
help='Action is one of all, dpdk, bess, kmod, clean'
324-
' dist_clean, help')
325-
parser.add_argument('--with-benchmark', dest='benchmark_path', nargs=1,
326-
help='Location of benchmark library')
316+
parser.add_argument(
317+
'action',
318+
metavar='action',
319+
nargs='?',
320+
default='all',
321+
help='Action is one of all, dpdk, bess, kmod, clean'
322+
' dist_clean, help')
323+
parser.add_argument(
324+
'--with-benchmark',
325+
dest='benchmark_path',
326+
nargs=1,
327+
help='Location of benchmark library')
327328
args = parser.parse_args()
328329

329330
if args.benchmark_path:

core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ifeq "$(shell expr $(CXXCOMPILER) = g++ \& $(CXXVERSION) \< 40800)" "1"
2525
$(error g++ 4.8 or higher is required)
2626
endif
2727

28-
RTE_SDK ?= $(abspath ../deps/dpdk-17.02)
28+
RTE_SDK ?= $(abspath ../deps/dpdk-17.05)
2929
RTE_TARGET ?= $(shell uname -m)-native-linuxapp-gcc
3030
DPDK_LIB ?= dpdk
3131

core/drivers/pmd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static CommandResponse find_dpdk_port_by_id(dpdk_port_t port_id,
8181
if (port_id >= RTE_MAX_ETHPORTS) {
8282
return CommandFailure(EINVAL, "Invalid port id %d", port_id);
8383
}
84-
if (!rte_eth_devices[port_id].attached) {
84+
if (rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED) {
8585
return CommandFailure(ENODEV, "Port id %d is not available", port_id);
8686
}
8787

core/packet.cc

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
namespace bess {
1717

18-
Packet pframe_template;
19-
2018
static struct rte_mempool *pframe_pool[RTE_MAX_NUMA_NODES];
2119

2220
static void packet_init(struct rte_mempool *mp, void *opaque_arg, void *_m,
@@ -72,22 +70,6 @@ static void init_mempool_socket(int sid) {
7270
<< ": OK";
7371
}
7472

75-
static void init_templates(void) {
76-
int i;
77-
78-
for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
79-
Packet *pkt;
80-
81-
if (!pframe_pool[i]) {
82-
continue;
83-
}
84-
85-
pkt = reinterpret_cast<Packet *>(rte_pktmbuf_alloc(pframe_pool[i]));
86-
pframe_template = *pkt;
87-
Packet::Free(pkt);
88-
}
89-
}
90-
9173
void init_mempool(void) {
9274
int initialized[RTE_MAX_NUMA_NODES];
9375

@@ -109,8 +91,6 @@ void init_mempool(void) {
10991
initialized[sid] = 1;
11092
}
11193
}
112-
113-
init_templates();
11494
}
11595

11696
void close_mempool(void) {
@@ -142,6 +122,32 @@ static Packet *paddr_to_snb_memchunk(struct rte_mempool_memhdr *chunk,
142122
return nullptr;
143123
}
144124

125+
#define check_offset(field) \
126+
do { \
127+
static_assert(offsetof(Packet, field##_) == offsetof(rte_mbuf, field), \
128+
"Incompatibility detected between class Packet and struct rte_mbuf"); \
129+
} while (0)
130+
131+
Packet::Packet() {
132+
// static assertions for rte_mbuf layout compatibility
133+
static_assert(offsetof(Packet, mbuf_) == 0, "mbuf_ must be at offset 0");
134+
check_offset(buf_addr);
135+
check_offset(rearm_data);
136+
check_offset(data_off);
137+
check_offset(refcnt);
138+
check_offset(nb_segs);
139+
check_offset(rx_descriptor_fields1);
140+
check_offset(pkt_len);
141+
check_offset(data_len);
142+
check_offset(buf_len);
143+
check_offset(pool);
144+
check_offset(next);
145+
146+
rte_pktmbuf_reset(&mbuf_);
147+
}
148+
149+
#undef check_offset
150+
145151
Packet *Packet::from_paddr(phys_addr_t paddr) {
146152
for (int i = 0; i < RTE_MAX_NUMA_NODES; i++) {
147153
struct rte_mempool *pool;
@@ -251,7 +257,7 @@ std::string Packet::Dump() {
251257

252258
dump << "refcnt chain: ";
253259
for (pkt = this; pkt; pkt = pkt->next_) {
254-
dump << pkt->refcnt_;
260+
dump << pkt->refcnt_ << ' ';
255261
}
256262
dump << std::endl;
257263

@@ -273,8 +279,8 @@ std::string Packet::Dump() {
273279
dump << "dump packet at " << this << ", phys=" << buf_physaddr_
274280
<< ", buf_len=" << buf_len_ << std::endl;
275281
dump << " pkt_len=" << pkt_len_ << ", ol_flags=" << std::hex
276-
<< offload_flags_ << ", nb_segs=" << std::dec << unsigned{nb_segs_}
277-
<< ", in_port=" << unsigned{port_} << std::endl;
282+
<< mbuf_.ol_flags << ", nb_segs=" << std::dec << nb_segs_
283+
<< ", in_port=" << mbuf_.port << std::endl;
278284

279285
nb_segs = nb_segs_;
280286
pkt = this;

0 commit comments

Comments
 (0)