[v8,10/10] app/testpmd: add RSS hash algorithms display

Message ID 20231101074039.3088716-11-haijie1@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series support setting and querying RSS algorithms |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Jie Hai Nov. 1, 2023, 7:40 a.m. UTC
  Add the command "show port X rss-hash algorithm" to display
the RSS hash algorithms of port X. An example is shown:

testpmd> show port 0 rss-hash algorithm
RSS algorithm:
  toeplitz

Signed-off-by: Jie Hai <haijie1@huawei.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
---
 app/test-pmd/cmdline.c | 29 ++++++++++++++++++++++++-----
 app/test-pmd/config.c  | 29 ++++++++++-------------------
 app/test-pmd/testpmd.h |  2 +-
 3 files changed, 35 insertions(+), 25 deletions(-)
  

Comments

Ferruh Yigit Nov. 1, 2023, 1:42 p.m. UTC | #1
On 11/1/2023 7:40 AM, Jie Hai wrote:
> Add the command "show port X rss-hash algorithm" to display
> the RSS hash algorithms of port X. An example is shown:
> 
> testpmd> show port 0 rss-hash algorithm
> RSS algorithm:
>   toeplitz
> 
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> Acked-by: Huisong Li <lihuisong@huawei.com>
> ---
>  app/test-pmd/cmdline.c | 29 ++++++++++++++++++++++++-----
>  app/test-pmd/config.c  | 29 ++++++++++-------------------
>  app/test-pmd/testpmd.h |  2 +-
>

Can you please update testpmd documentation,
'doc/guides/testpmd_app_ug/testpmd_funcs.rst', too?

<...>

> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index b9fdb7e8f162..23fb4f8aa781 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1504,24 +1504,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
>  		printf(" %d", rss_conf->queue[i]);
>  	printf("\n");
>  
> -	printf(" function: ");
> -	switch (rss_conf->func) {
> -	case RTE_ETH_HASH_FUNCTION_DEFAULT:
> -		printf("default\n");
> -		break;
> -	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
> -		printf("toeplitz\n");
> -		break;
> -	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
> -		printf("simple_xor\n");
> -		break;
> -	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
> -		printf("symmetric_toeplitz\n");
> -		break;
> -	default:
> -		printf("Unknown function\n");
> -		return;
> -	}
> +	printf(" function: %s\n", rte_eth_dev_rss_algo_name(rss_conf->func));
>  


Above modification can be moved to the patch that adds
'rte_eth_dev_rss_algo_name()'.
  
Jie Hai Nov. 2, 2023, 7:33 a.m. UTC | #2
On 2023/11/1 21:42, Ferruh Yigit wrote:
> On 11/1/2023 7:40 AM, Jie Hai wrote:
>> Add the command "show port X rss-hash algorithm" to display
>> the RSS hash algorithms of port X. An example is shown:
>>
>> testpmd> show port 0 rss-hash algorithm
>> RSS algorithm:
>>    toeplitz
>>
>> Signed-off-by: Jie Hai <haijie1@huawei.com>
>> Acked-by: Huisong Li <lihuisong@huawei.com>
>> ---
>>   app/test-pmd/cmdline.c | 29 ++++++++++++++++++++++++-----
>>   app/test-pmd/config.c  | 29 ++++++++++-------------------
>>   app/test-pmd/testpmd.h |  2 +-
>>
> 
> Can you please update testpmd documentation,
> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', too?
> 
> <...>
Thanks, will add.
> 
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index b9fdb7e8f162..23fb4f8aa781 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -1504,24 +1504,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
>>   		printf(" %d", rss_conf->queue[i]);
>>   	printf("\n");
>>   
>> -	printf(" function: ");
>> -	switch (rss_conf->func) {
>> -	case RTE_ETH_HASH_FUNCTION_DEFAULT:
>> -		printf("default\n");
>> -		break;
>> -	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
>> -		printf("toeplitz\n");
>> -		break;
>> -	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
>> -		printf("simple_xor\n");
>> -		break;
>> -	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
>> -		printf("symmetric_toeplitz\n");
>> -		break;
>> -	default:
>> -		printf("Unknown function\n");
>> -		return;
>> -	}
>> +	printf(" function: %s\n", rte_eth_dev_rss_algo_name(rss_conf->func));
>>   
> 
> 
> Above modification can be moved to the patch that adds
> 'rte_eth_dev_rss_algo_name()'.
> 
Thanks, will move.
> .
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 35f5e4bbc002..912bf3355c10 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -174,8 +174,8 @@  static void cmd_help_long_parsed(void *parsed_result,
 			" by masks on port X. size is used to indicate the"
 			" hardware supported reta size\n\n"
 
-			"show port (port_id) rss-hash [key]\n"
-			"    Display the RSS hash functions and RSS hash key of port\n\n"
+			"show port (port_id) rss-hash [key | algorithm]\n"
+			"    Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
 
 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
 			"    Clear information for port_id, or all.\n\n"
@@ -3026,15 +3026,17 @@  struct cmd_showport_rss_hash {
 	cmdline_fixed_string_t rss_hash;
 	cmdline_fixed_string_t rss_type;
 	cmdline_fixed_string_t key; /* optional argument */
+	cmdline_fixed_string_t algorithm; /* optional argument */
 };
 
 static void cmd_showport_rss_hash_parsed(void *parsed_result,
 				__rte_unused struct cmdline *cl,
-				void *show_rss_key)
+				__rte_unused void *data)
 {
 	struct cmd_showport_rss_hash *res = parsed_result;
 
-	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
+	port_rss_hash_conf_show(res->port_id,
+		!strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
 }
 
 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
@@ -3049,6 +3051,8 @@  static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
 				 "rss-hash");
 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
+static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
+	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
 
 static cmdline_parse_inst_t cmd_showport_rss_hash = {
 	.f = cmd_showport_rss_hash_parsed,
@@ -3065,7 +3069,7 @@  static cmdline_parse_inst_t cmd_showport_rss_hash = {
 
 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
 	.f = cmd_showport_rss_hash_parsed,
-	.data = (void *)1,
+	.data = NULL,
 	.help_str = "show port <port_id> rss-hash key",
 	.tokens = {
 		(void *)&cmd_showport_rss_hash_show,
@@ -3077,6 +3081,20 @@  static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
 	},
 };
 
+static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
+	.f = cmd_showport_rss_hash_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> rss-hash algorithm",
+	.tokens = {
+		(void *)&cmd_showport_rss_hash_show,
+		(void *)&cmd_showport_rss_hash_port,
+		(void *)&cmd_showport_rss_hash_port_id,
+		(void *)&cmd_showport_rss_hash_rss_hash,
+		(void *)&cmd_showport_rss_hash_rss_algo,
+		NULL,
+	},
+};
+
 /* *** Configure DCB *** */
 struct cmd_config_dcb {
 	cmdline_fixed_string_t port;
@@ -12969,6 +12987,7 @@  static cmdline_parse_ctx_t builtin_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
+	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
 	(cmdline_parse_inst_t *)&cmd_dump,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b9fdb7e8f162..23fb4f8aa781 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1504,24 +1504,7 @@  rss_config_display(struct rte_flow_action_rss *rss_conf)
 		printf(" %d", rss_conf->queue[i]);
 	printf("\n");
 
-	printf(" function: ");
-	switch (rss_conf->func) {
-	case RTE_ETH_HASH_FUNCTION_DEFAULT:
-		printf("default\n");
-		break;
-	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
-		printf("toeplitz\n");
-		break;
-	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
-		printf("simple_xor\n");
-		break;
-	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
-		printf("symmetric_toeplitz\n");
-		break;
-	default:
-		printf("Unknown function\n");
-		return;
-	}
+	printf(" function: %s\n", rte_eth_dev_rss_algo_name(rss_conf->func));
 
 	printf(" RSS key:\n");
 	if (rss_conf->key_len == 0) {
@@ -4486,7 +4469,7 @@  port_rss_reta_info(portid_t port_id,
  * key of the port.
  */
 void
-port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
+port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo)
 {
 	struct rte_eth_rss_conf rss_conf = {0};
 	uint8_t rss_key[RSS_HASH_KEY_LENGTH];
@@ -4536,8 +4519,16 @@  port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 		printf("RSS disabled\n");
 		return;
 	}
+
+	if (show_rss_algo) {
+		printf("RSS algorithm:\n  %s\n",
+			rte_eth_dev_rss_algo_name(rss_conf.algorithm));
+		return;
+	}
+
 	printf("RSS functions:\n");
 	rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
+
 	if (!show_rss_key)
 		return;
 	printf("RSS key:\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 09a36b90b806..9b10a9ea1cf2 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1153,7 +1153,7 @@  int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate,
 int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
 			 uint8_t avail_thresh);
 
-void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
+void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
 			      uint8_t *hash_key, uint8_t hash_key_len);
 int rx_queue_id_is_invalid(queueid_t rxq_id);