From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53876A0548; Thu, 4 Nov 2021 13:50:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC64442716; Thu, 4 Nov 2021 13:50:00 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2069.outbound.protection.outlook.com [40.107.101.69]) by mails.dpdk.org (Postfix) with ESMTP id 7F4DA41223; Thu, 4 Nov 2021 13:49:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JyxoSVA1UrJBjNjNycwLlr8NU5/NLKg44cRDIUc2w2SRuSsdKq5aAotVgqhaThaISeEch1ED249kAoSqWogEUkkc9nVzb4kImRnCYq0RX1moRn3fgCohA8xVUwrJ9ACDB2ow+jbm5IUbr823tmncy2vgKWnlmvZx7GJ7T2xcn/d6MnjxiM8sJzhbZy8UGkGvCt3/6eVFCrAWo5fDjuEC6ge5Wyh+OufYxAKJJWUlyF8oycOLYy0EMfHVv+ny48/TruMQtNUP25JaLkdrEOk/+bMg1scF4G+RYvH4fUWMtAPbeYuQ43pSC3dsiz6c4j1S+JXjPOT83s9nY7x4Kos7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o2IFU7XPo1Y9+rh+0e0Ux7Ko2XWKjWch7yMBO5ODr9E=; b=mOVp5O00YcLtLrwosJgeGyYDMOArMgLRUy+Pl5rNXUUUKj1qSPSEEIMk04nbFq7aTDHgVkbYDwS1ltGNc/LQ3Yj9jmKIhF718Cx+pRLs2ZrZJCTJ4huo3LOYQnYwz3fFVqxFztW7OHck4bUjNtogRIo0QetkgtBAIhg9WBTTWR/bNA5p6mxfllkkD4fIgNlBilUwL7bhIaDBndWDbu/bCmjhRrtjaUDPKCRme6kZBMgJaUTjfgRRXJyuIXAmogxAi975sxISjOcqgX/e7t5Vye7+pHG02LfxF+EOY3HtiUcUh+GMI10Z8encD+cnYH5NR05V6ntgQ7k6dgVH/9DPpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o2IFU7XPo1Y9+rh+0e0Ux7Ko2XWKjWch7yMBO5ODr9E=; b=AJ96VNDlf7tkkXYbXPkSt1YCMD8EW2ve2V3zWQBqbd3yXqVY10MSC121HkHOmhqm80WCc4/viMfXu/sAbQhXpatYYN38hJX81Q5to28g7nxaA0nkL376LJCPlfShi1hOdIfMbAoQtFf9M0aUcnmGGlIGupzq+4KsFvkDhgXT932y9KVewGOg5Pi9QefFn32MTQghX23K5S0mUxeO6g71aV2XlFRL8WJaLfM5ZuUGcL/7Ec/FvbEvJdjjjARLgIjCfpf79fD1p/Y4xSegvBVGQAIyrqfBIgaJ1WoON9gt22BeFXC7EIN8nQtw3hkp46Z0KhN3RgKbuC5+G0VSTShSMg== Received: from BN9PR03CA0391.namprd03.prod.outlook.com (2603:10b6:408:111::6) by DM6PR12MB4187.namprd12.prod.outlook.com (2603:10b6:5:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Thu, 4 Nov 2021 12:49:56 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:408:111:cafe::8) by BN9PR03CA0391.outlook.office365.com (2603:10b6:408:111::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Thu, 4 Nov 2021 12:49:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 12:49:56 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 4 Nov 2021 12:49:52 +0000 From: Raja Zidane To: CC: Matan Azrad , Date: Thu, 4 Nov 2021 12:49:26 +0000 Message-ID: <20211104124929.24899-2-rzidane@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211104124929.24899-1-rzidane@nvidia.com> References: <20211104124929.24899-1-rzidane@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b69ac63-d216-4fa3-5e4f-08d99f919ac8 X-MS-TrafficTypeDiagnostic: DM6PR12MB4187: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 06GaI/jEY6sTfmhlAeXI8hCgCUslkvkVvvLWnyxyQuWStUm1hbnlLkbCrfD3VQ518FMRAwP0V8rwj8J9aKEGDzuhq111C7B/D2GVaZNEI2P/MzQU0liIKnswzcxoA65VBO5w34BSX8rRGjOMmUQoqhO5/VzidZbkbs3GNJCunnK08wQ1bjaSOvP+Y222aCz5mcmV7p97VEehOIhr9MYmOgzr82m4DUh6AYOYrVzWOzqS7lmpioKXh/kJZjpC05uEnjtsuIWewtAEHIGw4tjK2fz1M06k3Sws543P2H+l0tjiLRasK+xsvT9tHgy0sTLgENPFCn+1IMML/ZidY4+I9760Kr+sGFsTRW8KexGgP7eloD/cCcoaet4iZtjIcpMElpchAlZWTg/nWJFOng6EIiPw8Ufv+2KRWx5Nz4VKHbsyNJVJW2BeE2gE4SLF3Ts08FSRx8vcB2KbeC9yBEjRSkctDNNPhq2vhICAX5u/fEck5vus45LI7qNNaHfMkQFRwa3yPSIzvhyArwGw85bvsuchyiLEeH36TP/vJew493YQaoHA4Z1DaiDkxNJY0/SaDqgnlY9/7H790xoVDB/D0KvIlkXmcXSourJPAwHSCR1MF+XJeq46yYSIpTVsrUSVAVi0xmpAIFDB7FbsEDjYmbnWb6INPqZMYGnj0C/WESx4bXJgYWP/4AWXSiGvOhGdspA4zDn/+sf0mPwMjDQSPQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(83380400001)(36860700001)(336012)(1076003)(86362001)(4326008)(450100002)(54906003)(6666004)(2616005)(7636003)(426003)(316002)(55016002)(82310400003)(356005)(8936002)(16526019)(47076005)(70206006)(186003)(508600001)(8676002)(36756003)(26005)(6286002)(7696005)(5660300002)(2906002)(6916009)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 12:49:56.2934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b69ac63-d216-4fa3-5e4f-08d99f919ac8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4187 Subject: [dpdk-dev] [PATCH 1/4] common/mlx5: fix overflows in DevX queues size calculations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Matan Azrad --- 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 825f84b183..0e58308b0b 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, @@ -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, diff --git a/drivers/common/mlx5/mlx5_common_devx.h b/drivers/common/mlx5/mlx5_common_devx.h index f699405f69..7138bd7914 100644 --- a/drivers/common/mlx5/mlx5_common_devx.h +++ b/drivers/common/mlx5/mlx5_common_devx.h @@ -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 -- 2.17.1