ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
As the two struct ``rte_flow_action_modify_data`` and ``rte_flow_field_data`` share the same information, the struct ``rte_flow_action_modify_data`` will be converge to the name more generic struct ``rte_flow_field_data`` in next release as well.
Suanming Mou (2):
ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 7 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 230 ++++++++--- 11 files changed, 690 insertions(+), 62 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
As the two struct ``rte_flow_action_modify_data`` and ``rte_flow_field_data`` share the same information, the struct ``rte_flow_action_modify_data`` will be converge to the name more generic struct ``rte_flow_field_data`` in next release as well.
--- app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 230 ++++++++--- 7 files changed, 605 insertions(+), 61 deletions(-)
app/test-pmd/cmdline_flow.c +405 -11
@@ -543,6 +543,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -740,13 +762,17 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; + +/** Maximum size for external pattern in struct rte_flow_field_data. */ +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -940,7 +966,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -1590,6 +1616,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2121,6 +2148,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2863,6 +2922,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -5982,6 +6059,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -6961,7 +7206,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -8404,6 +8649,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -9773,10 +10134,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -11890,6 +12251,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
@@ -12003,10 +12397,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/nics/features/default.ini +1 -0
@@ -87,6 +87,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1573,6 +1573,13 @@ Matches the packet type as defined in rte_mbuf_ptype. - ``packet_type``: L2/L3/L4 and tunnel information. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +6 -0
@@ -3841,6 +3841,12 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. Actions list ^^^^^^^^^^^^
lib/ethdev/rte_flow.c +1 -0
@@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +180 -50
248 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/2 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the pmd code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is
supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 +- drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +1 -1
@@ -63,7 +63,7 @@ New Features * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field. - + * Added support for comparing result between packet fields or value. Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
v2 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 7 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 + drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 9 +- drivers/net/mlx5/mlx5_flow_dv.c | 10 +- drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 326 ++++++++------- 13 files changed, 701 insertions(+), 169 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/3 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-)
app/test-pmd/cmdline_flow.c +1 -1
@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define ACTION_MODIFY_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3171,7 +3171,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -1121,7 +1121,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -2523,7 +2523,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2828,7 +2828,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -1446,7 +1446,7 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; }
@@ -1454,7 +1454,7 @@ mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1578,7 +1578,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5329,8 +5329,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
lib/ethdev/rte_flow.h +4 -4
@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4021,8 +4021,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
RE: [PATCH v2 1/3] ethdev: rename action modify field data structure
Quoted 6 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Tuesday, December 19, 2023 3:34 AM
Quoted 8 lines
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.Signed-off-by Suanming Mou <[email protected]>---
Best,
Ori
Andrew Rybchenko
Acked-byRe: [PATCH v2 1/3] ethdev: rename action modify field data structure
Quoted 12 lines · Ori Kam
Quoted 12 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Tuesday, December 19, 2023 3:34 AMCurrent
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Suanming Mou <[email protected]>---
Acked-by Ori Kam <[email protected]>Best,
Ori
PATCH v2 2/3 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
--- app/test-pmd/cmdline_flow.c | 414 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 322 ++++++++------- 7 files changed, 602 insertions(+), 154 deletions(-)
app/test-pmd/cmdline_flow.c +404 -10
@@ -543,6 +543,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -740,13 +762,17 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -940,7 +966,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -1590,6 +1616,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2121,6 +2148,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2863,6 +2922,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -5982,6 +6059,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -6961,7 +7206,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -8404,6 +8649,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -9773,10 +10134,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -11890,6 +12251,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
@@ -12003,10 +12397,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/nics/features/default.ini +1 -0
@@ -87,6 +87,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1573,6 +1573,13 @@ Matches the packet type as defined in rte_mbuf_ptype. - ``packet_type``: L2/L3/L4 and tunnel information. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +6 -0
@@ -3841,6 +3841,12 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. Actions list ^^^^^^^^^^^^
lib/ethdev/rte_flow.c +1 -0
@@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +178 -144
340 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH v2 2/3] ethdev: add compare item
Quoted 23 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Tuesday, December 19, 2023 3:34 AMThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)
Quoted 2 lines
Signed-off-by Suanming Mou <[email protected]>---
Best,
Ori
Re: [PATCH v2 2/3] ethdev: add compare item
In reply to Suanming MouQuoted 17 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)
Quoted 1 line
Signed-off-by Suanming Mou <[email protected]>
Just one nit below, anyway
I dislike that many line of code are moved, but it looks like it is better than keeping them in place and break order in the file.
Quoted 5 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0
doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items and their attributes, if any. · line 3849
Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +6
-0@@ -3841,6 +3841,12 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width.
Missing one more empty line before the next section.
Quoted 3 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0Actions list ^^^^^^^^^^^^
[snip]
RE: [PATCH v2 2/3] ethdev: add compare item
Hi,
Quoted 28 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, January 12, 2024 4:11 PM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ferruh Yigit <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2 2/3] ethdev: add compare itemQuoted 17 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)
Quoted 7 lines
Quoted 1 line
Signed-off-by Suanming Mou <[email protected]>Just one nit below, anyway
Acked-by Andrew Rybchenko <[email protected]>I dislike that many line of code are moved, but it looks like it is better than keeping them in place and break order in the file.
These only change once but will keep the file be clean for the coming days. Anyway, if there are others suggest that as well, I will change. Thanks.
Quoted 11 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items and their
Quoted 7 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0@@ -3841,6 +3841,12 @@ This section lists supported pattern items and theirattributes, if any.
Quoted 3 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0- ``packet_type {unsigned}``: packet type.
Quoted 8 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items and their attributes, if any. · line 3849
Quoted 6 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +6
-0+- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width.Missing one more empty line before the next section.
Thanks, will update.
Quoted 6 lines
Quoted 4 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0Actions list ^^^^^^^^^^^^[snip]
PATCH v2 3/3 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 +- drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +1 -1
@@ -63,7 +63,7 @@ New Features * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field. - + * Added support for comparing result between packet fields or value. Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH v2 3/3] net/mlx5: add compare item support
Quoted 16 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Tuesday, December 19, 2023 3:34 AM
The compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
Quoted 2 lines
Signed-off-by Suanming Mou <[email protected]>---
Best
Ori
v3 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V3:
- fix code style missing empty line in rte_flow.rst.
- fix missing the ABI change release notes.
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 8 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 + drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 9 +- drivers/net/mlx5/mlx5_flow_dv.c | 10 +- drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 326 ++++++++------- 13 files changed, 703 insertions(+), 169 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/3 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)
app/test-pmd/cmdline_flow.c +1 -1
@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define ACTION_MODIFY_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3171,7 +3171,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
doc/guides/rel_notes/release_24_03.rst +1 -0
@@ -106,6 +106,7 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data`` Known Issues ------------
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -1121,7 +1121,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -2523,7 +2523,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2828,7 +2828,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -1446,7 +1446,7 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; }
@@ -1454,7 +1454,7 @@ mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1578,7 +1578,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5329,8 +5329,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
lib/ethdev/rte_flow.h +4 -4
@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4021,8 +4021,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
Re: [PATCH v3 1/3] ethdev: rename action modify field data structure
Quoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.
ack to rename struct to use in pattern.
Quoted 18 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)app/test-pmd/cmdline_flow.c +0
-0
app/test-pmd/cmdline_flow.c enum index { · line 745
Quoted 7 lines
app/test-pmd/cmdline_flow.c +1
-1@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define ACTION_MODIFY_PATTERN_SIZE 32
What do you think to update 'ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field.
New note is not very helpful, how can we make it more useful?
Does it make sense to keep 'MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is too generic.
RE: [PATCH v3 1/3] ethdev: rename action modify field data structure
Hi,
Quoted 43 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:19 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.ack to rename struct to use in pattern.
Quoted 21 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)app/test-pmd/cmdline_flow.c +0
-0@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
Quoted 9 lines
app/test-pmd/cmdline_flow.c
Quoted 6 lines
app/test-pmd/cmdline_flow.c +0
-1-/** Maximum size for external pattern in struct
rte_flow_action_modify_data. */app/test-pmd/cmdline_flow.c +2
-0+/** Maximum size for external pattern in struct rte_flow_field_data. +*/ #define ACTION_MODIFY_PATTERN_SIZE 32What do you think to update '
ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?
Agree.
Quoted 17 lines
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
affdc8121b..40f6dcaacd100644lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. New note is not very helpful, how can we make it more useful?
Quoted 2 lines
Does it make sense to keep '
MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is too generic.
OK, sorry, the purpose is to make it generic. So next time if other ITEM or ACTION need that field, it can be used directly. Otherwise, it feels like it can only be used by 'MODIFY_FIELD' and 'COMPARE_ITEM', what do you think?
Re: [PATCH v3 1/3] ethdev: rename action modify field data structure
Quoted 74 lines · Suanming Mou
Hi,
Quoted 43 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:19 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.ack to rename struct to use in pattern.
Quoted 21 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)app/test-pmd/cmdline_flow.c +0
-0@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)Quoted 9 lines
app/test-pmd/cmdline_flow.c
Quoted 6 lines
app/test-pmd/cmdline_flow.c +0
-1-/** Maximum size for external pattern in struct
rte_flow_action_modify_data. */app/test-pmd/cmdline_flow.c +2
-0+/** Maximum size for external pattern in struct rte_flow_field_data. +*/ #define ACTION_MODIFY_PATTERN_SIZE 32What do you think to update '
ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?Agree.
Quoted 17 lines
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
affdc8121b..40f6dcaacd100644lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. New note is not very helpful, how can we make it more useful?
Quoted 6 lines
Quoted 2 lines
Does it make sense to keep '
MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is too generic.OK, sorry, the purpose is to make it generic. So next time if other ITEM or ACTION need that field, it can be used directly. Otherwise, it feels like it can only be used by '
MODIFY_FIELD' and 'COMPARE_ITEM', what do you think?
I don't have an intention to limit its usage, but to clarify usage for whoever checks the document.
"Field description for packet field." doesn't say what exactly it is and cause confusion.
Perhaps wording can be changed to say two possible usages are for 'MODIFY_FIELD' and 'COMPARE_ITEM'?
RE: [PATCH v3 1/3] ethdev: rename action modify field data structure
Quoted 101 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, February 1, 2024 6:56 PM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 57 lines · Suanming Mou
Hi,
Quoted 45 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:19 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.ack to rename struct to use in pattern.
Quoted 21 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)(quoted diff) +0
-0
b/app/test-pmd/cmdline_flow.cindexce71818705..3725e955c7100644app/test-pmd/cmdline_flow.c +0
-0@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)Quoted 9 lines
app/test-pmd/cmdline_flow.c
Quoted 6 lines
app/test-pmd/cmdline_flow.c +0
-1-/** Maximum size for external pattern in struct
rte_flow_action_modify_data. */app/test-pmd/cmdline_flow.c +2
-0+/** Maximum size for external pattern in struct rte_flow_field_data. +*/ #define ACTION_MODIFY_PATTERN_SIZE 32What do you think to update '
ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?Quoted 21 lines
Agree.
Quoted 19 lines
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
affdc8121b..40f6dcaacd100644lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. New note is not very helpful, how can we make it more useful?
Does it make sense to keep '
MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is toogeneric.
Quoted 2 lines
OK, sorry, the purpose is to make it generic. So next time if other ITEM or
ACTION need that field, it can be used directly.
Quoted 1 line
Otherwise, it feels like it can only be used by '
MODIFY_FIELD' and'
COMPARE_ITEM', what do you think?Quoted 1 line
Quoted 8 lines
I don't have an intention to limit its usage, but to clarify usage for whoever checks the document.
"Field description for packet field." doesn't say what exactly it is and cause confusion.
Perhaps wording can be changed to say two possible usages are for '
MODIFY_FIELD' and 'COMPARE_ITEM'?
Sounds good, OK, I will update.
BTW, I saw the patch apply failed, seems it is due to Raslan's branch has some extra features than your branch. So I just want to know is it OK? Or should I still base on your branch? When will the branches be synced.
Re: [PATCH v3 1/3] ethdev: rename action modify field data structure
Quoted 107 lines · Suanming Mou
Quoted 107 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, February 1, 2024 6:56 PM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 57 lines · Suanming Mou
Hi,
Quoted 45 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:19 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.ack to rename struct to use in pattern.
Quoted 21 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)(quoted diff) +0
-0
b/app/test-pmd/cmdline_flow.cindexce71818705..3725e955c7100644app/test-pmd/cmdline_flow.c +0
-0@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)Quoted 9 lines
app/test-pmd/cmdline_flow.c
Quoted 6 lines
app/test-pmd/cmdline_flow.c +0
-1-/** Maximum size for external pattern in struct
rte_flow_action_modify_data. */app/test-pmd/cmdline_flow.c +2
-0+/** Maximum size for external pattern in struct rte_flow_field_data. +*/ #define ACTION_MODIFY_PATTERN_SIZE 32What do you think to update '
ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?Quoted 21 lines
Agree.
Quoted 19 lines
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
affdc8121b..40f6dcaacd100644lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. New note is not very helpful, how can we make it more useful?
Does it make sense to keep '
MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is toogeneric.
Quoted 2 lines
OK, sorry, the purpose is to make it generic. So next time if other ITEM or
ACTION need that field, it can be used directly.
Quoted 1 line
Otherwise, it feels like it can only be used by '
MODIFY_FIELD' and'
COMPARE_ITEM', what do you think?Quoted 1 line
I don't have an intention to limit its usage, but to clarify usage for whoever checks the document.
"Field description for packet field." doesn't say what exactly it is and cause confusion.
Quoted 8 lines
Quoted 2 lines
Perhaps wording can be changed to say two possible usages are for '
MODIFY_FIELD' and 'COMPARE_ITEM'?Sounds good, OK, I will update.
BTW, I saw the patch apply failed, seems it is due to Raslan's branch has some extra features than your branch. So I just want to know is it OK? Or should I still base on your branch? When will the branches be synced.
Thanks.
Can you please rebase next version on next-net, this way we can benefit from CI checks?
RE: [PATCH v3 1/3] ethdev: rename action modify field data structure
Quoted 133 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, February 1, 2024 7:21 PM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 111 lines · Suanming Mou
Quoted 111 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, February 1, 2024 6:56 PM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 57 lines · Suanming Mou
Hi,
Quoted 45 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:19 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; NBU- Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 1/3] ethdev: rename action modify field data structureQuoted 6 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.ack to rename struct to use in pattern.
Quoted 21 lines
Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>--- app/test-pmd/cmdline_flow.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 8 ++++---- 7 files changed, 17 insertions(+), 16 deletions(-)(quoted diff) +0
-0
b/app/test-pmd/cmdline_flow.cindexce71818705..3725e955c7100644app/test-pmd/cmdline_flow.c +0
-0@@ -740,7 +740,7 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)Quoted 9 lines
app/test-pmd/cmdline_flow.c
Quoted 6 lines
app/test-pmd/cmdline_flow.c +0
-1-/** Maximum size for external pattern in struct
rte_flow_action_modify_data. */app/test-pmd/cmdline_flow.c +2
-0+/** Maximum size for external pattern in struct rte_flow_field_data. +*/ #define ACTION_MODIFY_PATTERN_SIZE 32What do you think to update '
ACTION_MODIFY_PATTERN_SIZE' here too, instead of next patch?Quoted 22 lines
Agree.
Quoted 20 lines
<...>
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3914
Quoted 11 lines
lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0
-0
affdc8121b..40f6dcaacd100644lib/ethdev/rte_flow.h +1
-1@@ -3910,9 +3910,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. New note is not very helpful, how can we make it more useful?
Does it make sense to keep '
MODIFY_FIELD' and add 'COMPARE ITEM' in next patch, to clarify the intended usage for the struct, otherwise it is toogeneric.
Quoted 3 lines
OK, sorry, the purpose is to make it generic. So next time if other ITEM or
ACTION need that field, it can be used directly.
Quoted 1 line
Otherwise, it feels like it can only be used by '
MODIFY_FIELD' and'
COMPARE_ITEM', what do you think?Quoted 1 line
I don't have an intention to limit its usage, but to clarify usage for whoever checks the document.
"Field description for packet field." doesn't say what exactly it is and cause confusion.
Quoted 6 lines
Quoted 2 lines
Perhaps wording can be changed to say two possible usages are for '
MODIFY_FIELD' and 'COMPARE_ITEM'?Sounds good, OK, I will update.
BTW, I saw the patch apply failed, seems it is due to Raslan's branch has some
extra features than your branch.
Quoted 8 lines
Quoted 1 line
So I just want to know is it OK? Or should I still base on your branch? When will
the branches be synced.
Quoted 1 line
Thanks.
Can you please rebase next version on next-net, this way we can benefit from CI checks?
OK, got it.
PATCH v3 2/3 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
--- app/test-pmd/cmdline_flow.c | 414 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 322 ++++++++------- 7 files changed, 603 insertions(+), 154 deletions(-)
app/test-pmd/cmdline_flow.c +404 -10
@@ -543,6 +543,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -740,13 +762,17 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -940,7 +966,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -1590,6 +1616,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2121,6 +2148,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2863,6 +2922,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -5982,6 +6059,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -6961,7 +7206,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -8404,6 +8649,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -9773,10 +10134,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -11890,6 +12251,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
@@ -12003,10 +12397,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/nics/features/default.ini +1 -0
@@ -87,6 +87,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1573,6 +1573,13 @@ Matches the packet type as defined in rte_mbuf_ptype. - ``packet_type``: L2/L3/L4 and tunnel information. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
@@ -3841,6 +3841,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^
lib/ethdev/rte_flow.c +1 -0
@@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +178 -144
340 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 2/3] ethdev: add compare item
Quoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some sample commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please check for it?
Quoted 11 lines
The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
<...>
app/test-pmd/cmdline_flow.c static const char *const modify_field_ops[] = { · line 969
Quoted 4 lines
app/test-pmd/cmdline_flow.c +1
-1-static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {
I wonder if this rename should be in previous patch, as it does the logical change of the modify action specific fields to more generic fields.
<...>
Quoted 7 lines
doc/guides/rel_notes/release_24_03.rst +0
-0@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin.
doc/guides/rel_notes/release_24_03.rst New Features · line 65
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +5
-0======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field.
I guess you are rebasing on some internal repo, because above NVIDIA note doesn't exist in upstream repo. Can you please rebase on latest next-net, this also helps to resolve conflict with random action in upstream repo.
<...>
Quoted 40 lines
doc/guides/rel_notes/release_24_03.rst +40
-0+/** + * Field IDs for packet field. + */ +enum rte_flow_field_id { + RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ + RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */ + RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ + RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ + RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ + RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ + RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ + RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ + RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ + RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ + RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ + RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ + RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ + RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ + RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */ + RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */ + RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ + RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */ + RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ + RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */ + RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */ + RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ + RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */ + RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ + RTE_FLOW_FIELD_TAG, /**< Tag value. */ + RTE_FLOW_FIELD_MARK, /**< Mark value. */ + RTE_FLOW_FIELD_META, /**< Metadata value. */ + RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ + RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ + RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ + RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ + RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ + RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ + RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ + RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */
doc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */ + RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */ + RTE_FLOW_FIELD_MPLS, /**< MPLS header. */ + RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */ + RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ + RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ + RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ +}; +
+1 to move the structs to keep the proper order, but not sure if it is better to do this in previous patch or this one.
Quoted 85 lines
doc/guides/rel_notes/release_24_03.rst +84
-0+/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Field description for packet field. + */ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex item handle. */ + union { + struct { + /** + * Packet encapsulation level containing + * the field to modify. + * + * - @p 0 requests the default behavior. + * Depending on the packet type, it + * can mean outermost, innermost or + * anything in between. + * + * It basically stands for the + * innermost encapsulation level. + * Modification can be performed + * according to PMD and device + * capabilities. + * + * - @p 1 requests modification to be + * performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent values request + * modification to be performed on + * the specified inner packet + * encapsulation level, from + * outermost to innermost (lower to + * higher values). + * + * Values other than @p 0 are not + * necessarily supported. + * + * @note that for MPLS field, + * encapsulation level also include + * tunnel since MPLS may appear in + * outer, inner or tunnel. + */ + uint8_t level; + union { + /** + * Tag index array inside + * encapsulation level. + * Used for VLAN, MPLS or TAG types. + */ + uint8_t tag_index; + /** + * Geneve option identifier. + * Relevant only for + * RTE_FLOW_FIELD_GENEVE_OPT_XXXX + * modification type. + */ + struct { + /** + * Geneve option type. + */ + uint8_t type; + /** + * Geneve option class. + */ + rte_be16_t class_id; + }; + }; + }; + struct rte_flow_item_flex_handle *flex_handle; + }; + /** Number of bits to skip from a field. */ + uint32_t offset; + }; + /** + * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the + * same byte order and length as in relevant rte_flow_item_xxx. + * The immediate source bitfield offset is inherited from + * the destination's one. + */
doc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ uint8_t value[16]; + /** + * Memory address for RTE_FLOW_FIELD_POINTER, memory layout + * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; + }; +}; +
I am aware that you are just moving the above struct, but it is nested too much which is making it hard to read.
As you are touching it, can we extract some structs and make this struct less nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-up patch before moving it around.
<...>
doc/guides/rel_notes/release_24_03.rst
Quoted 13 lines
doc/guides/rel_notes/release_24_03.rst +12
-0+/** + * + * RTE_FLOW_ITEM_TYPE_COMPARE + * + * Matches the packet with compare result. + * + * The operation means a compare with b result. + */ +struct rte_flow_item_compare { + enum rte_flow_item_compare_op operation; /* The compare operation. */ + struct rte_flow_field_data a; /* Field be compared. */ + struct rte_flow_field_data b; /* Field as comparator. */
Variable names 'a' and 'b' are not descriptive although it may be OK since there is no significance to the values, but other option can be 'first' and 'second', but overall not strong opinion.
RE: [PATCH v3 2/3] ethdev: add compare item
Hi,
Quoted 22 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
Quoted 6 lines
ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some sample commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please check for it?
Yes, I think we have something to do in "testpmd_funcs.rst", will update.
Quoted 16 lines
Quoted 12 lines
The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]><...>
Quoted 1 line
Quoted 6 lines
app/test-pmd/cmdline_flow.c static const char *const modify_field_ops[] = { · line 969
Quoted 3 lines
app/test-pmd/cmdline_flow.c +1
-1-static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {I wonder if this rename should be in previous patch, as it does the logical change of the modify action specific fields to more generic fields.
Agree, will adjust.
Quoted 19 lines
<...>
Quoted 16 lines
doc/guides/rel_notes/release_24_03.rst +5
-0@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.**
Quoted 6 lines
doc/guides/rel_notes/release_24_03.rst New Features · line 65
Quoted 2 lines
doc/guides/rel_notes/release_24_03.rst +0
-0* Added support for accumulating from src field to dst field.I guess you are rebasing on some internal repo, because above NVIDIA note doesn't exist in upstream repo. Can you please rebase on latest next-net, this also helps to resolve conflict with random action in upstream repo.
Will rebase and update.
Quoted 55 lines
<...>
doc/guides/rel_notes/release_24_03.rst
Quoted 6 lines
doc/guides/rel_notes/release_24_03.rst +6
-0+/** + * Field IDs for packet field. + */ +enum rte_flow_field_id { + RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ + RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address.*/
doc/guides/rel_notes/release_24_03.rst
Quoted 13 lines
doc/guides/rel_notes/release_24_03.rst +13
-0+ RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */ + RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */ + RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */ + RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */ + RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */ + RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */ + RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */ + RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */ + RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */ + RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */ + RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */ + RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */ + RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number.*/
doc/guides/rel_notes/release_24_03.rst
Quoted 1 line
doc/guides/rel_notes/release_24_03.rst +1
-0+ RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination PortNumber. */
doc/guides/rel_notes/release_24_03.rst
Quoted 2 lines
doc/guides/rel_notes/release_24_03.rst +2
-0+ RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */ + RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP AcknowledgmentNumber. */
doc/guides/rel_notes/release_24_03.rst
Quoted 2 lines
doc/guides/rel_notes/release_24_03.rst +2
-0+ RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */ + RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number.*/
doc/guides/rel_notes/release_24_03.rst
Quoted 1 line
doc/guides/rel_notes/release_24_03.rst +1
-0+ RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination PortNumber. */
doc/guides/rel_notes/release_24_03.rst
Quoted 2 lines
doc/guides/rel_notes/release_24_03.rst +2
-0+ RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */ + RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE NetworkIdentifier. */
Quoted 18 lines
doc/guides/rel_notes/release_24_03.rst +18
-0+ RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */ + RTE_FLOW_FIELD_TAG, /**< Tag value. */ + RTE_FLOW_FIELD_MARK, /**< Mark value. */ + RTE_FLOW_FIELD_META, /**< Metadata value. */ + RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ + RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ + RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ + RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ + RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ + RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */ + RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */ + RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ + RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */ + RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */ + RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */ + RTE_FLOW_FIELD_MPLS, /**< MPLS header. */ + RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */
Quoted 8 lines
doc/guides/rel_notes/release_24_03.rst
Quoted 5 lines
doc/guides/rel_notes/release_24_03.rst +5
-0+ RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */ + RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */ + RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN /**< IPv6 payload length. */ +}; ++1 to move the structs to keep the proper order, but not sure if it is better to do this in previous patch or this one.
The previous patch is just for renaming, I assume moving the struct is too much in previous patch, what do you think?
Quoted 106 lines
doc/guides/rel_notes/release_24_03.rst
Quoted 12 lines
doc/guides/rel_notes/release_24_03.rst +11
-0+/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Field description for packet field. + */ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 12 lines
doc/guides/rel_notes/release_24_03.rst +12
-0+ union { + struct { + /** + * Packet encapsulation level containing + * the field to modify. + * + * - @p 0 requests the default behavior. + * Depending on the packet type, it + * can mean outermost, innermost or + * anything in between. + * + * It basically stands for thedoc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ * innermost encapsulation level. + * Modification can be performed + * according to PMD and device + * capabilities. + * + * - @p 1 requests modification to be + * performed on the outermost packet + * encapsulation level. + * + * - @p 2 and subsequent valuesrequest
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ * modification to be performed on + * the specified inner packet + * encapsulation level, from + * outermost to innermost (lower to + * higher values). + * + * Values other than @p 0 are not + * necessarily supported. + * + * @note that for MPLS field,doc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ * encapsulation level also include + * tunnel since MPLS may appear in + * outer, inner or tunnel. + */ + uint8_t level; + union { + /** + * Tag index array inside + * encapsulation level. + * Used for VLAN, MPLS or TAGtypes.
doc/guides/rel_notes/release_24_03.rst
Quoted 6 lines
doc/guides/rel_notes/release_24_03.rst +6
-0+ */ + uint8_t tag_index; + /** + * Geneve option identifier. + * Relevant only for + *
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 11 lines
doc/guides/rel_notes/release_24_03.rst +11
-0+ * modification type. + */ + struct { + /** + * Geneve option type. + */ + uint8_t type; + /** + * Geneve option class. + */ + rte_be16_t class_id;doc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ }; + }; + }; + struct rte_flow_item_flex_handle *flex_handle; + }; + /** Number of bits to skip from a field. */ + uint32_t offset; + }; + /** + * Immediate value for RTE_FLOW_FIELD_VALUE, presented inthe
doc/guides/rel_notes/release_24_03.rst
Quoted 7 lines
doc/guides/rel_notes/release_24_03.rst +7
-0+ * same byte order and length as in relevant rte_flow_item_xxx. + * The immediate source bitfield offset is inherited from + * the destination's one. + */ + uint8_t value[16]; + /** + * Memory address for RTE_FLOW_FIELD_POINTER, memorylayout
doc/guides/rel_notes/release_24_03.rst
Quoted 8 lines
doc/guides/rel_notes/release_24_03.rst +7
-0+ * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too much which is making it hard to read.
Quoted 4 lines
As you are touching it, can we extract some structs and make this struct less nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-up patch before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any idea about this?
And if it is really expected, I believe another new thread is worth for that change, better not be in that series. Need to discuss the new struct name and other stuff. What do you think?
Quoted 14 lines
<...>
doc/guides/rel_notes/release_24_03.rst
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+/** + * + * RTE_FLOW_ITEM_TYPE_COMPARE + * + * Matches the packet with compare result. + * + * The operation means a compare with b result. + */ +struct rte_flow_item_compare { + enum rte_flow_item_compare_op operation; /* The compare operation.*/
Quoted 7 lines
doc/guides/rel_notes/release_24_03.rst
Quoted 3 lines
doc/guides/rel_notes/release_24_03.rst +2
-0+ struct rte_flow_field_data a; /* Field be compared. */ + struct rte_flow_field_data b; /* Field as comparator. */Variable names 'a' and 'b' are not descriptive although it may be OK since there is no significance to the values, but other option can be 'first' and 'second', but overall not strong opinion.
Yes, thanks for the suggestion, in fact we also discussed about the name a lot, finally we choose the widely used 'a' and 'b'
Thanks
RE: [PATCH v3 2/3] ethdev: add compare item
Hi
Quoted 37 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 18 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.Quoted 3 lines
ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some
sample
Quoted 3 lines
commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please checkfor it?
[Snip ..]
Quoted 120 lines
Quoted 13 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 12 lines
lib/ethdev/rte_flow.h +11
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Field description for packet field. +*/ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* the field to modify. +* +* - @p 0 requests the default behavior.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Depending on the packet type, it + * can mean outermost, innermostor
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet
Quoted 16 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG
Quoted 8 lines
types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2503
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 5 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* modification type. +*/ +struct { +/** +* Geneve option type.
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +uint8_t type; +/** +* Geneve option class.
Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 7 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2489
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too
much
Quoted 5 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this struct less nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-up
Quoted 7 lines
patch
Quoted 1 line
before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any idea about this?
As far as I remember, it was never discussed,
I think for this series we should keep it as is, and revise it later.
Best,
Ori
Quoted 33 lines
And if it is really expected, I believe another new thread is worth for that change, better not be in that series.
Need to discuss the new struct name and other stuff. What do you think?Quoted 13 lines
<...>
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* +* RTE_FLOW_ITEM_TYPE_COMPARE +* +* Matches the packet with compare result. +* +* The operation means a compare with b result. +*/ +struct rte_flow_item_compare { +enum rte_flow_item_compare_op operation;/* The compare operation.
Quoted 6 lines
*/
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2513
Quoted 3 lines
lib/ethdev/rte_flow.h +2
-0+struct rte_flow_field_data a;/* Field be compared. */ +struct rte_flow_field_data b;/* Field as comparator. */ Variable names 'a' and 'b' are not descriptive although it may be OK since
there is
Quoted 1 line
no significance to the values, but other option can be 'first' and 'second',
but
Quoted 1 line
overall not strong opinion.
Yes, thanks for the suggestion, in fact we also discussed about the name a lot, finally we choose the widely used 'a' and 'b'
Thanks
Re: [PATCH v3 2/3] ethdev: add compare item
Quoted 165 lines · Ori Kam
Hi
Quoted 37 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 18 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.Quoted 3 lines
ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some
sample
Quoted 3 lines
commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please checkfor it?
[Snip ..]
Quoted 123 lines
Quoted 13 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 12 lines
lib/ethdev/rte_flow.h +11
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Field description for packet field. +*/ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* the field to modify. +* +* - @p 0 requests the default behavior.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Depending on the packet type, it + * can mean outermost, innermostor
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet
Quoted 16 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG
Quoted 8 lines
types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2503
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 5 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* modification type. +*/ +struct { +/** +* Geneve option type.
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +uint8_t type; +/** +* Geneve option class.
Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 7 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2489
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too
much
Quoted 5 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this struct less nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-uppatch
Quoted 1 line
before moving it around.
Quoted 9 lines
Quoted 4 lines
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any idea about this?
As far as I remember, it was never discussed,
I think for this series we should keep it as is, and revise it later.
If you don't want to make this set more complex with this, that is OK as long as it is addressed at some point.
Quoted 36 lines
Best,
OriQuoted 33 lines
And if it is really expected, I believe another new thread is worth for that change, better not be in that series.
Need to discuss the new struct name and other stuff. What do you think?Quoted 13 lines
<...>
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* +* RTE_FLOW_ITEM_TYPE_COMPARE +* +* Matches the packet with compare result. +* +* The operation means a compare with b result. +*/ +struct rte_flow_item_compare { +enum rte_flow_item_compare_op operation;/* The compare operation.
Quoted 6 lines
*/
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2513
Quoted 3 lines
lib/ethdev/rte_flow.h +2
-0+struct rte_flow_field_data a;/* Field be compared. */ +struct rte_flow_field_data b;/* Field as comparator. */ Variable names 'a' and 'b' are not descriptive although it may be OK since
there is
Quoted 1 line
no significance to the values, but other option can be 'first' and 'second',
but
Quoted 1 line
overall not strong opinion.
Yes, thanks for the suggestion, in fact we also discussed about the name a lot, finally we choose the widely used 'a' and 'b'
Thanks
RE: [PATCH v3 2/3] ethdev: add compare item
Quoted 181 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 6:46 PM
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 33 lines · Ori Kam
Hi
Quoted 31 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 20 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.ack, above sample makes it easier to understand.
Quoted 127 lines
Quoted 6 lines
Quoted 1 line
This patch is adding testpmd commands, can you please provide some
sample
Quoted 3 lines
commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please checkfor it?
[Snip ..]
Quoted 118 lines
Quoted 13 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 12 lines
lib/ethdev/rte_flow.h +11
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Field description for packet field. +*/ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* the field to modify. +* +* - @p 0 requests the default behavior.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Depending on the packet type, it + * can mean outermost, innermostor
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet
Quoted 16 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG
Quoted 8 lines
types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2503
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 5 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* modification type. +*/ +struct { +/** +* Geneve option type.
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +uint8_t type; +/** +* Geneve option class.
Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 7 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2489
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too
much
Quoted 3 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this struct
less
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-up
Quoted 5 lines
Quoted 5 lines
patch
Quoted 1 line
before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any
idea
Quoted 3 lines
Quoted 2 lines
about this?
Quoted 7 lines
Quoted 4 lines
As far as I remember, it was never discussed,
I think for this series we should keep it as is, and revise it later.
If you don't want to make this set more complex with this, that is OK as long as it is addressed at some point.
Agree,
If you have suggestions, I will be more than happy to hear.
Quoted 38 lines
Quoted 33 lines
Best,
OriQuoted 30 lines
And if it is really expected, I believe another new thread is worth for that change, better not be in that series.
Need to discuss the new struct name and other stuff. What do you think?Quoted 13 lines
<...>
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* +* RTE_FLOW_ITEM_TYPE_COMPARE +* +* Matches the packet with compare result. +* +* The operation means a compare with b result. +*/ +struct rte_flow_item_compare { +enum rte_flow_item_compare_op operation;/* The compare operation.
Quoted 6 lines
*/
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2513
Quoted 3 lines
lib/ethdev/rte_flow.h +2
-0+struct rte_flow_field_data a;/* Field be compared. */ +struct rte_flow_field_data b;/* Field as comparator. */ Variable names 'a' and 'b' are not descriptive although it may be OK since
there is
Quoted 1 line
no significance to the values, but other option can be 'first' and 'second',
but
Quoted 1 line
overall not strong opinion.
Yes, thanks for the suggestion, in fact we also discussed about the name a
lot,
Quoted 4 lines
Quoted 3 lines
finally we choose the widely used 'a' and 'b'
Thanks
Re: [PATCH v3 2/3] ethdev: add compare item
Quoted 183 lines · Ori Kam
Quoted 183 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 6:46 PM
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 33 lines · Ori Kam
Hi
Quoted 31 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 20 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.ack, above sample makes it easier to understand.
Quoted 127 lines
Quoted 6 lines
Quoted 1 line
This patch is adding testpmd commands, can you please provide some
sample
Quoted 3 lines
commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please checkfor it?
[Snip ..]
Quoted 118 lines
Quoted 13 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 12 lines
lib/ethdev/rte_flow.h +11
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Field description for packet field. +*/ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* the field to modify. +* +* - @p 0 requests the default behavior.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Depending on the packet type, it + * can mean outermost, innermostor
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet
Quoted 16 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG
Quoted 8 lines
types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2503
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 5 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* modification type. +*/ +struct { +/** +* Geneve option type.
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +uint8_t type; +/** +* Geneve option class.
Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 7 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2489
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too
much
Quoted 3 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this struct
less
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-up
Quoted 5 lines
Quoted 5 lines
patch
Quoted 1 line
before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any
idea
Quoted 5 lines
Quoted 2 lines
about this?
As far as I remember, it was never discussed,
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
I think for this series we should keep it as is, and revise it later.
If you don't want to make this set more complex with this, that is OK as long as it is addressed at some point.
Agree,
If you have suggestions, I will be more than happy to hear.
For the struct?
Simply extracting the inner structs as named structs to reduce the nested structs, does this make sense?
RE: [PATCH v3 2/3] ethdev: add compare item
Quoted 229 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 7:54 PMQuoted 16 lines · Ori Kam
Quoted 16 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 6:46 PM
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 8 lines · Ori Kam
Hi
Quoted 6 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 2 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon
(EXTERNAL)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
<[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 5 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate
a
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some
sample
Quoted 2 lines
commands in commit log?
The more samples are better, as far as I remember there was atestpmd
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
documentation that documents the sample usages, can you please
check
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
for it?
[Snip ..]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without priornotice
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
+ *
+ * Field description for packet field.
+ */(quoted diff) +2
-0+struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID.*/
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ union { + struct { + /** Encapsulation level and tag index or flexitem
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
handle. */
Review
Quoted 4 lines
(quoted diff) +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ * the field to modify. + * + * - @p 0 requests the defaultbehavior.
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * Depending on the packettype, it
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * can mean outermost,innermost
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
or
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ * anything in between. + * + * It basically stands for the + * innermost encapsulationlevel.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * Modification can beperformed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * according to PMD anddevice
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ * capabilities. + * + * - @p 1 requestsmodification to be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * performed on theoutermost
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
packet
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ * encapsulation level. + * + * - @p 2 and subsequentvalues
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
request
Review
Quoted 1 line
(quoted diff) +1
-0+ * modification to beperformed on
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ * the specified inner packet + * encapsulation level, from + * outermost to innermost(lower to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ * higher values). + * + * Values other than @p 0 arenot
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ * necessarily supported. + * + * @note that for MPLS field, + * encapsulation level alsoinclude
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * tunnel since MPLS mayappear in
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ * outer, inner or tunnel. + */ + uint8_t level; + union { + /** + * Tag index arrayinside
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * encapsulation level. + * Used for VLAN,MPLS or
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
TAG
Quoted 5 lines
types.
Review
Quoted 4 lines
(quoted diff) +4
-0+ */ + uint8_t tag_index; + /** + * Geneve optionidentifier.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Relevant only for + *
RTE_FLOW_FIELD_GENEVE_OPT_XXXXReview
Quoted 5 lines
(quoted diff) +5
-0+ * modification type. + */ + struct { + /** + * Geneveoption
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
type.
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ */ + uint8_t type; + /** + * Geneveoption
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
class.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ */ + rte_be16_t
class_id;Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ }; + }; + }; + struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ }; + /** Number of bits to skip from a field. */ + uint32_t offset; + }; + /** + * Immediate value for RTE_FLOW_FIELD_VALUE,presented
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ * The immediate source bitfield offset is inheritedfrom
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ * the destination's one. + */ + uint8_t value[16]; + /** + * Memory address for RTE_FLOW_FIELD_POINTER,memory
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
layout
Review
Quoted 8 lines
(quoted diff) +7
-0+ * should be the same as for relevant field in the + * rte_flow_item_xxx structure. + */ + void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested
too
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
much
Quoted 3 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this
struct
Quoted 3 lines
Quoted 3 lines
less
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
nested, what do you think?
Of course it needs to be done in separate patch, as apreperation/clean-
Quoted 6 lines
Quoted 6 lines
up
Quoted 5 lines
Quoted 5 lines
patch
Quoted 1 line
before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have
any
Quoted 12 lines
Quoted 11 lines
idea
Quoted 7 lines
Quoted 2 lines
about this?
As far as I remember, it was never discussed,
I think for this series we should keep it as is, and revise it later.
If you don't want to make this set more complex with this, that is OK as long as it is addressed at some point.
Quoted 8 lines
Quoted 3 lines
Agree,
If you have suggestions, I will be more than happy to hear.For the struct?
Simply extracting the inner structs as named structs to reduce the nested structs, does this make sense?
Yes that make sense.
RE: [PATCH v3 2/3] ethdev: add compare item
In reply to Ferruh YigitQuoted 187 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, February 1, 2024 12:46 AM
To: Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 173 lines · Ori Kam
Hi
Quoted 38 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, January 31, 2024 4:48 AMHi,
Quoted 4 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 31, 2024 1:34 AM
To: Suanming Mou <[email protected]>; Ori KamQuoted 18 lines
Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v3 2/3] ethdev: add compare itemQuoted 9 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.Quoted 3 lines
ack, above sample makes it easier to understand.
This patch is adding testpmd commands, can you please provide some
sample
Quoted 4 lines
commands in commit log?
The more samples are better, as far as I remember there was a testpmd documentation that documents the sample usages, can you please checkfor it?
[Snip ..]
Quoted 129 lines
Quoted 13 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 12 lines
lib/ethdev/rte_flow.h +11
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Field description for packet field. +*/ +struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+ union { + struct { + /** + * Packet encapsulation levelcontaining
Quoted 3 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* the field to modify. +* +* - @p 0 requests the default behavior.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * Depending on the packet type, it + * can mean outermost, innermostor
Quoted 10 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet
Quoted 16 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 8 lines
lib/ethdev/rte_flow.h +8
-0+* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG
Quoted 8 lines
types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2503
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 5 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* modification type. +*/ +struct { +/** +* Geneve option type.
Quoted 4 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+*/ +uint8_t type; +/** +* Geneve option class.
Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle
*flex_handle;Quoted 6 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+ }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in
Quoted 2 lines
the
Review
Quoted 1 line
(quoted diff) +1
-0+ * same byte order and length as in relevant
rte_flow_item_xxx.Quoted 7 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 11 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2489
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +I am aware that you are just moving the above struct, but it is nested too
much
Quoted 6 lines
which is making it hard to read.
As you are touching it, can we extract some structs and make this struct less nested, what do you think?
Of course it needs to be done in separate patch, as a preperation/clean-uppatch
Quoted 1 line
before moving it around.
Agree the struct maybe a bit nested. But not sure how it was discussed before during the last new member was added... @Ori, Do you have any idea about this?
Quoted 7 lines
Quoted 4 lines
As far as I remember, it was never discussed,
I think for this series we should keep it as is, and revise it later.
If you don't want to make this set more complex with this, that is OK as long as it is addressed at some point.
OK, thanks. As it is addressed, will update v4 soon.
Quoted 39 lines
Quoted 39 lines
Best,
OriQuoted 35 lines
And if it is really expected, I believe another new thread is worth for that change, better not be in that series.
Need to discuss the new struct name and other stuff. What do you think?Quoted 13 lines
<...>
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+/** +* +* RTE_FLOW_ITEM_TYPE_COMPARE +* +* Matches the packet with compare result. +* +* The operation means a compare with b result. +*/ +struct rte_flow_item_compare { +enum rte_flow_item_compare_op operation;/* The compare operation.
Quoted 7 lines
*/
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2513
Quoted 3 lines
lib/ethdev/rte_flow.h +2
-0+struct rte_flow_field_data a;/* Field be compared. */ +struct rte_flow_field_data b;/* Field as comparator. */ Variable names 'a' and 'b' are not descriptive although it may be OK since
there is
Quoted 2 lines
no significance to the values, but other option can be 'first' and 'second',
but
Quoted 1 line
overall not strong opinion.
Yes, thanks for the suggestion, in fact we also discussed about the name a lot, finally we choose the widely used 'a' and 'b'
Thanks
PATCH v3 3/3 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 +- drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -780,6 +780,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +1 -1
@@ -63,7 +63,7 @@ New Features * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field. - + * Added support for comparing result between packet fields or value. Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
v4 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V4:
- rebase on top of the latest version.
- move ACTION_MODIFY_PATTERN_SIZE and modify_field_ids rename to first patch.
- add comparison flow create sample in testpmd_funcs.rst.
V3:
- fix code style missing empty line in rte_flow.rst.
- fix missing the ABI change release notes.
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 8 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 11 +- drivers/net/mlx5/mlx5_flow_dv.c | 12 +- drivers/net/mlx5/mlx5_flow_geneve.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 75 +++- lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 328 ++++++++------- 14 files changed, 725 insertions(+), 174 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/3 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 22 +++++++++++----------- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 8 ++++---- drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------ drivers/net/mlx5/mlx5_flow_geneve.c | 2 +- lib/ethdev/rte_flow.h | 8 ++++---- 8 files changed, 30 insertions(+), 29 deletions(-)
app/test-pmd/cmdline_flow.c +11 -11
@@ -745,13 +745,13 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +/** Maximum size for external pattern in struct rte_flow_field_data. */ +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -945,7 +945,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -7016,7 +7016,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -9828,10 +9828,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -12058,10 +12058,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3185,7 +3185,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
doc/guides/rel_notes/release_24_03.rst +1 -0
@@ -140,6 +140,7 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data`` Known Issues ------------
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +4 -4
@@ -1127,7 +1127,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -1839,7 +1839,7 @@ int mlx5_flow_geneve_tlv_option_validate(struct mlx5_priv *priv,const struct rte_flow_item *geneve_opt, struct rte_flow_error *error);int mlx5_geneve_opt_modi_field_get (struct mlx5_priv *priv, -const struct rte_flow_action_modify_data *data); +const struct rte_flow_field_data *data);struct mlx5_geneve_tlv_options_mng ; int mlx5_geneve_tlv_option_register(struct mlx5_priv *priv,
@@ -2612,7 +2612,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2919,7 +2919,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +6 -6
@@ -1460,14 +1460,14 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; } static __rte_always_inline intflow_geneve_opt_modi_field_get (struct mlx5_priv *priv, -const struct rte_flow_action_modify_data *data) +const struct rte_flow_field_data *data) {#ifdef HAVE_MLX5_HWS_SUPPORT return mlx5_geneve_opt_modi_field_get (priv, data);
@@ -1483,7 +1483,7 @@ flow_geneve_opt_modi_field_get(struct mlx5_priv *priv,static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1613,7 +1613,7 @@ mlx5_dv_modify_ipv6_traffic_class_supported(struct mlx5_priv *priv)void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5441,8 +5441,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
drivers/net/mlx5/mlx5_flow_geneve.c +1 -1
@@ -326,7 +326,7 @@ mlx5_get_geneve_option_modify_field_id(const void *dr_ctx, uint8_t type,*/ int mlx5_geneve_opt_modi_field_get (struct mlx5_priv *priv, -const struct rte_flow_action_modify_data *data) +const struct rte_flow_field_data *data) {uint16_t class = data->class_id;uint8_t type = data->type;
lib/ethdev/rte_flow.h +4 -4
@@ -3940,9 +3940,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4051,8 +4051,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
PATCH v4 2/3 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \ compare op mask le a_type mask tag a_tag_index mask 1 b_type \ mask tag b_tag_index mask 2 width mask 0xffffffff / end
flow actions_template 0 create ingress actions_template_id 1 template \
count / drop / end mask count / drop / end
flow template_table 0 create table_id 1 group 2 priority 1 ingress \
rules_number 1 pattern_template 1 actions_template 1
flow queue 0 create 0 template_table 1 pattern_template 0 \ actions_template 0 postpone no pattern compare op is le \ a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \ width is 32 / end actions count / drop / end
--- app/test-pmd/cmdline_flow.c | 394 ++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 324 +++++++++------- 7 files changed, 611 insertions(+), 145 deletions(-)
app/test-pmd/cmdline_flow.c +394 -0
@@ -548,6 +548,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -745,6 +767,10 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define FLOW_FIELD_PATTERN_SIZE 32
@@ -1597,6 +1623,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2137,6 +2164,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2879,6 +2938,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -6037,6 +6114,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -8459,6 +8704,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -11945,6 +12306,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
doc/guides/nics/features/default.ini +1 -0
@@ -88,6 +88,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1587,6 +1587,13 @@ the packet. - ``value``: Specific value to match. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -70,6 +70,11 @@ New Features * Added a fath path function ``rte_eth_tx_queue_count`` to get the number of used descriptors of a Tx queue. +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated NVIDIA mlx5 driver.**
doc/guides/testpmd_app_ug/testpmd_funcs.rst +24 -0
@@ -3859,6 +3859,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^
@@ -5323,6 +5330,23 @@ A RAW rule can be created as following using ``pattern_hex`` key and mask. pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions queue index 4 / end +Sample match with comparison rule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Match with comparsion rule can be created as following using ``compare``. + +:: + + testpmd> flow pattern_template 0 create ingress pattern_template_id 1 template compare op mask le + a_type mask tag a_tag_index mask 1 b_type mask tag b_tag_index mask 2 width mask 0xffffffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 1 template count / drop / end + mask count / drop / end + testpmd> flow template_table 0 create table_id 1 group 2 priority 1 ingress rules_number 1 + pattern_template 1 actions_template 1 + testpmd> flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 postpone no + pattern compare op is le a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 width is 32 / end + actions count / drop / end + BPF Functions --------------
lib/ethdev/rte_flow.c +1 -0
@@ -170,6 +170,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +179 -145
342 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 3/3 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 75 +++++++++++++++++++++++++- 5 files changed, 86 insertions(+), 2 deletions(-)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -816,6 +816,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -96,6 +96,8 @@ New Features * Added HW steering support for modify field ``RTE_FLOW_FIELD_GENEVE_OPT_CLASS`` flow action. * Added HW steering support for modify field ``RTE_FLOW_FIELD_GENEVE_OPT_DATA`` flow action. + * Added support for comparing result between packet fields or value. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -280,6 +280,9 @@ enum mlx5_feature_name {/* Random ITEM */ #define MLX5_FLOW_ITEM_RANDOM (1ull << 54) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 55) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -2
111 lines not on this page · raw message
Signature · 1 line
2.34.1
v5 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V5:
- rebase on top of next-net
- add sample detail for rte_flow_field.
V4:
- rebase on top of the latest version.
- move ACTION_MODIFY_PATTERN_SIZE and modify_field_ids rename to first patch.
- add comparison flow create sample in testpmd_funcs.rst.
V3:
- fix code style missing empty line in rte_flow.rst.
- fix missing the ABI change release notes.
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 8 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 9 +- drivers/net/mlx5/mlx5_flow_dv.c | 10 +- drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 332 +++++++++------- 13 files changed, 726 insertions(+), 169 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/3 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 22 +++++++++++----------- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 12 ++++++++---- 7 files changed, 31 insertions(+), 26 deletions(-)
app/test-pmd/cmdline_flow.c +11 -11
@@ -742,13 +742,13 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +/** Maximum size for external pattern in struct rte_flow_field_data. */ +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -942,7 +942,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -6986,7 +6986,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -9798,10 +9798,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -12028,10 +12028,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3185,7 +3185,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
doc/guides/rel_notes/release_24_03.rst +1 -0
@@ -124,6 +124,7 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data`` Known Issues ------------
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -1121,7 +1121,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -2523,7 +2523,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2828,7 +2828,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -1441,7 +1441,7 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; }
@@ -1449,7 +1449,7 @@ mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1573,7 +1573,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5284,8 +5284,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
lib/ethdev/rte_flow.h +8 -4
@@ -3887,6 +3887,8 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. */ enum rte_flow_field_id {RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */
@@ -3940,9 +3942,11 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. +* e.g. the packet fields used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4051,8 +4055,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
Re: [PATCH v5 1/3] ethdev: rename action modify field data structure
Quoted 9 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
<...>
doc/guides/rel_notes/release_24_03.rst ABI Changes · line 128
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +1
-0@@ -124,6 +124,7 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data``
Please put one more empty line after your change, to have two empty lines before next section.
<...>
lib/ethdev/rte_flow.h struct rte_flow_action_ethdev { · line 3892
Quoted 11 lines
lib/ethdev/rte_flow.h +2
-0@@ -3887,6 +3887,8 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE.
In this patch there is no RTE_FLOW_ITEM_TYPE_COMPARE yet, can you please update to have RTE_FLOW_ACTION_TYPE_MODIFY_FIELD in this patch and add RTE_FLOW_ITEM_TYPE_COMPARE in next patch?
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3948
Quoted 12 lines
lib/ethdev/rte_flow.h +0
-0*/ enum rte_flow_field_id {lib/ethdev/rte_flow.h +3
-1RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */@@ -3940,9 +3942,11 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. +* e.g. the packet fields used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE.
Same here, can you please mention from RTE_FLOW_ITEM_TYPE_COMPARE in next patch.
PATCH v5 2/3 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \ compare op mask le a_type mask tag a_tag_index mask 1 b_type \ mask tag b_tag_index mask 2 width mask 0xffffffff / end
flow actions_template 0 create ingress actions_template_id 1 template \
count / drop / end mask count / drop / end
flow template_table 0 create table_id 1 group 2 priority 1 ingress \
rules_number 1 pattern_template 1 actions_template 1
flow queue 0 create 0 template_table 1 pattern_template 0 \ actions_template 0 postpone no pattern compare op is le \ a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \ width is 32 / end actions count / drop / end
--- app/test-pmd/cmdline_flow.c | 394 ++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 332 +++++++++-------- 7 files changed, 615 insertions(+), 149 deletions(-)
app/test-pmd/cmdline_flow.c +394 -0
@@ -545,6 +545,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -742,6 +764,10 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define FLOW_FIELD_PATTERN_SIZE 32
@@ -1594,6 +1620,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2131,6 +2158,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2873,6 +2932,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -6007,6 +6084,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -8429,6 +8674,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -11915,6 +12276,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
doc/guides/nics/features/default.ini +1 -0
@@ -88,6 +88,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1587,6 +1587,13 @@ the packet. - ``value``: Specific value to match. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -70,6 +70,11 @@ New Features * Added a fath path function ``rte_eth_tx_queue_count`` to get the number of used descriptors of a Tx queue. +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated Atomic Rules' Arkville PMD.** * Added support for Atomic Rules' TK242 packet-capture family of devices
doc/guides/testpmd_app_ug/testpmd_funcs.rst +24 -0
@@ -3856,6 +3856,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^
@@ -5320,6 +5327,23 @@ A RAW rule can be created as following using ``pattern_hex`` key and mask. pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions queue index 4 / end +Sample match with comparison rule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Match with comparsion rule can be created as following using ``compare``. + +:: + + testpmd> flow pattern_template 0 create ingress pattern_template_id 1 template compare op mask le + a_type mask tag a_tag_index mask 1 b_type mask tag b_tag_index mask 2 width mask 0xffffffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 1 template count / drop / end + mask count / drop / end + testpmd> flow template_table 0 create table_id 1 group 2 priority 1 ingress rules_number 1 + pattern_template 1 actions_template 1 + testpmd> flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 postpone no + pattern compare op is le a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 width is 32 / end + actions count / drop / end + BPF Functions --------------
lib/ethdev/rte_flow.c +1 -0
@@ -170,6 +170,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +183 -149
350 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 2/3] ethdev: add compare item
doc/guides/testpmd_app_ug/testpmd_funcs.rst A RAW rule can be created as following using ``pattern_hex`` key and mask. · line 5334
Quoted 11 lines · Suanming Mou
Actions list
^^^^^^^^^^^^doc/guides/testpmd_app_ug/testpmd_funcs.rst +5
-0@@ -5320,6 +5327,23 @@ A RAW rule can be created as following using ``pattern_hex`` key and mask. pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions queue index 4 / end +Sample match with comparison rule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Match with comparsion rule can be created as following using ``compare``. +
s/comparsion/comparison/
PATCH v5 3/3 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 86 insertions(+)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -80,6 +80,8 @@ New Features * Added support for Atomic Rules' TK242 packet-capture family of devices with PCI IDs: ``0x1024, 0x1025, 0x1026``. + * Added support for comparing result between packet fields or value. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 3/3] net/mlx5: add compare item support
doc/guides/rel_notes/release_24_03.rst New Features · line 85
Quoted 11 lines · Suanming Mou
doc/guides/rel_notes/release_24_03.rst +2
-0@@ -80,6 +80,8 @@ New Features * Added support for Atomic Rules' TK242 packet-capture family of devices with PCI IDs: ``0x1024, 0x1025, 0x1026``. + * Added support for comparing result between packet fields or value. +
Above update is under 'Atomic Rule' block, I guess something went wrong during git rebase, can you please check?
Quoted 36 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)V5:
- rebase on top of next-net
- add sample detail forrte_flow_field.V4:
- rebase on top of the latest version.
- moveACTION_MODIFY_PATTERN_SIZEandmodify_field_idsrename to first patch.
- add comparison flow create sample intestpmd_funcs.rst.V3:
- fix code style missing empty line inrte_flow.rst.
- fix missing the ABI change release notes.V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Quoted 5 lines
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
Mostly looks good, please find comments on a few minor issues on patches.
Quoted 46 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, February 2, 2024 2:56 AM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>
Subject: Re: [PATCH v5 0/3] ethdev: addRTE_FLOW_ITEM_TYPE_COMPAREQuoted 36 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)V5:
- rebase on top of next-net
- add sample detail forrte_flow_field.V4:
- rebase on top of the latest version.
- moveACTION_MODIFY_PATTERN_SIZEandmodify_field_idsrename to first patch.
- add comparison flow create sample intestpmd_funcs.rst.V3:
- fix code style missing empty line inrte_flow.rst.
- fix missing the ABI change release notes.V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Quoted 7 lines
Quoted 5 lines
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item supportMostly looks good, please find comments on a few minor issues on patches.
Sure, thanks.
v6 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V6:
- fix typo and style issue.
- adjust flow_field description.
V5:
- rebase on top of next-net
- add sample detail for rte_flow_field.
V4:
- rebase on top of the latest version.
- move ACTION_MODIFY_PATTERN_SIZE and modify_field_ids rename to first patch.
- add comparison flow create sample in testpmd_funcs.rst.
V3:
- fix code style missing empty line in rte_flow.rst.
- fix missing the ABI change release notes.
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (3):
ethdev: rename action modify field data structure
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 9 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 9 +- drivers/net/mlx5/mlx5_flow_dv.c | 10 +- drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 332 +++++++++------- 13 files changed, 727 insertions(+), 169 deletions(-)
Signature · 1 line
2.34.1
PATCH v6 1/3 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 22 +++++++++++----------- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 2 ++ drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 10 ++++++---- 7 files changed, 30 insertions(+), 26 deletions(-)
app/test-pmd/cmdline_flow.c +11 -11
@@ -744,13 +744,13 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +/** Maximum size for external pattern in struct rte_flow_field_data. */ +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -944,7 +944,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -6995,7 +6995,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -9821,10 +9821,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -12051,10 +12051,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3185,7 +3185,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -124,6 +124,8 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data`` + Known Issues ------------
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -1121,7 +1121,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -2523,7 +2523,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2828,7 +2828,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -1441,7 +1441,7 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; }
@@ -1449,7 +1449,7 @@ mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1573,7 +1573,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5284,8 +5284,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
lib/ethdev/rte_flow.h +6 -4
@@ -3894,6 +3894,7 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. */ enum rte_flow_field_id {RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */
@@ -3947,9 +3948,10 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Field description for packet field. +* e.g. the packet fields used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4058,8 +4060,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
Re: [PATCH v6 1/3] ethdev: rename action modify field data structure
02/02/2024 01:42, Suanming Mou:
doc/guides/rel_notes/release_24_03.rst ABI Changes · line 127
Quoted 7 lines
doc/guides/rel_notes/release_24_03.rst +1
-0@@ -124,6 +124,8 @@ ABI Changes * No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct rte_flow_action_modify_data`` to be ``struct rte_flow_field_data``
It should be in API change section.
Please us past tense as recommened in comments in the file.
lib/ethdev/rte_flow.h struct rte_flow_action_ethdev { · line 3897
Quoted 7 lines
lib/ethdev/rte_flow.h +1
-0@@ -3894,6 +3894,7 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
Better to give the full name in the first line,
so no need to add a second line of comment.
[...]
lib/ethdev/rte_flow.h enum rte_flow_field_id { · line 3952
Quoted 3 lines
lib/ethdev/rte_flow.h +2
-1-* Field description for MODIFY_FIELD action. +* Field description for packet field. +* e.g. the packet fields used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.
Same here, can be one simple line with full name.
RE: [PATCH v6 1/3] ethdev: rename action modify field data structure
Hi Thomas,
Quoted 16 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, February 5, 2024 7:23 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]
Subject: Re: [PATCH v6 1/3] ethdev: rename action modify field data structure02/02/2024 01:42, Suanming Mou:
Quoted 4 lines
doc/guides/rel_notes/release_24_03.rst +0
-0@@ -124,6 +124,8 @@ ABI Changes
Quoted 7 lines
doc/guides/rel_notes/release_24_03.rst ABI Changes
Quoted 4 lines
doc/guides/rel_notes/release_24_03.rst +2
-0* No ABI change that would break compatibility with 23.11. +* ethdev: Rename the experimental ``struct +rte_flow_action_modify_data`` to be ``struct rte_flow_field_data``It should be in API change section.
Please us past tense as recommened in comments in the file.
OK.
Quoted 11 lines
lib/ethdev/rte_flow.h struct rte_flow_action_ethdev { · line 3897
Quoted 8 lines
lib/ethdev/rte_flow.h +1
-0@@ -3894,6 +3894,7 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. Better to give the full name in the first line, so no need to add a second line of comment.
So maybe " Field IDs for packet field, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD."?
But when COMPARE item to be added. It will be " Field IDs for packet field, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD and RTE_FLOW_ITEM_TYPE_COMPARE." And I assume that will still need a second line since it is too long.
Quoted 9 lines
[...]
Quoted 3 lines
- * Field description for
MODIFY_FIELDaction.
+ * Field description for packet field.
+ * e.g. the packet fields used inRTE_FLOW_ACTION_TYPE_MODIFY_FIELD.Same here, can be one simple line with full name.
Re: [PATCH v6 1/3] ethdev: rename action modify field data structure
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/ethdev/rte_flow.h +0
-0@@ -3894,6 +3894,7 @@ struct rte_flow_action_ethdev {
Quoted 8 lines
Quoted 6 lines
lib/ethdev/rte_flow.h struct rte_flow_action_ethdev { · line 3897
Quoted 3 lines
lib/ethdev/rte_flow.h +1
-0/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. Better to give the full name in the first line, so no need to add a second line of comment.
So maybe " Field IDs for packet field, used by
RTE_FLOW_ACTION_TYPE_MODIFY_FIELD."?
Yes, or just
"Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD."
Quoted 1 line
But when COMPARE item to be added. It will be " Field IDs for packet field, used by
RTE_FLOW_ACTION_TYPE_MODIFY_FIELDandRTE_FLOW_ITEM_TYPE_COMPARE." And I assume that will still need a second line since it is too long.
Yes no problem, I'm just trying to have something concise while being explicit and easy to read.
RE: [PATCH v6 1/3] ethdev: rename action modify field data structure
Hi,
Quoted 29 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, February 5, 2024 8:39 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; [email protected]; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]
Subject: Re: [PATCH v6 1/3] ethdev: rename action modify field data structureQuoted 7 lines
Quoted 7 lines
lib/ethdev/rte_flow.h struct rte_flow_action_ethdev { · line 3897
Quoted 7 lines
lib/ethdev/rte_flow.h +1
-0@@ -3894,6 +3894,7 @@ struct rte_flow_action_ethdev {/** * Field IDs for MODIFY_FIELD action. +* e.g. the packet field IDs used in
RTE_FLOW_ACTION_TYPE_MODIFY_FIELD.Quoted 5 lines
Quoted 3 lines
Better to give the full name in the first line, so no need to add a second line of comment.
So maybe " Field IDs for packet field, used by
RTE_FLOW_ACTION_TYPE_MODIFY_FIELD."?Yes, or just
"Packet header field IDs, used byRTE_FLOW_ACTION_TYPE_MODIFY_FIELD."
Quoted 7 lines
Quoted 1 line
But when COMPARE item to be added. It will be " Field IDs for packet field, used
by
RTE_FLOW_ACTION_TYPE_MODIFY_FIELDandRTE_FLOW_ITEM_TYPE_COMPARE." And I assume that will still need a second line since it is too long.Yes no problem, I'm just trying to have something concise while being explicit and easy to read.
Got it, thanks. Will update.
Quoted 2 lines
PATCH v6 2/3 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \ compare op mask le a_type mask tag a_tag_index mask 1 b_type \ mask tag b_tag_index mask 2 width mask 0xffffffff / end
flow actions_template 0 create ingress actions_template_id 1 template \
count / drop / end mask count / drop / end
flow template_table 0 create table_id 1 group 2 priority 1 ingress \
rules_number 1 pattern_template 1 actions_template 1
flow queue 0 create 0 template_table 1 pattern_template 0 \ actions_template 0 postpone no pattern compare op is le \ a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \ width is 32 / end actions count / drop / end
--- app/test-pmd/cmdline_flow.c | 394 ++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 330 ++++++++-------- 7 files changed, 615 insertions(+), 147 deletions(-)
app/test-pmd/cmdline_flow.c +394 -0
@@ -545,6 +545,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -744,6 +766,10 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define FLOW_FIELD_PATTERN_SIZE 32
@@ -1596,6 +1622,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2133,6 +2160,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2882,6 +2941,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -6016,6 +6093,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -8452,6 +8697,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -11938,6 +12299,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
doc/guides/nics/features/default.ini +1 -0
@@ -88,6 +88,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1587,6 +1587,13 @@ the packet. - ``value``: Specific value to match. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -70,6 +70,11 @@ New Features * Added a fath path function ``rte_eth_tx_queue_count`` to get the number of used descriptors of a Tx queue. +* **Added compare flow matching criteria.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare + result between the packet fields or value. + * **Updated Atomic Rules' Arkville PMD.** * Added support for Atomic Rules' TK242 packet-capture family of devices
doc/guides/testpmd_app_ug/testpmd_funcs.rst +24 -0
@@ -3856,6 +3856,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^
@@ -5324,6 +5331,23 @@ A RAW rule can be created as following using ``pattern_hex`` key and mask. pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions queue index 4 / end +Sample match with comparison rule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Match with comparison rule can be created as following using ``compare``. + +:: + + testpmd> flow pattern_template 0 create ingress pattern_template_id 1 template compare op mask le + a_type mask tag a_tag_index mask 1 b_type mask tag b_tag_index mask 2 width mask 0xffffffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 1 template count / drop / end + mask count / drop / end + testpmd> flow template_table 0 create table_id 1 group 2 priority 1 ingress rules_number 1 + pattern_template 1 actions_template 1 + testpmd> flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 postpone no + pattern compare op is le a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 width is 32 / end + actions count / drop / end + BPF Functions --------------
lib/ethdev/rte_flow.c +1 -0
@@ -170,6 +170,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +183 -147
348 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v6 2/3] ethdev: add compare item
02/02/2024 01:42, Suanming Mou:
doc/guides/rel_notes/release_24_03.rst New Features · line 73
Quoted 3 lines
doc/guides/rel_notes/release_24_03.rst +1
-0+* **Added compare flow matching criteria.**
Suggestion:
"Added flow matching with various comparisons."
Not sure how to illustrate the idea.
Quoted 1 line
+ Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare
s/compare/comparison/
Quoted 1 line
+ result between the packet fields or value.
remove "the"
lib/ethdev/rte_flow.h
Quoted 4 lines
lib/ethdev/rte_flow.h +2
-0+/** +* Matches the packet with compare result.
Match packet with various comparison types.
Quoted 53 lines
lib/ethdev/rte_flow.h +46
-0+* +* See struct rte_flow_item_compare. +*/ + RTE_FLOW_ITEM_TYPE_COMPARE, };/** @@ -2365,6 +2372,182 @@ static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { };#endif +/** +* Field IDs for packet field. +* e.g. the packet field IDs used in RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. +*/ +enum rte_flow_field_id { +RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */ +RTE_FLOW_FIELD_MAC_DST ,/**< Destination MAC Address. */ +RTE_FLOW_FIELD_MAC_SRC ,/**< Source MAC Address. */ +RTE_FLOW_FIELD_VLAN_TYPE ,/**< VLAN Tag Identifier. */ +RTE_FLOW_FIELD_VLAN_ID ,/**< VLAN Identifier. */ +RTE_FLOW_FIELD_MAC_TYPE ,/**< EtherType. */ +RTE_FLOW_FIELD_IPV4_DSCP ,/**< IPv4 DSCP. */ +RTE_FLOW_FIELD_IPV4_TTL ,/**< IPv4 Time To Live. */ +RTE_FLOW_FIELD_IPV4_SRC ,/**< IPv4 Source Address. */ +RTE_FLOW_FIELD_IPV4_DST ,/**< IPv4 Destination Address. */ +RTE_FLOW_FIELD_IPV6_DSCP ,/**< IPv6 DSCP. */ +RTE_FLOW_FIELD_IPV6_HOPLIMIT ,/**< IPv6 Hop Limit. */ +RTE_FLOW_FIELD_IPV6_SRC ,/**< IPv6 Source Address. */ +RTE_FLOW_FIELD_IPV6_DST ,/**< IPv6 Destination Address. */ +RTE_FLOW_FIELD_TCP_PORT_SRC ,/**< TCP Source Port Number. */ +RTE_FLOW_FIELD_TCP_PORT_DST ,/**< TCP Destination Port Number. */ +RTE_FLOW_FIELD_TCP_SEQ_NUM ,/**< TCP Sequence Number. */ +RTE_FLOW_FIELD_TCP_ACK_NUM ,/**< TCP Acknowledgment Number. */ +RTE_FLOW_FIELD_TCP_FLAGS ,/**< TCP Flags. */ +RTE_FLOW_FIELD_UDP_PORT_SRC ,/**< UDP Source Port Number. */ +RTE_FLOW_FIELD_UDP_PORT_DST ,/**< UDP Destination Port Number. */ +RTE_FLOW_FIELD_VXLAN_VNI ,/**< VXLAN Network Identifier. */ +RTE_FLOW_FIELD_GENEVE_VNI ,/**< GENEVE Network Identifier. */ +RTE_FLOW_FIELD_GTP_TEID ,/**< GTP Tunnel Endpoint Identifier. */ +RTE_FLOW_FIELD_TAG ,/**< Tag value. */ +RTE_FLOW_FIELD_MARK ,/**< Mark value. */ +RTE_FLOW_FIELD_META ,/**< Metadata value. */ +RTE_FLOW_FIELD_POINTER ,/**< Memory pointer. */ +RTE_FLOW_FIELD_VALUE ,/**< Immediate value. */ +RTE_FLOW_FIELD_IPV4_ECN ,/**< IPv4 ECN. */ +RTE_FLOW_FIELD_IPV6_ECN ,/**< IPv6 ECN. */ +RTE_FLOW_FIELD_GTP_PSC_QFI ,/**< GTP QFI. */ +RTE_FLOW_FIELD_METER_COLOR ,/**< Meter color marker. */ +RTE_FLOW_FIELD_IPV6_PROTO ,/**< IPv6 next header. */ +RTE_FLOW_FIELD_FLEX_ITEM ,/**< Flex item. */ +RTE_FLOW_FIELD_HASH_RESULT ,/**< Hash result. */
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2426
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+RTE_FLOW_FIELD_GENEVE_OPT_TYPE ,/**< GENEVE option type. */ +RTE_FLOW_FIELD_GENEVE_OPT_CLASS ,/**< GENEVE option class. */ +RTE_FLOW_FIELD_GENEVE_OPT_DATA ,/**< GENEVE option data. */ +RTE_FLOW_FIELD_MPLS ,/**< MPLS header. */ +RTE_FLOW_FIELD_TCP_DATA_OFFSET ,/**< TCP data offset. */ +RTE_FLOW_FIELD_IPV4_IHL ,/**< IPv4 IHL. */ +RTE_FLOW_FIELD_IPV4_TOTAL_LEN ,/**< IPv4 total length. */ +RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN ,/**< IPv6 payload length. */ +RTE_FLOW_FIELD_RANDOM /**< Random value. */ +};
You should use spaces for aligmnent of the comments.
[...]
Quoted 89 lines
lib/ethdev/rte_flow.h +89
-0+struct rte_flow_field_data { +enum rte_flow_field_id field;/**< Field or memory type ID. */ +union { +struct { +/** Encapsulation level and tag index or flex item handle. */ +union { +struct { +/** +* Packet encapsulation level containing +* the field to modify. +* +* - @p 0 requests the default behavior. +* Depending on the packet type, it +* can mean outermost, innermost or +* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet +* encapsulation level. +* +* - @p 2 and subsequent values request +* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in +* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG types. +*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +* RTE_FLOW_FIELD_GENEVE_OPT_XXXX +* modification type. +*/ +struct { +/** +* Geneve option type. +*/ +uint8_t type; +/** +* Geneve option class. +*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle *flex_handle; + }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in the +* same byte order and length as in relevant rte_flow_item_xxx. +* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout +* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; + +/**
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2534
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* Expected operation types for compare item. +*/ +enum rte_flow_item_compare_op { +RTE_FLOW_ITEM_COMPARE_EQ ,/* Compare result equal. */ +RTE_FLOW_ITEM_COMPARE_NE ,/* Compare result not equal. */ +RTE_FLOW_ITEM_COMPARE_LT ,/* Compare result less than. */ +RTE_FLOW_ITEM_COMPARE_LE ,/* Compare result less than or equal. */ +RTE_FLOW_ITEM_COMPARE_GT ,/* Compare result great than. */ +RTE_FLOW_ITEM_COMPARE_GE ,/* Compare result great than or equal. */ +};
It's a pity we cannot easily what changed because it moved. Maybe make the move in a separate patch before changing it?
RE: [PATCH v6 2/3] ethdev: add compare item
Hi Thomas,
Quoted 9 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, February 5, 2024 9:01 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]
Subject: Re: [PATCH v6 2/3] ethdev: add compare item
Quoted 8 lines
02/02/2024 01:42, Suanming Mou:
doc/guides/rel_notes/release_24_03.rst New Features · line 73
Quoted 3 lines
doc/guides/rel_notes/release_24_03.rst +1
-0+* **Added compare flow matching criteria.**Suggestion:
"Added flow matching with various comparisons."
Not sure how to illustrate the idea.
What about " Added flow matching with various comparison results." ?
Quoted 81 lines
Quoted 2 lines
+ Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare
s/compare/comparison/
Quoted 1 line
+ result between the packet fields or value.
remove "the"
lib/ethdev/rte_flow.h
Quoted 4 lines
lib/ethdev/rte_flow.h +2
-0+/** +* Matches the packet with compare result. Match packet with various comparison types.
Quoted 10 lines
lib/ethdev/rte_flow.h +4
-0+* +* See struct rte_flow_item_compare. +*/ + RTE_FLOW_ITEM_TYPE_COMPARE, };/** @@ -2365,6 +2372,182 @@ static const struct rte_flow_item_ptype
rte_flow_item_ptype_mask= { }; #endiflib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 9 lines
lib/ethdev/rte_flow.h +9
-0+/** +* Field IDs for packet field. +* e.g. the packet field IDs used in +RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. +*/ +enum rte_flow_field_id { +RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */ +RTE_FLOW_FIELD_MAC_DST ,/**< Destination MAC Address. */
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 13 lines
lib/ethdev/rte_flow.h +13
-0+RTE_FLOW_FIELD_MAC_SRC ,/**< Source MAC Address. */ +RTE_FLOW_FIELD_VLAN_TYPE ,/**< VLAN Tag Identifier. */ +RTE_FLOW_FIELD_VLAN_ID ,/**< VLAN Identifier. */ +RTE_FLOW_FIELD_MAC_TYPE ,/**< EtherType. */ +RTE_FLOW_FIELD_IPV4_DSCP ,/**< IPv4 DSCP. */ +RTE_FLOW_FIELD_IPV4_TTL ,/**< IPv4 Time To Live. */ +RTE_FLOW_FIELD_IPV4_SRC ,/**< IPv4 Source Address. */ +RTE_FLOW_FIELD_IPV4_DST ,/**< IPv4 Destination Address. */ +RTE_FLOW_FIELD_IPV6_DSCP ,/**< IPv6 DSCP. */ +RTE_FLOW_FIELD_IPV6_HOPLIMIT ,/**< IPv6 Hop Limit. */ +RTE_FLOW_FIELD_IPV6_SRC ,/**< IPv6 Source Address. */ +RTE_FLOW_FIELD_IPV6_DST ,/**< IPv6 Destination Address. */ +RTE_FLOW_FIELD_TCP_PORT_SRC ,/**< TCP Source Port Number. */
lib/ethdev/rte_flow.h
Quoted 1 line
lib/ethdev/rte_flow.h +1
-0+ RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination PortNumber. */
lib/ethdev/rte_flow.h
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+RTE_FLOW_FIELD_TCP_SEQ_NUM ,/**< TCP Sequence Number. */ + RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP AcknowledgmentNumber. */
lib/ethdev/rte_flow.h
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+RTE_FLOW_FIELD_TCP_FLAGS ,/**< TCP Flags. */ + RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number.*/
lib/ethdev/rte_flow.h
Quoted 1 line
lib/ethdev/rte_flow.h +1
-0+ RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination PortNumber. */
lib/ethdev/rte_flow.h
Quoted 2 lines
lib/ethdev/rte_flow.h +2
-0+RTE_FLOW_FIELD_VXLAN_VNI ,/**< VXLAN Network Identifier. */ + RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE NetworkIdentifier. */
Quoted 17 lines
lib/ethdev/rte_flow.h +17
-0+RTE_FLOW_FIELD_GTP_TEID ,/**< GTP Tunnel Endpoint Identifier. */ +RTE_FLOW_FIELD_TAG ,/**< Tag value. */ +RTE_FLOW_FIELD_MARK ,/**< Mark value. */ +RTE_FLOW_FIELD_META ,/**< Metadata value. */ +RTE_FLOW_FIELD_POINTER ,/**< Memory pointer. */ +RTE_FLOW_FIELD_VALUE ,/**< Immediate value. */ +RTE_FLOW_FIELD_IPV4_ECN ,/**< IPv4 ECN. */ +RTE_FLOW_FIELD_IPV6_ECN ,/**< IPv6 ECN. */ +RTE_FLOW_FIELD_GTP_PSC_QFI ,/**< GTP QFI. */ +RTE_FLOW_FIELD_METER_COLOR ,/**< Meter color marker. */ +RTE_FLOW_FIELD_IPV6_PROTO ,/**< IPv6 next header. */ +RTE_FLOW_FIELD_FLEX_ITEM ,/**< Flex item. */ +RTE_FLOW_FIELD_HASH_RESULT ,/**< Hash result. */ +RTE_FLOW_FIELD_GENEVE_OPT_TYPE ,/**< GENEVE option type. */ +RTE_FLOW_FIELD_GENEVE_OPT_CLASS ,/**< GENEVE option class. */ +RTE_FLOW_FIELD_GENEVE_OPT_DATA ,/**< GENEVE option data. */ + RTE_FLOW_FIELD_MPLS, /**< MPLS header. */
Quoted 8 lines
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2426
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+RTE_FLOW_FIELD_TCP_DATA_OFFSET ,/**< TCP data offset. */ +RTE_FLOW_FIELD_IPV4_IHL ,/**< IPv4 IHL. */ +RTE_FLOW_FIELD_IPV4_TOTAL_LEN ,/**< IPv4 total length. */ +RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN ,/**< IPv6 payload length. */ + RTE_FLOW_FIELD_RANDOM /**< Random value. */ +};You should use spaces for aligmnent of the comments.
Sorry, the original code is not using spaces.
Anyway, never mind, since I touched that, let me format them with spaces.
Quoted 105 lines
[...]
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+struct rte_flow_field_data { + enum rte_flow_field_id field; /**< Field or memory type ID. */ + union { + struct { + /** Encapsulation level and tag index or flex itemhandle. */
Quoted 12 lines
lib/ethdev/rte_flow.h +12
-0+union { +struct { +/** +* Packet encapsulation level containing +* the field to modify. +* +* - @p 0 requests the default behavior. +* Depending on the packet type, it +* can mean outermost, innermost or +* anything in between. +* +* It basically stands for the lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet +* encapsulation level. +* +* - @p 2 and subsequent values request
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* encapsulation level also include +* tunnel since MPLS may appear in +* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG types.
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { · line 2537
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +*
RTE_FLOW_FIELD_GENEVE_OPT_XXXXQuoted 11 lines
lib/ethdev/rte_flow.h +11
-0+* modification type. +*/ +struct { +/** +* Geneve option type. +*/ +uint8_t type; +/** +* Geneve option class. +*/ +rte_be16_t class_id;lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+ }; + }; + }; +struct rte_flow_item_flex_handle *flex_handle; + }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 7 lines
lib/ethdev/rte_flow.h +7
-0+* same byte order and length as in relevant rte_flow_item_xxx. +* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout
Quoted 5 lines
lib/ethdev/rte_flow.h +5
-0+* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + };lib/ethdev/rte_flow.h static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+}; + +/** +* Expected operation types for compare item. +*/ +enum rte_flow_item_compare_op { +RTE_FLOW_ITEM_COMPARE_EQ ,/* Compare result equal. */ +RTE_FLOW_ITEM_COMPARE_NE ,/* Compare result not equal. */ +RTE_FLOW_ITEM_COMPARE_LT ,/* Compare result less than. */ +RTE_FLOW_ITEM_COMPARE_LE ,/* Compare result less than or equal. */
Quoted 8 lines
lib/ethdev/rte_flow.h
Quoted 1 line
lib/ethdev/rte_flow.h +1
-0+ RTE_FLOW_ITEM_COMPARE_GT, /* Compare result great than.*/
lib/ethdev/rte_flow.h
Quoted 1 line
lib/ethdev/rte_flow.h +1
-0+ RTE_FLOW_ITEM_COMPARE_GE, /* Compare result great than orequal. */
Quoted 1 line
+};
It's a pity we cannot easily what changed because it moved. Maybe make the move in a separate patch before changing it?
Since you are the second one concern about that, I will split the move to a separate patch before.
Quoted 1 line
Re: [PATCH v6 2/3] ethdev: add compare item
05/02/2024 14:28, Suanming Mou:
Quoted 11 lines
From: Thomas Monjalon <[email protected]>
Quoted 8 lines
02/02/2024 01:42, Suanming Mou:
doc/guides/rel_notes/release_24_03.rst New Features · line 73
Quoted 3 lines
doc/guides/rel_notes/release_24_03.rst +1
-0+* **Added compare flow matching criteria.**Suggestion:
"Added flow matching with various comparisons."
Not sure how to illustrate the idea.What about " Added flow matching with various comparison results." ?
I am thinking we are comparing packet fields,
and you say we match comparison results,
which at the end is the same :)
I feel not talking about results is clearer but I may be wrong. You choose.
RE: [PATCH v6 2/3] ethdev: add compare item
Quoted 22 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, February 5, 2024 10:09 PM
To: Suanming Mou <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]
Subject: Re: [PATCH v6 2/3] ethdev: add compare item05/02/2024 14:28, Suanming Mou:
Quoted 10 lines
From: Thomas Monjalon <[email protected]>
Quoted 8 lines
02/02/2024 01:42, Suanming Mou:
doc/guides/rel_notes/release_24_03.rst New Features · line 73
Quoted 3 lines
doc/guides/rel_notes/release_24_03.rst +1
-0+* **Added compare flow matching criteria.**Suggestion:
"Added flow matching with various comparisons."
Not sure how to illustrate the idea.
Quoted 7 lines
Quoted 1 line
What about " Added flow matching with various comparison results." ?
I am thinking we are comparing packet fields, and you say we match comparison results, which at the end is the same :)
I feel not talking about results is clearer but I may be wrong. You choose.
OK, thanks, I prefer to keep results since user will be able to specify the comparison result.
Quoted 1 line
PATCH v6 3/3 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 86 insertions(+)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -80,6 +80,8 @@ New Features * Added support for Atomic Rules' TK242 packet-capture family of devices with PCI IDs: ``0x1024, 0x1025, 0x1026``. + * Added support for comparing result between packet fields or value. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
v7 cover ethdev: add RTE_FLOW_ITEM_TYPE_COMPARE
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
V7:
- Moved release notes to API.
- Optimize comment descriptions.
V6:
- fix typo and style issue.
- adjust flow_field description.
V5:
- rebase on top of next-net
- add sample detail for rte_flow_field.
V4:
- rebase on top of the latest version.
- move ACTION_MODIFY_PATTERN_SIZE and modify_field_ids rename to first patch.
- add comparison flow create sample in testpmd_funcs.rst.
V3:
- fix code style missing empty line in rte_flow.rst.
- fix missing the ABI change release notes.
V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Suanming Mou (4):
ethdev: rename action modify field data structure
ethdev: move flow field data structures
ethdev: add compare item
net/mlx5: add compare item support
app/test-pmd/cmdline_flow.c | 416 +++++++++++++++++++- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 + doc/guides/prog_guide/rte_flow.rst | 9 +- doc/guides/rel_notes/release_24_03.rst | 10 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow.h | 9 +- drivers/net/mlx5/mlx5_flow_dv.c | 10 +- drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 330 +++++++++------- 13 files changed, 726 insertions(+), 169 deletions(-)
Signature · 1 line
2.34.1
PATCH v7 1/4 ethdev: rename action modify field data structure
Current rte_flow_action_modify_data struct describes the pkt field perfectly and is used only in action.
It is planned to be used for item as well. This commit renames it to "rte_flow_field_data" making it compatible to be used by item.
--- app/test-pmd/cmdline_flow.c | 22 +++++++++++----------- doc/guides/prog_guide/rte_flow.rst | 2 +- doc/guides/rel_notes/release_24_03.rst | 3 +++ drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- lib/ethdev/rte_flow.h | 10 +++++----- 7 files changed, 30 insertions(+), 27 deletions(-)
app/test-pmd/cmdline_flow.c +11 -11
@@ -744,13 +744,13 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) -/** Maximum size for external pattern in struct rte_flow_action_modify_data. */ -#define ACTION_MODIFY_PATTERN_SIZE 32 +/** Maximum size for external pattern in struct rte_flow_field_data. */ +#define FLOW_FIELD_PATTERN_SIZE 32/** Storage size for struct rte_flow_action_modify_field including pattern. */ #define ACTION_MODIFY_SIZE \ (sizeof(struct rte_flow_action_modify_field) + \ - ACTION_MODIFY_PATTERN_SIZE) + FLOW_FIELD_PATTERN_SIZE)/** Maximum number of queue indices in struct rte_flow_action_rss. */ #define ACTION_RSS_QUEUE_NUM 128
@@ -944,7 +944,7 @@ static const char *const modify_field_ops[] = {"set" ,"add" ,"sub" ,NULL }; -static const char *const modify_field_ids[] = { +static const char *const flow_field_ids[] = {"start" ,"mac_dst" ,"mac_src" ,"vlan_type" ,"vlan_id" ,"mac_type" , "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
@@ -6995,7 +6995,7 @@ static const struct token token_list[] = { ARGS_ENTRY_ARB(0, 0), ARGS_ENTRY_ARB (sizeof(struct rte_flow_action_modify_field), - ACTION_MODIFY_PATTERN_SIZE)), + FLOW_FIELD_PATTERN_SIZE)), .call = parse_vc_conf, }, [ACTION_MODIFY_FIELD_WIDTH] = {
@@ -9821,10 +9821,10 @@ parse_vc_modify_field_id(struct context *ctx, const struct token *token,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)) +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len))break ; -if (!modify_field_ids[i]) +if (!flow_field_ids[i])return -1 ;if (!ctx->object)return len;
@@ -12051,10 +12051,10 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,RTE_SET_USED (token);if (!buf) -return RTE_DIM (modify_field_ids); -if (ent >=RTE_DIM (modify_field_ids) -1 ) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 )return -1 ; - name = modify_field_ids[ent]; + name = flow_field_ids[ent];if (ctx->curr ==ACTION_MODIFY_FIELD_SRC_TYPE || (strcmp (name,"pointer" ) &&strcmp (name,"value" )))return strlcpy (buf, name, size);
doc/guides/prog_guide/rte_flow.rst +1 -1
@@ -3185,7 +3185,7 @@ destination offset as ``48``, and provide immediate value ``0xXXXX85XX``. | ``width`` | number of bits to use | +---------------+-------------------------+ -.. _table_rte_flow_action_modify_data: +.. _table_rte_flow_field_data: .. table:: destination/source field definition
doc/guides/rel_notes/release_24_03.rst +3 -0
@@ -106,6 +106,9 @@ API Changes * gso: ``rte_gso_segment`` now returns -ENOTSUP for unknown protocols. +* ethdev: Renamed structure ``rte_flow_action_modify_data`` to be + ``rte_flow_field_data`` for more generic usage. + ABI Changes -----------
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -2493,7 +2493,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* Validate the level value for modify field action. * * @param[in] data -* Pointer to the rte_flow_action_modify_data structure either src or dst. +* Pointer to the rte_flow_field_data structure either src or dst. * @param[out] error * Pointer to error structure. *
@@ -2501,7 +2501,7 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ int -flow_validate_modify_field_level (const struct rte_flow_action_modify_data *data, +flow_validate_modify_field_level (const struct rte_flow_field_data *data,struct rte_flow_error *error) {if (data->level ==0 )
drivers/net/mlx5/mlx5_flow.h +3 -3
@@ -1121,7 +1121,7 @@ flow_items_to_tunnel(const struct rte_flow_item items[])* Tag array index. */ static inline uint8_t -flow_tag_index_get (const struct rte_flow_action_modify_data *data) +flow_tag_index_get (const struct rte_flow_field_data *data) {return data->tag_index ? data->tag_index : data->level; }
@@ -2523,7 +2523,7 @@ int mlx5_flow_validate_action_default_miss(uint64_t action_flags,const struct rte_flow_attr *attr, struct rte_flow_error *error);int flow_validate_modify_field_level - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask,
@@ -2828,7 +2828,7 @@ size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);int flow_dv_convert_encap_data (const struct rte_flow_item *items,uint8_t *buf,size_t *size,struct rte_flow_error *error);void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -1441,7 +1441,7 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_mas } static __rte_always_inline enum mlx5_modification_field -mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +mlx5_mpls_modi_field_get (const struct rte_flow_field_data *data) {return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; }
@@ -1449,7 +1449,7 @@ mlx5_mpls_modi_field_get(const struct rte_flow_action_modify_data *data)static void mlx5_modify_flex_item (const struct rte_eth_dev *dev,const struct mlx5_flex_item *flex, -const struct rte_flow_action_modify_data *data, +const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width) {
@@ -1573,7 +1573,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,void mlx5_flow_field_id_to_modify_info - (const struct rte_flow_action_modify_data *data, + (const struct rte_flow_field_data *data,struct field_modify_info *info,uint32_t *mask,uint32_t width,struct rte_eth_dev *dev,const struct rte_flow_attr *attr,struct rte_flow_error *error)
@@ -5284,8 +5284,8 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_sh_config *config = &priv->sh->config;struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *conf = action->conf; -const struct rte_flow_action_modify_data *src_data = &conf->src; -const struct rte_flow_action_modify_data *dst_data = &conf->dst; +const struct rte_flow_field_data *src_data = &conf->src; +const struct rte_flow_field_data *dst_data = &conf->dst;uint32_t dst_width, src_width, width = conf->width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);
lib/ethdev/rte_flow.h +5 -5
@@ -3893,7 +3893,7 @@ struct rte_flow_action_ethdev { };/** -* Field IDs for MODIFY_FIELD action. +* Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. */ enum rte_flow_field_id {RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */
@@ -3947,9 +3947,9 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Field description for MODIFY_FIELD action. +* Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. */ -struct rte_flow_action_modify_data { +struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ union { struct {
@@ -4058,8 +4058,8 @@ enum rte_flow_modify_op {*/ struct rte_flow_action_modify_field {enum rte_flow_modify_op operation;/**< Operation to perform. */ -struct rte_flow_action_modify_data dst;/**< Destination field. */ -struct rte_flow_action_modify_data src;/**< Source field. */ +struct rte_flow_field_data dst;/**< Destination field. */ +struct rte_flow_field_data src;/**< Source field. */ uint32_t width;/**< Number of bits to use from a source field. */ };
Signature · 1 line
2.34.1
Re: [PATCH v7 1/4] ethdev: rename action modify field data structure
Quoted 10 lines · Suanming Mou
Current
rte_flow_action_modify_datastruct describes the pkt field perfectly and is used only in action.It is planned to be used for item as well. This commit renames it to "
rte_flow_field_data" making it compatible to be used by item.Signed-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
PATCH v7 2/4 ethdev: move flow field data structures
In reply to Suanming MouAs flow field relevant data structures will be used by both actions and items, this commit moves the relevant data structures up to item parts.
--- lib/ethdev/rte_flow.h | 290 +++++++++++++++++++++--------------------- 1 file changed, 145 insertions(+), 145 deletions(-)
lib/ethdev/rte_flow.h +145 -145
@@ -2365,6 +2365,151 @@ static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { };#endif +/** +* Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. +*/ +enum rte_flow_field_id { +RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */ +RTE_FLOW_FIELD_MAC_DST ,/**< Destination MAC Address. */ +RTE_FLOW_FIELD_MAC_SRC ,/**< Source MAC Address. */ +RTE_FLOW_FIELD_VLAN_TYPE ,/**< VLAN Tag Identifier. */ +RTE_FLOW_FIELD_VLAN_ID ,/**< VLAN Identifier. */ +RTE_FLOW_FIELD_MAC_TYPE ,/**< EtherType. */ +RTE_FLOW_FIELD_IPV4_DSCP ,/**< IPv4 DSCP. */ +RTE_FLOW_FIELD_IPV4_TTL ,/**< IPv4 Time To Live. */ +RTE_FLOW_FIELD_IPV4_SRC ,/**< IPv4 Source Address. */ +RTE_FLOW_FIELD_IPV4_DST ,/**< IPv4 Destination Address. */ +RTE_FLOW_FIELD_IPV6_DSCP ,/**< IPv6 DSCP. */ +RTE_FLOW_FIELD_IPV6_HOPLIMIT ,/**< IPv6 Hop Limit. */ +RTE_FLOW_FIELD_IPV6_SRC ,/**< IPv6 Source Address. */ +RTE_FLOW_FIELD_IPV6_DST ,/**< IPv6 Destination Address. */ +RTE_FLOW_FIELD_TCP_PORT_SRC ,/**< TCP Source Port Number. */ +RTE_FLOW_FIELD_TCP_PORT_DST ,/**< TCP Destination Port Number. */ +RTE_FLOW_FIELD_TCP_SEQ_NUM ,/**< TCP Sequence Number. */ +RTE_FLOW_FIELD_TCP_ACK_NUM ,/**< TCP Acknowledgment Number. */ +RTE_FLOW_FIELD_TCP_FLAGS ,/**< TCP Flags. */ +RTE_FLOW_FIELD_UDP_PORT_SRC ,/**< UDP Source Port Number. */ +RTE_FLOW_FIELD_UDP_PORT_DST ,/**< UDP Destination Port Number. */ +RTE_FLOW_FIELD_VXLAN_VNI ,/**< VXLAN Network Identifier. */ +RTE_FLOW_FIELD_GENEVE_VNI ,/**< GENEVE Network Identifier. */ +RTE_FLOW_FIELD_GTP_TEID ,/**< GTP Tunnel Endpoint Identifier. */ +RTE_FLOW_FIELD_TAG ,/**< Tag value. */ +RTE_FLOW_FIELD_MARK ,/**< Mark value. */ +RTE_FLOW_FIELD_META ,/**< Metadata value. */ +RTE_FLOW_FIELD_POINTER ,/**< Memory pointer. */ +RTE_FLOW_FIELD_VALUE ,/**< Immediate value. */ +RTE_FLOW_FIELD_IPV4_ECN ,/**< IPv4 ECN. */ +RTE_FLOW_FIELD_IPV6_ECN ,/**< IPv6 ECN. */ +RTE_FLOW_FIELD_GTP_PSC_QFI ,/**< GTP QFI. */ +RTE_FLOW_FIELD_METER_COLOR ,/**< Meter color marker. */ +RTE_FLOW_FIELD_IPV6_PROTO ,/**< IPv6 next header. */ +RTE_FLOW_FIELD_FLEX_ITEM ,/**< Flex item. */ +RTE_FLOW_FIELD_HASH_RESULT ,/**< Hash result. */ +RTE_FLOW_FIELD_GENEVE_OPT_TYPE ,/**< GENEVE option type. */ +RTE_FLOW_FIELD_GENEVE_OPT_CLASS ,/**< GENEVE option class. */ +RTE_FLOW_FIELD_GENEVE_OPT_DATA ,/**< GENEVE option data. */ +RTE_FLOW_FIELD_MPLS ,/**< MPLS header. */ +RTE_FLOW_FIELD_TCP_DATA_OFFSET ,/**< TCP data offset. */ +RTE_FLOW_FIELD_IPV4_IHL ,/**< IPv4 IHL. */ +RTE_FLOW_FIELD_IPV4_TOTAL_LEN ,/**< IPv4 total length. */ +RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN ,/**< IPv6 payload length. */ +RTE_FLOW_FIELD_RANDOM /**< Random value. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. +*/ +struct rte_flow_field_data { +enum rte_flow_field_id field;/**< Field or memory type ID. */ +union { +struct { +/** Encapsulation level and tag index or flex item handle. */ +union { +struct { +/** +* Packet encapsulation level containing +* the field to modify. +* +* - @p 0 requests the default behavior. +* Depending on the packet type, it +* can mean outermost, innermost or +* anything in between. +* +* It basically stands for the +* innermost encapsulation level. +* Modification can be performed +* according to PMD and device +* capabilities. +* +* - @p 1 requests modification to be +* performed on the outermost packet +* encapsulation level. +* +* - @p 2 and subsequent values request +* modification to be performed on +* the specified inner packet +* encapsulation level, from +* outermost to innermost (lower to +* higher values). +* +* Values other than @p 0 are not +* necessarily supported. +* +* @note that for MPLS field, +* encapsulation level also include +* tunnel since MPLS may appear in +* outer, inner or tunnel. +*/ +uint8_t level; +union { +/** +* Tag index array inside +* encapsulation level. +* Used for VLAN, MPLS or TAG types. +*/ +uint8_t tag_index; +/** +* Geneve option identifier. +* Relevant only for +* RTE_FLOW_FIELD_GENEVE_OPT_XXXX +* modification type. +*/ +struct { +/** +* Geneve option type. +*/ +uint8_t type; +/** +* Geneve option class. +*/ +rte_be16_t class_id; + }; + }; + }; +struct rte_flow_item_flex_handle *flex_handle; + }; +/** Number of bits to skip from a field. */ +uint32_t offset; + }; +/** +* Immediate value for RTE_FLOW_FIELD_VALUE, presented in the +* same byte order and length as in relevant rte_flow_item_xxx. +* The immediate source bitfield offset is inherited from +* the destination's one. +*/ +uint8_t value[16 ]; +/** +* Memory address for RTE_FLOW_FIELD_POINTER, memory layout +* should be the same as for relevant field in the +* rte_flow_item_xxx structure. +*/ +void *pvalue; + }; +}; +/** * Action types. *
@@ -3892,151 +4037,6 @@ struct rte_flow_action_ethdev {uint16_t port_id;/**< ethdev port ID */ }; -/** -* Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. -*/ -enum rte_flow_field_id { -RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */ -RTE_FLOW_FIELD_MAC_DST ,/**< Destination MAC Address. */ -RTE_FLOW_FIELD_MAC_SRC ,/**< Source MAC Address. */ -RTE_FLOW_FIELD_VLAN_TYPE ,/**< VLAN Tag Identifier. */ -RTE_FLOW_FIELD_VLAN_ID ,/**< VLAN Identifier. */ -RTE_FLOW_FIELD_MAC_TYPE ,/**< EtherType. */ -RTE_FLOW_FIELD_IPV4_DSCP ,/**< IPv4 DSCP. */ -RTE_FLOW_FIELD_IPV4_TTL ,/**< IPv4 Time To Live. */ -RTE_FLOW_FIELD_IPV4_SRC ,/**< IPv4 Source Address. */ -RTE_FLOW_FIELD_IPV4_DST ,/**< IPv4 Destination Address. */ -RTE_FLOW_FIELD_IPV6_DSCP ,/**< IPv6 DSCP. */ -RTE_FLOW_FIELD_IPV6_HOPLIMIT ,/**< IPv6 Hop Limit. */ -RTE_FLOW_FIELD_IPV6_SRC ,/**< IPv6 Source Address. */ -RTE_FLOW_FIELD_IPV6_DST ,/**< IPv6 Destination Address. */ -RTE_FLOW_FIELD_TCP_PORT_SRC ,/**< TCP Source Port Number. */ -RTE_FLOW_FIELD_TCP_PORT_DST ,/**< TCP Destination Port Number. */ -RTE_FLOW_FIELD_TCP_SEQ_NUM ,/**< TCP Sequence Number. */ -RTE_FLOW_FIELD_TCP_ACK_NUM ,/**< TCP Acknowledgment Number. */ -RTE_FLOW_FIELD_TCP_FLAGS ,/**< TCP Flags. */ -RTE_FLOW_FIELD_UDP_PORT_SRC ,/**< UDP Source Port Number. */ -RTE_FLOW_FIELD_UDP_PORT_DST ,/**< UDP Destination Port Number. */ -RTE_FLOW_FIELD_VXLAN_VNI ,/**< VXLAN Network Identifier. */ -RTE_FLOW_FIELD_GENEVE_VNI ,/**< GENEVE Network Identifier. */ -RTE_FLOW_FIELD_GTP_TEID ,/**< GTP Tunnel Endpoint Identifier. */ -RTE_FLOW_FIELD_TAG ,/**< Tag value. */ -RTE_FLOW_FIELD_MARK ,/**< Mark value. */ -RTE_FLOW_FIELD_META ,/**< Metadata value. */ -RTE_FLOW_FIELD_POINTER ,/**< Memory pointer. */ -RTE_FLOW_FIELD_VALUE ,/**< Immediate value. */ -RTE_FLOW_FIELD_IPV4_ECN ,/**< IPv4 ECN. */ -RTE_FLOW_FIELD_IPV6_ECN ,/**< IPv6 ECN. */ -RTE_FLOW_FIELD_GTP_PSC_QFI ,/**< GTP QFI. */ -RTE_FLOW_FIELD_METER_COLOR ,/**< Meter color marker. */ -RTE_FLOW_FIELD_IPV6_PROTO ,/**< IPv6 next header. */ -RTE_FLOW_FIELD_FLEX_ITEM ,/**< Flex item. */ -RTE_FLOW_FIELD_HASH_RESULT ,/**< Hash result. */ -RTE_FLOW_FIELD_GENEVE_OPT_TYPE ,/**< GENEVE option type. */ -RTE_FLOW_FIELD_GENEVE_OPT_CLASS ,/**< GENEVE option class. */ -RTE_FLOW_FIELD_GENEVE_OPT_DATA ,/**< GENEVE option data. */ -RTE_FLOW_FIELD_MPLS ,/**< MPLS header. */ -RTE_FLOW_FIELD_TCP_DATA_OFFSET ,/**< TCP data offset. */ -RTE_FLOW_FIELD_IPV4_IHL ,/**< IPv4 IHL. */ -RTE_FLOW_FIELD_IPV4_TOTAL_LEN ,/**< IPv4 total length. */ -RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN ,/**< IPv6 payload length. */ -RTE_FLOW_FIELD_RANDOM /**< Random value. */ -}; - -/** -* @warning -* @b EXPERIMENTAL: this structure may change without prior notice -* -* Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. -*/ -struct rte_flow_field_data { -enum rte_flow_field_id field;/**< Field or memory type ID. */ -union { -struct { -/** Encapsulation level and tag index or flex item handle. */ -union { -struct { -/** -* Packet encapsulation level containing -* the field to modify. -* -* - @p 0 requests the default behavior. -* Depending on the packet type, it -* can mean outermost, innermost or -* anything in between. -* -* It basically stands for the -* innermost encapsulation level. -* Modification can be performed -* according to PMD and device -* capabilities. -* -* - @p 1 requests modification to be -* performed on the outermost packet -* encapsulation level. -* -* - @p 2 and subsequent values request -* modification to be performed on -* the specified inner packet -* encapsulation level, from -* outermost to innermost (lower to -* higher values). -* -* Values other than @p 0 are not -* necessarily supported. -* -* @note that for MPLS field, -* encapsulation level also include -* tunnel since MPLS may appear in -* outer, inner or tunnel. -*/ -uint8_t level; -union { -/** -* Tag index array inside -* encapsulation level. -* Used for VLAN, MPLS or TAG types. -*/ -uint8_t tag_index; -/** -* Geneve option identifier. -* Relevant only for -* RTE_FLOW_FIELD_GENEVE_OPT_XXXX -* modification type. -*/ -struct { -/** -* Geneve option type. -*/ -uint8_t type; -/** -* Geneve option class. -*/ -rte_be16_t class_id; - }; - }; - }; -struct rte_flow_item_flex_handle *flex_handle; - }; -/** Number of bits to skip from a field. */ -uint32_t offset; - }; -/** -* Immediate value for RTE_FLOW_FIELD_VALUE, presented in the -* same byte order and length as in relevant rte_flow_item_xxx. -* The immediate source bitfield offset is inherited from -* the destination's one. -*/ -uint8_t value[16 ]; -/** -* Memory address for RTE_FLOW_FIELD_POINTER, memory layout -* should be the same as for relevant field in the -* rte_flow_item_xxx structure. -*/ -void *pvalue; - }; -}; -/** * Operation types for MODIFY_FIELD action. */
Signature · 1 line
2.34.1
Re: [PATCH v7 2/4] ethdev: move flow field data structures
Quoted 5 lines · Suanming Mou
As flow field relevant data structures will be used by both actions and items, this commit moves the relevant data structures up to item parts.
Signed-off-by Suanming Mou <[email protected]>
PATCH v7 3/4 ethdev: add compare item
In reply to Suanming MouThe new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \ compare op mask le a_type mask tag a_tag_index mask 1 b_type \ mask tag b_tag_index mask 2 width mask 0xffffffff / end
flow actions_template 0 create ingress actions_template_id 1 template \
count / drop / end mask count / drop / end
flow template_table 0 create table_id 1 group 2 priority 1 ingress \
rules_number 1 pattern_template 1 actions_template 1
flow queue 0 create 0 template_table 1 pattern_template 0 \ actions_template 0 postpone no pattern compare op is le \ a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \ width is 32 / end actions count / drop / end
--- app/test-pmd/cmdline_flow.c | 394 ++++++++++++++++++++ doc/guides/nics/features/default.ini | 1 + doc/guides/prog_guide/rte_flow.rst | 7 + doc/guides/rel_notes/release_24_03.rst | 5 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 40 +- 7 files changed, 470 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +394 -0
@@ -545,6 +545,28 @@ enum index {ITEM_PTYPE ,ITEM_PTYPE_VALUE ,ITEM_NSH , +ITEM_COMPARE , +ITEM_COMPARE_OP , +ITEM_COMPARE_OP_VALUE , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_TYPE_VALUE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_LEVEL_VALUE , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_TYPE_VALUE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_LEVEL_VALUE , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH ,/* Validate/create actions. */ ACTIONS,
@@ -744,6 +766,10 @@ enum index {#define ITEM_RAW_SIZE \ (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE) +static const char *const compare_ops[] = { +"eq" ,"ne" ,"lt" ,"le" ,"gt" ,"ge" ,NULL +}; +/** Maximum size for external pattern in struct rte_flow_field_data. */ #define FLOW_FIELD_PATTERN_SIZE 32
@@ -1596,6 +1622,7 @@ static const enum index next_item[] = {ITEM_IB_BTH ,ITEM_PTYPE ,ITEM_NSH , +ITEM_COMPARE ,END_SET , ZERO, };
@@ -2133,6 +2160,38 @@ static const enum index item_nsh[] = { ZERO, }; +static const enum index item_compare_field[] = { +ITEM_COMPARE_OP , +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_NEXT , +ZERO , +}; + +static const enum index compare_field_a[] = { +ITEM_COMPARE_FIELD_A_TYPE , +ITEM_COMPARE_FIELD_A_LEVEL , +ITEM_COMPARE_FIELD_A_TAG_INDEX , +ITEM_COMPARE_FIELD_A_TYPE_ID , +ITEM_COMPARE_FIELD_A_CLASS_ID , +ITEM_COMPARE_FIELD_A_OFFSET , +ITEM_COMPARE_FIELD_B_TYPE , +ZERO , +}; + +static const enum index compare_field_b[] = { +ITEM_COMPARE_FIELD_B_TYPE , +ITEM_COMPARE_FIELD_B_LEVEL , +ITEM_COMPARE_FIELD_B_TAG_INDEX , +ITEM_COMPARE_FIELD_B_TYPE_ID , +ITEM_COMPARE_FIELD_B_CLASS_ID , +ITEM_COMPARE_FIELD_B_OFFSET , +ITEM_COMPARE_FIELD_B_VALUE , +ITEM_COMPARE_FIELD_B_POINTER , +ITEM_COMPARE_FIELD_WIDTH , +ZERO , +}; +static const enum index next_action[] = {ACTION_END ,ACTION_VOID ,
@@ -2882,6 +2941,24 @@ comp_quota_update_name(struct context *ctx, const struct token *token,static int comp_qu_mode_name (struct context *ctx,const struct token *token,unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size); +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);struct indlst_conf {uint32_t id;
@@ -6016,6 +6093,174 @@ static const struct token token_list[] = { .next = NEXT(item_nsh), .call = parse_vc, }, + [ITEM_COMPARE] = { + .name = "compare", + .help = "match with the comparison result", + .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), + .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)), + .call = parse_vc, + }, + [ITEM_COMPARE_OP] = { + .name = "op", + .help = "operation type", + .next =NEXT (item_compare_field, + NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)), + }, + [ITEM_COMPARE_OP_VALUE] = { + .name = "{operation}", + .help = "operation type value", + .call = parse_vc_compare_op, + .comp = comp_set_compare_op, + }, + [ITEM_COMPARE_FIELD_A_TYPE] = { + .name = "a_type", + .help = "compared field type", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = { + .name = "{a_type}", + .help = "compared field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_A_LEVEL] = { + .name = "a_level", + .help = "compared field level", + .next =NEXT (compare_field_a, + NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)), + }, + [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = { + .name = "{a_level}", + .help = "compared field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_A_TAG_INDEX] = { + .name = "a_tag_index", + .help = "compared field tag array", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.tag_index)), + }, + [ITEM_COMPARE_FIELD_A_TYPE_ID] = { + .name = "a_type_id", + .help = "compared field type ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.type)), + }, + [ITEM_COMPARE_FIELD_A_CLASS_ID] = { + .name = "a_class", + .help = "compared field class ID", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + a.class_id)), + }, + [ITEM_COMPARE_FIELD_A_OFFSET] = { + .name = "a_offset", + .help = "compared field bit offset", + .next =NEXT (compare_field_a, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + a.offset)), + }, + [ITEM_COMPARE_FIELD_B_TYPE] = { + .name = "b_type", + .help = "comparator field type", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.field)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = { + .name = "{b_type}", + .help = "comparator field type value", + .call = parse_vc_compare_field_id, + .comp = comp_set_compare_field_id, + }, + [ITEM_COMPARE_FIELD_B_LEVEL] = { + .name = "b_level", + .help = "comparator field level", + .next =NEXT (compare_field_b, + NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.level)), + }, + [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = { + .name = "{b_level}", + .help = "comparator field level value", + .call = parse_vc_compare_field_level, + .comp = comp_none, + }, + [ITEM_COMPARE_FIELD_B_TAG_INDEX] = { + .name = "b_tag_index", + .help = "comparator field tag array", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.tag_index)), + }, + [ITEM_COMPARE_FIELD_B_TYPE_ID] = { + .name = "b_type_id", + .help = "comparator field type ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.type)), + }, + [ITEM_COMPARE_FIELD_B_CLASS_ID] = { + .name = "b_class", + .help = "comparator field class ID", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare, + b.class_id)), + }, + [ITEM_COMPARE_FIELD_B_OFFSET] = { + .name = "b_offset", + .help = "comparator field bit offset", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.offset)), + }, + [ITEM_COMPARE_FIELD_B_VALUE] = { + .name = "b_value", + .help = "comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args =ARGS (ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB (0 ,0 ), + ARGS_ENTRY(struct rte_flow_item_compare, + b.value)), + }, + [ITEM_COMPARE_FIELD_B_POINTER] = { + .name = "b_ptr", + .help = "pointer to comparator immediate value", + .next =NEXT (compare_field_b, + NEXT_ENTRY(COMMON_HEX), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + b.pvalue), +ARGS_ENTRY_ARB (0 ,0 ), +ARGS_ENTRY_ARB + (sizeof (struct rte_flow_item_compare ), + FLOW_FIELD_PATTERN_SIZE)), + }, + [ITEM_COMPARE_FIELD_WIDTH] = { + .name = "width", + .help = "number of bits to compare", + .next =NEXT (item_compare_field, + NEXT_ENTRY(COMMON_UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, + width)), + },/* Validate/create actions. */ [ACTIONS] = {
@@ -8452,6 +8697,122 @@ parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,return len; } +/** Parse operation for compare match item. */ +static int +parse_vc_compare_op (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_OP_VALUE ) +return -1 ; +for (i =0 ; compare_ops[i]; ++i) +if (!strcmp_partial (compare_ops[i], str, len)) +break ; +if (!compare_ops[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + compare_item->operation = (enum rte_flow_item_compare_op )i; +return len; +} + +/** Parse id for compare match item. */ +static int +parse_vc_compare_field_id (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +unsigned int i; + + (void )token; + (void )buf; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_TYPE_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_TYPE_VALUE ) +return -1 ; +for (i =0 ; flow_field_ids[i]; ++i) +if (!strcmp_partial (flow_field_ids[i], str, len)) +break ; +if (!flow_field_ids[i]) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; +if (ctx->curr ==ITEM_COMPARE_FIELD_A_TYPE_VALUE ) + compare_item->a.field = (enum rte_flow_field_id )i; +else + compare_item->b.field = (enum rte_flow_field_id )i; +return len; +} + +/** Parse level for compare match item. */ +static int +parse_vc_compare_field_level (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct rte_flow_item_compare *compare_item; +struct flex_item *fp =NULL ; +uint32_t val; +struct buffer *out = buf; +char *end; + + (void )token; + (void )size; +if (ctx->curr !=ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + ctx->curr !=ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) +return -1 ; +if (!ctx->object) +return len; + compare_item = ctx->object; + errno =0 ; + val =strtoumax (str, &end,0 ); +if (errno || (size_t )(end - str) != len) +return -1 ; +/* No need to validate action template mask value */ +if (out->args.vc.masks) { +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) + compare_item->a.level = val; +else + compare_item->b.level = val; +return len; + } +if ((ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE && + compare_item->a.field ==RTE_FLOW_FIELD_FLEX_ITEM ) || + (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE && + compare_item->b.field ==RTE_FLOW_FIELD_FLEX_ITEM )) { +if (val >=FLEX_MAX_PARSERS_NUM ) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + fp = flex_items[ctx->port][val]; +if (!fp) { +printf ("Bad flex item handle\n" ); +return -1 ; + } + } +if (ctx->curr ==ITEM_COMPARE_FIELD_A_LEVEL_VALUE ) { +if (compare_item->a.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->a.level = val; +else + compare_item->a.flex_handle = fp->flex_handle; + }else if (ctx->curr ==ITEM_COMPARE_FIELD_B_LEVEL_VALUE ) { +if (compare_item->b.field !=RTE_FLOW_FIELD_FLEX_ITEM ) + compare_item->b.level = val; +else + compare_item->b.flex_handle = fp->flex_handle; + } +return len; +} +/** Parse meter color action type. */ static int parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
@@ -11938,6 +12299,39 @@ comp_rule_id(struct context *ctx, const struct token *token,return i; } +/** Complete operation for compare match item. */ +static int +comp_set_compare_op (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +RTE_SET_USED (ctx); +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (compare_ops); +if (ent <RTE_DIM (compare_ops) -1 ) +return strlcpy (buf, compare_ops[ent], size); +return -1 ; +} + +/** Complete field id for compare match item. */ +static int +comp_set_compare_field_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +const char *name; + +RTE_SET_USED (token); +if (!buf) +return RTE_DIM (flow_field_ids); +if (ent >=RTE_DIM (flow_field_ids) -1 ) +return -1 ; + name = flow_field_ids[ent]; +if (ctx->curr ==ITEM_COMPARE_FIELD_B_TYPE || + (strcmp (name,"pointer" ) &&strcmp (name,"value" ))) +return strlcpy (buf, name, size); +return -1 ; +} +/** Complete type field for RSS action. */ static int comp_vc_action_rss_type(struct context *ctx, const struct token *token,
doc/guides/nics/features/default.ini +1 -0
@@ -88,6 +88,7 @@ aggr_affinity = ah = any = arp_eth_ipv4 = +compare = conntrack = ecpri = esp =
doc/guides/prog_guide/rte_flow.rst +7 -0
@@ -1587,6 +1587,13 @@ the packet. - ``value``: Specific value to match. +Item: ``COMPARE`` +^^^^^^^^^^^^^^^^^ + +Matches the comparison result between packet fields or value. + +- ``compare``: Comparison information. + Actions ~~~~~~~
doc/guides/rel_notes/release_24_03.rst +5 -0
@@ -70,6 +70,11 @@ New Features * Added a fath path function ``rte_eth_tx_queue_count`` to get the number of used descriptors of a Tx queue. +* **Added flow matching with various comparison results.** + + Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on comparison + result between packet fields or value. + * **Updated Atomic Rules' Arkville PMD.** * Added support for Atomic Rules' TK242 packet-capture family of devices
doc/guides/testpmd_app_ug/testpmd_funcs.rst +24 -0
@@ -3856,6 +3856,13 @@ This section lists supported pattern items and their attributes, if any. - ``packet_type {unsigned}``: packet type. +- ``compare``: match the comparison result between packet fields or value. + + - ``op {string}``: comparison operation type. + - ``a_type {string}``: compared field. + - ``b_type {string}``: comparator field. + - ``width {unsigned}``: comparison width. + Actions list ^^^^^^^^^^^^
@@ -5324,6 +5331,23 @@ A RAW rule can be created as following using ``pattern_hex`` key and mask. pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions queue index 4 / end +Sample match with comparison rule +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Match with comparison rule can be created as following using ``compare``. + +:: + + testpmd> flow pattern_template 0 create ingress pattern_template_id 1 template compare op mask le + a_type mask tag a_tag_index mask 1 b_type mask tag b_tag_index mask 2 width mask 0xffffffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 1 template count / drop / end + mask count / drop / end + testpmd> flow template_table 0 create table_id 1 group 2 priority 1 ingress rules_number 1 + pattern_template 1 actions_template 1 + testpmd> flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 postpone no + pattern compare op is le a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 width is 32 / end + actions count / drop / end + BPF Functions --------------
lib/ethdev/rte_flow.c +1 -0
@@ -170,6 +170,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (TX_QUEUE ,sizeof (struct rte_flow_item_tx_queue )),MK_FLOW_ITEM (IB_BTH ,sizeof (struct rte_flow_item_ib_bth )),MK_FLOW_ITEM (PTYPE ,sizeof (struct rte_flow_item_ptype )), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), };/** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +38 -2
@@ -714,6 +714,13 @@ enum rte_flow_item_type {* @see struct rte_flow_item_random. */ RTE_FLOW_ITEM_TYPE_RANDOM , + +/** +* Match packet with various comparison types. +* +* See struct rte_flow_item_compare. +*/ + RTE_FLOW_ITEM_TYPE_COMPARE, };/**
@@ -2366,7 +2373,8 @@ static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {#endif /** -* Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. +* Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. */ enum rte_flow_field_id {RTE_FLOW_FIELD_START =0 ,/**< Start of a packet. */
@@ -2420,7 +2428,8 @@ enum rte_flow_field_id {* @warning * @b EXPERIMENTAL: this structure may change without prior notice * -* Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. +* Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD +* and RTE_FLOW_ITEM_TYPE_COMPARE. */ struct rte_flow_field_data {enum rte_flow_field_id field;/**< Field or memory type ID. */
@@ -2510,6 +2519,33 @@ struct rte_flow_field_data { }; }; +/** +* Expected operation types for compare item. +*/ +enum rte_flow_item_compare_op { +RTE_FLOW_ITEM_COMPARE_EQ ,/* Compare result equal. */ +RTE_FLOW_ITEM_COMPARE_NE ,/* Compare result not equal. */ +RTE_FLOW_ITEM_COMPARE_LT ,/* Compare result less than. */ +RTE_FLOW_ITEM_COMPARE_LE ,/* Compare result less than or equal. */ +RTE_FLOW_ITEM_COMPARE_GT ,/* Compare result great than. */ +RTE_FLOW_ITEM_COMPARE_GE ,/* Compare result great than or equal. */ +}; + +/** +* +* RTE_FLOW_ITEM_TYPE_COMPARE +* +* Matches the packet with compare result. +* +* The operation means a compare with b result. +*/ +struct rte_flow_item_compare { +enum rte_flow_item_compare_op operation;/* The compare operation. */ +struct rte_flow_field_data a;/* Field be compared. */ +struct rte_flow_field_data b;/* Field as comparator. */ +uint32_t width;/* Compare width. */ +}; +/** * Action types. *
Signature · 1 line
2.34.1
Re: [PATCH v7 3/4] ethdev: add compare item
Quoted 25 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \ compare op mask le a_type mask tag a_tag_index mask 1 b_type \ mask tag b_tag_index mask 2 width mask 0xffffffff / endflow
actions_template0 create ingressactions_template_id1 template \
count / drop / end mask count / drop / end
flowtemplate_table0 createtable_id1 group 2 priority 1 ingress \
rules_number1pattern_template1actions_template1
Quoted 9 lines
flow queue 0 create 0 template_table 1 pattern_template 0 \ actions_template 0 postpone no pattern compare op is le \ a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \ width is 32 / end actions count / drop / endSigned-off-by Suanming Mou <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
PATCH v7 4/4 net/mlx5: add compare item support
In reply to Suanming MouThe compare item allows adding flow match with comparison result. This commit adds compare item support to the PMD code.
Due to HW limitation:
- Only HWS supported.
- Only 32-bit comparison is supported.
- Only single compare flow is supported in the flow table.
- Only match with compare result between packet fields is supported.
--- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 + drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 86 insertions(+)
doc/guides/nics/features/mlx5.ini +1 -0
@@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y
doc/guides/nics/mlx5.rst +7 -0
@@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ----------
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -80,6 +80,8 @@ New Features * Added support for Atomic Rules' TK242 packet-capture family of devices with PCI IDs: ``0x1024, 0x1025, 0x1026``. + * Added support for comparing result between packet fields or value. + Removed Items -------------
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -277,6 +277,9 @@ enum mlx5_feature_name {/* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
drivers/net/mlx5/mlx5_flow_hw.c +73 -0
103 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v7 4/4] net/mlx5: add compare item support
doc/guides/rel_notes/release_24_03.rst New Features · line 85
Quoted 7 lines · Suanming Mou
doc/guides/rel_notes/release_24_03.rst +2
-0@@ -80,6 +80,8 @@ New Features * Added support for Atomic Rules' TK242 packet-capture family of devices with PCI IDs: ``0x1024, 0x1025, 0x1026``. + * Added support for comparing result between packet fields or value. +
Comment in v5 seems not addressed, above is still under wrong block.
Adding "* **Updated NVIDIA mlx5 driver.**" while merging.
Quoted 44 lines · Suanming Mou
The new item type is added for the case user wants to match traffic based on packet field compare result with other fields or immediate value.
e.g. take advantage the compare item user will be able to accumulate a IPv4/TCP packet's TCP
data_offsetand IPv4 IHL field to a tag register, then compare the tag register with IPv4 header total length to understand the packet has payload or not.The supported operations can be as below:
-RTE_FLOW_ITEM_COMPARE_EQ(equal)
-RTE_FLOW_ITEM_COMPARE_NE(not equal)
-RTE_FLOW_ITEM_COMPARE_LT(less than)
-RTE_FLOW_ITEM_COMPARE_LE(less than or equal)
-RTE_FLOW_ITEM_COMPARE_GT(great than)
-RTE_FLOW_ITEM_COMPARE_GE(great than or equal)V7:
- Moved release notes to API.
- Optimize comment descriptions.V6:
- fix typo and style issue.
- adjustflow_fielddescription.V5:
- rebase on top of next-net
- add sample detail forrte_flow_field.V4:
- rebase on top of the latest version.
- moveACTION_MODIFY_PATTERN_SIZEandmodify_field_idsrename to first patch.
- add comparison flow create sample intestpmd_funcs.rst.V3:
- fix code style missing empty line inrte_flow.rst.
- fix missing the ABI change release notes.V2:
- Since modify field data struct is experiment, rename modify field data directly instead of adding new flow field struct.
Quoted 6 lines
Suanming Mou (4):
ethdev: rename action modify field data structure
ethdev: move flow field data structures
ethdev: add compare item
net/mlx5: add compare item support
Series applied to dpdk-next-net/main, thanks.