Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp340600rdh; Thu, 23 Nov 2023 05:34:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+bMJJGjZRaSwCHudKkiLsadrITPooHTnL+195iWUTWmFpG5Lu8zta0cM5guIwVHEmCzxX X-Received: by 2002:a17:903:22d1:b0:1cf:6542:b4c8 with SMTP id y17-20020a17090322d100b001cf6542b4c8mr3646318plg.21.1700746469883; Thu, 23 Nov 2023 05:34:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700746469; cv=none; d=google.com; s=arc-20160816; b=NowUn+0AHuDpzaVzzwSt4kGh8bJRh4WBVI5HD5h55Pb5bMX65s/Efcihtd2GOFwcDK J78lWbJdHAuI1PEznExQhVkqKOIDGDj8u2Jd5B7dCWlqgfvedix/Gv2JM9HmveRQEyk0 nNXSs81R/yiXZeC8WOaDbjGSg9akuMaXe/Eq7osd8DbIerFoFmVwHghlYTo/P9OuPn99 /GQUQ+4/1G/weOzFQeABzm1Goet9TKsjVWn+E001hhqlgnymGiHdfJD11M7PDqCYAtfs TQ9E8RYD/Pi9jFbPCpMmRvTC2bFgzqiQMl9b0E9BcDF905Vd9DDSOM1uk38uyFSdmAXV TilA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=cinKUmZ4zkbIH1tUjGf+OdP+ZTy+Ry1+qtGbfY1mZ8A=; fh=IMYGoU7jS3HaS5iEdQiyiDhnAR9nxxNosD4SnzXeWBc=; b=t3ZA+bgKiaJW5Ci30g4lZ/Em7iG/vK+GPbwQcNB2Ixb8dfTuNiEngGJYqpC0uPs4L2 12WXsq3QWcLed5Mzd5VQH5Qve1bewMfUDLMcGpmBXPKHqagGgapJJG09yBQGmQgiTSQ4 HAlo9GjP9La7/e49gw658zHPK0+Z3meaeXJ1E6kLZsZGtwMwC7FEoaZdhMtMN+pGq4ur s5YPG7E5vbP9gtUMEDgc21nB5Q/hlvAWHF6V5pd5+Kf7HJmeoY44vfRdG5Jqv7024d/z KHeg9nf7mlmY9a32iSH/iJia/+UEmilGqIr79goDn7sBbNHgUqj5OxTilMNY4brq/tf4 pC9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UOO8Za6H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h5-20020a170902b94500b001c5de4a5b4esi1076961pls.597.2023.11.23.05.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 05:34:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UOO8Za6H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7183E82972C9; Thu, 23 Nov 2023 05:34:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345487AbjKWNeM (ORCPT + 99 others); Thu, 23 Nov 2023 08:34:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345468AbjKWNeL (ORCPT ); Thu, 23 Nov 2023 08:34:11 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99BF0BA; Thu, 23 Nov 2023 05:34:14 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2F59620005; Thu, 23 Nov 2023 13:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700746453; 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=cinKUmZ4zkbIH1tUjGf+OdP+ZTy+Ry1+qtGbfY1mZ8A=; b=UOO8Za6HjSl2UudqbG/0pNhsaYzO/1IlyebbDxI+/Q1ridQHcUG1e2KxWTsYCLh74nqsWj Ny45otfpj5EqCSTIh4iBCX12ZggZ2RLloAGQu45f+254IcKVlH4TgyWocDfInwkt6K6/Qn ULGwlks2vcTfpsacv5Wy5TdOgl4FlYCptjDdUysrt2NsGpQHwp0oZ274nQFPBIQcB2CfzK NYfHUSG28wqYuGkZK8DsaPDzLDFanOI9yC4vs8EcLXNLuh746PR8flwQDE08+3GspoAQm/ CIvfTaZgV89treUfuBt0ny2T8XYLoPC89uqJyCL7XorJeMdAxAvQjD3DDiJckw== Date: Thu, 23 Nov 2023 14:34:08 +0100 From: Maxime Chevallier To: Andrew Lunn Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Jakub Kicinski , 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 Subject: Re: [RFC PATCH net-next v2 01/10] net: phy: Introduce ethernet link topology representation Message-ID: <20231123143408.3cae1b04@device.home> In-Reply-To: <9079c9f5-5531-4c38-b9c9-975ed3d96104@lunn.ch> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-2-maxime.chevallier@bootlin.com> <9079c9f5-5531-4c38-b9c9-975ed3d96104@lunn.ch> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 05:34:27 -0800 (PST) Hello Andrew, On Tue, 21 Nov 2023 01:24:47 +0100 Andrew Lunn wrote: > > +int link_topo_add_phy(struct link_topology *lt, struct phy_device *phy, > > + enum phy_upstream upt, void *upstream) > > +{ > > + ret = xa_alloc_cyclic(<->phys, &phy->phyindex, pdn, xa_limit_32b, > > + <->next_phy_index, GFP_KERNEL); > > + if (ret) > > + goto err; > > + > > + return 0; > > It looks like that could be just return xa_alloc_cyclic(...); Indeed, nice catch > > > diff --git a/include/linux/link_topology.h b/include/linux/link_topology.h > > I think this filename is too generic. Maybe phy_link_topology.h, or > move it into include/net. > > > +struct phy_device *link_topo_get_phy(struct link_topology *lt, int phyindex); > > +int link_topo_add_phy(struct link_topology *lt, struct phy_device *phy, > > + enum phy_upstream upt, void *upstream); > > + > > +void link_topo_del_phy(struct link_topology *lt, struct phy_device *phy); > > What is the locking for these functions? Are you assuming RTNL? Maybe > add ASSERT_RTNL(); into them to make this clear. Indeed I assume it, I'll add an assert and document that clearly then. > > > diff --git a/include/linux/link_topology_core.h b/include/linux/link_topology_core.h > > Again, i think this filename is too generic. > > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > > index a16c9cc063fe..7021a0d3d982 100644 > > --- a/include/linux/netdevice.h > > +++ b/include/linux/netdevice.h > > @@ -40,7 +40,6 @@ > > #include > > #endif > > #include > > - > > #include > > Whitespace change. > > > #include > > #include > > @@ -52,6 +51,7 @@ > > #include > > #include > > #include > > +#include > > > > struct netpoll_info; > > struct device; > > @@ -2405,6 +2405,7 @@ struct net_device { > > #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) > > struct netprio_map __rcu *priomap; > > #endif > > + struct link_topology link_topo; > > struct phy_device *phydev; > > struct sfp_bus *sfp_bus; > > struct lock_class_key *qdisc_tx_busylock; > > diff --git a/include/linux/phy.h b/include/linux/phy.h > > index 3cc52826f18e..d698180b1df0 100644 > > --- a/include/linux/phy.h > > +++ b/include/linux/phy.h > > @@ -543,6 +543,8 @@ struct macsec_ops; > > * @drv: Pointer to the driver for this PHY instance > > * @devlink: Create a link between phy dev and mac dev, if the external phy > > * used by current mac interface is managed by another mac interface. > > + * @phyindex: Unique id across the phy's parent tree of phys to address the PHY > > + * from userspace, similar to ifindex. It's never recycled. > > * @phy_id: UID for this device found during discovery > > * @c45_ids: 802.3-c45 Device Identifiers if is_c45. > > * @is_c45: Set to true if this PHY uses clause 45 addressing. > > @@ -640,6 +642,7 @@ struct phy_device { > > > > struct device_link *devlink; > > > > + int phyindex; > > Is this int, or unsigned int? Is a negative value possible and legal? You're right this should be unsigned. I've also missed properly documenting correct values and their meaning (like phyindex 0 would be no index assigned). > > > +enum phy_upstream { > > + PHY_UPSTREAM_MAC, > > + PHY_UPSTREAM_SFP, > > + PHY_UPSTREAM_PHY, > > +}; > > Please document what these actually mean. I'll do this as well. Thank you for reviewing, Maxime > > Andrew