diff options
author | Marvin Liu <yong.liu@intel.com> | 2016-04-22 09:42:47 +0800 |
---|---|---|
committer | Marvin Liu <yong.liu@intel.com> | 2016-04-22 09:42:47 +0800 |
commit | 9413f1fc1443d6f737269f88669a32a2313aafbd (patch) | |
tree | 68b38ec409e1623727d8f15d9eb9717f639c55ab | |
parent | e65f16e7d7d2f92bc9cb82d49c706503f2767d30 (diff) | |
parent | adfaa5ba726c535bf96a2ecc9013313b396ed0f3 (diff) |
Merge branch 'next'
-rw-r--r-- | conf/ports.cfg | 8 | ||||
-rw-r--r-- | framework/config.py | 2 | ||||
-rw-r--r-- | framework/crb.py | 92 | ||||
-rw-r--r-- | framework/dut.py | 75 | ||||
-rw-r--r-- | framework/project_dpdk.py | 2 | ||||
-rw-r--r-- | framework/settings.py | 2 | ||||
-rw-r--r-- | framework/tester.py | 45 | ||||
-rw-r--r-- | framework/virt_dut.py | 7 | ||||
-rw-r--r-- | nics/net_device.py | 212 | ||||
-rw-r--r-- | tests/TestSuite_blacklist.py | 8 | ||||
-rw-r--r-- | tests/TestSuite_coremask.py | 20 | ||||
-rw-r--r-- | tests/TestSuite_multiprocess.py | 42 |
12 files changed, 301 insertions, 214 deletions
diff --git a/conf/ports.cfg b/conf/ports.cfg index 2c9a60a..7fa7aae 100644 --- a/conf/ports.cfg +++ b/conf/ports.cfg @@ -14,9 +14,9 @@ ports = pci=XX:XX.X,intf=eth0; pci=YY:YY.Y,mac=XX:XX:XX:XX:XX:XX,peer=ZZ:ZZ.Z,numa=0; pci=ZZ:ZZ.Y,peer=IXIA:X.Y; - pci=XX:XX.X,peer=ZZ:ZZ.Z,tp_ip=127.0.0.1,tp_path=/home/libertyTrailTP_322291/perl; - pci=YY:YY.Y,peer=ZZ:ZZ.Z,sec_port=yes,first_port=XX:XX.X; + pci=0000:XX:XX.X,peer=0000:ZZ:ZZ.Z,tp_ip=127.0.0.1,tp_path=/home/libertyTrailTP_322291/perl; + pci=0000:YY:YY.Y,peer=0000:ZZ:ZZ.Z,sec_port=yes,first_port=XX:XX.X; [VM NAME] ports = - dev_idx=0,peer=XX:XX.X; - dev_idx=1,peer=YY:YY.Y; + dev_idx=0,peer=0000:XX:XX.X; + dev_idx=1,peer=0000:YY:YY.Y; diff --git a/framework/config.py b/framework/config.py index 37606de..8d564a6 100644 --- a/framework/config.py +++ b/framework/config.py @@ -130,7 +130,7 @@ class PortConf(UserConf): def __init__(self, port_conf=PORTCONF): self.config_file = port_conf self.ports_cfg = {} - self.pci_regex = "([\da-f]{2}:[\da-f]{2}.\d{1})$" + self.pci_regex = "([\da-f]{4}:[\da-f]{2}:[\da-f]{2}.\d{1})$" try: self.port_conf = UserConf(self.config_file) except ConfigParseException: diff --git a/framework/crb.py b/framework/crb.py index f2009b9..3194f69 100644 --- a/framework/crb.py +++ b/framework/crb.py @@ -161,18 +161,20 @@ class Crb(object): """ Set numbers of huge pages """ + page_size = self.send_expect("awk '/Hugepagesize/ {print $2}' /proc/meminfo", "# ") + if numa == -1: - self.send_expect('echo %d > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages' % huge_pages, '# ', 5) + self.send_expect('echo %d > /sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % (huge_pages, page_size), '# ', 5) else: #sometimes we set hugepage on kernel cmdline, so we need clear default hugepage - self.send_expect('echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages', '# ', 5) + self.send_expect('echo 0 > /sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % (page_size), '# ', 5) #some platform not support numa, example vm dut try: - self.send_expect('echo %d > /sys/devices/system/node/node%d/hugepages/hugepages-2048kB/nr_hugepages' % (huge_pages, numa), '# ', 5) + self.send_expect('echo %d > /sys/devices/system/node/node%d/hugepages/hugepages-%skB/nr_hugepages' % (huge_pages, numa, page_size), '# ', 5) except: self.logger.warning("set %d hugepage on socket %d error" % (huge_pages, numa)) - self.send_expect('echo %d > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages' % huge_pages, '# ', 5) + self.send_expect('echo %d > /sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % (huge_pages. page_size), '# ', 5) def set_speedup_options(self, read_cache, skip_setup): """ @@ -235,8 +237,8 @@ class Crb(object): Look for the NIC's information (PCI Id and card type). """ out = self.send_expect( - "lspci -nn | grep -i eth", "# ", alt_session=True) - rexp = r"([\da-f]{2}:[\da-f]{2}.\d{1}) .*Eth.*?ernet .*?([\da-f]{4}:[\da-f]{4})" + "lspci -Dnn | grep -i eth", "# ", alt_session=True) + rexp = r"([\da-f]{4}:[\da-f]{2}:[\da-f]{2}.\d{1}) .*Eth.*?ernet .*?([\da-f]{4}:[\da-f]{4})" pattern = re.compile(rexp) match = pattern.findall(out) self.pci_devices_info = [] @@ -257,20 +259,20 @@ class Crb(object): card_type = "8086:%s" % match[i][1] self.pci_devices_info.append((match[i][0], card_type)) - def get_pci_dev_driver(self, bus_id, devfun_id): + def get_pci_dev_driver(self, domain_id, bus_id, devfun_id): """ Get the driver of specified pci device. """ get_pci_dev_driver = getattr( self, 'get_pci_dev_driver_%s' % self.get_os_type()) - return get_pci_dev_driver(bus_id, devfun_id) + return get_pci_dev_driver(domain_id, bus_id, devfun_id) - def get_pci_dev_driver_linux(self, bus_id, devfun_id): + def get_pci_dev_driver_linux(self, domain_id, bus_id, devfun_id): """ Get the driver of specified pci device on linux. """ - out = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/uevent" % - (bus_id, devfun_id), "# ", alt_session=True) + out = self.send_expect("cat /sys/bus/pci/devices/%s\:%s\:%s/uevent" % + (domain_id, bus_id, devfun_id), "# ", alt_session=True) rexp = r"DRIVER=(.+?)\r" pattern = re.compile(rexp) match = pattern.search(out) @@ -284,20 +286,20 @@ class Crb(object): """ return True - def get_pci_dev_id(self, bus_id, devfun_id): + def get_pci_dev_id(self, domain_id, bus_id, devfun_id): """ Get the pci id of specified pci device. """ get_pci_dev_id = getattr( self, 'get_pci_dev_id_%s' % self.get_os_type()) - return get_pci_dev_id(bus_id, devfun_id) + return get_pci_dev_id(domain_id, bus_id, devfun_id) - def get_pci_dev_id_linux(self, bus_id, devfun_id): + def get_pci_dev_id_linux(self, domain_id, bus_id, devfun_id): """ Get the pci id of specified pci device on linux. """ - out = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/uevent" % - (bus_id, devfun_id), "# ", alt_session=True) + out = self.send_expect("cat /sys/bus/pci/devices/%s\:%s\:%s/uevent" % + (domain_id, bus_id, devfun_id), "# ", alt_session=True) rexp = r"PCI_ID=(.+)" pattern = re.compile(rexp) match = re.search(out) @@ -305,21 +307,21 @@ class Crb(object): return None return match.group(1) - def get_device_numa(self, bus_id, devfun_id): + def get_device_numa(self, domain_id, bus_id, devfun_id): """ Get numa number of specified pci device. """ get_device_numa = getattr( self, "get_device_numa_%s" % self.get_os_type()) - return get_device_numa(bus_id, devfun_id) + return get_device_numa(domain_id, bus_id, devfun_id) - def get_device_numa_linux(self, bus_id, devfun_id): + def get_device_numa_linux(self, domain_id, bus_id, devfun_id): """ Get numa number of specified pci device on Linux. """ numa = self.send_expect( - "cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node" % - (bus_id, devfun_id), "# ", alt_session=True) + "cat /sys/bus/pci/devices/%s\:%s\:%s/numa_node" % + (domain_id, bus_id, devfun_id), "# ", alt_session=True) try: numa = int(numa) @@ -493,41 +495,25 @@ class Crb(object): cpuinfo = \ self.send_expect( - "grep --color=never \"processor\\|physical id\\|core id\\|^$\" /proc/cpuinfo", + "lscpu -p|grep -v \#", "#", alt_session=True) - if "processor" not in cpuinfo: - # yocto not support --color=never, but ubuntu must need --color=never, - # so check cpuinfo, before parsing cpuinfo, if cpuifo get error, delete --color=never - # and get cpuinfo again - cpuinfo = \ - self.send_expect( - r'grep "processor\|physical id\|core id\|^$" /proc/cpuinfo', - "#", alt_session=True) - - cpuinfo = cpuinfo.split('\r\n\r\n') + cpuinfo = cpuinfo.split() # haswell cpu on cottonwood core id not correct # need addtional coremap for haswell cpu core_id = 0 coremap = {} for line in cpuinfo: - m = re.search("processor\t: (\d+)\r\n" + - "physical id\t: (\d+)\r\n" + - "core id\t\t: (\d+)", line) - - if m: - thread = m.group(1) - socket = m.group(2) - core = m.group(3) - - if core not in coremap.keys(): - coremap[core] = core_id - core_id += 1 - - if self.crb['bypass core0'] and core == '0' and socket == '0': - self.logger.info("Core0 bypassed") - continue - self.cores.append( + (thread, core, unused, socket) = line.split(',')[0:4] + + if core not in coremap.keys(): + coremap[core] = core_id + core_id += 1 + + if self.crb['bypass core0'] and core == '0' and socket == '0': + self.logger.info("Core0 bypassed") + continue + self.cores.append( {'thread': thread, 'socket': socket, 'core': coremap[core]}) self.number_of_cores = len(self.cores) @@ -588,17 +574,13 @@ class Crb(object): # return thread list return map(str, thread_list) - def get_core_list(self, config, th=False, socket=-1): + def get_core_list(self, config, socket=-1): """ Get lcore array according to the core config like "all", "1S/1C/1T". We can specify the physical CPU socket by paramter "socket". """ if config == 'all': - - if th: - return [n['thread'] for n in self.cores] - else: - return [n for n in range(0, self.number_of_cores - 1)] + return [n['thread'] for n in self.cores] m = re.match("([1234])S/([1-9]+)C/([12])T", config) diff --git a/framework/dut.py b/framework/dut.py index bd437cb..bcfedb6 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -237,9 +237,10 @@ class Dut(Crb): if driver is not None: # unbind device driver addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] - port = GetNicObj(self, bus_id, devfun_id) + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] + port = GetNicObj(self, domain_id, bus_id, devfun_id) port.stop() def restore_interfaces_linux(self): @@ -254,16 +255,17 @@ class Dut(Crb): if driver is not None: # unbind device driver addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] - port = GetNicObj(self, bus_id, devfun_id) + port = GetNicObj(self, domain_id, bus_id, devfun_id) - self.send_expect('echo 0000:%s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind' - % (pci_bus, bus_id, devfun_id), '# ') + self.send_expect('echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind' + % (pci_bus, domain_id, bus_id, devfun_id), '# ') # bind to linux kernel driver self.send_expect('modprobe %s' % driver, '# ') - self.send_expect('echo 0000:%s > /sys/bus/pci/drivers/%s/bind' + self.send_expect('echo %s > /sys/bus/pci/drivers/%s/bind' % (pci_bus, driver), '# ') itf = port.get_interface_name() self.send_expect("ifconfig %s up" % itf, "# ") @@ -301,6 +303,8 @@ class Dut(Crb): elif self.architecture == "x86_x32": arch_huge_pages = hugepages if hugepages > 0 else 256 force_socket = True + elif self.architecture == "ppc_64": + arch_huge_pages = hugepages if hugepages > 0 else 512 if total_huge_pages != arch_huge_pages: # before all hugepage average distribution by all socket, @@ -565,15 +569,12 @@ class Dut(Crb): for port_info in self.ports_info: port = port_info['port'] - intf = port.get_interface_name() - if "No such file" in intf: - self.logger.info("DUT: [0000:%s] %s" % (pci_bus, unknow_interface)) - continue + intf = port_info['intf'] out = self.send_expect("ip link show %s" % intf, "# ") if "DOWN" in out: self.send_expect("ip link set %s up" % intf, "# ") time.sleep(5) - macaddr = port.get_mac_addr() + macaddr = port_info['mac'] out = self.send_expect("ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'" % intf, "# ") ipv6 = out.split('/')[0] @@ -581,8 +582,6 @@ class Dut(Crb): if ":" not in ipv6: ipv6 = "Not connected" - port_info['mac'] = macaddr - port_info['intf'] = intf port_info['ipv6'] = ipv6 def rescan_ports_uncached_freebsd(self): @@ -592,7 +591,7 @@ class Dut(Crb): port = port_info['port'] intf = port.get_interface_name() if "No such file" in intf: - self.logger.info("DUT: [0000:%s] %s" % (pci_bus, unknow_interface)) + self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface)) continue self.send_expect("ifconfig %s up" % intf, "# ") time.sleep(5) @@ -652,7 +651,7 @@ class Dut(Crb): port = GetNicObj(self, port_info['pci'], port_info['type']) intf = port.get_interface_name() - self.logger.info("DUT cached: [000:%s %s] %s" % (port_info['pci'], + self.logger.info("DUT cached: [%s %s] %s" % (port_info['pci'], port_info['type'], intf)) port_info['port'] = port @@ -675,19 +674,42 @@ class Dut(Crb): for (pci_bus, pci_id) in self.pci_devices_info: if self.check_ports_available(pci_bus, pci_id) is False: - self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id, + self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id, skipped)) continue addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] + + port = GetNicObj(self, domain_id, bus_id, devfun_id) + intf = port.get_interface_name() + if "No such file" in intf: + self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface)) + continue + + macaddr = port.get_mac_addr() + if "No such file" in intf: + self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface)) + continue + + numa = port.socket + # store the port info to port mapping + self.ports_info.append( + {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa, + 'intf': intf, 'mac': macaddr}) + + if not port.get_interface2_name(): + continue - port = GetNicObj(self, bus_id, devfun_id) + intf = port.get_interface2_name() + macaddr = port.get_intf2_mac_addr() numa = port.socket # store the port info to port mapping self.ports_info.append( - {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa}) + {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa, + 'intf': intf, 'mac': macaddr}) def scan_ports_uncached_freebsd(self): """ @@ -756,9 +778,10 @@ class Dut(Crb): vfs_port = [] for vf_pci in sriov_vfs_pci: addr_array = vf_pci.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] - vf_port = GetNicObj(self, bus_id, devfun_id) + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] + vf_port = GetNicObj(self, domain_id, bus_id, devfun_id) vfs_port.append(vf_port) self.ports_info[port_id]['vfs_port'] = vfs_port diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py index e7a0f88..feaebc8 100644 --- a/framework/project_dpdk.py +++ b/framework/project_dpdk.py @@ -336,7 +336,7 @@ class DPDKdut(Dut): self.bind_interfaces_linux() for port in range(0, len(self.ports_info)): if(port not in dutPorts): - blacklist += '-b 0000:%s ' % self.ports_info[port]['pci'] + blacklist += '-b %s ' % self.ports_info[port]['pci'] return blacklist def get_blacklist_string_freebsd(self, target, nic): diff --git a/framework/settings.py b/framework/settings.py index 9ae4cc2..5572e47 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -79,6 +79,7 @@ NICS = { 'fortpark':'8086:374c', 'fvl10g_vf':'8086:154c', 'atwood': '8086:15d5', + 'ConnectX3':'15b3:1003', 'ConnectX4':'15b3:1013', 'boulderrapid': '8086:15d0', } @@ -116,6 +117,7 @@ DRIVERS = { 'fortpark':'i40e', 'fvl10g_vf':'i40evf', 'atwood': 'fm10k', + 'ConnectX3':'mlx4_core', 'ConnectX4':'mlx5_core', 'boulderrapid': 'fm10k', } diff --git a/framework/tester.py b/framework/tester.py index 4944da3..76ceeb4 100644 --- a/framework/tester.py +++ b/framework/tester.py @@ -203,10 +203,14 @@ class Tester(Crb): try: for (pci_bus, pci_id) in self.pci_devices_info: addr_array = pci_bus.split(':') - port = GetNicObj(self, addr_array[0], addr_array[1]) + port = GetNicObj(self, addr_array[0], addr_array[1], addr_array[2]) itf = port.get_interface_name() self.enable_ipv6(itf) self.send_expect("ifconfig %s up" % itf, "# ") + if port.get_interface2_name(): + itf = port.get_interface2_name() + self.enable_ipv6(itf) + self.send_expect("ifconfig %s up" % itf, "# ") except Exception as e: self.logger.error(" !!! Restore ITF: " + e.message) @@ -217,9 +221,12 @@ class Tester(Crb): try: for (pci_bus, pci_id) in self.pci_devices_info: addr_array = pci_bus.split(':') - port = GetNicObj(self, addr_array[0], addr_array[1]) + port = GetNicObj(self, addr_array[0], addr_array[1], addr_array[2]) itf = port.get_interface_name() self.enable_promisc(itf) + if port.get_interface2_name(): + itf = port.get_interface2_name() + self.enable_promisc(itf) except Exception as e: pass @@ -284,23 +291,24 @@ class Tester(Crb): for (pci_bus, pci_id) in self.pci_devices_info: # ignore unknown card types if pci_id not in NICS.values(): - self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id, + self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, "unknow_nic")) continue addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] - port = GetNicObj(self, bus_id, devfun_id) + port = GetNicObj(self, domain_id, bus_id, devfun_id) intf = port.get_interface_name() if "No such file" in intf: - self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id, + self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, "unknow_interface")) continue - self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id, intf)) + self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, intf)) macaddr = port.get_mac_addr() ipv6 = port.get_ipv6_addr() @@ -313,6 +321,25 @@ class Tester(Crb): 'mac': macaddr, 'ipv6': ipv6}) + # return if port is not connect x3 + if not port.get_interface2_name(): + continue + + intf = port.get_interface2_name() + + self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, intf)) + macaddr = port.get_intf2_mac_addr() + + ipv6 = port.get_ipv6_addr() + + # store the port info to port mapping + self.ports_info.append({'port': port, + 'pci': pci_bus, + 'type': pci_id, + 'intf': intf, + 'mac': macaddr, + 'ipv6': ipv6}) + def send_ping6(self, localPort, ipv6, mac): """ Send ping6 packet from local port with destination ipv6 address. @@ -327,7 +354,7 @@ class Tester(Crb): Return tester local port numa. """ pci = self.ports_info[port]['pci'] - out = self.send_expect("cat /sys/bus/pci/devices/0000:%s/numa_node" % pci, "#") + out = self.send_expect("cat /sys/bus/pci/devices/%s/numa_node" % pci, "#") return int(out) def check_port_list(self, portList, ftype='normal'): diff --git a/framework/virt_dut.py b/framework/virt_dut.py index df6c5fd..cc86827 100644 --- a/framework/virt_dut.py +++ b/framework/virt_dut.py @@ -251,9 +251,10 @@ class VirtDut(DPDKdut): driver = settings.get_nic_driver(pci_id) if driver is not None: addr_array = pci_bus.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] - port = GetNicObj(self, bus_id, devfun_id) + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] + port = GetNicObj(self, domain_id, bus_id, devfun_id) itf = port.get_interface_name() self.send_expect("ifconfig %s up" % itf, "# ") time.sleep(30) diff --git a/nics/net_device.py b/nics/net_device.py index 49b7a91..afd6036 100644 --- a/nics/net_device.py +++ b/nics/net_device.py @@ -52,18 +52,22 @@ class NetDevice(object): Abstract the device which is PF or VF. """ - def __init__(self, crb, bus_id, devfun_id): + def __init__(self, crb, domain_id, bus_id, devfun_id): if not isinstance(crb, Crb): raise Exception(" Please input the instance of Crb!!!") self.crb = crb + self.domain_id = domain_id self.bus_id = bus_id self.devfun_id = devfun_id - self.pci = bus_id + ':' + devfun_id - self.pci_id = get_pci_id(crb, bus_id, devfun_id) + self.pci = domain_id + ':' + bus_id + ':' + devfun_id + self.pci_id = get_pci_id(crb, domain_id, bus_id, devfun_id) self.default_driver = settings.get_nic_driver(self.pci_id) if self.nic_is_pf(): self.default_vf_driver = '' + + self.intf_name = 'N/A' + self.intf2_name = None self.get_interface_name() self.socket = self.get_nic_socket() @@ -111,7 +115,7 @@ class NetDevice(object): """ Get the NIC driver. """ - return self.crb.get_pci_dev_driver(self.bus_id, self.devfun_id) + return self.crb.get_pci_dev_driver(self.domain_id, self.bus_id, self.devfun_id) def get_nic_socket(self): """ @@ -120,11 +124,11 @@ class NetDevice(object): get_nic_socket = getattr( self, 'get_nic_socket_%s' % self.__get_os_type()) - return get_nic_socket(self.bus_id, self.devfun_id) + return get_nic_socket(self.domain_id, self.bus_id, self.devfun_id) - def get_nic_socket_linux(self, bus_id, devfun_id): - command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node' % - (bus_id, devfun_id)) + def get_nic_socket_linux(self, domain_id, bus_id, devfun_id): + command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/numa_node' % + (domain_id, bus_id, devfun_id)) try: out = self.__send_expect(command, '# ') socket = int(out) @@ -144,15 +148,26 @@ class NetDevice(object): get_interface_name = getattr( self, 'get_interface_name_%s' % self.__get_os_type()) - out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver) + out = get_interface_name(self.domain_id, self.bus_id, self.devfun_id, self.current_driver) if "No such file or directory" in out: self.intf_name = 'N/A' else: self.intf_name = out + # not a complete fix for CX3. + if len(out.split()) > 1 and self.default_driver == 'mlx4_core': + self.intf_name = out.split()[0] + self.intf2_name = out.split()[1] + return self.intf_name - def get_interface_name_linux(self, bus_id, devfun_id, driver): + def get_interface2_name(self): + """ + Get interface name of second port of this pci device. + """ + return self.intf2_name + + def get_interface_name_linux(self, domain_id, bus_id, devfun_id, driver): """ Get interface name of specified pci device on linux. """ @@ -167,22 +182,22 @@ class NetDevice(object): get_interface_name_linux = getattr(self, 'get_interface_name_linux_%s' % generic_driver) - return get_interface_name_linux(bus_id, devfun_id) + return get_interface_name_linux(domain_id, bus_id, devfun_id) - def get_interface_name_linux_virtio_pci(self, bus_id, devfun_id): + def get_interface_name_linux_virtio_pci(self, domain_id, bus_id, devfun_id): """ Get virtio device interface name by the default way on linux. """ - command = 'ls --color=never /sys/bus/pci/devices/0000\:%s\:%s/virtio*/net' % ( - bus_id, devfun_id) + command = 'ls --color=never /sys/bus/pci/devices/%s\:%s\:%s/virtio*/net' % ( + domain_id, bus_id, devfun_id) return self.__send_expect(command, '# ') - def get_interface_name_linux_generic(self, bus_id, devfun_id): + def get_interface_name_linux_generic(self, domain_id, bus_id, devfun_id): """ Get the interface name by the default way on linux. """ - command = 'ls --color=never /sys/bus/pci/devices/0000\:%s\:%s/net' % ( - bus_id, devfun_id) + command = 'ls --color=never /sys/bus/pci/devices/%s\:%s\:%s/net' % ( + domain_id, bus_id, devfun_id) return self.__send_expect(command, '# ') def get_interface_name_freebsd(self, bus_id, devfun_id, driver): @@ -235,13 +250,25 @@ class NetDevice(object): Get mac address of specified pci device. """ get_mac_addr = getattr(self, 'get_mac_addr_%s' % self.__get_os_type()) - out = get_mac_addr(self.intf_name, self.bus_id, self.devfun_id, self.current_driver) + out = get_mac_addr(self.intf_name, self.domain_id, self.bus_id, self.devfun_id, self.current_driver) + if "No such file or directory" in out: + return 'N/A' + else: + return out + + @nic_has_driver + def get_intf2_mac_addr(self): + """ + Get mac address of 2nd port of specified pci device. + """ + get_mac_addr = getattr(self, 'get_mac_addr_%s' % self.__get_os_type()) + out = get_mac_addr(self.get_interface2_name(), self.domain_id, self.bus_id, self.devfun_id, self.current_driver) if "No such file or directory" in out: return 'N/A' else: return out - def get_mac_addr_linux(self, intf, bus_id, devfun_id, driver): + def get_mac_addr_linux(self, intf, domain_id, bus_id, devfun_id, driver): """ Get mac address of specified pci device on linux. """ @@ -258,26 +285,26 @@ class NetDevice(object): 'get_mac_addr_linux_%s' % generic_driver) - return get_mac_addr_linux(intf, bus_id, devfun_id, driver) + return get_mac_addr_linux(intf, domain_id, bus_id, devfun_id, driver) - def get_mac_addr_linux_generic(self, intf, bus_id, devfun_id, driver): + def get_mac_addr_linux_generic(self, intf, domain_id, bus_id, devfun_id, driver): """ Get MAC by the default way on linux. """ - command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/net/%s/address' % - (bus_id, devfun_id, intf)) + command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/net/%s/address' % + (domain_id, bus_id, devfun_id, intf)) return self.__send_expect(command, '# ') - def get_mac_addr_linux_virtio_pci(self, intf, bus_id, devfun_id, driver): + def get_mac_addr_linux_virtio_pci(self, intf, domain_id, bus_id, devfun_id, driver): """ Get MAC by the default way on linux. """ - virtio_cmd = ('ls /sys/bus/pci/devices/0000\:%s\:%s/ | grep --color=never virtio' % - (bus_id, devfun_id)) + virtio_cmd = ('ls /sys/bus/pci/devices/%s\:%s\:%s/ | grep --color=never virtio' % + (domain_id, bus_id, devfun_id)) virtio = self.__send_expect(virtio_cmd, '# ') - command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/%s/net/%s/address' % - (bus_id, devfun_id, virtio, intf)) + command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/%s/net/%s/address' % + (domain_id, bus_id, devfun_id, virtio, intf)) return self.__send_expect(command, '# ') def get_mac_addr_freebsd(self, intf, bus_id, devfun_id, driver): @@ -329,7 +356,7 @@ class NetDevice(object): self, 'get_ipv4_linux_%s' % generic_driver) - return get_ipv4_addr_linux(intf, bus_id, devfun_id, driver) + return get_ipv4_addr_linux(intf, domain_id, bus_id, devfun_id, driver) def get_ipv4_addr_linux_generic(self, intf): """ @@ -496,13 +523,13 @@ class NetDevice(object): """ Get numa number of specified pci device. """ - self.crb.get_nic_numa(self.bus_id, self.devfun_id) + self.crb.get_device_numa(self.domain_id, self.bus_id, self.devfun_id) def get_card_type(self): """ Get card type of specified pci device. """ - return self.crb.get_pci_dev_id(self.bus_id, self.devfun_id) + return self.crb.get_pci_dev_id(self.domain_id, self.bus_id, self.devfun_id) @nic_has_driver def get_sriov_vfs_pci(self): @@ -511,9 +538,9 @@ class NetDevice(object): """ get_sriov_vfs_pci = getattr( self, 'get_sriov_vfs_pci_%s' % self.__get_os_type()) - return get_sriov_vfs_pci(self.bus_id, self.devfun_id, self.current_driver) + return get_sriov_vfs_pci(self.domain_id, self.bus_id, self.devfun_id, self.current_driver) - def get_sriov_vfs_pci_linux(self, bus_id, devfun_id, driver): + def get_sriov_vfs_pci_linux(self, domain_id, bus_id, devfun_id, driver): """ Get all SRIOV VF pci bus of specified pci device on linux. """ @@ -529,15 +556,15 @@ class NetDevice(object): 'get_sriov_vfs_pci_linux_%s' % generic_driver) - return get_sriov_vfs_pci_linux(bus_id, devfun_id) + return get_sriov_vfs_pci_linux(domain_id, bus_id, devfun_id) - def get_sriov_vfs_pci_linux_generic(self, bus_id, devfun_id): + def get_sriov_vfs_pci_linux_generic(self, domain_id, bus_id, devfun_id): """ Get all the VF PCIs of specified PF by the default way on linux. """ sriov_numvfs = self.__send_expect( - "cat /sys/bus/pci/devices/0000\:%s\:%s/sriov_numvfs" % - (bus_id, devfun_id), "# ") + "cat /sys/bus/pci/devices/%s\:%s\:%s/sriov_numvfs" % + (domain_id, bus_id, devfun_id), "# ") sriov_vfs_pci = [] if "No such file" in sriov_numvfs: @@ -548,18 +575,18 @@ class NetDevice(object): else: try: virtfns = self.__send_expect( - "ls -d /sys/bus/pci/devices/0000\:%s\:%s/virtfn*" % - (bus_id, devfun_id), "# ") + "ls -d /sys/bus/pci/devices/%s\:%s\:%s/virtfn*" % + (domain_id, bus_id, devfun_id), "# ") for virtfn in virtfns.split(): vf_uevent = self.__send_expect( "cat %s" % os.path.join(virtfn, "uevent"), "# ") vf_pci = re.search( - r"PCI_SLOT_NAME=0000:([0-9a-f]+:[0-9a-f]+\.[0-9a-f]+)", + r"PCI_SLOT_NAME=%s:([0-9a-f]+:[0-9a-f]+\.[0-9a-f]+)" %domain_id, vf_uevent).group(1) sriov_vfs_pci.append(vf_pci) except Exception as e: - print "Scan linux port [0000:%s.%s] sriov vf failed: %s" % (bus_id, devfun_id, e) + print "Scan linux port [%s:%s.%s] sriov vf failed: %s" % (domain_id, bus_id, devfun_id, e) return sriov_vfs_pci @@ -574,6 +601,7 @@ class NetDevice(object): self, 'generate_sriov_vfs_%s' % self.__get_os_type()) generate_sriov_vfs( + self.domain_id, self.bus_id, self.devfun_id, vf_num, @@ -583,16 +611,17 @@ class NetDevice(object): vf_pci = self.sriov_vfs_pci[0] addr_array = vf_pci.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] self.default_vf_driver = self.crb.get_pci_dev_driver( - bus_id, devfun_id) + domain_id, bus_id, devfun_id) else: self.sriov_vfs_pci = [] time.sleep(1) - def generate_sriov_vfs_linux(self, bus_id, devfun_id, vf_num, driver): + def generate_sriov_vfs_linux(self, domain_id, bus_id, devfun_id, vf_num, driver): """ Generate some numbers of SRIOV VF. """ @@ -608,9 +637,9 @@ class NetDevice(object): 'generate_sriov_vfs_linux_%s' % generic_driver) - return generate_sriov_vfs_linux(bus_id, devfun_id, vf_num) + return generate_sriov_vfs_linux(domain_id, bus_id, devfun_id, vf_num) - def generate_sriov_vfs_linux_generic(self, bus_id, devfun_id, vf_num): + def generate_sriov_vfs_linux_generic(self, domain_id, bus_id, devfun_id, vf_num): """ Generate SRIOV VFs by the default way on linux. """ @@ -620,12 +649,12 @@ class NetDevice(object): return None vf_reg_file = "sriov_numvfs" - vf_reg_path = os.path.join("/sys/bus/pci/devices/0000:%s:%s" % - (bus_id, devfun_id), vf_reg_file) + vf_reg_path = os.path.join("/sys/bus/pci/devices/%s:%s:%s" % + (domain_id, bus_id, devfun_id), vf_reg_file) self.__send_expect("echo %d > %s" % (int(vf_num), vf_reg_path), "# ") - def generate_sriov_vfs_linux_igb_uio(self, bus_id, devfun_id, vf_num): + def generate_sriov_vfs_linux_igb_uio(self, domain_id, bus_id, devfun_id, vf_num): """ Generate SRIOV VFs by the special way of igb_uio driver on linux. """ @@ -636,11 +665,11 @@ class NetDevice(object): vf_reg_file = "max_vfs" if self.default_driver == 'i40e': - regx_reg_path = "find /sys -name %s | grep %s:%s" % (vf_reg_file, bus_id, devfun_id) + regx_reg_path = "find /sys -name %s | grep %s:%s:%s" % (vf_reg_file, domain_id, bus_id, devfun_id) vf_reg_path = self.__send_expect(regx_reg_path, "# ") else: - vf_reg_path = os.path.join("/sys/bus/pci/devices/0000:%s:%s" % - (bus_id, devfun_id), vf_reg_file) + vf_reg_path = os.path.join("/sys/bus/pci/devices/%s:%s:%s" % + (domain_id, bus_id, devfun_id), vf_reg_file) self.__send_expect("echo %d > %s" % (int(vf_num), vf_reg_path), "# ") @@ -667,16 +696,18 @@ class NetDevice(object): return for vf_pci in self.sriov_vfs_pci: addr_array = vf_pci.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] - bind_vf_driver(bus_id, devfun_id, driver) + bind_vf_driver(domain_id, bus_id, devfun_id, driver) else: addr_array = pci.split(':') - bus_id = addr_array[0] - devfun_id = addr_array[1] + domain_id = addr_array[0] + bus_id = addr_array[1] + devfun_id = addr_array[2] - bind_vf_driver(bus_id, devfun_id, driver) + bind_vf_driver(domain_id, bus_id, devfun_id, driver) def bind_driver(self, driver=''): """ @@ -688,11 +719,11 @@ class NetDevice(object): print "Must specify a driver because default driver is NULL!" return driver = self.default_driver - ret = bind_driver(self.bus_id, self.devfun_id, driver) + ret = bind_driver(self.domain_id, self.bus_id, self.devfun_id, driver) time.sleep(1) return ret - def bind_driver_linux(self, bus_id, devfun_id, driver): + def bind_driver_linux(self, domain_id, bus_id, devfun_id, driver): """ Bind NIC port to specified driver on linux. """ @@ -702,34 +733,37 @@ class NetDevice(object): self, 'bind_driver_linux_%s' % driver_alias) - return bind_driver_linux(bus_id, devfun_id) + return bind_driver_linux(domain_id, bus_id, devfun_id) except Exception as e: driver_alias = 'generic' bind_driver_linux = getattr( self, 'bind_driver_linux_%s' % driver_alias) - return bind_driver_linux(bus_id, devfun_id, driver) + return bind_driver_linux(domain_id, bus_id, devfun_id, driver) - def bind_driver_linux_generic(self, bus_id, devfun_id, driver): + def bind_driver_linux_generic(self, domain_id, bus_id, devfun_id, driver): """ Bind NIC port to specified driver by the default way on linux. """ new_id = self.pci_id.replace(':', ' ') - nic_pci_num = ':'.join(['0000', bus_id, devfun_id]) + nic_pci_num = ':'.join([domain_id, bus_id, devfun_id]) self.__send_expect( "echo %s > /sys/bus/pci/drivers/%s/new_id" % (new_id, driver), "# ") self.__send_expect( - "echo %s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind" % - (nic_pci_num, bus_id, devfun_id), "# ") + "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind" % + (nic_pci_num, domain_id, bus_id, devfun_id), "# ") self.__send_expect( "echo %s > /sys/bus/pci/drivers/%s/bind" % (nic_pci_num, driver), "# ") if driver == self.default_driver: itf = self.get_interface_name() self.__send_expect("ifconfig %s up" % itf, "# ") + if self.get_interface2_name(): + itf = self.get_interface2_name() + self.__send_expect("ifconfig %s up" % itf, "# ") - def bind_driver_linux_pci_stub(self, bus_id, devfun_id): + def bind_driver_linux_pci_stub(self, domain_id, bus_id, devfun_id): """ Bind NIC port to the pci-stub driver on linux. """ @@ -737,8 +771,8 @@ class NetDevice(object): self.__send_expect( "echo %s > /sys/bus/pci/drivers/pci-stub/new_id" % new_id, "# ") self.__send_expect( - "echo %s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind" % - (nic_pci_num, bus_id, devfun_id), "# ") + "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind" % + (nic_pci_num, domain_id, bus_id, devfun_id), "# ") self.__send_expect( "echo %s > /sys/bus/pci/drivers/pci-stub/bind" % nic_pci_num, "# ") @@ -753,11 +787,11 @@ class NetDevice(object): self.__get_os_type()) if not driver: driver = 'generic' - ret = unbind_driver(self.bus_id, self.devfun_id, driver) + ret = unbind_driver(self.domain_id, self.bus_id, self.devfun_id, driver) time.sleep(1) return ret - def unbind_driver_linux(self, bus_id, devfun_id, driver): + def unbind_driver_linux(self, domain_id, bus_id, devfun_id, driver): """ Unbind driver on linux. """ @@ -765,15 +799,15 @@ class NetDevice(object): unbind_driver_linux = getattr( self, 'unbind_driver_linux_%s' % driver_alias) - return unbind_driver_linux(bus_id, devfun_id) + return unbind_driver_linux(domain_id, bus_id, devfun_id) - def unbind_driver_linux_generic(self, bus_id, devfun_id): + def unbind_driver_linux_generic(self, domain_id, bus_id, devfun_id): """ Unbind driver by the default way on linux. """ - nic_pci_num = ':'.join(['0000', bus_id, devfun_id]) - cmd = "echo %s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind" - self.__send_expect(cmd % (nic_pci_num, bus_id, devfun_id), "# ") + nic_pci_num = ':'.join([domain_id, bus_id, devfun_id]) + cmd = "echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind" + self.__send_expect(cmd % (nic_pci_num, domain_id, bus_id, devfun_id), "# ") def _cal_mtu(self, framesize): return framesize - HEADER_SIZE['eth'] @@ -791,16 +825,16 @@ class NetDevice(object): self.__send_expect(cmd % (self.intf_name, mtu), "# ") -def get_pci_id(crb, bus_id, devfun_id): +def get_pci_id(crb, domain_id, bus_id, devfun_id): """ Return pci device type """ - command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/vendor' % - (bus_id, devfun_id)) + command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/vendor' % + (domain_id, bus_id, devfun_id)) out = crb.send_expect(command, "# ") vender = out[2:] - command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/device' % - (bus_id, devfun_id)) + command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/device' % + (domain_id, bus_id, devfun_id)) out = crb.send_expect(command, '# ') device = out[2:] return "%s:%s" % (vender, device) @@ -818,14 +852,14 @@ def add_to_list(host, obj): NICS_LIST.append(nic) -def get_from_list(host, bus_id, devfun_id): +def get_from_list(host, domain_id, bus_id, devfun_id): """ Get network device object from global structure - Parameter will by host ip, pci bus id, pci function id + Parameter will by host ip, pci domain id, pci bus id, pci function id """ for nic in NICS_LIST: if host == nic['host']: - pci = ':'.join((bus_id, devfun_id)) + pci = ':'.join((domain_id, bus_id, devfun_id)) if pci == nic['pci']: return nic['port'] return None @@ -839,18 +873,18 @@ def remove_from_list(host): if host == nic['host']: NICS_LIST.remove(nic) -def GetNicObj(crb, bus_id, devfun_id): +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'], bus_id, devfun_id) + obj = get_from_list(crb.crb['My IP'], domain_id, bus_id, devfun_id) if obj: return obj - pci_id = get_pci_id(crb, bus_id, devfun_id) + pci_id = get_pci_id(crb, domain_id, bus_id, devfun_id) nic = settings.get_nic_name(pci_id) if nic == 'redrockcanyou': @@ -866,7 +900,7 @@ def GetNicObj(crb, bus_id, devfun_id): from br import BoulderRapid obj = BoulderRapid(crb, bus_id, devfun_id) else: - obj = NetDevice(crb, bus_id, devfun_id) + obj = NetDevice(crb, domain_id, bus_id, devfun_id) add_to_list(crb.crb['My IP'], obj) return obj diff --git a/tests/TestSuite_blacklist.py b/tests/TestSuite_blacklist.py index ba39b36..06dbf87 100644 --- a/tests/TestSuite_blacklist.py +++ b/tests/TestSuite_blacklist.py @@ -50,9 +50,9 @@ class TestBlackList(TestCase): [arch, machine, self.env, toolchain] = self.target.split('-') if self.env == 'bsdapp': - self.regexp_blacklisted_port = "EAL: PCI device 0000:%02x:%s on NUMA socket [-0-9]+[^\n]*\nEAL: probe driver[^\n]*\nEAL: Device is blacklisted, not initializing" + self.regexp_blacklisted_port = "EAL: PCI device %02x:%s on NUMA socket [-0-9]+[^\n]*\nEAL: probe driver[^\n]*\nEAL: Device is blacklisted, not initializing" else: - self.regexp_blacklisted_port = "EAL: PCI device 0000:%s on NUMA socket [-0-9]+[^\n]*\nEAL: probe driver[^\n]*\nEAL: Device is blacklisted, not initializing" + self.regexp_blacklisted_port = "EAL: PCI device %s on NUMA socket [-0-9]+[^\n]*\nEAL: probe driver[^\n]*\nEAL: Device is blacklisted, not initializing" self.pmdout = PmdOutput(self.dut) def set_up(self): @@ -101,7 +101,7 @@ class TestBlackList(TestCase): Run testpmd with one port blacklisted. """ self.dut.kill_all() - out = self.pmdout.start_testpmd("Default", eal_param="-b 0000:%s" % self.dut.ports_info[0]['pci']) + out = self.pmdout.start_testpmd("Default", eal_param="-b %s" % self.dut.ports_info[0]['pci']) self.check_blacklisted_ports(out, self.ports[1:]) def test_bl_allbutoneportblacklisted(self): @@ -112,7 +112,7 @@ class TestBlackList(TestCase): ports_to_blacklist = self.ports[:-1] cmdline = "" for port in ports_to_blacklist: - cmdline += " -b 0000:%s" % self.dut.ports_info[port]['pci'] + cmdline += " -b %s" % self.dut.ports_info[port]['pci'] out = self.pmdout.start_testpmd("Default", eal_param=cmdline) blacklisted_ports = self.check_blacklisted_ports(out, ports_to_blacklist, True) diff --git a/tests/TestSuite_coremask.py b/tests/TestSuite_coremask.py index d1cc6e3..4f6f4bd 100644 --- a/tests/TestSuite_coremask.py +++ b/tests/TestSuite_coremask.py @@ -60,11 +60,11 @@ class TestCoremask(TestCase): out = self.dut.send_expect(command, "RTE>>", 10) - self.verify("EAL: Detected lcore %d as core" % core in out, - "Core %d not detected" % core) + self.verify("EAL: Detected lcore %s as core" % core in out, + "Core %s not detected" % core) - self.verify("EAL: Master lcore %d is ready" % core in out, - "Core %d not ready" % core) + self.verify("EAL: Master lcore %s is ready" % core in out, + "Core %s not ready" % core) self.dut.send_expect("quit", "# ", 10) @@ -86,11 +86,11 @@ class TestCoremask(TestCase): "Core 0 not detected") for core in self.all_cores[1:]: - self.verify("EAL: lcore %d is ready" % core in out, - "Core %d not ready" % core) + self.verify("EAL: lcore %s is ready" % core in out, + "Core %s not ready" % core) - self.verify("EAL: Detected lcore %d as core" % core in out, - "Core %d not detected" % core) + self.verify("EAL: Detected lcore %s as core" % core in out, + "Core %s not detected" % core) self.dut.send_expect("quit", "# ", 10) @@ -135,8 +135,8 @@ class TestCoremask(TestCase): for core in self.all_cores[1:]: - self.verify("EAL: Detected lcore %d as core" % core in out, - "Core %d not detected" % core) + self.verify("EAL: Detected lcore %s as core" % core in out, + "Core %s not detected" % core) self.dut.send_expect("quit", "# ", 10) diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py index 197bdb4..97d3092 100644 --- a/tests/TestSuite_multiprocess.py +++ b/tests/TestSuite_multiprocess.py @@ -83,9 +83,12 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): Basic operation. """ # Send message from secondary to primary - self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 --proc-type=primary" % self.target, "Finished Process Init", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=primary" % (self.target, coremask), "Finished Process Init", 100) time.sleep(20) - self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C --proc-type=secondary" % self.target, "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=secondary" % (self.target, coremask), "Finished Process Init", 100) self.session_secondary.send_expect("send hello_primary", ">") out = self.dut.get_session_output() @@ -93,9 +96,12 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): self.dut.send_expect("quit","# ") self.verify("Received 'hello_primary'" in out, "Message not received on primary process") # Send message from primary to secondary - self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 --proc-type=primary " % self.target, "Finished Process Init", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=primary " % (self.target, coremask), "Finished Process Init", 100) time.sleep(20) - self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C --proc-type=secondary" % self.target, "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=secondary" % (self.target, coremask), "Finished Process Init", 100) self.session_secondary.send_expect("send hello_secondary", ">") out = self.dut.get_session_output() self.session_secondary.send_expect("quit", "# ") @@ -109,9 +115,12 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): Load test of Simple MP application. """ - self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 --proc-type=primary" % self.target, "Finished Process Init", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=primary" % (self.target, coremask), "Finished Process Init", 100) time.sleep(20) - self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C --proc-type=secondary" % self.target, "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=secondary" % (self.target, coremask), "Finished Process Init", 100) stringsSent = 0 for line in open('/usr/share/dict/words', 'r').readlines(): line = line.split('\n')[0] @@ -130,10 +139,13 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): """ # Send message from secondary to primary (auto process type) - out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 --proc-type=auto " % self.target, "Finished Process Init", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=auto " % (self.target, coremask), "Finished Process Init", 100) self.verify("EAL: Auto-detected process type: PRIMARY" in out, "The type of process (PRIMARY) was not detected properly") time.sleep(20) - out = self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C --proc-type=auto" % self.target, "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + out = self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=auto" % (self.target, coremask), "Finished Process Init", 100) self.verify("EAL: Auto-detected process type: SECONDARY" in out, "The type of process (SECONDARY) was not detected properly") @@ -144,10 +156,13 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): self.verify("Received 'hello_primary'" in out, "Message not received on primary process") # Send message from primary to secondary (auto process type) - out = self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 --proc-type=auto" % self.target, "Finished Process Init", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + out = self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=auto" % (self.target, coremask), "Finished Process Init", 100) self.verify("EAL: Auto-detected process type: PRIMARY" in out, "The type of process (PRIMARY) was not detected properly") time.sleep(20) - out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C --proc-type=auto" % self.target, "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s --proc-type=auto" % (self.target, coremask), "Finished Process Init", 100) self.verify("EAL: Auto-detected process type: SECONDARY" in out, "The type of process (SECONDARY) was not detected properly") self.session_secondary.send_expect("send hello_secondary", ">",100) out = self.dut.get_session_output() @@ -162,8 +177,11 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator): Multiple processes without "--proc-type" flag. """ - self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c 3 -m 64" % self.target, "Finished Process Init", 100) - out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c C" % self.target, "# ", 100) + cores = self.dut.get_core_list('1S/2C/1T') + coremask = dts.create_mask(cores) + self.session_secondary.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s -m 64" % (self.target, coremask), "Finished Process Init", 100) + coremask = hex(int(coremask, 16) * 0x10000).rstrip("L") + out = self.dut.send_expect("./examples/multi_process/simple_mp/simple_mp/%s/simple_mp -n 1 -c %s" % (self.target, coremask), "# ", 100) self.verify("Is another primary process running" in out, "No other primary process detected") |