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 DFB3EA0547 for ; Mon, 22 Nov 2021 15:17:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF8164114B; Mon, 22 Nov 2021 15:17:53 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2043.outbound.protection.outlook.com [40.107.102.43]) by mails.dpdk.org (Postfix) with ESMTP id 908C74003C; Mon, 22 Nov 2021 15:17:51 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f9cIQZjtYbTDNPnjgXmnUUcOAtR0FEkyxEKLnxmYS9V6WgJomIBGV6VduEe7+rJEXYi7+e78axjNvTL4qYP7ca8umSGK7xBlYmJ4pqRaxTcYeDxdUqB4Da/RJiK1XLtGZG1nLIZYO+cc2vQRP+Eh/IpPgi2uNZvBQjSIU4/bINQd8UYf5FVVF/yOxRDYH91T71nW4x6tUNTzfxpOMbogQlBeecaczNTYp9ba93/qZ85cxdcnt1sntn2JaU0SW42YxB9OxW+8RXBiFj0sKt6VJpBKd7F9yiYCYjqTnH5aPxAQtEYI4+Z/Tng2X4nTIX6NBwpNi0l/GeSx6eIsaToVFA== 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=fKvv3RcPIpRcljz1mTc5+/ThEwuyoO+iBKXQGyM8j0o=; b=HSIFSKJ7sXYCn+ALzdNQxArLBmJ0fuRk9IKeBbfFFv2cZlHsSH0nA91d3Rxkt9LmVTCrepah7CCC2ydEYYPKOyIzktTXDAo6gwK/KOpbo7UKBsOJRCmNU+8wFYPPqOCnKm1rgFhjdzy8/O2Spzwrlp2VC3dQ10V7ye+ckG5t1WPvn7HB4PWvczwJ6z1bf+u0PDNoroIR11b/BJ9X0carGci053/sceKxXntHy083rYHWimNMRBvql/D3lUPe0krxWAiWnGxISOsq9/Y8/4h7fftdkExQQJTYg9VDpT554ijDJqRko9d0Cn3XRFG3bbejujBl0nYo8l2QVyvkfmIZww== 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=fKvv3RcPIpRcljz1mTc5+/ThEwuyoO+iBKXQGyM8j0o=; b=ZTksgKV9FBFDnpwZFrWw8sXZq2WDaiSGzO0YZBug1G4Zfsw8SlBDEm8GaIUJqFiRPP7VaugVin4CBUIVPVK9n8cVjtH8WHu0JQwjF3s5+oG9F72dgQihhhk9VM9idhH91GIHFIuUd5PNR6G1Sf4DgVfq6Sux1SM0ta4SvejY7hst9pxLpsl85hO61Gyd6TrNHcW1pO6BxfX5RDvNF2oVsMC6fnR4r9rPOd5yphXlJ2pjNeqM8LznmlLz84vk6HcLQyYEp9+7we7A8V9x7WEpv26Jh6zn5WaIoHqTJbvaurKrRe0AUiDLyMDdmVSJ0hiHvv2YRd351BuvrGBh6sD5BQ== Received: from DM5PR18CA0077.namprd18.prod.outlook.com (2603:10b6:3:3::15) by DM6PR12MB4577.namprd12.prod.outlook.com (2603:10b6:5:2aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Mon, 22 Nov 2021 14:17:48 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:3:3:cafe::9b) by DM5PR18CA0077.outlook.office365.com (2603:10b6:3:3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Mon, 22 Nov 2021 14:17:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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 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 DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Mon, 22 Nov 2021 14:17:47 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 22 Nov 2021 14:17:44 +0000 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Dmitry Kozlyuk CC: Raslan Darawsheh , , Subject: [PATCH v2] net/mlx5: fix refcount on detached indirect action Date: Mon, 22 Nov 2021 16:17:07 +0200 Message-ID: <20211122141708.61680-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117154605.112390-1-dsosnowski@nvidia.com> References: <20211117154605.112390-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3bd3e1e-c405-4b92-4a9f-08d9adc2dc44 X-MS-TrafficTypeDiagnostic: DM6PR12MB4577: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:257; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LW9uaJt/MeyQXqE6hD6JvPxIvHr0mgcCq4b323x5YQfHNSwuqOfEy0Bbf9wSdoGiMYuSQ8TbS987FHt0wPp2Q3Caj4nKEBxwiHqoAHcdX3t6Qn0Pc3OIxF4RhwUHg3kot7gpl2OegbKXZ6t3rd1DMHHdzy+79ddIVxOoINBFhH6rUeUQbJ7n/pjIqFjApTUHWix7+Wn29xkgkiGbDd0xwgfkPF5E1PQ44e2Ih1Ndnit9pbDOgBKkfIblP5qO8X3jQSHd7zSpT2FE8pi2eYcHg7FEf+5SNA4y0GPiHCzc/nOag0UXb/CKs70HNzZF1zA8P5SqkaHJW2432EsW+DaQBoEdTMG+QuyBNMuzwtm7zffc47UA9R5eBHCPL95jTEwe2PI25rFFxauiC/y4JL+Q1vK0NGXVVgBU1VM4binLp69wZKmmqGKbQ54b5qmVbi9rQDno8v3vWccXwqNqHILKtIERAqF7tsgcExv/oLG8ygqxSlHJ14/2iTA1q72puNBg4F/ykip1HSikWAjvdMXpDp5cSLZyLvUChJmvQI11qNhmHorlVfn1s4/OzQuwxEFTNgq8pLvbLzcGOQoSJyyRUeHThXqnTI+jLGgxJu4OnDJGD4EjdqhC2JoPuXOsCZb/CQaPK+Kb9XYwNxOiwvBII0Yge8VprXpIqSJUR33pCwIK8mTX8WKenTDDf6VY5tYd4SQ6umxtf2HaniP9lNifTg== 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)(36840700001)(46966006)(426003)(316002)(36906005)(508600001)(6286002)(450100002)(83380400001)(336012)(26005)(4326008)(16526019)(36860700001)(47076005)(1076003)(186003)(36756003)(356005)(7636003)(6666004)(5660300002)(2906002)(6636002)(8936002)(8676002)(7696005)(55016002)(54906003)(110136005)(82310400003)(86362001)(70586007)(2616005)(70206006)(30864003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 14:17:47.9300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3bd3e1e-c405-4b92-4a9f-08d9adc2dc44 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4577 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org This patch fixes segfault which was triggered when port, with indirect actions created, was closed. Segfault was occurring only when RTE_LIBRTE_MLX5_DEBUG was defined. It was caused by redundant decrement of RX queues refcount: - refcount was decremented when port was stopped and indirect actions were detached from RX queues (port stop), - refcount was decremented when indirect actions objects were destroyed (port close or destroying of indirect action). This patch fixes behavior. Dereferencing RX queues is done if and only if indirect action is explicitly destroyed by the user or detached on port stop. Dereferencing RX queues on action destroy operation depends on an argument to the wrapper of indirect action destroy operation, introduced in this patch. Fixes: ec4e11d41d12 ("net/mlx5: preserve indirect actions on restart") Cc: dkozlyuk@nvidia.com Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_flow.c | 43 +++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 15 +++++++++--- drivers/net/mlx5/mlx5_rx.h | 3 ++- drivers/net/mlx5/mlx5_rxq.c | 21 ++++++++++------ 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 43598f92ee..fb4ec2d8da 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -8644,6 +8644,27 @@ flow_drv_action_validate(struct rte_eth_dev *dev, return fops->action_validate(dev, conf, action, error); } +/* Wrapper for driver action_destroy op callback */ +static int +flow_drv_action_destroy(struct rte_eth_dev *dev, + struct rte_flow_action_handle *handle, + bool deref_qs, + struct rte_flow_error *error) +{ + static const char err_msg[] = "indirect action destruction unsupported"; + struct rte_flow_attr attr = { .transfer = 0 }; + const struct mlx5_flow_driver_ops *fops = + flow_get_drv_ops(flow_get_drv_type(dev, &attr)); + + if (!fops->action_destroy) { + DRV_LOG(ERR, "port %u %s.", dev->data->port_id, err_msg); + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, + NULL, err_msg); + return -rte_errno; + } + return fops->action_destroy(dev, handle, deref_qs, error); +} + /** * Destroys the shared action by handle. * @@ -8665,21 +8686,10 @@ mlx5_action_handle_destroy(struct rte_eth_dev *dev, struct rte_flow_action_handle *handle, struct rte_flow_error *error) { - static const char err_msg[] = "indirect action destruction unsupported"; - struct rte_flow_attr attr = { .transfer = 0 }; - const struct mlx5_flow_driver_ops *fops = - flow_get_drv_ops(flow_get_drv_type(dev, &attr)); - - if (!fops->action_destroy) { - DRV_LOG(ERR, "port %u %s.", dev->data->port_id, err_msg); - rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, - NULL, err_msg); - return -rte_errno; - } - return fops->action_destroy(dev, handle, error); + return flow_drv_action_destroy(dev, handle, true, error); } -/* Wrapper for driver action_destroy op callback */ +/* Wrapper for driver action_update op callback */ static int flow_drv_action_update(struct rte_eth_dev *dev, struct rte_flow_action_handle *handle, @@ -8698,7 +8708,7 @@ flow_drv_action_update(struct rte_eth_dev *dev, return fops->action_update(dev, handle, update, error); } -/* Wrapper for driver action_destroy op callback */ +/* Wrapper for driver action_query op callback */ static int flow_drv_action_query(struct rte_eth_dev *dev, const struct rte_flow_action_handle *handle, @@ -8850,8 +8860,9 @@ mlx5_action_handle_flush(struct rte_eth_dev *dev) ILIST_FOREACH(priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS], priv->rss_shared_actions, idx, shared_rss, next) { - ret |= mlx5_action_handle_destroy(dev, - (struct rte_flow_action_handle *)(uintptr_t)idx, &error); + ret |= flow_drv_action_destroy(dev, + (struct rte_flow_action_handle *)(uintptr_t)idx, false, + &error); } return ret; } diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 1de2f2edb0..71ee513951 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1199,6 +1199,7 @@ typedef struct rte_flow_action_handle *(*mlx5_flow_action_create_t) typedef int (*mlx5_flow_action_destroy_t) (struct rte_eth_dev *dev, struct rte_flow_action_handle *action, + bool deref_qs, struct rte_flow_error *error); typedef int (*mlx5_flow_action_update_t) (struct rte_eth_dev *dev, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 2f03e59f9c..b0d59b94ca 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -14732,7 +14732,7 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev, error_hrxq_new: err = rte_errno; __flow_dv_action_rss_hrxqs_release(dev, shared_rss); - if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true)) + if (!mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true, true)) shared_rss->ind_tbl = NULL; rte_errno = err; return -rte_errno; @@ -14839,6 +14839,9 @@ __flow_dv_action_rss_create(struct rte_eth_dev *dev, * Pointer to the Ethernet device structure. * @param[in] idx * The shared RSS action object ID to be removed. + * @param[in] deref_rxqs + * If true, then dereference any RX queues related to shared RSS action. + * Otherwise, no additional action will be taken. * @param[out] error * Perform verbose error reporting if not NULL. Initialized in case of * error only. @@ -14848,6 +14851,7 @@ __flow_dv_action_rss_create(struct rte_eth_dev *dev, */ static int __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx, + bool deref_rxqs, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -14875,7 +14879,8 @@ __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx, NULL, "shared rss hrxq has references"); queue = shared_rss->ind_tbl->queues; - remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true); + remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true, + deref_rxqs); if (remaining) return rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_ACTION, @@ -14977,6 +14982,9 @@ flow_dv_action_create(struct rte_eth_dev *dev, * @param[out] error * Perform verbose error reporting if not NULL. Initialized in case of * error only. + * @param[in] deref_qs + * If true, then dereference any queues related to the shared action object. + * Otherwise, no additional action will be taken. * * @return * 0 on success, otherwise negative errno value. @@ -14984,6 +14992,7 @@ flow_dv_action_create(struct rte_eth_dev *dev, static int flow_dv_action_destroy(struct rte_eth_dev *dev, struct rte_flow_action_handle *handle, + bool deref_qs, struct rte_flow_error *error) { uint32_t act_idx = (uint32_t)(uintptr_t)handle; @@ -14995,7 +15004,7 @@ flow_dv_action_destroy(struct rte_eth_dev *dev, switch (type) { case MLX5_INDIRECT_ACTION_TYPE_RSS: - return __flow_dv_action_rss_release(dev, idx, error); + return __flow_dv_action_rss_release(dev, idx, deref_qs, error); case MLX5_INDIRECT_ACTION_TYPE_COUNT: cnt = flow_dv_counter_get_by_idx(dev, idx, NULL); if (!__atomic_compare_exchange_n(&cnt->shared_info.refcnt, diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 9cc1a2703b..b19464bb37 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -225,7 +225,8 @@ struct mlx5_ind_table_obj *mlx5_ind_table_obj_get(struct rte_eth_dev *dev, uint32_t queues_n); int mlx5_ind_table_obj_release(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl, - bool standalone); + bool standalone, + bool deref_rxqs); int mlx5_ind_table_obj_setup(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl); int mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 480f4f9f07..1f6ddbab8b 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2195,6 +2195,9 @@ mlx5_ind_table_obj_get(struct rte_eth_dev *dev, const uint16_t *queues, * Indirection table to release. * @param standalone * Indirection table for Standalone queue. + * @param deref_rxqs + * If true, then dereference RX queues related to indirection table. + * Otherwise, no additional action will be taken. * * @return * 1 while a reference on it exists, 0 when freed. @@ -2202,7 +2205,8 @@ mlx5_ind_table_obj_get(struct rte_eth_dev *dev, const uint16_t *queues, int mlx5_ind_table_obj_release(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl, - bool standalone) + bool standalone, + bool deref_rxqs) { struct mlx5_priv *priv = dev->data->dev_private; unsigned int i, ret; @@ -2215,8 +2219,10 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev, if (ret) return 1; priv->obj_ops.ind_table_destroy(ind_tbl); - for (i = 0; i != ind_tbl->queues_n; ++i) - claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i])); + if (deref_rxqs) { + for (i = 0; i != ind_tbl->queues_n; ++i) + claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i])); + } mlx5_free(ind_tbl); return 0; } @@ -2573,7 +2579,7 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx, if (ind_tbl != hrxq->ind_table) { MLX5_ASSERT(!hrxq->standalone); mlx5_ind_table_obj_release(dev, hrxq->ind_table, - hrxq->standalone); + hrxq->standalone, true); hrxq->ind_table = ind_tbl; } hrxq->hash_fields = hash_fields; @@ -2583,7 +2589,8 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx, err = rte_errno; if (ind_tbl != hrxq->ind_table) { MLX5_ASSERT(!hrxq->standalone); - mlx5_ind_table_obj_release(dev, ind_tbl, hrxq->standalone); + mlx5_ind_table_obj_release(dev, ind_tbl, hrxq->standalone, + true); } rte_errno = err; return -rte_errno; @@ -2600,7 +2607,7 @@ __mlx5_hrxq_remove(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq) priv->obj_ops.hrxq_destroy(hrxq); if (!hrxq->standalone) { mlx5_ind_table_obj_release(dev, hrxq->ind_table, - hrxq->standalone); + hrxq->standalone, true); } mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_HRXQ], hrxq->idx); } @@ -2666,7 +2673,7 @@ __mlx5_hrxq_create(struct rte_eth_dev *dev, return hrxq; error: if (!rss_desc->ind_tbl) - mlx5_ind_table_obj_release(dev, ind_tbl, standalone); + mlx5_ind_table_obj_release(dev, ind_tbl, standalone, true); if (hrxq) mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_HRXQ], hrxq_idx); return NULL; -- 2.25.1