1. install python3 and python3-pip
安转python3和pip3组件,后面有些配置可直接通过python执行
sudo apt install python3
sudo apt install python3-pip
2.Install Meson and Ninja using pip3. It is advised to install Meson for the user to avoid accessing denial.
安装Meson和Ninja组件,记得使用pip安装,使用apt-get会有路径问题。
pip3 install meson
pip3 install ninja
# recommend this way
pip3 install --user meson
3.export enviorment variable
临时指定下环境变量,注意只在当前终端生效,关闭了需要重来一次。
export PATH=$PATH:$HOME/.local/bin
4.install pkg-config tool
使用apt-get安装pkg-config工具
sudo apt-get install pkg-config
5.intsall auxiliary tools
安装以下辅助工具:python-pyelftools python3-pyelftools,使用apt-get安装
sudo apt-get install python-pyelftools python3-pyelftools
6.download DPDK 21.11 sources by any way, for example, you can download it in wedsite
下载DPDK的源代码,这里使用的是官网下载,也可以到国内的开源网站(gitee)镜像下载。
https://core.dpdk.org/download/
7.unpacked the sources
选择一个合适的位置,在当前路径下解压源码压缩包。
tar -xf dpdk-21.11.5.tar.xz
8.build sources in download path by meson
使用meson和ninja编译整个DPDK套件,也可以使用参数指定其他编译方式。如果执行ninja命令提示没有权限,使用以下命令进行编译。
sudo ~/.local/bin/ninja build install
meson build
# compile for debug version
meson -Dbuildtype=debug -Dexamples=ALL -Denable_kmods=true build
ninja -C build
sudo ninja -C build install
# other way if last cmd is error
sudo ~/.local/bin/ninja build install
9.show lib version
编译完成,会生成库文件,使用前面安装的pkg-config来查看包状态,结果如下:
pkg-config --modversion libdpdk
21.11.5
10、set hugepage by dpdk tools
这里没有给出永久配置大页的方式,新手推荐使用官方提供的py程序临时挂载。先要爱/dev目录下新建一个hugepages文件夹,然后执行官方到巨页挂载程序,注意该命令关机后失效,每次开机需要重新挂载。
cd /dev
mkdir hugepages
sudo dpdk-hugepages.py -p 1G --setup 2G
# display hugepages
dpdk-hugepages.py -s
Node Pages Size Total
0 2 1Gb 2Gb
Hugepages mounted on /dev/hugepages
11、run hello-world example
lib包编译完,巨页挂载完成后,运行实例查看是否搭建好环境。先到目录下的example文件夹,找到helloworld文件夹,执行make生成可执行文件,最后运行./helloworld,将从每个核上打印一个helloworld,说明开发环境已经全部准备完毕。
cd examples/helloworld
make
cd build
# run a example
sudo ./helloworld
EAL: Detected CPU lcores: 12
EAL: Detected NUMA nodes: 1
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: No available 2048 kB hugepages reported
EAL: VFIO support initialized
TELEMETRY: No legacy callbacks, legacy socket not created
hello from core 1
hello from core 2
hello from core 3
hello from core 4
hello from core 5
hello from core 6
hello from core 7
hello from core 8
hello from core 9
hello from core 10
hello from core 11
hello from core 0