From patchwork Tue Jan 3 22:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13088054 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 F2612C54EBC for ; Tue, 3 Jan 2023 22:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234003AbjACWFu (ORCPT ); Tue, 3 Jan 2023 17:05:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbjACWFp (ORCPT ); Tue, 3 Jan 2023 17:05:45 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062.outbound.protection.outlook.com [40.107.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 198F814D29; Tue, 3 Jan 2023 14:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SHn1KFts8xodf4iuPvW9JgyhPgMhgzknIl8GNG8SRyaGyqWWKbSyJSennOGadI00Hi9+w8CuX5m507UvykzqAsLGtDV3MMTX0Jl5m6nUcaOdPxU8kL9iARTeS7WvXLiJ57qmi5AvRn4gvpkPOlkOVMkCe7AR8tCAy3ZSmGm3LZk1FB6Koi8u9JSpiJC7od2UNZ37xGI6GTrwkfNVMAS1uu9hDi/t+A05RiIqtBXCgPOYIPdbkoSZX2fdzwo2ziKhN2Ykj5ZEHQnRJCFguI/ds2qOOyBIoAsEd9jsZ7EaAkrR5eeHiKcGbxPXITyFrGhD3UL41Fb2MJZCFeBity1g0w== 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=tBx2EPpjk5eg3mcjNHLHlcfeB089h5/CB2j8PXvrIjk=; b=XPTb3oqBqiFsp5vwNu/0R3HrkETS5oeUKcm0JvKla9159z4s6W94kdfVgJxH6nEXHKDYvFodcsUkooLPDxrYSU+33NX73fr4hc5mIILBTR/0srb8mQL+S1QsEvnztAbhrh6ohXr7ZLpIQMDZqGC4xuTK9rUh7EiV3jTVrSbZEf8GZnGvWBZ1XeUnEz/xx2W12dHrJGgePtjSlrH7UEsgvEs8h/CkvpUNxncA+EUPLa0O//ui7AnDL3f0CTAk+I+dmcrKp9S9e4nK6aFbGacHhDQ+6Jct0wGAzJY70xOsLg+D0BgTUJYcNdJ9zTcxxOriJeilfLvFzfbbDpqJaxSVXQ== 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=tBx2EPpjk5eg3mcjNHLHlcfeB089h5/CB2j8PXvrIjk=; b=d7agaVsF3qSeitqqrCxbapTanDHt1XqbxwkS/Ej/jfjypYpJfLozAvXgf10JoIpJcjzBHXrJC+KzDX8j9c9b7hd3u12DXhSdJbPlQ7cT/paeZabH4iaX5VsXgZz5VDmZjB79ncszv+jvV+RfCYkXEUzdUAHuIPLBfOKijFpaWCbRSxUyEGNzSN/VkgJKEUbr88dByCgb/jJdi+SS94Kz3WgFQj116pm041lyk23pumjMXndxFfkGMo0/H6+YxNWVSGuwCAFZYxDglpxhIQieOfeGNKPXAv5NJwE0RmzAc3GZaH0y2y2GFMrH4a4nLVBa6SUq3H7aW+dACaB88sN1Zg== 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 VI1PR03MB9900.eurprd03.prod.outlook.com (2603:10a6:800:1c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:05:40 +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.5944.019; Tue, 3 Jan 2023 22:05:40 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: "David S . Miller" , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Tim Harvey , Vladimir Oltean , Sean Anderson , Russell King Subject: [PATCH net-next v5 1/4] net: phy: Move/rename phylink_interface_max_speed Date: Tue, 3 Jan 2023 17:05:08 -0500 Message-Id: <20230103220511.3378316-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20230103220511.3378316-1-sean.anderson@seco.com> References: <20230103220511.3378316-1-sean.anderson@seco.com> X-ClientProxiedBy: SJ0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:a03:39c::7) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|VI1PR03MB9900:EE_ X-MS-Office365-Filtering-Correlation-Id: 09f99c14-fedf-4ced-dec7-08daedd6a6ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dzJBgWkz8wu+ZBdwjl5c4ztKnn75d1AFWZuH1QVfUEYpcM3sNpyIk9A5LjzxAuBdmSRef+MlzWZAENo5q1yX0JQt54LGnS4m8r7DMfMfS0r0lGMspwBw8EJr0ixQU1RFMyeo96CDoYd6Fo9ygc7v+Y03HfUc2nrzAFCpnOeXxRFMgjrICjh6fQgDvz1fsJ/MVNxvrowSyKP8Tah3kOt0op1LiBibtO9/sTGTZzLknv+GzqU/z520gRrX86IAlt5Khip+7QzYWMGPjHDbgerPgtWmpFbHpCRBr60w2tZuscWsyD6p1RiiFzflnCce4Cw6P0PE6Upt5WiT/g+g8aKrgIg9gp937blg96FTf8w4/MFUgiowaeQPHvxRoTIE6uoup2EMcip8Vvz9qJv3TqMrDmWaY7oeauPP0ZAR+yTSF/e0SFMwlac935bZdKyE50XwjeVGT+HDX4VDEXTGq6Vmj/bo8rNysL8H32uYTs2POV7w5vRfGQhWVK+rSdpsmORu1MuiCj69SUf0YOOC8vMekMeM42URlHsQ2N2ulceOhA1d1lZKXQXsQwidTlmESirtc1+zCBzYHe/x4lRfdcza++rd4U9om3XeHRfrpbnAB4BDvXriN3VavQubKUgzUU+mTfZw3Xlx7sFOdD+pezH4Dvgywrl632bvR+ZuzQKLrqVamFmKKCq8N4ZFuTwDE4PXLncfwmApILiI1ersdBsngOJjc7ApEY0UvC4zsYfBHiY= 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)(376002)(366004)(39840400004)(396003)(346002)(451199015)(110136005)(54906003)(26005)(186003)(52116002)(6666004)(1076003)(2616005)(66476007)(6486002)(66556008)(66946007)(6512007)(478600001)(4326008)(83380400001)(8936002)(8676002)(5660300002)(7416002)(41300700001)(44832011)(2906002)(316002)(38100700002)(38350700002)(86362001)(6506007)(36756003)(22166009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /yQNNFEQIqu5rt84iwn5vhW/p71sL1Tg/+e1r0NBUES12rlY4/dvZrOVGGXKOyu9HsWL5lTBKa29ApD9wgUBe2kG03/0U+kbdIsrU4Xpor7vVJ+zoXm6VTyea3mYdwd3WdQWa1hXfYOMz5dDS04ExxxnkvVAlhYyJ0RgNBUg215Y6tE8j//mee7LIO1DiICRA9G5+mY1ML9oR+/SE4hrHf1Zb5GDCRCLvUrrvd0ZXUEr6ErMJuv8mMcYipLlVFFV3KNlC6jfzWLCWAmlVKHxB2+d7MvrdR8o25dQY6hu5TeuoZGm4Fv/ypmpJnOKz4ZnUFjuzXRNI0AbYqoOAN9C2Tl4y0dB0J4dnBhhaVhYoA3LhoFS28ACIvTaL28GMztjPdgiZEzaBT9SPOLH2UPx0IfwzvtKkRYNtxZqn+8LsA7pmeYMreRXsezIGsxCz/1zM1nU8btH0tVZAp2PgqovsajSl2mAEn2HeR8gUtP6taIjkXnGKmFNkBtGr3yx6f9p/VCMUJJvY0HkBR4J9vmJdImUfbHHup9dGTV4ldgOePIyZGM9sGGyrjPqfkPSV2O4VxAHihfKEWcmzk6+CSQdaSQxRlVCYuNS3186CdpX4iLD1nh+JVHRA1ABRUOELk8XmgMmjSF+j10B1QsSNpOWaiCVv1GIwLRInWgN768mp4U5Dks2WK2CchLGbsn7uDyr3x3HsxxjMG86MRy7CpNkSvB2RwOj0qWkyYOsYExrXAZXp5IdzC8eEVGRo76QmQ7le4XHY/uDBlVk4cZfBY5XklCFpJts67SdeWiAStMAP3ySE4ssOM/MQtP00JWoYN3zP4y5IcpCMmy26fWmyH9mYAyk6MBDXmwSlfc8lbWCP+Gqfk/XFcKcUVYRdaGz5/UAtJ31eB95n0gUGDSdPynn5ZQUrtGxq/j2RmyjkWzoomzgh8oVQ/xFzq57e1i3YwYR3zzTu9qd52mczFhdM/ChIrVYReXvhgpcEP75GEOv1G+H0E2oswjbfZHxuOi3/X+a9wA6VSCSRqWygCqQyjHkzZI97Wvw+UDwEZR5Xb5qJ7bmZ3NPVPphnFccmx3SrZd4diAvlivvh0UjKZXCjvF3ngzdii0VOc7MWuDCTin1LSRgDN3c4oR2uwG5wyW8vOyw7BC8UVjIGt084kMY+xjZy79XPoHZ5wMu+gejr9r9HHdFHtQhKraXp+UjO3FjtacHFdkB2nD2Q1EUUvWKdTMkGAd5eI+FiR5sdkox08cVMWI/N352MFkWGPHcy3C4iUxeAfoLJ7CeCTCiDALgw+J5oEuZ5iu41n3KObxY+qMZTce85vTDuhrp84lp/buhr77j9NtnQu5PsTnKNuqgjduFqM54VcCvd4+KD40+sGyvrAvEkVhCxtVvNu2SnhGB9hbn3T2oUQyBPZWBq0TEHDJAEMRs82fMVv58HqlY83wqLDSCKQv/RQca4SIASMkrgw/dSMyRThK0EZID4IHlYZFSUDnWOLnpLCV9Fkar3mrNsgfAtTscvGGhJiOCqPyOzsOkrYLj1j4D6uLJm9fpt3mVVRS6HqU9sxJaWmFF209AdL+skbaCE+jiLzdPWM2nBphxMNB+JDLYF+w2+YmCuVDe7A== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09f99c14-fedf-4ced-dec7-08daedd6a6ff X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:05:40.8167 (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: fJYRKcHxNfJspCkgINWgk6KJMS3wnQyXOBjLSL8wgguyKh1Bbw+oOH7R0zhylh4xplRmKVHCw3YPhHfwC81k/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB9900 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 Tue Jan 3 22:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13088055 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 CA8FBC4708E for ; Tue, 3 Jan 2023 22:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238248AbjACWFv (ORCPT ); Tue, 3 Jan 2023 17:05:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233989AbjACWFt (ORCPT ); Tue, 3 Jan 2023 17:05:49 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2070.outbound.protection.outlook.com [40.107.104.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1998690; Tue, 3 Jan 2023 14:05:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bRQMWACc7cBp2bDkT0fWkMP0CEl6/yFtq9XGJQcP2yyNdY1T9jvHbZLSSapUeQGt8sYjAyzfFQOdhFbXb0ZSsbz2Q/UYdi8cbb4F57N5q0kV8LVzzYRfLSljNmV7zk4BMO5LLqf9c+3g4REUAtctrZEpNQTxcw+aTZNY5ddyDV+Pb54w9IetrXoG912B1i46uzReee2M0XWzTtKuzPgTwhh/XkJJS5kgWVNrZWTJhgN1tvm2L2321fwNkLcCTY8Zhvep6dOi+aFbtT50hTxkqldnSKfy7iXZyqBEJFvUyy8DLLRZG63uF3khgjz3SKKEcoWMYzMyG8CA3o6XAFQG4g== 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=MaM/lc8IHfnf6gwWWK15TNOSFWBfGk/Z1dMtGv56+tc=; b=LYSSE9l0vl9f9Ae8y5yOphR2pEPgA6QA8iJD8lYhP6xTAbYrGlQG4ukSHNgut/fIgNfCKP6OqLzLv08NQi/Wxi4TK1oXB62y3c0C58oRzZlJFKYD4AckGfJl0wSxJfAv3C8Q3H+gB8xFl3m4Nm8drIJJuOWKKSNHNxv3FSR5VOCE/s06TwZzqqAOPX5JJ2M9ZkAF8EsK7rPHCR9Fd0Cl1bu7snTaGqPoaDMiZpi2nvjbDsFuiHAvFRgS2tvD0G64bMJyEiVH1hCrFxh947nhkHvM0Oke2ACFecHSD1luJ8ycBlqk/lrTc5ctU/el6iExeys55760fduczD1Fn/a5mg== 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=MaM/lc8IHfnf6gwWWK15TNOSFWBfGk/Z1dMtGv56+tc=; b=iP7fX9KnfD3VAv+/qSYI3ud5z1UMal4DE8xjSswZzaJ7fo8rSeuURtthYWqSrTQ6lr7ooamDztviSEkyCu5xDPMi30OxcCaa3dYA4h5QP5373hKhwL4HbGIDf4thMZd0uqaOlFFzbZYQnTD2SVbnS+WeqG+AmzJf4RVS67ZrHkB7P1b6PUl4nhX38twWq5hAnxmbuH3AKrEDL6/wvHvKlwI84Ybg2Th9p95sO//aG1Fx6Hde9u3yMMDGdzYmXt1MzTItU9/hMwjQrF+PVob6/VzoSMcCfMF7f6xAJlwCaLr6lwpFuNF2m7HyFS3dFnLyPV08xKiT3JanxHRVDfK5ZQ== 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 VI1PR03MB9900.eurprd03.prod.outlook.com (2603:10a6:800:1c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:05:44 +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.5944.019; Tue, 3 Jan 2023 22:05:44 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: "David S . Miller" , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Tim Harvey , Vladimir Oltean , Sean Anderson Subject: [PATCH net-next v5 2/4] phy: mdio: Reorganize defines Date: Tue, 3 Jan 2023 17:05:09 -0500 Message-Id: <20230103220511.3378316-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20230103220511.3378316-1-sean.anderson@seco.com> References: <20230103220511.3378316-1-sean.anderson@seco.com> X-ClientProxiedBy: SJ0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:a03:39c::7) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|VI1PR03MB9900:EE_ X-MS-Office365-Filtering-Correlation-Id: 93e68c4e-dff7-4fc8-c806-08daedd6a939 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +/1LxmL/fjClFCF2Lt8VZJVb55FsgtaJRIQbSF10TIn3hV89mQ7gg6UCd4zHRPW4oir7H/Fc0yc7VxrsQFO28Ec6uFZePuqyb3SaVj1lEQE3Pu5RLufe4c6jXK2wVyc4P9RlPhEYuzGrR1yXzJK/mu8fbiMR2bzBk7IoTp5gqGW0AWeikolu42B0gKgve4QTF3+2tcYnaMKCVAFUvCL8H5zHjhNvnWk81A6UWVHy/2Zw8T6bBul67yzDHhqecpYmky4Ia6N+IP/dXvM9uW4GszuqQuudS+aJkqz4E2iNTqCVYlLyTTn7eu8kEjQxKV2j7rwBo8DIPzSEQ2c/4WTwM73pstEqnf37hUYeVYmHwLk0xAlSMvaAj4+0XHDZnxsu2Opsaybay/9dHxw1keqlVMVUMh04Db78UOrrHmJB7pbEPn+XwAmXYyWWy1mQiSxVd3lnEwx5qOz8xxPIPoZkJto/C9zMqnM0WIs4GUIjCUhBxZKQwudtTIz2RBRFsvpeC1PCQ2p7csL0uvktMI+FgzdKTpexGbNAOGOQQY0GL0I5ipAf6sIe29yyaNkMKMHVtkynGVow/zKez4yuAQz5Xw98piZndvR5r38gwwR7R3tX35ZTd5RxeeDZg28g3Y8A4993rYPBf6mcVg9VdMzv8/IAU0k22MYwcYe3JVeQPaBBELwtOAeAYIAxwNH12dUYJh6OWQepKGWyHYIxGFFBGZIuNswjDvpDNB7hajKseUs= 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)(376002)(366004)(39840400004)(396003)(346002)(451199015)(110136005)(54906003)(26005)(186003)(52116002)(107886003)(6666004)(1076003)(2616005)(66476007)(6486002)(66556008)(66946007)(6512007)(478600001)(4326008)(83380400001)(8936002)(8676002)(30864003)(5660300002)(7416002)(41300700001)(44832011)(2906002)(316002)(38100700002)(38350700002)(86362001)(6506007)(36756003)(22166009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hK0DewAAApNUG0eX5n8b/8O9GZZ+vOj2Dz0iMYZxEQ5pHTZNzLWRYYLyFIzAG7+XP/V72soOmXkDz25Y7BkwjkLfmnsMY+/DWWdOZCrMtJhsuQSa5NP089H+DPfjZD7FuhuOAi0ATIXJRaI9Ut/NLzgHs1Ayfim9wI+nw2qz05Dl3hgudQSPnHFi44ADxkmH3MjfWKIptv9ONJuSKexIcWM9dPVTTJZWK+aekQYVIW5ZbsSOGCM+0loUnu0OUPUTFyzcQMaIW6VXrxkmZ5TEWEDGuOez5tXZNTdiB0fl42if+q7034k1aiSr9M2pehs7LkZUdfIlxfJ0ooEBJ+2VIv0OH/5a1yYbGm4I6wvjU5KaoJVpFhNB9ZARo7+vrnWs3oTSyEpqTe4NuV/Yt7mX+rNaGS5oZRCet2uT6AxMKaHxjv5k80G1qIh994ddM4rtQGwk/H7vUYaeDMTzIP3p5XgqhaLp0Jq0K0zb37UxI35GM6/zqxhiJ0aZuzSxtGCIk/WraZzJmflx0FmOr2j4VMk4IjHLQdeaWjDchIiMtaAoshAy2BL54uFA0ReyUJg3Jqyaals6M1lpjP3X6gchakIvQ1zj+sHk10/Ab0silPjFf8bFDcSjJf9yPozK/6jnmteOdDcMEVR6MgrEH7YCP8YoOe/2SsZEqMGArf6JtJKpnUfvIryAsNsZvR7iPQYNUWuWysh5c5tTIc33gSi/GSqrOFN9sbt+E7m4gcFal3QV2beU2lB8phGrh32+5lx8IPAdzBRAeTBK1kXZACVHpJytGXnWaRZyYh5O36Zz5+W45gkGKc/VOqQzfOHhoG7GhZBvI5MYl8P4aIN55vN8AcgcvAwPPO9lN0d9y9aexYI3QOg4A6ip7FU4N0/7yARF10OWgwTv2qXKHybuUSVOHfahyYoxYpvnWu2R757WQCjXKjpGSf0KLP1/fAAClnEOpb+BXmXKSUiI73TLyk0L8aYmCOJkuv9WDI7fdo17nAqvnxd1Ug6T6LlxfDe0vXlBlKEY3VBQaVO+5p1mPQFvpHdC5+p4D3H6siyHc0u3951m3qvESzUp/7j4Oo5chIZwLB5ZBEui0pBZRVNIQkjXhuAMCcsAPIuAly3AdwmtfGq6JHbSAkyx+vNOtE8/qT83ZQxImG1updogfgfbQNPiljCcthIfeVmdpRtQeuIbv50dGSQP51yFrCCUN2rrxcXEasZHvjMnpIBWTGMpEL02bbFEQQrc93l3TyCpF9GUJ6d4ZCR+mWDSyQdsKGnFJrNtinKydKGKH+bC6kvSJSMAYf+JHb5zmdW67XR23SXpJt8hCxiZNG8Z2EehNiYngNV/IaAWj/Uh9iqHG/RdLHyEugu4CgmJ3Pbo/BvBHJMnZJvAHbFZHruKga5emUqKzvPvD4H0p0saQLtxoYUPzn8YlxW9q9hr586Hns0pZpwkATxM/VzG/ElNhG4KPSU/F8hUvM42MuXxBRyD+MWZGYOXTIagyS7YdTjYmccMR29SAdPkcb1pXnQ0eeqNOBLEfMrEOSyucv/yFesaON1+jNHKc3c0LttRRkMfQW2ywlddqVr4iXnawYKrIPKbHqc+jpOWdhul36YL0iT6KGmamxZG5A== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93e68c4e-dff7-4fc8-c806-08daedd6a939 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:05:44.6600 (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: OjrtJ9g2kSoMWWy+HfAV4n9Au3lXCZ8QBLJwGjUMzGIDDvF1X+lbbAGD1bGDZ79usrDVFcuw/W2sWGBtkjFdew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB9900 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Reorder all registers to be grouped by MMD. Groups fields in similarly-named registers in the same way. This is especially useful for registers which may have some bits in common, but interpret other bits in different ways. The comments have been tweaked to more closely follow 802.3's naming. Signed-off-by: Sean Anderson --- (no changes since v4) Changes in v4: - New include/uapi/linux/mdio.h | 102 ++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 75b7257a51e1..14b779a8577b 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -37,40 +37,47 @@ #define MDIO_DEVS2 6 #define MDIO_CTRL2 7 /* 10G control 2 */ #define MDIO_STAT2 8 /* 10G status 2 */ +#define MDIO_PKGID1 14 /* Package identifier */ +#define MDIO_PKGID2 15 + +/* PMA/PMD registers. */ #define MDIO_PMA_TXDIS 9 /* 10G PMA/PMD transmit disable */ #define MDIO_PMA_RXDET 10 /* 10G PMA/PMD receive signal detect */ #define MDIO_PMA_EXTABLE 11 /* 10G PMA/PMD extended ability */ -#define MDIO_PKGID1 14 /* Package identifier */ -#define MDIO_PKGID2 15 -#define MDIO_AN_ADVERTISE 16 /* AN advertising (base page) */ -#define MDIO_AN_LPA 19 /* AN LP abilities (base page) */ -#define MDIO_PCS_EEE_ABLE 20 /* EEE Capability register */ -#define MDIO_PCS_EEE_ABLE2 21 /* EEE Capability register 2 */ +#define MDIO_PMA_PMD_BT1 18 /* BASE-T1 PMA/PMD extended ability */ #define MDIO_PMA_NG_EXTABLE 21 /* 2.5G/5G PMA/PMD extended ability */ -#define MDIO_PCS_EEE_WK_ERR 22 /* EEE wake error counter */ -#define MDIO_PHYXS_LNSTAT 24 /* PHY XGXS lane state */ -#define MDIO_AN_EEE_ADV 60 /* EEE advertisement */ -#define MDIO_AN_EEE_LPABLE 61 /* EEE link partner ability */ -#define MDIO_AN_EEE_ADV2 62 /* EEE advertisement 2 */ -#define MDIO_AN_EEE_LPABLE2 63 /* EEE link partner ability 2 */ -#define MDIO_AN_CTRL2 64 /* AN THP bypass request control */ - -/* Media-dependent registers. */ #define MDIO_PMA_10GBT_SWAPPOL 130 /* 10GBASE-T pair swap & polarity */ #define MDIO_PMA_10GBT_TXPWR 131 /* 10GBASE-T TX power control */ #define MDIO_PMA_10GBT_SNR 133 /* 10GBASE-T SNR margin, lane A. * Lanes B-D are numbered 134-136. */ #define MDIO_PMA_10GBR_FSRT_CSR 147 /* 10GBASE-R fast retrain status and control */ #define MDIO_PMA_10GBR_FECABLE 170 /* 10GBASE-R FEC ability */ +#define MDIO_PMA_PMD_BT1_CTRL 2100 /* BASE-T1 PMA/PMD control register */ +#define MDIO_B10L_PMA_CTRL 2294 /* 10BASE-T1L PMA control */ +#define MDIO_PMA_10T1L_STAT 2295 /* 10BASE-T1L PMA status */ + +/* PCS registers */ +#define MDIO_PCS_EEE_ABLE 20 /* EEE Capability register */ +#define MDIO_PCS_EEE_ABLE2 21 /* EEE Capability register 2 */ +#define MDIO_PCS_EEE_WK_ERR 22 /* EEE wake error counter */ #define MDIO_PCS_10GBX_STAT1 24 /* 10GBASE-X PCS status 1 */ #define MDIO_PCS_10GBRT_STAT1 32 /* 10GBASE-R/-T PCS status 1 */ #define MDIO_PCS_10GBRT_STAT2 33 /* 10GBASE-R/-T PCS status 2 */ +#define MDIO_PCS_10T1L_CTRL 2278 /* 10BASE-T1L PCS control */ + +/* PHY XS registers */ +#define MDIO_PHYXS_LNSTAT 24 /* PHY XGXS lane state */ + +/* Auto_negotiation registers */ +#define MDIO_AN_ADVERTISE 16 /* AN advertising (base page) */ +#define MDIO_AN_LPA 19 /* AN LP abilities (base page) */ #define MDIO_AN_10GBT_CTRL 32 /* 10GBASE-T auto-negotiation control */ #define MDIO_AN_10GBT_STAT 33 /* 10GBASE-T auto-negotiation status */ -#define MDIO_B10L_PMA_CTRL 2294 /* 10BASE-T1L PMA control */ -#define MDIO_PMA_10T1L_STAT 2295 /* 10BASE-T1L PMA status */ -#define MDIO_PCS_10T1L_CTRL 2278 /* 10BASE-T1L PCS control */ -#define MDIO_PMA_PMD_BT1 18 /* BASE-T1 PMA/PMD extended ability */ +#define MDIO_AN_EEE_ADV 60 /* EEE advertisement */ +#define MDIO_AN_EEE_LPABLE 61 /* EEE link partner ability */ +#define MDIO_AN_EEE_ADV2 62 /* EEE advertisement 2 */ +#define MDIO_AN_EEE_LPABLE2 63 /* EEE link partner ability 2 */ +#define MDIO_AN_CTRL2 64 /* AN THP bypass request control */ #define MDIO_AN_T1_CTRL 512 /* BASE-T1 AN control */ #define MDIO_AN_T1_STAT 513 /* BASE-T1 AN status */ #define MDIO_AN_T1_ADV_L 514 /* BASE-T1 AN advertisement register [15:0] */ @@ -79,7 +86,6 @@ #define MDIO_AN_T1_LP_L 517 /* BASE-T1 AN LP Base Page ability register [15:0] */ #define MDIO_AN_T1_LP_M 518 /* BASE-T1 AN LP Base Page ability register [31:16] */ #define MDIO_AN_T1_LP_H 519 /* BASE-T1 AN LP Base Page ability register [47:32] */ -#define MDIO_PMA_PMD_BT1_CTRL 2100 /* BASE-T1 PMA/PMD control register */ /* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */ #define MDIO_PMA_LASI_RXCTRL 0x9000 /* RX_ALARM control */ @@ -89,7 +95,7 @@ #define MDIO_PMA_LASI_TXSTAT 0x9004 /* TX_ALARM status */ #define MDIO_PMA_LASI_STAT 0x9005 /* LASI status */ -/* Control register 1. */ +/* Generic control 1 register. */ /* Enable extended speed selection */ #define MDIO_CTRL1_SPEEDSELEXT (BMCR_SPEED1000 | BMCR_SPEED100) /* All speed selection bits */ @@ -97,15 +103,6 @@ #define MDIO_CTRL1_FULLDPLX BMCR_FULLDPLX #define MDIO_CTRL1_LPOWER BMCR_PDOWN #define MDIO_CTRL1_RESET BMCR_RESET -#define MDIO_PMA_CTRL1_LOOPBACK 0x0001 -#define MDIO_PMA_CTRL1_SPEED1000 BMCR_SPEED1000 -#define MDIO_PMA_CTRL1_SPEED100 BMCR_SPEED100 -#define MDIO_PCS_CTRL1_LOOPBACK BMCR_LOOPBACK -#define MDIO_PHYXS_CTRL1_LOOPBACK BMCR_LOOPBACK -#define MDIO_AN_CTRL1_RESTART BMCR_ANRESTART -#define MDIO_AN_CTRL1_ENABLE BMCR_ANENABLE -#define MDIO_AN_CTRL1_XNP 0x2000 /* Enable extended next page */ -#define MDIO_PCS_CTRL1_CLKSTOP_EN 0x400 /* Stop the clock during LPI */ /* 10 Gb/s */ #define MDIO_CTRL1_SPEED10G (MDIO_CTRL1_SPEEDSELEXT | 0x00) @@ -116,10 +113,29 @@ /* 5 Gb/s */ #define MDIO_CTRL1_SPEED5G (MDIO_CTRL1_SPEEDSELEXT | 0x1c) -/* Status register 1. */ +/* PMA/PMD control 1 register. */ +#define MDIO_PMA_CTRL1_LOOPBACK 0x0001 +#define MDIO_PMA_CTRL1_SPEED1000 BMCR_SPEED1000 +#define MDIO_PMA_CTRL1_SPEED100 BMCR_SPEED100 + +/* PCS control 1 register. */ +#define MDIO_PCS_CTRL1_LOOPBACK BMCR_LOOPBACK +#define MDIO_PCS_CTRL1_CLKSTOP_EN 0x400 /* Stop the clock during LPI */ + +/* PHY XS control 1 register. */ +#define MDIO_PHYXS_CTRL1_LOOPBACK BMCR_LOOPBACK + +/* AN control register. */ +#define MDIO_AN_CTRL1_RESTART BMCR_ANRESTART +#define MDIO_AN_CTRL1_ENABLE BMCR_ANENABLE +#define MDIO_AN_CTRL1_XNP 0x2000 /* Enable extended next page */ + +/* Generic status 1 register. */ #define MDIO_STAT1_LPOWERABLE 0x0002 /* Low-power ability */ #define MDIO_STAT1_LSTATUS BMSR_LSTATUS #define MDIO_STAT1_FAULT 0x0080 /* Fault */ + +/* AN status register. */ #define MDIO_AN_STAT1_LPABLE 0x0001 /* Link partner AN ability */ #define MDIO_AN_STAT1_ABLE BMSR_ANEGCAPABLE #define MDIO_AN_STAT1_RFAULT BMSR_RFAULT @@ -127,13 +143,17 @@ #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_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 */ + +/* PCS et al. Speed register. */ #define MDIO_PCS_SPEED_10P2B 0x0002 /* 10PASS-TS/2BASE-TL capable */ #define MDIO_PCS_SPEED_2_5G 0x0040 /* 2.5G capable */ #define MDIO_PCS_SPEED_5G 0x0080 /* 5G capable */ @@ -152,7 +172,7 @@ #define MDIO_DEVS_VEND1 MDIO_DEVS_PRESENT(MDIO_MMD_VEND1) #define MDIO_DEVS_VEND2 MDIO_DEVS_PRESENT(MDIO_MMD_VEND2) -/* Control register 2. */ +/* PMA/PMD control 2 register. */ #define MDIO_PMA_CTRL2_TYPE 0x000f /* PMA/PMD type selection */ #define MDIO_PMA_CTRL2_10GBCX4 0x0000 /* 10GBASE-CX4 type */ #define MDIO_PMA_CTRL2_10GBEW 0x0001 /* 10GBASE-EW type */ @@ -173,17 +193,21 @@ #define MDIO_PMA_CTRL2_2_5GBT 0x0030 /* 2.5GBaseT type */ #define MDIO_PMA_CTRL2_5GBT 0x0031 /* 5GBaseT type */ #define MDIO_PMA_CTRL2_BASET1 0x003D /* BASE-T1 type */ + +/* PCS control 2 register. */ #define MDIO_PCS_CTRL2_TYPE 0x0003 /* PCS type selection */ #define MDIO_PCS_CTRL2_10GBR 0x0000 /* 10GBASE-R type */ #define MDIO_PCS_CTRL2_10GBX 0x0001 /* 10GBASE-X type */ #define MDIO_PCS_CTRL2_10GBW 0x0002 /* 10GBASE-W type */ #define MDIO_PCS_CTRL2_10GBT 0x0003 /* 10GBASE-T type */ -/* Status register 2. */ +/* Generic status 2 register. */ #define MDIO_STAT2_RXFAULT 0x0400 /* Receive fault */ #define MDIO_STAT2_TXFAULT 0x0800 /* Transmit fault */ #define MDIO_STAT2_DEVPRST 0xc000 /* Device present */ #define MDIO_STAT2_DEVPRST_VAL 0x8000 /* Device present value */ + +/* PMA/PMD status 2 register */ #define MDIO_PMA_STAT2_LBABLE 0x0001 /* PMA loopback ability */ #define MDIO_PMA_STAT2_10GBEW 0x0002 /* 10GBASE-EW ability */ #define MDIO_PMA_STAT2_10GBLW 0x0004 /* 10GBASE-LW ability */ @@ -196,27 +220,29 @@ #define MDIO_PMA_STAT2_EXTABLE 0x0200 /* Extended abilities */ #define MDIO_PMA_STAT2_RXFLTABLE 0x1000 /* Receive fault ability */ #define MDIO_PMA_STAT2_TXFLTABLE 0x2000 /* Transmit fault ability */ + +/* PCS status 2 register */ #define MDIO_PCS_STAT2_10GBR 0x0001 /* 10GBASE-R capable */ #define MDIO_PCS_STAT2_10GBX 0x0002 /* 10GBASE-X capable */ #define MDIO_PCS_STAT2_10GBW 0x0004 /* 10GBASE-W capable */ #define MDIO_PCS_STAT2_RXFLTABLE 0x1000 /* Receive fault ability */ #define MDIO_PCS_STAT2_TXFLTABLE 0x2000 /* Transmit fault ability */ -/* Transmit disable register. */ +/* PMD Transmit disable register. */ #define MDIO_PMD_TXDIS_GLOBAL 0x0001 /* Global PMD TX disable */ #define MDIO_PMD_TXDIS_0 0x0002 /* PMD TX disable 0 */ #define MDIO_PMD_TXDIS_1 0x0004 /* PMD TX disable 1 */ #define MDIO_PMD_TXDIS_2 0x0008 /* PMD TX disable 2 */ #define MDIO_PMD_TXDIS_3 0x0010 /* PMD TX disable 3 */ -/* Receive signal detect register. */ +/* PMD receive signal detect register. */ #define MDIO_PMD_RXDET_GLOBAL 0x0001 /* Global PMD RX signal detect */ #define MDIO_PMD_RXDET_0 0x0002 /* PMD RX signal detect 0 */ #define MDIO_PMD_RXDET_1 0x0004 /* PMD RX signal detect 1 */ #define MDIO_PMD_RXDET_2 0x0008 /* PMD RX signal detect 2 */ #define MDIO_PMD_RXDET_3 0x0010 /* PMD RX signal detect 3 */ -/* Extended abilities register. */ +/* PMA/PMD extended ability register. */ #define MDIO_PMA_EXTABLE_10GCX4 0x0001 /* 10GBASE-CX4 ability */ #define MDIO_PMA_EXTABLE_10GBLRM 0x0002 /* 10GBASE-LRM ability */ #define MDIO_PMA_EXTABLE_10GBT 0x0004 /* 10GBASE-T ability */ @@ -229,7 +255,7 @@ #define MDIO_PMA_EXTABLE_BT1 0x0800 /* BASE-T1 ability */ #define MDIO_PMA_EXTABLE_NBT 0x4000 /* 2.5/5GBASE-T ability */ -/* PHY XGXS lane state register. */ +/* 10G PHY XGXS lane status register. */ #define MDIO_PHYXS_LNSTAT_SYNC0 0x0001 #define MDIO_PHYXS_LNSTAT_SYNC1 0x0002 #define MDIO_PHYXS_LNSTAT_SYNC2 0x0004 From patchwork Tue Jan 3 22:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13088056 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 6BD7BC4708E for ; Tue, 3 Jan 2023 22:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238433AbjACWGC (ORCPT ); Tue, 3 Jan 2023 17:06:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234043AbjACWFw (ORCPT ); Tue, 3 Jan 2023 17:05:52 -0500 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E25E56; Tue, 3 Jan 2023 14:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GXExqV9ZK7GXMaz6cV5AzhPZPMJTrlDobL/3xyz+2RxuXJEAccc3ch3BOKztxhrBoIH9ATLcDKvWda9r/XeF+PVYxkZpKt/5A2V7jdbJ2krVkVXtyhFROHqbQ8qZ2U25M6vdfbar3Ng3nGaSi5JlbdW5XCM+zmHQoVWJ3kIdcZ6dh7hX9ubURAlvODWoZpqyY4m0Z8woQ+yMCZjRwnTUefhF+Pwwc3vrsdQsuFEXKW0Chs6iSwJWGLdn8OvpjSPogpj0M3XRl/dBOO2PuBY+mO8vqwBuk/50QXgcGNWtK+lwx1MXViMopcf8Q+qaHBWUpRMqjm1WD+1pyw32g6LyiQ== 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=2zKgX8iVwdqeQnqD84zbln0DK5aLv2Bsa8x25J6fqyo=; b=KZcWRcT4rBcs+AXPzUa1ldJrB/z+UCgC4UYc6LQUe2dfETNKJ0+1MIWufyMZS8fLEN9UofcqSvvrXwJUVssfqSeQiSRHmR+A29Qs/kRn0NtHqdzsxhTwFV4u6+bvq77v3AG1Zv5Tgpyk6ZuJ6WPKWMjwsR+hqV7DeqAXw7shqTT2keP4uAWdxofOZsdbibpa4uHmrcDBjQ5ImoYQOtatgzocPf7SbLaDafLeRzgTAkoMyaYXfhJSVwr0oWFrnh0D3roTMPEe6iuC1wtHfBjLzb82C1rGOcqRrGIYCfrEznUAlcFt6dR2zx94j9pc1LsYNkZB/RxA1xbp8hVKZ5Sgmw== 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=2zKgX8iVwdqeQnqD84zbln0DK5aLv2Bsa8x25J6fqyo=; b=e6/NIjP611c+QT22uFNgA35Ppgtr8lSX0bSH8KlbILOofau6q2gOP5fBIzv/0dD5Js282XyTt93U5BBUc0HU0etPVA5cnbregF7VUdAMkbb7e6lf3b56yTlXypZy583DSxhzMTTcpl2AXF+cXZ6E1tqUVnn+vf8YmLKFaMyNCDmqw7aVM7vbKYzOU0A3URRCnHzYBmRRaBcoEjn9RbvtvxQdJPj+pvQ2wA2nIAEaLmij2tzOi6ABSK2WOEsZVQsXD7RGrhLmteudgBLPrRmIyFhHGvoVQNSHo1y8qvtFQP9WLPy1Tw7q5rAkuxhL0ZqRitU0DumKpWNq4KwLSwXb5Q== 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 VI1PR03MB9900.eurprd03.prod.outlook.com (2603:10a6:800:1c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:05:48 +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.5944.019; Tue, 3 Jan 2023 22:05:48 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: "David S . Miller" , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Tim Harvey , Vladimir Oltean , Sean Anderson Subject: [PATCH net-next v5 3/4] net: mdio: Update speed register bits Date: Tue, 3 Jan 2023 17:05:10 -0500 Message-Id: <20230103220511.3378316-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20230103220511.3378316-1-sean.anderson@seco.com> References: <20230103220511.3378316-1-sean.anderson@seco.com> X-ClientProxiedBy: SJ0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:a03:39c::7) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|VI1PR03MB9900:EE_ X-MS-Office365-Filtering-Correlation-Id: 861581e5-4a8f-4700-1ff5-08daedd6ab57 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c0qArlKtDjXRE48RWKcHNM+DdiWWi8xplS6Ud8mfBJfGylKDSpCUSN38ADilBYnmz5bZf8BDFC/vm5MSTsdOHg1vthOHVv2ZXdegniftWY5rBUq69sHO9mxmv6rdU50EH2i5ACsEBZhNQCi0UIn8NQbK/DLBjYqiVHLTJvTrhwV/FTsuHhfCkn6YV8wUmfwRU7jwbaITQCfhDrlHGxQeW+ozQgVUJdJvYQsxFtBy/Kv42fCUWOvJGRZfbqQmB6G/I3OF0qJc/DEBXpmQSpUKrSyGqQBUZ9ZgqpWuc3pUe85UnrzkMwNP0V5nhGE6tFBQE91+IXLrjlocQ7F/cz8ovbZjM21Wry7eSanyyXNgkBhRGGqlhsMaenrgRxDa2CYo8Eg9rStFa/DLf3lXh0vC/tgNcBaWSIXVSYVQFa3dZxRkE8cFs0nFLq6tFB9umCryvB4Cd7kKdE7upLLSwNqYBmm7JnP4fEI3u45hiu1MSQ45BviGlpozkCIZoJLScAJpc9c8wxGIMSRZgD7W+zdeQHL7deHOgjQ3Aw+SVXxze17rfu3YwQMGed6F15QTClxDTpJxuS0MRWyU+2A2h/FNfrtcMPKBmXsPwl2gFRntA25fssdqkHLfF1lPY4XhXCyJjEq2pAbaLttRXpjyFl34e2PGMxiDk+5TlCF4/cmtMs01n9ecNjr4aJoB1rRU/nniPv7RZIbE+UQJgCwzjqsF/wQy/38tAJuIWXqvtyaOXIM= 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)(376002)(366004)(39840400004)(396003)(346002)(451199015)(110136005)(54906003)(26005)(186003)(52116002)(107886003)(6666004)(1076003)(2616005)(66476007)(6486002)(66556008)(66946007)(6512007)(478600001)(4326008)(83380400001)(8936002)(8676002)(5660300002)(7416002)(41300700001)(44832011)(2906002)(316002)(15650500001)(38100700002)(38350700002)(86362001)(6506007)(36756003)(22166009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ES14v2kWbLK8ud1aD2UJU3oA9nD/t11PAIfKaC6+IF0MG2NX6XXsbyR+9XvIaFd6jreVGlFny1wrtlui49cH1cRFa/tns9xNaJ09CFjXpr2IjzvSVxTCnTBvo0ElTjeKo8l3VNCAGkfxpuNQU0fmN7/ts2IXC0umqWTPt6GNF3LjtFQulAFtbDyerCSn61yC84fUKY3yha4N2GI3YaLdEjA5NaRfse934IrNx1ee3qCeIZsCRZuoBPq8HAWNI0+9/fYvWl0lSTvQN6YO3e8qo92rPtFvspa/CtWAislIiGDVJEUTmOg/lKFq2Z0hwsajfJY6eHUcUGUmvrlLLGKdjYveDY/oUJTg2q8S5P80XjW2jpBgCwgEwN+i4PfnLJTleRjoHRYEtjvRyxTWtQUWe4dKunbhEunbITJYuq+z9IHD+cPKWhTahBJwyAJYbQ0kK8jl6YTfEJ2tRwS9liw6wCAifBz3uvLd4N3xaDIQ+GRd+LMrD9AvQV6l1X2s/v1lpAkWhAr234BtDp4OT50RpPOeK46CF/yxAWsgeHQ81mFQZ41s5eCt7cDpfCfjt5WOJWOiCxpkXDO9FvzUoEGgG1l5yUlZRQD1gbus2XH6DCBn/6ET3WZ6zh+lRqkMQjUKvDSv7TwrvMPZADmQkp6wTyr5vXRhUNK25aPyauHuUc1kSOiuzvS/CBMXQVpQDajCy81HqaZyFelO04diKy+Y2EeJrbux16L71lJg/F77AlNVjbjyBGFjPxA7hcmYEvKfYMLyCxwNAHJ5q+1c1pdtetXtp4MvZkg92pvr4Atj2+otTNwLkf88o3SN5dAvgMGjdIiGU3q0YlizQ/h5sawRXsvybO3wx1UmA8gc9WJuKOikyPtWi7qSfdDKwwwWNIgdKvarcHznct7Fr73jXyn73FOYD/7sbWErNGj8nM8QR2UGQGLRoFFkR8Ap9ZlO8Sxp/Muc0L/JeOjJAD8FVLzTzDClsxLT9kuIwu6ZTQ7Do6c2oV1q+qfyoJGKA0C272Uis//T/LzHcLCmNV6PkkFO40LUDZvIRXX4aCIorkqonQSMbQlbHlNjKLi7dbV+3I+rlF0gdf1wC3su7ozwccrFZHYYxD5Sbqo/tkTILbCtqq/TixQiSiI1+oVCdckU9lMOYfr/rYlUAGnQqTS0pdRSsJ0GPiFeDS3jeUtby8JLSmoCkE6EfDKZXQnCc8HUTc6eJ94pmb+eSxUN1xJay+c/g3L6JqakdRks81uV6NZgfRYaHayau8HfoIzBbUHGPBM7c5FRe/44BjnPLI6CH1/sbgTV1lB2fWAaR9qgsOAMTQNje/nQMq1wOjpVSue4ePtKgocsRmcz5Ge1r25ESBTgHGR3tjtH/m+DbiqIiCdryKz8FW/OI/tiLXpYg8hShttbbecZZoY2r5YOfCd2uJ9eWC6ut4gJIthpRCe1FkKLZUPdDB4kJBPEE2zSrXalzdnt4L8Nj5dlwhBiRUGxRH4+jwahNev0ubnklyy8S8kz0I/AlIKUr1YzpVZJUqVGy1lTwm4ZaVApCxFV8UoXz6y87OCR/twO6NAm9dNPwWbw8jKFf2UTov5YNTw6wGnY1J7gvyJvBHxutEvO0Hmqy+6HaQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 861581e5-4a8f-4700-1ff5-08daedd6ab57 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:05:48.0838 (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: q+oq4lgIjNfk/hejg1Dq3oHDwXABETIj+U3a8fAYmWnUQk30I3sXDnPITK2HQzwWt7+F8K08IXHUQNN39LF+5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB9900 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. Signed-off-by: Sean Anderson --- Changes in v5: - Add missing PMA/PMD speed bits Changes in v3: - New include/uapi/linux/mdio.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 14b779a8577b..67a005ff8a76 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -147,16 +147,32 @@ #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 /* 10G/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 Tue Jan 3 22:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13088057 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 490D4C3DA7D for ; Tue, 3 Jan 2023 22:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238485AbjACWG3 (ORCPT ); Tue, 3 Jan 2023 17:06:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238476AbjACWGW (ORCPT ); Tue, 3 Jan 2023 17:06:22 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA1E2EE3D; Tue, 3 Jan 2023 14:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V8DmdA0jk5gCJsK3PNAN6hhCwNzEYFb5tG2PooDcgOsYI17KKemUqYaonWj0akNIbUUry8haq4qmrJj5rCAGNE/qNvEm3y+xRyKCFSgv+zSHSzDyerYEFAvPb3C1GrvFvKjZg97I3MWdhlHRjHDDcCHFVEcsFOb5HobXh2HPAmCbGglAQlOil79B1rEPgwHUly5+vx2NK/9J8H+S5qxbEfI9j/zBYWfpd+FvaTAtBdkTJ5wJ1YIklaYI+mfO4AKotT7XxZ4MOSBDbx7OFva0VfUwe8dmS+APDwa9pctKYqeDLr4bEpUJvBMdCKb3DRBxRej3eqLnqBwgjQzCp2q58w== 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=FixiQeZX2s4eSs/V+hSzO+cxbXlZ70ZmQ7Ft0qtjywU=; b=Dlf9m4v5YVLZPzFhLBQF94v+dCbeWdOWCnlp+TPG5s1Dt4+elJ7PsBkRNBXR54e6eSDQX2/i9s7JDHaVEmY0rMR1LgdjicGNiNsy2EZQyUKb8AVDMiu2JYMcyPUYDt5LCwCSbZb6Jce+IZi9l4Ee8QX3+P5Y2tObjKNlsBrubD8uFiLFKJAa7BgAX9OQsCKFWLAfz7J/jgbJqJMDqUUxLO36GNBegYLmJVklLorhwpRjp80Kxhovmp7Vml0GCsahwiYYvY9V6SJntV33Xxx0kJuGVpb/huXCpj9kolA1AtqhrXOv4WMNvV0QWLZDVtHS+LM8ibG3/TjYD82MYF4/hg== 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=FixiQeZX2s4eSs/V+hSzO+cxbXlZ70ZmQ7Ft0qtjywU=; b=ueUA6LQkgRNmhc0cQCPCu0C+HEhGzrHo1ukIxZKNsfufWlckwSbX9Oi5elZlA1sMhm3WpoJ0POa5x3Sz/yhxICS/13QFXD189ZZql0WKJUX5jJ5v8XA+XYaqzfjKt3Xwe+xOE85QfJvuBRvrc57S6bHqFu+95csnRWD8yBLygNiq1ezrwC0MsAGhs3jN98UBKrmXCyL/vN6+Q3p1/6ve/cGuy3R/8/0ECufTA1ITM/YHZKvEghmqvE6gueqi9lCA4WrV1iyTtfP8b1+fO2Yusd+80lesGZFta0hBf5t7MlT3hRlacHUhzT5fZjMqCD81/+MosDjf+t+zCGU/CXRjjw== 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 VI1PR03MB9900.eurprd03.prod.outlook.com (2603:10a6:800:1c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Tue, 3 Jan 2023 22:05:51 +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.5944.019; Tue, 3 Jan 2023 22:05:51 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: "David S . Miller" , Paolo Abeni , linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Tim Harvey , Vladimir Oltean , Sean Anderson Subject: [PATCH net-next v5 4/4] phy: aquantia: Determine rate adaptation support from registers Date: Tue, 3 Jan 2023 17:05:11 -0500 Message-Id: <20230103220511.3378316-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20230103220511.3378316-1-sean.anderson@seco.com> References: <20230103220511.3378316-1-sean.anderson@seco.com> X-ClientProxiedBy: SJ0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:a03:39c::7) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|VI1PR03MB9900:EE_ X-MS-Office365-Filtering-Correlation-Id: 3aafd07d-0f39-44e8-3fa8-08daedd6ad61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U4s5GdQuOwYkBUIwirw2cbRKM0bNw4ODAoUIDTqeyITsO07Ysb031ZHv7jwBeRj0XBijx2WTloWnManYh1/jH/3WbKwOHXiM6yqGe21CSyRuiiq/O6px7m08TfqfYdDQJofpaS+TAyucCWo6rvY2gIZEqlFsqjfywqXsR96XFJuSZYfGGeBbaydWctu3VLxIDJJOk9gmxCyIw/aFwq/S+P0+QEUHq0+JBPb+dBbMMmAdIgZ5KViUkPVXbPJAG2eFhFtuPpyC/fAkfcP79Ek9KVlIKwiXp3CxoQ1JNDeQ3x/0WVIae89zByViXWe8JhNOyl5uL0ArJi1Hk2kdpypIm6ehBKXxHhn109JSaNG1jxsrA2Ldxw0vpuUxxL3/SuP8bGhuIkF+/4CoVoLpxsltOt4PFUuSSYHJYxslDWRmhELUAbtgRjFaD8yGch+hAmtsdiKgq7DWOnfV2Z0ORGPcDjmR5Jfq+IFFV0ZkJ6ZDAkxRZYo9ibrq4XSZS9Uvu+pxYkdeBcuvxSjsDCTeMJDG5WnTDgQyEM7D/vmsM6qG3mdQaLCGvD+qPsrTSAQyDt76r8c/rC31yaM3hnHeKh1KrBaePyamSmxqyloTVYVpFxLLLXAFly4eElh4wbqOvFuBMa9Xw82sbd0TV6GdBkoFdS7PvITQ578Rq/PwlUGdjpIk6a+4CAzCC1j5FO17X0PDgTyO4xc/gbT51AgRYKK4o8TmqpzV2iaCW1bYjCyOuCw= 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)(376002)(366004)(39840400004)(396003)(346002)(451199015)(110136005)(54906003)(26005)(186003)(52116002)(107886003)(6666004)(1076003)(2616005)(66476007)(6486002)(66556008)(66946007)(6512007)(478600001)(4326008)(83380400001)(8936002)(8676002)(5660300002)(7416002)(41300700001)(44832011)(2906002)(316002)(38100700002)(38350700002)(86362001)(6506007)(36756003)(22166009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: krNJFP4NigfE4tSJSfT1WWUJjklw6t6VC4lh1iALDUZM1K3zB6T2yd6T/JjIzEFTnlMnAbtrhzTinY7toW5rw+fHoDpG3TYrLcewYfHO4rIKkYeUBsbQgvxh3l0dWKsgBoesi1Y+PeFXOpawhgycrPRzFsU4mGSAJ5m1E141ixKUvE0qQUStLSHW4ElofBrY2eSdDP+xP9Fdlv39l7wwtChiLycpdib/QH9lq5Dt5Iq2cvrR31kOWOu+J8euDNJSFe/22A3WbzaUJEl4t9UfOMndXL9O+uIJXqATyB978UuK7T331kUTNCskRjQQHB6obNcOX5ttZUsvOrlWKF3MPVNFowmtyhr3xIqUhe/pSeFpaFYJd3FPLg3yoQ80GVP29GBpM6DDVHJRbVIU2KmSrfAcg3SNYjJDHT5sA2c9wC9TbXww5/Y3l5/OW0g0S8/sC7n5Fq0Dn2kkEmiYm7nETtNJWrBPXf94iUlacFtxXDdb5AsxnHEmjdp+47S0MlPvlFhwgSxGpdW0RLPHzSrRkTQwPs1WhlFGNOl0DDZT31fSu0oMaWYtFNp1+gyvSsOMD785Y77019MSBH+qhuOajbFMsTNJP+sj5abb/9v08dO6O6Ms0P8iLqwvFzUfr5YwCBQyLl0pOnwMR+YEaQlkAKNNSgXVI3Zyw4DgQaQo4/RLYSz9yCzIooKj7hTR09d52IDLEZuLNX94YS89/T0uI6PJM5lmUY0RDfAQEz1+RSnYNLx24mfbhgVAk2Ue4zzhJ7kf+l26GFIdgH4UbFy9iTE1byJyiT0RCtraF/yHjLTMHIT0IC4uPVajKKxVgAwdai4YlVrVxYcwFcH3EdHnSyFzS1ETo7YOgkNa2/1Jcs7mMIG3eJFJScOM/OPpgFUf10E6gQ6yyDllWqRRYNYyftjgHVc7VHSBUWvG5ED6avgFT1eMETYOdECsPIhrY76zwcWzN8V7ajLFa9NH6leLXAT7TeDYqXS6FcnuzBEF2SvI593iRD/zf114cyzuuOcOp4xePqmmQX1lEaNW+IL2Ko2IiTkIM/SVAf0mxnHwoxejZBHLQT2rum/qo83cUFWqc5Kdit7FKMEwfr+Q5yoSY5htlZBqwPxzU0yhHCdHvefV7+RWy/2GyXrQhstOq9OBZ8cnkdcDIPIBYBpDpo85FJ5nLIVQJAD8T/PLXwjjLvcFZlTaoOsUgS5w38ubZyirh8sVWy1+0le70GZiBAZmi73C8OtDe0AJXUoUBucmd3eUaAdgUDQ9uJPtmrzcYRZPoow4XimUDdyloNECxz3QvE4wTEpHYRBJjK2JCj+eBw94f7yv8KWDmyuQGEb1j2DBAT6IET8RtDNfhzw9yD6NX4d+zBM3V7RzdBZy4qFSbrGimPVOoAsUz2fHBkb/UgyorNeXWWMwiyy1QfQY2bvs2pE9oDUxfx4iZgY6ZkMW3YySFfoPHyekXybJYX2tfn+m20utgrCmpy1Yofshz+VabLVYAmZ0ILN1we9dejHNF9eUOm/s752vb6iMaqlCtI9KCR/+WO8PSRxkUmU7+crFglb4yt6RW6yW+GN6zOkpvzdfXuqkfVTsalntj6HBKPWyjd1t17oiucOOWmVrU4XLDA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aafd07d-0f39-44e8-3fa8-08daedd6ad61 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2023 22:05:51.5211 (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: e0TDNglbytGbmspDeJzX8n6kSr6allzP0tWsjna8MCxI/M2BMx3NkkjQyRDQwzYNeYoLOevH/R6m/bsr4QEzOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB9900 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. 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 v5: - Don't handle PHY_INTERFACE_MODE_NA, and simplify logic Changes in v4: - Fix kerneldoc using - instead of : for parameters 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 | 136 ++++++++++++++++++++++++++++++-- 1 file changed, 128 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 334a6904ca5a..06078cd2d5b3 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,14 +684,119 @@ 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() - Validate rate adaptation for a 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 or if + * @link_cfg.speed will not be advertised, %false otherwise. + */ +static bool aqr107_rate_adapt_ok(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; + } +} + 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) - return RATE_MATCH_PAUSE; - return RATE_MATCH_NONE; + 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 speed = phy_interface_max_speed(iface); + bool got_one = false; + int i; + + for (i = 0; i < ARRAY_SIZE(speed_table) && + speed_table[i].speed <= speed; i++) { + if (!aqr107_rate_adapt_ok(phydev, speed, &speed_table[i])) + return RATE_MATCH_NONE; + got_one = true; + } + + /* Must match at least one speed */ + return got_one ? RATE_MATCH_PAUSE : RATE_MATCH_NONE; } static int aqr107_suspend(struct phy_device *phydev) @@ -713,10 +825,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); }