[PATCH 4/5] app/proc-info: show RSS types with strings

Dongdong Liu liudongdong3 at huawei.com
Wed Mar 15 12:00:32 CET 2023


From: Jie Hai <haijie1 at huawei.com>

show RSS types details and adjust RSS info display format as following:

  - RSS info
	  -- hf:
		ipv4  ipv4-frag  ipv4-other  ipv6  ipv6-frag  ipv6-other
	  -- key len: 40
	  -- key (hex): 6d5a56da255b0ec24167253d43a38fb0d0ca2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa

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

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 878ce37e8b..7b6f8f1228 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -54,6 +54,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+/* It is used to print the RSS types. */
+#define RSS_TYPES_CHAR_NUM_PER_LINE 64
+
 /* mask of enabled ports */
 static unsigned long enabled_port_mask;
 /* Enable stats. */
@@ -132,6 +135,76 @@ struct desc_param {
 static struct desc_param rx_desc_param;
 static struct desc_param tx_desc_param;
 
+/* Information for a given RSS type. */
+struct rss_type_info {
+	const char *str; /* Type name. */
+	uint64_t rss_type; /* Type value. */
+};
+
+static const struct rss_type_info rss_type_table[] = {
+	/* Group types */
+	{ "all", RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP |
+		RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_PAYLOAD |
+		RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP |
+		RTE_ETH_RSS_GTPU | RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_MPLS | RTE_ETH_RSS_L2TPV2},
+	{ "none", 0 },
+	{ "ip", RTE_ETH_RSS_IP },
+	{ "udp", RTE_ETH_RSS_UDP },
+	{ "tcp", RTE_ETH_RSS_TCP },
+	{ "sctp", RTE_ETH_RSS_SCTP },
+	{ "tunnel", RTE_ETH_RSS_TUNNEL },
+	{ "vlan", RTE_ETH_RSS_VLAN },
+
+	/* Individual type */
+	{ "ipv4", RTE_ETH_RSS_IPV4 },
+	{ "ipv4-frag", RTE_ETH_RSS_FRAG_IPV4 },
+	{ "ipv4-tcp", RTE_ETH_RSS_NONFRAG_IPV4_TCP },
+	{ "ipv4-udp", RTE_ETH_RSS_NONFRAG_IPV4_UDP },
+	{ "ipv4-sctp", RTE_ETH_RSS_NONFRAG_IPV4_SCTP },
+	{ "ipv4-other", RTE_ETH_RSS_NONFRAG_IPV4_OTHER },
+	{ "ipv6", RTE_ETH_RSS_IPV6 },
+	{ "ipv6-frag", RTE_ETH_RSS_FRAG_IPV6 },
+	{ "ipv6-tcp", RTE_ETH_RSS_NONFRAG_IPV6_TCP },
+	{ "ipv6-udp", RTE_ETH_RSS_NONFRAG_IPV6_UDP },
+	{ "ipv6-sctp", RTE_ETH_RSS_NONFRAG_IPV6_SCTP },
+	{ "ipv6-other", RTE_ETH_RSS_NONFRAG_IPV6_OTHER },
+	{ "l2-payload", RTE_ETH_RSS_L2_PAYLOAD },
+	{ "ipv6-ex", RTE_ETH_RSS_IPV6_EX },
+	{ "ipv6-tcp-ex", RTE_ETH_RSS_IPV6_TCP_EX },
+	{ "ipv6-udp-ex", RTE_ETH_RSS_IPV6_UDP_EX },
+	{ "port", RTE_ETH_RSS_PORT },
+	{ "vxlan", RTE_ETH_RSS_VXLAN },
+	{ "geneve", RTE_ETH_RSS_GENEVE },
+	{ "nvgre", RTE_ETH_RSS_NVGRE },
+	{ "gtpu", RTE_ETH_RSS_GTPU },
+	{ "eth", RTE_ETH_RSS_ETH },
+	{ "s-vlan", RTE_ETH_RSS_S_VLAN },
+	{ "c-vlan", RTE_ETH_RSS_C_VLAN },
+	{ "esp", RTE_ETH_RSS_ESP },
+	{ "ah", RTE_ETH_RSS_AH },
+	{ "l2tpv3", RTE_ETH_RSS_L2TPV3 },
+	{ "pfcp", RTE_ETH_RSS_PFCP },
+	{ "pppoe", RTE_ETH_RSS_PPPOE },
+	{ "ecpri", RTE_ETH_RSS_ECPRI },
+	{ "mpls", RTE_ETH_RSS_MPLS },
+	{ "ipv4-chksum", RTE_ETH_RSS_IPV4_CHKSUM },
+	{ "l4-chksum", RTE_ETH_RSS_L4_CHKSUM },
+	{ "l2tpv2", RTE_ETH_RSS_L2TPV2 },
+	{ "l3-pre96", RTE_ETH_RSS_L3_PRE96 },
+	{ "l3-pre64", RTE_ETH_RSS_L3_PRE64 },
+	{ "l3-pre56", RTE_ETH_RSS_L3_PRE56 },
+	{ "l3-pre48", RTE_ETH_RSS_L3_PRE48 },
+	{ "l3-pre40", RTE_ETH_RSS_L3_PRE40 },
+	{ "l3-pre32", RTE_ETH_RSS_L3_PRE32 },
+	{ "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY },
+	{ "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY },
+	{ "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY },
+	{ "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY },
+	{ "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY },
+	{ "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY },
+	{ NULL, 0},
+};
+
 /* display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -806,6 +879,33 @@ show_offloads(uint64_t offloads,
 	}
 }
 
+static void
+show_rss_types(uint64_t rss_types)
+{
+	uint16_t total_len = 0;
+	uint16_t str_len;
+	uint16_t i;
+
+	printf("\t\t");
+	for (i = 0; rss_type_table[i].str != NULL; i++) {
+		if (rss_type_table[i].rss_type == 0)
+			continue;
+
+		if ((rss_type_table[i].rss_type & rss_types) ==
+					rss_type_table[i].rss_type) {
+			/* Contain two spaces */
+			str_len = strlen(rss_type_table[i].str) + 2;
+			if (total_len + str_len > RSS_TYPES_CHAR_NUM_PER_LINE) {
+				printf("\n\t\t");
+				total_len = 0;
+			}
+			printf("%s  ", rss_type_table[i].str);
+			total_len += str_len;
+		}
+	}
+	printf("\n");
+}
+
 static void
 show_port(void)
 {
@@ -991,13 +1091,19 @@ show_port(void)
 		rss_conf.rss_key_len = dev_info.hash_key_size;
 		ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
 		if (ret == 0) {
-			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 info\n");
+			if (rss_conf.rss_hf == 0) {
+				printf("\tRSS disabled\n");
+			} else {
+				printf("\t  -- hf:\n");
+				show_rss_types(rss_conf.rss_hf);
+				printf("\t  -- key len: %u\n",
+						rss_conf.rss_key_len);
+				printf("\t  -- key (hex): ");
+				for (k = 0; k < rss_conf.rss_key_len; k++)
+					printf("%02x", rss_conf.rss_key[k]);
+				printf("\n");
+			}
 		}
 
 		rte_free(rss_key);
-- 
2.22.0



More information about the dev mailing list