[3/5] app/proc-info: fix never show RSS info
Checks
Commit Message
Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is showned 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 | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
Comments
> -----Original Message-----
> + uint8_t *rss_key;
Instead of pointer can you just take key of type below, so u no need to do dynamic memory allocation using malloc and free .
Ex: uint8_t hash_key[RSS_HASH_KEY_LENGTH];
And then do below ?
rss_conf.rss_key = hash_key;
Hi, Pattan, Reshma
On 2023/9/6 0:29, Pattan, Reshma wrote:
>
>
>> -----Original Message-----
>> + uint8_t *rss_key;
>
> Instead of pointer can you just take key of type below, so u no need to do dynamic memory allocation using malloc and free .
>
> Ex: uint8_t hash_key[RSS_HASH_KEY_LENGTH];
>
> And then do below ?
> rss_conf.rss_key = hash_key;
> .
Thanks for your review, will fix it in next version.
Thanks,
Jie Hai
@@ -1013,6 +1013,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)
@@ -1171,19 +1172,25 @@ show_port(void)
printf("\n");
}
+ rss_key = malloc(dev_info.hash_key_size * sizeof(uint8_t));
+ 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);
}
+ free(rss_key);
+
#ifdef RTE_LIB_SECURITY
show_security_context(i, true);
#endif