Skip to contentSkip to conversation

fix sample ID backward compatibility

PATCH In review Rongwei Liu 3 participants 6 messages Mar 22, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

cover fix sample ID backward compatibility

Rollback flex parser sample ID format changes and keep it compatible with previous firmware.

Michael Baum (1):
common/mlx5: fix sample ID backward compatibility

Rongwei Liu (1):
net/mlx5: adopt new sample ID

 drivers/common/mlx5/mlx5_devx_cmds.c | 89 +++++++++++++++++++++++-----
 drivers/common/mlx5/mlx5_devx_cmds.h | 23 +++++--
 drivers/common/mlx5/mlx5_prm.h       | 51 +++++++++-------
 drivers/common/mlx5/version.map      |  1 +
 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 +++---
 9 files changed, 193 insertions(+), 98 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 common/mlx5: fix sample ID backward compatibility

From: Michael Baum <[email protected]>

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")
---
 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(-)
drivers/common/mlx5/mlx5_devx_cmds.c +58 -0
index 580a2ff4f6..86bc183679 100644
@@ -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) {
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
index 6ee7d81a99..09540d2f5b 100644
@@ -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_ */
drivers/common/mlx5/mlx5_prm.h +28 -1
index 4b0a56f4e5..924f8a7258 100644
@@ -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];
drivers/common/mlx5/version.map +1 -0
index 03c8ce5593..e05e1aa8c5 100644
@@ -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;
Signature · 1 line
2.27.0
Acked-by on v1 1/2
#2 lore raw

RE: [PATCH v1 1/2] common/mlx5: fix sample ID backward compatibility

Quoted 17 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: среда, 22 марта 2023 г. 11:38
To: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Michael Baum <[email protected]>; Rongwei Liu <[email protected]>
Subject: [PATCH v1 1/2] common/mlx5: fix sample ID backward compatibility

From: Michael Baum <[email protected]>

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.

Quoted 4 lines
Fixes f1324a171aac ("net/mlx5: adopt IPv6 routing extension PRM definition")
#3 lore raw

PATCH 2/2 net/mlx5: adopt new sample ID

In reply to Rongwei Liu

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.

---
 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(-)
drivers/common/mlx5/mlx5_devx_cmds.c +17 -18
index 86bc183679..d0907fcd49 100644
@@ -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)
drivers/common/mlx5/mlx5_devx_cmds.h +3 -4
index 09540d2f5b..ce173bc36a 100644
@@ -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
drivers/common/mlx5/mlx5_prm.h +2 -20
index 924f8a7258..4fb1930071 100644
@@ -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];
drivers/net/mlx5/mlx5.c +42 -29

130 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +8 -12
index 6ad8a42df6..9eae692037 100644
@@ -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;
drivers/net/mlx5/mlx5_flow.h +5 -4
index 9e1e1b975d..1d116ea0f6 100644
@@ -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;
 		}
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
index ca26f39f2b..f136f43b0a 100644
@@ -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;
drivers/net/mlx5/mlx5_flow_flex.c +11 -8
index aa317fc958..b527f4178c 100644
@@ -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;
Signature · 1 line
2.27.0
Acked-by on v1 2/2
#4 lore raw

RE: [PATCH v1 2/2] net/mlx5: adopt new sample ID

Quoted 14 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: среда, 22 марта 2023 г. 11:38
To: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Subject: [PATCH v1 2/2] net/mlx5: adopt new sample ID

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.

Quoted 5 lines

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.

#5 lore raw
In reply to Rongwei Liu

Hi,

Quoted 28 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Wednesday, March 22, 2023 11:38 AM
To: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Subject: [PATCH v1 0/2] fix sample ID backward compatibility

Rollback flex parser sample ID format changes and keep it compatible with previous firmware.

Michael Baum (1):
common/mlx5: fix sample ID backward compatibility

Rongwei Liu (1):
net/mlx5: adopt new sample ID

 drivers/common/mlx5/mlx5_devx_cmds.c | 89 +++++++++++++++++++++++-----
drivers/common/mlx5/mlx5_devx_cmds.h | 23 +++++--
 drivers/common/mlx5/mlx5_prm.h       | 51 +++++++++-------
 drivers/common/mlx5/version.map      |  1 +
 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 +++---
 9 files changed, 193 insertions(+), 98 deletions(-)
Quoted 2 lines

--
2.27.0

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh