From patchwork Fri Aug 2 10:46: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: 13751436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8280FC3DA4A for ; Fri, 2 Aug 2024 10:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rikXu0t2tLqao+iuwW+8gc88e95JwdCZibSBDQw7Iz4=; b=4JxvlLalIbk9u+afviNnCneZmU llG49WkWpPTJ/iPXroe2pZHrQ4YuvpGFdZIg4cdeHHqa/Mst4yEHhUWheXi7PqhR5NQGkjyfB+4oi 2uPmyEW/DsWpAJdddAtU0Eebwnm/3XcetFoYHsVoi6nDKvcWBD3e82uTl5JF+Cj+p2bbUGNoS90Pf +ikIdQkGrStdIBMkfTkxruYdz5mATcehK17or4miiIADRgHZWxIv2ZEVQnOPiF/KYxKD3Zij2C0tp H5K6tNBt7osHlG2s44klF2xUpH9rNdc/gsYbBj6CS8n8pUbOfV0eM3JQvtY5IHnKrS44nnTMtNwJi ppcPBFqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpp2-00000008XGj-17nZ; Fri, 02 Aug 2024 10:47:44 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpoW-00000008X1K-2aQD for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:47:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rikXu0t2tLqao+iuwW+8gc88e95JwdCZibSBDQw7Iz4=; b=Rj8goWRMMBHUjN28k4D2RXfQiA jVLOnl7V7m2LOcDsMe3ZkCdfJICFeNOR9ahc7UPv71NZqtqAnPbaJ11wIeNEKjysqPhnsH+tIq/BE qK658Zp7exY/cWZwTm9Qp+Uazfsx9md6ttWK42LJT4C3FStSusqnxXpjPpq3q+rM0ZtspZ1FUkAsb my56WURKbErm5PsN5GRUJWp9w86i0AbSbYWT3jtt1ZZf68n/Gv8eGJ6FJ9/JWfLjkApfiJoYTas3u 4avIQNgWaQQvg8cvaZ6/cs972+9fTPfOAs494kYs5zsurnLBU5s573X9DyY9TdtEpylmZ02hGmLpO 6L/SQCnQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58546 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 1sZpnl-0006Dp-2w; Fri, 02 Aug 2024 11:46:26 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpnq-000eGq-U0; Fri, 02 Aug 2024 11:46:30 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 01/14] net: stmmac: qcom-ethqos: add ethqos_pcs_set_inband() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:30 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034712_847203_413C9819 X-CRM114-Status: UNSURE ( 9.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add ethqos_pcs_set_inband() to improve readability, and to allow future changes when phylink PCS support is properly merged. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Halaney --- .../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 901a3c1959fa..092b053dd8da 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -636,6 +636,11 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed) } } +static void ethqos_pcs_set_inband(struct stmmac_priv *priv, bool enable) +{ + stmmac_pcs_ctrl_ane(priv, priv->ioaddr, enable, 0, 0); +} + /* On interface toggle MAC registers gets reset. * Configure MAC block for SGMII on ethernet phy link up */ @@ -654,7 +659,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); + ethqos_pcs_set_inband(priv, false); break; case SPEED_1000: val &= ~ETHQOS_MAC_CTRL_PORT_SEL; @@ -662,12 +667,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); + ethqos_pcs_set_inband(priv, true); 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); + ethqos_pcs_set_inband(priv, true); break; case SPEED_10: val |= ETHQOS_MAC_CTRL_PORT_SEL; @@ -677,7 +682,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); + ethqos_pcs_set_inband(priv, true); break; } From patchwork Fri Aug 2 10:46:36 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: 13751437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0C19C3DA4A for ; Fri, 2 Aug 2024 10:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JaWuG7+rQO/Ul/PPdHoPd+nkstTVgqxf0FWXUBMchWg=; b=4dqucoFdIKQ7uHj1NmtuLua71F YEsZgPjFX0ZeWfvJGtgof+WZhl9x1K3boeWxuCbYyzo5EfPPCx+UctmnBA+XmlFdnIsG0smHrcMng avtWXzdetkg8VZzy/k3W2S1/yATe2MYI06jko+NSskgUhAIDEGskfb3Q4Vo9IOwruCVr1U6VRg7oL gHjuFRCglPGdFvoQK0a8IgamH0eZFyaQkvLQu+CIVHZTDpbySucUs0NQrnr732TGXimb+74OWDc8j /CCD0/Ikp6FSQTmqh8CF78YUbA2IFfknw9AKXg2e0zs7LP3c4wmnx6FrePeTA5EvyruSykC1+U/L2 FX5RSb/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppV-00000008XSJ-3N7W; Fri, 02 Aug 2024 10:48:13 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpoe-00000008X9X-25hQ for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:47:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JaWuG7+rQO/Ul/PPdHoPd+nkstTVgqxf0FWXUBMchWg=; b=zu1U9C5AvRf8kOWTzgVz1jrNcB bszhfBEMbW61kQkHBEqO9ykD4YxnC0kKU8bKKb/SNvEDGbad19x0nU6yekQFgZ1U4M/XEKrtjlEc6 RgqawJ5sogJdfu0mV7o6MIW+XOaJNK7Qq0cRRLyvpHG+9fX0Wc38qWfGSCEjSVa6qjRUozdCc/fsw MnDe38qlPFSEz2J3cfdeViSzGBRE231pKgW1lCMH7txi5Y6qsmxytqYgGqEEo8IRRQYFkf7BfAcK1 HFMZaFQZEgbIRcg4LJlfCzK6B9g5NJtFY3o0oHEAhk/DOs201HjV9eM7qGQ2iQFCV8/AOOKhM4ZJs q4um9k9w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58552 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 1sZpnr-0006E1-1f; Fri, 02 Aug 2024 11:46:31 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpnw-000eGw-2F; Fri, 02 Aug 2024 11:46:36 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 02/14] net: stmmac: replace ioaddr with stmmac_priv for pcs_set_ane() method MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:36 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034720_548500_FAF4FCA4 X-CRM114-Status: GOOD ( 12.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Pass the stmmac_priv structure into the pcs_set_ane() MAC method rather than having callers dereferencing this structure for the IO address. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 6 +++--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 092b053dd8da..ddf86ca1a093 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -638,7 +638,7 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed) static void ethqos_pcs_set_inband(struct stmmac_priv *priv, bool enable) { - stmmac_pcs_ctrl_ane(priv, priv->ioaddr, enable, 0, 0); + stmmac_pcs_ctrl_ane(priv, enable, 0, 0); } /* On interface toggle MAC registers gets reset. diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index d413d76a8936..a673cfe9c016 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -398,10 +398,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, - bool loopback) +static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane, + bool srgmi_ral, bool loopback) { - dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); + dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } static void dwmac1000_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index f98741d2607e..0c3aac304193 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -752,10 +752,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(struct stmmac_priv *priv, bool ane, bool srgmi_ral, bool loopback) { - dwmac_ctrl_ane(ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); + dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } static void dwmac4_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index e53c32362774..74d7b2394591 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -368,7 +368,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)(struct stmmac_priv *priv, bool ane, bool srgmi_ral, bool loopback); void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv); /* Safety Features */ @@ -482,7 +482,7 @@ struct stmmac_ops { #define stmmac_mac_debug(__priv, __args...) \ 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) + stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __priv, __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...) \ From patchwork Fri Aug 2 10:46:41 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: 13751438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A51B9C3DA4A for ; Fri, 2 Aug 2024 10:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EpjH42ZYRLEtWP1bc9GI1pFyG22AKovRXxMyj5jwJD0=; b=ZB0qEsJf0gJkUpWyYYmiHNcWiQ OlBD9BEjt6SwQL/FGLNvBC1w0SBKRIiJpVwMV706SHOV4HcqbUHDgiliJyzp81DrpnD/25rM85XeN ypG13j850e2SpypGQqKDqwo005NYEvVW2J6y9gTooSzmvPXQ4Xmu89WnxHIEtFXDK6yQODxIadcgD tZ0BdcTbCycgLSc0hHWcMZ2DbgE9STkHqVfFukAvwKO/qrhtUXSkuYRnPJtl7hw6Hk346+qSQa1GE 4YTg0h8legfXxEHd96TyQCjTfQnMz3qAGohPpWFoIl08iUmeqcQNolzrY49tn1l3xiZsfDNet0KoI aKGPKUjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpq3-00000008Xfg-3QjA; Fri, 02 Aug 2024 10:48:47 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpp0-00000008XF3-19H2 for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:47:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EpjH42ZYRLEtWP1bc9GI1pFyG22AKovRXxMyj5jwJD0=; b=hbgxXwxqnVcpC3nWpRl7iuoWyQ 90gTv6bprDmuUxZBzhW6TNVkuE/YSotvkZgJNRhAwu5ZlG/KSqfLVbo1++hhbS8l06Vkl+FZgkO09 mmJZArinx+Kqyf2QBUmqK0oMkZoD8bjX0jbUnLtQ/lKPvCmgD5LZP5j5V/9mYx11KmCFb9JCuTyOH CFUHU+jqHrc38YRCLnFoHLTr7Lc4AWv2hlumC8/rhymTAYYMf0+ousGaeLlCJKvuhu2Ql6H8ydLng pIxGSvh/LVltR591csAgDvvpFnAXrs7NPpeO+jlmVO7VylLMQOIciogQoMqMSOLz493ur37SU3c8S G3V8uHaA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:40360 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 1sZpnz-0006EH-1z; Fri, 02 Aug 2024 11:46:40 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpo1-000eH2-6W; Fri, 02 Aug 2024 11:46:41 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 03/14] net: stmmac: remove pcs_get_adv_lp() support MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:41 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034742_502624_8544A576 X-CRM114-Status: GOOD ( 19.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Discussing with Serge Semin, it appears that the GMAC_ANE_ADV and GMAC_ANE_LPA registers are only available for TBI and RTBI PHY interfaces. In commit 482b3c3ba757 ("net: stmmac: Drop TBI/RTBI PCS flags") support for these was dropped, and thus it no longer makes sense to access these registers. Remove the *_get_adv_lp() functions from the stmmac driver. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Halaney --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 6 --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ---- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 47 +------------------ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 32 +------------ 5 files changed, 4 insertions(+), 92 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index a673cfe9c016..8af51ddef3e8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -404,11 +404,6 @@ static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } -static void dwmac1000_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) -{ - dwmac_get_adv_lp(ioaddr, GMAC_PCS_BASE, adv); -} - static void dwmac1000_debug(struct stmmac_priv *priv, void __iomem *ioaddr, struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues) @@ -514,7 +509,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, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 0c3aac304193..d919fc07c8f1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -758,11 +758,6 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } -static void dwmac4_get_adv_lp(void __iomem *ioaddr, struct rgmii_adv *adv) -{ - dwmac_get_adv_lp(ioaddr, GMAC_PCS_BASE, adv); -} - /* RGMII or SMII interface */ static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x) { @@ -1210,7 +1205,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, @@ -1254,7 +1248,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, @@ -1302,7 +1295,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, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 74d7b2394591..1711d8072cd2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -370,7 +370,6 @@ struct stmmac_ops { /* PCS calls */ void (*pcs_ctrl_ane)(struct stmmac_priv *priv, 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); @@ -483,8 +482,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, __priv, __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...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 7008219fd88d..fbf71d0af9bc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -324,7 +324,6 @@ 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)) { - struct rgmii_adv adv; u32 supported, advertising, lp_advertising; if (!priv->xstats.pcs_link) { @@ -336,10 +335,6 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev, 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( @@ -349,44 +344,12 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev, 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( @@ -521,12 +484,9 @@ 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_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { + if (priv->hw->pcs) { pause->autoneg = 1; - if (!adv_lp.pause) - return; } else { phylink_ethtool_get_pauseparam(priv->phylink, pause); } @@ -537,12 +497,9 @@ 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_pcs_get_adv_lp(priv, priv->ioaddr, &adv_lp)) { + if (priv->hw->pcs) { pause->autoneg = 1; - if (!adv_lp.pause) - return -EOPNOTSUPP; return 0; } else { return phylink_ethtool_set_pauseparam(priv->phylink, pause); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 1bdf87b237c4..4a684c97dfae 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -16,6 +16,8 @@ /* PCS registers (AN/TBI/SGMII/RGMII) offsets */ #define GMAC_AN_CTRL(x) (x) /* AN control */ #define GMAC_AN_STATUS(x) (x + 0x4) /* AN status */ + +/* ADV, LPA and EXP are only available for the TBI and RTBI interfaces */ #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 */ @@ -107,34 +109,4 @@ 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; -} #endif /* __STMMAC_PCS_H__ */ From patchwork Fri Aug 2 10:46:46 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: 13751439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19068C3DA4A for ; Fri, 2 Aug 2024 10:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0ROxeCV42WFqA6mDcBR75RvMM2/Y1MHX653bKx9WiT8=; b=omNDfzrfjrK6p1n2D59EyKghc5 foQdujc0IGTo4GoBv1XJKUg+2mdz9wQ29p6qAqkcr548F2Nb0lvxjQIm1kbsT4uyBstkvwHr+cJtp LNzPgTHyGvolZaGoaWYKtUpSBN1UIb+jqNu9pHuw0bAo/zn+oEqgJMF2jY8eNKD8qfZIDZh8xJoxc XK/vQRSDjAL2hP4Y6dSsdFwjpjExSPkeGUu4T5YKCSQYQnFCqJeFZXDLWTSCl8FwSkur3UZUjho15 i+FoPC3WnStjK2HzkBJRXXGrLwYLbZfDBinb4h93jECgRV2Xkjv0nJH7UfA3o3+Kin6AWSW5f0T/f OZZoG5Fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpqX-00000008Xnr-2HfH; Fri, 02 Aug 2024 10:49:17 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpp8-00000008XHG-2haG for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:47:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0ROxeCV42WFqA6mDcBR75RvMM2/Y1MHX653bKx9WiT8=; b=elL+3TNSn+9x7T3N9KEHN+P8e/ YhgHuNgdOu3Y5FuHQbc/pBkLJzhCMIjpl8QOZ2pEYNQR5a/ZNySUAihDz4AM/y9z8I3dRID50/9HU Nl5KyJ/vawETVaRTOw3rtdsX91jfsO5QvEoBQ+BhIDGkASe/Zzw+XEhqhx8FA8zm3soiZQeS2ChBB ojGc0gWADBtOis69n2lHEcmdhXyCCRXf2xX8ZgGXEyINlBeHRJQiA0eqXyJIlkc1y/uNhUHSpqr0A xExNm6P03M2xqSCY9WXIA8ie8eNUrSpinUIsPy8W1T522OISz4w4q0T7wEnSppxyzoMZAWstfzF6I w99fDlPg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:40364 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 1sZpoF-0006ES-28; Fri, 02 Aug 2024 11:47:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpo6-000eH7-Aa; Fri, 02 Aug 2024 11:46:46 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 04/14] net: stmmac: add infrastructure for hwifs to provide PCS MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:46 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034750_889107_5AFA2D27 X-CRM114-Status: GOOD ( 25.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow hwifs to provide a phylink_select_pcs() implementation via struct stmmac_ops, which can be used to provide a phylink PCS. Code analysis shows that when STMMAC_FLAG_HAS_INTEGRATED_PCS is set, then: stmmac_common_interrupt() stmmac_ethtool_set_link_ksettings() stmmac_ethtool_get_link_ksettings() will all ignore the presence of the PCS. The latter two will pass the ethtool commands to phylink. The former will avoid manipulating the netif carrier state behind phylink's back based on the PCS status. This flag is only set by the ethqos driver. From what I can tell, amongst the current kernel DT files that use the ethqos driver, only sa8775p-ride.dts enables ethernet, and this defines a SGMII-mode link to its PHYs without the "managed" property. Thus, phylink will be operating in MLO_AN_PHY mode, and inband mode will not be used. Therefore, it is safe to ignore the STMMAC_FLAG_HAS_INTEGRATED_PCS flag in stmmac_mac_select_pcs(). Further code analysis shows that XPCS is used by Intel for Cisco SGMII and 1000base-X modes. In this case, we do not want to provide the integrated PCS, but the XPCS. The same appears to also be true of the Lynx PCS. Therefore, it seems that the integrated PCS provided by the hwif MAC code should only be used when an external PCS is not being used, so give priority to the external PCS. Provide a phylink_pcs instance in struct mac_device_info for hwifs to use to provide their phylink PCS. Omit the non-phylink PCS code paths when a hwif provides a phylink_select_pcs() method (in other words, when they are converted to use a phylink PCS.) This provides a way to transition parts of the driver in the subsequent patches. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/common.h | 15 ++++++++++++++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 19 +++++++++++++++++-- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 10 ++++++---- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++--- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index cd36ff4da68c..9e8f1659377e 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) @@ -582,6 +582,18 @@ struct mii_regs { unsigned int clk_csr_mask; }; +struct stmmac_pcs { + struct stmmac_priv *priv; + void __iomem *pcs_base; + struct phylink_pcs pcs; +}; + +static inline struct stmmac_pcs * +phylink_pcs_to_stmmac_pcs(struct phylink_pcs *pcs) +{ + return container_of(pcs, struct stmmac_pcs, pcs); +} + struct mac_device_info { const struct stmmac_ops *mac; const struct stmmac_desc_ops *desc; @@ -591,6 +603,7 @@ struct mac_device_info { const struct stmmac_tc_ops *tc; const struct stmmac_mmc_ops *mmc; const struct stmmac_est_ops *est; + struct stmmac_pcs mac_pcs; struct dw_xpcs *xpcs; struct phylink_pcs *phylink_pcs; struct mii_regs mii; /* MII register Addresses */ diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 1711d8072cd2..06284aee4088 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 */ @@ -430,6 +438,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...) \ @@ -527,6 +539,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 fbf71d0af9bc..3c8ae3753205 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)) { u32 supported, advertising, lp_advertising; if (!priv->xstats.pcs_link) { @@ -373,7 +374,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; @@ -485,7 +487,7 @@ stmmac_get_pauseparam(struct net_device *netdev, { struct stmmac_priv *priv = netdev_priv(netdev); - if (priv->hw->pcs) { + if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) { pause->autoneg = 1; } else { phylink_ethtool_get_pauseparam(priv->phylink, pause); @@ -498,7 +500,7 @@ stmmac_set_pauseparam(struct net_device *netdev, { struct stmmac_priv *priv = netdev_priv(netdev); - if (priv->hw->pcs) { + if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) { pause->autoneg = 1; return 0; } else { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 12689774d755..a08dccad0ff2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -957,7 +957,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, return pcs; } - return NULL; + return stmmac_mac_phylink_select_pcs(priv, interface); } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, @@ -3486,7 +3486,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 */ @@ -6064,7 +6064,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 Aug 2 10:46: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: 13751442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B87DEC3DA4A for ; Fri, 2 Aug 2024 10:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AasczkNb11bsNmuV1kDQTIcXsK7ueDkdZx5V2wjlYDk=; b=vfxmgIN7udRrPzahL6u6bTtC9G PujpTzAvpH3FzGYgxI+ZfqEXFHbvJsMJi6p6IGoz4o9kL8Biq32SruAc8s8hT/xUWvUdGZZqFvHrA glWS9kCJgq2yuoo65EFennWRANG9wF3BUwI75w4vAnnlyaZafMdE63TEot8nOtO3iDMXXGSmivJ4Q u2N0GdPGDer8L8cEiQFeJDvIohWyGPI3N7LhvvLvldTuf6DEq3GowICH1I+KD6KO5yYwkdOS3MYVW k3Ok+NPQhxjUWXTFW5mJRWO9xACTv7va7Do1RDOdxupQmt+0qH3qN0ufZ2PQpM2iinGVjYia1YavY sFB8+CPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZps3-00000008YLA-0TRU; Fri, 02 Aug 2024 10:50:51 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppH-00000008XLt-34gZ for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:48:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AasczkNb11bsNmuV1kDQTIcXsK7ueDkdZx5V2wjlYDk=; b=17mmKeB+++QONTfu6Hlc3z2HQs NlWxzFj/pGibOwtctx8XPHlACMQXLSbFHlSofk9Lk1CaIRdAVMc4UUkdjjz7nrUtpubtbgeCeBWFU 9fJYEDSUn2y+MR1Pg5+hLf23wGbngcJ6RpKjOgT3dN5YenmyVeRQnW4h94dXMpYsjhlh2ecYqhtUn ZeDHtFv3oPB5YKTb0Q9Lwik3fHuELh5Im7sVPB1VWFt454v/vsttrzVDwdyZjlgrfWprlSEIaU/ry Zfch0X19gmZIoJLXUXJALj2yJR0tWzezd0urJuqfJs6m67fH23jgW8OMWKHXM+PVTiMJbXmUVhfOb R1hUXTcw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36344 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 1sZpoO-0006Eb-1V; Fri, 02 Aug 2024 11:47:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoB-000eHD-Ek; Fri, 02 Aug 2024 11:46:51 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 05/14] net: stmmac: provide core phylink PCS infrastructure MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:51 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034759_922673_7A0E8EBE X-CRM114-Status: GOOD ( 18.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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() and dwmac_ctrl_ane(). Rather than use these (which don't quite fit with phylink PCS, provide phylink PCS specific versions. Also provide an implementation to parse the RSGMII status register. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 47 +++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 50 +++++++++++++++++++ 3 files changed, 98 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..292c039c9778 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "stmmac.h" +#include "stmmac_pcs.h" + +static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral, + bool loopback) + +{ + u32 val; + + val = readl(spcs->pcs_base + GMAC_AN_CTRL(0)); + + /* Enable and restart the Auto-Negotiation */ + if (ane) + val |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + else + val &= ~GMAC_AN_CTRL_ANE; + + /* In case of MAC-2-MAC connection, block is configured to operate + * according to MAC conf register. + */ + if (srgmi_ral) + val |= GMAC_AN_CTRL_SGMRAL; + + if (loopback) + val |= GMAC_AN_CTRL_ELE; + else + val &= ~GMAC_AN_CTRL_ELE; + + writel(val, spcs->pcs_base + GMAC_AN_CTRL(0)); +} + +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 stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + + /* The RGMII interface does not have the GMAC_AN_CTRL register */ + if (phy_interface_mode_is_rgmii(spcs->priv->plat->mac_interface)) + return 0; + + __dwmac_ctrl_ane(spcs, true, spcs->priv->hw->ps, false); + + return 0; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 4a684c97dfae..f0d6442711ff 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -46,6 +46,19 @@ #define GMAC_ANE_RFE_SHIFT 12 #define GMAC_ANE_ACK BIT(14) +/* MAC specific status - for RGMII and SGMII. These appear as + * GMAC_RGSMIIIS[15:0] and GMAC_PHYIF_CONTROL_STATUS[31:16] + */ +#define GMAC_RS_STAT_LNKMOD BIT(0) +#define GMAC_RS_STAT_SPEED GENMASK(2, 1) +#define GMAC_RS_STAT_LNKSTS BIT(3) +#define GMAC_RS_STAT_JABTO BIT(4) +#define GMAC_RS_STAT_FALSECARDET BIT(5) + +#define GMAC_RS_STAT_SPEED_125 2 +#define GMAC_RS_STAT_SPEED_25 1 +#define GMAC_RS_STAT_SPEED_2_5 0 + /** * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR * @ioaddr: IO registers pointer @@ -109,4 +122,41 @@ static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, writel(value, ioaddr + GMAC_AN_CTRL(reg)); } + +static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state, + uint16_t rs_stat) +{ + unsigned int speed; + + state->link = !!(rs_stat & GMAC_RS_STAT_LNKSTS); + if (!state->link) + return false; + + speed = FIELD_GET(GMAC_RS_STAT_SPEED, rs_stat); + switch (speed) { + case GMAC_RS_STAT_SPEED_125: + state->speed = SPEED_1000; + break; + case GMAC_RS_STAT_SPEED_25: + state->speed = SPEED_100; + break; + case GMAC_RS_STAT_SPEED_2_5: + state->speed = SPEED_10; + break; + default: + state->link = false; + return false; + } + + state->duplex = rs_stat & GMAC_RS_STAT_LNKMOD ? + DUPLEX_FULL : DUPLEX_HALF; + + return true; +} + +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); + #endif /* __STMMAC_PCS_H__ */ From patchwork Fri Aug 2 10:46:56 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: 13751441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11EA9C3DA4A for ; Fri, 2 Aug 2024 10:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WrkoatYWq64VBcokQEdFjC44CkyN1bduVYDNhV5nBuE=; b=bl0OQMjcP7WZMl3Eauz/2bjiRK yRlTwk5OUYGll7MU/SvbkV4IfC1bkFxQIrJtZ4YnA2NB/dci3CKJjpWjZ7pAcnZ6VlAv9p4PHyM6S fg7LXHNtfGWAAVWIatWltgcQKIU5F71TjlgyoEVC9WyY5dmZFSgw+pFmMFhR5jQ5x8mokopVYZYYG IYrUNdvC5chNrDrzi0ZohtlX3HOylfdcw2JU8qM0y4Mtrmf4KDBXhoGqKqcfpEHsrhUk9w0N/ndgX vTwAVv/5SFKQ1hN7xmefLwZj8vPF50aICTY3gGSC5pLhM3SLCg/buMPHgyFCfon8VYvZ3m4U6B2f3 t2iXIjuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZprX-00000008YCd-4ADN; Fri, 02 Aug 2024 10:50:19 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppH-00000008XLp-0M4f for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:48:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WrkoatYWq64VBcokQEdFjC44CkyN1bduVYDNhV5nBuE=; b=DyTB/i6j3q8i9hD8fTN6nSJ/iK QKQp5gq4FVVMY0daYduRtolyYbkPC9qGO8xD5ORzHb0Eoi/xroPYKJvyB5WnM9KS+S/q5nhhBUeuM L5RyiNraz40bwus65p4uSWX7tY83HfREsd6+egP6V3xiYVQh+o4eap7FSdtb4dBa5eyKOQZaYNYLo JtbBvPYRVFUpv1JgCRNuTn31X4G6Sd2i4220FOm4N8kIJFxG62ExlQuo1ohdKvM9v9BLJ05U6mRgA dz4+aBfhC2pP8fEgRd5YHrSojrPJW4twsYegolX8TFCCORvQlD19bVQhrb6EQYXorGRWoVBxxObd6 H4d+tBjg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36356 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 1sZpoO-0006Ee-0G; Fri, 02 Aug 2024 11:47:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoG-000eHH-Ic; Fri, 02 Aug 2024 11:46:56 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 06/14] net: stmmac: dwmac1000: convert sgmii/rgmii "pcs" to phylink MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:46:56 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034759_190684_24B811A2 X-CRM114-Status: GOOD ( 17.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. We do not provide a validate method to enforce auto-negotiation, because the ethtool autonegotiation is a property of the media facing link, not of the internal network device links. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 73 ++++++++++--------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index 4296ddda8aaa..50a73bf1c6f5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -86,19 +86,8 @@ enum power_event { #define GMAC_RGSMIIIS 0x000000d8 /* RGMII/SMII status */ /* SGMII/RGMII status register */ -#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_RS_STAT GENMASK(15, 0) #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 8af51ddef3e8..66c17be79dec 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.pcs, false); + x->irq_rgmii_n++; + } return ret; } @@ -404,6 +376,31 @@ static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } +static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) +{ + struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + u32 status = readl(spcs->priv->ioaddr + GMAC_RGSMIIIS); + + dwmac_rs_decode_stat(state, FIELD_GET(GMAC_RGSMIIIS_RS_STAT, status)); +} + +static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { + .pcs_config = dwmac_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.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) @@ -494,6 +491,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, @@ -543,5 +541,10 @@ int dwmac1000_setup(struct stmmac_priv *priv) mac->mii.clk_csr_shift = 2; mac->mii.clk_csr_mask = GENMASK(5, 2); + mac->mac_pcs.priv = priv; + mac->mac_pcs.pcs_base = priv->ioaddr + GMAC_PCS_BASE; + mac->mac_pcs.pcs.ops = &dwmac1000_mii_pcs_ops; + mac->mac_pcs.pcs.neg_mode = true; + return 0; } From patchwork Fri Aug 2 10:47:01 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: 13751440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04EF4C3DA49 for ; Fri, 2 Aug 2024 10:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PBu+kBwVrpwu0aLOAbJWnE+yeChvJS6HtcbuvsSx73w=; b=jyXdGMGY61OXzT+yTSEy3YPOaG Lj0UebEanU9Sn0pwUTqlbvdq0rP1cwt1pdr5UbVX7/CNh92twmKpMSmWfEQdYs7vjqofH70B27SbT V1LFevHWufmZaYRfOQF9EKK1oEg08+Ykl8jrDDtqY0l3rsAQv/YZEQGyDed+sTsw1XiWhlZ0YRWfv uv1i7kvcClyOySoLtfxYpQuSDXLRZjnafL4SsLyuTsKmpg7zftZmtrqPOQr0ArDbpr4kQdPtvuQHv Vlmfn53R7TviJpU8TA//C5tT2a5cHv7nq3KGtDKFErgcNhbHSPv+rkuT42+6HS7HL8vo5qukZ3k43 XVmLHBLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpr1-00000008Y2O-3zre; Fri, 02 Aug 2024 10:49:47 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppB-00000008XJW-2Rey for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:47:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PBu+kBwVrpwu0aLOAbJWnE+yeChvJS6HtcbuvsSx73w=; b=Bi6peKW9a4oGw1dQ3HqExAWnsE HFTrKWBfbSQy+coYNtPtReDf31gPe4smTGUYtz82zptWyXgb9b3vDPIxwiLaGGDdWfzBumrgJB2yd DwcW2w740SIO1nZ2pCuDVTUt8aPDhmX/hPkV4e45gUKjLfWHksT8vXY0AWr5zHewkhDjthCbbr/Qe DQW6LJLOwfvji9WMyqN9FWdEHBspGm3Jm47jiUFZRcvi6QQVZvj7OPrXFrQIWM4tvzRneLF78ynkO ovemk8kPziZva2zmKuVf2GvUZ+w6aK72eSoe9xRkhgbi/8/nfAmVx7pIPKtnf16PetDGKqOQTfczH tb/bgzZg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36366 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 1sZpoO-0006Eh-0N; Fri, 02 Aug 2024 11:47:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoL-000eHN-OZ; Fri, 02 Aug 2024 11:47:01 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 07/14] net: stmmac: dwmac1000: move PCS interrupt control MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:01 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034753_633626_25D509A9 X-CRM114-Status: GOOD ( 11.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Control the PCS interrupt mask from phylink's pcs_enable() and pcs_disable() methods rather than relying on driver variables. This assumes that GMAC_INT_DISABLE_RGMII, GMAC_INT_DISABLE_PCSLINK and GMAC_INT_DISABLE_PCSAN are all relevant to the PCS. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 66c17be79dec..05b2df08cb0f 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 */ @@ -376,6 +371,30 @@ static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } +static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) +{ + struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + void __iomem *ioaddr = spcs->priv->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 stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + void __iomem *ioaddr = spcs->priv->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_mii_pcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { @@ -386,6 +405,8 @@ static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, } static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { + .pcs_enable = dwmac1000_mii_pcs_enable, + .pcs_disable = dwmac1000_mii_pcs_disable, .pcs_config = dwmac_pcs_config, .pcs_get_state = dwmac1000_mii_pcs_get_state, }; From patchwork Fri Aug 2 10:47:06 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: 13751443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73764C3DA4A for ; Fri, 2 Aug 2024 10:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4++u+M2gUsWJ0uVVvTAggA9qzMZa6bmuLtZOnE5wpxw=; b=ys4UHpfPk2vlEA3ajfGPpseXLX eFY8LX95YPc+buM2GKw0PWP+UrGyZcSd6VzrG5MOTN8Cyc+QN6/3gguC5kbf5AVjKK4BLiVyChBxu 5nYtZuFV3pnENCQdvxS76ndiX/iVlS51ZRVo4FaSEtBJjnnWThr01bsR4Bj3XNdXc4QaXk/R+w3Ab G4cS11JU+RZrLQBCuYMMp3AndcEJUcHW9KV5nA6gK4iiROe80JmvKKARsjsUfNrOhPbvIsEH5wYe1 aVSOw2wYpVw/UCLwvKRI+DqvRzw6azQCEoIKscWoNYGqHL3mthJRywavKfCtUw8gldw0rB2nMHuiO ACJq1ooQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpsU-00000008YQd-0CFd; Fri, 02 Aug 2024 10:51:18 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppH-00000008XLe-3nqx for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:48:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4++u+M2gUsWJ0uVVvTAggA9qzMZa6bmuLtZOnE5wpxw=; b=DcJMFv5DuAQmmU/DBxlbCFzpyN LzF/ThYcFNtdSVoSbs51EBxlBt3SUPSYarYUmuXoRCz8jz3wzN1l0GyF+qC7Zdtx0XbdbR/pDj7Zm vNUWaDuw+tdqFsk2wH2pah2CU33nE/XcR0OPpd/S/AtCNIueOjtvXUrzYIXJhaCzFbN5G/PStMHFw TM49wXLBD2JlpOkGgZS00tgcGkYeo+L/6H8JsyFXr5/7EedHJ/FI0mz0N3jsitkMf6czIuQ0eKPtl X3DsU9bsRvaB6cbaPn29jzxUvC2EVA3dfG0AGnJSHEQ28qrHFseg4BiOvbzJLE+mnHerJg0P/+Tij Y4TFJmGg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36368 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 1sZpoP-0006El-0l; Fri, 02 Aug 2024 11:47:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoQ-000eHS-TH; Fri, 02 Aug 2024 11:47:06 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 08/14] net: stmmac: dwmac4: convert sgmii/rgmii "pcs" to phylink MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:06 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034800_175256_7B2A575F X-CRM114-Status: GOOD ( 16.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert dwmac4 sgmii/rgmii "pcs" implementation to use a phylink_pcs so we can eventually get rid of the exceptional paths that conflict with phylink. We do not provide a validate method to enforce auto-negotiation, because the ethtool autonegotiation is a property of the media facing link, not of the internal network device links. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 13 +---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 58 +++++++++++-------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index d3c5306f1c41..c6a254ecfbb8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -567,18 +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_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 +#define GMAC_PHYIF_CTRLSTATUS_RS_STAT GENMASK(31, 16) 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 d919fc07c8f1..ec8e94ddf948 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,37 +759,32 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } -/* RGMII or SMII interface */ -static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x) +static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) { + struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); u32 status; - status = readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); - x->irq_rgmii_n++; + status = readl(spcs->priv->ioaddr + GMAC_PHYIF_CONTROL_STATUS); - /* Check the link status */ - if (status & GMAC_PHYIF_CTRLSTATUS_LNKSTS) { - int speed_value; + dwmac_rs_decode_stat(state, FIELD_GET(GMAC_PHYIF_CTRLSTATUS_RS_STAT, + status)); +} - x->pcs_link = 1; +static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { + .pcs_config = dwmac_pcs_config, + .pcs_get_state = dwmac4_mii_pcs_get_state, +}; - 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; - 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.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, @@ -862,8 +858,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.pcs, false); + x->irq_rgmii_n++; + } return ret; } @@ -1181,6 +1181,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, @@ -1224,6 +1225,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, @@ -1271,6 +1273,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, @@ -1383,5 +1386,10 @@ 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.priv = priv; + mac->mac_pcs.pcs_base = priv->ioaddr + GMAC_PCS_BASE; + mac->mac_pcs.pcs.ops = &dwmac4_mii_pcs_ops; + mac->mac_pcs.pcs.neg_mode = true; + return 0; } From patchwork Fri Aug 2 10:47:12 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: 13751445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE1D8C3DA4A for ; Fri, 2 Aug 2024 10:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C9f3sXn5CIBBTPqFMcdW/Yt6tX1XEnjE29jmPpTSSas=; b=JGkjUS2JHMLdjgT8uyOyyBbbYk MrUUxnRQ0GzbXbLNO+pksfbhXUPe07sBeY0OFCq4KuvEJ3uURCY6jWAnUCmP8/NiTyKjINu4cd+vt YPIXjeDZF9/YK0ea8nN2p+LwM4VCJGZodHqKxgyPKzZVgMa6Q8YdQ6usESs56NEo2PorHu7Q3b8do tqIXgYjsjDRjGEes0TwEZtm7fCXxtZPEQU/KPjw6hAZUme1EdVJ78d4Cxo9VAJfOPAX4UEcrHPboI U6K0i3TXMKunMxSXTYGPdINNdePlcN3foOZNFAHEDnZOX8khKBgkpJnNYYBA3VknmopUibYU2y/J4 yeVv5kbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpsz-00000008YbF-3hp7; Fri, 02 Aug 2024 10:51:50 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZppK-00000008XMf-0L02 for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:48:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C9f3sXn5CIBBTPqFMcdW/Yt6tX1XEnjE29jmPpTSSas=; b=YA+HABMmrD1CP6n7MpAGJNEF2W 8BpQW2jlqXHH4Y8kj0gXiXH7YELvpvvtd+u5DTKHjTDoIw5J6s4SJvcWL6WtYnWzpRv0sMZr6s2MQ 0tJzH+nOxbp4d5vWfOKWAIKAdWylM+ONzeAoi8jD0Bhm2VkyZ6q2Rof7y9nQ9HWiZH9yDpKi/BGV9 P/ZHh0PgKhGL1xkmSeD6QW9MKmfEL+wB97S9uYSj8UVKIq70HqplQDMoqRP1+FrpYkEWQAQ8swHDI SF9NAqqJkIsVP7HapXELkl9VTe6o0xG5XT24axc6DtTR2NySKiWb34HoHLp21EbyHoFodEG8l+i5z bJx/HR7Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48622 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 1sZpoY-0006F1-0F; Fri, 02 Aug 2024 11:47:14 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoW-000eHZ-0d; Fri, 02 Aug 2024 11:47:12 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 09/14] net: stmmac: dwmac4: move PCS interrupt control MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:12 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_034802_180399_49DF7E54 X-CRM114-Status: GOOD ( 11.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Control the PCS interrupt mask from the phylink pcs_enable() and pcs_disable() methods rather than relying on driver variables. This assumes that GMAC_INT_RGSMIIS, GMAC_INT_PCS_LINK and GMAC_INT_PCS_ANE are all relevant to the PCS. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index ec8e94ddf948..0d261709bee6 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; @@ -759,6 +756,30 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); } +static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) +{ + struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + void __iomem *ioaddr = spcs->priv->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 stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); + void __iomem *ioaddr = spcs->priv->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_mii_pcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { @@ -772,11 +793,12 @@ static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, } static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { + .pcs_enable = dwmac4_mii_pcs_enable, + .pcs_disable = dwmac4_mii_pcs_disable, .pcs_config = dwmac_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) { From patchwork Fri Aug 2 10:47:17 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: 13751466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37D62C3DA4A for ; Fri, 2 Aug 2024 10:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fPCM+FUmWtfT/a/xJLEhtPgnqWcJcdaOoc4ivCX+/S0=; b=tV8cNzmk/tS4KVrvBGIaO5nPgX x7C0W/kXO3LJWltN4XOf/+4JZeHDGfWLv+ukl5jxnDd1YDo9dDVy0UbjIIlsWTZwaNEeqxclqTwMI 6KdDw7oILfNd3cd3OaDOXafIY9FMje44TAz2USH3k3fLMvhmHTo1CGUz+/mGx1dUtXudfFNvtevGi mtX3LmANudJ9/XHhRkKruj+4LbkKLB0/q8A93f2kAP19+NjZ0BJJmY4BzUc11SzGSuwhV3r/O3UOu 8ocI4HT4xrBzA53Q1VtxYuD3fyiBpCzD6vsXv3wRIzhcA8dPNQR5TEcFI47xbNaj/ZNbZ+/xDfR5C vI+Kr88g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpzw-00000008ayF-2E8N; Fri, 02 Aug 2024 10:59:00 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpy4-00000008aS3-2zGw for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:57:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fPCM+FUmWtfT/a/xJLEhtPgnqWcJcdaOoc4ivCX+/S0=; b=tYky5PA18t33CscmHoO/Ekl1oh NiTiAun3mT7tfZ47r8asCc2IhOQONj9l5MfAfHh0Zi+9p6VsLiq1Ttk0E/FJBtuLK5W2vJabWsnjk 9GEKUkWPjv792/d63e6PBa3qRW/vzmvw4msHMWal7DeRtJ5Yqk4/DxwgdCqHZCbUzBygpLOlb8HsR xCZlPhz0CDPvH2nXk6MnJKjcdVCMdhMtoVSiDvN48IWOBHV0eusokW7ak6luaf/Nj8YeaULg5tpK8 xCAqdL6TjKr93fyutpwCNMgRppEmVuBYXpT3SdniVUV0JXFmi++N1j5tmElh7buHJzfAvVY6GAuAw LmMoxTyg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48636 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 1sZpoi-0006FG-1U; Fri, 02 Aug 2024 11:47:25 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpob-000eHh-4p; Fri, 02 Aug 2024 11:47:17 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 10/14] net: stmmac: move dwmac_ctrl_ane() into stmmac_pcs.c MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:17 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_035704_913888_9200EBDA X-CRM114-Status: GOOD ( 16.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move dwmac_ctrl_ane() into stmmac_pcs.c, changing its arguments to take the stmmac_priv structure. Update it to use the previously provided __dwmac_ctrl_ane() function, which makes use of the stmmac_pcs struct and thus does not require passing the PCS base address offset. This removes the core-specific functions, instead pointing the method at the generic method in stmmac_pcs.c. Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Halaney --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 8 +--- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 ++---- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 16 ++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 37 ++----------------- 4 files changed, 23 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 05b2df08cb0f..d2defa2e4996 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -365,12 +365,6 @@ 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(struct stmmac_priv *priv, bool ane, - bool srgmi_ral, bool loopback) -{ - dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); -} - static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); @@ -527,7 +521,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_ctrl_ane = dwmac1000_ctrl_ane, + .pcs_ctrl_ane = dwmac_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 0d261709bee6..2f02bb47c952 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -750,12 +750,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, - bool loopback) -{ - dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback); -} - static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); @@ -1227,7 +1221,7 @@ 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, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1271,7 +1265,7 @@ 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, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, @@ -1319,7 +1313,7 @@ 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, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 292c039c9778..e435facc9849 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -30,6 +30,22 @@ static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral, writel(val, spcs->pcs_base + GMAC_AN_CTRL(0)); } +/** + * dwmac_ctrl_ane - To program the AN Control Register. + * @priv: pointer to &struct stmmac_priv + * @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. + */ +void dwmac_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, + bool loopback) +{ + __dwmac_ctrl_ane(&priv->hw->mac_pcs, ane, srgmi_ral, loopback); +} + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index f0d6442711ff..083128e0013c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -89,40 +89,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. - * 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 *ioaddr, u32 reg, bool ane, - bool srgmi_ral, bool loopback) -{ - u32 value = readl(ioaddr + GMAC_AN_CTRL(reg)); - - /* Enable and restart the Auto-Negotiation */ - if (ane) - value |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; - else - value &= ~GMAC_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; - - if (loopback) - value |= GMAC_AN_CTRL_ELE; - - writel(value, ioaddr + GMAC_AN_CTRL(reg)); -} - static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state, uint16_t rs_stat) { @@ -154,6 +120,9 @@ static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state, return true; } +void dwmac_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral, + bool loopback); + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising, From patchwork Fri Aug 2 10:47:22 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: 13751462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12B19C3DA49 for ; Fri, 2 Aug 2024 10:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BCL9SgQ/g7nSh4Zd8wOmWQ96bng4Q8TSEK3rpU47Mi0=; b=z5Ar0rI70t6OEWibUT9kO60euo GT9BM596LjEeTj6Dhj5cD5tCodcxYS8q+SWJxTtG/+pPdP35vPvE3hFmfhuZI+5QWBBiPBJPRmJgA F2Z/pQ7oD4XUr+vOY2xNMnR6ASmCwjPC0y7JEPDguKgSdrzrL0rhjTgbrV2XfT01iiToZr/t8+Y8g n0TfBOjwFygA8H20vS5V0BSFlzHbDdybAyEuYg4dW+XDlk/FNDIgdL1KUn1vR4iG7VEZa5+6ohv0z aayWcqvUjgjrP/yHkC+4tq/khDpLZChNuENfnzJNQBSO8r/Hcbj7A4JEolCDgIhFM6FPhd3K3rQFg uj0xfCjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpy4-00000008aSH-3Onr; Fri, 02 Aug 2024 10:57:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpxW-00000008aDu-0MCF for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:56:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BCL9SgQ/g7nSh4Zd8wOmWQ96bng4Q8TSEK3rpU47Mi0=; b=DxKFsnXp8sGTTutqn2Bi5W0BRf cbvSDj3tM0SE4DLz4cnIS1t6tYwzG6HJuOKHCZ0w9lmJU5To3WszLye/J1MexcXczZSh7Ts83QBC7 XvNbWdU2FGf6Gmh7fppZuSwiBJzlXI9p43UETfEge0wsDtNcI3JxbFLpXqF1ZfU+goCI8C6v9rbCd oNJHmT/GjkogfPtpPJPcZNOxi9CzJ6mCRgxSCMub8M+57QDVCksLwKqlRjqEqraepaQZeohS9HI9M sMAKxSurY5vTE5xZRXr/rI6RH/pbKq0dUUppi5jFQw42gdvqlTwj8SlpLKk5+ebIbwH+JINKkRCJW 4hWCcdrA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59784 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 1sZpom-0006Fd-1u; Fri, 02 Aug 2024 11:47:28 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpog-000eHn-8r; Fri, 02 Aug 2024 11:47:22 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 11/14] net: stmmac: pass stmmac_pcs into dwmac_pcs_isr() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:22 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_035630_130877_3FDDA4A0 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Pass the stmmac_pcs into dwmac_pcs_isr() so that we have the base address of the PCS block available. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index d2defa2e4996..2bed04403baa 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->mac_pcs, intr_status, x); if (intr_status & PCS_RGSMIIIS_IRQ) { /* TODO Dummy-read to clear the IRQ status */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 2f02bb47c952..12b7b93ce71e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -873,7 +873,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->mac_pcs, 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/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 083128e0013c..c73a08dab7b2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -61,18 +61,18 @@ /** * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR - * @ioaddr: IO registers pointer + * @spcs: pointer to &struct stmmac_pcs * @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(struct stmmac_pcs *spcs, unsigned int intr_status, struct stmmac_extra_stats *x) { - u32 val = readl(ioaddr + GMAC_AN_STATUS(reg)); + u32 val = readl(spcs->pcs_base + GMAC_AN_STATUS(0)); if (intr_status & PCS_ANE_IRQ) { x->irq_pcs_ane_n++; From patchwork Fri Aug 2 10:47:27 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: 13751463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 992F1C3DA49 for ; Fri, 2 Aug 2024 10:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uQGMZ5XIRT1DXXPthPdl6hu8lVDGel4TJqDFGYE469k=; b=aOdGW/Sb0zDWV4tIQ6omOvetyA yxn2l1Q49bqS21xakc3QIAF8ObNoIdnTA0KclMobwkEjyJVfLab9jUTXu57agzhvED+yqwmo56I2y H6sUJC6D9qHrOIUjEvm0EYBmdjrcS+W+vGU3ha0HF9jtoDHaAa4SLnRflKHKxvnwDxXEcuuHGVC5V vrVo3BPOc/xOj6xNSVas8ZTSbhC44eDYt4eFZCczzGFCwoBxABTZO/+wH7avDIVH1rcUVY0mChtiI ih+sbZIUw4c/F8uX3l8NblAQXmc/fblnmClMkneA2wSrx7sCZ0pKepQWiyopyjNLcgJhHAuxytbsF LbmBqTTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpyZ-00000008ad9-3YzT; Fri, 02 Aug 2024 10:57:35 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpxc-00000008aGY-0O66 for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:56:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uQGMZ5XIRT1DXXPthPdl6hu8lVDGel4TJqDFGYE469k=; b=xv81wunMVkAZrvkXAQKllU4HCR mytnXa4aLSkhFKRJSWLvty1MKb0K6CipZ6r+/GigReiQu/USZTPT+ySJoutvzlJ7rwI13yuB+35SZ 1lmaLUv7KleBxjeMXY3T4rbzi+aXX1xDDQL/dOkWVQb9ECcGCkTc0f70jQ9l6AWz32rL77reXR7yo HMAykra+gLXE9VWOSafmHnv5tIwEUbBpD5m5iSTkS2SnNo3IYd1CT86WieEzp7B56b/fCymbMGc9m 57fD59ttmbxsxCQPktc4KnMTtEMTn8NglwRsKpZ8ZYTeXz/7RZYcFxRXfImNWApJ58Dh3qJh4RIOe 7PD4r6TQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57288 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 1sZpon-0006Fl-1q; Fri, 02 Aug 2024 11:47:30 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpol-000eHs-Cn; Fri, 02 Aug 2024 11:47:27 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 12/14] net: stmmac: rename PCS registers MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:27 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_035636_324689_0453EEA8 X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename the PCS registers from GMAC_xxx to STMMAC_PCS_xxx to make it clear that they are for the PCS. Avoid using PCS_ as this is too generic and may (eventually) clash with definitions elsewhere in the kernel. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 16 +++--- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 52 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index e435facc9849..7960bfd83b74 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -8,26 +8,26 @@ static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral, { u32 val; - val = readl(spcs->pcs_base + GMAC_AN_CTRL(0)); + val = readl(spcs->pcs_base + STMMAC_PCS_AN_CTRL); /* Enable and restart the Auto-Negotiation */ if (ane) - val |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + val |= STMMAC_PCS_AN_CTRL_ANE | STMMAC_PCS_AN_CTRL_RAN; else - val &= ~GMAC_AN_CTRL_ANE; + val &= ~STMMAC_PCS_AN_CTRL_ANE; /* In case of MAC-2-MAC connection, block is configured to operate * according to MAC conf register. */ if (srgmi_ral) - val |= GMAC_AN_CTRL_SGMRAL; + val |= STMMAC_PCS_AN_CTRL_SGMRAL; if (loopback) - val |= GMAC_AN_CTRL_ELE; + val |= STMMAC_PCS_AN_CTRL_ELE; else - val &= ~GMAC_AN_CTRL_ELE; + val &= ~STMMAC_PCS_AN_CTRL_ELE; - writel(val, spcs->pcs_base + GMAC_AN_CTRL(0)); + writel(val, spcs->pcs_base + STMMAC_PCS_AN_CTRL); } /** @@ -53,7 +53,7 @@ int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); - /* The RGMII interface does not have the GMAC_AN_CTRL register */ + /* The RGMII interface does not have the STMMAC_PCS_AN_CTRL register */ if (phy_interface_mode_is_rgmii(spcs->priv->plat->mac_interface)) return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index c73a08dab7b2..1827c7e64dba 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -14,37 +14,37 @@ #include "common.h" /* 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 STMMAC_PCS_AN_CTRL 0x00 /* AN control */ +#define STMMAC_PCS_AN_STATUS 0x04 /* AN status */ /* ADV, LPA and EXP are only available for the TBI and RTBI interfaces */ -#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 STMMAC_PCS_ANE_ADV 0x08 /* ANE Advertisement */ +#define STMMAC_PCS_ANE_LPA 0x0c /* ANE link partener ability */ +#define STMMAC_PCS_ANE_EXP 0x10 /* ANE expansion */ +#define STMMAC_PCS_TBI 0x14 /* TBI extend 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 STMMAC_PCS_AN_CTRL_RAN BIT(9) /* Restart Auto-Negotiation */ +#define STMMAC_PCS_AN_CTRL_ANE BIT(12) /* Auto-Negotiation Enable */ +#define STMMAC_PCS_AN_CTRL_ELE BIT(14) /* External Loopback Enable */ +#define STMMAC_PCS_AN_CTRL_ECD BIT(16) /* Enable Comma Detect */ +#define STMMAC_PCS_AN_CTRL_LR BIT(17) /* Lock to Reference */ +#define STMMAC_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 STMMAC_PCS_AN_STATUS_LS BIT(2) /* Link Status 0:down 1:up */ +#define STMMAC_PCS_AN_STATUS_ANA BIT(3) /* Auto-Negotiation Ability */ +#define STMMAC_PCS_AN_STATUS_ANC BIT(5) /* Auto-Negotiation Complete */ +#define STMMAC_PCS_AN_STATUS_ES BIT(8) /* Extended Status */ /* 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 STMMAC_PCS_ANE_FD BIT(5) +#define STMMAC_PCS_ANE_HD BIT(6) +#define STMMAC_PCS_ANE_PSE GENMASK(8, 7) +#define STMMAC_PCS_ANE_PSE_SHIFT 7 +#define STMMAC_PCS_ANE_RFE GENMASK(13, 12) +#define STMMAC_PCS_ANE_RFE_SHIFT 12 +#define STMMAC_PCS_ANE_ACK BIT(14) /* MAC specific status - for RGMII and SGMII. These appear as * GMAC_RGSMIIIS[15:0] and GMAC_PHYIF_CONTROL_STATUS[31:16] @@ -72,17 +72,17 @@ static inline void dwmac_pcs_isr(struct stmmac_pcs *spcs, unsigned int intr_status, struct stmmac_extra_stats *x) { - u32 val = readl(spcs->pcs_base + GMAC_AN_STATUS(0)); + u32 val = readl(spcs->pcs_base + STMMAC_PCS_AN_STATUS); if (intr_status & PCS_ANE_IRQ) { x->irq_pcs_ane_n++; - if (val & GMAC_AN_STATUS_ANC) + if (val & STMMAC_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 & STMMAC_PCS_AN_STATUS_LS) pr_info("stmmac_pcs: Link Up\n"); else pr_info("stmmac_pcs: Link Down\n"); From patchwork Fri Aug 2 10:47:32 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: 13751464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 710D0C3DA49 for ; Fri, 2 Aug 2024 10:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jIviv6KDjZ9/e4h50twL5vRZAbpJUeov/O77JpjwYYM=; b=Jm0amzBszN31g5FkPo5woeBHz+ X2Gd7nhzxj0KSRBAeFaziBIWYJZrjZ+HlUHm0/hk2keDUFbIdf0NuFlox411i6ZYNVkbCmm7mW3py dFfYsyvERNwDWoba///JNT674t1yfxEhBgeB9PGJ1Sxx1JiZTTWaZmFfQMJ1tT8Hr6gjAtFxMvY4Q 2KQRfB0zOJAas2UxNt/Fovp0PNX6X2CHKhoMzoxLN6I2LYWL9v15fY/K5NE+ljffyFZ9VSbiPWvff saQD4kiSuv9POwnbGlx9hlY1ZxJ+T4Vg5cnWoW+TGJ1sYJ+LASJOIG3XJ9Qcqwt/+zcUklCvJSwYY GhROHXhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpz1-00000008aiP-2t2T; Fri, 02 Aug 2024 10:58:03 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpxm-00000008aJN-2gTW for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:56:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jIviv6KDjZ9/e4h50twL5vRZAbpJUeov/O77JpjwYYM=; b=xAXqjJe8Tn/sEqXkWHJ0xL8MT3 gnCOl4/rIhMnc7O9in1o/DGjnSumBvRkoaanQJzyPv4D+slS3My8zo3mAU2+u+vaJZCKaOCh+I3QC eLnmSnn7LUYR+c95ue68/zOlzx8+85Rx/fbqK4O52Ko2v3IlXlavwZRxkQ2n2n8j1Q3TCnBcHVHwk TJwWHK1a6IetnqkY+QHEk5FuToseNSuVC79O91xBVgJl1BATWMaz884IuxjyIveCq/cmtHlYSYKwF e1eczWTiPzhnDW4lSVPGVLvwjm0zphssWVFn/93q/OOsUgKybGED3J+3prgu1bYhdeIfIkXLp8j+q PVmJ0swA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57294 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 1sZpoo-0006Ft-2k; Fri, 02 Aug 2024 11:47:31 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpoq-000eHy-GR; Fri, 02 Aug 2024 11:47:32 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 13/14] net: stmmac: remove obsolete pcs methods and associated code MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:32 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_035646_846638_42BD3770 X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pcs_ctrl_ane() method is 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 | 10 --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 70 +------------------ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ---- 4 files changed, 2 insertions(+), 95 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 9e8f1659377e..5a49d8db30fe 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; @@ -394,13 +391,6 @@ enum request_irq_err { #define CORE_IRQ_MTL_RX_OVERFLOW BIT(8) /* Physical Coding Sublayer */ -struct rgmii_adv { - unsigned int pause; - unsigned int duplex; - unsigned int lp_pause; - unsigned int lp_duplex; -}; - #define STMMAC_PCS_PAUSE 1 #define STMMAC_PCS_ASYM_PAUSE 2 diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 06284aee4088..3553e8a767cb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -303,7 +303,6 @@ struct stmmac_dma_ops { struct mac_device_info; struct net_device; -struct rgmii_adv; struct stmmac_tc_entry; struct stmmac_pps_cfg; struct stmmac_rss; @@ -539,9 +538,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 3c8ae3753205..799af80024d2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -321,48 +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)) { - 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; - - /* 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); - - /* Reg49[3] always set because ANE is always supported */ - cmd->base.autoneg = ADVERTISED_Autoneg; - supported |= SUPPORTED_Autoneg; - advertising |= ADVERTISED_Autoneg; - lp_advertising |= ADVERTISED_Autoneg; - - 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); } @@ -372,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); } @@ -487,11 +430,7 @@ stmmac_get_pauseparam(struct net_device *netdev, { struct stmmac_priv *priv = netdev_priv(netdev); - if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) { - pause->autoneg = 1; - } else { - phylink_ethtool_get_pauseparam(priv->phylink, pause); - } + phylink_ethtool_get_pauseparam(priv->phylink, pause); } static int @@ -500,12 +439,7 @@ stmmac_set_pauseparam(struct net_device *netdev, { struct stmmac_priv *priv = netdev_priv(netdev); - if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs(priv)) { - pause->autoneg = 1; - 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 a08dccad0ff2..3e43f2d6d49f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3486,9 +3486,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); @@ -6062,16 +6059,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); } } From patchwork Fri Aug 2 10:47:37 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: 13751465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1A2CC3DA4A for ; Fri, 2 Aug 2024 10:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2bZWIDKO7QK63SdQEWdaWdYkEx8EK7NXAOA4z7KnCes=; b=yDCur4fK8NcGxPfRIAEpON64Nr qCM09MG/Tc2fTAprwKpqKAFtxlBrFBvthkPA1aYSZKPX+6dEx3dlsqva+Zc91SKG+cFrGOE633y4Q Hoicz8vFd8OfTssLurvPrlccNEf3NfGJD+J8CMwDL8d7BrgLt2J7Pl8txp2BjC9vuXYQG8MUpUffe 6xUx2tlP4urBcq8aTNfl8j12o7U0tG3H3Ujcyo02R4nnDtBQv7YpVUXaqtpIMV9/uOdVCWfNarWyk gY/yPtjvezESCfX80zfeQqgz+GBFcIsXfgCVIJWXZkgIaCGQcKP3IHnqJkRPLVNnC/8et1eMW1gWB MBWA/rlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpzU-00000008apB-0K6A; Fri, 02 Aug 2024 10:58:32 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZpxq-00000008aL1-3K5F for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 10:56:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2bZWIDKO7QK63SdQEWdaWdYkEx8EK7NXAOA4z7KnCes=; b=DtmHklPdtrhWJGHoRM2rYpDpWc o3pZhqXOfXPwc2mgQ+g9tNH28IcRUfukvqDbvc3JG8OPxrXQ4uAusoGLDNRNuF2xzhzn46mWlkT9v vzAO4K8JRfo2xQ3YEQjakvFUUTSTkgFbq+OgdXsPyg/gn/RB8Oof2ZeD4RrQ+ST4mb6GeETnK+8I+ 3V0GpKr0t2MxgXEwhpX7Z2JFcztqbJtWeZokbG5d70Z7PM/Klovy6dFpOJjVnCjgbiJF39AEXOfsJ 7c7PGXbR+2a9GLerSZJq+ho6X2nqWnQps9M0o1ig9lEIGhEYiSgUNX/OPwhrAgV4uXcoJJTQvP5bc gdUlgoQQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57304 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 1sZpox-0006GF-2y; Fri, 02 Aug 2024 11:47:41 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sZpov-000eI5-KP; Fri, 02 Aug 2024 11:47:37 +0100 In-Reply-To: References: From: Russell King (Oracle) To: Serge Semin Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Halaney , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Vinod Koul Subject: [PATCH net-next 14/14] net: stmmac: Activate Inband/PCS flag based on the selected iface MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Aug 2024 11:47:37 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_035650_859632_EA20033F X-CRM114-Status: GOOD ( 16.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 3e43f2d6d49f..a9b5e2a34b10 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1133,18 +1133,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; } /**