[v4,1/2] ethdev: add random item support
Checks
Commit Message
Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
This item enables to match on some random value as a part of flow rule.
Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
doc/guides/nics/features/default.ini | 1 +
doc/guides/prog_guide/rte_flow.rst | 14 +++++++++++
doc/guides/rel_notes/release_24_03.rst | 5 ++++
lib/ethdev/rte_flow.c | 1 +
lib/ethdev/rte_flow.h | 35 +++++++++++++++++++++++++-
5 files changed, 55 insertions(+), 1 deletion(-)
Comments
> Subject: [PATCH v4 1/2] ethdev: add random item support
>
> Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
> This item enables to match on some random value as a part of flow rule.
>
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Best regards,
Dariusz Sosnowski
Hi Michael,
> -----Original Message-----
> From: Michael Baum <michaelba@nvidia.com>
> Sent: Thursday, December 14, 2023 12:59 PM
> Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
> This item enables to match on some random value as a part of flow rule.
>
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
On 12/14/2023 10:58 AM, Michael Baum wrote:
> Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
> This item enables to match on some random value as a part of flow rule.
>
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
> ---
> doc/guides/nics/features/default.ini | 1 +
> doc/guides/prog_guide/rte_flow.rst | 14 +++++++++++
> doc/guides/rel_notes/release_24_03.rst | 5 ++++
> lib/ethdev/rte_flow.c | 1 +
> lib/ethdev/rte_flow.h | 35 +++++++++++++++++++++++++-
> 5 files changed, 55 insertions(+), 1 deletion(-)
>
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
> index 806cb033ff..6d50236292 100644
> --- a/doc/guides/nics/features/default.ini
> +++ b/doc/guides/nics/features/default.ini
> @@ -140,6 +140,7 @@ pppoe_proto_id =
> ptype =
> quota =
> raw =
> +random =
> represented_port =
> sctp =
> tag =
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index 627b845bfb..900fdaefb6 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -1573,6 +1573,20 @@ Matches the packet type as defined in rte_mbuf_ptype.
>
> - ``packet_type``: L2/L3/L4 and tunnel information.
>
> +Item: ``RANDOM``
> +^^^^^^^^^^^^^^^^
> +
> +Matches a random value.
> +
> +A random unsigned integer (at most 32-bit) is generated for each packet during
> +flow rule processing, by either HW, SW or some external source.
> +Application can match on either exact value or range of values.
> +This value is not based on the packet data/headers.
> +Application shouldn't assume that this value is kept during the lifetime of
> +the packet.
> +
> +- ``value``: Specific value to match.
> +
Hi Michael,
What is the usecase for the 'random' flow item?
Is it to match some kind of metadata generated by HW?
Or is it a way to sampling traffic?
And how random 'random' item is, is it configured/set in HW or random
per packet?
On 12/14/2023 2:18 PM, Ferruh Yigit wrote:
>
> On 12/14/2023 10:58 AM, Michael Baum wrote:
> > Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
> > This item enables to match on some random value as a part of flow rule.
> >
...
> >
> > +Item: ``RANDOM``
> > +^^^^^^^^^^^^^^^^
> > +
> > +Matches a random value.
> > +
> > +A random unsigned integer (at most 32-bit) is generated for each
> > +packet during flow rule processing, by either HW, SW or some external source.
> > +Application can match on either exact value or range of values.
> > +This value is not based on the packet data/headers.
> > +Application shouldn't assume that this value is kept during the
> > +lifetime of the packet.
> > +
> > +- ``value``: Specific value to match.
> > +
>
>
> Hi Michael,
>
> What is the usecase for the 'random' flow item?
I can think about 2 different use cases:
1. Sampling - when application wants to sample certain percentage of the flow, it can match random value for getting it.
2. Distribution - when application wants to distribute the traffic between ports/queues, it can match all random value range with send to port/queue actions.
>
> Is it to match some kind of metadata generated by HW?
It can be generated by either HW, SW or some external source.
Each PMD supporting random item responds to have a generator for that.
> Or is it a way to sampling traffic?
It can be both. The PMD can use random value generated by HW while user match on it for sampling traffic.
>
> And how random 'random' item is, is it configured/set in HW or random per packet?
From API perspective, it is pure random not packet oriented. Same packet can get different values during the pipeline.
I mentioned it in documentation:
"This value is not based on the packet data/headers.
Application shouldn't assume that this value is kept during the lifetime of the packet."
On 12/14/2023 1:43 PM, Michael Baum wrote:
>
> On 12/14/2023 2:18 PM, Ferruh Yigit wrote:
>>
>> On 12/14/2023 10:58 AM, Michael Baum wrote:
>>> Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
>>> This item enables to match on some random value as a part of flow rule.
>>>
>
> ...
>
>>>
>>> +Item: ``RANDOM``
>>> +^^^^^^^^^^^^^^^^
>>> +
>>> +Matches a random value.
>>> +
>>> +A random unsigned integer (at most 32-bit) is generated for each
>>> +packet during flow rule processing, by either HW, SW or some external source.
>>> +Application can match on either exact value or range of values.
>>> +This value is not based on the packet data/headers.
>>> +Application shouldn't assume that this value is kept during the
>>> +lifetime of the packet.
>>> +
>>> +- ``value``: Specific value to match.
>>> +
>>
>>
>> Hi Michael,
>>
>> What is the usecase for the 'random' flow item?
> I can think about 2 different use cases:
> 1. Sampling - when application wants to sample certain percentage of the flow, it can match random value for getting it.
> 2. Distribution - when application wants to distribute the traffic between ports/queues, it can match all random value range with send to port/queue actions.
>
>>
>> Is it to match some kind of metadata generated by HW?
> It can be generated by either HW, SW or some external source.
> Each PMD supporting random item responds to have a generator for that.
>
>> Or is it a way to sampling traffic?
> It can be both. The PMD can use random value generated by HW while user match on it for sampling traffic.
>
>>
>> And how random 'random' item is, is it configured/set in HW or random per packet?
> From API perspective, it is pure random not packet oriented. Same packet can get different values during the pipeline.
> I mentioned it in documentation:
> "This value is not based on the packet data/headers.
> Application shouldn't assume that this value is kept during the lifetime of the packet."
>
Thanks Michael, for clarification.
I was thinking if this can be used together with external (to DPDK) flow
steering configuration.
Like external tool can set values to match for specific pattern,
tcp --> 100
udp --> 200
Later these values can be used by DPDK application and this filtering item.
Can you please confirm this is not the "use case"/intention, if so we
may need to rename the rte flow item.
Also there will be driver implementation in this release, right?
On 12/14/2023 5:56 PM, Ferruh Yigit wrote:
>
> On 12/14/2023 1:43 PM, Michael Baum wrote:
> >
> > On 12/14/2023 2:18 PM, Ferruh Yigit wrote:
> >>
> >> On 12/14/2023 10:58 AM, Michael Baum wrote:
> >>> Add support for a new item type "RTE_FLOW_ITEM_TYPE_RANDOM".
> >>> This item enables to match on some random value as a part of flow rule.
> >>>
> >
> > ...
> >
> >>>
> >>> +Item: ``RANDOM``
> >>> +^^^^^^^^^^^^^^^^
> >>> +
> >>> +Matches a random value.
> >>> +
> >>> +A random unsigned integer (at most 32-bit) is generated for each
> >>> +packet during flow rule processing, by either HW, SW or some external
> source.
> >>> +Application can match on either exact value or range of values.
> >>> +This value is not based on the packet data/headers.
> >>> +Application shouldn't assume that this value is kept during the
> >>> +lifetime of the packet.
> >>> +
> >>> +- ``value``: Specific value to match.
> >>> +
> >>
> >>
> >> Hi Michael,
> >>
> >> What is the usecase for the 'random' flow item?
> > I can think about 2 different use cases:
> > 1. Sampling - when application wants to sample certain percentage of the flow,
> it can match random value for getting it.
> > 2. Distribution - when application wants to distribute the traffic between
> ports/queues, it can match all random value range with send to port/queue
> actions.
> >
> >>
> >> Is it to match some kind of metadata generated by HW?
> > It can be generated by either HW, SW or some external source.
> > Each PMD supporting random item responds to have a generator for that.
> >
> >> Or is it a way to sampling traffic?
> > It can be both. The PMD can use random value generated by HW while user
> match on it for sampling traffic.
> >
> >>
> >> And how random 'random' item is, is it configured/set in HW or random per
> packet?
> > From API perspective, it is pure random not packet oriented. Same packet can
> get different values during the pipeline.
> > I mentioned it in documentation:
> > "This value is not based on the packet data/headers.
> > Application shouldn't assume that this value is kept during the lifetime of the
> packet."
> >
>
> Thanks Michael, for clarification.
>
> I was thinking if this can be used together with external (to DPDK) flow steering
> configuration.
> Like external tool can set values to match for specific pattern, tcp --> 100 udp -->
> 200 Later these values can be used by DPDK application and this filtering item.
>
> Can you please confirm this is not the "use case"/intention, if so we may need to
> rename the rte flow item.
Hi, this is not the use-case.
>
> Also there will be driver implementation in this release, right?
Yes, series-30558 ("net/mlx5: add random item support")
https://patchwork.dpdk.org/project/dpdk/cover/20231214151248.1654878-1-michaelba@nvidia.com/
@@ -140,6 +140,7 @@ pppoe_proto_id =
ptype =
quota =
raw =
+random =
represented_port =
sctp =
tag =
@@ -1573,6 +1573,20 @@ Matches the packet type as defined in rte_mbuf_ptype.
- ``packet_type``: L2/L3/L4 and tunnel information.
+Item: ``RANDOM``
+^^^^^^^^^^^^^^^^
+
+Matches a random value.
+
+A random unsigned integer (at most 32-bit) is generated for each packet during
+flow rule processing, by either HW, SW or some external source.
+Application can match on either exact value or range of values.
+This value is not based on the packet data/headers.
+Application shouldn't assume that this value is kept during the lifetime of
+the packet.
+
+- ``value``: Specific value to match.
+
Actions
~~~~~~~
@@ -55,6 +55,11 @@ New Features
Also, make sure to start the actual text at the margin.
=======================================================
+* **Added flow matching of random value.**
+
+ * Added ``RTE_FLOW_ITEM_TYPE_RANDOM`` to match random value.
+ * Added ``RTE_FLOW_FIELD_RANDOM`` to represent it in field API.
+
Removed Items
-------------
@@ -136,6 +136,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
MK_FLOW_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)),
+ MK_FLOW_ITEM(RANDOM, sizeof(struct rte_flow_item_random)),
MK_FLOW_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
MK_FLOW_ITEM(GRE_KEY, sizeof(rte_be32_t)),
MK_FLOW_ITEM(GRE_OPTION, sizeof(struct rte_flow_item_gre_opt)),
@@ -704,6 +704,19 @@ enum rte_flow_item_type {
*
*/
RTE_FLOW_ITEM_TYPE_PTYPE,
+
+ /**
+ * [META]
+ *
+ * Matches a random value.
+ *
+ * This value is not based on the packet data/headers.
+ * Application shouldn't assume that this value is kept during the
+ * lifetime of the packet.
+ *
+ * @see struct rte_flow_item_random.
+ */
+ RTE_FLOW_ITEM_TYPE_RANDOM,
};
/**
@@ -2047,6 +2060,25 @@ static const struct rte_flow_item_ib_bth rte_flow_item_ib_bth_mask = {
};
#endif
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_RANDOM
+ *
+ * Matches a random value.
+ */
+struct rte_flow_item_random {
+ uint32_t value;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_RANDOM. */
+#ifndef __cplusplus
+static const struct rte_flow_item_random rte_flow_item_random_mask = {
+ .value = UINT32_MAX,
+};
+#endif
+
/**
* Matching pattern item definition.
*
@@ -3903,7 +3935,8 @@ enum rte_flow_field_id {
RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */
RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */
RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */
- RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */
+ RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN,/**< IPv6 payload length. */
+ RTE_FLOW_FIELD_RANDOM /**< Random value. */
};
/**