From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id C730E58D6 for ; Mon, 22 Feb 2016 06:52:23 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 21 Feb 2016 21:52:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,483,1449561600"; d="scan'208";a="920981239" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 21 Feb 2016 21:52:24 -0800 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 21 Feb 2016 21:52:22 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 21 Feb 2016 21:52:22 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.172]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.249]) with mapi id 14.03.0248.002; Mon, 22 Feb 2016 13:52:19 +0800 From: "Pei, Yulong" To: "Tu, LijuanX A" , "dts@dpdk.org" , "Xu, Qian Q" Thread-Topic: [dts][PATCH v2]tests: add checksum offload and tso test scripts test_plans: add test plan for checksum offload and tso Thread-Index: AQHRag7q5+rfwT2v+0mNS/+d6EyT8p83lcFQ Date: Mon, 22 Feb 2016 05:52:19 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F0035301FC@shsmsx102.ccr.corp.intel.com> References: <1455773760-2336-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1455773760-2336-1-git-send-email-lijuanx.a.tu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTFjMTg5ZjUtYTAzNi00OWE5LWI4ZWYtYTBkMWU1ZWJiOWUxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicytHbFM4ZWFXMjkwM2x2S3hWRm5ITmRwMStlT2pxZjhUK2hVWHRBVEJFdz0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH v2]tests: add checksum offload and tso test scripts test_plans: add test plan for checksum offload and tso X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2016 05:52:24 -0000 Hi Lijuan, 1. I only saw "checksum on the transmit packet" test, where is "checksum o= n the receive packet" test ? 2. where is tso test plan ? Best Regards Yulong Pei -----Original Message----- From: Tu, LijuanX A=20 Sent: Thursday, February 18, 2016 1:36 PM To: dts@dpdk.org; Xu, Qian Q ; Pei, Yulong Cc: Lijuan Tu ; Tu, LijuanX A Subject: [dts][PATCH v2]tests: add checksum offload and tso test scripts te= st_plans: add test plan for checksum offload and tso From: Lijuan Tu Signed-off-by: Lijuan Tu --- test_plans/vf_offload.rst | 178 ++++++++++++++++++++ tests/TestSuite_vf_offload.py | 369 ++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 547 insertions(+) create mode 100644 test_plans/vf_offload.rst create mode 100644 tests/Tes= tSuite_vf_offload.py diff --git a/test_plans/vf_offload.rst b/test_plans/vf_offload.rst new file= mode 100644 index 0000000..38956e6 --- /dev/null +++ b/test_plans/vf_offload.rst @@ -0,0 +1,178 @@ +Prerequisites +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +Create Two VF interfaces from two kernel PF ineterfaces, and then attach t= hem to VM. +Start testpmd on vm:: + + + ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x7 -n 1 -- -i=20 + --portmask=3D0x1 --enable-rx-cksum --txqflags=3D0 + --crc-strip --port-topology=3Dloop + + +Test Case: Insert IPv4/IPv6 UDP/TCP/SCTP checksum on the transmit=20 +packet=20 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +=3D + +Setup the ``csum`` forwarding mode:: + + testpmd> set fwd csum + Set csum packet forwarding mode + +Enable the IPv4/UDP/TCP/SCTP checksum offload on port 0:: + + testpmd> tx_checksum set 0xf 0 + testpmd> start + csum packet forwarding - CRC stripping disabled - packets/burst=3D32 + nb forwarding cores=3D1 - nb forwarding ports=3D10 + RX queues=3D1 - RX desc=3D128 - RX free threshold=3D64 + RX threshold registers: pthresh=3D8 hthresh=3D8 wthresh=3D4 + TX queues=3D1 - TX desc=3D512 - TX free threshold=3D0 + TX threshold registers: pthresh=3D32 hthresh=3D8 wthresh=3D8 + +Configure the traffic generator to send the multiple packets for the=20 +following +combination: IPv4/UDP, IPv4/TCP, IPv4/SCTP, IPv6/UDP, IPv6/TCP. + +Except that SCTP header + payload length must be a multiple of 4 bytes. +IPv4 + UDP/TCP packet length can range from the minimum length to 1518 byt= es. + +Then verify that the same number of packet are correctly received on=20 +the traffic generator side. And IPv4 checksum, TCP checksum, UDP=20 +checksum, SCTP CRC32c need be validated as pass by the IXIA. + +The IPv4 source address will not be changed by testpmd. + + +Test Case: Do not insert IPv4/IPv6 UDP/TCP checksum on the transmit=20 +packet=20 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +=3D=3D=3D + +Setup the ``csum`` forwarding mode:: + + testpmd> set fwd csum + Set csum packet forwarding mode + +Disable the IPv4/UDP/TCP/SCTP checksum offload on port 0:: + + testpmd> tx_checksum set 0x0 0 + testpmd> start + csum packet forwarding - CRC stripping disabled - packets/burst=3D32 + nb forwarding cores=3D1 - nb forwarding ports=3D10 + RX queues=3D1 - RX desc=3D128 - RX free threshold=3D64 + RX threshold registers: pthresh=3D8 hthresh=3D8 wthresh=3D4 + TX queues=3D1 - TX desc=3D512 - TX free threshold=3D0 + TX threshold registers: pthresh=3D32 hthresh=3D8 wthresh=3D8 + +Configure the traffic generator to send the multiple packets for the=20 +follwing +combination: IPv4/UDP, IPv4/TCP, IPv6/UDP, IPv6/TCP. + +IPv4 + UDP/TCP packet length can range from the minimum length to 1518 byt= es. + +Then verify that the same number of packet are correctly received on=20 +the traffic generator side. And IPv4 checksum, TCP checksum, UDP=20 +checksum need be validated as pass by the IXIA. + +The first byte of source IPv4 address will be increment by testpmd. The=20 +checksum is indeed recalculated by software algorithms. + + + + +If you start vm by manual ,you can refer to below commands Suppose PF=20 +is 0000:04:00.0. Generate 2VFs using commands below and make them in pci-s= tub mods. + +1. Get the pci device id of DUT:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection'=20 + if=3Dens261f0 drv=3Dixgbe unused=3Digb_uio + +2. Create 2 VFs from 2 PFs:: + + echo 2 > /sys/bus/pci/devices/0000\:04\:00.0/sriov_numvfs + +VFs 04:10.0 & 04:10.1 have been created:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f0 drv=3Dixgbe unused=3D + 0000:04:10.0 '82599 Ethernet Controller Virtual Function' if=3Denp4s16= drv=3Dixgbevf unused=3D + 0000:04:10.1 '82599 Ethernet Controller Virtual Function'=20 + if=3Denp4s16f1 drv=3Dixgbevf unused=3D + +3. detach VFs from the host, bind them to pci-stub driver:: + + /sbin/modprobe pci-stub + echo "8086 10ed" > /sys/bus/pci/drivers/pci-stub/new_id + echo 0000:04:10.0 > /sys/bus/pci/devices/0000\:04\:10.0/driver/unbind + echo 0000:04:10.0 > /sys/bus/pci/drivers/pci-stub/bind + echo 0000:04:10.1 > /sys/bus/pci/devices/0000\:04\:10.1/driver/unbind + echo 0000:04:10.1 > /sys/bus/pci/drivers/pci-stub/bind + +or using the following more easy way:: + + ./dpdk_nic_bind.py -b pci-stub 04:10.0 04:10.1 + +it can be seen that VFs 04:10.0 & 04:10.1 's drv is pci-stub:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f0 drv=3Dixgbe unused=3Dvfio-pci + 0000:04:10.0 '82599 Ethernet Controller Virtual Function' if=3D drv=3D= pci-stub unused=3Dixgbevf,vfio-pci + 0000:04:10.1 '82599 Ethernet Controller Virtual Function' if=3D=20 + drv=3Dpci-stub unused=3Dixgbevf,vfio-pci + +4. Do not forget bring up PFs:: + + ifconfig ens261f0 up + +Passthrough VFs 04:10.0 & 04:10.1 to vm0, and start vm0, you can refer to = below command:: + + taskset -c 6-12 qemu-system-x86_64 \ + -enable-kvm -m 8192 -smp 6 -cpu host -name dpdk15-vm1 \ + -drive file=3D/home/image/fedora23.img \ + -netdev tap,id=3Dhostnet1,ifname=3Dtap1,script=3D/etc/qemu-ifup,vhost= =3Don \ + -device rtl8139,netdev=3Dhostnet1,id=3Dnet1,mac=3D52:54:01:6b:10:61,bu= s=3Dpci.0,addr=3D0xa \ + -device pci-assign,bus=3Dpci.0,addr=3D0x6,host=3D04:10.0 \ + -device pci-assign,bus=3Dpci.0,addr=3D0x7,host=3D04:10.1 \ + -vnc :11 -daemonize + +the /etc/qemu-ifup can be below script, need you to create first:: + + #!/bin/sh + set -x + switch=3Dbr0 + if [ -n "$1" ];then + /usr/sbin/tunctl -u `whoami` -t $1 + /sbin/ip link set $1 up + sleep 0.5s + /usr/sbin/brctl addif $switch $1 + exit 0 + else + echo "Error: no interface specified" + exit 1 + fi + +Set up bridge br0 before create /etc/qemu-ifup, for example:: + + cd /etc/sysconfig/network-scripts + vim ifcfg-enp1s0f0 + + HWADDR=3D00:1e:67:fb:0f:d4 + TYPE=3DEthernet + NAME=3Denp1s0f0 + ONBOOT=3Dyes + DEVICE=3Denp1s0f0 + NM_CONTROLLED=3Dno + BRIDGE=3Dbr0 + + vim ifcfg-br0 + TYPE=3DBridge + DEVICE=3Dbr0 + ONBOOT=3Dyes + NM_CONTROLLED=3Dno + BOOTPROTO=3Ddhcp + HOSTNAME=3D"dpdk-test58" + +Login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &=20 +00:07.0, bind them to igb_uio driver, and then start testpmd, set it in=20 +mac forward mode:: + + ./tools/dpdk_nic_bind.py --bind=3Digb_uio 00:06.0 00:07.0 + ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -- -i + testpmd-> set fwd mac + testpmd-> start diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py = new file mode 100644 index 0000000..ccae3c6 --- /dev/null +++ b/tests/TestSuite_vf_offload.py @@ -0,0 +1,369 @@ +# + +import re +import time + +import dts +from qemu_kvm import QEMUKvm +from test_case import TestCase +from pmd_output import PmdOutput +from utils import RED, GREEN +from net_device import NetDevice +from crb import Crb +from scapy.all import * +from settings import HEADER_SIZE +VM_CORES_MASK =3D 'all' + +class TestVfOffload(TestCase): + + def set_up_all(self): + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) > 1, "Insufficient ports") + self.vm0 =3D None + self.setup_2pf_2vf_1vm_env_flag =3D 0 + self.setup_2pf_2vf_1vm_env(driver=3D'') + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.portMask =3D dts.create_mask([self.vm0_dut_ports[0]]) + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + + def set_up(self): + pass + + def setup_2pf_2vf_1vm_env(self, driver=3D'default'): + + self.used_dut_port_0 =3D self.dut_ports[0] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, drive= r=3Ddriver) + self.sriov_vfs_port_0 =3D self.dut.ports_info[self.used_dut_port_0= ]['vfs_port'] + self.used_dut_port_1 =3D self.dut_ports[1] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, drive= r=3Ddriver) + self.sriov_vfs_port_1 =3D=20 + 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 =3D {'opt_host': self.sriov_vfs_port_0[0].pci} + vf1_prop =3D {'opt_host': self.sriov_vfs_port_1[0].pci} + + if driver =3D=3D 'igb_uio': + # start testpmd without the two VFs on the host + self.host_testpmd =3D PmdOutput(self.dut) + eal_param =3D '-b %(vf0)s -b %(vf1)s' % {'vf0': self.sriov= _vfs_port_0[0].pci, + 'vf1': self.sriov_v= fs_port_1[0].pci} + self.host_testpmd.start_testpmd("1S/2C/2T",=20 + eal_param=3Deal_param) + + # set up VM0 ENV + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_port_start_stop') + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prop) + self.vm0.set_vm_device(driver=3D'pci-assign', **vf1_prop) + self.vm_dut_0 =3D self.vm0.start() + if self.vm_dut_0 is None: + raise Exception("Set up VM0 ENV failed!") + + self.setup_2pf_2vf_1vm_env_flag =3D 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 =3D None + self.vm0_dut_ports =3D None + #destroy vm0 + self.vm0.stop() + self.vm0 =3D None + + if getattr(self, 'host_testpmd', None): + self.host_testpmd.execute_cmd('quit', '# ') + self.host_testpmd =3D None + + if getattr(self, 'used_dut_port_0', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) + port =3D self.dut.ports_info[self.used_dut_port_0]['port'] + port.bind_driver() + self.used_dut_port_0 =3D None + + if getattr(self, 'used_dut_port_1', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1) + port =3D self.dut.ports_info[self.used_dut_port_1]['port'] + port.bind_driver() + self.used_dut_port_1 =3D None + + for port_id in self.dut_ports: + port =3D self.dut.ports_info[port_id]['port'] + port.bind_driver() + + self.setup_2pf_2vf_1vm_env_flag =3D 0 + + def checksum_enablehw(self, port, dut): + dut.send_expect("csum set ip hw %d" % port, "testpmd>") + dut.send_expect("csum set udp hw %d" % port, "testpmd>") + dut.send_expect("csum set tcp hw %d" % port, "testpmd>") + dut.send_expect("csum set sctp hw %d" % port, "testpmd>") + + def checksum_enablesw(self, port, dut): + dut.send_expect("csum set ip sw %d" % port, "testpmd>") + dut.send_expect("csum set udp sw %d" % port, "testpmd>") + dut.send_expect("csum set tcp sw %d" % port, "testpmd>") + dut.send_expect("csum set sctp sw %d" % port, "testpmd>") + + def checksum_validate(self, packets_sent, packets_expected): + """ + Validate the checksum. + """ + tx_interface =3D self.tester.get_interface(self.tester.get_local_p= ort(self.dut_ports[0])) + rx_interface =3D=20 + self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0] + )) + + sniff_src =3D self.vm0_testpmd.get_port_mac(0) + checksum_pattern =3D re.compile("chksum.*=3D.*(0x[0-9a-z]+)") + + chksum =3D dict() + result =3D dict() + + self.tester.send_expect("scapy", ">>> ") + + for packet_type in packets_expected.keys(): + self.tester.send_expect("p =3D %s" % packets_expected[packet_t= ype], ">>>") + out =3D self.tester.send_expect("p.show2()", ">>>") + chksums =3D checksum_pattern.findall(out) + chksum[packet_type] =3D chksums + print packet_type, ": ", chksums + + self.tester.send_expect("exit()", "#") + + self.tester.scapy_background() + self.tester.scapy_append('p =3D sniff(filter=3D"ether src %s", ifa= ce=3D"%s", count=3D%d)' % (sniff_src, rx_interface, len(packets_sent))) + self.tester.scapy_append('nr_packets=3Dlen(p)') + self.tester.scapy_append('reslist =3D [p[i].sprintf("%IP.chksum%;%= TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]') + self.tester.scapy_append('import string') + self.tester.scapy_append('RESULT =3D string.join(reslist, ",")') + + # Send packet. + self.tester.scapy_foreground() + + for packet_type in packets_sent.keys(): + self.tester.scapy_append('sendp([%s], iface=3D"%s")' %=20 + (packets_sent[packet_type], tx_interface)) + + self.tester.scapy_execute() + out =3D self.tester.scapy_get_result() + packets_received =3D out.split(',') + self.verify(len(packets_sent) =3D=3D len(packets_received),=20 + "Unexpected Packets Drop") + + for packet_received in packets_received: + ip_checksum, tcp_checksum, udp_checksup, sctp_checksum =3D pac= ket_received.split(';') + print "ip_checksum: ", ip_checksum, "tcp_checksum:, ",=20 + tcp_checksum, "udp_checksup: ", udp_checksup, "sctp_checksum: ",=20 + sctp_checksum + + packet_type =3D '' + l4_checksum =3D '' + if tcp_checksum !=3D '??': + packet_type =3D 'TCP' + l4_checksum =3D tcp_checksum + elif udp_checksup !=3D '??': + packet_type =3D 'UDP' + l4_checksum =3D udp_checksup + elif sctp_checksum !=3D '??': + packet_type =3D 'SCTP' + l4_checksum =3D sctp_checksum + + if ip_checksum !=3D '??': + packet_type =3D 'IP/' + packet_type + if chksum[packet_type] !=3D [ip_checksum, l4_checksum]: + result[packet_type] =3D packet_type + " checksum error= " + else: + packet_type =3D 'IPv6/' + packet_type + if chksum[packet_type] !=3D [l4_checksum]: + result[packet_type] =3D packet_type + " checksum error= " + + return result + + def test_checksum_offload_enable(self): + """ + Insert IPv4/IPv6 UDP/TCP/SCTP checksum on the transmit packet. + Enable Checksum offload. + Verify that the same number of packet are correctly received on th= e + traffic generator side. + """ + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=3D%s " % + (self.portMask) + "--disable-hw-vlan= --enable-rx-cksum " + "--txqflags=3D0 " + + "--crc-strip --port-topology=3Dloop"= ) + self.vm0_testpmd.execute_cmd('set fwd csum') + + time.sleep(2) + + mac =3D self.vm0_testpmd.get_port_mac(0) + + pkts =3D {'IP/UDP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")/= IP(chksum=3D0x0)/UDP(chksum=3D0xf)/("X"*46)' % mac, + 'IP/TCP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")/IP= (chksum=3D0x0)/TCP(chksum=3D0xf)/("X"*46)' % mac, + 'IP/SCTP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")/I= P(chksum=3D0x0)/SCTP(chksum=3D0xf)/("X"*48)' % mac, + 'IPv6/UDP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")/= IPv6(src=3D"::1")/UDP(chksum=3D0xf)/("X"*46)' % mac, + 'IPv6/TCP': 'Ether(dst=3D"%s",=20 + src=3D"52:00:00:00:00:00")/IPv6(src=3D"::1")/TCP(chksum=3D0xf)/("X"*46)' = %=20 + mac} + + pkts_ref =3D {'IP/UDP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%= s")/IP(src=3D"127.0.0.2")/UDP()/("X"*46)' % mac, + 'IP/TCP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%s"= )/IP(src=3D"127.0.0.2")/TCP()/("X"*46)' % mac, + 'IP/SCTP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%s= ")/IP(src=3D"127.0.0.2")/SCTP()/("X"*48)' % mac, + 'IPv6/UDP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%= s")/IPv6(src=3D"::2")/UDP()/("X"*46)' % mac, + 'IPv6/TCP': 'Ether(dst=3D"02:00:00:00:00:00",=20 + src=3D"%s")/IPv6(src=3D"::2")/TCP()/("X"*46)' % mac} + + if self.nic in ['redrockcanyou', 'atwood']: + del pkts['IP/SCTP'] + del pkts_ref['IP/SCTP'] + + self.checksum_enablehw(0,self.vm_dut_0) + + self.vm0_testpmd.execute_cmd('start') + result =3D self.checksum_validate(pkts, pkts_ref) + self.vm0_testpmd.execute_cmd('stop') + + self.verify(len(result) =3D=3D 0, string.join(result.values(),=20 + ",")) + + def _test_checksum_offload_disable(self): + """ + Do not insert IPv4/IPv6 UDP/TCP checksum on the transmit packet. + Disable Checksum offload. + Verify that the same number of packet are correctly received on + the traffic generator side. + """ + + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=3D%s " % + (self.portMask) + "--disable-hw-vlan= --enable-rx-cksum " + + "--crc-strip --port-topology=3Dloop"= ) + self.vm0_testpmd.execute_cmd('set fwd csum') + + time.sleep(2) + + + mac =3D self.vm0_testpmd.get_port_mac(0) + sndIP =3D '10.0.0.1' + sndIPv6 =3D '::1' + sndPkts =3D {'IP/UDP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00= ")/IP(src=3D"%s",chksum=3D0x0)/UDP(chksum=3D0xf)/("X"*46)' % (mac, sndIP), + 'IP/TCP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")= /IP(src=3D"%s",chksum=3D0x0)/TCP(chksum=3D0xf)/("X"*46)' % (mac, sndIP), + 'IPv6/UDP': 'Ether(dst=3D"%s", src=3D"52:00:00:00:00:00= ")/IPv6(src=3D"%s")/UDP(chksum=3D0xf)/("X"*46)' % (mac, sndIPv6), + 'IPv6/TCP': 'Ether(dst=3D"%s",=20 + src=3D"52:00:00:00:00:00")/IPv6(src=3D"%s")/TCP(chksum=3D0xf)/("X"*46)' %= =20 + (mac, sndIPv6)} + + expIP =3D "10.0.0.2" + expIPv6 =3D '::2' + expPkts =3D {'IP/UDP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%s= ")/IP(src=3D"%s")/UDP()/("X"*46)' % (mac, expIP), + 'IP/TCP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%s")= /IP(src=3D"%s")/TCP()/("X"*46)' % (mac, expIP), + 'IPv6/UDP': 'Ether(dst=3D"02:00:00:00:00:00", src=3D"%s= ")/IPv6(src=3D"%s")/UDP()/("X"*46)' % (mac, expIPv6), + 'IPv6/TCP': 'Ether(dst=3D"02:00:00:00:00:00",=20 + src=3D"%s")/IPv6(src=3D"%s")/TCP()/("X"*46)' % (mac, expIPv6)} + + self.vm0_testpmd.execute_cmd('start') + result =3D self.checksum_validate(sndPkts, expPkts) + self.vm0_testpmd.execute_cmd('stop') + + self.verify(len(result) =3D=3D 0, string.join(result.values(),=20 + ",")) + + def tcpdump_start_sniffing(self, ifaces=3D[]): + """ + Starts tcpdump in the background to sniff the tester interface whe= re + the packets are transmitted to and from the self.dut. + All the captured packets are going to be stored in a file for a + post-analysis. + """ + + for iface in ifaces: + command =3D ('tcpdump -w tcpdump_{0}.pcap -i {0} 2>tcpdump_{0}= .out &').format(iface) + self.tester.send_expect('rm -f tcpdump_{0}.pcap', '#').format(= iface) + self.tester.send_expect(command, '#') + + def tcpdump_stop_sniff(self): + """ + Stops the tcpdump process running in the background. + """ + self.tester.send_expect('killall tcpdump', '#') + time.sleep(1) + self.tester.send_expect('echo "Cleaning buffer"', '#') + time.sleep(1) + + def tcpdump_command(self, command): + """ + Sends a tcpdump related command and returns an integer from the ou= tput + """ + + result =3D self.tester.send_expect(command, '#') + print result + return int(result.strip()) + + def number_of_packets(self, iface): + """ + By reading the file generated by tcpdump it counts how many packet= s were + forwarded by the sample app and received in the self.tester. The s= ample app + will add a known MAC address for the test to look for. + """ + + command =3D ('tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/dev/= null | ' + + 'grep -c "seq"') + return self.tcpdump_command(command.format(**locals())) + + def test_tso(self): + """ + TSO IPv4 TCP, IPv6 TCP, VXLan testing + """ + import pdb + pdb.set_trace() + tx_interface =3D self.tester.get_interface(self.tester.get_local_p= ort(self.dut_ports[0])) + rx_interface =3D=20 + self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1] + )) + + self.frame_sizes =3D [128, 1458] + self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEA= DER_SIZE['tcp'] + padding =3D self.frame_sizes[0] - self.headers_size + + self.tester.send_expect("ethtool -K %s rx off tx off tso off gso o= ff gro off lro off" % tx_interface, "# ") + self.tester.send_expect("ip l set %s up" % tx_interface, "# ") + + self.portMask =3D dts.create_mask([self.vm0_dut_ports[0]]) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=3D%s " % + (self.portMask) + "--enable-rx-cksum= " + + "--txqflags=3D0 " +=20 + "--crc-strip=20 + --port-topology=3Dloop") + + mac =3D self.vm0_testpmd.get_port_mac(0) + + self.checksum_enablehw(0,self.vm_dut_0) + self.vm0_testpmd.execute_cmd("tso set 800 %d" % self.vm0_dut_ports= [1]) + self.vm0_testpmd.execute_cmd("set fwd csum") + self.vm0_testpmd.execute_cmd("start") + + self.tester.scapy_foreground() + time.sleep(5) + + # IPv4 tcp test + + self.tcpdump_start_sniffing([tx_interface, rx_interface]) + self.tester.scapy_append('sendp([Ether(dst=3D"%s",src=3D"52:00:00:= 00:00:00")/IP(src=3D"192.168.1.1",dst=3D"192.168.1.2")/TCP(sport=3D1021,dpo= rt=3D1021)/("X"*%s)], iface=3D"%s")' % (mac, padding, tx_interface)) + out =3D self.tester.scapy_execute() + out =3D self.vm0_testpmd.execute_cmd("show port stats all") + print out + self.tcpdump_stop_sniff() + rx_stats =3D self.number_of_packets(rx_interface) + if (rx_stats =3D=3D 2): + self.verify(1, "Pass") + + # IPv6 tcp test + + self.tcpdump_start_sniffing([tx_interface, rx_interface]) + self.tester.scapy_append('sendp([Ether(dst=3D"%s", src=3D"52:00:00= :00:00:00")/IPv6(src=3D"FE80:0:0:0:200:1FF:FE00:200", dst=3D"3555:5555:6666= :6666:7777:7777:8888:8888")/TCP(sport=3D1021,dport=3D1021)/("X"*%s)], iface= =3D"%s")' % (mac, padding, tx_interface)) + out =3D self.tester.scapy_execute() + out =3D self.vm0_testpmd.execute_cmd("show port stats all") + print out + self.tcpdump_stop_sniff() + rx_stats =3D self.number_of_packets(rx_interface) + if (rx_stats =3D=3D 2): + self.verify(1, "Pass") + + + def tear_down(self): + pass + + def tear_down_all(self): + print "tear_down_all" + if self.setup_2pf_2vf_1vm_env_flag =3D=3D 1: + self.destroy_2pf_2vf_1vm_env() -- 2.5.0