Linux网络之DPDK环境搭建

相关网站

编译dpdk-19.11

1
2
3
4
5
6
7
8
9
$ ./mk/rte.cpuflags.mk    SSE4_1
$ export RTE_SDK=`pwd`
$ ./usertools/dpdk-setup.sh 38

$ export RTE_SDK=/mnt/dtt/dpdk/dpdk-19.11
$ export RTE_TARGET=x86_64-native-linuxapp-gcc
$ export EXTRA_CFLAGS="-O0 -g"
$ make config T=x86_64-native-linuxapp-gcc
$ make install T=x86_64-native-linuxapp-gcc

编译dpdk-23.03

1
2
3
4
5
6
$ apt-get update
$ apt-get install meson

$ cd dpdk-23.03
$ meson build
$ ninja -C build

使用

自己编写Makefile编译dpdk:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <rte_version.h>
#include <rte_eal.h>

int main(int argc, char **argv) {
printf("Hello, DPDK! Version: %s\n", rte_version());
int ret = rte_eal_init(argc, argv);
if (ret < 0) {
rte_exit(EXIT_FAILURE, "Cannot init EAL\n");
}

return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

RTE_SDK = /home/dpdk/
RTE_DPDK_OUPUT = /home/dpdk/dpdk-output/

CC=gcc
CFLAGS=-O3 -g -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-format-truncation
LDFLAGS=-L$(RTE_DPDK_OUPUT)/lib -Wl,--no-whole-archive -ldpdk -Wl,--no-whole-archive -lpthread -lm -ldl -lnuma
INCLUDES=-I$(RTE_DPDK_OUPUT)/include

all: hellodpdk

hellodpdk: main.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

main.o: main.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<

clean:
rm -f hellodpdk main.o

其他