https://aijishu.com/a/1060000000212215
本文记录l3fwd和ovs-dpdk性能测试中用到的关键脚本。
#set hugepage
umount /dev/hugepages
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
mount -t hugetlbfs none /dev/hugepages -o pagesize=2MB
#l3fwd scripts (1,2,4,6,8 cores):
sudo /home/ubuntu/mlx_ovs/dpdk-19.11/examples/l3fwd/build/l3fwd -l 15 -n 1 -w 0000:05:00.0 -w 0000:05:00.1 -- -p 0x3 --config="(0,0,15),(1,0,15)" --no-numa
sudo /home/ubuntu/mlx_ovs/dpdk-19.11/examples/l3fwd/build/l3fwd -l 13,15 -n 1 -w 0000:05:00.0 -w 0000:05:00.1 -- -p 0x3 --config="(0,0,13),(1,0,15)" --no-numa
sudo /home/ubuntu/mlx_ovs/dpdk-19.11/examples/l3fwd/build/l3fwd -l 9,11,13,15 -n 1 -w 0000:05:00.0 -w 0000:05:00.1 -- -p 0x3 --config="(0,0,9),(0,1,11),(1,0,13),(1,1,15)" --no-numa
sudo /home/ubuntu/mlx_ovs/dpdk-19.11/examples/l3fwd/build/l3fwd -l 12,9,10,11,13,15 -n 1 -w 0000:05:00.0 -w 0000:05:00.1 -- -p 0x3 --config="(0,0,12),(0,1,9),(0,2,10),(1,0,11),(1,1,13),(1,2,15)" --no-numa
sudo /home/ubuntu/mlx_ovs/dpdk-19.11/examples/l3fwd/build/l3fwd -l 8,9,10,11,12,13,14,15 -n 1 -w 0000:05:00.0 -w 0000:05:00.1 -- -p 0x3 --config="(0,0,8),(0,1,9),(0,2,10),(0,3,11),(1,0,12),(1,1,13),(1,2,14),(1,3,15)" --no-numa
#ovs-dpdk scripts (8 cores):
#!/bin/sh
#STEP1: reset the ovs environment
sudo rm -rf /usr/local/etc/openvswitch/conf.db
sudo rm -rf /usr/local/var/run/openvswitch/vhost-user1
sudo rm -rf /usr/local/var/run/openvswitch/vhost-user2
sudo rm -f /tmp/conf.db
#STEP2: Specify the initial Open vSwitch (OVS) database to use
sudo mkdir -p /var/log/openvswitch
sudo mkdir -p /usr/local/etc/openvswitch
sudo mkdir -p /usr/local/var/run/openvswitch
sudo /usr/local/bin/ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
sudo /usr/local/sbin/ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --log-file=/var/log/openvswitch/ovs-vswitchd.log
export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
#STEP3: Configure the OVS to support DPDK ports
sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
sudo -E ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-extra="-w 0000:05:00.0 -w 0000:05:00.1"
#STEP4: Configure OVS to work with 1G hugespages
export SOCK_MEM=1024
sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem="$SOCK_MEM"
export OVS_CORE_MASK=0xff00
# For the OVS_CORE_MASK value:
# 2core = 0xa000, 4core =0x8888, 8core = 0xaaaa, 12core=0xfff0
export OVS_SERVICE_MASK=0x1
sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-lcore-mask=$OVS_SERVICE_MASK
sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=$OVS_CORE_MASK
#sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:n-rxq=1
#sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:n-txq=1
sudo /usr/local/sbin/ovs-vswitchd unix:$DB_SOCK --pidfile --detach -c $OVS_CORE_MASK --log-file=/var/log/openvswitch/ovs-vswitchd.log
sudo /usr/local/bin/ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
sudo /usr/local/bin/ovs-vsctl add-port br0 dpdk0 -- set Interface dpdk0 type=dpdk options:dpdk-devargs=0000:05:00.0
sudo /usr/local/bin/ovs-vsctl add-port br0 dpdk1 -- set Interface dpdk1 type=dpdk options:dpdk-devargs=0000:05:00.1
sudo /usr/local/bin/ovs-vsctl set Interface dpdk0 options:n_rxq=4
sudo /usr/local/bin/ovs-vsctl set Interface dpdk1 options:n_rxq=4
sudo /usr/local/bin/ovs-vsctl set Interface dpdk0 options:n_txq=4
sudo /usr/local/bin/ovs-vsctl set Interface dpdk1 options:n_txq=4
sudo /usr/local/bin/ovs-ofctl del-flows br0
# because the SUT(server under test) is connected with Ixia by using switch, so the destination MAC address of packets are needed to be updated.
sudo /usr/local/bin/ovs-ofctl add-flow br0 -O OpenFlow13 table=0,in_port=1,actions=mod_dl_dst:02:00:00:00:00:00,output:2
sudo /usr/local/bin/ovs-ofctl add-flow br0 -O OpenFlow13 table=0,in_port=2,actions=mod_dl_dst:02:00:00:00:00:01,output:1
sudo /usr/local/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:emc-insert-inv-prob=1