Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2785982rwi; Fri, 21 Oct 2022 07:56:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+BmcKxSo3rjVbUKMG7EXRMTIVoArficZt2jkiJpNg3gQTP+oqKbQ5qVGAa8jQio4E/FwX X-Received: by 2002:a63:2345:0:b0:463:7c74:73b with SMTP id u5-20020a632345000000b004637c74073bmr16806212pgm.39.1666364187074; Fri, 21 Oct 2022 07:56:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666364187; cv=pass; d=google.com; s=arc-20160816; b=DtgtIettLlyY+xWdZVYU3DJR+9lRpCEi5qIvevGtKHnefAnO6Bdc6M+/nHFISFABdG TA6U8ZvWCc1KmU/XVH45rA/81Inz04zUK7w4kzC5qVsw0jymLdzeNcDseJKV6uiT0okF G37hQHJnRTAbs6sdC3RBCh84FqQzYe3g7VAODDq2yYw7FbkPjMvagpOUeExbk6daSdel XWv4wd/R/M4vXZigQSzBZgZsCxToghsn53ZvevgImz60ZpGqHpE8txKxI6SQiXnmcwbG clp9IFM31y/gGd9NfeXuX66m5cW+HRs0LqhTctMc3HMTESccF3xAAN0cj6DOJtZYlZD7 vu9g== 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 :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=YQihd/9TpOkqE4hyzar68xHe+Upy6lCp9gQdTxIdsNE=; b=ns+U2ZqE1TdVK7zmyHf7rntn4ZkPzC9cYUzHa/m+7pilAHZED5QUk82Yb/dDP8KxwS yIDapSVgXxIPQRh6fP0I2PLmjSdXPRox9WGvU7WDOzDCvFU+Hv+5j9qspT2CmFal9cQ2 uHL8sqVYwE24J4xVqw+aiygsrruU34JsEJBUK8W3AVEIFROI7nWQscyRCc4efFKQPfTy gHOWK5LlRY/xTtjuPdl1/f0KY9bmdvVpjzBNVfAWJ2ots/mLL3TpWu5T6hHDJ8AmU/ID wgMBRXTvNnUmNoJFBYnARkNGfa2RlMMHHG9WT9YDpqIOA8oQOrnHgq3vpy6BYICS1TQU 3HWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=YOREOEnf; 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 c23-20020a170902849700b00182140f0836si23032641plo.459.2022.10.21.07.56.14; Fri, 21 Oct 2022 07:56:27 -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=YOREOEnf; 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 S231371AbiJUOMn (ORCPT + 99 others); Fri, 21 Oct 2022 10:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbiJUOMi (ORCPT ); Fri, 21 Oct 2022 10:12:38 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABA9127BB19; Fri, 21 Oct 2022 07:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K7dPddLK8heAhMJn5ypMt868u0eweifI7IfBlNuERI7gpC1eNijGiJ38vdmWp7JSk2grToDre3HbWcaCJHTplj7e4T2MAcfIDzNl62QkjtYG1XB85YbTn2DSuI1AwUABFrsGKRdJ519Hk2/kuod4lzOqIFOY2lvw+B4uvkf2qpMCqHLDjW6kcuDd5teDbg6ZGicWJDG2pXiOM3aoghrsjC5ATnFxaJIaep7qanTjmOlrqH06S3MgjsQNXxV02T+15XNITRNdOqM+E2kbZonjbHCdpK/JHProMqhGbxk33orwZEkwo33anXUwj4H6Lso5IR7sn6u1U8E8Vb46w9d8lQ== 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=YQihd/9TpOkqE4hyzar68xHe+Upy6lCp9gQdTxIdsNE=; b=hjNykVlytLIKAjcN889efbT0UcbwwOxKUJi0CxLmDvYKzdqIMrYdzQ6ggOmQrhARoOtH2NpZl+DQgK5ZySV/SLM5h9Zz3i7kWovd/bnu6umYxEfiCDkOYR1gnKvqeKO0suWLPPRs8UnT8MlQxIWL9rp8eeihxmridYdSzP3ctMqdUegvQi7Tyc10a15Ab5XKUeHO7ly9eLWhudDExh51Yku5mbwZ/pe8oLX5aDwDVVL/2FJd7+B2Ylu8ozvrqpWV73bj2Hnk7NXztT7rghNg+2xf1jqpqVUXnERQKQIIJpXqZJBtXeACU1Zl9ILiRGRRFcENoJXTYBgq+3rbILr48A== 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=YQihd/9TpOkqE4hyzar68xHe+Upy6lCp9gQdTxIdsNE=; b=YOREOEnf9cjq/TZAHKlIdn8L9r+iCz041SKw+ekkTNAjQl16dZmJxFXrfL6lqVGyPVoGs3cLGfGv0YUS6dKahNQB5b+Z6aorOFgDvSn/AbuxfziFIfE8+vD8K1tNacuDQ4dkwHmiaoDGNvY1jWaKPiGAzoomrjX9U0df54tIYmo= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB9377.eurprd04.prod.outlook.com (2603:10a6:10:36b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Fri, 21 Oct 2022 14:12:35 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5723.035; Fri, 21 Oct 2022 14:12:35 +0000 From: Vladimir Oltean To: Maxime Chevallier CC: "davem@davemloft.net" , Rob Herring , Krzysztof Kozlowski , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "thomas.petazzoni@bootlin.com" , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "linux-arm-kernel@lists.infradead.org" , Luka Perkov , Robert Marko Subject: Re: [PATCH net-next v5 4/5] net: ipqess: Add out-of-band DSA tagging support Thread-Topic: [PATCH net-next v5 4/5] net: ipqess: Add out-of-band DSA tagging support Thread-Index: AQHY5UsYuAuylYj1TUe2Wb346JRkWg== Date: Fri, 21 Oct 2022 14:12:35 +0000 Message-ID: <20221021141234.rgzd3znogpmm26tf@skbuf> References: <20221021124556.100445-1-maxime.chevallier@bootlin.com> <20221021124556.100445-1-maxime.chevallier@bootlin.com> <20221021124556.100445-5-maxime.chevallier@bootlin.com> <20221021124556.100445-5-maxime.chevallier@bootlin.com> In-Reply-To: <20221021124556.100445-5-maxime.chevallier@bootlin.com> <20221021124556.100445-5-maxime.chevallier@bootlin.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR04MB5136:EE_|DB9PR04MB9377:EE_ x-ms-office365-filtering-correlation-id: 54d0c949-01e5-40ad-e38d-08dab36e4d56 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5I7jF8NWnM2esboxCwTgkPdATChc0H3wMyvxFqsjGDBVYGCkO9+eVE4456O85J62EZe5WQIv6p598EAMTXrkiWD9gwh+GxnbvKRa4n9u2Q72fnWba0B8EZ84J+o8KI1bqFz2ZpObA+42+bGnHWDDS2hGuvEnHjwgqZqShXO2dtOG05N+TIS+wIrZGio7mYCqnSny98BD5nQ/hmLLv+t8cg47jsnO9Wb8UrEq+MDyQGFo+CIlQecxU3kIC2jigY4iv/Vslg2tdMK8n7s5++TO5Uup3+BsNk1XL9qvgelb4zdp68EbXOfCm5b6uwRqxznjsX3dU20krhCdmsxpWf0qkBPrUq7attVwnpcNX5n6NSdXVWH8+U8aBlt5qtI28oqjgreIAwK7OhZzXiciwp5SfkgZRZw8c/4Irn82ZY4G4i16COztfcVG2neywptW/PBPpBwSo8vS5p/pf8H/O2jjqpyA65NAAE1WYMyv3IFxVY2mIimEzwErcfzAN8zSSufovdL0e/Ub9XCtVUe59Q0aDFQOvrGO3NwKv96EMy0nI9+PKEwMGYhe5N0fIEo+ltXtCrIepm0nTVDmJ8+AVPVNsrj3Sa56vHoR5OYSxhgIUStDhuDampEuPhcf+OMAXNZrJDqaEy+SUATBUJs/RYE4fuGZJtsZXIW54IjE0s3wVA4wN/52HL83nApbrJkG1YOzrBBGbOLnW8UYl+9HKU+ypQTG5wFLsxfW1JeRr/wvjirIfLTnVKiGVFhtsDTF83ymKyKI+Y3HtDItdb4lnqcdpg== 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)(7916004)(4636009)(376002)(346002)(136003)(396003)(366004)(39860400002)(451199015)(1076003)(33716001)(38070700005)(83380400001)(122000001)(86362001)(38100700002)(478600001)(6916009)(316002)(76116006)(66556008)(7416002)(66946007)(5660300002)(2906002)(186003)(44832011)(64756008)(71200400001)(8936002)(54906003)(66446008)(6486002)(6506007)(8676002)(6512007)(66476007)(26005)(4326008)(41300700001)(9686003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ge+rfPnGUZlKuMMu3tBtYZeVovgvrfVJtwTXJ0Dew5qAkZUcT2qTWm6goeHT?= =?us-ascii?Q?1ZvXamKMhjriLtUqXbc70dKBpHyvOPZd395HGbVrPB1fGR1mLY//BOLy9vX9?= =?us-ascii?Q?2t5LMbF6+5qOu1LfKJo+faTselY9019wd5AkPGB3uhKFLgv5+xJF7ISorR4T?= =?us-ascii?Q?3+enNpgPE9bd5TLuNe2IdPgOOiMcMZYsYoZ22hhgyjSMgyMyVC1fQZl74j8V?= =?us-ascii?Q?ox5zYnEfOatnV/AaMXwaBbjC/DPcwKWK8bW2YC/rZnr9wHqQ9MdwDWgQOuBJ?= =?us-ascii?Q?7moO6SgcNpUIfj7l1ZOLNEiqGPGWOI+oPdcE6boYMFmuvRd49MFeTPChXVnW?= =?us-ascii?Q?c/8WHp3T4eDlkFDqA6f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jC2j+xoS?= =?us-ascii?Q?AyawVU/CoEwWW0ZajVd58RtbxyZHWsH46RSoRsmukDTkegtJChyWlJLOyQt8?= =?us-ascii?Q?Vg0hahUpFDMnQZ8LN3Mbh6BxAt1GndNPNUmt1k2eDRgGWzvGDy1i4C/aGiZT?= =?us-ascii?Q?MmuYSEAuyyu/BdKDqLw0Tuj3in23rgJ4gTLq6UxHB1v5vUpTc4zAMIh6+NjW?= =?us-ascii?Q?aRY1cXKU/keQx9PAOJNtQgiz1BTFBsHWbw2K/37b1oBJIzQ4ZzdLcoswqc5A?= =?us-ascii?Q?xUCh2dqXhy9m5zjJCgZLtIcXC8GGsd/k9UtoxcWrlIgvbGBGBlmDWZBVHILD?= =?us-ascii?Q?ZqqTNpG+rVKgynzMbuwq7bozlEuOhbztdmH1VeX/s/oEaA2FHDogFr29QYRs?= =?us-ascii?Q?/A=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <47381449673B5E48B7667B1DF2DD94D8@eurprd04.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54d0c949-01e5-40ad-e38d-08dab36e4d56 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2022 14:12:35.1035 (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: v+a7j+KLTVqle9QDV+d2tQyllXI+culuItDxDf2WJhr4cWLrycrV6qkyu/Lf2hZVHll30x2ZB/XnIzPSh06pnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9377 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,URIBL_BLOCKED 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 On Fri, Oct 21, 2022 at 02:45:55PM +0200, Maxime Chevallier wrote: > +static int ipqess_netdevice_event(struct notifier_block *nb, > + unsigned long event, void *ptr) > +{ > + struct ipqess *ess =3D container_of(nb, struct ipqess, netdev_notifier)= ; > + struct net_device *dev =3D netdev_notifier_info_to_dev(ptr); > + struct netdev_notifier_changeupper_info *info; > + > + switch (event) { > + case NETDEV_CHANGEUPPER: > + info =3D ptr; > + > + if (dev->netdev_ops !=3D &ipqess_axi_netdev_ops) > + return NOTIFY_DONE; > + > + if (!dsa_slave_dev_check(info->upper_dev)) > + return NOTIFY_DONE; > + > + if (info->linking) > + ess->dsa_ports++; > + else > + ess->dsa_ports--; How many ipqess devices are there in a system? The netdev notifier should be a singleton, meaning it should be registered at module_init() and unregistered at module_exit(). You can then get the "ess" pointer as netdev_priv(dev), once you ensure that dev->netdev_ops is what you expect. The code is already wrong: you take *ess from the &ess->netdev_notifier reference, then you increment ess->dsa_ports based on the sole condition that "dev" (the interface on which the notification was already emitted) was an ess netdevice. But the "dev" pointer could be ess1, and the "ess" pointer could be the netdev_priv(ess0). Your logic would increment the dsa_ports of ess0 when a DSA switch joined ess1 (because all notifier handlers see the event). > + > + return NOTIFY_DONE; > + } > + return NOTIFY_OK; > +} > + > @@ -1201,12 +1255,19 @@ static int ipqess_axi_probe(struct platform_devic= e *pdev) > netif_napi_add(netdev, &ess->rx_ring[i].napi_rx, ipqess_rx_napi); > } > =20 > - err =3D register_netdev(netdev); > + ess->netdev_notifier.notifier_call =3D ipqess_netdevice_event; > + err =3D register_netdevice_notifier(&ess->netdev_notifier); > if (err) > goto err_hw_stop; > =20 > + err =3D register_netdev(netdev); > + if (err) > + goto err_notifier_unregister; > + > return 0; > =20 > +err_notifier_unregister: > + unregister_netdevice_notifier(&ess->netdev_notifier); > err_hw_stop: > ipqess_hw_stop(ess); > =20 > diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h b/drivers/net/= ethernet/qualcomm/ipqess/ipqess.h > index 9a4ab6ce282a..33cccaf6f143 100644 > --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h > +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h > @@ -171,6 +171,10 @@ struct ipqess { > struct platform_device *pdev; > struct phylink *phylink; > struct phylink_config phylink_config; > + > + struct notifier_block netdev_notifier; > + int dsa_ports; > + > struct ipqess_tx_ring tx_ring[IPQESS_NETDEV_QUEUES]; > =20 > struct ipqess_statistics ipqess_stats; > --=20 > 2.37.3 >=