1 Star 0 Fork 75

mds.lanruo/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0174-app-testpmd-refactor-config-all-RSS-command.patch 9.99 KB
一键复制 编辑 原始数据 按行查看 历史
From 860c15e4347ca38d50f4ce9d3f00e744f090e4e8 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:50 +0800
Subject: [PATCH 174/189] app/testpmd: refactor config all RSS command
The "port config <port_id> rss-hash-key" and "show port <port_id>
rss-hash key" commands both use the 'rss_type_table[]' to get
'rss_types' or the RSS type name. So this patch uses the
'rss_type_table[]' to get the RSS types. In this way, this command
naturally supports more individual types.
Suggested-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/cmdline.c | 120 ++++++--------------
app/test-pmd/config.c | 20 +++-
app/test-pmd/testpmd.h | 1 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 +-
4 files changed, 58 insertions(+), 93 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c5e4c30c9f..6cb095f965 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -792,9 +792,14 @@ static void cmd_help_long_parsed(void *parsed_result,
" Enable or disable packet drop on all RX queues of all ports when no "
"receive buffers available.\n\n"
- "port config all rss (all|default|ip|tcp|udp|sctp|"
- "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|"
- "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
+ "port config all rss (all|default|level-default|level-outer|level-inner|"
+ "ip|tcp|udp|sctp|tunnel|vlan|none|"
+ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
" Set the RSS mode.\n\n"
"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -2169,79 +2174,7 @@ cmd_config_rss_parsed(void *parsed_result,
uint16_t i;
int ret;
- if (!strcmp(res->value, "all"))
- rss_conf.rss_hf = 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;
- else if (!strcmp(res->value, "eth"))
- rss_conf.rss_hf = RTE_ETH_RSS_ETH;
- else if (!strcmp(res->value, "vlan"))
- rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
- else if (!strcmp(res->value, "ip"))
- rss_conf.rss_hf = RTE_ETH_RSS_IP;
- else if (!strcmp(res->value, "udp"))
- rss_conf.rss_hf = RTE_ETH_RSS_UDP;
- else if (!strcmp(res->value, "tcp"))
- rss_conf.rss_hf = RTE_ETH_RSS_TCP;
- else if (!strcmp(res->value, "sctp"))
- rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
- else if (!strcmp(res->value, "l2_payload"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
- else if (!strcmp(res->value, "port"))
- rss_conf.rss_hf = RTE_ETH_RSS_PORT;
- else if (!strcmp(res->value, "vxlan"))
- rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
- else if (!strcmp(res->value, "geneve"))
- rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
- else if (!strcmp(res->value, "nvgre"))
- rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
- else if (!strcmp(res->value, "l3-pre32"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
- else if (!strcmp(res->value, "l3-pre40"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
- else if (!strcmp(res->value, "l3-pre48"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
- else if (!strcmp(res->value, "l3-pre56"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
- else if (!strcmp(res->value, "l3-pre64"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
- else if (!strcmp(res->value, "l3-pre96"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
- else if (!strcmp(res->value, "l3-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
- else if (!strcmp(res->value, "l3-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
- else if (!strcmp(res->value, "l4-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
- else if (!strcmp(res->value, "l4-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
- else if (!strcmp(res->value, "l2-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
- else if (!strcmp(res->value, "l2-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
- else if (!strcmp(res->value, "l2tpv3"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
- else if (!strcmp(res->value, "esp"))
- rss_conf.rss_hf = RTE_ETH_RSS_ESP;
- else if (!strcmp(res->value, "ah"))
- rss_conf.rss_hf = RTE_ETH_RSS_AH;
- else if (!strcmp(res->value, "pfcp"))
- rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
- else if (!strcmp(res->value, "pppoe"))
- rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
- else if (!strcmp(res->value, "gtpu"))
- rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
- else if (!strcmp(res->value, "ecpri"))
- rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
- else if (!strcmp(res->value, "mpls"))
- rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
- else if (!strcmp(res->value, "ipv4-chksum"))
- rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
- else if (!strcmp(res->value, "none"))
- rss_conf.rss_hf = 0;
- else if (!strcmp(res->value, "level-default")) {
+ if (!strcmp(res->value, "level-default")) {
rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
} else if (!strcmp(res->value, "level-outer")) {
@@ -2250,14 +2183,24 @@ cmd_config_rss_parsed(void *parsed_result,
} else if (!strcmp(res->value, "level-inner")) {
rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
- } else if (!strcmp(res->value, "default"))
+ } else if (!strcmp(res->value, "default")) {
use_default = 1;
- else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
- atoi(res->value) < 64)
- rss_conf.rss_hf = 1ULL << atoi(res->value);
- else {
- fprintf(stderr, "Unknown parameter\n");
- return;
+ } else if (isdigit(res->value[0])) {
+ int value = atoi(res->value);
+ if (value > 0 && value < 64)
+ rss_conf.rss_hf = 1ULL << (uint8_t)value;
+ else {
+ fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
+ return;
+ }
+ } else if (!strcmp(res->value, "none")) {
+ rss_conf.rss_hf = 0;
+ } else {
+ rss_conf.rss_hf = str_to_rsstypes(res->value);
+ if (rss_conf.rss_hf == 0) {
+ fprintf(stderr, "Unknown parameter\n");
+ return;
+ }
}
rss_conf.rss_key = NULL;
/* Update global configuration for RSS types. */
@@ -2308,9 +2251,14 @@ cmdline_parse_inst_t cmd_config_rss = {
.f = cmd_config_rss_parsed,
.data = NULL,
.help_str = "port config all rss "
- "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|"
- "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|"
- "none|level-default|level-outer|level-inner|<flowtype_id>",
+ "all|default|level-default|level-outer|level-inner|"
+ "ip|tcp|udp|sctp|tunnel|vlan|none|"
+ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
.tokens = {
(void *)&cmd_config_rss_port,
(void *)&cmd_config_rss_keyword,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2849ee7e7c..b08face76d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -672,6 +672,19 @@ print_dev_capabilities(uint64_t capabilities)
}
}
+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;
+}
+
const char *
rsstypes_to_str(uint64_t rss_type)
{
@@ -3063,15 +3076,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;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index d6a775c485..e50188778b 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1105,6 +1105,7 @@ extern int flow_parse(const char *src, void *result, unsigned int size,
struct rte_flow_item **pattern,
struct rte_flow_action **actions);
+uint64_t str_to_rsstypes(const char *str);
const char *rsstypes_to_str(uint64_t rss_type);
/*
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index b75adcce55..e15dc0c4c4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2285,7 +2285,15 @@ port config - RSS
Set the RSS (Receive Side Scaling) mode on or off::
- testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none)
+ testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \
+ ip|tcp|udp|sctp|tunnel|vlan|none| \
+ ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \
+ ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \
+ ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex| \
+ l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \
+ esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \
+ l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \
+ l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)
RSS is on by default.
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdslanruo/dpdk.git
git@gitee.com:mdslanruo/dpdk.git
mdslanruo
dpdk
dpdk
master

搜索帮助