[5/5] app/proc-info: support querying RSS hash algorithm

Message ID 20230904072851.7384-6-haijie1@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [1/5] ethdev: support setting and querying RSS algorithm |

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/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Jie Hai Sept. 4, 2023, 7:28 a.m. UTC
  Display RSS hash algorithm with command show-port as below.
  - RSS info
	  -- hash algorithm : toeplitz

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

Comments

Pattan, Reshma Sept. 5, 2023, 5:07 p.m. UTC | #1
> -----Original Message-----
> From: Jie Hai <haijie1@huawei.com>
> 
> +static const char *
> +rss_func_to_str(enum rte_eth_hash_function func) {
> +	switch (func) {
> +	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
> +		return "simple_xor";
> +	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
> +		return "toeplitz";
> +	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
> +		return "symmetric_toeplitz";
> +	case RTE_ETH_HASH_FUNCTION_DEFAULT:
> +		return "default";
> +	default:
> +		return "unknown";
> +	}
> +}
> +


Instead of above function you can declare const array of strings as below to map hash function names.

static const char * const hf_names[] = {
        [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = " simple_xor ",
        [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = " toeplitz ",
        [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = " symmetric_toeplitz ",
        [RTE_ETH_HASH_FUNCTION_DEFAULT] = "default"
};


> +			printf("\t  -- hash algorithm : %s\n",
> +				rss_func_to_str(rss_conf.func));
>  		}
> 

And then print  as below ?
printf("\t  -- hash algorithm : %s\n", hf_names [rss_conf.func]);
  
Jie Hai Sept. 8, 2023, 8:01 a.m. UTC | #2
Hi, Pattan, Reshma

On 2023/9/6 1:07, Pattan, Reshma wrote:
> 
> Instead of above function you can declare const array of strings as below to map hash function names.
> 
> static const char * const hf_names[] = {
>          [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = " simple_xor ",
>          [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = " toeplitz ",
>          [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = " symmetric_toeplitz ",
>          [RTE_ETH_HASH_FUNCTION_DEFAULT] = "default"
> };
> 
> 
>> +			printf("\t  -- hash algorithm : %s\n",
>> +				rss_func_to_str(rss_conf.func));
>>   		}
>>
> And then print  as below ?
> printf("\t  -- hash algorithm : %s\n", hf_names [rss_conf.func]);
> .
Thanks for your review, that sounds better, will fix it.

Thanks,
Jie Hai
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 6d2d77fea6ba..02b418a4c661 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -996,6 +996,23 @@  show_offloads(uint64_t offloads,
 	}
 }
 
+static const char *
+rss_func_to_str(enum rte_eth_hash_function func)
+{
+	switch (func) {
+	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
+		return "simple_xor";
+	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
+		return "toeplitz";
+	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
+		return "symmetric_toeplitz";
+	case RTE_ETH_HASH_FUNCTION_DEFAULT:
+		return "default";
+	default:
+		return "unknown";
+	}
+}
+
 static void
 show_port(void)
 {
@@ -1188,6 +1205,8 @@  show_port(void)
 				printf("%02x", rss_conf.rss_key[k]);
 			printf("\n\t  -- hf : 0x%"PRIx64"\n",
 					rss_conf.rss_hf);
+			printf("\t  -- hash algorithm : %s\n",
+				rss_func_to_str(rss_conf.func));
 		}
 
 		free(rss_key);