00、前置条件概述
思科VPP(Vector Packet Processing)是一款由思科开发的商用代码,后来其开源版本被加入到Linux基金会的FD.io项目中,并成为该项目的核心。本期我们继续讲解思科VPP24.02系列专题,本期我们讲述如何运行vpp软件
下载vpp软件:
git clone -b stable/2402 https://gerrit.fd.io/r/vpp 从官网拉取 vpp 24.02 版本
01、配置文件简介
本章节思科VPP(Vector Packet Processing)运行的配置文件startup.conf文件,其中包括配置文件展示、字段解析、工程意义等方面进行解析。
配置文件路径:
src/vpp/conf/startup.conf
代码语言:javascript复制root@inspur6680:/home/ubuntu/work/vpp# pwd
/home/ubuntu/work/vpp
root@inspur6680:/home/ubuntu/work/vpp# ls
INFO.yaml LICENSE MAINTAINERS Makefile README.md build/ build-data/ build-root/ configure* docs/ extras/ src/ test/ vpp.si4project/
root@inspur6680:/home/ubuntu/work/vpp# find -name startup.conf
src/vpp/conf/startup.conf
配置文件内容展示
代码语言:javascript复制root@inspur6680:/home/ubuntu/work/vpp# cat src/vpp/conf/startup.conf
内容展示如下:
代码语言:javascript复制
unix {
nodaemon
log /var/log/vpp/vpp.log
full-coredump
cli-listen /run/vpp/cli.sock
gid vpp
## run vpp in the interactive mode
# interactive
## do not use colors in terminal output
# nocolor
## do not display banner
# nobanner
}
api-trace {
## This stanza controls binary API tracing. Unless there is a very strong reason,
## please leave this feature enabled.
on
## Additional parameters:
##
## To set the number of binary API trace records in the circular buffer, configure nitems
##
## nitems <nnn>
##
## To save the api message table decode tables, configure a filename. Results in /tmp/<filename>
## Very handy for understanding api message changes between versions, identifying missing
## plugins, and so forth.
##
## save-api-table <filename>
}
api-segment {
gid vpp
}
socksvr {
default
}
# memory {
## Set the main heap size, default is 1G
# main-heap-size 2G
## Set the main heap page size. Default page size is OS default page
## which is in most cases 4K. if different page size is specified VPP
## will try to allocate main heap by using specified page size.
## special keyword 'default-hugepage' will use system default hugepage
## size
# main-heap-page-size 1G
## Set the default huge page size.
# default-hugepage-size 1G
#}
cpu {
## In the VPP there is one main thread and optionally the user can create worker(s)
## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
## Manual pinning of thread(s) to CPU core(s)
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
# main-core 1
## Set logical CPU core(s) where worker threads are running
# corelist-workers 2-3,18-19
## Automatic pinning of thread(s) to CPU core(s)
## Sets number of CPU core(s) to be skipped (1 ... N-1)
## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
## The main thread is automatically pinned to the first available CPU core and worker(s)
## are pinned to next free CPU core(s) after core assigned to main thread
# skip-cores 4
## Specify a number of workers to be created
## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
## and main thread's CPU core
# workers 2
## Set scheduling policy and priority of main and worker threads
## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
# scheduler-policy fifo
## Scheduling priority is used only for "real-time policies (fifo and rr),
## and has to be in the range of priorities supported for a particular policy
# scheduler-priority 50
}
# buffers {
## Increase number of buffers allocated, needed only in scenarios with
## large number of interfaces and worker threads. Value is per numa node.
## Default is 16384 (8192 if running unpriviledged)
# buffers-per-numa 128000
## Size of buffer data area
## Default is 2048
# default data-size 2048
## Size of the memory pages allocated for buffer data
## Default will try 'default-hugepage' then 'default'
## you can also pass a size in K/M/G e.g. '8M'
# page-size default-hugepage
# }
# dpdk {
## Change default settings for all interfaces
# dev default {
## Number of receive queues, enables RSS
## Default is 1
# num-rx-queues 3
## Number of transmit queues, Default is equal
## to number of worker threads or 1 if no workers treads
# num-tx-queues 3
## Number of descriptors in transmit and receive rings
## increasing or reducing number can impact performance
## Default is 1024 for both rx and tx
# num-rx-desc 512
# num-tx-desc 512
## TCP Segment Offload
## Default is off
## To enable TSO, 'enable-tcp-udp-checksum' must be set
# tso on
## Devargs
## device specific init args
## Default is NULL
# devargs safe-mode-support=1,pipeline-mode-support=1
## rss-queues
## set valid rss steering queues
# rss-queues 0,2,5-7
# }
## Whitelist specific interface by specifying PCI address
# dev 0000:02:00.0
## Blacklist specific device type by specifying PCI vendor:device
## Whitelist entries take precedence
# blacklist 8086:10fb
## Set interface name
# dev 0000:02:00.1 {
# name eth0
# }
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
# dev 0000:02:00.1 {
# num-rx-queues 2
# }
## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci,
## uio_pci_generic or auto (default)
# uio-driver vfio-pci
## Disable multi-segment buffers, improves performance but
## disables Jumbo MTU support
# no-multi-seg
## Change hugepages allocation per-socket, needed only if there is need for
## larger number of mbufs. Default is 256M on each detected CPU socket
# socket-mem 2048,2048
## Disables UDP / TCP TX checksum offload. Typically needed for use
## faster vector PMDs (together with no-multi-seg)
# no-tx-checksum-offload
## Enable UDP / TCP TX checksum offload
## This is the reversed option of 'no-tx-checksum-offload'
# enable-tcp-udp-checksum
## Enable/Disable AVX-512 vPMDs
# max-simd-bitwidth <256|512>
# }
## node variant defaults
#node {
## specify the preferred default variant
# default { variant avx512 }
## specify the preferred variant, for a given node
# ip4-rewrite { variant avx2 }
#}
# plugins {
## Adjusting the plugin path depending on where the VPP plugins are
# path /ws/vpp/build-root/install-vpp-native/vpp/lib/vpp_plugins
## Add additional directory to the plugin path
# add-path /tmp/vpp_plugins
## Disable all plugins by default and then selectively enable specific plugins
# plugin default { disable }
# plugin dpdk_plugin.so { enable }
# plugin acl_plugin.so { enable }
## Enable all plugins by default and then selectively disable specific plugins
# plugin dpdk_plugin.so { disable }
# plugin acl_plugin.so { disable }
# }
## Statistics Segment
# statseg {
# socket-name <filename>, name of the stats segment socket
# defaults to /run/vpp/stats.sock
# size <nnn>[KMG], size of the stats segment, defaults to 32mb
# page-size <nnn>, page size, ie. 2m, defaults to 4k
# per-node-counters on | off, defaults to none
# update-interval <f64-seconds>, sets the segment scrape / update interval
# }
## L2 FIB
# l2fib {
## l2fib hash table size.
# table-size 512M
## l2fib hash table number of buckets. Must be power of 2.
# num-buckets 524288
# }
## ipsec
# {
# ip4 {
## ipsec for ipv4 tunnel lookup hash number of buckets.
# num-buckets 524288
# }
# ip6 {
## ipsec for ipv6 tunnel lookup hash number of buckets.
# num-buckets 524288
# }
# }
# logging {
## set default logging level for logging buffer
## logging levels: emerg, alert,crit, error, warn, notice, info, debug, disabled
# default-log-level debug
## set default logging level for syslog or stderr output
# default-syslog-log-level info
## Set per-class configuration
# class dpdk/cryptodev { rate-limit 100 level debug syslog-level error }
# }
03、字段含义解析
1、UNIX配置参数解析
代码语言:javascript复制unix {
nodaemon
log /var/log/vpp/vpp.log
full-coredump
cli-listen /run/vpp/cli.sock
gid vpp
## run vpp in the interactive mode
# interactive
## do not use colors in terminal output
# nocolor
## do not display banner
# nobanner
}
nodaemon:不要fork /后台vpp进程。从进程监视器调用VPP应用程序时的典型情况。一般情况下配置为 nodaemon
log:配置日志记录信息,如将日志写入/var/log/vpp/vpp.log文件中。
full-coredump: 该字段要求Linux内核转储所有内存映射的地址区域,主要用于vpp发生crash时,记录core文件。
gid vpp 设置有效的组id来指定gid或者是进程的名称
interactive:表示启动vpp直接进入交互界面
nobanner:表示进入vpp后不显示vpp的banner
2、CPU参数解析
代码语言:javascript复制
cpu {
## In the VPP there is one main thread and optionally the user can create worker(s)
## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
## Manual pinning of thread(s) to CPU core(s)
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
# main-core 1
## Set logical CPU core(s) where worker threads are running
# corelist-workers 2-3,18-19
## Automatic pinning of thread(s) to CPU core(s)
## Sets number of CPU core(s) to be skipped (1 ... N-1)
## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
## The main thread is automatically pinned to the first available CPU core and worker(s)
## are pinned to next free CPU core(s) after core assigned to main thread
# skip-cores 4
## Specify a number of workers to be created
## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
## and main thread's CPU core
# workers 2
## Set scheduling policy and priority of main and worker threads
## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
# scheduler-policy fifo
## Scheduling priority is used only for "real-time policies (fifo and rr),
## and has to be in the range of priorities supported for a particular policy
# scheduler-priority 50
}
main-core:表示使用指定的cpuid作为main-core来运行main 线程
corelist-workers:表示使用指定的cpu核来运行work 线程
skip-cores:表示vpp运行时跳过的cpu核
scheduler-policy:表示调度的策略如idle、fifo、rr等方式
scheduler-priority:设置调度优先级
3、DPDK参数解析
代码语言:javascript复制dpdk {
## Change default settings for all interfaces
# dev default {
## Number of receive queues, enables RSS
## Default is 1
# num-rx-queues 3
## Number of transmit queues, Default is equal
## to number of worker threads or 1 if no workers treads
# num-tx-queues 3
## Number of descriptors in transmit and receive rings
## increasing or reducing number can impact performance
## Default is 1024 for both rx and tx
# num-rx-desc 512
# num-tx-desc 512
## TCP Segment Offload
## Default is off
## To enable TSO, 'enable-tcp-udp-checksum' must be set
# tso on
## Devargs
## device specific init args
## Default is NULL
# devargs safe-mode-support=1,pipeline-mode-support=1
## rss-queues
## set valid rss steering queues
# rss-queues 0,2,5-7
# }
## Whitelist specific interface by specifying PCI address
# dev 0000:02:00.0
## Blacklist specific device type by specifying PCI vendor:device
## Whitelist entries take precedence
# blacklist 8086:10fb
## Set interface name
# dev 0000:02:00.1 {
# name eth0
# }
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
# dev 0000:02:00.1 {
# num-rx-queues 2
# }
## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci,
## uio_pci_generic or auto (default)
# uio-driver vfio-pci
## Disable multi-segment buffers, improves performance but
## disables Jumbo MTU support
# no-multi-seg
## Change hugepages allocation per-socket, needed only if there is need for
## larger number of mbufs. Default is 256M on each detected CPU socket
# socket-mem 2048,2048
## Disables UDP / TCP TX checksum offload. Typically needed for use
## faster vector PMDs (together with no-multi-seg)
# no-tx-checksum-offload
## Enable UDP / TCP TX checksum offload
## This is the reversed option of 'no-tx-checksum-offload'
# enable-tcp-udp-checksum
## Enable/Disable AVX-512 vPMDs
# max-simd-bitwidth <256|512>
# }
num-rx-queues:配置dpdk网卡的rx队列数
num-tx-queues:配置dpdk网卡的tx队列数
tso:on表示使能TCP Segment Offload功能
dev 0000:02:00.0 表示vpp纳管的网卡的端口
dev pcie-addr name 表示将网口命名为指定名称
代码语言:javascript复制 dev 0000:02:00.1 {
name eth0
}
uio-driver vfio-pci 表示vpp使用dpdk的 vfio-pci驱动,如果是使用igb uio则配置为对应模式。
4、plugins 配置
代码语言:javascript复制# plugins {
## Adjusting the plugin path depending on where the VPP plugins are
# path /ws/vpp/build-root/install-vpp-native/vpp/lib/vpp_plugins
## Add additional directory to the plugin path
# add-path /tmp/vpp_plugins
## Disable all plugins by default and then selectively enable specific plugins
# plugin default { disable }
# plugin dpdk_plugin.so { enable }
# plugin acl_plugin.so { enable }
## Enable all plugins by default and then selectively disable specific plugins
# plugin dpdk_plugin.so { disable }
# plugin acl_plugin.so { disable }
# }
path 表示vpp运行对应的lib库路径
plugins name {disable} :表示vpp运行时候去使能该插件
plugins name {enable} :表示vpp运行时候使能该插件
5、L2转发配置
代码语言:javascript复制# l2fib {
## l2fib hash table size.
# table-size 512M
## l2fib hash table number of buckets. Must be power of 2.
# num-buckets 524288
# }
该部分配置用于配置 L2 fwd table的大小和entry条目数量。
6、日志相关配置
代码语言:javascript复制# logging {
## set default logging level for logging buffer
## logging levels: emerg, alert,crit, error, warn, notice, info, debug, disabled
# default-log-level debug
## set default logging level for syslog or stderr output
# default-syslog-log-level info
## Set per-class configuration
# class dpdk/cryptodev { rate-limit 100 level debug syslog-level error }
# }
配置vpp 运行时的日志等级和syslog日志等级
04、运行vpp软件
1、vpp 运行环境
加载 vfio-pci:根据配置文件中配置,选择对应的驱动,如果配置文件设置为 uio-driver vfio-pci 则加载vifo-pci.ko
大页配置:
代码语言:javascript复制root@inspur6680:/home/ubuntu/work/vpp# vi /etc/default/grub
1 # If you change this file, run 'update-grub' afterwards to update
2 # /boot/grub/grub.cfg.
3 # For full documentation of the options in this file, see:
4 # info -f grub -n 'Simple configuration'
5
6 GRUB_DEFAULT=0
7 GRUB_TIMEOUT_STYLE=hidden
8 GRUB_TIMEOUT=0
9 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
10 GRUB_CMDLINE_LINUX_DEFAULT="default_hugepagesz=1G hugepagesz=1G hugepages=64 irqaffinity=0,14,28,42 isolcpus=1-13,15-27,29-41,43-55 nohz_full=1-13,15-27,29-41,43-55 rcu_nocbs=1-13,15-27,29-41,43-55 iommu=pt intel_iommu
11 GRUB_CMDLINE_LINUX=""
12
root@inspur6680:~# grub-mkconfig -o /boot/grub/grub.cfg
运行软件命令:
vpp/build-root/install-vpp-native/vpp/bin/vpp -c /etc/vpp/startup.conf
04、结束
小伙伴们,本章节关于Ubuntu 22.04环境下运行思科VPP 24.02版本的配置文件解析就先介绍到这了。后续章节我们继续讲解VPP的相关知识,感谢小伙伴们的阅读,下期再见!
作者简介
作者:通信行业搬砖工 云网络高级软件工程师
数通领域行业从业人员
现云网络行业从业者
(正文完)
END
转载与投稿
文章转载需注明:来源公众号:通信行业搬砖工,并且附上链接
文章错误之处,欢迎指导斧正,各位大拿留言交流,探讨技术。