* [dts] [PATCH v2] add vf mac filter test automation script and plan
@ 2016-01-11 2:49 Qian Xu
2016-01-19 1:44 ` Tu, LijuanX A
0 siblings, 1 reply; 6+ messages in thread
From: Qian Xu @ 2016-01-11 2:49 UTC (permalink / raw)
To: dts
This patch will add vf test plan,script and config file.
VF MAC filter test case is as below:
1. Kernel PF using ip link set command to set VF
MAC address, then check mac filter works or not.
Also check negative case that sending packets
with wrong MAC to ensure mac filter works.
2. Kernel PF will not set MAC address for VF, VF
MAC address is randomly generated. Sending packets
to the VF mac address to ensure mac filter works.
Also using mac_addr add command in testpmd to add
a new mac address, then check if the packets with
this new mac address can be RX/TX. Also check traffic
with wrong MAC address will not be RXed.
Signed-off-by: Qian Xu <qian.q.xu@intel.com>
diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg
new file mode 100644
index 0000000..856b712
--- /dev/null
+++ b/conf/vf_macfilter.cfg
@@ -0,0 +1,105 @@
+# QEMU options
+# name
+# name: vm0
+#
+# enable_kvm
+# enable: [yes | no]
+#
+# cpu
+# model: [host | core2duo | ...]
+# usage:
+# choose model value from the command
+# qemu-system-x86_64 -cpu help
+# number: '4' #number of vcpus
+# cpupin: '3 4 5 6' # host cpu list
+#
+# mem
+# size: 1024
+#
+# disk
+# file: /path/to/image/test.img
+#
+# net
+# type: [nic | user | tap | bridge | ...]
+# nic
+# opt_vlan: 0
+# note: Default is 0.
+# opt_macaddr: 00:00:00:00:01:01
+# note: if creating a nic, it`s better to specify a MAC,
+# else it will get a random number.
+# opt_model:["e1000" | "virtio" | "i82551" | ...]
+# note: Default is e1000.
+# opt_name: 'nic1'
+# opt_addr: ''
+# note: PCI cards only.
+# opt_vectors:
+# note: This option currently only affects virtio cards.
+# user
+# opt_vlan: 0
+# note: default is 0.
+# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
+# note: If not specified, it will be setted automatically.
+# tap
+# opt_vlan: 0
+# note: default is 0.
+# opt_br: br0
+# note: if choosing tap, need to specify bridge name,
+# else it will be br0.
+# opt_script: QEMU_IFUP_PATH
+# note: if not specified, default is self.QEMU_IFUP_PATH.
+# opt_downscript: QEMU_IFDOWN_PATH
+# note: if not specified, default is self.QEMU_IFDOWN_PATH.
+#
+# device
+# driver: [pci-assign | virtio-net-pci | ...]
+# pci-assign
+# prop_host: 08:00.0
+# prop_addr: 00:00:00:00:01:02
+# virtio-net-pci
+# prop_netdev: mynet1
+# prop_id: net1
+# prop_mac: 00:00:00:00:01:03
+# prop_bus: pci.0
+# prop_addr: 0x3
+#
+# monitor
+# port: 6061
+# note: if adding monitor to vm, need to specicy
+# this port, else it will get a free port
+# on the host machine.
+#
+# qga
+# enable: [yes | no]
+#
+# serial_port
+# enable: [yes | no]
+#
+# vnc
+# displayNum: 1
+# note: you can choose a number not used on the host.
+#
+# daemon
+# enable: 'yes'
+# note:
+# By default VM will start with the daemonize status.
+# Not support starting it on the stdin now.
+
+# vm configuration for pmd sriov case
+[vm0]
+cpu =
+ model=host,number=4,cpupin=5 6 7 8;
+disk =
+ file=/home/img/sriov-fc20-1.img;
+login =
+ user=root,password=tester;
+net =
+ type=nic,opt_vlan=0;
+ type=user,opt_vlan=0;
+monitor =
+ port=;
+qga =
+ enable=yes;
+vnc =
+ displayNum=1;
+daemon =
+ enable=yes;
diff --git a/test_plans/vf_macfilter_test_plan.rst b/test_plans/vf_macfilter_test_plan.rst
new file mode 100644
index 0000000..7a95d2b
--- /dev/null
+++ b/test_plans/vf_macfilter_test_plan.rst
@@ -0,0 +1,194 @@
+.. Copyright (c) <2015>, Intel Corporation
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
+=====================================================
+
+1. Get the pci device id of DUT, for example::
+
+./dpdk_nic_bind.py --st
+
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+
+2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
+
+echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
+echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
+
+./dpdk_nic_bind.py --st
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+0000:81:02.0 'XL710/X710 Virtual Function' unused=
+0000:81:0a.0 'XL710/X710 Virtual Function' unused=
+
+ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
+
+3. Detach VFs from the host, bind them to pci-stub driver::
+
+/sbin/modprobe pci-stub
+
+using `lspci -nn|grep -i ethernet` got VF device id, for example "8086 154c",
+
+echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
+echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
+echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
+
+echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
+echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
+echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
+
+or using the following more easy way,
+
+virsh nodedev-detach pci_0000_81_02_0;
+virsh nodedev-detach pci_0000_81_0a_0;
+
+./dpdk_nic_bind.py --st
+
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
+0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
+
+it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
+
+4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
+
+/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \
+-cpu host -smp 4 -m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \
+-device pci-assign,host=81:02.0,id=pt_0 \
+-device pci-assign,host=81:0a.0,id=pt_1
+
+5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0 & 00:07.0, bind them to igb_uio driver,
+and then start testpmd, enable CRC strip, disable promisc mode,set it in mac forward mode::
+
+./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
+./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w 00:07.0 -- -i --portmask=0x3 --txqflags=0
+
+testpmd> port stop all
+testpmd> port config all crc-strip on
+testpmd> port start all
+testpmd> set promisc all off
+testpmd> set fwd mac
+testpmd> start
+
+6. Use scapy to send 100 random packets with ip link set MAC to VF, verify the packets can be received by one
+VF and can be forward to another VF correctly.
+
+7. Also use scapy to send 100 random packets with a wrong MAC to VF, verify the packets can't be received by one
+VF and can be forward to another VF correctly.
+
+Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
+===================================================
+
+1. Get the pci device id of DUT, for example::
+
+./dpdk_nic_bind.py --st
+
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+
+2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
+
+echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
+echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
+
+./dpdk_nic_bind.py --st
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+0000:81:02.0 'XL710/X710 Virtual Function' unused=
+0000:81:0a.0 'XL710/X710 Virtual Function' unused=
+
+3. Detach VFs from the host, bind them to pci-stub driver::
+
+/sbin/modprobe pci-stub
+
+using `lspci -nn|grep -i ethernet` to get VF device id, for example "8086 154c",
+
+echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
+echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
+echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
+
+echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
+echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
+echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
+
+or using the following more easy way,
+
+virsh nodedev-detach pci_0000_81_02_0;
+virsh nodedev-detach pci_0000_81_0a_0;
+
+./dpdk_nic_bind.py --st
+
+0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0 drv=i40e unused=
+0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1 drv=i40e unused=
+0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
+0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
+
+it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
+
+4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
+
+/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \
+-cpu host -smp 4 -m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \
+-device pci-assign,host=81:02.0,id=pt_0 \
+-device pci-assign,host=81:0a.0,id=pt_1
+
+5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0 & 00:07.0, bind them to igb_uio driver,
+and then start testpmd, enable CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then start::
+
+./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
+./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w 00:07.0 -- -i --portmask=0x3 --txqflags=0
+
+testpmd> port stop all
+testpmd> port config all crc-strip on
+testpmd> port start all
+testpmd> set promisc all off
+testpmd> mac_addr add 0 00:11:22:33:44:55
+testpmd> set fwd mac
+testpmd> start
+
+Note: In Jan,2016, i40e doesn't support mac_addr add operation, so the case will be failed for FVL/Fort park NICs.
+
+6. Use scapy to send 100 random packets with current VF0's MAC, verify the packets can be received by one
+VF and can be forward to another VF correctly.
+
+7. Use scapy to send 100 random packets with new added VF0's MAC, verify the packets can be received by one
+VF and can be forward to another VF correctly.
+
+8. Use scapy to send 100 random packets with a wrong MAC to VF0, verify the packets can't be received by one
+VF and can be forward to another VF correctly.
+
+
+
+
diff --git a/tests/TestSuite_vf_macfilter.py b/tests/TestSuite_vf_macfilter.py
new file mode 100644
index 0000000..1f7fbfb
--- /dev/null
+++ b/tests/TestSuite_vf_macfilter.py
@@ -0,0 +1,224 @@
+# <COPYRIGHT_TAG>
+
+import re
+import time
+
+import dts
+from qemu_kvm import QEMUKvm
+from test_case import TestCase
+from pmd_output import PmdOutput
+
+VM_CORES_MASK = 'all'
+
+
+class TestVfMacFilter(TestCase):
+
+ def set_up_all(self):
+ self.dut_ports = self.dut.get_ports(self.nic)
+ self.verify(len(self.dut_ports) > 1, "Insufficient ports")
+ self.vm0 = None
+ self.pf0_vf0_mac = "00:12:34:56:78:01"
+ self.iplinkset = True
+
+ def set_up(self):
+
+ self.setup_2pf_2vf_1vm_env_flag = 0
+
+ def setup_2pf_2vf_1vm_env(self, driver='default'):
+
+ self.used_dut_port_0 = self.dut_ports[0]
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver=driver)
+ self.sriov_vfs_port_0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']
+ pf_intf0 = self.dut.ports_info[0]['port'].get_interface_name()
+
+ if self.iplinkset:
+ self.dut.send_expect("ip link set %s vf 0 mac %s" %(pf_intf0, self.pf0_vf0_mac), "#")
+
+ self.used_dut_port_1 = self.dut_ports[1]
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, driver=driver)
+ self.sriov_vfs_port_1 = self.dut.ports_info[self.used_dut_port_1]['vfs_port']
+
+
+ try:
+
+ for port in self.sriov_vfs_port_0:
+ port.bind_driver('pci-stub')
+
+ for port in self.sriov_vfs_port_1:
+ port.bind_driver('pci-stub')
+
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
+ vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
+
+ if driver == 'igb_uio':
+ # start testpmd without the two VFs on the host
+ self.host_testpmd = PmdOutput(self.dut)
+ eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0': self.sriov_vfs_port_0[0].pci,
+ 'vf1': self.sriov_vfs_port_1[0].pci}
+ self.host_testpmd.start_testpmd("1S/2C/2T", eal_param=eal_param)
+
+ # set up VM0 ENV
+ self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
+ self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
+ self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
+ self.vm_dut_0 = self.vm0.start()
+ if self.vm_dut_0 is None:
+ raise Exception("Set up VM0 ENV failed!")
+
+ self.setup_2pf_2vf_1vm_env_flag = 1
+ except Exception as e:
+ self.destroy_2pf_2vf_1vm_env()
+ raise Exception(e)
+
+ def destroy_2pf_2vf_1vm_env(self):
+ if getattr(self, 'vm0', None):
+ #destroy testpmd in vm0
+ self.vm0_testpmd.execute_cmd('stop')
+ self.vm0_testpmd.execute_cmd('quit', '# ')
+ self.vm0_testpmd = None
+ self.vm0_dut_ports = None
+ #destroy vm0
+ self.vm0.stop()
+ self.vm0 = None
+
+ if getattr(self, 'host_testpmd', None):
+ self.host_testpmd.execute_cmd('quit', '# ')
+ self.host_testpmd = None
+
+ if getattr(self, 'used_dut_port_0', None):
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
+ port = self.dut.ports_info[self.used_dut_port_0]['port']
+ port.bind_driver()
+ self.used_dut_port_0 = None
+
+ if getattr(self, 'used_dut_port_1', None):
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
+ port = self.dut.ports_info[self.used_dut_port_1]['port']
+ port.bind_driver()
+ self.used_dut_port_1 = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_2pf_2vf_1vm_env_flag = 0
+
+######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter scenario
+###### kernel pf will first run 'ip link set pf_interface vf 0 mac xx:xx:xx:xx:xx:xx, then
+###### in the vm, send packets with this MAC to VF, check if the MAC filter works. Also
+###### send the packets with wrong MAC address to VF, check if the VF will not RX the packets.
+
+ def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
+
+ self.setup_2pf_2vf_1vm_env(driver='')
+
+ self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
+ self.vm0_testpmd = PmdOutput(self.vm_dut_0)
+ self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
+ # Get VF's MAC
+ pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
+ vf0_wrongmac = "00:11:22:33:48:55"
+ self.vm0_testpmd.execute_cmd('port stop all')
+ self.vm0_testpmd.execute_cmd('port config all crc-strip on')
+ self.vm0_testpmd.execute_cmd('port start all')
+ self.vm0_testpmd.execute_cmd('set promisc all off')
+ self.vm0_testpmd.execute_cmd('set fwd mac')
+ self.vm0_testpmd.execute_cmd('start')
+
+ time.sleep(2)
+
+ tgen_ports = []
+ tx_port = self.tester.get_local_port(self.dut_ports[0])
+ rx_port = self.tester.get_local_port(self.dut_ports[1])
+ tgen_ports.append((tx_port, rx_port))
+ dst_mac = self.pf0_vf0_mac
+ src_mac = self.tester.get_mac(tx_port)
+ pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
+
+ print "\nfirst send packets to the kernel PF set MAC, expected result is RX packets=TX packets\n"
+ result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
+ print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ self.verify(result1 != False, "VF0 failed to forward packets to VF1")
+
+ print "\nSecondly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n"
+ dst_mac = vf0_wrongmac
+ pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
+ result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
+ print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ self.verify(result2 != True, "VF0 failed to forward packets to VF1")
+
+#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter scenario.
+####### kernel pf will not set MAC address and the VF will get a random generated MAC
+####### in the testpmd in VM, and then add VF mac address in the testpmd,for example, VF_MAC1
+####### then send packets to the VF with the random generated MAC and the new added VF_MAC1
+####### and the expected result is that all packets can be RXed and TXed. What's more, send
+####### packets with a wrong MAC address to the VF will not received by the VF.
+
+ def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
+
+ self.iplinkset = False
+ self.setup_2pf_2vf_1vm_env(driver='')
+
+ self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
+ self.vm0_testpmd = PmdOutput(self.vm_dut_0)
+ self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
+
+ # Get VF0 port MAC address
+ pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
+ vf0_setmac = "00:11:22:33:44:55"
+ vf0_wrongmac = "00:11:22:33:48:55"
+ self.vm0_testpmd.execute_cmd('port stop all')
+ self.vm0_testpmd.execute_cmd('port config all crc-strip on')
+ self.vm0_testpmd.execute_cmd('port start all')
+ self.vm0_testpmd.execute_cmd('set promisc all off')
+ ret = self.vm0_testpmd.execute_cmd('mac_addr add 0 %s' %vf0_setmac)
+ # check the operation is supported or not.
+ print ret
+
+ self.vm0_testpmd.execute_cmd('set fwd mac')
+ self.vm0_testpmd.execute_cmd('start')
+
+ time.sleep(2)
+
+ tgen_ports = []
+ tx_port = self.tester.get_local_port(self.dut_ports[0])
+ rx_port = self.tester.get_local_port(self.dut_ports[1])
+ tgen_ports.append((tx_port, rx_port))
+ src_mac = self.tester.get_mac(tx_port)
+ dst_mac = pmd_vf0_mac
+ pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
+
+ print "\nfirst send packets to the random generated VF MAC, expected result is RX packets=TX packets\n"
+ result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
+ print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ self.verify(result1 != False, "VF0 failed to forward packets to VF1")
+
+ print "\nsecondly, send packets to the new added MAC, expected result is RX packets=TX packets\n"
+ dst_mac = vf0_setmac
+ pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
+ result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
+ print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ self.verify(result2 != False, "VF0 failed to forward packets to VF1")
+
+ print "\nThirdly, negative test, send packets to a wrong MAC, expected result is RX packets=0\n"
+ dst_mac = vf0_wrongmac
+ pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
+ result3 = self.tester.check_random_pkts(tgen_ports, pktnum=100, allow_miss=False, params=pkt_param)
+ print "\nshow port stats in testpmd for double check: \n", self.vm0_testpmd.execute_cmd('show port stats all')
+ self.verify(result3 != True, "VF0 failed to forward packets to VF1")
+
+
+ def tear_down(self):
+
+ if self.setup_2pf_2vf_1vm_env_flag == 1:
+ self.destroy_2pf_2vf_1vm_env()
+
+ def tear_down_all(self):
+
+ if getattr(self, 'vm0', None):
+ self.vm0.stop()
+
+ for port_id in self.dut_ports:
+ self.dut.destroy_sriov_vfs_by_port(port_id)
+
--
2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH v2] add vf mac filter test automation script and plan
2016-01-11 2:49 [dts] [PATCH v2] add vf mac filter test automation script and plan Qian Xu
@ 2016-01-19 1:44 ` Tu, LijuanX A
2016-01-19 1:53 ` Xu, Qian Q
0 siblings, 1 reply; 6+ messages in thread
From: Tu, LijuanX A @ 2016-01-19 1:44 UTC (permalink / raw)
To: Xu, Qian Q, dts
Tested-by: Lijuan Tu <lijuanx.a.tu@intel.com>
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, January 11, 2016 10:49 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] add vf mac filter test automation script and
> plan
>
> This patch will add vf test plan,script and config file.
>
> VF MAC filter test case is as below:
>
> 1. Kernel PF using ip link set command to set VF MAC address, then
> check mac filter works or not.
> Also check negative case that sending packets with wrong MAC to ensure
> mac filter works.
>
> 2. Kernel PF will not set MAC address for VF, VF MAC address is
> randomly generated. Sending packets to the VF mac address to ensure mac
> filter works.
> Also using mac_addr add command in testpmd to add a new mac address,
> then check if the packets with this new mac address can be RX/TX. Also
> check traffic with wrong MAC address will not be RXed.
>
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
>
> diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg new file
> mode 100644 index 0000000..856b712
> --- /dev/null
> +++ b/conf/vf_macfilter.cfg
> @@ -0,0 +1,105 @@
> +# QEMU options
> +# name
> +# name: vm0
> +#
> +# enable_kvm
> +# enable: [yes | no]
> +#
> +# cpu
> +# model: [host | core2duo | ...]
> +# usage:
> +# choose model value from the command
> +# qemu-system-x86_64 -cpu help
> +# number: '4' #number of vcpus
> +# cpupin: '3 4 5 6' # host cpu list
> +#
> +# mem
> +# size: 1024
> +#
> +# disk
> +# file: /path/to/image/test.img
> +#
> +# net
> +# type: [nic | user | tap | bridge | ...]
> +# nic
> +# opt_vlan: 0
> +# note: Default is 0.
> +# opt_macaddr: 00:00:00:00:01:01
> +# note: if creating a nic, it`s better to specify a
> MAC,
> +# else it will get a random number.
> +# opt_model:["e1000" | "virtio" | "i82551" | ...]
> +# note: Default is e1000.
> +# opt_name: 'nic1'
> +# opt_addr: ''
> +# note: PCI cards only.
> +# opt_vectors:
> +# note: This option currently only affects virtio
> cards.
> +# user
> +# opt_vlan: 0
> +# note: default is 0.
> +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-
> [guestaddr]:guestport
> +# note: If not specified, it will be setted
> automatically.
> +# tap
> +# opt_vlan: 0
> +# note: default is 0.
> +# opt_br: br0
> +# note: if choosing tap, need to specify bridge name,
> +# else it will be br0.
> +# opt_script: QEMU_IFUP_PATH
> +# note: if not specified, default is
> self.QEMU_IFUP_PATH.
> +# opt_downscript: QEMU_IFDOWN_PATH
> +# note: if not specified, default is
> self.QEMU_IFDOWN_PATH.
> +#
> +# device
> +# driver: [pci-assign | virtio-net-pci | ...]
> +# pci-assign
> +# prop_host: 08:00.0
> +# prop_addr: 00:00:00:00:01:02
> +# virtio-net-pci
> +# prop_netdev: mynet1
> +# prop_id: net1
> +# prop_mac: 00:00:00:00:01:03
> +# prop_bus: pci.0
> +# prop_addr: 0x3
> +#
> +# monitor
> +# port: 6061
> +# note: if adding monitor to vm, need to specicy
> +# this port, else it will get a free port
> +# on the host machine.
> +#
> +# qga
> +# enable: [yes | no]
> +#
> +# serial_port
> +# enable: [yes | no]
> +#
> +# vnc
> +# displayNum: 1
> +# note: you can choose a number not used on the host.
> +#
> +# daemon
> +# enable: 'yes'
> +# note:
> +# By default VM will start with the daemonize status.
> +# Not support starting it on the stdin now.
> +
> +# vm configuration for pmd sriov case
> +[vm0]
> +cpu =
> + model=host,number=4,cpupin=5 6 7 8; disk =
> + file=/home/img/sriov-fc20-1.img;
> +login =
> + user=root,password=tester;
> +net =
> + type=nic,opt_vlan=0;
> + type=user,opt_vlan=0;
> +monitor =
> + port=;
> +qga =
> + enable=yes;
> +vnc =
> + displayNum=1;
> +daemon =
> + enable=yes;
> diff --git a/test_plans/vf_macfilter_test_plan.rst
> b/test_plans/vf_macfilter_test_plan.rst
> new file mode 100644
> index 0000000..7a95d2b
> --- /dev/null
> +++ b/test_plans/vf_macfilter_test_plan.rst
> @@ -0,0 +1,194 @@
> +.. Copyright (c) <2015>, Intel Corporation
> + All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> +
> + - Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> +
> + - Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in
> + the documentation and/or other materials provided with the
> + distribution.
> +
> + - Neither the name of Intel Corporation nor the names of its
> + contributors may be used to endorse or promote products derived
> + from this software without specific prior written permission.
> +
> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
> + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
> + OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +
> +Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
> +=====================================================
> +
> +1. Get the pci device id of DUT, for example::
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +
> +2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
> +
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> +
> +./dpdk_nic_bind.py --st
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> +
> +ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
> +
> +3. Detach VFs from the host, bind them to pci-stub driver::
> +
> +/sbin/modprobe pci-stub
> +
> +using `lspci -nn|grep -i ethernet` got VF device id, for example "8086
> +154c",
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +or using the following more easy way,
> +
> +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> +pci_0000_81_0a_0;
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +
> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> +
> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> +
> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp 4
> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> +pci-assign,host=81:02.0,id=pt_0 \ -device
> +pci-assign,host=81:0a.0,id=pt_1
> +
> +5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &
> +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> CRC strip, disable promisc mode,set it in mac forward mode::
> +
> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> +00:07.0 -- -i --portmask=0x3 --txqflags=0
> +
> +testpmd> port stop all
> +testpmd> port config all crc-strip on
> +testpmd> port start all
> +testpmd> set promisc all off
> +testpmd> set fwd mac
> +testpmd> start
> +
> +6. Use scapy to send 100 random packets with ip link set MAC to VF,
> +verify the packets can be received by one VF and can be forward to
> another VF correctly.
> +
> +7. Also use scapy to send 100 random packets with a wrong MAC to VF,
> +verify the packets can't be received by one VF and can be forward to
> another VF correctly.
> +
> +Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
> +===================================================
> +
> +1. Get the pci device id of DUT, for example::
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +
> +2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
> +
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> +
> +./dpdk_nic_bind.py --st
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> +
> +3. Detach VFs from the host, bind them to pci-stub driver::
> +
> +/sbin/modprobe pci-stub
> +
> +using `lspci -nn|grep -i ethernet` to get VF device id, for example
> +"8086 154c",
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +or using the following more easy way,
> +
> +virsh nodedev-detach pci_0000_81_02_0;
> +virsh nodedev-detach pci_0000_81_0a_0;
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +
> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> +
> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> +
> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp 4
> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> +pci-assign,host=81:02.0,id=pt_0 \ -device
> +pci-assign,host=81:0a.0,id=pt_1
> +
> +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &
> +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then
> start::
> +
> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> +00:07.0 -- -i --portmask=0x3 --txqflags=0
> +
> +testpmd> port stop all
> +testpmd> port config all crc-strip on
> +testpmd> port start all
> +testpmd> set promisc all off
> +testpmd> mac_addr add 0 00:11:22:33:44:55 set fwd mac start
> +
> +Note: In Jan,2016, i40e doesn't support mac_addr add operation, so the
> case will be failed for FVL/Fort park NICs.
> +
> +6. Use scapy to send 100 random packets with current VF0's MAC, verify
> +the packets can be received by one VF and can be forward to another VF
> correctly.
> +
> +7. Use scapy to send 100 random packets with new added VF0's MAC,
> +verify the packets can be received by one VF and can be forward to
> another VF correctly.
> +
> +8. Use scapy to send 100 random packets with a wrong MAC to VF0,
> verify
> +the packets can't be received by one VF and can be forward to another
> VF correctly.
> +
> +
> +
> +
> diff --git a/tests/TestSuite_vf_macfilter.py
> b/tests/TestSuite_vf_macfilter.py new file mode 100644 index
> 0000000..1f7fbfb
> --- /dev/null
> +++ b/tests/TestSuite_vf_macfilter.py
> @@ -0,0 +1,224 @@
> +# <COPYRIGHT_TAG>
> +
> +import re
> +import time
> +
> +import dts
> +from qemu_kvm import QEMUKvm
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +VM_CORES_MASK = 'all'
> +
> +
> +class TestVfMacFilter(TestCase):
> +
> + def set_up_all(self):
> + self.dut_ports = self.dut.get_ports(self.nic)
> + self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> + self.vm0 = None
> + self.pf0_vf0_mac = "00:12:34:56:78:01"
> + self.iplinkset = True
> +
> + def set_up(self):
> +
> + self.setup_2pf_2vf_1vm_env_flag = 0
> +
> + def setup_2pf_2vf_1vm_env(self, driver='default'):
> +
> + self.used_dut_port_0 = self.dut_ports[0]
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1,
> driver=driver)
> + self.sriov_vfs_port_0 =
> self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> + pf_intf0 = self.dut.ports_info[0]['port'].get_interface_name()
> +
> + if self.iplinkset:
> + self.dut.send_expect("ip link set %s vf 0 mac %s"
> + %(pf_intf0, self.pf0_vf0_mac), "#")
> +
> + self.used_dut_port_1 = self.dut_ports[1]
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1,
> driver=driver)
> + self.sriov_vfs_port_1 =
> + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> +
> +
> + try:
> +
> + for port in self.sriov_vfs_port_0:
> + port.bind_driver('pci-stub')
> +
> + for port in self.sriov_vfs_port_1:
> + port.bind_driver('pci-stub')
> +
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
> +
> + if driver == 'igb_uio':
> + # start testpmd without the two VFs on the host
> + self.host_testpmd = PmdOutput(self.dut)
> + eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0':
> self.sriov_vfs_port_0[0].pci,
> + 'vf1':
> self.sriov_vfs_port_1[0].pci}
> + self.host_testpmd.start_testpmd("1S/2C/2T",
> + eal_param=eal_param)
> +
> + # set up VM0 ENV
> + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
> + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + self.vm_dut_0 = self.vm0.start()
> + if self.vm_dut_0 is None:
> + raise Exception("Set up VM0 ENV failed!")
> +
> + self.setup_2pf_2vf_1vm_env_flag = 1
> + except Exception as e:
> + self.destroy_2pf_2vf_1vm_env()
> + raise Exception(e)
> +
> + def destroy_2pf_2vf_1vm_env(self):
> + if getattr(self, 'vm0', None):
> + #destroy testpmd in vm0
> + self.vm0_testpmd.execute_cmd('stop')
> + self.vm0_testpmd.execute_cmd('quit', '# ')
> + self.vm0_testpmd = None
> + self.vm0_dut_ports = None
> + #destroy vm0
> + self.vm0.stop()
> + self.vm0 = None
> +
> + if getattr(self, 'host_testpmd', None):
> + self.host_testpmd.execute_cmd('quit', '# ')
> + self.host_testpmd = None
> +
> + if getattr(self, 'used_dut_port_0', None):
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> + port = self.dut.ports_info[self.used_dut_port_0]['port']
> + port.bind_driver()
> + self.used_dut_port_0 = None
> +
> + if getattr(self, 'used_dut_port_1', None):
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> + port = self.dut.ports_info[self.used_dut_port_1]['port']
> + port.bind_driver()
> + self.used_dut_port_1 = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_2pf_2vf_1vm_env_flag = 0
> +
> +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> +scenario ###### kernel pf will first run 'ip link set pf_interface vf
> 0
> +mac xx:xx:xx:xx:xx:xx, then ###### in the vm, send packets with this
> +MAC to VF, check if the MAC filter works. Also ###### send the packets
> with wrong MAC address to VF, check if the VF will not RX the packets.
> +
> + def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
> +
> + self.setup_2pf_2vf_1vm_env(driver='')
> +
> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> + # Get VF's MAC
> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> + vf0_wrongmac = "00:11:22:33:48:55"
> + self.vm0_testpmd.execute_cmd('port stop all')
> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> + self.vm0_testpmd.execute_cmd('port start all')
> + self.vm0_testpmd.execute_cmd('set promisc all off')
> + self.vm0_testpmd.execute_cmd('set fwd mac')
> + self.vm0_testpmd.execute_cmd('start')
> +
> + time.sleep(2)
> +
> + tgen_ports = []
> + tx_port = self.tester.get_local_port(self.dut_ports[0])
> + rx_port = self.tester.get_local_port(self.dut_ports[1])
> + tgen_ports.append((tx_port, rx_port))
> + dst_mac = self.pf0_vf0_mac
> + src_mac = self.tester.get_mac(tx_port)
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> +
> + print "\nfirst send packets to the kernel PF set MAC, expected
> result is RX packets=TX packets\n"
> + result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result1 != False, "VF0 failed to forward packets
> to
> +VF1")
> +
> + print "\nSecondly, negative test, send packets to a wrong MAC,
> expected result is RX packets=0\n"
> + dst_mac = vf0_wrongmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result2 != True, "VF0 failed to forward packets to
> + VF1")
> +
> +#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> scenario.
> +####### kernel pf will not set MAC address and the VF will get a
> random
> +generated MAC ####### in the testpmd in VM, and then add VF mac
> address
> +in the testpmd,for example, VF_MAC1 ####### then send packets to the
> VF
> +with the random generated MAC and the new added VF_MAC1 ####### and
> the
> +expected result is that all packets can be RXed and TXed. What's more,
> send ####### packets with a wrong MAC address to the VF will not
> received by the VF.
> +
> + def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
> +
> + self.iplinkset = False
> + self.setup_2pf_2vf_1vm_env(driver='')
> +
> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> +
> + # Get VF0 port MAC address
> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> + vf0_setmac = "00:11:22:33:44:55"
> + vf0_wrongmac = "00:11:22:33:48:55"
> + self.vm0_testpmd.execute_cmd('port stop all')
> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> + self.vm0_testpmd.execute_cmd('port start all')
> + self.vm0_testpmd.execute_cmd('set promisc all off')
> + ret = self.vm0_testpmd.execute_cmd('mac_addr add
> 0 %s' %vf0_setmac)
> + # check the operation is supported or not.
> + print ret
> +
> + self.vm0_testpmd.execute_cmd('set fwd mac')
> + self.vm0_testpmd.execute_cmd('start')
> +
> + time.sleep(2)
> +
> + tgen_ports = []
> + tx_port = self.tester.get_local_port(self.dut_ports[0])
> + rx_port = self.tester.get_local_port(self.dut_ports[1])
> + tgen_ports.append((tx_port, rx_port))
> + src_mac = self.tester.get_mac(tx_port)
> + dst_mac = pmd_vf0_mac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> +
> + print "\nfirst send packets to the random generated VF MAC,
> expected result is RX packets=TX packets\n"
> + result1 = self.tester.check_random_pkts(tgen_ports, pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result1 != False, "VF0 failed to forward packets
> to
> + VF1")
> +
> + print "\nsecondly, send packets to the new added MAC, expected
> result is RX packets=TX packets\n"
> + dst_mac = vf0_setmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result2 = self.tester.check_random_pkts(tgen_ports, pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result2 != False, "VF0 failed to forward packets
> to
> + VF1")
> +
> + print "\nThirdly, negative test, send packets to a wrong MAC,
> expected result is RX packets=0\n"
> + dst_mac = vf0_wrongmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result3 = self.tester.check_random_pkts(tgen_ports, pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result3 != True, "VF0 failed to forward packets to
> + VF1")
> +
> +
> + def tear_down(self):
> +
> + if self.setup_2pf_2vf_1vm_env_flag == 1:
> + self.destroy_2pf_2vf_1vm_env()
> +
> + def tear_down_all(self):
> +
> + if getattr(self, 'vm0', None):
> + self.vm0.stop()
> +
> + for port_id in self.dut_ports:
> + self.dut.destroy_sriov_vfs_by_port(port_id)
> +
> --
> 2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH v2] add vf mac filter test automation script and plan
2016-01-19 1:44 ` Tu, LijuanX A
@ 2016-01-19 1:53 ` Xu, Qian Q
2016-01-19 1:56 ` Tu, LijuanX A
0 siblings, 1 reply; 6+ messages in thread
From: Xu, Qian Q @ 2016-01-19 1:53 UTC (permalink / raw)
To: Tu, LijuanX A, dts
Lijuan,
Have you tried it on Niantic and FVL? FVL will have failed case since mac_addr add is not supported by i40e.
Thanks
Qian
-----Original Message-----
From: Tu, LijuanX A
Sent: Tuesday, January 19, 2016 9:44 AM
To: Xu, Qian Q; dts@dpdk.org
Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script and plan
Tested-by: Lijuan Tu <lijuanx.a.tu@intel.com>
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, January 11, 2016 10:49 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] add vf mac filter test automation script and
> plan
>
> This patch will add vf test plan,script and config file.
>
> VF MAC filter test case is as below:
>
> 1. Kernel PF using ip link set command to set VF MAC address, then
> check mac filter works or not.
> Also check negative case that sending packets with wrong MAC to ensure
> mac filter works.
>
> 2. Kernel PF will not set MAC address for VF, VF MAC address is
> randomly generated. Sending packets to the VF mac address to ensure
> mac filter works.
> Also using mac_addr add command in testpmd to add a new mac address,
> then check if the packets with this new mac address can be RX/TX. Also
> check traffic with wrong MAC address will not be RXed.
>
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
>
> diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg new file
> mode 100644 index 0000000..856b712
> --- /dev/null
> +++ b/conf/vf_macfilter.cfg
> @@ -0,0 +1,105 @@
> +# QEMU options
> +# name
> +# name: vm0
> +#
> +# enable_kvm
> +# enable: [yes | no]
> +#
> +# cpu
> +# model: [host | core2duo | ...]
> +# usage:
> +# choose model value from the command
> +# qemu-system-x86_64 -cpu help
> +# number: '4' #number of vcpus
> +# cpupin: '3 4 5 6' # host cpu list
> +#
> +# mem
> +# size: 1024
> +#
> +# disk
> +# file: /path/to/image/test.img
> +#
> +# net
> +# type: [nic | user | tap | bridge | ...]
> +# nic
> +# opt_vlan: 0
> +# note: Default is 0.
> +# opt_macaddr: 00:00:00:00:01:01
> +# note: if creating a nic, it`s better to specify a
> MAC,
> +# else it will get a random number.
> +# opt_model:["e1000" | "virtio" | "i82551" | ...]
> +# note: Default is e1000.
> +# opt_name: 'nic1'
> +# opt_addr: ''
> +# note: PCI cards only.
> +# opt_vectors:
> +# note: This option currently only affects virtio
> cards.
> +# user
> +# opt_vlan: 0
> +# note: default is 0.
> +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-
> [guestaddr]:guestport
> +# note: If not specified, it will be setted
> automatically.
> +# tap
> +# opt_vlan: 0
> +# note: default is 0.
> +# opt_br: br0
> +# note: if choosing tap, need to specify bridge name,
> +# else it will be br0.
> +# opt_script: QEMU_IFUP_PATH
> +# note: if not specified, default is
> self.QEMU_IFUP_PATH.
> +# opt_downscript: QEMU_IFDOWN_PATH
> +# note: if not specified, default is
> self.QEMU_IFDOWN_PATH.
> +#
> +# device
> +# driver: [pci-assign | virtio-net-pci | ...]
> +# pci-assign
> +# prop_host: 08:00.0
> +# prop_addr: 00:00:00:00:01:02
> +# virtio-net-pci
> +# prop_netdev: mynet1
> +# prop_id: net1
> +# prop_mac: 00:00:00:00:01:03
> +# prop_bus: pci.0
> +# prop_addr: 0x3
> +#
> +# monitor
> +# port: 6061
> +# note: if adding monitor to vm, need to specicy
> +# this port, else it will get a free port
> +# on the host machine.
> +#
> +# qga
> +# enable: [yes | no]
> +#
> +# serial_port
> +# enable: [yes | no]
> +#
> +# vnc
> +# displayNum: 1
> +# note: you can choose a number not used on the host.
> +#
> +# daemon
> +# enable: 'yes'
> +# note:
> +# By default VM will start with the daemonize status.
> +# Not support starting it on the stdin now.
> +
> +# vm configuration for pmd sriov case [vm0] cpu =
> + model=host,number=4,cpupin=5 6 7 8; disk =
> + file=/home/img/sriov-fc20-1.img;
> +login =
> + user=root,password=tester;
> +net =
> + type=nic,opt_vlan=0;
> + type=user,opt_vlan=0;
> +monitor =
> + port=;
> +qga =
> + enable=yes;
> +vnc =
> + displayNum=1;
> +daemon =
> + enable=yes;
> diff --git a/test_plans/vf_macfilter_test_plan.rst
> b/test_plans/vf_macfilter_test_plan.rst
> new file mode 100644
> index 0000000..7a95d2b
> --- /dev/null
> +++ b/test_plans/vf_macfilter_test_plan.rst
> @@ -0,0 +1,194 @@
> +.. Copyright (c) <2015>, Intel Corporation
> + All rights reserved.
> +
> + Redistribution and use in source and binary forms, with or without
> + modification, are permitted provided that the following conditions
> + are met:
> +
> + - Redistributions of source code must retain the above copyright
> + notice, this list of conditions and the following disclaimer.
> +
> + - Redistributions in binary form must reproduce the above copyright
> + notice, this list of conditions and the following disclaimer in
> + the documentation and/or other materials provided with the
> + distribution.
> +
> + - Neither the name of Intel Corporation nor the names of its
> + contributors may be used to endorse or promote products derived
> + from this software without specific prior written permission.
> +
> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
> + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
> + OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +
> +Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
> +=====================================================
> +
> +1. Get the pci device id of DUT, for example::
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +
> +2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
> +
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> +
> +./dpdk_nic_bind.py --st
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> +
> +ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
> +
> +3. Detach VFs from the host, bind them to pci-stub driver::
> +
> +/sbin/modprobe pci-stub
> +
> +using `lspci -nn|grep -i ethernet` got VF device id, for example
> +"8086 154c",
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +or using the following more easy way,
> +
> +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> +pci_0000_81_0a_0;
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +
> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> +
> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> +
> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp 4
> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> +pci-assign,host=81:02.0,id=pt_0 \ -device
> +pci-assign,host=81:0a.0,id=pt_1
> +
> +5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &
> +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> CRC strip, disable promisc mode,set it in mac forward mode::
> +
> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> +00:07.0 -- -i --portmask=0x3 --txqflags=0
> +
> +testpmd> port stop all
> +testpmd> port config all crc-strip on port start all set promisc all
> +testpmd> off set fwd mac start
> +
> +6. Use scapy to send 100 random packets with ip link set MAC to VF,
> +verify the packets can be received by one VF and can be forward to
> another VF correctly.
> +
> +7. Also use scapy to send 100 random packets with a wrong MAC to VF,
> +verify the packets can't be received by one VF and can be forward to
> another VF correctly.
> +
> +Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
> +===================================================
> +
> +1. Get the pci device id of DUT, for example::
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +
> +2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
> +
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> +
> +./dpdk_nic_bind.py --st
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> +
> +3. Detach VFs from the host, bind them to pci-stub driver::
> +
> +/sbin/modprobe pci-stub
> +
> +using `lspci -nn|grep -i ethernet` to get VF device id, for example
> +"8086 154c",
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> +
> +or using the following more easy way,
> +
> +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> +pci_0000_81_0a_0;
> +
> +./dpdk_nic_bind.py --st
> +
> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> +drv=i40e unused=
> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> +drv=i40e unused=
> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> +
> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> +
> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> +
> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp 4
> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> +pci-assign,host=81:02.0,id=pt_0 \ -device
> +pci-assign,host=81:0a.0,id=pt_1
> +
> +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &
> +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then
> start::
> +
> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> +00:07.0 -- -i --portmask=0x3 --txqflags=0
> +
> +testpmd> port stop all
> +testpmd> port config all crc-strip on port start all set promisc all
> +testpmd> off mac_addr add 0 00:11:22:33:44:55 set fwd mac start
> +
> +Note: In Jan,2016, i40e doesn't support mac_addr add operation, so
> +the
> case will be failed for FVL/Fort park NICs.
> +
> +6. Use scapy to send 100 random packets with current VF0's MAC,
> +verify the packets can be received by one VF and can be forward to
> +another VF
> correctly.
> +
> +7. Use scapy to send 100 random packets with new added VF0's MAC,
> +verify the packets can be received by one VF and can be forward to
> another VF correctly.
> +
> +8. Use scapy to send 100 random packets with a wrong MAC to VF0,
> verify
> +the packets can't be received by one VF and can be forward to another
> VF correctly.
> +
> +
> +
> +
> diff --git a/tests/TestSuite_vf_macfilter.py
> b/tests/TestSuite_vf_macfilter.py new file mode 100644 index
> 0000000..1f7fbfb
> --- /dev/null
> +++ b/tests/TestSuite_vf_macfilter.py
> @@ -0,0 +1,224 @@
> +# <COPYRIGHT_TAG>
> +
> +import re
> +import time
> +
> +import dts
> +from qemu_kvm import QEMUKvm
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +VM_CORES_MASK = 'all'
> +
> +
> +class TestVfMacFilter(TestCase):
> +
> + def set_up_all(self):
> + self.dut_ports = self.dut.get_ports(self.nic)
> + self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> + self.vm0 = None
> + self.pf0_vf0_mac = "00:12:34:56:78:01"
> + self.iplinkset = True
> +
> + def set_up(self):
> +
> + self.setup_2pf_2vf_1vm_env_flag = 0
> +
> + def setup_2pf_2vf_1vm_env(self, driver='default'):
> +
> + self.used_dut_port_0 = self.dut_ports[0]
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1,
> driver=driver)
> + self.sriov_vfs_port_0 =
> self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> + pf_intf0 =
> + self.dut.ports_info[0]['port'].get_interface_name()
> +
> + if self.iplinkset:
> + self.dut.send_expect("ip link set %s vf 0 mac %s"
> + %(pf_intf0, self.pf0_vf0_mac), "#")
> +
> + self.used_dut_port_1 = self.dut_ports[1]
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1,
> driver=driver)
> + self.sriov_vfs_port_1 =
> + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> +
> +
> + try:
> +
> + for port in self.sriov_vfs_port_0:
> + port.bind_driver('pci-stub')
> +
> + for port in self.sriov_vfs_port_1:
> + port.bind_driver('pci-stub')
> +
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
> +
> + if driver == 'igb_uio':
> + # start testpmd without the two VFs on the host
> + self.host_testpmd = PmdOutput(self.dut)
> + eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0':
> self.sriov_vfs_port_0[0].pci,
> + 'vf1':
> self.sriov_vfs_port_1[0].pci}
> + self.host_testpmd.start_testpmd("1S/2C/2T",
> + eal_param=eal_param)
> +
> + # set up VM0 ENV
> + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
> + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + self.vm_dut_0 = self.vm0.start()
> + if self.vm_dut_0 is None:
> + raise Exception("Set up VM0 ENV failed!")
> +
> + self.setup_2pf_2vf_1vm_env_flag = 1
> + except Exception as e:
> + self.destroy_2pf_2vf_1vm_env()
> + raise Exception(e)
> +
> + def destroy_2pf_2vf_1vm_env(self):
> + if getattr(self, 'vm0', None):
> + #destroy testpmd in vm0
> + self.vm0_testpmd.execute_cmd('stop')
> + self.vm0_testpmd.execute_cmd('quit', '# ')
> + self.vm0_testpmd = None
> + self.vm0_dut_ports = None
> + #destroy vm0
> + self.vm0.stop()
> + self.vm0 = None
> +
> + if getattr(self, 'host_testpmd', None):
> + self.host_testpmd.execute_cmd('quit', '# ')
> + self.host_testpmd = None
> +
> + if getattr(self, 'used_dut_port_0', None):
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> + port = self.dut.ports_info[self.used_dut_port_0]['port']
> + port.bind_driver()
> + self.used_dut_port_0 = None
> +
> + if getattr(self, 'used_dut_port_1', None):
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> + port = self.dut.ports_info[self.used_dut_port_1]['port']
> + port.bind_driver()
> + self.used_dut_port_1 = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_2pf_2vf_1vm_env_flag = 0
> +
> +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> +scenario ###### kernel pf will first run 'ip link set pf_interface vf
> 0
> +mac xx:xx:xx:xx:xx:xx, then ###### in the vm, send packets with this
> +MAC to VF, check if the MAC filter works. Also ###### send the
> +packets
> with wrong MAC address to VF, check if the VF will not RX the packets.
> +
> + def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
> +
> + self.setup_2pf_2vf_1vm_env(driver='')
> +
> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> + # Get VF's MAC
> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> + vf0_wrongmac = "00:11:22:33:48:55"
> + self.vm0_testpmd.execute_cmd('port stop all')
> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> + self.vm0_testpmd.execute_cmd('port start all')
> + self.vm0_testpmd.execute_cmd('set promisc all off')
> + self.vm0_testpmd.execute_cmd('set fwd mac')
> + self.vm0_testpmd.execute_cmd('start')
> +
> + time.sleep(2)
> +
> + tgen_ports = []
> + tx_port = self.tester.get_local_port(self.dut_ports[0])
> + rx_port = self.tester.get_local_port(self.dut_ports[1])
> + tgen_ports.append((tx_port, rx_port))
> + dst_mac = self.pf0_vf0_mac
> + src_mac = self.tester.get_mac(tx_port)
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> +
> + print "\nfirst send packets to the kernel PF set MAC,
> + expected
> result is RX packets=TX packets\n"
> + result1 = self.tester.check_random_pkts(tgen_ports,
> + pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result1 != False, "VF0 failed to forward packets
> to
> +VF1")
> +
> + print "\nSecondly, negative test, send packets to a wrong
> + MAC,
> expected result is RX packets=0\n"
> + dst_mac = vf0_wrongmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result2 = self.tester.check_random_pkts(tgen_ports,
> + pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result2 != True, "VF0 failed to forward packets
> + to
> + VF1")
> +
> +#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> scenario.
> +####### kernel pf will not set MAC address and the VF will get a
> random
> +generated MAC ####### in the testpmd in VM, and then add VF mac
> address
> +in the testpmd,for example, VF_MAC1 ####### then send packets to the
> VF
> +with the random generated MAC and the new added VF_MAC1 ####### and
> the
> +expected result is that all packets can be RXed and TXed. What's
> +more,
> send ####### packets with a wrong MAC address to the VF will not
> received by the VF.
> +
> + def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
> +
> + self.iplinkset = False
> + self.setup_2pf_2vf_1vm_env(driver='')
> +
> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> +
> + # Get VF0 port MAC address
> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> + vf0_setmac = "00:11:22:33:44:55"
> + vf0_wrongmac = "00:11:22:33:48:55"
> + self.vm0_testpmd.execute_cmd('port stop all')
> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> + self.vm0_testpmd.execute_cmd('port start all')
> + self.vm0_testpmd.execute_cmd('set promisc all off')
> + ret = self.vm0_testpmd.execute_cmd('mac_addr add
> 0 %s' %vf0_setmac)
> + # check the operation is supported or not.
> + print ret
> +
> + self.vm0_testpmd.execute_cmd('set fwd mac')
> + self.vm0_testpmd.execute_cmd('start')
> +
> + time.sleep(2)
> +
> + tgen_ports = []
> + tx_port = self.tester.get_local_port(self.dut_ports[0])
> + rx_port = self.tester.get_local_port(self.dut_ports[1])
> + tgen_ports.append((tx_port, rx_port))
> + src_mac = self.tester.get_mac(tx_port)
> + dst_mac = pmd_vf0_mac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> +
> + print "\nfirst send packets to the random generated VF MAC,
> expected result is RX packets=TX packets\n"
> + result1 = self.tester.check_random_pkts(tgen_ports,
> + pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result1 != False, "VF0 failed to forward packets
> to
> + VF1")
> +
> + print "\nsecondly, send packets to the new added MAC,
> + expected
> result is RX packets=TX packets\n"
> + dst_mac = vf0_setmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result2 = self.tester.check_random_pkts(tgen_ports,
> + pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result2 != False, "VF0 failed to forward packets
> to
> + VF1")
> +
> + print "\nThirdly, negative test, send packets to a wrong MAC,
> expected result is RX packets=0\n"
> + dst_mac = vf0_wrongmac
> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> + result3 = self.tester.check_random_pkts(tgen_ports,
> + pktnum=100,
> allow_miss=False, params=pkt_param)
> + print "\nshow port stats in testpmd for double check: \n",
> self.vm0_testpmd.execute_cmd('show port stats all')
> + self.verify(result3 != True, "VF0 failed to forward packets
> + to
> + VF1")
> +
> +
> + def tear_down(self):
> +
> + if self.setup_2pf_2vf_1vm_env_flag == 1:
> + self.destroy_2pf_2vf_1vm_env()
> +
> + def tear_down_all(self):
> +
> + if getattr(self, 'vm0', None):
> + self.vm0.stop()
> +
> + for port_id in self.dut_ports:
> + self.dut.destroy_sriov_vfs_by_port(port_id)
> +
> --
> 2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH v2] add vf mac filter test automation script and plan
2016-01-19 1:53 ` Xu, Qian Q
@ 2016-01-19 1:56 ` Tu, LijuanX A
2016-01-19 1:57 ` Xu, Qian Q
0 siblings, 1 reply; 6+ messages in thread
From: Tu, LijuanX A @ 2016-01-19 1:56 UTC (permalink / raw)
To: Xu, Qian Q, dts
Yes , I have tested it on Niantic and FVL ,and FVL will have failed case since mac_addr add is not supported by i40e
> -----Original Message-----
> From: Xu, Qian Q
> Sent: Tuesday, January 19, 2016 9:53 AM
> To: Tu, LijuanX A; dts@dpdk.org
> Cc: Xu, Qian Q
> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
> and plan
>
> Lijuan,
> Have you tried it on Niantic and FVL? FVL will have failed case since
> mac_addr add is not supported by i40e.
>
> Thanks
> Qian
>
> -----Original Message-----
> From: Tu, LijuanX A
> Sent: Tuesday, January 19, 2016 9:44 AM
> To: Xu, Qian Q; dts@dpdk.org
> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
> and plan
>
> Tested-by: Lijuan Tu <lijuanx.a.tu@intel.com>
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> > Sent: Monday, January 11, 2016 10:49 AM
> > To: dts@dpdk.org
> > Subject: [dts] [PATCH v2] add vf mac filter test automation script
> and
> > plan
> >
> > This patch will add vf test plan,script and config file.
> >
> > VF MAC filter test case is as below:
> >
> > 1. Kernel PF using ip link set command to set VF MAC address, then
> > check mac filter works or not.
> > Also check negative case that sending packets with wrong MAC to
> ensure
> > mac filter works.
> >
> > 2. Kernel PF will not set MAC address for VF, VF MAC address is
> > randomly generated. Sending packets to the VF mac address to ensure
> > mac filter works.
> > Also using mac_addr add command in testpmd to add a new mac address,
> > then check if the packets with this new mac address can be RX/TX.
> Also
> > check traffic with wrong MAC address will not be RXed.
> >
> > Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> >
> > diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg new file
> > mode 100644 index 0000000..856b712
> > --- /dev/null
> > +++ b/conf/vf_macfilter.cfg
> > @@ -0,0 +1,105 @@
> > +# QEMU options
> > +# name
> > +# name: vm0
> > +#
> > +# enable_kvm
> > +# enable: [yes | no]
> > +#
> > +# cpu
> > +# model: [host | core2duo | ...]
> > +# usage:
> > +# choose model value from the command
> > +# qemu-system-x86_64 -cpu help
> > +# number: '4' #number of vcpus
> > +# cpupin: '3 4 5 6' # host cpu list
> > +#
> > +# mem
> > +# size: 1024
> > +#
> > +# disk
> > +# file: /path/to/image/test.img
> > +#
> > +# net
> > +# type: [nic | user | tap | bridge | ...]
> > +# nic
> > +# opt_vlan: 0
> > +# note: Default is 0.
> > +# opt_macaddr: 00:00:00:00:01:01
> > +# note: if creating a nic, it`s better to specify
> a
> > MAC,
> > +# else it will get a random number.
> > +# opt_model:["e1000" | "virtio" | "i82551" | ...]
> > +# note: Default is e1000.
> > +# opt_name: 'nic1'
> > +# opt_addr: ''
> > +# note: PCI cards only.
> > +# opt_vectors:
> > +# note: This option currently only affects virtio
> > cards.
> > +# user
> > +# opt_vlan: 0
> > +# note: default is 0.
> > +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-
> > [guestaddr]:guestport
> > +# note: If not specified, it will be setted
> > automatically.
> > +# tap
> > +# opt_vlan: 0
> > +# note: default is 0.
> > +# opt_br: br0
> > +# note: if choosing tap, need to specify bridge
> name,
> > +# else it will be br0.
> > +# opt_script: QEMU_IFUP_PATH
> > +# note: if not specified, default is
> > self.QEMU_IFUP_PATH.
> > +# opt_downscript: QEMU_IFDOWN_PATH
> > +# note: if not specified, default is
> > self.QEMU_IFDOWN_PATH.
> > +#
> > +# device
> > +# driver: [pci-assign | virtio-net-pci | ...]
> > +# pci-assign
> > +# prop_host: 08:00.0
> > +# prop_addr: 00:00:00:00:01:02
> > +# virtio-net-pci
> > +# prop_netdev: mynet1
> > +# prop_id: net1
> > +# prop_mac: 00:00:00:00:01:03
> > +# prop_bus: pci.0
> > +# prop_addr: 0x3
> > +#
> > +# monitor
> > +# port: 6061
> > +# note: if adding monitor to vm, need to specicy
> > +# this port, else it will get a free port
> > +# on the host machine.
> > +#
> > +# qga
> > +# enable: [yes | no]
> > +#
> > +# serial_port
> > +# enable: [yes | no]
> > +#
> > +# vnc
> > +# displayNum: 1
> > +# note: you can choose a number not used on the host.
> > +#
> > +# daemon
> > +# enable: 'yes'
> > +# note:
> > +# By default VM will start with the daemonize status.
> > +# Not support starting it on the stdin now.
> > +
> > +# vm configuration for pmd sriov case [vm0] cpu =
> > + model=host,number=4,cpupin=5 6 7 8; disk =
> > + file=/home/img/sriov-fc20-1.img;
> > +login =
> > + user=root,password=tester;
> > +net =
> > + type=nic,opt_vlan=0;
> > + type=user,opt_vlan=0;
> > +monitor =
> > + port=;
> > +qga =
> > + enable=yes;
> > +vnc =
> > + displayNum=1;
> > +daemon =
> > + enable=yes;
> > diff --git a/test_plans/vf_macfilter_test_plan.rst
> > b/test_plans/vf_macfilter_test_plan.rst
> > new file mode 100644
> > index 0000000..7a95d2b
> > --- /dev/null
> > +++ b/test_plans/vf_macfilter_test_plan.rst
> > @@ -0,0 +1,194 @@
> > +.. Copyright (c) <2015>, Intel Corporation
> > + All rights reserved.
> > +
> > + Redistribution and use in source and binary forms, with or
> without
> > + modification, are permitted provided that the following
> conditions
> > + are met:
> > +
> > + - Redistributions of source code must retain the above copyright
> > + notice, this list of conditions and the following disclaimer.
> > +
> > + - Redistributions in binary form must reproduce the above
> copyright
> > + notice, this list of conditions and the following disclaimer in
> > + the documentation and/or other materials provided with the
> > + distribution.
> > +
> > + - Neither the name of Intel Corporation nor the names of its
> > + contributors may be used to endorse or promote products derived
> > + from this software without specific prior written permission.
> > +
> > + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> > + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> OR
> > + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> > + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT,
> > + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> > + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED
> > + OF THE POSSIBILITY OF SUCH DAMAGE.
> > +
> > +
> > +Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
> > +=====================================================
> > +
> > +1. Get the pci device id of DUT, for example::
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +
> > +2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
> > +
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> > +
> > +./dpdk_nic_bind.py --st
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> > +
> > +ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
> > +
> > +3. Detach VFs from the host, bind them to pci-stub driver::
> > +
> > +/sbin/modprobe pci-stub
> > +
> > +using `lspci -nn|grep -i ethernet` got VF device id, for example
> > +"8086 154c",
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> > +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> > +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +or using the following more easy way,
> > +
> > +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> > +pci_0000_81_0a_0;
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +
> > +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> > +
> > +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> > +
> > +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
> 4
> > +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> > +pci-assign,host=81:02.0,id=pt_0 \ -device
> > +pci-assign,host=81:0a.0,id=pt_1
> > +
> > +5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0
> &
> > +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> > CRC strip, disable promisc mode,set it in mac forward mode::
> > +
> > +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> > +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> > +00:07.0 -- -i --portmask=0x3 --txqflags=0
> > +
> > +testpmd> port stop all
> > +testpmd> port config all crc-strip on port start all set promisc all
> > +testpmd> off set fwd mac start
> > +
> > +6. Use scapy to send 100 random packets with ip link set MAC to VF,
> > +verify the packets can be received by one VF and can be forward to
> > another VF correctly.
> > +
> > +7. Also use scapy to send 100 random packets with a wrong MAC to VF,
> > +verify the packets can't be received by one VF and can be forward to
> > another VF correctly.
> > +
> > +Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
> > +===================================================
> > +
> > +1. Get the pci device id of DUT, for example::
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +
> > +2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
> > +
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> > +
> > +./dpdk_nic_bind.py --st
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> > +
> > +3. Detach VFs from the host, bind them to pci-stub driver::
> > +
> > +/sbin/modprobe pci-stub
> > +
> > +using `lspci -nn|grep -i ethernet` to get VF device id, for example
> > +"8086 154c",
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> > +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> > +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +or using the following more easy way,
> > +
> > +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> > +pci_0000_81_0a_0;
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +
> > +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> > +
> > +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> > +
> > +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
> 4
> > +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> > +pci-assign,host=81:02.0,id=pt_0 \ -device
> > +pci-assign,host=81:0a.0,id=pt_1
> > +
> > +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0
> &
> > +00:07.0, bind them to igb_uio driver, and then start testpmd, enable
> > CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then
> > start::
> > +
> > +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> > +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> > +00:07.0 -- -i --portmask=0x3 --txqflags=0
> > +
> > +testpmd> port stop all
> > +testpmd> port config all crc-strip on port start all set promisc all
> > +testpmd> off mac_addr add 0 00:11:22:33:44:55 set fwd mac start
> > +
> > +Note: In Jan,2016, i40e doesn't support mac_addr add operation, so
> > +the
> > case will be failed for FVL/Fort park NICs.
> > +
> > +6. Use scapy to send 100 random packets with current VF0's MAC,
> > +verify the packets can be received by one VF and can be forward to
> > +another VF
> > correctly.
> > +
> > +7. Use scapy to send 100 random packets with new added VF0's MAC,
> > +verify the packets can be received by one VF and can be forward to
> > another VF correctly.
> > +
> > +8. Use scapy to send 100 random packets with a wrong MAC to VF0,
> > verify
> > +the packets can't be received by one VF and can be forward to
> another
> > VF correctly.
> > +
> > +
> > +
> > +
> > diff --git a/tests/TestSuite_vf_macfilter.py
> > b/tests/TestSuite_vf_macfilter.py new file mode 100644 index
> > 0000000..1f7fbfb
> > --- /dev/null
> > +++ b/tests/TestSuite_vf_macfilter.py
> > @@ -0,0 +1,224 @@
> > +# <COPYRIGHT_TAG>
> > +
> > +import re
> > +import time
> > +
> > +import dts
> > +from qemu_kvm import QEMUKvm
> > +from test_case import TestCase
> > +from pmd_output import PmdOutput
> > +
> > +VM_CORES_MASK = 'all'
> > +
> > +
> > +class TestVfMacFilter(TestCase):
> > +
> > + def set_up_all(self):
> > + self.dut_ports = self.dut.get_ports(self.nic)
> > + self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> > + self.vm0 = None
> > + self.pf0_vf0_mac = "00:12:34:56:78:01"
> > + self.iplinkset = True
> > +
> > + def set_up(self):
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 0
> > +
> > + def setup_2pf_2vf_1vm_env(self, driver='default'):
> > +
> > + self.used_dut_port_0 = self.dut_ports[0]
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1,
> > driver=driver)
> > + self.sriov_vfs_port_0 =
> > self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> > + pf_intf0 =
> > + self.dut.ports_info[0]['port'].get_interface_name()
> > +
> > + if self.iplinkset:
> > + self.dut.send_expect("ip link set %s vf 0 mac %s"
> > + %(pf_intf0, self.pf0_vf0_mac), "#")
> > +
> > + self.used_dut_port_1 = self.dut_ports[1]
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1,
> > driver=driver)
> > + self.sriov_vfs_port_1 =
> > + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> > +
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port_0:
> > + port.bind_driver('pci-stub')
> > +
> > + for port in self.sriov_vfs_port_1:
> > + port.bind_driver('pci-stub')
> > +
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
> > +
> > + if driver == 'igb_uio':
> > + # start testpmd without the two VFs on the host
> > + self.host_testpmd = PmdOutput(self.dut)
> > + eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0':
> > self.sriov_vfs_port_0[0].pci,
> > + 'vf1':
> > self.sriov_vfs_port_1[0].pci}
> > + self.host_testpmd.start_testpmd("1S/2C/2T",
> > + eal_param=eal_param)
> > +
> > + # set up VM0 ENV
> > + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
> > + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> > + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> > + self.vm_dut_0 = self.vm0.start()
> > + if self.vm_dut_0 is None:
> > + raise Exception("Set up VM0 ENV failed!")
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 1
> > + except Exception as e:
> > + self.destroy_2pf_2vf_1vm_env()
> > + raise Exception(e)
> > +
> > + def destroy_2pf_2vf_1vm_env(self):
> > + if getattr(self, 'vm0', None):
> > + #destroy testpmd in vm0
> > + self.vm0_testpmd.execute_cmd('stop')
> > + self.vm0_testpmd.execute_cmd('quit', '# ')
> > + self.vm0_testpmd = None
> > + self.vm0_dut_ports = None
> > + #destroy vm0
> > + self.vm0.stop()
> > + self.vm0 = None
> > +
> > + if getattr(self, 'host_testpmd', None):
> > + self.host_testpmd.execute_cmd('quit', '# ')
> > + self.host_testpmd = None
> > +
> > + if getattr(self, 'used_dut_port_0', None):
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> > + port = self.dut.ports_info[self.used_dut_port_0]['port']
> > + port.bind_driver()
> > + self.used_dut_port_0 = None
> > +
> > + if getattr(self, 'used_dut_port_1', None):
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> > + port = self.dut.ports_info[self.used_dut_port_1]['port']
> > + port.bind_driver()
> > + self.used_dut_port_1 = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 0
> > +
> > +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> > +scenario ###### kernel pf will first run 'ip link set pf_interface
> vf
> > 0
> > +mac xx:xx:xx:xx:xx:xx, then ###### in the vm, send packets with this
> > +MAC to VF, check if the MAC filter works. Also ###### send the
> > +packets
> > with wrong MAC address to VF, check if the VF will not RX the packets.
> > +
> > + def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
> > +
> > + self.setup_2pf_2vf_1vm_env(driver='')
> > +
> > + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> > + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> > + # Get VF's MAC
> > + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> > + vf0_wrongmac = "00:11:22:33:48:55"
> > + self.vm0_testpmd.execute_cmd('port stop all')
> > + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> > + self.vm0_testpmd.execute_cmd('port start all')
> > + self.vm0_testpmd.execute_cmd('set promisc all off')
> > + self.vm0_testpmd.execute_cmd('set fwd mac')
> > + self.vm0_testpmd.execute_cmd('start')
> > +
> > + time.sleep(2)
> > +
> > + tgen_ports = []
> > + tx_port = self.tester.get_local_port(self.dut_ports[0])
> > + rx_port = self.tester.get_local_port(self.dut_ports[1])
> > + tgen_ports.append((tx_port, rx_port))
> > + dst_mac = self.pf0_vf0_mac
> > + src_mac = self.tester.get_mac(tx_port)
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > +
> > + print "\nfirst send packets to the kernel PF set MAC,
> > + expected
> > result is RX packets=TX packets\n"
> > + result1 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result1 != False, "VF0 failed to forward packets
> > to
> > +VF1")
> > +
> > + print "\nSecondly, negative test, send packets to a wrong
> > + MAC,
> > expected result is RX packets=0\n"
> > + dst_mac = vf0_wrongmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result2 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result2 != True, "VF0 failed to forward packets
> > + to
> > + VF1")
> > +
> > +#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> > scenario.
> > +####### kernel pf will not set MAC address and the VF will get a
> > random
> > +generated MAC ####### in the testpmd in VM, and then add VF mac
> > address
> > +in the testpmd,for example, VF_MAC1 ####### then send packets to the
> > VF
> > +with the random generated MAC and the new added VF_MAC1 ####### and
> > the
> > +expected result is that all packets can be RXed and TXed. What's
> > +more,
> > send ####### packets with a wrong MAC address to the VF will not
> > received by the VF.
> > +
> > + def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
> > +
> > + self.iplinkset = False
> > + self.setup_2pf_2vf_1vm_env(driver='')
> > +
> > + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> > + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> > +
> > + # Get VF0 port MAC address
> > + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> > + vf0_setmac = "00:11:22:33:44:55"
> > + vf0_wrongmac = "00:11:22:33:48:55"
> > + self.vm0_testpmd.execute_cmd('port stop all')
> > + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> > + self.vm0_testpmd.execute_cmd('port start all')
> > + self.vm0_testpmd.execute_cmd('set promisc all off')
> > + ret = self.vm0_testpmd.execute_cmd('mac_addr add
> > 0 %s' %vf0_setmac)
> > + # check the operation is supported or not.
> > + print ret
> > +
> > + self.vm0_testpmd.execute_cmd('set fwd mac')
> > + self.vm0_testpmd.execute_cmd('start')
> > +
> > + time.sleep(2)
> > +
> > + tgen_ports = []
> > + tx_port = self.tester.get_local_port(self.dut_ports[0])
> > + rx_port = self.tester.get_local_port(self.dut_ports[1])
> > + tgen_ports.append((tx_port, rx_port))
> > + src_mac = self.tester.get_mac(tx_port)
> > + dst_mac = pmd_vf0_mac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > +
> > + print "\nfirst send packets to the random generated VF MAC,
> > expected result is RX packets=TX packets\n"
> > + result1 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result1 != False, "VF0 failed to forward packets
> > to
> > + VF1")
> > +
> > + print "\nsecondly, send packets to the new added MAC,
> > + expected
> > result is RX packets=TX packets\n"
> > + dst_mac = vf0_setmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result2 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result2 != False, "VF0 failed to forward packets
> > to
> > + VF1")
> > +
> > + print "\nThirdly, negative test, send packets to a wrong MAC,
> > expected result is RX packets=0\n"
> > + dst_mac = vf0_wrongmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result3 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result3 != True, "VF0 failed to forward packets
> > + to
> > + VF1")
> > +
> > +
> > + def tear_down(self):
> > +
> > + if self.setup_2pf_2vf_1vm_env_flag == 1:
> > + self.destroy_2pf_2vf_1vm_env()
> > +
> > + def tear_down_all(self):
> > +
> > + if getattr(self, 'vm0', None):
> > + self.vm0.stop()
> > +
> > + for port_id in self.dut_ports:
> > + self.dut.destroy_sriov_vfs_by_port(port_id)
> > +
> > --
> > 2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH v2] add vf mac filter test automation script and plan
2016-01-19 1:56 ` Tu, LijuanX A
@ 2016-01-19 1:57 ` Xu, Qian Q
2016-01-19 3:12 ` Liu, Yong
0 siblings, 1 reply; 6+ messages in thread
From: Xu, Qian Q @ 2016-01-19 1:57 UTC (permalink / raw)
To: Tu, LijuanX A, dts
Good to know, well done!
Thanks
Qian
-----Original Message-----
From: Tu, LijuanX A
Sent: Tuesday, January 19, 2016 9:57 AM
To: Xu, Qian Q; dts@dpdk.org
Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script and plan
Yes , I have tested it on Niantic and FVL ,and FVL will have failed case since mac_addr add is not supported by i40e
> -----Original Message-----
> From: Xu, Qian Q
> Sent: Tuesday, January 19, 2016 9:53 AM
> To: Tu, LijuanX A; dts@dpdk.org
> Cc: Xu, Qian Q
> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
> and plan
>
> Lijuan,
> Have you tried it on Niantic and FVL? FVL will have failed case since
> mac_addr add is not supported by i40e.
>
> Thanks
> Qian
>
> -----Original Message-----
> From: Tu, LijuanX A
> Sent: Tuesday, January 19, 2016 9:44 AM
> To: Xu, Qian Q; dts@dpdk.org
> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
> and plan
>
> Tested-by: Lijuan Tu <lijuanx.a.tu@intel.com>
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> > Sent: Monday, January 11, 2016 10:49 AM
> > To: dts@dpdk.org
> > Subject: [dts] [PATCH v2] add vf mac filter test automation script
> and
> > plan
> >
> > This patch will add vf test plan,script and config file.
> >
> > VF MAC filter test case is as below:
> >
> > 1. Kernel PF using ip link set command to set VF MAC address, then
> > check mac filter works or not.
> > Also check negative case that sending packets with wrong MAC to
> ensure
> > mac filter works.
> >
> > 2. Kernel PF will not set MAC address for VF, VF MAC address is
> > randomly generated. Sending packets to the VF mac address to ensure
> > mac filter works.
> > Also using mac_addr add command in testpmd to add a new mac address,
> > then check if the packets with this new mac address can be RX/TX.
> Also
> > check traffic with wrong MAC address will not be RXed.
> >
> > Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> >
> > diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg new file
> > mode 100644 index 0000000..856b712
> > --- /dev/null
> > +++ b/conf/vf_macfilter.cfg
> > @@ -0,0 +1,105 @@
> > +# QEMU options
> > +# name
> > +# name: vm0
> > +#
> > +# enable_kvm
> > +# enable: [yes | no]
> > +#
> > +# cpu
> > +# model: [host | core2duo | ...]
> > +# usage:
> > +# choose model value from the command
> > +# qemu-system-x86_64 -cpu help
> > +# number: '4' #number of vcpus
> > +# cpupin: '3 4 5 6' # host cpu list
> > +#
> > +# mem
> > +# size: 1024
> > +#
> > +# disk
> > +# file: /path/to/image/test.img
> > +#
> > +# net
> > +# type: [nic | user | tap | bridge | ...]
> > +# nic
> > +# opt_vlan: 0
> > +# note: Default is 0.
> > +# opt_macaddr: 00:00:00:00:01:01
> > +# note: if creating a nic, it`s better to specify
> a
> > MAC,
> > +# else it will get a random number.
> > +# opt_model:["e1000" | "virtio" | "i82551" | ...]
> > +# note: Default is e1000.
> > +# opt_name: 'nic1'
> > +# opt_addr: ''
> > +# note: PCI cards only.
> > +# opt_vectors:
> > +# note: This option currently only affects virtio
> > cards.
> > +# user
> > +# opt_vlan: 0
> > +# note: default is 0.
> > +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-
> > [guestaddr]:guestport
> > +# note: If not specified, it will be setted
> > automatically.
> > +# tap
> > +# opt_vlan: 0
> > +# note: default is 0.
> > +# opt_br: br0
> > +# note: if choosing tap, need to specify bridge
> name,
> > +# else it will be br0.
> > +# opt_script: QEMU_IFUP_PATH
> > +# note: if not specified, default is
> > self.QEMU_IFUP_PATH.
> > +# opt_downscript: QEMU_IFDOWN_PATH
> > +# note: if not specified, default is
> > self.QEMU_IFDOWN_PATH.
> > +#
> > +# device
> > +# driver: [pci-assign | virtio-net-pci | ...]
> > +# pci-assign
> > +# prop_host: 08:00.0
> > +# prop_addr: 00:00:00:00:01:02
> > +# virtio-net-pci
> > +# prop_netdev: mynet1
> > +# prop_id: net1
> > +# prop_mac: 00:00:00:00:01:03
> > +# prop_bus: pci.0
> > +# prop_addr: 0x3
> > +#
> > +# monitor
> > +# port: 6061
> > +# note: if adding monitor to vm, need to specicy
> > +# this port, else it will get a free port
> > +# on the host machine.
> > +#
> > +# qga
> > +# enable: [yes | no]
> > +#
> > +# serial_port
> > +# enable: [yes | no]
> > +#
> > +# vnc
> > +# displayNum: 1
> > +# note: you can choose a number not used on the host.
> > +#
> > +# daemon
> > +# enable: 'yes'
> > +# note:
> > +# By default VM will start with the daemonize status.
> > +# Not support starting it on the stdin now.
> > +
> > +# vm configuration for pmd sriov case [vm0] cpu =
> > + model=host,number=4,cpupin=5 6 7 8; disk =
> > + file=/home/img/sriov-fc20-1.img; login =
> > + user=root,password=tester;
> > +net =
> > + type=nic,opt_vlan=0;
> > + type=user,opt_vlan=0;
> > +monitor =
> > + port=;
> > +qga =
> > + enable=yes;
> > +vnc =
> > + displayNum=1;
> > +daemon =
> > + enable=yes;
> > diff --git a/test_plans/vf_macfilter_test_plan.rst
> > b/test_plans/vf_macfilter_test_plan.rst
> > new file mode 100644
> > index 0000000..7a95d2b
> > --- /dev/null
> > +++ b/test_plans/vf_macfilter_test_plan.rst
> > @@ -0,0 +1,194 @@
> > +.. Copyright (c) <2015>, Intel Corporation
> > + All rights reserved.
> > +
> > + Redistribution and use in source and binary forms, with or
> without
> > + modification, are permitted provided that the following
> conditions
> > + are met:
> > +
> > + - Redistributions of source code must retain the above copyright
> > + notice, this list of conditions and the following disclaimer.
> > +
> > + - Redistributions in binary form must reproduce the above
> copyright
> > + notice, this list of conditions and the following disclaimer in
> > + the documentation and/or other materials provided with the
> > + distribution.
> > +
> > + - Neither the name of Intel Corporation nor the names of its
> > + contributors may be used to endorse or promote products derived
> > + from this software without specific prior written permission.
> > +
> > + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> > + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> > + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> > + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> > + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> > + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> OR
> > + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> > + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT,
> > + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> > + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED
> > + OF THE POSSIBILITY OF SUCH DAMAGE.
> > +
> > +
> > +Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
> > +=====================================================
> > +
> > +1. Get the pci device id of DUT, for example::
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +
> > +2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
> > +
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> > +
> > +./dpdk_nic_bind.py --st
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> > +
> > +ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
> > +
> > +3. Detach VFs from the host, bind them to pci-stub driver::
> > +
> > +/sbin/modprobe pci-stub
> > +
> > +using `lspci -nn|grep -i ethernet` got VF device id, for example
> > +"8086 154c",
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> > +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> > +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +or using the following more easy way,
> > +
> > +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> > +pci_0000_81_0a_0;
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +
> > +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> > +
> > +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> > +
> > +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
> 4
> > +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> > +pci-assign,host=81:02.0,id=pt_0 \ -device
> > +pci-assign,host=81:0a.0,id=pt_1
> > +
> > +5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0
> &
> > +00:07.0, bind them to igb_uio driver, and then start testpmd,
> > +enable
> > CRC strip, disable promisc mode,set it in mac forward mode::
> > +
> > +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> > +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> > +00:07.0 -- -i --portmask=0x3 --txqflags=0
> > +
> > +testpmd> port stop all
> > +testpmd> port config all crc-strip on port start all set promisc
> > +testpmd> all off set fwd mac start
> > +
> > +6. Use scapy to send 100 random packets with ip link set MAC to VF,
> > +verify the packets can be received by one VF and can be forward to
> > another VF correctly.
> > +
> > +7. Also use scapy to send 100 random packets with a wrong MAC to
> > +VF, verify the packets can't be received by one VF and can be
> > +forward to
> > another VF correctly.
> > +
> > +Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
> > +===================================================
> > +
> > +1. Get the pci device id of DUT, for example::
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +
> > +2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
> > +
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
> > +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
> > +
> > +./dpdk_nic_bind.py --st
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
> > +
> > +3. Detach VFs from the host, bind them to pci-stub driver::
> > +
> > +/sbin/modprobe pci-stub
> > +
> > +using `lspci -nn|grep -i ethernet` to get VF device id, for example
> > +"8086 154c",
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
> > +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
> > +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
> > +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
> > +
> > +or using the following more easy way,
> > +
> > +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
> > +pci_0000_81_0a_0;
> > +
> > +./dpdk_nic_bind.py --st
> > +
> > +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
> > +drv=i40e unused=
> > +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
> > +drv=i40e unused=
> > +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
> > +
> > +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
> > +
> > +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
> > +
> > +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
> 4
> > +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
> > +pci-assign,host=81:02.0,id=pt_0 \ -device
> > +pci-assign,host=81:0a.0,id=pt_1
> > +
> > +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0
> &
> > +00:07.0, bind them to igb_uio driver, and then start testpmd,
> > +enable
> > CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then
> > start::
> > +
> > +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
> > +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
> > +00:07.0 -- -i --portmask=0x3 --txqflags=0
> > +
> > +testpmd> port stop all
> > +testpmd> port config all crc-strip on port start all set promisc
> > +testpmd> all off mac_addr add 0 00:11:22:33:44:55 set fwd mac start
> > +
> > +Note: In Jan,2016, i40e doesn't support mac_addr add operation, so
> > +the
> > case will be failed for FVL/Fort park NICs.
> > +
> > +6. Use scapy to send 100 random packets with current VF0's MAC,
> > +verify the packets can be received by one VF and can be forward to
> > +another VF
> > correctly.
> > +
> > +7. Use scapy to send 100 random packets with new added VF0's MAC,
> > +verify the packets can be received by one VF and can be forward to
> > another VF correctly.
> > +
> > +8. Use scapy to send 100 random packets with a wrong MAC to VF0,
> > verify
> > +the packets can't be received by one VF and can be forward to
> another
> > VF correctly.
> > +
> > +
> > +
> > +
> > diff --git a/tests/TestSuite_vf_macfilter.py
> > b/tests/TestSuite_vf_macfilter.py new file mode 100644 index
> > 0000000..1f7fbfb
> > --- /dev/null
> > +++ b/tests/TestSuite_vf_macfilter.py
> > @@ -0,0 +1,224 @@
> > +# <COPYRIGHT_TAG>
> > +
> > +import re
> > +import time
> > +
> > +import dts
> > +from qemu_kvm import QEMUKvm
> > +from test_case import TestCase
> > +from pmd_output import PmdOutput
> > +
> > +VM_CORES_MASK = 'all'
> > +
> > +
> > +class TestVfMacFilter(TestCase):
> > +
> > + def set_up_all(self):
> > + self.dut_ports = self.dut.get_ports(self.nic)
> > + self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> > + self.vm0 = None
> > + self.pf0_vf0_mac = "00:12:34:56:78:01"
> > + self.iplinkset = True
> > +
> > + def set_up(self):
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 0
> > +
> > + def setup_2pf_2vf_1vm_env(self, driver='default'):
> > +
> > + self.used_dut_port_0 = self.dut_ports[0]
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0,
> > + 1,
> > driver=driver)
> > + self.sriov_vfs_port_0 =
> > self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> > + pf_intf0 =
> > + self.dut.ports_info[0]['port'].get_interface_name()
> > +
> > + if self.iplinkset:
> > + self.dut.send_expect("ip link set %s vf 0 mac %s"
> > + %(pf_intf0, self.pf0_vf0_mac), "#")
> > +
> > + self.used_dut_port_1 = self.dut_ports[1]
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1,
> > + 1,
> > driver=driver)
> > + self.sriov_vfs_port_1 =
> > + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> > +
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port_0:
> > + port.bind_driver('pci-stub')
> > +
> > + for port in self.sriov_vfs_port_1:
> > + port.bind_driver('pci-stub')
> > +
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
> > +
> > + if driver == 'igb_uio':
> > + # start testpmd without the two VFs on the host
> > + self.host_testpmd = PmdOutput(self.dut)
> > + eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0':
> > self.sriov_vfs_port_0[0].pci,
> > + 'vf1':
> > self.sriov_vfs_port_1[0].pci}
> > + self.host_testpmd.start_testpmd("1S/2C/2T",
> > + eal_param=eal_param)
> > +
> > + # set up VM0 ENV
> > + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
> > + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> > + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> > + self.vm_dut_0 = self.vm0.start()
> > + if self.vm_dut_0 is None:
> > + raise Exception("Set up VM0 ENV failed!")
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 1
> > + except Exception as e:
> > + self.destroy_2pf_2vf_1vm_env()
> > + raise Exception(e)
> > +
> > + def destroy_2pf_2vf_1vm_env(self):
> > + if getattr(self, 'vm0', None):
> > + #destroy testpmd in vm0
> > + self.vm0_testpmd.execute_cmd('stop')
> > + self.vm0_testpmd.execute_cmd('quit', '# ')
> > + self.vm0_testpmd = None
> > + self.vm0_dut_ports = None
> > + #destroy vm0
> > + self.vm0.stop()
> > + self.vm0 = None
> > +
> > + if getattr(self, 'host_testpmd', None):
> > + self.host_testpmd.execute_cmd('quit', '# ')
> > + self.host_testpmd = None
> > +
> > + if getattr(self, 'used_dut_port_0', None):
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> > + port = self.dut.ports_info[self.used_dut_port_0]['port']
> > + port.bind_driver()
> > + self.used_dut_port_0 = None
> > +
> > + if getattr(self, 'used_dut_port_1', None):
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> > + port = self.dut.ports_info[self.used_dut_port_1]['port']
> > + port.bind_driver()
> > + self.used_dut_port_1 = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_2pf_2vf_1vm_env_flag = 0
> > +
> > +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
> > +scenario ###### kernel pf will first run 'ip link set pf_interface
> vf
> > 0
> > +mac xx:xx:xx:xx:xx:xx, then ###### in the vm, send packets with
> > +this MAC to VF, check if the MAC filter works. Also ###### send the
> > +packets
> > with wrong MAC address to VF, check if the VF will not RX the packets.
> > +
> > + def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
> > +
> > + self.setup_2pf_2vf_1vm_env(driver='')
> > +
> > + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> > + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> > + # Get VF's MAC
> > + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> > + vf0_wrongmac = "00:11:22:33:48:55"
> > + self.vm0_testpmd.execute_cmd('port stop all')
> > + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> > + self.vm0_testpmd.execute_cmd('port start all')
> > + self.vm0_testpmd.execute_cmd('set promisc all off')
> > + self.vm0_testpmd.execute_cmd('set fwd mac')
> > + self.vm0_testpmd.execute_cmd('start')
> > +
> > + time.sleep(2)
> > +
> > + tgen_ports = []
> > + tx_port = self.tester.get_local_port(self.dut_ports[0])
> > + rx_port = self.tester.get_local_port(self.dut_ports[1])
> > + tgen_ports.append((tx_port, rx_port))
> > + dst_mac = self.pf0_vf0_mac
> > + src_mac = self.tester.get_mac(tx_port)
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > +
> > + print "\nfirst send packets to the kernel PF set MAC,
> > + expected
> > result is RX packets=TX packets\n"
> > + result1 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result1 != False, "VF0 failed to forward
> > + packets
> > to
> > +VF1")
> > +
> > + print "\nSecondly, negative test, send packets to a wrong
> > + MAC,
> > expected result is RX packets=0\n"
> > + dst_mac = vf0_wrongmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result2 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result2 != True, "VF0 failed to forward packets
> > + to
> > + VF1")
> > +
> > +#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC
> > +filter
> > scenario.
> > +####### kernel pf will not set MAC address and the VF will get a
> > random
> > +generated MAC ####### in the testpmd in VM, and then add VF mac
> > address
> > +in the testpmd,for example, VF_MAC1 ####### then send packets to
> > +the
> > VF
> > +with the random generated MAC and the new added VF_MAC1 ####### and
> > the
> > +expected result is that all packets can be RXed and TXed. What's
> > +more,
> > send ####### packets with a wrong MAC address to the VF will not
> > received by the VF.
> > +
> > + def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
> > +
> > + self.iplinkset = False
> > + self.setup_2pf_2vf_1vm_env(driver='')
> > +
> > + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> > + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> > +
> > + # Get VF0 port MAC address
> > + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
> > + vf0_setmac = "00:11:22:33:44:55"
> > + vf0_wrongmac = "00:11:22:33:48:55"
> > + self.vm0_testpmd.execute_cmd('port stop all')
> > + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
> > + self.vm0_testpmd.execute_cmd('port start all')
> > + self.vm0_testpmd.execute_cmd('set promisc all off')
> > + ret = self.vm0_testpmd.execute_cmd('mac_addr add
> > 0 %s' %vf0_setmac)
> > + # check the operation is supported or not.
> > + print ret
> > +
> > + self.vm0_testpmd.execute_cmd('set fwd mac')
> > + self.vm0_testpmd.execute_cmd('start')
> > +
> > + time.sleep(2)
> > +
> > + tgen_ports = []
> > + tx_port = self.tester.get_local_port(self.dut_ports[0])
> > + rx_port = self.tester.get_local_port(self.dut_ports[1])
> > + tgen_ports.append((tx_port, rx_port))
> > + src_mac = self.tester.get_mac(tx_port)
> > + dst_mac = pmd_vf0_mac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > +
> > + print "\nfirst send packets to the random generated VF MAC,
> > expected result is RX packets=TX packets\n"
> > + result1 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result1 != False, "VF0 failed to forward
> > + packets
> > to
> > + VF1")
> > +
> > + print "\nsecondly, send packets to the new added MAC,
> > + expected
> > result is RX packets=TX packets\n"
> > + dst_mac = vf0_setmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result2 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result2 != False, "VF0 failed to forward
> > + packets
> > to
> > + VF1")
> > +
> > + print "\nThirdly, negative test, send packets to a wrong
> > + MAC,
> > expected result is RX packets=0\n"
> > + dst_mac = vf0_wrongmac
> > + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
> > + result3 = self.tester.check_random_pkts(tgen_ports,
> > + pktnum=100,
> > allow_miss=False, params=pkt_param)
> > + print "\nshow port stats in testpmd for double check: \n",
> > self.vm0_testpmd.execute_cmd('show port stats all')
> > + self.verify(result3 != True, "VF0 failed to forward packets
> > + to
> > + VF1")
> > +
> > +
> > + def tear_down(self):
> > +
> > + if self.setup_2pf_2vf_1vm_env_flag == 1:
> > + self.destroy_2pf_2vf_1vm_env()
> > +
> > + def tear_down_all(self):
> > +
> > + if getattr(self, 'vm0', None):
> > + self.vm0.stop()
> > +
> > + for port_id in self.dut_ports:
> > + self.dut.destroy_sriov_vfs_by_port(port_id)
> > +
> > --
> > 2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH v2] add vf mac filter test automation script and plan
2016-01-19 1:57 ` Xu, Qian Q
@ 2016-01-19 3:12 ` Liu, Yong
0 siblings, 0 replies; 6+ messages in thread
From: Liu, Yong @ 2016-01-19 3:12 UTC (permalink / raw)
To: Xu, Qian Q, Tu, LijuanX A, dts
Applied. Thanks.
On 01/19/2016 09:57 AM, Xu, Qian Q wrote:
> Good to know, well done!
>
> Thanks
> Qian
>
>
> -----Original Message-----
> From: Tu, LijuanX A
> Sent: Tuesday, January 19, 2016 9:57 AM
> To: Xu, Qian Q; dts@dpdk.org
> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script and plan
>
> Yes , I have tested it on Niantic and FVL ,and FVL will have failed case since mac_addr add is not supported by i40e
>
>> -----Original Message-----
>> From: Xu, Qian Q
>> Sent: Tuesday, January 19, 2016 9:53 AM
>> To: Tu, LijuanX A; dts@dpdk.org
>> Cc: Xu, Qian Q
>> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
>> and plan
>>
>> Lijuan,
>> Have you tried it on Niantic and FVL? FVL will have failed case since
>> mac_addr add is not supported by i40e.
>>
>> Thanks
>> Qian
>>
>> -----Original Message-----
>> From: Tu, LijuanX A
>> Sent: Tuesday, January 19, 2016 9:44 AM
>> To: Xu, Qian Q; dts@dpdk.org
>> Subject: RE: [dts] [PATCH v2] add vf mac filter test automation script
>> and plan
>>
>> Tested-by: Lijuan Tu <lijuanx.a.tu@intel.com>
>>
>>> -----Original Message-----
>>> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
>>> Sent: Monday, January 11, 2016 10:49 AM
>>> To: dts@dpdk.org
>>> Subject: [dts] [PATCH v2] add vf mac filter test automation script
>> and
>>> plan
>>>
>>> This patch will add vf test plan,script and config file.
>>>
>>> VF MAC filter test case is as below:
>>>
>>> 1. Kernel PF using ip link set command to set VF MAC address, then
>>> check mac filter works or not.
>>> Also check negative case that sending packets with wrong MAC to
>> ensure
>>> mac filter works.
>>>
>>> 2. Kernel PF will not set MAC address for VF, VF MAC address is
>>> randomly generated. Sending packets to the VF mac address to ensure
>>> mac filter works.
>>> Also using mac_addr add command in testpmd to add a new mac address,
>>> then check if the packets with this new mac address can be RX/TX.
>> Also
>>> check traffic with wrong MAC address will not be RXed.
>>>
>>> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
>>>
>>> diff --git a/conf/vf_macfilter.cfg b/conf/vf_macfilter.cfg new file
>>> mode 100644 index 0000000..856b712
>>> --- /dev/null
>>> +++ b/conf/vf_macfilter.cfg
>>> @@ -0,0 +1,105 @@
>>> +# QEMU options
>>> +# name
>>> +# name: vm0
>>> +#
>>> +# enable_kvm
>>> +# enable: [yes | no]
>>> +#
>>> +# cpu
>>> +# model: [host | core2duo | ...]
>>> +# usage:
>>> +# choose model value from the command
>>> +# qemu-system-x86_64 -cpu help
>>> +# number: '4' #number of vcpus
>>> +# cpupin: '3 4 5 6' # host cpu list
>>> +#
>>> +# mem
>>> +# size: 1024
>>> +#
>>> +# disk
>>> +# file: /path/to/image/test.img
>>> +#
>>> +# net
>>> +# type: [nic | user | tap | bridge | ...]
>>> +# nic
>>> +# opt_vlan: 0
>>> +# note: Default is 0.
>>> +# opt_macaddr: 00:00:00:00:01:01
>>> +# note: if creating a nic, it`s better to specify
>> a
>>> MAC,
>>> +# else it will get a random number.
>>> +# opt_model:["e1000" | "virtio" | "i82551" | ...]
>>> +# note: Default is e1000.
>>> +# opt_name: 'nic1'
>>> +# opt_addr: ''
>>> +# note: PCI cards only.
>>> +# opt_vectors:
>>> +# note: This option currently only affects virtio
>>> cards.
>>> +# user
>>> +# opt_vlan: 0
>>> +# note: default is 0.
>>> +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-
>>> [guestaddr]:guestport
>>> +# note: If not specified, it will be setted
>>> automatically.
>>> +# tap
>>> +# opt_vlan: 0
>>> +# note: default is 0.
>>> +# opt_br: br0
>>> +# note: if choosing tap, need to specify bridge
>> name,
>>> +# else it will be br0.
>>> +# opt_script: QEMU_IFUP_PATH
>>> +# note: if not specified, default is
>>> self.QEMU_IFUP_PATH.
>>> +# opt_downscript: QEMU_IFDOWN_PATH
>>> +# note: if not specified, default is
>>> self.QEMU_IFDOWN_PATH.
>>> +#
>>> +# device
>>> +# driver: [pci-assign | virtio-net-pci | ...]
>>> +# pci-assign
>>> +# prop_host: 08:00.0
>>> +# prop_addr: 00:00:00:00:01:02
>>> +# virtio-net-pci
>>> +# prop_netdev: mynet1
>>> +# prop_id: net1
>>> +# prop_mac: 00:00:00:00:01:03
>>> +# prop_bus: pci.0
>>> +# prop_addr: 0x3
>>> +#
>>> +# monitor
>>> +# port: 6061
>>> +# note: if adding monitor to vm, need to specicy
>>> +# this port, else it will get a free port
>>> +# on the host machine.
>>> +#
>>> +# qga
>>> +# enable: [yes | no]
>>> +#
>>> +# serial_port
>>> +# enable: [yes | no]
>>> +#
>>> +# vnc
>>> +# displayNum: 1
>>> +# note: you can choose a number not used on the host.
>>> +#
>>> +# daemon
>>> +# enable: 'yes'
>>> +# note:
>>> +# By default VM will start with the daemonize status.
>>> +# Not support starting it on the stdin now.
>>> +
>>> +# vm configuration for pmd sriov case [vm0] cpu =
>>> + model=host,number=4,cpupin=5 6 7 8; disk =
>>> + file=/home/img/sriov-fc20-1.img; login =
>>> + user=root,password=tester;
>>> +net =
>>> + type=nic,opt_vlan=0;
>>> + type=user,opt_vlan=0;
>>> +monitor =
>>> + port=;
>>> +qga =
>>> + enable=yes;
>>> +vnc =
>>> + displayNum=1;
>>> +daemon =
>>> + enable=yes;
>>> diff --git a/test_plans/vf_macfilter_test_plan.rst
>>> b/test_plans/vf_macfilter_test_plan.rst
>>> new file mode 100644
>>> index 0000000..7a95d2b
>>> --- /dev/null
>>> +++ b/test_plans/vf_macfilter_test_plan.rst
>>> @@ -0,0 +1,194 @@
>>> +.. Copyright (c) <2015>, Intel Corporation
>>> + All rights reserved.
>>> +
>>> + Redistribution and use in source and binary forms, with or
>> without
>>> + modification, are permitted provided that the following
>> conditions
>>> + are met:
>>> +
>>> + - Redistributions of source code must retain the above copyright
>>> + notice, this list of conditions and the following disclaimer.
>>> +
>>> + - Redistributions in binary form must reproduce the above
>> copyright
>>> + notice, this list of conditions and the following disclaimer in
>>> + the documentation and/or other materials provided with the
>>> + distribution.
>>> +
>>> + - Neither the name of Intel Corporation nor the names of its
>>> + contributors may be used to endorse or promote products derived
>>> + from this software without specific prior written permission.
>>> +
>>> + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
>> CONTRIBUTORS
>>> + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>>> + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
>>> + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
>>> + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
>> INDIRECT,
>>> + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
>>> + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
>> OR
>>> + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
>>> + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> CONTRACT,
>>> + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>>> + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
>> ADVISED
>>> + OF THE POSSIBILITY OF SUCH DAMAGE.
>>> +
>>> +
>>> +Test Case 1: test_kernel_2pf_2vf_1vm_iplink_macfilter
>>> +=====================================================
>>> +
>>> +1. Get the pci device id of DUT, for example::
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +
>>> +2. Create 2 VFs from 2 PFs, and set the VF MAC address at PF0::
>>> +
>>> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
>>> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
>>> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
>>> +
>>> +ip link set ens259f0 vf 0 mac 00:11:22:33:44:55
>>> +
>>> +3. Detach VFs from the host, bind them to pci-stub driver::
>>> +
>>> +/sbin/modprobe pci-stub
>>> +
>>> +using `lspci -nn|grep -i ethernet` got VF device id, for example
>>> +"8086 154c",
>>> +
>>> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
>>> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
>>> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
>>> +
>>> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
>>> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
>>> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
>>> +
>>> +or using the following more easy way,
>>> +
>>> +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
>>> +pci_0000_81_0a_0;
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
>>> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
>>> +
>>> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
>>> +
>>> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
>>> +
>>> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
>> 4
>>> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
>>> +pci-assign,host=81:02.0,id=pt_0 \ -device
>>> +pci-assign,host=81:0a.0,id=pt_1
>>> +
>>> +5. Login vm0, got VFs pci device id in vm0, assume they are 00:06.0
>> &
>>> +00:07.0, bind them to igb_uio driver, and then start testpmd,
>>> +enable
>>> CRC strip, disable promisc mode,set it in mac forward mode::
>>> +
>>> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
>>> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
>>> +00:07.0 -- -i --portmask=0x3 --txqflags=0
>>> +
>>> +testpmd> port stop all
>>> +testpmd> port config all crc-strip on port start all set promisc
>>> +testpmd> all off set fwd mac start
>>> +
>>> +6. Use scapy to send 100 random packets with ip link set MAC to VF,
>>> +verify the packets can be received by one VF and can be forward to
>>> another VF correctly.
>>> +
>>> +7. Also use scapy to send 100 random packets with a wrong MAC to
>>> +VF, verify the packets can't be received by one VF and can be
>>> +forward to
>>> another VF correctly.
>>> +
>>> +Test Case 2: test_kernel_2pf_2vf_1vm_mac_add_filter
>>> +===================================================
>>> +
>>> +1. Get the pci device id of DUT, for example::
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +
>>> +2. Create 2 VFs from 2 PFs, and don't set the VF MAC address at PF0::
>>> +
>>> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs
>>> +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +0000:81:02.0 'XL710/X710 Virtual Function' unused=
>>> +0000:81:0a.0 'XL710/X710 Virtual Function' unused=
>>> +
>>> +3. Detach VFs from the host, bind them to pci-stub driver::
>>> +
>>> +/sbin/modprobe pci-stub
>>> +
>>> +using `lspci -nn|grep -i ethernet` to get VF device id, for example
>>> +"8086 154c",
>>> +
>>> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
>>> +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind
>>> +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind
>>> +
>>> +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id
>>> +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind
>>> +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind
>>> +
>>> +or using the following more easy way,
>>> +
>>> +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach
>>> +pci_0000_81_0a_0;
>>> +
>>> +./dpdk_nic_bind.py --st
>>> +
>>> +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f0
>>> +drv=i40e unused=
>>> +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=ens259f1
>>> +drv=i40e unused=
>>> +0000:81:02.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
>>> +0000:81:0a.0 'XL710/X710 Virtual Function' if= drv=pci-stub unused=
>>> +
>>> +it can be seen that VFs 81:02.0 & 81:0a.0 's driver is pci-stub.
>>> +
>>> +4. Passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0::
>>> +
>>> +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp
>> 4
>>> +-m 2048 -drive file=/home/image/sriov-fc20-1.img -vnc :1 \ -device
>>> +pci-assign,host=81:02.0,id=pt_0 \ -device
>>> +pci-assign,host=81:0a.0,id=pt_1
>>> +
>>> +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0
>> &
>>> +00:07.0, bind them to igb_uio driver, and then start testpmd,
>>> +enable
>>> CRC strip on VF, disable promisc mode, add a new MAC to VF0 and then
>>> start::
>>> +
>>> +./tools/dpdk_nic_bind.py --bind=igb_uio 00:06.0 00:07.0
>>> +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w
>>> +00:07.0 -- -i --portmask=0x3 --txqflags=0
>>> +
>>> +testpmd> port stop all
>>> +testpmd> port config all crc-strip on port start all set promisc
>>> +testpmd> all off mac_addr add 0 00:11:22:33:44:55 set fwd mac start
>>> +
>>> +Note: In Jan,2016, i40e doesn't support mac_addr add operation, so
>>> +the
>>> case will be failed for FVL/Fort park NICs.
>>> +
>>> +6. Use scapy to send 100 random packets with current VF0's MAC,
>>> +verify the packets can be received by one VF and can be forward to
>>> +another VF
>>> correctly.
>>> +
>>> +7. Use scapy to send 100 random packets with new added VF0's MAC,
>>> +verify the packets can be received by one VF and can be forward to
>>> another VF correctly.
>>> +
>>> +8. Use scapy to send 100 random packets with a wrong MAC to VF0,
>>> verify
>>> +the packets can't be received by one VF and can be forward to
>> another
>>> VF correctly.
>>> +
>>> +
>>> +
>>> +
>>> diff --git a/tests/TestSuite_vf_macfilter.py
>>> b/tests/TestSuite_vf_macfilter.py new file mode 100644 index
>>> 0000000..1f7fbfb
>>> --- /dev/null
>>> +++ b/tests/TestSuite_vf_macfilter.py
>>> @@ -0,0 +1,224 @@
>>> +# <COPYRIGHT_TAG>
>>> +
>>> +import re
>>> +import time
>>> +
>>> +import dts
>>> +from qemu_kvm import QEMUKvm
>>> +from test_case import TestCase
>>> +from pmd_output import PmdOutput
>>> +
>>> +VM_CORES_MASK = 'all'
>>> +
>>> +
>>> +class TestVfMacFilter(TestCase):
>>> +
>>> + def set_up_all(self):
>>> + self.dut_ports = self.dut.get_ports(self.nic)
>>> + self.verify(len(self.dut_ports) > 1, "Insufficient ports")
>>> + self.vm0 = None
>>> + self.pf0_vf0_mac = "00:12:34:56:78:01"
>>> + self.iplinkset = True
>>> +
>>> + def set_up(self):
>>> +
>>> + self.setup_2pf_2vf_1vm_env_flag = 0
>>> +
>>> + def setup_2pf_2vf_1vm_env(self, driver='default'):
>>> +
>>> + self.used_dut_port_0 = self.dut_ports[0]
>>> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0,
>>> + 1,
>>> driver=driver)
>>> + self.sriov_vfs_port_0 =
>>> self.dut.ports_info[self.used_dut_port_0]['vfs_port']
>>> + pf_intf0 =
>>> + self.dut.ports_info[0]['port'].get_interface_name()
>>> +
>>> + if self.iplinkset:
>>> + self.dut.send_expect("ip link set %s vf 0 mac %s"
>>> + %(pf_intf0, self.pf0_vf0_mac), "#")
>>> +
>>> + self.used_dut_port_1 = self.dut_ports[1]
>>> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1,
>>> + 1,
>>> driver=driver)
>>> + self.sriov_vfs_port_1 =
>>> + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
>>> +
>>> +
>>> + try:
>>> +
>>> + for port in self.sriov_vfs_port_0:
>>> + port.bind_driver('pci-stub')
>>> +
>>> + for port in self.sriov_vfs_port_1:
>>> + port.bind_driver('pci-stub')
>>> +
>>> + time.sleep(1)
>>> + vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
>>> + vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci}
>>> +
>>> + if driver == 'igb_uio':
>>> + # start testpmd without the two VFs on the host
>>> + self.host_testpmd = PmdOutput(self.dut)
>>> + eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0':
>>> self.sriov_vfs_port_0[0].pci,
>>> + 'vf1':
>>> self.sriov_vfs_port_1[0].pci}
>>> + self.host_testpmd.start_testpmd("1S/2C/2T",
>>> + eal_param=eal_param)
>>> +
>>> + # set up VM0 ENV
>>> + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
>>> + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
>>> + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
>>> + self.vm_dut_0 = self.vm0.start()
>>> + if self.vm_dut_0 is None:
>>> + raise Exception("Set up VM0 ENV failed!")
>>> +
>>> + self.setup_2pf_2vf_1vm_env_flag = 1
>>> + except Exception as e:
>>> + self.destroy_2pf_2vf_1vm_env()
>>> + raise Exception(e)
>>> +
>>> + def destroy_2pf_2vf_1vm_env(self):
>>> + if getattr(self, 'vm0', None):
>>> + #destroy testpmd in vm0
>>> + self.vm0_testpmd.execute_cmd('stop')
>>> + self.vm0_testpmd.execute_cmd('quit', '# ')
>>> + self.vm0_testpmd = None
>>> + self.vm0_dut_ports = None
>>> + #destroy vm0
>>> + self.vm0.stop()
>>> + self.vm0 = None
>>> +
>>> + if getattr(self, 'host_testpmd', None):
>>> + self.host_testpmd.execute_cmd('quit', '# ')
>>> + self.host_testpmd = None
>>> +
>>> + if getattr(self, 'used_dut_port_0', None):
>>> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
>>> + port = self.dut.ports_info[self.used_dut_port_0]['port']
>>> + port.bind_driver()
>>> + self.used_dut_port_0 = None
>>> +
>>> + if getattr(self, 'used_dut_port_1', None):
>>> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
>>> + port = self.dut.ports_info[self.used_dut_port_1]['port']
>>> + port.bind_driver()
>>> + self.used_dut_port_1 = None
>>> +
>>> + for port_id in self.dut_ports:
>>> + port = self.dut.ports_info[port_id]['port']
>>> + port.bind_driver()
>>> +
>>> + self.setup_2pf_2vf_1vm_env_flag = 0
>>> +
>>> +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC filter
>>> +scenario ###### kernel pf will first run 'ip link set pf_interface
>> vf
>>> 0
>>> +mac xx:xx:xx:xx:xx:xx, then ###### in the vm, send packets with
>>> +this MAC to VF, check if the MAC filter works. Also ###### send the
>>> +packets
>>> with wrong MAC address to VF, check if the VF will not RX the packets.
>>> +
>>> + def test_kernel_2pf_2vf_1vm_iplink_macfilter(self):
>>> +
>>> + self.setup_2pf_2vf_1vm_env(driver='')
>>> +
>>> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
>>> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
>>> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
>>> + # Get VF's MAC
>>> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
>>> + vf0_wrongmac = "00:11:22:33:48:55"
>>> + self.vm0_testpmd.execute_cmd('port stop all')
>>> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
>>> + self.vm0_testpmd.execute_cmd('port start all')
>>> + self.vm0_testpmd.execute_cmd('set promisc all off')
>>> + self.vm0_testpmd.execute_cmd('set fwd mac')
>>> + self.vm0_testpmd.execute_cmd('start')
>>> +
>>> + time.sleep(2)
>>> +
>>> + tgen_ports = []
>>> + tx_port = self.tester.get_local_port(self.dut_ports[0])
>>> + rx_port = self.tester.get_local_port(self.dut_ports[1])
>>> + tgen_ports.append((tx_port, rx_port))
>>> + dst_mac = self.pf0_vf0_mac
>>> + src_mac = self.tester.get_mac(tx_port)
>>> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
>>> +
>>> + print "\nfirst send packets to the kernel PF set MAC,
>>> + expected
>>> result is RX packets=TX packets\n"
>>> + result1 = self.tester.check_random_pkts(tgen_ports,
>>> + pktnum=100,
>>> allow_miss=False, params=pkt_param)
>>> + print "\nshow port stats in testpmd for double check: \n",
>>> self.vm0_testpmd.execute_cmd('show port stats all')
>>> + self.verify(result1 != False, "VF0 failed to forward
>>> + packets
>>> to
>>> +VF1")
>>> +
>>> + print "\nSecondly, negative test, send packets to a wrong
>>> + MAC,
>>> expected result is RX packets=0\n"
>>> + dst_mac = vf0_wrongmac
>>> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
>>> + result2 = self.tester.check_random_pkts(tgen_ports,
>>> + pktnum=100,
>>> allow_miss=False, params=pkt_param)
>>> + print "\nshow port stats in testpmd for double check: \n",
>>> self.vm0_testpmd.execute_cmd('show port stats all')
>>> + self.verify(result2 != True, "VF0 failed to forward packets
>>> + to
>>> + VF1")
>>> +
>>> +#######2. test case for kernel pf and dpdk vf 2pf_2vf_1vm MAC
>>> +filter
>>> scenario.
>>> +####### kernel pf will not set MAC address and the VF will get a
>>> random
>>> +generated MAC ####### in the testpmd in VM, and then add VF mac
>>> address
>>> +in the testpmd,for example, VF_MAC1 ####### then send packets to
>>> +the
>>> VF
>>> +with the random generated MAC and the new added VF_MAC1 ####### and
>>> the
>>> +expected result is that all packets can be RXed and TXed. What's
>>> +more,
>>> send ####### packets with a wrong MAC address to the VF will not
>>> received by the VF.
>>> +
>>> + def test_kernel_2pf_2vf_1vm_mac_add_filter(self):
>>> +
>>> + self.iplinkset = False
>>> + self.setup_2pf_2vf_1vm_env(driver='')
>>> +
>>> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
>>> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
>>> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
>>> +
>>> + # Get VF0 port MAC address
>>> + pmd_vf0_mac = self.vm0_testpmd.get_port_mac(0)
>>> + vf0_setmac = "00:11:22:33:44:55"
>>> + vf0_wrongmac = "00:11:22:33:48:55"
>>> + self.vm0_testpmd.execute_cmd('port stop all')
>>> + self.vm0_testpmd.execute_cmd('port config all crc-strip on')
>>> + self.vm0_testpmd.execute_cmd('port start all')
>>> + self.vm0_testpmd.execute_cmd('set promisc all off')
>>> + ret = self.vm0_testpmd.execute_cmd('mac_addr add
>>> 0 %s' %vf0_setmac)
>>> + # check the operation is supported or not.
>>> + print ret
>>> +
>>> + self.vm0_testpmd.execute_cmd('set fwd mac')
>>> + self.vm0_testpmd.execute_cmd('start')
>>> +
>>> + time.sleep(2)
>>> +
>>> + tgen_ports = []
>>> + tx_port = self.tester.get_local_port(self.dut_ports[0])
>>> + rx_port = self.tester.get_local_port(self.dut_ports[1])
>>> + tgen_ports.append((tx_port, rx_port))
>>> + src_mac = self.tester.get_mac(tx_port)
>>> + dst_mac = pmd_vf0_mac
>>> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
>>> +
>>> + print "\nfirst send packets to the random generated VF MAC,
>>> expected result is RX packets=TX packets\n"
>>> + result1 = self.tester.check_random_pkts(tgen_ports,
>>> + pktnum=100,
>>> allow_miss=False, params=pkt_param)
>>> + print "\nshow port stats in testpmd for double check: \n",
>>> self.vm0_testpmd.execute_cmd('show port stats all')
>>> + self.verify(result1 != False, "VF0 failed to forward
>>> + packets
>>> to
>>> + VF1")
>>> +
>>> + print "\nsecondly, send packets to the new added MAC,
>>> + expected
>>> result is RX packets=TX packets\n"
>>> + dst_mac = vf0_setmac
>>> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
>>> + result2 = self.tester.check_random_pkts(tgen_ports,
>>> + pktnum=100,
>>> allow_miss=False, params=pkt_param)
>>> + print "\nshow port stats in testpmd for double check: \n",
>>> self.vm0_testpmd.execute_cmd('show port stats all')
>>> + self.verify(result2 != False, "VF0 failed to forward
>>> + packets
>>> to
>>> + VF1")
>>> +
>>> + print "\nThirdly, negative test, send packets to a wrong
>>> + MAC,
>>> expected result is RX packets=0\n"
>>> + dst_mac = vf0_wrongmac
>>> + pkt_param=[("ether", {'dst': dst_mac, 'src': src_mac})]
>>> + result3 = self.tester.check_random_pkts(tgen_ports,
>>> + pktnum=100,
>>> allow_miss=False, params=pkt_param)
>>> + print "\nshow port stats in testpmd for double check: \n",
>>> self.vm0_testpmd.execute_cmd('show port stats all')
>>> + self.verify(result3 != True, "VF0 failed to forward packets
>>> + to
>>> + VF1")
>>> +
>>> +
>>> + def tear_down(self):
>>> +
>>> + if self.setup_2pf_2vf_1vm_env_flag == 1:
>>> + self.destroy_2pf_2vf_1vm_env()
>>> +
>>> + def tear_down_all(self):
>>> +
>>> + if getattr(self, 'vm0', None):
>>> + self.vm0.stop()
>>> +
>>> + for port_id in self.dut_ports:
>>> + self.dut.destroy_sriov_vfs_by_port(port_id)
>>> +
>>> --
>>> 2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-01-19 3:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 2:49 [dts] [PATCH v2] add vf mac filter test automation script and plan Qian Xu
2016-01-19 1:44 ` Tu, LijuanX A
2016-01-19 1:53 ` Xu, Qian Q
2016-01-19 1:56 ` Tu, LijuanX A
2016-01-19 1:57 ` Xu, Qian Q
2016-01-19 3:12 ` Liu, Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).