From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Iremonger, Bernard" Subject: Re: [PATCH v2 3/4] app/testpmd: add new commands to manipulate with pctype mapping Date: Mon, 4 Sep 2017 17:29:06 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C24E044683@IRSMSX108.ger.corp.intel.com> References: <1503569908-104074-1-git-send-email-kirill.rybalchenko@intel.com> <1504278166-32769-1-git-send-email-kirill.rybalchenko@intel.com> <1504278166-32769-4-git-send-email-kirill.rybalchenko@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "Rybalchenko, Kirill" , "Chilikin, Andrey" , "Xing, Beilei" , "Wu, Jingjing" To: "Rybalchenko, Kirill" , "dev@dpdk.org" Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 80986374F for ; Mon, 4 Sep 2017 19:29:09 +0200 (CEST) In-Reply-To: <1504278166-32769-4-git-send-email-kirill.rybalchenko@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Kirill, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko > Sent: Friday, September 1, 2017 4:03 PM > To: dev@dpdk.org > Cc: Rybalchenko, Kirill ; Chilikin, Andrey > ; Xing, Beilei ; Wu, > Jingjing > Subject: [dpdk-dev] [PATCH v2 3/4] app/testpmd: add new commands to > manipulate with pctype mapping >=20 > Add new commands to manipulate with dynamic flow type to pctype > mapping table in i40e PMD. > Commands allow to print table, modify it and reset to default value. >=20 > Signed-off-by: Kirill Rybalchenko > --- > app/test-pmd/cmdline.c | 311 > +++++++++++++++++++++++++++- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 ++ > 2 files changed, 322 insertions(+), 10 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 0144191..f7d0733 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -637,6 +637,16 @@ static void cmd_help_long_parsed(void > *parsed_result, > "ptype mapping update (port_id) (hw_ptype) > (sw_ptype)\n" > " Update a ptype mapping item on a port\n\n" >=20 > + "pctype mapping reset (port_id)\n" > + " Reset flow type to pctype mapping on a port\n\n" > + > + "pctype mapping get (port_id)\n" > + " Get flow ptype to pctype mapping on a port\n\n" > + > + "pctype mapping update (port_id) > (pctype_id_0[,pctype_id_1]*)" > + " (flow_type_id)\n" > + " Update a flow type to pctype mapping item on a > port\n\n" > + > , list_pkt_forwarding_modes() > ); > } > @@ -681,7 +691,8 @@ static void cmd_help_long_parsed(void > *parsed_result, > " Set crc-strip/scatter/rx-checksum/hardware- > vlan/drop_en" > " for ports.\n\n" >=20 > - "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|)\n" > " Set the RSS mode.\n\n" >=20 > "port config port-id rss reta > (hash,queue)[,(hash,queue)]\n" > @@ -878,8 +889,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|) (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|" > @@ -1716,6 +1727,8 @@ cmd_config_rss_parsed(void *parsed_result, > rss_conf.rss_hf =3D ETH_RSS_NVGRE; > else if (!strcmp(res->value, "none")) > rss_conf.rss_hf =3D 0; > + else if (isdigit(res->value[0]) && atoi(res->value) > 0 && atoi(res- > >value) < 64) > + rss_conf.rss_hf =3D 1ULL << atoi(res->value); > else { > printf("Unknown parameter\n"); > return; > @@ -1739,14 +1752,13 @@ cmdline_parse_token_string_t > cmd_config_rss_all =3D cmdline_parse_token_string_t cmd_config_rss_name > =3D > TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); > cmdline_parse_token_string_t cmd_config_rss_value =3D > - 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); >=20 > cmdline_parse_inst_t cmd_config_rss =3D { > .f =3D cmd_config_rss_parsed, > .data =3D NULL, > .help_str =3D "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| >", > .tokens =3D { > (void *)&cmd_config_rss_port, > (void *)&cmd_config_rss_keyword, > @@ -8987,6 +8999,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; > } >=20 > @@ -10463,9 +10479,7 @@ cmdline_parse_token_num_t > cmd_set_hash_input_set_port_id =3D > port_id, UINT8); > cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =3D > 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 =3D > TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, > inset_field, > @@ -10484,7 +10498,7 @@ cmdline_parse_inst_t cmd_set_hash_input_set > =3D { > .data =3D NULL, > .help_str =3D "set_hash_input_set " > "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| " > "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|" > @@ -13806,6 +13820,279 @@ cmdline_parse_inst_t cmd_clear_vf_stats =3D { > }, > }; >=20 > +/* pctype mapping reset */ > + > +/* Common result structure for pctype mapping reset */ struct > +cmd_pctype_mapping_reset_result { > + cmdline_fixed_string_t pctype; > + cmdline_fixed_string_t mapping; > + cmdline_fixed_string_t reset; > + uint8_t port_id; > +}; > + > +/* Common CLI fields for pctype mapping reset*/ > +cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_reset_result, > + pctype, "pctype"); > +cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_reset_result, > + mapping, "mapping"); > +cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_reset_result, > + reset, "reset"); > +cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =3D > + TOKEN_NUM_INITIALIZER > + (struct cmd_pctype_mapping_reset_result, > + port_id, UINT8); > + > +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 =3D parsed_result; > + int ret =3D -ENOTSUP; > + > + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) > + return; > + > +#ifdef RTE_LIBRTE_I40E_PMD > + ret =3D 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 =3D { > + .f =3D cmd_pctype_mapping_reset_parsed, > + .data =3D NULL, > + .help_str =3D "pctype mapping reset ", > + .tokens =3D { > + (void *)&cmd_pctype_mapping_reset_pctype, > + (void *)&cmd_pctype_mapping_reset_mapping, > + (void *)&cmd_pctype_mapping_reset_reset, > + (void *)&cmd_pctype_mapping_reset_port_id, > + NULL, > + }, > +}; > + > +/* pctype mapping get */ > + > +#define FLOW_TYPE_MAX 64 > +#define PCTYPE_MAX 64 > + > +/* Common result structure for pctype mapping get */ struct > +cmd_pctype_mapping_get_result { > + cmdline_fixed_string_t pctype; > + cmdline_fixed_string_t mapping; > + cmdline_fixed_string_t get; > + uint8_t port_id; > +}; > + > +/* Common CLI fields for pctype mapping get */ > +cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_get_result, > + pctype, "pctype"); > +cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_get_result, > + mapping, "mapping"); > +cmdline_parse_token_string_t cmd_pctype_mapping_get_get =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_get_result, > + get, "get"); > +cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =3D > + TOKEN_NUM_INITIALIZER > + (struct cmd_pctype_mapping_get_result, > + port_id, UINT8); > + > +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 =3D parsed_result; > + int ret =3D -ENOTSUP; > +#ifdef RTE_LIBRTE_I40E_PMD > + struct rte_pmd_i40e_flow_type_mapping > mapping[FLOW_TYPE_MAX]; > + uint16_t count; > + int i, j; > +#endif > + > + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) > + return; > + > +#ifdef RTE_LIBRTE_I40E_PMD > + ret =3D rte_pmd_i40e_flow_type_mapping_get(res->port_id, > + mapping, > + FLOW_TYPE_MAX, > + &count, > + 1); > +#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)); > + } > + > +#ifdef RTE_LIBRTE_I40E_PMD > + if (!ret) { > + for (i =3D 0; i < count; i++) { > + int first_pctype =3D 1; > + > + printf("pctype: "); > + for (j =3D 0; j < PCTYPE_MAX; j++) { > + if (mapping[i].pctype & (1ULL << j)) { > + printf(first_pctype ? "%02d" : > ",%02d", j); > + first_pctype =3D 0; > + } > + } > + printf(" -> flowtype: %02d\n", > mapping[i].flow_type); > + } > + } > +#endif > +} > + > +cmdline_parse_inst_t cmd_pctype_mapping_get =3D { > + .f =3D cmd_pctype_mapping_get_parsed, > + .data =3D NULL, > + .help_str =3D "pctype mapping get ", > + .tokens =3D { > + (void *)&cmd_pctype_mapping_get_pctype, > + (void *)&cmd_pctype_mapping_get_mapping, > + (void *)&cmd_pctype_mapping_get_get, > + (void *)&cmd_pctype_mapping_get_port_id, > + NULL, > + }, > +}; > + > +/* pctype mapping update */ > + > +/* Common result structure for pctype mapping update */ struct > +cmd_pctype_mapping_update_result { > + cmdline_fixed_string_t pctype; > + cmdline_fixed_string_t mapping; > + cmdline_fixed_string_t update; > + uint8_t port_id; > + 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_pctype =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_update_result, > + pctype, "pctype"); > +cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_update_result, > + mapping, "mapping"); > +cmdline_parse_token_string_t cmd_pctype_mapping_update_update =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_update_result, > + update, "update"); > +cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =3D > + TOKEN_NUM_INITIALIZER > + (struct cmd_pctype_mapping_update_result, > + port_id, UINT8); > +cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_pctype_mapping_update_result, > + pctype_list, NULL); > +cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =3D > + 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 =3D parsed_result; > + int ret =3D -ENOTSUP; > +#ifdef RTE_LIBRTE_I40E_PMD > + struct rte_pmd_i40e_flow_type_mapping mapping; #endif > + unsigned int nb_item, i; > + unsigned int pctype_list[PCTYPE_MAX]; > + > + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) > + return; > + > + nb_item =3D parse_item_list(res->pctype_list, "pctypes", > PCTYPE_MAX, > + pctype_list, 1); > + > + > +#ifdef RTE_LIBRTE_I40E_PMD > + mapping.flow_type =3D res->flow_type; > + for (i =3D 0, mapping.pctype =3D 0ULL; i < nb_item; i++) > + mapping.pctype |=3D (1ULL << pctype_list[i]); > + ret =3D 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 =3D { > + .f =3D cmd_pctype_mapping_update_parsed, > + .data =3D NULL, > + .help_str =3D "pctype mapping update > " > + " ", > + .tokens =3D { > + (void *)&cmd_pctype_mapping_update_pctype, > + (void *)&cmd_pctype_mapping_update_mapping, > + (void *)&cmd_pctype_mapping_update_update, > + (void *)&cmd_pctype_mapping_update_port_id, > + (void *)&cmd_pctype_mapping_update_pc_type, > + (void *)&cmd_pctype_mapping_update_flow_type, > + NULL, > + }, > +}; > + > /* ptype mapping get */ >=20 > /* Common result structure for ptype mapping get */ @@ -14387,6 > +14674,10 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (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, > }; >=20 > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 2ed62f5..f5913b7 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -1310,6 +1310,27 @@ Reset ptype mapping table:: >=20 > testpmd> ptype mapping reset (port_id) >=20 > +pctype mapping > +~~~~~~~~~~~~~ > + > +List all items from the pctype mapping table:: > + > + testpmd> pctype mapping get (port_id) > + > +Update hardware defined pctype to software defined flow type mapping > table:: > + > + testpmd> pctype mapping update (port_id) > + (pctype_id_0[,pctype_id_1]*) (flow_type_d) > + > +where: > + > +* ``pctype_id_x``: hardware pctype id as index of bit in bitmask value o= f the > pctype mapping table. > + > +* ``flow_type_id``: software flow type id as the index of the pctype > mapping table. > + > +Reset pctype mapping table:: > + > + testpmd> pctype mapping reset (port_id) > + > Port Functions > -------------- >=20 > -- > 2.5.5 There are checkpatch warnings in cmdline.c at lines 1730, 13971 and 14083= . Regards, Bernard.