From patchwork Sat Sep 23 13:48:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725933 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97C4818E3A; Sat, 23 Sep 2023 13:49:31 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2050.outbound.protection.outlook.com [40.107.21.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7F51A8; Sat, 23 Sep 2023 06:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L60m+OlNp3pU5OL2U0FAFLCArE3K5ykdGIYhofDJtS56vhmIsIkan2tUeKuznGTah2OEETFLIE/3KL4INUxI1RGQJdH8M3JKJrcuSlnr2JUGmYyicMahiLzzU1hNv+Kv6yQ5KGguLbRHe8eoG9tZCsW1rrNx5HsqCB2sZ79UQ+s4HIVeI/D54Mv0CkcVr3nTil/6nkBs6rc1+EHwNsMJ86rQATrkcJ2Pht7v7mB5uqMrTr+f6RuHPc38fM3OZqQ4fRmlXXaKJCWurCKBP2JPtx3HTU3eLysys4Tu2FQ+5VcQnIs0qFXc7ni6kOamhgrnVnOv1xn+HdCuBtsCC705LQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+moDXYg7ec3f5CMV+vQmkzpE+tgU/T4ad+voqfJCMHw=; b=OBw9KzjVpuboTHDUjMQygm7ECL1YLrt7oL2h9KyBOVbxkbrHqeIZtTudgVkJaKx99ljcPD2J9Qu7ePruT+lMC2jODTDyi7WPkgT4xTWhhnkXbL9/kbugM6tBv//ejN7HfBdTI1g3JeG9TaaYX1L+eRmg0lr+ARfq7OhzzsBHMZE24jLOplg2AcWLUmm/awXD/w5CoDdmPuxlHZTIqFdvYaiMhYIBaQzETAZmgsGXZkRYDFhBQB+70xKc5NDB6DwGxpC3nKkpSIilhPPeCECsZxsBUmjtaX61a3LDORcJQasCi8cjFwZSZqyLsedJekQWk9kPYSuUHE6ZVx8VKG83pg== 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=+moDXYg7ec3f5CMV+vQmkzpE+tgU/T4ad+voqfJCMHw=; b=Y8wDkgSRvRPAQcnGXCNU/rpBbj9dGrxnpP4luVSFYZA8eRtVkim8tIlsJN9FznvgQXdRUjFoUpk1n+QMzfyL3OBdVucG8hHGN3c84UbHDCC4yOVi7BbGj2fJNiHFcD4tGYU2l6DwtsmbV6ox9LUGopPoC1I2SakDh7AexLoFbAc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB8396.eurprd04.prod.outlook.com (2603:10a6:10:24a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.25; Sat, 23 Sep 2023 13:49:23 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:23 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 01/15] phy: introduce phy_get_status() and use it to report CDR lock Date: Sat, 23 Sep 2023 16:48:50 +0300 Message-Id: <20230923134904.3627402-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB8396:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a30e01f-fbdd-4dbb-3fbd-08dbbc3be4d5 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6EoJlGk6DYpyl7hzWVTIZJemEiPR+yIkzT+V2dKsEljcg54Sdvfeb0/TEwTY2GL6JMoVpf2VThiwJjB/mtlWUphrscePo4+NV8+ovVq31u4qBmB9fnz8UYbrfLY5vJH65TukWerTneSyO7kE7mz+8Y39z/Yap6osaVVzEGwOc3HNGmy4gH/c+KBXFOQUfMjcu9kixeTxGvo/RN2Cmv0AUuhwpIjAN9lzZf6zXYRkvK3nTKMtl2pZQmd8m5X3Ff3pal4Y3jWf7nrOTFeqofzxbw3104t678NDTBRTB1Jjo0Phpl4QOmE8EWld0R4GsxkWtZ3ShTM5scexVjT8Vr1V1BnAxio5bzczMpRYCPYkQ6OmCfMbDyfdShnYwUYac1Tk+7uJwhd4awznIZhCwkO/qP4gJ/lumvKxDf1jkxNjfgxdL7SdaCQz+yfjx3LvDGP7+/rdWofQeQasWeVmNnvl5rJKRMJbbQgoYS2LaDnU8ERikPr9VAOohQAxLReXPuJFFv9RPi7ZCLpA76zVe8k21R9pbh2iWA4b8aHk5QcjKLBr4DMAgT9ABZBbqbt4R2w+7QdDRBJToOQwiRUaoAkpPSHFI3sPGR8w9egW2anJtJECPAguHct47RM6XeufLabP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(186009)(1800799009)(451199024)(6512007)(52116002)(6506007)(6486002)(6666004)(83380400001)(86362001)(38350700002)(38100700002)(36756003)(1076003)(2616005)(26005)(2906002)(41300700001)(316002)(7416002)(44832011)(54906003)(66946007)(66476007)(66556008)(478600001)(8936002)(4326008)(8676002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MlN8gH3d0n+lxcUvoj7TDzXiHuXWKInTOxMxz894gR66IkbWVCNr2T3D+ztRJCYmzil+VONgC9w4BlUcnsgKCmUL+LOpNhQaOIC9Oh+zvdTUPRrI6tSPnRm7/unGw2k9Io1jOYX2ppUqvXSJgq1EmvXE+Bj6SHEDSjUtyS6bWFqErsELYSzkHE1zdlH8OhM0JtT1O9M76sDeleOMgG7ULrNvrOSncd82FSZzgAHkKK7EsPS1tU1uEp7NVEmAWeWsrjfEV7bPVKWfkS0JNsRZjOl9HlHl3Xq/yysnmuI7ZWFbtSe/6LQW3G7Jm2ntLfah1MhYKVl3Zzyqtq4J0kP7M0GxHTqN2/kn8iE380AIUjbfX5AZlRjQcFg2ER8f1WBXKbGWtLN8OkFD9S1xPjYgHwanLKZKaXJ2MRFkLag+WXhTYWjMQcKrpf5zuQsX4A+tiXkAI6ut3mjQiSkc0OSlUTy4aWJsYNMTROLW7PsZy9nPzvL8JZNHdQk69F5/KJ9Mvqev1Kpqdg1OMG27UKZM/96APe4hjZOZbtqWOXlX6Umu79m5jvjE2rsStuJxwNTbRAUousGWf0C3F+HVMl1G+OTzM0Yz9HglCJMGtF8hcUaBioXiDVRxf5qHqBVNiTvf9R8T4PW3cENTB9fyGyC+rheASeq4t+ONKehoQBeLC2+R9CaN4+jtxS8tJM1WfYXL2fiZwNaC09mEgXXU+qBFHk7SOISr3YdL0h0YK6Br8dhbSW2LifcOqYH3kd5YiVkJtZSxWHp9MU9nhpNNFuArz1bRuq8hwUZyni4C+87ZmHTLf/YAg/zujsbk1MrMV6i9/6zixbO32m0dfDfOYJVfUCnvUd/FzqslW/bxTQhYO2IQBiyU6xfaOIoekXPh0Cpm4vgmsWInaxqxL/uyxOFT2nrQ6OQKwqRwhcf8YQXwF9bs3ROtZGQy9pNuhOqftUvpI/UpdnWxaKmHzqql7vh29SJMsV35oE3z+vqsEqFmG9lAr23dkYIcHEb2sIsmMI9xdAtXsDg3V5loPlqOb1Wri8FivYA9B8OMsb6XtYIArzJx8SwISTpNR4RYf5HFvjpogSsdvFRc/459AoeNGTIP7dZr8osBszOdTB5L1qbtPVJfXVQOjAUqya0xYmbW5jNNH7rfsweoRg39g9SXamifPh2D+JarTaP3NojLba16HZoEnMQhSa2QSeDVLw9BbUswk0UcDEUCbNoLSMejcXc18qTF+hOnvcBOn1JvAnlm0/DroqGJeY3ljlNi0aWomaWmRRvakny1cafmI8zNxSMx91C4Rf8hk37DW7+1RzaIlrkf6VcoXwbyAMt5UrYgn3txi2xwD14NMQGtS4g3a4BfwDOKky5OIvmuX61I5fEjBADL/5JuTWZRAdWSxv7SKmoFUMoVhqsFMIB1tdaQDlfALHDBVEaS7D5otX9QwfIH4Jbbc+6PkDNntDI2DNNfnekP3jPO6xI6byN+Pqzjopjl3GwtU8PcuF7khgRuwTTQt96Xct0BSnokcUx54kiRezow1eHVzCukZG9DER95wUST/prsZEzZHm0ylxXYPXi4IH5ViisRTIu6X6s5OeertsVgVKLCur9DeBgbTcXPR4CkXQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a30e01f-fbdd-4dbb-3fbd-08dbbc3be4d5 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:23.2797 (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: W+bvc7lu8SUQM6Mnw3bZlimFdqmRifYc89RonsBBaO2/RMr7190jVX56gOVFr3Nv1MZ86qNNM3ZxvOOcmUjsGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8396 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Some modules, like the MTIP AN/LT block used as a copper backplane PHY driver, need this extra information from the SerDes PHY as another source of "link up" information. Namely, the 25GBase-R PCS does not have a MDIO_CTRL1_LPOWER bit implemented in its MDIO_MMD_PCS:MDIO_CTRL1 register. That bit is typically set from phy_suspend() or phylink_pcs_disable() implementations, and that is supposed to cause a link drop event on the link partner. But here it does not happen. By implementing the networking phylink_pcs_disable() as phy_power_off(), we are able to actually power down the lane in a way that is visible to the remote end. Where it is visible is the CDR lock, so we introduce PHY_STATUS_TYPE_CDR_LOCK as an extra link indication, we are able to detect that condition and signal it to upper layers of the network stack. A more high-level and generic phy_get_status() operation was chosen instead of the more specific phy_get_cdr_lock() alternative, because I saw this as being more in the spirit of the generic PHY API. Also, phy_get_status() is more extensible and reusable for other purposes as well. Signed-off-by: Vladimir Oltean --- v1->v2: reimplement phy_check_cdr_lock() as something more generic drivers/phy/phy-core.c | 31 ++++++++++++++++++++++++++ include/linux/phy/phy.h | 49 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 96a0b1e111f3..3b7e04a59a00 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -553,6 +553,37 @@ int phy_validate(struct phy *phy, enum phy_mode mode, int submode, } EXPORT_SYMBOL_GPL(phy_validate); +/** + * phy_get_status() - Query various parameters of a PHY + * @phy: the phy returned by phy_get() + * @type: type of the status being queried + * @opts: pointer to union of status structures, determined by type + * + * phy_init() must have been called on the phy. The status is relative to the + * current phy mode, that can be changed using phy_set_mode(). Not all status + * types may be relevant to all phy modes. + * + * Return: %0 if successful, a negative error code otherwise + */ +int phy_get_status(struct phy *phy, enum phy_status_type type, + union phy_status_opts *opts) +{ + int ret; + + if (!phy) + return -EINVAL; + + if (!phy->ops->get_status) + return -EOPNOTSUPP; + + mutex_lock(&phy->mutex); + ret = phy->ops->get_status(phy, type, opts); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_status); + /** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index f6d607ef0e80..6be348f1fa0e 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -51,6 +51,29 @@ enum phy_media { PHY_MEDIA_DAC, }; +enum phy_status_type { + /* Valid for PHY_MODE_ETHERNET */ + PHY_STATUS_CDR_LOCK, +}; + +/* If the CDR (Clock and Data Recovery) block is able to lock onto the RX bit + * stream, it means that the stream contains valid bit transitions for the + * configured protocol. This indicates that a link partner is physically + * present and powered on. + */ +struct phy_status_opts_cdr { + bool cdr_locked; +}; + +/** + * union phy_status_opts - Opaque generic phy status + * + * @cdr: Configuration set applicable for PHY_STATUS_CDR_LOCK. + */ +union phy_status_opts { + struct phy_status_opts_cdr cdr; +}; + /** * union phy_configure_opts - Opaque generic phy configuration * @@ -78,6 +101,7 @@ union phy_configure_opts { * @set_speed: set the speed of the phy (optional) * @reset: resetting the phy * @calibrate: calibrate the phy + * @get_status: get the mode-specific status of the phy * @release: ops to be performed while the consumer relinquishes the PHY * @owner: the module owner containing the ops */ @@ -122,6 +146,20 @@ struct phy_ops { union phy_configure_opts *opts); int (*reset)(struct phy *phy); int (*calibrate)(struct phy *phy); + + /** + * @get_status: + * + * Optional. + * + * Used to query the mode-specific status of the phy. Must have no side + * effects. + * + * Returns: 0 if the operation was successful, negative error code + * otherwise. + */ + int (*get_status)(struct phy *phy, enum phy_status_type type, + union phy_status_opts *opts); void (*release)(struct phy *phy); struct module *owner; }; @@ -236,6 +274,8 @@ int phy_set_speed(struct phy *phy, int speed); int phy_configure(struct phy *phy, union phy_configure_opts *opts); int phy_validate(struct phy *phy, enum phy_mode mode, int submode, union phy_configure_opts *opts); +int phy_get_status(struct phy *phy, enum phy_status_type type, + union phy_status_opts *opts); static inline enum phy_mode phy_get_mode(struct phy *phy) { @@ -414,6 +454,15 @@ static inline int phy_validate(struct phy *phy, enum phy_mode mode, int submode, return -ENOSYS; } +static inline int phy_get_status(struct phy *phy, enum phy_status_type type, + union phy_status_opts *opts) +{ + if (!phy) + return 0; + + return -ENOSYS; +} + static inline int phy_get_bus_width(struct phy *phy) { return -ENOSYS; From patchwork Sat Sep 23 13:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725932 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2483B1C6AD; Sat, 23 Sep 2023 13:49:32 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2050.outbound.protection.outlook.com [40.107.21.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A9C81A7; Sat, 23 Sep 2023 06:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FFKgXbVoJj4EaJYLNAmWJJa9qp9f9tHKGggXdk8P6FYsYvC12FMAhgiETHFtQzpQb7iGvfplzXyXxrlWquNJXVvKBwDlC8E0MHVl0JtUZuD1lip+6FdJDiCdRE/2pCbsHRSuHCu7XnFVVHCh8YKsb4dEGjbXG3X4HaURIETVF86SnXyImvwL80mqsoYJZs+mZArJCx7bjEVG/qrNHDo073VQHQc821rmnezYqKpLvyGNWBGyBRSJB0chAdax6jbSMgCta/OddZMN5D1re/YorXsoMgzJtb5+Ip0HI+18+CFCQrGvLe3h30jLU3ObBhU7C6sx0v/4eVoRdU3+U3a1+g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qigG5kUcxAwEk9WKAMwLV1yzRRj89M0MJtvmmZxb0iM=; b=U4v5VFT8f3/gsfXdabLEq1WLm+azxfl92H8f+/YbVVWmqG1pP7sS1fylW5v6sq2mpbWDqfQkZbhad8Llx6Pfh2EiuRn/z5RJZwdoCTjCNSzgqmAGF2RFs++AHFtiwGxXovJoF7aShEGaLoKlYn5CuFcFj/L+StSsuVxamcKCzFMK2R1IOTLo3MF2I/aFTs2m5RHzLTf0R0rU5Ua1Tcl/JsvLb0HynRkuTjqdIX2xrc95gEg3L/IxrSboB0h4G26ZZ1j82OdNnyvr0wHqnHN8BHR0urNRDj4bhWGXDZq3IsK4kODSEm65PTIHWYkD0Obh4VyoT9tan6G2Xcp8PZXlDQ== 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=qigG5kUcxAwEk9WKAMwLV1yzRRj89M0MJtvmmZxb0iM=; b=r4sN/v6UzCTCH+TTzJvQjk2A7uM5dockNIcyuG81N8Srq7eRs4RocDVJZLMtNeXE4HfZAz6iCIRmXDSeEI58YeU5+zn9PhwyzxmBPlv1UOKAz3Ve4v0uNNtSIhCwWvP6N1W3CJhJNpQAXHiHUQ51dw1dTvxfCn5kvduvLNK3V+U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB8396.eurprd04.prod.outlook.com (2603:10a6:10:24a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.25; Sat, 23 Sep 2023 13:49:24 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:24 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 02/15] phy: introduce the PHY_MODE_ETHTOOL mode for phy_set_mode_ext() Date: Sat, 23 Sep 2023 16:48:51 +0300 Message-Id: <20230923134904.3627402-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB8396:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ebe1571-e53a-45ba-34d9-08dbbc3be58f X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q8cdED9KtdwcPd7PrbdlBc5/lotElwqi8F9SVvwa1vcjOGjw2UVOz3iOEWPNXD4mR9/vDvdz8EKv5NyiqJPvLTc+2Tug+uBced7rxGRGci8p2/WjrCD6+gx7z+W1VFubgSS8wWgZQaNTQYbvU2ZirKLy+HxM40F1Ob0NtbS1jD1YV6OSGBF+ORhbhtBvbS4srJosqZSKbctcwKg8z7pl8j3VFn2rWblonedaPGgzs3wskG5W5wIUkyHGz1Bdzvxxhqi13otm7RNpSj/M3367ChGY4/QXKyhfaMHCtyQJ/KwhX+TuPWNgAS/UcdjBCrm/qG8uoKAj+60c2I+xl/kNEfDlC2VKb2b2NOHkskMNUlrX9nUm0va1zpbVHLVe352seNp0TAyb5lP1DN0K/iYyyBgwdo1M8Fo20axUWxhuJHwR8rD8BAZFZr4/QV3+QJadrlytGX9KYVnyYowe807s2bTzSYQCAs7htAydqZ4uPmKb4Zqn40IXIYJ2o9rPOhvNIOmGTjiOQEHOdoaKNmjwFCuXKUT698tHLWu3QcnZxmLSB1Cpi2fsjx2yKcKTmieA03F3fnqktEyIM5fxfxMcVrEN7fC+Hes2mZ/oBhDzSlXFYs48oHRhorcrc4Tt0ZCu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(186009)(1800799009)(451199024)(6512007)(52116002)(6506007)(6486002)(6666004)(83380400001)(86362001)(38350700002)(38100700002)(36756003)(1076003)(2616005)(26005)(2906002)(19627235002)(41300700001)(316002)(7416002)(44832011)(54906003)(66946007)(66476007)(66556008)(478600001)(8936002)(4326008)(8676002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R/IE8Kxf2kbD5sK49xlUaeFrEwp4sO7iBwdBoO4NBc2nXvWN7jHMNvm3hSDZ2Pdp3Lo4ycAGJMMso37omyrmR/CzqnKmhrM6SsIHtGahQv/ROCcGtSo+eNg0HbSYlA4Q7ozlaNE889PXv0jdRTee2/PwtOYP+FrUMR6IXdhENxwRPAVirCLEI2hosw56dFPM5LXj6SRMTlq29ThJylvv1bC3DvAFhzrWt8TiCvrsH6Tjf68EQ4s2ZpxgLzEs0gtPsXS3H22aBzMvnoJRRH8PoKYa1SBjCkr2/JjQhzySvrDZC+N3CJhqWSULa7/NHdTpxFMwfNIyQn6BM70p3IHx6egxAjY1c+qi9iD1HTNqFxnQFjqOqQY7IN+QTktk9wFn1X3F+QZfW9eA0UBDZLGFewXkoFT1M4VyviTl5xJFJfIT2s7DiK/B2sHezwlRlhA3j/q74tcAhKNz5MN3xo+f2mx2Q2Lp7fUJCSLxG/lJ4zAk2KlYOfIx/hdAODVbyPatlzLhuj5s8GgTBlwr4s03afXYFYKSEqH6RSXcJZkPIelFXGQrV+RYgWc+2jXTTcS+lRGrvt7mG/f3VOjkHZHo7ns9yFSPhuVYrFg4vywOIwiSCuhnnCgYHvVLdgwlTnSXw+VLlhcGBohdX32cgs4cMRNvwDYrG8bWtsTCxVMYB1R0Z2c5AqpIcCalBFidu4XChVcQ9efLmLYvxwC2kedgDfn8YO9mJd2XlZV1Nemgcj3pMCD5JtnpnDOFq053xCfX+/LM0nmsbqonfJro9mI/0ggWcPYIwpQtksOKkoKCfgQHJUQp9JVqUXaed7J60KOzdLPP0nAa6H5OywEdH8ZqB4NS1zgtJnInXCRIHwPO1yJV7gJnXSzL8Yu8i1BReFsIxdf5ITny99J6PqtxJPnVpSATQ+vykCwnmDJ6j9skrXCW8nC85tElAaTirFd6CMqFU676Je4QsI5OBvGTrvDX47ynMfFW1R9ZiElzW1LnudTTGdJp/IxnG/r9/0mfQOu4D/1k1GTLdVA6FRwfV2bD06Thk1+XWhOoyleJFR6lZmUjz28YL2Eqxp5533Oe2oRydssVd7M3lwOLVihvJKOYiXzjPkmdZwzLH66NI3X4hd1sf+95Ktcg4yNdN9KDFJmUD7DPPRv68hlJZ7SW6RGPDLD3fnnMYNGJ8Hv15YIRFq9+84RwpZ4nmqRpOOToiS2+5beFzQcSC/pyIAlgOQnQoiBj8k4mGrq6tBFpGEFgCEuNZHNVv8Ogs1LuLoMVxDTGESW17/Vo2dW3A233VLYgz/689l7ImtWKmyNvZmDoWCJMuA6Fu3Ovtx1o/h/+VpxswSZMknplqnEX3WIMyq8vieWWAdzG/2YKInKSJx634tRC/E3QDKJw8WBdcQ/hq2oeinwIYEydvB2627VJdstXhMa1J+0h/T1OwyENs06TczXvqLBXfzCV8perjm/go2KOLvtuQ76Jr0YdszwGvJhH76jlM78sZ2YXSuT2ZnuZPlTbfceV7XUYgfSWFrviC1atu9VIY4hafybfgC9P4FJND7zthwCuxgtM9BHeX81GU4lNNcvi546GXCFoaKzG9G1C8ao2p6K6qjtOP/30yNwwAg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ebe1571-e53a-45ba-34d9-08dbbc3be58f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:24.5258 (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: WN0zbgKSr7IbtrN+B24lY/U491xxOPXwrPEqQUNFdnHgRDYkvpTyHqKnjrUUOkN9AkUAn/neHovZ9Xen8ghhxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8396 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net In networking, we have 2 distinct data types: - phy_interface_t describes the link between a MAC (or MAC-side PCS) and an attached PHY or SFP cage - enum ethtool_link_mode_bit_indices describes the link between a local PHY and a remote PHY (for example, gigabit RJ45 twisted copper pairs) Currently, phy_set_mode_ext(PHY_MODE_ETHERNET) takes arguments of the phy_interface_t type, and there is no way to pass an argument of the enum ethtool_link_mode_bit_indices type. The new PHY_MODE_ETHTOOL intends to address that. It is true that there is currently some overlap between these data types, namely: phy_interface_t enum ethtool_link_mode_bit_indices ----------------------------------------------------------------- PHY_INTERFACE_MODE_10GKR ETHTOOL_LINK_MODE_10000baseKR_Full_BIT PHY_INTERFACE_MODE_1000BASEKX ETHTOOL_LINK_MODE_1000baseKX_Full_BIT but those overlaps were deemed to be mistakes, and PHY-to-PHY link modes should only be added to ethtool_link_mode_bit_indices going forward. Thus, I believe that the distinction is necessary, rather than hacking more improper PHY modes. Some of the PHY-to-PHY link modes which may be added in the future (to ethtool_link_mode_bit_indices and not to phy_interface_t) are: ETHTOOL_LINK_MODE_100000baseKP4_Full_BIT ETHTOOL_LINK_MODE_100000baseCR10_Full_BIT ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT ETHTOOL_LINK_MODE_25000baseCR_S_Full_BIT One user of PHY_MODE_ETHTOOL will be the MTIP backplane AN/LT + Lynx SerDes PHY combo, where the backplane autoneg protocol (IEEE 802.3 clause 73) selects the operating PHY-to-PHY link mode. There are electrical differences between the PHY-to-PHY backplane link modes (like ETHTOOL_LINK_MODE_10000baseKR_Full_BIT) and their non-backplane counterparts (like PHY_INTERFACE_MODE_10GBASER), namely the number of TX signal equalization taps and their configurability. This further justifies distinguishing between them in the generic PHY API. Signed-off-by: Vladimir Oltean --- v1->v2: rename PHY_MODE_ETHERNET_PHY to PHY_MODE_ETHTOOL at Russell's suggestion include/linux/phy/phy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6be348f1fa0e..72ef4afcda81 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -39,6 +39,7 @@ enum phy_mode { PHY_MODE_UFS_HS_B, PHY_MODE_PCIE, PHY_MODE_ETHERNET, + PHY_MODE_ETHTOOL, PHY_MODE_MIPI_DPHY, PHY_MODE_SATA, PHY_MODE_LVDS, @@ -52,7 +53,7 @@ enum phy_media { }; enum phy_status_type { - /* Valid for PHY_MODE_ETHERNET */ + /* Valid for PHY_MODE_ETHERNET and PHY_MODE_ETHTOOL */ PHY_STATUS_CDR_LOCK, }; From patchwork Sat Sep 23 13:48:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725930 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CEE21D529; Sat, 23 Sep 2023 13:49:34 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2050.outbound.protection.outlook.com [40.107.21.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCA3B1A6; Sat, 23 Sep 2023 06:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AsHr3Ik7ivl3eleh7H7tG64dEtjfkVGp8jAioHV51A7Qm5RNe2mvs+nY80M+awxSvZMDOzN83OYHLp6k+SDDE+88hV8Ac6UejS6vDUkjmLcrbz+xxmf8RoOEQYYl4yc0zSQ6vWsJm9SoTeWHavxx2IiPdzxfAy30frpKYHHV5UVWtMKfnR7pteYKtTdJj9S7SEXEfDAbEmg2a3e6w0LcuxZB0JyY+51mamhU71odLOwiTvupuROTTuO9pIV7M6Ibi3rf15Nw6pdG+F5SW9PNyMTYXB4I5fez12jEt0truVq2akY9u8WnZbuaRvFGSVUTFL7HISN7sfqgAD6TlXP+jw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WHG+pQCdNNfl/A3ljPjF0GmP2TBdr2IG6AJruGaKh/Y=; b=byY7Rl9DQLQ5hp7qQg/Tr9VlAJ6Mf0YGkpus+JTuTtJRR13Oke2XCZ+9DO6T5lVtdaJafzme/cy77SFqnKVRX7zL/L/mObZRyxKwBi0gXmsHaflWSfqMCvea5cvg9mgAzIYMHGQzYpRZ+vAxiVtYmetUh6wgMbUSdtQP86ZzeVGrM69OfNzxprvEqjmpCcgrt9NEHHYBnIraR2DHe7ruzVDos+72wwJ5lSufWVpW8FobCD4kiJiTfnl/A6JI07PKSeOkwjNUuskmhsukBwdrjXQSCxFiU8eLNnTS8p2PprA4iMYSSc/QpFocRsbqLpiJy6z/inBMbIoGAp1j+uJeBA== 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=WHG+pQCdNNfl/A3ljPjF0GmP2TBdr2IG6AJruGaKh/Y=; b=f+izn+7kTag5NBYWtUV500CQcutfympl8lTx8qr7LlhM/GrpkC9ZZyBn0M8Wup9LgWwRevmZr7DDEI9QOrYcX1EGbcAdS2WkKPUAAT9pE3vllRVRNg7YrsDgj43Z825PvU9D4A7nlar0tDDlIQBsisT64cF2OEI6j4eOqkmRF0Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB8396.eurprd04.prod.outlook.com (2603:10a6:10:24a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.25; Sat, 23 Sep 2023 13:49:26 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:25 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 03/15] phy: ethernet: add configuration interface for copper backplane Ethernet PHYs Date: Sat, 23 Sep 2023 16:48:52 +0300 Message-Id: <20230923134904.3627402-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB8396:EE_ X-MS-Office365-Filtering-Correlation-Id: eb6892f6-915b-45db-eeaf-08dbbc3be64d X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pC1L43cZAOIlx5oY9W7tXG7B59cgZGfUQ28ByZqiWX4+qY43ug4my8YsduvTcGMqZMbAIUIvIPrXX8t/fwoe+8xttr0Pa/3R+CkAp+4MD9rdlxpuz2LDhgfU8TTiG2Nfss90NQl4kHdeEtZvV6HWId2+NTnGjJEUyM6H8dVpv3WCOYPNrojvu54mpE1bTeDmbvEXgqlLt0yudnn90/PSyy5/UPZl8GSbgACcerpMkULGpvkrTqlHBYFYzSCm+Wzsn7AkpPFhez5Krs3q2VbMd6+imhpSRsbF4z/GX9DhjgodC10IC7u/uHsCfW2QUWmoj5VEY5yIbSO0+ZmmQvkFTP1rdhLrnK4J6WTeKHSL8mpB+UWnpUSlkzXXIAb2yDGET8UQHp9LGI8u1r3lotu0u2j0EyM2VPfsaY1XnLsCUEdyBZ6Q3/fzXgHAXPUHQsZT4vTG7lQfZ1en+kLfn8n8K+XgUetWMQOCimrPA0bp6elvOWW4XIgbpLzUuEGaw5AO3C/jwy5hh34mVAGB9CkFP1YNmWI17qChC1//U0vua7TcYmk0idw1sGBKyO87WKIupCslt6qNwYNeO2Dj4dlVhSKVxujk/UcOaOCs2sImaVDZYjurGa9xgvQgah/J6+11 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(186009)(1800799009)(451199024)(6512007)(66899024)(52116002)(6506007)(6486002)(6666004)(83380400001)(86362001)(38350700002)(38100700002)(36756003)(1076003)(2616005)(26005)(2906002)(41300700001)(316002)(7416002)(30864003)(44832011)(54906003)(66946007)(66476007)(66556008)(478600001)(8936002)(4326008)(8676002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IserxLF4z9Ufnhp0kCYLKGilhS7QenzkjtZpTRe7l1g/BiDSuteFqIUpZ09D9vqnps7/L7arSzU71EGghX1AkW7nJtv75nH4/MrUKthGtYdQKVTjnkCkhw7irzRhv81O0/Wq0Xt3hr8yfJquUCbBAHBUs/lbgJc9lItZjDmr4iPAQ10weNWW4JSmpAi628Xvq4R6vQD1/iEvU51SpJTqFrjqqM6mBpdIjloND7uV/eaQ0b5meheDLrtuZWAG+jl3RXpI9IlvOFM3yDOJp2JEU+BQD+ijnfGiL8gzS1BX7Po0Op1n1EAUZqLnisNwoaSofkXe/3lNr0YxHaxizXQwC72Hqag0YKch5MPDwjlj8QeHeO/2USQnGJf7fWtg/7egNyFfKZzTmdVPRf9AnT6Pz5pbc5DDZESLwqwlS+W8Rpvb/kb/o8OZfOU52GAFiU0KV0I+zevtFWMzAuJ/b3pNecUDpOx7P1mwZb3LZjQO5M2zOZRcF26SAT7EMDk0uOnVYbbVzqJj9fpqrcskrEOqI0cMZmNZLXa3k5OoNyKDqUuRsljuzdPRL9wyB6P+1dqx097tTPyj4+DuvxzbpKwTJvVjD0JFycAic29XfmYmcPd/W98PoA1STewGOia/87IWO8fWLvLmi7XUWlmapB3bTRzPCodoECjylYwUVwWPZukWe1Vydbqzx02kkzMHerixC61c+wCqzWjr/GSupQznX4jYSznO02o1cUWQv5qqruRywdFdCyQMchWayA7nmTpNsAbfYfjR1E+Z4OPdUCchVw7FaCCD6j4PHZjtHyY6heCHZy4L85f38gIvh+U2kWVUvkDWi54D3VEzSFYSnlaAkZmYqQQDPFqVMlEbd14o+TZEz6vl4DbcvwH8EGrxl2MmJrdTgC66eouOf5wYZkiwQXjafJq7b/v/YAjLidNwj0xhkrWWGugr36LRjujLJSnrtpFoVu4sWQ+IUpDXIHXO2bOXiWLqw4qUp4OE3cpOwNQpNdRQvdR6nDYIu/jGPtU3QOw8x+GoMcQLSZXjigBczOEsTA7IsE0S+pKqXPWTc7tn+1ujC0iWwHkXeG3CyV25ofIA+E+h0iM+fD598wqzt3prHT8tzsPri/K74+09Wtswj5PuWYKaNZyFvW2cSzOOCK6w0FCH6jCZx0rWELEaBX/vDnru2M9CLPjHqqTLOUwRDrXSfcMdIgIsvZrHQShdzBx7N94vzks02TsP6KKW/ERe8kQE4Ha/8/JR5L4NuBBdM8Ga6i0SHvedTP5VMW0Jy2weUfbrQvWku3fakVXwDK6kx431uEWETEZ+FYrU2uut6DJt17zmPMi5KnKJoJFv/Hk6IvDGqWdnpbrN+M0eLw5Em3fgcHXPBB1WLU32viMjGMw1qduBMG55govCtWHkfm4tS7QatPsy4M8dFWj+uIvrdr1Aztgk/BIPplvVm9Cp6lp0dFbHvEHiVXZ4QSHhV7YW0uZMZG6nL6Nry81BYFyhJm70M9g9AZ4VoCtXt7ejM3A+kS1VpO2E+sujiOkFqWkZr5zIMnpRYe7uzDn1k6EYU+ClvD0PifN1OzkL9xgyg94nuz4gixDC6jC970wf6t8SXcpqlU8drhaJShKykQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb6892f6-915b-45db-eeaf-08dbbc3be64d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:25.8017 (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: e4t5Zuti3q7G9Gp5Y14+XoeYDV42+2ZtB+sh7yVR92+6Yj/jn7VyQoArEj3a5oQMQxVLKa10GykecDrUsyv14w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8396 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net In Layerscape and QorIQ SoCs, compliance with the backplane Ethernet protocol is bolted on top of the SerDes lanes using an external IP core, that is modeled as an Ethernet PHY. This means that dynamic tuning of the electrical equalization parameters of the link needs to be communicated with the consumer of the generic PHY. Create a small layer of glue API between a networking PHY (dealing with the AN/LT logic for backplanes) and a generic PHY by extending the phy_configure() API with a new struct phy_configure_opts_ethernet. There are 2 directions of interest. In the "local TX training", the generic PHY consumer gets requests over the wire from the link partner regarding changes we should make to our TX equalization. In the "remote TX training" direction, the generic PHY is the producer of requests, based on its RX status, and the generic PHY consumer polls for these requests until we are happy. Each request is also sent (externally to the generic PHY layer) to the link partner board, for it to adjust its TX equalization. struct phy_configure_opts_ethernet is valid when phy_set_mode_ext() has been called with PHY_MODE_ETHERNET or PHY_MODE_ETHTOOL, same as with other union phy_configure_opts types. Signed-off-by: Vladimir Oltean --- v1->v2: - rename "xgkr" to "ethernet" in phy_configure_opts_ethernet, to match other modes like PHY_MODE_LVDS and phy_configure_opts_lvds. - add kerneldocs include/linux/phy/phy-ethernet.h | 292 +++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 4 + 2 files changed, 296 insertions(+) create mode 100644 include/linux/phy/phy-ethernet.h diff --git a/include/linux/phy/phy-ethernet.h b/include/linux/phy/phy-ethernet.h new file mode 100644 index 000000000000..5260e132de21 --- /dev/null +++ b/include/linux/phy/phy-ethernet.h @@ -0,0 +1,292 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2023 NXP + */ + +#ifndef __PHY_ETHERNET_H_ +#define __PHY_ETHERNET_H_ + +struct phy; + +/** + * enum coef_status - Status report field of one TX equalization tap + * (coefficient), according to IEEE 802.3-2018 clause + * 72.6.10.2.4.5 Coefficient (k) status + * + * @COEF_STAT_NOT_UPDATED: The default state for a given tap is not_updated. + * An increment or decrement request will only be acted + * upon when the state of the tap is not_updated. + * @COEF_STAT_UPDATED: The tap transitions to this state after it has + * successfully responded to an update request different + * from HOLD. + * @COEF_STAT_MIN: The tap transitions to this state when it has received a DEC + * request, but it has already reached its minimum limit and it + * cannot fulfill the request. + * @COEF_STAT_MAX: The tap transitions to this state when it has received an + * INC request, but it has already reached its maximum limit + * and it cannot fulfill the request. + * + * After any non-HOLD update request which results in an update of the + * coefficient status, the update request must return to the HOLD state. + * Then, the status field returns to NOT_UPDATED and the process can repeat. + */ +enum coef_status { + COEF_STAT_NOT_UPDATED = 0, + COEF_STAT_UPDATED = 1, + COEF_STAT_MIN = 2, + COEF_STAT_MAX = 3, +}; + +/** + * enum coef_update - Requested update field of one TX equalization tap + * (coefficient), according to IEEE 802.3-2018 clause + * 72.6.10.2.3.3 Coefficient (k) update + * + * @COEF_UPD_HOLD: The default state for a given tap is hold, which corresponds + * to no change in the coefficient. + * @COEF_UPD_INC: Request the link partner to increase the equalization of the + * given tap by one step, which implies a change to the waveform + * voltages within the limits defined in IEEE 802.3-2018 Table + * 72-7 "Transmitter output waveform requirements related to + * coefficient update" + * @COEF_UPD_DEC: See @COEF_UPD_DEC + * + * Coefficient increment/decrement shall not be sent in combination with + * initialize or preset. + */ +enum coef_update { + COEF_UPD_HOLD = 0, + COEF_UPD_INC = 1, + COEF_UPD_DEC = 2, +}; + +/** + * struct c72_coef_update - C72 coefficient request + * + * @com1: corresponds to "Coefficient (-1) update" ("minus 1") + * @coz: corresponds to "Coefficient (0) update" ("zero") + * @cop1: corresponds to "Coefficient (+1) update" ("plus 1") + * @preset: when set, preset coefficients are requested + * @init: when set, coefficient initialization is requested + * + * This is the input structure for a local TX link training step, and is based + * on the definitions from IEEE 802.3-2018 clause 72.6.10.2.3 "Coefficient + * update field". It carries correction information from the local receiver + * to the link partner transmit equalizer. The structure consists of preset + * controls, initialization controls, and coefficient updates for three + * transmit equalizer taps. + */ +struct c72_coef_update { + enum coef_update com1; + enum coef_update coz; + enum coef_update cop1; + bool preset; + bool init; +}; + +/** + * struct c72_coef_status - response to C72 coefficient request + * + * @com1: corresponds to "Coefficient (-1) status" ("minus 1") + * @coz: corresponds to "Coefficient (0) status" ("zero") + * @cop1: corresponds to "Coefficient (+1) status" ("plus 1") + * + * This is the output structure for a local TX link training step, and is based + * on the definitions from IEEE 802.3-2018 clause 72.6.10.2.4 "Status report + * field". The "Receiver ready" (bit 15 as defined by IEEE) of the status + * report is deliberately not part of this structure, since it is logically + * part of the remote TX link training procedure, and is decoupled from the + * local TX link training. + */ +struct c72_coef_status { + enum coef_status com1; + enum coef_status coz; + enum coef_status cop1; +}; + +/** + * enum ethernet_phy_configure_type - Configuration types for an Ethernet phy + * + * @C72_LOCAL_TX: Execute a C72 link training step for the local transmitter. + * @C72_REMOTE_TX: Execute a C72 link training step for the remote transmitter. + * @C72_LT_DONE: Finalize C72 link training. + * + * The @C72_LOCAL_TX, @C72_REMOTE_TX and @C72_LT_DONE types apply to Ethernet + * phys supporting media types with the IEEE 802.3 clause 72: 10GBase-KR, + * 40GBase-KR etc. + */ +enum ethernet_phy_configure_type { + C72_LOCAL_TX, + C72_REMOTE_TX, + C72_LT_DONE, +}; + +/** + * struct c72_phy_configure_local_tx - configuration set for C72 local TX + * link training + * @update: input structure containing a C72 coefficient update request + * from the link partner. + * @status: output structure containing the response of the local PHY to + * the given update request + * + * Adjust the TX equalization of the local PHY in response to a C72 coefficient + * update request from the link partner. Used when @ethernet_phy_configure_type + * is set to @C72_LOCAL_TX. + */ +struct c72_phy_configure_local_tx { + struct c72_coef_update update; + struct c72_coef_status status; +}; + +/** + * struct c72_phy_configure_remote_tx - configuration set for C72 remote TX + * link training + * + * @rx_ready: output boolean set by phy when it does not need any transmitter + * adjustments from the link partner + * @update: output structure containing a request to the link partner + * transmitter, based on information from the local receiver + * @cb: optional callback to see how the link partner reacted to the + * update request (which is echoed back unmodified). The + * coefficient status is only valid if there was no error + * during its propagation. + * @cb_priv: private structure for the callback @cb. + * + * Query the phy RX quality in order to compute a C72 coefficient update + * request to the link partner to improve that. The phy consumer is responsible + * for taking the computed request and transmitting it to the link partner, and + * then calling the optional phy callback before making any other query. + * + * Used when @ethernet_phy_configure_type is set to @C72_REMOTE_TX. + * + * WARNING: the phy implementation may be stateful, i.e. the number of previous + * requests and their received status may modify the phy's state and it might + * influence the next computed request. + */ +struct c72_phy_configure_remote_tx { + bool rx_ready; + struct c72_coef_update update; + void (*cb)(void *cb_priv, int err, struct c72_coef_update update, + struct c72_coef_status status); + void *cb_priv; +}; + +/** + * struct phy_configure_opts_ethernet - Ethernet PHY configuration set + * + * This structure is used to represent the configuration state of an Ethernet + * PHY (of various media types). + */ +struct phy_configure_opts_ethernet { + enum ethernet_phy_configure_type type; + union { + struct c72_phy_configure_local_tx local_tx; + struct c72_phy_configure_remote_tx remote_tx; + }; +}; + +/** + * coef_update_opposite - return the opposite of one C72 coefficient update + * request + * + * @update: original coefficient update + * + * Helper to transform the update request of one equalization tap into a + * request of the same tap in the opposite direction. May be used by C72 + * phy remote TX link training algorithms. + */ +static inline enum coef_update coef_update_opposite(enum coef_update update) +{ + switch (update) { + case COEF_UPD_INC: + return COEF_UPD_DEC; + case COEF_UPD_DEC: + return COEF_UPD_INC; + default: + return COEF_UPD_HOLD; + } +} + +/** + * coef_update_clamp - clamp one C72 coefficient update request + * + * @update: pointer to coefficient update + * @status: response from link partner to a previous update request to the + * same tap, based on which we are clamping this one + * + * Helper which may be used by C72 phy remote TX link training algorithms to + * clamp coefficient updates for a tap. When the link partner responded with + * MAX or MIN to a previous update request for the same tap, future requests + * are likely to result in the same response, so just transform them into HOLD, + * which represents the lack of an update request. + */ +static inline void coef_update_clamp(enum coef_update *update, + enum coef_status status) +{ + if (*update == COEF_UPD_INC && status == COEF_STAT_MAX) + *update = COEF_UPD_HOLD; + if (*update == COEF_UPD_DEC && status == COEF_STAT_MIN) + *update = COEF_UPD_HOLD; +} + +/* Other helpers */ +static inline bool coef_update_is_all_hold(const struct c72_coef_update *update) +{ + return update->coz == COEF_UPD_HOLD && + update->com1 == COEF_UPD_HOLD && + update->cop1 == COEF_UPD_HOLD; +} + +#define C72_COEF_UPDATE_BUFSIZ 64 +#define C72_COEF_STATUS_BUFSIZ 64 + +static inline const char *coef_update_to_string(enum coef_update coef) +{ + switch (coef) { + case COEF_UPD_HOLD: + return "HOLD"; + case COEF_UPD_INC: + return "INC"; + case COEF_UPD_DEC: + return "DEC"; + default: + return "unknown"; + } +} + +static inline const char *coef_status_to_string(enum coef_status coef) +{ + switch (coef) { + case COEF_STAT_NOT_UPDATED: + return "NOT_UPDATED"; + case COEF_STAT_UPDATED: + return "UPDATED"; + case COEF_STAT_MIN: + return "MIN"; + case COEF_STAT_MAX: + return "MAX"; + default: + return "unknown"; + } +} + +static void inline c72_coef_update_print(const struct c72_coef_update *update, + char buf[C72_COEF_UPDATE_BUFSIZ]) +{ + sprintf(buf, "INIT %d, PRESET %d, C(-1) %s, C(0) %s, C(+1) %s", + update->init, update->preset, + coef_update_to_string(update->com1), + coef_update_to_string(update->coz), + coef_update_to_string(update->cop1)); +} + +static inline void c72_coef_status_print(const struct c72_coef_status *status, + char buf[C72_COEF_STATUS_BUFSIZ]) +{ + sprintf(buf, "C(-1) %s, C(0) %s, C(+1) %s", + coef_status_to_string(status->com1), + coef_status_to_string(status->coz), + coef_status_to_string(status->cop1)); +} + +#endif /* __PHY_ETHERNET_H_ */ diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 72ef4afcda81..f1f03fa66943 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -84,11 +85,14 @@ union phy_status_opts { * the DisplayPort protocol. * @lvds: Configuration set applicable for phys supporting * the LVDS phy mode. + * @ethernet: Configuration set applicable for phys supporting + * the ethernet and ethtool phy mode. */ union phy_configure_opts { struct phy_configure_opts_mipi_dphy mipi_dphy; struct phy_configure_opts_dp dp; struct phy_configure_opts_lvds lvds; + struct phy_configure_opts_ethernet ethernet; }; /** From patchwork Sat Sep 23 13:48:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725632 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50B771BDDA; Sat, 23 Sep 2023 13:49:32 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C671A5; Sat, 23 Sep 2023 06:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GdbFsbOjx7DB6aazzpGNBagMAWV2z6aQ/1FwX3kTBMnE1K9ifS6vB0SureYgTeLj170NVCYTtgGsdI2Mo1KmRUPL0ckICjsr6O9a+FUY3v+cwKRdTDrNRQLxlHJHg9Rw6l1XFjTlwoVa14oe2PJPEgoQ7HMaJ0Dc0MtbMQXXpkSbQ0VH5aNl9KJnkIrecmZKaaRcrWxzZ3Y/k6I3YYZR/5FcA2vEPSZh7hnJJ+7X1ev1ooZB/veM3ALbHu+8jozf7eAPI88GEA/JXv0/PVhVJW+pjt6vohPIQ50JRtJs27QdS48KWINoaHAZQ8vSQu5kf3IYjsR1KzVTZmkNLfm0mA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5vY9X0usskXKpLQcnQGAHoEgjxFUewnZMRLemH6ly+w=; b=hrgXd+Qa8MUOuOSJKoSncjWUYp4kojlbJ+VDgGZHIq9LMVUUjWgUcjZNKT+Izi2XjeRo6CfLpKkUxALQWbpYsFnztNwTOoXd1xfCqvunVf4yQ1yGah6hcN1TmsAiJObj8LYWQhKTFJubZaf23ddglmI6jF+TRgKMlDGr8Q6a/3u30av4UMy5i+OlelFxDuZDArVD1Q0j45K6vF0exj8PfzqFZ26U8RlKh4EvPQy13GTbVXRKZqChlb5m1UZjO03bOX6HJqnqwmgJrFwjcD48v2crvkAxIfL4ykuqCDcmdevaoAygqN7sc61K/SZiWcZn0+Q6hz4LT2Y+RIcS4K90NA== 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=5vY9X0usskXKpLQcnQGAHoEgjxFUewnZMRLemH6ly+w=; b=qB5wW8SqQfQONuS4pStOTgYnb2yym+fg0nD4Z0wENrjp9k85U41RQZX97FSbnel2ceCIwP0ND+WiGo4qw+cI4bGdZdCN7y7a2Wic3sZZujKeecx+jvoL++mpKLYucTDRuYmDKBgaLS9EKXyMmtzMXv2ltnJDHV5LpDD4gdmAdBE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:27 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:27 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 04/15] phy: allow querying the address of protocol converters through phy_get_status() Date: Sat, 23 Sep 2023 16:48:53 +0300 Message-Id: <20230923134904.3627402-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 11e97d8b-fd6a-40fa-a83f-08dbbc3be70c X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iWNzmBY2sZVJJGtTFhZNJcuT1yXmrnFcEdTzjX5pi7YXQDqhLMxp3E9LfAK2FYco1San/qxnCxdHV9+0uufPlpdrribo7LjIUJAUl9kbRyIUkDxgGWSKHJbzMJVOabEDf4jzrPraghu1vcyFHTjQP0KnBUX8JM9a+D4VFAVuVVuXnbn8iIaJ2SDG5RUwR6Yjeih/hzHGPIzvm50+eMgfXgdSZJVXbcMIJoBRTtzQoopLikD1p5bwFKVmqsRfb135ufM30g0sKLIx9lSVH6YRA7qb3B53/lxEPv8WCvuLCc+hP11voaTw1V7F4rLgjreMXGdbz5M9WHkdKCe45py5PRtAVYLQimNDz2pGCRPMp3NPQUMe8xPWcuAwAuKzRDHvjIoxfkxbPLI2lUo1UTMJIH4VaAEAuPLWncf5PsHH4ujGUQyC66Pd7igXUVrap5TxsT1e+NEltRsdV7fg6bAe6/FZoSy9TYL5diilzhW/0g0s2j98quVkjZzDDEonRCBeBVnZtFJ//y66m5XGoE0/ljixnotv/tzSZ2qpHQc+w6cG1+AZWRTlN43eyhE/fBNd+qxTDj7awRFBohfHiEPCtGtAMkFwIgwV3oPUyog0BKJgFGFMeCtM+nKGcKzjs6e8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GVUfj2vFfBEu+jR/WPmo37tC/4h9xX/OtLEfmF7RUKydKH23VDbZL1agbVQISFv3HeGCiAe8IZPc72woJCBdrlaNe0pK3SeL9kLbGUTPd2sHrO/SO/dmqUNsJM6rdlVZmyxlICloThQLnh3f88PkGydroTuks4opjL6qbJlH8mBpJwgO33U8AGEv2oZERvdZOM2EQ69rbRpjfyiSbSNjm4HuVxtDGtHqKnH2WpBqlXc/ovYG7M0oY6sqz8LmPpg89sik3rt7158b9HO7Jt2mdprV4E0SdvmKn7HzNFOit0fcU14KbAioMEVjyTm4U8n1oZrDPmLUbGYjir6F1AlNBqgjhrJya6i1GZKRpVgiMfgXUfTJRdDgDxnsutb/FmJpeiaLETbXrBJZ43ToEgmEW0nHmUqQT9mFZaRmdXk2dB69ICs76LSFISe38JnjgfA5LtI7DjCzXhJXiQ/4w7qJOw60TCG7F4igghLSGIExsZWq6W0dbz3j1z3bOIpdhgOwsWV92QPcWj0niO6kig4v9uc6TU4mzPmM79IuGxjvD0YMieQJRi50ccTlAv634UjxFRjc3lJVXjimqGjqjy19RKHv66o5rmGHhSVox/Uh1HBtm3D7hQBpPXHj8mObEi2GeRqpInLCuSCjCK6PbXHI8DiIxLYDndY1SI08dLuIryRIZrzo+ZfEH2/zkZ7JCwXq6MP/7Cqh/ckMAsxBfnhjrzFmBjItjcRysO+kmdwlbau7J442GVzSwhH2YnsPRcaaoPDbcZogxZdBXZhzuXc+m31O+mfo6iJc7HUbxNhtNzW4EWKvqWrPE4qnSkC3zHPO++ff37Wgr8Mt3v1uuILCCknFAPyaT6dENH5d2H17a2Nyh7OCfVDSnRRqs7CJfytVv8C5a2vxrOP0WrUY3M8rSVwfECbaDBK6fKi/U4eXOwpVY5HQoVO5eoVYkZ3zBpbaEtuJd29gts/v+eydZDfJ3Jfpp6OcBKeZxFXADVqtCWCsjrzIoDS7vRx2q5n1x+anSJYwiOzpPpvX1pSmIrlOTgR2S/sUIed3ap9ESM8aDZzenbcgzq8KrfC5g0A5tjDVd9qI5fBkgINMUmVWxkydnW7UdhSnubIwCodsYuqEw1TqCf4yvQ5d1YAjjsAM5aXtBxgZHj2+lcNkCoilXZDyWiN4rlgFZYyVzMB8PVjIAL8izuOA4DQUajpCTDcIaP8qirEtwyJ8p2CJ2IGsLl7e7dGhV2Y6yMST7kj+Sl6kWAJOCLLu8vo9JThxERg3VrrqEjZl4CToP6pIJB4Rz9oDDWe5Tl1ZN2NnHt7cijvcMMm5P21xvqWQEOk1rQ7RXE2HkK6pynVoTpVaKUXd6dJKoM8rrWm03iYlcBZgivRVAOWbxcmud4Wd+A58O/TMB8I1HXlCwrIYv+JvzyAsbU5vj5iVSOVRIvADjZg2MeGyDTg2vdnHDSvfZLrsWJlBcPkRiOby/VAKR0ftBrLf2K0NgmLaMJ1AzRYOyv5f3NIa+dY9otLXRSB6A0NrVOAkEVOq7OwAvwBYr2Y/DdbkOOnVpmZ0nO+F7YAcLUteBm/FCEVNss6I7AXzsE8dywJ1ryQQ91MgtUPJm+nLUadbWc6bpQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11e97d8b-fd6a-40fa-a83f-08dbbc3be70c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:26.9984 (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: l+B8SSMcfwA6PPASudIaOCjpU9rmfGhOihqkByKF/YDkaYIyPyAwwGqbBFrt8wSnBQYmdwc+ISHDyYiav9KCmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net The bit stream handled by a SerDes lane needs protocol converters to be usable for Ethernet. On Freescale/NXP SoCs, those protocol converters are located on the internal MDIO buses of the Ethernet MACs that need them. The location on that MDIO bus, on these SoCs, is not fixed, but given by some control registers of the SerDes block itself. Because no one modifies those addresses from the power-on default, so far we've relied on hardcoding the default values in the device trees, resulting in something like this: pcs_mdio1: mdio@8c07000 { compatible = "fsl,fman-memac-mdio"; pcs1: ethernet-phy@0 { reg = <0>; }; }; where the "reg" of "pcs1" can actually be retrieved from "serdes_1". That was for the PCS. For AN/LT blocks, that can also be done, but the MAC to PCS to AN/LT block mapping is non-trivial and extremely easy to get wrong, which will confuse and frustrate any device tree writers. The proposal is to take advantage of the fact that these protocol converters *are* discoverable, and to side-step that entire device tree mapping issue by not putting them in the device tree at all. So, one of the consumers of the SerDes PHY uses the phy_get_status() API to figure out the address on the MDIO bus, it also has a reference to the MDIO bus => it can create the mdio_device in a non OF-based manner. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/linux/phy/phy.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index f1f03fa66943..ee721067517b 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -56,6 +56,33 @@ enum phy_media { enum phy_status_type { /* Valid for PHY_MODE_ETHERNET and PHY_MODE_ETHTOOL */ PHY_STATUS_CDR_LOCK, + PHY_STATUS_PCVT_ADDR, +}; + +/* enum phy_pcvt_type - PHY protocol converter type + * + * @PHY_PCVT_ETHERNET_PCS: Ethernet Physical Coding Sublayer, top-most layer of + * an Ethernet PHY. Connects through MII to the MAC, + * and handles link status detection and the conversion + * of MII signals to link-specific code words (8b/10b, + * 64b/66b etc). + * @PHY_PCVT_ETHERNET_ANLT: Ethernet Auto-Negotiation and Link Training, + * bottom-most layer of an Ethernet PHY, beneath the + * PMA and PMD. Its activity is only visible on the + * physical medium, and it is responsible for + * selecting the most adequate PCS/PMA/PMD set that + * can operate on that medium. + */ +enum phy_pcvt_type { + PHY_PCVT_ETHERNET_PCS, + PHY_PCVT_ETHERNET_ANLT, +}; + +struct phy_status_opts_pcvt { + enum phy_pcvt_type type; + union { + unsigned int mdio; + } addr; }; /* If the CDR (Clock and Data Recovery) block is able to lock onto the RX bit @@ -71,9 +98,11 @@ struct phy_status_opts_cdr { * union phy_status_opts - Opaque generic phy status * * @cdr: Configuration set applicable for PHY_STATUS_CDR_LOCK. + * @pcvt: Configuration set applicable for PHY_STATUS_PCVT_ADDR. */ union phy_status_opts { struct phy_status_opts_cdr cdr; + struct phy_status_opts_pcvt pcvt; }; /** From patchwork Sat Sep 23 13:48:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725631 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D271CF89; Sat, 23 Sep 2023 13:49:33 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFBA819E; Sat, 23 Sep 2023 06:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MX19dRYCCAvt+C31gYhl6SEeH0e8k66R0BeQTWoKL+CaRdgxNG8Dot0pBmLXpV1TeC3eDi+GnIjoexFJN0RWOL1EWpcHkmZYEGqpGds+kJB697+MYHw4vz4caWqtsQUr3L59MllAffbTzzHW+VbQMLc3MNijfUfMWxUo11JRnqKmDj/ERYYlhwx8mIJOFQXyFPZHNrOtZW5g3cBzTqnT+4wq2y/g16XCaFDbq0Mq4pI0giHIu9rVz0GAT7rPgyw5X3jza7AhIRHVcZKy236zMq3jkYXB95Y3VZm2EzaYteN2D0yR5SOkW8tjCEmGkYvodiTbvm17IGIDWzTEK4osUA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XGVOAf2flIf4A1Jltg+syV089a2DDSocHMXzvwBipd4=; b=MIjIAXE8EfCJgUhycXjzLDS/MXzO8k5lUOcPT0Ai3a9Kq6skbc1p4tWoLZedI+7/ABvxfMvUOmxFsNtFl3gxvHiJlL1cdXQqLxXlQBCAYuidj+rCG4XsTYm4j6bvh1N95GAxqjAKjxcp+IWwLv24k2cpCLEtujNpWjDdNcUXs5IdNQ0djRqfczOZICzjeM9ijUx4wR6cUNNcY/Hr1eDkFLHzD7HD67kmRQhTFAI22/CjtWaQ+nM8CmtBb1Y/0RiN30uCsSR/kmnrDvvRz5e1Zdrq4zfgg7z1qG+M7Xk/ziOLj1gKA2ZLvjPjxinnFsnCFOx351OOhRRXaijLfS5Ncg== 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=XGVOAf2flIf4A1Jltg+syV089a2DDSocHMXzvwBipd4=; b=bzBZwSUVEU7E0WsOJKZsw9Y6RivIxT8HpeUYwReY0mhFbeTfmZPPI4g2F5ksS/d2vYYivG5Hu46M/+VetJVw/JebdEUYo9pKlDJqmKuhC3twsNtxiqDminGyHP/fuVy+86EZvigMJp5wMQrNUFiyNmx9SgzbYnQx5dRK4GbVOlQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:28 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 05/15] net: add 25GBase-KR-S and 25GBase-CR-S to ethtool link mode UAPI Date: Sat, 23 Sep 2023 16:48:54 +0300 Message-Id: <20230923134904.3627402-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: beb9c323-d5aa-413c-ffad-08dbbc3be7c8 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aScDlhiZPYZZWaIqMboVwCNoi/PnzVoRpL0fQyBc1lqLuhn38r++tZv8F5F0JkWcojut6WCJii16XSKl9ojzAAGGEAZYdWktth8X7FRGr4rzrok09sjTQqSj+etEN3e3NJ2kTaM3hpzh3xWdhRXwWNNZ5MhRkWbz0kGWIG18mqESG7xLhLcB7RFX7hlQdy0AzSfC8GFDs3wbxD4U+C6xNbZEVn4bw9/QOPpji43vpUsRhotnBGw9fF5qKFn861ovXoO9mPoWgabCTnOdqeZXhyhjGN9xaxgEjiw+oz2gj1MnMJ+fk3YEUODDvizg8PoHyhTQnI7MVRxux8vj9DRZYuquhnYpVuZ6NSHovxaZQMlIse0I8ROM/kaVVZi+TE5Omat1sIZlnosMkSEcdKq1EMioTzjraWUujreoytZ05ZmqEv72DhIUAy/CtjIBCj9RhMti5Irsf9ytPfKdit0VFgZ+BAbcdjT8PnSsj824QGyAcNwSHADWcuatgolv7aDf0OzS+qIQlolL+CR+52obyb6UUox+lwiW2zTqp2oQCCUiBCrct4ktnuOkHLTQuJ+3Gp9afFSt9OVb92zSdqXqxDgMpOLgdbtMS+PuleSPi2kcgbP654SlbIO39/0hY46T X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(19627235002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tKAqdbXgjELMXUcx5HeY9DyqHUXLmjzZ5DMNg9+IDPomuv6e1YwkMYu3AQhf1XQ8aa/b+ulWUOX8HJlDxsLZfMoOiCHjJcsCbtEaEIB4pu9X9a9cG/V6yIpUCQ2RQLmHcXtAe/befk1SYQ0X28KUlSSgcXKF9O0QuUkDPBTA/FjP8zIFs0X0zSVozlj00Pd8vSRRJGVKjKX9CT2ju7YM4xbyJ60zCTL5Am2BXI9aG/lGOfYrtP+MGpHVT5MCEDKqk7UV84+7ebJ3WY93HN0RVWX71jUfvsUUDqkVfut064f4Uv/VVF+CMGDxrmuAQDHwZWZfqZ03quzV5+CzB0fMlEEzQUEU0+XJvp2W22eyJwKmp5p9pXV8X8p7+PnQDfYhzQG656cz7wa3cn/0wdUWk3s6cgU77k9N5c9gSjyM6enBhbba8/ED4cDCrr4t7TImCiF7Y7fSgPClm5D58s6atu05CQFqyuPjc4RG2t2KdEGbjJYN1U63QhoNOpxlZOS9P8Y+729PRYY5D+BuiiYEpVoxS9zqaM5iTzQzKG8OdZywdHhsyRaVVOsT0A6pDGuQbFRQRmZxTyIXlnppKWr7cbIYXXZOrC7Yug/3AlC9Im2CkfhUqPIaawbuwMefrHOXd8wT4+ySNu/4CFRkrBNZyDijXoGi6uacve8iUQYD3cnhBSG//kwtw/VK4dsOvJLolAhNnJ9NoxfoiFpvwB5G79SAXehO033tkDjmY6lWDEXgu3c6B/Vc39Iqv0CcP8MsCHTqUDdUSDRHP4Vhmtos8p1PcsLSmISjUmFCn84BtNft6x0mdI71amIGdEZaMbOSPXb6JU4x/tkOdgORJ15qmYZw6OSh4Gee6kx32jPnO87Zo76XK6JeZ+YON34mhoOVQrv/ymsj9OA41hwB6yv2iLzmJKjSNSiyYtzLJ75svh4/c4x0fl5MIOe1kUoisYlS+TLychoVMyk1EHkOmwOKVDvH29GctbwSWCHczWnJVRcQ8NUDyMFfEe3bWiJecT9070Hsc83Gvu4F/8O4tR6lx2QtHEmwFdzGLPVT5H2LL06VVYLRcFg/3JNqNxsuna/OmAXr5CqSxdWmE4/cHj1L59L7hO97PHcXyWcjPK+mZsPDl6kxIDo9pUh62dAyHBIGWTcpfTYyrVQUJtZ0ULk+nckoER3TBEW6MqQ2PhwHTBZr2t8rneMggfiNUteEmPzAP6Etc2GCOa+EthNHZGs4mjLQ8K5KyGSKrEROdh1pP4xT9YGkojFaKqU83fNv63YxM7IRKYkOn+x6721rAedg226Dzt9iBqYaUJwIz1yX8xJ6EUDA1z8zF0JFWxWkRVhV83jFnHVc3mJ0fpn3q7r5/a2hD2X7Xu1B0bmHAAdarvdDRWGkQEiOxI5bhCwEMYXkhAOBQUn1q79Rto/iV9AhexztAULNH+EzegeuJpGJRE0TJiH+047dHEefVt3HAOQSrbVtp+NwCjCW5utCcuAqso20kuIQj1xbHj7JIsY8A+5SKWfT7Ub3xLG5jZr+upwg+RFHwkc2e2/uBso0Hhv+DQEti1HJpiY4CQ4L+b7HSwP8/3XEJHr7I4Z8OEfkDiVbYGdqIrQYDNHeym/qnlHHKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: beb9c323-d5aa-413c-ffad-08dbbc3be7c8 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:28.2780 (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: pUlkhqZ2XSs7POPSSZt2fx10qTxsAgZtjBOhFxrGYbKhGc46NaJnh6Y0DvKvXDzHYvp0t5v4cGculQDD5nAzVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Some relevant quotes from IEEE 802.3-2018: Clause 73.6.4 Technology Ability Field: | 25GBASE-KR-S abilities are a subset of 25GBASE-KR abilities, and | likewise 25GBASE-CR-S abilities are a subset of 25GBASE-CR abilities. | To allow interoperation between 25GBASE-KR-S and 25GBASE-KR PHY types, | and between 25GBASE-CR-S and 25GBASE-CR PHY types, a device that | supports 25GBASE-KR or 25GBASE-CR should advertise both A9 and A10 | ability bits during auto-negotiation. Definition 1.4.93 25GBASE-CR-S: | IEEE 802.3 Physical Layer specification equivalent to 25GBASE-CR without | support for the RS-FEC sublayer specified in Clause 108. Definition 1.4.96 25GBASE-KR-S: | IEEE 802.3 Physical Layer specification equivalent to 25GBASE-KR | without support for the RS-FEC sublayer specified in Clause 108. Because Linux already has link modes for the full 25GBase-CR and 25GBase-KR, it makes a lot more sense to increase interoperability in the way that IEEE recommends, by being able to advertise the subsets too. Some of the existing drivers which could make use of this, based on a keyword search, are: NFP_MEDIA_25GBASE_KR_S, NFP_MEDIA_25GBASE_CR_S HINIC_25GE_BASE_KR_S, HINIC_25GE_BASE_CR_S ICE_PHY_TYPE_LOW_25GBASE_KR_S, ICE_PHY_TYPE_LOW_25GBASE_CR_S Signed-off-by: Vladimir Oltean --- drivers/net/phy/phy-core.c | 2 +- include/uapi/linux/ethtool.h | 2 ++ net/ethtool/common.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 966c93cbe616..5f4e2a120abb 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -13,7 +13,7 @@ */ const char *phy_speed_to_str(int speed) { - BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 102, + BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 104, "Enum ethtool_link_mode_bit_indices and phylib are out of sync. " "If a speed or mode has been added please update phy_speed_to_str " "and the PHY settings array.\n"); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f7fba0dc87e5..421eb57fb6e9 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1787,6 +1787,8 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_10baseT1S_Full_BIT = 99, ETHTOOL_LINK_MODE_10baseT1S_Half_BIT = 100, ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT = 101, + ETHTOOL_LINK_MODE_25000baseCR_S_Full_BIT = 102, + ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT = 103, /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS diff --git a/net/ethtool/common.c b/net/ethtool/common.c index f5598c5f50de..2b3ddea465af 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -211,10 +211,13 @@ const char link_mode_names[][ETH_GSTRING_LEN] = { __DEFINE_LINK_MODE_NAME(10, T1S, Full), __DEFINE_LINK_MODE_NAME(10, T1S, Half), __DEFINE_LINK_MODE_NAME(10, T1S_P2MP, Half), + __DEFINE_LINK_MODE_NAME(25000, CR_S, Full), + __DEFINE_LINK_MODE_NAME(25000, KR_S, Full), }; static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS); #define __LINK_MODE_LANES_CR 1 +#define __LINK_MODE_LANES_CR_S 1 #define __LINK_MODE_LANES_CR2 2 #define __LINK_MODE_LANES_CR4 4 #define __LINK_MODE_LANES_CR8 8 @@ -223,6 +226,7 @@ static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS); #define __LINK_MODE_LANES_DR4 4 #define __LINK_MODE_LANES_DR8 8 #define __LINK_MODE_LANES_KR 1 +#define __LINK_MODE_LANES_KR_S 1 #define __LINK_MODE_LANES_KR2 2 #define __LINK_MODE_LANES_KR4 4 #define __LINK_MODE_LANES_KR8 8 @@ -374,6 +378,8 @@ const struct link_mode_info link_mode_params[] = { __DEFINE_LINK_MODE_PARAMS(10, T1S, Full), __DEFINE_LINK_MODE_PARAMS(10, T1S, Half), __DEFINE_LINK_MODE_PARAMS(10, T1S_P2MP, Half), + __DEFINE_LINK_MODE_PARAMS(25000, CR_S, Full), + __DEFINE_LINK_MODE_PARAMS(25000, KR_S, Full), }; static_assert(ARRAY_SIZE(link_mode_params) == __ETHTOOL_LINK_MODE_MASK_NBITS); From patchwork Sat Sep 23 13:48:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725931 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 516381D530; Sat, 23 Sep 2023 13:49:35 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6349B1AD; Sat, 23 Sep 2023 06:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Au9RnhxRxuYrNIecqSBFLUj6un40ZVTzD6CVNIvdl8gIgdmAX7uE4BkVd/i6hpdHkEb/pwnaIrYMRddQwm6LVhjXvOXdi1v5/QLSAIshsLLRkno/jD2xFSXmTQv74c962aZLuKlSflM1NDESEmxK89uQPx4ovFppp7nUv9B+GsfKkoQkBLKeypKlyBEMa2/s/yPpjCzHT3WJ4m5Y4J6LR0SI2YYTnwN5CSObbwSfP85N80pe9Nj19J2pV09BnZ/3uh9SnVn5AdczOJ+6DAi7ftdOCcyPgKqaGOSdZcx2j2j4e5S/2DH/MS2kNqsqSK0Pcq2nruVfT6Q83/5FzIp5bg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wiSwOhxch5ounlXMEbCvqxtOsgRamFp18/3AewOcUXA=; b=jVxSe+N0UCsjP3d7Z2RoyvGa2eKDXADp00/P7rUwM/1oszctZjWQ6ecrcN0V6b9e9lCwMWNvxTXxMxpj7U9pnLWIDjZOQYUKHR5+u+dTLniW6DsAPttc0bo9Hzq3Ddn1T4xQBxf5rqGlA875gnR1+8RjAQLuroutq731t+d+77WY/jDl0MD37D+H1hFp4sX6Pjq/ypJ8nIMG+gsi0gQm2vo/sPW23JGQjh1uYPwUEyBpubwvrmMhuvajn3+xCcUVZSG+JYfYmfX9Pf1nKnfgUTixZr2XByWDN98vvIO+lu5C8MTWLRiTQ4RvmDkn8oxcm58COTuRRViVXLOKivad1w== 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=wiSwOhxch5ounlXMEbCvqxtOsgRamFp18/3AewOcUXA=; b=JhEPZf7Das5BUGkWfbynAJTgZhUJ9d9HWzK2ichSRyCosV/kMk8oTQ+xCQDHkk34DOHGNjRjaM5P9oVoM8H63rc2JKOnjZGQe3yFcenj2CsdlRUNUEeMkUYWMRwdeCxfxeuTnfuYIzDAhB/eYZgr/pvPCsfI0/O6hTQqTwSxmh8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:29 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:29 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 06/15] net: mii: add C73 base page helpers Date: Sat, 23 Sep 2023 16:48:55 +0300 Message-Id: <20230923134904.3627402-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: c7d5a709-02a0-460a-b97e-08dbbc3be887 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LJS9s+jRz96uWRHhHlQ5AkbU2skR4FyOMT0jbK4Cr71VyvnP3zJwZy11Up5brgwnC6wXaEYw1lJq4cbjbNl9z2ysmrL1vkyfldaQXKnoqnfcyu7VNhXCql9uESma1Q0JoLvFRCR4lOysbGgR7wYGGYmvv+1AtjMiY4tiJjRBmTVXsByMj1rneSon32KPm7LX1ythSl/5v74pfEdIefGvnwKVJ0TmuTQLphmK84PhSDPslcBQEwVif/dXvDqg3PgVBuSZGpP3FONIz9jKLYwRbjN1OTZ7UGlWeQAxjpHiBT6gDqp7cvfJxtAky4MRVoXIvbIQ2lvS6kvBE7JuqQ+WLX3xjr4qvhQ2M4j7E6Zau/L4gLy13WvPGVTqZb0G4YCG5aUzlaM6vUB++TMFf0xuoAlKw2S/E2fuWeRr3S9jdbfiznaX6R5tiGTGEKoOkadpx4BeVWqwd9rHx7rZXe8PPMOCzj/mk/9Bl4wKfii9u2K1vsO+nV0sKmBD85GpLm+kploAbpAvUShqTmFMk2x7J2MlhNaC8VakIWQ+DmU9uewQiALf1dbARUbOHojozVo2a3aiHmMwcL9aqAhomeLgzxmxCabEp60WOQ73vXVzjSk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(19627235002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(966005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TLBAfG097hRsAi69qRxiC9GK1rSZPMBPYRPG0bzDqmjQOKTvNpz2/l8d4gOrINs/+JofosOiwMQm2k1syuBOAHR5T/Wfi1BpDwuRv6R5E5anUnI9QcZ/GjO3y9K/gjWEJ5FEM69wh2GdYO2Oq5TyJmuAdlQlqu3O9jnxvkprB9eWm74BJ8lt+2UKqzGF2KbEMxQn6lj7e3QGaAkEUaFCJbk1uKfwaunaDh52VZIfB0okRqv9Gsc4v+7qECVnjac2EiJbmawCcrV2VmP5K8BODNyVfBtfRXGwtBEbfFORcNRjqED60BIIL6d0C9AwNUckvE/zw6WTz56JYpOagZCFPqXUTCbNF5ByucWA6KyORlu3VRLzOCFd5xgWLpoAQ+64c0/kXwY09Xck10iZvpfDlFciKHBOdQAj52qONjZXLkB8W+jhQoZuBdH9fzX/C9mmRULIb8fMYGYlPMrZ6JmiRLx5HS7HFLSCjELhS3BNLQR632Eu2Yi0u9vFQn8cFeTydqszVWxaotLcFK2N83XtKswuL/vKvS/HlUYGozhK3xmArGmWrWHYLgOelgIBeSm9X4VG6e8+XpyPX7lOhSWDQ6m2KZGMuPaVRK7v5pLu2Yu981kWscQsjDm6w9RVPbjfoS2Tbs7t7hXHiUmcL8WVV2Qh8SPhTFiSYWQ4fpmP3a6N3XX50CAHfrZPMs1dpsJCFZuQxLHdZl2dVlyngnw64le4BBiTmHfPEJr4nL+/xxIBmY0ayztXasKa21sESg+eye1Lb8UszEmzbtUEavKqxouDXiouYl7Gytgfe1qq4f2U6WpyBoc7qZoukNkoE3VBPsqdCNrQIKJBO9QNyQPVe7X52hqDt78KHjbKJKTs8AmKSBqyb6K4qFp+bf4toAknjIQV13YgfRpuVMTG/Z8gwsXxB8uDZFEfxY52rZAHyqVwDY5Qb1fzDy/hgR/wd1WL5CL4mfudIiPhtvqK5wu2Rxi7IwzyoYuySNM2pHy5TlXJ2cl690Fq4wuZ+K9c/DKQqElMYY3jiRWfyvnevf+ywmvk5ejv5GIF7qeuW9P9mGAGHoq6G4gCYL7pLesKzQryB6YfCSkkPK74A5ot4FBfUQOLUUyyD3Suu5prR/EX6draJfokLR9SPhcQEOgvTMrvB631WcuQjAFXXv9/kwylplD7HElVcmO+q5Ilb1ejGi3SCeF5WH3TlXbCkHBM7hYibEczR/UsTW0vRlMdtciToPLT4+GMTEmdJ7piOfD3Pd/ukstWJwzGcQ4rdMCL1IrdgPfj2tNI4lzcqolkBVA2kKN4um+J0Byl7D0DF2EAtb9C1rRMNlEoJvT+PBk6NuR3BGAnJcjwZ+C4dX1x06p5iyp3xVZOlLYSOm/CkjlOaKYES3j3YMXNNaktqHfRbWch3cXSz5qGeUIf2dEw1S2MXF1Ukj9B7iPxe+IEKomHNXqiBz1YBvT+JvDIkuz1Ika1HZGbvlrjLCKofACZDbHhY3hjApoIcpF1LKdWsoPWSrc5rCsVB88MGlOAMf3J8xfiUmEXi7l8rjbk1lEldkK/mCsj3zuVT3W0LN5T56mMHMeGHQEjLDlW9tI773bVxpzUPo1Dh3DAVqkgZMLd08+WrQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7d5a709-02a0-460a-b97e-08dbbc3be887 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:29.4801 (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: 9pCHcofvo0X7wWpx6M7TJjLdSv/hCghxVxSXQLXtgMjHHfWQuuVQkx0Md/oKAVBGXIRMqhb7HSVoBqahVAUbdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net IEEE 802.3 clause 73 defines auto-negotiation for backplanes and copper cable assemblies. This is a medium type (link mode) just like Ethernet over twisted pairs (BASE-T / BASE-TX) and over two wires for automotive (BASE-T1) for which the PHY library currently contains support. As a minimal framework for backplane PHY drivers, introduce a set of helpers that parse and interpret the base pages that are exchanged by PHYs during the clause 73 negotiation. The placement in the "legacy" mii code is perhaps not the best, but I tried to put them somewhere accessible by phylib, phylink and non-phylib drivers. Note that phylink also has its own phylink_resolve_c73() which is more or less similar in purpose, but: - it requires constructing a struct phylink_link_state which is deeply embedded with the phylink API and that may not be desirable for drivers - the presence of some link modes in phylink's own phylink_c73_priority_resolution[] is "interesting", like ETHTOOL_LINK_MODE_2500baseX_Full_BIT, which is not a backplane mode negotiable through C73 at all. That comes from the xpcs driver which may have a non-standard C73 autoneg, and this makes it difficult for me to e.g. refactor phylink_resolve_c73() to use the more generic linkmode_c73_priority_resolution(). Also see the attached link where I had previously pointed this out. Link: https://lore.kernel.org/netdev/20230516090009.ssq3uedjl53kzsjr@skbuf/ Signed-off-by: Vladimir Oltean --- v1->v2: add 25GBase-KR-S and 25GBase-CR-S drivers/net/mii.c | 34 +++++++++++++- include/linux/mii.h | 105 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) diff --git a/drivers/net/mii.c b/drivers/net/mii.c index 22680f47385d..03e8b0877600 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c @@ -648,6 +648,38 @@ int generic_mii_ioctl(struct mii_if_info *mii_if, return rc; } +static const enum ethtool_link_mode_bit_indices c73_linkmodes[] = { + ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, + /* ETHTOOL_LINK_MODE_100000baseKP4_Full_BIT not supported */ + /* ETHTOOL_LINK_MODE_100000baseCR10_Full_BIT not supported */ + ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, + ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, + ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT, + ETHTOOL_LINK_MODE_25000baseCR_S_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, + ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, +}; + +int +linkmode_c73_priority_resolution(const unsigned long *modes, + enum ethtool_link_mode_bit_indices *resolved) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(c73_linkmodes); i++) { + if (linkmode_test_bit(c73_linkmodes[i], modes)) { + *resolved = c73_linkmodes[i]; + return 0; + } + } + + return -ENOPROTOOPT; +} + MODULE_AUTHOR ("Jeff Garzik "); MODULE_DESCRIPTION ("MII hardware support library"); MODULE_LICENSE("GPL"); @@ -662,4 +694,4 @@ EXPORT_SYMBOL(mii_check_link); EXPORT_SYMBOL(mii_check_media); EXPORT_SYMBOL(mii_check_gmii_support); EXPORT_SYMBOL(generic_mii_ioctl); - +EXPORT_SYMBOL(linkmode_c73_priority_resolution); diff --git a/include/linux/mii.h b/include/linux/mii.h index d5a959ce4877..4b141e9acd08 100644 --- a/include/linux/mii.h +++ b/include/linux/mii.h @@ -13,6 +13,36 @@ #include #include +/* 802.3-2018 clause 73.6 Link codeword encoding */ +#define C73_BASE_PAGE_SELECTOR(x) ((x) & GENMASK(4, 0)) +#define C73_BASE_PAGE_ECHOED_NONCE(x) (((x) << 5) & GENMASK(9, 5)) +#define C73_BASE_PAGE_ECHOED_NONCE_X(x) (((x) & GENMASK(9, 5)) >> 5) +#define C73_BASE_PAGE_ECHOED_NONCE_MSK GENMASK(9, 5) +#define C73_BASE_PAGE_PAUSE BIT(10) +#define C73_BASE_PAGE_ASM_DIR BIT(11) +#define C73_BASE_PAGE_RF BIT(13) +#define C73_BASE_PAGE_ACK BIT(14) +#define C73_BASE_PAGE_NP BIT(15) +#define C73_BASE_PAGE_TRANSMITTED_NONCE(x) (((x) << 16) & GENMASK(20, 16)) +#define C73_BASE_PAGE_TRANSMITTED_NONCE_X(x) (((x) & GENMASK(20, 16)) >> 16) +#define C73_BASE_PAGE_TRANSMITTED_NONCE_MSK GENMASK(20, 16) +#define C73_BASE_PAGE_A(x) BIT(21 + (x)) +#define C73_BASE_PAGE_TECH_ABL_1000BASEKX C73_BASE_PAGE_A(0) +#define C73_BASE_PAGE_TECH_ABL_10GBASEKX4 C73_BASE_PAGE_A(1) +#define C73_BASE_PAGE_TECH_ABL_10GBASEKR C73_BASE_PAGE_A(2) +#define C73_BASE_PAGE_TECH_ABL_40GBASEKR4 C73_BASE_PAGE_A(3) +#define C73_BASE_PAGE_TECH_ABL_40GBASECR4 C73_BASE_PAGE_A(4) +#define C73_BASE_PAGE_TECH_ABL_100GBASECR10 C73_BASE_PAGE_A(5) +#define C73_BASE_PAGE_TECH_ABL_100GBASEKP4 C73_BASE_PAGE_A(6) +#define C73_BASE_PAGE_TECH_ABL_100GBASEKR4 C73_BASE_PAGE_A(7) +#define C73_BASE_PAGE_TECH_ABL_100GBASECR4 C73_BASE_PAGE_A(8) +#define C73_BASE_PAGE_TECH_ABL_25GBASEKRS C73_BASE_PAGE_A(9) +#define C73_BASE_PAGE_TECH_ABL_25GBASEKR C73_BASE_PAGE_A(10) +#define C73_BASE_PAGE_25G_RS_FEC_REQ BIT_ULL(44) +#define C73_BASE_PAGE_25G_BASER_FEC_REQ BIT_ULL(45) +#define C73_BASE_PAGE_10G_BASER_FEC_ABL BIT_ULL(46) +#define C73_BASE_PAGE_10G_BASER_FEC_REQ BIT_ULL(47) + struct ethtool_cmd; struct mii_if_info { @@ -47,6 +77,10 @@ extern int generic_mii_ioctl(struct mii_if_info *mii_if, struct mii_ioctl_data *mii_data, int cmd, unsigned int *duplex_changed); +extern int +linkmode_c73_priority_resolution(const unsigned long *modes, + enum ethtool_link_mode_bit_indices *resolved); + static inline struct mii_ioctl_data *if_mii(struct ifreq *rq) { @@ -506,6 +540,77 @@ static inline u16 linkmode_adv_to_mii_adv_x(const unsigned long *linkmodes, return adv; } +static inline u64 linkmode_adv_to_c73_base_page(const unsigned long *advertising) +{ + u64 result = 0; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_1000BASEKX; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_10GBASEKX4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_10GBASEKR; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_40GBASEKR4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_40GBASECR4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_100GBASEKR4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_100GBASECR4; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, + advertising)) + result |= C73_BASE_PAGE_TECH_ABL_25GBASEKR; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising)) + result |= C73_BASE_PAGE_PAUSE; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising)) + result |= C73_BASE_PAGE_ASM_DIR; + + return result; +} + +static inline void mii_c73_mod_linkmode_lpa_t(unsigned long *advertising, + u64 base_page) +{ + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_1000BASEKX); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_10GBASEKX4); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_10GBASEKR); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_40GBASEKR4); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_40GBASECR4); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_100GBASEKR4); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_100GBASECR4); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, advertising, + base_page & C73_BASE_PAGE_TECH_ABL_25GBASEKR); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising, + base_page & C73_BASE_PAGE_PAUSE); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising, + base_page & C73_BASE_PAGE_ASM_DIR); +} + /** * mii_advertise_flowctrl - get flow control advertisement flags * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both) From patchwork Sat Sep 23 13:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725630 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44DD61D687; Sat, 23 Sep 2023 13:49:36 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A3B1B1; Sat, 23 Sep 2023 06:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hPcg5s3pWll7T0xmKYK7A1driEbtAJwf9kGBSbueWXW5yx7eZQkQsWR6fPwgLNOWBju9/mwpyZI2KxUFFW4yef4ROQ90S0YsvkWvTMmXXkLbJ+m5uRacUbd306a9O3tXHU2jmy4J9N1yiLs4oPD5ZZzc+SU0PG0TkI7D0lf+3FuDSphN0pL3VeY6AbfTWmbzV1WcJ0AXHL4MrKf9CfOaPb38KPh+rXuSQhN3g3XDeYAKQHTn7SNkcxoJNxCjFEBUHNj7z4ilYffjA828rJjgAA4c6xrUilkfE+1sJN81WLrA5tivvnlXKYOTGkB0clmiUsHyEh3lU9Y+UWchADJr0w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PLdZ3Q+/1tKzmXbcdN+NWqFouUwTh+6/uQGHuEziuRQ=; b=GwoTDfzNFhRxm14pnMCJQRQ6eaOfZoxKkfGWxtBB+0yTjDX+qJEmjfFLchAynU/9RN8jZgNBixHWblnKf2kEJjBEU/O+qsaVY2rfJvZqQpHu6LP8ZdE4jB71clXiIkVQoUbviUvOTxkpF5zYxiT5iaXi82LEruNEnx4vm3gENn1aYA9/s+wbJgpBmO04aZB/2na8IUGG6K9QpctloiEtZvsuy+PMvRANbcK2QdeFLCQJ7C7os2xCvsqY7uGvjw7bGkW1o2UKQQn9psdEmVgwR2CGm3v4HbLQY9QzHdYgb22G8XLuB+x2QgA6V2cSNth/YGitBun+wTwe1Fasozgukw== 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=PLdZ3Q+/1tKzmXbcdN+NWqFouUwTh+6/uQGHuEziuRQ=; b=Bq40txfnjAsdZ8yJdVh/rcomyIt4S+Y/AgvbHcXVhTbwU+ZaB5cOA6RiY8dD7ImJFW2UCjxnyU76XHuditMphGCvbRb894dqHH5b+tBaTYEV1pOG6KTsRkxDhNCUwOiSlTfUhT0XOPGDL2PBV5qTTXiSub8D5IXKK1SJAEYMe/g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:30 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:30 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 07/15] net: phylink: centralize phy_interface_mode_is_8023z() && phylink_autoneg_inband() checks Date: Sat, 23 Sep 2023 16:48:56 +0300 Message-Id: <20230923134904.3627402-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 8db5e03c-3d2c-4f06-4c3e-08dbbc3be93f X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2xibz12cGhe/hmq/lCbsgqclsp6+eFD+RXPJmdUJq1PLjg8iTm3d79qVSYKj18+1lE926br/b0omeABRl/O+AkqiMHgfbt65n5qcsfT84reRpJfHIUXi26hZkj/peTe+sl5E3u17QDD1AnqzMobvIu36/6MJcEgxB+Zlku9hEhMrzX9dAn136LgumM37PHt72V9DTUzAS42rfuzuK+RuK32yXb5drxIff6iK6iUWM8l7bdNJPLXcEWgUWUX6l8XD/1rbxRvCBwSflVRyLEw4MkBcxWe7Xsu0JqdD014XiT9NY9ZAdohXzbatceUHagyzlOb6cmyCYuSEUn1yplvCIouBLU0bps2lPnnY7gUldVi7F+d7V1TUp+vbFANWELjUF37PAWPUXhOxLeqMQ6B2xPtfm211gbeTMYUTrqA2n2S42xFachNkJx9DfC7hR3j4T1AChEXd0WI3zKg5dVXsrARWCtBslDywDpBVD+k3ULq+iJ6MzjkxRc9GKYlCaj3uKiii0BkykW/8oax6z0UUIZ0ZH6Ym0Q4hST2+8aWJ5KWtEO1cPoWP/ysYEe0lB9yu8rlhUUqLR5oSKDl71nAFkzr8uU8WsBETmij4hN8W6Gs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DeqYSwm6zItu4Aa84ZABUciLVTEqlXyNqFDSd4F2gijpfhhFAy7FoQuM8kt7nNAKXum5gS0Atciy3a4QqLc1XXboNO2ddI/OUae4vq0rCrOKD3uhZP0+9uS1xK+dK1tlD6zYEBJQ97RnhnmeOrMf+b3o6vOcTp8w+s3LhBuzUH5Cfh04gIkd9TSEa39mL6QpjiE6OIy8450HsE5WBHkRvUAmbeOFYzQiyPWk5QeGKh5Hn9gfkBmkbJyajQ2q7biTdzAq0FdpMWEtL+etW+rXyzKxbef8LJfsJ7sSlzOQaYs0cpJM9UkjDBi/yohm7yVOCHDjjnQ4bjC+lN8ma2JU3mpp6gck7WT60ZtykI5ZJWroe+9pXAu0Xf+IrDvRBjk5alTW+vHlRFbAmJ1ncjzakSeMa3T/Dn2o0NeLlkvxTBibYxrP6IvNQMKdNwH1wrfZfnw74UXnrKYSI2887lLDWe1gzCk/YJSDCK/uFISl6TZsCZjuArELV1XYVh90KwA1XvY3y3QC+Yx/0lrnDhrSpqs3QjBI/Lvv0EUE6rNKdcBX16n6X8vZQWmgEUrYWTBr4Hl9ukY7bjjzXY6F1KAabOt7+ZUXh5yS9ecsqu6SS3nc5eP3S9DMXYg9dC33+URv4WXgJlDzVjEnlgYZhY/OSZ9UCJElWYrbJs0TvvjDiOBAaSAnlnWqlqWTGGcfwFgkEPdqJll5wP7L7MkiJE3hUFV43gfsdReXlw3b30kefQmsdCJ1Vkz2k2Cfy6l20dQgJ0du+HlzbpPurvh6k2oQWis5ozgTyLGaPK74n8k5g2xUdT6GN+X5lMt6FcnAiO6+cpJ+vtU1B2/uTh67VRKLm4Fe/wvx5WD0uNuHaO6Lh2aCnotN4IBwglqkHy+S5Xzj+N8HvLdOjUhlUL2neAwflDnGyJdAZ+22UzI0q8ZVwhPwO1G5K0VkxegMytRtgkvqs5h6MIAM5PlKL2NP1VHyKvfAQceDDTz/RfTpG53kAoGa8ptVnyhds158P93zFl24IVkDe+cEa2+GPkc6PoJsD0PvZJ27pZLQ49Kf3mwysYh0SiEIDXnGgWYBMYfWTWoNylaNi7eHOkJZ+64b2e8iZld/iT1j+LbTHnCLquTVMkBR78K7SnPSkqrDSfJ9GwqIDEj9VPCWKo3bfGsBwIe6/9o9xsIJX3ymMiS1m0oRwLBfrhKlmE0s9xfOXzQiob3dC9hgAFOBnsq0SdhC1jV7doG7WjyPqO2sMCLn5bf40RsZKd+N7/25vPSwyrtfoFwr7A6dRqyc+p29ZFrEE9BGhok+gSAHpm2g8EcAhbvx29b5gSiNW+E48MdYd3B2hSOZB543noc3alLS2Jjw+86WKLRWrDS5llAjvdqCNWiXpffV41KAk4EBu3TNeypOzNqL5lt5GN4P8RfV6g26lJZQTN3nkjxRFxsdmGfhU+zEV6tN0H0kY8O5pgCT5RUHMnNChhSTIujBr41sc4UjpV5kLMVWlZl4Wik1+lEH5pHsq25vtf1ucP2ONK1x1HagELq5lLS3tm+w7WC+m7XfcPlkge/5qvheJgb0LuFGKwvW2HimDcKby0VINjf78FKB5+ZmOyNIi0MyscE8gtTq5rrJTg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8db5e03c-3d2c-4f06-4c3e-08dbbc3be93f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:30.6609 (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: DJ4yQptNNwTefbm/F1mO6Ha2GaVXDwRFzxHo2vVqko7Vw7vVEndbs2LxwC8HZOVvQ/IbAA0+LnjWYnKlhY9s3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net In a future change, we will extend the PHY interface modes for which phylink allows the PCS to handle autoneg. Group the existing occurences into a common phylink_pcs_handles_an(). Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/phy/phylink.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0d7354955d62..548130d77302 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1107,12 +1107,17 @@ static void phylink_mac_config(struct phylink *pl, pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, &st); } +static bool phylink_pcs_handles_an(phy_interface_t iface, unsigned int mode) +{ + return phy_interface_mode_is_8023z(iface) && phylink_autoneg_inband(mode); +} + static void phylink_pcs_an_restart(struct phylink *pl) { if (pl->pcs && linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, pl->link_config.advertising) && - phy_interface_mode_is_8023z(pl->link_config.interface) && - phylink_autoneg_inband(pl->cur_link_an_mode)) + phylink_pcs_handles_an(pl->link_config.interface, + pl->cur_link_an_mode)) pl->pcs->ops->pcs_an_restart(pl->pcs); } @@ -1716,8 +1721,8 @@ EXPORT_SYMBOL_GPL(phylink_destroy); bool phylink_expects_phy(struct phylink *pl) { if (pl->cfg_link_an_mode == MLO_AN_FIXED || - (pl->cfg_link_an_mode == MLO_AN_INBAND && - phy_interface_mode_is_8023z(pl->link_config.interface))) + phylink_pcs_handles_an(pl->link_config.interface, + pl->cfg_link_an_mode)) return false; return true; } @@ -1852,8 +1857,8 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, phy_interface_t interface) { if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED || - (pl->cfg_link_an_mode == MLO_AN_INBAND && - phy_interface_mode_is_8023z(interface) && !pl->sfp_bus))) + (phylink_pcs_handles_an(interface, pl->cfg_link_an_mode) && + !pl->sfp_bus))) return -EINVAL; if (pl->phydev) @@ -1937,10 +1942,11 @@ int phylink_fwnode_phy_connect(struct phylink *pl, struct phy_device *phy_dev; int ret; - /* Fixed links and 802.3z are handled without needing a PHY */ + /* Fixed links and the modes where the PCS can handle autoneg with the + * far end do not need a PHY. + */ if (pl->cfg_link_an_mode == MLO_AN_FIXED || - (pl->cfg_link_an_mode == MLO_AN_INBAND && - phy_interface_mode_is_8023z(pl->link_interface))) + phylink_pcs_handles_an(pl->link_interface, pl->cfg_link_an_mode)) return 0; phy_fwnode = fwnode_get_phy_node(fwnode); From patchwork Sat Sep 23 13:48:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725629 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E88D51D69C; Sat, 23 Sep 2023 13:49:37 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313AB1B4; Sat, 23 Sep 2023 06:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOzXetMLqFyYwTtjCg9f4H+o3B33cBunQY3bich9+FHDpUuw/pFx1uCLbTF4qFMgZlmZX5OJA81X+iK0dRBTkEzMrDec12/6XYtdm+k3hQY+3+1vkWpFtxyt5sUnApJQoUYnfuknH3at+B5NZpk8EKCRxuTGv85Ph8CZtbm4jWamIXacurmfsr5tYMUguLb8421LEHhrsH6czn+5SpBkBMb0PLSf2jT6Y74NzR2If5XnM3RXKbndYGQauuwwkH9NDrCRiLcNHq8+l7QQwgMC+tTUtYzydO03GEAZkE/P/voyohkVOlF5KX/zAHWGjsbTx4Kp97Z/Bk8DwjSMxlKPDQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PwfNxp6iQHMtoGWJzG46LEBYlY49OXWm672bXR/o/pQ=; b=RfMGyV5/b7VtQJuy2iho6ixAdZT/zltd2x3DMYXZRZIqE8zgykCUehG3Hf9JzghY2CKarlLt1JBRBAJaKfd1RcdnbCJIHmF6nx8pWxp2PsiK9VvnVJB7qFEx52SsEmhWc8xhATzlrme21Y7jSRp5DoQIlYK2BYF7eI78wULeVdXbMFk1m4degexj/tU8ZBpQ/nu7AKvPM5O3c+pPsLRbnWeqOWrClWlGjQAI+P39MVNSGbKNZd/aPu2S6Y1QF26wnh2ee/PdJXmdyJUn/npm/n6+LPr0YssTUe02qcLdZ0MLtc3tY8blVdempOgsXHrcwPYjJ1U9Kt/OGut6NlaH4Q== 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=PwfNxp6iQHMtoGWJzG46LEBYlY49OXWm672bXR/o/pQ=; b=D2d5DhHcmgir2Hf+3Ii2DKiRta3E/zqbJ6xACOgXq/bvU/o3nOFyvmPFW5ywKdbfU9TLwstr3gMwTGBnHqm9HbYE2ZWcsVH2ELk+E/1XyvekolulHJ9TCYSGvq5irPcpwHBysuSGa2Rn0UJrVRYDyEZw+3c+WBKUBcfMo0FIMN4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:32 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 08/15] net: phylink: allow PCS to handle C73 autoneg for phy-mode = "internal" Date: Sat, 23 Sep 2023 16:48:57 +0300 Message-Id: <20230923134904.3627402-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 640f6bb4-59fb-418e-defa-08dbbc3be9f6 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y2objuQAL6ahXAgjAbo5CP9+QfPO3EtaB4Et5hSiI44g/KBHE4AXas5QtNWi4Ve2WQJv6NMHwrIY6yAdckn43zqOTP/vAchYy+wrxoBFoaU8c7EVE+f4i/XhEkr/inXIH3sduvXQSSvYh+UjWXufxXsuji11Iqjr9KA1UG33sIL+xH10R3UmTRjBsHOf//AbJSQNGw1zwBLzP42VsFDZtvdJTnbCkOB/3eDcMSJPRUWCFdeS/U0C1SZJjaMGAku1aQEPh3fERL6scnRfWCeBXxxrhqCVfScHcV7fcmjaFdmBnC0gQLV3yn6rIKdsucCEhefQAtFB41Yu4nxTrAZVOjRHGSTldjx9UpRv4z2PMWN905QvCJLA27/76RC5s+O/A/G/q9xnybRMX/B3ftZF1b2zxjdxOhMH+YTEld5RWWlQsRF7a5ivL0ZkXJPWjU0LzsSNFvuJyvRG0gKmDxeQ7cQNoPD6K4F3URQpGCXKNk0jqGQLopbkysOhq6VhUTk9y18efVro9wtgiYtCWc+zDJkrFWdHsAfa7PSepawdzsC8x1U87hE8JdCXMtEl75TEYX4zHhpxboaAPt2BKEmmGmhDqRyBW9m8IArXgoEYKpI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(19627235002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(966005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zs3oW2vLbYvWbdsAN1X2GXLHC3lc4MKfxWjwd+SIE7pXpprfeGCszgrf7lzxwQlbJfBGze3EbKaZfdrLHTvjceNFWEDLcvONsn8zYDIsvoaYhppETPtFkqoz8gepixM6U3J0YCb51P5MnQevmxOySdYvNBkcFVQI/oY+doSfoHPVM+p0g+kgGLjLysS3P8O1mH+KpPA82Jhbj9LeDNNGbmkCsLh+oUw5X/h4x6mY3mDMBB3Qkso87OGmv8OKMacu5hxj6QosZmlO+4nXORqc6sZKKyaSCOpyaOoGbgF2Y1RGqlyfMFVJrMSllraqBzJFWzNX6dJiilj7Js5u+lQLVzDJewNdA1oiubFAz6gyg8ywpoKG2l+cVgmO/3JXYdbIWLgVs36uMgbINV2keaBYuY+YkGo7fnGaq8hqgn52jpsvLYkJX6wiV/7I2uj/wevT2IXcSDAyC2RgXQh8z1rDgQOuNNMVk/uYDv/C3xHm8ajYh2o0d+i9aZAGBftk85XV02k4joGql7neuUHa+Y1cqC7PNe6/Itr59EhJYdiE2wniqh5U6FT1zNJX7gCpexIxgmevIROXQlpMnCU2hNLDVNKxliEdhzeNJzBteNEXQOXWQnzCcIHMEXzH0uoKAc53YnrmCPbGiQ0TDynJ7D7VI/AgJQxFYEDlFVFp0c6fqQFIwHSQqjP2etgcZyc1pVQo0Hw62j+WyrDOMbFra5/53nJf3d9vYjUMvaR2zN9cnCNq2DJyv05jKXnPS7tWJAJ93Pzl1GJH+8/H6Mqcq8N0PlleAbQmql2U8VCGSHff2lCE4cTVoGN39VZMWW5cuF/wwicLUjkjfMWdSAK+4+K7ERfLTfTMZSBU7FoY2BnZPkSaiRNzGby+f8IZvNVrgjDjON1kBJ6+6NnE2+/WRFeXYt8bv8aXrM2/UA2u/Xc8G+ihXT0QgKS1XkhGZCRSsI2JqLktT9xLZ9Q4IZjTS3gWBBn6vobSpNDDAbrv//Q6q9EDZDZbuM+hL6dYP+ryBX6CZJ9oVyHrjxnQB2Q98YCaWeMF7Ca41/R232/0+KJx6P4QzrVRLAQn47g/nf3qu9pTZjsvXTNvjgZ893m1GEQheFvJw5+DCi7Th/XAnwzJcWldsCDd70OHRP2TkeXyQOqmUaTWgPlb2KouA6OVm+NvjHAfzoLoifjf4QwBqbPXdWxs7PDCfN7lG0dEQwlmSzNEFFTeHbfoRtrqu/fv7uXJ2K3eW7/ZC8QwKzh03OUtqbQF+ADnenyJ4QMK3sy4xMKHS8zt9Vte2ZhnBNG8zrmGleOwSN6ed/h4zmIa8Pw7Rao/gSNB1sHH0JQpUEnZ8sC2Wm9PoTQwq8BLHloOVctJNNWrXLgSW2LDO6ROQqXptE+j6s+pQHZXWKfhjosrEBOKsafSO2ZtGEjHbFWyFmEwQwgToN+n5o5mfvfDvklyAuWYplBlWkHq20r1gUUSZVFLmU0YYjw6NiFExxWzalm6g/l8hpqlSYx1lZR2pL5B708S7cwDNV2J/1dK4MzdSWUcEWCyhm894PkZQGyM2z6pFQKEZ0Xx7y3qcfW1ExtFXVmEao0Kh9VH6vScBqY5S7O0lERtOew20qAmlp900tB2Vw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 640f6bb4-59fb-418e-defa-08dbbc3be9f6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:31.8896 (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: UI/QFharUd/6sjfsNL3geIeLSKebTTCpy2pXpWC/fS6s8FGJuTvozPFjZoVA1/LyTBPnCrvROnAcxbuJZrGhGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Some phylink and phylib based systems might want to operate on backplane media types ("K" in the name), and thus, picking a phy_interface_t for them becomes a challenge. phy_interface_t is a description of the connection between the MAC and the PHY, or if a MAC-side PCS is present, the connection between that and the next link segment (which can be remote). A MAC-side PCS is so far considered to be a PCS handling link modes with optional C37 autoneg. But C73 autoneg (for backplanes and SFP28 modules) is not at the same level in the OSI layering, so that existing model may or may not apply. (a) If we say that the PCS is MAC-side for C73 modes as well, the implication seems to be that the phy-mode should be one of PHY_INTERFACE_MODE_10GBASEKR, PHY_INTERFACE_MODE_1000BASEKX, etc. Similar to PHY_INTERFACE_MODE_1000BASEX which imitates the link mode ETHTOOL_LINK_MODE_1000baseX_Full_BIT. (b) If we say that the PCS is not MAC-side, but rather that the phylink_pcs represents an entire non-phylib backplane PHY which may negotiate one of many link modes (like a copper phylib PHY), then the phy-mode should probably be one of PHY_INTERFACE_MODE_XGMII, XLGMII etc. Or rather, because there is no MII pinout per se and the backplane PHY / phylink_pcs is internal, we can also use PHY_INTERFACE_MODE_INTERNAL. The trouble with (a), in my opinion, is that if we let the phy_interface_t follow the link mode like in the case of Base-X fiber modes, we have to consider the fact that C73 PHYs can advertise multiple link modes, so the phy_interface_t selection will be arbitrary, and any phy_interface_t selection will have to leave in the "supported" and "advertised" masks of link modes all the other backplane modes. This may be hard to justify. That is the reasoning based on which I selected this phy-mode to describe the setup in Layerscape SoCs which have integrated backplane autoneg support. The changes in phylink permit the managed = "in-band-status" fwnode property to be extended for C73 autoneg, which is then controllable through ethtool. With phy-mode = "internal" in an in-band autoneg mode, we advertise all backplane link modes. The list is not exhaustive and may be extended in the future. Link: https://lore.kernel.org/netdev/ZOXlpkbcAZ4okric@shell.armlinux.org.uk/ Link: https://lore.kernel.org/netdev/ZGIkGmyL8yL1q1zp@shell.armlinux.org.uk/ Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/phy/phylink.c | 19 ++++++++++++++++++- include/linux/phylink.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 548130d77302..88ace7e203c3 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -972,6 +972,21 @@ static int phylink_parse_mode(struct phylink *pl, phylink_set(pl->supported, 100000baseDR2_Full); break; + case PHY_INTERFACE_MODE_INTERNAL: + phylink_set(pl->supported, 1000baseKX_Full); + phylink_set(pl->supported, 10000baseKX4_Full); + phylink_set(pl->supported, 10000baseKR_Full); + phylink_set(pl->supported, 25000baseCR_Full); + phylink_set(pl->supported, 25000baseKR_Full); + phylink_set(pl->supported, 25000baseCR_S_Full); + phylink_set(pl->supported, 25000baseKR_S_Full); + phylink_set(pl->supported, 40000baseKR4_Full); + phylink_set(pl->supported, 50000baseKR2_Full); + phylink_set(pl->supported, 50000baseKR_Full); + phylink_set(pl->supported, 100000baseKR4_Full); + phylink_set(pl->supported, 100000baseKR2_Full); + break; + default: phylink_err(pl, "incorrect link mode %s for in-band status\n", @@ -1109,7 +1124,9 @@ static void phylink_mac_config(struct phylink *pl, static bool phylink_pcs_handles_an(phy_interface_t iface, unsigned int mode) { - return phy_interface_mode_is_8023z(iface) && phylink_autoneg_inband(mode); + return (phy_interface_mode_is_8023z(iface) || + iface == PHY_INTERFACE_MODE_INTERNAL) && + phylink_autoneg_inband(mode); } static void phylink_pcs_an_restart(struct phylink *pl) diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 2b886ea654bb..7e8e26001587 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -141,6 +141,7 @@ static inline unsigned int phylink_pcs_neg_mode(unsigned int mode, case PHY_INTERFACE_MODE_1000BASEX: case PHY_INTERFACE_MODE_2500BASEX: + case PHY_INTERFACE_MODE_INTERNAL: /* 1000base-X is designed for use media-side for Fibre * connections, and thus the Autoneg bit needs to be * taken into account. We also do this for 2500base-X From patchwork Sat Sep 23 13:48:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725929 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBAB01E517; Sat, 23 Sep 2023 13:49:38 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBDB1BD; Sat, 23 Sep 2023 06:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DW/ajB72BxvMtDSS12cCqLSkvrgPABwqpsCB1oUXXaJSnc3g2sFEeRDemcbN80I6nuDiWm5/SLV2Asr8hCm+qJPuMsbe3v3w94Vi/pLze8+7pEG4Zigjm00iQUevajv7QxRwgOG6B3fUQKTQ/nt1LwmnUgDISMJMnI02+fta6XWUPC5c6/U7G0QZYE0kdp+Fsl52h1mJ6k7nKhPHknclxKFbpUOdEHkA0dUFJhdooPHpVlzDednyTMy9V0a1WyYq5W0pySeJjFBF66McON47ArzNDtm7RxqPyOyFnu3Ta8fkeY50wyHZ0Fl9B5EBeyuS3fpMxBy1yOBrDasbjUzMZA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5opFA3sHphDMtZr7cXb2BkhQSw25iuh5BpeyWpeg7Ss=; b=BDG9VUJmDVtYN47dKLYIA5AF92HYe4MFCmhnpKMOaSGAZ6QACNTDaecBDD8tYDDmCgxINEWs01d6K352QaO64Y71vd0q302GDoZUzUODVRzKTAKNOAyEZBivE6CKSTNYiG9J1H0elogf4L7psEjF7pLhrqNSPAb97mCSV9KJtBTZda+Coe5NZW2yox1bxVY12t6TB+zAiS8eKSRT/Fz5MESrzbub+vrB+A+Am+tLhcWpafhz14R90PilC7bglpZLOFPRVw0po3K9QweIglSQA5Z+W/JZBHTCbC/nFelBo9xbsbZT8hteRPDByh8O2ud/lUQoElF0ya2o1qLq9wixAQ== 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=5opFA3sHphDMtZr7cXb2BkhQSw25iuh5BpeyWpeg7Ss=; b=TCnYAYFriZ7RErVfinlB5veJfq00ghAc3YenWZqJmpK/VlxQTVj/m3LUIpFRopsp84n6dVn37x4DGc3d738ytQjZU+SGPm1wnvYKRa0HNk0/gZsrtwa/YUv6BPtxR4EtGgUiugOuF/+33/2wi/yZTf9fyUQeEGY4QGmVT1Du/Yg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:33 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 09/15] net: ethtool: introduce ethtool_link_mode_str() Date: Sat, 23 Sep 2023 16:48:58 +0300 Message-Id: <20230923134904.3627402-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 705f73e4-ada0-4a8b-0f6d-08dbbc3beaac X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cjWmT6vIrw9Z+ZXd1DMuLmHZRnkxrs+VuVnQcag8cG9XpeQI7DZKI+C2of5HcGFs3J2BATKJuugMvsTY7j16AptlcKPzF5m63CcsmrRx+Ff0GXMoWAA7PDGmWwba6QEuZTViJFNwrRQkm+YUHwmDLbJnflAfLg6pN+tGXnEO5Kj12GWSSnD69TqZEiE+kX5fEiqYIoeHm4Tvc3JBlP2htBIiGxb+RTZoWDgtmSAhWcUx5fAqNo3nGqKScco6wyxmidLZAmDnxEjMZMJm2h875Pqy5UdT20FfA8OWl+A23HvgFRhqdoCFhXN07es12bcQ4Af0+hOnMGepRvBMSmvLgaOFRber+u6Mp/UPC+YE/QHTnhKw+cSSlj43ct+s3zDJ+vFrTMyv0lzJURW5D4CURv/8HoyBXGU+82ygNwgwTNt8wBBzVKIxdw+uxBbS2Lk27eds73QYBv397psou5r2I+VE4TRbY8GxtleMuNuxL63ybJy5X/5MqyAvqdbZJ+8W+wQCXQEoA6JoYXLBv0gK7511F5oS3J/yTxR5dVv+nIGTAvaBaz5VvRSrKHPSu3OBAcLYB+umDOyn/B2rSCoj+n2/lfcoYvB5Q/dRHJDncXla3SjoPk2OPxF4wHzWU1gN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pE3xgH+WfUZtHT2IU8KOedW0ry+g8yiIcCxsCpbRK4cbfhWSOzv3goyqDg2ipjsekcJGEoJNRc2OYkwktyDvUpnWWof80/x6g7skNBlmX8tkaYAtIg58SMJN2OyYkYcNrOP9vnadkr9qjKqXe+5yMd+FxZ0HnvVa5KGf+hZ5S+pDSRhw3SiEZDvsq2GOYzfLNOvbH4bmIZyGD/wRxg6QDMQXf+GOobD37OyTevp0H3levfNj15kZPEqbm6MrSWicXPblqHra5HmFzso6bDSFiNrIkONxS+mOcBFaXYTsrZcJpmuUtOFdrOnPh7EYtEPXB6wYFYeJ9d+ERvWmKI5p2QZs8l+u+JlgNAn82rDgmeWIhuVBkT32re3tY1QxZ7L1lVwtya21s2RevD8LXG8TEXUY3v0Y/xNfxoI2BnMAPdIasOb8XgifSCMLO/zK+ks5PROq9htj+Jpq1mhug+p1HchZYEu3mfF5B4eeZcoZkpi6WaJeXyNimy3ju+RFMHBaamrueubWPHqS8X2sSQUiwVNkwA1rpEaV1oJedugXlssIIli6TJ8v82sWAYlAm/e33v8yr6qWGdhMGdINdKimXR7dLzJFswyWkFHlBUcaLtdZQfE+oIJZVg0ogVlgnLQvPEZdBsCmlUAAlkXVKQYFKk5Fzt/W+XIqnfoPkaSXrFx/EI54gu2GZjIGtOWSlMowSjw2/jnQpn3w2MxNSDnotmoqGBT/9rRgrXUezyWZNpIDznI3maeDCfAcpysWjA8uKuXMPW3sdH43RnmRwsddgEhAYs3moUdQC8DQpWiDJNGCLn5JgvIxl1Fo5D2E1ddeXQsxvUlViilAqV15PIGdWXnb3LqQD5VNnjFOElkMURuka3huG85f0LE1cENxw7Jg0254SQtdScSCf6XKtAe9UTDWzBznSQOwAWTS9SblFMYQYyRnT/JEYWmDcSCHJU+EYgQoB7833q3L6OLo250fW0pHctR6wiwboGDtWLFJ7TnCJUntHW2QaPa/FWLwnNvuRcGXUWwuFw5Pmlox3S21V7IzUyeu3MqlLI3y1/R6Ukjz/xbgmeMb9GOgJbRkhEcDp1lcFoZQ54BoxIKulAy5oawm4pp7XlOpzOkhl/0MITrh2HnfKA0CrMQREQRy5Lh3rnaJKJKzh8nBq3pxZb4vZrjgIHziaVOKB/yNLGJMZqPEVKJVmC14H05ZTj1sU2M/J+SIYkuMB9YGuXE6GMSoR9WdirlZOXaDhZk+OxgRhtuGvmq/+e+hH6nkuUVfQZGmagHRNYvK2nw9AFDAC7MNuXg3munulxPbTC+M6wj5KLw1QQLo9uIKgdTQhaATr0xxDvnANulC9SJUztnBqbefdh0vJ8cktiz/WqfaNQSf4vpzT+ow4noJzE/G5Sy6TMdlf4WLxtkNyUSaEBZYAliUym2JkfeWJV+DsPIEdh3+MpZ+DlH5Rs8I6bUuO1lQ8rv9jKv6y4QpmVgK+yxUJYcwUK0Vm+xnFrSZ8HLZS+0MPQ8EuKuB3XWevCl1qtmi8gAKxlo6RGOjMMlabPzUizlPWDSC6TOZLGamxO9c9dekLFmZh/zPdufmEfUb6K/gTXUVtPPMq4PLK5T/w855SOKczg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 705f73e4-ada0-4a8b-0f6d-08dbbc3beaac X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:33.0746 (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: EhQTaWRvNlpG0ldO5wLdAWDGU8ovnewFRG33RWab5WFGgMRfR5WP4G1TsH2mGMarp6luGez6u6c0bhGDzZXPlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Allow driver code to print stuff like the resolved link mode to the kernel log, by giving it access to the link_mode_names[] ethtool internal array which already holds this info. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v2: patch is new include/linux/ethtool.h | 6 ++++++ net/ethtool/common.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 62b61527bcc4..7b144f2b7dfd 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -988,6 +988,12 @@ void ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, enum ethtool_link_mode_bit_indices link_mode); +/** + * ethtool_link_mode_str - Get name of a given link mode, in string format + * @link_mode: the link mode represented in integer format + */ +const char *ethtool_link_mode_str(enum ethtool_link_mode_bit_indices link_mode); + /** * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller * is responsible to free memory of vclock_index diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 2b3ddea465af..9a79548adb68 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -691,3 +691,9 @@ ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, link_ksettings->base.duplex = link_info->duplex; } EXPORT_SYMBOL_GPL(ethtool_params_from_link_mode); + +const char *ethtool_link_mode_str(enum ethtool_link_mode_bit_indices link_mode) +{ + return link_mode_names[link_mode]; +} +EXPORT_SYMBOL(ethtool_link_mode_str); From patchwork Sat Sep 23 13:48:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725628 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6884C1E51C; Sat, 23 Sep 2023 13:49:40 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC55CC7; Sat, 23 Sep 2023 06:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYOt2smFwsLNOXpJtlKG9auOote6smGUEYZwYgfoRblngBu7t6M8Hpwqu5JvEDDHGKwGdJE0v0ywQ0QgAq+d55yy2KSBS1Cb9MhVF8sBfpYoj1KzH3MMS9NU7q0xum+eANZYTm73BXLdnjIJNWNsFT1KVK2zFwlcxxplrC5LMBMwwRlxryXSWgFeHGVr7XkE9PK4ZjNXdR4YVOB2//7iNAjwfAAn31F2zMNSr5ZSzMXUGIaulcQn5vMr6nj8BzWPygy9XTMbVtr6Eh8/5CdsnumamIqa1LsIESwCqWZHnLmYatn9rJNn9lFVQcicKh5Kq2PG3X4ylGIKsB7ploK4Gg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f2SciGmlkCgzOy99iuFcgQ8/NUtI7USZSQUF0JH52F4=; b=YTEwFrGmifKe3Kh+Ktvald9CeUsR9jHZromRtzmmTM82W41WwDTle2V1kkbQ4lJ0sS9zP6/+RnmL/rRDmEH0rMFYAW8x0QRRCbU5/cfy12KM6qKu+8Srwp0TGerXzq++3jVikef06uZl6VCF6twHopdqVVn5p8L1KwjhUqXS3Db4UEEr9hoAr7smT653pZXxnCRZ5ZN3MTfs63FSMA37NjVPwfzt3lCdYIeu7jByZK5zEmoXNGVEmeC95ml8V97TK7//Lz8BRwbQn3+gXMvPOilZ9oeQdw3AIfCb4HgBv7izNYuYCUbZMMCXAKLuwXGHXXaR8jC+MpPtvaNG/HD//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=f2SciGmlkCgzOy99iuFcgQ8/NUtI7USZSQUF0JH52F4=; b=r4+Ua2HMWh50mgmwuEw5gNlwlMe/ehCD9Soi66crh67ewps1Aso/R8FTnujp90Z6byJOKyY+tvma7Ch2nJVI1iLT9IvukxAgrutATmJpUJGWxZfU34vBHriNE5jFTzMnZFw4kc8aW2pxe+WEl9LaRne5uRgji3resJqcQ8wfHYY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:34 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 10/15] net: phylink: support all ethtool port modes with inband modes Date: Sat, 23 Sep 2023 16:48:59 +0300 Message-Id: <20230923134904.3627402-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: d32c1671-df61-4eb9-3fdd-08dbbc3beb61 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8Jhxud0XyVF7/5WqN8gNU5QOkshPkIX5frQm1uAEzUy+KdHigRbWhCrfJc5PgXB8LQ/IutCnBFhAjiQCAbvRCiD5ojXiUSWjtzfCq5hsXN+9svhe7cXEvE0OGo3gmjvIxV/NDEQLRADiic8PJWjfYGugtbx0JM1o/FMdASo2Wfxya64llcOw4iQjsNq/5zEpUyAg3yVH3vHU7B15eHEDcOG6CPq21EKZOSGFlta93uVvzd/wExL1auOWldRlzvax8DP7yDOk19tiIz5/Jy3QslJDWr8PbHoV7oYJRostAXxT/gav1pCd9bGinrBH/8eZeh+Pu6yQlSEmHNZm7ucR0dyVsuYTaszfW96bbxtMq27kdknAx0WG3/fPoLID0oHtP18RWJmIQEVzDMSKdoB3o/9tFCxB3GuXJ7xoE63wPkFKLhvcllDVEPeDjTMKHQU23H+XMmAv28O96KdOvozITx0sdFDjHJcB3FrSjFGaqLRiN8eLZ48cHeAOybCE3Gwiaocd2QGPjYqv+YO/o3wRBa11A8tH6Nt9KA3+WFxoIH+X2/eD47TZUrfT3Ihbfi7PgIVWeOThv24NicNqo2rPhwQGfxVnL9SpxIGOLSH8O1VSW47HhIs+P5a+Ogwawmi2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MAoeq/OoZgtICxCbhF2Rmx0lgXWWUbgkYK7W8liZQprq/RlYrmV0zpUOUsmWQohXKxx0WIKe3O/8H9yqRy16vldE39ZxgW+/AfQjVfv5UYM3DrMm0q25q6gtzgbN4+BeM+Y7JytAPpUw574bx5nZu5HloGNyaCeqLbBY00D0GgFgvnesh9VEaE4iKiWJfOwkwFSUZZXU7sXhQisDRcKXzdpwo8BO6QGAIxZOtNem9mgjb94Rf91j9ONEcL0W1K9I+fYLvy/yX/6+iSVlWE9CQkmRNWGbyLhGc+TkwBG65qB7LDN2qPGW3t9VZdnJm6afhvcwXGToM29cF9JT7xZlw3QsMlyskQ6Z3ykF9+F35Eb+sCEeYzmzNRAXUEnracczOAo73W8eUglobbMUKU63pBNZWmTSJ7kvqvWMumq1lvP+DMaYW8EXd4imzapPMWFl8MpSUkwcAb6u+LDz4R5e9ERtRkFMkWXNGOUDcI9Ul42GlHn4BRcP2leR6Udneh0vXgpeV8Sd44J6BRH59i4etKyFJDKHYYtGNZTs2u+7Y1pOyKYYQKO49C7fd2/0GzWRidv3QNf4bEF0vbjsRQzz9vyEgyqpE6zLvyENReaFoFpJDws7ReXvo1G7Qy3psXkHd25NhuiFzEv+lHDGA4wvunhA/K57CaKTpr2ZKriLQVlF0nkIYYVJHuAbTUYK2fnSa6AkaVw7V/7IZox3iVd9Bc9/ImEywIZgJTfwkBx0RzZhpNPz+jcLJ24AxBwSd+iC4tXP56w5iX0nJFjdqSCYQXDLpZIcZk2lCpttjPrlktVnCV5Dj8pwRFqGOFEx0MeekWg/KW/L9Aupjuo4JwqmbGxq+hVdPmV6wfqDNurW3EJu9dT+vcfnmUEurdcLl4FUoAAjpmiCMuIlBzdgPej7RNXHW7Y3Ul89GQX53p1Ua5K1mFz+X6VRiJxyKa3q9P5oMKPyDdLcqWJuax5N48OkvGVzigFmdIAFVTXW5FLKEoTdQ3knWtgDs04X33m7V0dMdivi5aN4llPlMPmfu7lBdST5oAEzA97gs/3e3LxOlGB8f0AOJ5LoDy0/nBzV2tlV4Gscw3dUkHo+4li98rdUuTFx0KStrmv3NTgMTunQYNLb+BQYr80ugGOMIpy7g8hH3aXZ5VJ89q2LyZHJzrAjPr/s2svEA/wz4WRWiGA9ZauoSk7384IEwKslyb0apNrK4IRAE5PXp6t+NGLDddJmsC1AGKr6PhzSmKqrhVfBMriQZMbcJVI344G7tFxpyj8WN2UmTkimPRRmakkTXKwqo0qH0V1PhgXMkeFufO2HmqkQlhTBFdLFcS+TS0FF/bLbhxnm8PmHR35n6I5O+n3nQBMtuHA1npZZYaB3Ke4V8jq67Yt0SYMt7By7jXZNRX1hHVBTioszzqHESHd1AFQ8Tv6BTp2eUvbHVVw+qZx3yviG17jJonALZCzRRzVazVtCbux2X18MkEea36Oo1vsjcBidv/hFGk19z64wHSmD1FbEtAGXAv3nNSgbySHLWDv0IDbEI55I8cM2nM9as9Qv/2KJFwQFNlL5yJ1Ls89W68g9H8NvQ2iViWO3SSBLsSs6qlDsWuHl3+E1PhOWr3fwHQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d32c1671-df61-4eb9-3fdd-08dbbc3beb61 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:34.2688 (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: m4W2km6SRx4VPXYBATJ8UPAsGXSfUv5Ae6ghCuytEvKXLSwbuavVyf7UONE/44K5a9nat9R8/fc0KvhzakweWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Currently, phylink_parse_mode() filters out all port modes except ETHTOOL_LINK_MODE_MII_BIT for in-band link modes. But if we're going to accept backplane port modes with inband autoneg, then we should also allow ETHTOOL_LINK_MODE_Backplane_BIT. Use phylink_set_port_modes() to just allow them all, and let the validate() functions of the MAC and phylink_pcs restrict what they don't support. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/phy/phylink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 88ace7e203c3..6415c7b91053 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -880,7 +880,7 @@ static int phylink_parse_mode(struct phylink *pl, } linkmode_zero(pl->supported); - phylink_set(pl->supported, MII); + phylink_set_port_modes(pl->supported); phylink_set(pl->supported, Autoneg); phylink_set(pl->supported, Asym_Pause); phylink_set(pl->supported, Pause); From patchwork Sat Sep 23 13:49:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725928 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4711F937; Sat, 23 Sep 2023 13:49:42 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B17DCCD; Sat, 23 Sep 2023 06:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXN6sW20/KWW2Z6N/TL/cxPTap24RTwkXCYHSXNYsrhZUjNsiyVLDw47g0VzPh6WBy5ifg/RHt6psMYnXys7oXo5DTuMdQKaMMKrPCMRKgeFHKZ1CQCJMQbrsq3FKAe6/QA4VKOljcRaoYJlCiH26+5IufvxkPkseCfrOs0fGsbcUq5zYMStR8PY0NAxhhr82Y/Rig3FYbKN/vIB/NbjMHKIGBYh/rWrK8Zh0Z98F12wjtLcE7j+xMlLF/xrQ4kvLcmvgkLhjiCCtdCTppEQa97s2m7gtHMgwhHYmyPeDZs3Xiqpw1Bn6IRvSo+DwGn8jfn6WWrWHyJnEUPVH8pNGQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3YUQpG9c5L2XJmX0f1KrxEihSueqyDJwLwUkN4nNd3I=; b=GGB1FAT6xXaXLbMUTptd0pcy7i9fD2VzQGHu9aCrxKWQlqagwP31dUCMKg06xO+gQmt3KDf1U38YbG6J3szeDk2hA6LQ1Ss4q1OR9Xj6moHRm4PGkfrycNbYWRxbT161Uj128y/+zeH+qB6n5/W65+zZiAGTGS6/umbuq6Z8kA/aUGfP5QdCZ9rM5dteRgSnPEBalLG3l/h3PNL0aFr0pj2Qijsvydx+7zsbFVgOypegPan1M8HSACBkaNHtzj5x1v4tprZWgpPK2LNgatuZg9yWpL4mklobNRwLPBIp59QNBGnlNbBU1x7depuu30zyObfydSZ+MjBGGvC6onExUw== 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=3YUQpG9c5L2XJmX0f1KrxEihSueqyDJwLwUkN4nNd3I=; b=ZR5q80vIiNWs+wy82/JHJkM9wK9+Rwo8rzqfR6f1VJ72G/fwKVl7eZoMw7kDdOIJpLL8Wu1keaDxHMaNMk5ZI4Q6vv3eCEW9CTJeQQj5M+cyCSN0dmn92sRw3nAUtRcw8qZ3bdW2SbOH3z2FiS2mdA20mnpR5MJS1K0r+pDkzvs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:35 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:35 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 11/15] net: phylink: support the 25GBase-KR-S and 25GBase-CR-S link modes too Date: Sat, 23 Sep 2023 16:49:00 +0300 Message-Id: <20230923134904.3627402-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 79fd9972-4a3a-4648-d2a7-08dbbc3bec18 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AebI+8myDC8QXg7vQ3YwSeqjZFXl7OgmhPIZy619Bts5rnaXBB6fPaWc/l7havbIZPjQi52DpPcUCAfExDo+qRr+nE7qNKO2XDz8nLCDQgmz9Zi6hHAaIuTCWm30ugf9OHIckNSRnhBaCegy7sZUgNfvuzRtTyjEVWVsoBxiKMQXIza3KykVA+DOIogoECd0ZnWGXKAM3japMZt60pRSmaZwDrGYePXEgPSdee5g7qkA+/AlThb2UrOzOgNYrfVAF5g69fGPvPVF1crazRP48nundJvpBpvibmL6t8kGtN+HOvRJ5R/Rz7dG5iC43vQe1boPXeW8EGWPCruA5+59uIZjIXZq3pbP3ZrOYvnqDUOKzGD/a2qnznvDSw2pLYcxegmCleA35mGWsh+3b6foX2nIW9W1tLnMeV9mLA5Zy7apsggzxjDe6h52hZqW8gCFuJW8mumH2EzaDOu4buHzKyBgTtjzJDUj8oMNOnxPZkWQMS8u2tJVY4NpLcAWwlrHMS7YY4SZthhhftSXfkWG2yRUnE2+1Jxo4iGxsjj6ZBTGZLHD2wbjagDtI2o3S2HQLpQWIXXyeGhtCwvVOPy2v0Z5cN2Uuv7Mdenl6zA4hRiR1HGBI+tJtG3r6/pWOYEq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SfM9zlXt3q1Xm3Zm7RT0h1Rf6viYdnjbpq1vqSuMSQBOU5MJ7Trhhn5mgER1NaCt9kah9tvNNlL3E2MMSJDl8eVAP4zR2MIVZpgsFM0n56a+7jsL0tmRJg/Zsimsn/aOuNTw1NtIAGlvHUi3zB4LwIK9iZiv/S8lRzHsAod2irzYUH5a0trPWiMqbZBBVX3BuGKBD5S8MovqnQKTkHCZZiHz24JRpEX6uJHXxZDPmY99e3VuSq1Zc2SCm/5uwZM5+YKcq05V8bn718hPkIcaY9AwDebN7GnUVeTw/hZJxABsRNWBEbd7rePGO+OPKjUecnQZafpDXwiYFYiWECDbcV/cbkxg/ggZxWeS9T2NyTeVHdCXguHyM5OBjupM/gu4Kmeu4Cg4Rl9X2YDaAKiNEkEAJPXqVvLTZMxBCC/2gCt4ZEcl6j7fGPr1kR1XNCs7MDbPb5IinalZz+OKAmAntcbtJa83lR96OaS7YpH4IArTwjubjMzf21ogrQlfmEYxry1JktVrSyGoXgc+Q+RA7342bdEUm17TeDKhA+Fh7A2NEt5UwR7IKCyRC0ZiQLIV1pJRDUb+khNc9777KLNc70BXM9OM0iHxAbrXPpb98tMbZiQMWBjLO2yqcWoWFJ+qc1osHlHJn0t9uuS/SGTVVJAOSoq5ovszd2GCT0KH628MMbwUARJSLxNRbG2ZRG+76Z7s1kYlM/IwqJf1xeyTt/urV80lh86oXnXnV/RVhRTj2OuaJnzVIJfLXLkFHDfA+xEMDEr0OVTRU5+tTkpU05NlW4lqm5NOBu9LX738Vt3R7wdopbMHXsT3hzTPV5aqn/IOpI60Ov/zIo7GdvHwax14x/3H9PykHuDGv9mgnuGbaKmN/0Yd06vDpG/FKyUUxKxtK5VExDk/Zmp05uLF6GEEvdBFBrPDKSDY60lSjej7a/z3GeknUZEtznXghp+IteEcmMEYOfECfMSciyqHowGZJQxEEXtSVycT7QCI1k5HJcSKmH9TPh2tzUUhmr9gnOdeod1yRy3KK1ijO8WrT0yziIl3B5tARC0uEsB+aTugivs/NJb1r2ErA4v4vAJfAaY9+wEF3l+5Pb520IYWba4CG9AiCq2wrJlm5DrfJeRJFKviQzxZQoofN3Dm/rJZ/bqcVwaRp0VNQ3yOJd1uSN29H40QSER+73cXc3LoMCdR0eha/kimmShNX8oDLG+T3FQSEiB9OZt8rVVm69mkG/xHc6E0ax5MD7ESzIMVnhmJibyC6pxsTc7trvIL/ZMoSHSwXQqVlkM1CM49orlJTBC9Ck37Bg/qIydCJGaWTc2TLYOaVVhdTqToeHcJRBSjrLriB0/QG2D2No55gebMoIcTXTqmb8XukiofmlIpAzCGCJJ7A9e4wr3G7xNFvFk0JWUoRag/VfvIrabCxOc/bZFJExz8Tf5R6f5cOYwhUCMVqjvuqsI2awVEhBRgXr803H+DyTuNMgsjW7c11xDTMD2WSrF6uCI/yGlEwHXR5XrrkNYv6a2yx0s/s9NvVoO/YwtNEjFKL0apgxfLP3SZ61ncbxK9fMw6B8x6gWRWlPTDIbR69ERbHK+Ya5gcuQmqwHD3hxmZwJIbu6jk9nW23w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79fd9972-4a3a-4648-d2a7-08dbbc3bec18 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:35.4983 (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: sY5Aq1rFDqGF7oK1Nvk9V2Hc1UtjjS65M+X6z2PBKLrVDzSzcS0EnbCE22Gp/AZ9ybcDrij3rYF5+gJVFzCw5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Treat the newly introduced subsets of 25GBase-KR and 25GBase-CR the same way as the fully-featured link modes. The difference only consists in RS-FEC support. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/phy/phylink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 6415c7b91053..157984dd81de 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -321,6 +321,8 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) if (caps & MAC_25000FD) { __set_bit(ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, linkmodes); __set_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, linkmodes); + __set_bit(ETHTOOL_LINK_MODE_25000baseCR_S_Full_BIT, linkmodes); + __set_bit(ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT, linkmodes); __set_bit(ETHTOOL_LINK_MODE_25000baseSR_Full_BIT, linkmodes); } @@ -919,6 +921,8 @@ static int phylink_parse_mode(struct phylink *pl, case PHY_INTERFACE_MODE_25GBASER: phylink_set(pl->supported, 25000baseCR_Full); phylink_set(pl->supported, 25000baseKR_Full); + phylink_set(pl->supported, 25000baseCR_S_Full); + phylink_set(pl->supported, 25000baseKR_S_Full); phylink_set(pl->supported, 25000baseSR_Full); fallthrough; case PHY_INTERFACE_MODE_USXGMII: @@ -948,6 +952,8 @@ static int phylink_parse_mode(struct phylink *pl, case PHY_INTERFACE_MODE_XLGMII: phylink_set(pl->supported, 25000baseCR_Full); phylink_set(pl->supported, 25000baseKR_Full); + phylink_set(pl->supported, 25000baseCR_S_Full); + phylink_set(pl->supported, 25000baseKR_S_Full); phylink_set(pl->supported, 25000baseSR_Full); phylink_set(pl->supported, 40000baseKR4_Full); phylink_set(pl->supported, 40000baseCR4_Full); From patchwork Sat Sep 23 13:49:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725627 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 603961F956; Sat, 23 Sep 2023 13:49:44 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D5291BB; Sat, 23 Sep 2023 06:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXuhQm6yItcgG78oL19VDcO3JBmIbONzJ5JIybQ1X3SGrZ16HfUKJJagTiFH4hXUUi9CEAiIDi4qVT1EfPSAa08kxI6JDpRsS1osMkdOVp4IlQe5MZxsYqEywF/sG1Ac2nrWZG0OnI0pw4VfiVDXu6AWAR5B5HjYOuIqp1OoqirAuFBgFNpSAeFFw7t7WWm4nZFjOC/lLppdTLNUgYq07jd5Yi5L6E7eVCa2JJlW5bYfROmNFV+gz7rUUZwGPaY4ViR5/gQKKrOHezslj9htzPb+1Rsi9W6VL9c6Wd2zOd22i56/itA9hEOBG4T428SRTZqJt54UQ+V+IQt5UifFNg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JWTsqDWQQ5BI3+PWtN1EH7dxdWOxyeOoC1NwQtHXqCk=; b=L0habHwiIbR7yz6T+BErX92H5zAA43YuMHy9a4L6+8d0UVzDzPzOtEpII5DtixXx2ZkZwNY+uUqxD2ljNpVC4TCn8Xo/UCyQnuTLDoK8mZnPfCNLhojuwMBhUXF3voLxAhnAUCOyjFRi3WDjE6zThkfXpyU/gScq9SJHM5jtNSZ1KboCJcAOtsMMQ+uEx32BUbA3b+ovUriGXz95kNY9+sIYjD/3nujDtXs6Bjy2xrfVEt2T4nw6q+Fop75JRzIqcWuNl9x+qIrBDi/XRNo/VsXzM8jd58goks576M5YibIEtqL7evZA0zd5R82sMlWS75T4fl64TkiC2bbae7czmg== 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=JWTsqDWQQ5BI3+PWtN1EH7dxdWOxyeOoC1NwQtHXqCk=; b=bus802hnN/tyRWkCaYse3Nd5PbSvRhaYddR6KDRD/Cy9w3dpl0zY6r2nxbseB6kPZ/iboxrBajlYjjcNdIbHr+4xeCc8KOQDVLaaG743b8w2PANB0w5LY513NzgWJZBR/ZSJKKu0XijnWfMbOnCIv8Hsz3MO/tF/hNnvweGf/Fs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:36 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:36 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 12/15] net: phylink: add the 25G link modes to phylink_c73_priority_resolution[] Date: Sat, 23 Sep 2023 16:49:01 +0300 Message-Id: <20230923134904.3627402-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d8c0bb2-4be1-4f4e-eecc-08dbbc3becd9 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fhpc89n4MjopHsqt6xZuLj0sJPzGxPxUbYTken7RbpiKSExaIrjB5wUzE9u2fyQd4BRswmP42ybMFbWSs7aywnrn7RXHlnYMtrXg6gMzzsolUVrBcSZzy8YhiNb06hWLR96xGYSPBF1ta5KvTYjM/72zxrcZP+HeClDSWUztcmFqvYc1QrVFgWFcOFeEE/93QRU/I0fNJCcP6yRb0Cf+syhvPPsC4JWPv99Nn+5BwiVvtxSMforOGYMKEWtJeyxk0N/agocg0zTzI8n2JYn7TRN0nEwEYP0W6HomTh13WjBA7qVbL0EQCtmNg0DxMDbzi4wIf4cyTzfbnCFJhsYjeRGxm4BBpl56ehnR2PzBO/qMLYf1neSBZblMuEROxRg4dYi4ra4Ld2L5vAyVYVh+U6knnn8Y6G/mvt4En1OESBAinLDmgFN8mqRA9GOAZOOb9h+4nfscuPYKmup8X99jffrTsT3cx5i2iHNxDikMlBshOp7WyTZMLi49GWyQPOuE7I0PhQHVBv5PXdiPC5AMDtfsUEhaYFYQk80bTvjNdHMkKUUAw12uZasw6MbPWRTGTf6DMJKb5NWFQUoIlkdXQ+s3vS8UnPrxnzCCcJxyhPvds9M44lH9rL8uQcmxwt2l X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vq/d6whXlZfuFIuGDjPxul/K71D4bpu3QwE9q5wJzYQz94OFHls2tsTNQk/q1SsV2fUFimQhR1FgzRJcWrucCvgN3y2+N9n3htsY+ND89jQtO98P9GIjR8wdnOyj7TiQk/0p+4dOjBRKGiX7D0Mjb7yWSGWS8/DRyHOpWgN4BRJ0dc3GkgqSnHwAgYKLFybSl00UAuthFD5s/xfA2IEVOZ3tbyCfM+gszxJzdGM8Ve05m8cn85cbw9Gzkm3L5CBeSVwL34Cd3QleoZkOUhk1hCtblAfPHpXP+m1UvcHuWTHWMgMCMxof1KZhVwvAeJyVXx9C4yFC1J0UsKbwS4GJeLxttPNgxGOCEkBOoHlE7IA87rH1juS43r6DLKyFedtMzssSfbRyPHtOaTd8PUhpyv6xCeiJw+WJ4BNtiNRmbkBWb1Yz82cdSl5f9sudfcG0bYQzl7LaRG0RhWL8Iasb4LmNDXXdrgCjXFPDrdCOVQ+oKAB96jJp2VjuODc+T4wtFba6NJzDpI8xhQ+uvIyutJcOb9/3h1ZLiv6Em56fgwLaJhVBxjBBfZlBLGsO/SuOkVIzmIfTtcCYTd2qztucXW9eS09icq6MwOlg8xNdda+V2UZImjwyvNXuRB8Jrta65BsE1nqJGtrzK+enUzDI1qJABMb/whCM/j/J1M3/L+hrfIGv1TyVii/QsJZZ6zkie6XOnuPPTakGeP8+JCv9OJuK03x585DU3tjOpornkh5ihb0u/w81lvkzRQ4Sa7qvvwiikiEU9nFirHg0UsL6K6ceiiPwlM6oyCCFAEg9C7iqta9tDF8Te9CYs9LBLdTGyTm3xr2L5WB6IbkwDlsYzVV+YE9F7xb5szY+765PbpN45iRXJA/MHY/Rg7D4ZgFLz6k6Lw7kS1h+Lx6usB/7uZlBwHmUahyIs3m4E/0fHtHr6/bqUkryl7ipQOwIxbK/sv9HxnRDJ+UTgwoELrkl1qPaVi1vQJb2KTYVgNPldL2Rk6ihRCg8Vi5Az+3ur/6f13MCc2rYqPEJ6rEg0JzoN0fXn0NfbCueR/ChH5BvbxHKS+6y0p2pXzswiLZC8mDZznPWqCm4fIA46IaHJw3wVTI/zfhPvoT+ZoK0KlezayuM6uzpLn0azqXavyUG6fy8Tp7bfd0VjIY43rvURlZ2QV6Dj8+JJ1Ncas6c5GG2/5pUl3WUTPfq5GTtmEY/hbqiNpRmpzAeHX/w1mOeXceaB8mi8MgvD3ZUBzJsiMsDVMGbwrMvbIeIdlr3/Atj9EWqrTwHYJyYWKDNP0xfN83763qfGtp+TsPMqqpmBMOU62SyAEK6e8yRTfMdZ0pRvbaNEcx4KG4/2Hl3XeaeJolSgZ5gyeQLxZiayeVY4EHnSUilZyORh7PJlA20BSSIYWAdpGfLP6ktYnPdd8IeVHfh8OfI3zj/PbC0m8+FTZYZyMsDGKiL11XQ0xjntO9XNPXW47rXSbe2G+MNlhGXBhO82LC8/2tl9XlfoB1bZabIVt2bNBqj5ZgZRjD+9QlLd5Wvcak+uELxfEUnzOoajkVNKaaZPflhHBPoYtnA+RgEi3BjZIoWSkgWeT41ckL+PnoOVLpOprDRlcHN/0OAwWum2A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d8c0bb2-4be1-4f4e-eecc-08dbbc3becd9 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:36.7046 (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: xxll6W073uISqac8gWohl7Jctqd9OWUSqt2th7SBN9SIZRxC+AP9aLTc1Zih5K8iPkHMQdrxXRS2WE8kKqo4nA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Allow phylink_resolve_c73() to resolve backplane (KR) or SFP28 (CR) link speeds of 25Gbps. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/phy/phylink.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 157984dd81de..484db2a5b62b 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3382,6 +3382,10 @@ static struct { /* 100GBASE-KP4 and 100GBASE-CR10 not supported */ { ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, SPEED_40000 }, { ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, SPEED_40000 }, + { ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, SPEED_25000 }, + { ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, SPEED_25000 }, + { ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT, SPEED_25000 }, + { ETHTOOL_LINK_MODE_25000baseCR_S_Full_BIT, SPEED_25000 }, { ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, SPEED_10000 }, { ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, SPEED_10000 }, /* 5GBASE-KR not supported */ From patchwork Sat Sep 23 13:49:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725927 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBE6A1D532; Sat, 23 Sep 2023 13:49:47 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6211CD5; Sat, 23 Sep 2023 06:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4slrmptnyOpoMjQzXDldX/4MMGFXuJ0WsuyUM637HiTtK6LHKP1cA3tG6etXzYKodmOZLuiVMt8jZu3TJNAq/PtG8p2h7N88KHKf8HupNxe7CzkvAWk/9xWUcw9QG5kJFamZ/WNpFiEfK83IA0PUII4nudodCJBMKHj2qT+TtdwXJs2btJqCIcv4m/0UTSQz8W2JhiuFBBAKSLpSn/0W9bSFbs9xfhovta2MQPARWvEg5IgvJqBHZcb7PpO/WSlS/DBb5jJTugMAp5cPYQZrNsJrERTHfhmPVjrkQtYL02Y6wFV8SDxBDXuXb2mCwElB0P0CKPEhs50p9/wxZo8nw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jKuluqSsGlv2qiqVeGNa2wDmuMo83UB53CrdOlVVZ3c=; b=E10VyLE10ViBLiMcCSYuqjHFzMlro03t1Xwl2RhgmMLbDFYhqtfnkpgTWCH9YwhpcyeBStTG6jFbrnlDHVUgqNYQ6bNa2U6KDKOzDKWHC5zsl9lUJy3ce0VbkpxXVlH7z61x1WzmPr82XpSHczhIbVPqb6e3JePV4hFdY29zcEjSfY33tUCL+5BI5jfWP8k4c0Hr+VZ39fmbChQ92OHDiXzQaFf7zunG/Pdo7iHxyBnlPu+egeavgi7Dpn0eRSg23Bf+ynYEvc4l+j04/TT7WTLBzI/tdDTrBtsF2fYPvb2945pl2q2ZuApn1c1BVDnImPvOWNmC6MQakgjYkjCC8w== 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=jKuluqSsGlv2qiqVeGNa2wDmuMo83UB53CrdOlVVZ3c=; b=GmHZ9ZhKYQzYIm/DwMf5hK11Zbh/1ju0uPuMcjkDz3rr9pyniJgudIpbVlE//BZFtiRMtfuLPKUXZJpY7xekco1SSKXeIhn/HPxC/u6aMh5VUXaKUpf/OG3zy8+NXNxKYfaWHgnJbo850J4+5DAOYIli4nY+QbijhfGa8H/64Cg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:38 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:37 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 13/15] dt-bindings: lynx-pcs: add properties for backplane mode Date: Sat, 23 Sep 2023 16:49:02 +0300 Message-Id: <20230923134904.3627402-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: e134f390-c707-42cc-1f27-08dbbc3bed8f X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SSS2CIchjtTc4bsEg9hPBu+j6DMWxXSgDfV1/HCVWzC9bV67lMlzC5FloBcHxF2CO4Ybtz0j3YxSOJfMhVwvoOZCsxU2X/P626fJp9Nx7Ef3LUDD/4bcb4p3d3tO7lZu8j/d0LdCiiP9oOqnMkzvJQOQbnq0khtM8P844/6SOb12aEJbx815p0cHwRBEB+/vQofy8n3/YCpl2JzYoIVcz1T21Kdh+rffb1hiLvX0ggPoDa1yOthA53XT9rQg25X7WnD8zVNMA/V3ZH3zWuJWYSYtfAiRGnsDNP9koV+PHV3i4yF4RbHUf24UgKF4G5GOc0rZK7Ib+tKHfmNjQMjKCclyH1/xSnc8S/ERjAxFhkQVapua/4xU8rD276ubO+KFFpKujUzATdWSezH83TjMgYV8XolcHdEGPn9G8CUQbohwAtgNc2Waof/N/okkLyBFPwXSgHZ8CIlqzQmqlFZFjGpNWlaDRGuVlB5pz4iKMGztHmcJRcT2BHPmsJZotrDXtXTeJRxZ3dxsac7kZLmiTshJn7DniixyU14n1NendBMlRZQxJ2MpWecHKoojeQENebQcUvvjhJdb/V28wQ7pjKXEr9/1V0FeIIXFX9DYocRtW7XwdnCLNAOrN7FoZKA0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n3i9mO7TWwLSbaP7T64TxWT/uNIVNDHyIrJvU2/lEzGJBRgbWlE2BNN+nQyy8dgIb6jgk6nLSpr/McQx8SWYYE3jtJNAQNKJy/buMLTTaN1TuVuSMJJY2FPXbGAiXLgn3GSB0O5aGL3SOcjaQJAGU4lzyokqqfMToUk1iSbtXfnSdCcdgmUucLF+3z5bWel0I+B3KZDmRZ4Ajrv9nZfDg0wWwqQ40gmi1uEHGpjNVcfQbVfoFftUpmhY+kKGcgZBHe/eQU1KdC5uaX/HTud02I1zcRAbvo6T9vo72bdBth7PAmkrieEK4P3BQeA0/vX9kk8kv4RFeqwFCjDgC+uSXJLMhfkoOML5XZrwg7VYba2sgrt/rFwVwyc9+7fiqz3hpkBVPqWdHQHr5FntsbzWDHYhpqOVp2iT1c6ju4CDk75EO/PmvgyFROtYeu35tlay6fyMy+04toFABU96J/xXlpgD//z/KToTkDcOlD1yumEoR9c3I0Bax0cc5bijF40ln5Pq/1zT/udtMistTdO9mSui/P6eDKNRne6+IoSLJAoHdZoVbrMQwKbFUtw2OXtRYZjKxInbuJdI0JQVAIjAPUw3d6+oXxDlwAVJ2SRf4OAm3D8RvAP0sLW+iH1GZUEvWlxf9xpf4Ja6URhXiD8XwEGOM/oADksdK1FxgYuqtan+U+zYANDRiTmPh8aaZP6sbgJUzmMtkO2eQu81BrQiiMAQLqT8xI/qPd063/BU/xHGULp/LYDkBpA7rbbNXeGLgNT5NRjivdSRoWzxbAX27YOZlu9I7I6AHlqkDBvRAvYPnMc+Izsry5mzkBnt9Kzj5DiqEEkGpnB6qhv1UdynyJkwsho8/sElWaRVEodGuLN+MIJVuuJiTkSI9yCd89e37108946xU5qSFu/8plGndTqBNKRllNB/1DuKsatRQjSYxGczPwiTizgqbTAOPlPlZ3CgXj3MFBvg5ehBp8iGedO40zai7E8KfzcMG6ltRKBa2cDHbq141YD0Sj1nrCB2dvMEk1nElu5e8iXtflZJ/rQ9NkI1IsabI25xE5XTeEAuQx+YPAl8oomuags3d8RtY5gt7w5jH4vHQ5K3IZyiEfToylgxFFsdFa+HStjy0zz3MXGE7rpRsdUcdvlwvbTJVMSxMCnrd1BaV33w+PHL9nDjI3j7h09AxRQjHeXbIVgCLW1rCH0cHXtBfdCKt4dbD1AKSmBns3PZ2IRJvvchmX+0wB1qq/3rEOSP7gMJiPWbTg2K0KeCJYCMI68z170zycBgemkzoumNbh43bVl2Bpt8tUEFfpcZq+dQzNQZ+n41c3BNKYfrlYZ22NC0Fkjywdj5FJb/XbqwlcaD6hRZ4m9DXDqgp+jxpSj6oydglYLE9msXaiGJb3XO22G81WOj7JDfZqLcx70X0EJOcO9NIO5Xf91lMy7IaS3q4JYKQeUeHfzF0KFsgCM82QMw66ox9ku5mtCDwkCHP08SSKXnoX1qsXq+QGwIRkmFZnKTdRDk3ReEv7zgtLeOhEAg8QCC22gc5jkHKKMxGJ9UQfUwlR/nCxc0pyROUhvNqfzbe+zJ65pGydq433HcZWWrr1NNyJn/kkmTRmNxoUPqqLkgXQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e134f390-c707-42cc-1f27-08dbbc3bed8f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:37.9078 (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: UxaszYWSVU2ol8Cq02t1IM8sNXAt1sDO2MlaFIRxgkB44K0kwVGaFs/zy6psE+U1d4er/GUWwpD1K3XRVbS2jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net When the Lynx PCS is deployed on a copper backplane link, it must be prepared to handle clause 73 autoneg and clause 72 link training, which it can do using a dedicated AN/LT block. The latter doesn't need to be described in the device tree, because it is discoverable from the SerDes lanes. The media type that is deployed on the link is not discoverable though, so the introduction of a fsl,backplane-mode boolean property appears necessary to determine whether the AN/LT block should be employed, or left bypassed. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new .../devicetree/bindings/net/pcs/fsl,lynx-pcs.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/pcs/fsl,lynx-pcs.yaml b/Documentation/devicetree/bindings/net/pcs/fsl,lynx-pcs.yaml index fbedf696c555..40fbcd80ee2a 100644 --- a/Documentation/devicetree/bindings/net/pcs/fsl,lynx-pcs.yaml +++ b/Documentation/devicetree/bindings/net/pcs/fsl,lynx-pcs.yaml @@ -16,11 +16,24 @@ description: | properties: compatible: - const: fsl,lynx-pcs + enum: + - fsl,lx2160a-lynx-pcs + - fsl,lynx-pcs reg: maxItems: 1 + phys: + maxItems: 4 + description: + phandle for the SerDes lanes that act as PMA/PMD layer when the PCS is + part of a copper backplane PHY. + + fsl,backplane-mode: + $ref: /schemas/types.yaml#/definitions/flag + description: + Indicates that the PCS is deployed over a copper backplane link. + required: - compatible - reg From patchwork Sat Sep 23 13:49:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725926 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD9E710A12; Sat, 23 Sep 2023 13:50:14 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5772EE71; Sat, 23 Sep 2023 06:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZnkBNBEFJNcDATvETDvtOOuoTVI4OsT73jRG2Dq8UGsPWL1GkEGI+lWbt7R+3XEXJ+CPVZheFACjmxL7ho238ozsP0QL3yo4/pGfX04+ojuzpSKCoMT0IocaBypgXRwVunFsH9q9oF61E8myfwj4svDg/FZpJ/IwEKnfn+9YgJO6z5gfPx40NG/OO/iJvqeukdByQYa4KYtukhrHjp+v3hcNOngHcHKOfUyyorObAVARex1mnCIlTKju58rCeNvvMWCxoi9L5dgrFkkoobJ5K7esqRdjQlE0FsA7SWXUkfp2E27mQGELSxyxLi6ipU8yvy2xlEfTmMTXoXmoxXLUTw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lYRCvmN84FYGRFGfldV3n2Ntb7Y890S0SJu8SXIImLQ=; b=iz6Axf2iS7KGwMf+c2zgy1qxIGw+E9RLPFjTHgSVtzvW/ITCATGqZtgquNbSaLrwY5oY7BgXcdFAelCY0jsKaXMZSloAiNTwZI51shw8ZpqaKwFZWC4tnBuWdAHGIZClG141Fl0BdfqF59/AevWI7IYdCcNx1cnEXIc5BYpKO/NY0hl7KkSG+BZjPFOJnQZCsAJbPnk17ljiVLPsULRp50TARiKD33GA0p5Y4uPB1GtIk2DqeATUgRKZJqKk3SyjGD2ZfnVImH1K0dokA7QOR9ZdweGPR8NxgPBLoiVvWwnnxNtN+0BgoKgGthU5gs4E+gn1QZ/ao7uLpq8kKmuITg== 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=lYRCvmN84FYGRFGfldV3n2Ntb7Y890S0SJu8SXIImLQ=; b=aE9RFjqDq5KObXC+qKc0svH0Ng/Moe4avUUWYHSPcC/cutrOox6AmbqOsKewOiDqRkY3oT+hZjNV7pCsjB+Y1zmJMmFfkVggKT3hpZwQfnwIWFJVeeGyxPtMBA5gEru+9VMMY+MaptcZEt9d0iomSTWY6Dx3ip9PjYVPl5ZsJmM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:39 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:39 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 14/15] net: pcs: mtip_backplane: add driver for MoreThanIP backplane AN/LT core Date: Sat, 23 Sep 2023 16:49:03 +0300 Message-Id: <20230923134904.3627402-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: e79efab6-07cf-43f8-b1ea-08dbbc3bee46 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6vvTJp/OWWw4EvYMZ/7+wLH7tF69nBzCMbYTN3WLIeIuXeM5nG/L2n9rVmVoLmbSpWrS7sdnkz89jmXZXjBeF78LjtkqYmW+m5vJa+tAc4py8lM/RzQbVuJjZEAy+NhU0A7h9PCA+kBP2J6i1FrGgRdW2kuOAtvjdieZDJaYeoW6DBDUE9FVkSBiKJphWF3cjHE+UE7ZwES/sqHcm2v1+Gw3LrnUMb73hBvtV+VSKkjEcHrVvC9u6xIHTCwDc+3+AOVJHeiMcD8s8jNQT7jha9fV8AAYz76eaM30s9ueNV9A3P8aEqptWwKA7uQly02Z8VSpzA6NQi8YJtwLyIMoeEt73gtyxAESGKEpCrqK7PuoF4hT7zPMp1CgymLULfVRvid57Epgc4Lm1ILOPbouynuI5IjrSsKLiMF0DFayAz2g3LOGP4nkl218kOs8bp4LEpTBgJa/Zxqbxqw6kQKYhTg0Df3j8nwHX5ppIJw6EPX6Fz3VWpWTBkRbhnf93AealwR6uVAcVjj0iyKWB+JP4DqcmwmCjpu+3jvEOgHC98aBSZs78O+XXaZcRgQ/SPeHmqXwtLsFmJdK7qZ13xkH/dI8m/8RpsLofzJHtN5ciSFX/uqy83vcMFrDCC8StM70 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(30864003)(86362001)(8676002)(83380400001)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R8oy83qf+/EHk6OWszWXDKnPlLQD66rBjtg3lgUcdRUD3jCjcw/No9mj7Zh3pVz0BlqeUi5cvRw3xx8ybo5aESTaPWpxf7G9kyiY3yTwrZvsXjv7+A7/7wLRhH4SJpOeCxgvTs6LwXR1jUsrPcVe/o/9P0qo6cYr0UUwgza4XMEtEohGvygEwM+flRfjzCuiiI78OsY1y4bY5T6qetAXaS2OFzyhUWWV5zJwKBJ7GXuAxcx04J/HGg1A6UkGDKrE++0i5iBPpbWrRqDSHXO0rlWTtVJjQ33TvQZJEIimthDli7ZvBMSD0e+Kdz+h1AHqxgcPgjLE1tQHgqc5KFXb2bzaW+MjX2TpgzPr+ALYLJoIfSCbeV1PV+bg9zTDledPw567AcQPkvkwXNHYHP7KAbr8jpl8YEBcbm3/Y/LvgZ8nFwfODDaTl3xPT9IWCdOo60V7+9corcbhKWUCcvQge0lZhuiAp2NVaLEeCnvEyOMu85wPnVz1tREQH51oSw3tGuxTyEFU5nGpLdWgpqn97+7LjRUluddzh8YMRGJY0zF4wEuhqQbR0/IJPxS93DiOKW/YQ/RcI0Xj4S0nmtlcbLB0ZQqC1S6ma9lsJvWG7EBxr5Bd53wsxQKLYsQuYJYl4p26O6DvnzRTVrD4cHT0YBK4Ti0tXx9Np6L2mc65NVbVhP+3xHrxMmje0h5J7KN01y+fdCITi/Jrs5jNY6bjmBbPutymjksyGE5R38G1PXHsgzzUAlrudV5nBIZjtAH8Qi404hm4DaVDijvZyb5I5JrM8cucD+81sdf2FBUVu0FwjifLzOlrYXEmAW8cJPpm4v2HI4xQ5SyNXBsBnOe5PRe/eiJZ8DavpkGSnx218BoXtIxEpnZaZBACGo0B/P6EdhDNggvWJbxKjPH4vD6NGdZoxfJBBaXwku4BKailhb1sQMczHoIB7GEJLeqAHbty9R9vZMMu8gZ6gJVNTsmk3R7xDHZt16UP+AsPjfXxaNPKBMf+/weGlfTfeAAa6hJ6Ks7plm/MPNHdSSykqe/aFM8Sr8zJEr5z1/MuGgmNEJ/d/pba6ww30DXnIZF1QOyFrgdd1x/sF8I79J7RAByHDmb/gkXZFiEJ1FyswZh0xJs9tuEx4ps/Knmz7JDJjR0+YB3zADdGlRhqXgtkQ69I2JHmhZ2IsVeeGhtmU+TLI2NbUVEvFQ4FH3kQmkkEDpqU+SymTrrcuZNw4NK4EW7mSYVBdEIB07Mqrdjmld92RYldIaNFF4Lf7gMEzFb64w6FlpjendUnxmxcKAqb5BdWNZTYr/D0DI50vCnlQbsGBaj6y0m/8nvI2PXjDftDU952T0Z9AR/aB0EPULAOyHl9gvRd6tQn8lgpJMf7epdwLFdZ+Cixozegehez38rWEQOjkeMHbxLPnWiB2TZtt7o/O/WDKIx/056DowJmKWRJzeVGbSeOpDawT6CJ2PalkfMDjyOPxfW4bHkDYzwvCssNZnpBUsgwFyihcW73urPicOytN5oz2yKPcs6idOe7YKw7Oh8hbAgB4yxFZjyEbJk1LsaqlabhX7o+vKkLTvfTnztPXFwdIE22QoW+BDdEmtYsPNF9XTvZ8a/xTvyZQKIXHA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e79efab6-07cf-43f8-b1ea-08dbbc3bee46 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:39.3456 (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: vD/tpxiZezb764EYCPG5H6zrto0M9jUzfpJ5GL947J8PB7SefjH6SmC5gf2RPS1GY/EUMGpzK2JvE9GmhyvcPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net For each networking SerDes lane on certain Layerscape SoCs, there is a block, based on an IP core from MoreThanIP, which optionally handles IEEE 802.3 clause 73 and clause 72, i.e. backplane auto-negotiation and link training. The hardware integration between the SerDes lane and this AN/LT block is rather weak. For this reason, there is no automatic link training performed in hardware, but rather, software needs to implement a custom, SerDes-specific link training algorithm and use the AN/LT registers to communicate it with the link partner. This driver is an inapt attempt to do just that. Since the MTIP AN/LT block may be, in premise, integrated in non-NXP SoCs as well, the implementation is as generic as possible. In fact, it is not a driver per se, but it is presented as library code which can be instantiated from the lynx phylink_pcs support code. Initial support is present only for the LX2160A SoC. Here, the register map of the IP block was a bit mangled, and we don't have any PHY ID for auto-detection. But, the location of the AN/LT block is detectable by querying the SerDes for the ANLTnCR1[MDEV_PORT] fields. Signed-off-by: Vladimir Oltean --- v1->v2: - support multi-lane link modes: see mtip_backplane_add_subordinate() as an entry point for what that support entails - replace phylib integration with phylink_pcs integration - auto-detect the location of the AN/LT block using the SerDes' MDEV_PORT registers, rather than hardcoding in the device tree. There are now no dt-bindings for the AN/LT block, just the Lynx PCS bindings were extended. - mtip_lt_frame_lock() was reading the wrong register, leading to incorrectly proceeding to link training when the other side wasn't yet ready for it - use mdiodev->addr instead of dev_name(dev) in the kthread workers' name, as it is shorter and it would have been impossible to distinguish names otherwise. But now it is not unique for different ports... - some reinterpretations of link training status fields, as well as a small rework of the control flow in mtip_local_tx_lt_work() and mtip_remote_tx_lt_work() - also advertise 25GBase-KR-S when advertising 25GBase-KR. The FEC/RS-FEC resolution and application is still TODO. - some more defensive workarounds in mtip_irqpoll_work() which end up restarting autoneg in circumstances where the AN/LT block enters a strange state - don't call mtip_start_irqpoll() since mtip_backplane_create(), but wait until mtip_backplane_resume() - aka disable polling when the link is administratively down drivers/net/pcs/Kconfig | 7 + drivers/net/pcs/Makefile | 1 + drivers/net/pcs/mtip_backplane.c | 2022 ++++++++++++++++++++++++++++++ drivers/net/pcs/mtip_backplane.h | 87 ++ 4 files changed, 2117 insertions(+) create mode 100644 drivers/net/pcs/mtip_backplane.c create mode 100644 drivers/net/pcs/mtip_backplane.h diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig index 87cf308fc6d8..24a033e93bdd 100644 --- a/drivers/net/pcs/Kconfig +++ b/drivers/net/pcs/Kconfig @@ -5,6 +5,13 @@ menu "PCS device drivers" +config MTIP_BACKPLANE_PHY + tristate "MoreThanIP copper backplane PHYs" + help + Enable support for the MoreThanIP copper backplane Auto-Negotiation + and Link Training blocks, as implemented on the QorIQ and Layerscape + SoCs. + config PCS_XPCS tristate select PHYLINK diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile index fb1694192ae6..08f9102c3fba 100644 --- a/drivers/net/pcs/Makefile +++ b/drivers/net/pcs/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers +obj-$(CONFIG_MTIP_BACKPLANE_PHY) += mtip_backplane.o pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-wx.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o diff --git a/drivers/net/pcs/mtip_backplane.c b/drivers/net/pcs/mtip_backplane.c new file mode 100644 index 000000000000..a4eb8b470215 --- /dev/null +++ b/drivers/net/pcs/mtip_backplane.c @@ -0,0 +1,2022 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Driver for MoreThanIP copper backplane AN/LT (Auto-Negotiation and + * Link Training) core + * + * Copyright 2023 NXP + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "mtip_backplane.h" + +#define BP_ETH_STAT_ALWAYS_1 BIT(0) +#define BP_ETH_STAT_1GKX BIT(1) +#define BP_ETH_STAT_10GKX4 BIT(2) +#define BP_ETH_STAT_10GKR BIT(3) +#define BP_ETH_STAT_FC_FEC BIT(4) +#define BP_ETH_STAT_40GKR4 BIT(5) +#define BP_ETH_STAT_40GCR4 BIT(6) +#define BP_ETH_STAT_RS_FEC BIT(7) +#define BP_ETH_STAT_100GCR10 BIT(8) +#define BP_ETH_STAT_100GKP4 BIT(9) +#define BP_ETH_STAT_100GKR4 BIT(10) +#define BP_ETH_STAT_100GCR4 BIT(11) +#define BP_ETH_STAT_25GKR_S BIT(12) +#define BP_ETH_STAT_25GKR BIT(13) + +#define BP_ETH_STAT_PARALLEL_DETECT (BP_ETH_STAT_ALWAYS_1 | \ + BP_ETH_STAT_1GKX | \ + BP_ETH_STAT_10GKX4) + +#define LT_CTRL_RESTART_TRAINING BIT(0) +#define LT_CTRL_TRAINING_ENABLE BIT(1) + +#define LT_STAT_RX_STATUS BIT(0) +#define LT_STAT_FRAME_LOCK BIT(1) +#define LT_STAT_STARTUP_PROTOCOL_STATUS BIT(2) +#define LT_STAT_TRAINING_FAILURE BIT(3) +#define LT_STAT_SIGNAL_DETECT BIT(15) + +#define LT_COM1_MASK GENMASK(1, 0) +#define LT_COZ_MASK GENMASK(3, 2) +#define LT_COP1_MASK GENMASK(5, 4) +#define LT_COM1(x) ((x) & LT_COM1_MASK) +#define LT_COM1_X(x) ((x) & LT_COM1_MASK) +#define LT_COZ(x) (((x) << 2) & LT_COZ_MASK) +#define LT_COZ_X(x) (((x) & LT_COZ_MASK) >> 2) +#define LT_COP1(x) (((x) << 4) & LT_COP1_MASK) +#define LT_COP1_X(x) (((x) & LT_COP1_MASK) >> 4) + +#define LT_COEF_STAT_MASK (LT_COM1_MASK | LT_COZ_MASK | LT_COP1_MASK) +#define LT_COEF_STAT_ALL_NOT_UPDATED(x) (((x) & LT_COEF_STAT_MASK) == 0) +#define LT_COEF_STAT_ANY_UPDATED(x) (((x) & LT_COEF_STAT_MASK) != 0) + +#define LT_COEF_UPD_MASK (LT_COM1_MASK | LT_COZ_MASK | LT_COP1_MASK) +#define LT_COEF_UPD_ALL_HOLD (LT_COM1(COEF_UPD_HOLD) | \ + LT_COZ(COEF_UPD_HOLD) | \ + LT_COP1(COEF_UPD_HOLD)) + +#define LT_COEF_UPD_ANYTHING(x) ((x) != 0) +#define LT_COEF_UPD_NOTHING(x) ((x) == 0) + +#define LT_COEF_UPD_INIT BIT(12) +#define LT_COEF_UPD_PRESET BIT(13) + +#define LT_COEF_STAT_RX_READY BIT(15) + +#define C73_ADV_0(x) (u16)((x) & GENMASK(15, 0)) +#define C73_ADV_1(x) (u16)(((x) & GENMASK(31, 16)) >> 16) +#define C73_ADV_2(x) (u16)(((x) & GENMASK_ULL(47, 32)) >> 32) + +#define IRQPOLL_INTERVAL (HZ / 4) + +#define MTIP_CDR_SLEEP_US 100 +#define MTIP_CDR_TIMEOUT_US 500000 + +#define MTIP_LT_END_SLEEP_US 10 +#define MTIP_LT_END_TIMEOUT_US 300000 + +#define MTIP_LT_RESTART_SLEEP_US 10 +#define MTIP_LT_RESTART_TIMEOUT_US 1000000 + +#define MTIP_FRAME_LOCK_SLEEP_US 10 +#define MTIP_FRAME_LOCK_TIMEOUT_US 1000000 + +#define MTIP_RESET_SLEEP_US 100 +#define MTIP_RESET_TIMEOUT_US 100000 + +#define MTIP_BP_ETH_STAT_SLEEP_US 10 +#define MTIP_BP_ETH_STAT_TIMEOUT_US 100 + +#define MTIP_COEF_STAT_SLEEP_US 10 +#define MTIP_COEF_STAT_TIMEOUT_US 500000 + +#define MTIP_LT_TIMEOUT_MS 1000 +#define MTIP_AN_TIMEOUT_MS 10000 + +#define MTIP_MAX_NUM_SUBORDINATES 3 + +enum mtip_an_reg { + AN_CTRL, + AN_STAT, + AN_ADV_0, + AN_ADV_1, + AN_ADV_2, + AN_LPA_0, + AN_LPA_1, + AN_LPA_2, + AN_MS_CNT, + AN_ADV_XNP_0, + AN_ADV_XNP_1, + AN_ADV_XNP_2, + AN_LPA_XNP_0, + AN_LPA_XNP_1, + AN_LPA_XNP_2, + AN_BP_ETH_STAT, +}; + +enum mtip_lt_reg { + LT_CTRL, + LT_STAT, + LT_LP_COEF, + LT_LP_STAT, + LT_LD_COEF, + LT_LD_STAT, + LT_TRAIN_PATTERN, + LT_RX_PATTERN, + LT_RX_PATTERN_ERR, + LT_RX_PATTERN_BEGIN, +}; + +struct mtip_irqpoll { + struct mutex lock; + struct delayed_work work; + u16 old_an_stat; + u16 old_pcs_stat; + bool link; + bool link_ack; + bool cdr_locked; + bool run_once; +}; + +struct mtip_lt_work { + struct mtip_backplane *priv; + struct kthread_work work; +}; + +struct mtip_backplane; + +struct mtip_backplane { + struct mdio_device *mdiodev; + struct mdio_device *pcs_mdiodev; + union { + struct mtip_backplane *subordinate[MTIP_MAX_NUM_SUBORDINATES]; + struct mtip_backplane *coordinator; + }; + bool is_subordinate; + int num_subordinates; + struct phylink_pcs *pcs; + struct phy *serdes; + const u16 *an_regs; + const u16 *lt_regs; + int lt_mmd; + enum ethtool_link_mode_bit_indices link_mode; + bool link_mode_resolved; + bool lane_powered_on; + bool any_request_received; + unsigned long last_lt_done; + unsigned long last_an_restart; + struct mtip_irqpoll irqpoll; + struct kthread_worker *local_tx_lt_worker; + struct kthread_worker *remote_tx_lt_worker; + /* Serialized by an_restart_lock */ + bool an_restart_pending; + bool an_enabled; + /* Used for orderly shutdown of LT threads. Modified without any + * locking. Set to true only by the irqpoll thread, set to false + * by irqpoll and by the LT threads. + */ + bool lt_stop_request; + bool lt_enabled; + bool local_tx_lt_done; + bool remote_tx_lt_done; + /* Serialize concurrent attempts from the local TX and remote TX + * kthreads to finalize their side of the link training + */ + struct mutex lt_lock; + struct mutex an_restart_lock; +}; + +/* Auto-Negotiation Control and Status Registers are on page 0: 0x0 */ +static const u16 mtip_lx2160a_an_regs[] = { + [AN_CTRL] = 0, + [AN_STAT] = 1, + [AN_ADV_0] = 2, + [AN_ADV_1] = 3, + [AN_ADV_2] = 4, + [AN_LPA_0] = 5, + [AN_LPA_1] = 6, + [AN_LPA_2] = 7, + [AN_MS_CNT] = 8, + [AN_ADV_XNP_0] = 9, + [AN_ADV_XNP_1] = 10, + [AN_ADV_XNP_2] = 11, + [AN_LPA_XNP_0] = 12, + [AN_LPA_XNP_1] = 13, + [AN_LPA_XNP_2] = 14, + [AN_BP_ETH_STAT] = 15, +}; + +/* Link Training Control and Status Registers are on page 1: 256 = 0x100 */ +static const u16 mtip_lx2160a_lt_regs[] = { + [LT_CTRL] = 0x100, + [LT_STAT] = 0x101, + [LT_LP_COEF] = 0x102, + [LT_LP_STAT] = 0x103, + [LT_LD_COEF] = 0x104, + [LT_LD_STAT] = 0x105, + [LT_TRAIN_PATTERN] = 0x108, + [LT_RX_PATTERN] = 0x109, + [LT_RX_PATTERN_ERR] = 0x10a, + [LT_RX_PATTERN_BEGIN] = 0x10b, +}; + +/* Keep sorted in order of decreasing link speeds */ +static const enum ethtool_link_mode_bit_indices mtip_backplane_link_modes[] = { + ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, + ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, + ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT, + ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, +}; + +static bool +link_mode_needs_training(enum ethtool_link_mode_bit_indices link_mode) +{ + if (link_mode == ETHTOOL_LINK_MODE_1000baseKX_Full_BIT) + return false; + + return true; +} + +static int for_each_lane(int (*cb)(struct mtip_backplane *priv), + struct mtip_backplane *priv) +{ + int i, err; + + err = cb(priv); + if (err) + return err; + + for (i = 0; i < priv->num_subordinates; i++) { + err = cb(priv->subordinate[i]); + if (err) + return err; + } + + return 0; +} + +static int for_each_lane_args(int (*cb)(struct mtip_backplane *priv, + void *args), + struct mtip_backplane *priv, void *args) +{ + int i, err; + + err = cb(priv, args); + if (err) + return err; + + for (i = 0; i < priv->num_subordinates; i++) { + err = cb(priv->subordinate[i], args); + if (err) + return err; + } + + return 0; +} + +static int mtip_read_an(struct mtip_backplane *priv, enum mtip_an_reg reg) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_read(mdiodev, MDIO_MMD_AN, priv->an_regs[reg]); +} + +static int mtip_write_an(struct mtip_backplane *priv, enum mtip_an_reg reg, + u16 val) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_write(mdiodev, MDIO_MMD_AN, priv->an_regs[reg], + val); +} + +static int mtip_modify_an(struct mtip_backplane *priv, enum mtip_an_reg reg, + u16 mask, u16 set) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_modify(mdiodev, MDIO_MMD_AN, priv->an_regs[reg], + mask, set); +} + +static int mtip_read_lt(struct mtip_backplane *priv, enum mtip_lt_reg reg) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_read(mdiodev, priv->lt_mmd, priv->lt_regs[reg]); +} + +static int mtip_write_lt(struct mtip_backplane *priv, enum mtip_lt_reg reg, + u16 val) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_write(mdiodev, priv->lt_mmd, priv->lt_regs[reg], + val); +} + +static int mtip_modify_lt(struct mtip_backplane *priv, enum mtip_lt_reg reg, + u16 mask, u16 set) +{ + struct mdio_device *mdiodev = priv->mdiodev; + + return mdiodev_c45_modify(mdiodev, priv->lt_mmd, priv->lt_regs[reg], + mask, set); +} + +static int mtip_read_pcs(struct mtip_backplane *priv, int reg) +{ + struct mdio_device *mdiodev = priv->pcs_mdiodev; + + return mdiodev_c45_read(mdiodev, MDIO_MMD_PCS, reg); +} + +static int mtip_reset_pcs(struct mtip_backplane *priv) +{ + struct mdio_device *mdiodev = priv->pcs_mdiodev; + int err, val; + + err = mdiodev_c45_modify(mdiodev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_CTRL1_RESET, MDIO_CTRL1_RESET); + if (err < 0) + return err; + + err = read_poll_timeout(mdiodev_c45_read, val, + val < 0 || !(val & MDIO_CTRL1_RESET), + MTIP_RESET_SLEEP_US, MTIP_RESET_TIMEOUT_US, + false, mdiodev, MDIO_MMD_PCS, MDIO_CTRL1); + + return (val < 0) ? val : err; +} + +static int mtip_reset_an(struct mtip_backplane *priv) +{ + int err, val; + + err = mtip_modify_an(priv, AN_CTRL, MDIO_CTRL1_RESET, + MDIO_CTRL1_RESET); + if (err < 0) + return err; + + err = read_poll_timeout(mtip_read_an, val, + val < 0 || !(val & MDIO_CTRL1_RESET), + MTIP_RESET_SLEEP_US, MTIP_RESET_TIMEOUT_US, + false, priv, AN_CTRL); + + return (val < 0) ? val : err; +} + +static int mtip_check_cdr_lock(struct mtip_backplane *priv, + bool *all_lanes_have_cdr_lock) +{ + union phy_status_opts opts = {}; + int i, err; + + err = phy_get_status(priv->serdes, PHY_STATUS_CDR_LOCK, &opts); + if (err) + return err; + + *all_lanes_have_cdr_lock = opts.cdr.cdr_locked; + + /* Until C73 resolves a link mode, only the primary lane needs + * to have CDR lock. The others may even be powered off. + */ + if (!priv->link_mode_resolved || !*all_lanes_have_cdr_lock) + return 0; + + for (i = 0; i < priv->num_subordinates; i++) { + err = phy_get_status(priv->subordinate[i]->serdes, + PHY_STATUS_CDR_LOCK, &opts); + if (err) + return err; + + if (!opts.cdr.cdr_locked) { + *all_lanes_have_cdr_lock = false; + return 0; + } + } + + return 0; +} + +static int mtip_wait_for_cdr_lock(struct mtip_backplane *priv) +{ + bool cdr_locked; + int err, val; + + err = read_poll_timeout(mtip_check_cdr_lock, val, + val < 0 || cdr_locked, + MTIP_CDR_SLEEP_US, MTIP_CDR_TIMEOUT_US, + false, priv, &cdr_locked); + + return (val < 0) ? val : err; +} + +int mtip_backplane_validate(struct mtip_backplane *priv, + unsigned long *supported) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(mtip_supported) = {}; + const enum ethtool_link_mode_bit_indices *link_modes; + int i, err; + + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, mtip_supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_Backplane_BIT, mtip_supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, mtip_supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, mtip_supported); + + link_modes = mtip_backplane_link_modes; + + /* Ask the SerDes driver what link modes are supported, + * based on the current PLL configuration. + */ + for (i = 0; i < ARRAY_SIZE(mtip_backplane_link_modes); i++) { + err = phy_validate(priv->serdes, PHY_MODE_ETHTOOL, + link_modes[i], NULL); + if (err) + continue; + + linkmode_set_bit(link_modes[i], mtip_supported); + } + + linkmode_and(supported, supported, mtip_supported); + + return 0; +} +EXPORT_SYMBOL(mtip_backplane_validate); + +static void mtip_start_irqpoll(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + + if (priv->is_subordinate) + return; + + schedule_delayed_work(&irqpoll->work, 0); +} + +static void mtip_stop_irqpoll(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + + if (priv->is_subordinate) + return; + + cancel_delayed_work_sync(&irqpoll->work); +} + +static void mtip_run_irqpoll_once(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + + if (priv->is_subordinate) + return; + + irqpoll->run_once = true; + schedule_delayed_work(&irqpoll->work, 0); +} + +int mtip_backplane_suspend(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + mtip_stop_irqpoll(priv); + + err = phy_power_off(priv->serdes); + if (err) { + dev_err(dev, "Failed to power off SerDes: %pe\n", + ERR_PTR(err)); + return err; + } + + priv->lane_powered_on = false; + + /* The link will drop via the CDR lock check after we power off the + * SerDes lane, and that is not latched low. So we need to schedule + * the irqpoll thread once more, so that we don't miss the event. + */ + mtip_run_irqpoll_once(priv); + + return 0; +} +EXPORT_SYMBOL(mtip_backplane_suspend); + +int mtip_backplane_resume(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + err = phy_power_on(priv->serdes); + if (err) { + dev_err(dev, "Failed to power on SerDes: %pe\n", ERR_PTR(err)); + return err; + } + + priv->lane_powered_on = true; + + if (!priv->is_subordinate) + mtip_start_irqpoll(priv); + + return 0; +} +EXPORT_SYMBOL(mtip_backplane_resume); + +/* Our LT_LP_STAT register updates only after receiving training frames, so + * unless we wait for it to lock, there is a risk that after a renegotiation, + * we act upon information from the previous link training process. + */ +static int mtip_lt_frame_lock(struct mtip_backplane *priv) +{ + int err, val; + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || (val & LT_STAT_FRAME_LOCK), + MTIP_FRAME_LOCK_SLEEP_US, MTIP_FRAME_LOCK_TIMEOUT_US, + false, priv, LT_STAT); + + return (val < 0) ? val : err; +} + +static int mtip_restart_lt(struct mtip_backplane *priv, bool enable) +{ + u16 mask = LT_CTRL_RESTART_TRAINING | LT_CTRL_TRAINING_ENABLE; + u16 set = LT_CTRL_RESTART_TRAINING; + int err, val; + + if (enable) + set |= LT_CTRL_TRAINING_ENABLE; + + err = mtip_modify_lt(priv, LT_CTRL, mask, set); + if (err < 0) + return err; + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || !(val & LT_CTRL_RESTART_TRAINING), + MTIP_LT_RESTART_SLEEP_US, MTIP_LT_RESTART_TIMEOUT_US, + false, priv, LT_CTRL); + + return (val < 0) ? val : err; +} + +/* Enable the lane datapath by disconnecting it from the AN/LT block + * and connecting it to the PCS. This is called both from the irqpoll thread, + * as well as from the last link training kthread to finish. + */ +static int mtip_finish_lt(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + if (!priv->lt_enabled) + return 0; + + err = mtip_restart_lt(priv, false); + if (err) { + dev_err(dev, "Failed to disable link training: %pe\n", + ERR_PTR(err)); + return err; + } + + /* Subsequent attempts to disable LT will time out, so stop them */ + priv->lt_enabled = false; + + return 0; +} + +static struct mtip_irqpoll *mtip_get_irqpoll(struct mtip_backplane *priv) +{ + if (priv->is_subordinate) + return &priv->coordinator->irqpoll; + + return &priv->irqpoll; +} + +static int mtip_stop_lt(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = mtip_get_irqpoll(priv); + struct device *dev = &priv->mdiodev->dev; + int err; + + lockdep_assert_held(&irqpoll->lock); + + kthread_flush_worker(priv->remote_tx_lt_worker); + kthread_flush_worker(priv->local_tx_lt_worker); + + err = mtip_finish_lt(priv); + if (err) + return err; + + dev_dbg(dev, "Link training disabled\n"); + + return 0; +} + +static int mtip_reset_lt(struct mtip_backplane *priv) +{ + int err; + + /* Don't allow AN to complete without training */ + err = mtip_modify_lt(priv, LT_STAT, LT_STAT_RX_STATUS, 0); + if (err < 0) + return err; + + err = mtip_write_lt(priv, LT_LD_COEF, 0); + if (err < 0) + return err; + + err = mtip_write_lt(priv, LT_LD_STAT, 0); + if (err < 0) + return err; + + priv->any_request_received = false; + + return 0; +} + +/* Reset state when detecting that the previously determined link mode + * is no longer valid + */ +static int mtip_state_reset(struct mtip_backplane *priv) +{ + int i, err; + + priv->link_mode_resolved = false; + + err = for_each_lane(mtip_stop_lt, priv); + if (err) + return err; + + err = for_each_lane(mtip_reset_lt, priv); + if (err < 0) + return err; + + /* 802.3-2018 clause 73.5.1 recommends: "For any multi-lane PHY, DME + * pages shall be transmitted only on lane 0. The transmitters on other + * lanes should be disabled". Let's do that and only keep them enabled + * when the link mode has been resolved. + */ + for (i = 0; i < priv->num_subordinates; i++) { + if (priv->subordinate[i]->lane_powered_on) { + err = mtip_backplane_suspend(priv->subordinate[i]); + if (err) + return err; + } + } + + priv->local_tx_lt_done = false; + priv->remote_tx_lt_done = false; + priv->lt_stop_request = false; + + /* If we received a new base page and the local link training threads + * also requested an autoneg restart, it's pointless to fulfill it now. + * Clear the request here, after the link training was stopped, so that + * we don't race with it. + */ + priv->an_restart_pending = false; + + return 0; +} + +/* Make sure we don't act on old event bits from previous runs when + * we restart autoneg. + */ +static int mtip_unlatch_an_stat(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + int val; + + lockdep_assert_held(&irqpoll->lock); + + val = mtip_read_an(priv, AN_STAT); + if (val < 0) + return val; + + /* Discard the current AN status, it will become invalid soon */ + irqpoll->old_an_stat = 0; + + return 0; +} + +/* Suppress a "PCS link dropped, restarting autoneg" event when initiating + * an autoneg restart locally. + */ +static int mtip_unlatch_pcs_stat(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + + irqpoll->old_pcs_stat = 0; + + return 0; +} + +static int mtip_read_adv(struct mtip_backplane *priv, u64 *base_page) +{ + int val; + + val = mtip_read_an(priv, AN_ADV_0); + if (val < 0) + return val; + + *base_page = (u64)val; + + val = mtip_read_an(priv, AN_ADV_1); + if (val < 0) + return val; + + *base_page |= (u64)val << 16; + + val = mtip_read_an(priv, AN_ADV_2); + if (val < 0) + return val; + + *base_page |= (u64)val << 32; + + return 0; +} + +static int mtip_write_adv(struct mtip_backplane *priv, u64 base_page) +{ + int val; + + val = mtip_write_an(priv, AN_ADV_0, C73_ADV_0(base_page)); + if (val < 0) + return val; + + val = mtip_write_an(priv, AN_ADV_1, C73_ADV_1(base_page)); + if (val < 0) + return val; + + val = mtip_write_an(priv, AN_ADV_2, C73_ADV_2(base_page)); + if (val < 0) + return val; + + return 0; +} + +static int mtip_read_lpa(struct mtip_backplane *priv, u64 *base_page) +{ + int val; + + val = mtip_read_an(priv, AN_LPA_0); + if (val < 0) + return val; + + *base_page = (u64)val; + + val = mtip_read_an(priv, AN_LPA_1); + if (val < 0) + return val; + + *base_page |= (u64)val << 16; + + val = mtip_read_an(priv, AN_LPA_2); + if (val < 0) + return val; + + *base_page |= (u64)val << 32; + + return 0; +} + +static int mtip_config_an_adv(struct mtip_backplane *priv, + const unsigned long *advertising) +{ + u64 base_page = linkmode_adv_to_c73_base_page(advertising); + u8 nonce; + + /* The transmitted nonce must not be equal with the one transmitted by + * the link partner, otherwise AN will not complete (nonce_match=true). + */ + get_random_bytes(&nonce, sizeof(nonce)); + + base_page |= C73_BASE_PAGE_TRANSMITTED_NONCE(nonce); + /* According to Annex 28A, set Selector to "IEEE 802.3" */ + base_page |= C73_BASE_PAGE_SELECTOR(1); + /* C73_BASE_PAGE_ACK and C73_BASE_PAGE_ECHOED_NONCE seem to have + * a life of their own, regardless of what we set them to. + */ + + return mtip_write_adv(priv, base_page); +} + +static int mtip_an_restart(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + dev_dbg(dev, "Link training requests autoneg restart\n"); + + err = mtip_state_reset(priv); + if (err) + return err; + + /* Make sure AN is temporarily disabled, so that we can safely + * unlatch the previous status without losing real events + */ + err = mtip_reset_an(priv); + if (err < 0) + return err; + + err = mtip_unlatch_an_stat(priv); + if (err) + return err; + + err = mtip_unlatch_pcs_stat(priv); + if (err) + return err; + + err = mtip_modify_an(priv, AN_CTRL, + MDIO_AN_CTRL1_ENABLE | MDIO_AN_CTRL1_RESTART, + MDIO_AN_CTRL1_ENABLE | MDIO_AN_CTRL1_RESTART); + if (err < 0) + return err; + + priv->last_an_restart = jiffies; + priv->an_restart_pending = false; + + return 0; +} + +void mtip_backplane_an_restart(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + struct device *dev = &priv->mdiodev->dev; + int err; + + mutex_lock(&irqpoll->lock); + + if (!priv->an_enabled) + goto out_unlock; + + err = mtip_an_restart(priv); + if (err) + dev_err(dev, "Failed to restart backplane autoneg: %pe\n", + ERR_PTR(err)); + +out_unlock: + mutex_unlock(&irqpoll->lock); +} +EXPORT_SYMBOL(mtip_backplane_an_restart); + +/* The reason for deferral is that the irqpoll thread waits for the LT kthreads + * to finish with irqpoll->lock held, and AN restart also requires holding the + * irqpoll->lock. So the kthreads cannot directly restart autoneg without + * deadlocking with the irqpoll thread, they must signal to the irqpoll thread + * to do so. + */ +static void mtip_an_restart_from_lt(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + struct mtip_backplane *coordinator; + + dev_dbg(dev, "Link training requests autoneg restart\n"); + + coordinator = priv->is_subordinate ? priv->coordinator : priv; + + mutex_lock(&coordinator->an_restart_lock); + coordinator->an_restart_pending = true; + mutex_unlock(&coordinator->an_restart_lock); +} + +static int mtip_wait_for_lt_end(struct mtip_backplane *priv) +{ + int err, val; + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || !(val & LT_STAT_STARTUP_PROTOCOL_STATUS), + MTIP_LT_END_SLEEP_US, MTIP_LT_END_TIMEOUT_US, + false, priv, LT_STAT); + + return (val < 0) ? val : err; +} + +static int mtip_finalize_lt(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + union phy_configure_opts opts = { + .ethernet = { + .type = C72_LT_DONE, + }, + }; + int err, val; + + lockdep_assert_held(&priv->lt_lock); + + if (!priv->local_tx_lt_done || !priv->remote_tx_lt_done) + return 0; + + priv->last_lt_done = jiffies; + + /* Let the local state machine know we're done */ + err = mtip_modify_lt(priv, LT_STAT, LT_STAT_RX_STATUS, + LT_STAT_RX_STATUS); + if (err < 0) { + dev_err(dev, "Failed to update LT_STAT: %pe\n", ERR_PTR(err)); + return err; + } + + /* Give some time for the LP to see our training frames + * with "RX ready", before disabling link training. + */ + err = mtip_wait_for_lt_end(priv); + if (err) { + /* With 25G, this can often be seen to fail, but it seems + * inconsequential, so ignore it + */ + dev_warn(dev, + "Failed to wait for the Start-up Protocol Status bit to clear: %pe, LT_STAT = 0x%x\n", + ERR_PTR(err), mtip_read_lt(priv, LT_STAT)); + } + + err = mtip_finish_lt(priv); + if (err) + return err; + + val = mtip_read_lt(priv, LT_STAT); + if (val < 0) + return val; + + if (!(val & LT_STAT_SIGNAL_DETECT)) { + dev_err(dev, "Link training did not succeed: LT_STAT = 0x%x\n", + val); + return -ENETDOWN; + } + + return phy_configure(priv->serdes, &opts); +} + +static int mtip_tx_c72_coef_update(struct mtip_backplane *priv, + const struct c72_coef_update *upd, + struct c72_coef_status *stat) +{ + char upd_buf[C72_COEF_UPDATE_BUFSIZ], stat_buf[C72_COEF_STATUS_BUFSIZ]; + struct device *dev = &priv->mdiodev->dev; + int err, val; + u16 ld_coef; + + c72_coef_update_print(upd, upd_buf); + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || LT_COEF_STAT_ALL_NOT_UPDATED(val), + MTIP_COEF_STAT_SLEEP_US, MTIP_COEF_STAT_TIMEOUT_US, + false, priv, LT_LP_STAT); + if (val < 0) + return val; + if (err) { + dev_err(dev, + "LP did not set coefficient status to NOT_UPDATED, couldn't send %s; LP_STAT = 0x%x\n", + upd_buf, val); + return err; + } + + ld_coef = LT_COM1(upd->com1) | LT_COZ(upd->coz) | LT_COP1(upd->cop1); + if (upd->init) + ld_coef |= LT_COEF_UPD_INIT; + if (upd->preset) + ld_coef |= LT_COEF_UPD_PRESET; + + err = mtip_write_lt(priv, LT_LD_COEF, ld_coef); + if (err < 0) + return err; + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || LT_COEF_STAT_ANY_UPDATED(val), + MTIP_COEF_STAT_SLEEP_US, MTIP_COEF_STAT_TIMEOUT_US, + false, priv, LT_LP_STAT); + if (val < 0) + return val; + if (err) { + dev_err(dev, + "LP did not update coefficient status for %s; LP_STAT = 0x%x\n", + upd_buf, val); + return err; + } + + stat->com1 = LT_COM1_X(val); + stat->coz = LT_COZ_X(val); + stat->cop1 = LT_COP1_X(val); + c72_coef_status_print(stat, stat_buf); + + ld_coef = LT_COM1(COEF_UPD_HOLD) | LT_COZ(COEF_UPD_HOLD) | + LT_COP1(COEF_UPD_HOLD); + err = mtip_write_lt(priv, LT_LD_COEF, ld_coef); + if (err < 0) + return err; + + dev_dbg(dev, "Sent update: %s, got status: %s\n", upd_buf, stat_buf); + + return 0; +} + +static int mtip_c72_process_request(struct mtip_backplane *priv, + const struct c72_coef_update *upd, + struct c72_coef_status *stat) +{ + union phy_configure_opts opts = { + .ethernet = { + .type = C72_LOCAL_TX, + .local_tx = { + .update = *upd, + }, + }, + }; + int err; + + err = phy_configure(priv->serdes, &opts); + if (err) + return err; + + *stat = opts.ethernet.local_tx.status; + priv->any_request_received = true; + + return 0; +} + +static int mtip_read_lt_lp_coef_if_not_ready(struct mtip_backplane *priv, + bool *rx_ready) +{ + int val; + + val = mtip_read_lt(priv, LT_LP_STAT); + if (val < 0) + return val; + + *rx_ready = !!(val & LT_COEF_STAT_RX_READY); + if (*rx_ready) + return 0; + + return mtip_read_lt(priv, LT_LP_COEF); +} + +static int mtip_rx_c72_coef_update(struct mtip_backplane *priv, + struct c72_coef_update *upd, + bool *rx_ready) +{ + char upd_buf[C72_COEF_UPDATE_BUFSIZ], stat_buf[C72_COEF_STATUS_BUFSIZ]; + struct device *dev = &priv->mdiodev->dev; + struct c72_coef_status stat = {}; + int err, val; + + err = read_poll_timeout(mtip_read_lt_lp_coef_if_not_ready, + val, val < 0 || *rx_ready || LT_COEF_UPD_ANYTHING(val), + MTIP_COEF_STAT_SLEEP_US, MTIP_COEF_STAT_TIMEOUT_US, + false, priv, rx_ready); + if (val < 0) + return val; + if (*rx_ready) { + if (!priv->any_request_received) + dev_warn(dev, + "LP says its RX is ready, but there was no coefficient request (LP_STAT = 0x%x, LD_STAT = 0x%x)\n", + mtip_read_lt(priv, LT_LP_STAT), + mtip_read_lt(priv, LT_LD_STAT)); + else + dev_dbg(dev, "LP says its RX is ready\n"); + return 0; + } + if (err) { + dev_err(dev, + "LP did not request coefficient updates; LP_COEF = 0x%x\n", + val); + return err; + } + + upd->com1 = LT_COM1_X(val); + upd->coz = LT_COZ_X(val); + upd->cop1 = LT_COP1_X(val); + upd->init = !!(val & LT_COEF_UPD_INIT); + upd->preset = !!(val & LT_COEF_UPD_PRESET); + c72_coef_update_print(upd, upd_buf); + + if ((upd->com1 || upd->coz || upd->cop1) + upd->init + upd->preset > 1) { + dev_warn(dev, "Ignoring illegal request: %s (LP_COEF = 0x%x)\n", + upd_buf, val); + return 0; + } + + err = mtip_c72_process_request(priv, upd, &stat); + if (err) + return err; + + c72_coef_status_print(&stat, stat_buf); + dev_dbg(dev, "Received update: %s, responded with status: %s\n", + upd_buf, stat_buf); + + err = mtip_modify_lt(priv, LT_LD_STAT, LT_COEF_STAT_MASK, + LT_COM1(stat.com1) | LT_COZ(stat.coz) | + LT_COP1(stat.cop1)); + if (err < 0) + return err; + + err = read_poll_timeout(mtip_read_lt, val, + val < 0 || LT_COEF_UPD_NOTHING(val), + MTIP_COEF_STAT_SLEEP_US, MTIP_COEF_STAT_TIMEOUT_US, + false, priv, LT_LP_COEF); + if (val < 0) + return val; + if (err) { + dev_err(dev, "LP did not revert to HOLD; LP_COEF = 0x%x\n", + val); + return err; + } + + err = mtip_modify_lt(priv, LT_LD_STAT, LT_COEF_STAT_MASK, + LT_COM1(COEF_STAT_NOT_UPDATED) | + LT_COZ(COEF_STAT_NOT_UPDATED) | + LT_COP1(COEF_STAT_NOT_UPDATED)); + if (err < 0) + return err; + + return 0; +} + +static int mtip_local_tx_lt_done(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + mutex_lock(&priv->lt_lock); + + priv->local_tx_lt_done = true; + + err = mtip_finalize_lt(priv); + if (!err) + dev_dbg(dev, "Link training for local TX done\n"); + + mutex_unlock(&priv->lt_lock); + + return err; +} + +static int mtip_remote_tx_lt_done(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + mutex_lock(&priv->lt_lock); + + priv->remote_tx_lt_done = true; + + err = mtip_finalize_lt(priv); + if (!err) + dev_dbg(dev, "Link training for remote TX done\n"); + + mutex_unlock(&priv->lt_lock); + + return err; +} + +/* This is our hardware-based 500 ms timer for the link training */ +static int mtip_lt_in_progress(struct mtip_backplane *priv) +{ + int val; + + val = mtip_read_lt(priv, LT_STAT); + if (val < 0) + return val; + + return !!(val & LT_STAT_TRAINING_FAILURE) ? -ETIMEDOUT : 0; +} + +/* Make adjustments to the local TX according to link partner requests, + * so that its RX improves + */ +static void mtip_local_tx_lt_work(struct kthread_work *work) +{ + struct mtip_lt_work *lt_work = container_of(work, struct mtip_lt_work, + work); + struct mtip_backplane *priv = lt_work->priv; + struct device *dev = &priv->mdiodev->dev; + int err; + + while (!READ_ONCE(priv->lt_stop_request)) { + struct c72_coef_update upd = {}; + bool rx_ready; + + err = mtip_lt_in_progress(priv); + if (err) { + dev_err(dev, "Local TX LT failed: %pe\n", ERR_PTR(err)); + break; + } + + err = mtip_rx_c72_coef_update(priv, &upd, &rx_ready); + if (err) + goto out; + + if (rx_ready) { + err = mtip_local_tx_lt_done(priv); + if (err) { + dev_err(dev, "Failed to finalize local LT: %pe\n", + ERR_PTR(err)); + goto out; + } + break; + } + } + +out: + if (err && !READ_ONCE(priv->lt_stop_request)) + mtip_an_restart_from_lt(priv); + + kfree(lt_work); +} + +/* Train the link partner TX, so that the local RX quality improves */ +static void mtip_remote_tx_lt_work(struct kthread_work *work) +{ + struct mtip_lt_work *lt_work = container_of(work, struct mtip_lt_work, + work); + struct mtip_backplane *priv = lt_work->priv; + struct device *dev = &priv->mdiodev->dev; + int err; + + while (true) { + struct c72_coef_status status = {}; + union phy_configure_opts opts = { + .ethernet = { + .type = C72_REMOTE_TX, + }, + }; + + if (READ_ONCE(priv->lt_stop_request)) + goto out; + + err = mtip_lt_in_progress(priv); + if (err) { + dev_err(dev, "Remote TX LT failed: %pe\n", ERR_PTR(err)); + goto out; + } + + err = phy_configure(priv->serdes, &opts); + if (err) { + dev_err(dev, + "Failed to get remote TX training request from SerDes: %pe\n", + ERR_PTR(err)); + goto out; + } + + if (opts.ethernet.remote_tx.rx_ready) + break; + + err = mtip_tx_c72_coef_update(priv, &opts.ethernet.remote_tx.update, + &status); + if (opts.ethernet.remote_tx.cb) + opts.ethernet.remote_tx.cb(opts.ethernet.remote_tx.cb_priv, + err, opts.ethernet.remote_tx.update, + status); + if (err) + goto out; + } + + /* Let the link partner know we're done */ + err = mtip_modify_lt(priv, LT_LD_STAT, LT_COEF_STAT_RX_READY, + LT_COEF_STAT_RX_READY); + if (err < 0) { + dev_err(dev, "Failed to update LT_LD_STAT: %pe\n", + ERR_PTR(err)); + goto out; + } + + err = mtip_remote_tx_lt_done(priv); + if (err) { + dev_err(dev, "Failed to finalize remote LT: %pe\n", + ERR_PTR(err)); + goto out; + } + +out: + if (err && !READ_ONCE(priv->lt_stop_request)) + mtip_an_restart_from_lt(priv); + + kfree(lt_work); +} + +static int mtip_start_lt(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = mtip_get_irqpoll(priv); + struct device *dev = &priv->mdiodev->dev; + struct mtip_lt_work *remote_tx_lt_work; + struct mtip_lt_work *local_tx_lt_work; + int err; + + lockdep_assert_held(&irqpoll->lock); + + local_tx_lt_work = kzalloc(sizeof(*local_tx_lt_work), GFP_KERNEL); + if (!local_tx_lt_work) { + err = -ENOMEM; + goto out; + } + + remote_tx_lt_work = kzalloc(sizeof(*remote_tx_lt_work), GFP_KERNEL); + if (!remote_tx_lt_work) { + err = -ENOMEM; + goto out_free_local_tx_lt; + } + + err = mtip_reset_lt(priv); + if (err) + goto out_free_remote_tx_lt; + + err = mtip_restart_lt(priv, true); + if (err) + goto out_free_remote_tx_lt; + + priv->lt_enabled = true; + + dev_dbg(dev, "Link training enabled\n"); + + err = mtip_lt_frame_lock(priv); + if (err) { + dev_err(dev, + "Failed to acquire training frame delineation: %pe\n", + ERR_PTR(err)); + goto out_stop_lt; + } + + local_tx_lt_work->priv = priv; + kthread_init_work(&local_tx_lt_work->work, mtip_local_tx_lt_work); + kthread_queue_work(priv->local_tx_lt_worker, &local_tx_lt_work->work); + + remote_tx_lt_work->priv = priv; + kthread_init_work(&remote_tx_lt_work->work, mtip_remote_tx_lt_work); + kthread_queue_work(priv->remote_tx_lt_worker, &remote_tx_lt_work->work); + + return 0; + +out_stop_lt: + mtip_finish_lt(priv); +out_free_remote_tx_lt: + kfree(remote_tx_lt_work); +out_free_local_tx_lt: + kfree(local_tx_lt_work); +out: + dev_err(dev, "Failed to start link training: %pe\n", ERR_PTR(err)); + return err; +} + +/* Allow the datapath to come up without link training */ +static int mtip_bypass_lt(struct mtip_backplane *priv) +{ + struct device *dev = &priv->mdiodev->dev; + int err; + + err = mtip_modify_lt(priv, LT_STAT, LT_STAT_RX_STATUS, + LT_STAT_RX_STATUS); + if (err < 0) { + dev_err(dev, "Failed to bypass link training: %pe\n", + ERR_PTR(err)); + return err; + } + + return 0; +} + +static void mtip_update_link_latch(struct mtip_backplane *priv, + bool cdr_locked, bool phy_los, + bool an_complete, bool pcs_lstat) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + struct device *dev = &priv->mdiodev->dev; + + lockdep_assert_held(&irqpoll->lock); + + /* Update irqpoll->link if true, or if false + * and mtip_read_status() saw that already. + */ + if (irqpoll->link || irqpoll->link_ack) { + irqpoll->link = phy_los && cdr_locked && an_complete && pcs_lstat; + irqpoll->link_ack = false; + } + + dev_dbg(dev, "PCS link%s: %d, PHY LOS: %d, CDR locked: %d, AN complete: %d\n", + priv->link_mode_resolved ? "" : " (ignored)", + pcs_lstat, phy_los, cdr_locked, an_complete); +} + +static bool mtip_cached_an_complete(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + + lockdep_assert_held(&irqpoll->lock); + + return !!(irqpoll->old_an_stat & MDIO_AN_STAT1_COMPLETE); +} + +static bool mtip_read_link_unlatch(struct mtip_backplane *priv) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + bool old_link = irqpoll->link; + + lockdep_assert_held(&irqpoll->lock); + + /* A change to the link status may have occurred while a link + * loss was latched, so update it again after reading it + */ + irqpoll->link = !!(irqpoll->old_an_stat & MDIO_STAT1_LSTATUS) && + !!(irqpoll->old_an_stat & MDIO_AN_STAT1_COMPLETE) && + !!(irqpoll->old_pcs_stat & MDIO_STAT1_LSTATUS) && + irqpoll->cdr_locked; + irqpoll->link_ack = true; + + return old_link; +} + +static u16 mtip_expected_bp_eth_stat(enum ethtool_link_mode_bit_indices link_mode) +{ + switch (link_mode) { + case ETHTOOL_LINK_MODE_1000baseKX_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_1GKX; + case ETHTOOL_LINK_MODE_10000baseKR_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_10GKR; + case ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_40GKR4; + case ETHTOOL_LINK_MODE_25000baseKR_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_25GKR; + case ETHTOOL_LINK_MODE_25000baseKR_S_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_25GKR_S; + case ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT: + return BP_ETH_STAT_ALWAYS_1 | BP_ETH_STAT_100GKR4; + default: + return 0; + } +} + +static int mtip_wait_bp_eth_stat(struct mtip_backplane *priv, + enum ethtool_link_mode_bit_indices link_mode) +{ + u16 expected = mtip_expected_bp_eth_stat(link_mode); + struct device *dev = &priv->mdiodev->dev; + int err, val; + + err = read_poll_timeout(mtip_read_an, val, + val < 0 || val == expected, + MTIP_BP_ETH_STAT_SLEEP_US, + MTIP_BP_ETH_STAT_TIMEOUT_US, + false, priv, AN_BP_ETH_STAT); + if (val < 0) + return val; + + if (err) { + dev_warn(dev, + "BP_ETH_STAT did not become 0x%x to indicate resolved link mode %s, instead it shows 0x%x%s\n", + expected, ethtool_link_mode_str(link_mode), val, + val == BP_ETH_STAT_PARALLEL_DETECT ? " (parallel detection)" : ""); + return err; + } + + return 0; +} + +static int mtip_switch_protocol(struct mtip_backplane *priv, void *args) +{ + const enum ethtool_link_mode_bit_indices *resolved = args; + struct device *dev = &priv->mdiodev->dev; + int err; + + err = phy_set_mode_ext(priv->serdes, PHY_MODE_ETHTOOL, *resolved); + if (err) { + dev_err(dev, "phy_set_mode_ext(%s) returned %pe\n", + ethtool_link_mode_str(*resolved), ERR_PTR(err)); + return err; + } + + return 0; +} + +static int mtip_c73_page_received(struct mtip_backplane *priv, bool *restart_an) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); + __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); + enum ethtool_link_mode_bit_indices resolved; + struct device *dev = &priv->mdiodev->dev; + __ETHTOOL_DECLARE_LINK_MODE_MASK(common); + u64 base_page, lpa; + int i, err; + + err = mtip_state_reset(priv); + if (err) + return err; + + err = mtip_read_adv(priv, &base_page); + if (err < 0) + return err; + + err = mtip_read_lpa(priv, &lpa); + if (err < 0) + return err; + + if (lpa & C73_BASE_PAGE_NP) + dev_warn(dev, "Next Page exchange not implemented!\n"); + + mii_c73_mod_linkmode_lpa_t(advertising, base_page); + mii_c73_mod_linkmode_lpa_t(lp_advertising, lpa); + linkmode_and(common, advertising, lp_advertising); + + err = linkmode_c73_priority_resolution(common, &resolved); + if (err) { + dev_warn(dev, "C73 page received, no common link mode\n"); + *restart_an = true; + return 0; + } + + err = mtip_wait_bp_eth_stat(priv, resolved); + if (err) { + *restart_an = true; + return 0; + } + + dev_dbg(dev, + "C73 page received, LD %04x:%04x:%04x, LP %04x:%04x:%04x, resolved link mode %s\n", + C73_ADV_2(base_page), C73_ADV_1(base_page), C73_ADV_0(base_page), + C73_ADV_2(lpa), C73_ADV_1(lpa), C73_ADV_0(lpa), + ethtool_link_mode_str(resolved)); + + err = for_each_lane_args(mtip_switch_protocol, priv, &resolved); + if (err) + return err; + + for (i = 0; i < priv->num_subordinates; i++) { + if (!priv->subordinate[i]->lane_powered_on) { + err = mtip_backplane_resume(priv->subordinate[i]); + if (err) + return err; + } + } + + err = mtip_wait_for_cdr_lock(priv); + if (err) { + dev_warn(dev, "Failed to reacquire CDR lock after protocol change: %pe\n", + ERR_PTR(err)); + *restart_an = true; + return 0; + } + + if (link_mode_needs_training(resolved)) { + err = for_each_lane(mtip_start_lt, priv); + if (err) { // FIXME return err + /* mtip_an_restart() -> mtip_state_reset() + * will clean up and stop the kthreads for the lanes + * where link training may have already started + */ + *restart_an = true; + return 0; + } + } else { + err = for_each_lane(mtip_bypass_lt, priv); + if (err) + return err; + } + + priv->link_mode = resolved; + priv->link_mode_resolved = true; + + return 0; +} + +static void mtip_c73_remote_fault(struct mtip_backplane *priv, bool fault) +{ + struct device *dev = &priv->mdiodev->dev; + + dev_err(dev, "Remote fault: %d\n", fault); +} + +static bool mtip_are_all_lanes_trained(struct mtip_backplane *priv) +{ + int i; + + if (!priv->local_tx_lt_done || !priv->remote_tx_lt_done) + return false; + + for (i = 0; i < priv->num_subordinates; i++) { + if (!priv->subordinate[i]->local_tx_lt_done || + !priv->subordinate[i]->remote_tx_lt_done) + return false; + } + + return true; +} + +static void mtip_irqpoll_work(struct work_struct *work) +{ + struct mtip_irqpoll *irqpoll = container_of(work, struct mtip_irqpoll, work.work); + struct mtip_backplane *priv = container_of(irqpoll, struct mtip_backplane, irqpoll); + struct device *dev = &priv->mdiodev->dev; + bool all_lanes_have_cdr_lock; + bool restart_an = false; + bool new_page = false; + int val, err = 0; + int pcs_stat = 0; + + /* Check for AN restart requests from the link training kthreads */ + mutex_lock(&priv->an_restart_lock); + if (priv->an_restart_pending) { + restart_an = true; + priv->an_restart_pending = false; + } + mutex_unlock(&priv->an_restart_lock); + + /* Then enter the irqpoll logic per se + * (PCS MDIO_STAT1, AN/LT MDIO_STAT1 and CDR lock) + */ + mutex_lock(&irqpoll->lock); + + err = mtip_check_cdr_lock(priv, &all_lanes_have_cdr_lock); + if (err) + goto out_unlock; + + if (priv->link_mode_resolved) { + pcs_stat = mtip_read_pcs(priv, MDIO_STAT1); + if (pcs_stat < 0) { + err = pcs_stat; + goto out_unlock; + } + } + + val = mtip_read_an(priv, AN_STAT); + if (val < 0) { + err = val; + goto out_unlock; + } + + if ((irqpoll->cdr_locked != all_lanes_have_cdr_lock) || + ((irqpoll->old_an_stat ^ val) & (MDIO_STAT1_LSTATUS | + MDIO_AN_STAT1_COMPLETE)) || + ((irqpoll->old_pcs_stat ^ pcs_stat) & MDIO_STAT1_LSTATUS)) { + mtip_update_link_latch(priv, all_lanes_have_cdr_lock, + !!(val & MDIO_STAT1_LSTATUS), + !!(val & MDIO_AN_STAT1_COMPLETE), + !!(pcs_stat & MDIO_STAT1_LSTATUS)); + } + + /* The manual says that this bit is latched high, but experimentation + * shows that reads will not unlatch it while link training is in + * progress; only reading it after link training has completed will. + * Only act upon bit transitions, to avoid processing a false "page + * received" event during link training. + */ + if (((irqpoll->old_an_stat ^ val) & MDIO_AN_STAT1_PAGE) && + (val & MDIO_AN_STAT1_PAGE) && !restart_an) { + /* When we had a link and the LP retriggers autoneg, we first + * detect a new base page and resolve the link mode properly, + * then we see that the PCS link dropped and we retrigger + * autoneg again. Avoid that. + */ + new_page = true; + + err = mtip_c73_page_received(priv, &restart_an); + if (err) + goto out_unlock; + } + + if ((irqpoll->old_an_stat ^ val) & MDIO_AN_STAT1_RFAULT) + mtip_c73_remote_fault(priv, val & MDIO_AN_STAT1_RFAULT); + + /* Checks that result in AN restart should go at the end */ + + /* Make sure the lane goes back into DME page exchange mode + * after a link drop + */ + if (priv->link_mode_resolved && !new_page && + (irqpoll->old_pcs_stat & MDIO_STAT1_LSTATUS) && + !(pcs_stat & MDIO_STAT1_LSTATUS)) { + dev_dbg(dev, "PCS link dropped, restarting autoneg\n"); + restart_an = true; + } + + /* Paranoid workaround for undetermined issue */ + if (!priv->link_mode_resolved && (val & MDIO_AN_STAT1_COMPLETE) && + priv->an_enabled && time_after(jiffies, priv->last_an_restart + + msecs_to_jiffies(MTIP_AN_TIMEOUT_MS))) { + dev_err(dev, + "Hardware says AN has completed, but we never saw a base page, and that's bogus\n"); + restart_an = true; + } + + /* Sometimes, after a renegotiation, it can be seen that link training + * failures on one side trigger an autoneg restart (as they should), + * but that does not get acted upon by the other side. It appears that + * the other side is in a strange state where it has completed link + * training and it's waiting for something. As seen in the + * MDIO_AN_STAT1_PAGE workaround above, we will fail to detect new base + * pages received during link training, so we won't be able to exit + * that state. Detect it and exit it if 1 second has passed since link + * training has completed, but the 'autoneg done' bit hasn't asserted. + */ + if (mtip_are_all_lanes_trained(priv) && !(val & MDIO_AN_STAT1_COMPLETE) && + time_after(jiffies, priv->last_lt_done + + msecs_to_jiffies(MTIP_LT_TIMEOUT_MS))) { + dev_err(dev, "AN did not complete after link training completed\n"); + restart_an = true; + } + + if (priv->link_mode_resolved && priv->lt_enabled) { + int expected = mtip_expected_bp_eth_stat(priv->link_mode); + int bp_eth_stat = mtip_read_an(priv, AN_BP_ETH_STAT); + + if (bp_eth_stat != expected) { + dev_err(dev, "BP_ETH_STAT 0x%x changed from expected value of 0x%x\n", + bp_eth_stat, expected); + restart_an = true; + } + } + + if (restart_an) { + err = mtip_an_restart(priv); + if (err) + goto out_unlock; + + /* don't overwrite what was set by mtip_unlatch_an_stat() */ + goto ignore_an_and_pcs_stat; + } + + irqpoll->old_an_stat = val; + irqpoll->old_pcs_stat = pcs_stat; +ignore_an_and_pcs_stat: + irqpoll->cdr_locked = all_lanes_have_cdr_lock; + +out_unlock: + mutex_unlock(&irqpoll->lock); + + if (err) { + dev_err(dev, + "Error detected from irqpoll thread: %pe, exiting...\n", + ERR_PTR(err)); + return; + } + + if (!irqpoll->run_once) + schedule_delayed_work(&irqpoll->work, IRQPOLL_INTERVAL); + + irqpoll->run_once = false; +} + +int mtip_backplane_config_aneg(struct mtip_backplane *priv, bool autoneg, + const unsigned long *advertising) +{ + u16 mask = MDIO_AN_CTRL1_ENABLE | MDIO_AN_CTRL1_RESTART; + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + int err; + + mutex_lock(&irqpoll->lock); + + if (autoneg) { + err = mtip_config_an_adv(priv, advertising); + if (err < 0) + goto out_unlock; + + err = mtip_an_restart(priv); + if (err) + goto out_unlock; + + priv->an_enabled = true; + } else { + err = mtip_modify_an(priv, AN_CTRL, mask, 0); + if (err < 0) + goto out_unlock; + + priv->an_enabled = false; + } + +out_unlock: + mutex_unlock(&irqpoll->lock); + + return err; +} +EXPORT_SYMBOL(mtip_backplane_config_aneg); + +static int mtip_resolve_aneg_linkmode(struct mtip_backplane *priv, + struct phylink_link_state *state) +{ + u64 base_page; + int err; + + linkmode_zero(state->lp_advertising); + + err = mtip_read_lpa(priv, &base_page); + if (err) + return err; + + mii_c73_mod_linkmode_lpa_t(state->lp_advertising, base_page); + phylink_resolve_c73(state); + + return 0; +} + +void mtip_backplane_get_state(struct mtip_backplane *priv, + struct phylink_link_state *state) +{ + struct mtip_irqpoll *irqpoll = &priv->irqpoll; + struct device *dev = &priv->mdiodev->dev; + u64 base_page; + int err = 0; + + mutex_lock(&irqpoll->lock); + + state->speed = SPEED_UNKNOWN; + state->duplex = DUPLEX_UNKNOWN; + state->pause = 0; + + err = mtip_read_adv(priv, &base_page); + if (err) + goto out_unlock; + + state->link = mtip_read_link_unlatch(priv); + if (!state->link) + goto out_unlock; + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + state->advertising)) { + state->an_complete = mtip_cached_an_complete(priv); + + if (state->an_complete) + err = mtip_resolve_aneg_linkmode(priv, state); + + state->link = state->link && mtip_are_all_lanes_trained(priv); + } + +out_unlock: + mutex_unlock(&irqpoll->lock); + + if (err) + dev_err(dev, "Failed to get backplane state: %pe\n", + ERR_PTR(err)); +} +EXPORT_SYMBOL(mtip_backplane_get_state); + +int mtip_backplane_add_subordinate(struct mtip_backplane *priv, + struct mtip_backplane *subordinate) +{ + if (priv->num_subordinates == MTIP_MAX_NUM_SUBORDINATES) + return -ERANGE; + + subordinate->is_subordinate = true; + subordinate->coordinator = priv; + priv->subordinate[priv->num_subordinates++] = subordinate; + + return 0; +} +EXPORT_SYMBOL(mtip_backplane_add_subordinate); + +static struct mdio_device * +mtip_get_mdiodev_for_link_mode(struct mii_bus *bus, struct phy *serdes, + enum ethtool_link_mode_bit_indices link_mode) +{ + union phy_status_opts opts = { + .pcvt = { + .type = PHY_PCVT_ETHERNET_ANLT, + }, + }; + int err; + + err = phy_set_mode_ext(serdes, PHY_MODE_ETHTOOL, link_mode); + if (err) + return ERR_PTR(err); + + err = phy_get_status(serdes, PHY_STATUS_PCVT_ADDR, &opts); + if (err) + return ERR_PTR(err); + + return mdio_device_create(bus, opts.pcvt.addr.mdio); +} + +static struct mdio_device *mtip_get_mdiodev(struct mii_bus *bus, + struct phy *serdes) +{ + const enum ethtool_link_mode_bit_indices *link_modes; + int i, err; + + link_modes = mtip_backplane_link_modes; + + /* Preconfigure the SerDes lane for the highest supported link mode, + * make sure the backplane AN/LT + PCS are enabled, and get the MDIO + * address of our device so that we can access its registers. + */ + for (i = 0; i < ARRAY_SIZE(mtip_backplane_link_modes); i++) { + err = phy_validate(serdes, PHY_MODE_ETHTOOL, + link_modes[i], NULL); + if (err) + continue; + + return mtip_get_mdiodev_for_link_mode(bus, serdes, + link_modes[i]); + } + + dev_err(&serdes->dev, "No backplane link modes supported!\n"); + + return ERR_PTR(-ENODEV); +} + +static void mtip_irqpoll_init(struct mtip_backplane *priv, + struct mtip_irqpoll *irqpoll) +{ + mutex_init(&irqpoll->lock); + INIT_DELAYED_WORK(&irqpoll->work, mtip_irqpoll_work); +} + +struct mtip_backplane *mtip_backplane_create(struct mdio_device *pcs_mdiodev, + struct phy *serdes, + enum mtip_model model) +{ + struct mii_bus *bus = pcs_mdiodev->bus; + struct mtip_backplane *priv; + struct mdio_device *mdiodev; + struct device *dev; + int err; + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) { + err = -ENOMEM; + goto out; + } + + mdiodev = mtip_get_mdiodev(bus, serdes); + if (IS_ERR(mdiodev)) { + err = PTR_ERR(mdiodev); + goto out_free_priv; + } + + dev = &mdiodev->dev; + priv->pcs_mdiodev = pcs_mdiodev; + priv->mdiodev = mdiodev; + priv->serdes = serdes; + + switch (model) { + case MTIP_MODEL_LX2160A: + priv->an_regs = mtip_lx2160a_an_regs; + priv->lt_regs = mtip_lx2160a_lt_regs; + priv->lt_mmd = MDIO_MMD_AN; + break; + default: + /* TODO */ + err = -EINVAL; + goto out_free_mdiodev; + } + + err = mtip_reset_pcs(priv); + if (err < 0) + goto out_free_mdiodev; + + err = mtip_reset_an(priv); + if (err < 0) + goto out_free_mdiodev; + + mtip_irqpoll_init(priv, &priv->irqpoll); + mutex_init(&priv->an_restart_lock); + mutex_init(&priv->lt_lock); + + priv->local_tx_lt_worker = kthread_create_worker(0, "%d_local_tx_lt", + mdiodev->addr); + if (IS_ERR(priv->local_tx_lt_worker)) { + err = PTR_ERR(priv->local_tx_lt_worker); + goto out_free_priv; + } + + priv->remote_tx_lt_worker = kthread_create_worker(0, "%d_remote_tx_lt", + mdiodev->addr); + if (IS_ERR(priv->remote_tx_lt_worker)) { + err = PTR_ERR(priv->remote_tx_lt_worker); + goto out_destroy_local_tx_lt; + } + + err = phy_init(priv->serdes); + if (err) { + dev_err(dev, "Failed to initialize SerDes: %pe\n", + ERR_PTR(err)); + goto out_destroy_remote_tx_lt; + } + + return priv; + +out_destroy_remote_tx_lt: + kthread_destroy_worker(priv->remote_tx_lt_worker); +out_destroy_local_tx_lt: + kthread_destroy_worker(priv->local_tx_lt_worker); +out_free_mdiodev: + mdio_device_put(priv->mdiodev); +out_free_priv: + kfree(priv); +out: + return ERR_PTR(err); +} +EXPORT_SYMBOL(mtip_backplane_create); + +void mtip_backplane_destroy(struct mtip_backplane *priv) +{ + phy_exit(priv->serdes); + kthread_destroy_worker(priv->remote_tx_lt_worker); + kthread_destroy_worker(priv->local_tx_lt_worker); + mdio_device_put(priv->mdiodev); + kfree(priv); +} +EXPORT_SYMBOL(mtip_backplane_destroy); + +MODULE_AUTHOR("Vladimir Oltean "); +MODULE_DESCRIPTION("MTIP Backplane PHY driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/pcs/mtip_backplane.h b/drivers/net/pcs/mtip_backplane.h new file mode 100644 index 000000000000..d418630017d3 --- /dev/null +++ b/drivers/net/pcs/mtip_backplane.h @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2023 NXP + */ +#ifndef _MTIP_BACKPLANE_H +#define _MTIP_BACKPLANE_H + +struct mdio_device; +struct mtip_backplane; +struct phy; + +enum mtip_model { + MTIP_MODEL_AUTODETECT, + MTIP_MODEL_LX2160A, +}; + +#if IS_ENABLED(CONFIG_MTIP_BACKPLANE_PHY) + +int mtip_backplane_config_aneg(struct mtip_backplane *priv, bool autoneg, + const unsigned long *advertising); +void mtip_backplane_an_restart(struct mtip_backplane *priv); +void mtip_backplane_get_state(struct mtip_backplane *priv, + struct phylink_link_state *state); +int mtip_backplane_suspend(struct mtip_backplane *priv); +int mtip_backplane_resume(struct mtip_backplane *priv); +int mtip_backplane_validate(struct mtip_backplane *priv, + unsigned long *supported); +int mtip_backplane_add_subordinate(struct mtip_backplane *priv, + struct mtip_backplane *subordinate); +struct mtip_backplane *mtip_backplane_create(struct mdio_device *pcs_mdiodev, + struct phy *serdes, + enum mtip_model model); +void mtip_backplane_destroy(struct mtip_backplane *priv); + +#else + +static inline int mtip_backplane_config_aneg(struct mtip_backplane *priv, + bool autoneg, + const unsigned long *advertising) +{ + return -ENODEV; +} + +static inline void mtip_backplane_an_restart(struct mtip_backplane *priv) +{ +} + +static inline void mtip_backplane_get_state(struct mtip_backplane *priv, + struct phylink_link_state *state) +{ +} + +static inline int mtip_backplane_suspend(struct mtip_backplane *priv) +{ + return -ENODEV; +} + +static inline int mtip_backplane_resume(struct mtip_backplane *priv) +{ + return -ENODEV; +} + +static inline int mtip_backplane_validate(struct mtip_backplane *priv, + unsigned long *supported) +{ + return -ENODEV; +} + +static inline int mtip_backplane_add_subordinate(struct mtip_backplane *priv, + struct mtip_backplane *subordinate) +{ + return -ENODEV; +} + +static inline struct mtip_backplane *mtip_backplane_create(struct mdio_device *pcs_mdiodev, + struct phy *serdes, + enum mtip_model model) +{ + return -ENODEV; +} + +static inline void mtip_backplane_destroy(struct mtip_backplane *priv) +{ +} + +#endif + +#endif From patchwork Sat Sep 23 13:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 725626 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EA781D553; Sat, 23 Sep 2023 13:49:54 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CCA5CF1; Sat, 23 Sep 2023 06:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ni9bxzrNJrhDkfYC6+t/nReANzgz7lmGWKK37eT8/0eqf4XkBeUicH8YyXfKt+y3yn31ECp83AK0dj//++jID4yJGHF0b6ACVO1Na91uMO1SGF+paWZWUK0lSapsRnAcmdHpeWMq8BKIlLrPloWUVhVKuqyrU0PKopGsiIInqBRNVND1hG4x4oveH2ikyfT4x7Uaq4iwYaGSMfuwxAEPBfFD7JEdfetIiwyQ5oI2NQEJTTGwrxIJNCUSWLNU7HiRgj+ikuUvSQkJpWuikSBpbvncovePfYFa4QFG32aEyc7qNRdtcTZ5SQ73KW901Xx3oZcSFsZV7740nbmBfE8sIw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AsPLlrLnEi/DL0vDxMpT7yQn5nNjqHycisJ0DsF6O/Y=; b=WwxDEGf9mon4O0EjzNDmZ8Yv4RRcLe7XXPucokm93R3CfZk72wbYaJW15N9ZtSdlHUfle+swxd7AGSJ5b1adtShByCuE2kniZm5CyGQIfO1cY6yQFYos91g4VaKz6J43T/a8AeHRuDBXSRzNA+2saKLsX6vVPDvTb/zbWTQgN6hnn4/21/UVbhNuyUnaD22bP+CdJkZIktv9geELcD47fAxNrdxaY7r/kYUzCx7g2wEi7ubnBxphsAhVoxs84azhCcAfC5EMVMWvXqhTbb6gPxteQh4ejA/3exs04zuv2rWsS9aY67NR627S6lQCXC/TDDJCWjlVjcLYuYqDFmAi8g== 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=AsPLlrLnEi/DL0vDxMpT7yQn5nNjqHycisJ0DsF6O/Y=; b=nTypnb0fJPlqwvhLGymrjMZY2r5+0IbI6NMM2f0jU8mR9jRAEAyVw8tfcuOy+oR3UwEW2f2NwO6iwGeD32TksE0hHwrxXsfECoZLJ4wABMDOqO60dDyHVQBQx+VtM8FAF6ezI9ys29M+hNxo0UmbbYVTbmWln2Je5G4wXx78aEA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:40 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:40 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 15/15] net: pcs: lynx: use MTIP AN/LT block for copper backplanes Date: Sat, 23 Sep 2023 16:49:04 +0300 Message-Id: <20230923134904.3627402-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 460eb46b-a7ee-49a9-69e9-08dbbc3bef24 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PwTKE0k6ZRHcRwGh365N5UKFWpIIIDb9WB3IPSKNU3U1lStmmLbLwWRozsFecGLbkvBhIO9YR4CwIjpgKIyQD0GN7y3pzNibYn3VngCpXFu160h/b3wVX8H7fZnP6YgwDkkZGiUymVAaEijYIBjdWzLbibblCo+wEiQS1+Kg5c2Jl8fOJ32dG1HzQoSDP1hHnbNra4SEocEolq6/uw0xWn9D75s2g0DCfMpiwU4CckedIiZ0k46HU77HZwv8NVrPY3uyMh0STcYTf/38yFo5Uv0Vtmt6Pj7LcEbropfbf6i/t+CamlkmM0hFmt32j7DYSMDyj7NR8Umkf81atOWZJTrHjzd+KyzdPXna/x29BxUFSWCiYwyU2P5dDjxgRn0Qhbt3vdVNdFLvhX61TXRZeeZVsHaQrCPfw2+asa+6engORTzFdFjQnNgttg8QWX9EnW+5yz6p/mMT9/sWAViIiFeTXCG2bgRHYypu14riqogHpihesCOL7uAQS8AcawtL4sZvkls4+1KTXhbHOxnEi59oiYLuGqpjqkgwukv8bl6k4sU/lROOzuSniL7BHCrymXO+NyB+PDm4PfZE8rrpb873X3SW6ABRfu99w9qaJ/dV1Tla5LojdhSf7CfxxhOm X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6452.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c0eMDlAhN2Xj3R4Hc0lEzjhXo/bR99xJ+wzYQaq+dku3eQZMCbwY/enzhTL2FMBch8VdBtpuHCe8bU/tCHUZ1SIOe9qCvJFfSbZnTlWoNfIpc2sTKwpgnAAgFvOWF6zKCM+JYH9lc3b8QZy/Pzr+hprxxAW5M0Y0x4h8u61HiSb9JbNwYBmGKrNYh/ze8sQM6YGYvG5mTb1D6qhcb7fw4dbkC5CcyG2Ug//QTRg2KrzwwBJM0SsQ3N3ViyPVkzLawDUV0Uwvb89fb2IFhibKDtce+na6shPgUGVqferbx3CQI4ZBDu8HCDBzZWyEAQBjaEzKythlX/3iQdft2D1JeNkZYVsYIDgpoG7OpL3CLzR2pR2o/EGsVZVYy2reiV74XqvcOWy9DrvVad/HR2cG0y3qRjmh/e3UvFTlLN9KA+Z6p1oYKvlv7HYnz5rDlmJcmG2MK/84EGLvGW2bniTl6n7Rapv5HUzjkvawbNW5gkZ43wve92ju4iT1uHVK2XWbja+CyWpLon/APeZJrzA0N6ETqNeludB7qN4WmmR7J67KFHWkvloBlTmgi38138T31IBE82BN9U+3kW/YdD4E2fpe8bgXvu8T3f7o8td1wwtyOvW93vquz4ko4XQRH+b6M+UY3MrD5U45njDh1owcXjh2D+P2jrXtjlzend5FZfGGhZc4tJUtfmTEyXPxi9PhJqejdonP7H5pafDRnMizxFmr+bdDKuion7Dx2A8j/YnYRIA0sC241ihkPvf9S0OTa652W38qAYBSuripA6NNGzXgcEybYAtyOoD72tVwE8Sey7TChvv3fN+kH9vMzR4+zeOBKp+vn0gFUgq+MvdgnqUNmDVkhH93ZTveN6PGh8UclJu2w+zTR1qFgR8CGMSUI9ca7yPSZ9XmgT+AYiut6YEETAJkJs0jZ3rkCvGvmMf7zFIPk4QwsWwP1wOGWirZe09txMtOVoVwz1/oA1ziOfLVkUUv+VCUw+TANGameHizxk6C+lQjtQEN2uJ2J+tyFIbePBHdJOPR18kPNznGh8gXn2rriO5uRWB4xekn1PFa/p9tWlk8NDUjms0JN9CKo7WjhOYUbrdKNmTck4Qmwf6HvaIA0108NOZiCn7roVarecZrRADtyw1jKHXT/UKN4qfDNlMB7pLbag0ekWEy3hNdXHRAZcnvtFqAUkKPMgnWzUmQmvur9D/hLD6E5D8UO9c5YCaKqIwo1WZ4ts8zqWy8xj0xyRcLks7QCtc4AUFDL/v7fXqFQ3P20uvISb4Nygl0T1QXfPU1cPnhyew7n2QbMNpq4KmockANwZddszStA7aPS2VIXmQIso05ycv77xqsfL1vPVjFclNsH0gQthJTbB7b/wYdL6leuSYs7MwdRzuisWaTyxzO6RoUWaA5EC9idwb/NuNeld88BWAQSq3uIlLWw8a5e3yFdPGA6PrK8yoWuqXTt1yyIRLvjfQyv3cFFFmIkznjtXF5cXsVLYI46QWd2zWhVBaTzKKFoKpRY3S6KZCrOFn7kVhyeCIgjkFhB33t4N8BCFJGAtNfaoCy8VnvBWplRTaHucRjWIqftGmh8uC40hLx1cmUidWtjBCigjNyyEVnovyc0BU+WQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 460eb46b-a7ee-49a9-69e9-08dbbc3bef24 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:40.5633 (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: rMIqtdpsKG2bR6a2VejghxXFaTzd7qflHqZpZqj+qjTFsDgR12XJzZ8Jewed8rofypDvu8j10A9JV7G2K54dVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net If the fsl,backplane-mode device tree property is present, then the Lynx PCS makes use of the AN/LT block to advertise the supported backplane link modes using clause 73 autoneg. Signed-off-by: Vladimir Oltean --- v1->v2: code is new drivers/net/pcs/Kconfig | 1 + drivers/net/pcs/pcs-lynx.c | 135 +++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig index 24a033e93bdd..be561c465b4a 100644 --- a/drivers/net/pcs/Kconfig +++ b/drivers/net/pcs/Kconfig @@ -13,6 +13,7 @@ config MTIP_BACKPLANE_PHY SoCs. config PCS_XPCS + depends on MTIP_BACKPLANE_PHY || MTIP_BACKPLANE_PHY=n tristate select PHYLINK help diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index dc3962b2aa6b..1352f08edcf3 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -4,10 +4,14 @@ */ #include +#include +#include #include #include #include +#include "mtip_backplane.h" + #define SGMII_CLOCK_PERIOD_NS 8 /* PCS is clocked at 125 MHz */ #define LINK_TIMER_VAL(ns) ((u32)((ns) / SGMII_CLOCK_PERIOD_NS)) @@ -20,9 +24,15 @@ #define IF_MODE_SPEED_MSK GENMASK(3, 2) #define IF_MODE_HALF_DUPLEX BIT(4) +#define PRIMARY_LANE 0 +#define MAX_NUM_LANES 4 + struct lynx_pcs { struct phylink_pcs pcs; struct mdio_device *mdio; + struct mtip_backplane *anlt[MAX_NUM_LANES]; + int num_lanes; + bool backplane_mode; }; enum sgmii_speed { @@ -100,6 +110,9 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs, case PHY_INTERFACE_MODE_10GBASER: phylink_mii_c45_pcs_get_state(lynx->mdio, state); break; + case PHY_INTERFACE_MODE_INTERNAL: + mtip_backplane_get_state(lynx->anlt[PRIMARY_LANE], state); + break; default: break; } @@ -168,6 +181,17 @@ static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, ADVERTISE_SGMII | ADVERTISE_LPACK); } +static int lynx_pcs_config_backplane(struct phylink_pcs *pcs, + unsigned int neg_mode, + const unsigned long *advertising) +{ + bool autoneg = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED; + struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + + return mtip_backplane_config_aneg(lynx->anlt[PRIMARY_LANE], autoneg, + advertising); +} + static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t ifmode, const unsigned long *advertising, bool permit) @@ -193,6 +217,8 @@ static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, case PHY_INTERFACE_MODE_10GBASER: /* Nothing to do here for 10GBASER */ break; + case PHY_INTERFACE_MODE_INTERNAL: + return lynx_pcs_config_backplane(pcs, neg_mode, advertising); default: return -EOPNOTSUPP; } @@ -204,6 +230,9 @@ static void lynx_pcs_an_restart(struct phylink_pcs *pcs) { struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + if (lynx->backplane_mode) + return mtip_backplane_an_restart(lynx->anlt[PRIMARY_LANE]); + phylink_mii_c22_pcs_an_restart(lynx->mdio); } @@ -306,16 +335,111 @@ static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, } } +static int lynx_pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, + const struct phylink_link_state *state) +{ + struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + + if (state->interface != PHY_INTERFACE_MODE_INTERNAL) + return 0; + + return mtip_backplane_validate(lynx->anlt[PRIMARY_LANE], supported); +} + +static int lynx_pcs_enable(struct phylink_pcs *pcs) +{ + struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + int err; + + if (lynx->backplane_mode) { + err = mtip_backplane_resume(lynx->anlt[PRIMARY_LANE]); + if (err) + return err; + } + + return 0; +} + +static void lynx_pcs_disable(struct phylink_pcs *pcs) +{ + struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + + if (lynx->backplane_mode) + mtip_backplane_suspend(lynx->anlt[PRIMARY_LANE]); +} + static const struct phylink_pcs_ops lynx_pcs_phylink_ops = { .pcs_get_state = lynx_pcs_get_state, .pcs_config = lynx_pcs_config, .pcs_an_restart = lynx_pcs_an_restart, .pcs_link_up = lynx_pcs_link_up, + .pcs_validate = lynx_pcs_validate, + .pcs_enable = lynx_pcs_enable, + .pcs_disable = lynx_pcs_disable, }; +static int lynx_pcs_parse_fwnode(struct lynx_pcs *lynx) +{ + struct fwnode_handle *node = lynx->mdio->dev.fwnode; + enum mtip_model model = MTIP_MODEL_AUTODETECT; + struct device_node *np = to_of_node(node); + struct mdio_device *mdio = lynx->mdio; + struct device *dev = &mdio->dev; + struct phy *phy; + int i, err; + + if (!node) + return 0; + + lynx->backplane_mode = fwnode_property_present(node, "fsl,backplane-mode"); + if (!lynx->backplane_mode) + return 0; + + if (fwnode_device_is_compatible(node, "fsl,lx2160a-lynx-pcs")) + model = MTIP_MODEL_LX2160A; + + lynx->num_lanes = of_count_phandle_with_args(np, "phys", "#phy-cells"); + if (lynx->num_lanes < 0) + return lynx->num_lanes; + + if (WARN_ON(lynx->num_lanes > MAX_NUM_LANES)) + return -EINVAL; + + for (i = 0; i < lynx->num_lanes; i++) { + phy = devm_of_phy_get_by_index(dev, np, i); + if (IS_ERR(phy)) + return dev_err_probe(dev, PTR_ERR(phy), + "Failed to get SerDes PHY %d\n", i); + + lynx->anlt[i] = mtip_backplane_create(mdio, phy, model); + if (IS_ERR(lynx->anlt[i])) { + err = PTR_ERR(lynx->anlt[i]); + + while (i-- > 0) + mtip_backplane_destroy(lynx->anlt[i]); + + return err; + } + } + + for (i = 1; i < lynx->num_lanes; i++) { + err = mtip_backplane_add_subordinate(lynx->anlt[PRIMARY_LANE], + lynx->anlt[i]); + if (WARN_ON(err)) { + /* Too many SerDes lanes in the device tree? */ + for (i = 0; i < lynx->num_lanes; i++) + mtip_backplane_destroy(lynx->anlt[i]); + return err; + } + } + + return 0; +} + static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) { struct lynx_pcs *lynx; + int err; lynx = kzalloc(sizeof(*lynx), GFP_KERNEL); if (!lynx) @@ -327,6 +451,12 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) lynx->pcs.neg_mode = true; lynx->pcs.poll = true; + err = lynx_pcs_parse_fwnode(lynx); + if (err) { + kfree(lynx); + return ERR_PTR(err); + } + return lynx_to_phylink_pcs(lynx); } @@ -392,6 +522,11 @@ EXPORT_SYMBOL_GPL(lynx_pcs_create_fwnode); void lynx_pcs_destroy(struct phylink_pcs *pcs) { struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); + int i; + + if (lynx->backplane_mode) + for (i = 0; i < lynx->num_lanes; i++) + mtip_backplane_destroy(lynx->anlt[i]); mdio_device_put(lynx->mdio); kfree(lynx);