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 2CBCBA055E for ; Wed, 26 Feb 2020 08:06:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 669021BFB5; Wed, 26 Feb 2020 08:06:13 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id BC86D1BFB3 for ; Wed, 26 Feb 2020 08:06:11 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id ED3E8240882; Wed, 26 Feb 2020 16:06:10 +0900 (JST) From: Itsuro Oda To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Wed, 26 Feb 2020 16:06:09 +0900 Message-Id: <20200226070610.3496-5-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226070610.3496-1-oda@valinux.co.jp> References: <20200226013746.2875-1-oda@valinux.co.jp> <20200226070610.3496-1-oda@valinux.co.jp> Subject: [spp] [PATCH v2 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 d584f7f..caccc81 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 d8e6e73..65998a9 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. @@ -64,10 +65,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 if if_type == "phy" and "nq" in if_num: port_num, queue_num = if_num.split("nq") @@ -545,12 +546,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