From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4D4191B19B for ; Wed, 11 Oct 2017 10:40:41 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 01:40:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="161798163" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 11 Oct 2017 01:40:36 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 11 Oct 2017 01:40:36 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 11 Oct 2017 01:40:36 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Wed, 11 Oct 2017 16:40:33 +0800 From: "Pei, Yulong" To: "Singh, Jasvinder" , "dev@dpdk.org" CC: "Dumitrescu, Cristian" , "Wu, Jingjing" , "De Lara Guarch, Pablo" Thread-Topic: [dpdk-dev] [PATCH v6 3/3] app/test-pmd: add CLI for TM nodes and hierarchy commit Thread-Index: AQHTQTBAuGMO+foYsEyK8FakvS8Y2aLeVk+A Date: Wed, 11 Oct 2017 08:40:32 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F03C0E14DF@SHSMSX104.ccr.corp.intel.com> References: <20170929123829.81964-1-jasvinder.singh@intel.com> <20171009190750.6697-1-jasvinder.singh@intel.com> <20171009190750.6697-3-jasvinder.singh@intel.com> In-Reply-To: <20171009190750.6697-3-jasvinder.singh@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzBlNjVmMGEtY2VkMy00ZDcxLWFlYzgtMDk1YTVkOWQ2MDZhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImVUUUMxWFJNeW9CUjBCUXBBakFPOXpEUnBLSm1IM3VpaHV1T21EUjkxRXc9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6 3/3] app/test-pmd: add CLI for TM nodes and 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: , X-List-Received-Date: Wed, 11 Oct 2017 08:40:42 -0000 Hi Jasvinder, -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jasvinder Singh Sent: Tuesday, October 10, 2017 3:08 AM To: dev@dpdk.org Cc: Dumitrescu, Cristian ; Wu, Jingjing ; De Lara Guarch, Pablo Subject: [dpdk-dev] [PATCH v6 3/3] app/test-pmd: add CLI for TM nodes and h= ierarchy commit Add following CLIs in testpmd application for device traffic management; - commands to add TM hierarchy nodes (leaf and nonleaf). - command for runtime update of node weight. - command to commit the TM hierarchy Signed-off-by: Jasvinder Singh Acked-by: Cristian Dumitrescu --- v5 change: - add shaper related parameters to leaf node add command v4 change: - remove softnic specific checks to make it generic for the devices app/test-pmd/cmdline.c | 27 +++ app/test-pmd/cmdline_tm.c | 526 ++++++++++++++++++++++++++++++++++++++++++= ++++ app/test-pmd/cmdline_tm.h | 5 + 3 files changed, 558 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d89583c.= .c6b35ba 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -683,6 +683,28 @@ static void cmd_help_long_parsed(void *parsed_result, "del port tm node wred profile (port_id) (wred_profile_id)\n" " Delete port tm node wred profile.\n\n" =20 + "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" + " (priority) (weight) (level_id) (shaper_profile_id)" + " (shared_shaper_id) (n_shared_shapers) (n_sp_priorities)" + " (stats_mask)\n" + " Add port tm nonleaf node.\n\n" + + "add port tm leaf node (port_id) (node_id) (parent_node_id)" + " (priority) (weight) (level_id) (shaper_profile_id)" + " (shared_shaper_id) (n_shared_shapers) (n_sp_priorities)" + " (cman_mode) (wred_profile_id) (stats_mask)\n" + " Add port tm leaf node.\n\n" + For leaf node , it should not have "n_sp_priorities" parameter. Best Regards Yulong Pei + "del port tm node (port_id) (node_id)\n" + " Delete port tm node.\n\n" + + "set port tm node parent (port_id) (node_id) (parent_node_id)" + " (priority) (weight)\n" + " Set port tm node parent.\n\n" + + "port tm hierarchy commit (port_id) (clean_on_fail)\n" + " Commit tm hierarchy.\n\n" + , list_pkt_forwarding_modes() ); } @@ -14872,6 +14894,11 @@ cmdline_parse_ctx_t main_ctx[] =3D { (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, + (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, + (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, + (cmdline_parse_inst_t *)&cmd_del_port_tm_node, + (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, + (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, NULL, }; =20 diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c index f1= cd810..a8b7c20 100644 --- a/app/test-pmd/cmdline_tm.c +++ b/app/test-pmd/cmdline_tm.c @@ -1427,3 +1427,529 @@ cmdline_parse_inst_t cmd_set_port_tm_node_shaper_pr= ofile =3D { NULL, }, }; + +/* *** Add Port TM nonleaf node *** */ +struct cmd_add_port_tm_nonleaf_node_result { + cmdline_fixed_string_t add; + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t nonleaf; + cmdline_fixed_string_t node; + uint16_t port_id; + uint32_t node_id; + int32_t parent_node_id; + uint32_t priority; + uint32_t weight; + uint32_t level_id; + uint32_t shaper_profile_id; + uint32_t shared_shaper_id; + uint32_t n_shared_shapers; + uint32_t n_sp_priorities; + uint64_t stats_mask; +}; + +cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, add, "add");=20 +cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, port, "port");=20 +cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");=20 +cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");=20 +cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, node, "node");=20 +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =3D + TOKEN_NUM_INITIALIZER( + struct cmd_add_port_tm_nonleaf_node_result, + port_id, UINT16); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + node_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + parent_node_id, INT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + priority, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + weight, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + level_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id = =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + shaper_profile_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shared_shaper_id = =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + shared_shaper_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_shared_shapers = =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + n_shared_shapers, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + n_sp_priorities, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result, + stats_mask, UINT64); + +static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_add_port_tm_nonleaf_node_result *res =3D parsed_result; + struct rte_tm_error error; + struct rte_tm_node_params np; + uint32_t parent_node_id; + portid_t port_id =3D res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Port status */ + if (port_is_started(port_id)) { + printf(" Port %u not stopped (error)\n", port_id); + return; + } + + /* Node parameters */ + if (res->parent_node_id < 0) + parent_node_id =3D UINT32_MAX; + else + parent_node_id =3D res->parent_node_id; + + memset(&np, 0, sizeof(struct rte_tm_node_params)); + np.shaper_profile_id =3D res->shaper_profile_id; + np.n_shared_shapers =3D res->n_shared_shapers; + + if (np.n_shared_shapers =3D=3D 1) + np.shared_shaper_id[0] =3D res->shared_shaper_id; + else + np.shared_shaper_id =3D NULL; + + np.nonleaf.n_sp_priorities =3D res->n_sp_priorities; + np.stats_mask =3D res->stats_mask; + np.nonleaf.wfq_weight_mode =3D NULL; + + ret =3D rte_tm_node_add(port_id, res->node_id, parent_node_id, + res->priority, res->weight, res->level_id, + &np, &error); + if (ret !=3D 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node =3D { + .f =3D cmd_add_port_tm_nonleaf_node_parsed, + .data =3D NULL, + .help_str =3D "Add port tm nonleaf node", + .tokens =3D { + (void *)&cmd_add_port_tm_nonleaf_node_add, + (void *)&cmd_add_port_tm_nonleaf_node_port, + (void *)&cmd_add_port_tm_nonleaf_node_tm, + (void *)&cmd_add_port_tm_nonleaf_node_nonleaf, + (void *)&cmd_add_port_tm_nonleaf_node_node, + (void *)&cmd_add_port_tm_nonleaf_node_port_id, + (void *)&cmd_add_port_tm_nonleaf_node_node_id, + (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id, + (void *)&cmd_add_port_tm_nonleaf_node_priority, + (void *)&cmd_add_port_tm_nonleaf_node_weight, + (void *)&cmd_add_port_tm_nonleaf_node_level_id, + (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id, + (void *)&cmd_add_port_tm_nonleaf_node_shared_shaper_id, + (void *)&cmd_add_port_tm_nonleaf_node_n_shared_shapers, + (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities, + (void *)&cmd_add_port_tm_nonleaf_node_stats_mask, + NULL, + }, +}; + +/* *** Add Port TM leaf node *** */ +struct cmd_add_port_tm_leaf_node_result { + cmdline_fixed_string_t add; + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t leaf; + cmdline_fixed_string_t node; + uint16_t port_id; + uint32_t node_id; + int32_t parent_node_id; + uint32_t priority; + uint32_t weight; + uint32_t level_id; + uint32_t shaper_profile_id; + uint32_t shared_shaper_id; + uint32_t n_shared_shapers; + uint32_t cman_mode; + uint32_t wred_profile_id; + uint64_t stats_mask; +}; + +cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_leaf_node_result, add, "add");=20 +cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_leaf_node_result, port, "port");=20 +cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_leaf_node_result, tm, "tm");=20 +cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");=20 +cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =3D + TOKEN_STRING_INITIALIZER( + struct cmd_add_port_tm_leaf_node_result, node, "node");=20 +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + port_id, UINT16); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + node_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + parent_node_id, INT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + priority, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + weight, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + level_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + shaper_profile_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shared_shaper_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + shared_shaper_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_n_shared_shapers =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + n_shared_shapers, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + cman_mode, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + wred_profile_id, UINT32); +cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =3D + TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result, + stats_mask, UINT64); + +static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_add_port_tm_leaf_node_result *res =3D parsed_result; + struct rte_tm_error error; + struct rte_tm_node_params np; + uint32_t parent_node_id; + portid_t port_id =3D res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Port status */ + if (port_is_started(port_id)) { + printf(" Port %u not stopped (error)\n", port_id); + return; + } + + /* Node parameters */ + if (res->parent_node_id < 0) + parent_node_id =3D UINT32_MAX; + else + parent_node_id =3D res->parent_node_id; + + memset(&np, 0, sizeof(struct rte_tm_node_params)); + np.shaper_profile_id =3D res->shaper_profile_id; + np.n_shared_shapers =3D res->n_shared_shapers; + + if (np.n_shared_shapers =3D=3D 1) + np.shared_shaper_id[0] =3D res->shared_shaper_id; + else + np.shared_shaper_id =3D NULL; + + np.leaf.cman =3D res->cman_mode; + np.leaf.wred.wred_profile_id =3D res->wred_profile_id; + np.stats_mask =3D res->stats_mask; + + ret =3D rte_tm_node_add(port_id, res->node_id, parent_node_id, + res->priority, res->weight, res->level_id, + &np, &error); + if (ret !=3D 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_add_port_tm_leaf_node =3D { + .f =3D cmd_add_port_tm_leaf_node_parsed, + .data =3D NULL, + .help_str =3D "Add port tm leaf node", + .tokens =3D { + (void *)&cmd_add_port_tm_leaf_node_add, + (void *)&cmd_add_port_tm_leaf_node_port, + (void *)&cmd_add_port_tm_leaf_node_tm, + (void *)&cmd_add_port_tm_leaf_node_nonleaf, + (void *)&cmd_add_port_tm_leaf_node_node, + (void *)&cmd_add_port_tm_leaf_node_port_id, + (void *)&cmd_add_port_tm_leaf_node_node_id, + (void *)&cmd_add_port_tm_leaf_node_parent_node_id, + (void *)&cmd_add_port_tm_leaf_node_priority, + (void *)&cmd_add_port_tm_leaf_node_weight, + (void *)&cmd_add_port_tm_leaf_node_level_id, + (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id, + (void *)&cmd_add_port_tm_leaf_node_shared_shaper_id, + (void *)&cmd_add_port_tm_leaf_node_n_shared_shapers, + (void *)&cmd_add_port_tm_leaf_node_cman_mode, + (void *)&cmd_add_port_tm_leaf_node_wred_profile_id, + (void *)&cmd_add_port_tm_leaf_node_stats_mask, + NULL, + }, +}; + +/* *** Delete Port TM Node *** */ +struct cmd_del_port_tm_node_result { + cmdline_fixed_string_t del; + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t node; + uint16_t port_id; + uint32_t node_id; +}; + +cmdline_parse_token_string_t cmd_del_port_tm_node_del =3D + TOKEN_STRING_INITIALIZER( + struct cmd_del_port_tm_node_result, del, "del");=20 +cmdline_parse_token_string_t cmd_del_port_tm_node_port =3D + TOKEN_STRING_INITIALIZER( + struct cmd_del_port_tm_node_result, port, "port");=20 +cmdline_parse_token_string_t cmd_del_port_tm_node_tm =3D + TOKEN_STRING_INITIALIZER( + struct cmd_del_port_tm_node_result, tm, "tm");=20 +cmdline_parse_token_string_t cmd_del_port_tm_node_node =3D + TOKEN_STRING_INITIALIZER( + struct cmd_del_port_tm_node_result, node, "node");=20 +cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result, + port_id, UINT16); +cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result, + node_id, UINT32); + +static void cmd_del_port_tm_node_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_del_port_tm_node_result *res =3D parsed_result; + struct rte_tm_error error; + uint32_t node_id =3D res->node_id; + portid_t port_id =3D res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Port status */ + if (port_is_started(port_id)) { + printf(" Port %u not stopped (error)\n", port_id); + return; + } + + ret =3D rte_tm_node_delete(port_id, node_id, &error); + if (ret !=3D 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_del_port_tm_node =3D { + .f =3D cmd_del_port_tm_node_parsed, + .data =3D NULL, + .help_str =3D "Delete port tm node", + .tokens =3D { + (void *)&cmd_del_port_tm_node_del, + (void *)&cmd_del_port_tm_node_port, + (void *)&cmd_del_port_tm_node_tm, + (void *)&cmd_del_port_tm_node_node, + (void *)&cmd_del_port_tm_node_port_id, + (void *)&cmd_del_port_tm_node_node_id, + NULL, + }, +}; + +/* *** Update Port TM Node Parent *** */ struct=20 +cmd_set_port_tm_node_parent_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t node; + cmdline_fixed_string_t parent; + uint16_t port_id; + uint32_t node_id; + uint32_t parent_id; + uint32_t priority; + uint32_t weight; +}; + +cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =3D + TOKEN_STRING_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, set, "set");=20 +cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =3D + TOKEN_STRING_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, port, "port");=20 +cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =3D + TOKEN_STRING_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, tm, "tm");=20 +cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =3D + TOKEN_STRING_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, node, "node");=20 +cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =3D + TOKEN_STRING_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, parent, "parent");=20 +cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =3D + TOKEN_NUM_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, port_id, UINT16);=20 +cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =3D + TOKEN_NUM_INITIALIZER( + struct cmd_set_port_tm_node_parent_result, node_id, UINT32);=20 +cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =3D + TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result, + parent_id, UINT32); +cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =3D + TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result, + priority, UINT32); +cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =3D + TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result, + weight, UINT32); + +static void cmd_set_port_tm_node_parent_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_port_tm_node_parent_result *res =3D parsed_result; + struct rte_tm_error error; + uint32_t node_id =3D res->node_id; + uint32_t parent_id =3D res->parent_id; + uint32_t priority =3D res->priority; + uint32_t weight =3D res->weight; + portid_t port_id =3D res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Port status */ + if (!port_is_started(port_id)) { + printf(" Port %u not started (error)\n", port_id); + return; + } + + ret =3D rte_tm_node_parent_update(port_id, node_id, + parent_id, priority, weight, &error); + if (ret !=3D 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_set_port_tm_node_parent =3D { + .f =3D cmd_set_port_tm_node_parent_parsed, + .data =3D NULL, + .help_str =3D "Set port tm node parent", + .tokens =3D { + (void *)&cmd_set_port_tm_node_parent_set, + (void *)&cmd_set_port_tm_node_parent_port, + (void *)&cmd_set_port_tm_node_parent_tm, + (void *)&cmd_set_port_tm_node_parent_node, + (void *)&cmd_set_port_tm_node_parent_parent, + (void *)&cmd_set_port_tm_node_parent_port_id, + (void *)&cmd_set_port_tm_node_parent_node_id, + (void *)&cmd_set_port_tm_node_parent_parent_id, + (void *)&cmd_set_port_tm_node_parent_priority, + (void *)&cmd_set_port_tm_node_parent_weight, + NULL, + }, +}; + +/* *** Port TM Hierarchy Commit *** */ +struct cmd_port_tm_hierarchy_commit_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t hierarchy; + cmdline_fixed_string_t commit; + uint16_t port_id; + uint32_t clean_on_fail; +}; + +cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =3D + TOKEN_STRING_INITIALIZER( + struct cmd_port_tm_hierarchy_commit_result, port, "port");=20 +cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =3D + TOKEN_STRING_INITIALIZER( + struct cmd_port_tm_hierarchy_commit_result, tm, "tm");=20 +cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =3D + TOKEN_STRING_INITIALIZER( + struct cmd_port_tm_hierarchy_commit_result, + hierarchy, "hierarchy"); +cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =3D + TOKEN_STRING_INITIALIZER( + struct cmd_port_tm_hierarchy_commit_result, commit, "commit");=20 +cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =3D + TOKEN_NUM_INITIALIZER( + struct cmd_port_tm_hierarchy_commit_result, + port_id, UINT16); +cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_clean_on_fail =3D + TOKEN_NUM_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result, + clean_on_fail, UINT32); + +static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_port_tm_hierarchy_commit_result *res =3D parsed_result; + struct rte_tm_error error; + uint32_t clean_on_fail =3D res->clean_on_fail; + portid_t port_id =3D res->port_id; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + /* Port status */ + if (port_is_started(port_id)) { + printf(" Port %u not stopped (error)\n", port_id); + return; + } + + ret =3D rte_tm_hierarchy_commit(port_id, clean_on_fail, &error); + if (ret !=3D 0) { + print_err_msg(&error); + return; + } +} + +cmdline_parse_inst_t cmd_port_tm_hierarchy_commit =3D { + .f =3D cmd_port_tm_hierarchy_commit_parsed, + .data =3D NULL, + .help_str =3D "Set port tm node shaper profile", + .tokens =3D { + (void *)&cmd_port_tm_hierarchy_commit_port, + (void *)&cmd_port_tm_hierarchy_commit_tm, + (void *)&cmd_port_tm_hierarchy_commit_hierarchy, + (void *)&cmd_port_tm_hierarchy_commit_commit, + (void *)&cmd_port_tm_hierarchy_commit_port_id, + (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail, + NULL, + }, +}; diff --git a/app/test-pmd/cmdline_tm.h b/app/test-pmd/cmdline_tm.h index 5e= d9de0..9d5fdf0 100644 --- a/app/test-pmd/cmdline_tm.h +++ b/app/test-pmd/cmdline_tm.h @@ -47,5 +47,10 @@ extern cmdline_parse_inst_t cmd_del_port_tm_node_shared_= shaper; extern cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile; extern cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile; extern cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile; +extern cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node; extern=20 +cmdline_parse_inst_t cmd_add_port_tm_leaf_node; extern=20 +cmdline_parse_inst_t cmd_del_port_tm_node; extern cmdline_parse_inst_t=20 +cmd_set_port_tm_node_parent; extern cmdline_parse_inst_t=20 +cmd_port_tm_hierarchy_commit; =20 #endif /* _CMDLINE_TM_H_ */ -- 2.9.3