ethdev: extend modify field API
cover ethdev: extend modify field API
This petch-set extend the modify field action API to support 2 special cases.
1. Modify field when the relevant header appears multiple times inside same encapsulation level.
2. Modify Geneve option header which is specified by its "type" and "class" fields.
In current API, the header type is provided by "rte_flow_field_id" enumeration and the encapsulation level (inner/outer/tunnel) is specified by "data.level" field.
However, there is no way to specify header inside encapsulation level.
For example, for this packet:
eth / mpls / mpls / mpls / ipv4 / udp
the both second and third MPLS headers cannot be modified using this API.
Michael Baum (2):
ethdev: add GENEVE TLV option modification support
ethdev: add MPLS header modification support
app/test-pmd/cmdline_flow.c | 69 +++++++++++++++++++++++++++- doc/guides/prog_guide/rte_flow.rst | 33 +++++++++++--- lib/ethdev/rte_flow.h | 72 ++++++++++++++++++++++++++++-- 3 files changed, 165 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1
RFC 1/2 ethdev: add GENEVE TLV option modification support
Add modify field support for GENEVE option fields:
- "RTE_FLOW_FIELD_GENEVE_OPT_TYPE"
- "RTE_FLOW_FIELD_GENEVE_OPT_CLASS"
- "RTE_FLOW_FIELD_GENEVE_OPT_DATA"
Each GENEVE TLV option is identified by both its "class" and "type", so 2 new fields were added to "rte_flow_action_modify_data" structure to help specify which option to modify.
To get room for those 2 new fields, the "level" field move to use "uint8_t" which is more than enough for encapsulation level.
--- app/test-pmd/cmdline_flow.c | 47 ++++++++++++++++++++++++++- doc/guides/prog_guide/rte_flow.rst | 27 +++++++++++++--- lib/ethdev/rte_flow.h | 51 +++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +46 -1
@@ -636,11 +636,15 @@ enum index {ACTION_MODIFY_FIELD_DST_TYPE_VALUE ,ACTION_MODIFY_FIELD_DST_LEVEL ,ACTION_MODIFY_FIELD_DST_LEVEL_VALUE , +ACTION_MODIFY_FIELD_DST_TYPE_ID , +ACTION_MODIFY_FIELD_DST_CLASS_ID ,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_LEVEL_VALUE , +ACTION_MODIFY_FIELD_SRC_TYPE_ID , +ACTION_MODIFY_FIELD_SRC_CLASS_ID ,ACTION_MODIFY_FIELD_SRC_OFFSET ,ACTION_MODIFY_FIELD_SRC_VALUE , ACTION_MODIFY_FIELD_SRC_POINTER,
@@ -854,7 +858,8 @@ static const char *const modify_field_ids[] = {"ipv4_ecn" ,"ipv6_ecn" ,"gtp_psc_qfi" ,"meter_color" ,"ipv6_proto" ,"flex_item" , -"hash_result" ,NULL +"hash_result" , +"geneve_opt_type" ,"geneve_opt_class" ,"geneve_opt_data" ,NULL }; static const char *const meter_colors[] = {
@@ -2295,6 +2300,8 @@ static const enum index next_action_sample[] = {static const enum index action_modify_field_dst[] = {ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_TYPE_ID , +ACTION_MODIFY_FIELD_DST_CLASS_ID ,ACTION_MODIFY_FIELD_DST_OFFSET ,ACTION_MODIFY_FIELD_SRC_TYPE ,ZERO ,
@@ -2302,6 +2309,8 @@ static const enum index action_modify_field_dst[] = {static const enum index action_modify_field_src[] = {ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_TYPE_ID , +ACTION_MODIFY_FIELD_SRC_CLASS_ID ,ACTION_MODIFY_FIELD_SRC_OFFSET ,ACTION_MODIFY_FIELD_SRC_VALUE ,ACTION_MODIFY_FIELD_SRC_POINTER ,
@@ -6388,6 +6397,24 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { + .name = "dst_type_id", + .help = "destination field type ID", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.type)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_DST_CLASS_ID] = { + .name = "dst_class", + .help = "destination field class ID", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.class_id)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_OFFSET] = { .name = "dst_offset", .help = "destination field bit offset",
@@ -6423,6 +6450,24 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = { + .name = "src_type_id", + .help = "source field type ID", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.type)), + .call = parse_vc_conf, + }, + [ACTION_MODIFY_FIELD_SRC_CLASS_ID] = { + .name = "src_class", + .help = "source field class ID", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.class_id)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_SRC_OFFSET] = { .name = "src_offset", .help = "source field bit offset",
doc/guides/prog_guide/rte_flow.rst +22 -5
@@ -2917,23 +2917,36 @@ The immediate value ``RTE_FLOW_FIELD_VALUE`` (or a pointer to it ``RTE_FLOW_FIELD_START`` is used to point to the beginning of a packet. See ``enum rte_flow_field_id`` for the list of supported fields. -``op`` selects the operation to perform on a destination field. +``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`` +- ``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. +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. + 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). + 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. +``type`` is used to specify (along with ``class_id``) the Geneve option which +is being modified. +This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type. + +``class_id`` is used to specify (along with ``type``) the Geneve option which +is being modified. +This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type. + ``flex_handle`` is used to specify the flex item pointer which is being modified. ``flex_handle`` and ``level`` are mutually exclusive.
@@ -2991,6 +3004,10 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. +-----------------+----------------------------------------------------------+ | ``level`` | encapsulation level of a packet field or tag array index | +-----------------+----------------------------------------------------------+ + | ``type`` | geneve option type | + +-----------------+----------------------------------------------------------+ + | ``class_id`` | geneve option class ID | + +-----------------+----------------------------------------------------------+ | ``flex_handle`` | flex item handle of a packet field | +-----------------+----------------------------------------------------------+ | ``offset`` | number of bits to skip at the beginning |
lib/ethdev/rte_flow.h +50 -1
63 lines not on this page · raw message
Signature · 1 line
2.25.1
RFC 2/2 ethdev: add MPLS header modification support
In reply to Michael BaumAdd support for MPLS modify header using "RTE_FLOW_FIELD_MPLS" id.
Since MPLS heaser might appear more the one time in inner/outer/tunnel, a new field was added to "rte_flow_action_modify_data" structure in addition to "level" field.
The "sub_level" field is the index of the header inside encapsulation level. It is used for modify multiple MPLS headers in same encapsulation level.
This addition enables to modify multiple VLAN headers too, so the description of "RTE_FLOW_FIELD_VLAN_XXXX" was updated.
--- app/test-pmd/cmdline_flow.c | 24 ++++++++++++++- doc/guides/prog_guide/rte_flow.rst | 6 ++++ lib/ethdev/rte_flow.h | 47 ++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 16 deletions(-)
app/test-pmd/cmdline_flow.c +23 -1
@@ -636,6 +636,7 @@ enum index {ACTION_MODIFY_FIELD_DST_TYPE_VALUE ,ACTION_MODIFY_FIELD_DST_LEVEL ,ACTION_MODIFY_FIELD_DST_LEVEL_VALUE , +ACTION_MODIFY_FIELD_DST_SUB_LEVEL ,ACTION_MODIFY_FIELD_DST_TYPE_ID ,ACTION_MODIFY_FIELD_DST_CLASS_ID , ACTION_MODIFY_FIELD_DST_OFFSET,
@@ -643,6 +644,7 @@ enum index {ACTION_MODIFY_FIELD_SRC_TYPE_VALUE ,ACTION_MODIFY_FIELD_SRC_LEVEL ,ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE , +ACTION_MODIFY_FIELD_SRC_SUB_LEVEL ,ACTION_MODIFY_FIELD_SRC_TYPE_ID ,ACTION_MODIFY_FIELD_SRC_CLASS_ID , ACTION_MODIFY_FIELD_SRC_OFFSET,
@@ -859,7 +861,7 @@ static const char *const modify_field_ids[] = {"ipv6_proto" ,"flex_item" ,"hash_result" , -"geneve_opt_type" ,"geneve_opt_class" ,"geneve_opt_data" ,NULL +"geneve_opt_type" ,"geneve_opt_class" ,"geneve_opt_data" ,"mpls" ,NULL }; static const char *const meter_colors[] = {
@@ -2300,6 +2302,7 @@ static const enum index next_action_sample[] = {static const enum index action_modify_field_dst[] = {ACTION_MODIFY_FIELD_DST_LEVEL , +ACTION_MODIFY_FIELD_DST_SUB_LEVEL ,ACTION_MODIFY_FIELD_DST_TYPE_ID ,ACTION_MODIFY_FIELD_DST_CLASS_ID ,ACTION_MODIFY_FIELD_DST_OFFSET ,
@@ -2309,6 +2312,7 @@ static const enum index action_modify_field_dst[] = {static const enum index action_modify_field_src[] = {ACTION_MODIFY_FIELD_SRC_LEVEL , +ACTION_MODIFY_FIELD_SRC_SUB_LEVEL ,ACTION_MODIFY_FIELD_SRC_TYPE_ID ,ACTION_MODIFY_FIELD_SRC_CLASS_ID ,ACTION_MODIFY_FIELD_SRC_OFFSET ,
@@ -6397,6 +6401,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_DST_SUB_LEVEL] = { + .name = "dst_sub_level", + .help = "destination field sub level", + .next =NEXT (action_modify_field_dst, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + dst.sub_level)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_DST_TYPE_ID] = { .name = "dst_type_id", .help = "destination field type ID",
@@ -6450,6 +6463,15 @@ static const struct token token_list[] = { .call = parse_vc_modify_field_level, .comp = comp_none, }, + [ACTION_MODIFY_FIELD_SRC_SUB_LEVEL] = { + .name = "stc_sub_level", + .help = "source field sub level", + .next =NEXT (action_modify_field_src, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field, + src.sub_level)), + .call = parse_vc_conf, + }, [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = { .name = "src_type_id", .help = "source field type ID",
doc/guides/prog_guide/rte_flow.rst +6 -0
@@ -2939,6 +2939,10 @@ as well as any tag element in the tag array: For the tag array (in case of multiple tags are supported and present) ``level`` translates directly into the array index. +- ``sub_level`` is the index of the header inside encapsulation level. + It is used for modify either ``VLAN`` or ``MPLS`` headers which multiple of + them might be supported in same encapsulation level. + ``type`` is used to specify (along with ``class_id``) the Geneve option which is being modified. This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type.
@@ -3004,6 +3008,8 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}. +-----------------+----------------------------------------------------------+ | ``level`` | encapsulation level of a packet field or tag array index | +-----------------+----------------------------------------------------------+ + | ``sub_level`` | header level inside encapsulation level | + +-----------------+----------------------------------------------------------+ | ``type`` | geneve option type | +-----------------+----------------------------------------------------------+ | ``class_id`` | geneve option class ID |
lib/ethdev/rte_flow.h +32 -15
69 lines not on this page · raw message
Signature · 1 line
2.25.1