Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp11330rdb; Fri, 5 Jan 2024 00:32:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBV2Pt1kBsnNp9inl7ztzz1DaEfMWN2pYVEPQ89pMCmuqsohaGdmj3MLB542zc3eK+Nfh2 X-Received: by 2002:a05:6808:1401:b0:3bb:7cce:1ec6 with SMTP id w1-20020a056808140100b003bb7cce1ec6mr2213309oiv.28.1704443556637; Fri, 05 Jan 2024 00:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443556; cv=none; d=google.com; s=arc-20160816; b=G3Q/CigVpZSJJj6Q00krrn8jFa2AA/HLqQab5DF6zxCdU7tU8IQezq3RGjzKZRChAW UMBxupoC2LTqdJjtlek7kTRlE2N4n3FQx8n9ZXJ+tVBDovHa3U7zs1WE1o9nZoj9NjQD aI8y330peiPKE3XPiETXou3oJSmY4gpWXNN1wRz2xIkUvvwF+qal7RSeL7ZFF3iwrcTM qT9FM3K2cJy9t7HvRLkZ0MyEsFXTwU64Ms6h6yuKIuvct4yoWf4hrXqrQz+YipPewFVR 9zj1BQrXD52wtEsaUHOl52waOT7ZWWUji2+AiEGltewvSXq0mXqQBRl9a5iuSwKX4ym9 BG7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=kmyYmzVm/qP7CoTti/7/1uH5HNF3/IzXKxXhez/kx98=; fh=OsPM//bQrMEF0Wcb3Eb5VSpvLEX7YsyJSTP+La8dx/M=; b=IzfH8kuOzz77lm5Pu/AfGtXzHvBYzSrwRXuBb7lii7GW5u2MO7glb/NR95GSl2/b6E gKMtHwQbado63pzoljTi9kl9rJeaiUhTPkszVsEJ/xADBQM23TtKmN6tOFF4TNTaI8gV 2jaQr1+sMxKTVLFgg6XTv3tsIVM+eq5gMwe4sL3QtYjSAKJFx3q96xoyVfW591FS0pU7 cE61ULw6wt+3CDWpwNkYuMEYiZyIxJPrX615P+y1djZbCvSJ9mjpNraQgC6iXKNUZbrr XWob0a+F/dawj+yZADxRD97SO69rbeR4sPX+c7tvkt5Mkn3UAD2cZkAacvqCYb/CMXMR /ELA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bk8VwQGY; spf=pass (google.com: domain of linux-kernel+bounces-17604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f13-20020a0cf3cd000000b006806781ace9si1324649qvm.42.2024.01.05.00.32.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:32:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bk8VwQGY; spf=pass (google.com: domain of linux-kernel+bounces-17604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5F0441C22D6F for ; Fri, 5 Jan 2024 08:32:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75A3021359; Fri, 5 Jan 2024 08:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="bk8VwQGY" X-Original-To: linux-kernel@vger.kernel.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 666BF208BD; Fri, 5 Jan 2024 08:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id D578C40005; Fri, 5 Jan 2024 08:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1704443541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmyYmzVm/qP7CoTti/7/1uH5HNF3/IzXKxXhez/kx98=; b=bk8VwQGYlzu3Ebd+X3+nP4+BE4bFXE9ZGZCBQp/VY0+vekrlAvi1sqnw9zBzxXbJwSy9ap kbNxKxAMlcat2ng9Dhx/oacFdFEiMzhduDajPQ7sjNcsFiK4SuyMSsAiTQR2H4iPTF04rV XDv9Qc5Wx1LeHhGJuoQi9NOsdk/SjX8/WwBPh7aGVZkn5QhJBrJ5Tq01tAn5noNEtcjlY9 i+/wW5+5O1caAfCHluzAKSugHz/+jMpTyGpYXNJBjPIeJsBJOgOg5TNHqQOKtsTHKYtOV4 7UnPxsS7wojv9FfAlzELNdVPF60uDafpV75k0D7e+zXGN5Qq+3V3iTfUpDPgWw== Date: Fri, 5 Jan 2024 10:29:18 +0100 From: Maxime Chevallier To: Jakub Kicinski Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?B?S8O2cnk=?= Maincent , Jesse Brandeburg , Jonathan Corbet , Marek =?UTF-8?B?QmVow7pu?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?B?Tmljb2zDsg==?= Veronese , Simon Horman Subject: Re: [PATCH net-next v5 01/13] net: phy: Introduce ethernet link topology representation Message-ID: <20240105102918.24398552@device-28.home> In-Reply-To: <20240104151242.52fa8cb4@kernel.org> References: <20231221180047.1924733-1-maxime.chevallier@bootlin.com> <20231221180047.1924733-2-maxime.chevallier@bootlin.com> <20240104151242.52fa8cb4@kernel.org> Organization: Bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com Hi Jakub, On Thu, 4 Jan 2024 15:12:42 -0800 Jakub Kicinski wrote: > On Thu, 21 Dec 2023 19:00:34 +0100 Maxime Chevallier wrote: > > @@ -2441,6 +2442,7 @@ struct net_device { > > #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) > > struct netprio_map __rcu *priomap; > > #endif > > + struct phy_link_topology link_topo; > > Perhaps others would disagree but can we make this a pointer instead? > Only allocate it on demand, when first PHY gets attached? > Both saves space and netdevice.h will no longer need to know the > definition of the struct. > > Complete noob question but I thought PHYs get attached at ndo_open > time for drivers, don't they? We shouldn't want to re-ID in that case. I'll give it a try, it could be doable to try to keep the index for _some_ PHYs. I had a first try at this in the very first iteration, but that was lost when converting to xarray for the index management. Since the phy_device keeps track of its own index, we can try to re-use it, but I can see it becoming difficult if we destroy the topology when all PHYs are detached (after ndo_close). When re-creating the xarray at the next ndo_open, we would need to know what was the previous next_index, and we can't know that until PHYs are all re-attached. For now it would work because in most cases, we only have one PHY behind the MAC we can guarantee won't go away, but there are devices out-there with 2 PHYs connected to the same MAC with a MUX in the middle (that's one thing this series prepares for), and here it would be more complex to re-allocate the topology while knowing what's the next unused index. Hope that makes sense :) To summarize, I don't think we can easily both dynamically allocate/destroy the topology based only on the presence of at least one PHY, and try to keep the PHY index the same for non-hot-pluggable PHYs. > > > struct phy_device *phydev; > > struct sfp_bus *sfp_bus; > > struct lock_class_key *qdisc_tx_busylock; > > > @@ -10872,6 +10873,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, > > #ifdef CONFIG_NET_SCHED > > hash_init(dev->qdisc_hash); > > #endif > > + phy_link_topo_init(&dev->link_topo); > > + > > dev->priv_flags = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM; > > setup(dev); > > > > I think you're missing a call to xa_destroy() somewhere, no? Arg you're right... I was under the false assumption that because the xarray wasn't dynamically allocated, we didn't need to perform any cleanup, thanks for spotting this. Maxime