From patchwork Fri Dec 16 16:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13075228 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 BB6F5C4167B for ; Fri, 16 Dec 2022 16:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbiLPQtJ (ORCPT ); Fri, 16 Dec 2022 11:49:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbiLPQtG (ORCPT ); Fri, 16 Dec 2022 11:49:06 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F241C905; Fri, 16 Dec 2022 08:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKs/pzG0dnIhTg0qgdjj5fAgKxJW3tjZs2rgIYHjVvX9Mm2OPtYMSq+oCOT5/50YrTWs+CRryuqxMt4gHa+4rpb42GDtD+iHbVQteJAnQyWny98vh73Dk1O0/4GciGDttQo041IJsyjcEGJ75JVI2HamCaY94g3uJfbAsn+F949eAS3iXtco42Np2W6wrSA01Rjkiso93GygbtWygUkcsGy0ksC8Fkm2tbQsA6wz7xhR23CN460f+UoSAmjxFXJmGI1OF5aAEVU7PQnWbejrejM7s72cAjiVdiyTWysKEmgViBb7D+0UpN+t1AQScPLB92S2abWeK63E78jKypLMkQ== 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=dnexn5JvscFZRuIlk6J8YEX5bBHqezU1IdzVHe81a+iAVHtZdXqsJKFrHDpqGhBln2p3Xn63MLFpIwSLg6YtRbjjnnVQXefod/xkihqhew7C4c6nSncYdPVWAXjgCQlfguWD14L5QM3Kl/WgO3GLQw1lk3n/bxRLIMtttIuKhg5egawvCGEYKUMZjs85Mvz2Zjx/J+3iYkaPqTy1mQKwANbandfzYvt7dWpIyGX3PDOYaomKvmkHDZLwWp4oj2Ag2lBl3qKWZvQN1T+d5sWgL8Sc0JWw0h70zr81hP2RYHv9lzYx6ow2yqeO6o8NfLJNU8JZQOcVtcH/k508NfIbOg== 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=iAKBtAH228UACucqS52M6oxVw5ViGUOhQRW7g1sNoiZNVbQ8kYUGoET7eNcyDajPHb3uoFs4pm7JYQAfjuKzihRnhw9X2GCdwJtM8bpJINREaKfZwtljZ01rv59BMRNyp6bCIMuXcQdppFoTZ7XhqFCAr/R6QpQMAc/G/Y/jG0mx4TO/7XEAL5w1M4aHqkNxxlOJhNo0MQDWLu+L326Ez/8HgH7d4IW6gUWqxLAgBOJYj/i3cQvzPzd7BPJfhl/hgZWDQ8I6k4FYFnIDCBO8Lc4h3d5YR9B+UxG7POtBO/Mb1p/cvvyL5KmGqwItN9H7fr4ew/6f3fhfKmy6JMeusA== 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 AM9PR03MB8010.eurprd03.prod.outlook.com (2603:10a6:20b:43d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Fri, 16 Dec 2022 16:49:02 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%6]) with mapi id 15.20.5880.019; Fri, 16 Dec 2022 16:49:02 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Jakub Kicinski , Tim Harvey , "David S . Miller" , Eric Dumazet , Sean Anderson , Russell King Subject: [PATCH net-next v4 1/4] net: phy: Move/rename phylink_interface_max_speed Date: Fri, 16 Dec 2022 11:48:48 -0500 Message-Id: <20221216164851.2932043-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221216164851.2932043-1-sean.anderson@seco.com> References: <20221216164851.2932043-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0150.namprd13.prod.outlook.com (2603:10b6:208:2bb::35) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|AM9PR03MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: c3f727c6-1d34-43d4-cb8b-08dadf856fe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h1aTPwgkKSBGy9ivc88Fq0bcPe6oiCZDbD8s77hHMiY5KWxokTJE11TZrSBbffroWBhT0Y4BLyvQsPl59mS4jMRdTWvYR/xw90LIZ9Cuu/FqAXp6pC7jS1f8TOM/KpMiV5UVJiKw9Jh1o1UHq+bkWnkI1tXSUrfM+K4nhvpSrf9+CcNJ7mjr88exhX3AvXx7DRULPo8H2NQJFEEMB/wHLvvf3NtxiJB/6QhMCPHqbzizC/hO5ovO+rU3oCQroxaYaq4fxKKbx7BgC8vC4UJX+9sUxf4VEqXS/z7ogX9NvwZSy0xNINIeo4OIKYC0Mcv0IzqZvXquVFLqLH62YSh0T10159M55Y6nxCoircdfnsqKSmXxMBkounpBZyG8Z6aGPl/RVusHG92tmWLmjFdZ7NOn137zKEZeSdF9sV5YRp0Gdnz//XTuePmFzASohkrsDrTZZVZ4HieqUCuuEvnDDmCnOjBfbir/kuNdWJsnP8BpeN9/egqYkEaIrnzLkoVfUcnSkoC+I5R0qp64m0SVSss+lsR9j5iU/JT0M/aOPAl1EBKuMWXxq9kqp4jn0SKfRJUHQVGGIgcZGiP1LqWmI5HnDsq3LFWdMfow6CVilg5XLrAwLlo/V+zol6PjSPSwkBYWIOOHRYBWJ0Q4LvKtyow+YPf8BTtPHgZDcjE0FEejyLx1duOWcaUeKP1upyl621YGRM0t1ZFNdKlIQfyTNg== 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)(396003)(366004)(346002)(376002)(39850400004)(451199015)(2616005)(1076003)(86362001)(83380400001)(36756003)(38350700002)(44832011)(38100700002)(316002)(41300700001)(2906002)(8936002)(66476007)(66556008)(66946007)(4326008)(5660300002)(8676002)(7416002)(186003)(52116002)(478600001)(26005)(6486002)(6512007)(54906003)(6506007)(6666004)(110136005);DIR:OUT;SFP:1101; X-MS-Exch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JdQgBKXnV0Ru4fJsfYcoRMuUrIbJ6oaSg9dlVKw/bkUSoBKfI7MA8geIkn4l1lAHHca1Mb9ZYMLQs7tHVkchoB3T31wkf3sGFT4/jOsmYC/qcrhkMemhJcxz5ni5SZoT+HTUeQxj7pMiXPruwAWnPKxGK5ZqGNZvqjZ+wbDmm9OGipKe+xTmzChMZ3KNmf0vyqtr4irg/ZOvsFOhxeE+GVjmeRE77gR05LU8DB/8yYDlqWbHPrUH288ziaHeBre8/b97YvVE3IFWaMuGC757AfoafbeAQb/ejf2KpGTnjqAkcF2jTcB56erCNdL+r+6VThj9Ab2U7LFEtb3arur/URG8yiDPAHsdKjHB9GfRMTffOdqOqV6VU+cFfddzhkVMU4a1cUgd3Xm0ftKKV6XsGSkLX0ytAcSbJj0Z0kdzoZL9OqPVD79axMgRWq8yThGvax0apkMpkzF6AJIjga5grOSJ6X09AHKm5l4waEtO4YQU/v5OEwolbzBGsigvodSyguK1OTJ8RqeH2EtcAA1DljUkOy30tNlnVjq4sZZik0HYmmCPJWAgM9Dy6cukVor243GpTYv/20KX0xf8w== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3f727c6-1d34-43d4-cb8b-08dadf856fe1 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2022 16:49:02.8309 (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: xqJjQ3u75HHtJkf6R7w4Dg7OJPQm8sEPcInSFYhe7fQpOovXv1nC/N3Q5npUL0BqUh+Lk42xsBYLJvjkw8yddw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB8010 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 16 16:48:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13075229 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 B0443C4332F for ; Fri, 16 Dec 2022 16:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbiLPQtU (ORCPT ); Fri, 16 Dec 2022 11:49:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbiLPQtI (ORCPT ); Fri, 16 Dec 2022 11:49:08 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B48B41C41C; Fri, 16 Dec 2022 08:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E6xhqrp7N7KlDLW+rL+rVC7LYwer+F2AINnSavmSTl7hDb8SNdMxMUUGIc6m1OTUQtYJnzixRiLp1z8vr0zzTPA2nKWu1tKAzcTLC7vDYT/IjhGqaWg4/y0UCp7gWY1noZSReWED1tGZSygyHBi8nLvFjcXEQSPL2I3Y2N3hXOyCkLhBkA4cWSLvx2GV067Xi9JiklOk6u94BHSgXLdOe3mifbSYsNnnwzgb5CmMRY+geV6F2CVYzcdeF+8VHTpeyrFo6OvD4PD6YGxh6nE1iImszoemraHYmFEoUmfRpzDOj14JoBgm1a/7VoHZuAZdrWllofA1ruEX/WWTHzuaIA== 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=gDgtRCIfD7OobxyMw5s/jnPaDVjohEEFfM+/mb0BVcg=; b=gF9KVjkNda9aseQylyTvlEYy2zfEaqrPmKgNPGywL0SPWeytHZSjGY/7YODnkmHgtBUN1e6q5ESjR8um33hJYmq8d/zR2jKg4zHJszEnQ93yiyKsT/J/pDMW/pti3yL2ddG0fVwUyO1I8pm4jZnuZkBaJ5HkJq1xJDYWuFDeXpg4mdLAk6fe+V5cFqArDs6qtHtMYFUH5CE5fCJJprAwb5m/jwjjClFLyto89fn+RA5r5qrM0YULJ2+OCqXkTJDf/EoHZCk/L0qa49uIHYCUQ+RLcwat462lb99ibSbjpH7Ew923rjC+C4vBlqslB8JiAvGNb/pSEz8Hu7tDVdcIMQ== 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=gDgtRCIfD7OobxyMw5s/jnPaDVjohEEFfM+/mb0BVcg=; b=DD5jvZEjs8u/Snf/pvvlzLljwJJWSuM34GtixIP7SH1KCw/+2cT4tvUYueaxm4eD5ZuudKhvUcV/Fzy05d65oyWA3kCL7wrnz222lS738GKuk9lhmNku9mvvDFjILA2YXhg5wnMoGVK5Kxz/gcyn7vTk6KJ8Fs6DInNtZdJLtjON2ffA9T+uAoHYgrHQPwU8G1EJA9d6rb597CMJpTDN5Igh/Q7KBNWNpcoE3MI6xqNIj0ZJ4X5VAiBW0gtQcGJi1LWwHSxpN04PjGu+Kf2oXVQN9AAuN9zRO8+DGaGWSp5KWXRMrlt7qPIdG2lzItrmXu0359vSomGoDMLglF4pZQ== 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 AM9PR03MB8010.eurprd03.prod.outlook.com (2603:10a6:20b:43d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Fri, 16 Dec 2022 16:49:04 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%6]) with mapi id 15.20.5880.019; Fri, 16 Dec 2022 16:49:04 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Jakub Kicinski , Tim Harvey , "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v4 2/4] phy: mdio: Reorganize defines Date: Fri, 16 Dec 2022 11:48:49 -0500 Message-Id: <20221216164851.2932043-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221216164851.2932043-1-sean.anderson@seco.com> References: <20221216164851.2932043-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0150.namprd13.prod.outlook.com (2603:10b6:208:2bb::35) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|AM9PR03MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: e9545b9c-c683-4a62-38cb-08dadf8570c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkMO18oCQrdFYoyp1KRwM8j/S86NDC1w5efqSY0d4FGlvtkLfyc4H1skuL/fJrjaz4+XIydBQJlM2m3xukffvhLSe3gwh3OuCNQw8aBtwKi00j7+vZ17XW+Vqo80/Q6t60mK3T//GQXBhgW1AiF1EMvVZbfuxsdAAATQmOOwNSgX70/SV1+YwkCeRiJ6UaYIXNg12WZ4VcGHLPdEt2wK09RBLUtzMVGRAMLuKBBMyoROIe7WEdG+tXMSG72qT3UX30UyUwJIG39lOt46SPfWtwOmVH8DFjcf506fcvyT+pglTdWTaOjzjmtYoxuzNREF0ve77wJXWJYRZo/byw5FyXdVBCwfvmU0yfpB92ZwViPkALDkvFRXYU/VkwI8re5yPnNMfaDsLQbMx/LQU66N/TQ1BGy+I2SVNQHEkDLeJcTEBtqMXuTYaR9tAnGhQvdgZPFGzq8JYSPc0Mi9G8ry39Y2lM+4GZQVZv8GPC6Zjkk5gY8724ztzsmXmIhO7SZ70knrxVzkkk9fjoIdqhnt/g2EYrwJnRvKlKDsZ5cJvfzrlzqVkSfjqo1sAyLp84Qs2US/R1ysi6DupAxd3WJ69CpwA75rAxzRMiHjh05gC7uDUWUWWnvbag3Boi/lseHhPMXOK/uBnHfn7eYwZOXjRG2AcpgRL20haM2woA8WwYmW+6kytSd8YAGWghpKyNqSg2GJOMMdmVHlY83T3f91NQ== 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)(396003)(366004)(346002)(376002)(39850400004)(451199015)(2616005)(1076003)(86362001)(83380400001)(36756003)(38350700002)(44832011)(30864003)(38100700002)(316002)(41300700001)(2906002)(8936002)(66476007)(66556008)(66946007)(4326008)(5660300002)(8676002)(7416002)(186003)(52116002)(478600001)(107886003)(26005)(6486002)(6512007)(54906003)(6506007)(6666004)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jOp533UCv3Fyhqx4VExTnaGtvIM2AJAMwSbSH7UGN4xYKhMf76P2FUwxuEpng0r2yaPP0djQdOdNcOjAdjGYJGxxT08+DjWVfM37Tq/Mw9G6t4hRWLnJMFD6PRbByoj+EzHOVakhOwC7U9uKraMt3E4cWjJw9pdVeDad3oXt3y2p0rh+ZM4td6veDQVAb+EAhmVex53uVJhG74UwQ3hpRgNkDfeeQlGI5Ausd+8cjvGlSaz9oMqjJs+wJuq8JbbBXVuzN7rKpOteodJECYdcx/CfovCXBJJp14v8DEd7NQsUAHSlfGJ6yfN8oi0nwQU0qPlsDIARxVupnDdjJer6B5DVf8n2tR+KtLZQWvICEgx9puXBbc3leJZFXcl4PcSY/ATZ28J71VBf4bLhLNQS9AjZaEHoT9Bl05h6RK6Ezwp1CLAjOjtl5hWwbjd+ZHZi97w7ygMZnL1rNdMl0w6oWgNHaBFNoq+jB1KtfK11TAUGayJJevhKd52Ee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pzpZMqZQJD2o1IRtkFmg+ALuxeOgsdg+3+/4IZUjrcvoixUZHoA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9545b9c-c683-4a62-38cb-08dadf8570c9 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2022 16:49:04.3475 (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: nPT7xeP6dIlo3t+0Jw7NnXp4pMTGw16S61d9SM9NCGa8kIaZhzbskCwjrLX1071hWeqgYmAGQM8b8xP3c8WFtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB8010 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 --- 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 Fri Dec 16 16:48:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13075230 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 1E333C001B2 for ; Fri, 16 Dec 2022 16:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbiLPQtW (ORCPT ); Fri, 16 Dec 2022 11:49:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiLPQtI (ORCPT ); Fri, 16 Dec 2022 11:49:08 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2732E687; Fri, 16 Dec 2022 08:49:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O0XZgJ6fAx8F3RvD10QncW+jH9aRE6UpSAf9z09Tk7P+v8q7Z+FbujVwj2c8SDi/ao39xVMu7DWRxcYLQBsCwCFh+5cskNxXD6vhjQWr1e9IrzrInQ/rDrMIlXSmH63MKuXdqpD2YyFI9kYf29wiE34v3mFAAp2/KS6wOilgaH0Xsh2uGWBhaYEkIHiYS58BzSiF+SYf2F/hjMd/AOgSYMNVaqbMAOyI+vTtGFQbxGMPG+4EIQdWNfLeeKm0kZRNrnAELTj1qrNG5/EWCvEHk3gQGmkUOW1GBj7Frz10CxBtxkN9AGNjXEVL3ch4KznJox7Vt4bf0vIxWqciX5nABw== 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=z8tcwfqxgeHFKjb7K07Cbtw70yEW6LmRa05eLq/in08=; b=exbshPg1QHDZ7nwgBX9kzh7fct3ttmerUbfLR4WJbOP8VnzWG9dks5M57rqpRaBUV0fDZdAuAwGpV76t8nVrGrPhpd+dIS3sCaZcBmOqfZq1cmoaLXC6QBrmcg+uoK5P2GN+WrEDOITVKe9gznf5TFurtg4tAGGWy95DLOFIun1kogDvMYc2JPxw6VB+QAuw4yVWSAKwYWOZWUqcvGJ8eKd3TCj4xsq1Xq6R1SBn734jSBEnmOPn2EBv/0F1g2JjRj5Z063WnNDWbucl1zpWfMXWCOzMTScuNk4lRscPsd83oZPWLkTD2eNa8QamglEgfniO8kjD6jN7uWsOe+zRHA== 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=z8tcwfqxgeHFKjb7K07Cbtw70yEW6LmRa05eLq/in08=; b=JEjx30ZZD0jSzVO3lQqSPzdVRoZiHto4G0Ibd6dV1bHsi7SUA7905ohLDfnqOGzUC3llAXkgHBwzGqGLbA3ywH7J38C7/YiZxWnbJekEofVlkUNY4ldfsdWR3hbaeaWe1+Elu+Hd9mWLpqVddsx1/ckpQ6ZFv5Lw5JevEEL8XLkuuXikmdeID8wd0Jl08K3YB1oxooG0L/jmTzJMEItOQ5CP1Qn5CvjGMT9gqqVPR07LOUPx7n+0K5Kf1p82ReV7tiVNbrAusNLB4GxXvmkcitK0J2A7evGXO/YMOVSpO7WpDpDnB3DasRARrueIx+5mZh3Qv8Uz7sgkLBGj7f9/YA== 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 AM9PR03MB8010.eurprd03.prod.outlook.com (2603:10a6:20b:43d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Fri, 16 Dec 2022 16:49:06 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%6]) with mapi id 15.20.5880.019; Fri, 16 Dec 2022 16:49:05 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Jakub Kicinski , Tim Harvey , "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v4 3/4] net: mdio: Update speed register bits Date: Fri, 16 Dec 2022 11:48:50 -0500 Message-Id: <20221216164851.2932043-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221216164851.2932043-1-sean.anderson@seco.com> References: <20221216164851.2932043-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0150.namprd13.prod.outlook.com (2603:10b6:208:2bb::35) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|AM9PR03MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e9b1937-1d4e-4d0f-2f68-08dadf8571b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X9TGCbs8vnoidoyYnGPmtoMzqTjNN+CAQ0x/tMrz6U9C7YFUWcMXOEGuQEaKhGyHaRO1h9Kc8JkyWa0Hk2tHcFF86ENxVHm9FFTjfAqXhVoF563TUbZZoFoMLcK6onaQ6nIIhGFA1GKztjtDQT93GFSh05TSbT/4aqYYkSC0/UkdciLc7S5dEHTlmpnguh+TaPMYjrIxzPM7EpmC1HcUO5pJUU7vLw1itQrCrk3LRULr4Se45DxCuTAI3YA+ZJJQxSfF2CktvSf5mCDwIOYN7iNEvjVTdTNKvEvrkZPoQW0AK/rNK2oKqRSND4JmWeYyNFREwd+6VCIVGeU99TZNwRnkvhaC6328dPA03pRyrNiNuxJei0qgWn4+r8BkW4UmU3uKcdUNQQWrcs+iOrSsmCwJK16pHeDv5HIpfNxjibA3WjmfhTCZnW8mvwT4d4PJG895JvgyXXzI/nI/uft+aPk2fPjQfI7/jR6XYJlK6wtwt7JpMYBNOt4Aj9ODH8r/288APbU03gSQ8+m2WULTgOwxh+A2Z7xyuceyFt0Zd3yG9OZy1ww/AyTV8XMacOWGDe7eFYKUF+1rZRyiQ/5GBWsazfn7spoT5QtEfY3TIBgITRM8nfUXfcZwlPU3wlQlBieDb8/B+apZhQjNj+iBxIK3L0fo5n5g4F0buy4CoT9LpXjhUf0xEs326s/apqtYz+qRo8St2C8do6G2Ud/BJQ== 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)(396003)(366004)(346002)(376002)(39850400004)(451199015)(2616005)(1076003)(86362001)(83380400001)(36756003)(38350700002)(15650500001)(44832011)(38100700002)(316002)(41300700001)(2906002)(8936002)(66476007)(66556008)(66946007)(4326008)(5660300002)(8676002)(7416002)(186003)(52116002)(478600001)(107886003)(26005)(6486002)(6512007)(54906003)(6506007)(6666004)(110136005);DIR:OUT;SFP:1101;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GqgyPxDf6iMV8APLyvTyViNSPBm+eGhYH5LXRU5Q+tEz9B9zOWs3okvm9v3f8Ba0HedWZGLyD6Qu/gJrYH/FQbXzzij0sZsxO360tDmeCeu5S/+vT5Ed8av4zA6h82EsReSKo32i1B9x2Tr+osIwa8fxR5ZWC/shmYZiwEV6b7hVUFZdstWorc1IM3ipFHGEIL8HJuOV91f9jTYAVRO8TsYUijixetTTkjcynQ8b0TKWHa7KgNQbFBU15U8hZOdB//WFI2157ZpzMkMvzSwaivX2IVqCg6bh/mgWLhBgmill5QTmeos+zeefsHgTOSm5CRC1KnhTZOjeOQeCFafvWCAMNrA9ula6FO+ywfV7wRhz8Athto1XdzHx979exgYggw+/dqHfBtm48Dv2jMjNrFceGQ4YzIe2O2qEh7P4GK0pIp71QwS2+u6caPX+cyaCGIz167CBf7KcefKI+n3DVTr0JYKD6Yj6lhegIOqEbRW+49vo+tBfGppRs1P14phFHKC8eOmg8V+KH8mdEtl9e6k5LimkPs21hXeeuA/65O1UdHpeQ/bc1JADodpDrDsjFD8ql06PDb9G+LzN3suaQ0WK38bmAznmhtm0OvtIujw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e9b1937-1d4e-4d0f-2f68-08dadf8571b3 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2022 16:49:05.8636 (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: p3ao5dYlb4j1jMTKX+1wlOdAajyZL5jvh5udq/zP2JxYIn+eWGTRMqaJdw9GqN2bcaW10MwFGX5AH0TEMtlVhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB8010 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 --- (no changes since v3) Changes in v3: - New include/uapi/linux/mdio.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 14b779a8577b..490466f9a5c5 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -147,6 +147,7 @@ #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 */ @@ -154,9 +155,15 @@ #define MDIO_PMA_SPEED_10 0x0040 /* 10M 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 16 16:48:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13075231 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 0F773C001B2 for ; Fri, 16 Dec 2022 16:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbiLPQtd (ORCPT ); Fri, 16 Dec 2022 11:49:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbiLPQtL (ORCPT ); Fri, 16 Dec 2022 11:49:11 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2082.outbound.protection.outlook.com [40.107.7.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C1B2EF5F; Fri, 16 Dec 2022 08:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPnzNEl/TN+cpzQnodWFhH6LLOv/jD6zl26RXu/80Xn8Y5LhtF8wVrO4DfVC1xXm1y4MIEK1QpnUUY+fPIwBwXhQT4bVmfjoY9l4/TO5sOBV2JpB2Tx5HS99Huc3FRaI63s6H5C/NmpFcH9AjdpwYd/g81fTkRljmsQcQCGcZS5KIzko02SmbjqJZR1te1uYUwggb8Fw7uySpIacV7SyXzDJt4laEV0dkY4VQfqj84cQslCTSQGj00uqLzCr2+4Q5ARtQxAkrvw7iM3vNTrEZmt+Ve9Kn9ljvEkVF/owTYhYTSmuXYKb+ilcSPLvIYvR3pjy1gRwbFzvsOlS7QFpWQ== 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=gZ5+60YgTTFJLnItN5vGFfcUAmm1TcS4Ut+u2eL/CsI=; b=Niw6mKP14nX80odQiiv3MNrPsmBg+CPM55E0PEZ8IhRMzv2+eclmULPUf0qcXThzu7NZcKOB/ZGIkytmFA2IvcgwvwgDsCbladJpxS25rCZXA860cw0hxooYc70EpoWtQJBcnKhFSTVm2Si05Kuk4H1MMB9l+AsNCI7DLj1cgm5EG+d53k7mJhkOijYj8aZ12Qxw52pz4WrbaUuX7nNObOuJh9+v40xO17WKLWw36zAstVU0oRh4LWblcQ/9F3YVlne7+p2fYrhM49UoDfj5NIVBd84R+2lD8YwAmrj0UZcrVLCAgxp/fEy67LWQd1sB+3vTu+pELchMcVZAR/9yhQ== 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=gZ5+60YgTTFJLnItN5vGFfcUAmm1TcS4Ut+u2eL/CsI=; b=XOnlE/68tvDWqyioU2wJMir2pRpBoxRfp2+NgeCB4qtsnRhXHe2pD4FES8EboqyF/L9IM7X4pJ+uw0/5lQBXgup9PXSP2nmtzz7y5XXZQclk2zs3VoFWL6bxZZ10wPFGzgOPMHC0oslB/YxwlWdh+J/XiGMZpVhzHOYeYSjxm5WEKWLaKcGK08zZctaNyLVIhHV0nuWguKbV4Vte97jx/wIe+O+hX7niwpjVn/7mC9H2oLnmaszwUvvScENrkVGLKH1xrgTqLi7RcPJyFzxInhgxkiHITsJwZbbYM6yK0sp5PA4MwpItipAb2tEmgXHC/E5rsVcsh6YkSgsR7xSLRg== 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 AM9PR03MB8010.eurprd03.prod.outlook.com (2603:10a6:20b:43d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Fri, 16 Dec 2022 16:49:07 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%6]) with mapi id 15.20.5880.019; Fri, 16 Dec 2022 16:49:07 +0000 From: Sean Anderson To: Andrew Lunn , Heiner Kallweit , netdev@vger.kernel.org, Russell King Cc: Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Jakub Kicinski , Tim Harvey , "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v4 4/4] phy: aquantia: Determine rate adaptation support from registers Date: Fri, 16 Dec 2022 11:48:51 -0500 Message-Id: <20221216164851.2932043-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20221216164851.2932043-1-sean.anderson@seco.com> References: <20221216164851.2932043-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0150.namprd13.prod.outlook.com (2603:10b6:208:2bb::35) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|AM9PR03MB8010:EE_ X-MS-Office365-Filtering-Correlation-Id: b61168b7-905d-4538-bdee-08dadf85729c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eUJ11rGXli+5gJ0E8P7pU9T0TJ2zh+ybscoAu5ak9ET2DF64X9TyrMBCPjrCHeNuIqwTtr4QajVImgBnj8Pkj1LSMQha2m0bIBE5gHzuHgKCO5Oxp7iTntNXVx2Tx6NheXuut2uqQLoEKCpIFJLRJswgeXvY9qe9aOwqek7/i3LI+nXFhx1Po3htk6G5Ks2imStZwTQ88vuCfeZ7T04T16PUKSW+2Vqke26xXf6QFMJaPdA3Z/LpMMBDXmPuaaBR4J7ram7aWNS3Y97IkmGxVHXnnoeaP7l3vJaFyGr1H38NDhtRR1UywXyFtLfgPBJmStyynOHzV3Tw+gTr/XHYUdtI9ocNl9YI4feTvvwkV+W/fgEcHTOWurms/frdrsQaGu2qqTEgABH4ddZ/SrxvO26PAhP+eh45RYZGcu8wKeADu4FvqIw0Wwf/kNgEtd+T12bfFV/tvBqmG7p/5LbLDpKBuNeERwLWe7nbg3XTzWaVVa7dbIPo0aXo5DOPFVNeVHuAEMW018gDIRQVdcP9umcXql7VOIFcKT8SmwY4HzewKDDwaw571pb4KaqXDIkc+n1VjsegyRXHB4Mz2eyMsvb20SgLqeEoNOhOvJutnZREH81oAEyEqq9CNJLIQAPD4RO+4KgC1Ok1uDYG24jbTPEk8BkyaJjWbBdYbaWXn3IVaS7ixUrP0wozIBRzCFYq+oQRiNf6idDI0B3e+4UvgQ== 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)(396003)(366004)(346002)(376002)(39850400004)(451199015)(2616005)(1076003)(86362001)(83380400001)(36756003)(38350700002)(44832011)(38100700002)(316002)(41300700001)(2906002)(8936002)(66476007)(66556008)(66946007)(4326008)(5660300002)(8676002)(7416002)(186003)(52116002)(478600001)(107886003)(26005)(6486002)(6512007)(54906003)(6506007)(6666004)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5NYYKhjHKs+azNVznnb12M2DXzznY3CS9Z9oqjiByUAr+A7pD6TmjqkPBnPUI/wYhZMc2lu0prQePtA3p2jIiFIT7WVNa2luHXOTmfx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mVWEyP1EWsl7WCWUrzw+6hLWqA0CUOAMrATbunA1weOrmwMmGTT7UaAMW5kE+kR11i0kIMXnORWG1w2tcxNd+uVgsmBO9nubX+6JSHkVds7p7EZtSKyY3XnfCxbhoNeum/kFC46GtP+mBfuPkgY5EyOqJmw8KfYTrlXTZdcl39ywya4Z/LeJ0pjN5UZcgQ5+zX+aLoNKpdvlq1VPvLE/hY22yybL458h7FJQnWmrLqQbGSJn6yaDzc2oZGJ8YgTKMifhyZnboEOIgFalvKFkDxVHrv5AY8TN0lcRIzAwfO7Wa7mZyVG8mME53zv+175FGFXSebaMuBTjRsWgGQaxOVvoC6YktlfegOh+DHXW7tWpIkD5N7DAUsmJR1sdi+xEl4ZWEPxSgb3R1rAhAG3UYSLdRb6bueIbTC4BoSXyrk1FKT5O2Q== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: b61168b7-905d-4538-bdee-08dadf85729c X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2022 16:49:07.4739 (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: HQIK7Cu1ltHix0woKR7hgKJEKmAb4c9ERPbT4aEBT9FhH6v4QsPwTP8pmvK6EuoNRMNofAwpA3AaXc4/d6WdRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB8010 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 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 | 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..e942b99be823 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); }