From patchwork Fri Jul 15 16:01:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2850AC43334 for ; Fri, 15 Jul 2022 16:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dVtz2WFyIDMUf28W38+Oat90NEJci3uTaIy/rzVJ8Gg=; b=tVJmynul3G1u/qqied+p1m6qkh MyS/wn4RmnEHvnW30DXzhlULbZaB98RoDiFydFkf+7kkRSWdBe2bDSnddfgAO2ZEXmhCpIgWvDUoy l9XBaydaWQZztvS4fD5Hq9zas8ajJmjhZr/czkGMC1ymdQIxJEIeIiDmKS0vLgUdMGx1SxAdNafKG iJLQs3awcSilvfpblkFfR9B9uqvNJduYLEuE7XSaOOZd/e23N8KMWJEJROQPDpvDLj29YVjhh5yVA n+3xkD6bOgx23/xczQ/84RwM6eduZxsOGRkpucACPtRgNxbgKiD2mpJXfzeE4AQkF1nn8c6MX4W8g mNA2WP1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlQ-008bac-OK; Fri, 15 Jul 2022 16:02:00 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNl8-008bUo-NM; Fri, 15 Jul 2022 16:01:44 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dVtz2WFyIDMUf28W38+Oat90NEJci3uTaIy/rzVJ8Gg=; b=ORpmgDmRKp0ZVMMxf0AwIgU0ke 1HW/rY1+lW47v5RaKJwilfdzHqR9O47lvJL2djla3gOJn2giyt0AKcMnS5CYNZ+oMqQOKRAqavn2R kwofOhoeVJlyS+p0T2ePc/SdNQAkdLlSl23tnl5njaaaU/CbZJpKyyr8KYWuLio1/EuS203GKI4mC Z7LhqgSRtslp3mizKHvAfuowgOjTXNlyqZ8mURQJ3uJd1EdGI8kDKhkdqGsXbXaJ+Evn7aBb5HmwL oejki5KRVbREu1H2/UlKH60RzyOhcNHcWffAD+G/1DM3lPg2a7u0wkvzjnKAN2enJAz3LghdvxRPM moLo8y/Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46046 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.94.2) (envelope-from ) id 1oCNku-0007CO-5a; Fri, 15 Jul 2022 17:01:28 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNkt-006e3Z-F4; Fri, 15 Jul 2022 17:01:27 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 1/6] net: phylink: split out and export interface to caps translation MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:27 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090142_797938_18172EC1 X-CRM114-Status: GOOD ( 13.73 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org phylink_get_linkmodes() translates the interface mode into a set of speed and duplex capabilities which are masked with the MAC modes to then derive the link modes that are available. Split out the initial transformation into a new function phylink_interface_to_caps(), and export it, which will be useful when setting the maximum fixed link speed in DSA code. Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 30 ++++++++++++++++++++++-------- include/linux/phylink.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9bd69328dc4d..1d4a48d5a5ac 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -297,17 +297,12 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes, } /** - * phylink_get_linkmodes() - get acceptable link modes - * @linkmodes: ethtool linkmode mask (must be already initialised) + * phylink_interface_to_caps() - translate an interface mode to phylink caps * @interface: phy interface mode defined by &typedef phy_interface_t - * @mac_capabilities: bitmask of MAC capabilities * - * Set all possible pause, speed and duplex linkmodes in @linkmodes that - * are supported by the @interface mode and @mac_capabilities. @linkmodes - * must have been initialised previously. + * Translate the @interface mode to a phylink MAC capabilities mask. */ -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities) +unsigned long phylink_interface_to_caps(phy_interface_t interface) { unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; @@ -381,6 +376,25 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, break; } + return caps; +} +EXPORT_SYMBOL_GPL(phylink_interface_to_caps); + +/** + * phylink_get_linkmodes() - get acceptable link modes + * @linkmodes: ethtool linkmode mask (must be already initialised) + * @interface: phy interface mode defined by &typedef phy_interface_t + * @mac_capabilities: bitmask of MAC capabilities + * + * Set all possible pause, speed and duplex linkmodes in @linkmodes that + * are supported by the @interface mode and @mac_capabilities. @linkmodes + * must have been initialised previously. + */ +void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, + unsigned long mac_capabilities) +{ + unsigned long caps = phylink_interface_to_caps(interface); + phylink_caps_to_linkmodes(linkmodes, caps & mac_capabilities); } EXPORT_SYMBOL_GPL(phylink_get_linkmodes); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6d06896fc20d..692be109a9fa 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -518,6 +518,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); #endif +unsigned long phylink_interface_to_caps(phy_interface_t interface); void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, From patchwork Fri Jul 15 16:01:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DD0DC433EF for ; Fri, 15 Jul 2022 16:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5XcgCX5IEnr5TgMlYC+cQseNSP2R9E/qzSlMeqbtQYw=; b=mtDFNd27prKrQnw3VFSkYwugs8 Gigddkip3rEHSGveckFt5KVVkcM0CdySFL9i0wLVaxDCN38hnYjZFA9XtNN7eh+6Y3yE61ii5ulxM p6RN0XnHncn/Sds3q5F9z9aOdzFOLge3DczrmXoyYWNUVn1MwpXC6jQlb421KawRpH3IRE5Uo3tBR wRLnbUP6x7yApL+GAWK1Q06ppiiZGNG7gWZcfs3L37n0aNqRIPjCx2uRA4WNtlvlqRxKA24o6BZHT 9YaZtSmxfNfAVzJ/7gqY7FjTB7PjLllnwpHIb2zQtYzGLFVSYZV+uevD4a/f3IP0yAz5JOX3szOJ5 JGDruTow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlc-008bfZ-Rb; Fri, 15 Jul 2022 16:02:12 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlE-008bWe-TO; Fri, 15 Jul 2022 16:01:50 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5XcgCX5IEnr5TgMlYC+cQseNSP2R9E/qzSlMeqbtQYw=; b=eAEe1dZ3dEKHvCC5x6n3Pkepcg 4gsGy+Jcx5PFGq1jVI95XyMZoQ1qfUKvLAzMaJHHHnzHoV5PI6Q9If6eEvxRLH1AvWYF5PMhK4Nh0 T6mCY30xODECmugUBgUp0Rcz9/ui0QRr7Nas1aRUaQPWZcUCIKSLNApXo0WcCwDxNOgzTlvW8T/fP ENn20uelVEro+PJ+kw4iNiexW7BWXh3Wc1oty0mQV438h0z/wj4XByw7mwDoaAaY2nVEWv1j21RqZ St36PWhGLazvW/1oy7zsxgUtQFsID21vU/CCanEltavXYBK2xyv5MpiIKR4914QLEYuS94t/RerIT +XnvAR7g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46048 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.94.2) (envelope-from ) id 1oCNkz-0007Cj-F1; Fri, 15 Jul 2022 17:01:33 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNky-006e3g-KA; Fri, 15 Jul 2022 17:01:32 +0100 In-Reply-To: References: From: Russell King (Oracle) To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 2/6] software node: allow named software node to be created MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:32 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090148_977469_A9AE58F1 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Vladimir Oltean Allow a named software node to be created, which is needed for software nodes for a fixed-link specification for DSA. Signed-off-by: Vladimir Oltean Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- drivers/base/swnode.c | 14 ++++++++++++-- include/linux/property.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 0a482212c7e8..b2ea08f0e898 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -972,8 +972,9 @@ void software_node_unregister(const struct software_node *node) EXPORT_SYMBOL_GPL(software_node_unregister); struct fwnode_handle * -fwnode_create_software_node(const struct property_entry *properties, - const struct fwnode_handle *parent) +fwnode_create_named_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent, + const char *name) { struct fwnode_handle *fwnode; struct software_node *node; @@ -991,6 +992,7 @@ fwnode_create_software_node(const struct property_entry *properties, return ERR_CAST(node); node->parent = p ? p->node : NULL; + node->name = name; fwnode = swnode_register(node, p, 1); if (IS_ERR(fwnode)) @@ -998,6 +1000,14 @@ fwnode_create_software_node(const struct property_entry *properties, return fwnode; } +EXPORT_SYMBOL_GPL(fwnode_create_named_software_node); + +struct fwnode_handle * +fwnode_create_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent) +{ + return fwnode_create_named_software_node(properties, parent, NULL); +} EXPORT_SYMBOL_GPL(fwnode_create_software_node); void fwnode_remove_software_node(struct fwnode_handle *fwnode) diff --git a/include/linux/property.h b/include/linux/property.h index a5b429d623f6..23330ae2b1fa 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -492,6 +492,10 @@ void software_node_unregister(const struct software_node *node); struct fwnode_handle * fwnode_create_software_node(const struct property_entry *properties, const struct fwnode_handle *parent); +struct fwnode_handle * +fwnode_create_named_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent, + const char *name); void fwnode_remove_software_node(struct fwnode_handle *fwnode); int device_add_software_node(struct device *dev, const struct software_node *node); From patchwork Fri Jul 15 16:01:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9377FCCA480 for ; Fri, 15 Jul 2022 16:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Lqc9QNWxCRE0ZTswNQFjHonNK/1BZ9qUO9q3VIDngCQ=; b=SJp9rcPjHStmu07Rk87/6Ss5em d3fMN5nKDIxMpKmHdgbRP2B9f24oJdmZkFJQrIRaeBQztKvMk4yzmuPWuangUBuxY3xdU+xQzCo5w IR4vMlo4Gxprd3WJT9KDXBGglMhiGX74aaLIVhqfr62dRskZ6vmxXvYuSVsHbvI6DQHRF61i1eugM I1uKEw2QmL/6a8H/hWZd0kDBo3c/yZMAd6cxFXM5rUo5SJo1kR+6/5kOZAuLZX+fZMWqUOvIQrz5l jN0FpkUtab96uRvMSei0RJjv3AS5V8MPuuSy+tXOLN28YhzAuhhJLstCM4R1382ZQrd/D9EUBJ/L7 JRR++L0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlx-008bpi-63; Fri, 15 Jul 2022 16:02:33 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlI-008bXn-Iy; Fri, 15 Jul 2022 16:01:54 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Lqc9QNWxCRE0ZTswNQFjHonNK/1BZ9qUO9q3VIDngCQ=; b=gYicktMMGSidoeux9ONWCsOl6r d4j5l757pnf2tmUl7dVOq+3DPXPO8e8PJo9ot8rem26vB+oI/lcg870EhmLqI3W/GtKLoHyTiK14R GCzqOV9d8jtIeIMakkx8NoRXlJsPaSq5cec4uYa+TfXBPDlnPoH1rhOCvPGOQKaTeo/Qm11W6pKpu 1fIR2NzDJfkYA6ug0chPnZaMJg9snhoCicbkHtLY9+UysGmZUaMcDf1Zua6E8QaKylysRhbRRz5Zq xQJcCd0X2FXG+h6nRJSP/xMfcIqaJAjxgznq9VPYVmROtgaUHdR6aj24+UlcLnpPHPHJzIVMbW/ZQ k+05Ad0A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46050 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.94.2) (envelope-from ) id 1oCNl4-0007D2-Gj; Fri, 15 Jul 2022 17:01:38 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNl3-006e3n-PT; Fri, 15 Jul 2022 17:01:37 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 3/6] net: dsa: add support for retrieving the interface mode MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:37 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090152_849591_8C7F2F22 X-CRM114-Status: GOOD ( 20.45 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DSA port bindings allow for an optional phy interface mode. When an interface mode is not specified, DSA uses the NA interface mode type. However, phylink needs to know the parameters of the link, and this will become especially important when using phylink for ports that are devoid of all properties except the required "reg" property, so that phylink can select the maximum supported link settings. Without knowing the interface mode, phylink can't truely know the maximum link speed. Update the prototype for the phylink_get_caps method to allow drivers to report this information back to DSA, and update all DSA implementations function declarations to cater for this change. No code is added to the implementations. Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/b53/b53_common.c | 3 ++- drivers/net/dsa/bcm_sf2.c | 3 ++- drivers/net/dsa/hirschmann/hellcreek.c | 3 ++- drivers/net/dsa/lantiq_gswip.c | 6 ++++-- drivers/net/dsa/microchip/ksz_common.c | 3 ++- drivers/net/dsa/mt7530.c | 3 ++- drivers/net/dsa/mv88e6xxx/chip.c | 3 ++- drivers/net/dsa/ocelot/felix.c | 3 ++- drivers/net/dsa/qca/ar9331.c | 3 ++- drivers/net/dsa/qca8k.c | 3 ++- drivers/net/dsa/realtek/rtl8365mb.c | 3 ++- drivers/net/dsa/sja1105/sja1105_main.c | 3 ++- drivers/net/dsa/xrs700x/xrs700x.c | 3 ++- include/net/dsa.h | 3 ++- net/dsa/port.c | 23 +++++++++++++++++------ 15 files changed, 47 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 48cf344750ff..fe75b84ab791 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1310,7 +1310,8 @@ void b53_port_event(struct dsa_switch *ds, int port) EXPORT_SYMBOL(b53_port_event); static void b53_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct b53_device *dev = ds->priv; diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index be0edfa093d0..18a3847bd82b 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -713,7 +713,8 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port) } static void bcm_sf2_sw_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *interfaces = config->supported_interfaces; struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index 01f90994dedd..6c1ef6997789 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -1462,7 +1462,8 @@ static void hellcreek_teardown(struct dsa_switch *ds) } static void hellcreek_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct hellcreek *hellcreek = ds->priv; diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index e531b93f3cb2..a43dabfa5453 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1492,7 +1492,8 @@ static int gswip_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu) } static void gswip_xrx200_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { switch (port) { case 0: @@ -1525,7 +1526,8 @@ static void gswip_xrx200_phylink_get_caps(struct dsa_switch *ds, int port, } static void gswip_xrx300_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { switch (port) { case 0: diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 28d7cb2ce98f..4329e29a1695 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -721,7 +721,8 @@ static int ksz_check_device_id(struct ksz_device *dev) } static void ksz_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct ksz_device *dev = ds->priv; diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 835807911be0..dab308e454e3 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2914,7 +2914,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) } static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct mt7530_priv *priv = ds->priv; diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 37b649501500..f98be98551ef 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -819,7 +819,8 @@ static void mv88e6393x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, } static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct mv88e6xxx_chip *chip = ds->priv; diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 859196898a7d..0c1ac902b110 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -937,7 +937,8 @@ static int felix_vlan_del(struct dsa_switch *ds, int port, } static void felix_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct ocelot *ocelot = ds->priv; diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index 0796b7cf8cae..19e95dabe5b9 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -501,7 +501,8 @@ static enum dsa_tag_protocol ar9331_sw_get_tag_protocol(struct dsa_switch *ds, } static void ar9331_sw_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100; diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 1cbb05b0323f..beccd8338c81 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1749,7 +1749,8 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, } static void qca8k_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { switch (port) { case 0: /* 1st CPU port */ diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index da31d8b839ac..7bf420c2b083 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -1024,7 +1024,8 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port, } static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { const struct rtl8365mb_extint *extint = rtl8365mb_get_port_extint(ds->priv, port); diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index b253e27bcfb4..e15033177643 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1390,7 +1390,8 @@ static void sja1105_mac_link_up(struct dsa_switch *ds, int port, } static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { struct sja1105_private *priv = ds->priv; struct sja1105_xmii_params_entry *mii; diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 3887ed33c5fe..214a1dd670c2 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -443,7 +443,8 @@ static void xrs700x_teardown(struct dsa_switch *ds) } static void xrs700x_phylink_get_caps(struct dsa_switch *ds, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { switch (port) { case 0: diff --git a/include/net/dsa.h b/include/net/dsa.h index b902b31bebce..7c6870d2c607 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -852,7 +852,8 @@ struct dsa_switch_ops { * PHYLINK integration */ void (*phylink_get_caps)(struct dsa_switch *ds, int port, - struct phylink_config *config); + struct phylink_config *config, + phy_interface_t *default_interface); void (*phylink_validate)(struct dsa_switch *ds, int port, unsigned long *supported, struct phylink_link_state *state); diff --git a/net/dsa/port.c b/net/dsa/port.c index 3738f2d40a0b..35b4e1f8dc05 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1524,13 +1524,9 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { int dsa_port_phylink_create(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; - phy_interface_t mode; + phy_interface_t mode, def_mode; int err; - err = of_get_phy_mode(dp->dn, &mode); - if (err) - mode = PHY_INTERFACE_MODE_NA; - /* Presence of phylink_mac_link_state or phylink_mac_an_restart is * an indicator of a legacy phylink driver. */ @@ -1538,8 +1534,23 @@ int dsa_port_phylink_create(struct dsa_port *dp) ds->ops->phylink_mac_an_restart) dp->pl_config.legacy_pre_march2020 = true; + def_mode = PHY_INTERFACE_MODE_NA; if (ds->ops->phylink_get_caps) - ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); + ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config, + &def_mode); + + err = of_get_phy_mode(dp->dn, &mode); + if (err) { + /* We must not set the default mode for user ports as a PHY + * overrides the NA mode in phylink. Setting it here would + * prevent the interface mode being updated. + */ + if (dp->type == DSA_PORT_TYPE_CPU || + dp->type == DSA_PORT_TYPE_DSA) + mode = def_mode; + else + mode = PHY_INTERFACE_MODE_NA; + } dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode, &dsa_port_phylink_mac_ops); From patchwork Fri Jul 15 16:01:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0E95C433EF for ; Fri, 15 Jul 2022 16:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jgdDx9LQsyARI/DRrgkq1Gryik1L6rg1Iq2G8EvXqII=; b=fsYm85xfpJS4mgQuU6DW939pSn bjhy4RRmqd5saLBiewoxCbBWhPDAI0f1Y/4/XKZaapWYBnfD7ZA/1sCK7jQ4Z09u7hNpwZb84qDFG f6gi3kJIaxMGYRszWQ9bSZ1YJ6Po/Iy7PQxl+Nn8P+mDBJTVgv9Dwj8I0ODD1wcqv4rlv1X5WRTsc SRNZeAF4YLhX42iLHyeupFx4XZYLfvttUpKmIw0JhRKCnKQGu8wIM1d0w/xLbY5sWno6yi9wSO3Ro lb+M6Rd8Zx/85gJnx1RNpc0aYApZEOgb5ZHeEGC0VvPSwczljVLwsdJA1sYI++P6XEF7aVSjPq4ah BVBmyT1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNmC-008bxd-35; Fri, 15 Jul 2022 16:02:48 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlL-008bYm-JP; Fri, 15 Jul 2022 16:01:57 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jgdDx9LQsyARI/DRrgkq1Gryik1L6rg1Iq2G8EvXqII=; b=chYPJqcQOiyu0zMUNr+98oLToa M36cKhNrkv84F6LJX9VOK4hShxzL2cpeiO6hu9uYH0uzgXiLvDQHgMhWo8LaFkKf7AAELMSHt/Pr4 yjzHJh/R41KW8xPIuwre+xOlH5SQuzKPvSdju2TH5zLz0DBUGFIUsc7xXT6YRovY7kvKq86Kq5giz GJZb081aAtfvS25C4AE/nM+pyvRkwKsWhFLNTAuSU+d1ZYK+ghroNBI7W3tciBnU8jP+tKbPVAXQF MzNSjF5YIYGRDNtgsCsR9swsK81m5pok7uWPHKvOjWZL+COLg9Q8mSKnZ53AHXscLZvtUgadfq82s 4HcHVfKw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46052 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.94.2) (envelope-from ) id 1oCNl9-0007DP-MR; Fri, 15 Jul 2022 17:01:43 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNl8-006e3t-Ub; Fri, 15 Jul 2022 17:01:43 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 4/6] net: dsa: mv88e6xxx: report the default interface mode for the port MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:42 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090155_815453_F20D30C3 X-CRM114-Status: GOOD ( 19.71 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Report the maximum speed interface mode for the port, or if we don't have that information, the hardware configured interface mode for the port. This allows phylink to know which interface mode CPU and DSA ports are operating, which will be necessary when we want to select the maximum speed for the port (required for such ports without a PHY or fixed-link specified in firmware.) Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/mv88e6xxx/chip.c | 82 +++++++++++++++++++++++--------- drivers/net/dsa/mv88e6xxx/chip.h | 3 +- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index f98be98551ef..ccb35ea5d7b0 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -578,7 +578,8 @@ static const u8 mv88e6185_phy_interface_modes[] = { }; static void mv88e6095_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { u8 cmode = chip->ports[port].cmode; @@ -588,23 +589,29 @@ static void mv88e6095_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); } else { if (cmode < ARRAY_SIZE(mv88e6185_phy_interface_modes) && - mv88e6185_phy_interface_modes[cmode]) + mv88e6185_phy_interface_modes[cmode]) { __set_bit(mv88e6185_phy_interface_modes[cmode], config->supported_interfaces); + *default_interface = + mv88e6185_phy_interface_modes[cmode]; + } config->mac_capabilities |= MAC_1000FD; } } static void mv88e6185_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { u8 cmode = chip->ports[port].cmode; if (cmode < ARRAY_SIZE(mv88e6185_phy_interface_modes) && - mv88e6185_phy_interface_modes[cmode]) + mv88e6185_phy_interface_modes[cmode]) { __set_bit(mv88e6185_phy_interface_modes[cmode], config->supported_interfaces); + *default_interface = mv88e6185_phy_interface_modes[cmode]; + } config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; @@ -616,6 +623,7 @@ static const u8 mv88e6xxx_phy_interface_modes[] = { [MV88E6XXX_PORT_STS_CMODE_GMII] = PHY_INTERFACE_MODE_GMII, [MV88E6XXX_PORT_STS_CMODE_RMII_PHY] = PHY_INTERFACE_MODE_RMII, [MV88E6XXX_PORT_STS_CMODE_RMII] = PHY_INTERFACE_MODE_RMII, + [MV88E6XXX_PORT_STS_CMODE_RGMII] = PHY_INTERFACE_MODE_RGMII, [MV88E6XXX_PORT_STS_CMODE_100BASEX] = PHY_INTERFACE_MODE_100BASEX, [MV88E6XXX_PORT_STS_CMODE_1000BASEX] = PHY_INTERFACE_MODE_1000BASEX, [MV88E6XXX_PORT_STS_CMODE_SGMII] = PHY_INTERFACE_MODE_SGMII, @@ -625,22 +633,32 @@ static const u8 mv88e6xxx_phy_interface_modes[] = { */ }; -static void mv88e6xxx_translate_cmode(u8 cmode, unsigned long *supported) +static void mv88e6xxx_translate_cmode(u8 cmode, unsigned long *supported, + phy_interface_t *default_interface) { + phy_interface_t interface; + if (cmode < ARRAY_SIZE(mv88e6xxx_phy_interface_modes) && - mv88e6xxx_phy_interface_modes[cmode]) - __set_bit(mv88e6xxx_phy_interface_modes[cmode], supported); - else if (cmode == MV88E6XXX_PORT_STS_CMODE_RGMII) - phy_interface_set_rgmii(supported); + mv88e6xxx_phy_interface_modes[cmode]) { + interface = mv88e6xxx_phy_interface_modes[cmode]; + if (interface == PHY_INTERFACE_MODE_RGMII) + phy_interface_set_rgmii(supported); + else + __set_bit(interface, supported); + if (default_interface) + *default_interface = interface; + } } static void mv88e6250_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; /* Translate the default cmode */ - mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported, + default_interface); config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; } @@ -676,13 +694,15 @@ static int mv88e6352_get_port4_serdes_cmode(struct mv88e6xxx_chip *chip) } static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; int err, cmode; /* Translate the default cmode */ - mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported, + default_interface); config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; @@ -702,19 +722,21 @@ static void mv88e6352_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, dev_err(chip->dev, "p%d: failed to read serdes cmode\n", port); else - mv88e6xxx_translate_cmode(cmode, supported); + mv88e6xxx_translate_cmode(cmode, supported, NULL); unlock: mv88e6xxx_reg_unlock(chip); } } static void mv88e6341_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; /* Translate the default cmode */ - mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported, + default_interface); /* No ethtool bits for 200Mbps */ config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | @@ -726,17 +748,21 @@ static void mv88e6341_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported); __set_bit(PHY_INTERFACE_MODE_2500BASEX, supported); + *default_interface = PHY_INTERFACE_MODE_2500BASEX; + config->mac_capabilities |= MAC_2500FD; } } static void mv88e6390_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; /* Translate the default cmode */ - mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported, + default_interface); /* No ethtool bits for 200Mbps */ config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | @@ -748,16 +774,19 @@ static void mv88e6390_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, __set_bit(PHY_INTERFACE_MODE_1000BASEX, supported); __set_bit(PHY_INTERFACE_MODE_2500BASEX, supported); + *default_interface = PHY_INTERFACE_MODE_2500BASEX; + config->mac_capabilities |= MAC_2500FD; } } static void mv88e6390x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; - mv88e6390_phylink_get_caps(chip, port, config); + mv88e6390_phylink_get_caps(chip, port, config, default_interface); /* For the 6x90X, ports 2-7 can be in automedia mode. * (Note that 6x90 doesn't support RXAUI nor XAUI). @@ -783,18 +812,22 @@ static void mv88e6390x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, __set_bit(PHY_INTERFACE_MODE_XAUI, supported); __set_bit(PHY_INTERFACE_MODE_RXAUI, supported); + *default_interface = PHY_INTERFACE_MODE_XAUI; + config->mac_capabilities |= MAC_10000FD; } } static void mv88e6393x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config) + struct phylink_config *config, + phy_interface_t *default_interface) { unsigned long *supported = config->supported_interfaces; bool is_6191x = chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X; - mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported, + default_interface); config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; @@ -812,6 +845,8 @@ static void mv88e6393x_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, /* FIXME: USXGMII is not supported yet */ /* __set_bit(PHY_INTERFACE_MODE_USXGMII, supported); */ + *default_interface = PHY_INTERFACE_MODE_10GBASER; + config->mac_capabilities |= MAC_2500FD | MAC_5000FD | MAC_10000FD; } @@ -824,7 +859,8 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port, { struct mv88e6xxx_chip *chip = ds->priv; - chip->info->ops->phylink_get_caps(chip, port, config); + chip->info->ops->phylink_get_caps(chip, port, config, + default_interface); /* Internal ports need GMII for PHYLIB */ if (mv88e6xxx_phy_is_internal(ds, port)) diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index e693154cf803..4518c17c1b9b 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -643,7 +643,8 @@ struct mv88e6xxx_ops { /* Phylink */ void (*phylink_get_caps)(struct mv88e6xxx_chip *chip, int port, - struct phylink_config *config); + struct phylink_config *config, + phy_interface_t *default_interface); /* Max Frame Size */ int (*set_max_frame_size)(struct mv88e6xxx_chip *chip, int mtu); From patchwork Fri Jul 15 16:01:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CC44C433EF for ; Fri, 15 Jul 2022 16:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=87oaXdELgJ7WCn+eCWvUqcviggDTNCP3mxTrSmjvxRo=; b=nao0KEYLI68egYCOKj8VMRqyf4 fzrYPWqUvXw0ro5QjGjl4+fobhVOtLpdfg2JYSftVkeiPPHpc3dPeZJI0oZE9F2/x67Nsa1X53IV+ 9UmBYmKkSqQYUwfITK/0kWQedBPGBwoC1kXtoRcVVgovQhLgPMMdkHT+pgie9tJ4CLcMAqVx3znf5 AWJ/bTmfZMOqxkPvFGQhjjGoZcVVy6+d1LqHeHgG5YDBJqtA0oj8GIwYuyRf+pt7aOfaNYhX3enAP Bvqs8iLrtiJ4mddO9R/6R1EdrQDgvcNonkPxk6zTkOubFnM6etTOQYINjLiCwXm4WgGzPFPjpBP12 xFLg+wrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNmg-008cHd-Tw; Fri, 15 Jul 2022 16:03:18 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlS-008bao-76; Fri, 15 Jul 2022 16:02:04 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=87oaXdELgJ7WCn+eCWvUqcviggDTNCP3mxTrSmjvxRo=; b=Vld7o3lF8EzFGJUgwqhcdYnml5 eJZalvrsHTb8byNYTiNvzwDTS8vZrkaMoIGj/iuIb45CcpFowKB1VUBxDpx55gESiyTFSjHRo+URo tCPmtUIWjaPDZa8SI3UdbY2TnILT2zrIRznaJ9qfhyFrkvozc8npOGky22Q6/EBn+2f6XoIHixw0L eGpbyfWQKw2+dvACZass7UaVpyR8rhrV5FxwBnP0iOryXJ4qoOTYu++dD7skAifhdyKeKHj/HAStj 9achYz9MR+rroR2m/0KHFi4jERfBN7JDTGGYglz5FrENkpwmcR/JpD25LlopPn77f8mjwZ0Xh8/rj pZ9q/ShA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46054 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.94.2) (envelope-from ) id 1oCNlE-0007Dx-R9; Fri, 15 Jul 2022 17:01:48 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNlE-006e3z-3T; Fri, 15 Jul 2022 17:01:48 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 5/6] net: dsa: use swnode fixed-link if using default params MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:48 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090202_445224_2EFAE3EE X-CRM114-Status: GOOD ( 18.26 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Create and use a swnode fixed-link specification for phylink if no parameters are given in DT for a fixed-link. This allows phylink to be used for "default" cases for DSA and CPU ports. Enable the use of phylink in all cases for DSA and CPU ports. Co-developed by Vladimir Oltean and myself. Signed-off-by: Vladimir Oltean Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- net/dsa/port.c | 152 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 13 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index 35b4e1f8dc05..abcf7899abf8 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1521,10 +1521,131 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { .mac_link_up = dsa_port_phylink_mac_link_up, }; +static struct { + unsigned long mask; + int speed; + int duplex; +} phylink_caps_params[] = { + { MAC_400000FD, SPEED_400000, DUPLEX_FULL }, + { MAC_200000FD, SPEED_200000, DUPLEX_FULL }, + { MAC_100000FD, SPEED_100000, DUPLEX_FULL }, + { MAC_56000FD, SPEED_56000, DUPLEX_FULL }, + { MAC_50000FD, SPEED_50000, DUPLEX_FULL }, + { MAC_40000FD, SPEED_40000, DUPLEX_FULL }, + { MAC_25000FD, SPEED_25000, DUPLEX_FULL }, + { MAC_20000FD, SPEED_20000, DUPLEX_FULL }, + { MAC_10000FD, SPEED_10000, DUPLEX_FULL }, + { MAC_5000FD, SPEED_5000, DUPLEX_FULL }, + { MAC_2500FD, SPEED_2500, DUPLEX_FULL }, + { MAC_1000FD, SPEED_1000, DUPLEX_FULL }, + { MAC_100FD, SPEED_100, DUPLEX_FULL }, + { MAC_10FD, SPEED_10, DUPLEX_FULL }, + { MAC_1000HD, SPEED_1000, DUPLEX_HALF }, + { MAC_100HD, SPEED_100, DUPLEX_HALF }, + { MAC_10HD, SPEED_10, DUPLEX_HALF }, +}; + +static int dsa_port_find_max_speed(unsigned long caps, int *speed, int *duplex) +{ + int i; + + *speed = SPEED_UNKNOWN; + *duplex = DUPLEX_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) { + if (caps & phylink_caps_params[i].mask) { + *speed = phylink_caps_params[i].speed; + *duplex = phylink_caps_params[i].duplex; + break; + } + } + + return *speed == SPEED_UNKNOWN ? -EINVAL : 0; +} + +static void dsa_port_find_max_caps(struct dsa_port *dp, + phy_interface_t *max_interface, + unsigned long *max_caps) +{ + struct phylink_config *config = &dp->pl_config; + phy_interface_t interface; + unsigned long caps; + + *max_interface = PHY_INTERFACE_MODE_NA; + *max_caps = 0; + + for_each_set_bit(interface, config->supported_interfaces, + PHY_INTERFACE_MODE_MAX) { + caps = config->mac_capabilities & + phylink_interface_to_caps(interface); + if (caps > *max_caps) { + *max_caps = caps; + *max_interface = interface; + } + } +} + +static struct fwnode_handle *dsa_port_get_fwnode(struct dsa_port *dp, + phy_interface_t mode) +{ + struct property_entry fixed_link_props[3] = { }; + struct property_entry port_props[3] = {}; + struct fwnode_handle *fixed_link_fwnode; + struct fwnode_handle *new_port_fwnode; + struct device_node *dn = dp->dn; + struct device_node *phy_node; + int err, speed, duplex; + unsigned long caps; + + phy_node = of_parse_phandle(dn, "phy-handle", 0); + of_node_put(phy_node); + if (phy_node || of_phy_is_fixed_link(dn)) + /* Nothing broken, nothing to fix. + * TODO: As discussed with Russell, maybe phylink could provide + * a more comprehensive helper to determine what constitutes a + * valid fwnode binding than this guerilla kludge. + */ + return of_fwnode_handle(dn); + + if (mode == PHY_INTERFACE_MODE_NA) + dsa_port_find_max_caps(dp, &mode, &caps); + else + caps = dp->pl_config.mac_capabilities & + phylink_interface_to_caps(mode); + + err = dsa_port_find_max_speed(caps, &speed, &duplex); + if (err) + return ERR_PTR(err); + + fixed_link_props[0] = PROPERTY_ENTRY_U32("speed", speed); + if (duplex == DUPLEX_FULL) + fixed_link_props[1] = PROPERTY_ENTRY_BOOL("full-duplex"); + + port_props[0] = PROPERTY_ENTRY_STRING("phy-mode", phy_modes(mode)); + + new_port_fwnode = fwnode_create_software_node(port_props, NULL); + if (IS_ERR(new_port_fwnode)) + return new_port_fwnode; + + /* Node needs to be named so that phylink's call to + * fwnode_get_named_child_node() finds it. + */ + fixed_link_fwnode = fwnode_create_named_software_node(fixed_link_props, + new_port_fwnode, + "fixed-link"); + if (IS_ERR(fixed_link_fwnode)) { + fwnode_remove_software_node(new_port_fwnode); + return fixed_link_fwnode; + } + + return new_port_fwnode; +} + int dsa_port_phylink_create(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; phy_interface_t mode, def_mode; + struct fwnode_handle *fwnode; int err; /* Presence of phylink_mac_link_state or phylink_mac_an_restart is @@ -1552,8 +1673,19 @@ int dsa_port_phylink_create(struct dsa_port *dp) mode = PHY_INTERFACE_MODE_NA; } - dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), - mode, &dsa_port_phylink_mac_ops); + fwnode = dsa_port_get_fwnode(dp, mode); + if (IS_ERR(fwnode)) { + dev_err(ds->dev, + "Failed to get fwnode for port %d: %pe\n", + dp->index, fwnode); + return PTR_ERR(fwnode); + } + + dp->pl = phylink_create(&dp->pl_config, fwnode, mode, + &dsa_port_phylink_mac_ops); + + fwnode_remove_software_node(fwnode); + if (IS_ERR(dp->pl)) { pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl)); return PTR_ERR(dp->pl); @@ -1663,20 +1795,14 @@ static int dsa_port_phylink_register(struct dsa_port *dp) int dsa_port_link_register_of(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; - struct device_node *phy_np; int port = dp->index; if (!ds->ops->adjust_link) { - phy_np = of_parse_phandle(dp->dn, "phy-handle", 0); - if (of_phy_is_fixed_link(dp->dn) || phy_np) { - if (ds->ops->phylink_mac_link_down) - ds->ops->phylink_mac_link_down(ds, port, - MLO_AN_FIXED, PHY_INTERFACE_MODE_NA); - of_node_put(phy_np); - return dsa_port_phylink_register(dp); - } - of_node_put(phy_np); - return 0; + if (ds->ops->phylink_mac_link_down) + ds->ops->phylink_mac_link_down(ds, port, MLO_AN_FIXED, + PHY_INTERFACE_MODE_NA); + + return dsa_port_phylink_register(dp); } dev_warn(ds->dev, From patchwork Fri Jul 15 16:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12919466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 401D0C433EF for ; Fri, 15 Jul 2022 16:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ee0S/L/lAaawjhGQkdBJydNVbnF4FxpHz5nSk4/ecXA=; b=Y6zVeSW+uurG1fM5OD/TO+RAvG bvapdnzE6+oihCu+dYTqQWQldOt2/qvS4usdMSDR/GTxVXKFw6loUPcUf1kP3Uteb2mx5niQ2moYd PMWNDBUe05oF4bzhaNWstWz2CNWG0XPaYlzYg5WMhX8EOQDGSfNzr4DV9CHV18bRdyxdgoM3PIjbm FdNUM8E4fTEnhP1HsgeOB8yLh/fSiC722D/0pT2BQcJ/k9zGTTlgSDzTyUgknDzeelnyXjKPaLL8V Dn6Vg6/9MJAoZGNBqAcsGZVoyZKFmIqnO4+GUuk3kKFtxj5WMmUttsWCuOZwMJAeU8NQqmHLDFmdo mtPGrLKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNnF-008cce-WA; Fri, 15 Jul 2022 16:03:54 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCNlX-008bdO-60; Fri, 15 Jul 2022 16:02:09 +0000 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:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ee0S/L/lAaawjhGQkdBJydNVbnF4FxpHz5nSk4/ecXA=; b=sl1F19CLN6rb7NOrnwdMLwMK/g GAngKGXU0eid+AVplNeyYiLz50q6npmcJqExM0vFLK9fXEWfPTNr0RDJptioQ11st5Rv9VUJdbDYI vL3tm9Gy5H2C1gbKLE4qIQ8Xsl5WQ/XjdIn70kORSmS1Bo4zcMYVYqpqCSVPLKYneFGqpbW9ke1u4 qhby2li7dYpgXSFiQTZrvIffZtd/cPm0pwxvaAXDfAEnFddcHmUtwn4Y1ALKdvAxZJvyxt0a99X4q v5aDgiICHVjRpQpIZTMKx8eZBj1pEXDG5Muosc3v1Sr8IDlo+vPFEBaeeacnWeWyYArjb7H/hR3Wp 19/3RMcA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46056 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.94.2) (envelope-from ) id 1oCNlK-0007EM-1h; Fri, 15 Jul 2022 17:01:54 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oCNlJ-006e45-8V; Fri, 15 Jul 2022 17:01:53 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Belloni , "Alvin __ipraga" , Andy Shevchenko , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?q?Beh=FAn?= Subject: [PATCH net-next 6/6] net: dsa: mv88e6xxx: remove handling for DSA and CPU ports MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 15 Jul 2022 17:01:53 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_090207_407560_E08D5437 X-CRM114-Status: GOOD ( 16.86 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org As we now always use a fixed-link for DSA and CPU ports, we no longer need the hack in the Marvell code to make this work. Remove it. This is especially important with the conversion of DSA drivers to phylink_pcs, as the PCS code only gets called if we are using phylink for the port. Reviewed-by: Marek Behún Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/mv88e6xxx/chip.c | 49 +++----------------------------- drivers/net/dsa/mv88e6xxx/chip.h | 3 -- drivers/net/dsa/mv88e6xxx/port.c | 32 --------------------- drivers/net/dsa/mv88e6xxx/port.h | 5 ---- 4 files changed, 4 insertions(+), 85 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index ccb35ea5d7b0..01dff8d46642 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3314,9 +3314,8 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) { struct device_node *phy_handle = NULL; struct dsa_switch *ds = chip->ds; - phy_interface_t mode; struct dsa_port *dp; - int tx_amp, speed; + int tx_amp; int err; u16 reg; @@ -3325,40 +3324,9 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) dp = dsa_to_port(ds, port); - /* MAC Forcing register: don't force link, speed, duplex or flow control - * state to any particular values on physical ports, but force the CPU - * port and all DSA ports to their maximum bandwidth and full duplex. - */ - if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { - unsigned long caps = dp->pl_config.mac_capabilities; - - if (chip->info->ops->port_max_speed_mode) - mode = chip->info->ops->port_max_speed_mode(port); - else - mode = PHY_INTERFACE_MODE_NA; - - if (caps & MAC_10000FD) - speed = SPEED_10000; - else if (caps & MAC_5000FD) - speed = SPEED_5000; - else if (caps & MAC_2500FD) - speed = SPEED_2500; - else if (caps & MAC_1000) - speed = SPEED_1000; - else if (caps & MAC_100) - speed = SPEED_100; - else - speed = SPEED_10; - - err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, - speed, DUPLEX_FULL, - PAUSE_OFF, mode); - } else { - err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, - SPEED_UNFORCED, DUPLEX_UNFORCED, - PAUSE_ON, - PHY_INTERFACE_MODE_NA); - } + err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, + SPEED_UNFORCED, DUPLEX_UNFORCED, + PAUSE_ON, PHY_INTERFACE_MODE_NA); if (err) return err; @@ -4306,7 +4274,6 @@ static const struct mv88e6xxx_ops mv88e6141_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, - .port_max_speed_mode = mv88e6341_port_max_speed_mode, .port_tag_remap = mv88e6095_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -4699,7 +4666,6 @@ static const struct mv88e6xxx_ops mv88e6190_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -4762,7 +4728,6 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390x_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -4825,7 +4790,6 @@ static const struct mv88e6xxx_ops mv88e6191_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_frame_mode = mv88e6351_port_set_frame_mode, .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, @@ -4990,7 +4954,6 @@ static const struct mv88e6xxx_ops mv88e6290_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -5141,7 +5104,6 @@ static const struct mv88e6xxx_ops mv88e6341_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, - .port_max_speed_mode = mv88e6341_port_max_speed_mode, .port_tag_remap = mv88e6095_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -5364,7 +5326,6 @@ static const struct mv88e6xxx_ops mv88e6390_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -5431,7 +5392,6 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, - .port_max_speed_mode = mv88e6390x_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6352_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, @@ -5497,7 +5457,6 @@ static const struct mv88e6xxx_ops mv88e6393x_ops = { .port_sync_link = mv88e6xxx_port_sync_link, .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, - .port_max_speed_mode = mv88e6393x_port_max_speed_mode, .port_tag_remap = mv88e6390_port_tag_remap, .port_set_policy = mv88e6393x_port_set_policy, .port_set_frame_mode = mv88e6351_port_set_frame_mode, diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index 4518c17c1b9b..a3b7cfe3eb23 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -502,9 +502,6 @@ struct mv88e6xxx_ops { int (*port_set_speed_duplex)(struct mv88e6xxx_chip *chip, int port, int speed, int duplex); - /* What interface mode should be used for maximum speed? */ - phy_interface_t (*port_max_speed_mode)(int port); - int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port); int (*port_set_policy)(struct mv88e6xxx_chip *chip, int port, diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index 90c55f23b7c9..47e21f3c437a 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -333,14 +333,6 @@ int mv88e6341_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, duplex); } -phy_interface_t mv88e6341_port_max_speed_mode(int port) -{ - if (port == 5) - return PHY_INTERFACE_MODE_2500BASEX; - - return PHY_INTERFACE_MODE_NA; -} - /* Support 10, 100, 200, 1000 Mbps (e.g. 88E6352 family) */ int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int speed, int duplex) @@ -372,14 +364,6 @@ int mv88e6390_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, duplex); } -phy_interface_t mv88e6390_port_max_speed_mode(int port) -{ - if (port == 9 || port == 10) - return PHY_INTERFACE_MODE_2500BASEX; - - return PHY_INTERFACE_MODE_NA; -} - /* Support 10, 100, 200, 1000, 2500, 10000 Mbps (e.g. 88E6190X) */ int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int speed, int duplex) @@ -394,14 +378,6 @@ int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, duplex); } -phy_interface_t mv88e6390x_port_max_speed_mode(int port) -{ - if (port == 9 || port == 10) - return PHY_INTERFACE_MODE_XAUI; - - return PHY_INTERFACE_MODE_NA; -} - /* Support 10, 100, 200, 1000, 2500, 5000, 10000 Mbps (e.g. 88E6393X) * Function mv88e6xxx_port_set_speed_duplex() can't be used as the register * values for speeds 2500 & 5000 conflict. @@ -491,14 +467,6 @@ int mv88e6393x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, return 0; } -phy_interface_t mv88e6393x_port_max_speed_mode(int port) -{ - if (port == 0 || port == 9 || port == 10) - return PHY_INTERFACE_MODE_10GBASER; - - return PHY_INTERFACE_MODE_NA; -} - static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port, phy_interface_t mode, bool force) { diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h index cb04243f37c1..2a5741a44e97 100644 --- a/drivers/net/dsa/mv88e6xxx/port.h +++ b/drivers/net/dsa/mv88e6xxx/port.h @@ -357,11 +357,6 @@ int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int mv88e6393x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port, int speed, int duplex); -phy_interface_t mv88e6341_port_max_speed_mode(int port); -phy_interface_t mv88e6390_port_max_speed_mode(int port); -phy_interface_t mv88e6390x_port_max_speed_mode(int port); -phy_interface_t mv88e6393x_port_max_speed_mode(int port); - int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state); int mv88e6xxx_port_set_vlan_map(struct mv88e6xxx_chip *chip, int port, u16 map);