test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 0/4] Support additional port configuration file
@ 2015-01-23  8:26 Marvin Liu
  2015-01-23  8:26 ` [dts] [PATCH 1/4] framework: add new module for load " Marvin Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Marvin Liu @ 2015-01-23  8:26 UTC (permalink / raw)
  To: dts

From: Yong Liu <yong.liu@intel.com>

This patch set will implement new module to support additional port config 
file. In port config file, users can specified NICs' macaddress, interface, 
numa id or peer tester pci device. Thus will support users deploy their own 
NIC validation even their NICs not supported in kernel.

In this patch set, DUT and Tester port initialize sequence will also be 
reorganized. Now DUT port initialization sequence will be scan,restore,rescan,
check with port config. Tester port initialization will only make sure all 
interface up.

This patch now only support Linux OS, will implement in FreeBSD later.

Yong Liu (4):
  framework: add new module for load port configuration file
  framework: execuction file support port config nic_type
  framework: reorganize DUT and Tester port initialize sequence
  suites: remove nic type check from testsuites

 conf/ports.cfg                      |   4 +
 execution.cfg                       |   2 +-
 framework/config.py                 |  93 ++++++++++++++++++
 framework/crb.py                    |  53 +++--------
 framework/dts.py                    |  62 +++++++-----
 framework/dut.py                    | 181 +++++++++++++++++++++++++++---------
 framework/project_dpdk.py           |  22 ++---
 framework/tester.py                 |  30 ++++++
 tests/TestSuite_blacklist.py        |   2 +-
 tests/TestSuite_checksum_offload.py |   2 +-
 tests/TestSuite_fdir.py             |  16 ++--
 tests/TestSuite_ieee1588.py         |   6 +-
 tests/TestSuite_ip_pipeline.py      |   2 +-
 tests/TestSuite_ipfrag.py           |   2 +-
 tests/TestSuite_jumboframes.py      |   2 +-
 tests/TestSuite_l2fwd.py            |   2 +-
 tests/TestSuite_l3fwd.py            |   6 +-
 tests/TestSuite_link_flowctrl.py    |   2 +-
 tests/TestSuite_multiprocess.py     |   2 +-
 tests/TestSuite_pmd.py              |   4 +-
 tests/TestSuite_pmd_bonded.py       |   2 +-
 tests/TestSuite_vlan.py             |   3 +-
 tests/TestSuite_whitelist.py        |   2 +-
 23 files changed, 352 insertions(+), 150 deletions(-)
 create mode 100644 conf/ports.cfg
 create mode 100755 framework/config.py

-- 
1.9.3

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

* [dts] [PATCH 1/4] framework: add new module for load port configuration file
  2015-01-23  8:26 [dts] [PATCH 0/4] Support additional port configuration file Marvin Liu
@ 2015-01-23  8:26 ` Marvin Liu
  2015-02-04  3:26   ` Qiu, Michael
  2015-01-23  8:26 ` [dts] [PATCH 2/4] framework: execuction file support port config nic_type Marvin Liu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Marvin Liu @ 2015-01-23  8:26 UTC (permalink / raw)
  To: dts

From: Yong Liu <yong.liu@intel.com>

Config module will load port configuration and parse port parameter.
Port configuration will be used in the process of setting up DUT.
User can assign port mac, numa or tester peer pci address of DUT port.

Signed-off-by: Marvinliu <yong.liu@intel.com>
---
 conf/ports.cfg      |  4 +++
 framework/config.py | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)
 create mode 100644 conf/ports.cfg
 create mode 100755 framework/config.py

diff --git a/conf/ports.cfg b/conf/ports.cfg
new file mode 100644
index 0000000..85c1998
--- /dev/null
+++ b/conf/ports.cfg
@@ -0,0 +1,4 @@
+[10.239.128.117]
+ports=
+    pci=86:00.0,intf=p4p1;
+    pci=86:00.1,mac=90:e2:ba:39:b7:69,peer=05:00.1,numa=0
diff --git a/framework/config.py b/framework/config.py
new file mode 100755
index 0000000..140c84b
--- /dev/null
+++ b/framework/config.py
@@ -0,0 +1,93 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 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.
+
+"""
+Generic port and crbs configuration file load function
+"""
+
+import ConfigParser  # config parse module
+import argparse      # prase arguments module
+
+portconf = "../conf/ports.cfg"
+crbconf = "../conf/crbs.cfg"
+
+
+class UserConf():
+
+    def __init__(self, port_conf=portconf, crb_conf=crbconf):
+        self.port_config = port_conf
+        self.crb_config = crb_conf
+        self.ports_cfg = {}
+        try:
+            self.port_conf = ConfigParser.SafeConfigParser()
+            self.port_conf.read(self.port_config)
+        except Exception as e:
+            print "FAILED LOADING PORT CONFIG!!!"
+
+    def load_ports_config(self, crbIP):
+        ports = []
+        for crb in self.port_conf.sections():
+            if crb != crbIP:
+                continue
+            ports = [port.strip()
+                     for port in self.port_conf.get(crb, 'ports').split(';')]
+
+        for port in ports:
+            port_cfg = self.parse_port_param(port)
+            if 'pci' not in port_cfg:
+                print "INVALID CONFIG FOR NO PCI ADDRESS!!!"
+            keys = port_cfg.keys()
+            keys.remove('pci')
+            self.ports_cfg[port_cfg['pci']] = {key: port_cfg[key] for key in keys}
+
+    def check_port_available(self, pci_addr):
+        if pci_addr in self.ports_cfg.keys():
+            return True
+        else:
+            return False
+
+    def parse_port_param(self, port):
+        portDict = dict()
+
+        for param in port.split(','):
+            (key, _, value) = param.partition('=')
+            portDict[key] = value
+        return portDict
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description="Load DTS configuration files")
+    parser.add_argument("-p", "--portconf", default=portconf)
+    parser.add_argument("-c", "--crbconf", default=crbconf)
+    args = parser.parse_args()
+    conf = UserConf()
+    conf.load_ports_config('10.239.128.120')
+    conf.check_port_available('0000:86:00.0')
-- 
1.9.3

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

* [dts] [PATCH 2/4] framework: execuction file support port config nic_type
  2015-01-23  8:26 [dts] [PATCH 0/4] Support additional port configuration file Marvin Liu
  2015-01-23  8:26 ` [dts] [PATCH 1/4] framework: add new module for load " Marvin Liu
@ 2015-01-23  8:26 ` Marvin Liu
  2015-02-04  3:57   ` Qiu, Michael
  2015-01-23  8:26 ` [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Marvin Liu
  2015-01-23  8:26 ` [dts] [PATCH 4/4] suites: remove nic type check from testsuites Marvin Liu
  3 siblings, 1 reply; 11+ messages in thread
From: Marvin Liu @ 2015-01-23  8:26 UTC (permalink / raw)
  To: dts

From: Yong Liu <yong.liu@intel.com>

DTS support new function that get linux driver with pci device id.
DTS sample execution configuration support configured DUT port.
One execution section support only one DUT.

Signed-off-by: Marvinliu <yong.liu@intel.com>
---
 execution.cfg    |  2 +-
 framework/dts.py | 62 +++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/execution.cfg b/execution.cfg
index 18781ee..a67d7b3 100644
--- a/execution.cfg
+++ b/execution.cfg
@@ -19,7 +19,7 @@ test_suites=
     pmd_bonded
 targets=
     x86_64-native-linuxapp-gcc
-parameters=nic_type=niantic:func=true
+parameters=nic_type=cfg:func=true
 
 [Execution2]
 crbs=<Performance CRB IP Address>
diff --git a/framework/dts.py b/framework/dts.py
index 712ed54..9ba23fe 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -42,7 +42,7 @@ import rst          # rst file support
 from crbs import crbs
 from tester import Tester
 from dut import Dut
-from settings import NICS
+from settings import NICS, DRIVERS
 from serializer import Serializer
 from exception import VerifyFailure
 from test_case import TestCase
@@ -131,6 +131,18 @@ def close_crb_sessions():
     log_handler.info("DTF ended")
 
 
+def get_nic_driver(pci_id):
+    """
+    Return linux driver for specified pci device
+    """
+    driverlist = dict(zip(NICS.values(), DRIVERS.keys()))
+    try:
+        driver = DRIVERS[driverlist[pci_id]]
+    except Exception as e:
+        driver = None
+    return driver
+
+
 def accepted_nic(pci_id):
     """
     Return True if the pci_id is a known NIC card in the settings file and if
@@ -201,7 +213,7 @@ def dts_parse_config(section):
 
     nics = [_.strip() for _ in paramDict['nic_type'].split(',')]
 
-    return duts, targets, test_suites, nics
+    return duts[0], targets, test_suites, nics
 
 
 def get_project_obj(project_name, super_class, crbInst, serializer):
@@ -255,7 +267,7 @@ def dts_log_execution(log_handler):
         pass
 
 
-def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir):
+def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics):
     """
     Create dts dut/tester instance and initialize them.
     """
@@ -270,6 +282,7 @@ def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir):
     tester.dut = dut
     dut.set_speedup_options(read_cache, skip_setup)
     dut.set_directory(base_dir)
+    dut.set_nic_types(nics)
     tester.set_speedup_options(read_cache, skip_setup)
     show_speedup_options_messages(read_cache, skip_setup)
     dut.set_test_types(func_tests=functional_only, perf_tests=performance_only)
@@ -426,36 +439,35 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
         dts_parse_param(section)
 
         # verify if the delimiter is good if the lists are vertical
-        duts, targets, test_suites, nics = dts_parse_config(section)
+        dutIP, targets, test_suites, nics = dts_parse_config(section)
 
-        for dutIP in duts:
-            log_handler.info("\nDUT " + dutIP)
+        log_handler.info("\nDUT " + dutIP)
 
-            # look up in crbs - to find the matching IP
-            crbInst = None
-            for crb in crbs:
-                if crb['IP'] == dutIP:
-                    crbInst = crb
-                    break
+        # look up in crbs - to find the matching IP
+        crbInst = None
+        for crb in crbs:
+            if crb['IP'] == dutIP:
+                crbInst = crb
+                break
 
-            # only run on the dut in known crbs
-            if crbInst is None:
-                log_handler.error(" SKIP UNKNOWN CRB")
-                continue
+        # only run on the dut in known crbs
+        if crbInst is None:
+            log_handler.error(" SKIP UNKNOWN CRB")
+            continue
 
-            result.dut = dutIP
+        result.dut = dutIP
 
-            # init dut, tester crb
-            dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir)
+        # init dut, tester crb
+        dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics)
 
-            # Run DUT prerequisites
-            if dts_run_prerequisties(pkgName, patch) is False:
-                dts_crbs_exit()
-                continue
+        # Run DUT prerequisites
+        if dts_run_prerequisties(pkgName, patch) is False:
+            dts_crbs_exit()
+            continue
 
-            dts_run_target(crbInst, targets, test_suites, nics)
+        dts_run_target(crbInst, targets, test_suites, nics)
 
-            dts_crbs_exit()
+        dts_crbs_exit()
 
     save_all_results()
 
-- 
1.9.3

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

* [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence
  2015-01-23  8:26 [dts] [PATCH 0/4] Support additional port configuration file Marvin Liu
  2015-01-23  8:26 ` [dts] [PATCH 1/4] framework: add new module for load " Marvin Liu
  2015-01-23  8:26 ` [dts] [PATCH 2/4] framework: execuction file support port config nic_type Marvin Liu
@ 2015-01-23  8:26 ` Marvin Liu
  2015-02-04  3:56   ` Qiu, Michael
  2015-01-23  8:26 ` [dts] [PATCH 4/4] suites: remove nic type check from testsuites Marvin Liu
  3 siblings, 1 reply; 11+ messages in thread
From: Marvin Liu @ 2015-01-23  8:26 UTC (permalink / raw)
  To: dts

From: Yong Liu <yong.liu@intel.com>

DUT port initialization sequence: scan,restore,rescan,load config
Test port initialization sequence: modprobe, interface up
Separate restore interface function from DUT and Tester.

Signed-off-by: Marvinliu <yong.liu@intel.com>
---
 framework/crb.py          |  53 ++++----------
 framework/dut.py          | 181 +++++++++++++++++++++++++++++++++++-----------
 framework/project_dpdk.py |  22 ++----
 framework/tester.py       |  30 ++++++++
 4 files changed, 190 insertions(+), 96 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index aca62c1..d7a1afd 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -133,44 +133,6 @@ class Crb(object):
         """
         self.send_expect("ip link set  %s %s" % (eth, status), "# ")
 
-    def restore_interfaces(self):
-        """
-        Restore Linux interfaces.
-        """
-        if dts.drivername == "vfio-pci":
-            self.send_expect("rmmod vfio_iommu_type1", "# ", 10)
-            self.send_expect("rmmod vfio_pci", "# ", 10)
-            self.send_expect("rmmod vfio", "# ", 10)
-        else:
-            self.send_expect("rmmod igb_uio", "# ", 10)
-        self.send_expect("modprobe igb", "# ", 20)
-        self.send_expect("modprobe ixgbe", "# ", 20)
-        self.send_expect("modprobe e1000e", "# ", 20)
-        self.send_expect("modprobe e1000", "# ", 20)
-        self.send_expect("modprobe virtio_net", "# ", 20)
-
-        try:
-            for (pci_bus, pci_id) in self.pci_devices_info:
-                if pci_id in ('8086:10fb', '8086:151c', '8086:1528', '8086:1512', '8086:154a'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
-                elif pci_id in ('8086:10e8', '8086:150e', '8086:1521', '8086:10c9', '8086:1526', '8086:1533'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/igb/bind" % pci_bus, "# ")
-                elif pci_id in('8086:10d3', '8086:10b9'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000e/bind" % pci_bus, "# ")
-                elif pci_id in ('8086:100f', '8086:100e'):
-                    self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/e1000/bind" % pci_bus, "# ")
-                elif pci_id in ('1af4:1000'):
-                    self.send_expect("echo 0000%s > /sys/bus/pci/drivers/virtio-pci/bind" % pci_bus, "# ")
-                else:
-                    continue
-
-                addr_array = pci_bus.split(':')
-                itf = self.get_interface_name(addr_array[0], addr_array[1])
-                self.send_expect("ifconfig %s up" % itf, "# ")
-
-        except Exception as e:
-            self.logger.error("   !!! Restore ITF: " + e.message)
-
     def pci_devices_information(self):
         """
         Scan CRB pci device information and save it into cache file.
@@ -194,7 +156,7 @@ class Crb(object):
         Look for the NIC's information (PCI Id and card type).
         """
         out = self.send_expect("lspci -nn | grep -i eth", "# ")
-        rexp = r"([\da-f]{2}:[\da-f]{2}.\d{1}) Ethernet .* Intel Corporation .*?([\da-f]{4}:[\da-f]{4})"
+        rexp = r"([\da-f]{2}:[\da-f]{2}.\d{1}) Ethernet .*?([\da-f]{4}:[\da-f]{4})"
         pattern = re.compile(rexp)
         match = pattern.findall(out)
         self.pci_devices_info = []
@@ -264,6 +226,19 @@ class Crb(object):
         match = pattern.findall(out)
         return match[0]
 
+    def get_device_numa(self, bus_id, devfun_id):
+        """
+        Get numa id of specified pci device
+        """
+        numa = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node" %
+                                (bus_id, devfun_id), "# ")
+        try:
+            numa = int(numa)
+        except ValueError:
+            numa = -1
+            self.logger.warning("NUMA not available")
+        return numa
+
     def get_ipv6_addr(self, intf):
         """
         Get ipv6 address of specified pci device.
diff --git a/framework/dut.py b/framework/dut.py
index 4def144..959f499 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -33,6 +33,7 @@ import os
 import re
 import time
 import dts
+from config import UserConf
 from settings import NICS
 from ssh_connection import SSHConnection
 from crb import Crb
@@ -68,6 +69,7 @@ class Dut(Crb):
         self.cores = []
         self.architecture = None
         self.ports_info = None
+        self.conf = UserConf()
 
     def change_config_option(self, target, parameter, value):
         """
@@ -76,6 +78,14 @@ class Dut(Crb):
         self.send_expect("sed -i 's/%s=.*$/%s=%s/'  config/defconfig_%s" %
                          (parameter, parameter, value, target), "# ")
 
+    def set_nic_types(self, nics):
+        """
+        Set CRB NICS ready to validated.
+        """
+        self.nics = nics
+        if 'cfg' in nics:
+            self.conf.load_ports_config(self.get_ip_address())
+
     def set_toolchain(self, target):
         """
         This looks at the current target and instantiates an attribute to
@@ -136,8 +146,14 @@ class Dut(Crb):
 
         self.init_core_list()
         self.pci_devices_information()
-        self.restore_interfaces()
+        # scan ports before restore interface
         self.scan_ports()
+		# restore dut ports to kernel
+        self.restore_interfaces()
+		# rescan ports after interface up
+        self.rescan_ports()
+		# load port infor from config file
+        self.load_portconf()
         self.mount_procfs()
 
     def restore_interfaces(self):
@@ -251,7 +267,7 @@ class Dut(Crb):
 
         self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# ', 30)
 
-    def get_ports(self, nic_type, perf=None, socket=None):
+    def get_ports(self, nic_type='any', perf=None, socket=None):
         """
         Return DUT port list with the filter of NIC type, whether run IXIA
         performance test, whether request specified socket.
@@ -293,7 +309,7 @@ class Dut(Crb):
         else:
             return ports
 
-    def get_ports_performance(self, nic_type, perf=None, socket=None,
+    def get_ports_performance(self, nic_type='any', perf=None, socket=None,
                               force_same_socket=True,
                               force_different_nic=True):
         """
@@ -331,6 +347,15 @@ class Dut(Crb):
 
         return biggest_set
 
+    def get_peer_pci(self, port_num):
+        """
+        return the peer pci address of dut port
+        """
+        if 'peer' not in self.ports_info[port_num]:
+            return None
+        else:
+            return self.ports_info[port_num]['peer']
+
     def get_mac_address(self, port_num):
         """
         return the port mac on dut
@@ -373,6 +398,55 @@ class Dut(Crb):
         else:
             return 1
 
+    def check_ports_available(self, pci_bus, pci_id):
+        """
+        Check that whether auto scanned ports ready to use
+        """
+        pci_addr = "%s:%s" % (pci_bus, pci_id)
+        codenames = []
+        for nic in self.nics:
+            if nic == 'any':
+                return True
+            elif nic == 'cfg':
+                if self.conf.check_port_available(pci_bus) is True:
+                    return True
+            elif nic not in NICS.keys():
+                self.logger.warning("NOT SUPPORTED NIC TYPE: %s" % nic)
+            else:
+                codenames.append(NICS[nic])
+
+        if pci_id in codenames:
+            return True
+
+        return False
+
+    def rescan_ports(self):
+        unknow_interface = dts.RED('Skipped: unknow_interface')
+
+        for port_info in self.ports_info:
+            pci_bus = port_info['pci']
+            addr_array = pci_bus.split(':')
+            bus_id = addr_array[0]
+            devfun_id = addr_array[1]
+            intf = self.get_interface_name(bus_id, devfun_id)
+            if "No such file" in intf:
+                self.logger.info("DUT: [0000:%s] %s" % (pci_bus, unknow_interface))
+            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 = self.get_mac_addr(intf, bus_id, devfun_id)
+            out = self.send_expect("ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'"
+                                   % intf, "# ")
+            ipv6 = out.split('/')[0]
+            # Unconnected ports don't have IPv6
+            if ":" not in ipv6:
+                ipv6 = "Not connected"
+
+            port_info['mac'] = macaddr
+            port_info['intf'] = intf
+            port_info['ipv6'] = ipv6
+
     def scan_ports(self):
         """
         Scan ports information or just read it from cache file.
@@ -403,8 +477,7 @@ class Dut(Crb):
         unknow_interface = dts.RED('Skipped: unknow_interface')
 
         for (pci_bus, pci_id) in self.pci_devices_info:
-
-            if not dts.accepted_nic(pci_id):
+            if self.check_ports_available(pci_bus, pci_id) is False:
                 self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id,
                                                           skipped))
                 continue
@@ -412,47 +485,11 @@ class Dut(Crb):
             addr_array = pci_bus.split(':')
             bus_id = addr_array[0]
             devfun_id = addr_array[1]
-            self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/igb_uio/unbind" % pci_bus, "# ")
-            if pci_id == '8086:10fb':
-                self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
-            intf = self.get_interface_name(bus_id, devfun_id)
-
-            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)
-
-            self.logger.info("DUT: [000:%s %s] %s" % (pci_bus,
-                                                      pci_id,
-                                                      intf))
-
-            if "No such file" in intf:
-                self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id,
-                                                          unknow_interface))
-                continue
-
-            macaddr = self.get_mac_addr(intf, bus_id, devfun_id)
-
-            out = self.send_expect("ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'"
-                                   % intf, "# ")
-            ipv6 = out.split('/')[0]
-
-            # Unconnected ports don't have IPv6
-            if ":" not in ipv6:
-                ipv6 = "Not connected"
-
-            numa = self.send_expect("cat /sys/bus/pci/devices/0000\:%s\:%s/numa_node" %
-                                    (bus_id, devfun_id), "# ")
 
-            try:
-                numa = int(numa)
-            except ValueError:
-                numa = -1
-                self.logger.warning("NUMA not available")
+            numa = self.get_device_numa(bus_id, devfun_id)
 
             # store the port info to port mapping
-            self.ports_info.append({'pci': pci_bus, 'type': pci_id, 'intf':
-                                    intf, 'mac': macaddr, 'ipv6': ipv6, 'numa': numa})
+            self.ports_info.append({'pci': pci_bus, 'type': pci_id, 'numa': numa})
 
     def scan_ports_uncached_freebsd(self):
         """
@@ -494,3 +531,61 @@ class Dut(Crb):
             # store the port info to port mapping
             self.ports_info.append({'pci': pci_str, 'type': pci_id, 'intf':
                                     intf, 'mac': macaddr, 'ipv6': ipv6, 'numa': -1})
+
+    def restore_interfaces(self):
+        """
+        Restore Linux interfaces.
+        """
+        for port in self.ports_info:
+            pci_bus = port['pci']
+            pci_id = port['type']
+            # get device driver
+            driver = dts.get_nic_driver(pci_id)
+            if driver is not None:
+                # unbind device driver
+                addr_array = pci_bus.split(':')
+                bus_id = addr_array[0]
+                devfun_id = addr_array[1]
+
+                self.send_expect('echo 0000:%s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind'
+                                 % (pci_bus, 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'
+                                 % (pci_bus, driver), '# ')
+                itf = self.get_interface_name(addr_array[0], addr_array[1])
+                self.send_expect("ifconfig %s up" % itf, "# ")
+
+    def load_portconf(self):
+        """
+        Load port configurations for ports_info. If manually configured infor
+        not same as auto scanned, still use infor in configuration file.
+        """
+        for port in self.ports_info:
+            pci_bus = port['pci']
+            if pci_bus in self.conf.ports_cfg:
+                port_cfg = self.conf.ports_cfg[pci_bus]
+                port_cfg['source'] = 'cfg'
+            else:
+                port_cfg = {}
+
+            if 'intf' in port_cfg:
+                if 'intf' in port:
+                    if port_cfg['intf'] != port['intf']:
+                        self.logger.warning("CONFIGURED INTERFACE NOT SAME AS SCANNED!!!")
+                port['intf'] = port_cfg['intf']
+
+            if 'mac' in port_cfg:
+                if 'mac' in port:
+                    if port_cfg['mac'] != port['mac']:
+                        self.logger.warning("CONFIGURED MACADDRESS NOT SAME AS SCANNED!!!")
+                port['mac'] = port_cfg['mac']
+
+            if 'numa' in port_cfg:
+                if 'numa' in port:
+                    if port_cfg['numa'] != port['numa']:
+                        self.logger.warning("CONFIGURED NUMA NOT SAME AS SCANNED!!!")
+                port['numa'] = port_cfg['numa']
+
+            if 'numa' in port_cfg:
+                port['peer'] = port_cfg['peer']
diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
index 6e25f1f..13be836 100644
--- a/framework/project_dpdk.py
+++ b/framework/project_dpdk.py
@@ -234,13 +234,10 @@ class DPDKdut(Dut):
         binding_list = '--bind=%s ' % driver
 
         current_nic = 0
-        for (pci_bus, pci_id) in self.pci_devices_info:
-            if dts.accepted_nic(pci_id):
-
-                if nics_to_bind is None or current_nic in nics_to_bind:
-                    binding_list += '%s ' % (pci_bus)
-
-                current_nic += 1
+        for port_info in self.ports_info:
+            if nics_to_bind is None or current_nic in nics_to_bind:
+                binding_list += '%s ' % (port_info['pci'])
+            current_nic += 1
 
         self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# ')
 
@@ -252,13 +249,10 @@ class DPDKdut(Dut):
         binding_list = '-u '
 
         current_nic = 0
-        for (pci_bus, pci_id) in self.pci_devices_info:
-            if dts.accepted_nic(pci_id):
-
-                if nics_to_bind is None or current_nic in nics_to_bind:
-                    binding_list += '%s ' % (pci_bus)
-
-                current_nic += 1
+        for port_info in self.ports_info:
+            if nics_to_bind is None or current_nic in nics_to_bind:
+                binding_list += '%s ' % (port_info['pci'])
+            current_nic += 1
 
         self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# ', 30)
 
diff --git a/framework/tester.py b/framework/tester.py
index 2c023dd..345ab41 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -170,6 +170,24 @@ class Tester(Crb):
         else:
             return 'down'
 
+    def restore_interfaces(self):
+        """
+        Restore Linux interfaces.
+        """
+        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(':')
+                itf = self.get_interface_name(addr_array[0], addr_array[1])
+                self.send_expect("ifconfig %s up" % itf, "# ")
+
+        except Exception as e:
+            self.logger.error("   !!! Restore ITF: " + e.message)
+
     def scan_ports(self):
         """
         Scan all ports on tester and save port's pci/mac/interface.
@@ -253,6 +271,18 @@ class Tester(Crb):
         hits = [False] * len(self.ports_info)
 
         for dutPort in range(nrPorts):
+            peer = self.dut.get_peer_pci(dutPort)
+            if peer is not None:
+                for localPort in range(len(self.ports_info)):
+                    if self.ports_info[localPort]['pci'] == peer:
+                        hits[localPort] = True
+                        self.ports_map[dutPort] = localPort
+                        break
+                if self.ports_map[dutPort] == -1:
+                    self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!")
+                else:
+                    continue  # skip ping6 map
+
             for localPort in range(len(self.ports_info)):
                 if hits[localPort]:
                     continue
-- 
1.9.3

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

* [dts] [PATCH 4/4] suites: remove nic type check from testsuites
  2015-01-23  8:26 [dts] [PATCH 0/4] Support additional port configuration file Marvin Liu
                   ` (2 preceding siblings ...)
  2015-01-23  8:26 ` [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Marvin Liu
@ 2015-01-23  8:26 ` Marvin Liu
  2015-02-04  3:57   ` Qiu, Michael
  3 siblings, 1 reply; 11+ messages in thread
From: Marvin Liu @ 2015-01-23  8:26 UTC (permalink / raw)
  To: dts

From: Yong Liu <yong.liu@intel.com>

Signed-off-by: Marvinliu <yong.liu@intel.com>
---
 framework/dut.py                    |  6 +++---
 tests/TestSuite_blacklist.py        |  2 +-
 tests/TestSuite_checksum_offload.py |  2 +-
 tests/TestSuite_fdir.py             | 16 ++++++++--------
 tests/TestSuite_ieee1588.py         |  6 +++---
 tests/TestSuite_ip_pipeline.py      |  2 +-
 tests/TestSuite_ipfrag.py           |  2 +-
 tests/TestSuite_jumboframes.py      |  2 +-
 tests/TestSuite_l2fwd.py            |  2 +-
 tests/TestSuite_l3fwd.py            |  6 +++---
 tests/TestSuite_link_flowctrl.py    |  2 +-
 tests/TestSuite_multiprocess.py     |  2 +-
 tests/TestSuite_pmd.py              |  4 ++--
 tests/TestSuite_pmd_bonded.py       |  2 +-
 tests/TestSuite_vlan.py             |  3 +--
 tests/TestSuite_whitelist.py        |  2 +-
 16 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index 959f499..1c8367d 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -148,11 +148,11 @@ class Dut(Crb):
         self.pci_devices_information()
         # scan ports before restore interface
         self.scan_ports()
-		# restore dut ports to kernel
+        # restore dut ports to kernel
         self.restore_interfaces()
-		# rescan ports after interface up
+        # rescan ports after interface up
         self.rescan_ports()
-		# load port infor from config file
+        # load port infor from config file
         self.load_portconf()
         self.mount_procfs()
 
diff --git a/tests/TestSuite_blacklist.py b/tests/TestSuite_blacklist.py
index 65c1ec6..8e9debd 100644
--- a/tests/TestSuite_blacklist.py
+++ b/tests/TestSuite_blacklist.py
@@ -54,7 +54,7 @@ class TestBlacklist(TestCase):
             Two Ports
         """
 
-        self.ports = self.dut.get_ports(self.nic)
+        self.ports = self.dut.get_ports()
         self.verify(len(self.ports) >= 2, "Insufficient ports for testing")
         [arch, machine, self.env, toolchain] = self.target.split('-')
 
diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 1ebac0f..05438b2 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -54,7 +54,7 @@ class TestChecksumOffload(TestCase):
         Checksum offload prerequisites.
         """
         # Based on h/w type, choose how many ports to use
-        self.dut_ports = self.dut.get_ports_performance(self.nic)
+        self.dut_ports = self.dut.get_ports_performance()
 
         # Verify that enough ports are available
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports for testing")
diff --git a/tests/TestSuite_fdir.py b/tests/TestSuite_fdir.py
index a9f7fa3..1c8d8f7 100644
--- a/tests/TestSuite_fdir.py
+++ b/tests/TestSuite_fdir.py
@@ -48,7 +48,7 @@ class TestFdir(TestCase):
         """
         Run at the start of each test suite.
         """
-        ports = self.dut.get_ports(self.nic)
+        ports = self.dut.get_ports()
         self.verify(len(ports) >= 2, "Not enough ports available")
 
         self.pmdout = PmdOutput(self.dut)
@@ -81,7 +81,7 @@ class TestFdir(TestCase):
         Setting memory reserved for FDir filters.
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
 
         self.pmdout.start_testpmd("all", "--rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=64K")
         out = self.dut.send_expect("show port fdir %s" % dutPorts[0], "testpmd>")
@@ -111,7 +111,7 @@ class TestFdir(TestCase):
           - Send the ``p_udp`` packet with Scapy on the traffic generator and check that FDir information is printed
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
@@ -173,7 +173,7 @@ class TestFdir(TestCase):
           - Send the packet and validate the filter function.
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
@@ -230,7 +230,7 @@ class TestFdir(TestCase):
           - Send the packet and validate the perfect filter function.
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
@@ -261,7 +261,7 @@ class TestFdir(TestCase):
         fields, or parts of fields are used in the matching process.
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
@@ -306,7 +306,7 @@ class TestFdir(TestCase):
         to the bytes at offset 36 and 37, as the offset is in 2-byte units
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
@@ -335,7 +335,7 @@ class TestFdir(TestCase):
         FDir VLAN field filtering
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         localPort = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(localPort)
 
diff --git a/tests/TestSuite_ieee1588.py b/tests/TestSuite_ieee1588.py
index c6fdd61..bf48188 100644
--- a/tests/TestSuite_ieee1588.py
+++ b/tests/TestSuite_ieee1588.py
@@ -52,7 +52,7 @@ class TestIeee1588(TestCase):
         IEEE1588 Prerequisites
         """
 
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         self.verify(len(dutPorts) > 0, "No ports found for " + self.nic)
 
         # Change the config file to support IEEE1588 and recompile the package.
@@ -82,7 +82,7 @@ class TestIeee1588(TestCase):
         time.sleep(1)  # Allow the output from the "start" command to finish before looking for a regexp in expect
 
         # use the first port on that self.nic
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         port = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(port)
 
@@ -125,7 +125,7 @@ class TestIeee1588(TestCase):
         time.sleep(3)
 
         # use the first port on that self.nic
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         port = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(port)
 
diff --git a/tests/TestSuite_ip_pipeline.py b/tests/TestSuite_ip_pipeline.py
index 9c56799..22c6766 100644
--- a/tests/TestSuite_ip_pipeline.py
+++ b/tests/TestSuite_ip_pipeline.py
@@ -293,7 +293,7 @@ class TestIPPipeline(TestCase):
 
         # Check for port availability
         self.needed_ports = {"niantic": 2}
-        self.dut_ports = self.dut.get_ports(self.nic)
+        self.dut_ports = self.dut.get_ports()
         self.verify(len(self.dut_ports) >= self.needed_ports[self.nic],
                     "Insufficient ports for speed testing")
 
diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
index 1f08c85..22a24a6 100644
--- a/tests/TestSuite_ipfrag.py
+++ b/tests/TestSuite_ipfrag.py
@@ -81,7 +81,7 @@ class TestIpfrag(TestCase):
         """
 
         # Based on h/w type, choose how many ports to use
-        ports = self.dut.get_ports(self.nic)
+        ports = self.dut.get_ports()
         print ports
 
         # Verify that enough ports are available
diff --git a/tests/TestSuite_jumboframes.py b/tests/TestSuite_jumboframes.py
index 2b862af..83b3427 100644
--- a/tests/TestSuite_jumboframes.py
+++ b/tests/TestSuite_jumboframes.py
@@ -113,7 +113,7 @@ class TestJumboframes(TestCase):
         Prerequisite steps for each test suit.
         """
 
-        self.dut_ports = self.dut.get_ports(self.nic)
+        self.dut_ports = self.dut.get_ports()
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
         self.rx_port = self.dut_ports[0]
         self.tx_port = self.dut_ports[1]
diff --git a/tests/TestSuite_l2fwd.py b/tests/TestSuite_l2fwd.py
index b75163c..5c79cbf 100644
--- a/tests/TestSuite_l2fwd.py
+++ b/tests/TestSuite_l2fwd.py
@@ -83,7 +83,7 @@ class TestL2fwd(TestCase):
         self.headers_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + \
             HEADER_SIZE['udp']
 
-        self.dut_ports = self.dut.get_ports_performance(self.nic)
+        self.dut_ports = self.dut.get_ports_performance()
 
         self.verify(len(self.dut_ports) >= self.number_of_ports,
                     "Not enough ports for " + self.nic)
diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py
index 0e7df85..1b2bf0d 100644
--- a/tests/TestSuite_l3fwd.py
+++ b/tests/TestSuite_l3fwd.py
@@ -309,9 +309,9 @@ class TestL3fwd(TestCase):
         L3fwd Prerequisites
         """
         # Based on h/w type, choose how many ports to use
-        ports = self.dut.get_ports(self.nic, socket=1)
+        ports = self.dut.get_ports(socket=1)
         if not ports:
-            ports = self.dut.get_ports(self.nic, socket=0)
+            ports = self.dut.get_ports(socket=0)
 
         # Verify that enough ports are available
         self.verify(len(ports) >= 2, "Insufficient ports for speed testing")
@@ -473,7 +473,7 @@ class TestL3fwd(TestCase):
         """
 
         # Based on h/w type, choose how many ports to use
-        ports = self.dut.get_ports(self.nic)
+        ports = self.dut.get_ports()
         # Verify that enough ports are available
         self.verify(len(ports) >= 4, "Insufficient ports for speed testing")
 
diff --git a/tests/TestSuite_link_flowctrl.py b/tests/TestSuite_link_flowctrl.py
index 3c195c9..e52f95a 100644
--- a/tests/TestSuite_link_flowctrl.py
+++ b/tests/TestSuite_link_flowctrl.py
@@ -64,7 +64,7 @@ class TestLinkFlowctrl(TestCase):
         Link flow control Prerequisites
         """
 
-        self.dutPorts = self.dut.get_ports(self.nic)
+        self.dutPorts = self.dut.get_ports()
         self.verify(len(self.dutPorts) > 1, "Insuficient ports")
 
         self.rx_port = self.dutPorts[0]
diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
index 2c8eeba..4ef5313 100644
--- a/tests/TestSuite_multiprocess.py
+++ b/tests/TestSuite_multiprocess.py
@@ -191,7 +191,7 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
         """
         self.dut.kill_all()
         self.dut.send_expect("fg", "# ")
-        dutPorts = self.dut.get_ports(self.nic)
+        dutPorts = self.dut.get_ports()
         txPort = self.tester.get_local_port(dutPorts[0])
         rxPort = self.tester.get_local_port(dutPorts[1])
         mac = self.tester.get_mac(txPort)
diff --git a/tests/TestSuite_pmd.py b/tests/TestSuite_pmd.py
index acd6364..a21977b 100644
--- a/tests/TestSuite_pmd.py
+++ b/tests/TestSuite_pmd.py
@@ -104,7 +104,7 @@ class TestPmd(TestCase):
                     "NIC Unsupported: " + str(self.nic))
 
         # Based on h/w type, choose how many ports to use
-        self.dut_ports = self.dut.get_ports(self.nic)
+        self.dut_ports = self.dut.get_ports()
 
         # Verify that enough ports are available
         self.verify(len(self.dut_ports) >= self.needed_ports[self.nic],
@@ -162,7 +162,7 @@ class TestPmd(TestCase):
                 queues = 1
 
             core_mask = dts.create_mask(core_list)
-            port_mask = dts.create_mask(self.dut.get_ports(self.nic))
+            port_mask = dts.create_mask(self.dut.get_ports())
 
             self.pmdout.start_testpmd("all", "--coremask=%s --rxq=%d --txq=%d --portmask=%s" % (core_mask, queues, queues, port_mask))
 
diff --git a/tests/TestSuite_pmd_bonded.py b/tests/TestSuite_pmd_bonded.py
index e8e61dd..fd15c1d 100644
--- a/tests/TestSuite_pmd_bonded.py
+++ b/tests/TestSuite_pmd_bonded.py
@@ -792,7 +792,7 @@ UDP(sport=srcport, dport=destport)/Raw(load="\x50"*%s)], iface="%s", count=%d)'
         self.ip_head_size = 20
         self.udp_header_size = 8
 
-        self.dut_ports = self.dut.get_ports(self.nic)
+        self.dut_ports = self.dut.get_ports()
 
         self.port_mask = dts.create_mask(self.dut_ports)
 
diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index e9813f3..66dc4f3 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -53,12 +53,11 @@ class TestVlan(TestCase):
         """
 
         # Based on h/w type, choose how many ports to use
-        ports = self.dut.get_ports(self.nic)
+        ports = self.dut.get_ports()
 
         # Verify that enough ports are available
         self.verify(len(ports) >= 2, "Insufficient ports")
 
-        ports = self.dut.get_ports(self.nic)
         global valports
         valports = [_ for _ in ports if self.tester.get_local_port(_) != -1]
 
diff --git a/tests/TestSuite_whitelist.py b/tests/TestSuite_whitelist.py
index a32251d..aedae40 100644
--- a/tests/TestSuite_whitelist.py
+++ b/tests/TestSuite_whitelist.py
@@ -55,7 +55,7 @@ class TestWhitelist(TestCase):
         self.frames_to_send = 1
 
         # Based on h/w type, choose how many ports to use
-        self.dutPorts = self.dut.get_ports(self.nic)
+        self.dutPorts = self.dut.get_ports()
 
         # Verify that enough ports are available
         self.verify(len(self.dutPorts) >= 1, "Insufficient ports")
-- 
1.9.3

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

* Re: [dts] [PATCH 1/4] framework: add new module for load port configuration file
  2015-01-23  8:26 ` [dts] [PATCH 1/4] framework: add new module for load " Marvin Liu
@ 2015-02-04  3:26   ` Qiu, Michael
  2015-02-04  4:51     ` Liu, Yong
  0 siblings, 1 reply; 11+ messages in thread
From: Qiu, Michael @ 2015-02-04  3:26 UTC (permalink / raw)
  To: Liu, Yong, dts

On 1/23/2015 4:27 PM, Marvin Liu wrote:
> From: Yong Liu <yong.liu@intel.com>
>
> Config module will load port configuration and parse port parameter.
> Port configuration will be used in the process of setting up DUT.
> User can assign port mac, numa or tester peer pci address of DUT port.
>
> Signed-off-by: Marvinliu <yong.liu@intel.com>
> ---
>  conf/ports.cfg      |  4 +++
>  framework/config.py | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 97 insertions(+)
>  create mode 100644 conf/ports.cfg
>  create mode 100755 framework/config.py
>
> diff --git a/conf/ports.cfg b/conf/ports.cfg
> new file mode 100644
> index 0000000..85c1998
> --- /dev/null
> +++ b/conf/ports.cfg
> @@ -0,0 +1,4 @@
> +[10.239.128.117]
> +ports=
> +    pci=86:00.0,intf=p4p1;
> +    pci=86:00.1,mac=90:e2:ba:39:b7:69,peer=05:00.1,numa=0
> diff --git a/framework/config.py b/framework/config.py
> new file mode 100755
> index 0000000..140c84b
> --- /dev/null
> +++ b/framework/config.py
> @@ -0,0 +1,93 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2014 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.
> +
> +"""
> +Generic port and crbs configuration file load function
> +"""
> +
> +import ConfigParser  # config parse module
> +import argparse      # prase arguments module
> +
> +portconf = "../conf/ports.cfg"
> +crbconf = "../conf/crbs.cfg"
> +
> +
> +class UserConf():
> +
> +    def __init__(self, port_conf=portconf, crb_conf=crbconf):
> +        self.port_config = port_conf
> +        self.crb_config = crb_conf
> +        self.ports_cfg = {}
> +        try:
> +            self.port_conf = ConfigParser.SafeConfigParser()
> +            self.port_conf.read(self.port_config)
> +        except Exception as e:
> +            print "FAILED LOADING PORT CONFIG!!!"
> +
> +    def load_ports_config(self, crbIP):
> +        ports = []
> +        for crb in self.port_conf.sections():
> +            if crb != crbIP:
> +                continue
> +            ports = [port.strip()
> +                     for port in self.port_conf.get(crb, 'ports').split(';')]
> +
> +        for port in ports:
> +            port_cfg = self.parse_port_param(port)
> +            if 'pci' not in port_cfg:
> +                print "INVALID CONFIG FOR NO PCI ADDRESS!!!"

Would you think this port is valid for this error?

> +            keys = port_cfg.keys()
> +            keys.remove('pci')
> +            self.ports_cfg[port_cfg['pci']] = {key: port_cfg[key] for key in keys}
> +
> +    def check_port_available(self, pci_addr):
> +        if pci_addr in self.ports_cfg.keys():
> +            return True
> +        else:
> +            return False
> +
> +    def parse_port_param(self, port):
> +        portDict = dict()
> +
> +        for param in port.split(','):
> +            (key, _, value) = param.partition('=')
> +            portDict[key] = value
> +        return portDict
> +
> +
> +if __name__ == '__main__':
> +    parser = argparse.ArgumentParser(description="Load DTS configuration files")
> +    parser.add_argument("-p", "--portconf", default=portconf)
> +    parser.add_argument("-c", "--crbconf", default=crbconf)
> +    args = parser.parse_args()
> +    conf = UserConf()
> +    conf.load_ports_config('10.239.128.120')
> +    conf.check_port_available('0000:86:00.0')

Why here show ip and PCI address?

All those could inside cfg file, and parse it here, cfg file can be user
defined, but the script should not be changed for different config.

Thanks,
Michael


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

* Re: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence
  2015-01-23  8:26 ` [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Marvin Liu
@ 2015-02-04  3:56   ` Qiu, Michael
  2015-02-04  5:24     ` Liu, Yong
  0 siblings, 1 reply; 11+ messages in thread
From: Qiu, Michael @ 2015-02-04  3:56 UTC (permalink / raw)
  To: Liu, Yong, dts

On 1/23/2015 4:27 PM, Marvin Liu wrote:
> From: Yong Liu <yong.liu@intel.com>
>
> DUT port initialization sequence: scan,restore,rescan,load config
> Test port initialization sequence: modprobe, interface up
> Separate restore interface function from DUT and Tester.
>
> Signed-off-by: Marvinliu <yong.liu@intel.com>
> ---
>  framework/crb.py          |  53 ++++----------
>  framework/dut.py          | 181 +++++++++++++++++++++++++++++++++++-----------
>  framework/project_dpdk.py |  22 ++----
>  framework/tester.py       |  30 ++++++++
>  4 files changed, 190 insertions(+), 96 deletions(-)
>

[...]

> @@ -494,3 +531,61 @@ class Dut(Crb):
>              # store the port info to port mapping
>              self.ports_info.append({'pci': pci_str, 'type': pci_id, 'intf':
>                                      intf, 'mac': macaddr, 'ipv6': ipv6, 'numa': -1})
> +
> +    def restore_interfaces(self):
> +        """
> +        Restore Linux interfaces.
> +        """
> +        for port in self.ports_info:
> +            pci_bus = port['pci']
> +            pci_id = port['type']
> +            # get device driver
> +            driver = dts.get_nic_driver(pci_id)
> +            if driver is not None:
> +                # unbind device driver
> +                addr_array = pci_bus.split(':')
> +                bus_id = addr_array[0]
> +                devfun_id = addr_array[1]
> +
> +                self.send_expect('echo 0000:%s > /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind'

Here  if this devices has no driver binded, will failed, but seems no
affect for logic, but at least should give some log message I think.

Thanks,
Michael
> +                                 % (pci_bus, 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'
> +                                 % (pci_bus, driver), '# ')
> +                itf = self.get_interface_name(addr_array[0], addr_array[1])
> +                self.send_expect("ifconfig %s up" % itf, "# ")
> +
> +    def load_portconf(self):
> +        """
> +        Load port configurations for ports_info. If manually configured infor
> +        not same as auto scanned, still use infor in configuration file.
> +        """
> +        for port in self.ports_info:
> +            pci_bus = port['pci']
> +            if pci_bus in self.conf.ports_cfg:
> +                port_cfg = self.conf.ports_cfg[pci_bus]
> +                port_cfg['source'] = 'cfg'
> +            else:
> +                port_cfg = {}
> +
> +            if 'intf' in port_cfg:
> +                if 'intf' in port:
> +                    if port_cfg['intf'] != port['intf']:
> +                        self.logger.warning("CONFIGURED INTERFACE NOT SAME AS SCANNED!!!")
> +                port['intf'] = port_cfg['intf']
> +
> +            if 'mac' in port_cfg:
> +                if 'mac' in port:
> +                    if port_cfg['mac'] != port['mac']:
> +                        self.logger.warning("CONFIGURED MACADDRESS NOT SAME AS SCANNED!!!")
> +                port['mac'] = port_cfg['mac']
> +
> +            if 'numa' in port_cfg:
> +                if 'numa' in port:
> +                    if port_cfg['numa'] != port['numa']:
> +                        self.logger.warning("CONFIGURED NUMA NOT SAME AS SCANNED!!!")
> +                port['numa'] = port_cfg['numa']
> +
> +            if 'numa' in port_cfg:
> +                port['peer'] = port_cfg['peer']

Why "if 'numa' in port_cfg:" twice here?

Also it is almost the same for those:

if key in port_cfg:

So can we do a iteration here?Like below:

for key in port_cfg:
    if key in port:
        if port_cfg['intf'] != port['intf']:
            self.logger.warning("CONFIGURED INTERFACE NOT SAME AS
SCANNED!!!")
        port[key] = port_cfg[key]


Thanks,
Michael

> diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
> index 6e25f1f..13be836 100644
> --- a/framework/project_dpdk.py
> +++ b/framework/project_dpdk.py
> @@ -234,13 +234,10 @@ class DPDKdut(Dut):
>          binding_list = '--bind=%s ' % driver
>  
>          current_nic = 0
> -        for (pci_bus, pci_id) in self.pci_devices_info:
> -            if dts.accepted_nic(pci_id):
> -
> -                if nics_to_bind is None or current_nic in nics_to_bind:
> -                    binding_list += '%s ' % (pci_bus)
> -
> -                current_nic += 1
> +        for port_info in self.ports_info:
> +            if nics_to_bind is None or current_nic in nics_to_bind:
> +                binding_list += '%s ' % (port_info['pci'])
> +            current_nic += 1
>  
>          self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# ')
>  
> @@ -252,13 +249,10 @@ class DPDKdut(Dut):
>          binding_list = '-u '
>  
>          current_nic = 0
> -        for (pci_bus, pci_id) in self.pci_devices_info:
> -            if dts.accepted_nic(pci_id):
> -
> -                if nics_to_bind is None or current_nic in nics_to_bind:
> -                    binding_list += '%s ' % (pci_bus)
> -
> -                current_nic += 1
> +        for port_info in self.ports_info:
> +            if nics_to_bind is None or current_nic in nics_to_bind:
> +                binding_list += '%s ' % (port_info['pci'])
> +            current_nic += 1
>  
>          self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '# ', 30)
>  
> diff --git a/framework/tester.py b/framework/tester.py
> index 2c023dd..345ab41 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -170,6 +170,24 @@ class Tester(Crb):
>          else:
>              return 'down'
>  
> +    def restore_interfaces(self):
> +        """
> +        Restore Linux interfaces.
> +        """
> +        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(':')
> +                itf = self.get_interface_name(addr_array[0], addr_array[1])
> +                self.send_expect("ifconfig %s up" % itf, "# ")
> +
> +        except Exception as e:
> +            self.logger.error("   !!! Restore ITF: " + e.message)
> +
>      def scan_ports(self):
>          """
>          Scan all ports on tester and save port's pci/mac/interface.
> @@ -253,6 +271,18 @@ class Tester(Crb):
>          hits = [False] * len(self.ports_info)
>  
>          for dutPort in range(nrPorts):
> +            peer = self.dut.get_peer_pci(dutPort)
> +            if peer is not None:
> +                for localPort in range(len(self.ports_info)):
> +                    if self.ports_info[localPort]['pci'] == peer:
> +                        hits[localPort] = True
> +                        self.ports_map[dutPort] = localPort
> +                        break
> +                if self.ports_map[dutPort] == -1:
> +                    self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!")
> +                else:
> +                    continue  # skip ping6 map
> +
>              for localPort in range(len(self.ports_info)):
>                  if hits[localPort]:
>                      continue


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

* Re: [dts] [PATCH 4/4] suites: remove nic type check from testsuites
  2015-01-23  8:26 ` [dts] [PATCH 4/4] suites: remove nic type check from testsuites Marvin Liu
@ 2015-02-04  3:57   ` Qiu, Michael
  0 siblings, 0 replies; 11+ messages in thread
From: Qiu, Michael @ 2015-02-04  3:57 UTC (permalink / raw)
  To: Liu, Yong, dts

On 1/23/2015 4:27 PM, Marvin Liu wrote:
> From: Yong Liu <yong.liu@intel.com>
>
> Signed-off-by: Marvinliu <yong.liu@intel.com>
> ---
>  framework/dut.py                    |  6 +++---
>  tests/TestSuite_blacklist.py        |  2 +-
>  tests/TestSuite_checksum_offload.py |  2 +-
>  tests/TestSuite_fdir.py             | 16 ++++++++--------
>  tests/TestSuite_ieee1588.py         |  6 +++---
>  tests/TestSuite_ip_pipeline.py      |  2 +-
>  tests/TestSuite_ipfrag.py           |  2 +-
>  tests/TestSuite_jumboframes.py      |  2 +-
>  tests/TestSuite_l2fwd.py            |  2 +-
>  tests/TestSuite_l3fwd.py            |  6 +++---
>  tests/TestSuite_link_flowctrl.py    |  2 +-
>  tests/TestSuite_multiprocess.py     |  2 +-
>  tests/TestSuite_pmd.py              |  4 ++--
>  tests/TestSuite_pmd_bonded.py       |  2 +-
>  tests/TestSuite_vlan.py             |  3 +--
>  tests/TestSuite_whitelist.py        |  2 +-
>  16 files changed, 30 insertions(+), 31 deletions(-)
>
> diff --git a/framework/dut.py b/framework/dut.py
> index 959f499..1c8367d 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -148,11 +148,11 @@ class Dut(Crb):
>          self.pci_devices_information()
>          # scan ports before restore interface
>          self.scan_ports()
> -		# restore dut ports to kernel
> +        # restore dut ports to kernel
>          self.restore_interfaces()
> -		# rescan ports after interface up
> +        # rescan ports after interface up
>          self.rescan_ports()
> -		# load port infor from config file
> +        # load port infor from config file
>          self.load_portconf()
>          self.mount_procfs()
>  
> diff --git a/tests/TestSuite_blacklist.py b/tests/TestSuite_blacklist.py
> index 65c1ec6..8e9debd 100644
> --- a/tests/TestSuite_blacklist.py
> +++ b/tests/TestSuite_blacklist.py
> @@ -54,7 +54,7 @@ class TestBlacklist(TestCase):
>              Two Ports
>          """
>  
> -        self.ports = self.dut.get_ports(self.nic)
> +        self.ports = self.dut.get_ports()
>          self.verify(len(self.ports) >= 2, "Insufficient ports for testing")
>          [arch, machine, self.env, toolchain] = self.target.split('-')
>  
> diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
> index 1ebac0f..05438b2 100644
> --- a/tests/TestSuite_checksum_offload.py
> +++ b/tests/TestSuite_checksum_offload.py
> @@ -54,7 +54,7 @@ class TestChecksumOffload(TestCase):
>          Checksum offload prerequisites.
>          """
>          # Based on h/w type, choose how many ports to use
> -        self.dut_ports = self.dut.get_ports_performance(self.nic)
> +        self.dut_ports = self.dut.get_ports_performance()
>  
>          # Verify that enough ports are available
>          self.verify(len(self.dut_ports) >= 2, "Insufficient ports for testing")
> diff --git a/tests/TestSuite_fdir.py b/tests/TestSuite_fdir.py
> index a9f7fa3..1c8d8f7 100644
> --- a/tests/TestSuite_fdir.py
> +++ b/tests/TestSuite_fdir.py
> @@ -48,7 +48,7 @@ class TestFdir(TestCase):
>          """
>          Run at the start of each test suite.
>          """
> -        ports = self.dut.get_ports(self.nic)
> +        ports = self.dut.get_ports()
>          self.verify(len(ports) >= 2, "Not enough ports available")
>  
>          self.pmdout = PmdOutput(self.dut)
> @@ -81,7 +81,7 @@ class TestFdir(TestCase):
>          Setting memory reserved for FDir filters.
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>  
>          self.pmdout.start_testpmd("all", "--rxq=2 --txq=2 --disable-rss --pkt-filter-mode=perfect --pkt-filter-size=64K")
>          out = self.dut.send_expect("show port fdir %s" % dutPorts[0], "testpmd>")
> @@ -111,7 +111,7 @@ class TestFdir(TestCase):
>            - Send the ``p_udp`` packet with Scapy on the traffic generator and check that FDir information is printed
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> @@ -173,7 +173,7 @@ class TestFdir(TestCase):
>            - Send the packet and validate the filter function.
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> @@ -230,7 +230,7 @@ class TestFdir(TestCase):
>            - Send the packet and validate the perfect filter function.
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> @@ -261,7 +261,7 @@ class TestFdir(TestCase):
>          fields, or parts of fields are used in the matching process.
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> @@ -306,7 +306,7 @@ class TestFdir(TestCase):
>          to the bytes at offset 36 and 37, as the offset is in 2-byte units
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> @@ -335,7 +335,7 @@ class TestFdir(TestCase):
>          FDir VLAN field filtering
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          localPort = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(localPort)
>  
> diff --git a/tests/TestSuite_ieee1588.py b/tests/TestSuite_ieee1588.py
> index c6fdd61..bf48188 100644
> --- a/tests/TestSuite_ieee1588.py
> +++ b/tests/TestSuite_ieee1588.py
> @@ -52,7 +52,7 @@ class TestIeee1588(TestCase):
>          IEEE1588 Prerequisites
>          """
>  
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          self.verify(len(dutPorts) > 0, "No ports found for " + self.nic)
>  
>          # Change the config file to support IEEE1588 and recompile the package.
> @@ -82,7 +82,7 @@ class TestIeee1588(TestCase):
>          time.sleep(1)  # Allow the output from the "start" command to finish before looking for a regexp in expect
>  
>          # use the first port on that self.nic
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          port = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(port)
>  
> @@ -125,7 +125,7 @@ class TestIeee1588(TestCase):
>          time.sleep(3)
>  
>          # use the first port on that self.nic
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          port = self.tester.get_local_port(dutPorts[0])
>          itf = self.tester.get_interface(port)
>  
> diff --git a/tests/TestSuite_ip_pipeline.py b/tests/TestSuite_ip_pipeline.py
> index 9c56799..22c6766 100644
> --- a/tests/TestSuite_ip_pipeline.py
> +++ b/tests/TestSuite_ip_pipeline.py
> @@ -293,7 +293,7 @@ class TestIPPipeline(TestCase):
>  
>          # Check for port availability
>          self.needed_ports = {"niantic": 2}
> -        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.dut_ports = self.dut.get_ports()
>          self.verify(len(self.dut_ports) >= self.needed_ports[self.nic],
>                      "Insufficient ports for speed testing")
>  
> diff --git a/tests/TestSuite_ipfrag.py b/tests/TestSuite_ipfrag.py
> index 1f08c85..22a24a6 100644
> --- a/tests/TestSuite_ipfrag.py
> +++ b/tests/TestSuite_ipfrag.py
> @@ -81,7 +81,7 @@ class TestIpfrag(TestCase):
>          """
>  
>          # Based on h/w type, choose how many ports to use
> -        ports = self.dut.get_ports(self.nic)
> +        ports = self.dut.get_ports()
>          print ports
>  
>          # Verify that enough ports are available
> diff --git a/tests/TestSuite_jumboframes.py b/tests/TestSuite_jumboframes.py
> index 2b862af..83b3427 100644
> --- a/tests/TestSuite_jumboframes.py
> +++ b/tests/TestSuite_jumboframes.py
> @@ -113,7 +113,7 @@ class TestJumboframes(TestCase):
>          Prerequisite steps for each test suit.
>          """
>  
> -        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.dut_ports = self.dut.get_ports()
>          self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
>          self.rx_port = self.dut_ports[0]
>          self.tx_port = self.dut_ports[1]
> diff --git a/tests/TestSuite_l2fwd.py b/tests/TestSuite_l2fwd.py
> index b75163c..5c79cbf 100644
> --- a/tests/TestSuite_l2fwd.py
> +++ b/tests/TestSuite_l2fwd.py
> @@ -83,7 +83,7 @@ class TestL2fwd(TestCase):
>          self.headers_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + \
>              HEADER_SIZE['udp']
>  
> -        self.dut_ports = self.dut.get_ports_performance(self.nic)
> +        self.dut_ports = self.dut.get_ports_performance()
>  
>          self.verify(len(self.dut_ports) >= self.number_of_ports,
>                      "Not enough ports for " + self.nic)
> diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py
> index 0e7df85..1b2bf0d 100644
> --- a/tests/TestSuite_l3fwd.py
> +++ b/tests/TestSuite_l3fwd.py
> @@ -309,9 +309,9 @@ class TestL3fwd(TestCase):
>          L3fwd Prerequisites
>          """
>          # Based on h/w type, choose how many ports to use
> -        ports = self.dut.get_ports(self.nic, socket=1)
> +        ports = self.dut.get_ports(socket=1)
>          if not ports:
> -            ports = self.dut.get_ports(self.nic, socket=0)
> +            ports = self.dut.get_ports(socket=0)
>  
>          # Verify that enough ports are available
>          self.verify(len(ports) >= 2, "Insufficient ports for speed testing")
> @@ -473,7 +473,7 @@ class TestL3fwd(TestCase):
>          """
>  
>          # Based on h/w type, choose how many ports to use
> -        ports = self.dut.get_ports(self.nic)
> +        ports = self.dut.get_ports()
>          # Verify that enough ports are available
>          self.verify(len(ports) >= 4, "Insufficient ports for speed testing")
>  
> diff --git a/tests/TestSuite_link_flowctrl.py b/tests/TestSuite_link_flowctrl.py
> index 3c195c9..e52f95a 100644
> --- a/tests/TestSuite_link_flowctrl.py
> +++ b/tests/TestSuite_link_flowctrl.py
> @@ -64,7 +64,7 @@ class TestLinkFlowctrl(TestCase):
>          Link flow control Prerequisites
>          """
>  
> -        self.dutPorts = self.dut.get_ports(self.nic)
> +        self.dutPorts = self.dut.get_ports()
>          self.verify(len(self.dutPorts) > 1, "Insuficient ports")
>  
>          self.rx_port = self.dutPorts[0]
> diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
> index 2c8eeba..4ef5313 100644
> --- a/tests/TestSuite_multiprocess.py
> +++ b/tests/TestSuite_multiprocess.py
> @@ -191,7 +191,7 @@ class TestMultiprocess(TestCase, IxiaPacketGenerator):
>          """
>          self.dut.kill_all()
>          self.dut.send_expect("fg", "# ")
> -        dutPorts = self.dut.get_ports(self.nic)
> +        dutPorts = self.dut.get_ports()
>          txPort = self.tester.get_local_port(dutPorts[0])
>          rxPort = self.tester.get_local_port(dutPorts[1])
>          mac = self.tester.get_mac(txPort)
> diff --git a/tests/TestSuite_pmd.py b/tests/TestSuite_pmd.py
> index acd6364..a21977b 100644
> --- a/tests/TestSuite_pmd.py
> +++ b/tests/TestSuite_pmd.py
> @@ -104,7 +104,7 @@ class TestPmd(TestCase):
>                      "NIC Unsupported: " + str(self.nic))
>  
>          # Based on h/w type, choose how many ports to use
> -        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.dut_ports = self.dut.get_ports()
>  
>          # Verify that enough ports are available
>          self.verify(len(self.dut_ports) >= self.needed_ports[self.nic],
> @@ -162,7 +162,7 @@ class TestPmd(TestCase):
>                  queues = 1
>  
>              core_mask = dts.create_mask(core_list)
> -            port_mask = dts.create_mask(self.dut.get_ports(self.nic))
> +            port_mask = dts.create_mask(self.dut.get_ports())
>  
>              self.pmdout.start_testpmd("all", "--coremask=%s --rxq=%d --txq=%d --portmask=%s" % (core_mask, queues, queues, port_mask))
>  
> diff --git a/tests/TestSuite_pmd_bonded.py b/tests/TestSuite_pmd_bonded.py
> index e8e61dd..fd15c1d 100644
> --- a/tests/TestSuite_pmd_bonded.py
> +++ b/tests/TestSuite_pmd_bonded.py
> @@ -792,7 +792,7 @@ UDP(sport=srcport, dport=destport)/Raw(load="\x50"*%s)], iface="%s", count=%d)'
>          self.ip_head_size = 20
>          self.udp_header_size = 8
>  
> -        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.dut_ports = self.dut.get_ports()
>  
>          self.port_mask = dts.create_mask(self.dut_ports)
>  
> diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
> index e9813f3..66dc4f3 100644
> --- a/tests/TestSuite_vlan.py
> +++ b/tests/TestSuite_vlan.py
> @@ -53,12 +53,11 @@ class TestVlan(TestCase):
>          """
>  
>          # Based on h/w type, choose how many ports to use
> -        ports = self.dut.get_ports(self.nic)
> +        ports = self.dut.get_ports()
>  
>          # Verify that enough ports are available
>          self.verify(len(ports) >= 2, "Insufficient ports")
>  
> -        ports = self.dut.get_ports(self.nic)
>          global valports
>          valports = [_ for _ in ports if self.tester.get_local_port(_) != -1]
>  
> diff --git a/tests/TestSuite_whitelist.py b/tests/TestSuite_whitelist.py
> index a32251d..aedae40 100644
> --- a/tests/TestSuite_whitelist.py
> +++ b/tests/TestSuite_whitelist.py
> @@ -55,7 +55,7 @@ class TestWhitelist(TestCase):
>          self.frames_to_send = 1
>  
>          # Based on h/w type, choose how many ports to use
> -        self.dutPorts = self.dut.get_ports(self.nic)
> +        self.dutPorts = self.dut.get_ports()
>  
>          # Verify that enough ports are available
>          self.verify(len(self.dutPorts) >= 1, "Insufficient ports")
Acked-by: Michael Qiu <michael.qiu@intel.com>

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

* Re: [dts] [PATCH 2/4] framework: execuction file support port config nic_type
  2015-01-23  8:26 ` [dts] [PATCH 2/4] framework: execuction file support port config nic_type Marvin Liu
@ 2015-02-04  3:57   ` Qiu, Michael
  0 siblings, 0 replies; 11+ messages in thread
From: Qiu, Michael @ 2015-02-04  3:57 UTC (permalink / raw)
  To: Liu, Yong, dts

On 1/23/2015 4:27 PM, Marvin Liu wrote:
> From: Yong Liu <yong.liu@intel.com>
>
> DTS support new function that get linux driver with pci device id.
> DTS sample execution configuration support configured DUT port.
> One execution section support only one DUT.
>
> Signed-off-by: Marvinliu <yong.liu@intel.com>
> ---
>  execution.cfg    |  2 +-
>  framework/dts.py | 62 +++++++++++++++++++++++++++++++++-----------------------
>  2 files changed, 38 insertions(+), 26 deletions(-)
>
> diff --git a/execution.cfg b/execution.cfg
> index 18781ee..a67d7b3 100644
> --- a/execution.cfg
> +++ b/execution.cfg
> @@ -19,7 +19,7 @@ test_suites=
>      pmd_bonded
>  targets=
>      x86_64-native-linuxapp-gcc
> -parameters=nic_type=niantic:func=true
> +parameters=nic_type=cfg:func=true
>  
>  [Execution2]
>  crbs=<Performance CRB IP Address>
> diff --git a/framework/dts.py b/framework/dts.py
> index 712ed54..9ba23fe 100644
> --- a/framework/dts.py
> +++ b/framework/dts.py
> @@ -42,7 +42,7 @@ import rst          # rst file support
>  from crbs import crbs
>  from tester import Tester
>  from dut import Dut
> -from settings import NICS
> +from settings import NICS, DRIVERS
>  from serializer import Serializer
>  from exception import VerifyFailure
>  from test_case import TestCase
> @@ -131,6 +131,18 @@ def close_crb_sessions():
>      log_handler.info("DTF ended")
>  
>  
> +def get_nic_driver(pci_id):
> +    """
> +    Return linux driver for specified pci device
> +    """
> +    driverlist = dict(zip(NICS.values(), DRIVERS.keys()))
> +    try:
> +        driver = DRIVERS[driverlist[pci_id]]
> +    except Exception as e:
> +        driver = None
> +    return driver
> +
> +
>  def accepted_nic(pci_id):
>      """
>      Return True if the pci_id is a known NIC card in the settings file and if
> @@ -201,7 +213,7 @@ def dts_parse_config(section):
>  
>      nics = [_.strip() for _ in paramDict['nic_type'].split(',')]
>  
> -    return duts, targets, test_suites, nics
> +    return duts[0], targets, test_suites, nics
>  
>  
>  def get_project_obj(project_name, super_class, crbInst, serializer):
> @@ -255,7 +267,7 @@ def dts_log_execution(log_handler):
>          pass
>  
>  
> -def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir):
> +def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics):
>      """
>      Create dts dut/tester instance and initialize them.
>      """
> @@ -270,6 +282,7 @@ def dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir):
>      tester.dut = dut
>      dut.set_speedup_options(read_cache, skip_setup)
>      dut.set_directory(base_dir)
> +    dut.set_nic_types(nics)
>      tester.set_speedup_options(read_cache, skip_setup)
>      show_speedup_options_messages(read_cache, skip_setup)
>      dut.set_test_types(func_tests=functional_only, perf_tests=performance_only)
> @@ -426,36 +439,35 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
>          dts_parse_param(section)
>  
>          # verify if the delimiter is good if the lists are vertical
> -        duts, targets, test_suites, nics = dts_parse_config(section)
> +        dutIP, targets, test_suites, nics = dts_parse_config(section)
>  
> -        for dutIP in duts:
> -            log_handler.info("\nDUT " + dutIP)
> +        log_handler.info("\nDUT " + dutIP)
>  
> -            # look up in crbs - to find the matching IP
> -            crbInst = None
> -            for crb in crbs:
> -                if crb['IP'] == dutIP:
> -                    crbInst = crb
> -                    break
> +        # look up in crbs - to find the matching IP
> +        crbInst = None
> +        for crb in crbs:
> +            if crb['IP'] == dutIP:
> +                crbInst = crb
> +                break
>  
> -            # only run on the dut in known crbs
> -            if crbInst is None:
> -                log_handler.error(" SKIP UNKNOWN CRB")
> -                continue
> +        # only run on the dut in known crbs
> +        if crbInst is None:
> +            log_handler.error(" SKIP UNKNOWN CRB")
> +            continue
>  
> -            result.dut = dutIP
> +        result.dut = dutIP
>  
> -            # init dut, tester crb
> -            dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir)
> +        # init dut, tester crb
> +        dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics)
>  
> -            # Run DUT prerequisites
> -            if dts_run_prerequisties(pkgName, patch) is False:
> -                dts_crbs_exit()
> -                continue
> +        # Run DUT prerequisites
> +        if dts_run_prerequisties(pkgName, patch) is False:
> +            dts_crbs_exit()
> +            continue
>  
> -            dts_run_target(crbInst, targets, test_suites, nics)
> +        dts_run_target(crbInst, targets, test_suites, nics)
>  
> -            dts_crbs_exit()
> +        dts_crbs_exit()
>  
>      save_all_results()
>  
Acked-by: Michael Qiu <michael.qiu@intel.com>

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

* Re: [dts] [PATCH 1/4] framework: add new module for load port configuration file
  2015-02-04  3:26   ` Qiu, Michael
@ 2015-02-04  4:51     ` Liu, Yong
  0 siblings, 0 replies; 11+ messages in thread
From: Liu, Yong @ 2015-02-04  4:51 UTC (permalink / raw)
  To: Qiu, Michael, dts

These codes were just sample code for config module and their purpose is just to show how to use this module.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Wednesday, February 04, 2015 11:26 AM
> To: Liu, Yong; dts@dpdk.org
> Subject: Re: [dts] [PATCH 1/4] framework: add new module for load port
> configuration file
> 
> On 1/23/2015 4:27 PM, Marvin Liu wrote:
> > From: Yong Liu <yong.liu@intel.com>
> >
> > Config module will load port configuration and parse port parameter.
> > Port configuration will be used in the process of setting up DUT.
> > User can assign port mac, numa or tester peer pci address of DUT port.
> >
> > Signed-off-by: Marvinliu <yong.liu@intel.com>
> > ---
> >  conf/ports.cfg      |  4 +++
> >  framework/config.py | 93
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 97 insertions(+)
> >  create mode 100644 conf/ports.cfg
> >  create mode 100755 framework/config.py
> >
> > diff --git a/conf/ports.cfg b/conf/ports.cfg
> > new file mode 100644
> > index 0000000..85c1998
> > --- /dev/null
> > +++ b/conf/ports.cfg
> > @@ -0,0 +1,4 @@
> > +[10.239.128.117]
> > +ports=
> > +    pci=86:00.0,intf=p4p1;
> > +    pci=86:00.1,mac=90:e2:ba:39:b7:69,peer=05:00.1,numa=0
> > diff --git a/framework/config.py b/framework/config.py
> > new file mode 100755
> > index 0000000..140c84b
> > --- /dev/null
> > +++ b/framework/config.py
> > @@ -0,0 +1,93 @@
> > +# BSD LICENSE
> > +#
> > +# Copyright(c) 2010-2014 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.
> > +
> > +"""
> > +Generic port and crbs configuration file load function
> > +"""
> > +
> > +import ConfigParser  # config parse module
> > +import argparse      # prase arguments module
> > +
> > +portconf = "../conf/ports.cfg"
> > +crbconf = "../conf/crbs.cfg"
> > +
> > +
> > +class UserConf():
> > +
> > +    def __init__(self, port_conf=portconf, crb_conf=crbconf):
> > +        self.port_config = port_conf
> > +        self.crb_config = crb_conf
> > +        self.ports_cfg = {}
> > +        try:
> > +            self.port_conf = ConfigParser.SafeConfigParser()
> > +            self.port_conf.read(self.port_config)
> > +        except Exception as e:
> > +            print "FAILED LOADING PORT CONFIG!!!"
> > +
> > +    def load_ports_config(self, crbIP):
> > +        ports = []
> > +        for crb in self.port_conf.sections():
> > +            if crb != crbIP:
> > +                continue
> > +            ports = [port.strip()
> > +                     for port in self.port_conf.get(crb,
> 'ports').split(';')]
> > +
> > +        for port in ports:
> > +            port_cfg = self.parse_port_param(port)
> > +            if 'pci' not in port_cfg:
> > +                print "INVALID CONFIG FOR NO PCI ADDRESS!!!"
> 
> Would you think this port is valid for this error?
> 
> > +            keys = port_cfg.keys()
> > +            keys.remove('pci')
> > +            self.ports_cfg[port_cfg['pci']] = {key: port_cfg[key] for
> key in keys}
> > +
> > +    def check_port_available(self, pci_addr):
> > +        if pci_addr in self.ports_cfg.keys():
> > +            return True
> > +        else:
> > +            return False
> > +
> > +    def parse_port_param(self, port):
> > +        portDict = dict()
> > +
> > +        for param in port.split(','):
> > +            (key, _, value) = param.partition('=')
> > +            portDict[key] = value
> > +        return portDict
> > +
> > +
> > +if __name__ == '__main__':
> > +    parser = argparse.ArgumentParser(description="Load DTS
> configuration files")
> > +    parser.add_argument("-p", "--portconf", default=portconf)
> > +    parser.add_argument("-c", "--crbconf", default=crbconf)
> > +    args = parser.parse_args()
> > +    conf = UserConf()
> > +    conf.load_ports_config('10.239.128.120')
> > +    conf.check_port_available('0000:86:00.0')
> 
> Why here show ip and PCI address?
> 
> All those could inside cfg file, and parse it here, cfg file can be user
> defined, but the script should not be changed for different config.
> 
> Thanks,
> Michael

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

* Re: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence
  2015-02-04  3:56   ` Qiu, Michael
@ 2015-02-04  5:24     ` Liu, Yong
  0 siblings, 0 replies; 11+ messages in thread
From: Liu, Yong @ 2015-02-04  5:24 UTC (permalink / raw)
  To: Qiu, Michael, dts

Michael, thanks for your comments.

> -----Original Message-----
> From: Qiu, Michael
> Sent: Wednesday, February 04, 2015 11:56 AM
> To: Liu, Yong; dts@dpdk.org
> Subject: Re: [dts] [PATCH 3/4] framework: reorganize DUT and Tester port
> initialize sequence
> 
> On 1/23/2015 4:27 PM, Marvin Liu wrote:
> > From: Yong Liu <yong.liu@intel.com>
> >
> > DUT port initialization sequence: scan,restore,rescan,load config
> > Test port initialization sequence: modprobe, interface up
> > Separate restore interface function from DUT and Tester.
> >
> > Signed-off-by: Marvinliu <yong.liu@intel.com>
> > ---
> >  framework/crb.py          |  53 ++++----------
> >  framework/dut.py          | 181 +++++++++++++++++++++++++++++++++++----
> -------
> >  framework/project_dpdk.py |  22 ++----
> >  framework/tester.py       |  30 ++++++++
> >  4 files changed, 190 insertions(+), 96 deletions(-)
> >
> 
> [...]
> 
> > @@ -494,3 +531,61 @@ class Dut(Crb):
> >              # store the port info to port mapping
> >              self.ports_info.append({'pci': pci_str, 'type': pci_id,
> 'intf':
> >                                      intf, 'mac': macaddr, 'ipv6': ipv6,
> 'numa': -1})
> > +
> > +    def restore_interfaces(self):
> > +        """
> > +        Restore Linux interfaces.
> > +        """
> > +        for port in self.ports_info:
> > +            pci_bus = port['pci']
> > +            pci_id = port['type']
> > +            # get device driver
> > +            driver = dts.get_nic_driver(pci_id)
> > +            if driver is not None:
> > +                # unbind device driver
> > +                addr_array = pci_bus.split(':')
> > +                bus_id = addr_array[0]
> > +                devfun_id = addr_array[1]
> > +
> > +                self.send_expect('echo 0000:%s >
> /sys/bus/pci/devices/0000\:%s\:%s/driver/unbind'
> 
> Here  if this devices has no driver binded, will failed, but seems no
> affect for logic, but at least should give some log message I think.
> 
> Thanks,
> Michael

Michael, here is just our logic. If there's no driver available for this nic, DTS will keep it untouched and load config for it. 
It's better to add some message for remind user DTS will not restore this nic. 

> > +                                 % (pci_bus, 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'
> > +                                 % (pci_bus, driver), '# ')
> > +                itf = self.get_interface_name(addr_array[0],
> addr_array[1])
> > +                self.send_expect("ifconfig %s up" % itf, "# ")
> > +
> > +    def load_portconf(self):
> > +        """
> > +        Load port configurations for ports_info. If manually configured
> infor
> > +        not same as auto scanned, still use infor in configuration file.
> > +        """
> > +        for port in self.ports_info:
> > +            pci_bus = port['pci']
> > +            if pci_bus in self.conf.ports_cfg:
> > +                port_cfg = self.conf.ports_cfg[pci_bus]
> > +                port_cfg['source'] = 'cfg'
> > +            else:
> > +                port_cfg = {}
> > +
> > +            if 'intf' in port_cfg:
> > +                if 'intf' in port:
> > +                    if port_cfg['intf'] != port['intf']:
> > +                        self.logger.warning("CONFIGURED INTERFACE NOT
> SAME AS SCANNED!!!")
> > +                port['intf'] = port_cfg['intf']
> > +
> > +            if 'mac' in port_cfg:
> > +                if 'mac' in port:
> > +                    if port_cfg['mac'] != port['mac']:
> > +                        self.logger.warning("CONFIGURED MACADDRESS NOT
> SAME AS SCANNED!!!")
> > +                port['mac'] = port_cfg['mac']
> > +
> > +            if 'numa' in port_cfg:
> > +                if 'numa' in port:
> > +                    if port_cfg['numa'] != port['numa']:
> > +                        self.logger.warning("CONFIGURED NUMA NOT SAME
> AS SCANNED!!!")
> > +                port['numa'] = port_cfg['numa']
> > +
> > +            if 'numa' in port_cfg:
> > +                port['peer'] = port_cfg['peer']
> 
> Why "if 'numa' in port_cfg:" twice here?
> 
> Also it is almost the same for those:
> 
> if key in port_cfg:
> 
> So can we do a iteration here?Like below:
> 
> for key in port_cfg:
>     if key in port:
>         if port_cfg['intf'] != port['intf']:
>             self.logger.warning("CONFIGURED INTERFACE NOT SAME AS
> SCANNED!!!")
>         port[key] = port_cfg[key]
> 
> 
> Thanks,
> Michael
> 

Thanks for this catch, the second "numa" should be "peer".
Will implement one function replace of these duplicate codes.
 
> > diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
> > index 6e25f1f..13be836 100644
> > --- a/framework/project_dpdk.py
> > +++ b/framework/project_dpdk.py
> > @@ -234,13 +234,10 @@ class DPDKdut(Dut):
> >          binding_list = '--bind=%s ' % driver
> >
> >          current_nic = 0
> > -        for (pci_bus, pci_id) in self.pci_devices_info:
> > -            if dts.accepted_nic(pci_id):
> > -
> > -                if nics_to_bind is None or current_nic in nics_to_bind:
> > -                    binding_list += '%s ' % (pci_bus)
> > -
> > -                current_nic += 1
> > +        for port_info in self.ports_info:
> > +            if nics_to_bind is None or current_nic in nics_to_bind:
> > +                binding_list += '%s ' % (port_info['pci'])
> > +            current_nic += 1
> >
> >          self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '#
> ')
> >
> > @@ -252,13 +249,10 @@ class DPDKdut(Dut):
> >          binding_list = '-u '
> >
> >          current_nic = 0
> > -        for (pci_bus, pci_id) in self.pci_devices_info:
> > -            if dts.accepted_nic(pci_id):
> > -
> > -                if nics_to_bind is None or current_nic in nics_to_bind:
> > -                    binding_list += '%s ' % (pci_bus)
> > -
> > -                current_nic += 1
> > +        for port_info in self.ports_info:
> > +            if nics_to_bind is None or current_nic in nics_to_bind:
> > +                binding_list += '%s ' % (port_info['pci'])
> > +            current_nic += 1
> >
> >          self.send_expect('tools/dpdk_nic_bind.py %s' % binding_list, '#
> ', 30)
> >
> > diff --git a/framework/tester.py b/framework/tester.py
> > index 2c023dd..345ab41 100644
> > --- a/framework/tester.py
> > +++ b/framework/tester.py
> > @@ -170,6 +170,24 @@ class Tester(Crb):
> >          else:
> >              return 'down'
> >
> > +    def restore_interfaces(self):
> > +        """
> > +        Restore Linux interfaces.
> > +        """
> > +        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(':')
> > +                itf = self.get_interface_name(addr_array[0],
> addr_array[1])
> > +                self.send_expect("ifconfig %s up" % itf, "# ")
> > +
> > +        except Exception as e:
> > +            self.logger.error("   !!! Restore ITF: " + e.message)
> > +
> >      def scan_ports(self):
> >          """
> >          Scan all ports on tester and save port's pci/mac/interface.
> > @@ -253,6 +271,18 @@ class Tester(Crb):
> >          hits = [False] * len(self.ports_info)
> >
> >          for dutPort in range(nrPorts):
> > +            peer = self.dut.get_peer_pci(dutPort)
> > +            if peer is not None:
> > +                for localPort in range(len(self.ports_info)):
> > +                    if self.ports_info[localPort]['pci'] == peer:
> > +                        hits[localPort] = True
> > +                        self.ports_map[dutPort] = localPort
> > +                        break
> > +                if self.ports_map[dutPort] == -1:
> > +                    self.logger.error("CONFIGURED TESTER PORT CANNOT
> FOUND!!!")
> > +                else:
> > +                    continue  # skip ping6 map
> > +
> >              for localPort in range(len(self.ports_info)):
> >                  if hits[localPort]:
> >                      continue

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

end of thread, other threads:[~2015-02-04  5:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  8:26 [dts] [PATCH 0/4] Support additional port configuration file Marvin Liu
2015-01-23  8:26 ` [dts] [PATCH 1/4] framework: add new module for load " Marvin Liu
2015-02-04  3:26   ` Qiu, Michael
2015-02-04  4:51     ` Liu, Yong
2015-01-23  8:26 ` [dts] [PATCH 2/4] framework: execuction file support port config nic_type Marvin Liu
2015-02-04  3:57   ` Qiu, Michael
2015-01-23  8:26 ` [dts] [PATCH 3/4] framework: reorganize DUT and Tester port initialize sequence Marvin Liu
2015-02-04  3:56   ` Qiu, Michael
2015-02-04  5:24     ` Liu, Yong
2015-01-23  8:26 ` [dts] [PATCH 4/4] suites: remove nic type check from testsuites Marvin Liu
2015-02-04  3:57   ` Qiu, Michael

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).