From patchwork Tue Aug 1 18:57:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13337180 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 67580200AC for ; Tue, 1 Aug 2023 18:57:45 +0000 (UTC) Received: from pandora.armlinux.org.uk (unknown [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6629A10C1 for ; Tue, 1 Aug 2023 11:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VbILsHnal4xKBGioU0EAyYH9GfmXUZxWRJr/xsHB78I=; b=YbtdvS8nxTQyujUXjpddqC8Gqo vfU5x18XFv9nkiGK8vCfJAvU5cxVbMqD3D6uBPsUuPSfyZrUPVI0hG8bfndHJSH20Y8HnospbZHWG G8qV2Nw52bSxGpobWwaalC7+veWxRiKS+ry5PVcQQPwYnQKKp6V3UbswsfFPnVLqfNLMBpWHCn4vJ 0mnxB6kCE79FJ9TtUjZRMezj9el/KQ4XRFPP1E+1YJVUcqxD4tUSoLXzLxRiNiOoRwipqF/zfuDOQ 3LUagF0YPD0WV02YwMnX8hAgr8C6Y/y5nGhgUh+IZO58p9MBZ8Xh/jSJKgGHfK1+1DUASaAKQoB+e SIyLLb3Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46386 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qQuYo-0004WC-1K; Tue, 01 Aug 2023 19:57:34 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qQuYo-001WX1-H2; Tue, 01 Aug 2023 19:57:34 +0100 From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Frank Wunderlich , "David S. Miller" , Eric Dumazet , Eric Woudstra , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH RFC net-next] net: phy: move marking PHY on SFP module into SFP code Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 01 Aug 2023 19:57:34 +0100 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Move marking the PHY as being on a SFP module into the SFP code between getting the PHY device (and thus initialising the phy_device structure) and registering the discovered device. This means that PHY drivers can use phy_on_sfp() in their match and get_features methods. Signed-off-by: Russell King (Oracle) --- Eric Woudstra has a SFP module that has a realtek PHY on that could be driven by the realtek PHY driver - except that the PHY is behind a Rollball access implementation that only supports clause 45 access. This is a work in progress, but it seems useful in these situations that drivers should know whether the PHY is on a module very early on, so that a particular PHY driver instance can choose whether or not to drive the instance, or maybe use a different PHY driver instance to drive it - thus allowing a separate set of function pointers for the clause-45 only accessable PHY. Some experimental patches can be found at: https://gist.github.com/ericwoud/d912301a93cd41b39621a65cc372a5c0#file-0000-oem-sfp-2-5g-t-patches-realtek-short-c and onward discussion prompted this patch. Ignore the first non-patch C file! drivers/net/phy/phy_device.c | 2 -- drivers/net/phy/sfp.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 61921d4dbb13..da544faf1661 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1487,8 +1487,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, if (phydev->sfp_bus_attached) dev->sfp_bus = phydev->sfp_bus; - else if (dev->sfp_bus) - phydev->is_on_sfp_module = true; } /* Some Ethernet drivers try to connect to a PHY device before diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index d855a18308d7..4ecfac227865 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1763,6 +1763,9 @@ static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45) return PTR_ERR(phy); } + /* Mark this PHY as being on a SFP module */ + phy->is_on_sfp_module = true; + err = phy_device_register(phy); if (err) { phy_device_free(phy);