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 0D1AEA2F6B for ; Tue, 8 Oct 2019 04:22:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 035BF1BFF8; Tue, 8 Oct 2019 04:22:37 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 2D8761BF8C for ; Tue, 8 Oct 2019 04:22:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2019 19:22:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,269,1566889200"; d="scan'208";a="205266476" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 07 Oct 2019 19:22:34 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 7 Oct 2019 19:22:33 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX152.ccr.corp.intel.com ([10.239.6.52]) with mapi id 14.03.0439.000; Tue, 8 Oct 2019 10:22:27 +0800 From: "Chen, Zhaoyan" To: "Mei, JianweiX" , "dts@dpdk.org" CC: "Ma, LihongX" , "Chen, Zhaoyan" Thread-Topic: [dts][PATCH V1 4/6] framework/dut.py: add function create_eal_parameters Thread-Index: AQHVdRBllcay37kzQ0epdEc7YRqG/qdQFE+g Date: Tue, 8 Oct 2019 02:22:27 +0000 Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41DD7392@SHSMSX104.ccr.corp.intel.com> References: <1569605698-316544-1-git-send-email-jianweix.mei@intel.com> <1569605698-316544-4-git-send-email-jianweix.mei@intel.com> In-Reply-To: <1569605698-316544-4-git-send-email-jianweix.mei@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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" Acked-by: Chen, Zhaoyan Regards, Zhaoyan Chen > -----Original Message----- > From: Mei, JianweiX > Sent: Saturday, September 28, 2019 1:35 AM > To: dts@dpdk.org > Cc: Chen, Zhaoyan ; Ma, LihongX ; > Mei, JianweiX > Subject: [dts][PATCH V1 4/6] framework/dut.py: add function > create_eal_parameters >=20 > From: meijx >=20 > add new method to create EAL parameters and overwrite self.cores accordin= g to > configured dut_cores. >=20 > Signed-off-by: meijx > --- > framework/dut.py | 155 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 155 insertions(+) >=20 > 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 =3D None > # hypervisor pid list, used for cleanup > self.virt_pids =3D [] > + self.prefix_subfix =3D str(os.getpid()) + '_' + time.strftime("%= Y%m%d%H%M%S", > time.localtime()) > + self.prefix_list =3D [] > + > + def filter_cores_from_crb_cfg(self): > + # get core list from crbs.cfg > + core_list =3D [] > + all_core_list =3D [str(core['core']) for core in self.cores] > + core_list_str =3D self.crb['dut_cores'] > + if core_list_str =3D=3D '': > + core_list =3D all_core_list > + split_by_comma =3D core_list_str.split(',') > + range_cores =3D [] > + for item in split_by_comma: > + if '-' in item: > + tmp =3D item.split('-') > + range_cores.extend([str(i) for i in range(int(tmp[0]), i= nt(tmp[1]) + 1)]) > + else: > + core_list.append(item) > + core_list.extend(range_cores) > + > + abnormal_core_list =3D [] > + 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, al= l core list of system > are %s' % (abnormal_core_list, all_core_list)) > + raise Exception('configured cores out of range system') > + > + core_list =3D [core for core in self.cores if str(core['core']) = in core_list] > + self.cores =3D core_list > + self.number_of_cores =3D len(self.cores) > + > + def create_eal_parameters(self, fixed_prefix=3DFalse, socket=3D-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 --fi= le- > prefix=3Ddpdk_1112_20190809143420' > + """ > + default_cores =3D '1S/2C/1T' > + blank =3D ' ' > + os_type =3D self.get_os_type() > + if config: > + # deal with cores > + if config.has_key('cores'): > + if config['cores'] =3D=3D '' or config['cores'] =3D=3D '= Default': > + core_list =3D self.get_core_list(default_cores) > + elif type(config['cores']) =3D=3D list: > + core_list =3D config['cores'] > + else: > + core_list =3D self.get_core_list(config['cores'], so= cket=3Dsocket) > + else: > + core_list =3D self.get_core_list(default_cores) > + > + # deal with ports > + w_pci_list =3D [] > + if config.has_key('ports') and len(config['ports']) !=3D 0: > + for port in config['ports']: > + if type(port) =3D=3D int: > + if config.has_key('port_options') and port in > config['port_options'].keys(): > + port_option =3D config['port_options'][port] > + w_pci_list.append('-w %s,%s' % (self.ports_i= nfo[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 =3D 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 =3D ['-w %s' % pci for pci in con= fig['ports']] > + w_pci_str =3D ' '.join(w_pci_list) > + > + # deal with black ports > + b_pci_list =3D [] > + if config.has_key('b_ports') and len(config['b_ports']) !=3D= 0: > + for port in config['b_ports']: > + if type(port) =3D=3D int: > + b_pci_list.append('-b %s' % self.ports_info[port= ]['pci']) > + else: > + b_pci_list =3D ['-b %s' % pci for pci in config[= 'b_ports']] > + b_ports_str =3D ' '.join(b_pci_list) > + > + # deal with no-pci > + if config.has_key('no_pci'): > + if config['no_pci'] =3D=3D True: > + no_pci =3D '--no-pci' > + else: > + no_pci =3D '' > + else: > + no_pci =3D '' > + > + # deal with file prefix > + if config.has_key('prefix') and config['prefix'] !=3D '': > + if fixed_prefix =3D=3D True: > + file_prefix =3D config['prefix'] > + else: > + file_prefix =3D config['prefix'] + '_' + self.prefix= _subfix > + else: > + file_prefix =3D 'dpdk' + '_' + self.prefix_subfix > + self.prefix_list.append(file_prefix) > + > + # deal with vdev > + if config.has_key('vdevs') and len(config['vdevs']) !=3D 0: > + vdev =3D '--vdev ' + ' --vdev '.join(config['vdevs']) > + else: > + vdev =3D '' > + > + if os_type =3D=3D 'freebsd': > + eal_str =3D '-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 =3D '-l ' + ','.join(map(str, core_list)) \ > + + blank + '-n %d' % self.get_memory_channels()= \ > + + blank + w_pci_str \ > + + blank + b_ports_str \ > + + blank + '--file-prefix=3D' + file_prefix \ > + + blank + no_pci \ > + + blank + vdev > + else: > + # get pci from ports_info > + pci_list =3D [] > + if len(self.ports_info) !=3D 0: > + for port_info in self.ports_info: > + pci_list.append('-w %s' % port_info['pci']) > + self.logger.info(pci_list) > + pci_str =3D ' '.join(pci_list) > + # default cores '1S/2C/1T' > + core_list =3D self.get_core_list(default_cores) > + file_prefix =3D 'dpdk' + '_' + self.prefix_subfix > + self.prefix_list.append(file_prefix) > + if os_type =3D=3D 'freebsd': > + eal_str =3D '-l ' + ','.join(map(str, core_list)) \ > + + blank + '-n %d' % self.get_memory_channels()= \ > + + blank + pci_str > + else: > + eal_str =3D '-l ' + ','.join(map(str, core_list)) \ > + + blank + '-n %d' % self.get_memory_channels()= \ > + + blank + pci_str \ > + + blank + '--file-prefix=3D' + file_prefix > + > + return eal_str > + > + def get_eal_of_prefix(self, prefix=3DNone): > + > + if prefix: > + file_prefix =3D [prefix_name for prefix_name in self.prefix_= list if prefix in > prefix_name] > + else: > + file_prefix =3D 'dpdk' + '_' + self.prefix_subfix > + > + return file_prefix >=20 > def init_host_session(self, vm_name): > """ > @@ -199,6 +353,7 @@ class Dut(Crb): > self.send_expect('alias sed=3Dgsed', '# ') >=20 > 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