From patchwork Thu Aug 24 13:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13364182 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 02558C7EE43 for ; Thu, 24 Aug 2023 13:39: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oCPyQfXLVa8faP3Vl1/mf27WhZb3eM7RSj2QSx2lvAM=; b=EzZyukR6RUCjhZ LloaaOUex5ngg7zkGNpDSOPN59c4fJoD1GZQA5fIaVklQPS996YabF667177os5Q64NG04her6E7W orjJT3PaCBMqytVXlb8Hvt1fQeHW7pUNBpV8ec1OZvKX4FeY8rwD4Oy6tPzRbCgznQTzhvzzKyba1 e/e/oZstuKVGpOmGVH8yFDc4wgrH/TJvIDBGxNk8LaUchJro0O+M+oQZ0Pcqxmx84Nbe6imWx9tvP NeVFtSI/SJgYe+NMYmFfXzdbJZp83WlKABx8HHXclVSRwDr2lD2eflBfZVnrovvrrnXdr8UA8mhgw CE8d/y3OKz9tTD98Gmrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZAXg-0039uI-2J; Thu, 24 Aug 2023 13:38:32 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZAXU-0039pF-0K for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2023 13:38:22 +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=fL2vmU0lJyEilSH6H6zvhSQ3kxhQLqqMcqHG138QaUM=; b=v048nZiNmFsgapvw8SNn1zpX0p YWAbOIBRp6gG7xg3O96UaGgdLNwRwAMVIogELoM8iwKRPERMwmAGf5OgN/4AEzmp2O63wLVjWhGbx mKTMJwpHrZ8IbXJ8Lt+TCUx8mqRyUWGecy7iZG2uriugF/BqNUCle4RkvoR7dKqwHx6Y27DJibR12 tDs/nLXX3J3Tixcw1x5plCjJFJL9VXzZU+LeXZ7ddqYj5NnDUjXitdoHHAWpeKqa9u3BT9V0rosNG /2RgAy7Si4n8BU8aNwXo1bArrI4yn3GfiaKjbdGUXCw1/g+l+uIrV+Tmpt+cDbMBaLjZCKD9P4Ud2 IeISrkmw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:54822 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 1qZAXN-0004D7-2k; Thu, 24 Aug 2023 14:38:13 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qZAXO-005pU7-61; Thu, 24 Aug 2023 14:38:14 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Alexandre Torgue , Jose Abreu Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Feiyang Chen , Heiner Kallweit , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni Subject: [PATCH net-next 05/10] net: stmmac: use phylink_limit_mac_speed() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 24 Aug 2023 14:38:14 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230824_063820_136230_8708257E X-CRM114-Status: GOOD ( 11.60 ) 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 Use phylink_limit_mac_speed() to limit the MAC capabilities rather than coding this for each speed. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index fe733a9f5fe4..30a085f2b8fa 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1200,10 +1200,10 @@ static int stmmac_init_phy(struct net_device *dev) static int stmmac_phy_setup(struct stmmac_priv *priv) { struct stmmac_mdio_bus_data *mdio_bus_data; - int max_speed = priv->plat->max_speed; int mode = priv->plat->phy_interface; struct fwnode_handle *fwnode; struct phylink *phylink; + int max_speed; priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type = PHYLINK_NETDEV; @@ -1222,29 +1222,18 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.supported_interfaces); priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | - MAC_10 | MAC_100; - - if (!max_speed || max_speed >= 1000) - priv->phylink_config.mac_capabilities |= MAC_1000; + MAC_10 | MAC_100 | MAC_1000; if (priv->plat->has_gmac4) { - if (!max_speed || max_speed >= 2500) - priv->phylink_config.mac_capabilities |= MAC_2500FD; + priv->phylink_config.mac_capabilities |= MAC_2500FD; } else if (priv->plat->has_xgmac) { - if (!max_speed || max_speed >= 2500) - priv->phylink_config.mac_capabilities |= MAC_2500FD; - if (!max_speed || max_speed >= 5000) - priv->phylink_config.mac_capabilities |= MAC_5000FD; - if (!max_speed || max_speed >= 10000) - priv->phylink_config.mac_capabilities |= MAC_10000FD; - if (!max_speed || max_speed >= 25000) - priv->phylink_config.mac_capabilities |= MAC_25000FD; - if (!max_speed || max_speed >= 40000) - priv->phylink_config.mac_capabilities |= MAC_40000FD; - if (!max_speed || max_speed >= 50000) - priv->phylink_config.mac_capabilities |= MAC_50000FD; - if (!max_speed || max_speed >= 100000) - priv->phylink_config.mac_capabilities |= MAC_100000FD; + priv->phylink_config.mac_capabilities |= MAC_2500FD; + priv->phylink_config.mac_capabilities |= MAC_5000FD; + priv->phylink_config.mac_capabilities |= MAC_10000FD; + priv->phylink_config.mac_capabilities |= MAC_25000FD; + priv->phylink_config.mac_capabilities |= MAC_40000FD; + priv->phylink_config.mac_capabilities |= MAC_50000FD; + priv->phylink_config.mac_capabilities |= MAC_100000FD; } /* Half-Duplex can only work with single queue */ @@ -1253,6 +1242,10 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) ~(MAC_10HD | MAC_100HD | MAC_1000HD); priv->phylink_config.mac_managed_pm = true; + max_speed = priv->plat->max_speed; + if (max_speed) + phylink_limit_mac_speed(&priv->phylink_config, max_speed); + fwnode = priv->plat->port_node; if (!fwnode) fwnode = dev_fwnode(priv->device);