From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9D834CE7 for ; Tue, 2 Feb 2016 07:13:33 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 01 Feb 2016 22:13:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,383,1449561600"; d="scan'208";a="894386793" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 01 Feb 2016 22:13:32 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Feb 2016 22:13:32 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.172]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0248.002; Tue, 2 Feb 2016 14:13:24 +0800 From: "Fu, JingguoX" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [DTS][PATCH V3 3/3] virt: vf to vf nic bridge test suite Thread-Index: AQHRXM0YfYf6nfTT+06fdQer+zFLeZ8YSAYw Date: Tue, 2 Feb 2016 06:13:24 +0000 Message-ID: <6BD6202160B55B409D423293115822622BA9CFF6@shsmsx102.ccr.corp.intel.com> References: <1453803123-25208-1-git-send-email-jingguox.fu@intel.com> <1453803123-25208-3-git-send-email-jingguox.fu@intel.com> <56AF1BE5.6030104@intel.com> In-Reply-To: <56AF1BE5.6030104@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] [DTS][PATCH V3 3/3] virt: vf to vf nic bridge test suite 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: Tue, 02 Feb 2016 06:13:34 -0000 Update in v4 Thanks Jingguo Fu -----Original Message----- From: Liu, Yong=20 Sent: Monday, February 01, 2016 4:49 PM To: Fu, JingguoX; dts@dpdk.org Cc: Xu, Qian Q; Pei, Yulong Subject: Re: [DTS][PATCH V3 3/3] virt: vf to vf nic bridge test suite Jingguo, Please change preparing environment code in set_up function, this will help= us to skip preparing virtual environment when debugging test case. There has been one sample in Testsuite_vxlan_sample. Pre-case setup functio= n will setup case specified environment. On 01/26/2016 06:12 PM, Jingguo Fu wrote: > Abstract: > This suite adds three cases totally for vf to vf bridge test=20 > suite, the test scenario details see the test plan , which named=20 > "0002-virt-vf-to-vf-nic-bridge-test-plan.patch". > > Test Case1: test_2vf_d2d_pktgen_stream > use pktgen-dpdk as packet generator in first vm, and use pmd=20 > driver on another vm > > Test Case2: test_2vf_d2k_pktgen_stream > use pktgen-dpdk as packet generator in first vm, and use=20 > kernel driver on another vm > > Test Case3: test_2vf_k2d_scapy_stream > use scapy as packet generator in first vm, and use pmd driver=20 > on another vm > > v3: using default pktgen as packet generator > > Signed-off-by: Jingguo Fu > --- > tests/TestSuite_vf_to_vf_nic_bridge.py | 247 ++++++++++++++++++++++++++= +++++++ > 1 file changed, 247 insertions(+) > create mode 100644 tests/TestSuite_vf_to_vf_nic_bridge.py > > diff --git a/tests/TestSuite_vf_to_vf_nic_bridge.py=20 > b/tests/TestSuite_vf_to_vf_nic_bridge.py > new file mode 100644 > index 0000000..45f3039 > --- /dev/null > +++ b/tests/TestSuite_vf_to_vf_nic_bridge.py > @@ -0,0 +1,247 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > +# All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without=20 > +# modification, are permitted provided that the following conditions=20 > +# 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=20 > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE=20 > +COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,=20 > +INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES=20 > +(INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR=20 > +SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION)=20 > +HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT,=20 > +STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE)=20 > +ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF= THE POSSIBILITY OF SUCH DAMAGE. > +""" > +DPDK Test suite > +Test vf to vf nic bridge > +""" > + > +import re > +import dts > +import time > +import pdb > + > +from test_case import TestCase > +from qemu_kvm import QEMUKvm > +from pmd_output import PmdOutput > + > +VF_NUMS_ON_ONE_PF =3D 2 > +VF_TEMP_MAC =3D "52:54:12:45:67:1%d" > +SEND_PACKET =3D 100 > + > +class TestVF2VFBridge(TestCase): > + def set_up_all(self): > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") > + self.vm0 =3D None > + self.vm1 =3D None > + > + def set_up(self): > + pass > + > + def set_up_vf_to_vf_env(self, driver=3D'default'): Suggest call this function in set_up and distinguish by test case name. =20 You can reference to set_up function vxlan_sample suite. > + self.pf_port_for_vfs =3D self.dut_ports[0] > + self.dut.restore_interfaces() > + self.dut.generate_sriov_vfs_by_port(self.pf_port_for_vfs, VF_NUM= S_ON_ONE_PF, driver=3Ddriver) > + self.sriov_vfs_ports =3D self.dut.ports_info[self.pf_port_for_vf= s]['vfs_port'] > + self.host_port_intf =3D self.dut.ports_info[self.pf_port_for_vfs= ]['intf'] > + for i in range(VF_NUMS_ON_ONE_PF): > + self.dut.send_expect('ip link set dev %s vf %d mac %s' % \ > + (self.host_port_intf, i, VF_TEMP_MAC % i= ), '#', 10) > + try: > + for port in self.sriov_vfs_ports: > + port.bind_driver('pci-stub') > + time.sleep(1) > + except Exception as e: > + raise Exception(e) > + > + vf0_prop =3D {'opt_host' : self.sriov_vfs_ports[0].pci} > + vf1_prop =3D {'opt_host' : self.sriov_vfs_ports[1].pci} > + time.sleep(1) > + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_to_vf_bridge') > + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prop) > + try: > + self.vm0_dut =3D self.vm0.start() > + if self.vm0_dut is None: > + raise Exception('Set up VM0 failed') > + except Exception as e: > + print dts.RED(str(e)) > + > + self.vm1 =3D QEMUKvm(self.dut, 'vm1', 'vf_to_vf_bridge') > + self.vm1.set_vm_device(driver=3D'pci-assign', **vf1_prop) > + try: > + self.vm1_dut =3D self.vm1.start() > + if self.vm1_dut is None: > + raise Exception('Set up VM1 failed') > + except Exception as e: > + print dts.RED(str(e)) > + > + def clear_vf_to_vf_env(self): > + if self.vm0 is not None: > + self.vm0.stop() > + self.vm0 =3D None > + if self.vm1 is not None: > + self.vm1.stop() > + self.vm1 =3D None > + if self.pf_port_for_vfs is not None: > + self.dut.destroy_sriov_vfs_by_port(self.pf_port_for_vfs) > + port =3D self.dut.ports_info[self.pf_port_for_vfs]['port'] > + port.bind_driver() > + self.pf_port_for_vfs =3D 0 > + > + def generate_pcap_pkt(self, dst, src, load, pktname=3D'flow.pcap'): > + """ > + dst: > + server: dst server object > + ether: dst mac > + ip: dst ip > + udp: dst udp protocol > + tcp: dst tcp protocal > + src: > + server: src server object > + ether: src mac > + ip: src ip > + udp: src udp protocol > + tcp: src tcp protocal > + load: > + content: pay load > + length: content length > + """ > + context =3D '[Ether(dst=3D"%s", src=3D"%s")/IP()/Raw(load=3D%s)]= ' % \ > + (str(dst['ether']), str(src['ether']),load['content']= ) > + src['server'].send_expect('scapy', '>>> ', 10) > + src['server'].send_expect('wrpcap("%s", %s)'% (pktname, context)= , '>>> ', 10) > + src['server'].send_expect('quit()', '#', 10) > + > + def prepare_pktgen(self, vm): > + vm.session.copy_file_to('./dep/tgen.tgz') > + vm.send_expect("cd /root", "#", 10) > + vm.send_expect("tar xvf tgen.tgz", '#', 20) > + > + def send_stream_pktgen(self, vm, pktname=3D'flow.pcap'): > + vm.send_expect("echo 2048 > /sys/kernel/mm/hugepages/hugepages-2= 048kB/nr_hugepages", "#", 10) > + vm.send_expect(" mount -t hugetlbfs nodedev /mnt/huge/", "#", 10= ) > + vm.send_expect("./pktgen -c 0xf -n 2 --proc-type auto -- -P -T -= m '1.0' -s 0:%s" % pktname, "", 100) > + time.sleep(60) > + vm.send_expect("set 0 rate 50", "", 20) > + time.sleep(5) > + vm.send_expect("set 0 count %d" % SEND_PACKET, "", 20) > + time.sleep(5) > + vm.send_expect("start all", "", 20) > + time.sleep(20) > + > + def stop_stream_pktgen(self, vm): > + vm.send_expect("stop all", "", 20) > + time.sleep(5) > + vm.send_expect("quit", "#", 20) > + > + def test_2vf_d2d_pktgen_stream(self): > + self.set_up_vf_to_vf_env() > + self.vm0_ports =3D self.vm0_dut.get_ports('any') > + self.vm0_pmd =3D PmdOutput(self.vm0_dut) > + self.vm0_pmd.start_testpmd('all') > + self.vm0_pmd.execute_cmd('set fwd rxonly') > + self.vm0_pmd.execute_cmd('start') > + > + self.vm1_ports =3D self.vm1_dut.get_ports('any') > + self.prepare_pktgen(self.vm1_dut) > + > + dst =3D {} > + dst['server'] =3D self.vm0_dut > + dst['ether'] =3D self.vm0_dut.ports_info[self.vm0_ports[0]]['mac= '] > + src =3D {} > + src['server'] =3D self.vm1_dut > + src['ether'] =3D self.vm1_dut.ports_info[self.vm1_ports[0]]['mac= '] > + load =3D {} > + load['content'] =3D "'X'*46" > + self.generate_pcap_pkt(dst, src, load) > + self.send_stream_pktgen(self.vm1_dut) > + recv_num =3D self.vm0_pmd.get_pmd_stats(0)['RX-packets'] > + time.sleep(1) > + self.stop_stream_pktgen(self.vm1_dut) > + self.vm0_pmd.execute_cmd('stop') > + self.vm0_pmd.execute_cmd('quit', '# ') > + > + self.verify(recv_num is SEND_PACKET,'Rx port recv error: %d'=20 > + % recv_num) > + > + def test_2vf_d2k_pktgen_stream(self): > + self.set_up_vf_to_vf_env() > + self.vm0_dut.restore_interfaces() > + self.vm0_ports =3D self.vm0_dut.get_ports('any') > + vf0_intf =3D self.vm0_dut.ports_info[self.vm0_ports[0]]['intf'] > + self.vm0_dut.send_expect('tcpdump -i %s -s 1000 > /dev/null=20 > + &' % vf0_intf, '#', 30) > + > + self.vm1_ports =3D self.vm1_dut.get_ports('any') > + self.prepare_pktgen(self.vm1_dut) > + > + dst =3D {} > + dst['server'] =3D self.vm0_dut > + dst['ether'] =3D self.vm0_dut.ports_info[self.vm0_ports[0]]['mac= '] > + src =3D {} > + src['server'] =3D self.vm1_dut > + src['ether'] =3D self.vm1_dut.ports_info[self.vm1_ports[0]]['mac= '] > + load =3D {} > + load['content'] =3D "'X'*46" > + self.generate_pcap_pkt(dst, src, load) > + self.send_stream_pktgen(self.vm1_dut) > + self.stop_stream_pktgen(self.vm1_dut) > + > + recv_tcpdump =3D self.vm0_dut.send_expect('killall tcpdump', '#'= , 30) > + time.sleep(5) > + recv_pattern =3D re.compile("(\d+) packets captured") > + recv_info =3D recv_pattern.search(recv_tcpdump) > + recv_str =3D recv_info.group(0).split(' ')[0] > + recv_number =3D int(recv_str, 10) > + self.vm0_dut.bind_interfaces_linux(dts.drivername) > + > + self.verify(recv_number is SEND_PACKET, 'Rx port recv error:=20 > + %d' % recv_number) > + > + def test_2vf_k2d_scapy_stream(self): > + self.set_up_vf_to_vf_env() > + self.vm0_ports =3D self.vm0_dut.get_ports('any') > + self.vm0_pmd =3D PmdOutput(self.vm0_dut) > + self.vm0_pmd.start_testpmd('all') > + self.vm0_pmd.execute_cmd('set fwd rxonly') > + self.vm0_pmd.execute_cmd('start') > + self.vm0_pmd.execute_cmd('clear port stats all') > + > + self.vm1_ports =3D self.vm1_dut.get_ports('any') > + self.vm1_dut.restore_interfaces() > + vf1_intf =3D self.vm1_dut.ports_info[self.vm1_ports[0]]['intf'] > + > + dst_mac =3D self.vm0_dut.ports_info[self.vm0_ports[0]]['mac'] > + src_mac =3D self.vm1_dut.ports_info[self.vm1_ports[0]]['mac'] > + pkt_content =3D 'Ether(dst=3D"%s", src=3D"%s")/IP()/Raw(load=3D"= X"*46)' % \ > + (dst_mac, src_mac) > + self.vm1_dut.send_expect('scapy', '>>> ', 10) > + self.vm1_dut.send_expect('sendp([%s], iface=3D"%s", count=3D%d)'= % (pkt_content, vf1_intf, SEND_PACKET), '>>> ', 30) > + self.vm1_dut.send_expect('quit()', '# ', 10) > + self.vm1_dut.bind_interfaces_linux(dts.drivername) > + recv_num =3D self.vm0_pmd.get_pmd_stats(0)['RX-packets'] > + self.vm0_pmd.execute_cmd('stop') > + self.vm0_pmd.execute_cmd('quit', '# ') > + > + self.verify(recv_num is SEND_PACKET, 'Rx port recv error: %d'=20 > + % recv_num) > + > + def tear_down(self): > + self.clear_vf_to_vf_env() > + > + def tear_down_all(self): > + pass