From patchwork Sun Feb 13 19:12:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12744656 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 D8FA2C433F5 for ; Sun, 13 Feb 2022 19:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237931AbiBMTNQ (ORCPT ); Sun, 13 Feb 2022 14:13:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237917AbiBMTNP (ORCPT ); Sun, 13 Feb 2022 14:13:15 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2133.outbound.protection.outlook.com [40.107.236.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE534593BE; Sun, 13 Feb 2022 11:13:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVdue1aOaOyYYSfdN3Ht7mrAAOf9EOlJVrZMTXZhibzmsTX1FYyjNq4NvkfLYvom1p6mFhLvGIa4+d7/+RCtJ4qllrepTzBi/4uNKfFSIip8vITwUCBP0o/8y7AsjSe/zDbLO4cM6ePz1ArKoYWuGlAT1lpXIvy8ELlt4JhhYNYt7iC/I7A4uqKj8n98RaJuPPgsXKVNOZond7zPU/NsE4v0FHSnMDsMOogl29piOWqh/9cXB8PJU3cC/19SDNqnUY+kM5MFRSTdRybSi3P2H3f/6r6EnWFdSe6fm4xJrBndMFNYjgWwuOun8a9MQcuYrgy4i4dSMfzecMr6xA7yCg== 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=juxvqwuCGZcRXNpT/zJB3Glo7mhiiIRS8v7h6zqDnzE=; b=RA3zE52U2DRMepUD86zRGvhPQDyElsZHYu2bPVfVqnSUDLCsVYzfR4MCY8k8RzKQpaDuzyScOrN4ksspQMM/+qNarVdMWBGw/lh5qfMQdbXo4wmRtIj15qM8ELdrtdrSrovG5NrMxjUsU2toKCfd+84k0Ipb/5WVZO4agfh1MJDFHKGAFoL/VOS8IoDvdhWQN1QAG81BWWnJZNJGHZjgFoP/XelIbyiAZFp9/NXs4n5jHGRj3twK6tDnr+P32ejZm1TlnaxpgdM6r76pwtTGqYdS0zOCUI+6yV2gCYRryWbW52ycwBKvCnwlOKwcCg/k2fjxW3tU8rmI8vS3H6NGYg== 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=juxvqwuCGZcRXNpT/zJB3Glo7mhiiIRS8v7h6zqDnzE=; b=tVfHNIua7xRSu5p23NBM1QnYMMgs3kQA1KJaoGLWPr0N3hMYV1fiS+pGHrnO1kg+sp3q9g2VKagZEhqCD3KCcUQSPEJ/gC0+5UwXP6dO7bmUQb7A2tFCk2YgXcfvG9HaQjj7HHcP1kgo2sSTtStqDmCfb1RgUsx5ZujKkREK6IA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by BN8PR10MB3315.namprd10.prod.outlook.com (2603:10b6:408:c8::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Sun, 13 Feb 2022 19:13:06 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7c:dc80:7f24:67c5]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7c:dc80:7f24:67c5%6]) with mapi id 15.20.4975.012; Sun, 13 Feb 2022 19:13:05 +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 v7 net-next 1/4] net: mscc: ocelot: remove unnecessary stat reading from ethtool Date: Sun, 13 Feb 2022 11:12:51 -0800 Message-Id: <20220213191254.1480765-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220213191254.1480765-1-colin.foster@in-advantage.com> References: <20220213191254.1480765-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0346.namprd04.prod.outlook.com (2603:10b6:303:8a::21) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb5127ca-4ebf-48e4-af5b-08d9ef24dc58 X-MS-TrafficTypeDiagnostic: BN8PR10MB3315: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: kxCUv6DCw5tBSz+eYIzG7FXyzgetgmiqRA5jiPCC7PeQruI4WCI12+ctv3fE5Kc6/si2tf+bhgUnCjPnJoONJg76cfX7ZX2s1iKd37qWmS3TRa2jWkvPOVKTFXw5hVg2a+YimB8nwn3Dgm2q+1WyiQce3lfquKj8gKvHD9MeDNwcRBMVRcj1x5pVxKiQMxpKCrc1PcSQqB7Iw48dlSMRgyBA54gIavehtk7N4JTipDpOjoAyehgbwTYgCmzP+vvrJ9nUX+Z2A990Rkpuqbi/GQu/ZnQYxDOdVvgjj/RheZ16+tQaGTAzFjS3HrXJsmXuUEHzkv6NN7liO5xfo//eHrCLtxRc2bB85hWJu8xMu8zlBUOQotu1X2DHVmdPhxDPdBHaVJTYfuX+hyY4yEPxU1E36/kZ6zAvzDPAP3tVdLROX66klByxsTgjcWi8XJFMi5Nxyx51a+Z/pjBlqPNmRzY35fJdke0wW+uwmFo6U7+5SzKNuGObAhUHOKYXHk35qLiVBvVVfISbSBA0JWkzuY5U9ZJBK22Ud1DQfd4rWd7OTIwli2dzgaN0GYFJ0XmzwuL30biGXmurYEtjCqEFmZCyrkJ210D+iXFIx8EWphlF2zcXwO2lVL9lTQDvjix1ylK/2Q2xke4kpJH/motd8cm+28byCf2/k8m2VrrVEDtq9MMqvkaaha5S0m3fLMdEYru3kIWI/rsIW2jvfXVnyw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(136003)(42606007)(366004)(376002)(39830400003)(346002)(396003)(26005)(186003)(2616005)(508600001)(6486002)(6512007)(66556008)(66476007)(38100700002)(4326008)(66946007)(44832011)(1076003)(38350700002)(5660300002)(8676002)(36756003)(83380400001)(52116002)(6506007)(86362001)(6666004)(8936002)(2906002)(54906003)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9zF280pDCvGPdRfLeHKnww2kKRpSlM83GcaOYritICodLSe0Pv91W+hrjGKE93sT/WWh6/TsBOUYbcU+vSLC1CqgBOdnYns4vD5qpfZD1YSJF7IdiStfbh0Xw/MXV8dyYJXI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1/vRIjexnZIcHd7iugmj1ddohHMWpkdygdmaWIApyoINaMX24X9cHHC03JRhfoZ5AgpoIHYO2jotkeBSPTnoAobCHYdY94YVDA3FGnmh3bcgi+F2DtR7LjRnpa4oo0b2ejlHaQ/UkfuVx/O1NGK66k1EawsyPmHQ4Wen/IawxZvpUPtCZEa4At/atFkhjalSXw+QEUHwfAqniVSbqBjfTJAd/bX6l/JuyrV8F0EkbMXflzsxn3NGoLBeMh3FQhtNJiRmbTUZXIESTWGuxX2NNeTLbsc87h9GGbgs61gZYj13HP8GXPHhyJ50gswrkrujE6toBPoJcWG/gdLZhH8VU7TuG8sNYt3jDBpsv7UUobNXszX5SXJ5Kv/T9NrQGZ3IAYk7cwicCG6Peb9BwUYzM34JdXXOsSUuXqGW0euj4qx6T7wHsvu0G29YJp/BABrIuMc3Mdk+eMqfrEEGatAB3w== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb5127ca-4ebf-48e4-af5b-08d9ef24dc58 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2022 19:13:04.6171 (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: dpCfT+PvZYsq4jjAugcveqwVSO+smg6arxBuBcNI7eOQN9z4ttHIXM9ZrpM4MJcGcUiOmimLzgNo96VbWXnu4QZ+6jH0FhxLgVKmYqibkZM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR10MB3315 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 e6de86552df0..885288eb389c 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1746,27 +1746,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_port_update_stats(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; } } @@ -1775,9 +1772,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_port_update_stats(ocelot, i); mutex_unlock(&ocelot->stats_lock); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, @@ -1791,7 +1790,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_port_update_stats(ocelot, port); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++)