From: Raja Zidane <rzidane@nvidia.com>
To: <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>, <stable@dpdk.org>
Subject: [dpdk-dev] [PATCH V2 1/4] common/mlx5: fix overflows in DevX queues size calculations
Date: Mon, 8 Nov 2021 13:09:18 +0000 [thread overview]
Message-ID: <20211108130921.19143-2-rzidane@nvidia.com> (raw)
In-Reply-To: <20211108130921.19143-1-rzidane@nvidia.com>
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.
Fixes: 9dab4d62b4dc ("common/mlx5: share DevX CQ creation")
Fixes: 38f537635c15 ("common/mlx5: share DevX SQ creation")
Fixes: f9213ab12cf9 ("common/mlx5: share DevX queue pair operations")
Cc: stable@dpdk.org
Signed-off-by: Raja Zidane <rzidane@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/common/mlx5/mlx5_common_devx.c | 16 ++++++++--------
drivers/common/mlx5/mlx5_common_devx.h | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common_devx.c b/drivers/common/mlx5/mlx5_common_devx.c
index 85b5282061..5afe6f2b9c 100644
--- a/drivers/common/mlx5/mlx5_common_devx.c
+++ b/drivers/common/mlx5/mlx5_common_devx.c
@@ -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,
diff --git a/drivers/common/mlx5/mlx5_common_devx.h b/drivers/common/mlx5/mlx5_common_devx.h
index 7ceac040f8..df92feebe2 100644
--- a/drivers/common/mlx5/mlx5_common_devx.h
+++ b/drivers/common/mlx5/mlx5_common_devx.h
@@ -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
--
2.17.1
next prev parent reply other threads:[~2021-11-08 13:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 12:49 [dpdk-dev] [PATCH 0/4] fixes to queue size config Raja Zidane
2021-11-04 12:49 ` [dpdk-dev] [PATCH 1/4] common/mlx5: fix overflows in DevX queues size calculations Raja Zidane
2021-11-04 12:49 ` [dpdk-dev] [PATCH 2/4] crypto/mlx5: fix driver destroy before the configuration Raja Zidane
2021-11-04 12:49 ` [dpdk-dev] [PATCH 3/4] crypto/mlx5: fix the queue size configuration Raja Zidane
2021-11-04 18:59 ` Tal Shnaiderman
2021-11-04 12:49 ` [dpdk-dev] [PATCH 4/4] common/mlx5: fix RQ size configuration in QP create Raja Zidane
2021-11-08 9:02 ` [dpdk-dev] [PATCH 0/4] fixes to queue size config Thomas Monjalon
2021-11-08 12:33 ` [dpdk-dev] [PATCH V2 " Raja Zidane
2021-11-08 12:33 ` [dpdk-dev] [PATCH V2 1/4] common/mlx5: fix overflows in DevX queues size calculations Raja Zidane
2021-11-08 12:33 ` [dpdk-dev] [PATCH V2 2/4] crypto/mlx5: fix driver destroy before the configuration Raja Zidane
2021-11-08 12:33 ` [dpdk-dev] [PATCH V2 3/4] crypto/mlx5: fix the queue size configuration Raja Zidane
2021-11-08 12:33 ` [dpdk-dev] [PATCH V2 4/4] common/mlx5: fix RQ size configuration in QP create Raja Zidane
2021-11-08 13:09 ` [dpdk-dev] [PATCH V2 0/4] fixes to queue size config Raja Zidane
2021-11-08 13:09 ` Raja Zidane [this message]
2021-11-08 13:09 ` [dpdk-dev] [PATCH V2 2/4] crypto/mlx5: fix driver destroy before the configuration Raja Zidane
2021-11-08 13:09 ` [dpdk-dev] [PATCH V2 3/4] crypto/mlx5: fix the queue size configuration Raja Zidane
2021-11-08 13:09 ` [dpdk-dev] [PATCH V2 4/4] common/mlx5: fix RQ size configuration in QP create Raja Zidane
2021-11-08 18:44 ` [dpdk-dev] [PATCH V2 0/4] fixes to queue size config Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211108130921.19143-2-rzidane@nvidia.com \
--to=rzidane@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).