net/mlx5: add modify field actions number validation
cover net/mlx5: add modify field actions number validation
This patchset adds validation for the number of modify field actions, when working with HW Steering.
Dariusz Sosnowski (2):
common/mlx5: query maximum modify header pattern length net/mlx5: add modify field actions number validation
drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/common/mlx5/mlx5_prm.h | 3 +- drivers/net/mlx5/mlx5_flow_hw.c | 51 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/2 common/mlx5: query maximum modify header pattern length
This patch adds querying the HCA capabilities for maximum supported pattern length for Header Modify Pattern objects.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/common/mlx5/mlx5_prm.h | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -1086,6 +1086,8 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, flow_counter_access_aso); attr->flow_access_aso_opc_mod =MLX5_GET (cmd_hca_cap, hcattr, flow_access_aso_opc_mod); + attr->wqe_based_flow_table_sup =MLX5_GET (cmd_hca_cap, hcattr, + wqe_based_flow_table_update_cap);/* * Flex item support needs max_num_prog_sample_field * from the Capabilities 2 table for PARSE_GRAPH_NODE
@@ -1293,6 +1295,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->rss_ind_tbl_cap =MLX5_GET (per_protocol_networking_offload_caps, hcattr, rss_ind_tbl_cap); +if (attr->wqe_based_flow_table_sup) { + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_WQE_BASED_FLOW_TABLE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { +DRV_LOG (DEBUG ,"Failed to query WQE Based Flow table capabilities" ); +return rc; + } + attr->max_header_modify_pattern_length =MLX5_GET (wqe_based_flow_table_cap, + hcattr, + max_header_modify_pattern_length); + }/* Query HCA attribute for ROCE. */ if (attr->roce) { hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc,
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
@@ -299,6 +299,8 @@ struct mlx5_hca_attr { uint32_t flow_access_aso_opc_mod:8; uint32_t cross_vhca:1; uint32_t lag_rx_port_affinity:1; + uint32_t wqe_based_flow_table_sup:1; +uint8_t max_header_modify_pattern_length; };/* LAG Context. */
drivers/common/mlx5/mlx5_prm.h +2 -1
@@ -2289,7 +2289,8 @@ struct mlx5_ifc_wqe_based_flow_table_cap_bits {u8 rtc_index_mode[0x5 ];u8 reserved_at_58[0x3 ];u8 rtc_log_depth_max[0x5 ]; -u8 reserved_at_60[0x10 ]; +u8 reserved_at_60[0x8 ]; +u8 max_header_modify_pattern_length[0x8 ];u8 ste_format[0x10 ];u8 stc_action_type[0x80 ];u8 header_insert_type[0x10 ];
Signature · 1 line
2.25.1
PATCH 2/2 net/mlx5: add modify field actions number validation
In reply to Dariusz SosnowskiThis patch adds validation for the number of modify field actions, when working with HW Steering.
If translation of modify field actions generated more HW commands than supported by the FW, then proper error is returned. Additionally, number of generated commands is logged, along with a number of NOP commands added.
This validation is only valid for HWS template tables, in groups > 0.
--- drivers/net/mlx5/mlx5_flow_hw.c | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/net/mlx5/mlx5_flow_hw.c +51 -0
@@ -1086,6 +1086,53 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev,return 0 ; } +static uint32_t +flow_hw_count_nop_modify_field (struct mlx5_hw_modify_header_action *mhdr) +{ +uint32_t i; +uint32_t nops =0 ; + +for (i =0 ; i < mhdr->mhdr_cmds_num; ++i) { +struct mlx5_modification_cmd cmd = mhdr->mhdr_cmds[i]; + + cmd.data0 =rte_be_to_cpu_32 (cmd.data0); +if (cmd.action_type ==MLX5_MODIFICATION_TYPE_NOP ) + ++nops; + } +return nops; +} + +static int +flow_hw_validate_compiled_modify_field (struct rte_eth_dev *dev, +const struct mlx5_flow_template_table_cfg *cfg, +struct mlx5_hw_modify_header_action *mhdr, +struct rte_flow_error *error) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr; + +/* +* Header modify pattern length limitation is only valid for HWS groups, i.e. groups > 0. +* In group 0, MODIFY_FIELD actions are handled with header modify actions +* managed by rdma-core. +*/ +if (cfg->attr.flow_attr.group !=0 && + mhdr->mhdr_cmds_num > hca_attr->max_header_modify_pattern_length) { +uint32_t nops =flow_hw_count_nop_modify_field (mhdr); + +DRV_LOG (ERR ,"Too many modify header commands generated from " +"MODIFY_FIELD actions. " +"Generated HW commands = %u (amount of NOP commands = %u). " +"Maximum supported = %u." , + mhdr->mhdr_cmds_num, nops, + hca_attr->max_header_modify_pattern_length); +return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Number of MODIFY_FIELD actions exceeds maximum " +"supported limit of actions" ); + } +return 0 ; +} + static int flow_hw_represented_port_compile(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
@@ -1704,6 +1751,10 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,uint32_t bulk_size;size_t mhdr_len; +if (flow_hw_validate_compiled_modify_field (dev, cfg, &mhdr, error)) { +__flow_hw_action_template_destroy (dev, acts); +return -rte_errno; + } acts->mhdr =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*acts->mhdr),0 ,SOCKET_ID_ANY );if (!acts->mhdr)
Signature · 1 line
2.25.1
Hi,
Quoted 23 lines
-----Original Message-----
From: Dariusz Sosnowski <[email protected]>
Sent: Wednesday, May 17, 2023 11:25 PM
To: Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]
Subject: [PATCH 0/2] net/mlx5: add modify field actions number validationThis patchset adds validation for the number of modify field actions, when working with HW Steering.
Dariusz Sosnowski (2):
common/mlx5: query maximum modify header pattern length net/mlx5: add modify field actions number validationdrivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/common/mlx5/mlx5_prm.h | 3 +- drivers/net/mlx5/mlx5_flow_hw.c | 51 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-)
Quoted 2 lines
--
2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh