From patchwork Fri Apr 25 14:14:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 884578 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 F2535255E30; Fri, 25 Apr 2025 14:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745590527; cv=none; b=svMnhf1QlA3cJ5ITYshy0pbVSeAbOJV+/lbMtVd2SrG31crUClMtJy+/vIHy+KeBUUDw9gDVY4TM8ncGB7GD0U27Zm3Y0ew+6FHMrRSxo2AuRLG1iqy0OTQ+lJnnMt5P5e1cHs/pvPyaEAKNpGqSmhJu1ixdVwJXWA2IpGydh6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745590527; c=relaxed/simple; bh=5dISe7KMP2MHp1jX5PEsqWuvrZF5gWM/0+w1D+o1XLA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=J5CW30fNIwt3OoT0MQYpUrdpGC10qXJ3I0qwhUiVfb+v4VDunjLTW0cmMpST1dcKfGln/sYIhs+7MfdSAiNc3qd9ZpAkcWP5EzwMoKDPpGKHeqPxeZhabZCSeuXZgAxuNII7tX270gT+rdG6ErugAaX3LmIVcjqCDNDXP+ygtJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Veo6Z4dH; arc=none smtp.client-ip=217.70.183.199 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Veo6Z4dH" Received: by mail.gandi.net (Postfix) with ESMTPSA id 1939443A13; Fri, 25 Apr 2025 14:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1745590516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=rBmHqc79xOObMUSrcBLjs2T46vN3sbAfY07gHFNec9w=; b=Veo6Z4dHat851NSzQgnnlcLOdKgIjyJFNGQDc8h8ehxi4Ap+kW/1GSnYreSTP80ZB9+qta ldvOsWO8jYJziz6Iqa+s6CHofUQS58ihrquP8xVAN4QjpICg4BL9KJfDSHLHFwQ+zMpDN1 dlbxPQvHZOB6c8PSiHAutUCinQn0h1W2r0zZ7bOtuNCxtUsaepYGSnFvkVd9npB3/H1+lt dHSdWePCeV/MyMYRFSkaNY5av0s7w0/XFr0yQXRfBK9ASrorBL6Pbil0vjnKhMtJ30T1me vs2mj+N0hxAUwZnHacPX1X3OFlepaCu9llIkBAoPAQeT+F5gd6fL2PwB3T/LFQ== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , 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?q?K=C3=B6ry_Maincent?= , =?utf-8?q?Marek?= =?utf-8?q?_Beh=C3=BAn?= , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Antoine Tenart , devicetree@vger.kernel.org, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Romain Gantois , Daniel Golle , Dimitri Fedrau Subject: [PATCH net-next v5 00/14] Introduce an ethernet port representation Date: Fri, 25 Apr 2025 16:14:53 +0200 Message-ID: <20250425141511.182537-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvhedvheehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepueefvedvgffgvdetleeihfdugfdtgfffueduhedtieevieeghefgieduleduleefnecuffhomhgrihhnpehnvghtuggvvhgtohhnfhdrihhnfhhopdhlphgtrdgvvhgvnhhtshdpkhgvrhhnvghlrdhorhhgnecukfhppedvrgdtudemtggsudelmeekugegheemgeeltddtmeeiheeikeemvdelsgdumeelvghfheemvgektgejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkegugeehmeegledttdemieehieekmedvlegsudemlegvfhehmegvkegtjedphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepfedupdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopehmrgigihhmv gdrtghhvghvrghllhhivghrsegsohhothhlihhnrdgtohhmpdhrtghpthhtohepnhgvthguvghvsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrghrmhdqmhhsmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehthhhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhg X-GND-Sasl: maxime.chevallier@bootlin.com Hi everyone, This is a new version of the first phase for Ethernet port support. Before going into the details, a few important notes : - This is only a first phase. It instantiates the port, and leverage that to make the MAC <-> PHY <-> SFP usecase simpler. - Next phase will deal with controlling the port state, as well as the netlink uAPI for that. - The end-goal is to enable support for complex port MUX. This preliminary work focuses on PHY-driven ports, but this will be extended to support muxing at the MII level (Multi-phy, or compo PHY + SFP as found on Turris Omnia for example). - The naming is definitely not set in stone. I named that "phy_port", but this may convey the false sense that this is phylib-specific. Even the word "port" is not that great, as it already has several different meanings in the net world (switch port, devlink port, etc.). I used the term "connector" in the binding. A bit of history on that work : The end goal that I personnaly want to achieve is : + PHY - RJ45 | MAC - MUX -+ PHY - RJ45 After many discussions here on netdev@, but also at netdevconf[1] and LPC[2], there appears to be several analoguous designs that exist out there. [1] : https://netdevconf.info/0x17/sessions/talk/improving-multi-phy-and-multi-port-interfaces.html [2] : https://lpc.events/event/18/contributions/1964/ (video isn't the right one) Take the MAchiatobin, it has 2 interfaces that looks like this : MAC - PHY -+ RJ45 | + SFP - Whatever the module does Now, looking at the Turris Omnia, we have : MAC - MUX -+ PHY - RJ45 | + SFP - Whatever the module does We can find more example of this kind of designs, the common part is that we expose multiple front-facing media ports. This is what this current work aims at supporting. As of right now, it does'nt add any support for muxing, but this will come later on. This first phase focuses on phy-driven ports only, but there are already quite some challenges already. For one, we can't really autodetect how many ports are sitting behind a PHY. That's why this series introduces a new binding. Describing ports in DT should however be a last-resort thing when we need to clear some ambiguity about the PHY media-side. The only use-cases that we have today for multi-port PHYs are combo PHYs that drive both a Copper port and an SFP (the Macchiatobin case). This in itself is challenging and this series only addresses part of this support, by registering a phy_port for the PHY <-> SFP connection. The SFP module should in the end be considered as a port as well, but that's not yet the case. However, because now PHYs can register phy_ports for every media-side interface they have, they can register the capabilities of their ports, which allows making the PHY-driver SFP case much more generic. Let me know what you think, I'm all in for discussions :) Regards, Changes in V5 : - renamed the bindings to use the term "connector" instead of "port" - Rebased, and fixed some issues reported on the 83822 driver - Use phy_caps Changes in V4 : - Introduced a kernel doc - Reworked the mediums definitions in patch 2 - QCA807x now uses the generic SFP support - Fixed some implementation bugs to build the support list based on the interfaces supported on a port V4: https://lore.kernel.org/netdev/20250213101606.1154014-1-maxime.chevallier@bootlin.com/ V3: https://lore.kernel.org/netdev/20250207223634.600218-1-maxime.chevallier@bootlin.com/ RFC V2: https://lore.kernel.org/netdev/20250122174252.82730-1-maxime.chevallier@bootlin.com/ RFC V1: https://lore.kernel.org/netdev/20241220201506.2791940-1-maxime.chevallier@bootlin.com/ Maxime Maxime Chevallier (14): dt-bindings: net: Introduce the ethernet-connector description net: ethtool: Introduce ETHTOOL_LINK_MEDIUM_* values net: phy: Introduce PHY ports representation net: phy: dp83822: Add support for phy_port representation net: phy: Create a phy_port for PHY-driven SFPs net: phy: Introduce generic SFP handling for PHY drivers net: phy: marvell-88x2222: Support SFP through phy_port interface net: phy: marvell: Support SFP through phy_port interface net: phy: marvell10g: Support SFP through phy_port net: phy: at803x: Support SFP through phy_port interface net: phy: qca807x: Support SFP through phy_port interface net: phy: Only rely on phy_port for PHY-driven SFP net: phy: dp83822: Add SFP support through the phy_port interface Documentation: networking: Document the phy_port infrastructure .../bindings/net/ethernet-connector.yaml | 47 +++ .../devicetree/bindings/net/ethernet-phy.yaml | 18 + Documentation/networking/index.rst | 1 + Documentation/networking/phy-port.rst | 111 +++++++ MAINTAINERS | 3 + drivers/net/phy/Makefile | 2 +- drivers/net/phy/dp83822.c | 77 +++-- drivers/net/phy/marvell-88x2222.c | 96 +++--- drivers/net/phy/marvell.c | 100 +++--- drivers/net/phy/marvell10g.c | 37 +-- drivers/net/phy/phy_device.c | 312 +++++++++++++++++- drivers/net/phy/phy_port.c | 182 ++++++++++ drivers/net/phy/qcom/at803x.c | 64 +--- drivers/net/phy/qcom/qca807x.c | 75 ++--- include/linux/ethtool.h | 33 +- include/linux/phy.h | 38 ++- include/linux/phy_port.h | 92 ++++++ include/uapi/linux/ethtool.h | 20 ++ net/ethtool/common.c | 265 +++++++++------ 19 files changed, 1186 insertions(+), 387 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ethernet-connector.yaml create mode 100644 Documentation/networking/phy-port.rst create mode 100644 drivers/net/phy/phy_port.c create mode 100644 include/linux/phy_port.h