summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-07-25 18:10:03 +0100
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-07-25 19:27:34 +0200
commit552e3f72d49ec91d0cec250cb392b23aaf3757c1 (patch)
tree97fb154349eba4a9605452d8cde137fc87d28bd7
parentc73369e6d19af0696f8af7846ff42e3173d6f724 (diff)
downloaddpdk-552e3f72d49ec91d0cec250cb392b23aaf3757c1.zip
dpdk-552e3f72d49ec91d0cec250cb392b23aaf3757c1.tar.gz
dpdk-552e3f72d49ec91d0cec250cb392b23aaf3757c1.tar.xz
net/softnic: add command for tmgr shaper profile
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>
-rw-r--r--drivers/net/softnic/parser.c18
-rw-r--r--drivers/net/softnic/parser.h2
-rw-r--r--drivers/net/softnic/rte_eth_softnic_cli.c100
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) {