From: Itsuro Oda <oda@valinux.co.jp>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH v2 4/5] spp-ctl: enable add pipe port to the primary
Date: Wed, 26 Feb 2020 16:06:09 +0900 [thread overview]
Message-ID: <20200226070610.3496-5-oda@valinux.co.jp> (raw)
In-Reply-To: <20200226070610.3496-1-oda@valinux.co.jp>
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 <oda@valinux.co.jp>
---
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
next prev parent reply other threads:[~2020-02-26 7:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 1:37 [spp] [PATCH 0/5] REST API and CLI support for pipe PMD Itsuro Oda
2020-02-26 1:37 ` [spp] [PATCH 1/5] shared: add PIPE port type Itsuro Oda
2020-02-26 1:37 ` [spp] [PATCH 2/5] primary: suport pipe PMD Itsuro Oda
2020-02-26 6:29 ` Yasufumi Ogawa
2020-02-26 1:37 ` [spp] [PATCH 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26 1:37 ` [spp] [PATCH 4/5] spp-ctl: enable add pipe port to the primary Itsuro Oda
2020-02-26 1:37 ` [spp] [PATCH 5/5] cli: support pipe PMD Itsuro Oda
2020-02-26 7:06 ` [spp] [PATCH v2 0/5] REST API and CLI support for " Itsuro Oda
2020-02-26 7:06 ` [spp] [PATCH v2 1/5] shared: add PIPE port type Itsuro Oda
2020-02-26 7:06 ` [spp] [PATCH v2 2/5] primary: suport pipe PMD Itsuro Oda
2020-02-26 7:06 ` [spp] [PATCH v2 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26 7:06 ` Itsuro Oda [this message]
2020-02-26 7:06 ` [spp] [PATCH v2 5/5] cli: support " Itsuro Oda
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=20200226070610.3496-5-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).