From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B9C792B8E for ; Fri, 5 Aug 2016 17:36:41 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 05 Aug 2016 08:36:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,474,1464678000"; d="scan'208";a="1020319936" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 05 Aug 2016 08:36:39 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u75FacfP014328; Fri, 5 Aug 2016 16:36:38 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u75FacCj009965; Fri, 5 Aug 2016 16:36:38 +0100 Received: (from awalabdu@localhost) by sivswdev02.ir.intel.com with id u75FacRa009961; Fri, 5 Aug 2016 16:36:38 +0100 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: Mohammad Abdul Awal Date: Fri, 5 Aug 2016 16:34:51 +0100 Message-Id: <1470411291-9567-1-git-send-email-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size 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, 05 Aug 2016 15:36:42 -0000 RSS hash-key-size is retrieved from device configuration instead of using a fixed size of 40 bytes. Fixes: f79959ea1504 ("app/testpmd: allow to configure RSS hash key") Signed-off-by: Mohammad Abdul Awal --- v2: * Used macro instead of hard-coded value. * Some nits as per comments. app/test-pmd/cmdline.c | 27 ++++++++++++++++++++------- app/test-pmd/config.c | 18 +++++++++++++++--- app/test-pmd/testpmd.h | 6 ++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f90befc..a631c43 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -1608,7 +1608,6 @@ struct cmd_config_rss_hash_key { cmdline_fixed_string_t key; }; -#define RSS_HASH_KEY_LENGTH 40 static uint8_t hexa_digit_to_value(char hexa_digit) { @@ -1644,16 +1643,29 @@ cmd_config_rss_hash_key_parsed(void *parsed_result, uint8_t xdgt0; uint8_t xdgt1; int i; + struct rte_eth_dev_info dev_info; + uint8_t hash_key_size; + uint32_t key_len; + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(res->port_id, &dev_info); + if (dev_info.hash_key_size > 0 && + dev_info.hash_key_size <= sizeof(hash_key)) + hash_key_size = dev_info.hash_key_size; + else { + printf("dev_info did not provide a valid hash key size\n"); + return; + } /* Check the length of the RSS hash key */ - if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) { + key_len = strlen(res->key); + if (key_len != (hash_key_size * 2)) { printf("key length: %d invalid - key must be a string of %d" - "hexa-decimal numbers\n", (int) strlen(res->key), - RSS_HASH_KEY_LENGTH * 2); + " hexa-decimal numbers\n", + (int) key_len, hash_key_size * 2); return; } /* Translate RSS hash key into binary representation */ - for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) { + for (i = 0; i < hash_key_size; i++) { xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); if (xdgt0 == 0xFF) return; @@ -1663,7 +1675,7 @@ cmd_config_rss_hash_key_parsed(void *parsed_result, hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); } port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, - RSS_HASH_KEY_LENGTH); + hash_key_size); } cmdline_parse_token_string_t cmd_config_rss_hash_key_port = @@ -1692,7 +1704,8 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = { "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|" "ipv6-sctp|ipv6-other|l2-payload|" - "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n", + "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " + "\n", .tokens = { (void *)&cmd_config_rss_hash_key_port, (void *)&cmd_config_rss_hash_key_config, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index bfcbff9..44ba91e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1012,14 +1012,26 @@ void port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) { struct rte_eth_rss_conf rss_conf; - uint8_t rss_key[10 * 4] = ""; + uint8_t rss_key[RSS_HASH_KEY_LENGTH]; uint64_t rss_hf; uint8_t i; int diag; + struct rte_eth_dev_info dev_info; + uint8_t hash_key_size; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(port_id, &dev_info); + if (dev_info.hash_key_size > 0 && + dev_info.hash_key_size <= sizeof(rss_key)) + hash_key_size = dev_info.hash_key_size; + else { + printf("dev_info did not provide a valid hash key size\n"); + return; + } + rss_conf.rss_hf = 0; for (i = 0; i < RTE_DIM(rss_type_table); i++) { if (!strcmp(rss_info, rss_type_table[i].str)) @@ -1028,7 +1040,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) /* Get RSS hash key if asked to display it */ rss_conf.rss_key = (show_rss_key) ? rss_key : NULL; - rss_conf.rss_key_len = sizeof(rss_key); + rss_conf.rss_key_len = hash_key_size; diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); if (diag != 0) { switch (diag) { @@ -1058,7 +1070,7 @@ port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key) if (!show_rss_key) return; printf("RSS key:\n"); - for (i = 0; i < sizeof(rss_key); i++) + for (i = 0; i < hash_key_size; i++) printf("%02X", rss_key[i]); printf("\n"); } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2b281cc..74bf5cb 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -45,6 +45,12 @@ #define RTE_PORT_HANDLING (uint16_t)3 /* + * It is used to allocate the memory for hash key. + * The hash key size is NIC dependent. + */ +#define RSS_HASH_KEY_LENGTH 64 + +/* * Default size of the mbuf data buffer to receive standard 1518-byte * Ethernet frames in a mono-segment memory buffer. */ -- 2.7.4