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 21807A0524; Wed, 5 May 2021 08:42:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 79FCF410FA; Wed, 5 May 2021 08:42:43 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by mails.dpdk.org (Postfix) with ESMTP id E033640143 for ; Wed, 5 May 2021 08:42:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qwan3D4Vx0lkIo4tZDXe548BdhtXHkhXsNjxuP3olcc8KQihu4q4CmnCugJHKrbHrvuJMKYALeqoRxAeFYqpha62tJgAtmZsM1fIKbVH8TWkkB1M4hPV+/Dp/wy0Lp3t6M/gSlsAHsuOAYJO9RwAM6J4HgLXGRXtZ3KmCZtOlqB6evsvTEPIo4EALZGNh+DI0QpM7GFe7s7l3Kvq+uKIfp1WfLrCid9i0dldCubJi63qTKCKa/JfOY4BjS36t2FkvV90KTlGnSpQdacYbkvn0aOhxaeM4SgZ67WcX7mR3n1+HkxMU+be6LUQQ5hk3nTsVSxUaIUg19CMV03odmuXmg== 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=Qr7HC4hJvKIVM/qmo50mKNtXO6QNdR/MyAWqaPkmj/4=; b=h+SOZMG9ZTCFqNxIeKKfuL45m7G6loRRnJGm5y91MDZEqJdpaBjMaU3M6303AuXNfHIsyF+6NsyBaB8jAMDYzJvwr5PaI9+jVaw3Xp4DlY2tOiHOQ4DXlT1rgAdh7cDmYZ9ouIuK0AwCL/xc9/3rJHa9ttmm6CL8fQCuZSO7mY8dSBRIZmiv2rYsiImVL7rhbG9RqVU3bcTXdJpj89ISPJVWgkBL8wGF5EE4yMIIUhNOSGlr2uJO6cMaNJfxvDDSFUAKcMWJ4KzXcg/YF0eGbb6bsV/z2Oi9Pj2soQVpDP4pzPiV4kd/18O3mugCtgtpXx/i1LUrb/lMNVGwe+AYSA== 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=Qr7HC4hJvKIVM/qmo50mKNtXO6QNdR/MyAWqaPkmj/4=; b=VRP1wUlJEI5l5spEgJGSE2hROhMvFVHV868l6MXdrYr+Al+mOpOHDlp1b0KngEHMCL2uKaavUIsL8sjUCGZxt1PFpCuCuJRn7hacDWIsz8RTcXW5nkfdMJuDeAp6cNO1EXvrOG03QW4i3wgymtdfzVpsIPSYbMCRyBmLz4O5c4VoWyVYMydTSnkzfyhkYQ9x7VBckJRzunRHLPy4PtrodmzRqnFhAxcgXxwRVe8O8cngRR5X457cqoZ6tDGh4A7+rfYE0QKtkllxiNfB8cDOBov+XF6IqF7RLYclRPYO8R3FDpvCXZ5nQbs+/RZP4BaFZ2tQ57YZOFvQZddw4rwjow== Received: from BN6PR17CA0010.namprd17.prod.outlook.com (2603:10b6:404:65::20) by DM6PR12MB3596.namprd12.prod.outlook.com (2603:10b6:5:3e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Wed, 5 May 2021 06:42:42 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:404:65:cafe::d0) by BN6PR17CA0010.outlook.office365.com (2603:10b6:404:65::20) 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:41 +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 BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Wed, 5 May 2021 06:42:41 +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:35 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 09:40:57 +0300 Message-ID: <20210505064104.30248-11-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: 2195a1db-c306-4aba-edbd-08d90f90fb87 X-MS-TrafficTypeDiagnostic: DM6PR12MB3596: 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: I84q725Rz/bfijHIEZj47/WkwrSxSBEFJiPSy9VT34lj7bVBmIUi5E/+yyCVr2BIXW0uOIr/EJRs1D2MYgbYJiedCPin+i/PYGAMZZYmb4NmtTDR8Ur9PLYAo7je9YyFHkewn5jd/D0Df0sqrcAVYds6fLgrYHrPzcpd6hyqwsBfDugbvjN8EI25U8jd/Q0S/TbdgBchj6azYRc1azHtlfuwwXslvtlGGe7F+VOvObPKdHJ3CDF85Gdvldf5Tz4oemxv5tS9ptbVjDUdVNvuAPjH3NYIFX4kOR9Orw/1S2swhQxmcc6JJ6QNMToU86gYim+TchmhKpLbYuNOVgZCJo0fa5YNe6T6Q4tUbnKh+JkYWsTlSEP9uEs5nC0MqSDWRylyrfdFk6NW++fc0kWdfLB6mz+Qb/WaDuE37/gJ8sheVEk5u54oeKgXvvDsKZecmQmLtXT3g7AByuWeG/2ossCNDs8NWF6M3aXtZ7aZ1Cnq6rSvykHRqLTh0/J0/W+bFKu+uJwoUmmHvk/GJ9/WoKGe1C0f2vYP9vFhCcWdZGcV0RS7e4lCBQ2dT8x/rAmRy1EriBuVAABPpapOlAUewQtuWLQzX8eQIMuIsPL10avCkNsSJjGXw5fp7cx5Iq6HCNoEZnJecUq71DAkp3cuEQ== 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)(396003)(346002)(39860400002)(46966006)(36840700001)(86362001)(82310400003)(83380400001)(36860700001)(47076005)(316002)(2906002)(82740400003)(7636003)(6666004)(4326008)(478600001)(336012)(107886003)(1076003)(6286002)(110136005)(8936002)(36756003)(54906003)(186003)(26005)(70586007)(2616005)(70206006)(55016002)(8676002)(426003)(36906005)(16526019)(356005)(5660300002)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 06:42:41.7433 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2195a1db-c306-4aba-edbd-08d90f90fb87 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: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3596 Subject: [dpdk-dev] [PATCH v3 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 84e7f0b3d3..0fa0671ace 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -11136,9 +11136,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 @@ -11154,6 +11160,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); @@ -13648,6 +13656,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