test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case
@ 2015-07-13  1:14 Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device Qian Xu
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

This patchset will enable vhost-user and vhost-cuse sample one-vm performance cases based on the virtualization framework. The vhost-user's implementation is based on vhost user socket, while the vhost-cuse is via IOCTL messages.
The patchset includes below things:
1. Vhost-user sample automation has 4 cases: one VM with dpdk fwd, one VM with dpdk fwd with jumboframe enabled, one VM with legacy fwd, one VM with legacy fwd with jumboframe enabled.
2. Vhost-cuse sample automation has similar 4 cases as above.
3. The required qemu version fo vhost-user is >=qemu2.2
4. The one-vm has 2 virtio, and the vhost has binded to one physical port.
5. update qemu_kvm.py to support vhost-cuse.
6. vhost_cuse_sample.cfg and vhost_sample.cfg are the config file for references.


Qian Xu (5):
  add vhost-cuse implementations for virtio pci device
  add vhost-cuse sample config file for reference
  add the vhost-user sample config file for reference
  add vhost-cuse one vm sample
  add vhost-user one vm sample case

 conf/vhost_cuse_sample.cfg           |  14 ++
 conf/vhost_sample.cfg                |  14 ++
 framework/qemu_kvm.py                |  23 +-
 tests/TestSuite_vhost_cuse_sample.py | 415 +++++++++++++++++++++++++++++++++++
 tests/TestSuite_vhost_sample.py      | 398 +++++++++++++++++++++++++++++++++
 5 files changed, 863 insertions(+), 1 deletion(-)
 create mode 100644 conf/vhost_cuse_sample.cfg
 create mode 100644 conf/vhost_sample.cfg
 create mode 100644 tests/TestSuite_vhost_cuse_sample.py
 create mode 100644 tests/TestSuite_vhost_sample.py

-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device
  2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
@ 2015-07-13  1:14 ` Qian Xu
  2015-07-13  1:17   ` Liu, Yong
  2015-07-13  1:14 ` [dts] [PATCH 2/5] add vhost-cuse sample config file for reference Qian Xu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

Signed-off-by: Qian Xu <qian.q.xu@intel.com>

diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 4ccce81..44db411 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -85,7 +85,7 @@ class QEMUKvm(VirtBase):
         self.char_idx = 0
         self.netdev_idx = 0
         self.pt_idx = 0
-
+	self.cuse_id = 0
         # devices pass-through into vm
         self.pt_devices = []
         self.pci_maps = []
@@ -569,6 +569,8 @@ class QEMUKvm(VirtBase):
                 self.__add_vm_virtio_net_pci(**options)
             elif options['driver'] == 'vhost-user':
                 self.__add_vm_virtio_user_pci(**options)
+	    elif options['driver'] == 'vhost-cuse':
+                self.__add_vm_virtio_cuse_pci(**options)
 
     def __add_vm_pci_assign(self, **options):
         """
@@ -620,6 +622,25 @@ class QEMUKvm(VirtBase):
 
             self.__add_vm_virtio_net_pci(**opts)
 
+    def __add_vm_virtio_cuse_pci(self, **options):
+        """
+        driver virtio-net-pci
+        opt_mac: 52:54:00:00:00:01
+        """
+        separator = ','
+        dev_boot_line = '-netdev tap'
+        cuse_id = 'vhost%d' %self.cuse_id
+        dev_boot_line += separator + 'id=%s' %cuse_id + separator +'ifname=tap_%s' %cuse_id + separator +"vhost=on" +separator +"script=no"
+        self.cuse_id += 1
+        self.__add_boot_line(dev_boot_line)
+        # device parameter
+        opts = {'opt_netdev': '%s' % cuse_id ,
+                'opt_id': '%s_net' % cuse_id}
+        if 'opt_mac' in options.keys() and options['opt_mac']:
+                opts['opt_mac'] = options['opt_mac']
+	print "debug info: add cuse info:", dev_boot_line
+        self.__add_vm_virtio_net_pci(**opts)
+
     def __add_vm_virtio_net_pci(self, **options):
         """
         driver: virtio-net-pci
-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dts] [PATCH 2/5] add vhost-cuse sample config file for reference
  2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device Qian Xu
@ 2015-07-13  1:14 ` Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 3/5] add the vhost-user " Qian Xu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

Signed-off-by: Qian Xu <qian.q.xu@intel.com>

diff --git a/conf/vhost_cuse_sample.cfg b/conf/vhost_cuse_sample.cfg
new file mode 100644
index 0000000..b1abb7e
--- /dev/null
+++ b/conf/vhost_cuse_sample.cfg
@@ -0,0 +1,14 @@
+# vm configuration for vhost sample case
+[vm0]
+cpu =
+    model=host,number=4,cpupin=24 25 26 27;
+mem =
+    size=4096,hugepage=yes;
+disk =
+    file=/home/img/vm0.img;
+login =
+    user=root,password=tester;
+vnc = 
+    displayNum=4;
+daemon =
+    enable=yes;
-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dts] [PATCH 3/5] add the vhost-user sample config file for reference
  2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 2/5] add vhost-cuse sample config file for reference Qian Xu
@ 2015-07-13  1:14 ` Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 4/5] add vhost-cuse one vm sample Qian Xu
  2015-07-13  1:14 ` [dts] [PATCH 5/5] add vhost-user one vm sample case Qian Xu
  4 siblings, 0 replies; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

Signed-off-by: Qian Xu <qian.q.xu@intel.com>

diff --git a/conf/vhost_sample.cfg b/conf/vhost_sample.cfg
new file mode 100644
index 0000000..b1abb7e
--- /dev/null
+++ b/conf/vhost_sample.cfg
@@ -0,0 +1,14 @@
+# vm configuration for vhost sample case
+[vm0]
+cpu =
+    model=host,number=4,cpupin=24 25 26 27;
+mem =
+    size=4096,hugepage=yes;
+disk =
+    file=/home/img/vm0.img;
+login =
+    user=root,password=tester;
+vnc = 
+    displayNum=4;
+daemon =
+    enable=yes;
-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dts] [PATCH 4/5] add vhost-cuse one vm sample
  2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
                   ` (2 preceding siblings ...)
  2015-07-13  1:14 ` [dts] [PATCH 3/5] add the vhost-user " Qian Xu
@ 2015-07-13  1:14 ` Qian Xu
  2015-07-13  1:19   ` Liu, Yong
  2015-07-13  1:14 ` [dts] [PATCH 5/5] add vhost-user one vm sample case Qian Xu
  4 siblings, 1 reply; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

Signed-off-by: Qian Xu <qian.q.xu@intel.com>

diff --git a/tests/TestSuite_vhost_cuse_sample.py b/tests/TestSuite_vhost_cuse_sample.py
new file mode 100644
index 0000000..ff3d9d0
--- /dev/null
+++ b/tests/TestSuite_vhost_cuse_sample.py
@@ -0,0 +1,415 @@
+#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
+# 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.
+
+"""
+DPDK Test suite.
+
+Vhost Cuse 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 TestVhostCUSESample(TestCase, IxiaPacketGenerator):
+	
+	def set_up_all(self):
+		# To Extend IXIA packet generator method, call the tester's method.
+           	self.tester.extend_external_packet_generator(TestVhostCUSESample,self)
+
+        	# Change config file to enable vhost-cuse compiled.
+            	#self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=y/' ./config/common_linuxapp", "# ", 30)
+		self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=n/' ./config/common_linuxapp", "# ", 30)
+	        self.dut.build_install_dpdk(self.target)
+                self.dut.send_expect("cd ./lib/librte_vhost","#",30)
+                print self.dut.send_expect("make", "#", 30)
+                self.dut.send_expect("cd ./eventfd_link", "#", 30)
+                print self.dut.send_expect("make", "#", 30)
+                self.dut.send_expect("cd ~/dpdk", "#", 30)
+                
+	        # build the vhost sample in vhost-cuse mode.
+                self.dut.send_expect("sed -i -e 's/define MAX_QUEUES 512/define MAX_QUEUES 128/' ./examples/vhost/main.c", "#")
+                out = 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")
+
+		# Build target with modified config file
+	    	self.dut.build_install_dpdk(self.target)
+	
+
+		# Get and verify the ports
+		self.dut_ports = self.dut.get_ports()
+		self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
+
+		# Get the port's socket
+ 		self.pf = self.dut_ports[0]
+		netdev = self.dut.ports_info[self.pf]['port']
+		self.socket = netdev.get_nic_socket()
+		self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
+		
+		# Set the params of vhost-cuse sample 
+		self.vhost_app = "./examples/vhost/build/vhost-switch"
+		self.zero_copy = 0
+		self.vm2vm = 0
+		self.jumbo = 0
+		self.vhost_test = self.vhost_app + " -c %s -n %d --socket-mem 1024,1024 -- -p 0x1 --mergeable %d --zero-copy %d --vm2vm %d 2 > ./vhost.out &"
+	
+		# Define the virtio/VM variables
+		self.virtio1 = "eth1"
+		self.virtio2 = "eth2"
+		self.virtio1_mac = "52:54:00:00:00:01"
+		self.virtio2_mac = "52:54:00:00:00:02"
+		self.src1 = "192.168.4.1"
+		self.src2 = "192.168.3.1"
+		self.dst1 = "192.168.3.1"
+		self.dst2 = "192.168.4.1"
+		self.vm_dut = None
+		
+		#Define the table columns
+		self.header_row = ["Scenario","Mode", "Frame", "Mpps", "% linerate"]
+		self.memory_channel = 4
+ 
+	def set_up(self):
+        ######################################
+        ## Run before each test case.
+        ######################################
+		# Launch vhost sample using default params
+		
+		if "jumbo" in self.running_case:
+			self.jumbo = 1
+			self.frame_sizes = [68,128,256,512,1024,1280,1518,1522,2048,5000,9000]
+			#self.frame_sizes = [256,5000]
+			self.vm_testpmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3" \
+                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-filter --max-pkt-len 9600"		
+		else: 
+			self.jumbo = 0
+			self.frame_sizes = [68,128,256,512,1024,1280,1518]
+			#self.frame_sizes = [68, 128]
+			self.vm_testpmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3" \
+                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-filter"
+		self.dut.send_expect("rm -rf ./vhost.out", "#")
+                
+		self.launch_vhost_sample()
+
+                # start VM with 2virtio
+                self.start_onevm()
+
+	
+	def launch_vhost_sample(self):
+	####################################################################
+	## Launch the vhost sample with different parameters
+	####################################################################			
+		self.coremask = dts.create_mask(self.cores)
+		self.vhostapp_testcmd = self.vhost_test %(self.coremask, self.memory_channel, self.jumbo, self.zero_copy,
+							self.vm2vm)
+		# Clean and prepare the vhost cuse modules
+		self.dut.send_expect("rm -rf /dev/vhost-net", "#", 20)
+		self.dut.send_expect("modprobe fuse", "#", 20)
+		self.dut.send_expect("modprobe cuse", "#", 20)
+		self.dut.send_expect("rmmod eventfd_link", "#", 20)
+		self.dut.send_expect("insmod lib/librte_vhost/eventfd_link/eventfd_link.ko", "#", 20)
+		self.dut.send_expect(self.vhostapp_testcmd, "# ", 40)
+                time.sleep(30)
+		try: 
+			print "Launch vhost sample\n"
+			self.dut.send_expect("cat ./vhost.out", "VHOST_DATA: Procesing on", 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))
+
+	
+	def start_onevm(self):
+	#####################################
+	## Start One VM with 2 virtio devices
+	#####################################
+		
+		self.vm = QEMUKvm(self.dut, 'vm0', 'vhost_sample')
+		if "cuse" in self.running_case:
+			vm_params ={}
+			vm_params['driver'] = 'vhost-cuse'
+			vm_params['opt_mac'] = self.virtio1_mac
+			self.vm.set_vm_device(**vm_params)
+			vm_params['opt_mac'] = self.virtio2_mac
+			self.vm.set_vm_device(**vm_params)
+			print "cuse setup is done, vm_params: ", vm_params
+		try: 
+			self.vm_dut = self.vm.start(auto_portmap=False)
+			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))
+		
+		return True
+	
+	def vm_testpmd_start(self):
+	####################################################### 
+	## 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: 
+			self.vm_dut.kill_all()
+			time.sleep(1)
+			self.vm_dut.close()
+			self.vm_dut.logger.logger_exit()
+			self.vm_dut = None 
+		if self.vm: 
+			self.vm.stop()
+			self.vm = None
+		
+	
+	def set_legacy_disablefw(self):
+	############################################################
+	## Disable firewall and ip tables 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", "#")
+		
+	def set_onevm_legacy_fwd(self):
+		if self.vm_dut is not None:
+			ifcfg = self.vm_dut.send_expect("ifconfig -a", "#", 10)
+                	intfs = re.compile('eth\d').findall(ifcfg)
+			# Get the virito1/virtio2's interface names
+                	for intf in intfs:
+                        	out_mac = self.vm_dut.send_expect("ifconfig %s" %intf, "#", 10)
+                        	if self.virtio1_mac in out_mac:
+                                	self.virtio1 = intf
+                        	if self.virtio2_mac in out_mac:
+                                	self.virtio2 = intf
+                	print "\nvirtio1's intf is %s" %self.virtio1
+			print "\nvirtio2's intf is %s" %self.virtio2
+			# Set the MTU for jumboframe enabled case
+			if self.jumbo == 1:
+				self.vm_dut.send_expect("ifconfig %s mtu 9000" %self.virtio1, "#")
+				self.vm_dut.send_expect("ifconfig %s mtu 9000" %self.virtio2, "#")
+			# Set the ipv4 fwd rules
+			self.vm_dut.send_expect("ip addr add 192.168.4.2/24 dev %s" %self.virtio1,"#")
+                	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.virtio1, "#")
+                	self.vm_dut.send_expect("ip link set dev %s up" %self.virtio2, "#")
+                	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", "#")
+
+
+
+	
+
+	def test_perf_cuse_one_vm_legacy_fwd(self):
+	#####################################################################
+	## Test the performance of one vm with 2virtio devices in legacy fwd
+	#####################################################################
+
+		self.vm_dut.restore_interfaces()
+                # Setup legacy env
+		self.set_legacy_disablefw()
+		self.set_onevm_legacy_fwd()
+		
+		time.sleep(5)
+                
+		out1 = self.dut.get_session_output(timeout=2)
+                #print "\nclean out1:", out1
+
+                out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
+		print out
+                # Get the VLAN ID for virtio
+                print "\ncheck the vlan info: \n"
+                l1 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio1_mac)),out)
+                if len(l1)>0:
+                        vlan_id1=l1[0]
+                        print "vlan_id1 is ", vlan_id1
+                l2 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio2_mac)),out)
+                if len(l2)>0:
+                        vlan_id2=l2[0]
+                        print "vlan_id2 is ", vlan_id2
+
+                #vlan_id1 = 1000
+                #vlan_id2 = 1001
+                dts.results_table_add_header(self.header_row)
+
+		 # Create pcap file and ixia traffic
+                for frame_size in self.frame_sizes:
+                        info = "Running test %s, and %d frame size.\n" % (self.running_case, frame_size)
+                        self.logger.info(info)
+
+                        payload_size=frame_size - HEADER_SIZE['eth']-HEADER_SIZE['ip']
+                        flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
+                        flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
+                        tgenInput = []
+                        port = self.tester.get_local_port(self.pf)
+                        tgenInput.append((port,port,"flow2.pcap"))
+                        
+
+                        _, pps = self.tester.traffic_generator_throughput(tgenInput,delay=15)
+		       #self.verify(pps > 0, "No traffic detected")
+                        pps /=1000000.0
+                        linerate = self.wirespeed(self.nic, frame_size, 1)
+			pct = pps *100/ linerate
+			scenario = self.running_case
+			mode = "vhost cuse"
+                        data_row = [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)
+	
+
+
+	def test_perf_cuse_one_vm_dpdk_fwd(self):
+	######################################################################
+        ## Test the performance of one vm with 2virtio devices in legacy fwd
+        #####################################################################
+             
+                # start testpmd on VM
+		self.vm_testpmd_start()
+		time.sleep(5)
+		# Clean the output to make the next command can get correct answers
+		out1 = self.dut.get_session_output(timeout=2)
+		#print "\nclean out1:", out1
+		out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
+		#out = self.dut.get_session_output(timeout=2)
+                # Get the VLAN ID for virtio
+		print "\nout:",out
+		print "\ncheck the vlan info: \n"
+		l1 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio1_mac)),out)
+		if len(l1)>0:
+			vlan_id1=l1[0]
+			print vlan_id1
+		l2 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio2_mac)),out)
+                if len(l2)>0:
+                        vlan_id2=l2[0]
+                        print vlan_id2
+
+		#vlan_id1 = 1000
+		#vlan_id2 = 1001
+		dts.results_table_add_header(self.header_row)
+	
+		# Create pcap file and ixia traffic
+		for frame_size in self.frame_sizes:
+			info = "Running test %s, and %d frame size.\n" % (self.running_case, frame_size)
+                        self.logger.info(info)
+
+			payload_size=frame_size - HEADER_SIZE['eth']-HEADER_SIZE['ip']
+			flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
+			flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
+		        tgenInput = []
+			port = self.tester.get_local_port(self.pf)
+			tgenInput.append((port,port,"flow1.pcap"))
+			tgenInput.append((port,port,"flow2.pcap"))
+
+			_, pps = self.tester.traffic_generator_throughput(tgenInput,delay=15)
+#			self.verify(pps > 0, "No traffic detected")
+			pps /=1000000.0
+			linerate = self.wirespeed(self.nic, frame_size, 1)
+			pct = pps *100/ linerate
+			scenario = self.running_case
+			mode = "vhost user"
+			data_row = [scenario, mode, frame_size, str(pps), str(pct)]
+			dts.results_table_add_row(data_row)
+		
+		dts.results_table_print()
+		# Stop testpmd
+		print self.vm_dut.send_expect("stop", "testpmd>")
+                time.sleep(1)
+		self.vm_dut.send_expect("quit", "# ")
+		#self.vm.stop()
+		
+		
+		# Stop the Vhost sample
+		#self.dut.send_expect("^C", "#")
+		self.dut.send_expect("killall -s INT vhost-switch", "#")
+
+	def test_perf_cuse_one_vm_legacy_fwd_jumboframe(self):
+		self.test_perf_cuse_one_vm_legacy_fwd()
+
+	def test_perf_cuse_one_vm_dpdk_fwd_jumboframe(self):
+		self.test_perf_cuse_one_vm_dpdk_fwd()
+	
+
+	def tear_down(self):
+		###################################
+        	## Run after each test case.
+        	################################
+		self.clear_vhost_env()
+		self.dut.kill_all()
+		time.sleep(2)
+		
+
+	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/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=y/' ./config/common_linuxapp", "# ", 30)
+		self.dut.build_install_dpdk(self.target)
+		time.sleep(20)
+
-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dts] [PATCH 5/5] add vhost-user one vm sample case
  2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
                   ` (3 preceding siblings ...)
  2015-07-13  1:14 ` [dts] [PATCH 4/5] add vhost-cuse one vm sample Qian Xu
@ 2015-07-13  1:14 ` Qian Xu
  2015-07-13  1:25   ` Liu, Yong
  4 siblings, 1 reply; 11+ messages in thread
From: Qian Xu @ 2015-07-13  1:14 UTC (permalink / raw)
  To: dts

Signed-off-by: Qian Xu <qian.q.xu@intel.com>

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
+# 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.
+
+"""
+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):
+	
+	def set_up_all(self):
+		# To Extend IXIA packet generator method, call the tester's method.
+           	self.tester.extend_external_packet_generator(TestVhostSample,self)
+
+        	# Change config file,no need now since the default is y. 
+            	#self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=y/' ./config/common_linuxapp", "# ", 30)
+	
+		# Build target with modified config file
+	    	self.dut.build_install_dpdk(self.target)
+	
+
+		# Get and verify the ports
+		self.dut_ports = self.dut.get_ports()
+		self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
+
+		# Get the port's socket
+ 		self.pf = self.dut_ports[0]
+		netdev = self.dut.ports_info[self.pf]['port']
+		self.socket = netdev.get_nic_socket()
+		self.cores = self.dut.get_core_list("1S/2C/1T", socket=self.socket)
+		
+		# Set the params of vhost sample 
+		self.vhost_app = "./examples/vhost/build/vhost-switch"
+		self.zero_copy = 0
+		self.vm2vm = 0
+		self.jumbo = 0
+		#self.rxq = 1
+		# Using file to save the vhost sample output since in jumboframe case, there will be lots of output
+		self.vhost_test = self.vhost_app + " -c %s -n %d --socket-mem 1024,1024 -- -p 0x1 --mergeable %d --zero-copy %d --vm2vm %d 2 > ./vhost.out &"
+ 		# build the vhost sample in vhost-user mode.  	
+		self.dut.send_expect("sed -i -e 's/define MAX_QUEUES 512/define MAX_QUEUES 128/' ./examples/vhost/main.c", "#")
+		out = 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")
+	
+		# Define the virtio/VM variables
+		self.virtio1 = "eth1"
+		self.virtio2 = "eth2"
+		self.virtio1_mac = "52:54:00:00:00:01"
+		self.virtio2_mac = "52:54:00:00:00:02"
+		self.src1 = "192.168.4.1"
+		self.src2 = "192.168.3.1"
+		self.dst1 = "192.168.3.1"
+		self.dst2 = "192.168.4.1"
+		self.vm_dut = None
+		
+		self.header_row = ["Test","Mode", "Frame", "Mpps", "% linerate"]
+		self.memory_channel = 4
+ 
+	def set_up(self):
+        ######################################
+        ## Run before each test case.
+        ######################################
+		# Launch vhost sample using default params
+		
+		if "jumbo" in self.running_case:
+			self.jumbo = 1
+			self.frame_sizes = [68,128,256,512,1024,1280,1518,1522,2048,5000,9000]
+			#self.frame_sizes = [256,5000]
+			self.vm_testpmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3" \
+                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-filter --max-pkt-len 9600"		
+		else: 
+			self.jumbo = 0
+			self.frame_sizes = [68,128,256,512,1024,1280,1518]
+			#self.frame_sizes = [68, 128]
+			self.vm_testpmd = "./x86_64-native-linuxapp-gcc/app/testpmd -c f -n 3" \
+                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-filter"
+		self.dut.send_expect("rm -rf ./vhost.out", "#")
+		
+		self.launch_vhost_sample()
+		
+		print "Start VM with 2virtio\n"
+               	# start VM with 2virtio	
+           	self.start_onevm()
+
+
+	def launch_vhost_sample(self):
+	####################################################################
+	## Launch the vhost sample with different parameters
+	####################################################################			
+		self.coremask = dts.create_mask(self.cores)
+		self.vhostapp_testcmd = self.vhost_test %(self.coremask, self.memory_channel, self.jumbo, self.zero_copy,
+							self.vm2vm)
+#		self.dut.send_expect(self.vhostapp_testcmd, "VHOST_CONFIG: bind to vhost-net", 120)
+		self.dut.send_expect(self.vhostapp_testcmd, "# ", 40)
+                time.sleep(30)
+		try: 
+			print "Launch vhost sample\n"
+			out = 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))			
+				self.dut.send_expect("rm -rf ./vhost-net" ,"#", 20)
+	
+	def start_onevm(self):
+	#####################################
+	## Start One VM with 2 virtio devices
+	#####################################
+		
+		self.vm = QEMUKvm(self.dut, 'vm0', 'vhost_sample')
+		#qemu_path = "/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 ={}
+			vm_params['driver'] = 'vhost-user'
+			vm_params['opt_path'] = './vhost-net'
+			vm_params['opt_mac'] = self.virtio1_mac
+			self.vm.set_vm_device(**vm_params)
+	        	vm_params['opt_mac'] = self.virtio2_mac
+			self.vm.set_vm_device(**vm_params)
+
+		try: 
+			self.vm_dut = self.vm.start(auto_portmap=False)
+			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))
+		
+		return True
+	
+	def vm_testpmd_start(self):
+	####################################################### 
+	## 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: 
+			self.vm_dut.kill_all()
+			time.sleep(1)
+			self.vm_dut.close()
+			self.vm_dut.logger.logger_exit()
+			self.vm_dut = None 
+		if self.vm: 
+			self.vm.stop()
+			self.vm = None
+		
+	
+	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", "#")
+		
+	def set_onevm_legacy_fwd(self):
+		if self.vm_dut is not None:
+			ifcfg = self.vm_dut.send_expect("ifconfig -a", "#", 10)
+                	intfs = re.compile('eth\d').findall(ifcfg)
+			# Find the virtio1 and virtio2's interface names
+                	for intf in intfs:
+                        	out_mac = self.vm_dut.send_expect("ifconfig %s" %intf, "#", 10)
+                        	if self.virtio1_mac in out_mac:
+                                	self.virtio1 = intf
+                        	if self.virtio2_mac in out_mac:
+                                	self.virtio2 = 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 == 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 
+			self.vm_dut.send_expect("ip addr add 192.168.4.2/24 dev %s" %self.virtio1,"#")
+                	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.virtio1, "#")
+                	self.vm_dut.send_expect("ip link set dev %s up" %self.virtio2, "#")
+                	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", "#")
+
+	
+
+	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()
+		
+		self.set_legacy_disablefw()
+		# Set the legacy fwd rules then get the VLAN id from vhost sample output
+		self.set_onevm_legacy_fwd()
+		
+		time.sleep(5)
+                outdebug = self.dut.get_session_output(timeout=2)
+                out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
+                # Get the VLAN ID for virtio
+                print out, "\ncheck the vlan info: \n"
+                l1 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio1_mac)),out)
+                if len(l1)>0:
+                        vlan_id1=l1[0]
+                        print "vlan_id1 is ", vlan_id1
+                l2 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio2_mac)),out)
+                if len(l2)>0:
+                        vlan_id2=l2[0]
+                        print "vlan_id2 is ", vlan_id2
+
+                #vlan_id1 = 1000
+                #vlan_id2 = 1001
+                dts.results_table_add_header(self.header_row)
+
+		 # Create pcap file and ixia traffic
+                for frame_size in self.frame_sizes:
+                        info = "Running test %s, and %d frame size.\n" % (self.running_case, frame_size)
+                        self.logger.info(info)
+
+                        payload_size=frame_size - HEADER_SIZE['eth']-HEADER_SIZE['ip']
+                        flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
+                        flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
+                        tgenInput = []
+                        port = self.tester.get_local_port(self.pf)
+                        tgenInput.append((port,port,"flow2.pcap"))
+                        
+
+                        _, pps = self.tester.traffic_generator_throughput(tgenInput,delay=15)
+		       #self.verify(pps > 0, "No traffic detected")
+                        pps /=1000000.0
+                        linerate = self.wirespeed(self.nic, frame_size, 1)
+			pct = pps *100/ linerate
+			scenario = self.running_case
+			mode = "vhost user"
+                        data_row = [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)
+	
+
+
+	def test_perf_user_one_vm_dpdk_fwd(self):
+	######################################################################
+        ## Test the performance of one vm with 2virtio devices in legacy fwd
+        #####################################################################
+             
+                # start testpmd on VM
+		self.vm_testpmd_start()
+		time.sleep(5)
+		# Clean the output to ensure the commands cat ./vhost.out can be sent and got answered correctly.
+		out_debug = self.dut.get_session_output(timeout=2)
+		out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
+		#out = self.dut.get_session_output(timeout=2)
+                # Get the VLAN ID for virtio
+		print out, "\ncheck the vlan info: \n"
+		l1 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio1_mac)),out)
+		if len(l1)>0:
+			vlan_id1=l1[0]
+			print vlan_id1
+		l2 = re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(self.virtio2_mac)),out)
+                if len(l2)>0:
+                        vlan_id2=l2[0]
+                        print vlan_id2
+
+		#vlan_id1 = 1000
+		#vlan_id2 = 1001
+		dts.results_table_add_header(self.header_row)
+	
+		# Create pcap file and ixia traffic
+		for frame_size in self.frame_sizes:
+			info = "Running test %s, and %d frame size.\n" % (self.running_case, frame_size)
+                        self.logger.info(info)
+
+			payload_size=frame_size - HEADER_SIZE['eth']-HEADER_SIZE['ip']
+			flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
+			flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
+		        tgenInput = []
+			port = self.tester.get_local_port(self.pf)
+			tgenInput.append((port,port,"flow1.pcap"))
+			tgenInput.append((port,port,"flow2.pcap"))
+
+			_, pps = self.tester.traffic_generator_throughput(tgenInput,delay=15)
+#			self.verify(pps > 0, "No traffic detected")
+			pps /=1000000.0
+			linerate = self.wirespeed(self.nic, frame_size, 1)
+			pct = pps *100/ linerate
+			scenario = self.running_case
+			mode = "vhost user"
+			data_row = [scenario, mode, frame_size, str(pps), str(pct)]
+			dts.results_table_add_row(data_row)
+		
+		dts.results_table_print()
+		# Stop testpmd
+		print self.vm_dut.send_expect("stop", "testpmd>")
+                time.sleep(1)
+		self.vm_dut.send_expect("quit", "# ")
+		
+		# 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()
+	
+
+	def tear_down(self):
+		###################################
+        	## Run after each test case.
+        	################################
+		self.clear_vhost_env()
+		self.dut.kill_all()
+		time.sleep(2)
+		
+
+	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=y$/RTE_LIBRTE_VHOST=n/' config/common_linuxapp", "#", 30)
+		#self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=n/' ./config/common_linuxapp", "# ", 30)
+		#self.dut.build_install_dpdk(self.target)
+#		time.sleep(20)
+		pass
-- 
2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device
  2015-07-13  1:14 ` [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device Qian Xu
@ 2015-07-13  1:17   ` Liu, Yong
  2015-07-13  1:18     ` Xu, Qian Q
  0 siblings, 1 reply; 11+ messages in thread
From: Liu, Yong @ 2015-07-13  1:17 UTC (permalink / raw)
  To: Xu, Qian Q, dts

Qian, please remove debug function in your patch.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, July 13, 2015 9:14 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci
> device
> 
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> 
> diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
> index 4ccce81..44db411 100644
> --- a/framework/qemu_kvm.py
> +++ b/framework/qemu_kvm.py
> @@ -85,7 +85,7 @@ class QEMUKvm(VirtBase):
>          self.char_idx = 0
>          self.netdev_idx = 0
>          self.pt_idx = 0
> -
> +	self.cuse_id = 0
>          # devices pass-through into vm
>          self.pt_devices = []
>          self.pci_maps = []
> @@ -569,6 +569,8 @@ class QEMUKvm(VirtBase):
>                  self.__add_vm_virtio_net_pci(**options)
>              elif options['driver'] == 'vhost-user':
>                  self.__add_vm_virtio_user_pci(**options)
> +	    elif options['driver'] == 'vhost-cuse':
> +                self.__add_vm_virtio_cuse_pci(**options)
> 
>      def __add_vm_pci_assign(self, **options):
>          """
> @@ -620,6 +622,25 @@ class QEMUKvm(VirtBase):
> 
>              self.__add_vm_virtio_net_pci(**opts)
> 
> +    def __add_vm_virtio_cuse_pci(self, **options):
> +        """
> +        driver virtio-net-pci
> +        opt_mac: 52:54:00:00:00:01
> +        """
> +        separator = ','
> +        dev_boot_line = '-netdev tap'
> +        cuse_id = 'vhost%d' %self.cuse_id
> +        dev_boot_line += separator + 'id=%s' %cuse_id + separator
> +'ifname=tap_%s' %cuse_id + separator +"vhost=on" +separator +"script=no"
> +        self.cuse_id += 1
> +        self.__add_boot_line(dev_boot_line)
> +        # device parameter
> +        opts = {'opt_netdev': '%s' % cuse_id ,
> +                'opt_id': '%s_net' % cuse_id}
> +        if 'opt_mac' in options.keys() and options['opt_mac']:
> +                opts['opt_mac'] = options['opt_mac']
> +	print "debug info: add cuse info:", dev_boot_line
> +        self.__add_vm_virtio_net_pci(**opts)
> +
>      def __add_vm_virtio_net_pci(self, **options):
>          """
>          driver: virtio-net-pci
> --
> 2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device
  2015-07-13  1:17   ` Liu, Yong
@ 2015-07-13  1:18     ` Xu, Qian Q
  2015-07-13  1:26       ` Liu, Yong
  0 siblings, 1 reply; 11+ messages in thread
From: Xu, Qian Q @ 2015-07-13  1:18 UTC (permalink / raw)
  To: Liu, Yong, dts

OK, I can comment them, any other changes needed? 

Thanks
Qian


-----Original Message-----
From: Liu, Yong 
Sent: Monday, July 13, 2015 9:17 AM
To: Xu, Qian Q; dts@dpdk.org
Subject: RE: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device

Qian, please remove debug function in your patch.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, July 13, 2015 9:14 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio 
> pci device
> 
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> 
> diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index 
> 4ccce81..44db411 100644
> --- a/framework/qemu_kvm.py
> +++ b/framework/qemu_kvm.py
> @@ -85,7 +85,7 @@ class QEMUKvm(VirtBase):
>          self.char_idx = 0
>          self.netdev_idx = 0
>          self.pt_idx = 0
> -
> +	self.cuse_id = 0
>          # devices pass-through into vm
>          self.pt_devices = []
>          self.pci_maps = []
> @@ -569,6 +569,8 @@ class QEMUKvm(VirtBase):
>                  self.__add_vm_virtio_net_pci(**options)
>              elif options['driver'] == 'vhost-user':
>                  self.__add_vm_virtio_user_pci(**options)
> +	    elif options['driver'] == 'vhost-cuse':
> +                self.__add_vm_virtio_cuse_pci(**options)
> 
>      def __add_vm_pci_assign(self, **options):
>          """
> @@ -620,6 +622,25 @@ class QEMUKvm(VirtBase):
> 
>              self.__add_vm_virtio_net_pci(**opts)
> 
> +    def __add_vm_virtio_cuse_pci(self, **options):
> +        """
> +        driver virtio-net-pci
> +        opt_mac: 52:54:00:00:00:01
> +        """
> +        separator = ','
> +        dev_boot_line = '-netdev tap'
> +        cuse_id = 'vhost%d' %self.cuse_id
> +        dev_boot_line += separator + 'id=%s' %cuse_id + separator 
> +'ifname=tap_%s' %cuse_id + separator +"vhost=on" +separator +"script=no"
> +        self.cuse_id += 1
> +        self.__add_boot_line(dev_boot_line)
> +        # device parameter
> +        opts = {'opt_netdev': '%s' % cuse_id ,
> +                'opt_id': '%s_net' % cuse_id}
> +        if 'opt_mac' in options.keys() and options['opt_mac']:
> +                opts['opt_mac'] = options['opt_mac']
> +	print "debug info: add cuse info:", dev_boot_line
> +        self.__add_vm_virtio_net_pci(**opts)
> +
>      def __add_vm_virtio_net_pci(self, **options):
>          """
>          driver: virtio-net-pci
> --
> 2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dts] [PATCH 4/5] add vhost-cuse one vm sample
  2015-07-13  1:14 ` [dts] [PATCH 4/5] add vhost-cuse one vm sample Qian Xu
@ 2015-07-13  1:19   ` Liu, Yong
  0 siblings, 0 replies; 11+ messages in thread
From: Liu, Yong @ 2015-07-13  1:19 UTC (permalink / raw)
  To: Xu, Qian Q, dts

Qian, there's some unaligned code in my view, can you use pep8 tool to check with that?

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, July 13, 2015 9:14 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH 4/5] add vhost-cuse one vm sample
> 
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> 
> diff --git a/tests/TestSuite_vhost_cuse_sample.py
> b/tests/TestSuite_vhost_cuse_sample.py
> new file mode 100644
> index 0000000..ff3d9d0
> --- /dev/null
> +++ b/tests/TestSuite_vhost_cuse_sample.py
> @@ -0,0 +1,415 @@
> +#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
> +# 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.
> +
> +"""
> +DPDK Test suite.
> +
> +Vhost Cuse 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 TestVhostCUSESample(TestCase, IxiaPacketGenerator):
> +
> +	def set_up_all(self):
> +		# To Extend IXIA packet generator method, call the tester's
> method.
> +
> 	self.tester.extend_external_packet_generator(TestVhostCUSESample,sel
> f)
> +
> +        	# Change config file to enable vhost-cuse compiled.
> +            	#self.dut.send_expect("sed -i -e
> 's/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=y/' ./config/common
> _linuxapp", "# ", 30)
> +		self.dut.send_expect("sed -i -e
> 's/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=n/' ./con
> fig/common_linuxapp", "# ", 30)
> +	        self.dut.build_install_dpdk(self.target)
> +                self.dut.send_expect("cd ./lib/librte_vhost","#",30)
> +                print self.dut.send_expect("make", "#", 30)
> +                self.dut.send_expect("cd ./eventfd_link", "#", 30)
> +                print self.dut.send_expect("make", "#", 30)
> +                self.dut.send_expect("cd ~/dpdk", "#", 30)
> +
> +	        # build the vhost sample in vhost-cuse mode.
> +                self.dut.send_expect("sed -i -e 's/define MAX_QUEUES
> 512/define MAX_QUEUES 128/' ./examples/vhost/main.c", "#")
> +                out = 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")
> +
> +		# Build target with modified config file
> +	    	self.dut.build_install_dpdk(self.target)
> +
> +
> +		# Get and verify the ports
> +		self.dut_ports = self.dut.get_ports()
> +		self.verify(len(self.dut_ports) >= 1, "Insufficient ports for
> testing")
> +
> +		# Get the port's socket
> + 		self.pf = self.dut_ports[0]
> +		netdev = self.dut.ports_info[self.pf]['port']
> +		self.socket = netdev.get_nic_socket()
> +		self.cores = self.dut.get_core_list("1S/2C/1T",
> socket=self.socket)
> +
> +		# Set the params of vhost-cuse sample
> +		self.vhost_app = "./examples/vhost/build/vhost-switch"
> +		self.zero_copy = 0
> +		self.vm2vm = 0
> +		self.jumbo = 0
> +		self.vhost_test = self.vhost_app + " -c %s -n %d --socket-mem
> 1024,1024 -- -p 0x1 --mergeable %d --zero-copy %d --vm2vm %d
> 2 > ./vhost.out &"
> +
> +		# Define the virtio/VM variables
> +		self.virtio1 = "eth1"
> +		self.virtio2 = "eth2"
> +		self.virtio1_mac = "52:54:00:00:00:01"
> +		self.virtio2_mac = "52:54:00:00:00:02"
> +		self.src1 = "192.168.4.1"
> +		self.src2 = "192.168.3.1"
> +		self.dst1 = "192.168.3.1"
> +		self.dst2 = "192.168.4.1"
> +		self.vm_dut = None
> +
> +		#Define the table columns
> +		self.header_row = ["Scenario","Mode", "Frame", "Mpps", "%
> linerate"]
> +		self.memory_channel = 4
> +
> +	def set_up(self):
> +        ######################################
> +        ## Run before each test case.
> +        ######################################
> +		# Launch vhost sample using default params
> +
> +		if "jumbo" in self.running_case:
> +			self.jumbo = 1
> +			self.frame_sizes =
> [68,128,256,512,1024,1280,1518,1522,2048,5000,9000]
> +			#self.frame_sizes = [256,5000]
> +			self.vm_testpmd = "./x86_64-native-linuxapp-
> gcc/app/testpmd -c f -n 3" \
> +                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-
> filter --max-pkt-len 9600"
> +		else:
> +			self.jumbo = 0
> +			self.frame_sizes = [68,128,256,512,1024,1280,1518]
> +			#self.frame_sizes = [68, 128]
> +			self.vm_testpmd = "./x86_64-native-linuxapp-
> gcc/app/testpmd -c f -n 3" \
> +                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-
> filter"
> +		self.dut.send_expect("rm -rf ./vhost.out", "#")
> +
> +		self.launch_vhost_sample()
> +
> +                # start VM with 2virtio
> +                self.start_onevm()
> +
> +
> +	def launch_vhost_sample(self):
> +	####################################################################
> +	## Launch the vhost sample with different parameters
> +	####################################################################
> 
> +		self.coremask = dts.create_mask(self.cores)
> +		self.vhostapp_testcmd = self.vhost_test %(self.coremask,
> self.memory_channel, self.jumbo, self.zero_copy,
> +							self.vm2vm)
> +		# Clean and prepare the vhost cuse modules
> +		self.dut.send_expect("rm -rf /dev/vhost-net", "#", 20)
> +		self.dut.send_expect("modprobe fuse", "#", 20)
> +		self.dut.send_expect("modprobe cuse", "#", 20)
> +		self.dut.send_expect("rmmod eventfd_link", "#", 20)
> +		self.dut.send_expect("insmod
> lib/librte_vhost/eventfd_link/eventfd_link.ko", "#", 20)
> +		self.dut.send_expect(self.vhostapp_testcmd, "# ", 40)
> +                time.sleep(30)
> +		try:
> +			print "Launch vhost sample\n"
> +			self.dut.send_expect("cat ./vhost.out", "VHOST_DATA:
> Procesing on", 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))
> +
> +
> +	def start_onevm(self):
> +	#####################################
> +	## Start One VM with 2 virtio devices
> +	#####################################
> +
> +		self.vm = QEMUKvm(self.dut, 'vm0', 'vhost_sample')
> +		if "cuse" in self.running_case:
> +			vm_params ={}
> +			vm_params['driver'] = 'vhost-cuse'
> +			vm_params['opt_mac'] = self.virtio1_mac
> +			self.vm.set_vm_device(**vm_params)
> +			vm_params['opt_mac'] = self.virtio2_mac
> +			self.vm.set_vm_device(**vm_params)
> +			print "cuse setup is done, vm_params: ", vm_params
> +		try:
> +			self.vm_dut = self.vm.start(auto_portmap=False)
> +			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))
> +
> +		return True
> +
> +	def vm_testpmd_start(self):
> +	#######################################################
> +	## 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:
> +			self.vm_dut.kill_all()
> +			time.sleep(1)
> +			self.vm_dut.close()
> +			self.vm_dut.logger.logger_exit()
> +			self.vm_dut = None
> +		if self.vm:
> +			self.vm.stop()
> +			self.vm = None
> +
> +
> +	def set_legacy_disablefw(self):
> +	############################################################
> +	## Disable firewall and ip tables 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", "#")
> +
> +	def set_onevm_legacy_fwd(self):
> +		if self.vm_dut is not None:
> +			ifcfg = self.vm_dut.send_expect("ifconfig -a", "#", 10)
> +                	intfs = re.compile('eth\d').findall(ifcfg)
> +			# Get the virito1/virtio2's interface names
> +                	for intf in intfs:
> +                        	out_mac =
> self.vm_dut.send_expect("ifconfig %s" %intf, "#", 10)
> +                        	if self.virtio1_mac in out_mac:
> +                                	self.virtio1 = intf
> +                        	if self.virtio2_mac in out_mac:
> +                                	self.virtio2 = intf
> +                	print "\nvirtio1's intf is %s" %self.virtio1
> +			print "\nvirtio2's intf is %s" %self.virtio2
> +			# Set the MTU for jumboframe enabled case
> +			if self.jumbo == 1:
> +				self.vm_dut.send_expect("ifconfig %s mtu
> 9000" %self.virtio1, "#")
> +				self.vm_dut.send_expect("ifconfig %s mtu
> 9000" %self.virtio2, "#")
> +			# Set the ipv4 fwd rules
> +			self.vm_dut.send_expect("ip addr add 192.168.4.2/24
> dev %s" %self.virtio1,"#")
> +                	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.virtio1, "#")
> +                	self.vm_dut.send_expect("ip link set dev %s
> up" %self.virtio2, "#")
> +                	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", "#")
> +
> +
> +
> +
> +
> +	def test_perf_cuse_one_vm_legacy_fwd(self):
> +
> 	####################################################################
> #
> +	## Test the performance of one vm with 2virtio devices in legacy fwd
> +
> 	####################################################################
> #
> +
> +		self.vm_dut.restore_interfaces()
> +                # Setup legacy env
> +		self.set_legacy_disablefw()
> +		self.set_onevm_legacy_fwd()
> +
> +		time.sleep(5)
> +
> +		out1 = self.dut.get_session_output(timeout=2)
> +                #print "\nclean out1:", out1
> +
> +                out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
> +		print out
> +                # Get the VLAN ID for virtio
> +                print "\ncheck the vlan info: \n"
> +                l1 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio1_mac)),out)
> +                if len(l1)>0:
> +                        vlan_id1=l1[0]
> +                        print "vlan_id1 is ", vlan_id1
> +                l2 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio2_mac)),out)
> +                if len(l2)>0:
> +                        vlan_id2=l2[0]
> +                        print "vlan_id2 is ", vlan_id2
> +
> +                #vlan_id1 = 1000
> +                #vlan_id2 = 1001
> +                dts.results_table_add_header(self.header_row)
> +
> +		 # Create pcap file and ixia traffic
> +                for frame_size in self.frame_sizes:
> +                        info = "Running test %s, and %d frame size.\n" %
> (self.running_case, frame_size)
> +                        self.logger.info(info)
> +
> +                        payload_size=frame_size - HEADER_SIZE['eth']-
> HEADER_SIZE['ip']
> +
> flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(
> self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
> +
> flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
> +                        tgenInput = []
> +                        port = self.tester.get_local_port(self.pf)
> +                        tgenInput.append((port,port,"flow2.pcap"))
> +
> +
> +                        _, pps =
> self.tester.traffic_generator_throughput(tgenInput,delay=15)
> +		       #self.verify(pps > 0, "No traffic detected")
> +                        pps /=1000000.0
> +                        linerate = self.wirespeed(self.nic, frame_size, 1)
> +			pct = pps *100/ linerate
> +			scenario = self.running_case
> +			mode = "vhost cuse"
> +                        data_row = [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)
> +
> +
> +
> +	def test_perf_cuse_one_vm_dpdk_fwd(self):
> +
> 	####################################################################
> ##
> +        ## Test the performance of one vm with 2virtio devices in legacy
> fwd
> +
> #####################################################################
> +
> +                # start testpmd on VM
> +		self.vm_testpmd_start()
> +		time.sleep(5)
> +		# Clean the output to make the next command can get correct
> answers
> +		out1 = self.dut.get_session_output(timeout=2)
> +		#print "\nclean out1:", out1
> +		out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
> +		#out = self.dut.get_session_output(timeout=2)
> +                # Get the VLAN ID for virtio
> +		print "\nout:",out
> +		print "\ncheck the vlan info: \n"
> +		l1 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio1_mac)),out)
> +		if len(l1)>0:
> +			vlan_id1=l1[0]
> +			print vlan_id1
> +		l2 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio2_mac)),out)
> +                if len(l2)>0:
> +                        vlan_id2=l2[0]
> +                        print vlan_id2
> +
> +		#vlan_id1 = 1000
> +		#vlan_id2 = 1001
> +		dts.results_table_add_header(self.header_row)
> +
> +		# Create pcap file and ixia traffic
> +		for frame_size in self.frame_sizes:
> +			info = "Running test %s, and %d frame size.\n" %
> (self.running_case, frame_size)
> +                        self.logger.info(info)
> +
> +			payload_size=frame_size - HEADER_SIZE['eth']-
> HEADER_SIZE['ip']
> +
> 	flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d
> )]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
> +
> 	flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
> +		        tgenInput = []
> +			port = self.tester.get_local_port(self.pf)
> +			tgenInput.append((port,port,"flow1.pcap"))
> +			tgenInput.append((port,port,"flow2.pcap"))
> +
> +			_, pps =
> self.tester.traffic_generator_throughput(tgenInput,delay=15)
> +#			self.verify(pps > 0, "No traffic detected")
> +			pps /=1000000.0
> +			linerate = self.wirespeed(self.nic, frame_size, 1)
> +			pct = pps *100/ linerate
> +			scenario = self.running_case
> +			mode = "vhost user"
> +			data_row = [scenario, mode, frame_size, str(pps),
> str(pct)]
> +			dts.results_table_add_row(data_row)
> +
> +		dts.results_table_print()
> +		# Stop testpmd
> +		print self.vm_dut.send_expect("stop", "testpmd>")
> +                time.sleep(1)
> +		self.vm_dut.send_expect("quit", "# ")
> +		#self.vm.stop()
> +
> +
> +		# Stop the Vhost sample
> +		#self.dut.send_expect("^C", "#")
> +		self.dut.send_expect("killall -s INT vhost-switch", "#")
> +
> +	def test_perf_cuse_one_vm_legacy_fwd_jumboframe(self):
> +		self.test_perf_cuse_one_vm_legacy_fwd()
> +
> +	def test_perf_cuse_one_vm_dpdk_fwd_jumboframe(self):
> +		self.test_perf_cuse_one_vm_dpdk_fwd()
> +
> +
> +	def tear_down(self):
> +		###################################
> +        	## Run after each test case.
> +        	################################
> +		self.clear_vhost_env()
> +		self.dut.kill_all()
> +		time.sleep(2)
> +
> +
> +	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/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=y/' ./con
> fig/common_linuxapp", "# ", 30)
> +		self.dut.build_install_dpdk(self.target)
> +		time.sleep(20)
> +
> --
> 2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dts] [PATCH 5/5] add vhost-user one vm sample case
  2015-07-13  1:14 ` [dts] [PATCH 5/5] add vhost-user one vm sample case Qian Xu
@ 2015-07-13  1:25   ` Liu, Yong
  0 siblings, 0 replies; 11+ messages in thread
From: Liu, Yong @ 2015-07-13  1:25 UTC (permalink / raw)
  To: Xu, Qian Q, dts

Qian, please use pep8 tool to check with this patch. Please also remove those useless code start with "#". 

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> Sent: Monday, July 13, 2015 9:14 AM
> To: dts@dpdk.org
> Subject: [dts] [PATCH 5/5] add vhost-user one vm sample case
> 
> Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> 
> 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
> +# 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.
> +
> +"""
> +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):
> +
> +	def set_up_all(self):
> +		# To Extend IXIA packet generator method, call the tester's
> method.
> +
> 	self.tester.extend_external_packet_generator(TestVhostSample,self)
> +
> +        	# Change config file,no need now since the default is y.
> +            	#self.dut.send_expect("sed -i -e
> 's/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=y/' ./config/common
> _linuxapp", "# ", 30)
> +
> +		# Build target with modified config file
> +	    	self.dut.build_install_dpdk(self.target)
> +
> +
> +		# Get and verify the ports
> +		self.dut_ports = self.dut.get_ports()
> +		self.verify(len(self.dut_ports) >= 1, "Insufficient ports for
> testing")
> +
> +		# Get the port's socket
> + 		self.pf = self.dut_ports[0]
> +		netdev = self.dut.ports_info[self.pf]['port']
> +		self.socket = netdev.get_nic_socket()
> +		self.cores = self.dut.get_core_list("1S/2C/1T",
> socket=self.socket)
> +
> +		# Set the params of vhost sample
> +		self.vhost_app = "./examples/vhost/build/vhost-switch"
> +		self.zero_copy = 0
> +		self.vm2vm = 0
> +		self.jumbo = 0
> +		#self.rxq = 1
> +		# Using file to save the vhost sample output since in
> jumboframe case, there will be lots of output
> +		self.vhost_test = self.vhost_app + " -c %s -n %d --socket-mem
> 1024,1024 -- -p 0x1 --mergeable %d --zero-copy %d --vm2vm %d
> 2 > ./vhost.out &"
> + 		# build the vhost sample in vhost-user mode.
> +		self.dut.send_expect("sed -i -e 's/define MAX_QUEUES
> 512/define MAX_QUEUES 128/' ./examples/vhost/main.c", "#")
> +		out = 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")
> +
> +		# Define the virtio/VM variables
> +		self.virtio1 = "eth1"
> +		self.virtio2 = "eth2"
> +		self.virtio1_mac = "52:54:00:00:00:01"
> +		self.virtio2_mac = "52:54:00:00:00:02"
> +		self.src1 = "192.168.4.1"
> +		self.src2 = "192.168.3.1"
> +		self.dst1 = "192.168.3.1"
> +		self.dst2 = "192.168.4.1"
> +		self.vm_dut = None
> +
> +		self.header_row = ["Test","Mode", "Frame", "Mpps", "%
> linerate"]
> +		self.memory_channel = 4
> +
> +	def set_up(self):
> +        ######################################
> +        ## Run before each test case.
> +        ######################################

Please use """ for function description. This will be used for function's doc string.

> +		# Launch vhost sample using default params
> +
> +		if "jumbo" in self.running_case:
> +			self.jumbo = 1
> +			self.frame_sizes =
> [68,128,256,512,1024,1280,1518,1522,2048,5000,9000]
> +			#self.frame_sizes = [256,5000]
> +			self.vm_testpmd = "./x86_64-native-linuxapp-
> gcc/app/testpmd -c f -n 3" \
> +                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-
> filter --max-pkt-len 9600"
> +		else:
> +			self.jumbo = 0
> +			self.frame_sizes = [68,128,256,512,1024,1280,1518]
> +			#self.frame_sizes = [68, 128]
> +			self.vm_testpmd = "./x86_64-native-linuxapp-
> gcc/app/testpmd -c f -n 3" \
> +                          + " -- -i --txqflags=0xf00 --disable-hw-vlan-
> filter"
> +		self.dut.send_expect("rm -rf ./vhost.out", "#")
> +
> +		self.launch_vhost_sample()
> +
> +		print "Start VM with 2virtio\n"
> +               	# start VM with 2virtio
> +           	self.start_onevm()
> +

Please use dts.GREEN to emphasize the log.

> +
> +	def launch_vhost_sample(self):
> +	####################################################################
> +	## Launch the vhost sample with different parameters
> +	####################################################################
> 
> +		self.coremask = dts.create_mask(self.cores)
> +		self.vhostapp_testcmd = self.vhost_test %(self.coremask,
> self.memory_channel, self.jumbo, self.zero_copy,
> +							self.vm2vm)
> +#		self.dut.send_expect(self.vhostapp_testcmd, "VHOST_CONFIG:
> bind to vhost-net", 120)
> +		self.dut.send_expect(self.vhostapp_testcmd, "# ", 40)
> +                time.sleep(30)
> +		try:
> +			print "Launch vhost sample\n"
> +			out = 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))
> +				self.dut.send_expect("rm -rf ./vhost-net" ,"#", 20)
> +
> +	def start_onevm(self):
> +	#####################################
> +	## Start One VM with 2 virtio devices
> +	#####################################
> +
> +		self.vm = QEMUKvm(self.dut, 'vm0', 'vhost_sample')
> +		#qemu_path = "/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 ={}
> +			vm_params['driver'] = 'vhost-user'
> +			vm_params['opt_path'] = './vhost-net'
> +			vm_params['opt_mac'] = self.virtio1_mac
> +			self.vm.set_vm_device(**vm_params)
> +	        	vm_params['opt_mac'] = self.virtio2_mac
> +			self.vm.set_vm_device(**vm_params)
> +
> +		try:
> +			self.vm_dut = self.vm.start(auto_portmap=False)
> +			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))
> +
> +		return True
> +
> +	def vm_testpmd_start(self):
> +	#######################################################
> +	## 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:
> +			self.vm_dut.kill_all()
> +			time.sleep(1)
> +			self.vm_dut.close()
> +			self.vm_dut.logger.logger_exit()
> +			self.vm_dut = None
> +		if self.vm:
> +			self.vm.stop()
> +			self.vm = None
> +
> +
> +	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", "#")
> +
> +	def set_onevm_legacy_fwd(self):
> +		if self.vm_dut is not None:
> +			ifcfg = self.vm_dut.send_expect("ifconfig -a", "#", 10)
> +                	intfs = re.compile('eth\d').findall(ifcfg)
> +			# Find the virtio1 and virtio2's interface names
> +                	for intf in intfs:
> +                        	out_mac =
> self.vm_dut.send_expect("ifconfig %s" %intf, "#", 10)
> +                        	if self.virtio1_mac in out_mac:
> +                                	self.virtio1 = intf
> +                        	if self.virtio2_mac in out_mac:
> +                                	self.virtio2 = 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 == 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
> +			self.vm_dut.send_expect("ip addr add 192.168.4.2/24
> dev %s" %self.virtio1,"#")
> +                	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.virtio1, "#")
> +                	self.vm_dut.send_expect("ip link set dev %s
> up" %self.virtio2, "#")
> +                	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", "#")
> +
> +
> +
> +	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()
> +
> +		self.set_legacy_disablefw()
> +		# Set the legacy fwd rules then get the VLAN id from vhost
> sample output
> +		self.set_onevm_legacy_fwd()
> +
> +		time.sleep(5)
> +                outdebug = self.dut.get_session_output(timeout=2)
> +                out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
> +                # Get the VLAN ID for virtio
> +                print out, "\ncheck the vlan info: \n"
> +                l1 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio1_mac)),out)
> +                if len(l1)>0:
> +                        vlan_id1=l1[0]
> +                        print "vlan_id1 is ", vlan_id1
> +                l2 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio2_mac)),out)
> +                if len(l2)>0:
> +                        vlan_id2=l2[0]
> +                        print "vlan_id2 is ", vlan_id2
> +
> +                #vlan_id1 = 1000
> +                #vlan_id2 = 1001
> +                dts.results_table_add_header(self.header_row)
> +
> +		 # Create pcap file and ixia traffic
> +                for frame_size in self.frame_sizes:
> +                        info = "Running test %s, and %d frame size.\n" %
> (self.running_case, frame_size)
> +                        self.logger.info(info)
> +
> +                        payload_size=frame_size - HEADER_SIZE['eth']-
> HEADER_SIZE['ip']
> +
> flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d)]' %(
> self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
> +
> flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
> +                        tgenInput = []
> +                        port = self.tester.get_local_port(self.pf)
> +                        tgenInput.append((port,port,"flow2.pcap"))
> +
> +
> +                        _, pps =
> self.tester.traffic_generator_throughput(tgenInput,delay=15)
> +		       #self.verify(pps > 0, "No traffic detected")
> +                        pps /=1000000.0
> +                        linerate = self.wirespeed(self.nic, frame_size, 1)
> +			pct = pps *100/ linerate
> +			scenario = self.running_case
> +			mode = "vhost user"
> +                        data_row = [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)
> +
> +
> +
> +	def test_perf_user_one_vm_dpdk_fwd(self):
> +
> 	####################################################################
> ##
> +        ## Test the performance of one vm with 2virtio devices in legacy
> fwd
> +
> #####################################################################
> +
> +                # start testpmd on VM
> +		self.vm_testpmd_start()
> +		time.sleep(5)
> +		# Clean the output to ensure the commands cat ./vhost.out can
> be sent and got answered correctly.
> +		out_debug = self.dut.get_session_output(timeout=2)
> +		out = self.dut.send_expect("cat ./vhost.out", "# ", 20)
> +		#out = self.dut.get_session_output(timeout=2)
> +                # Get the VLAN ID for virtio
> +		print out, "\ncheck the vlan info: \n"
> +		l1 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio1_mac)),out)
> +		if len(l1)>0:
> +			vlan_id1=l1[0]
> +			print vlan_id1
> +		l2 =
> re.findall('MAC_ADDRESS.*?%s.*?and.*?VLAN_TAG.*?(\d+).*?registered'%(str(s
> elf.virtio2_mac)),out)
> +                if len(l2)>0:
> +                        vlan_id2=l2[0]
> +                        print vlan_id2
> +
> +		#vlan_id1 = 1000
> +		#vlan_id2 = 1001
> +		dts.results_table_add_header(self.header_row)
> +
> +		# Create pcap file and ixia traffic
> +		for frame_size in self.frame_sizes:
> +			info = "Running test %s, and %d frame size.\n" %
> (self.running_case, frame_size)
> +                        self.logger.info(info)
> +
> +			payload_size=frame_size - HEADER_SIZE['eth']-
> HEADER_SIZE['ip']
> +
> 	flow1='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%s")/("X"*%d
> )]' %(self.virtio1_mac,vlan_id1,self.src1,self.dst1,payload_size)
> +
> 	flow2='[Ether(dst="%s")/Dot1Q(vlan=%s)/IP(src="%s",dst="%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=self.ip_virtio
> +		        tgenInput = []
> +			port = self.tester.get_local_port(self.pf)
> +			tgenInput.append((port,port,"flow1.pcap"))
> +			tgenInput.append((port,port,"flow2.pcap"))
> +
> +			_, pps =
> self.tester.traffic_generator_throughput(tgenInput,delay=15)
> +#			self.verify(pps > 0, "No traffic detected")
> +			pps /=1000000.0
> +			linerate = self.wirespeed(self.nic, frame_size, 1)
> +			pct = pps *100/ linerate
> +			scenario = self.running_case
> +			mode = "vhost user"
> +			data_row = [scenario, mode, frame_size, str(pps),
> str(pct)]
> +			dts.results_table_add_row(data_row)
> +
> +		dts.results_table_print()
> +		# Stop testpmd
> +		print self.vm_dut.send_expect("stop", "testpmd>")
> +                time.sleep(1)
> +		self.vm_dut.send_expect("quit", "# ")
> +
> +		# 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()
> +
> +
> +	def tear_down(self):
> +		###################################
> +        	## Run after each test case.
> +        	################################
> +		self.clear_vhost_env()
> +		self.dut.kill_all()
> +		time.sleep(2)
> +
> +
> +	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=y$/RTE_LIBRTE_VHOST=n/' config/common_linuxapp", "#",
> 30)
> +		#self.dut.send_expect("sed -i -e
> 's/CONFIG_RTE_LIBRTE_VHOST_USER=.*$/CONFIG_RTE_LIBRTE_VHOST_USER=n/' ./con
> fig/common_linuxapp", "# ", 30)
> +		#self.dut.build_install_dpdk(self.target)
> +#		time.sleep(20)
> +		pass
> --
> 2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device
  2015-07-13  1:18     ` Xu, Qian Q
@ 2015-07-13  1:26       ` Liu, Yong
  0 siblings, 0 replies; 11+ messages in thread
From: Liu, Yong @ 2015-07-13  1:26 UTC (permalink / raw)
  To: Xu, Qian Q, dts

No more comments on this patch. Just need use pep8 to check the format.

> -----Original Message-----
> From: Xu, Qian Q
> Sent: Monday, July 13, 2015 9:18 AM
> To: Liu, Yong; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio
> pci device
> 
> OK, I can comment them, any other changes needed?
> 
> Thanks
> Qian
> 
> 
> -----Original Message-----
> From: Liu, Yong
> Sent: Monday, July 13, 2015 9:17 AM
> To: Xu, Qian Q; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio
> pci device
> 
> Qian, please remove debug function in your patch.
> 
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Qian Xu
> > Sent: Monday, July 13, 2015 9:14 AM
> > To: dts@dpdk.org
> > Subject: [dts] [PATCH 1/5] add vhost-cuse implementations for virtio
> > pci device
> >
> > Signed-off-by: Qian Xu <qian.q.xu@intel.com>
> >
> > diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index
> > 4ccce81..44db411 100644
> > --- a/framework/qemu_kvm.py
> > +++ b/framework/qemu_kvm.py
> > @@ -85,7 +85,7 @@ class QEMUKvm(VirtBase):
> >          self.char_idx = 0
> >          self.netdev_idx = 0
> >          self.pt_idx = 0
> > -
> > +	self.cuse_id = 0
> >          # devices pass-through into vm
> >          self.pt_devices = []
> >          self.pci_maps = []
> > @@ -569,6 +569,8 @@ class QEMUKvm(VirtBase):
> >                  self.__add_vm_virtio_net_pci(**options)
> >              elif options['driver'] == 'vhost-user':
> >                  self.__add_vm_virtio_user_pci(**options)
> > +	    elif options['driver'] == 'vhost-cuse':
> > +                self.__add_vm_virtio_cuse_pci(**options)
> >
> >      def __add_vm_pci_assign(self, **options):
> >          """
> > @@ -620,6 +622,25 @@ class QEMUKvm(VirtBase):
> >
> >              self.__add_vm_virtio_net_pci(**opts)
> >
> > +    def __add_vm_virtio_cuse_pci(self, **options):
> > +        """
> > +        driver virtio-net-pci
> > +        opt_mac: 52:54:00:00:00:01
> > +        """
> > +        separator = ','
> > +        dev_boot_line = '-netdev tap'
> > +        cuse_id = 'vhost%d' %self.cuse_id
> > +        dev_boot_line += separator + 'id=%s' %cuse_id + separator
> > +'ifname=tap_%s' %cuse_id + separator +"vhost=on" +separator
> +"script=no"
> > +        self.cuse_id += 1
> > +        self.__add_boot_line(dev_boot_line)
> > +        # device parameter
> > +        opts = {'opt_netdev': '%s' % cuse_id ,
> > +                'opt_id': '%s_net' % cuse_id}
> > +        if 'opt_mac' in options.keys() and options['opt_mac']:
> > +                opts['opt_mac'] = options['opt_mac']
> > +	print "debug info: add cuse info:", dev_boot_line
> > +        self.__add_vm_virtio_net_pci(**opts)
> > +
> >      def __add_vm_virtio_net_pci(self, **options):
> >          """
> >          driver: virtio-net-pci
> > --
> > 2.1.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-07-13  1:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13  1:14 [dts] [PATCH 0/5]Add vhost-user and vhost-cuse one vm sample case Qian Xu
2015-07-13  1:14 ` [dts] [PATCH 1/5] add vhost-cuse implementations for virtio pci device Qian Xu
2015-07-13  1:17   ` Liu, Yong
2015-07-13  1:18     ` Xu, Qian Q
2015-07-13  1:26       ` Liu, Yong
2015-07-13  1:14 ` [dts] [PATCH 2/5] add vhost-cuse sample config file for reference Qian Xu
2015-07-13  1:14 ` [dts] [PATCH 3/5] add the vhost-user " Qian Xu
2015-07-13  1:14 ` [dts] [PATCH 4/5] add vhost-cuse one vm sample Qian Xu
2015-07-13  1:19   ` Liu, Yong
2015-07-13  1:14 ` [dts] [PATCH 5/5] add vhost-user one vm sample case Qian Xu
2015-07-13  1:25   ` 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).