Soft Patch Panel
 help / color / mirror / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/6] cli: add file prefix opt for launch cmd
Date: Fri, 20 Dec 2019 16:40:59 +0900	[thread overview]
Message-ID: <20191220074103.14065-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20191220074103.14065-1-yasufum.o@gmail.com>

From: Yasufumi Ogawa <yasufum.o@gmail.com>

`--file-prefix` is an EAL option for running several DPDK applications
by naming shared data file other than default one. However, it should be
the same name among processes if it is implemented as a multi-process
app.

This update is to add `--file-prefix` in completed launch command. SPP
CLI expects that the prefix is defined as an environment variable
`SPP_FILE_PREFIX`. It completes `--file-prefix` with the variable, or
does not complete this option itself if the variable is not defined.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/cli/commands/pri.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index bee0d81..9212897 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -4,6 +4,7 @@
 from .. import spp_common
 from ..shell_lib import common
 from ..spp_common import logger
+import os
 import time
 
 
@@ -21,6 +22,8 @@ class SppPrimary(object):
     PRI_CMDS = ['status', 'add', 'del', 'forward', 'stop', 'patch',
                 'launch', 'clear']
 
+    ENV_FILE_PREF = 'SPP_FILE_PREFIX'
+
     def __init__(self, spp_ctl_cli):
         self.spp_ctl_cli = spp_ctl_cli
 
@@ -29,9 +32,14 @@ class SppPrimary(object):
 
         # Default args for `pri; launch`, used if given cli_config is invalid
 
+        # used for secondary's --file-prefix option if defined
+        file_prefix = os.getenv(self.ENV_FILE_PREF)
+
         # Setup template of args for `pri; launch`
         temp = "-l {m_lcore},{s_lcores} "
         temp = temp + "{mem} "
+        if file_prefix:
+            temp = temp + "--file-prefix {} ".format(file_prefix)
         temp = temp + "-- "
         temp = temp + "{opt_sid} {sid} "  # '-n 1' or '--client-id 1'
         temp = temp + "-s {sec_addr} "  # '-s 192.168.1.100:6666'
@@ -166,7 +174,7 @@ class SppPrimary(object):
                         print('  - slave: {}'.format(json_obj['lcores'][1]))
                     else:
                         lcores = ', '.join([str(i)
-                            for i in json_obj['lcores'][1:]])
+                                            for i in json_obj['lcores'][1:]])
                         print('  - slaves: [{}]'.format(lcores))
 
             sep = ' '
@@ -197,8 +205,10 @@ class SppPrimary(object):
                 temp = '{s6}{portid:2}  {rx:10}  {tx:10}  {tx_d:10}  {eth}'
                 for pports in json_obj['phy_ports']:
                     print(temp.format(s6=sep*6,
-                        portid=pports['id'], rx=pports['rx'], tx=pports['tx'],
-                        tx_d=pports['tx_drop'], eth=pports['eth']))
+                                      portid=pports['id'], rx=pports['rx'],
+                                      tx=pports['tx'],
+                                      tx_d=pports['tx_drop'],
+                                      eth=pports['eth']))
 
             if 'ring_ports' in json_obj:
                 print('  - ring ports:')
@@ -207,7 +217,7 @@ class SppPrimary(object):
                 temp = '{s6}{rid:2}  {rx:10}  {tx:10}  {rx_d:10}  {tx_d:10}'
                 for rports in json_obj['ring_ports']:
                     print(temp.format(s6=sep*6,
-                        rid=rports['id'], rx=rports['rx'], tx=rports['tx'],
+                          rid=rports['id'], rx=rports['rx'], tx=rports['tx'],
                         rx_d=rports['rx_drop'], tx_d=rports['tx_drop']))
 
         except KeyError as e:
@@ -461,7 +471,8 @@ class SppPrimary(object):
                 if has_invalid_param is False:
                     candidates = [self.launch_template.format(
                         m_lcore=master_lcore, s_lcores=slave_lcores,
-                        mem=sec_mem, opt_sid=opt_sid, sid=sid,
+                        mem=sec_mem,
+                        opt_sid=opt_sid, sid=sid,
                         sec_addr=server_addr,
                         vhost_cli=vhost_client)]
                 else:
-- 
2.17.1


  parent reply	other threads:[~2019-12-20  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20  7:40 [spp] [PATCH 0/6] Run SPP with --file-prefix option yasufum.o
2019-12-20  7:40 ` [spp] [PATCH 1/6] cli: add env command yasufum.o
2019-12-20  7:40 ` yasufum.o [this message]
2019-12-20  7:41 ` [spp] [PATCH 3/6] bin: add SPP_FILE_PREFIX env variable yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 4/6] readme: update example of config.sh yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 5/6] docs: add desc for env command yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 6/6] docs: add file prefix option in usecases yasufum.o

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=20191220074103.14065-3-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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).