DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC v1] ethdev: add flow metadata
@ 2018-06-07 12:52 Xueming Li
  2018-06-26  8:54 ` [dpdk-dev] [RFC v2] " Xueming Li
  0 siblings, 1 reply; 5+ messages in thread
From: Xueming Li @ 2018-06-07 12:52 UTC (permalink / raw)
  To: Adrien Mazarguil
  Cc: Xueming Li, dev, Shahaf Shuler, Thomas Monjalon, Olivier Matz

Currently, rte_flow pattern only match packet header fields.
This patch adds additional data to match the packet.

For example, in egress direction, to do an action depending on the VM
id, the application needs to configure rte_flow rule with the new
metadata pattern:
	pattern meta data is {vm} / end action encap …
Then the PMD will send VM id as metadata associated in mbuf to NIC,
then egress flow on NIC match metadata as other regular packet headers,
the appropriate encapsulation is done according to the VM id metadata.

Metadata could be used on ingress as well to save useful info before
flow modification (not defined yet) or decapsulation action. PMD is
responsible to save metadata into mbuf field. The application must get
metadata from the mbuf.

This patch introduces metadata item type for rte_flow, and new metadata
fields in mbuf to support metadata usage. They are two 32 bits metadata
fields defined for HW that support multiple metadata fields.

Cc: Thomas Monjalon <thomasm@mellanox.com>
Cc: Olivier Matz <olivier.matz@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst |  7 +++++++
 lib/librte_ethdev/rte_flow.c       |  1 +
 lib/librte_ethdev/rte_flow.h       | 28 ++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h         |  4 ++++
 4 files changed, 40 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index b305a72a5..c2f01fc9f 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1191,6 +1191,13 @@ Normally preceded by any of:
 - `Item: ICMP6_ND_NS`_
 - `Item: ICMP6_ND_OPT`_
 
+Item: ``META``
+^^^^^^^^^^^^^^
+
+Matches an metadata variable.
+
+- ``data``: 32 bit value.
+
 Actions
 ~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index b2afba089..54a07dd4a 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -66,6 +66,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 		     sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
 	MK_FLOW_ITEM(ICMP6_ND_OPT_TLA_ETH,
 		     sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
+	MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f8ba71cdb..f74e0eaec 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -413,6 +413,18 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_mark.
 	 */
 	RTE_FLOW_ITEM_TYPE_MARK,
+
+	/**
+	 * Matches a metadata variable.
+	 *
+	 * Possible sources of metadata:
+	 * - mbuf port or metadata field on egress
+	 * - egress metadata loopback to ingress
+	 * - data copied from packet header
+	 *
+	 * See struct rte_flow_item_meta.
+	 */
+	RTE_FLOW_ITEM_TYPE_META,
 };
 
 /**
@@ -849,6 +861,22 @@ static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
 #endif
 
 /**
+ * RTE_FLOW_ITEM_TYPE_META.
+ *
+ * Matches a meta data header.
+ */
+struct rte_flow_item_meta {
+	uint32_t data;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_META. */
+#ifndef __cplusplus
+static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
+	.data = RTE_BE32(UINT32_MAX),
+};
+#endif
+
+/**
  * RTE_FLOW_ITEM_TYPE_FUZZY
  *
  * Fuzzy pattern match, expect faster than default.
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8e6b4d292..a9e376b22 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -550,6 +550,10 @@ struct rte_mbuf {
 	RTE_STD_C11
 	union {
 		void *userdata;   /**< Can be used for external metadata */
+		struct {
+			uint32_t metadata0; /**< Metadata0 for rx/tx flow */
+			uint32_t metadata1; /**< Metadata1 for rx/tx flow */
+		};
 		uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
 	};
 
-- 
2.13.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [RFC v2] ethdev: add flow metadata
  2018-06-07 12:52 [dpdk-dev] [RFC v1] ethdev: add flow metadata Xueming Li
@ 2018-06-26  8:54 ` Xueming Li
  2018-08-20 15:45   ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Xueming Li @ 2018-06-26  8:54 UTC (permalink / raw)
  Cc: Xueming Li, dev, Adrien Mazarguil, Shahaf Shuler,
	Thomas Monjalon, Olivier Matz

Currently, rte_flow pattern only match packet header fields.
This patch adds additional data to match the packet.

For example, in egress direction, to do an action depending on the VM
id, the application needs to configure rte_flow rule with the new
metadata pattern:
    pattern meta data is {vm} / end action encap …
Then the PMD will send VM id as metadata associated in mbuf to NIC,
then egress flow on NIC match metadata as other regular packet headers,
the appropriate encapsulation is done according to the VM id metadata.

Metadata could be used on ingress as well to save useful info before
flow modification (not defined yet) or decapsulation action. PMD is
responsible to save metadata into mbuf field. The application must get
metadata from the mbuf.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Olivier Matz <olivier.matz@6wind.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 doc/guides/prog_guide/rte_flow.rst |  7 +++++++
 lib/librte_ethdev/rte_flow.c       |  1 +
 lib/librte_ethdev/rte_flow.h       | 28 ++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index b305a72a5..7989e5856 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1191,6 +1191,13 @@ Normally preceded by any of:
 - `Item: ICMP6_ND_NS`_
 - `Item: ICMP6_ND_OPT`_
 
+Item: ``META``
+^^^^^^^^^^^^^^
+
+Matches a metadata variable.
+
+- ``data``: 64 bit value.
+
 Actions
 ~~~~~~~
 
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index b2afba089..54a07dd4a 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -66,6 +66,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 		     sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
 	MK_FLOW_ITEM(ICMP6_ND_OPT_TLA_ETH,
 		     sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
+	MK_FLOW_ITEM(META, sizeof(struct rte_flow_item_meta)),
 };
 
 /** Generate flow_action[] entry. */
diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index f8ba71cdb..61b3dbe7b 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -413,6 +413,18 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_mark.
 	 */
 	RTE_FLOW_ITEM_TYPE_MARK,
+
+	/**
+	 * Matches a metadata variable.
+	 *
+	 * Possible sources of metadata:
+	 * - mbuf udata64 field on egress
+	 * - egress metadata loopback to ingress
+	 * - data copied from packet header
+	 *
+	 * See struct rte_flow_item_meta.
+	 */
+	RTE_FLOW_ITEM_TYPE_META,
 };
 
 /**
@@ -849,6 +861,22 @@ static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
 #endif
 
 /**
+ * RTE_FLOW_ITEM_TYPE_META.
+ *
+ * Matches a meta data header.
+ */
+struct rte_flow_item_meta {
+	uint64_t data;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_META. */
+#ifndef __cplusplus
+static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
+	.data = RTE_BE64(UINT64_MAX),
+};
+#endif
+
+/**
  * RTE_FLOW_ITEM_TYPE_FUZZY
  *
  * Fuzzy pattern match, expect faster than default.
-- 
2.13.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [RFC v2] ethdev: add flow metadata
  2018-06-26  8:54 ` [dpdk-dev] [RFC v2] " Xueming Li
@ 2018-08-20 15:45   ` Ferruh Yigit
  2018-08-20 16:03     ` Ferruh Yigit
  2018-08-23 20:41     ` Yongseok Koh
  0 siblings, 2 replies; 5+ messages in thread
From: Ferruh Yigit @ 2018-08-20 15:45 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Adrien Mazarguil, Shahaf Shuler, Thomas Monjalon, Olivier Matz

On 6/26/2018 9:54 AM, Xueming Li wrote:
> Currently, rte_flow pattern only match packet header fields.
> This patch adds additional data to match the packet.
> 
> For example, in egress direction, to do an action depending on the VM
> id, the application needs to configure rte_flow rule with the new
> metadata pattern:
>     pattern meta data is {vm} / end action encap …
> Then the PMD will send VM id as metadata associated in mbuf to NIC,
> then egress flow on NIC match metadata as other regular packet headers,
> the appropriate encapsulation is done according to the VM id metadata.
> 
> Metadata could be used on ingress as well to save useful info before
> flow modification (not defined yet) or decapsulation action. PMD is
> responsible to save metadata into mbuf field. The application must get
> metadata from the mbuf.
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: Olivier Matz <olivier.matz@6wind.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  doc/guides/prog_guide/rte_flow.rst |  7 +++++++
>  lib/librte_ethdev/rte_flow.c       |  1 +
>  lib/librte_ethdev/rte_flow.h       | 28 ++++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
> index b305a72a5..7989e5856 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -1191,6 +1191,13 @@ Normally preceded by any of:
>  - `Item: ICMP6_ND_NS`_
>  - `Item: ICMP6_ND_OPT`_
>  
> +Item: ``META``
> +^^^^^^^^^^^^^^
> +
> +Matches a metadata variable.
> +
> +- ``data``: 64 bit value.
> +

Isn't this "user data" more than metadata?

And there is only one userdata can be provided for a flow.
Can there be a need to provide multiple userdata? Should we support it?
For your example, on egress what if you want to do specific action on a flow for
both VM id and process id, you can only pass single user data?
What about passing a key-value pair?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [RFC v2] ethdev: add flow metadata
  2018-08-20 15:45   ` Ferruh Yigit
@ 2018-08-20 16:03     ` Ferruh Yigit
  2018-08-23 20:41     ` Yongseok Koh
  1 sibling, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2018-08-20 16:03 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Adrien Mazarguil, Shahaf Shuler, Thomas Monjalon, Olivier Matz

On 8/20/2018 4:45 PM, Ferruh Yigit wrote:
> On 6/26/2018 9:54 AM, Xueming Li wrote:
>> Currently, rte_flow pattern only match packet header fields.
>> This patch adds additional data to match the packet.
>>
>> For example, in egress direction, to do an action depending on the VM
>> id, the application needs to configure rte_flow rule with the new
>> metadata pattern:
>>     pattern meta data is {vm} / end action encap …
>> Then the PMD will send VM id as metadata associated in mbuf to NIC,
>> then egress flow on NIC match metadata as other regular packet headers,
>> the appropriate encapsulation is done according to the VM id metadata.
>>
>> Metadata could be used on ingress as well to save useful info before
>> flow modification (not defined yet) or decapsulation action. PMD is
>> responsible to save metadata into mbuf field. The application must get
>> metadata from the mbuf.
>>
>> Cc: Thomas Monjalon <thomas@monjalon.net>
>> Cc: Olivier Matz <olivier.matz@6wind.com>
>> Cc: Shahaf Shuler <shahafs@mellanox.com>
>> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
>> ---
>>  doc/guides/prog_guide/rte_flow.rst |  7 +++++++
>>  lib/librte_ethdev/rte_flow.c       |  1 +
>>  lib/librte_ethdev/rte_flow.h       | 28 ++++++++++++++++++++++++++++
>>  3 files changed, 36 insertions(+)
>>
>> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
>> index b305a72a5..7989e5856 100644
>> --- a/doc/guides/prog_guide/rte_flow.rst
>> +++ b/doc/guides/prog_guide/rte_flow.rst
>> @@ -1191,6 +1191,13 @@ Normally preceded by any of:
>>  - `Item: ICMP6_ND_NS`_
>>  - `Item: ICMP6_ND_OPT`_
>>  
>> +Item: ``META``
>> +^^^^^^^^^^^^^^
>> +
>> +Matches a metadata variable.
>> +
>> +- ``data``: 64 bit value.
>> +
> 
> Isn't this "user data" more than metadata?
> 
> And there is only one userdata can be provided for a flow.
> Can there be a need to provide multiple userdata? Should we support it?
> For your example, on egress what if you want to do specific action on a flow for
> both VM id and process id, you can only pass single user data?
> What about passing a key-value pair?

Looks like a there is a new version of the patch:
https://patches.dpdk.org/patch/43684/

I will update status of this one as "Superseded" and continue with new one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [RFC v2] ethdev: add flow metadata
  2018-08-20 15:45   ` Ferruh Yigit
  2018-08-20 16:03     ` Ferruh Yigit
@ 2018-08-23 20:41     ` Yongseok Koh
  1 sibling, 0 replies; 5+ messages in thread
From: Yongseok Koh @ 2018-08-23 20:41 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: Xueming(Steven) Li, dev, Adrien Mazarguil, Shahaf Shuler,
	Thomas Monjalon, Olivier Matz


> On Aug 20, 2018, at 8:45 AM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
> On 6/26/2018 9:54 AM, Xueming Li wrote:
>> Currently, rte_flow pattern only match packet header fields.
>> This patch adds additional data to match the packet.
>> 
>> For example, in egress direction, to do an action depending on the VM
>> id, the application needs to configure rte_flow rule with the new
>> metadata pattern:
>>    pattern meta data is {vm} / end action encap …
>> Then the PMD will send VM id as metadata associated in mbuf to NIC,
>> then egress flow on NIC match metadata as other regular packet headers,
>> the appropriate encapsulation is done according to the VM id metadata.
>> 
>> Metadata could be used on ingress as well to save useful info before
>> flow modification (not defined yet) or decapsulation action. PMD is
>> responsible to save metadata into mbuf field. The application must get
>> metadata from the mbuf.
>> 
>> Cc: Thomas Monjalon <thomas@monjalon.net>
>> Cc: Olivier Matz <olivier.matz@6wind.com>
>> Cc: Shahaf Shuler <shahafs@mellanox.com>
>> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
>> ---
>> doc/guides/prog_guide/rte_flow.rst |  7 +++++++
>> lib/librte_ethdev/rte_flow.c       |  1 +
>> lib/librte_ethdev/rte_flow.h       | 28 ++++++++++++++++++++++++++++
>> 3 files changed, 36 insertions(+)
>> 
>> diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
>> index b305a72a5..7989e5856 100644
>> --- a/doc/guides/prog_guide/rte_flow.rst
>> +++ b/doc/guides/prog_guide/rte_flow.rst
>> @@ -1191,6 +1191,13 @@ Normally preceded by any of:
>> - `Item: ICMP6_ND_NS`_
>> - `Item: ICMP6_ND_OPT`_
>> 
>> +Item: ``META``
>> +^^^^^^^^^^^^^^
>> +
>> +Matches a metadata variable.
>> +
>> +- ``data``: 64 bit value.
>> +
> 
> Isn't this "user data" more than metadata?
> 
> And there is only one userdata can be provided for a flow.
> Can there be a need to provide multiple userdata? Should we support it?
> For your example, on egress what if you want to do specific action on a flow for
> both VM id and process id, you can only pass single user data?
> What about passing a key-value pair?

It could be matter of how device supports metadata. I assume that most of devices
would support one single metadata. Then, we can leave it as user's choice. I mean
user can partition 64bit according to its need. E.g. (key << 32) | value.

Thanks,
Yongseok


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-23 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 12:52 [dpdk-dev] [RFC v1] ethdev: add flow metadata Xueming Li
2018-06-26  8:54 ` [dpdk-dev] [RFC v2] " Xueming Li
2018-08-20 15:45   ` Ferruh Yigit
2018-08-20 16:03     ` Ferruh Yigit
2018-08-23 20:41     ` Yongseok Koh

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).