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 60E49A0524; Wed, 5 May 2021 08:42:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED1E9410EE; Wed, 5 May 2021 08:42:31 +0200 (CEST) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750047.outbound.protection.outlook.com [40.107.75.47]) by mails.dpdk.org (Postfix) with ESMTP id 54CFD410E1 for ; Wed, 5 May 2021 08:42:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P881RFn6ZKT0D23PQqCH4KxmOZVxv70aD7uvhJkmNjShuR7godCz70L548VK6zUKrdKx50YFDa2DMmpn0oUBd8CEPg11xA2Uy7N3LAZMt7e+sFOLdT651t/KRumhYZ+IevwqFKIPpjQpIS9ss0P2U/MDjEpjRGgZiv56rFcuK+AdvuGePElmDRA8EQxiKl6jusgSs3J37p/rRC2GQ0rNmF1JUELGBHijUGhlqJv29PpGP+EQ1d3bdjfE9YzQtGtMJ2Pp8uyKwA+i9W+Mm+/P5S6i3IwKfXTqZblwedomS78fUDUPVGpkyJ4z5BjNV3j7xKNP7O3eWIS3VbCf9Dc0Pw== 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=oXc9ye9ZIhQu5cM+mQpCKM45CIorUabT7pDc4VTreVyRORkrp0pA4+njO0DdKi9jl8TvUx3LuBZhpi2uQppD8NnHK85K+O76wY6IM8/Pej97DwvH0aW6D/2jWs7haWn0V1WBIzcr6AjUJ64BWHVq5yeREti9uqwiyoNpSHs+slQBQ69jzgzLrPzEyvrqfmAZThSFFwxBE3ZZmPweCJIfHItvMmsrfbvn0eYOAM7qIurskLch+FmxABpso4c1wO94rfuEZhW8ZEJDJZhXonAXSm2XgWvR6oFLvALYafQ/UAJe/iiSsw0ygG71dmaz8gJgRIachO/RPQ60ZtOe7JfwdQ== 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=UGfr/rBASlGOMEU8UY5R9vmelmq5o8WujakTEEgIMYIU1pFU2fzPU0BCWWp1fc4m6Y5J8dAAUlzgWv/3zRzyG9SxD1CmFVX06tDHRBJ5rvNIEpc2gaOB7KL/IJfSvqzBTy6Qyl5Zj5aMrd7n1lOeF7BgjR1daL3SE4qF+NZVPTNhAxFJAc2tZOmJi0LLyuHaULZDzwGUonlzm8H9Kyi0V5NRyFumu0EtegAibdqw2rmRDKoJLbX1OhVe8Mua5aRnlA8PK7u155CoKLYpnF4kFvRZfh1WswFyy7EuFiih7mjJ3fOhpTUVtkUtTMDu7IHZWIQ2HKS52tX2t1x+22Ze9g== Received: from DM5PR10CA0017.namprd10.prod.outlook.com (2603:10b6:4:2::27) by BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Wed, 5 May 2021 06:42:28 +0000 Received: from DM6NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:4:2:cafe::db) by DM5PR10CA0017.outlook.office365.com (2603:10b6:4:2::27) 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 06:42:28 +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 DM6NAM11FT022.mail.protection.outlook.com (10.13.172.210) 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 06:42:28 +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 06:42:22 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 09:40:55 +0300 Message-ID: <20210505064104.30248-9-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505064104.30248-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505064104.30248-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: 90b69c92-6f3c-4d45-23c0-08d90f90f3be X-MS-TrafficTypeDiagnostic: BN8PR12MB3108: 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: u5QnTU681xrZUiJmeHCVNDlUvFoVRO2bnuTk+00sAvVSEycu5ScGaLRq5tRto8SaBVhc+3/dIgF+5ae1BRVSjVwJ+L52sWs+OIwugCoskush0zxQrm99e0l6pFAZrVsZX1IMl0M3iAFH7z/2wrEn51spp6OFUkw2TPBOpDMhNQizXUrmn7ns+Yx9uqn3ekV0zmUOhcGkUAyTOCmJKZkANGm7AC0QmZUlacXBbwG6D5bNKGu7PP32YWfaT8YFPpcfx+Onr2Twh1C1Rw5JGsV1ULQ5pzyN8QvuoPPYOnsb6rZ8PYUyHq8aU0DmmzL1bqgV+FOnPDRjIWB2offcwHl08jDOGQL2CV8ktg/trryCGVX7TpV9r4P1wk+uKNSTj/6dAUJ4sbX1pvaGiQznfp2IP4luAYkHxk127fabtpN0CZJWp4F/gLD/d2uE0XpDGr5DJ4+dpSHrYeYoiBYSm3R40sxWpzgr37ibI3Fm4idVbxZIVZoOfcUj2ieew+o9L8kfOKp9j1AwY/Qeruq5F5g4mrPgf7WB33lV6mdLEwcvep2G781mWH3sN0C6fxmRNvVujIlNYION8MqG7PNTQ/+EAJJIoryKFQffTDnr3I7T9qeJRdIZhf6gMqJx05zCwwTfZVKFztN2YpKFksP13vIlc478rpDF06IYpLp/dj//ark= 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)(376002)(346002)(396003)(136003)(36840700001)(46966006)(4326008)(8676002)(83380400001)(47076005)(26005)(110136005)(316002)(2616005)(478600001)(82740400003)(36756003)(54906003)(356005)(36906005)(5660300002)(16526019)(86362001)(7696005)(55016002)(7636003)(186003)(2906002)(70206006)(82310400003)(6666004)(426003)(36860700001)(107886003)(336012)(8936002)(1076003)(6286002)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 06:42:28.7578 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90b69c92-6f3c-4d45-23c0-08d90f90f3be 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: DM6NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3108 Subject: [dpdk-dev] [PATCH v3 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