From patchwork Wed Nov 17 15:29:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12624925 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C48CBC433EF for ; Wed, 17 Nov 2021 15:29:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A173C61A56 for ; Wed, 17 Nov 2021 15:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236675AbhKQPcV (ORCPT ); Wed, 17 Nov 2021 10:32:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbhKQPcU (ORCPT ); Wed, 17 Nov 2021 10:32: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 4CDB1C061570 for ; Wed, 17 Nov 2021 07:29:22 -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=S/2yRFaFlD6kkXQGsryWk54u9gmNZZ1HSG5rOScUuz4=; b=0kf5kkG+GVuS16s50qm1UjUywl JYFYRPqeR+l99Xu6kAB54QgwT+Nh5nxapDBuJJbd9RDLeURWf7VPhGbRqqfD8Yl8NW1mvz/bSiD73 WXfxZHeD2rzT/Dt9FfWpgyHGUK0WeguDv9hrXCZQz48rjMLrlKMYjgGrx/mviRL5C2NxosLvOdZfb RQWvePRJ/J7bM7nLftVC3Yv+jRGHVxUCLkgwHx1kuZeWYK+WQJEdC2huWZ4PHC8sAhmeOoees8uYB ssCVCgtDQu7NEhZoM/q64lHqGsDqbHSuMa4QpKaCPBGoG3FInL99lefQMOyAcEtrJKBCoAE+qxhd+ MoPE/iQg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45516 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 1mnMsC-0001yo-N6; Wed, 17 Nov 2021 15:29:20 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mnMsC-007y7m-7f; Wed, 17 Nov 2021 15:29:20 +0000 In-Reply-To: References: From: Russell King To: Chris Snook , Oleksij Rempel Cc: netdev@vger.kernel.org Subject: [PATCH RFC net-next 1/3] net: ag71xx: populate supported_interfaces member MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 17 Nov 2021 15:29:20 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Populate the phy_interface_t bitmap for the Atheros ag71xx driver with interfaces modes supported by the MAC. Signed-off-by: Russell King --- drivers/net/ethernet/atheros/ag71xx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c index 88d2ab748399..8d55ce266aa3 100644 --- a/drivers/net/ethernet/atheros/ag71xx.c +++ b/drivers/net/ethernet/atheros/ag71xx.c @@ -1178,6 +1178,32 @@ static int ag71xx_phylink_setup(struct ag71xx *ag) ag->phylink_config.dev = &ag->ndev->dev; ag->phylink_config.type = PHYLINK_NETDEV; + if ((ag71xx_is(ag, AR9330) && ag->mac_idx == 0) || + ag71xx_is(ag, AR9340) || + ag71xx_is(ag, QCA9530) || + (ag71xx_is(ag, QCA9550) && ag->mac_idx == 1)) + __set_bit(PHY_INTERFACE_MODE_MII, + ag->phylink_config.supported_interfaces); + + if ((ag71xx_is(ag, AR9330) && ag->mac_idx == 1) || + (ag71xx_is(ag, AR9340) && ag->mac_idx == 1) || + (ag71xx_is(ag, QCA9530) && ag->mac_idx == 1)) + __set_bit(PHY_INTERFACE_MODE_GMII, + ag->phylink_config.supported_interfaces); + + if (ag71xx_is(ag, QCA9550) && ag->mac_idx == 0) + __set_bit(PHY_INTERFACE_MODE_SGMII, + ag->phylink_config.supported_interfaces); + + if (ag71xx_is(ag, AR9340) && ag->mac_idx == 0) + __set_bit(PHY_INTERFACE_MODE_RMII, + ag->phylink_config.supported_interfaces); + + if ((ag71xx_is(ag, AR9340) && ag->mac_idx == 0) || + (ag71xx_is(ag, QCA9550) && ag->mac_idx == 1)) + __set_bit(PHY_INTERFACE_MODE_RGMII, + ag->phylink_config.supported_interfaces); + phylink = phylink_create(&ag->phylink_config, ag->pdev->dev.fwnode, ag->phy_if_mode, &ag71xx_phylink_mac_ops); if (IS_ERR(phylink)) From patchwork Wed Nov 17 15:29:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12624927 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BF36C433F5 for ; Wed, 17 Nov 2021 15:29:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01EF761A64 for ; Wed, 17 Nov 2021 15:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236704AbhKQPca (ORCPT ); Wed, 17 Nov 2021 10:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236828AbhKQPc0 (ORCPT ); Wed, 17 Nov 2021 10:32:26 -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 54A39C061570 for ; Wed, 17 Nov 2021 07:29:27 -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=TJWsQEQaHiTvQtN+zUvqAuiQTyoh1ybLoZenhjB9auw=; b=bEw+LRy13kYXDuZijHxWzP28un xctXyim4oVeYhNdbTv9XZxneB9Sr8bUxEpwKse8RxpfuFevsPMllxv1ciF3SOJM4XGz+Y988bOWGj CBTonxEs8fH1f36RVlEFekI/LZ8WOiptrg9LX38bBf9jbX89rpajYJeAQOso7vdlmi+JXQW0uDmwA DxM0QeGB0wiYrVdRJmObJ7mlks5eMxRbDSiKYL7rYOfLJBXOLVfObIoGfDTSxHF2ZwiC6Z4avMPXt nyeFTkWGQZBNg9dh6to7RLSzkk+O8SEaN4I3D3Gtl1DFnZz0N1MkXE4Nkvju8Bt0C5Zg310+kg5eI sRmFQhYg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45518 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 1mnMsH-0001yy-Om; Wed, 17 Nov 2021 15:29:25 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mnMsH-007y7s-Be; Wed, 17 Nov 2021 15:29:25 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Chris Snook , Oleksij Rempel Cc: netdev@vger.kernel.org Subject: [PATCH RFC net-next 2/3] net: ag71xx: remove interface checks in ag71xx_mac_validate() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 17 Nov 2021 15:29:25 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC As phylink checks the interface mode against the supported_interfaces bitmap, we no longer need to validate the interface mode, nor handle PHY_INTERFACE_MODE_NA in the validation function. Remove these to simplify the implementation. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/atheros/ag71xx.c | 41 +-------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c index 8d55ce266aa3..20c2cfdc30da 100644 --- a/drivers/net/ethernet/atheros/ag71xx.c +++ b/drivers/net/ethernet/atheros/ag71xx.c @@ -1028,42 +1028,8 @@ static void ag71xx_mac_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { - struct ag71xx *ag = netdev_priv(to_net_dev(config->dev)); __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; - switch (state->interface) { - case PHY_INTERFACE_MODE_NA: - break; - case PHY_INTERFACE_MODE_MII: - if ((ag71xx_is(ag, AR9330) && ag->mac_idx == 0) || - ag71xx_is(ag, AR9340) || - ag71xx_is(ag, QCA9530) || - (ag71xx_is(ag, QCA9550) && ag->mac_idx == 1)) - break; - goto unsupported; - case PHY_INTERFACE_MODE_GMII: - if ((ag71xx_is(ag, AR9330) && ag->mac_idx == 1) || - (ag71xx_is(ag, AR9340) && ag->mac_idx == 1) || - (ag71xx_is(ag, QCA9530) && ag->mac_idx == 1)) - break; - goto unsupported; - case PHY_INTERFACE_MODE_SGMII: - if (ag71xx_is(ag, QCA9550) && ag->mac_idx == 0) - break; - goto unsupported; - case PHY_INTERFACE_MODE_RMII: - if (ag71xx_is(ag, AR9340) && ag->mac_idx == 0) - break; - goto unsupported; - case PHY_INTERFACE_MODE_RGMII: - if ((ag71xx_is(ag, AR9340) && ag->mac_idx == 0) || - (ag71xx_is(ag, QCA9550) && ag->mac_idx == 1)) - break; - goto unsupported; - default: - goto unsupported; - } - phylink_set(mask, MII); phylink_set(mask, Pause); @@ -1074,8 +1040,7 @@ static void ag71xx_mac_validate(struct phylink_config *config, phylink_set(mask, 100baseT_Half); phylink_set(mask, 100baseT_Full); - if (state->interface == PHY_INTERFACE_MODE_NA || - state->interface == PHY_INTERFACE_MODE_SGMII || + if (state->interface == PHY_INTERFACE_MODE_SGMII || state->interface == PHY_INTERFACE_MODE_RGMII || state->interface == PHY_INTERFACE_MODE_GMII) { phylink_set(mask, 1000baseT_Full); @@ -1084,10 +1049,6 @@ static void ag71xx_mac_validate(struct phylink_config *config, linkmode_and(supported, supported, mask); linkmode_and(state->advertising, state->advertising, mask); - - return; -unsupported: - linkmode_zero(supported); } static void ag71xx_mac_pcs_get_state(struct phylink_config *config, From patchwork Wed Nov 17 15:29:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12624929 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 260FCC433F5 for ; Wed, 17 Nov 2021 15:29:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0519561A56 for ; Wed, 17 Nov 2021 15:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236828AbhKQPcd (ORCPT ); Wed, 17 Nov 2021 10:32:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbhKQPcb (ORCPT ); Wed, 17 Nov 2021 10:32:31 -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 71862C061570 for ; Wed, 17 Nov 2021 07: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=pM9RqqgqXQUBfxxPczlvb62iYPFSnxraY0XFMpKgbFQ=; b=hBv0lHgtf9xIstXidFle+EA+Cf yHtg0ooSqDp1mx/Ww0RxwHtGjZP+9NGoYd5h/rwt514frIurH3XgYV3OXGnBbHXHe9JdO3f6mN3/a iev4zQiaz0XhE1XizATLwButihcWIbt4+WrSdHgyknQ7PyW20Mgt4Hr1+DbXMQyXU9AgDdl3f+pBe DhpPD6i3T18YBTIUxXxOnESbWBzTnu0dYGw/q4TBcRBgBvd78eDjrmSlC/057AZU3XXaR6e734kjr WJW6ae8cNZKEFaor5nr/H2wdodwPDvlvfKRAvP7WZTqByQ0fzAUdWslkbgjysNRL639C07oWGCuHj 9zaogtxQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45520 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 1mnMsM-0001z6-Sj; Wed, 17 Nov 2021 15:29:30 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mnMsM-007y7z-F5; Wed, 17 Nov 2021 15:29:30 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Chris Snook , Oleksij Rempel Cc: netdev@vger.kernel.org Subject: [PATCH RFC net-next 3/3] net: ag71xx: convert to phylink_get_linkmodes() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 17 Nov 2021 15:29:30 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC ag71xx only supports MII port type, so can't use the generic phylink validation callback. Update to use phylink_get_linkmodes() instead. Signed-off-by: Russell King (Oracle) --- This implementation seems wrong. If it only supports the MII port type, then it doesn't support fibre or twisted pair - yet it can as a PHY can be connected. If this can be fixed, we can convert it to use phylink_generic_validate() and get rid of ag71xx_mac_validate() entirely. drivers/net/ethernet/atheros/ag71xx.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c index 20c2cfdc30da..2d2725b2a6ae 100644 --- a/drivers/net/ethernet/atheros/ag71xx.c +++ b/drivers/net/ethernet/atheros/ag71xx.c @@ -1032,20 +1032,8 @@ static void ag71xx_mac_validate(struct phylink_config *config, phylink_set(mask, MII); - phylink_set(mask, Pause); - phylink_set(mask, Asym_Pause); phylink_set(mask, Autoneg); - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); - - if (state->interface == PHY_INTERFACE_MODE_SGMII || - state->interface == PHY_INTERFACE_MODE_RGMII || - state->interface == PHY_INTERFACE_MODE_GMII) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - } + phylink_get_linkmodes(mask, state->interface, config->mac_capabilities); linkmode_and(supported, supported, mask); linkmode_and(state->advertising, state->advertising, mask); @@ -1138,6 +1126,8 @@ static int ag71xx_phylink_setup(struct ag71xx *ag) ag->phylink_config.dev = &ag->ndev->dev; ag->phylink_config.type = PHYLINK_NETDEV; + ag->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | + MAC_10 | MAC_100 | MAC_1000FD; if ((ag71xx_is(ag, AR9330) && ag->mac_idx == 0) || ag71xx_is(ag, AR9340) ||