[v4,4/7] app/proc-info: fix never show RSS info

Message ID 20230908080030.3837515-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. 8, 2023, 8 a.m. UTC
  Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is shown only when rss_conf.rss_key is not
NULL. Since no memory is allocated for rss_conf.rss_key, rss_key
will always be NULL and the rss_info will never show. 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@dpdk.org

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

Comments

Pattan, Reshma Sept. 13, 2023, 11:48 a.m. UTC | #1
> -----Original Message-----
> From: Jie Hai <haijie1@huawei.com>
> Sent: Friday, September 8, 2023 9:00 AM
> To: dev@dpdk.org; Pattan, Reshma <reshma.pattan@intel.com>; Vipin
> Varghese <vipin.varghese@amd.com>; Mcnamara, John
> <john.mcnamara@intel.com>
> Cc: haijie1@huawei.com; lihuisong@huawei.com
> Subject: [PATCH v4 4/7] app/proc-info: fix never show RSS info
> 
> Command show-port should show RSS info (rss_key, len and rss_hf), However,
> the information is shown only when rss_conf.rss_key is not NULL. Since no
> memory is allocated for rss_conf.rss_key, rss_key will always be NULL and the
> rss_info will never show. This patch allocates memory for rss_conf.rss_key and
> makes it possible to show RSS info.
> 

Nitpick:
You have to change the commit message as malloc and free not used now.

Acked-by: Reshma Pattan <reshma.pattan@intel.com>
  
Jie Hai Sept. 25, 2023, 1:13 a.m. UTC | #2
On 2023/9/13 19:48, Pattan, Reshma wrote:
> 
> 
>> -----Original Message-----
>> From: Jie Hai <haijie1@huawei.com>
>> Sent: Friday, September 8, 2023 9:00 AM
>> To: dev@dpdk.org; Pattan, Reshma <reshma.pattan@intel.com>; Vipin
>> Varghese <vipin.varghese@amd.com>; Mcnamara, John
>> <john.mcnamara@intel.com>
>> Cc: haijie1@huawei.com; lihuisong@huawei.com
>> Subject: [PATCH v4 4/7] app/proc-info: fix never show RSS info
>>
>> Command show-port should show RSS info (rss_key, len and rss_hf), However,
>> the information is shown only when rss_conf.rss_key is not NULL. Since no
>> memory is allocated for rss_conf.rss_key, rss_key will always be NULL and the
>> rss_info will never show. This patch allocates memory for rss_conf.rss_key and
>> makes it possible to show RSS info.
>>
> 
Hi, Pattan, Reshma
> Nitpick:
> You have to change the commit message as malloc and free not used now.
> 
> Acked-by: Reshma Pattan <reshma.pattan@intel.com>
> 
> 
Thanks for your comment, will do in next version.

Best regards,
Jie Hai
> 
> 
> .
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..95dd4514b3c9 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -152,6 +152,8 @@  struct desc_param {
 static struct desc_param rx_desc_param;
 static struct desc_param tx_desc_param;
 
+#define RSS_HASH_KEY_SIZE 64
+
 /* display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -1013,6 +1015,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[RSS_HASH_KEY_SIZE];
 
 		/* Skip if port is not in mask */
 		if ((enabled_port_mask & (1ul << i)) == 0)
@@ -1171,17 +1174,17 @@  show_port(void)
 			printf("\n");
 		}
 
+		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);
 		}
 
 #ifdef RTE_LIB_SECURITY