1 Star 0 Fork 75

chenjiji09/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0176-app-testpmd-compact-RSS-types-output.patch 4.83 KB
一键复制 编辑 原始数据 按行查看 历史
From ce06141d60c64963a7dc02fbdd9b2229d38a6819 Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit@xilinx.com>
Date: Fri, 21 Oct 2022 15:36:52 +0800
Subject: [PATCH 176/189] app/testpmd: compact RSS types output
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 | 68 +++++++++++++++++++++++++++++++-----------
app/test-pmd/testpmd.h | 2 ++
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7b725fc7a1..873cca6f3e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -698,6 +698,38 @@ rsstypes_to_str(uint64_t rss_type)
return NULL;
}
+static void
+rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line)
+{
+ uint16_t user_defined_str_len;
+ uint16_t total_len = 0;
+ uint16_t str_len = 0;
+ uint64_t rss_offload;
+ uint16_t i;
+
+ for (i = 0; i < sizeof(offload_types) * CHAR_BIT; i++) {
+ rss_offload = RTE_BIT64(i);
+ if ((offload_types & rss_offload) != 0) {
+ const char *p = rsstypes_to_str(rss_offload);
+
+ user_defined_str_len =
+ strlen("user-defined-") + (i / 10 + 1);
+ str_len = p ? strlen(p) : user_defined_str_len;
+ str_len += 2; /* add two spaces */
+ if (total_len + str_len >= char_num_per_line) {
+ total_len = 0;
+ printf("\n");
+ }
+
+ if (p)
+ printf(" %s", p);
+ else
+ printf(" user-defined-%u", i);
+ total_len += str_len;
+ }
+ }
+}
+
void
port_infos_display(portid_t port_id)
{
@@ -802,21 +834,10 @@ 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 = rsstypes_to_str(rss_offload);
- if (p)
- printf(" %s\n", p);
- else
- printf(" user defined %u\n",
- i);
- }
- }
+ rss_offload_types_display(dev_info.flow_type_rss_offloads,
+ TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
+ printf("\n");
}
printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize);
@@ -1555,8 +1576,10 @@ port_flow_complain(struct rte_flow_error *error)
}
static void
-rss_types_display(uint64_t rss_types)
+rss_types_display(uint64_t rss_types, uint16_t char_num_per_line)
{
+ uint16_t total_len = 0;
+ uint16_t str_len;
uint16_t i;
if (rss_types == 0)
@@ -1565,9 +1588,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 spaces */
+ str_len = strlen(rss_type_table[i].str) + 2;
+ if (total_len + str_len > char_num_per_line) {
+ printf("\n");
+ total_len = 0;
+ }
printf(" %s", rss_type_table[i].str);
+ total_len += str_len;
+ }
}
}
@@ -1613,7 +1645,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
printf(" none\n");
return;
}
- rss_types_display(rss_conf->types);
+ rss_types_display(rss_conf->types, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
}
static struct port_indirect_action *
@@ -3066,7 +3098,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
return;
}
printf("RSS functions:\n");
- rss_types_display(rss_hf);
+ rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
printf("\n");
if (!show_rss_key)
return;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e50188778b..9c3a5d9bc5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -105,6 +105,8 @@ struct pkt_burst_stats {
unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
};
+
+#define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64
/** Information for a given RSS type. */
struct rss_type_info {
const char *str; /**< Type name. */
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenjiji09/dpdk.git
git@gitee.com:chenjiji09/dpdk.git
chenjiji09
dpdk
dpdk
master

搜索帮助