From patchwork Wed Feb 1 16:10:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124669 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECF9FC05027 for ; Wed, 1 Feb 2023 16:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231685AbjBAQL7 (ORCPT ); Wed, 1 Feb 2023 11:11:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjBAQL6 (ORCPT ); Wed, 1 Feb 2023 11:11:58 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8352265F3D for ; Wed, 1 Feb 2023 08:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g7zTLtUlh/DGRlRaCGS8FKdBHpakz0BCXdFlUPjQ7rFBBTPN/01i35J81T5z4TUVSR5t+zGnCzajqrm4C9I67GVcQbIRgBD4PIoxNscvM7K5h6zcqPCeka2DSpcBR7t0HbBaSuc36m0Xzp/xeG0+SM/2oGtbA3kPFSfIdSnkI7xSPr/br4AyXbl+cecsfrrs8QrQEhf3op2eY8zSNTZRKUAH9oWpxLejlolDWWScANPu42anY+aM3pafL07C/RMTKV0ZTKYZ+jc8A+muzQodWDLsurHSU1smxzLRLl1I1czVRbav9KGrkuT9jGZUsLLcDM1iA7gyWs3o8YzbgGI5xA== 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=Yp5crgyHSmpk8i9WC8TruC0Bu3MCMUwxBQJ3c4bwZPY=; b=RjiOd1WhP4r50HJ1X2lo1qMukkdLuCThWtrM6q6baT0JMrGUq65OuUeMX6CIhWo7bn9xql+Qnqk22BrDwiEn4eVaaVZxndvFYE34TsiFcqhuNdkgKmbmqGXtF60sYER3rT984g7N9TYYdPtXR55nN7yhHDEAIzc7G8CdnW9EZVzcJQSgYF7Kbt/Pb4xOHE7QzgX2fvdIUW3LXrqe5AKETGzkP7rqQfYXR7x3xj/kB2pMgjdx3bZNP9+lVPuwzEtkFLqy81fpJaQ32uVBKaKeK8PgEOy3KXK8LweSjYwUQ7pR+OKyzwc2GYJRe8BW+vrajXdqBDjav+tXqxlZuL1obA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yp5crgyHSmpk8i9WC8TruC0Bu3MCMUwxBQJ3c4bwZPY=; b=mQ6FoWa9uekwrfIVSh22i5SOWdMEZshFCkbxbUYUQk/FRBjEMjDaJ0KOhjkGGRumj1RB1UUikZTTMJmpO6Ip31QHI0DxPaPkU+qBGA1kH7bVv08g/sZkaOjNVjZrp3U3H9HgZHli4/4MfQCV9yohd0BXntC6up4EVqlifvG+axTCreR/IxW2BmvhIsnF0HfpOwnf0rnger+MJRAmMQPqd3pWOkTSzSojToi1Hhwb8OtICvuyQJx70H8XfZW2lfJjMWfl49Nqtdn5RgkVZ9hKKs00dmABwTZPTQ4lxZMC6OxR9/06PSUci+0cElGM67Ga/9ueJxLC3DBear9G5H6fDw== Received: from DS7PR06CA0024.namprd06.prod.outlook.com (2603:10b6:8:2a::8) by MW4PR12MB7384.namprd12.prod.outlook.com (2603:10b6:303:22b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:11:54 +0000 Received: from DM6NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2a:cafe::25) by DS7PR06CA0024.outlook.office365.com (2603:10b6:8:2a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:11:53 +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 DM6NAM11FT062.mail.protection.outlook.com (10.13.173.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:11:53 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.36; Wed, 1 Feb 2023 08:11:46 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 08:11:46 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:43 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 1/9] net/sched: optimize action stats api calls Date: Wed, 1 Feb 2023 18:10:30 +0200 Message-ID: <20230201161039.20714-2-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT062:EE_|MW4PR12MB7384:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b9fd9bd-c294-4422-9efb-08db046f08cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4i3nBF86E7rk5UecXdy6i37hPQccsckSWj7VWU/Tm5HnM6ukijih4aerDrCTlX8xMhE9CFnk+wgtCIVKpbQjTNt93VaSTfk01DdjwhdXIaCnudB5qycUEE+mkIuVbt/+uNdPM643fFCfjReq6cR/FJqnS4SAGB4WCquYwW7hTT3ZjJNrlnv96XafCNVqAzss/7aOSKT7yVKoJLkgvPPVYOpI8jACVHaz/aRRv3EIoj5jgFaAW2qjZBx3zutpkiZkXj/WF65XB1lFUyA3Izjy/gv/xTez9+1T0kc9hNqqdJaVcl9ainErWSBNzHNsD9qgL0G/OHfo0VZqlDQfDWSIPSnWYJaHdr7Gp/PQdQuV+K1iMb05SfOV330A/F4M6HupVSiGtugLoLLMjRdamNqa0Dn9XO4m1fkK/5A1dJHfG8Ca+aBKdht3RdFMYsiyW6QkXTxLnSWBw+7irfOaTbbivBm6QZhzR9Xhk5t0kkumxi8bdYyo7AcgEB3NR+ZT0RuJInA6E2oJTLTHM/ElaWprVtiBXndLOY+Xia1xKVwUoY+R1UgUS+ia56e9u3F5k2ZeAFs6UVaHTRVHjYG4XRWx4UBZ5Kox8tZ4b1saD5J8hp4vehzk2FGOWCToY+PQGxWyEvlm6eDQ9f3Xh90ictLyTJ/SulNoysQ+l4aGHLa360ck8H0Kd3tBtxxPCYlR7eclSeTFwv8AD1Aybfp1I1V4cw== 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:(13230025)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(336012)(478600001)(8936002)(2906002)(186003)(107886003)(6666004)(1076003)(41300700001)(8676002)(4326008)(70586007)(6916009)(70206006)(5660300002)(316002)(2616005)(54906003)(83380400001)(86362001)(82740400003)(7636003)(426003)(40480700001)(26005)(82310400005)(356005)(47076005)(36860700001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:11:53.7356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b9fd9bd-c294-4422-9efb-08db046f08cf 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: DM6NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7384 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently the hw action stats update is called from tcf_exts_hw_stats_update, when a tc filter is dumped, and from tcf_action_copy_stats, when a hw action is dumped. However, the tcf_action_copy_stats is also called from tcf_action_dump. As such, the hw action stats update cb is called 3 times for every tc flower filter dump. Move the tc action hw stats update from tcf_action_copy_stats to tcf_dump_walker to update the hw action stats when tc action is dumped. Signed-off-by: Oz Shlomo Reviewed-by: Simon Horman --- net/sched/act_api.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index cd09ef49df22..f4fa6d7340f8 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -539,6 +539,8 @@ static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb, (unsigned long)p->tcfa_tm.lastuse)) continue; + tcf_action_update_hw_stats(p); + nest = nla_nest_start_noflag(skb, n_i); if (!nest) { index--; @@ -1539,9 +1541,6 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p, if (p == NULL) goto errout; - /* update hw stats for this action */ - tcf_action_update_hw_stats(p); - /* compat_mode being true specifies a call that is supposed * to add additional backward compatibility statistic TLVs. */ From patchwork Wed Feb 1 16:10:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124671 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33753C636D7 for ; Wed, 1 Feb 2023 16:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbjBAQMH (ORCPT ); Wed, 1 Feb 2023 11:12:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232466AbjBAQME (ORCPT ); Wed, 1 Feb 2023 11:12:04 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B88C376412 for ; Wed, 1 Feb 2023 08:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZIJSv8YUvTboLWjK69psRGFHekTPiSXq22512PLYoasebt4PtoVElzvi+VnZTOzpggRDFoxHf0cOIa7Jy15D2bkc7gxh92RAwMSxw9asVSOMxY/RUlZKK/ZuGhXIkivt30TqtYhOiQbFXYDzXTMx2YOGTfR0ZdQp7HOFic2Sb0dwL9SbGY0bgvxswCH2cVQkr9DRmy6KHjt+98KDzprvJ8KpKGFHFqK1a5kALE/9WI1jQpxB2jmSeaK837z3h0bqH8lsN6AC9hujD+TgRpdY/Qu/0SZKh0W1qwfPA+IJUqAe40+m/K9MFCjdgaFu296Xh78RCkd61jwhSiIjcdce+w== 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=oeI3HnsFSoPGB9L8q9Vqtc8BRtMQ/wdADB40hNm1TTk=; b=Z41l5/Z7Gh9j3DWaH9SugUqYH+goY2wTJZ1koI6xfjfZbwAcYnlKNIKjoErnjxKL0DsiilmV7CsfpG1CkEE8QVjV2AV2SUpKBzdLsxqNZMte53Ys5tr+7RRpLKu70Hn3AM/uCdUgHXq9Qd5xgfTD+YzcnloyFiqc0po85ZCocg6eqkm3zRskSMnUXIkQ42XfZ+Sxq3Xeh2WOJVzY0IukqCqtpQm9GEePibaYrVsbCrU0s5czDxAbSKwICA3TVonJ3MS8N44jfsXT09bZRHjwkOzsn4efkRhdpoQdikAjWpjMzdRyeauwV9nWQtl+PVvCMzxPxImeSkgGfv5grS3YqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oeI3HnsFSoPGB9L8q9Vqtc8BRtMQ/wdADB40hNm1TTk=; b=T+MNb/cDtepmVD3gBRHhpAvRGHPjqT6KRIf7l/OmiIE77AGogsPOF7LztOtOdXJeB85qA3hs4TlEdN6iVZ5A2jx4+H49EASrczW9BHlL4ljH/LQGKvITKalOh2aNRamI/7MnWCRahDJqnb/8cRjIN+3J+EQh1lLwLgxMw6OEYeHJPMfxR96OrzFG+tOdSk/dmh47LDjyEqttIdu8tnMsSaoeNJq6jOIhqXIqRRHqBVSdxxncWJiOgnY9q3mIW/mtfr/5p9pPywmOmRdSEEIZXlSnBP3JYUXc5kyTeRlZmTc87FWFGo8Zy9N9Ap33VmAJqiateh0x0YJ0Uhouje6N0w== Received: from BN9PR03CA0342.namprd03.prod.outlook.com (2603:10b6:408:f6::17) by DM4PR12MB5357.namprd12.prod.outlook.com (2603:10b6:5:39b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:12:01 +0000 Received: from BN8NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::d9) by BN9PR03CA0342.outlook.office365.com (2603:10b6:408:f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 16:12:01 +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 BN8NAM11FT086.mail.protection.outlook.com (10.13.176.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22 via Frontend Transport; Wed, 1 Feb 2023 16:12:01 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.36; Wed, 1 Feb 2023 08:11:49 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 08:11:49 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:46 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 2/9] net/sched: act_pedit, setup offload action for action stats query Date: Wed, 1 Feb 2023 18:10:31 +0200 Message-ID: <20230201161039.20714-3-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT086:EE_|DM4PR12MB5357:EE_ X-MS-Office365-Filtering-Correlation-Id: 20e6c19a-d3c4-435e-4515-08db046f0d3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5pkDEKKUOpbyxIXP1GmvM0mMQS6PnG7ZwVM+VVmafLrBmhec+th9TNg1I9VY1t+bfsywNk2SFAmaYvfFvsjzDkqsiQQHSFJmnYn7L/Sq2+wwoaA8n8mVyt94pj1gMHm1rJ/iTWoUDRy+ZMj0u+NQ789dhyR1skHgW+lFojy9LF+b6+5d+BQdar0Gw2+fVCuSBXfAuYm1xNVcRs+hRg9L3Y54sPr4xrRnDVVofJjjlt+e7MCGLema8P3dgyx3jsM8fFnqaKK7kQNjhj1shRbrvlPYrRYSJsLdeb8DoD00ZfODg18GLbjh2b8UK4KGlG0kdvNRsp/LSessMfXkbZnsDsT9I2D9C1mPx6kEgn/+E3GJ2rtzdNDbH0QfHHlkiQiCrGOE+12B8JsO1Lz4yTlagBRXyGn2PSnDcy/vPeyKGID6xolM3fg51X2IfhbJbwbCKETF1Q5hNf3Mnz8GJvSLg6WTC9LNNFaZNCcfds5rZIRS1v1OgB+xFkBt2CQzXSx0mI2wFlyKH5GuS5KGJZQoHS9F+mINpNFlJMcxz2yPq6vWO2ZRZ+Mh59JsSwkHG7qrr2ZH3997oziDsFDlYT7SY3cA9LiNEkXabel4wende7TsV5wCnqMSuJ7jaW/aV+YR28tOOv9OeLKGdtnQdL5nyvwcFeM2+SBixq7lsTSFgCSN99b4LssP1r2RVMXXQjbkLetUyrv+Ga9GXZ7fZKYGzA== 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:(13230025)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199018)(36840700001)(40470700004)(46966006)(6666004)(41300700001)(70206006)(36756003)(6916009)(54906003)(316002)(8676002)(4326008)(8936002)(82310400005)(5660300002)(70586007)(7636003)(86362001)(356005)(82740400003)(36860700001)(107886003)(186003)(26005)(1076003)(40480700001)(426003)(336012)(2906002)(40460700003)(47076005)(83380400001)(478600001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:01.1091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20e6c19a-d3c4-435e-4515-08db046f0d3e 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: BN8NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5357 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org A single tc pedit action may be translated to multiple flow_offload actions. Offload only actions that translate to a single pedit command value. Signed-off-by: Oz Shlomo --- net/sched/act_pedit.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index a0378e9f0121..abceef794f28 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -522,7 +522,29 @@ static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data, } *index_inc = k; } else { - return -EOPNOTSUPP; + struct flow_offload_action *fl_action = entry_data; + u32 last_cmd; + int k; + + for (k = 0; k < tcf_pedit_nkeys(act); k++) { + u32 cmd = tcf_pedit_cmd(act, k); + + if (k && cmd != last_cmd) + return -EOPNOTSUPP; + + last_cmd = cmd; + switch (cmd) { + case TCA_PEDIT_KEY_EX_CMD_SET: + fl_action->id = FLOW_ACTION_MANGLE; + break; + case TCA_PEDIT_KEY_EX_CMD_ADD: + fl_action->id = FLOW_ACTION_ADD; + break; + default: + NL_SET_ERR_MSG_MOD(extack, "Unsupported pedit command offload"); + return -EOPNOTSUPP; + } + } } return 0; From patchwork Wed Feb 1 16:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124672 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACB61C64EC4 for ; Wed, 1 Feb 2023 16:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232954AbjBAQMI (ORCPT ); Wed, 1 Feb 2023 11:12:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbjBAQMH (ORCPT ); Wed, 1 Feb 2023 11:12:07 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F577640E for ; Wed, 1 Feb 2023 08:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fU3J1NTgBA85m3al876Zbx6vbu1PZM9ZuD6QTobGWuiBl5k3kupsNkUmiN7Pcdk5XrSVPYNUF3rfnm2P7c6bQS3jsy7utKajSwCnt7kUsrEcR/gecwHbOUi4iUYU1WGyHfe+wQkLQ05rKDJMkymToVfb4uVjioDjDUsWU5VfwhYpyK0/ZKINqMNxZFNqX5EukBv9tof16yS1fOrpdq779GY6ktIeFwAfJgY3Dy1DDxDJ8Rm/GNUO7y9IHqNZVO2Qsoh0GoFInhYcci6ZgG2uINFpr2rrrcJ6cPMOyBEkBZZpB2iVnvsNEuXcYuWf3EaUBW3he9cA0WomZIyVUbXs/A== 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=TG3Hfud968Ty635JdlT0H/qdo83zAV3Ssy7S9jtC/Wc=; b=GqLu0N5rnljyj9XKckM7KimWzvylKK7cydUc2DdJVbwLBYj68sBDzKUgtjxH5w3umLjQ/fk07wHrpg68IG1Lny6K7sd1b6yOts2EPWh378z3T3Yb2wB+iLx5SGx2ZCIBrGjOyn6Vk4vPTOfuZmEf9/xyETP/IaFeH8OwA5tr+wrNxHnBoRYgkPEwQBLYlCAbcQFlYBTH63RFKSsGOHCcXLdZt9gNaI6Sd8NqLprt4XVloKsNV89DW3eDhX8Ju6cIUnoZA7YRjA0r7rv7V/b6K5v1eQ0m6jaJSLtcNAdFsgPhnAPkB1pBKxV06FK2ufQpxlBOdurJTTDoKKwHlyzaDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TG3Hfud968Ty635JdlT0H/qdo83zAV3Ssy7S9jtC/Wc=; b=OiK9SGQQVAXpeygDxLtILln+1jVrCGyD2KqQGVBRk0n1t3Fd1IMEgxdXIvOjaM1WrW8glyU8mj3GVFmmdeJ87om46SRFltwEvXyXzv0dymmQQmGFqS2YGh1uofXks03vt2iDKvoI01Ozsi2YiVLUPxvPGY16di0alOQLvbJ1EHteMfZRyoU9OcjqjulSBTEJWx09Cgfsv4nZMSjjpQYrbfK9h7vL7oPhm2qwI7qKK5arHqrf4tRxm2AB45RegWFaxL18Bkn2IZhz4Xrb+3fkSF4IwiWk4Mgz8m7y/0DJlLY2OcJjrgbsYW+hfTR21fXCQjJlDK5EigSgFQE7UhrIiw== Received: from BN0PR08CA0030.namprd08.prod.outlook.com (2603:10b6:408:142::9) by PH7PR12MB6396.namprd12.prod.outlook.com (2603:10b6:510:1fc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Wed, 1 Feb 2023 16:12:04 +0000 Received: from BN8NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::99) by BN0PR08CA0030.outlook.office365.com (2603:10b6:408:142::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.23 via Frontend Transport; Wed, 1 Feb 2023 16:12:03 +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 BN8NAM11FT075.mail.protection.outlook.com (10.13.176.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:12:03 +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.36; Wed, 1 Feb 2023 08:11:52 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.986.36; Wed, 1 Feb 2023 08:11:52 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:49 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 3/9] net/sched: pass flow_stats instead of multiple stats args Date: Wed, 1 Feb 2023 18:10:32 +0200 Message-ID: <20230201161039.20714-4-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT075:EE_|PH7PR12MB6396:EE_ X-MS-Office365-Filtering-Correlation-Id: b3e56401-debd-4f4a-fe81-08db046f0ed6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oGk8DrlM5LxSJM4G9aGske0BNuTZokqlYorzhQ6x7vz44x0km0vNbtIVQHX+CJi2+/w4yYL/Sxue+wHEq5i7CushOIlTz9EIm+gcfqWH3EfVqK1SnByc4EjBvKLcB30z6jmI4lSeAA8Jy0SFZ8/XovWgpBZSpf8QYuxoJgw7YSbUfm6FQ13RoAX1yJ65odaWRh7hsXqoXlgXwWAKsdGWREZhXM4IyD57Cigc/97rDVa5weU/BT07JZLqONDWfq8TMNzhfWM1VxrXlfPiGdl4DVXlnBblCwxFlI3Hwsn7U5JqdyFerMWK8Tpd6abNWZ1HAHyVTBHNXmKNYNdKOZmF1GeEGtwb4aJElC2xyNDsEEh+JLcyLWkFeywYX7x633FohwFuRyYBpY6ZO07/BmWC4tWtMFk/51qPnDFRsuqOnjTzMlBOuUydUOMaY7iFTft1bi2NTwotJSWv6DL3jUgg5GdUFFCRj5w/AOjLVf/fzP8V9IEMUUqlie1LN/ULtpf176qkIOx0KgbcrlSKhUEHmtrZsWTKVjnLxC7Zs2hvuhe+HlypB2tzpE1++DfXsu8oaKIIjKEZX0hlwJfnK50Rk0HZ3PFUKT6SaknJ0UMOl/TL7Y83340QrZCpBcZfMzl7u5qzbtGZFoG8n0wYQUoFAMHWTjtqKoWoD7iamsXtaUs2hUnfckNl1YQbrhX4XPgrI7FWBN0F5zzLLn8NQpepNQ== 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:(13230025)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(83380400001)(82310400005)(36756003)(186003)(26005)(54906003)(336012)(426003)(316002)(47076005)(2906002)(82740400003)(8676002)(7636003)(107886003)(70586007)(478600001)(86362001)(6666004)(4326008)(40460700003)(2616005)(1076003)(8936002)(36860700001)(70206006)(41300700001)(5660300002)(40480700001)(356005)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:03.7877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3e56401-debd-4f4a-fe81-08db046f0ed6 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: BN8NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6396 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of passing 6 stats related args, pass the flow_stats. Signed-off-by: Oz Shlomo Reviewed-by: Simon Horman --- include/net/pkt_cls.h | 11 +++++------ net/sched/cls_flower.c | 7 +------ net/sched/cls_matchall.c | 6 +----- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 4cabb32a2ad9..be21764a3b34 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -294,8 +294,7 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) static inline void tcf_exts_hw_stats_update(const struct tcf_exts *exts, - u64 bytes, u64 packets, u64 drops, u64 lastuse, - u8 used_hw_stats, bool used_hw_stats_valid) + struct flow_stats *stats) { #ifdef CONFIG_NET_CLS_ACT int i; @@ -306,12 +305,12 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) /* if stats from hw, just skip */ if (tcf_action_update_hw_stats(a)) { preempt_disable(); - tcf_action_stats_update(a, bytes, packets, drops, - lastuse, true); + tcf_action_stats_update(a, stats->bytes, stats->pkts, stats->drops, + stats->lastused, true); preempt_enable(); - a->used_hw_stats = used_hw_stats; - a->used_hw_stats_valid = used_hw_stats_valid; + a->used_hw_stats = stats->used_hw_stats; + a->used_hw_stats_valid = stats->used_hw_stats_valid; } } #endif diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 0b15698b3531..cb04739a13ce 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -502,12 +502,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f, tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false, rtnl_held); - tcf_exts_hw_stats_update(&f->exts, cls_flower.stats.bytes, - cls_flower.stats.pkts, - cls_flower.stats.drops, - cls_flower.stats.lastused, - cls_flower.stats.used_hw_stats, - cls_flower.stats.used_hw_stats_valid); + tcf_exts_hw_stats_update(&f->exts, &cls_flower.stats); } static void __fl_put(struct cls_fl_filter *f) diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 705f63da2c21..b3883d3d4dbd 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -331,11 +331,7 @@ static void mall_stats_hw_filter(struct tcf_proto *tp, tc_setup_cb_call(block, TC_SETUP_CLSMATCHALL, &cls_mall, false, true); - tcf_exts_hw_stats_update(&head->exts, cls_mall.stats.bytes, - cls_mall.stats.pkts, cls_mall.stats.drops, - cls_mall.stats.lastused, - cls_mall.stats.used_hw_stats, - cls_mall.stats.used_hw_stats_valid); + tcf_exts_hw_stats_update(&head->exts, &cls_mall.stats); } static int mall_dump(struct net *net, struct tcf_proto *tp, void *fh, From patchwork Wed Feb 1 16:10:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124673 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8CDCC38142 for ; Wed, 1 Feb 2023 16:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbjBAQMI (ORCPT ); Wed, 1 Feb 2023 11:12:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232374AbjBAQMF (ORCPT ); Wed, 1 Feb 2023 11:12:05 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BE0E14497 for ; Wed, 1 Feb 2023 08:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IreEPS43oXlQ66KX3s9culOs8GTmG+bMopoT38MwaN1OgSTf5TSXzSLuqOAtyLNHIG0gZz61BuL6e/ljNakl8Gd7jpkl12TDBhjbDrgQBMsU1taLp9ZXR6dq7rrNl/UjLbeVRRjtfX5jOqNAawo99plzw/kY+5Ra6ygYDVCCWpxU1V7JDbXz4IHrFH+eaEb4ZVZYW65W8rqlBPzOXEVQleJrPFbtdKj/AhRN9LznNGbpdDLTo/a3qXWGRgr++kf57ef71yQNikDqkRMQsRq7+S1DeSIJQAn1exT+yxlGe/ATaWVYbslZv0rHQnJbx3qIKH7pVRfa8SId4jbECfepZw== 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=nBbcz3M4jLun1422FZgS5K2cfwY7BBYuh7iDUjLyxI4=; b=hwLWqGxecxI6O+4l1CoF1qZtjFcX40LhlbDcip/bvBM0nzY89m6gsnBoXBo+sbI4CWZNC5TCX3Y2cxQ2AB3W3koPZoHvCfGTxE554OZ4C3F/iHMdgmGnto8puo9LG4UEeKcC63XEemM1bHJsIX9EKsfkZX3zlLAM8xIJojxlQnqK23pavwolaLkfJLeCO9bJPvRjDJM10uXEYs3vW6FPMrGGffgjGguNMvJQh1QQq/JSZl/NpyZn/JBhrPNr2wZdVIKE2PN8HuFyiABI1HDQAjUvvz/dq9QbVSAuUv6taM++JBgwjUxn6HZzCZ3wAhtI7NSaH1QNEOHcjJTzqzA6mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nBbcz3M4jLun1422FZgS5K2cfwY7BBYuh7iDUjLyxI4=; b=mcO2nN2zdotzbEhA0Dm/LcOEMhUeDFlX9sYASnny4muAukMl/YsF9CsDqA1uAV+l72QzP2mjh4nkpQcIeCq7hrC++f3SeG4B2GtWAZ2KmOagtsZY1LRvDvTgwa+q4cx8hZHK9k7cfbLaXnIwDrqUIIHpRTZqQqWZLxyJZoOIVCAvm82C+SWUs21tl4V/YheMMqXRmUV4L/sDSh7eh3yWTxcMq1dcV/BZnd+nh501yN+3xINdeEyfs7xaB4YTdhsRdKT2JDzG5MTW+MxRcw/WTKLHPXja3E0iUG856QiPD3iOVUEWPcVzjcKEdFZI4/iAdEDT7xKpNcupcff9Yd7SMA== Received: from DM6PR02CA0060.namprd02.prod.outlook.com (2603:10b6:5:177::37) by DS7PR12MB5910.namprd12.prod.outlook.com (2603:10b6:8:7b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Wed, 1 Feb 2023 16:12:02 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::a6) by DM6PR02CA0060.outlook.office365.com (2603:10b6:5:177::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 16:12:02 +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 DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 16:12:02 +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.36; Wed, 1 Feb 2023 08:11:55 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.986.36; Wed, 1 Feb 2023 08:11:55 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:52 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 4/9] net/sched: introduce flow_offload action cookie Date: Wed, 1 Feb 2023 18:10:33 +0200 Message-ID: <20230201161039.20714-5-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT003:EE_|DS7PR12MB5910:EE_ X-MS-Office365-Filtering-Correlation-Id: e782745b-58f5-4d8f-a865-08db046f0e01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6ObWsbx6zjysnK7sopuyTel9fDhcAvZS8dIvu9vKcytKqiva7XxpkP8rx6VDZowwy/n8kRwp93f0+5wci7t7mNvf47rc+MdLL2bzwLZ442mWrnI+AtMfkmndA0LmotUA5A5xbljItKv7rvWGBMpW7YmzThtOc0paDspOyeyRU+O+ZnsYRuhvxCQDMGArt+zkeb0iy+zJz+DAyADO9p3wrw7bqtr9HBo+4Iyt8O5nW0wM1NDjtqXFjY69Msap6+r7ugO3pi+0CrMvR6sxd4nurpkVScw7attVnR9Tx2ELvIwwyEDb9Wex0bu/nvbOKx+HNgSv0NpHY7eSa4ty/ZK64IaDl4hkoBW7zi6X0r1VNoPxMR+iGRdtKSORHHHxxhjCv4LDMckjwWQYv74ldnH9845q8Rtg9/Ke402dceUYOUR6yI95RE6sVIvxPDu8fSc2LjV1JU2mjkyJ0yLhUTfhMnO6g4iEubdJa6D5OwBdfVUZ0/1VFuaVShyXlBVVURGJL/u3MJMIr9EwHsOyHlAZBLWzPIe4x4oirFNy+eQ6nuSFLdRH4OOWpOZbXePyqIMbc/XwxK1XRknuM68DMe9CoDNCI4PjWRAIs7J0x9f68keYXZ23FmlOTp1jNPeOSaFSes/R6CuCwVGtwyAHu3GjYL7PfH8Ekjy1O+NI7SvPux9VUSWqbMaOs2QLOpbVqJ6EXLgPyX7MbUE+eHJwYvepTA== 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:(13230025)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199018)(40470700004)(36840700001)(46966006)(40460700003)(336012)(186003)(8676002)(7636003)(2906002)(54906003)(5660300002)(316002)(356005)(36860700001)(8936002)(82740400003)(70586007)(41300700001)(4326008)(6916009)(70206006)(426003)(83380400001)(36756003)(1076003)(40480700001)(26005)(86362001)(82310400005)(47076005)(6666004)(107886003)(478600001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:02.4365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e782745b-58f5-4d8f-a865-08db046f0e01 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5910 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently a hardware action is uniquely identified by the tuple. However, the id is set by the flow_act_setup callback and tc core cannot enforce this, and it is possible that a future change could break this. In addition, are not unique across network namespaces. Uniquely identify the action by setting an action cookie by the tc core. Use the unique action cookie to query the action's hardware stats. Signed-off-by: Oz Shlomo Reviewed-by: Simon Horman --- include/net/flow_offload.h | 2 ++ net/sched/act_api.c | 1 + net/sched/cls_api.c | 1 + 3 files changed, 4 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 0400a0ac8a29..d177bf5f0e1a 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -228,6 +228,7 @@ struct flow_action_cookie *flow_action_cookie_create(void *data, struct flow_action_entry { enum flow_action_id id; u32 hw_index; + unsigned long act_cookie; enum flow_action_hw_stats hw_stats; action_destr destructor; void *destructor_priv; @@ -610,6 +611,7 @@ struct flow_offload_action { enum offload_act_command command; enum flow_action_id id; u32 index; + unsigned long cookie; struct flow_stats stats; struct flow_action action; }; diff --git a/net/sched/act_api.c b/net/sched/act_api.c index f4fa6d7340f8..917827199102 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -192,6 +192,7 @@ static int offload_action_init(struct flow_offload_action *fl_action, fl_action->extack = extack; fl_action->command = cmd; fl_action->index = act->tcfa_index; + fl_action->cookie = (unsigned long)act; if (act->ops->offload_act_setup) { spin_lock_bh(&act->tcfa_lock); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 5b4a95e8a1ee..bfabc9c95fa9 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3577,6 +3577,7 @@ int tc_setup_action(struct flow_action *flow_action, for (k = 0; k < index ; k++) { entry[k].hw_stats = tc_act_hw_stats(act->hw_stats); entry[k].hw_index = act->tcfa_index; + entry[k].act_cookie = (unsigned long)act; } j += index; From patchwork Wed Feb 1 16:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124674 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A947C05027 for ; Wed, 1 Feb 2023 16:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232614AbjBAQMJ (ORCPT ); Wed, 1 Feb 2023 11:12:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232374AbjBAQMI (ORCPT ); Wed, 1 Feb 2023 11:12:08 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2064.outbound.protection.outlook.com [40.107.94.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1EC177502 for ; Wed, 1 Feb 2023 08:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bjx6avri89DMMKEh3LbISDhs3ukX3vql60BXmjJ9USYgx35g36xXFNAYDuDoDGvQgDw0/7HOROx4lWvACNE545ldCLfqM0fjyK/v+0Q8bMLQU4tHhEmpEHR8Q0i0Za7ZZdab+LJmyHhf9brvkWYgl+OA+U4AcRBknpoe/b7vn9TypHVw8VhWyofzfcnTxNpkE6r/P3T5QfbbTWFyJ6b2XdRDsynYLqNbWw2nDVW5qNoYh/26EGPyXG61EOp9kHtuB1x9mxkRGCkmEb/r7lK5oO+Nf8Sk1DFSIh3DefSC6NKFO+M+i/eSPGCW5MIgZsJYUdTP4ix2aHGfdoGslOV/MA== 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=AAOnkL5YXIgT/OTV2HYLmkny8BnH9vvNOKGbpb5jgeI=; b=bEdKBFJgNZ1gO0+aNTAcKTTBY+A7ebw4N/olATOKY7tuo1W7YB9bMppR1hO4srizOI8Vm8z/yt8fVqI63xan6BbMWcwd+kHU4lq7joUr2+T1zjY/lIemonFdthxjzS6un4+g2xslFbjh0HJGBw1ZNLIulh9wCUyjYTTQGUhyh+Xm+wsNzxgT7k5p1lMMZhlVvVHcwzbPkiw3+sfvtQZjV1DhnCl9xv22elGH1IX0pZAPkfBz0LGJt4GjuFjcbBp2UMCn0vYDI/SMu8Pe/HjjN4lFD2W4cCTVx/Q2ggKj6ygHhxW5L/67QHK8h4vrXMYToe1+g4sHr1YcFzHUeRUEvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AAOnkL5YXIgT/OTV2HYLmkny8BnH9vvNOKGbpb5jgeI=; b=Okpq+oB35bUvsKPK1HeDcd3LyGTiobw2Hz8M3JdTkQnusAKcEO54MXJLbXUQZV5pG4NHNr/sBTpvXuDWwb/tktCIydblyde2Rhb0ArCelOLy+God+yf3+f8qbsSpH8kbaFt/120UxAMrJAVZSRppzBuxWNi1pkI7w3UkE9jN1k1m1By6ytZF3kxzvgQ2ZsE7GgRzrRTBaf0A8u60e2afVVYnt1rNUzyyVpILTrmsbCWHhb0qm2wreKZt0f73lmwAmlfttWcCWoyfsIwntc0Bl44D64umFk15oCdD6doeaaKUJzSwotsQvZpXjyJmTHyqdrCFu+GswhXU5GZEfD0o5A== Received: from DM6PR07CA0131.namprd07.prod.outlook.com (2603:10b6:5:330::19) by SA1PR12MB7127.namprd12.prod.outlook.com (2603:10b6:806:29e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Wed, 1 Feb 2023 16:12:05 +0000 Received: from DM6NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:5:330:cafe::e9) by DM6PR07CA0131.outlook.office365.com (2603:10b6:5:330::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:12:05 +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 DM6NAM11FT100.mail.protection.outlook.com (10.13.172.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Wed, 1 Feb 2023 16:12:05 +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.36; Wed, 1 Feb 2023 08:11:58 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.986.36; Wed, 1 Feb 2023 08:11:58 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:55 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 5/9] net/sched: support per action hw stats Date: Wed, 1 Feb 2023 18:10:34 +0200 Message-ID: <20230201161039.20714-6-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT100:EE_|SA1PR12MB7127:EE_ X-MS-Office365-Filtering-Correlation-Id: f692d22e-94b1-424f-3553-08db046f0faf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WhoBXNCuw882orCIEAOBc72HuQXH2Sg4F5yuwYnhU3qK6wbdffSE/vhRWG0PnuMeABB7V3qFYsxkwHKWkZXryaw5v6s/WmYBYrdlqpwTR3PbtGskICXGj8oCyPysKlbfFnQFXPRD7HNB6RPY7OPNC2pDmPQ4IwUc2XkHsZsV0DvglLAFSoIDalCq8Qm+XEGejYmdpp9NBm8X22WNmSzTySxlYs/aSnnDh8BwzURQqt0rQxssQE7Kk4/spdTYab9HK8qaBGS+1MMqAdJ+BCp/WJaqi9JXMPRxRuq6oM83uGira3FRKkTdD1bEfiaFwlfImX6vUtMsguBUKAy+5/HTSF0M53IoXVCvd7wA5sdZAioLzjWA84b9EbZSdIM4DemhCFMq5X8FjT7/Fgvde4V0SO1alZW/SIs8qfvTPSi/uTuCTsxjAa7C0WHO9mc92CcQfmfgOxCAg29vvm7sUnMdm/SshjfG88+zWg2wKs6NAWrNy0nrqGXJdy3TmRAk7jeooQ9Q/OmV2MbNd6PB8db2Qd+hZYGQOzeuEPx7NiZkpM5CGdNZ65gmnQJXMHZBceL5RaHF58hN9L3LrlvnXUhzdxjJCNI4G1vfy+8A6DShvXGNQr9/emVuaF7rL3eFa1+mZR37pOdRd5Hz7FPeKTh9PaUAAe/Whz3cPCg8a06fqV3lbxcPjoMKnsBNKDOZPL+s/8/cwGbxgsPLSrbd24LVxS7GvDYdvVIEGgF5SqKyQGk= 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:(13230025)(4636009)(396003)(376002)(39860400002)(136003)(346002)(451199018)(36840700001)(46966006)(40470700004)(2906002)(41300700001)(36756003)(478600001)(54906003)(107886003)(6666004)(86362001)(356005)(82310400005)(40460700003)(47076005)(426003)(6916009)(336012)(4326008)(8676002)(316002)(40480700001)(1076003)(5660300002)(26005)(8936002)(36860700001)(82740400003)(70586007)(70206006)(186003)(7636003)(83380400001)(2616005)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:05.2516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f692d22e-94b1-424f-3553-08db046f0faf 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: DM6NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7127 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are currently two mechanisms for populating hardware stats: 1. Using flow_offload api to query the flow's statistics. The api assumes that the same stats values apply to all the flow's actions. This assumption breaks when action drops or jumps over following actions. 2. Using hw_action api to query specific action stats via a driver callback method. This api assures the correct action stats for the offloaded action, however, it does not apply to the rest of the actions in the flow's actions array. Extend the flow_offload stats callback to indicate that a per action stats update is required. Use the existing flow_offload_action api to query the action's hw stats. In addition, currently the tc action stats utility only updates hw actions. Reuse the existing action stats cb infrastructure to query any action stats. Signed-off-by: Oz Shlomo --- include/net/flow_offload.h | 1 + include/net/pkt_cls.h | 29 +++++++++++++++++++---------- net/sched/act_api.c | 8 -------- net/sched/cls_flower.c | 2 +- net/sched/cls_matchall.c | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index d177bf5f0e1a..27decadd4f5f 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -597,6 +597,7 @@ struct flow_cls_offload { unsigned long cookie; struct flow_rule *rule; struct flow_stats stats; + bool use_act_stats; u32 classid; }; diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index be21764a3b34..d4315757d1a2 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -292,9 +292,15 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) #define tcf_act_for_each_action(i, a, actions) \ for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) +static bool tc_act_in_hw(struct tc_action *act) +{ + return !!act->in_hw_count; +} + static inline void tcf_exts_hw_stats_update(const struct tcf_exts *exts, - struct flow_stats *stats) + struct flow_stats *stats, + bool use_act_stats) { #ifdef CONFIG_NET_CLS_ACT int i; @@ -302,16 +308,18 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) for (i = 0; i < exts->nr_actions; i++) { struct tc_action *a = exts->actions[i]; - /* if stats from hw, just skip */ - if (tcf_action_update_hw_stats(a)) { - preempt_disable(); - tcf_action_stats_update(a, stats->bytes, stats->pkts, stats->drops, - stats->lastused, true); - preempt_enable(); - - a->used_hw_stats = stats->used_hw_stats; - a->used_hw_stats_valid = stats->used_hw_stats_valid; + if (use_act_stats || tc_act_in_hw(a)) { + tcf_action_update_hw_stats(a); + continue; } + + preempt_disable(); + tcf_action_stats_update(a, stats->bytes, stats->pkts, stats->drops, + stats->lastused, true); + preempt_enable(); + + a->used_hw_stats = stats->used_hw_stats; + a->used_hw_stats_valid = stats->used_hw_stats_valid; } #endif } @@ -769,6 +777,7 @@ struct tc_cls_matchall_offload { enum tc_matchall_command command; struct flow_rule *rule; struct flow_stats stats; + bool use_act_stats; unsigned long cookie; }; diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 917827199102..eda58b78da13 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -169,11 +169,6 @@ static bool tc_act_skip_sw(u32 flags) return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false; } -static bool tc_act_in_hw(struct tc_action *act) -{ - return !!act->in_hw_count; -} - /* SKIP_HW and SKIP_SW are mutually exclusive flags. */ static bool tc_act_flags_valid(u32 flags) { @@ -308,9 +303,6 @@ int tcf_action_update_hw_stats(struct tc_action *action) struct flow_offload_action fl_act = {}; int err; - if (!tc_act_in_hw(action)) - return -EOPNOTSUPP; - err = offload_action_init(&fl_act, action, FLOW_ACT_STATS, NULL); if (err) return err; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index cb04739a13ce..885c95191ccf 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -502,7 +502,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f, tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false, rtnl_held); - tcf_exts_hw_stats_update(&f->exts, &cls_flower.stats); + tcf_exts_hw_stats_update(&f->exts, &cls_flower.stats, cls_flower.use_act_stats); } static void __fl_put(struct cls_fl_filter *f) diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index b3883d3d4dbd..fa3bbd187eb9 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -331,7 +331,7 @@ static void mall_stats_hw_filter(struct tcf_proto *tp, tc_setup_cb_call(block, TC_SETUP_CLSMATCHALL, &cls_mall, false, true); - tcf_exts_hw_stats_update(&head->exts, &cls_mall.stats); + tcf_exts_hw_stats_update(&head->exts, &cls_mall.stats, cls_mall.use_act_stats); } static int mall_dump(struct net *net, struct tcf_proto *tp, void *fh, From patchwork Wed Feb 1 16:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124676 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3E3EC636CD for ; Wed, 1 Feb 2023 16:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232960AbjBAQMo (ORCPT ); Wed, 1 Feb 2023 11:12:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232409AbjBAQMY (ORCPT ); Wed, 1 Feb 2023 11:12:24 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061.outbound.protection.outlook.com [40.107.94.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1ED7783C9 for ; Wed, 1 Feb 2023 08:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/w7AbLZ7GxiPxxeCc3z9aEDMto+blQhKlJBXmEyDHLtGfBKKZWbd5Z7zf89SpGshaMzJEh3iem8+FvTJAp6Is7dEEXXHlALyoc6O8xNOwiree5ZCGLKfh6DX6WnlOTpcLL9YtKew7v4iJ+wYbaBSm40+414lWZEWapTLV9+BGeHjsDMRn1wlhIrcnYGwrglTUGHhEURo5DfTFUD3BleZyoLy5+3G+y1jMNyamDnCpkT6zE4bYJQcJdbBzeOg4G+GbmQy/ilkm70RpOJXFrOrDrc9ZAORecCy0lOq6U72lnFTT+iJfQrvgHt4RHZXoGpfXIpXPwad0XrytuyNBTIIg== 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=bMfHc5isviPAq4o9ckZeUYS1gFA00N0SeOsvV31q0tU=; b=aXfU/Zw3X3mwB0dJ7edGiT1qeYzHYMULiFBoEU6T6abeQ0SvPNCge/Iwxy7eprJeFTep3wSUomTfFhnPT0Bx0ZGmEBiNLx4hrW5S04Y2tRPCeWxdKg/1g8iNm6tBUoIdiSjUhTvjbN/zY5Nl+ViifdXHQMTyjdCn2OZRgVm4fwmiJXPu31Wq3gjgAuSO7znQ5HLYpCjdMcvH6Zl8JV8Zp80qWcogU3Y26vRRmt6HPFYSvPwhnDdxuSikTjd20R6lgiXFcuMspFQM16IJTwOwmPf8dHIb3XJGt4l4sjdTq+ID3O6x9S6WarvTpIFROx75wWmp/KwSfp5paFsxhT6WsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bMfHc5isviPAq4o9ckZeUYS1gFA00N0SeOsvV31q0tU=; b=aNawsVg0DaK0tv6upXTaJ0TlcfpRpIzI6k7NrVjAEh2I5gR2yyYC4l7+lz87N0JjXW0s44XP2Vyu1Wd7rKc5b6exfY33jPbhaHnLffP11+qjOzlSz7qmDf13cXS//nnOPTKS2qHnPp26nlXa7Fkl2PLa9zvkKugrxvevcdOEAhZS3LkRVGXv2f6vF7jjHvvEhRyhrqbe/1QeMnLahImRo8W1+8JidzkjNpgJzbnvkLd549CYxQvzLDSVQqIURsJlayfDJ5o+t1bDlIIoy/04hvoC5x5Ek34sk7kvBao0meC8FGvFN5H8bOpA5H/ndRRH6e3jNvmXRR7fiWbC75t9FA== Received: from BN0PR08CA0011.namprd08.prod.outlook.com (2603:10b6:408:142::33) by SA3PR12MB7878.namprd12.prod.outlook.com (2603:10b6:806:31e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:12:12 +0000 Received: from BN8NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::79) by BN0PR08CA0011.outlook.office365.com (2603:10b6:408:142::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22 via Frontend Transport; Wed, 1 Feb 2023 16:12:12 +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 BN8NAM11FT075.mail.protection.outlook.com (10.13.176.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:12:11 +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.36; Wed, 1 Feb 2023 08:12:02 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.986.36; Wed, 1 Feb 2023 08:12:01 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:11:59 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 6/9] net/mlx5e: TC, add hw counter to branching actions Date: Wed, 1 Feb 2023 18:10:35 +0200 Message-ID: <20230201161039.20714-7-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT075:EE_|SA3PR12MB7878:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ecee9eb-bbfd-4816-8aa1-08db046f13a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qP+xw+ruNZvi0yYiFJZT7KJ6pmdrBUR+wqOY2mrFFp/plkDLJu/ZBInIQinKwuDYR3h4S/iuYvNXsA5dkZdDPlEIbNjXxrozPXqG+62suVAIDptFZsqaatxpSxBzs6TiBpnz8RLiO0wh6fGEtTE76xmTq9uFmHP+eO7dDFHhdDpHJfldQHR//B6F+u39bSqUP/jdujmP3a7VDL7BAdvmn2bchhgWC3FjdVf7QBUNiMvvj0wCYUGAw09Bwr/98rgfQCfSOfQvwvJ0Xy7Ltxo30yvk7jxV1fwnsJbSvRmaagYNnWP4kFL+NN4gGx0E8C6ygTmQe/OA8ApDLlmFGpm17tpTjObtIFLEGkAJH0K39FRUg/zxO+VGGbU9T+xrPcFqvmlvz4IeeynltVKUvJln/WvdjdNlk5j9poKPd5J+6OE4948zTZWb+TpCN/dJIzv20yiMoCkPFvj6RUxivciJx9gE8R1BTZfQlSjelnsBOfohz252dwGtfCLw16MBM0bgq5gmgAmmwXvav2qFIDdw5il1mcM8Cs4Gk7aL+L8li1mshQskcI7jhiaQVY7MWQdaleXGJWkkFZktCErVXJpfqfhhJ18P7bsW3EZEh9szDYjLdM+TJC46aCUuC8HLQ6vD0QOEF0D91mZq0xlGltOvpjOqg/UZ5P8i/zp9Diyp8pIW5DtU1SnC0D+Y87/CVwxL3hYAbCAQLHhb9fFDj0kQsQ== 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:(13230025)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(4326008)(2906002)(5660300002)(1076003)(36756003)(6666004)(107886003)(8936002)(186003)(2616005)(41300700001)(7636003)(70206006)(26005)(70586007)(426003)(47076005)(40460700003)(336012)(478600001)(6916009)(40480700001)(86362001)(8676002)(316002)(82310400005)(54906003)(356005)(82740400003)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:11.8654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ecee9eb-bbfd-4816-8aa1-08db046f13a7 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: BN8NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7878 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently a hw count action is appended to the last action of the action list. However, a branching action may terminate the action list before reaching the last action. Append a count action to a branching action. In the next patches, filters with branching actions will read this counter when reporting stats per action. Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 4e6f5caf8ab6..39f75f7d5c8b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3796,6 +3796,7 @@ bool mlx5e_same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv) INIT_LIST_HEAD(&attr2->list); parse_attr->filter_dev = attr->parse_attr->filter_dev; attr2->action = 0; + attr2->counter = NULL; attr2->flags = 0; attr2->parse_attr = parse_attr; attr2->dest_chain = 0; @@ -4095,6 +4096,10 @@ struct mlx5_flow_attr * jump_state->jumping_attr = attr->branch_false; jump_state->jump_count = jump_count; + + /* branching action requires its own counter */ + attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + return 0; err_branch_false: From patchwork Wed Feb 1 16:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124675 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ED6EC38142 for ; Wed, 1 Feb 2023 16:12:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229454AbjBAQM2 (ORCPT ); Wed, 1 Feb 2023 11:12:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbjBAQMT (ORCPT ); Wed, 1 Feb 2023 11:12:19 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04738783C8 for ; Wed, 1 Feb 2023 08:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXVCJ1m/amfIYKhSOZjR1sD2WGHhPRZ3ZnkLTAJ/9iN3O+PZS5eZuxWpK/KCNKyFl+G8+On8u+YdlJpZD61NxDvPZfIIrt/48R3hThdnYUe9QR2/rEqaSyFumPKSt4D2UL0EByZclE/lmtgh6+do1fqYLnmarZB5Gpb8p/7O/Ybg8HsHaQZgUtVuAUZ2RH5kJ0PXI6PD9RHJwPsa+f3GY9L/FUaXzMVYQCeRVrb8rddWT9mT+gqkuIZIXyDDzBGrM9a6UfAzeT1dSZPw7HiVvOL+7XPTwNitkZ25tQFGMTMMwpOqZrNSPDGuivdGeqcbK3tYLF4myHR9LeY9goaTCg== 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=8jfFfoImAJIqhJ6Yj2CFjv8Yfc3z3/hD+s92ePxhMxg=; b=AungUNzy0WapoDNA8Tldb8BE7QkdybCIV4+Q7uLn2S8NqyoUnUe4+lHNzcD5Nj4WYIgJbqeDsUk3urH+a+3D+scx/ynxuV2He6ynE5ldbxxncFE/lISnF3UAHfeNQiwiBdf7R0q/XxVydS9fqCXPfe4lo3h+bp5B9ASdai3I31e/goQOvEFNvkWey2V4eeSKY3t11wTcZnm7H+vtAJAwZ6/5eje5rpiy2MCR01Bsr9wvCnO4/fTtMDFVGU8Ndp6wN3TPWrUrwSf2LSaABqDF2B5xrk7lI9Y0FOa1FnXPKrubrzNG5kDkK/HRw3H13g4HyPRRtgzNoW7XDkQpZ8DI5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8jfFfoImAJIqhJ6Yj2CFjv8Yfc3z3/hD+s92ePxhMxg=; b=mOskJEIjDFYxXkX/JVZhS2dn2M7nyG6eRqX4wLj1DLUl9afUvQeTQsabbSGsTGv/fMuGAfh2MZhHchRTg6jIjn0FJjTEPGAeZqGyBpBItGQ9YMXNpKgnkeICEh0CxG2R2ccpTY+f4SrdqnV/HaPLDwxcyalgKp5XdMUkaj5ukJYGzd8Iv0laXflotHn6FngkJoaOfPSnnwL8IKACzERwQoQQaVaHS5zdwdaIkUqJMnLxh0srgvDl2uNi280OU5w+EA6zLSZlnU79se+jtPvTXusBRe90MiRiBn7KCLNVCto0bSRWQiITp76sLJ8ScbxQ5E0UUdnEwRxZ1Kv5FoMnUQ== Received: from DM6PR07CA0110.namprd07.prod.outlook.com (2603:10b6:5:330::26) by PH7PR12MB6418.namprd12.prod.outlook.com (2603:10b6:510:1fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:12:09 +0000 Received: from DM6NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:5:330::4) by DM6PR07CA0110.outlook.office365.com (2603:10b6:5:330::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22 via Frontend Transport; Wed, 1 Feb 2023 16:12:08 +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 DM6NAM11FT100.mail.protection.outlook.com (10.13.172.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36 via Frontend Transport; Wed, 1 Feb 2023 16:12:08 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.36; Wed, 1 Feb 2023 08:12:05 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 08:12:04 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:12:02 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 7/9] net/mlx5e: TC, store tc action cookies per attr Date: Wed, 1 Feb 2023 18:10:36 +0200 Message-ID: <20230201161039.20714-8-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT100:EE_|PH7PR12MB6418:EE_ X-MS-Office365-Filtering-Correlation-Id: 833c81cd-ebda-4ca0-1552-08db046f11be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Qcw3KR2Ar0ud4FHvc7+uiwfoMXHsXTHC/gEwVmc/z14xlCA0pqrN7QYCaJC5zkhjr59B5kfd9Ujs4u9T0J4c3/HdlyndnOTGQGFQArNPl10pZcjDCWAN0gC/vVVdwJafc0dNeI5xTqzi0Yv3DCi5M0tk7SIAWC3IwoJv/du9XN6iYqy886OcyWngLlrlv5h30ZTL/ZJlpLWJvZ46Y7MEdqUcLmGt9aMMrdvJt1RXMVGjyjMSoBGpbAxxM7fk7DHf88YM+E5QZ/R6IJz7WtwC1EDWeTcRZan2T1tD82SnjK5SW3op3tYkJxvAVxo6deR7Q/69BrcgiErX6Xfg2u05nVGTTlt41h4t9HFYscktFNV1jkeXzYUXEMlt1aEEp35A4iZ+ybVMyPkb9bvbgww8z3VM/ewzzPKWPNL66CQJoYMvMs4wU0l2siYRFZFeoGKB8XiCnAmQ1s2Qw0+8xj0O7puG7R4XzrrHomk9NSYbvAY79ikdM62L5a5xLrwF3++BMdw2wGh95XahkJYkvob0F/0/ivENjIXUmtvBxjzjoRqdhm3Doow5BLZN/t5VniXPF2N/kubJAosh+Fe98ZNJzeGw9vMGzRqvlzEjFwPwTMLaJSc3v6qCYo+Bs5nTBjb2yX6fZAfa/Hu1xdwnr5Bc4WR3+6HrTeirQmKmTB3C8FKidTe87NSxIm+vLpRtp5Ca8WzL/oldc1zZ6fS1e/JtA== 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:(13230025)(4636009)(39860400002)(376002)(136003)(396003)(346002)(451199018)(46966006)(36840700001)(40470700004)(356005)(86362001)(82740400003)(36860700001)(70586007)(70206006)(316002)(7636003)(36756003)(8936002)(82310400005)(54906003)(8676002)(6916009)(4326008)(5660300002)(41300700001)(2906002)(40480700001)(426003)(336012)(40460700003)(47076005)(2616005)(478600001)(186003)(1076003)(107886003)(26005)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:08.7045 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 833c81cd-ebda-4ca0-1552-08db046f11be 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: DM6NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6418 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The tc parse action phase translates the tc actions to mlx5 flow attributes data structure that is used during the flow offload phase. Currently, the flow offload stage instantiates hw counters while associating them to flow cookie. However, flows with branching actions are required to associate a hardware counter with its action cookies. Store the parsed tc action cookies on the flow attribute. Use the list of cookies in the next patch to associate a tc action cookie with its allocated hw counter. Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 39f75f7d5c8b..a5118da3ed6c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3797,6 +3797,7 @@ bool mlx5e_same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv) parse_attr->filter_dev = attr->parse_attr->filter_dev; attr2->action = 0; attr2->counter = NULL; + attr->tc_act_cookies_count = 0; attr2->flags = 0; attr2->parse_attr = parse_attr; attr2->dest_chain = 0; @@ -4160,6 +4161,8 @@ struct mlx5_flow_attr * goto out_free; parse_state->actions |= attr->action; + if (!tc_act->stats_action) + attr->tc_act_cookies[attr->tc_act_cookies_count++] = act->act_cookie; /* Split attr for multi table act if not the last act. */ if (jump_state.jump_target || diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h index ce516dc7f3fd..8aa25d8bac86 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h @@ -70,6 +70,8 @@ struct mlx5_nic_flow_attr { struct mlx5_flow_attr { u32 action; struct mlx5_fc *counter; + unsigned long tc_act_cookies[TCA_ACT_MAX_PRIO]; + int tc_act_cookies_count; struct mlx5_modify_hdr *modify_hdr; struct mlx5e_mod_hdr_handle *mh; /* attached mod header instance */ struct mlx5e_mod_hdr_handle *slow_mh; /* attached mod header instance for slow path */ From patchwork Wed Feb 1 16:10:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124678 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86BFBC05027 for ; Wed, 1 Feb 2023 16:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232995AbjBAQNF (ORCPT ); Wed, 1 Feb 2023 11:13:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbjBAQMu (ORCPT ); Wed, 1 Feb 2023 11:12:50 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B96790B0 for ; Wed, 1 Feb 2023 08:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rowfgd1O1nGRfZqK2KlPrOVNBoEitptMYyZdjloHwazebyCx9y8VtdQmGfsYJEXW2AoGk6FqYPDWKvxrpX+KFh6liIvZ6wfvsZF6oae4WQxslT1cqx/nfZdU6wkAsUJsHRcbE+Y9PFX40TMNIQ9Fi3R98LYmNb9WltufYHZp+c620ZBjjvXT/cVs625lz5FRjiHDeRA6ShrA7HOOKsdvwHn0HNBozgHgZFXza+uFK3Gj5hMfBFXqym9xkkBweCJ/SNa4+TcXmVGr3VlnniqGZ/fzq9Y260cl2zahQT2qNJlUEfK4HKq6AlRmHdzXfLNYzyJ0UF7OEskxxoIbSxVhvw== 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=HVzv9mvApAag93n9pUYvFe2fI9bqKi/iTalr8zCR8aA=; b=iJVbcPvmFfqHWYNWtjkS2UrqVtVmkoWHJ1uAlCEm3qmzxpxVPRuRcjHFTmE7ip62dJsMcg4seIJoX7/uMMze0v0cL0BDL8c3cOeYDFuW3WXUdv3w/a+UgtgBP47bbYrtYTdHashLad7sfuKOx9ulMGrtVrkbPF7SFA+bX4tf3EQZ9tJwZQxCYbhgiAkyaELzOaAn9S47uG/lyD3QxT7g9EM063hrV+4WxmnfCO96SxMSE1m2CHGjtPz3Qsgkn3cj4rOjpfs3p/t26P4PNVscliGwtWHxpIKATcD4OZRF0jKLTsDmbX2/nsJJM1oNgfwHZSp4MkELOwn553VclPIohA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HVzv9mvApAag93n9pUYvFe2fI9bqKi/iTalr8zCR8aA=; b=ibqSfpGbVUToAoYwuwXVGXheb0T1BHUXf5T4LpzTHKMeHkzr3xKe5rR9+IGAcjIEF2FCxKhaZZs8BrSYJGdMUGjwe2gCfCdaIyVsVfmv1kfcznM2UInvjrBBd7s1UJ/Jnd/czcYatHwDq3N5sSwyn1atcLRHeBhN3+5fcTjNBPg2lDu/gHHrsfaZhzC5roYKc2lIyTCsRYxCszS4rnlxF6He5LWZkbQnGuHL+Ri2xpQ1H6EHI1yJhLqbkJCvFhlEZ1TJaxqg0q/nWtPIgoYRttOh2g4kSt018nvhNBMWeorHm2Wap/vomB0bm81wbKrJLD9tkd8AEaXMePGJGDjP9w== Received: from MN2PR16CA0014.namprd16.prod.outlook.com (2603:10b6:208:134::27) by SJ1PR12MB6338.namprd12.prod.outlook.com (2603:10b6:a03:455::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:12:19 +0000 Received: from BL02EPF000108EA.namprd05.prod.outlook.com (2603:10b6:208:134:cafe::5b) by MN2PR16CA0014.outlook.office365.com (2603:10b6:208:134::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24 via Frontend Transport; Wed, 1 Feb 2023 16:12: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 BL02EPF000108EA.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.21 via Frontend Transport; Wed, 1 Feb 2023 16:12:18 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.36; Wed, 1 Feb 2023 08:12:08 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 08:12:07 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:12:05 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 8/9] net/sched: TC, map tc action cookie to a hw counter Date: Wed, 1 Feb 2023 18:10:37 +0200 Message-ID: <20230201161039.20714-9-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000108EA:EE_|SJ1PR12MB6338:EE_ X-MS-Office365-Filtering-Correlation-Id: a8b8d37a-c203-42dd-791e-08db046f17d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i7o219+glffvNqW5yQeLXS8Ro/hMGAsO34irJ5cpYyXCPBM97enEGENpfMi1TRto5lbHI4LWLCEOOB/iR/JMaEMU4pcg7FhHG5tSr7qBCn0RcLR15X3wgQi+weHocVISeEyRYoTrENZJR8W7G31kqywe/AMZa/sg13p2U+b+by9eI6YVceSux/EtOaSqfW6riCXWzXrsJcKsdSQ0hxt0akKBw0zkMA6508jALeJ9y6UUe0wDV72rCoLzgdL8+ZLKh+m+8R4QF78/f0cZ0HCBA03KlcI2yLQd0hG+d440fCEZCbeeRixbYbm/dBaX/qzwNSYwgWHMtw6aMRYF+s/gFibfvSpouqWVgq9IQQUG5gW2m4bcIwjfbkQvaHFZ30s2f5Ji3HIsrrMh5iEC3S8FB6f6IvxP/bKNTo8O9662JhklUP7eiJfc747B8RhO/XQD9BVNgs5gNkQFyugXXn0lawZhVQf0OIVp+hff5KDpSAuHjeOTmgcZqRJkHX1dl8NH5tOeLN/JMmZVgMAYMf3U+OqJUlHTrY2XZkUBN0XQdC4jF8nWJG2eqAH/ZaV2RXF28Cp6zjpCDxNi5Hyl5wEum2iaZNluh3tVPsD/wdNhnKfhB61EZCUsJaQIROKjS4clhkaM315ZcwXJYIOqpr1O+QhL1TwGhllyi/blI1JnpVM+FTuNkr8iLNhYFYRp2/h1oa8t3d4xn4OMiWdN4w/ISA== 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:(13230025)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199018)(46966006)(36840700001)(40470700004)(47076005)(4326008)(426003)(5660300002)(70206006)(70586007)(336012)(6916009)(82740400003)(8936002)(41300700001)(7636003)(40460700003)(54906003)(83380400001)(316002)(40480700001)(36756003)(8676002)(86362001)(356005)(36860700001)(478600001)(82310400005)(26005)(186003)(1076003)(107886003)(6666004)(2906002)(30864003)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:18.8642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8b8d37a-c203-42dd-791e-08db046f17d3 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: BL02EPF000108EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6338 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently a hardware counter is associated with a flow cookie. This does not apply to flows using branching action which are required to return per action stats. A single counter may apply to multiple actions. Scan the flow actions in reverse (from the last to the first action) while caching the last counter. Associate all the flow attribute tc action cookies with the current cached counter. Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan --- drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../ethernet/mellanox/mlx5/core/en/tc/act_stats.c | 153 +++++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/tc/act_stats.h | 23 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 3 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 44 ++++++ 5 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile index cd4a1ab0ea78..06f511fcbd8e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -47,7 +47,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \ en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o \ en/tc/post_act.o en/tc/int_port.o en/tc/meter.o \ - en/tc/post_meter.o + en/tc/post_meter.o en/tc/act_stats.o mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c new file mode 100644 index 000000000000..d1272c0f883c --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include +#include +#include "en/tc_priv.h" +#include "act_stats.h" +#include "en/fs.h" + +struct mlx5e_tc_act_stats_handle { + struct rhashtable ht; + spinlock_t ht_lock; /* protects hashtable */ +}; + +struct mlx5e_tc_act_stats { + unsigned long tc_act_cookie; + + struct mlx5_fc *counter; + u64 lastpackets; + u64 lastbytes; + + struct rhash_head hash; + struct rcu_head rcu_head; +}; + +static const struct rhashtable_params act_counters_ht_params = { + .head_offset = offsetof(struct mlx5e_tc_act_stats, hash), + .key_offset = 0, + .key_len = offsetof(struct mlx5e_tc_act_stats, counter), + .automatic_shrinking = true, +}; + +struct mlx5e_tc_act_stats_handle * +mlx5e_tc_act_stats_create(void) +{ + struct mlx5e_tc_act_stats_handle *handle; + int err; + + handle = kvzalloc(sizeof(*handle), GFP_KERNEL); + if (IS_ERR(handle)) + return ERR_PTR(-ENOMEM); + + err = rhashtable_init(&handle->ht, &act_counters_ht_params); + if (err) + goto err; + + spin_lock_init(&handle->ht_lock); + return handle; +err: + kvfree(handle); + return ERR_PTR(err); +} + +void mlx5e_tc_act_stats_free(struct mlx5e_tc_act_stats_handle *handle) +{ + rhashtable_destroy(&handle->ht); + kvfree(handle); +} + +static int +mlx5e_tc_act_stats_add(struct mlx5e_tc_act_stats_handle *handle, + unsigned long act_cookie, + struct mlx5_fc *counter) +{ + struct mlx5e_tc_act_stats *act_stats, *old_act_stats; + struct rhashtable *ht = &handle->ht; + int err = 0; + + act_stats = kvzalloc(sizeof(*act_stats), GFP_KERNEL); + if (!act_stats) + return -ENOMEM; + + act_stats->tc_act_cookie = act_cookie; + act_stats->counter = counter; + + rcu_read_lock(); + old_act_stats = rhashtable_lookup_get_insert_fast(ht, + &act_stats->hash, + act_counters_ht_params); + if (IS_ERR(old_act_stats)) { + err = PTR_ERR(old_act_stats); + goto err_hash_insert; + } else if (old_act_stats) { + err = -EEXIST; + goto err_hash_insert; + } + rcu_read_unlock(); + + return 0; + +err_hash_insert: + rcu_read_unlock(); + kvfree(act_stats); + return err; +} + +void +mlx5e_tc_act_stats_del_flow(struct mlx5e_tc_act_stats_handle *handle, + struct mlx5e_tc_flow *flow) +{ + struct mlx5_flow_attr *attr; + struct mlx5e_tc_act_stats *act_stats; + int i; + + list_for_each_entry(attr, &flow->attrs, list) { + for (i = 0; i < attr->tc_act_cookies_count; i++) { + struct rhashtable *ht = &handle->ht; + + spin_lock(&handle->ht_lock); + act_stats = rhashtable_lookup_fast(ht, + &attr->tc_act_cookies[i], + act_counters_ht_params); + if (act_stats && + rhashtable_remove_fast(ht, &act_stats->hash, + act_counters_ht_params) == 0) + kvfree_rcu(act_stats, rcu_head); + + spin_unlock(&handle->ht_lock); + } + } +} + +int +mlx5e_tc_act_stats_add_flow(struct mlx5e_tc_act_stats_handle *handle, + struct mlx5e_tc_flow *flow) +{ + struct mlx5_fc *curr_counter = NULL; + unsigned long last_cookie = 0; + struct mlx5_flow_attr *attr; + int err; + int i; + + list_for_each_entry(attr, &flow->attrs, list) { + if (attr->counter) + curr_counter = attr->counter; + + for (i = 0; i < attr->tc_act_cookies_count; i++) { + /* jump over identical ids (e.g. pedit)*/ + if (last_cookie == attr->tc_act_cookies[i]) + continue; + + err = mlx5e_tc_act_stats_add(handle, attr->tc_act_cookies[i], curr_counter); + if (err) + goto out_err; + last_cookie = attr->tc_act_cookies[i]; + } + } + + return 0; +out_err: + mlx5e_tc_act_stats_del_flow(handle, flow); + return err; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h new file mode 100644 index 000000000000..4929301a5260 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_EN_ACT_STATS_H__ +#define __MLX5_EN_ACT_STATS_H__ + +#include +#include "en/tc_priv.h" + +struct mlx5e_tc_act_stats_handle; + +struct mlx5e_tc_act_stats_handle *mlx5e_tc_act_stats_create(void); +void mlx5e_tc_act_stats_free(struct mlx5e_tc_act_stats_handle *handle); + +int +mlx5e_tc_act_stats_add_flow(struct mlx5e_tc_act_stats_handle *handle, + struct mlx5e_tc_flow *flow); + +void +mlx5e_tc_act_stats_del_flow(struct mlx5e_tc_act_stats_handle *handle, + struct mlx5e_tc_flow *flow); + +#endif /* __MLX5_EN_ACT_STATS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h index b4e691760da9..0abe3313c673 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h @@ -100,6 +100,9 @@ struct mlx5_rep_uplink_priv { struct mlx5e_tc_int_port_priv *int_port_priv; struct mlx5e_flow_meters *flow_meters; + + /* tc action stats */ + struct mlx5e_tc_act_stats_handle *action_stats_handle; }; struct mlx5e_rep_priv { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index a5118da3ed6c..ec5d1fbae22e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -45,6 +45,7 @@ #include #include "en.h" #include "en/tc/post_act.h" +#include "en/tc/act_stats.h" #include "en_rep.h" #include "en/rep/tc.h" #include "en/rep/neigh.h" @@ -101,6 +102,9 @@ struct mlx5e_tc_table { struct mapping_ctx *mapping; struct mlx5e_hairpin_params hairpin_params; struct dentry *dfs_root; + + /* tc action stats */ + struct mlx5e_tc_act_stats_handle *action_stats_handle; }; struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[] = { @@ -286,6 +290,24 @@ struct mlx5_fs_chains *mlx5e_nic_chains(struct mlx5e_tc_table *tc) return err; } +static struct mlx5e_tc_act_stats_handle * +get_act_stats_handle(struct mlx5e_priv *priv) +{ + struct mlx5e_tc_table *tc = mlx5e_fs_get_tc(priv->fs); + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; + struct mlx5_rep_uplink_priv *uplink_priv; + struct mlx5e_rep_priv *uplink_rpriv; + + if (is_mdev_switchdev_mode(priv->mdev)) { + uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH); + uplink_priv = &uplink_rpriv->uplink_priv; + + return uplink_priv->action_stats_handle; + } + + return tc->action_stats_handle; +} + struct mlx5e_tc_int_port_priv * mlx5e_get_int_port_priv(struct mlx5e_priv *priv) { @@ -2035,6 +2057,10 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro if (err) goto err_out; + err = mlx5e_tc_act_stats_add_flow(get_act_stats_handle(priv), flow); + if (err) + goto err_out; + /* we get here if one of the following takes place: * (1) there's no error * (2) there's an encap action and we don't have valid neigh @@ -2131,6 +2157,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, if (flow_flag_test(flow, L3_TO_L2_DECAP)) mlx5e_detach_decap(priv, flow); + mlx5e_tc_act_stats_del_flow(get_act_stats_handle(priv), flow); + free_flow_post_acts(flow); free_branch_attr(flow, attr->branch_true); free_branch_attr(flow, attr->branch_false); @@ -5342,8 +5370,16 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv) mlx5e_tc_debugfs_init(tc, mlx5e_fs_get_debugfs_root(priv->fs)); + tc->action_stats_handle = mlx5e_tc_act_stats_create(); + if (IS_ERR(tc->action_stats_handle)) + goto err_act_stats; + return 0; +err_act_stats: + unregister_netdevice_notifier_dev_net(priv->netdev, + &tc->netdevice_nb, + &tc->netdevice_nn); err_reg: mlx5_tc_ct_clean(tc->ct); mlx5e_tc_post_act_destroy(tc->post_act); @@ -5393,6 +5429,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) mapping_destroy(tc->mapping); mlx5_chains_destroy(tc->chains); mlx5e_tc_nic_destroy_miss_table(priv); + mlx5e_tc_act_stats_free(tc->action_stats_handle); } int mlx5e_tc_ht_init(struct rhashtable *tc_ht) @@ -5469,8 +5506,14 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv) goto err_register_fib_notifier; } + uplink_priv->action_stats_handle = mlx5e_tc_act_stats_create(); + if (IS_ERR(uplink_priv->action_stats_handle)) + goto err_action_counter; + return 0; +err_action_counter: + mlx5e_tc_tun_cleanup(uplink_priv->encap); err_register_fib_notifier: mapping_destroy(uplink_priv->tunnel_enc_opts_mapping); err_enc_opts_mapping: @@ -5497,6 +5540,7 @@ void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv) mlx5_tc_ct_clean(uplink_priv->ct_priv); mlx5e_flow_meters_cleanup(uplink_priv->flow_meters); mlx5e_tc_post_act_destroy(uplink_priv->post_act); + mlx5e_tc_act_stats_free(uplink_priv->action_stats_handle); } int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags) From patchwork Wed Feb 1 16:10:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13124677 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 865A7C05027 for ; Wed, 1 Feb 2023 16:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232993AbjBAQND (ORCPT ); Wed, 1 Feb 2023 11:13:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233001AbjBAQMt (ORCPT ); Wed, 1 Feb 2023 11:12:49 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C6D47642E for ; Wed, 1 Feb 2023 08:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jKgsuMGoqo//3aQ9nnQQ+xWU2oBAVhubUuPr9qTswM+2CtWCq18gp2A2dwxtKEvU2wNmmW6xms/INn6vp8mztrzlWHvajWiBEkOQU4oi6sQLp0GUjfDHi/5fBUj7Hy/M45lOXMvDl8ekxS+LOirgEw4IxW0oDujQCBYGxgk9tSJhQB4VKO8fOYt88QGkk6wz1MAeFtls7IQBm+oeCUBus3jm84o3BshUS5xBNMZE6KodnPgdDMe2Xvp1q7+vjtZ4KREpC/r6rSRApqIxvrX4GaRdkmfTD6qcI3fx15WWaUOzXEgTD6MxTS6WtCaQXB5CuQNHWIdu7pV66B3ieioNyw== 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=KaISgpC5voDKifEzzzqYhorE/phygihpt+k/s6RbayI=; b=NTo9/C9diZ1N2Qxy15/vTuirIDOPXzwBoHnT5ooDE5BQg+pKWLMOs++OXKbck+trELb5js+gYHwv+/fFiQO95gn4+FTSOw7IY6Spwp0r5T8dOJ/jVII0Z2eBkMkz6VXcJjRQcZ9RCyKvuRPnyrxz3JigX8NWc29i3XBxVmxbL8tQME0AyeTl9kckgkEhVXp/uuiLvN3ozcnUY9Pzx6v1z0h6bvm8GCoK9xJuUXg+CwBdr/UQUCdpVcLGxmnVLo59tV106Yi5Nwdwq6JF75e223Vr2szytE80jBmFJFEQgmhyr298W1QagB2z1VY+JfcIFh6kCyFjIAKr1ie8LZ+D3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KaISgpC5voDKifEzzzqYhorE/phygihpt+k/s6RbayI=; b=KYj/yhy0w7LeG2wNOo/ffBYnCeTf8iu6JX+6/CZDLB1Z01OikZpQ0ndA0IDdy2S6EBCOGmnXQQ4Eix4FmgCwrM6emJvvM9OHROYX99M/GDSTfc1TNS8n6WbZTGGAM80CrMuL48eCNLLvg5T1iBlCbTZjFDcwqkqF9LvxepCvgeT15o+1vhwcsqv9FsfKMySIgKulZu7FQJxDNs1164ffhYtDuY1+8/gSeA892aEriDPEX7NlC3UQ3SG7G/1eLWaZMjVTqnSY2BX7EvOGjXUIYX007pfWOUBWIzooYhZ85iQOZx3NZluluBmK2RTp2VQo+RO+DBRN2vT/FO6z5D9hXQ== Received: from DS7PR03CA0093.namprd03.prod.outlook.com (2603:10b6:5:3b7::8) by PH8PR12MB7133.namprd12.prod.outlook.com (2603:10b6:510:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 16:12:19 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::32) by DS7PR03CA0093.outlook.office365.com (2603:10b6:5:3b7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 16:12:19 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Wed, 1 Feb 2023 16:12:19 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.36; Wed, 1 Feb 2023 08:12:11 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 1 Feb 2023 08:12:11 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 1 Feb 2023 08:12:08 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next 9/9] net/sched: TC, support per action stats Date: Wed, 1 Feb 2023 18:10:38 +0200 Message-ID: <20230201161039.20714-10-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230201161039.20714-1-ozsh@nvidia.com> References: <20230201161039.20714-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT004:EE_|PH8PR12MB7133:EE_ X-MS-Office365-Filtering-Correlation-Id: 23bac678-29ce-4889-c330-08db046f1844 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T24qgR8TS5UgyiubC6W4JuaW+i2JCHg+uoie6U+rXoy8N6V6STFKDinuNZxz2Yt30mCu0zkHlKxiFAjSY81qi1xDbzbUbGg1bErQx3j8RI0cL5yAd34jsCJcfF5LJKsDcAKH9BlYdjPiNNy33eExPYcaD67hCZOFxMmnMgsNBfAXc7DdVLrgMTTJlJZQnEXpHz0zDRgsEc7qPaHKbWXukmfBtmuti8+I+i4CnlP8aVz/GoygSMs9++25oC9RRTMTZ1hVa/hUYpvehwKO3opltBsT6I47m/EcMvMqHYGB1yuPQG9IxeJ4Bg6g09kmFw1jpgtJrbT1njDmq6pFTy+i2FZmuHszGBbUwX/V7pxlE8bElCFRcv5sLDrx4sEX1K38iokk4pl397UeaKpz6ViMWJgO2bmn4deVuYDyHakOlfT6Gvng2d6G7hqCMhG+A4PQ3qrCRXjxh5UxGMHGvWFNylC/7vEQtxzZnT+zY6F1LYyThm1bJel5qyNBlFQwbdvivJnSdStHEN3YVN2Um3MdIPs1uQ9JaY+0iCXDH9JrDv1hoNporh10R14ID/TPU3yHI/hGke9c62Ny6VSP4EM4c9nQC7Yr3zVxwDaHGUvZFlBHukjxuDvdHOUI1/tVdBl7IFQje24ZQDXfdqZOKeE6IjS4fA+sTTb6n3bdoFrQ8aYGnMeHt161EwPNljrGPtJvjTwqzd4j/sTukf5TbUr+Rg== 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:(13230025)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(8936002)(336012)(2616005)(186003)(54906003)(6666004)(26005)(5660300002)(40460700003)(8676002)(1076003)(107886003)(82310400005)(36756003)(4326008)(70206006)(6916009)(40480700001)(70586007)(41300700001)(426003)(36860700001)(47076005)(2906002)(478600001)(316002)(83380400001)(356005)(86362001)(7636003)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 16:12:19.6535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23bac678-29ce-4889-c330-08db046f1844 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7133 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Extend the action stats callback implementation to update stats for actions that are associated with hw counters. Note that the callback may be called from tc action utility or from tc flower. Both apis expect the driver to return the stats difference from the last update. As such, query the raw counter value and maintain the diff from the last api call in the tc layer, instead of the fs_core layer. Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan --- .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 2 +- .../ethernet/mellanox/mlx5/core/en/tc/act_stats.c | 44 ++++++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/tc/act_stats.h | 4 ++ .../net/ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 39 +++++++++++++------ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 + .../net/ethernet/mellanox/mlx5/core/fs_counters.c | 10 +++++ include/linux/mlx5/fs.h | 2 + 8 files changed, 91 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c index b08339d986d5..3b590cfe33b8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c @@ -589,7 +589,7 @@ static bool mlx5e_rep_macvlan_mode_supported(const struct net_device *dev) act = mlx5e_tc_act_get(fl_act->id, ns_type); if (!act || !act->stats_action) - return -EOPNOTSUPP; + return mlx5e_tc_fill_action_stats(priv, fl_act); return act->stats_action(priv, fl_act); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c index d1272c0f883c..f71766dca660 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c @@ -102,6 +102,9 @@ void mlx5e_tc_act_stats_free(struct mlx5e_tc_act_stats_handle *handle) struct mlx5e_tc_act_stats *act_stats; int i; + if (!flow_flag_test(flow, USE_ACT_STATS)) + return; + list_for_each_entry(attr, &flow->attrs, list) { for (i = 0; i < attr->tc_act_cookies_count; i++) { struct rhashtable *ht = &handle->ht; @@ -130,6 +133,9 @@ void mlx5e_tc_act_stats_free(struct mlx5e_tc_act_stats_handle *handle) int err; int i; + if (!flow_flag_test(flow, USE_ACT_STATS)) + return 0; + list_for_each_entry(attr, &flow->attrs, list) { if (attr->counter) curr_counter = attr->counter; @@ -151,3 +157,41 @@ void mlx5e_tc_act_stats_free(struct mlx5e_tc_act_stats_handle *handle) mlx5e_tc_act_stats_del_flow(handle, flow); return err; } + +int +mlx5e_tc_act_stats_fill_stats(struct mlx5e_tc_act_stats_handle *handle, + struct flow_offload_action *fl_act) +{ + struct rhashtable *ht = &handle->ht; + struct mlx5e_tc_act_stats *item; + struct mlx5e_tc_act_stats key; + u64 pkts, bytes, lastused; + int err = 0; + + key.tc_act_cookie = fl_act->cookie; + + rcu_read_lock(); + item = rhashtable_lookup(ht, &key, act_counters_ht_params); + if (!item) { + rcu_read_unlock(); + err = -ENOENT; + goto err_out; + } + + mlx5_fc_query_cached_raw(item->counter, + &bytes, &pkts, &lastused); + + flow_stats_update(&fl_act->stats, + bytes - item->lastbytes, + pkts - item->lastpackets, + 0, lastused, FLOW_ACTION_HW_STATS_DELAYED); + + item->lastpackets = pkts; + item->lastbytes = bytes; + rcu_read_unlock(); + + return 0; + +err_out: + return err; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h index 4929301a5260..002292c2567c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.h @@ -20,4 +20,8 @@ mlx5e_tc_act_stats_del_flow(struct mlx5e_tc_act_stats_handle *handle, struct mlx5e_tc_flow *flow); +int +mlx5e_tc_act_stats_fill_stats(struct mlx5e_tc_act_stats_handle *handle, + struct flow_offload_action *fl_act); + #endif /* __MLX5_EN_ACT_STATS_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h index f575646d2f50..451fd4342a5a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h @@ -30,6 +30,7 @@ enum { MLX5E_TC_FLOW_FLAG_TUN_RX = MLX5E_TC_FLOW_BASE + 9, MLX5E_TC_FLOW_FLAG_FAILED = MLX5E_TC_FLOW_BASE + 10, MLX5E_TC_FLOW_FLAG_SAMPLE = MLX5E_TC_FLOW_BASE + 11, + MLX5E_TC_FLOW_FLAG_USE_ACT_STATS = MLX5E_TC_FLOW_BASE + 12, }; struct mlx5e_tc_flow_parse_attr { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index ec5d1fbae22e..50432c9d78c0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -4128,6 +4128,7 @@ struct mlx5_flow_attr * /* branching action requires its own counter */ attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + flow_flag_set(flow, USE_ACT_STATS); return 0; @@ -4978,6 +4979,12 @@ int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv, return err; } +int mlx5e_tc_fill_action_stats(struct mlx5e_priv *priv, + struct flow_offload_action *fl_act) +{ + return mlx5e_tc_act_stats_fill_stats(get_act_stats_handle(priv), fl_act); +} + int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, struct flow_cls_offload *f, unsigned long flags) { @@ -5004,11 +5011,15 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, } if (mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, CT)) { - counter = mlx5e_tc_get_counter(flow); - if (!counter) - goto errout; + if (flow_flag_test(flow, USE_ACT_STATS)) { + f->use_act_stats = true; + } else { + counter = mlx5e_tc_get_counter(flow); + if (!counter) + goto errout; - mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + } } /* Under multipath it's possible for one rule to be currently @@ -5024,14 +5035,18 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, u64 packets2; u64 lastuse2; - counter = mlx5e_tc_get_counter(flow->peer_flow); - if (!counter) - goto no_peer_counter; - mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2); - - bytes += bytes2; - packets += packets2; - lastuse = max_t(u64, lastuse, lastuse2); + if (flow_flag_test(flow, USE_ACT_STATS)) { + f->use_act_stats = true; + } else { + counter = mlx5e_tc_get_counter(flow->peer_flow); + if (!counter) + goto no_peer_counter; + mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2); + + bytes += bytes2; + packets += packets2; + lastuse = max_t(u64, lastuse, lastuse2); + } } no_peer_counter: diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h index 8aa25d8bac86..a54f26dcd23a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h @@ -199,6 +199,8 @@ int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv, int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, struct flow_cls_offload *f, unsigned long flags); +int mlx5e_tc_fill_action_stats(struct mlx5e_priv *priv, + struct flow_offload_action *fl_act); int mlx5e_tc_configure_matchall(struct mlx5e_priv *priv, struct tc_cls_matchall_offload *f); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c index b406e0367af6..17fe30a4c06c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c @@ -504,6 +504,16 @@ void mlx5_fc_query_cached(struct mlx5_fc *counter, counter->lastpackets = c.packets; } +void mlx5_fc_query_cached_raw(struct mlx5_fc *counter, + u64 *bytes, u64 *packets, u64 *lastuse) +{ + struct mlx5_fc_cache c = counter->cache; + + *bytes = c.bytes; + *packets = c.packets; + *lastuse = c.lastuse; +} + void mlx5_fc_queue_stats_work(struct mlx5_core_dev *dev, struct delayed_work *dwork, unsigned long delay) diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h index ba6958b49a8e..90a2fe5839fa 100644 --- a/include/linux/mlx5/fs.h +++ b/include/linux/mlx5/fs.h @@ -296,6 +296,8 @@ int mlx5_modify_rule_destination(struct mlx5_flow_handle *handler, u64 mlx5_fc_query_lastuse(struct mlx5_fc *counter); void mlx5_fc_query_cached(struct mlx5_fc *counter, u64 *bytes, u64 *packets, u64 *lastuse); +void mlx5_fc_query_cached_raw(struct mlx5_fc *counter, + u64 *bytes, u64 *packets, u64 *lastuse); int mlx5_fc_query(struct mlx5_core_dev *dev, struct mlx5_fc *counter, u64 *packets, u64 *bytes); u32 mlx5_fc_id(struct mlx5_fc *counter);