X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fcmdline.c;h=d17b3645ad1c1295923fe11e9eebffaeb79b4af0;hb=1c1d4d7a923d4804f1926fc5264f9ecdd8977b04;hp=f909597122f2a815bace8ec2ac3444d74ac946b1;hpb=3be52ffc882d8a690f3e414e0b9a21acb3d726d8;p=dpdk.git diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f909597122..d17b3645ad 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -4,32 +4,31 @@ * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * * Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #include @@ -405,6 +404,9 @@ static void cmd_help_long_parsed(void *parsed_result, "port config all rss (ip|udp|none)\n" " Set the RSS mode.\n\n" + "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" + " Set the RSS redirection table.\n\n" + "port config (port_id) dcb vt (on|off) (traffic_class)" " pfc (on|off)\n" " Set the DCB mode.\n\n" @@ -1079,6 +1081,182 @@ cmdline_parse_inst_t cmd_config_rss = { }, }; +/* *** Configure RSS RETA *** */ +struct cmd_config_rss_reta { + cmdline_fixed_string_t port; + cmdline_fixed_string_t keyword; + uint8_t port_id; + cmdline_fixed_string_t name; + cmdline_fixed_string_t list_name; + cmdline_fixed_string_t list_of_items; +}; + +static int +parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf) +{ + int i; + unsigned size; + uint8_t hash_index; + uint8_t nb_queue; + char s[256]; + const char *p, *p0 = str; + char *end; + enum fieldnames { + FLD_HASH_INDEX = 0, + FLD_QUEUE, + _NUM_FLD + }; + unsigned long int_fld[_NUM_FLD]; + char *str_fld[_NUM_FLD]; + + while ((p = strchr(p0,'(')) != NULL) { + ++p; + if((p0 = strchr(p,')')) == NULL) + return -1; + + size = p0 - p; + if(size >= sizeof(s)) + return -1; + + rte_snprintf(s, sizeof(s), "%.*s", size, p); + if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) + return -1; + for (i = 0; i < _NUM_FLD; i++) { + errno = 0; + int_fld[i] = strtoul(str_fld[i], &end, 0); + if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) + return -1; + } + + hash_index = (uint8_t)int_fld[FLD_HASH_INDEX]; + nb_queue = (uint8_t)int_fld[FLD_QUEUE]; + + if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) { + printf("Invalid RETA hash index=%d",hash_index); + return -1; + } + + if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2) + reta_conf->mask_lo |= (1ULL << hash_index); + else + reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2)); + + reta_conf->reta[hash_index] = nb_queue; + } + + return 0; +} + +static void +cmd_set_rss_reta_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + int ret; + struct rte_eth_rss_reta reta_conf; + struct cmd_config_rss_reta *res = parsed_result; + + memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta)); + if (!strcmp(res->list_name, "reta")) { + if (parse_reta_config(res->list_of_items, &reta_conf)) { + printf("Invalid RSS Redirection Table config entered\n"); + return; + } + ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf); + if (ret != 0) + printf("Bad redirection table parameter, return code = %d \n",ret); + } +} + +cmdline_parse_token_string_t cmd_config_rss_reta_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); +cmdline_parse_token_string_t cmd_config_rss_reta_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); +cmdline_parse_token_num_t cmd_config_rss_reta_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8); +cmdline_parse_token_string_t cmd_config_rss_reta_name = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); +cmdline_parse_token_string_t cmd_config_rss_reta_list_name = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); +cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, + NULL); +cmdline_parse_inst_t cmd_config_rss_reta = { + .f = cmd_set_rss_reta_parsed, + .data = NULL, + .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]", + .tokens = { + (void *)&cmd_config_rss_reta_port, + (void *)&cmd_config_rss_reta_keyword, + (void *)&cmd_config_rss_reta_port_id, + (void *)&cmd_config_rss_reta_name, + (void *)&cmd_config_rss_reta_list_name, + (void *)&cmd_config_rss_reta_list_of_items, + NULL, + }, +}; + +/* *** SHOW PORT INFO *** */ +struct cmd_showport_reta { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + uint8_t port_id; + cmdline_fixed_string_t rss; + cmdline_fixed_string_t reta; + uint64_t mask_lo; + uint64_t mask_hi; +}; + +static void cmd_showport_reta_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_showport_reta *res = parsed_result; + struct rte_eth_rss_reta reta_conf; + + if ((res->mask_lo == 0) && (res->mask_hi == 0)) { + printf("Invalid RSS Redirection Table config entered\n"); + return; + } + + reta_conf.mask_lo = res->mask_lo; + reta_conf.mask_hi = res->mask_hi; + + port_rss_reta_info(res->port_id,&reta_conf); +} + +cmdline_parse_token_string_t cmd_showport_reta_show = + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); +cmdline_parse_token_string_t cmd_showport_reta_port = + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); +cmdline_parse_token_num_t cmd_showport_reta_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8); +cmdline_parse_token_string_t cmd_showport_reta_rss = + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); +cmdline_parse_token_string_t cmd_showport_reta_reta = + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); +cmdline_parse_token_num_t cmd_showport_reta_mask_lo = + TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64); +cmdline_parse_token_num_t cmd_showport_reta_mask_hi = + TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64); + +cmdline_parse_inst_t cmd_showport_reta = { + .f = cmd_showport_reta_parsed, + .data = NULL, + .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\ + (mask_lo and mask_hi is UINT64)", + .tokens = { + (void *)&cmd_showport_reta_show, + (void *)&cmd_showport_reta_port, + (void *)&cmd_showport_reta_port_id, + (void *)&cmd_showport_reta_rss, + (void *)&cmd_showport_reta_reta, + (void *)&cmd_showport_reta_mask_lo, + (void *)&cmd_showport_reta_mask_hi, + NULL, + }, +}; + /* *** Configure DCB *** */ struct cmd_config_dcb { cmdline_fixed_string_t port; @@ -3691,6 +3869,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, (cmdline_parse_inst_t *)&cmd_config_rss, + (cmdline_parse_inst_t *)&cmd_config_rss_reta, + (cmdline_parse_inst_t *)&cmd_showport_reta, (cmdline_parse_inst_t *)&cmd_config_burst, (cmdline_parse_inst_t *)&cmd_config_thresh, (cmdline_parse_inst_t *)&cmd_config_threshold,