net/mlx5: add modify MPLS support
cover net/mlx5: add modify MPLS support
Add support for MPLS header modification.
RFC:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Michael Baum (2):
net/mlx5: align implementation with modify API
net/mlx5: add MPLS modify field support
doc/guides/nics/mlx5.rst | 2 ++ drivers/common/mlx5/mlx5_prm.h | 5 +++ drivers/net/mlx5/mlx5_flow.h | 13 ++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 41 ++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 57 +++++++++++++++++++++++++-------- 5 files changed, 105 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 net/mlx5: align implementation with modify API
Modify field action API has been changed to use "tag_index" instead of "level" fields to represent the tag array for TAG modification type.
Although the old API still work, this patch move all internal API usage to use "tag_index".
--- drivers/net/mlx5/mlx5_flow.h | 12 +++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 18 +++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 47 ++++++++++++++++++++++++++------- 3 files changed, 67 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.h +12 -0
@@ -1108,6 +1108,18 @@ flow_dv_fetch_field(const uint8_t *data, uint32_t size)return ret; } +static inline bool +flow_modify_field_support_tag_array (enum rte_flow_field_id field) +{ +switch (field) { +case RTE_FLOW_FIELD_TAG : +return true; +default : +break ; + } +return false; +} +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. */
drivers/net/mlx5/mlx5_flow_dv.c +18 -0
@@ -5291,6 +5291,15 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, ret =flow_validate_modify_field_level (dst_data, error);if (ret)return ret; +if (dst_data->tag_index && + !flow_modify_field_support_tag_array (dst_data->field)) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination tag index is not supported" ); +if (dst_data->class_id) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"destination class ID is not supported" ); }if (src_data->field !=RTE_FLOW_FIELD_VALUE && src_data->field !=RTE_FLOW_FIELD_POINTER ) {
@@ -5306,6 +5315,15 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, ret =flow_validate_modify_field_level (src_data, error);if (ret)return ret; +if (src_data->tag_index && + !flow_modify_field_support_tag_array (src_data->field)) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"source tag index is not supported" ); +if (src_data->class_id) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"source class ID is not supported" ); }if ((dst_data->field == src_data->field) && (dst_data->level == src_data->level))
drivers/net/mlx5/mlx5_flow_hw.c +37 -10
160 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 net/mlx5: add MPLS modify field support
In reply to Michael BaumAdd support for modify field in tunnel MPLS header. For now it is supported only to copy from.
--- doc/guides/nics/mlx5.rst | 2 ++ drivers/common/mlx5/mlx5_prm.h | 5 +++++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 10 +++++++--- 5 files changed, 38 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -0
@@ -538,6 +538,8 @@ Limitations - Supports the 'set' and 'add' operations for ``RTE_FLOW_ACTION_TYPE_MODIFY_FIELD`` action. - Modification of an arbitrary place in a packet via the special ``RTE_FLOW_FIELD_START`` Field ID is not supported. + - Modification of the MPLS header is supported only in HWS and only to copy + from, the encapsulation level is always 0. - Modification of the 802.1Q Tag, VXLAN Network or GENEVE Network ID's is not supported. - Encapsulation levels are not supported, can modify outermost header fields only. - Offsets cannot skip past the boundary of a field.
drivers/common/mlx5/mlx5_prm.h +5 -0
@@ -787,6 +787,11 @@ enum mlx5_modification_field {MLX5_MODI_TUNNEL_HDR_DW_1 =0x75 ,MLX5_MODI_GTPU_FIRST_EXT_DW_0 =0x76 ,MLX5_MODI_HASH_RESULT =0x81 , +MLX5_MODI_IN_MPLS_LABEL_0 =0x8a , +MLX5_MODI_IN_MPLS_LABEL_1 , +MLX5_MODI_IN_MPLS_LABEL_2 , +MLX5_MODI_IN_MPLS_LABEL_3 , +MLX5_MODI_IN_MPLS_LABEL_4 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , MLX5_MODI_INVALID = INT_MAX, };
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1113,6 +1113,7 @@ flow_modify_field_support_tag_array(enum rte_flow_field_id field) {switch (field) {case RTE_FLOW_FIELD_TAG : +case RTE_FLOW_FIELD_MPLS :return true;default :break ;
drivers/net/mlx5/mlx5_flow_dv.c +23 -0
@@ -1388,6 +1388,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,case RTE_FLOW_FIELD_GENEVE_VNI :return 24 ;case RTE_FLOW_FIELD_GTP_TEID : +case RTE_FLOW_FIELD_MPLS :case RTE_FLOW_FIELD_TAG :return 32 ;case RTE_FLOW_FIELD_MARK :
@@ -1435,6 +1436,12 @@ flow_modify_info_mask_32_masked(uint32_t length, uint32_t off, uint32_t post_masreturn rte_cpu_to_be_32 (mask & post_mask); } +static __rte_always_inline enum mlx5_modification_field +mlx5_mpls_modi_field_get (const struct rte_flow_action_modify_data *data) +{ +return MLX5_MODI_IN_MPLS_LABEL_0 + data->tag_index; +} + static void mlx5_modify_flex_item(const struct rte_eth_dev *dev, const struct mlx5_flex_item *flex,
@@ -1893,6 +1900,16 @@ mlx5_flow_field_id_to_modify_infoelse info[idx].offset = off_be;break ; +case RTE_FLOW_FIELD_MPLS : +MLX5_ASSERT (data->offset + width <=32 ); + off_be =32 - (data->offset + width); + info[idx] = (struct field_modify_info ){4 ,0 , +mlx5_mpls_modi_field_get (data)}; +if (mask) + mask[idx] =flow_modify_info_mask_32 (width, off_be); +else + info[idx].offset = off_be; +break ;case RTE_FLOW_FIELD_TAG : {MLX5_ASSERT (data->offset + width <=32 );
@@ -5362,6 +5379,12 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION , action,"modifications of the GENEVE Network" " Identifier is not supported"); +if (dst_data->field ==RTE_FLOW_FIELD_MPLS || + src_data->field ==RTE_FLOW_FIELD_MPLS ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"modifications of the MPLS header " +"is not supported" );if (dst_data->field ==RTE_FLOW_FIELD_MARK || src_data->field ==RTE_FLOW_FIELD_MARK ) if (config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY ||
drivers/net/mlx5/mlx5_flow_hw.c +7 -3
@@ -3713,6 +3713,11 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION , action,"modifying Geneve VNI is not supported" ); +/* Due to HW bug, tunnel MPLS header is read only. */ +if (action_conf->dst.field ==RTE_FLOW_FIELD_MPLS ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"MPLS cannot be used as destination" );return 0 ; }
@@ -4243,9 +4248,8 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD : - ret =flow_hw_validate_action_modify_field (action, - mask, - error); + ret =flow_hw_validate_action_modify_field (action, mask, + error);if (ret <0 )return ret; action_flags |=MLX5_FLOW_ACTION_MODIFY_FIELD ;
Signature · 1 line
2.25.1
Hi,
Quoted 26 lines
-----Original Message-----
From: Michael Baum <[email protected]>
Sent: Wednesday, June 14, 2023 8:53 AM
To: [email protected]
Cc: Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: [PATCH 0/2] net/mlx5: add modify MPLS supportAdd support for MPLS header modification.
RFC:
https://patchwork.dpdk.org/project/dpdk/patch/20230420094347.523784
[email protected]/Michael Baum (2):
net/mlx5: align implementation with modify API
net/mlx5: add MPLS modify field supportdoc/guides/nics/mlx5.rst | 2 ++ drivers/common/mlx5/mlx5_prm.h | 5 +++ drivers/net/mlx5/mlx5_flow.h | 13 ++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 41 ++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 57 +++++++++++++++++++++++++------ -- 5 files changed, 105 insertions(+), 13 deletions(-)
Quoted 2 lines
--
2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh