* [PATCH 0/2] net/mlx5: add modify field actions number validation
@ 2023-05-17 20:24 Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 1/2] common/mlx5: query maximum modify header pattern length Dariusz Sosnowski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dariusz Sosnowski @ 2023-05-17 20:24 UTC (permalink / raw)
To: Ori Kam, Suanming Mou, Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
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(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] common/mlx5: query maximum modify header pattern length
2023-05-17 20:24 [PATCH 0/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
@ 2023-05-17 20:24 ` Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 2/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
2023-05-24 14:07 ` [PATCH 0/2] " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Dariusz Sosnowski @ 2023-05-17 20:24 UTC (permalink / raw)
To: Ori Kam, Suanming Mou, Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
This patch adds querying the HCA capabilities for maximum supported
pattern length for Header Modify Pattern objects.
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
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(-)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index d0907fcd49..95d86d9573 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -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,
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index ce173bc36a..410ada31b8 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -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. */
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index ed3d5efbb7..8cf9316589 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -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];
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net/mlx5: add modify field actions number validation
2023-05-17 20:24 [PATCH 0/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 1/2] common/mlx5: query maximum modify header pattern length Dariusz Sosnowski
@ 2023-05-17 20:24 ` Dariusz Sosnowski
2023-05-24 14:07 ` [PATCH 0/2] " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Dariusz Sosnowski @ 2023-05-17 20:24 UTC (permalink / raw)
To: Ori Kam, Suanming Mou, Matan Azrad, Viacheslav Ovsiienko; +Cc: dev
This 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.
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 51 +++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 7e0ee8d883..0a7416c7a1 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -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)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 0/2] net/mlx5: add modify field actions number validation
2023-05-17 20:24 [PATCH 0/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 1/2] common/mlx5: query maximum modify header pattern length Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 2/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
@ 2023-05-24 14:07 ` Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2023-05-24 14:07 UTC (permalink / raw)
To: Dariusz Sosnowski, Ori Kam, Suanming Mou, Matan Azrad, Slava Ovsiienko
Cc: dev
Hi,
> -----Original Message-----
> From: Dariusz Sosnowski <dsosnowski@nvidia.com>
> Sent: Wednesday, May 17, 2023 11:25 PM
> To: Ori Kam <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 0/2] 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(-)
>
> --
> 2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-24 14:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 20:24 [PATCH 0/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 1/2] common/mlx5: query maximum modify header pattern length Dariusz Sosnowski
2023-05-17 20:24 ` [PATCH 2/2] net/mlx5: add modify field actions number validation Dariusz Sosnowski
2023-05-24 14:07 ` [PATCH 0/2] " Raslan Darawsheh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).