From patchwork Wed Jan 11 16:17:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 42081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3412205wrt; Wed, 11 Jan 2023 08:21:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXQ+mUTY/d0cG5PQV2SkSJawd9WejCBKmesfFJpn18L8MU/axGwSmSRKM5ql3VP6p/Dz27 X-Received: by 2002:a17:90b:4cc3:b0:228:d392:fb3a with SMTP id nd3-20020a17090b4cc300b00228d392fb3amr5888897pjb.25.1673454061131; Wed, 11 Jan 2023 08:21:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673454061; cv=pass; d=google.com; s=arc-20160816; b=dPIqD2V0j0yBg8NAoiIA85XZvF0pZNStnBPAo6OvdND7QLpLc/DmkkdtMmZbfkZa7X 4RNy4YxfoYd30nF0XFeeTmDw5YHjh56KDFf06gUUbXbIILiV5BLUgwQKEokioTo0cYVq S/0TfsTFNhey1tSwN3mNheFeVI9il3X/R3Bxa+iZMxmAkk+jUVLOBtZ09eZcBL7SRea2 5hp6DblcnK+Eo61qIxKorHYEkmcG9rcnLOMyoIlkFbxTh0Nq17CnYsl5zi80HuEw5TxX rIB26SUrfKY/tuwclSVJ1IdhVZJSw0nnihB+VgTmEyRamMJ6MUUD7dPBMnKlFSEbRc7u Da/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lfGDgR8XtBdxz/tXCK4dGk2/b046Jl6bSnKzUfD9r/o=; b=oncouGj9wxbkoSNxIsQ6IQH4kMXbz3XSZkqPQJZKwnqNUB9Y9wUqVRmbP9wsXJei9t wMC3gzLzzTBbik2gCm79oljHnWentXQZv1EX0WajnD75fck/jxvOz+62f15G7sWyL1GA oRGbrrfPO8Q39RU43N4a2yKnZ8WY06r/wRTiedSvxjrME+hKDxs6t8wyZD84AiaXnbhb CNhcDaluCah3NTqNd/d3LhbFGeR3KNjVhGtP+UuH0MWSNg/z6UryyLHFy0ywnViQbmNy vTRdHp93SDxR0om4KfjyMGb4P2TeyMEtAh38TWuSr5KGqjZ1qlTYXlut05WT+g/VZh6r L6HQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=AHZ6dMCg; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s37-20020a63ff65000000b00478d30cde9csi13945158pgk.832.2023.01.11.08.20.49; Wed, 11 Jan 2023 08:21:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=AHZ6dMCg; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238792AbjAKQTe (ORCPT + 99 others); Wed, 11 Jan 2023 11:19:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234896AbjAKQRo (ORCPT ); Wed, 11 Jan 2023 11:17:44 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2054.outbound.protection.outlook.com [40.107.13.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44605F4A; Wed, 11 Jan 2023 08:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kLmUiHunXXE285em5MBz+qLFz1noyWRBWhxyae5x7Fx8z41k37QQvtahPoHB67WqscmAReOvqVsb+O/mHpYJ45RsB5Myf3fbC1KuDki+4UkNZkmXLtf0mxdKlQnC47Ug6YMJN6Fc9RFcmTbTe0Ny1os7W8gl4bFhBTA+ACQCxtTXr4xRQiqBOxl6KVc2v8FnsAxSr12jxWPY8FFEsLYAwe7Hn18dL8QXYeJUNt4KP//kgGGZLZgnqTbM3JqU1oJsXBSxlt5rY4mpx0GY4FcEDnzcnFFAbuDXQ0z6X++XUYwo77sCjgB2pN0YeHMlSpn+D41VtNtWnWbZzJrdfeSsLg== 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=lfGDgR8XtBdxz/tXCK4dGk2/b046Jl6bSnKzUfD9r/o=; b=Oo9f5lBNjM54jZu4KsdZ9fxlGJO13MFVcEXT92pGMyHPdjS0CvgqwK6U+QJDGYyg8b2a45wpL/eydVEZ4A5qu55R4vIPm132gaisb1UUJ2+u7rllVArvrJI4EJg3I4PpE89e7uQzdXcnRsNjZv9SMV/j/J2iGWYBZIrJ2GYSbpYlthUK6+SAGuxPh9mFSjtRt1hTtRpHkiiNEbLgOEztO+bMDvjwkgS8GNEmvVGrnsIqx9pNuc7zW80krg2r5KjAH4L000nuzobe4qFqDlst+a7cGdQHgVk464kjj7OvphasLkYK0qVru5gRSZjrt9bUkUVxDLGDI35tveGNdJEmog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lfGDgR8XtBdxz/tXCK4dGk2/b046Jl6bSnKzUfD9r/o=; b=AHZ6dMCge+269GRCu+oMBSKHhhOPwTQDpPRvUkjCqD6hsKbY9wlWpchBpRDXiJZht04I2/xTx0MEiEBTPHdsNtYDw3lT6LfMgw2BkuG7C9jaF6qfhH4p3Gii6OXXQJlyJzA5LIEYn40kaE5OxcdUCSlxi5gL0ZXTdfdtgzUd9GA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7549.eurprd04.prod.outlook.com (2603:10a6:102:e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:31 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper Date: Wed, 11 Jan 2023 18:17:04 +0200 Message-Id: <20230111161706.1465242-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: dfe4acb6-ad11-4468-2bc1-08daf3ef5727 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4g0n9FZvecSWzszyiU7mgOCDYm1s9pwPOBATHqwHlUF3tetHzhiqBV5EmwNs4VxIft50yIRlBF7Ywmq3lKX/2M+fP7XHaCLkTTLz91Jr4S0kahU7NvCihwwyTWJRInIofWrbaj9EBRwYpLZX5pydXdsiLcKYWX/OEIDIaMFaOlOG+TpiOehPRA9Ie3aH9BCi5WfDzSBW+9zMxtZ2gO3veDrIxfeHVXU7dypnljkpi1bvidgHfcCtlRhioE3+f6WtdZeH5cEErVs9Fo04qzFzF2CBHD112bgDn2G66lMNnFNcvK/1ihS4vK4OfP8rbRGHhh2E6mR7kSXw0VkxQKOqhcEsgF1q4CtGvMN9YK13j722FM8ZHHBYBSubnGNaPawzFNrG8oWUdcy441f801MRO+J8xoO0vbpA4Hufhmdq2S/rCdPCiofQkKRLkkGINaG736khmwc/wYJKWKrV6Q3vwZwXPFLsaVQJdoaR3OTILDIVV8olcxJothsZsdGfxwjju6vhueHyPHzZQ0tAEo1xWEYShelG9Gwrhf62FemQWvx7A9iCLqzznnivF5E8vLuJfi17ACg/FQgqjO7cJQfmn7q7mlW6iagIenjmtncS/7+gp/s8qJZr0+1CPGCjvQNDyVZR+VE1sCVgxhB8ch9phKAk9BqyEt2GMmnqVQfQ4YCZFVYsoQN7gfNJ9yJan23m X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(451199015)(36756003)(38100700002)(8936002)(186003)(2906002)(41300700001)(7416002)(5660300002)(52116002)(6916009)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(54906003)(44832011)(38350700002)(6512007)(26005)(2616005)(1076003)(86362001)(83380400001)(478600001)(6486002)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DoUAGu176m++ID/iO4/9uYhOiRnCtd/qh9KZfFKpmwc/t/z/XHIYm9IgcFhghSEyldJpdUij6uJotfBVDyeVL/G1HAfIyJosA+FM8+I7MVJzY1vTPR1QY7mMrd7rDo9K3VVbLIk3aaS6ccpPEn9w2uU6pCEcIn0DppuY/Nk9D8KItiCMV11vLixALyk1d9zILBjDwBNPBe9mJJlrHeMwQZJJhMjPfZRAdV5cKQM/vr5tXRaKYJjlwlBBH40ZkdVcSQabrkQ2ETPdRNmuqWEVsHzAvoT1/ncSuf2Xpsw8NfLEC0/IP+B8ebtkBYDnUfzt099Y1gnSQsqD0EXmEnD0yhnTII3up6qoykLm/t97/03lZKwhzeuNXRVDJBFV8cGjf74mkQv+S1/EWBRHD8ehvY9+mma+/cXXurZb/yfUf8fakYbBUNqM+3/DGe4/e9HMIEZpoK1nBiD+CjYfa7D4q83QZN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XfTCoRXkKV1YHjVAUZdlckN3UVZj9YzYY7yNJusFEowAEvbNt5BhA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfe4acb6-ad11-4468-2bc1-08daf3ef5727 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:31.2827 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EETpE2opMYtrHXAq6kpu8J1nsZSAGJ9X0ztdqIoQo6F280C+A3/txJonvVIyzccVkOJYsevlCHgMW36Kk/k+CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754743765777796583?= X-GMAIL-MSGID: =?utf-8?q?1754743765777796583?= Some hardware instances of the ocelot driver support the MAC Merge layer, which gives access to an extra preemptible MAC. This has implications upon the statistics. There will be a stats layout when MM isn't supported, and a different one when it is. The ocelot_stats_layout() helper will return the correct one. In preparation of that, refactor the existing code to use this helper. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (v1 was written for enetc) drivers/net/ethernet/mscc/ocelot_stats.c | 40 +++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_stats.c b/drivers/net/ethernet/mscc/ocelot_stats.c index 01306172b7f7..551e3cbfae79 100644 --- a/drivers/net/ethernet/mscc/ocelot_stats.c +++ b/drivers/net/ethernet/mscc/ocelot_stats.c @@ -228,6 +228,12 @@ static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STATS] = { OCELOT_COMMON_STATS, }; +static const struct ocelot_stat_layout * +ocelot_get_stats_layout(struct ocelot *ocelot) +{ + return ocelot_stats_layout; +} + /* Read the counters from hardware and keep them in region->buf. * Caller must hold &ocelot->stat_view_lock. */ @@ -306,16 +312,19 @@ static void ocelot_check_stats_work(struct work_struct *work) void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) { + const struct ocelot_stat_layout *layout; int i; if (sset != ETH_SS_STATS) return; + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) { - if (ocelot_stats_layout[i].name[0] == '\0') + if (layout[i].name[0] == '\0') continue; - memcpy(data, ocelot_stats_layout[i].name, ETH_GSTRING_LEN); + memcpy(data, layout[i].name, ETH_GSTRING_LEN); data += ETH_GSTRING_LEN; } } @@ -350,13 +359,16 @@ static void ocelot_port_stats_run(struct ocelot *ocelot, int port, void *priv, int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) { + const struct ocelot_stat_layout *layout; int i, num_stats = 0; if (sset != ETH_SS_STATS) return -EOPNOTSUPP; + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) - if (ocelot_stats_layout[i].name[0] != '\0') + if (layout[i].name[0] != '\0') num_stats++; return num_stats; @@ -366,14 +378,17 @@ EXPORT_SYMBOL(ocelot_get_sset_count); static void ocelot_port_ethtool_stats_cb(struct ocelot *ocelot, int port, void *priv) { + const struct ocelot_stat_layout *layout; u64 *data = priv; int i; + layout = ocelot_get_stats_layout(ocelot); + /* Copy all supported counters */ for (i = 0; i < OCELOT_NUM_STATS; i++) { int index = port * OCELOT_NUM_STATS + i; - if (ocelot_stats_layout[i].name[0] == '\0') + if (layout[i].name[0] == '\0') continue; *data++ = ocelot->stats[index]; @@ -602,16 +617,19 @@ EXPORT_SYMBOL(ocelot_port_get_stats64); static int ocelot_prepare_stats_regions(struct ocelot *ocelot) { struct ocelot_stats_region *region = NULL; + const struct ocelot_stat_layout *layout; unsigned int last = 0; int i; INIT_LIST_HEAD(&ocelot->stats_regions); + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) { - if (!ocelot_stats_layout[i].reg) + if (!layout[i].reg) continue; - if (region && ocelot_stats_layout[i].reg == last + 4) { + if (region && layout[i].reg == last + 4) { region->count++; } else { region = devm_kzalloc(ocelot->dev, sizeof(*region), @@ -620,17 +638,17 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot) return -ENOMEM; /* enum ocelot_stat must be kept sorted in the same - * order as ocelot_stats_layout[i].reg in order to have - * efficient bulking + * order as layout[i].reg in order to have efficient + * bulking */ - WARN_ON(last >= ocelot_stats_layout[i].reg); + WARN_ON(last >= layout[i].reg); - region->base = ocelot_stats_layout[i].reg; + region->base = layout[i].reg; region->count = 1; list_add_tail(®ion->node, &ocelot->stats_regions); } - last = ocelot_stats_layout[i].reg; + last = layout[i].reg; } list_for_each_entry(region, &ocelot->stats_regions, node) {