Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/4] shared: add parsing resource UID
Date: Tue,  9 Oct 2018 19:48:44 +0900	[thread overview]
Message-ID: <20181009104847.42502-2-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181009104847.42502-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Resource UID is defined as a combination of port type and ID, and
separated with ':' such as 'ring:0'. This patch is to add a utility
function parse_resource_uid() to extract port type and ID.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/common.c | 24 ++++++++++++++++++++++++
 src/shared/common.h |  1 +
 2 files changed, 25 insertions(+)

diff --git a/src/shared/common.c b/src/shared/common.c
index 56f89df..56ef8c5 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -217,6 +217,30 @@ parse_server(char **server_ip, int *server_port, char *server_addr)
 	return 0;
 }
 
+/**
+ * Retieve port type and ID from resource UID. For example, resource UID
+ * 'ring:0' is  parsed to retrieve port tyep 'ring' and ID '0'.
+ */
+int
+parse_resource_uid(char *str, char **port_type, int *port_id)
+{
+	char *token;
+	char delim[] = ":";
+	char *endp;
+
+	*port_type = strtok(str, delim);
+
+	token = strtok(NULL, delim);
+	*port_id = strtol(token, &endp, 10);
+
+	if (*endp) {
+		RTE_LOG(ERR, APP, "Bad integer value: %s\n", str);
+		return -1;
+	}
+
+	return 0;
+}
+
 int
 spp_atoi(const char *str, int *val)
 {
diff --git a/src/shared/common.h b/src/shared/common.h
index 52a9a65..1580b08 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -196,6 +196,7 @@ void get_sec_stats_json(char *str, const char *running_stat,
 		struct port *ports_fwd_array,
 		struct port_map *port_map);
 
+int parse_resource_uid(char *str, char **port_type, int *port_id);
 int spp_atoi(const char *str, int *val);
 
 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
-- 
2.7.4

  reply	other threads:[~2018-10-09 10:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 10:48 [spp] [PATCH 0/4] Port management with " ogawa.yasufumi
2018-10-09 10:48 ` ogawa.yasufumi [this message]
2018-10-09 10:48 ` [spp] [PATCH 2/4] spp_nfv: change to use parse_resource_uid ogawa.yasufumi
2018-10-09 10:48 ` [spp] [PATCH 3/4] spp_vm: " ogawa.yasufumi
2018-10-09 10:48 ` [spp] [PATCH 4/4] controller: unify accepting resource UID format ogawa.yasufumi

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=20181009104847.42502-2-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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).