From patchwork Tue Jan 25 06:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12723319 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 4D9C9C433F5 for ; Tue, 25 Jan 2022 06:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354590AbiAYGjU (ORCPT ); Tue, 25 Jan 2022 01:39:20 -0500 Received: from mail-mw2nam12on2101.outbound.protection.outlook.com ([40.107.244.101]:33504 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1353930AbiAYGg6 (ORCPT ); Tue, 25 Jan 2022 01:36:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EpMujYrGxuGYg/KmRwBMKQZ2Ip9dulHpgclWodtT3pJibB7zmtmV9RnasU1xzBCd8cenMG0dX2Zm87KKBj4Dy45d8/9pK7SFoxTKVdtgIBPFOssA9utahNqbEdXe0CKkH4a5oKvCPyJP1uUA8ZTvl6gKt6JnFu0Xi+AFahwCArawOmQ7hMXKMr3V7q9FB8/13SFBttJLk59Yy3k3FwjPeXj3Em+uceBYvH8F/Fp6Z2OSXMblSXDOZbSnBQVZ8MAaeblxnHjTtCeyRp3lzaSsuQxdJ4rzF4z4olcepweza+4jie9W95WPpb7LyX0DL+0kYuTRzc+wdtktM3ehPIbVrw== 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=kipKlXdzRY/0wVxXJ/wItTQ3Q+CUCEFi0tVKMuUamG3+aO46mR3DE1lqPxitcSdk+CzuWi19SlTgKvdohPKn92znHnJBmhduqJhzQ0dgZRTqyLu1Oo/MY5P9payhhrvVNZ4RYqizdxIRAJZkYwgse/wQfiHxnD0aaypv0ibfTiYFn3nABHIiEY9Yupz3bWbOnwTo3P9T8Q6ecOqz0repQUA41JJQix+BvAjuFrRjeG1IO4ooN5G7Jq4a4MMEXw7cxRTAlrHmyjqskpMsxDD0AwdtDZDCtPS6eleMnbKsA7zgEv1vwNyciKPbh2cwdk88jrKiOLCJaE0Vc6kYxhuHaw== 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=oukviimz1Sa8N1vxICudpQ6Dh1XzSjh8ZsNj8pbaiOqYkLmg3429l4sV+rO+RgVPMDHXPEg/m+MLZ+cjT5SCP53I+OS5BFkNUV+XEknSiwRT6qS4iJfjABiWZu6Qaw6efLPFjnvkG1UdDeYaq6jcEUnMGON0bHYC0PT4xBNphHI= 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 BLAPR10MB5265.namprd10.prod.outlook.com (2603:10b6:208:325::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Tue, 25 Jan 2022 06:35:50 +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 06:35:50 +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 v2 net 1/2] net: mscc: ocelot: add ability to perform bulk reads Date: Mon, 24 Jan 2022 22:35:39 -0800 Message-Id: <20220125063540.1178932-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125063540.1178932-1-colin.foster@in-advantage.com> References: <20220125063540.1178932-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0309.namprd03.prod.outlook.com (2603:10b6:303:dd::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: 626188c5-7658-4ee5-d377-08d9dfcced2f X-MS-TrafficTypeDiagnostic: BLAPR10MB5265: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: mCvSdYZH3bVX8i2MgH0zw4FKDNvRkaI5WP7kCbq6fx4jIzgUu7VPi5QLWb8Td/T5F+MJSgHmpBvmYjj/IS9ceqQEXFEWYyb8najAZYgWLoSmD8Q7uDd57uFyQ4BNyp/8zej7R/1djlWYJU114E4dPhUED+nDLpAeie2Oi44pXl9EdAjprCAFAkgGV4BPTZgGMZV7sgfhS/9KZylaOs0iQvMqaZrreKFPcJxBJJs0Bd3cCshy2J/IYQaYQ6fJafWmNCDxv7aGV124yD8cApNNgKqlVBmEfdRQVkZQ+PsriQ1Ss3DlFF0EmP7+h0xR1/cbVu9lFxDqnZQUaTmIuJ7aD+9dmAmy+YAYqSYFg4NqFos2AWYJmimYdau4cnQyNxeGU64wSO0WYVdgPA8pP9LXftg5HDZX7ahyfWACT2LqIyOLG4wtIbbYTe3JCMp6WzdlOBfvT98PuNYlP4/MSe4SeF5tt/A92mJzoCf0pCrVZ+xrkQnXoKMxFkORuZl1UBTOH8MSVABEFGo2qUpRzwAhujcC1JLp4De8R7qA3+Tqvtd9JYmu6V/oTc+uiQ/VGlEPnBA8xH2RlpUDanPhyxxOiQTwGZ7glkwezL4NpGjPSfcYq0G5otWg2SybzMICcw8Pzp+qWCZTQ0TwyVVloms3LWRG27Okwo49upEo1sDitV5Jm/2n+z4hvvsdGRJARXJoIDbxTgtky5WfLvu6jTbZww== 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)(39830400003)(42606007)(366004)(376002)(346002)(396003)(136003)(316002)(66946007)(52116002)(6512007)(26005)(6506007)(186003)(1076003)(6666004)(2616005)(54906003)(83380400001)(508600001)(6486002)(44832011)(5660300002)(86362001)(2906002)(38100700002)(38350700002)(8676002)(8936002)(66476007)(36756003)(66556008)(4326008)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3NJjsjaol5ZoZHaWFKtyt08DvSTFD8MAO2py/EcymSJolC0YkD72bcunKQwbyL/tK16V1lLZEa+Ny8wO5ezgX50PtFiG4cB+E2qQuAfaAxNW2los1/SY3tFk4DpF+mb9l5qJzzkN8Y7eFBQF97IcI5o6JPfhfQha9eTos0YcMG9HIKBjcd9dFrLAdfg48otnuWiS2DaTfxOKqA9Pt5f8gyKi4sSC4JXSiHcZcBjB0n3foDfF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ZjyBqnLxNS1HxJoEcV24L2jxjAi2L1DtKIByouOf9OoyQRWy5rj2djtJL2UqJ6BDUtGnh0p3RWw0OqEwZ2KcGLvL2vy9cSH9bPYWBVGKENyGdEt16p9NaHFDdxF9cMM7o/7zfJ26NhLYvOPtvdi4E595Sog0tdRKGv7PnFVBPq4IFUOkWoYTnXEJGxzgyO7j60ZONqmeCpDbplkYk1v0Jt1raaCt/9G9p/oN3aO961Curopt5UhICskp+bbYcURpbMpandTvhCKzZ3tVoNC2nVKc3mzJsnGI8RljaxxDh+JSzfoEnRPeNqGiVEXLZ4uUX3Qac1OpCzT22Fxu5Xqq4K5Ao5FoX/FvPSL1nwHMA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 626188c5-7658-4ee5-d377-08d9dfcced2f X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 06:35:49.6855 (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: MqZ9mNIGlY79FHI1kCyt76ixBC0hED+US4vx0ENUtSxfgd72SkghXQk1LxyqgYYcxbX4BpbTjh68/lsOGF6bU58lq1pU5Lu4thFJcmgku5c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5265 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 06:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12723320 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 18D36C433EF for ; Tue, 25 Jan 2022 06:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354854AbiAYGjs (ORCPT ); Tue, 25 Jan 2022 01:39:48 -0500 Received: from mail-mw2nam12on2106.outbound.protection.outlook.com ([40.107.244.106]:26465 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1353336AbiAYGf6 (ORCPT ); Tue, 25 Jan 2022 01:35:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpxjLvniQ8nIEkLxwu7N78SQK0+kAhfBTwfTwbPlK4K3S7K/QU4OdTiSnX8G4X/1JXtlHngc/6pNZrGTJhhsAIT0O2g48x92Zr4arz06lWiPJf/g5k0JUEi9qNzhri+HiHBv13j0LcdtRRaKpgqZoEHy6WJVK1mtoEmpr395opFhck3hEs5gOkiu8kvpkmGmHyYpKccXjRgxlpEEBBycczI5dbKGYkR+CyzXG9hS+mo17yte9qK3iQffnRuloDKUJIKkVoG/mfo3jhXRljftsN09dlI2TtKxGCDo5KqvcS4bDDFZmCkOMI2YsxFFVCK42bnx/Iq9WdewcBZBAyaqlA== 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=j6VREaav/KKFRAjiizK100MisXFaB0rHfWp9M6c/i28YCFWhIZQwQr2rbKgNuDm+r/0PLwa9RbqWoiE2qwwd1N1AQWxVw3/GrKamt0VA9GL8zhAkDLilVHsXUaqQs56ahIBSuaR/03rh9wMtN1bks2D1MtPU1Lz/kOiPnRLy1OttG9zXRFad/S/xJyysbHsi300o2ulOmZcBbj/b4+u3imbRoV4H+0Z1YufL5EF7Xo8G2Fmv39HVZ8vV6nPtfYnfKc9yHAti4BTJVeBZT72PB6B2fcGBLfMmPDak8UxoPaBRQ/bTJV0jweazVlD3f1Ezs1vczP3y7gqAFXFyEghaoQ== 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=PCa4lrmfP0aJCEom+Kc4utKBnSNjSOOXpNEDRgPJzoXw6kuWPvR5gS2sBFQ548y2Lr/5+vHGueyV4syRNj5ptQwARn5W7KlAVlrRcIokV22coFlkdV5t0stWYUTfXJaJwFeYbJh/qzRIqeTlT2SObVksrH6HhaCaLlIBpoEkO5A= 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 BLAPR10MB5265.namprd10.prod.outlook.com (2603:10b6:208:325::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Tue, 25 Jan 2022 06:35:51 +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 06:35:51 +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 v2 net 2/2] net: mscc: ocelot: use bulk reads for stats Date: Mon, 24 Jan 2022 22:35:40 -0800 Message-Id: <20220125063540.1178932-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125063540.1178932-1-colin.foster@in-advantage.com> References: <20220125063540.1178932-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0309.namprd03.prod.outlook.com (2603:10b6:303:dd::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: 921875fa-b312-4ada-1d52-08d9dfcced7c X-MS-TrafficTypeDiagnostic: BLAPR10MB5265: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: t2SbB5kDxHmSh0kUaGnIkgetdZJLi0ml2Iz5ddFmkfXqTSWo4MGaWckNB2FMowb3qrBfyjdqK81eC0LoDrJyAAIWxMRiWUgeic/Y5hPc0jQrWOu3l45x8VPYjMUoV1J0DgM5HRtATZSaxNkcDKShU/HIoNtS18Hvxt10vd8axNnE3WgDz6HiebsxeHADmPXj5bNEuv38dqRcORO3ptrz/r3iRcgXaAy6wnhyJDfYaKNGONkMOcWQ8UHWaZRrKSfMgHhzQ2+DL7LP9TG0NUJjgs/skSaRXJehKv6qB6orUPWjPupdin3YGdiQd5N8T7S2YfVeI8V/e8Mrcm/hEbUK+X1G3/l6QRc7oXiTk1/+5ccF0X3eYo7RHSIKllxBRb3ex7cElIMDKDXYiwVdfWmRsJ0Mnqg24IUpDrHt9Lh6Np12NpEefDCxgCP50pemoGelKnlERDpP4rseMcv9rI6t7g+tRPcK1ggNGcGEJwk/L0LbuXtKxvQMPU0scL4iEQvaQJQCS/LAxqudB75GngY3do1yt4TSW7NVrAOWG3pbWoCFvXw9HaK4IqLjV9YptgIlwuUwQL9Lyf6SJgYxbO/FNh0xa7buGGgV6BFmGeuH6IdzKW0KGfIDyk8upwKRAv+V8vNsHmRnCEP10gCU4yAaE4sG23iqTXLJwFvapZRj9HfkQfcHeTinbVdwhXZNrTI+Imd3jDG1PRrVFGwuilZg3Q== 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)(39830400003)(42606007)(366004)(376002)(346002)(396003)(136003)(316002)(66946007)(52116002)(6512007)(26005)(6506007)(186003)(1076003)(6666004)(2616005)(54906003)(83380400001)(508600001)(6486002)(44832011)(5660300002)(86362001)(2906002)(38100700002)(38350700002)(8676002)(8936002)(66476007)(36756003)(66556008)(4326008)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FsrTa0pvN6qQ01L4xl0Rlnlh7CMx96KPf8YZVsWj7uLA29vZZ7g4ODMFo0wnmoOFM0BmhBNNUcNe2i3ytinso/1iIBXDHZbm7O4hjwcFt80hy3+aedf8zVdNlr2sp9lK3kCv3pS4WIKBefuvA+r1xY1OwL4xOa+9n0Xg2I1zV5RPznp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yzkO4uVr/v9+Orpm1rSyLa4AsXFLr0JmpKL7HTiyXGtD5J5UkYmFEnqyuKQQF3lX6E/sjV72iXgdICpUOh9S5gZz42duwD3uKEWs0xy0BC5PjIh/nMNGeU+qSl8I6u2B0NfXLT4Jbg1Qw0yE8eRwWZtFVC1XHu8Vn3nH2tOjc6AyJ+meZ72rDav3aF3CXXnZAcj5fepsbLEF3CDgKTRKq0V0e8WtU1UYwU+Ma8BVKIB/G/cuul7FWv2xrl+QxtVykCkE6aQTh6clRtrv7aIgX/hJY8XSrJ5hha1Bqhq6QGIoqjMjJ4q9RWxmDU9In6VY8IXGmiA3ythEA64cZfJnJoG+rGuesur5U1l1WjS2XDf7YDQQABN9per6/s4uSP8D6rIYoarGjv7HjHnNt1ZDoG+wsz9ELWVHVf0/BUgiaK7rUrrmWek/7ICTnw+Wbly0= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 921875fa-b312-4ada-1d52-08d9dfcced7c X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 06:35:50.1698 (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: Sc15oiyrySMy5KJ8u0JOq/h2i8hHGRZZ9JJvi3iNW4gWK30LAN1kr0E8PDO1AOMoLO+5d9llDVFtkJRNRizJlzjLPXAKd4fF6aE0fz1Xtzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5265 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];