test suite reviews and discussions
 help / color / mirror / Atom feed
From: Haiyang Zhao <haiyangx.zhao@intel.com>
To: lijuan.tu@intel.com, dts@dpdk.org
Cc: Haiyang Zhao <haiyangx.zhao@intel.com>
Subject: [dts] [PATCH V1 1/2] framework/pmd_output: fix a bug in start_testpmd
Date: Wed, 23 Dec 2020 16:24:21 +0800	[thread overview]
Message-ID: <20201223082422.7153-2-haiyangx.zhao@intel.com> (raw)
In-Reply-To: <20201223082422.7153-1-haiyangx.zhao@intel.com>

the regular expression in split_eal_param can not recognize the eal param
like "-a af:00.0,representor=0-1", this patch fixed this bug and optimized
the eal parameter reassmeble method.

Signed-off-by: Haiyang Zhao <haiyangx.zhao@intel.com>
---
 framework/pmd_output.py | 107 +++++++++++++---------------------------
 1 file changed, 34 insertions(+), 73 deletions(-)

diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index 9dc6d3b4..f4ea6670 100644
--- a/framework/pmd_output.py
+++ b/framework/pmd_output.py
@@ -103,87 +103,48 @@ class PmdOutput():
     def get_pmd_cmd(self):
         return self.command
 
-    def split_eal_param(self, eal_param):
-        """
-        split eal param from test suite
-        :param eal_param:
-        :return:
-        """
-        re_w_pci_str = '\s?-[w,a]\s+\w*:?[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}.[A-Fa-f0-9]{1},.*=\d+' \
-                       '|\s?-[w,a]\s+\w*:?[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}.[A-Fa-f0-9]{1}'
-        re_file_prefix_str = '--file-prefix[\s*=]\S+\s'
-        re_b_pci_str = '\s?-b\s+\w*:?[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}.[A-Fa-f0-9]{1},.*=\d+' \
-                       '|\s?-b\s+\w*:?[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}.[A-Fa-f0-9]{1}'
-        eal_param = eal_param + ' '
-        # pci_str_list eg: ['-w   0000:1a:00.0 ', '-w 0000:1a:00.1,queue-num-per-vf=4 ', '-w 0000:aa:bb.1,queue-num-per-vf=4 ',
-        #                   '-a   0000:1a:00.0 ', '-a 0000:1a:00.1,queue-num-per-vf=4 ', '-a 0000:aa:bb.1,queue-num-per-vf=4 ']
-        w_pci_str_list = re.findall(re_w_pci_str, eal_param)
-        # file_prefix_str eg: ['--file-prefix=dpdk ']
-        file_prefix_str = re.findall(re_file_prefix_str, eal_param)
-        b_pci_str_list = re.findall(re_b_pci_str, eal_param)
-        has_pci_option = {}
-        pci_list = []
-        if w_pci_str_list:
-            for pci_str in w_pci_str_list:
-                # has pci options
-                pci_str_options = pci_str.split('-w ') if '-w ' in pci_str else pci_str.split('-a ')
-                if ',' in pci_str_options[-1]:
-                    pci_option = pci_str_options[-1].split(',')
-                    has_pci_option[pci_option[0]] = pci_option[1].strip()
-                    pci_list.append(pci_option[0])
-                else:
-                    pci_list.append(pci_str_options[-1])
-
-        b_pci_list = []
-        if b_pci_str_list:
-            for b_pci in b_pci_str_list:
-                tmp = b_pci.split('-b')[1].strip()
-                b_pci_list.append(tmp)
-
-        file_prefix = ''
+    def start_testpmd(self, cores='default', param='', eal_param='', socket=0, fixed_prefix=False, **config):
+        """
+        start testpmd with input parameters.
+        :param cores: eg:
+                cores='default'
+                cores='1S/4C/1T'
+        :param param: dpdk application (testpmd) parameters
+        :param eal_param: user defined DPDK eal parameters, eg:
+                eal_param='-a af:00.0 -a af:00.1,proto_xtr=vlan',
+                eal_param='-b af:00.0 --file-prefix=vf0',
+                eal_param='--no-pci',
+        :param socket: physical CPU socket index
+        :param fixed_prefix: use fixed file-prefix or not, when it is true,
+               the file-prefix will not be added a timestamp
+        :param config: kwargs user defined eal parameters, eg:
+                set PCI allow list: ports=[0,1], port_options={0: "proto_xtr=vlan"},
+                set PCI block list: b_ports=['0000:1a:00.0'],
+                disable PCI: no_pci=True,
+                add virtual device: vdevs=['net_vhost0,iface=vhost-net,queues=1']
+        :return: output of launching testpmd
+        """
+        eal_param = ' ' + eal_param + ' '
+        eal_param = eal_param.replace(' -w ', ' -a ')
+        re_file_prefix = '--file-prefix[\s*=]\S+\s'
+        file_prefix_str = re.findall(re_file_prefix, eal_param)
         if file_prefix_str:
             tmp = re.split('(=|\s+)', file_prefix_str[-1].strip())
             file_prefix = tmp[-1].strip()
+            config['prefix'] = file_prefix
+        eal_param = re.sub(re_file_prefix, '', eal_param)
 
-        other_eal_str = re.sub(re_w_pci_str, '', eal_param)
-        other_eal_str = re.sub(re_b_pci_str, '', other_eal_str)
-        other_eal_str = re.sub(re_file_prefix_str, '', other_eal_str)
-
-        no_pci = False
-        if '--no-pci' in other_eal_str:
-            no_pci = True
-            other_eal_str = other_eal_str.replace('--no-pci','')
-
-        return pci_list, has_pci_option, b_pci_list, file_prefix, no_pci, other_eal_str
-
-    def start_testpmd(self, cores='default', param='', eal_param='', socket=0, fixed_prefix=False, **config):
         config['cores'] = cores
-        if eal_param == '':
-            # use configured ports if not set
-            if 'ports' not in list(config.keys()):
-                config['ports'] = [self.dut.ports_info[i]['pci'] for i in range(len(self.dut.ports_info))]
-            all_eal_param = self.dut.create_eal_parameters(fixed_prefix=fixed_prefix, socket=socket, **config)
-        else:
-            w_pci_list, port_options, b_pci_list, file_prefix, no_pci, other_eal_str = self.split_eal_param(eal_param)
-            config['other_eal_param'] = other_eal_str
-            if no_pci:
-                config['no_pci'] = no_pci
-            if w_pci_list:
-                config['ports'] = w_pci_list
-            if port_options:
-                config['port_options'] = port_options
-            if b_pci_list:
-                config['b_ports'] = b_pci_list
-            if file_prefix:
-                config['prefix'] = file_prefix
-
-            if not w_pci_list and not b_pci_list and 'ports' not in list(config.keys()):
-                config['ports'] = [self.dut.ports_info[i]['pci'] for i in range(len(self.dut.ports_info))]
-            part_eal_param = self.dut.create_eal_parameters(fixed_prefix=fixed_prefix, socket=socket, **config)
-            all_eal_param = part_eal_param + ' ' + other_eal_str
+        if ' -w ' not in eal_param and ' -a ' not in eal_param and ' -b ' not in eal_param \
+            and 'ports' not in config and 'b_ports' not in config and ' --no-pci ' not in eal_param \
+            and ( 'no_pci' not in config or ('no_pci' in config and config['no_pci'] != True)):
+            config['ports'] = [self.dut.ports_info[i]['pci'] for i in range(len(self.dut.ports_info))]
+        part_eal_param = self.dut.create_eal_parameters(fixed_prefix=fixed_prefix, socket=socket, **config)
+        all_eal_param = part_eal_param + ' ' + eal_param
 
         app_name = self.dut.apps_name['test-pmd']
         command = app_name + " %s -- -i %s" % (all_eal_param, param)
+        command = command.replace('  ', ' ')
         if self.session != self.dut:
             self.session.send_expect("cd %s" % self.dut.base_dir, "# ")
         out = self.session.send_expect(command, "testpmd> ", 120)
-- 
2.17.1


  reply	other threads:[~2020-12-23  8:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23  8:24 [dts] [PATCH V1 0/2] framework: " Haiyang Zhao
2020-12-23  8:24 ` Haiyang Zhao [this message]
2020-12-23  8:24 ` [dts] [PATCH V1 2/2] framework/dut: replace "-w" with "-a" Haiyang Zhao
2020-12-23  8:35 ` [dts] [PATCH V1 0/2] framework: fix a bug in start_testpmd Zhao, HaiyangX
2020-12-24  3:03 ` Tu, Lijuan

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=20201223082422.7153-2-haiyangx.zhao@intel.com \
    --to=haiyangx.zhao@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).