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 97C79A057B for ; Mon, 13 Apr 2020 01:02:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 91F122B83; Mon, 13 Apr 2020 01:02:23 +0200 (CEST) Received: from mail.valinux.co.jp (mail.valinux.co.jp [210.128.90.3]) by dpdk.org (Postfix) with ESMTP id 42BE4293C for ; Mon, 13 Apr 2020 01:02:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.valinux.co.jp (Postfix) with ESMTP id 835CB9FC9B; Mon, 13 Apr 2020 08:02:21 +0900 (JST) X-Virus-Scanned: Debian amavisd-new at valinux.co.jp Received: from mail.valinux.co.jp ([127.0.0.1]) by localhost (mail.valinux.co.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ahx-yWaAWvM8; Mon, 13 Apr 2020 08:02:21 +0900 (JST) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with ESMTP id 6BCB69FC90; Mon, 13 Apr 2020 08:02:21 +0900 (JST) From: Itsuro Oda To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 13 Apr 2020 08:02:20 +0900 Message-Id: <20200412230221.28737-2-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200412230221.28737-1-oda@valinux.co.jp> References: <20200412230221.28737-1-oda@valinux.co.jp> Subject: [spp] [PATCH 1/2] cli: enable to add pipe without forwarder X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" 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 --- 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