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 BC9D2A00C4; Mon, 14 Feb 2022 10:37:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85C9A426EC; Mon, 14 Feb 2022 10:36:14 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by mails.dpdk.org (Postfix) with ESMTP id 4B08041176; Mon, 14 Feb 2022 10:36:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UyKWk5Mi+v4Rs5ZSYWdyS9j7+pD1TC27t7H63t4F8a9PBWaYu1HNUB61Qj2028hQvptvIO1Jc2GP9t9ziJBs5cEru2C0Xptqg82dk1VPIxI4Dpe7EuzoWph8xJWaQ5aWzEuPCRMyxc14uJ26br0IgLaMlARvvM1GFgSxCEKUf6dh6AxMet/lu2/VyCjgo4RlsbDa4PnyPvEa4ab/UnwEI00QOf1ca0Dkn3xG9iUW3aJ/Uu+fOZpNMS/Hqu7OwArDwWe7mN3kSxCcv+ch5sKM3iFj80DdmiKIMfPv72M1KqPYicVM0hy8g4WPKTT1dQP3QP5ZELvQ8tt34rnAHTxguw== 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=n+NV5KIM34h2UIWmkOJ8LvWyfdgOaZnaDi00584OSC0=; b=MBlwqS4+1ZYjYDT8R7Rn/WH2/Ha33H/82OrdBvQ1RfSyptLrHD1UjoyTvCpFhWiVmewbO16/FLNmyUtV+3RPDHKLa1G2Jihvz42KmCpX86lg1kn/FEDlPHTXcWwyHLGhIKwT6qzI0rcAQotUb//kKLhExxEjhMVTgLw1I9cCzNVO1ikwwE7SMXzXTvOyq8WoWWG8cy6mN1z8yzu4u7sE1VJNBGco94hgIVLDqgq0ZyEgtkNJRNQE4vynJVNQfrD4oFPEtyb/8rTI6aQu9iAditmNe4f4J3H7tFB3eV+Y0KaK8yIpOtcna1S0np708xrL6wuReRnX+I8sbD3st/pf4Q== 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=n+NV5KIM34h2UIWmkOJ8LvWyfdgOaZnaDi00584OSC0=; b=g2EsIUefOGZF7gayRa7h5rk+4qyaKqo9xElIoLYYfrNUTr4vqlJ1YUWKDNCCzecbnKHxOOXyR+iudGeCF5svms12u96NPNQrP89Bz2Q9TLJFMi0OtxdH2bAy7ThumfiWs1kmLBYFPSYNA5osLS9xANmKK9s8yJnlnqkT8nWUe7Gum5bOnS+G8sl5Tx6foOcmzBQBw63B78Bq3zozXfE0ESjWYDyG43y3UBLX+7G0Rb1qJfVfhyvtK0XP0oqgD7G8MKG94ZK4KAta3Xc2QlHx/ag9vOUryoNFx2YFxiP7R4IJD1RanKhw8OJA2W0BVmbzIkJ7OdYpD92T8/IlOBVg5w== Received: from BN9PR03CA0910.namprd03.prod.outlook.com (2603:10b6:408:107::15) by DM6PR12MB4355.namprd12.prod.outlook.com (2603:10b6:5:2a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17; Mon, 14 Feb 2022 09:36:10 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::d6) by BN9PR03CA0910.outlook.office365.com (2603:10b6:408:107::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 09:36:10 +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 BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 09:36:09 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 09:35:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 14 Feb 2022 01:35:31 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Mon, 14 Feb 2022 01:35:29 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Subject: [PATCH v2 04/20] net/mlx5: fix inconsistency errno update in SH creation Date: Mon, 14 Feb 2022 11:34:55 +0200 Message-ID: <20220214093511.1592698-5-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220214093511.1592698-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> <20220214093511.1592698-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: f8710f3d-db01-4df7-77a8-08d9ef9d6f12 X-MS-TrafficTypeDiagnostic: DM6PR12MB4355: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: /Li/H77nW8nunlHHCOXE7Cu0c8zNUwmImyI6Y1tpNhRkxm2t4Xf4mC5QhHpy5uAO0x7/E3XMX1yzB2QijKuxo5GG8jL+vIWl0bpj7iSBjV24tLO4jbu+UVuEzlXXk/mTrveXepVVJvpa2BBEWVjFq6EyF9ngv9leiM/kxbTnV3xCYipfIYwNGC9o6zAZM94Efxc5MsVgsFEEzgY25PZs+Hk3Tcs1xd6pGIDoaaHDw+k3MByBif2B8RJ6RAueU7CTVO1R6gNa1OCL6nuXeyJBbweI2eAITuRluSap+UOCb9RVPevTuiiVMwgrWCzCgXAzFvl6EljRPf1nDqJuBsDZasXrj0KHhHZL/daTENBVsHOrBq2kGE9rnTb2z7/TXyirTf4eOlzcTZd0TE5A4bung9M8KqcqWDTOZGUwOkWbmjO1RGc17Np2UjMmycuOOG3Y8cwXt9jMEN9nr4hpeE3LkNw8fFPlie3h8JYEeWbi0ixrdJ9gDBvuz8UAHPDmhkOK537ashLplczOH9195cXNaMDFLwE1mhwh8ddbUSNCXFeyt23BLARMr7eha10rwfdXMVNLnx9SuW8Vd16ZmQ5GwRx7yYvOf0g7qAiste8DnigsT+s/FRDHMfA+8CTMm6ENYCS7CGQ/vxn11CGkxW2kTvXWczBJXZxL+g4uc0/wJXqbmQXTvmaJ7AND2t1v5yUsABO9fOkYn9DgYjD1FaoMhQ== 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:(13230001)(4636009)(46966006)(36840700001)(40470700004)(36756003)(2906002)(6666004)(508600001)(15650500001)(36860700001)(55016003)(5660300002)(7696005)(6286002)(54906003)(6916009)(26005)(316002)(47076005)(336012)(356005)(1076003)(426003)(40460700003)(81166007)(70586007)(70206006)(4326008)(83380400001)(2616005)(86362001)(82310400004)(186003)(8936002)(450100002)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 09:36:09.9677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8710f3d-db01-4df7-77a8-08d9ef9d6f12 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: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4355 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 69d3e1e3ad..faab310b11 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 cde8d022cd..0e154b88ed 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 3db33cd0cf..a9619e5bda 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