Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4633100rwe; Tue, 30 Aug 2022 13:59:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4BnHd9h72GtCNejKI/E6MeT4KcRCX7Xs5PqXtiY50/683OAYFnsVE+G4XxkmLZtarYloXy X-Received: by 2002:a17:902:9b97:b0:173:dd7:3f3 with SMTP id y23-20020a1709029b9700b001730dd703f3mr22638279plp.56.1661893152050; Tue, 30 Aug 2022 13:59:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661893152; cv=pass; d=google.com; s=arc-20160816; b=sBoeuRa0JrO8mnaxeVaYLkmOF5ccjTFBUh7RArMZNJ0DP5RaZXOcx8cc+TdUKZCWK9 49j1DYH76A9kLXVeF/i6HHzZaa3dm+6786rojABmZdzBCLbNvwf530H1c7hI1qIcMX+r Ae03zx5BxjIF1ORPq5zPXubYJQGBikAG3ydvFJkG541bBPxMR4T18iPEV7wPgJVUV0ea 7foYvz9jXARn50/P8mYaMeJRwQf9A5uAnDg532GnPJyGIjwOV1B4HlPUsMs36eqhuR8h MNJUZpCwfW739sjFC6vbk0feeoWcBpGDXP7g71qhAnrJbt/3Hr02Tkg1+VFnTwCmgt59 F7kQ== 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=umXZbWuDzLvhEefwGTx3wHuHvXFqLYhD8d2S6wz7vaY=; b=VX1iliaN2P3VpjyxaixZmrnfAHRFZKHt/4HvwovVSJEAw196NuxitfbqN0mYwv0pPA +PJGZkulbZD8Wju+TjqrHod2JKuLdWq+zIssf4qe8vuHcJimQY1O0pjRSE3tdn61LPn5 sxpLDIhVYVrPQyebrrhR28bce3bVHoifkt9tcJle5F3CDrqMxLvOxsb8X64gGu5uRTGw lMG+2rdpcs01OT6H68ZSjXL/7unNeTo/a4B+gqSLZJTGwVpX5ODqzm1TJx8f873b2uI3 fReInEkFMMGCiW5RUfX+K8jtcyeaTJWfRsRVEnrQ72dXYnHf34R9QFm3Vsh3WyapaAgi gJzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QNjF1+Z5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a056a00218600b00537280a2fc4si13386295pfi.231.2022.08.30.13.58.42; Tue, 30 Aug 2022 13:59:12 -0700 (PDT) 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=QNjF1+Z5; 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 S231580AbiH3UAC (ORCPT + 99 others); Tue, 30 Aug 2022 16:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbiH3T7w (ORCPT ); Tue, 30 Aug 2022 15:59:52 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2063.outbound.protection.outlook.com [40.107.20.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8360A108E; Tue, 30 Aug 2022 12:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C+iSGpAwRIF+8Zje9nmC/8SPLrPBe3UZXlxESKxLWWpLPbO9wJfORTNSuf7ByTPYtTpHAHPB3ULqIu4Wb65mH64aNr5unACdsBnlGi6beNZR9HMpntaqnzvwEvcr9akYeDrKfh6H4P1uUGBqLytGPu/ujdNXZ3oyadF/2I7ohSlL9y6srcxA71cvBDwLyHEaKMZfjh8UYuBihMqoNG9BCdp+2TDUjmizjXbpsTOtlQYUjkYzCwftKBA3yUFDd1T9fz6Yiv/eL3RKCdGxRzT2Rqc7aOTSG4grKydAN69Xitjk7H3/XgmQ4sr8A4WHz2Vtiw6sx+VZa1wpNA0aBfW80Q== 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=umXZbWuDzLvhEefwGTx3wHuHvXFqLYhD8d2S6wz7vaY=; b=ey6dsRYHLoBcU5PJGslLRHeTNlo4kKHPyHwDoxtIdVshBUVTwZMWz3DUFqmuAgGrn+nimEMyD4QucLf7tRxHCKVSQvgD1rgkiF3ge5CV+TKU96oW9UwTDNbmvXZBKW2PAwdaW+Z9YXR5ct2khMSKGqn+bykwlgaitGyebz9gMvYnSl4/rlb3JE7pwtKKBqHsRT18ZJOmomDLAP8IzpHvgwHEDNHaWEZQJaENeYTNdRL45N+QhqSQl+VfOnri17j+Ak+74qPTQ8Jn7Nm2y54cA78ee4DIeko6g2OagnOWn0TfduLfD21SM+OTzSCTKUDsML0JUvmu2El7K36bjDvdWg== 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=umXZbWuDzLvhEefwGTx3wHuHvXFqLYhD8d2S6wz7vaY=; b=QNjF1+Z5GlScJ0sSPvjxK26A3V7a03OBP/VWb2iEcDw8NwUZNuAIFpD8daumnXFKRi3lIlDLmf4q3bR9sUUtXzF1cPWWFXTKnrC939n7uu6FoQwhE8axfTZUQijUKyXnesUME2MLSxGY08B3CCxd8YJ5/6mhm8i2AA2oR41Wqcc= 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 VI1PR04MB6270.eurprd04.prod.outlook.com (2603:10a6:803:fb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Tue, 30 Aug 2022 19:59:44 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.010; Tue, 30 Aug 2022 19:59:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov , Tobias Waldekranz , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Ansuel Smith , DENG Qingfang , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Linus Walleij , Luiz Angelo Daros de Luca , Felix Fietkau , John Crispin , Sean Wang Subject: [PATCH net-next 1/9] net: introduce iterators over synced hw addresses Date: Tue, 30 Aug 2022 22:59:24 +0300 Message-Id: <20220830195932.683432-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220830195932.683432-1-vladimir.oltean@nxp.com> References: <20220830195932.683432-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BE0P281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:a::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e3fcd36-97fa-4ec4-2559-08da8ac22ea4 X-MS-TrafficTypeDiagnostic: VI1PR04MB6270:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5BR5EaM+ztyS2T30mSQTEKPvWdpa/KQVGG5EJq4y0RplQPSTdTaR9kR/mb9KNVG9U+pm3Kpmro2vF5NxSy8TOx8Ugzjn0H+gsZkgHKJHRzWe84+zHodtPupD+QgCGiWglEpiS7eZX3JRaTS8f95levzzoRF+hxxXLIg15pUCPWXn3qszsVGiZ1eRPyhmxr17kyK60pH1VUYDS9LkpfJgLY23x9sqmVq13ga0oDik0oB6L5mQBrTZtq/HTHmwKspB7X3fkQGKDTgxIh0/GzxcdkrGIr+iyIYirC3f3IfRSzL9wj2v5FbdPIZI34ZxmgLD8I03gYHBdfSJqfe0yuaNFXDnnzWBPzJBS4tLqn7o/NtbEi0ReISeRdM3Bt9szpZtRdN1Jh1f8ie7/T+0jCvDaFCtZ7SpxcB+NOxX4PZxF1ETgQSDj7m7O1BEgum5XyWKysf6ZEYZ4K9TlLxpjDi/rLQ0FifKg10IIb0FAi9ZOasTixiwcYmOkCn574PYmQYjJ+CfZ0GrLihpqctV8mSUewJRz+oyYPkj5PzB3hf1Xc9mlT2RvWDINke/DO0AsY7SN4KuHsS9H6lDHIVqZsN1yhmrFFiENE6h5Jxnn75Hy0RJ6SpeFzM3eUJEAZVyDvGZdM02nv/5fZFKrnL8t4c8zqQe+CYZAByypyuzNG8H0Yd/1EcL/+gbeIfZjRfXGX1hx2JL1qtczuHU1GCMgrcy1jrf6CUAFDD7H0YmaplKOJUADXaW7szWQ59FLcOZtmR 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:(13230016)(4636009)(396003)(346002)(366004)(39860400002)(136003)(376002)(41300700001)(66476007)(6486002)(8676002)(4326008)(66946007)(478600001)(66556008)(52116002)(2906002)(83380400001)(44832011)(26005)(5660300002)(6506007)(6512007)(7416002)(6666004)(8936002)(2616005)(316002)(86362001)(6916009)(54906003)(36756003)(38350700002)(1076003)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+6n6ddAECgAdvap7qsUsgd8hOrkLGVCkilvPmY6+uz4ucwMwqUu3DtMddJbQ?= =?us-ascii?Q?L75per88oEXLSwbyhq/R5Don8ZculB5xtF3d32Nt+fETtfVPOPG2x4CPATe9?= =?us-ascii?Q?AKxHkA/r8AEj10EGT3BN3/B7GZ2PdwnOJ5AkSTaOAu0IWeSG/JGCDovAlBHB?= =?us-ascii?Q?u2spp88aAt+W0wRj8e5hKF5s5ZAiGdGHpaMHwEacylkemDyTRcz/rCxSC1Fc?= =?us-ascii?Q?bJmhKIl7Tu/FEt4qa4vySlx1v7xKiBO5zytxaIw3yC7RIHe+UFuWioudjVXh?= =?us-ascii?Q?dT45YBep5Hm8aXqbB+ViNIUg6nYhNx3YN9gRzwKDpsWkVbVKRrpo03GsNkVI?= =?us-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UeEy0e/8XP/vgWpplPUvf8B4?= =?us-ascii?Q?tk7tUYh58rkqjL++m2JwEvEJ+aEcFbm3+p2Gk0RjUzuyfkdRgGhVW3ywNHM/?= =?us-ascii?Q?OwOk6HwR1IH/l1AtkNadgUtga2BNu59zYf/lnsLcsQrgoGLrrmXhu0Nr4bgY?= =?us-ascii?Q?mI9LQXIOBOc+lDaKgwP3oEHb0144KvXWfx0iAHkqx+9je9mecDvwmIO+WkBA?= =?us-ascii?Q?T13fTfVG6mUN6mUCV/VcXVD7o7Wx1DIDN1XayVYjKzBUr5iPwtrORqdntFDk?= =?us-ascii?Q?2+G0sDGh8wk6VyxBECQh/abKeziwc/j/GIR64xLs34m018G15e+6G+aDJOAw?= =?us-ascii?Q?vfAlSPPYxLMf+0g1RMZR4eol3Q+EeGEB5r7y2ZG+f1+HyBKYQf0lhWjSg6+n?= =?us-ascii?Q?6Q=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e3fcd36-97fa-4ec4-2559-08da8ac22ea4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 19:59:43.9488 (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: 5+h8oljntjcF+3hKDuz4UJ5nrDDiyHaEcrVI0uceru6pKNCyx1r9Epdbhz3mCH420u67KFqwWF4Uh+/ybQ1dWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6270 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,T_SCC_BODY_TEXT_LINE 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 Some network drivers use __dev_mc_sync()/__dev_uc_sync() and therefore program the hardware only with addresses with a non-zero sync_cnt. Some of the above drivers also need to save/restore the address filtering lists when certain events happen, and they need to walk through the struct net_device :: uc and struct net_device :: mc lists. But these lists contain unsynced addresses too. To keep the appearance of an elementary form of data encapsulation, provide iterators through these lists that only look at entries with a non-zero sync_cnt, instead of filtering entries out from device drivers. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- include/linux/netdevice.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index eec35f9b6616..2979293b966c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -253,11 +253,17 @@ struct netdev_hw_addr_list { #define netdev_uc_empty(dev) netdev_hw_addr_list_empty(&(dev)->uc) #define netdev_for_each_uc_addr(ha, dev) \ netdev_hw_addr_list_for_each(ha, &(dev)->uc) +#define netdev_for_each_synced_uc_addr(_ha, _dev) \ + netdev_for_each_uc_addr((_ha), (_dev)) \ + if ((_ha)->sync_cnt) #define netdev_mc_count(dev) netdev_hw_addr_list_count(&(dev)->mc) #define netdev_mc_empty(dev) netdev_hw_addr_list_empty(&(dev)->mc) #define netdev_for_each_mc_addr(ha, dev) \ netdev_hw_addr_list_for_each(ha, &(dev)->mc) +#define netdev_for_each_synced_mc_addr(_ha, _dev) \ + netdev_for_each_mc_addr((_ha), (_dev)) \ + if ((_ha)->sync_cnt) struct hh_cache { unsigned int hh_len; -- 2.34.1