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 07D57A0032; Thu, 27 Jan 2022 16:40:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 107F942867; Thu, 27 Jan 2022 16:40:09 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2074.outbound.protection.outlook.com [40.107.101.74]) by mails.dpdk.org (Postfix) with ESMTP id 37DBE42811; Thu, 27 Jan 2022 16:40:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gwp0j3InyrHTuqR7ilThIj5z03v7cseIMgkSm0PHybc4lJCux6f92TpJbPxh+3jn8VvMKTmugu6suvNNTuAp5bRZokc2hq+7mffuQN25P8NFVQMInlllEdyRj6dfLlAUVll3X/1f7f98oK+snCW7d4vOolfrNbv3mCwX5jwJg2iLg9KWpR24C0K1NjQmydHupDq1JEtaPavAYmObHTu0gGAOLyQE/vPYad3VwckbS8l8U+CcNihSuRXyLFNdtLRJ5Kgd3cnp3UV7Tu8XSGmrPSZNmxS/UPHGbY56v5YaeVmW5LKM2TM7DKI6GoABtgp2HUMYICLqp/LS3fbu9n/RZQ== 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=wtPvLzEshKHN0ZHSy61EppzDSebnDI+hXcktWtRmP9c=; b=GNYzV7/9VKo4cL019fVrj64ze4pYp1I6NfV1Acpv42kJ4j9sggZ4f6ItUx8ITFWv28lZ8O4C/98mFn7TCr8CsIpmadgQV2GSdvjme65F/uBluCZRyxYqdWQfi2BZ/LMlCQ0ER4JAN1/a2dF8FBb2iCz7RwcJ7ReSZEJsJeNJ+IdoLVO183AuiM3eitXuaQau+IeDrm+rCFyKBplKLAwbtDX4L1p+h/m8fhKTrP9w4COlzmrhU3kYZxJyGLUZXpxl34afHnF1PXPUepjyi/hjpxcGyzLyHsdpoLB9f0aojk34sUlRvcCnZQwxypcgHXZhoYuZ2FUa58KOdpdrknwzmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=wtPvLzEshKHN0ZHSy61EppzDSebnDI+hXcktWtRmP9c=; b=WQICwfmvNREN8hQIRcNYc3fWfep570QNen1gB2OQSFlXg3GyMkpPs0lROFW4ZI2bpKp5ATaEV0tnPRdxTZVafKkrcZznXsVP0wFjicqfP9PNdisI8xwLjGbUAV4+vrboQslPZVASWMr5RuG+mdiz98vz371DSqSvYTfzNA1LiMDsKYQ8ilOLHXi/azH8o7BGAEQzeeKS0J+ZDZCgmGUn9K5eeGXxF60t2FsKPD409TCwEp50OPX0inLOaja9hF7YjKUmFICgBO9BYkpIjAkIU+pXFnRIKjrMCw6k3SA+z4yPc0gDMAFVsaAIETFOmTK4+qeqFd6yjg6+XuhI5U38mQ== Received: from BN8PR04CA0005.namprd04.prod.outlook.com (2603:10b6:408:70::18) by MW3PR12MB4524.namprd12.prod.outlook.com (2603:10b6:303:2d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.11; Thu, 27 Jan 2022 15:40:05 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::be) by BN8PR04CA0005.outlook.office365.com (2603:10b6:408:70::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 15:40:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 15:40:04 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 27 Jan 2022 15:40:04 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 27 Jan 2022 07:40:03 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Thu, 27 Jan 2022 07:40:02 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Subject: [PATCH 04/20] net/mlx5: fix inconsistency errno update in SH creation Date: Thu, 27 Jan 2022 17:39:34 +0200 Message-ID: <20220127153950.812953-5-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127153950.812953-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78df4582-d977-4e65-7264-08d9e1ab49f0 X-MS-TrafficTypeDiagnostic: MW3PR12MB4524:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 34hfQao34ZsTbsmKbrCgIKRGpTfWP/MhTvbeOwPCretP+JhiYsjP9ITh6Nt1xAj/3iRtLwKZwQUYlBKkqE8LxzyX00eIpzkuCxag7k9/SXdlvXhRttTriEPmsyqXiTvBGo/Qjwclyl7sUzM9Bi2jgwQ7TKtFyHneC4vDSCEcu1I4sCbnqb+q6CEAiH3c356SfxbiQSoOpFU7W1Mx4Z+V95UKcuf2pKRy+odN2UYIC0sI2r6bnLGr9MTxaRHHk926lD5V22+HtzXmSnrp5MYe+T513EqfM8O7D/bWK9T1tkN2NOoTz8tiSYqwSyrBsCmKqJmjPDjQQ3FgtVrIlTpDFIMn4iHzAz24ZA5i3O+AuBfg0FCHsqKtYu/IUgmnVGZ4zODTBFckYp6er2so3YlAluJ+LN+1QK2cAFmQw42I5cu2tJCylAxhQpO0TKiVhHU3TWrSPlTMpWA9Q9VSnVZC3XSH6A10ZsoxNMTrVN/NtE92sTUDc0RQ3aUvl/raM/Bgr0OvhIm7iROHBh1WDhBI223o6hf/FApGPGp91AM5RKDossIRvFmOC2hie/pAycVxU6LRpcx27hxWTZ8rxG5UcntwcfIjuqO8YRYkAgfMDa1yZk6noYsRLC6y3RgzJi8wgsM5QaAIYrvCqoJ1glWmNfyKKrvuVTKf9+o7czGI7AabOSwnXF98PuVPRjTbXAfHAYF7G0qiBjNiNGIeQL6jitfAMr7Z57JZLwTxIuE8jIdBP+b0aAbrs2hF9dUCDJHkMEFSHz32/lKIP/+B/0xqAm8FMTsk2j7RUqKaPFgnT9w= X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(40470700004)(36840700001)(2906002)(186003)(26005)(40460700003)(7696005)(6286002)(36756003)(86362001)(316002)(6916009)(47076005)(81166007)(356005)(83380400001)(55016003)(70586007)(82310400004)(70206006)(4326008)(54906003)(15650500001)(508600001)(450100002)(8936002)(36860700001)(8676002)(6666004)(426003)(5660300002)(1076003)(336012)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 15:40:04.3912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78df4582-d977-4e65-7264-08d9e1ab49f0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4524 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 The mlx5_alloc_shared_dev_ctx() function has a local variable named "err" which contains the errno value in case of failure. When functions called by this function are failed, this variable is updated with their return value (that should be a positive errno value). However, some functions doesn't update errno value by themselves or return negative errno value. If one of them fails, the "err" variable contains negative value what cause to assertion failure. This patch updates all functions uses by mlx5_alloc_shared_dev_ctx() function to update rte_errno and take this value instead of "err" value. Fixes: 5dfa003db53f ("common/mlx5: fix post doorbell barrier") Fixes: 5d55a494f4e6 ("net/mlx5: split multi-thread flow handling per OS") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_flow_os.c | 3 ++- drivers/net/mlx5/linux/mlx5_os.c | 16 ++++++++++------ drivers/net/mlx5/mlx5.c | 24 +++++++++++------------- drivers/net/mlx5/windows/mlx5_flow_os.c | 2 +- drivers/net/mlx5/windows/mlx5_os.c | 24 ++++++++++++------------ 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c index 893f00b824..a5956c255a 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.c +++ b/drivers/net/mlx5/linux/mlx5_flow_os.c @@ -14,7 +14,8 @@ mlx5_flow_os_init_workspace_once(void) { if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); - return -ENOMEM; + rte_errno = ENOMEM; + return -rte_errno; } return 0; } diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index e45e56f4b6..f587a47f6e 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -138,7 +138,7 @@ mlx5_os_set_nonblock_channel_fd(int fd) * Pointer to mlx5 device attributes. * * @return - * 0 on success, non zero error number otherwise + * 0 on success, a negative errno value otherwise and rte_errno is set. */ int mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, @@ -150,8 +150,10 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, memset(device_attr, 0, sizeof(*device_attr)); err = mlx5_glue->query_device_ex(ctx, NULL, &attr_ex); - if (err) - return err; + if (err) { + rte_errno = errno; + return -rte_errno; + } device_attr->device_cap_flags_ex = attr_ex.device_cap_flags_ex; device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr; device_attr->max_sge = attr_ex.orig_attr.max_sge; @@ -170,8 +172,10 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, struct mlx5dv_context dv_attr = { .comp_mask = 0 }; err = mlx5_glue->dv_query_device(ctx, &dv_attr); - if (err) - return err; + if (err) { + rte_errno = errno; + return -rte_errno; + } device_attr->flags = dv_attr.flags; device_attr->comp_mask = dv_attr.comp_mask; @@ -195,7 +199,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, strlcpy(device_attr->fw_ver, attr_ex.orig_attr.fw_ver, sizeof(device_attr->fw_ver)); - return err; + return 0; } /** diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d1d398f49a..25d4d2082b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1172,12 +1172,11 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, MLX5_ASSERT(spawn->max_port); sh = mlx5_malloc(MLX5_MEM_ZERO | MLX5_MEM_RTE, sizeof(struct mlx5_dev_ctx_shared) + - spawn->max_port * - sizeof(struct mlx5_dev_shared_port), + spawn->max_port * sizeof(struct mlx5_dev_shared_port), RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); if (!sh) { - DRV_LOG(ERR, "shared context allocation failure"); - rte_errno = ENOMEM; + DRV_LOG(ERR, "Shared context allocation failure."); + rte_errno = ENOMEM; goto exit; } pthread_mutex_init(&sh->txpp.mutex, NULL); @@ -1199,9 +1198,8 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, strncpy(sh->ibdev_path, mlx5_os_get_ctx_device_path(sh->cdev->ctx), sizeof(sh->ibdev_path) - 1); /* - * Setting port_id to max unallowed value means - * there is no interrupt subhandler installed for - * the given port index i. + * Setting port_id to max unallowed value means there is no interrupt + * subhandler installed for the given port index i. */ for (i = 0; i < sh->max_port; i++) { sh->port[i].ih_port_id = RTE_MAX_ETHPORTS; @@ -1211,12 +1209,12 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, sh->td = mlx5_devx_cmd_create_td(sh->cdev->ctx); if (!sh->td) { DRV_LOG(ERR, "TD allocation failure"); - err = ENOMEM; + rte_errno = ENOMEM; goto error; } if (mlx5_setup_tis(sh)) { DRV_LOG(ERR, "TIS allocation failure"); - err = ENOMEM; + rte_errno = ENOMEM; goto error; } err = mlx5_rxtx_uars_prepare(sh); @@ -1246,19 +1244,19 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex); return sh; error: + err = rte_errno; pthread_mutex_destroy(&sh->txpp.mutex); pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex); MLX5_ASSERT(sh); - if (sh->td) - claim_zero(mlx5_devx_cmd_destroy(sh->td)); + mlx5_rxtx_uars_release(sh); i = 0; do { if (sh->tis[i]) claim_zero(mlx5_devx_cmd_destroy(sh->tis[i])); } while (++i < (uint32_t)sh->bond.n_port); - mlx5_rxtx_uars_release(sh); + if (sh->td) + claim_zero(mlx5_devx_cmd_destroy(sh->td)); mlx5_free(sh); - MLX5_ASSERT(err > 0); rte_errno = err; return NULL; } diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 7bb4c4590a..f5e3893ed4 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -372,7 +372,7 @@ mlx5_flow_os_init_workspace_once(void) if (err) { DRV_LOG(ERR, "Can't create flow workspace data thread key."); - return err; + return -rte_errno; } pthread_mutex_init(&lock_thread_list, NULL); return 0; diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 8eb53f2cb7..d31de6a5e8 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -152,7 +152,7 @@ mlx5_init_once(void) * Pointer to mlx5 device attributes. * * @return - * 0 on success, non zero error number otherwise. + * 0 on success, a negative errno value otherwise and rte_errno is set. */ int mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, @@ -161,10 +161,11 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, struct mlx5_context *mlx5_ctx; void *pv_iseg = NULL; u32 cb_iseg = 0; - int err = 0; - if (!cdev || !cdev->ctx) - return -EINVAL; + if (!cdev || !cdev->ctx) { + rte_errno = EINVAL; + return -rte_errno; + } mlx5_ctx = (struct mlx5_context *)cdev->ctx; memset(device_attr, 0, sizeof(*device_attr)); device_attr->max_cq = 1 << cdev->config.hca_attr.log_max_cq; @@ -187,15 +188,14 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev, pv_iseg = mlx5_glue->query_hca_iseg(mlx5_ctx, &cb_iseg); if (pv_iseg == NULL) { DRV_LOG(ERR, "Failed to get device hca_iseg"); - return errno; - } - if (!err) { - snprintf(device_attr->fw_ver, 64, "%x.%x.%04x", - MLX5_GET(initial_seg, pv_iseg, fw_rev_major), - MLX5_GET(initial_seg, pv_iseg, fw_rev_minor), - MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor)); + rte_errno = errno; + return -rte_errno; } - return err; + snprintf(device_attr->fw_ver, 64, "%x.%x.%04x", + MLX5_GET(initial_seg, pv_iseg, fw_rev_major), + MLX5_GET(initial_seg, pv_iseg, fw_rev_minor), + MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor)); + return 0; } /** -- 2.25.1