ethdev: introduce generic copy rte flow action
PATCH 1/1 ethdev: introduce generic copy rte flow action
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC: http://patches.dpdk.org/patch/85384/
--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)
doc/guides/prog_guide/rte_flow.rst +35 -0
@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. + +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
lib/librte_ethdev/rte_flow.c +1 -0
@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.24.1
Hi Alexander,
I guess that the test-pmd part will be available later right?
Quoted 8 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
Quoted 9 lines
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Since the question why you are using enum and not just offset from
the start of the packet, was discussed and raised by number of people it will be best if it will appear in the commit log, at least the advantages to this implementation.
Quoted 26 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com% 7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C 1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a mp;reserved=0Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +
For tag I think you should also use the index right?
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2778
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item.
Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.
What happens if we want to copy between different sizes?
for example copy IPV6 src to number of tags? I assume we will be using offset and split the copy command to number of actions right?
Quoted 86 lines
doc/guides/prog_guide/rte_flow.rst +25
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ + Negative types ~~~~~~~~~~~~~~lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +28
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM ,
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID , +RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};
I don't think this name is good since it not rte_flow_item this is just internal enumeration for this action.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;
Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting +* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;
Why use 32 bit register?
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
Correct, Ori. We'll soon send the testpmd part and pmd draft.
Regards,
Asaf Penso
Quoted 231 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Ori Kam
Sent: Sunday, January 10, 2021 10:01 AM
To: Alexander Kozyrev <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] ethdev: introduce generic copy rte flow actionHi Alexander,
I guess that the test-pmd part will be available later right?
Quoted 8 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
Quoted 9 lines
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Since the question why you are using enum and not just offset from the start of the packet, was discussed and raised by number of people it will be best if it will appear in the commit log, at least the advantages to this implementation.
Quoted 2 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
Quoted 1 line
es.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com %
Quoted 2 lines
7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc
c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7 C
Quoted 1 line
1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a
Quoted 7 lines
mp;reserved=0
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59++++++++++++++++++++++++++++++
Quoted 12 lines
3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +For tag I think you should also use the index right?
doc/guides/prog_guide/rte_flow.rst
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and it +is possible to start the copy from the ``offset`` bits in an item.Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.What happens if we want to copy between different sizes?
for example copy IPV6 src to number of tags? I assume we will be using offset and split the copy command to number of actions right?Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item |doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2803
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | ++===============+==========================================
+Quoted 66 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ + Negative types ~~~~~~~~~~~~~~(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.cindexa06f64c271..fdbabefc47100644lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-1/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index
0977a78270..0540c861fb100644lib/librte_ethdev/rte_flow.h +28
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM ,lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID , +RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};I don't think this name is good since it not
rte_flow_itemthis is just internal enumeration for this action.lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting +* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;Why use 32 bit register?
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
Quoted 4 lines
From: Ori Kam <[email protected]> on Sunday, January 10, 2021 3:01 Hi Alexander,
I guess that the test-pmd part will be available later right?
Yes, please take a look at v2 version for testpmd implementation.
Quoted 18 lines
Quoted 8 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
Quoted 9 lines
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Quoted 5 lines
Since the question why you are using enum and not just offset from the start of the packet, was discussed and raised by number of people it will be best
if it will appear in the commit log, at least the advantages to this implementation.
Ok, will add to v3 commit message.
Quoted 32 lines
Quoted 2 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.
dQuoted 1 line
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com%
Quoted 1 line
7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc
Quoted 1 line
c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C
Quoted 20 lines
1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a mp;reserved=0
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +For tag I think you should also use the index right?
Right, index is here to access any element in the tag array in addition to outermost or any inner packet header fields. Will specify explicitly in the doc.
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2778
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item.Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.
0 is outer most, of course, I'Il add some clarification about that.
Quoted 4 lines
What happens if we want to copy between different sizes?
for example copy IPV6 src to number of tags? I assume we will be using offset and
split the copy command to number of actions right?
That is the correct understanding. We can utilize 4 copy_item actions in this case to copy 32-bits of an IPv6 SRC at the time (specifying different offsets) to 4 different Tag fields.
Quoted 92 lines
Quoted 92 lines
doc/guides/prog_guide/rte_flow.rst +25
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ + Negative types ~~~~~~~~~~~~~~lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +34
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM , +RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID ,
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};I don't think this name is good since it not
rte_flow_itemthis is just internal enumeration
for this action.
Will rename to rte_flow_action_copy_item_id in v3? Is this ok?
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
This extends the flexibility of the copy API. This way you can modify any place in a packet as you desire by specifying RTE_FLOW_ITEM_NONE to start with the beginning of a packet and choosing a particular offset value to point in a desired place. And since packet length can be pretty big we need to accommodate this.
Do you think this flexibility is not necessary and we should bound the offset to the length of a selected packet field only? Index is 32 bit for the same field in RSS.
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM +* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;Why use 32 bit register?
Again, to make API as generic as possible in case there will be a PMD driver that can copy a huge chunk of a packet into the another place of this packet. What is your opinion on that?
Quoted 11 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
Hi,
Quoted 91 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, January 12, 2021 4:16 PM
To: Ori Kam <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce generic copy rte flow actionQuoted 4 lines
From: Ori Kam <[email protected]> on Sunday, January 10, 2021 3:01 Hi Alexander,
I guess that the test-pmd part will be available later right?
Yes, please take a look at v2 version for testpmd implementation.
Quoted 13 lines
Quoted 13 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
Quoted 7 lines
Quoted 4 lines
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Since the question why you are using enum and not just offset from the start of the packet, was discussed and raised by number of people it will
be
Quoted 3 lines
best
if it will appear in the commit log, at least the advantages to this implementation.Ok, will add to v3 commit message.
Quoted 6 lines
Quoted 2 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.
dQuoted 1 line
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com%
Quoted 2 lines
Quoted 1 line
7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc
Quoted 2 lines
Quoted 1 line
c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ
Quoted 2 lines
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C
Quoted 1 line
Quoted 1 line
1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a
Quoted 19 lines
Quoted 19 lines
mp;reserved=0
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +For tag I think you should also use the index right?
Right, index is here to access any element in the tag array in addition to outermost or any inner packet header fields. Will specify explicitly in the doc.
Quoted 8 lines
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2778
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item.Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.0 is outer most, of course, I'Il add some clarification about that.
Not necessary, like I said please look at the RSS, 0 can mean the inner most.
Quoted 110 lines
Quoted 4 lines
What happens if we want to copy between different sizes?
for example copy IPV6 src to number of tags? I assume we will be using offset and
split the copy command to number of actions right?That is the correct understanding. We can utilize 4
copy_itemactions in this case to
copy 32-bits of an IPv6 SRC at the time (specifying different offsets) to 4 different Tag fields.Quoted 12 lines
Quoted 12 lines
doc/guides/prog_guide/rte_flow.rst +12
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2803
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | ++===============+==========================================+ > > + | ``item`` | ID of a packet field/mark/metadata/tag | > > + | ``index`` | index of outer/inner header or tag array | > > + | ``offset`` | number of bits to skip during the copy | > > + +---------------+------------------------------------------+Quoted 68 lines
Quoted 68 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ Negative types ~~~~~~~~~~~~~~lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +34
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM , +RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID ,Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};I don't think this name is good since it not
rte_flow_itemthis is just internal enumeration
for this action.
Quoted 2 lines
Will rename to
rte_flow_action_copy_item_idin v3? Is this ok?
Yes better,
Or rte_flow_copy_item_id?
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
Quoted 10 lines
This extends the flexibility of the copy API. This way you can modify any place in a packet as you desire by specifying
RTE_FLOW_ITEM_NONEto start with the
beginning of a packet and choosing a particular offset value to point in a desired place.
And since packet length can be pretty big we need to accommodate this. Do you think this flexibility is not necessary and we should bound the offset to the
length of a selected packet field only? Index is 32 bit for the same field in RSS.
Nice idea but then I would add ITEM_OFFSET or something around this name, I don't think NONE is a valid value.
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM +* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;Why use 32 bit register?
Quoted 4 lines
Again, to make API as generic as possible in case there will be a PMD driver that can copy a huge chunk of a packet into the another place of this packet. What is your opinion on that?
Nice thinking,
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
Hi,
Quoted 231 lines
-----Original Message-----
From: Ori Kam
Sent: Tuesday, January 12, 2021 4:53 PM
To: Alexander Kozyrev <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce generic copy rte flow actionHi,
Quoted 5 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, January 12, 2021 4:16 PM
To: Ori Kam <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-ThomasMonjalon
Quoted 28 lines
<[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce generic copy rte flow actionQuoted 4 lines
From: Ori Kam <[email protected]> on Sunday, January 10, 2021 3:01 Hi Alexander,
I guess that the test-pmd part will be available later right?
Yes, please take a look at v2 version for testpmd implementation.
Quoted 18 lines
Quoted 17 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Quoted 11 lines
Quoted 2 lines
Since the question why you are using enum and not just offset from the start of the packet, was discussed and raised by number of people it will
be
Quoted 3 lines
best
if it will appear in the commit log, at least the advantages to this implementation.Ok, will add to v3 commit message.
Quoted 3 lines
Quoted 2 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.
Quoted 4 lines
Quoted 3 lines
d
Quoted 1 line
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com%
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C
Quoted 2 lines
Quoted 1 line
Quoted 1 line
1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
mp;reserved=0
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59++++++++++++++++++++++++++++++
Quoted 25 lines
Quoted 12 lines
Quoted 12 lines
3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +For tag I think you should also use the index right?
Right, index is here to access any element in the tag array in addition to outermost or any inner packet header fields. Will specify explicitly in the doc.
Quoted 8 lines
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2778
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item.Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.0 is outer most, of course, I'Il add some clarification about that.
Not necessary, like I said please look at the RSS, 0 can mean the inner most.
Quoted 2 lines
Quoted 2 lines
What happens if we want to copy between different sizes? for example copy IPV6 src to number of tags? I assume we will be using
offset
Quoted 108 lines
Quoted 2 lines
and
split the copy command to number of actions right?That is the correct understanding. We can utilize 4
copy_itemactions in this case to
copy 32-bits of an IPv6 SRC at the time (specifying different offsets) to 4 different Tag fields.Quoted 12 lines
Quoted 12 lines
doc/guides/prog_guide/rte_flow.rst +12
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2803
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | ++===============+==========================================+ > > + | ``item`` | ID of a packet field/mark/metadata/tag | > > + | ``index`` | index of outer/inner header or tag array | > > + | ``offset`` | number of bits to skip during the copy | > > + +---------------+------------------------------------------+Quoted 76 lines
Quoted 62 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ Negative types ~~~~~~~~~~~~~~lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +28
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM ,lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID , +RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};I don't think this name is good since it not
rte_flow_itemthis is just internal enumeration
for this action.
Quoted 5 lines
Quoted 2 lines
Will rename to
rte_flow_action_copy_item_idin v3? Is this ok?Yes better,
Orrte_flow_copy_item_id?
On second thought I think a better name should be:rte_flow_field_id - I removed the copy since we may use it in other actions for example set/add
Quoted 54 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
Quoted 10 lines
This extends the flexibility of the copy API. This way you can modify any place in a packet as you desire by specifying
RTE_FLOW_ITEM_NONEto start with the
beginning of a packet and choosing a particular offset value to point in a desired place.
And since packet length can be pretty big we need to accommodate this. Do you think this flexibility is not necessary and we should bound the offset to the
length of a selected packet field only? Index is 32 bit for the same field in RSS.Nice idea but then I would add
ITEM_OFFSETor something around this name, I don't think NONE is a valid value.Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM +* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;Why use 32 bit register?
Quoted 4 lines
Again, to make API as generic as possible in case there will be a PMD driver that can copy a huge chunk of a packet into the another place of this packet. What is your opinion on that?
Nice thinking,
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
Quoted 237 lines
Quoted 3 lines
From: Ori Kam onTuesday, January 12, 2021 4:53 PM
To: Alexander Kozyrev <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-ThomasMonjalon
Quoted 4 lines
<[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce generic copy rte flow actionQuoted 38 lines
Hi,
Quoted 5 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, January 12, 2021 4:16 PM
To: Ori Kam <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-ThomasMonjalon
Quoted 30 lines
<[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce generic copy rte flow actionQuoted 4 lines
From: Ori Kam <[email protected]> on Sunday, January 10, 2021 3:01 Hi Alexander,
I guess that the test-pmd part will be available later right?
Yes, please take a look at v2 version for testpmd implementation.
Quoted 20 lines
Quoted 8 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 8, 2021 8:33 AM
Subject: [PATCH] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
Quoted 9 lines
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
Since the question why you are using enum and not just offset from the start of the packet, was discussed and raised by number of people it
will
Quoted 10 lines
Quoted 9 lines
be
Quoted 3 lines
best
if it will appear in the commit log, at least the advantages to this implementation.Ok, will add to v3 commit message.
Quoted 3 lines
Quoted 2 lines
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
d
Quoted 1 line
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com%
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
7Cd04c2e49c3a840994da408d8b39f3304%7C43083d15727340c1b7db39efd9cc
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
c17a%7C0%7C0%7C637456843629116269%7CUnknown%7CTWFpbGZsb3d8eyJ
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C
Quoted 11 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
1000&sdata=85096rASBtzbjU42pV6sPkl3nVt5HlR6%2BL9nxI3qgFA%3D&a
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
mp;reserved=0
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59++++++++++++++++++++++++++++++
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined
Quoted 8 lines
3 files changed, 95 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,41 @@ The behaviour of the shared action definedby
Quoted 138 lines
Quoted 17 lines
Quoted 4 lines
Quoted 4 lines
``action`` argument of type
| no properties | +---------------+Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2776
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +For tag I think you should also use the index right?
Right, index is here to access any element in the tag array in addition to outermost or any inner packet header fields. Will specify explicitly in the doc.
Quoted 8 lines
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2778
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item.Please specify what means index 0 /1 ... 0 is outer most? Inner most? You can look at the RSS level for reference.
I think it will be best to use the same values.0 is outer most, of course, I'Il add some clarification about that.
Not necessary, like I said please look at the RSS, 0 can mean the inner most.
Quoted 2 lines
Quoted 2 lines
What happens if we want to copy between different sizes? for example copy IPV6 src to number of tags? I assume we will be using
offset
Quoted 108 lines
Quoted 2 lines
and
split the copy command to number of actions right?That is the correct understanding. We can utilize 4
copy_itemactions in this case to
copy 32-bits of an IPv6 SRC at the time (specifying different offsets) to 4 different Tag fields.Quoted 12 lines
Quoted 12 lines
doc/guides/prog_guide/rte_flow.rst +12
-0+ +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2803
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | ++===============+==========================================+ > > + | ``item`` | ID of a packet field/mark/metadata/tag | > > + | ``index`` | index of outer/inner header or tag array | > > + | ``offset`` | number of bits to skip during the copy | > > + +---------------+------------------------------------------+Quoted 76 lines
Quoted 62 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ Negative types ~~~~~~~~~~~~~~lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +28
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_NONE =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM ,lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_ITEM_TCP_FLAGS , +RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID , +RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +};I don't think this name is good since it not
rte_flow_itemthis is just internal enumeration
for this action.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Will rename to
rte_flow_action_copy_item_idin v3? Is this ok?Yes better,
Orrte_flow_copy_item_id?On second thought I think a better name should be:
rte_flow_field_id- I removed the copy since we may use it in other actions for example set/add
Then I would prefer sticking to the original rte_flow_item_id naming. It allows room for anyone to use it as a general enum and incrorporates tag/metadata and other future extensions, not just packet fields.
Quoted 57 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2836
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ +struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t index; +uint32_t offset;Why use 32 bits? Since this copy only one register with max len of 32 bit. The max offset can 31? Same for the index.
This extends the flexibility of the copy API. This way you can modify any
place
Quoted 6 lines
Quoted 6 lines
in a packet as you desire by specifying
RTE_FLOW_ITEM_NONEto start with the
beginning of a packet and choosing a particular offset value to point in a desired place.
And since packet length can be pretty big we need to accommodate this. Do you think this flexibility is not necessary and we should bound the offsetto
Quoted 2 lines
Quoted 2 lines
the
length of a selected packet field only? Index is 32 bit for the same field inRSS.
Quoted 37 lines
Quoted 1 line
Nice idea but then I would add
ITEM_OFFSETor something around this name, I don't think NONE is a valid value.Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM +* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting Quoted 8 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2850
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* an arbituary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width;Why use 32 bit register?
Quoted 4 lines
Again, to make API as generic as possible in case there will be a PMD driver that can copy a huge chunk of a packet into the another place of this packet. What is your opinion on that?
Nice thinking,
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
Best,
Ori
v2 cover generic copy rte flow action support
In reply to Alexander KozyrevImplement a generic copy rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows copying a specified number of bits from a source header field to a destination header field. Tag, mark or metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value.
Outermost/innermost packet fields (and Tag array elements) are accessible via the index parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
v2: Added testpmd support.
Alexander Kozyrev (2):
ethdev: introduce generic copy rte flow action app/testpmd: add support for generic copy rte flow action
app/test-pmd/cmdline_flow.c | 156 +++++++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 35 +++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 +++++++++++ 4 files changed, 251 insertions(+)
Signature · 1 line
2.24.1
PATCH v2 1/2 ethdev: introduce generic copy rte flow action
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC: http://patches.dpdk.org/patch/85384/
--- doc/guides/prog_guide/rte_flow.rst | 35 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+)
doc/guides/prog_guide/rte_flow.rst +35 -0
@@ -2766,6 +2766,41 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. + +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
lib/librte_ethdev/rte_flow.c +1 -0
@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v2 2/2 app/testpmd: add support for generic copy rte flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_COPY_ITEM to the testpmd. Implement CLI to create the copy_item action and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another item.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions copy_item dst_type tag dst_index 0 dst_offset 8 src_type gtp_teid src_index 0 src_offset 0 width 32 / end
This flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
--- app/test-pmd/cmdline_flow.c | 156 ++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+)
app/test-pmd/cmdline_flow.c +156 -0
@@ -408,6 +408,16 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_COPY_ITEM , +ACTION_COPY_ITEM_DST_TYPE , +ACTION_COPY_ITEM_DST_TYPE_VALUE , +ACTION_COPY_ITEM_DST_INDEX , +ACTION_COPY_ITEM_DST_OFFSET , +ACTION_COPY_ITEM_SRC_TYPE , +ACTION_COPY_ITEM_SRC_TYPE_VALUE , +ACTION_COPY_ITEM_SRC_INDEX , +ACTION_COPY_ITEM_SRC_OFFSET , + ACTION_COPY_ITEM_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +571,18 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const copy_item_table[] = { +"none" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1328,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_COPY_ITEM , ZERO, };
@@ -1638,6 +1661,10 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_copy_item (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1749,8 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_copy_item (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4066,85 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_COPY_ITEM] = { + .name = "copy_item", + .help = "copy data from dst to src item", + .priv =PRIV_ACTION (COPY_ITEM , + sizeof(struct rte_flow_action_copy_item)), + .next = NEXT(NEXT_ENTRY(ACTION_COPY_ITEM_DST_TYPE)), + .call = parse_vc, + }, + [ACTION_COPY_ITEM_DST_TYPE] = { + .name = "dst_type", + .help = "destination item type", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_DST_INDEX ), + NEXT_ENTRY(ACTION_COPY_ITEM_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_DST_TYPE_VALUE] = { + .name = "{type}", + .help = "destination item type value", + .call = parse_vc_copy_item, + .comp = comp_set_copy_item, + }, + [ACTION_COPY_ITEM_DST_INDEX] = { + .name = "dst_index", + .help = "destination item index", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_DST_OFFSET ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + dst.index)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination item offset", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_SRC_TYPE ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_TYPE] = { + .name = "src_type", + .help = "source item type", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_SRC_INDEX ), + NEXT_ENTRY(ACTION_COPY_ITEM_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_TYPE_VALUE] = { + .name = "{type}", + .help = "source item type value", + .call = parse_vc_copy_item, + .comp = comp_set_copy_item, + }, + [ACTION_COPY_ITEM_SRC_INDEX] = { + .name = "src_index", + .help = "source item type index", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_SRC_OFFSET ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + src.index)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_OFFSET] = { + .name = "src_offset", + .help = "source item type offset", + .next =NEXT (NEXT_ENTRY (ACTION_COPY_ITEM_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6068,36 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for copy_item command. */ +static int +parse_vc_copy_item (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_copy_item *action_copy_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_COPY_ITEM_DST_TYPE_VALUE && + ctx->curr !=ACTION_COPY_ITEM_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; copy_item_table[i]; ++i) +if (!strcmp_partial (copy_item_table[i], str, len)) +break ; +if (!copy_item_table[i]) +return -1 ; +if (!ctx->object) +return len; + action_copy_item = ctx->object; +if (ctx->curr ==ACTION_COPY_ITEM_DST_TYPE_VALUE ) + action_copy_item->dst.item = i; +else + action_copy_item->src.item = i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7167,24 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete item type for copy_item command. */ +static int +comp_set_copy_item (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; copy_item_table[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, copy_item_table[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: add support for generic copy rte flow action
Hi Alexander,
Quoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Alexander Kozyrev
Subject: [dpdk-dev] [PATCH v2 2/2] app/testpmd: add support for generic copy rte flow actionAdd support for the
RTE_FLOW_ACTION_COPY_ITEMto the testpmd. Implement CLI to create thecopy_itemaction and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another item.
Quoted 5 lines
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actionscopy_itemdst_typetagdst_index0dst_offset8src_typegtp_teidsrc_index0src_offset0 width 32 / end
This is a long command, and for most cases holds to many extra values. I suggest to allow default values, meaning that the application must say the src and the dest fields but all the rest of the information can be extract from those two parameters (offset =0, len(field_type). If the user request he can add those parameters for more control.
Quoted 6 lines
This flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the
dst_offsetaction parameter.Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
v3 cover generic copy rte flow action support
In reply to Alexander KozyrevImplement a generic copy rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows copying a specified number of bits from a source header field to a destination header field. Tag, mark or metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3:
Made dst_type and src_type only mandatory parameters.
Alexander Kozyrev (2):
ethdev: introduce generic copy rte flow action app/testpmd: add support for generic copy rte flow action
app/test-pmd/cmdline_flow.c | 167 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 50 ++++++++ doc/guides/rel_notes/release_21_02.rst | 5 + lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 +++++++++ 5 files changed, 282 insertions(+)
Signature · 1 line
2.24.1
PATCH v3 1/2 ethdev: introduce generic copy rte flow action
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata/mark or directly copied from another packet field.
The item ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet
as needed.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or dividing a big packet field into multiple small items (let's say copying 128 bits of IPv6 to 4 tags).
RFC: http://patches.dpdk.org/patch/85384/
--- doc/guides/prog_guide/rte_flow.rst | 50 ++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 5 +++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++ 4 files changed, 115 insertions(+)
doc/guides/prog_guide/rte_flow.rst +50 -0
@@ -2766,6 +2766,56 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +``RTE_FLOW_ITEM_START`` is used to point to the beginning of a packet. +The copy is ignored in case the item specified is not present in a packet. + + ``level`` is used to access any packet field on any encapsulation level + as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can + mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet + encapsulation level, from outermost to innermost (lower to higher values). + For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from an item start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller items. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy an item to an +arbitrary place in a packet essentially providing a way to copy any part of +a packet to any other part of it if supported by a underlying PMD driver. + +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``item`` | item ID of a packet field or mark/metadata/tag | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning during the copy | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of copy action in the flow API.** + + Added copy action support to copy any arbitrary header field + (as well as mark, metadata or tag values) to another one: + ``RTE_FLOW_ACTION_TYPE_COPY_ITEM``. Removed Items -------------
lib/librte_ethdev/rte_flow.c +1 -0
@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.24.1
Hi Alexander,
Quoted 185 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, January 13, 2021 5:39 AM
Subject: [PATCH v3 1/2] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata/mark or directly copied from another packet field.
The item ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (
ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet
as needed.The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or dividing a big packet field into multiple small items (let's say copying 128 bits of IPv6 to 4 tags).
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com% 7C57d1832b57bf4d6852e808d8b774c4b9%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637461059443472688%7CUnknown%7CTWFpbGZsb3d8eyJ WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C 1000&sdata=7g5wYtlhsN9z2m%2FGMMMGt6rV2bx2z6oFLW1pzGJVGqA%3 D&reserved=0Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 50 ++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 5 +++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++ 4 files changed, 115 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2766,6 +2766,56 @@ The behaviour of the shared action defined by``action`` argument of type
| no properties | +---------------+doc/guides/prog_guide/rte_flow.rst +46
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. +``RTE_FLOW_ITEM_START`` is used to point to the beginning of a packet. +The copy is ignored in case the item specified is not present in a packet. + + ``level`` is used to access any packet field on any encapsulation level + as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can + mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet + encapsulation level, from outermost to innermost (lower to higher values). + For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from an item start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller items. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy an item to an +arbitrary place in a packet essentially providing a way to copy any part of +a packet to any other part of it if supported by a underlying PMD driver. + +.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+
doc/guides/prog_guide/rte_flow.rst +5
-0+ | ``item`` | item ID of a packet field or mark/metadata/tag | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning during the copy | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~doc/guides/rel_notes/release_21_02.rst +5
-0@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of copy action in the flow API.** + + Added copy action support to copy any arbitrary header field + (as well as mark, metadata or tag values) to another one: + ``RTE_FLOW_ACTION_TYPE_COPY_ITEM``. Removed Items -------------lib/librte_ethdev/rte_flow.c +1
-0@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)), MK_FLOW_ACTION(SAMPLE, sizeof(struct rte_flow_action_sample)), +MK_FLOW_ACTION (COPY_ITEM ,sizeof (struct rte_flow_action_copy_item)),lib/librte_ethdev/rte_flow.c +0
-0/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see lib/librte_ethdev/rte_flow.h +29
-0@@ -2198,6 +2198,16 @@ enum rte_flow_action_type {* struct rte_flow_shared_action). */ RTE_FLOW_ACTION_TYPE_SHARED , + +/** +* Copy a packet header field, tag, mark or metadata. +* +* Allow saving an arbitrary header field by copying its value +* to a tag/mark/metadata or copy it into another header field. +* +* See struct rte_flow_action_copy_item. +*/ + RTE_FLOW_ACTION_TYPE_COPY_ITEM, };/** @@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +enum rte_flow_item_id { +RTE_FLOW_ITEM_START =0 , +RTE_FLOW_ITEM_MAC_DST , +RTE_FLOW_ITEM_MAC_SRC , +RTE_FLOW_ITEM_VLAN_TYPE , +RTE_FLOW_ITEM_VLAN_ID , +RTE_FLOW_ITEM_MAC_TYPE , +RTE_FLOW_ITEM_IPV4_DSCP , +RTE_FLOW_ITEM_IPV4_TTL , +RTE_FLOW_ITEM_IPV4_SRC , +RTE_FLOW_ITEM_IPV4_DST , +RTE_FLOW_ITEM_IPV6_HOPLIMIT , +RTE_FLOW_ITEM_IPV6_SRC , +RTE_FLOW_ITEM_IPV6_DST , +RTE_FLOW_ITEM_TCP_PORT_SRC , +RTE_FLOW_ITEM_TCP_PORT_DST , +RTE_FLOW_ITEM_TCP_SEQ_NUM , +RTE_FLOW_ITEM_TCP_ACK_NUM , +RTE_FLOW_ITEM_TCP_FLAGS ,
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2832
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_ITEM_UDP_PORT_SRC , +RTE_FLOW_ITEM_UDP_PORT_DST , +RTE_FLOW_ITEM_VXLAN_VNI , +RTE_FLOW_ITEM_GENEVE_VNI , +RTE_FLOW_ITEM_GTP_TEID , +RTE_FLOW_ITEM_TAG , +RTE_FLOW_ITEM_MARK , + RTE_FLOW_ITEM_META, +}; +
Please change the names, RTE_FLOW_ITEM_XXX means that it can be used as rte_flow item this is not the case here. Maybe RTE_FLOW_FIELD_XXX?
Quoted 25 lines
lib/librte_ethdev/rte_flow.h +20
-1+struct rte_flow_action_copy_data { +enum rte_flow_item_id item; +uint32_t level; +uint32_t offset; +}; + +/** +* RTE_FLOW_ACTION_TYPE_COPY_ITEM +* +* Copies a specified number of bits from a source header field +* to a destination header field. Tag, mark or metadata can also +* be used as a source/destination to allow saving/overwriting +* an arbitrary header field with a user-specified value. +*/ +struct rte_flow_action_copy_item { +struct rte_flow_action_copy_data dst; +struct rte_flow_action_copy_data src; +uint32_t width; +}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --2.24.1
PATCH v3 2/2 app/testpmd: add support for generic copy rte flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_COPY_ITEM to the testpmd. Implement CLI to create the copy_item action and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another item.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions copy_item dst_type tag dst_level 0 dst_offset 8 src_type gtp_teid src_level 0 src_offset 0 width 32 / end
This flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
dst_type and src_type are the only mandatory parameters to specify. Levels and offset are 0 by default if they are not overriden by a user. The width parameter gets the smallest width from the source and destination sizes if it is not specified.
--- app/test-pmd/cmdline_flow.c | 167 ++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+)
app/test-pmd/cmdline_flow.c +167 -0
@@ -408,6 +408,16 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_COPY_ITEM , +ACTION_COPY_ITEM_DST_TYPE , +ACTION_COPY_ITEM_DST_TYPE_VALUE , +ACTION_COPY_ITEM_DST_LEVEL , +ACTION_COPY_ITEM_DST_OFFSET , +ACTION_COPY_ITEM_SRC_TYPE , +ACTION_COPY_ITEM_SRC_TYPE_VALUE , +ACTION_COPY_ITEM_SRC_LEVEL , +ACTION_COPY_ITEM_SRC_OFFSET , + ACTION_COPY_ITEM_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +571,18 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const copy_item_table[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1328,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_COPY_ITEM , ZERO, };
@@ -1556,6 +1579,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_copy_item_dst[] = { +ACTION_COPY_ITEM_DST_LEVEL , +ACTION_COPY_ITEM_DST_OFFSET , +ACTION_COPY_ITEM_SRC_TYPE , +ZERO , +}; + +static const enum index action_copy_item_src[] = { +ACTION_COPY_ITEM_SRC_LEVEL , +ACTION_COPY_ITEM_SRC_OFFSET , +ACTION_COPY_ITEM_WIDTH , +ACTION_NEXT , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1676,10 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_copy_item (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1764,8 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_copy_item (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4081,81 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_COPY_ITEM] = { + .name = "copy_item", + .help = "copy data from destination to source item", + .priv =PRIV_ACTION (COPY_ITEM , + sizeof(struct rte_flow_action_copy_item)), + .next = NEXT(NEXT_ENTRY(ACTION_COPY_ITEM_DST_TYPE)), + .call = parse_vc, + }, + [ACTION_COPY_ITEM_DST_TYPE] = { + .name = "dst_type", + .help = "destination item type", + .next =NEXT (action_copy_item_dst, + NEXT_ENTRY(ACTION_COPY_ITEM_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_DST_TYPE_VALUE] = { + .name = "{type}", + .help = "destination item type value", + .call = parse_vc_copy_item, + .comp = comp_set_copy_item, + }, + [ACTION_COPY_ITEM_DST_LEVEL] = { + .name = "dst_level", + .help = "destination item level", + .next = NEXT(action_copy_item_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination item bit offset", + .next = NEXT(action_copy_item_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_TYPE] = { + .name = "src_type", + .help = "source item type", + .next =NEXT (action_copy_item_src, + NEXT_ENTRY(ACTION_COPY_ITEM_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_TYPE_VALUE] = { + .name = "{type}", + .help = "source item type value", + .call = parse_vc_copy_item, + .comp = comp_set_copy_item, + }, + [ACTION_COPY_ITEM_SRC_LEVEL] = { + .name = "src_level", + .help = "source item level", + .next = NEXT(action_copy_item_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_SRC_OFFSET] = { + .name = "src_offset", + .help = "source item bit offset", + .next = NEXT(action_copy_item_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_ITEM_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_item, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6079,36 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for copy_item command. */ +static int +parse_vc_copy_item (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_copy_item *action_copy_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_COPY_ITEM_DST_TYPE_VALUE && + ctx->curr !=ACTION_COPY_ITEM_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; copy_item_table[i]; ++i) +if (!strcmp_partial (copy_item_table[i], str, len)) +break ; +if (!copy_item_table[i]) +return -1 ; +if (!ctx->object) +return len; + action_copy_item = ctx->object; +if (ctx->curr ==ACTION_COPY_ITEM_DST_TYPE_VALUE ) + action_copy_item->dst.item = (enum rte_flow_item_id )i; +else + action_copy_item->src.item = (enum rte_flow_item_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7178,24 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete item type for copy_item command. */ +static int +comp_set_copy_item (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; copy_item_table[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, copy_item_table[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
v4 cover generic copy rte flow action support
In reply to Alexander KozyrevImplement a generic copy rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows copying a specified number of bits from a source header field to a destination header field. Tag, mark or metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters. v4:
Renamed action to TE_FLOW_ACTION_TYPE_COPY_FIELD.
Alexander Kozyrev (2):
ethdev: introduce generic copy rte flow action app/testpmd: add support for generic copy rte flow action
app/test-pmd/cmdline_flow.c | 166 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 57 +++++++++ doc/guides/rel_notes/release_21_02.rst | 5 + lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 +++++++++ 5 files changed, 288 insertions(+)
Signature · 1 line
2.24.1
PATCH v4 1/2 ethdev: introduce generic copy rte flow action
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another field.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata/mark or directly copied from another packet field.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet
as needed.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or dividing a big packet field into multiple small fields (let's say copying 128 bits of IPv6 to 4 tags).
RFC: http://patches.dpdk.org/patch/85384/
--- doc/guides/prog_guide/rte_flow.rst | 57 +++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 5 +++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++ 4 files changed, 122 insertions(+)
doc/guides/prog_guide/rte_flow.rst +57 -0
@@ -2766,6 +2766,63 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``COPY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` field to ``dst`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. +The copy is ignored in case the field specified is not present in a packet. + + ``width`` defines a number of bits to copy. A user is responsible for + supplying the appropriate length to copy. The width that exceeds the + hardware capabilities is rejected. + + ``level`` is used to access any packet field on any encapsulation level + as well as any tag element in the tag array. + +- ``0`` means the default behaviour. Depending on the packet type, it can + mean outermost, innermost or anything in between. + +- ``1`` requests access to the outermost packet encapsulation level. + +- ``2`` and subsequent values requests access to the specified packet + encapsulation level, from outermost to innermost (lower to higher values). + For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from an field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy an field to an +arbitrary place in a packet essentially providing a way to copy any part of +a packet to any other part of it if supported by a underlying PMD driver. + +.. _table_rte_flow_action_copy_field: + +.. table:: COPY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to copy | + +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | field ID of a packet field or mark/metadata/tag | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning during the copy | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of copy action in the flow API.** + + Added copy action support to copy any arbitrary header field + (as well as mark, metadata or tag values) to another one: + ``RTE_FLOW_ACTION_TYPE_COPY_FIELD``. Removed Items -------------
lib/librte_ethdev/rte_flow.c +1 -0
@@ -176,6 +176,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (COPY_FIELD ,sizeof (struct rte_flow_action_copy_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.24.1
Hi Alexander,
Quoted 36 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, January 13, 2021 7:08 PM
Subject: [PATCH v4 1/2] ethdev: introduce generic copy rte flow actionImplement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another field.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata/mark or directly copied from another packet field.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (
ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet
as needed.The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or dividing a big packet field into multiple small fields (let's say copying 128 bits of IPv6 to 4 tags).
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com% 7C17fcc82431974e7e56f108d8b7e5c877%7C43083d15727340c1b7db39efd9ccc 17a%7C0%7C0%7C637461544825998974%7CUnknown%7CTWFpbGZsb3d8eyJW IjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C10 00&sdata=kTd45BEYhWsYtRuB9r5Y%2BTwa88wnkKgwUhWFFIutcvc%3D& amp;reserved=0
Quoted 8 lines
Signed-off-by Alexander Kozyrev <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 57 +++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 5 +++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++ 4 files changed, 122 insertions(+)
Thanks,
Ori
PATCH v4 2/2 app/testpmd: add support for generic copy rte flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_COPY_FIELD to the testpmd. Implement CLI to create the copy_field action and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another field.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions copy_field dst_type tag dst_level 0 dst_offset 8 src_type gtp_teid src_level 0 src_offset 0 width 32 / end
This flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
dst_type and src_type are the only mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The width parameter gets the smallest width from the source and destination sizes if it is not specified.
--- app/test-pmd/cmdline_flow.c | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+)
app/test-pmd/cmdline_flow.c +166 -0
@@ -408,6 +408,16 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_COPY_FIELD , +ACTION_COPY_FIELD_DST_TYPE , +ACTION_COPY_FIELD_DST_TYPE_VALUE , +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE , +ACTION_COPY_FIELD_SRC_TYPE_VALUE , +ACTION_COPY_FIELD_SRC_LEVEL , +ACTION_COPY_FIELD_SRC_OFFSET , + ACTION_COPY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +571,18 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const copy_field_table[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1328,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_COPY_FIELD , ZERO, };
@@ -1556,6 +1579,20 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_copy_field_dst[] = { +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_copy_field_src[] = { +ACTION_COPY_FIELD_SRC_LEVEL , +ACTION_COPY_FIELD_SRC_OFFSET , +ACTION_COPY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1675,10 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1763,8 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_copy_field (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4080,81 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_COPY_FIELD] = { + .name = "copy_field", + .help = "copy data from destination field to source field", + .priv =PRIV_ACTION (COPY_FIELD , + sizeof(struct rte_flow_action_copy_field)), + .next = NEXT(NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE)), + .call = parse_vc, + }, + [ACTION_COPY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_copy_field_dst, + NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_DST_TYPE_VALUE] = { + .name = "{type}", + .help = "destination field type value", + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_copy_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_copy_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_copy_field_src, + NEXT_ENTRY(ACTION_COPY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_TYPE_VALUE] = { + .name = "{type}", + .help = "source field type value", + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_copy_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_copy_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6078,36 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for copy_field command. */ +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_copy_field *action_copy_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_COPY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_COPY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; copy_field_table[i]; ++i) +if (!strcmp_partial (copy_field_table[i], str, len)) +break ; +if (!copy_field_table[i]) +return -1 ; +if (!ctx->object) +return len; + action_copy_field = ctx->object; +if (ctx->curr ==ACTION_COPY_FIELD_DST_TYPE_VALUE ) + action_copy_field->dst.field = (enum rte_flow_field_id )i; +else + action_copy_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7177,24 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete field type for copy_field command. */ +static int +comp_set_copy_field (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; copy_field_table[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, copy_field_table[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: add support for generic copy rte flow action
Hi
Quoted 90 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, January 13, 2021 7:08 PM
Subject: [PATCH v4 2/2] app/testpmd: add support for generic copy rte flow actionAdd support for the
RTE_FLOW_ACTION_COPY_FIELDto the testpmd. Implement CLI to create thecopy_fieldaction and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another field.Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actionscopy_fielddst_typetagdst_level0dst_offset8src_typegtp_teidsrc_level0src_offset0 width 32 / endThis flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the
dst_offsetaction parameter.
dst_typeandsrc_typeare the only mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The width parameter gets the smallest width from the source and destination sizes if it is not specified.Signed-off-by Alexander Kozyrev <[email protected]>--- app/test-pmd/cmdline_flow.c | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+)app/test-pmd/cmdline_flow.c +22
-0@@ -408,6 +408,16 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_COPY_FIELD , +ACTION_COPY_FIELD_DST_TYPE , +ACTION_COPY_FIELD_DST_TYPE_VALUE , +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE , +ACTION_COPY_FIELD_SRC_TYPE_VALUE , +ACTION_COPY_FIELD_SRC_LEVEL , +ACTION_COPY_FIELD_SRC_OFFSET , + ACTION_COPY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -561,6 +571,18 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const copy_field_table[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define
CTX_STACK_SIZE16app/test-pmd/cmdline_flow.c +5
-0@@ -1306,6 +1328,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_COPY_FIELD , ZERO, };@@ -1556,6 +1579,20 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_copy_field_dst[] = { +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE ,
app/test-pmd/cmdline_flow.c static const enum index next_action_sample[] = { · line 1595
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ ZERO, +}; + +static const enum index action_copy_field_src[] = { +ACTION_COPY_FIELD_SRC_LEVEL , +ACTION_COPY_FIELD_SRC_OFFSET , +ACTION_COPY_FIELD_WIDTH , +ZERO , +}; +
I think if we remove the order of actions then it is possible to use the same struct both for the src and the dst. What do you think? (see my comment below)
Quoted 25 lines
app/test-pmd/cmdline_flow.c +6
-0static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );@@ -1638,6 +1675,10 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );@@ -1722,6 +1763,8 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_copy_field (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4089
Quoted 10 lines
app/test-pmd/cmdline_flow.c +7
-0@@ -4037,6 +4080,81 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_COPY_FIELD] = { + .name = "copy_field", + .help = "copy data from destination field to source field", + .priv =PRIV_ACTION (COPY_FIELD , + sizeof(struct rte_flow_action_copy_field)), + .next = NEXT(NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE)), + .call = parse_vc,
You are forcing that the first parameter will be the source, what do you think about removing this limitation?
Quoted 138 lines
app/test-pmd/cmdline_flow.c +68
-0+ }, + [ACTION_COPY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_copy_field_dst, + NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_DST_TYPE_VALUE] = { + .name = "{type}", + .help = "destination field type value", + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_copy_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_copy_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_copy_field_src, + NEXT_ENTRY(ACTION_COPY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_TYPE_VALUE] = { + .name = "{type}", + .help = "source field type value", + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_copy_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_copy_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_copy_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ app/test-pmd/cmdline_flow.c +30
-0[SET] = { .name = "set",@@ -5960,6 +6078,36 @@ parse_vc_action_sample_index(struct context *ctx,const struct token *token, return len; } +/** Parse tokens for copy_field command. */ +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_copy_field *action_copy_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_COPY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_COPY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; copy_field_table[i]; ++i) +if (!strcmp_partial (copy_field_table[i], str, len)) +break ; +if (!copy_field_table[i]) +return -1 ; +if (!ctx->object) +return len; + action_copy_field = ctx->object; +if (ctx->curr ==ACTION_COPY_FIELD_DST_TYPE_VALUE ) + action_copy_field->dst.field = (enum rte_flow_field_id )i; +else + action_copy_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static intparse_destroy(struct context *ctx, const struct token *token,
app/test-pmd/cmdline_flow.c +18
-1@@ -7029,6 +7177,24 @@ comp_set_sample_index(struct context *ctx, conststruct token *token, return nb; } +/** Complete field type for copy_field command. */ +static int +comp_set_copy_field (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; copy_field_table[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, copy_field_table[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context; --
Quoted 1 line
2.24.1
Best,
Ori
Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: add support for generic copy rte flow action
Quoted 104 lines
From: Ori Kam <[email protected]> on Thursday, January 14, 2021 10:19
Subject: RE: [PATCH v4 2/2] app/testpmd: add support for generic copy rte flow actionHi
Quoted 4 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, January 13, 2021 7:08 PM
Subject: [PATCH v4 2/2] app/testpmd: add support for generic copy rteflow
Quoted 67 lines
action
Add support for the
RTE_FLOW_ACTION_COPY_FIELDto the testpmd. Implement CLI to create thecopy_fieldaction and supply all the needed parameters to copy an arbitrary packet field (as well as mark, tag or metadata) into another field.Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actionscopy_fielddst_typetagdst_level0dst_offset8src_typegtp_teidsrc_level0src_offset0 width 32 / endThis flow copies 32 bits from the first Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the
dst_offsetaction parameter.
dst_typeandsrc_typeare the only mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The width parameter gets the smallest width from the source and destination sizes if it is not specified.Signed-off-by Alexander Kozyrev <[email protected]>--- app/test-pmd/cmdline_flow.c | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+)app/test-pmd/cmdline_flow.c +22
-0@@ -408,6 +408,16 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_COPY_FIELD , +ACTION_COPY_FIELD_DST_TYPE , +ACTION_COPY_FIELD_DST_TYPE_VALUE , +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE , +ACTION_COPY_FIELD_SRC_TYPE_VALUE , +ACTION_COPY_FIELD_SRC_LEVEL , +ACTION_COPY_FIELD_SRC_OFFSET , + ACTION_COPY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -561,6 +571,18 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const copy_field_table[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,NULL +}; +Quoted 1 line
/** Maximum number of subsequent tokens and arguments on the stack.
*/
app/test-pmd/cmdline_flow.c static const enum index next_action_sample[] =
Quoted 11 lines
#define
CTX_STACK_SIZE16app/test-pmd/cmdline_flow.c +1
-0@@ -1306,6 +1328,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_COPY_FIELD , ZERO, };@@ -1556,6 +1579,20 @@ static const enum index next_action_sample[] ={
Quoted 12 lines
app/test-pmd/cmdline_flow.c +9
-0ZERO, }; +static const enum index action_copy_field_dst[] = { +ACTION_COPY_FIELD_DST_LEVEL , +ACTION_COPY_FIELD_DST_OFFSET , +ACTION_COPY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_copy_field_src[] = { +ACTION_COPY_FIELD_SRC_LEVEL ,
Quoted 8 lines
app/test-pmd/cmdline_flow.c static const enum index next_action_sample[] = { · line 1595
Quoted 5 lines
app/test-pmd/cmdline_flow.c +5
-0+ACTION_COPY_FIELD_SRC_OFFSET , +ACTION_COPY_FIELD_WIDTH , + ZERO, +}; +I think if we remove the order of actions then it is possible to use the same struct
both for the src and the dst. What do you think? (see my comment below)
This is done intentionally so user can get away without specifying all the mandatory parameters. That saves us a trouble to validate if they are present or not later.
Quoted 37 lines
app/test-pmd/cmdline_flow.c static const enum index next_action_sample[] = · line 1596
Quoted 1 line
app/test-pmd/cmdline_flow.c +0
-0static int parse_set_raw_encap_decap(struct context *, const struct token*,
app/test-pmd/cmdline_flow.c static int · line 1675
Quoted 4 lines
app/test-pmd/cmdline_flow.c +0
-0const char *, unsigned int, void *, unsigned int);@@ -1638,6 +1675,10 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token*token,
Quoted 20 lines
app/test-pmd/cmdline_flow.c +6
-0const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );@@ -1722,6 +1763,8 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_copy_field (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4088
Quoted 9 lines
app/test-pmd/cmdline_flow.c +6
-0@@ -4037,6 +4080,81 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_COPY_FIELD] = { + .name = "copy_field", + .help = "copy data from destination field to source field", + .priv =PRIV_ACTION (COPY_FIELD , + sizeof(struct rte_flow_action_copy_field)), + .next =NEXT(NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE)),
Quoted 5 lines
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4089
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+ .call = parse_vc,You are forcing that the first parameter will be the source, what do you think about
removing this limitation?
I'm forcing the first parameter to be the destination, then the source, then the width. This way I can be sure that all of them are specified when the flow is created.
Quoted 156 lines
Quoted 10 lines
app/test-pmd/cmdline_flow.c +8
-0+ }, + [ACTION_COPY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_copy_field_dst, + NEXT_ENTRY(ACTION_COPY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + },app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ [ACTION_COPY_FIELD_DST_TYPE_VALUE ] = { + .name ="{type}" , + .help ="destination field type value" , + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_DST_LEVEL ] = { + .name ="dst_level" , + .help ="destination field level" , + .next = NEXT(action_copy_field_dst,
NEXT_ENTRY(UNSIGNED)),app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4109
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+ .args = ARGS(ARGS_ENTRY(struct
rte_flow_action_copy_field,app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 7 lines
app/test-pmd/cmdline_flow.c +7
-0+ dst.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_copy_field_dst,
NEXT_ENTRY(UNSIGNED)),app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4117
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+ .args = ARGS(ARGS_ENTRY(struct
rte_flow_action_copy_field,Quoted 11 lines
app/test-pmd/cmdline_flow.c +10
-0+ dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_copy_field_src, + NEXT_ENTRY(ACTION_COPY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + },app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ [ACTION_COPY_FIELD_SRC_TYPE_VALUE ] = { + .name ="{type}" , + .help ="source field type value" , + .call = parse_vc_copy_field, + .comp = comp_set_copy_field, + }, + [ACTION_COPY_FIELD_SRC_LEVEL ] = { + .name ="src_level" , + .help ="source field level" , + .next = NEXT(action_copy_field_src,
NEXT_ENTRY(UNSIGNED)),app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4139
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+ .args = ARGS(ARGS_ENTRY(struct
rte_flow_action_copy_field,app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 7 lines
app/test-pmd/cmdline_flow.c +7
-0+ src.level)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_copy_field_src,
NEXT_ENTRY(UNSIGNED)),app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4147
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+ .args = ARGS(ARGS_ENTRY(struct
rte_flow_action_copy_field,app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 9 lines
app/test-pmd/cmdline_flow.c +9
-0+ src.offset)), + .call = parse_vc_conf, + }, + [ACTION_COPY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct
rte_flow_action_copy_field,app/test-pmd/cmdline_flow.c parse_vc_action_sample_index(struct context
Quoted 7 lines
app/test-pmd/cmdline_flow.c +3
-0+ width)), + .call = parse_vc_conf, + },/* Top level command. */ app/test-pmd/cmdline_flow.c +0
-0[SET] = { .name = "set",@@ -5960,6 +6078,36 @@ parse_vc_action_sample_index(struct context*ctx,
app/test-pmd/cmdline_flow.c comp_set_sample_index(struct context *ctx,
Quoted 38 lines
app/test-pmd/cmdline_flow.c +30
-0const struct token *token, return len; } +/** Parse tokens for copy_field command. */ +static int +parse_vc_copy_field (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_copy_field *action_copy_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_COPY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_COPY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; copy_field_table[i]; ++i) +if (!strcmp_partial (copy_field_table[i], str, len)) +break ; +if (!copy_field_table[i]) +return -1 ; +if (!ctx->object) +return len; + action_copy_field = ctx->object; +if (ctx->curr ==ACTION_COPY_FIELD_DST_TYPE_VALUE ) + action_copy_field->dst.field = (enum rte_flow_field_id )i; +else + action_copy_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static intparse_destroy(struct context *ctx, const struct token *token,
app/test-pmd/cmdline_flow.c +0
-0@@ -7029,6 +7177,24 @@ comp_set_sample_index(struct context *ctx,const
Quoted 26 lines
app/test-pmd/cmdline_flow.c +18
-1struct token *token, return nb; } +/** Complete field type for copy_field command. */ +static int +comp_set_copy_field (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; copy_field_table[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, copy_field_table[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context; --Quoted 1 line
2.24.1
Acked-by Ori Kam <[email protected]>Best,
Ori
v5 cover generic modify rte flow action support
In reply to Alexander KozyrevImplement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows modifying a destination header field with data from a source header field. Number of bits to use from source is specified. Tag, mark or metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action to RTE_FLOW_ACTION_TYPE_COPY_FIELD. v5:
Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 65 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++- 5 files changed, 399 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
PATCH v5 1/2 ethdev: introduce generic modify rte flow action
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified packet field/tag/metadata/mark/memory location or directly provided by a user.
Supported operation are:
- mov: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.
The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
An immediate value (or pointer to it) can be specified instead of the level and the offset for the special FIELD_VALUE ID (or FIELD_POINTER). Can be used as a source only, in case of user-provided values.
RFC: http://patches.dpdk.org/patch/85384/
---
v1: Initialy RTE_FLOW_ACTION_TYPE_COPY_ITEM
v2: Renamed to RTE_FLOW_ACTION_TYPE_COPY_FIELD
v3: Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
--- doc/guides/prog_guide/rte_flow.rst | 65 +++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 8 +++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++++++++++++++++++++- 4 files changed, 153 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +65 -0
@@ -2766,6 +2766,71 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (move, addition, +substraction) with ``width`` bits of data from ``src`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``mov`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` substracts ``src`` from ``dst`` and stores the result into ``dst`` + + ``width`` defines a number of bits to use from ``src`` field. + + ``level`` is used to access any packet field on any encapsulation level + as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can + mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet + encapsulation level, from outermost to innermost (lower to higher values). + For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it if supported by an underlying PMD driver. + +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a poiner to it | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of modify field action in the flow API.** + + Added modify action support to perform various operations on + any arbitrary header field (as well as mark, metadata or tag values): + ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD``. + supported operations are: overwriting the field with the content from + another field, addition and subtraction of an immediate value. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with fixes and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -176,6 +176,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (MODIFY_FIELD , +sizeof (struct rte_flow_action_modify_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +78 -1
97 lines not on this page · raw message
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic modify rte flow action
Hi Alexander,
Small inline, but I leave it to you if you want to change it.
Quoted 5 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 15, 2021 5:43 PM
Subject: [PATCH v5 1/2] ethdev: introduce generic modify rte flow action
Quoted 9 lines
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified packet field/tag/metadata/mark/memory location or directly
provided by a user.
Quoted 1 line
[Snip]
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2852
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+ +enum rte_flow_modify_op { +RTE_FLOW_MODIFY_MOV =0 , +RTE_FLOW_MODIFY_ADD , +RTE_FLOW_MODIFY_SUB , +}; +
I think mov is not the best option, since we the value in src stays I think copy or set will be better.
If you change it feel free to add my ack.
Quoted 22 lines
lib/librte_ethdev/rte_flow.h +18
-1+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* +* Modifies a destination header field according to the specified +* operation. Another packet field can be used as a source as well +* as tag, mark, metadata or an immediate value or a pointer to it. +* Width is the number of bits used from the source item. +*/ +struct rte_flow_action_modify_field { +enum rte_flow_modify_op operation; +struct rte_flow_action_modify_data dst; +struct rte_flow_action_modify_data src; +uint32_t width; +}; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; --
Quoted 1 line
2.24.1
Best,
Ori
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic modify rte flow action
Quoted 33 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Friday, January 15, 2021 20:04
To: Alexander Kozyrev <[email protected]>; [email protected]
Cc: Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v5 1/2] ethdev: introduce generic modify rte flow actionHi Alexander,
Small inline, but I leave it to you if you want to change it.
Quoted 6 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 15, 2021 5:43 PM
Subject: [PATCH v5 1/2] ethdev: introduce generic modify rte flow actionQuoted 9 lines
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified packet field/tag/metadata/mark/memory location or directly
provided by a user.
Quoted 1 line
[Snip]
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2852
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+ +enum rte_flow_modify_op { +RTE_FLOW_MODIFY_MOV =0 , +RTE_FLOW_MODIFY_ADD , +RTE_FLOW_MODIFY_SUB , +}; +I think mov is not the best option, since we the value in src stays I think copy or set will be better.
If you change it feel free to add my ack.
MOV is quite common usage (in Assembly) to specify exactly the operation we are going to introduce.
And we are going to assign the destination both from field and some immediate value provided. So, MOV in my opinion would be more relevant than COPY.
With best regards,
Slava
Quoted 28 lines
Quoted 22 lines
lib/librte_ethdev/rte_flow.h +18
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* +* Modifies a destination header field according to the specified +* operation. Another packet field can be used as a source as well +* as tag, mark, metadata or an immediate value or a pointer to it. +* Width is the number of bits used from the source item. +*/ +struct rte_flow_action_modify_field { +enum rte_flow_modify_op operation; +struct rte_flow_action_modify_data dst; +struct rte_flow_action_modify_data src; +uint32_t width; +}; + /* Mbuf dynamic field offset for metadata. */ extern int32_t
rte_flow_dynf_metadata_offs;Quoted 2 lines
--
2.24.1Acked-by Ori Kam <[email protected]>Best,
Ori
PATCH v5 2/2 app/testpmd: add support for modify field flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_MODIFY_FIELD to the testpmd. Implement CLI to create the modify_field action and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions modify_field op mov dst_type tag dst_level 2 dst_offset 8
src_type gtp_teid src_level 0 src_offset 0 width 16 / end
This flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
op, dst_type, src_type and width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be mov, add or sub.
---
v1: Initial implementation.
v2: Made dst_type, src_type and width only mandatory parameters.
v3: Reworked to accomodate API change from copy_field to modify_field.
--- app/test-pmd/cmdline_flow.c | 246 ++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
app/test-pmd/cmdline_flow.c +246 -0
@@ -408,6 +408,19 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_MODIFY_FIELD , +ACTION_MODIFY_FIELD_OP , +ACTION_MODIFY_FIELD_OP_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE , +ACTION_MODIFY_FIELD_DST_TYPE_VALUE , +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ACTION_MODIFY_FIELD_SRC_TYPE_VALUE , +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , + ACTION_MODIFY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +574,22 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const modify_field_ops[] = { +"mov" ,"add" ,"sub" ,NULL +}; + +static const char *const modify_field_ids[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,"value" ,"pointer" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1335,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_MODIFY_FIELD , ZERO, };
@@ -1556,6 +1586,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_modify_field_dst[] = { +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_modify_field_src[] = { +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , +ACTION_MODIFY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1683,14 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1775,10 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_op (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4094,103 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_MODIFY_FIELD] = { + .name = "modify_field", + .help = "modify destination field with data from source field", + .priv =PRIV_ACTION (MODIFY_FIELD , + sizeof(struct rte_flow_action_modify_field)), + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), + .call = parse_vc, + }, + [ACTION_MODIFY_FIELD_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_DST_TYPE ), + NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_modify_field_op, + .comp = comp_set_modify_field_op, + }, + [ACTION_MODIFY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = { + .name = "{dst_type}", + .help = "destination field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = { + .name = "{src_type}", + .help = "source field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_VALUE] = { + .name = "src_value", + .help = "source immediate value", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.value)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6114,62 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse operation for modify_field command. */ +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_OP_VALUE ) +return -1 ; +for (i =0 ; modify_field_ops[i]; ++i) +if (!strcmp_partial (modify_field_ops[i], str, len)) +break ; +if (!modify_field_ops[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; + action_modify_field->operation = (enum rte_flow_modify_op )i; +return len; +} + +/** Parse id for modify_field command. */ +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; modify_field_ids[i]; ++i) +if (!strcmp_partial (modify_field_ids[i], str, len)) +break ; +if (!modify_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; +if (ctx->curr ==ACTION_MODIFY_FIELD_DST_TYPE_VALUE ) + action_modify_field->dst.field = (enum rte_flow_field_id )i; +else + action_modify_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7239,42 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete operation for modify_field command. */ +static int +comp_set_modify_field_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ops[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ops[ent], size); +return -1 ; +} + +/** Complete field id for modify_field command. */ +static int +comp_set_modify_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ids[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ids[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v5 2/2] app/testpmd: add support for modify field flow action
Quoted 26 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Friday, January 15, 2021 5:43 PM
Subject: [PATCH v5 2/2] app/testpmd: add support for modify field flow actionAdd support for the
RTE_FLOW_ACTION_MODIFY_FIELDto the testpmd. Implement CLI to create themodify_fieldaction and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actionsmodify_fieldop movdst_typetagdst_level2dst_offset8
src_typegtp_teidsrc_level0src_offset0 width 16 / endThis flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the
dst_offsetaction parameter.op,
dst_type,src_typeand width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be mov, add or sub.
Quoted 7 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
v1: Initial implementation.
v2: Madedst_type,src_typeand width only mandatory parameters.
v3: Reworked to accomodate API change fromcopy_fieldtomodify_field.
---
Thanks,
Ori
v6 cover generic modify rte flow action support
In reply to Alexander KozyrevImplement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action to RTE_FLOW_ACTION_TYPE_COPY_FIELD. v5:
Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. v6:
Fixed typos in documentation.
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 65 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++- 5 files changed, 399 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
PATCH v6 1/2 ethdev: introduce generic modify rte flow action
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.
Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.
The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
An immediate value (or pointer to it) can be specified instead of the level and the offset for the special FIELD_VALUE ID (or FIELD_POINTER). Can be used as a source only, in case of user-provided values.
RFC: http://patches.dpdk.org/patch/85384/
---
v1: Initialy RTE_FLOW_ACTION_TYPE_COPY_ITEM
v2: Renamed to RTE_FLOW_ACTION_TYPE_COPY_FIELD
v3: Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
v4: Fixed typos in documentation, renamed mov operation to set.
--- doc/guides/prog_guide/rte_flow.rst | 65 +++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 8 +++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++++++++++++++++++++- 4 files changed, 153 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +65 -0
@@ -2766,6 +2766,71 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (move, addition, +substraction) with ``width`` bits of data from ``src`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` substracts ``src`` from ``dst`` and stores the result into ``dst`` + +``width`` defines a number of bits to use from ``src`` field. + +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet +encapsulation level, from outermost to innermost (lower to higher values). +For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it if supported by an underlying PMD driver. + +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a poiner to it | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of modify field action in the flow API.** + + Added modify action support to perform various operations on + any arbitrary header field (as well as mark, metadata or tag values): + ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD``. + supported operations are: overwriting a field with the content from + another field, addition and subtraction using an immediate value. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with fixes and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -176,6 +176,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (MODIFY_FIELD , +sizeof (struct rte_flow_action_modify_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +78 -1
97 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v6 2/2 app/testpmd: add support for modify field flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_MODIFY_FIELD to the testpmd. Implement CLI to create the modify_field action and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions modify_field op set dst_type tag dst_level 2 dst_offset 8
src_type gtp_teid src_level 0 src_offset 0 width 16 / end
This flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
op, dst_type, src_type and width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be set, add or sub.
---
v1: Initial implementation.
v2: Made dst_type, src_type and width only mandatory parameters.
v3: Reworked to accomodate API change from copy_field to modify_field.
v4: Renamed the mov operation to set.
--- app/test-pmd/cmdline_flow.c | 246 ++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
app/test-pmd/cmdline_flow.c +246 -0
@@ -408,6 +408,19 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_MODIFY_FIELD , +ACTION_MODIFY_FIELD_OP , +ACTION_MODIFY_FIELD_OP_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE , +ACTION_MODIFY_FIELD_DST_TYPE_VALUE , +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ACTION_MODIFY_FIELD_SRC_TYPE_VALUE , +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , + ACTION_MODIFY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +574,22 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const modify_field_ops[] = { +"set" ,"add" ,"sub" ,NULL +}; + +static const char *const modify_field_ids[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,"value" ,"pointer" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1335,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_MODIFY_FIELD , ZERO, };
@@ -1556,6 +1586,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_modify_field_dst[] = { +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_modify_field_src[] = { +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , +ACTION_MODIFY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1683,14 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1775,10 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_op (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4094,103 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_MODIFY_FIELD] = { + .name = "modify_field", + .help = "modify destination field with data from source field", + .priv =PRIV_ACTION (MODIFY_FIELD , + sizeof(struct rte_flow_action_modify_field)), + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), + .call = parse_vc, + }, + [ACTION_MODIFY_FIELD_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_DST_TYPE ), + NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_modify_field_op, + .comp = comp_set_modify_field_op, + }, + [ACTION_MODIFY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = { + .name = "{dst_type}", + .help = "destination field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = { + .name = "{src_type}", + .help = "source field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_VALUE] = { + .name = "src_value", + .help = "source immediate value", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.value)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6114,62 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse operation for modify_field command. */ +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_OP_VALUE ) +return -1 ; +for (i =0 ; modify_field_ops[i]; ++i) +if (!strcmp_partial (modify_field_ops[i], str, len)) +break ; +if (!modify_field_ops[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; + action_modify_field->operation = (enum rte_flow_modify_op )i; +return len; +} + +/** Parse id for modify_field command. */ +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; modify_field_ids[i]; ++i) +if (!strcmp_partial (modify_field_ids[i], str, len)) +break ; +if (!modify_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; +if (ctx->curr ==ACTION_MODIFY_FIELD_DST_TYPE_VALUE ) + action_modify_field->dst.field = (enum rte_flow_field_id )i; +else + action_modify_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7239,42 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete operation for modify_field command. */ +static int +comp_set_modify_field_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ops[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ops[ent], size); +return -1 ; +} + +/** Complete field id for modify_field command. */ +static int +comp_set_modify_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ids[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ids[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
v7 cover generic modify rte flow action support
In reply to Alexander KozyrevImplement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action to RTE_FLOW_ACTION_TYPE_COPY_FIELD. v5:
Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. v6:
Fixed typos in documentation.
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 65 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++- 5 files changed, 399 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
PATCH v7 1/2 ethdev: introduce generic modify rte flow action
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.
Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.
The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
An immediate value (or pointer to it) can be specified instead of the level and the offset for the special FIELD_VALUE ID (or FIELD_POINTER). Can be used as a source only.
RFC: http://patches.dpdk.org/patch/85384/
---
v1: Initialy RTE_FLOW_ACTION_TYPE_COPY_ITEM
v2: Renamed to RTE_FLOW_ACTION_TYPE_COPY_FIELD
v3: Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
v4: Fixed typos in documentation, renamed mov operation to set.
--- doc/guides/prog_guide/rte_flow.rst | 65 +++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 8 +++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 79 +++++++++++++++++++++++++- 4 files changed, 153 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +65 -0
@@ -2766,6 +2766,71 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (move, addition, +subtraction) with ``width`` bits of data from ``src`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` + +``width`` defines a number of bits to use from ``src`` field. + +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet +encapsulation level, from outermost to innermost (lower to higher values). +For the tag array ``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it if supported by an underlying PMD driver. + +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a pointer to this value | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of modify field action in the flow API.** + + Added modify action support to perform various operations on + any arbitrary header field (as well as mark, metadata or tag values): + ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD``. + supported operations are: overwriting a field with the content from + another field, addition and subtraction using an immediate value. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with fixes and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -176,6 +176,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (MODIFY_FIELD , +sizeof (struct rte_flow_action_modify_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +78 -1
97 lines not on this page · raw message
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic modify rte flow action
16/01/2021 05:50, Alexander Kozyrev:
Quoted 26 lines
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (
ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
Quoted 5 lines
An immediate value (or pointer to it) can be specified instead of the level and the offset for the special
FIELD_VALUEID (orFIELD_POINTER). Can be used as a source only.
You don't need to refer to the RFC in the commit message.
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2773
Quoted 9 lines
Signed-off-by Alexander Kozyrev <[email protected]>Acked-by Ori Kam <[email protected]>---
doc/guides/prog_guide/rte_flow.rst +5
-0+Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (move, addition, +subtraction) with ``width`` bits of data from ``src`` field.
"move" is changed to "set", right?
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +7
-0+Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field.
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2791
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` + +``width`` defines a number of bits to use from ``src`` field. + +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between.
I feel the interpretation of the level 0 is driver-dependent?
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2795
Quoted 4 lines
+- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packetdoc/guides/prog_guide/rte_flow.rst +2
-0+encapsulation level, from outermost to innermost (lower to higher values). +For the tag array ``level`` translates directly into the array index.
You should define what is a tag array.
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2802
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +7
-0+ +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it if supported by an underlying PMD driver.
All features of this specification require PMD support, so I think it is useless to mention here.
Quoted 20 lines
doc/guides/prog_guide/rte_flow.rst +20
-0+ +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: +
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2832
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a pointer to this value | + +---------------+----------------------------------------------------------+
I know the whole rte_flow guide has this kind of table, but really it looks like doxygen and can be skipped here.
If really this redundant info is required, it should be RST definition lists, not tables.
[...]
In my opinion, the most important info is in the doxygen comments.
Please add a doxygen comment for this enum.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2805
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+enum rte_flow_field_id { +RTE_FLOW_FIELD_START =0 ,
Please add a doxygen comment for the value RTE_FLOW_FIELD_START.
Quoted 16 lines
lib/librte_ethdev/rte_flow.h +16
-0+RTE_FLOW_FIELD_MAC_DST , +RTE_FLOW_FIELD_MAC_SRC , +RTE_FLOW_FIELD_VLAN_TYPE , +RTE_FLOW_FIELD_VLAN_ID , +RTE_FLOW_FIELD_MAC_TYPE , +RTE_FLOW_FIELD_IPV4_DSCP , +RTE_FLOW_FIELD_IPV4_TTL , +RTE_FLOW_FIELD_IPV4_SRC , +RTE_FLOW_FIELD_IPV4_DST , +RTE_FLOW_FIELD_IPV6_HOPLIMIT , +RTE_FLOW_FIELD_IPV6_SRC , +RTE_FLOW_FIELD_IPV6_DST , +RTE_FLOW_FIELD_TCP_PORT_SRC , +RTE_FLOW_FIELD_TCP_PORT_DST , +RTE_FLOW_FIELD_TCP_SEQ_NUM , + RTE_FLOW_FIELD_TCP_ACK_NUM,
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_FIELD_TCP_FLAGS , +RTE_FLOW_FIELD_UDP_PORT_SRC , +RTE_FLOW_FIELD_UDP_PORT_DST , +RTE_FLOW_FIELD_VXLAN_VNI , +RTE_FLOW_FIELD_GENEVE_VNI , +RTE_FLOW_FIELD_GTP_TEID , +RTE_FLOW_FIELD_TAG , +RTE_FLOW_FIELD_MARK , +RTE_FLOW_FIELD_META , + RTE_FLOW_FIELD_POINTER,
Please add a doxygen comment for the value RTE_FLOW_FIELD_POINTER.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2832
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_FIELD_VALUE,
Please add a doxygen comment for the value RTE_FLOW_FIELD_VALUE.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2845
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+struct rte_flow_action_modify_data { +enum rte_flow_field_id field; + RTE_STD_C11 + union { +struct { +uint32_t level; +uint32_t offset; + }; +uint64_t value; + }; +};
Please add doxygen for this struct and fields.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2851
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ +enum rte_flow_modify_op { +RTE_FLOW_MODIFY_SET =0 , +RTE_FLOW_MODIFY_ADD , +RTE_FLOW_MODIFY_SUB , +};
Please add doxygen for this enum.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2862
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* +* Modifies a destination header field according to the specified +* operation. Another packet field can be used as a source as well +* as tag, mark, metadata or an immediate value or a pointer to it. +* Width is the number of bits used from the source item.
width should be documented below as other fields.
Quoted 7 lines
+ */
lib/librte_ethdev/rte_flow.h +6
-0+struct rte_flow_action_modify_field { +enum rte_flow_modify_op operation; +struct rte_flow_action_modify_data dst; +struct rte_flow_action_modify_data src; +uint32_t width; +};
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic modify rte flow action
Quoted 41 lines
From: Thomas Monjalon <[email protected]> on Sunday, January 17, 2021 18:16 16/01/2021 05:50, Alexander Kozyrev:
Quoted 26 lines
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (
ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
Quoted 5 lines
An immediate value (or pointer to it) can be specified instead of the level and the offset for the special
FIELD_VALUEID (orFIELD_POINTER). Can be used as a source only.RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
es.dpdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Cakozyrev%40nv idia.com%7Ce20d2c38372b4062420d08d8bb3dd549%7C43083d15727340c1b7d b39efd9ccc17a%7C0%7C0%7C637465221537183554%7CUnknown%7CTWFpb GZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI 6Mn0%3D%7C1000&sdata=gWEdmyAabnCCmeFyi%2FvHs0aheMmWNx IyR%2BTC96O3Yck%3D&reserved=0
Quoted 1 line
You don't need to refer to the RFC in the commit message.
Removing link to it.
Quoted 4 lines
Quoted 4 lines
Signed-off-by Alexander Kozyrev <[email protected]>Acked-by Ori Kam <[email protected]>
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2773
Quoted 6 lines
---
doc/guides/prog_guide/rte_flow.rst +5
-0+Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (move, addition, +subtraction) with ``width`` bits of data from ``src`` field."move" is changed to "set", right?
Right, thanks for catching this.
Quoted 12 lines
Quoted 12 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` +
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2791
Quoted 6 lines
+``width`` defines a number of bits to use from ``src`` field.
doc/guides/prog_guide/rte_flow.rst +5
-0+ +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between.I feel the interpretation of the level 0 is driver-dependent?
It is driver-dependent, the behavior is the same as in case of RSS.
Quoted 7 lines
Quoted 3 lines
+- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet+encapsulation level, from outermost to innermost (lower to higher
values).
Quoted 1 line
+For the tag array ``level`` translates directly into the array index.
You should define what is a tag array.
Ok, but it is defined already in RTE_FLOW_ACTION_TYPE_SET_TAG action.
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2802
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +7
-0+ +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it if supported by an underlying PMD driver.All features of this specification require PMD support, so I think it is useless to mention here.
Removing.
Quoted 34 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER``respectively.
Quoted 11 lines
doc/guides/prog_guide/rte_flow.rst +11
-0+ +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field |doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2833
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | ++===============+=========================================
=================+doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2832
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a pointer to this value | + +---------------+----------------------------------------------------------+
Quoted 5 lines
I know the whole
rte_flowguide has this kind of table, but really it looks like doxygen and can be skipped here.If really this redundant info is required, it should be RST definition lists, not tables.
I would keep these tables for the sake of consistency of the rte_flow guide.
Quoted 3 lines
[...]
In my opinion, the most important info is in the doxygen comments.
Agree, adding them for all the structures/fields mentioned below.
Quoted 86 lines
Please add a doxygen comment for this enum.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2805
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+enum rte_flow_field_id { +RTE_FLOW_FIELD_START =0 ,Please add a doxygen comment for the value
RTE_FLOW_FIELD_START.Quoted 16 lines
lib/librte_ethdev/rte_flow.h +16
-0+RTE_FLOW_FIELD_MAC_DST , +RTE_FLOW_FIELD_MAC_SRC , +RTE_FLOW_FIELD_VLAN_TYPE , +RTE_FLOW_FIELD_VLAN_ID , +RTE_FLOW_FIELD_MAC_TYPE , +RTE_FLOW_FIELD_IPV4_DSCP , +RTE_FLOW_FIELD_IPV4_TTL , +RTE_FLOW_FIELD_IPV4_SRC , +RTE_FLOW_FIELD_IPV4_DST , +RTE_FLOW_FIELD_IPV6_HOPLIMIT , +RTE_FLOW_FIELD_IPV6_SRC , +RTE_FLOW_FIELD_IPV6_DST , +RTE_FLOW_FIELD_TCP_PORT_SRC , +RTE_FLOW_FIELD_TCP_PORT_DST , +RTE_FLOW_FIELD_TCP_SEQ_NUM , + RTE_FLOW_FIELD_TCP_ACK_NUM,lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2831
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_FIELD_TCP_FLAGS , +RTE_FLOW_FIELD_UDP_PORT_SRC , +RTE_FLOW_FIELD_UDP_PORT_DST , +RTE_FLOW_FIELD_VXLAN_VNI , +RTE_FLOW_FIELD_GENEVE_VNI , +RTE_FLOW_FIELD_GTP_TEID , +RTE_FLOW_FIELD_TAG , +RTE_FLOW_FIELD_MARK , +RTE_FLOW_FIELD_META , + RTE_FLOW_FIELD_POINTER,Please add a doxygen comment for the value
RTE_FLOW_FIELD_POINTER.lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2832
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_FIELD_VALUE,Please add a doxygen comment for the value
RTE_FLOW_FIELD_VALUE.lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2845
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+struct rte_flow_action_modify_data { +enum rte_flow_field_id field; + RTE_STD_C11 + union { +struct { +uint32_t level; +uint32_t offset; + }; +uint64_t value; + }; +};Please add doxygen for this struct and fields.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2851
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ +enum rte_flow_modify_op { +RTE_FLOW_MODIFY_SET =0 , +RTE_FLOW_MODIFY_ADD , +RTE_FLOW_MODIFY_SUB , +};Please add doxygen for this enum.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2862
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* +* Modifies a destination header field according to the specified +* operation. Another packet field can be used as a source as well +* as tag, mark, metadata or an immediate value or a pointer to it. +* Width is the number of bits used from the source item. width should be documented below as other fields.
Quoted 7 lines
+ */
lib/librte_ethdev/rte_flow.h +6
-0+struct rte_flow_action_modify_field { +enum rte_flow_modify_op operation; +struct rte_flow_action_modify_data dst; +struct rte_flow_action_modify_data src; +uint32_t width; +};
PATCH v7 2/2 app/testpmd: add support for modify field flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_MODIFY_FIELD to the testpmd. Implement CLI to create the modify_field action and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions modify_field op set dst_type tag dst_level 2 dst_offset 8
src_type gtp_teid src_level 0 src_offset 0 width 16 / end
This flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
op, dst_type, src_type and width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be set, add or sub.
---
v1: Initial implementation.
v2: Made dst_type, src_type and width only mandatory parameters.
v3: Reworked to accomodate API change from copy_field to modify_field.
v4: Renamed the mov operation to set.
--- app/test-pmd/cmdline_flow.c | 246 ++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
app/test-pmd/cmdline_flow.c +246 -0
@@ -408,6 +408,19 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_MODIFY_FIELD , +ACTION_MODIFY_FIELD_OP , +ACTION_MODIFY_FIELD_OP_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE , +ACTION_MODIFY_FIELD_DST_TYPE_VALUE , +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ACTION_MODIFY_FIELD_SRC_TYPE_VALUE , +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , + ACTION_MODIFY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +574,22 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const modify_field_ops[] = { +"set" ,"add" ,"sub" ,NULL +}; + +static const char *const modify_field_ids[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,"value" ,"pointer" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1335,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_MODIFY_FIELD , ZERO, };
@@ -1556,6 +1586,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_modify_field_dst[] = { +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_modify_field_src[] = { +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , +ACTION_MODIFY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1683,14 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1775,10 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_op (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4094,103 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_MODIFY_FIELD] = { + .name = "modify_field", + .help = "modify destination field with data from source field", + .priv =PRIV_ACTION (MODIFY_FIELD , + sizeof(struct rte_flow_action_modify_field)), + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), + .call = parse_vc, + }, + [ACTION_MODIFY_FIELD_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_DST_TYPE ), + NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_modify_field_op, + .comp = comp_set_modify_field_op, + }, + [ACTION_MODIFY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = { + .name = "{dst_type}", + .help = "destination field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = { + .name = "{src_type}", + .help = "source field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_VALUE] = { + .name = "src_value", + .help = "source immediate value", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.value)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6114,62 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse operation for modify_field command. */ +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_OP_VALUE ) +return -1 ; +for (i =0 ; modify_field_ops[i]; ++i) +if (!strcmp_partial (modify_field_ops[i], str, len)) +break ; +if (!modify_field_ops[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; + action_modify_field->operation = (enum rte_flow_modify_op )i; +return len; +} + +/** Parse id for modify_field command. */ +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; modify_field_ids[i]; ++i) +if (!strcmp_partial (modify_field_ids[i], str, len)) +break ; +if (!modify_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; +if (ctx->curr ==ACTION_MODIFY_FIELD_DST_TYPE_VALUE ) + action_modify_field->dst.field = (enum rte_flow_field_id )i; +else + action_modify_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7239,42 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete operation for modify_field command. */ +static int +comp_set_modify_field_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ops[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ops[ent], size); +return -1 ; +} + +/** Complete field id for modify_field command. */ +static int +comp_set_modify_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ids[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ids[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
v8 cover generic modify rte flow action support
In reply to Alexander KozyrevImplement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
Example of RTE_FLOW_ACTION_TYPE_MODIFY_FIELD implementation for MLX5:
https://patchwork.dpdk.org/patch/86736/
---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action to RTE_FLOW_ACTION_TYPE_COPY_FIELD.
v5: https://patchwork.dpdk.org/cover/86705/
Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
v6: https://patchwork.dpdk.org/cover/86715/
Fixed typos in documentation.
v7: https://patchwork.dpdk.org/cover/86718/
Fixed warnings.
v8:
Added doxygen comments.
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 66 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 87 ++++++++- 5 files changed, 408 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
PATCH v8 1/2 ethdev: introduce generic modify rte flow action
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.
Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.
The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
An immediate value (or a pointer to it) can be specified instead of the level and the offset for the special FIELD_VALUE ID (or FIELD_POINTER). Can be used as a source only.
---
v1: Initialy RTE_FLOW_ACTION_TYPE_COPY_ITEM
v2: Renamed to RTE_FLOW_ACTION_TYPE_COPY_FIELD
v3: Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
v4: Fixed typos in documentation, renamed mov operation to set
v5: Added doxygen comments
--- doc/guides/prog_guide/rte_flow.rst | 66 +++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 8 +++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 87 +++++++++++++++++++++++++- 4 files changed, 162 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +66 -0
@@ -2766,6 +2766,72 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (set, addition, +subtraction) with ``width`` bits of data from ``src`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` + +``width`` defines a number of bits to use from ``src`` field. + +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet +encapsulation level, from outermost to innermost (lower to higher values). +For the tag array (in case of multiple tags are supported and present) +``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it. + +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a pointer to this value | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of modify field action in the flow API.** + + Added modify action support to perform various operations on + any arbitrary header field (as well as mark, metadata or tag values): + ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD``. + supported operations are: overwriting a field with the content from + another field, addition and subtraction using an immediate value. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with fixes and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -176,6 +176,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (MODIFY_FIELD , +sizeof (struct rte_flow_action_modify_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +86 -1
105 lines not on this page · raw message
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic modify rte flow action
18/01/2021 17:18, Alexander Kozyrev:
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2842
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+/** +* Field description for MODIFY_FIELD action. +*/ +struct rte_flow_action_modify_data { +enum rte_flow_field_id field;/**< Field ID */
more accurate:
Field or memory type
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2847
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+RTE_STD_C11 + union { +struct { +uint32_t level;/**< Encapsulation level or tag index */ +uint32_t offset;/**< Number of bits to skip from src */
"from src" only?
I think we could use it for dst as well.
I would remove "from src".
Review
Quoted 2 lines
(quoted diff) +2
-0+ }; + uint64_t value; /**< Immediate value or memory address of it */
You should specify for RTE_FLOW_FIELD_POINTER and RTE_FLOW_FIELD_VALUE.
Please add a dot at the end of each comment.
[...]
Quoted 7 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ *RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
+ *
+ * Modifies a destination header field according to the specified
s/Modifies/Modify/ (imperative form is preferred)
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2877
Quoted 9 lines
+ * operation. Another packet field can be used as a source as well
+ * as tag, mark, metadata, immediate value or a pointer to it.
+ */lib/librte_ethdev/rte_flow.h +6
-0+struct rte_flow_action_modify_field { +enum rte_flow_modify_op operation;/**< Operation to perform on dst*/ +struct rte_flow_action_modify_data dst;/**< Destination field */ +struct rte_flow_action_modify_data src;/**< Source field */ +uint32_t width;/**< Number of bits to use from a source field */ +};
With above changes,
PATCH v8 2/2 app/testpmd: add support for modify field flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_MODIFY_FIELD to the testpmd. Implement CLI to create the modify_field action and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions modify_field op set dst_type tag dst_level 2 dst_offset 8
src_type gtp_teid src_level 0 src_offset 0 width 16 / end
This flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
op, dst_type, src_type and width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be set, add or sub.
---
v1: Initial implementation.
v2: Made dst_type, src_type and width only mandatory parameters.
v3: Reworked to accomodate API change from copy_field to modify_field.
v4: Renamed the mov operation to set.
--- app/test-pmd/cmdline_flow.c | 246 ++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
app/test-pmd/cmdline_flow.c +246 -0
@@ -408,6 +408,19 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_MODIFY_FIELD , +ACTION_MODIFY_FIELD_OP , +ACTION_MODIFY_FIELD_OP_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE , +ACTION_MODIFY_FIELD_DST_TYPE_VALUE , +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ACTION_MODIFY_FIELD_SRC_TYPE_VALUE , +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , + ACTION_MODIFY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +574,22 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const modify_field_ops[] = { +"set" ,"add" ,"sub" ,NULL +}; + +static const char *const modify_field_ids[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,"pointer" ,"value" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1335,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_MODIFY_FIELD , ZERO, };
@@ -1556,6 +1586,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_modify_field_dst[] = { +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_modify_field_src[] = { +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , +ACTION_MODIFY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1683,14 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1775,10 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_op (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4094,103 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_MODIFY_FIELD] = { + .name = "modify_field", + .help = "modify destination field with data from source field", + .priv =PRIV_ACTION (MODIFY_FIELD , + sizeof(struct rte_flow_action_modify_field)), + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), + .call = parse_vc, + }, + [ACTION_MODIFY_FIELD_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_DST_TYPE ), + NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_modify_field_op, + .comp = comp_set_modify_field_op, + }, + [ACTION_MODIFY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = { + .name = "{dst_type}", + .help = "destination field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = { + .name = "{src_type}", + .help = "source field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_VALUE] = { + .name = "src_value", + .help = "source immediate value", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.value)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6114,62 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse operation for modify_field command. */ +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_OP_VALUE ) +return -1 ; +for (i =0 ; modify_field_ops[i]; ++i) +if (!strcmp_partial (modify_field_ops[i], str, len)) +break ; +if (!modify_field_ops[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; + action_modify_field->operation = (enum rte_flow_modify_op )i; +return len; +} + +/** Parse id for modify_field command. */ +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; modify_field_ids[i]; ++i) +if (!strcmp_partial (modify_field_ids[i], str, len)) +break ; +if (!modify_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; +if (ctx->curr ==ACTION_MODIFY_FIELD_DST_TYPE_VALUE ) + action_modify_field->dst.field = (enum rte_flow_field_id )i; +else + action_modify_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7239,42 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete operation for modify_field command. */ +static int +comp_set_modify_field_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ops[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ops[ent], size); +return -1 ; +} + +/** Complete field id for modify_field command. */ +static int +comp_set_modify_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ids[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ids[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v8 0/2] generic modify rte flow action support
In reply to Alexander KozyrevQuoted 37 lines · Alexander Kozyrev
Implement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
Example of
RTE_FLOW_ACTION_TYPE_MODIFY_FIELDimplementation for MLX5:
https://patchwork.dpdk.org/patch/86736/---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Madedst_type,src_typeand width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action toRTE_FLOW_ACTION_TYPE_COPY_FIELD.
v5: https://patchwork.dpdk.org/cover/86705/
Redesigned asRTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
v6: https://patchwork.dpdk.org/cover/86715/
Fixed typos in documentation.
v7: https://patchwork.dpdk.org/cover/86718/
Fixed warnings.
v8:
Added doxygen comments.
Quoted 3 lines
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
I see Thomas has some comments on one of the patches. Please address that. Otherwise ack for the series.
Quoted 11 lines
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 66 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 87 ++++++++- 5 files changed, 408 insertions(+), 1 deletion(-)--
2.24.1
v9 cover generic modify rte flow action support
In reply to Alexander KozyrevImplement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/
This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
Example of RTE_FLOW_ACTION_TYPE_MODIFY_FIELD implementation for MLX5:
https://patchwork.dpdk.org/patch/86736/
---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Made dst_type, src_type and width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action to RTE_FLOW_ACTION_TYPE_COPY_FIELD.
v5: https://patchwork.dpdk.org/cover/86705/
Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
v6: https://patchwork.dpdk.org/cover/86715/
Fixed typos in documentation.
v7: https://patchwork.dpdk.org/cover/86718/
Fixed warnings.
v8: https://patchwork.dpdk.org/cover/86816/
Added doxygen comments.
v9:
Minor documentation corrections.
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
app/test-pmd/cmdline_flow.c | 246 +++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 66 +++++++ doc/guides/rel_notes/release_21_02.rst | 8 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 93 +++++++++- 5 files changed, 414 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1
PATCH v9 1/2 ethdev: introduce generic modify rte flow action
Implement the generic modify flow API to allow manipulations on an arbitrary header field (as well as mark, metadata or tag) using data from another field or a user-specified value.
This generic modify mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future.
Supported operation are:
- set: copy data from source to destination.
- add: integer addition, stores the result in destination.
- sub: integer subtraction, stores the result in destination.
The field ID is used to specify the desired source/destination packet field in order to simplify the API for various encapsulation models. Specifying the packet field ID with the needed encapsulation level is able to quickly get a packet field for any inner packet header.
Alternatively, the special ID (ITEM_START) can be used to point to the very beginning of a packet. This ID in conjunction with the offset parameter provides great flexibility to copy/modify any part of a packet as needed.
The number of bits to use from a source as well as the offset can be be specified to allow a partial copy or dividing a big packet field into multiple small fields (e.g. copying 128 bits of IPv6 to 4 tags).
An immediate value (or a pointer to it) can be specified instead of the level and the offset for the special FIELD_VALUE ID (or FIELD_POINTER). Can be used as a source only.
---
v1: Initialy RTE_FLOW_ACTION_TYPE_COPY_ITEM
v2: Renamed to RTE_FLOW_ACTION_TYPE_COPY_FIELD
v3: Redesigned as RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
v4: Fixed typos in documentation, renamed mov operation to set
v5: Added doxygen comments
v6: Minor documentation edits.
--- doc/guides/prog_guide/rte_flow.rst | 66 ++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 8 +++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 93 +++++++++++++++++++++++++- 4 files changed, 168 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +66 -0
@@ -2766,6 +2766,72 @@ The behaviour of the shared action defined by ``action`` argument of type | no properties | +---------------+ +Action: ``MODIFY_FIELD`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Modify ``dst`` field according to ``op`` selected (set, addition, +subtraction) with ``width`` bits of data from ``src`` field. + +Any arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination fields as set by ``field``. +The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it +``RTE_FLOW_FIELD_POINTER``) is allowed as a source only. +``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. + +``op`` selects the operation to perform on a destination field. +- ``set`` copies the data from ``src`` field to ``dst`` field. +- ``add`` adds together ``dst`` and ``src`` and stores the result into ``dst``. +- ``sub`` subtracts ``src`` from ``dst`` and stores the result into ``dst`` + +``width`` defines a number of bits to use from ``src`` field. + +``level`` is used to access any packet field on any encapsulation level +as well as any tag element in the tag array. +- ``0`` means the default behaviour. Depending on the packet type, it can +mean outermost, innermost or anything in between. +- ``1`` requests access to the outermost packet encapsulation level. +- ``2`` and subsequent values requests access to the specified packet +encapsulation level, from outermost to innermost (lower to higher values). +For the tag array (in case of multiple tags are supported and present) +``level`` translates directly into the array index. + +``offset`` specifies the number of bits to skip from a field's start. +That allows performing a partial copy of the needed part or to divide a big +packet field into multiple smaller fields. Alternatively, ``offset`` allows +going past the specified packet field boundary to copy a field to an +arbitrary place in a packet, essentially providing a way to copy any part of +a packet to any other part of it. + +``value`` sets an immediate value to be used as a source or points to a +location of the value in memory. It is used instead of ``level`` and ``offset`` +for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. + +.. _table_rte_flow_action_modify_field: + +.. table:: MODIFY_FIELD + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``op`` | operation to perform | + | ``dst`` | destination field | + | ``src`` | source field | + | ``width`` | number of bits to use | + +---------------+-------------------------+ + +.. _table_rte_flow_action_modify_data: + +.. table:: destination/source field definition + + +--------------------------------------------------------------------------+ + | Field | Value | + +===============+==========================================================+ + | ``field`` | ID: packet field, mark, meta, tag, immediate, pointer | + | ``level`` | encapsulation level of a packet field or tag array index | + | ``offset`` | number of bits to skip at the beginning | + | ``value`` | immediate value or a pointer to this value | + +---------------+----------------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_02.rst +8 -0
@@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support of modify field action in the flow API.** + + Added modify action support to perform various operations on + any arbitrary header field (as well as mark, metadata or tag values): + ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD``. + supported operations are: overwriting a field with the content from + another field, addition and subtraction using an immediate value. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with fixes and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -176,6 +176,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )),MK_FLOW_ACTION (SAMPLE ,sizeof (struct rte_flow_action_sample )), +MK_FLOW_ACTION (MODIFY_FIELD , +sizeof (struct rte_flow_action_modify_field )),/** * Shared action represented as handle of type * (struct rte_flow_shared action *) stored in conf field (see
lib/librte_ethdev/rte_flow.h +92 -1
111 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v9 2/2 app/testpmd: add support for modify field flow action
In reply to Alexander KozyrevAdd support for the RTE_FLOW_ACTION_MODIFY_FIELD to the testpmd. Implement CLI to create the modify_field action and supply all the needed parameters to modify an arbitrary packet field (as well as mark, tag or metadata) with data from another field or immediate value.
Example of the flow is the following:
flow create 0 egress group 1 pattern eth / ipv4 / udp / end
actions modify_field op set dst_type tag dst_level 2 dst_offset 8
src_type gtp_teid src_level 0 src_offset 0 width 16 / end
This flow copies 16 bits from the second Tag in the Tags array into the outermost GTP TEID packet header field. 8 bits of the Tag are skipped as indicated by the dst_offset action parameter.
op, dst_type, src_type and width are the mandatory parameters to specify. Levels and offset are 0 by default if they are not overridden by a user. The operation can be set, add or sub.
---
v1: Initial implementation.
v2: Made dst_type, src_type and width only mandatory parameters.
v3: Reworked to accomodate API change from copy_field to modify_field.
v4: Renamed the mov operation to set.
--- app/test-pmd/cmdline_flow.c | 246 ++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
app/test-pmd/cmdline_flow.c +246 -0
@@ -408,6 +408,19 @@ enum index {ACTION_SAMPLE_INDEX_VALUE ,ACTION_SHARED ,SHARED_ACTION_ID2PTR , +ACTION_MODIFY_FIELD , +ACTION_MODIFY_FIELD_OP , +ACTION_MODIFY_FIELD_OP_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE , +ACTION_MODIFY_FIELD_DST_TYPE_VALUE , +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ACTION_MODIFY_FIELD_SRC_TYPE_VALUE , +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , + ACTION_MODIFY_FIELD_WIDTH, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -561,6 +574,22 @@ struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM ];struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM ]; +static const char *const modify_field_ops[] = { +"set" ,"add" ,"sub" ,NULL +}; + +static const char *const modify_field_ids[] = { +"start" ,"mac_dst" ,"mac_src" , +"vlan_type" ,"vlan_id" ,"mac_type" , +"ipv4_dscp" ,"ipv4_ttl" ,"ipv4_src" ,"ipv4_dst" , +"ipv6_hoplimit" ,"ipv6_src" ,"ipv6_dst" , +"tcp_port_src" ,"tcp_port_dst" , +"tcp_seq_num" ,"tcp_ack_num" ,"tcp_flags" , +"udp_port_src" ,"udp_port_dst" , +"vxlan_vni" ,"geneve_vni" ,"gtp_teid" , +"tag" ,"mark" ,"meta" ,"pointer" ,"value" ,NULL +}; +/** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16
@@ -1306,6 +1335,7 @@ static const enum index next_action[] = {ACTION_AGE ,ACTION_SAMPLE ,ACTION_SHARED , +ACTION_MODIFY_FIELD , ZERO, };
@@ -1556,6 +1586,21 @@ static const enum index next_action_sample[] = { ZERO, }; +static const enum index action_modify_field_dst[] = { +ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_OFFSET , +ACTION_MODIFY_FIELD_SRC_TYPE , +ZERO , +}; + +static const enum index action_modify_field_src[] = { +ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_OFFSET , +ACTION_MODIFY_FIELD_SRC_VALUE , +ACTION_MODIFY_FIELD_WIDTH , +ZERO , +}; +static int parse_set_raw_encap_decap (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1638,6 +1683,14 @@ static int parse_vc_action_sample_index(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -1722,6 +1775,10 @@ static int comp_set_raw_index(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_sample_index (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_op (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_set_modify_field_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -4037,6 +4094,103 @@ static const struct token token_list[] = { .call = parse_vc_action_raw_decap_index, .comp = comp_set_raw_index, }, + [ACTION_MODIFY_FIELD] = { + .name = "modify_field", + .help = "modify destination field with data from source field", + .priv =PRIV_ACTION (MODIFY_FIELD , + sizeof(struct rte_flow_action_modify_field)), + .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)), + .call = parse_vc, + }, + [ACTION_MODIFY_FIELD_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_DST_TYPE ), + NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_modify_field_op, + .comp = comp_set_modify_field_op, + }, + [ACTION_MODIFY_FIELD_DST_TYPE] = { + .name = "dst_type", + .help = "destination field type", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = { + .name = "{dst_type}", + .help = "destination field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_DST_LEVEL] = { + .name = "dst_level", + .help = "destination field level", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_OFFSET] = { + .name = "dst_offset", + .help = "destination field bit offset", + .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE] = { + .name = "src_type", + .help = "source field type", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = { + .name = "{src_type}", + .help = "source field type value", + .call = parse_vc_modify_field_id, + .comp = comp_set_modify_field_id, + }, + [ACTION_MODIFY_FIELD_SRC_LEVEL] = { + .name = "src_level", + .help = "source field level", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.level)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_OFFSET] = { + .name = "src_offset", + .help = "source field bit offset", + .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.offset)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_VALUE] = { + .name = "src_value", + .help = "source immediate value", + .next =NEXT (NEXT_ENTRY (ACTION_MODIFY_FIELD_WIDTH ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.value)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to copy", + .next =NEXT (NEXT_ENTRY (ACTION_NEXT ), + NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + width)), + .call = parse_vc_conf, + },/* Top level command. */ [SET] = { .name = "set",
@@ -5960,6 +6114,62 @@ parse_vc_action_sample_index(struct context *ctx, const struct token *token,return len; } +/** Parse operation for modify_field command. */ +static int +parse_vc_modify_field_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_OP_VALUE ) +return -1 ; +for (i =0 ; modify_field_ops[i]; ++i) +if (!strcmp_partial (modify_field_ops[i], str, len)) +break ; +if (!modify_field_ops[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; + action_modify_field->operation = (enum rte_flow_modify_op )i; +return len; +} + +/** Parse id for modify_field command. */ +static int +parse_vc_modify_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_action_modify_field *action_modify_field; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ACTION_MODIFY_FIELD_DST_TYPE_VALUE && + ctx->curr !=ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ) +return -1 ; +for (i =0 ; modify_field_ids[i]; ++i) +if (!strcmp_partial (modify_field_ids[i], str, len)) +break ; +if (!modify_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + action_modify_field = ctx->object; +if (ctx->curr ==ACTION_MODIFY_FIELD_DST_TYPE_VALUE ) + action_modify_field->dst.field = (enum rte_flow_field_id )i; +else + action_modify_field->src.field = (enum rte_flow_field_id )i; +return len; +} +/** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token,
@@ -7029,6 +7239,42 @@ comp_set_sample_index(struct context *ctx, const struct token *token,return nb; } +/** Complete operation for modify_field command. */ +static int +comp_set_modify_field_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ops[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ops[ent], size); +return -1 ; +} + +/** Complete field id for modify_field command. */ +static int +comp_set_modify_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +uint16_t idx =0 ; + +RTE_SET_USED (ctx); +RTE_SET_USED (token); +for (idx =0 ; modify_field_ids[idx]; ++idx) + ; +if (!buf) +return idx +1 ; +if (ent < idx) +return strlcpy (buf, modify_field_ids[ent], size); +return -1 ; +} +/** Internal context. */ static struct context cmd_flow_context;
Signature · 1 line
2.24.1
Re: [dpdk-dev] [PATCH v9 0/2] generic modify rte flow action support
In reply to Alexander KozyrevQuoted 38 lines · Alexander Kozyrev
Implement a generic modify rte flow API as described in RFC:
http://patches.dpdk.org/patch/85384/This API allows modifying a destination header field with data from a source header field. Number of bits to use from the source is specified. Tag, Mark or Metadata can also be used as a source/destination to allow saving/overwriting an arbitrary header field with a user-specified value. Alternatively, an immediate value can be provided by a user as a source.
Outermost/innermost packet fields (and Tag array elements) are accessible via the level parameter to facilitate the modification of encapsulated packet header fields. The offset parameter provides the flexibility to copy/set any part of a packet starting the specified packet header field.
Example of
RTE_FLOW_ACTION_TYPE_MODIFY_FIELDimplementation for MLX5:
https://patchwork.dpdk.org/patch/86736/---
v1: https://patchwork.dpdk.org/patch/86173/
Initial design.
v2: https://patchwork.dpdk.org/cover/86369/
Added testpmd support.
v3: https://patchwork.dpdk.org/cover/86442/
Madedst_type,src_typeand width only mandatory parameters.
v4: https://patchwork.dpdk.org/cover/86488/
Renamed action toRTE_FLOW_ACTION_TYPE_COPY_FIELD.
v5: https://patchwork.dpdk.org/cover/86705/
Redesigned asRTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
v6: https://patchwork.dpdk.org/cover/86715/
Fixed typos in documentation.
v7: https://patchwork.dpdk.org/cover/86718/
Fixed warnings.
v8: https://patchwork.dpdk.org/cover/86816/
Added doxygen comments.
v9:
Minor documentation corrections.
Quoted 4 lines
Alexander Kozyrev (2):
ethdev: introduce generic modify rte flow action app/testpmd: add support for modify field flow action
Series applied to dpdk-next-net/main, thanks.
Quoted 30 lines · Alexander Kozyrev
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC: http://patches.dpdk.org/patch/85384/
Signed-off-by Alexander Kozyrev <[email protected]>---
doc/guides/prog_guide/rte_flow.rst +11
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. +
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2789
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy |
Overall it is a good improvement.
I think, if we add transform "op" here then it can be more generic. In other words, A generic packet transform and copy operation is just one of the operations.
ie.. making it as rte_flow_action_xform_item and introduce COPY, ADD, SUB, etc transform along with existing rte_flow_action_copy_item fields.
It may useful for expressing P4 packet transforms to rte_flow.
The current generation of Marvell HW does not have COPY transform so I am leaving suggestions to vendors with this HW capablity.
Quoted 18 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ +
Hi Jerin,
Quoted 66 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, January 14, 2021 4:00 PM
Subject: Re: [dpdk-dev] [PATCH] ethdev: introduce generic copy rte flow actionQuoted 9 lines · Alexander Kozyrev
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
Quoted 5 lines
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com% 7C62ab41b9ed5948d056c308d8b894af02%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637462296023413253%7CUnknown%7CTWFpbGZsb3d8eyJ WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C 1000&sdata=ovpEss3%2B7TgZRYFiDkrvuMFW52747Gno5oOIeDLwrBQ%3D &reserved=0Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
doc/guides/prog_guide/rte_flow.rst +11
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. +doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2789
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy |Overall it is a good improvement.
I think, if we add transform "op" here then it can be more generic. In other words, A generic packet transform and copy operation is just one of the operations.
ie.. making it asrte_flow_action_xform_itemand introduce COPY, ADD, SUB, etc transform along with existingrte_flow_action_copy_itemfields.
Quoted 6 lines
It may useful for expressing P4 packet transforms to
rte_flow.The current generation of Marvell HW does not have COPY transform so I am leaving suggestions to vendors with this HW capablity.
+1
Lest have dst, src, width, op members,
and change the action name to rte_flow_action_modify_field()
also lest add new field name immediate so the copy can be used as set. (copy of an immediate value is a set)
Possible op = copy / add / sub
Quoted 18 lines
Quoted 18 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ +
Quoted 76 lines · Ori Kam
Hi Jerin,
Quoted 66 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, January 14, 2021 4:00 PM
Subject: Re: [dpdk-dev] [PATCH] ethdev: introduce generic copy rte flow actionQuoted 9 lines · Alexander Kozyrev
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
Quoted 5 lines
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatches.d
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com% 7C62ab41b9ed5948d056c308d8b894af02%7C43083d15727340c1b7db39efd9cc c17a%7C0%7C0%7C637462296023413253%7CUnknown%7CTWFpbGZsb3d8eyJ WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C 1000&sdata=ovpEss3%2B7TgZRYFiDkrvuMFW52747Gno5oOIeDLwrBQ%3D &reserved=0Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
doc/guides/prog_guide/rte_flow.rst +11
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. +doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2789
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy |Overall it is a good improvement.
I think, if we add transform "op" here then it can be more generic. In other words, A generic packet transform and copy operation is just one of the operations.
ie.. making it asrte_flow_action_xform_itemand introduce COPY, ADD, SUB, etc transform along with existingrte_flow_action_copy_itemfields.Quoted 6 lines
It may useful for expressing P4 packet transforms to
rte_flow.The current generation of Marvell HW does not have COPY transform so I am leaving suggestions to vendors with this HW capablity.
Quoted 8 lines
+1
Lest have dst, src, width, op members,
and change the action name torte_flow_action_modify_field()also lest add new field name immediate so the copy can be used as set. (copy of an immediate value is a set)
Possible op = copy / add / sub
+1
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
doc/guides/prog_guide/rte_flow.rst +14
-0+ +---------------+-------------------------+ + +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | + +===============+==========================================+ + | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ +
Quoted 98 lines
From: Jerin Jacob <[email protected]> on Friday, January 15, 2021 9:01
Subject: Re: [dpdk-dev] [PATCH] ethdev: introduce generic copy rte flow actionQuoted 7 lines · Ori Kam
Hi Jerin,
Quoted 4 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, January 14, 2021 4:00 PM
Subject: Re: [dpdk-dev] [PATCH] ethdev: introduce generic copy rte flowaction
Quoted 2 lines
Quoted 2 lines
On Fri, Jan 8, 2021 at 12:02 PM Alexander Kozyrev
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines · wrote:
Implement a generic copy flow API to allow copying of an arbitrary header field (as well as mark, metadata or tag) to another item.
This generic copy mechanism removes the necessity to implement a separate RTE Flow action every time we need to modify a new packet field in the future. A user-provided value can be used from a specified tag/metadata or directly copied from other packet field.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
The number of bits to copy as well as the offset to start from can be specified to allow a partial copy or copy into an arbitrary place in a packet for greater flexibility.
RFC:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch
es.dQuoted 1 line
Quoted 1 line
pdk.org%2Fpatch%2F85384%2F&data=04%7C01%7Corika%40nvidia.com %
Quoted 1 line
Quoted 1 line
7C62ab41b9ed5948d056c308d8b894af02%7C43083d15727340c1b7db39efd9cc
Quoted 1 line
Quoted 1 line
c17a%7C0%7C0%7C637462296023413253%7CUnknown%7CTWFpbGZsb3d8ey J
Quoted 1 line
Quoted 1 line
WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D% 7C
Quoted 1 line
Quoted 1 line
1000&sdata=ovpEss3%2B7TgZRYFiDkrvuMFW52747Gno5oOIeDLwrBQ% 3D
Quoted 50 lines
Quoted 39 lines
&reserved=0
Quoted 16 lines
Signed-off-by Alexander Kozyrev <[email protected]>---
doc/guides/prog_guide/rte_flow.rst +11
-0+Action: ``COPY_ITEM`` +^^^^^^^^^^^^^^^^^^^^^ + +Copy ``width`` bits from ``src`` item to ``dst`` item. + +An arbitrary header field (as well as mark, metadata or tag values) +can be used as both source and destination items as set by ``item``. + +Inner packet header fields can be accessed using the ``index`` and +it is possible to start the copy from the ``offset`` bits in an item. +doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2789
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. _table_rte_flow_action_copy_item: + +.. table:: COPY_ITEM + + +-----------------------------------------+ + | Field | Value | + +===============+=========================+ + | ``dst`` | destination item | + | ``src`` | source item | + | ``width`` | number of bits to copy |Overall it is a good improvement.
I think, if we add transform "op" here then it can be more generic. In other words, A generic packet transform and copy operation is just one of the operations.
ie.. making it asrte_flow_action_xform_itemand introduce COPY, ADD, SUB, etc transform along with existingrte_flow_action_copy_itemfields.Quoted 6 lines
It may useful for expressing P4 packet transforms to
rte_flow.The current generation of Marvell HW does not have COPY transform so I am leaving suggestions to vendors with this HW capablity.
+1
Lest have dst, src, width, op members,
and change the action name torte_flow_action_modify_field()
Quoted 6 lines
Quoted 4 lines
also lest add new field name immediate so the copy can be used as set. (copy of an immediate value is a set)
Possible op = copy / add / sub
+1
Thank you, Jerin, for a great idea. I'm issuing a v4 patch with generic modify_field design.
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
+ +---------------+-------------------------+
Quoted 8 lines
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst The behaviour of the shared action defined by ``action`` argument of type · line 2803
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +.. _table_rte_flow_action_copy_data: + +.. table:: destination/source item definition + + +----------------------------------------------------------+ + | Field | Value | ++===============+=========================================
=+Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+ | ``item`` | ID of a packet field/mark/metadata/tag | + | ``index`` | index of outer/inner header or tag array | + | ``offset`` | number of bits to skip during the copy | + +---------------+------------------------------------------+ +