DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com
Subject: [dpdk-dev] [PATCH 2/6] net/softnic: add CLI command for tmgr shaper profile
Date: Wed, 25 Jul 2018 18:10:03 +0100	[thread overview]
Message-ID: <20180725171007.94198-3-jasvinder.singh@intel.com> (raw)
In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com>

From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Add support to create Traffic Manager (TMGR) shaper profile
through firmware CLI script.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 drivers/net/softnic/parser.c              |  18 ++++++
 drivers/net/softnic/parser.h              |   2 +
 drivers/net/softnic/rte_eth_softnic_cli.c | 100 +++++++++++++++++++++++++++++-
 3 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/drivers/net/softnic/parser.c b/drivers/net/softnic/parser.c
index 7087b87..a8688a2 100644
--- a/drivers/net/softnic/parser.c
+++ b/drivers/net/softnic/parser.c
@@ -93,6 +93,24 @@ softnic_parser_read_arg_bool(const char *p)
 }
 
 int
+softnic_parser_read_int32(int32_t *value, const char *p)
+{
+	char *next;
+	int32_t val;
+
+	p = skip_white_spaces(p);
+	if (!isdigit(*p))
+		return -EINVAL;
+
+	val = strtol(p, &next, 10);
+	if (p == next)
+		return -EINVAL;
+
+	*value = val;
+	return 0;
+}
+
+int
 softnic_parser_read_uint64(uint64_t *value, const char *p)
 {
 	char *next;
diff --git a/drivers/net/softnic/parser.h b/drivers/net/softnic/parser.h
index 5ab4763..1ee3f82 100644
--- a/drivers/net/softnic/parser.h
+++ b/drivers/net/softnic/parser.h
@@ -33,6 +33,8 @@ skip_digits(const char *src)
 
 int softnic_parser_read_arg_bool(const char *p);
 
+int softnic_parser_read_int32(int32_t *value, const char *p);
+
 int softnic_parser_read_uint64(uint64_t *value, const char *p);
 int softnic_parser_read_uint32(uint32_t *value, const char *p);
 int softnic_parser_read_uint16(uint16_t *value, const char *p);
diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index 4a63b94..0a9ec01 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -185,6 +185,93 @@ cmd_swq(struct pmd_internals *softnic,
 }
 
 /**
+ * tmgr shaper profile
+ *  id <profile_id>
+ *  rate <tb_rate> size <tb_size>
+ *  adj <packet_length_adjust>
+ */
+static void
+cmd_tmgr_shaper_profile(struct pmd_internals *softnic,
+	char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_tm_shaper_params sp;
+	struct rte_tm_error error;
+	uint32_t shaper_profile_id;
+	uint16_t port_id;
+	int status;
+
+	memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
+
+	if (n_tokens != 11) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	if (strcmp(tokens[1], "shaper") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shaper");
+		return;
+	}
+
+	if (strcmp(tokens[2], "profile") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
+		return;
+	}
+
+	if (strcmp(tokens[3], "id") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "id");
+		return;
+	}
+
+	if (softnic_parser_read_uint32(&shaper_profile_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "profile_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "rate") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rate");
+		return;
+	}
+
+	if (softnic_parser_read_uint64(&sp.peak.rate, tokens[6]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
+		return;
+	}
+
+	if (strcmp(tokens[7], "size") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "size");
+		return;
+	}
+
+	if (softnic_parser_read_uint64(&sp.peak.size, tokens[8]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
+		return;
+	}
+
+	if (strcmp(tokens[9], "adj") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "adj");
+		return;
+	}
+
+	if (softnic_parser_read_int32(&sp.pkt_length_adjust, tokens[10]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "packet_length_adjust");
+		return;
+	}
+
+	status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
+	if (status)
+		return;
+
+	status = rte_tm_shaper_profile_add(port_id, shaper_profile_id, &sp, &error);
+	if (status != 0) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * tmgr <tmgr_name>
  */
 static void
@@ -3983,8 +4070,17 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg)
 	}
 
 	if (strcmp(tokens[0], "tmgr") == 0) {
-		cmd_tmgr(softnic, tokens, n_tokens, out, out_size);
-		return;
+		if (n_tokens == 2) {
+			cmd_tmgr(softnic, tokens, n_tokens, out, out_size);
+			return;
+		}
+
+		if (n_tokens >= 3 &&
+			(strcmp(tokens[1], "shaper") == 0) &&
+			(strcmp(tokens[2], "profile") == 0)) {
+			cmd_tmgr_shaper_profile(softnic, tokens, n_tokens, out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "tap") == 0) {
-- 
2.9.3

  parent reply	other threads:[~2018-07-25 17:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 17:10 [dpdk-dev] [PATCH 0/6] net/softnic: expose tmgr through firmware Jasvinder Singh
2018-07-25 17:10 ` [dpdk-dev] [PATCH 1/6] net/softnic: add CLI command for tmgr create Jasvinder Singh
2018-07-25 17:10 ` Jasvinder Singh [this message]
2018-07-25 17:10 ` [dpdk-dev] [PATCH 3/6] net/softnic: add CLI command for tmgr shared shaper Jasvinder Singh
2018-07-25 17:10 ` [dpdk-dev] [PATCH 4/6] net/softnic: add CLI command for tmgr node addition Jasvinder Singh
2018-07-25 17:10 ` [dpdk-dev] [PATCH 5/6] net/softnic: add CLI command for tmgr hierarchy commit Jasvinder Singh
2018-07-25 17:10 ` [dpdk-dev] [PATCH 6/6] net/softnic: add CLI command for default tmgr hierarchy Jasvinder Singh
2018-07-25 17:35 ` [dpdk-dev] [PATCH 0/6] net/softnic: expose tmgr through firmware Dumitrescu, Cristian

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=20180725171007.94198-3-jasvinder.singh@intel.com \
    --to=jasvinder.singh@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@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).