[V3,app/testpmd,2/4] app/testpmd: unify RSS types display and obtaination

Message ID 20220607083246.12259-3-lihuisong@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series fix RSS types and flow type |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

lihuisong (C) June 7, 2022, 8:32 a.m. UTC
  The 'rss_type_table[]' maintains string name and value of RSS types. This
patch unifies a common interface to display or obtain RSS types.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
 app/test-pmd/config.c | 59 +++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 24 deletions(-)
  

Comments

Ferruh Yigit June 7, 2022, 3:46 p.m. UTC | #1
On 6/7/2022 9:32 AM, Huisong Li wrote:

> 
> The 'rss_type_table[]' maintains string name and value of RSS types. This
> patch unifies a common interface to display or obtain RSS types.
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>

<...>

> @@ -5669,6 +5681,7 @@ set_record_burst_stats(uint8_t on_off)
>          record_burst_stats = on_off;
>   }
> 
> +#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
>   static char*
>   flowtype_to_str(uint16_t flow_type)
>   {
> @@ -5712,8 +5725,6 @@ flowtype_to_str(uint16_t flow_type)
>          return NULL;
>   }
> 
> -#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
> -

I think this change should be in first patch (v1/4) where 
'flowtype_to_str' stopped being used.
  
lihuisong (C) June 9, 2022, 3:25 a.m. UTC | #2
在 2022/6/7 23:46, Ferruh Yigit 写道:
> On 6/7/2022 9:32 AM, Huisong Li wrote:
>
>>
>> The 'rss_type_table[]' maintains string name and value of RSS types. 
>> This
>> patch unifies a common interface to display or obtain RSS types.
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
>
> <...>
>
>> @@ -5669,6 +5681,7 @@ set_record_burst_stats(uint8_t on_off)
>>          record_burst_stats = on_off;
>>   }
>>
>> +#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
>>   static char*
>>   flowtype_to_str(uint16_t flow_type)
>>   {
>> @@ -5712,8 +5725,6 @@ flowtype_to_str(uint16_t flow_type)
>>          return NULL;
>>   }
>>
>> -#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
>> -
>
> I think this change should be in first patch (v1/4) where 
> 'flowtype_to_str' stopped being used.
Ack.
>
> .
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index d290ca3a06..9cb1211f00 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -66,8 +66,6 @@ 
 
 #define NS_PER_SEC 1E9
 
-static char *flowtype_to_str(uint16_t flow_type);
-
 static const struct {
 	enum tx_pkt_split split;
 	const char *name;
@@ -197,6 +195,36 @@  const struct rss_type_info rss_type_table[] = {
 	{ NULL, 0 },
 };
 
+static void
+rss_types_display(uint64_t rss_types)
+{
+	uint16_t i;
+
+	if (rss_types == 0)
+		return;
+
+	for (i = 0; rss_type_table[i].str; i++) {
+		if (rss_type_table[i].rss_type == 0)
+			continue;
+		if ((rss_types & rss_type_table[i].rss_type) ==
+						rss_type_table[i].rss_type)
+			printf("  %s", rss_type_table[i].str);
+	}
+}
+
+static uint64_t
+str_to_rsstypes(const char *str)
+{
+	uint16_t i;
+
+	for (i = 0; rss_type_table[i].str != NULL; i++) {
+		if (strcmp(rss_type_table[i].str, str) == 0)
+			return rss_type_table[i].rss_type;
+	}
+
+	return 0;
+}
+
 static const struct {
 	enum rte_eth_fec_mode mode;
 	const char *name;
@@ -1651,13 +1679,7 @@  rss_config_display(struct rte_flow_action_rss *rss_conf)
 		printf("  none\n");
 		return;
 	}
-	for (i = 0; rss_type_table[i].str; i++) {
-		if ((rss_conf->types &
-		    rss_type_table[i].rss_type) ==
-		    rss_type_table[i].rss_type &&
-		    rss_type_table[i].rss_type != 0)
-			printf("  %s\n", rss_type_table[i].str);
-	}
+	rss_types_display(rss_conf->types);
 }
 
 static struct port_indirect_action *
@@ -3887,13 +3909,8 @@  port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 		printf("RSS disabled\n");
 		return;
 	}
-	printf("RSS functions:\n ");
-	for (i = 0; rss_type_table[i].str; i++) {
-		if (rss_type_table[i].rss_type == 0)
-			continue;
-		if ((rss_hf & rss_type_table[i].rss_type) == rss_type_table[i].rss_type)
-			printf("%s ", rss_type_table[i].str);
-	}
+	printf("RSS functions:\n");
+	rss_types_display(rss_hf);
 	printf("\n");
 	if (!show_rss_key)
 		return;
@@ -3909,15 +3926,10 @@  port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 {
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
-	unsigned int i;
 
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = 0;
-	rss_conf.rss_hf = 0;
-	for (i = 0; rss_type_table[i].str; i++) {
-		if (!strcmp(rss_type_table[i].str, rss_type))
-			rss_conf.rss_hf = rss_type_table[i].rss_type;
-	}
+	rss_conf.rss_hf = str_to_rsstypes(rss_type);
 	diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
 	if (diag == 0) {
 		rss_conf.rss_key = hash_key;
@@ -5669,6 +5681,7 @@  set_record_burst_stats(uint8_t on_off)
 	record_burst_stats = on_off;
 }
 
+#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
 static char*
 flowtype_to_str(uint16_t flow_type)
 {
@@ -5712,8 +5725,6 @@  flowtype_to_str(uint16_t flow_type)
 	return NULL;
 }
 
-#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
-
 static inline void
 print_fdir_mask(struct rte_eth_fdir_masks *mask)
 {