Skip to contentSkip to conversation

mlx5: replaced hardware queue object

PATCH Superseded Raja Zidane 2 participants 38 messages Sep 3, 2021 – Oct 5, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mlx5: replaced hardware queue object

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

 drivers/common/mlx5/mlx5_common_devx.c   | 144 ++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h   |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c     |  17 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  13 +-
 drivers/common/mlx5/mlx5_prm.h           |  47 ++++++-
 drivers/common/mlx5/version.map          |   3 +
 drivers/compress/mlx5/mlx5_compress.c    |  71 +++++-----
 drivers/crypto/mlx5/mlx5_crypto.c        |  96 ++++----------
 drivers/crypto/mlx5/mlx5_crypto.h        |   5 +-
 drivers/regex/mlx5/mlx5_regex.c          |   6 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  64 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 159 +++++++++++------------
 drivers/vdpa/mlx5/mlx5_vdpa.h            |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c      |  53 ++------
 15 files changed, 435 insertions(+), 287 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 common/mlx5: share DevX QP operations

Currently drivers using QP (vDPA, crypto and compress, regex soon) manage their memory, creation, modification and destruction of the QP, in almost identical code.
Move QP memory management, creation and destruction to common. Add common function to change QP state to RTS.
Add user_index attribute to QP creation.
It's for better code maintenance and reuse.

---
 drivers/common/mlx5/mlx5_common_devx.c | 144 +++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c   |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.h   |   1 +
 drivers/common/mlx5/version.map        |   3 +
 drivers/crypto/mlx5/mlx5_crypto.c      |  96 ++++-------------
 drivers/crypto/mlx5/mlx5_crypto.h      |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h          |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c    |  53 +++------
 9 files changed, 209 insertions(+), 122 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +144 -0
index 22c8d356c4..825f84b183 100644
@@ -271,6 +271,115 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,
 	return -rte_errno;
 }
 
+/**
+ * Destroy DevX Queue Pair.
+ *
+ * @param[in] qp
+ *   DevX QP to destroy.
+ */
+void
+mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)
+{
+	if (qp->qp)
+		claim_zero(mlx5_devx_cmd_destroy(qp->qp));
+	if (qp->umem_obj)
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
+	if (qp->umem_buf)
+		mlx5_free((void *)(uintptr_t)qp->umem_buf);
+}
+
+/**
+ * Create Queue Pair using DevX API.
+ *
+ * Get a pointer to partially initialized attributes structure, and updates the
+ * following fields:
+ *   wq_umem_id
+ *   wq_umem_offset
+ *   dbr_umem_valid
+ *   dbr_umem_id
+ *   dbr_address
+ *   log_page_size
+ * All other fields are updated by caller.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in/out] qp_obj
+ *   Pointer to QP to create.
+ * @param[in] log_wqbb_n
+ *   Log of number of WQBBs in queue.
+ * @param[in] attr
+ *   Pointer to QP attributes structure.
+ * @param[in] socket
+ *   Socket to use for allocation.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,
+		    struct mlx5_devx_qp_attr *attr, int socket)
+{
+	struct mlx5_devx_obj *qp = NULL;
+	struct mlx5dv_devx_umem *umem_obj = NULL;
+	void *umem_buf = NULL;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	uint32_t umem_size, umem_dbrec;
+	uint16_t qp_size = 1 << log_wqbb_n;
+	int ret;
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get WQE buf alignment.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Allocate memory buffer for WQEs and doorbell record. */
+	umem_size = MLX5_WQE_SIZE * qp_size;
+	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
+	umem_size += MLX5_DBR_SIZE;
+	umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size,
+			       alignment, socket);
+	if (!umem_buf) {
+		DRV_LOG(ERR, "Failed to allocate memory for QP.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Register allocated buffer in user space with DevX. */
+	umem_obj = mlx5_os_umem_reg(ctx, (void *)(uintptr_t)umem_buf, umem_size,
+				    IBV_ACCESS_LOCAL_WRITE);
+	if (!umem_obj) {
+		DRV_LOG(ERR, "Failed to register umem for QP.");
+		rte_errno = errno;
+		goto error;
+	}
+	/* Fill attributes for SQ object creation. */
+	attr->wq_umem_id = mlx5_os_get_umem_id(umem_obj);
+	attr->wq_umem_offset = 0;
+	attr->dbr_umem_valid = 1;
+	attr->dbr_umem_id = attr->wq_umem_id;
+	attr->dbr_address = umem_dbrec;
+	attr->log_page_size = MLX5_LOG_PAGE_SIZE;
+	/* Create send queue object with DevX. */
+	qp = mlx5_devx_cmd_create_qp(ctx, attr);
+	if (!qp) {
+		DRV_LOG(ERR, "Can't create DevX QP object.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
+	qp_obj->umem_buf = umem_buf;
+	qp_obj->umem_obj = umem_obj;
+	qp_obj->qp = qp;
+	qp_obj->db_rec = RTE_PTR_ADD(qp_obj->umem_buf, umem_dbrec);
+	return 0;
+error:
+	ret = rte_errno;
+	if (umem_obj)
+		claim_zero(mlx5_os_umem_dereg(umem_obj));
+	if (umem_buf)
+		mlx5_free((void *)(uintptr_t)umem_buf);
+	rte_errno = ret;
+	return -rte_errno;
+}
+
 /**
  * Destroy DevX Receive Queue.
  *
@@ -385,3 +494,38 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+
+/**
+ * Change QP state to RTS.
+ *
+ * @param[in] qp
+ *   DevX QP to change.
+ * @param[in] remote_qp_id
+ *   The remote QP ID for MLX5_CMD_OP_INIT2RTR_QP operation.
+ *
+ * @return
+ *	 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id)
+{
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
drivers/common/mlx5/mlx5_common_devx.h +23 -0
index aad0184e5a..f699405f69 100644
@@ -33,6 +33,18 @@ struct mlx5_devx_sq {
 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
 };
 
+/* DevX Queue Pair structure. */
+struct mlx5_devx_qp {
+	struct mlx5_devx_obj *qp; /* The QP DevX object. */
+	void *umem_obj; /* The QP umem object. */
+	union {
+		void *umem_buf;
+		struct mlx5_wqe *wqes; /* The QP ring buffer. */
+		struct mlx5_aso_wqe *aso_wqes;
+	};
+	volatile uint32_t *db_rec; /* The QP doorbell record. */
+};
+
 /* DevX Receive Queue structure. */
 struct mlx5_devx_rq {
 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
@@ -59,6 +71,14 @@ int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
 			uint16_t log_wqbb_n,
 			struct mlx5_devx_create_sq_attr *attr, int socket);
 
+__rte_internal
+void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
+
+__rte_internal
+int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
+			uint16_t log_wqbb_n,
+			struct mlx5_devx_qp_attr *attr, int socket);
+
 __rte_internal
 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
 
@@ -67,4 +87,7 @@ int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
index 56407cc332..ac554cca05 100644
@@ -2021,6 +2021,7 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, st, MLX5_QP_ST_RC);
 	MLX5_SET(qpc, qpc, pd, attr->pd);
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
+	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index e576e30f24..c071629904 100644
@@ -397,6 +397,7 @@ struct mlx5_devx_qp_attr {
 	uint64_t dbr_address;
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
+	uint32_t user_index:24;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/version.map +3 -0
index e5cb6b7060..d3c5040aac 100644
@@ -67,6 +67,9 @@ INTERNAL {
 
 	mlx5_devx_get_out_command_status;
 
+	mlx5_devx_qp2rts;
+	mlx5_devx_qp_create;
+	mlx5_devx_qp_destroy;
 	mlx5_devx_rq_create;
 	mlx5_devx_rq_destroy;
 	mlx5_devx_sq_create;
drivers/crypto/mlx5/mlx5_crypto.c +22 -74

168 lines not on this page · raw message

drivers/crypto/mlx5/mlx5_crypto.h +1 -4
index d49b0001f0..013eed30b5 100644
@@ -43,11 +43,8 @@ struct mlx5_crypto_priv {
 struct mlx5_crypto_qp {
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_devx_cq cq_obj;
-	struct mlx5_devx_obj *qp_obj;
+	struct mlx5_devx_qp qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
 	struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
 	struct mlx5_mr_ctrl mr_ctrl;
drivers/vdpa/mlx5/mlx5_vdpa.h +1 -4
index 2a04e36607..a27f3fdadb 100644
@@ -54,10 +54,7 @@ struct mlx5_vdpa_cq {
 struct mlx5_vdpa_event_qp {
 	struct mlx5_vdpa_cq cq;
 	struct mlx5_devx_obj *fw_qp;
-	struct mlx5_devx_obj *sw_qp;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
+	struct mlx5_devx_qp sw_qp;
 };
 
 struct mlx5_vdpa_query_mr {
drivers/vdpa/mlx5/mlx5_vdpa_event.c +13 -40

118 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

v2 cover mlx5: replaced hardware queue object

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

V2: fix coding style issues.

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

 drivers/common/mlx5/mlx5_common_devx.c   | 144 +++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h   |  23 +++
 drivers/common/mlx5/mlx5_devx_cmds.c     |  23 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  13 +-
 drivers/common/mlx5/mlx5_prm.h           |  48 ++++++-
 drivers/common/mlx5/version.map          |   3 +
 drivers/compress/mlx5/mlx5_compress.c    |  73 +++++-----
 drivers/crypto/mlx5/mlx5_crypto.c        | 100 ++++---------
 drivers/crypto/mlx5/mlx5_crypto.h        |   5 +-
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 drivers/vdpa/mlx5/mlx5_vdpa.h            |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c      |  59 +++-----
 15 files changed, 460 insertions(+), 294 deletions(-)
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 1/5 common/mlx5: share DevX QP operations

Currently drivers using QP (vDPA, crypto and compress, regex soon) manage their memory, creation, modification and destruction of the QP, in almost identical code.
Move QP memory management, creation and destruction to common. Add common function to change QP state to RTS.
Add user_index attribute to QP creation.
It's for better code maintenance and reuse.

---
 drivers/common/mlx5/mlx5_common_devx.c | 144 +++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c   |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.h   |   1 +
 drivers/common/mlx5/version.map        |   3 +
 drivers/crypto/mlx5/mlx5_crypto.c      | 100 +++++------------
 drivers/crypto/mlx5/mlx5_crypto.h      |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h          |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c    |  59 +++-------
 9 files changed, 216 insertions(+), 125 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +144 -0
index 22c8d356c4..825f84b183 100644
@@ -271,6 +271,115 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,
 	return -rte_errno;
 }
 
+/**
+ * Destroy DevX Queue Pair.
+ *
+ * @param[in] qp
+ *   DevX QP to destroy.
+ */
+void
+mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)
+{
+	if (qp->qp)
+		claim_zero(mlx5_devx_cmd_destroy(qp->qp));
+	if (qp->umem_obj)
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
+	if (qp->umem_buf)
+		mlx5_free((void *)(uintptr_t)qp->umem_buf);
+}
+
+/**
+ * Create Queue Pair using DevX API.
+ *
+ * Get a pointer to partially initialized attributes structure, and updates the
+ * following fields:
+ *   wq_umem_id
+ *   wq_umem_offset
+ *   dbr_umem_valid
+ *   dbr_umem_id
+ *   dbr_address
+ *   log_page_size
+ * All other fields are updated by caller.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in/out] qp_obj
+ *   Pointer to QP to create.
+ * @param[in] log_wqbb_n
+ *   Log of number of WQBBs in queue.
+ * @param[in] attr
+ *   Pointer to QP attributes structure.
+ * @param[in] socket
+ *   Socket to use for allocation.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,
+		    struct mlx5_devx_qp_attr *attr, int socket)
+{
+	struct mlx5_devx_obj *qp = NULL;
+	struct mlx5dv_devx_umem *umem_obj = NULL;
+	void *umem_buf = NULL;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	uint32_t umem_size, umem_dbrec;
+	uint16_t qp_size = 1 << log_wqbb_n;
+	int ret;
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get WQE buf alignment.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Allocate memory buffer for WQEs and doorbell record. */
+	umem_size = MLX5_WQE_SIZE * qp_size;
+	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
+	umem_size += MLX5_DBR_SIZE;
+	umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size,
+			       alignment, socket);
+	if (!umem_buf) {
+		DRV_LOG(ERR, "Failed to allocate memory for QP.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Register allocated buffer in user space with DevX. */
+	umem_obj = mlx5_os_umem_reg(ctx, (void *)(uintptr_t)umem_buf, umem_size,
+				    IBV_ACCESS_LOCAL_WRITE);
+	if (!umem_obj) {
+		DRV_LOG(ERR, "Failed to register umem for QP.");
+		rte_errno = errno;
+		goto error;
+	}
+	/* Fill attributes for SQ object creation. */
+	attr->wq_umem_id = mlx5_os_get_umem_id(umem_obj);
+	attr->wq_umem_offset = 0;
+	attr->dbr_umem_valid = 1;
+	attr->dbr_umem_id = attr->wq_umem_id;
+	attr->dbr_address = umem_dbrec;
+	attr->log_page_size = MLX5_LOG_PAGE_SIZE;
+	/* Create send queue object with DevX. */
+	qp = mlx5_devx_cmd_create_qp(ctx, attr);
+	if (!qp) {
+		DRV_LOG(ERR, "Can't create DevX QP object.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
+	qp_obj->umem_buf = umem_buf;
+	qp_obj->umem_obj = umem_obj;
+	qp_obj->qp = qp;
+	qp_obj->db_rec = RTE_PTR_ADD(qp_obj->umem_buf, umem_dbrec);
+	return 0;
+error:
+	ret = rte_errno;
+	if (umem_obj)
+		claim_zero(mlx5_os_umem_dereg(umem_obj));
+	if (umem_buf)
+		mlx5_free((void *)(uintptr_t)umem_buf);
+	rte_errno = ret;
+	return -rte_errno;
+}
+
 /**
  * Destroy DevX Receive Queue.
  *
@@ -385,3 +494,38 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+
+/**
+ * Change QP state to RTS.
+ *
+ * @param[in] qp
+ *   DevX QP to change.
+ * @param[in] remote_qp_id
+ *   The remote QP ID for MLX5_CMD_OP_INIT2RTR_QP operation.
+ *
+ * @return
+ *	 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id)
+{
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
drivers/common/mlx5/mlx5_common_devx.h +23 -0
index aad0184e5a..f699405f69 100644
@@ -33,6 +33,18 @@ struct mlx5_devx_sq {
 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
 };
 
+/* DevX Queue Pair structure. */
+struct mlx5_devx_qp {
+	struct mlx5_devx_obj *qp; /* The QP DevX object. */
+	void *umem_obj; /* The QP umem object. */
+	union {
+		void *umem_buf;
+		struct mlx5_wqe *wqes; /* The QP ring buffer. */
+		struct mlx5_aso_wqe *aso_wqes;
+	};
+	volatile uint32_t *db_rec; /* The QP doorbell record. */
+};
+
 /* DevX Receive Queue structure. */
 struct mlx5_devx_rq {
 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
@@ -59,6 +71,14 @@ int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
 			uint16_t log_wqbb_n,
 			struct mlx5_devx_create_sq_attr *attr, int socket);
 
+__rte_internal
+void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
+
+__rte_internal
+int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
+			uint16_t log_wqbb_n,
+			struct mlx5_devx_qp_attr *attr, int socket);
+
 __rte_internal
 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
 
@@ -67,4 +87,7 @@ int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
index 56407cc332..ac554cca05 100644
@@ -2021,6 +2021,7 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, st, MLX5_QP_ST_RC);
 	MLX5_SET(qpc, qpc, pd, attr->pd);
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
+	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index e576e30f24..c071629904 100644
@@ -397,6 +397,7 @@ struct mlx5_devx_qp_attr {
 	uint64_t dbr_address;
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
+	uint32_t user_index:24;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/version.map +3 -0
index e5cb6b7060..d3c5040aac 100644
@@ -67,6 +67,9 @@ INTERNAL {
 
 	mlx5_devx_get_out_command_status;
 
+	mlx5_devx_qp2rts;
+	mlx5_devx_qp_create;
+	mlx5_devx_qp_destroy;
 	mlx5_devx_rq_create;
 	mlx5_devx_rq_destroy;
 	mlx5_devx_sq_create;
drivers/crypto/mlx5/mlx5_crypto.c +25 -75

172 lines not on this page · raw message

drivers/crypto/mlx5/mlx5_crypto.h +1 -4
index d49b0001f0..013eed30b5 100644
@@ -43,11 +43,8 @@ struct mlx5_crypto_priv {
 struct mlx5_crypto_qp {
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_devx_cq cq_obj;
-	struct mlx5_devx_obj *qp_obj;
+	struct mlx5_devx_qp qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
 	struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
 	struct mlx5_mr_ctrl mr_ctrl;
drivers/vdpa/mlx5/mlx5_vdpa.h +1 -4
index 2a04e36607..a27f3fdadb 100644
@@ -54,10 +54,7 @@ struct mlx5_vdpa_cq {
 struct mlx5_vdpa_event_qp {
 	struct mlx5_vdpa_cq cq;
 	struct mlx5_devx_obj *fw_qp;
-	struct mlx5_devx_obj *sw_qp;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
+	struct mlx5_devx_qp sw_qp;
 };
 
 struct mlx5_vdpa_query_mr {
drivers/vdpa/mlx5/mlx5_vdpa_event.c +17 -42

122 lines not on this page · raw message

Signature · 1 line
2.17.1
#4 lore raw

v3 cover mlx5: replaced hardware queue object

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

V2: fix checkpatch errors.
V3: rebase.

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

 drivers/common/mlx5/mlx5_common_devx.c   | 144 +++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h   |  23 +++
 drivers/common/mlx5/mlx5_devx_cmds.c     |  23 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  13 +-
 drivers/common/mlx5/mlx5_prm.h           |  48 ++++++-
 drivers/common/mlx5/version.map          |   3 +
 drivers/compress/mlx5/mlx5_compress.c    |  73 +++++-----
 drivers/crypto/mlx5/mlx5_crypto.c        | 102 ++++----------
 drivers/crypto/mlx5/mlx5_crypto.h        |   5 +-
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 drivers/vdpa/mlx5/mlx5_vdpa.h            |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c      |  59 +++-----
 15 files changed, 461 insertions(+), 295 deletions(-)
Signature · 1 line
2.17.1
#5 lore raw

PATCH v3 1/5 common/mlx5: share DevX QP operations

Currently drivers using QP (vDPA, crypto and compress, regex soon) manage their memory, creation, modification and destruction of the QP, in almost identical code.
Move QP memory management, creation and destruction to common. Add common function to change QP state to RTS.
Add user_index attribute to QP creation.
It's for better code maintenance and reuse.

---
 drivers/common/mlx5/mlx5_common_devx.c | 144 +++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c   |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.h   |   1 +
 drivers/common/mlx5/version.map        |   3 +
 drivers/crypto/mlx5/mlx5_crypto.c      | 102 +++++-------------
 drivers/crypto/mlx5/mlx5_crypto.h      |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h          |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c    |  59 +++-------
 9 files changed, 217 insertions(+), 126 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +144 -0
index 22c8d356c4..825f84b183 100644
@@ -271,6 +271,115 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,
 	return -rte_errno;
 }
 
+/**
+ * Destroy DevX Queue Pair.
+ *
+ * @param[in] qp
+ *   DevX QP to destroy.
+ */
+void
+mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)
+{
+	if (qp->qp)
+		claim_zero(mlx5_devx_cmd_destroy(qp->qp));
+	if (qp->umem_obj)
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
+	if (qp->umem_buf)
+		mlx5_free((void *)(uintptr_t)qp->umem_buf);
+}
+
+/**
+ * Create Queue Pair using DevX API.
+ *
+ * Get a pointer to partially initialized attributes structure, and updates the
+ * following fields:
+ *   wq_umem_id
+ *   wq_umem_offset
+ *   dbr_umem_valid
+ *   dbr_umem_id
+ *   dbr_address
+ *   log_page_size
+ * All other fields are updated by caller.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in/out] qp_obj
+ *   Pointer to QP to create.
+ * @param[in] log_wqbb_n
+ *   Log of number of WQBBs in queue.
+ * @param[in] attr
+ *   Pointer to QP attributes structure.
+ * @param[in] socket
+ *   Socket to use for allocation.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,
+		    struct mlx5_devx_qp_attr *attr, int socket)
+{
+	struct mlx5_devx_obj *qp = NULL;
+	struct mlx5dv_devx_umem *umem_obj = NULL;
+	void *umem_buf = NULL;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	uint32_t umem_size, umem_dbrec;
+	uint16_t qp_size = 1 << log_wqbb_n;
+	int ret;
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get WQE buf alignment.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Allocate memory buffer for WQEs and doorbell record. */
+	umem_size = MLX5_WQE_SIZE * qp_size;
+	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
+	umem_size += MLX5_DBR_SIZE;
+	umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size,
+			       alignment, socket);
+	if (!umem_buf) {
+		DRV_LOG(ERR, "Failed to allocate memory for QP.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Register allocated buffer in user space with DevX. */
+	umem_obj = mlx5_os_umem_reg(ctx, (void *)(uintptr_t)umem_buf, umem_size,
+				    IBV_ACCESS_LOCAL_WRITE);
+	if (!umem_obj) {
+		DRV_LOG(ERR, "Failed to register umem for QP.");
+		rte_errno = errno;
+		goto error;
+	}
+	/* Fill attributes for SQ object creation. */
+	attr->wq_umem_id = mlx5_os_get_umem_id(umem_obj);
+	attr->wq_umem_offset = 0;
+	attr->dbr_umem_valid = 1;
+	attr->dbr_umem_id = attr->wq_umem_id;
+	attr->dbr_address = umem_dbrec;
+	attr->log_page_size = MLX5_LOG_PAGE_SIZE;
+	/* Create send queue object with DevX. */
+	qp = mlx5_devx_cmd_create_qp(ctx, attr);
+	if (!qp) {
+		DRV_LOG(ERR, "Can't create DevX QP object.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
+	qp_obj->umem_buf = umem_buf;
+	qp_obj->umem_obj = umem_obj;
+	qp_obj->qp = qp;
+	qp_obj->db_rec = RTE_PTR_ADD(qp_obj->umem_buf, umem_dbrec);
+	return 0;
+error:
+	ret = rte_errno;
+	if (umem_obj)
+		claim_zero(mlx5_os_umem_dereg(umem_obj));
+	if (umem_buf)
+		mlx5_free((void *)(uintptr_t)umem_buf);
+	rte_errno = ret;
+	return -rte_errno;
+}
+
 /**
  * Destroy DevX Receive Queue.
  *
@@ -385,3 +494,38 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+
+/**
+ * Change QP state to RTS.
+ *
+ * @param[in] qp
+ *   DevX QP to change.
+ * @param[in] remote_qp_id
+ *   The remote QP ID for MLX5_CMD_OP_INIT2RTR_QP operation.
+ *
+ * @return
+ *	 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id)
+{
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
drivers/common/mlx5/mlx5_common_devx.h +23 -0
index aad0184e5a..f699405f69 100644
@@ -33,6 +33,18 @@ struct mlx5_devx_sq {
 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
 };
 
+/* DevX Queue Pair structure. */
+struct mlx5_devx_qp {
+	struct mlx5_devx_obj *qp; /* The QP DevX object. */
+	void *umem_obj; /* The QP umem object. */
+	union {
+		void *umem_buf;
+		struct mlx5_wqe *wqes; /* The QP ring buffer. */
+		struct mlx5_aso_wqe *aso_wqes;
+	};
+	volatile uint32_t *db_rec; /* The QP doorbell record. */
+};
+
 /* DevX Receive Queue structure. */
 struct mlx5_devx_rq {
 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
@@ -59,6 +71,14 @@ int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
 			uint16_t log_wqbb_n,
 			struct mlx5_devx_create_sq_attr *attr, int socket);
 
+__rte_internal
+void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
+
+__rte_internal
+int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
+			uint16_t log_wqbb_n,
+			struct mlx5_devx_qp_attr *attr, int socket);
+
 __rte_internal
 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
 
@@ -67,4 +87,7 @@ int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
index 56407cc332..ac554cca05 100644
@@ -2021,6 +2021,7 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, st, MLX5_QP_ST_RC);
 	MLX5_SET(qpc, qpc, pd, attr->pd);
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
+	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index e576e30f24..c071629904 100644
@@ -397,6 +397,7 @@ struct mlx5_devx_qp_attr {
 	uint64_t dbr_address;
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
+	uint32_t user_index:24;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/version.map +3 -0
index e5cb6b7060..d3c5040aac 100644
@@ -67,6 +67,9 @@ INTERNAL {
 
 	mlx5_devx_get_out_command_status;
 
+	mlx5_devx_qp2rts;
+	mlx5_devx_qp_create;
+	mlx5_devx_qp_destroy;
 	mlx5_devx_rq_create;
 	mlx5_devx_rq_destroy;
 	mlx5_devx_sq_create;
drivers/crypto/mlx5/mlx5_crypto.c +26 -76

174 lines not on this page · raw message

drivers/crypto/mlx5/mlx5_crypto.h +1 -4
index d589e0ac3d..4d7e6d2d10 100644
@@ -44,11 +44,8 @@ struct mlx5_crypto_priv {
 struct mlx5_crypto_qp {
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_devx_cq cq_obj;
-	struct mlx5_devx_obj *qp_obj;
+	struct mlx5_devx_qp qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
 	struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
 	struct mlx5_mr_ctrl mr_ctrl;
drivers/vdpa/mlx5/mlx5_vdpa.h +1 -4
index 2a04e36607..a27f3fdadb 100644
@@ -54,10 +54,7 @@ struct mlx5_vdpa_cq {
 struct mlx5_vdpa_event_qp {
 	struct mlx5_vdpa_cq cq;
 	struct mlx5_devx_obj *fw_qp;
-	struct mlx5_devx_obj *sw_qp;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
+	struct mlx5_devx_qp sw_qp;
 };
 
 struct mlx5_vdpa_query_mr {
drivers/vdpa/mlx5/mlx5_vdpa_event.c +17 -42

122 lines not on this page · raw message

Signature · 1 line
2.17.1
#6 lore raw

PATCH v3 2/5 common/mlx5: update new MMO HCA capabilities

In reply to Raja Zidane

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 15 ++++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h       | 20 ++++++++++++++------
 3 files changed, 34 insertions(+), 12 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -3
index ac554cca05..00c78b1288 100644
@@ -858,9 +858,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..070c538c8c 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xe];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x1];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
Signature · 1 line
2.17.1
#7 lore raw

Re: [dpdk-dev] [PATCH V3 2/5] common/mlx5: update new MMO HCA capabilities

15/09/2021 02:05, Raja Zidane:

Quoted 14 lines

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---

drivers/common/mlx5/mlx5_devx_cmds.h +0 -1
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;

drivers/common/mlx5/mlx5_devx_cmds.h struct mlx5_hca_attr { · line 183

Quoted 10 lines
drivers/common/mlx5/mlx5_devx_cmds.h +8 -2
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;

It does not compile:
struct mlx5_hca_attr has no member named mmo_compress_en

#8 lore raw

PATCH v3 3/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  7 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -0
index 00c78b1288..eefb869b7d 100644
@@ -2032,6 +2032,13 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if (attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in,
+				in, qpc_extension_and_pas_list);
+			void *qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list,
+				qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +27 -1
index 070c538c8c..cb28adb80a 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,11 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits
+					qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#9 lore raw

PATCH v3 4/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 73 +++++++++++++++------------
 1 file changed, 42 insertions(+), 31 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +42 -31
index c5e0a83a8c..5c5aa87a18 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1;
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp
+			&& priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if (ret)
 		goto err;
-	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
+		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#10 lore raw

PATCH v3 5/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 4 files changed, 133 insertions(+), 125 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +5 -2
index f17b6df47f..a3368749b9 100644
@@ -146,7 +146,8 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) &&
+		(!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +165,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +32 -33

117 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +87 -83

383 lines not on this page · raw message

Signature · 1 line
2.17.1
#11 lore raw

v4 cover mlx5: replaced hardware queue object

In reply to Raja Zidane

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

V2: fix checkpatch errors.
V3: rebase.
V4: compilation error in commit 2/5.

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

 drivers/common/mlx5/mlx5_common_devx.c   | 144 +++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h   |  23 +++
 drivers/common/mlx5/mlx5_devx_cmds.c     |  23 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  13 +-
 drivers/common/mlx5/mlx5_prm.h           |  48 ++++++-
 drivers/common/mlx5/version.map          |   3 +
 drivers/compress/mlx5/mlx5_compress.c    |  73 +++++-----
 drivers/crypto/mlx5/mlx5_crypto.c        | 102 ++++----------
 drivers/crypto/mlx5/mlx5_crypto.h        |   5 +-
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 drivers/vdpa/mlx5/mlx5_vdpa.h            |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c      |  59 +++-----
 15 files changed, 461 insertions(+), 295 deletions(-)
Signature · 1 line
2.17.1
#12 lore raw

PATCH v4 1/5 common/mlx5: share DevX QP operations

Currently drivers using QP (vDPA, crypto and compress, regex soon) manage their memory, creation, modification and destruction of the QP, in almost identical code.
Move QP memory management, creation and destruction to common. Add common function to change QP state to RTS.
Add user_index attribute to QP creation.
It's for better code maintenance and reuse.

---
 drivers/common/mlx5/mlx5_common_devx.c | 144 +++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c   |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.h   |   1 +
 drivers/common/mlx5/version.map        |   3 +
 drivers/crypto/mlx5/mlx5_crypto.c      | 102 +++++-------------
 drivers/crypto/mlx5/mlx5_crypto.h      |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h          |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c    |  59 +++-------
 9 files changed, 217 insertions(+), 126 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +144 -0
index 22c8d356c4..825f84b183 100644
@@ -271,6 +271,115 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,
 	return -rte_errno;
 }
 
+/**
+ * Destroy DevX Queue Pair.
+ *
+ * @param[in] qp
+ *   DevX QP to destroy.
+ */
+void
+mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)
+{
+	if (qp->qp)
+		claim_zero(mlx5_devx_cmd_destroy(qp->qp));
+	if (qp->umem_obj)
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
+	if (qp->umem_buf)
+		mlx5_free((void *)(uintptr_t)qp->umem_buf);
+}
+
+/**
+ * Create Queue Pair using DevX API.
+ *
+ * Get a pointer to partially initialized attributes structure, and updates the
+ * following fields:
+ *   wq_umem_id
+ *   wq_umem_offset
+ *   dbr_umem_valid
+ *   dbr_umem_id
+ *   dbr_address
+ *   log_page_size
+ * All other fields are updated by caller.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in/out] qp_obj
+ *   Pointer to QP to create.
+ * @param[in] log_wqbb_n
+ *   Log of number of WQBBs in queue.
+ * @param[in] attr
+ *   Pointer to QP attributes structure.
+ * @param[in] socket
+ *   Socket to use for allocation.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,
+		    struct mlx5_devx_qp_attr *attr, int socket)
+{
+	struct mlx5_devx_obj *qp = NULL;
+	struct mlx5dv_devx_umem *umem_obj = NULL;
+	void *umem_buf = NULL;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	uint32_t umem_size, umem_dbrec;
+	uint16_t qp_size = 1 << log_wqbb_n;
+	int ret;
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get WQE buf alignment.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Allocate memory buffer for WQEs and doorbell record. */
+	umem_size = MLX5_WQE_SIZE * qp_size;
+	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
+	umem_size += MLX5_DBR_SIZE;
+	umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size,
+			       alignment, socket);
+	if (!umem_buf) {
+		DRV_LOG(ERR, "Failed to allocate memory for QP.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Register allocated buffer in user space with DevX. */
+	umem_obj = mlx5_os_umem_reg(ctx, (void *)(uintptr_t)umem_buf, umem_size,
+				    IBV_ACCESS_LOCAL_WRITE);
+	if (!umem_obj) {
+		DRV_LOG(ERR, "Failed to register umem for QP.");
+		rte_errno = errno;
+		goto error;
+	}
+	/* Fill attributes for SQ object creation. */
+	attr->wq_umem_id = mlx5_os_get_umem_id(umem_obj);
+	attr->wq_umem_offset = 0;
+	attr->dbr_umem_valid = 1;
+	attr->dbr_umem_id = attr->wq_umem_id;
+	attr->dbr_address = umem_dbrec;
+	attr->log_page_size = MLX5_LOG_PAGE_SIZE;
+	/* Create send queue object with DevX. */
+	qp = mlx5_devx_cmd_create_qp(ctx, attr);
+	if (!qp) {
+		DRV_LOG(ERR, "Can't create DevX QP object.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
+	qp_obj->umem_buf = umem_buf;
+	qp_obj->umem_obj = umem_obj;
+	qp_obj->qp = qp;
+	qp_obj->db_rec = RTE_PTR_ADD(qp_obj->umem_buf, umem_dbrec);
+	return 0;
+error:
+	ret = rte_errno;
+	if (umem_obj)
+		claim_zero(mlx5_os_umem_dereg(umem_obj));
+	if (umem_buf)
+		mlx5_free((void *)(uintptr_t)umem_buf);
+	rte_errno = ret;
+	return -rte_errno;
+}
+
 /**
  * Destroy DevX Receive Queue.
  *
@@ -385,3 +494,38 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+
+/**
+ * Change QP state to RTS.
+ *
+ * @param[in] qp
+ *   DevX QP to change.
+ * @param[in] remote_qp_id
+ *   The remote QP ID for MLX5_CMD_OP_INIT2RTR_QP operation.
+ *
+ * @return
+ *	 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id)
+{
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
drivers/common/mlx5/mlx5_common_devx.h +23 -0
index aad0184e5a..f699405f69 100644
@@ -33,6 +33,18 @@ struct mlx5_devx_sq {
 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
 };
 
+/* DevX Queue Pair structure. */
+struct mlx5_devx_qp {
+	struct mlx5_devx_obj *qp; /* The QP DevX object. */
+	void *umem_obj; /* The QP umem object. */
+	union {
+		void *umem_buf;
+		struct mlx5_wqe *wqes; /* The QP ring buffer. */
+		struct mlx5_aso_wqe *aso_wqes;
+	};
+	volatile uint32_t *db_rec; /* The QP doorbell record. */
+};
+
 /* DevX Receive Queue structure. */
 struct mlx5_devx_rq {
 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
@@ -59,6 +71,14 @@ int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
 			uint16_t log_wqbb_n,
 			struct mlx5_devx_create_sq_attr *attr, int socket);
 
+__rte_internal
+void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
+
+__rte_internal
+int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
+			uint16_t log_wqbb_n,
+			struct mlx5_devx_qp_attr *attr, int socket);
+
 __rte_internal
 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
 
@@ -67,4 +87,7 @@ int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
index 56407cc332..ac554cca05 100644
@@ -2021,6 +2021,7 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, st, MLX5_QP_ST_RC);
 	MLX5_SET(qpc, qpc, pd, attr->pd);
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
+	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index e576e30f24..c071629904 100644
@@ -397,6 +397,7 @@ struct mlx5_devx_qp_attr {
 	uint64_t dbr_address;
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
+	uint32_t user_index:24;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/version.map +3 -0
index e5cb6b7060..d3c5040aac 100644
@@ -67,6 +67,9 @@ INTERNAL {
 
 	mlx5_devx_get_out_command_status;
 
+	mlx5_devx_qp2rts;
+	mlx5_devx_qp_create;
+	mlx5_devx_qp_destroy;
 	mlx5_devx_rq_create;
 	mlx5_devx_rq_destroy;
 	mlx5_devx_sq_create;
drivers/crypto/mlx5/mlx5_crypto.c +26 -76

174 lines not on this page · raw message

drivers/crypto/mlx5/mlx5_crypto.h +1 -4
index d589e0ac3d..4d7e6d2d10 100644
@@ -44,11 +44,8 @@ struct mlx5_crypto_priv {
 struct mlx5_crypto_qp {
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_devx_cq cq_obj;
-	struct mlx5_devx_obj *qp_obj;
+	struct mlx5_devx_qp qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
 	struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
 	struct mlx5_mr_ctrl mr_ctrl;
drivers/vdpa/mlx5/mlx5_vdpa.h +1 -4
index 2a04e36607..a27f3fdadb 100644
@@ -54,10 +54,7 @@ struct mlx5_vdpa_cq {
 struct mlx5_vdpa_event_qp {
 	struct mlx5_vdpa_cq cq;
 	struct mlx5_devx_obj *fw_qp;
-	struct mlx5_devx_obj *sw_qp;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
+	struct mlx5_devx_qp sw_qp;
 };
 
 struct mlx5_vdpa_query_mr {
drivers/vdpa/mlx5/mlx5_vdpa_event.c +17 -42

122 lines not on this page · raw message

Signature · 1 line
2.17.1
#13 lore raw

PATCH v4 2/5 common/mlx5: update new MMO HCA capabilities

In reply to Raja Zidane

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c  | 15 ++++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h  | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h        | 20 ++++++++++++++------
 drivers/compress/mlx5/mlx5_compress.c |  4 ++--
 4 files changed, 36 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -3
index ac554cca05..00c78b1288 100644
@@ -858,9 +858,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..ec5f871c61 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xc];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x3];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
drivers/compress/mlx5/mlx5_compress.c +2 -2
index c5e0a83a8c..1e03030510 100644
@@ -813,8 +813,8 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+	    att.mmo_dma_sq_en == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
Signature · 1 line
2.17.1
#14 lore raw

PATCH v4 3/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  7 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -0
index 00c78b1288..eefb869b7d 100644
@@ -2032,6 +2032,13 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if (attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in,
+				in, qpc_extension_and_pas_list);
+			void *qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list,
+				qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +27 -1
index ec5f871c61..54e62aa153 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,11 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits
+					qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#15 lore raw

PATCH v4 4/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 73 +++++++++++++++------------
 1 file changed, 42 insertions(+), 31 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +42 -31
index 1e03030510..5c5aa87a18 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1;
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp
+			&& priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if (ret)
 		goto err;
-	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
-	    att.mmo_dma_sq_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
+		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#16 lore raw

PATCH v4 5/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 4 files changed, 133 insertions(+), 125 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +5 -2
index f17b6df47f..a3368749b9 100644
@@ -146,7 +146,8 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) &&
+		(!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +165,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +32 -33

117 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +87 -83

384 lines not on this page · raw message

Signature · 1 line
2.17.1
#17 lore raw

v5 cover mlx5: replaced hardware queue object

In reply to Raja Zidane

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

V2: fix checkpatch errors.
V3: rebase.
V4: compilation error in commit 2/5.
V5: rebase.

Raja Zidane (5):
common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects compress/mlx5: allow partial transformations support

 drivers/common/mlx5/mlx5_devx_cmds.c     |  22 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  12 +-
 drivers/common/mlx5/mlx5_prm.h           |  48 ++++++-
 drivers/compress/mlx5/mlx5_compress.c    | 128 +++++++++++------
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 8 files changed, 287 insertions(+), 181 deletions(-)
Signature · 1 line
2.17.1
#18 lore raw

PATCH v5 1/5 common/mlx5: update new MMO HCA capabilities

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c  | 15 ++++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h  | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h        | 20 ++++++++++++++------
 drivers/compress/mlx5/mlx5_compress.c |  4 ++--
 4 files changed, 36 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -3
index ac554cca05..00c78b1288 100644
@@ -858,9 +858,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..ec5f871c61 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xc];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x3];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
drivers/compress/mlx5/mlx5_compress.c +2 -2
index c5e0a83a8c..1e03030510 100644
@@ -813,8 +813,8 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+	    att.mmo_dma_sq_en == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
Signature · 1 line
2.17.1
#19 lore raw

PATCH v5 2/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  7 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -0
index 00c78b1288..eefb869b7d 100644
@@ -2032,6 +2032,13 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if (attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in,
+				in, qpc_extension_and_pas_list);
+			void *qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list,
+				qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +27 -1
index ec5f871c61..54e62aa153 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,11 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits
+					qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#20 lore raw

PATCH v5 3/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 73 +++++++++++++++------------
 1 file changed, 42 insertions(+), 31 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +42 -31
index 1e03030510..5c5aa87a18 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1;
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp
+			&& priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if (ret)
 		goto err;
-	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
-	    att.mmo_dma_sq_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
+		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#21 lore raw

PATCH v5 4/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 4 files changed, 133 insertions(+), 125 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +5 -2
index 8866a4d0c6..5aa988be6d 100644
@@ -146,7 +146,8 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) &&
+		(!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +165,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +32 -33

117 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +87 -83

384 lines not on this page · raw message

Signature · 1 line
2.17.1
#22 lore raw

PATCH v5 5/5 compress/mlx5: allow partial transformations support

In reply to Raja Zidane

Currently compress, decompress and dma are allowed only when all 3 capabilities are on.
A case where the user wants decompress offload, if decompress capability is on but one of compress, dma is off, is not allowed.
Split compress/decompress/dma support check to allow partial transformations.

---
 drivers/compress/mlx5/mlx5_compress.c | 61 ++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 15 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +46 -15
index 5c5aa87a18..e94e8fb0c6 100644
@@ -291,17 +291,44 @@ mlx5_compress_xform_create(struct rte_compressdev *dev,
 	struct mlx5_compress_xform *xfrm;
 	uint32_t size;
 
-	if (xform->type == RTE_COMP_COMPRESS && xform->compress.level ==
-							  RTE_COMP_LEVEL_NONE) {
-		DRV_LOG(ERR, "Non-compressed block is not supported.");
-		return -ENOTSUP;
-	}
-	if ((xform->type == RTE_COMP_COMPRESS && xform->compress.hash_algo !=
-	     RTE_COMP_HASH_ALGO_NONE) || (xform->type == RTE_COMP_DECOMPRESS &&
-		      xform->decompress.hash_algo != RTE_COMP_HASH_ALGO_NONE)) {
-		DRV_LOG(ERR, "SHA is not supported.");
+	switch (xform->type) {
+	case RTE_COMP_COMPRESS:
+		if (xform->compress.algo == RTE_COMP_ALGO_NULL &&
+				!priv->mmo_dma_qp && !priv->mmo_dma_sq) {
+			DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?");
+			return -ENOTSUP;
+		} else if (!priv->mmo_comp_qp && !priv->mmo_comp_sq) {
+			DRV_LOG(ERR, "Not enough capabilities to support compress operation, maybe old FW/OFED version?");
+			return -ENOTSUP;
+		}
+		if (xform->compress.level == RTE_COMP_LEVEL_NONE) {
+			DRV_LOG(ERR, "Non-compressed block is not supported.");
+			return -ENOTSUP;
+		}
+		if (xform->compress.hash_algo != RTE_COMP_HASH_ALGO_NONE) {
+			DRV_LOG(ERR, "SHA is not supported.");
+			return -ENOTSUP;
+		}
+		break;
+	case RTE_COMP_DECOMPRESS:
+		if (xform->decompress.algo == RTE_COMP_ALGO_NULL &&
+				!priv->mmo_dma_qp && !priv->mmo_dma_sq) {
+			DRV_LOG(ERR, "Not enough capabilities to support DMA operation, maybe old FW/OFED version?");
+			return -ENOTSUP;
+		} else if (!priv->mmo_decomp_qp && !priv->mmo_decomp_sq) {
+			DRV_LOG(ERR, "Not enough capabilities to support decompress operation, maybe old FW/OFED version?");
+			return -ENOTSUP;
+		}
+		if (xform->compress.hash_algo != RTE_COMP_HASH_ALGO_NONE) {
+			DRV_LOG(ERR, "SHA is not supported.");
+			return -ENOTSUP;
+		}
+		break;
+	default:
+		DRV_LOG(ERR, "Xform type should be compress/decompress");
 		return -ENOTSUP;
 	}
+
 	xfrm = rte_zmalloc_socket(__func__, sizeof(*xfrm), 0,
 						    priv->dev_config.socket_id);
 	if (xfrm == NULL)
@@ -816,12 +843,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		rte_errno = ENODEV;
 		return -rte_errno;
 	}
-	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
-		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
-		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
-		DRV_LOG(ERR, "Not enough capabilities to support compress "
-			"operations, maybe old FW/OFED version?");
+	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0) {
+		DRV_LOG(ERR, "Failed to query device capabilities");
+		claim_zero(mlx5_glue->close_device(ctx));
+		rte_errno = ENOTSUP;
+		return -ENOTSUP;
+	}
+	if (!att.mmo_decompress_qp_en && !att.mmo_decompress_sq_en
+		&& !att.mmo_compress_qp_en && !att.mmo_compress_sq_en
+		&& !att.mmo_dma_qp_en && !att.mmo_dma_sq_en) {
+		DRV_LOG(ERR, "Not enough capabilities to support compress operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
 		rte_errno = ENOTSUP;
 		return -ENOTSUP;
Signature · 1 line
2.17.1
#23 lore raw

v6 cover mlx5: replaced hardware queue object

In reply to Raja Zidane

The mlx5 PMDs for compress and regex classes use an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, mmo, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the mmo configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set mmo configuration according to the new FW capabilities.

V2: fix checkpatch errors.
V3: rebase.
V4: compilation error in commit 2/5.
V5: rebase.
V6: rebase on main.

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

 drivers/common/mlx5/mlx5_common_devx.c   | 144 +++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h   |  23 +++
 drivers/common/mlx5/mlx5_devx_cmds.c     |  23 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h     |  13 +-
 drivers/common/mlx5/mlx5_prm.h           |  48 ++++++-
 drivers/common/mlx5/version.map          |   3 +
 drivers/compress/mlx5/mlx5_compress.c    |  73 +++++-----
 drivers/crypto/mlx5/mlx5_crypto.c        | 102 ++++----------
 drivers/crypto/mlx5/mlx5_crypto.h        |   5 +-
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 drivers/vdpa/mlx5/mlx5_vdpa.h            |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c      |  59 +++-----
 15 files changed, 461 insertions(+), 295 deletions(-)
Signature · 1 line
2.17.1
#24 lore raw

PATCH v6 1/5 common/mlx5: share DevX QP operations

Currently drivers using QP (vDPA, crypto and compress, regex soon) manage their memory, creation, modification and destruction of the QP, in almost identical code.
Move QP memory management, creation and destruction to common. Add common function to change QP state to RTS.
Add user_index attribute to QP creation.
It's for better code maintenance and reuse.

---
 drivers/common/mlx5/mlx5_common_devx.c | 144 +++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_common_devx.h |  23 ++++
 drivers/common/mlx5/mlx5_devx_cmds.c   |   1 +
 drivers/common/mlx5/mlx5_devx_cmds.h   |   1 +
 drivers/common/mlx5/version.map        |   3 +
 drivers/crypto/mlx5/mlx5_crypto.c      | 102 +++++-------------
 drivers/crypto/mlx5/mlx5_crypto.h      |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h          |   5 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c    |  59 +++-------
 9 files changed, 217 insertions(+), 126 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +144 -0
index 22c8d356c4..825f84b183 100644
@@ -271,6 +271,115 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,
 	return -rte_errno;
 }
 
+/**
+ * Destroy DevX Queue Pair.
+ *
+ * @param[in] qp
+ *   DevX QP to destroy.
+ */
+void
+mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)
+{
+	if (qp->qp)
+		claim_zero(mlx5_devx_cmd_destroy(qp->qp));
+	if (qp->umem_obj)
+		claim_zero(mlx5_os_umem_dereg(qp->umem_obj));
+	if (qp->umem_buf)
+		mlx5_free((void *)(uintptr_t)qp->umem_buf);
+}
+
+/**
+ * Create Queue Pair using DevX API.
+ *
+ * Get a pointer to partially initialized attributes structure, and updates the
+ * following fields:
+ *   wq_umem_id
+ *   wq_umem_offset
+ *   dbr_umem_valid
+ *   dbr_umem_id
+ *   dbr_address
+ *   log_page_size
+ * All other fields are updated by caller.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in/out] qp_obj
+ *   Pointer to QP to create.
+ * @param[in] log_wqbb_n
+ *   Log of number of WQBBs in queue.
+ * @param[in] attr
+ *   Pointer to QP attributes structure.
+ * @param[in] socket
+ *   Socket to use for allocation.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,
+		    struct mlx5_devx_qp_attr *attr, int socket)
+{
+	struct mlx5_devx_obj *qp = NULL;
+	struct mlx5dv_devx_umem *umem_obj = NULL;
+	void *umem_buf = NULL;
+	size_t alignment = MLX5_WQE_BUF_ALIGNMENT;
+	uint32_t umem_size, umem_dbrec;
+	uint16_t qp_size = 1 << log_wqbb_n;
+	int ret;
+
+	if (alignment == (size_t)-1) {
+		DRV_LOG(ERR, "Failed to get WQE buf alignment.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Allocate memory buffer for WQEs and doorbell record. */
+	umem_size = MLX5_WQE_SIZE * qp_size;
+	umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE);
+	umem_size += MLX5_DBR_SIZE;
+	umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size,
+			       alignment, socket);
+	if (!umem_buf) {
+		DRV_LOG(ERR, "Failed to allocate memory for QP.");
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	/* Register allocated buffer in user space with DevX. */
+	umem_obj = mlx5_os_umem_reg(ctx, (void *)(uintptr_t)umem_buf, umem_size,
+				    IBV_ACCESS_LOCAL_WRITE);
+	if (!umem_obj) {
+		DRV_LOG(ERR, "Failed to register umem for QP.");
+		rte_errno = errno;
+		goto error;
+	}
+	/* Fill attributes for SQ object creation. */
+	attr->wq_umem_id = mlx5_os_get_umem_id(umem_obj);
+	attr->wq_umem_offset = 0;
+	attr->dbr_umem_valid = 1;
+	attr->dbr_umem_id = attr->wq_umem_id;
+	attr->dbr_address = umem_dbrec;
+	attr->log_page_size = MLX5_LOG_PAGE_SIZE;
+	/* Create send queue object with DevX. */
+	qp = mlx5_devx_cmd_create_qp(ctx, attr);
+	if (!qp) {
+		DRV_LOG(ERR, "Can't create DevX QP object.");
+		rte_errno = ENOMEM;
+		goto error;
+	}
+	qp_obj->umem_buf = umem_buf;
+	qp_obj->umem_obj = umem_obj;
+	qp_obj->qp = qp;
+	qp_obj->db_rec = RTE_PTR_ADD(qp_obj->umem_buf, umem_dbrec);
+	return 0;
+error:
+	ret = rte_errno;
+	if (umem_obj)
+		claim_zero(mlx5_os_umem_dereg(umem_obj));
+	if (umem_buf)
+		mlx5_free((void *)(uintptr_t)umem_buf);
+	rte_errno = ret;
+	return -rte_errno;
+}
+
 /**
  * Destroy DevX Receive Queue.
  *
@@ -385,3 +494,38 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,
 	return -rte_errno;
 }
 
+
+/**
+ * Change QP state to RTS.
+ *
+ * @param[in] qp
+ *   DevX QP to change.
+ * @param[in] remote_qp_id
+ *   The remote QP ID for MLX5_CMD_OP_INIT2RTR_QP operation.
+ *
+ * @return
+ *	 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id)
+{
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RST2INIT_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to INIT state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_INIT2RTR_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTR state(%u).",
+			rte_errno);
+		return -1;
+	}
+	if (mlx5_devx_cmd_modify_qp_state(qp->qp, MLX5_CMD_OP_RTR2RTS_QP,
+					  remote_qp_id)) {
+		DRV_LOG(ERR, "Failed to modify QP to RTS state(%u).",
+			rte_errno);
+		return -1;
+	}
+	return 0;
+}
drivers/common/mlx5/mlx5_common_devx.h +23 -0
index aad0184e5a..f699405f69 100644
@@ -33,6 +33,18 @@ struct mlx5_devx_sq {
 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
 };
 
+/* DevX Queue Pair structure. */
+struct mlx5_devx_qp {
+	struct mlx5_devx_obj *qp; /* The QP DevX object. */
+	void *umem_obj; /* The QP umem object. */
+	union {
+		void *umem_buf;
+		struct mlx5_wqe *wqes; /* The QP ring buffer. */
+		struct mlx5_aso_wqe *aso_wqes;
+	};
+	volatile uint32_t *db_rec; /* The QP doorbell record. */
+};
+
 /* DevX Receive Queue structure. */
 struct mlx5_devx_rq {
 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
@@ -59,6 +71,14 @@ int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
 			uint16_t log_wqbb_n,
 			struct mlx5_devx_create_sq_attr *attr, int socket);
 
+__rte_internal
+void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
+
+__rte_internal
+int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
+			uint16_t log_wqbb_n,
+			struct mlx5_devx_qp_attr *attr, int socket);
+
 __rte_internal
 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
 
@@ -67,4 +87,7 @@ int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
 			uint32_t wqe_size, uint16_t log_wqbb_n,
 			struct mlx5_devx_create_rq_attr *attr, int socket);
 
+__rte_internal
+int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
+
 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
index 56407cc332..ac554cca05 100644
@@ -2021,6 +2021,7 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, st, MLX5_QP_ST_RC);
 	MLX5_SET(qpc, qpc, pd, attr->pd);
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
+	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index e576e30f24..c071629904 100644
@@ -397,6 +397,7 @@ struct mlx5_devx_qp_attr {
 	uint64_t dbr_address;
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
+	uint32_t user_index:24;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/version.map +3 -0
index e5cb6b7060..d3c5040aac 100644
@@ -67,6 +67,9 @@ INTERNAL {
 
 	mlx5_devx_get_out_command_status;
 
+	mlx5_devx_qp2rts;
+	mlx5_devx_qp_create;
+	mlx5_devx_qp_destroy;
 	mlx5_devx_rq_create;
 	mlx5_devx_rq_destroy;
 	mlx5_devx_sq_create;
drivers/crypto/mlx5/mlx5_crypto.c +26 -76

174 lines not on this page · raw message

drivers/crypto/mlx5/mlx5_crypto.h +1 -4
index d589e0ac3d..4d7e6d2d10 100644
@@ -44,11 +44,8 @@ struct mlx5_crypto_priv {
 struct mlx5_crypto_qp {
 	struct mlx5_crypto_priv *priv;
 	struct mlx5_devx_cq cq_obj;
-	struct mlx5_devx_obj *qp_obj;
+	struct mlx5_devx_qp qp_obj;
 	struct rte_cryptodev_stats stats;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
 	struct rte_crypto_op **ops;
 	struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */
 	struct mlx5_mr_ctrl mr_ctrl;
drivers/vdpa/mlx5/mlx5_vdpa.h +1 -4
index 2a04e36607..a27f3fdadb 100644
@@ -54,10 +54,7 @@ struct mlx5_vdpa_cq {
 struct mlx5_vdpa_event_qp {
 	struct mlx5_vdpa_cq cq;
 	struct mlx5_devx_obj *fw_qp;
-	struct mlx5_devx_obj *sw_qp;
-	struct mlx5dv_devx_umem *umem_obj;
-	void *umem_buf;
-	volatile uint32_t *db_rec;
+	struct mlx5_devx_qp sw_qp;
 };
 
 struct mlx5_vdpa_query_mr {
drivers/vdpa/mlx5/mlx5_vdpa_event.c +17 -42

122 lines not on this page · raw message

Signature · 1 line
2.17.1
#25 lore raw

PATCH v6 2/5 common/mlx5: update new MMO HCA capabilities

In reply to Raja Zidane

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c  | 15 ++++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h  | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h        | 20 ++++++++++++++------
 drivers/compress/mlx5/mlx5_compress.c |  4 ++--
 4 files changed, 36 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -3
index ac554cca05..00c78b1288 100644
@@ -858,9 +858,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..ec5f871c61 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xc];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x3];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
drivers/compress/mlx5/mlx5_compress.c +2 -2
index c5e0a83a8c..1e03030510 100644
@@ -813,8 +813,8 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+	    att.mmo_dma_sq_en == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
Signature · 1 line
2.17.1
#26 lore raw

PATCH v6 3/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  7 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -0
index 00c78b1288..eefb869b7d 100644
@@ -2032,6 +2032,13 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if (attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in,
+				in, qpc_extension_and_pas_list);
+			void *qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list,
+				qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +27 -1
index ec5f871c61..54e62aa153 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,11 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits
+					qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#27 lore raw

PATCH v6 4/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 73 +++++++++++++++------------
 1 file changed, 42 insertions(+), 31 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +42 -31
index 1e03030510..5c5aa87a18 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1;
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp
+			&& priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if (ret)
 		goto err;
-	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
-	    att.mmo_dma_sq_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
+		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#28 lore raw

PATCH v6 5/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 4 files changed, 133 insertions(+), 125 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +5 -2
index 8866a4d0c6..5aa988be6d 100644
@@ -146,7 +146,8 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) &&
+		(!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +165,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +32 -33

117 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +87 -83

384 lines not on this page · raw message

Signature · 1 line
2.17.1
#29 lore raw
In reply to Raja Zidane
Quoted 6 lines

Raja Zidane (5):
common/mlx5: share DevX QP operations common/mlx5: update new MMO HCA capabilities common/mlx5: add MMO configuration for the DevX QP compress/mlx5: refactor queue HW object regex/mlx5: refactor HW queue objects

Applied, thanks.

#30 lore raw

PATCH v2 2/5 common/mlx5: update new MMO HCA capabilities

In reply to Raja Zidane

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 15 ++++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h       | 20 ++++++++++++++------
 3 files changed, 34 insertions(+), 12 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -3
index ac554cca05..00c78b1288 100644
@@ -858,9 +858,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr,
+			decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..070c538c8c 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xe];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x1];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
Signature · 1 line
2.17.1
#31 lore raw

PATCH v2 3/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  7 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -0
index 00c78b1288..eefb869b7d 100644
@@ -2032,6 +2032,13 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if (attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in,
+				in, qpc_extension_and_pas_list);
+			void *qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list,
+				qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +27 -1
index 070c538c8c..cb28adb80a 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,11 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits
+					qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#32 lore raw

PATCH v2 4/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 73 +++++++++++++++------------
 1 file changed, 42 insertions(+), 31 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +42 -31
index 883e720ec1..0f002195c6 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1;
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp
+			&& priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if (ret)
 		goto err;
-	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+		att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 ||
+		att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#33 lore raw

PATCH v2 5/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   7 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  65 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 170 ++++++++++++-----------
 4 files changed, 133 insertions(+), 125 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +5 -2
index f17b6df47f..a3368749b9 100644
@@ -146,7 +146,8 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) &&
+		(!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +165,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +32 -33

117 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +87 -83

383 lines not on this page · raw message

Signature · 1 line
2.17.1
#34 lore raw

PATCH 2/5 common/mlx5: update new MMO HCA capabilities

In reply to Raja Zidane

New MMO HCA capabilities were added and others were renamed. Align hca capabilities with new prm.
Add support in devx interface for changes in HCA capabilities.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 11 ++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h | 11 ++++++++---
 drivers/common/mlx5/mlx5_prm.h       | 20 ++++++++++++++------
 3 files changed, 30 insertions(+), 12 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +8 -3
index ac554cca05..fbc2123883 100644
@@ -858,9 +858,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->log_max_srq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_srq_sz);
 	attr->reg_c_preserve =
 		MLX5_GET(cmd_hca_cap, hcattr, reg_c_preserve);
-	attr->mmo_dma_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo);
-	attr->mmo_compress_en = MLX5_GET(cmd_hca_cap, hcattr, compress);
-	attr->mmo_decompress_en = MLX5_GET(cmd_hca_cap, hcattr, decompress);
+	attr->mmo_regex_qp_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_qp);
+	attr->mmo_regex_sq_en = MLX5_GET(cmd_hca_cap, hcattr, regexp_mmo_sq);
+	attr->mmo_dma_sq_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_sq);
+	attr->mmo_compress_sq_en = MLX5_GET(cmd_hca_cap, hcattr, compress_mmo_sq);
+	attr->mmo_decompress_sq_en = MLX5_GET(cmd_hca_cap, hcattr, decompress_mmo_sq);
+	attr->mmo_dma_qp_en = MLX5_GET(cmd_hca_cap, hcattr, dma_mmo_qp);
+	attr->mmo_compress_qp_en = MLX5_GET(cmd_hca_cap, hcattr, compress_mmo_qp);
+	attr->mmo_decompress_qp_en = MLX5_GET(cmd_hca_cap, hcattr, decompress_mmo_qp);
 	attr->compress_min_block_size = MLX5_GET(cmd_hca_cap, hcattr,
 						 compress_min_block_size);
 	attr->log_max_mmo_dma = MLX5_GET(cmd_hca_cap, hcattr, log_dma_mmo_size);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -3
index c071629904..b21df0fd9b 100644
@@ -173,9 +173,14 @@ struct mlx5_hca_attr {
 	uint32_t log_max_srq;
 	uint32_t log_max_srq_sz;
 	uint32_t rss_ind_tbl_cap;
-	uint32_t mmo_dma_en:1;
-	uint32_t mmo_compress_en:1;
-	uint32_t mmo_decompress_en:1;
+	uint32_t mmo_dma_sq_en:1;
+	uint32_t mmo_compress_sq_en:1;
+	uint32_t mmo_decompress_sq_en:1;
+	uint32_t mmo_dma_qp_en:1;
+	uint32_t mmo_compress_qp_en:1;
+	uint32_t mmo_decompress_qp_en:1;
+	uint32_t mmo_regex_qp_en:1;
+	uint32_t mmo_regex_sq_en:1;
 	uint32_t compress_min_block_size:4;
 	uint32_t log_max_mmo_dma:5;
 	uint32_t log_max_mmo_compress:5;
drivers/common/mlx5/mlx5_prm.h +14 -6
index d361bcf90e..070c538c8c 100644
@@ -1386,10 +1386,10 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 rtr2rts_qp_counters_set_id[0x1];
 	u8 rts2rts_udp_sport[0x1];
 	u8 rts2rts_lag_tx_port_affinity[0x1];
-	u8 dma_mmo[0x1];
+	u8 dma_mmo_sq[0x1];
 	u8 compress_min_block_size[0x4];
-	u8 compress[0x1];
-	u8 decompress[0x1];
+	u8 compress_mmo_sq[0x1];
+	u8 decompress_mmo_sq[0x1];
 	u8 log_max_ra_res_qp[0x6];
 	u8 end_pad[0x1];
 	u8 cc_query_allowed[0x1];
@@ -1519,7 +1519,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_lag_ports[0x4];
 	u8 reserved_at_280[0x10];
 	u8 max_wqe_sz_sq[0x10];
-	u8 reserved_at_2a0[0x10];
+	u8 reserved_at_2a0[0xe];
+	u8 regexp_mmo_sq[0x1];
+	u8 reserved_at_2b0[0x1];
 	u8 max_wqe_sz_rq[0x10];
 	u8 max_flow_counter_31_16[0x10];
 	u8 max_wqe_sz_sq_dc[0x10];
@@ -1632,7 +1634,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 num_vhca_ports[0x8];
 	u8 reserved_at_618[0x6];
 	u8 sw_owner_id[0x1];
-	u8 reserved_at_61f[0x1e1];
+	u8 reserved_at_61f[0x109];
+	u8 dma_mmo_qp[0x1];
+	u8 regexp_mmo_qp[0x1];
+	u8 compress_mmo_qp[0x1];
+	u8 decompress_mmo_qp[0x1];
+	u8 reserved_at_624[0xd4];
 };
 
 struct mlx5_ifc_qos_cap_bits {
@@ -3244,7 +3251,8 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 uid[0x10];
 	u8 reserved_at_20[0x10];
 	u8 op_mod[0x10];
-	u8 reserved_at_40[0x40];
+	u8 qpc_ext[0x1];
+	u8 reserved_at_41[0x3f];
 	u8 opt_param_mask[0x20];
 	u8 reserved_at_a0[0x20];
 	struct mlx5_ifc_qpc_bits qpc;
Signature · 1 line
2.17.1
#35 lore raw

PATCH 3/5 common/mlx5: add MMO configuration for the DevX QP

In reply to Raja Zidane

A new configuration MMO was added to QP Context.
If set, MMO WQEs are supported on this QP.
For DMA MMO, supported only when dma_mmo_qp==1.
For REGEXP MMO, supported only when regexp_mmo_qp==1. For COMPRESS MMO, supported only when compress_mmo_qp==1. For DECOMPRESS MMO, supported only when decompress_mmo_qp==1. Add support to DevX interface to set MMO bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  5 +++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       | 27 ++++++++++++++++++++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +5 -0
index fbc2123883..4678288207 100644
@@ -2028,6 +2028,11 @@ mlx5_devx_cmd_create_qp(void *ctx,
 	MLX5_SET(qpc, qpc, ts_format, attr->ts_format);
 	MLX5_SET(qpc, qpc, user_index, attr->user_index);
 	if (attr->uar_index) {
+		if(attr->mmo) {
+			void *qpc_ext_and_pas_list = MLX5_ADDR_OF(create_qp_in, in, qpc_extension_and_pas_list);
+			void* qpc_ext = MLX5_ADDR_OF(qpc_extension_and_pas_list, qpc_ext_and_pas_list, qpc_data_extension);
+			MLX5_SET(qpc_extension, qpc_ext, mmo, 1);
+		}
 		MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
 		MLX5_SET(qpc, qpc, uar_page, attr->uar_index);
 		if (attr->log_page_size > MLX5_ADAPTER_PAGE_SHIFT)
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index b21df0fd9b..e149f8b4f5 100644
@@ -403,6 +403,7 @@ struct mlx5_devx_qp_attr {
 	uint32_t wq_umem_id;
 	uint64_t wq_umem_offset;
 	uint32_t user_index:24;
+	uint32_t mmo:1;
 };
 
 struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +26 -1
index 070c538c8c..4130b618c5 100644
@@ -3243,6 +3243,28 @@ struct mlx5_ifc_create_qp_out_bits {
 	u8 reserved_at_60[0x20];
 };
 
+struct mlx5_ifc_qpc_extension_bits {
+	u8 reserved_at_0[0x2];
+	u8 mmo[0x1];
+	u8 reserved_at_3[0x5fd];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_pas_list_bits {
+	u8 pas[0][0x40];
+};
+
+#ifdef PEDANTIC
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+struct mlx5_ifc_qpc_extension_and_pas_list_bits {
+	struct mlx5_ifc_qpc_extension_bits qpc_data_extension;
+	u8 pas[0][0x40];
+};
+
+
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
@@ -3260,7 +3282,10 @@ struct mlx5_ifc_create_qp_in_bits {
 	u8 wq_umem_id[0x20];
 	u8 wq_umem_valid[0x1];
 	u8 reserved_at_861[0x1f];
-	u8 pas[0][0x40];
+	union {
+		struct mlx5_ifc_qpc_pas_list_bits qpc_pas_list;
+		struct mlx5_ifc_qpc_extension_and_pas_list_bits qpc_extension_and_pas_list;
+	};
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
Signature · 1 line
2.17.1
#36 lore raw

PATCH 4/5 compress/mlx5: refactor queue HW object

In reply to Raja Zidane

The mlx5 PMD for compress class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/compress/mlx5/mlx5_compress.c | 71 ++++++++++++++++-----------
 1 file changed, 41 insertions(+), 30 deletions(-)
drivers/compress/mlx5/mlx5_compress.c +41 -30
index 883e720ec1..d65e1e14da 100644
@@ -40,7 +40,7 @@ struct mlx5_compress_priv {
 	void *uar;
 	uint32_t pdn; /* Protection Domain number. */
 	uint8_t min_block_size;
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	/* Minimum huffman block size supported by the device. */
 	struct ibv_pd *pd;
 	struct rte_compressdev_config dev_config;
@@ -48,6 +48,13 @@ struct mlx5_compress_priv {
 	rte_spinlock_t xform_sl;
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	volatile uint64_t *uar_addr;
+	/* HCA caps*/
+	uint32_t mmo_decomp_sq:1;
+	uint32_t mmo_decomp_qp:1;
+	uint32_t mmo_comp_sq:1;
+	uint32_t mmo_comp_qp:1;
+	uint32_t mmo_dma_sq:1;
+	uint32_t mmo_dma_qp:1; 
 #ifndef RTE_ARCH_64
 	rte_spinlock_t uar32_sl;
 #endif /* RTE_ARCH_64 */
@@ -61,7 +68,7 @@ struct mlx5_compress_qp {
 	struct mlx5_mr_ctrl mr_ctrl;
 	int socket_id;
 	struct mlx5_devx_cq cq;
-	struct mlx5_devx_sq sq;
+	struct mlx5_devx_qp qp;
 	struct mlx5_pmd_mr opaque_mr;
 	struct rte_comp_op **ops;
 	struct mlx5_compress_priv *priv;
@@ -134,8 +141,8 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 {
 	struct mlx5_compress_qp *qp = dev->data->queue_pairs[qp_id];
 
-	if (qp->sq.sq != NULL)
-		mlx5_devx_sq_destroy(&qp->sq);
+	if (qp->qp.qp != NULL)
+		mlx5_devx_qp_destroy(&qp->qp);
 	if (qp->cq.cq != NULL)
 		mlx5_devx_cq_destroy(&qp->cq);
 	if (qp->opaque_mr.obj != NULL) {
@@ -152,12 +159,12 @@ mlx5_compress_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 }
 
 static void
-mlx5_compress_init_sq(struct mlx5_compress_qp *qp)
+mlx5_compress_init_qp(struct mlx5_compress_qp *qp)
 {
 	volatile struct mlx5_gga_wqe *restrict wqe =
-				    (volatile struct mlx5_gga_wqe *)qp->sq.wqes;
+				    (volatile struct mlx5_gga_wqe *)qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
-	const uint32_t sq_ds = rte_cpu_to_be_32((qp->sq.sq->id << 8) | 4u);
+	const uint32_t sq_ds = rte_cpu_to_be_32((qp->qp.qp->id << 8) | 4u);
 	const uint32_t flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					MLX5_COMP_MODE_OFFSET);
 	const uint32_t opaq_lkey = rte_cpu_to_be_32(qp->opaque_mr.lkey);
@@ -182,15 +189,10 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 	struct mlx5_devx_cq_attr cq_attr = {
 		.uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar),
 	};
-	struct mlx5_devx_create_sq_attr sq_attr = {
+	struct mlx5_devx_qp_attr qp_attr = {
+		.pd = priv->pdn,
+		.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar),
 		.user_index = qp_id,
-		.wq_attr = (struct mlx5_devx_wq_attr){
-			.pd = priv->pdn,
-			.uar_page = mlx5_os_get_devx_uar_page_id(priv->uar),
-		},
-	};
-	struct mlx5_devx_modify_sq_attr modify_attr = {
-		.state = MLX5_SQC_STATE_RDY,
 	};
 	uint32_t log_ops_n = rte_log2_u32(max_inflight_ops);
 	uint32_t alloc_size = sizeof(*qp);
@@ -242,24 +244,26 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		DRV_LOG(ERR, "Failed to create CQ.");
 		goto err;
 	}
-	sq_attr.cqn = qp->cq.cq->id;
-	sq_attr.ts_format = mlx5_ts_format_conv(priv->sq_ts_format);
-	ret = mlx5_devx_sq_create(priv->ctx, &qp->sq, log_ops_n, &sq_attr,
+	qp_attr.cqn = qp->cq.cq->id;
+	qp_attr.ts_format = mlx5_ts_format_conv(priv->qp_ts_format);
+	qp_attr.rq_size = 0;
+	qp_attr.sq_size = RTE_BIT32(log_ops_n);
+	qp_attr.mmo = priv->mmo_decomp_qp && priv->mmo_comp_qp && priv->mmo_dma_qp;
+	ret = mlx5_devx_qp_create(priv->ctx, &qp->qp, log_ops_n, &qp_attr,
 				  socket_id);
 	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to create SQ.");
+		DRV_LOG(ERR, "Failed to create QP.");
 		goto err;
 	}
-	mlx5_compress_init_sq(qp);
-	ret = mlx5_devx_cmd_modify_sq(qp->sq.sq, &modify_attr);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Can't change SQ state to ready.");
+	mlx5_compress_init_qp(qp);
+	ret = mlx5_devx_qp2rts(&qp->qp, 0);
+	if(ret) {
 		goto err;
 	}
 	/* Save pointer of global generation number to check memory event. */
 	qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
 	DRV_LOG(INFO, "QP %u: SQN=0x%X CQN=0x%X entries num = %u",
-		(uint32_t)qp_id, qp->sq.sq->id, qp->cq.cq->id, qp->entries_n);
+		(uint32_t)qp_id, qp->qp.qp->id, qp->cq.cq->id, qp->entries_n);
 	return 0;
 err:
 	mlx5_compress_qp_release(dev, qp_id);
@@ -508,7 +512,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 {
 	struct mlx5_compress_qp *qp = queue_pair;
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-							      qp->sq.wqes, *wqe;
+							      qp->qp.wqes, *wqe;
 	struct mlx5_compress_xform *xform;
 	struct rte_comp_op *op;
 	uint16_t mask = qp->entries_n - 1;
@@ -563,7 +567,7 @@ mlx5_compress_enqueue_burst(void *queue_pair, struct rte_comp_op **ops,
 	} while (--remain);
 	qp->stats.enqueued_count += nb_ops;
 	rte_io_wmb();
-	qp->sq.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
+	qp->qp.db_rec[MLX5_SND_DBR] = rte_cpu_to_be_32(qp->pi);
 	rte_wmb();
 	mlx5_compress_uar_write(*(volatile uint64_t *)wqe, qp->priv);
 	rte_wmb();
@@ -598,7 +602,7 @@ mlx5_compress_cqe_err_handle(struct mlx5_compress_qp *qp,
 	volatile struct mlx5_err_cqe *cqe = (volatile struct mlx5_err_cqe *)
 							      &qp->cq.cqes[idx];
 	volatile struct mlx5_gga_wqe *wqes = (volatile struct mlx5_gga_wqe *)
-								    qp->sq.wqes;
+								    qp->qp.wqes;
 	volatile struct mlx5_gga_compress_opaque *opaq = qp->opaque_mr.addr;
 
 	op->status = RTE_COMP_OP_STATUS_ERROR;
@@ -813,8 +817,9 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 		return -rte_errno;
 	}
 	if (mlx5_devx_cmd_query_hca_attr(ctx, &att) != 0 ||
-	    att.mmo_compress_en == 0 || att.mmo_decompress_en == 0 ||
-	    att.mmo_dma_en == 0) {
+	    ((att.mmo_compress_sq_en == 0 || att.mmo_decompress_sq_en == 0 ||
+	    	att.mmo_dma_sq_en == 0) && (att.mmo_compress_qp_en == 0 || 
+				att.mmo_decompress_qp_en == 0 || att.mmo_dma_qp_en == 0))) {
 		DRV_LOG(ERR, "Not enough capabilities to support compress "
 			"operations, maybe old FW/OFED version?");
 		claim_zero(mlx5_glue->close_device(ctx));
@@ -835,10 +840,16 @@ mlx5_compress_dev_probe(struct rte_device *dev)
 	cdev->enqueue_burst = mlx5_compress_enqueue_burst;
 	cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 	priv = cdev->data->dev_private;
+	priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
+	priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
+	priv->mmo_comp_sq = att.mmo_compress_sq_en;
+	priv->mmo_comp_qp = att.mmo_compress_qp_en;
+	priv->mmo_dma_sq = att.mmo_dma_sq_en;
+	priv->mmo_dma_qp = att.mmo_dma_qp_en;
 	priv->ctx = ctx;
 	priv->cdev = cdev;
 	priv->min_block_size = att.compress_min_block_size;
-	priv->sq_ts_format = att.sq_ts_format;
+	priv->qp_ts_format = att.qp_ts_format;
 	if (mlx5_compress_hw_global_prepare(priv) != 0) {
 		rte_compressdev_pmd_destroy(priv->cdev);
 		claim_zero(mlx5_glue->close_device(priv->ctx));
Signature · 1 line
2.17.1
#37 lore raw

PATCH 5/5 regex/mlx5: refactor HW queue objects

In reply to Raja Zidane

The mlx5 PMD for regex class uses an MMO WQE operated by the GGA engine in BF devices.
Currently, all the MMO WQEs are managed by the SQ object. Starting from BF3, the queue of the MMO WQEs should be connected to the GGA engine using a new configuration, MMO, that will be supported only in the QP object.
The FW introduced new capabilities to define whether the MMO configuration should be configured for the GGA queue. Replace all the GGA queue objects to QP, set MMO configuration according to the new FW capabilities.

---
 drivers/regex/mlx5/mlx5_regex.c          |   6 +-
 drivers/regex/mlx5/mlx5_regex.h          |  16 ++-
 drivers/regex/mlx5/mlx5_regex_control.c  |  64 +++++----
 drivers/regex/mlx5/mlx5_regex_fastpath.c | 159 +++++++++++------------
 4 files changed, 123 insertions(+), 122 deletions(-)
drivers/regex/mlx5/mlx5_regex.c +4 -2
index f17b6df47f..54d9fae03c 100644
@@ -146,7 +146,7 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
 		goto dev_error;
-	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
+	} else if (((!attr.regex) && (!attr.mmo_regex_sq_en) && (!attr.mmo_regex_qp_en)) || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
@@ -164,7 +164,9 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
 		rte_errno = ENOMEM;
 		goto dev_error;
 	}
-	priv->sq_ts_format = attr.sq_ts_format;
+	priv->mmo_regex_qp_cap = attr.mmo_regex_qp_en;
+	priv->mmo_regex_sq_cap = attr.mmo_regex_sq_en;
+	priv->qp_ts_format = attr.qp_ts_format;
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */
 	ret = mlx5_devx_regex_register_read(priv->ctx, 0,
drivers/regex/mlx5/mlx5_regex.h +9 -7
index 514f3408f9..2242d250a3 100644
@@ -17,12 +17,12 @@
 #include "mlx5_rxp.h"
 #include "mlx5_regex_utils.h"
 
-struct mlx5_regex_sq {
+struct mlx5_regex_hw_qp {
 	uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
-	struct mlx5_devx_sq sq_obj; /* The SQ DevX object. */
+	struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
 	size_t pi, db_pi;
 	size_t ci;
-	uint32_t sqn;
+	uint32_t qpn;
 };
 
 struct mlx5_regex_cq {
@@ -34,10 +34,10 @@ struct mlx5_regex_cq {
 struct mlx5_regex_qp {
 	uint32_t flags; /* QP user flags. */
 	uint32_t nb_desc; /* Total number of desc for this qp. */
-	struct mlx5_regex_sq *sqs; /* Pointer to sq array. */
-	uint16_t nb_obj; /* Number of sq objects. */
+	struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
+	uint16_t nb_obj; /* Number of qp objects. */
 	struct mlx5_regex_cq cq; /* CQ struct. */
-	uint32_t free_sqs;
+	uint32_t free_qps;
 	struct mlx5_regex_job *jobs;
 	struct ibv_mr *metadata;
 	struct ibv_mr *outputs;
@@ -73,8 +73,10 @@ struct mlx5_regex_priv {
 	/**< Called by memory event callback. */
 	struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */
 	uint8_t is_bf2; /* The device is BF2 device. */
-	uint8_t sq_ts_format; /* Whether SQ supports timestamp formats. */
+	uint8_t qp_ts_format; /* Whether SQ supports timestamp formats. */
 	uint8_t has_umr; /* The device supports UMR. */
+	uint32_t mmo_regex_qp_cap:1;
+	uint32_t mmo_regex_sq_cap:1;
 };
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
drivers/regex/mlx5/mlx5_regex_control.c +31 -33

116 lines not on this page · raw message

drivers/regex/mlx5/mlx5_regex_fastpath.c +79 -80

374 lines not on this page · raw message

Signature · 1 line
2.17.1