type
Post
status
Published
slug
2024/10/31/Compile-DPDK-and-pktgen-24.07-on-CentOS-9
summary
tags
Centos
Linux
DPDK
category
DPDK
icon
password
new update day
Property
Nov 1, 2024 08:13 AM
created days
Last edited time
Nov 1, 2024 08:13 AM

编译 dpdk

设置编译依赖

dnf install meson ninja-build -y dnf install libpcap-devel cmake libbpf -y dnf install python3-sphinx -y dnf install python3-pyelftools -y dnf install kernel-devel pciutils -y dnf install libbsd-devel -y dnf install numactl-devel -y dnf install libbpf-devel -y
  • 克隆代码
git clone git://dpdk.org/dpdk
  • 设置编译参数
meson setup -Dexamples=all build
  • 开始编译
cd build ninja
  • 安装
meson install ldconfig

编译 pktgen

  • 克隆代码
git clone git://dpdk.org/apps/pktgen-dpdk git checkout pktgen-24.07.0
  • 设置环境变量
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
  • 开始编译
make >>> Use 'make help' for more commands\n ./tools/pktgen-build.sh build >> SDK Path : /root >> Install Path : /root/pktgen-dpdk >> Build Directory : /root/pktgen-dpdk/builddir >> Target Directory : usr/local >> Build Path : /root/pktgen-dpdk/builddir >> Target Path : /root/pktgen-dpdk/usr/local Build and install values: lua_enabled : -Denable_lua=false >>> Ninja build in '/root/pktgen-dpdk/builddir' buildtype=release meson configure -Dbuildtype=release -Denable_lua=false /root/pktgen-dpdk/builddir ninja: Entering directory `/root/pktgen-dpdk/builddir' [0/1] Regenerating build files. The Meson build system Version: 0.59.4 Source dir: /root/pktgen-dpdk Build dir: /root/pktgen-dpdk/builddir Build type: native build Program cat found: YES (/usr/bin/cat) Project name: pktgen Project version: 24.07.0 C compiler for the host machine: cc (gcc 10.3.1 "cc (GCC) 10.3.1") C linker for the host machine: cc ld.bfd 2.37 Host machine cpu family: x86_64 Host machine cpu: x86_64 Compiler for C supports arguments -mavx: YES (cached) Compiler for C supports arguments -mavx2: YES (cached) Compiler for C supports arguments -Wno-pedantic: YES (cached) Compiler for C supports arguments -Wno-format-truncation: YES (cached) Found pkg-config: /usr/bin/pkg-config (1.8.0) Found CMake: /usr/bin/cmake (3.22.0) Run-time dependency libfgen found: NO (tried pkgconfig and cmake) Dependency libdpdk found: YES 24.07.0 (cached) Message: prefix: /usr/local libdir: lib64 Message: DPDK lib path: /usr/local/lib64 Library rte_net_bond found: YES Program python3 found: YES (/usr/bin/python3) Library rte_net_i40e found: YES Library rte_net_ixgbe found: YES Library rte_net_ice found: YES Library rte_bus_vdev found: YES Dependency threads found: YES unknown (cached) Dependency numa found: YES 2.0.16 (cached) Dependency pcap found: YES 1.10.3 (cached) Library dl found: YES Library m found: YES Library bsd found: YES Program doxygen found: NO Program sphinx-build found: YES (/usr/bin/sphinx-build) Program echo found: YES (/usr/bin/echo) Build targets in project: 10 Found ninja-1.10.2 at /usr/bin/ninja ninja: no work to do. >>> Ninja install to '/root/pktgen-dpdk/usr/local' ninja: Entering directory `/root/pktgen-dpdk/builddir' [0/1] Installing files. Installing app/pktgen to /root/pktgen-dpdk/usr/local/bin Installing /root/pktgen-dpdk/doc/source/custom.css to /root/pktgen-dpdk/usr/local/share/doc/dpdk/_static/css

pktgen 运行测试

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH /root/pktgen-dpdk/usr/local/bin/pktgen
/root/pktgen-dpdk/usr/local/bin/pktgen -h *** Copyright(c) <2010-2024>, Intel Corporation. All rights reserved. *** Pktgen created by: Keith Wiles -- >>> Powered by <<< EAL: Detected CPU lcores: 6 EAL: Detected NUMA nodes: 1 Usage: /root/pktgen-dpdk/usr/local/bin/pktgen [options] EAL common options: -c COREMASK Hexadecimal bitmask of cores to run on -l CORELIST List of cores to run on The argument format is <c1>[-c2][,c3[-c4],...] where c1, c2, etc are core indexes between 0 and 128 --lcores COREMAP Map lcore set to physical cpu set The argument format is '<lcores[@cpus]>[<,lcores[@cpus]>...]' lcores and cpus list are grouped by '(' and ')' Within the group, '-' is used for range separator, ',' is used for single number separator. '( )' can be omitted for single element group, '@' can be omitted if cpus and lcores have the same value -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores --main-lcore ID Core ID that is used as main --mbuf-pool-ops-name Pool ops name for mbuf to use -n CHANNELS Number of memory channels -m MB Memory to allocate (see also --socket-mem) -r RANKS Force number of memory ranks (don't detect) -b, --block Add a device to the blocked list. Prevent EAL from using this device. The argument format for PCI devices is <domain:bus:devid.func>. -a, --allow Add a device to the allow list. Only use the specified devices. The argument format for PCI devices is <[domain:]bus:devid.func>. This option can be present several times. [NOTE: allow cannot be used with block option] --vdev Add a virtual device. The argument format is <driver><id>[,key=val,...] (ex: --vdev=net_pcap0,iface=eth2). --iova-mode Set IOVA mode. 'pa' for IOVA_PA 'va' for IOVA_VA -d LIB.so|DIR Add a driver or driver directory (can be used multiple times) --vmware-tsc-map Use VMware TSC map instead of native RDTSC --proc-type Type of this process (primary|secondary|auto) --syslog Set syslog facility --log-level=<level> Set global log level --log-level=<type-match>:<level> Set specific log level --log-level=help Show log types and levels --trace=<regex-match> Enable trace based on regular expression trace name. By default, the trace is disabled. User must specify this option to enable trace. --trace-dir=<directory path> Specify trace directory for trace output. By default, trace output will created at $HOME directory and parameter must be specified once only. --trace-bufsz=<int> Specify maximum size of allocated memory for trace output for each thread. Valid unit can be either 'B|K|M' for 'Bytes', 'KBytes' and 'MBytes' respectively. Default is 1MB and parameter must be specified once only. --trace-mode=<o[verwrite] | d[iscard]> Specify the mode of update of trace output file. Either update on a file can be wrapped or discarded when file size reaches its maximum limit. Default mode is 'overwrite' and parameter must be specified once only. -v Display version information on startup -h, --help This help --in-memory Operate entirely in memory. This will disable secondary process support --base-virtaddr Base virtual address --telemetry Enable telemetry support (on by default) --no-telemetry Disable telemetry support --force-max-simd-bitwidth Force the max SIMD bitwidth EAL options for DEBUG use only: --huge-unlink[=existing|always|never] When to unlink files in hugetlbfs ('existing' by default, no value means 'always') --no-huge Use malloc instead of hugetlbfs --no-pci Disable PCI --no-hpet Disable HPET --no-shconf No shared config (mmap'd files) EAL Linux options: --socket-mem Memory to allocate on sockets (comma separated values) --socket-limit Limit memory allocation on sockets (comma separated values) --huge-dir Directory where hugetlbfs is mounted --file-prefix Prefix for hugepage filenames --create-uio-dev Create /dev/uioX (usually done by hotplug) --vfio-intr Interrupt mode for VFIO (legacy|msi|msix) --vfio-vf-token VF token (UUID) shared between SR-IOV PF and VFs --legacy-mem Legacy memory mode (no dynamic allocation, contiguous segments) --single-file-segments Put all hugepage memory in single files --match-allocations Free hugepages exactly as allocated --huge-worker-stack[=size] Allocate worker thread stacks from hugepage memory. Size is in units of kbytes and defaults to system thread stack size if not specified. ===== Application Usage ===== Usage: /root/pktgen-dpdk/usr/local/bin/pktgen [EAL options] -- [-h] [-v] [-P] [-G] [-g host:port] [-T] [-f cmd_file] [-l log_file] [-s P:filepath] [-m <string>] -f filename Command file (.pkt) to execute -l filename Write log to filename -s P:filepath PCAP packet stream file, 'P' is the port number -P Enable PROMISCUOUS mode on all ports -g address Optional IP address and port number default is (localhost:0x5606) If -g is used that enable socket support as a server application -G Enable socket support using default server values localhost:0x5606 -N Enable NUMA support -T Enable the color output -v Verbose output -j Enable jumbo frames of 9600 bytes -c Enable clock_gettime --txd=N set the number of descriptors in Tx rings to N --rxd=N set the number of descriptors in Rx rings to N -m <string> matrix for mapping ports to logical cores BNF: (or kind of BNF) <matrix-string> := """ <lcore-port> { "," <lcore-port>} """ <lcore-port> := <lcore-list> "." <port> <lcore-list> := "[" <rx-list> ":" <tx-list> "]" <port> := "<num>" <rx-list> := <num> { "/" (<num> | <list>) } <tx-list> := <num> { "/" (<num> | <list>) } <list> := <num> { "/" (<range> | <list>) } <range> := <num> "-" <num> { "/" <range> } <num> := <digit>+ <digit> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 1.0, 2.1, 3.2 - core 1 handles port 0 rx/tx, core 2 handles port 1 rx/tx core 3 handles port 2 rx/tx 1.[0-2], 2.3, ... - core 1 handle ports 0,1,2 rx/tx, core 2 handle port 3 rx/tx [0-1].0, [2/4-5].1, ... - cores 0-1 handle port 0 rx/tx, cores 2,4,5 handle port 1 rx/tx [1:2].0, [4:6].1, ... - core 1 handles port 0 rx, core 2 handles port 0 tx, [1:2-3].0, [4:5-6].1, ... - core 1 handles port 0 rx, cores 2,3 handle port 0 tx core 4 handles port 1 rx & core 5,6 handles port 1 tx [1-2:3].0, [4-5:6].1, ... - core 1,2 handles port 0 rx, core 3 handles port 0 tx core 4,5 handles port 1 rx & core 6 handles port 1 tx [1-2:3-5].0, [4-5:6/8].1, ... - core 1,2 handles port 0 rx, core 3,4,5 handles port 0 tx core 4,5 handles port 1 rx & core 6,8 handles port 1 tx BTW: you can use "{}" instead of "[]" as it does not matter to the syntax. -h Display the help information
 
欢迎加入喵星计算机技术研究院,原创技术文章第一时间推送。
notion image
 
自建 tailscaler derper 中继服务CentOS 9 DPDK 源码编译