Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp476041lqe; Sat, 6 Apr 2024 08:51:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUuBMO1RhI7VsyA5dF0gXLQQnZqZ7D9tuVL9NtuB6zRVDyznRsPKGCIsbtx53ETbO4q92aDfOhELM8tQ8c9CAN8xzZm0xNuC0ievHl4pg== X-Google-Smtp-Source: AGHT+IFl7YS9R8oeNjpjbkfSVvITqx1XnzTqmhFLmUtb8kGAZMLRj7lTbgxg/Nml7ec9WQfXEfNd X-Received: by 2002:a05:6a00:84c:b0:6ec:e733:c66f with SMTP id q12-20020a056a00084c00b006ece733c66fmr5347825pfk.0.1712418688594; Sat, 06 Apr 2024 08:51:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712418688; cv=pass; d=google.com; s=arc-20160816; b=E82zbLZ9aLzNuXR68999pe3JCxC9YU/T9/523qNxDQkTSLBTtbb+OltUs5obMtqHZh 1Jypy16Z/opyUiDdTo8x52ulKjIL6UdgHs7ljcTquiUK3Bck1AGkVNQ3zj27Yy0VhlIq 9XiM9ESbC9EzfzkV3I0P7UZPSesCpIY8jljIYRqimCb7Dynu63F7QyzN6f6PAlsYYyY5 l5IsTD/GV9heWiAwsfmfVLzfx5CVBaUgDxj0f4TsVnBozEQsrXtDIpTe5+wXQL8Z1O37 SFTX+nUaiJsLdQkm1F6/BqD3YW7BvyAY5BNCoQHY+5MwY5rmBpSJAd1n4CQqS7IZGzDT etQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Eq+WYVe7ZG4D7uYVbOzuAjHgqNe69MUAj/3ZLYiacM0=; fh=iFMvJPe5+iMz9fvI7Ro3QqHP2FRNSaC5Or4Przs7Ch4=; b=zOIN/W9rxIV9QCITuOIMck+eNmhHtDPf5XHxh0k4HPD14S9XrCAacpWlxKPrU4C6nI i6KU5UHDlCYhZI16X7GXb9lEc77maN8tHUmPpa6wA4U1GK79R//OxAZQyagD3+H5Pvyk SSqXxTb/AbMacQfXx+Ht+UebnN6Kt0msTnjieJsCxBKVy++/6QLG4xZEy6Zgspp8god2 zAmZwhMcOsQjAE3582XAFbWL8SjIU8QWBMQRFny5WWkTRmaRkaNZ0hwG967Dc/w2gihs xmjJdhWPKMVMOlEPTVgRmVgUhN4VSXPqHmCGknDLOexbQU3O2TnQl+W2V5uZfg5h7axC gaJA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=04ff6QxF; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-133988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133988-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q11-20020a056a00084b00b006ecea2c6a4csi3375389pfk.380.2024.04.06.08.51.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 08:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=04ff6QxF; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-133988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133988-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 19AC628246B for ; Sat, 6 Apr 2024 15:51:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3168F3BBD7; Sat, 6 Apr 2024 15:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="04ff6QxF" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 13F7F2B9CE; Sat, 6 Apr 2024 15:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712418679; cv=none; b=Z5AZhF19gtiMG9IN+4dmQH9WYJUwVdOPLo+azQ772g2K3NcNfIKaWEbSFhCu25P2oGr32ovBJmqFRz++5u5aTbnY4tenG5J+X8JfmAokkN47XOgvZ2kTnPafOOD1udSCguPD7xU5TiNiMKlIrYh7ItxfeejtUE9zd5iZ4CDBIf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712418679; c=relaxed/simple; bh=lp6fIx2QGzzZL15VJHwAUgYmgUhpH59peCuTj/YVL8E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PF8j3zfJoQn0c786XqKHiAnoD1zrUwVzhKhYjuES3wI6HXgwboWx6Cqu3OD5v0esGTwYKwEY0Ds3b3yvmV03q6/dH51NjMfcRE7lu1xsSRJptVBWW84aWrLL/qJqVJ/eDdjZa0KOIui4ZbKa7aXRBliDk5mPG90yR3o86oLOVu0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=04ff6QxF; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch 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=Eq+WYVe7ZG4D7uYVbOzuAjHgqNe69MUAj/3ZLYiacM0=; b=04ff6QxFGP+O57ChfgcHW3uZbO obGU9F50Oxw3CTxg7vb4GrGMfdCVexgtBoJOSO9sgvqihy+gz+r4aCJxv8rUzRrKZlSR14uvnn4q3 kCv/ByhY6HWGoufYbwjjkAIXYIGmJk7VIAADlfO54zQaXzWv91tjI6gj/23lGHfk58n4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rt8Jv-00CNRN-K5; Sat, 06 Apr 2024 17:51:07 +0200 Date: Sat, 6 Apr 2024 17:51:07 +0200 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 , Jonathan Corbet , Marek =?iso-8859-1?Q?Beh=FAn?= , Piergiorgio Beruto , Oleksij Rempel , =?iso-8859-1?Q?Nicol=F2?= Veronese , Simon Horman , mwojtas@chromium.org Subject: Re: [PATCH net-next v11 01/13] net: phy: Introduce ethernet link topology representation Message-ID: References: <20240404093004.2552221-1-maxime.chevallier@bootlin.com> <20240404093004.2552221-2-maxime.chevallier@bootlin.com> 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-Disposition: inline In-Reply-To: <20240404093004.2552221-2-maxime.chevallier@bootlin.com> On Thu, Apr 04, 2024 at 11:29:51AM +0200, Maxime Chevallier wrote: > Link topologies containing multiple network PHYs attached to the same > net_device can be found when using a PHY as a media converter for use > with an SFP connector, on which an SFP transceiver containing a PHY can > be used. > > With the current model, the transceiver's PHY can't be used for > operations such as cable testing, timestamping, macsec offload, etc. > > The reason being that most of the logic for these configuration, coming > from either ethtool netlink or ioctls tend to use netdev->phydev, which > in multi-phy systems will reference the PHY closest to the MAC. > > Introduce a numbering scheme allowing to enumerate PHY devices that > belong to any netdev, which can in turn allow userspace to take more > precise decisions with regard to each PHY's configuration. > > The numbering is maintained per-netdev, in a phy_device_list. > The numbering works similarly to a netdevice's ifindex, with > identifiers that are only recycled once INT_MAX has been reached. > > This prevents races that could occur between PHY listing and SFP > transceiver removal/insertion. > > The identifiers are assigned at phy_attach time, as the numbering > depends on the netdevice the phy is attached to. The PHY index can be > re-used for PHYs that are persistent. > > Signed-off-by: Maxime Chevallier Reviewed-by: Andrew Lunn Andrew