From patchwork Thu Feb 10 04:13:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12741237 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 D32E5C433F5 for ; Thu, 10 Feb 2022 04:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233155AbiBJEPj (ORCPT ); Wed, 9 Feb 2022 23:15:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233116AbiBJEPg (ORCPT ); Wed, 9 Feb 2022 23:15:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C931655B6; Wed, 9 Feb 2022 20:15:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aumz750zjEbrmhQ4gCx8Q9DT9zCgjH0tI+kyn2/fKZz/9Pah2MtiG95AmWslAlot4xspgSLJHZBPKubju0Wwm6VDSzMlBq8Jzoy9f9EveQo8EN4grcJR8F0bLKbw36ABzdG1eJKLDhJMV94sc5NIUeod+IpmW/5mJP8FJa4Tn0eslVT5VnoPPL1hcTKCqtXI0EVeKA1507rhH1ZydI9iAj+bMTR/dpRWgkbwfDSqGaGPd65P0MX9Hv8xKDjGC6rGjMQhuaVgey4LjgYeeb/7UfY6W1H4Orl67haTIoGJKTEAjgqvEBKpSprPIlJGjZ5ohxeXDUMusGPyx0zniJa2Cw== 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=64JdQrorSOzXXiUx/CxRquRBwwgUczwJ+Erb//gyknY=; b=oUOwRP/RpPiLSTKjjkKbA6mmt16hpo8oN4AXDJQxI3TtZjo3BCz1357tLy/3RFIycwrEPQvUIzp1oEYmAFzZJNhslo6Ue/pHTjXhyThx5zZQw3I0awqcJm5F2286tJ9PsWRuDCW5PLuNEkrg1CTv8aZpVUmhjISPHumpusFvKXjsanSgzrW0jenOdpCy1SbnAe4vIdsMSf2hWDx+mu27IfM9rnbI2GrWrSpLch30aITCg+Nmjgy//2krn4uU1x5BQxFGpbuot4/xluWEa//6LJdjI4dKb4R3IuYNNyZMFYGj1quePKDq1Vnh63X/YGD5FBxvngHPvk4t+IB+i3UnnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=64JdQrorSOzXXiUx/CxRquRBwwgUczwJ+Erb//gyknY=; b=rlERPA8EBZbqa+Y5lSFes0Bh1CCBuNmHQIbv5o+taDwvs6dDSPaJXJBCEQkXaEW5OFXnm3QKE+EsL0KXcAxeT20Q29I90kyXvk9tZAuVmObu2x6FV0uPICtkCrffhePUiD9cMLL9Ywes6hTJF11M27kcOe7GJIifULp5eP/j2W4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) by BN7PR10MB2564.namprd10.prod.outlook.com (2603:10b6:406:c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 10 Feb 2022 04:15:35 +0000 Received: from DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4]) by DM5PR1001MB2345.namprd10.prod.outlook.com ([fe80::bcda:8606:7c7a:b1d4%3]) with mapi id 15.20.4951.017; Thu, 10 Feb 2022 04:15:35 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v6 net-next 2/5] net: mscc: ocelot: remove unnecessary stat reading from ethtool Date: Wed, 9 Feb 2022 20:13:42 -0800 Message-Id: <20220210041345.321216-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210041345.321216-1-colin.foster@in-advantage.com> References: <20220210041345.321216-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0084.namprd04.prod.outlook.com (2603:10b6:303:6b::29) To DM5PR1001MB2345.namprd10.prod.outlook.com (2603:10b6:4:2d::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eefa4083-9ead-4a6e-018f-08d9ec4bfc70 X-MS-TrafficTypeDiagnostic: BN7PR10MB2564:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: knRJ6UyEAnXOZnVvlgIHsNXMcVUGcgS/KtgGtn32XMUj0RauaINP/UsemDW1Z0UubeV24W+LTjC+yZ23aWnp6yC8aNNQa+nbDaHKzFqLF2MCN8rM8Y6OZeNmb3jgwvEWAOAjgNgLy8rWR8N7fsde8siSzBzGnNkGmkHwNvz56ZigN3a463CUHoW7db251N/G3GC3pUMyCKJMyzeQzbp4QOsSJiqXz03/JP1r8GsL2gFbFdrnQZ402DMVhFFNyct6JnvDw2RQsT1yTawLljhJIPd2/nCgWmD2FxhrmaRHIB168cf6nocRHAAimUUpzITQXVb4pWDwd5I80K4bM27eyCFSOTuZsnBWbO97/tHKru+wbDZpPT5rHITsNwNbHnP6eHC1d9VA7asCYnXUH3ox/z4wEGTCs8a++yj3gvIdIAq9mymY4JUnt3dypt3PLdDZS048bejUsrBuci7WiB1HQLLy++19cmsZ2A56suwlq2RJ6+B3BmVTg8vu60ZX6SkTyVxK+/kihiLMTb7bgZKaGLG0yDtwkw2Zh3Q3pPkH2yHgujThFcFqA/07jET4mplGXLiPR2PXFV8fjQPeRla67+nZhgNJPaICQu0Qzda0bFc8hxGZJZFEAVSAqFQffK6RMh38YSFzA1KwMo7F0z7XyPoJtiZkZztbFXWnrcE/PlNrkXU/Jxz0FNg1w9iJGEuQksQ+66eggi5kCo7EZRi45g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR1001MB2345.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(346002)(42606007)(366004)(39830400003)(396003)(376002)(136003)(316002)(66946007)(86362001)(508600001)(8676002)(38350700002)(8936002)(4326008)(38100700002)(2616005)(54906003)(66476007)(66556008)(5660300002)(26005)(44832011)(6486002)(6512007)(2906002)(6506007)(6666004)(83380400001)(36756003)(52116002)(186003)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5c1mrxgVfSLWm/kbk9H3l19fQ9wJtV9t682NTRFpzH55JcNnJkmy4ogv3cTsODyHedXcSynd6sij4L0ZOLQp70QtmI/vZ4+qxv7Y0vTEoNFiPFvPL/xSXUHUMR0idufpxqm6+Yzgyun/H5HWWAWJH+AXtUp7jGb1MVAJ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tScoSgFkLYkgu43Qqz3Ix+fMk7JnAloBPWgYKK5vGDz1OGqhSmcwtYMykrpRXdnO1YEFA2YopZug0Xcsvj9KGcXx0gbEdM0ql7ClCtfbM+M8buv9FOFgF8buVabvogVF8d6G87/5AS7JeJnauNDz8TTTKabZ6H3et9gR2sY3oxU2pY5lQJERRc+tMWBPm7cfzdeVazkBZojzp6ISdvdwR3cuR4qcQL1kjw+kBmsRRCFwAQlxkIu+zSC7gITA1fzW0JYjRTyERwPSDJsD7pCwFjv/eQ83iUnxNwWehvN+3mwmvCxb325cy01wieA7iv0FJiVLcLKaFyhYqqfgGshkZpW9r+eKNDMw0T9lTQrzovMAiEI6MMGW1hmzSCu9SisJsYmd/IzpV/8+P0JZJgxzNn2BJR50HiHbG+Awv+catUhvxA92AUVRl9+wQF+l4vluP+4Tv0fze0j5Y= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: eefa4083-9ead-4a6e-018f-08d9ec4bfc70 X-MS-Exchange-CrossTenant-AuthSource: DM5PR1001MB2345.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 04:15:35.3255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5hONyVS08VSCECmBtnJ/NMrvbGdHAuunNXjgJ+T2VBXfTl9bsqakrgmR0wB81bEtgMkms1kM6MjyYgwC7jbEpdsUKmtc5J0qD8KoGgItRg8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR10MB2564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ocelot_update_stats function only needs to read from one port, yet it was updating the stats for all ports. Update to only read the stats that are necessary. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 6933dff1dd37..ab36732e7d3f 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1738,27 +1738,24 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) EXPORT_SYMBOL(ocelot_get_strings); /* Caller must hold &ocelot->stats_lock */ -static void ocelot_update_stats(struct ocelot *ocelot) +static void ocelot_update_stats_for_port(struct ocelot *ocelot, int port) { - int i, j; + int j; - for (i = 0; i < ocelot->num_phys_ports; i++) { - /* Configure the port to read the stats from */ - ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); + /* Configure the port to read the stats from */ + ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port), SYS_STAT_CFG); - for (j = 0; j < ocelot->num_stats; j++) { - u32 val; - unsigned int idx = i * ocelot->num_stats + j; + for (j = 0; j < ocelot->num_stats; j++) { + u32 val; + unsigned int idx = port * ocelot->num_stats + j; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, + ocelot->stats_layout[j].offset); - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + if (val < (ocelot->stats[idx] & U32_MAX)) + ocelot->stats[idx] += (u64)1 << 32; - ocelot->stats[idx] = (ocelot->stats[idx] & - ~(u64)U32_MAX) + val; - } + ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; } } @@ -1767,9 +1764,11 @@ static void ocelot_check_stats_work(struct work_struct *work) struct delayed_work *del_work = to_delayed_work(work); struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); + int i; mutex_lock(&ocelot->stats_lock); - ocelot_update_stats(ocelot); + for (i = 0; i < ocelot->num_phys_ports; i++) + ocelot_update_stats_for_port(ocelot, i); mutex_unlock(&ocelot->stats_lock); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, @@ -1783,7 +1782,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) mutex_lock(&ocelot->stats_lock); /* check and update now */ - ocelot_update_stats(ocelot); + ocelot_update_stats_for_port(ocelot, port); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++)