mlx5: replaced hardware queue object
Subsystems (3)
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 (3):
common/mlx5: add common qp_create
compress/mlx5: refactor queue creation in mlx5 add support to compress
and regex drivers in BlueField3
regex/mlx5: refactor queue creation in mlx5 add support to compress
and regex drivers in Bluefield3
drivers/common/mlx5/mlx5_common_devx.c | 139 ++++++++++++++++++++++++ drivers/common/mlx5/mlx5_common_devx.h | 23 ++++ drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++- drivers/common/mlx5/mlx5_devx_cmds.h | 10 +- drivers/common/mlx5/mlx5_prm.h | 42 ++++++- drivers/common/mlx5/version.map | 3 + drivers/compress/mlx5/mlx5_compress.c | 62 ++++++----- drivers/crypto/mlx5/mlx5_crypto.c | 98 ++++------------- drivers/crypto/mlx5/mlx5_crypto.h | 5 +- drivers/regex/mlx5/mlx5_regex.h | 6 +- drivers/regex/mlx5/mlx5_regex_control.c | 60 +++++----- drivers/vdpa/mlx5/mlx5_vdpa.h | 5 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 58 +++------- 13 files changed, 326 insertions(+), 199 deletions(-)
Signature · 1 line
2.27.0
RFC 1/3 common/mlx5: add common qp_create
--- drivers/common/mlx5/mlx5_common_devx.c | 111 +++++++++++++++++++++++++ drivers/common/mlx5/mlx5_common_devx.h | 20 +++++ drivers/common/mlx5/version.map | 2 + drivers/crypto/mlx5/mlx5_crypto.c | 80 +++++++----------- drivers/crypto/mlx5/mlx5_crypto.h | 5 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 5 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 58 ++++--------- 7 files changed, 181 insertions(+), 100 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +111 -0
@@ -271,6 +271,117 @@ 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 +* sq_size +* log_page_size +* rq_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. *
drivers/common/mlx5/mlx5_common_devx.h +20 -0
@@ -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);
drivers/common/mlx5/version.map +2 -0
@@ -71,6 +71,8 @@ INTERNAL { mlx5_devx_rq_destroy; mlx5_devx_sq_create; mlx5_devx_sq_destroy; + mlx5_devx_qp_create; + mlx5_devx_qp_destroy; mlx5_free;
drivers/crypto/mlx5/mlx5_crypto.c +29 -51
160 lines not on this page · raw message
drivers/crypto/mlx5/mlx5_crypto.h +1 -4
@@ -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
@@ -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 -41
122 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC 2/3 compress/mlx5: refactor queue creation in mlx5 add support to compress and regex drivers in BlueField3
In reply to Raja Zidane--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++- drivers/common/mlx5/mlx5_devx_cmds.h | 10 ++- drivers/common/mlx5/mlx5_prm.h | 42 +++++++++++-- drivers/compress/mlx5/mlx5_compress.c | 91 ++++++++++++++++++--------- 4 files changed, 116 insertions(+), 41 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -3
@@ -858,9 +858,12 @@ 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_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);
@@ -2022,6 +2025,11 @@ mlx5_devx_cmd_create_qp(void *ctx,MLX5_SET (qpc, qpc, pd, attr->pd);MLX5_SET (qpc, qpc, ts_format, attr->ts_format);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 +7 -3
@@ -173,9 +173,12 @@ 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 compress_min_block_size:4; uint32_t log_max_mmo_dma:5; uint32_t log_max_mmo_compress:5;
@@ -397,6 +400,7 @@ struct mlx5_devx_qp_attr {uint64_t dbr_address;uint32_t wq_umem_id;uint64_t wq_umem_offset; +uint32_t mmo; };struct mlx5_devx_virtio_q_couners_attr {
drivers/common/mlx5/mlx5_prm.h +36 -6
73 lines not on this page · raw message
drivers/compress/mlx5/mlx5_compress.c +62 -29
175 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC 3/3 regex/mlx5: refactor queue creation in mlx5 add support to compress and regex drivers in Bluefield3
In reply to Raja Zidane--- drivers/common/mlx5/mlx5_common_devx.c | 28 ++++++++++++ drivers/common/mlx5/mlx5_common_devx.h | 3 ++ drivers/common/mlx5/version.map | 1 + drivers/compress/mlx5/mlx5_compress.c | 31 +------------ drivers/crypto/mlx5/mlx5_crypto.c | 30 +------------ drivers/regex/mlx5/mlx5_regex.h | 6 +-- drivers/regex/mlx5/mlx5_regex_control.c | 60 ++++++++++++------------- 7 files changed, 65 insertions(+), 94 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +28 -0
@@ -496,3 +496,31 @@ mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj, uint32_t wqe_size,return -rte_errno; } +int +mlx5_devx_qp2rts (struct mlx5_devx_qp *qp) +{ +/* +* In Order to configure self loopback, when calling these functions the +* remote QP id that is used is the id of the same QP. +*/ +if (mlx5_devx_cmd_modify_qp_state (qp->qp,MLX5_CMD_OP_RST2INIT_QP , + qp->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 , + qp->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 , + qp->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 +3 -0
@@ -87,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); +#endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -73,6 +73,7 @@ INTERNAL { mlx5_devx_sq_destroy; mlx5_devx_qp_create; mlx5_devx_qp_destroy; + mlx5_devx_qp2rts; mlx5_free;
drivers/compress/mlx5/mlx5_compress.c +1 -30
@@ -174,35 +174,6 @@ mlx5_compress_init_qp(struct mlx5_compress_qp *qp) } } -static int -mlx5_compress_qp2rts (struct mlx5_compress_qp *qp) -{ -/* -* In Order to configure self loopback, when calling these functions the -* remote QP id that is used is the id of the same QP. -*/ -if (mlx5_devx_cmd_modify_qp_state (qp->qp.qp,MLX5_CMD_OP_RST2INIT_QP , - qp->qp.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.qp,MLX5_CMD_OP_INIT2RTR_QP , - qp->qp.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.qp,MLX5_CMD_OP_RTR2RTS_QP , - qp->qp.qp->id)) { -DRV_LOG (ERR ,"Failed to modify QP to RTS state(%u)." , - rte_errno); -return -1 ; - } -return 0 ; -} - -static int mlx5_compress_qp_setup (struct rte_compressdev *dev,uint16_t qp_id,uint32_t max_inflight_ops,int socket_id)
@@ -277,7 +248,7 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,DRV_LOG (ERR ,"Failed to create QP." ); goto err; } - ret =mlx5_compress_qp2rts (qp); + ret =mlx5_devx_qp2rts (&qp->qp);if (ret) { goto err; }
drivers/crypto/mlx5/mlx5_crypto.c +1 -29
@@ -270,34 +270,6 @@ mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)return 0 ; } -static int -mlx5_crypto_qp2rts (struct mlx5_crypto_qp *qp) -{ -/* -* In Order to configure self loopback, when calling these functions the -* remote QP id that is used is the id of the same QP. -*/ -if (mlx5_devx_cmd_modify_qp_state (qp->qp_obj.qp,MLX5_CMD_OP_RST2INIT_QP , - qp->qp_obj.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_obj.qp,MLX5_CMD_OP_INIT2RTR_QP , - qp->qp_obj.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_obj.qp,MLX5_CMD_OP_RTR2RTS_QP , - qp->qp_obj.qp->id)) { -DRV_LOG (ERR ,"Failed to modify QP to RTS state(%u)." , - rte_errno); -return -1 ; - } -return 0 ; -} - static __rte_noinline uint32_tmlx5_crypto_get_block_size (struct rte_crypto_op *op) {
@@ -692,7 +664,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, goto error; } qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen; -if (mlx5_crypto_qp2rts (qp)) +if (mlx5_devx_qp2rts (&qp->qp_obj)) goto error; qp->mkey = (struct mlx5_devx_obj **)RTE_ALIGN ((uintptr_t )(qp +1 ),RTE_CACHE_LINE_SIZE );
drivers/regex/mlx5/mlx5_regex.h +3 -3
@@ -17,9 +17,9 @@#include "mlx5_rxp.h" #include "mlx5_regex_utils.h" -struct mlx5_regex_sq { +struct mlx5_regex_inner_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;
@@ -34,7 +34,7 @@ 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. */ +struct mlx5_regex_inner_qp *qps;/* Pointer to qp array. */ uint16_t nb_obj;/* Number of sq objects. */ struct mlx5_regex_cq cq;/* CQ struct. */ uint32_t free_sqs;
drivers/regex/mlx5/mlx5_regex_control.c +28 -32
113 lines not on this page · raw message
Signature · 1 line
2.27.0