Soft Patch Panel
 help / color / mirror / Atom feed
From: Itsuro Oda <oda@valinux.co.jp>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 1/2] cli: enable to add pipe without forwarder
Date: Mon, 13 Apr 2020 08:02:20 +0900	[thread overview]
Message-ID: <20200412230221.28737-2-oda@valinux.co.jp> (raw)
In-Reply-To: <20200412230221.28737-1-oda@valinux.co.jp>

Pipe port is independent of the forwarder but it can be added
only if the forwarder exists currently.
This patch enables to add pipe port even if the forwarder does
not exist.

Fixes: 427350f31cfe (cli: support pipe PMD)

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/cli/commands/pri.py | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index 6fc7f00..3f5da29 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -49,6 +49,9 @@ class SppPrimary(object):
 
         self.flow = SppPrimaryFlow(spp_ctl_cli)
 
+    def _port_is_pipe(self, params):
+        return len(params) > 0 and params[0].startswith("pipe:")
+
     def _do_if_forwarder_exists(self, status, func, params):
         """Execute command of func if forwarder thread is existing.
 
@@ -103,10 +106,16 @@ class SppPrimary(object):
                     print('Error: unknown response from status.')
 
         elif subcmd == 'add':
-            self._do_if_forwarder_exists(status, self._run_add, params)
+            if self._port_is_pipe(params):
+                self._run_add(params, is_pipe=True)
+            else:
+                self._do_if_forwarder_exists(status, self._run_add, params)
 
         elif subcmd == 'del':
-            self._do_if_forwarder_exists(status, self._run_del, params)
+            if self._port_is_pipe(params):
+                self._run_del(params, is_pipe=True)
+            else:
+                self._do_if_forwarder_exists(status, self._run_del, params)
 
         elif subcmd == 'forward' or subcmd == 'stop':
             self._do_if_forwarder_exists(status,
@@ -795,7 +804,7 @@ class SppPrimary(object):
             index += 1
         return opts_dict
 
-    def _run_add(self, params):
+    def _run_add(self, params, is_pipe=False):
         """Run `add` command."""
 
         if len(params) == 0:
@@ -819,12 +828,13 @@ class SppPrimary(object):
                 else:
                     print('Error: unknown response for add.')
 
-            self.ports = self._get_ports()  # update to current status
-            if self.ports is None:
-                print('Cannot retrieve ports from spp_primary')
-                self.ports = []
+            if not is_pipe:
+                self.ports = self._get_ports()  # update to current status
+                if self.ports is None:
+                    print('Cannot retrieve ports from spp_primary')
+                    self.ports = []
 
-    def _run_del(self, params):
+    def _run_del(self, params, is_pipe=False):
         """Run `del` command."""
 
         if len(params) == 0:
@@ -849,10 +859,11 @@ class SppPrimary(object):
                     else:
                         print('Error: unknown response for del.')
 
-            self.patches = self._get_patches()  # update to current status
-            if self.patches is None:
-                print('Cannot retrieve patches from spp_primary')
-                self.patches = []
+            if not is_pipe:
+                self.patches = self._get_patches()  # update to current status
+                if self.patches is None:
+                    print('Cannot retrieve patches from spp_primary')
+                    self.patches = []
 
     def _run_forward_or_stop(self, cmd):
         """Run `forward` or `stop` command."""
-- 
2.17.0


  reply	other threads:[~2020-04-12 23:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12 23:02 [spp] [PATCH 0/2] enabel to add pipe withcout forwarder Itsuro Oda
2020-04-12 23:02 ` Itsuro Oda [this message]
2020-04-12 23:02 ` [spp] [PATCH 2/2] cli: fix status display of pipes Itsuro Oda
2020-04-30  2:41 ` [spp] (x-fn-spp-ml 677) [PATCH 0/2] enabel to add pipe withcout forwarder Hideyuki Yamashita
2020-05-25  3:10 ` [spp] " Yasufumi Ogawa

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=20200412230221.28737-2-oda@valinux.co.jp \
    --to=oda@valinux.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    --cc=yasufum.o@gmail.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).