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 D972CA0524; Wed, 5 May 2021 14:24:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F2D641159; Wed, 5 May 2021 14:24:12 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) by mails.dpdk.org (Postfix) with ESMTP id 0100A4114E for ; Wed, 5 May 2021 14:24:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GdpkYGBGlSudRRkMuaFjiiqA4ChyD5Xmsi2Bm+c22MqZ9TZHJBNO4/OFmw/QMSg0eJK+fZZbwCrVLc09BhupwU3x5f1BPAoTwjeMoAs/6PuRO3KGQk1iO88jjpnF5z/ftcugXkq0qk2tXMJEvJi/wQhSg/lg0Xjvz98ZTvgDMm7RWDeoCwl7p1VrtA/6tOk/x/vPg4tZYiKQob5JTh5fEKxrGFMLyYQ2RlSlz2mY3k59SxXBwA9Y0lFS93AdAOJKUGR2LQV5mqjmdB+8Q+Bbt87tz7SHCociHaasfVYKSvxL/mXlbKf+xq1Svtpb5zsLonvilBixWzgSVUDKWGWWIA== 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=yVPlTU6ih4+mZg0N0mF+AO9yT79T1Oqeiv4hgAg15mg=; b=EMu8yibAVvvgWPi+bfdcBbwfGFZVOpk6rK75u5IALPj6ymspsRdNn3WrtuJLFYvt7Cy+jdUxUXs7X4eT/5DQxONfv1njyyeMfT0YEoKL4892Nby1igyB01iuseXKWOZwGMc53SMUSUTIMPSPzRpVVbpu1PuYVbtmPXUnRZU1cH07TaIOFuRgUZad27925oG2Ve9JW1nA9JeX1+xrUkaYVo8jFHVFLfzjkALKcOrFTAEsNrSyuDRNzDQfAV9FrHT0DxGSR3z6krUQ4gLvOEZcWO5GS3O8MqeNGkQ2PsMUyAT9Z5rttUOBjkbxeqL99yHCeqSsE4gamUkNQw4Jgh0O/A== 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=yVPlTU6ih4+mZg0N0mF+AO9yT79T1Oqeiv4hgAg15mg=; b=gYvaaQGSoBa9b97g6BP5umJuT+L60X/POHX7bGiQc59eN11RWFZxWVa6iNdy4Nd9Aa/yOpfwK/KigNJGwO0rkLOMD4UIz7AYD9wBgGp1uHfpXmnGqg1Zj1lYx0CV7s3FZ1sCbEetxJJ+w0VZFNvTvPm5WH5mvqskcnnhY1Gow6sHDfjiEjqMYVvcgnnZlgHWw19OYdMQlbd1FCd7UkNF66nuaXhs8j4raF8L9pFOLF9ZupVU2kXD+j5JEVzucniQcetGGnXIvSE5/IEaJMCk1tT6qYyRF5PQ/vWWFeOPpkCDaCCZClKj492q10fT6gK2Ay0v2I5uyuomx01vO+GIlQ== Received: from DS7PR05CA0010.namprd05.prod.outlook.com (2603:10b6:5:3b9::15) by DM5PR12MB1641.namprd12.prod.outlook.com (2603:10b6:4:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.35; Wed, 5 May 2021 12:24:09 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::2c) by DS7PR05CA0010.outlook.office365.com (2603:10b6:5:3b9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.9 via Frontend Transport; Wed, 5 May 2021 12:24:09 +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 DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) 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 12:24:09 +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 12:24:05 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 15:23:21 +0300 Message-ID: <20210505122328.51129-11-bingz@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505122328.51129-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505122328.51129-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: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6070bb09-3e27-465c-2a3c-08d90fc0aef0 X-MS-TrafficTypeDiagnostic: DM5PR12MB1641: 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: Xx62o9jrxzI/jCOS15K0EmM8MLEYgrHa1pSsXz+tNj9Bc8cXamIaBL31VGRC52qC4G5KPycbkki3ZRgynhYZRA9NcyKeG8GE0pbGQbBoiRodD3w4RB1MTU5xEG+lBzy8Jw/nYPs1z5ChGBrWqwtYmCOawhW4aSVprBLfWkL0kfsHHuZWCzqxjytZctdKmVXFSc9xTYTrsxemxcIFW3olxkNewu2rY/+zwljo3WYDr95eTHArlGu5QrW/RvJFrGcTA0HBndPe6p3n0tqHp84gRLbLastRwZbbQwqJ4bZJLfKPCMjLYMRsRUqWX5oDTc+3DERDK5bSeIxkdMYD/MHioIgwvADgrcxwQ0aP/oXOJ6eOntbq7FylFpBmKSwDOjk+tnN9Y7hnbjKMAXYCitsVn/jTjRskpoOg6815pECK/Hk7bEVwGh8GtOPmOX3Sx6aK+aX68vd2QP+qvGvxD0Eglte5yo7YjImwvH/aYSt24MshZiFo2ESif0Rpiyru7LjgTxcS9ZXafhcmUWACO5r6Z45fqfC7m76bwteRuj0rpFYycve9qorHKTAyQnkqsgzsMKQ5efjPBbUH9VTPn1kOAaxt6EtQAvav4bFsb5YEpyWaL/jKdgqqltyfP/LkTf8g49XEssCKxgMbn3mRXmmtDw== 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)(396003)(346002)(136003)(376002)(39860400002)(36840700001)(46966006)(54906003)(336012)(316002)(82310400003)(83380400001)(4326008)(478600001)(426003)(7636003)(86362001)(110136005)(36906005)(2616005)(16526019)(186003)(6286002)(356005)(36860700001)(26005)(107886003)(47076005)(7696005)(36756003)(2906002)(6666004)(82740400003)(8676002)(8936002)(55016002)(70586007)(1076003)(5660300002)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 12:24:09.1539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6070bb09-3e27-465c-2a3c-08d90fc0aef0 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: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1641 Subject: [dpdk-dev] [PATCH v7 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 Acked-by: Viacheslav Ovsiienko --- 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 e1beb83e92..c0d17fd599 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); @@ -14078,6 +14086,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.26.2