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 98329A055E for ; Wed, 26 Feb 2020 02:37:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D07D1BFC7; Wed, 26 Feb 2020 02:37:49 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id D11D51BFB2 for ; Wed, 26 Feb 2020 02:37:47 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id 05D2D240882; Wed, 26 Feb 2020 10:37:46 +0900 (JST) From: Itsuro Oda To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Wed, 26 Feb 2020 10:37:45 +0900 Message-Id: <20200226013746.2875-5-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226013746.2875-1-oda@valinux.co.jp> References: <20200226013746.2875-1-oda@valinux.co.jp> Subject: [spp] [PATCH 4/5] spp-ctl: enable add pipe port to the primary 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" This patch adds pipe type to add port REST API to the primary. Note that del port API is common among all port types including pipe. Signed-off-by: Itsuro Oda --- src/spp-ctl/spp_proc.py | 7 +++++-- src/spp-ctl/spp_webapi.py | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py index 35919fb..c784f56 100644 --- a/src/spp-ctl/spp_proc.py +++ b/src/spp-ctl/spp_proc.py @@ -294,8 +294,11 @@ class PrimaryProc(SppProc): return "clear" @exec_command - def port_add(self, port): - return "add {port}".format(**locals()) + def port_add(self, port, rx=None, tx=None): + if rx is not None and tx is not None: + return "add {port} {rx} {tx}".format(**locals()) + else: + return "add {port}".format(**locals()) @exec_command def port_del(self, port): diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py index 31befe2..c7d8271 100644 --- a/src/spp-ctl/spp_webapi.py +++ b/src/spp-ctl/spp_webapi.py @@ -13,7 +13,8 @@ import sys import spp_proc -PORT_TYPES = ["phy", "vhost", "ring", "pcap", "nullpmd", "tap", "memif"] +PORT_TYPES = ["phy", "vhost", "ring", "pcap", "nullpmd", "tap", "memif", + "pipe"] VF_PORT_TYPES = ["phy", "vhost", "ring"] # TODO(yasufum) add other ports # TODO(yasufum) consider PCAP_PORT_TYPES is required. @@ -50,10 +51,10 @@ class BaseHandler(bottle.Bottle): res.content_type = "text/plain" return res.body - def _validate_port(self, port): + def _validate_port(self, port, port_types=PORT_TYPES): try: if_type, if_num = port.split(":") - if if_type not in PORT_TYPES: + if if_type not in port_types: raise int(if_num) except Exception: @@ -514,12 +515,27 @@ class V1PrimaryHandler(BaseHandler): raise KeyInvalid('action', body['action']) self._validate_port(body['port']) + def _validate_pipe_args(self, rx_ring, tx_ring): + try: + self._validate_port(rx_ring, ["ring"]) + except Exception: + raise KeyInvalid('rx', rx_ring) + try: + self._validate_port(tx_ring, ["ring"]) + except Exception: + raise KeyInvalid('tx', tx_ring) + def primary_port(self, body): self._validate_nfv_port(body) proc = self._get_proc() if body['action'] == "add": - proc.port_add(body['port']) + if body['port'].startswith("pipe:"): + self._validate_pipe_args(body.get('rx', ""), + body.get('tx', "")) + proc.port_add(body['port'], body['rx'], body['tx']) + else: + proc.port_add(body['port']) else: proc.port_del(body['port']) -- 2.17.1