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 9DA5DA0C4D; Mon, 8 Nov 2021 14:09:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C25514113F; Mon, 8 Nov 2021 14:09:42 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) by mails.dpdk.org (Postfix) with ESMTP id A995A410FD; Mon, 8 Nov 2021 14:09:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMG56CR53F+2tcqnPPr0O/To25sJXn8ZFYO3BXyfXWecyRyJtEu3g7L6xouG5zvj2wJ/bj6Zj9MgZ6dzyZ9MOd4EjU8il9Q3d9rcdix5ob16jUY2WucMuJNXqaAXvUdl+cthNYvV97om8O79iinHXVnQSmZfKlr52EyZ5znzKq9lKUfNc+5vEblSRWBJ273wDKw51WqaA0Ps6kc+f0X/PpKb5qVZ71fE/nG8hvpJ/KydFffkt4pxa3hItoM42mXdgf4ydBdGIR9M8GQQQFy8+D8+/k940ZPDT0XIEv+x3Ohk2uEtwbJo6/SQtwhDUPQttnhCGFnF0gmXceL4y5GmKg== 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=0GNYQmU9m+1XJe9jz7M8ChAo21Cw6UfHnflMol3JnLI=; b=AxnWgeQ8LALtNxDpt+Sp5mnkRrWw3zGQZ4ncuCvPWd0a4ue2qK8d6Kc9jz7MdHZp0Z53v04vGrSUcdz3MPvXXo0J8eDDiCtnNPLd2EOxuoy4Iwnp1whjRZAf4MQFhc+cJm16D1kSZJoawsJZsS43giwgpqgMQNgWQ7oTpyu09JmYG9Ak9+O/sx1igvXku0xs7aZAjKg+XoL2d4Y9SWLa1W6QnIJ+jIzm79jW6g+MNfSuUKvcu5dXtGOxfJMNGWKluGqSeafzoczSJjq6LSUYKgfnaLD3FrhqHNIboqNaKfIvOvw5sbq5WE5tVub8du9aCWiCuUY5+rdeRD9hPJ5xUQ== 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=0GNYQmU9m+1XJe9jz7M8ChAo21Cw6UfHnflMol3JnLI=; b=qZAM09WKvKjN8XtNEd+BSErC89k4RvZWhr7LkSw+TL93OcDD6Re2j95TuMISCFtCa8PLzEsm/CIIUOF8kTApTPogSvZkiSwnThlXOQkdpzfP/H6aPW/8MuumVbKnGYi9wSPuSjoF8Xh1jULw1NYiWZ/17pbsDfakTZPpRDck8M5AXUX1n8+EU+UUfbgvVVNQk74R5HL2huChv+AHDGbtbkoelLAYxQWLizJqhq1AjX7rHCFCXwjIXf6NOy4bLLWmilC5mKVQR4CFdNM+bI6M8erYZGPVUBMQYmU6C33DjwUEwcpgatPsqZfrEd8hUx+4bxYgNxvcbonHlic2jcmxEw== Received: from MWHPR1701CA0013.namprd17.prod.outlook.com (2603:10b6:301:14::23) by SA0PR12MB4413.namprd12.prod.outlook.com (2603:10b6:806:9e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Mon, 8 Nov 2021 13:09:39 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:301:14:cafe::de) by MWHPR1701CA0013.outlook.office365.com (2603:10b6:301:14::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Mon, 8 Nov 2021 13:09:39 +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 CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 13:09:38 +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; Mon, 8 Nov 2021 13:09:36 +0000 From: Raja Zidane To: CC: Matan Azrad , Date: Mon, 8 Nov 2021 13:09:18 +0000 Message-ID: <20211108130921.19143-2-rzidane@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211108130921.19143-1-rzidane@nvidia.com> References: <20211108123354.2194-1-rzidane@nvidia.com> <20211108130921.19143-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: cc08473c-054b-43c9-fb93-08d9a2b90502 X-MS-TrafficTypeDiagnostic: SA0PR12MB4413: 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: S4g8UFhpcW43dcfZ70XtG0TR20QVqjlyRcEfUOaPKcSFgMAx+9qEwx0fPKz+HLuMKgalTNWwmW7N3CdbQ82rxSVn0vRssZcCLJT1zPABZr8A6AwjQ574Yp91bu0Sbz8xWmlaNghYZPUINHHK6RA4ABRKJAkSsGg+964pqV03VnZiZMpLaifcHu9MX1IM5PDMHtjJGN3N9wegsPoLT4DeAKAzhSSpnOgEIoaNkc3CnxwdDahxad1YJJBqpcKXxLEzQzmQnHG+DZOSeK6MWgkJePd8mJba+5WTfJ3sGve4tmSxKjuZ4kOtqxfVdJ1Jgi70HLTilY7pkzXVa6228vWw813bJW7ZWr6eFj0lUgu52Z3fTH3iA1DYfTP2oW7krIZACgxKVmc1hiIA6ydPISB9UadlBA9wTpiieVGTjEHyS8V2oSeSyHStTiDydnMNZpF8EHY7YVPj5avlwQ7EW8TRlkQTWXxJjmR/MRrus16l4EfGZZT10lPP3261zNtK8wmw52F5kK3RRjuh3BixsBHchc9jOmDImx7UsOwDnCHXc/R6Y5oCwI2ZpHlSPt3h13XAl04F72vWh28NlLrsrSTVDIkFI9fqIcd82Yiowy5zwoMCK4H4RdmfuzdpSKtXhVI1yXQ7wzHhaBrlKTK5K/Z9h8Tfgf66A4TJ4nyLYiLArPtvNtzPw7f0YWtKK8LVLazr 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)(7696005)(86362001)(36860700001)(6666004)(356005)(7636003)(36756003)(8676002)(54906003)(47076005)(6916009)(5660300002)(2616005)(70586007)(70206006)(316002)(508600001)(186003)(2906002)(426003)(450100002)(82310400003)(4326008)(55016002)(83380400001)(8936002)(336012)(1076003)(6286002)(16526019)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 13:09:38.5277 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc08473c-054b-43c9-fb93-08d9a2b90502 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: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4413 Subject: [dpdk-dev] [PATCH V2 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 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