From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31A9FA0523; Tue, 30 Jun 2020 09:04:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 364371BEDE; Tue, 30 Jun 2020 09:04:38 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 7E36A1B13C for ; Tue, 30 Jun 2020 09:04:35 +0200 (CEST) IronPort-SDR: nxTxxm48FKDkZtNvydUeyVU0mIqFW4pQkh7LnaeRXaEKMZHoY1HrqikVgaS6g95CqtuvmBLW3M d18/Ud8taNvg== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="126289972" X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="126289972" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 00:04:30 -0700 IronPort-SDR: PFI0guEnrdm2q4NG/OcIOONluTm5HIu5ptGrIFkXQeFqoBMF1Qxzkvl3Wlevl7VYK1MYcyxC95 c9imq6QkwItA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="481076997" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.208]) by fmsmga005.fm.intel.com with ESMTP; 30 Jun 2020 00:04:28 -0700 From: yufengmx To: dts@dpdk.org, lijuan.tu@intel.com, yingyax.han@intel.com Cc: yufengmx Date: Tue, 30 Jun 2020 15:04:09 +0800 Message-Id: <20200630070409.27542-8-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200630070409.27542-1-yufengx.mo@intel.com> References: <20200630070409.27542-1-yufengx.mo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V1 7/7] tests/l3fwd_base: change core/thread/queue definition X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" #. change core/thread/queue definition. #. limit the behavior to use one core to poll 2 queues of the same port when physical cores >= ports number. Signed-off-by: yufengmx --- tests/l3fwd_base.py | 79 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/tests/l3fwd_base.py b/tests/l3fwd_base.py index 2b4934c..a6e26b0 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,56 @@ 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_core_list(self, thread_num, cores, socket): + corelist = self.dut.get_core_list( + cores, socket if cores.startswith('1S') else -1) + corelist = corelist[self.__core_offset*thread_num:] + if '2T' in cores: + corelist = corelist[0::2] + corelist[1::2] + return corelist + + 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,12 +1023,10 @@ 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( - cores, socket if cores.startswith('1S') else -1) - corelist = corelist[self.__core_offset*thread_num:] + for item in product(range(ports), range(queues_per_port))] + corelist = self.__get_core_list(thread_num, cores, socket) cores_mask = utils.create_mask(corelist) total = len(grp) _corelist = (corelist * (total // len(corelist) + 1))[:total] @@ -986,7 +1038,7 @@ class L3fwdBase(object): test_item, cores_mask, ','.join(["({0},{1},{2})".format(port, queue, core) - for queue, port, core in grp]), + for port, queue, core in grp]), frame_size, ]) for frame_size in _frame_sizes] return configs, sorted(set(frame_sizes_grp)) @@ -1072,9 +1124,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