From patchwork Tue Jan 25 07:15:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12723361 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 9C787C433F5 for ; Tue, 25 Jan 2022 07:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442662AbiAYHVE (ORCPT ); Tue, 25 Jan 2022 02:21:04 -0500 Received: from mail-co1nam11on2118.outbound.protection.outlook.com ([40.107.220.118]:4612 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1443677AbiAYHQS (ORCPT ); Tue, 25 Jan 2022 02:16:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XdaaOvJYiOj49gdDRZWeUW6y/3TV9vdH8D1EAc3nExC/aIezUyru4PgZi+jv6gUVqhsk/DDxpLGtNE03hTkUfD8vOxGyjS9EgIe8WyQqElLeeEgcVLpXoVXc69oRC3LYKskAvEZVg9bZfdGTR/+uKmJRXf0OyZ+zDnSGaJEdofLGEUcdSMheF4D4AcNZPbj/pfUyc49TWxaolgTK0Htzr+WD695YV0k479ldJiEKsfyxJ9a2/BGPrj1qvo2JrkU4HvXjv6gCJ3xQMCQukAjxoJNhdCn0gmIK2gBrnEHuGaZnCIApKF7ccOzIFHimWyGaMc3QGoPb9sRmWYFls8mBOg== 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=mQDF4oCS4oyLJbH4+gGFq/wxc013Q8C8cVc0ZWNaAXo=; b=D0NRkBZ8wjdQAEg+qYamDAaU1gWcDzqIvd82mb+QF+8jLzbWpfOC6rMVIEqovz5SINFWU68VCbHkemLIXNlalcE5iUnmHBg2ZootEibtNJkg6UqeTtD6Nsvpi6r8qQ5cuzVO/Jo6AQKpgswFqJlUAxU1MC31l+fTIN0z5Be+sDvO5Q27C+9uoojmredYxz3I6Nm6cS1zMyDspeFSalSprAzJnKqedIPgehWT09Aqq1QFibulsCA/dG8UyQcQbeLZY7Tkhi1m9vnAAshdlUcfslpvucN4GcmfqS2NiqJMcDdI3DJxMurLMnvz3Kge4dWQre7aey9Ikw5xCilLIBj4kg== 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=mQDF4oCS4oyLJbH4+gGFq/wxc013Q8C8cVc0ZWNaAXo=; b=D0PP4/2FAQz3LEI7BA3XWqRexOYPBlu3IB5YkjT3Tw9aFSVjiK0ESFwo2FzKjKsJOfxoAez+SNhb5jv0TLdwEZHOkB3hBM0snhf9V/ogaXjKIH8Y+SIkon+KyAqM6ghV1IKrxSzPR4a6noxbUkunZ7iZt5Og7d0Y0TgaSWY6iEE= 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 DM6PR10MB2538.namprd10.prod.outlook.com (2603:10b6:5:b3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 07:15:43 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f%4]) with mapi id 15.20.4909.017; Tue, 25 Jan 2022 07:15:43 +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 v3 net-next 1/2] net: mscc: ocelot: add ability to perform bulk reads Date: Mon, 24 Jan 2022 23:15:30 -0800 Message-Id: <20220125071531.1181948-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125071531.1181948-1-colin.foster@in-advantage.com> References: <20220125071531.1181948-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR20CA0028.namprd20.prod.outlook.com (2603:10b6:300:ed::14) 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: 93ed2847-8f81-42a7-6591-08d9dfd27f7b X-MS-TrafficTypeDiagnostic: DM6PR10MB2538: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: UwyfB7bc9HWRE5uXAYhclfGLk3oGQO1omoL8G1o4vflz4cxGas8plmQ7CA4uiRVgfhmrKVoI7yLUUR9Hk8gkmZ21q1ZXCos2yJ8VL4mX0JwOa7LP7anopfiNDy47hO7VgUX4NI+Wt7CdUKXnoBEfyXAQwWb8Z4kjwxe9Ya5UyL113QFLKY0CVfVxdweHXycjL5Hw+sZUYdXUuD0eFO6AQ8HnMZe4ni6rkMwefkB1QDLNpk+rTwdZ2+6RZkowh8njYwuC87VHNpPUN/HIx6HQsQWIkoc0r89xF2sEl+jKxeTLTK2deM4WWCH1nryMPbGxbM2kb4WgIyRZx9PH+2pI34vLBDf2dKYucMsP9PSXfi1ZlVH4xQ5R8Uh/wjXs5nU6JN9VRGRoYWzk26WGj9fZX+47ztLfqtYbmrIVA3yvgnEhOHDJpyz4WpAKNa3hH0E0o2FUoRfIiAhGnguCyRsdwPRJ4H5c3D/QP1UoyGo9eRNOBWdc8nlLKM8yZaUDe3eJcKfzf4P64ezxAFEibvaIbkxdETCtKz6cqPtqDdYMyYakyrMKc9WV3Zej9UFEWfiqB2UWTVeAVtkVRJdulJV9SaVQS9cMfZvn+TakiUhDCVl5SNqNA7yDGVnCf1M5FKhZ3emSq4y3eWlzahkYL3U/S5+JEzNseEEq9aTUazO6ko/ScigcmefS7wMGHxaZNdC2c8qYhhEfJqi/f9hZnRCkSA== 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:(396003)(346002)(376002)(136003)(42606007)(366004)(39830400003)(66946007)(38350700002)(6666004)(2906002)(8936002)(36756003)(38100700002)(508600001)(6512007)(2616005)(8676002)(5660300002)(316002)(4326008)(44832011)(6506007)(52116002)(54906003)(86362001)(83380400001)(26005)(66556008)(186003)(66476007)(1076003)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f9+CK+Hl77m5X+vu82aJqu7CwmC0IZJaJmQjd19M9JRrPTg15KeYZD9T7fTQVRVvqa9M7l8fhZM8wTSD0ZGD87YAOsaiKpwUtc0zh/PjcjBRSeRcXx4oV21DLTNVFrOrRZPw4+l2ih03KGaDdFvQ3U3qDL/Wz/apKIx+WzSNSHOrlQA07jVNmoYli8t3wRkzDNNGU8k8MigGltkoJeh5e3jUC/DP5DeHostC0u+GywcM+sGVSm2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XCL50g5ct1n+IGkckaPuIGL1eg7p9V7x6kxL9diYRUHaKw8QkxJTreViZmH1PbOsq+WtFHl5grxL7SCPB3UngtQX+Nv0yYe7bUJ+mkENQiZdnGdApDeqQR8DMOKturiL07hRe5HmTVMvTT2ejF+P2g2tpgCLqXNZa3mIl9zukx7sLl/LC8d291pIcNkxN7IrM+Xsr8n0Qj1LbeUNCShyYpI16NcwwIuRtlBTBo8DnM1BwHBTkUFptR+6VhgMrVh/ZmewdZd4YkHSsK2CQAR3hLQ8eF5SL10OlvyK3r5ooSilIegKn+uXjAvQ/8Mp9bV6BiM3T4JIlC6sXp5eCW8GNpZtaUSZbi1ihbFHGKHAgbeHcidXtSLdwaY= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93ed2847-8f81-42a7-6591-08d9dfd27f7b X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 07:15:42.6586 (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: 9Scwc8LsM9dT7UPtJWX6D3MSswX6Ic90MB63lmD47XTLi+kstJwiwafgPANZlvl11cKe+qdizsitL539PuMLWbNbCcE+qEHdWPMPmLpca5U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2538 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 --- drivers/net/ethernet/mscc/ocelot_io.c | 13 +++++++++++++ include/soc/mscc/ocelot.h | 4 ++++ 2 files changed, 17 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 62cd61d4142e..b66e5abe04a7 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,6 +744,8 @@ 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) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) @@ -786,6 +788,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 Tue Jan 25 07:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12723362 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 ADC6DC433F5 for ; Tue, 25 Jan 2022 07:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443330AbiAYHVQ (ORCPT ); Tue, 25 Jan 2022 02:21:16 -0500 Received: from mail-dm6nam10on2091.outbound.protection.outlook.com ([40.107.93.91]:19424 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1443734AbiAYHQz (ORCPT ); Tue, 25 Jan 2022 02:16:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aH9vpVOzOGrQdZ6I9wYZxSCITvtdBRRUAClLWZCOqlX2+1+VImIw+q6pNh3HgkRM2sm2mihUs8o9r4QdPCsta+De8bEU+oYglOT9kZ67XJ2AHZ9kgN66nNReikLmkAi8wdDupLRcfGKBwcalQ41zV3B4Q/yL4TsaRS5kixUw4LRQoTEEdLdP//sDf3KEeBAU+XZCRtloSIu4FIu14f42m8gu4ijTdcBkqShy0cXwWSqFKlLzVLUAA6U+ItsMkYixYxCNsEJc3jw/feOy7vcljBduYuqV4OwOt7fSelCoxLPn5Nr+CnkumOGuzztCatjX/Xz9neF2/RUvMMdltyRcnA== 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=G/xZGfgHv8igdzdDkVnlH6iolqtPYJqmenLJ+1BBxsA=; b=SHV+X8Gb2Ud3PChSu0R6X4sU7qXNuZ6pPoX0UEP/0JDTCgJYDNoCJ3MPRNCwyUOL5UJAOHeYKt9PxZ+ao+JTrpqLvjpGSuT7Mud3zI2tz0/ATkShmZsvII60K7/sDVlznKcq9g349kKn+p+Nv7J4hML5+N2vO0nHKyhPxX4tYZmWj9mGOgPW0KK5U4IVnhPnRJ8YysiSGzo8fkXA0oyQx5fqx9EKpPSH8dw68CghMfLoRfeX9l+ED758/U7BUiznkIpWHLQy8SKTqCk70cGm2h5wr0SOIeCVtDeXN9F8mOqIhwCugSKeL1AhI/RLBdG3zS0ssK98guMz5rbBJ+rooQ== 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=G/xZGfgHv8igdzdDkVnlH6iolqtPYJqmenLJ+1BBxsA=; b=KoegP99OXiWHjcaPAkbkaAIuM0CvKwjoTxVBcKMlO4k5euwqzuYQk5oW1/UYc16NsunnShO/fkg0HCbToWgJuAfgaR/fFPME+bWrkSdiW/+/I01fnMjyFf6xsJmQnSbV5A+7H/ekyQl4Z+yfk2MTvyF52CB8vhhIPCBHJ/1gFPc= 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 DM6PR10MB2538.namprd10.prod.outlook.com (2603:10b6:5:b3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 07:15:43 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f%4]) with mapi id 15.20.4909.017; Tue, 25 Jan 2022 07:15:43 +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 v3 net-next 2/2] net: mscc: ocelot: use bulk reads for stats Date: Mon, 24 Jan 2022 23:15:31 -0800 Message-Id: <20220125071531.1181948-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125071531.1181948-1-colin.foster@in-advantage.com> References: <20220125071531.1181948-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR20CA0028.namprd20.prod.outlook.com (2603:10b6:300:ed::14) 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: c142948b-3569-4d72-740d-08d9dfd27fcc X-MS-TrafficTypeDiagnostic: DM6PR10MB2538:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EyNN3k3ajn2OPs1P0Ty+aGDyjn+dVpcuuPOGoyNL+YFu45ak5uxfcI/C3GKmnJ5T3mLkn9RYRzllJVxaoEGHfrBEgg2bIXTACVv5LExQVL84puL/eynnnAh0t92/aNtrbCseb3oMgMrPH+wcNCgkaSOirwyl9VxN4CTtSBILmAcMeJ7jpWwMQhVaDI5mJyxfH7/C/MWxN5LWNVVE4zd0r6HkRbMi1wJzqnGnRgjadoIEXJkoTZy3rMeRcRjGaREZQDXaZPYU1jGe6iQyuD7QJcmfaTLC7ApS+PdXPwaPXCCOCL8YE6uM8GPnWolKPLyCQYu6NRoUcmw08DmKOlW8/nHjA7dNM30Oh4836BQ0QC5+7CYowAsxW0AybYZdA8sR1itHkxJYgmVUsPJGqxDEZ7iEpd3XsFpafl9TFE5gntK2E3x/Cm9+pzfslHn/1qvQXil8sOKq2v4Hjno5pnaoMOqV+oxDOF/gesTNUL8S7Ymf8j6AgR/RJghHYWt7xKoix7KSU5oC2hFmXKzY4PJA2k5TH5Muke1o3975gdTjNZnRFcaNm/To0e52e9pK/ap2AQbpuLNOPfhIPdseABOp4Ce+bCd37ypnHGnpeFBAqaVfughDfhD53Aj0rrWrsikNroJB2v7DTVqnC4jv5/S3n4T3sVDGZt2iHnXUDVIbxXxrENDlHd1kmeMcc4sc5OF3Iqx6bTVSqwvDK8WyjmMRJg== 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:(396003)(346002)(376002)(136003)(42606007)(366004)(39830400003)(66946007)(38350700002)(6666004)(2906002)(8936002)(36756003)(38100700002)(508600001)(6512007)(2616005)(8676002)(5660300002)(316002)(4326008)(44832011)(6506007)(52116002)(54906003)(86362001)(83380400001)(26005)(66556008)(186003)(66476007)(1076003)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NquaZrdkgb7sWgCWk2D+PfPOl4Hv5WlzzxH1Oq0i39PIO2Kz/7QHveT4bVaTltqO7N6SnMXIdbh/z/SBO3Q9TZ6NbwV7S4lDhBSl/zFFNZBs1fNEHTLw4vemMosoio0sfIomDWc4aRUP78Y0FAPZl8JZYjs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VQG6sO0rLD/cxY7+PmUu5qNocsNwZ0O4MBAjyTx3pCKaZXj9jLDJpN0PeezogkerB0KVN2IuBpqwx4AUFSZNlawf+03jaUoNU65d/ELwufiWfvFv0pZ1Anc4km7wAbOwfBUk+d1XrdqkkYjJlhRh1RK6hfBkxQFc+cItVuf3mPebdrUguhQJzdfv/iSUXDCxGAhcDRua95VjOfgidkV3SnlBrlUwsrSJu8gCUaqgyJZiVfJEWumLanSH2Zw0lGMTEPXiqksV6QMhjaDYtuV/oNjHKpvbzuup0p+j4R2joBTpvNi1AJalB0Bo2Ay0lWJb13crzeU2D568eg90qqz9R71NqU590wM8xF7kJUn52SOy6UiLptHE7DNv1D5oLUxgoWbZvMZLpKJ06EeEe5qMQ8rbmDesDnAN0nmR+sd5Nh9cxUfz5gz5f8w9Tti7uF+CJE/BO+krOCdCgfU16isMktRlXdyoTiZ3chJVOE= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: c142948b-3569-4d72-740d-08d9dfd27fcc X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 07:15:43.1742 (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: QMIqjqQUHOWcWukOyy9teNB8ON/1Xt8VP2XeFB0ILHLo5bHCy1yAYmyfOtsVqD7ss6LAb0VMWbSF9MfZIhCKVIK6kaInqO3gzZvxzpWRBpU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2538 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 --- drivers/net/ethernet/mscc/ocelot.c | 76 +++++++++++++++++++++++++----- include/soc/mscc/ocelot.h | 8 ++++ 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 455293aa6343..bf466eaeba3d 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1737,32 +1737,40 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) } EXPORT_SYMBOL(ocelot_get_strings); -static void ocelot_update_stats(struct ocelot *ocelot) +static int ocelot_update_stats(struct ocelot *ocelot) { - int i, j; + struct ocelot_stats_region *region; + int i, j, err = 0; mutex_lock(&ocelot->stats_lock); for (i = 0; i < ocelot->num_phys_ports; i++) { + unsigned int idx = 0; /* Configure the port to read the stats from */ ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); - for (j = 0; j < ocelot->num_stats; j++) { - u32 val; - unsigned int idx = i * 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) + goto out; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + for (j = 0; j < region->count; j++) { + if (region->buf[j] < (ocelot->stats[idx + j] & U32_MAX)) + ocelot->stats[idx + j] += (u64)1 << 32; - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + ocelot->stats[idx + j] = (ocelot->stats[idx + j] & + ~(u64)U32_MAX) + region->buf[j]; + } - ocelot->stats[idx] = (ocelot->stats[idx] & - ~(u64)U32_MAX) + val; + idx += region->count; } } +out: mutex_unlock(&ocelot->stats_lock); + return err; } static void ocelot_check_stats_work(struct work_struct *work) @@ -1779,10 +1787,11 @@ static void ocelot_check_stats_work(struct work_struct *work) void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) { - int i; + int i, err; /* check and update now */ - ocelot_update_stats(ocelot); + err = ocelot_update_stats(ocelot); + WARN_ONCE(err, "Error %d updating ethtool stats\n", err); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++) @@ -1799,6 +1808,43 @@ 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_kzalloc(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) { @@ -2799,6 +2845,10 @@ 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) + 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 b66e5abe04a7..837450fdea57 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];