From patchwork Mon Feb 6 13:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129919 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 EF213C05027 for ; Mon, 6 Feb 2023 14:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjBFOBH (ORCPT ); Mon, 6 Feb 2023 09:01:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbjBFOAt (ORCPT ); Mon, 6 Feb 2023 09:00:49 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD2625953 for ; Mon, 6 Feb 2023 06:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dr75wSLoh18nxvzArAagU1U4dISC3cGetHS1CP5Ij9u9HhC1S3D0KD80YKg2S3D8SO8/mmlBytrR+ogtJtdK3cWLwTGnkdfgVNw+qG9oZJzpozkFCmPwVIkyLftidIcrPdmIrV/I/BmFFbQFMMORcagG1Ul1CztQz4f4uI2fyx453hGpuxE3dfKlC5LVFvrRdRG+wUD9fySvrs2L3CtNln94O9YD51Hamf+5RT4GzEjxkhLkMQNbNJSdgS4fOJa+CmR0cq2ivKZ/rvDLnoafR1segRrt6kA6VNsYl9LH+y7oZLe7cYBjvdwMQVKysoqgX8HrPJHhOrgYgQYyYUv14Q== 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=uYidjSZnwvZk6/CSjod/j+4hD5+c2KmBSY3wGeTDLr8=; b=XE0yv4VSkvbpPfmLEknLBz7JZgDVjEdvx772qw4PWo4rROdMNALimZxf22IcQyyShgJcH2QGx5InpyF/o6OGYlAmvDawmVi7vQDlOSjv8UEm3LJmtVr0USP4oDWa2+7ET+s55wVLGR8GoFMvBVnvJMfPlmmvsd2FWeXNkDYgBTm6dzci4aPi6t/bgPpu0e/QQirbeF4mfIOCzv+hRprzM7VKeo+xfxZnELXLid4jHIVdpeMWRUBRyRhdGz0kJz+eFQt1+M0d3E/sdUmEA/OAhK8P/r/2l30VkjyunrvlSGKo3YpFS/gyQtvbINjLOHXnYbuOP7RQCHnMxgptne93QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=uYidjSZnwvZk6/CSjod/j+4hD5+c2KmBSY3wGeTDLr8=; b=BGbGjkU9lZY5GgIEoizR0Ys6pKgIJBZJrs8lmm1c1bRnh+V9AaWgATn3La8OaPKEbe8tiKDwERYpr5tBeW1nniPkLwTN2pMBS5EBreTpGoEkbNgds2TVUYyVSEaWmrDCN0ZcCmdgWmIuK6k3u+NC095/1fpPuf0DxlIx73JhPe51GcGvbR3wuoY1K9vZ1RdCXL12LFbJmWm7GuTRbAf5WoxkHJrMJ7zaf5rv2Iwjw8CV69D88w8vPPV8NL4wNZPuJFOLazoYOGHquv6aimT3RepLZrbWVhK2wRsT20Tg3vgADQ5dpLVk0Jh2ylFIl06s3F9topFFAufpSdjs9gEsOQ== Received: from BN9PR03CA0445.namprd03.prod.outlook.com (2603:10b6:408:113::30) by SA1PR12MB6774.namprd12.prod.outlook.com (2603:10b6:806:259::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:16 +0000 Received: from BN8NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:408:113:cafe::fa) by BN9PR03CA0445.outlook.office365.com (2603:10b6:408:113::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT027.mail.protection.outlook.com (10.13.177.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:16 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:08 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:07 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:05 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 1/9] net/sched: optimize action stats api calls Date: Mon, 6 Feb 2023 15:54:34 +0200 Message-ID: <20230206135442.15671-2-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT027:EE_|SA1PR12MB6774:EE_ X-MS-Office365-Filtering-Correlation-Id: 93850763-d98f-4f58-42d4-08db084a79c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fXVtNeQUFO59rW+g+Cv92zPHSO7jlnjMuu4TIjW3Wh5w4NqhrlJ8aww9Z8Sv/It/ors/NVhvB7HPfdJNFli2neDZKMyG3gnbyqU7LMfU730GXozEKotnC+8Mn21B4u+tJGASlGRnoldPHwi+/xnyfVO6B0bunlyeu0MjE0JYq/i/rt0CqihP7wjB+KySMz3D3PMerdlIjHeVP7ziD2X6w1dKMND8/EIubd6uvsM2Vn+Ycl2dQzb8kiWIh9LHEYutmTm/k6AdsYa3YQ+hH8pX8QCyVF4gulq6P+X/ZvmSHShELogZFIRnU2DKxqzD6qx0nrEJSYp6so9QI2H4OttNcn1Da1rlnKcDWxl49fzlKGTpDJ1omzDIjCv9TI7xqluogBKSeJWTBY8BR3qE4Q3VAict3kcQZTEPH2ku34svcP117MHgnmFvYqKpZXPyvIDjx63NUtFbDMBc3at5U0IPZSWY3y3GdY2leRLkFb32rOgizuvOGrlZLGM6islu/R8jwiIDAn9Cn0LeU2pYKwmiIlUCioMzTQAKywOGFeYvhPXcBShSzV06NgATpliW3Y+UqPUG/nM6K5Kc/tLPk6dK/nVbLCVcOLUquqVqACzNSd0Z867cXYHVKiWMZ6RPEyEsLh+gL88CpedDk6dt6EidrzTZeqEdDWVLyq3Sf5DDkhkBCg/YbXJlS38DdpMvPTSE21g1IDrmSvGzSvvS1b42QQ== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(396003)(39860400002)(136003)(376002)(451199018)(40470700004)(36840700001)(46966006)(70206006)(54906003)(82310400005)(70586007)(6916009)(8676002)(4326008)(41300700001)(316002)(8936002)(5660300002)(356005)(7636003)(86362001)(36860700001)(36756003)(82740400003)(1076003)(26005)(107886003)(6666004)(186003)(426003)(47076005)(40460700003)(40480700001)(2906002)(478600001)(83380400001)(2616005)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:16.4755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93850763-d98f-4f58-42d4-08db084a79c5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6774 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 --- 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 Mon Feb 6 13:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129918 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 1315BC61DA4 for ; Mon, 6 Feb 2023 14:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjBFOBD (ORCPT ); Mon, 6 Feb 2023 09:01:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231232AbjBFOAe (ORCPT ); Mon, 6 Feb 2023 09:00:34 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 020F625977 for ; Mon, 6 Feb 2023 06:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dXg4UnngiNWJpX/Z5RgWJTFLWXxM+JDG7Dn3N6EYh4KftWB8wS1UTKTfV4POXOLNeoo9f0zY322gbEj6wrKKpcNeET+opSvcSw3Y1xHcr7/5EehbAUEuFLMKiIReDM16YmZPalSoWXoXlUAJfAuhuTDOt4ixdNwblybIh4cov56n2fV4EQ6xkAV/91LxuJb/WtxJyr62Mxmg+MoPTX2N5PLQ5r5fgpWtB4CWrj0n8d/zTMkaioifsB5d1WMblN7/Kdh+ME/ltmtB1/9CUrKQDEE1h8WlzyT31ERNQW822ntL9Yf54nhwsKX7BDftezGa8gsfas0RRUVO/2yE6Y2DdA== 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=e/0TXdOq2Aq9wVekOrNIz1RxpxU9N5Q8aJNDtqw2Ohk=; b=g/LlL2AwhbqGqPaYANotQFlASjREFe0LdsXZ2QMcAu/nybzgE2HyWnPnVLYgkWElO8smkMrSJaw1c729TYvyP0f1Kik7pPxZ4/nhn4m7MMZo3FDaxOSXL9aPrgExkiitlFinw3lAmExktsQvg4yq31E+UtMTyem2eHgD1XnKvDtKUeZPW8lsiGpNapitl58r0JxHl/+/udrCarMkbsxur0XhjdH3UppG/EJ5LwCYpVQSW1pCw4lH/YtYa0NCw527WQhLi80RL0nEAOIBu0T6AHUKScRVFYMK+aznWP78FNnwZk2UptzdVaJjDaX588ksUQsx6gMS2HtdB2INyMWnsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=e/0TXdOq2Aq9wVekOrNIz1RxpxU9N5Q8aJNDtqw2Ohk=; b=OzlwKBY5P2bxXT2EO3+EHx5PWUDRQ+K+h6cJ2Sl5qCz94Y84WR3emLCGDiKRztAJ077puMrH9cNTerXA3beZwcAyRIEDbY2anqy5+sH+mM+DSMiZvzujPsqJHMTbwsEgwRGFW1K/I0kHVUx2suTLTNk9+9aBsNiwiFOJ/iItWzZAyP2X6bWfMSZdMHj03qYhqNjbGRBTX4H9GEQmDYXxRfB2oDcLFhmaHN/K7vWJfy3rre4QzgZUvnjf4GsY4Ia/4P3CV61cLBO74H5I60zEL8xTg2zq4dB0Roiji3YxblfuYnQhPwjXuoPUYCJQFjMPDDZarBgF+7SsV3uzH71PDg== Received: from BN9PR03CA0758.namprd03.prod.outlook.com (2603:10b6:408:13a::13) by IA0PR12MB7752.namprd12.prod.outlook.com (2603:10b6:208:431::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:21 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::90) by BN9PR03CA0758.outlook.office365.com (2603:10b6:408:13a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 14:00:21 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:11 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:10 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:08 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 2/9] net/sched: act_pedit, setup offload action for action stats query Date: Mon, 6 Feb 2023 15:54:35 +0200 Message-ID: <20230206135442.15671-3-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT033:EE_|IA0PR12MB7752:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ae79492-7792-4ed4-00bf-08db084a7ce4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wQlb/XIqVK6L6YAJyrL6kbJ8RVu3ohh3sGGXT2xKy+8ft/JSAP7Do2unnLWX8eH2kmM8efWJ3Yva7uIGmWhU5L1yu8LqgxNE/UdCUw+ogBCEYH2Z6E6aVopTgzfjYyh6jdiDBdfTu+jMV+dsP/MQ6+slewKs9wfzWGkoTRlH5lOZTZsBpfMXn4ruyebntSc1IhrIFKGAU4bzNFu9fG3xmFhm1dmlkk0XXSdUyRdhjh/1S/N//gP22sNxsTlGhbAdD/plafE+nK8J7qF2yFlI6Kjs8fzI8jkS/Oa4/oSMifAxmky0fmHvo7UhjEGGLOaMY/krHOOpOJRQy2HM1ZIxzKqNFPOj5yyEYSV0zROaUlA4kM7jiD4IKqSMv9PBtBAjlDq5b6bZ3ROg69HjrVbnuQMRVSUvKYPAFlYRg4tjywEarbVHSHlB1ZDEw1Z8jEpu8wn9lazw4pBLjgGW+HfDqR5lmU29w6D+eN8yFxJ2o6rNvP6njTciChohTDQLUpbgmi361+g2/5CdVSjMfTNWNdK+HUwQq5Pp5k46bDwgjtUW+dov9y5Xlc8uXabuvJZx5LQwTEHzsJkOgj3/5dfGm8UhR9cxky1geqovA4LKt9a/cKCXPqOLp9nFndCphPu/uDCwqv583eFNEk/qOiGQOAL9+jZ9CY99efijS4ci2gjDKRuQuBzjb1u2U+lOz+i9jpJjEv95/IXiZBEaxdgC1w== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199018)(36840700001)(40470700004)(46966006)(82310400005)(40460700003)(6916009)(1076003)(40480700001)(107886003)(6666004)(478600001)(2616005)(8676002)(186003)(26005)(4326008)(70586007)(70206006)(316002)(54906003)(36756003)(82740400003)(7636003)(356005)(86362001)(426003)(47076005)(83380400001)(36860700001)(336012)(5660300002)(41300700001)(8936002)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:21.6945 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae79492-7792-4ed4-00bf-08db084a7ce4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7752 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 --- 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 --- net/sched/act_pedit.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c42fcc47dd6d..924beb76f5b7 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -545,7 +545,32 @@ 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); + u32 last_cmd; + 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++) { + last_cmd = cmd; + cmd = tcf_pedit_cmd(act, k); + + if (cmd != last_cmd) { + NL_SET_ERR_MSG_MOD(extack, "Unsupported pedit command offload"); + return -EOPNOTSUPP; + } + } } return 0; From patchwork Mon Feb 6 13:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129920 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 DD648C61DA4 for ; Mon, 6 Feb 2023 14:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231287AbjBFOBS (ORCPT ); Mon, 6 Feb 2023 09:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBFOAy (ORCPT ); Mon, 6 Feb 2023 09:00:54 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915E11EFCD for ; Mon, 6 Feb 2023 06:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OFKwEasGJicf3PTvMJOFUGJZB5e3xd1M8wsWAZ5DcKXELRyJs9pdHFSIEXP5eMhFqnbfs4KWMymG2XuXdv7NFgmKz7SRbfrqpnqao8CfnJvHBaEMPO3nVP/1TD4ZlGyXqeSmRGcVYQTIvHiiXSLKDF2gj7M1/thUngf8qZv19gOvQbE1HObaWM1Dxb51qlcS+gqu8yU/U4NRjXFmVl2H2Ekn+ZAQPprqCWI8J0cDMEjefAqKE6yjaQbmCoeIItwBeqVeXrVQYIKTu1+RuKNNDmr2iWiub68m4982tyhMIzxHDH+lXQPPK0UolSiYDrIT1wd/Tfdmt8WA39y8p5wfLQ== 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=EEhkDS06X5QHgDdvQADms1spQZ2RgBw0yubZ/8t+ebM=; b=njRsmTyseg6goOVVSq6306EIn0zBZvzGIxZohcX0puExyVClp+6EtVy1MSetl9EXztaW0Q3/32b4bLojQ49KToZKUkPeY0pJ5am5QtM/JqV0BcCt7gd8qQPGmpC6FaxmoHvHblb8vNNgD00iXTWIZ3c9yXs81zRe78FcyEBc4HN7E30sc+Zz1srvAo5NuyprOkGzyc5D6R1mdOIDD8A0SiRYdytdRIw9Q/axLPIwt+8TuzYGTwwDX3kwCRJKlLf2meDJO/r2nmgvPh8157GaNZMGGMEY4O0L9xtnymgHK/WOW/GR26FrFmjitvT3xDqSEw6NI1Z7uELp0ignzkfNng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=EEhkDS06X5QHgDdvQADms1spQZ2RgBw0yubZ/8t+ebM=; b=rhH/xQnKGrBkgj4tfx+7A78JeIi4UFf65Pdi9C4LKydOmgJmPyOLBUTT5BaG7bl8dasg5AaNND8OS71v9AqZ5sw0D1kJ5vi6CsVOT0E0YrTEjLLYbggzlSScuafoeiBhHH5nWNhAfPsi310JpCT/YLySseFPtN2bxkshThqPAMoFS+BStx6pJXf+s+9r/AIfK4SeTiEHsNPH7oQJJQpg5iZ79oM4mSKGX0E0l/ZFpJ9MJ+Oc+sANHrGUvm3rb+mskn8cRy6eDrI0camSvFLF3u+cYKHSMsNcOw1cL0/ooC72LAIWAePkmLU5sPbqAnTrhi5r0cGF/ethA9HPGUnHdQ== Received: from DM6PR11CA0043.namprd11.prod.outlook.com (2603:10b6:5:14c::20) by PH7PR12MB6441.namprd12.prod.outlook.com (2603:10b6:510:1fb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:28 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::ab) by DM6PR11CA0043.outlook.office365.com (2603:10b6:5:14c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 14:00:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:27 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:14 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:13 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:11 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 3/9] net/sched: pass flow_stats instead of multiple stats args Date: Mon, 6 Feb 2023 15:54:36 +0200 Message-ID: <20230206135442.15671-4-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT059:EE_|PH7PR12MB6441:EE_ X-MS-Office365-Filtering-Correlation-Id: 6627ae75-7f61-444b-bf64-08db084a8064 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LQAxuzGPVdAYMeqxLLJlvEdq+Excw3se8PahOlFwVy/ApcNMmFoXMoQnEVa724zrGX4a+m6yEt1sJqPB45AqjGTUo8SHEG8ePcbyOG0Q1TeUG//H9ipHmEVzKjnKHgZCbJlP4fuABj1gIc3FzOgqA8YxkxOU+XwHNt9b73W3S0PbHg2v3+H7dg/fLvH+Z6RT/DZ8hSVgT4mPHIyh0S48uLWrCptpwEtzDpFPr2vOSJdD6eAXqgeQxulLSdJIT+rpOnD1dv5/V672+56zTNQsFL7Zgy5x3BjAMDPn9Ewi6SHnfGPFC18M9JToC4Ne5i/NCHeVbw/xK0vX9Pkqd7gBnKkTIxqOMUhtlhL/WoCdHGT7u4FRqaTLjrEo+/2koJrYL2UDx37zlbhPnhVTXkd4kHeMKvsh33tkQ/r15yhviDKYLiQ6B9xYcFwi2hiqZgd8+1GV+BjLCee77Cp9qJU5WxCdKqzSmmz81FBZHrAAlcaVQ2M1ncaUIAXe/vyHELRAJ25TUri8FZ8eeLaQJd7yWYkJisrvEWYr8pJsexPwB4qqDP5phQOHMMBuwxeg52xuPUF9sWlCqKZXBg9ZeRVxwrSApbKyIjcOUlh4gDWYGmZpMH23EcaHExm11UPCtvRoBCAx4LG8k5G6wbfXeKQKPcImIekvEIDQuOifshAkU3kU9Zu905Rruapgizn4cA/bCDB6fi/mRT+a7M7WAF89OQ== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199018)(40470700004)(36840700001)(46966006)(5660300002)(6916009)(41300700001)(4326008)(8676002)(2906002)(70586007)(70206006)(316002)(54906003)(36860700001)(36756003)(426003)(478600001)(47076005)(6666004)(82310400005)(107886003)(2616005)(336012)(1076003)(8936002)(26005)(186003)(86362001)(40480700001)(356005)(40460700003)(82740400003)(83380400001)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:27.6339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6627ae75-7f61-444b-bf64-08db084a8064 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6441 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 --- 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 Mon Feb 6 13:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129921 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 DEE93C05027 for ; Mon, 6 Feb 2023 14:01:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbjBFOB2 (ORCPT ); Mon, 6 Feb 2023 09:01:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbjBFOA7 (ORCPT ); Mon, 6 Feb 2023 09:00:59 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D26B27986 for ; Mon, 6 Feb 2023 06:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NuqyXHiO73fYHYL2dQfZz3if6o2jbO6zN3o1LMFwRkvzz4K4FJTZGvCJnYZw/H5dLfyF8NmdtJm83h+gTlYZN5y9RQTdzg/czBUQRS3OMZ4E5afwKxRz2JUUXqDsgpGGquei8IGuRcoAJyhlSei7qA1+kw/Xp+iwTY/ckUHpSG4DSgTtf7WQFk17YeivJC41jtt902p3U/zCNXWJm9cfjxre2X6QODZp8oMbiBmppFdmnrparDxcDaXOQ4kodOpY719dBQ/gE8bEXj0PjCBFIAIslW44EZP47XfKJNdbT7K5J6Ui5ftGJiBe5sAhrDvp28o5pFwWxNAYI3t2HeRUhA== 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=x+7YDjkoSoU+0wJnvoF8VMfGYxl7O4Sl4bRE4vm0nK8=; b=neKAVNN4iJuj/+4/stdpE7ztph5qGuUSSmOTcalKnPCIZCy7vBMXF8TPU83Gmx64pyOEnewGn8MUd/JamU0Z/0a9aW43s7SHxK9Nc3pbjDzV13iGgKutHhGZR2ARVsnfMfakQ3Cu/4G79vU+Y/PodeXmU4mxWRaBGzTB+Z+4jJbyX9cgIAMACTjGmneHmAUj0T/cEzDQW3GXTHFmEcwxZ5vP8XSekUDm9AYqsVANXQ3miQp1o9pj8f8itJ63U45Ale+vQcRgyhAFS6Q+WPKE35BzKMslCu3T43bCDs1/kPqvWCXfS+tmAB/k6svYoBr1T7x+uR8VvnahKtPfdRwlwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=x+7YDjkoSoU+0wJnvoF8VMfGYxl7O4Sl4bRE4vm0nK8=; b=P5sxwPgVqrfKdlb70FLYcMJP0lzvDdBdIcGMHVj56dJZNCTLAmPyFZbmJMmZMOjzgXY8jYe0WpKt2wJq3J1w7eLiL4QgMC14Z6/KydWnqvubGWrd7n2OvmTx44+cSBBUaQsokY1JZ0Nb/pkk5Eo4NIeBeTKXAi+UDLlyn/7rX2j85Wmuq4jWwLCemCGXiw/ZgfRRO/j00oGcYfjDTQudwiZpUOdDqz7z69mxHn7tO4L4ohYOeHB3FH+dDNkwQB3DLnW0n8IbZMXb4qth9E7CkfKHrZaZS77SdlZ7I3ZcV658nnf5cv0H84t3kebaZY5ydqytSnrxIJY6tDwW1gAZtg== Received: from BN9P220CA0025.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::30) by PH7PR12MB6696.namprd12.prod.outlook.com (2603:10b6:510:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Mon, 6 Feb 2023 14:00:32 +0000 Received: from BN8NAM11FT094.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::2c) by BN9P220CA0025.outlook.office365.com (2603:10b6:408:13e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT094.mail.protection.outlook.com (10.13.176.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 14:00:31 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:17 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:16 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:14 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 4/9] net/sched: introduce flow_offload action cookie Date: Mon, 6 Feb 2023 15:54:37 +0200 Message-ID: <20230206135442.15671-5-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT094:EE_|PH7PR12MB6696:EE_ X-MS-Office365-Filtering-Correlation-Id: a86a9688-3b49-4a64-5d13-08db084a8300 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nB97b3Zg8zOlkg4k8z4Rcr13hTMywDbd0dasKHjiwJp2FGvQOVgH4SliNfs4Wtm65FFRYQyHjf/kGGFcRTIsTGvb67HY6z/RSILWe+reW3ZL55gzYy1jBfQE8OOuXAegy/uWpu05scq9jhJ5iIMZlW+W8DFbBp2yD3L/tE5H3lB+MBi3R3h66XN4wKZ9+lkXkg9H0H3H6EXV4NYk+t4kjCKS6XWBrDplfKCRZ9uwj4aGnTNRQFuTw4wKMxqdViHmBPMwOSAm+MkjW0BcH3T3vP/YvadytkW7HuftgdlkjgDUAoA2PEnXxUcXsyQDGH6brYthc6RG2U0PY6Cs2tzQxFr0PtmZwnVHBpTFiPfV3oNKWQJYM6igsF3iyWZxnDnMPHlIAWmoHjWSq9YG5gHe+ucMTNqBAWZoTtvKUHdPE9QHprqoOyHFQDbmExi209aIc3PxNhk2qhF4vw18h0Qs/wqW8z/DRQed1rGFXUvvueDxoAeDiwx59lGqmNWKVpEi3bRWyhw1GFE1WNWdasR09K+ud2KhGTPqizDwQ9Til4LQNLvsBVyzywNSX+QR6DyU3UnvAHOTZMkQ8CT3CxuGKAUkqJZl7xDbq5XHZrS4+6uMpeVOGW9NDZL94eDaf3EeafJiCDdDN4BW+0858hrFq13ZR3mHMLk7hYDst5VvPGK+TqUFCh8wNSTvhyZYD2nqb7MGuheVZc7/cLwlJU2+oA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199018)(46966006)(36840700001)(40470700004)(107886003)(316002)(6666004)(54906003)(478600001)(8936002)(4326008)(6916009)(41300700001)(70206006)(70586007)(8676002)(2906002)(5660300002)(40460700003)(82310400005)(426003)(40480700001)(26005)(82740400003)(36860700001)(7636003)(83380400001)(2616005)(336012)(186003)(47076005)(356005)(1076003)(86362001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:31.9467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a86a9688-3b49-4a64-5d13-08db084a8300 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT094.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6696 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 --- 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 Mon Feb 6 13:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129922 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 53EB7C05027 for ; Mon, 6 Feb 2023 14:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229526AbjBFOBk (ORCPT ); Mon, 6 Feb 2023 09:01:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjBFOBD (ORCPT ); Mon, 6 Feb 2023 09:01:03 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C712279AF for ; Mon, 6 Feb 2023 06:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VrFdFyTSrp61ISbbNKdoJJhprcLfBmU1jSIhDHfoFNTmk5T6CMZmvvyUB/Z1y4RLWYhSEX7OEjrzZbVxkRRghAIjrOEWgxw5DEyIUyhj5AVVfJBKKXg9gdrDJABkkkmUrZOX2bujRWThaMRApu/2LvGD3FdroPK759PJwbMyBbJd4O8tE8Xr7eKO0XtwpVP2rTxG6xN8WPVSjOa1GObyRDTv/K2h7GasIxtkyMvEoF8mc3tOGZCAE621gpojFqsDsmUzX6/svy+7sThmWk2YtsymBaSSoRkG6cP5hYxK325kESFsMuWppj1CxCs9bn3rNgBalzJJklDKU458hHxoSA== 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=+8gk9+i5chFDjQultlfx9RPgT8sSmRN3Vmu2kVHrVxY=; b=WOMmkIUxGYAuPoz/mBKqW5J8cNGv3atr440K9e1NQtR84wgrutDGNDsqoVUKXBD8Dfo5eGIXH4i9HedBpvuSGzdwfzRuez0LcXnuKU35VowzZwJCB/IGWqd1keJ4tKrYca2aQaDd21y/Gx7RGGkaqZNMVZvc7mBgHB8Zgi+S081sfrk+8mlc9vnh0RLWIvWzlc9gzv//82/JYgSmEYYctwo02RHNlIzfX49mfiskf1y7L4/u7+F7bAq3NqEqU0MReV0HxT9UuDnV4ZFPlib0SplMjzCfljj6Z5K5GBB1cL9HSDq966eKAPfHI43inCkZ2IWet1tbHotdML/O/ANOFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=+8gk9+i5chFDjQultlfx9RPgT8sSmRN3Vmu2kVHrVxY=; b=gLy1eDj/yD8TTALnuvvhmGY9MEN/BGk35JmLV23+dRVQy7U8R85KDUA2D68IcNBVK1+BK/q0VcAunCOllkS1M7EXwOwxS0SCK96GHU58zgULIb8trRZl3xGbz9sFMEM6oGwDPRYyWA11Kj/mN0jD4GPQuNeEjWI0LVayx1s7r4vCbbCb2iuL/BPYpZs1F27nvvQ9RsGBsN+zp+UTwtEhE1G1EeWV9Xsi4Vrb+U8cOBPxrLhib906s4TB++oej+JYhMpfkZz2td+MllkJPyrjpoFwbr5DV6QHg/70CCxD1m4E3G7JdI1bdC1XHONzoLHvHqVjkZmJNlwHko8ZQo1uMw== Received: from DM6PR03CA0022.namprd03.prod.outlook.com (2603:10b6:5:40::35) 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.6064.34; Mon, 6 Feb 2023 14:00:33 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40:cafe::18) by DM6PR03CA0022.outlook.office365.com (2603:10b6:5:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35 via Frontend Transport; Mon, 6 Feb 2023 14:00:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:32 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:19 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:19 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:17 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 5/9] net/sched: support per action hw stats Date: Mon, 6 Feb 2023 15:54:38 +0200 Message-ID: <20230206135442.15671-6-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT025:EE_|CH2PR12MB4184:EE_ X-MS-Office365-Filtering-Correlation-Id: 837b8d6d-8d74-4e3e-dfd1-08db084a835e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CqpbTmoaHtI2E1OfNntw4SvHQgOydpqZjQ4ky8o1qRwLejJ0K3dkXUuC4bKm+W3H5ROS8LPbuT7DSI9nTBisCQrALqtx37L7C0LuHkA9E34wyPriQjum/4L85bVcFivYNuUGu5fwa9gaX41gOKTpU1Z4jrZVCj5gvr05PAMwkoyYfzTumATmMbKLqULNMoxh3I8R1XetK8R5RMDKUMcsmrKISLuzGdFL0ND0HK5rsCkBa7Dv0Mg1UInIpGoCDdd4dGI8Dc+4HeExMWe7y+u0VWHPLA8Rrzi/RcIen6FWtbp6NkdkxPOpNPGxOCpFY8lPGDC3MSG1q+jwptTLB5MFTbQ/cOlx+D08V8yFFAnkq2djTuhGiws12Uc4v4cZw9LAGd4a/KpUypVk1ZIvE422U1hCYeSkggte50BpLXKYWl7dC8IyOh/7T3RHlYB8ROvB1jlziRlL3cwnkJvH7nT1HeKJWA+zwZbo085ZqMCb/V9P+Mr8XYHkpmbrt4B+TLvNpkTWeOGvc8Hhwad/x9wPWRfcbMeSwHcc/ei27FOMvtomsWqNb8fWv3j7wbKYBbfZz9Rqnpmuw7p8ZuV/0Tv+QtRjbmEGwcSanEA7xFiV1vpJblWEAZsHP0hMJOvVzkg1hGbWBa7XwmOryfjJU1P0LL5lLWIwYlkawWJ0eTqPOPqwA0kqrHHrKO9E4Fj4u5ezMG0NqF0eqfB5Cwv8s8U5O8s8VfEf2G3X71rfl+wa0iA= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(82310400005)(47076005)(36756003)(40460700003)(356005)(7636003)(40480700001)(86362001)(26005)(82740400003)(36860700001)(2616005)(426003)(478600001)(186003)(83380400001)(336012)(8676002)(1076003)(107886003)(6666004)(54906003)(316002)(4326008)(70206006)(41300700001)(6916009)(70586007)(8936002)(5660300002)(2906002)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:32.6129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 837b8d6d-8d74-4e3e-dfd1-08db084a835e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT025.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 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 --- 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 Mon Feb 6 13:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129923 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 9925BC61DA4 for ; Mon, 6 Feb 2023 14:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbjBFOBs (ORCPT ); Mon, 6 Feb 2023 09:01:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbjBFOBJ (ORCPT ); Mon, 6 Feb 2023 09:01:09 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D427F28211 for ; Mon, 6 Feb 2023 06:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5L5IrvXtDs2rjPir7zVpRvFsrb/Yk/kmqZhhjfeHjOyupUdQGhfJhP9RWAiK0OAMrsgBjscveJzxm3bGw4HcUqHmMeT6ZNU4mPZ1FILr8nSwXkOWdESArr4eMlZCFW6PQ4y7+HA5QdGDOZxyaslGA8lkrgjmNIp2XorNldSWeRR94rFBlTBa8wZNtCN9DCdND3ptqCCNonDBQKfP9Hc4kY+f69MP/tZD5RUVqSLgv7hwmoFsUC/6CswxQVkZ6iV80ChtJMFtSJ5Jalh0M2n3e1/q2egP3ZF5IQLytCkcyR4b/pALU8qGS32lVHQemeMJAWtq8al7jq3DHhhWfRM0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bMfHc5isviPAq4o9ckZeUYS1gFA00N0SeOsvV31q0tU=; b=k2KDoMxWhUDpuvPX4iH6mZRs/qvqbFowUKsve6h6VR/DuWsaKH+xn9OxOXHAJIxE2zP7yu7W+mbdM89sRq8mOIDS6rbKrbKxZNyae/9hgDpQMkElB6pNNhqZieUllzmzrW0U9tQURAPMkca9xA5Of3pD2sKPw3dZdeZqJDsec3hdI8JVRiF73UIDa7Q/AwQcnjrrmBxy/0TuSYA52dA4upJYkjQecUTBlqiEmDXpsBri1Dqp7WuKTpPMTrNczGj3d3/aMzUJmhwelkkaqBZH1lvltzCa8YbbQkrcTKM1l1zD5RX4N3eyAihTSRzjGUfFa049j0/4IyhrH8SB+OedUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bMfHc5isviPAq4o9ckZeUYS1gFA00N0SeOsvV31q0tU=; b=nzF6mloggv/yJLrwyYjW7G+3fx0P6auXfAYjWjUML+ypVD/SFNd3eJ6CxIe5l/OYnhWoo43hBD2fG22MvKe0XL4FDBPnHTkSmz2JR0UMU2bWBx2uaYBMKw9djjT9BVM5AJDKnN5MjODee5AnkxsBRJoMRb8iwSaAqRp3jeaZygU+EU1pQ+jM+Th60nuVssDvHx6EEInbOHZhsw6+xj2MBlLPy57QgB7NINqemNHO9AT+O6I/NglGevC7oRwYQRTX/oieLz8yDlnpl/t30+HXD1vbOZBzWi3Hbj7TJwoGFPaKzWasC5/ylQoV+nDP7kCYzcR2RYNAFgzEpXrQXVncPQ== Received: from DM6PR01CA0008.prod.exchangelabs.com (2603:10b6:5:296::13) by DM6PR12MB4925.namprd12.prod.outlook.com (2603:10b6:5:1b7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:36 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::a3) by DM6PR01CA0008.outlook.office365.com (2603:10b6:5:296::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:35 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:22 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:22 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:20 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 6/9] net/mlx5e: TC, add hw counter to branching actions Date: Mon, 6 Feb 2023 15:54:39 +0200 Message-ID: <20230206135442.15671-7-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT049:EE_|DM6PR12MB4925:EE_ X-MS-Office365-Filtering-Correlation-Id: 563b10e7-5b6a-42b9-9c54-08db084a854f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TwRUkB9ftQI7NNH5SJR54JcrqZxfoWaVz5mpUlU/pAHc/aBWD3+BNg+HU6ulro66T3+A8+qIWOjzyaxrGG2CFNyczwM8Li8wakvCy8c1jEeVg6GJHq6cnPDOqIxzb48KPU6ovuO8VXZ6tybyEWLDTiM3MRhj3nYJRtbs/tB9d+igduGi/KSHgsRZJPvHFjyc3NEztumoSoefxyJG1/5iA6KntFUDYvC/FmzgXnfK0tR3/Pl5u1FVJweAVzKGz5uxTExSxkHE3l0EsOq7wW27Kmy5CZnqt8PVwyVfP3pX3KykY/TzVoW10PuXqDuVllvxdPOdRJYbouSM6Y5cJmERnOSV4lAOPkc2twm6p4aR6JaE/ETk2Xi2MV0JMFvWd54oHYgaiE6UGdHq5KWPHCve6/i81LlHkXAFxa/InMv45yRW48LOLeiZoRtZPBAjDMDdgmX8i1eWRia3o0lP9Ti2Iqp4gfOm0B7gDvvxtAtVvVvZW1OKg0ZhaPfuuUHTkJRrMXw5efaW6/HYHI20iwqmNiIRCyQCCazLHC/wZbIFCl+6Wp5kvp9XtEuJ3JA/AqfrU5TJ6pAG3R8/H8/ButXxOTAyaVKAilAlPomnYszcM4ZIyzNSsLIUTwzyzoroNFwDFaqBJxsFbki0fPCPJwJIi16ipIWTo13yXOnSxfMPq8IX9cm6HSYL+j3eqsItibOwoq2VwVyRvjgsB2AKVL04VQ== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(376002)(136003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(336012)(70206006)(47076005)(40460700003)(426003)(82740400003)(7636003)(40480700001)(356005)(8936002)(41300700001)(36860700001)(6916009)(70586007)(4326008)(8676002)(2906002)(2616005)(1076003)(26005)(186003)(82310400005)(107886003)(316002)(54906003)(478600001)(6666004)(36756003)(86362001)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:35.8996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 563b10e7-5b6a-42b9-9c54-08db084a854f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4925 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently a hw count action is appended to the last action of the action list. However, a branching action may terminate the action list before reaching the last action. Append a count action to a branching action. In the next patches, filters with branching actions will read this counter when reporting stats per action. Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 4e6f5caf8ab6..39f75f7d5c8b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3796,6 +3796,7 @@ bool mlx5e_same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv) INIT_LIST_HEAD(&attr2->list); parse_attr->filter_dev = attr->parse_attr->filter_dev; attr2->action = 0; + attr2->counter = NULL; attr2->flags = 0; attr2->parse_attr = parse_attr; attr2->dest_chain = 0; @@ -4095,6 +4096,10 @@ struct mlx5_flow_attr * jump_state->jumping_attr = attr->branch_false; jump_state->jump_count = jump_count; + + /* branching action requires its own counter */ + attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + return 0; err_branch_false: From patchwork Mon Feb 6 13:54:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129926 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 8A273C05027 for ; Mon, 6 Feb 2023 14:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbjBFOCq (ORCPT ); Mon, 6 Feb 2023 09:02:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbjBFOBJ (ORCPT ); Mon, 6 Feb 2023 09:01:09 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37B328207 for ; Mon, 6 Feb 2023 06:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TkrWva0MACSxirlPde7GbFvw9XUxhNuK0kma1rg1d4+HhmD23W/rBuzLus489ae3XPL+53AtvokPP9JJ2/p5hC/qv0l2sf9ONfKbqCi3aCtpectYtzAk+REYxJPsIEK457G8h6UcrFO10RTIJTJbv++kqr+5fLfXzq2SIo38GOULMKDEfIfPWNTA4yr6jlYZlTK3SlbKX6UoU0h+l5Uo+SWpip+1ZKiI2pkT1PToiouPIGWZlSUbaQVhox3Xpx9rEYzO1HcXIk0KHEn7oU7WSrL0uuASeMZLjYeyYfFsZyEdjcLx6Z2r9AIeLHKT3ZH7oij1oEkE1n8CqfEmOBIt5Q== 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=qH0uDYc0Gcl8lsCxYn8R81YLZ0hLaQjmJgjBfaeb48k=; b=mc0iCcXZazF+AbQDAwQzWc/QTgCnkbo5JcJIP+LsM8ZA07Y+4O7k1hyS+mBQ29Lu/NHrbN4g4DgRks2beqbEDTVosjssITRc2i/JsHKxEXZvcv4SHVJrFS0+VU0JPm77mynEqpj8iFPZ7llq+B2OzE/IBOhElgVidA2Bk0XE4bo50UDYmVIDj8sTso96vRkzn2dYyGNd1y3Rd/0Gvx8sZ9gXlqN+2WsaHe7CAmhi38ydazXWr19vP1yEgn7hliBaeilkuWq+0rtQYIGP8GEGV3MIMujd/XxQX4BF59kBLY/j2Dh7TWOZfAqUZPKq1iHIUIaWpmVeqvtnFvvkZNjv8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=qH0uDYc0Gcl8lsCxYn8R81YLZ0hLaQjmJgjBfaeb48k=; b=UZEk5Sex3OwuTiI5LmVrn5G7SjxneQkFRtnCis2gApzOGlQhgnAfjJjLDDcHR0vtq5n+WIgnGLkuXIKWoJNeKzna86uYwZbtTSoiVCiaOXWUWMkIuBotlte75MPwvnJ3DYf7fMfZvMwiAPe4+CjpMCBGayvESC7sQ6Uf+R345PPGw2/tUmJ2vjtYZqzgseoINodT+5ksgJgnLxi9wTYQJzILpgB7SbaXgIKKinY36gEYPJAoDX2zLZ2q9mVIgaCRpYRhIO6YVWgtJv0ATA+lbLT52ntPvOdtGbhRq23XBzglOiR1E12TFPZPZvnCd3H+5LhA3tPxS4EcqBrp8KRnWw== Received: from DM6PR02CA0102.namprd02.prod.outlook.com (2603:10b6:5:1f4::43) by DS0PR12MB7972.namprd12.prod.outlook.com (2603:10b6:8:14f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35; Mon, 6 Feb 2023 14:00:37 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::6d) by DM6PR02CA0102.outlook.office365.com (2603:10b6:5:1f4::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35 via Frontend Transport; Mon, 6 Feb 2023 14:00:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:37 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:25 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:25 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:22 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 7/9] net/mlx5e: TC, store tc action cookies per attr Date: Mon, 6 Feb 2023 15:54:40 +0200 Message-ID: <20230206135442.15671-8-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|DS0PR12MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 14d36683-8788-4145-bf3b-08db084a85fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HvLie6dEBTt7Wq+7QunvSjvHqOJzCQ4GFzHQPWmjTqp6mmfCo5R6hccXkKuawq+IkPPCNle8CxBA496BaAwTq9x/Obme6dxP3Fwoe50HLeil+pNEtQlO0ZPtsa7McQLvylRFwRtOeqwJHIR7s1GSdwQl7LfxFshsLkOGxqoLo5lwBr7flvhgoE1KPXLQ3M0642Qy5TueAgNbfk+CjhvCymM7XG53weqS+tC2lnAS8HKoZrfLzza/IHcYBvFADgaAWEHyXrgxgfioYM8YUjz1jjwYd3j55yAQApboWkK9FeaGrmvAGbVa7ipSoqhaKF2hb7OTpK07FhwCySmD4f7wmrHUb+5hDkWz5inHpAl7Is8XDDchxz07fxNGzCxoPWxBUNhzyrWjdBnguRyq0Mu3+v78Ta2JGsEKGwe7ZgsS+wp7BgocXefqfYrW2ANVqzMI27gwuQszNdwbBktiBUvPIRkBqDRDkXvvhAmeaLlVMkiRS44mTl1hxfhYEhMQf6SpR4JZ5tU8e1Y+1iViXe/S6jDN4x/iiFdijn5rbeUUCrO484p19YARU51GuTuA403n/gK++rtMnFyqlbj4oGaEa26e2PG7iZX9320B3a9hdrbBZgD0+4kTwb+frtE2gKQXhrWVQqmOCVJdUKLx0qJg0M8gt1NIAsYnqm1kQg9s2agIpdEi1jn3wTp7YGV+rU82eYiFZmPQM+HxCsFWSr/LGw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(39860400002)(136003)(376002)(451199018)(46966006)(40470700004)(36840700001)(82310400005)(5660300002)(36756003)(2906002)(356005)(41300700001)(86362001)(8936002)(26005)(316002)(54906003)(70586007)(6916009)(70206006)(186003)(478600001)(8676002)(82740400003)(40480700001)(4326008)(7636003)(40460700003)(2616005)(107886003)(6666004)(336012)(47076005)(1076003)(36860700001)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:37.0252 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14d36683-8788-4145-bf3b-08db084a85fd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7972 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 39f75f7d5c8b..a5118da3ed6c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3797,6 +3797,7 @@ bool mlx5e_same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv) parse_attr->filter_dev = attr->parse_attr->filter_dev; attr2->action = 0; attr2->counter = NULL; + attr->tc_act_cookies_count = 0; attr2->flags = 0; attr2->parse_attr = parse_attr; attr2->dest_chain = 0; @@ -4160,6 +4161,8 @@ struct mlx5_flow_attr * goto out_free; parse_state->actions |= attr->action; + if (!tc_act->stats_action) + attr->tc_act_cookies[attr->tc_act_cookies_count++] = act->act_cookie; /* Split attr for multi table act if not the last act. */ if (jump_state.jump_target || diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h index ce516dc7f3fd..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 Mon Feb 6 13:54:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129924 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 44B74C61DA4 for ; Mon, 6 Feb 2023 14:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231213AbjBFOCJ (ORCPT ); Mon, 6 Feb 2023 09:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbjBFOBk (ORCPT ); Mon, 6 Feb 2023 09:01:40 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7736729438 for ; Mon, 6 Feb 2023 06:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EVns4hOR3ojq/nn8XQiOHduGBXmWjpZUrJYm9bRnlOuNTa04qLU3wNMaipCORu4w1vxfK2SMny58RzuxRfS4ALcXAUGkqeTuvF2Mn4o77gnqQobW5BSV0I8ywijAxhW9t4rJYnCzqXS2kUrRPgXYMe5MIcZCjs9rIP9+HdukpHZPwOjEAAXBa7ZXQmVeig5PhqktmBT2a4oMHWezrlX3X5R+sxEStgsu/lgpIJ6ZDBFriCXfb+lv6rkTnzkb/klD0Ie4SHFg9s/umBZukRLg/sfDw+HMlgEHWjJ9FLEs+LpBkMZik2DEm4jlzpntjknmRyIZ88guuAUcSahALCYRhA== 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=I1WINQ6yox3Nla3dethRxITIzoiZNf/AcgCIBTGq46c=; b=JlOot1XOZEnVWO0HEkSXvkKnOkQeSXei+FHRt7BPqnCzI3i3+tF3nnB0PY9+shSuiNX31ixTtwHDR6mCYI6DRI9/KAl9PFnyN0fVj4bekwFmpHIv/4FHj3CVy+NtPi1hmtJ0/EwcdB2VqdrqS8/Zuh+/hI1eofdP8j9V8mKzYwwoJHLthu+POMp7z269qYYGQOKZHM3X7TWdLl54PJZGTiaUCRecSXeJ7oxtS376nG03U4avAeBEyif5+hbNwE8z6JpXIFX1QpEdZUT01NqPvsW6YUt/8cLW6AM7ru6CYtq/nwkOAXVCR8Q27zBQMyzB1qiK6NXwJq9hhkpA25VBkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=I1WINQ6yox3Nla3dethRxITIzoiZNf/AcgCIBTGq46c=; b=Qdm5yP7+SAqOnz7QLGH8Z5E9TdEQjziHVQHs6aBFhfSPvWAnxt/z/i6NUml1QMRoBomMMdN2jqkpgG0ay2g0KGb7U5LvXB8hsU7rHQifibqgIN3dvzoxjW6MVTlvDD7JDeCpFnWrfb5bRFKFOH/DWZzyWIkoS9N0p5Ymo87vrrY8F5UFOp1JY03lLNThIpzSni7WZOL1/yUkVyt34RQ9e+nXFuUyuTLm2jSbxyfaspKbfWRSH0qimC1aG1N9CNGiR2pT6zvCJc+5FlgTmPtmyXGi00LJZPZjhJGAAwD69smoTA/iw1rqVVdR/2MXVd/yCAJ/hIZBnf0TYjz5LDrMgw== Received: from BN9PR03CA0519.namprd03.prod.outlook.com (2603:10b6:408:131::14) by SN7PR12MB6713.namprd12.prod.outlook.com (2603:10b6:806:273::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:44 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::4e) by BN9PR03CA0519.outlook.office365.com (2603:10b6:408:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:43 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:28 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:28 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:25 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 8/9] net/mlx5e: TC, map tc action cookie to a hw counter Date: Mon, 6 Feb 2023 15:54:41 +0200 Message-ID: <20230206135442.15671-9-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT009:EE_|SN7PR12MB6713:EE_ X-MS-Office365-Filtering-Correlation-Id: 80c16bca-95c1-46cd-ef61-08db084a8994 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bGtHd/Nk+rASm8DpBmHAByf4ipilG+x/UtYaMnCN53MD4Qi6MaX3Vxi+7xbikFQCz0I3ora1mo/p2Q2nLocyAy2pDXBeYUkQDL7zb4UOvF8kNFbw5IH1TxszNN3KqC+ZPxqk950Ybo1JETbJKm34iKwQ2H6VufUiwDSl8NxndoJ2pEWk+at7LiwPkVdqKVhYy+unUrGbrMyyZcoPzqW20Mul15ZVI1IkbuLNQW85w0eY8CYP99tDHjmhQsPs/DwzjqQpsZojRQqfLCelCCM1Aya0DFtw9u/mhgUEgfzE3rTl4gbwsiGLPvvHoGzuG/sqU+CTKC9KaGfvW7D8qpHYt6NUkoAf/UkeDHloW9f+/F5N1cQYx/nY+L8OxGXiHzhD/hnphtzfyVXFk4I0Hns1iQBIrd9vdumiSGCR1J79xrhYERngILx98itFxcrKXD0AnVyypcErLIstk2eNhnQShYL0qI/Tym89yR58SHBYvaYTWlG3Q+1j0vbbFy9xURPGs0isRKkIKXKSPE/WJqRyikI0dY1Vld+QvI1YMtxyKKK78ICSfZkKiPi0oM0/nnaqXtgrKO+d1xiorvsH6k+1nbKM1O/DEeYphC52lRG+LwwvhDgvlxG8Vu78crfedj2XhSY23M9N/DAgQdhJNajRyqtQM0A6O/Vp1VTxXgnYqvVC91FMREYgjRe8s6Sktr0bJqfPDskvHXV7baONX20Zew== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(1076003)(2906002)(36756003)(54906003)(107886003)(356005)(83380400001)(2616005)(316002)(6666004)(40480700001)(336012)(86362001)(82310400005)(47076005)(426003)(478600001)(7636003)(40460700003)(82740400003)(26005)(30864003)(4326008)(8936002)(36860700001)(8676002)(6916009)(70586007)(186003)(5660300002)(70206006)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:43.0023 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80c16bca-95c1-46cd-ef61-08db084a8994 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6713 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 a5118da3ed6c..ec5d1fbae22e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -45,6 +45,7 @@ #include #include "en.h" #include "en/tc/post_act.h" +#include "en/tc/act_stats.h" #include "en_rep.h" #include "en/rep/tc.h" #include "en/rep/neigh.h" @@ -101,6 +102,9 @@ struct mlx5e_tc_table { struct mapping_ctx *mapping; struct mlx5e_hairpin_params hairpin_params; struct dentry *dfs_root; + + /* tc action stats */ + struct mlx5e_tc_act_stats_handle *action_stats_handle; }; struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[] = { @@ -286,6 +290,24 @@ struct mlx5_fs_chains *mlx5e_nic_chains(struct mlx5e_tc_table *tc) return err; } +static struct mlx5e_tc_act_stats_handle * +get_act_stats_handle(struct mlx5e_priv *priv) +{ + struct mlx5e_tc_table *tc = mlx5e_fs_get_tc(priv->fs); + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; + struct mlx5_rep_uplink_priv *uplink_priv; + struct mlx5e_rep_priv *uplink_rpriv; + + if (is_mdev_switchdev_mode(priv->mdev)) { + uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH); + uplink_priv = &uplink_rpriv->uplink_priv; + + return uplink_priv->action_stats_handle; + } + + return tc->action_stats_handle; +} + struct mlx5e_tc_int_port_priv * mlx5e_get_int_port_priv(struct mlx5e_priv *priv) { @@ -2035,6 +2057,10 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro if (err) goto err_out; + err = mlx5e_tc_act_stats_add_flow(get_act_stats_handle(priv), flow); + if (err) + goto err_out; + /* we get here if one of the following takes place: * (1) there's no error * (2) there's an encap action and we don't have valid neigh @@ -2131,6 +2157,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, if (flow_flag_test(flow, L3_TO_L2_DECAP)) mlx5e_detach_decap(priv, flow); + mlx5e_tc_act_stats_del_flow(get_act_stats_handle(priv), flow); + free_flow_post_acts(flow); free_branch_attr(flow, attr->branch_true); free_branch_attr(flow, attr->branch_false); @@ -5342,8 +5370,16 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv) mlx5e_tc_debugfs_init(tc, mlx5e_fs_get_debugfs_root(priv->fs)); + tc->action_stats_handle = mlx5e_tc_act_stats_create(); + if (IS_ERR(tc->action_stats_handle)) + goto err_act_stats; + return 0; +err_act_stats: + unregister_netdevice_notifier_dev_net(priv->netdev, + &tc->netdevice_nb, + &tc->netdevice_nn); err_reg: mlx5_tc_ct_clean(tc->ct); mlx5e_tc_post_act_destroy(tc->post_act); @@ -5393,6 +5429,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) mapping_destroy(tc->mapping); mlx5_chains_destroy(tc->chains); mlx5e_tc_nic_destroy_miss_table(priv); + mlx5e_tc_act_stats_free(tc->action_stats_handle); } int mlx5e_tc_ht_init(struct rhashtable *tc_ht) @@ -5469,8 +5506,14 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv) goto err_register_fib_notifier; } + uplink_priv->action_stats_handle = mlx5e_tc_act_stats_create(); + if (IS_ERR(uplink_priv->action_stats_handle)) + goto err_action_counter; + return 0; +err_action_counter: + mlx5e_tc_tun_cleanup(uplink_priv->encap); err_register_fib_notifier: mapping_destroy(uplink_priv->tunnel_enc_opts_mapping); err_enc_opts_mapping: @@ -5497,6 +5540,7 @@ void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv) mlx5_tc_ct_clean(uplink_priv->ct_priv); mlx5e_flow_meters_cleanup(uplink_priv->flow_meters); mlx5e_tc_post_act_destroy(uplink_priv->post_act); + mlx5e_tc_act_stats_free(uplink_priv->action_stats_handle); } int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags) From patchwork Mon Feb 6 13:54:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oz Shlomo X-Patchwork-Id: 13129925 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 748A4C63797 for ; Mon, 6 Feb 2023 14:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbjBFOCN (ORCPT ); Mon, 6 Feb 2023 09:02:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbjBFOBn (ORCPT ); Mon, 6 Feb 2023 09:01:43 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81830298C0 for ; Mon, 6 Feb 2023 06:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PjGyfGh4DDgROYIibZ034Bzw+DnxkLt3l8vh/sTmii5iiRbtvkkV43Gn6NMMz8f0AeYe0ykStOApYwsMAlridcV09/cY1DOG09DFLo2HZf9u6zEfYeoqCznOBVUzUc4PJnqavh9/Zi/Yx1LrcQ0uwBuTBJbZxqYZIQS6qdNazA/aZahmUjUGO8y5HP4LN9gZwFsEsK2B/+4sGZoAKI9nr+ixr75VFCHfun6oN9dGPFAM2xslZGMly2UO+U5ZacK7ASX1b9X9dmMCCAwW1pM5dsz1KwQ1QU9aekwOEJRyFzEkFzH/uLWGE8WJDD8j4EvxjBaIjKmC+z3turnKjVGoXA== 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=1sMqnR4oR+k4VRZsqbv44XBPr1lbX+AunSGunTtjB00=; b=MN+Qx3MNzc5jZsYUV7cF/nGztruuYO4wcqi3jyl2hd9zJO0FqLiaHCceFGKFhupq40xUeAyPJk0pm/XVrwt9qGxgz8QDtg/jbT96IGUwzlREE6Hxn3RvxxWWmd8itx/PuY2/tzXoe16sfsgO9Lqhd9qcHWuaSH94+/nV2jGRz1KdhfBChL80e7WlSZdOFWwNnkvjiG8nFAdF/8gEYcBTaC4DG2Cd8dUr2jBxxKy7oBCZ1+HoqLRhTWGJkp+mQtgpbwASFOfkBRpGSjRfcQ3VF9m8EDB9IAnqCCPmrttnuQfbr8lTlFUtIEWH3WBTpEqP5KbesgPH7RAQcdYQ/J5dbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=1sMqnR4oR+k4VRZsqbv44XBPr1lbX+AunSGunTtjB00=; b=Xr8aghGCAx7HABUQssg0ore377H2uWJyCi3C/NHsdLisl0rHmGiUQqHWLbo0iDG4IK+Fj45Iplyoz0nPFPav/aT3XrJ1W8lm15wzSZ1zmGIh4ztCLcfE90gQmvcGSJ8GubouY7oKTI3a6GYLcDPdAiU2hyf+eVqhK88bEIBh53R1rfxnxOrsWF04xz581T+AbIB6fsPX+v/sthq3lSN+5vHyVrw7sZsJHOo1xGto99YKULupUhKmdIx8e3ZvyQBd0mXu9TO2m6iGMRCd735l89GRhz9ZND5kNW4XNpbQfRdRsu7KfBbO+J6+W0kMMdPXyaoMaZqHmbkXMXAgkNBkYQ== Received: from DM6PR02CA0153.namprd02.prod.outlook.com (2603:10b6:5:332::20) by CH2PR12MB4085.namprd12.prod.outlook.com (2603:10b6:610:79::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 14:00:46 +0000 Received: from DM6NAM11FT076.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::fe) by DM6PR02CA0153.outlook.office365.com (2603:10b6:5:332::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.35 via Frontend Transport; Mon, 6 Feb 2023 14:00:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DM6NAM11FT076.mail.protection.outlook.com (10.13.173.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 14:00:45 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:31 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 06:00:31 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 6 Feb 2023 06:00:28 -0800 From: Oz Shlomo To: CC: Saeed Mahameed , Roi Dayan , "Jiri Pirko" , Marcelo Ricardo Leitner , "Simon Horman" , Baowen Zheng , Jamal Hadi Salim , Edward Cree , "Oz Shlomo" Subject: [PATCH net-next v3 9/9] net/mlx5e: TC, support per action stats Date: Mon, 6 Feb 2023 15:54:42 +0200 Message-ID: <20230206135442.15671-10-ozsh@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230206135442.15671-1-ozsh@nvidia.com> References: <20230206135442.15671-1-ozsh@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT076:EE_|CH2PR12MB4085:EE_ X-MS-Office365-Filtering-Correlation-Id: 00ab5b53-d6db-46d6-d405-08db084a8b45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7+FZavZkQoZ0RNQBzKcNrT+rj1GuU1r6vKsp8qMmML7d/IMg3Rz+23kyb7KfIB3UfMbsbVFTo1x2qsklhpysDttiGbhOGSKAviKwuCM7zXp+eVpwr8DovUzzqSqVazUYLDoZJ9UVBtYpKtgwPaDItbq+Yn856SOAUOQ1lt0IAh/8LoGJCE4p6TCIgNuYbt0wVgZ2vajey17gxT1V52iDpIFiB8jzkU3xg78lPzL/xivgDk9717l6fWvZgMo9AC3Zp2Aln3cKJimtW5icWSwTOK22TSsEsLF1JV6+OdzuxZ3OvTsJyyD3a5bSmAmcJ2lnq5tHzLZTNirdGxBjMFqMBtWMB7Xhu/cR5PHyuEQvxqOTq4mBbO2dfvgJTa11POwfuFNLSR725k2Z1bcsxfP25ypqi54UJKebk5QrqUY8BE5nJgzEd/wMsN1qZmyV/m/Cy+YfKAHNVsqqCD0lRopUSbJuVUz3plLYCjlnBp5yvCayBqVS8KBzyIcFMIceh4gXRbmTK5Rt/2jNUZ0u2mhDF3uAHmyhDAIyvTpX1MPSRD3CHPPXccrQv5OLGR0FArj9mciUVZvUp1ykBCZKJSK95rZ0YuARNiwwHxoegD19VSc8MMFHaO8XN36cggGol/CTIA21AGTOfjs2spCtTXVp2pT9QJJIFnp2oMT8Phd9luflrFi7/6Jf61LccIA0fvgwNU59UyN1kX8PgkMfdlTBqw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(36860700001)(36756003)(26005)(82740400003)(70586007)(70206006)(54906003)(316002)(82310400005)(8676002)(4326008)(41300700001)(6916009)(8936002)(5660300002)(86362001)(356005)(7636003)(186003)(6666004)(1076003)(107886003)(2906002)(47076005)(426003)(40460700003)(40480700001)(478600001)(83380400001)(2616005)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 14:00:45.9018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00ab5b53-d6db-46d6-d405-08db084a8b45 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT076.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4085 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 ec5d1fbae22e..50432c9d78c0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -4128,6 +4128,7 @@ struct mlx5_flow_attr * /* branching action requires its own counter */ attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + flow_flag_set(flow, USE_ACT_STATS); return 0; @@ -4978,6 +4979,12 @@ int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv, return err; } +int mlx5e_tc_fill_action_stats(struct mlx5e_priv *priv, + struct flow_offload_action *fl_act) +{ + return mlx5e_tc_act_stats_fill_stats(get_act_stats_handle(priv), fl_act); +} + int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, struct flow_cls_offload *f, unsigned long flags) { @@ -5004,11 +5011,15 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, } if (mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, CT)) { - counter = mlx5e_tc_get_counter(flow); - if (!counter) - goto errout; + if (flow_flag_test(flow, USE_ACT_STATS)) { + f->use_act_stats = true; + } else { + counter = mlx5e_tc_get_counter(flow); + if (!counter) + goto errout; - mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + mlx5_fc_query_cached(counter, &bytes, &packets, &lastuse); + } } /* Under multipath it's possible for one rule to be currently @@ -5024,14 +5035,18 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, u64 packets2; u64 lastuse2; - counter = mlx5e_tc_get_counter(flow->peer_flow); - if (!counter) - goto no_peer_counter; - mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2); - - bytes += bytes2; - packets += packets2; - lastuse = max_t(u64, lastuse, lastuse2); + if (flow_flag_test(flow, USE_ACT_STATS)) { + f->use_act_stats = true; + } else { + counter = mlx5e_tc_get_counter(flow->peer_flow); + if (!counter) + goto no_peer_counter; + mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2); + + bytes += bytes2; + packets += packets2; + lastuse = max_t(u64, lastuse, lastuse2); + } } no_peer_counter: diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h index 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);