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 04275A0613 for ; Fri, 27 Sep 2019 10:48:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EFECC3195; Fri, 27 Sep 2019 10:48:55 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 1B8AB2C4F for ; Fri, 27 Sep 2019 10:48:53 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2019 01:48:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,554,1559545200"; d="scan'208";a="219706383" Received: from unknown (HELO dpdk-meijianwei-tester.sh.intel.com) ([10.240.179.33]) by fmsmga002.fm.intel.com with ESMTP; 27 Sep 2019 01:48:52 -0700 From: Jianwei Mei To: dts@dpdk.org Cc: zhaoyan.chen@intel.com, lihongx.ma@intel.com, meijx Date: Sat, 28 Sep 2019 01:34:56 +0800 Message-Id: <1569605698-316544-4-git-send-email-jianweix.mei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569605698-316544-1-git-send-email-jianweix.mei@intel.com> References: <1569605698-316544-1-git-send-email-jianweix.mei@intel.com> Subject: [dts] [PATCH V1 4/6] framework/dut.py: add function create_eal_parameters 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" From: meijx add new method to create EAL parameters and overwrite self.cores according to configured dut_cores. Signed-off-by: meijx --- framework/dut.py | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/framework/dut.py b/framework/dut.py index a394b34..b30506f 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -75,6 +75,160 @@ class Dut(Crb): self.virt_pool = None # hypervisor pid list, used for cleanup self.virt_pids = [] + self.prefix_subfix = str(os.getpid()) + '_' + time.strftime("%Y%m%d%H%M%S", time.localtime()) + self.prefix_list = [] + + def filter_cores_from_crb_cfg(self): + # get core list from crbs.cfg + core_list = [] + all_core_list = [str(core['core']) for core in self.cores] + core_list_str = self.crb['dut_cores'] + if core_list_str == '': + core_list = all_core_list + split_by_comma = core_list_str.split(',') + range_cores = [] + for item in split_by_comma: + if '-' in item: + tmp = item.split('-') + range_cores.extend([str(i) for i in range(int(tmp[0]), int(tmp[1]) + 1)]) + else: + core_list.append(item) + core_list.extend(range_cores) + + abnormal_core_list = [] + for core in core_list: + if core not in all_core_list: + abnormal_core_list.append(core) + + if abnormal_core_list: + self.logger.info('those %s cores are out of range system, all core list of system are %s' % (abnormal_core_list, all_core_list)) + raise Exception('configured cores out of range system') + + core_list = [core for core in self.cores if str(core['core']) in core_list] + self.cores = core_list + self.number_of_cores = len(self.cores) + + def create_eal_parameters(self, fixed_prefix=False, socket=-1, **config): + """ + generate eal parameters character string + :param config: + :return: eal_str eg:'-c 0xf -w 0000:88:00.0 -w 0000:88:00.1 --file-prefix=dpdk_1112_20190809143420' + """ + default_cores = '1S/2C/1T' + blank = ' ' + os_type = self.get_os_type() + if config: + # deal with cores + if config.has_key('cores'): + if config['cores'] == '' or config['cores'] == 'Default': + core_list = self.get_core_list(default_cores) + elif type(config['cores']) == list: + core_list = config['cores'] + else: + core_list = self.get_core_list(config['cores'], socket=socket) + else: + core_list = self.get_core_list(default_cores) + + # deal with ports + w_pci_list = [] + if config.has_key('ports') and len(config['ports']) != 0: + for port in config['ports']: + if type(port) == int: + if config.has_key('port_options') and port in config['port_options'].keys(): + port_option = config['port_options'][port] + w_pci_list.append('-w %s,%s' % (self.ports_info[port]['pci'], port_option)) + else: + w_pci_list.append('-w %s' % self.ports_info[port]['pci']) + else: + if config.has_key('port_options') and port in config['port_options'].keys(): + port_option = config['port_options'][port] + w_pci_list.append('-w %s,%s' % (self.ports_info[config['ports'].index(port)]['pci'], port_option)) + else: + w_pci_list = ['-w %s' % pci for pci in config['ports']] + w_pci_str = ' '.join(w_pci_list) + + # deal with black ports + b_pci_list = [] + if config.has_key('b_ports') and len(config['b_ports']) != 0: + for port in config['b_ports']: + if type(port) == int: + b_pci_list.append('-b %s' % self.ports_info[port]['pci']) + else: + b_pci_list = ['-b %s' % pci for pci in config['b_ports']] + b_ports_str = ' '.join(b_pci_list) + + # deal with no-pci + if config.has_key('no_pci'): + if config['no_pci'] == True: + no_pci = '--no-pci' + else: + no_pci = '' + else: + no_pci = '' + + # deal with file prefix + if config.has_key('prefix') and config['prefix'] != '': + if fixed_prefix == True: + file_prefix = config['prefix'] + else: + file_prefix = config['prefix'] + '_' + self.prefix_subfix + else: + file_prefix = 'dpdk' + '_' + self.prefix_subfix + self.prefix_list.append(file_prefix) + + # deal with vdev + if config.has_key('vdevs') and len(config['vdevs']) != 0: + vdev = '--vdev ' + ' --vdev '.join(config['vdevs']) + else: + vdev = '' + + if os_type == 'freebsd': + eal_str = '-l ' + ','.join(map(str, core_list)) \ + + blank + '-n %d' % self.get_memory_channels() \ + + blank + w_pci_str \ + + blank + b_ports_str \ + + blank + no_pci \ + + blank + vdev + else: + eal_str = '-l ' + ','.join(map(str, core_list)) \ + + blank + '-n %d' % self.get_memory_channels() \ + + blank + w_pci_str \ + + blank + b_ports_str \ + + blank + '--file-prefix=' + file_prefix \ + + blank + no_pci \ + + blank + vdev + else: + # get pci from ports_info + pci_list = [] + if len(self.ports_info) != 0: + for port_info in self.ports_info: + pci_list.append('-w %s' % port_info['pci']) + self.logger.info(pci_list) + pci_str = ' '.join(pci_list) + # default cores '1S/2C/1T' + core_list = self.get_core_list(default_cores) + file_prefix = 'dpdk' + '_' + self.prefix_subfix + self.prefix_list.append(file_prefix) + if os_type == 'freebsd': + eal_str = '-l ' + ','.join(map(str, core_list)) \ + + blank + '-n %d' % self.get_memory_channels() \ + + blank + pci_str + else: + eal_str = '-l ' + ','.join(map(str, core_list)) \ + + blank + '-n %d' % self.get_memory_channels() \ + + blank + pci_str \ + + blank + '--file-prefix=' + file_prefix + + return eal_str + + def get_eal_of_prefix(self, prefix=None): + + if prefix: + file_prefix = [prefix_name for prefix_name in self.prefix_list if prefix in prefix_name] + else: + file_prefix = 'dpdk' + '_' + self.prefix_subfix + + return file_prefix def init_host_session(self, vm_name): """ @@ -199,6 +353,7 @@ class Dut(Crb): self.send_expect('alias sed=gsed', '# ') self.init_core_list() + self.filter_cores_from_crb_cfg() self.pci_devices_information() # make sure ipv6 enable before scan self.enable_tester_ipv6() -- 1.8.3.1