test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org, lijuan.tu@intel.com
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 7/7] tests/l3fwd_base: change core/thread/queue definition
Date: Wed, 17 Jun 2020 16:36:59 +0800	[thread overview]
Message-ID: <20200617083659.4719-8-yufengx.mo@intel.com> (raw)
In-Reply-To: <20200617083659.4719-1-yufengx.mo@intel.com>


change core/thread/queue definition.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 tests/l3fwd_base.py | 63 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 7 deletions(-)

diff --git a/tests/l3fwd_base.py b/tests/l3fwd_base.py
index 2b4934c..e210201 100644
--- a/tests/l3fwd_base.py
+++ b/tests/l3fwd_base.py
@@ -33,6 +33,7 @@
 Layer-3 forwarding test script base class.
 """
 import os
+import re
 import time
 import traceback
 import texttable
@@ -172,6 +173,19 @@ class L3fwdBase(object):
         self.verify(total > 0, 'cpu socket should not be zero')
         return total
 
+    @property
+    def __core_thread_num(self):
+        cpu_topos = self.dut.get_all_cores()
+        core_index = cpu_topos[-1]['core']
+        thread_index = int(cpu_topos[-1]['thread'])
+        if not core_index:
+            msg = 'wrong core index'
+            raise VerifyFailure(msg)
+        if not thread_index:
+            msg = 'wrong thread index'
+            raise VerifyFailure(msg)
+        return thread_index//core_index
+
     def __pmd_con(self, cmd):
         if not self.__pmd_session:
             return
@@ -675,7 +689,8 @@ class L3fwdBase(object):
         # It is aimed to make sure packet generator detect link up status.
         wait_time = self.__l3fwd_wait_up if self.__l3fwd_wait_up else \
                     2 * len(self.__valports)
-        self.logger.debug(f"wait {wait_time} seconds for port link up")
+        self.logger.debug(
+            f"wait {wait_time} seconds for port link up")
         time.sleep(wait_time)
 
     def __l3fwd_restart_check(self, command_line):
@@ -950,17 +965,48 @@ class L3fwdBase(object):
         if except_content:
             raise VerifyFailure(except_content)
 
-    def __parse_port_config(self, config):
-        cores, total_threads, queue = config.split('/')
+    def __parse_port_config(self, config, cores_for_all):
+        '''
+        [n]C/[mT]-[i]Q
+        
+            n: how many physical core use for polling.
+            m: how many cpu thread use for polling, if Hyper-threading disabled
+                in BIOS, m equals n, if enabled, m is 2 times as n.
+            i: how many queues use per port, so total queues = i x nb_port
+        '''
+        # old format
+        pat = '(.*)\/(.*)\/(.*)'
+        result1 = re.findall(pat, config)
+        # new format
+        pat = '(.*)\/(.*)-(.*)'
+        result2 = re.findall(pat, config)
+        result = result1 if result1 else result2
+        if not result:
+            msg = f"{config} is wrong format, please check"
+            raise VerifyFailure(msg)
+        cores, total_threads, queue = result[0]
         _thread_num = int(int(total_threads[:-1]) // int(cores[:-1]))
+        _thread_num = self.__core_thread_num \
+            if _thread_num > self.__core_thread_num else _thread_num
         _thread = str(_thread_num) + 'T'
-        _cores = str(self.__core_offset + int(cores[:-1]) * len(self.__valports)) + 'C'
+        multiple = 1 if cores_for_all else len(self.__valports)
+        _cores = str(self.__core_offset + int(cores[:-1]) * multiple) + 'C'
+        if len(self.__valports) == 1 and int(total_threads[:-1]) > int(queue[:-1]) * len(self.__valports):
+            msg = f"Invalid configuration: {config}, please check"
+            self.logger.warning(msg)
+        if int(total_threads[:-1]) not in [self.__core_thread_num * int(cores[:-1]), int(cores[:-1])]:
+            support_num = f"1 or {self.__core_thread_num}" \
+                if self.__core_thread_num > 1 else "1"
+            msg = (
+                f"Invalid configuration: {config}, "
+                f"threads should be {support_num} times of cores")
+            self.logger.warning(msg)
         # only use one socket
         cores_config = '/'.join(['1S', _cores, _thread])
         queues_per_port = int(queue[:-1])
         return cores_config, _thread_num, queues_per_port
 
-    def __get_test_configs(self, options, ports, socket):
+    def __get_test_configs(self, options, ports, socket, cores_for_all):
         if not options:
             msg = "'test_parameters' not set in suite configuration file"
             raise VerifyFailure(msg)
@@ -969,7 +1015,7 @@ class L3fwdBase(object):
         for test_item, frame_sizes in sorted(options.items()):
             _frame_sizes = [int(frame_size) for frame_size in frame_sizes]
             frame_sizes_grp.extend([int(item) for item in _frame_sizes])
-            cores, thread_num, queues_per_port = self.__parse_port_config(test_item)
+            cores, thread_num, queues_per_port = self.__parse_port_config(test_item, cores_for_all)
             grp = [list(item)
                    for item in product(range(queues_per_port), range(ports))]
             corelist = self.dut.get_core_list(
@@ -1072,9 +1118,12 @@ class L3fwdBase(object):
         self.__traffic_stop_wait_time = \
             test_content.get('traffic_stop_wait_time', 0)
         # parse port config of l3fwd suite
+        cores_for_all = test_content.get('cores_for_all', False)
         port_configs, frame_sizes = self.__get_test_configs(
             test_content.get('test_parameters'),
-            len(self.__valports), self.__socket)
+            len(self.__valports),
+            self.__socket,
+            cores_for_all)
         test_content['port_configs'] = port_configs
         test_content['frame_sizes'] = frame_sizes
         self.logger.debug(pformat(test_content))
-- 
2.21.0


  parent reply	other threads:[~2020-06-17  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  8:36 [dts] [PATCH V1 0/7] l3fwd: " yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 1/7] conf/l3fwd: " yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 2/7] conf/vf_l3fwd_kernelpf: " yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 3/7] conf/l3fwd_em: " yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 4/7] conf/l3fwd_lpm_ipv4_rfc2544: change core/thread/queue yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 5/7] conf/l3fwd_lpm_ipv4: change core/thread/queue definition yufengmx
2020-06-17  8:36 ` [dts] [PATCH V1 6/7] conf/l3fwd_lpm_ipv6: " yufengmx
2020-06-17  8:36 ` yufengmx [this message]
2020-06-18  2:16 ` [dts] [PATCH V1 0/7] l3fwd: " Mo, YufengX
2020-06-30  7:04 yufengmx
2020-06-30  7:04 ` [dts] [PATCH V1 7/7] tests/l3fwd_base: " yufengmx

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=20200617083659.4719-8-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    /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).