[V3,app/testpmd,3/4] app/testpmd: compact RSS types output in some commands

Message ID 20220607083246.12259-4-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
  From: Ferruh Yigit <ferruh.yigit@xilinx.com>

In port info command output, 'show port info all', supported RSS offload
types printed one type per line, and although this information is not
most important part of the command it takes big part of the command
output.

In port RSS hash and flow RSS command output, 'show port 0 rss-hash',
and 'flow query 0 0 rss', all enabled RSS types are printed on one line.
If there are many types, the print will be very long.

Compacting these RSS offloads and types output by fixing the length of the
character string printed on each line, instead of one per line or one line.
Output becomes as following:

Supported RSS offload flow types:
  ipv4-frag  ipv4-tcp  ipv4-udp  ipv4-sctp  ipv4-other  ipv6-frag  ipv6-tcp
  ipv6-udp  ipv6-sctp  ipv6-other  l4-dst-only  l4-src-only  l3-dst-only
  l3-src-only

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

Comments

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

> 
> From: Ferruh Yigit <ferruh.yigit@xilinx.com>
> 
> In port info command output, 'show port info all', supported RSS offload
> types printed one type per line, and although this information is not
> most important part of the command it takes big part of the command
> output.
> 
> In port RSS hash and flow RSS command output, 'show port 0 rss-hash',
> and 'flow query 0 0 rss', all enabled RSS types are printed on one line.
> If there are many types, the print will be very long.
> 
> Compacting these RSS offloads and types output by fixing the length of the
> character string printed on each line, instead of one per line or one line.
> Output becomes as following:
> 
> Supported RSS offload flow types:
>    ipv4-frag  ipv4-tcp  ipv4-udp  ipv4-sctp  ipv4-other  ipv6-frag  ipv6-tcp
>    ipv6-udp  ipv6-sctp  ipv6-other  l4-dst-only  l4-src-only  l3-dst-only
>    l3-src-only
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
>   app/test-pmd/config.c | 64 ++++++++++++++++++++++++++++++++-----------
>   1 file changed, 48 insertions(+), 16 deletions(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 9cb1211f00..209cbcc514 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -66,6 +66,8 @@
> 
>   #define NS_PER_SEC 1E9
> 
> +#define MAX_CHAR_NUM_PER_LINE 64
> +
>   static const struct {
>          enum tx_pkt_split split;
>          const char *name;
> @@ -198,6 +200,8 @@ const struct rss_type_info rss_type_table[] = {
>   static void
>   rss_types_display(uint64_t rss_types)
>   {
> +       uint16_t total_len = 0;
> +       uint16_t str_len = 0;
>          uint16_t i;
> 
>          if (rss_types == 0)
> @@ -206,9 +210,18 @@ rss_types_display(uint64_t rss_types)
>          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)
> +                                               rss_type_table[i].rss_type) {
> +                       /* contain two blanks */
> +                       str_len = strlen(rss_type_table[i].str) + 2;
> +                       if (total_len + str_len > MAX_CHAR_NUM_PER_LINE) {
> +                               printf("\n");
> +                               total_len = 0;
> +                       }
>                          printf("  %s", rss_type_table[i].str);
> +                       total_len += str_len;
> +               }
>          }
>   }
> 
> @@ -766,6 +779,38 @@ rss_offload_to_str(uint64_t rss_offload)
>          return NULL;
>   }
> 
> +static void
> +rss_offload_types_display(uint64_t rss_offload_types)
> +{
> +#define USER_DEFINED_DISPLAY_STR_LEN 23
> +
> +       uint16_t total_len = 0;
> +       uint16_t str_len = 0;
> +       uint64_t rss_offload;
> +       uint16_t i;
> +
> +       for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
> +               rss_offload = RTE_BIT64(i);
> +               if ((rss_offload_types & rss_offload) != 0) {
> +                       const char *p = rss_offload_to_str(rss_offload);
> +
> +                       str_len = p ? strlen(p) : USER_DEFINED_DISPLAY_STR_LEN;
> +                       str_len += 2; /* add two blanks */
> +                       if (total_len + str_len >= MAX_CHAR_NUM_PER_LINE) {
> +                               total_len = 0;
> +                               printf("\n");
> +                       }
> +
> +                       if (p)
> +                               printf("  %s", p);
> +                       else
> +                               printf("  user defined 0x%"PRIx64"",
> +                                      rss_offload);
> +                       total_len += str_len;
> +               }
> +       }
> +}

If you go with 'rss_type_table[]', above function can be used for both 
'port_infos_display()' and 'rss_types_display()', what do you think?
And perhaps 'rss_offload_types_display()' can get length as parameter.

> +
>   void
>   port_infos_display(portid_t port_id)
>   {
> @@ -870,22 +915,9 @@ port_infos_display(portid_t port_id)
>          if (!dev_info.flow_type_rss_offloads)
>                  printf("No RSS offload flow type is supported.\n");
>          else {
> -               uint64_t rss_offload_types = dev_info.flow_type_rss_offloads;
> -               uint16_t i;
> -
>                  printf("Supported RSS offload flow types:\n");
> -               for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
> -                       uint64_t rss_offload = RTE_BIT64(i);
> -                       if ((rss_offload_types & rss_offload) != 0) {
> -                               const char *p =
> -                                       rss_offload_to_str(rss_offload);
> -                               if (p)
> -                                       printf("  %s\n", p);
> -                               else
> -                                       printf("  user defined 0x%"PRIx64"\n",
> -                                              rss_offload);
> -                       }
> -               }
> +               rss_offload_types_display(dev_info.flow_type_rss_offloads);
> +               printf("\n");
>          }
> 
>          printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize);
> --
> 2.33.0
>
  
lihuisong (C) June 9, 2022, 3:41 a.m. UTC | #2
在 2022/6/7 23:46, Ferruh Yigit 写道:
> On 6/7/2022 9:32 AM, Huisong Li wrote:
>
>>
>> From: Ferruh Yigit <ferruh.yigit@xilinx.com>
>>
>> In port info command output, 'show port info all', supported RSS offload
>> types printed one type per line, and although this information is not
>> most important part of the command it takes big part of the command
>> output.
>>
>> In port RSS hash and flow RSS command output, 'show port 0 rss-hash',
>> and 'flow query 0 0 rss', all enabled RSS types are printed on one line.
>> If there are many types, the print will be very long.
>>
>> Compacting these RSS offloads and types output by fixing the length 
>> of the
>> character string printed on each line, instead of one per line or one 
>> line.
>> Output becomes as following:
>>
>> Supported RSS offload flow types:
>>    ipv4-frag  ipv4-tcp  ipv4-udp  ipv4-sctp  ipv4-other ipv6-frag  
>> ipv6-tcp
>>    ipv6-udp  ipv6-sctp  ipv6-other  l4-dst-only  l4-src-only l3-dst-only
>>    l3-src-only
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>>   app/test-pmd/config.c | 64 ++++++++++++++++++++++++++++++++-----------
>>   1 file changed, 48 insertions(+), 16 deletions(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index 9cb1211f00..209cbcc514 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -66,6 +66,8 @@
>>
>>   #define NS_PER_SEC 1E9
>>
>> +#define MAX_CHAR_NUM_PER_LINE 64
>> +
>>   static const struct {
>>          enum tx_pkt_split split;
>>          const char *name;
>> @@ -198,6 +200,8 @@ const struct rss_type_info rss_type_table[] = {
>>   static void
>>   rss_types_display(uint64_t rss_types)
>>   {
>> +       uint16_t total_len = 0;
>> +       uint16_t str_len = 0;
>>          uint16_t i;
>>
>>          if (rss_types == 0)
>> @@ -206,9 +210,18 @@ rss_types_display(uint64_t rss_types)
>>          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)
>> + rss_type_table[i].rss_type) {
>> +                       /* contain two blanks */
>> +                       str_len = strlen(rss_type_table[i].str) + 2;
>> +                       if (total_len + str_len > 
>> MAX_CHAR_NUM_PER_LINE) {
>> +                               printf("\n");
>> +                               total_len = 0;
>> +                       }
>>                          printf("  %s", rss_type_table[i].str);
>> +                       total_len += str_len;
>> +               }
>>          }
>>   }
>>
>> @@ -766,6 +779,38 @@ rss_offload_to_str(uint64_t rss_offload)
>>          return NULL;
>>   }
>>
>> +static void
>> +rss_offload_types_display(uint64_t rss_offload_types)
>> +{
>> +#define USER_DEFINED_DISPLAY_STR_LEN 23
>> +
>> +       uint16_t total_len = 0;
>> +       uint16_t str_len = 0;
>> +       uint64_t rss_offload;
>> +       uint16_t i;
>> +
>> +       for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
>> +               rss_offload = RTE_BIT64(i);
>> +               if ((rss_offload_types & rss_offload) != 0) {
>> +                       const char *p = rss_offload_to_str(rss_offload);
>> +
>> +                       str_len = p ? strlen(p) : 
>> USER_DEFINED_DISPLAY_STR_LEN;
>> +                       str_len += 2; /* add two blanks */
>> +                       if (total_len + str_len >= 
>> MAX_CHAR_NUM_PER_LINE) {
>> +                               total_len = 0;
>> +                               printf("\n");
>> +                       }
>> +
>> +                       if (p)
>> +                               printf("  %s", p);
>> +                       else
>> +                               printf("  user defined 0x%"PRIx64"",
>> +                                      rss_offload);
>> +                       total_len += str_len;
>> +               }
>> +       }
>> +}
>
> If you go with 'rss_type_table[]', above function can be used for both 
> 'port_infos_display()' and 'rss_types_display()', what do you think?
I just don't think it's appropriate to use this table for that.
> And perhaps 'rss_offload_types_display()' can get length as parameter.
Ack.
>
>> +
>>   void
>>   port_infos_display(portid_t port_id)
>>   {
>> @@ -870,22 +915,9 @@ port_infos_display(portid_t port_id)
>>          if (!dev_info.flow_type_rss_offloads)
>>                  printf("No RSS offload flow type is supported.\n");
>>          else {
>> -               uint64_t rss_offload_types = 
>> dev_info.flow_type_rss_offloads;
>> -               uint16_t i;
>> -
>>                  printf("Supported RSS offload flow types:\n");
>> -               for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; 
>> i++) {
>> -                       uint64_t rss_offload = RTE_BIT64(i);
>> -                       if ((rss_offload_types & rss_offload) != 0) {
>> -                               const char *p =
>> - rss_offload_to_str(rss_offload);
>> -                               if (p)
>> -                                       printf("  %s\n", p);
>> -                               else
>> -                                       printf("  user defined 
>> 0x%"PRIx64"\n",
>> -                                              rss_offload);
>> -                       }
>> -               }
>> + rss_offload_types_display(dev_info.flow_type_rss_offloads);
>> +               printf("\n");
>>          }
>>
>>          printf("Minimum size of RX buffer: %u\n", 
>> dev_info.min_rx_bufsize);
>> -- 
>> 2.33.0
>>
>
> .
  
Ferruh Yigit June 20, 2022, 12:37 p.m. UTC | #3
On 6/9/2022 4:41 AM, lihuisong (C) wrote:
> CAUTION: This message has originated from an External Source. Please use 
> proper judgment and caution when opening attachments, clicking links, or 
> responding to this email.
> 
> 
> 在 2022/6/7 23:46, Ferruh Yigit 写道:
>> On 6/7/2022 9:32 AM, Huisong Li wrote:
>>
>>>
>>> From: Ferruh Yigit <ferruh.yigit@xilinx.com>
>>>
>>> In port info command output, 'show port info all', supported RSS offload
>>> types printed one type per line, and although this information is not
>>> most important part of the command it takes big part of the command
>>> output.
>>>
>>> In port RSS hash and flow RSS command output, 'show port 0 rss-hash',
>>> and 'flow query 0 0 rss', all enabled RSS types are printed on one line.
>>> If there are many types, the print will be very long.
>>>
>>> Compacting these RSS offloads and types output by fixing the length
>>> of the
>>> character string printed on each line, instead of one per line or one
>>> line.
>>> Output becomes as following:
>>>
>>> Supported RSS offload flow types:
>>>    ipv4-frag  ipv4-tcp  ipv4-udp  ipv4-sctp  ipv4-other ipv6-frag
>>> ipv6-tcp
>>>    ipv6-udp  ipv6-sctp  ipv6-other  l4-dst-only  l4-src-only l3-dst-only
>>>    l3-src-only
>>>
>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> ---
>>>   app/test-pmd/config.c | 64 ++++++++++++++++++++++++++++++++-----------
>>>   1 file changed, 48 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>>> index 9cb1211f00..209cbcc514 100644
>>> --- a/app/test-pmd/config.c
>>> +++ b/app/test-pmd/config.c
>>> @@ -66,6 +66,8 @@
>>>
>>>   #define NS_PER_SEC 1E9
>>>
>>> +#define MAX_CHAR_NUM_PER_LINE 64
>>> +
>>>   static const struct {
>>>          enum tx_pkt_split split;
>>>          const char *name;
>>> @@ -198,6 +200,8 @@ const struct rss_type_info rss_type_table[] = {
>>>   static void
>>>   rss_types_display(uint64_t rss_types)
>>>   {
>>> +       uint16_t total_len = 0;
>>> +       uint16_t str_len = 0;
>>>          uint16_t i;
>>>
>>>          if (rss_types == 0)
>>> @@ -206,9 +210,18 @@ rss_types_display(uint64_t rss_types)
>>>          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)
>>> + rss_type_table[i].rss_type) {
>>> +                       /* contain two blanks */
>>> +                       str_len = strlen(rss_type_table[i].str) + 2;
>>> +                       if (total_len + str_len >
>>> MAX_CHAR_NUM_PER_LINE) {
>>> +                               printf("\n");
>>> +                               total_len = 0;
>>> +                       }
>>>                          printf("  %s", rss_type_table[i].str);
>>> +                       total_len += str_len;
>>> +               }
>>>          }
>>>   }
>>>
>>> @@ -766,6 +779,38 @@ rss_offload_to_str(uint64_t rss_offload)
>>>          return NULL;
>>>   }
>>>
>>> +static void
>>> +rss_offload_types_display(uint64_t rss_offload_types)
>>> +{
>>> +#define USER_DEFINED_DISPLAY_STR_LEN 23
>>> +
>>> +       uint16_t total_len = 0;
>>> +       uint16_t str_len = 0;
>>> +       uint64_t rss_offload;
>>> +       uint16_t i;
>>> +
>>> +       for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
>>> +               rss_offload = RTE_BIT64(i);
>>> +               if ((rss_offload_types & rss_offload) != 0) {
>>> +                       const char *p = rss_offload_to_str(rss_offload);
>>> +
>>> +                       str_len = p ? strlen(p) :
>>> USER_DEFINED_DISPLAY_STR_LEN;
>>> +                       str_len += 2; /* add two blanks */
>>> +                       if (total_len + str_len >=
>>> MAX_CHAR_NUM_PER_LINE) {
>>> +                               total_len = 0;
>>> +                               printf("\n");
>>> +                       }
>>> +
>>> +                       if (p)
>>> +                               printf("  %s", p);
>>> +                       else
>>> +                               printf("  user defined 0x%"PRIx64"",
>>> +                                      rss_offload);
>>> +                       total_len += str_len;
>>> +               }
>>> +       }
>>> +}
>>
>> If you go with 'rss_type_table[]', above function can be used for both
>> 'port_infos_display()' and 'rss_types_display()', what do you think?
> I just don't think it's appropriate to use this table for that.

I put some more comment to other patch on why 'rss_type_table[]' can be 
used.

>> And perhaps 'rss_offload_types_display()' can get length as parameter.
> Ack.
>>
>>> +
>>>   void
>>>   port_infos_display(portid_t port_id)
>>>   {
>>> @@ -870,22 +915,9 @@ port_infos_display(portid_t port_id)
>>>          if (!dev_info.flow_type_rss_offloads)
>>>                  printf("No RSS offload flow type is supported.\n");
>>>          else {
>>> -               uint64_t rss_offload_types =
>>> dev_info.flow_type_rss_offloads;
>>> -               uint16_t i;
>>> -
>>>                  printf("Supported RSS offload flow types:\n");
>>> -               for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT;
>>> i++) {
>>> -                       uint64_t rss_offload = RTE_BIT64(i);
>>> -                       if ((rss_offload_types & rss_offload) != 0) {
>>> -                               const char *p =
>>> - rss_offload_to_str(rss_offload);
>>> -                               if (p)
>>> -                                       printf("  %s\n", p);
>>> -                               else
>>> -                                       printf("  user defined
>>> 0x%"PRIx64"\n",
>>> -                                              rss_offload);
>>> -                       }
>>> -               }
>>> + rss_offload_types_display(dev_info.flow_type_rss_offloads);
>>> +               printf("\n");
>>>          }
>>>
>>>          printf("Minimum size of RX buffer: %u\n",
>>> dev_info.min_rx_bufsize);
>>> -- 
>>> 2.33.0
>>>
>>
>> .
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9cb1211f00..209cbcc514 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -66,6 +66,8 @@ 
 
 #define NS_PER_SEC 1E9
 
+#define MAX_CHAR_NUM_PER_LINE 64
+
 static const struct {
 	enum tx_pkt_split split;
 	const char *name;
@@ -198,6 +200,8 @@  const struct rss_type_info rss_type_table[] = {
 static void
 rss_types_display(uint64_t rss_types)
 {
+	uint16_t total_len = 0;
+	uint16_t str_len = 0;
 	uint16_t i;
 
 	if (rss_types == 0)
@@ -206,9 +210,18 @@  rss_types_display(uint64_t rss_types)
 	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)
+						rss_type_table[i].rss_type) {
+			/* contain two blanks */
+			str_len = strlen(rss_type_table[i].str) + 2;
+			if (total_len + str_len > MAX_CHAR_NUM_PER_LINE) {
+				printf("\n");
+				total_len = 0;
+			}
 			printf("  %s", rss_type_table[i].str);
+			total_len += str_len;
+		}
 	}
 }
 
@@ -766,6 +779,38 @@  rss_offload_to_str(uint64_t rss_offload)
 	return NULL;
 }
 
+static void
+rss_offload_types_display(uint64_t rss_offload_types)
+{
+#define USER_DEFINED_DISPLAY_STR_LEN 23
+
+	uint16_t total_len = 0;
+	uint16_t str_len = 0;
+	uint64_t rss_offload;
+	uint16_t i;
+
+	for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
+		rss_offload = RTE_BIT64(i);
+		if ((rss_offload_types & rss_offload) != 0) {
+			const char *p = rss_offload_to_str(rss_offload);
+
+			str_len = p ? strlen(p) : USER_DEFINED_DISPLAY_STR_LEN;
+			str_len += 2; /* add two blanks */
+			if (total_len + str_len >= MAX_CHAR_NUM_PER_LINE) {
+				total_len = 0;
+				printf("\n");
+			}
+
+			if (p)
+				printf("  %s", p);
+			else
+				printf("  user defined 0x%"PRIx64"",
+				       rss_offload);
+			total_len += str_len;
+		}
+	}
+}
+
 void
 port_infos_display(portid_t port_id)
 {
@@ -870,22 +915,9 @@  port_infos_display(portid_t port_id)
 	if (!dev_info.flow_type_rss_offloads)
 		printf("No RSS offload flow type is supported.\n");
 	else {
-		uint64_t rss_offload_types = dev_info.flow_type_rss_offloads;
-		uint16_t i;
-
 		printf("Supported RSS offload flow types:\n");
-		for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
-			uint64_t rss_offload = RTE_BIT64(i);
-			if ((rss_offload_types & rss_offload) != 0) {
-				const char *p =
-					rss_offload_to_str(rss_offload);
-				if (p)
-					printf("  %s\n", p);
-				else
-					printf("  user defined 0x%"PRIx64"\n",
-					       rss_offload);
-			}
-		}
+		rss_offload_types_display(dev_info.flow_type_rss_offloads);
+		printf("\n");
 	}
 
 	printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize);