From patchwork Fri Dec 2 18:17:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13063079 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 371D9C4708D for ; Fri, 2 Dec 2022 18:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234327AbiLBSRk (ORCPT ); Fri, 2 Dec 2022 13:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234320AbiLBSRj (ORCPT ); Fri, 2 Dec 2022 13:17:39 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2065.outbound.protection.outlook.com [40.107.105.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5DB1172; Fri, 2 Dec 2022 10:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zlokok0b9r6duRszF+FUik+YnQ4GtsLtGVblggblrefBLa6Z4DRjf73AapBz2gENr2vyJh5EWj60FUjMEjhDpkqN2HxEjsL8oCxCuaxUo5XGKZX0jtkhKIXwE+9gyPMoxLVGoYvnSii7k1bdn5yXDVfYcWW+/2vvWOOggoFKO+9HEg/yCpKriY5Oj+1bYh7bKq7Ypo/zXLvNiN7NHMyOMLFvfPIrTxR8VMd1PZBWGVDTY7ua9mfMDkxYeqOv+Ewya28BTM8I1P8hA7dp3wS+AbSnqlTTuail9C8fr5IfJMNz4GMVErvLVMD71anF/u86Ea3N3nN0kd6PRukJOAYazg== 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=qcykd8ozgb3khZ4QG9LdAl4Q+yIgKs8/2rS7hQ5g3FE=; b=XE88+Tj+Gc5JA3N0txwGgpun2aHKzt9uLnlvA8ng6Hhl86u1aBdUcSgbeZqfXjXWIe26StCV1FmRszwK8MbtW/JsjidSUHKlpiIcs9s39EoIz0QreJ1qjJX1zJtM+dzVmPcfRwTetJAj88Xm9QVLJPMn4QViGCL06GkVrFRsxIi0DcMTMjc4GqjZQPpya/uauBlHqr8Y1YbP/WBM7aFSl+p4ToKNxKSqgs+3onvl/in+nNVIN/xEril01rVExHT2L2d8xWXS908M6CzJIUIAvsSoBvBhtyiAnJHahT/l0Cj86nuNZ3Xs8VIAL6co3CNjB3Ro9XyhBwh5xZestZ7JWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qcykd8ozgb3khZ4QG9LdAl4Q+yIgKs8/2rS7hQ5g3FE=; b=zA2uMZYDFTqXUrrs903RM4kaDF8vFXtLiLRTcOqE27GyxzgdxVj4hYVpleio62j+Fy9YcG60hZPJBJ6W6c4x9wDkoQBdIDKGiPV1sFZ6F+DXZ5T455aKZDEbRMWoOxHt1lZQ2LnbElhs70TNgr7jP0X8alEmmPtKCeVdZoqvT7X9dbbfZQzMfCLAI4lhoqdaHzfjYEULkPJrc96tL5AgrSKj0Ua2uH1jtM8uhfr1vUaqVHW59xnKub8c8bQORtY2yraI9pLOK8brTBkKkIhD9WF/0d6grH2arOMfCJc87JQqrfhgXWI1QeVpdU1QGfRkZ/KF7DItM5Zxzq4N671x6A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) by DBBPR03MB7081.eurprd03.prod.outlook.com (2603:10a6:10:206::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Fri, 2 Dec 2022 18:17:32 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%8]) with mapi id 15.20.5857.023; Fri, 2 Dec 2022 18:17:32 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , Russell King , netdev@vger.kernel.org Cc: "David S . Miller" , Tim Harvey , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Sean Anderson Subject: [PATCH net-next v3 1/3] net: phy: Move/rename phylink_interface_max_speed Date: Fri, 2 Dec 2022 13:17:16 -0500 Message-Id: <20221202181719.1068869-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221202181719.1068869-1-sean.anderson@seco.com> References: <20221202181719.1068869-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::17) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|DBBPR03MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: 661acce5-8328-4344-a8cb-08dad4917ad9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t55UeB4z2bRJ1XIpNdzykQW0EJ2GRGreu+KcsEulDffLHo9H0rOn7G888UW+9xDxhJ0vJ4IeNlzpxSQhgf2kulnZ5Qm60l3t5MOdSyCL/S4qeoUBY4p3ynhlhdBx9ecevY263Om+q6/JsNpWBbzvj2xXVDwiYBdbYFS+cBRe1ExFWRlHMDTwV8VJVJMdEB91YV/enzxVWBlCe2Hgy+KWfZfOJxCPYPQMO/Cz3oUHsc9KQG4/e3UpH0EIVE26fs46s9mqlIi5CLHyxYrneRSwctLDqH+4VBW9LbbUXKZiJUZwMJ0bpku3KOxdEzEUxo7wmWwfitQtBuOVoCm7OqhoAVPKcM4yE1P3FRWgpbDfD7aLN4P+LhXZ3IXvEWxSADD4jKUqoBQzuOr671gmofs4pqPcNIrVL68MyMGL4GEB/OkNz1zWTV4Sk+C6R5QRX27hVEsq0ePGb40HGIvEGb9JpWIPys0d4yJCtl8uqGJnZAbz5ZlBjVr46jOsX53eqBpn8bZ1fRj4cwFO956eYhbTBMwqFcddkpGvp73BFYJP14Ii93bxwewklYg8xg7QQYKWGXCd+B/oleQ27C7TpM9CA5KzzTyY4UKqaENz8DeeAXQe5vTYqHOGZDWdrctfSV5iiRYFSivzlM4Ifswg16jr/4sNrNz2TiwPOLm2cSb+sLdZ3KW189LycOkQAif7FENz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR03MB8847.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(346002)(39850400004)(396003)(366004)(376002)(451199015)(36756003)(38100700002)(38350700002)(86362001)(54906003)(316002)(110136005)(8676002)(107886003)(6666004)(478600001)(6486002)(26005)(6512007)(6506007)(52116002)(83380400001)(1076003)(186003)(41300700001)(2906002)(66556008)(66476007)(2616005)(7416002)(5660300002)(4326008)(66946007)(44832011)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-Mess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VAv0GLEeYljbWGKbbqOb3JT+CzF2T0kRH8skQf5HK+M/PR4nB2l2wbPSQw7YNBSf9+QW/4SBSrLBGJlppQMrguqMeBQQN0XuPeMeoA/JmV2NEkJ9wCsjsqHPVKl1cg4B0isZKEPrBON1w4EEVVQ3O2Ir6PF9iEjreLPAEZOYCGi0sCbjObH66nGy02PoBslYNvSlmNUvOnaDcimf4NEqOh/CnPYKBWJEotUqnyfl71FSJIB34SvqF0FCCiQEjpQnCncO1V1VyMXR5k2/2oU10LOHGEt9s60hUIBn7xUjC3mssnzehTRSFINjjm5em5ncyPzgiFep1P/5JPEX6RXeurL3Ode/G5zxnBUADbbmQsEsBcw6B+JeZNg6pkc1WruBWYWKHGxRems6PBwFddRZ6fMoVKHgX80NAkylknT0l26SluSkh504PzR0i9I5wVo32c+FdRj5JyZmROap3j7wMyhBf62k55ZgQbXFJDoR+SZ3cRmKm9X8+ZCy+5DbP9ZLsD16Spnmoa6I+SsHYyR9wlFbyehk9wwG60gSdaFDGDCSk6ER0ncka5RHfXt6W8y8gEgH9Gw22juh46JPw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 661acce5-8328-4344-a8cb-08dad4917ad9 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 18:17:32.3715 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3pnDXdo0Tht0L/8VwJBVaBzXxPupDI7LBzUyWD3FoKG5nyfDBJ1WaMVdseYs0ZLOBYoxNPK33+cjfcW9ejswZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7081 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This is really a core phy function like phy_interface_num_ports. Move it to drivers/net/phy/phy-core.c and rename it accordingly. Signed-off-by: Sean Anderson Reviewed-by: Russell King (Oracle) --- (no changes since v2) Changes in v2: - New drivers/net/phy/phy-core.c | 70 +++++++++++++++++++++++++++++++++++ drivers/net/phy/phylink.c | 75 ++------------------------------------ include/linux/phy.h | 1 + 3 files changed, 74 insertions(+), 72 deletions(-) diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 5d08c627a516..5a515434a228 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -150,6 +150,76 @@ int phy_interface_num_ports(phy_interface_t interface) } EXPORT_SYMBOL_GPL(phy_interface_num_ports); +/** + * phy_interface_max_speed() - get the maximum speed of a phy interface + * @interface: phy interface mode defined by &typedef phy_interface_t + * + * Determine the maximum speed of a phy interface. This is intended to help + * determine the correct speed to pass to the MAC when the phy is performing + * rate matching. + * + * Return: The maximum speed of @interface + */ +int phy_interface_max_speed(phy_interface_t interface) +{ + switch (interface) { + case PHY_INTERFACE_MODE_100BASEX: + case PHY_INTERFACE_MODE_REVRMII: + case PHY_INTERFACE_MODE_RMII: + case PHY_INTERFACE_MODE_SMII: + case PHY_INTERFACE_MODE_REVMII: + case PHY_INTERFACE_MODE_MII: + return SPEED_100; + + case PHY_INTERFACE_MODE_TBI: + case PHY_INTERFACE_MODE_MOCA: + case PHY_INTERFACE_MODE_RTBI: + case PHY_INTERFACE_MODE_1000BASEX: + case PHY_INTERFACE_MODE_1000BASEKX: + case PHY_INTERFACE_MODE_TRGMII: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_QSGMII: + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_GMII: + return SPEED_1000; + + case PHY_INTERFACE_MODE_2500BASEX: + return SPEED_2500; + + case PHY_INTERFACE_MODE_5GBASER: + return SPEED_5000; + + case PHY_INTERFACE_MODE_XGMII: + case PHY_INTERFACE_MODE_RXAUI: + case PHY_INTERFACE_MODE_XAUI: + case PHY_INTERFACE_MODE_10GBASER: + case PHY_INTERFACE_MODE_10GKR: + case PHY_INTERFACE_MODE_USXGMII: + case PHY_INTERFACE_MODE_QUSGMII: + return SPEED_10000; + + case PHY_INTERFACE_MODE_25GBASER: + return SPEED_25000; + + case PHY_INTERFACE_MODE_XLGMII: + return SPEED_40000; + + case PHY_INTERFACE_MODE_INTERNAL: + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_MAX: + /* No idea! Garbage in, unknown out */ + return SPEED_UNKNOWN; + } + + /* If we get here, someone forgot to add an interface mode above */ + WARN_ON_ONCE(1); + return SPEED_UNKNOWN; +} +EXPORT_SYMBOL_GPL(phy_interface_max_speed); + /* A mapping of all SUPPORTED settings to speed/duplex. This table * must be grouped by speed and sorted in descending match priority * - iow, descending speed. diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 09cc65c0da93..f8cba09f9d87 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -156,75 +156,6 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } -/** - * phylink_interface_max_speed() - get the maximum speed of a phy interface - * @interface: phy interface mode defined by &typedef phy_interface_t - * - * Determine the maximum speed of a phy interface. This is intended to help - * determine the correct speed to pass to the MAC when the phy is performing - * rate matching. - * - * Return: The maximum speed of @interface - */ -static int phylink_interface_max_speed(phy_interface_t interface) -{ - switch (interface) { - case PHY_INTERFACE_MODE_100BASEX: - case PHY_INTERFACE_MODE_REVRMII: - case PHY_INTERFACE_MODE_RMII: - case PHY_INTERFACE_MODE_SMII: - case PHY_INTERFACE_MODE_REVMII: - case PHY_INTERFACE_MODE_MII: - return SPEED_100; - - case PHY_INTERFACE_MODE_TBI: - case PHY_INTERFACE_MODE_MOCA: - case PHY_INTERFACE_MODE_RTBI: - case PHY_INTERFACE_MODE_1000BASEX: - case PHY_INTERFACE_MODE_1000BASEKX: - case PHY_INTERFACE_MODE_TRGMII: - case PHY_INTERFACE_MODE_RGMII_TXID: - case PHY_INTERFACE_MODE_RGMII_RXID: - case PHY_INTERFACE_MODE_RGMII_ID: - case PHY_INTERFACE_MODE_RGMII: - case PHY_INTERFACE_MODE_QSGMII: - case PHY_INTERFACE_MODE_SGMII: - case PHY_INTERFACE_MODE_GMII: - return SPEED_1000; - - case PHY_INTERFACE_MODE_2500BASEX: - return SPEED_2500; - - case PHY_INTERFACE_MODE_5GBASER: - return SPEED_5000; - - case PHY_INTERFACE_MODE_XGMII: - case PHY_INTERFACE_MODE_RXAUI: - case PHY_INTERFACE_MODE_XAUI: - case PHY_INTERFACE_MODE_10GBASER: - case PHY_INTERFACE_MODE_10GKR: - case PHY_INTERFACE_MODE_USXGMII: - case PHY_INTERFACE_MODE_QUSGMII: - return SPEED_10000; - - case PHY_INTERFACE_MODE_25GBASER: - return SPEED_25000; - - case PHY_INTERFACE_MODE_XLGMII: - return SPEED_40000; - - case PHY_INTERFACE_MODE_INTERNAL: - case PHY_INTERFACE_MODE_NA: - case PHY_INTERFACE_MODE_MAX: - /* No idea! Garbage in, unknown out */ - return SPEED_UNKNOWN; - } - - /* If we get here, someone forgot to add an interface mode above */ - WARN_ON_ONCE(1); - return SPEED_UNKNOWN; -} - /** * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes * @linkmodes: ethtool linkmode mask (must be already initialised) @@ -435,7 +366,7 @@ unsigned long phylink_get_capabilities(phy_interface_t interface, unsigned long mac_capabilities, int rate_matching) { - int max_speed = phylink_interface_max_speed(interface); + int max_speed = phy_interface_max_speed(interface); unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; unsigned long matched_caps = 0; @@ -1221,7 +1152,7 @@ static void phylink_link_up(struct phylink *pl, * the link_state) to the interface speed, and will send * pause frames to the MAC to limit its transmission speed. */ - speed = phylink_interface_max_speed(link_state.interface); + speed = phy_interface_max_speed(link_state.interface); duplex = DUPLEX_FULL; rx_pause = true; break; @@ -1231,7 +1162,7 @@ static void phylink_link_up(struct phylink *pl, * the link_state) to the interface speed, and will cause * collisions to the MAC to limit its transmission speed. */ - speed = phylink_interface_max_speed(link_state.interface); + speed = phy_interface_max_speed(link_state.interface); duplex = DUPLEX_HALF; break; } diff --git a/include/linux/phy.h b/include/linux/phy.h index 71eeb4e3b1fd..65d21a79bab3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1004,6 +1004,7 @@ const char *phy_duplex_to_str(unsigned int duplex); const char *phy_rate_matching_to_str(int rate_matching); int phy_interface_num_ports(phy_interface_t interface); +int phy_interface_max_speed(phy_interface_t interface); /* A structure for mapping a particular speed and duplex * combination to a particular SUPPORTED and ADVERTISED value From patchwork Fri Dec 2 18:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13063081 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B5E9C4332F for ; Fri, 2 Dec 2022 18:18:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234371AbiLBSSE (ORCPT ); Fri, 2 Dec 2022 13:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbiLBSRl (ORCPT ); Fri, 2 Dec 2022 13:17:41 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2065.outbound.protection.outlook.com [40.107.105.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19238AE62; Fri, 2 Dec 2022 10:17:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CtvjV0yuJZzI0BQ/Khgymd3IatECjDijHZh7W2Xb6telZGGD2AdZM3QUd93s0eAZltQ1Kj5HT/7d+qSDZ1NJX2fUKweOMDUB5Rb3+5/XHE26PZyrr2On2hlqo1ZCeAdZVfeUapbkOT62im7EA50II/KmtPSqTe8hOag7B5cvjHBaiMH/OLfRpA0BZ8tP/FpWUUM+lGwYkSmJ5mui9dFzLTHWQrnKw/eOBl5209ukyngFtK3NpePtNP9N0m7Vm58hAXl8J/nC2FncHhfYbDNhSZ0kGxWl5PdBpt/OyJGMbiiXfhEl7fjxA54rh+Q6JvbddojJ6vcoP+Htn7lmtsW7pg== 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=jLqIuvf2AT5eFpBCvndQYqDKO2eKnKNkuYn/2OiJIOc=; b=mytW8ynY9jPHlun9yD/g64ihzYzfQRYgjuJth/DFLRe4ckevO9mi31vy/i88VHYQIzmHXuyPQUpGA/sIA1PzrwKOkoH6BFvqrWmdGCKurG969BoR1qhwj2rv1RC16e7wrOL8zD2ZRsE2OkfWRa4QZVNYlNwxXdl88J4A55N2Zrlw3Sw3+ZHAkcJwwWzENrtFcX4TJkL8T531KSjfmash7UpkORCI753s4RXI/KaHhFZCpeCH43fZEWZdggkyJlVN30s6DmJqbLpdqjYDK9XgSJ9RvyKeguWkhe3NMy/z9lhEN84v2isUyGtr5xQGeL9j9DpoRQDsMZG46zeEtf0wOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jLqIuvf2AT5eFpBCvndQYqDKO2eKnKNkuYn/2OiJIOc=; b=HjUHJdY4VVanWXQcOvdj94P/7fNwoJjbDSQAjNf9V0SYPRKMUscLhnSVYlF01rqZmEPQ8l1UH+uSkcD7VOhWhe6y2YPQvck86Rlm9Rrs7HhRsucnLl/DB2+N6wXwdWXRFk1n+9oglvrUkqdRffHkmbvhoTsnM0qcs7CkONYjeK74KzuVSQrHjVCZCLpzaDMm+7TyuySrb55LiQ+BCogq977jAtjY5zy6UQwuxZjMZsMIiFf70T7yB5s9FvxKsWKB1PSTOg4BGms4rAQGlwtLC0JNn2V5RHifBcNPzg+GXIL1vbQO1o3i2qCVtyR2R0tFj9Gp9zkCGdBCh1Y1ZZHTMA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) by DBBPR03MB7081.eurprd03.prod.outlook.com (2603:10a6:10:206::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Fri, 2 Dec 2022 18:17:34 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%8]) with mapi id 15.20.5857.023; Fri, 2 Dec 2022 18:17:33 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , Russell King , netdev@vger.kernel.org Cc: "David S . Miller" , Tim Harvey , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Sean Anderson Subject: [PATCH net-next v3 2/3] net: mdio: Update speed register bits Date: Fri, 2 Dec 2022 13:17:17 -0500 Message-Id: <20221202181719.1068869-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221202181719.1068869-1-sean.anderson@seco.com> References: <20221202181719.1068869-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::17) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|DBBPR03MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: fd0298d2-e48d-4506-9f05-08dad4917bcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LL5zXNYqS4To5D/xZVvFpba7zmLowScJCTHl6IAZu0tlqA7aHM4DLE/Vbq5loXA2RLeu9d/IhwTNqu+89tMLVoRX1/2asUtSBMJzRom+Bxmn8G8TfcZ5zEBMr7iFY5A8rszPhSdnY0NjdFcxEFKFpq3poJRHeF1alXN2ucJcu8P00hrE+vZdqZh09mueBAiB4bgpiGVTZmaFO1+150iAzWzNz1WzP7q9NjZ5DSHEfrC6VRmK4NnwWLjzAfh5wmI6T5B/Z9PH0m61oqpbfztAhhGYmVDLBRuxcdfG6mYlUgJZ2Lz03lOhYehoaiysmQOKa4yjUz0XrKj/44QbXHKKmyIYm4R2a6gfNNORKlD1SUCHdyuJI+zprbk99BQuBjrR6VGgZqbShvaix5RcgCiVEvwT8iZsjp6zfZSKtNYCXSXqo6YwrqeFEA/d3fUEqRO0QFFVRfvad6WWAeyiKf9NqB9rwPY5L+9dU9r56tj8HEotBiScmaxiUp7J3Fk9XbNJl6X9YzhT4Ccpq1FEGlFqQMp3wMzpSsL5jOHP4DtkwhDokbClVGpR60LAvo+bSDI5TbXbXnrgQ56ZZUoSSIWNqwiUM2L2JXnl1b5dAhxsvBH4tDu6OpmAm09TMYDRiO98jVAL+vfOS5roz3hxfG2xc4Hr6m9SKtxkMiYwBFdaCQWRxxaq0R6ByasnL0gnZ5Qo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR03MB8847.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(346002)(39850400004)(396003)(366004)(376002)(451199015)(36756003)(38100700002)(38350700002)(86362001)(54906003)(316002)(110136005)(8676002)(107886003)(6666004)(478600001)(6486002)(26005)(6512007)(6506007)(52116002)(83380400001)(15650500001)(1076003)(186003)(41300700001)(2906002)(66556008)(66476007)(2616005)(7416002)(5660300002)(4326008)(66946007)(44832011)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4UfQtgRBUIUuP93m9y4qE7Jl4IJYOPFQ9KRv5+aiwY2qtKX+OHCLmseslCY8CIuUFELpcmmA5O1qHJdwCjQ+N8XcQDXoR2V1KsyJABliClL2WcihUZCEDOU/A0gXL9MKTyoeAaN9UsciM9KLNVlawFtKyD71BUrUnDxhjnyFGSLGQ/T5FlKQVQro3esjbdd94P780L1B59Iz3Rymoenb5HJLLSrrlTok+c8CjGI9U0cnYVKUO37GPagrXGh3BjCc+BK/xuKmfYgdGuP01Ad9LbCWvM043QGRzj01/jmHKxjeDd5Oi499IsySg9EMJgIU8bWpuH/5ETCpexVRkQEQaFHK+1Lxbd6NkzVciVKXK9943fXjZwnhvo6TBbwiC9EeTtxeVRui81cgKfMaq19HNlS9QFeZIlZMS66HbaCWf0qEziICR5jv2x7gtao1dj+AUGFnuv/WgoozDMeJubeXAXWd+++xTCifLW3Z7tugXiYL9TipjBBJfYQk40qy8XtlZNytt0fnAAJCZh6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55vPOF1Bgg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd0298d2-e48d-4506-9f05-08dad4917bcc X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 18:17:33.9637 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: plOZGw0jPaZ/y/1Qmtc9HRbM3CD/ef8o/yST1AzdaE8pBtmuhEQxvNGgyNrEzuXxfUU+OHec9j9ZYVXw1xXGPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7081 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This updates the speed register bits to the 2018 revision of 802.3. It also splits up the definitions to prevent confusion in casual observers. Signed-off-by: Sean Anderson --- Changes in v3: - New include/uapi/linux/mdio.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 75b7257a51e1..d700e9e886b9 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -127,16 +127,36 @@ #define MDIO_AN_STAT1_PAGE 0x0040 /* Page received */ #define MDIO_AN_STAT1_XNP 0x0080 /* Extended next page status */ -/* Speed register. */ +/* Generic speed register */ #define MDIO_SPEED_10G 0x0001 /* 10G capable */ + +/* PMA/PMD Speed register. */ +#define MDIO_PMA_SPEED_10G MDIO_SPEED_10G #define MDIO_PMA_SPEED_2B 0x0002 /* 2BASE-TL capable */ #define MDIO_PMA_SPEED_10P 0x0004 /* 10PASS-TS capable */ #define MDIO_PMA_SPEED_1000 0x0010 /* 1000M capable */ #define MDIO_PMA_SPEED_100 0x0020 /* 100M capable */ #define MDIO_PMA_SPEED_10 0x0040 /* 10M capable */ +#define MDIO_PMA_SPEED_10G1G 0x0080 /* 10/1G capable */ +#define MDIO_PMA_SPEED_40G 0x0100 /* 40G capable */ +#define MDIO_PMA_SPEED_100G 0x0200 /* 100G capable */ +#define MDIO_PMA_SPEED_10GP 0x0400 /* 10GPASS-XR capable */ +#define MDIO_PMA_SPEED_25G 0x0800 /* 25G capable */ +#define MDIO_PMA_SPEED_200G 0x1000 /* 200G capable */ +#define MDIO_PMA_SPEED_2_5G 0x2000 /* 2.5G capable */ +#define MDIO_PMA_SPEED_5G 0x4000 /* 5G capable */ +#define MDIO_PMA_SPEED_400G 0x8000 /* 400G capable */ + +/* PCS et al. Speed register. */ +#define MDIO_PCS_SPEED_10G MDIO_SPEED_10G #define MDIO_PCS_SPEED_10P2B 0x0002 /* 10PASS-TS/2BASE-TL capable */ +#define MDIO_PCS_SPEED_40G 0x0004 /* 450G capable */ +#define MDIO_PCS_SPEED_100G 0x0008 /* 100G capable */ +#define MDIO_PCS_SPEED_25G 0x0010 /* 25G capable */ #define MDIO_PCS_SPEED_2_5G 0x0040 /* 2.5G capable */ #define MDIO_PCS_SPEED_5G 0x0080 /* 5G capable */ +#define MDIO_PCS_SPEED_200G 0x0100 /* 200G capable */ +#define MDIO_PCS_SPEED_400G 0x0200 /* 400G capable */ /* Device present registers. */ #define MDIO_DEVS_PRESENT(devad) (1 << (devad)) From patchwork Fri Dec 2 18:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13063082 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D1BAC47088 for ; Fri, 2 Dec 2022 18:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234394AbiLBSSG (ORCPT ); Fri, 2 Dec 2022 13:18:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234361AbiLBSRt (ORCPT ); Fri, 2 Dec 2022 13:17:49 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2065.outbound.protection.outlook.com [40.107.105.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4257CE033; Fri, 2 Dec 2022 10:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fPZs4FxbeWFbjDR1qdEUo3mr7R4413KO4+V/TC6wDbfUd/gWZ3maeGwZNXOXQmVo4XkYAL455Q+ANl4jofp9yZv8UB3mB7OziYi5zQ0+20SzaFXmALtK66cqEFwj3LUhq8HAjuLt06xs/Aq+h3bX9WNl+/tGp6arryQcc0EIXw19zaENmBZKdqUV2aurmy+g0uS6+Sf0FuhHRwzH60FyngdTWpHEnRE422oKC0xXfFAyzHFqnuucCCBTMBemZVvp8xGdxKgGKkwmwXL77iDzb7JHrxZkthNn8byDn6MM9mExLCMlou8yv2ntdU8CJCgy/Unfs+DuiJgUS4gk97HTiA== 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=7oe1/5YiY+Ivy2JKtDWcCbtfT6qLTsYByF7Nzyz0upo=; b=Me3lpWmSvwasonV9bjeJtqsCq6R3cCI3WfqXkgonlzAxSVZio/EcrRxcgxWRoy4cM0XlspYbkceeOU7JPDVV0yBf4hI/KoJsXplxyoZHFJeOB6MkVrMOFVaenEoz/d19ToLNJyg5ilICjHRFUDPuhpd9zaryvP2yCUciMaI1dyLX0W/2kuV4INV7kDq+BpR6FoMLd7AIY0cM90Y4KLnDFEL1FNQyAuHFA5Tc2qVGmglH1IrwuOehOUacEPphJH94VmGG/BnNu6Vci0RkBie4JugXebVatSwF8djXMMPHOI+ZKg59oya0Vf4yoYLeBX7OC6Kj81PyUjFTWIMl+o5b+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7oe1/5YiY+Ivy2JKtDWcCbtfT6qLTsYByF7Nzyz0upo=; b=ygR9tGwX+kSRBVkSenHjUNRbr0V0WxSVc/G6lCbwlQ3WL7O6j1nAOJeoo8er9UCSaRb7ht+/p1oHxwZ7b4pZLVsa4WIRLwpYZgHFVZZvkK3eOXNPqtYVeL04++ECw0Omd3MMjkByHyQ8hHPVRQbb1IJi1yamQuhDIQU2zbtEdSdid4SdokjzqKpZqGICwfih5ShE0ENXtPND73jEVxPmjP2QoUpk7hMoC/NrCrUbBTuASyruwLx+S/VrvcvSkWh7oZAKWcizhiDGvUb/ImYntH/gI5N+bohMMB4OdxrMYBNWOIXQLgefi0P4B33OlNO7Cv5fXkX/d2W6F/l4/70zmw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) by DBBPR03MB7081.eurprd03.prod.outlook.com (2603:10a6:10:206::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Fri, 2 Dec 2022 18:17:35 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%8]) with mapi id 15.20.5857.023; Fri, 2 Dec 2022 18:17:35 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , Russell King , netdev@vger.kernel.org Cc: "David S . Miller" , Tim Harvey , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Sean Anderson Subject: [PATCH net-next v3 3/3] phy: aquantia: Determine rate adaptation support from registers Date: Fri, 2 Dec 2022 13:17:18 -0500 Message-Id: <20221202181719.1068869-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221202181719.1068869-1-sean.anderson@seco.com> References: <20221202181719.1068869-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::17) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|DBBPR03MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: f7f5f568-d0c1-4d21-ab31-08dad4917cb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 32ClNpma67miASy056cdMJytovhxcAlHXV1Do5666B6hpNiKpDsl9mAWPkjBGg/HSKEoV6OV5Az0sID792Anmu7HcBVZKkBB8clNT0vSQgGLUNjJwrEnkAqBmdjOWqKUOeJivGjYXU89bxlNyVpPg0KlKrKlVOJ36vc0JRqJMUXUqAzJsrJCWXwE54w+qeqJt4ojWnYgsY44Fv24C2jMbIYDxlbNS4QPl+XJiHoJEiktJOCPAVofEOssBdSe1RCK161idNa1INeV6v2IrgmjQO24B40FqEc+NW+lVNObk3xlQQgfuuvv+JoH/pImV7AGRfU0b0i95NXv7CIx2mx4bK6iZWyETQ4pL24ghw2PqBCqfS8Y4pQdsnmrOpSLRET9UQW25F6YHFfvKW/WD7BLSuJe4qhVUoZhEzopHqXL/LvvEsTZKztsIsyWfOKI7ZqpnMWwZSepZdSMzCN4S9ojgXNzHRXHn8NEfp/diaAghOMcDtEQx7j7ODNDzB0NYmLylBrfmrNX5G+PgvcdRjzQGrEy58qIo+FWb4IvLuN9VaPruM1YrS1XRk+A4/GbnowmwE7LTf8AL+Dxo0kr8wezs+fmXStz244ZbxGLa58ubUatmHcp4UjT2Lk/SjIcB/b+Z3lNI3gRR4yz5/yOclYRBerMIDrpdfJ2PGc5YAQTyRLuFLkdyf1pSl25iXzI6XgJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR03MB8847.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(346002)(39850400004)(396003)(366004)(376002)(451199015)(36756003)(38100700002)(38350700002)(86362001)(54906003)(316002)(110136005)(8676002)(107886003)(6666004)(478600001)(6486002)(26005)(6512007)(6506007)(52116002)(83380400001)(1076003)(186003)(41300700001)(2906002)(66556008)(66476007)(2616005)(7416002)(5660300002)(4326008)(66946007)(44832011)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XFENNtkrNPstkY3IZdJ4IRb6W/vscNJHwDOMmQ2l4EWxJg4e6cjN6bvOWA2AkiTLKv9grISyQkPSmyDzjRhuSrnm+SJBNvubhVpYR7V6FnsS4ntmaGLDGl2YiJbNMOKVaSl3Ye2Su6Q5vJH4U69T4IcVhERmsMC9Yd0wb/lm2bHbMJOLcp/0Rvg1gnCVCW/E3+ku1qKcY2oBgNR4fVDB4G78i1Umwhubis+ie8ORuEPQd4Fmev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Da4J77gzotIr+4CzjyTJexkRgxT48XQWjHVgm6dugg2ItYTyrKyJFoZxfhYOxL3CkdGZXzk71EL3u27Ma1nCfOYcGqXw4Gs1tQNMCfIf7yFNVtTGFQ1Dd2laHhwyIfeCUa64KvoDBWIWgHpbxxrOIriVIZDDJ4CEPeQItZ9NHmF3c/aLz2vob0to1pzEJsMQPEqHehYUR6mG4A+bBb2KsZMVTdwbBBvD9qisGk5ro82hgJyZ2eSn1tNHe7ZOQXs5OLNRRLg5QnaHOmE8aT8N2r+ZEfHr5XmBC2gp3Ul6Y2A== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7f5f568-d0c1-4d21-ab31-08dad4917cb1 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 18:17:35.4648 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wkl0jAZk2S0ObZUB3k+F4giFUAPwRK0QGQ3TmsAozrAG5oQpClddU84+kZ5xpqMh62gAKk0r/82p1mE8FYembg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB7081 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When autonegotiation completes, the phy interface will be set based on the global config register for that speed. If the SERDES mode is set to something which the MAC does not support, then the link will not come up. To avoid this, validate each combination of interface speed and link speed which might be configured. This way, we ensure that we only consider rate adaptation in our advertisement when we can actually use it. The API for get_rate_matching requires that PHY_INTERFACE_MODE_NA be handled properly. To do this, we adopt a structure similar to phylink_validate. At the top-level, we either validate a particular interface speed or all of them. Below that, we validate each combination of serdes speed and link speed. For some firmwares, not all speeds are supported. In this case, the global config register for that speed will be initialized to zero (indicating that rate adaptation is not supported). We can detect this by reading the PMA/PMD speed register to determine which speeds are supported. This register is read once in probe and cached for later. Signed-off-by: Sean Anderson --- This commit fixes 3c42563b3041 ("net: phy: aquantia: Add support for rate matching"). In an effort to avoid backporting of this commit until it has soaked in master for a while, the fixes tag has been left off. Changes in v3: - Fix incorrect bits for PMA/PMD speed Changes in v2: - Rework to just validate things instead of modifying registers drivers/net/phy/aquantia_main.c | 160 ++++++++++++++++++++++++++++++-- 1 file changed, 154 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 334a6904ca5a..e157e000d95b 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -111,6 +111,12 @@ #define VEND1_GLOBAL_CFG_RATE_ADAPT_NONE 0 #define VEND1_GLOBAL_CFG_RATE_ADAPT_USX 1 #define VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE 2 +#define VEND1_GLOBAL_CFG_SERDES_MODE GENMASK(2, 0) +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI 0 +#define VEND1_GLOBAL_CFG_SERDES_MODE_SGMII 3 +#define VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII 4 +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI5G 6 +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI20G 7 #define VEND1_GLOBAL_RSVD_STAT1 0xc885 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID GENMASK(7, 4) @@ -175,6 +181,7 @@ static const struct aqr107_hw_stat aqr107_hw_stats[] = { struct aqr107_priv { u64 sgmii_stats[AQR107_SGMII_STAT_SZ]; + int pmapmd_speeds; }; static int aqr107_get_sset_count(struct phy_device *phydev) @@ -677,13 +684,146 @@ static int aqr107_wait_processor_intensive_op(struct phy_device *phydev) return 0; } +/** + * struct aqr107_link_speed_cfg - Common configuration for link speeds + * @speed - The speed of this config + * @reg - The global system configuration register for this speed + * @speed_bit - The bit in the PMA/PMD speed ability register which determines + * whether this link speed is supported + */ +struct aqr107_link_speed_cfg { + int speed; + u16 reg, speed_bit; +}; + +/** + * aqr107_rate_adapt_ok_one() - Validate rate adaptation for one configuration + * @phydev: The phy to act on + * @serdes_speed: The speed of the serdes (aka the phy interface) + * @link_cfg: The config for the link speed + * + * This function validates whether rate adaptation will work for a particular + * combination of @serdes_speed and @link_cfg. + * + * Return: %true if the @link_cfg.reg is configured for rate adaptation, %true + * if @link_cfg.speed will not be advertised, %false otherwise. + */ +static bool aqr107_rate_adapt_ok_one(struct phy_device *phydev, int serdes_speed, + const struct aqr107_link_speed_cfg *link_cfg) +{ + struct aqr107_priv *priv = phydev->priv; + int val; + + phydev_dbg(phydev, "validating link_speed=%d serdes_speed=%d\n", + link_cfg->speed, serdes_speed); + + /* Vacuously OK, since we won't advertise it anyway */ + if (!(priv->pmapmd_speeds & link_cfg->speed_bit)) + return true; + + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, link_cfg->reg); + if (val < 0) { + phydev_warn(phydev, "could not read register %x:%.04x (err = %d)\n", + MDIO_MMD_VEND1, link_cfg->reg, val); + return false; + } + + phydev_dbg(phydev, "%x:%.04x = %.04x\n", MDIO_MMD_VEND1, link_cfg->reg, val); + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) != + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + return false; + + switch (FIELD_GET(VEND1_GLOBAL_CFG_SERDES_MODE, val)) { + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI20G: + return serdes_speed == SPEED_20000; + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI: + return serdes_speed == SPEED_10000; + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI5G: + return serdes_speed == SPEED_5000; + case VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII: + return serdes_speed == SPEED_2500; + case VEND1_GLOBAL_CFG_SERDES_MODE_SGMII: + return serdes_speed == SPEED_1000; + default: + return false; + } +} + +/** + * aqr107_rate_adapt_ok() - Validate rate adaptation for an interface speed + * @phydev: The phy device + * @speed: The serdes (phy interface) speed + * + * This validates whether rate adaptation will work for a particular @speed. + * All link speeds less than or equal to @speed are validate to ensure they are + * configured properly. + * + * Return: %true if rate adaptation is supported for @speed, %false otherwise. + */ +static bool aqr107_rate_adapt_ok(struct phy_device *phydev, int speed) +{ + static const struct aqr107_link_speed_cfg speed_table[] = { + { + .speed = SPEED_10, + .reg = VEND1_GLOBAL_CFG_10M, + .speed_bit = MDIO_PMA_SPEED_10, + }, + { + .speed = SPEED_100, + .reg = VEND1_GLOBAL_CFG_100M, + .speed_bit = MDIO_PMA_SPEED_100, + }, + { + .speed = SPEED_1000, + .reg = VEND1_GLOBAL_CFG_1G, + .speed_bit = MDIO_PMA_SPEED_1000, + }, + { + .speed = SPEED_2500, + .reg = VEND1_GLOBAL_CFG_2_5G, + .speed_bit = MDIO_PMA_SPEED_2_5G, + }, + { + .speed = SPEED_5000, + .reg = VEND1_GLOBAL_CFG_5G, + .speed_bit = MDIO_PMA_SPEED_5G, + }, + { + .speed = SPEED_10000, + .reg = VEND1_GLOBAL_CFG_10G, + .speed_bit = MDIO_PMA_SPEED_10G, + }, + }; + int i; + + for (i = 0; i < ARRAY_SIZE(speed_table) && + speed_table[i].speed <= speed; i++) + if (!aqr107_rate_adapt_ok_one(phydev, speed, &speed_table[i])) + return false; + + /* Must match at least one speed */ + if (i == ARRAY_SIZE(speed_table) && speed != speed_table[i].speed) + return false; + + return true; +} + static int aqr107_get_rate_matching(struct phy_device *phydev, phy_interface_t iface) { - if (iface == PHY_INTERFACE_MODE_10GBASER || - iface == PHY_INTERFACE_MODE_2500BASEX || - iface == PHY_INTERFACE_MODE_NA) + if (iface != PHY_INTERFACE_MODE_NA) { + if (aqr107_rate_adapt_ok(phydev, + phy_interface_max_speed(iface))) + return RATE_MATCH_PAUSE; + else + return RATE_MATCH_NONE; + } + + if (aqr107_rate_adapt_ok(phydev, SPEED_10000) || + aqr107_rate_adapt_ok(phydev, SPEED_2500) || + aqr107_rate_adapt_ok(phydev, SPEED_1000)) return RATE_MATCH_PAUSE; + return RATE_MATCH_NONE; } @@ -713,10 +853,18 @@ static int aqr107_resume(struct phy_device *phydev) static int aqr107_probe(struct phy_device *phydev) { - phydev->priv = devm_kzalloc(&phydev->mdio.dev, - sizeof(struct aqr107_priv), GFP_KERNEL); - if (!phydev->priv) + struct aqr107_priv *priv; + + priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); + if (!priv) return -ENOMEM; + phydev->priv = priv; + + priv->pmapmd_speeds = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_SPEED); + if (priv->pmapmd_speeds < 0) { + phydev_err(phydev, "could not read PMA/PMD speeds\n"); + return priv->pmapmd_speeds; + }; return aqr_hwmon_probe(phydev); }