[v4,5/5] app/testpmd: support query RSS config in flow query

Message ID 20200708011841.22295-6-chenxux.di@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series re-implement legacy filter functions by private API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Chenxu Di July 8, 2020, 1:18 a.m. UTC
  This patch support RSS action in flow query.
It can display the RSS configuration of the specified rule.

For example:
we can create an RSS rule by command "flow create 0 ingress
pattern eth / ipv4 / tcp / end actions rss types ipv4-tcp
l3-src-only l4-dst-only end queues end func symmetric_toeplitz
 / end" and then query it "flow query 0 0 rss"
the log will be follow
RSS:
 queues: none
 function: symmetric_toeplitz
 types:
  ipv4-tcp
  l3-src-only
  l4-dst-only

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
---
 app/test-pmd/config.c | 55 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
  

Comments

Qiming Yang July 8, 2020, 3:32 a.m. UTC | #1
Acke-by: Qiming Yang <qiming.yang@intel.com>

> -----Original Message-----
> From: Di, ChenxuX <chenxux.di@intel.com>
> Sent: Wednesday, July 8, 2020 09:19
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Di, ChenxuX
> <chenxux.di@intel.com>
> Subject: [PATCH v4 5/5] app/testpmd: support query RSS config in flow query
> 
> This patch support RSS action in flow query.
> It can display the RSS configuration of the specified rule.
> 
> For example:
> we can create an RSS rule by command "flow create 0 ingress pattern eth /
> ipv4 / tcp / end actions rss types ipv4-tcp l3-src-only l4-dst-only end queues
> end func symmetric_toeplitz  / end" and then query it "flow query 0 0 rss"
> the log will be follow
> RSS:
>  queues: none
>  function: symmetric_toeplitz
>  types:
>   ipv4-tcp
>   l3-src-only
>   l4-dst-only
> 
> Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> ---
>  app/test-pmd/config.c | 55
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> cf14b584f..53a9b97d6 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1395,6 +1395,56 @@ port_flow_complain(struct rte_flow_error *error)
>  	return -err;
>  }
> 
> +static void
> +rss_config_display(struct rte_flow_action_rss *rss_conf) {
> +	uint8_t i;
> +
> +	if (rss_conf == NULL) {
> +		printf("Invalid rule\n");
> +		return;
> +	}
> +
> +	printf("RSS:\n"
> +	       " queues: ");
> +	if (rss_conf->queue_num == 0)
> +		printf("none\n");
> +	for (i = 0; i < rss_conf->queue_num; i++)
> +		printf("%d\n", rss_conf->queue[i]);
> +
> +	printf(" function: ");
> +	switch (rss_conf->func) {
> +	case RTE_ETH_HASH_FUNCTION_DEFAULT:
> +		printf("default\n");
> +		break;
> +	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
> +		printf("toeplitz\n");
> +		break;
> +	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
> +		printf("simple_xor\n");
> +		break;
> +	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
> +		printf("symmetric_toeplitz\n");
> +		break;
> +	default:
> +		printf("Unknown function\n");
> +		return;
> +	}
> +
> +	printf(" types:\n");
> +	if (rss_conf->types == 0) {
> +		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);
> +	}
> +}
> +
>  /** Validate flow rule. */
>  int
>  port_flow_validate(portid_t port_id,
> @@ -1581,6 +1631,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
>  	const char *name;
>  	union {
>  		struct rte_flow_query_count count;
> +		struct rte_flow_action_rss rss_conf;
>  	} query;
>  	int ret;
> 
> @@ -1602,6 +1653,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
>  		return port_flow_complain(&error);
>  	switch (action->type) {
>  	case RTE_FLOW_ACTION_TYPE_COUNT:
> +	case RTE_FLOW_ACTION_TYPE_RSS:
>  		break;
>  	default:
>  		printf("Cannot query action type %d (%s)\n", @@ -1626,6
> +1678,9 @@ port_flow_query(portid_t port_id, uint32_t rule,
>  		       query.count.hits,
>  		       query.count.bytes);
>  		break;
> +	case RTE_FLOW_ACTION_TYPE_RSS:
> +		rss_config_display(&query.rss_conf);
> +		break;
>  	default:
>  		printf("Cannot display result for action type %d (%s)\n",
>  		       action->type, name);
> --
> 2.17.1
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cf14b584f..53a9b97d6 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1395,6 +1395,56 @@  port_flow_complain(struct rte_flow_error *error)
 	return -err;
 }
 
+static void
+rss_config_display(struct rte_flow_action_rss *rss_conf)
+{
+	uint8_t i;
+
+	if (rss_conf == NULL) {
+		printf("Invalid rule\n");
+		return;
+	}
+
+	printf("RSS:\n"
+	       " queues: ");
+	if (rss_conf->queue_num == 0)
+		printf("none\n");
+	for (i = 0; i < rss_conf->queue_num; i++)
+		printf("%d\n", rss_conf->queue[i]);
+
+	printf(" function: ");
+	switch (rss_conf->func) {
+	case RTE_ETH_HASH_FUNCTION_DEFAULT:
+		printf("default\n");
+		break;
+	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
+		printf("toeplitz\n");
+		break;
+	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
+		printf("simple_xor\n");
+		break;
+	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
+		printf("symmetric_toeplitz\n");
+		break;
+	default:
+		printf("Unknown function\n");
+		return;
+	}
+
+	printf(" types:\n");
+	if (rss_conf->types == 0) {
+		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);
+	}
+}
+
 /** Validate flow rule. */
 int
 port_flow_validate(portid_t port_id,
@@ -1581,6 +1631,7 @@  port_flow_query(portid_t port_id, uint32_t rule,
 	const char *name;
 	union {
 		struct rte_flow_query_count count;
+		struct rte_flow_action_rss rss_conf;
 	} query;
 	int ret;
 
@@ -1602,6 +1653,7 @@  port_flow_query(portid_t port_id, uint32_t rule,
 		return port_flow_complain(&error);
 	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
+	case RTE_FLOW_ACTION_TYPE_RSS:
 		break;
 	default:
 		printf("Cannot query action type %d (%s)\n",
@@ -1626,6 +1678,9 @@  port_flow_query(portid_t port_id, uint32_t rule,
 		       query.count.hits,
 		       query.count.bytes);
 		break;
+	case RTE_FLOW_ACTION_TYPE_RSS:
+		rss_config_display(&query.rss_conf);
+		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
 		       action->type, name);