From patchwork Mon Oct 5 14:28:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 288989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D083C4363A for ; Mon, 5 Oct 2020 14:28:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 322322078A for ; Mon, 5 Oct 2020 14:28:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="sv04IrCl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbgJEO2l (ORCPT ); Mon, 5 Oct 2020 10:28:41 -0400 Received: from mail-eopbgr10068.outbound.protection.outlook.com ([40.107.1.68]:62374 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726429AbgJEO2j (ORCPT ); Mon, 5 Oct 2020 10:28:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S7ZWHQe7ZgmXqm4lcVanywz+xtDeCDCs1M08J/QJEk51rjd0n+S8LQ0m4wfpmhfyNHRBtH4UH5flg8n9m/dzT1A55HiRyk19lNL03qNs+KVuNcqXidnzDEyQjjxP4GyUnFmeb4nFRmnjgcWe5mQdLHd0ZEoyz+0tvqsG86AJH3ANnad6+tSS1xbex1t5Nssqj6+ET+4nGZAfpl0CxiFEQRT9XRgm65WIiMEVWHScsFtlDDoBTVgMzVffgoqdd7zbdMNGEI7cq106eALLGdXQzeG3Sx0vtbxTSTJe02KBlQXU9VQgAUr9on/AeEFNTbGarXHW+C9a5X7d9eZiOzT1sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uf+TN0d3gXlh6B9yDnPvKvjm7/HBFEZI5c8S2K67A7s=; b=cBycV3d13o+NbbGZQdSQ2YjlGRrwCMf9pun6ZxWqf7QLEl6xf2IpDltvPlTU3ms1FXXxVtIRK2n7KQam5AJZLo0626V7SYSdqW+pYGkuZHSVfUwav65QszOJRtrtXXrMJY3V/U0ILNhleMJtgmDzbon1vhFXnggNXquZHU9xaFukG0LZdZ0EhYV6yaye7533Jq44lD4Vhz3HG6ifoxrSnZzFjDsyl6PMP0f50g7sxUKUY+JaQedRnBAT3n3kxm+OdygCu9Q9Oc0XFhEKPeUb2y0eWTalFDfTvmnKHk5luyH6h0EHbxDRBXqaSOoMo4aciY8PEi5QL8P/9Wd802M9/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uf+TN0d3gXlh6B9yDnPvKvjm7/HBFEZI5c8S2K67A7s=; b=sv04IrCl4LEXIn1DEO4M6zOVCMalL1rG7yk1z2JAVkTv2Ge17Sp10Mg1fpqlRBvc5ntLKFWZH9eA+1gB77pUuBWL2bhPgFjJweChcrBYrTUnfj5iOQLf4MDlFfffZlh2wmYoKTg5rLTtns1+Cw6wLXoZqtu9qUqGfRvvrA1XxD4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) by AM0PR04MB7171.eurprd04.prod.outlook.com (2603:10a6:208:19c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Mon, 5 Oct 2020 14:28:32 +0000 Received: from AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b]) by AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b%3]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 14:28:32 +0000 From: Claudiu Manoil To: netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Russell King , Vladimir Oltean Subject: [PATCH net-next 1/4] enetc: Clean up MAC and link configuration Date: Mon, 5 Oct 2020 17:28:15 +0300 Message-Id: <20201005142818.15110-2-claudiu.manoil@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005142818.15110-1-claudiu.manoil@nxp.com> References: <20201005142818.15110-1-claudiu.manoil@nxp.com> X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) To AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15141.swis.ro-buh01.nxp.com (83.217.231.2) by AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.37 via Frontend Transport; Mon, 5 Oct 2020 14:28:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2a484404-a6a0-4551-8cf4-08d8693aefaf X-MS-TrafficTypeDiagnostic: AM0PR04MB7171: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rql8N4LuWlhP7xMs/sHQWBTKwaZTFen9pa+WKhrgFpXjaIi+pUkJ90IIKG/Zi9tftkVYzE8O84h9TYQMsDgl6LFCVsoWfnebEgD9vDMsyev/bugBPSwGs2ssuCvZlNm9TlINuk/7zthS65aAScX7cUbQnvlUPFHaoAyzo+6207sUNxNbtiBrYdINBe3pF8UQL2Yfy06ln0vUayI9DuHHuOH+lTzInP3MaDWg0jQQpGy16aQlUkHlrM4hZPNyEYjwElZvVwgectqAV1LylvLsZJalPxBLYmX3Eb7TssdQaBv7qqJaMRHp176yuCUGdp/xT0JQlAob0EVYUtqD/yt5CA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6754.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(36756003)(6486002)(8676002)(2616005)(4326008)(956004)(6666004)(2906002)(7696005)(52116002)(6916009)(16526019)(26005)(8936002)(186003)(86362001)(54906003)(1076003)(478600001)(316002)(83380400001)(66476007)(44832011)(66946007)(5660300002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +Gc4X4DT3LeYmqdOdcWFKNhvlD5nzVvBoKEAQLySWMo4pwYAqE/WQiDpHaveNQIySoO8xUT9CBiAcFvHXPBFItEqg8d2eHxGsByOMaqyu1RRfDE530hYeQvIbi4w3QK2jNjMNftO4rNrM9QXg54skr9TeENYCzUXHwINxnfWxAXPIleyrjudFzNJG8uwYB3Zy4u3fUzOARmawUe81uBZKNpq2O04HQ8zslyZ5hKrELG27Gg+ivNXX20iO0HC3NkxcKR/6rHQAAyzo5Swt0IisXPc6n8XYRMcryt7jhZi/Yj/3yKAUUB7CZeRIMaIK/v1e9oYUjd6Zir8NJRTp8gMtEMsAAzo3/xxC50u970pYsEvNHp0f2QwoztYVFBamidM4z0iUb3tKQBc1HsZ+msDxcFhRzOGf3cYNHvjcNC9ltJHTfK9U91RLy2cUjy0L37/HFCFzY2kKUV0eErrjA3yG1OZiWKal+J8DUgeHZ78h43c1r74np0ebF4FO2K9imVV6JhhZM4cLjaaJYl5hB+8oE31xxzSbmvRArRWWWrpv3t1G03Efv9w+I7GZa/rgkGtj6Ne3fYKgJxNtZFRPDCPaOmRucn8hfgHdOin2tu/0fPQOhvDDky9Fj/ILOzUoQ0oJK7Z6sJ3RZhI2SaXCcmT+Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a484404-a6a0-4551-8cf4-08d8693aefaf X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6754.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 14:28:32.7661 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FCww81fsfaRqh8orv9As5Mdb/BTWpdy3TjvdGEo64Rd9u8P3YbgtNpkgFLtz4lieRztvwrEVhIa/mj7+/IvAiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7171 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Decouple level MAC configuration based on phy interface type from general port configuration. Group together MAC and link configuration code. Decouple external mdio bus creation from interface type parsing. No longer return an (unhandled) error code when phy_node not found, use phy_node to indicate whether the port has a phy or not. No longer fall-through when serdes configuration fails for the link modes that require internal link configuration. Signed-off-by: Claudiu Manoil --- .../net/ethernet/freescale/enetc/enetc_pf.c | 115 ++++++++++-------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 177334f0adb1..64596731c1c9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -482,8 +482,7 @@ static void enetc_port_si_configure(struct enetc_si *si) enetc_port_wr(hw, ENETC_PSIVLANFMR, ENETC_PSIVLANFMR_VS); } -static void enetc_configure_port_mac(struct enetc_hw *hw, - phy_interface_t phy_mode) +static void enetc_configure_port_mac(struct enetc_hw *hw) { enetc_port_wr(hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(ENETC_RX_MAXFRM_SIZE)); @@ -492,12 +491,16 @@ static void enetc_configure_port_mac(struct enetc_hw *hw, enetc_port_wr(hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE); enetc_port_wr(hw, ENETC_PM0_CMD_CFG, ENETC_PM0_CMD_PHY_TX_EN | - ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC | - ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC); enetc_port_wr(hw, ENETC_PM1_CMD_CFG, ENETC_PM0_CMD_PHY_TX_EN | - ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC | - ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC); +} + +static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode) +{ + u32 val; + /* set auto-speed for RGMII */ if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG || phy_interface_mode_is_rgmii(phy_mode)) @@ -505,6 +508,14 @@ static void enetc_configure_port_mac(struct enetc_hw *hw, if (phy_mode == PHY_INTERFACE_MODE_USXGMII) enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII); + + /* enable Rx and Tx */ + val = enetc_port_rd(hw, ENETC_PM0_CMD_CFG); + enetc_port_wr(hw, ENETC_PM0_CMD_CFG, + val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + + enetc_port_wr(hw, ENETC_PM1_CMD_CFG, + val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); } static void enetc_configure_port_pmac(struct enetc_hw *hw) @@ -527,7 +538,7 @@ static void enetc_configure_port(struct enetc_pf *pf) enetc_configure_port_pmac(hw); - enetc_configure_port_mac(hw, pf->if_mode); + enetc_configure_port_mac(hw); enetc_port_si_configure(pf->si); @@ -733,11 +744,10 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, enetc_get_primary_mac_addr(&si->hw, ndev->dev_addr); } -static int enetc_mdio_probe(struct enetc_pf *pf) +static int enetc_mdio_probe(struct enetc_pf *pf, struct device_node *np) { struct device *dev = &pf->si->pdev->dev; struct enetc_mdio_priv *mdio_priv; - struct device_node *np; struct mii_bus *bus; int err; @@ -754,26 +764,36 @@ static int enetc_mdio_probe(struct enetc_pf *pf) mdio_priv->mdio_base = ENETC_EMDIO_BASE; snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev_name(dev)); - np = of_get_child_by_name(dev->of_node, "mdio"); - if (!np) { - dev_err(dev, "MDIO node missing\n"); - return -EINVAL; - } - err = of_mdiobus_register(bus, np); if (err) { - of_node_put(np); dev_err(dev, "cannot register MDIO bus\n"); return err; } - of_node_put(np); pf->mdio = bus; return 0; } -static void enetc_mdio_remove(struct enetc_pf *pf) +static int enetc_mdiobus_create(struct enetc_pf *pf) +{ + struct device *dev = &pf->si->pdev->dev; + struct device_node *mdio_np; + int err; + + mdio_np = of_get_child_by_name(dev->of_node, "mdio"); + if (mdio_np) { + err = enetc_mdio_probe(pf, mdio_np); + + of_node_put(mdio_np); + if (err) + return err; + } + + return 0; +} + +static void enetc_mdiobus_destroy(struct enetc_pf *pf) { if (pf->mdio) mdiobus_unregister(pf->mdio); @@ -783,14 +803,13 @@ static int enetc_of_get_phy(struct enetc_pf *pf) { struct device *dev = &pf->si->pdev->dev; struct device_node *np = dev->of_node; - struct device_node *mdio_np; int err; pf->phy_node = of_parse_phandle(np, "phy-handle", 0); if (!pf->phy_node) { if (!of_phy_is_fixed_link(np)) { - dev_err(dev, "PHY not specified\n"); - return -ENODEV; + dev_dbg(dev, "PHY not specified\n"); + return 0; } err = of_phy_register_fixed_link(np); @@ -802,24 +821,12 @@ static int enetc_of_get_phy(struct enetc_pf *pf) pf->phy_node = of_node_get(np); } - mdio_np = of_get_child_by_name(np, "mdio"); - if (mdio_np) { - of_node_put(mdio_np); - err = enetc_mdio_probe(pf); - if (err) { - of_node_put(pf->phy_node); - return err; - } - } - err = of_get_phy_mode(np, &pf->if_mode); if (err) { dev_err(dev, "missing phy type\n"); of_node_put(pf->phy_node); if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); - else - enetc_mdio_remove(pf); return -EINVAL; } @@ -1004,10 +1011,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, pf->si = si; pf->total_vfs = pci_sriov_get_totalvfs(pdev); - err = enetc_of_get_phy(pf); - if (err) - dev_warn(&pdev->dev, "Fallback to PHY-less operation\n"); - enetc_configure_port(pf); enetc_get_si_caps(si); @@ -1022,8 +1025,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, enetc_pf_netdev_setup(si, ndev, &enetc_ndev_ops); priv = netdev_priv(ndev); - priv->phy_node = pf->phy_node; - priv->if_mode = pf->if_mode; enetc_init_si_rings_params(priv); @@ -1039,9 +1040,24 @@ static int enetc_pf_probe(struct pci_dev *pdev, goto err_alloc_msix; } - err = enetc_configure_serdes(priv); + err = enetc_of_get_phy(pf); if (err) - dev_warn(&pdev->dev, "Attempted SerDes config but failed\n"); + goto err_of_get_phy; + + if (pf->phy_node) { + priv->phy_node = pf->phy_node; + priv->if_mode = pf->if_mode; + + err = enetc_mdiobus_create(pf); + if (err) + goto err_mdiobus_create; + + err = enetc_configure_serdes(priv); + if (err) + goto err_configure_serdes; + + enetc_mac_config(&pf->si->hw, pf->if_mode); + } err = register_netdev(ndev); if (err) @@ -1053,6 +1069,11 @@ static int enetc_pf_probe(struct pci_dev *pdev, err_reg_netdev: enetc_teardown_serdes(priv); +err_configure_serdes: + enetc_mdiobus_destroy(pf); +err_mdiobus_create: + enetc_of_put_phy(pf); +err_of_get_phy: enetc_free_msix(priv); err_alloc_msix: enetc_free_si_resources(priv); @@ -1060,8 +1081,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, si->ndev = NULL; free_netdev(ndev); err_alloc_netdev: - enetc_mdio_remove(pf); - enetc_of_put_phy(pf); err_map_pf_space: enetc_pci_remove(pdev); @@ -1074,16 +1093,16 @@ static void enetc_pf_remove(struct pci_dev *pdev) struct enetc_pf *pf = enetc_si_priv(si); struct enetc_ndev_priv *priv; + priv = netdev_priv(si->ndev); + enetc_teardown_serdes(priv); + enetc_mdiobus_destroy(pf); + enetc_of_put_phy(pf); + if (pf->num_vfs) enetc_sriov_configure(pdev, 0); - priv = netdev_priv(si->ndev); unregister_netdev(si->ndev); - enetc_teardown_serdes(priv); - enetc_mdio_remove(pf); - enetc_of_put_phy(pf); - enetc_free_msix(priv); enetc_free_si_resources(priv); From patchwork Mon Oct 5 14:28:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 268095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 292ECC4363A for ; Mon, 5 Oct 2020 14:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2B352078A for ; Mon, 5 Oct 2020 14:28:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="OpAKL+r1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgJEO2u (ORCPT ); Mon, 5 Oct 2020 10:28:50 -0400 Received: from mail-eopbgr10068.outbound.protection.outlook.com ([40.107.1.68]:62374 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726526AbgJEO2o (ORCPT ); Mon, 5 Oct 2020 10:28:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cp2RRcFX4hNsT6pLXntRM3ffupy467nPVVkPUSQZq4KI2Q013weMtdvi+3RjY3Gm7i3nuMbecpmJhHGpS+UfTeP5VowNeLubTZ7UdHnF4rjknYkfNBZlV53lTcfP6Er7vU9RfISaPm1go8ttkL4RQqf1ZD9go9cyHkEogyj7WLcJASsicbeUKVy1FrtU9Eex4ZujZD/VdraTHzc9xFcIrcO+2+f+g3axG/hTGuSX2CPNX/hMyeB6wDY6/wlDn8rEqq+K6fz4adExwnDd+pSFTGLHoAK2cM1gHfzUNkpy8N+1ufdjU3+xxuBSYn3LhT4o9UN0+qCb8mp+ghHJsCV3PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wjFtVGgpSKwjz/Jlkofgjdz2QAxhTKoZEbi/XG1ZVSI=; b=aon1vs3+MFM+SOI7VsDqcRLQbY0jJcjjQnBkeseDnK1MP25FSQXsIqWhF6WBJmnP63PQWXf75c4t3yxgdQetBf0/OLIOSfEF4YPhqjHBWoszzeGFeSN8nFNwhSc2Lbc4LYO10yCplbwFfPpvLE95n3D0iYdVSRnKoilPdJ6ui+U7rtuW13DnlNrFT19v+gSxV4JAk+8SBQvlR2E0+5jf41LTAKArJdaAYj6FnmikEHAuVq8yVj9wwsHFoLnCAfQFZdrjoSWxiT0kpLujMFFQPmDWAmppUgGDUSJFHJ4yiqjX6XPwbylmt3Faj6CBnbxVgYJiwYSywe7G3VIBNJqNaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wjFtVGgpSKwjz/Jlkofgjdz2QAxhTKoZEbi/XG1ZVSI=; b=OpAKL+r1olu5EHoqpCqhsnDGsQNgbtNK2r3cypJJf9M+27dplEX9lpFTKo5HsDgudQuqXOsiGoMvKCyJFNakVtRJCFDAu2XIbaTfas7eAJgE3IbhBhXIBVV/JUBveYpU3d6hrPt76569gfC/ypc33tFDRnrXjd3omdAkOcnyZGg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) by AM0PR04MB7171.eurprd04.prod.outlook.com (2603:10a6:208:19c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Mon, 5 Oct 2020 14:28:33 +0000 Received: from AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b]) by AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b%3]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 14:28:33 +0000 From: Claudiu Manoil To: netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Russell King , Vladimir Oltean Subject: [PATCH net-next 2/4] enetc: Clean up serdes configuration Date: Mon, 5 Oct 2020 17:28:16 +0300 Message-Id: <20201005142818.15110-3-claudiu.manoil@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005142818.15110-1-claudiu.manoil@nxp.com> References: <20201005142818.15110-1-claudiu.manoil@nxp.com> X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) To AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15141.swis.ro-buh01.nxp.com (83.217.231.2) by AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.37 via Frontend Transport; Mon, 5 Oct 2020 14:28:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 67f11cf0-bb19-4b1c-8873-08d8693af034 X-MS-TrafficTypeDiagnostic: AM0PR04MB7171: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:24; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4xn6GThffUYmsB1RAn0QSPUcDtXtWUJFL74egih20aH06JoTc+tepeb75gtPK7zeSnkZde+LreWwhL/16lepmJRdeqVndhUn1AhTbfl6X8v+HWxzXWSvNS53CFcxdTMf3Pi/mXuhNegB1qz85h4AIWOX/Qw4j3xACAove3EiY0a8sg7TEHEL/j/Gy8AjB4QjDtqoTo51b/nFGPHHow4PESUNE9cz9pH8gLUuuW5EPpdjk9QMWQ0lOzSt8gE4fRXaepsocUCMGIpr7w8hrcS1Ngik571h8aZlJdk/4+rG79PGjGVTpOaYq4rnIwfmEZVzWiNNrv9kDLt7xiQki3oDvg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6754.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(36756003)(6486002)(8676002)(2616005)(4326008)(956004)(6666004)(2906002)(7696005)(52116002)(6916009)(16526019)(26005)(8936002)(186003)(86362001)(54906003)(1076003)(478600001)(316002)(83380400001)(66476007)(44832011)(66946007)(5660300002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DovgA9BDJ2UuJoF1TNTva8uR8H/ZsPwZEyfOoXuNbUtundQZdmUj3iUt3czPzvtKHiQPVmqlDDYnQilc7zxO0EgEOqVWxne0T1IwMF/eSjhdf4TCmzTQ2a5riWWfpdLMqMgEnLHV/n+dDiEaUZ1Z7tHNwkoRG7rVJv1/Qo0iMZxBsqhVu6y7shwVPtSh3lOapbcbXMhhS61JtHkoCPKZjqJVni3FbjO1W0xVg9SC5YK3kryFlxKjs6fqONCGxZ8CKNbnQZGqA6GXyWDvnIrjJUGCvV840bbOQQzwsoSg+ko5Wy/ZvPVYY4+klSf3ObN/sWS6UPIezI5evL9UOyBjWi2bsUzPavWtKiu82qMZhaCaziNV40w9vHCQnkAlY0LBm3sICRMP0OAdd/2VQ7HPFRZCdds7ZYH/vIfJVjglAdVkF1Vy5m2mYD0oCJi8GOqiYV4X20ZPz3sJXL2LZwVOAUtSMEFa0TiZUY9jZNo7Zfz4G7SRsf+8XVim5H2x4jqjjnCjXsN7W0RoqYe/5VBPi5zAMdR+tdGMm7LLRXH3dW7Zl8D5omu6M0mKB5woUgrvd1DkN/L/ocDAr1AtRThaiaR97jXZIdwtzA97GC2Mzincw6f3tvmdCjiGlJDVH6WMD6L2VCbE2vecU8zjAgZ0RQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67f11cf0-bb19-4b1c-8873-08d8693af034 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6754.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 14:28:33.5117 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZwZIpQngQmLmhGwEdvySHxTD6a/aSgS0sQ8uWyZvvOlVbhBARU7o3Be7jSa8TDNqzmNJqEwDWWztXtlgleTsvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7171 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Decouple internal mdio bus creation from serdes configuration, as a prerequisite to offloading serdes configuration to a different module. Group together mdio bus creation routines, cleanup. Signed-off-by: Claudiu Manoil --- .../net/ethernet/freescale/enetc/enetc_pf.c | 101 +++++++++--------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 64596731c1c9..6c533bf9e615 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -775,25 +775,7 @@ static int enetc_mdio_probe(struct enetc_pf *pf, struct device_node *np) return 0; } -static int enetc_mdiobus_create(struct enetc_pf *pf) -{ - struct device *dev = &pf->si->pdev->dev; - struct device_node *mdio_np; - int err; - - mdio_np = of_get_child_by_name(dev->of_node, "mdio"); - if (mdio_np) { - err = enetc_mdio_probe(pf, mdio_np); - - of_node_put(mdio_np); - if (err) - return err; - } - - return 0; -} - -static void enetc_mdiobus_destroy(struct enetc_pf *pf) +static void enetc_mdio_remove(struct enetc_pf *pf) { if (pf->mdio) mdiobus_unregister(pf->mdio); @@ -844,7 +826,7 @@ static void enetc_of_put_phy(struct enetc_pf *pf) of_node_put(pf->phy_node); } -static int enetc_imdio_init(struct enetc_pf *pf, bool is_c45) +static int enetc_imdio_create(struct enetc_pf *pf) { struct device *dev = &pf->si->pdev->dev; struct enetc_mdio_priv *mdio_priv; @@ -872,7 +854,7 @@ static int enetc_imdio_init(struct enetc_pf *pf, bool is_c45) goto free_mdio_bus; } - pcs = get_phy_device(bus, 0, is_c45); + pcs = get_phy_device(bus, 0, pf->if_mode == PHY_INTERFACE_MODE_USXGMII); if (IS_ERR(pcs)) { err = PTR_ERR(pcs); dev_err(dev, "cannot get internal PCS PHY (%d)\n", err); @@ -901,6 +883,45 @@ static void enetc_imdio_remove(struct enetc_pf *pf) } } +static bool enetc_port_has_pcs(struct enetc_pf *pf) +{ + return (pf->if_mode == PHY_INTERFACE_MODE_SGMII || + pf->if_mode == PHY_INTERFACE_MODE_2500BASEX || + pf->if_mode == PHY_INTERFACE_MODE_USXGMII); +} + +static int enetc_mdiobus_create(struct enetc_pf *pf) +{ + struct device *dev = &pf->si->pdev->dev; + struct device_node *mdio_np; + int err; + + mdio_np = of_get_child_by_name(dev->of_node, "mdio"); + if (mdio_np) { + err = enetc_mdio_probe(pf, mdio_np); + + of_node_put(mdio_np); + if (err) + return err; + } + + if (enetc_port_has_pcs(pf)) { + err = enetc_imdio_create(pf); + if (err) { + enetc_mdio_remove(pf); + return err; + } + } + + return 0; +} + +static void enetc_mdiobus_destroy(struct enetc_pf *pf) +{ + enetc_mdio_remove(pf); + enetc_imdio_remove(pf); +} + static void enetc_configure_sgmii(struct phy_device *pcs) { /* SGMII spec requires tx_config_Reg[15:0] to be exactly 0x4001 @@ -940,22 +961,9 @@ static void enetc_configure_usxgmii(struct phy_device *pcs) BMCR_RESET | BMCR_ANENABLE | BMCR_ANRESTART); } -static int enetc_configure_serdes(struct enetc_ndev_priv *priv) +static void enetc_configure_serdes(struct enetc_pf *pf) { - bool is_c45 = priv->if_mode == PHY_INTERFACE_MODE_USXGMII; - struct enetc_pf *pf = enetc_si_priv(priv->si); - int err; - - if (priv->if_mode != PHY_INTERFACE_MODE_SGMII && - priv->if_mode != PHY_INTERFACE_MODE_2500BASEX && - priv->if_mode != PHY_INTERFACE_MODE_USXGMII) - return 0; - - err = enetc_imdio_init(pf, is_c45); - if (err) - return err; - - switch (priv->if_mode) { + switch (pf->if_mode) { case PHY_INTERFACE_MODE_SGMII: enetc_configure_sgmii(pf->pcs); break; @@ -966,18 +974,9 @@ static int enetc_configure_serdes(struct enetc_ndev_priv *priv) enetc_configure_usxgmii(pf->pcs); break; default: - dev_err(&pf->si->pdev->dev, "Unsupported link mode %s\n", - phy_modes(priv->if_mode)); + dev_dbg(&pf->si->pdev->dev, "Unsupported link mode %s\n", + phy_modes(pf->if_mode)); } - - return 0; -} - -static void enetc_teardown_serdes(struct enetc_ndev_priv *priv) -{ - struct enetc_pf *pf = enetc_si_priv(priv->si); - - enetc_imdio_remove(pf); } static int enetc_pf_probe(struct pci_dev *pdev, @@ -1052,9 +1051,8 @@ static int enetc_pf_probe(struct pci_dev *pdev, if (err) goto err_mdiobus_create; - err = enetc_configure_serdes(priv); - if (err) - goto err_configure_serdes; + if (enetc_port_has_pcs(pf)) + enetc_configure_serdes(pf); enetc_mac_config(&pf->si->hw, pf->if_mode); } @@ -1068,8 +1066,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, return 0; err_reg_netdev: - enetc_teardown_serdes(priv); -err_configure_serdes: enetc_mdiobus_destroy(pf); err_mdiobus_create: enetc_of_put_phy(pf); @@ -1094,7 +1090,6 @@ static void enetc_pf_remove(struct pci_dev *pdev) struct enetc_ndev_priv *priv; priv = netdev_priv(si->ndev); - enetc_teardown_serdes(priv); enetc_mdiobus_destroy(pf); enetc_of_put_phy(pf); From patchwork Mon Oct 5 14:28:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 268096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C213C4363D for ; Mon, 5 Oct 2020 14:28:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF82C2078A for ; Mon, 5 Oct 2020 14:28:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="JDmBbgW1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbgJEO2k (ORCPT ); Mon, 5 Oct 2020 10:28:40 -0400 Received: from mail-eopbgr80071.outbound.protection.outlook.com ([40.107.8.71]:38417 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726517AbgJEO2j (ORCPT ); Mon, 5 Oct 2020 10:28:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BsErwRrTJhNGvPgT+4uQFnLA2KUrKWEd2JtXsQLYXnz0RmMWFs3dBt7ElkLjInxIbiIMQ1sgkCdes6x39iRI8ELEEaNRCXLDlZJl0E+P3tehvqvFcnLQOtItVh9WkXctC7JhAYZsXu3Fumjvuw+T2hgbV5VWhqYT829sQIBTW3NnbKi0Is2/RRKxotMvmPEPFr0oZDnp01KKHM9Cxvu/O2N+DBMRsrn9atCUTfvfLbncsg8u8Q5NsIZcMiyricufbKZN/d8Gktci2F+B8w/aDnqX34qz9mCPAshIVkOL0uaPA0Bgx5D1wRL3eO9ueFJMAP1KH1vb355CHngwRu493A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HTQ9hk2lIWvd6+3g25p/mO5ho2/BmpM74MlW+kdADy8=; b=KU+bFgdBcZI5eb6UcDDOcGu3B8nlGfQv73+YZevCMptSBEFdm29p8qH+0KCKsnibWIfQmPDdu8PYDebACExAmxsBshc0Oo/Y6bIrmVRSWDs0PZiid6qEbQsg4QkBd1SAXJTPbzhaR8QXSQo0w0z9E8MNrrFIda8NaTtSRLC28RvVPLX9Tkp+Em6cNPOqKM1vqGoqhemGC+Iu7mj+xoXQsHJAyWYdi6KrjcyL4tY9as9jIZt0ZnLa+GMehRnyVhKN92NexcE2TWUxIVdqfBWSBeTmig9c0loOptKAqY2u70sis7JA8VS5vB5ybjV7ziNfEvRDvNkap4kUD54Qk8rDrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HTQ9hk2lIWvd6+3g25p/mO5ho2/BmpM74MlW+kdADy8=; b=JDmBbgW1coQC9siIuvenbsf6yn807wCpFalmCUlCortG77kyXok+IxIZrp0nb84FyRsKkVSOK2ApnhsqSlY1Bea2P2k+5hnNk3Nx1yVfqNuDanyRk/zND+yRTCSdOxhqvDWk2qZP+2fgDFlCBmuTlxgvW9BEBmWBFRjzztFp//Y= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) by AM0PR04MB6180.eurprd04.prod.outlook.com (2603:10a6:208:140::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Mon, 5 Oct 2020 14:28:34 +0000 Received: from AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b]) by AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b%3]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 14:28:34 +0000 From: Claudiu Manoil To: netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Russell King , Vladimir Oltean Subject: [PATCH net-next 3/4] arm64: dts: fsl-ls1028a-rdb: Specify in-band mode for ENETC port 0 Date: Mon, 5 Oct 2020 17:28:17 +0300 Message-Id: <20201005142818.15110-4-claudiu.manoil@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005142818.15110-1-claudiu.manoil@nxp.com> References: <20201005142818.15110-1-claudiu.manoil@nxp.com> X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) To AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15141.swis.ro-buh01.nxp.com (83.217.231.2) by AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.37 via Frontend Transport; Mon, 5 Oct 2020 14:28:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0d58267a-d16a-4eb8-d5dd-08d8693af0c0 X-MS-TrafficTypeDiagnostic: AM0PR04MB6180: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3+hXaY4Z564X31NTpp1sjWAJOVtXww0WjndotqlHMqsB3aUJxTxxKludplPw0Exe3RZg3XEKSs6RCCC1sx78796+l0HG2FcJS5PCi1KKmNiwdmUv1qP5RTN/lsBRNA/gZTG+76mbZz8p5XlyH2MgDR5/OhJQBBKuYWQP/lli9UrD8nFt76d1QRV6RUbO/LNgH9Zgd5d4UpOhK5y+3zrczvmCnhDnz4GYVoWeS4y0MLFRk2Bj9rWYL8ULLqaFaJAzMxVYj1YQGLOvXif9D4muLPKizPIeofVygXdd4jYmsRejsRNfdofD11cGFKdAU1GI35dytVUyKMKScvKWUz3ztQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6754.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(478600001)(316002)(86362001)(4744005)(54906003)(44832011)(5660300002)(66946007)(66556008)(1076003)(66476007)(8676002)(6666004)(36756003)(956004)(2616005)(6486002)(4326008)(7696005)(2906002)(52116002)(186003)(16526019)(26005)(8936002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TSMdHbJYjxuctDZ4NXYzKUTd8MxS1LC5BTx2k/cKChJMtrYd2IXECJ3DeV6B6xqDc+iHEycTQgrhYF7OXPMXWq5g3BF/sAcJHgUVNaHi+g0Y1C4gxCbajvMSIWEVq2uahTKHEY1gIWaZ+ulZD+8s2wBZTrhR0xuF6tOLFwr/j1AIsY5eSyguWOrepSIxNvS8nQ1hsY+U/4NyyoiJ+XsVOxx4e5JGBMw7qZddiGhD3EArdaYYoin22FNpuC8xCK1wS1YC/tku7dd+8xoqXQg0dryW8dxanZEh+3iQcXtZzRE2QLw+Ratv0/4svBEKWHrANLYTTUNBa2u5nHfmIQArCa4gKo7zqG4vADlyyjxqUdD/gyvu7z2nSNUP6GUjeu3ZzyDxjwxmb5bYFDPl0/CJ0HyJFjGtnDH0+Uq3dZP+wOCbMbOQLPKaNvjB1CSikBLRSi7dq1SOgB1nLnUEmq9jMMMUGE3ucw7eW3gySUuFDbiGdEd3iohCEMlldYoU6/VXJDe+EPIuwAgMs+lXMJA2Q5f1IRi7chcYx0sL/94AvJSlwHfUZ/YI6ilEexS8r6zNxjTsxMYMgNQVrCqt3SrpGXiO2BeMwcaPu1uPXfyvV8d/FAD20ALO6LyLLT1rysgFjYdvGQerE/A7gRvQjsjHwg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d58267a-d16a-4eb8-d5dd-08d8693af0c0 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6754.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 14:28:34.3922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +SNIb84YF6soR028qbvKiF/LNnS6S4eYhluXduOt4FWiKnaBMO33tRXk3XztJR+p8p1Hvp1epkEJ9t2zRTYYbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6180 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As part of the transition of the enetc ethernet driver from phylib to phylink, the in-band operation mode of the SGMII interface from enetc port 0 needs to be specified explicitly for phylink. Signed-off-by: Claudiu Manoil --- arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dts b/arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dts index c2dc1232f93f..1efb61cff454 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dts +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dts @@ -199,6 +199,7 @@ &enetc_port0 { phy-handle = <&sgmii_phy0>; phy-connection-type = "sgmii"; + managed = "in-band-status"; status = "okay"; mdio { From patchwork Mon Oct 5 14:28:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 288988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F2ADC4363D for ; Mon, 5 Oct 2020 14:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46D0820776 for ; Mon, 5 Oct 2020 14:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="EwlR+Ht+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726590AbgJEO2t (ORCPT ); Mon, 5 Oct 2020 10:28:49 -0400 Received: from mail-eopbgr80071.outbound.protection.outlook.com ([40.107.8.71]:38417 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726525AbgJEO2n (ORCPT ); Mon, 5 Oct 2020 10:28:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFP7lXcczqeY1rC/HNela6dP2bbDxjvGL51PzuBkj3T7Qs38RRV7SZD93rM3RRQgvHdzDhxxC3c/Mf/9x25dP0S0Hi0B6APkqRiHe+pDE/Jmj5gOZJPyOvwHW+H5sOv8rQeQjA3vsmztzR9PItVdHdCRsVAYMhKuplEegdJ+oI6e+GLyWy1szvTn9N9cXvs2eijW1Yzf0xn5NgWxs83TJfxeIchuL+JPVUG1zOx4z+QGu0dLxeObKCNgDniWbVXA5n/jjVYojlgX1+Tlr5oigTgJQPRWggVB30gBsqmfRgBUPS8lZ7eAVEzwy9sAxfyAlRqBh+ZiZ2jEhe9Al79dxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=31px3i2u4NMUF8CVDYfk4i1Hc8ftc/FZYbamIdNKmy0=; b=Tx/GpTbjf3Sp5X773FsJEkCsjLAF5gMypLZzUZKCmCBPGGv4h7Rstj8QJDp/3ChGYi9/bgWWoqskAnTAftghfPdDG7Iezg1uE8q2TlTf66WjRbLG3pJSrqxCbPOrF2a8EFNXFRqtDIb69MZ240EiF8DXrAb4HNZS7+sTBrrFD1gJ5Zt3uhI+nuo4dG5TtNW7SlpwyaTfyfI+kP+J4ydMYweW3n/X9V7XJlkHtOj5x5+oU2rMhcqiM+DtF0caofd3GlvFR1QjrImtHatOiOR2dkrwO/dblgH8mqFpYICHT3oS8f1bYRGsvpykQuFHS9aB01v+Eoc6NPniy21DvC2cDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=31px3i2u4NMUF8CVDYfk4i1Hc8ftc/FZYbamIdNKmy0=; b=EwlR+Ht+dH34vIwX952MNYGQ3bHIuy75cplHoeM8dlDAjAe2bNi+SaVAXQVkzKmsKjQPDRcJVP5HMYt2nQ3i2oAzsryfv8fSkkn7cdAWMxxVq9B8aRUQOGaBacBvx2La1QG3b1SqCeOwpaxlR6zvog4IGa+KpJhfn98POVHBUSc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) by AM0PR04MB6180.eurprd04.prod.outlook.com (2603:10a6:208:140::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Mon, 5 Oct 2020 14:28:35 +0000 Received: from AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b]) by AM0PR04MB6754.eurprd04.prod.outlook.com ([fe80::21b9:fda3:719f:f37b%3]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 14:28:35 +0000 From: Claudiu Manoil To: netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Russell King , Vladimir Oltean Subject: [PATCH net-next 4/4] enetc: Migrate to PHYLINK and PCS_LYNX Date: Mon, 5 Oct 2020 17:28:18 +0300 Message-Id: <20201005142818.15110-5-claudiu.manoil@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005142818.15110-1-claudiu.manoil@nxp.com> References: <20201005142818.15110-1-claudiu.manoil@nxp.com> X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) To AM0PR04MB6754.eurprd04.prod.outlook.com (2603:10a6:208:170::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15141.swis.ro-buh01.nxp.com (83.217.231.2) by AM0PR04CA0060.eurprd04.prod.outlook.com (2603:10a6:208:1::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.37 via Frontend Transport; Mon, 5 Oct 2020 14:28:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3c55d578-695e-4160-4b88-08d8693af13b X-MS-TrafficTypeDiagnostic: AM0PR04MB6180: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eJOMFZEPHaAnBEb0lm+oOIWpiUqURaoKn0MmrmHW0H9wm2Io6vG533cbzYvtyKwRjrV+wkuQcY3wYtgEXnEpi6OC8PWnUva0bsfkXk8VLHcLp3aS0hzHEPR47zYZWnDwDZBSw4nwTz790XxSrFx4mvN6CqgBHpuebBUNa8qDKnR2igB5a2sRdPxB6WTP7/OgfiW7dp7XnZw2PC0aU9DXHjrLImy+sfCeIOpMXuF1snlAwC7Umhvly0bkbVJA0zSq8+Jfg8dpfMqrP67Jnt/xn0bBSK3x8+dIq8n8y21FbRTFBG1WZ1+hIO41ObNvV41AmEdvsnnNdYnMnpKlVDdeEg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6754.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(478600001)(316002)(86362001)(54906003)(44832011)(5660300002)(66946007)(66556008)(1076003)(83380400001)(66476007)(30864003)(8676002)(6666004)(36756003)(956004)(2616005)(6486002)(4326008)(7696005)(2906002)(52116002)(186003)(16526019)(26005)(8936002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: KR+TMH4SqltXK8xpBMySOt+zBKKb4neHGJe2bBAwKeXqLyedVP0oj1Ub9zFB6ZO2NWDUY6KtL8Z2AyNjNmVsArpoNa9yJWD7yIvVpHlKXrN8KoEL+34TR6BrBWixiPzJNs7RzhFoi+evoABg/4S31qd+5BSlbiQMfAlZ+ehP6Br3qssx6FYxBj7HLQGGkCy6drEv9p6hFtowIv4QST8uv/hGxXSRYx1H7NwyWkhT1Zx1foMA9Xmyo1nn4x9BG1cFWJLJrPMeAjFzVjJG8NhQS/vqI8mx1g/K5no1kRNSN27jgadV7L7sWBumzK4e+L7gCyY2g9bIFKIryFv7JclwaMEh8uxo1YYIDc5ak9Pvt2AZ70XD03lc7sYpXpTFVpQMlizVFje1Vpn+zBcy1zq24P2bBuvehkTvEvUd7usb8x4t0c+bRUI3jOfhqs3yFbLG6mfuKyztaLDo8kNTrgJNvy12hgi02oahPd2+b4UOJAP4XAnpRQfwW3a8medLz72RroZc49ZJQH3jj/74a3OL+bf33P57QLoTRKHaUxYvCkYaDLgpSZJF6FHMR+hlcWgElUsn4mO2hpmIW6GsWiOvC4htEnuzsc1DiSTtIr4159/3aZwWyuVN+uD2pSTSL6Xt+5x91XKZrXlbqnNBKhmKKA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c55d578-695e-4160-4b88-08d8693af13b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6754.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 14:28:35.2837 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1oKZD+rMK2+9+xKFVw/z6qKLxJIE91x1ZKL0oiIH3AQRbghfxHzCvdr6D1pSF9sH1cmZO0vd9QECnIhmf9/uuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6180 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a methodical transition of the driver from phylib to phylink, following the guidelines from sfp-phylink.rst. The MAC register configurations based on interface mode were moved from the probing path to the mac_config() hook. MAC enable and disable commands (enabling Rx and Tx paths at MAC level) were also extracted and assigned to their corresponding phylink hooks. As part of the migration to phylink, the serdes configuration from the driver was offloaded to the PCS_LYNX module, introduced in commit 0da4c3d393e4 ("net: phy: add Lynx PCS module"), the PCS_LYNX module being a mandatory component required to make the enetc driver work with phylink. Signed-off-by: Claudiu Manoil --- drivers/net/ethernet/freescale/enetc/Kconfig | 5 +- drivers/net/ethernet/freescale/enetc/enetc.c | 53 ++-- drivers/net/ethernet/freescale/enetc/enetc.h | 9 +- .../ethernet/freescale/enetc/enetc_ethtool.c | 26 +- .../net/ethernet/freescale/enetc/enetc_pf.c | 246 +++++++++--------- .../net/ethernet/freescale/enetc/enetc_pf.h | 8 +- .../net/ethernet/freescale/enetc/enetc_qos.c | 9 +- 7 files changed, 190 insertions(+), 166 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/Kconfig b/drivers/net/ethernet/freescale/enetc/Kconfig index 37b804f8bd76..0fa18b00c49b 100644 --- a/drivers/net/ethernet/freescale/enetc/Kconfig +++ b/drivers/net/ethernet/freescale/enetc/Kconfig @@ -3,7 +3,8 @@ config FSL_ENETC tristate "ENETC PF driver" depends on PCI && PCI_MSI select FSL_ENETC_MDIO - select PHYLIB + select PHYLINK + select PCS_LYNX select DIMLIB help This driver supports NXP ENETC gigabit ethernet controller PCIe @@ -15,7 +16,7 @@ config FSL_ENETC config FSL_ENETC_VF tristate "ENETC VF driver" depends on PCI && PCI_MSI - select PHYLIB + select PHYLINK select DIMLIB help This driver supports NXP ENETC gigabit ethernet controller PCIe diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index f78ca7b343d2..52be6e315752 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -4,7 +4,6 @@ #include "enetc.h" #include #include -#include #include /* ENETC overhead: optional extension BD + 1 BD gap */ @@ -1392,38 +1391,24 @@ static void enetc_clear_interrupts(struct enetc_ndev_priv *priv) enetc_rxbdr_wr(&priv->si->hw, i, ENETC_RBIER, 0); } -static void adjust_link(struct net_device *ndev) +static int enetc_phylink_connect(struct net_device *ndev) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct phy_device *phydev = ndev->phydev; - - if (priv->active_offloads & ENETC_F_QBV) - enetc_sched_speed_set(ndev); - - phy_print_status(phydev); -} - -static int enetc_phy_connect(struct net_device *ndev) -{ - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct phy_device *phydev; struct ethtool_eee edata; + int err; - if (!priv->phy_node) + if (!priv->phylink) return 0; /* phy-less mode */ - phydev = of_phy_connect(ndev, priv->phy_node, &adjust_link, - 0, priv->if_mode); - if (!phydev) { + err = phylink_of_phy_connect(priv->phylink, priv->dev->of_node, 0); + if (err) { dev_err(&ndev->dev, "could not attach to PHY\n"); - return -ENODEV; + return err; } - phy_attached_info(phydev); - /* disable EEE autoneg, until ENETC driver supports it */ memset(&edata, 0, sizeof(struct ethtool_eee)); - phy_ethtool_set_eee(phydev, &edata); + phylink_ethtool_set_eee(priv->phylink, &edata); return 0; } @@ -1443,8 +1428,8 @@ void enetc_start(struct net_device *ndev) enable_irq(irq); } - if (ndev->phydev) - phy_start(ndev->phydev); + if (priv->phylink) + phylink_start(priv->phylink); else netif_carrier_on(ndev); @@ -1460,7 +1445,7 @@ int enetc_open(struct net_device *ndev) if (err) return err; - err = enetc_phy_connect(ndev); + err = enetc_phylink_connect(ndev); if (err) goto err_phy_connect; @@ -1490,8 +1475,8 @@ int enetc_open(struct net_device *ndev) err_alloc_rx: enetc_free_tx_resources(priv); err_alloc_tx: - if (ndev->phydev) - phy_disconnect(ndev->phydev); + if (priv->phylink) + phylink_disconnect_phy(priv->phylink); err_phy_connect: enetc_free_irqs(priv); @@ -1514,8 +1499,8 @@ void enetc_stop(struct net_device *ndev) napi_disable(&priv->int_vector[i]->napi); } - if (ndev->phydev) - phy_stop(ndev->phydev); + if (priv->phylink) + phylink_stop(priv->phylink); else netif_carrier_off(ndev); @@ -1529,8 +1514,8 @@ int enetc_close(struct net_device *ndev) enetc_stop(ndev); enetc_clear_bdrs(priv); - if (ndev->phydev) - phy_disconnect(ndev->phydev); + if (priv->phylink) + phylink_disconnect_phy(priv->phylink); enetc_free_rxtx_rings(priv); enetc_free_rx_resources(priv); enetc_free_tx_resources(priv); @@ -1780,6 +1765,7 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr) int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) { + struct enetc_ndev_priv *priv = netdev_priv(ndev); #ifdef CONFIG_FSL_ENETC_PTP_CLOCK if (cmd == SIOCSHWTSTAMP) return enetc_hwtstamp_set(ndev, rq); @@ -1787,9 +1773,10 @@ int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) return enetc_hwtstamp_get(ndev, rq); #endif - if (!ndev->phydev) + if (!priv->phylink) return -EOPNOTSUPP; - return phy_mii_ioctl(ndev->phydev, rq, cmd); + + return phylink_mii_ioctl(priv->phylink, rq, cmd); } int enetc_alloc_msix(struct enetc_ndev_priv *priv) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index d309803cfeb6..dd0fb0c066d7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "enetc_hw.h" @@ -264,8 +264,7 @@ struct enetc_ndev_priv { struct psfp_cap psfp_cap; - struct device_node *phy_node; - phy_interface_t if_mode; + struct phylink *phylink; int ic_mode; u32 tx_ictt; }; @@ -323,7 +322,7 @@ int enetc_send_cmd(struct enetc_si *si, struct enetc_cbd *cbd); #ifdef CONFIG_FSL_ENETC_QOS int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data); -void enetc_sched_speed_set(struct net_device *ndev); +void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed); int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data); int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data); int enetc_setup_tc_block_cb(enum tc_setup_type type, void *type_data, @@ -388,7 +387,7 @@ static inline int enetc_psfp_disable(struct enetc_ndev_priv *priv) #else #define enetc_setup_tc_taprio(ndev, type_data) -EOPNOTSUPP -#define enetc_sched_speed_set(ndev) (void)0 +#define enetc_sched_speed_set(priv, speed) (void)0 #define enetc_setup_tc_cbs(ndev, type_data) -EOPNOTSUPP #define enetc_setup_tc_txtime(ndev, type_data) -EOPNOTSUPP #define enetc_setup_tc_psfp(ndev, type_data) -EOPNOTSUPP diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index 1dab83fbca77..8ed1ebd5a183 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -686,6 +686,28 @@ static int enetc_set_wol(struct net_device *dev, return ret; } +static int enetc_get_link_ksettings(struct net_device *dev, + struct ethtool_link_ksettings *cmd) +{ + struct enetc_ndev_priv *priv = netdev_priv(dev); + + if (!priv->phylink) + return -EOPNOTSUPP; + + return phylink_ethtool_ksettings_get(priv->phylink, cmd); +} + +static int enetc_set_link_ksettings(struct net_device *dev, + const struct ethtool_link_ksettings *cmd) +{ + struct enetc_ndev_priv *priv = netdev_priv(dev); + + if (!priv->phylink) + return -EOPNOTSUPP; + + return phylink_ethtool_ksettings_set(priv->phylink, cmd); +} + static const struct ethtool_ops enetc_pf_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES | @@ -704,8 +726,8 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = { .get_ringparam = enetc_get_ringparam, .get_coalesce = enetc_get_coalesce, .set_coalesce = enetc_set_coalesce, - .get_link_ksettings = phy_ethtool_get_link_ksettings, - .set_link_ksettings = phy_ethtool_set_link_ksettings, + .get_link_ksettings = enetc_get_link_ksettings, + .set_link_ksettings = enetc_set_link_ksettings, .get_link = ethtool_op_get_link, .get_ts_info = enetc_get_ts_info, .get_wol = enetc_get_wol, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 6c533bf9e615..3473ce90f6c7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -499,8 +499,6 @@ static void enetc_configure_port_mac(struct enetc_hw *hw) static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode) { - u32 val; - /* set auto-speed for RGMII */ if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG || phy_interface_mode_is_rgmii(phy_mode)) @@ -508,14 +506,17 @@ static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode) if (phy_mode == PHY_INTERFACE_MODE_USXGMII) enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII); +} + +static void enetc_mac_enable(struct enetc_hw *hw, bool en) +{ + u32 val = enetc_port_rd(hw, ENETC_PM0_CMD_CFG); - /* enable Rx and Tx */ - val = enetc_port_rd(hw, ENETC_PM0_CMD_CFG); - enetc_port_wr(hw, ENETC_PM0_CMD_CFG, - val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + val &= ~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + val |= en ? (ENETC_PM0_TX_EN | ENETC_PM0_RX_EN) : 0; - enetc_port_wr(hw, ENETC_PM1_CMD_CFG, - val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + enetc_port_wr(hw, ENETC_PM0_CMD_CFG, val); + enetc_port_wr(hw, ENETC_PM1_CMD_CFG, val); } static void enetc_configure_port_pmac(struct enetc_hw *hw) @@ -781,56 +782,12 @@ static void enetc_mdio_remove(struct enetc_pf *pf) mdiobus_unregister(pf->mdio); } -static int enetc_of_get_phy(struct enetc_pf *pf) -{ - struct device *dev = &pf->si->pdev->dev; - struct device_node *np = dev->of_node; - int err; - - pf->phy_node = of_parse_phandle(np, "phy-handle", 0); - if (!pf->phy_node) { - if (!of_phy_is_fixed_link(np)) { - dev_dbg(dev, "PHY not specified\n"); - return 0; - } - - err = of_phy_register_fixed_link(np); - if (err < 0) { - dev_err(dev, "fixed link registration failed\n"); - return err; - } - - pf->phy_node = of_node_get(np); - } - - err = of_get_phy_mode(np, &pf->if_mode); - if (err) { - dev_err(dev, "missing phy type\n"); - of_node_put(pf->phy_node); - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - - return -EINVAL; - } - - return 0; -} - -static void enetc_of_put_phy(struct enetc_pf *pf) -{ - struct device_node *np = pf->si->pdev->dev.of_node; - - if (np && of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - if (pf->phy_node) - of_node_put(pf->phy_node); -} - static int enetc_imdio_create(struct enetc_pf *pf) { struct device *dev = &pf->si->pdev->dev; struct enetc_mdio_priv *mdio_priv; - struct phy_device *pcs; + struct lynx_pcs *pcs_lynx; + struct mdio_device *pcs; struct mii_bus *bus; int err; @@ -854,15 +811,23 @@ static int enetc_imdio_create(struct enetc_pf *pf) goto free_mdio_bus; } - pcs = get_phy_device(bus, 0, pf->if_mode == PHY_INTERFACE_MODE_USXGMII); + pcs = mdio_device_create(bus, 0); if (IS_ERR(pcs)) { err = PTR_ERR(pcs); - dev_err(dev, "cannot get internal PCS PHY (%d)\n", err); + dev_err(dev, "cannot create pcs (%d)\n", err); + goto unregister_mdiobus; + } + + pcs_lynx = lynx_pcs_create(pcs); + if (!pcs_lynx) { + mdio_device_free(pcs); + err = -ENOMEM; + dev_err(dev, "cannot create lynx pcs (%d)\n", err); goto unregister_mdiobus; } pf->imdio = bus; - pf->pcs = pcs; + pf->pcs = pcs_lynx; return 0; @@ -875,8 +840,10 @@ static int enetc_imdio_create(struct enetc_pf *pf) static void enetc_imdio_remove(struct enetc_pf *pf) { - if (pf->pcs) - put_device(&pf->pcs->mdio.dev); + if (pf->pcs) { + mdio_device_free(pf->pcs->mdio); + lynx_pcs_destroy(pf->pcs); + } if (pf->imdio) { mdiobus_unregister(pf->imdio); mdiobus_free(pf->imdio); @@ -922,61 +889,118 @@ static void enetc_mdiobus_destroy(struct enetc_pf *pf) enetc_imdio_remove(pf); } -static void enetc_configure_sgmii(struct phy_device *pcs) +static void enetc_pl_mac_validate(struct phylink_config *config, + unsigned long *supported, + struct phylink_link_state *state) { - /* SGMII spec requires tx_config_Reg[15:0] to be exactly 0x4001 - * for the MAC PCS in order to acknowledge the AN. - */ - phy_write(pcs, MII_ADVERTISE, ADVERTISE_SGMII | ADVERTISE_LPACK); + struct enetc_pf *pf = phylink_to_enetc_pf(config); + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; + + if (state->interface != PHY_INTERFACE_MODE_NA && + state->interface != pf->if_mode) { + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return; + } - phy_write(pcs, ENETC_PCS_IF_MODE, - ENETC_PCS_IF_MODE_SGMII_EN | - ENETC_PCS_IF_MODE_USE_SGMII_AN); + phylink_set_port_modes(mask); + phylink_set(mask, Autoneg); + phylink_set(mask, Pause); + phylink_set(mask, Asym_Pause); + phylink_set(mask, 10baseT_Half); + phylink_set(mask, 10baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 100baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 1000baseT_Half); + phylink_set(mask, 1000baseT_Full); + + if (state->interface == PHY_INTERFACE_MODE_INTERNAL || + state->interface == PHY_INTERFACE_MODE_2500BASEX || + state->interface == PHY_INTERFACE_MODE_USXGMII) { + phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full); + } - /* Adjust link timer for SGMII */ - phy_write(pcs, ENETC_PCS_LINK_TIMER1, ENETC_PCS_LINK_TIMER1_VAL); - phy_write(pcs, ENETC_PCS_LINK_TIMER2, ENETC_PCS_LINK_TIMER2_VAL); + bitmap_and(supported, supported, mask, + __ETHTOOL_LINK_MODE_MASK_NBITS); + bitmap_and(state->advertising, state->advertising, mask, + __ETHTOOL_LINK_MODE_MASK_NBITS); +} - phy_write(pcs, MII_BMCR, BMCR_ANRESTART | BMCR_ANENABLE); +static void enetc_pl_mac_config(struct phylink_config *config, + unsigned int mode, + const struct phylink_link_state *state) +{ + struct enetc_pf *pf = phylink_to_enetc_pf(config); + struct enetc_ndev_priv *priv; + + enetc_mac_config(&pf->si->hw, state->interface); + + priv = netdev_priv(pf->si->ndev); + if (pf->pcs) + phylink_set_pcs(priv->phylink, &pf->pcs->pcs); } -static void enetc_configure_2500basex(struct phy_device *pcs) +static void enetc_pl_mac_link_up(struct phylink_config *config, + struct phy_device *phy, unsigned int mode, + phy_interface_t interface, int speed, + int duplex, bool tx_pause, bool rx_pause) { - phy_write(pcs, ENETC_PCS_IF_MODE, - ENETC_PCS_IF_MODE_SGMII_EN | - ENETC_PCS_IF_MODE_SGMII_SPEED(ENETC_PCS_SPEED_2500)); + struct enetc_pf *pf = phylink_to_enetc_pf(config); + struct enetc_ndev_priv *priv; - phy_write(pcs, MII_BMCR, BMCR_SPEED1000 | BMCR_FULLDPLX | BMCR_RESET); + priv = netdev_priv(pf->si->ndev); + if (priv->active_offloads & ENETC_F_QBV) + enetc_sched_speed_set(priv, speed); + + enetc_mac_enable(&pf->si->hw, true); } -static void enetc_configure_usxgmii(struct phy_device *pcs) +static void enetc_pl_mac_link_down(struct phylink_config *config, + unsigned int mode, + phy_interface_t interface) { - /* Configure device ability for the USXGMII Replicator */ - phy_write_mmd(pcs, MDIO_MMD_VEND2, MII_ADVERTISE, - ADVERTISE_SGMII | ADVERTISE_LPACK | - MDIO_USXGMII_FULL_DUPLEX); - - /* Restart PCS AN */ - phy_write_mmd(pcs, MDIO_MMD_VEND2, MII_BMCR, - BMCR_RESET | BMCR_ANENABLE | BMCR_ANRESTART); + struct enetc_pf *pf = phylink_to_enetc_pf(config); + + enetc_mac_enable(&pf->si->hw, false); } -static void enetc_configure_serdes(struct enetc_pf *pf) +static const struct phylink_mac_ops enetc_mac_phylink_ops = { + .validate = enetc_pl_mac_validate, + .mac_config = enetc_pl_mac_config, + .mac_link_up = enetc_pl_mac_link_up, + .mac_link_down = enetc_pl_mac_link_down, +}; + +static int enetc_phylink_create(struct enetc_ndev_priv *priv) { - switch (pf->if_mode) { - case PHY_INTERFACE_MODE_SGMII: - enetc_configure_sgmii(pf->pcs); - break; - case PHY_INTERFACE_MODE_2500BASEX: - enetc_configure_2500basex(pf->pcs); - break; - case PHY_INTERFACE_MODE_USXGMII: - enetc_configure_usxgmii(pf->pcs); - break; - default: - dev_dbg(&pf->si->pdev->dev, "Unsupported link mode %s\n", - phy_modes(pf->if_mode)); + struct enetc_pf *pf = enetc_si_priv(priv->si); + struct device *dev = &pf->si->pdev->dev; + struct phylink *phylink; + int err; + + pf->phylink_config.dev = &priv->ndev->dev; + pf->phylink_config.type = PHYLINK_NETDEV; + if (enetc_port_has_pcs(pf)) + pf->phylink_config.pcs_poll = true; + + phylink = phylink_create(&pf->phylink_config, + of_fwnode_handle(dev->of_node), + pf->if_mode, &enetc_mac_phylink_ops); + if (IS_ERR(phylink)) { + err = PTR_ERR(phylink); + return err; } + + priv->phylink = phylink; + + return 0; +} + +static void enetc_phylink_destroy(struct enetc_ndev_priv *priv) +{ + if (priv->phylink) + phylink_destroy(priv->phylink); } static int enetc_pf_probe(struct pci_dev *pdev, @@ -1039,37 +1063,27 @@ static int enetc_pf_probe(struct pci_dev *pdev, goto err_alloc_msix; } - err = enetc_of_get_phy(pf); - if (err) - goto err_of_get_phy; - - if (pf->phy_node) { - priv->phy_node = pf->phy_node; - priv->if_mode = pf->if_mode; - + if (!of_get_phy_mode(pdev->dev.of_node, &pf->if_mode)) { err = enetc_mdiobus_create(pf); if (err) goto err_mdiobus_create; - if (enetc_port_has_pcs(pf)) - enetc_configure_serdes(pf); - - enetc_mac_config(&pf->si->hw, pf->if_mode); + err = enetc_phylink_create(priv); + if (err) + goto err_phylink_create; } err = register_netdev(ndev); if (err) goto err_reg_netdev; - netif_carrier_off(ndev); - return 0; err_reg_netdev: + enetc_phylink_destroy(priv); +err_phylink_create: enetc_mdiobus_destroy(pf); err_mdiobus_create: - enetc_of_put_phy(pf); -err_of_get_phy: enetc_free_msix(priv); err_alloc_msix: enetc_free_si_resources(priv); @@ -1090,8 +1104,8 @@ static void enetc_pf_remove(struct pci_dev *pdev) struct enetc_ndev_priv *priv; priv = netdev_priv(si->ndev); + enetc_phylink_destroy(priv); enetc_mdiobus_destroy(pf); - enetc_of_put_phy(pf); if (pf->num_vfs) enetc_sriov_configure(pdev, 0); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h index 0d0ee91282a5..263946c51e37 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h @@ -2,6 +2,7 @@ /* Copyright 2017-2019 NXP */ #include "enetc.h" +#include #define ENETC_PF_NUM_RINGS 8 @@ -45,12 +46,15 @@ struct enetc_pf { struct mii_bus *mdio; /* saved for cleanup */ struct mii_bus *imdio; - struct phy_device *pcs; + struct lynx_pcs *pcs; - struct device_node *phy_node; phy_interface_t if_mode; + struct phylink_config phylink_config; }; +#define phylink_to_enetc_pf(config) \ + container_of((config), struct enetc_pf, phylink_config) + int enetc_msg_psi_init(struct enetc_pf *pf); void enetc_msg_psi_free(struct enetc_pf *pf); void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int mbox_id, u16 *status); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 1c4a535890da..c81be32bcedf 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -15,17 +15,14 @@ static u16 enetc_get_max_gcl_len(struct enetc_hw *hw) & ENETC_QBV_MAX_GCL_LEN_MASK; } -void enetc_sched_speed_set(struct net_device *ndev) +void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed) { - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct phy_device *phydev = ndev->phydev; u32 old_speed = priv->speed; - u32 speed, pspeed; + u32 pspeed; - if (phydev->speed == old_speed) + if (speed == old_speed) return; - speed = phydev->speed; switch (speed) { case SPEED_1000: pspeed = ENETC_PMR_PSPEED_1000M;