From patchwork Wed Jun 9 12:32:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 94059 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45A0FA0C46; Wed, 9 Jun 2021 14:33:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D14F4410DE; Wed, 9 Jun 2021 14:33:14 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2042.outbound.protection.outlook.com [40.107.93.42]) by mails.dpdk.org (Postfix) with ESMTP id 093B34003C; Wed, 9 Jun 2021 14:33:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PN1v26P1q5C3/E/ht+5CQUudB9/3EHnGecVJq6UjSr9krgTZehdQw4Y5df/oZc422VJj/spOeRB7YE7odOqaDg4oIb60wTp2/fqhpgGlTexei4yL82Tri2pjny9iblO31SfawWcwTpwheug/L94W1zJZPpbhzaHy0P40YY6xztn2i1YSuxorJZUvAqXjnDSYD+1/CONwmTJerCObDNsWLAxM5un/psLqomv1uvKFuUTb1yRAwi0WNwtfgP4nQ+QT2/l4j3Hk3WA2ol5HPiBBtVegbHfG228U90621aPazfBO6bHgyZDE2o+986oVLZ30DOM90TEfTRWak+5vlAZUIg== 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=R/1axBKjLA9UCa3FzVwx/AWWNkmLiViaXHojNl2FYpI=; b=YZul+mZV4mQ7GNDaoR0lZZ7HWQKVyy79B8bULZjAr1zU8zce2HDNQ5BiMaHad84mcl3X0HRcg0DjYgrDa0GjVwE9jgdUPZVpIV/ar91Yy9Yv0Hhy+BvAhY+1wndenAmf3NfPglnvoGvoIzf4HgawE87zYBqgoRlmvkMrCRUQppzq2VZIcOG5v1pSoYs7CCZHYBilJ6X3L7LcZNm6JYV2prxardZx0Ps3A29+XL+0ltW44BXiCjwRad8vcm/lbH+RdWNS0o38i6iWqUFSH8nNAfyho1dzXgoP9HB6m4LtSWT0gt/FgExR4FZ2quFleiV37rOFwB0ZrNSjmBdmM/ghyQ== 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=R/1axBKjLA9UCa3FzVwx/AWWNkmLiViaXHojNl2FYpI=; b=SFjDRcOLCt2ek99b3gMkl8m7ZVHDPW2w7SqYcZh5QD+VmleO07H78qOX/ez53Ss7FdW87ojU71PiBj0MZCHFFaC+2R0nObiYyyb8Kcgrukvffm8Qf6ihthTtmhUbnZddfZa5dXxgj2fA3/tUjyk/Aatv7zuBbDbJqi+3f7h8Bt9b+6auoKAgw8DFZ4++EFEamO8Qylw7XLH0OfRW90Y7eo+uQmgAY1WVEqadmaHFx/mxGqabCaxdbmt0EwM/y3wOkpxCAMy0CxY+oUADlbs1Zo4drGQzqilNoJmDDvHif/qKoU0D/3xuMidbKgZwTk19aMI5zuqalKnb7CYernftJg== Received: from DM6PR02CA0141.namprd02.prod.outlook.com (2603:10b6:5:332::8) by MN2PR12MB4255.namprd12.prod.outlook.com (2603:10b6:208:198::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.24; Wed, 9 Jun 2021 12:33:12 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::b3) by DM6PR02CA0141.outlook.office365.com (2603:10b6:5:332::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:33:12 +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 DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:33:12 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Jun 2021 12:33:10 +0000 From: Matan Azrad To: CC: Viacheslav Ovsiienko , , "Bing Zhao" Date: Wed, 9 Jun 2021 15:32:51 +0300 Message-ID: <20210609123251.3558588-1-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [172.20.187.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: 3345f08b-a812-400c-04ac-08d92b42bf3f X-MS-TrafficTypeDiagnostic: MN2PR12MB4255: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zSIiZ2M2D2OphYozfsdeDYtFFaJiIm67CPVArcIa5QjwgwbalR54SW1d7B1ZLWCDd8zrGSAp7ESFDe/vQNKwPWWjGS5VeWUMGPloG6kQBGRnQXuiATT5IE8zSHoxt0rPZZxi/3bxxDV0ST822sAqSk3UUAO3xA48GB0ltSfHrOaP+WVjoFXJ2dqdet9b2V0gMcOIrhE5L1bCHxKjeRyysY9DExKmYCmy8gnSaPBJ4Ka5tgA/br1VuTvjcmQl/E1RaV9oM7UvTLT4N7kXMGYCaDTso15Iz0mQ0d1kfwctqfMH2v1iEItP88ndYe7ZXGEOO2Fm6f6NuWO/d7kqpBTGfL9DZRBWLfZM6kUIEX2oe0qI/k0rMjksHrLUJDgCtGbUUkNejEw5L3eW6zcI5yt+Ih28dZLE1Gbzsv5Z7SEb0Vzvm5V52Q8ts7zL+CQvraF1zGX8HJFRKc7o95RoL+tUibtL64RkM8R5rDNT3SeRiYq7JOxXQNYH5DoxE0ADFIH8UUn8rPsfhHY0P8qdCe7XLVh1+xBE+e0pqlotknv1+s9tT0K8NoiyQm/n48mc1EwW7JShUKokPKDOZ4cglQgpdWBKNgF6VntL4xR0Fzhu3oGru8Lr5Q6hoeDyH/lOK7ti6k4vjSgeTZkRqDnCAN0qsEvFGreS+LLPD56aGZGi/OA= 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)(346002)(396003)(136003)(39860400002)(46966006)(36840700001)(2616005)(55016002)(6286002)(107886003)(70206006)(426003)(336012)(8676002)(82310400003)(86362001)(8936002)(82740400003)(83380400001)(356005)(2906002)(5660300002)(54906003)(7636003)(4326008)(316002)(7696005)(6666004)(450100002)(26005)(70586007)(16526019)(1076003)(186003)(36860700001)(36906005)(36756003)(6916009)(47076005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:33:12.4950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3345f08b-a812-400c-04ac-08d92b42bf3f 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: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4255 Subject: [dpdk-dev] [PATCH] net/mlx5: fix aging counter deallocation 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 a counter is destroyed and used for aging action, the driver should remove the counter object from the age-out list if it is there. The counter memory of the list entry and of the counter shared information is shared because, currently, shared counter cannot be used for aging. When the support for counter action in action handle API was added, the counter shared information was reused and moved to be used also for non-shared case. Wrongly, it is used for aging case too. Remove the usage of shared information in case of aging. Fixes: f3191849f2c2 ("net/mlx5: support flow count action handle") Cc: stable@dpdk.org Signed-off-by: Matan Azrad Acked-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow_dv.c | 47 ++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c9887c8376..1b2639d232 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6110,28 +6110,33 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t counter) return; cnt = flow_dv_counter_get_by_idx(dev, counter, &pool); MLX5_ASSERT(pool); - /* - * If the counter action is shared by ID, the l3t_clear_entry function - * reduces its references counter. If after the reduction the action is - * still referenced, the function returns here and does not release it. - */ - if (IS_LEGACY_SHARED_CNT(counter) && - mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, cnt->shared_info.id)) - return; - /* - * If the counter action is shared by indirect action API, the atomic - * function reduces its references counter. If after the reduction the - * action is still referenced, the function returns here and does not - * release it. - * When the counter action is not shared neither by ID nor by indirect - * action API, shared info is 1 before the reduction, so this condition - * is failed and function doesn't return here. - */ - if (!IS_LEGACY_SHARED_CNT(counter) && - __atomic_sub_fetch(&cnt->shared_info.refcnt, 1, __ATOMIC_RELAXED)) - return; - if (pool->is_aged) + if (pool->is_aged) { flow_dv_counter_remove_from_age(dev, counter, cnt); + } else { + /* + * If the counter action is shared by ID, the l3t_clear_entry + * function reduces its references counter. If after the + * reduction the action is still referenced, the function + * returns here and does not release it. + */ + if (IS_LEGACY_SHARED_CNT(counter) && + mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, + cnt->shared_info.id)) + return; + /* + * If the counter action is shared by indirect action API, + * the atomic function reduces its references counter. + * If after the reduction the action is still referenced, the + * function returns here and does not release it. + * When the counter action is not shared neither by ID nor by + * indirect action API, shared info is 1 before the reduction, + * so this condition is failed and function doesn't return here. + */ + if (!IS_LEGACY_SHARED_CNT(counter) && + __atomic_sub_fetch(&cnt->shared_info.refcnt, 1, + __ATOMIC_RELAXED)) + return; + } cnt->pool = pool; /* * Put the counter back to list to be updated in none fallback mode.