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 4C782A0524; Wed, 5 May 2021 10:07:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BD2D41142; Wed, 5 May 2021 10:06:56 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2071.outbound.protection.outlook.com [40.107.102.71]) by mails.dpdk.org (Postfix) with ESMTP id 6584941103 for ; Wed, 5 May 2021 10:06:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mEhsPmFU395My8mGcs4Y4einGhw9SnVDr4PMrNevIOfM2V5fr0V040gbwPJ77hDjHO6jHREofapJQjaQcc0fKCE6bsTw3mQPJYZ7qR18LB8p7N1+F828NHf2DknWB8ku4ek1Xtu3lRJpme6XxSiiIgEnpGKKmNcQ1DnndB5Bk0xc+PxO8GiUCIHpezyxr+5vDoRbFvTcsj2mNEiZfxMFzZSW7JI+h6BJ6P1zfTkPH8CDWlOtYMYx2vLbNMn5WM0Do9PW8cd1FutR/YypKYIZLPOwkJhscypYd0wriPoVRlNHPH1q6TIls0sdq4EDdMTe4InaNfeHocbMagXtiTrnEw== 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=W6zuH+fC3IgruuqBagCpGd/LXtT91ZAjPmAB1hN14A9v6iuf1zM7vi1wlJAcboSQEmtMjGFA98NtFUFkd6Sr2j/jkyVWNZ8ws9dOBB/br9woS7mm+OT3oy/41O1J8RY3UrG3JQKfZb6bTNkJ2D2u7chI1NQPC0bJKkcsjdPBdO4terhEYRVqsBAPEb0OhSujEzEun/5ypZjRS/wxlriFx10RjeuncBVd3CvBM12b7ceJNaon7HiYhOMZcnxGMFVbe914d4atsEBUNRc3ISnEe/7jLcztkCcJKzep0hQcLkI8W/OfkRqN/H4hZEPld7yEEZZqcD1HSwbLOA8doRJFFg== 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=BH2ek9KVbU4fHMWvQmnXq5R8fb2yfdF51KzQBKGv/X6ARACOmot5oDQ6cYEnBFAj18pM6sJGEmT6agLQWLlOIHj7KRZnAhDLaGq6Gg0uCb1KdmvY5KC+WnaGbepwLfrXPl03Q2bejbaFdPHrb7BFPA45KHDYRwXK8DQ2ItuOtjpFJAO4T70R9TmzIxxrDXgmVZswqyYm8r1l4XADLUrtt0Ai3kHCiQ+oXsoI3Wg0XCSK2QvgAj3HV8AY4lx5xx5QpEiTUyYEUpZsnGIry10kx4QnK686DFLTnvIUX5GQB2Y2kqGu3PcrBSY+HCXqmuNoBtZAB30in+dX8ScKwQdXpg== Received: from BN6PR13CA0039.namprd13.prod.outlook.com (2603:10b6:404:13e::25) by BN6PR1201MB2482.namprd12.prod.outlook.com (2603:10b6:404:ac::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Wed, 5 May 2021 08:06:48 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:404:13e:cafe::dc) by BN6PR13CA0039.outlook.office365.com (2603:10b6:404:13e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.10 via Frontend Transport; Wed, 5 May 2021 08:06:48 +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 BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) 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:48 +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:46 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 11:05:53 +0300 Message-ID: <20210505080600.33749-11-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: b29e0c86-67ff-4c54-b20f-08d90f9cbb8d X-MS-TrafficTypeDiagnostic: BN6PR1201MB2482: 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: uLRBfjdwyyH+HWnVtCCKg1TWOVaerpl3RDrxJ7q7gbdrbADY2g9PLMj7t8uAsL23kwbmQFqbwdI/5/wHMKh6KBOoejFRq6KookMtHZDhvN3lio5DqvmjbOpNhp+ApDrw1zy+WyUa5IVnPlBhtS7shKcth3meOxzNMf+NPZt86WdDgrTyQeA/IhbaAhTLJ7ijSBG8JJombTNezyyQLm5wLh9eR/5Jpuvy237Hj07Ye27gUrBLXJIrpNvsypUNpdURscAzDYTKZ7ZFOInJZEpCsGi03+31zihS4XU7v3kfZ4IxMMjiUkHSNOQ0zMikKaHbhpMbrjcHI0prDWjzMXgrEHvddSSp2T3OG2N8x1KL+7hDv9fEnBwZV1KBP2G6Q0Ol/Pew8tkGFAkxGJZUUsPUMGf4CuAIyItQgCLP14Tubk+XBjWeDPHG3Ps6dhz8YGNmecNFfNtXRzbFfMvcH/TqTopubJcO7wsoatLYNBKulrtxWW5Rb5w2ui9HGmoX4d1rS2Rncll6LoYq4YMJcnPlENVAXMHzPBs3UudBlr/NTBmgkJft3gOjpVhVKs6ZzsiUBAO6s+VQLLnj3/R8HgXHT2rij9Yy60M+J3ACyPxZanzk+JrBlz0+CIRxJvOgDJY84CUlYPD2+VCaphDCC4smMA== 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)(346002)(136003)(396003)(376002)(39860400002)(36840700001)(46966006)(16526019)(478600001)(70206006)(7636003)(186003)(82310400003)(47076005)(55016002)(6286002)(316002)(36860700001)(356005)(54906003)(2906002)(70586007)(36906005)(110136005)(4326008)(2616005)(36756003)(107886003)(7696005)(86362001)(5660300002)(8676002)(26005)(6666004)(82740400003)(1076003)(426003)(83380400001)(8936002)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 08:06:48.3787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b29e0c86-67ff-4c54-b20f-08d90f9cbb8d 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: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2482 Subject: [dpdk-dev] [PATCH v5 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