DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@nvidia.com>
To: Michael Baum <michaelba@nvidia.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>,
	 Raslan Darawsheh <rasland@nvidia.com>,
	Slava Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>
Subject: RE: [PATCH v5 2/3] net/mlx5: add support to compare random value
Date: Mon, 19 Feb 2024 03:00:08 +0000	[thread overview]
Message-ID: <CO6PR12MB5396F1D3785B67E00B836D0AC1512@CO6PR12MB5396.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20240214073015.2060103-3-michaelba@nvidia.com>



> -----Original Message-----
> From: Michael Baum <michaelba@nvidia.com>
> Sent: Wednesday, February 14, 2024 3:30 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Dariusz Sosnowski
> <dsosnowski@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming
> Mou <suanmingm@nvidia.com>
> Subject: [PATCH v5 2/3] net/mlx5: add support to compare random value
> 
> Add support to use "RTE_FLOW_ITEM_TYPE_COMPARE" with
> "RTE_FLOW_FIELD_RAMDOM" as an argument.
> The random field is supported only when base is an immediate value, random
> field cannot be compared with enother field.
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>

> ---
>  doc/guides/nics/mlx5.rst        |  9 ++++-
>  drivers/net/mlx5/mlx5_flow_hw.c | 70 ++++++++++++++++++++++++---------
>  2 files changed, 59 insertions(+), 20 deletions(-)
> 
> diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index
> fa013b03bb..43ef8a99dc 100644
> --- a/doc/guides/nics/mlx5.rst
> +++ b/doc/guides/nics/mlx5.rst
> @@ -820,8 +820,13 @@ Limitations
> 
>    - Only supported in HW steering(``dv_flow_en`` = 2) mode.
>    - Only single flow is supported to the flow table.
> -  - Only 32-bit comparison is supported.
> -  - Only match with compare result between packet fields is supported.
> +  - Only single item is supported per pattern template.
> +  - Only 32-bit comparison is supported or 16-bits for random field.
> +  - Only supported for ``RTE_FLOW_FIELD_META``, ``RTE_FLOW_FIELD_TAG``,
> +    ``RTE_FLOW_FIELD_RANDOM`` and ``RTE_FLOW_FIELD_VALUE``.
> +  - The field type ``RTE_FLOW_FIELD_VALUE`` must be the base (``b``) field.
> +  - The field type ``RTE_FLOW_FIELD_RANDOM`` can only be compared with
> +    ``RTE_FLOW_FIELD_VALUE``.
> 
> 
>  Statistics
> diff --git a/drivers/net/mlx5/mlx5_flow_hw.c
> b/drivers/net/mlx5/mlx5_flow_hw.c index 3af5e1f160..b5741f0817 100644
> --- a/drivers/net/mlx5/mlx5_flow_hw.c
> +++ b/drivers/net/mlx5/mlx5_flow_hw.c
> @@ -6717,18 +6717,55 @@ flow_hw_prepend_item(const struct rte_flow_item
> *items,
>  	return copied_items;
>  }
> 
> -static inline bool
> -flow_hw_item_compare_field_supported(enum rte_flow_field_id field)
> +static int
> +flow_hw_item_compare_field_validate(enum rte_flow_field_id arg_field,
> +				    enum rte_flow_field_id base_field,
> +				    struct rte_flow_error *error)
>  {
> -	switch (field) {
> +	switch (arg_field) {
> +	case RTE_FLOW_FIELD_TAG:
> +	case RTE_FLOW_FIELD_META:
> +		break;
> +	case RTE_FLOW_FIELD_RANDOM:
> +		if (base_field == RTE_FLOW_FIELD_VALUE)
> +			return 0;
> +		return rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +					  NULL,
> +					  "compare random is supported only
> with immediate value");
> +	default:
> +		return rte_flow_error_set(error, ENOTSUP,
> +
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +					  NULL,
> +					  "compare item argument field is not
> supported");
> +	}
> +	switch (base_field) {
>  	case RTE_FLOW_FIELD_TAG:
>  	case RTE_FLOW_FIELD_META:
>  	case RTE_FLOW_FIELD_VALUE:
> -		return true;
> +		break;
> +	default:
> +		return rte_flow_error_set(error, ENOTSUP,
> +
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +					  NULL,
> +					  "compare item base field is not
> supported");
> +	}
> +	return 0;
> +}
> +
> +static inline uint32_t
> +flow_hw_item_compare_width_supported(enum rte_flow_field_id field) {
> +	switch (field) {
> +	case RTE_FLOW_FIELD_TAG:
> +	case RTE_FLOW_FIELD_META:
> +		return 32;
> +	case RTE_FLOW_FIELD_RANDOM:
> +		return 16;
>  	default:
>  		break;
>  	}
> -	return false;
> +	return 0;
>  }
> 
>  static int
> @@ -6737,6 +6774,7 @@ flow_hw_validate_item_compare(const struct
> rte_flow_item *item,  {
>  	const struct rte_flow_item_compare *comp_m = item->mask;
>  	const struct rte_flow_item_compare *comp_v = item->spec;
> +	int ret;
> 
>  	if (unlikely(!comp_m))
>  		return rte_flow_error_set(error, EINVAL, @@ -6748,19 +6786,13
> @@ flow_hw_validate_item_compare(const struct rte_flow_item *item,
>  				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
>  				   NULL,
>  				   "compare item only support full mask");
> -	if (!flow_hw_item_compare_field_supported(comp_m->a.field) ||
> -	    !flow_hw_item_compare_field_supported(comp_m->b.field))
> -		return rte_flow_error_set(error, ENOTSUP,
> -				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> -				   NULL,
> -				   "compare item field not support");
> -	if (comp_m->a.field == RTE_FLOW_FIELD_VALUE &&
> -	    comp_m->b.field == RTE_FLOW_FIELD_VALUE)
> -		return rte_flow_error_set(error, EINVAL,
> -				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> -				   NULL,
> -				   "compare between value is not valid");
> +	ret = flow_hw_item_compare_field_validate(comp_m->a.field,
> +						  comp_m->b.field, error);
> +	if (ret < 0)
> +		return ret;
>  	if (comp_v) {
> +		uint32_t width;
> +
>  		if (comp_v->operation != comp_m->operation ||
>  		    comp_v->a.field != comp_m->a.field ||
>  		    comp_v->b.field != comp_m->b.field) @@ -6768,7 +6800,9
> @@ flow_hw_validate_item_compare(const struct rte_flow_item *item,
> 
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
>  					   NULL,
>  					   "compare item spec/mask not
> matching");
> -		if ((comp_v->width & comp_m->width) != 32)
> +		width = flow_hw_item_compare_width_supported(comp_v-
> >a.field);
> +		MLX5_ASSERT(width > 0);
> +		if ((comp_v->width & comp_m->width) != width)
>  			return rte_flow_error_set(error, EINVAL,
> 
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
>  					   NULL,
> --
> 2.25.1


  reply	other threads:[~2024-02-19  3:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 10:45 [PATCH v1 0/2] net/mlx5: add random compare support Michael Baum
2023-12-25 10:45 ` [PATCH v1 1/2] net/mlx5/hws: add support for compare matcher Michael Baum
2023-12-25 10:45 ` [PATCH v1 2/2] net/mlx5: add support to compare random value Michael Baum
2024-01-28 10:22 ` [PATCH v2 0/2] net/mlx5: add random compare support Michael Baum
2024-01-28 10:22   ` [PATCH v2 1/2] net/mlx5/hws: add support for compare matcher Michael Baum
2024-01-28 10:22   ` [PATCH v2 2/2] net/mlx5: add support to compare random value Michael Baum
2024-01-29 13:44   ` [PATCH v3 0/2] net/mlx5: add random compare support Michael Baum
2024-01-29 13:44     ` [PATCH v3 1/2] net/mlx5/hws: add support for compare matcher Michael Baum
2024-01-29 13:44     ` [PATCH v3 2/2] net/mlx5: add support to compare random value Michael Baum
2024-02-07 16:14     ` [PATCH v4 0/2] net/mlx5: add random compare support Michael Baum
2024-02-07 16:14       ` [PATCH v4 1/2] net/mlx5/hws: add support for compare matcher Michael Baum
2024-02-07 16:14       ` [PATCH v4 2/2] net/mlx5: add support to compare random value Michael Baum
2024-02-14  7:30       ` [PATCH v5 0/3] net/mlx5: add compare item support Michael Baum
2024-02-14  7:30         ` [PATCH v5 1/3] net/mlx5/hws: add support for compare matcher Michael Baum
2024-02-19  3:00           ` Suanming Mou
2024-02-14  7:30         ` [PATCH v5 2/3] net/mlx5: add support to compare random value Michael Baum
2024-02-19  3:00           ` Suanming Mou [this message]
2024-02-14  7:30         ` [PATCH v5 3/3] net/mlx5/hws: add compare ESP sequence number support Michael Baum
2024-02-19  2:59           ` Suanming Mou
2024-02-19  7:21             ` Michael Baum
2024-02-19  7:37               ` Suanming Mou
2024-02-26 13:03         ` [PATCH v6 0/3] net/mlx5: add compare item support Michael Baum
2024-02-26 13:03           ` [PATCH v6 1/3] net/mlx5/hws: add support for compare matcher Michael Baum
2024-02-26 13:03           ` [PATCH v6 2/3] net/mlx5: add support to compare random value Michael Baum
2024-02-26 13:03           ` [PATCH v6 3/3] net/mlx5/hws: add compare ESP sequence number support Michael Baum
2024-02-26 13:18           ` [PATCH v7 0/3] net/mlx5: add compare item support Michael Baum
2024-02-26 13:18             ` [PATCH v7 1/3] net/mlx5/hws: add support for compare matcher Michael Baum
2024-02-26 13:18             ` [PATCH v7 2/3] net/mlx5: add support to compare random value Michael Baum
2024-02-26 13:18             ` [PATCH v7 3/3] net/mlx5/hws: add compare ESP sequence number support Michael Baum
2024-02-27  9:08             ` [PATCH v7 0/3] net/mlx5: add compare item support Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO6PR12MB5396F1D3785B67E00B836D0AC1512@CO6PR12MB5396.namprd12.prod.outlook.com \
    --to=suanmingm@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=michaelba@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).