[v3,4/5] app/testpmd: add RSS hash algorithms display

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jie Hai Sept. 4, 2023, 6:10 a.m. UTC
  1. Add the command "show port X rss-hash func" to display the RSS hash
algorithms of port X.
2. Add the command "show port X rss-hash all" to display the RSS hash
configuration of port X, including RSS hash types, key and algorithms.

Signed-off-by: Jie Hai <haijie1@huawei.com>
---
 app/test-pmd/cmdline.c | 50 +++++++++++++++++++++++++++++++++++++-----
 app/test-pmd/config.c  | 46 +++++++++++++++++++++++---------------
 app/test-pmd/testpmd.h |  2 +-
 3 files changed, 74 insertions(+), 24 deletions(-)
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0d0723f6596e..e7888be305da 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 | func | all]\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"
@@ -3017,15 +3017,21 @@  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 func; /* optional argument */
+	cmdline_fixed_string_t all; /* 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);
+	if (!strcmp(res->all, "all"))
+		port_rss_hash_conf_show(res->port_id, true, true);
+	else
+		port_rss_hash_conf_show(res->port_id,
+			!strcmp(res->key, "key"), !strcmp(res->func, "func"));
 }
 
 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
@@ -3040,6 +3046,10 @@  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_func =
+	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, func, "func");
+static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, all, "all");
 
 static cmdline_parse_inst_t cmd_showport_rss_hash = {
 	.f = cmd_showport_rss_hash_parsed,
@@ -3056,7 +3066,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,
@@ -3068,6 +3078,34 @@  static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
 	},
 };
 
+static cmdline_parse_inst_t cmd_showport_rss_hash_func = {
+	.f = cmd_showport_rss_hash_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> rss-hash func",
+	.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_func,
+		NULL,
+	},
+};
+
+static cmdline_parse_inst_t cmd_showport_rss_hash_all = {
+	.f = cmd_showport_rss_hash_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> rss-hash all",
+	.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_all,
+		NULL,
+	},
+};
+
 /* *** Configure DCB *** */
 struct cmd_config_dcb {
 	cmdline_fixed_string_t port;
@@ -12905,6 +12943,8 @@  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_func,
+	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_all,
 	(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 11f3a2204839..65eca8467d61 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1485,6 +1485,27 @@  rss_types_display(uint64_t rss_types, uint16_t char_num_per_line)
 	printf("\n");
 }
 
+static void rss_algo_display(enum rte_eth_hash_function func)
+{
+	switch (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;
+	}
+}
+
 static void
 rss_config_display(struct rte_flow_action_rss *rss_conf)
 {
@@ -1504,23 +1525,7 @@  rss_config_display(struct rte_flow_action_rss *rss_conf)
 	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;
-	}
+	rss_algo_display(rss_conf->func);
 
 	printf(" RSS key:\n");
 	if (rss_conf->key_len == 0) {
@@ -4406,7 +4411,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_func)
 {
 	struct rte_eth_rss_conf rss_conf = {0};
 	uint8_t rss_key[RSS_HASH_KEY_LENGTH];
@@ -4458,6 +4463,11 @@  port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 	}
 	printf("RSS functions:\n");
 	rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
+
+	if (show_rss_func) {
+		printf("RSS algorithms:\n  ");
+		rss_algo_display(rss_conf.func);
+	}
 	if (!show_rss_key)
 		return;
 	printf("RSS key:\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index f1df6a8fafaa..3dc2f47280ad 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1146,7 +1146,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_func);
 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);