From patchwork Fri Mar 8 12:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586810 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2082.outbound.protection.outlook.com [40.107.93.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82AD61D52B for ; Fri, 8 Mar 2024 13:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902965; cv=fail; b=I3uIICLaNnE5D3C6jiVl7IND4R/D9d4Zd/vgW3MYNANev8kt1iwBokgZcfHHTDslPO5x81NQuq37d+4zQjsVWF5RWQJPSZ48Y3SkBI6oglyfSVI3hoV19ShbhV6hPXwJ/32mkPLBHH5s36WUBjC0by/wZEyZPjY043v2bu5Fbb8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902965; c=relaxed/simple; bh=i/zLVAjd+HIIUnIHAKKYbe9G8RroMajIYOAwe2trn64=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n0jmdUH6WJ3EBmY4IBH7mNPtnEbUfAaXHP7jxeKf2x9xJ5SFr4B9QfwEmP697umKDVYU/5vfGzeDhVY1bKJjxCQc1LMgrMYeKyygU9LR+yqz5C+eAXEkBp4lrc8s7Krj0BawprYjqCheIVf5bG5qMRqZjQHyLatTdMy/jI+U6ps= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=j+co84vl; arc=fail smtp.client-ip=40.107.93.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="j+co84vl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jrNPqg8Nf+uP6SzFLzxSKcdjwW4U63La41afJ8XJHYWXZo3njGllPe5zEheleaNaxFP0VDu0tIOtFd3KfS/BmDCFbpQWNkU51WdtoRbVaTIkY7TP6A+lqTQDlZGBjLgZxR/ZIemd7JsA9N24L9eMT7htBo/S1OfvIrs2hZ1CszTCKk2lHphYXIj1w2Cj+hsulhgwW/p6Ib/jcA7HPmMqMSML62YutOPTjknP7GKyweq8fR+Ng6yA0sNKLFOhyCIgwzh2V1VeQKOX7QRHya/cKXCj/0cKdR4yq6ckMOT8/xcCFW9uXfDp9U0k31euHA0wDkXrj7s5RQuVnfZKx4vaqg== 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=OFw7jw7ZrThWZUex5cp7RA0Vpi5zHOOtr0jlqf+H0B4=; b=SblbmWvqwZoX5cdp8D+YrLUUbCvNCwyzgu1SAz2zGw/sY8imvcPa0c8GpgvcVzu1tlbt6UoNxRNa6Cu5B4kmPggEfMpGjDbKnmXzdsRLPElsABnijqj7sYHlvWR4vnTKPwn+wXYF2a2w25W3x5UVD/+whXm/J1JBRUzkqYf/4NBkIXm7WFUuIT5hJke8GjtVALavSG2JIjVxziJJqDif1mRZEEoSJThG6/eS3uSGkKKUOHtwwQHavWUcFTiwcOrgTlD+O+9s4gogm/OkBPV8d9nws28FBI3SlAWHZ+nAwyGsM4epg3YZT/oB3w+iHq2PGh7ivUUJS/jYDAUOPOxOsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=OFw7jw7ZrThWZUex5cp7RA0Vpi5zHOOtr0jlqf+H0B4=; b=j+co84vlyQXQYVCSvarkzTgar5qc6ZdX9eLC9NbrAevl/MOB1SiP5ri3mjYP8BIKEXFc8SZbfQL8mFHJei8OMHdcSzxyMjPwe/yGt3lDFseSRcczYUUmptPyigSapic0hwVJWuRWoH8DvuYyFTXugGkoOH94P65CrDGWLWpU9/rJvMcUC4RHOIkGf9DfmCIaaaK7gzv9gSmxclmIH0FG4YWFissXmxY3a7iTf+DaXJAPHQerju7aWl1HUPKbjJF0yFZPTBB4F8Y+lyUGbeddNkvjLuHr2c8nxCs26Wfshycm7VMAuhEfBMhLLtYGEJvL5TEXpQYQKFG6TON9VdY7tQ== Received: from DS7PR03CA0089.namprd03.prod.outlook.com (2603:10b6:5:3bb::34) by PH7PR12MB6538.namprd12.prod.outlook.com (2603:10b6:510:1f1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Fri, 8 Mar 2024 13:02:40 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:3bb:cafe::8f) by DS7PR03CA0089.outlook.office365.com (2603:10b6:5:3bb::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29 via Frontend Transport; Fri, 8 Mar 2024 13:02:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.12 via Frontend Transport; Fri, 8 Mar 2024 13:02:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:22 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:18 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 01/11] net: nexthop: Initialize NH group ID in resilient NH group notifiers Date: Fri, 8 Mar 2024 13:59:45 +0100 Message-ID: <025fef095dcfb408042568bb5439da014d47239e.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|PH7PR12MB6538:EE_ X-MS-Office365-Filtering-Correlation-Id: 071b823d-77b6-49b7-322c-08dc3f7008e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZYv5TR9wOKEdqnYUKpBUkHAyRrs3nUV/VPxCbRzx+5+kF98ptdzdv1XNKkPPcWDvgDf0AJxJO21I0w4Ln38ItMa6aWq+fviyODyv1PknVTPHg4QSQOmLgoosZSaeqism58p/XuP267k1RYZswEj6EVAa6o+zEA3fzDpt3uTrDgRMWEM0UMpDYg9dqFNtQIgSIgweZm4woEVu5E8djOBetmbZPDe2HUaS7mu5SWzkvphhEicGm/RtRaTEWcKCYuAFh1UnU4oZl5iLvMp0fhiFopGAY5J2Fmhui8vcR7pfjfOKFPAf0EU8hVYWYdCt9h/OgGKr0T9YE1rLv2G+GCGwLdpOLFuvAefdVOOIJG9YZ6TyjkL2BVRBkQg++HVFpVscQpzHmIHljI/LnQKL6ii7lYkEpC54B+T4CHIS7rUzvRt61fk8TNYfwvzOMZUNRy2YEh20XjuE/WkpeuVTUfc/SXn53kMWhC2iwNmOGHIfgkhK941mw9vy0Rz/6/P5MJ7yVIRNQFwn61wNXzbADQzHhgjsfZ4PjOBvD415LWff2yEEIIy850vdcR5Oc1Ean4OGpMDSOT211bIEPsaYD08npjonEdFUzOx3q7iITkm/kezmB6FzCUN+zBpFUrcZTeiUWvHer6ZDK+rjHy0+eHZiP9MlkDHByhE7muAxDOtqtUaSIx9yDx94XHyDdXFlMbA2Le/lMp2MJ/GxaMAlR3p4zMc6X5Vf4CO375TA9vbbQQiLofVxZ0gGzrTEWnIhnJph X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:02:39.6396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 071b823d-77b6-49b7-322c-08dc3f7008e6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6538 X-Patchwork-Delegate: kuba@kernel.org The NEXTHOP_EVENT_RES_TABLE_PRE_REPLACE notifier currently keeps the group ID unset. That makes it impossible to look up the group for which the notifier is intended. This is not an issue at the moment, because the only client is netdevsim, and that just so that it veto replacements, which is a static property not tied to a particular group. But for any practical use, the ID is necessary. Set it. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- net/ipv4/nexthop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index e34466751d7b..0548d1b46708 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -407,6 +407,7 @@ static int call_nexthop_res_table_notifiers(struct net *net, struct nexthop *nh, struct nh_notifier_info info = { .net = net, .extack = extack, + .id = nh->id, }; struct nh_group *nhg; int err; From patchwork Fri Mar 8 12:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586812 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2041.outbound.protection.outlook.com [40.107.243.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71E9F3612C for ; Fri, 8 Mar 2024 13:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902970; cv=fail; b=GAFE9Mr1liUi7m3khDBiI/jJfVQKNgHeuM5lWVyh+YUmqMfT0tC4coilv7wpbnC/wI4KziiDgrgtFD0VIugxA+3HB92k2S3ipsvIPsyy70pBRtzn8qvI4fv11rnA00pPUBwqnjyUu6fpJQzkEL910ttVzUOWYeoOA1LT+U9vVAg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902970; c=relaxed/simple; bh=Yy0SE5eLrViFgQ9tfi+84Igpfem4F4skyV1OXXIinOs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LlUyKqJzXnGcKRsxKRzutHasYo0qpHyb5MzXqV9VmPFLW5UMp+4yC7f/ESdQhXxJWS3c/8l0cJtEDF8sTWRHShwe+6vwCBP2bwPbJgBk3o3cb0MSEggLDOsPR/JiPw3ShxaiT4swX+vreFH52oD3ZFI0ivgtJylnFIAXhfGH1Vc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=F2RKCE+E; arc=fail smtp.client-ip=40.107.243.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="F2RKCE+E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T23ORuS8UKILTPZknsbGGITHxb24LBwV8A4hLy1ergADMJoZgKTX6IQFJc1mcD7jzWlURSZjKEEVi0r4O5ByI+kGKvdsDPw5/JonjnNvH7pQ158K0BHmTNHQtK1tTTf8dgTu25io2TnSytq2bm5dwdIncNMsNyVB5i8uyskIjbeiQ/2eNScp0y/YEJJmFdW9pcE0qMpFypSAUL6gFtssaTlU7x8bEgQN7leQFjE4ZDN06y1aSwBHmaWHoOg+T+zIfCzmb6Sa1Cc8NKSMe6VSvw5jaVnaEVl1b0sKeUCSmvam4MpPci3Z4f3XLYbN/46EkuW2LvPr7xe8/laduoorYg== 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=ukZ58s0eVRJRgE5LujwzACj8LcjSHw06uWEYQoS2+T4=; b=H6GB7EQRM70+wxWloaBjUNMkuy99ze/NopnYBgqCNKcLKt/S2mVoRdCxmE1zKtaqQgbba+JK6u1yZE1cbnTZEU+jvzYtoOj479MYnCYu/5BOyDpRsyEIKO4bltdB3Y7/516L+RHS2crmtUoqIjI/d/YNZWvF2XqxLIAcYqlhOU2m/liTsvWxA4wrn3N7qnfs4U570nGNm3mvHYxlNoGYcp4l2c8BCK78IxgdF8TSjoYs+aP849QTKg1eJlmdPChOfAA92jF+rbmRvQCD7TmMCUJvuj7XLa4MlJJ5/my+TevJ8QFmGEx1rpZmW7KsbP4dNOWBbF44sEBunsKH6ah91Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=ukZ58s0eVRJRgE5LujwzACj8LcjSHw06uWEYQoS2+T4=; b=F2RKCE+ESsLbFbAb1UM5bGWLI9zCFIoEx3hhR2n4zHTlRGbYT2naDxZ2ceY9Jq3Tztpp/gA5mjCDSb+8bm+4SkPrV8ler3lsHgVTUtqBv3ZjvmHL5aMCcxZr99DIIivA3i/xpBixlBqexaqZkvkR7+wKKlRT1GRCfmKEhhS8W7h5mGEUJbuqokokcWHnITtMCG2rgsjFAeC7pxKoKhUSiBx4sDJ93VGo0kKFFPCQ88lKK7Zp6jjriKnMgAOQ8LsJKd1MRVFOkz6GmN7SrMyK0wv8Nm8JoDR5wD+in62NT+cMh+iQvPXdfTT6sZV0KZwaDlRPuIpXEuGwVcbaDIzPWQ== Received: from DS7PR03CA0088.namprd03.prod.outlook.com (2603:10b6:5:3bb::33) by MW4PR12MB6973.namprd12.prod.outlook.com (2603:10b6:303:20a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29; Fri, 8 Mar 2024 13:02:44 +0000 Received: from DS1PEPF00017097.namprd05.prod.outlook.com (2603:10b6:5:3bb:cafe::ea) by DS7PR03CA0088.outlook.office365.com (2603:10b6:5:3bb::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29 via Frontend Transport; Fri, 8 Mar 2024 13:02:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017097.mail.protection.outlook.com (10.167.18.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:02:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:27 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:22 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 02/11] net: nexthop: Have all NH notifiers carry NH ID Date: Fri, 8 Mar 2024 13:59:46 +0100 Message-ID: <8f964cd50b1a56d3606ce7ab4c50354ae019c43b.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017097:EE_|MW4PR12MB6973:EE_ X-MS-Office365-Filtering-Correlation-Id: d2a37a64-23ad-4ab3-375a-08dc3f700b52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4mnTlfxzQY+wPQCh2AxXCUrlo8I5xWNbAu6N6I977VRxqqeZg8fq7AR6qBZRU9QfXcAeBCfUJi4UDPYtaCEMkQEnmjCLv8gKPaHnC1E8R1MsePFCXuBabgvALXe5jSNjFGOiZrUPopij4vdvD5GT6rpCboJX7Ppz2LxXhORWo4IHPCy5PZIh3EV3yZoOfjrb2dv6KRhkvhymWN8Opp4hk/ZpsQY0clIMDHoSCju/AhpR0OOgRPRcFsEwu1ErSaoH00C70Kc8WE44o13RoYPbXoQJu0a1PKF6utxhY6lHIR0+gSYpzPDKM7wE30hyikjqKs7x9bUsCIcJ1ayY7bMpK+x+pzgfSW/snJShqwjb5T8gO1LTIuncWyUAInKQ/D0TkG8lOeGSw15mIBXCfoJQTEW+gausFOd6zcUHltiDZQeduxMlychpYOwe9A2ozluPWodk/S4VgUoSi+p3s+dYCNdyMLpPmU1n8h4bGEofksyHKGFkoEZNmKXMp2pB7QqH1D8X4zey9O3l/bpdHzeZqqer9FO01OaPo+7P2vKtRqfdUiebsgARrV2wSHe55rVWbaToDVUN4NqPlITvzi38jbnqzkFHwpTOsyYfDwEmXFePsCTQFg9jnldcCUXxd0UTm92MtukAcCaA9hlXtHzLLJsGgAMGD44mSLeqrMmTncyndkf4y2PBVmHD9qP6wlvWgvAkTyJi/0paJirPXwCjB5EfbnZwM8gRabywW2Kp4MD4LEDpkOT+3EXcgDU/luen X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(82310400014)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:02:43.7186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2a37a64-23ad-4ab3-375a-08dc3f700b52 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017097.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6973 X-Patchwork-Delegate: kuba@kernel.org When sending the notifications to collect NH statistics for resilient groups, the driver will need to know the nexthop IDs in individual buckets to look up the right counter. To that end, move the nexthop ID from struct nh_notifier_grp_entry_info to nh_notifier_single_info. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- include/net/nexthop.h | 2 +- net/ipv4/nexthop.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/nexthop.h b/include/net/nexthop.h index 7ec9cc80f11c..7ca315ad500e 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -185,6 +185,7 @@ struct nh_notifier_single_info { __be32 ipv4; struct in6_addr ipv6; }; + u32 id; u8 is_reject:1, is_fdb:1, has_encap:1; @@ -192,7 +193,6 @@ struct nh_notifier_single_info { struct nh_notifier_grp_entry_info { u8 weight; - u32 id; struct nh_notifier_single_info nh; }; diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 0548d1b46708..5d09270359b1 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -104,6 +104,7 @@ __nh_notifier_single_info_init(struct nh_notifier_single_info *nh_info, else if (nh_info->gw_family == AF_INET6) nh_info->ipv6 = nhi->fib_nhc.nhc_gw.ipv6; + nh_info->id = nhi->nh_parent->id; nh_info->is_reject = nhi->reject_nh; nh_info->is_fdb = nhi->fdb_nh; nh_info->has_encap = !!nhi->fib_nhc.nhc_lwtstate; @@ -150,7 +151,6 @@ static int nh_notifier_mpath_info_init(struct nh_notifier_info *info, struct nh_info *nhi; nhi = rtnl_dereference(nhge->nh->nh_info); - info->nh_grp->nh_entries[i].id = nhge->nh->id; info->nh_grp->nh_entries[i].weight = nhge->weight; __nh_notifier_single_info_init(&info->nh_grp->nh_entries[i].nh, nhi); From patchwork Fri Mar 8 12:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586813 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 481711D547 for ; Fri, 8 Mar 2024 13:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902982; cv=fail; b=kb1VmS85XkPZ4XB/XYZXpWfp3OYUBp3Hsp8ZOvmRL59Ao6yDwctynVByYfRxiC0D2V6xDidIk1az9MouwWOVXL5SimdLErESyZlarxryP4gwNVPE1Fh5eYHzeAhJsCw5e3rJ9C4K+Lv3IAHwQ6r+qWSc/GVKaigiBMeddSX4rrg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902982; c=relaxed/simple; bh=Uheps32TVFKxxEyrpyTpcK/skwowJQehhEyZczsXNQs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B+gGcc2EoDLGb/nqUid4tWWQ+9lG7O7rWqa5Xet4c3tiPtqJbtj1fV9Y+MsMD8QumCBurac/WPsnpTJCS62mzcGu9a5YN/95sMFQApLdrC9WeVr2O6CfR8GGM0s0A39GXhzngFvbqD6fhMPO1LgNsuSs0iTcRyoy20aZtAPr0TI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=IUyXo2t6; arc=fail smtp.client-ip=40.107.223.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="IUyXo2t6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j23EA5Tud6qAdhdqfitSkkB+Z915SRThMk0GU52FaBnBE92zt3BqI/wWj6JR4N6STDoVDvsSYu/4wEXHoBSTFrST2hTcEYnukH5NKEPWDxQA1N8l/Hkj5P85Idr1FgGfotW34C+/GGzjmRD6UUqwfcLIdhmlqeobTv0wDluTBeyPsP7BQNZMr1faQvOGUB6BMj62BCSYQSeyJAaqlAR6ClJcrQuYNyCEes037NHkMlkV1KrFHXvB5x192oO88GVb4CFyzwGaz3jOwbVIdOmKQ/Yr9hH0gAQXwzf7jkPb7Y/qjwlHXqXT5ph7hKHE29JNhGLQYua4NXhvlKpdSO5uPQ== 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=DNTMt16pv4ook8Z67tdJNDA5EiJYrtftRFdqhSfRzPI=; b=dv+4c4fGw7fSY3cbVVBtzBcbi9xv9yBVmctRmvGoQUN5f+Fz1aN0C1e9fImdI3JLeve+3/a6f2PO8OMbdNaMRvxMu+pOuOQOARn1NNL+hJP2khe0cTfszkdoLB7wPaDTReIx1OaRQc61QstqNNze/MQ4wi/oM+IHAXe80OTwxD8X641ALVMtcN295P+tpAggF/3jIM1DlhwO3uUxS4QcwjR4D5Fb5vTd23cV+Sy10ngfRPDLqOmdrxQ7FNGbwKohnVtMdqq6nsoRmEPu0iRl//VCuiw9l2ThJEPTiqaqT50J34Z6uwQKA4zq+q6C7L5V//rgLf170e7zpB+7rdY3CA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=DNTMt16pv4ook8Z67tdJNDA5EiJYrtftRFdqhSfRzPI=; b=IUyXo2t6zjlDFRpVgfztnqsrXb2r1TQXukJOAar+XJ3lwis50hNWny7qc7mxaZutkS/SyH8jANNhjBMqE/RKGBr8Hc2LVqoJu2qMbyRJ6p1qgpQXH7eBo23neb2VmPG0W84LlfauIBx6JyDcGq+zrY4vQqKv+Ftjd6VIcd//PRLg0BblWqTTjiV+vamDzoVf5kJ9nlRqTiXzj+TN1MCnIp5eOmoDF9RkAffmSSUlBUsFQzELy0BpJ5YDvv1cUbK6Owp4OInI2PCW9tRZmoXtY9pdYjH6WOgq9dQ3/ThLyhQBxSGiH/FvcnWXJ0Q6OlfnHyL8d2uhBADnteMb2O5jYg== Received: from BN9PR03CA0610.namprd03.prod.outlook.com (2603:10b6:408:106::15) by SJ2PR12MB8689.namprd12.prod.outlook.com (2603:10b6:a03:53d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Fri, 8 Mar 2024 13:02:53 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:408:106:cafe::d8) by BN9PR03CA0610.outlook.office365.com (2603:10b6:408:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 13:02:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:02:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:32 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:27 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 03/11] mlxsw: spectrum_router: Rename two functions Date: Fri, 8 Mar 2024 13:59:47 +0100 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449D:EE_|SJ2PR12MB8689:EE_ X-MS-Office365-Filtering-Correlation-Id: 93cc4e7c-96d7-4901-5024-08dc3f701086 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lPZ1921qBQwLSu2dNXEPOAF351CJz0Y1K3IRdA2K+XAIfnelkrKJyDjRtYdPAb6p5kOjrstrwylhgpp8GhNVUDr2HAwOX2YRRaDZHNCGfDMdhbNj9i9wtxaB/mGAqhMhZbN2DnV97tiquEOw/+GYbXItWu4BUsN40TyJ+NWmSVsN6GGUX36Si9UKdAvPtQ+1HIWcpGn6r05U/BhmQJlm1ZBnUv72au+lE8ex3K2jiAhEJWN4TfvXaY2MLxNZZyKu9pmQiE/nLIliyAFqUVmeNw4ZiHBBiso53lCoi2LDinMGCJIQQ89/It+L3549hwXXxWPAOulare/Z3AOJEh0SJtI1+ghdXP4D526vmX7tKA1lk0+L8PsrhdPlygCWGZWakGaaV/7Cq2eEZ4sSSKflH7oua3DMtnnwaZUsx7PbU6Wcn880qTLckL2AQMvvoQdObATJICBUsNCF3PL1QCBp7Ofthsa6JKll8wwPmn/KyIIPpjK95ADozi84SuaZYywfYrVKTB4eLU75nO46cBtVay7cyLbdE2pWgqPhAZyKmoPaoZRht4lJB2fXTDHsDoJeZm1czdup8R5q5ku3iUgpCjrBCcg0u7Iizlio9G8S2x+y4NSgC94gBV4SQTb/GRbC1TCkQ+aYn7pOKWLDWh8lMOrhH+qKDWwZXMiKZpPrcLlnaPDPI+4Np0ajttrItusEbqYfzGuBmpqtE9Tqt3V40RELIzolYyO/ZXwYYJenWLTgETJdxZ/07nOOZiiP5611 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:02:52.3861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93cc4e7c-96d7-4901-5024-08dc3f701086 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8689 X-Patchwork-Delegate: kuba@kernel.org The function mlxsw_sp_nexthop_counter_alloc() doesn't directly allocate anything, and mlxsw_sp_nexthop_counter_free() doesn't directly free. For the following patches, we will need names for functions that actually do those things. Therefore rename to mlxsw_sp_nexthop_counter_enable() and mlxsw_sp_nexthop_counter_disable() to free up the namespace. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_dpipe.c | 4 +-- .../ethernet/mellanox/mlxsw/spectrum_router.c | 26 +++++++++---------- .../ethernet/mellanox/mlxsw/spectrum_router.h | 8 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c index c8a356accdf8..22e3dcb1d67a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c @@ -1193,9 +1193,9 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable) mlxsw_sp_nexthop_indexes(nh, &adj_index, &adj_size, &adj_hash_index); if (enable) - mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); else - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); mlxsw_sp_nexthop_eth_update(mlxsw_sp, adj_index + adj_hash_index, nh, true, ratr_pl); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 87617df694ab..9bb58fb0d1da 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3151,8 +3151,8 @@ struct mlxsw_sp_nexthop_group { bool can_destroy; }; -void mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh) +void mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) { struct devlink *devlink; @@ -3167,8 +3167,8 @@ void mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp, nh->counter_valid = true; } -void mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh) +void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) { if (!nh->counter_valid) return; @@ -4507,7 +4507,7 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, if (err) return err; - mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); if (!dev) @@ -4531,7 +4531,7 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, err_nexthop_neigh_init: list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); mlxsw_sp_nexthop_remove(mlxsw_sp, nh); return err; } @@ -4541,7 +4541,7 @@ static void mlxsw_sp_nexthop4_fini(struct mlxsw_sp *mlxsw_sp, { mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); mlxsw_sp_nexthop_remove(mlxsw_sp, nh); } @@ -5006,7 +5006,7 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp, break; } - mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); nh->ifindex = dev->ifindex; @@ -5030,7 +5030,7 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp, err_type_init: list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); return err; } @@ -5041,7 +5041,7 @@ static void mlxsw_sp_nexthop_obj_fini(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_nexthop_obj_blackhole_fini(mlxsw_sp, nh); mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); nh->should_offload = 0; } @@ -6734,7 +6734,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, #if IS_ENABLED(CONFIG_IPV6) nh->neigh_tbl = &nd_tbl; #endif - mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); @@ -6750,7 +6750,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, err_nexthop_type_init: list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); return err; } @@ -6759,7 +6759,7 @@ static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp, { mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); } static bool mlxsw_sp_rt6_is_gateway(const struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h index ed3b628caafe..bc5894c405a6 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h @@ -156,10 +156,10 @@ int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_nexthop_eth_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, struct mlxsw_sp_nexthop *nh, bool force, char *ratr_pl); -void mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh); -void mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh); +void mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh); +void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh); static inline bool mlxsw_sp_l3addr_eq(const union mlxsw_sp_l3addr *addr1, const union mlxsw_sp_l3addr *addr2) From patchwork Fri Mar 8 12:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586814 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6C9F1CD20 for ; Fri, 8 Mar 2024 13:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902983; cv=fail; b=jph3DKDXntPSObYZVzGoLHZRi3tzwSHsCvIUSNxyZzjB12E9S4tfpb8XSbTQ7vZt1jlcFD2ZDIxuKBaduabtZ3iQzQSKROYpUxrWAeRGOprOHJKV3Q6XdF5VmATVtMdPwEC73iwmmFWcNZe00P9NeK+DBf82a/KzjfYalkYVd9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902983; c=relaxed/simple; bh=b1Z502eE1pOmziyhkKqwwYV7Js69TIreh7QKy27rc9A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qu/3q9kb1gwfVFVCStN+exNj0fFqhUFC9vC0keAzQ8/F65nz8sWfNSf3jKsyl8AQjlS5wTIs8/lxFN3to7XO+hkTzLGrKLJmvLZbWdlICrPpa8izn7FmR4tMLLBE6fQBvlZ8Bde15mmZyrvVD5wQiGVWUqOfKsfU5NTG4K2oICY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=inoY7kkN; arc=fail smtp.client-ip=40.107.243.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="inoY7kkN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zoia7bUdy9WZvqntZsb7+m063PRYpGjbdUjVn3wCt++ImbaxemAyJToye7VwL8LM74G6+GOD27eorbWnT14Cq3gpHorDt7l6Bj/QWEfJtbbMeV6qQ1c6e7YiNsuLdTpvHmbsm2u6JxurdFq1VKsVQ4lbMDZN6dteDSsKzLcaCWm89ncKdHLH1fpNRgbXsjNr+d3VFKu5TUBleEeAuRKxDiIwPWuhZBrZ3UmXO2M5Y59AYzeHbrnCBmcdzgp5k6kVe9hgZ91M4di1uN1/ewvSrSLgNfIO2HXy8E1Xx7DyBzDmBl3RmX0CdTlztD9I+iiwCX3Fc3t5nDw7MQPc4CS76A== 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=u3khXWJaPaZwPLElsg/C5y9LC0+vM+nse3PRz9eZuiU=; b=c+NnOswOZJSOPZuIJtJM+1jYa9BKKkRpi5EbBV6i1Fk7EHN7/APIdO1isbnmjJbMTe21jiW9NdHMGoP38UY+cgwKD08BelOIoVoXnl6xY9jnw1IGbQIPP6GdFNgmkEDuHYPfU0735nD9QUohWLZ4PJks/NnDkS2KB+c6uA01WWzS7RGtj/N9Zw37fk0/QOpQUIMvkwx/x7UvKiDXzytHFv8Kx0vyWuh5nH+7pUqiY5qV0yZOoTAyxRjRSaDW9/cu9UlFjGs+fJr2Bv4hwcEUeeVV15cq5cRmWTsQoLWqwYcEi39jc2R0R5svHWZ8uELzzsgFwtqXwGc2iIjzcPyoDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=u3khXWJaPaZwPLElsg/C5y9LC0+vM+nse3PRz9eZuiU=; b=inoY7kkNNzTeadMVGiRb3x/d8AfZC6K1wc5WI8mE9t0qikKssvD7sGzK7r22Ljj+6/4IQrdeVQ4VZaZHKHA6mEFnlGA71Z85LwcCBCwrCcFMuWcho2sk9u13nK20Qccpo+LKD7GaSeijikNIumPONEwTXaN9RXHNoLBBukksUxs56BtutwY/XMhDASAQeVJv365Yqz9qJZF+9BzK8qFR2PT+r7tvsc4uBRGs6pkc+EnXL8k6aL45mWIxVlYNBBz11LM64WNqiTc3BtMucFmWQ1Eshw3LpAuLVrfw8r3zEqzUeEEDmUdirYXDy12HBq7Og0jHCXDrEWvU+wdetJkETA== Received: from BN9PR03CA0347.namprd03.prod.outlook.com (2603:10b6:408:f6::22) by CH3PR12MB8547.namprd12.prod.outlook.com (2603:10b6:610:164::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Fri, 8 Mar 2024 13:02:58 +0000 Received: from BN2PEPF000044A1.namprd02.prod.outlook.com (2603:10b6:408:f6:cafe::47) by BN9PR03CA0347.outlook.office365.com (2603:10b6:408:f6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29 via Frontend Transport; Fri, 8 Mar 2024 13:02:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN2PEPF000044A1.mail.protection.outlook.com (10.167.243.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:02:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:36 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:32 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 04/11] mlxsw: spectrum_router: Have mlxsw_sp_nexthop_counter_enable() return int Date: Fri, 8 Mar 2024 13:59:48 +0100 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A1:EE_|CH3PR12MB8547:EE_ X-MS-Office365-Filtering-Correlation-Id: 986131dd-0af2-4788-5d97-08dc3f7013da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kxTl6y8pmvQ4R1gv9BeTOoe21m8RNbaKhU/b4ZdQS/9PUCzLtVZDQEQeZNWGyU2xleO1jL1cM6QePqSGbs5+KA6FXV1O44Bpl2W0yXtcU6G5BvXYS+N6nX6BoNeiufzt4ehLRsTXOyfSFGE014Lj07W67oPGmiHRxWO/sNq1ZP8hlv3EsjNURC7s2ezOobREAfezpfPkjjh0YdtUfbiZGE6vo435owozU+IvTmMdxNkqvjBXI5SjKwuM8p2fBFSHn+W5X4K3hw0/fHapRgY/WB4R7DftOP7/1O0B8M88FjyY8qs39Nql3YRB2egRJJdJwuJSmVlXKGEAjzjQw5Q4sN9HZUiDGElwiJeid+qZm1ul6eeHsUInsiwQef3akfhNgWL2f7+8P4dpS1nHeO6r0Bfvc7OFUj7cqPdVuJTJGPRBKANoa7gYzTJgXrD8DoppLyODo+mLjH5j9Ff4FNUNM/cdDNaZChKxOycFmUifhz1t0tZ8bphVV03GeR1O/NcD5L4zhnfLZRfBho5pyM8dZo8zrTLcLIw9uDjSLV1G6VijCkHrb/qqFDt8pdCuhKXzquYlZPPh8SFzj+Yu3u5Wstror56QGoDKe7BHcArBPY5Nga/9DWhYgzSiUH2eGid9jiUGZRdGDaY8yKkhbGBWDC0pATeMsZ2zXMbGz8Sar7jPy8+9eYJb4RMTLsPqP2f+kqwSgITZkQfoTeQoDW41H2M27rVM6snbK2aJGnswz1x95gwbP4LeB1mOjsamPZIK X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:02:57.9701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 986131dd-0af2-4788-5d97-08dc3f7013da X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8547 X-Patchwork-Delegate: kuba@kernel.org In order to be able to diagnose failures in counter allocation, have the function mlxsw_sp_nexthop_counter_enable() return an error code. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_dpipe.c | 20 +++++++++++++--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 24 +++++++++++++------ .../ethernet/mellanox/mlxsw/spectrum_router.h | 4 ++-- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c index 22e3dcb1d67a..ca80af06465f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c @@ -1181,9 +1181,11 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable) char ratr_pl[MLXSW_REG_RATR_LEN]; struct mlxsw_sp *mlxsw_sp = priv; struct mlxsw_sp_nexthop *nh; + unsigned int n_done = 0; u32 adj_hash_index = 0; u32 adj_index = 0; u32 adj_size = 0; + int err; mlxsw_sp_nexthop_for_each(nh, mlxsw_sp->router) { if (!mlxsw_sp_nexthop_is_forward(nh) || @@ -1192,15 +1194,27 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable) mlxsw_sp_nexthop_indexes(nh, &adj_index, &adj_size, &adj_hash_index); - if (enable) - mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); - else + if (enable) { + err = mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + if (err) + goto err_counter_enable; + } else { mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); + } mlxsw_sp_nexthop_eth_update(mlxsw_sp, adj_index + adj_hash_index, nh, true, ratr_pl); + n_done++; } return 0; + +err_counter_enable: + mlxsw_sp_nexthop_for_each(nh, mlxsw_sp->router) { + if (!n_done--) + break; + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); + } + return err; } static u64 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 9bb58fb0d1da..23b54a4040af 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3151,20 +3151,23 @@ struct mlxsw_sp_nexthop_group { bool can_destroy; }; -void mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh) +int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) { struct devlink *devlink; + int err; devlink = priv_to_devlink(mlxsw_sp->core); if (!devlink_dpipe_table_counter_enabled(devlink, MLXSW_SP_DPIPE_TABLE_NAME_ADJ)) - return; + return 0; - if (mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nh->counter_index)) - return; + err = mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nh->counter_index); + if (err) + return err; nh->counter_valid = true; + return 0; } void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, @@ -4507,7 +4510,10 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, if (err) return err; - mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + err = mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + if (err) + goto err_counter_enable; + list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); if (!dev) @@ -4532,6 +4538,7 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, err_nexthop_neigh_init: list_del(&nh->router_list_node); mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); +err_counter_enable: mlxsw_sp_nexthop_remove(mlxsw_sp, nh); return err; } @@ -6734,7 +6741,10 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, #if IS_ENABLED(CONFIG_IPV6) nh->neigh_tbl = &nd_tbl; #endif - mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + + err = mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + if (err) + return err; list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h index bc5894c405a6..0432c7cc6b07 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h @@ -156,8 +156,8 @@ int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_nexthop_eth_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, struct mlxsw_sp_nexthop *nh, bool force, char *ratr_pl); -void mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_nexthop *nh); +int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh); void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh); From patchwork Fri Mar 8 12:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586816 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC2731BF37 for ; Fri, 8 Mar 2024 13:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902996; cv=fail; b=Ss8je4I5GQ4cSJ+jCRkVDnERbiGHFL8tUIYaYHe+6nWZLIiUwNiA63/HEGMoE4yzNrUD7q8Y4j2eZRmP6XB73b4+hWPAtKtnvB9RoGM4TjzK0tY71L24w6mo/XgOKaW635TJTYW4whjRL59hbsFzW58pegHp5Ya+0LL9ufUDd2U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902996; c=relaxed/simple; bh=nnzWd1nyDoYsE+9tfNGu5MTrUjNefN0+vzwqwuJ9Bxo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lyUISkFp56vkBhZZu+yxAeL1GaJWtw1xwkbD9rX72SU+B9gnnlxUPIpeZPAWvbun1snuso3I15QqOwJZSF+pvAMDEHm1kiG2hjX5WBAduTGSwT7gq1PEQ5un3tTF7yEBzNlkgjt4MMQHK3xWne1Eeowbo5B7hr7mmFwTbGGS7XM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=R0cBXZMn; arc=fail smtp.client-ip=40.107.244.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="R0cBXZMn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjBJckG6r6doTJd4JuMGrF9zSfzwZDqaBIFZMRqwksq2nKmjKgLryWDgaZm9XSev9ZyWuk4dixPnfpQasPIDOjaXO+Uze5lgAJfPNhKUp7fcWYUV9xQY0/qAjEh9L3ARJE3st80+Rf84c57L3NwuStC+ZaQpNY/gPuRFKA8ZoscbIZ1vXP2Z6ATrEGNxl8y/aZHYaJDZxOj4X5QJSg0sWvBy5V4c5DJTRZSJMGZPLqIhRTo4y8xwTlUm2LdoZvjFlJ188wkrppqF9tzVYoYW6Wkzy+F6+ouGh41ZUtSY83JJHmelNA6h3rQfUKj7RDDSh+ieBD4LqOuWIREtf/tMGg== 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=qmmRghU9CwUyMOZTwZ4B8G9VGKz/luvm3EJLEgSZbRk=; b=AyCWeCP86XJY8XjupkiBWVEolOZtdMm5dADNXmuRef/aVfCSNP1WdfPYjYi1eWXbIHS/Xrn45pvp4oksDXdUaru885Vvka1qhVsk+VjvwBcnh2UixHXsW0RrFhPgYzsOUTudlxp6ScuxcUsr+fayF5wIOXujLvAUR01CgurXZzSvVKvWn2LMxnep551tgxfg5DmIrki8kq+NA8d9RAtlEFGuS6KZFt0NWil7G1Ph9nwTE81nxq1M27MzCiCyD0WRiwKWpI2I5+feEzzFAS1XCchfoCoMQwFBFYXobeZbDj0Nz/0fT7rENB7+OE1M7wkWw1CGddjAJe1P+HiWjyExFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=qmmRghU9CwUyMOZTwZ4B8G9VGKz/luvm3EJLEgSZbRk=; b=R0cBXZMng6iS80YP17a2C8EGC5pQ4W61Wdw+nK1kjXCWJaBcBYOU+d1P3gUTROpYdR1RPL0bDHUkuOOkV4FF5ixMz81rT7pzE48B4jfS6RT4ihIECjWFHz+uw+hkZ+xED6XCu+mMVD9DlW0YOqaHBq2VIclXD1PFnayw7OR76orhkqud0zoxT2oEBDHcC5LB5qnDXitpN/Nzluqb6TmUFYJKhnMPEzHGr21mAahIkX2wWojToUDlUXCRLnCJ36qpp82TakL3Naeg2EjKca1lOhf6+Au3lBF1AZncWjy5+W1WBceiaRJLmqvLGko+LJZ0USK9CWUeYouJVwug+Z2xjA== Received: from BN9PR03CA0341.namprd03.prod.outlook.com (2603:10b6:408:f6::16) by PH0PR12MB8097.namprd12.prod.outlook.com (2603:10b6:510:295::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29; Fri, 8 Mar 2024 13:03:07 +0000 Received: from BN2PEPF000044A1.namprd02.prod.outlook.com (2603:10b6:408:f6:cafe::56) by BN9PR03CA0341.outlook.office365.com (2603:10b6:408:f6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 13:03:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN2PEPF000044A1.mail.protection.outlook.com (10.167.243.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:41 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:36 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 05/11] mlxsw: spectrum: Allow fetch-and-clear of flow counters Date: Fri, 8 Mar 2024 13:59:49 +0100 Message-ID: <6a096ede8ee92d5041e3832242c3bbc137198aba.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A1:EE_|PH0PR12MB8097:EE_ X-MS-Office365-Filtering-Correlation-Id: ddc6796e-f98f-4ead-6bea-08dc3f70193c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +7B2jbja9cBOzkRoPO0ljPMiVWJ/JPMbrTHYo9Rcslq91E6c5N4qoyOezCfn2stVQyqbaHdV7dyE5NWtVpVDtOh46KLBlmk7FUQNNm7ObiR0FnmsFJqD7bdEQ4gmJDk2noqYmirh3O0z2H7Y2yOBQAHv4aTa9ioQh31uA/wxKw3bjYgD7VVovrGe4ljPApu3GY5hO0MP67Tod2gPQhFUfXdN8rgtoopF3tK/PpkArNHXwX5XfY3dokXFYBz6EiS1fCQAdLsFHZdlMR9N34QQPgKLx9XFH7dXUP/c+yGMd/ph33WGBn6xnHN19EhA1QMwgMQhuKM7FsJfS3mjoFGko9/0sdseRpbtIfZhYrocybJIT/rf3ZiVbchv3g1op2J+YM4YNcsnhC029RDXiElp0+Ve0j+p0lQBoavgYJMk6x5Wx7s10GltaxS+uomos5oarf4k5v84QbXyCigCy/OChzbR2Df7S72CyNG7EPGnM8tyiv4jpAgveEnnMwLPXMvN3rptZ1NvWDXjznhTBUXgd1Z80qIT9bfmcquTJ78IY3mrZdVhCmjSDJIRkiLZKK2XVvYehtBBJUIm2KfA1i2lrWC+et409Dzqb5tGtwV6i/PaI7maIVXFmmUZB9ORyDS/nti6oBTIAFG+sA3lolV3BiZTGz+RGESdaVNirw8RlqbF1XkVY6i9thSIckukHT4oA3YY9jtyVm7IziL8jtnDPhtD2QKJK1vCFsWfXB13NJFP29mnJIUlbo1FAoZ9rlRu X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:07.0013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddc6796e-f98f-4ead-6bea-08dc3f70193c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8097 X-Patchwork-Delegate: kuba@kernel.org For the report_delta-like interface like a previous patch has added for collection of NH group statistics, it's easiest to read the counter and have the HW clear it right away. Thus, change mlxsw_sp_flow_counter_get() to take a bool indicating whether this should be done. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 +++++--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 4 ++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index ecde2086c703..bb642e9bb6cf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -176,13 +176,15 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 16, 16); MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4); int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, - unsigned int counter_index, u64 *packets, - u64 *bytes) + unsigned int counter_index, bool clear, + u64 *packets, u64 *bytes) { + enum mlxsw_reg_mgpc_opcode op = clear ? MLXSW_REG_MGPC_OPCODE_CLEAR : + MLXSW_REG_MGPC_OPCODE_NOP; char mgpc_pl[MLXSW_REG_MGPC_LEN]; int err; - mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, MLXSW_REG_MGPC_OPCODE_NOP, + mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, op, MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES); err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); if (err) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 898d24232935..3beb5d0847ab 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -706,8 +706,8 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev, int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, u16 vid_end, bool is_member, bool untagged); int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, - unsigned int counter_index, u64 *packets, - u64 *bytes); + unsigned int counter_index, bool clear, + u64 *packets, u64 *bytes); int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int *p_counter_index); void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index b01b000bc71c..3e70cee4d2f3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -1024,7 +1024,7 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, rulei = mlxsw_sp_acl_rule_rulei(rule); if (rulei->counter_valid) { err = mlxsw_sp_flow_counter_get(mlxsw_sp, rulei->counter_index, - ¤t_packets, + false, ¤t_packets, ¤t_bytes); if (err) return err; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c index 221aa6a474eb..01d81ae3662a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr_tcam.c @@ -361,7 +361,7 @@ static int mlxsw_sp_mr_tcam_route_stats(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_mr_tcam_route *route = route_priv; return mlxsw_sp_flow_counter_get(mlxsw_sp, route->counter_index, - packets, bytes); + false, packets, bytes); } static int diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 23b54a4040af..2df95b5a444f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2251,7 +2251,7 @@ int mlxsw_sp_neigh_counter_get(struct mlxsw_sp *mlxsw_sp, return -EINVAL; return mlxsw_sp_flow_counter_get(mlxsw_sp, neigh_entry->counter_index, - p_counter, NULL); + false, p_counter, NULL); } static struct mlxsw_sp_neigh_entry * @@ -3186,7 +3186,7 @@ int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, return -EINVAL; return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter_index, - p_counter, NULL); + false, p_counter, NULL); } struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router, From patchwork Fri Mar 8 12:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586818 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B181376F5 for ; Fri, 8 Mar 2024 13:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902999; cv=fail; b=Anixxef8OqjFoaslpcZvlJjuPeMDHK+yqBm64c5yrMpsoIgx15QG3IZYEcuKB69pr9lX8ElQm7FkqtfoZUBAyN/7yRrJDHmPJX+xZ9PMRq0w8ysMjiTa7FlQOTmLzLOrfrXuX0uC70knZh75zEhtdnh9t/jxob3UAGzCeBBeAYc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902999; c=relaxed/simple; bh=WEQRL4Qu8tUrLn12bh8NJauRJGQK9lzC0uXB/JnKozU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g+aAFns9QU4L279/YziEwZGPjmRGJcnE/S+6fmsbrtl6TP+rOvNPPT8udHaubSIHecCEhKqZyhaqXvTdoulo/oDT6yX08MTuKo8Hh7TS3k5QGfAuET+CORoNe123Sa+iFPpl5rW3dFLov6ViRvDp8aLyHr1Re7wUGIDdCXVZue0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=q9ShGxVF; arc=fail smtp.client-ip=40.107.220.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="q9ShGxVF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXChU5bXQUGnjtogUqRClFtsfo6LJl12PdYUMoVJInDiqJ06rbBeM3R83f3TCqt+ziUJ8XKRDP9gjtloJOAp+QRgVc9BOgLQSV01oW3GT1krGdVw+6wlzm5fBVPl3GI8bBaiRQDZ1fTqcUViXzNvxhSva8ZSmAwUBj2Iomu61t5fgh53WuPPlpjATUUWMgj01ipmFQ27BOZnQrig7aR5lAreQZ5Ar/d+HSe2fIOPv/0xmk8DjjF2QuhMmfJfz83+xAvcK4NzqcPA1fsXIuxLIgsTG4jGbR+m3teixoR92IeV9vPMSWuullyGIi/LU34YdHumQoa68AI4txSe8Am3fA== 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=HSBRiphpevI7+iHILAIOXSt14wWcUUEQ1ezc+Bnd2BM=; b=oXvwVsVvE0ruQKsTRmZ0iZqByUn6MPWv/XAkG9yvc8wXVmp7kmIfYCyBTkKsvQVTzbNvz6kdmgpuAnuVekZSm0fzaZ+4CJ8hHZT16V6fr8GGWzqwW8FE+emQQwyNVbEDKhR5907gtJA7mN1OLYimeRO4RJpIvnMszp1/Qx5wW19mNE2pcRYut/kMydHMi1lSJy/XnZpO+ImUCuNIP61W+QXfNbbb/rn1+U1+Ohpmsb6XDlGX6LD5B81w2OqABHdmvrfPvqZPrkEFsPxgQK5o1UtMPxm53suNG436TNebsdTsJ99CPPcFKDzxx490rkjKHbA8PzFbniLhyPmOLdDfHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=HSBRiphpevI7+iHILAIOXSt14wWcUUEQ1ezc+Bnd2BM=; b=q9ShGxVF06kQP9ZMeWwXMqrjw1KPLH9bfhUC6/FPWW9l/h5ajxhimSZnLSan0XFzP+K/prFVM3NkchPtu06jzzcaVd9T/nOV5xiwvFRkjhb3VhrR6AfbSpS8AGUqe9YjwT0mJg3ZmnrtmYM58u4/57xBkZu4wARRNHsHRtyxtSHL+KsIQr2jAqUzJdnx4MnBOt3Dgk/vU5G0vHWsKWGXLoMFCf/AtmgJCpYaN0tt/bQZ4OD6alPcKTZJSatv3i3PEblsVLGO4l6T1LWCeoe6+eXmd1rDCjK0mpIM5lhv9O7buwF9CveyW9jAf+adVxp4NKkb78V1Cz4AnBUr/oS+BQ== Received: from BN0PR04CA0156.namprd04.prod.outlook.com (2603:10b6:408:eb::11) by DM4PR12MB6424.namprd12.prod.outlook.com (2603:10b6:8:be::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Fri, 8 Mar 2024 13:03:12 +0000 Received: from BN1PEPF00004680.namprd03.prod.outlook.com (2603:10b6:408:eb:cafe::e6) by BN0PR04CA0156.outlook.office365.com (2603:10b6:408:eb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.31 via Frontend Transport; Fri, 8 Mar 2024 13:03:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN1PEPF00004680.mail.protection.outlook.com (10.167.243.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:46 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:41 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 06/11] mlxsw: spectrum_router: Avoid allocating NH counters twice Date: Fri, 8 Mar 2024 13:59:50 +0100 Message-ID: <0cc9050e196366c1387ab5ee47f1cee8ecde9c86.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004680:EE_|DM4PR12MB6424:EE_ X-MS-Office365-Filtering-Correlation-Id: d1ad33ff-c688-423d-c112-08dc3f701c2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VRG6wFLQ4zUCt/rp4ak0CzJR17GmMjq9eyk51xG1jWFnNjcNEDR1bvqmF84+tiMVaG6IRpnm1h6xmmbvGpYep1nP1nLMGwE9He8ozIr/kq5sQOjhTTTN2VjM6KYu5VMEh8ZGsc2AAGW2a9Kxx8AApN7ncBMxjUJtesnlM9SWx26RbrAovRHxjH8frClZG44Cafw4I9YXC5diph1PGm0BuFQPfOovBgEV0zOwVyyBxa0rCIiaciIMQf4ghnutjmW5vDDsoh96FlvKE1422mJ0s+nCVe72FnU0QDedqkP/qVfwemHU3h+5Zl1K5EJTOY7Fy3mFcOghjgJ1PtdHWW+YZBe080MTN5nFeS6LivVt1OyPcrgsuunqsA5doP/MIJ9nYferuMFi4f2pAXn7f1J8bcnFlY3oMynZCLX6CsR1DMTDFDypgj5F5cEp8yvwec+2JhPDZpdNUdJjz8w7PJO5CamuGnn2HLNl431jF9S9Bt8jwhpNJ1DEgKaON37RhwYpp/eN9SAeRV+jmPE9b9/K6+TyuBlrOoMWaos1i2g8UE6gYH/HZyh5u2o16IGvyCcgEMEGo2Yx1UVT/npmZhXbYX4m7kDbu5AnVL0Td4nPkEY1Qllpyw5B56Y/NeNeY4x3PQGzPn89xaNPdn3ARkA0tPDLMLRRX2OMF01F6ORzqg2A+WfFRCCTD1q3hVeI7dAf31ZobEhpwe3rtTntFc+GJLP8wU0T4kRUFBhlyVFOZk5mnYPLDSVYQF7AKkOCT6lG X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:11.9515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1ad33ff-c688-423d-c112-08dc3f701c2f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004680.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6424 X-Patchwork-Delegate: kuba@kernel.org mlxsw_sp_nexthop_counter_disable() decays to a nop when called on a disabled counter, but mlxsw_sp_nexthop_counter_enable() can't similarly be called on an enabled counter. This would be useful in the following patches. Add the missing condition. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 2df95b5a444f..a724484614ab 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3157,6 +3157,9 @@ int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, struct devlink *devlink; int err; + if (nh->counter_valid) + return 0; + devlink = priv_to_devlink(mlxsw_sp->core); if (!devlink_dpipe_table_counter_enabled(devlink, MLXSW_SP_DPIPE_TABLE_NAME_ADJ)) From patchwork Fri Mar 8 12:59:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586815 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 900EE1CD20 for ; Fri, 8 Mar 2024 13:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902992; cv=fail; b=tpYyeOJ5piD8bzKJehZtmQy/DvzQIYQRWvcvgiBurfDMe36WumHvgfDsyx0oMgsreJcCOAgLhR87rDIo1rSDUlisKqnCGaHNwyTAuI3BMlPcZwxTyXdia15pelMYGFrL/2bpO7OL+5S6JWLzHrwMDu9P0Mz4ArYxLErER+ZoET0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902992; c=relaxed/simple; bh=ROSIIi7AsmMDXDtWdIe7kQuU+SIVMlu3JA/UeNSeObU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SURzOZJ2zODnD1+/OXXBXgMYhH8vzHbrLvbzQtHCwUJMHzGIYlwi0hRfnG3SU87sCWXbv40Kv+xmEbTAwK47kFRA7v5r/qn7Fot6R7lVTkYkkJBzTazYA+cNUAnf4PNkKW6PE0kUT/une8rni+dhg6zYh3CcL9841OBg7VKVLiM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=f7zB2q4x; arc=fail smtp.client-ip=40.107.237.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="f7zB2q4x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XpGToEARUy0siDSyT+67La5zSVLQlpFlmDJUjccM41TlttbJpOEsBFw+Y9jD1YLiAm8zxxhnT5c0Z6KyXt/zd2yk4vrP8XOh8p0O9zxfDWPbQBOiwUc8E8ZoSB2KQ7fRmLUhfsducKIjDls5pdWl/pTMzatQNKyZResiShig1WhWWgjcr+GkfZngtdEVDVpERjHEZ4PmP1oF/s9fbbnUQs6CHSMCPTHp3p5wNF63qHn8nmUsDFuk06xNbb55K8IO1GRhHDmPkhLKdqI1CnELvj7m0Yl0VsDsLazofDdRQIFyH41HEfOBAnMebrBHgaMSVmbgC9C8OWkirh6xQ8NwNg== 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=zzro2YMAvjFu5gJ5cL15mw+EYu3cMpht/X9Hh6GgoWM=; b=MtFeOBf/Aj1kxBQPQw6vJG/wF/DjBWOSk1anN7SYamUgnNQWx1C+bjPZaicIYiC5pdKO2gJtNRAQt5hR779067x5FeeIoCIrCTKDjKoO29IxPpw37Oi5oYWLavECSPJsOq7CyMKMj5ZYrEZD5DtTAldxqAaCWgpVde1YBOj1HtwJE5DlcTDlVkmiY/mzbzQgLOFqYsob7+mtHIbZLrd5sUbea60rIhIZRx7Ivmcs7xRzBx4xUCbNverUzGIoIciyyZj/ARIClEYjgrCU5X1NWuV4T/QbLcFJJbswmEFzPlX26dsM/JoakUsCFY7XTHSgebn1HKG01tcHNVqf29g25g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=zzro2YMAvjFu5gJ5cL15mw+EYu3cMpht/X9Hh6GgoWM=; b=f7zB2q4xivNCSy3YQRjRLMoDZtlMT/IzapqlBxuZFzTgXrtegQlHqBE2uaLfdnIBez/0myxUbPZH/Eq37ntITWWmXQJX9rep7P3RLGjhvzfDHhsmdKT/lR2sH7SkfLotzBILgIqkirtnVVwBdOXMocfkOOpziibGdjTcJoIV9sUJDXDJn2F+HkNHlkqFRel+/pfRfCaWjKc0R00gthEUlbwB2X8v5+mHhuzELBPgaONbsPktC4CQf/MZ1hQbcpCjUlZf2/seazIguYQRjcXVadrjYpCcQIxdyVQbDGyrWUbJrAPuXlxLJdt8q+z6Gvg/+9+JW6Q7Et9Z7nrWgLrU2A== Received: from DM6PR07CA0066.namprd07.prod.outlook.com (2603:10b6:5:74::43) by DM4PR12MB6086.namprd12.prod.outlook.com (2603:10b6:8:b2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Fri, 8 Mar 2024 13:03:07 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:74:cafe::92) by DM6PR07CA0066.outlook.office365.com (2603:10b6:5:74::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.29 via Frontend Transport; Fri, 8 Mar 2024 13:03:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:50 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:46 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 07/11] mlxsw: spectrum_router: Add helpers for nexthop counters Date: Fri, 8 Mar 2024 13:59:51 +0100 Message-ID: <61f23fa4f8c5d7879f68dacd793d8ab7425f33c0.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|DM4PR12MB6086:EE_ X-MS-Office365-Filtering-Correlation-Id: 56f88611-a3e7-4463-9e8a-08dc3f701926 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i/m2lm17FWYkY6ZuF+ZXi90T3l9f3uJmqkikFbh9o3JNJRHkZA3ITHv8Fbiz3w8ApTHgvJBmKrrWf6yMu/H8UILtrL2erxIig6cPgWZIsIdugZ9VA9HngbwS3FjKnn45oGwqHkQVp5C1ZKq5dIUpvGKWvHB+Ay6B1wuiueLD7zMMBe/g8rt0VOjsqEM+u4B8usw2791na6GgpeuysICweo+nsdFY3pQxBvFUfvg2zcAmTqDyBY+FartsYwSx0T4++dBgS6bF2bzQgWWiH/2ckaeBf1sD7SZtg+R47Mcncqb60kxmNM9KIPgBTfEaGVfpctVE99j9popZs3lJj2s9qz/3jvrSY7VG/Erm7dRKClDCe5c6c3GkESNJHQHhQamKFW0pAVUpycsV89rjEWuSSda3+RLLgQK6kqL/gpKKEcQSx1WMeheZuWc9u3JsEL8hcSnjTQOVeE4HXDT+akXFM8GROJSWVgFu8hSAfjT21j2QcWYLfLfSKKRMot1OnpkjtjD822OwFAvhiVsh9yW8nJ6zoLmUyEyHVoag2VZIz3CTxRdyjdqMBtU2t6dyw96m1LAym4w7Y8wKTiTzHsLVdZCe2XtzVdOYq9K2kwxI1/3crVIXExc31de+rw5DTiKFDJEAYX3UpcDVvpxTqrFDbHOHdW8CvmzH4Yxg1CT+bR6ZaVPHQRDUhqeNi2iSAg8K5mymaMtJ8OUm68qhXs8D6nT/77C8zAnnVNjOqaRpy9Z8+gLz+udzBimNdL+1Zm7I X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(376005)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:06.9053 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56f88611-a3e7-4463-9e8a-08dc3f701926 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6086 X-Patchwork-Delegate: kuba@kernel.org The next patch will add the ability to share nexthop counters among mlxsw nexthops backed by the same core nexthop. To have a place to store reference count, the counter should be kept in a dedicated structure. In this patch, introduce the structure together with the related helpers, sans the refcount, which comes in the next patch. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index a724484614ab..73a16c328252 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3049,6 +3049,8 @@ struct mlxsw_sp_nexthop_key { struct fib_nh *fib_nh; }; +struct mlxsw_sp_nexthop_counter; + struct mlxsw_sp_nexthop { struct list_head neigh_list_node; /* member of neigh entry list */ struct list_head crif_list_node; @@ -3080,8 +3082,7 @@ struct mlxsw_sp_nexthop { struct mlxsw_sp_neigh_entry *neigh_entry; struct mlxsw_sp_ipip_entry *ipip_entry; }; - unsigned int counter_index; - bool counter_valid; + struct mlxsw_sp_nexthop_counter *counter; }; static struct net_device * @@ -3151,13 +3152,46 @@ struct mlxsw_sp_nexthop_group { bool can_destroy; }; +struct mlxsw_sp_nexthop_counter { + unsigned int counter_index; +}; + +static struct mlxsw_sp_nexthop_counter * +mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp) +{ + struct mlxsw_sp_nexthop_counter *nhct; + int err; + + nhct = kzalloc(sizeof(*nhct), GFP_KERNEL); + if (!nhct) + return ERR_PTR(-ENOMEM); + + err = mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nhct->counter_index); + if (err) + goto err_counter_alloc; + + return nhct; + +err_counter_alloc: + kfree(nhct); + return ERR_PTR(err); +} + +static void +mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop_counter *nhct) +{ + mlxsw_sp_flow_counter_free(mlxsw_sp, nhct->counter_index); + kfree(nhct); +} + int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh) { + struct mlxsw_sp_nexthop_counter *nhct; struct devlink *devlink; - int err; - if (nh->counter_valid) + if (nh->counter) return 0; devlink = priv_to_devlink(mlxsw_sp->core); @@ -3165,30 +3199,30 @@ int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, MLXSW_SP_DPIPE_TABLE_NAME_ADJ)) return 0; - err = mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nh->counter_index); - if (err) - return err; + nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); + if (IS_ERR(nhct)) + return PTR_ERR(nhct); - nh->counter_valid = true; + nh->counter = nhct; return 0; } void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh) { - if (!nh->counter_valid) + if (!nh->counter) return; - mlxsw_sp_flow_counter_free(mlxsw_sp, nh->counter_index); - nh->counter_valid = false; + mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh->counter); + nh->counter = NULL; } int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh, u64 *p_counter) { - if (!nh->counter_valid) + if (!nh->counter) return -EINVAL; - return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter_index, + return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter->counter_index, false, p_counter, NULL); } @@ -3662,8 +3696,9 @@ static int __mlxsw_sp_nexthop_eth_update(struct mlxsw_sp *mlxsw_sp, WARN_ON_ONCE(1); return -EINVAL; } - if (nh->counter_valid) - mlxsw_reg_ratr_counter_pack(ratr_pl, nh->counter_index, true); + if (nh->counter) + mlxsw_reg_ratr_counter_pack(ratr_pl, nh->counter->counter_index, + true); else mlxsw_reg_ratr_counter_pack(ratr_pl, 0, false); From patchwork Fri Mar 8 12:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586817 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2041.outbound.protection.outlook.com [40.107.243.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77D9CEEA9 for ; Fri, 8 Mar 2024 13:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902997; cv=fail; b=pZkF+rclRrDhhGSyEoUH13tXBrffQcGHpKU4ZwvVuTruoAGDViOFR5zrJxe2FW67M4BRBkIRL3q5uf7CxaT3MzJ9ItYxiTAOVxv5neRUfgAQdMPVMswD7uxKWhPCUM23A1wtpvqM11aFQyQGH9V8YSVaWJtc4lU4K05zGHmLBoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902997; c=relaxed/simple; bh=o0HQpejV6Ud33l8KxdW3qqcnd81FoKqPLOpz7GcXyIU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ec0rqgBp38f7zotk5svZ6+X9Ww+UtHxYkifWJaoa4uFBojQZFzTbvTjEnBWl2wBJnMv6Y3zt4lHWH89OkKQurB+HKNr2O6bXQG7iZnPxwKkRbaDqoOVMQJj9ClYHB0yAF8usXuoQin6CGDix9/oekfCQoPXz6GNmNyRZ9ij6FEg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YwhudCvY; arc=fail smtp.client-ip=40.107.243.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YwhudCvY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YyvFlDzCZ1ni1EIQ2U7iXVum6t4p0BpRUGx/Xb+LT6nfofbJPBPpQOdSswJG2IQzua1Vn23RfoIIuqRvEX69H7/zuiQZXWgwtX5W7+3+K64IXG/pUH+FrtWTQ9OO1GePKsqO/S3rPxEEqkfCMDSrxCyI+H8gCCOwzTGIg2jH7mQFVxxXUqRSHoPI6eBQyhWGIa7CH0PDWjh2JFAQQLx7kHFv54iP8IVj2VO/Us5Ec5YK/nv7INNbuTVgKEZZJeLBqTVqT8tTtog/eUep5jH5Nox6BZo0xxynVkPoBRUGMLFBJibXC3op4e9jSjR6haxhZ/aAsocucbqEDpNQC58Udg== 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=32HlKym3Vt7mqKQp0qasWHD1Qz0h7xDlXB7CKvRnRjc=; b=aDohMusss7lDVNne7mDQ+qQLcOzjCRKDv6b5apzC6vJiiYEY+i8ToZArN4py7nyxngVJ1WdKopnl/Y86F7StGNlyLNSXuZJ7MVhgChSoB43x6hvaq8+/SKC4Kz/8NEEZiSpRhv4vC2mkL0E4oX4Tq5f75iE6kzuTQpatGQnZiLkDW/X+PHvfBHLzr0Hk9LRY2/8Gsz5Empwu7KkQ5h5tBXwl8aad8DXQKt+I2oUmylA8RAYfi34OHPn1eAfeKCHcGSzl008Hv6kY6pXiNmUh1nkfRecdNxLqhCPLVZxu94eaTRgaMtRGYQoEzNVxXqx+LqUcTYwETAFajkrRPQJ84w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=32HlKym3Vt7mqKQp0qasWHD1Qz0h7xDlXB7CKvRnRjc=; b=YwhudCvYkSTzjR8xSiomfdMzEmRmjHMuLNlvJIhZE84m5XkGvy9nO1Bha6fejiNu8+R0tNX+0lgObnBCwOL/uCmfFFfYqJ1oDdWaWbX/pWXpG5sJWcygSTPE5Zg+K4Y9hS1Xp4n3kcovtMa4QfUeWL0+xb+eNI8PMrRDNEp/43q3sJCLoN5JT8XKA7q4vFxsz6tiJgaPzIm+PYV/foOs44gxznCSLgR6p+K+2gBRJdtKqGj+xwiaWRvnyfznRjcQ3U93JTVLPCDKIDpbRfof3oU/6x+Fba4awCANkR3khqEFrMoM9gIqtrY/Nk8U3gpGSE/wMdA8uxDKLZVtYmKAPQ== Received: from DM6PR07CA0063.namprd07.prod.outlook.com (2603:10b6:5:74::40) by MN2PR12MB4359.namprd12.prod.outlook.com (2603:10b6:208:265::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.28; Fri, 8 Mar 2024 13:03:10 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:5:74:cafe::8b) by DM6PR07CA0063.outlook.office365.com (2603:10b6:5:74::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 13:03:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:02:55 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:51 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 08/11] mlxsw: spectrum_router: Track NH ID's of group members Date: Fri, 8 Mar 2024 13:59:52 +0100 Message-ID: <184ceb6b154e08f5bcf116a705b0fcb01c31895c.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709D:EE_|MN2PR12MB4359:EE_ X-MS-Office365-Filtering-Correlation-Id: ec251411-b011-4e7f-00ca-08dc3f701b3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DV3eng/NtUa33E4QGaaWyAa81s4zDKz2FdkqigQ1mT+QBmtz7JuXlZbqzDjJ7U+eFfyFitNYJRd6eVqNyIjYl0QEZrMaRW7lutgsvlr91+mYvRGLMICyJtIZE0LH5IKhK9Q7JomxOo8h1JATQicqczCCc+/TkwDirfn+bivXr3K40/DC+EsQp5QSlDS9IvhZY0AS7RS+0kS6wes+YnvDKfDKmwkBdaGPqVGWQLJbBbORmEqmka9aWuZIEiJ6lzcHa7JGfl+rhJqiLHXjxa+SKu6jPW0+FPNlb8VUqo4sqi1fyW9SdOmfTpfEZxYpuE+5+XrM1EEyIDWNy9KsPNCzyGugLEFTX/yfZEkhtpO9NakxB7Of6KtJNmg/jr9mWeRRtbMidqoYr/gtu8QBwAS9me0KVYvYDtij3PHLVZWKV5IGE+a3p6JNXHsUh81eJ3SQ/5wqOVfo7TEoHxpxjkvPxuS2tEu1Bstk57t7oGFOOEDll0ZxSwdFKEGlYEMgSHTxZXi5DKeFF+Cfn359wIog9aF71PVeURUYcU1QfJtxsXRx83/C6MRPHlxE6qCmkTmj0Y8k5KySwtDzL3xXC78zTDvYIDo8hlzSbx0Eq5IRcmoIQBfoDET6aPxGUgLW6P8ZdTAX4ZavFXB7IqUaZCeJBo9xnxJl/Rd5ip+5PmX2hziSAaqdHCbagd/haI4FAmENGD8O7hXQUF4v1ZYz6HojMxxP29c3/e08dpTZ8BwFRf3fwFqjacEwT6JII7ZyDT66 X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(1800799015)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:10.3878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec251411-b011-4e7f-00ca-08dc3f701b3a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4359 X-Patchwork-Delegate: kuba@kernel.org The core interfaces for collecting per-NH statistics are built around nexthops even for resilient groups. Because mlxsw models each bucket as a nexthop, the core next hop that a given bucket contributes to needs to be looked up. In order to be able to match the two up, we need to track nexthop ID for members of group nexthop objects. For simplicity, do it for all nexthop objects, not just group members. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 73a16c328252..922dcd9c0b5a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3083,6 +3083,7 @@ struct mlxsw_sp_nexthop { struct mlxsw_sp_ipip_entry *ipip_entry; }; struct mlxsw_sp_nexthop_counter *counter; + u32 id; /* NH ID for members of a NH object group. */ }; static struct net_device * @@ -5054,6 +5055,7 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp, mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); nh->ifindex = dev->ifindex; + nh->id = nh_obj->id; err = mlxsw_sp_nexthop_type_init(mlxsw_sp, nh, dev); if (err) From patchwork Fri Mar 8 12:59:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586819 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2053.outbound.protection.outlook.com [40.107.223.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F93636AF8 for ; Fri, 8 Mar 2024 13:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902999; cv=fail; b=W6UmeD9oBC1x5WaizXXWzjqz8Ps9VXfA7d5VgBhYzq0Cnrz72+92XT4SNWe5nMmPfcd3oKa+3mcePflkuhlmorUf37XSAfWCXzjQoy0BeE0aTx+U6CntJUAH6OR6IbDwF3i78bcAXJk7Zvf3V6G+lqRuTB+oAUNv9To/L+ET0U0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902999; c=relaxed/simple; bh=JeRijEx23Ns1L/7q4wfOrIBd/3s2+2IlWxsCVjMTBPI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZwkQEVgwJmiBXdDUs38+JrI3mGurt666KH1wjwKQJRN3lOdbDrbyNT4piL2aZo25FxVD424E7JS+IDptqt5cUFhJAmayYKyVal3ppqdlv0vRgol+O3n2XuG3Snyl14DqmyWEfeobPZcVSPyXwpvIzLW9w+4PzCQlsBa9/njdBm8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=mJjNcy3b; arc=fail smtp.client-ip=40.107.223.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="mJjNcy3b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fni+v4Yhw0EAaCVaefDymmusY2LaYBHVMEu8BX4qZG3FPlwVHr5jBSemTp8Uks7Ne60O72oz9MR+Z8+la28pnoMIFhvYQuUCMYwFozAsZ7gI9ZlulI9fEccg1GBhxvMq8snG+VdbqlodK0i96nO/9K52lUvzmNEuhPNWeNdgrnBylt+OYl19+gjQMSmUK2IGfmHzyp/9YoCOiHU3mg9mnIgM/UDnUt1PawkhgQFQVxWw8YOtHX5Elf9RwFG2XFuxorjupR9C2Nw7lakIjSoLj4wg59Q0p7cTaMYaSKBmpCIynIRPsbIgY3dx3PDK94otiyqpD2yZobenfubPo6bjmA== 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=W0DzTKuvVpMpdluGl4yL3+ZafZmGGyQYoiOrKx9hZek=; b=nZ6yrGGWpgs2i5UI/+qPAlA/UU7LtWsEmFMBKZdKABedcKapA5LwDX4gkTJ2NF493fHavGP2/YGD4ql5DR9MDQ5V00529ZXNnbKw6ZtkGSJCAH3W2MV4jS+RHUIWuL8cIU/x/VnYF8+C8BCwF/993PYaWhLEbqq8IQvDKOs04BtkqlDkmSYIYlfuf258KzUqxqy0fOBQfcEKfF9YxTvhvv0RRVfJS2N8p58vrxrKBLu4BEUhrkxVDgZqdt6gAmV/AC1lnItJgrCMoLkW1UKevjJSTHWZRNR9yTKM3+BEzIRdDI6m9BJhPdaEgHp3zGnrT0/gmlbozHHVzJ7bSomK0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=W0DzTKuvVpMpdluGl4yL3+ZafZmGGyQYoiOrKx9hZek=; b=mJjNcy3bh+QPEh8sHBjYUe1p85+wsSBTe6ldred8Q2Gu3zGalEb3TICeeBXsinMauVMnJw+f8KMjeCBWvJIB/nDMjnCLFGX3W41luX/4gaRjp90SILkk7x35utL87pi8pZUfj45wmlWdKw8rFE4VYTETSw7yDAJS4zQPiPvdcxzciSjRlUH4QVzLl3H4wtbi9FRgWFNhzq8OpqtYWNiOKTerpYIgOmWLZDUXvPQyJyFyDsSy7UqT715aKWlKnmo6hOnvtXfZp35JHte3rMnJMpMai9GJHHm/liZ7ZY7YP9iynMtzzXk9TtadbMAdJbUYtv7dK0IC5plxzdjTbs50Cw== Received: from DS7PR03CA0087.namprd03.prod.outlook.com (2603:10b6:5:3bb::32) by SN7PR12MB8433.namprd12.prod.outlook.com (2603:10b6:806:2e5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Fri, 8 Mar 2024 13:03:14 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:3bb:cafe::20) by DS7PR03CA0087.outlook.office365.com (2603:10b6:5:3bb::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 13:03:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.12 via Frontend Transport; Fri, 8 Mar 2024 13:03:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:03:00 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:02:55 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 09/11] mlxsw: spectrum_router: Support nexthop group hardware statistics Date: Fri, 8 Mar 2024 13:59:53 +0100 Message-ID: <87495a72f187df2e5d491d02729c550d235fcc85.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|SN7PR12MB8433:EE_ X-MS-Office365-Filtering-Correlation-Id: 8fe3a586-62dc-4392-4c52-08dc3f701dcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 62s9xla5JnfYQmuaF9CSLypm6NOgxNgTflxkeOsUHHZfUE/E9wWcyCuLRCo8BhpMV9bTlWB4gooM+kTWYt1sP4q2sEP4Nn6ieOu1S5/KgeM86pJXtqx9I8m95QVUiLC8t2FqlI7ETcVXn3DKbvsdf091HCJdCjSmQ8842oMyvcqUx8I9CJB6Bv9P1UT0l7keV72ZzkPEkACWf64H8lxWQPoNokbmX6E7n9hhyWk4PD56BVJEOSVwC6VUubs8UUBYstAlyTO2EkGcJ/0QsdQg1yEHXUUe0YlRx0kSGOGG8DzhQwj+5S0oEu5jdJJ523Ie1Zi4RqBzSCun6ARILvGNC6OK2p+ctHFo5/EjIgvrBWjdtrGhsgL97CnXztiC1yaLwxfTz43zrhzX59g28N5nV9qWaNGRdjnfiHaN2SK58wjSHGQtc9Rw2vfmySRmzoqOxTrGLoPkPe8rdXZ5DdMlwGvwz8UBeaeevqWEL+PXTiyzejAxBdkHek1pefgjr+q9uEbeuxxMox4HBpbeZOeFh1rzXI/zlx3aZNkJEGdgUbk11RXBTX0hr6Dg4cUcnnokd1CfbygfWNMT5jpHKa+bS+QBYm46YT3MAa9Vw7mKpSdbrb2SA8FFZe0xnQ3tK5NXFVk2AGrIIwD7CnwvsZLlAb6rYlXq10iCrQ8DohwVgkpLX9m2ytCbiByXBVp3geDOcjOeyDSsGmxd+YA8MGv9bss+N0n0Nx1nXxaRDOyM6pOp9gyBGPkJ6f+T1MD+Ji1Y X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:14.7020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fe3a586-62dc-4392-4c52-08dc3f701dcc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8433 X-Patchwork-Delegate: kuba@kernel.org When hw_stats is set on a group, install nexthop counters on members of a group. Counter allocation request is moved from nexthop object initialization to the update code. The previous placement made sense: when the counters are enabled by dpipe, the counters are installed to all existing nexthops and all nexthops created from then on get them. For the finer-grained nexthop group statistics, this is unsuitable. The existing placement was kept for the IPv4 and IPv6 nexthops. Resilient group replacement emits a pre_replace notification, and then any bucket_replace notifications if there were any replacements at all. If the group is balanced and the nexthop composition of the replaced group didn't change, there will be no such notifiers. Therefore hook to the pre_replace notifier and mark all buckets for update, to un/install the counters. When reporting deltas for resilient groups, use the nexthop ID that we stored in a previous patch to look up to which nexthop a bucket contributes. Co-developed-by: Ido Schimmel Signed-off-by: Ido Schimmel Signed-off-by: Petr Machata --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 148 +++++++++++++++++- 1 file changed, 142 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 922dcd9c0b5a..93ead5ccf864 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -3108,7 +3108,8 @@ struct mlxsw_sp_nexthop_group_info { int sum_norm_weight; u8 adj_index_valid:1, gateway:1, /* routes using the group use a gateway */ - is_resilient:1; + is_resilient:1, + hw_stats:1; struct list_head list; /* member in nh_res_grp_list */ struct mlxsw_sp_nexthop nexthops[] __counted_by(count); }; @@ -3189,15 +3190,17 @@ mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh) { + const char *table_adj = MLXSW_SP_DPIPE_TABLE_NAME_ADJ; struct mlxsw_sp_nexthop_counter *nhct; struct devlink *devlink; + bool dpipe_stats; if (nh->counter) return 0; devlink = priv_to_devlink(mlxsw_sp->core); - if (!devlink_dpipe_table_counter_enabled(devlink, - MLXSW_SP_DPIPE_TABLE_NAME_ADJ)) + dpipe_stats = devlink_dpipe_table_counter_enabled(devlink, table_adj); + if (!(nh->nhgi->hw_stats || dpipe_stats)) return 0; nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); @@ -3217,6 +3220,15 @@ void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, nh->counter = NULL; } +static int mlxsw_sp_nexthop_counter_update(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) +{ + if (nh->nhgi->hw_stats) + return mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); + return 0; +} + int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh, u64 *p_counter) { @@ -3224,7 +3236,7 @@ int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, return -EINVAL; return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter->counter_index, - false, p_counter, NULL); + true, p_counter, NULL); } struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router, @@ -3786,6 +3798,7 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, nh = &nhgi->nexthops[i]; if (!nh->should_offload) { + mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); nh->offloaded = 0; continue; } @@ -3793,6 +3806,10 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, if (nh->update || reallocate) { int err = 0; + err = mlxsw_sp_nexthop_counter_update(mlxsw_sp, nh); + if (err) + return err; + err = mlxsw_sp_nexthop_update(mlxsw_sp, adj_index, nh, true, ratr_pl); if (err) @@ -5052,7 +5069,6 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp, break; } - mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh); list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); nh->ifindex = dev->ifindex; nh->id = nh_obj->id; @@ -5077,7 +5093,6 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp, err_type_init: list_del(&nh->router_list_node); - mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh); return err; } @@ -5100,6 +5115,7 @@ mlxsw_sp_nexthop_obj_group_info_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop_group_info *nhgi; struct mlxsw_sp_nexthop *nh; bool is_resilient = false; + bool hw_stats = false; unsigned int nhs; int err, i; @@ -5109,9 +5125,11 @@ mlxsw_sp_nexthop_obj_group_info_init(struct mlxsw_sp *mlxsw_sp, break; case NH_NOTIFIER_INFO_TYPE_GRP: nhs = info->nh_grp->num_nh; + hw_stats = info->nh_grp->hw_stats; break; case NH_NOTIFIER_INFO_TYPE_RES_TABLE: nhs = info->nh_res_table->num_nh_buckets; + hw_stats = info->nh_res_table->hw_stats; is_resilient = true; break; default: @@ -5126,6 +5144,7 @@ mlxsw_sp_nexthop_obj_group_info_init(struct mlxsw_sp *mlxsw_sp, nhgi->gateway = mlxsw_sp_nexthop_obj_is_gateway(mlxsw_sp, info); nhgi->is_resilient = is_resilient; nhgi->count = nhs; + nhgi->hw_stats = hw_stats; for (i = 0; i < nhgi->count; i++) { struct nh_notifier_single_info *nh_obj; int weight; @@ -5347,6 +5366,43 @@ mlxsw_sp_nexthop_obj_group_replace(struct mlxsw_sp *mlxsw_sp, return err; } +static int mlxsw_sp_nexthop_obj_res_group_pre(struct mlxsw_sp *mlxsw_sp, + struct nh_notifier_info *info) +{ + struct nh_notifier_grp_info *grp_info = info->nh_grp; + struct mlxsw_sp_nexthop_group_info *nhgi; + struct mlxsw_sp_nexthop_group *nh_grp; + int err; + int i; + + nh_grp = mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp, info->id); + if (!nh_grp) + return 0; + nhgi = nh_grp->nhgi; + + if (nhgi->hw_stats == grp_info->hw_stats) + return 0; + + nhgi->hw_stats = grp_info->hw_stats; + + for (i = 0; i < nhgi->count; i++) { + struct mlxsw_sp_nexthop *nh = &nhgi->nexthops[i]; + + if (nh->offloaded) + nh->update = 1; + } + + err = mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); + if (err) + goto err_group_refresh; + + return 0; + +err_group_refresh: + nhgi->hw_stats = !grp_info->hw_stats; + return err; +} + static int mlxsw_sp_nexthop_obj_new(struct mlxsw_sp *mlxsw_sp, struct nh_notifier_info *info) { @@ -5523,6 +5579,79 @@ static int mlxsw_sp_nexthop_obj_bucket_replace(struct mlxsw_sp *mlxsw_sp, return err; } +static void +mlxsw_sp_nexthop_obj_mp_hw_stats_get(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop_group_info *nhgi, + struct nh_notifier_grp_hw_stats_info *info) +{ + int nhi; + + for (nhi = 0; nhi < info->num_nh; nhi++) { + struct mlxsw_sp_nexthop *nh = &nhgi->nexthops[nhi]; + u64 packets; + int err; + + err = mlxsw_sp_nexthop_counter_get(mlxsw_sp, nh, &packets); + if (err) + continue; + + nh_grp_hw_stats_report_delta(info, nhi, packets); + } +} + +static void +mlxsw_sp_nexthop_obj_res_hw_stats_get(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop_group_info *nhgi, + struct nh_notifier_grp_hw_stats_info *info) +{ + int nhi = -1; + int bucket; + + for (bucket = 0; bucket < nhgi->count; bucket++) { + struct mlxsw_sp_nexthop *nh = &nhgi->nexthops[bucket]; + u64 packets; + int err; + + if (nhi == -1 || info->stats[nhi].id != nh->id) { + for (nhi = 0; nhi < info->num_nh; nhi++) + if (info->stats[nhi].id == nh->id) + break; + if (WARN_ON_ONCE(nhi == info->num_nh)) { + nhi = -1; + continue; + } + } + + err = mlxsw_sp_nexthop_counter_get(mlxsw_sp, nh, &packets); + if (err) + continue; + + nh_grp_hw_stats_report_delta(info, nhi, packets); + } +} + +static void mlxsw_sp_nexthop_obj_hw_stats_get(struct mlxsw_sp *mlxsw_sp, + struct nh_notifier_info *info) +{ + struct mlxsw_sp_nexthop_group_info *nhgi; + struct mlxsw_sp_nexthop_group *nh_grp; + + if (info->type != NH_NOTIFIER_INFO_TYPE_GRP_HW_STATS) + return; + + nh_grp = mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp, info->id); + if (!nh_grp) + return; + nhgi = nh_grp->nhgi; + + if (nhgi->is_resilient) + mlxsw_sp_nexthop_obj_res_hw_stats_get(mlxsw_sp, nhgi, + info->nh_grp_hw_stats); + else + mlxsw_sp_nexthop_obj_mp_hw_stats_get(mlxsw_sp, nhgi, + info->nh_grp_hw_stats); +} + static int mlxsw_sp_nexthop_obj_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -5538,6 +5667,10 @@ static int mlxsw_sp_nexthop_obj_event(struct notifier_block *nb, mutex_lock(&router->lock); switch (event) { + case NEXTHOP_EVENT_RES_TABLE_PRE_REPLACE: + err = mlxsw_sp_nexthop_obj_res_group_pre(router->mlxsw_sp, + info); + break; case NEXTHOP_EVENT_REPLACE: err = mlxsw_sp_nexthop_obj_new(router->mlxsw_sp, info); break; @@ -5548,6 +5681,9 @@ static int mlxsw_sp_nexthop_obj_event(struct notifier_block *nb, err = mlxsw_sp_nexthop_obj_bucket_replace(router->mlxsw_sp, info); break; + case NEXTHOP_EVENT_HW_STATS_REPORT_DELTA: + mlxsw_sp_nexthop_obj_hw_stats_get(router->mlxsw_sp, info); + break; default: break; } From patchwork Fri Mar 8 12:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586820 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9F3F1EA8F for ; Fri, 8 Mar 2024 13:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903004; cv=fail; b=uI9YUYw6BRtFBUsvXuIsPlSpr7CfPPpv2oaQfDPpGGWPAFNlzAI3R8zYrIdj9k/DywULLhBj8eNa+ccZor4ACDYQVNLNY4XKXFKbuTikpQfZtQVTTqFBoBqYStEiYxrtkFFWavQJPB79bypOce64R/lstG5AZrjq48QSNBA+EJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903004; c=relaxed/simple; bh=vPrMql4lu6lan29viOPM9n1eAyPz+gFQi3hMfkQtSow=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ubU/+G61nQR/jLOElTF8luyuBa49ILZKZwB2Zr40fe5ifmFqq+ud25f+q3Cws2X2HyyW2vtlM8nRDg1p+0BUi9rS8kFLwhuPzt0xANaj2CgNxpDKuSYm+bgI7MLmhtrFTNMcVqUb0sPpfITE4PIucNmZ1s2UD8V2ObNuaDZLRc8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Dg5WNqVS; arc=fail smtp.client-ip=40.107.94.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Dg5WNqVS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oa6G6b/++DlSWA/JrVt6AKy2ix82dTdIcHalN0xJkNVv9FiQ73VO30Bazoh8PJ71pJJejzDHYoeVys/2QCQ/fD+ZibrMEuciZgaFZCmXd3iTESl6gNVDQ8fG4iI+DwSdUcIks65Ed/cenFscehi5W+peldwiTQv2AqXTf33Q/arU8IZ4XsfGXNMF/A/WDmc3cQGOVrJJeLflfuSveZ0NuuyYrlhk/QlbQiR654pRFc4GmK5mBtlSYTqSgn3LNiAwTcsOTeCMw76rB88zWIrRnT6piAoM1KV6X18qngA3LMPOxnqiWNQmtfDIhVKk5FIy2n8xk/mhgScS9ue6YTKZYQ== 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=je/dY06JKrnYZQ9xfYtbtpMY9MQcYZI6HaESi/Uk4Og=; b=BHoATRGPTtZDk0sMjNS3fq7Upb/Kb9lLYuDHxPUFbwYlFln7k2j02m77M9oLz4MN1Q0f2MVbA3Bs14B5lPhWYnVOa/saZnGavF4JXA/Wdmz5PzwSMgLO4DjHCbdcYuadRh3mVt+bM9VRLRawjEnyUJy2vxs6lEZja6AkcSETuEpvfxubQYFzd3Y4eKX6+FJHHp9IT7Us3ukg/qjur1urDGL1swAOToUds8S2Xi8TOHW1mUFbD4YtCbgR6Y5VuLNqv+SPAk4cYWMK0mVitEZ0JxQiyHkUSe/ujME0c3qDUgw/HjcSYKulEWdrJFy4XPfLcylEZ+NoVnJ9xckJzmBufQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=je/dY06JKrnYZQ9xfYtbtpMY9MQcYZI6HaESi/Uk4Og=; b=Dg5WNqVSVjcxmsEX5Cu8m2aVsXXtxXatW3aIaD5PCxHm1ptiybzwnZJ4Osvhum4X+DyyQiDpkQEnJsktsWTZo915QFk4rF/jZsT3S9Xp+hKMjNq6Ta3Q8iDE6nm/pJ6tQUL+V7so/gUQEjYfa7CjkvjwNOb1H9/dfQmJQpeIspk6y8tcGQg6ly3Iid2LdvKHxYMUAv91ghgkWzhyJUBR12KnTM1WI/BF3rpdZOwvUiZZiOit/prqXIgq4ERMvaQMkguj1DO74ZqzvgSAGPLH0najCjz1ndBrc6wqo4vBk9OyZKeNUcHAjboqPOd2DnAhLGHb6qJIUqAbrKUhHg6i9w== Received: from DS7PR03CA0078.namprd03.prod.outlook.com (2603:10b6:5:3bb::23) by MW4PR12MB7141.namprd12.prod.outlook.com (2603:10b6:303:213::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.31; Fri, 8 Mar 2024 13:03:20 +0000 Received: from DS1PEPF00017097.namprd05.prod.outlook.com (2603:10b6:5:3bb:cafe::41) by DS7PR03CA0078.outlook.office365.com (2603:10b6:5:3bb::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.28 via Frontend Transport; Fri, 8 Mar 2024 13:03:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017097.mail.protection.outlook.com (10.167.18.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:03:04 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:03:00 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 10/11] mlxsw: spectrum_router: Share nexthop counters in resilient groups Date: Fri, 8 Mar 2024 13:59:54 +0100 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017097:EE_|MW4PR12MB7141:EE_ X-MS-Office365-Filtering-Correlation-Id: 0392a655-a59d-4bc2-7a4d-08dc3f7020da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IMCInKQMiHTJoolqBSwRTsuXcVoAsMF+MbVSUdVKvMT0bUHxsBLMEQEq/17BWz3QoFk1FLDpMp6mn3GoaR2unNQwaJD2a71/P3AmriXt8QWkPRqXASX+Bg/CYCAzH/EV/javN8YVXoECH970kGxSruDAlTa3meXm0Duh8/1YT7wGzLbaesCnehvPwQomlRL2UgU3QTGIpEdTq62yt+CNHcFu61xpGORll6Xko/Lh0O/FJ/E5ehm/Fvx1JImctYO3TVJ9TuZuGHPhFBbGymjlG19Bo0S6+/B6bCk/9+ZBqs+aagbXbGVi0nqUKoethC6GsvRSjYVl7SZRj6oxWkS+V0adNuMbJYFWwRzztd81hy6kxeOy5JKEpPKHj/86PRloOJ7p60KuE5ITaiBki6J151VrL2mYSfNuM66fjHPgqWXabo7+zloeHmX1YsZ56ga4Bogehi427iroPKibLgCPjBfEr/sYuutY2UayBdnoIIZOjGYbYh9hyhn9jJT/RYAf6D1jO7VIOyyeNz26zFtiXR8h1/g9vkiS8LPA2U5SDcc7rx51snauEnHPdMAsnUfQJJPJiEmimY3gh6FVClazVKha/7EmI4qQe66Jal95nVuWxIsmfRTENEMaDMpfdVbg3ht2u+N2ZJNTGpDbSRSAif2jKC4FkV91fG18KC47QN4gCaOQGDThaZ7LiXOdYiuNo32cABrMjZmLSggi82COHp+m88PDUgm8tedPhfqoAc/5pCUO1SCvzlUb6oN7YbMi X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(376005)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:19.8281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0392a655-a59d-4bc2-7a4d-08dc3f7020da X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017097.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7141 X-Patchwork-Delegate: kuba@kernel.org For resilient groups, we can reuse the same counter for all the buckets that share the same nexthop. Keep a reference count per counter, and keep all these counters in a per-next hop group xarray, which serves as a NHID->counter cache. If a counter is already present for a given NHID, just take a reference and use the same counter. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 70 ++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 93ead5ccf864..40ba314fbc72 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -3111,6 +3112,7 @@ struct mlxsw_sp_nexthop_group_info { is_resilient:1, hw_stats:1; struct list_head list; /* member in nh_res_grp_list */ + struct xarray nexthop_counters; struct mlxsw_sp_nexthop nexthops[] __counted_by(count); }; @@ -3156,6 +3158,7 @@ struct mlxsw_sp_nexthop_group { struct mlxsw_sp_nexthop_counter { unsigned int counter_index; + refcount_t ref_count; }; static struct mlxsw_sp_nexthop_counter * @@ -3172,6 +3175,7 @@ mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp) if (err) goto err_counter_alloc; + refcount_set(&nhct->ref_count, 1); return nhct; err_counter_alloc: @@ -3187,6 +3191,56 @@ mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, kfree(nhct); } +static struct mlxsw_sp_nexthop_counter * +mlxsw_sp_nexthop_sh_counter_get(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) +{ + struct mlxsw_sp_nexthop_group *nh_grp = nh->nhgi->nh_grp; + struct mlxsw_sp_nexthop_counter *nhct; + void *ptr; + int err; + + nhct = xa_load(&nh_grp->nhgi->nexthop_counters, nh->id); + if (nhct) { + refcount_inc(&nhct->ref_count); + return nhct; + } + + nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); + if (IS_ERR(nhct)) + return nhct; + + ptr = xa_store(&nh_grp->nhgi->nexthop_counters, nh->id, nhct, + GFP_KERNEL); + if (IS_ERR(ptr)) { + err = PTR_ERR(ptr); + goto err_store; + } + + return nhct; + +err_store: + mlxsw_sp_nexthop_counter_free(mlxsw_sp, nhct); + return ERR_PTR(err); +} + +static void mlxsw_sp_nexthop_sh_counter_put(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) +{ + struct mlxsw_sp_nexthop_group *nh_grp = nh->nhgi->nh_grp; + struct mlxsw_sp_nexthop_counter *nhct; + + nhct = xa_load(&nh_grp->nhgi->nexthop_counters, nh->id); + if (WARN_ON(!nhct)) + return; + + if (!refcount_dec_and_test(&nhct->ref_count)) + return; + + xa_erase(&nh_grp->nhgi->nexthop_counters, nh->id); + mlxsw_sp_nexthop_counter_free(mlxsw_sp, nhct); +} + int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh) { @@ -3203,7 +3257,10 @@ int mlxsw_sp_nexthop_counter_enable(struct mlxsw_sp *mlxsw_sp, if (!(nh->nhgi->hw_stats || dpipe_stats)) return 0; - nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); + if (nh->id) + nhct = mlxsw_sp_nexthop_sh_counter_get(mlxsw_sp, nh); + else + nhct = mlxsw_sp_nexthop_counter_alloc(mlxsw_sp); if (IS_ERR(nhct)) return PTR_ERR(nhct); @@ -3216,7 +3273,11 @@ void mlxsw_sp_nexthop_counter_disable(struct mlxsw_sp *mlxsw_sp, { if (!nh->counter) return; - mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh->counter); + + if (nh->id) + mlxsw_sp_nexthop_sh_counter_put(mlxsw_sp, nh); + else + mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh->counter); nh->counter = NULL; } @@ -5145,6 +5206,9 @@ mlxsw_sp_nexthop_obj_group_info_init(struct mlxsw_sp *mlxsw_sp, nhgi->is_resilient = is_resilient; nhgi->count = nhs; nhgi->hw_stats = hw_stats; + + xa_init_flags(&nhgi->nexthop_counters, XA_FLAGS_ALLOC1); + for (i = 0; i < nhgi->count; i++) { struct nh_notifier_single_info *nh_obj; int weight; @@ -5227,6 +5291,8 @@ mlxsw_sp_nexthop_obj_group_info_fini(struct mlxsw_sp *mlxsw_sp, } mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); WARN_ON_ONCE(nhgi->adj_index_valid); + WARN_ON(!xa_empty(&nhgi->nexthop_counters)); + xa_destroy(&nhgi->nexthop_counters); kfree(nhgi); } From patchwork Fri Mar 8 12:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13586821 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B9C1CD20 for ; Fri, 8 Mar 2024 13:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903020; cv=fail; b=fmNSSgVp7nkNVxrqNm/p72jJwGrxIFyZxhxrtSQu3QRk/7HKaZWwpP9cUIl28LoTrBftxPIb7xjqdjkkwCb8tfXSuypUP+I4uFJYdFmhqeKFP1TvC4ONraEBg5Ygv5rq015w35ojGlAXvZ7E6JXvqHCN1P6B+PlR2Ap45yStnOs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903020; c=relaxed/simple; bh=bBDcS4DLEyoA3A2s0DqpD9Mxc5daRv9SUnBGZf+jTTU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=txMYBLMSycwnIqJfSjQWNz5TfaEsOfDpqPRQSRZO3e80XMCtS8A7gGEzV2SkgyLnHvdZ6rFHSf6g6IoTp4UZ7cnpbpwPUanSwzCfKDEhQkuIW6W9ddqlbvmTNxrXyn1uaBI26LgnyxqisIzgN9HURPenlZDJX1FhlqxowfAMedI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=lyk6iOe7; arc=fail smtp.client-ip=40.107.236.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="lyk6iOe7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ArcFqsdDEvCRiv32dBFJjg0ZloNA3l5NIZZkHv38ycM6Cotxqh0Sj9TsQU7uSoPQd59z0Nw7wVmheI0yjw0FYbyTxEeW1FMghEjwEwm9GhM0MqJX57fU55WpOh7Bo/ZMAbu3LhOM9LX4ySvUze+/ApjRCKToD6kXReR5P+3aCGZcSxVb+RwZQjbS6eBhtPVb2juSMdcjTt7Cnnu/pJCoyi6O1crpdl/fOQ9KRtIdrvh5v9BvYhzNNfHic48Hr+JbSoDIVhigwrDy0IfXcgqZ+9aqtlo635FjKArqQpbYl9V4fti4Nu418/pSIFjkDx0G9RuNBft+SQG6tawA4NZ8VQ== 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=sX16NSAhwbIYw1NnHZC3F4kW6In3aTx3xIjLjgMFci4=; b=QB1Bv2GuIEZTFMA9WRALOpKlYqvbCfn614edgt1KXMYAoj6FakkQQWDEKaTWeV8mEbX6usDDyujv45HUGry9g4OAEVvVyW1/TTWTMJeU0SthKJ0ewbpx3Feg0508p96IRjm59R5k4NRxjDr2l8zxPnR0PK/1HshBCrGIp/s6O+mOtuOyOSUi3Qk2STpxHw5ar0svWIIbTeysldJpHJqxkhQQbzfFMb4xU4tJLvvInpq5s7ZbEa+E+6H6H7J6ja0RD9dqC58sNq11/zKVCjJPFp0jFutrNsyStw6gHF+OwFx5mKp1zkaivm1oDKcUNQETLemf1tgOkPRU4T1mpWuyFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=sX16NSAhwbIYw1NnHZC3F4kW6In3aTx3xIjLjgMFci4=; b=lyk6iOe7ut2UxWQNCIH0sLy6LCMMrMFVo3jZSosjgWE5vD5UWhfTWxoCMBGMad2YZGTBIQPSSmfYxa30fgSKxSyL0GAUvAx+850X+p4ZxYRqYMP946bINmtDGmBLuEjxpfM1sas/rOYqnCdw4WuxGXSkDEMOSsvZtCvZtcVQa89If3NB58sOArcJeYYtXDgoAa24c87q8osZtRsmyloRfaFI/bE1bo+8QJEir/rKhZDSiS2Pwh1jQe5kNAmOmXL4WS+vPvfPQdF+fchv/GpV1ricupC4Wo4w1yZv4NeN5a+qL2gkgAlT6q5RUDcTKzhqXaHSFIWC0U9cW+icBXFO/Q== Received: from BN1PR12CA0020.namprd12.prod.outlook.com (2603:10b6:408:e1::25) by SA1PR12MB7344.namprd12.prod.outlook.com (2603:10b6:806:2b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Fri, 8 Mar 2024 13:03:34 +0000 Received: from BN2PEPF000044A3.namprd02.prod.outlook.com (2603:10b6:408:e1:cafe::b5) by BN1PR12CA0020.outlook.office365.com (2603:10b6:408:e1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 13:03:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN2PEPF000044A3.mail.protection.outlook.com (10.167.243.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 13:03:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 8 Mar 2024 05:03:09 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 8 Mar 2024 05:03:05 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "David Ahern" , Shuah Khan , Subject: [PATCH net-next 11/11] selftests: forwarding: Add a test for NH group stats Date: Fri, 8 Mar 2024 13:59:55 +0100 Message-ID: <2a424c54062a5f1efd13b9ec5b2b0e29c6af2574.1709901020.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A3:EE_|SA1PR12MB7344:EE_ X-MS-Office365-Filtering-Correlation-Id: f60525cd-e9de-4987-5b8e-08dc3f7028ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0+R30TdwDAgYcSN+rwJt5tJqkSMeLFpIeoVno5Gr6Vl17ZYn506Nd9qetcWvg1p91hySOdusMMOKwAwL0+13u7jjxtdFNT6a9aiiL6myd9P0MerPQleMYuvMimUuspl0PhCEgEaNTsoFD2ZajTLGvWI/OifsxcNnHYzgaWKjaK0uCvHl/cY0Ax8UKamNKmIbyzbcwg6iThfXi6wpQfebcnlNZuyIfsI/0P3cv4tgouz1yKdbLQSUoxBlyIqc5hK1/Ql5UpcaUgkBkqUpsk45UGiPJRZ34JT9PYTwhCyKn5rnRfAXYm4Mjh67QCwW0cfDKhJ6WlULpkiBw/DxqyZUKQHfqanQA1G91mC5nxkFpu+62qLH4k42kxpvE8FMkpo1vCp/pcGwFBfcyl8zeR2BwLaVAK4W7CcxxFC6+D10x+TibiZIY+fE3FaJC+Uf0A9Lu0HsrW/41TGLv1LY2VLYU7exc1mxvw64CS2dpVM+DuIa4JQ+R2WwqHuLzB1oa/IcGq9uT5bEVTr95d/4Fk2WiUMFnQdcD1WqJiCzrF0jfTZs3jx49CQe3pBQZSZ6w1qpbPO1Si5E6NLw1omdu2l/wFzrUy/yvC+PF9Wk7HMM4CJc1CqCRHSLWLAF2N4fOlexrdE6D1NsdJ55jYb7HBsYlBKVxLqgeOsxX/ibuS9YnH3hRvrelkNtdcsDauLGo86inYoA+4iuvMxoF3+yjWO/tjd2ZF6PMiRmlR2uDNy7mhxlW7rc8YsIKpjre5mqqpm8 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:03:33.3202 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f60525cd-e9de-4987-5b8e-08dc3f7028ec X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A3.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7344 X-Patchwork-Delegate: kuba@kernel.org Add to lib.sh support for fetching NH stats, and a new library, router_mpath_nh_lib.sh, with the common code for testing NH stats. Use the latter from router_mpath_nh.sh and router_mpath_nh_res.sh. The test works by sending traffic through a NH group, and checking that the reported values correspond to what the link that ultimately receives the traffic reports having seen. Signed-off-by: Petr Machata --- .../testing/selftests/net/forwarding/Makefile | 1 + tools/testing/selftests/net/forwarding/lib.sh | 34 +++++ .../net/forwarding/router_mpath_nh.sh | 13 ++ .../net/forwarding/router_mpath_nh_lib.sh | 129 ++++++++++++++++++ .../net/forwarding/router_mpath_nh_res.sh | 13 ++ 5 files changed, 190 insertions(+) create mode 100644 tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index cdefc9a5ec34..535865b3d1d6 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -123,6 +123,7 @@ TEST_FILES := devlink_lib.sh \ mirror_gre_topo_lib.sh \ mirror_lib.sh \ mirror_topo_lib.sh \ + router_mpath_nh_lib.sh \ sch_ets_core.sh \ sch_ets_tests.sh \ sch_tbf_core.sh \ diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d1bf39eaf2b3..e579c2e0c462 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -900,6 +900,33 @@ hw_stats_get() jq ".[0].stats64.$dir.$stat" } +__nh_stats_get() +{ + local key=$1; shift + local group_id=$1; shift + local member_id=$1; shift + + ip -j -s -s nexthop show id $group_id | + jq --argjson member_id "$member_id" --arg key "$key" \ + '.[].group_stats[] | select(.id == $member_id) | .[$key]' +} + +nh_stats_get() +{ + local group_id=$1; shift + local member_id=$1; shift + + __nh_stats_get packets "$group_id" "$member_id" +} + +nh_stats_get_hw() +{ + local group_id=$1; shift + local member_id=$1; shift + + __nh_stats_get packets_hw "$group_id" "$member_id" +} + humanize() { local speed=$1; shift @@ -2010,3 +2037,10 @@ bail_on_lldpad() fi fi } + +absval() +{ + local v=$1; shift + + echo $((v > 0 ? v : -v)) +} diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh index 982e0d098ea9..3f0f5dc95542 100755 --- a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh +++ b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh @@ -7,9 +7,12 @@ ALL_TESTS=" multipath_test ping_ipv4_blackhole ping_ipv6_blackhole + nh_stats_test_v4 + nh_stats_test_v6 " NUM_NETIFS=8 source lib.sh +source router_mpath_nh_lib.sh h1_create() { @@ -325,6 +328,16 @@ ping_ipv6_blackhole() ip -6 nexthop del id 1001 } +nh_stats_test_v4() +{ + __nh_stats_test_v4 mpath +} + +nh_stats_test_v6() +{ + __nh_stats_test_v6 mpath +} + setup_prepare() { h1=${NETIFS[p1]} diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh new file mode 100644 index 000000000000..7e7d62161c34 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: GPL-2.0 + +nh_stats_do_test() +{ + local what=$1; shift + local nh1_id=$1; shift + local nh2_id=$1; shift + local group_id=$1; shift + local stats_get=$1; shift + local mz="$@" + + local dp + + RET=0 + + sleep 2 + for ((dp=0; dp < 60000; dp += 10000)); do + local dd + local t0_rp12=$(link_stats_tx_packets_get $rp12) + local t0_rp13=$(link_stats_tx_packets_get $rp13) + local t0_nh1=$($stats_get $group_id $nh1_id) + local t0_nh2=$($stats_get $group_id $nh2_id) + + ip vrf exec vrf-h1 \ + $mz -q -p 64 -d 0 -t udp \ + "sp=1024,dp=$((dp))-$((dp + 10000))" + sleep 2 + + local t1_rp12=$(link_stats_tx_packets_get $rp12) + local t1_rp13=$(link_stats_tx_packets_get $rp13) + local t1_nh1=$($stats_get $group_id $nh1_id) + local t1_nh2=$($stats_get $group_id $nh2_id) + + local d_rp12=$((t1_rp12 - t0_rp12)) + local d_rp13=$((t1_rp13 - t0_rp13)) + local d_nh1=$((t1_nh1 - t0_nh1)) + local d_nh2=$((t1_nh2 - t0_nh2)) + + dd=$(absval $((d_rp12 - d_nh1))) + ((dd < 10)) + check_err $? "Discrepancy between link and $stats_get: d_rp12=$d_rp12 d_nh1=$d_nh1" + + dd=$(absval $((d_rp13 - d_nh2))) + ((dd < 10)) + check_err $? "Discrepancy between link and $stats_get: d_rp13=$d_rp13 d_nh2=$d_nh2" + done + + log_test "NH stats test $what" +} + +nh_stats_test_dispatch_swhw() +{ + local what=$1; shift + local nh1_id=$1; shift + local nh2_id=$1; shift + local group_id=$1; shift + local mz="$@" + + local used + + nh_stats_do_test "$what" "$nh1_id" "$nh2_id" "$group_id" \ + nh_stats_get "${mz[@]}" + + used=$(ip -s -j -d nexthop show id $group_id | + jq '.[].hw_stats.used') + kind=$(ip -j -d link show dev $rp11 | + jq -r '.[].linkinfo.info_kind') + if [[ $used == true ]]; then + nh_stats_do_test "HW $what" "$nh1_id" "$nh2_id" "$group_id" \ + nh_stats_get_hw "${mz[@]}" + elif [[ $kind == veth ]]; then + log_test_skip "HW stats not offloaded on veth topology" + fi +} + +nh_stats_test_dispatch() +{ + local nhgtype=$1; shift + local what=$1; shift + local nh1_id=$1; shift + local nh2_id=$1; shift + local group_id=$1; shift + local mz="$@" + + local enabled + local kind + + if ! ip nexthop help 2>&1 | grep -q hw_stats; then + log_test_skip "NH stats test: ip doesn't support HW stats" + return + fi + + ip nexthop replace id $group_id group $nh1_id/$nh2_id \ + hw_stats on type $nhgtype + enabled=$(ip -s -j -d nexthop show id $group_id | + jq '.[].hw_stats.enabled') + if [[ $enabled == true ]]; then + nh_stats_test_dispatch_swhw "$what" "$nh1_id" "$nh2_id" \ + "$group_id" "${mz[@]}" + elif [[ $enabled == false ]]; then + check_err 1 "HW stats still disabled after enabling" + log_test "NH stats test" + else + log_test_skip "NH stats test: ip doesn't report hw_stats info" + fi + + ip nexthop replace id $group_id group $nh1_id/$nh2_id \ + hw_stats off type $nhgtype +} + +__nh_stats_test_v4() +{ + local nhgtype=$1; shift + + sysctl_set net.ipv4.fib_multipath_hash_policy 1 + nh_stats_test_dispatch $nhgtype "IPv4" 101 102 103 \ + $MZ $h1 -A 192.0.2.2 -B 198.51.100.2 + sysctl_restore net.ipv4.fib_multipath_hash_policy +} + +__nh_stats_test_v6() +{ + local nhgtype=$1; shift + + sysctl_set net.ipv6.fib_multipath_hash_policy 1 + nh_stats_test_dispatch $nhgtype "IPv6" 104 105 106 \ + $MZ -6 $h1 -A 2001:db8:1::2 -B 2001:db8:2::2 + sysctl_restore net.ipv6.fib_multipath_hash_policy +} diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh index a60ff54723b7..4b483d24ad00 100755 --- a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh +++ b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh @@ -5,9 +5,12 @@ ALL_TESTS=" ping_ipv4 ping_ipv6 multipath_test + nh_stats_test_v4 + nh_stats_test_v6 " NUM_NETIFS=8 source lib.sh +source router_mpath_nh_lib.sh h1_create() { @@ -333,6 +336,16 @@ multipath_test() ip nexthop replace id 106 group 104,1/105,1 type resilient } +nh_stats_test_v4() +{ + __nh_stats_test_v4 resilient +} + +nh_stats_test_v6() +{ + __nh_stats_test_v6 resilient +} + setup_prepare() { h1=${NETIFS[p1]}