Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp217828iob; Mon, 2 May 2022 17:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzuBQUd8gOMpFxq9XBmznwL1qE1kuDP9JOWnRHDE/bEg1Iktf1vktdPx85zFDr28DGcd5u X-Received: by 2002:a17:902:d508:b0:15e:a12e:8089 with SMTP id b8-20020a170902d50800b0015ea12e8089mr8589739plg.137.1651537928644; Mon, 02 May 2022 17:32:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651537928; cv=pass; d=google.com; s=arc-20160816; b=LU6SsvPEvSzzA3LFqQKhSPmUMuM3XeDLtOX75W9lPRCx8s1iSgWUowFyIAH+x5QMkM o/ofSps5+5nR3Yuv69NwbCnD9EH73GG6lFJLscA6YThf8AEVPSCluMYOTFCJtDtq5I9T U2FRA0afoQXd3VahKxbSqdX8Ft38JCt5JpKW1tYhM+xXK9kl0AZN6uvIhzDeRIQPjZPz U0lscsvJbzowJQXuCiq+GC1BmY9wQ9MsBtv11HdxsuLBGD+50WsEUMbe9CNL6O2gd8PB ckhLMuQ4qLg4082z4aPo/2InIjquGr0GYXwTlCToMaQIhZkyJlIAV/P6JmqYGXqxAc8y 2Tyg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ygE+0/9jFGvkToLKUjXmTPQ0HxfSIKAOMb8VEQrV3QQ=; b=gP8Mcfvr1mfFS1xuEnfuf8VyT3GchMoeHzwU0EusXE2xz1dvDRRfq+aeMKZqHfcpta xpIemF8EqtyEf5RkAUjCL2dq9OocQMCCqB7XeC1tZrEHQmhph0KkF6CyKag0aqL+8q3z 2X5s/oS83kPTwXo29jwIJfEYXrAOVz6jnws9T+mAzZpqVu58mrpFQlXT4Mhe5qqe+Wxx drBFWzQn77hwGUQTTFG4+Uw6Sdi6IqQXv32xT0d9CtU9oSavA9VqbC8PXjQtklvCFZdx PoC+lwxbJGGxY+dcTfq1oPvWuzDABGKzYWG39jnH3xq+zCGc8Jtn1SzQa+1unNfpCSCB 8yYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inadvantage.onmicrosoft.com header.s=selector2-inadvantage-onmicrosoft-com header.b=uMej7Afc; arc=pass (i=1 spf=pass spfdomain=in-advantage.com dkim=pass dkdomain=in-advantage.com dmarc=pass fromdomain=in-advantage.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=in-advantage.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x66-20020a633145000000b003ab28cd4d18si15674946pgx.391.2022.05.02.17.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:32:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@inadvantage.onmicrosoft.com header.s=selector2-inadvantage-onmicrosoft-com header.b=uMej7Afc; arc=pass (i=1 spf=pass spfdomain=in-advantage.com dkim=pass dkdomain=in-advantage.com dmarc=pass fromdomain=in-advantage.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=in-advantage.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F6663586A; Mon, 2 May 2022 17:25:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238279AbiD2VeR (ORCPT + 99 others); Fri, 29 Apr 2022 17:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237435AbiD2VeN (ORCPT ); Fri, 29 Apr 2022 17:34:13 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2123.outbound.protection.outlook.com [40.107.237.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AFB4369DF; Fri, 29 Apr 2022 14:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QS7IxyS0nKmZDOCYU+D2iUnYJEneznhOJmRQoSW1lxS90H9VnAh6m7yd9IoxErp70BbpT233RuLk6+vcsen0dUcV3YlCdqHL8BditxQWMGk2mXAv9n7zYufA7Xng1G3emAggkPSFAnIuhfMqQSlTJSA0q955po4t2Bprsg+rrurrG83qnWCaxNDfPhCHRDPCoCMDiW9nVtUdzg/KS0eTz/lCS4/K1dXqq4WtYAjuI3MQnSvkVGnxG6FxK6ATCIZ7OKk4H3BRPI+9FC5SJCHNRHdUQXF6/V/lGOeRElGEY86lnxqQF93tJACiSBsJ09IYGX4YmHycGbpb7YY1vstlGA== 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=ygE+0/9jFGvkToLKUjXmTPQ0HxfSIKAOMb8VEQrV3QQ=; b=AoO720u72vWcqbtHpTCapIhU09/QLVg9SHRR1MZlYyBJhVbPJ/2AD4qWK1tZPOsTU9yPSMYLGqfC7vg/MILJDolP5S55lQrmSIyjkXQgTuZMKPxuME+q8pBlkXGsr01zkcx+z3pgBNQ1+U3FDpM91/Cxe4fxNzLUDi6haKrJPZb0CsN9QHuW+aDSTpT0yILw1XfNix9Cr8jx2Eq9wsmDYbV0yzL1gtGA26MfVGtpNN4545DaPjUijOrkt+/rTWUkyo/uO0fuNoWujh0IxEKi/BbkU8S+O/B0Jld2mIQhQSXzUy756HfErR3JYBIcx4Lhlzc4A0+kzHQNVL5FyIKXxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; 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=ygE+0/9jFGvkToLKUjXmTPQ0HxfSIKAOMb8VEQrV3QQ=; b=uMej7AfcRR5DyeFBAX3GccY5/oGZr109ptf/LbHPaLn3rf8TkxATwO/PERUU3oj+34kR7EK6zc5tTVnzdaB1sx3JUmDrp91rm72LU1afrMc5WtuDEZxTcEHkL3S9h8rPmWKFcLD7nFi/PLSASXDmAE/yLcuALmFlYWyF+qVnVKs= 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 CY4PR10MB1957.namprd10.prod.outlook.com (2603:10b6:903:127::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Fri, 29 Apr 2022 21:30:49 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e%3]) with mapi id 15.20.5186.026; Fri, 29 Apr 2022 21:30:48 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: aolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v1 net-next 0/1] net: ethernet: ocelot: remove num_stats initializer requirement Date: Fri, 29 Apr 2022 14:30:35 -0700 Message-Id: <20220429213036.3482333-1-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0200.namprd13.prod.outlook.com (2603:10b6:a03:2c3::25) 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: 1f6c852c-9a99-4df3-d16a-08da2a2786a2 X-MS-TrafficTypeDiagnostic: CY4PR10MB1957:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: efUS3NSR6K30b9MyY7R1FtpDJaBPNAPuOp/D+CYomMAspQkYfNVPXo/QDbE0pF0DViHgrkl2DaH+opEAsWiEEP36gVpT38yEEqlAOQSmNGcba4KGUQuHyR++TtKh6YkzBS77QfyEDrzvSpm8Vz5lGpMWFKQP8Pk7GB7qTU/9d1GzIC3zsTJSDlLpcI1kjUwOIoMQy82np6/ijtT8qld5IAueJbKdbW93i/GYRbCQVzyX5tvIBEqT+qrZTBVWX8EsmrP4aUn3MU70bPfC4H3JdUSEVZUJ8b8aTjiMsihR1KtHSqjlV25qDkC7J73SDrcDtBHzyyj2B/RC8yuhYxWHr8r5RJ2sp9Xwif1RvftPgK3gINlxPXCZTy/NKes90Ih+rTMWp/TLNV3q84Y9G5EDrrNmdq8LuClfUe/FAuFD4ikAFc5RBKIYavM02KZouftH4U+KkjI9b27Ncr5dNuMbUpQxfUotyWJzrSQgB/e/V+0VixrvW31h9/WswvuNSv1beC8BKRqV5LEfBLLK4Psml5TuNGORrA+iPXmkmIhxCwUS4gEbyzR25AfwFQ+1Ce2i2wJMLc2CpYGOs7eHcdycUKkwPTvW+fcjJ4fYB5XkVTVKQdhXRmLFo6uZm0bzmaZyiuYRd05HF9ffzM2YeJVcmuiCL9vRv69bDJiA51xgQzOWXu/DOeeYLwskSoFTgH2ANiNfrnF6NTiI3TygQbhTxQ== 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)(366004)(376002)(39830400003)(396003)(136003)(346002)(86362001)(6486002)(54906003)(2616005)(1076003)(186003)(508600001)(8936002)(36756003)(44832011)(2906002)(7416002)(83380400001)(66946007)(8676002)(5660300002)(4326008)(66556008)(66476007)(26005)(6512007)(6506007)(6666004)(316002)(52116002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nv9jI9vySsNzIxFaeNFALPwr0KUOMktG2xBO+QZHu+NoBs71V4uuP3Jr70Pt?= =?us-ascii?Q?Hk4GxojzasjibkiH5VL5EfPkO+E3mgsTqrLNWQp7tk9WU8YXzv1KI0SOr488?= =?us-ascii?Q?dknNpvhl934mqRfJ3Opeu2y2GEMyJabtnzLA6n2pfH5uc0PgXzn37tOWVC1L?= =?us-ascii?Q?EpI9EPKNsiizK+7WbFDcsr6UaMx+qLODYlkFMl58rAr9HzjghI6oL8t+P7SG?= =?us-ascii?Q?5igwtixEPeYdmP+CwqtgiqaWB7iQs/bx+wlLMlM4oWw9hwu7ytDNakX/hCHd?= =?us-ascii?Q?lXPsy0GF1E3Jwg41vXeg/FZVPwxXb4K7JS7XNvoZDPPhQmT7hTgi5L1veZao?= =?us-ascii?Q?1Y7DX5Y7Rb3ddtstKg+47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ruwu?= =?us-ascii?Q?XnrdhLVtTjGqereE/3vS4wrZUQwHi7HScJ3jC/woDWnX2pQDnl6tefj6cN7Z?= =?us-ascii?Q?XjKRVw+fsJdDNBXXgRutesioYGP5+sKaT/NzOgHTduazXyCoZPn/Jkw+OUW6?= =?us-ascii?Q?M1A5wq9Gpg+sfAKUGP9xEWY9duDjlfdZr6581xqHlhBP8FkoulLoXvBw2ic1?= =?us-ascii?Q?OQc9iHZeVRHp6V+KBLdeabainhCFbnV4Hbo78+0Kd8+oZ3JY3wO1FIE/eeV4?= =?us-ascii?Q?OX0yk7JyynMghqNU/CMl1YaSQvr6CphAG19FRfaqZk3HmCMFO7PBQUU4+cLG?= =?us-ascii?Q?FanUPakuBfgukuQcc9kEF2a+dwHD7IZV0PBQYvHwUo+RM4kFYu1ZW38X+0Fu?= =?us-ascii?Q?+LIxIroofgak/TbcHBeqIdwiMjL3w+Yl2TZ5y0st9NBZsZfe2mv9a5ptJUwt?= =?us-ascii?Q?KQp6w8JnZqIPifFCtWbh2y6R+SBdkcIlchdnawwFXNIkzjbmnALxdltE4VxI?= =?us-ascii?Q?9WAdOIX8uupI/jYOGkE/omfVHWJBAYvXvwWQg5HF9hb4P8LO5pDP?= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f6c852c-9a99-4df3-d16a-08da2a2786a2 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2022 21:30:48.1942 (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: c553Msb5p38c5DIayaYTXKodQmH/MYuCV0jlTkMgsQTojBWGLsoJKM5pAKfFRTS5U08AVRX7al9ppLRA8uCQJczGOuetY2G1wk0i0n3fadk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1957 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 The ocelot_stats_layout structure array is common with other chips, specifically the VSC7512. It can only be controlled externally (SPI, PCIe...) During the VSC7512 / Felix driver development, it was noticed that this array can be shared with the Ocelot driver. As with other arrays shared between the VSC7514 and VSC7512, it makes sense to define them in drivers/net/ethernet/mscc/vsc7514_regs.c, while declaring them in include/soc/mscc/vsc7514_regs.h The thing that makes the stats_layout unique is that it is not accessed indirectly by way of a shared enumeration index, but instead is looped over. As such, the num_stats parameter has been used as the loop bounds. Since the array size isn't necessarily fixed-length, the size has to be determined. This was done locally in the C file with ARRAY_SIZE, but that isn't possible if the array is declared via: extern const struct ocelot_stat_layout ocelot_stats_layout[]; Instead, determine the size by the elemenets of the structure itself. This way stats can be added / removed as needed (though they rarely should) without the requirement of dragging a size variable around. I don't have felix / seville / vsc7514 hardware to test, so I'd appreciate if someone could give it a test. I've verified functionality on my in-development kernel, but wouldn't mind feedback from the existing users who have had the misfortune of having to find my mistakes when it was too late. Colin Foster (1): net: ethernet: ocelot: remove the need for num_stats initializer drivers/net/dsa/ocelot/felix.c | 1 - drivers/net/dsa/ocelot/felix.h | 1 - drivers/net/dsa/ocelot/felix_vsc9959.c | 2 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 2 +- drivers/net/ethernet/mscc/ocelot.c | 5 +++++ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 2 +- include/soc/mscc/ocelot.h | 10 ++++++++++ 7 files changed, 18 insertions(+), 5 deletions(-) -- 2.25.1