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 DDB90A0540; Mon, 31 Oct 2022 17:08:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44B9240E5A; Mon, 31 Oct 2022 17:08:48 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) by mails.dpdk.org (Postfix) with ESMTP id A8B6F40F16 for ; Mon, 31 Oct 2022 17:08:44 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hb5DoBocvbyJiEKi82PFbQhj+JRm4zXKC74xnhUkvmA99DMSSgkLi/31mnKQ3qIU59QktVPTS1RhbPjzWAwlafaoUUrbHbWUgucPtijf830Pd7S08Knfjx/MlXjTXuOZjuiWQdl5dSrsBQ9+DpSwOnlL/lFpa3+nt2aFHDNtqYlRGUlK7L6KR51Sjx7f2J/N/iRZoX01AQqD9b0MiB/jdB/xmb03CY/psjgfeQphA+z2uBAhLZtxeeOVMqDMZEx+mVYP6NHuYA3bKKL421aPVcF06X0w0Zyn2YfZ189X5wL6kpyzON+V0qLIYU/aHi3ZCLywJWdE/+S6DdiogCLfZw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/XWAFrDYc+4/aEhFbxOwax9JVPcyAR6zylNos/NOKsg=; b=OLqww2PTVK/GHiGUHm/Go1/K/kttAHnjIoh8dSAd0pTZBAs5laQP3wHYb+E3ca+knvT477pEXS4+RV+F5Fo/TuOt99kzj/cD6VtUHdypjdV6eDWuh1HZq7nhcNYOFxF1ZKiZdpM5ylq81LpDzxLeLXb9lD8UG29NTzpu47e6zMP0+xSUhMx9rYwel9xE8L7WsQFdBmO4t2sRlTZFe6Q5TAUckIUxbNhxsaP3AxME2hEe4a4yRFuJKW4ng8wK3Z5rxSRp+tB/jFEMRyvbQ59p9weliMIzM3/tj6etyvdFndz2zySGKZebYo5QDQMwSB8MIqeZESB2A/vXaX7LF0iWcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=/XWAFrDYc+4/aEhFbxOwax9JVPcyAR6zylNos/NOKsg=; b=MZAnPFBB8HX/bdh8+62VGIFwlcMorFsVW5M9z1FQNgXcOaRfAxy3yN0fcz8N+P4ReUjXUBxE5tsxgzHtKYg6UF5vjr+zvjR30cKdHcfQ5v5C7Y5t7oDM9Q3b0WY5AkieLlUFpVZEYugTptBpNjL51aaNl8hPVVFsqJAN42gxoPrMF880jYjj+DPGfAElnpTN1vvLV15qLj3/QmCR0TBBhvX5AY9oBFq4QvmDmcg5IGCvINl26eZawATeFg9GAUjY7laR/4+xP/3ji0S0G1224pOHOvt4fWx279w3it4o1WRBIWRejBard2HP2nbbcMy1y0MgPHUOaenuGXIYJB0MVw== Received: from BN9PR03CA0174.namprd03.prod.outlook.com (2603:10b6:408:f4::29) by CH2PR12MB4328.namprd12.prod.outlook.com (2603:10b6:610:a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Mon, 31 Oct 2022 16:08:43 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::ca) by BN9PR03CA0174.outlook.office365.com (2603:10b6:408:f4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19 via Frontend Transport; Mon, 31 Oct 2022 16:08:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.14 via Frontend Transport; Mon, 31 Oct 2022 16:08:42 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 31 Oct 2022 09:08:33 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 31 Oct 2022 09:08:33 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29 via Frontend Transport; Mon, 31 Oct 2022 09:08:31 -0700 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Subject: [PATCH 2/5] net/mlx5: fix accessing the wrong counter Date: Mon, 31 Oct 2022 18:08:21 +0200 Message-ID: <20221031160824.330200-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221031160824.330200-1-michaelba@nvidia.com> References: <20221031160824.330200-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|CH2PR12MB4328:EE_ X-MS-Office365-Filtering-Correlation-Id: 01f14294-2aea-46ed-1904-08dabb5a2e5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t9Bu7QX6VbP2+ouREAu40IJh4oWntLyq5zwVEm+SqyT5ILy55B0lpxdVekg9zKmIxJzLVuEP2RJf5qulqP5Go2LngpQsnUrPt/unR36Gcv8wryUEUeifgeAQV7N38AFTv/FL5D1zqZsd8T1bEo/Dnz+vlVhS5ZLLOmNsNQmvKAL9Ax0F+pzS5iYJJooHLdeOyzeFVTPfUjDNGStyVNZrwTPA0sLOsLsjR9HFZH76CDHhI9xgwIZ3QzIaofPBFcxK+qPr6sLFPmCtbG63U8rK9IqrgCWcLqfrQL3irbziN5FDDW/f5QgMVLDMwQNO37gV4AOzWjvootgeQmR4xTu6VifBOp/abky0/YBDieFdJQST+R5p12obP+c/Yk0vkznqZNGhldKFos2MWyG7tGktu9rBjSFRuF5YMswpSc+OIErHczRUR8jPulioN53bT+nqNO0YdMpeEEupcPa1acpoPWAf3kovyOMlteCkCaa1fs4Bos9KnZIWizDjn+1krsl/cdxuqcVmZHjSRwah23M/AQNAN1OYPlXP7JsgWld6IKXYpu0ww6ZA/O2I5NwA1eP8ksvkDWtRJOsQxGk/k+nOd67p7tV7NFOul7apagRCrZ/Z+KONhfC+nY29LsrWEwBwK2/ZavArXgDZyQ9Gp6E80k7Ajg+66ykQ716mFvfVt24kIu22/y6//tZJP9/iYnVGUM3EF4CMuMtwF/QEVWQkGk6Thx7P8hwTAaD4c0VnCJlHBxj56Vdy9BdGsff35VfaazNnP9ytYKD8ZEycNHxqrw== X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(36860700001)(2616005)(7696005)(6286002)(478600001)(26005)(83380400001)(47076005)(107886003)(186003)(1076003)(336012)(6666004)(426003)(2906002)(40480700001)(40460700003)(55016003)(54906003)(82310400005)(316002)(8676002)(70206006)(70586007)(4326008)(8936002)(5660300002)(6916009)(41300700001)(86362001)(36756003)(82740400003)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2022 16:08:42.3775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01f14294-2aea-46ed-1904-08dabb5a2e5d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4328 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 The HWS counter has 2 different identifiers: 1. Type "cnt_id_t" which represents the counter inside caches and in the flow structure. This index cannot be zero and is mostly called "cnt_id". 2. Internal index, the index in counters array with type "uint32_t". mostly it is called "iidx". The second ID is calculated from the first using "mlx5_hws_cnt_iidx()" function. When a direct counter is allocated, if the queue cache is not empty, the counter represented by cnt_id is popped from the cache. This counter may be invalid according to the query_gen field. Thus, the "iidx" is parsed from cnt_id and if it is valid, it is used to update the fields of the counter structure. When this counter is invalid, all the cache is flashed and new counters are fetched into the cache. After fetching, another counter represented by cnt_id is taken from the cache. Unfortunately, for updating fields like "in_used" or "age_idx", the function wrongly may use the old "iidx" coming from an invalid cnt_id. Update the "iidx" in case of an invalid counter popped from the cache. Fixes: 4d368e1da3a4 ("net/mlx5: support flow counter action for HWS") Cc: jackmin@nvidia.com Signed-off-by: Michael Baum Acked-by: Matan Azrad Acked-by: Xiaoyu Min --- drivers/net/mlx5/mlx5_hws_cnt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/mlx5/mlx5_hws_cnt.h b/drivers/net/mlx5/mlx5_hws_cnt.h index e311923f71..196604aded 100644 --- a/drivers/net/mlx5/mlx5_hws_cnt.h +++ b/drivers/net/mlx5/mlx5_hws_cnt.h @@ -506,6 +506,7 @@ mlx5_hws_cnt_pool_get(struct mlx5_hws_cnt_pool *cpool, uint32_t *queue, rte_ring_dequeue_zc_burst_elem_start(qcache, sizeof(cnt_id_t), 1, &zcdc, NULL); *cnt_id = *(cnt_id_t *)zcdc.ptr1; + iidx = mlx5_hws_cnt_iidx(cpool, *cnt_id); } __hws_cnt_query_raw(cpool, *cnt_id, &cpool->pool[iidx].reset.hits, &cpool->pool[iidx].reset.bytes); -- 2.25.1