Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp63112rdf; Mon, 20 Nov 2023 16:25:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGp7WUXS9cqx1j4Cpt51xLTDNI+KoXFLqVAe6lyh/QvCJpsr9mZOAGWkoTWaLPlRQqrgvuA X-Received: by 2002:a05:6a20:6a0b:b0:18a:d78e:4ef8 with SMTP id p11-20020a056a206a0b00b0018ad78e4ef8mr811915pzk.1.1700526306275; Mon, 20 Nov 2023 16:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700526306; cv=none; d=google.com; s=arc-20160816; b=H2uejQeLNO0GSxBOsUVaLpuo/tVP8DMUQ9nyYY4ZXcmXeNbeAsmV0wZaXP7FmNts3T z5HlXjoQdd4Q+u1gNAwWWdiBg6qlhrCWS/MdLCYDcw17E3MQU2ViXYty1OzBPM2wk3IS sH9ucIAHVnndb4GjSH9bLKkyQB7WSIRdVV2Jbuju/6HXz+l2k4eXnos1MHHnFQgoUp5M VU1HQiIUy1CGT02rE+2qEu88Ld6r3YHdVxWboFf4mcEvvfoObSc/4YtfpbMHJDzvCBMM Y3OZx0QU8eg7ta64tGRQ9bi5p4VrXHgf9ldUmhl4uM6zobNTysF7evQl9/croZwdOPQc NvNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9vlgy8wfHdl3PYwUVlmm+Im+7f3OcAa0y0Xf8fqzxVQ=; fh=C0TfBJhgfV5KqzbS/KnZmKykOYUXFy9xkb3FDuNAbrk=; b=RUq/DosTBsG6giLRGynP1z59aWBkWtsPm0q17SsTm3p+kC+4kAELt1bYtIVq+Fg4Q8 F6c/viNCDu33/2cnCzzUp2Uvi/6fhRHvPW+4aDM/NXYPP5jObqeLzQLM1DNnucnPnIj8 rvTfrmyDGT6yc/O4gBGQz5gVzWYrzjU8poFZMHneewWvKd1GppPZqqtujs7RVQ66yFB5 z4UQkQxQsLmrQwoiYRNrHgjRdVZudMK/xDUW681+QFZw5+++SnJ42AAkGJjnuBGAp4Cf glbOASKqasFaxcc8GgeQUodxaxxbT2uJSsnHxzo+8MIqAFVqcTpQxpC9ztGUq+iIQ3FG 66Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=L7BwsBkX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k30-20020aa7999e000000b006c339539752si8738698pfh.363.2023.11.20.16.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 16:25:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=L7BwsBkX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 65FDD809C16E; Mon, 20 Nov 2023 16:25:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbjKUAY5 (ORCPT + 99 others); Mon, 20 Nov 2023 19:24:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbjKUAY4 (ORCPT ); Mon, 20 Nov 2023 19:24:56 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A3FBA; Mon, 20 Nov 2023 16:24:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=9vlgy8wfHdl3PYwUVlmm+Im+7f3OcAa0y0Xf8fqzxVQ=; b=L7BwsBkXDv6yE5ugjFsPF6yKSj jTqghU9sCbh/qP3kYQo+fDvDxqqLcFcwt3XdLqdMHA3GEPhDDHoJnIQWpqRRAUk52zeEHwXE0UoPx Dq9d1JjI57DARF73zid/0LBEJzurXPf5b4yYEAi3yfYuUxkzZRFCa0Iu5kDoTVVaC71o=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1r5EZL-000hsQ-Pb; Tue, 21 Nov 2023 01:24:47 +0100 Date: Tue, 21 Nov 2023 01:24:47 +0100 From: Andrew Lunn To: Maxime Chevallier 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 , =?iso-8859-1?Q?K=F6ry?= Maincent , Jesse Brandeburg Subject: Re: [RFC PATCH net-next v2 01/10] net: phy: Introduce ethernet link topology representation Message-ID: <9079c9f5-5531-4c38-b9c9-975ed3d96104@lunn.ch> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-2-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231117162323.626979-2-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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 20 Nov 2023 16:25:03 -0800 (PST) > +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(...); > 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. > 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? > +enum phy_upstream { > + PHY_UPSTREAM_MAC, > + PHY_UPSTREAM_SFP, > + PHY_UPSTREAM_PHY, > +}; Please document what these actually mean. Andrew