[v1,01/12] ethdev: add ethdev item to flow API

Message ID 20211001134716.1608857-2-andrew.rybchenko@oktetlabs.ru (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: rework transfer flow API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure

Commit Message

Andrew Rybchenko Oct. 1, 2021, 1:47 p.m. UTC
  From: Ivan Malov <ivan.malov@oktetlabs.ru>

For use with "transfer" flows. Supposed to match traffic transmitted
by the DPDK application via the specified ethdev, at e-switch level.

Must not be combined with attributes "ingress" / "egress".

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 app/test-pmd/cmdline_flow.c                 | 27 ++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst          | 35 +++++++++++++++++++++
 doc/guides/rel_notes/release_21_11.rst      |  2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 +++
 lib/ethdev/rte_flow.c                       |  1 +
 lib/ethdev/rte_flow.h                       | 27 ++++++++++++++++
 6 files changed, 96 insertions(+)
  

Comments

Ori Kam Oct. 3, 2021, 11:52 a.m. UTC | #1
Hi Andrew and Ivan,

> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Friday, October 1, 2021 4:47 PM
> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
> 
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> For use with "transfer" flows. Supposed to match traffic transmitted by the
> DPDK application via the specified ethdev, at e-switch level.
> 
> Must not be combined with attributes "ingress" / "egress".
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---

[Snip]

>  /** Generate flow_action[] entry. */
> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
> 7b1ed7f110..880502098e 100644
> --- a/lib/ethdev/rte_flow.h
> +++ b/lib/ethdev/rte_flow.h
> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
>  	 * @see struct rte_flow_item_conntrack.
>  	 */
>  	RTE_FLOW_ITEM_TYPE_CONNTRACK,
> +
> +	/**
> +	 * [META]
> +	 *
> +	 * Matches traffic at e-switch going from (sent by) the given ethdev.
> +	 *
> +	 * @see struct rte_flow_item_ethdev
> +	 */
> +	RTE_FLOW_ITEM_TYPE_ETHDEV,
>  };
> 
>  /**
> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
> rte_flow_item_conntrack_mask = {  };  #endif
> 
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change without prior notice
> + *
> + * Provides an ethdev ID for use with items which are as follows:
> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
> + */
> +struct rte_flow_item_ethdev {
> +	uint16_t id; /**< Ethdev ID */

True for all above uses,
should this be renamed to port?

> +};
> +
> +/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */ #ifndef
> __cplusplus
> +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
> +	.id = 0xffff,
> +};
> +#endif
> +
>  /**
>   * Matching pattern item definition.
>   *
> --
> 2.30.2
  
Ivan Malov Oct. 3, 2021, 5:40 p.m. UTC | #2
Hi Ori,

On 03/10/2021 14:52, Ori Kam wrote:
> Hi Andrew and Ivan,
> 
>> -----Original Message-----
>> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> Sent: Friday, October 1, 2021 4:47 PM
>> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>
>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>
>> For use with "transfer" flows. Supposed to match traffic transmitted by the
>> DPDK application via the specified ethdev, at e-switch level.
>>
>> Must not be combined with attributes "ingress" / "egress".
>>
>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> ---
> 
> [Snip]
> 
>>   /** Generate flow_action[] entry. */
>> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>> 7b1ed7f110..880502098e 100644
>> --- a/lib/ethdev/rte_flow.h
>> +++ b/lib/ethdev/rte_flow.h
>> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
>>   	 * @see struct rte_flow_item_conntrack.
>>   	 */
>>   	RTE_FLOW_ITEM_TYPE_CONNTRACK,
>> +
>> +	/**
>> +	 * [META]
>> +	 *
>> +	 * Matches traffic at e-switch going from (sent by) the given ethdev.
>> +	 *
>> +	 * @see struct rte_flow_item_ethdev
>> +	 */
>> +	RTE_FLOW_ITEM_TYPE_ETHDEV,
>>   };
>>
>>   /**
>> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
>> rte_flow_item_conntrack_mask = {  };  #endif
>>
>> +/**
>> + * @warning
>> + * @b EXPERIMENTAL: this structure may change without prior notice
>> + *
>> + * Provides an ethdev ID for use with items which are as follows:
>> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
>> + */
>> +struct rte_flow_item_ethdev {
>> +	uint16_t id; /**< Ethdev ID */
> 
> True for all above uses,
> should this be renamed to port?

I'd not rename it to "port". The very idea of this series is to 
disambiguate things. This structure is shared between primitives ETHDEV 
and ESWITCH_PORT. If we go for "port", then in conjunction with 
ESWITCH_PORT the structure name may trick readers into thinking that the 
ID in question is the own ID of the e-switch port itself. But in fact 
this ID is an ethdev ID which is associated with the e-switch port.

Should you wish to elaborate on your concerns with regard to naming, 
please do so. I'm all ears.

> 
>> +};
>> +
>> +/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */ #ifndef
>> __cplusplus
>> +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
>> +	.id = 0xffff,
>> +};
>> +#endif
>> +
>>   /**
>>    * Matching pattern item definition.
>>    *
>> --
>> 2.30.2
  
Ori Kam Oct. 3, 2021, 9:09 p.m. UTC | #3
Hi Ivan,

> -----Original Message-----
> From: Ivan Malov <Ivan.Malov@oktetlabs.ru>
> Subject: Re: [PATCH v1 01/12] ethdev: add ethdev item to flow API
> 
> Hi Ori,
> 
> On 03/10/2021 14:52, Ori Kam wrote:
> > Hi Andrew and Ivan,
> >
> >> -----Original Message-----
> >> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> >> Sent: Friday, October 1, 2021 4:47 PM
> >> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
> >>
> >> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> >>
> >> For use with "transfer" flows. Supposed to match traffic transmitted
> >> by the DPDK application via the specified ethdev, at e-switch level.
> >>
> >> Must not be combined with attributes "ingress" / "egress".
> >>
> >> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> >> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> >> ---
> >
> > [Snip]
> >
> >>   /** Generate flow_action[] entry. */ diff --git
> >> a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
> >> 7b1ed7f110..880502098e 100644
> >> --- a/lib/ethdev/rte_flow.h
> >> +++ b/lib/ethdev/rte_flow.h
> >> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
> >>   	 * @see struct rte_flow_item_conntrack.
> >>   	 */
> >>   	RTE_FLOW_ITEM_TYPE_CONNTRACK,
> >> +
> >> +	/**
> >> +	 * [META]
> >> +	 *
> >> +	 * Matches traffic at e-switch going from (sent by) the given ethdev.
> >> +	 *
> >> +	 * @see struct rte_flow_item_ethdev
> >> +	 */
> >> +	RTE_FLOW_ITEM_TYPE_ETHDEV,
> >>   };
> >>
> >>   /**
> >> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
> >> rte_flow_item_conntrack_mask = {  };  #endif
> >>
> >> +/**
> >> + * @warning
> >> + * @b EXPERIMENTAL: this structure may change without prior notice
> >> + *
> >> + * Provides an ethdev ID for use with items which are as follows:
> >> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
> >> + */
> >> +struct rte_flow_item_ethdev {
> >> +	uint16_t id; /**< Ethdev ID */
> >
> > True for all above uses,
> > should this be renamed to port?
> 
> I'd not rename it to "port". The very idea of this series is to disambiguate
> things. This structure is shared between primitives ETHDEV and
> ESWITCH_PORT. If we go for "port", then in conjunction with ESWITCH_PORT
> the structure name may trick readers into thinking that the ID in question is
> the own ID of the e-switch port itself. But in fact this ID is an ethdev ID which
> is associated with the e-switch port.
> 
> Should you wish to elaborate on your concerns with regard to naming, please
> do so. I'm all ears.
> 
Fully understand and agree that the idea is to clear the ambiguaty.
My concern is that we don't use ethdev id, from application ethdev has only
ports, so what is the id? (if we keep this, we should document that the id is the
port) 
What about ETHDEV_PORT and ESWITCH_PORT?

Best,
Ori
> >
> >> +};
> >> +
> >> +/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */ #ifndef
> >> __cplusplus
> >> +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask
> = {
> >> +	.id = 0xffff,
> >> +};
> >> +#endif
> >> +
> >>   /**
> >>    * Matching pattern item definition.
> >>    *
> >> --
> >> 2.30.2
> 
> --
> Ivan M
  
Ivan Malov Oct. 4, 2021, midnight UTC | #4
Hi Ori,

On 04/10/2021 00:09, Ori Kam wrote:
> Hi Ivan,
> 
>> -----Original Message-----
>> From: Ivan Malov <Ivan.Malov@oktetlabs.ru>
>> Subject: Re: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>
>> Hi Ori,
>>
>> On 03/10/2021 14:52, Ori Kam wrote:
>>> Hi Andrew and Ivan,
>>>
>>>> -----Original Message-----
>>>> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>> Sent: Friday, October 1, 2021 4:47 PM
>>>> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>>>
>>>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>>
>>>> For use with "transfer" flows. Supposed to match traffic transmitted
>>>> by the DPDK application via the specified ethdev, at e-switch level.
>>>>
>>>> Must not be combined with attributes "ingress" / "egress".
>>>>
>>>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>> ---
>>>
>>> [Snip]
>>>
>>>>    /** Generate flow_action[] entry. */ diff --git
>>>> a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>>> 7b1ed7f110..880502098e 100644
>>>> --- a/lib/ethdev/rte_flow.h
>>>> +++ b/lib/ethdev/rte_flow.h
>>>> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
>>>>    	 * @see struct rte_flow_item_conntrack.
>>>>    	 */
>>>>    	RTE_FLOW_ITEM_TYPE_CONNTRACK,
>>>> +
>>>> +	/**
>>>> +	 * [META]
>>>> +	 *
>>>> +	 * Matches traffic at e-switch going from (sent by) the given ethdev.
>>>> +	 *
>>>> +	 * @see struct rte_flow_item_ethdev
>>>> +	 */
>>>> +	RTE_FLOW_ITEM_TYPE_ETHDEV,
>>>>    };
>>>>
>>>>    /**
>>>> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
>>>> rte_flow_item_conntrack_mask = {  };  #endif
>>>>
>>>> +/**
>>>> + * @warning
>>>> + * @b EXPERIMENTAL: this structure may change without prior notice
>>>> + *
>>>> + * Provides an ethdev ID for use with items which are as follows:
>>>> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
>>>> + */
>>>> +struct rte_flow_item_ethdev {
>>>> +	uint16_t id; /**< Ethdev ID */
>>>
>>> True for all above uses,
>>> should this be renamed to port?
>>
>> I'd not rename it to "port". The very idea of this series is to disambiguate
>> things. This structure is shared between primitives ETHDEV and
>> ESWITCH_PORT. If we go for "port", then in conjunction with ESWITCH_PORT
>> the structure name may trick readers into thinking that the ID in question is
>> the own ID of the e-switch port itself. But in fact this ID is an ethdev ID which
>> is associated with the e-switch port.
>>
>> Should you wish to elaborate on your concerns with regard to naming, please
>> do so. I'm all ears.
>>
> Fully understand and agree that the idea is to clear the ambiguaty.
> My concern is that we don't use ethdev id, from application ethdev has only
> ports, so what is the id? (if we keep this, we should document that the id is the
> port)
> What about ETHDEV_PORT and ESWITCH_PORT?

I understand that, technically, the only ports which the application can 
really interface with are ethdevs. So, terms "ethdev" and "port" may 
appear synonymous to the application - you are right on that. But, given 
the fact that we have some primitives like PHY_PORT and the likes, which 
also have "PORT" in their names, I'd rather go for "ethdev" as more 
precise term.

But let me assure you: I'm not saying that my opinion should prevail. 
I'm giving more thoughts to this in the background. Maybe Andrew can 
join this conversation as well.

> 
> Best,
> Ori
>>>
>>>> +};
>>>> +
>>>> +/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */ #ifndef
>>>> __cplusplus
>>>> +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask
>> = {
>>>> +	.id = 0xffff,
>>>> +};
>>>> +#endif
>>>> +
>>>>    /**
>>>>     * Matching pattern item definition.
>>>>     *
>>>> --
>>>> 2.30.2
>>
>> --
>> Ivan M
  
Andrew Rybchenko Oct. 4, 2021, 10:47 a.m. UTC | #5
On 10/4/21 3:00 AM, Ivan Malov wrote:
> Hi Ori,
> 
> On 04/10/2021 00:09, Ori Kam wrote:
>> Hi Ivan,
>>
>>> -----Original Message-----
>>> From: Ivan Malov <Ivan.Malov@oktetlabs.ru>
>>> Subject: Re: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>>
>>> Hi Ori,
>>>
>>> On 03/10/2021 14:52, Ori Kam wrote:
>>>> Hi Andrew and Ivan,
>>>>
>>>>> -----Original Message-----
>>>>> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>>> Sent: Friday, October 1, 2021 4:47 PM
>>>>> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>>>>
>>>>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>>>
>>>>> For use with "transfer" flows. Supposed to match traffic transmitted
>>>>> by the DPDK application via the specified ethdev, at e-switch level.
>>>>>
>>>>> Must not be combined with attributes "ingress" / "egress".
>>>>>
>>>>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>>> ---
>>>>
>>>> [Snip]
>>>>
>>>>>    /** Generate flow_action[] entry. */ diff --git
>>>>> a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>>>> 7b1ed7f110..880502098e 100644
>>>>> --- a/lib/ethdev/rte_flow.h
>>>>> +++ b/lib/ethdev/rte_flow.h
>>>>> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
>>>>>         * @see struct rte_flow_item_conntrack.
>>>>>         */
>>>>>        RTE_FLOW_ITEM_TYPE_CONNTRACK,
>>>>> +
>>>>> +    /**
>>>>> +     * [META]
>>>>> +     *
>>>>> +     * Matches traffic at e-switch going from (sent by) the given
>>>>> ethdev.
>>>>> +     *
>>>>> +     * @see struct rte_flow_item_ethdev
>>>>> +     */
>>>>> +    RTE_FLOW_ITEM_TYPE_ETHDEV,
>>>>>    };
>>>>>
>>>>>    /**
>>>>> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
>>>>> rte_flow_item_conntrack_mask = {  };  #endif
>>>>>
>>>>> +/**
>>>>> + * @warning
>>>>> + * @b EXPERIMENTAL: this structure may change without prior notice
>>>>> + *
>>>>> + * Provides an ethdev ID for use with items which are as follows:
>>>>> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
>>>>> + */
>>>>> +struct rte_flow_item_ethdev {
>>>>> +    uint16_t id; /**< Ethdev ID */
>>>>
>>>> True for all above uses,
>>>> should this be renamed to port?
>>>
>>> I'd not rename it to "port". The very idea of this series is to
>>> disambiguate
>>> things. This structure is shared between primitives ETHDEV and
>>> ESWITCH_PORT. If we go for "port", then in conjunction with ESWITCH_PORT
>>> the structure name may trick readers into thinking that the ID in
>>> question is
>>> the own ID of the e-switch port itself. But in fact this ID is an
>>> ethdev ID which
>>> is associated with the e-switch port.
>>>
>>> Should you wish to elaborate on your concerns with regard to naming,
>>> please
>>> do so. I'm all ears.
>>>
>> Fully understand and agree that the idea is to clear the ambiguaty.
>> My concern is that we don't use ethdev id, from application ethdev has
>> only
>> ports, so what is the id? (if we keep this, we should document that
>> the id is the
>> port)
>> What about ETHDEV_PORT and ESWITCH_PORT?
> 
> I understand that, technically, the only ports which the application can
> really interface with are ethdevs. So, terms "ethdev" and "port" may
> appear synonymous to the application - you are right on that. But, given
> the fact that we have some primitives like PHY_PORT and the likes, which
> also have "PORT" in their names, I'd rather go for "ethdev" as more
> precise term.
> 
> But let me assure you: I'm not saying that my opinion should prevail.
> I'm giving more thoughts to this in the background. Maybe Andrew can
> join this conversation as well.

As far as I can see ethdev API uses 'port_id' everywhere to
refer to ethdev port by its number. So, I suggest

struct rte_flow_item_ethdev {
    uint16_t port_id; /**< ethdev port ID */
};

Basically I agree with Ori, that just "id" is a bit confusing
even when it is a member of the _ethdev structure, but I'd
prepend "port_"  a field name to sync with ethdev API which
uses port_id. So, we have ethdev->port_id.

Andrew.
  
Ivan Malov Oct. 4, 2021, 11:08 a.m. UTC | #6
Hi Andrew, Ori,

On 04/10/2021 13:47, Andrew Rybchenko wrote:
> On 10/4/21 3:00 AM, Ivan Malov wrote:
>> Hi Ori,
>>
>> On 04/10/2021 00:09, Ori Kam wrote:
>>> Hi Ivan,
>>>
>>>> -----Original Message-----
>>>> From: Ivan Malov <Ivan.Malov@oktetlabs.ru>
>>>> Subject: Re: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>>>
>>>> Hi Ori,
>>>>
>>>> On 03/10/2021 14:52, Ori Kam wrote:
>>>>> Hi Andrew and Ivan,
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>>>> Sent: Friday, October 1, 2021 4:47 PM
>>>>>> Subject: [PATCH v1 01/12] ethdev: add ethdev item to flow API
>>>>>>
>>>>>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>>>>
>>>>>> For use with "transfer" flows. Supposed to match traffic transmitted
>>>>>> by the DPDK application via the specified ethdev, at e-switch level.
>>>>>>
>>>>>> Must not be combined with attributes "ingress" / "egress".
>>>>>>
>>>>>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>>>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>>>> ---
>>>>>
>>>>> [Snip]
>>>>>
>>>>>>     /** Generate flow_action[] entry. */ diff --git
>>>>>> a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index
>>>>>> 7b1ed7f110..880502098e 100644
>>>>>> --- a/lib/ethdev/rte_flow.h
>>>>>> +++ b/lib/ethdev/rte_flow.h
>>>>>> @@ -574,6 +574,15 @@ enum rte_flow_item_type {
>>>>>>          * @see struct rte_flow_item_conntrack.
>>>>>>          */
>>>>>>         RTE_FLOW_ITEM_TYPE_CONNTRACK,
>>>>>> +
>>>>>> +    /**
>>>>>> +     * [META]
>>>>>> +     *
>>>>>> +     * Matches traffic at e-switch going from (sent by) the given
>>>>>> ethdev.
>>>>>> +     *
>>>>>> +     * @see struct rte_flow_item_ethdev
>>>>>> +     */
>>>>>> +    RTE_FLOW_ITEM_TYPE_ETHDEV,
>>>>>>     };
>>>>>>
>>>>>>     /**
>>>>>> @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack
>>>>>> rte_flow_item_conntrack_mask = {  };  #endif
>>>>>>
>>>>>> +/**
>>>>>> + * @warning
>>>>>> + * @b EXPERIMENTAL: this structure may change without prior notice
>>>>>> + *
>>>>>> + * Provides an ethdev ID for use with items which are as follows:
>>>>>> + * RTE_FLOW_ITEM_TYPE_ETHDEV.
>>>>>> + */
>>>>>> +struct rte_flow_item_ethdev {
>>>>>> +    uint16_t id; /**< Ethdev ID */
>>>>>
>>>>> True for all above uses,
>>>>> should this be renamed to port?
>>>>
>>>> I'd not rename it to "port". The very idea of this series is to
>>>> disambiguate
>>>> things. This structure is shared between primitives ETHDEV and
>>>> ESWITCH_PORT. If we go for "port", then in conjunction with ESWITCH_PORT
>>>> the structure name may trick readers into thinking that the ID in
>>>> question is
>>>> the own ID of the e-switch port itself. But in fact this ID is an
>>>> ethdev ID which
>>>> is associated with the e-switch port.
>>>>
>>>> Should you wish to elaborate on your concerns with regard to naming,
>>>> please
>>>> do so. I'm all ears.
>>>>
>>> Fully understand and agree that the idea is to clear the ambiguaty.
>>> My concern is that we don't use ethdev id, from application ethdev has
>>> only
>>> ports, so what is the id? (if we keep this, we should document that
>>> the id is the
>>> port)
>>> What about ETHDEV_PORT and ESWITCH_PORT?
>>
>> I understand that, technically, the only ports which the application can
>> really interface with are ethdevs. So, terms "ethdev" and "port" may
>> appear synonymous to the application - you are right on that. But, given
>> the fact that we have some primitives like PHY_PORT and the likes, which
>> also have "PORT" in their names, I'd rather go for "ethdev" as more
>> precise term.
>>
>> But let me assure you: I'm not saying that my opinion should prevail.
>> I'm giving more thoughts to this in the background. Maybe Andrew can
>> join this conversation as well.
> 
> As far as I can see ethdev API uses 'port_id' everywhere to
> refer to ethdev port by its number. So, I suggest
> 
> struct rte_flow_item_ethdev {
>      uint16_t port_id; /**< ethdev port ID */
> };
> 
> Basically I agree with Ori, that just "id" is a bit confusing
> even when it is a member of the _ethdev structure, but I'd
> prepend "port_"  a field name to sync with ethdev API which
> uses port_id. So, we have ethdev->port_id.

Ack

> 
> Andrew.
>
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index bb22294dd3..e05b0d83d2 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -306,6 +306,8 @@  enum index {
 	ITEM_POL_PORT,
 	ITEM_POL_METER,
 	ITEM_POL_POLICY,
+	ITEM_ETHDEV,
+	ITEM_ETHDEV_ID,
 
 	/* Validate/create actions. */
 	ACTIONS,
@@ -1000,6 +1002,7 @@  static const enum index next_item[] = {
 	ITEM_GENEVE_OPT,
 	ITEM_INTEGRITY,
 	ITEM_CONNTRACK,
+	ITEM_ETHDEV,
 	END_SET,
 	ZERO,
 };
@@ -1368,6 +1371,12 @@  static const enum index item_integrity_lv[] = {
 	ZERO,
 };
 
+static const enum index item_ethdev[] = {
+	ITEM_ETHDEV_ID,
+	ITEM_NEXT,
+	ZERO,
+};
+
 static const enum index next_action[] = {
 	ACTION_END,
 	ACTION_VOID,
@@ -3608,6 +3617,21 @@  static const struct token token_list[] = {
 			     item_param),
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
 	},
+	[ITEM_ETHDEV] = {
+		.name = "ethdev",
+		.help = "match traffic at e-switch going from (sent by) the given ethdev",
+		.priv = PRIV_ITEM(ETHDEV,
+				  sizeof(struct rte_flow_item_ethdev)),
+		.next = NEXT(item_ethdev),
+		.call = parse_vc,
+	},
+	[ITEM_ETHDEV_ID] = {
+		.name = "id",
+		.help = "ethdev ID",
+		.next = NEXT(item_ethdev, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, id)),
+	},
 	/* Validate/create actions. */
 	[ACTIONS] = {
 		.name = "actions",
@@ -8343,6 +8367,9 @@  flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_PFCP:
 		mask = &rte_flow_item_pfcp_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_ETHDEV:
+		mask = &rte_flow_item_ethdev_mask;
+		break;
 	default:
 		break;
 	}
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 2b42d5ec8c..ab628d9139 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1425,6 +1425,41 @@  Matches a conntrack state after conntrack action.
 - ``flags``: conntrack packet state flags.
 - Default ``mask`` matches all state bits.
 
+Item: ``ETHDEV``
+^^^^^^^^^^^^^^^^
+
+Matches traffic at e-switch going from (sent by) the given ethdev.
+
+::
+
+   *    (Ethdev) ~~~~~~~~~~~~ (Internal Port) >>>> [] ~~~~ (External Port)
+   *    :  SW                 :   Logical                    Net / Guest :
+   *    :                     :                                          :
+   *    | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ |
+   *
+   *    [] shows the effective ("transfer") standpoint, the match engine;
+   *    >> shows the traffic flow in question hitting the match engine;
+   *    ~~ shows logical interconnects between the endpoints.
+
+Use this with attribute **transfer**. Attributes **ingress** and
+**egress** (`Attribute: Traffic direction`_) must not be used.
+
+- Default ``mask`` provides exact match behaviour.
+
+.. _table_rte_flow_item_ethdev:
+
+.. table:: ETHDEV
+
+   +----------+----------+---------------------------+
+   | Field    | Subfield | Value                     |
+   +==========+==========+===========================+
+   | ``spec`` | ``id``   | ethdev ID                 |
+   +----------+----------+---------------------------+
+   | ``last`` | ``id``   | upper range value         |
+   +----------+----------+---------------------------+
+   | ``mask`` | ``id``   | zeroed for wildcard match |
+   +----------+----------+---------------------------+
+
 Actions
 ~~~~~~~
 
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index f099b1cca2..91631adb4e 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -167,6 +167,8 @@  API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* ethdev: Added item ``ETHDEV`` to flow API.
+
 * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to
   rte_cryptodev_is_valid_dev as it can be used by the application as
   well as PMD to check whether the device is valid or not.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index bbef706374..6d5de5457c 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3820,6 +3820,10 @@  This section lists supported pattern items and their attributes, if any.
 
 - ``conntrack``: match conntrack state.
 
+- ``ethdev``: match traffic at e-switch going from (sent by) the given ethdev
+
+  - ``id {unsigned}``: ethdev ID
+
 Actions list
 ^^^^^^^^^^^^
 
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..84eb61cb6c 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -100,6 +100,7 @@  static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)),
 	MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)),
 	MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)),
+	MK_FLOW_ITEM(ETHDEV, sizeof(struct rte_flow_item_ethdev)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 7b1ed7f110..880502098e 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -574,6 +574,15 @@  enum rte_flow_item_type {
 	 * @see struct rte_flow_item_conntrack.
 	 */
 	RTE_FLOW_ITEM_TYPE_CONNTRACK,
+
+	/**
+	 * [META]
+	 *
+	 * Matches traffic at e-switch going from (sent by) the given ethdev.
+	 *
+	 * @see struct rte_flow_item_ethdev
+	 */
+	RTE_FLOW_ITEM_TYPE_ETHDEV,
 };
 
 /**
@@ -1799,6 +1808,24 @@  static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
 };
 #endif
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * Provides an ethdev ID for use with items which are as follows:
+ * RTE_FLOW_ITEM_TYPE_ETHDEV.
+ */
+struct rte_flow_item_ethdev {
+	uint16_t id; /**< Ethdev ID */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */
+#ifndef __cplusplus
+static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
+	.id = 0xffff,
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *