From patchwork Fri Aug 22 08:26:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Helin" X-Patchwork-Id: 195 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DDE9EB37D for ; Fri, 22 Aug 2014 10:22:47 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 22 Aug 2014 01:26:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,378,1406617200"; d="scan'208";a="580304319" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 22 Aug 2014 01:26:27 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7M8QP9G017813; Fri, 22 Aug 2014 16:26:25 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s7M8QLnX009919; Fri, 22 Aug 2014 16:26:23 +0800 Received: (from hzhan75@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7M8QL1Z009915; Fri, 22 Aug 2014 16:26:21 +0800 From: Helin Zhang To: dev@dpdk.org Date: Fri, 22 Aug 2014 16:26:09 +0800 Message-Id: <1408695969-9774-6-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1408695969-9774-1-git-send-email-helin.zhang@intel.com> References: <1408695969-9774-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH 5/5] app/testpmd: rework of updating/querying redirection table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2014 08:22:48 -0000 As multiple sizes (64, 128, 512) of redirection table have been supported, the commands of updating/querying redirection table entries have been reworked. In addition, the redirection table size can be queried by the existing command of 'show port info <>'. Signed-off-by: Helin Zhang Reviewed-by: Jijiang Liu Reviewed-by: Cunming Liang Reviewed-by: Jingjing Wu --- app/test-pmd/cmdline.c | 159 ++++++++++++++++++++++++++++++++++++------------- app/test-pmd/config.c | 37 ++++++------ app/test-pmd/testpmd.h | 4 +- 3 files changed, 137 insertions(+), 63 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 345be11..5ad501e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -186,6 +187,11 @@ static void cmd_help_long_parsed(void *parsed_result, "show port (info|stats|fdir|stat_qmap) (port_id|all)\n" " Display information for port_id, or all.\n\n" + "show port X rss reta (size) (mask0,mask1,...)\n" + " Display the rss redirection table entry indicated" + " by masks or port X. size is used to indicate the" + " hardware supported reta size\n\n" + "show port rss-hash [key]\n" " Display the RSS hash functions and RSS hash key" " of port X\n\n" @@ -1436,11 +1442,13 @@ struct cmd_config_rss_reta { }; static int -parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf) +parse_reta_config(const char *str, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t nb_entries) { int i; unsigned size; - uint8_t hash_index; + uint16_t hash_index, idx, shift; uint8_t nb_queue; char s[256]; const char *p, *p0 = str; @@ -1475,17 +1483,15 @@ parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf) 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) { + if (hash_index >= nb_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; + idx = hash_index / RTE_BIT_WIDTH_64; + shift = hash_index % RTE_BIT_WIDTH_64; + reta_conf[idx].mask |= (1ULL << shift); + reta_conf[idx].reta[shift] = nb_queue; } return 0; @@ -1493,22 +1499,42 @@ parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf) static void cmd_set_rss_reta_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) { int ret; - struct rte_eth_rss_reta reta_conf; + struct rte_eth_dev_info dev_info; + struct rte_eth_rss_reta_entry64 reta_conf[8]; struct cmd_config_rss_reta *res = parsed_result; - memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta)); + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(res->port_id, &dev_info); + if (dev_info.reta_size == 0) { + printf("Redirection table size is 0 which is " + "invalid for RSS\n"); + return; + } else + printf("The reta size of port %d is %u\n", + res->port_id, dev_info.reta_size); + if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { + printf("Currently do not support more than %u entries of " + "redirection table\n", ETH_RSS_RETA_SIZE_512); + return; + } + + memset(reta_conf, 0, sizeof(reta_conf)); if (!strcmp(res->list_name, "reta")) { - if (parse_reta_config(res->list_of_items, &reta_conf)) { - printf("Invalid RSS Redirection Table config entered\n"); + if (parse_reta_config(res->list_of_items, reta_conf, + dev_info.reta_size)) { + printf("Invalid RSS Redirection Table " + "config entered\n"); return; } - ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf); + ret = rte_eth_dev_rss_reta_update(res->port_id, + reta_conf, dev_info.reta_size); if (ret != 0) - printf("Bad redirection table parameter, return code = %d \n",ret); + printf("Bad redirection table parameter, " + "return code = %d \n", ret); } } @@ -1547,56 +1573,103 @@ struct cmd_showport_reta { uint8_t port_id; cmdline_fixed_string_t rss; cmdline_fixed_string_t reta; - uint64_t mask_lo; - uint64_t mask_hi; + uint16_t size; + cmdline_fixed_string_t list_of_items; }; -static void cmd_showport_reta_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) +static int +showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, + uint16_t nb_entries, + char *str) { - struct cmd_showport_reta *res = parsed_result; - struct rte_eth_rss_reta reta_conf; + uint32_t size; + const char *p, *p0 = str; + char s[256]; + char *end; + char *str_fld[8]; + uint16_t i, num = nb_entries / RTE_BIT_WIDTH_64; + int ret; - if ((res->mask_lo == 0) && (res->mask_hi == 0)) { - printf("Invalid RSS Redirection Table config entered\n"); - return; + p = strchr(p0, '('); + if (p == NULL) + return -1; + p++; + p0 = strchr(p, ')'); + if (p0 == NULL) + return -1; + size = p0 - p; + if (size >= sizeof(s)) { + printf("The string size exceeds the internal buffer size\n"); + return -1; + } + snprintf(s, sizeof(s), "%.*s", size, p); + ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); + if (ret <= 0 || ret != num) { + printf("The bits of masks do not match the number of " + "reta entries: %u\n", num); + return -1; } + for (i = 0; i < ret; i++) + conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); - reta_conf.mask_lo = res->mask_lo; - reta_conf.mask_hi = res->mask_hi; + return 0; +} - port_rss_reta_info(res->port_id,&reta_conf); +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_entry64 reta_conf[8]; + struct rte_eth_dev_info dev_info; + + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(res->port_id, &dev_info); + if (dev_info.reta_size == 0 || res->size != dev_info.reta_size || + res->size > ETH_RSS_RETA_SIZE_512) { + printf("Invalid redirection table size: %u\n", res->size); + return; + } + + memset(reta_conf, 0, sizeof(reta_conf)); + if (showport_parse_reta_config(reta_conf, res->size, + res->list_of_items) < 0) { + printf("Invalid string: %s for reta masks\n", + res->list_of_items); + return; + } + port_rss_reta_info(res->port_id, reta_conf, res->size); } cmdline_parse_token_string_t cmd_showport_reta_show = - TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "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"); + 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); + 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"); + 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); + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); +cmdline_parse_token_num_t cmd_showport_reta_size = + TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); +cmdline_parse_token_string_t cmd_showport_reta_list_of_items = + TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, + list_of_items, NULL); 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)", + .help_str = "show port X rss reta (size) (mask0,mask1,...)", .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, + (void *)&cmd_showport_reta_size, + (void *)&cmd_showport_reta_list_of_items, NULL, }, }; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c72f6ee..e56320e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -254,6 +254,7 @@ port_infos_display(portid_t port_id) struct rte_port *port; struct ether_addr mac_addr; struct rte_eth_link link; + struct rte_eth_dev_info dev_info; int vlan_offload; struct rte_mempool * mp; static const char *info_border = "*********************"; @@ -309,6 +310,11 @@ port_infos_display(portid_t port_id) else printf(" qinq(extend) off \n"); } + + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(port_id, &dev_info); + if (dev_info.reta_size > 0) + printf("Redirection table size: %u\n", dev_info.reta_size); } static int @@ -728,36 +734,29 @@ rxtx_config_display(void) } void -port_rss_reta_info(portid_t port_id,struct rte_eth_rss_reta *reta_conf) +port_rss_reta_info(portid_t port_id, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t nb_entries) { - uint8_t i,j; + uint16_t i, idx, shift; int ret; if (port_id_is_invalid(port_id)) return; - ret = rte_eth_dev_rss_reta_query(port_id, reta_conf); + ret = rte_eth_dev_rss_reta_query(port_id, reta_conf, nb_entries); if (ret != 0) { printf("Failed to get RSS RETA info, return code = %d\n", ret); return; } - if (reta_conf->mask_lo != 0) { - for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) { - if (reta_conf->mask_lo & (uint64_t)(1ULL << i)) - printf("RSS RETA configuration: hash index=%d," - "queue=%d\n",i,reta_conf->reta[i]); - } - } - - if (reta_conf->mask_hi != 0) { - for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) { - if(reta_conf->mask_hi & (uint64_t)(1ULL << i)) { - j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2); - printf("RSS RETA configuration: hash index=%d," - "queue=%d\n",j,reta_conf->reta[j]); - } - } + for (i = 0; i < nb_entries; i++) { + idx = i / RTE_BIT_WIDTH_64; + shift = i % RTE_BIT_WIDTH_64; + if (!(reta_conf[idx].mask & (1ULL << shift))) + continue; + printf("RSS RETA configuration: hash index=%u, queue=%u\n", + i, reta_conf[idx].reta[shift]); } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ac86bfe..9c033e3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -530,7 +530,9 @@ void fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id, struct rte_fdir_filter *fdir_filter); void fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks); -void port_rss_reta_info(portid_t port_id, struct rte_eth_rss_reta *reta_conf); +void port_rss_reta_info(portid_t port_id, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t nb_entries); void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on); void set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id,