From patchwork Thu Feb 24 16:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758855 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46672C433F5 for ; Thu, 24 Feb 2022 16:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiBXQa0 (ORCPT ); Thu, 24 Feb 2022 11:30:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbiBXQaY (ORCPT ); Thu, 24 Feb 2022 11:30:24 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC361F83E7 for ; Thu, 24 Feb 2022 08:29:49 -0800 (PST) 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=lIY6XpFN6DHXZxJ3h/lyIVZFaJkNxeJQjru2eCe7kOs=; b=oZ90EN2ioNDkkzGs/YVFGai3Gu pzC69jRgRZ2lAGcl6cNuk3yyoJQOloUWNsa9c4rvPasv/7b2hwnIL1716y+YeNdlZCZh5bqatc1vS bvL5EiGMgr7IiMdNuypnJNx+7LMfNammvkkhvZpuxPZHsVaSWYgceIBhTduItsGQdzgomM8QkqiPh b0AtfGs3kI7MHRCI6fEWZE5NyiFoR1vzPOJ8LngQID2BJES9ARYhLM6sB6mx3+1qqsEx3NNJ0p9ZI U0mYcjMuVMczXm1l0Wu5iWGLcQXGfOc9Rjb1bIo4mJ9U0hcI0891uajKheSq44e4aij2LYQPr8F1G mxolV8uw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39178 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGlw-0004C0-LE; Thu, 24 Feb 2022 16:15:16 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGlv-00AOid-Vd; Thu, 24 Feb 2022 16:15:16 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 1/6] net: dsa: sja1105: populate supported_interfaces MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:15 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Populate the supported interfaces bitmap for the SJA1105 DSA switch. This switch only supports a static model of configuration, so we restrict the interface modes to the configured setting. Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index b513713be610..90e73a982faf 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1412,6 +1412,18 @@ static void sja1105_mac_link_up(struct dsa_switch *ds, int port, sja1105_inhibit_tx(priv, BIT(port), false); } +static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct sja1105_private *priv = ds->priv; + + /* The SJA1105 MAC programming model is through the static config + * (the xMII Mode table cannot be dynamically reconfigured), and + * we have to program that early. + */ + __set_bit(priv->phy_mode[port], config->supported_interfaces); +} + static void sja1105_phylink_validate(struct dsa_switch *ds, int port, unsigned long *supported, struct phylink_link_state *state) @@ -3152,6 +3164,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .set_ageing_time = sja1105_set_ageing_time, .port_change_mtu = sja1105_change_mtu, .port_max_mtu = sja1105_get_max_mtu, + .phylink_get_caps = sja1105_phylink_get_caps, .phylink_validate = sja1105_phylink_validate, .phylink_mac_config = sja1105_mac_config, .phylink_mac_link_up = sja1105_mac_link_up, From patchwork Thu Feb 24 16:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758854 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BD46C433FE for ; Thu, 24 Feb 2022 16:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229627AbiBXQaV (ORCPT ); Thu, 24 Feb 2022 11:30:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiBXQaU (ORCPT ); Thu, 24 Feb 2022 11:30:20 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7801E1125 for ; Thu, 24 Feb 2022 08:29:44 -0800 (PST) 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=4x58eViSPNvwcXyTfywfg/RWpnLitLMEVepFTrlZWrU=; b=oX6jbh3mIAynsiYxG/FvP/lqrO 2nOKZjRbFXYOfhBCNjaYMEHaXUf1uk4N/mHMpCXJ5YISIoO1nnK0qugy6yQCnvRmSegJbsauW75qP f6nk9oIY0Lku9wMbaQsOSdpCIvbkk7ckWLg52waZTLFZhHO1F/rPiRLIvUMyQBihF1ShQbST2HFju +LKsVt2j0cD4Qa9jiAB/P4XMb3A7l1JGj2G6ofABTnZbv36pxe/vkyV85R2zykNfIBI42mzuVzRER MCTwtLMbmR69FO4jztw9tBiGaxpXBJz1wyoZM1NtadPpJGti96L71muwhD6bxg9eiZbk+wAR/eS4/ 9WrOzq/w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39180 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGm1-0004CF-MN; Thu, 24 Feb 2022 16:15:21 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGm1-00AOij-3q; Thu, 24 Feb 2022 16:15:21 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 2/6] net: dsa: sja1105: remove interface checks MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:21 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC When the supported interfaces bitmap is populated, phylink will itself check that the interface mode is present in this bitmap. Drivers no longer need to perform this check themselves. Remove these checks. Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 29 -------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 90e73a982faf..e278bd86e3c6 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1358,19 +1358,6 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, return sja1105_clocking_setup_port(priv, port); } -/* The SJA1105 MAC programming model is through the static config (the xMII - * Mode table cannot be dynamically reconfigured), and we have to program - * that early (earlier than PHYLINK calls us, anyway). - * So just error out in case the connected PHY attempts to change the initial - * system interface MII protocol from what is defined in the DT, at least for - * now. - */ -static bool sja1105_phy_mode_mismatch(struct sja1105_private *priv, int port, - phy_interface_t interface) -{ - return priv->phy_mode[port] != interface; -} - static void sja1105_mac_config(struct dsa_switch *ds, int port, unsigned int mode, const struct phylink_link_state *state) @@ -1379,12 +1366,6 @@ static void sja1105_mac_config(struct dsa_switch *ds, int port, struct sja1105_private *priv = ds->priv; struct dw_xpcs *xpcs; - if (sja1105_phy_mode_mismatch(priv, port, state->interface)) { - dev_err(ds->dev, "Changing PHY mode to %s not supported!\n", - phy_modes(state->interface)); - return; - } - xpcs = priv->xpcs[port]; if (xpcs) @@ -1438,16 +1419,6 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port, mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; - /* include/linux/phylink.h says: - * When @state->interface is %PHY_INTERFACE_MODE_NA, phylink - * expects the MAC driver to return all supported link modes. - */ - if (state->interface != PHY_INTERFACE_MODE_NA && - sja1105_phy_mode_mismatch(priv, port, state->interface)) { - linkmode_zero(supported); - return; - } - /* The MAC does not support pause frames, and also doesn't * support half-duplex traffic modes. */ From patchwork Thu Feb 24 16:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758853 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 462A3C433EF for ; Thu, 24 Feb 2022 16:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbiBXQaU (ORCPT ); Thu, 24 Feb 2022 11:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiBXQaN (ORCPT ); Thu, 24 Feb 2022 11:30:13 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B951E112A for ; Thu, 24 Feb 2022 08:29:41 -0800 (PST) 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=iKQ+ddk7h+ceocwkB0iQA76XDs7dCxfpVMw7+eotZNI=; b=Yeb0UC+yy2Eo7Me0QJMPnpBLpf lO7+n6iWIhEGXv5x9J6zXTwL1tf+ioL4MNq/h1c2C1eW/dCyKOxxTznlv4xD7lDa+oYCVVkFIJE9t xiy0uUeqHmtXsGsQkKaCEs8jmagXGPVW1uaO8B+HWivaa7Tkl496++2WnhBpiMdGBMUe2UNRhQxeY xqm6WefZvr0caWzKqHXnogGDrs+pR80xuwsIhtZkwVnu+WNDoJkM8z4kgjZL3crGT8lvEyZndLBol YG5g9ecc7uGG7/z/67cqNCN7DQCuZ3ZmJTJLOvAP/jgY0XyHGVMW0NH86FpjKQP8OWsCKTm3GwrMd ZKnPF0cQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39182 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGm6-0004CR-Ph; Thu, 24 Feb 2022 16:15:26 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGm6-00AOip-6r; Thu, 24 Feb 2022 16:15:26 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 3/6] net: dsa: sja1105: use .mac_select_pcs() interface MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:26 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Convert the PCS selection to use mac_select_pcs, which allows the PCS to perform any validation it needs, and removes the need to set the PCS in the mac_config() callback, delving into the higher DSA levels to do so. Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index e278bd86e3c6..b5c36f808df1 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1358,18 +1358,16 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, return sja1105_clocking_setup_port(priv, port); } -static void sja1105_mac_config(struct dsa_switch *ds, int port, - unsigned int mode, - const struct phylink_link_state *state) +static struct phylink_pcs * +sja1105_mac_select_pcs(struct dsa_switch *ds, int port, phy_interface_t iface) { - struct dsa_port *dp = dsa_to_port(ds, port); struct sja1105_private *priv = ds->priv; - struct dw_xpcs *xpcs; - - xpcs = priv->xpcs[port]; + struct dw_xpcs *xpcs = priv->xpcs[port]; if (xpcs) - phylink_set_pcs(dp->pl, &xpcs->pcs); + return &xpcs->pcs; + + return NULL; } static void sja1105_mac_link_down(struct dsa_switch *ds, int port, @@ -3137,7 +3135,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .port_max_mtu = sja1105_get_max_mtu, .phylink_get_caps = sja1105_phylink_get_caps, .phylink_validate = sja1105_phylink_validate, - .phylink_mac_config = sja1105_mac_config, + .phylink_mac_select_pcs = sja1105_mac_select_pcs, .phylink_mac_link_up = sja1105_mac_link_up, .phylink_mac_link_down = sja1105_mac_link_down, .get_strings = sja1105_get_strings, From patchwork Thu Feb 24 16:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758851 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A852BC433F5 for ; Thu, 24 Feb 2022 16:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiBXQaL (ORCPT ); Thu, 24 Feb 2022 11:30:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbiBXQaH (ORCPT ); Thu, 24 Feb 2022 11:30:07 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E8801C7EB4 for ; Thu, 24 Feb 2022 08:29:35 -0800 (PST) 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=hmOb6sS0rjImnEIuZ1CMwjM/aO0v0FODYFQFp1xbsf0=; b=QJtaniQshTr15wEMPNMnyAvwxf XgdoyXLNaiTTu7CeeAjCEZmH+b04MvgJcLTnvp8a2mUcL0HtrBwFPM1jtHJUBg2OGyV/aPVoOWHtv 83HXpHabUuvZAQbL6DRbKk5maUkcddBh6z/woV1jNlNcbZSWAAwXJaFYZ/7bP39kN3+5rC91OoMDS xlknkalG/bSJvFlFdhKEuKYC209zDseSE8K6YZNLPV3SdhX/spMyLMZD24qE06nmvvjvLXPHV0/v5 /AT2IjS4mWk3puyR2ikEpSaaZyiQYv+zsdbJ6d57mgdEbe7uu2EKAnuU/Xqe6pChbsvZ3m+W5U1RV HSugjCqA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39184 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGmB-0004Cc-Su; Thu, 24 Feb 2022 16:15:31 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGmB-00AOj0-A8; Thu, 24 Feb 2022 16:15:31 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 4/6] net: dsa: sja1105: mark as non-legacy MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:31 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The sja1105 DSA driver does not have a phylink_mac_config() method implementation, it is safe to mark this as a non-legacy driver. Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index b5c36f808df1..8f061cce77f0 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1396,6 +1396,12 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; + /* This driver does not make use of the speed, duplex, pause or the + * advertisement in its mac_config, so it is safe to mark this driver + * as non-legacy. + */ + config->legacy_pre_march2020 = false; + /* The SJA1105 MAC programming model is through the static config * (the xMII Mode table cannot be dynamically reconfigured), and * we have to program that early. From patchwork Thu Feb 24 16:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758850 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 450C5C4332F for ; Thu, 24 Feb 2022 16:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbiBXQaG (ORCPT ); Thu, 24 Feb 2022 11:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiBXQaF (ORCPT ); Thu, 24 Feb 2022 11:30:05 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CDB1A39FA for ; Thu, 24 Feb 2022 08:29:32 -0800 (PST) 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=cgnxRvxAr25UyLKUfOhTDeie2ydSHIXffnwqxjdk484=; b=hOjLGXklFNNtJoORqd3fqXEcbC Z1QF/oZ8+aa+oDpxlzLjoNV+MVkka9eDmVV5T+L6MMdvY3vndUFXp0YH2GKXIBWQMxo4F2QVG8pRP 1TGK1yI9uQ3g8nx0lceAiJdMwMgJbUUaQkdtJ+ChvT6yGLai2Bp6qblk7dCZaoKI7DkDhtC0Lc+Hb Qr6t7f9Jq0QdvE6yOvuIYrWP6mocxCYXPMXcqHvwEIcgLlAEqHmXsMDNQkDDDX9J6+VRKHg+V5Xp1 9O66WPF8WmxTescveZ9+aiReDD9Ytl/JLuACj18OYVdUbspbFU5wC+Z5OZRiPDBHHh4sHV2J768Ti uRG2IC5g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39186 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGmH-0004Cn-0N; Thu, 24 Feb 2022 16:15:37 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGmG-00AOj6-Dl; Thu, 24 Feb 2022 16:15:36 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 5/6] net: dsa: sja1105: convert to phylink_generic_validate() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:36 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Populate the MAC capabilities for the SJA1105 DSA switch using the same decision making which sja1105_phylink_validate() uses. Remove the now obsolete sja1105_phylink_validate() implementation to allow DSA to use phylink_generic_validate() for this switch driver. As noted by Vladimir, this fixes an inconsequential bug which allowed gigabit and lower interface modes to be indicated when operating in 2500base-X mode. Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 35 ++++++-------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 8f061cce77f0..5beef06d8ff7 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1395,6 +1395,7 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { struct sja1105_private *priv = ds->priv; + struct sja1105_xmii_params_entry *mii; /* This driver does not make use of the speed, duplex, pause or the * advertisement in its mac_config, so it is safe to mark this driver @@ -1407,40 +1408,19 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, * we have to program that early. */ __set_bit(priv->phy_mode[port], config->supported_interfaces); -} - -static void sja1105_phylink_validate(struct dsa_switch *ds, int port, - unsigned long *supported, - struct phylink_link_state *state) -{ - /* Construct a new mask which exhaustively contains all link features - * supported by the MAC, and then apply that (logical AND) to what will - * be sent to the PHY for "marketing". - */ - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; - struct sja1105_private *priv = ds->priv; - struct sja1105_xmii_params_entry *mii; - - mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; /* The MAC does not support pause frames, and also doesn't * support half-duplex traffic modes. */ - phylink_set(mask, Autoneg); - phylink_set(mask, MII); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 100baseT1_Full); + config->mac_capabilities = MAC_10FD | MAC_100FD; + + mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; if (mii->xmii_mode[port] == XMII_MODE_RGMII || mii->xmii_mode[port] == XMII_MODE_SGMII) - phylink_set(mask, 1000baseT_Full); - if (priv->info->supports_2500basex[port]) { - phylink_set(mask, 2500baseT_Full); - phylink_set(mask, 2500baseX_Full); - } + config->mac_capabilities |= MAC_1000FD; - linkmode_and(supported, supported, mask); - linkmode_and(state->advertising, state->advertising, mask); + if (priv->info->supports_2500basex[port]) + config->mac_capabilities |= MAC_2500FD; } static int @@ -3140,7 +3120,6 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .port_change_mtu = sja1105_change_mtu, .port_max_mtu = sja1105_get_max_mtu, .phylink_get_caps = sja1105_phylink_get_caps, - .phylink_validate = sja1105_phylink_validate, .phylink_mac_select_pcs = sja1105_mac_select_pcs, .phylink_mac_link_up = sja1105_mac_link_up, .phylink_mac_link_down = sja1105_mac_link_down, From patchwork Thu Feb 24 16:15:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12758856 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB146C433EF for ; Thu, 24 Feb 2022 16:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiBXQaj (ORCPT ); Thu, 24 Feb 2022 11:30:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbiBXQah (ORCPT ); Thu, 24 Feb 2022 11:30:37 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E61A20C18B for ; Thu, 24 Feb 2022 08:29:55 -0800 (PST) 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=CGzygN9zmXKhz0Z67FMFNp2qiPseiFfA7FYjWGYAj+E=; b=1ymhgbw5dfFvnlQqfC9ZnBCaOR lkIdjqkkNrtMm8sC10LkAQYHiKXyZROj2DiuGflcljAlacCJzMHqFC+13OIZdN5xZhLAMT3j9AOZK o5stzYuB8lUiGSTivTDzFlD/5MOKx3zwXxVrzLnC6uD0goKQVQZ90g5t3U1AUJDDuekitPZQ9OXs3 eiOEwDm2D1Ix3NPsEDwdkMr7LDIhDERS6cMdWlU5npywBkiCx2xZzLhrqt0ivwUMj/aKHMNhg1hz4 f20/mB7c8yyHohs1Hxq+eESw9d/Dd+3J61DVCjVjxbl8hbDEByDBfCkjUBmfksvWIPSrfMf8UIbmP VIsPw7dA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39188 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGmM-0004Cy-43; Thu, 24 Feb 2022 16:15:42 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGmL-00AOjC-HP; Thu, 24 Feb 2022 16:15:41 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 6/6] net: dsa: sja1105: support switching between SGMII and 2500BASE-X MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:41 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Vladimir Oltean suggests that sla1105 can support switching between SGMII and 2500BASE-X modes. Augment sja1105_phylink_get_caps() to fill in both interface modes if they can be supported. Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/sja1105/sja1105_main.c | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 5beef06d8ff7..36001b1d7968 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1396,6 +1396,7 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; struct sja1105_xmii_params_entry *mii; + phy_interface_t phy_mode; /* This driver does not make use of the speed, duplex, pause or the * advertisement in its mac_config, so it is safe to mark this driver @@ -1403,11 +1404,28 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, */ config->legacy_pre_march2020 = false; - /* The SJA1105 MAC programming model is through the static config - * (the xMII Mode table cannot be dynamically reconfigured), and - * we have to program that early. - */ - __set_bit(priv->phy_mode[port], config->supported_interfaces); + phy_mode = priv->phy_mode[port]; + if (phy_mode == PHY_INTERFACE_MODE_SGMII || + phy_mode == PHY_INTERFACE_MODE_2500BASEX) { + /* Changing the PHY mode on SERDES ports is possible and makes + * sense, because that is done through the XPCS. We allow + * changes between SGMII and 2500base-X (it is unknown whether + * 1000base-X is supported). + */ + if (priv->info->supports_sgmii[port]) + __set_bit(PHY_INTERFACE_MODE_SGMII, + config->supported_interfaces); + + if (priv->info->supports_2500basex[port]) + __set_bit(PHY_INTERFACE_MODE_2500BASEX, + config->supported_interfaces); + } else { + /* The SJA1105 MAC programming model is through the static + * config (the xMII Mode table cannot be dynamically + * reconfigured), and we have to program that early. + */ + __set_bit(phy_mode, config->supported_interfaces); + } /* The MAC does not support pause frames, and also doesn't * support half-duplex traffic modes.