From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 97F9B5A6B for ; Fri, 10 Jul 2015 07:27:57 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 09 Jul 2015 22:27:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,445,1432623600"; d="scan'208";a="521815692" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by FMSMGA003.fm.intel.com with ESMTP; 09 Jul 2015 22:27:56 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 10 Jul 2015 13:27:50 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.246]) with mapi id 14.03.0224.002; Fri, 10 Jul 2015 13:27:49 +0800 From: "Xu, Qian Q" To: =?us-ascii?Q?y=7F=40ecsmtp=2Esh=2Eintel=2Ecom?= , "dts@dpdk.org" Thread-Topic: [dts][PATCH 5/5] add vhost-user one vm sample case Thread-Index: AQHQutD3LJEobdsBOk63+0/BOapCap3ULHJA Date: Fri, 10 Jul 2015 05:27:48 +0000 Message-ID: <82F45D86ADE5454A95A89742C8D1410E01D7A8CF@shsmsx102.ccr.corp.intel.com> References: <1436505936-31370-1-git-send-email-y> In-Reply-To: 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] [PATCH 5/5] add vhost-user one vm sample case 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: Fri, 10 Jul 2015 05:27:58 -0000 Sorry, the "From mail" is a typo, and the mail is sent from me.=20 Thanks Qian -----Original Message----- From: y=7F@ecsmtp.sh.intel.com [mailto:y=7F@ecsmtp.sh.intel.com]=20 Sent: Friday, July 10, 2015 1:26 PM To: dts@dpdk.org Cc: Xu, Qian Q Subject: [dts][PATCH 5/5] add vhost-user one vm sample case From: Qian Xu Signed-off-by: Qian Xu diff --git a/tests/TestSuite_vhost_sample.py b/tests/TestSuite_vhost_sample= .py new file mode 100644 index 0000000..2769c3a --- /dev/null +++ b/tests/TestSuite_vhost_sample.py @@ -0,0 +1,398 @@ +#BSD LICENSE +# +# Copyright(c) 2010-2015 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 COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. + +Vhost user one-copy sample test suite. +""" +import os +import dts +import string +import re +import time +from scapy.utils import wrpcap, rdpcap +from test_case import TestCase +from exception import VerifyFailure +from settings import HEADER_SIZE +from etgen import IxiaPacketGenerator +from qemu_kvm import QEMUKvm + +class TestVhostSample(TestCase, IxiaPacketGenerator): +=09 + def set_up_all(self): + # To Extend IXIA packet generator method, call the tester's method. + =09 +self.tester.extend_external_packet_generator(TestVhostSample,self) + + # Change config file,no need now since the default is y.=20 + #self.dut.send_expect("sed -i -e=20 + 's/CONFIG_RTE_LIBRTE_VHOST=3D.*$/CONFIG_RTE_LIBRTE_VHOST=3Dy/'=20 + ./config/common_linuxapp", "# ", 30) +=09 + # Build target with modified config file + self.dut.build_install_dpdk(self.target) +=09 + + # Get and verify the ports + self.dut_ports =3D self.dut.get_ports() + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports for=20 +testing") + + # Get the port's socket + self.pf =3D self.dut_ports[0] + netdev =3D self.dut.ports_info[self.pf]['port'] + self.socket =3D netdev.get_nic_socket() + self.cores =3D self.dut.get_core_list("1S/2C/1T", socket=3Dself.socket) + =09 + # Set the params of vhost sample=20 + self.vhost_app =3D "./examples/vhost/build/vhost-switch" + self.zero_copy =3D 0 + self.vm2vm =3D 0 + self.jumbo =3D 0 + #self.rxq =3D 1 + # Using file to save the vhost sample output since in jumboframe case, t= here will be lots of output + self.vhost_test =3D self.vhost_app + " -c %s -n %d --socket-mem 1024,102= 4 -- -p 0x1 --mergeable %d --zero-copy %d --vm2vm %d 2 > ./vhost.out &" + # build the vhost sample in vhost-user mode. =09 + self.dut.send_expect("sed -i -e 's/define MAX_QUEUES 512/define MAX_QUEU= ES 128/' ./examples/vhost/main.c", "#") + out =3D self.dut.send_expect("make -C examples/vhost", "#") + self.verify("Error" not in out, "compilation error") + self.verify("No such file" not in out, "Not found file error") +=09 + # Define the virtio/VM variables + self.virtio1 =3D "eth1" + self.virtio2 =3D "eth2" + self.virtio1_mac =3D "52:54:00:00:00:01" + self.virtio2_mac =3D "52:54:00:00:00:02" + self.src1 =3D "192.168.4.1" + self.src2 =3D "192.168.3.1" + self.dst1 =3D "192.168.3.1" + self.dst2 =3D "192.168.4.1" + self.vm_dut =3D None + =09 + self.header_row =3D ["Test","Mode", "Frame", "Mpps", "% linerate"] + self.memory_channel =3D 4 +=20 + def set_up(self): + ###################################### + ## Run before each test case. + ###################################### + # Launch vhost sample using default params + =09 + if "jumbo" in self.running_case: + self.jumbo =3D 1 + self.frame_sizes =3D [68,128,256,512,1024,1280,1518,1522,2048,5000,9000= ] + #self.frame_sizes =3D [256,5000] + self.vm_testpmd =3D "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3= " \ + + " -- -i --txqflags=3D0xf00 --disable-hw-vlan-f= ilter --max-pkt-len 9600" =09 + else:=20 + self.jumbo =3D 0 + self.frame_sizes =3D [68,128,256,512,1024,1280,1518] + #self.frame_sizes =3D [68, 128] + self.vm_testpmd =3D "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3= " \ + + " -- -i --txqflags=3D0xf00 --disable-hw-vlan-f= ilter" + self.dut.send_expect("rm -rf ./vhost.out", "#") + =09 + self.launch_vhost_sample() + =09 + print "Start VM with 2virtio\n" + # start VM with 2virtio=09 + self.start_onevm() + + + def launch_vhost_sample(self): + #################################################################### + ## Launch the vhost sample with different parameters + #################################################################### =09 + self.coremask =3D dts.create_mask(self.cores) + self.vhostapp_testcmd =3D self.vhost_test %(self.coremask, self.memory_c= hannel, self.jumbo, self.zero_copy, + self.vm2vm) +# self.dut.send_expect(self.vhostapp_testcmd, "VHOST_CONFIG: bind to vhos= t-net", 120) + self.dut.send_expect(self.vhostapp_testcmd, "# ", 40) + time.sleep(30) + try:=20 + print "Launch vhost sample\n" + out =3D self.dut.send_expect("cat ./vhost.out", "VHOST_CONFIG: bind to = vhost-net", 20) + if "Error" in out: + raise Exception("Launch vhost sample failed") + except Exception as e: + print dts.RED("Failed to launch vhost sample: %s" %str(e)) =09 + self.dut.send_expect("rm -rf ./vhost-net" ,"#", 20) +=09 + def start_onevm(self): + ##################################### + ## Start One VM with 2 virtio devices + ##################################### + =09 + self.vm =3D QEMUKvm(self.dut, 'vm0', 'vhost_sample') + #qemu_path =3D "/home/qxu10/qemu-2.2.0/x86_64-softmmu/qemu-system-x86_64= " + #self.vm.set_qemu_emulator(qemu_path) + if "user" in self.running_case: + vm_params =3D{} + vm_params['driver'] =3D 'vhost-user' + vm_params['opt_path'] =3D './vhost-net' + vm_params['opt_mac'] =3D self.virtio1_mac + self.vm.set_vm_device(**vm_params) + vm_params['opt_mac'] =3D self.virtio2_mac + self.vm.set_vm_device(**vm_params) + + try:=20 + self.vm_dut =3D self.vm.start(auto_portmap=3DFalse) + if self.vm_dut is None: + raise Exception("Set up VM ENV failed") + except Exception as e: + print dts.RED("Failure for %s" % str(e)) + =09 + return True +=09 + def vm_testpmd_start(self): + #######################################################=20 + ## Start testpmd in vm + ####################################################### + if self.vm_dut is not None: + # Start testpmd with user + self.vm_dut.send_expect(self.vm_testpmd, "testpmd>", 20) + # Start tx_first + self.vm_dut.send_expect("start tx_first", "testpmd>") + + def clear_vhost_env(self): + ######################################################### + ## Kill all vhost sample, shutdown VM + ####################################################### + if self.vm_dut:=20 + self.vm_dut.kill_all() + time.sleep(1) + self.vm_dut.close() + self.vm_dut.logger.logger_exit() + self.vm_dut =3D None=20 + if self.vm:=20 + self.vm.stop() + self.vm =3D None + =09 +=09 + def set_legacy_disablefw(self): + ############################################### + ## Disable firewall and iptables in legacy case + ################################################ + if self.vm_dut is not None: + self.vm_dut.send_expect("systemctl stop firewalld.service", "#") + self.vm_dut.send_expect("systemctl disable firewalld.service", "#") + self.vm_dut.send_expect("systemctl stop ip6tables.service", "#") + self.vm_dut.send_expect("systemctl disable ip6tables.service", "#") + self.vm_dut.send_expect("systemctl stop iptables.service", "#") + self.vm_dut.send_expect("systemctl disable iptables.service", "#") + self.vm_dut.send_expect("systemctl stop NetworkManager.service", "#") + self.vm_dut.send_expect("systemctl disable NetworkManager.service", "#"= ) + self.vm_dut.send_expect("echo 1 >/proc/sys/net/ipv4/ip_forward",=20 +"#") + =09 + def set_onevm_legacy_fwd(self): + if self.vm_dut is not None: + ifcfg =3D self.vm_dut.send_expect("ifconfig -a", "#", 10) + intfs =3D re.compile('eth\d').findall(ifcfg) + # Find the virtio1 and virtio2's interface names + for intf in intfs: + out_mac =3D self.vm_dut.send_expect("ifconfig %s"= %intf, "#", 10) + if self.virtio1_mac in out_mac: + self.virtio1 =3D intf + if self.virtio2_mac in out_mac: + self.virtio2 =3D intf + print "\nvirtio1's intf is %s" %self.virtio1 + print "\nvirtio2's intf is %s" %self.virtio2 + # Set the mtu 9000 if jumboframe is enabled. + if self.jumbo =3D=3D 1: + self.vm_dut.send_expect("ifconfig %s mtu 9000" %self.virtio1, "#") + self.vm_dut.send_expect("ifconfig %s mtu 9000" %self.virtio2, "#") + # Set up the ip address/ipv4 fwd tables=20 + self.vm_dut.send_expect("ip addr add 192.168.4.2/24 dev %s" %self.virti= o1,"#") + self.vm_dut.send_expect("ip addr add 192.168.3.2/24 dev %= s" %self.virtio2,"#") + self.vm_dut.send_expect("ip link set dev %s up" %self.vir= tio1, "#") + self.vm_dut.send_expect("ip link set dev %s up" %self.vir= tio2, "#") + self.vm_dut.send_expect("ip neigh add 192.168.4.1 lladdr = 52:00:00:00:00:01 dev %s"%self.virtio1, "#") + self.vm_dut.send_expect("ip neigh add 192.168.3.1 lladdr = 52:00:00:00:00:02 dev %s"%self.virtio2, "#") + self.vm_dut.send_expect("ip route show", "#") + print self.vm_dut.send_expect("arp -a", "#") + +=09 + + def test_perf_user_one_vm_legacy_fwd(self): + ##################################################################### + ## Test the performance of one vm with 2virtio devices in legacy fwd + ##################################################################### + # Restore the virtio interfaces to use legacy driver + self.vm_dut.restore_interfaces() + =09 + self.set_legacy_disablefw() + # Set the legacy fwd rules then get the VLAN id from vhost sample output + self.set_onevm_legacy_fwd() + =09 + time.sleep(5) + outdebug =3D self.dut.get_session_output(timeout=3D2) + out =3D self.dut.send_expect("cat ./vhost.out", "# ", 20) + # Get the VLAN ID for virtio + print out, "\ncheck the vlan info: \n" + l1 =3D re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d= +).*?registered'%(str(self.virtio1_mac)),out) + if len(l1)>0: + vlan_id1=3Dl1[0] + print "vlan_id1 is ", vlan_id1 + l2 =3D re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d= +).*?registered'%(str(self.virtio2_mac)),out) + if len(l2)>0: + vlan_id2=3Dl2[0] + print "vlan_id2 is ", vlan_id2 + + #vlan_id1 =3D 1000 + #vlan_id2 =3D 1001 + dts.results_table_add_header(self.header_row) + + # Create pcap file and ixia traffic + for frame_size in self.frame_sizes: + info =3D "Running test %s, and %d frame size.\n" %= (self.running_case, frame_size) + self.logger.info(info) + + payload_size=3Dframe_size - HEADER_SIZE['eth']-HEA= DER_SIZE['ip'] + flow1=3D'[Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(sr= c=3D"%s",dst=3D"%s")/("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.= dst1,payload_size) + =20 + flow2=3D'[Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"%s",dst=3D"%s")/("= X"*%d)] + ' %(self.virtio2_mac,vlan_id2,self.src2,self.dst2,payload_size) + =09 + self.tester.scapy_append('wrpcap("flow1.pcap", %s)' %flow= 1) + self.tester.scapy_append('wrpcap("flow2.pcap",%s)'= %flow2) + self.tester.scapy_execute() + + # Capture the performance + #self.ip=3Dself.ip_virtio + tgenInput =3D [] + port =3D self.tester.get_local_port(self.pf) + tgenInput.append((port,port,"flow2.pcap")) + =20 + + _, pps =3D self.tester.traffic_generator_throughpu= t(tgenInput,delay=3D15) + #self.verify(pps > 0, "No traffic detected") + pps /=3D1000000.0 + linerate =3D self.wirespeed(self.nic, frame_size, = 1) + pct =3D pps *100/ linerate + scenario =3D self.running_case + mode =3D "vhost user" + data_row =3D [scenario, mode, frame_size, str(pps)= , str(pct)] + dts.results_table_add_row(data_row) + + dts.results_table_print() + + # Stop the Vhost sample + #self.dut.send_expect("^C", "#") + self.dut.send_expect("killall -s INT vhost-switch", "#", 20) +=09 + + + def test_perf_user_one_vm_dpdk_fwd(self): + ###################################################################### + ## Test the performance of one vm with 2virtio devices in legacy f= wd + =20 +##################################################################### + =20 + # start testpmd on VM + self.vm_testpmd_start() + time.sleep(5) + # Clean the output to ensure the commands cat ./vhost.out can be sent an= d got answered correctly. + out_debug =3D self.dut.get_session_output(timeout=3D2) + out =3D self.dut.send_expect("cat ./vhost.out", "# ", 20) + #out =3D self.dut.get_session_output(timeout=3D2) + # Get the VLAN ID for virtio + print out, "\ncheck the vlan info: \n" + l1 =3D re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registere= d'%(str(self.virtio1_mac)),out) + if len(l1)>0: + vlan_id1=3Dl1[0] + print vlan_id1 + l2 =3D re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registere= d'%(str(self.virtio2_mac)),out) + if len(l2)>0: + vlan_id2=3Dl2[0] + print vlan_id2 + + #vlan_id1 =3D 1000 + #vlan_id2 =3D 1001 + dts.results_table_add_header(self.header_row) +=09 + # Create pcap file and ixia traffic + for frame_size in self.frame_sizes: + info =3D "Running test %s, and %d frame size.\n" % (self.running_case, = frame_size) + self.logger.info(info) + + payload_size=3Dframe_size - HEADER_SIZE['eth']-HEADER_SIZE['ip'] + flow1=3D'[Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"%s",dst=3D"%s")/= ("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size) + flow2=3D'[Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"%s",dst=3D"%s")/= ("X"*%d)]' %(self.virtio2_mac,vlan_id2,self.src2,self.dst2,payload_size) + self.tester.scapy_append('wrpcap("flow1.pcap", %s)' %flow1) + self.tester.scapy_append('wrpcap("flow2.pcap",%s)' %flow2) + self.tester.scapy_execute() + + # Capture the performance + #self.ip=3Dself.ip_virtio + tgenInput =3D [] + port =3D self.tester.get_local_port(self.pf) + tgenInput.append((port,port,"flow1.pcap")) + tgenInput.append((port,port,"flow2.pcap")) + + _, pps =3D self.tester.traffic_generator_throughput(tgenInput,delay=3D1= 5) +# self.verify(pps > 0, "No traffic detected") + pps /=3D1000000.0 + linerate =3D self.wirespeed(self.nic, frame_size, 1) + pct =3D pps *100/ linerate + scenario =3D self.running_case + mode =3D "vhost user" + data_row =3D [scenario, mode, frame_size, str(pps), str(pct)] + dts.results_table_add_row(data_row) + =09 + dts.results_table_print() + # Stop testpmd + print self.vm_dut.send_expect("stop", "testpmd>") + time.sleep(1) + self.vm_dut.send_expect("quit", "# ") + =09 + # Stop the Vhost sample + self.dut.send_expect("killall -s INT vhost-switch", "#") + + def test_perf_user_one_vm_legacy_fwd_jumboframe(self): + self.test_perf_user_one_vm_legacy_fwd() + + def test_perf_user_one_vm_dpdk_fwd_jumboframe(self): + self.test_perf_user_one_vm_dpdk_fwd() +=09 + + def tear_down(self): + ################################### + ## Run after each test case. + ################################ + self.clear_vhost_env() + self.dut.kill_all() + time.sleep(2) + =09 + + def tear_down_all(self): + """ + Run after each test suite. + """ + # Restore the config file and recompile the package +# self.dut.send_expect("sed -i -e 's/RTE_LIBRTE_VHOST=3Dy$/RTE_LIBRTE_VHO= ST=3Dn/' config/common_linuxapp", "#", 30) + #self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=3D.*$/C= ONFIG_RTE_LIBRTE_VHOST_USER=3Dn/' ./config/common_linuxapp", "# ", 30) + #self.dut.build_install_dpdk(self.target) +# time.sleep(20) + pass -- 2.1.0