From patchwork Fri May 31 11:26:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681542 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 5434BC25B75 for ; Fri, 31 May 2024 11:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=dmr/Tw8rs6MrbrQ36XE+zVnAv0djeXxVicQEDeQRq5U=; b=Ny9wIJtvYlVYDm 83hunw43YLNhSrEGGRGWKKqax+CG6p6NxwCTpD4U6mlKcF+9W5L4Cr4LgnfdFFrUHo25ffH4KnZ6P JWZPuvsY+igeLzclIToTg1eUPA8XnWcvpa/HlynOGwL1iRCLpTJAvQmn4jUGMILPxeGb/2zzh+JbC 77Zug9fHijUUxyfdjV441DxSLGzlxcASfHIYMjeVpW1pBaY+Bj29lhGmmSqFYQolvCgB8yJxeNgJC SeMsF8x8mtUPhMhCVUq6HVMKooJqA59kLdpnAXWmI8ypvFBO+K4Vb+2u9VjHZpPRkqplW2iUBdx/f gU9DBms1CkZCvoovxmAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0P3-0000000A42N-0dVM; Fri, 31 May 2024 11:26:33 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0Oy-0000000A3zZ-1WKX for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:31 +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=znBvrxbm5XBULWEnnD42FCLop5RMvOAuJY+uJBUOxaI=; b=Haw/SstVgRX+H7bIgQQKSGKSsr 78W61r+U1sACYCStLTNEQq9f9iUK1APsKsyOTGFKLWjpkMh6xJRNqT8r3CM9kXdXwQmC9YyvY50kr A74JKm0wqo5BtNZV+zIR1D6ik8fGOjY5i4bYkN4c1jhemHw4vEoyx7xKUtvmC/teRwDL0m9LCjGfZ oOHcI2vdCHA4HE7c9xC//IwO4A+NVR5Xg2xRypTo63AB8WCBK1DlrYvYbTQ7M5mjwzhgHEdUxlR3B zNLd1P6UifVyDejDSzfszqdx84iD+TUaUC5FntuXrOBd9F4X6XTGlavRQ/QlFOOey8ZBXJiw9269C woJEn7og==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:38408 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 1sD0Oi-0008RI-0u; Fri, 31 May 2024 12:26:12 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0Ol-00EzBh-3f; Fri, 31 May 2024 12:26:15 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 1/8] net: stmmac: add infrastructure for hwifs to provide PCS MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:15 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042628_798577_1AAE6A3E X-CRM114-Status: GOOD ( 24.72 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow hwifs to provide a phylink_select_pcs() implementation via struct stmmac_ops, which can be used to provide a phylink PCS. Code analysis shows that when STMMAC_FLAG_HAS_INTEGRATED_PCS is set, then: stmmac_common_interrupt() stmmac_ethtool_set_link_ksettings() stmmac_ethtool_get_link_ksettings() will all ignore the presence of the PCS. The latter two will pass the ethtool commands to phylink. The former will avoid manipulating the netif carrier state behind phylink's back based on the PCS status. This flag is only set by the ethqos driver. From what I can tell, amongst the current kernel DT files that use the ethqos driver, only sa8775p-ride.dts enables ethernet, and this defines a SGMII-mode link to its PHYs without the "managed" property. Thus, phylink will be operating in MLO_AN_PHY mode, and inband mode will not be used. Therefore, it is safe to ignore the STMMAC_FLAG_HAS_INTEGRATED_PCS flag in stmmac_mac_select_pcs(). Further code analysis shows that XPCS is used by Intel for Cisco SGMII and 1000base-X modes. In this case, we do not want to provide the integrated PCS, but the XPCS. The same appears to also be true of the Lynx PCS. Therefore, it seems that the integrated PCS provided by the hwif MAC code should only be used when an external PCS is not being used, so give priority to the external PCS. Provide a phylink_pcs instance in struct mac_device_info for hwifs to use to provide their phylink PCS. Omit the non-phylink PCS code paths when a hwif provides a phylink_select_pcs() method (in other words, when they are converted to use a phylink PCS.) This provides a way to transition parts of the driver in the subsequent patches. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/common.h | 9 ++++++++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 19 +++++++++++++++++-- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 12 ++++++++---- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++--- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index cd36ff4da68c..940e83fa1202 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #if IS_ENABLED(CONFIG_VLAN_8021Q) @@ -591,6 +591,7 @@ struct mac_device_info { const struct stmmac_tc_ops *tc; const struct stmmac_mmc_ops *mmc; const struct stmmac_est_ops *est; + struct phylink_pcs mac_pcs; /* The MAC's RGMII/SGMII "PCS" */ struct dw_xpcs *xpcs; struct phylink_pcs *phylink_pcs; struct mii_regs mii; /* MII register Addresses */ @@ -611,6 +612,12 @@ struct mac_device_info { bool hw_vlan_en; }; +static inline struct mac_device_info * +phylink_pcs_to_mac_dev_info(struct phylink_pcs *pcs) +{ + return container_of(pcs, struct mac_device_info, mac_pcs); +} + struct stmmac_rx_routing { u32 reg_mask; u32 reg_shift; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 97934ccba5b1..aa5f6e40cb53 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -5,6 +5,7 @@ #ifndef __STMMAC_HWIF_H__ #define __STMMAC_HWIF_H__ +#include #include #include @@ -17,13 +18,17 @@ } \ __result; \ }) -#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ +#define stmmac_do_typed_callback(__type, __fail_ret, __priv, __module, \ + __cname, __arg0, __args...) \ ({ \ - int __result = -EINVAL; \ + __type __result = __fail_ret; \ if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \ __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ __result; \ }) +#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ + stmmac_do_typed_callback(int, -EINVAL, __priv, __module, __cname, \ + __arg0, ##__args) struct stmmac_extra_stats; struct stmmac_priv; @@ -310,6 +315,9 @@ struct stmmac_ops { void (*core_init)(struct mac_device_info *hw, struct net_device *dev); /* Update MAC capabilities */ void (*update_caps)(struct stmmac_priv *priv); + /* Get phylink PCS (for MAC */ + struct phylink_pcs *(*phylink_select_pcs)(struct stmmac_priv *priv, + phy_interface_t interface); /* Enable the MAC RX/TX */ void (*set_mac)(void __iomem *ioaddr, bool enable); /* Enable and verify that the IPC module is supported */ @@ -431,6 +439,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, core_init, __args) #define stmmac_mac_update_caps(__priv) \ stmmac_do_void_callback(__priv, mac, update_caps, __priv) +#define stmmac_mac_phylink_select_pcs(__priv, __interface) \ + stmmac_do_typed_callback(struct phylink_pcs *, ERR_PTR(-EOPNOTSUPP), \ + __priv, mac, phylink_select_pcs, __priv,\ + __interface) #define stmmac_mac_set(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_mac, __args) #define stmmac_rx_ipc(__priv, __args...) \ @@ -530,6 +542,9 @@ struct stmmac_ops { #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) +#define stmmac_has_mac_phylink_select_pcs(__priv) \ + ((__priv)->hw->mac->phylink_select_pcs != NULL) + /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 18468c0228f0..7c6530d63ade 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -323,7 +323,8 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev, if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII)) { + priv->hw->pcs & STMMAC_PCS_SGMII) && + !stmmac_has_mac_phylink_select_pcs(priv)) { struct rgmii_adv adv; u32 supported, advertising, lp_advertising; @@ -410,7 +411,8 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev, if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII)) { + priv->hw->pcs & STMMAC_PCS_SGMII) && + !stmmac_has_mac_phylink_select_pcs(priv)) { /* Only support ANE */ if (cmd->base.autoneg != AUTONEG_ENABLE) return -EINVAL; @@ -523,7 +525,8 @@ stmmac_get_pauseparam(struct net_device *netdev, struct stmmac_priv *priv = netdev_priv(netdev); struct rgmii_adv adv_lp; - if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { + if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv) && + !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { pause->autoneg = 1; if (!adv_lp.pause) return; @@ -539,7 +542,8 @@ stmmac_set_pauseparam(struct net_device *netdev, struct stmmac_priv *priv = netdev_priv(netdev); struct rgmii_adv adv_lp; - if (priv->hw->pcs && !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { + if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv) && + !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { pause->autoneg = 1; if (!adv_lp.pause) return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index bbedf2a8c60f..56c351e11952 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -953,7 +953,10 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, if (priv->hw->xpcs) return &priv->hw->xpcs->pcs; - return priv->hw->phylink_pcs; + if (priv->hw->phylink_pcs) + return priv->hw->phylink_pcs; + + return stmmac_mac_phylink_select_pcs(priv, interface); } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, @@ -3482,7 +3485,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) } } - if (priv->hw->pcs) + if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, priv->hw->ps, 0); /* set TX and RX rings length */ @@ -6052,7 +6055,8 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) /* PCS link status */ if (priv->hw->pcs && - !(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS)) { + !(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && + !stmmac_has_mac_phylink_select_pcs(priv)) { if (priv->xstats.pcs_link) netif_carrier_on(priv->dev); else From patchwork Fri May 31 11:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681543 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 63213C25B7C for ; Fri, 31 May 2024 11:26: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=ZNlqRyJbcMfo95AP/AvNlrpBE6swS1Spvi/ZNsVqVLo=; b=leS6ZpdTY7EEoA qCBgqmPBhmihZb+qaDKaGL5R/ESf2kSo824FLLn9SsuWAcJ7mITb4mOFJmSH3dJQAxDUAvUQrKdgm u+RwNAgznWydSUu5sRYFtce1g40cSiSXx+xMHySTLf6IphvV2aTFOO2oU5A37ZBMe2kFV56j8/m4s /QPeypzdKEyk57JlpjiiERt5syYusR5wUjk4Z1Y6dq+7kkho+87fSV1gVaTXwtb9+2sZc8NbuCjfd 69IVsCkTecDwuF7kVXyLfdiv1Kn0pKMuSpdGxjaznzyj1WANDswjqqyS3kwNDGsj9gE6NB0pkU7c9 FcdTahgtMCx+jOzad56w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PC-0000000A47Q-0LT1; Fri, 31 May 2024 11:26:42 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0P5-0000000A435-2Rg4 for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:37 +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=jj7AcYEJSvX8DA6Efl2MBL0SU/0tAK+cClfs48CxxHo=; b=FcF+3s6ukj7zNSKLyCLVdDN5Tw AIzF6t+uVVlGf4UDE2zFMI+FacTEu7JeR2lUrjFeIYZXm+61Dec5MXncFX3KUnyPQD11dp+LAYc+2 iuDX+NSu77AXY22P7m9U3GJcjTVf7V2En5q3+Sw6yYuVxpVD1vLixLc7fp387MpXrAsOe/U7Qc/FL tDQXC4E7M7HIH8RQyFvqueBQ8iAycuSXS+F+ugKea+8nFPsCROzKcJmH4rq95CkXqlQul0kq9Qw/I lLEDQFpSDgPZBVcBZXy/o7kXirsjspv83WsKCBpU1UiZ2eaBdk3UAR8SVhmHDR3bQu4xwjkC0tkp1 bfFjP44w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59324 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 1sD0On-0008RU-1m; Fri, 31 May 2024 12:26:17 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0Oq-00EzBo-7r; Fri, 31 May 2024 12:26:20 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org Subject: [PATCH RFC net-next v2 2/8] net: stmmac: provide core phylink PCS infrastructure MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:20 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042635_664689_18082038 X-CRM114-Status: GOOD ( 15.78 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are some common operations shared between the dwmac hwifs, the only difference is where they are located within the device. These are already present in the form of dwmac_rane(), dwmac_ctrl_ane() and dwmac_get_adv_lp(). Rather than use these (which don't quite fit with phylink PCS, provide phylink PCS specific versions. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 58 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 10 ++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index c2f0e91f6bf8..9e15f7615ff4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \ dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \ stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ - stmmac_xdp.o stmmac_est.o \ + stmmac_xdp.o stmmac_est.o stmmac_pcs.o \ $(stmmac-y) stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c new file mode 100644 index 000000000000..849e6f121505 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -0,0 +1,58 @@ +#include "common.h" +#include "stmmac_pcs.h" + +int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, + unsigned int reg_base) +{ + u32 val; + + val = readl(hw->pcsr + GMAC_AN_CTRL(reg_base)); + + val |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + + if (hw->ps) + val |= GMAC_AN_CTRL_SGMRAL; + + writel(val, hw->pcsr + GMAC_AN_CTRL(reg_base)); + + return 0; +} + +void dwmac_pcs_get_state(struct mac_device_info *hw, + struct phylink_link_state *state, + unsigned int reg_base) +{ + u32 val; + + val = readl(hw->pcsr + GMAC_ANE_LPA(reg_base)); + + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + state->lp_advertising); + + if (val & GMAC_ANE_FD) { + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + state->lp_advertising); + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, + state->lp_advertising); + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, + state->lp_advertising); + } + + if (val & GMAC_ANE_HD) { + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, + state->lp_advertising); + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, + state->lp_advertising); + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, + state->lp_advertising); + } + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, + state->lp_advertising, + FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_PAUSE); + linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, + state->lp_advertising, + FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_ASYM_PAUSE); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 1bdf87b237c4..888485fa2761 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -137,4 +137,14 @@ static inline void dwmac_get_adv_lp(void __iomem *ioaddr, u32 reg, adv_lp->lp_pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT; } + +int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, + unsigned int reg_base); + +void dwmac_pcs_get_state(struct mac_device_info *hw, + struct phylink_link_state *state, + unsigned int reg_base); + #endif /* __STMMAC_PCS_H__ */ From patchwork Fri May 31 11:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681545 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 D8F59C25B75 for ; Fri, 31 May 2024 11:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=uNyldK7X0NMpDthBZzQtzxrdN6iZRL4xWhO4Lpjx4Y8=; b=LB3yaRWU7bPGZV RW4VxuVDdP7hBT28hfbeHZsaEJB/BOrZBfbHK3e1KBU2dK0pMm4OF2ZPweNizVn5OtWMz55+RLbnV pk3cWxaMi7fI9VD3vsGHQ6ii0sBvu958KbXpkh3uCrlSxUAsJ0M3k4EeHDbZLtLLXq/9OBGmse6cl WGEwX5rQ9AHzG0xV5YX9j371fXE2gibQrZF0OsIgbhhbdSYUBqjxCFxbZl3EJZgGIRKpDnt9qwIg6 sJ1ngY4hAtORSN37TrJ/SLXcKup5WJYLCXIutR6zijOL3IYhujTXJArYWGG+Q+fLbBiS3SkUBgIby WjaT4iwhxf2KTm12HSCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PU-0000000A4HW-14A5; Fri, 31 May 2024 11:27:00 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0P9-0000000A44U-3ZqU for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:42 +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=w+hJV1Y6OwOM4T6mSnn7qj2UsDUhsehMQ+K2hdlXRfg=; b=l6AvPnSTSdekvL8SdZWe4tLxMW d5kbnJNAwhAAZBiHDU0B2DJMaqX1mRBXpOQqc6V4kPMojnbRPAMRNucwbxMJZjwjQoStjvD1x2M0o zaDBIKrre1FRiWH/r5qCMcHq/64B5fQ/WkimHPp1I9nj1fiEkxtPV0fT8PxUy/G5ohwnSW8Q1DfKl szHv/Yf8M/FjKdrY9LgvbpnJwSruFwIjl/YrxV/oXJauR7DOdkoIZMdfKEmSO0L7INO5Apf8Vdj2Y yeFr+4p3vUfb8k1svXuijBWKdo2V11n44fq1cd5L6QeSxKBs+lxtjUtP2oVbVVrfQg1XMRVo+DFKB 1C8V5gfw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59326 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 1sD0Os-0008Ri-2Y; Fri, 31 May 2024 12:26:22 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0Ov-00EzBu-BC; Fri, 31 May 2024 12:26:25 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 3/8] net: stmmac: dwmac1000: convert sgmii/rgmii "pcs" to phylink MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:25 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042640_156241_2CED21AE X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert dwmac1000 sgmii/rgmii "pcs" implementation to use a phylink_pcs so we can eventually get rid of the exceptional paths that conflict with phylink. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 113 ++++++++++++------ 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index d413d76a8936..4a0572d5f865 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac1000.h" @@ -261,39 +262,6 @@ static void dwmac1000_pmt(struct mac_device_info *hw, unsigned long mode) writel(pmt, ioaddr + GMAC_PMT); } -/* RGMII or SMII interface */ -static void dwmac1000_rgsmii(void __iomem *ioaddr, struct stmmac_extra_stats *x) -{ - u32 status; - - status = readl(ioaddr + GMAC_RGSMIIIS); - x->irq_rgmii_n++; - - /* Check the link status */ - if (status & GMAC_RGSMIIIS_LNKSTS) { - int speed_value; - - x->pcs_link = 1; - - speed_value = ((status & GMAC_RGSMIIIS_SPEED) >> - GMAC_RGSMIIIS_SPEED_SHIFT); - if (speed_value == GMAC_RGSMIIIS_SPEED_125) - x->pcs_speed = SPEED_1000; - else if (speed_value == GMAC_RGSMIIIS_SPEED_25) - x->pcs_speed = SPEED_100; - else - x->pcs_speed = SPEED_10; - - x->pcs_duplex = (status & GMAC_RGSMIIIS_LNKMOD_MASK); - - pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed, - x->pcs_duplex ? "Full" : "Half"); - } else { - x->pcs_link = 0; - pr_info("Link is Down\n"); - } -} - static int dwmac1000_irq_status(struct mac_device_info *hw, struct stmmac_extra_stats *x) { @@ -335,8 +303,12 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); - if (intr_status & PCS_RGSMIIIS_IRQ) - dwmac1000_rgsmii(ioaddr, x); + if (intr_status & PCS_RGSMIIIS_IRQ) { + /* TODO Dummy-read to clear the IRQ status */ + readl(ioaddr + GMAC_RGSMIIIS); + phylink_pcs_change(&hw->mac_pcs, false); + x->irq_rgmii_n++; + } return ret; } @@ -404,9 +376,71 @@ static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral, dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } -static void dwmac1000_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) +static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, + unsigned long *supported, + const struct phylink_link_state *state) +{ + /* Only support in-band */ + if (!test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising)) + return -EINVAL; + + return 0; +} + +static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, + unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) { - dwmac_get_adv_lp(ioaddr, GMAC_PCS_BASE, adv); + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + + return dwmac_pcs_config(hw, neg_mode, interface, advertising, + GMAC_PCS_BASE); +} + +static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + unsigned int spd_clk; + u32 status; + + status = readl(hw->pcsr + GMAC_RGSMIIIS); + + state->link = status & GMAC_RGSMIIIS_LNKSTS; + if (!state->link) + return; + + spd_clk = FIELD_GET(GMAC_RGSMIIIS_SPEED, status); + if (spd_clk == GMAC_RGSMIIIS_SPEED_125) + state->speed = SPEED_1000; + else if (spd_clk == GMAC_RGSMIIIS_SPEED_25) + state->speed = SPEED_100; + else if (spd_clk == GMAC_RGSMIIIS_SPEED_2_5) + state->speed = SPEED_10; + + state->duplex = status & GMAC_RGSMIIIS_LNKMOD_MASK ? + DUPLEX_FULL : DUPLEX_HALF; + + dwmac_pcs_get_state(hw, state, GMAC_PCS_BASE); +} + +static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { + .pcs_validate = dwmac1000_mii_pcs_validate, + .pcs_config = dwmac1000_mii_pcs_config, + .pcs_get_state = dwmac1000_mii_pcs_get_state, +}; + +static struct phylink_pcs * +dwmac1000_phylink_select_pcs(struct stmmac_priv *priv, + phy_interface_t interface) +{ + if (priv->hw->pcs & STMMAC_PCS_RGMII || + priv->hw->pcs & STMMAC_PCS_SGMII) + return &priv->hw->mac_pcs; + + return NULL; } static void dwmac1000_debug(struct stmmac_priv *priv, void __iomem *ioaddr, @@ -499,6 +533,7 @@ static void dwmac1000_set_mac_loopback(void __iomem *ioaddr, bool enable) const struct stmmac_ops dwmac1000_ops = { .core_init = dwmac1000_core_init, + .phylink_select_pcs = dwmac1000_phylink_select_pcs, .set_mac = stmmac_set_mac, .rx_ipc = dwmac1000_rx_ipc_enable, .dump_regs = dwmac1000_dump_regs, @@ -514,7 +549,6 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, .pcs_ctrl_ane = dwmac1000_ctrl_ane, - .pcs_get_adv_lp = dwmac1000_get_adv_lp, .set_mac_loopback = dwmac1000_set_mac_loopback, }; @@ -549,5 +583,8 @@ int dwmac1000_setup(struct stmmac_priv *priv) mac->mii.clk_csr_shift = 2; mac->mii.clk_csr_mask = GENMASK(5, 2); + mac->mac_pcs.ops = &dwmac1000_mii_pcs_ops; + mac->mac_pcs.neg_mode = true; + return 0; } From patchwork Fri May 31 11:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681544 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 9CD78C25B7C for ; Fri, 31 May 2024 11:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=PMFshi8Akk7IN2Voc4cMYztQRuTOJ/x36cfsGxoc0uU=; b=orBtFW6LwFkiis erUEDSYByjuxgLIRgcsYM3RjrOdeGsPN9fjB/T8vkcdDWi7HrhSoLbsUGK+UIi2mjt/ehn1sR4i3P dhH+uVQErQ4MyOIjyjKiXBLmw4YNfbG6BJDCsjTdSzt3lzTGHANzhN5mTeTKbtp18+FYjQZPpJKXH S/o4e1aG6HggWX0IGmVn+FAJHeWR0Y1yxNwQdmpSeXbcbtrkaooUeINuUamqLXmTF6jwETlqwTts9 D5o1uUYUJeTXzOGSYYNTgMWOnt4eZKP27iwI+bShCLMXMgQ0NML3FhVDWJL5nScL+i6O40GByP9pr L05Yfh18hDOV6tq2BOUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PW-0000000A4IV-0LFc; Fri, 31 May 2024 11:27:02 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PE-0000000A48Q-39iX for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:48 +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=7DUZ/QJwKjlEf/7QUPAOogKJPw017FgEZY7g/VFAZT4=; b=EE8b+sJLsyCTUigJ6jljrYvC+R km5VfDG6dRdgm/I1jvHcT3inY98dSTpzOlvHbkkAXGqJLySsVTImSBF22XDESmSShvz/0JKkiNoos omMMoWGca6ya0a+rZJXIAJibFibUxdXzS73OOF5m57F8pgw8eyoFg1tOY6ibmLgbZhilMS7qkPUc7 /AmVzMs5DdbBzoRArO9Ibzhlbw8Ldn9bdGnLEwj78UJ1rNxxx/RqYW7i915crEFxOvQr1ydTnOhml wJJ9WmwuKcyafj1Wf9hmhZVyHrjWuYuJueFv0y2nZg2YHxI972Jn5yXAExx6OvAZMI/qzxn9PsuZq tD9zOdeA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44044 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 1sD0Oy-0008Ry-0B; Fri, 31 May 2024 12:26:28 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0P0-00EzC0-J8; Fri, 31 May 2024 12:26:30 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 4/8] net: stmmac: dwmac1000: move PCS interrupt control MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:30 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042644_869434_CCE57313 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Control the PCS interrupt mask from phylink's pcs_enable() and pcs_disable() methods rather than relying on driver variables. This assumes that GMAC_INT_DISABLE_RGMII, GMAC_INT_DISABLE_PCSLINK and GMAC_INT_DISABLE_PCSAN are all relevant to the PCS. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 4a0572d5f865..3ba65ea3e46f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -56,12 +56,7 @@ static void dwmac1000_core_init(struct mac_device_info *hw, writel(value, ioaddr + GMAC_CONTROL); /* Mask GMAC interrupts */ - value = GMAC_INT_DEFAULT_MASK; - - if (hw->pcs) - value &= ~GMAC_INT_DISABLE_PCS; - - writel(value, ioaddr + GMAC_INT_MASK); + writel(GMAC_INT_DEFAULT_MASK, ioaddr + GMAC_INT_MASK); #ifdef STMMAC_VLAN_TAG_USED /* Tag detection without filtering */ @@ -387,6 +382,30 @@ static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, return 0; } +static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask &= ~GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); + + return 0; +} + +static void dwmac1000_mii_pcs_disable(struct phylink_pcs *pcs) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask |= GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, @@ -428,6 +447,8 @@ static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { .pcs_validate = dwmac1000_mii_pcs_validate, + .pcs_enable = dwmac1000_mii_pcs_enable, + .pcs_disable = dwmac1000_mii_pcs_disable, .pcs_config = dwmac1000_mii_pcs_config, .pcs_get_state = dwmac1000_mii_pcs_get_state, }; From patchwork Fri May 31 11:26:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681546 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 8059AC25B75 for ; Fri, 31 May 2024 11:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=9HBSCb/yWIg/9TRLw85yS/W0KphSzsINJd/lDLI3yNo=; b=hOH/F+KLci0GOs +xHCidTcyd9MHxaWPtZbUgnHzGNlmwyFZ/7UG2wlphX/MH8hTUIRiiocX0EbGkxhJQH8JvXLssb7N Rp8JP8oolrH5DMvWbXX3DitDqn02YB9FbbEvWvjJRXnt3WXqt2guij1+VqrgDQXAjW4Dq/KbzIQom YFcRsYK0omf3jNdF8HJP8CEKX0eSUhldZ3JODzhJIyGA16zZtfEWww4IpUepR6l9nPGJZPDTRifv1 uxqawoL+z1nkzoNgkdSdZOkVlu8UDGza58qPBNGJUJMXi8S64t1JnsuD+gcdqHls2jqWZvWv8JAA9 J5fUifeFYzKz4eb17yfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0Pb-0000000A4LE-0g1V; Fri, 31 May 2024 11:27:07 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PL-0000000A4BL-2HGc for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:55 +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=qpacFX5VDJA8hqeTYWlxmcQDH7WR5LnO+Gr7wC03k4w=; b=L7TkgavT1I7Vf1zeF5TFVRCPEj 0UPVZGv3ZgRnjkTWVNNzu2n5AQh1Df3/3thGflGhS2FAq/7zroKoA6mivRDAILqrgIdkZex/CJFcU BKPeGVCH5kDg8cofP/zjhBEXFZehElg+s8bjcbV+lps6t5AIFtJjSlbZiG8X16V6cb960ZcVsQtVD RPH6tbt9WW9P+cYxz0tYA2Ca7CTYO9GEy+PBbFZ2Emkx/uE6BjyKlTgImQ53aiYyqqJvdRJ/Bukku p+w1NEaxttykYdhObzu5gsprW6EWa0P0cITE8Xq0hnvVtITNclt+87XfH60XjCaXvDGDm+Xwe3VuE 7bsd8KoQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44060 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 1sD0P4-0008SI-09; Fri, 31 May 2024 12:26:34 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0P5-00EzC6-Me; Fri, 31 May 2024 12:26:35 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 5/8] net: stmmac: dwmac4: convert sgmii/rgmii "pcs" to phylink MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:35 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042651_944740_3E4A5CBC X-CRM114-Status: GOOD ( 18.58 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert dwmac4 sgmii/rgmii "pcs" implementation to use a phylink_pcs so we can eventually get rid of the exceptional paths that conflict with phylink. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 102 ++++++++++++------ 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index dbd9f93b2460..cb99cb69c52b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac4.h" @@ -758,42 +759,76 @@ static void dwmac4_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral, dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } -static void dwmac4_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) +static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, + unsigned long *supported, + const struct phylink_link_state *state) { - dwmac_get_adv_lp(ioaddr, GMAC_PCS_BASE, adv); + /* Only support in-band */ + if (!test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising)) + return -EINVAL; + + return 0; } -/* RGMII or SMII interface */ -static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x) +static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) { + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + + return dwmac_pcs_config(hw, neg_mode, interface, advertising, + GMAC_PCS_BASE); +} + +static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + unsigned int clk_spd; u32 status; - status = readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); - x->irq_rgmii_n++; + status = readl(hw->pcsr + GMAC_PHYIF_CONTROL_STATUS); + + state->link = !!(status & GMAC_PHYIF_CTRLSTATUS_LNKSTS); + if (!state->link) + return; - /* Check the link status */ - if (status & GMAC_PHYIF_CTRLSTATUS_LNKSTS) { - int speed_value; + clk_spd = FIELD_GET(GMAC_PHYIF_CTRLSTATUS_SPEED, status); + if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_125) + state->speed = SPEED_1000; + else if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_25) + state->speed = SPEED_100; + else if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_2_5) + state->speed = SPEED_10; + + /* FIXME: Is this even correct? + * GMAC_PHYIF_CTRLSTATUS_TC = BIT(0) + * GMAC_PHYIF_CTRLSTATUS_LNKMOD = BIT(16) + * GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK = 1 + * + * The result is, we test bit 0 for the duplex setting. + */ + state->duplex = status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK ? + DUPLEX_FULL : DUPLEX_HALF; - x->pcs_link = 1; + dwmac_pcs_get_state(hw, state, GMAC_PCS_BASE); +} - speed_value = ((status & GMAC_PHYIF_CTRLSTATUS_SPEED) >> - GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT); - if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_125) - x->pcs_speed = SPEED_1000; - else if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_25) - x->pcs_speed = SPEED_100; - else - x->pcs_speed = SPEED_10; +static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { + .pcs_validate = dwmac4_mii_pcs_validate, + .pcs_config = dwmac4_mii_pcs_config, + .pcs_get_state = dwmac4_mii_pcs_get_state, +}; - x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK); +static struct phylink_pcs * +dwmac4_phylink_select_pcs(struct stmmac_priv *priv, phy_interface_t interface) +{ + if (priv->hw->pcs & STMMAC_PCS_RGMII || + priv->hw->pcs & STMMAC_PCS_SGMII) + return &priv->hw->mac_pcs; - pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed, - x->pcs_duplex ? "Full" : "Half"); - } else { - x->pcs_link = 0; - pr_info("Link is Down\n"); - } + return NULL; } static int dwmac4_irq_mtl_status(struct stmmac_priv *priv, @@ -867,8 +902,12 @@ static int dwmac4_irq_status(struct mac_device_info *hw, } dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); - if (intr_status & PCS_RGSMIIIS_IRQ) - dwmac4_phystatus(ioaddr, x); + if (intr_status & PCS_RGSMIIIS_IRQ) { + /* TODO Dummy-read to clear the IRQ status */ + readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); + phylink_pcs_change(&hw->mac_pcs, false); + x->irq_rgmii_n++; + } return ret; } @@ -1186,6 +1225,7 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw) const struct stmmac_ops dwmac4_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, + .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1210,7 +1250,6 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1230,6 +1269,7 @@ const struct stmmac_ops dwmac4_ops = { const struct stmmac_ops dwmac410_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, + .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_dwmac4_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1254,7 +1294,6 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, @@ -1278,6 +1317,7 @@ const struct stmmac_ops dwmac410_ops = { const struct stmmac_ops dwmac510_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, + .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_dwmac4_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1302,7 +1342,6 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, @@ -1391,5 +1430,8 @@ int dwmac4_setup(struct stmmac_priv *priv) mac->mii.clk_csr_mask = GENMASK(11, 8); mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr); + mac->mac_pcs.ops = &dwmac4_mii_pcs_ops; + mac->mac_pcs.neg_mode = true; + return 0; } From patchwork Fri May 31 11:26:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681547 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 098F8C25B7C for ; Fri, 31 May 2024 11:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=pDP91dCC+1ccnJMsI7IvV3i4DAKoFnHkCtBN/VKHgU0=; b=DGGp09qlboBZex WSK997t1InzoAvkYCYWmJyK1SzFkRp1xilLuJSCRrvHFtB13p4dBpJ+8ipauvV7zi/ozzQpzyNed6 kNDpi3jD+fCn0EZILqKW0a5U8vbFLGhbZDnVZCMV/tVsV8QVTaAN+h+ZM8STSG2jVQVHFCjM62K2b RkJW2ZWsKnamK/AEZPpAZsoALWAQZzgGZirkXCuibK33lsoG2aAJQPunlSxh7ShmIFg2te2gb9sxM 4u/cJ7ka8gfYcSey2r9hr2W9Bq3wi6oLTVnOFehMcD5cFgpwpKzjobsbl8WtA/mxzGxXHtdChTqF4 s0jTV64zMLCUui08YDSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0Pd-0000000A4MO-03Ak; Fri, 31 May 2024 11:27:09 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PQ-0000000A4Em-0eNU for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:26:58 +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=nYV0iwaM4CrzqivMDUO7NpiYXQHAZmA2iACOt/v5Uqw=; b=mdiCJmxl5lFpKc42IfdPL7sG0Y yhaC0eybZDMUUz1JsIXzDRzvGNXhnX3j3BvEWhMqokJ1EsNURsoHOWml8TWUvmRgceh5DWkWctS4r CRxeeKrYZwaecnmmBs7Zn3otZIn21hXgeB5Esn3/KTODsfVfUQasQX+2sGn4oJN0wE8uVXiOqLYGA Fr1bSIx5dAvOO7YDjxWhP4YrGVdKeoWJWk9BHnllwbzWzumtrmQP49xgoSRMRXjCD58Re2hyxxOrI mbcHZ1cbGQk1Hk8KLzAAIsp/+i/nUS4cYH3S5q2+ahY6JeGGwih+BWekAN8GGgbixFkFJc6eB3xqL wSsQB7xA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34888 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 1sD0P8-0008SZ-2T; Fri, 31 May 2024 12:26:38 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0PA-00EzCC-Qb; Fri, 31 May 2024 12:26:40 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 6/8] net: stmmac: dwmac4: move PCS interrupt control MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:40 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042656_392829_9E5515F0 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Control the PCS interrupt mask from the phylink pcs_enable() and pcs_disable() methods rather than relying on driver variables. This assumes that GMAC_INT_RGSMIIS, GMAC_INT_PCS_LINK and GMAC_INT_PCS_ANE are all relevant to the PCS. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index cb99cb69c52b..5cf2a6cb8f66 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -56,9 +56,6 @@ static void dwmac4_core_init(struct mac_device_info *hw, /* Enable GMAC interrupts */ value = GMAC_INT_DEFAULT_ENABLE; - if (hw->pcs) - value |= GMAC_PCS_IRQ_DEFAULT; - /* Enable FPE interrupt */ if ((GMAC_HW_FEAT_FPESEL & readl(ioaddr + GMAC_HW_FEATURE3)) >> 26) value |= GMAC_INT_FPE_EN; @@ -770,6 +767,30 @@ static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, return 0; } +static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable |= GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); + + return 0; +} + +static void dwmac4_mii_pcs_disable(struct phylink_pcs *pcs) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable &= ~GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); +} + static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising, @@ -817,6 +838,8 @@ static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { .pcs_validate = dwmac4_mii_pcs_validate, + .pcs_enable = dwmac4_mii_pcs_enable, + .pcs_disable = dwmac4_mii_pcs_disable, .pcs_config = dwmac4_mii_pcs_config, .pcs_get_state = dwmac4_mii_pcs_get_state, }; From patchwork Fri May 31 11:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681549 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 22580C25B75 for ; Fri, 31 May 2024 11:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=jU9TOvpefdO8T1PNKBO4O+7wukq4wLzBfo9NCBYjH/E=; b=2mHB1Qrw+M3BUZ fq8dUDi5C+IldxY7NXs9drBXyFLP1zh56TckwMgb0nE+lLrGG3UYjpMokSnYlR56cvNVevRbgefDk D/XZg7R/VxFmZqIMg5QiskC+YXMErsKzbjOyKGsxBjfrcQt1HajhXYCu+3WaQqtGdeyhDuxPuX9W0 aXjXiyUprYM6va1MaHV5PkjmqUgLtbwlbRGAdKwKYkjMh4Cytpx9muFzG5zYiGlMxxsQWzYWTCTYO i9XBpLinMyyoZ4MHwFgulA2vYexF+xsMQehWaSKPdUU4TbXbk+n6MWFGWuBs9yMGLSghPSiRmuVf+ KdC3EY6MmiFHFPqpSbTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0QL-0000000A4hl-0FNl; Fri, 31 May 2024 11:27:53 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PU-0000000A4HJ-1dWB for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:27:03 +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=IJqln5CuneS2TvD1H9y/Tz8bk9KxHi2kkk+NrB7yFlU=; b=UAGagerFYK9Dr2Z2gvazyIG2XD jRMd9D0LVd0sTZrFi/ag5R5RDtjqPXfj5u6q6aIorRYDdo9DmKZVEaLng9yWMeCRU3T9SNtWjTLKf LTwHkot2z0Bd+4RYlVeI4+8Gg+t3GgxgNEcrUZhSjFhJL3G8I7okK7D5kh3H/laZTCKjfI2Y97qfG uKABc6+a0hemA6yrr/iAGztwUqjJdxQAeSsNGhz78wJCkgN96uqIxrNgvQe7Tj6j30Ngpz2f8rWUw W7U4JFzaJGnoH4PX7pk7w7iQ1zICgsoOxaSqAQSbb6DD+JqInAv0CYYeglyI88jcKQVK5KcvBJj6m 8FzRO7GA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34898 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 1sD0PE-0008Su-1e; Fri, 31 May 2024 12:26:45 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0PF-00EzCJ-UL; Fri, 31 May 2024 12:26:45 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 7/8] net: stmmac: remove obsolete pcs methods and associated code MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:45 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042700_770280_BCB0E5C9 X-CRM114-Status: GOOD ( 18.28 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pcs_ctrl_ane() and pcs_get_adv_lp(0 methods are no longer required as this will be handled by the mac_pcs phylink_pcs instance. Remove these methods, their common implementation, the pcs_link, pcs_duplex and pcs_speed members of struct stmmac_extra_stats, and stmmac_has_mac_phylink_select_pcs(). Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/common.h | 3 - drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 - .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 115 +----------------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 13 -- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 30 ----- 5 files changed, 2 insertions(+), 165 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 940e83fa1202..a66b836996d6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -191,9 +191,6 @@ struct stmmac_extra_stats { unsigned long irq_pcs_ane_n; unsigned long irq_pcs_link_n; unsigned long irq_rgmii_n; - unsigned long pcs_link; - unsigned long pcs_duplex; - unsigned long pcs_speed; /* debug register */ unsigned long mtl_tx_status_fifo_full; unsigned long mtl_tx_fifo_not_empty; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index aa5f6e40cb53..8a17e7d6e37d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -378,7 +378,6 @@ struct stmmac_ops { /* PCS calls */ void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral, bool loopback); - void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv); /* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp, struct stmmac_safety_feature_cfg *safety_cfg); @@ -495,8 +494,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, debug, __priv, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) -#define stmmac_pcs_get_adv_lp(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) #define stmmac_safety_feat_config(__priv, __args...) \ stmmac_do_callback(__priv, mac, safety_feat_config, __args) #define stmmac_safety_feat_irq_status(__priv, __args...) \ @@ -542,9 +539,6 @@ struct stmmac_ops { #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) -#define stmmac_has_mac_phylink_select_pcs(__priv) \ - ((__priv)->hw->mac->phylink_select_pcs != NULL) - /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 7c6530d63ade..db439d00f692 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -321,85 +321,6 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev, { struct stmmac_priv *priv = netdev_priv(dev); - if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && - (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII) && - !stmmac_has_mac_phylink_select_pcs(priv)) { - struct rgmii_adv adv; - u32 supported, advertising, lp_advertising; - - if (!priv->xstats.pcs_link) { - cmd->base.speed = SPEED_UNKNOWN; - cmd->base.duplex = DUPLEX_UNKNOWN; - return 0; - } - cmd->base.duplex = priv->xstats.pcs_duplex; - - cmd->base.speed = priv->xstats.pcs_speed; - - /* Get and convert ADV/LP_ADV from the HW AN registers */ - if (stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv)) - return -EOPNOTSUPP; /* should never happen indeed */ - - /* Encoding of PSE bits is defined in 802.3z, 37.2.1.4 */ - - ethtool_convert_link_mode_to_legacy_u32( - &supported, cmd->link_modes.supported); - ethtool_convert_link_mode_to_legacy_u32( - &advertising, cmd->link_modes.advertising); - ethtool_convert_link_mode_to_legacy_u32( - &lp_advertising, cmd->link_modes.lp_advertising); - - if (adv.pause & STMMAC_PCS_PAUSE) - advertising |= ADVERTISED_Pause; - if (adv.pause & STMMAC_PCS_ASYM_PAUSE) - advertising |= ADVERTISED_Asym_Pause; - if (adv.lp_pause & STMMAC_PCS_PAUSE) - lp_advertising |= ADVERTISED_Pause; - if (adv.lp_pause & STMMAC_PCS_ASYM_PAUSE) - lp_advertising |= ADVERTISED_Asym_Pause; - - /* Reg49[3] always set because ANE is always supported */ - cmd->base.autoneg = ADVERTISED_Autoneg; - supported |= SUPPORTED_Autoneg; - advertising |= ADVERTISED_Autoneg; - lp_advertising |= ADVERTISED_Autoneg; - - if (adv.duplex) { - supported |= (SUPPORTED_1000baseT_Full | - SUPPORTED_100baseT_Full | - SUPPORTED_10baseT_Full); - advertising |= (ADVERTISED_1000baseT_Full | - ADVERTISED_100baseT_Full | - ADVERTISED_10baseT_Full); - } else { - supported |= (SUPPORTED_1000baseT_Half | - SUPPORTED_100baseT_Half | - SUPPORTED_10baseT_Half); - advertising |= (ADVERTISED_1000baseT_Half | - ADVERTISED_100baseT_Half | - ADVERTISED_10baseT_Half); - } - if (adv.lp_duplex) - lp_advertising |= (ADVERTISED_1000baseT_Full | - ADVERTISED_100baseT_Full | - ADVERTISED_10baseT_Full); - else - lp_advertising |= (ADVERTISED_1000baseT_Half | - ADVERTISED_100baseT_Half | - ADVERTISED_10baseT_Half); - cmd->base.port = PORT_OTHER; - - ethtool_convert_legacy_u32_to_link_mode( - cmd->link_modes.supported, supported); - ethtool_convert_legacy_u32_to_link_mode( - cmd->link_modes.advertising, advertising); - ethtool_convert_legacy_u32_to_link_mode( - cmd->link_modes.lp_advertising, lp_advertising); - - return 0; - } - return phylink_ethtool_ksettings_get(priv->phylink, cmd); } @@ -409,21 +330,6 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev, { struct stmmac_priv *priv = netdev_priv(dev); - if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && - (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII) && - !stmmac_has_mac_phylink_select_pcs(priv)) { - /* Only support ANE */ - if (cmd->base.autoneg != AUTONEG_ENABLE) - return -EINVAL; - - mutex_lock(&priv->lock); - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, priv->hw->ps, 0); - mutex_unlock(&priv->lock); - - return 0; - } - return phylink_ethtool_ksettings_set(priv->phylink, cmd); } @@ -523,16 +429,8 @@ stmmac_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct stmmac_priv *priv = netdev_priv(netdev); - struct rgmii_adv adv_lp; - if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv) && - !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { - pause->autoneg = 1; - if (!adv_lp.pause) - return; - } else { - phylink_ethtool_get_pauseparam(priv->phylink, pause); - } + phylink_ethtool_get_pauseparam(priv->phylink, pause); } static int @@ -540,17 +438,8 @@ stmmac_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct stmmac_priv *priv = netdev_priv(netdev); - struct rgmii_adv adv_lp; - if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv) && - !stmmac_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { - pause->autoneg = 1; - if (!adv_lp.pause) - return -EOPNOTSUPP; - return 0; - } else { - return phylink_ethtool_set_pauseparam(priv->phylink, pause); - } + return phylink_ethtool_set_pauseparam(priv->phylink, pause); } static u64 stmmac_get_rx_normal_irq_n(struct stmmac_priv *priv, int q) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 56c351e11952..ad19ba42c412 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3485,9 +3485,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) } } - if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, priv->hw->ps, 0); - /* set TX and RX rings length */ stmmac_set_rings_length(priv); @@ -6053,16 +6050,6 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) for (queue = 0; queue < queues_count; queue++) stmmac_host_mtl_irq_status(priv, priv->hw, queue); - /* PCS link status */ - if (priv->hw->pcs && - !(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) && - !stmmac_has_mac_phylink_select_pcs(priv)) { - if (priv->xstats.pcs_link) - netif_carrier_on(priv->dev); - else - netif_carrier_off(priv->dev); - } - stmmac_timestamp_interrupt(priv, priv); } } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 888485fa2761..27ea7f4d789d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -108,36 +108,6 @@ static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, writel(value, ioaddr + GMAC_AN_CTRL(reg)); } -/** - * dwmac_get_adv_lp - Get ADV and LP cap - * @ioaddr: IO registers pointer - * @reg: Base address of the AN Control Register. - * @adv_lp: structure to store the adv,lp status - * Description: this is to expose the ANE advertisement and Link partner ability - * status to ethtool support. - */ -static inline void dwmac_get_adv_lp(void __iomem *ioaddr, u32 reg, - struct rgmii_adv *adv_lp) -{ - u32 value = readl(ioaddr + GMAC_ANE_ADV(reg)); - - if (value & GMAC_ANE_FD) - adv_lp->duplex = DUPLEX_FULL; - if (value & GMAC_ANE_HD) - adv_lp->duplex |= DUPLEX_HALF; - - adv_lp->pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT; - - value = readl(ioaddr + GMAC_ANE_LPA(reg)); - - if (value & GMAC_ANE_FD) - adv_lp->lp_duplex = DUPLEX_FULL; - if (value & GMAC_ANE_HD) - adv_lp->lp_duplex = DUPLEX_HALF; - - adv_lp->lp_pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT; -} - int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising, From patchwork Fri May 31 11:26:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13681548 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 C2DEDC25B7C for ; Fri, 31 May 2024 11:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: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=0aWjJOZPeeFb/QvadeDwyrN3w+U2QDqW8BqTqwMm0vk=; b=SKKWyisFkUpcgx 5AIazmgPfEVfwwyxMqVVsG4lJtkEQ24myEoQSCJ/ox7nS6eaeD8kobpgJnktCzL2lnU0pPFJXyKlt 2+xjy0AoszHcojns+Mcypth1ZaxT8G4ebH+5n9CSecNHTcyMrjA8IYIG/RAAnwoxTyOCgo+WRwlPP OiestSIVXXbqZYvHVGGJ2UKcmffOgDbJ5/Lt4ESymrBy1vuyZR2JgTvjpPxLKGy0sHo8cy/fNg/h5 Tq9EzFJ+AJTIBML3jCA9N1HbPO6RHlZjZsuYE0iKN0b/JtaL9/x22U11EXjhpKrb7dMaFN/9RHMx2 ZPhIxK1c8jlVX9lFpG/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0QL-0000000A4iJ-3Yxi; Fri, 31 May 2024 11:27:53 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD0PX-0000000A4Ix-3yQq for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2024 11:27:08 +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=yz4eTBWoxbuuF2Ohye0DezdsGM6F55QSQ6ouR9V4Ptc=; b=EXs2dttXM8ndBMt8IApzgkEDHA ga7xrkejCRdN7lqD2UVBjsJpQEWWoXRv7yLAF9K/jZ3CNcb3JxHjUWL0h61Hv7j2DpFRoeJ1wOm5y Gi2JpJxYxsu+6jJ4TcWLQDQTcDtM3zZLVr+yuqdYKngWiBAtbIzfYiVGLrcIStLSSfc4IRmCmah3C orNEaZCslTVJvctl6/IqeJMdbHoQLHZ0eQ2jRInDO8ULH2zkpKuGhhIZ1ZsCk1y2EsIMXPpwS+8qx NCqDByD6TAo4cdI5fI8e3rhQ8BoQnOTY90lDk/lBFuy0Zx1URcpNxfTKcZl/4iZP+Tg79oH2SOzQN iy5nyZKw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:32886 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 1sD0PJ-0008TA-1W; Fri, 31 May 2024 12:26:49 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sD0PL-00EzCP-1u; Fri, 31 May 2024 12:26:51 +0100 In-Reply-To: References: From: Russell King (Oracle) To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC net-next v2 8/8] net: stmmac: Activate Inband/PCS flag based on the selected iface MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 31 May 2024 12:26:51 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240531_042704_387545_AC211F2E X-CRM114-Status: GOOD ( 16.85 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Serge Semin The HWFEATURE.PCSSEL flag is set if the PCS block has been synthesized into the DW GMAC controller. It's always done if the controller supports at least one of the SGMII, TBI, RTBI PHY interfaces. If none of these interfaces support was activated during the IP-core synthesize the PCS block won't be activated either and the HWFEATURE.PCSSEL flag won't be set. Based on that the RGMII in-band status detection procedure implemented in the driver hasn't been working for the devices with the RGMII interface support and with none of the SGMII, TBI, RTBI PHY interfaces available in the device. Fix that just by dropping the dma_cap.pcs flag check from the conditional statement responsible for the In-band/PCS functionality activation. If the RGMII interface is supported by the device then the in-band link status detection will be also supported automatically (it's always embedded into the RGMII RTL code). If the SGMII interface is supported by the device then the PCS block will be supported too (it's unconditionally synthesized into the controller). The later is also correct for the TBI/RTBI PHY interfaces. Note while at it drop the netdev_dbg() calls since at the moment of the stmmac_check_pcs_mode() invocation the network device isn't registered. So the debug prints will be for the unknown/NULL device. Signed-off-by: Serge Semin [rmk: fix build errors, only use PCS for SGMII if priv->dma_cap.pcs is set] Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ad19ba42c412..4384d61a3bcd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1132,18 +1132,10 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv) { int interface = priv->plat->mac_interface; - if (priv->dma_cap.pcs) { - if ((interface == PHY_INTERFACE_MODE_RGMII) || - (interface == PHY_INTERFACE_MODE_RGMII_ID) || - (interface == PHY_INTERFACE_MODE_RGMII_RXID) || - (interface == PHY_INTERFACE_MODE_RGMII_TXID)) { - netdev_dbg(priv->dev, "PCS RGMII support enabled\n"); - priv->hw->pcs = STMMAC_PCS_RGMII; - } else if (interface == PHY_INTERFACE_MODE_SGMII) { - netdev_dbg(priv->dev, "PCS SGMII support enabled\n"); - priv->hw->pcs = STMMAC_PCS_SGMII; - } - } + if (phy_interface_mode_is_rgmii(interface)) + priv->hw->pcs = STMMAC_PCS_RGMII; + else if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) + priv->hw->pcs = STMMAC_PCS_SGMII; } /** From patchwork Mon Jun 24 13:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709516 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 61A80C2BD09 for ; Mon, 24 Jun 2024 13:28:50 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=weoB2927OHeQLkItSsl1+92aESa5A0VbbSHXdYNaCxU=; b=YIoSSZn2x6zGcO9mUgflYBtc6K KwdEFLUtmBFSGVZrUkzcoIUrEjdrDYtvPUho9tPucAO7A133fwICtHo5Q1GIE2DFqczvUGLo0j5V/ riaiOAKR+gqyjz0iIV0k2/ycsTPX+1QKV5ugPsh0fsrSR15mx9W9EO9hs/tcdvReDz+Soj/sE1PqX JB1TOsFVFQP8lE+gQTyhCgK1ks65pxqT2rnn8Qih+owblz853a1QqZyuHfA+1BR30cfb7KvW3kBUs eg5MYYUYxhJgAzse13OQ92poz8HSP7PHBeTn3B7qF78S3tnxKET2DAjqf+eZ4t3kvxqEz1kSvYQLZ dRCDjcAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkN-0000000Gv0E-1VHi; Mon, 24 Jun 2024 13:28:39 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkH-0000000Guwg-0PYx for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:34 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52cd87277d8so2669950e87.2 for ; Mon, 24 Jun 2024 06:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235711; x=1719840511; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=weoB2927OHeQLkItSsl1+92aESa5A0VbbSHXdYNaCxU=; b=g3T41FiBfYqGal/w0VK96zEqAA4Z9bFz3qAstlkYPfQBRxnOO0cT1FIDY/DwB8Eh4U bVB6eZn1gjl+e9gzg8hDa4EYaGUWBtAdxu6gN7Gn7MgonIe+m7q8p10/Wn6FIo41vJEu SC9Bgjt+njQsMPXqkdM4BXwR2q6qTD11rK28hJliobjcmluRrqBgsv3oBrbHmMERNZEm F18ImPDdzoyWTu0vOvycz9kIaFrjJU+kZPeWWPRVOKmwtW4eYF25emDjGauUIKAeHx4Q 59OyCqxgGd30ytX6fZ55H+l8KRYGNeSjaZhYy5RH690DetcVeTcJm6RRfq2UM8GA9nDP CDiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235711; x=1719840511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=weoB2927OHeQLkItSsl1+92aESa5A0VbbSHXdYNaCxU=; b=ZFrO5kCIppvLRAxO4kYlWvMxtwC5HvstP51hFk+A40UgxVCYWCFRajmQEgLmARY41/ G2whdP2fvUZOVA+tbqvI950h872vikoTBkMTsthPDqW9/bZS3gVVca+oRrH4w4MwOO7H 28y41A1CgUsoFYHxzQnpZ7FTuYze6f69GSbR3r6LNY+/gCaOvaTXhZ2nLhTSmJrGg6/N 7x0l390Gdv+hjLePwF9OzLUPXc2Uwg8SWlK5I85yu7quouwWSzRVGQAlMLTNbxUSr9iF b5ErNk1lZQPbxnmXLYY6DM+djMaopIxnX37H5Y+pzNLqw2DBhDnaEPcveRfR6jgGDdRN 61Ig== X-Forwarded-Encrypted: i=1; AJvYcCUC0SvJZ91+GmhWjgX9Ie4pBG0dwUdQJYlUCQTAwjsOZZ4TsVOIvYuWgzuq6SBKNCA6HDg/zDLNUFnZ9oyyHoE09ph5WU5rVOC67kAHo6ajxsjtAcY= X-Gm-Message-State: AOJu0YzLibaQGO/CIWRSyAXbc2coSVEc2GuPLqO/2dBz4Q5nVOuV1J5g QPl0ZfDAjXlUPoGRpHKDvNYT461pf87jo2tjVuu1Xey70wkuxMk8 X-Google-Smtp-Source: AGHT+IFq8C6kBEtbmGEGitX4D9FUoJzf8LPqBHNhfBy21YGAueF442o3wAvxepev68ZGGljisU8J+g== X-Received: by 2002:a05:6512:ba1:b0:52c:dd38:f3a3 with SMTP id 2adb3069b0e04-52ce185cf4amr3356821e87.46.1719235710522; Mon, 24 Jun 2024 06:28:30 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd6454a96sm968129e87.303.2024.06.24.06.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:30 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 09/17] net: stmmac: Introduce mac_device_info::priv pointer Date: Mon, 24 Jun 2024 16:26:26 +0300 Message-ID: <20240624132802.14238-1-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062833_199779_401565BC X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is going to be introduced an PCS-specific CSR space pointer defined in the stmmac_priv structure nearby the mmcaddr, estaddr and ptpaddr fields. In order to have that pointer accessible from the PCS-specific callback, let's introduce pointer to stmmac_priv defined in the mac_device_info structure. Signed-off-by: Serge Semin --- Note the better approach would be to convert the mac_device_info instance to being embedded into the stmmac_priv structure. It would have solved many driver problems like non-unified HW abstraction interface, duplicated fields (ioaddr and pcsr, etc) or too many non-runtime parameters passed to the callbacks, etc. But the change also would have been much-much more invasive than this one is. If despite of that you find the mac_device_info embedding into stmmac_priv more appropriate (as I do), then I'll provide the respective patch in place of this one. --- drivers/net/ethernet/stmicro/stmmac/common.h | 1 + drivers/net/ethernet/stmicro/stmmac/hwif.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index a66b836996d6..f7661268518f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -580,6 +580,7 @@ struct mii_regs { }; struct mac_device_info { + struct stmmac_priv *priv; const struct stmmac_ops *mac; const struct stmmac_desc_ops *desc; const struct stmmac_dma_ops *dma; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 29367105df54..84fd57b76fad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -351,6 +351,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv) mac->tc = mac->tc ? : entry->tc; mac->mmc = mac->mmc ? : entry->mmc; mac->est = mac->est ? : entry->est; + mac->priv = priv; priv->hw = mac; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off; From patchwork Mon Jun 24 13:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709517 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 3E57BC2D0D1 for ; Mon, 24 Jun 2024 13:28:54 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GBRZg7O8NUfGqtDS+Z7CLeIhfmvXkPJ6rvrljuz9exI=; b=qshjZhVoPwRZ7TMEnJzJ4jIvdm 0oWbJP612AGZDhtqRF5gytINNIzJmMLGr0Jc/pMyBmOFzTpXTxZYwF/kfhJaJbuI1TlGJIscZt1OP JOVhFDzo9BpyKienT7L4JmNLhmseDbLmFfzgAzpQX+C+f3AmlKbsSumYR4RAetRV9FpQXmJ/QEdlD KvEOz5F3ZoQt74b14u23Qu8Oaw3PZUpacfj9m/Ez0vOVziCE47n+DUAIZCLMtnCyXu1MAfoMcJ1jk MH5Y7jP4IXccrGhJwzXAbwxkH08pFnNHrVIYVzbwakDq4Cm8aAOeefYcDETZFzl+o6sj8mafDXEgY Ege1cxig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkP-0000000Gv1C-0JJD; Mon, 24 Jun 2024 13:28:41 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkJ-0000000Guxx-3dqR for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:37 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so2711066e87.2 for ; Mon, 24 Jun 2024 06:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235713; x=1719840513; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GBRZg7O8NUfGqtDS+Z7CLeIhfmvXkPJ6rvrljuz9exI=; b=Y82ZTfO6HvBJTayipmyLl0NR6AUPODlBlSV12T27FazE+GXy3S19UYTSCnLw01LO83 kUZWKUIvCSnFr/Dp7tReqYymd/O8ZWjKLLM3rakkZH2XtMIk2DseNFUaLKAZ9tq1VUMk oKXOMMd+EVF+ukeiMXVFvRVbcuGdUgcs/nDOsOSJF0sizR27vgTkJElPZs76E53p84nw MhmTvkOYNJDC5aNRObCI+Cx1ApZyejPhK8y2VAwaPM3Ze6FSt7Tws5UQaA8gFjPmVviP sELV0SYxD7l+oynsqUbXS+gaJ2wd/CdrzmD9RZ2EBVdtW01CFjE4qXgNBMI5CAWI3B4E mZtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235713; x=1719840513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GBRZg7O8NUfGqtDS+Z7CLeIhfmvXkPJ6rvrljuz9exI=; b=l/kvGEW9NMWSpJ9jHbHia7W89zYMq7Y4bst2h2ppsT+i/nxAFO1PAjHBqfMZnCkfdl 9I2ggeOFMeCJrCdZWjA06prpmkvJSFLqSc82c14BcO8s0uEV4fzOed0GnhXFds9SxTRG ox8CP4QEP8cL9UVdWzuMEyXdNiYUMrbx50ZB/xG3O63tV5Gww5bidZdVZ5wYvtRFxW08 ud9pJOLlTdHd77Pdfo5CDufWmlMO2uaoitZfhnm6S06YFBkRS4pHZJAd20sMnl8war13 DD/+yJPsfmZT+uBZ8ZbZSDycCsQXhVCHqpXvFPA2tomzEFfL7PXwDNn3nxzxPmSpTbsI KY8w== X-Forwarded-Encrypted: i=1; AJvYcCWnq0L2TlsP5DisY0JdXZR6Op7iCYkbp1DzWnqWUcoCuYgbeNweDKj3Yo5OdKHGOkmxrYpuztABv0ZfFh5wChqMO/GRyIj427uYxEy+423a1xLbKCk= X-Gm-Message-State: AOJu0Yx6OuSu4t5DYVn6l1bl+IN+rn/CmdOQz+KZIaLfkiYKVhKwtEgp N3Yve7820UyYHDZ2wnZHgNnYTyuiTb9hCvBQAKCKQc/Kc9pMfNX0slVeGCNP X-Google-Smtp-Source: AGHT+IFJL5eRR4dwLd0ix3322JrLNkioz2/OwTWkrVNV55ws/qhEikb0xuP3NZJAldpr5iiFrBu+Lg== X-Received: by 2002:a05:6512:114c:b0:52c:ebd0:609 with SMTP id 2adb3069b0e04-52cebd006bdmr749138e87.7.1719235713165; Mon, 24 Jun 2024 06:28:33 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd63bd28dsm989026e87.92.2024.06.24.06.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:32 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Vinod Koul , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 10/17] net: stmmac: Introduce internal PCS offset-based CSR access Date: Mon, 24 Jun 2024 16:26:27 +0300 Message-ID: <20240624132802.14238-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062836_039272_AAC030CD X-CRM114-Status: GOOD ( 23.17 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Internal PCS module can be found on the DW GMAC v3.x and DW QoS Eth IP-cores. The register space is almost identical except the base address and the SGMII/RGMII/SMII Control and Status Register layout. Thus the common PCS code could be set free from passing the PCS CSRs base address by using the base calcultaed on the MAC-device info init stage. The same approach has been utilized in the STMMAC MMC, PTP and EST modules. Let's convert the PCS module to using it too by adding the PCS CSRs offset declarations and the CSRs base address calculation for the detected IP-core. While at it replace the GMAC_ prefix with PCS_ to mark the common STMMAC PCS macros in the same way as it's done in the mmc.h, stmmac_ptp.h and stmmac_est.h for the respective common modules. Note the phylink_pcs_ops instance has been defined empty for now. It will be populated later upon the rest of the PCS-code movement to the stmmac_pcs.c module. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 8 +- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 11 ++- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 +-- drivers/net/ethernet/stmicro/stmmac/hwif.c | 14 ++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 30 ++++--- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 79 +++++++++---------- 8 files changed, 89 insertions(+), 70 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 80eb72bc6311..d0bcebe87ee8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -633,7 +633,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_2500); - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 0, 0, 0); + stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 0, 0, 0); break; case SPEED_1000: val &= ~ETHQOS_MAC_CTRL_PORT_SEL; @@ -641,12 +641,12 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); + stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); break; case SPEED_100: val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); + stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); break; case SPEED_10: val |= ETHQOS_MAC_CTRL_PORT_SEL; @@ -656,7 +656,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) SGMII_10M_RX_CLK_DVDR), RGMII_IO_MACRO_CONFIG); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); + stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); break; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 3ba65ea3e46f..e525b92955b4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -296,7 +296,7 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); + dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); if (intr_status & PCS_RGSMIIIS_IRQ) { /* TODO Dummy-read to clear the IRQ status */ @@ -365,10 +365,10 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + LPI_TIMER_CTRL); } -static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral, +static void dwmac1000_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback) { - dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); + dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); } static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, @@ -414,8 +414,7 @@ static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - return dwmac_pcs_config(hw, neg_mode, interface, advertising, - GMAC_PCS_BASE); + return dwmac_pcs_config(hw, neg_mode, advertising, advertising); } static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, @@ -442,7 +441,7 @@ static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, state->duplex = status & GMAC_RGSMIIIS_LNKMOD_MASK ? DUPLEX_FULL : DUPLEX_HALF; - dwmac_pcs_get_state(hw, state, GMAC_PCS_BASE); + dwmac_pcs_get_state(hw, state); } static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 5cf2a6cb8f66..e51c95732bad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -750,10 +750,10 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral, +static void dwmac4_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback) { - dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); + dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); } static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, @@ -798,8 +798,7 @@ static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - return dwmac_pcs_config(hw, neg_mode, interface, advertising, - GMAC_PCS_BASE); + return dwmac_pcs_config(hw, advertising, interface, advertising); } static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, @@ -833,7 +832,7 @@ static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, state->duplex = status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK ? DUPLEX_FULL : DUPLEX_HALF; - dwmac_pcs_get_state(hw, state, GMAC_PCS_BASE); + dwmac_pcs_get_state(hw, state); } static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { @@ -924,7 +923,8 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); + dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); + if (intr_status & PCS_RGSMIIIS_IRQ) { /* TODO Dummy-read to clear the IRQ status */ readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 84fd57b76fad..3666893acb69 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -6,6 +6,7 @@ #include "common.h" #include "stmmac.h" +#include "stmmac_pcs.h" #include "stmmac_ptp.h" #include "stmmac_est.h" @@ -116,6 +117,7 @@ static const struct stmmac_hwif_entry { const void *tc; const void *mmc; const void *est; + const void *pcs; int (*setup)(struct stmmac_priv *priv); int (*quirks)(struct stmmac_priv *priv); } stmmac_hw[] = { @@ -144,12 +146,14 @@ static const struct stmmac_hwif_entry { .xgmac = false, .min_id = 0, .regs = { + .pcs_off = PCS_GMAC3_X_OFFSET, .ptp_off = PTP_GMAC3_X_OFFSET, .mmc_off = MMC_GMAC3_X_OFFSET, }, .desc = NULL, .dma = &dwmac1000_dma_ops, .mac = &dwmac1000_ops, + .pcs = &dwmac_pcs_ops, .hwtimestamp = &stmmac_ptp, .mode = NULL, .tc = NULL, @@ -162,6 +166,7 @@ static const struct stmmac_hwif_entry { .xgmac = false, .min_id = 0, .regs = { + .pcs_off = PCS_GMAC4_OFFSET, .ptp_off = PTP_GMAC4_OFFSET, .mmc_off = MMC_GMAC4_OFFSET, .est_off = EST_GMAC4_OFFSET, @@ -169,6 +174,7 @@ static const struct stmmac_hwif_entry { .desc = &dwmac4_desc_ops, .dma = &dwmac4_dma_ops, .mac = &dwmac4_ops, + .pcs = &dwmac_pcs_ops, .hwtimestamp = &stmmac_ptp, .mode = NULL, .tc = &dwmac510_tc_ops, @@ -182,6 +188,7 @@ static const struct stmmac_hwif_entry { .xgmac = false, .min_id = DWMAC_CORE_4_00, .regs = { + .pcs_off = PCS_GMAC4_OFFSET, .ptp_off = PTP_GMAC4_OFFSET, .mmc_off = MMC_GMAC4_OFFSET, .est_off = EST_GMAC4_OFFSET, @@ -189,6 +196,7 @@ static const struct stmmac_hwif_entry { .desc = &dwmac4_desc_ops, .dma = &dwmac4_dma_ops, .mac = &dwmac410_ops, + .pcs = &dwmac_pcs_ops, .hwtimestamp = &stmmac_ptp, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, @@ -202,6 +210,7 @@ static const struct stmmac_hwif_entry { .xgmac = false, .min_id = DWMAC_CORE_4_10, .regs = { + .pcs_off = PCS_GMAC4_OFFSET, .ptp_off = PTP_GMAC4_OFFSET, .mmc_off = MMC_GMAC4_OFFSET, .est_off = EST_GMAC4_OFFSET, @@ -209,6 +218,7 @@ static const struct stmmac_hwif_entry { .desc = &dwmac4_desc_ops, .dma = &dwmac410_dma_ops, .mac = &dwmac410_ops, + .pcs = &dwmac_pcs_ops, .hwtimestamp = &stmmac_ptp, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, @@ -222,6 +232,7 @@ static const struct stmmac_hwif_entry { .xgmac = false, .min_id = DWMAC_CORE_5_10, .regs = { + .pcs_off = PCS_GMAC4_OFFSET, .ptp_off = PTP_GMAC4_OFFSET, .mmc_off = MMC_GMAC4_OFFSET, .est_off = EST_GMAC4_OFFSET, @@ -229,6 +240,7 @@ static const struct stmmac_hwif_entry { .desc = &dwmac4_desc_ops, .dma = &dwmac410_dma_ops, .mac = &dwmac510_ops, + .pcs = &dwmac_pcs_ops, .hwtimestamp = &stmmac_ptp, .mode = &dwmac4_ring_mode_ops, .tc = &dwmac510_tc_ops, @@ -356,6 +368,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv) priv->hw = mac; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off; priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off; + if (entry->pcs) + priv->pcsaddr = priv->ioaddr + entry->regs.pcs_off; if (entry->est) priv->estaddr = priv->ioaddr + entry->regs.est_off; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 8a17e7d6e37d..ba930a87b71a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -376,7 +376,7 @@ struct stmmac_ops { struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues); /* PCS calls */ - void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral, + void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback); /* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp, @@ -670,6 +670,7 @@ struct stmmac_est_ops { stmmac_do_void_callback(__priv, est, irq_status, __args) struct stmmac_regs_off { + u32 pcs_off; u32 ptp_off; u32 mmc_off; u32 est_off; @@ -692,6 +693,7 @@ extern const struct stmmac_desc_ops dwxgmac210_desc_ops; extern const struct stmmac_mmc_ops dwmac_mmc_ops; extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; extern const struct stmmac_est_ops dwmac510_est_ops; +extern const struct phylink_pcs_ops dwmac_pcs_ops; #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b23b920eedb1..8091d162545a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -312,6 +312,7 @@ struct stmmac_priv { struct mutex aux_ts_lock; wait_queue_head_t tstamp_busy_wait; + void __iomem *pcsaddr; void __iomem *mmcaddr; void __iomem *ptpaddr; void __iomem *estaddr; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 849e6f121505..41b99f7e36e6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -3,35 +3,35 @@ int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, phy_interface_t interface, - const unsigned long *advertising, - unsigned int reg_base) + const unsigned long *advertising) { + struct stmmac_priv *priv = hw->priv; u32 val; - val = readl(hw->pcsr + GMAC_AN_CTRL(reg_base)); + val = readl(priv->pcsaddr + PCS_AN_CTRL); - val |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + val |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; if (hw->ps) - val |= GMAC_AN_CTRL_SGMRAL; + val |= PCS_AN_CTRL_SGMRAL; - writel(val, hw->pcsr + GMAC_AN_CTRL(reg_base)); + writel(val, priv->pcsaddr + PCS_AN_CTRL); return 0; } void dwmac_pcs_get_state(struct mac_device_info *hw, - struct phylink_link_state *state, - unsigned int reg_base) + struct phylink_link_state *state) { + struct stmmac_priv *priv = hw->priv; u32 val; - val = readl(hw->pcsr + GMAC_ANE_LPA(reg_base)); + val = readl(priv->pcsaddr + PCS_ANE_LPA); linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->lp_advertising); - if (val & GMAC_ANE_FD) { + if (val & PCS_ANE_FD) { linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, state->lp_advertising); linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, @@ -40,7 +40,7 @@ void dwmac_pcs_get_state(struct mac_device_info *hw, state->lp_advertising); } - if (val & GMAC_ANE_HD) { + if (val & PCS_ANE_HD) { linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, state->lp_advertising); linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, @@ -49,10 +49,14 @@ void dwmac_pcs_get_state(struct mac_device_info *hw, state->lp_advertising); } + /* TODO Make sure that STMMAC_PCS_PAUSE STMMAC_PCS_ASYM_PAUSE usage is legitimate */ linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, state->lp_advertising, - FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_PAUSE); + FIELD_GET(PCS_ANE_PSE, val) & STMMAC_PCS_PAUSE); linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, state->lp_advertising, - FIELD_GET(GMAC_ANE_PSE, val) & STMMAC_PCS_ASYM_PAUSE); + FIELD_GET(PCS_ANE_PSE, val) & STMMAC_PCS_ASYM_PAUSE); } + +const struct phylink_pcs_ops dwmac_pcs_ops = { +}; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 27ea7f4d789d..62be3921ac91 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -13,61 +13,63 @@ #include #include "common.h" +#define PCS_GMAC4_OFFSET 0x000000e0 +#define PCS_GMAC3_X_OFFSET 0x000000c0 + /* PCS registers (AN/TBI/SGMII/RGMII) offsets */ -#define GMAC_AN_CTRL(x) (x) /* AN control */ -#define GMAC_AN_STATUS(x) (x + 0x4) /* AN status */ -#define GMAC_ANE_ADV(x) (x + 0x8) /* ANE Advertisement */ -#define GMAC_ANE_LPA(x) (x + 0xc) /* ANE link partener ability */ -#define GMAC_ANE_EXP(x) (x + 0x10) /* ANE expansion */ -#define GMAC_TBI(x) (x + 0x14) /* TBI extend status */ +#define PCS_AN_CTRL 0x00 /* AN control */ +#define PCS_AN_STATUS 0x04 /* AN status */ +#define PCS_ANE_ADV 0x08 /* ANE Advertisement */ +#define PCS_ANE_LPA 0x0c /* ANE link partener ability */ +#define PCS_ANE_EXP 0x10 /* ANE expansion */ +#define PCS_TBI_EXT 0x14 /* TBI extended status */ /* AN Configuration defines */ -#define GMAC_AN_CTRL_RAN BIT(9) /* Restart Auto-Negotiation */ -#define GMAC_AN_CTRL_ANE BIT(12) /* Auto-Negotiation Enable */ -#define GMAC_AN_CTRL_ELE BIT(14) /* External Loopback Enable */ -#define GMAC_AN_CTRL_ECD BIT(16) /* Enable Comma Detect */ -#define GMAC_AN_CTRL_LR BIT(17) /* Lock to Reference */ -#define GMAC_AN_CTRL_SGMRAL BIT(18) /* SGMII RAL Control */ +#define PCS_AN_CTRL_RAN BIT(9) /* Restart Auto-Negotiation */ +#define PCS_AN_CTRL_ANE BIT(12) /* Auto-Negotiation Enable */ +#define PCS_AN_CTRL_ELE BIT(14) /* External Loopback Enable */ +#define PCS_AN_CTRL_ECD BIT(16) /* Enable Comma Detect */ +#define PCS_AN_CTRL_LR BIT(17) /* Lock to Reference */ +#define PCS_AN_CTRL_SGMRAL BIT(18) /* SGMII RAL Control */ /* AN Status defines */ -#define GMAC_AN_STATUS_LS BIT(2) /* Link Status 0:down 1:up */ -#define GMAC_AN_STATUS_ANA BIT(3) /* Auto-Negotiation Ability */ -#define GMAC_AN_STATUS_ANC BIT(5) /* Auto-Negotiation Complete */ -#define GMAC_AN_STATUS_ES BIT(8) /* Extended Status */ +#define PCS_AN_STATUS_LS BIT(2) /* Link Status 0:down 1:up */ +#define PCS_AN_STATUS_ANA BIT(3) /* Auto-Negotiation Ability */ +#define PCS_AN_STATUS_ANC BIT(5) /* Auto-Negotiation Complete */ +#define PCS_AN_STATUS_ES BIT(8) /* Extended Status Ability */ /* ADV and LPA defines */ -#define GMAC_ANE_FD BIT(5) -#define GMAC_ANE_HD BIT(6) -#define GMAC_ANE_PSE GENMASK(8, 7) -#define GMAC_ANE_PSE_SHIFT 7 -#define GMAC_ANE_RFE GENMASK(13, 12) -#define GMAC_ANE_RFE_SHIFT 12 -#define GMAC_ANE_ACK BIT(14) +#define PCS_ANE_FD BIT(5) /* AN Full-duplex flag */ +#define PCS_ANE_HD BIT(6) /* AN Half-duplex flag */ +#define PCS_ANE_PSE GENMASK(8, 7) /* AN Pause Encoding */ +#define PCS_ANE_PSE_SHIFT 7 +#define PCS_ANE_RFE GENMASK(13, 12) /* AN Remote Fault Encoding */ +#define PCS_ANE_RFE_SHIFT 12 +#define PCS_ANE_ACK BIT(14) /* AN Base-page acknowledge */ /** * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR * @ioaddr: IO registers pointer - * @reg: Base address of the AN Control Register. * @intr_status: GMAC core interrupt status * @x: pointer to log these events as stats * Description: it is the ISR for PCS events: Auto-Negotiation Completed and * Link status. */ -static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, +static inline void dwmac_pcs_isr(void __iomem *pcsaddr, unsigned int intr_status, struct stmmac_extra_stats *x) { - u32 val = readl(ioaddr + GMAC_AN_STATUS(reg)); + u32 val = readl(pcsaddr + PCS_AN_STATUS); if (intr_status & PCS_ANE_IRQ) { x->irq_pcs_ane_n++; - if (val & GMAC_AN_STATUS_ANC) + if (val & PCS_AN_STATUS_ANC) pr_info("stmmac_pcs: ANE process completed\n"); } if (intr_status & PCS_LINK_IRQ) { x->irq_pcs_link_n++; - if (val & GMAC_AN_STATUS_LS) + if (val & PCS_AN_STATUS_LS) pr_info("stmmac_pcs: Link Up\n"); else pr_info("stmmac_pcs: Link Down\n"); @@ -77,7 +79,6 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, /** * dwmac_ctrl_ane - To program the AN Control Register. * @ioaddr: IO registers pointer - * @reg: Base address of the AN Control Register. * @ane: to enable the auto-negotiation * @srgmi_ral: to manage MAC-2-MAC SGMII connections. * @loopback: to cause the PHY to loopback tx data into rx path. @@ -85,36 +86,34 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, * and init the ANE, select loopback (usually for debugging purpose) and * configure SGMII RAL. */ -static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, +static inline void dwmac_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback) { - u32 value = readl(ioaddr + GMAC_AN_CTRL(reg)); + u32 value = readl(pcsaddr + PCS_AN_CTRL); /* Enable and restart the Auto-Negotiation */ if (ane) - value |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + value |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; else - value &= ~GMAC_AN_CTRL_ANE; + value &= ~PCS_AN_CTRL_ANE; /* In case of MAC-2-MAC connection, block is configured to operate * according to MAC conf register. */ if (srgmi_ral) - value |= GMAC_AN_CTRL_SGMRAL; + value |= PCS_AN_CTRL_SGMRAL; if (loopback) - value |= GMAC_AN_CTRL_ELE; + value |= PCS_AN_CTRL_ELE; - writel(value, ioaddr + GMAC_AN_CTRL(reg)); + writel(value, pcsaddr + PCS_AN_CTRL); } int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, phy_interface_t interface, - const unsigned long *advertising, - unsigned int reg_base); + const unsigned long *advertising); void dwmac_pcs_get_state(struct mac_device_info *hw, - struct phylink_link_state *state, - unsigned int reg_base); + struct phylink_link_state *state); #endif /* __STMMAC_PCS_H__ */ From patchwork Mon Jun 24 13:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709518 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 055BCC3064D for ; Mon, 24 Jun 2024 13:29:13 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=L+/PkaXmRsVYIqKGZx4UeA9J6j62ytdn83yxhqwCP6o=; b=XAFlDA+rJ7+viI+mCH5t05Mqf5 6NGaj3X0hDlAJ8pWPKcV1He9gUhqlkS8wMWHdfrYa5yfttD0/iMrJ/LQZojG0ACm1+AF6M+61+F8l 0aS8Bp/XDN92cljT4e9UZhrFp0yDyKJP8YE6SQYCkk0FqzzspUVn+DzW+6JjaEVYSlrCtVlIHnhhz KFRhpn6jj1KYhfdqNQBkcDqxHHUf/30oPlWznMi0r+sqns3626vxnLFflNUGgz/g7hFL12b5WDf2U BqQLmFI8A+9VP8bcw06m4JeL409ZQyFlmDpe7pY425KfNCuKZziaN47C4MGbGSTEWKY0HJ+VVK5dH SNKVmUVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkk-0000000GvC4-0JY9; Mon, 24 Jun 2024 13:29:02 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkO-0000000GuzS-1DTv for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:42 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cd87277d8so2670026e87.2 for ; Mon, 24 Jun 2024 06:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235716; x=1719840516; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L+/PkaXmRsVYIqKGZx4UeA9J6j62ytdn83yxhqwCP6o=; b=ZhOrEeSpeBnRcSSMHGFoPZiot8+FRl3xcAskX4Pkb67SvaGzvG23FNwB2kkOipkXF1 nKGSwu2rLTCz+zH6AUxwLKKP+GVMLFkRww3PCXosKOCDMOKHIWXM7e3Jed1wO/ZgOru1 ktwG9gC2Z3S13t71hmYgpzlvcpNBUu4CwEFtDa9VOXKdsHSMgggHxtrFvYO9hm3MYnFX KeDrqNLtAFMVbSLGlKCf6Iq8TE+fAfikE0PErCmKrDtVBbsahBiapC3PQOc/mcJW7B7y HAdXZkXpGl2j5BAcLib42cZS25kBtFGyO9n67OAat8YcJhiiEXr2bE59tSnwDRuO+AxP VZnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235716; x=1719840516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L+/PkaXmRsVYIqKGZx4UeA9J6j62ytdn83yxhqwCP6o=; b=RaKQRaO1oUblb8DnK7MiScoymTpfbfEu5aZ9SvPLI4QT1nVPl5Pi1RChuTtj+XRmP0 8yBItQGOJJyUZUJw+X1NUaDHrSPUNrc0wgU/veaag7ejoDC54k2vSJIr1eaNtAkALthj Dbzf0kQ/iS8hbfzcLt0HjI8UEjIxv279SGSPoQk2456xnvPDrX6DSbmyrGfQvCaqNf1f eJrPiT8BfXQQyuyhB+MOK/3bKrAFSAfovKK/2Zx1d9+vEa41SpJEmjU01NMscKuZsmtH Iqa9Mav71w9+a0Kai7AsAdPMDaCKMlVvTgaxCwJ6bcs8CHSwwv4ZGnvPG4lO77BOFvZd 3fHA== X-Forwarded-Encrypted: i=1; AJvYcCVvOU9TDWHFgZjYZWdRQEGvlp1We33uNieHsWKB/A8pYo0NYhvG/oEVzyMQHSVYMicvXoKSJHiK7LURk3PQT0FqRg6jUksG/ew5a2Q9KyhmdObWNoY= X-Gm-Message-State: AOJu0YxXdSzJg8JSHnBm6HHs7mtY+N9uKdHrHqrug7K3JpT2/9B7NiPN HA4r9TDaZiY7TbkDIQ74zsvY0n1kj9QSSuT4bfk9M/L+AwGmIhfP X-Google-Smtp-Source: AGHT+IH809R8vF6zTQILCWIugVLXjGsYzjDJo9A/xeg6IqGYA6QXLn9MgMKJTyre4EaY/xpUaBI5NA== X-Received: by 2002:a05:6512:1154:b0:52c:9d38:9df1 with SMTP id 2adb3069b0e04-52ce183263dmr3351699e87.10.1719235715596; Mon, 24 Jun 2024 06:28:35 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd63b4bc2sm982966e87.27.2024.06.24.06.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:35 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 11/17] net: stmmac: Introduce internal PCS config register getter Date: Mon, 24 Jun 2024 16:26:28 +0300 Message-ID: <20240624132802.14238-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062840_623049_EF03F48B X-CRM114-Status: GOOD ( 16.66 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The optional PCS module CSRs are mainly represented in the framework of the address spaces [0x00c0:0x00db] on DW GMAC and [0x00e0:0x00f7] on DW QoS Eth. The spaces mapping is identical in both IP-cores. But the link state retrieved from the PHY or from another MAC (in MAC2MAC setup) is mapped over the SGMII/RGMII/SMII Control and Status register in a non-compatible way. In particular the DW GMAC register have the link state mapped at the [15:0] field, and the DW QoS Eth register have it mapped at the [31:16] field. Other than that the fields semantics is identical - it's the TX_CONFIG_REG[15:0] register (see SGMII specification for details) with a bit re-ordered fields and extended with some SMII-specific flags: tx_config_reg[0]: LNKMOD tx_config_reg[1:2]: LNKSPEED tx_config_reg[3]: LNKSTS tx_config_reg[4]: JABTO (Jabber Timeout, SMII-specific) tx_config_reg[5]: FALSCARDET (False Carrier Detected, SMII-specific) In order to provide a fully generic internal STMMAC PCS module, let's introduce the MAC-specific callback returning the link state detected by the internal PCS. Note the callback name has been chosen to be referring to the TX_CONFIG_REG data described in the IP-core databooks and in the SGMII specification. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 1 + .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 11 +++++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 13 +++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +++ 5 files changed, 29 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index 4296ddda8aaa..f3a95d27298c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -86,6 +86,7 @@ enum power_event { #define GMAC_RGSMIIIS 0x000000d8 /* RGMII/SMII status */ /* SGMII/RGMII status register */ +#define GMAC_RGSMIIIS_CONFIG_REG GENMASK(15, 0) #define GMAC_RGSMIIIS_LNKMODE BIT(0) #define GMAC_RGSMIIIS_SPEED GENMASK(2, 1) #define GMAC_RGSMIIIS_SPEED_SHIFT 1 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index e525b92955b4..1e50cc573407 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -365,6 +365,16 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + LPI_TIMER_CTRL); } +static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 val; + + val = readl(ioaddr + GMAC_RGSMIIIS); + + return FIELD_GET(GMAC_RGSMIIIS_CONFIG_REG, val); +} + static void dwmac1000_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback) { @@ -568,6 +578,7 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, + .pcs_get_config_reg = dwmac1000_pcs_get_config_reg, .pcs_ctrl_ane = dwmac1000_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index d3c5306f1c41..bb2997191f08 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -567,6 +567,7 @@ static inline u32 mtl_low_credx_base_addr(const struct dwmac4_addrs *addrs, #define GMAC_PHYIF_CTRLSTATUS_TC BIT(0) #define GMAC_PHYIF_CTRLSTATUS_LUD BIT(1) #define GMAC_PHYIF_CTRLSTATUS_SMIDRXS BIT(4) +#define GMAC_PHYIF_CTRLSTATUS_CONFIG_REG GENMASK(31, 16) #define GMAC_PHYIF_CTRLSTATUS_LNKMOD BIT(16) #define GMAC_PHYIF_CTRLSTATUS_SPEED GENMASK(18, 17) #define GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT 17 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index e51c95732bad..b7db076b4214 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -456,6 +456,16 @@ static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + GMAC4_LPI_TIMER_CTRL); } +static u16 dwmac4_pcs_get_config_reg(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 val; + + val = readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); + + return FIELD_GET(GMAC_PHYIF_CTRLSTATUS_CONFIG_REG, val); +} + static void dwmac4_write_single_vlan(struct net_device *dev, u16 vid) { void __iomem *ioaddr = (void __iomem *)dev->base_addr; @@ -1274,6 +1284,7 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, .update_vlan_hash = dwmac4_update_vlan_hash, @@ -1318,6 +1329,7 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1366,6 +1378,7 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, .safety_feat_irq_status = dwmac5_safety_feat_irq_status, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index ba930a87b71a..00995a0c9813 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -376,6 +376,7 @@ struct stmmac_ops { struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues); /* PCS calls */ + u16 (*pcs_get_config_reg)(struct mac_device_info *hw); void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback); /* Safety Features */ @@ -492,6 +493,8 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_eee_pls, __args) #define stmmac_mac_debug(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, debug, __priv, __args) +#define stmmac_pcs_get_config_reg(__priv, __args...) \ + stmmac_do_callback(__priv, mac, pcs_get_config_reg, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) #define stmmac_safety_feat_config(__priv, __args...) \ From patchwork Mon Jun 24 13:26:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709519 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 40A36C2D0D1 for ; Mon, 24 Jun 2024 13:29:18 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=I2AcJmtOWxMHdiZJR5LHSRSHyE wr8PGEtUa8R3Sy42rFf33XZSF2h5vst9TtOCIvz+DxxyOv2bEwAMcGzkt8Y9XH41NmojE4HNJFY9E vMz4vn5E+zUrbifqVkz6wn1/jQDTTExC6FPtSoRSV2oW0QNcA8RTk1PCjkOekVjIa5udO/R9YiOjh HPn6xNYwKjMdFPCvR4gzGZsUBh2npDdlcyVtT/D+1X+6dfQZR8+4BC2XKl+5iAakSstgIK5VdJLYW gSn2gaFiN+Y3qjvaqipJ8DmiNVQ/Hw27erVlQJ27WzGu2VzFOKTwYx/xsgEo/016AkyQGtF9wOG/E 1JNm73YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkn-0000000GvDi-0gNM; Mon, 24 Jun 2024 13:29:05 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkO-0000000Guzu-1ChS for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:41 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so2711252e87.2 for ; Mon, 24 Jun 2024 06:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235718; x=1719840518; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=fkFDTU4EzIegg8tbo8An8YBuY6haPYZTW9W5zmvUm5XVnZnRuCsEy38drtUNG/LFBq gcrEbcaK7+pqG68JGItb+z+D8+Hhiu5s7K++TYtEVKLH3yaeXyV3vQxgQUG3AwWW8/hx Ga9HTv2SWdQk5pI+GpMA3+RyObUTOSfgmtWMEH9MhDOF+5KUDCXN2X3FmOX9akXja4qA klFGTah959QkzgrBMPebKxrokIdSFG+mjDfWrdsG2F1d4f5a5D3XDkIZl5wgjYXzr068 O1QQrkLFNs+/C8yhWLIvRYAc0yX+QcFq7H2F1BT8YvSVdaMy1VivqxM/xbfls4avU1Gp QJiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235718; x=1719840518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=QenIUk8qAO4DKxcsfZ53yFGwZx3V+4SUn6lRTcRXiaEqDeVk8Z8wVnWGsWB/CW96dM mzQ6yaWSKQsgut6XYM67p9DIjF90HUuhPx2tbfAFkkQEoa6iEkeM/1w99GDmMSj96kJl PZEwC22gdw4OMn06dftw+SAlIroj86uHjwfY4pfjbwga3EmMuqe6ls2SNUrZN/PO8tfL cQ69HtW38WgnbiSPbPqsOjXhu3ldBr7v9wrD1q0D9tJZ33y27LjKIbK6fOM1l+pngCGQ DH0WB9fxpP/E721qZtZp8MxtD6RtFlV2M82jY8HVlyyJJ6HP66aR1AJAMsY9HKvOsPpr yxYg== X-Forwarded-Encrypted: i=1; AJvYcCUi19lXqJtnM4/7fBKldOWzC/XoscQ84VTS1voH7lsXKlN0iUgy5IQQY1AUw4dmJGEBmcUIouszXC+xZOP72lmZiDGRDzegrRwbRzM6Go8wcz3rxo0= X-Gm-Message-State: AOJu0YzTGi6GgLs0FPYiu8NOhNouJD9fkQFiCPdvygdeNMlZvqIPOnnv WtHlflH5U9evvona1A5VooMk/U4zdUixFZR4JhZtwAl/0908RCsw X-Google-Smtp-Source: AGHT+IFCP0Abnl0ON1YlKTZpmLSz+wWOfdf3+G3qM0oG3CK0Ou7QI39akcE1gEBgfNlx61R5C1552w== X-Received: by 2002:a05:6512:3d10:b0:52c:e326:f4cf with SMTP id 2adb3069b0e04-52ce326f5e4mr3905981e87.3.1719235717804; Mon, 24 Jun 2024 06:28:37 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cebd0985fsm48965e87.258.2024.06.24.06.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:37 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 12/17] net: stmmac: Introduce internal PCS IRQ enable/disable methods Date: Mon, 24 Jun 2024 16:26:29 +0300 Message-ID: <20240624132802.14238-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062840_368881_E625A2E3 X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PCS IRQ enable/disable procedures have been utilized in the framework of the PHYLINK PCS enable/disable callbacks. Since a generic STMMAC PHYLINK PCS implementation is about to be introduced let's move the procedures into the dedicated DW GMAC and DW QoS Eth HW-abstraction methods. These methods will be called from the PCS enable/disable functions defined in the stmmac_pcs.c in the DW MAC-independent manner. Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 34 ++++++++++++----- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 38 ++++++++++++++----- drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 +++ 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 1e50cc573407..99f0bbb318ec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -365,6 +365,26 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + LPI_TIMER_CTRL); } +static void dwmac1000_pcs_enable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask &= ~GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + +static void dwmac1000_pcs_disable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask |= GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) { void __iomem *ioaddr = hw->pcsr; @@ -395,12 +415,8 @@ static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_mask; - intr_mask = readl(ioaddr + GMAC_INT_MASK); - intr_mask &= ~GMAC_INT_DISABLE_PCS; - writel(intr_mask, ioaddr + GMAC_INT_MASK); + dwmac1000_pcs_enable_irq(hw); return 0; } @@ -408,12 +424,8 @@ static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) static void dwmac1000_mii_pcs_disable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_mask; - intr_mask = readl(ioaddr + GMAC_INT_MASK); - intr_mask |= GMAC_INT_DISABLE_PCS; - writel(intr_mask, ioaddr + GMAC_INT_MASK); + dwmac1000_pcs_disable_irq(hw); } static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, @@ -578,6 +590,8 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, + .pcs_enable_irq = dwmac1000_pcs_enable_irq, + .pcs_disable_irq = dwmac1000_pcs_disable_irq, .pcs_get_config_reg = dwmac1000_pcs_get_config_reg, .pcs_ctrl_ane = dwmac1000_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index b7db076b4214..5dc8d59d3a8f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -456,6 +456,26 @@ static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + GMAC4_LPI_TIMER_CTRL); } +static void dwmac4_pcs_enable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable |= GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); +} + +static void dwmac4_pcs_disable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable &= ~GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); +} + static u16 dwmac4_pcs_get_config_reg(struct mac_device_info *hw) { void __iomem *ioaddr = hw->pcsr; @@ -780,12 +800,8 @@ static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_enable; - intr_enable = readl(ioaddr + GMAC_INT_EN); - intr_enable |= GMAC_PCS_IRQ_DEFAULT; - writel(intr_enable, ioaddr + GMAC_INT_EN); + dwmac4_pcs_enable_irq(hw); return 0; } @@ -793,12 +809,8 @@ static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) static void dwmac4_mii_pcs_disable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_enable; - intr_enable = readl(ioaddr + GMAC_INT_EN); - intr_enable &= ~GMAC_PCS_IRQ_DEFAULT; - writel(intr_enable, ioaddr + GMAC_INT_EN); + dwmac4_pcs_disable_irq(hw); } static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, @@ -1284,6 +1296,8 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1329,6 +1343,8 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, @@ -1378,6 +1394,8 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 00995a0c9813..2caa946a92f9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -376,6 +376,8 @@ struct stmmac_ops { struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues); /* PCS calls */ + void (*pcs_enable_irq)(struct mac_device_info *hw); + void (*pcs_disable_irq)(struct mac_device_info *hw); u16 (*pcs_get_config_reg)(struct mac_device_info *hw); void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback); @@ -493,6 +495,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_eee_pls, __args) #define stmmac_mac_debug(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, debug, __priv, __args) +#define stmmac_pcs_enable_irq(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, pcs_enable_irq, __args) +#define stmmac_pcs_disable_irq(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, pcs_disable_irq, __args) #define stmmac_pcs_get_config_reg(__priv, __args...) \ stmmac_do_callback(__priv, mac, pcs_get_config_reg, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ From patchwork Mon Jun 24 13:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709520 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 D93B4C2BD09 for ; Mon, 24 Jun 2024 13:29:18 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=MynZwWlLLlg8SzNhGpRYgN3pGB xqArPFnxAWbdNQKyCOH9ULpGZnGh72qhVJn5YE61E0UMLToCBVwOef+K1MCtMJd3uUgL7dluRBMVQ gL+0ZB5Nt48pta0eq1jjN0vBAlNJU6/ESCaSaSGNXaeQzYe6RlzNIydJcqktqByx8d7RmSNDpj3Ly C47F66BYLvDHE2cZasWPOR/e0WSkNjn6zK0HBb6gfIeKd/jcJrSmnERf/vhskJJQO+Q2HD7ZpLxQx Fk0jSdmoxfVO7sMm4VgdZ3CU1INqfSC94UnpFFZ3FoeXKqYTXOr04KWvRwHhB4LKrS9SQPZBWBdQa 2A5S8a0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkq-0000000GvFP-0MVP; Mon, 24 Jun 2024 13:29:08 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkQ-0000000Gv1E-1hsL for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:43 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52ce0140416so1847066e87.0 for ; Mon, 24 Jun 2024 06:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235720; x=1719840520; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=X/VgYCdqAazrtSD3BhENQgjDX1yEwy9hoIn9dPTObS0pXftrzCI8reqy/dU5Ngbcgl 6eq2ImMxZs5pydWUHh17YuUB9s84sJ/1ZYC3pjlsSPHyMJ6uMdRznam00y4xJQ+btw0K FVaXjIUOzRIXZuC18r7y1oZ6NQCC/0+w4muaiPbb8qU5tcxc39AlMGwmqby8Lx6VCQQM NhJojVnLEmPV8GmVVJPoXv5rboORO3ObshdjfmZYARudFM5pB3fc2WU6Hg6Be92s+/m8 y4d5kHBtNYLoFYwQzGzIWI1QzeCd8hWgD3aAcnRlp1ao+Ovj7td5Vm6lrhB+WS5vWiBn +kJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235720; x=1719840520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YtZp0AbrnXQs3O13v2d6+EuVN6MSe7p8ad/hbNOPJWI=; b=okQFJhNFjaZDbcVyka2DsbEqCyH9X4e5PvE4xefCI9ZOdfSr3Mbw9I51uwrg98n8gh yhnScUttwl5aiVAweQRKpC5gaQhgD84j00+x+zsFgL/m6raK+uHAvscRClsYbC/T8kW/ u6H1M5g3NLF4POnUIXFeh7KNep8nbwOQtOUbwF5kpGc76UemgOpFvKAWclJ/yH59MRpB 9qmRf7Gpd1Hbwbi4Wc9M2csDN51kGiJt627JHRP5qUKPltZzZ2Gd1y1YGilUa3jVu0TI Heou+oZv1wLvfUuL1W0i/r3w5BcnCtYir1l6afDbw7yC/wBW4StIoMXgrSHhbqs5f7uG zn1Q== X-Forwarded-Encrypted: i=1; AJvYcCW6k4u88iQ9X28DE278JpqP/euESzri2VhKZt1Xq11icxuCMKgwrZurhCFK2w61XMXdQ5sjkFj9sZQ5SaO0PY5Rzka8UN/BIgMy3xxH1a3b6NNzGEc= X-Gm-Message-State: AOJu0YwS+av3az5PruZdASQb4snT6Oadqbu7GHCnmIOnFs/oxeBX3Ps6 PTv1uqjsQxRO8aVT0ea6Dq4p1OL6ECki7UAxW8L5DWXo+GiLZZwD X-Google-Smtp-Source: AGHT+IGnD5pCpdtBAgEV0LPviNccHChm0nS52nkrjh8YxukL2E9OFJq+KfJaFse+52g2ituyaoatpQ== X-Received: by 2002:a19:4310:0:b0:52c:b479:902d with SMTP id 2adb3069b0e04-52ce06105efmr3684613e87.4.1719235720181; Mon, 24 Jun 2024 06:28:40 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd643342dsm982999e87.231.2024.06.24.06.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:39 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Vinod Koul , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 13/17] net: stmmac: Move internal PCS ANE-control method to dwmac-qcom-ethqos.c Date: Mon, 24 Jun 2024 16:26:30 +0300 Message-ID: <20240624132802.14238-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062842_494116_C4882697 X-CRM114-Status: GOOD ( 19.59 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The dwmac_ctrl_ane() method is not going to be utilized in the internal PCS implementation. Simplify the DW *MAC HW-abstraction interface by moving the method definition to the only user of it - dwmac-qcom-ethqos.c. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 ++++++++++++++--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 7 ---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 ----- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 --- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 33 ------------------- 5 files changed, 27 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index d0bcebe87ee8..fcd13a9afd59 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -615,6 +615,29 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed) } } +static inline void ethqos_ctrl_ane(void __iomem *pcsaddr, bool ane, + bool srgmi_ral, bool loopback) +{ + u32 value = readl(pcsaddr + PCS_AN_CTRL); + + /* Enable and restart the Auto-Negotiation */ + if (ane) + value |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; + else + value &= ~PCS_AN_CTRL_ANE; + + /* In case of MAC-2-MAC connection, block is configured to operate + * according to MAC conf register. + */ + if (srgmi_ral) + value |= PCS_AN_CTRL_SGMRAL; + + if (loopback) + value |= PCS_AN_CTRL_ELE; + + writel(value, pcsaddr + PCS_AN_CTRL); +} + /* On interface toggle MAC registers gets reset. * Configure MAC block for SGMII on ethernet phy link up */ @@ -633,7 +656,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_2500); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 0, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 0, 0, 0); break; case SPEED_1000: val &= ~ETHQOS_MAC_CTRL_PORT_SEL; @@ -641,12 +664,12 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; case SPEED_100: val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; case SPEED_10: val |= ETHQOS_MAC_CTRL_PORT_SEL; @@ -656,7 +679,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) SGMII_10M_RX_CLK_DVDR), RGMII_IO_MACRO_CONFIG); ethqos_set_serdes_speed(ethqos, SPEED_1000); - stmmac_pcs_ctrl_ane(priv, priv->pcsaddr, 1, 0, 0); + ethqos_ctrl_ane(priv->pcsaddr, 1, 0, 0); break; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 99f0bbb318ec..9511ea753da7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -395,12 +395,6 @@ static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) return FIELD_GET(GMAC_RGSMIIIS_CONFIG_REG, val); } -static void dwmac1000_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); -} - static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, const struct phylink_link_state *state) @@ -593,7 +587,6 @@ const struct stmmac_ops dwmac1000_ops = { .pcs_enable_irq = dwmac1000_pcs_enable_irq, .pcs_disable_irq = dwmac1000_pcs_disable_irq, .pcs_get_config_reg = dwmac1000_pcs_get_config_reg, - .pcs_ctrl_ane = dwmac1000_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 5dc8d59d3a8f..1e73c14f36ce 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -780,12 +780,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(pcsaddr, ane, srgmi_ral, loopback); -} - static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, const struct phylink_link_state *state) @@ -1294,7 +1288,6 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, @@ -1341,7 +1334,6 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, @@ -1392,7 +1384,6 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, .pcs_enable_irq = dwmac4_pcs_enable_irq, .pcs_disable_irq = dwmac4_pcs_disable_irq, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 2caa946a92f9..3d39417e906d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -379,8 +379,6 @@ struct stmmac_ops { void (*pcs_enable_irq)(struct mac_device_info *hw); void (*pcs_disable_irq)(struct mac_device_info *hw); u16 (*pcs_get_config_reg)(struct mac_device_info *hw); - void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, - bool loopback); /* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp, struct stmmac_safety_feature_cfg *safety_cfg); @@ -501,8 +499,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, pcs_disable_irq, __args) #define stmmac_pcs_get_config_reg(__priv, __args...) \ stmmac_do_callback(__priv, mac, pcs_get_config_reg, __args) -#define stmmac_pcs_ctrl_ane(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) #define stmmac_safety_feat_config(__priv, __args...) \ stmmac_do_callback(__priv, mac, safety_feat_config, __args) #define stmmac_safety_feat_irq_status(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 62be3921ac91..76badfd208b6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -76,39 +76,6 @@ static inline void dwmac_pcs_isr(void __iomem *pcsaddr, } } -/** - * dwmac_ctrl_ane - To program the AN Control Register. - * @ioaddr: IO registers pointer - * @ane: to enable the auto-negotiation - * @srgmi_ral: to manage MAC-2-MAC SGMII connections. - * @loopback: to cause the PHY to loopback tx data into rx path. - * Description: this is the main function to configure the AN control register - * and init the ANE, select loopback (usually for debugging purpose) and - * configure SGMII RAL. - */ -static inline void dwmac_ctrl_ane(void __iomem *pcsaddr, bool ane, - bool srgmi_ral, bool loopback) -{ - u32 value = readl(pcsaddr + PCS_AN_CTRL); - - /* Enable and restart the Auto-Negotiation */ - if (ane) - value |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; - else - value &= ~PCS_AN_CTRL_ANE; - - /* In case of MAC-2-MAC connection, block is configured to operate - * according to MAC conf register. - */ - if (srgmi_ral) - value |= PCS_AN_CTRL_SGMRAL; - - if (loopback) - value |= PCS_AN_CTRL_ELE; - - writel(value, pcsaddr + PCS_AN_CTRL); -} - int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising); From patchwork Mon Jun 24 13:26:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709521 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 2BB73C3064D for ; Mon, 24 Jun 2024 13:29:27 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZJoJKZg8DGaUrEn+jqEV7Z916g2ud2UaUPgX3w+6oi0=; b=gSreuMo7sHrXFIC0zT/FVT0Feo io9Xtp4huisI1eBK1PdCQZhZfdFNjTtLwdxFFXy4/GPZyeAFmsF4ZdItT/kcbQrTHk5PZfyutLLO7 oLBsm3+r6yHj7gBB8h/6uow4OSNJeZe/J/p2zeRI02mAvVvZoSHrmZYu6efp9b7amX422GDkhgdzp lY0Sw5yL5R257qgjJUGJA/Yqt8sGU6SFrhdszJth1nMkO6GeoBccZ418rFUaqXtv4oETATBlhsXm0 5j+X+BGwzLWq1R52VfdHK99ayo7rlNl5pSXPORAVueJ0lZAEr3LjWU8yu+2hXQWtQBa4BSQcc1kQD SN3GB02g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkx-0000000GvKi-1QM6; Mon, 24 Jun 2024 13:29:15 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkS-0000000Gv2n-3CBw for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:47 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ec59193468so12837341fa.1 for ; Mon, 24 Jun 2024 06:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235723; x=1719840523; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZJoJKZg8DGaUrEn+jqEV7Z916g2ud2UaUPgX3w+6oi0=; b=e6xKJM20M2+DcrZRkGrRfNgYhlUpNgGWw/aCtv0TPoYqqvHRTwctdlBRPgo7X8PHKA da1DMvUuY4o9ld+63MzMvcjialegMdO6+k7GiJ/8Q5QI2qWb/UUPDfKBn9aTiCh7gfxX VdTQZ3WhCpzWGibCi02lMn6I84C3UF/KBUpXphEBPMC/zvZgFilhUzQNkrvcHBAdRmkg llSCfYANeuy3DRvMjoUOxHECKfkJQOm2Bvb7GKQnK2rs34vqi4m8c2az5iXtx8fFdtuc 4LebFp5TmxEYwvrPFF5eKyBryOy91qp/AVQWO/tdCkwscFTGISTVlyM1Uufuj/r3VTQU v1ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235723; x=1719840523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZJoJKZg8DGaUrEn+jqEV7Z916g2ud2UaUPgX3w+6oi0=; b=sSGLvN3nfpKoV9TNIIyG3Acm3uJQa3uly7Fdl5D1ZQp/yIsu866ILQ4VEJ/kp1395Q u3udsGgrn3de6Wy6zA6bvPkbnZqDKDuw/clT10L+e5h8zZwtMGRFhmKqkjFbW9FOq8sO yoadDrZtPFjG1RYvhEv6yG2Kv1B02lYqwR8kjka5efo4jBY7ApHcKsX7Fh2itEcJYoMg FKHJ7wVNZCBcacT6zVeTqyj7qHNuMbXRtgmRHXwWrM3EzBdq/Mj+SswBnz00ZM42LzIu AAiYtg5+4559jTBQ1dP/KDTAx8zy9rbnXcl4/B4CKCnbFZZkDnygxH60ajfa/dCZHG4K /0zA== X-Forwarded-Encrypted: i=1; AJvYcCVWX1uNaYgygevF6PYTQw2q7b3REfiEQDZqHW2odnHdzWIzeG+Qni6fKV8fRhOol32j08645i/pBQaIAQ6cphqAtHcA7+A6RB4uQcOQBx+K/0q0tUs= X-Gm-Message-State: AOJu0YywszPtQlBh0Z2RMbmeLljO2K/DwdDySRT2D0bOO7v+vBSDOq6n GS76le96IKIYde2MLjcnVR2wu53wMPm0m3fBt5X5pLRHuc2Dmm7a X-Google-Smtp-Source: AGHT+IFkIfRbp+aHOp0QJLguwUS6UijGlNN4urIEqL5oFVzo2oSq28oQIZx1BDU3sm9HOV8ePIuJXA== X-Received: by 2002:a05:651c:10e:b0:2ec:4f0f:d93d with SMTP id 38308e7fff4ca-2ec56a6a72cmr15464891fa.5.1719235722742; Mon, 24 Jun 2024 06:28:42 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d600c1bsm9632101fa.8.2024.06.24.06.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:42 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 14/17] net: stmmac: Move internal PCS PHYLINK ops to stmmac_pcs.c Date: Mon, 24 Jun 2024 16:26:31 +0300 Message-ID: <20240624132802.14238-6-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062844_864446_AEAA44D4 X-CRM114-Status: GOOD ( 21.05 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PCS-related code is now ready to be consolidated in the PCS-specific module. Let's move the PHYLINK PCS operations implementation to the stmmac_pcs.c file. No semantics has changed. The same functionality has been re-implemented in stammac_pcs.c by using the generic link status register macros and the phylink_pcs_ops instance has been populated with the new callbacks. Signed-off-by: Serge Semin --- Note the code has been equipped with some TODO-notes to think about on the RFC review stage. --- .../net/ethernet/stmicro/stmmac/dwmac1000.h | 12 --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 74 ---------------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 12 --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 80 ----------------- drivers/net/ethernet/stmicro/stmmac/hwif.c | 1 + .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 86 +++++++++++++++++-- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 17 ++-- 7 files changed, 91 insertions(+), 191 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index f3a95d27298c..94be66e794be 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -87,19 +87,7 @@ enum power_event { /* SGMII/RGMII status register */ #define GMAC_RGSMIIIS_CONFIG_REG GENMASK(15, 0) -#define GMAC_RGSMIIIS_LNKMODE BIT(0) -#define GMAC_RGSMIIIS_SPEED GENMASK(2, 1) -#define GMAC_RGSMIIIS_SPEED_SHIFT 1 -#define GMAC_RGSMIIIS_LNKSTS BIT(3) -#define GMAC_RGSMIIIS_JABTO BIT(4) -#define GMAC_RGSMIIIS_FALSECARDET BIT(5) #define GMAC_RGSMIIIS_SMIDRXS BIT(16) -/* LNKMOD */ -#define GMAC_RGSMIIIS_LNKMOD_MASK 0x1 -/* LNKSPEED */ -#define GMAC_RGSMIIIS_SPEED_125 0x2 -#define GMAC_RGSMIIIS_SPEED_25 0x1 -#define GMAC_RGSMIIIS_SPEED_2_5 0x0 /* GMAC Configuration defines */ #define GMAC_CONTROL_2K 0x08000000 /* IEEE 802.3as 2K packets */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 9511ea753da7..332018ecd624 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -395,79 +395,6 @@ static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) return FIELD_GET(GMAC_RGSMIIIS_CONFIG_REG, val); } -static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, - unsigned long *supported, - const struct phylink_link_state *state) -{ - /* Only support in-band */ - if (!test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising)) - return -EINVAL; - - return 0; -} - -static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - dwmac1000_pcs_enable_irq(hw); - - return 0; -} - -static void dwmac1000_mii_pcs_disable(struct phylink_pcs *pcs) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - dwmac1000_pcs_disable_irq(hw); -} - -static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, - unsigned int neg_mode, - phy_interface_t interface, - const unsigned long *advertising, - bool permit_pause_to_mac) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - return dwmac_pcs_config(hw, neg_mode, advertising, advertising); -} - -static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, - struct phylink_link_state *state) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - unsigned int spd_clk; - u32 status; - - status = readl(hw->pcsr + GMAC_RGSMIIIS); - - state->link = status & GMAC_RGSMIIIS_LNKSTS; - if (!state->link) - return; - - spd_clk = FIELD_GET(GMAC_RGSMIIIS_SPEED, status); - if (spd_clk == GMAC_RGSMIIIS_SPEED_125) - state->speed = SPEED_1000; - else if (spd_clk == GMAC_RGSMIIIS_SPEED_25) - state->speed = SPEED_100; - else if (spd_clk == GMAC_RGSMIIIS_SPEED_2_5) - state->speed = SPEED_10; - - state->duplex = status & GMAC_RGSMIIIS_LNKMOD_MASK ? - DUPLEX_FULL : DUPLEX_HALF; - - dwmac_pcs_get_state(hw, state); -} - -static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { - .pcs_validate = dwmac1000_mii_pcs_validate, - .pcs_enable = dwmac1000_mii_pcs_enable, - .pcs_disable = dwmac1000_mii_pcs_disable, - .pcs_config = dwmac1000_mii_pcs_config, - .pcs_get_state = dwmac1000_mii_pcs_get_state, -}; - static struct phylink_pcs * dwmac1000_phylink_select_pcs(struct stmmac_priv *priv, phy_interface_t interface) @@ -621,7 +548,6 @@ int dwmac1000_setup(struct stmmac_priv *priv) mac->mii.clk_csr_shift = 2; mac->mii.clk_csr_mask = GENMASK(5, 2); - mac->mac_pcs.ops = &dwmac1000_mii_pcs_ops; mac->mac_pcs.neg_mode = true; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index bb2997191f08..5c765e16bc13 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -568,18 +568,6 @@ static inline u32 mtl_low_credx_base_addr(const struct dwmac4_addrs *addrs, #define GMAC_PHYIF_CTRLSTATUS_LUD BIT(1) #define GMAC_PHYIF_CTRLSTATUS_SMIDRXS BIT(4) #define GMAC_PHYIF_CTRLSTATUS_CONFIG_REG GENMASK(31, 16) -#define GMAC_PHYIF_CTRLSTATUS_LNKMOD BIT(16) -#define GMAC_PHYIF_CTRLSTATUS_SPEED GENMASK(18, 17) -#define GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT 17 -#define GMAC_PHYIF_CTRLSTATUS_LNKSTS BIT(19) -#define GMAC_PHYIF_CTRLSTATUS_JABTO BIT(20) -#define GMAC_PHYIF_CTRLSTATUS_FALSECARDET BIT(21) -/* LNKMOD */ -#define GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK 0x1 -/* LNKSPEED */ -#define GMAC_PHYIF_CTRLSTATUS_SPEED_125 0x2 -#define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1 -#define GMAC_PHYIF_CTRLSTATUS_SPEED_2_5 0x0 extern const struct stmmac_dma_ops dwmac4_dma_ops; extern const struct stmmac_dma_ops dwmac410_dma_ops; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 1e73c14f36ce..1487f5cc5249 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -780,85 +780,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, - unsigned long *supported, - const struct phylink_link_state *state) -{ - /* Only support in-band */ - if (!test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising)) - return -EINVAL; - - return 0; -} - -static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - dwmac4_pcs_enable_irq(hw); - - return 0; -} - -static void dwmac4_mii_pcs_disable(struct phylink_pcs *pcs) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - dwmac4_pcs_disable_irq(hw); -} - -static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, - phy_interface_t interface, - const unsigned long *advertising, - bool permit_pause_to_mac) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - - return dwmac_pcs_config(hw, advertising, interface, advertising); -} - -static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, - struct phylink_link_state *state) -{ - struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - unsigned int clk_spd; - u32 status; - - status = readl(hw->pcsr + GMAC_PHYIF_CONTROL_STATUS); - - state->link = !!(status & GMAC_PHYIF_CTRLSTATUS_LNKSTS); - if (!state->link) - return; - - clk_spd = FIELD_GET(GMAC_PHYIF_CTRLSTATUS_SPEED, status); - if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_125) - state->speed = SPEED_1000; - else if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_25) - state->speed = SPEED_100; - else if (clk_spd == GMAC_PHYIF_CTRLSTATUS_SPEED_2_5) - state->speed = SPEED_10; - - /* FIXME: Is this even correct? - * GMAC_PHYIF_CTRLSTATUS_TC = BIT(0) - * GMAC_PHYIF_CTRLSTATUS_LNKMOD = BIT(16) - * GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK = 1 - * - * The result is, we test bit 0 for the duplex setting. - */ - state->duplex = status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK ? - DUPLEX_FULL : DUPLEX_HALF; - - dwmac_pcs_get_state(hw, state); -} - -static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { - .pcs_validate = dwmac4_mii_pcs_validate, - .pcs_enable = dwmac4_mii_pcs_enable, - .pcs_disable = dwmac4_mii_pcs_disable, - .pcs_config = dwmac4_mii_pcs_config, - .pcs_get_state = dwmac4_mii_pcs_get_state, -}; - static struct phylink_pcs * dwmac4_phylink_select_pcs(struct stmmac_priv *priv, phy_interface_t interface) { @@ -1475,7 +1396,6 @@ int dwmac4_setup(struct stmmac_priv *priv) mac->mii.clk_csr_mask = GENMASK(11, 8); mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr); - mac->mac_pcs.ops = &dwmac4_mii_pcs_ops; mac->mac_pcs.neg_mode = true; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 3666893acb69..c42fb2437948 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -363,6 +363,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv) mac->tc = mac->tc ? : entry->tc; mac->mmc = mac->mmc ? : entry->mmc; mac->est = mac->est ? : entry->est; + mac->mac_pcs.ops = mac->mac_pcs.ops ?: entry->pcs; mac->priv = priv; priv->hw = mac; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 41b99f7e36e6..24b95d1fdb64 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -1,17 +1,54 @@ +#include + #include "common.h" #include "stmmac_pcs.h" -int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, - phy_interface_t interface, - const unsigned long *advertising) +static int dwmac_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, + const struct phylink_link_state *state) +{ + /* Only support in-band */ + if (!test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising)) + return -EINVAL; + + return 0; +} + +static int dwmac_pcs_enable(struct phylink_pcs *pcs) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + + stmmac_pcs_enable_irq(hw->priv, hw); + + return 0; +} + +static void dwmac_pcs_disable(struct phylink_pcs *pcs) { + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); + + stmmac_pcs_disable_irq(hw->priv, hw); +} + +static int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) +{ + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); struct stmmac_priv *priv = hw->priv; u32 val; + /* TODO Think about this: + * + En/dis SGMII/RGMII IRQs based on the neg_mode value? + * + Do we need to set PCS_CONTROL.TC?.. For SGMII MAC2MAC? + * + The next is SGMII/RTBI/TBI-specific + */ + val = readl(priv->pcsaddr + PCS_AN_CTRL); val |= PCS_AN_CTRL_ANE | PCS_AN_CTRL_RAN; + /* + The SGMRAL flag is SGMII-specific */ if (hw->ps) val |= PCS_AN_CTRL_SGMRAL; @@ -20,12 +57,40 @@ int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, return 0; } -void dwmac_pcs_get_state(struct mac_device_info *hw, - struct phylink_link_state *state) +static void dwmac_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) { + struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); struct stmmac_priv *priv = hw->priv; u32 val; + val = stmmac_pcs_get_config_reg(priv, hw); + + /* TODO The next is SGMII/RGMII/SMII-specific */ + state->link = !!(val & PCS_CFG_LNKSTS); + if (!state->link) + return; + + switch (FIELD_GET(PCS_CFG_LNKSPEED, val)) { + case PCS_CFG_LNKSPEED_2_5: + state->speed = SPEED_10; + break; + case PCS_CFG_LNKSPEED_25: + state->speed = SPEED_100; + break; + case PCS_CFG_LNKSPEED_250: + state->speed = SPEED_1000; + break; + default: + netdev_err(priv->dev, "Unknown speed detected\n"); + break; + } + + state->duplex = val & PCS_CFG_LNKMOD ? DUPLEX_FULL : DUPLEX_HALF; + + /* TODO Check the PCS_AN_STATUS.Link status here?.. Note the flag is latched-low */ + + /* TODO The next is the TBI/RTBI-specific and seems to be valid if PCS_AN_STATUS.ANC */ val = readl(priv->pcsaddr + PCS_ANE_LPA); linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, @@ -49,7 +114,10 @@ void dwmac_pcs_get_state(struct mac_device_info *hw, state->lp_advertising); } - /* TODO Make sure that STMMAC_PCS_PAUSE STMMAC_PCS_ASYM_PAUSE usage is legitimate */ + /* TODO The databook says the encoding is defined in IEEE 802.3z, + * Section 37.2.1.4. Do we need the STMMAC_PCS_PAUSE and + * STMMAC_PCS_ASYM_PAUSE mask here? + */ linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, state->lp_advertising, FIELD_GET(PCS_ANE_PSE, val) & STMMAC_PCS_PAUSE); @@ -59,4 +127,10 @@ void dwmac_pcs_get_state(struct mac_device_info *hw, } const struct phylink_pcs_ops dwmac_pcs_ops = { + .pcs_validate = dwmac_pcs_validate, + .pcs_enable = dwmac_pcs_enable, + .pcs_disable = dwmac_pcs_disable, + .pcs_config = dwmac_pcs_config, + .pcs_get_state = dwmac_pcs_get_state, + }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 76badfd208b6..2baebb92bea7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -47,6 +47,16 @@ #define PCS_ANE_RFE_SHIFT 12 #define PCS_ANE_ACK BIT(14) /* AN Base-page acknowledge */ +/* SGMII/RGMII/SMII link status register */ +#define PCS_CFG_LNKMOD BIT(0) /* Link Duplex Mode */ +#define PCS_CFG_LNKSPEED GENMASK(2, 1) /* Link Speed: */ +#define PCS_CFG_LNKSPEED_2_5 0x0 /* 2.5 MHz - 10 Mbps */ +#define PCS_CFG_LNKSPEED_25 0x1 /* 25 MHz - 100 Mbps */ +#define PCS_CFG_LNKSPEED_250 0x2 /* 250 MHz - 1000 Mbps */ +#define PCS_CFG_LNKSTS BIT(3) /* Link Up/Down Status */ +#define PCS_CFG_JABTO BIT(4) /* Jabber Timeout (SMII only) */ +#define PCS_CFG_FALSCARDET BIT(5) /* False Carrier (SMII only) */ + /** * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR * @ioaddr: IO registers pointer @@ -76,11 +86,4 @@ static inline void dwmac_pcs_isr(void __iomem *pcsaddr, } } -int dwmac_pcs_config(struct mac_device_info *hw, unsigned int neg_mode, - phy_interface_t interface, - const unsigned long *advertising); - -void dwmac_pcs_get_state(struct mac_device_info *hw, - struct phylink_link_state *state); - #endif /* __STMMAC_PCS_H__ */ From patchwork Mon Jun 24 13:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709522 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 CF0D5C2D0D1 for ; Mon, 24 Jun 2024 13:29:35 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=Xd++MhLEIqxqx+UFhCSF73AGGz MmEm+bP8td9ETj2zIbQLli6cq6gJnSHKwn98w2O6+KZDPlk8DF0/vILsNC70fHZPlkWfWp0lxtJbP 0J6X9RslMF7BweWxuAXlffEUBFUgvOsDYli6K55kbPXyVGhA2laooG6I2RXRvjHDcaG4O2OapOz9J U98qKoYKUbdMg7f43nal854+3d0gzlxUPNLDadBvp3XFgggoac8gAKcLtHEGdC34rmtRs7AOfGNAO zwl9iG5/onMsvbQMM5z9tsc/Q0KCOl/9pWCCNTWyGGH89SAh16JSbC/I1GeP6OMlWCQlCDkQN50Sj GCp2pflA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjl2-0000000GvOL-2GXM; Mon, 24 Jun 2024 13:29:20 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkV-0000000Gv4j-0W62 for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:48 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ec5779b423so19931921fa.0 for ; Mon, 24 Jun 2024 06:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235725; x=1719840525; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=H75DMK4g/Flp/Rjmmof8QiMicOxG/YZ1C9fNZezHdlR0YNf2vbX62qInW91SUHU22B CNtKG1jRuBE+i1ERx3hhSdYF7bkTjytouyeFFJK0OarysQgRqREnqcTD7IFaLsSSFoxs 4usLwiT1j+52mI0oDAx05bmnvCnQKBycoFgiSSX3VulxtiHb8PhZHrd7tV9FkHb4Hvcj ZGm9wQtmRI3oc0+pZRF7OGtmzqcjQV6wCB/gMG+WbyT+6/pzx/i7ZUHqd6+z6kh11JHG Z5Qq6V37wVuoJDUAaUmfccZyGj7W+gD6raGZ6/DnZm4YOfeCsqz8BrHez7D9hFj/BAO9 v/gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235725; x=1719840525; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=vuLZynyKgMBseDuxYa3/EX3GLqOE/buP5iyAPKEyIziuSb2+X8Og3nndxn90H/j9mA 6xC9JS+i4OhfwcEiiTIYl1GHsWol5uJJQV2ugcEDrSKlDAtv0gNwCGUtZa0WtyfgX3eh LkJpANzjAnJVdoL5/puiVhOTAyHQURBj1d73l9HALICib1yYt6J5mjZ7O4tRI2uXgwIT nhbFuj7QNmSW2F6yDJwWQVUqAAIdjlmEIn1wFAC6yjdBZLzUjYpbwGI3YyFpDdF5o6eI m6u/GMosf9O3Vi9sVrIGkLgS4NOY+qU0v7RoHwEqE6VGT3pr5CgdpCQ0cZNuI1s7rqt4 oOmQ== X-Forwarded-Encrypted: i=1; AJvYcCVpfJ1fhdsiqdYb4Ov9bGqQ4NSIUSqNxd0szlXuDmFEXesOm0bXcP8Wx0gnAMN0CJJdbJHZpKg496PaYipuyJ1A2JiwCzCwggf6bJVsddTATSAd2RA= X-Gm-Message-State: AOJu0Ywewqu0cKXprZaf30r+r93mPpH0zPkOUP/wgg8oVcFsw/51IABf WqmAs271xkFSRqx9NMj+kRrV5fghns1AgmleFORdf71/kKK5DQuU X-Google-Smtp-Source: AGHT+IH0GO4PBGc5Gd3PGuDIANu9HTgigG+8VkYo1wUOWDrul73npApHt9lg7dmWYbZTxCAcThzWtg== X-Received: by 2002:a2e:6a02:0:b0:2e1:2169:a5cc with SMTP id 38308e7fff4ca-2ec5931d8c3mr36751081fa.15.1719235724924; Mon, 24 Jun 2024 06:28:44 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d602703sm9729211fa.4.2024.06.24.06.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:44 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 15/17] net: stmmac: Move internal PCS ISR to stmmac_pcs.c Date: Mon, 24 Jun 2024 16:26:32 +0300 Message-ID: <20240624132802.14238-7-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062847_310612_91751C69 X-CRM114-Status: GOOD ( 17.44 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similarly to the PHYLINK PCS ops, the STMMAC PCS ISR can be now fully implemented in the stmmac_pcs.c file. As before this change the resultant method will be called from the DW GMAC and DW QoS Eth core interrupt handlers. Signed-off-by: Serge Semin --- Note the AN Complete and Link state changes now cause the PHYLINK PCS state update. --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 9 +---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 +---- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 33 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 31 ++--------------- 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 332018ecd624..2d77ffd16f0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -296,14 +296,7 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); - - if (intr_status & PCS_RGSMIIIS_IRQ) { - /* TODO Dummy-read to clear the IRQ status */ - readl(ioaddr + GMAC_RGSMIIIS); - phylink_pcs_change(&hw->mac_pcs, false); - x->irq_rgmii_n++; - } + dwmac_pcs_isr(hw, intr_status, x); return ret; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 1487f5cc5249..c58dc20eddeb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -860,14 +860,7 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); - - if (intr_status & PCS_RGSMIIIS_IRQ) { - /* TODO Dummy-read to clear the IRQ status */ - readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); - phylink_pcs_change(&hw->mac_pcs, false); - x->irq_rgmii_n++; - } + dwmac_pcs_isr(hw, intr_status, x); return ret; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 24b95d1fdb64..aac49f6472f0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -134,3 +134,36 @@ const struct phylink_pcs_ops dwmac_pcs_ops = { .pcs_get_state = dwmac_pcs_get_state, }; + +void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, + struct stmmac_extra_stats *x) +{ + struct stmmac_priv *priv = hw->priv; + bool an_status = false, sr_status = false; + + if (intr_status & PCS_ANE_IRQ) { + x->irq_pcs_ane_n++; + an_status = true; + } + + if (intr_status & PCS_LINK_IRQ) { + x->irq_pcs_link_n++; + an_status = true; + } + + if (intr_status & PCS_RGSMIIIS_IRQ) { + x->irq_rgmii_n++; + sr_status = true; + } + + /* Read the AN and SGMII/RGMII/SMII status regs to clear IRQ */ + if (an_status) + readl(priv->pcsaddr + PCS_AN_STATUS); + + if (sr_status) + readl(priv->pcsaddr + PCS_SRGMII_CSR); + + /* Any PCS event shall trigger the PHYLINK PCS state update */ + if (an_status || sr_status) + phylink_pcs_change(&hw->mac_pcs, false); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 2baebb92bea7..6e364285a4ef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -23,6 +23,7 @@ #define PCS_ANE_LPA 0x0c /* ANE link partener ability */ #define PCS_ANE_EXP 0x10 /* ANE expansion */ #define PCS_TBI_EXT 0x14 /* TBI extended status */ +#define PCS_SRGMII_CSR 0x18 /* SGMII/RGMII/SMII CSR */ /* AN Configuration defines */ #define PCS_AN_CTRL_RAN BIT(9) /* Restart Auto-Negotiation */ @@ -57,33 +58,7 @@ #define PCS_CFG_JABTO BIT(4) /* Jabber Timeout (SMII only) */ #define PCS_CFG_FALSCARDET BIT(5) /* False Carrier (SMII only) */ -/** - * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR - * @ioaddr: IO registers pointer - * @intr_status: GMAC core interrupt status - * @x: pointer to log these events as stats - * Description: it is the ISR for PCS events: Auto-Negotiation Completed and - * Link status. - */ -static inline void dwmac_pcs_isr(void __iomem *pcsaddr, - unsigned int intr_status, - struct stmmac_extra_stats *x) -{ - u32 val = readl(pcsaddr + PCS_AN_STATUS); - - if (intr_status & PCS_ANE_IRQ) { - x->irq_pcs_ane_n++; - if (val & PCS_AN_STATUS_ANC) - pr_info("stmmac_pcs: ANE process completed\n"); - } - - if (intr_status & PCS_LINK_IRQ) { - x->irq_pcs_link_n++; - if (val & PCS_AN_STATUS_LS) - pr_info("stmmac_pcs: Link Up\n"); - else - pr_info("stmmac_pcs: Link Down\n"); - } -} +void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, + struct stmmac_extra_stats *x); #endif /* __STMMAC_PCS_H__ */ From patchwork Mon Jun 24 13:26:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709523 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 3B9F6C2BD09 for ; Mon, 24 Jun 2024 13:29:39 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1U9L4Yq0u2xGF5ZPArCNKUT73HjSRjPESwAp7waM0I4=; b=iHGcUh87S74rEpooGx2caT8wWO cgpeWv0EQPo3k9LU33kXE7BeElCaud8l9DPjU9OyvBV4gH8vB1bAj973xadNMSM3SOT22NOd5xmaN k1DwXtJjubBJNx3oBoPpLTRILLWNc1lo+poBuOqwZh8qgP+Wx5LsZzL9NeIgtRg7uaE16sZTskBsp X9SzwRVpbgPev3GnC5JkHckngDniYernxkwSzDy86YPlQsAYJAGO27ojTHDORJaRtzSiG60hxm4V7 XI8HRQd6bTkGW7MVpzfOm8exdni9tCchRIOmwFoSYbXF1JE1MkPuPUhxU0wWl587cDr8VPNul1Q69 FweX3bxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjl9-0000000GvTW-0LbI; Mon, 24 Jun 2024 13:29:27 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkX-0000000Gv6B-1cWR for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:50 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ec1620a956so51895091fa.1 for ; Mon, 24 Jun 2024 06:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235728; x=1719840528; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1U9L4Yq0u2xGF5ZPArCNKUT73HjSRjPESwAp7waM0I4=; b=B8GUMNTUuY9GCuuQ0aWeAyvC3JBJpBFlcEy+H5DC4PoRGUHzDFWTYoEztJ0iILBwnv ANw9ERfGjSF5KIn+hcJg6TVDDBgJq9QmKcMQ3mL1gjA73XuZyjTLueMACfrNkaoKrG92 eXU/8HADJuMinCZS0BSO3eX5mbLn0Un0fmT0Hw2ljQMtu9Sn0C+8aYfHscwmAj5zL5v0 1924SQBq1vQ8UVGo9nQw6ZRkdE5gMPZ0W4ihOTe3Kkdn04WyAjiLua1uuvOU0WyiAvKn Thyw8t/zkdYIGCOgdUKmsGDOU8NpETOUjBsiO/BN+YxIj1uh9UlnALGcVFpscPeD5Ey5 SHaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235728; x=1719840528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1U9L4Yq0u2xGF5ZPArCNKUT73HjSRjPESwAp7waM0I4=; b=MSlvN+eF13bbrlEUUvJ2bRaBoyi87qeBspki9dll8lqao2K6t+EqYi3s6mOjX5Zskh wO9D7ZuKJgFWh/9+kDEHZIZF+GVUfAu+/kd0skDAAyzEZqsMNGerQSO87YT1WJ0cjvTU wqhKDSppipF/RsCoEU0g6tGQnAU5t4viw4QeWbX77i4cQgow6vRktqkCCl1W9MH0SwnQ nciIkgkEs1AuHfZBvt+d8qt08dnJBjqdKgk/oYjJar0cYVM+CFBDn298edqrvjc4YCfS II2Qpykzu3EqaVLk678BxQhFh1VUK4sd0lqZ8nnD6Ub36aKpre7CTlxtVQx3MZYuY5sy 9L7w== X-Forwarded-Encrypted: i=1; AJvYcCW2KM+LdevYlAO0ducYM6M4nKL2a8sluvUKlZOma6TyWaSRXzEwbiVUHGi3cFtfDLE9gZq42CtoKoJuksqXEL97ImopSQIiESfDogdRE9pwhhcfITU= X-Gm-Message-State: AOJu0Yym+gEAIQcAnJlV7zOpnWGWUXA4feYq5rQoozPS0KU5ml7A3HHs DdrXRcNIkcMlK5VX49ZuZ+sm40wiYBOah23J7+ZJQxDXdZEJ+1CD X-Google-Smtp-Source: AGHT+IHaRb4z8zCJyi0+00brLpXIArmVXMkb2V0LJo/l5CAtSvnDvFz1BfQxWmUL7peMQYPsZ68IVA== X-Received: by 2002:a2e:3518:0:b0:2ec:3e02:972a with SMTP id 38308e7fff4ca-2ec5b3180d8mr24914191fa.11.1719235727509; Mon, 24 Jun 2024 06:28:47 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec6563c8a2sm1055351fa.9.2024.06.24.06.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:47 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 16/17] net: stmmac: Move internal PCS init method to stmmac_pcs.c Date: Mon, 24 Jun 2024 16:26:33 +0300 Message-ID: <20240624132802.14238-8-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062849_587126_8196A9D0 X-CRM114-Status: GOOD ( 27.38 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the internal PCS initialization procedure is split up into several functions and special flags: 1. stmmac_check_pcs_mode() - determine the internal PCS based on the specified interface and init the mac_device_info::pcs field with the respective flag (STMMAC_PCS_RGMII or STMMAC_PCS_SGMII); 2. stmmac_ops::phylink_select_pcs() - callback specific for the DW GMAC and DW QoS Eth IP-cores which returns the pointer to the phylink_pcs structure if any of the STMMAC_PCS_RGMII or STMMAC_PCS_SGMII flag is found in the mac_device_info::pcs field. The initialization procedure described above can be simplified by converting the stmmac_check_pcs_mode() to the PCS-init method defined in stmmac_pcs.c, which besides would take the STMMAC_FLAG_HAS_INTEGRATED_PCS flag into account. Seeing the RGMII and SGMII MAC-interfaces can be only found on the DW GMAC and DW QoS Eth, the stmmac_ops::phylink_select_pcs() callbacks content can be freely moved right into the generic phylink_mac_ops::mac_select_pcs() function. Signed-off-by: Serge Semin --- The change looks very promising and greatly simplifying the internal PCS initialization procedure by providing a single coherent method activating the internal PCS capability based on the requested interface and the detected DW MAC HW-capability. --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 16 +------------ .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 17 +------------ drivers/net/ethernet/stmicro/stmmac/hwif.h | 15 ++---------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 24 ++++--------------- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 3 +++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 15 ++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 2 ++ 7 files changed, 28 insertions(+), 64 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 2d77ffd16f0a..2fbb853cc19c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -16,7 +16,7 @@ #include #include #include -#include + #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac1000.h" @@ -388,17 +388,6 @@ static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) return FIELD_GET(GMAC_RGSMIIIS_CONFIG_REG, val); } -static struct phylink_pcs * -dwmac1000_phylink_select_pcs(struct stmmac_priv *priv, - phy_interface_t interface) -{ - if (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII) - return &priv->hw->mac_pcs; - - return NULL; -} - static void dwmac1000_debug(struct stmmac_priv *priv, void __iomem *ioaddr, struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues) @@ -489,7 +478,6 @@ static void dwmac1000_set_mac_loopback(void __iomem *ioaddr, bool enable) const struct stmmac_ops dwmac1000_ops = { .core_init = dwmac1000_core_init, - .phylink_select_pcs = dwmac1000_phylink_select_pcs, .set_mac = stmmac_set_mac, .rx_ipc = dwmac1000_rx_ipc_enable, .dump_regs = dwmac1000_dump_regs, @@ -541,7 +529,5 @@ int dwmac1000_setup(struct stmmac_priv *priv) mac->mii.clk_csr_shift = 2; mac->mii.clk_csr_mask = GENMASK(5, 2); - mac->mac_pcs.neg_mode = true; - return 0; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index c58dc20eddeb..f5449f0962ad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -14,7 +14,7 @@ #include #include #include -#include + #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac4.h" @@ -780,16 +780,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static struct phylink_pcs * -dwmac4_phylink_select_pcs(struct stmmac_priv *priv, phy_interface_t interface) -{ - if (priv->hw->pcs & STMMAC_PCS_RGMII || - priv->hw->pcs & STMMAC_PCS_SGMII) - return &priv->hw->mac_pcs; - - return NULL; -} - static int dwmac4_irq_mtl_status(struct stmmac_priv *priv, struct mac_device_info *hw, u32 chan) { @@ -1178,7 +1168,6 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw) const struct stmmac_ops dwmac4_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, - .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1224,7 +1213,6 @@ const struct stmmac_ops dwmac4_ops = { const struct stmmac_ops dwmac410_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, - .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_dwmac4_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1274,7 +1262,6 @@ const struct stmmac_ops dwmac410_ops = { const struct stmmac_ops dwmac510_ops = { .core_init = dwmac4_core_init, .update_caps = dwmac4_update_caps, - .phylink_select_pcs = dwmac4_phylink_select_pcs, .set_mac = stmmac_dwmac4_set_mac, .rx_ipc = dwmac4_rx_ipc_enable, .rx_queue_enable = dwmac4_rx_queue_enable, @@ -1389,7 +1376,5 @@ int dwmac4_setup(struct stmmac_priv *priv) mac->mii.clk_csr_mask = GENMASK(11, 8); mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr); - mac->mac_pcs.neg_mode = true; - return 0; } diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 3d39417e906d..4bacfe8a18e0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -18,17 +18,13 @@ } \ __result; \ }) -#define stmmac_do_typed_callback(__type, __fail_ret, __priv, __module, \ - __cname, __arg0, __args...) \ +#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ ({ \ - __type __result = __fail_ret; \ + int __result = -EINVAL; \ if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \ __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ __result; \ }) -#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ - stmmac_do_typed_callback(int, -EINVAL, __priv, __module, __cname, \ - __arg0, ##__args) struct stmmac_extra_stats; struct stmmac_priv; @@ -315,9 +311,6 @@ struct stmmac_ops { void (*core_init)(struct mac_device_info *hw, struct net_device *dev); /* Update MAC capabilities */ void (*update_caps)(struct stmmac_priv *priv); - /* Get phylink PCS (for MAC */ - struct phylink_pcs *(*phylink_select_pcs)(struct stmmac_priv *priv, - phy_interface_t interface); /* Enable the MAC RX/TX */ void (*set_mac)(void __iomem *ioaddr, bool enable); /* Enable and verify that the IPC module is supported */ @@ -439,10 +432,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, core_init, __args) #define stmmac_mac_update_caps(__priv) \ stmmac_do_void_callback(__priv, mac, update_caps, __priv) -#define stmmac_mac_phylink_select_pcs(__priv, __interface) \ - stmmac_do_typed_callback(struct phylink_pcs *, ERR_PTR(-EOPNOTSUPP), \ - __priv, mac, phylink_select_pcs, __priv,\ - __interface) #define stmmac_mac_set(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_mac, __args) #define stmmac_rx_ipc(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 72c2d3e2c121..743d356f6d12 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -950,13 +950,16 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, { struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + if (priv->hw->pcs) + return &priv->hw->mac_pcs; + if (priv->hw->xpcs) return &priv->hw->xpcs->pcs; if (priv->hw->phylink_pcs) return priv->hw->phylink_pcs; - return stmmac_mac_phylink_select_pcs(priv, interface); + return NULL; } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, @@ -1121,23 +1124,6 @@ static const struct phylink_mac_ops stmmac_phylink_mac_ops = { .mac_link_up = stmmac_mac_link_up, }; -/** - * stmmac_check_pcs_mode - verify if RGMII/SGMII is supported - * @priv: driver private structure - * Description: this is to verify if the HW supports the PCS. - * Physical Coding Sublayer (PCS) interface that can be used when the MAC is - * configured for the TBI, RTBI, or SGMII PHY interface. - */ -static void stmmac_check_pcs_mode(struct stmmac_priv *priv) -{ - int interface = priv->plat->mac_interface; - - if (phy_interface_mode_is_rgmii(interface)) - priv->hw->pcs = STMMAC_PCS_RGMII; - else if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) - priv->hw->pcs = STMMAC_PCS_SGMII; -} - /** * stmmac_init_phy - PHY initialization * @dev: net device structure @@ -7704,8 +7690,6 @@ int stmmac_dvr_probe(struct device *device, else stmmac_clk_csr_set(priv); - stmmac_check_pcs_mode(priv); - pm_runtime_get_noresume(device); pm_runtime_set_active(device); if (!pm_runtime_enabled(device)) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa43117134d3..985b4b8c021f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -22,6 +22,7 @@ #include "dwxgmac2.h" #include "stmmac.h" +#include "stmmac_pcs.h" #define MII_BUSY 0x00000001 #define MII_WRITE 0x00000002 @@ -505,6 +506,8 @@ int stmmac_pcs_setup(struct net_device *ndev) priv = netdev_priv(ndev); mode = priv->plat->phy_interface; + dwmac_pcs_init(priv->hw); + if (priv->plat->pcs_init) { ret = priv->plat->pcs_init(priv); } else if (priv->plat->mdio_bus_data && diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index aac49f6472f0..fdfc95299f89 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -167,3 +167,18 @@ void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, if (an_status || sr_status) phylink_pcs_change(&hw->mac_pcs, false); } + +void dwmac_pcs_init(struct mac_device_info *hw) +{ + struct stmmac_priv *priv = hw->priv; + int interface = priv->plat->mac_interface; + + if (priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) + return; + else if (phy_interface_mode_is_rgmii(interface)) + hw->pcs = STMMAC_PCS_RGMII; + else if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) + hw->pcs = STMMAC_PCS_SGMII; + + hw->mac_pcs.neg_mode = true; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 6e364285a4ef..a17e5b37c411 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -61,4 +61,6 @@ void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, struct stmmac_extra_stats *x); +void dwmac_pcs_init(struct mac_device_info *hw); + #endif /* __STMMAC_PCS_H__ */ From patchwork Mon Jun 24 13:26:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709524 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 C446FC2BD09 for ; Mon, 24 Jun 2024 13:29:45 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WtEe7sDqfN9JW3LcLHq6hNyDw8ZBCvPF/f0tUgUw0Ek=; b=3e2jBUYvbmS70YfyBirIPrpkyE aFej6cbs9kAdb+grjmw7wAo1sSVFWoYe0RVVYQmlLFnBug6t/RaxzVtQeRFM4ldlcCXW7Bv856/VX JKBY8g/KDtNi5DdtEbC9JLxKG2fkxvafBljjkTq5uRO8CStQfbCR+1HcFdn2WWfGWV6i0DACYE8l/ jB4PaK2AbarVtP59VaYQYuuWIvfl9LAN0gUk5BRgGXB9+4LxIYg6C2ly6txRZgOeqQZAQXkWcjIyu r689eRsED+ij4OV5Ki7Czof3cHFfpaOAHGpRfSmIqwajiyHrCzISH5ZVyb3yaRFlJwqgVLWrvBncS NK42g9sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjlF-0000000GvYU-3TJE; Mon, 24 Jun 2024 13:29:34 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkZ-0000000Gv6v-3kNo for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:53 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so50421541fa.3 for ; Mon, 24 Jun 2024 06:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235729; x=1719840529; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WtEe7sDqfN9JW3LcLHq6hNyDw8ZBCvPF/f0tUgUw0Ek=; b=MXHeXFOdrhM7TZ3hRJAsF/GEr6cr4H44eW+Jf7t0xwzkQumRMjdNSPGI/ZOffsfxNl 4ngfEgQhq4uaxiSjKoUHbbDIY9KSkbNGG76tCYJthk5voArD9LYzIPV3k5hW6Yylfopj C4CCuwVevMGfBr5/4W3nKbD5f6Z6FioJ58xUYQ5WW/OZCXWDoY11ZF/p8/F6MsFb0Wob d3eWwwDBJMNyvhC31Hh34+5+vmCfcxjJRtPVc8NkYdugsmAUpDgotWjifSZLdNX+iiUS SNKqoy/WHRs4U2ALIyGDtA/E3o5Y0tODsiOfx78C2NhAuNpH089sIxrZU9Rj31/6ChSz beCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235729; x=1719840529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WtEe7sDqfN9JW3LcLHq6hNyDw8ZBCvPF/f0tUgUw0Ek=; b=ZVBJpYgl4mghOqz7xeq7Nbkfq4jWHHQ4BjFpGIyu9oYdgBBS2TTELiM6B+mLMwayr4 cH7hpjDkUuooYItd+T1v2+MGtWYfkFDkj0Z5jrqFec3T8OI/Ajhl12vtjzdQEgW2Fh3s xiI8pSpJNtOPLvkBeT+eCCbopickUHVV3qlLPmhsQ8OEG7B8+qFzqW20nYxk35IR5IjG /gR2yNLjns1scPsQx3H6kQ2hYrBUhUq0Ca3d5pXUutj1Kj7FAnROdQWAFu5jmsJBUpul hn3E+4KcNZ+lWwkNvrgn48+ADcY5JZw6+JMl1VAi5qZzHzbOnWCtw+58ztocOtD9/Xfp EKSQ== X-Forwarded-Encrypted: i=1; AJvYcCVbX58v9WVXXc7XW6DNGF5EsqhhBEK13m5E6uzCi76mQqdxd650rkRL7HWF1xiPKz+hOiZDjkcIclYKtDHBfC6uG5Y2pzIWddLbvH9UdOsqiQ0jplc= X-Gm-Message-State: AOJu0YzjpwH4h8BEpxesASn72ZKNF83jkcEwZx9TSW3PsyvgWykrRC6F uNOQal+E2WReL2QLwltly6ZqtinpksagejmvgZQ6PEWvQGalxSFW X-Google-Smtp-Source: AGHT+IFPP14441T+3czwKEItmbrOsbND2YdLL8uZN7bzYoWhRPQpBDSL2HCd8X2teLzstMx3I7E0FQ== X-Received: by 2002:a05:651c:1988:b0:2ec:637a:c212 with SMTP id 38308e7fff4ca-2ec637ac2b5mr15471271fa.39.1719235729169; Mon, 24 Jun 2024 06:28:49 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d602519sm9997201fa.6.2024.06.24.06.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:48 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 17/17] net: stmmac: pcs: Drop the _SHIFT macros Date: Mon, 24 Jun 2024 16:26:34 +0300 Message-ID: <20240624132802.14238-9-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062852_087399_11BB3099 X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PCS_ANE_PSE_SHIFT and PCS_ANE_RFE_SHIFT are unused anyway. Moreover PCS_ANE_PSE and PCS_ANE_RFE are the respective field masks. So the FIELD_GET()/FIELD_SET() macro-functions can be used to get/set the fields content. Drop the _SHIFT macros for good then. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index a17e5b37c411..0f15c9898788 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -43,9 +43,7 @@ #define PCS_ANE_FD BIT(5) /* AN Full-duplex flag */ #define PCS_ANE_HD BIT(6) /* AN Half-duplex flag */ #define PCS_ANE_PSE GENMASK(8, 7) /* AN Pause Encoding */ -#define PCS_ANE_PSE_SHIFT 7 #define PCS_ANE_RFE GENMASK(13, 12) /* AN Remote Fault Encoding */ -#define PCS_ANE_RFE_SHIFT 12 #define PCS_ANE_ACK BIT(14) /* AN Base-page acknowledge */ /* SGMII/RGMII/SMII link status register */