[PATCH 3/5] app/proc-info: fix never show RSS info

Dongdong Liu liudongdong3 at huawei.com
Wed Mar 15 12:00:31 CET 2023


From: Jie Hai <haijie1 at huawei.com>

Command show-port shows rss info only if rss_conf.rss_key
is not null but it will never be true. This patch allocates
memory for rss_conf.rss_key and makes it possible to show
rss info.

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: stable at dpdk.org

Signed-off-by: Jie Hai <haijie1 at huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3 at huawei.com>
---
 app/proc-info/main.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..878ce37e8b 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -823,6 +823,7 @@ show_port(void)
 		struct rte_eth_fc_conf fc_conf;
 		struct rte_ether_addr mac;
 		struct rte_eth_dev_owner owner;
+		uint8_t *rss_key;
 
 		/* Skip if port is not in mask */
 		if ((enabled_port_mask & (1ul << i)) == 0)
@@ -981,19 +982,26 @@ show_port(void)
 			printf("\n");
 		}
 
+		rss_key = rte_malloc(NULL,
+			dev_info.hash_key_size * sizeof(uint8_t), 0);
+		if (rss_key == NULL)
+			return;
+
+		rss_conf.rss_key = rss_key;
+		rss_conf.rss_key_len = dev_info.hash_key_size;
 		ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
 		if (ret == 0) {
-			if (rss_conf.rss_key) {
-				printf("  - RSS\n");
-				printf("\t  -- RSS len %u key (hex):",
-						rss_conf.rss_key_len);
-				for (k = 0; k < rss_conf.rss_key_len; k++)
-					printf(" %x", rss_conf.rss_key[k]);
-				printf("\t  -- hf 0x%"PRIx64"\n",
-						rss_conf.rss_hf);
-			}
+			printf("  - RSS\n");
+			printf("\t  -- RSS len %u key (hex):",
+					rss_conf.rss_key_len);
+			for (k = 0; k < rss_conf.rss_key_len; k++)
+				printf(" %x", rss_conf.rss_key[k]);
+			printf("\t  -- hf 0x%"PRIx64"\n",
+					rss_conf.rss_hf);
 		}
 
+		rte_free(rss_key);
+
 #ifdef RTE_LIB_SECURITY
 		show_security_context(i, true);
 #endif
-- 
2.22.0



More information about the stable mailing list