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/MXV8dyYJXIqG1T+VwHjpwrhCw2y6EQQ803rvZuAGvWGgVwZatBhPunleQJpPBFX6rxjGYcbmaKUjIQTWbrWKv2jK1h3TYWivFFKNouSbC1cmKQJpqgp4gF3ERUMsI6zydtD3nZE1+I22U52XdQRNHQEwAA/G1bvpWwAVAadSK6tIfHYDY3TsaeiIwprf5qdEVoJ+1pVWeaAH1Av0l/PMVM0gprGdjHmvKxcWPy12RyMiEd4aMoLlGFtBQpJaBpWKkRbByMtUTFNednWXf6Sj6VQ/hKsm0a3pc44UPW96Fc/vvTCuA/dUVcfVeSinq5HBR8THpFwZEnK/SRsjE408C4mBOrOsobHL2y+9GmoIgBDwjqEl1NfhXDi/X1Jj4r6FFmBi23AtIXj5oXnCvrKgvDoK8aG/Q4PMofI2zZOnfqQXXXwtVXkJtDOUBGEssNazhE9t+VvEkJbP4jdc63Jw0eCEkGkFiwMOp49rTf8HzveSsz0P+9frqmSacWTWtcn2NucM7GpoN6WzeLrLn9LNdwNc/JcMGwfMVtO10SMFnwxo91GLSWUd4hpwComPU058mKZESRT5scL2Y2JfmsWFLxSEOpYlL/hOHQgqThDDCN6bOv9U2UPHSGubdN5gopBF01s+A4uhor3PDA4XHYJqkWjEHRWVwQ5oWQdXZW1Ip5QQirmlArVd0Zhr2w+8iatKqytO/F3HLgwoZUDm24ey8HFXcfZvEcnQ4hqci+FBviSieeBvbDUPUfBzxqD4viKjUs0COJebCDurHcy7nFBI5g7Uf0e+B+lMtMIzKoNmV9j7QoLystj9HEbWxUCNZLhTfjpuQYdpd9rriYI2m+qXUhfsgSE2QLTjcQS/HglyteUNytdXVCm8LXakXtkXXRnX/VyGmEc99/dVBWn78iRhaQvAUA3oBK5OsAIyQWrf4T9oxD2XYx1GZ8lIJ2+Va7G9+NIjxSS2gE+La5uWS+sYLnL2oj59AzpJBEVVXEvQv5igMq/LPsV5r7isxYS+VP+jVCpxtFw9VaSaS10pw+bLiBB+SH3NLbiqC/hH8KKuaZeosipV3uoHsfxilUva8Rg6IrXGxb1/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++) From patchwork Sun Feb 13 19:12:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12744657 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 144C5C433EF for ; Sun, 13 Feb 2022 19:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237937AbiBMTNR (ORCPT ); Sun, 13 Feb 2022 14:13:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237927AbiBMTNP (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 D3047593BC; Sun, 13 Feb 2022 11:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBpDUHPy0jqPLNN4qgJioGfs+4e8HpIHnhURuJX99asZwAYspsEo3aDRugi6dpszzCmo8d4QBqwc4Fhe5SrfA/KIYw5h0tJLhwwdUHapd4FGdTGj445wCNOs0xhqwT+XCbUnNXfhO0sc2WJEeZdp/VonWdcCaJUeiTB+qluUpfLC9A4JgPtaGhnTeumhvfDNvIjCKn+FnSk2+f3X42BCyF/UmEdAG5kPMe/PLQNy6ItcDKv+n1G9edTUC8eIJX1bSqI0cL/rkYdP60GQsqbmYgRS7IEZU1m7UFEhzNJnLj0nmOKRtgtDF/Ym9kl5yjBdkP7psPtVfHsKqwF+ea9Hcw== 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=h5VZeZLsIGqRGKTJuhtykj1JlNQTe0Ojr+G1AalvZ+A=; b=VgjpL+hKSDb97n8dlDz7ni6xXu2YkB209Nc/c/NxKL9puXf/PAnvk3VIhceXW9tWoCRSOB1VNtacbwyLU5j2q/JEMP4kKKBjAIZ+QsdSDSqGs2eyIYucBoc/oJmLhLgaCUHZ8xLAFRkkQXkivJtYq8w8H/1RPE3GHLdcRGbCcyUQYFWzrcinfgu9x7Tf4mQWBgdOaxs0CwXUhFYZ83LwUqROod1QlPWS07NQXUIQr4ZJTYJ/JO8QOKXTBdKqrHmjC9sAqeTn+g2b5CAY+vMsFJZHrZxbAS9tKSY5erw0dnityZJ+MvYg/Uy/s280AUL04vaR2nLNqdt06pAedQt+LA== 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=h5VZeZLsIGqRGKTJuhtykj1JlNQTe0Ojr+G1AalvZ+A=; b=zN0Tkd/LccFY3i/XivnfOy91RQ7C2Le7mu+JbTyaHc62k/LsbP1R18hQtbUCTA2b+Z4u2RMEjdGiUIij4icsdD5MeOT5b0UJwDv75DP11aQKSE6AmhtlHNZDSrjuO2aOT6nFQheI04iJcIZgMAYSAo7gXozOhI7Kc7Ov+A8+nbE= 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:07 +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:07 +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 2/4] net: ocelot: align macros for consistency Date: Sun, 13 Feb 2022 11:12:52 -0800 Message-Id: <20220213191254.1480765-3-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: 3372135a-1ff8-4242-96ec-08d9ef24dca2 X-MS-TrafficTypeDiagnostic: BN8PR10MB3315:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TiU6tfO6bVvZOZK/hnfP3gWGQ3Ug17VDN/3zUTY99JNQf35Nna2BKI0oJkLXd3zZ10mJ+2l3chge7NiE9mgAbHE1sde9pSJ92vxgMjbTYcpFFAI5vnffD/vphtCIZz7d4YJfTSuEUxCbS6oEaoHpvNWh/jue62yjFr4xi+Ek4/AGKQdb7Kejjq7DQvQAGf6BqMu/MzYGH7xXy34on3wjbEt43ZiZwsYklyVz0RiYVYvSp+1tWhyJZ8RIAJ26yqQC1fBd5LcylFwvISRf8A3jumDZfCF0yAaSo1wCLnLxwSVk6FDIOGyjVYyBZK1ng7zBEkEURoRW6yBKhB9yDgdMHDJmSK9uZhahWzaj6tp8up8V8ANAtp/IH8qm4OMV9DWUpyAM57WJAkNdFjajmYdcHGBrAh5vMueekqYoXxjQ1QaAyiRT8TLd5Fff7axVpRK8QQOGvapqpUV/oIMXPhn2rPeH5iTcCreEqUyRcwFBVFyJZ54Isj9tlI3oYLgsmUL7CCm71OLiXI5jSMTS1SzCLSe34XpHlan87Hhs8wakuCWo/DmLt56UlwljirJxkpjPAxX17n+8S171JsscutUcZJhjivipiAP8pEfLMBKW6ORTi1ATmpnBLwKRpsxn2YNR9MO8bsLAj1bfXFFMm8hQqNgsiSIxKA9+mLrVNp+2G5lRYITReEIRzQI1WLDMbXZMvjKRmHnh50thBwPs5TS7AQ== 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: 4xr7Pqb3LtmMBM1QiFvkdzdEoRX2XPuEof+4ke6LJ91tPPbLiYnuNtJNsv9/dQVMQt1smsnO35QJ5cgmRBYPdVlCFpeqh2r4saJ654UqegnWgvxaI6KxZZEoZtVt2FLxV5ZGnL2YFPgCG9ny1wLx8OmD6fHrvaLE0cmyOzUi6oVElqy3wikk8suv8XkiOVSgr+AMBN11MNHFEQnmWNcMyB3dY3Rq9xR+0oIJSzeXusHqPBA2+/992RhYFXnqE23RUTXR5s+ElOUrX83GqkGjr9wwxSVC3pUDGZvhbCgnc1LzKvF/b/DkXZHbJZSq5ndwyRqoI4zBvFAPCoPowjSbgOtvIg2vKnn5PffTRoXBY9116J+1I0+ZthqJmR89gs5bDj4dqY9Q4CcinkYa2CyWqeHSEpXctEl8kXMk408LglKe/LJJYRABPplLIyk7Im4NYw69BkyLsc529Yb/0U+mPgYTMvMUgHmqNGpYpeI9mMaT0x8GIoTxB8uOVgCxyfvajphfUZ8M1CakD1izVAift/uWBYBR8BXdPLNHY/PiaK+/32Tg7O24soClVyGx+w3ZrojZ86fvmuVv0ir0ZjwHR6RxbShkk8YYsR7/hrrHP1i5O/F7DWLdCFQaJ6uC+n+zsrXpojb6qksU0ERC7OFU0vqfdhlFSSDzQPnpoXDjYTqChyiUVDrCHl/BVnGdRfOO/AE8wPWR59CgPnAoMoQD7VcQZW5jeITbWBno+VNXAERQ02U5mzV0hfJ5y2CkCgEc0xXMPXBNLY4vpiAHuJMdjNCAhqaAkE/xhyfhU3NPCB1/vuo0tQt0E/Acc/wIyvcC0LXRtN1wXx3Iy6uiu+FnVckePH0meNElvdkeokcHdnPXeYjtJRRuhnfZfGjcjlWoLLFMuQZ0QdaI90tnEutAZnkb1ZwbmFWq41EmQObqwIXHPcY/iETj73SQAhJ9GVEJ4IzjNPBtgd1h5tIrrLNcF0RxVt72qqzhyRxXF/LYu8H9vgAc2qkYvXRG0FtnX1p07yuxJRGWbIZ4SpMmQBjW68rlK180bEJjPzSammEwSskIk1HPrcz0s/r3fX0sWzpa3cIhNbpoz3C9nveoaMsg9fUfMjieU7V39gEuYxetnPbC78pkjXjImYcrHuriFsxeIm27uF9EJs333GGsS3bnM3WqTO7YgaNkUUhraVDoKt3KjoPIwzQ2V2udRvCCAhW5rj6ErN5nkiqmSHdiVQpKNupi/dtsHNSQHlNU43+9LYvSKPx/rZqHJl779LxTUgG3JB3vJ0IY8OANhQ4jHX8VqsG2scYyAIHyntRj3zintxw3eZokZDGjjyd5tBEYmcXAuS6WMmqNzMCKM8JI5X18mX24YBduOA+8ESlO9SVd/94L1DmxWTohjYCmfR6i/A1ol1oTgnz5bC2QI8zmRv6m85Fo4XeYh1Stz//Z/zsefvjBUl2k2eyWgJCf2IDKdlYwfO+dQ1vrdEFdUr6fHEG1XudbIfOKYxcmmlAILCH4xnOm7fpwJrJdF07MnfpII27f7qRmtRp4kalUGNYe9JKfXqauda2rX4hcvzy8k7HpSkXvyxYl3ciBnw1SHpYvny8lq1vmdDI6Qr/gzWwDpHF3nO09d3ZbDcLqgmx//CMKjoFIni9vl7JE3JyiQGCjW9mFObq1ZGNfLwzZSlj7LB7awA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3372135a-1ff8-4242-96ec-08d9ef24dca2 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:05.0389 (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: I7bEBNJAIBFEiycxDiIk4V2hMID+0FfkHngK5+z1BHfTRAIXzoi1jEFhUuMBI4Bv7PZekwr0F2h20E23NuplEOFRjlgr4OoOe5JcxrvvgtY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR10MB3315 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the ocelot.h file, several read / write macros were split across multiple lines, while others weren't. Split all macros that exceed the 80 character column width and match the style of the rest of the file. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- include/soc/mscc/ocelot.h | 44 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 62cd61d4142e..14a6f4de8e1f 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,25 +744,39 @@ struct ocelot_policer { u32 burst; /* bytes */ }; -#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) -#define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) -#define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0) - -#define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) -#define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) +#define ocelot_read_ix(ocelot, reg, gi, ri) \ + __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_read_gix(ocelot, reg, gi) \ + __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) +#define ocelot_read_rix(ocelot, reg, ri) \ + __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) +#define ocelot_read(ocelot, reg) \ + __ocelot_read_ix(ocelot, reg, 0) + +#define ocelot_write_ix(ocelot, val, reg, gi, ri) \ + __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_write_gix(ocelot, val, reg, gi) \ + __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) +#define ocelot_write_rix(ocelot, val, reg, ri) \ + __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) -#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) -#define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) -#define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) +#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) +#define ocelot_rmw_gix(ocelot, val, m, reg, gi) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) +#define ocelot_rmw_rix(ocelot, val, m, reg, ri) \ + __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0) -#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val)) -#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) -#define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val)) -#define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val)) +#define ocelot_field_write(ocelot, reg, val) \ + regmap_field_write((ocelot)->regfields[(reg)], (val)) +#define ocelot_field_read(ocelot, reg, val) \ + regmap_field_read((ocelot)->regfields[(reg)], (val)) +#define ocelot_fields_write(ocelot, id, reg, val) \ + regmap_fields_write((ocelot)->regfields[(reg)], (id), (val)) +#define ocelot_fields_read(ocelot, id, reg, val) \ + regmap_fields_read((ocelot)->regfields[(reg)], (id), (val)) #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \ __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) From patchwork Sun Feb 13 19:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12744658 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 AB30DC433F5 for ; Sun, 13 Feb 2022 19:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237993AbiBMTN3 (ORCPT ); Sun, 13 Feb 2022 14:13:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237941AbiBMTNS (ORCPT ); Sun, 13 Feb 2022 14:13:18 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2130.outbound.protection.outlook.com [40.107.236.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C7B593BC; Sun, 13 Feb 2022 11:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y4C8VSePQBYrAeNL41t1aNly6xfji0iC2a/JTySLjZhjXMvfXK4DjEZFTNEvkzVPd6lv/M5FgKgRQBAFYbaBW25iVWsr+cEqTIFysS0cWVvrtCPfIyusvUkUOpNCHBeiVmIDszIpFP51QV7qlIk7fURiTgJSsShSrgGlotZqVz5F/rbR0LNEVJRiYre8MFyx8TyhnpL8z5HsqLNiA3oZT4hbl8TKv+133nrSvPUMXvkdLRujSJS3f7IkqSJvBhHU6RFDJpDXgkQDqstj52mmXGzgi78v43pI/Ts8MoVfKaP0kjANfbpq0ULkQzfImf8dmyoU7cY+WQMpqOvBYt6xvQ== 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=/nv5AjNp/bsPNTC6KiiFtIi7/+Szne1J4+M/2V0nzN8=; b=NFhk6mP7LGLDiVtTqM3UKkXSpk2nOLi20TmewCz2i/LhsKEURQaG3zK65JzL4u8c/yAs9eeEmujF8TjdzkqVyUPPCez8bpxoAOw3i0HSilxROqEu6Dq/o5vcoweQLSFnSDwCdP7Vqx7e3RxJ6r1uG7x8c9ZiiYP1fPILvJ6eFavAq7XFhZ9EVidYxNHeAYF+n8sHai/3GBqZl0Xs0FSALQ2AGR+61FGIkiq/Ha86SHyqo5wa/NBgqtqLzssVG29N0CwNp+ckHxYZCxb/9re4YyAFuidVW0t8lszj9+9BnKX3ZwtdvJx+py+5VdEmp/3xMMnQHAD3CBptaz+Dbf783g== 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=/nv5AjNp/bsPNTC6KiiFtIi7/+Szne1J4+M/2V0nzN8=; b=mKAF4RetFHvD3js6GL95XaijUEJgi8bFRJaqCcrWXQ12nc+PP5eG8w6nrOavnbsFQ5NsMApuEMU6vloa+QSaI3XEyWjLvVOwHVRXG5vY48gHQDcv7c/PbyCxxPxLV47GvKnrJtfCEDAqctzQHRZJTtlw8fEip8Ulqj1o+fMSCNQ= 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:08 +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:08 +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 3/4] net: mscc: ocelot: add ability to perform bulk reads Date: Sun, 13 Feb 2022 11:12:53 -0800 Message-Id: <20220213191254.1480765-4-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: 71411400-7bd6-4783-f53c-08d9ef24dce2 X-MS-TrafficTypeDiagnostic: BN8PR10MB3315:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dYepqvpusFGjj4HoyFxVfDUBf7nR9tuFP/ZnU1ZRUKkD5gufd/pD6oQ72kEQzcO5Z0UmxphJzUvKItoMRnnnGmuuhaTKDrDuD/RUVrFoM2AAjJTw4USefoZibYOdxNsJgZuW7/8eJSS6fWkOwdsTIOizBU4nL8BNZc3Fb1A6x8ILQ+O1OaomEq/DhM3obb2Q7Hde4QZM8DbJ5E8GDqplbg0khkPXnMF9aaKB6JboHF0q0k65d28cJ+OkVGPaJxp8Dv5mMSnNUCbZU2cCXUrpVqlFXEi05FY0x3nYlH+T0MSPOwT5WrXEPvH1gbLrmNSPtq22OTthXSpwrlTYZNdP3qQydx1eWhocscl3BEmnWugpPShHIglLhjqu6/p03oQMBAs2/m8w42QYyScgK2tjjEsgF2RmEqbVoqCETN7YsaYtgtpJlwDmEYWqWqYLdVG3VN7fcSSs5gSgtmJwSRnUBwwFja4qbPYKQYF37YDkE3uKY5BWFY4SaqTjdQMSC5ay9WmpHi4rN9rAheNz3tDb3H2TjaAL+HeIN1eiArIp8yBvZkW2ZjN95xcfM2c7Urj3APK9844Gc4WU0imNfuQu8er+mJmP/l+3glBIpTKaDxRMOArTx4NGiv6oUCM0TSbLfhrGpDvNl88VxDp5RXrQ8JOt8/9cBz+wWZwOcgzE7AL8TMoQE4yPN/Pw42mfLPiG+/3920fF6t2qYe673m6gZQ== 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: EUZAwI4yCEEIZKuV5/DgwQlPPAuaxNUsVM9g3dDNjFqct0/FnY57Rhig+ViSOjK11kvKOhGfyayXXOGG80vpwIclXgMJHOWWBEZ3hdO446VlJ+WZblOjh4YttIdWiaUTC++DNqeIfW+yk423CwCao7T0UQX4jAVchcwAau3iAUD14Cx3rUhqV6eNYJOhg3hcR1z8MkqhBpGTL0HmLW+YzpXYc2RFeixqGuMpERhsV7hvjnem5AejV6ApjRWYTJ1cN4HDmyaLKqMH+etvM8S/AuFRuFbvCo/NOYSgXFy7QwIheaHKm9kWCNszDNNejhjlEaNksX5uoR7iE2daPjIPYF4syEnLaeEuiP2DKOyyvm+7hUWf2YEW5z1OSaD7yKRvRbhotMaAOplYEfwn3E9y5R5sBftPKktu3nhuFSIMuf+8/AYIJ9/d+8fLllzXuSNBMef+KxpN5r/C+WLBAJfsvtnP5cgDnKXJGEEhrRFuEH3rfdy5dCtND0i6BKJg/june476lNNTXendGwxhCQG6/yIhRUOREi1TMBMznSwlg5MVqRx2/J6lo1j0eRk+2CcYQ2bFU+CUMlN/BHKKox5yphrmBxjZk2v/BwsNEt2yXSgqk4LttOVPcakCGtQLeFtEkNTqDfKKmJ+lRhQIv2NC5H0uQYGK3O/kLbaVko7HCtARZyGVQebT2yki/IQ3R/b9liRnaM8A8dJk6xRBVXlvINxYMrKluzEI/13r/W2koPe7sCrzJl5Wpyop+FNRY9JbQbp8Pzi5lkVZ55dmVqWNUZcnoU0CgRA5zG3t6PWc7HQVBtKKKCt4ILp7bMk4gPNMXDhNTg0Sj+tUTCpm9Oio21iK0tD5PM8tnxtz4wMFVkonH4WXXUuCya9jXoQk3fR6lD27nvMEW2g9nIDxChPSdQLTs1hwhnWAGfP9NQ8CFObtIrLtv5Ocr6nLoIKmgOgNJawom/qcTqsBW8ql2Ix1LiqcwdWTkdE9kLBch5BTIhXZvcj2BU4amwjfFS1aFsO00lRIipCb7R6rn7ScByAMDrMGR57yDtcJ9HPpVFcbZdpsoeHqfS1oDtdrPZc1GYSUGV87g8BuB64yIjSAGRIi5pUF+fP4gSdR10w/J16iUXzkCqHsC+Ymw5K3kd3XBKR59jzPbimNR6sdcjGZ4mz0gczzMcxwe+AKOiWNQQpHD5K8BVlEVmYuF/IgkZV2ODjAyiumi3QuX29EvJr1Idwel5wpelnV+ZCNLrY2laPU1bPzXLUQSILdYXwLbiWvYAZflC6ikuCOr6jC8joBx677iF06Ka7pJDS9qCzMNhAt7yeIh9etvgi3W1TcGgzA1v29COjwIPIjMpkVxVSgpz4WPOYORXyPnVeg6y7Zvc9GQcbL/kUzhHJ2OTaUvWscMFisc7fx4DKl4sFMwRA4GyrA4p4ublozpd5XhZ76GSqHgCt2+gy50Gl4EkD2gUkmS2THEn6XxRPNaUSuyg3V9jQDT1q5AN75Wses4htn2JAwnMRn4VzzmmYR8U+mgeAyTg+sqtGkbGNSV/YEoPN9kp3gFQBjG459xDeChHwrlOJBT6C3fyzfXxB03If/BUdRem5dcUzzN+Im1VBLZ14UbzdctKSk+E/lSoDxqZdwyCVfCfmCEbMKJHdgw/KrxeY5h3DCj5ZZhkA55z8ppLp4bpOLEQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71411400-7bd6-4783-f53c-08d9ef24dce2 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:05.4452 (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: h41jt6jzMSKJwo3uIUlnW2cKJqo542SjIdKCs5cZiGZlT4TrZ/F/KsOF78jHdnKMY6f6z0awT03dcFSxQDVumP+n7ifix5BCPREIG+Ieo+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR10MB3315 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Regmap supports bulk register reads. Ocelot does not. This patch adds support for Ocelot to invoke bulk regmap reads. That will allow any driver that performs consecutive reads over memory regions to optimize that access. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot_io.c | 13 +++++++++++++ include/soc/mscc/ocelot.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot_io.c b/drivers/net/ethernet/mscc/ocelot_io.c index 7390fa3980ec..2067382d0ee1 100644 --- a/drivers/net/ethernet/mscc/ocelot_io.c +++ b/drivers/net/ethernet/mscc/ocelot_io.c @@ -10,6 +10,19 @@ #include "ocelot.h" +int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf, + int count) +{ + u16 target = reg >> TARGET_OFFSET; + + WARN_ON(!target); + + return regmap_bulk_read(ocelot->targets[target], + ocelot->map[target][reg & REG_MASK] + offset, + buf, count); +} +EXPORT_SYMBOL_GPL(__ocelot_bulk_read_ix); + u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset) { u16 target = reg >> TARGET_OFFSET; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 14a6f4de8e1f..312b72558659 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,6 +744,9 @@ struct ocelot_policer { u32 burst; /* bytes */ }; +#define ocelot_bulk_read_rix(ocelot, reg, ri, buf, count) \ + __ocelot_bulk_read_ix(ocelot, reg, reg##_RSZ * (ri), buf, count) + #define ocelot_read_ix(ocelot, reg, gi, ri) \ __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) #define ocelot_read_gix(ocelot, reg, gi) \ @@ -800,6 +803,8 @@ struct ocelot_policer { u32 ocelot_port_readl(struct ocelot_port *port, u32 reg); void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg); void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg); +int __ocelot_bulk_read_ix(struct ocelot *ocelot, u32 reg, u32 offset, void *buf, + int count); u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset); void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, From patchwork Sun Feb 13 19:12:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12744659 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 ECB19C433FE for ; Sun, 13 Feb 2022 19:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238012AbiBMTNa (ORCPT ); Sun, 13 Feb 2022 14:13:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237946AbiBMTNS (ORCPT ); Sun, 13 Feb 2022 14:13:18 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2130.outbound.protection.outlook.com [40.107.236.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1862593BF; Sun, 13 Feb 2022 11:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxFnbPxCm2WYDIZFmye2bah4wFkUE+gxVXGSSoXmAz3hHUKuQFrjCty6QdJlqdQqw0drtzvQA74wMGvDTbsIz13owh6rS5hBrMsm8rpogTfOEdurzZdcpLyoBV6ED9MSA5OXYX9km97i4WgOMSSU9ccMBst4jYBORHn5FKompTjQyp92vfOxxrlt1LR5mqusOubGJdtqtUrL1JoI/yKTALADSnI06xBzLY6kjAbL0ZhxcEWgksPpi0rJXRZVCVFGvdgPaCX3DsLNhx/xKg4YBL99TmueWBMODvB1i5ZLjM+SON2QVe6pM2IUTNtMMDa+YtyUn2Vujn9Ufleyi6NMnQ== 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=KZHj/DHgAuUXu1C0ErXL6Y79QyrspA4UNH5Q+pqM660=; b=i0euhPkgLu7gJuqnoMDeY+A0pLyDR2rokSusFAGfq3n1SAFVU2MoRiqdQMPaPe+5z1qoA4ohRItRKIa/FW3monOC9mFVmkEM0EYbYbXzHbo+fJXI2c994gM7mBN8UFxeTRF3jMrarUWK5MF391P7HvL0Gfj11gn3FUbsIqgaCqutekyMVA42jPAo2C7gQfY8xq+TXSscq/HVgp5UXuZZLGRyK6PjRR6UNFn+jI77kNV2NbPuWUOAYsguXwMCIqBmxUKOT+LJfCzmk0ojeG3hxh95NBsoIagPGxhkWodeLlDiuec35cS9RTvZtmUm5DDit/dAGBSzSVjd4ff3bOuOCw== 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=KZHj/DHgAuUXu1C0ErXL6Y79QyrspA4UNH5Q+pqM660=; b=S9d2ML11NanNWhZxHTOISotcTeTilBjAu4gvRs9kmEr1Yn7w+4XoDnz6sUO/26xhio2tp5t0VAb3JZ54TsbM3a919L6p1sGH+PmCxFyAG32S6v6SSfdB7ImV/v+OSuylVg0i76YvyTKyM76jCYqUsJwgUnZ5wSYMvS+k6dbS8Cg= 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:10 +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:10 +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 4/4] net: mscc: ocelot: use bulk reads for stats Date: Sun, 13 Feb 2022 11:12:54 -0800 Message-Id: <20220213191254.1480765-5-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: 5e1b6391-d6d5-45cf-f144-08d9ef24dd20 X-MS-TrafficTypeDiagnostic: BN8PR10MB3315:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c7wElJkUaqwcyVUa9NdWbb3j8L88JR5YXz/DWLFEtFu1NP+tVZFDqT8EbKZ9OoERh7zBrjwGUPdtiD9fus264NJcMGcuZ+XilmZJFpnald0A7nekpeVW2Gi0JJwavcWOP3iMi1XjeeX4bxolYDHlquZYfe8B20kmnfqVAR0SCNpjbXkOUYEHCdInP9CuQXe7mK7TLT/rIOXkn7Ad8V6wSDPIWu7aCsoF1Mxlg+Mq3Gl2h5iUDRbCl662rMe+vGRKC8O5rCZqPBw8Zc/4/0oHdMrECm2C6k1W7lD0SifJhEQCNv5M2+Pa4x+b/1lpdvY/1e3IdjXFXzHfZwgPjRW18PFcPY+DT2AxS4BqEyKKylKj+zo/Q4wUsBkJCU76jrNyDljD7YYmflWwhU3pfbmndt8xgVu5F01Ror3Bw8dR6s3CNViAc66ZcS9sutyA5fCflcFZ8xE5kHeF57gTWLpneC3Cb1tudnA0/qfJNAUBWOVYLQY9a22ADffdUV+ioaced7izequQHoH5swpxy7rBcvVu03AfiKD2XXXeZK62+0PbOa0Kvz/OzQBL6G2w9nLQfYnmVtXyKRFlTMTPfsHWx0YcLJAloJpW6v93kYIvTl1rztoB2bfn8bsLRpKrcJUwhkOHIoL0MUtqgn1z0aQO8aqI0TkvgOsfb7qGW+zaSBwnDgcTVeScGGJmaZFPXCEe/XkY0Rdsyly5YmzmJEWYgQ== 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: Ns/Eumri1xPXnTpsJGAvEsrpLxmykYENGYkusdWoAa3EzgIirZTSBKkjV5FVVTq8+NwYXeuqJ0v6rr325tZ63EC7lZQsAxGI41zbrsG0cMDgvxZmqLaSA/9OLDH/vxeVBZy3WfRmuyLQOXFUGkWSJjKYNQOYZxwUPbv0sv3uIBWLgAWWPq+WbW/RcooFpkVU+6cmdRGIrhKeKSC5Ma0a0zNe3x6iJfI6cOKOpJNP7sGJdU5pYMv/VKI0g4FrpTShBdNQmFVm1T2Df7b7OT1/03VstVYN5N/OmLbAZtA9DydddMeeFnebVR4rdqofgHYaXq8EbVNw5G4da27bNJFVIpeGWBAnJVIgMsP52n9PbsUH4Bt0h9M8aVfjAkMBsVWi515gKb8TluD9Y+ms2tX2l+T+dckvdmHP7DB0rG6gWN9ULXSaRV/sJNLzF39St0+ojUzmC5Q12gx7Bin3mcxnW29IOs7pKhiRpo7u6d1IAR7tZAONS2r+a03p4b844LH6OE9uRGqfOfAgENbczrdRrQap53MEzbQqk2/seZyOoV34vPoI4QWoK+G6P0HZfCB8bqIbyaK+XzMAQUt/lCiZ3dPGv0rxWetqaNhf7qAC4Y0e4WUCyLY/KV8ouwBcpVdQF4zuFL0zUOfIctWj05vy3/vHUcOQgjg4s+AGOso8B63ygWDSbRsuHDLCujdLfk6cKRp1W6bCfosQV/zn0YTWS4EKDqAjpvWstBKPiVkPfhoH/cd5UwHvA9/kboN7pNx0zaJ7KICtUDb1k1t76+ekbaMwyeAnEyZxcFwVv0vYYPvOlL1JpPFCOKO1f8kEE6Bc88CHe+wE/hUX2jgHPwmQu3oa5rCdQQ01nZjzMmBFKxB3gSgmGNCTaXUsIDmbvZV4JDkWG1XfkwPwUWZEp39wicHQ9qB/+g1uzjEDCkpWTaS3xk/CSCbHUu3HAxiFkYB25FOyhhhukQgcAB4enhwSdZxKJL7bezJmQ9AvJNoulCNaAKdRz45ZZwb/0ykBZ98TIVErvUm6yDrcTztwZaWl+MqtuGGVxEI01Htl3WvNldv8WXBsIssTRiC/W/DS8XiNJ0azV5dtoMzOKQme+e5x7rYPEyeQHydiClixHzpAXxf870H+0t1w9gFyCas4ZFluBKZY3n8R2dN1JphLqcPAa/PP69A4RVzPtPgrXTeuaGVDyxM/3F/MDlgWLHX+OHz3JgEvBKf50xtYAWvdRJo+b4Xhi8MpyHSxU1Nks9IwE0vtSN4QQ2URJq3KjYmdI/4nC9Wpu5X+4hz5/WnvTIv78xVkkEU9HTGtVKm9orb1tLUwg2zw+QXZHEHRvMMzTybGYnWsRwR0A5fQfTrbIh2YzvyEjwRLSyUP6GJfwYhYk4YDg1pMOYwIs/RnCiZTY1PMGJxT0DcqdUlTnJxFz/9gjACws5rx22ZFu5DNgsNu06knVTfzKxA4Hs/QCGDL1vD9BibRoteK5HzRvSSRJzhN01slo8zGFsyHVMeWjmpyyZAcM+WVTLSBXEguJOoP/FfqFoexHMdHQox29MU6AewJ5ycyTTiamXL5XvhhJdPPmT+lEdXtn9mbeDObc0W6BMWQ9V6lEPL6iRf+YPhXBvGR25RJLfdcfUjHiTMZmfM/uaa6mUKCEgx1k7JJhOt6tFoMxKTnCXuorYAaqe5Ce4xqnQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e1b6391-d6d5-45cf-f144-08d9ef24dd20 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:05.8826 (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: jtMI1/AQIR9ZjmHxa5d6YPu8itlFcj06T0NfeHKAN0fGVnI2955MeLIwvSdjlkG9jpR9UxIXiswDIFZO3fWaRJl9tPMcqFC9SkNCQtm9+vk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR10MB3315 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create and utilize bulk regmap reads instead of single access for gathering stats. The background reading of statistics happens frequently, and over a few contiguous memory regions. High speed PCIe buses and MMIO access will probably see negligible performance increase. Lower speed buses like SPI and I2C could see significant performance increase, since the bus configuration and register access times account for a large percentage of data transfer time. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 92 +++++++++++++++++++++++++----- include/soc/mscc/ocelot.h | 8 +++ 2 files changed, 85 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 885288eb389c..637fd79402e0 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1746,25 +1746,36 @@ 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_port_update_stats(struct ocelot *ocelot, int port) +static int ocelot_port_update_stats(struct ocelot *ocelot, int port) { - int j; + unsigned int idx = port * ocelot->num_stats; + struct ocelot_stats_region *region; + int err, j; /* 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 = port * ocelot->num_stats + j; + list_for_each_entry(region, &ocelot->stats_regions, node) { + err = ocelot_bulk_read_rix(ocelot, SYS_COUNT_RX_OCTETS, + region->offset, region->buf, + region->count); + if (err) + return err; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + for (j = 0; j < region->count; j++) { + u64 *stat = &ocelot->stats[idx + j]; + u64 val = region->buf[j]; - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + if (val < (*stat & U32_MAX)) + *stat += (u64)1 << 32; - ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; + *stat = (*stat & ~(u64)U32_MAX) + val; + } + + idx += region->count; } + + return err; } static void ocelot_check_stats_work(struct work_struct *work) @@ -1772,31 +1783,40 @@ 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; + int i, err; mutex_lock(&ocelot->stats_lock); - for (i = 0; i < ocelot->num_phys_ports; i++) - ocelot_port_update_stats(ocelot, i); + for (i = 0; i < ocelot->num_phys_ports; i++) { + err = ocelot_port_update_stats(ocelot, i); + if (err) + break; + } mutex_unlock(&ocelot->stats_lock); + if (err) + dev_err(ocelot->dev, "Error %d updating ethtool stats\n", err); + queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, OCELOT_STATS_CHECK_DELAY); } void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) { - int i; + int i, err; mutex_lock(&ocelot->stats_lock); /* check and update now */ - ocelot_port_update_stats(ocelot, port); + err = ocelot_port_update_stats(ocelot, port); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++) *data++ = ocelot->stats[port * ocelot->num_stats + i]; mutex_unlock(&ocelot->stats_lock); + + if (err) + dev_err(ocelot->dev, "Error %d updating ethtool stats\n", err); } EXPORT_SYMBOL(ocelot_get_ethtool_stats); @@ -1809,6 +1829,41 @@ int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) } EXPORT_SYMBOL(ocelot_get_sset_count); +static int ocelot_prepare_stats_regions(struct ocelot *ocelot) +{ + struct ocelot_stats_region *region = NULL; + unsigned int last; + int i; + + INIT_LIST_HEAD(&ocelot->stats_regions); + + for (i = 0; i < ocelot->num_stats; i++) { + if (region && ocelot->stats_layout[i].offset == last + 1) { + region->count++; + } else { + region = devm_kzalloc(ocelot->dev, sizeof(*region), + GFP_KERNEL); + if (!region) + return -ENOMEM; + + region->offset = ocelot->stats_layout[i].offset; + region->count = 1; + list_add_tail(®ion->node, &ocelot->stats_regions); + } + + last = ocelot->stats_layout[i].offset; + } + + list_for_each_entry(region, &ocelot->stats_regions, node) { + region->buf = devm_kcalloc(ocelot->dev, region->count, + sizeof(*region->buf), GFP_KERNEL); + if (!region->buf) + return -ENOMEM; + } + + return 0; +} + int ocelot_get_ts_info(struct ocelot *ocelot, int port, struct ethtool_ts_info *info) { @@ -2809,6 +2864,13 @@ int ocelot_init(struct ocelot *ocelot) ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6), ANA_CPUQ_8021_CFG, i); + ret = ocelot_prepare_stats_regions(ocelot); + if (ret) { + destroy_workqueue(ocelot->stats_queue); + destroy_workqueue(ocelot->owq); + return ret; + } + INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, OCELOT_STATS_CHECK_DELAY); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 312b72558659..d3291a5f7e88 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -542,6 +542,13 @@ struct ocelot_stat_layout { char name[ETH_GSTRING_LEN]; }; +struct ocelot_stats_region { + struct list_head node; + u32 offset; + int count; + u32 *buf; +}; + enum ocelot_tag_prefix { OCELOT_TAG_PREFIX_DISABLED = 0, OCELOT_TAG_PREFIX_NONE, @@ -673,6 +680,7 @@ struct ocelot { struct regmap_field *regfields[REGFIELD_MAX]; const u32 *const *map; const struct ocelot_stat_layout *stats_layout; + struct list_head stats_regions; unsigned int num_stats; u32 pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM];