[v2,4/5] net/i40e: enable flow query RSS

Message ID 20200615021858.13985-5-chenxux.di@intel.com (mailing list archive)
State Superseded, 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/Intel-compilation success Compilation OK

Commit Message

Chenxu Di June 15, 2020, 2:18 a.m. UTC
  This patch enables flow query function to get the
configuration ofthe specified rule.

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 51 ++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
  

Comments

Guo, Jia June 30, 2020, 6:48 a.m. UTC | #1
hi, chenxu

On 6/15/2020 10:18 AM, Chenxu Di wrote:
> This patch enables flow query function to get the
> configuration ofthe specified rule.


"ofthe" should be "of the".


>
> Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> ---
>   drivers/net/i40e/i40e_flow.c | 51 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 51 insertions(+)
>
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index 8f8df6fae..b070802bd 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -43,6 +43,11 @@ static int i40e_flow_destroy(struct rte_eth_dev *dev,
>   			     struct rte_flow_error *error);
>   static int i40e_flow_flush(struct rte_eth_dev *dev,
>   			   struct rte_flow_error *error);
> +static int i40e_flow_query(struct rte_eth_dev *dev,
> +			   struct rte_flow *flow,
> +			   const struct rte_flow_action *actions,
> +			   void *data,
> +			   struct rte_flow_error *error);
>   static int
>   i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
>   				  const struct rte_flow_item *pattern,
> @@ -129,6 +134,7 @@ const struct rte_flow_ops i40e_flow_ops = {
>   	.create = i40e_flow_create,
>   	.destroy = i40e_flow_destroy,
>   	.flush = i40e_flow_flush,
> +	.query = i40e_flow_query,
>   };
>   
>   static union i40e_filter_t cons_filter;
> @@ -5462,3 +5468,48 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)
>   
>   	return ret;
>   }
> +
> +static int
> +i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
> +		struct rte_flow *flow,
> +		const struct rte_flow_action *actions,
> +		void *data,
> +		struct rte_flow_error *error)


This line is no need to separate and please check also below code.


> +{
> +	struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
> +	enum rte_filter_type filter_type = flow->filter_type;
> +	struct rte_flow_action_rss *rss_conf = data;
> +
> +	if (!rss_rule) {
> +		rte_flow_error_set(error, EINVAL,
> +				   RTE_FLOW_ERROR_TYPE_HANDLE,
> +				   NULL, "Invalid rule");
> +		return -rte_errno;
> +	}
> +
> +	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
> +		switch (actions->type) {
> +		case RTE_FLOW_ACTION_TYPE_VOID:
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_RSS:
> +			if (filter_type != RTE_ETH_FILTER_HASH) {
> +				rte_flow_error_set(error, ENOTSUP,
> +						   RTE_FLOW_ERROR_TYPE_ACTION,
> +						   actions,
> +						   "action not supported");
> +				return -rte_errno;
> +			}
> +			rte_memcpy(rss_conf,
> +				   &rss_rule->rss_filter_info.conf,
> +				   sizeof(struct rte_flow_action_rss));
> +			break;
> +		default:
> +			return rte_flow_error_set(error, ENOTSUP,
> +						  RTE_FLOW_ERROR_TYPE_ACTION,
> +						  actions,
> +						  "action not supported");
> +		}
> +	}
> +
> +	return 0;
> +}
  
Qiming Yang June 30, 2020, 10:27 a.m. UTC | #2
> -----Original Message-----
> From: Di, ChenxuX <chenxux.di@intel.com>
> Sent: Monday, June 15, 2020 10:19
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Di, ChenxuX <chenxux.di@intel.com>
> Subject: [PATCH v2 4/5] net/i40e: enable flow query RSS
> 
> This patch enables flow query function to get the configuration ofthe
> specified rule.
> 
> Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> ---
>  drivers/net/i40e/i40e_flow.c | 51
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index 8f8df6fae..b070802bd 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -43,6 +43,11 @@ static int i40e_flow_destroy(struct rte_eth_dev *dev,
>  			     struct rte_flow_error *error);
>  static int i40e_flow_flush(struct rte_eth_dev *dev,
>  			   struct rte_flow_error *error);
> +static int i40e_flow_query(struct rte_eth_dev *dev,
> +			   struct rte_flow *flow,
> +			   const struct rte_flow_action *actions,
> +			   void *data,
> +			   struct rte_flow_error *error);
>  static int
>  i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
>  				  const struct rte_flow_item *pattern, @@ -
> 129,6 +134,7 @@ const struct rte_flow_ops i40e_flow_ops = {
>  	.create = i40e_flow_create,
>  	.destroy = i40e_flow_destroy,
>  	.flush = i40e_flow_flush,
> +	.query = i40e_flow_query,
>  };
> 
>  static union i40e_filter_t cons_filter; @@ -5462,3 +5468,48 @@
> i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)
> 
>  	return ret;
>  }
> +
> +static int
> +i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
> +		struct rte_flow *flow,
> +		const struct rte_flow_action *actions,
> +		void *data,
> +		struct rte_flow_error *error)
> +{
> +	struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
> +	enum rte_filter_type filter_type = flow->filter_type;
> +	struct rte_flow_action_rss *rss_conf = data;
> +
> +	if (!rss_rule) {
> +		rte_flow_error_set(error, EINVAL,
> +				   RTE_FLOW_ERROR_TYPE_HANDLE,
> +				   NULL, "Invalid rule");
> +		return -rte_errno;
> +	}
> +
> +	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
> +		switch (actions->type) {
> +		case RTE_FLOW_ACTION_TYPE_VOID:
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_RSS:
> +			if (filter_type != RTE_ETH_FILTER_HASH) {
> +				rte_flow_error_set(error, ENOTSUP,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						   actions,
> +						   "action not supported");
> +				return -rte_errno;
> +			}
> +			rte_memcpy(rss_conf,
> +				   &rss_rule->rss_filter_info.conf,
> +				   sizeof(struct rte_flow_action_rss));

Don't understand the behavior, what's action means? What's the things this commend query?

> +			break;
> +		default:
> +			return rte_flow_error_set(error, ENOTSUP,
> +
> RTE_FLOW_ERROR_TYPE_ACTION,
> +						  actions,
> +						  "action not supported");
> +		}
> +	}
> +
> +	return 0;
> +}
> --
> 2.17.1
  
Chenxu Di July 1, 2020, 1:15 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: Yang, Qiming
> Sent: Tuesday, June 30, 2020 6:27 PM
> To: Di, ChenxuX <chenxux.di@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>
> Subject: RE: [PATCH v2 4/5] net/i40e: enable flow query RSS
> 
> 
> 
> > -----Original Message-----
> > From: Di, ChenxuX <chenxux.di@intel.com>
> > Sent: Monday, June 15, 2020 10:19
> > To: dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Di, ChenxuX <chenxux.di@intel.com>
> > Subject: [PATCH v2 4/5] net/i40e: enable flow query RSS
> >
> > This patch enables flow query function to get the configuration ofthe
> > specified rule.
> >
> > Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> > ---
> >  drivers/net/i40e/i40e_flow.c | 51
> > ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 51 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index 8f8df6fae..b070802bd 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -43,6 +43,11 @@ static int i40e_flow_destroy(struct rte_eth_dev *dev,
> >       struct rte_flow_error *error);
> >  static int i40e_flow_flush(struct rte_eth_dev *dev,
> >     struct rte_flow_error *error);
> > +static int i40e_flow_query(struct rte_eth_dev *dev,
> > +   struct rte_flow *flow,
> > +   const struct rte_flow_action *actions,
> > +   void *data,
> > +   struct rte_flow_error *error);
> >  static int
> >  i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
> >    const struct rte_flow_item *pattern, @@ -
> > 129,6 +134,7 @@ const struct rte_flow_ops i40e_flow_ops = {  .create =
> > i40e_flow_create,  .destroy = i40e_flow_destroy,  .flush =
> > i40e_flow_flush,
> > +.query = i40e_flow_query,
> >  };
> >
> >  static union i40e_filter_t cons_filter; @@ -5462,3 +5468,48 @@
> > i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)
> >
> >  return ret;
> >  }
> > +
> > +static int
> > +i40e_flow_query(struct rte_eth_dev *dev __rte_unused, struct rte_flow
> > +*flow, const struct rte_flow_action *actions, void *data, struct
> > +rte_flow_error *error) { struct i40e_rss_filter *rss_rule = (struct
> > +i40e_rss_filter *)flow->rule; enum rte_filter_type filter_type =
> > +flow->filter_type; struct rte_flow_action_rss *rss_conf = data;
> > +
> > +if (!rss_rule) {
> > +rte_flow_error_set(error, EINVAL,
> > +   RTE_FLOW_ERROR_TYPE_HANDLE,
> > +   NULL, "Invalid rule");
> > +return -rte_errno;
> > +}
> > +
> > +for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { switch
> > +(actions->type) { case RTE_FLOW_ACTION_TYPE_VOID:
> > +break;
> > +case RTE_FLOW_ACTION_TYPE_RSS:
> > +if (filter_type != RTE_ETH_FILTER_HASH) { rte_flow_error_set(error,
> > +ENOTSUP,
> > +
> > RTE_FLOW_ERROR_TYPE_ACTION,
> > +   actions,
> > +   "action not supported");
> > +return -rte_errno;
> > +}
> > +rte_memcpy(rss_conf,
> > +   &rss_rule->rss_filter_info.conf,
> > +   sizeof(struct rte_flow_action_rss));
> 
> Don't understand the behavior, what's action means? What's the things this
> commend query?
> 

By zhangqi's comment, it will query the configuration of rss rule.
It just return the config and display it.

> > +break;
> > +default:
> > +return rte_flow_error_set(error, ENOTSUP,
> > +
> > RTE_FLOW_ERROR_TYPE_ACTION,
> > +  actions,
> > +  "action not supported");
> > +}
> > +}
> > +
> > +return 0;
> > +}
> > --
> > 2.17.1
>
  

Patch

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 8f8df6fae..b070802bd 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -43,6 +43,11 @@  static int i40e_flow_destroy(struct rte_eth_dev *dev,
 			     struct rte_flow_error *error);
 static int i40e_flow_flush(struct rte_eth_dev *dev,
 			   struct rte_flow_error *error);
+static int i40e_flow_query(struct rte_eth_dev *dev,
+			   struct rte_flow *flow,
+			   const struct rte_flow_action *actions,
+			   void *data,
+			   struct rte_flow_error *error);
 static int
 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
 				  const struct rte_flow_item *pattern,
@@ -129,6 +134,7 @@  const struct rte_flow_ops i40e_flow_ops = {
 	.create = i40e_flow_create,
 	.destroy = i40e_flow_destroy,
 	.flush = i40e_flow_flush,
+	.query = i40e_flow_query,
 };
 
 static union i40e_filter_t cons_filter;
@@ -5462,3 +5468,48 @@  i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)
 
 	return ret;
 }
+
+static int
+i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
+		struct rte_flow *flow,
+		const struct rte_flow_action *actions,
+		void *data,
+		struct rte_flow_error *error)
+{
+	struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
+	enum rte_filter_type filter_type = flow->filter_type;
+	struct rte_flow_action_rss *rss_conf = data;
+
+	if (!rss_rule) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE,
+				   NULL, "Invalid rule");
+		return -rte_errno;
+	}
+
+	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+		switch (actions->type) {
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			if (filter_type != RTE_ETH_FILTER_HASH) {
+				rte_flow_error_set(error, ENOTSUP,
+						   RTE_FLOW_ERROR_TYPE_ACTION,
+						   actions,
+						   "action not supported");
+				return -rte_errno;
+			}
+			rte_memcpy(rss_conf,
+				   &rss_rule->rss_filter_info.conf,
+				   sizeof(struct rte_flow_action_rss));
+			break;
+		default:
+			return rte_flow_error_set(error, ENOTSUP,
+						  RTE_FLOW_ERROR_TYPE_ACTION,
+						  actions,
+						  "action not supported");
+		}
+	}
+
+	return 0;
+}