app/testpmd: add Rx HW timestamp
[dpdk.git] / app / test-pmd / cmdline.c
index 20e04f7..f996ee3 100644 (file)
@@ -637,6 +637,11 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "E-tag set filter del e-tag-id (value) port (port_id)\n"
                        "    Delete an E-tag forwarding filter on a port\n\n"
 
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+                       "set port tm hierarchy default (port_id)\n"
+                       "       Set default traffic Management hierarchy on a port\n\n"
+
+#endif
                        "ddp add (port_id) (profile_path[,output_path])\n"
                        "    Load a profile package on a port\n\n"
 
@@ -693,7 +698,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "port config all max-pkt-len (value)\n"
                        "    Set the max packet length.\n\n"
 
-                       "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
+                       "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
                        "hw-vlan-strip|hw-vlan-extend|drop-en)"
                        " (on|off)\n"
                        "    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
@@ -1614,6 +1619,15 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
                        printf("Unknown parameter\n");
                        return;
                }
+       } else if (!strcmp(res->name, "rx-timestamp")) {
+               if (!strcmp(res->value, "on"))
+                       rx_mode.hw_timestamp = 1;
+               else if (!strcmp(res->value, "off"))
+                       rx_mode.hw_timestamp = 0;
+               else {
+                       printf("Unknown parameter\n");
+                       return;
+               }
        } else if (!strcmp(res->name, "hw-vlan")) {
                if (!strcmp(res->value, "on")) {
                        rx_mode.hw_vlan_filter = 1;
@@ -1682,7 +1696,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
-                                       "crc-strip#scatter#rx-cksum#hw-vlan#"
+                                       "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
                                        "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
@@ -1691,7 +1705,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
        .f = cmd_config_rx_mode_flag_parsed,
        .data = NULL,
-       .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
+       .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
                "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
        .tokens = {
                (void *)&cmd_config_rx_mode_flag_port,
@@ -13424,6 +13438,86 @@ cmdline_parse_inst_t cmd_vf_tc_max_bw = {
        },
 };
 
+
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+
+/* *** Set Port default Traffic Management Hierarchy *** */
+struct cmd_set_port_tm_hierarchy_default_result {
+       cmdline_fixed_string_t set;
+       cmdline_fixed_string_t port;
+       cmdline_fixed_string_t tm;
+       cmdline_fixed_string_t hierarchy;
+       cmdline_fixed_string_t def;
+       uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result, set, "set");
+cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result, port, "port");
+cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
+cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result,
+                       hierarchy, "hierarchy");
+cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
+       TOKEN_STRING_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result,
+                       def, "default");
+cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
+       TOKEN_NUM_INITIALIZER(
+               struct cmd_set_port_tm_hierarchy_default_result,
+                       port_id, UINT8);
+
+static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
+       struct rte_port *p;
+       uint16_t port_id = res->port_id;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN))
+               return;
+
+       p = &ports[port_id];
+
+       /* Port tm flag */
+       if (p->softport.tm_flag == 0) {
+               printf("  tm not enabled on port %u (error)\n", port_id);
+               return;
+       }
+
+       /* Forward mode: tm */
+       if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
+               printf("  tm mode not enabled(error)\n");
+               return;
+       }
+
+       /* Set the default tm hierarchy */
+       p->softport.tm.default_hierarchy_enable = 1;
+}
+
+cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
+       .f = cmd_set_port_tm_hierarchy_default_parsed,
+       .data = NULL,
+       .help_str = "set port tm hierarchy default <port_id>",
+       .tokens = {
+               (void *)&cmd_set_port_tm_hierarchy_default_set,
+               (void *)&cmd_set_port_tm_hierarchy_default_port,
+               (void *)&cmd_set_port_tm_hierarchy_default_tm,
+               (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
+               (void *)&cmd_set_port_tm_hierarchy_default_default,
+               (void *)&cmd_set_port_tm_hierarchy_default_port_id,
+               NULL,
+       },
+};
+#endif
+
 /* Strict link priority scheduling mode setting */
 static void
 cmd_strict_link_prio_parsed(
@@ -13843,8 +13937,8 @@ no_print_pctypes:
 
        free(proto);
        ret = 0;
-#endif
 no_print_return:
+#endif
        if (ret == -ENOTSUP)
                printf("Function not supported in PMD driver\n");
        close_ddp_package_file(pkg);
@@ -14390,17 +14484,16 @@ cmd_pctype_mapping_update_parsed(
 #ifdef RTE_LIBRTE_I40E_PMD
        struct rte_pmd_i40e_flow_type_mapping mapping;
        unsigned int i;
-#endif
        unsigned int nb_item;
        unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
+#endif
 
        if (port_id_is_invalid(res->port_id, ENABLED_WARN))
                return;
 
+#ifdef RTE_LIBRTE_I40E_PMD
        nb_item = parse_item_list(res->pctype_list, "pctypes",
                                  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
-
-#ifdef RTE_LIBRTE_I40E_PMD
        mapping.flow_type = res->flow_type;
        for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
                mapping.pctype |= (1ULL << pctype_list[i]);
@@ -15020,6 +15113,9 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
        (cmdline_parse_inst_t *)&cmd_strict_link_prio,
        (cmdline_parse_inst_t *)&cmd_tc_min_bw,
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+       (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
+#endif
        (cmdline_parse_inst_t *)&cmd_ddp_add,
        (cmdline_parse_inst_t *)&cmd_ddp_del,
        (cmdline_parse_inst_t *)&cmd_ddp_get_list,