add flex item implementation
cover add flex item implementation
Implement the flex item matching and modify field in HWS.
Rongwei Liu (6):
net/mlx5: enable hws flex item create net/mlx5: add IPv6 protocol as flex item input net/mlx5/hws: add hws flex item matching support net/mlx5: add flex item modify field implementation net/mlx5: return error for sws modify field doc/mlx5: update mlx5 doc
doc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++ drivers/net/mlx5/linux/mlx5_os.c | 27 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 186 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_flex.c | 135 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 64 ++++++++- 10 files changed, 460 insertions(+), 52 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/6 net/mlx5: enable hws flex item create
Enable flex item create and destroy with dv_flow_en=2
--- drivers/net/mlx5/linux/mlx5_os.c | 27 +++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +15 -12
@@ -474,10 +474,20 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) err =mlx5_alloc_table_hash_list (priv);if (err) goto error; -if (priv->sh->config.dv_flow_en ==2 ) -return 0 ;/* The resources below are only valid with DV support. */ #ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error; +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
@@ -518,16 +528,9 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; -/* Init shared flex parsers list, no need lcore_share */ -snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); - sh->flex_parsers_dv =mlx5_list_create (s, sh, false, - mlx5_flex_parser_create_cb, - mlx5_flex_parser_match_cb, - mlx5_flex_parser_remove_cb, - mlx5_flex_parser_clone_cb, - mlx5_flex_parser_clone_free_cb); -if (!sh->flex_parsers_dv) - goto error; +#else +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5_flow_hw.c +2 -0
@@ -8361,6 +8361,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .query = flow_hw_query, .get_aged_flows = flow_hw_get_aged_flows, .get_q_aged_flows = flow_hw_get_q_aged_flows, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, };/**
Signature · 1 line
2.27.0
PATCH 2/6 net/mlx5: add IPv6 protocol as flex item input
In reply to Rongwei LiuSupport IPv6 protocol as new flex item input link.
--- drivers/net/mlx5/mlx5_flow_flex.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/mlx5/mlx5_flow_flex.c +19 -0
@@ -1050,6 +1050,22 @@ mlx5_flex_arc_in_udp(const struct rte_flow_item *item,return rte_be_to_cpu_16 (spec->hdr.dst_port); } +static int +mlx5_flex_arc_in_ipv6 (const struct rte_flow_item *item, +struct rte_flow_error *error) +{ +const struct rte_flow_item_ipv6 *spec = item->spec; +const struct rte_flow_item_ipv6 *mask = item->mask; +struct rte_flow_item_ipv6 ip = { .hdr.proto =0xff }; + +if (memcmp (mask, &ip,sizeof (struct rte_flow_item_ipv6 ))) { +return rte_flow_error_set + (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , item, +"invalid ipv6 item mask, full mask is desired" ); + } +return spec->hdr.proto; +} + static int mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr, const struct rte_flow_item_flex_conf *conf,
@@ -1096,6 +1112,9 @@ mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr,case RTE_FLOW_ITEM_TYPE_UDP : ret =mlx5_flex_arc_in_udp (rte_item, error);break ; +case RTE_FLOW_ITEM_TYPE_IPV6 : + ret =mlx5_flex_arc_in_ipv6 (rte_item, error); +break ;default :MLX5_ASSERT (false);return rte_flow_error_set
Signature · 1 line
2.27.0
PATCH 3/6 net/mlx5/hws: add hws flex item matching support
In reply to Rongwei LiuSupport flex item matching in hws and syntax follows sws exactly.
Flex item should be created in advance and follow current json mapping logic.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++++++++ drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_flex.c | 116 ++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_hw.c | 48 ++++++++++- 7 files changed, 239 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +83 -0
@@ -309,6 +309,43 @@ mlx5dr_definer_ipv6_routing_ext_set(struct mlx5dr_definer_fc *fc,DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); } +static void +mlx5dr_definer_flex_parser_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag,bool is_inner) +{ +const struct rte_flow_item_flex *flex = item; +uint32_t byte_off, val, idx; +int ret; + + val =0 ; + byte_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); + idx = fc->fname -MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + byte_off -= idx *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (flex, flex->handle, byte_off, + false, is_inner, &val); +if (ret ==-1 || !val) +return ; + +DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); +} + +static void +mlx5dr_definer_flex_parser_inner_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, true); +} + +static void +mlx5dr_definer_flex_parser_outer_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, false); +} + static void mlx5dr_definer_gre_key_set(struct mlx5dr_definer_fc *fc, const void *item_spec,
@@ -1750,6 +1787,47 @@ mlx5dr_definer_check_item_range_supp(struct rte_flow_item *item) } } +static int +mlx5dr_definer_conv_item_flex_parser (struct mlx5dr_definer_conv_data *cd, +struct rte_flow_item *item, +int item_idx) +{ +uint32_t base_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); +const struct rte_flow_item_flex *v, *m; +enum mlx5dr_definer_fname fname; +struct mlx5dr_definer_fc *fc; +uint32_t i, mask, byte_off; +bool is_inner = cd->tunnel; +int ret; + + m = item->mask; + v = item->spec; + mask =0 ; +for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) { + byte_off = base_off - i *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (m, v->handle, byte_off, + true, is_inner, &mask); +if (ret ==-1 ) { + rte_errno =EINVAL ; +return rte_errno; + } + +if (!mask) +continue ; + + fname =MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + fname += (enum mlx5dr_definer_fname )i; + fc = &cd->fc[fname]; + fc->byte_off = byte_off; + fc->item_idx = item_idx; + fc->tag_set = cd->tunnel ? &mlx5dr_definer_flex_parser_inner_set : + &mlx5dr_definer_flex_parser_outer_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->bit_mask = mask; + } +return 0 ; +} + static int mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, struct mlx5dr_match_template *mt,
@@ -1877,6 +1955,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, item_flags |= cd.tunnel ?MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT :MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT ;break ; +case RTE_FLOW_ITEM_TYPE_FLEX : + ret =mlx5dr_definer_conv_item_flex_parser (&cd, items, i); + item_flags |= cd.tunnel ?MLX5_FLOW_ITEM_INNER_FLEX : +MLX5_FLOW_ITEM_OUTER_FLEX ; +break ;default :DR_LOG (ERR ,"Unsupported item type %d" , items->type); rte_errno =ENOTSUP ;
drivers/net/mlx5/mlx5.c +1 -1
@@ -1033,7 +1033,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +6 -0
@@ -2255,6 +2255,12 @@ void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher,void *key,const struct rte_flow_item *item,bool is_inner); +int mlx5_flex_get_sample_id (const struct mlx5_flex_item *tp, +uint32_t idx,uint32_t *pos, +bool is_inner,uint32_t *def); +int mlx5_flex_get_parser_value_per_byte_off (const struct rte_flow_item_flex *item, +void *flex,uint32_t byte_off, +bool is_mask,bool tunnel,uint32_t *value);int mlx5_flex_acquire_index (struct rte_eth_dev *dev,struct rte_flow_item_flex_handle *handle,bool acquire);
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1229,6 +1229,7 @@ struct rte_flow_pattern_template {* tag pattern item for representor matching. */ bool implicit_tag; +uint8_t flex_item;/* flex item index. */ };/* Flow action template struct. */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -10668,7 +10668,7 @@ flow_dv_translate_item_flex(struct rte_eth_dev *dev, void *matcher, void *key, (const struct rte_flow_item_flex *)item->spec;int index =mlx5_flex_acquire_index (dev, spec->handle, false); -MLX5_ASSERT (index >=0 && index <= (int )(sizeof (uint32_t ) *CHAR_BIT )); +MLX5_ASSERT (index >=0 && index < (int )(sizeof (uint32_t ) *CHAR_BIT ));if (index <0 )return ;if (!(dev_flow->handle->flex_item &RTE_BIT32 (index))) {
drivers/net/mlx5/mlx5_flow_flex.c +100 -16
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +47 -1
84 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 4/6 net/mlx5: add flex item modify field implementation
In reply to Rongwei LiuAdd flex item modify field HWS implementation.
The minimum modify boundary is one byte.
--- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_dv.c | 165 +++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 14 ++- 4 files changed, 170 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -761,6 +761,7 @@ enum mlx5_modification_field {MLX5_MODI_GTPU_FIRST_EXT_DW_0 =0x76 ,MLX5_MODI_HASH_RESULT =0x81 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , + MLX5_MODI_INVALID = INT_MAX, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1084,6 +1084,8 @@ struct field_modify_info {uint32_t size;/* Size of field in protocol header, in bytes. */ uint32_t offset;/* Offset of field in protocol header, in bytes. */ enum mlx5_modification_field id; +uint32_t shift; +uint8_t is_flex;/* Temporary indicator for flex item modify filed WA. */ };/* HW steering flow attributes. */
@@ -1248,6 +1250,7 @@ struct rte_flow_actions_template {uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ +uint8_t flex_item;/* flex item index. */ };/* Jump action struct. */
drivers/net/mlx5/mlx5_flow_dv.c +153 -12
215 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +13 -1
@@ -4558,6 +4558,17 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, at->actions[i].conf = actions->conf; at->masks[i].conf = masks->conf; } +if (actions->type ==RTE_FLOW_ACTION_TYPE_MODIFY_FIELD ) { +const struct rte_flow_action_modify_field *info = actions->conf; + +if ((info->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->dst.flex_handle, + &at->flex_item)) || + (info->src.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->src.flex_handle, + &at->flex_item))) + goto error; + } } at->tmpl =flow_hw_dr_actions_template_create (at);if (!at->tmpl)
@@ -4589,7 +4600,7 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_actions_template_destroy (struct rte_eth_dev *dev,struct rte_flow_actions_template *template, struct rte_flow_error *error __rte_unused) {
@@ -4602,6 +4613,7 @@ flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, "action template in using"); }LIST_REMOVE (template, next); +flow_hw_flex_item_release (dev, &template->flex_item);if (template->tmpl)mlx5dr_action_template_destroy (template->tmpl);mlx5_free (template);
Signature · 1 line
2.27.0
PATCH 5/6 net/mlx5: return error for sws modify field
In reply to Rongwei LiuReturn unsupported error message when application tries to modify flex item field.
Validation of packet modifications actions for SW Steering checked if either source or destination field of MODIFY_FIELD action was a flex item.
When DEC_TTL action is used, DEC_TTL action does not have any action configuration and dereferencing source or destination field is invalid, so validation of source and destination field types should be moved to MODIFY_FIELD specific validation function, then field types are validated if and only if action type is MODIFY_FIELD.
--- drivers/net/mlx5/mlx5_flow_dv.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +12 -7
@@ -4838,6 +4838,7 @@ flow_dv_validate_action_modify_hdr(const uint64_t action_flags,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION_CONF ,NULL ,"action configuration not set" ); +if (action_flags &MLX5_FLOW_ACTION_ENCAP ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -5163,17 +5164,21 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *action_modify_field = action->conf; -uint32_t dst_width =mlx5_flow_item_field_width (dev, - action_modify_field->dst.field, --1 , attr, error); -uint32_t src_width =mlx5_flow_item_field_width (dev, - action_modify_field->src.field, - dst_width, attr, error); +uint32_t dst_width, src_width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);if (ret)return ret; - +if (action_modify_field->src.field ==RTE_FLOW_FIELD_FLEX_ITEM || + action_modify_field->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"flex item fields modification" +" is not supported" ); + dst_width =mlx5_flow_item_field_width (dev, action_modify_field->dst.field, +-1 , attr, error); + src_width =mlx5_flow_item_field_width (dev, action_modify_field->src.field, + dst_width, attr, error);if (action_modify_field->width ==0 ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action,
Signature · 1 line
2.27.0
PATCH 6/6 doc/mlx5: update mlx5 doc
In reply to Rongwei LiuAdd flex item matching and modify field feature into mlx5 documents.
--- doc/guides/nics/mlx5.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
doc/guides/nics/mlx5.rst +3 -1
@@ -107,6 +107,7 @@ Features - Sub-Function. - Matching on represented port. - Matching on IPv6 routing extension header. +- Modify flex item field. Limitations
@@ -292,11 +293,12 @@ Limitations - Firmware supports 8 global sample fields. Each flex item allocates non-shared sample fields from that pool. - Supported flex item can have 1 input link - ``eth`` or ``udp`` - and up to 2 output links - ``ipv4`` or ``ipv6``. + and up to 3 output links - ``ipv4`` or ``ipv6``. - Flex item fields (``next_header``, ``next_protocol``, ``samples``) do not participate in RSS hash functions. - In flex item configuration, ``next_header.field_base`` value must be byte aligned (multiple of 8). + - Modify field with flex item, the offset must be byte aligned (multiple of 8). - No Tx metadata go to the E-Switch steering domain for the Flow group 0. The flows within group 0 and set metadata action are rejected by hardware.
Signature · 1 line
2.27.0
v2 cover add flex item implementation
Implement the flex item matching and modify field in HWS.
Rongwei Liu (6):
net/mlx5: enable hws flex item create net/mlx5: add IPv6 protocol as flex item input net/mlx5/hws: add hws flex item matching support net/mlx5: add flex item modify field implementation net/mlx5: return error for sws modify field doc/mlx5: update mlx5 doc
doc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++ drivers/net/mlx5/linux/mlx5_os.c | 27 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 186 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_flex.c | 135 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 64 ++++++++- 10 files changed, 460 insertions(+), 52 deletions(-)
Signature · 1 line
2.27.0
PATCH v2 1/6 net/mlx5: enable hws flex item create
Enable flex item create and destroy with dv_flow_en=2
--- drivers/net/mlx5/linux/mlx5_os.c | 27 +++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +15 -12
@@ -474,10 +474,20 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) err =mlx5_alloc_table_hash_list (priv);if (err) goto error; -if (priv->sh->config.dv_flow_en ==2 ) -return 0 ;/* The resources below are only valid with DV support. */ #ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error; +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
@@ -518,16 +528,9 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; -/* Init shared flex parsers list, no need lcore_share */ -snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); - sh->flex_parsers_dv =mlx5_list_create (s, sh, false, - mlx5_flex_parser_create_cb, - mlx5_flex_parser_match_cb, - mlx5_flex_parser_remove_cb, - mlx5_flex_parser_clone_cb, - mlx5_flex_parser_clone_free_cb); -if (!sh->flex_parsers_dv) - goto error; +#else +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5_flow_hw.c +2 -0
@@ -8436,6 +8436,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .query = flow_hw_query, .get_aged_flows = flow_hw_get_aged_flows, .get_q_aged_flows = flow_hw_get_q_aged_flows, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, };/**
Signature · 1 line
2.27.0
PATCH v2 2/6 net/mlx5: add IPv6 protocol as flex item input
In reply to Rongwei LiuSupport IPv6 protocol as new flex item input link.
--- drivers/net/mlx5/mlx5_flow_flex.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/mlx5/mlx5_flow_flex.c +19 -0
@@ -1050,6 +1050,22 @@ mlx5_flex_arc_in_udp(const struct rte_flow_item *item,return rte_be_to_cpu_16 (spec->hdr.dst_port); } +static int +mlx5_flex_arc_in_ipv6 (const struct rte_flow_item *item, +struct rte_flow_error *error) +{ +const struct rte_flow_item_ipv6 *spec = item->spec; +const struct rte_flow_item_ipv6 *mask = item->mask; +struct rte_flow_item_ipv6 ip = { .hdr.proto =0xff }; + +if (memcmp (mask, &ip,sizeof (struct rte_flow_item_ipv6 ))) { +return rte_flow_error_set + (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , item, +"invalid ipv6 item mask, full mask is desired" ); + } +return spec->hdr.proto; +} + static int mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr, const struct rte_flow_item_flex_conf *conf,
@@ -1096,6 +1112,9 @@ mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr,case RTE_FLOW_ITEM_TYPE_UDP : ret =mlx5_flex_arc_in_udp (rte_item, error);break ; +case RTE_FLOW_ITEM_TYPE_IPV6 : + ret =mlx5_flex_arc_in_ipv6 (rte_item, error); +break ;default :MLX5_ASSERT (false);return rte_flow_error_set
Signature · 1 line
2.27.0
PATCH v2 3/6 net/mlx5/hws: add hws flex item matching support
In reply to Rongwei LiuSupport flex item matching in hws and syntax follows sws exactly.
Flex item should be created in advance and follow current json mapping logic.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++++++++ drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_flex.c | 116 ++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_hw.c | 48 ++++++++++- 7 files changed, 239 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +83 -0
@@ -311,6 +311,43 @@ mlx5dr_definer_ipv6_routing_ext_set(struct mlx5dr_definer_fc *fc,DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); } +static void +mlx5dr_definer_flex_parser_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag,bool is_inner) +{ +const struct rte_flow_item_flex *flex = item; +uint32_t byte_off, val, idx; +int ret; + + val =0 ; + byte_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); + idx = fc->fname -MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + byte_off -= idx *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (flex, flex->handle, byte_off, + false, is_inner, &val); +if (ret ==-1 || !val) +return ; + +DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); +} + +static void +mlx5dr_definer_flex_parser_inner_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, true); +} + +static void +mlx5dr_definer_flex_parser_outer_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, false); +} + static void mlx5dr_definer_gre_key_set(struct mlx5dr_definer_fc *fc, const void *item_spec,
@@ -1782,6 +1819,47 @@ mlx5dr_definer_conv_item_esp(struct mlx5dr_definer_conv_data *cd,return 0 ; } +static int +mlx5dr_definer_conv_item_flex_parser (struct mlx5dr_definer_conv_data *cd, +struct rte_flow_item *item, +int item_idx) +{ +uint32_t base_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); +const struct rte_flow_item_flex *v, *m; +enum mlx5dr_definer_fname fname; +struct mlx5dr_definer_fc *fc; +uint32_t i, mask, byte_off; +bool is_inner = cd->tunnel; +int ret; + + m = item->mask; + v = item->spec; + mask =0 ; +for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) { + byte_off = base_off - i *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (m, v->handle, byte_off, + true, is_inner, &mask); +if (ret ==-1 ) { + rte_errno =EINVAL ; +return rte_errno; + } + +if (!mask) +continue ; + + fname =MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + fname += (enum mlx5dr_definer_fname )i; + fc = &cd->fc[fname]; + fc->byte_off = byte_off; + fc->item_idx = item_idx; + fc->tag_set = cd->tunnel ? &mlx5dr_definer_flex_parser_inner_set : + &mlx5dr_definer_flex_parser_outer_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->bit_mask = mask; + } +return 0 ; +} + static int mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, struct mlx5dr_match_template *mt,
@@ -1913,6 +1991,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret =mlx5dr_definer_conv_item_esp (&cd, items, i); item_flags |=MLX5_FLOW_ITEM_ESP ;break ; +case RTE_FLOW_ITEM_TYPE_FLEX : + ret =mlx5dr_definer_conv_item_flex_parser (&cd, items, i); + item_flags |= cd.tunnel ?MLX5_FLOW_ITEM_INNER_FLEX : +MLX5_FLOW_ITEM_OUTER_FLEX ; +break ;default :DR_LOG (ERR ,"Unsupported item type %d" , items->type); rte_errno =ENOTSUP ;
drivers/net/mlx5/mlx5.c +1 -1
@@ -1033,7 +1033,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +6 -0
@@ -2257,6 +2257,12 @@ void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher,void *key,const struct rte_flow_item *item,bool is_inner); +int mlx5_flex_get_sample_id (const struct mlx5_flex_item *tp, +uint32_t idx,uint32_t *pos, +bool is_inner,uint32_t *def); +int mlx5_flex_get_parser_value_per_byte_off (const struct rte_flow_item_flex *item, +void *flex,uint32_t byte_off, +bool is_mask,bool tunnel,uint32_t *value);int mlx5_flex_acquire_index (struct rte_eth_dev *dev,struct rte_flow_item_flex_handle *handle,bool acquire);
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1229,6 +1229,7 @@ struct rte_flow_pattern_template {* tag pattern item for representor matching. */ bool implicit_tag; +uint8_t flex_item;/* flex item index. */ };/* Flow action template struct. */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -10668,7 +10668,7 @@ flow_dv_translate_item_flex(struct rte_eth_dev *dev, void *matcher, void *key, (const struct rte_flow_item_flex *)item->spec;int index =mlx5_flex_acquire_index (dev, spec->handle, false); -MLX5_ASSERT (index >=0 && index <= (int )(sizeof (uint32_t ) *CHAR_BIT )); +MLX5_ASSERT (index >=0 && index < (int )(sizeof (uint32_t ) *CHAR_BIT ));if (index <0 )return ;if (!(dev_flow->handle->flex_item &RTE_BIT32 (index))) {
drivers/net/mlx5/mlx5_flow_flex.c +100 -16
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +47 -1
84 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 4/6 net/mlx5: add flex item modify field implementation
In reply to Rongwei LiuAdd flex item modify field HWS implementation.
The minimum modify boundary is one byte.
--- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_dv.c | 165 +++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 14 ++- 4 files changed, 170 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -761,6 +761,7 @@ enum mlx5_modification_field {MLX5_MODI_GTPU_FIRST_EXT_DW_0 =0x76 ,MLX5_MODI_HASH_RESULT =0x81 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , + MLX5_MODI_INVALID = INT_MAX, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1084,6 +1084,8 @@ struct field_modify_info {uint32_t size;/* Size of field in protocol header, in bytes. */ uint32_t offset;/* Offset of field in protocol header, in bytes. */ enum mlx5_modification_field id; +uint32_t shift; +uint8_t is_flex;/* Temporary indicator for flex item modify filed WA. */ };/* HW steering flow attributes. */
@@ -1248,6 +1250,7 @@ struct rte_flow_actions_template {uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ +uint8_t flex_item;/* flex item index. */ };/* Jump action struct. */
drivers/net/mlx5/mlx5_flow_dv.c +153 -12
215 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +13 -1
@@ -4562,6 +4562,17 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, at->actions[i].conf = actions->conf; at->masks[i].conf = masks->conf; } +if (actions->type ==RTE_FLOW_ACTION_TYPE_MODIFY_FIELD ) { +const struct rte_flow_action_modify_field *info = actions->conf; + +if ((info->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->dst.flex_handle, + &at->flex_item)) || + (info->src.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->src.flex_handle, + &at->flex_item))) + goto error; + } } at->tmpl =flow_hw_dr_actions_template_create (at);if (!at->tmpl)
@@ -4593,7 +4604,7 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_actions_template_destroy (struct rte_eth_dev *dev,struct rte_flow_actions_template *template, struct rte_flow_error *error __rte_unused) {
@@ -4606,6 +4617,7 @@ flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, "action template in using"); }LIST_REMOVE (template, next); +flow_hw_flex_item_release (dev, &template->flex_item);if (template->tmpl)mlx5dr_action_template_destroy (template->tmpl);mlx5_free (template);
Signature · 1 line
2.27.0
PATCH v2 5/6 net/mlx5: return error for sws modify field
In reply to Rongwei LiuReturn unsupported error message when application tries to modify flex item field.
Validation of packet modifications actions for SW Steering checked if either source or destination field of MODIFY_FIELD action was a flex item.
When DEC_TTL action is used, DEC_TTL action does not have any action configuration and dereferencing source or destination field is invalid, so validation of source and destination field types should be moved to MODIFY_FIELD specific validation function, then field types are validated if and only if action type is MODIFY_FIELD.
--- drivers/net/mlx5/mlx5_flow_dv.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +12 -7
@@ -4838,6 +4838,7 @@ flow_dv_validate_action_modify_hdr(const uint64_t action_flags,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION_CONF ,NULL ,"action configuration not set" ); +if (action_flags &MLX5_FLOW_ACTION_ENCAP ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -5163,17 +5164,21 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *action_modify_field = action->conf; -uint32_t dst_width =mlx5_flow_item_field_width (dev, - action_modify_field->dst.field, --1 , attr, error); -uint32_t src_width =mlx5_flow_item_field_width (dev, - action_modify_field->src.field, - dst_width, attr, error); +uint32_t dst_width, src_width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);if (ret)return ret; - +if (action_modify_field->src.field ==RTE_FLOW_FIELD_FLEX_ITEM || + action_modify_field->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"flex item fields modification" +" is not supported" ); + dst_width =mlx5_flow_item_field_width (dev, action_modify_field->dst.field, +-1 , attr, error); + src_width =mlx5_flow_item_field_width (dev, action_modify_field->src.field, + dst_width, attr, error);if (action_modify_field->width ==0 ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action,
Signature · 1 line
2.27.0
PATCH v2 6/6 doc/mlx5: update mlx5 doc
In reply to Rongwei LiuAdd flex item matching and modify field feature into mlx5 documents.
--- doc/guides/nics/mlx5.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
doc/guides/nics/mlx5.rst +3 -1
@@ -108,6 +108,7 @@ Features - Sub-Function. - Matching on represented port. - Matching on IPv6 routing extension header. +- Modify flex item field. Limitations
@@ -291,11 +292,12 @@ Limitations - Firmware supports 8 global sample fields. Each flex item allocates non-shared sample fields from that pool. - Supported flex item can have 1 input link - ``eth`` or ``udp`` - and up to 2 output links - ``ipv4`` or ``ipv6``. + and up to 3 output links - ``ipv4`` or ``ipv6``. - Flex item fields (``next_header``, ``next_protocol``, ``samples``) do not participate in RSS hash functions. - In flex item configuration, ``next_header.field_base`` value must be byte aligned (multiple of 8). + - Modify field with flex item, the offset must be byte aligned (multiple of 8). - No Tx metadata go to the E-Switch steering domain for the Flow group 0. The flows within group 0 and set metadata action are rejected by hardware.
Signature · 1 line
2.27.0
v3 cover add flex item implementation
In reply to Rongwei LiuImplement the flex item matching and modify field in HWS.
v3: add error message for testpmd output.
Rongwei Liu (7):
net/mlx5: enable hws flex item create net/mlx5: add IPv6 protocol as flex item input net/mlx5/hws: add hws flex item matching support net/mlx5: add flex item modify field implementation net/mlx5: return error for sws modify field doc/mlx5: update mlx5 doc
net/mlx5: add error message
doc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++ drivers/net/mlx5/linux/mlx5_os.c | 27 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 186 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_flex.c | 135 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 77 ++++++++++- 10 files changed, 473 insertions(+), 52 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/7 net/mlx5: enable hws flex item create
Enable flex item create and destroy with dv_flow_en=2
--- drivers/net/mlx5/linux/mlx5_os.c | 27 +++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +15 -12
@@ -474,10 +474,20 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) err =mlx5_alloc_table_hash_list (priv);if (err) goto error; -if (priv->sh->config.dv_flow_en ==2 ) -return 0 ;/* The resources below are only valid with DV support. */ #ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error; +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
@@ -518,16 +528,9 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; -/* Init shared flex parsers list, no need lcore_share */ -snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); - sh->flex_parsers_dv =mlx5_list_create (s, sh, false, - mlx5_flex_parser_create_cb, - mlx5_flex_parser_match_cb, - mlx5_flex_parser_remove_cb, - mlx5_flex_parser_clone_cb, - mlx5_flex_parser_clone_free_cb); -if (!sh->flex_parsers_dv) - goto error; +#else +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5_flow_hw.c +2 -0
@@ -8436,6 +8436,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .query = flow_hw_query, .get_aged_flows = flow_hw_get_aged_flows, .get_q_aged_flows = flow_hw_get_q_aged_flows, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, };/**
Signature · 1 line
2.27.0
PATCH v3 2/7 net/mlx5: add IPv6 protocol as flex item input
In reply to Rongwei LiuSupport IPv6 protocol as new flex item input link.
--- drivers/net/mlx5/mlx5_flow_flex.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/mlx5/mlx5_flow_flex.c +19 -0
@@ -1050,6 +1050,22 @@ mlx5_flex_arc_in_udp(const struct rte_flow_item *item,return rte_be_to_cpu_16 (spec->hdr.dst_port); } +static int +mlx5_flex_arc_in_ipv6 (const struct rte_flow_item *item, +struct rte_flow_error *error) +{ +const struct rte_flow_item_ipv6 *spec = item->spec; +const struct rte_flow_item_ipv6 *mask = item->mask; +struct rte_flow_item_ipv6 ip = { .hdr.proto =0xff }; + +if (memcmp (mask, &ip,sizeof (struct rte_flow_item_ipv6 ))) { +return rte_flow_error_set + (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , item, +"invalid ipv6 item mask, full mask is desired" ); + } +return spec->hdr.proto; +} + static int mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr, const struct rte_flow_item_flex_conf *conf,
@@ -1096,6 +1112,9 @@ mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr,case RTE_FLOW_ITEM_TYPE_UDP : ret =mlx5_flex_arc_in_udp (rte_item, error);break ; +case RTE_FLOW_ITEM_TYPE_IPV6 : + ret =mlx5_flex_arc_in_ipv6 (rte_item, error); +break ;default :MLX5_ASSERT (false);return rte_flow_error_set
Signature · 1 line
2.27.0
PATCH v3 3/7 net/mlx5/hws: add hws flex item matching support
In reply to Rongwei LiuSupport flex item matching in hws and syntax follows sws exactly.
Flex item should be created in advance and follow current json mapping logic.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++++++++ drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_flex.c | 116 ++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_hw.c | 48 ++++++++++- 7 files changed, 239 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +83 -0
@@ -311,6 +311,43 @@ mlx5dr_definer_ipv6_routing_ext_set(struct mlx5dr_definer_fc *fc,DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); } +static void +mlx5dr_definer_flex_parser_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag,bool is_inner) +{ +const struct rte_flow_item_flex *flex = item; +uint32_t byte_off, val, idx; +int ret; + + val =0 ; + byte_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); + idx = fc->fname -MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + byte_off -= idx *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (flex, flex->handle, byte_off, + false, is_inner, &val); +if (ret ==-1 || !val) +return ; + +DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); +} + +static void +mlx5dr_definer_flex_parser_inner_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, true); +} + +static void +mlx5dr_definer_flex_parser_outer_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, false); +} + static void mlx5dr_definer_gre_key_set(struct mlx5dr_definer_fc *fc, const void *item_spec,
@@ -1782,6 +1819,47 @@ mlx5dr_definer_conv_item_esp(struct mlx5dr_definer_conv_data *cd,return 0 ; } +static int +mlx5dr_definer_conv_item_flex_parser (struct mlx5dr_definer_conv_data *cd, +struct rte_flow_item *item, +int item_idx) +{ +uint32_t base_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); +const struct rte_flow_item_flex *v, *m; +enum mlx5dr_definer_fname fname; +struct mlx5dr_definer_fc *fc; +uint32_t i, mask, byte_off; +bool is_inner = cd->tunnel; +int ret; + + m = item->mask; + v = item->spec; + mask =0 ; +for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) { + byte_off = base_off - i *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (m, v->handle, byte_off, + true, is_inner, &mask); +if (ret ==-1 ) { + rte_errno =EINVAL ; +return rte_errno; + } + +if (!mask) +continue ; + + fname =MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + fname += (enum mlx5dr_definer_fname )i; + fc = &cd->fc[fname]; + fc->byte_off = byte_off; + fc->item_idx = item_idx; + fc->tag_set = cd->tunnel ? &mlx5dr_definer_flex_parser_inner_set : + &mlx5dr_definer_flex_parser_outer_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->bit_mask = mask; + } +return 0 ; +} + static int mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, struct mlx5dr_match_template *mt,
@@ -1913,6 +1991,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret =mlx5dr_definer_conv_item_esp (&cd, items, i); item_flags |=MLX5_FLOW_ITEM_ESP ;break ; +case RTE_FLOW_ITEM_TYPE_FLEX : + ret =mlx5dr_definer_conv_item_flex_parser (&cd, items, i); + item_flags |= cd.tunnel ?MLX5_FLOW_ITEM_INNER_FLEX : +MLX5_FLOW_ITEM_OUTER_FLEX ; +break ;default :DR_LOG (ERR ,"Unsupported item type %d" , items->type); rte_errno =ENOTSUP ;
drivers/net/mlx5/mlx5.c +1 -1
@@ -1033,7 +1033,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +6 -0
@@ -2257,6 +2257,12 @@ void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher,void *key,const struct rte_flow_item *item,bool is_inner); +int mlx5_flex_get_sample_id (const struct mlx5_flex_item *tp, +uint32_t idx,uint32_t *pos, +bool is_inner,uint32_t *def); +int mlx5_flex_get_parser_value_per_byte_off (const struct rte_flow_item_flex *item, +void *flex,uint32_t byte_off, +bool is_mask,bool tunnel,uint32_t *value);int mlx5_flex_acquire_index (struct rte_eth_dev *dev,struct rte_flow_item_flex_handle *handle,bool acquire);
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1229,6 +1229,7 @@ struct rte_flow_pattern_template {* tag pattern item for representor matching. */ bool implicit_tag; +uint8_t flex_item;/* flex item index. */ };/* Flow action template struct. */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -10668,7 +10668,7 @@ flow_dv_translate_item_flex(struct rte_eth_dev *dev, void *matcher, void *key, (const struct rte_flow_item_flex *)item->spec;int index =mlx5_flex_acquire_index (dev, spec->handle, false); -MLX5_ASSERT (index >=0 && index <= (int )(sizeof (uint32_t ) *CHAR_BIT )); +MLX5_ASSERT (index >=0 && index < (int )(sizeof (uint32_t ) *CHAR_BIT ));if (index <0 )return ;if (!(dev_flow->handle->flex_item &RTE_BIT32 (index))) {
drivers/net/mlx5/mlx5_flow_flex.c +100 -16
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +47 -1
84 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 4/7 net/mlx5: add flex item modify field implementation
In reply to Rongwei LiuAdd flex item modify field HWS implementation.
The minimum modify boundary is one byte.
--- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_dv.c | 165 +++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 14 ++- 4 files changed, 170 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -761,6 +761,7 @@ enum mlx5_modification_field {MLX5_MODI_GTPU_FIRST_EXT_DW_0 =0x76 ,MLX5_MODI_HASH_RESULT =0x81 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , + MLX5_MODI_INVALID = INT_MAX, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1084,6 +1084,8 @@ struct field_modify_info {uint32_t size;/* Size of field in protocol header, in bytes. */ uint32_t offset;/* Offset of field in protocol header, in bytes. */ enum mlx5_modification_field id; +uint32_t shift; +uint8_t is_flex;/* Temporary indicator for flex item modify filed WA. */ };/* HW steering flow attributes. */
@@ -1248,6 +1250,7 @@ struct rte_flow_actions_template {uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ +uint8_t flex_item;/* flex item index. */ };/* Jump action struct. */
drivers/net/mlx5/mlx5_flow_dv.c +153 -12
215 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +13 -1
@@ -4562,6 +4562,17 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, at->actions[i].conf = actions->conf; at->masks[i].conf = masks->conf; } +if (actions->type ==RTE_FLOW_ACTION_TYPE_MODIFY_FIELD ) { +const struct rte_flow_action_modify_field *info = actions->conf; + +if ((info->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->dst.flex_handle, + &at->flex_item)) || + (info->src.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->src.flex_handle, + &at->flex_item))) + goto error; + } } at->tmpl =flow_hw_dr_actions_template_create (at);if (!at->tmpl)
@@ -4593,7 +4604,7 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_actions_template_destroy (struct rte_eth_dev *dev,struct rte_flow_actions_template *template, struct rte_flow_error *error __rte_unused) {
@@ -4606,6 +4617,7 @@ flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, "action template in using"); }LIST_REMOVE (template, next); +flow_hw_flex_item_release (dev, &template->flex_item);if (template->tmpl)mlx5dr_action_template_destroy (template->tmpl);mlx5_free (template);
Signature · 1 line
2.27.0
PATCH v3 5/7 net/mlx5: return error for sws modify field
In reply to Rongwei LiuReturn unsupported error message when application tries to modify flex item field.
Validation of packet modifications actions for SW Steering checked if either source or destination field of MODIFY_FIELD action was a flex item.
When DEC_TTL action is used, DEC_TTL action does not have any action configuration and dereferencing source or destination field is invalid, so validation of source and destination field types should be moved to MODIFY_FIELD specific validation function, then field types are validated if and only if action type is MODIFY_FIELD.
--- drivers/net/mlx5/mlx5_flow_dv.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +12 -7
@@ -4838,6 +4838,7 @@ flow_dv_validate_action_modify_hdr(const uint64_t action_flags,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION_CONF ,NULL ,"action configuration not set" ); +if (action_flags &MLX5_FLOW_ACTION_ENCAP ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -5163,17 +5164,21 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *action_modify_field = action->conf; -uint32_t dst_width =mlx5_flow_item_field_width (dev, - action_modify_field->dst.field, --1 , attr, error); -uint32_t src_width =mlx5_flow_item_field_width (dev, - action_modify_field->src.field, - dst_width, attr, error); +uint32_t dst_width, src_width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);if (ret)return ret; - +if (action_modify_field->src.field ==RTE_FLOW_FIELD_FLEX_ITEM || + action_modify_field->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"flex item fields modification" +" is not supported" ); + dst_width =mlx5_flow_item_field_width (dev, action_modify_field->dst.field, +-1 , attr, error); + src_width =mlx5_flow_item_field_width (dev, action_modify_field->src.field, + dst_width, attr, error);if (action_modify_field->width ==0 ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action,
Signature · 1 line
2.27.0
PATCH v3 6/7 doc/mlx5: update mlx5 doc
In reply to Rongwei LiuAdd flex item matching and modify field feature into mlx5 documents.
--- doc/guides/nics/mlx5.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
doc/guides/nics/mlx5.rst +3 -1
@@ -108,6 +108,7 @@ Features - Sub-Function. - Matching on represented port. - Matching on IPv6 routing extension header. +- Modify flex item field. Limitations
@@ -291,11 +292,12 @@ Limitations - Firmware supports 8 global sample fields. Each flex item allocates non-shared sample fields from that pool. - Supported flex item can have 1 input link - ``eth`` or ``udp`` - and up to 2 output links - ``ipv4`` or ``ipv6``. + and up to 3 output links - ``ipv4`` or ``ipv6``. - Flex item fields (``next_header``, ``next_protocol``, ``samples``) do not participate in RSS hash functions. - In flex item configuration, ``next_header.field_base`` value must be byte aligned (multiple of 8). + - Modify field with flex item, the offset must be byte aligned (multiple of 8). - No Tx metadata go to the E-Switch steering domain for the Flow group 0. The flows within group 0 and set metadata action are rejected by hardware.
Signature · 1 line
2.27.0
Re: [PATCH v3 6/7] doc/mlx5: update mlx5 doc
23/02/2023 08:06, Rongwei Liu:
Quoted 5 lines
Add flex item matching and modify field feature into mlx5 documents.
Signed-off-by Rongwei Liu <[email protected]>
Please don't do a separate commit for doc update.
The doc should be updated with the related code in the same patch.
v4 cover add flex item implementation
Implement the flex item matching and modify field in HWS.
v4: squash doc commit.
v3: add error message for testpmd output.
Rongwei Liu (6):
net/mlx5: enable hws flex item create net/mlx5: add IPv6 protocol as flex item input net/mlx5/hws: add hws flex item matching support net/mlx5: add flex item modify field implementation net/mlx5: return error for sws modify field net/mlx5: add error message
doc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++ drivers/net/mlx5/linux/mlx5_os.c | 27 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 186 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_flex.c | 135 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 77 ++++++++++- 10 files changed, 473 insertions(+), 52 deletions(-)
Signature · 1 line
2.27.0
PATCH v4 1/6 net/mlx5: enable hws flex item create
Enable flex item create and destroy with dv_flow_en=2
--- drivers/net/mlx5/linux/mlx5_os.c | 27 +++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 2 ++ 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +15 -12
@@ -474,10 +474,20 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) err =mlx5_alloc_table_hash_list (priv);if (err) goto error; -if (priv->sh->config.dv_flow_en ==2 ) -return 0 ;/* The resources below are only valid with DV support. */ #ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error; +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
@@ -518,16 +528,9 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; -/* Init shared flex parsers list, no need lcore_share */ -snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); - sh->flex_parsers_dv =mlx5_list_create (s, sh, false, - mlx5_flex_parser_create_cb, - mlx5_flex_parser_match_cb, - mlx5_flex_parser_remove_cb, - mlx5_flex_parser_clone_cb, - mlx5_flex_parser_clone_free_cb); -if (!sh->flex_parsers_dv) - goto error; +#else +if (priv->sh->config.dv_flow_en ==2 ) +return 0 ;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5_flow_hw.c +2 -0
@@ -8436,6 +8436,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .query = flow_hw_query, .get_aged_flows = flow_hw_get_aged_flows, .get_q_aged_flows = flow_hw_get_q_aged_flows, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, };/**
Signature · 1 line
2.27.0
PATCH v4 2/6 net/mlx5: add IPv6 protocol as flex item input
In reply to Rongwei LiuSupport IPv6 protocol as new flex item input link.
--- drivers/net/mlx5/mlx5_flow_flex.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/mlx5/mlx5_flow_flex.c +19 -0
@@ -1050,6 +1050,22 @@ mlx5_flex_arc_in_udp(const struct rte_flow_item *item,return rte_be_to_cpu_16 (spec->hdr.dst_port); } +static int +mlx5_flex_arc_in_ipv6 (const struct rte_flow_item *item, +struct rte_flow_error *error) +{ +const struct rte_flow_item_ipv6 *spec = item->spec; +const struct rte_flow_item_ipv6 *mask = item->mask; +struct rte_flow_item_ipv6 ip = { .hdr.proto =0xff }; + +if (memcmp (mask, &ip,sizeof (struct rte_flow_item_ipv6 ))) { +return rte_flow_error_set + (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , item, +"invalid ipv6 item mask, full mask is desired" ); + } +return spec->hdr.proto; +} + static int mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr, const struct rte_flow_item_flex_conf *conf,
@@ -1096,6 +1112,9 @@ mlx5_flex_translate_arc_in(struct mlx5_hca_flex_attr *attr,case RTE_FLOW_ITEM_TYPE_UDP : ret =mlx5_flex_arc_in_udp (rte_item, error);break ; +case RTE_FLOW_ITEM_TYPE_IPV6 : + ret =mlx5_flex_arc_in_ipv6 (rte_item, error); +break ;default :MLX5_ASSERT (false);return rte_flow_error_set
Signature · 1 line
2.27.0
PATCH v4 3/6 net/mlx5/hws: add hws flex item matching support
In reply to Rongwei LiuSupport flex item matching in hws and syntax follows sws exactly.
Flex item should be created in advance and follow current json mapping logic.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++++++++ drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_flex.c | 116 ++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow_hw.c | 48 ++++++++++- 7 files changed, 239 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +83 -0
@@ -311,6 +311,43 @@ mlx5dr_definer_ipv6_routing_ext_set(struct mlx5dr_definer_fc *fc,DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); } +static void +mlx5dr_definer_flex_parser_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag,bool is_inner) +{ +const struct rte_flow_item_flex *flex = item; +uint32_t byte_off, val, idx; +int ret; + + val =0 ; + byte_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); + idx = fc->fname -MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + byte_off -= idx *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (flex, flex->handle, byte_off, + false, is_inner, &val); +if (ret ==-1 || !val) +return ; + +DR_SET (tag, val, fc->byte_off,0 , fc->bit_mask); +} + +static void +mlx5dr_definer_flex_parser_inner_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, true); +} + +static void +mlx5dr_definer_flex_parser_outer_set (struct mlx5dr_definer_fc *fc, +const void *item, +uint8_t *tag) +{ +mlx5dr_definer_flex_parser_set (fc, item, tag, false); +} + static void mlx5dr_definer_gre_key_set(struct mlx5dr_definer_fc *fc, const void *item_spec,
@@ -1782,6 +1819,47 @@ mlx5dr_definer_conv_item_esp(struct mlx5dr_definer_conv_data *cd,return 0 ; } +static int +mlx5dr_definer_conv_item_flex_parser (struct mlx5dr_definer_conv_data *cd, +struct rte_flow_item *item, +int item_idx) +{ +uint32_t base_off =MLX5_BYTE_OFF (definer_hl, flex_parser.flex_parser_0); +const struct rte_flow_item_flex *v, *m; +enum mlx5dr_definer_fname fname; +struct mlx5dr_definer_fc *fc; +uint32_t i, mask, byte_off; +bool is_inner = cd->tunnel; +int ret; + + m = item->mask; + v = item->spec; + mask =0 ; +for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) { + byte_off = base_off - i *sizeof (uint32_t ); + ret =mlx5_flex_get_parser_value_per_byte_off (m, v->handle, byte_off, + true, is_inner, &mask); +if (ret ==-1 ) { + rte_errno =EINVAL ; +return rte_errno; + } + +if (!mask) +continue ; + + fname =MLX5DR_DEFINER_FNAME_FLEX_PARSER_0 ; + fname += (enum mlx5dr_definer_fname )i; + fc = &cd->fc[fname]; + fc->byte_off = byte_off; + fc->item_idx = item_idx; + fc->tag_set = cd->tunnel ? &mlx5dr_definer_flex_parser_inner_set : + &mlx5dr_definer_flex_parser_outer_set; + fc->tag_mask_set = &mlx5dr_definer_ones_set; + fc->bit_mask = mask; + } +return 0 ; +} + static int mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, struct mlx5dr_match_template *mt,
@@ -1913,6 +1991,11 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret =mlx5dr_definer_conv_item_esp (&cd, items, i); item_flags |=MLX5_FLOW_ITEM_ESP ;break ; +case RTE_FLOW_ITEM_TYPE_FLEX : + ret =mlx5dr_definer_conv_item_flex_parser (&cd, items, i); + item_flags |= cd.tunnel ?MLX5_FLOW_ITEM_INNER_FLEX : +MLX5_FLOW_ITEM_OUTER_FLEX ; +break ;default :DR_LOG (ERR ,"Unsupported item type %d" , items->type); rte_errno =ENOTSUP ;
drivers/net/mlx5/mlx5.c +1 -1
@@ -1033,7 +1033,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +6 -0
@@ -2257,6 +2257,12 @@ void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher,void *key,const struct rte_flow_item *item,bool is_inner); +int mlx5_flex_get_sample_id (const struct mlx5_flex_item *tp, +uint32_t idx,uint32_t *pos, +bool is_inner,uint32_t *def); +int mlx5_flex_get_parser_value_per_byte_off (const struct rte_flow_item_flex *item, +void *flex,uint32_t byte_off, +bool is_mask,bool tunnel,uint32_t *value);int mlx5_flex_acquire_index (struct rte_eth_dev *dev,struct rte_flow_item_flex_handle *handle,bool acquire);
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1229,6 +1229,7 @@ struct rte_flow_pattern_template {* tag pattern item for representor matching. */ bool implicit_tag; +uint8_t flex_item;/* flex item index. */ };/* Flow action template struct. */
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -10668,7 +10668,7 @@ flow_dv_translate_item_flex(struct rte_eth_dev *dev, void *matcher, void *key, (const struct rte_flow_item_flex *)item->spec;int index =mlx5_flex_acquire_index (dev, spec->handle, false); -MLX5_ASSERT (index >=0 && index <= (int )(sizeof (uint32_t ) *CHAR_BIT )); +MLX5_ASSERT (index >=0 && index < (int )(sizeof (uint32_t ) *CHAR_BIT ));if (index <0 )return ;if (!(dev_flow->handle->flex_item &RTE_BIT32 (index))) {
drivers/net/mlx5/mlx5_flow_flex.c +100 -16
132 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +47 -1
84 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 4/6 net/mlx5: add flex item modify field implementation
In reply to Rongwei LiuAdd flex item modify field HWS implementation.
The minimum modify boundary is one byte.
--- doc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5_flow.h | 3 + drivers/net/mlx5/mlx5_flow_dv.c | 165 +++++++++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 14 ++- 5 files changed, 173 insertions(+), 14 deletions(-)
doc/guides/nics/mlx5.rst +3 -1
@@ -108,6 +108,7 @@ Features - Sub-Function. - Matching on represented port. - Matching on IPv6 routing extension header. +- Modify flex item field. Limitations
@@ -291,11 +292,12 @@ Limitations - Firmware supports 8 global sample fields. Each flex item allocates non-shared sample fields from that pool. - Supported flex item can have 1 input link - ``eth`` or ``udp`` - and up to 2 output links - ``ipv4`` or ``ipv6``. + and up to 3 output links - ``ipv4`` or ``ipv6``. - Flex item fields (``next_header``, ``next_protocol``, ``samples``) do not participate in RSS hash functions. - In flex item configuration, ``next_header.field_base`` value must be byte aligned (multiple of 8). + - Modify field with flex item, the offset must be byte aligned (multiple of 8). - No Tx metadata go to the E-Switch steering domain for the Flow group 0. The flows within group 0 and set metadata action are rejected by hardware.
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -761,6 +761,7 @@ enum mlx5_modification_field {MLX5_MODI_GTPU_FIRST_EXT_DW_0 =0x76 ,MLX5_MODI_HASH_RESULT =0x81 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , + MLX5_MODI_INVALID = INT_MAX, };/* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -1084,6 +1084,8 @@ struct field_modify_info {uint32_t size;/* Size of field in protocol header, in bytes. */ uint32_t offset;/* Offset of field in protocol header, in bytes. */ enum mlx5_modification_field id; +uint32_t shift; +uint8_t is_flex;/* Temporary indicator for flex item modify filed WA. */ };/* HW steering flow attributes. */
@@ -1248,6 +1250,7 @@ struct rte_flow_actions_template {uint16_t mhdr_off;/* Offset of DR modify header action. */ uint32_t refcnt;/* Reference counter. */ uint16_t rx_cpy_pos;/* Action position of Rx metadata to be copied. */ +uint8_t flex_item;/* flex item index. */ };/* Jump action struct. */
drivers/net/mlx5/mlx5_flow_dv.c +153 -12
215 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +13 -1
@@ -4562,6 +4562,17 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, at->actions[i].conf = actions->conf; at->masks[i].conf = masks->conf; } +if (actions->type ==RTE_FLOW_ACTION_TYPE_MODIFY_FIELD ) { +const struct rte_flow_action_modify_field *info = actions->conf; + +if ((info->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->dst.flex_handle, + &at->flex_item)) || + (info->src.field ==RTE_FLOW_FIELD_FLEX_ITEM && +flow_hw_flex_item_acquire (dev, info->src.flex_handle, + &at->flex_item))) + goto error; + } } at->tmpl =flow_hw_dr_actions_template_create (at);if (!at->tmpl)
@@ -4593,7 +4604,7 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,* 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, +flow_hw_actions_template_destroy (struct rte_eth_dev *dev,struct rte_flow_actions_template *template, struct rte_flow_error *error __rte_unused) {
@@ -4606,6 +4617,7 @@ flow_hw_actions_template_destroy(struct rte_eth_dev *dev __rte_unused, "action template in using"); }LIST_REMOVE (template, next); +flow_hw_flex_item_release (dev, &template->flex_item);if (template->tmpl)mlx5dr_action_template_destroy (template->tmpl);mlx5_free (template);
Signature · 1 line
2.27.0
PATCH v4 5/6 net/mlx5: return error for sws modify field
In reply to Rongwei LiuReturn unsupported error message when application tries to modify flex item field.
Validation of packet modifications actions for SW Steering checked if either source or destination field of MODIFY_FIELD action was a flex item.
When DEC_TTL action is used, DEC_TTL action does not have any action configuration and dereferencing source or destination field is invalid, so validation of source and destination field types should be moved to MODIFY_FIELD specific validation function, then field types are validated if and only if action type is MODIFY_FIELD.
--- drivers/net/mlx5/mlx5_flow_dv.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +12 -7
@@ -4838,6 +4838,7 @@ flow_dv_validate_action_modify_hdr(const uint64_t action_flags,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION_CONF ,NULL ,"action configuration not set" ); +if (action_flags &MLX5_FLOW_ACTION_ENCAP ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -5163,17 +5164,21 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;const struct rte_flow_action_modify_field *action_modify_field = action->conf; -uint32_t dst_width =mlx5_flow_item_field_width (dev, - action_modify_field->dst.field, --1 , attr, error); -uint32_t src_width =mlx5_flow_item_field_width (dev, - action_modify_field->src.field, - dst_width, attr, error); +uint32_t dst_width, src_width; ret =flow_dv_validate_action_modify_hdr (action_flags, action, error);if (ret)return ret; - +if (action_modify_field->src.field ==RTE_FLOW_FIELD_FLEX_ITEM || + action_modify_field->dst.field ==RTE_FLOW_FIELD_FLEX_ITEM ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"flex item fields modification" +" is not supported" ); + dst_width =mlx5_flow_item_field_width (dev, action_modify_field->dst.field, +-1 , attr, error); + src_width =mlx5_flow_item_field_width (dev, action_modify_field->src.field, + dst_width, attr, error);if (action_modify_field->width ==0 ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action,
Signature · 1 line
2.27.0
PATCH v4 6/6 net/mlx5: add error message
In reply to Rongwei LiuWhen pattern/action template creation fails the testpmd expects error details.
The driver did not set the error structure and testpmd failed with a segmentation fault.
--- drivers/net/mlx5/mlx5_flow_hw.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_hw.c +14 -1
@@ -4570,8 +4570,12 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, &at->flex_item)) || (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM && flow_hw_flex_item_acquire(dev, info->src.flex_handle, - &at->flex_item))) + &at->flex_item))) { +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to acquire flex item" ); goto error; + } } } at->tmpl =flow_hw_dr_actions_template_create (at);
@@ -4587,6 +4591,9 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,mlx5dr_action_template_destroy (at->tmpl);mlx5_free (at); } +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to create action template" );return NULL ; }
@@ -4936,6 +4943,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, (mlx5_alloc_srh_flex_parser(dev))) {claim_zero (mlx5dr_match_template_destroy (it->mt));mlx5_free (it); +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot create IPv6 routing extension support" );return NULL ; } }
@@ -4948,6 +4958,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,if (flow_hw_flex_item_acquire (dev, handle, &it->flex_item)) {claim_zero (mlx5dr_match_template_destroy (it->mt));mlx5_free (it); +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to acquire flex item" );return NULL ; } }
Signature · 1 line
2.27.0
Hi,
Quoted 34 lines
-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Thursday, February 23, 2023 2:49 PM
To: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Raslan Darawsheh <[email protected]>
Subject: [PATCH v4 0/6] add flex item implementationImplement the flex item matching and modify field in HWS.
v4: squash doc commit.
v3: add error message for testpmd output.Rongwei Liu (6):
net/mlx5: enable hws flex item create net/mlx5: add IPv6 protocol as flex item inputnet/mlx5/hws: add hws flex item matching support net/mlx5: add flex item modify field implementation net/mlx5: return error for sws modify field net/mlx5: add error messagedoc/guides/nics/mlx5.rst | 4 +- drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/hws/mlx5dr_definer.c | 83 ++++++++++++ drivers/net/mlx5/linux/mlx5_os.c | 27 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 + drivers/net/mlx5/mlx5_flow.h | 4 + drivers/net/mlx5/mlx5_flow_dv.c | 186 +++++++++++++++++++++++--- drivers/net/mlx5/mlx5_flow_flex.c | 135 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 77 ++++++++++- 10 files changed, 473 insertions(+), 52 deletions(-)
Quoted 2 lines
--
2.27.0
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
PATCH v3 7/7 net/mlx5: add error message
In reply to Rongwei LiuWhen pattern/action template creation fails the testpmd expects error details.
The driver did not set the error structure and testpmd failed with a segmentation fault.
--- drivers/net/mlx5/mlx5_flow_hw.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_hw.c +14 -1
@@ -4570,8 +4570,12 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, &at->flex_item)) || (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM && flow_hw_flex_item_acquire(dev, info->src.flex_handle, - &at->flex_item))) + &at->flex_item))) { +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to acquire flex item" ); goto error; + } } } at->tmpl =flow_hw_dr_actions_template_create (at);
@@ -4587,6 +4591,9 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,mlx5dr_action_template_destroy (at->tmpl);mlx5_free (at); } +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to create action template" );return NULL ; }
@@ -4936,6 +4943,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, (mlx5_alloc_srh_flex_parser(dev))) {claim_zero (mlx5dr_match_template_destroy (it->mt));mlx5_free (it); +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot create IPv6 routing extension support" );return NULL ; } }
@@ -4948,6 +4958,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,if (flow_hw_flex_item_acquire (dev, handle, &it->flex_item)) {claim_zero (mlx5dr_match_template_destroy (it->mt));mlx5_free (it); +rte_flow_error_set (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"Failed to accquire flex item" );return NULL ; } }
Signature · 1 line
2.27.0