def GetNicObj(crb, domain_id, bus_id, devfun_id): """ Get network device object. If network device has been initialized, just return object. Based on nic type, some special nics like RRC will return object different from default. """ # find existed NetDevice object obj = get_from_list(crb.crb['My IP'], domain_id, bus_id, devfun_id) if obj: return obj pci_id = get_pci_id(crb, domain_id, bus_id, devfun_id) nic = settings.get_nic_name(pci_id) if nic == 'redrockcanyou': # redrockcanyou nic need special initialization from rrc import RedRockCanyou obj = RedRockCanyou(crb, domain_id, bus_id, devfun_id) elif nic == 'atwood': # atwood nic need special initialization from atwood import Atwood obj = Atwood(crb, domain_id, bus_id, devfun_id) elif nic == 'boulderrapid': # atwood nic need special initialization from br import BoulderRapid obj = BoulderRapid(crb, domain_id, bus_id, devfun_id) else: obj = NetDevice(crb, domain_id, bus_id, devfun_id) add_to_list(crb.crb['My IP'], obj) return obj
def wirespeed(self, nic, frame_size, num_ports): """ Calculate bit rate. It is depended for NICs """ bitrate = 1000.0 # 1Gb ('.0' forces to operate as float) if self.nic == "any" or self.nic == "cfg": driver = self._get_nic_driver(self.dut.ports_info[0]['type']) nic = get_nic_name(self.dut.ports_info[0]['type']) else: driver = self._get_nic_driver(self.nic) nic = self.nic if driver == "ixgbe": bitrate *= 10 # 10 Gb NICs elif nic == "avoton2c5": bitrate *= 2.5 # 2.5 Gb NICs elif nic in ["fortville_spirit", "fortville_spirit_single"]: bitrate *= 40 elif nic == 'fortville_eagle': bitrate *= 10 elif nic == 'fortpark_TLV': bitrate *= 10 elif nic == 'redrockcanyou': bitrate *= 40 elif driver == 'thunder-nicvf': bitrate *= 10 return bitrate * num_ports / 8 / (frame_size + 20)
def _check_nic(self, nic_type): if 'all' == nic_type[0].lower(): return True dut_nic_type = get_nic_name(self.dut.ports_info[0]['type']) if dut_nic_type in nic_type: return True else: return False
def GetNicObj(crb, domain_id, bus_id, devfun_id): """ Get NICs object. If NICs has been initialized, just return object. """ obj = get_from_list(crb.crb['My IP'], domain_id, bus_id, devfun_id) if obj: return obj pci_id = get_pci_id(crb, domain_id, bus_id, devfun_id) nic = settings.get_nic_name(pci_id) obj = NetDevice(crb, domain_id, bus_id, devfun_id) add_to_list(crb.crb['My IP'], obj) return obj
def test_vf_vlan_strip(self): random_vlan = random.randint(1, MAX_VLAN - 1) rx_vlans = [1, random_vlan, MAX_VLAN] # start testpmd in VM self.vm0_dut_ports = self.vm_dut_0.get_ports('any') self.vm0_testpmd = PmdOutput(self.vm_dut_0) if self.kdriver == "i40e": self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '') else: self.vm0_testpmd.start_testpmd(VM_CORES_MASK) self.vm0_testpmd.execute_cmd('set fwd rxonly') self.vm0_testpmd.execute_cmd('set verbose 1') self.vm0_testpmd.execute_cmd('start') for rx_vlan in rx_vlans: self.vm0_testpmd.execute_cmd('vlan set strip on 0') self.vm0_testpmd.execute_cmd('rx_vlan add %d 0' % rx_vlan) time.sleep(1) out = self.send_and_getout(vlan=rx_vlan, pkt_type="VLAN_UDP") # enable strip, vlan will be in mbuf vlan_hex = hex(rx_vlan) self.verify("VLAN tci=%s" % vlan_hex in out, "Failed to strip vlan packet!!!") self.verify("PKT_RX_VLAN_STRIPPED" in out, "Failed to strip vlan packet!") self.vm0_testpmd.execute_cmd('vlan set strip off 0') out = self.send_and_getout(vlan=rx_vlan, pkt_type="VLAN_UDP") self.verify("received 1 packets" in out, "Not received vlan packet as expected!!!") nic_type = self.vm_dut_0.ports_info[0]['type'] nic_name = get_nic_name(nic_type) if nic_name in ['fvl10g_vf', 'fortpark_TLV_vf']: self.verify("VLAN tci=%s" % vlan_hex in out, "Failed to disable strip vlan!!!") else: self.verify("PKT_RX_VLAN_STRIPPED" not in out, "Failed to disable strip vlan!!!") self.vm0_testpmd.quit()
def __init__(self, duts, tester, target, suitename): self.suite_name = suitename self.dut = duts[0] self.duts = duts self.tester = tester self.target = target # local variable self._requested_tests = None # check session and reconnect if possible for dutobj in self.duts: self._check_and_reconnect(crb=dutobj) self._check_and_reconnect(crb=self.tester) # covert netdevice to codename self.nics = [] for portid in range(len(self.dut.ports_info)): nic_type = self.dut.ports_info[portid]['type'] self.nics.append(get_nic_name(nic_type)) if len(self.nics): self.nic = self.nics[0] else: self.nic = '' self.kdriver = self._get_nic_driver(self.nic) # result object for save suite result self._suite_result = Result() self._suite_result.dut = self.dut.crb['IP'] self._suite_result.target = target self._suite_result.nic = self.nic self._suite_result.test_suite = self.suite_name if self._suite_result is None: raise ValueError("Result object should not None") # load running enviornment if load_global_setting(PERF_SETTING) == "yes": self._enable_perf = True else: self._enable_perf = False if load_global_setting(FUNC_SETTING) == "yes": self._enable_func = True else: self._enable_func = False if load_global_setting(DEBUG_SETTING) == "yes": self._enable_debug = True else: self._enable_debug = False if load_global_setting(DEBUG_CASE_SETTING) == "yes": self._debug_case = True else: self._debug_case = False self.drivername = load_global_setting(HOST_DRIVER_SETTING) # create rst format report for this suite self._rst_obj = RstReport('rst_report', target, self.nic, self.suite_name, self._enable_perf) # load suite configuration self._suite_conf = SuiteConf(self.suite_name) self._suite_cfg = self._suite_conf.suite_cfg