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 5C6A8A0524; Wed, 5 May 2021 10:07:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1689E4112D; Wed, 5 May 2021 10:06:45 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2081.outbound.protection.outlook.com [40.107.237.81]) by mails.dpdk.org (Postfix) with ESMTP id CE7AF41114 for ; Wed, 5 May 2021 10:06:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l/CBsZeu5Ky0S71jGDIKoKlYhetSDjzXU9otpphQSli0BH2cNFauZN4b4WQpy2Xxe0TIz6H49KWBKB/PgrNIXOhgDKQEn9tJqX+mz51AIMRWXZuXEKG9N9P0dx4XrBips/xNxASNLZS1QIXpqLkKZtEyp1YBBWSkZZOIm4I/n/medkSoCVL/OFwM2G9b+yelMiWovI9LIaBGrPiMONKrdZZvgl2Pn6R94/G9tEXE9hLF3Xmux3Oxxx00V0ZptsoMfw9g9tYCP+JvZgZhPfo5ZovqRyQI9HgzO34c3s5jkgUBIrKE0NJRuQUHlxFEsBbR1wa/CRBw/+vYXNp/89w9Xw== 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=lSfptIf/5QPe2pyMO6ZChxHfZWbLogdEgGL8OyqyXrlMnhw0AhHk3iAM0qPDr8hIlYAoOFQ3Qkd5sPzAcAyEA/M7dpx9O3NJ45+KriYU3w/A94EW2NHJNb/aRMx2LrzxJrVEleRbGxk4m8mw+7++6zkgxPYDLIU+WA4yF2UUlQO3rsyofQYqWFw3K4jvem8kf03iP9TNHYU6N+Po0w2ClMHGTaaMgRJNwCU/6P2Wo9MzL+dYBE3jRGON8DQ811EUR1JPlXxHiP1FMGbEkqSxZwArMMcieTCuoXhzqjaDAIHW6w4dIcPd9ezPibaEVYW5mqlY4SjWupN52g2PxWs5IA== 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=EMtHZrBarIW1YEkWyj8hDHG3lWUTaFKUq5RE9DTjxszxY3Fgqn0GxUzpJOACkIoIbfCv+zn2xskJmSWVUQCeJStC3e4SKWwloL98tLpVcEWlvS8mtNMEG18Id1wtPc72P1DdPSBbuDxKIC5mojfpBR1J/j1N7R6z3RdzPGNDfdAOUiUYQjpQ41zNLoK4OAl0+grNAeW791Tvg3Gu/frn4zNyndvQcvwMv/D/pYKoCzFDAiEJw7AJ1df5AbRcVzlZ5uAZ7BvtqfzFGRJAyZrMdlUjIiDVqdlrT49LMJn7Lx7Zt8o/e+jCQq+wfd7sUKv9kWaSCogR/PXMDmD+Bhdhhw== Received: from BN6PR20CA0070.namprd20.prod.outlook.com (2603:10b6:404:151::32) by BY5PR12MB4997.namprd12.prod.outlook.com (2603:10b6:a03:1d6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Wed, 5 May 2021 08:06:42 +0000 Received: from BN8NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:404:151:cafe::85) by BN6PR20CA0070.outlook.office365.com (2603:10b6:404:151::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 08:06:42 +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 BN8NAM11FT011.mail.protection.outlook.com (10.13.176.140) 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 08:06:42 +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 08:06:39 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 11:05:51 +0300 Message-ID: <20210505080600.33749-9-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505080600.33749-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505080600.33749-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: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbe831ff-7105-43ef-1efb-08d90f9cb7eb X-MS-TrafficTypeDiagnostic: BY5PR12MB4997: 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: 1L1hGy5Ptu/W8b5zHZHJP7pZHNR72YxA7agtNc6Xej44zAvR+cKL5cmqza/O1K/YkqZfoRhXlwvpB43RS+8QBbe7laUjO+On64Z43xYvrO99QFc7l13wvlWfMMUxzJKk641DqiiDgQfidDz5PfP9+j1qGNLG07/xByy3S10SLdKwFXhvJK/V61Np7lFuMEPZWY5CC0G5/LeABv4pMi343VX7HC6nyLvy1vgCmlL+xyZMX15wVqFpWohMlzYK0VkYmI40ketExy6/cEtKgd70RrhsnBBAWA70de/j19sOO9FObxFdqca3eSdwAtbh4FetqcZGKITGAlSAdEEJUcyA9IwgijxCFtQDZYRjkrV0f3ZRMdSoZWr6wbwagH2CUNzAjRww+SC74gQ/Gb86pSQHIwOfhOoVxnvADOJsiXPjCxRjndAy0OHVT5wzh+YIrZWBwOhIB4NtmQ68I+VusXTZpOH8djMt43IAkX+grMuxT4ryG+OcBKD2qLg8mpj7cjQsf41cZntPryBuIoG5qAKu/YUEbb+Zw/k/z0SQHQf0lEmBxtKsH1Tmkp9RxzEo+uyb9XqRaOliuGEfIg8MrzfLq71nwb3iXGRgL422GIarLd0cHeHTqqREUqs5j/m7T0Q6f7a3vqrlCENEgVDpTGA+dotbIRvs95D0jhCwqeSllV4= 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)(136003)(346002)(396003)(36840700001)(46966006)(47076005)(110136005)(8936002)(1076003)(55016002)(316002)(356005)(7636003)(36906005)(82310400003)(54906003)(478600001)(7696005)(82740400003)(2616005)(36860700001)(16526019)(107886003)(426003)(26005)(6286002)(70586007)(36756003)(186003)(83380400001)(2906002)(4326008)(86362001)(8676002)(5660300002)(70206006)(6666004)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 08:06:42.2721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbe831ff-7105-43ef-1efb-08d90f9cb7eb 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: BN8NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4997 Subject: [dpdk-dev] [PATCH v5 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