From patchwork Wed Jul 25 17:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43371 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D85453250; Wed, 25 Jul 2018 19:10:13 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 4EF931C01 for ; Wed, 25 Jul 2018 19:10:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856108" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:09 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:02 +0100 Message-Id: <20180725171007.94198-2-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 1/6] net/softnic: add CLI command for tmgr create X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support to create Traffic Manager (TMGR) object through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic.c | 17 +- drivers/net/softnic/rte_eth_softnic_cli.c | 32 ++++ drivers/net/softnic/rte_eth_softnic_internals.h | 14 +- drivers/net/softnic/rte_eth_softnic_tm.c | 205 ++++++++++-------------- 4 files changed, 124 insertions(+), 144 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 2688e17..30fb395 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -156,14 +156,6 @@ pmd_dev_start(struct rte_eth_dev *dev) struct pmd_internals *p = dev->data->dev_private; int status; - /* TM */ - if (tm_used(dev)) { - status = tm_start(p); - - if (status) - return status; - } - /* Firmware */ status = softnic_cli_script_process(p, p->params.firmware, @@ -197,8 +189,7 @@ pmd_dev_stop(struct rte_eth_dev *dev) softnic_softnic_swq_free_keep_rxq_txq(p); softnic_mempool_free(p); - /* TM */ - tm_stop(p); + tm_hierarchy_free(p); } static void @@ -273,10 +264,11 @@ pmd_init(struct pmd_params *params) memcpy(&p->params, params, sizeof(p->params)); /* Resources */ + tm_hierarchy_init(p); + softnic_mempool_init(p); softnic_swq_init(p); softnic_link_init(p); - tm_init(p); softnic_tmgr_init(p); softnic_tap_init(p); softnic_port_in_action_profile_init(p); @@ -322,11 +314,12 @@ pmd_free(struct pmd_internals *p) softnic_port_in_action_profile_free(p); softnic_tap_free(p); softnic_tmgr_free(p); - tm_free(p); softnic_link_free(p); softnic_swq_free(p); softnic_mempool_free(p); + tm_hierarchy_free(p); + rte_free(p); } diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 860d6a9..4a63b94 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -185,6 +185,33 @@ cmd_swq(struct pmd_internals *softnic, } /** + * tmgr + */ +static void +cmd_tmgr(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + char *name; + struct softnic_tmgr_port *tmgr_port; + + if (n_tokens != 2) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + name = tokens[1]; + + tmgr_port = softnic_tmgr_port_create(softnic, name); + if (tmgr_port == NULL) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + +/** * tap */ static void @@ -3955,6 +3982,11 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) return; } + if (strcmp(tokens[0], "tmgr") == 0) { + cmd_tmgr(softnic, tokens, n_tokens, out, out_size); + return; + } + if (strcmp(tokens[0], "tap") == 0) { cmd_tap(softnic, tokens, n_tokens, out, out_size); return; diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 4738cf3..a25eb87 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -203,7 +203,6 @@ struct tm_internals { /** Blueprints */ struct tm_params params; - struct rte_sched_port *sched; }; struct softnic_tmgr_port { @@ -575,20 +574,13 @@ softnic_tmgr_port_find(struct pmd_internals *p, struct softnic_tmgr_port * softnic_tmgr_port_create(struct pmd_internals *p, - const char *name, - struct rte_sched_port *sched); - -int -tm_init(struct pmd_internals *p); + const char *name); void -tm_free(struct pmd_internals *p); - -int -tm_start(struct pmd_internals *p); +tm_hierarchy_init(struct pmd_internals *p); void -tm_stop(struct pmd_internals *p); +tm_hierarchy_free(struct pmd_internals *p); static inline int tm_used(struct rte_eth_dev *dev) diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c index 8e473c8..baaafbe 100644 --- a/drivers/net/softnic/rte_eth_softnic_tm.c +++ b/drivers/net/softnic/rte_eth_softnic_tm.c @@ -34,6 +34,7 @@ softnic_tmgr_free(struct pmd_internals *p) break; TAILQ_REMOVE(&p->tmgr_port_list, tmgr_port, node); + rte_sched_port_free(tmgr_port->s); free(tmgr_port); } } @@ -56,23 +57,71 @@ softnic_tmgr_port_find(struct pmd_internals *p, struct softnic_tmgr_port * softnic_tmgr_port_create(struct pmd_internals *p, - const char *name, - struct rte_sched_port *sched) + const char *name) { struct softnic_tmgr_port *tmgr_port; + struct tm_params *t = &p->soft.tm.params; + struct rte_sched_port *sched; + uint32_t n_subports, subport_id; /* Check input params */ if (name == NULL || - softnic_tmgr_port_find(p, name) || - sched == NULL) + softnic_tmgr_port_find(p, name)) return NULL; - /* Resource */ + /* + * Resource + */ + + /* Is hierarchy frozen? */ + if (p->soft.tm.hierarchy_frozen == 0) + return NULL; + + /* Port */ + sched = rte_sched_port_config(&t->port_params); + if (sched == NULL) + return NULL; + + /* Subport */ + n_subports = t->port_params.n_subports_per_port; + for (subport_id = 0; subport_id < n_subports; subport_id++) { + uint32_t n_pipes_per_subport = t->port_params.n_pipes_per_subport; + uint32_t pipe_id; + int status; + + status = rte_sched_subport_config(sched, + subport_id, + &t->subport_params[subport_id]); + if (status) { + rte_sched_port_free(sched); + return NULL; + } + + /* Pipe */ + for (pipe_id = 0; pipe_id < n_pipes_per_subport; pipe_id++) { + int pos = subport_id * TM_MAX_PIPES_PER_SUBPORT + pipe_id; + int profile_id = t->pipe_to_profile[pos]; + + if (profile_id < 0) + continue; + + status = rte_sched_pipe_config(sched, + subport_id, + pipe_id, + profile_id); + if (status) { + rte_sched_port_free(sched); + return NULL; + } + } + } /* Node allocation */ tmgr_port = calloc(1, sizeof(struct softnic_tmgr_port)); - if (tmgr_port == NULL) + if (tmgr_port == NULL) { + rte_sched_port_free(sched); return NULL; + } /* Node fill in */ strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name)); @@ -84,10 +133,22 @@ softnic_tmgr_port_create(struct pmd_internals *p, return tmgr_port; } -static void +static struct rte_sched_port * +SCHED(struct pmd_internals *p) +{ + struct softnic_tmgr_port *tmgr_port; + + tmgr_port = softnic_tmgr_port_find(p, "TMGR"); + if (tmgr_port == NULL) + return NULL; + + return tmgr_port->s; +} + +void tm_hierarchy_init(struct pmd_internals *p) { - memset(&p->soft.tm.h, 0, sizeof(p->soft.tm.h)); + memset(&p->soft.tm, 0, sizeof(p->soft.tm)); /* Initialize shaper profile list */ TAILQ_INIT(&p->soft.tm.h.shaper_profiles); @@ -102,8 +163,8 @@ tm_hierarchy_init(struct pmd_internals *p) TAILQ_INIT(&p->soft.tm.h.nodes); } -static void -tm_hierarchy_uninit(struct pmd_internals *p) +void +tm_hierarchy_free(struct pmd_internals *p) { /* Remove all nodes*/ for ( ; ; ) { @@ -154,98 +215,7 @@ tm_hierarchy_uninit(struct pmd_internals *p) free(shaper_profile); } - memset(&p->soft.tm.h, 0, sizeof(p->soft.tm.h)); -} - -int -tm_init(struct pmd_internals *p) -{ tm_hierarchy_init(p); - - return 0; -} - -void -tm_free(struct pmd_internals *p) -{ - tm_hierarchy_uninit(p); -} - -int -tm_start(struct pmd_internals *p) -{ - struct softnic_tmgr_port *tmgr_port; - struct tm_params *t = &p->soft.tm.params; - struct rte_sched_port *sched; - uint32_t n_subports, subport_id; - int status; - - /* Is hierarchy frozen? */ - if (p->soft.tm.hierarchy_frozen == 0) - return -1; - - /* Port */ - sched = rte_sched_port_config(&t->port_params); - if (sched == NULL) - return -1; - - /* Subport */ - n_subports = t->port_params.n_subports_per_port; - for (subport_id = 0; subport_id < n_subports; subport_id++) { - uint32_t n_pipes_per_subport = - t->port_params.n_pipes_per_subport; - uint32_t pipe_id; - - status = rte_sched_subport_config(sched, - subport_id, - &t->subport_params[subport_id]); - if (status) { - rte_sched_port_free(sched); - return -1; - } - - /* Pipe */ - n_pipes_per_subport = t->port_params.n_pipes_per_subport; - for (pipe_id = 0; pipe_id < n_pipes_per_subport; pipe_id++) { - int pos = subport_id * TM_MAX_PIPES_PER_SUBPORT + - pipe_id; - int profile_id = t->pipe_to_profile[pos]; - - if (profile_id < 0) - continue; - - status = rte_sched_pipe_config(sched, - subport_id, - pipe_id, - profile_id); - if (status) { - rte_sched_port_free(sched); - return -1; - } - } - } - - tmgr_port = softnic_tmgr_port_create(p, "TMGR", sched); - if (tmgr_port == NULL) { - rte_sched_port_free(sched); - return -1; - } - - /* Commit */ - p->soft.tm.sched = sched; - - return 0; -} - -void -tm_stop(struct pmd_internals *p) -{ - if (p->soft.tm.sched) { - rte_sched_port_free(p->soft.tm.sched); - p->soft.tm.sched = NULL; - } - /* Unfreeze hierarchy */ - p->soft.tm.hierarchy_frozen = 0; } static struct tm_shaper_profile * @@ -1095,7 +1065,7 @@ update_subport_tc_rate(struct rte_eth_dev *dev, subport_params.tc_rate[tc_id] = sp_new->params.peak.rate; /* Update the subport configuration. */ - if (rte_sched_subport_config(p->soft.tm.sched, + if (rte_sched_subport_config(SCHED(p), subport_id, &subport_params)) return -1; @@ -2623,10 +2593,8 @@ pmd_tm_hierarchy_commit(struct rte_eth_dev *dev, status = hierarchy_commit_check(dev, error); if (status) { - if (clear_on_fail) { - tm_hierarchy_uninit(p); - tm_hierarchy_init(p); - } + if (clear_on_fail) + tm_hierarchy_free(p); return status; } @@ -2668,7 +2636,7 @@ update_pipe_weight(struct rte_eth_dev *dev, struct tm_node *np, uint32_t weight) return -1; /* Update the pipe profile used by the current pipe. */ - if (rte_sched_pipe_config(p->soft.tm.sched, subport_id, pipe_id, + if (rte_sched_pipe_config(SCHED(p), subport_id, pipe_id, (int32_t)pipe_profile_id)) return -1; @@ -2717,7 +2685,7 @@ update_queue_weight(struct rte_eth_dev *dev, return -1; /* Update the pipe profile used by the current pipe. */ - if (rte_sched_pipe_config(p->soft.tm.sched, subport_id, pipe_id, + if (rte_sched_pipe_config(SCHED(p), subport_id, pipe_id, (int32_t)pipe_profile_id)) return -1; @@ -2850,7 +2818,7 @@ update_subport_rate(struct rte_eth_dev *dev, subport_params.tb_size = sp->params.peak.size; /* Update the subport configuration. */ - if (rte_sched_subport_config(p->soft.tm.sched, subport_id, + if (rte_sched_subport_config(SCHED(p), subport_id, &subport_params)) return -1; @@ -2897,7 +2865,7 @@ update_pipe_rate(struct rte_eth_dev *dev, return -1; /* Update the pipe profile used by the current pipe. */ - if (rte_sched_pipe_config(p->soft.tm.sched, subport_id, pipe_id, + if (rte_sched_pipe_config(SCHED(p), subport_id, pipe_id, (int32_t)pipe_profile_id)) return -1; @@ -2942,7 +2910,7 @@ update_tc_rate(struct rte_eth_dev *dev, return -1; /* Update the pipe profile used by the current pipe. */ - if (rte_sched_pipe_config(p->soft.tm.sched, subport_id, pipe_id, + if (rte_sched_pipe_config(SCHED(p), subport_id, pipe_id, (int32_t)pipe_profile_id)) return -1; @@ -3077,8 +3045,7 @@ read_port_stats(struct rte_eth_dev *dev, uint32_t tc_ov, id; /* Stats read */ - int status = rte_sched_subport_read_stats( - p->soft.tm.sched, + int status = rte_sched_subport_read_stats(SCHED(p), subport_id, &s, &tc_ov); @@ -3125,8 +3092,7 @@ read_subport_stats(struct rte_eth_dev *dev, uint32_t tc_ov, tc_id; /* Stats read */ - int status = rte_sched_subport_read_stats( - p->soft.tm.sched, + int status = rte_sched_subport_read_stats(SCHED(p), subport_id, &s, &tc_ov); @@ -3186,8 +3152,7 @@ read_pipe_stats(struct rte_eth_dev *dev, i / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS, i % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS); - int status = rte_sched_queue_read_stats( - p->soft.tm.sched, + int status = rte_sched_queue_read_stats(SCHED(p), qid, &s, &qlen); @@ -3247,8 +3212,7 @@ read_tc_stats(struct rte_eth_dev *dev, tc_id, i); - int status = rte_sched_queue_read_stats( - p->soft.tm.sched, + int status = rte_sched_queue_read_stats(SCHED(p), qid, &s, &qlen); @@ -3307,8 +3271,7 @@ read_queue_stats(struct rte_eth_dev *dev, tc_id, queue_id); - int status = rte_sched_queue_read_stats( - p->soft.tm.sched, + int status = rte_sched_queue_read_stats(SCHED(p), qid, &s, &qlen); From patchwork Wed Jul 25 17:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43372 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6E15378B; Wed, 25 Jul 2018 19:10:16 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 02CE91C01 for ; Wed, 25 Jul 2018 19:10:12 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856123" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:10 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:03 +0100 Message-Id: <20180725171007.94198-3-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 2/6] net/softnic: add CLI command for tmgr shaper profile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support to create Traffic Manager (TMGR) shaper profile through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- 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 + * rate size + * adj + */ +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 */ 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) { From patchwork Wed Jul 25 17:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43373 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35D2544BE; Wed, 25 Jul 2018 19:10:19 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id C221D324B for ; Wed, 25 Jul 2018 19:10:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856140" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:12 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:04 +0100 Message-Id: <20180725171007.94198-4-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 3/6] net/softnic: add CLI command for tmgr shared shaper X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support to create Traffic Manager (TMGR) shared shaper through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_cli.c | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 0a9ec01..73ea7bd 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -272,6 +272,72 @@ cmd_tmgr_shaper_profile(struct pmd_internals *softnic, } /** + * tmgr shared shaper + * id + * profile + */ +static void +cmd_tmgr_shared_shaper(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct rte_tm_error error; + uint32_t shared_shaper_id, shaper_profile_id; + uint16_t port_id; + int status; + + if (n_tokens != 7) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "shared") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shared"); + return; + } + + if (strcmp(tokens[2], "shaper") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shaper"); + return; + } + + if (strcmp(tokens[3], "id") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "id"); + return; + } + + if (softnic_parser_read_uint32(&shared_shaper_id, tokens[4]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared_shaper_id"); + return; + } + + if (strcmp(tokens[5], "profile") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile"); + return; + } + + if (softnic_parser_read_uint32(&shaper_profile_id, tokens[6]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shaper_profile_id"); + return; + } + + status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); + if (status) + return; + + status = rte_tm_shared_shaper_add_update(port_id, + shared_shaper_id, + shaper_profile_id, + &error); + if (status != 0) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + +/** * tmgr */ static void @@ -4081,6 +4147,13 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) cmd_tmgr_shaper_profile(softnic, tokens, n_tokens, out, out_size); return; } + + if (n_tokens >= 3 && + (strcmp(tokens[1], "shared") == 0) && + (strcmp(tokens[2], "shaper") == 0)) { + cmd_tmgr_shared_shaper(softnic, tokens, n_tokens, out, out_size); + return; + } } if (strcmp(tokens[0], "tap") == 0) { From patchwork Wed Jul 25 17:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43374 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C596343C; Wed, 25 Jul 2018 19:10:21 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 13204324B for ; Wed, 25 Jul 2018 19:10:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856154" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:13 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:05 +0100 Message-Id: <20180725171007.94198-5-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 4/6] net/softnic: add CLI command for tmgr node addition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support for adding Traffic Manager (TMGR) hierarchy node through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_cli.c | 171 ++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 73ea7bd..d5485b5 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -338,6 +338,171 @@ cmd_tmgr_shared_shaper(struct pmd_internals *softnic, } /** + * tmgr node + * id + * parent + * priority + * weight + * [shaper profile ] + * [shared shaper ] + * [nonleaf sp ] + */ +static void +cmd_tmgr_node(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct rte_tm_error error; + struct rte_tm_node_params np; + uint32_t node_id, parent_node_id, priority, weight, shared_shaper_id; + uint16_t port_id; + int status; + + memset(&np, 0, sizeof(struct rte_tm_node_params)); + np.shaper_profile_id = RTE_TM_SHAPER_PROFILE_ID_NONE; + np.nonleaf.n_sp_priorities = 1; + + if (n_tokens < 10) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "node") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "node"); + return; + } + + if (strcmp(tokens[2], "id") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "id"); + return; + } + + if (softnic_parser_read_uint32(&node_id, tokens[3]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "node_id"); + return; + } + + if (strcmp(tokens[4], "parent") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "parent"); + return; + } + + if (strcmp(tokens[5], "none") == 0) + parent_node_id = RTE_TM_NODE_ID_NULL; + else { + if (softnic_parser_read_uint32(&parent_node_id, tokens[5]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "parent_node_id"); + return; + } + } + + if (strcmp(tokens[6], "priority") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority"); + return; + } + + if (softnic_parser_read_uint32(&priority, tokens[7]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "priority"); + return; + } + + if (strcmp(tokens[8], "weight") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "weight"); + return; + } + + if (softnic_parser_read_uint32(&weight, tokens[9]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "weight"); + return; + } + + tokens += 10; + n_tokens -= 10; + + if (n_tokens >= 2 && + (strcmp(tokens[0], "shaper") == 0) && + (strcmp(tokens[1], "profile") == 0)) { + if (n_tokens < 3) { + snprintf(out, out_size, MSG_ARG_MISMATCH, "tmgr node"); + return; + } + + if (strcmp(tokens[2], "none") == 0) { + np.shaper_profile_id = RTE_TM_SHAPER_PROFILE_ID_NONE; + } else { + if (softnic_parser_read_uint32(&np.shaper_profile_id, tokens[2]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shaper_profile_id"); + return; + } + } + + tokens += 3; + n_tokens -= 3; + } /* shaper profile */ + + if (n_tokens >= 2 && + (strcmp(tokens[0], "shared") == 0) && + (strcmp(tokens[1], "shaper") == 0)) { + if (n_tokens < 3) { + snprintf(out, out_size, MSG_ARG_MISMATCH, "tmgr node"); + return; + } + + if (softnic_parser_read_uint32(&shared_shaper_id, tokens[2]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared_shaper_id"); + return; + } + + np.shared_shaper_id = &shared_shaper_id; + np.n_shared_shapers = 1; + + tokens += 3; + n_tokens -= 3; + } /* shared shaper */ + + if (n_tokens >= 2 && + (strcmp(tokens[0], "nonleaf") == 0) && + (strcmp(tokens[1], "sp") == 0)) { + if (n_tokens < 3) { + snprintf(out, out_size, MSG_ARG_MISMATCH, "tmgr node"); + return; + } + + if (softnic_parser_read_uint32(&np.nonleaf.n_sp_priorities, tokens[2]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "n_sp_priorities"); + return; + } + + tokens += 3; + n_tokens -= 3; + } /* nonleaf sp */ + + if (n_tokens) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); + if (status != 0) + return; + + status = rte_tm_node_add(port_id, + node_id, + parent_node_id, + priority, + weight, + RTE_TM_NODE_LEVEL_ID_ANY, + &np, + &error); + if (status != 0) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + +/** * tmgr */ static void @@ -4154,6 +4319,12 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) cmd_tmgr_shared_shaper(softnic, tokens, n_tokens, out, out_size); return; } + + if (n_tokens >= 2 && + (strcmp(tokens[1], "node") == 0)) { + cmd_tmgr_node(softnic, tokens, n_tokens, out, out_size); + return; + } } if (strcmp(tokens[0], "tap") == 0) { From patchwork Wed Jul 25 17:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43375 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA0314B4B; Wed, 25 Jul 2018 19:10:23 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 5BAA2326C for ; Wed, 25 Jul 2018 19:10:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856164" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:14 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:06 +0100 Message-Id: <20180725171007.94198-6-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 5/6] net/softnic: add CLI command for tmgr hierarchy commit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support for Traffic Manager (TMGR) hierarchy commit through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_cli.c | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index d5485b5..4bd792b 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -503,6 +503,46 @@ cmd_tmgr_node(struct pmd_internals *softnic, } /** + * tmgr hierarchy commit + */ +static void +cmd_tmgr_hierarchy_commit(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct rte_tm_error error; + uint16_t port_id; + int status; + + if (n_tokens != 3) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "hierarchy") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "hierarchy"); + return; + } + + if (strcmp(tokens[2], "commit") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "commit"); + return; + } + + status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); + if (status != 0) + return; + + status = rte_tm_hierarchy_commit(port_id, 1, &error); + if (status) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + +/** * tmgr */ static void @@ -4325,6 +4365,13 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) cmd_tmgr_node(softnic, tokens, n_tokens, out, out_size); return; } + + if (n_tokens >= 3 && + (strcmp(tokens[1], "hierarchy") == 0) && + (strcmp(tokens[2], "commit") == 0)) { + cmd_tmgr_hierarchy_commit(softnic, tokens, n_tokens, out, out_size); + return; + } } if (strcmp(tokens[0], "tap") == 0) { From patchwork Wed Jul 25 17:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 43376 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 132694C8D; Wed, 25 Jul 2018 19:10:26 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id DF5CF378E for ; Wed, 25 Jul 2018 19:10:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2018 10:10:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,401,1526367600"; d="scan'208";a="69856173" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2018 10:10:15 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Wed, 25 Jul 2018 18:10:07 +0100 Message-Id: <20180725171007.94198-7-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180725171007.94198-1-jasvinder.singh@intel.com> References: <20180725171007.94198-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 6/6] net/softnic: add CLI command for default tmgr hierarchy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Cristian Dumitrescu Add support for creating default Traffic Manager (TMGR) hierarchy through firmware CLI script. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_cli.c | 498 ++++++++++++++++++++++++++++++ 1 file changed, 498 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 4bd792b..0c7448c 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -502,6 +502,498 @@ cmd_tmgr_node(struct pmd_internals *softnic, } } +static uint32_t +root_node_id(uint32_t n_spp, + uint32_t n_pps) +{ + uint32_t n_queues = n_spp * n_pps * RTE_SCHED_QUEUES_PER_PIPE; + uint32_t n_tc = n_spp * n_pps * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; + uint32_t n_pipes = n_spp * n_pps; + + return n_queues + n_tc + n_pipes + n_spp; +} + +static uint32_t +subport_node_id(uint32_t n_spp, + uint32_t n_pps, + uint32_t subport_id) +{ + uint32_t n_pipes = n_spp * n_pps; + uint32_t n_tc = n_pipes * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; + uint32_t n_queues = n_pipes * RTE_SCHED_QUEUES_PER_PIPE; + + return n_queues + n_tc + n_pipes + subport_id; +} + +static uint32_t +pipe_node_id(uint32_t n_spp, + uint32_t n_pps, + uint32_t subport_id, + uint32_t pipe_id) +{ + uint32_t n_pipes = n_spp * n_pps; + uint32_t n_tc = n_pipes * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; + uint32_t n_queues = n_pipes * RTE_SCHED_QUEUES_PER_PIPE; + + return n_queues + + n_tc + + pipe_id + + subport_id * n_pps; +} + +static uint32_t +tc_node_id(uint32_t n_spp, + uint32_t n_pps, + uint32_t subport_id, + uint32_t pipe_id, + uint32_t tc_id) +{ + uint32_t n_pipes = n_spp * n_pps; + uint32_t n_queues = n_pipes * RTE_SCHED_QUEUES_PER_PIPE; + + return n_queues + + tc_id + + (pipe_id + subport_id * n_pps) * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; +} + +static uint32_t +queue_node_id(uint32_t n_spp __rte_unused, + uint32_t n_pps, + uint32_t subport_id, + uint32_t pipe_id, + uint32_t tc_id, + uint32_t queue_id) +{ + return queue_id + + tc_id * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE + + (pipe_id + subport_id * n_pps) * RTE_SCHED_QUEUES_PER_PIPE; +} + +struct tmgr_hierarchy_default_params { + uint32_t n_spp; /**< Number of subports per port. */ + uint32_t n_pps; /**< Number of pipes per subport. */ + + struct { + uint32_t port; + uint32_t subport; + uint32_t pipe; + uint32_t tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + } shaper_profile_id; + + struct { + uint32_t tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + uint32_t tc_valid[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + } shared_shaper_id; + + struct { + uint32_t queue[RTE_SCHED_QUEUES_PER_PIPE]; + } weight; +}; + +static int +tmgr_hierarchy_default(struct pmd_internals *softnic, + struct tmgr_hierarchy_default_params *params) +{ + struct rte_tm_node_params root_node_params = { + .shaper_profile_id = params->shaper_profile_id.port, + .nonleaf = { + .n_sp_priorities = 1, + }, + }; + + struct rte_tm_node_params subport_node_params = { + .shaper_profile_id = params->shaper_profile_id.subport, + .nonleaf = { + .n_sp_priorities = 1, + }, + }; + + struct rte_tm_node_params pipe_node_params = { + .shaper_profile_id = params->shaper_profile_id.pipe, + .nonleaf = { + .n_sp_priorities = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE, + }, + }; + + struct rte_tm_node_params tc_node_params[] = { + [0] = { + .shaper_profile_id = params->shaper_profile_id.tc[0], + .shared_shaper_id = ¶ms->shared_shaper_id.tc[0], + .n_shared_shapers = + (¶ms->shared_shaper_id.tc_valid[0]) ? 1 : 0, + .nonleaf = { + .n_sp_priorities = 1, + }, + }, + + [1] = { + .shaper_profile_id = params->shaper_profile_id.tc[1], + .shared_shaper_id = ¶ms->shared_shaper_id.tc[1], + .n_shared_shapers = + (¶ms->shared_shaper_id.tc_valid[1]) ? 1 : 0, + .nonleaf = { + .n_sp_priorities = 1, + }, + }, + + [2] = { + .shaper_profile_id = params->shaper_profile_id.tc[2], + .shared_shaper_id = ¶ms->shared_shaper_id.tc[2], + .n_shared_shapers = + (¶ms->shared_shaper_id.tc_valid[2]) ? 1 : 0, + .nonleaf = { + .n_sp_priorities = 1, + }, + }, + + [3] = { + .shaper_profile_id = params->shaper_profile_id.tc[3], + .shared_shaper_id = ¶ms->shared_shaper_id.tc[3], + .n_shared_shapers = + (¶ms->shared_shaper_id.tc_valid[3]) ? 1 : 0, + .nonleaf = { + .n_sp_priorities = 1, + }, + }, + }; + + struct rte_tm_node_params queue_node_params = { + .shaper_profile_id = RTE_TM_SHAPER_PROFILE_ID_NONE, + }; + + struct rte_tm_error error; + uint32_t n_spp = params->n_spp, n_pps = params->n_pps, s; + int status; + uint16_t port_id; + + status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); + if (status) + return -1; + + /* Hierarchy level 0: Root node */ + status = rte_tm_node_add(port_id, + root_node_id(n_spp, n_pps), + RTE_TM_NODE_ID_NULL, + 0, + 1, + RTE_TM_NODE_LEVEL_ID_ANY, + &root_node_params, + &error); + if (status) + return -1; + + /* Hierarchy level 1: Subport nodes */ + for (s = 0; s < params->n_spp; s++) { + uint32_t p; + + status = rte_tm_node_add(port_id, + subport_node_id(n_spp, n_pps, s), + root_node_id(n_spp, n_pps), + 0, + 1, + RTE_TM_NODE_LEVEL_ID_ANY, + &subport_node_params, + &error); + if (status) + return -1; + + /* Hierarchy level 2: Pipe nodes */ + for (p = 0; p < params->n_pps; p++) { + uint32_t t; + + status = rte_tm_node_add(port_id, + pipe_node_id(n_spp, n_pps, s, p), + subport_node_id(n_spp, n_pps, s), + 0, + 1, + RTE_TM_NODE_LEVEL_ID_ANY, + &pipe_node_params, + &error); + if (status) + return -1; + + /* Hierarchy level 3: Traffic class nodes */ + for (t = 0; t < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; t++) { + uint32_t q; + + status = rte_tm_node_add(port_id, + tc_node_id(n_spp, n_pps, s, p, t), + pipe_node_id(n_spp, n_pps, s, p), + t, + 1, + RTE_TM_NODE_LEVEL_ID_ANY, + &tc_node_params[t], + &error); + if (status) + return -1; + + /* Hierarchy level 4: Queue nodes */ + for (q = 0; q < RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; q++) { + status = rte_tm_node_add(port_id, + queue_node_id(n_spp, n_pps, s, p, t, q), + tc_node_id(n_spp, n_pps, s, p, t), + 0, + params->weight.queue[q], + RTE_TM_NODE_LEVEL_ID_ANY, + &queue_node_params, + &error); + if (status) + return -1; + } /* Queue */ + } /* TC */ + } /* Pipe */ + } /* Subport */ + + return 0; +} + + +/** + * tmgr hierarchy-default + * spp + * pps + * shaper profile + * port + * subport + * pipe + * tc0 + * tc1 + * tc2 + * tc3 + * shared shaper + * tc0 + * tc1 + * tc2 + * tc3 + * weight + * queue ... + */ +static void +cmd_tmgr_hierarchy_default(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct tmgr_hierarchy_default_params p; + int i, status; + + memset(&p, 0, sizeof(p)); + + if (n_tokens != 50) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "hierarchy-default") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "hierarchy-default"); + return; + } + + if (strcmp(tokens[2], "spp") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "spp"); + return; + } + + if (softnic_parser_read_uint32(&p.n_spp, tokens[3]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "n_subports_per_port"); + return; + } + + if (strcmp(tokens[4], "pps") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps"); + return; + } + + if (softnic_parser_read_uint32(&p.n_pps, tokens[5]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport"); + return; + } + + /* Shaper profile */ + + if (strcmp(tokens[6], "shaper") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shaper"); + return; + } + + if (strcmp(tokens[7], "profile") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile"); + return; + } + + if (strcmp(tokens[8], "port") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.port, tokens[9]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "port profile id"); + return; + } + + if (strcmp(tokens[10], "subport") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "subport"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.subport, tokens[11]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "subport profile id"); + return; + } + + if (strcmp(tokens[12], "pipe") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipe"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.pipe, tokens[13]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipe_profile_id"); + return; + } + + if (strcmp(tokens[14], "tc0") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc0"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.tc[0], tokens[15]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "tc0 profile id"); + return; + } + + if (strcmp(tokens[16], "tc1") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc1"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.tc[1], tokens[17]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "tc1 profile id"); + return; + } + + if (strcmp(tokens[18], "tc2") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc2"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.tc[2], tokens[19]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "tc2 profile id"); + return; + } + + if (strcmp(tokens[20], "tc3") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc3"); + return; + } + + if (softnic_parser_read_uint32(&p.shaper_profile_id.tc[3], tokens[21]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "tc3 profile id"); + return; + } + + /* Shared shaper */ + + if (strcmp(tokens[22], "shared") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shared"); + return; + } + + if (strcmp(tokens[23], "shaper") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "shaper"); + return; + } + + if (strcmp(tokens[24], "tc0") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc0"); + return; + } + + if (strcmp(tokens[25], "none") == 0) + p.shared_shaper_id.tc_valid[0] = 0; + else { + if (softnic_parser_read_uint32(&p.shared_shaper_id.tc[0], tokens[25]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared shaper tc0"); + return; + } + + p.shared_shaper_id.tc_valid[0] = 1; + } + + if (strcmp(tokens[26], "tc1") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc1"); + return; + } + + if (strcmp(tokens[27], "none") == 0) + p.shared_shaper_id.tc_valid[1] = 0; + else { + if (softnic_parser_read_uint32(&p.shared_shaper_id.tc[1], tokens[27]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared shaper tc1"); + return; + } + + p.shared_shaper_id.tc_valid[1] = 1; + } + + if (strcmp(tokens[28], "tc2") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc2"); + return; + } + + if (strcmp(tokens[29], "none") == 0) + p.shared_shaper_id.tc_valid[2] = 0; + else { + if (softnic_parser_read_uint32(&p.shared_shaper_id.tc[2], tokens[29]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared shaper tc2"); + return; + } + + p.shared_shaper_id.tc_valid[2] = 1; + } + + if (strcmp(tokens[30], "tc3") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "tc3"); + return; + } + + if (strcmp(tokens[31], "none") == 0) + p.shared_shaper_id.tc_valid[3] = 0; + else { + if (softnic_parser_read_uint32(&p.shared_shaper_id.tc[3], tokens[31]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "shared shaper tc3"); + return; + } + + p.shared_shaper_id.tc_valid[3] = 1; + } + + /* Weight */ + + if (strcmp(tokens[32], "weight") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "weight"); + return; + } + + if (strcmp(tokens[33], "queue") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "queue"); + return; + } + + for (i = 0; i < 16; i++) { + if (softnic_parser_read_uint32(&p.weight.queue[i], tokens[34 + i]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "weight queue"); + return; + } + } + + status = tmgr_hierarchy_default(softnic, &p); + if (status != 0) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + /** * tmgr hierarchy commit */ @@ -4366,6 +4858,12 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) return; } + if (n_tokens >= 2 && + (strcmp(tokens[1], "hierarchy-default") == 0)) { + cmd_tmgr_hierarchy_default(softnic, tokens, n_tokens, out, out_size); + return; + } + if (n_tokens >= 3 && (strcmp(tokens[1], "hierarchy") == 0) && (strcmp(tokens[2], "commit") == 0)) {