vpp之dpdk测试环境搭建

绑定82955网口到dpdk模式

sudo modprobe vfio-pci
sudo /usr/bin/chmod a+x /dev/vfio
sudo /usr/bin/chmod 0666 /dev/vfio/*
sudo ifconfig p3p2 down
sudo ./dpdk-devbind.py --bind=vfio-pci p3p2
sudo ./dpdk-devbind.py --status
sudo mount -t hugetlbfs none /dev/huge

0000:43:00.1

vpp配置文件

unix {cli-listen /run/vpp/cli-vpp1.sock}
api-segment { prefix vpp1 }
cpu { main-core 0 workers 4}
dpdk {
	# Change default settings for all interfaces
	 dev default {
		# Number of receive queues, enables RSS
		# Default is 1
		 num-rx-queues 4

		# Number of transmit queues, Default is equal
		# to number of worker threads or 1 if no workers treads
		 num-tx-queues 4

		# 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

		# VLAN strip offload mode for interface
		# Default is off
		 vlan-strip-offload on
	}

	# Whitelist specific interface by specifying PCI address
	 dev 0000:43:00.1

	# Blacklist specific device type by specifying PCI vendor:device
        # Whitelist entries take precedence
	# blacklist 8086:10fb

	# Set interface name
	# dev 0000:43:00.1 {
	#	name eth0
	# }

	# Specify bonded interface and its slaves via PCI addresses
	#
	# Bonded interface in XOR load balance mode (mode 2) with L3 and L4 headers
	# vdev eth_bond0,mode=2,slave=0000:02:00.0,slave=0000:03:00.0,xmit_policy=l34
	# vdev eth_bond1,mode=2,slave=0000:02:00.1,slave=0000:03:00.1,xmit_policy=l34
	#
	# Bonded interface in Active-Back up mode (mode 1)
	# vdev eth_bond0,mode=1,slave=0000:02:00.0,slave=0000:03:00.0
	# vdev eth_bond1,mode=1,slave=0000:02:00.1,slave=0000:03:00.1

	# 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 512,512

	# Disables UDP / TCP TX checksum offload. Typically needed for use
	# faster vector PMDs (together with no-multi-seg)
	 no-tx-checksum-offload
}

#plugins { plugin dpdk_plugin.so { disable } }

启动vpp

sudo ./vpp -c ./startup.conf
sudo ./vppctl -s /run/vpp/cli-vpp1.sock

查看接口物理配置

DBGvpp# show hardware-interfaces 
              Name                Idx   Link  Hardware
TenGigabitEthernet43/0/1           1    down  TenGigabitEthernet43/0/1
  Link speed: 10 Gbps
  Ethernet address 90:e2:ba:92:a2:2e
  Intel 82599
    carrier up full duplex mtu 9206 
    flags: pmd maybe-multiseg rx-ip4-cksum
    rx: queues 4 (max 128), desc 512 (min 32 max 4096 align 8)
    tx: queues 4 (max 64), desc 512 (min 32 max 4096 align 8)
    pci: device 8086:10fb subsystem 8086:7a12 address 0000:43:00.01 numa 1
    module: id SFP/SFP+/SFP28, compatibility: 10g_base_lr 10g_base_lrm
            vendor: OLINKPHOTONICS, part OLSP311XL-CD10
            revision: 10, serial: A31180920057, date code: 180903
    max rx packet len: 15872
    promiscuous: unicast off all-multicast off
    vlan offload: strip off filter off qinq off
    rx offload avail:  vlan-strip ipv4-cksum udp-cksum tcp-cksum tcp-lro 
                       macsec-strip vlan-filter vlan-extend jumbo-frame scatter 
                       security keep-crc 
    rx offload active: ipv4-cksum jumbo-frame scatter 
    tx offload avail:  vlan-insert ipv4-cksum udp-cksum tcp-cksum sctp-cksum 
                       tcp-tso macsec-insert multi-segs security 
    tx offload active: multi-segs 
    rss avail:         ipv4 ipv4-tcp ipv4-udp ipv6 ipv6-tcp ipv6-udp ipv6-tcp-ex 
                       ipv6-udp-ex ipv6-ex ipv6-tcp-ex ipv6-udp-ex 
    rss active:        none
    tx burst function: ixgbe_xmit_pkts
    rx burst function: ixgbe_recv_pkts

给网口配置ip

set int state TenGigabitEthernet43/0/1 up
set int ip address TenGigabitEthernet43/0/1 1.1.1.1/24

查看trace信息

trace add dpdk-input 10
show trace


Packet 1

00:01:33:760207: dpdk-input
  TenGigabitEthernet43/0/1 rx queue 3
  buffer 0x96504: current data 0, length 98, buffer-pool 0, ref-count 1, totlen-nifb 0, trace 0x0
                  ext-hdr-valid 
                  l4-cksum-computed l4-cksum-correct 
  PKT MBUF: port 0, nb_segs 1, pkt_len 98
    buf_len 2176, data_len 98, ol_flags 0x182, data_off 128, phys_addr 0x2594180
    packet_type 0x11 l2_len 0 l3_len 0 outer_l2_len 0 outer_l3_len 0
    rss 0x9777117 fdir.hi 0x0 fdir.lo 0x9777117
    Packet Offload Flags
      PKT_RX_RSS_HASH (0x0002) RX packet with RSS hash result
      PKT_RX_IP_CKSUM_GOOD (0x0080) IP cksum of RX pkt. is valid
      PKT_RX_L4_CKSUM_GOOD (0x0100) L4 cksum of RX pkt. is valid
    Packet Types
      RTE_PTYPE_L2_ETHER (0x0001) Ethernet packet
      RTE_PTYPE_L3_IPV4 (0x0010) IPv4 packet without extension headers
  IP4: 00:1b:21:26:02:56 -> 90:e2:ba:92:a2:2e
  ICMP: 1.1.1.2 -> 1.1.1.1
    tos 0x00, ttl 64, length 84, checksum 0x87a7
    fragment id 0xaefd, flags DONT_FRAGMENT
  ICMP echo_request checksum 0x7ed0
00:01:33:760226: ip4-input-no-checksum
  ICMP: 1.1.1.2 -> 1.1.1.1
    tos 0x00, ttl 64, length 84, checksum 0x87a7
    fragment id 0xaefd, flags DONT_FRAGMENT
  ICMP echo_request checksum 0x7ed0
00:01:33:760236: ip4-lookup
  fib 0 dpo-idx 5 flow hash: 0x00000000
  ICMP: 1.1.1.2 -> 1.1.1.1
    tos 0x00, ttl 64, length 84, checksum 0x87a7
    fragment id 0xaefd, flags DONT_FRAGMENT
  ICMP echo_request checksum 0x7ed0
00:01:33:760241: ip4-local
    ICMP: 1.1.1.2 -> 1.1.1.1
      tos 0x00, ttl 64, length 84, checksum 0x87a7
      fragment id 0xaefd, flags DONT_FRAGMENT
    ICMP echo_request checksum 0x7ed0
00:01:33:760243: ip4-icmp-input
  ICMP: 1.1.1.2 -> 1.1.1.1
    tos 0x00, ttl 64, length 84, checksum 0x87a7
    fragment id 0xaefd, flags DONT_FRAGMENT
  ICMP echo_request checksum 0x7ed0
00:01:33:760244: ip4-icmp-echo-request
  ICMP: 1.1.1.2 -> 1.1.1.1
    tos 0x00, ttl 64, length 84, checksum 0x87a7
    fragment id 0xaefd, flags DONT_FRAGMENT
  ICMP echo_request checksum 0x7ed0
00:01:33:760248: ip4-load-balance
  fib 0 dpo-idx 1 flow hash: 0x00000000
  ICMP: 1.1.1.1 -> 1.1.1.2
    tos 0x00, ttl 64, length 84, checksum 0x17a2
    fragment id 0x1f03, flags DONT_FRAGMENT
  ICMP echo_reply checksum 0x86d0
00:01:33:760249: ip4-rewrite
  tx_sw_if_index 1 dpo-idx 1 : ipv4 via 1.1.1.2 TenGigabitEthernet43/0/1: mtu:9000 001b2126025690e2ba92a22e0800 flow hash: 0x00000000
  00000000: 001b2126025690e2ba92a22e0800450000541f034000400117a2010101010101
  00000020: 0102000086d06a73001b11e5995c00000000a08c0400000000001011
00:01:33:760251: TenGigabitEthernet43/0/1-output
  TenGigabitEthernet43/0/1 l4-cksum-computed l4-cksum-correct l2_hdr_offset_valid l3_hdr_offset_valid 
  IP4: 90:e2:ba:92:a2:2e -> 00:1b:21:26:02:56
  ICMP: 1.1.1.1 -> 1.1.1.2
    tos 0x00, ttl 64, length 84, checksum 0x17a2
    fragment id 0x1f03, flags DONT_FRAGMENT
  ICMP echo_reply checksum 0x86d0
00:01:33:760258: TenGigabitEthernet43/0/1-tx
  TenGigabitEthernet43/0/1 tx queue 4
  buffer 0x96504: current data 0, length 98, buffer-pool 0, ref-count 1, totlen-nifb 0, trace 0x0
                  ext-hdr-valid 
                  l4-cksum-computed l4-cksum-correct l2-hdr-offset 0 l3-hdr-offset 14 
  PKT MBUF: port 0, nb_segs 1, pkt_len 98
    buf_len 2176, data_len 98, ol_flags 0x182, data_off 128, phys_addr 0x2594180
    packet_type 0x11 l2_len 0 l3_len 0 outer_l2_len 0 outer_l3_len 0
    rss 0x9777117 fdir.hi 0x0 fdir.lo 0x9777117
    Packet Offload Flags
      PKT_RX_RSS_HASH (0x0002) RX packet with RSS hash result
      PKT_RX_IP_CKSUM_GOOD (0x0080) IP cksum of RX pkt. is valid
      PKT_RX_L4_CKSUM_GOOD (0x0100) L4 cksum of RX pkt. is valid
    Packet Types
      RTE_PTYPE_L2_ETHER (0x0001) Ethernet packet
      RTE_PTYPE_L3_IPV4 (0x0010) IPv4 packet without extension headers
  IP4: 90:e2:ba:92:a2:2e -> 00:1b:21:26:02:56
  ICMP: 1.1.1.1 -> 1.1.1.2
    tos 0x00, ttl 64, length 84, checksum 0x17a2
    fragment id 0x1f03, flags DONT_FRAGMENT
  ICMP echo_reply checksum 0x86d0
### 配置VPPDPDK环境 #### 安装环境准备 为了确保VPP及其依赖项DPDK能够顺利安装并正常工作,在开始之前需确认操作系统满足最低需求。通常推荐使用较新的Linux发行版,如Ubuntu LTS版本[^1]。 #### 获取源码与更新系统 通过`apt update -y`来刷新本地软件包索引,并保持系统的最新状态。接着利用Git工具克隆FD.io官方维护的VPP仓库至本地机器上: ```bash git clone https://github.com/FDio/vpp.git ``` #### 构建依赖库 进入解压后的VPP项目根目录执行如下指令以获取必要的构建工具链及其他外部依赖关系: ```bash cd vpp/ make install-dep make install-ext-deps ``` 这些操作将会拉取一些额外的支持组件用于后续编译过程之中[^3]。 #### 编译带有调试特性的VPP版本 对于开发者而言,建议先尝试创建一个包含完整符号表信息(build with debug symbols) 的实例以便于排查可能出现的问题: ```bash make build make pkg-deb sudo dpkg -i build-root/*.deb ``` 此流程不仅完成了VPP本身的组装还负责处理好内存预分配(Huge Pages Setup),从而简化了整体部署难度。 #### DPDK模块加载 值得注意的是并非所有的DPDK版本都会自动生成所需的内核驱动程序(比如`IGB_UIO`)。当遇到缺少特定ko文件的情况时可以考虑回退到稳定的老版本或者调整Makefile里的参数指定兼容性更好的分支进行重新编译。例如设置`dpdk_version=19.08`再运行一次完整的构建命令即可获得所需资源。 一旦完成以上各环节的操作之后便意味着已经成功建立了基于VPP框架下的网络性能优化平台,接下来就可以着手编写应用程序逻辑或是深入研究其内部机制了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值