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 68F08A0524; Wed, 5 May 2021 11:51:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D94B041142; Wed, 5 May 2021 11:50:49 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2046.outbound.protection.outlook.com [40.107.102.46]) by mails.dpdk.org (Postfix) with ESMTP id A30984112C for ; Wed, 5 May 2021 11:50:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmEvb1WsXS1gm0inodD6dNb+vbI7/5K/LmMU0VozErBcrQnuqjxe08uiAKeOB8HC1YZwhET4/hrYCInRpdOEsaT+K/igCZktLdD8mwGwxNJIunan561dUdsT9InvwXDfukOVPwmYRjXSOaQIdWD7Zaj0hkrI4d3sjZQOaerDVrN9OAppKqkKU04Lr5u04PMc7jV0jq0HENzM4lNmrlLpSkp3Ba/WQui0R+tktaIycDRMdqw3m1CX5xTSYN8AP9YPexq+H2n7S43XeHmpD1aXT4FNrvkXV8vXTqICFAmg/5rCgetFVOsvqg4/bSYrBCCy9+YFjUwQFq3pmwNlD7SGoQ== 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=uynwDbpfrqjvbp8gv4k4t05T2L0tNJ5JKSysEWLEtec=; b=Bp60ebqR0W3pSMjl6PG8pkV+9biHfNH5G8hTNUVSCaWISeokx6wOBSyWdNbBNxwH8I6RCn+G+LvUTPHN/ubCK1CO1ygAnvcO6Bg8se6WtK58SovglYgeqPXSVVFuPab06guTmH8prBDKUj6NtLewy6Q0Y/Gc4wt1mBQrl7IAX8IpxQ8fvkbuMDNOiNHaLLbtqaLp8P3DEjOHI9Q3XpED/w5vYtZzb3w1QNz8UUUtb2ETc0KhZEOWz8W8pSEqv3pztDYQhRiWiQ2IYpMbcyO3UO0UtIdFwoRUBWeCDHxzN4ycHhK+MLucKAwc+4oo8TX5nvUxtwjA/ikf/2g8cZhlzw== 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=uynwDbpfrqjvbp8gv4k4t05T2L0tNJ5JKSysEWLEtec=; b=NHdgSzWde5Fohb57UTN8VeSp7VeOZVk0J54k1p5Fp75sPutE50F2BxJ3fb97TCVNV8jhA6bjEMcP7bJLslABXPuAGXH2pgg6E1Ao/E/Doz2AiiysIEnLFwRTxl3J7nzFTIQXPvWuE4sEiNoH9R30w452b+07erAUPfplQbYb11F/GTcPS+4kOTFc7bE0JEiMtfPI6AECqHUDS7GasVEMuPl8iupRx4tQ8ARHR/t4tjmU95Qu2nGgOAAPYRscXHh6WvQb3L0+wns1k9+D0I6KQsa1gMvacPdRAYpLUaUt5IAIOIqaCeSB8yQGBk5fzjwxAmhzp+g9M8VquogOG3slIQ== Received: from BN1PR13CA0013.namprd13.prod.outlook.com (2603:10b6:408:e2::18) by BY5PR12MB4242.namprd12.prod.outlook.com (2603:10b6:a03:203::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 5 May 2021 09:50:47 +0000 Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::4a) by BN1PR13CA0013.outlook.office365.com (2603:10b6:408:e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.8 via Frontend Transport; Wed, 5 May 2021 09:50:47 +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 BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) 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 09:50:47 +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 09:50:44 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 12:50:02 +0300 Message-ID: <20210505095009.40250-11-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505095009.40250-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505095009.40250-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: 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: d48981a3-c71c-477c-13d2-08d90fab421a X-MS-TrafficTypeDiagnostic: BY5PR12MB4242: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OyecfcbYlmTc0vuLgIy/jfB62a93m4bkpOYgg1BhTseg5t71JL6H1IFNMSUK8akHfISdAoRkGWuFRUB/4238tSiIeS+xuLqjC4SEFlcpTktPe46WIKXbovg4EGWyASIlYq/p4hZ6XOnHhyB1PmhTjstmAdCpuma5x4EWs6a9klKaOdC7KP/dXxED1fv7z5pht+M2XsRLz+E810AnPMGs4ZiPvucpqT5dopLcEqnbaj66w4X21Hd3XDCocgp+IhDQf8j2kLKdeCtA3zN3NgpeakMsw7S+0kzDr8tihYplizQJnn3cP3rls2v7E2wvN0zrjowpqb/QDgxhYev7oxroqckUMomIs2d2pxiNL4M/2dt8oct492vmC3p9H5P9Ix/eT6ELkFxi4igaNm1LEXgGvA5ihzWbF5Yz7wRmBrviLk6JeiZq/ul4ndk1FBtsoO9t08/1M2yWc3yo5fP851U/MymUFf0G+hxhB1TF8X+b9uZKB9bm/ggB3cbqQnZjO1qxKu3aBsZ8zzlVE2b/9s0QIth38YrDSprlmbRw6FroxQZ74N5r5SAh2/anyTmXWhhau4YWRujfzJz2Bjn84ytCSTut2rG86Xo9oOQPj9/cyj8RxLrY9Kb/WVPJHHmlDU8NFY3Bd5QgIwGVihIW2qLqZQ== 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)(376002)(136003)(346002)(39860400002)(396003)(46966006)(36840700001)(26005)(107886003)(478600001)(8936002)(8676002)(36756003)(6666004)(70586007)(70206006)(55016002)(16526019)(186003)(5660300002)(36906005)(7696005)(2616005)(316002)(336012)(54906003)(110136005)(426003)(2906002)(7636003)(83380400001)(36860700001)(86362001)(356005)(47076005)(82310400003)(4326008)(1076003)(82740400003)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 09:50:47.0766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d48981a3-c71c-477c-13d2-08d90fab421a 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: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4242 Subject: [dpdk-dev] [PATCH v6 10/17] net/mlx5: add ASO CT destroy handling 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 trying to destroy an ASO connection tracking context, the DR action created on this context should also be destroyed. Before inserting the related software object into the management free list, the reference count should be checked. Right now, the context object will not be freed to the system and will be reused directly from the free list. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow_dv.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1ef98da025..14670d712b 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -11531,9 +11531,15 @@ flow_dv_aso_ct_release(struct rte_eth_dev *dev, uint32_t idx) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_aso_ct_pools_mng *mng = priv->sh->ct_mng; + uint32_t ret; struct mlx5_aso_ct_action *ct = flow_aso_ct_get_by_idx(dev, idx); - uint32_t ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED); + enum mlx5_aso_ct_state state = + __atomic_load_n(&ct->state, __ATOMIC_RELAXED); + /* Cannot release when CT is in the ASO SQ. */ + if (state == ASO_CONNTRACK_WAIT || state == ASO_CONNTRACK_QUERY) + return -1; + ret = __atomic_sub_fetch(&ct->refcnt, 1, __ATOMIC_RELAXED); if (!ret) { if (ct->dr_action_orig) { #ifdef HAVE_MLX5_DR_ACTION_ASO_CT @@ -11549,6 +11555,8 @@ flow_dv_aso_ct_release(struct rte_eth_dev *dev, uint32_t idx) #endif ct->dr_action_rply = NULL; } + /* Clear the state to free, no need in 1st allocation. */ + MLX5_ASO_CT_UPDATE_STATE(ct, ASO_CONNTRACK_FREE); rte_spinlock_lock(&mng->ct_sl); LIST_INSERT_HEAD(&mng->free_cts, ct, next); rte_spinlock_unlock(&mng->ct_sl); @@ -14079,6 +14087,12 @@ flow_dv_action_destroy(struct rte_eth_dev *dev, DRV_LOG(DEBUG, "Indirect age action %" PRIu32 " was" " released with references %d.", idx, ret); return 0; + case MLX5_INDIRECT_ACTION_TYPE_CT: + ret = flow_dv_aso_ct_release(dev, idx); + if (ret) + DRV_LOG(DEBUG, "Connection tracking object %u still " + "has references %d.", idx, ret); + return 0; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, -- 2.27.0