From patchwork Sun Feb 12 13:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137437 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 D516CC636D3 for ; Sun, 12 Feb 2023 13:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbjBLNZ4 (ORCPT ); Sun, 12 Feb 2023 08:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjBLNZz (ORCPT ); Sun, 12 Feb 2023 08:25:55 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2055.outbound.protection.outlook.com [40.107.95.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3A96E079 for ; Sun, 12 Feb 2023 05:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E/ur7c3JKRE1QAPLL4hQwJ4v4qxwQ1SecyNt8hJDbS9/Z7/vjq9AzaBBUOoJmcSrsalER/LmHf2PuDtg8FheCh/BL24fTCEENIxE2J9sRalzx8LTnIZEg7F3fE+Y0S9F+nCsV539Bv/8QPYK9Euv3169EOMI+tDCJ1nwquC00NPEzr4gAgRuYx1zQntolVVfyKIqh30XmR278fDcDhehlqB+55Lbq3m+oR4Q6YLDGYRvw9YCVx8r6pWEwGODIZ+YGrTDZbQGKUjM1mdP9ETqKORiHOoBc/DrqUANPGXrdcNoEm5vFaUYv8a+cNQsMLUTCpVpnb50MYTXjtadI9gjNA== 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=i0LE/4kK4bVON/LOT6Vi+6cHXJ9Ccbk/SBeieH1qSpI=; b=XjB/oF6xLf/nY1E4mMdznUQLuH46HFgWPvOUIhucHrZIVChHlGJwTzNiiPXmXSO+4rauOKlczUbAiBRbMh7ZlTtcgX0PdQ7IuzSs1GDZjUIdawPd7gcWQtZ/z9QLVQeTUbNYZDS5pS+stvdEtg6yNF+OU44CL7g5fwpeshOS6sx+xD6BgkYwOTyZqlcaXFNdmpO379OoBNaF3TIZQptNRtq15L+BvZB0MpYav7xPI5ODg9dX4ZQfwJXXn7acXG7Frr7tr1J01OaxqSYBznlJ1SirbVCeFqvFAAcr7b6l8xsbKxTitYMr+qMcfR3DAIGLoFkOU+XdH5zDvZWlmDhKOQ== 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=i0LE/4kK4bVON/LOT6Vi+6cHXJ9Ccbk/SBeieH1qSpI=; b=EZixebqe3dhoTCs0upVyvKbWqLSHZav+mftWn2pGerO0/yD6hcpYE6ZB5t384o8xeOP07bEmUPG23u/PUEGmb9kHRjsmUyneUpZkiCE6p8+oyeoc+u1Y7hTZJjGoZ2X9fDPna9/dG2YAthFrH+NZLEN8R7EWYzSJNbUDYSuZkZn1pnmyjoPtPOFA3D69oW+yRsK8/wWWyUMWT9e5uvbrixJErRaIberLq33OJXy0ysHu54DZCyCRHN7wCMZ6glHjapggZSR+6x40FUriEs9lKUfMZEFUPJD3G4D9pXyFIihBvD3UADR0AM+KxDRxDRSRC/xDd41uFYV37J9JCE2j/g== Received: from DM6PR08CA0046.namprd08.prod.outlook.com (2603:10b6:5:1e0::20) by IA1PR12MB6019.namprd12.prod.outlook.com (2603:10b6:208:3d5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22; Sun, 12 Feb 2023 13:25:53 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::91) by DM6PR08CA0046.outlook.office365.com (2603:10b6:5:1e0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:25:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22 via Frontend Transport; Sun, 12 Feb 2023 13:25:52 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Sun, 12 Feb 2023 05:25:42 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:25:41 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25:38 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , Jakub Kicinski , Oz Shlomo , "Marcelo Ricardo Leitner" Subject: [PATCH net-next v4 1/9] net/sched: optimize action stats api calls Date: Sun, 12 Feb 2023 15:25:12 +0200 Message-ID: <20230212132520.12571-2-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT044:EE_|IA1PR12MB6019:EE_ X-MS-Office365-Filtering-Correlation-Id: b8d1751c-dc5c-46f9-6eba-08db0cfcaa0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TSlvtfU8fziw5rvQ23IBKcDl+nP6ykx5jtQ0HN4/YEbV78GgAxrpoKjWsUjjI78G2UG7Kk21mOv25u/Z4BMMIXCJeSr3GNkeAhvwpOdv3Mw/4j5olqYSZluKRPXs/Swa1MO41P7O6laSD2Ia2oD4Bhj2T3bCDg4TaKi4fWlPWB2o+UNPW8I/nyyKX/lvEOgp4gCN56vlUCazP6+Ryo1aa4strQAfB07ueXKCIly4XpVSaqVERUcSVKXwd9tfMFCafHjLhmUYy4N3GCspHleY2p3i2LszWQMfDpzyLBf2OPCj8A5bTSAuYBPHruIuE1RU9GtEHaONiTXFBj2luJ8DlIC1N6heb1NUzji5CGw3oLVj/FR+q7t2G6K8P/Psjby+9QO08r1WGVKNHJxnNcKxv9e2AyuJ6egzb/jajxaT1AHES9S0urxHyN+tJk1IWd65CbyKPlPN2htRe8xDGIyydkRtiacaHX7apeVR9ofN7CimPBqS4IVj5mYDWvZdxpl/jlUW9/8Tvm1BrVmdtNJ4Do5hf1jzNgywbfplAYDShFJbXJvzvRC2l39hq2LlfmlylHQ0APAAPHDUIX/n3itBbPtAwdiknnx+HPKmmcB//0jsKyuEwa6vCAww43evk6KjWVcW9+MdaOoKh0ZL0uoFjXrxlYpRcD3TkxaNJEku94L0Xh8Ra1XhqO/s+T1Jj/oolBi7zzhOjqtkNSdlBHJiGw== 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)(346002)(136003)(396003)(451199018)(46966006)(40470700004)(36840700001)(1076003)(26005)(6666004)(186003)(478600001)(47076005)(2616005)(336012)(426003)(86362001)(356005)(82740400003)(7636003)(40460700003)(40480700001)(83380400001)(5660300002)(70206006)(2906002)(41300700001)(8936002)(4326008)(8676002)(36756003)(6916009)(36860700001)(316002)(54906003)(82310400005)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:25:52.5662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8d1751c-dc5c-46f9-6eba-08db0cfcaa0b 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6019 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 Reviewed-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim --- 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 Sun Feb 12 13:25:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137438 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 78590C636D4 for ; Sun, 12 Feb 2023 13:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbjBLN0D (ORCPT ); Sun, 12 Feb 2023 08:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjBLN0C (ORCPT ); Sun, 12 Feb 2023 08:26:02 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2DDE10434 for ; Sun, 12 Feb 2023 05:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oWZGe20A3YK8CfHMgPr3exSJgQv3lg8onnWsVertGMINa9OrszW5Q5onZURNLKoL+iC+cef9TNInjqORfBQOnldOaaWpad5CIj0R2h64CVjP5CG6J0eTnM+z3YhlR7JyqKRREE6Js/88BJNdK1GSr3Ae4Fjgc5HShIMdB+nQXXH4TkuvbBO5jAz8NTDqsFgeSNupY2CHogU0kMNP7Lvj12HkLMFq0wHAng/hdmHwhhUJDQa4szR37Vgaut+mu5l0KTmPUZ0EUqcf+i83sSUEeJaRnh+0z40xcoCSoQEUTzl8CjEdzWXNwTakLgLXYjdtsw5v6FI2dpVx28pNGIJ6iQ== 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=ybXRsN9IdmAMRe6MgwX2bJhpwIeFFRbBYLbKtsV2l+4=; b=fjRHVLRBd8gpNvQfxkuVP6a5sBvgHeF0ri7IEVaACB59oAT/ND9evMlQIbygzMD9LvgL21WPaf8dCXLgdPSQpeq1MoVcW7+yl/4o8wo/xlLED32Z/0yDuzV42cWi2syrV058nAzijtfnGgI3CmA4E0s4OIXyU0CK3wuR0DHEiS0wzuk4H0RAndJFTUYyim/Wthq1ZXqbC5fJPU+3OnCFPjltONlsjtW/ODY2euzSvN5OmJekBzVObAD1G2GNRsi1nBvyrMxmkpy8H8bKBBPWZnKaQAKZLk+mqxtiWU4Nfp9iqQdcWTkRi2KWuAbNPnnWGWKs5Iqv6j7ZfLFQv4QFmg== 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=ybXRsN9IdmAMRe6MgwX2bJhpwIeFFRbBYLbKtsV2l+4=; b=g/o4O8x70QvXfwtctMh4YWDB+OjV3SIsFDjbvpTE/DZZ4hV08qbq2pGqVYuZxJ9s0SDLdMSid+MESz9qovrF1Hp1RGBNgxgirQW/rysQG1kyCRDgVN4fs/DRYYVyawOMynXTlE61b+qMBU2FWRAKp0moLylDbNaoo2fM9B+G1t7qYp09g20J+60v1prVQA/LsBr34U0J9b4yt0vTfgtJx+Y0xLwE7cNjKoS5in8Hh4D8Zwt+qJMeXhMuy+mmXuS7KTyKXzZQ2UM6O9ZfMdYXM69VtXesfePUiqkzWyciruErWPIpoeO7IJYy3OpQHSpMQYWWp+FhYipRzHm0qN/ihQ== Received: from DM6PR08CA0046.namprd08.prod.outlook.com (2603:10b6:5:1e0::20) by CH3PR12MB8258.namprd12.prod.outlook.com (2603:10b6:610:128::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22; Sun, 12 Feb 2023 13:25:58 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::91) by DM6PR08CA0046.outlook.office365.com (2603:10b6:5:1e0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:25:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22 via Frontend Transport; Sun, 12 Feb 2023 13:25:57 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Sun, 12 Feb 2023 05:25:46 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 12 Feb 2023 05:25:45 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25:42 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , Jakub Kicinski , Oz Shlomo , "Marcelo Ricardo Leitner" Subject: [PATCH net-next v4 2/9] net/sched: act_pedit, setup offload action for action stats query Date: Sun, 12 Feb 2023 15:25:13 +0200 Message-ID: <20230212132520.12571-3-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT044:EE_|CH3PR12MB8258:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f53d647-198a-45f7-fe24-08db0cfcad35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Te3Eg2+ZKuGf9j8NK5Vx9KYmd3lK0xaGjizFDW0U4+QAsUKlmBaZ/3i2jWtY+gqvbDwcvqu1tCnMa6YG8r1e9FWiuYwVh3dxBHf1/uoYzL94dZCW+VM5eauxcHXbWCSMGdiVfuzRZfeWBCpBn9SDYUJB7T3857P2GQev9d9/W53LfSnj+1zFZKfYRXBXYt8EJVg47BdUi/gdy8tCIbdkOCy+WaXPAOfw6/DOn3vJv6CY9wc2AfgL3LNzUfPm+skWsFSHc0SfPRccIHHbJfUMZ9KqGU3PKO4pVzo579OgLvmed+pckeSfxHCDhW26BioPSq3sZQAn66R8TBZVHSB/+2akI0uZrOkNXRVpeV4UhWihN2U7wKDBI8grEbu5PtG9evQhkGTowF+zFovZ6SbufCwAexdI8XIlDamI3ibuu2V8Zm4VuR/hszCAlXRdHF5dZKtOeNA3duZvZj1KWY0nxwxCD0sxOfD8073h/Nl/113NzeK8y+hRzAbAZdTzBDc3H0RUPFsDO6sFuhk+jBZNRkOHJX1dZjolLADHWKFpA+uEWX747OSRYW/tz4LEjYUTeLFJ4GgK4Mmf1W0ajcGPJoumzyJZjnBQ8wVCD4zA5Yf3f78GvsVX3EedKDQatLKAp3DeqqEf6ncyMx+B4vraFgXzcXmIT1qSI2Q+/WKxbhepOM0poK2mijPZfQhkRJ0wvgxIMdXVaH+73ExB8noE1g== 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)(136003)(376002)(346002)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(1076003)(6666004)(5660300002)(82310400005)(47076005)(26005)(8936002)(426003)(336012)(41300700001)(2616005)(186003)(36756003)(4326008)(6916009)(478600001)(8676002)(2906002)(70586007)(86362001)(70206006)(356005)(82740400003)(36860700001)(40480700001)(54906003)(83380400001)(40460700003)(7636003)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:25:57.8783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f53d647-198a-45f7-fe24-08db0cfcad35 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8258 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 Reviewed-by: Simon Horman Reviewed-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim --- Change log: V1 -> V2: - Add extack message on error - Assign the flow action id outside the for loop. Ensure the rest of the pedit actions follow the assigned id. V2 -> V3: - Fix last_cmd initialization V3 -> V4: - Compare all action types to the first action --- net/sched/act_pedit.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c42fcc47dd6d..35ebe5d5c261 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -545,7 +545,28 @@ 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 cmd = tcf_pedit_cmd(act, 0); + int k; + + 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; + } + + for (k = 1; k < tcf_pedit_nkeys(act); k++) { + if (cmd != tcf_pedit_cmd(act, k)) { + NL_SET_ERR_MSG_MOD(extack, "Unsupported pedit command offload"); + return -EOPNOTSUPP; + } + } } return 0; From patchwork Sun Feb 12 13:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137440 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 C297EC636D4 for ; Sun, 12 Feb 2023 13:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbjBLN0J (ORCPT ); Sun, 12 Feb 2023 08:26:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjBLN0G (ORCPT ); Sun, 12 Feb 2023 08:26:06 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD27126EE for ; Sun, 12 Feb 2023 05:26:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oO+O3FfDoxmGgY9etMp6KfG3pJbBNsHL5M3LGsTFW3twiDO4iu369MdGLIOD5p5zW+FQtG64IGhIf1kcTZiw3uS+yiM3fYvy7LlE/pldIvG+zu+mzgGfY4g5YyBZ+fbMAP0ytR5HqsTGwqVCBxAfjpru6LiDCzumrNvdWYUAaBjKsI2reELNsMK8Z9YQ8QQW+JVinwM6SQ3mQatwiSp1tjvl3SoYzm3WQoha6jtmdzpgHFHO7dAtjhIIB86Enci0Wn1CysWZI/9gt3IAVcH4rEWXDzh9wq8Hq/JziymOKiUoIGtWs4FV8I4m3p1iexBcMceRo6/z1w5Fs4c7S6DfXg== 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=dnArYJSINm0ldiKEqtgZ6wzZhB1KmIgF0uMxsoBZRK4=; b=RF5yIqDXBvtjqBl5hXlIs0H65e4+L/CFj2PTwmSX5BSVf/Bbla8y8qAfq+AeNqYnXRUNzkHe+UdZR/L3GuX/XNq4kro3k+sQNobV/611Cgo+QIbSEHlSspsTrOM2GcQBF0vlrg1D7p7gx5GqjfP+Ia0hX7Hv422FWIkBsUcWxM7Wllm+YB/PULktmxUEH2ROZQ4M2COFNXXPNzdxgMRX+6JJ2wTYcJ33EPOqvHuFamCmBeQW57q35D7IzWS/i8iKk12X3ijTCUzKJiO6Bq1OYONuO7+rOymKeF8v8H4GEUCt90dbnXlIpHYRvvrk5Xwxd/OL3sPUMpZShVBd9Xl5qw== 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=dnArYJSINm0ldiKEqtgZ6wzZhB1KmIgF0uMxsoBZRK4=; b=jhx2lYCrBnG5Lk8nk1ZVZmn7ySKkKNTq+7I/yqyZuQXycaqRgZOZQaIf84I/XIIit3QvJhhOygTtfarduCVH1NhUN3TJZbCGBxJd03Q3dfGQ1UraQiI/pTlXF6JKJQENhF0aWWMAsjHrmA+egUst15LJp9mAz+mt8fSEg6sO+44iZEiUFwBUFQPaEyBrpo4D6BkTu/gCEY8mzpNBqvBz+P+QERhnpKVymt+zy8Pt/PblhDgPRv0bglNLvd8Ce+rzc/w4h+ManWgx94+BP1xxEZrR/ltdG+bqhlrwhjfbGS1NqLuhEIWfQGRaMSFmWfbVqd7oZVG5uSsurDa9/3qeLQ== Received: from DM6PR08CA0060.namprd08.prod.outlook.com (2603:10b6:5:1e0::34) by SJ2PR12MB7867.namprd12.prod.outlook.com (2603:10b6:a03:4cd::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:01 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::44) by DM6PR08CA0060.outlook.office365.com (2603:10b6:5:1e0::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:01 +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 DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.22 via Frontend Transport; Sun, 12 Feb 2023 13:26:00 +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; Sun, 12 Feb 2023 05:25:49 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:25:49 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25:45 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , Jakub Kicinski , Oz Shlomo , "Marcelo Ricardo Leitner" Subject: [PATCH net-next v4 3/9] net/sched: pass flow_stats instead of multiple stats args Date: Sun, 12 Feb 2023 15:25:14 +0200 Message-ID: <20230212132520.12571-4-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT044:EE_|SJ2PR12MB7867:EE_ X-MS-Office365-Filtering-Correlation-Id: ac7aaff8-c5ef-4d58-7d2d-08db0cfcaf04 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iAx/IpR2zhxrj8SvdqKwZePDVmKYup/ddqFacEIZNssxXXBQ1MFIFM6SlGYNvRmdHdU9lnTV0XHIJMdVMeGAZiV4Y/QQI678jKqQfdk7bJJLC2xZfkoowwRgglOSMPC5U7KzzyPv1utaXrMk5VzTeOdSxO0Iv13TMV8u+nNgj/RGv4EsQtFS1wjQ8wki93LG8j/CEdimQ8DOBA/NQis1+PUzdMxsPbPkjz0YMnGDJ/7pDwGG+0/tofGL+8JZmFIXIB6U0GTBfgcaccehztnNMk2vJeYG4a4GCbxpttLom3V3OjJ6Ir0a0gIhRxlYDvbbRebSY2OsxIgpE4vh0oKzfVjnJ2+lD1ltjqHdeiFnEr7j/WpR43ze8ZbeTP+Cava2cNAqfYu8k0nMTLtgA/SlxPtrNo6ep0diJJVbEiiATGhOTpz/rQZ1tQG0Pf9uajszfNPvQ66kSSyOejkTDZXZm62VBohsj/A/zu9aQFbHmWpJEMI27y4FHod3geOW+/U+1ywK3W89XCFlZFDhMTheA+kqJL31em3eu1c0ij+GeqvwkptmGcV+sMsqup0Uwv/tXq8YSD4URJ4w2RIy7kfCPkSoHFHSI0IJWJXI4PDS4Dpzai08AD6HjxlAXWwKKpFjy3iRgziejevIWcl27ND9Qhppxiof7DP282ZpyBuCTUuejVzDkasxEyFcmYvyeHNjnQ/T/YUA8KN8q005McsLYg== 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)(136003)(346002)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(82310400005)(82740400003)(426003)(47076005)(7636003)(86362001)(316002)(40480700001)(54906003)(70586007)(70206006)(41300700001)(36756003)(8676002)(4326008)(6916009)(36860700001)(5660300002)(8936002)(2906002)(83380400001)(40460700003)(356005)(1076003)(6666004)(2616005)(26005)(186003)(336012)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:00.9093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac7aaff8-c5ef-4d58-7d2d-08db0cfcaf04 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7867 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 Reviewed-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim --- 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 cd410a87517b..bf50829d9255 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 Sun Feb 12 13:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137439 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 65613C05027 for ; Sun, 12 Feb 2023 13:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjBLN0C (ORCPT ); Sun, 12 Feb 2023 08:26:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjBLN0B (ORCPT ); Sun, 12 Feb 2023 08:26:01 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2045.outbound.protection.outlook.com [40.107.94.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4622E39A for ; Sun, 12 Feb 2023 05:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MJUZj33sqoxru/v/r75uhcnphMA4CYyGCiYM/SzaMVOlgpga0g+qnDs5IuyrUKpDY2iRhg6FdL1mg1H7Z4floTY+BNzOouQdAlTo3EpPpxUjQdnElp5aZ0iqoqAHfzx4ghOmFIZ45h2VdbzQNhcnlgyu62Clxupuy9DkvzEFuEHnSCQtS3OMWWI2IbpSgiCPhjcWXyKkKIWG4SzsggCYD/9etjcCCsDX9Y6Pe/3FOWIUBRQ044J5ucmb6duQQfoF26e2hNQujKvIiH391fIpYA68MF69Qj/yaKL9HmWLYjkc3sv0XipEpxGwPfwOFXwodbHaxt5dnBGMWaw6J+BxAA== 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=Sx0X+EUXHei5MbZT515BMAdYJPC/PjqWzsxwsSBCF2E=; b=Ex8SKumM5o7oSOkWpcDy7Akm7AZKyH8Jz8+bFgjKUl8AZAwGEp2u//dNjuQ6KJ2G6aZ2dbUsRL04vl7mQ6PtDUWv66xrCuVegPT+e9IlPxhFvOGjdX4HLe3HGK26GMp4NCRFschU83Unetrh3GOJ+W+uuhU6kUHE+hKE/cvWciT0VbutvPlRjKz4UhSw2xMcJajGqC+mm7Q3ZViRPTWFsrU8Wq+G5VInAVquxRd78BxklKrOE7PYVk0EgTcKGLXByh7VDU5IvYew6LL8nvh3gOn28aXD6ycL3RMkOu74lyJ6MZdHiNA2UXyqCHaDscRn6qBiMRkyfNPrh8y/kp8ZxQ== 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=Sx0X+EUXHei5MbZT515BMAdYJPC/PjqWzsxwsSBCF2E=; b=ecfxQyp8qCL8lCPPrrB1XXcgKrLIJEDSAQb72pSnjvFj3okofHZjiGpJomVb4h5d6i4g3Zyjf/i5Kjr1pJY3ruNh2bSzj59KLP8rQflBXPbvRU6uDJgkg5HrAJ2kAzl9iSLgH3gH6LQU5BYEqaeoyGVomejbQbBasUaruZHhUT7FKAbo+qUA2Pf0FWeqwCpmJQKaAeaFPJ8MzRJ1OMLvsW8S213isVL62feMwWmW0ENRsPXT4oPnDbulN0DDYc9ENsQgTD9MW6RDxGWv5XgXs7Pl05i23TNIYpsMM6c1R5EqMjXrFQjRc/SNdwzysaR8MhoAzpi1XDibeXJvstglcg== Received: from DM6PR18CA0009.namprd18.prod.outlook.com (2603:10b6:5:15b::22) by SA3PR12MB8048.namprd12.prod.outlook.com (2603:10b6:806:31e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:25:58 +0000 Received: from DM6NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::4e) by DM6PR18CA0009.outlook.office365.com (2603:10b6:5:15b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:25:57 +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 DM6NAM11FT111.mail.protection.outlook.com (10.13.173.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:25:57 +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; Sun, 12 Feb 2023 05:25:52 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:25:52 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25: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 , Jakub Kicinski , Oz Shlomo , "Marcelo Ricardo Leitner" Subject: [PATCH net-next v4 4/9] net/sched: introduce flow_offload action cookie Date: Sun, 12 Feb 2023 15:25:15 +0200 Message-ID: <20230212132520.12571-5-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT111:EE_|SA3PR12MB8048:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c9dacb6-b257-4a8c-bea7-08db0cfcad09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cmiDVuHnjzYVa6+LUaVSx5eUNXCh7R8WbCWmsC4OamyrmbrTnfTbOVwO+nNS8hrKP0MHjaane3DrErpV2wVruQwWZu+f+NFv9x0faIZX/JB2FVpNCfQcLjm3Yiyl+PsmGNnBeC79i/Lca6tSthM0t52G3Ks52XMmFbDgap+UbsHCUPQTeBifqFfZxW116xpLtCIxBoBwJq7MVE4FSWDmaKxqL4sF/82CqH06onP/rFQ3kvdptF9Sdj2z6u04xE6VVK8n0657SYBQcQxtr3c9Nhb4+F5tz/OblfUEhljWNQERUxvbjyG/tQMF93TpVCzFpsvW9//yMuZqtHbXY24y2uK9RrzgbBjJ/5N2ZzGiPjJa88NZVog3+xvywE1xKtVzW3HdPsJ0to3ZdFqSc4EfOV7jQkSB2EaWgs0K/39tek+YL1r7Im+w68Q9aNwBk4895TPRlvqeNqKvKDdlH4eMb35qWmUM01WzXyCz0BgVEMaaCQSE8B+G01Kuc7a/7qFOPzTPBtcUOxEDyqeCf7899hWjU1oeOzfwjcvS/z4Q1tnp9sBbVmzi6mKwTFTTxlsLEUdbwuovyz+1jaJix9O0j5yy++g6dZ8yjpWARCIrPpY9XjaQa9z3A67Te6HqbR5OPIM0seF1tLTWMQW6/jHe99j7BtXVm1Un7w0XKmsEPoyi1qIGjV0qvpJMJwwrrrbsFVU6/OT3lXqveSEdwIevwQ== 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)(39860400002)(396003)(136003)(376002)(346002)(451199018)(40470700004)(46966006)(36840700001)(41300700001)(70206006)(54906003)(8676002)(6916009)(70586007)(316002)(5660300002)(8936002)(4326008)(2906002)(478600001)(6666004)(40460700003)(1076003)(186003)(26005)(2616005)(47076005)(36756003)(426003)(36860700001)(40480700001)(336012)(83380400001)(82740400003)(7636003)(82310400005)(86362001)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:25:57.6039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c9dacb6-b257-4a8c-bea7-08db0cfcad09 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: DM6NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8048 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 Reviewed-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim --- 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 Sun Feb 12 13:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137442 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 386A5C636D4 for ; Sun, 12 Feb 2023 13:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbjBLN0L (ORCPT ); Sun, 12 Feb 2023 08:26:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjBLN0H (ORCPT ); Sun, 12 Feb 2023 08:26:07 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2048.outbound.protection.outlook.com [40.107.92.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295B5126C1 for ; Sun, 12 Feb 2023 05:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5uMSbsTQiEuqHg1w8bmdNlevWSUxdDNTzeeej64vZ0bYO5r47JACLMd28idEcKYmsaa5gtsalKOq0mA9IWvdrHWn/y7JMgdlnVF2+wDGt/C4wBi+LycFH6CUs35x4ScozYLuwHpIrcGCc3DPg61DDNt6FXWXH4mezPbwIYRIIvh3Wut5pqbubnoRUV2A7dYI2Qb7r1bXNQq8dNTMeRSf3ERnAMFjtSYySWkOT9hMttKkBRmKmb+ftlz1IU2Ed/+E+z4MitoJR9LhOuDOS/YUonNVaMXSPzBhAAKCulaoa0c1sRLsTNpXGDCvKOlMFdlyT7rEvSPcGBptNi0GUymQQ== 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=ePHJOi3U/H08LdoM8e44OgbN5MPTMtT9ATbb8BAaxh8=; b=at+9TqlxMoJcuPyQwf2OyQ0wB1M4noIZAbsokhsnZ3Azcp/DnQLhALosd7HPp0/D1W9XqdaluOAvrkA9VYG1ImLE7ZUMLl9VaMmo4K4LD25wol9voIMSEuU+90cA6MJ2NdXEY9b8FC14dWBgnZ+P3rQk03ldzPi0bSkiz0B3j/dL9f+FWfE50d6SEFDHpu+2gIEL6l6B4PqSM2VFyxllu7BCcqA9nG8vur/6QS3SqxVZuzwTbB6z9qnH/Oi1uZAFaZMb07/JiW8QOqvvYpCzFsjNCJ+L3c65lvrMAUCMRFZq57MRuKjFhCD1UgRBj7NaN++PGtv+Jg33Ys6asi4xlQ== 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=ePHJOi3U/H08LdoM8e44OgbN5MPTMtT9ATbb8BAaxh8=; b=klEOQ65rajY0FJFdNBZDZhdFLpt6rsLn6mB6JdJgH3iu6MJxAuGp7jVKC4qkd0Cdr8zJQpASDrw6Hyp07mb9WBbNZ9mpbh7znpTBIqEKwlB36f275Ta655lBHhMvOBx+x10VbKQL1dVCeeMLyCbLNa40W6eEMfRybcdC+jOK/Y9WgOToTqEA/ehtvaW+LUd/CXXPTOpWN9UE77qlMiBHvHoUQhSxbM6FBEIng5RGEZ+oprjdWYe8iOq84tQz5qe5W+dS45qnXP5sK+Q5uf6pOgyrm6GuM5WEpTtJ+xRoj81ygbkr7JQRgVkJjzWRV0dFi0TQW4baCUBBpnhVRZhWPQ== Received: from DM6PR01CA0006.prod.exchangelabs.com (2603:10b6:5:296::11) by DM6PR12MB4314.namprd12.prod.outlook.com (2603:10b6:5:211::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:04 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::ef) by DM6PR01CA0006.outlook.office365.com (2603:10b6:5:296::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:04 +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 DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:04 +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; Sun, 12 Feb 2023 05:25:56 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:25:55 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25: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 , Jakub Kicinski , Oz Shlomo , "Marcelo Ricardo Leitner" Subject: [PATCH net-next v4 5/9] net/sched: support per action hw stats Date: Sun, 12 Feb 2023 15:25:16 +0200 Message-ID: <20230212132520.12571-6-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT010:EE_|DM6PR12MB4314:EE_ X-MS-Office365-Filtering-Correlation-Id: 339536ae-e68b-43ba-37fb-08db0cfcb0f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UnIWo1jJ4Hwh1hFX4XJPOstSnAeUl43XmN+pPszkkFLfloOo2qyKCe/C/xfz+lrSNBAvEhh4WaFIfgD0nFdpAqvMF/nI/RreF+DJCXnziZSVf336G7BLryPgVHrQyrc3srpSRJNI441UBM0RW18OSym59XtF4PHNzPbXi/qIAcxi2sNz/RCxUR9S2ZkRLW3WIUYuanMjI87JDEOvabKs731+C1Wm6tMZmNhKoR6PUJQggRoi4TFwVL6brnN2x9wlzZn1IayXUvGyEcBXEXb0uP2EvU6Rp2Exqx3bsKcdNXY8IV/PvWjYkUokMHWb7a2/gM43VNnHi+S2MB7KRlyp66K+O3qnyceQeQhB9RuMcsVqHaGYT/BMcyMkgQpxdlh2W8cYOIs5zMCAP/+GuHKjg2u0XopoSUc5IBU6NYV4/wRrYI11Dy+NiLsTG0tYgbqXr8UJpOTeyHnzAsvvhgwICGcdSSo1u+RBTdqC3YVCCVAsH/UqzxclrNxjH6V+pN1Y3mFkZJpyCLl9B08NiwXVkN4nYETMbyMt4383gl6MZ5ULHKGVbpTjcCqv3qv7i1YeUNsouBkACSGfexsURX8PkFH5eG9D/jah97g1at+qMpqZRbc/JZs83yKL6FWehkKrv9HT9i/dGQnAltSkGkJ/hwo5HG+VBC5AoEZCUDT5yQhsw+1Ea+qKEyTgnqA1YSUGEBS/O9y5P8ydak9VXoUXFfhcWn4xbwi6IaVQMj3CmX0= 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)(396003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(83380400001)(5660300002)(41300700001)(8936002)(426003)(47076005)(7636003)(36860700001)(82740400003)(82310400005)(86362001)(36756003)(40480700001)(356005)(40460700003)(2906002)(316002)(54906003)(1076003)(26005)(186003)(4326008)(6916009)(6666004)(336012)(478600001)(2616005)(8676002)(70586007)(70206006)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:04.1450 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 339536ae-e68b-43ba-37fb-08db0cfcb0f2 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4314 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 Reviewed-by: Simon Horman Reviewed-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim --- Change log: V1 -> V2 - Fix static function without inline keyword in header file - Rearrange flow_cls_offload members such that stats and use_act stats will be on the same cache line - Fall-through to flow stats when hw_stats update returns an error (this aligns with current behavior). --- 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..8c05455b1e34 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -594,6 +594,7 @@ struct flow_cls_common_offload { struct flow_cls_offload { struct flow_cls_common_offload common; enum flow_cls_command command; + bool use_act_stats; unsigned long cookie; struct flow_rule *rule; struct flow_stats stats; diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index bf50829d9255..ace437c6754b 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 inline 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)) { + if (!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 Sun Feb 12 13:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137441 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 26E65C05027 for ; Sun, 12 Feb 2023 13:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjBLN0K (ORCPT ); Sun, 12 Feb 2023 08:26:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjBLN0G (ORCPT ); Sun, 12 Feb 2023 08:26:06 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2082.outbound.protection.outlook.com [40.107.96.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C0E1167A for ; Sun, 12 Feb 2023 05:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGYe1GTmm8lujPTGzLy97lB6VatwsNG9n3LHWoyKadkHcQWZUR6mSyThQjiq1/1TKo4TRlN65S+WoB1jHSZMyQOEE6pP2KtVFq90l14pTve8t+d0Bkf6LigeebW3afJ//jS5SpcJ/V4NeK/hWXXllqZ5Q6xi1If1X78imAf8xnlUuZWXBSdzUr+JzI1Ztkd6yRdcL/3rvWcuKRGsNmTolcmxl33sj1cqS4TOadHQXxS97ZywM4vqgIbWyMjSIyjbtNxiT4LjIgZaD5qhj+BnBOyYee9bHs8j7N7G10RNmlIBbuj6eWqLKPFf2asCf/HOnpiAupVRjELgo54aFxvkEg== 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=CojsF1WM49btV+fNacnfmGqaPjQ5mF87InsRxyzeRy4=; b=ZXYzIgv5vO5bxzUnSNDXSNXRKxRNYH/GL0MOJ5vScGph1xoiAJj//OLOipFyfuc5ztISlwhFu8mL95iQacbKxMdaB/cxXZPECCCB1v7xIFZkLQCmwYWlfMxJNBCwQCJqww6z861kwMtj5MHKNwWyQc5CVuAD64kdVrNptOuTs34uHJVHLAjUC2btHJkwSO/asA6GIfJo6ArfI6ZoAO0pE6UJhSrHpIrF9EIoXQRPVrth7hfLp5LJzjrTaEP2nFt8JH+n39+PWM81JPLNKxIUHz925kMVo9nVCtBmLeKldos3lKlm9/DOIanYQiDmIJ+5yAlsexFs8VKqrguSHPDO7A== 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=CojsF1WM49btV+fNacnfmGqaPjQ5mF87InsRxyzeRy4=; b=RjT7bq4FC66qW426K+Tnjds/2Wc7K/7ASFZk47sWmgjs82NzzGJ9Ri0POTTLL5TIRRAB/u227OaeRlfkgZL89YqffHW+cqb+oG07CShF5mRddR0uO7iNuig0Zq7fP70fKO7V9PE0lxrnOpHJgvzOjrAU6cJ1+0w61vRD+6RR6crFKcMQuo40eATNGF8gsUJz2F0jiez3Zrcy+Pr234MnLJfQwAYZglT60TsstvDynkvSJ23ykc6+E60DBVaSqTtjc23cek8hsoBwv0nHCUqLxKmlkPrW/eftqiDzzcMWD1pexLPodNXyPomkrbJ7xoPoU52a4885Pqe1HYaAWMgI2Q== Received: from DS7PR05CA0013.namprd05.prod.outlook.com (2603:10b6:5:3b9::18) by BY5PR12MB4067.namprd12.prod.outlook.com (2603:10b6:a03:212::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:03 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::9d) by DS7PR05CA0013.outlook.office365.com (2603:10b6:5:3b9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.9 via Frontend Transport; Sun, 12 Feb 2023 13:26:02 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:02 +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; Sun, 12 Feb 2023 05:25:59 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:25:59 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25: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 , Jakub Kicinski , Oz Shlomo Subject: [PATCH net-next v4 6/9] net/mlx5e: TC, add hw counter to branching actions Date: Sun, 12 Feb 2023 15:25:17 +0200 Message-ID: <20230212132520.12571-7-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT018:EE_|BY5PR12MB4067:EE_ X-MS-Office365-Filtering-Correlation-Id: bf7a7d94-da9d-4d03-851c-08db0cfcb01c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rW3Yjb1QPE+tj6tYs2hVdk+pfN4vRPa1XQ4rg7nOQbmKbTTVAJiQXld2IQaUmeEY+zioQggHiU5jNDneKkg38YexhxYZa1jo1dq39AN8wPrE/YSBh8HcokukF5Df/Tql5ZgQgwo7V0GDrBo9rtdk+qbs1TTyiSsrZvxZSfeZydiYAkLiUydkeqVgipWpFRhmdIEvR/aZCvOXAKrS/coCE3jCBvv2s96Jx7qZgXHTQ8OIMhJRzO84DozouRsk3RDbM915sZ2Wdy0Fj07EsQQJFHeJem1ahyb36GC4npb4h+/LOy59f4x2lxi7oNcgf0HaRz0yYB0g1MuP5mJSEXLzbInCPA8hH6J2u3DYHuK1uB/VL5CkoRMmPfWvPf7HohFYiRjsunRIcXiZc3DTT+fqLObN2vW582Cf22QwKqedDz/BRNLuVwTxHjPvawRqu1YzruH7prfLgZYMZikROtPnnKMG4N8vmpPtPtcTZYOAqMHqH1URmO3HHyP0uF6B80oTTVDy6dI+ttqHUZSO3aQMT49TCQAVbfApoIrGgodkopo+bjTLcFQae3MM1gFjQ1zQdis2/K4oyLlO4+IU7DlAC3cUG3ZA8fypTwk6XE/4Jnv2HK2zTADhu0HURf7KeKjmbausckww5sXE4ckVs002EfcEJO/Jfb4vD2UA56PnfzM= 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)(396003)(136003)(346002)(39850400004)(451199018)(36840700001)(46966006)(5660300002)(41300700001)(8936002)(426003)(47076005)(7636003)(36860700001)(82740400003)(82310400005)(86362001)(36756003)(40480700001)(356005)(2906002)(316002)(54906003)(1076003)(26005)(186003)(4326008)(6916009)(107886003)(6666004)(336012)(478600001)(2616005)(8676002)(70586007)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:02.7758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf7a7d94-da9d-4d03-851c-08db0cfcb01c 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4067 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 e2ec80ebde58..a3b46feeff8a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3785,6 +3785,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; @@ -4084,6 +4085,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 Sun Feb 12 13:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137443 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 6AF6AC05027 for ; Sun, 12 Feb 2023 13:26:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjBLN0W (ORCPT ); Sun, 12 Feb 2023 08:26:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjBLN0U (ORCPT ); Sun, 12 Feb 2023 08:26:20 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31CA14220 for ; Sun, 12 Feb 2023 05:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SujyHiwilsWL2VwhUNXqKXH7hgEBSa/yHlUGHPAame2MjWSJ7j6bBNs+cQuAfFI1ZmEBuzUm8y8CQnn72sNpFpX4wKNVZ8T+ofs4aNcrBMm86HZPlwknRzfw9H0l2mbNjfNGec8mpHZuYZcqn/mrmAbktSuhwve6UTRGb+Sr6uWv+4Qc9JwuGw06TGiG6wTgMTrp9WVr6X5t5V1+lnN6qwhKuCvNyUPiySh9hnN6zOC+Xu5NtC9lDFuBeeNh6SWG4GC6Mr/RAd/xxNEsakP8JPUZFZ9QaDNySllCqvU1kqqusitOw1jhGY61bRM+PN+FNfs2J6HAT4NPY3f7fiXDJQ== 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=57PLWSpudxHF2rkh/8dLnU6NGoPex/ACVkAQOMuRWY4=; b=U+Xfm0OQwbrrJb3Bmkzaju1RHOJ6/Ao+wJy6/vk13FT83Q/jNZaPW/B1oMAsKCC3VVY2tzclvr2GXUHWgWAaSoUXXPTI1NDkPNXN15DGFNuey+tMU2YKdoQ1cnYn4l8nf+AxLG1nbsB6zLToS8vZSmS5DEHyzzxKrJH4gMBjN7N6Y7Ywq9Cn+OnwZi+FZ0XtmnpDut7eqpnRaNBVBMBCYNfB7XRJen64aWxo3fu+1nJl5XhqIlZaRVjtzAPSkno1oWCsA6fDI7IxJSNsw9mVPxONOW98dQAM9hfid4th1jRYHQHxIxZpoX1LmV78/o6+TOPkjcwtGIYYfuM+LbHQLw== 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=57PLWSpudxHF2rkh/8dLnU6NGoPex/ACVkAQOMuRWY4=; b=fIpN6qgPM0+b1Nb+xdZSV0Fuh2iyai+GDj38+azCQQ66ovC5QvQn1FNSmqOR84bj1TNCTwRipbLnkkcOA5DtFsItOw0wSr2kx8Oo09lTD+8rNtBoizUYKGJog3h9U/nd7rSQsEjpcPXaFXsfgafQ5oxatZfJFLxP2FXmt95G0jxGRM51S5EcCAfV70s6kP7lmy+DvU2R/4TS8tpOygJ66CeUYnh5TBHVeGOUf9ZJ+7OqrZWJEgHPRKSU+ZNMyVCLTkYFrR83QuNMvdbmW4PcjLEcY/So8ZmDCDGsVCzGaRey/9omxOnxWsIYZ9Ic5AKUBhHCnuQX2IvJfLFhMTB82Q== Received: from DM6PR01CA0014.prod.exchangelabs.com (2603:10b6:5:296::19) by CH0PR12MB5217.namprd12.prod.outlook.com (2603:10b6:610:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:11 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::96) by DM6PR01CA0014.outlook.office365.com (2603:10b6:5:296::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:11 +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 DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:11 +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; Sun, 12 Feb 2023 05:26:02 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Sun, 12 Feb 2023 05:26:01 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:25: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 , Jakub Kicinski , Oz Shlomo Subject: [PATCH net-next v4 7/9] net/mlx5e: TC, store tc action cookies per attr Date: Sun, 12 Feb 2023 15:25:18 +0200 Message-ID: <20230212132520.12571-8-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT010:EE_|CH0PR12MB5217:EE_ X-MS-Office365-Filtering-Correlation-Id: a0433685-a878-4176-3c95-08db0cfcb57b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a+0Sc662Co4iRYcHtT7pxy99uKFUP7ZIaf3oxltVv29WVN6d5K98sOWFqbgq1Xp20Hgg4UnLtElhc9lhw8052jfvnaORmtZuHX8gTh/20ryJ4ERfrBFIuO/ufaMZ/GK1w4rYhS0GCIwycvB9OFaA1YF8l/I6FiBaalLsII9ABCanjwF3wFKMgzxLb74+BFWONA/0JbeGB86NTeW1g1twQ7a6hkesDvg9YWVzcqzYDSQMAr3JZxzJPAj6TTKnNUrtafeKDKpJIvdtCEm/tadvaNsT/Lm03b4khfe4PaX302p1p7ri20eaJDqVMu0CyApTYkk+k00dp90xW2x5Mur/guGFs+iUx6mG5u/EI6hzaW8HB1RZD+tBynmXTmbO75vLyfq2Dov8x16P1QS8Nv3WjEOQV8HHA0Qeu5WfYYG3CuhC8WSAeGhn4zxtlXUb/CtWOdzkVDfk0wTHY4NufOo0UYO0a71BYYEZVCqxGs+Fy6AsjcuUuie2gCK/UxduO7NEbVq5XzOW9U8mI7cxVTU693HnTHpI4J5NBzyytiY9+bGuqOcYLe22WRWYxwnLZMy1V7ZRh3cMK/Mzxxhh71Or9fzeyPn+u4o5sw4SeMsGlO0ueeKe7M0eJcpzRc6bAqTWdAT/HFkA/YRj9cQy6rfF4V8OU5jV+2z6jMdvLTwrpU+2Ir3HGaWOd/UzczmH8KlKT49u9AnYcA/BToLGGVI/XA== 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)(396003)(136003)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(5660300002)(41300700001)(8936002)(426003)(47076005)(7636003)(36860700001)(82740400003)(82310400005)(86362001)(36756003)(40480700001)(356005)(40460700003)(2906002)(316002)(54906003)(1076003)(26005)(186003)(4326008)(6916009)(107886003)(6666004)(336012)(478600001)(2616005)(8676002)(70586007)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:11.7539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0433685-a878-4176-3c95-08db0cfcb57b 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5217 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 --- Change log: V1 -> V2: - Reduce tc_act_cookies_count size from int to u16 - Rearange mlx5_flow_attr attributes for better cache alignment --- 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 a3b46feeff8a..08123fb207ed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3786,6 +3786,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; @@ -4149,6 +4150,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..75b34e632916 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h @@ -69,6 +69,7 @@ struct mlx5_nic_flow_attr { struct mlx5_flow_attr { u32 action; + unsigned long tc_act_cookies[TCA_ACT_MAX_PRIO]; struct mlx5_fc *counter; struct mlx5_modify_hdr *modify_hdr; struct mlx5e_mod_hdr_handle *mh; /* attached mod header instance */ @@ -79,6 +80,7 @@ struct mlx5_flow_attr { struct mlx5e_tc_flow_parse_attr *parse_attr; u32 chain; u16 prio; + u16 tc_act_cookies_count; u32 dest_chain; struct mlx5_flow_table *ft; struct mlx5_flow_table *dest_ft; From patchwork Sun Feb 12 13:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137445 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 C19A9C05027 for ; Sun, 12 Feb 2023 13:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbjBLN0l (ORCPT ); Sun, 12 Feb 2023 08:26:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjBLN0k (ORCPT ); Sun, 12 Feb 2023 08:26:40 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2053.outbound.protection.outlook.com [40.107.223.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C782A13D6A for ; Sun, 12 Feb 2023 05:26:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A92bUsu6+Rop7sbIjik/wGiWWERLHIsiuTETKKgXX+vI1GwgS87AqZHsYL1tmZBgBxffvYQ4n5YvDy8JOs78d54H8VQ+u/Kabtj/p4ViamS3xqZ7GgVAqq0SLAIb9JtUhUbIHRdj14rjiPNOB05J68J+xwhCiWHQHSUk3Xa7WQ1sC+lPXfRLvo3hNtgsayJ/Hj2QDynt1/1jalbKMwNIEFMhsjZow9Jh2uFVUbj5TsItAPPlCIJ45lt1sWCn5wI/mY5HlFbgi3OsU8gzJ+K8A2UzvEoV5VefdulNPHmR5iB9X2+qeQZkl9abzP8LYJEcCMz2ReJ7+IY/X+f0YrHj3w== 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=F0poWjT15/+nWSj2PMM037EnUD64VeHEkRJEHoVVRIA=; b=lNd+RA7bQF3dyUYsemZl5NHv8RAkbhyW7SY7x4DVoq5h18M9PGBrA/Y9sNsJPhIOO6q/3pfD2kFWyip7/EgowsH1xC5nagPPbdHxXJfivNLmyhQFcftocz5gxgpegyGTSw62DOtSqqD7s3TlitwPYjwH5xfUkGHwSDeqIQDvHyFEnVQDyaBAv2RLU0YWpEji0eQFu7UZAl8JuCwzexSUbK/9aWuy9k3HHIOt8hXCsCCGRREz/eFnd4+m029HWFsdGBoxjzK3ZI9LrwZ1Tvh6fYCFHJqale+ov/p1isymzJtAD3SWClARR33Jss5KV7C/0noZ16pHaIYBxKuEHfzm0w== 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=F0poWjT15/+nWSj2PMM037EnUD64VeHEkRJEHoVVRIA=; b=UIWH24lYkWuaZ8YQfz/R1Ull5MC6t9qEdprn0Sb9mKkWOpGGJrcMzArOGI8pXCuCMhOcj+XscFQFtS1EFDhOj2ca1hdd14l5r5K8JQ8SUzmJd26FzMpGbafS0sFpZf6wy4uZMBDKBZ99Owt6HXAYaryprytNeY2qxJsXD4gLA7EDlT7fflSivMrH422sh3mmxkFPRZ3qftb2RRVi3blDq4+g0O8Zx3yKqdrnV3Z6OftIspc7V2HKlD01w4ri2ZG/iQhtoFkzfh95i60KUtRJEsokKXNh0DQ6kccVNTPIAOFQCYMoU+A7fRoUKhasvdXy9uNDpTOR+fYG2UpjqFvEnA== Received: from DS7PR03CA0110.namprd03.prod.outlook.com (2603:10b6:5:3b7::25) by IA1PR12MB6529.namprd12.prod.outlook.com (2603:10b6:208:3a6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:16 +0000 Received: from DM6NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::76) by DS7PR03CA0110.outlook.office365.com (2603:10b6:5:3b7::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:15 +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 DM6NAM11FT090.mail.protection.outlook.com (10.13.172.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:15 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Sun, 12 Feb 2023 05:26:06 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 12 Feb 2023 05:26:05 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:26: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 , Jakub Kicinski , Oz Shlomo Subject: [PATCH net-next v4 8/9] net/mlx5e: TC, map tc action cookie to a hw counter Date: Sun, 12 Feb 2023 15:25:19 +0200 Message-ID: <20230212132520.12571-9-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT090:EE_|IA1PR12MB6529:EE_ X-MS-Office365-Filtering-Correlation-Id: e255af46-fc5d-449c-9f8a-08db0cfcb7b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y7c6c8L+U7SPIBpP3XmJl+n5TZejtlu321Kad8qAlrdtQNca0Nq2ARz1h31rKGr5PMO8JFH4oK/VKdgKWcQZ3hPbHjODTwfJpmP+8PDTwErFryhU8YiyPW7WVS8bqHmwBUnW+RywQOFiF1PPP2D7O34nIhT824H+guyDS5mFlFvgPt7xsam+G6FsHw3fvcT57HD3lUcBmHt5DeZQNcxdx1J5ITqKETbeJDAOFgcb+qnYnK0/BqpyTiPomf8/8b74OUEAetISNTbjN8231SirsTGFhv8s29RDzefjVatkvxIPOjts+zG9tE7ThyitpBXIZIGDeYVj3pBPeqRkZbckvRWmQDh/I4OVF1As0fKr+HlTjaTGkOLLPUeI9vkzygDWYmxRBjbmURi9p7beKRqlnJmC2gIsHe9Q6o0g+X9XhvoOxBbZ8wgPYmIHW2DHrFxtUzAGkv/9Oo/K+7YFs6D/ht3iod0C7qNARS9Ie29prlCdPhISbVfRF2CrEAoFEa+TCZGfELppYVj/ZO+y/jZz/j90ci7gBdMVHCIwOrR7kTKryKUepLK6a7WZKDPY8GXYkIUfdU9p3NQAK5GtQNLxd7S9DwalZj1W1LhcOB51pL8qBrGriLsgX62cLKKWMrRBuzUqKL8iHZHO+cgLPY71n3+24gQ2O8KV9wreScBoNBsT6uf2Y67mvoAhMXcOO88hlox2wEkd2fBU0mRx5xh6xA== 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)(396003)(136003)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(30864003)(83380400001)(5660300002)(41300700001)(8936002)(426003)(47076005)(7636003)(36860700001)(82740400003)(82310400005)(86362001)(36756003)(40480700001)(356005)(40460700003)(2906002)(316002)(54906003)(1076003)(26005)(186003)(4326008)(6916009)(107886003)(6666004)(336012)(478600001)(2616005)(8676002)(70586007)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:15.4985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e255af46-fc5d-449c-9f8a-08db0cfcb7b6 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: DM6NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6529 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 --- Change log: V2 -> V3: - Change commit message title --- 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 08123fb207ed..f1dd25701406 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) { @@ -2026,6 +2048,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 @@ -2120,6 +2146,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); @@ -5331,8 +5359,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); @@ -5382,6 +5418,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) @@ -5458,8 +5495,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: @@ -5486,6 +5529,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 Sun Feb 12 13:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13137444 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 AF28CC636D3 for ; Sun, 12 Feb 2023 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbjBLN01 (ORCPT ); Sun, 12 Feb 2023 08:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjBLN0Z (ORCPT ); Sun, 12 Feb 2023 08:26:25 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64DEF13DFD for ; Sun, 12 Feb 2023 05:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k7EH6MMUopIbeUdoL7SmLu8646oCmn0c1pqpgThSL99I5SWt7gqucb2LCSSVmknaKSD/gIhaI2uPLs030DIvsPYDuElETgAAcSLZ7cD2R0ohACRCpbVAAtUhRW1i4by7sb6RzLY+WETj9gqQAySgmqSK3kpzbcujol5smLxfsWhkNeReLH3QN7dd8exI+GQJQf0UntuigWyyPjsryljwhPAuNmwhNkQxX86x9DzH35dRCEkka4z303mEfF+L3foVMLqg/INOAsB271YYnamPkQl0F8Fy2uWobhtBXihamuHhFOM9RHYnuW8IJjEFuEWtV8hz43yy2cFyknNbFtSM6g== 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=q5GxK3vQJJfDeETUfDiU/FxGsRXOffls6HjKtn9pQ48=; b=IhfRV+cz+fuVRfEBQcJDZ8k3gi/jzqUYWn4gY3NSCQ132t0whTtj8vsrQMI4jrweMemIG93IKYN5e/w/J/+P/XAn8ztd2ZlHFDFHr8Ck8Oe3nJwgqrjrwx8BqFVJG40n7TJBlZl8QSY5z3bXgOTEdriB+g+BVAxpIOWRbifoZHZkOZBWmasdd1BHBDU9YgtW++8XzWrkOfGgBf//40GyNkQPD3k8OO2qleDOe1qMrjT4qv5hkZ26cs9mBnhSMTKQDiveinSLQ1X4fQuuzP7ttmHCIDYjZ59zn7GxSqaZAYvM3pQj3zTc9I5ZVRuoz+F30hSlWyCjzy0vLuOg0+lhNQ== 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=q5GxK3vQJJfDeETUfDiU/FxGsRXOffls6HjKtn9pQ48=; b=RPsJT26LWA33C4DWCDtoOFDfALbvTEqnKS00qgLWFH4UoBQcl5EIMV/HyolPlwgrAXOYvJUURjiKPvaGnRNegpbvM6nMtgkHx8GQDZe/lzN5rtKrV5WSwJSipuz3t9ZJ65Mb6XV+laud36MfyDY41X0D0pMxxboS9X2eO6UQhR3jAByVnU1EKO0tLZldSlaLxLWmSIl9bwHCsQJGq7gZkYhVd8r0s2tEsFRnKW2+nU9ddcoVU2quQAvnCzh0Yyn1noYRgu9rP1DnX8Uq0rgjDI6w31DU5CIUGcj0FElfv8vF3J9Q+mCFe28xunzMa7QbKQWErlfLFR1vBFhJThCr0Q== Received: from DS7PR03CA0333.namprd03.prod.outlook.com (2603:10b6:8:55::15) by CH2PR12MB4184.namprd12.prod.outlook.com (2603:10b6:610:a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23; Sun, 12 Feb 2023 13:26:14 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:8:55:cafe::25) by DS7PR03CA0333.outlook.office365.com (2603:10b6:8:55::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.23 via Frontend Transport; Sun, 12 Feb 2023 13:26:14 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Sun, 12 Feb 2023 05:26:09 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 12 Feb 2023 05:26:08 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 12 Feb 2023 05:26: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 , Jakub Kicinski , Oz Shlomo Subject: [PATCH net-next v4 9/9] net/mlx5e: TC, support per action stats Date: Sun, 12 Feb 2023 15:25:20 +0200 Message-ID: <20230212132520.12571-10-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230212132520.12571-1-ozsh@nvidia.com> References: <20230212132520.12571-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT066:EE_|CH2PR12MB4184:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d2fb9d0-01b5-4023-2b1d-08db0cfcb6d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r7Dkvelj7vhjraL9H7Kc1VEOqRVO+S88JGGYO2BuAV2gPkAZmD0TpSpXM2LKbyH4dYqqTxi4TMyq/nPY3DYkhfyVtSN39rBfuoIUuvyvgDVzZP8cKCqkiJCoyNowNb6GXHiZu27kQB+HnKdU4Y8q8+txlRT19Blj/1s0NY4HDML0kvvxkiwrIgFbtug9riMtxtwSpm+B2wpDNUDxVrHgnExRoJeHeA9cVneLP80po1vpVq9RyhIV3nkkHKjTuMu8eHJwmPW0RGlBMTnJ98xBm4A7sNK3W72UEfPAdxcKeuOO0FCm6UCZwfshsNxBNhdwHW6MoQvh87OWvf3ZGMJfC8ibKbc2Uj9bqCUmMqqQZrGd6abkUl6kMXRDfAaUdneHSheOZ+PVtd42qZS6zJFAJs9tkFqtZeQuQyFGLz7xvdxJVxfpxLqQIxRjsjsvYqtIpS/HmgExZCU9WzL/tfSrht6p5aCjUDoOGGGJvMjJS11eKlFUNkyrW2kJ1l1SBmJe+53HD7AwRLszj5Nt8FHmawo4WQEw3ytTfCJBzMyu256Gt1HM/Y+AQBsKV1xnZfakSzX5Cd490ioQTIdB1eRmoqLFgj7IrLG2s3kCuJGtg4jc81yl3Z83t8QllsgUa2UpWx0gMtSJjSwjeN3gFPJq2PQUqpaYR72vH1i0nkMLgjcykFKhzm7XA37nPII2PXND9zL1JIV5h43Uv51unhNjHw== 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)(39860400002)(396003)(136003)(451199018)(36840700001)(40470700004)(46966006)(478600001)(40480700001)(36860700001)(336012)(36756003)(426003)(47076005)(83380400001)(356005)(82310400005)(86362001)(82740400003)(7636003)(6666004)(107886003)(26005)(186003)(2616005)(40460700003)(1076003)(70586007)(6916009)(70206006)(4326008)(8936002)(54906003)(316002)(5660300002)(8676002)(2906002)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2023 13:26:14.0144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d2fb9d0-01b5-4023-2b1d-08db0cfcb6d4 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: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4184 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 --- Change log: V2 -> V3: - Change commit message title --- .../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 f1dd25701406..2d06b4412762 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -4117,6 +4117,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; @@ -4967,6 +4968,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) { @@ -4993,11 +5000,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 @@ -5013,14 +5024,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 75b34e632916..e8e39fdcda73 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);