def setup_3vf_2vm_env(self, driver='default'): self.used_dut_port = self.dut_ports[0] self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 3, driver=driver) self.sriov_vfs_port = self.dut.ports_info[ self.used_dut_port]['vfs_port'] try: for port in self.sriov_vfs_port: print port.pci port.bind_driver(self.vf_driver) time.sleep(1) vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci} vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci} vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci} for port_id in self.dut_ports: if port_id == self.used_dut_port: continue port = self.dut.ports_info[port_id]['port'] port.bind_driver() if driver == 'igb_uio': self.host_testpmd = PmdOutput(self.dut) eal_param = '-b %(vf0)s -b %(vf1)s -b %(vf2)s' % { 'vf0': self.sriov_vfs_port[0].pci, 'vf1': self.sriov_vfs_port[1].pci, 'vf2': self.sriov_vfs_port[2].pci } if (self.nic in ["niantic", "sageville", "sagepond"]): self.host_testpmd.start_testpmd("1S/9C/1T", "--txq=4 --rxq=4 ", eal_param=eal_param) else: self.host_testpmd.start_testpmd("1S/2C/2T", eal_param=eal_param) # set up VM0 ENV self.vm0 = VM(self.dut, 'vm0', 'vf_packet_rxtx') self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop) self.vm_dut_0 = self.vm0.start() if self.vm_dut_0 is None: raise Exception("Set up VM0 ENV failed!") # set up VM1 ENV self.vm1 = VM(self.dut, 'vm1', 'vf_packet_rxtx') self.vm1.set_vm_device(driver=self.vf_assign_method, **vf2_prop) self.vm_dut_1 = self.vm1.start() if self.vm_dut_1 is None: raise Exception("Set up VM1 ENV failed!") self.setup_3vf_2vm_env_flag = 1 except Exception as e: self.destroy_3vf_2vm_env() raise Exception(e)
def start_one_vm(self, modem=0, mergeable=0): """ start qemu """ self.vm = VM(self.dut, 'vm0', 'vhost_sample') vm_params = {} vm_params['driver'] = 'vhost-user' vm_params['opt_path'] = './vhost-net' vm_params['opt_mac'] = self.virtio1_mac if modem == 1 and mergeable == 0: vm_params[ 'opt_settings'] = "disable-modern=false,mrg_rxbuf=off,rx_queue_size=1024,tx_queue_size=1024" elif modem == 1 and mergeable == 1: vm_params[ 'opt_settings'] = "disable-modern=false,mrg_rxbuf=on,rx_queue_size=1024,tx_queue_size=1024" elif modem == 0 and mergeable == 0: vm_params[ 'opt_settings'] = "disable-modern=true,mrg_rxbuf=off,rx_queue_size=1024,tx_queue_size=1024" elif modem == 0 and mergeable == 1: vm_params[ 'opt_settings'] = "disable-modern=true,mrg_rxbuf=on,rx_queue_size=1024,tx_queue_size=1024" self.vm.set_vm_device(**vm_params) try: self.vm_dut = self.vm.start() if self.vm_dut is None: raise Exception("Set up VM ENV failed") except Exception as e: self.logger.error("ERROR: Failure for %s" % str(e))
def setup_1pf_2vf_1vm_env(self, driver='default'): self.used_dut_port = self.dut_ports[0] self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver=driver) self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port'] try: for port in self.sriov_vfs_port: port.bind_driver(self.vf_driver) time.sleep(1) vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci} vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci} if driver == 'igb_uio': # start testpmd without the two VFs on the host self.host_testpmd = PmdOutput(self.dut) eal_param = '-b %(vf0)s -b %(vf1)s' % {'vf0': self.sriov_vfs_port[0].pci, 'vf1': self.sriov_vfs_port[1].pci} self.host_testpmd.start_testpmd("1S/2C/2T", eal_param=eal_param) # set up VM0 ENV self.vm0 = VM(self.dut, 'vm0', 'vf_port_start_stop') self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop) self.vm_dut_0 = self.vm0.start() if self.vm_dut_0 is None: raise Exception("Set up VM0 ENV failed!") self.setup_1pf_2vf_1vm_env_flag = 1 except Exception as e: self.destroy_1pf_2vf_1vm_env() raise Exception(e)
def setup_2pf_2vf_1vm_env(self, driver='default'): self.used_dut_port_0 = self.dut_ports[0] self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver=driver) self.sriov_vfs_port_0 = self.dut.ports_info[ self.used_dut_port_0]['vfs_port'] self.used_dut_port_1 = self.dut_ports[1] self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, driver=driver) self.sriov_vfs_port_1 = self.dut.ports_info[ self.used_dut_port_1]['vfs_port'] try: for port in self.sriov_vfs_port_0: port.bind_driver(self.vf_driver) for port in self.sriov_vfs_port_1: port.bind_driver(self.vf_driver) time.sleep(1) vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci} vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci} if driver == 'igb_uio': # start testpmd without the two VFs on the host self.host_testpmd = PmdOutput(self.dut) eal_param = '-b %(vf0)s -b %(vf1)s' % { 'vf0': self.sriov_vfs_port_0[0].pci, 'vf1': self.sriov_vfs_port_1[0].pci } if (self.nic in ["niantic", "sageville", "sagepond"]): self.host_testpmd.start_testpmd("1S/9C/1T", "--txq=4 --rxq=4 ", eal_param=eal_param) else: self.host_testpmd.start_testpmd("1S/5C/1T", "", eal_param=eal_param) # set up VM0 ENV self.vm0 = VM(self.dut, 'vm0', 'vf_packet_rxtx') self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop) self.vm_dut_0 = self.vm0.start() if self.vm_dut_0 is None: raise Exception("Set up VM0 ENV failed!") self.setup_2pf_2vf_1vm_env_flag = 1 except Exception as e: self.destroy_2pf_2vf_1vm_env() raise Exception(e)
def setup_vm_env(self, driver='default'): """ Create testing environment with 1VF generated from 1PF """ if self.env_done: return # bind to default driver self.bind_nic_driver(self.dut_ports[:1], driver="") self.used_dut_port = self.dut_ports[0] self.host_intf = self.dut.ports_info[self.used_dut_port]['intf'] tester_port = self.tester.get_local_port(self.used_dut_port) self.tester_intf = self.tester.get_interface(tester_port) self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1, driver=driver) self.sriov_vfs_port = self.dut.ports_info[ self.used_dut_port]['vfs_port'] self.vf_mac = "00:10:00:00:00:00" self.dut.send_expect( "ip link set %s vf 0 mac %s" % (self.host_intf, self.vf_mac), "# ") try: for port in self.sriov_vfs_port: port.bind_driver(self.vf_driver) time.sleep(1) vf_popt = {'opt_host': self.sriov_vfs_port[0].pci} # set up VM ENV self.vm = VM(self.dut, 'vm0', 'vf_jumboframe') self.vm.set_vm_device(driver=self.vf_assign_method, **vf_popt) self.vm_dut = self.vm.start() if self.vm_dut is None: raise Exception("Set up VM ENV failed!") TESTPMD_MAIN = "app/test-pmd/testpmd.c" if self.kdriver == "ixgbe": self.vm_dut.send_expect( "sed -i -e 's/.jumbo_frame = .*$/.jumbo_frame = 1,/g' %s" % TESTPMD_MAIN, "# ") self.vm_dut.build_install_dpdk(self.target) self.vm_testpmd = PmdOutput(self.vm_dut) except Exception as e: self.destroy_vm_env() raise Exception(e) self.env_done = True
def set_up_vf_to_vf_env(self, driver='default'): self.pf_port_for_vfs = self.dut_ports[0] self.dut.restore_interfaces() self.dut.generate_sriov_vfs_by_port( self.pf_port_for_vfs, VF_NUMS_ON_ONE_PF, driver=driver) self.sriov_vfs_ports = self.dut.ports_info[ self.pf_port_for_vfs]['vfs_port'] self.host_port_intf = self.dut.ports_info[self.pf_port_for_vfs]['intf'] for i in range(VF_NUMS_ON_ONE_PF): self.dut.send_expect('ip link set dev %s vf %d mac %s' % (self.host_port_intf, i, VF_TEMP_MAC % i), '#', 10) try: for port in self.sriov_vfs_ports: port.bind_driver(self.vf_driver) time.sleep(1) except Exception as e: raise Exception(e) vf0_prop = {'opt_host': self.sriov_vfs_ports[0].pci} vf1_prop = {'opt_host': self.sriov_vfs_ports[1].pci} time.sleep(1) self.vm0 = VM(self.dut, 'vm0', 'vf_to_vf_bridge') self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) try: self.vm0_dut = self.vm0.start() if self.vm0_dut is None: raise Exception('Set up VM0 failed') except Exception as e: print utils.RED(str(e)) self.vm1 = VM(self.dut, 'vm1', 'vf_to_vf_bridge') self.vm1.set_vm_device(driver=self.vf_assign_method, **vf1_prop) try: self.vm1_dut = self.vm1.start() if self.vm1_dut is None: raise Exception('Set up VM1 failed') except Exception as e: print utils.RED(str(e))
def start_onevm(self): """ Start One VM with one virtio device """ self.vm = VM(self.dut, 'vm0', 'vhost_sample') vm_params = {} vm_params['driver'] = 'vhost-user' vm_params['opt_path'] = './vhost-net' vm_params['opt_mac'] = self.virtio1_mac vm_params['opt_queue'] = self.queue_number vm_params['opt_settings'] = 'mrg_rxbuf=on,mq=on,vectors=%d' % ( 2 * self.queue_number + 2) self.vm.set_vm_device(**vm_params) try: self.vm_dut = self.vm.start() if self.vm_dut is None: raise Exception("Set up VM ENV failed") except Exception as e: self.logger.error("ERROR: Failure for %s" % str(e)) return True
def setup_vm_env(self, driver='default'): """ Create testing environment with 2VFs generated from 2PFs """ if self.env_done: return # bind to default driver self.bind_nic_driver(self.dut_ports[:2], driver="") self.used_dut_port_0 = self.dut_ports[0] self.host_intf0 = self.dut.ports_info[self.used_dut_port_0]['intf'] tester_port = self.tester.get_local_port(self.used_dut_port_0) self.tester_intf0 = self.tester.get_interface(tester_port) self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver=driver) self.sriov_vfs_port_0 = self.dut.ports_info[ self.used_dut_port_0]['vfs_port'] self.vf0_mac = "00:10:00:00:00:00" self.dut.send_expect( "ip link set %s vf 0 mac %s" % (self.host_intf0, self.vf0_mac), "# ") self.used_dut_port_1 = self.dut_ports[1] self.host_intf1 = self.dut.ports_info[self.used_dut_port_1]['intf'] self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, driver=driver) self.sriov_vfs_port_1 = self.dut.ports_info[ self.used_dut_port_1]['vfs_port'] tester_port = self.tester.get_local_port(self.used_dut_port_1) self.tester_intf1 = self.tester.get_interface(tester_port) self.vf1_mac = "00:20:00:00:00:00" self.dut.send_expect( "ip link set %s vf 0 mac %s" % (self.host_intf1, self.vf1_mac), "# ") try: for port in self.sriov_vfs_port_0: port.bind_driver(self.vf_driver) for port in self.sriov_vfs_port_1: port.bind_driver(self.vf_driver) time.sleep(1) vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci} vf1_prop = {'opt_host': self.sriov_vfs_port_1[0].pci} # set up VM0 ENV self.vm0 = VM(self.dut, 'vm0', 'vf_vlan') self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop) self.vm_dut_0 = self.vm0.start() if self.vm_dut_0 is None: raise Exception("Set up VM0 ENV failed!") except Exception as e: self.destroy_vm_env() raise Exception(e) self.env_done = True