ethdev: increase port id range
[dpdk.git] / app / test-pmd / cmdline.c
index cd8c358..91766bc 100644 (file)
@@ -230,6 +230,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 
                        "clear vf stats (port_id) (vf_id)\n"
                        "    Reset a VF's statistics.\n\n"
+
+                       "show port (port_id) pctype mapping\n"
+                       "    Get flow ptype to pctype mapping on a port\n\n"
+
                );
        }
 
@@ -681,7 +685,8 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
                        " for ports.\n\n"
 
-                       "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
+                       "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
+                       "geneve|nvgre|none|<flowtype_id>)\n"
                        "    Set the RSS mode.\n\n"
 
                        "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -716,6 +721,13 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "port config (port_id|all) l2-tunnel E-tag"
                        " (enable|disable)\n"
                        "    Enable/disable the E-tag support.\n\n"
+
+                       "port config (port_id) pctype mapping reset\n"
+                       "    Reset flow type to pctype mapping on a port\n\n"
+
+                       "port config (port_id) pctype mapping update"
+                       " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
+                       "    Update a flow type to pctype mapping item on a port\n\n"
                );
        }
 
@@ -878,8 +890,8 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
                        "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
                        "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
-                       "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
-                       "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
+                       "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
+                       "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
                        "ipv6-next-header|udp-src-port|udp-dst-port|"
                        "tcp-src-port|tcp-dst-port|sctp-src-port|"
                        "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
@@ -972,6 +984,8 @@ static void cmd_operate_port_parsed(void *parsed_result,
                stop_port(RTE_PORT_ALL);
        else if (!strcmp(res->name, "close"))
                close_port(RTE_PORT_ALL);
+       else if (!strcmp(res->name, "reset"))
+               reset_port(RTE_PORT_ALL);
        else
                printf("Unknown parameter\n");
 }
@@ -981,14 +995,14 @@ cmdline_parse_token_string_t cmd_operate_port_all_cmd =
                                                                "port");
 cmdline_parse_token_string_t cmd_operate_port_all_port =
        TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
-                                               "start#stop#close");
+                                               "start#stop#close#reset");
 cmdline_parse_token_string_t cmd_operate_port_all_all =
        TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
 
 cmdline_parse_inst_t cmd_operate_port = {
        .f = cmd_operate_port_parsed,
        .data = NULL,
-       .help_str = "port start|stop|close all: Start/Stop/Close all ports",
+       .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
        .tokens = {
                (void *)&cmd_operate_port_all_cmd,
                (void *)&cmd_operate_port_all_port,
@@ -1016,6 +1030,8 @@ static void cmd_operate_specific_port_parsed(void *parsed_result,
                stop_port(res->value);
        else if (!strcmp(res->name, "close"))
                close_port(res->value);
+       else if (!strcmp(res->name, "reset"))
+               reset_port(res->value);
        else
                printf("Unknown parameter\n");
 }
@@ -1025,7 +1041,7 @@ cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
                                                        keyword, "port");
 cmdline_parse_token_string_t cmd_operate_specific_port_port =
        TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
-                                               name, "start#stop#close");
+                                               name, "start#stop#close#reset");
 cmdline_parse_token_num_t cmd_operate_specific_port_id =
        TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
                                                        value, UINT8);
@@ -1033,7 +1049,7 @@ cmdline_parse_token_num_t cmd_operate_specific_port_id =
 cmdline_parse_inst_t cmd_operate_specific_port = {
        .f = cmd_operate_specific_port_parsed,
        .data = NULL,
-       .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
+       .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
        .tokens = {
                (void *)&cmd_operate_specific_port_cmd,
                (void *)&cmd_operate_specific_port_port,
@@ -1716,6 +1732,9 @@ cmd_config_rss_parsed(void *parsed_result,
                rss_conf.rss_hf = ETH_RSS_NVGRE;
        else if (!strcmp(res->value, "none"))
                rss_conf.rss_hf = 0;
+       else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
+                                               atoi(res->value) < 64)
+               rss_conf.rss_hf = 1ULL << atoi(res->value);
        else {
                printf("Unknown parameter\n");
                return;
@@ -1739,14 +1758,13 @@ cmdline_parse_token_string_t cmd_config_rss_all =
 cmdline_parse_token_string_t cmd_config_rss_name =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
 cmdline_parse_token_string_t cmd_config_rss_value =
-       TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
-               "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
+       TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
 
 cmdline_parse_inst_t cmd_config_rss = {
        .f = cmd_config_rss_parsed,
        .data = NULL,
        .help_str = "port config all rss "
-               "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
+               "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
        .tokens = {
                (void *)&cmd_config_rss_port,
                (void *)&cmd_config_rss_keyword,
@@ -4584,7 +4602,7 @@ struct cmd_show_bonding_config_result {
        cmdline_fixed_string_t show;
        cmdline_fixed_string_t bonding;
        cmdline_fixed_string_t config;
-       uint8_t port_id;
+       portid_t port_id;
 };
 
 static void cmd_show_bonding_config_parsed(void *parsed_result,
@@ -4593,7 +4611,7 @@ static void cmd_show_bonding_config_parsed(void *parsed_result,
 {
        struct cmd_show_bonding_config_result *res = parsed_result;
        int bonding_mode, agg_mode;
-       uint8_t slaves[RTE_MAX_ETHPORTS];
+       portid_t slaves[RTE_MAX_ETHPORTS];
        int num_slaves, num_active_slaves;
        int primary_id;
        int i;
@@ -6960,7 +6978,7 @@ cmd_set_vf_macvlan_parsed(void *parsed_result,
 
        memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
 
-       (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
+       rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
 
        /* set VF MAC filter */
        filter.is_vf = 1;
@@ -7209,11 +7227,22 @@ static void cmd_vf_mac_addr_parsed(void *parsed_result,
                __attribute__((unused)) void *data)
 {
        struct cmd_vf_mac_addr_result *res = parsed_result;
-       int ret = 0;
+       int ret = -ENOTSUP;
+
+       if (strcmp(res->what, "add") != 0)
+               return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       if (ret == -ENOTSUP)
+               ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
+                                                  &res->address);
+#endif
+#ifdef RTE_LIBRTE_BNXT_PMD
+       if (ret == -ENOTSUP)
+               ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
+                                               res->vf_num);
+#endif
 
-       if (strcmp(res->what, "add") == 0)
-               ret = rte_eth_dev_mac_addr_add(res->port_num,
-                                       &res->address, res->vf_num);
        if(ret < 0)
                printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
 
@@ -8823,7 +8852,7 @@ cmd_ethertype_filter_parsed(void *parsed_result,
        memset(&filter, 0, sizeof(filter));
        if (!strcmp(res->mac, "mac_addr")) {
                filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
-               (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
+               rte_memcpy(&filter.mac_addr, &res->mac_addr,
                        sizeof(struct ether_addr));
        }
        if (!strcmp(res->drop, "drop"))
@@ -8976,6 +9005,10 @@ str2flowtype(char *string)
                if (!strcmp(flowtype_str[i].str, string))
                        return flowtype_str[i].type;
        }
+
+       if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
+               return (uint16_t)atoi(string);
+
        return RTE_ETH_FLOW_UNKNOWN;
 }
 
@@ -9012,7 +9045,7 @@ do { \
 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
 do { \
        if ((ip_addr).family == AF_INET6) \
-               (void)rte_memcpy(&(ip), \
+               rte_memcpy(&(ip), \
                                 &((ip_addr).addr.ipv6), \
                                 sizeof(struct in6_addr)); \
        else { \
@@ -9144,12 +9177,12 @@ cmd_flow_director_filter_parsed(void *parsed_result,
        }
 
        if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
-               (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
+               rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
                                 &res->mac_addr,
                                 sizeof(struct ether_addr));
 
        if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
-               (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
+               rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
                                 &res->mac_addr,
                                 sizeof(struct ether_addr));
                entry.input.flow.tunnel_flow.tunnel_type =
@@ -9158,7 +9191,7 @@ cmd_flow_director_filter_parsed(void *parsed_result,
                        rte_cpu_to_be_32(res->tunnel_id_value);
        }
 
-       (void)rte_memcpy(entry.input.flow_ext.flexbytes,
+       rte_memcpy(entry.input.flow_ext.flexbytes,
                   flexbytes,
                   RTE_ETH_FDIR_MAX_FLEXLEN);
 
@@ -9856,7 +9889,7 @@ cmd_flow_director_flex_mask_parsed(void *parsed_result,
                        memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
                               0, sizeof(struct rte_eth_fdir_flex_mask));
                port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
-               (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
+               rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
                                 &flex_mask,
                                 sizeof(struct rte_eth_fdir_flex_mask));
                cmd_reconfig_device_queue(res->port_id, 1, 1);
@@ -10452,9 +10485,7 @@ cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
                port_id, UINT8);
 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
        TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
-               flow_type,
-               "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
-               "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
+               flow_type, NULL);
 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
        TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
                inset_field,
@@ -10473,7 +10504,7 @@ cmdline_parse_inst_t cmd_set_hash_input_set = {
        .data = NULL,
        .help_str = "set_hash_input_set <port_id> "
        "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
-       "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
+       "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
        "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
        "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
        "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
@@ -11496,7 +11527,7 @@ struct cmd_vf_vlan_stripq_result {
        cmdline_fixed_string_t vf;
        cmdline_fixed_string_t vlan;
        cmdline_fixed_string_t stripq;
-       uint8_t port_id;
+       portid_t port_id;
        uint16_t vf_id;
        cmdline_fixed_string_t on_off;
 };
@@ -13412,12 +13443,20 @@ cmd_ddp_info_parsed(
        uint32_t pkg_size;
        int ret = -ENOTSUP;
 #ifdef RTE_LIBRTE_I40E_PMD
-       uint32_t i;
+       uint32_t i, j, n;
        uint8_t *buff;
-       uint32_t buff_size;
+       uint32_t buff_size = 0;
        struct rte_pmd_i40e_profile_info info;
-       uint32_t dev_num;
+       uint32_t dev_num = 0;
        struct rte_pmd_i40e_ddp_device_id *devs;
+       uint32_t proto_num = 0;
+       struct rte_pmd_i40e_proto_info *proto;
+       uint32_t pctype_num = 0;
+       struct rte_pmd_i40e_ptype_info *pctype;
+       uint32_t ptype_num = 0;
+       struct rte_pmd_i40e_ptype_info *ptype;
+       uint8_t proto_id;
+
 #endif
 
        pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13470,12 +13509,11 @@ cmd_ddp_info_parsed(
                                (uint8_t *)&dev_num, sizeof(dev_num),
                                RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
        if (!ret && dev_num) {
-               devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
-                       sizeof(struct rte_pmd_i40e_ddp_device_id));
+               buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
+               devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
                if (devs) {
                        ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
-                                               (uint8_t *)devs, dev_num *
-                                               sizeof(struct rte_pmd_i40e_ddp_device_id),
+                                               (uint8_t *)devs, buff_size,
                                                RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
                        if (!ret) {
                                printf("List of supported devices:\n");
@@ -13491,8 +13529,110 @@ cmd_ddp_info_parsed(
                        free(devs);
                }
        }
+
+       /* get information about protocols and packet types */
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+               (uint8_t *)&proto_num, sizeof(proto_num),
+               RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
+       if (ret || !proto_num)
+               goto no_print_return;
+
+       buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
+       proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
+       if (!proto)
+               goto no_print_return;
+
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
+                                       buff_size,
+                                       RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
+       if (!ret) {
+               printf("List of used protocols:\n");
+               for (i = 0; i < proto_num; i++)
+                       printf("  %2u: %s\n", proto[i].proto_id,
+                              proto[i].name);
+               printf("\n");
+       }
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+               (uint8_t *)&pctype_num, sizeof(pctype_num),
+               RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
+       if (ret || !pctype_num)
+               goto no_print_pctypes;
+
+       buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
+       pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
+       if (!pctype)
+               goto no_print_pctypes;
+
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
+                                       buff_size,
+                                       RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
+       if (ret) {
+               free(pctype);
+               goto no_print_pctypes;
+       }
+
+       printf("List of defined packet classification types:\n");
+       for (i = 0; i < pctype_num; i++) {
+               printf("  %2u:", pctype[i].ptype_id);
+               for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
+                       proto_id = pctype[i].protocols[j];
+                       if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
+                               for (n = 0; n < proto_num; n++) {
+                                       if (proto[n].proto_id == proto_id) {
+                                               printf(" %s", proto[n].name);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               printf("\n");
+       }
+       printf("\n");
+       free(pctype);
+
+no_print_pctypes:
+
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
+                                       sizeof(ptype_num),
+                                       RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
+       if (ret || !ptype_num)
+               goto no_print_return;
+
+       buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
+       ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
+       if (!ptype)
+               goto no_print_return;
+
+       ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
+                                       buff_size,
+                                       RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
+       if (ret) {
+               free(ptype);
+               goto no_print_return;
+       }
+       printf("List of defined packet types:\n");
+       for (i = 0; i < ptype_num; i++) {
+               printf("  %2u:", ptype[i].ptype_id);
+               for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
+                       proto_id = ptype[i].protocols[j];
+                       if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
+                               for (n = 0; n < proto_num; n++) {
+                                       if (proto[n].proto_id == proto_id) {
+                                               printf(" %s", proto[n].name);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               printf("\n");
+       }
+       free(ptype);
+       printf("\n");
+
+       free(proto);
        ret = 0;
 #endif
+no_print_return:
        if (ret == -ENOTSUP)
                printf("Function not supported in PMD driver\n");
        close_ddp_package_file(pkg);
@@ -13795,6 +13935,304 @@ cmdline_parse_inst_t cmd_clear_vf_stats = {
        },
 };
 
+/* port config pctype mapping reset */
+
+/* Common result structure for port config pctype mapping reset */
+struct cmd_pctype_mapping_reset_result {
+       cmdline_fixed_string_t port;
+       cmdline_fixed_string_t config;
+       uint8_t port_id;
+       cmdline_fixed_string_t pctype;
+       cmdline_fixed_string_t mapping;
+       cmdline_fixed_string_t reset;
+};
+
+/* Common CLI fields for port config pctype mapping reset*/
+cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                port, "port");
+cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                config, "config");
+cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                port_id, UINT8);
+cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                pctype, "pctype");
+cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                mapping, "mapping");
+cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_reset_result,
+                reset, "reset");
+
+static void
+cmd_pctype_mapping_reset_parsed(
+       void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_pctype_mapping_reset_result *res = parsed_result;
+       int ret = -ENOTSUP;
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
+#endif
+
+       switch (ret) {
+       case 0:
+               break;
+       case -ENODEV:
+               printf("invalid port_id %d\n", res->port_id);
+               break;
+       case -ENOTSUP:
+               printf("function not implemented\n");
+               break;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+       }
+}
+
+cmdline_parse_inst_t cmd_pctype_mapping_reset = {
+       .f = cmd_pctype_mapping_reset_parsed,
+       .data = NULL,
+       .help_str = "port config <port_id> pctype mapping reset",
+       .tokens = {
+               (void *)&cmd_pctype_mapping_reset_port,
+               (void *)&cmd_pctype_mapping_reset_config,
+               (void *)&cmd_pctype_mapping_reset_port_id,
+               (void *)&cmd_pctype_mapping_reset_pctype,
+               (void *)&cmd_pctype_mapping_reset_mapping,
+               (void *)&cmd_pctype_mapping_reset_reset,
+               NULL,
+       },
+};
+
+/* show port pctype mapping */
+
+/* Common result structure for show port pctype mapping */
+struct cmd_pctype_mapping_get_result {
+       cmdline_fixed_string_t show;
+       cmdline_fixed_string_t port;
+       uint8_t port_id;
+       cmdline_fixed_string_t pctype;
+       cmdline_fixed_string_t mapping;
+};
+
+/* Common CLI fields for pctype mapping get */
+cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_get_result,
+                show, "show");
+cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_get_result,
+                port, "port");
+cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_pctype_mapping_get_result,
+                port_id, UINT8);
+cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_get_result,
+                pctype, "pctype");
+cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_get_result,
+                mapping, "mapping");
+
+static void
+cmd_pctype_mapping_get_parsed(
+       void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_pctype_mapping_get_result *res = parsed_result;
+       int ret = -ENOTSUP;
+#ifdef RTE_LIBRTE_I40E_PMD
+       struct rte_pmd_i40e_flow_type_mapping
+                               mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
+       int i, j, first_pctype;
+#endif
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
+#endif
+
+       switch (ret) {
+       case 0:
+               break;
+       case -ENODEV:
+               printf("invalid port_id %d\n", res->port_id);
+               return;
+       case -ENOTSUP:
+               printf("function not implemented\n");
+               return;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+               return;
+       }
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
+               if (mapping[i].pctype != 0ULL) {
+                       first_pctype = 1;
+
+                       printf("pctype: ");
+                       for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
+                               if (mapping[i].pctype & (1ULL << j)) {
+                                       printf(first_pctype ?
+                                              "%02d" : ",%02d", j);
+                                       first_pctype = 0;
+                               }
+                       }
+                       printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
+               }
+       }
+#endif
+}
+
+cmdline_parse_inst_t cmd_pctype_mapping_get = {
+       .f = cmd_pctype_mapping_get_parsed,
+       .data = NULL,
+       .help_str = "show port <port_id> pctype mapping",
+       .tokens = {
+               (void *)&cmd_pctype_mapping_get_show,
+               (void *)&cmd_pctype_mapping_get_port,
+               (void *)&cmd_pctype_mapping_get_port_id,
+               (void *)&cmd_pctype_mapping_get_pctype,
+               (void *)&cmd_pctype_mapping_get_mapping,
+               NULL,
+       },
+};
+
+/* port config pctype mapping update */
+
+/* Common result structure for port config pctype mapping update */
+struct cmd_pctype_mapping_update_result {
+       cmdline_fixed_string_t port;
+       cmdline_fixed_string_t config;
+       uint8_t port_id;
+       cmdline_fixed_string_t pctype;
+       cmdline_fixed_string_t mapping;
+       cmdline_fixed_string_t update;
+       cmdline_fixed_string_t pctype_list;
+       uint16_t flow_type;
+};
+
+/* Common CLI fields for pctype mapping update*/
+cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                port, "port");
+cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                config, "config");
+cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                port_id, UINT8);
+cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                pctype, "pctype");
+cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                mapping, "mapping");
+cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                update, "update");
+cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                pctype_list, NULL);
+cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_pctype_mapping_update_result,
+                flow_type, UINT16);
+
+static void
+cmd_pctype_mapping_update_parsed(
+       void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_pctype_mapping_update_result *res = parsed_result;
+       int ret = -ENOTSUP;
+#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];
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+
+       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]);
+       ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
+                                               &mapping,
+                                               1,
+                                               0);
+#endif
+
+       switch (ret) {
+       case 0:
+               break;
+       case -EINVAL:
+               printf("invalid pctype or flow type\n");
+               break;
+       case -ENODEV:
+               printf("invalid port_id %d\n", res->port_id);
+               break;
+       case -ENOTSUP:
+               printf("function not implemented\n");
+               break;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+       }
+}
+
+cmdline_parse_inst_t cmd_pctype_mapping_update = {
+       .f = cmd_pctype_mapping_update_parsed,
+       .data = NULL,
+       .help_str = "port config <port_id> pctype mapping update"
+       " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
+       .tokens = {
+               (void *)&cmd_pctype_mapping_update_port,
+               (void *)&cmd_pctype_mapping_update_config,
+               (void *)&cmd_pctype_mapping_update_port_id,
+               (void *)&cmd_pctype_mapping_update_pctype,
+               (void *)&cmd_pctype_mapping_update_mapping,
+               (void *)&cmd_pctype_mapping_update_update,
+               (void *)&cmd_pctype_mapping_update_pc_type,
+               (void *)&cmd_pctype_mapping_update_flow_type,
+               NULL,
+       },
+};
+
 /* ptype mapping get */
 
 /* Common result structure for ptype mapping get */
@@ -14376,6 +14814,10 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
        (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
        (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
+
+       (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
+       (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
+       (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
        NULL,
 };