예제 #1
0
    def restore_interfaces(self):
        """
        Restore Linux interfaces.
        """
        if self.skip_setup:
            return

        self.send_expect("modprobe igb", "# ", 20)
        self.send_expect("modprobe ixgbe", "# ", 20)
        self.send_expect("modprobe e1000e", "# ", 20)
        self.send_expect("modprobe e1000", "# ", 20)

        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],
                                 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)

        sleep(2)
예제 #2
0
    def restore_interfaces_linux(self):
        """
        Restore Linux interfaces.
        """
        for port in self.ports_info:
            pci_bus = port['pci']
            pci_id = port['type']
            # get device driver
            driver = settings.get_nic_driver(pci_id)
            if driver is not None:
                # unbind device driver
                addr_array = pci_bus.split(':')
                domain_id = addr_array[0]
                bus_id = addr_array[1]
                devfun_id = addr_array[2]

                port = GetNicObj(self, domain_id, 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 %s > /sys/bus/pci/drivers/%s/bind' %
                    (pci_bus, driver), '# ')
                itf = port.get_interface_name()
                self.send_expect("ifconfig %s up" % itf, "# ")
            else:
                self.logger.info("NOT FOUND DRIVER FOR PORT (%s|%s)!!!" %
                                 (pci_bus, pci_id))
예제 #3
0
    def scan_ports_uncached(self):
        """
        Return tester port pci/mac/interface information.
        """
        self.ports_info = []

        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: [%s %s] %s" % (pci_bus, pci_id,
                                                             "unknow_nic"))
                continue

            addr_array = pci_bus.split(':')
            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("Tester: [%s %s] %s" % (pci_bus, pci_id,
                                                             "unknow_interface"))
                continue

            self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, intf))
            macaddr = port.get_mac_addr()

            ipv6 = port.get_ipv6_addr()
            ipv4 = port.get_ipv4_addr()

            # store the port info to port mapping
            self.ports_info.append({'port': port,
                                    'pci': pci_bus,
                                    'type': pci_id,
                                    'intf': intf,
                                    'mac': macaddr,
				    'ipv4': ipv4,
                                    '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})
예제 #4
0
 def set_promisc(self):
     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], 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
예제 #5
0
    def scan_ports_uncached_freebsd(self):
        """
        Scan Freebsd ports and collect port's pci id, mac adress, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')

        for (pci_bus, pci_id) in self.pci_devices_info:

            if not settings.accepted_nic(pci_id):
                self.logger.info("DUT: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue
            addr_array = pci_bus.split(':')
            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()

            macaddr = port.get_mac_addr()
            ipv6 = port.get_ipv6_addr()

            if ipv6 is None:
                ipv6 = "Not available"

            self.logger.warning("NUMA not available on FreeBSD")

            self.logger.info("DUT: [%s %s] %s %s" %
                             (pci_bus, pci_id, intf, ipv6))

            # convert bsd format to linux format
            pci_split = pci_bus.split(':')
            pci_bus_id = hex(int(pci_split[0]))[2:]
            if len(pci_split[1]) == 1:
                pci_dev_str = "0" + pci_split[1]
            else:
                pci_dev_str = pci_split[1]

            pci_str = "%s:%s.%s" % (pci_bus_id, pci_dev_str, pci_split[2])

            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_str,
                'type': pci_id,
                'intf': intf,
                'mac': macaddr,
                'ipv6': ipv6,
                'numa': -1
            })
예제 #6
0
 def stop_ports(self):
     """
     After all execution done, some special nic like fm10k should be stop
     """
     for (pci_bus, pci_id) in self.pci_devices_info:
         driver = settings.get_nic_driver(pci_id)
         if driver is not None:
             # unbind device driver
             addr_array = pci_bus.split(':')
             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()
예제 #7
0
    def generate_sriov_vfs_by_port(self, port_id, vf_num, driver='default'):
        """
        Generate SRIOV VFs with default driver it is bound now or specifid driver.
        """
        port = self.ports_info[port_id]['port']
        port_driver = port.get_nic_driver()

        if driver == 'default':
            if not port_driver:
                self.logger.info(
                    "No driver on specified port, can not generate SRIOV VF.")
                return None
        else:
            if port_driver != driver:
                port.bind_driver(driver)
        port.generate_sriov_vfs(vf_num)

        # append the VF PCIs into the ports_info
        sriov_vfs_pci = port.get_sriov_vfs_pci()
        self.ports_info[port_id]['sriov_vfs_pci'] = sriov_vfs_pci

        # instantiate the VF
        vfs_port = []
        for vf_pci in sriov_vfs_pci:
            addr_array = vf_pci.split(':')
            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

        pci = self.ports_info[port_id]['pci']
        self.virt_pool.add_vf_on_pf(pf_pci=pci, vflist=sriov_vfs_pci)
예제 #8
0
    def get_ports(self):
        """
        Get tester's NICs information.
        """
        ethname = []
        drivername = []
        driver = []
        nic = []
        for key in DRIVERS:
            nic = key
            driver = DRIVERS[key]

        for (pci_bus, pci_id) in self.pci_devices_info:
            addr_array = pci_bus.split(':')
            port = GetNicObj(self, addr_array[0], addr_array[1], addr_array[2])
            eth = port.get_interface_name()
            self.enable_ipv6(eth)
            if len(eth) >= 12:
                status1 = eth.split()
                self.enable_ipv6(status1[0])
                self.enable_ipv6(status1[1])
                out1 = self.send_expect("ethtool -i %s" % status1[0], "# ")
                out2 = self.send_expect("ethtool -i %s" % status1[1], "# ")
                status2 = re.findall(r"driver:\s+(.*)", out1)
                status3 = re.findall(r"driver:\s+(.*)", out2)
                if status2:
                    drivername.append(status2[0])
                    ethname.append(status1[0])
                if status3:
                    drivername.append(status3[0])
                    ethname.append(status1[1])
                if not status2:
                    self.logger.error("ERROR: unexpected output")
                if not status3:
                    self.logger.error("ERROR: unexpected output")
            else:
                out = self.send_expect("ethtool -i %s" % eth, "# ")
                status = re.findall(r"driver:\s+(.*)", out)
                if status:
                    drivername.append(status[0])
                    ethname.append(eth)
                if not status:
                    self.logger.error("ERROR: unexpected output")
        return ethname, drivername
예제 #9
0
    def scan_ports_cached(self):
        if self.ports_info is None:
            return

        for port_info in self.ports_info:
            if port_info['type'] == 'ixia':
                continue

            addr_array = port_info['pci'].split(':')
            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()

            self.logger.info("Tester cached: [000:%s %s] %s" %
                             (port_info['pci'], port_info['type'], intf))
            port_info['port'] = port
예제 #10
0
    def scan_ports_uncached_linux(self):
        """
        Scan Linux ports and collect port's pci id, mac adress, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')
        unknow_interface = RED('Skipped: unknow_interface')

        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: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue

            addr_array = pci_bus.split(':')
            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

            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,
                'intf': intf,
                'mac': macaddr
            })
예제 #11
0
 def restore_interfaces_domu(self):
     """
     Restore Linux interfaces.
     """
     for port in self.ports_info:
         pci_bus = port['pci']
         pci_id = port['type']
         driver = settings.get_nic_driver(pci_id)
         if driver is not None:
             addr_array = pci_bus.split(':')
             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)
             print self.send_expect("ip link ls %s" % itf, "# ")
         else:
             self.logger.info(
                 "NOT FOUND DRIVER FOR PORT (%s|%s)!!!" % (pci_bus, pci_id))
예제 #12
0
    def scan_ports_cached_linux(self):
        """
        Scan Linux ports and instantiate tester port
        """
        if self.ports_info is None:
            return

        for port_info in self.ports_info:
            addr_array = port_info['pci'].split(':')
            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_info['port'] = port

            self.logger.info("DUT cached: [%s %s] %s" % (port_info['pci'],
                                port_info['type'], port_info['intf']))
예제 #13
0
    def scan_ports_uncached_linux(self):
        """
        Scan Linux ports and collect port's pci id, mac address, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')
        unknow_interface = RED('Skipped: unknow_interface')

        domain_id = "0000"
        bus_id = "01"
        devfun_id = "00.0"
        port = GetNicObj(self, domain_id, bus_id, devfun_id)
        port.socket = 0  # set to 0 as numa node in ls2088 is returning -1
        self.ports_info = [{
            'intf': 'eth0',
            'source': 'dpaa2',
            'mac': 'b2:c8:30:9e:a6:0b',
            'pci': 'nxp_NA',
            'numa': 1,
            'peer': '0001:00:00.0',
            'type': 'nxp:NA',
            'port': port
        }, {
            'intf': 'eth1',
            'source': 'dpaa2',
            'mac': 'b2:c8:30:9e:a6:0c',
            'pci': 'nxp_NA',
            'numa': 1,
            'peer': '0001:01:00.0',
            'type': 'nxp:NA',
            'port': port
        }]

        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: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue

            addr_array = pci_bus.split(':')
            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

            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,
                'intf': intf,
                'mac': macaddr
            })