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: 13681534 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13FA315099E for ; Fri, 31 May 2024 11:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154787; cv=none; b=poJFmen1gOeWj0E0//Ft5s1FBbkTYS7/s1bpYxSOMeHCrjg9UHfmmv3yQHYB9n69vy5JLmIy95sE5RxA6ufCiT/pBnVvNW27933Yz2YZz610E98ztOLvuIlJIoTTXTHLODFAu1LfsVTaTXPbFXHNg/g8h2Z0UsKfR0bVnBJ3SMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154787; c=relaxed/simple; bh=C0A5OQyluwnMYYlitivCEeBs4mWj5PBKfb3lv3BhyQY=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=M/8eywyzkRKjZarxnXlrSt3qt0vKQV+u3GWek+qXZNTtLvK6uh21XRErvHs5SUU3RENjILVGBNZFaZY5AN2k/yBBMnwLh1kYdKfoPi42Qx8yu9Mi4WsVrwYhA0JQEeAVahuDCsiMFRvG21LsasFBNdwK+gP+0r568YyNADTeXW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=Haw/SstV; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Haw/SstV" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:15 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681528 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 283A855894; Fri, 31 May 2024 11:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154796; cv=none; b=G+CJpauY6fnNZeSTkpdE736e5lGJMUuh2hSpD2eFV4Xvwt18bvSUSPvUmc/DErbNTtvmlteSNDLFwGyUfyjdPgap/+iizQFAHAsOTAQhipf70WblaG5ivPPiQCReeOBu1uRLjrTNpsXNL54YnSSlGQ2FmQ1eYr+m0u6AGcUj7nA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154796; c=relaxed/simple; bh=z3Aby6ZKEWo2K9dTSR/iu2+D892ulX4324Qd+67ZMM8=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=SvhIJiHNDrvvRQloeEZAIgPWZnur5MwCHhatZj2a4IUsDtyyEgaDXUdQM8BQAruxnybUZBcDe4mp+gVx82P2js/j65nTUMySiL31wb94nPbU4iuZ6NOOwrPJWwW1s8elHn6FgxYNTaNJyg7ehhAm9saTz2ji1G3xYvT/iTSoI18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=FcF+3s6u; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="FcF+3s6u" 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 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:20 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681535 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB6C055894 for ; Fri, 31 May 2024 11:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154800; cv=none; b=ijMlIutsMFQjJE3pj+aNaX3dx3p71rpIzq2Xu8taGpImHuDB+yP9HY9r5ri6sWjEXojAoRJmS3bBrJIa7o2ud72VSZ4gFTa4K58mw6fSaWkJhudOxLsD/Zv725qfXHz8koa0YLNZ+eIAijM6jROJ+h5vALnetuX1BGA/84iHKsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154800; c=relaxed/simple; bh=uN4nEp/qSdBLmc4QgZK340QgOlX918yIdAyDiy/rAhc=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=O3z6Vki7H9W9e0qJSEa/qpWj2pUXAIwNggKHagvCOzoW6ttBJglM0diro4lCSTf+w+vm+1j+hVY0FNBm0h26yNJTglIyS+UkeNz62K00xGay7ZrdS+hOeikOyleKfGfcmdBaLSMilUc94CJKtSf9bLW7ksKM/TC3OdgzXnVKaeo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=l6AvPnST; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="l6AvPnST" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:25 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681536 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DE10156F5B for ; Fri, 31 May 2024 11:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154805; cv=none; b=ObNQmYK/AntrNthEagN/WLKvTNCeh0DlJbDPlDns1AJ3JzsPl1E4bXr19UEys//xXTcx51E24UOsq3keqs3bfr0dzoKcr94UxTiVAWqp0Na9XrcaFoZpoCYkPXx+f9EXJJWpfAEbL3E4A1IIeaKbYicW4CbtomHpETR3FQld0G4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154805; c=relaxed/simple; bh=UWK1HrKUErfN9uxDIiZi/d6sleBXjg1ytuMtcF19Zp0=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=HgZscbOENCP9c5oVDOC+8UqVPqiTTS5Q2TurdgWlLrn7Jzb9Bh9KdY2JOSEeYTukWuFXpHXX54ttMXvmCYcXvQ8I14/BTGMhvKYtBWy3kptMk0M7QQQQb9PJSyQ9ScBgTcYNx0DNFapQF/mEjcvP0xMK7CPpXFJs2vhrBVLWzNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=EE8b+sJL; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="EE8b+sJL" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:30 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681537 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C07B4157470 for ; Fri, 31 May 2024 11:26:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154812; cv=none; b=Z5ZjikyVXbpJIg4xjQ6S6RIQajq2yuCN2z7jngctLE7W8mRzkkInM9lA0Mm2UKecSI2k7ChgCUplgLCJST7Zr7Ft7S2AMtU5dAknAt9FqvD41DFwBCY/hxGEtChaRugTsKZe+StpVqrcYTc53jzyxr37FFYTnxNdooGf5REbcxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154812; c=relaxed/simple; bh=cKN5lf6pA+apt/jEK8jbRQ79SOOxpYB3vUcvj7l6qN4=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=mXmqLl6+ht5IlcL58jfv6qLJWh1DMKTpdFA7KZtwsomwg7UOv5xY0/7syB4IKd/unG6/GYcAjanpESnJJTYpf7qpuwF5hHB0BAL74brHwihOgYDFFXm03NSOqSTtNGObWq05TKevU2e1xUYhPyrumtsROCVKoBJDX/n5cXK7ZD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=L7TkgavT; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="L7TkgavT" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:35 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681538 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B004D157470 for ; Fri, 31 May 2024 11:26:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154816; cv=none; b=f0dM+P3ik625GtGBzqc8upAkYthT/JebMNaALjOTxCG0rzdIENcHSi2zdEv0IN4r0UMmxI6Of/WlEas1UCBJrChfMZbcJQdFa5spAv4OUac+K4OK67x8nyp3SCDKQQZawAuqe6/k2lJ8Yv4xYLylW+8RX/SGJdQNhdjZka+HM6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154816; c=relaxed/simple; bh=8m0fIfXK4dPQUpzZu5dp7KplyKq7P5AZBWKPdSQVZK8=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=WJwgZNZFsisdnXx57HEsT+Ke7nBlOuMIvZvbOPztncNGLdj9AJPMmTDmP2ENAElb04R9xsje1EeeA8xZcL6aezWHriW9FDPBZXlrcPIP/bO1H7p58qRJ5CAWtfNjxTMuRRjaGtgirHTXYxQ7HgZqKdIrsIu2uDLaqkFVhp08poM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=mdiCJmxl; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="mdiCJmxl" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:40 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681539 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27B9C157468 for ; Fri, 31 May 2024 11:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154821; cv=none; b=JXkO/Jp8u1laCidl4mnbvZG10FOoWKs81nvBi9hE7fs0F4t8DDKRG/V5FOzUJlaa1BJ5bLOk44mQq6KisWaLn2bMRk7mnMErZ+mRQ275Eu2fCrTmVrpC6XwmZKAQOE6FrTUM5vxB8sLRsGoGAeZNFAiEYzuR2DDLmdqmPvPTgsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154821; c=relaxed/simple; bh=75ITdo0qMTUImH0PEMDTfiuXN2o6+iMP/6S05HHHemE=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=GQ/mUBq2j0XNzmV83kpiFJemRG8nT3wLybKiziXIfGGt2anrW+CXE4k6MjB9NIuLrCSPK3z5qu7vLDGNiP0IA0g6h0LgiZvPrEokL1BrulzcM+gSQljLkmFwa3gbu33vsp6pqlrfbY1Mkrzq9qvVGftVOLCckf6punr8Vr4oPX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=UAGagerF; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="UAGagerF" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:45 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13681540 X-Patchwork-Delegate: kuba@kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BB39157468 for ; Fri, 31 May 2024 11:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154824; cv=none; b=NmUHqzClp3XsLbuL2Mx5uoB9FQD6IL+jzvulFF0+Q4FVRouufpiUWQION34DP9OM7Rp4NSeeLmVhdL5qCzmku2bCRrBaSCDqyQoftJPh5dB0coRo9/W+uD+EdLnc395v/K9C0iH8csVYXOfWO2iqDf6g2LT8egbc+jgJx42ycZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717154824; c=relaxed/simple; bh=RRjMb3xjDikXAp19FZO1DkfmHsA1Assyrihd4raLC2c=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=IcQFlaV3KU28pCl6UeHpQjIHMDzRhnEt39iJXhZ1p/s79bpjp/1PNNny4umvhtaJqyAF66VfzDn3Bul/5ZZpwikub2H1J2RQ4OO+0NOLdKgZsE7iT9Xpg7ggieYSwowUvVF8aD5iMiUgGn153Ep0fWXWnyVUVocLVNabkzwJVqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=EXs2dttX; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="EXs2dttX" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 31 May 2024 12:26:51 +0100 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709497 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA56C13DBB1; Mon, 24 Jun 2024 13:28:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235714; cv=none; b=SWewAe9wq9OPaIradj9n2X4KBQwFnZk/Knw/IjmmeZdAcujjZIdUSsvdsVYAV9Y25fEFhsHDabgts8Frj/3X53Ti+XssU0LmRTnhSfGEHRfnB9xd9sop36CeJb37Y2GKDQbLr9bOqO1IjBRtdI5GGScDdjW7BUqyMeX1M/OFc3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235714; c=relaxed/simple; bh=Knw25hLKGn36AJuU2/rDQCCe9C1d6rjfmd8w0Kwrf9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ij8DXfiKXToFuDTVY01tS2zaDXOgFK/145lGw/7AK1/YTvys5gv0yLNOrAjkhpr2ddB9DLUUWe/TI54fe4hJz+OSo7d9R3ntMbHkOrzAGfMsW4XO4QTsxNsemsLzL2VFSyZnR+DhZs7o/gxS4HD/gJkVySpIiYUFGm5T5mxa3qI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZBqvaOJa; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZBqvaOJa" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52ce6a9fd5cso873385e87.3; 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=vger.kernel.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=ZBqvaOJaLpBvLvoDx4+DB36f8kUyelHn7dA4o5VH2fu5akGL1L2M/v7Re1FvqGErkF mL1F5jvl4QWMYgYQZr3xx0ZRORv058uKBOq6DLNq72BmAEgtnLh3mam/TQH4MYdrn+X3 nulmPUr2Q5XfiZxrdEZf0ECMlwE3xQXJ0gHo7SChh+oc+TPkMBrZaqdMrVabH05uaE5B Nh0lcQ6pveVRIbGhyWMvnpQH6mpvqSUapGMgx+t4AHgwJFq/wlDj2WpJBhnyM/iqlWXp hR8Fd9WdK6ubpox/SmGHNNOsyTvxLLPFJxz3RaMsZKQqGjeC2DwiX9AG9VeGsRYer1tc JMCQ== 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=fyvs2AGvpIUvOqgmcHFIFZhnu7kIV8W8EmYEZH/eCyDk25EKSqBq91i5L19Tq/bbPj zWss7SJLYKo7PvUhOM0Cgtj2jtwFrJ4wBdIPXof94xmMGKPkRjR9aqV9ZuOCDghoIvmt Hze1vnJlf84I53RfTDp9QlKhnVxeY8FXGvscPpxzuHfyZm0dxXAVtc+IGKpcK+b8v7OG R5ZXB9jLvB9pi5YMZAcEh4rBcnkbLx6POZSaVdhkT9IQNkyCVyAFiGkD68oYF5t6mk+z jd67Pi0xg4bbQav2mEvecgx5A831sZRK+/2ZG/d2+Ckx5juVdgzbOyX0KoQOClEDdRUs OZqQ== X-Forwarded-Encrypted: i=1; AJvYcCUt8CSfWT4qrkq+0q/n3qmvCqQnGgicP+g4OCNefaeSFP3D/8xqjy1FPUhwKUWdiPIBuiIsrdO7FAmFxx9hIwSrHbWW/XMy86jKPNXsByQvewpenDSVsNr0d4hir4JG5syLkVvZCbUZHWtFYYAwhfljYH3OTXZX7+Pg X-Gm-Message-State: AOJu0Yz1/FD+xM4RPyEWifSDkAfday+9RUKDTLkuGQGIPank5SvnS0Ov K4EyCiijSgJsKG2PnuRMGAfVZbimGVWf911QrvHFkMx0nMldC20E 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709498 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67D3313EFE3; Mon, 24 Jun 2024 13:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235717; cv=none; b=W1tZXlvolzLR92rerQO7OmAtPwamBSL2kyELGAmqTwidtziDdEokFIZ73fAYwMiLVBVhqx/XKr27SuosDDnjV9XjAD/U7KBkHT1y5vll6YoYjWxZcQ6zaVCFoKZ2oH0mCGLfZNYSv2sBOz3i2BS8WH9epscdIEELRKMHVDVciGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235717; c=relaxed/simple; bh=m+ybhBYefVRdgGupMoNJhaFAMLZk7REyA7vo4OfMHq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p5X7Qj1lPhhcQAli3gRgsycHY/r9Upyb4lC0ZQzmDF3euVLBGq6/Es6cRXSqLB0tqkD9lQrylu/q5iKKgSEGuWZTXw6fGT5+6Ih+ibb4GbbdPe9IP5/Bt201EDObF0fOSv8bTEbtNjExBtmM3PIGkI72qbJeQAaDsQgpUhOsMcw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BDZGdJx2; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BDZGdJx2" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5295eb47b48so5099726e87.1; 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=vger.kernel.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=BDZGdJx2wVnezRfvuu0FDOGlohUiK6LT36BYaUXwAudJv+Te0yhpDwbBS1AieWVGky BdOjqHNyAmZyehczBw5naKMu/P6y2Eb5rJA2QWXGqR27FI1hMkykCMbbw3GSnbxjtdtD gYE5SDiLekT5FQ9EXxjHJIm6V7meuKbwHRqoJgknykrHpDzsP2vm2//3i5j/kmawHN0L BuBO4sPB/dN9W35exrlu6JLWKUltw2ewkycj/INbJShdm3ESvzmjvu3KeT8H5Zh2cEC0 19BK9fPeq9Wn2kyzhHcRUOejBzwfsjsecmlH2BHpMKHXTY70PeTt08EQlmOyJKYhzD2s 8reA== 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=UG6SAVS8pzqTUJsS3mdQtXj8wI56hFU8mq1NziiweV3cAqF2iRftQFN7xOOAGPukWP ygGo+eI/r+99lXW/1ggo4RH/BeSVKQSKiLvgAZj2LALrZl9PBBrHuD5W/qrU5cGo2WME 7bzZ5oNlS6Gt5BTze/GWCda9Y2l8hS2IJPC+32RsIDOtrEPjouLQ0rfU90U9cKEk4htr bSbIOjpqlcZz1EM63ywSH2rlACp0a3BZ7Qy5ikORX2c+3E30EXz6GV7C/uCRwIXuWjny rdHmtB1iF4OHyooUzFYOSuGkSL95h5RbEI5p0d5tN5tfTOe9z2QqgjE5rxVnIgDEHL0z 5tlg== X-Forwarded-Encrypted: i=1; AJvYcCWGpDFuUTozfokiElVfwquA9UTRY1E30ZlzYFpAalOyRkLSl2B0fHOKR9StrYAHeusAKOXWzepzC09Q67D09mBSOpXgBqofXGK5IBLUeJBlg2c5sfIO3KR6Y7vjqr8T4tnbqy0gkM25jFehc1CVJgYeRrqpVt0OrwwNFzimy6aGiY13ZPqDBdo7yJIVuNaYoFIIge3Pq81nnw== X-Gm-Message-State: AOJu0YxwEU8wDJkcz6yoPKdP8Cuyi01Lqfww1LAGyaf2kAKfeaqR5abn 45NG6krCyxhl/z7Y8FkgUKzA9oa3WuLXu+fbSZYFcJfO8yBbtkMV 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709499 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 942B313F44D; Mon, 24 Jun 2024 13:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235719; cv=none; b=LoLYJ+fNv8grtGYav/qxg7kOhO2e8sdpAchnqeGoU+S+wK2nmFhbp73t/2Y+6Csbhe3o6p0MakpyS2fRJmsOx4+XLteLAi0iu0Gg520JCwbsqsZx0HXrIbh2aph3OSN6Fi/CjgWLgn6PbSrW7jEkW5MFGOP5X+K7RUivfxtQkMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235719; c=relaxed/simple; bh=/Se+MUZKf2rO8FEugEfFK6YmuKLizh44eeqE06vUbmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CkLIkAOVo0RRUVTr1s5Fihg/Idan+ZsOKV+W3pnRHA+yePkW3oG4EoQmbWh/C0ujAPCT+22fhGPW59H5hPSngNfeUiE8N44v2RuqjOq1mV2/gGZ1uDuKudPzchFVg0UKybMl+2bzrX8BAOi/FjeIFId17FSEF/iW3xoJXWGxLaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IcwZeSq6; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IcwZeSq6" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52cd717ec07so3319633e87.0; 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=vger.kernel.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=IcwZeSq6uErbhEH+mrX7Q4zxelMa3rRkqxiJIQd5r7yZkApbbf6KU5ZlSt73CZgCZL xGBCBZNGgPQ8eQgPzEeyT233eOAgH9NEhGvgZFz070R95MZxy6mP1sGTvmUtvuFN5Bag bzRRxLC4DOVkBhUKUsh0maI+81I1IbLYBm1fKrYUhLUv9Rl7EJyq7/ip8niR1CUmqIwn Qd5sib6zquwe2K7n7/D/N1EmuqWtQFyO0jdGaSCItbSgiwr3C/xJkjDF438WwTep58Jy rvyQ+txuYPb5oXmfq8CeAKfWL4qXjwxn32YmU4TTepGtnKEWrrkD9GdY+4oojnMoYYEV oE5g== 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=kKjZtOdFzncYY5RMCbbpzSi/os/E/maMTwz8xApO8LJqWTKTDyXcqtsifVyf6Pw+XF 53NY1eDeuQt2WHMC57y14edj9daEbFmZQyaFuS2wRKgaJ5VOxXvkQJkCD8DQFQ+iXzYe NHxoTCTuxPZiJLBI9Q5vJHIzrp/09QtAuK70i+KYzDGre+QHR9XWrnOxHiP88e05GCJC 2jIWg11E8J/Dwf18rzJXlMqe4IwTfWyLCVlvf3rFP8NaQcc/Pu8grldFiOV/EkV+He4E 6dEjCzPoWeUtnzoBrHyPNNmxnMBbLQQEoEEL7XUrc2/KzECSlUsvdmh18R01L9R9q7LH rrJA== X-Forwarded-Encrypted: i=1; AJvYcCUwXAxVPkF6+Jd2zvQ6rmDH2++64pM2SamAFG2mnw+v54DW4gY/A2gmzbZGg63SmoGb1TEEDh7llmSc79ppPZdQPocDI3kpUT4VWzXr3zoo1TNX7c1GR9hQhVi1638Np8OCNMH9ZCUBMzTCSJlvffJS5eiHyK/nUHLE X-Gm-Message-State: AOJu0YxHAqr74RleP8U8+wBbdzbGb8VeK2xXyB4wphjSEAQO/8gYFnkJ tWdPhRaM54T10pCQarHPYI5uFyp7qrHimsIVPYgKd3YHr6ELLUa1 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709500 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B81E914037D; Mon, 24 Jun 2024 13:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235721; cv=none; b=otmRCx6RCDx8Bfld2e5CB25ebppZI8DCenQiqA86N/dwR2dRRbPgud2P0b8XzcIn2Q8Scq7+VkweTZSbBFQshmp0qDlw2eD0eR/Fuw5ZHjcv6tA2QjsWT2yfs/cA0hOKXsjkMXe98bkXCz8JYPGIZyzMP7+3Mc5vGKFhbNNOeFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235721; c=relaxed/simple; bh=vI3cfKqKf1N8tTHvEKRxUuZwgu8WSPzXmooGPm1f6zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k/m6Dcjnu3htyk61u4EHlYaSMtsKnw+dAK9Nr1FFOr8evJq4WSZYK3Z5bjxOWL8aJoUDek5sjkFT/6odqDR4S5kQlNV7ibjD//zOMsAAHoifOu9AH5mXTDuy1InGpy7uyp1H6p7G39FM6d1paw3Q9oG72vL276RFDFvLcfDtmS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FAdybOxs; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FAdybOxs" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52ce0140416so1846993e87.0; 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=vger.kernel.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=FAdybOxsZ7H+svXGAGu0707p40gUA3vjtvEqgjhXirp0DhgBSl4UXL01dA2CMdrIFu NU1UXkgSM/Od6qOXu327pMfJq69xQ5eI24rmmHmzZLaxWv8Q1yzqtQ5Gqu/dH32+2Rw2 t2bVNAhi2guK1EbaitGGjEdb8tLGfaNR5s47ZEBHTV87ygRbiDgfLmN3vx9Z5UnOtEpN HcO37RCvOnbdZqHJo/UUeXkhgTYXT/Zdc87uhmAsD8yEM/FHqUwPK1xFaTLXFf75mL0J p0HA5+CM/p+N6rNZT0DZ8JvYOzgSWkyhihapWySrybREMs8hjN2ZqMz7Kr5DNVzmVMUs rCpw== 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=CprZSNdmD4StfBfmBIJhbMq19JbrrHGWqLtnxW1L3v7aGMt/LVem2XMIUQ88XFs7eN IbR3NG+UF8zkpTRMhWznslyHw731FF5Lb3YXM20zzuQRLhHbCqBQ8BklbmyyVlz/aLK+ OwsQYAzGt1iM05tlXXNbo+0qDQbttrQPBY++h7KogtVOhl/zYBij9NZgBQ3vsgSBsYjm j6bSU4i3+F2DWQSDwTinC8DXWPto/amXjfiOfkbVTGeq5XQw3z8INENny4MGBMAqB5Il nwjOGTPZ0te4tzL01RzL870yPEt/zgSsVNf2bJy71rnfiQSyGYu/iphhTXkJ7a9HuFxY TTjg== X-Forwarded-Encrypted: i=1; AJvYcCXnbIvdrFbtltrWYWpySSVWgz6WnKBmbOXPVae83VNCSBQhu3SLYvgG6odmqs4hGghDoQjCfJGbuGTgqMRESArvQBgSbDfE/da6Vim3xDZQzuhqM8mQn9E2AAdG40q9DJSAExS1vAHpGj25hLw4X6veLaif9Guylyoo X-Gm-Message-State: AOJu0Yzpaf4179J/sKVhYJpO+m9OphSkfazYDS1csVVbhd8lJRgwwXvo 9BeGcqrM6Y0/j7eVNlSLwf5QbiBybcPlbRXI/2Q0+yJK8Po7oPOh 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709501 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 459721411D3; Mon, 24 Jun 2024 13:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235724; cv=none; b=fRFIFuBjfI30f0fz69XCqYjwNjfk69jQH6De42aXCAgzf+F0WPMlSgKuDFY4QflGi2ypJePoTXtF47UnM5Ue/OD+veaL8Wr0FZ0OJO56rHHdzd2H+4sNfdXODrfZU9plnoEHN5JDWdHdcp9YgXrgQrOrINReJkK64vB+X5Qe05E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235724; c=relaxed/simple; bh=6POb5W1RI+/9TNlT1foE0fWiDxIDRIQiUlN44x1xRXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/Qlu16qZ+120vSYMuSFh3WM03EVy67ovIz2K5jInWn1p9AimhcoJT6yRUsCGQegUNOKERV9Y2bWtAx5LNl74vFo86cE4riH8MK+sUgzNDJJuXgNsA75bKN4ivZpYrHTqptGNumcx1odTs5gSuEWHI6CtY5cT974ot3FQ1Lfj/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N4JyiDVk; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4JyiDVk" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52ce0140416so1847068e87.0; Mon, 24 Jun 2024 06:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235720; x=1719840520; darn=vger.kernel.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=N4JyiDVkjXYrbR2nSbwdVqIUqzWhHUa1PKJWAL6FhAXWZSv5sJmpH5hADUmc/QEzeA m9JKhWRKKI09u3SInEsTTtKgMclEvyuqD1SZkcQWB+NBc2S0xLuh6p8VQameDnvHLJJd OZhKm/3KcbZWeBwYrwbSohPLCIPH3Ujqc44vFz6r0CTpB2hWwhM3paunxURy/eVWxBES nLGy8kvxtOtmv+dfdfk9OzUjzp5774Yil+vr0zjJ4HrPZnPCHz4LVRMZmyNpxXSx2xkB ENaG6txh88Z9hUxp3T9uqByrL+w1L1H2vDqrfMWtm5iYYPJstmOQyXIF7p2qXhx4tqd5 paqQ== 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=ehlF2r8AkfOLexl1I5RBKdYwXZvL54pdyu1dGQxh1Y5AFvpIiif8U0J+IgfLr0WZVW 37M7UcQwA8Wog7t3FDTqL5p9LY26Q4Pw5h0UWBtTlrnyhXUEuUZcblgQcR4UX5X6DdwU zCKTy45sOq3jGZMe0Nl5x1KJPz5iQo7zdiB2zh8mv/EL3BppoVgw4Ws8BWiFQERXKgn/ agi4JvFKrLWE+wwhHrcj6itQ3HVvYpQ/C/KJlmFoNtlj1zLaJBFcu1y+cauqowQK1Ebb yChbUGJetjtbHvvOhIgqXqyfL5FMzsl5OgHNjPofFfNfF18eKD8mrs2Qb8kbUYsaRg1m gINQ== X-Forwarded-Encrypted: i=1; AJvYcCVUMqv6msihSTjUtTR8h3I1IdG3d0bTJtTpAuYaJujWQiI5eUKrmkQLDgZi+p6bxh6574QWIc+zVKu55wcjCQuya+kpgUYJtHYiPt8BjNaD1esGjkiul0XkYmTWo+f3hlfw3QjFDO9/jjUAMx5Z/1sNZ2psOPK2J42aUCItGTYjcJNIU8IMG4PWyCPpsGBQYhFnDyW/htkyqQ== X-Gm-Message-State: AOJu0YyuvnqO3Ew+pkuiPdZmsHseY4vNTngMZOu/Ttm7NNy91GGWPYFE UgtXtcEPS0Zt2EEPZv+xQUckbKyrIEnG5H4g1MT+WI2EXl5QXNEt 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709502 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9211142621; Mon, 24 Jun 2024 13:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235726; cv=none; b=rVDHGCcO+41Qdoal69ZulzljyjTpAKDOsJbt0013OkHHatSF9jFbxlxphPjoStHNtKfHTO+BY//UTC0/Gwm9URMT2qVF/wgsBJ2W0EBwKbkbTh9+dDhbrDge1RyXRU+5bOjvf/c+xIjJNqvpAOh+Iv7GXrjxiJ3KuSTSmEpe8Jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235726; c=relaxed/simple; bh=ym+4Y7Ib1Bp26UCwCyfmGDHf+s9FRlXIxWhUXBMvrPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gmsDC651+WhCxCBuGNoKURo/yWJWhjJfMEAknet4m8QiecdbJxn9JM0qxQ89QDNsqGbZmWC/BQWAe+goJHoMRYU+KIpTK/qkK0VuVmgGlxEhCTbkuNKJA6QZcG4D57KJXXKuKqDzGDdYaMDG+61fJUgiCU0NZ2Gxir5HMhDVuGA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ho+6YDFy; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ho+6YDFy" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2ebe3fb5d4dso38156031fa.0; 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=vger.kernel.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=Ho+6YDFydmB120QYAz5GgPtCaXdnmR4m4xKuS/IVBluI6l3+D8SghqpslpkfGr7Ott DTrKduZaYxQLGwkkLhKy4yLRwkF0qfCk4hCrE1KUUaE3j+rjDbuNGV8n+LXdzo3Pi9/D IbabACdGpUfTX4zSRhs/fHFHc4iDA4TL3jcT3Ccl9gBE6G1TOLegWXfR/L8nPk1jz1tE 1//zVN3c3hKG+2qstjPyIad1CzwqiHPVQwB084Of8VM4e/rQZGx5XMESYiI4J4qzA5i9 2p5OC6BE7kJOAjbEo3tBL8m/HjriLexUiKyEHl0sZdW8VNccyYTm16ji8atoX9V5jomC SH2Q== 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=Ki+elq9drf/v9RLTYhif2nq8j0M7Zl6EJU4Z6pepJuwC4qAvJu+s1QH/ckxshX8v3M csWpflv1BBFc4egENb+CqLnb5mkbfZXPlPJVoLtSZc+nRFUQociV3OWTzFbAntCuWAFT 4kn0kgoCt5b1lfCeFr2H4wdGIGMYBlj8ieDownfRoxEyZo35gh2eLH36eAtQRfz70UPd /CPR/Mo8i1AGDNZBS1MXTvol6+sPhTa6eLFvrtDP+CGjR+WBfrFMABnv2O2Mgb01i/S2 U/CNONsx9dnCJIJA7XR6kqIK6el7wuzw6HWEO9tdEqki/ve9qRblD7rkxLWbYSs0R2TD 63gA== X-Forwarded-Encrypted: i=1; AJvYcCWbVWVWfzRlQKW5FB/Q2dhMVUNLVkk05ojdrso5thE7IDyp7sB6kuKJaMSXumAcNfMYK5dQ7lgYo9AFK3Ja6QU9roUbYCe07ddjYiPRNNBHittO96DFW4pLFFG1XxH9KscUeIbKaXVE4Mf9+IzlMLOSqv8YzSY8Wsqd X-Gm-Message-State: AOJu0YwLAFUqcxNMmyqhx8mPOlayO1dfMZACzQ91nTPO/pFwgfum73hF LlCNsb2LmJ2PojZ5mCN6EAVc6kABPsuRKaGC75Iu55LpL/uEggcm 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709503 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7E5E1428E5; Mon, 24 Jun 2024 13:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235728; cv=none; b=Xg737ZfKka9OHPKrm1pAUfsyy2xpJbEmTvcm2/MRkX0kaV+ROxeLJUw3mhiWEFftiaH2T1V6NO8aMC04BJ45THF9MZ3lWf0PYG8mFwJo3flP29CBzyhnG2WzVjI3taRRUoOvnoGYFEJ3URD+M5Kvlty1ok3qvMEVl3ybzNFxJjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235728; c=relaxed/simple; bh=H/nRiRhNGNJ+A+zOcP60AClklxPQ/DRXk8bhOo1X1GQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QvThw0PASavEy7/fQUDmCKw5fAkV3gnPqrHgft2GNA1k/6GM4NenJwEGL6JC2a+9WUEpu46VAPK2LcH0/Mofv8ikz7czpACY9OXnQCQ460guOJ/HyPwfeYmhXi14khsLzbhkOYlNg8+u/lbTuFaUK7PbXmYQUtmmyPnRag8JPgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Oz2fAfbo; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Oz2fAfbo" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52ce0140416so1847183e87.0; 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=vger.kernel.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=Oz2fAfboLN1fDckGL6kW1UNCdsK+RRrXWqg91I2QCTB6xlnZC+1+GxDRlJ4CAqhTId OiFPGR4geiXv10MW9hXHeYmDeQu9SWx24BNXZ6EYEuQqn6qmBTg3yBLMsgFIw9WpjZnW DGTuQjqbjVhL6vobWlFPWt0yFpwKgn2Few3ft89g4AMnPFD8KUq9D4SmS3qbT67ExVSD KuHXZltYJBRKdGsKOb0GZrS91S4BKmdF5I+K+RFythCrfs9fCkXm9jc73b7Xb7rHc6pD wwUKqwBmNQ0S0fJla+JDWOM3Gwy4JyNryWrPxa+29sROG7qsrcROcPiLYUDYu3cLx9yO gcUA== 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=UM0LSgNq8V4ltpuXgOKXsyZFO4VjccmzH6xNerOb9Nqex4Ry3FtTHcRb2Tnbcyt2Xq gx5niTdI4wERfuo5kTKNums3YShfd5jEL0/NzQojDHNsZoJq0BmtaPRgBFghCgp1sLhk X5dYSeAttcg71pohC8qL4J5FV1Tf2pG4bUxKlWYvCsb8W6ys+bTI02IQ59LF1RkcTHzx XcfCWdYSpEbxjGEe9ddIe6WKUQe8PByxjuow8DpThUQ0/DWzjhLznGT105pKXMJ0pAIQ lBkLMh1qmKL5eDFY5XxQG8dYj5KOL5K8B68Ag5FvmpaK3Yk3E6NbNg3hF/SjnnVTX1Mf a5Ng== X-Forwarded-Encrypted: i=1; AJvYcCW7eijgdSKLduyYH8CRZ2TSsTXUPSKve+O/jT5cF5d5/2UshpGKEp6vC1OwpQcDL7f92QUMNtdMEAzbx8yPxLSnJJNhwCR1sjanGv01InaA4r3d2QpcL72xhf5bH+8yg1WO3vuMcsGsU95BJ0coAKDmlSYYxWin3H5p X-Gm-Message-State: AOJu0YxYJW7/CJxc0auCPc2uOqLaobNNrQEjICQBAqDJLPL5Iwl1AxcL HawJfzEb3OWwiCRNGwijfcSWr/TwiYkrxxr+0ZAQN1sJrM3fsdrJ 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709504 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7F191411D3; Mon, 24 Jun 2024 13:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235731; cv=none; b=msvUYWZgeXHHB2lanlETWzjP8I/5ASGW0ES6U0lf1IBCzeLydOAYxRsDjhdW+P4g5FYda7zlmFLFUzwV3fIa9kUcSj5xz/LZLb05MbNxiTQF7wI2xnomSqOXmZHDtncV+8Xq+3fd6iLGQ2DZXWjhOa/IEuLQgwEvDgT00NLfwAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235731; c=relaxed/simple; bh=X1Ada1ye9iKeUslNrsy74En//UFSuGExAFa9+RyTjPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e59/gkM41SrcO5NcKQXTthYVOXid6Rzmuf63vN1m/z3BwuEBgxVVLNjQAKPZlnE9I0oMz/wUP+e+YWziG3w417U0hs/I5rt4LE1/RcU04MLQ9oRN/yKQbdxl5/RPNdW6L3aKJ4xm3lRFdRE3RPWzghR2lMzyt4tGQ/Y3FICa1mg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WDLUVO3n; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WDLUVO3n" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so49188561fa.3; 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=vger.kernel.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=WDLUVO3nD40Kk84jgSwoMDlxK71O1JoIgk/OFatCeVg95kR/i/lM8A68BC4BTSmLZV MgXKWSgq7Fq8ctOGYOKyO8aHVqn69xXXoPPdSsQaoea1TrG8l8lStzYnBN2R4T/UUR2T ebOnKVjWr33JBTP4QhRFTIgA9D5zgvNu1DQ7cpq2U96AecN0sMQR5DmIVwtf/zW9iV2w RUXaHjmP8uZgpYkH5BbNFKuz1nf57t6Gp7p9BteS55Q38h4We8Thzv6FWjhRe0OBu2h0 92sY/bI4MMVu5dWEbF89FtEkxsJbNKGPRUjbHIvcWD74X0lQylKxGKlxSMyYq0FT67cB IvHg== 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=a7SqP8qhMES7UEA0uxcnANsWDQ5wQSCN7jMQ0wSPuxIJ9MrCOh71rGZYVnC3pb/oIY 2lQuxAPrCmiKHOPj9QonLmfN7ZnHonqnhZa4FxHE7EcuBqtp0B+Y0HPD6AyhDhte1z54 mr4O+mGKE/5IqDRm5rAXP3NtDu7OTxmFH4QIrNQv27lPXt6tf3GGTWw75tpD0JYe/mHF +EQqhBwZ5xj625gyT9TNoHTb6WuCIEf64NTI+DYfX2ZG5Z+9KKGEZHDwS+HCTM4/jZsG HQjer80zIsToZCG0MOIXtI8OVUymCkkI4NSEHQ+Airt15nGYvIcxTO4vIG9DUhDC7WN8 kqVQ== X-Forwarded-Encrypted: i=1; AJvYcCXsKCoICH2v8y5/BKq+QsdR2OF7hfnWS45yAUr1g4JtWZYVlMO+Fm+vh8DSB9LSklq1I/I+euEjYU6HRELpsCTcYMnYLliV97guc5Shu3gqR5bNUrtpnczC/hIvktofSjQy93QaqD0/tJSKTO7mlEAtZEcqRMXC/8lh X-Gm-Message-State: AOJu0YwgWWHtCGIAIHM9Rwz2BKOTia+mMjq9lfi+Y75xjg6o7FQozP9x +b1RwVfVRozKmdYbrWr+PPp4QdQnKemm6eqpgbdWmrXhrZxlP3dI 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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: 13709505 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2164313E3ED; Mon, 24 Jun 2024 13:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235732; cv=none; b=fKOXdjMr8qfLgNObhLgN5ZqhFAlDCiB2q7dZuV1U46F82Qh/29nDoOvaxAJ7blFGXR1Db6xGpgO+cLyEjRYJ8+E7RnkjV1FTI9Ucq/I96xXFYaHkUElA/xEQmqFzRiDsttnZoxN9krtoQC/eeKa0IjdTFDm80Bvm2HbUTbeEzWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719235732; c=relaxed/simple; bh=cDqcb6SJV4vRBb4QkNmQT3Wl/AbFEpR2X5N+u6WtmW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oomZk6CRsk8ytWhalvCbqvQ0tKx2qDH51svMaTIduVNACagcZP0osPVzF8ugp7ml4D4DzlcJ1JF8G/PTYzgdWzALhsYOFehDWW3THayKAZ1lxPK/Zjh75HXkWEkpDQZjnNqnAyiVHrnRYYLauPnHln9+klMmQVdMIrzmS4hVkuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZMlwThy/; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZMlwThy/" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2ec6635aa43so4209021fa.1; 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=vger.kernel.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=ZMlwThy/3xzxtPwT3+luMCEFBU8NHV4ABEkK6TrI+XMuIjE0ITbgF8tppy75mwmS64 LmBcZuGQ6NBi7SYO5Jqm88u/55nvxpsiCVcw8IHYbBnJQ1EOyMmI/Vdcd0GAJoBlna96 rUbA3aglp4yEvhviO6Hy9nAo21pel+JTZIGUEm5Vb/9/MzvMCVU0u8YUtcXfaa8Idc0V qCcNEZTJESr1ZemwILHDkRTAh7Y532LYGxKnfOqxwM+QcauvYRnXEXdAfEl4hMky85ES IPrqVwBqeSi8DyVf6vPXg84IoiNL5eBmCibYG0uFr9LzX1nUjfxbEhz2UFoZd2meWH/E 5w2A== 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=fi8u9dR5qtzgPKO080S2J3CVBkOHsqFteIzW0tGrWEUPPVMmBVd0rk2q40buCQVAa6 QHf632rNkmlI7QBp7U9M/x4RnJsKVKTJfOgs3vDZ5atkTdVMZsC5+TGwAIYb5HkOj13o c334GeOEVkDggeJsiui857TjjK7mkahtzL5VR9Ge+UN3HG/diV8gldrVCbeVI0aQ4wZr EVOAuEwiDn4DbwN9Y6P5vuBlgJBxRcbeCuTgU7Kj+ejtwVH0zG3AYUfcFayRFeUyAYo/ sPEth9usubTcMZ7L2C1VZ97ha4gt0V1glwqsBlOUvs7mIFr72fnLJaNuLXejw5MuVM6S NBPg== X-Forwarded-Encrypted: i=1; AJvYcCVZWzYmDIrQJJaOE6hNaLIT0678H0vm6QZkUOqEOme/8fdr+wz0h6CE961S9x87lHw6fMH0RQGGUTA1B+dMCU4V1rN3onas7gMjaEZihpi8jRpTbJLL4QCXtx/z88qObmR5JUWMsyVJnntnfdUQa3zcyL/3JMawWYY7 X-Gm-Message-State: AOJu0YxOtaoTJ9a/QRNuvLJOMdD4ou2PNbbQUHYCfkW8qI0wXFzSy1Gm 0CP4Uo+mAMLmAGuAclQZsVqgH5t4L6ncfPX/WnvGWCMmeM0iNq9w 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: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 */