* [PATCH v1 1/2] common/mlx5: fix sample ID backward compatibility
2023-03-22 9:38 [PATCH v1 0/2] fix sample ID backward compatibility Rongwei Liu
@ 2023-03-22 9:38 ` Rongwei Liu
2023-03-22 10:00 ` Slava Ovsiienko
2023-03-22 9:38 ` [PATCH v1 2/2] net/mlx5: adopt new sample ID Rongwei Liu
2023-03-22 12:43 ` [PATCH v1 0/2] fix sample ID backward compatibility Raslan Darawsheh
2 siblings, 1 reply; 6+ messages in thread
From: Rongwei Liu @ 2023-03-22 9:38 UTC (permalink / raw)
To: dev, matan, viacheslavo, orika, thomas; +Cc: Michael Baum, rongweil
From: Michael Baum <michaelba@nvidia.com>
The sample ID of parse graph should be treated as a single
value.
Add support for new query operation "QUERY_MATCH_SAMPLE_INFO".
This operation provides sample information for parse graph sample.
DevX commands are only available when dv_flow_en is not zero.
Fixes: f1324a171aac ("net/mlx5: adopt IPv6 routing extension PRM definition")
Cc: rongweil@nvidia.com
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
---
drivers/common/mlx5/mlx5_devx_cmds.c | 58 ++++++++++++++++++++++++++++
drivers/common/mlx5/mlx5_devx_cmds.h | 18 ++++++++-
drivers/common/mlx5/mlx5_prm.h | 29 +++++++++++++-
drivers/common/mlx5/version.map | 1 +
4 files changed, 104 insertions(+), 2 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 580a2ff4f6..86bc183679 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -605,6 +605,62 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
}
}
+/**
+ * Query match sample handle parameters.
+ *
+ * This command allows translating a field sample handle returned by either
+ * PARSE_GRAPH_FLOW_MATCH_SAMPLE or by GENEVE TLV OPTION object into values
+ * used for header modification or header matching/hashing.
+ *
+ * @param[in] ctx
+ * Context used to create either GENEVE TLV option or FLEX PARSE GRAPH object.
+ * @param[in] sample_field_id
+ * Field sample handle returned by either PARSE_GRAPH_FLOW_MATCH_SAMPLE
+ * or by GENEVE TLV OPTION object.
+ * @param[out] attr
+ * Pointer to match sample info attributes structure.
+ *
+ * @return
+ * 0 on success, a negative errno otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_cmd_match_sample_info_query(void *ctx, uint32_t sample_field_id,
+ struct mlx5_devx_match_sample_info_query_attr *attr)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+ uint32_t out[MLX5_ST_SZ_DW(query_match_sample_info_out)] = {0};
+ uint32_t in[MLX5_ST_SZ_DW(query_match_sample_info_in)] = {0};
+ int rc;
+
+ MLX5_SET(query_match_sample_info_in, in, opcode,
+ MLX5_CMD_OP_QUERY_MATCH_SAMPLE_INFO);
+ MLX5_SET(query_match_sample_info_in, in, op_mod, 0);
+ MLX5_SET(query_match_sample_info_in, in, sample_field_id,
+ sample_field_id);
+ rc = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out, sizeof(out));
+ if (rc) {
+ DRV_LOG(ERR, "Failed to query match sample info using DevX: %s",
+ strerror(rc));
+ rte_errno = rc;
+ return -rc;
+ }
+ attr->modify_field_id = MLX5_GET(query_match_sample_info_out, out,
+ modify_field_id);
+ attr->sample_dw_data = MLX5_GET(query_match_sample_info_out, out,
+ field_format_select_dw);
+ attr->sample_dw_ok_bit = MLX5_GET(query_match_sample_info_out, out,
+ ok_bit_format_select_dw);
+ attr->sample_dw_ok_bit_offset = MLX5_GET(query_match_sample_info_out,
+ out, ok_bit_offset);
+ return 0;
+#else
+ (void)ctx;
+ (void)sample_field_id;
+ (void)attr;
+ return -ENOTSUP;
+#endif
+}
+
int
mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
struct mlx5_ext_sample_id *ids,
@@ -1029,6 +1085,8 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
alloc_flow_counter_pd);
attr->flow_counter_access_aso = MLX5_GET(cmd_hca_cap, hcattr,
flow_counter_access_aso);
+ attr->query_match_sample_info = MLX5_GET(cmd_hca_cap, hcattr,
+ query_match_sample_info);
attr->flow_access_aso_opc_mod = MLX5_GET(cmd_hca_cap, hcattr,
flow_access_aso_opc_mod);
if (attr->crypto) {
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index 6ee7d81a99..09540d2f5b 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -296,6 +296,7 @@ struct mlx5_hca_attr {
uint32_t flow_counter_bulk_log_granularity:5;
uint32_t alloc_flow_counter_pd:1;
uint32_t flow_counter_access_aso:1;
+ uint32_t query_match_sample_info:1;
uint32_t flow_access_aso_opc_mod:8;
uint32_t cross_vhca:1;
uint32_t lag_rx_port_affinity:1;
@@ -523,7 +524,6 @@ struct mlx5_devx_virtq_attr {
uint8_t q_type;
};
-
struct mlx5_devx_qp_attr {
uint32_t pd:24;
uint32_t uar_index:24;
@@ -551,6 +551,18 @@ struct mlx5_devx_virtio_q_couners_attr {
uint32_t invalid_buffer;
};
+/*
+ * Match sample info attributes structure, used by:
+ * - GENEVE TLV option query.
+ * - Graph flow match sample query.
+ */
+struct mlx5_devx_match_sample_info_query_attr {
+ uint32_t modify_field_id:12;
+ uint32_t sample_dw_data:8;
+ uint32_t sample_dw_ok_bit:8;
+ uint32_t sample_dw_ok_bit_offset:5;
+};
+
/*
* graph flow match sample attributes structure,
* used by flex parser operations.
@@ -717,6 +729,9 @@ __rte_internal
int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
struct mlx5_devx_modify_tir_attr *tir_attr);
__rte_internal
+int mlx5_devx_cmd_match_sample_info_query(void *ctx, uint32_t sample_field_id,
+ struct mlx5_devx_match_sample_info_query_attr *attr);
+__rte_internal
int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
struct mlx5_ext_sample_id ids[],
uint32_t num, uint8_t *anchor);
@@ -823,4 +838,5 @@ __rte_internal
int
mlx5_devx_cmd_query_lag(void *ctx,
struct mlx5_devx_lag_context *lag_ctx);
+
#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4b0a56f4e5..924f8a7258 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -1169,6 +1169,7 @@ enum {
MLX5_CMD_SET_REGEX_REGISTERS = 0xb06,
MLX5_CMD_QUERY_REGEX_REGISTERS = 0xb07,
MLX5_CMD_OP_ACCESS_REGISTER_USER = 0xb0c,
+ MLX5_CMD_OP_QUERY_MATCH_SAMPLE_INFO = 0xb13,
MLX5_CMD_OP_ALLOW_OTHER_VHCA_ACCESS = 0xb16,
MLX5_CMD_OP_GENERATE_WQE = 0xb17,
};
@@ -1258,6 +1259,31 @@ struct mlx5_ifc_query_flow_counter_in_bits {
u8 flow_counter_id[0x20];
};
+struct mlx5_ifc_query_match_sample_info_out_bits {
+ u8 status[0x8];
+ u8 reserved_at_8[0x18];
+ u8 syndrome[0x20];
+ u8 reserved_at_40[0x40];
+ u8 reserved_at_80[0x4];
+ u8 modify_field_id[0xc];
+ u8 ok_bit_format_select_dw[0x8];
+ u8 field_format_select_dw[0x8];
+ u8 reserved_at_a0[0x3];
+ u8 ok_bit_offset[0x5];
+ u8 reserved_at_a8[0x18];
+ u8 reserved_at_c0[0x40];
+};
+
+struct mlx5_ifc_query_match_sample_info_in_bits {
+ u8 opcode[0x10];
+ u8 uid[0x10];
+ u8 reserved_at_20[0x10];
+ u8 op_mod[0x10];
+ u8 reserved_at_40[0x60];
+ u8 sample_field_id[0x20];
+ u8 reserved_at_c0[0x140];
+};
+
#define MLX5_MAX_KLM_BYTE_COUNT 0x80000000u
#define MLX5_MIN_KLM_FIXED_BUFFER_SIZE 0x1000u
@@ -1442,7 +1468,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {
u8 access_other_hca_roce[0x1];
u8 alloc_flow_counter_pd[0x1];
u8 flow_counter_access_aso[0x1];
- u8 reserved_at_3[0x5];
+ u8 query_match_sample_info[0x1];
+ u8 reserved_at_4[0x4];
u8 flow_access_aso_opc_mod[0x8];
u8 reserved_at_10[0xf];
u8 vhca_resource_manager[0x1];
diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 03c8ce5593..e05e1aa8c5 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -45,6 +45,7 @@ INTERNAL {
mlx5_devx_cmd_flow_counter_query;
mlx5_devx_cmd_flow_dump;
mlx5_devx_cmd_flow_single_dump;
+ mlx5_devx_cmd_match_sample_info_query;
mlx5_devx_cmd_mkey_create;
mlx5_devx_cmd_modify_qp_state;
mlx5_devx_cmd_modify_rq;
--
2.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] net/mlx5: adopt new sample ID
2023-03-22 9:38 [PATCH v1 0/2] fix sample ID backward compatibility Rongwei Liu
2023-03-22 9:38 ` [PATCH v1 1/2] common/mlx5: " Rongwei Liu
@ 2023-03-22 9:38 ` Rongwei Liu
2023-03-22 9:57 ` Slava Ovsiienko
2023-03-22 12:43 ` [PATCH v1 0/2] fix sample ID backward compatibility Raslan Darawsheh
2 siblings, 1 reply; 6+ messages in thread
From: Rongwei Liu @ 2023-03-22 9:38 UTC (permalink / raw)
To: dev, matan, viacheslavo, orika, thomas
Extended sample ID is the behavior of the current firmware and this
change was reverted.
In Apr GA, the sample ID will be the same as 22.11 DPDK (0-7).
Now, the sample ID returned by mlx5_devx_cmd_query_parse_samples()
is still 0-7 and can be used directly by legacy SWS logic.
For HWS, the application should refer to the attributes returned by
mlx5_devx_cmd_query_match_sample_info to get the sample_dw_data/
modify_field_id/sample_dw_ok_bit/sample_dw_ok_bit_offset.
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
---
drivers/common/mlx5/mlx5_devx_cmds.c | 35 +++++++-------
drivers/common/mlx5/mlx5_devx_cmds.h | 7 ++-
drivers/common/mlx5/mlx5_prm.h | 22 +--------
drivers/net/mlx5/mlx5.c | 71 ++++++++++++++++------------
drivers/net/mlx5/mlx5.h | 20 ++++----
drivers/net/mlx5/mlx5_flow.h | 9 ++--
drivers/net/mlx5/mlx5_flow_dv.c | 8 ++--
drivers/net/mlx5/mlx5_flow_flex.c | 19 ++++----
8 files changed, 92 insertions(+), 99 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 86bc183679..d0907fcd49 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -663,7 +663,7 @@ mlx5_devx_cmd_match_sample_info_query(void *ctx, uint32_t sample_field_id,
int
mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
- struct mlx5_ext_sample_id *ids,
+ uint32_t *ids,
uint32_t num, uint8_t *anchor)
{
uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
@@ -695,7 +695,7 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
}
if (anchor)
*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
- for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM && idx <= num; i++) {
+ for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM && idx < num; i++) {
void *s_off = (void *)((char *)sample + i *
MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
uint32_t en;
@@ -704,8 +704,8 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
flow_match_sample_en);
if (!en)
continue;
- ids[idx++].id = MLX5_GET(parse_graph_flow_match_sample, s_off,
- flow_match_sample_field_id);
+ ids[idx++] = MLX5_GET(parse_graph_flow_match_sample, s_off,
+ flow_match_sample_field_id);
}
if (num != idx) {
rte_errno = EINVAL;
@@ -853,8 +853,7 @@ mlx5_devx_cmd_query_hca_parse_graph_node_cap
max_num_arc_out);
attr->max_num_sample = MLX5_GET(parse_graph_node_cap, hcattr,
max_num_sample);
- attr->anchor_en = MLX5_GET(parse_graph_node_cap, hcattr, anchor_en);
- attr->ext_sample_id = MLX5_GET(parse_graph_node_cap, hcattr, ext_sample_id);
+ attr->parse_graph_anchor = MLX5_GET(parse_graph_node_cap, hcattr, parse_graph_anchor);
attr->sample_tunnel_inner2 = MLX5_GET(parse_graph_node_cap, hcattr,
sample_tunnel_inner2);
attr->zero_size_supported = MLX5_GET(parse_graph_node_cap, hcattr,
@@ -1085,10 +1084,20 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
alloc_flow_counter_pd);
attr->flow_counter_access_aso = MLX5_GET(cmd_hca_cap, hcattr,
flow_counter_access_aso);
- attr->query_match_sample_info = MLX5_GET(cmd_hca_cap, hcattr,
- query_match_sample_info);
attr->flow_access_aso_opc_mod = MLX5_GET(cmd_hca_cap, hcattr,
flow_access_aso_opc_mod);
+ /*
+ * Flex item support needs max_num_prog_sample_field
+ * from the Capabilities 2 table for PARSE_GRAPH_NODE
+ */
+ if (attr->parse_graph_flex_node) {
+ rc = mlx5_devx_cmd_query_hca_parse_graph_node_cap
+ (ctx, &attr->flex);
+ if (rc)
+ return -1;
+ attr->flex.query_match_sample_info = MLX5_GET(cmd_hca_cap, hcattr,
+ query_match_sample_info);
+ }
if (attr->crypto) {
attr->aes_xts = MLX5_GET(cmd_hca_cap, hcattr, aes_xts) ||
MLX5_GET(cmd_hca_cap, hcattr, aes_xts_multi_block_be_tweak) ||
@@ -1172,16 +1181,6 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
log_max_num_meter_aso);
}
}
- /*
- * Flex item support needs max_num_prog_sample_field
- * from the Capabilities 2 table for PARSE_GRAPH_NODE
- */
- if (attr->parse_graph_flex_node) {
- rc = mlx5_devx_cmd_query_hca_parse_graph_node_cap
- (ctx, &attr->flex);
- if (rc)
- return -1;
- }
if (attr->vdpa.valid)
mlx5_devx_cmd_query_hca_vdpa_attr(ctx, &attr->vdpa);
if (!attr->eth_net_offloads)
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index 09540d2f5b..ce173bc36a 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -114,8 +114,8 @@ struct mlx5_hca_flex_attr {
uint8_t max_num_arc_out;
uint8_t max_num_sample;
uint8_t max_num_prog_sample:5; /* From HCA CAP 2 */
- uint8_t anchor_en:1;
- uint8_t ext_sample_id:1;
+ uint8_t parse_graph_anchor:1;
+ uint8_t query_match_sample_info:1; /* Support DevX query sample info. */
uint8_t sample_tunnel_inner2:1;
uint8_t zero_size_supported:1;
uint8_t sample_id_in_out:1;
@@ -296,7 +296,6 @@ struct mlx5_hca_attr {
uint32_t flow_counter_bulk_log_granularity:5;
uint32_t alloc_flow_counter_pd:1;
uint32_t flow_counter_access_aso:1;
- uint32_t query_match_sample_info:1;
uint32_t flow_access_aso_opc_mod:8;
uint32_t cross_vhca:1;
uint32_t lag_rx_port_affinity:1;
@@ -733,7 +732,7 @@ int mlx5_devx_cmd_match_sample_info_query(void *ctx, uint32_t sample_field_id,
struct mlx5_devx_match_sample_info_query_attr *attr);
__rte_internal
int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
- struct mlx5_ext_sample_id ids[],
+ uint32_t *ids,
uint32_t num, uint8_t *anchor);
__rte_internal
diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 924f8a7258..4fb1930071 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -1975,8 +1975,8 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
u8 max_num_arc_out[0x08];
u8 max_num_sample[0x08];
u8 reserved_at_78[0x03];
- u8 anchor_en[0x1];
- u8 ext_sample_id[0x1];
+ u8 parse_graph_anchor[0x1];
+ u8 reserved_at_7c[0x01];
u8 sample_tunnel_inner2[0x1];
u8 zero_size_supported[0x1];
u8 sample_id_in_out[0x1];
@@ -1988,24 +1988,6 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
u8 header_length_mask_width[0x08];
};
-/* ext_sample_id structure, see PRM Table: Flow Match Sample ID Format. */
-struct mlx5_ext_sample_id {
- union {
- struct {
-#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
- uint32_t format_select_dw:8;
- uint32_t modify_field_id:12;
- uint32_t sample_id:12;
-#else
- uint32_t sample_id:12;
- uint32_t modify_field_id:12;
- uint32_t format_select_dw:8;
-#endif
- };
- uint32_t id;
- };
-};
-
struct mlx5_ifc_flow_table_prop_layout_bits {
u8 ft_support[0x1];
u8 flow_tag[0x1];
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 41b1b12b91..f24e20a2ef 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -966,12 +966,11 @@ int
mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
{
struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;
struct mlx5_devx_graph_node_attr node = {
.modify_field_select = 0,
};
- struct mlx5_ext_sample_id ids[8];
+ uint32_t ids[8];
int ret;
if (!priv->sh->cdev->config.hca_attr.parse_graph_flex_node) {
@@ -1010,18 +1009,16 @@ mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num, NULL);
if (ret) {
DRV_LOG(ERR, "Failed to query sample IDs.");
- return (rte_errno == 0) ? -ENODEV : -rte_errno;
+ goto error;
}
prf->offset[0] = 0x0;
prf->offset[1] = sizeof(uint32_t);
- if (attr->ext_sample_id) {
- prf->ids[0] = ids[0].sample_id;
- prf->ids[1] = ids[1].sample_id;
- } else {
- prf->ids[0] = ids[0].id;
- prf->ids[1] = ids[1].id;
- }
+ prf->ids[0] = ids[0];
+ prf->ids[1] = ids[1];
return 0;
+error:
+ mlx5_devx_cmd_destroy(prf->obj);
+ return (rte_errno == 0) ? -ENODEV : -rte_errno;
}
/*
@@ -1057,20 +1054,24 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev)
struct mlx5_devx_graph_node_attr node = {
.modify_field_select = 0,
};
- struct mlx5_ext_sample_id ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+ uint32_t ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_common_dev_config *config = &priv->sh->cdev->config;
- void *ibv_ctx = priv->sh->cdev->ctx;
+ void *fp = NULL, *ibv_ctx = priv->sh->cdev->ctx;
int ret;
memset(ids, 0xff, sizeof(ids));
- if (!config->hca_attr.parse_graph_flex_node) {
- DRV_LOG(ERR, "Dynamic flex parser is not supported");
+ if (!config->hca_attr.parse_graph_flex_node ||
+ !config->hca_attr.flex.query_match_sample_info) {
+ DRV_LOG(ERR, "Dynamic flex parser is not supported on HWS");
return -ENOTSUP;
}
if (__atomic_add_fetch(&priv->sh->srh_flex_parser.refcnt, 1, __ATOMIC_RELAXED) > 1)
return 0;
-
+ priv->sh->srh_flex_parser.flex.devx_fp = mlx5_malloc(MLX5_MEM_ZERO,
+ sizeof(struct mlx5_flex_parser_devx), 0, SOCKET_ID_ANY);
+ if (!priv->sh->srh_flex_parser.flex.devx_fp)
+ return -ENOMEM;
node.header_length_mode = MLX5_GRAPH_NODE_LEN_FIELD;
/* Srv6 first two DW are not counted in. */
node.header_length_base_value = 0x8;
@@ -1086,28 +1087,41 @@ mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev)
node.sample[0].flow_match_sample_en = 1;
/* First come first serve no matter inner or outer. */
node.sample[0].flow_match_sample_tunnel_mode = MLX5_GRAPH_SAMPLE_TUNNEL_FIRST;
+ node.sample[0].flow_match_sample_offset_mode = MLX5_GRAPH_SAMPLE_OFFSET_FIXED;
node.out[0].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_TCP;
node.out[0].compare_condition_value = IPPROTO_TCP;
node.out[1].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_UDP;
node.out[1].compare_condition_value = IPPROTO_UDP;
node.out[2].arc_parse_graph_node = MLX5_GRAPH_ARC_NODE_IPV6;
node.out[2].compare_condition_value = IPPROTO_IPV6;
- priv->sh->srh_flex_parser.fp = mlx5_devx_cmd_create_flex_parser(ibv_ctx, &node);
- if (!priv->sh->srh_flex_parser.fp) {
+ fp = mlx5_devx_cmd_create_flex_parser(ibv_ctx, &node);
+ if (!fp) {
DRV_LOG(ERR, "Failed to create flex parser node object.");
- return (rte_errno == 0) ? -ENODEV : -rte_errno;
+ goto error;
}
- priv->sh->srh_flex_parser.num = 1;
- ret = mlx5_devx_cmd_query_parse_samples(priv->sh->srh_flex_parser.fp, ids,
- priv->sh->srh_flex_parser.num,
- &priv->sh->srh_flex_parser.anchor_id);
+ priv->sh->srh_flex_parser.flex.devx_fp->devx_obj = fp;
+ priv->sh->srh_flex_parser.flex.mapnum = 1;
+ priv->sh->srh_flex_parser.flex.devx_fp->num_samples = 1;
+
+ ret = mlx5_devx_cmd_query_parse_samples(fp, ids, priv->sh->srh_flex_parser.flex.mapnum,
+ &priv->sh->srh_flex_parser.flex.devx_fp->anchor_id);
if (ret) {
DRV_LOG(ERR, "Failed to query sample IDs.");
- return (rte_errno == 0) ? -ENODEV : -rte_errno;
+ goto error;
+ }
+ ret = mlx5_devx_cmd_match_sample_info_query(ibv_ctx, ids[0],
+ &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[0]);
+ if (ret) {
+ DRV_LOG(ERR, "Failed to query sample id information.");
+ goto error;
}
- priv->sh->srh_flex_parser.offset[0] = 0x0;
- priv->sh->srh_flex_parser.ids[0].id = ids[0].id;
return 0;
+error:
+ if (fp)
+ mlx5_devx_cmd_destroy(fp);
+ if (priv->sh->srh_flex_parser.flex.devx_fp)
+ mlx5_free(priv->sh->srh_flex_parser.flex.devx_fp);
+ return (rte_errno == 0) ? -ENODEV : -rte_errno;
}
/*
@@ -1125,10 +1139,9 @@ mlx5_free_srh_flex_parser(struct rte_eth_dev *dev)
if (__atomic_sub_fetch(&fp->refcnt, 1, __ATOMIC_RELAXED))
return;
- if (fp->fp)
- mlx5_devx_cmd_destroy(fp->fp);
- fp->fp = NULL;
- fp->num = 0;
+ mlx5_devx_cmd_destroy(fp->flex.devx_fp->devx_obj);
+ mlx5_free(fp->flex.devx_fp);
+ fp->flex.devx_fp = NULL;
}
uint32_t
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 6ad8a42df6..9eae692037 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -545,17 +545,6 @@ struct mlx5_counter_stats_raw {
volatile struct flow_counter_stats *data;
};
-/* Mlx5 internal flex parser profile structure. */
-struct mlx5_internal_flex_parser_profile {
- uint32_t num;/* Actual number of samples. */
- /* Sample IDs for this profile. */
- struct mlx5_ext_sample_id ids[MLX5_FLEX_ITEM_MAPPING_NUM];
- uint32_t offset[MLX5_FLEX_ITEM_MAPPING_NUM]; /* Each ID sample offset. */
- uint8_t anchor_id;
- uint32_t refcnt;
- void *fp; /* DevX flex parser object. */
-};
-
TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
/* Counter global management structure. */
@@ -1323,7 +1312,8 @@ struct mlx5_flex_parser_devx {
uint8_t anchor_id;
void *devx_obj;
struct mlx5_devx_graph_node_attr devx_conf;
- struct mlx5_ext_sample_id sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+ uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+ struct mlx5_devx_match_sample_info_query_attr sample_info[MLX5_GRAPH_NODE_SAMPLE_NUM];
};
/* Pattern field descriptor - how to translate flex pattern into samples. */
@@ -1344,6 +1334,12 @@ struct mlx5_flex_item {
struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM];
};
+/* Mlx5 internal flex parser profile structure. */
+struct mlx5_internal_flex_parser_profile {
+ uint32_t refcnt;
+ struct mlx5_flex_item flex; /* Hold map info for modify field. */
+};
+
struct mlx5_send_to_kernel_action {
void *action;
void *tbl;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 9e1e1b975d..1d116ea0f6 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2651,13 +2651,14 @@ flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
MLX5_ETH_FOREACH_DEV(port, NULL) {
struct mlx5_priv *priv;
struct mlx5_hca_flex_attr *attr;
+ struct mlx5_devx_match_sample_info_query_attr *info;
priv = rte_eth_devices[port].data->dev_private;
attr = &priv->sh->cdev->config.hca_attr.flex;
- if (priv->dr_ctx == dr_ctx && attr->ext_sample_id) {
- if (priv->sh->srh_flex_parser.num)
- return priv->sh->srh_flex_parser.ids[0].format_select_dw *
- sizeof(uint32_t);
+ if (priv->dr_ctx == dr_ctx && attr->query_match_sample_info) {
+ info = &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[0];
+ if (priv->sh->srh_flex_parser.flex.mapnum)
+ return info->sample_dw_data * sizeof(uint32_t);
else
return UINT32_MAX;
}
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ca26f39f2b..f136f43b0a 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1457,7 +1457,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,
struct field_modify_info tmp;
int tmp_id;
- if (!attr->ext_sample_id) {
+ if (!attr->query_match_sample_info) {
DRV_LOG(ERR, "FW doesn't support modify field with flex item.");
return;
}
@@ -1505,8 +1505,8 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,
tmp_id >= (int)flex->devx_fp->num_samples ||
tmp_id >= MLX5_GRAPH_NODE_SAMPLE_NUM)
return;
- if (flex->devx_fp->sample_ids[id].id !=
- flex->devx_fp->sample_ids[tmp_id].id ||
+ if (flex->devx_fp->sample_info[id].modify_field_id !=
+ flex->devx_fp->sample_info[tmp_id].modify_field_id ||
flex->map[j].shift != flex->map[j - 1].width +
flex->map[j - 1].shift) {
i = j;
@@ -1532,7 +1532,7 @@ mlx5_modify_flex_item(const struct rte_eth_dev *dev,
info[idx] = (struct field_modify_info){cur_width / CHAR_BIT, offset / CHAR_BIT,
id == -1 ? MLX5_MODI_INVALID :
(enum mlx5_modification_field)
- flex->devx_fp->sample_ids[id].modify_field_id,
+ flex->devx_fp->sample_info[id].modify_field_id,
map->shift + tmp_ofs, 1};
offset += cur_width;
width_left -= cur_width;
diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c
index aa317fc958..b527f4178c 100644
--- a/drivers/net/mlx5/mlx5_flow_flex.c
+++ b/drivers/net/mlx5/mlx5_flow_flex.c
@@ -280,7 +280,7 @@ mlx5_flex_get_parser_value_per_byte_off(const struct rte_flow_item_flex *item,
continue;
if (id >= (int)tp->devx_fp->num_samples || id >= MLX5_GRAPH_NODE_SAMPLE_NUM)
return -1;
- if (byte_off == tp->devx_fp->sample_ids[id].format_select_dw * sizeof(uint32_t)) {
+ if (byte_off == tp->devx_fp->sample_info[id].sample_dw_data * sizeof(uint32_t)) {
val = mlx5_flex_get_bitfield(item, pos, map->width, map->shift);
if (is_mask)
val &= RTE_BE32(def);
@@ -319,8 +319,6 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
misc_parameters_4);
void *misc4_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_4);
- struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
struct mlx5_flex_item *tp;
uint32_t i, pos = 0;
uint32_t sample_id;
@@ -330,7 +328,6 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
spec = item->spec;
mask = item->mask;
tp = (struct mlx5_flex_item *)spec->handle;
- MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
for (i = 0; i < tp->mapnum; i++) {
struct mlx5_flex_pattern_field *map = tp->map + i;
uint32_t val, msk, def;
@@ -344,10 +341,7 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
return;
val = mlx5_flex_get_bitfield(spec, pos, map->width, map->shift);
msk = mlx5_flex_get_bitfield(mask, pos, map->width, map->shift);
- if (attr->ext_sample_id)
- sample_id = tp->devx_fp->sample_ids[id].sample_id;
- else
- sample_id = tp->devx_fp->sample_ids[id].id;
+ sample_id = tp->devx_fp->sample_ids[id];
mlx5_flex_set_match_sample(misc4_m, misc4_v,
def, msk & def, val & msk & def,
sample_id, id);
@@ -1391,6 +1385,8 @@ mlx5_flex_parser_create_cb(void *list_ctx, void *ctx)
{
struct mlx5_dev_ctx_shared *sh = list_ctx;
struct mlx5_flex_parser_devx *fp, *conf = ctx;
+ uint32_t i;
+ uint8_t sample_info = sh->cdev->config.hca_attr.flex.query_match_sample_info;
int ret;
fp = mlx5_malloc(MLX5_MEM_ZERO, sizeof(struct mlx5_flex_parser_devx),
@@ -1412,6 +1408,13 @@ mlx5_flex_parser_create_cb(void *list_ctx, void *ctx)
&fp->anchor_id);
if (ret)
goto error;
+ /* Query sample information per ID. */
+ for (i = 0; i < fp->num_samples && sample_info; i++) {
+ ret = mlx5_devx_cmd_match_sample_info_query(sh->cdev->ctx, fp->sample_ids[i],
+ &fp->sample_info[i]);
+ if (ret)
+ goto error;
+ }
DRV_LOG(DEBUG, "DEVx flex parser %p created, samples num: %u",
(const void *)fp, fp->num_samples);
return &fp->entry;
--
2.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread