fixes to queue size config
Subsystems (3)
cover fixes to queue size config
fixes series.
for vdpa dependent on:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Raja Zidane (4):
common/mlx5: fix overflows in DevX queues size calculations crypto/mlx5: fix driver destroy before the configuration crypto/mlx5: fix the queue size configuration common/mlx5: fix RQ size configuration in QP create
drivers/common/mlx5/mlx5_common_devx.c | 19 ++-- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 9 +- drivers/crypto/mlx5/mlx5_crypto.c | 123 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 8 +- drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 +- drivers/regex/mlx5/mlx5_regex_control.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 9 +- 10 files changed, 144 insertions(+), 59 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/4 common/mlx5: fix overflows in DevX queues size calculations
The HW QP/SQ/RQ/CQ queue sizes may be bigger than 64KB. The width of the variable handled the queue size is 16 bits which cannot contain the maximum queue size. Replace the size type to be uint32_t.
--- drivers/common/mlx5/mlx5_common_devx.c | 16 ++++++++-------- drivers/common/mlx5/mlx5_common_devx.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +8 -8
@@ -86,7 +86,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,size_t alignment =MLX5_CQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec;uint32_t eqn; -uint16_t cq_size =1 << log_desc_n; +uint32_t num_of_cqes =RTE_BIT32 (log_desc_n);int ret;if (page_size == (size_t )-1 || alignment == (size_t )-1 ) {
@@ -102,7 +102,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,return -rte_errno; }/* Allocate memory buffer for CQEs and doorbell record. */ - umem_size =sizeof (struct mlx5_cqe ) * cq_size; + umem_size =sizeof (struct mlx5_cqe ) * num_of_cqes; 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,
@@ -142,7 +142,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n, cq_obj->cq = cq; cq_obj->db_rec =RTE_PTR_ADD (cq_obj->umem_buf, umem_dbrec);/* Mark all CQEs initially as invalid. */ -mlx5_cq_init (cq_obj, cq_size); +mlx5_cq_init (cq_obj, num_of_cqes);return 0 ; error: ret = rte_errno;
@@ -211,7 +211,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint16_t sq_size =1 << log_wqbb_n; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -220,7 +220,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * sq_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
@@ -316,7 +316,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -324,7 +324,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,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; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -333,7 +333,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * qp_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -76,7 +76,7 @@ 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, +uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
Signature · 1 line
2.17.1
PATCH 2/4 crypto/mlx5: fix driver destroy before the configuration
In reply to Raja ZidaneWhen calling device close, unset dek is called which destroys a hash list. In case of error during dev probe, close is called when dek hlist is not initialized.
Ensure non null list destroy.
--- drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/mlx5/mlx5_crypto_dek.c +4 -2
@@ -156,6 +156,8 @@ mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv)void mlx5_crypto_dek_unset (struct mlx5_crypto_priv *priv) { -mlx5_hlist_destroy (priv->dek_hlist); - priv->dek_hlist =NULL ; +if (priv->dek_hlist) { +mlx5_hlist_destroy (priv->dek_hlist); + priv->dek_hlist =NULL ; + } }
Signature · 1 line
2.17.1
PATCH 3/4 crypto/mlx5: fix the queue size configuration
In reply to Raja ZidaneThe DevX interface for QP creation expects the number of WQEBBs. Wrongly, the number of descriptors was provided to the QP creation. In addition, the QP size must be a power of 2 what was not guaranteed. Provide the number of WQEBBs to the QP creation API.
Round up the SQ size to a power of 2.
Rename (sq/rq)_size to num_of_(send/receive)_wqes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 4 +- drivers/crypto/mlx5/mlx5_crypto.c | 120 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 8 +- drivers/regex/mlx5/mlx5_regex_control.c | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 4 +- 7 files changed, 120 insertions(+), 39 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +8 -6
@@ -832,6 +832,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_HCA_CAP_OPMOD_GET_CUR);if (!hcattr)return rc; + attr->max_wqe_sz_sq =MLX5_GET (cmd_hca_cap, hcattr, max_wqe_sz_sq); attr->flow_counter_bulk_alloc_bitmap =MLX5_GET (cmd_hca_cap, hcattr, flow_counter_bulk_alloc); attr->flow_counters_dump = MLX5_GET(cmd_hca_cap, hcattr,
@@ -2099,21 +2100,22 @@ mlx5_devx_cmd_create_qp(void *ctx,if (attr->log_page_size >MLX5_ADAPTER_PAGE_SHIFT )MLX5_SET (qpc, qpc, log_page_size, attr->log_page_size -MLX5_ADAPTER_PAGE_SHIFT ); -if (attr->sq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->sq_size)); +if (attr->num_of_send_wqbbs) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->num_of_send_wqbbs));MLX5_SET (qpc, qpc, cqn_snd, attr->cqn);MLX5_SET (qpc, qpc, log_sq_size, -rte_log2_u32 (attr->sq_size)); +rte_log2_u32 (attr->num_of_send_wqbbs)); }else {MLX5_SET (qpc, qpc, no_sq,1 ); } -if (attr->rq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->rq_size)); +if (attr->num_of_receive_wqes) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 ( + attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, cqn_rcv, attr->cqn);MLX5_SET (qpc, qpc, log_rq_stride, attr->log_rq_stride -MLX5_LOG_RQ_STRIDE_SHIFT );MLX5_SET (qpc, qpc, log_rq_size, -rte_log2_u32 (attr->rq_size)); +rte_log2_u32 (attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, rq_type,MLX5_NON_ZERO_RQ ); }else {MLX5_SET (qpc, qpc, rq_type,MLX5_ZERO_LEN_RQ );
drivers/common/mlx5/mlx5_devx_cmds.h +3 -2
@@ -247,6 +247,7 @@ struct mlx5_hca_attr { uint32_t log_max_mmo_decompress:5; uint32_t umr_modify_entity_size_disabled:1; uint32_t umr_indirect_mkey_disabled:1; +uint16_t max_wqe_sz_sq; };/* LAG Context. */
@@ -462,9 +463,9 @@ struct mlx5_devx_qp_attr { uint32_t uar_index:24; uint32_t cqn:24; uint32_t log_page_size:5; - uint32_t rq_size:17; /* Must be power of 2. */ + uint32_t num_of_receive_wqes:17; /* Must be power of 2. */ uint32_t log_rq_stride:3; - uint32_t sq_size:17; /* Must be power of 2. */ + uint32_t num_of_send_wqbbs:17; /* Must be power of 2. */ uint32_t ts_format:2; uint32_t dbr_umem_valid:1;uint32_t dbr_umem_id;
drivers/compress/mlx5/mlx5_compress.c +2 -2
@@ -243,8 +243,8 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.cqn = qp->cq.cq->id; qp_attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - qp_attr.rq_size =0 ; - qp_attr.sq_size =RTE_BIT32 (log_ops_n); + qp_attr.num_of_receive_wqes =0 ; + qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr,
drivers/crypto/mlx5/mlx5_crypto.c +96 -24
173 lines not on this page · raw message
drivers/crypto/mlx5/mlx5_crypto.h +7 -1
@@ -16,6 +16,13 @@#define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)#define MLX5_CRYPTO_KEY_LENGTH 80 +#define MLX5_CRYPTO_UMR_WQE_STATIC_SIZE (sizeof(struct mlx5_wqe_cseg) +\ + sizeof(struct mlx5_wqe_umr_cseg) +\ + sizeof(struct mlx5_wqe_mkey_cseg) +\ + sizeof(struct mlx5_wqe_umr_bsf_seg)) +#define MLX5_CRYPTO_KLM_SEGS_NUM (umr_wqe_sz) ((umr_wqe_sz -\ + MLX5_CRYPTO_UMR_WQE_STATIC_SIZE) /\ + MLX5_WSEG_SIZE)struct mlx5_crypto_priv {TAILQ_ENTRY (mlx5_crypto_priv) next;
@@ -23,7 +30,6 @@ struct mlx5_crypto_priv {struct rte_cryptodev *crypto_dev;void *uar;/* User Access Region. */ volatile uint64_t *uar_addr; -uint32_t max_segs_num;/* Maximum supported data segs. */ struct mlx5_hlist *dek_hlist;/* Dek hash list. */ struct rte_cryptodev_config dev_config;struct mlx5_devx_obj *login_obj;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -150,8 +150,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, qp_obj->qpn = q_ind; qp_obj->ci =0 ; qp_obj->pi =0 ; - attr.rq_size =0 ; - attr.sq_size =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, + attr.num_of_receive_wqes =0 ; + attr.num_of_send_wqbbs =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret = mlx5_devx_qp_create(priv->cdev->ctx, &qp_obj->qp_obj,
drivers/vdpa/mlx5/mlx5_vdpa_event.c +2 -2
@@ -608,9 +608,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, } attr.uar_index = priv->uar->page_id; attr.cqn = eqp->cq.cq_obj.cq->id; - attr.rq_size =RTE_BIT32 (log_desc_n); + attr.num_of_receive_wqes =RTE_BIT32 (log_desc_n); attr.log_rq_stride =rte_log2_u32 (MLX5_WSEG_SIZE ); - attr.sq_size =0 ;/* No need SQ. */ + attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); ret = mlx5_devx_qp_create(priv->cdev->ctx, &(eqp->sw_qp), log_desc_n,
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 3/4] crypto/mlx5: fix the queue size configuration
Quoted 13 lines
Subject: [dpdk-dev] [PATCH 3/4]
crypto/mlx5: fix the queue size configurationExternal email: Use caution opening links or attachments
The DevX interface for QP creation expects the number of WQEBBs. Wrongly, the number of descriptors was provided to the QP creation. In addition, the QP size must be a power of 2 what was not guaranteed. Provide the number of WQEBBs to the QP creation API.
Round up the SQ size to a power of 2.
Rename (sq/rq)_size to num_of_(send/receive)_wqes.
Quoted 5 lines
Fixes 6152534e211e ("crypto/mlx5: support queue pairs operations")Signed-off-by Raja Zidane <[email protected]>Acked-by Matan Azrad <[email protected]>
PATCH 4/4 common/mlx5: fix RQ size configuration in QP create
In reply to Raja ZidaneThe number of WQEBBs was provided to QP create, and QP size was calculated by multiplying the number of WQEBBs by 64, which is the send WQE size. When creating RQ in the QP (i.e., vdpa driver), the queue size was bigger because the receive WQE size is 16.
Provide queue size to QP create instead of the number of WQEBBs.
--- drivers/common/mlx5/mlx5_common_devx.c | 9 ++++----- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/compress/mlx5/mlx5_compress.c | 5 +++-- drivers/crypto/mlx5/mlx5_crypto.c | 5 +++-- drivers/regex/mlx5/mlx5_regex_control.c | 4 ++-- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +++-- 6 files changed, 16 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +4 -5
@@ -305,8 +305,8 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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] queue_size +* Size of queue to create. * @param[in] attr * Pointer to QP attributes structure. * @param[in] socket
@@ -316,7 +316,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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,uint32_t log_wqbb_n, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -324,7 +324,6 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -333,7 +332,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * num_of_wqbbs; + umem_size = queue_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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -76,7 +76,7 @@ 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, -uint32_t log_wqbb_n, +uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
drivers/compress/mlx5/mlx5_compress.c +3 -2
@@ -247,8 +247,9 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr, - socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp, + qp_attr.num_of_send_wqbbs * +MLX5_WQE_SIZE , &qp_attr, socket_id);if (ret !=0 ) {DRV_LOG (ERR ,"Failed to create QP." ); goto err;
drivers/crypto/mlx5/mlx5_crypto.c +3 -2
@@ -641,8 +641,9 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, attr.num_of_send_wqbbs =RTE_BIT32 (log_wqbb_n); attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, log_wqbb_n, - &attr, socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , + &attr, socket_id);if (ret) {DRV_LOG (ERR ,"Failed to create QP." ); goto error;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -155,8 +155,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp_obj->qp_obj, -MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc), - &attr,SOCKET_ID_ANY ); + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , &attr, +SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Can't create QP object." ); rte_errno =ENOMEM ;
drivers/vdpa/mlx5/mlx5_vdpa_event.c +3 -2
@@ -613,8 +613,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), log_desc_n, - &attr,SOCKET_ID_ANY ); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), + attr.num_of_receive_wqes * +MLX5_WSEG_SIZE , &attr,SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Failed to create SW QP(%u)." , rte_errno); goto error;
Signature · 1 line
2.17.1
04/11/2021 13:49, Raja Zidane:
Quoted 9 lines
fixes series.
for vdpa dependent on:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/Raja Zidane (4):
common/mlx5: fix overflows in DevX queues size calculationscrypto/mlx5: fix driver destroy before the configurationcrypto/mlx5: fix the queue size configuration common/mlx5: fix RQ size configuration in QP create
Please rebase on latest main branch.
v2 cover fixes to queue size config
In reply to Raja Zidanefixes series.
for vdpa dependent on:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
V2: rebase.
Raja Zidane (4):
common/mlx5: fix overflows in DevX queues size calculations crypto/mlx5: fix driver destroy before the configuration crypto/mlx5: fix the queue size configuration common/mlx5: fix RQ size configuration in QP create
drivers/common/mlx5/mlx5_common_devx.c | 19 ++-- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 9 +- drivers/crypto/mlx5/mlx5_crypto.c | 123 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 7 ++ drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 +- drivers/regex/mlx5/mlx5_regex_control.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 9 +- 10 files changed, 144 insertions(+), 58 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/4 common/mlx5: fix overflows in DevX queues size calculations
The HW QP/SQ/RQ/CQ queue sizes may be bigger than 64KB. The width of the variable handled the queue size is 16 bits which cannot contain the maximum queue size. Replace the size type to be uint32_t.
--- drivers/common/mlx5/mlx5_common_devx.c | 16 ++++++++-------- drivers/common/mlx5/mlx5_common_devx.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +8 -8
@@ -86,7 +86,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,size_t alignment =MLX5_CQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec;uint32_t eqn; -uint16_t cq_size =1 << log_desc_n; +uint32_t num_of_cqes =RTE_BIT32 (log_desc_n);int ret;if (page_size == (size_t )-1 || alignment == (size_t )-1 ) {
@@ -102,7 +102,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,return -rte_errno; }/* Allocate memory buffer for CQEs and doorbell record. */ - umem_size =sizeof (struct mlx5_cqe ) * cq_size; + umem_size =sizeof (struct mlx5_cqe ) * num_of_cqes; 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,
@@ -142,7 +142,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n, cq_obj->cq = cq; cq_obj->db_rec =RTE_PTR_ADD (cq_obj->umem_buf, umem_dbrec);/* Mark all CQEs initially as invalid. */ -mlx5_cq_init (cq_obj, cq_size); +mlx5_cq_init (cq_obj, num_of_cqes);return 0 ; error: ret = rte_errno;
@@ -211,7 +211,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint16_t sq_size =1 << log_wqbb_n; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -220,7 +220,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * sq_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
@@ -349,7 +349,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -357,7 +357,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,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; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -366,7 +366,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * qp_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -89,7 +89,7 @@ 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, +uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
Signature · 1 line
2.17.1
PATCH v2 2/4 crypto/mlx5: fix driver destroy before the configuration
In reply to Raja ZidaneWhen calling device close, unset dek is called which destroys a hash list. In case of error during dev probe, close is called when dek hlist is not initialized.
Ensure non null list destroy.
--- drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/mlx5/mlx5_crypto_dek.c +4 -2
@@ -156,6 +156,8 @@ mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv)void mlx5_crypto_dek_unset (struct mlx5_crypto_priv *priv) { -mlx5_hlist_destroy (priv->dek_hlist); - priv->dek_hlist =NULL ; +if (priv->dek_hlist) { +mlx5_hlist_destroy (priv->dek_hlist); + priv->dek_hlist =NULL ; + } }
Signature · 1 line
2.17.1
PATCH v2 3/4 crypto/mlx5: fix the queue size configuration
In reply to Raja ZidaneThe DevX interface for QP creation expects the number of WQEBBs. Wrongly, the number of descriptors was provided to the QP creation. In addition, the QP size must be a power of 2 what was not guaranteed. Provide the number of WQEBBs to the QP creation API.
Round up the SQ size to a power of 2.
Rename (sq/rq)_size to num_of_(send/receive)_wqes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 4 +- drivers/crypto/mlx5/mlx5_crypto.c | 120 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 7 ++ drivers/regex/mlx5/mlx5_regex_control.c | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 4 +- 7 files changed, 120 insertions(+), 38 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +8 -6
@@ -832,6 +832,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_HCA_CAP_OPMOD_GET_CUR);if (!hcattr)return rc; + attr->max_wqe_sz_sq =MLX5_GET (cmd_hca_cap, hcattr, max_wqe_sz_sq); attr->flow_counter_bulk_alloc_bitmap =MLX5_GET (cmd_hca_cap, hcattr, flow_counter_bulk_alloc); attr->flow_counters_dump = MLX5_GET(cmd_hca_cap, hcattr,
@@ -2153,21 +2154,22 @@ mlx5_devx_cmd_create_qp(void *ctx,if (attr->log_page_size >MLX5_ADAPTER_PAGE_SHIFT )MLX5_SET (qpc, qpc, log_page_size, attr->log_page_size -MLX5_ADAPTER_PAGE_SHIFT ); -if (attr->sq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->sq_size)); +if (attr->num_of_send_wqbbs) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->num_of_send_wqbbs));MLX5_SET (qpc, qpc, cqn_snd, attr->cqn);MLX5_SET (qpc, qpc, log_sq_size, -rte_log2_u32 (attr->sq_size)); +rte_log2_u32 (attr->num_of_send_wqbbs)); }else {MLX5_SET (qpc, qpc, no_sq,1 ); } -if (attr->rq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->rq_size)); +if (attr->num_of_receive_wqes) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 ( + attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, cqn_rcv, attr->cqn);MLX5_SET (qpc, qpc, log_rq_stride, attr->log_rq_stride -MLX5_LOG_RQ_STRIDE_SHIFT );MLX5_SET (qpc, qpc, log_rq_size, -rte_log2_u32 (attr->rq_size)); +rte_log2_u32 (attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, rq_type,MLX5_NON_ZERO_RQ ); }else {MLX5_SET (qpc, qpc, rq_type,MLX5_ZERO_LEN_RQ );
drivers/common/mlx5/mlx5_devx_cmds.h +3 -2
@@ -251,6 +251,7 @@ struct mlx5_hca_attr { uint32_t log_max_mmo_decompress:5; uint32_t umr_modify_entity_size_disabled:1; uint32_t umr_indirect_mkey_disabled:1; +uint16_t max_wqe_sz_sq; };/* LAG Context. */
@@ -477,9 +478,9 @@ struct mlx5_devx_qp_attr { uint32_t uar_index:24; uint32_t cqn:24; uint32_t log_page_size:5; - uint32_t rq_size:17; /* Must be power of 2. */ + uint32_t num_of_receive_wqes:17; /* Must be power of 2. */ uint32_t log_rq_stride:3; - uint32_t sq_size:17; /* Must be power of 2. */ + uint32_t num_of_send_wqbbs:17; /* Must be power of 2. */ uint32_t ts_format:2; uint32_t dbr_umem_valid:1;uint32_t dbr_umem_id;
drivers/compress/mlx5/mlx5_compress.c +2 -2
@@ -244,8 +244,8 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.cqn = qp->cq.cq->id; qp_attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - qp_attr.rq_size =0 ; - qp_attr.sq_size =RTE_BIT32 (log_ops_n); + qp_attr.num_of_receive_wqes =0 ; + qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr,
drivers/crypto/mlx5/mlx5_crypto.c +96 -24
173 lines not on this page · raw message
drivers/crypto/mlx5/mlx5_crypto.h +7 -0
@@ -16,6 +16,13 @@#define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)#define MLX5_CRYPTO_KEY_LENGTH 80 +#define MLX5_CRYPTO_UMR_WQE_STATIC_SIZE (sizeof(struct mlx5_wqe_cseg) +\ + sizeof(struct mlx5_wqe_umr_cseg) +\ + sizeof(struct mlx5_wqe_mkey_cseg) +\ + sizeof(struct mlx5_wqe_umr_bsf_seg)) +#define MLX5_CRYPTO_KLM_SEGS_NUM (umr_wqe_sz) ((umr_wqe_sz -\ + MLX5_CRYPTO_UMR_WQE_STATIC_SIZE) /\ + MLX5_WSEG_SIZE)struct mlx5_crypto_priv {TAILQ_ENTRY (mlx5_crypto_priv) next;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -149,8 +149,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, qp_obj->qpn = q_ind; qp_obj->ci =0 ; qp_obj->pi =0 ; - attr.rq_size =0 ; - attr.sq_size =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, + attr.num_of_receive_wqes =0 ; + attr.num_of_send_wqbbs =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret = mlx5_devx_qp_create(priv->cdev->ctx, &qp_obj->qp_obj,
drivers/vdpa/mlx5/mlx5_vdpa_event.c +2 -2
@@ -589,9 +589,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, } attr.uar_index =mlx5_os_get_devx_uar_page_id (priv->uar.obj); attr.cqn = eqp->cq.cq_obj.cq->id; - attr.rq_size =RTE_BIT32 (log_desc_n); + attr.num_of_receive_wqes =RTE_BIT32 (log_desc_n); attr.log_rq_stride =rte_log2_u32 (MLX5_WSEG_SIZE ); - attr.sq_size =0 ;/* No need SQ. */ + attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); ret = mlx5_devx_qp_create(priv->cdev->ctx, &(eqp->sw_qp), log_desc_n,
Signature · 1 line
2.17.1
PATCH v2 4/4 common/mlx5: fix RQ size configuration in QP create
In reply to Raja ZidaneThe number of WQEBBs was provided to QP create, and QP size was calculated by multiplying the number of WQEBBs by 64, which is the send WQE size. When creating RQ in the QP (i.e., vdpa driver), the queue size was bigger because the receive WQE size is 16.
Provide queue size to QP create instead of the number of WQEBBs.
--- drivers/common/mlx5/mlx5_common_devx.c | 9 ++++----- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/compress/mlx5/mlx5_compress.c | 5 +++-- drivers/crypto/mlx5/mlx5_crypto.c | 5 +++-- drivers/regex/mlx5/mlx5_regex_control.c | 4 ++-- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +++-- 6 files changed, 16 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +4 -5
@@ -338,8 +338,8 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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] queue_size +* Size of queue to create. * @param[in] attr * Pointer to QP attributes structure. * @param[in] socket
@@ -349,7 +349,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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,uint32_t log_wqbb_n, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -357,7 +357,6 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -366,7 +365,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * num_of_wqbbs; + umem_size = queue_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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -89,7 +89,7 @@ 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, -uint32_t log_wqbb_n, +uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
drivers/compress/mlx5/mlx5_compress.c +3 -2
@@ -248,8 +248,9 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr, - socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp, + qp_attr.num_of_send_wqbbs * +MLX5_WQE_SIZE , &qp_attr, socket_id);if (ret !=0 ) {DRV_LOG (ERR ,"Failed to create QP." ); goto err;
drivers/crypto/mlx5/mlx5_crypto.c +3 -2
@@ -629,8 +629,9 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, attr.num_of_send_wqbbs =RTE_BIT32 (log_wqbb_n); attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, log_wqbb_n, - &attr, socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , + &attr, socket_id);if (ret) {DRV_LOG (ERR ,"Failed to create QP." ); goto error;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -154,8 +154,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp_obj->qp_obj, -MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc), - &attr,SOCKET_ID_ANY ); + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , &attr, +SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Can't create QP object." ); rte_errno =ENOMEM ;
drivers/vdpa/mlx5/mlx5_vdpa_event.c +3 -2
@@ -594,8 +594,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), log_desc_n, - &attr,SOCKET_ID_ANY ); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), + attr.num_of_receive_wqes * +MLX5_WSEG_SIZE , &attr,SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Failed to create SW QP(%u)." , rte_errno); goto error;
Signature · 1 line
2.17.1
v2 cover fixes to queue size config
In reply to Raja Zidanefixes series.
for vdpa dependent on:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
V2: rebase.
Raja Zidane (4):
common/mlx5: fix overflows in DevX queues size calculations crypto/mlx5: fix driver destroy before the configuration crypto/mlx5: fix the queue size configuration common/mlx5: fix RQ size configuration in QP create
drivers/common/mlx5/mlx5_common_devx.c | 19 ++-- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 9 +- drivers/crypto/mlx5/mlx5_crypto.c | 123 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 7 ++ drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 +- drivers/regex/mlx5/mlx5_regex_control.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 9 +- 10 files changed, 144 insertions(+), 58 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/4 common/mlx5: fix overflows in DevX queues size calculations
The HW QP/SQ/RQ/CQ queue sizes may be bigger than 64KB. The width of the variable handled the queue size is 16 bits which cannot contain the maximum queue size. Replace the size type to be uint32_t.
--- drivers/common/mlx5/mlx5_common_devx.c | 16 ++++++++-------- drivers/common/mlx5/mlx5_common_devx.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +8 -8
@@ -86,7 +86,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,size_t alignment =MLX5_CQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec;uint32_t eqn; -uint16_t cq_size =1 << log_desc_n; +uint32_t num_of_cqes =RTE_BIT32 (log_desc_n);int ret;if (page_size == (size_t )-1 || alignment == (size_t )-1 ) {
@@ -102,7 +102,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n,return -rte_errno; }/* Allocate memory buffer for CQEs and doorbell record. */ - umem_size =sizeof (struct mlx5_cqe ) * cq_size; + umem_size =sizeof (struct mlx5_cqe ) * num_of_cqes; 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,
@@ -142,7 +142,7 @@ mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj, uint16_t log_desc_n, cq_obj->cq = cq; cq_obj->db_rec =RTE_PTR_ADD (cq_obj->umem_buf, umem_dbrec);/* Mark all CQEs initially as invalid. */ -mlx5_cq_init (cq_obj, cq_size); +mlx5_cq_init (cq_obj, num_of_cqes);return 0 ; error: ret = rte_errno;
@@ -211,7 +211,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint16_t sq_size =1 << log_wqbb_n; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -220,7 +220,7 @@ mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * sq_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
@@ -349,7 +349,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -357,7 +357,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,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; +uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -366,7 +366,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint16_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * qp_size; + umem_size =MLX5_WQE_SIZE * num_of_wqbbs; 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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -89,7 +89,7 @@ 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, +uint32_t log_wqbb_n,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
Signature · 1 line
2.17.1
PATCH v2 2/4 crypto/mlx5: fix driver destroy before the configuration
In reply to Raja ZidaneWhen calling device close, unset dek is called which destroys a hash list. In case of error during dev probe, close is called when dek hlist is not initialized.
Ensure non null list destroy.
--- drivers/crypto/mlx5/mlx5_crypto_dek.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/mlx5/mlx5_crypto_dek.c +4 -2
@@ -156,6 +156,8 @@ mlx5_crypto_dek_setup(struct mlx5_crypto_priv *priv)void mlx5_crypto_dek_unset (struct mlx5_crypto_priv *priv) { -mlx5_hlist_destroy (priv->dek_hlist); - priv->dek_hlist =NULL ; +if (priv->dek_hlist) { +mlx5_hlist_destroy (priv->dek_hlist); + priv->dek_hlist =NULL ; + } }
Signature · 1 line
2.17.1
PATCH v2 3/4 crypto/mlx5: fix the queue size configuration
In reply to Raja ZidaneThe DevX interface for QP creation expects the number of WQEBBs. Wrongly, the number of descriptors was provided to the QP creation. In addition, the QP size must be a power of 2 what was not guaranteed. Provide the number of WQEBBs to the QP creation API.
Round up the SQ size to a power of 2.
Rename (sq/rq)_size to num_of_(send/receive)_wqes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 +-- drivers/common/mlx5/mlx5_devx_cmds.h | 5 +- drivers/compress/mlx5/mlx5_compress.c | 4 +- drivers/crypto/mlx5/mlx5_crypto.c | 120 +++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto.h | 7 ++ drivers/regex/mlx5/mlx5_regex_control.c | 4 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 4 +- 7 files changed, 120 insertions(+), 38 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +8 -6
@@ -832,6 +832,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_HCA_CAP_OPMOD_GET_CUR);if (!hcattr)return rc; + attr->max_wqe_sz_sq =MLX5_GET (cmd_hca_cap, hcattr, max_wqe_sz_sq); attr->flow_counter_bulk_alloc_bitmap =MLX5_GET (cmd_hca_cap, hcattr, flow_counter_bulk_alloc); attr->flow_counters_dump = MLX5_GET(cmd_hca_cap, hcattr,
@@ -2153,21 +2154,22 @@ mlx5_devx_cmd_create_qp(void *ctx,if (attr->log_page_size >MLX5_ADAPTER_PAGE_SHIFT )MLX5_SET (qpc, qpc, log_page_size, attr->log_page_size -MLX5_ADAPTER_PAGE_SHIFT ); -if (attr->sq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->sq_size)); +if (attr->num_of_send_wqbbs) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->num_of_send_wqbbs));MLX5_SET (qpc, qpc, cqn_snd, attr->cqn);MLX5_SET (qpc, qpc, log_sq_size, -rte_log2_u32 (attr->sq_size)); +rte_log2_u32 (attr->num_of_send_wqbbs)); }else {MLX5_SET (qpc, qpc, no_sq,1 ); } -if (attr->rq_size) { -MLX5_ASSERT (RTE_IS_POWER_OF_2 (attr->rq_size)); +if (attr->num_of_receive_wqes) { +MLX5_ASSERT (RTE_IS_POWER_OF_2 ( + attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, cqn_rcv, attr->cqn);MLX5_SET (qpc, qpc, log_rq_stride, attr->log_rq_stride -MLX5_LOG_RQ_STRIDE_SHIFT );MLX5_SET (qpc, qpc, log_rq_size, -rte_log2_u32 (attr->rq_size)); +rte_log2_u32 (attr->num_of_receive_wqes));MLX5_SET (qpc, qpc, rq_type,MLX5_NON_ZERO_RQ ); }else {MLX5_SET (qpc, qpc, rq_type,MLX5_ZERO_LEN_RQ );
drivers/common/mlx5/mlx5_devx_cmds.h +3 -2
@@ -251,6 +251,7 @@ struct mlx5_hca_attr { uint32_t log_max_mmo_decompress:5; uint32_t umr_modify_entity_size_disabled:1; uint32_t umr_indirect_mkey_disabled:1; +uint16_t max_wqe_sz_sq; };/* LAG Context. */
@@ -477,9 +478,9 @@ struct mlx5_devx_qp_attr { uint32_t uar_index:24; uint32_t cqn:24; uint32_t log_page_size:5; - uint32_t rq_size:17; /* Must be power of 2. */ + uint32_t num_of_receive_wqes:17; /* Must be power of 2. */ uint32_t log_rq_stride:3; - uint32_t sq_size:17; /* Must be power of 2. */ + uint32_t num_of_send_wqbbs:17; /* Must be power of 2. */ uint32_t ts_format:2; uint32_t dbr_umem_valid:1;uint32_t dbr_umem_id;
drivers/compress/mlx5/mlx5_compress.c +2 -2
@@ -244,8 +244,8 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.cqn = qp->cq.cq->id; qp_attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - qp_attr.rq_size =0 ; - qp_attr.sq_size =RTE_BIT32 (log_ops_n); + qp_attr.num_of_receive_wqes =0 ; + qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr,
drivers/crypto/mlx5/mlx5_crypto.c +96 -24
173 lines not on this page · raw message
drivers/crypto/mlx5/mlx5_crypto.h +7 -0
@@ -16,6 +16,13 @@#define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11)#define MLX5_CRYPTO_KEY_LENGTH 80 +#define MLX5_CRYPTO_UMR_WQE_STATIC_SIZE (sizeof(struct mlx5_wqe_cseg) +\ + sizeof(struct mlx5_wqe_umr_cseg) +\ + sizeof(struct mlx5_wqe_mkey_cseg) +\ + sizeof(struct mlx5_wqe_umr_bsf_seg)) +#define MLX5_CRYPTO_KLM_SEGS_NUM (umr_wqe_sz) ((umr_wqe_sz -\ + MLX5_CRYPTO_UMR_WQE_STATIC_SIZE) /\ + MLX5_WSEG_SIZE)struct mlx5_crypto_priv {TAILQ_ENTRY (mlx5_crypto_priv) next;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -149,8 +149,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, qp_obj->qpn = q_ind; qp_obj->ci =0 ; qp_obj->pi =0 ; - attr.rq_size =0 ; - attr.sq_size =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, + attr.num_of_receive_wqes =0 ; + attr.num_of_send_wqbbs =RTE_BIT32 (MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret = mlx5_devx_qp_create(priv->cdev->ctx, &qp_obj->qp_obj,
drivers/vdpa/mlx5/mlx5_vdpa_event.c +2 -2
@@ -589,9 +589,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, } attr.uar_index =mlx5_os_get_devx_uar_page_id (priv->uar.obj); attr.cqn = eqp->cq.cq_obj.cq->id; - attr.rq_size =RTE_BIT32 (log_desc_n); + attr.num_of_receive_wqes =RTE_BIT32 (log_desc_n); attr.log_rq_stride =rte_log2_u32 (MLX5_WSEG_SIZE ); - attr.sq_size =0 ;/* No need SQ. */ + attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); ret = mlx5_devx_qp_create(priv->cdev->ctx, &(eqp->sw_qp), log_desc_n,
Signature · 1 line
2.17.1
PATCH v2 4/4 common/mlx5: fix RQ size configuration in QP create
In reply to Raja ZidaneThe number of WQEBBs was provided to QP create, and QP size was calculated by multiplying the number of WQEBBs by 64, which is the send WQE size. When creating RQ in the QP (i.e., vdpa driver), the queue size was bigger because the receive WQE size is 16.
Provide queue size to QP create instead of the number of WQEBBs.
--- drivers/common/mlx5/mlx5_common_devx.c | 9 ++++----- drivers/common/mlx5/mlx5_common_devx.h | 2 +- drivers/compress/mlx5/mlx5_compress.c | 5 +++-- drivers/crypto/mlx5/mlx5_crypto.c | 5 +++-- drivers/regex/mlx5/mlx5_regex_control.c | 4 ++-- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 5 +++-- 6 files changed, 16 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_common_devx.c +4 -5
@@ -338,8 +338,8 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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] queue_size +* Size of queue to create. * @param[in] attr * Pointer to QP attributes structure. * @param[in] socket
@@ -349,7 +349,7 @@ mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp)* 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,uint32_t log_wqbb_n, +mlx5_devx_qp_create (void *ctx,struct mlx5_devx_qp *qp_obj,uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket) {struct mlx5_devx_obj *qp =NULL ;
@@ -357,7 +357,6 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,void *umem_buf =NULL ;size_t alignment =MLX5_WQE_BUF_ALIGNMENT ;uint32_t umem_size, umem_dbrec; -uint32_t num_of_wqbbs =RTE_BIT32 (log_wqbb_n);int ret;if (alignment == (size_t )-1 ) {
@@ -366,7 +365,7 @@ mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj, uint32_t log_wqbb_n,return -rte_errno; }/* Allocate memory buffer for WQEs and doorbell record. */ - umem_size =MLX5_WQE_SIZE * num_of_wqbbs; + umem_size = queue_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,
drivers/common/mlx5/mlx5_common_devx.h +1 -1
@@ -89,7 +89,7 @@ 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, -uint32_t log_wqbb_n, +uint32_t queue_size,struct mlx5_devx_qp_attr *attr,int socket); __rte_internal
drivers/compress/mlx5/mlx5_compress.c +3 -2
@@ -248,8 +248,9 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, qp_attr.num_of_send_wqbbs =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->cdev->ctx, &qp->qp, log_ops_n, &qp_attr, - socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp, + qp_attr.num_of_send_wqbbs * +MLX5_WQE_SIZE , &qp_attr, socket_id);if (ret !=0 ) {DRV_LOG (ERR ,"Failed to create QP." ); goto err;
drivers/crypto/mlx5/mlx5_crypto.c +3 -2
@@ -629,8 +629,9 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, attr.num_of_send_wqbbs =RTE_BIT32 (log_wqbb_n); attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, log_wqbb_n, - &attr, socket_id); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp->qp_obj, + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , + &attr, socket_id);if (ret) {DRV_LOG (ERR ,"Failed to create QP." ); goto error;
drivers/regex/mlx5/mlx5_regex_control.c +2 -2
@@ -154,8 +154,8 @@ regex_ctrl_create_hw_qp(struct mlx5_regex_priv *priv, struct mlx5_regex_qp *qp, log_nb_desc)); attr.mmo = priv->mmo_regex_qp_cap; ret =mlx5_devx_qp_create (priv->cdev->ctx, &qp_obj->qp_obj, -MLX5_REGEX_WQE_LOG_NUM (priv->has_umr, log_nb_desc), - &attr,SOCKET_ID_ANY ); + attr.num_of_send_wqbbs *MLX5_WQE_SIZE , &attr, +SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Can't create QP object." ); rte_errno =ENOMEM ;
drivers/vdpa/mlx5/mlx5_vdpa_event.c +3 -2
@@ -594,8 +594,9 @@ mlx5_vdpa_event_qp_create(struct mlx5_vdpa_priv *priv, uint16_t desc_n, attr.num_of_send_wqbbs =0 ;/* No need SQ. */ attr.ts_format =mlx5_ts_format_conv (priv->cdev->config.hca_attr.qp_ts_format); - ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), log_desc_n, - &attr,SOCKET_ID_ANY ); + ret =mlx5_devx_qp_create (priv->cdev->ctx, &(eqp->sw_qp), + attr.num_of_receive_wqes * +MLX5_WSEG_SIZE , &attr,SOCKET_ID_ANY );if (ret) {DRV_LOG (ERR ,"Failed to create SW QP(%u)." , rte_errno); goto error;
Signature · 1 line
2.17.1
Thomas Monjalon
AppliedQuoted 5 lines
Raja Zidane (4):
common/mlx5: fix overflows in DevX queues size calculationscrypto/mlx5: fix driver destroy before the configurationcrypto/mlx5: fix the queue size configuration common/mlx5: fix RQ size configuration in QP create
Applied, thanks.