app/testpmd: add command to suspend a TM node
authorTomasz Duszynski <tdu@semihalf.com>
Mon, 19 Feb 2018 07:46:18 +0000 (08:46 +0100)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Fri, 4 May 2018 14:37:54 +0000 (16:37 +0200)
Traffic manager provides an API for suspending
an arbitrary node in a hierarchy.

This commit adds support for calling this API from testpmd.

Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
Reviewed-by: Jasvinder Singh <jasvinder.singh@intel.com>
app/test-pmd/cmdline.c
app/test-pmd/cmdline_tm.c
app/test-pmd/cmdline_tm.h
doc/guides/testpmd_app_ug/testpmd_funcs.rst

index 9615670..0daed36 100644 (file)
@@ -771,6 +771,9 @@ static void cmd_help_long_parsed(void *parsed_result,
                        " (priority) (weight)\n"
                        "       Set port tm node parent.\n\n"
 
+                       "suspend port tm node (port_id) (node_id)"
+                       "       Suspend tm node.\n\n"
+
                        "port tm hierarchy commit (port_id) (clean_on_fail)\n"
                        "       Commit tm hierarchy.\n\n"
 
@@ -16693,6 +16696,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (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_suspend_port_tm_node,
        (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
        (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
        NULL,
index 9859c3d..972f4bc 100644 (file)
@@ -1966,6 +1966,70 @@ cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
        },
 };
 
+/* *** Suspend Port TM Node *** */
+struct cmd_suspend_port_tm_node_result {
+       cmdline_fixed_string_t suspend;
+       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_suspend_port_tm_node_suspend =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, suspend, "suspend");
+cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, port, "port");
+cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, tm, "tm");
+cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, node, "node");
+cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
+       TOKEN_NUM_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, port_id, UINT16);
+cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
+       TOKEN_NUM_INITIALIZER(
+               struct cmd_suspend_port_tm_node_result, node_id, UINT32);
+
+static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_suspend_port_tm_node_result *res = parsed_result;
+       struct rte_tm_error error;
+       uint32_t node_id = res->node_id;
+       portid_t port_id = res->port_id;
+       int ret;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN))
+               return;
+
+       ret = rte_tm_node_suspend(port_id, node_id, &error);
+       if (ret != 0) {
+               print_err_msg(&error);
+               return;
+       }
+}
+
+cmdline_parse_inst_t cmd_suspend_port_tm_node = {
+       .f = cmd_suspend_port_tm_node_parsed,
+       .data = NULL,
+       .help_str = "Suspend port tm node",
+       .tokens = {
+               (void *)&cmd_suspend_port_tm_node_suspend,
+               (void *)&cmd_suspend_port_tm_node_port,
+               (void *)&cmd_suspend_port_tm_node_tm,
+               (void *)&cmd_suspend_port_tm_node_node,
+               (void *)&cmd_suspend_port_tm_node_port_id,
+               (void *)&cmd_suspend_port_tm_node_node_id,
+               NULL,
+       },
+};
+
 /* *** Port TM Hierarchy Commit *** */
 struct cmd_port_tm_hierarchy_commit_result {
        cmdline_fixed_string_t port;
index ba30360..c4d5e8c 100644 (file)
@@ -22,6 +22,7 @@ extern cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node;
 extern cmdline_parse_inst_t cmd_add_port_tm_leaf_node;
 extern cmdline_parse_inst_t cmd_del_port_tm_node;
 extern cmdline_parse_inst_t cmd_set_port_tm_node_parent;
+extern cmdline_parse_inst_t cmd_suspend_port_tm_node;
 extern cmdline_parse_inst_t cmd_port_tm_hierarchy_commit;
 
 #endif /* _CMDLINE_TM_H_ */
index 013a405..23475ba 100644 (file)
@@ -2507,6 +2507,11 @@ success depends on the port support for this operation, as advertised through
 the port capability set. This function is valid for all nodes of the traffic
 management hierarchy except root node.
 
+Suspend port traffic management hierarchy node
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+   testpmd> suspend port tm node (port_id) (node_id)
+
 Commit port traffic management hierarchy
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~