[dts] [PATCH v3 26/27] framework: Adding linkspeed parameter for Cavium NICs

Angela Czubak aczubak at caviumnetworks.com
Wed Apr 19 14:22:19 CEST 2017


If a user wants to use Cavium NICs with only one certain linkspeed,
this parameter mya be now specified in execution.cfg file (Cavium NICs
can be 10Gb/s or 40Gb/s) by typing "linkspeed=<linkspeed of the
NIC>Mb/s", for instance "linkspeed=10000Mb/s". This parameter is
optional, if skipped, DTS does try to use every Cavium NIC whose
linkspeed could be read.

Signed-off-by: Angela Czubak <aczubak at caviumnetworks.com>
---
 doc/dts_gsg/config.rst | 4 ++++
 framework/crb.py       | 7 ++++---
 framework/dts.py       | 5 +++++
 framework/settings.py  | 1 +
 framework/test_case.py | 7 +++++--
 5 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/doc/dts_gsg/config.rst b/doc/dts_gsg/config.rst
index abd8da7..4700421 100644
--- a/doc/dts_gsg/config.rst
+++ b/doc/dts_gsg/config.rst
@@ -181,6 +181,10 @@ First of all, you must create a file named execution.cfg as below.
 
     – perf=true run only performance test
 
+Cavium NICs may use optional parameter named linkspeed, the format is as follows: "linkspeed=<Link Speed of NIC>Mb/s"
+(for instance, "linkspeed=40000Mb/s" for 40Gb/s).
+It may be skipped if the user does not want to bind only to NICs with that specific speed.
+
 Then please add the detail information about your CRB in **conf/crbs.conf** as follows:
 
 .. code-block:: console
diff --git a/framework/crb.py b/framework/crb.py
index 63c8093..afc30ed 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -32,7 +32,7 @@
 import time
 import re
 import os
-from settings import TIMEOUT, IXIA
+from settings import TIMEOUT, IXIA, HOST_NIC_LINKSPEED, load_global_setting
 from ssh_connection import SSHConnection
 from logger import getLogger
 
@@ -270,9 +270,10 @@ class Crb(object):
         for i in range(len(match)):
             #check if device is cavium and check its linkspeed, append only if it is 10G
             if "177d:" in match[i][1]:
-                linkspeed = "10000"
+                linkspeed = load_global_setting(HOST_NIC_LINKSPEED)
                 nic_linkspeed = self.send_command("cat /sys/bus/pci/devices/%s/net/*/speed" % match[i][0])
-                if nic_linkspeed == linkspeed:
+		# if a user wants to bind NICs with a certain linkspeed (and checking linkspeed does not end in an error)
+                if (linkspeed == "0" and "cat" not in nic_linkspeed) or nic_linkspeed == linkspeed:
                     self.pci_devices_info.append((match[i][0], match[i][1]))
             else:
                 self.pci_devices_info.append((match[i][0], match[i][1]))
diff --git a/framework/dts.py b/framework/dts.py
index 369599d..d2e5c24 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -80,8 +80,13 @@ def dts_parse_param(config, section):
     # Set parameters
     parameters = config.get(section, 'parameters').split(':')
     drivername = config.get(section, 'drivername').split('=')[-1]
+    if config.has_option(section, 'linkspeed'):
+    	linkspeed = config.get(section, 'linkspeed').split('=')[-1]
+    	linkspeed = re.sub('[^0-9]+',"",linkspeed) # change '+' to '*'? so that empty is good as well
+    else: linkspeed = '0' # default
 
     settings.save_global_setting(settings.HOST_DRIVER_SETTING, drivername)
+    settings.save_global_setting(settings.HOST_NIC_LINKSPEED, linkspeed)
 
     paramDict = dict()
     for param in parameters:
diff --git a/framework/settings.py b/framework/settings.py
index 342314d..aae03a5 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -205,6 +205,7 @@ PERF_SETTING = "DTS_PERF_ONLY"
 FUNC_SETTING = "DTS_FUNC_ONLY"
 HOST_DRIVER_SETTING = "DTS_HOST_DRIVER"
 HOST_NIC_SETTING = "DTS_HOST_NIC"
+HOST_NIC_LINKSPEED = "DTS_HOST_NIC_LINKSPEED"
 DEBUG_SETTING = "DTS_DEBUG_ENABLE"
 DEBUG_CASE_SETTING = "DTS_DEBUGCASE_ENABLE"
 DPDK_RXMODE_SETTING = "DTS_DPDK_RXMODE"
diff --git a/framework/test_case.py b/framework/test_case.py
index d97d898..2ab1d68 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -38,7 +38,7 @@ import traceback
 import signal
 
 from exception import VerifyFailure, TimeoutException
-from settings import DRIVERS, NICS, get_nic_name, load_global_setting
+from settings import DRIVERS, NICS, get_nic_name, load_global_setting, HOST_NIC_LINKSPEED
 from settings import PERF_SETTING, FUNC_SETTING, DEBUG_SETTING, DEBUG_CASE_SETTING, HOST_DRIVER_SETTING
 from rst import RstReport
 from test_result import ResultTable, Result
@@ -366,6 +366,9 @@ class TestCase(object):
         elif nic == 'redrockcanyou':
             bitrate *= 40
         elif driver == 'thunder-nicvf':
-            bitrate *= 10
+	    if load_global_setting(HOST_NIC_LINKSPEED) == "40000":
+            	bitrate *= 40
+	    else:
+            	bitrate *= 10 # assuming it is 10 Gb
 
         return bitrate * num_ports / 8 / (frame_size + 20)
-- 
2.7.4



More information about the dts mailing list