test suite reviews and discussions
 help / color / mirror / Atom feed
From: Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>
To: dts <dts@dpdk.org>
Subject: [dts] [PATCH v2 4/9] framework: enable connect X3 support
Date: Tue,  8 Mar 2016 15:36:42 +0530	[thread overview]
Message-ID: <1457431607-31596-5-git-send-email-gowrishankar.m@linux.vnet.ibm.com> (raw)
In-Reply-To: <1457431607-31596-1-git-send-email-gowrishankar.m@linux.vnet.ibm.com>

Connect X3 dual port adapter shares single pci device ID. This limits dts frame-
work to use both the ports for the tests. With this patch, a new attribute also
to refer second interface in such single pci port lookup is introduced. Added
supporting APIs to derive this second interface and its MAC addresses whereever
needed.

Signed-off-by: Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>
---
 framework/dut.py      |   33 +++++++++++++++++++++++++--------
 framework/settings.py |    2 ++
 framework/tester.py   |   26 ++++++++++++++++++++++++++
 nics/net_device.py    |   27 +++++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 8 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index ff40fac..bcfedb6 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -569,15 +569,12 @@ class Dut(Crb):
 
         for port_info in self.ports_info:
             port = port_info['port']
-            intf = port.get_interface_name()
-            if "No such file" in intf:
-                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
-                continue
+            intf = port_info['intf']
             out = self.send_expect("ip link show %s" % intf, "# ")
             if "DOWN" in out:
                 self.send_expect("ip link set %s up" % intf, "# ")
                 time.sleep(5)
-            macaddr = port.get_mac_addr()
+            macaddr = port_info['mac']
             out = self.send_expect("ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'"
                                    % intf, "# ")
             ipv6 = out.split('/')[0]
@@ -585,8 +582,6 @@ class Dut(Crb):
             if ":" not in ipv6:
                 ipv6 = "Not connected"
 
-            port_info['mac'] = macaddr
-            port_info['intf'] = intf
             port_info['ipv6'] = ipv6
 
     def rescan_ports_uncached_freebsd(self):
@@ -689,10 +684,32 @@ class Dut(Crb):
             devfun_id = addr_array[2]
 
             port = GetNicObj(self, domain_id, bus_id, devfun_id)
+            intf = port.get_interface_name()
+            if "No such file" in intf:
+                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
+                continue
+
+            macaddr = port.get_mac_addr()
+            if "No such file" in intf:
+                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
+                continue
+
+            numa = port.socket
+            # store the port info to port mapping
+            self.ports_info.append(
+                {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa,
+                 'intf': intf, 'mac': macaddr})
+
+            if not port.get_interface2_name():
+                continue
+
+            intf = port.get_interface2_name()
+            macaddr = port.get_intf2_mac_addr()
             numa = port.socket
             # store the port info to port mapping
             self.ports_info.append(
-                {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa})
+                {'port': port, 'pci': pci_bus, 'type': pci_id, 'numa': numa,
+                 'intf': intf, 'mac': macaddr})
 
     def scan_ports_uncached_freebsd(self):
         """
diff --git a/framework/settings.py b/framework/settings.py
index 068afce..f3e3b9a 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -78,6 +78,7 @@ NICS = {
     'fortpark':'8086:374c',
     'fvl10g_vf':'8086:154c',
     'atwood': '8086:15d5',
+    'ConnectX3':'15b3:1003',
     'ConnectX4':'15b3:1013',
     'boulderrapid': '8086:15d0',
 }
@@ -114,6 +115,7 @@ DRIVERS = {
     'fortpark':'i40e',
     'fvl10g_vf':'i40evf',
     'atwood': 'fm10k',
+    'ConnectX3':'mlx4_core',
     'ConnectX4':'mlx5_core',
     'boulderrapid': 'fm10k',
 }
diff --git a/framework/tester.py b/framework/tester.py
index 1d69355..76ceeb4 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -207,6 +207,10 @@ class Tester(Crb):
                 itf = port.get_interface_name()
                 self.enable_ipv6(itf)
                 self.send_expect("ifconfig %s up" % itf, "# ")
+                if port.get_interface2_name():
+                    itf = port.get_interface2_name()
+                    self.enable_ipv6(itf)
+                    self.send_expect("ifconfig %s up" % itf, "# ")
 
         except Exception as e:
             self.logger.error("   !!! Restore ITF: " + e.message)
@@ -220,6 +224,9 @@ class Tester(Crb):
                 port = GetNicObj(self, addr_array[0], addr_array[1], addr_array[2])
                 itf = port.get_interface_name()
                 self.enable_promisc(itf)
+                if port.get_interface2_name():
+                    itf = port.get_interface2_name()
+                    self.enable_promisc(itf)
         except Exception as e:
             pass
 
@@ -314,6 +321,25 @@ class Tester(Crb):
                                     'mac': macaddr,
                                     'ipv6': ipv6})
 
+            # return if port is not connect x3
+            if not port.get_interface2_name():
+                continue
+
+            intf = port.get_interface2_name()
+
+            self.logger.info("Tester: [%s %s] %s" % (pci_bus, pci_id, intf))
+            macaddr = port.get_intf2_mac_addr()
+
+            ipv6 = port.get_ipv6_addr()
+
+            # store the port info to port mapping
+            self.ports_info.append({'port': port,
+                                    'pci': pci_bus,
+                                    'type': pci_id,
+                                    'intf': intf,
+                                    'mac': macaddr,
+                                    'ipv6': ipv6})
+
     def send_ping6(self, localPort, ipv6, mac):
         """
         Send ping6 packet from local port with destination ipv6 address.
diff --git a/nics/net_device.py b/nics/net_device.py
index a9127cb..941be99 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -150,9 +150,21 @@ class NetDevice(object):
             self.intf_name = 'N/A'
         else:
             self.intf_name = out
+            self.intf2_name = None
+
+        # not a complete fix for CX3.
+        if len(out.split()) > 1 and self.default_driver == 'mlx4_core':
+            self.intf_name = out.split()[0]
+            self.intf2_name = out.split()[1]
 
         return self.intf_name
 
+    def get_interface2_name(self):
+        """
+        Get interface name of second port of this pci device.
+        """
+        return self.intf2_name
+
     def get_interface_name_linux(self, domain_id, bus_id, devfun_id, driver):
         """
         Get interface name of specified pci device on linux.
@@ -242,6 +254,18 @@ class NetDevice(object):
         else:
             return out
 
+    @nic_has_driver
+    def get_intf2_mac_addr(self):
+        """
+        Get mac address of 2nd port of specified pci device.
+        """
+        get_mac_addr = getattr(self, 'get_mac_addr_%s' % self.__get_os_type())
+        out = get_mac_addr(self.get_interface2_name(), self.domain_id, self.bus_id, self.devfun_id, self.current_driver)
+        if "No such file or directory" in out:
+            return 'N/A'
+        else:
+            return out
+
     def get_mac_addr_linux(self, intf, domain_id, bus_id, devfun_id, driver):
         """
         Get mac address of specified pci device on linux.
@@ -733,6 +757,9 @@ class NetDevice(object):
         if driver == self.default_driver:
             itf = self.get_interface_name()
             self.__send_expect("ifconfig %s up" % itf, "# ")
+            if self.get_interface2_name():
+                itf = self.get_interface2_name()
+                self.__send_expect("ifconfig %s up" % itf, "# ")
 
     def bind_driver_linux_pci_stub(self, domain_id, bus_id, devfun_id):
         """
-- 
1.7.10.4

  parent reply	other threads:[~2016-03-08 10:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 10:06 [dts] framework v2: hugepages, cpuinfo, connect x3 support and bug fixes Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 1/9] framework: check hugepage size and add pages Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 2/9] framework: platform independent cpu info parsing Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 3/9] framework: include domain id in pci tuple Gowrishankar
2016-03-08 10:06 ` Gowrishankar [this message]
2016-03-08 10:06 ` [dts] [PATCH v2 5/9] framework: fix numa number lookup for a dev Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 6/9] framework: fix get_core_list to return all lcores Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 7/9] tests: fix multiprocess test to set coremask through library Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 8/9] tests: fix coremask test to check expected EAL output Gowrishankar
2016-03-08 10:06 ` [dts] [PATCH v2 9/9] tests: fix blacklist test to discard extra pci domain id in verification string Gowrishankar
2016-03-09  4:34 ` [dts] framework v2: hugepages, cpuinfo, connect x3 support and bug fixes Liu, Yong
2016-03-10  9:28   ` gowrishankar
2016-03-11  9:26     ` Liu, Yong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457431607-31596-5-git-send-email-gowrishankar.m@linux.vnet.ibm.com \
    --to=gowrishankar.m@linux.vnet.ibm.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).