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 0A471A0524; Wed, 5 May 2021 09:20:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDC9241131; Wed, 5 May 2021 09:19:55 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) by mails.dpdk.org (Postfix) with ESMTP id CF84A410F3 for ; Wed, 5 May 2021 09:19:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sd1/p2rD2307kEimIO7Ce8BZe5sUi1B/Rythdb9clZkzFS1RGjfk4aGCFMp08qxppet0Q9Jo71Cn2mHDIzuzyFDuLeQijFRGo+UrPr6rD67N447rHhUfK6moc/BXBENbIbPPJsi8iCt/OLQ4pvoTwlzGP3aQsP7PC9+2jxTyquaXmrlLJe34mXZxMZ9aFJaQ/5a0AfJs2gwykF0h9smnc5gyJo9zfLtg9wcVPl++1oamI5xa5F+EGxxEhvNLg+xgFGLa2nMlgAJi6q3fFtzKdO69K8tJ6DGFWeIXoitOYOA16/reP7/5a7NlwH3ub4U+ecm0iD7XKNK/6iove4iIyw== 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-SenderADCheck; bh=z+r14AzkxTe9cKCzjkckKU0FYt9Bu1R+ILwPKWW5yrk=; b=PGPqV5+Sz6XkWyd+95XFLwf+OjehogoRSOIAjFWZzKLkP/dwkRXecpogEH9j3PYleiF0jYJIyTKmLqd9RdvlWK6UePMIcKDeSCsGPsnkqcn5yqXYrO91PmjBcZo/DupREZojQfSkA9zR7TFu+TOms6bZX7EmMaZE3nuhkJ0dff5oyd3zPEkWwWzq+y97WnWuohrIqpnTIu7W0Fc2nR+AIgA0wGk9ccTjGws2L5NJQvTmUvqAEBKHIoBM2G5XqsRNKG0c7IW1lQ4r6gGLrS45ume4NfU2XfB1E2r0MS5cRXJgBdgEwJFue6K4X9WqEpH+7O/vtPYDDoQdaQGtLuok7A== 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=none sp=none 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=z+r14AzkxTe9cKCzjkckKU0FYt9Bu1R+ILwPKWW5yrk=; b=ZSdo+mkIs96jt7Jt6CceEvzzGmIol5B39Gkc7p0n8TmPRMLhOqsdgQpoMcdwXhVTBiQNRNZB7HN9ZYKgN9VyRcCADa80xakrOKfN08TkWRVQNIfQtNloYo4P+cNNIpFoExzMdHNeCnrQHDUmT+JNgP2aq3a0Z5A4sZmW69mWdfQO5SErdESg+wjw+8yZICnQBpBWptFaZrJ7frgoT5U9Wfp6YA+RDXGvF4sgdBdxVUnZ05hLOICm2tSlwUjxbXSCfEieKnMMf/aI9hhbY97bt6nAKRuuJarW1vmnjSb7V3OI5BDekXMzqX7V9Xy7+pYhAPu+5oq+dPgkLgNUXrEJFw== Received: from DM6PR02CA0165.namprd02.prod.outlook.com (2603:10b6:5:332::32) by BN6PR12MB1123.namprd12.prod.outlook.com (2603:10b6:404:1b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.43; Wed, 5 May 2021 07:19:50 +0000 Received: from DM6NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::82) by DM6PR02CA0165.outlook.office365.com (2603:10b6:5:332::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:19:50 +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 DM6NAM11FT011.mail.protection.outlook.com (10.13.172.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 07:19:50 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 May 2021 07:19:48 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 10:19:08 +0300 Message-ID: <20210505071917.31802-9-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505071917.31802-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505071917.31802-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48ae753e-241f-47b0-31a8-08d90f962bcb X-MS-TrafficTypeDiagnostic: BN6PR12MB1123: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OBjOUTux57cFrjkshemot8q8Lc95wbvJefN8RHUD9qjmjVtkcXyTLmltt+v9eEUPivDT8W1GPfxvF2sMQODPmVCpQx5tCwyDvLcZVEXUXRWUnmccDplt4zYhQfcSiK9Slgj9pC5CwpMTuIQdZKFqCh/kUv9uv4ed+hclBbQo33eENasrOYvkzmwiJo0lH5IdSzSjlKHXD0j0G4MklqTfFYf4GMaX3O294DGLWZIWFVpENbT7fRHORpbjrxck1zZgZnoCeBAsRmUxVoEicoSWB+NK6aPW2qBaSGxGJJ+nn5PdPtzyrMY19VM4UlOl84lEz1OwpeoZrM04uyYNzpJZR6Jug0X11KKLuL/sfo9h4fm2M/H7OKmYi2gvRT5D8FvUiyyja5Ae8GatbtnVqnMhG0f8V5SsKyhuxbcM1u2kPUvApdvSZl4WxLliuQ9HKn6ooV2Z54kgkLZPjq6Q9ZWzdG6Z26OaGRNjRXV5iUEA9l/0cfXoK17VXvMcsrHKSNh0ClOHbAK8A3M7DQFTaL6CXdhQ5s1ik3dTR/EuPmEZRzOHk8wlIWIlwUpnBPRX4JsXq5/5C6LT0uV++UbFQ5oJHj28WWkiKweGEcVccaLZ6TXzUfZGtYrK6l65P+0L6w1od+IffpiIsWB17JxTFlnNaNXUSfyxuhKGeJ6R+6jzFY0= 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)(39860400002)(346002)(376002)(136003)(396003)(46966006)(36840700001)(6286002)(426003)(5660300002)(36756003)(36906005)(8676002)(1076003)(36860700001)(47076005)(2616005)(4326008)(107886003)(7696005)(356005)(83380400001)(6666004)(55016002)(316002)(336012)(82740400003)(86362001)(26005)(186003)(16526019)(8936002)(82310400003)(70586007)(478600001)(70206006)(54906003)(2906002)(110136005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:19:50.2654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48ae753e-241f-47b0-31a8-08d90f962bcb 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: DM6NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1123 Subject: [dpdk-dev] [PATCH v4 08/17] net/mlx5: close CT management structure 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" When freeing the IB shared context during stopping a device, the ASO connection tracking management structure should also be cleaned up. All the DR actions created should be destroyed. The structures need to be freed and ASO CT QP should be released. In the meanwhile, the allocated and registered memory region for query should also be deregistered and then freed. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5.c | 56 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_aso.c | 4 +++ 2 files changed, 60 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 86dbe6d573..d563da109a 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -706,6 +706,60 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh) return 0; } +/* + * Close and release all the resources of the + * ASO connection tracking management structure. + * + * @param[in] sh + * Pointer to mlx5_dev_ctx_shared object to free. + */ +static void +mlx5_flow_aso_ct_mng_close(struct mlx5_dev_ctx_shared *sh) +{ + struct mlx5_aso_ct_pools_mng *mng = sh->ct_mng; + struct mlx5_aso_ct_pool *ct_pool; + struct mlx5_aso_ct_action *ct; + uint32_t idx; + uint32_t val; + uint32_t cnt; + int i; + + mlx5_aso_queue_uninit(sh, ASO_OPC_MOD_CONNECTION_TRACKING); + idx = mng->next; + while (idx--) { + cnt = 0; + ct_pool = mng->pools[idx]; + for (i = 0; i < MLX5_ASO_CT_ACTIONS_PER_POOL; i++) { + ct = &ct_pool->actions[i]; + val = __atomic_fetch_sub(&ct->refcnt, 1, + __ATOMIC_RELAXED); + MLX5_ASSERT(val == 1); + if (val > 1) + cnt++; +#ifdef HAVE_MLX5_DR_ACTION_ASO_CT + if (ct->dr_action_orig) + claim_zero(mlx5_glue->destroy_flow_action + (ct->dr_action_orig)); + if (ct->dr_action_rply) + claim_zero(mlx5_glue->destroy_flow_action + (ct->dr_action_rply)); +#endif + } + claim_zero(mlx5_devx_cmd_destroy(ct_pool->devx_obj)); + if (cnt) { + DRV_LOG(DEBUG, "%u ASO CT objects are being used in the pool %u", + cnt, i); + } + mlx5_free(ct_pool); + /* in case of failure. */ + mng->next--; + } + mlx5_free(mng->pools); + mlx5_free(mng); + /* Management structure must be cleared to 0s during allocation. */ + sh->ct_mng = NULL; +} + /** * Initialize the flow resources' indexed mempool. * @@ -1508,6 +1562,8 @@ mlx5_dev_close(struct rte_eth_dev *dev) if (priv->mreg_cp_tbl) mlx5_hlist_destroy(priv->mreg_cp_tbl); mlx5_mprq_free_mp(dev); + if (priv->sh->ct_mng) + mlx5_flow_aso_ct_mng_close(priv->sh); mlx5_os_free_shared_dr(priv); if (priv->rss_conf.rss_key != NULL) mlx5_free(priv->rss_conf.rss_key); diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c index 0ff19e6171..3c2350a6b8 100644 --- a/drivers/net/mlx5/mlx5_flow_aso.c +++ b/drivers/net/mlx5/mlx5_flow_aso.c @@ -372,6 +372,10 @@ mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh, case ASO_OPC_MOD_POLICER: sq = &sh->mtrmng->pools_mng.sq; break; + case ASO_OPC_MOD_CONNECTION_TRACKING: + mlx5_aso_dereg_mr(sh, &sh->ct_mng->aso_sq.mr); + sq = &sh->ct_mng->aso_sq; + break; default: DRV_LOG(ERR, "Unknown ASO operation mode"); return; -- 2.27.0