DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size
@ 2016-08-05 15:34 Mohammad Abdul Awal
  2016-09-23 18:37 ` Thomas Monjalon
  2016-09-27 17:03 ` Ananyev, Konstantin
  0 siblings, 2 replies; 4+ messages in thread
From: Mohammad Abdul Awal @ 2016-08-05 15:34 UTC (permalink / raw)
  To: dev; +Cc: Mohammad Abdul Awal

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 <mohammad.abdul.awal@intel.com>
---
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 "
+		"<string of hexa digits (variable length, NIC dependent)>\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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size
  2016-08-05 15:34 [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size Mohammad Abdul Awal
@ 2016-09-23 18:37 ` Thomas Monjalon
  2016-09-27 17:03 ` Ananyev, Konstantin
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2016-09-23 18:37 UTC (permalink / raw)
  To: dev; +Cc: Mohammad Abdul Awal, pablo.de.lara.guarch

Anyone to review please?

2016-08-05 16:34, Mohammad Abdul Awal:
> 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 <mohammad.abdul.awal@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size
  2016-08-05 15:34 [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size Mohammad Abdul Awal
  2016-09-23 18:37 ` Thomas Monjalon
@ 2016-09-27 17:03 ` Ananyev, Konstantin
  2016-10-13 14:08   ` Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Ananyev, Konstantin @ 2016-09-27 17:03 UTC (permalink / raw)
  To: Awal, Mohammad Abdul, dev; +Cc: Awal, Mohammad Abdul

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mohammad Abdul Awal
> Sent: Friday, August 5, 2016 4:35 PM
> To: dev@dpdk.org
> Cc: Awal, Mohammad Abdul <mohammad.abdul.awal@intel.com>
> Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size
> 
> 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 <mohammad.abdul.awal@intel.com>
> ---

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size
  2016-09-27 17:03 ` Ananyev, Konstantin
@ 2016-10-13 14:08   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2016-10-13 14:08 UTC (permalink / raw)
  To: Awal, Mohammad Abdul; +Cc: dev, Ananyev, Konstantin

> > 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 <mohammad.abdul.awal@intel.com>
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-13 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05 15:34 [dpdk-dev] [PATCH v2] app/testpmd: fix RSS-hash-key size Mohammad Abdul Awal
2016-09-23 18:37 ` Thomas Monjalon
2016-09-27 17:03 ` Ananyev, Konstantin
2016-10-13 14:08   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).