Skip to contentSkip to conversation

ethdev: introduce copy_field rte flow action

RFC In review Alexander Kozyrev 4 participants 16 messages Dec 18, 2020 – Jan 10, 2021

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: introduce copy_field rte flow action

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

It is proposed to implement the "set copy_field" command to store all the required parameters and then to use this template by specifying the index of the needed copy action. For example, to modify the GTP tunnel ID after the packet is encapsulated following testpmd rules are used:

set copy_field width 32 src field tag index 1 offset 0
dst field teid index 0 offset 0
flow create 0 ingress pattern ... / end
raw_decap index 1 / raw_encap index 2 / copy_field index 1 / end

A more generic mechanism to overwrite an arbitrary header field may be introduced to the RTE flows implementation later:
RTE_FLOW_ACTION_TYPE_SET_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	uint8_t *data;
	uint16_t width;
};

This way we can have the generic way to specify an immediate value and use it as data for any packet header field instead of having separate RTE Flow action for each of the packet fields. Deprecation notice may be issued to RTE_FLOW_ACTION_TYPE_SET_XXX actions after the unified method of setting a value to any packet field is implemented.

---
 lib/librte_ethdev/rte_flow.c |  1 +
 lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
lib/librte_ethdev/rte_flow.c +1 -0
index a06f64c271..c3154a29e2 100644
@@ -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
#1 lore raw

Happy New Year Gentlemen, would you mind to share your thought on the proposed changes?
I was thinking about renaming it to more general "copy item" to cover all packet fields, tags and metadata. Other than that it is ready for a formal patch integration in my opinion if there are no objections. Please advise.

Regards,
Alex

Quoted 169 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Alexander Kozyrev
Sent: Thursday, December 17, 2020 20:31
To: [email protected]
Cc: Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Subject: [dpdk-dev] [RFC] ethdev: introduce copy_field rte flow action

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

It is proposed to implement the "set copy_field" command to store all the required parameters and then to use this template by specifying the index of the needed copy action. For example, to modify the GTP tunnel ID after the packet is encapsulated following testpmd rules are used:

set copy_field width 32 src field tag index 1 offset 0
dst field teid index 0 offset 0
flow create 0 ingress pattern ... / end
raw_decap index 1 / raw_encap index 2 / copy_field index 1 / end

A more generic mechanism to overwrite an arbitrary header field may be introduced to the RTE flows implementation later:
RTE_FLOW_ACTION_TYPE_SET_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	uint8_t *data;
	uint16_t width;
};

This way we can have the generic way to specify an immediate value and use it as data for any packet header field instead of having separate RTE Flow action for each of the packet fields. Deprecation notice may be issued to RTE_FLOW_ACTION_TYPE_SET_XXX actions after the unified method of setting a value to any packet field is implemented.

---
 lib/librte_ethdev/rte_flow.c |  1 +
 lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
lib/librte_ethdev/rte_flow.c +1 -0
index a06f64c271..c3154a29e2 100644
@@ -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)),
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 +59 -1
index 0977a78270..8f1798487c 100644
@@ -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_field.
+	 */
+	RTE_FLOW_ACTION_TYPE_COPY_FIELD,
 };
 
 /**
@@ -2791,6 +2801,55 @@ struct rte_flow_action_set_dscp {
  */
 struct rte_flow_shared_action;
 
+enum rte_flow_field_id {
+	RTE_FLOW_FIELD_NONE = 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,
+	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,
+};
+
+struct rte_flow_action_copy_data {
+	enum rte_flow_field_id field;
+	uint16_t index;
+	uint16_t offset;
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_COPY_FIELD
+ *
+ * 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_field {
+	struct rte_flow_action_copy_data dest;
+	struct rte_flow_action_copy_data src;
+	uint16_t width;
+};
+
 /* Mbuf dynamic field offset for metadata. */
 extern int32_t rte_flow_dynf_metadata_offs;
 
--

2.24.1

#2 lore raw

05/01/2021 23:12, Alexander Kozyrev:

Quoted 3 lines

Happy New Year Gentlemen, would you mind to share your thought on the proposed changes?
I was thinking about renaming it to more general "copy item" to cover all packet fields, tags and metadata. Other than that it is ready for a formal patch integration in my opinion if there are no objections. Please advise.

Our mails crossed, I've just replied to the RFC :) Yes we need to progress if we want to meet the deadline. More reviews may help.

#3 lore raw
In reply to Alexander Kozyrev

18/12/2020 02:31, Alexander Kozyrev:

Quoted 28 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};
Quoted 4 lines

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

So index is in reality the layer? How is it numbered exactly? What is the field id if an offset is given?
Can we say that a field id can always be replaced by an offset?

Quoted 1 line

It is proposed to implement the "set copy_field" command to store all

You are talking about testpmd here?
It looks unrelated to this patch and not sure it helps understanding.

Quoted 20 lines

the required parameters and then to use this template by specifying the index of the needed copy action. For example, to modify the GTP tunnel ID after the packet is encapsulated following testpmd rules are used:

set copy_field width 32 src field tag index 1 offset 0
dst field teid index 0 offset 0
flow create 0 ingress pattern ... / end
raw_decap index 1 / raw_encap index 2 / copy_field index 1 / end

A more generic mechanism to overwrite an arbitrary header field may be introduced to the RTE flows implementation later:
RTE_FLOW_ACTION_TYPE_SET_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	uint8_t *data;
	uint16_t width;
};
Quoted 5 lines

This way we can have the generic way to specify an immediate value and use it as data for any packet header field instead of having separate RTE Flow action for each of the packet fields. Deprecation notice may be issued to RTE_FLOW_ACTION_TYPE_SET_XXX actions after the unified method of setting a value to any packet field is implemented.

Yes having a single action for setting any field looks to be a good idea.

Quoted 3 lines
---
 lib/librte_ethdev/rte_flow.c |  1 +

We are very close to the -rc1 date and implemention is missing. Please update.

Quoted 2 lines
 lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

[...]

Quoted 18 lines
lib/librte_ethdev/rte_flow.h +18 -0
+enum rte_flow_field_id {
+	RTE_FLOW_FIELD_NONE = 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,
+};

I don't really like having to list all fields of the world, but it's probably better than the current situation of creating a new action for each field.

#4 lore raw
Quoted 29 lines

Tuesday, January 5, 2021 17:17, Thomas Monjalon <[email protected]>

Quoted 28 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};
Quoted 6 lines
Quoted 4 lines

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a few bits from the entire packet field or a big offset to move to completely different area.

Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it is going to be hard and cumbersome to calculate all the offsets for that. Field ID is much more convenient.

Quoted 4 lines
Quoted 1 line

It is proposed to implement the "set copy_field" command to store all

You are talking about testpmd here?
It looks unrelated to this patch and not sure it helps understanding.

I'm working on testpmd implementation and will send it shortly.

Quoted 20 lines
Quoted 20 lines

the required parameters and then to use this template by specifying the index of the needed copy action. For example, to modify the GTP tunnel ID after the packet is encapsulated following testpmd rules are used:

set copy_field width 32 src field tag index 1 offset 0
dst field teid index 0 offset 0
flow create 0 ingress pattern ... / end
raw_decap index 1 / raw_encap index 2 / copy_field index 1 / end

A more generic mechanism to overwrite an arbitrary header field may be introduced to the RTE flows implementation later:
RTE_FLOW_ACTION_TYPE_SET_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	uint8_t *data;
	uint16_t width;
};
Quoted 7 lines
Quoted 5 lines

This way we can have the generic way to specify an immediate value and use it as data for any packet header field instead of having separate RTE Flow action for each of the packet fields. Deprecation notice may be issued to RTE_FLOW_ACTION_TYPE_SET_XXX actions after the unified method of setting a value to any packet field is implemented.

Yes having a single action for setting any field looks to be a good idea.

Thanks.

Quoted 36 lines
Quoted 4 lines
---
 lib/librte_ethdev/rte_flow.c |  1 +

We are very close to the -rc1 date and implemention is missing. Please update.

Quoted 2 lines
 lib/librte_ethdev/rte_flow.h | 59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

[...]

Quoted 24 lines
lib/librte_ethdev/rte_flow.h +24 -0
+enum rte_flow_field_id {
+	RTE_FLOW_FIELD_NONE = 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,
+	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,
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_FIELD_TAG,
+	RTE_FLOW_FIELD_MARK,
+	RTE_FLOW_FIELD_META,
+};

I don't really like having to list all fields of the world, but it's probably better than the current situation of creating a new action for each field.

That is the idea, to get rid of the need to implement another action every time we want to modify another packet field.
Let me know about a better way if any.

#5 lore raw

07/01/2021 15:17, Alexander Kozyrev:

Quoted 34 lines
Quoted 34 lines

Tuesday, January 5, 2021 17:17, Thomas Monjalon <[email protected]>

Quoted 32 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

Quoted 4 lines
Quoted 1 line

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 4 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a few bits from the entire packet field or a big offset to move to completely different area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

Quoted 4 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it is going to be hard and cumbersome to calculate all the offsets for that. Field ID is much more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

#6 lore raw
Quoted 44 lines
Quoted 34 lines
Quoted 34 lines

Thursday, January 7, 2021 10:07, Thomas Monjalon <[email protected]>

Quoted 32 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

Quoted 4 lines
Quoted 1 line

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 2 lines
Quoted 1 line

What is the field id if an offset is given?

Quoted 7 lines
Quoted 2 lines

Field ID stays the same, you can specify a small offset to copy just a few bits from the entire packet field or a big offset to move to completely different

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for example.

Quoted 10 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it is

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is much

more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

#7 lore raw

07/01/2021 16:10, Alexander Kozyrev:

Quoted 46 lines
Quoted 46 lines
Quoted 34 lines
Quoted 34 lines

Thursday, January 7, 2021 10:07, Thomas Monjalon <[email protected]>

Quoted 32 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined below.

struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

Quoted 4 lines
Quoted 1 line

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 4 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a few bits from the entire packet field or a big offset to move to completely different

Quoted 7 lines
Quoted 5 lines

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it is

going to be

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is much

more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

We can set field and index to 0, and use only offset? Then it is a byte offset from the beginning mbuf.data?

#8 lore raw
Quoted 56 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};
Quoted 6 lines
Quoted 4 lines

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a few

bits

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

from the entire packet field or a big offset to move to completely different

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

Quoted 5 lines
Quoted 1 line

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it

is

Quoted 4 lines
Quoted 4 lines

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is much

more convenient.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

We can set field and index to 0, and use only offset?

Yes, I'm not inending to put any restrictions against that.

Quoted 1 line

Then it is a byte offset from the beginning mbuf.data?

Yes, but it is still bit offset, not byte offset.

#9 lore raw

07/01/2021 16:22, Alexander Kozyrev:

Quoted 56 lines
Quoted 56 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can be used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata or copy it into another header field directly. tag/mark/metadata can also be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};
Quoted 6 lines
Quoted 4 lines

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the tags array. The offset allows to copy a packet field value into the payload.

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a few

bits

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

from the entire packet field or a big offset to move to completely different

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Quoted 19 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but it

is

Quoted 4 lines
Quoted 4 lines

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is much

more convenient.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

We can set field and index to 0, and use only offset?

Yes, I'm not inending to put any restrictions against that.

Quoted 1 line

Then it is a byte offset from the beginning mbuf.data?

Yes, but it is still bit offset, not byte offset.

#10 lore raw
Quoted 67 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 14 lines
Quoted 14 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can

be

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata

or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

copy it into another header field directly. tag/mark/metadata can

also

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the

tags

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

array. The offset allows to copy a packet field value into the

payload.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 2 lines
Quoted 2 lines

bits

Quoted 1 line
Quoted 1 line
Quoted 1 line

from the entire packet field or a big offset to move to completely

different

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough? And it starts from the specific packet field pointed by the Field ID, correct.

Quoted 22 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but

it

Quoted 3 lines
Quoted 3 lines

is

Quoted 2 lines
Quoted 2 lines

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is

much

Quoted 13 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

We can set field and index to 0, and use only offset?

Yes, I'm not inending to put any restrictions against that.

Quoted 1 line

Then it is a byte offset from the beginning mbuf.data?

Yes, but it is still bit offset, not byte offset.

#11 lore raw

07/01/2021 17:57, Alexander Kozyrev:

Quoted 70 lines
Quoted 70 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 14 lines
Quoted 14 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can

be

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata

or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

copy it into another header field directly. tag/mark/metadata can

also

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

be used as a value to be stored in an arbitrary packet header field.

struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in the

tags

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

array. The offset allows to copy a packet field value into the

payload.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 2 lines
Quoted 2 lines

bits

Quoted 1 line
Quoted 1 line
Quoted 1 line

from the entire packet field or a big offset to move to completely

different

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough?

Yes 8KB may be too small for huge packets.
I recommend 32 bits.

Quoted 1 line

And it starts from the specific packet field pointed by the Field ID, correct.

I think it would be more useful as a global offset starting from the first bit of the packet.

Quoted 21 lines
Quoted 21 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure, but

it

Quoted 3 lines
Quoted 3 lines

is

Quoted 2 lines
Quoted 2 lines

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is

much

Quoted 13 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or offset.

We can set field and index to 0, and use only offset?

Yes, I'm not inending to put any restrictions against that.

Quoted 1 line

Then it is a byte offset from the beginning mbuf.data?

Yes, but it is still bit offset, not byte offset.

#12 lore raw
Quoted 86 lines

07/01/2021 17:57, Alexander Kozyrev:

Quoted 5 lines
Quoted 5 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 4 lines
Quoted 4 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

RTE Flows API lacks the ability to save an arbitrary header field

in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

order to use it later for advanced packet manipulations.

Examples

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include the usage of VxLAN ID after the packet is decapsulated

or

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form

any

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure

defined

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

below.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values)

can

Quoted 2 lines
Quoted 2 lines

be

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

used as both source and destination fields. This way we can save

an

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

arbitrary header field by copying its value to a

tag/mark/metadata

Quoted 2 lines
Quoted 2 lines

or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

copy it into another header field directly. tag/mark/metadata

can

Quoted 2 lines
Quoted 2 lines

also

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

be used as a value to be stored in an arbitrary packet header

field.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in

the

Quoted 18 lines
Quoted 18 lines

tags

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

array. The offset allows to copy a packet field value into the

payload.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 2 lines
Quoted 2 lines

bits

Quoted 1 line
Quoted 1 line
Quoted 1 line

from the entire packet field or a big offset to move to completely

Quoted 8 lines
Quoted 8 lines

different

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

area.

I don't understand what is an offset then.
Isn't it the byte or bit where the copy start?
Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address

for

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough?

Yes 8KB may be too small for huge packets.
I recommend 32 bits.

Sounds good, will make it 32-bit in the implementation.

Quoted 4 lines
Quoted 1 line

And it starts from the specific packet field pointed by the Field ID, correct.

I think it would be more useful as a global offset starting from the first bit of the packet.

The API gives you this flexibility when you specify None as the Field ID. But Field ID is useful when you don't want to calculate the offset by yourself. You can just say: I would like to copy IP address in the inner header (index 1), for example, and leave offset as 0 instead of trying to figure out where it is:
set copy_field width 32 src field ipv4 index 1 offset 0 dst field tag index 0 offset 0

Quoted 27 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Not really. You can use offset to jump around packet fields for sure,

but

Quoted 4 lines
Quoted 4 lines

it

Quoted 3 lines
Quoted 3 lines

is

Quoted 2 lines
Quoted 2 lines

going to be

Quoted 1 line

hard and cumbersome to calculate all the offsets for that. Field ID is

Quoted 8 lines
Quoted 8 lines

much

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

more convenient.

I think it depends for who.
For some use cases, it may be easier to pass an offset.
For some drivers, it may be more efficient to directly manage offsets.

It is possible with this RFC, driver can choose what to use: id and/or

offset.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

We can set field and index to 0, and use only offset?

Yes, I'm not inending to put any restrictions against that.

Quoted 1 line

Then it is a byte offset from the beginning mbuf.data?

Yes, but it is still bit offset, not byte offset.

#13 lore raw

07/01/2021 21:14, Alexander Kozyrev:

Quoted 97 lines
Quoted 86 lines

07/01/2021 17:57, Alexander Kozyrev:

Quoted 5 lines
Quoted 5 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 4 lines
Quoted 4 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

RTE Flows API lacks the ability to save an arbitrary header field

in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

order to use it later for advanced packet manipulations.

Examples

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include the usage of VxLAN ID after the packet is decapsulated

or

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

storing this ID inside the packet payload itself or swapping an arbitrary inner and outer packet fields.

The idea is to allow a copy of a specified number of bits form

any

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure

defined

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

below.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values)

can

Quoted 2 lines
Quoted 2 lines

be

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

used as both source and destination fields. This way we can save

an

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

arbitrary header field by copying its value to a

tag/mark/metadata

Quoted 2 lines
Quoted 2 lines

or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

copy it into another header field directly. tag/mark/metadata

can

Quoted 2 lines
Quoted 2 lines

also

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

be used as a value to be stored in an arbitrary packet header

field.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or tag/mark/metadata) to be used as a copy source or destination. The index gives access to inner packet headers or elements in

the

Quoted 18 lines
Quoted 18 lines

tags

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

array. The offset allows to copy a packet field value into the

payload.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number index. But is it also an index in the TAG array, so the name comes from it.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 3 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 2 lines
Quoted 2 lines

bits

Quoted 1 line
Quoted 1 line
Quoted 1 line

from the entire packet field or a big offset to move to completely

Quoted 8 lines
Quoted 8 lines

different

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

area.

I don't understand what is an offset then. Isn't it the byte or bit where the copy start? Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address

for

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough?

Yes 8KB may be too small for huge packets.
I recommend 32 bits.

Sounds good, will make it 32-bit in the implementation.

Quoted 2 lines
Quoted 1 line

And it starts from the specific packet field pointed by the Field ID, correct.

Quoted 7 lines
Quoted 2 lines

I think it would be more useful as a global offset starting from the first bit of the packet.

The API gives you this flexibility when you specify None as the Field ID. But Field ID is useful when you don't want to calculate the offset by yourself. You can just say: I would like to copy IP address in the inner header (index 1), for example, and leave offset as 0 instead of trying to figure out where it is:
set copy_field width 32 src field ipv4 index 1 offset 0 dst field tag index 0 offset 0

OK it makes sense.

I think you should better explain the calculations in the doxygen comments.

#14 lore raw
In reply to Thomas Monjalon
Quoted 103 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, January 7, 2021 19:06
To: Alexander Kozyrev <[email protected]>
Cc: [email protected]; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce copy_field rte flow action

07/01/2021 17:57, Alexander Kozyrev:

Quoted 9 lines
Quoted 9 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 8 lines
Quoted 8 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an arbitrary

inner and outer packet fields.

Quoted 16 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can

be

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata

or

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

copy it into another header field directly. tag/mark/metadata can

also

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

be used as a value to be stored in an arbitrary packet header

field.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or
tag/mark/metadata) to be used as a copy source or

destination.

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The index gives access to inner packet headers or elements in the

tags

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

array. The offset allows to copy a packet field value into the

payload.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number

index.

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

But is it also an index in the TAG array, so the name comes from it.

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 4 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 3 lines
Quoted 3 lines

bits

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

from the entire packet field or a big offset to move to completely

different

Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines

area.

I don't understand what is an offset then. Isn't it the byte or bit where the copy start? Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough?

Quoted 7 lines

Yes 8KB may be too small for huge packets. I recommend 32 bits.

Quoted 1 line

And it starts from the specific packet field pointed by the Field ID, correct.

I think it would be more useful as a global offset starting from the first bit of the packet.

M-m-m, sorry, I think this anchor (the first bit of the packet) is not applicable in general due to the field position in the packet is flexible and varying. For example, packet may contain VLAN tag, IP header options, TCP options, or may not, and absolute offset
(from the packet beginning) does not work well.

Hence, to unambiguously specify the desired part (as bit field) of the packet we need the following indices:
- protocol field, we do it with field enum, and field index (if any - in case if we have multiple similar items in the packet - say, inner or outer IP, or array of metadata tags)
- the bit offset in the field - to specify the beginning of our target bitfield
- the bitfield width in bits - to specify how many bits we would like to proceed

With this bitfield addressing approach we get the opportunity to manipulate with bitfields in the almost any protocol fields. For example we could copy congestion control bits from inner IP header to outer one. We can have fine handling the bits in metadata, and so on.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Theoretically we could consider defining some fixed packet structure and use offsets from there, say:
MAC_DST is 0
MAC_SRC is 6
MAC_TYPE is 12
VLAN_TAG is 14
VLAN_TYPE is 16
....

But, there are to many variations in the possible packet formats - tagged/untagged, CVLANs, IP4/6, IP options/extensions, the huge zoopark of tunnel... It would introduce and ambiguity and would require to predefine a lot of packet formats.

With best regards,
Slava

#15 lore raw

Hi

Quoted 138 lines

-----Original Message-----
From: Slava Ovsiienko <[email protected]>
Sent: Friday, January 8, 2021 2:16 PM
To: NBU-Contact-Thomas Monjalon <[email protected]>; Alexander Kozyrev <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [dpdk-dev] [RFC] ethdev: introduce copy_field rte flow action

Quoted 10 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, January 7, 2021 19:06
To: Alexander Kozyrev <[email protected]>
Cc: [email protected]; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce copy_field rte flow action

Quoted 10 lines

07/01/2021 17:57, Alexander Kozyrev:

Quoted 9 lines
Quoted 9 lines

07/01/2021 16:22, Alexander Kozyrev:

Quoted 8 lines
Quoted 8 lines

07/01/2021 16:10, Alexander Kozyrev:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Thursday, January 7, 2021 10:18, Thomas Monjalon

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

RTE Flows API lacks the ability to save an arbitrary header field in order to use it later for advanced packet manipulations. Examples include the usage of VxLAN ID after the packet is decapsulated or storing this ID inside the packet payload itself or swapping an

arbitrary

Quoted 40 lines

inner and outer packet fields.

Quoted 16 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The idea is to allow a copy of a specified number of bits form any packet header field into another header field:
RTE_FLOW_ACTION_TYPE_COPY_FIELD with the structure defined

below.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
struct rte_flow_action_copy_field {
	struct rte_flow_action_copy_data dest;
	struct rte_flow_action_copy_data src;
	uint16_t width;
};

Arbitrary header field (as well as mark, metadata or tag values) can

be

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

used as both source and destination fields. This way we can save an arbitrary header field by copying its value to a tag/mark/metadata

or

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

copy it into another header field directly. tag/mark/metadata can

also

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

be used as a value to be stored in an arbitrary packet header

field.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
struct rte_flow_action_copy_data {
	enum rte_flow_field_id field;
	uint16_t index;
	uint16_t offset;
};

The rte_flow_field_id specifies the particular packet field (or
tag/mark/metadata) to be used as a copy source or

destination.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The index gives access to inner packet headers or elements in the

tags

Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

array. The offset allows to copy a packet field value into the

payload.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

So index is in reality the layer? How is it numbered exactly?

It is a layer for packet fields, inner headers get higher number

index.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

But is it also an index in the TAG array, so the name comes from

it.

Quoted 34 lines
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Sorry it is not obvious.
Please describe the exact numbering in tunnel and VLAN cases.

Quoted 4 lines
Quoted 1 line

What is the field id if an offset is given?

Field ID stays the same, you can specify a small offset to copy just a

few

Quoted 3 lines
Quoted 3 lines

bits

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

from the entire packet field or a big offset to move to completely

different

Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines

area.

I don't understand what is an offset then. Isn't it the byte or bit where the copy start? Do you handle sizes smaller than a byte?

It is the bit offset, you can copy 20 bits out of 32 bits of IPv4 address for

example.

Now I'm confused.
You mean rte_flow_action_copy_data.offset is a bit offset?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

rte_flow_action_copy_data.offset and rte_flow_action_copy_field.width are measured in bits, right.

So the offset is limited to 16 bits?
How can it be useful? Is it an offset starting from the specified field?

Why 16? It can be up to 2^16=65536 bits. Do you think that is not enough?

Quoted 7 lines

Yes 8KB may be too small for huge packets. I recommend 32 bits.

Quoted 1 line

And it starts from the specific packet field pointed by the Field ID, correct.

I think it would be more useful as a global offset starting from the first bit of the packet.

M-m-m, sorry, I think this anchor (the first bit of the packet) is not applicable in general due to
the field position in the packet is flexible and varying. For example, packet may contain
VLAN tag, IP header options, TCP options, or may not, and absolute offset (from the packet beginning) does not work well.

Hence, to unambiguously specify the desired part (as bit field) of the packet we need the following indices:
- protocol field, we do it with field enum, and field index (if any - in case if we have multiple
similar items in the packet - say, inner or outer IP, or array of metadata tags)
- the bit offset in the field - to specify the beginning of our target bitfield
- the bitfield width in bits - to specify how many bits we would like to proceed

Quoted 8 lines

With this bitfield addressing approach we get the opportunity to manipulate with
bitfields in the almost any protocol fields. For example we could copy congestion
control bits from inner IP header to outer one. We can have fine handling the bits
in metadata, and so on.

+1

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Can we say that a field id can always be replaced by an offset?

Theoretically we could consider defining some fixed packet structure and use offsets from there, say:
MAC_DST is 0
MAC_SRC is 6
MAC_TYPE is 12
VLAN_TAG is 14
VLAN_TYPE is 16
....

Quoted 8 lines

But, there are to many variations in the possible packet formats - tagged/untagged,
CVLANs, IP4/6, IP options/extensions, the huge zoopark of tunnel... It would introduce
and ambiguity and would require to predefine a lot of packet formats.

With best regards,
Slava

Regards,
Ori