DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rongwei Liu <rongweil@nvidia.com>
To: <dev@dpdk.org>, <matan@nvidia.com>, <viacheslavo@nvidia.com>,
	<orika@nvidia.com>, <thomas@monjalon.net>
Cc: Michael Baum <michaelba@nvidia.com>, <rongweil@nvidia.com>
Subject: [PATCH v1 1/2] common/mlx5: fix sample ID backward compatibility
Date: Wed, 22 Mar 2023 11:38:14 +0200	[thread overview]
Message-ID: <20230322093815.3736701-2-rongweil@nvidia.com> (raw)
In-Reply-To: <20230322093815.3736701-1-rongweil@nvidia.com>

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


  reply	other threads:[~2023-03-22  9:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22  9:38 [PATCH v1 0/2] " Rongwei Liu
2023-03-22  9:38 ` Rongwei Liu [this message]
2023-03-22 10:00   ` [PATCH v1 1/2] common/mlx5: " Slava Ovsiienko
2023-03-22  9:38 ` [PATCH v1 2/2] net/mlx5: adopt new sample ID 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230322093815.3736701-2-rongweil@nvidia.com \
    --to=rongweil@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=michaelba@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).