From patchwork Thu Aug 18 16:46:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947447 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 39D6DC32772 for ; Thu, 18 Aug 2022 16:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345025AbiHRQqk (ORCPT ); Thu, 18 Aug 2022 12:46:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345011AbiHRQqe (ORCPT ); Thu, 18 Aug 2022 12:46:34 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7AABA9DE; Thu, 18 Aug 2022 09:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PjdEQ34tdwnG5onkP30aL2wLII+BTi0c/hI7pYYv+SWLQmbPo3KeMmz4faNR4Psxme+64S2mdSz0ODF4W6V1SpvbWYWNegDA7u0IOkFFlUmcwt1g+rrMiSa6P9bvag3thhn+OtiDJ8CR7VXh8bbyIA96nJht7cD2JiDzboeTEyweG7qYdx8vdx+YjsIsFLZDfgn/S0md6RPx82i8rWDWmnfZbZwPpn+BPsueSWbrGy8KkZqRgva1MuyRWXIrolbGuT5KiHRr6iXw10xJjjwC/2s3KwNdzClVyrnkisvzlJEHwAmr20TWaEDxolTQ/7kELKzEiEw5kRcNQteyQq0DeA== 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=zVN3RE4YPj3naLmLY7q0GTywVhKdcECxcsV/A7K37bA=; b=BTFK22EarPDhFmFtB+IhmOCtmIN0b2OhMysLLZh1tSRAjVRaYHyGyLbTWqgl06BUVB04P+23Hz4pN0xe5FRzR8LBESpKKDu/38QOMrnIWygvcv6rv8KhVRSrFjJOqqXAioVAMukY/CZMO2WkENeCI8DihAL61jMnT1aZYHYaBm+/GL9M/CVSyy/63v2pHL2RLrd+F6/LC9pSYQbRJdmcsfupzTbaUyIkKxK8RqJrojPd0K97oOaaFYixV6dn5ZdUwTebMhTftn5cpZ0q46jBVp9EKgY5lI/mGtC8gVf1f1O4GA+y3uYuvxkO0nSeHho8KUYM/nAAPVPP2t9VpnKMmA== 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=zVN3RE4YPj3naLmLY7q0GTywVhKdcECxcsV/A7K37bA=; b=Bn1JPU31xguUUJ1jNBRCLe6UwSxzg2FTuzTaOZg/3K35/5Q0pZpRB/o0YJ/ocTi3Zy2fKk9lg4YQr1B0GVk0ddmiEJP3tM2NqxZpz37aH0LfnLlXJmbtqIP1pTztyvHHaXoUa4/8J7g+DKsXFMmyL2YujdXKyDFtkuctMFrv0MT8LC48BjHaAdbiEMR2czM4Pko79nzpSNzszYAu6q+WAY9nDn3Q/dZ7QS44UccrwRtAHovG1i1vuQQyUHU7AuP/psmT5JVCEDoxLbGl7K/cY4wH3q680mGKAhP+09HC5hzFFQQs8KA/aDk3VMmp6sylCE3xzNediY2bgpSJaU/u8A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:28 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:28 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 01/10] net: phy: Add 1000BASE-KX interface mode Date: Thu, 18 Aug 2022 12:46:07 -0400 Message-Id: <20220818164616.2064242-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e660a573-aafd-4c40-e714-08da8139322b X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aGM+Q5bQWKOXa/A9EBTTkz1TdpLClNKIcrEYQgxDdxnEFarzVAsGec8yQCFE3cl6NWnBRL+EZ3V5MKVvw8yOXlBM9Ro7Md4LrkufZo7+SYnRNO1O28CrWD+oUUsX+3AIB1z750KTauHtmu8w6ytVbtigYws8gUblx4Y1UQx+FfFSWshOR2EBNFPnehx1qV9Zlgxyztp5artFe15KehZsb8uKfku2rVFxp9JPq+dt+LknwwkgvwYUB1Bb3p13Ive8Ef1uvvyT1y3MPGxWeQX5RLikUYy5X9QnSqoDoS4Knx5d53FaQYY2izyA7wqsvegTg2gPxb2R2Lp26qjPa80rrFdDL4juQ6gE8pyxOLEWnwSvEv3hLuhzEVvdtX6diIODdcixX5kasaC2XyY8VI+IGN0zO+GMWEb584VgI/RHWg3U3WdCcVo7yDxeXPQNJkehKZUXSGbT1ONZrANXOgIg+pLDf/wU3nHah/yfI6SHlWsp1avlNTXuSvaFe8E+1Mq7RKN9F4pp+ssarx0uoq3ummKCivHCaXF0LxT/acaUGYPyEGOj4aWQgXzFizMWGlMJ/YUVnv83LVt1+EmmauqkC2lpFZ7I3LwIyNWjhyNyEn1AIo6J83lMAEk7G+09nYDGg9RAEK3gwBiBqVbWoGSckVfozGaUoR85JhWyJ/4SIS7kUiQFxFaY0+NcMCW/QbWXLIYYgP5iscwmRFSdT2SpFrTUvn8gRnUqvfmQF+nilSEGqe5aSkWku+UMs4PPajXt5bEXlyaiF2oUawx/2rZCJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jwek7Gp9/Nah0bJmzNV2XRL23CTD+/vS2CCWmmBegimQtcn7he62al/02VGq7SqOUTyBOMLusNSuErzFh7jFzQPVtGP1a8UpzqsqNhyxFNV0HvygSt0WcIBsbAtCX1C9/1tSOeXtqJHYioh9fWsQQKWYt28f5b94B+2wroK8TaYsPm+qy6eHZj3nHIQmtBArA4e6DrjhpCTXSsNiAg1MpPeCHlJVuGup0KM5DklVrtY4mQz+nVb/SV9Mp9tF8RynqyMst3IZF6iVuyewrccYdjOhkiVlYBiN4c9GTyK8OOi06e5s8BjwFJFkKB2piOyVQCyxUwvFDurMiqX+FUl57zmp9amE5VKsWim83+QAZjE1YlNhJqBzkeu2PYsRwLTARVasEJOsnZ8W9YAQy/XqZVL0xBglioHHIZE8+yeOGcu5BfUKo8TeYy96Sf1+sVhXgw0+a0gxdsoaAGsxxk8xlgcrARzwixnFENFXV+Mh6AbBCbCIcyBHQEjuoSmxgQ6GYL4NyDHHwWQ0xO2SIRrnzJYYBhUpWC9bPXDPaeOsWotANimo6l7J2o9mFxTAodP/E0RmUrjJlcNaNzJ2+ljFhkyXG9jC+VKGw6myKawQMoH1TiQabCBaEoHaA6OT0MfyZttMH9fOWh8nJUIgkTDTQskb9Goslcwub0RvIpSPcejySLbt1m7jjWaXSZN0Av8viY+q8heDGVNtOrVmvgZ7r+WVU41hM1wDtrvaPaRAwRTatA0ui2UsZsb6L6rX+It1Rks4z/xB7hAvQxqmLUQlnuvNcyxpbkQKi9l298IeSKctf8jDk4kTkRDy8WG4upPUumz6uCGrnJPb6SX526AWHG6fzJIJ3Qba5EDJAS8E6PINyfWROPO3vtA5w762pufkPtksA4TukWiKMDoNOy/3/QVKsTZIJVjt4PS4KWMtBBtfWnZV5/b+JBAmGMDn9Hi1Ef8NNLVXg5mtusXO7B5kO00FO75AE+pjp47iWkst+HHUF+neCTON11Ckr3ZbeiMq6myCEZg1j/RPaHtIYVU4CG2bnK7avtYFnXN97Eu6B0E3AU1yLqbxawqU/F2r+Xw7+8Z8B8ScDZssGK8rUTfKxRbTjwX9Z+pNhcpfxEmPMvbRBk5gbmH2VpWW/cL465ev93FzQ6eNnY2zwjm+nrM2nKeRhaDU5hOw92jB3HSaAKHSyrSQLGMWTafb6+5LZgB6dA0SYwNNrPVSXb8JpkWmA7bsEZCOIhfCLiwYoCK+fbdiq2uNOLSwXoWnfR1VLxsf+5fyPUoVM47zs31ht6Ky8rglTR8FHBgT+brzkfj9HZ+DQiNZVHutz9cnCRbtUuLk+yFrjyc0HITJop2U1Cao5VwYvmUPGQ3qmSlxqI8eWL+fWJUWdW6MWnCtCKAJsTd/GSHufpi9PHpAQs4A3avWzyXV9S6I+eIamC9hJ69dx5wU3TD7CzNoKU30bO+A1DHRfCT8ZbQUQv39g6uLnVTk0y21ZWM+ALWovXF5/x08GXArHJbQU4Jan3XG6SjsXBZlanGGzMf6DUtlDK6F/TB7wMm5dpTsxziLQ0fGNAyEQqNp5QDEG5pHZWJ42o2VM3MZTRZgO5OSh8Zjs2xm6LVUbw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e660a573-aafd-4c40-e714-08da8139322b X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:28.2765 (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: EYQeXiVS2Eu6UybFFaXy/f84wgoHc1tWbPc9wpUVzSgOeYoKMaa0uWwsYA3rzWG6/GpcZ1agPWuSEBHnt8d/GQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add 1000BASE-KX interface mode. This 1G backplane ethernet as described in clause 70. Clause 73 autonegotiation is mandatory, and only full duplex operation is supported. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 1 + include/linux/phy.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9bd69328dc4d..b08716fe22c1 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -344,6 +344,7 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, case PHY_INTERFACE_MODE_1000BASEX: caps |= MAC_1000HD; fallthrough; + case PHY_INTERFACE_MODE_1000BASEKX: case PHY_INTERFACE_MODE_TRGMII: caps |= MAC_1000FD; break; diff --git a/include/linux/phy.h b/include/linux/phy.h index 87638c55d844..81ce76c3e799 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -115,6 +115,7 @@ extern const int phy_10gbit_features_array[1]; * @PHY_INTERFACE_MODE_25GBASER: 25G BaseR * @PHY_INTERFACE_MODE_USXGMII: Universal Serial 10GE MII * @PHY_INTERFACE_MODE_10GKR: 10GBASE-KR - with Clause 73 AN + * @PHY_INTERFACE_MODE_1000BASEKX: 1000Base-KX - with Clause 73 AN * @PHY_INTERFACE_MODE_MAX: Book keeping * * Describes the interface between the MAC and PHY. @@ -152,6 +153,7 @@ typedef enum { PHY_INTERFACE_MODE_USXGMII, /* 10GBASE-KR - with Clause 73 AN */ PHY_INTERFACE_MODE_10GKR, + PHY_INTERFACE_MODE_1000BASEKX, PHY_INTERFACE_MODE_MAX, } phy_interface_t; @@ -249,6 +251,8 @@ static inline const char *phy_modes(phy_interface_t interface) return "trgmii"; case PHY_INTERFACE_MODE_1000BASEX: return "1000base-x"; + case PHY_INTERFACE_MODE_1000BASEKX: + return "1000base-kx"; case PHY_INTERFACE_MODE_2500BASEX: return "2500base-x"; case PHY_INTERFACE_MODE_5GBASER: From patchwork Thu Aug 18 16:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947446 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 12375C32773 for ; Thu, 18 Aug 2022 16:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345021AbiHRQqj (ORCPT ); Thu, 18 Aug 2022 12:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345009AbiHRQqd (ORCPT ); Thu, 18 Aug 2022 12:46:33 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99CDBE4DD; Thu, 18 Aug 2022 09:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+6vjJDkxQo0SHXd3FVpxxLYtCmEGEw+zna2Cu7WXEZTscJDH91xRjq4YtdX4lSXqJ4R4azDoZZ3HlUsRl3g8va2zJ78Pacb+i43PW4V6Nap4vlVCnx16HYHt20+QGk90d05pQhUxgRqslMQSz3zbsR9XMGcihlKd+67GiedeTQkgy7+tXWmmqQQy1ElsirrZ51qqQgiDNUOCPqxhsRWJux4s4q0ZIE/LY67MWi4tjdb1HFjX+nmltHuw0QIuzA3Dna/f3YJ/SfJyP9i0WO4+aKxXnTKwOt11ph4XSsD0o0rXLQZmY2I16suV4VB2LQZNeYIrAZi2cvjD/eUb2JEmg== 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=cjcsfjliJwSEh13O05pl4nrVds79IIkn4hXvFzLQxyc=; b=m6Yl/0NxHbRV+ppuMRp12YD3JzrjnsGe0MH4DWA6bNk/1OALGg7GTwkeo7VJCEWOq1AV1UGywBo+a5qBVIzOu1m2K1j9kRkMwpyYUKpcptIpon2+PA15wdjtPL5nDv/dLFZ+SlZLsMqOBIS6v46TteXDoilKLSxkn/xZ0hdsKKggcnWYxU8SlZ4dsrCB62RPNxVPH3x7tE6MqLqur0V5hw1fPTkaAgfJU6M0Axg9uhYqYuKGK85Z7NmzpzeInGYN+xeUiZhEB7XLDGLMUwtmjKZk+m/M5ylZfPCK/asAw3qJVUsiAh7GoyNXSQMdjDZ2XLEtcg57TpVNB34knd6uOw== 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=cjcsfjliJwSEh13O05pl4nrVds79IIkn4hXvFzLQxyc=; b=LWfE/lemokzoccNYexXV/nVOMp5WPuJI+W0knZ3lYGsiIZiCzoA9fVpnIWzxCMBqE3mFGupvpJ+Y5Ag+n4Ei+e6q0A+pfHJW0nxJuDwk0Nx7bAjFMgSyFBldUP4E6mBc85juC3SU4C4TSSmrrl6QbTphZLEX5YPQ5VW/Lp4DybO8oFN2ApgTCgHIZIWTVpoWZU9Vs9dNu1ztTAWLO3+MLZgTVpxaTqw7cbSjYo8SSI/uohfDYmkGgtJtUxlHgMu/rmUTDBFVQka7AiJpRCvHRPBsg+hw7NG7u5UcGxPb1HctPrsc7DWSPRgT+FRp1Q6wkWfxdGLagaNegzc2exLhoA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:30 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:29 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 02/10] net: phylink: Document MAC_(A)SYM_PAUSE Date: Thu, 18 Aug 2022 12:46:08 -0400 Message-Id: <20220818164616.2064242-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c03eb5d-2112-47b9-fe64-08da8139332a X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAIPDBfVGC/2gxoMG82hMbEJgqiVXH8o/r3r+VBihrgwrsB2SS55i73Tcm6vpYHBefRxXOutRA3C3toTovC1vdQF56oj8pxvo8p3xAaEyB0b/EPMNu5hZTMJKnIOkhf0i4B7qoPRGIqvry5K1CRmVRNL0vA3ubHBkmlvH/s39ZLGtNUQr/I8Cn1y/JWJjv2IF1+YGc+V9T1UNTFA3B72ukgu6TbpEaMaZoj+0zCrhLOvMd7fxorI1BqiZFVwzDZIacqzsGik5RQfwoLMOlKshbiuDtA+5aeIwddVaUokt+yQHDQxQhuQZLLLZpbXfMGBcDl/k/yNsQEycEdiaJZq/61sC74bcu8g1XLs7sXv+Rml263SjieC1NCN5HPy/SH6ltZNvt68Hh/fa4meIh9Hv5J/7KIjwXZ+Klq6qADsLCbzNwHIJMSGbLl4hME35lYGx3ziPPEzWPsD+ilt/JGcu3AGA012kq4wQDWvVjPHQ6nRVhtS7s4+8rqkjVxQ8a9ZjdGHcn0ZVH4Q7/4b0UVOj4xme/FeNb1GRaqPME6AKbxXGCYoLWNPBL1seJ9N37AgBr7GBo6mWiKCN28k4kk73Dj2/0wX0xZNwH9N0+X9y3o3Ej+53EUg0uL5YLE4K9cKwTIa6mhSoxQm+dXu9C3GGfIu4KDJMz9iOF+KMdOjp1uoUwoyX8bhpCFStdmDZJ9e8dT9DB4U2ocJ3sTBA628i+MDi1rY8RRiWIM0tDPbM4A8OGD3qS4dp5BGUYl3CONT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DhXoJUBlT3eXA2SZqPEHvZHMzz82Fqx45MHaf6Nz9o8xMdlJpFNJOQohRRCIyzyVcXrbbpJt5LoS3+bLYb7FwyNWZay25wJOqkzVKZDUXHUQc10rYvz99j6TOx/qhx/sk/XpBJBVRwE/HAPYaVv5rs6XGIIUuSndBEZVDzGDMdBIwmFmrf9hIhCWYVsEB91FGYd0yoZtxkmXVE1Trti51BmHZdqvbhVsgJD1MDh1MLcV/6Dvho3J8S0LLL9vZH43PYh02YUn76kvuEZmcWkKCbu+4OFWciLFQRJ3PLdB6u5+AljFleCtqDMtUS21TupalEZvQuRzoEjyaC3ZnQXAzWNwTBEzUK4EdbPUz5UTiQpxnUS5K8xIv/bdRoPmMFqURHxVHBJqFJuHEnxaILnDcrGEOAR7kWdJd4w/sg2Za57csSzYomfiFAjlMQLPUfkZYKTzrHTYLUDXGs93AJaIeJob51L6yox4EA+JKBFheHJm2JDnHQV6NDTvKrOBOJwwXE/IBp3ou2jX+mspG1PQOft/HV8JVBOM3djN/GozOTakj+1epLKXyX/DlA4DZImjcdKecqzgHe6zkt6msiVgMtIhJ/Esq3KO1mD9Z7RBGetkuWRQKbE1VXno4id4DjqWgGmiZoVmgx59tCs0XDZ2V/KkIWE0nkYCLEQcuLQZQLXytr0jPJ7BcTPfd68v/TBk77hIISAuQxRHcUfhCalJxHBB1cnvOoFZLM1ReCCeGrtR5yOTFOQepgjembjdvtYDuQnRg1e66eS/pSsbSchKH1MJDogePSWYJpbK9KDOa5u1rhhilCcHhZ1n2VcAJSvPD5FPe+qLEupMfJ5BD9OJScgyBMcnfysBIekrpG5AoWWHIiOoi/xN9kDbmj5ig0Bcd0bOxTfXcFbI9AZqZz0B9oJbxqjUeb4lmIu0Ooo4H3ywQs2BLh5h4fEtRbJWTnVt7SjPzIjSgKPB9RQN9cEaE6VXPeL5wkMPFUzFIK5/aOAC0OxdhekoqWSQwbi6TbmJuEqINCVcq/TUPTpGdwFBwXZ4RvnbmSijiDuPwOOwYDyEMqBhWZU6s40X7bDTo2n+c5Ug3j5DiorSLAjLYIrjnk6qHu1v6pwg7QDrmKoFJiCqrdpFg4dT20ef7twARGPow3y4Zh7R5VN3Sc7fG2zlfi04Cv+7hLHTvSnIRjY37UeQI0LDGkksBWEzOnt/2dBMTz2vsMApWvyBMbM3gQB7FhbsjR/erhGjKQBr3cBBobAKzl6ey2vq2FsnRy4XfkFHwlDVAMrG82SS/nP67vRO9plDt0+2XpPhDMELUlPOKMTgRwUTk/gNnUlSLSFUk6SfTp7awO6HMsbmYbZirHe5NUzuDE9n7mIFlWf44Ii+kxpsFssOcKjV5lLpkBIDk+JLo7jv6do4NvDpohaxj+ZQ7Tby7UubYiXfIKywzGvLY7pG4vH2yd3j+HbwPzorwUXyq6Ta+0f9gS4VZGK7eODGIc15sQuWkSIfQAXJcq1YpdNr+BYEspmGsYgzU028myftCmYFdpOVaSzHtJKIbQNpsLYCCd8sxg52d3LwbfQSzDaHvQHuO+PDWGvLJ8eFlDBPtcDYkqQMduFpabxGNrhz/g== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c03eb5d-2112-47b9-fe64-08da8139332a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:29.9014 (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: fVVvo/v7KyrNj8y85NB3s04fiNdXf39rYhCP9Ji1gEfJq0Rb3IuMEvAZWkNxTmCkjNqlOyGwXfJnVfmPyMm4yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This documents the possible MLO_PAUSE_* settings which can result from different combinations of MLO_(A)SYM_PAUSE. These are more-or-less a direct consequence of Table 28B-2. Signed-off-by: Sean Anderson --- (no changes since v3) Changes in v3: - New include/linux/phylink.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6d06896fc20d..9629bcd594b1 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -21,6 +21,22 @@ enum { MLO_AN_FIXED, /* Fixed-link mode */ MLO_AN_INBAND, /* In-band protocol */ + /* MAC_SYM_PAUSE and MAC_ASYM_PAUSE correspond to the PAUSE and + * ASM_DIR bits used in autonegotiation, respectively. See IEEE802.3 + * Annex 28B for more information. + * + * The following table lists the values of MLO_PAUSE_* (aside from + * MLO_PAUSE_AN) which might be requested depending on the results of + * autonegotiation or user configuration: + * + * MAC_SYM_PAUSE MAC_ASYM_PAUSE Valid pause modes + * ============= ============== ============================== + * 0 0 MLO_PAUSE_NONE + * 0 1 MLO_PAUSE_NONE, MLO_PAUSE_TX + * 1 0 MLO_PAUSE_NONE, MLO_PAUSE_TXRX + * 1 1 MLO_PAUSE_NONE, MLO_PAUSE_TXRX, + * MLO_PAUSE_RX + */ MAC_SYM_PAUSE = BIT(0), MAC_ASYM_PAUSE = BIT(1), MAC_10HD = BIT(2), From patchwork Thu Aug 18 16:46:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947448 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 0A89BC00140 for ; Thu, 18 Aug 2022 16:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345029AbiHRQqm (ORCPT ); Thu, 18 Aug 2022 12:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345012AbiHRQqg (ORCPT ); Thu, 18 Aug 2022 12:46:36 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECF1CBFA9F; Thu, 18 Aug 2022 09:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IntrSFmcWSuwsIQ2b9D3nUo7ku5wgzScj2C2XoQBk/SlUtsoTVkCf4MOOQGK87D2DV7MCesZ1SMx1orDYclhtbVE1BpbwBgeRUeNXyxm3FonOJyWpNaGrVCBZ+aE5ed1QCA5Pvu0iXooROuXdkHrD/YEHhhKr+6l5a6TOONnLMAunfzeeLE/foEkztKXPbEEgAKCJOZlBPqAPBvOtsIs8b/rkBJOnT9hc4Y2NnKTxkVagsFlYWxfUB2/J9tBdfpPAjfPjIGO4V+rw0cm6p0x0CxEaYsxxdCsEMequ3oAUJzj6kCJMagpmsl7JjCwlPwjF3zUAkSBYbzzcykrsZ3Zog== 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=0jJ1221tKVunCESv1du32WcB+bJC4tZ6d5/Onqpe3VQ=; b=c0a44C1NEUq5mAem7IGwZ9+xvA2JYA72SOQJm/bxnU8eLafUzPtSYBGXD/A1aOVSEFeEIOkhZyVFgtDXyNNOIz2KM0DTRQ8VEI9luqK7ED5o7Jd0i/KED46REyNkxuJggvcy5c1c2jphYzctq0O2E8Z6hq570nWVHuAEn0Sj+TvkXvk6pxaL/sPeDN1YpKOrpDnTMJUvaqFpt4K2QcbW5lGoBM2hEJHcZb8f0w20wa0cexwDnfnwS+FzEDTLk+3M0U81bbMyhKJJi2ir2KPvwAXZ8gkB4z0RvigFntubW2yxPnZePyHkuacm0lmEtU7HfBnb8VQts8F2Or49LDZ4iA== 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=0jJ1221tKVunCESv1du32WcB+bJC4tZ6d5/Onqpe3VQ=; b=sMIMarbrgd9Cl/Ef1Jh2C8wyTcUiN2l3J3SlluKnSIyq8AbViNT8PYI2sKNoYwk51BCS0mUb12toIrukTtZFEhS4NLSnbzncw+KOkhsLu6Ny1RppvU6uIU5+IGQLQXD5j96aEO4HZPgy4WahwHDzDnAWQirQflUANQaToqmm43+qrFwaZmFMeqHI1z4gEMi5envXjUF/+ZpFh5AeePry23AD1PmdplnRcBBGgfvMR6ooEI+oiZrGvURB7px1unLadLzowgfFIEYsJnc1JJ0D5NrrsLkdbxbL6yGNS8cSMMs47ad2aQ3xtyeezUy/5fsWEYTj6Uz3lnvNjM7X9TqNqw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:31 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:31 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 03/10] net: phylink: Export phylink_caps_to_linkmodes Date: Thu, 18 Aug 2022 12:46:09 -0400 Message-Id: <20220818164616.2064242-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71392dc4-a816-4cbc-eeda-08da81393422 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DhNh/lWdUPuqqJ/AKNqmv01V+9PGLhGfLBSyjaSVQaG1NxlhGO2VTZq+1yNpWHtuMc73pt/ijwNx/TRqSjdn4GAjTzbmNuZN0N7Gh/qyqyBNH9o2R8LlfyWgZaPf2KxOufZcg9y9yE4Yf0E2dPc/w3+hJN2QJ5sq+10NEkhfTYTTD/eMdYmN9eju714SKpTDqph2sB5LnaXFIs4K/ciO3yZ/os3uLsrZyXsJ1SP6QhB6t1mC8ZzpZ2oHqpDdJJd8LfA1mhOMf/DTSEtM77dqqhWt7gvmdBurVXOpbstvxpATg2BJNGfxTT3mxIDJXf+P1/l0FnTPw/HjDoVRusXe4UFMabohl645nkg7r62vsbC4YzVqrQsQmd/l9oj+hQ/El3y8y59OzYvb9oSxUiDZclF1luBkOcSOsWIJ7bcXof1nGAFY8xBmQP+EcDwawh8HJlxFjPnZlUswlvtTciXsZH2PlIxYA/DSiLshCHbfvzB6h53rfxQ1nU8aIwTWWx0acuQXEd286XraQlTUAFiw5fO4LGn3NMR3yzWZlj0h9jOsicYSGiTCuPP0HTuVLJKXQDDqRGbHv5Nziww3JuXRjtN2K5zVHm24AsY9y10jTPRErGlLGfDBz8FktrzEcZkokiLva7EX+7LByNP+hGzO27Dilzv6G6Vb0SouCEhbh30si4Dqsys+gYd5Qm+ZTurvLfnurnnH7Q/k7lnPXaLdmQ1c2GEtn87SJzuIHJ7jEycj1G4fIogEo2TH19r0jf/EHqVntiHViZgiwZP2cOVqig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: og3wc0X4fDq/BmX3waPefDBTgJwLJyStT2dKkuUz4YFj2JpSRtjEbxVop76r4dnqx8qpSS1un4KNia56Ny4MZK7DOCwkGIMQl6Tj6N+t/R6W6XBNEWm4WILKDcPDl+k3odKHfpYH1b9g18PBwFhmRGZciQbIhO138jC/k7FHmf8nQsI/d5cI439yZQkuA9ptU0vL+25+n/NcilaDYJtzqZlbldIsGvnzNYhxu841S4A0NDBDKfm4i9yomWPZCyzPv4GwNhWZ7j42W/p3FRKSqecPwtzErg0ZC8k8UeQPfeKw6BlUq6BhUArhTodWS/eTCn7UY9+l7CLrrwBGrhyBJNZHjObyJcgUB2VvNcrep6Q/xl2Uzk4iPg2hkzxkdR6Cr/fnB+brjrtAD4Io7y/x8Cu427gH5eFJeb9S/kr3U12jJZMdOLLbzeXwWYoeX7xgJLqGkQAcOwQdze4P29L9coM9/fgaHforFAeIxRpGUEs3TyS4s8anu03Axb+0WJlJvPoLSIWeb4Qk+AsgFfQo40gr5IXtpJ9PSGfM1FlDBA2ZAHwzDC5yhTifkdGag2s9nggemfysSOfC3cMJIH/i05X7dJJz8xzlA2wYlHeQ0SIabimE2/4bQeSrpAu9gIcVmOjPfda7Wm7sPAQ/EA3CvEc6aN4QXQ575uQUyuCst7lDIJkkY0slMVoe6slFNU8t5fDOFZy4PGsSH3znrCVB244Xjkc13Gh+ytR/XzDAj/jFhrqhBY5iEhYWSFO/lqrtMOmZjCikqufOQd+GaQYx2JcqNilpMPRPhukyzWC3JXL54JDfJHLCs4BGZWeHQcWivVfMHjePtA4nqgXY4eWyEKGa29B0zHWdRtbcqlI92ETw+AOTTvq3hN2B0gJejIYgwwevC4irhWz5sC/GKhTjrm14/w+kdknrFVByajhxlEgSz9fstW0GARJm1SfJra8ELIcSxj3Lavv/eHQ3OEBQ7fDbG4xL/iwfnPs7JUqg85wirAZjGDojM88zV8elyejAYp9Mn+sPtnev3BarjW/vSlKDifNwICwqliFIRyxUzkPnLeYfE9RHsjKLJrWgHH5ghEDNtIUCpRnfHLqE0+SAPi8pmSrtL/REo/zJ1kpw7JtPMhLv8eeWCICtJQVP/F/2yqEf2DdQNFNcx6Nyf3xhGOd6oALXxR6PwHHze9vMV+nPNqQgslbT3hStUwYWBGA9OI+93RINjQCv2LOY8xzZ0v7TOs/NlA94hL26/G8CMTHy5E9SASZg7P9eJ2B+ncaJQXsV9ynqqOj48e02PPXPI3hVJSG78QpufJ5U2miSdghX/Q0EZXObrpXynq3/a/S9pY5Udlms5cilxgg+zAcgjwmn1SwJvXgiO1KqMyWRMh6hVRd0/VAVsnKIEYl9QZD1Dl5O1PIhomGx1XnLJIA+RfVr1GMy1uuW8itKRqkm+N7YRl3SsQe5vuln/2bOeu/29prvNfxxUgpA8t8We4osb1HC1FFjqa4907oOato83IeRKe3e3pYywAVNn7M7Q2lcND3+72qFnYnMGEZk/Bua6IrYWBFw1Bnsj+B82fi2v1Nvjf3jzdZ5Gx8uvsEO22FNe8RMeYyj1/WqMQSmqcNSHg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71392dc4-a816-4cbc-eeda-08da81393422 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:31.6513 (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: l/w9MdXoFa+1k3d+DX6S+e77U+aZavQYkH5ITrISfpQyLWQR7zCH9pbK84qnbZGu2URKPq1d/9d/qCgWXz8rPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This function is convenient for MAC drivers. They can use it to add or remove particular link modes based on capabilities (such as if half duplex is not supported for a particular interface mode). Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 12 ++++++++++-- include/linux/phylink.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index b08716fe22c1..51e66320526f 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,8 +155,15 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } -static void phylink_caps_to_linkmodes(unsigned long *linkmodes, - unsigned long caps) +/** + * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes + * @linkmodes: ethtool linkmode mask (must be already initialised) + * @caps: bitmask of MAC capabilities + * + * Set all possible pause, speed and duplex linkmodes in @linkmodes that are + * supported by the @caps. @linkmodes must have been initialised previously. + */ +void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) { if (caps & MAC_SYM_PAUSE) __set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes); @@ -295,6 +302,7 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes, __set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes); } } +EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** * phylink_get_linkmodes() - get acceptable link modes diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 9629bcd594b1..2a6d2f7a7ebb 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -534,6 +534,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); #endif +void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, From patchwork Thu Aug 18 16:46:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947457 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 3E2CCC00140 for ; Thu, 18 Aug 2022 16:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345043AbiHRQqr (ORCPT ); Thu, 18 Aug 2022 12:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345014AbiHRQqh (ORCPT ); Thu, 18 Aug 2022 12:46:37 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0F9BFC67; Thu, 18 Aug 2022 09:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eeHcxDJjReSkx96j1kaD/0fKF7TRCprADaax5frCG68n+RInyzLLDZBRLPLyus9B1r77RlPEhxrhEjTWf0OigIRxMTfNFNoBBuOTofs8h8V82USSVtwEcib080fDu6Q0EBW/f6NlMpznHiN182GEPVVCXXthmdqK/YsC5GdFMYdyguz416egpMny6F1l/KFDN7KFttW+XDoOsou5YvGWGvYHggaqe8jwNWJlugvtQAx45d5Rsvvsgf4p51gykV8y0uoR5M7NAZyFSwwAj2YhKVCB8TKW/Mee6f5AF4SrrPIMteHPRzK+7wyi9J7TuTmRphrDxKx+EHX/aBwCNx3M1w== 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=U5iFmrfwwkbvAIW1DiuwmjTQzQA6j27fMaHDaUsHht0=; b=H+vBiK+2pR1XK2NG+Tv8orzRlhTWNe5+tb3gPwsIQVJqtP7w9ghd3h//PviVTzd6lGy/+2wT0viU6QYgjfaMwitbdXXw1ZwY2hIoO4u3Zg84C/EC/AvibFIsnvO5AQVnQqkHHCypYWG7YaxC/Kno8uWRKU7t4jGgc3BJ4N1Xm8/pYTHEwewh2GJTSp0YzhQWwmkII6fSXtND+wwHC0Ryto2R0E9LH1FteXiz0B6qhmdLnLeI3oYzPf8uR1JxNmg8V1CtQLELwCkWpDbs2qZpeIULl/BS+narPFv4DcqeeeVOes1nGiMAzptMeBLV0YcEoN2VBN/EAuqzAQDih5GrrQ== 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=U5iFmrfwwkbvAIW1DiuwmjTQzQA6j27fMaHDaUsHht0=; b=Gxhyeev612xdWPVePtk5xZRvQM+B7/1MVlsXRYRr/6GQfH5wAx1jIncewsp/fF6+LrELzt7bZeEGH6vRBoPdyMCD9aRBlJK98UYtle6THKuty5iy9OjaOAWSK9dQy1LslYpq+exHNDyVNSJtLxGmG5HeeZZtSDX3y1xn/72KqbOTosfwqRI3oqVZHgbynLqEVK9L6zZmL2J1dFf8xPamQXTN/qV7/5w4GIHGSr0vCMrpJ6oSRNEPfyjIzUoC2/eBHh8rwqtekBQZunBFHoRAQq3eNcd8/I33Sg4yk1zW03zle2q2m6dzfcnCtMhEEe1MxRNWcNgvBfGlmU5aMDwafg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:33 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:33 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 04/10] net: phylink: Generate caps and convert to linkmodes separately Date: Thu, 18 Aug 2022 12:46:10 -0400 Message-Id: <20220818164616.2064242-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9128ab41-a051-4d8b-cac5-08da81393526 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D4UJxDuNtAWrHBYbiCZaowD7H/JVqJmunko70lr95FHROgpnSQJGvsb6nlw4a9geiFIlyzceDdLWZpkJiO+0lMTkaIIHiwdxs4I1hHHIugBIStRSbKoV9OdVlaCJCMpYTL8koVpZll2vQhS9nYIPKYtufxmv1ZGf1RyvwaRMFqjX3GWvXZaagchSgcOGAWQehVFvRIqwAGhoFiia7ay8L4j1Sd+VFoYzxC9Y2/nWKYgNnf+HgmGlza2HMLdDcm2zZ8fmVCY3RiYkzjLYpSeLRmjoGZIC8zRQX6tI8ydoOkUakp2Vyn/vs24ZXA+zQwlic8KD/9TWWL3cwoNwZ6VDafElAomSCxveYYsEuCQYlZ0HFEpHYnlXNDcLBYEHII0nByvTORcCk27Q7AJbh/vZU0tbxLjHQDTzrTzz+Gv3OrdyPzh2VqfWUFhsK2z1pIfW1UnXZMsejt1iu1DAToTb8DrDBZ+bHkmmfDsfJS+/5/XGAmC/SJS3WBMT2qD1pcUriS2PyeDFLTldOOwzlmY0rKzkitM6+OZMG5pai+w2SEpcgaCW91t5jAQMfs2m3rqem5fK95MnFVg0Wm7yjBhsJJn3znUotQXHI750lk0JCNh146QtAkDMDFJyk6/Q+llrrvqYi6TG5l/rsPz9eZsxKWGXjfRY+oe/ey5kZfzYL9NBqqfWHVN4OUyF5ZJks1QZ2oLehZKdnef5Bm0gP7YuYxMr+Ot2j/J5tdUgTvIhlJP1HH99qY/fpMWiWUj8AmYcauS8ElgPxo4eCtlcY4qS6g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hyYBn09OHaUBehqhVLQchuWstE3FNMvxjKClryK1a9wby5pv5JbJKGlwLKuyhAUUvJLpqg3ZdW7vTEWujXayN2crcbXLbXvNohI2zbRKxQ1/tVYjZ8pfuY86nZuyFQyGUY3KS52YammjH6jxmFpEdAuggsAOFuoBIy0fC7dyNwzyX+z0TAbmDJQInZqK9zQolDuBgAQHJEDOPmUVj3f7A2i/GuVsiJTtaPAyGbCJZ58M3IJoTgWzYOQLWEo7YHUxF0ewy3ohg48gttJvcu4XifUKy/2Fvgy4XphWgwSJePn3JfolqmqX2QCuJTEbAcpJyL+mYQwg39kn6cezwrEqKafEE5qFpYxPsob+EihcJajd2kSJpyOVI9C+gIZkrtS6uk/G3uMcHqJhPxROlcIi4dgrrHdrfNvGoHRLZNggQRNm7hvlS3+4cLnSDzWZH83nr3OFH/Gdp4qaoQBCP7EDJ3O7R6OoEKhgZ+2p817dCfoqGRBAEJg187qutBe/R725B/XBWamfBJJ40HYcQgnTLKlULwUg5+ndSmFLwNsr2K0x+TpGEpfzuUZuC2pR7sMV6Q64v7P2S00DXrg/zowwxXJvfRxC8JL0AMb8O8TCP4TrLE9FeoWmy4r8J1dFfkrJuBJ3tn0YUorSTNXeEdHW/QD48Egyh5FQSyHff+LvTdmJLAQRzr8EMDd2peFR3XjesSQ9lXTXZ9L1811jLrPv7VosQppYLcX9Mc4NyPsSwUvO1Q6jBhfTnHKfX7MqdX0zF6ewHG7TA+LOxms77ys5XRWyKwKnRM0GzfJ/0DHdt9yOqt8Du1l2mlW0kwYyfCKMI+9a1tNJD7QnwiCaM2F94L6WO9jnaVUWZIC7b0p1/990ygk9gkiLYX/1pKVtr2r+WnC3tQpUg98v3L8GMa2F4FcGS1Lsi3GAnqqor0Dye2jzO+P+wJcZ2JIw9k6BBobSBa8eZMXdUyxr8F1lFqRdi4Rbtyy/SC4WtVLRbHk42RFlpvdR4Spua2wbzfIzjeOA7P0lHh4+j7DQfH66A1PJJxZ1ZpcouM44Gfij2uOmqX1tHv5SutNYkZV08KI/WZyQLdeJMn9GPithhrdcDAjvH/acEW1FOd1+EQfkc+prNpYqVPdAjEut/C/hO8qOgynLnFWPJzzVpcK6tA8yv9F486GBfTgsq4rxJGF8Keo8Z0CjFNApkhOfbQkW3UBpMo43Mt1fO6mQynBtc/i9b7fCLfCkN4PpB3kOHavS3g//Xl/8pGyWWXAmFWtyAmdzk+KRa5x4MhXG//SBqjZ/u6BVzFQnpfrVT13YvUfr1MZ8jdumZSJyKBNqMtefMeX5Gp28L1Y9GOjv+JHsZkK5KGQqDRlDi84Xf/QZvuPDp64HkYKFtA4DzkO9KGAteqnKsbh3D3aNFSkU4V9rFGXEFKCp3cZJo7+c9+aC76B50zxNZtDbxW2aHEEJEwWSlAkAChRcV1C9XUWr4os8pe3UcTliXyghlLjV9pZ99uHtSVYUklCVzMcmScmlP2GL4ZkyGu4RQLDOMXX+M/WS5+Yz0q/rFEbbGgLo6rs8MY7s5aNPSRYBp+So7c95ZL1hkI6PjO5fhOMrrBisiosZIE7+Z894rw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9128ab41-a051-4d8b-cac5-08da81393526 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:33.2450 (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: HllbtHbLm/O2t6ZYyQ7VmxzYkhhOKaT4yDSeNIsSPLWJMBPxGZTZLvtqcVJQLQ9voRGSdXbppjosMdF3xARKlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If we call phylink_caps_to_linkmodes directly from phylink_get_linkmodes, it is difficult to re-use this functionality in MAC drivers. This is because MAC drivers must then work with an ethtool linkmode bitmap, instead of with mac capabilities. Instead, let the caller of phylink_get_linkmodes do the conversion. To reflect this change, rename the function to phylink_get_capabilities. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 21 +++++++++++---------- include/linux/phylink.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 51e66320526f..68a58ab6a8ed 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -305,17 +305,15 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** - * phylink_get_linkmodes() - get acceptable link modes - * @linkmodes: ethtool linkmode mask (must be already initialised) + * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t * @mac_capabilities: bitmask of MAC capabilities * - * Set all possible pause, speed and duplex linkmodes in @linkmodes that - * are supported by the @interface mode and @mac_capabilities. @linkmodes - * must have been initialised previously. + * Get the MAC capabilities that are supported by the @interface mode and + * @mac_capabilities. */ -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities) +unsigned long phylink_get_capabilities(phy_interface_t interface, + unsigned long mac_capabilities) { unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; @@ -390,9 +388,9 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, break; } - phylink_caps_to_linkmodes(linkmodes, caps & mac_capabilities); + return caps & mac_capabilities; } -EXPORT_SYMBOL_GPL(phylink_get_linkmodes); +EXPORT_SYMBOL_GPL(phylink_get_capabilities); /** * phylink_generic_validate() - generic validate() callback implementation @@ -408,11 +406,14 @@ void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { + unsigned long caps; __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; phylink_set_port_modes(mask); phylink_set(mask, Autoneg); - phylink_get_linkmodes(mask, state->interface, config->mac_capabilities); + caps = phylink_get_capabilities(state->interface, + config->mac_capabilities); + phylink_caps_to_linkmodes(mask, caps); linkmode_and(supported, supported, mask); linkmode_and(state->advertising, state->advertising, mask); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 2a6d2f7a7ebb..661d1d4fdbec 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -535,8 +535,8 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, #endif void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities); +unsigned long phylink_get_capabilities(phy_interface_t interface, + unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state); From patchwork Thu Aug 18 16:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947449 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 C72A2C2BB41 for ; Thu, 18 Aug 2022 16:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345009AbiHRQqo (ORCPT ); Thu, 18 Aug 2022 12:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344962AbiHRQqh (ORCPT ); Thu, 18 Aug 2022 12:46:37 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26444C0B61; Thu, 18 Aug 2022 09:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JOK5FDkFZIEI6tUG5CJOx6xDGrNFbrgUp+1ihGWq+vAaFpcGBvbhSNfOkXkGQ84t3cayARWkNgBC886BO3UoJs92o6WaNIIlsjS4lflF8NpsZHbuCxeSwP1VtyfEDlAtc2BNArOGHVnKtIym5fyM8HW3+PrpN+4uZWPdRU39+6JMP0x8SbCbJXjplDIAC+jLBkrLMQajmZn2YBDdzLczMBLir7aE8fxY+/mRJIaXf4spZlW724r3hkUcoGekB1wW/6AL2fN+1DAhmzKnnUqYM7FctW7ubUEt2ThPLc7zGsUoXLPZsWba/IU/bM52I3ecgVtiob9YnrSILWnc47+KcQ== 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=IaWH7tbDmG6BxoGHHGvyMDT5CLyr/K3DyajS+jXooQs=; b=F0+lb8seuLkxiRFY6C728HYvcpwZIPOs9XUXUPqvbqN+7JporUjy+PvYVRx/fpl0D10oSuMcMI6xicB+t4+bvR+4+wfY0CksqpNfTObNKTf/Fe2ZYnTov5vX6zutXlyVIJ85Hys7KLxzGyTSx8glwwbRAhQ9Km4/XZCXnZUwXLbA1qxqCalZ9ZhaDWatGYofEkmTOaB8R63nkURi73l68VINHLjpK4zSrIjcNRUFpYPvFj3IMsJGWzu2DW+qyx451wZrywqebvxaaiZsddYp9HZ5fqu7nFqOSI0gx31ixawNKz/55NDdFQOnkdCqZaQgPmOZT4Z/AZR97P6shg+bZw== 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=IaWH7tbDmG6BxoGHHGvyMDT5CLyr/K3DyajS+jXooQs=; b=bYOlJMDvUCSb1kwaDetxruSGzjIGTkvivuFt5epdI2FNoM3sQf9Ff3xuQm3MjxxOsMQ7nRz+wOV7Dw8OXYF5TZvf4rlu0Mf8yYRnPRvuDqoYPgh/yNlTpchfg8LbuQtkQPtWryjF4tdo3ZRSu23qvVcQ9OogqSsOib453IiVSfjGUmJItuTvCMDxhgSDDQ1eUHFJ/oLfV4gfMvpol7lVNHFwc++w7+UCJOSHsKWe0jmmbupRDAhYh6JQxohPXnLGbDMAgW6K8Q0rl8htN59yudfBfYUayMaWY+TD7KQ4YZF7QsJMgZJQ26gjSIYwkx1tDc3IV4pC3XXbok47fbXVAw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:35 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:35 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson , Russell King Subject: [PATCH net-next v4 05/10] net: phylink: Add some helpers for working with mac caps Date: Thu, 18 Aug 2022 12:46:11 -0400 Message-Id: <20220818164616.2064242-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c9cc86d-a623-405f-e215-08da81393625 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1xUiNy4eqXrIXoEroM2UfulJQtt9yv4Ty2knhZ/6qxBeJ37jpa9Se6GoFOWhQzwJ5KDUOj1fdK5wjgjuiwH7DWQdsy4Ue5N35RlJCNYY1KLTGZKGjse213ctYMey4K+1K4Ukj3iqypxYmAXI5lKpxhCmZTExp7K1OtdGdKcGUZVr2dAfgpJm7kfhCUTtY8wO16cvMd5hEhei9xpX18VjQssLo6G6nJCLB2IHZU7pXr0s1i9ajUt9snJO7dDy2rknttV18e+7+BlA2rGm25mb6IuwroC60+e190cFm36djorFjdymbjBiI3u7W08QqL/3aDEXsDvSkcItmmvDmG9xzxtbjVMBITVqgAl2WTqE0J7voXsZnvVJxh/D5HjofXrEESafXiP9Z1LuEoLXIjwvwCOd7VkyxYTDoiQ3MmqtEt4x3Q4LTzRTDurpFAgV/txCj1qOAvNmP4NUi1ZPdbxJODgDtvgUMtTrgrt3LVDLqvnjTYzCFm0k5h5yDgNCbCZZJRyN5dE3n9iBSoGbFazCie0DaBnkx3u6lGPEq+ovkvlmf2RVwZwSDrbf+hn18fYJ+LASfy0/akS4gnfs66R+EIjaKOm2iVqBpZ7YTSK9nctMk4vwQcGQXfaA6Krr3tcgBKKFK7YGstjulzam2j+2jmEFZNzkdagPwnaVndqQZU5PTT16OQ7ZsL0uVGkMyTWoR88vbDdIqT0hZHdLn0V+oFHvlqswmK81cfCthrvUrGpzk1QonI9r4D+hGvg+wxsMOMFLYDLs0MRExYNUAj+Lh/tVOYqShbZh16S+tY4a06k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(966005)(8676002)(2906002)(41300700001)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uheRL4GZ8xWC0DHj2joO8gvP/XP0izzEB7rGea3li7AI51D7s/Xxk9ZZnrnYh8xk0PUdRBBPBphxvqqwfZND0dmF4fhdCNya+0lqV43mj/hboOqOXhk6Z57S2cpfc9pR7t/7L5SxPr9VFnNfkNuD1tdKm43CsdvJhGzG7tyL3NqPF0Ao7nc4as0p/oqY/q0CMJBVkA4HvHPNkdVVeWtG/KU7eACJZN+PfNT4BsYJyWnjX+vGh27UZ0qohuRDQq0An/sBQ6/rk3aa6GXXxgdAxJKuqQPi4C5ZRwe/j0Yb+600FkncfHso2ieDJ6iqX/Kd17lLmS0r3zHvTLRHRX6dNqrMs0nEC/US3deQHq+FD7jUqp/ZL6Qo1eWq1QJGxEoLnobq+5fsXun3KfHspHzBsM2ZCY3T+fKzsJqYkvK3cGHD3U6JU7ghxmENasXewJgqA/W6PSRAl4q++1g3k6Ed0hs3xPj1P7itgKYgyr3VE+445lTUWWM+5CckEk8tGb/fjRdM/chfOehfRbNPk8fr2Aty33VGzLrK6Z4sfMw+lLk1fK6FviyYXHgWpKPTVX9lF3ODksVG9umG+VjexUfCcKkEI+M1n+rtDrR4ZwjL8jNgfx9iq8VMpCG72dDXQZ+bQDShleQqvTHK6bGLqsryuYKt3V4hpHJUTHwPWdZLpJMRGZSYwmb2C8WQf/F0mtmsCi+PWsIKMptL3ki/m84afseDhiTjgbDLguhANSuKt2KsmhRgeZheSnG4G13pvJ5oMJ8sgYhIBSZbELBYolAabbOlvXxI/ddqb/YuO/nQTA+z5LMTf7BnIjDa89JY+WNHzBvHif8lJHGxNk9IhGEuXbFjWuE+fdacS4yDMA1IIIEIZzJA9G5CZGo24xlYOBeb+EAsXkBvqBFBsZ2BjDwTbysAnaew8bYCbSlDKz/wBZ525P0Tur1feBXzOGCsN1JRflK4v4T8vDYOZAX9WouY1OQC5SGRcTK+zaBQwE7YpzuwfrJm9SPjAa9JxajW8Yx/sIlg84ioROr0AKZoqrLUumWBnc2q4U4Ykpv0BMvPABBWoFhracSi75o47JDfCrfvary93/LFgbLFo4sxzGuN9vmFnUyl5iQdfXK2HwRfk5plWHDywRHA9DL0lOCS/otp9dT73Ue2jRablmTuKg1mRSMrkvqffGfABNrWL4xUg7pv8gPMVtCxGFvPpqPFTrTXpUkZKzClmCb1nssd93M7HtdNa5Hk1EWsbnnc3NRwbsiOEGSotLRmVh31Dzz2VNT+1Rfl2Fl0u53T+1wxfX2E21sH0JJI8bQAZx4bAvJLSX4w7SWcCUgtUXo7CiCrYiKSdrUfnim5ihe9d0Az3Q06Dw5q1bWyULprMD6r6t/46MBEpD+4SUPmHm4X4H58XQEvMptm5AV5VKvO24layLEWVYXTj/h+ruN0rSTa1T5Sq0ZhEc6WDbtQIPFe1ZtW/Mg4quWxW6EYK+b/a+gIPH/rQU2Dz+EiZBrAOS7HDvd2wcOjHaFMgdnfP2bFoMYf9jT166vKU8so4dZt4/g1exb4dW6fkVRetRQtK9YxcixFzntJBMnfb5N7Vcly9o3BwLaKKaA2nIZ/AZLZwkh0TsKBoA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c9cc86d-a623-405f-e215-08da81393625 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:34.9167 (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: Z3r+rSxyuQCKv6assLMmoOJgVYOTpg8YjaeKq7i7cq7HN3ZV0sK6sDNNCzmfger17EbOMucnrXdj3Zsnjp8Kig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds a table for converting between speed/duplex and mac capabilities. It also adds a helper for getting the max speed/duplex from some caps. It is intended to be used by Russell King's DSA phylink series. The table will be used directly later in this series. Co-developed-by: Russell King (Oracle) Signed-off-by: Russell King (Oracle) [ adapted to live in phylink.c ] Signed-off-by: Sean Anderson --- This is adapted from [1]. [1] https://lore.kernel.org/netdev/E1oCNlE-006e3z-3T@rmk-PC.armlinux.org.uk/ Changes in v4: - Wrap docstring to 80 columns Changes in v3: - New drivers/net/phy/phylink.c | 57 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 2 ++ 2 files changed, 59 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 68a58ab6a8ed..8a9da7449c73 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -304,6 +304,63 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) } EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); +static struct { + unsigned long mask; + int speed; + unsigned int duplex; +} phylink_caps_params[] = { + { MAC_400000FD, SPEED_400000, DUPLEX_FULL }, + { MAC_200000FD, SPEED_200000, DUPLEX_FULL }, + { MAC_100000FD, SPEED_100000, DUPLEX_FULL }, + { MAC_56000FD, SPEED_56000, DUPLEX_FULL }, + { MAC_50000FD, SPEED_50000, DUPLEX_FULL }, + { MAC_40000FD, SPEED_40000, DUPLEX_FULL }, + { MAC_25000FD, SPEED_25000, DUPLEX_FULL }, + { MAC_20000FD, SPEED_20000, DUPLEX_FULL }, + { MAC_10000FD, SPEED_10000, DUPLEX_FULL }, + { MAC_5000FD, SPEED_5000, DUPLEX_FULL }, + { MAC_2500FD, SPEED_2500, DUPLEX_FULL }, + { MAC_1000FD, SPEED_1000, DUPLEX_FULL }, + { MAC_1000HD, SPEED_1000, DUPLEX_HALF }, + { MAC_100FD, SPEED_100, DUPLEX_FULL }, + { MAC_100HD, SPEED_100, DUPLEX_HALF }, + { MAC_10FD, SPEED_10, DUPLEX_FULL }, + { MAC_10HD, SPEED_10, DUPLEX_HALF }, +}; + +/** + * phylink_caps_find_max_speed() - Find the max speed/duplex of mac capabilities + * @caps: A mask of mac capabilities + * @speed: Variable to store the maximum speed + * @duplex: Variable to store the maximum duplex + * + * Find the maximum speed (and associated duplex) supported by a mask of mac + * capabilities. @speed and @duplex are always set, even if no matching mac + * capability was found. + * + * Return: 0 on success, or %-EINVAL if the maximum speed/duplex could not be + * determined. + */ +int phylink_caps_find_max_speed(unsigned long caps, int *speed, + unsigned int *duplex) +{ + int i; + + *speed = SPEED_UNKNOWN; + *duplex = DUPLEX_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) { + if (caps & phylink_caps_params[i].mask) { + *speed = phylink_caps_params[i].speed; + *duplex = phylink_caps_params[i].duplex; + return 0; + } + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(phylink_caps_find_max_speed); + /** * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 661d1d4fdbec..a5a236cfacb6 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -535,6 +535,8 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, #endif void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); +int phylink_caps_find_max_speed(unsigned long caps, int *speed, + unsigned int *duplex); unsigned long phylink_get_capabilities(phy_interface_t interface, unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, From patchwork Thu Aug 18 16:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947456 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 5CAE3C00140 for ; Thu, 18 Aug 2022 16:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345040AbiHRQqp (ORCPT ); Thu, 18 Aug 2022 12:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345022AbiHRQqj (ORCPT ); Thu, 18 Aug 2022 12:46:39 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4E2BA9DE; Thu, 18 Aug 2022 09:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NMeLELl1z8NjZtD8WgZHyDEtb6vAIyYHhafrlgIbEYMz+0PwMU9pwuju0mzJxm+2JKBgdWBwKvC+8qBn3ROsgIs1shj2Mj/9TUBK4q+ISoZKdHTiE5lAaQyLN+M/rSJPiEc3Gk7X12t2gdmWQiTlqO2I0yLODXmx/ue818egMkKnimdkpdvLbmyitDTSeZ44L0GfYYorlZiaPzo8ijNGvaIwmA1c1mlbYjcx/5wglj7GykHdHo6bd/ulKM0vsKnSqhhFVlf2nEgcGdSBwOgaEVE5BIwu+15e/bwVm/b5ZcigcuCW5fSTNGVnSGdacRNMrpdDswPTjVr14eynBwNiZg== 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=OQ+H5k3+A2zqjZSCDnlVcICVZH/ycKjZOAAfIjl7c8Q=; b=U0OkAXsK1hbE42nFE8hJyQ6SrLhwGxIg2X/pMc50xh0KT1QJST00FkMKIoXKEY0UFJFRu4r9lM3aDhJtStqCNt9nTfaZgRoQXg9EcZsfGMnGm7kZ5m/0qoPkcjDLQ5EHnaKUA7hcymsyg3ZlK//SQtiLJLQC7KtKz5sWXny3QmwtBc4eGCNDDQbnpzzIQx1bYxh8M3nJA4rAGErfoBqNYmfItOvdpeT3vgg/ohVcHoQD+v+6Nay8jx1s5U/20CDydxnifs1KNdvFlH5sPqcM+79xHAAK7h7CwjUigk6ppp/BXYkUJGSu6eeDU8jEKZjGPcFESsNrBatyyVJm1o+Q9A== 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=OQ+H5k3+A2zqjZSCDnlVcICVZH/ycKjZOAAfIjl7c8Q=; b=kYtpDc5Yv6+FaDoqd/WOZ66w4DsWyDkaMy2hT9TswbbG+hRRfzeySYbDKF/6d6hnbgC81knmOpiDrPcn1yox8IXqhIaFLF5zpLV4+t06qp1V98m/M7vVabElBV0tz6GqZX/N0mdtL3rru0+0FwcgOQi2dVnlQKd2JTCMszfKp43OViHB3PZMQhVNweamAYCCQ4hM2v6/G/5Bjr2jiTf0ee+GkUa6bT2cWiNzWuNT3X7MTwTGH6leI6CNq4otGSNbPLuI+dQxGq6516KN/rnlCjoXNAx4mkwEEnOBYN/Zae+H0BPJ3TXY9KWsa1BsUdzjp7qvdIIPFiewproE8HOE2g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:37 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:37 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH net-next v4 06/10] net: phy: Add support for rate adaptation Date: Thu, 18 Aug 2022 12:46:12 -0400 Message-Id: <20220818164616.2064242-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9deac057-1468-4e73-4560-08da81393752 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zunI1smg5cMJUPMpskZCXcJF/aPJOkz5GNKAptyXTBQvYpA/epa+61zJGfmOtTFh1ce5Kk85i5/nrOHVUuLmujKFW8ygQOg2P0KXUS0dabDwYAG8RyLcoGIiVeAsJF4KtY3RgEifU+1aUS5fsv/8d3e9ACkamaJmWTDvs/sUGganrv1gOFucwXy3wex45m4X9/yFSwLpMyyixGvmOxHvWiJAKWsdA8wsVXWBKBw7jEA+JmkyEiQ38Wkdd1VPaf8uLnGoP5Q8+tyVKveT57vxZs6ofeoU27KqT+e7Eeo8AkcQ0mxWXvLuaO46ide/zxSTf4bTvrCbdZERgNxWr4CPmU1CJ6Xt4lp73dQjSp7YrDqDuC3FYDXWqMld6HogWWE5jQ988BeJsf739naKwD/crkU0rfPG8bOeAfWUHyzKuEwNtg30nJVziUwgQma8VCsQiZnKCMzj+L4cZpTHbSdvS7IMQNi9f6HpIQlELuewSs8BijFYmwptJKuJsQsm0vcXKKfdshEgVW2g63Zv9IYUPjp4tqZzSvZ3oT+tT5kxWZOcBscMjP1hxqo8Wwz+yiY0jmXYY7bxP3ZBWWEcbF2u2XzSb2a+Ty127H6L/DEirh9MzssQKhMkZQfn6J6CDcps2qPrAKP5pshBgdoNh0NGIRZDbvCMyIuj6yF1643vslS5i3l40HxG8u1oP3twfKUQLtKj/B54Zm3KoLFJoC2ZhgyHLbmTPeP2rRgZTw5xbL4UBE9udw9EwRFC7NEB0KSzNxhtALWg4kTcSj6Q162NDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(30864003)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ooH0INar260WsmiLXQ8Z2j0vTSTk3PWUUKdOc4Kf2FYhRVLtCqziduFjvBlqFCBGlem56+ByBnsp+XYfrnMm2g5jeYUmt5B10NRqXI1r9rg6wBg/IylklDFUv1IEM/8TjX20jsdldZUHtn/NB+l8sgjmicM1GG7uT3K4Fp3iZHmmSv1AR/Ry7dboO3psrPaVOjfkPVEdIqVTr9XVSSnXEI8f+m1sViSiAurP3gYwOXVDcqZu8CuE6h+kZKefZRjFZENbSQLLQeKHenzgx5URno+zqHm/JsZ5EdL0Nz1m3zY74KlNdA/CpJPni4UpKLXAEyIuFIvU0VupDPbZgf+kZAjPKWkbWjxuwy1K85hX6zo9900MDAfvREkh0p8oi6hf4NFAVCoOHKsdHqUql07yAheL3UsVtMvJrqFSSbgmkncEvuyfjolVf23/DAfiXblvGU/J1NC7ac6dGjnYYkIr2iECFcIkqF/Qehx65il87nqp9D/TXNy47S78ow59AuFjJZ3xldZhsyXO5extS3pl8yealSwH7NnghZ1feA1hHG1ZIGYsJ/BD0nCDxGylgWkYd+vFmUvDuxdFXLNJPtB3amfU7LNT0D1odA54Ybi+GxGhtxAfja7nqLnQFpvAVJzEkWTwHhbKUyLkpFOKGE6dMIFpF+DDfyxdmVybY5IOPGdXU1SS7PCO49chga0b5uV1xqj5Ypqhd8yKA8QpW620J+SpR821jluMmx6/evgkHjEIK//1znrCVRopzppRd924n4YExQhqpizJUOLzawrYXz5P4xSdL60JP7hMxtp5cb9VE3aXx6OlM0iLSWYlc42Xkb55AtAy9iP9p92N+5VOf8gSZnT4hsRAf8e5VtIF0YbKuvzp2JrlnGA7sj2auAE6UQEV8GHaIotUU5ODRFr8D3MpD3D7CjQrDbV7EgdN6Z8aaS71/yt5mPT7d+B0aVZn8XxBPwR7ANHASEDaVQJLbhsM9HFT0YvxOw6WgOAQCa/7c6cvUuHArvBOwU28qzlq/Xh76MzOh0ivN1OV1/iN5kIKa9p6oHjjYAYowxRvmjJUJLQnzMAjueDoeAQX5egoxVnMEnNFtdHg8QERrqmKEr2Z7v132NclaMj0qBKWzDJYGurl50Vx05JE2kTGa/Me4XJg/DeVPKBwVkIkoafLFA3uGxNQUKVJXZoC6o7+Y5wXACChbyfNNr1l2Nalfcqj24Jcjz90dp1ZtHtY0pDs+RN1kt/UnDKDninZ500cuWhwsarG34m5ve/VMx1eqXozbXI4dhb9kJeZ0My9W7WyLkskVDnaMLR02A92dTJBM/uVlW05smWlo01jEiWN+iEG5IdTV16c2wPESLJ3m46q2o7UMpl6wXyjehgCEied3feWaty8vQR3zqfCp6OCF6nSard+D+o5W3K6zgT8IBXW7Ej15oHakdpOoBiDVR6hnKbhaehMctntq1P14Zb0rmEPRMZBjsJeIX14lmrmjFgMfhQ5kzrWQsZi7gDiVkj4P5LSdBAAujhRCfdBLDnmUpSqNJxXKLNfdbdPVZtD3jLoVnLQ6SDtT5cJqdTyLYbbCwXnMlMo0p2j2GpyZze0zsUdhw2hCxmomYCwmKgdfMzxKg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9deac057-1468-4e73-4560-08da81393752 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:36.9478 (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: zqglQ1x7/VxBn6ZkPQvJobb4GqIWl3CDHXAAHMtMuxmfqjtx3j/WPdJikc6nzPkuWtQigLnDF0M11zPmhAKV8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for rate adaptation to the phy subsystem. The general idea is that the phy interface runs at one speed, and the MAC throttles the rate at which it sends packets to the link speed. There's a good overview of several techniques for achieving this at [1]. This patch adds support for three: pause-frame based (such as in Aquantia phys), CRS-based (such as in 10PASS-TS and 2BASE-TL), and open-loop-based (such as in 10GBASE-W). This patch makes a few assumptions and a few non assumptions about the types of rate adaptation available. First, it assumes that different phys may use different forms of rate adaptation. Second, it assumes that phys can use rate adaptation for any of their supported link speeds (e.g. if a phy supports 10BASE-T and XGMII, then it can adapt XGMII to 10BASE-T). Third, it does not assume that all interface modes will use the same form of rate adaptation. Fourth, it does not assume that all phy devices will support rate adaptation (even some do). Relaxing or strengthening these (non-)assumptions could result in a different API. For example, if all interface modes were assumed to use the same form of rate adaptation, then a bitmask of interface modes supportting rate adaptation would suffice. For some better visibility into the process, the current rate adaptation mode is exposed as part of the ethtool ksettings. For the moment, only read access is supported. I'm not sure what userspace might want to configure yet (disable it altogether, disable just one mode, specify the mode to use, etc.). For the moment, since only pause-based rate adaptation support is added in the next few commits, rate adaptation can be disabled altogether by adjusting the advertisement. Signed-off-by: Sean Anderson --- Should the unimplemented adaptation modes be kept in? Changes in v4: - Export phy_rate_adaptation_to_str Changes in v2: - Use int/defines instead of enum to allow for use in ioctls/netlink - Add locking to phy_get_rate_adaptation - Add (read-only) ethtool support for rate adaptation - Move part of commit message to cover letter, as it gives a good overview of the whole series, and allows this patch to focus more on the specifics. Documentation/networking/ethtool-netlink.rst | 2 ++ drivers/net/phy/phy-core.c | 16 +++++++++++ drivers/net/phy/phy.c | 28 ++++++++++++++++++++ include/linux/phy.h | 22 ++++++++++++++- include/uapi/linux/ethtool.h | 18 +++++++++++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/ioctl.c | 1 + net/ethtool/linkmodes.c | 5 ++++ 8 files changed, 90 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index dbca3e9ec782..65ed29e78499 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -426,6 +426,7 @@ Kernel response contents: ``ETHTOOL_A_LINKMODES_DUPLEX`` u8 duplex mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG`` u8 Master/slave port mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE`` u8 Master/slave port state + ``ETHTOOL_A_LINKMODES_RATE_ADAPTATION`` u8 PHY rate adaptation ========================================== ====== ========================== For ``ETHTOOL_A_LINKMODES_OURS``, value represents advertised modes and mask @@ -449,6 +450,7 @@ Request contents: ``ETHTOOL_A_LINKMODES_SPEED`` u32 link speed (Mb/s) ``ETHTOOL_A_LINKMODES_DUPLEX`` u8 duplex mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG`` u8 Master/slave port mode + ``ETHTOOL_A_LINKMODES_RATE_ADAPTATION`` u8 PHY rate adaptation ``ETHTOOL_A_LINKMODES_LANES`` u32 lanes ========================================== ====== ========================== diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 1f2531a1a876..a09ed0013f04 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -74,6 +74,22 @@ const char *phy_duplex_to_str(unsigned int duplex) } EXPORT_SYMBOL_GPL(phy_duplex_to_str); +const char *phy_rate_adaptation_to_str(int rate_adaptation) +{ + switch (rate_adaptation) { + case RATE_ADAPT_NONE: + return "none"; + case RATE_ADAPT_PAUSE: + return "pause"; + case RATE_ADAPT_CRS: + return "crs"; + case RATE_ADAPT_OPEN_LOOP: + return "open-loop"; + } + return "Unsupported (update phy-core.c)"; +} +EXPORT_SYMBOL_GPL(phy_rate_adaptation_to_str); + /* 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/phy.c b/drivers/net/phy/phy.c index 8d3ee3a6495b..77cbf07852e6 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -114,6 +114,33 @@ void phy_print_status(struct phy_device *phydev) } EXPORT_SYMBOL(phy_print_status); +/** + * phy_get_rate_adaptation - determine if rate adaptation is supported + * @phydev: The phy device to return rate adaptation for + * @iface: The interface mode to use + * + * This determines the type of rate adaptation (if any) that @phy supports + * using @iface. @iface may be %PHY_INTERFACE_MODE_NA to determine if any + * interface supports rate adaptation. + * + * Return: The type of rate adaptation @phy supports for @iface, or + * %RATE_ADAPT_NONE. + */ +int phy_get_rate_adaptation(struct phy_device *phydev, + phy_interface_t iface) +{ + int ret = RATE_ADAPT_NONE; + + if (phydev->drv->get_rate_adaptation) { + mutex_lock(&phydev->lock); + ret = phydev->drv->get_rate_adaptation(phydev, iface); + mutex_unlock(&phydev->lock); + } + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_rate_adaptation); + /** * phy_config_interrupt - configure the PHY device for the requested interrupts * @phydev: the phy_device struct @@ -256,6 +283,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev, cmd->base.duplex = phydev->duplex; cmd->base.master_slave_cfg = phydev->master_slave_get; cmd->base.master_slave_state = phydev->master_slave_state; + cmd->base.rate_adaptation = phydev->rate_adaptation; if (phydev->interface == PHY_INTERFACE_MODE_MOCA) cmd->base.port = PORT_BNC; else diff --git a/include/linux/phy.h b/include/linux/phy.h index 81ce76c3e799..4ba8126b64f3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -276,7 +276,6 @@ static inline const char *phy_modes(phy_interface_t interface) } } - #define PHY_INIT_TIMEOUT 100000 #define PHY_FORCE_TIMEOUT 10 @@ -570,6 +569,7 @@ struct macsec_ops; * @lp_advertising: Current link partner advertised linkmodes * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited * @autoneg: Flag autoneg being used + * @rate_adaptation: Current rate adaptation mode * @link: Current link state * @autoneg_complete: Flag auto negotiation of the link has completed * @mdix: Current crossover @@ -637,6 +637,8 @@ struct phy_device { unsigned irq_suspended:1; unsigned irq_rerun:1; + int rate_adaptation; + enum phy_state state; u32 dev_flags; @@ -801,6 +803,21 @@ struct phy_driver { */ int (*get_features)(struct phy_device *phydev); + /** + * @get_rate_adaptation: Get the supported type of rate adaptation for a + * particular phy interface. This is used by phy consumers to determine + * whether to advertise lower-speed modes for that interface. It is + * assumed that if a rate adaptation mode is supported on an interface, + * then that interface's rate can be adapted to all slower link speeds + * supported by the phy. If iface is %PHY_INTERFACE_MODE_NA, and the phy + * supports any kind of rate adaptation for any interface, then it must + * return that rate adaptation mode (preferring %RATE_ADAPT_PAUSE, to + * %RATE_ADAPT_CRS). If the interface is not supported, this should + * return %RATE_ADAPT_NONE. + */ + int (*get_rate_adaptation)(struct phy_device *phydev, + phy_interface_t iface); + /* PHY Power Management */ /** @suspend: Suspend the hardware, saving state if needed */ int (*suspend)(struct phy_device *phydev); @@ -967,6 +984,7 @@ struct phy_fixup { const char *phy_speed_to_str(int speed); const char *phy_duplex_to_str(unsigned int duplex); +const char *phy_rate_adaptation_to_str(int rate_adaptation); /* A structure for mapping a particular speed and duplex * combination to a particular SUPPORTED and ADVERTISED value @@ -1681,6 +1699,8 @@ int phy_disable_interrupts(struct phy_device *phydev); void phy_request_interrupt(struct phy_device *phydev); void phy_free_interrupt(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); +int phy_get_rate_adaptation(struct phy_device *phydev, + phy_interface_t iface); void phy_set_max_speed(struct phy_device *phydev, u32 max_speed); void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode); void phy_advertise_supported(struct phy_device *phydev); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 2d5741fd44bb..49496acbeac9 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1840,6 +1840,20 @@ static inline int ethtool_validate_duplex(__u8 duplex) #define MASTER_SLAVE_STATE_SLAVE 3 #define MASTER_SLAVE_STATE_ERR 4 +/* These are used to throttle the rate of data on the phy interface when the + * native speed of the interface is higher than the link speed. These should + * not be used for phy interfaces which natively support multiple speeds (e.g. + * MII or SGMII). + */ +/* No rate adaptation performed. */ +#define RATE_ADAPT_NONE 0 +/* The phy sends pause frames to throttle the MAC. */ +#define RATE_ADAPT_PAUSE 1 +/* The phy asserts CRS to prevent the MAC from transmitting. */ +#define RATE_ADAPT_CRS 2 +/* The MAC is programmed with a sufficiently-large IPG. */ +#define RATE_ADAPT_OPEN_LOOP 3 + /* Which connector port. */ #define PORT_TP 0x00 #define PORT_AUI 0x01 @@ -2033,8 +2047,8 @@ enum ethtool_reset_flags { * reported consistently by PHYLIB. Read-only. * @master_slave_cfg: Master/slave port mode. * @master_slave_state: Master/slave port state. + * @rate_adaptation: Rate adaptation performed by the PHY * @reserved: Reserved for future use; see the note on reserved space. - * @reserved1: Reserved for future use; see the note on reserved space. * @link_mode_masks: Variable length bitmaps. * * If autonegotiation is disabled, the speed and @duplex represent the @@ -2085,7 +2099,7 @@ struct ethtool_link_settings { __u8 transceiver; __u8 master_slave_cfg; __u8 master_slave_state; - __u8 reserved1[1]; + __u8 rate_adaptation; __u32 reserved[7]; __u32 link_mode_masks[]; /* layout of link_mode_masks fields: diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index d2fb4f7be61b..3a5d81769ff4 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -242,6 +242,7 @@ enum { ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, /* u8 */ ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, /* u8 */ ETHTOOL_A_LINKMODES_LANES, /* u32 */ + ETHTOOL_A_LINKMODES_RATE_ADAPTATION, /* u8 */ /* add new constants above here */ __ETHTOOL_A_LINKMODES_CNT, diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 6a7308de192d..ef0ad300393a 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -571,6 +571,7 @@ static int ethtool_get_link_ksettings(struct net_device *dev, = __ETHTOOL_LINK_MODE_MASK_NU32; link_ksettings.base.master_slave_cfg = MASTER_SLAVE_CFG_UNSUPPORTED; link_ksettings.base.master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; + link_ksettings.base.rate_adaptation = RATE_ADAPT_NONE; return store_link_ksettings_for_user(useraddr, &link_ksettings); } diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c index 99b29b4fe947..7905bd985c7f 100644 --- a/net/ethtool/linkmodes.c +++ b/net/ethtool/linkmodes.c @@ -70,6 +70,7 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base, + nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */ + nla_total_size(sizeof(u32)) /* LINKMODES_LANES */ + nla_total_size(sizeof(u8)) /* LINKMODES_DUPLEX */ + + nla_total_size(sizeof(u8)) /* LINKMODES_RATE_ADAPTATION */ + 0; ret = ethnl_bitset_size(ksettings->link_modes.advertising, ksettings->link_modes.supported, @@ -143,6 +144,10 @@ static int linkmodes_fill_reply(struct sk_buff *skb, lsettings->master_slave_state)) return -EMSGSIZE; + if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_RATE_ADAPTATION, + lsettings->rate_adaptation)) + return -EMSGSIZE; + return 0; } From patchwork Thu Aug 18 16:46:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947458 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 2911BC00140 for ; Thu, 18 Aug 2022 16:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344928AbiHRQqx (ORCPT ); Thu, 18 Aug 2022 12:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345030AbiHRQqm (ORCPT ); Thu, 18 Aug 2022 12:46:42 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2050.outbound.protection.outlook.com [40.107.22.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250CBBFEB5; Thu, 18 Aug 2022 09:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0h5ZHuHA7e7zIkh15XD5zuzFqkVkISj13XrTla9br66uutJJNYPLnHSO/ZPkFjgSDRMcmrEsbZa3cOUWuNvOdw1YGJkv8I648zI59KMqrt1AwV9ZOvw1v1ozdAfrVpQrd7B6uMxyx4JhUwIDjS3V9fEOCyhkXqj86cU4hHfbYZgPzY30GxHoGfxtOIkSazPy9w3qEpd6wNIi3aXW92nB4EVFQUA9dx1eGwun25FiTVud5NjtZ29cLBRVOEHD2agnSvbBe8ZM7U6VVHT+GpvOCxfnkqj9vYlb+VzdZCDwd56u85i9xORnqgiC8xQeym5Dh9EsHRotAHGkBsA2izOsg== 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=s1rPMsKfqnEwh2ufY/Dqe8o4eHy5wNrBwrdjN0IPY74=; b=TFHmCM3TauiIPPUW6EbuwXYHaOWXzwayGzhrs6uwHYMWWqq/RiV3zyHZKLHaM+pVF982R9BeroTQnMTDz/DVd8WL5wYEjsMZmGQerkfEj3LaXJov8C7on6/Lo2drtsN0tHBcQb0MVySb9G6OOS5njCLYCViJ+OTxui1vpY4Rsq1iQfdeuuiBTkOJuq3aFNJRJDZccAmp4rpdan2cgjQQYrw6reqdaaNPIDkwITk85tOEZfHuOLxlEfXZX6UXoykE4Ku6VlTtYuJkMJkp83NsuNGBQEr/yQ3peAcLnAXinaG8DorsQ2wYseQFswlXKhCJesviV5iNETUtpEkSB8egTA== 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=s1rPMsKfqnEwh2ufY/Dqe8o4eHy5wNrBwrdjN0IPY74=; b=k6kaCNuomAHTgRT0Fv7HBJi0YaeZAgXLvZHc2GiyvZbViIDLXWrZZm1VFxiTU03YA04EAqVVFYJc07QWvyLQPpw0inw/5eRrfZSOF49VeNrhJXvOAmwWNC7DsV7LEThCBkJ8WYf2y/E0arjEZRZTEx9r8DzTZE3aAgY+fT+rvMQpr0Z2Kz8qIfY5K3wtSxV5oZIURQ4zDE63AYjes06ZTAxMaom6gzZ8uEprdTrSLvT/RONZIYDxnQjPe+ADhXnjvT0H03n6Wgf7XkVoUeJ7xQo7nN/qnvoPq5fNv55ApZcujBYqE5O9/DhZREYUms0aLq3OCQVQV9fGrLPhrd8u0A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:39 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:38 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 07/10] net: phylink: Adjust link settings based on rate adaptation Date: Thu, 18 Aug 2022 12:46:13 -0400 Message-Id: <20220818164616.2064242-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e56dee6a-1808-476d-bd1a-08da81393872 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tQKSFfzY+rMudDGHldlgub6fSRSgRlrurmmHTniJefpfHxzBNZbu/sE+GGcI0v3y8qIq4VGgEeci8o87gnAuKoVhrcCMtE2bEzgWlEeYzW1FdEvKtjBQo/vsjxZckZ4Ks4kMmCAqSRTldygZM1cx6WzRmbqmQGEttl7Fyb1WFnzUs/s2zVkB0Ot6/IZyaoFB5aaXtnkD0iqKTiH+SxNFXkLDQCs1XFBuxvzvQyuyxF/nT01/SV+ZPyPe5W7joNiNpTRhGl4m6mx7UDJYqfSe2XHlKeCn1M8j05MAvRVEwszRP+bsZKeoiXOmuWmshAE3pAabypYB+co2HOjX5Mr+lik34OCfAwJyst6ypPiraqz/p35U2ZSsIOv1tWvKCV5J57hdXr5+Z1GfOgtoGVXM/hh6/outUnYE5SsDqkXO9DmxXWMrsZJXTF0iPyLnmxZM/GSu9ORdFUxUs5K1tOMPtnlzxoATE7hJ+Yxqm8ldU9h2URJjAhaUwqDmApmNjbl1fxjlvncdFLpuptNxlP77osz/LM4YNyB8AAYwba9jPqLRj6nFg9uLw6TiQlzCgU5iuVvYfPaQnySbBqd712sm8fDfJY+EYR/uhy0AIGT30eVof/bjwMQN8kBVySvxbOkGlB1/1phaSMP/tluHu6CjJEkPKWi7pm+N6FQdJLMpQT76AAVqM4LFmyRN+VlBw0UJ/uVTi8Lj+61Rmwje2Oz+1szSBQEE84n0xLOwyseMGBBAMAFIcupNDNoR8s+YnGmGCtqpENSTCF6Ey0EzZ5mO0g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(84040400005)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BIr5+5F+1rhvmMgyImi1rJufzVpKkDtwxKOX6/K6ZmPTtDuqBLCZx9PADakxo+/mDzwLtHsgJaDkYqlUIk3RmjdglGP1Yn6rKMN//X5w8dDb/xTB+rX49EZsaSN4mzKQ8LDPJLIeGKeo6CE8e3yzBtMU0gQapRLEMnpB+QGbGaseEyywlrrAiR3PLacqVQpM5cAwob7i/OkfzI2QDw5iA49KGXRgPqUdNw5WM1qVSqLWkVpA0aO3gE/8AkLtX8KXl7KhY7yBLQxKTdgtVQHMGyxbEQUFYOyM0zoA2DagXTvhCIJWirebSHEhZZsGzYEHiZvVsx+/b48U3ugADc1klY7zAtpvuGCJiI5KFRPpFdbPC7cU8ytq+2Nl07VioINrQ9Zc3Zfi4ms7F1dtWZuw/AezqvO2gEDls87JApmKmPnbERI/Q+Ef0lkEISGPpwwdip047qaVX23xHn62Qs5I0x4kNI9tOXPt2GDuvOSpO3SVCnR2VZsXiVL396ru1zTINl7NtbCB27gnPvv/TMW0+468sLtBSriVgxmlLLMmu1Q5LejaGsmDZ6cTPBZVKVXomLa1UL6V+390bwhsQlDPsv35dNlWEE4v0DegrFXiUFnPGlkNqhDu+GNMPKbq8Ei8hsqMBnwVzFchpOt9ZYarbHmcYRI0rL4OHxCBGh7A4Dq/YycWP+IYEosC6h38jA2fEHT7duq55r9YAr4LBWdms+YhFuQWT20AjZ0IBWzciykVRoxkO3CEGdxIcuEDaNui3P/DvcvcUVPGWhv9jVOlEcgzkLkwN2FiTFh1jrIhYnTEobmeXI3PtjEECswT+HAxyapGxn6SE4fdts5EQ2WKcSJrpwo8gZJwCv7erMZnXfTxaGiFawTWVylVa2n2zXCc4Axj+nUBBcmNGG0yIUheq92zSULyKIM3zs8Mdr0ML0CZQMAuFeV/A+rdpwFoLEOmaO7HTJXLEp9GJ8XDdZ+sWmT6nHi0rAvjZbR8GxG2EA6xhZSUqnCqiSeuW7Uelg2niSy+0Fe8eggPQcfS89NuNoMRpaoEx+7lWe7Wr2bx6uXsXc17p33CR3gKjQ0Z8GmNzIt0PndoJhRXW1iZVMleFLMCqiDlm+09eUgl/wM9AntgG4bRZFXK1yqikv6Ie3XuellJ+iJdSmq9NDPA04E3jr4hgCNfth2n+/BnouGdzqhu0HtiDUd3j+RXKKgIXZTpA9XcSYsOGkvfpA4VE3PkuLn908Mpnx4Vq4oy51XjQc+o2c4fxrls1ouLepO6Wfyo1TYTvrRtjx6aaEjE1cA9pCDj977xX8rnYymCdPfswwIl8ErvZ/PPNLlfLpHe7WO/8gNQ4SH5+VvlgzVgSkHciCkJOvJhy0vNGmtFDzUypnEtk0p4Gwy2688LHLpG1dCKO/f/BtJZM9QVi1PCEiZ4Q5oYnqtk2Vn/YlBV0ZCaxyMnt/RFwvlW63jQvxcGi1HWJ3TYM+kt6Z1GBCtJQfmAcX29+0S3dRm+UwVneQftT8q6m7utthDPIQxAl0Xz1u1fhCP9T2Y/6/3pVP/ZurLkA9Uj3f9zHfOpz5pQsekcv1AW1o9zYIrtYvDXDqI6hm7M8xmRSjmtqpG0sxSmSI95cA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e56dee6a-1808-476d-bd1a-08da81393872 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:38.8383 (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: 7+ITgvZhQgj1hXkPtZFd7bFqhEi61/PKaSYe4RJcqxg2huR/ZOBGaLRgowz64gRVjfNWxidj/bz9WJWLI46MOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If the phy is configured to use pause-based rate adaptation, ensure that the link is full duplex with pause frame reception enabled. As suggested, if pause-based rate adaptation is enabled by the phy, then pause reception is unconditionally enabled. The interface duplex is determined based on the rate adaptation type. When rate adaptation is enabled, so is the speed. We assume the maximum interface speed is used. This is only relevant for MLO_AN_PHY. For MLO_AN_INBAND, the MAC/PCS's view of the interface speed will be used. Although there are no RATE_ADAPT_CRS phys in-tree, it has been added for comparison (and the implementation is quite simple). Co-developed-by: Russell King Signed-off-by: Sean Anderson --- Russell, I need your SoB as well as RB, since you wrote some of this. Changes in v4: - Remove phylink_interface_max_speed, which was accidentally added Changes in v3: - Modify link settings directly in phylink_link_up, instead of doing things more indirectly via link_*. Changes in v2: - Use the phy's rate adaptation setting to determine whether to use its link speed/duplex or the MAC's speed/duplex with MLO_AN_INBAND. - Always use the rate adaptation setting to determine the interface speed/duplex (instead of sometimes using the interface mode). drivers/net/phy/phylink.c | 136 ++++++++++++++++++++++++++++++++++---- include/linux/phylink.h | 5 ++ 2 files changed, 129 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 8a9da7449c73..3e4bbeb1fab2 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,6 +155,74 @@ 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 adaptation. + * + * 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: + 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) @@ -841,11 +909,12 @@ static void phylink_mac_config(struct phylink *pl, const struct phylink_link_state *state) { phylink_dbg(pl, - "%s: mode=%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n", + "%s: mode=%s/%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n", __func__, phylink_an_mode_str(pl->cur_link_an_mode), phy_modes(state->interface), phy_speed_to_str(state->speed), phy_duplex_to_str(state->duplex), + phy_rate_adaptation_to_str(state->rate_adaptation), __ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising, state->pause, state->link, state->an_enabled); @@ -982,7 +1051,8 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, linkmode_zero(state->lp_advertising); state->interface = pl->link_config.interface; state->an_enabled = pl->link_config.an_enabled; - if (state->an_enabled) { + state->rate_adaptation = pl->link_config.rate_adaptation; + if (state->an_enabled) { state->speed = SPEED_UNKNOWN; state->duplex = DUPLEX_UNKNOWN; state->pause = MLO_PAUSE_NONE; @@ -1065,19 +1135,45 @@ static void phylink_link_up(struct phylink *pl, struct phylink_link_state link_state) { struct net_device *ndev = pl->netdev; + int speed, duplex; + bool rx_pause; + + speed = link_state.speed; + duplex = link_state.duplex; + rx_pause = !!(link_state.pause & MLO_PAUSE_RX); + + switch (link_state.rate_adaptation) { + case RATE_ADAPT_PAUSE: + /* The PHY is doing rate adaption from the media rate (in + * 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); + duplex = DUPLEX_FULL; + rx_pause = true; + break; + + case RATE_ADAPT_CRS: + /* The PHY is doing rate adaption from the media rate (in + * 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); + duplex = DUPLEX_HALF; + break; + } pl->cur_interface = link_state.interface; + if (link_state.rate_adaptation == RATE_ADAPT_PAUSE) + link_state.pause |= MLO_PAUSE_RX; if (pl->pcs && pl->pcs->ops->pcs_link_up) pl->pcs->ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode, - pl->cur_interface, - link_state.speed, link_state.duplex); + pl->cur_interface, speed, duplex); - pl->mac_ops->mac_link_up(pl->config, pl->phydev, - pl->cur_link_an_mode, pl->cur_interface, - link_state.speed, link_state.duplex, - !!(link_state.pause & MLO_PAUSE_TX), - !!(link_state.pause & MLO_PAUSE_RX)); + pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode, + pl->cur_interface, speed, duplex, + !!(link_state.pause & MLO_PAUSE_TX), rx_pause); if (ndev) netif_carrier_on(ndev); @@ -1169,6 +1265,17 @@ static void phylink_resolve(struct work_struct *w) } link_state.interface = pl->phy_state.interface; + /* If we are doing rate adaptation, then the + * link speed/duplex comes from the PHY + */ + if (pl->phy_state.rate_adaptation) { + link_state.rate_adaptation = + pl->phy_state.rate_adaptation; + link_state.speed = pl->phy_state.speed; + link_state.duplex = + pl->phy_state.duplex; + } + /* If we have a PHY, we need to update with * the PHY flow control bits. */ @@ -1403,6 +1510,7 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) mutex_lock(&pl->state_mutex); pl->phy_state.speed = phydev->speed; pl->phy_state.duplex = phydev->duplex; + pl->phy_state.rate_adaptation = phydev->rate_adaptation; pl->phy_state.pause = MLO_PAUSE_NONE; if (tx_pause) pl->phy_state.pause |= MLO_PAUSE_TX; @@ -1414,10 +1522,11 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) phylink_run_resolve(pl); - phylink_dbg(pl, "phy link %s %s/%s/%s/%s\n", up ? "up" : "down", + phylink_dbg(pl, "phy link %s %s/%s/%s/%s/%s\n", up ? "up" : "down", phy_modes(phydev->interface), phy_speed_to_str(phydev->speed), phy_duplex_to_str(phydev->duplex), + phy_rate_adaptation_to_str(phydev->rate_adaptation), phylink_pause_to_str(pl->phy_state.pause)); } @@ -1481,6 +1590,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, pl->phy_state.pause = MLO_PAUSE_NONE; pl->phy_state.speed = SPEED_UNKNOWN; pl->phy_state.duplex = DUPLEX_UNKNOWN; + pl->phy_state.rate_adaptation = RATE_ADAPT_NONE; linkmode_copy(pl->supported, supported); linkmode_copy(pl->link_config.advertising, config.advertising); @@ -1923,8 +2033,10 @@ static void phylink_get_ksettings(const struct phylink_link_state *state, { phylink_merge_link_mode(kset->link_modes.advertising, state->advertising); linkmode_copy(kset->link_modes.lp_advertising, state->lp_advertising); - kset->base.speed = state->speed; - kset->base.duplex = state->duplex; + if (kset->base.rate_adaptation == RATE_ADAPT_NONE) { + kset->base.speed = state->speed; + kset->base.duplex = state->duplex; + } kset->base.autoneg = state->an_enabled ? AUTONEG_ENABLE : AUTONEG_DISABLE; } diff --git a/include/linux/phylink.h b/include/linux/phylink.h index a5a236cfacb6..192a18a8674a 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -75,6 +75,10 @@ static inline bool phylink_autoneg_inband(unsigned int mode) * @speed: link speed, one of the SPEED_* constants. * @duplex: link duplex mode, one of DUPLEX_* constants. * @pause: link pause state, described by MLO_PAUSE_* constants. + * @rate_adaptation: rate adaptation being performed, one of the RATE_ADAPT_* + * constants. If rate adaptation is taking place, then the speed/duplex of + * the medium link mode (@speed and @duplex) and the speed/duplex of the phy + * interface mode (@interface) are different. * @link: true if the link is up. * @an_enabled: true if autonegotiation is enabled/desired. * @an_complete: true if autonegotiation has completed. @@ -86,6 +90,7 @@ struct phylink_link_state { int speed; int duplex; int pause; + int rate_adaptation; unsigned int link:1; unsigned int an_enabled:1; unsigned int an_complete:1; From patchwork Thu Aug 18 16:46:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947459 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 A6D9CC32772 for ; Thu, 18 Aug 2022 16:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344931AbiHRQq4 (ORCPT ); Thu, 18 Aug 2022 12:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345032AbiHRQqn (ORCPT ); Thu, 18 Aug 2022 12:46:43 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2050.outbound.protection.outlook.com [40.107.22.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A18C3F58; Thu, 18 Aug 2022 09:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYQoFUnUYijqua8jO06+aWX6NSCqyIEHuZ7/v07b+WyIAmveNxF1wUDMoXxnsCM/5T8KCqGCNP2YeMKLtl/gNr1ADL//h9Gay84TGag6cK9HrIJYYlcgmOhD6nGEGF5DZfkSOyxibP9nbQULgPPOVAiOtGJb9StEzWb0PkjyQGr4rXOgg7/3IjxiE3BGxEc7BlhtKchsxhAogeTqSovphgYILOH26QFvWIL1aFTUX8QrheUh2mBj3DfQyxo9mPV/+qhduYNDCyfkuJb1daoxQK1xjKolCrlCta1G0cu84WCkPjO30dyGn1FyNqKn7cNXpjDjFnuR3aZUM9PNcsO+Yg== 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=YWTwdL8XYjWXUlCwYopbD4tR94omZLzELWNGk3uuUFA=; b=Zunudk/WkG5ZOdmESYMJO+P6Thv5uSOXm0p6eO8UxMFNESvu90fFGoY24Txe/yedekZA6+5i6x3OLutZu6KsB+ZpDvVsbIdsevseRG6F7Xt+BcpeQf2ymo0C1ltVajoxzmYcQbNiFytZHXSnCLTGi+ntHCRXJLaHe6fPVUUIm3YkQTx0rCJ0t9ONx8bt8+JpAFQIoQiYHFrmnPhLG5w2mlVw+hyO/MKqbFVrW6PxCwTJ4l9GdH9DOh7dk75NVbNg5qFHLbIdDRm4hXYAiAo1C6Ckw86ZGWRPHLQ70x27YeC89CXYuk5/UuIdqP9QwSyunBwB+nMhX/81UKsvMBiNTg== 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=YWTwdL8XYjWXUlCwYopbD4tR94omZLzELWNGk3uuUFA=; b=xhxCmPFuZw0x2Fq/uCsdQ6Y8bNglSN4EU4ukxNminSEUF4RYVYxBsriH9eLO73T/W/iD7t1fpQSAlgvRnyz1GJOwZrBwdH6/0YBhE6nPxlUekJyftE6XcQOEwHyYf1FYV9pJtnjto54bIJbzXIKpvOfy3y4Js+b9OK2cQ6x5iIkexmcbMRTj/NbUyL2HzAzc79o/+7bdvfmvvh9QRXYntQGyd7mKRdf3FDmeuWaemBK7QpcnKYbaKJ4ATLH/2GhNp6fLNms2FvKbkKbqp3FNPUnGQV94eQt8SHcINPbsaAvwox0fJsya/lIHQ37l0YcJYUP9QeOI0a9w15edVj+ohg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:40 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:40 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson Subject: [PATCH net-next v4 08/10] net: phylink: Adjust advertisement based on rate adaptation Date: Thu, 18 Aug 2022 12:46:14 -0400 Message-Id: <20220818164616.2064242-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8fb08306-f0b5-401c-5dac-08da8139397b X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HCjXou0EXB50zUyNhrJEIUvlqL9k3NBY4+no3gZzWCDDaaY5GtW+HVNyH+AW22P74qAv8jbRTH03w7yzurz41uawKiOtLbz0sukrv8zNETyCe2587OTFBBcC3enu8b2AKBWAJErx6yh3cIjYSoV6Pdz+0twdOlE3u0vJqwMt+G8bXI2XZseLshnvvuCgUoqP1Tiw3103feo8yEELEzZPWiYcwlK3IB5GE06jfWky7OEktefFU5DrQ8+3gz8wZgbcxI/6zbd/doLfFGmt7N8bGnP6p+HcYuExpIaLLzkRaL1rM+4tBgkBGOUQtG6oRxIWmW7mnBXlFcrCtZsjwiH33iW56UiIlssLTSKgIpLHzUDTjm5aRmQ4mPa9JvnTMf2uw87Gb3ygsLq/GIjYdc3+JmxdXxFXuDxQpKoEYGDTee7VV7X5bIpzBNc8Jgn72X09NNaRaAebWjMVR2CQ1F0JjUI949VMlQWo6gsV53wVtWgqw3ptHCzSYFcuC02IRYVbdu2RPxiR+z+t2BTPTjp4eN5TOTqP0wjgo0URnGPU3VhRU7g/9dUfOUFSnsWcO8+ziy3oO1iHavnBgwxG+TbAe7M77glNmSj+Jq8o8qDL11L8Q2KVK6S0Bwwvc99piVYBVZIOIgX9d6+QG+fFMSWFbbdITQnhUcdQ6cmquMmQeTmvkZcHVaSUxw+/2KA8AL69jNxkOEpgI8l9t700DukLbXr1mOePLXJnvUc1agU3tlbHWMh1dpUt3hTCMU3uefRA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(107886003)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KZIU2MBSNl8ayUPJPCHH9PpiusoGmxAnO8lgXST4bbSjqIk8R2W50wGL0Eg8X+7FY7gqlm0YIaL7p/qz5fvTqUOqF0jTUbZFr2SJ6SHKCOCh+a3elMnVbFhLpT4dHAZFQ1equZDjP6iyj8sSuG9FjmWernnMSApl5xZS6JAIIGuis9yp3kvzXsJWsdLgu2o8oxJwa/WyjhOIlaUq4IkjRHvMbCAJ44NI/s52CNckZdq7N0xl4caBSOpiDh/QFFcEdFv+agHJgQj/lydjZfE7JZSMovzUtlyl9BltprzIQgegzReFBmqr2TPlS+/kSqJZC1G/LG71UoJ8S++N+baJqEHYJOnw68E1wOAE0eVB2AgATkS2gMOU82a7tqVMOrmxuLhtPXIOWkkhQCXMzbKzRqN0M30cFUu7R2HYAkuIgNFhnBwEi1QN7a/mTD2xsyUN0n/WOUEL3f3/oitVcGGa4gEJl6fQUw7iueWkIAo9VGHnVHfeFd32Lu5Gq5f1wPCrQFsg+QaVWWFJttwyy2yJgQcOj2BnCrKXoZ4Aj1a3ZEl4s9yo3CHYXcJxkfwdfTCJKJVtc91ryUr1QLbW3HrFdTJdR49yopr7rsQJ5MzyHmJ9xUGzOUJqhuyucw4aJs6sXi++4s2P4Q3pWD8BzaXb6nfs7lQXpTesHgX+yb/AGsSMfBpIoFKPTkqQa+kG3eg/8jV9CBb67Nka94S2H0RwSnk0xzXzbGQ90/D3iMubAoPQUjErWJCrZc46biG0PVx/MjcQxl8iG+OjkDhiUL8SjoUtmWs/dUmAmmzROCeiXrHasZn/kVtXOdfwDnYMP9hdCpZzoYCUcjXjyby+tqQx7OyoeWXaokP6D5lJ2myxdKPORDl2qZvc0PFlCKhmkN8iXOkE04mvhPa1HOppV4V1rTzuTUqBXDE2bRLUVCzGknqmuem2Aj4MvX+4QNtnl9Ic9lNWqULQC9FPydrvK/QxEWr/Iyq7/X4JIWbIjdo48Qc6bibi8yDsTkavoGO8ekLJ0nLA3be6T6QkJBl6m29dctBA3tpf1RwMt/4k9HikNUCvRX08N1Hme4rHdmz6iRdWkxPosOwhtLFPy1v6quobRzr2waQ6h9r5UU9znYU1kZWKSDeOJFNLdTCZTRi4MF+qsmF9tkg1AlNGYo2pAvJ6Ypii0tDVbwey0znGmUvZyAeuV61S0hEhwOd2GD/fwizfB9Na340ZekQXVS+i1qqRO2GUHToNDomkadpvCt+PmAYIaG2d8NEb0thntd48z40drkZvmTt/kGwruvhkqxCJe+woGPJUCGc/HmSMK94m9ssyOURKn6WJXfGqAR+53s4HMMlShz6UqruNwaCM2xWq0IHANyuuyo2Xzlb8V+9ZI/boePM6tz1MDIIiPj8SgYsg+LJLnNAohQqBXrTdSwK5VobWQL577IIDMiCMhAeaE3kBzW0NOxcVyn6OYNMmwSY/DHgYTd+gncRp5aXaW903vawZ7/rYJZJxOfaP1tCiIMR+Gw+Xfx8GDugzhzUvyfua2Px1QdebdDwtkC0GxHU4N7cMQnUz0vsn7o0PanhEsokyh6dF80/AlgC9aScCE/DaD1QVFUvAekeRwXti6Y3Adw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fb08306-f0b5-401c-5dac-08da8139397b X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:40.5101 (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: Ra9MSjkgOdWzBefDvwVD/wkOb/MU1qCw9wUu9vt2PRuFJ4SyBmynfJ+WzzFQAADNGuCpNd7JLdAdQg5EkXWFpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for adjusting the advertisement for pause-based rate adaptation. This may result in a lossy link, since the final link settings are not adjusted. Asymmetric pause support is necessary. It would be possible for a MAC supporting only symmetric pause to use pause-based rate adaptation, but only if pause reception was enabled as well. Signed-off-by: Sean Anderson Reported-by: kernel test robot Reported-by: kernel test robot --- (no changes since v3) Changes in v3: - Add phylink_cap_from_speed_duplex to look up the mac capability corresponding to the interface's speed. - Include RATE_ADAPT_CRS; it's a few lines and it doesn't hurt. Changes in v2: - Determine the interface speed and max mac speed directly instead of guessing based on the caps. drivers/net/phy/phylink.c | 58 +++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 3 +- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 3e4bbeb1fab2..6cc033148ebf 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -433,14 +433,18 @@ EXPORT_SYMBOL_GPL(phylink_caps_find_max_speed); * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t * @mac_capabilities: bitmask of MAC capabilities + * @rate_adaptation: type of rate adaptation being performed * * Get the MAC capabilities that are supported by the @interface mode and * @mac_capabilities. */ unsigned long phylink_get_capabilities(phy_interface_t interface, - unsigned long mac_capabilities) + unsigned long mac_capabilities, + int rate_adaptation) { + int max_speed = phylink_interface_max_speed(interface); unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; + unsigned long adapted_caps = 0; switch (interface) { case PHY_INTERFACE_MODE_USXGMII: @@ -513,7 +517,53 @@ unsigned long phylink_get_capabilities(phy_interface_t interface, break; } - return caps & mac_capabilities; + switch (rate_adaptation) { + case RATE_ADAPT_OPEN_LOOP: + /* TODO */ + fallthrough; + case RATE_ADAPT_NONE: + adapted_caps = 0; + break; + case RATE_ADAPT_PAUSE: { + /* The MAC must support asymmetric pause towards the local + * device for this. We could allow just symmetric pause, but + * then we might have to renegotiate if the link partner + * doesn't support pause. This is because there's no way to + * accept pause frames without transmitting them if we only + * support symmetric pause. + */ + if (!(mac_capabilities & MAC_SYM_PAUSE) || + !(mac_capabilities & MAC_ASYM_PAUSE)) + break; + + /* We can't adapt if the MAC doesn't support the interface's + * max speed at full duplex. + */ + if (mac_capabilities & + phylink_cap_from_speed_duplex(max_speed, DUPLEX_FULL)) { + /* Although a duplex-adapting phy might exist, we + * conservatively remove these modes because the MAC + * will not be aware of the half-duplex nature of the + * link. + */ + adapted_caps = GENMASK(__fls(caps), __fls(MAC_10HD)); + adapted_caps &= ~(MAC_1000HD | MAC_100HD | MAC_10HD); + } + break; + } + case RATE_ADAPT_CRS: + /* The MAC must support half duplex at the interface's max + * speed. + */ + if (mac_capabilities & + phylink_cap_from_speed_duplex(max_speed, DUPLEX_HALF)) { + adapted_caps = GENMASK(__fls(caps), __fls(MAC_10HD)); + adapted_caps &= mac_capabilities; + } + break; + } + + return (caps & mac_capabilities) | adapted_caps; } EXPORT_SYMBOL_GPL(phylink_get_capabilities); @@ -537,7 +587,8 @@ void phylink_generic_validate(struct phylink_config *config, phylink_set_port_modes(mask); phylink_set(mask, Autoneg); caps = phylink_get_capabilities(state->interface, - config->mac_capabilities); + config->mac_capabilities, + state->rate_adaptation); phylink_caps_to_linkmodes(mask, caps); linkmode_and(supported, supported, mask); @@ -1563,6 +1614,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, config.interface = PHY_INTERFACE_MODE_NA; else config.interface = interface; + config.rate_adaptation = phy_get_rate_adaptation(phy, config.interface); ret = phylink_validate(pl, supported, &config); if (ret) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 192a18a8674a..265a344e1039 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -543,7 +543,8 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); int phylink_caps_find_max_speed(unsigned long caps, int *speed, unsigned int *duplex); unsigned long phylink_get_capabilities(phy_interface_t interface, - unsigned long mac_capabilities); + unsigned long mac_capabilities, + int rate_adaptation); void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state); From patchwork Thu Aug 18 16:46:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947460 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 1F9D9C2BB41 for ; Thu, 18 Aug 2022 16:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344961AbiHRQq5 (ORCPT ); Thu, 18 Aug 2022 12:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345037AbiHRQqo (ORCPT ); Thu, 18 Aug 2022 12:46:44 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2050.outbound.protection.outlook.com [40.107.22.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF17CBA9DE; Thu, 18 Aug 2022 09:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjCDbIt4Gz8xSBJiosVcS8n15zF2y3CDcEcjrwU8M6Lvc1v95AT7JkjZqHedgJisUsj2+/kAPhKUqwpBVR0xkBFcfnzhggx7tIaXjJKZZpKJifaRjz89QOrJQvvnEMb+c3uq8LnV+jM7ODlIJ0EafzCpk8+Q2Jw4Ag5whUILLQtb37lxlucf6zeEc1HAl44YdOZ5UhZAUqSmp/NXH+6uFwykx/VHM7yDr9mkyq3o5X/08fQ3iYFSYJ0zeFBi3EoUj5Cutr6aulY0UCWaJ9xShRNBy5oJVfbnYkgrPJIAfoR2Bc1sQJdzbF+exvWOJDxHeahiKjIcOkHgTIdmNfqzMQ== 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=msiT+UkpoCrjHVQp2GSjV0d6CwJSb1xGjry1C/EbVZU=; b=Z1GswzkMr78kTpH64To21hPZzEs031WsiyPjs9zH9jMgMnRxBTNZEpoWapK9772YYYR8347RYH/9E8jOqzQygeIAMIbu5MewS4SVMMlxsSsmR0JPIKo6R03pxtnAKk55uMT4XosLv3QRbl0UC333StNKVXNOnVldqlHwduAG3+xUnQz1AeVP9xAZ7L3TEs2zlRscNwflPADL1CijhHid6wfUjkkH54pVNXlh0gXXs6HjwlysNmb/KtoRzh4gZG+8i22c0kDRTfXMMw2B8cnslvDf0FcCdMhIF5chT/TtvZAGJ8Ea1Jo3lbgbu3kamPWDk44eZuWGsDs+2BP+WpYO8g== 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=msiT+UkpoCrjHVQp2GSjV0d6CwJSb1xGjry1C/EbVZU=; b=jnur/gNwNzq/vNvaQ02j4yC1gnMrSm6BhzIt3Co07BeKzZaimHjJNElq3kFyTEWO2vj/hvatVwfB1wFFzVOQUDWt/fWgti+XMrQjLxlYcMTva7aZk5uWmAq8pBXw9rnOUQbS5v9PoXr4uFsRj+jsFgZYNKDEfPi6gxfyPYkORRRksYIN79oQmoVQletiY3giFmIQll2Deo6sX1fFpagiX3kid4I/9qrCue+FCwVH1nI+vnJhFD/uFHdyKqUMbMlND/PfkVs6fQywDoazKMxq/a7faw7mY9qGjqn/8oE56UR0gN55Y5Wq4WQKVOBRObCfUjotzcMd1l3HkPkG/sXltg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:42 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:42 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v4 09/10] net: phy: aquantia: Add some additional phy interfaces Date: Thu, 18 Aug 2022 12:46:15 -0400 Message-Id: <20220818164616.2064242-10-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15876b1f-f863-44e4-608e-08da81393a86 X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iF9Tp1nqjNxXXvCROrw99ayG8q+aBLFJmhEbm/4Ix1JZuzkckBoDQWjbbXhPvTKjoGzJRUuqzuoaBxYkEqs0yUQqWAGOgqVZ0xA1fW9t4DSnCPvOAjrZCSaq48nDvmVQpzdMYB35dCfa1WwcNShDriXgb45c2y1Qj+db4ti9zwxRFF6ZvVZnALthyQXgo1bJtJwOjhB75h+r63wHHymSYLSgHqC2WYp4at6NBsFaLX8CCYcXGr9MdNlTcObSlLFZ6PUTfEkd8eGHh4WkSisFple+Q/emwziqUY+Wox0vGBVbi8mgHZaOng8plNRRphThnlA/p8ZZHug7pP7hDJ3NrO9563HP36MzlZZzQhtgYPC3Cy/KreQ7gRaWD6vhkCmS4VmtELE/p3NbnZ9CfBviAoke/oLDViig5j+GZwr/j0XL2SyRlOBSzRzx985IIIN0IWwIm+haZBGUoIJrkByuqErU1gKU5EsFq23P55hoWotuwkagZYFJaRTfbsLWM+/6Uckq48Mj0gcqDzRbfGQTYCyc358uo3XdI4O507M8/zI6CsblzDnX37loJrDnLFbqRgM7J9B6/xwyHTqoVYRWbJ9fTG9yH9BFkSUqXTFj0a4rAZTpIW7VfOdNUmQLJ2X9g5qIWprsheEfvZW3SotkVbAXaJ2kti/pe+pJXgUxdlAP9se+U7RLUTF+niJIEwsiM8lRc17hQFPSiAJmv16tVOn98owXPodOCJRhDRq1P1I1eY5BUPFO2Z4dtix+aXif4RSJ2seduDuQ3vbIjmLBSg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nbetuu1fRr5Ipxz8dN9L5XFdeF25T79Y1HFKVGqbfG8GCgW4auln/z5Cub44OupRCthj0gJc7QnKJbnDtevnm2Ef/tAZq0hFJLLD6RE3wLII36hUJpmairIRfoG9JzvgXoJ4mgKof3HxAs2dZfzPoaW1FiIW9X+2L2xIlJTgWaxldcGbFYlgT/WQ3STRPmO8/aN6TO55PobemIw7B6b9L2Na5dkPTWZrwjJTooWSjYK23QL2+YogN10Ndu3X9jc1hOOBj2ioVzglz0+aWKrctnA67Ol/ept+TFXL3fjxY+DHcVJmyk/MPnyMjXKh0DPIQ3NE8hHS2WX7GsnoXVmsN5EZyA2Ycrtp3ypX/QwyidiEViGMI9g6d6L0w6XTBFIfmsP1QSeiYH4K1sxA3A6cTlqy9uqUMU0UF4ZiFlpD4Vr2Wq3LWKPpUuxwrGwTzEkuZVvjphZGkEQFLuYDqS4FxmiUJ3WeV2egXIVFxWXvHHH6bnqcPres2SAj3G0E9ndD0edix/R7oukHsRP6jMADz9DH45M1YoGzT3JGcczJTjUPGMkBfBd3Qz/WGoNnoTRaf5axjU661UKoIboPrqlvQDYKiLspHnORon5XuTUJgIbpDI7FO0Ulj+ML8eUKgauT6xm3ifNBZiQNpbcgtsX9TrM/usS3O5xQ3QqpmuTG3nctFTypBHPWjk1ErLubjb9WNgUyzSNJjehym4vdz2Nx+VWZP7lL4gPSEZy8wow5qSI9MavCW4FrAizk4n1/j0Xb+nLj14EXtYfQH3dI8kXHMa8SoBeewPeqE8fMd006uMK3qOTZPZfugGIoU7DxsR57xCzhVUEfPtxSvpwbHWPmJXzM36FghHJAWT5FiadzFdgG4JAgKALlwE2o6fol6mbJ5SVGDcwj0MMVpTgcKeozfJy5DSCl2NYwWVp66h1W5LQvJCHFHQL6DfmoixEsDzBaQmCq0N12tpxYAfDeNBQcFOLPNe8AlOqpU9D097df2rJ4TOhGHv4ytySKFvIOR7hLA6aaZ5wvuwp4EWRC5pwxJs9v0qFxVk1TR0iDcdKqV/gCpviyxhO9VI0EKRs6yqkXA2KK4rO5lNuMyThhiNJqR2jJiUeE4dLD14/f1M6uhIoY6JUQnEIrIJD59SA1K6iUZrtvtVzPoEKvV12WNQQ+mPNU/O73ZI9kbwcSeNMY7+voGzsXwnnaW2TaQTPrrvSy37gBBYTbJpry+RYR2mujy/E7jWyACNcinyWHzuWhoMPkHX9PKwaDb/+NRuUulZDDQmvat+cSnlkP9thIAtTJLbtN68d7SzOaHSseA4fUFp3pBgEZSrmT0DqCB+0XKtG4HEeGmRY/wOOdjyuNnWmUnMS6J1q1mhrCK6+3QcaNjKYLue2zRSrLiJRqnX2RvsGvaVgsmbmo40QkZOpF5W9TCUCLNN51nylTqRo0EOBIqBS+C5dRp9c/dgbKz16xqwKLrRhGc0jIAv8TR5FY4ksf8PiuHgnCAFVfaBcJ6HQCoQt4JUh9iBuH5BkhYeGa/05hyGyn9TlQzE8JpOYRuwrqnioMo/OsswlDYPhOjF7zJOY8rwKIGzDJNBIyWxK3FMZ7+3D75tr86M76Oy0kFArooA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15876b1f-f863-44e4-608e-08da81393a86 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:42.5569 (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: b9fwp5ZahWXV2qPkSB7SZuwYvYrTNEpsAe6K5MwsQZblzsoL+vxGhFxDlsf4uN+JdDANSQAJYSx4Vvdy7YClCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These are documented in the AQR115 register reference. I haven't tested them, but perhaps they'll be useful to someone. Signed-off-by: Sean Anderson Reviewed-by: Andrew Lunn --- (no changes since v3) Changes in v3: - Move unused defines to next commit (where they will be used) drivers/net/phy/aquantia_main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 8b7a46db30e0..b3a5db487e52 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -27,9 +27,12 @@ #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR 0 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_KX 1 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI 2 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII 3 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_XAUI 4 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII 6 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_RXAUI 7 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII 10 #define MDIO_AN_VEND_PROV 0xc400 @@ -392,15 +395,24 @@ static int aqr107_read_status(struct phy_device *phydev) case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR: phydev->interface = PHY_INTERFACE_MODE_10GKR; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KX: + phydev->interface = PHY_INTERFACE_MODE_1000BASEKX; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI: phydev->interface = PHY_INTERFACE_MODE_10GBASER; break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII: phydev->interface = PHY_INTERFACE_MODE_USXGMII; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XAUI: + phydev->interface = PHY_INTERFACE_MODE_XAUI; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII: phydev->interface = PHY_INTERFACE_MODE_SGMII; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_RXAUI: + phydev->interface = PHY_INTERFACE_MODE_RXAUI; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII: phydev->interface = PHY_INTERFACE_MODE_2500BASEX; break; @@ -513,11 +525,14 @@ static int aqr107_config_init(struct phy_device *phydev) /* Check that the PHY interface type is compatible */ if (phydev->interface != PHY_INTERFACE_MODE_SGMII && + phydev->interface != PHY_INTERFACE_MODE_1000BASEKX && phydev->interface != PHY_INTERFACE_MODE_2500BASEX && phydev->interface != PHY_INTERFACE_MODE_XGMII && phydev->interface != PHY_INTERFACE_MODE_USXGMII && phydev->interface != PHY_INTERFACE_MODE_10GKR && - phydev->interface != PHY_INTERFACE_MODE_10GBASER) + phydev->interface != PHY_INTERFACE_MODE_10GBASER && + phydev->interface != PHY_INTERFACE_MODE_XAUI && + phydev->interface != PHY_INTERFACE_MODE_RXAUI) return -ENODEV; WARN(phydev->interface == PHY_INTERFACE_MODE_XGMII, From patchwork Thu Aug 18 16:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12947461 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 6539DC00140 for ; Thu, 18 Aug 2022 16:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344964AbiHRQq6 (ORCPT ); Thu, 18 Aug 2022 12:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344978AbiHRQqw (ORCPT ); Thu, 18 Aug 2022 12:46:52 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5656C57B7; Thu, 18 Aug 2022 09:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q51r1Hi4W1oIOErTUPRNgIUfr+YMkta7XtbAlhCLoJ9RXZFBj56YBQo81Oo0oSw7g/8d5pyAMQi10j6hARcpcwp7b1pDGrMW3TVsIiNJ1oHM8cMAYmaR1k32qmmcuoYxA9Nqc3ZcFeP02Uew5ZTuNqy2EEOSS8yLszvd+1ic5szGu6u3f+taC/5OuAmmcZXzIzjU1M8enIzs952Km08fxTQp3WJg+M9iPyyqR085VcnNaZTSHZeZQ4B6sYPfgU+4okdhAxxZlMl/pDMVq22HUjAT/UYHwNt8EGMJ2Hk4SFFpXY8P+yJEcs09xos0Hd0JTbztM4E4c+9E8FNVxatk0w== 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=NsV7YGT9vGnTEtFTU15G2k9BWfNRzFNNm89ghHTwVzc=; b=StEYJHbre8s3B59PurtNajP/c0/Eq7ay8dkc6eK27Me9J9q+vHnKSLVzNUfYR32zz5Khhlvq4oKb4+7TMg1t7nRAy69mL1wIM+EnBWkEdnlGmgm2D4G/b10XvNhPICvxsyAupc3CklndyZcXFDI6LyRRBa94Pgbvm5dJS3+HVnDuL+OqfkWsT3UN2hVVLWkne/ZiKPf+8pvp0O2hu8dtmm+FC1HP/nea4j8knHL7rvTP6/0pxAtTXbXHjZ1zus+Um8eA7h9+SnCIu0BU4nCzcain4yyPfLA89EFRirglUqUoIw9CiZZfDcD+VHi6QwpmYNN4XJ+BgepYNr1MYCOrgw== 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=NsV7YGT9vGnTEtFTU15G2k9BWfNRzFNNm89ghHTwVzc=; b=PPS0PK4RP6u7eGCoLBTg4GLFWUfO4tvFkF0IzjEeTZXmuvfKWmJ2dZ5m6DOcW9oqHuLvvfnzxqsvsRCJHVOsxRITOI9WtUE6oY2l7Zvr7ZnvpCMCHt1yHHq53cZczyh2PsRM81XuTMSg9lMskNtEUl+9NriBDeX1DgieqoV7rLaPld5UR18Y515ewGjbA+GU+BUptYDsRv3oVaCVPoglaU7uhAfhhung+sNJ1dUMFHEnf4CRLZ+KcUBXZslpRiXMxrF4B9EfRm7B3pUGdv4OpS55pk9vw5BNLHJj1Ub3xkZcfQ10tdxfrC6lsleRCB0jjswl48+hgXlMliO6TYQ+NQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by PAXPR03MB7649.eurprd03.prod.outlook.com (2603:10a6:102:1dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 16:46:44 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.019; Thu, 18 Aug 2022 16:46:44 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: "David S . Miller" , Paolo Abeni , Vladimir Oltean , linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Alexandru Marginean , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v4 10/10] net: phy: aquantia: Add support for rate adaptation Date: Thu, 18 Aug 2022 12:46:16 -0400 Message-Id: <20220818164616.2064242-11-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220818164616.2064242-1-sean.anderson@seco.com> References: <20220818164616.2064242-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:208:1a0::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b9c7228-41d3-4724-fd48-08da81393bcc X-MS-TrafficTypeDiagnostic: PAXPR03MB7649:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LNAdMpmBX6hCTpm5Uo7dezcXMdZ/l/mHbAf11kALSSd8Idv2JPa3lPiX7EsdNV/sxl8xMJlVIHT7dgfl6xJD5AGtfpbiD23D0UxF5knDaV08fiyjguY8ZvAMxSjqv5Ous5SIWJu0j6kdotY/nkle69r7i0+P80YDNUr2MKREms9RxJjt9o0s6RXXNe3SOsiLA0+VuqsUYYudiUVwU1cM38a3mGLsCmaWFOb009zdCUhtCuwrvrDZJCHsTXZbM2GX47IzU1utxuqYu1ASqWPki0SA5fGtT0JS7JTRd07aU5RFBpW33l5FUrpId0WLetqR41RwP7WbcMt+XAJNpMoocnhb5NK28fGzqQjjtBgmGVeU8+dwHUrZ4tqkgeUDj1YRHjVGsgctX7bLwGBlXR2lH3JyJdke/X2U0zjykR+Ph9M+QGiVPBLtDu0hswThTbrJnOEMba4+58DQBGX979/LqPH4WpGJZDIWhGSSfA85+U6q+/3Ok8Wh/B1wbbFy7CtE6cJTbXz0pPLCeBlP0S2sQR+swu8dqPg2wmqFO5gZpoY+x8deMVi1VOOrUnY+baIODMS/n6CducRlvEW7Y9zYWfqiqoGuEoyKngVSfGANu8Qeick8CTEBafEkgOufTxXWLnauB3qVwS+RnVYwIDjdedaAGNUOsnYCumYfZNNZqca2em/RQnWuKHRQqgSOpzt7IgdSw5D7eE6fK9LX4frfnLkgMOYlAyodczHxBU2Cpvx4F2uGBP6O990kWM5afxlOBESvhuQXURBfCajEr719ug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(396003)(346002)(376002)(366004)(136003)(66476007)(66946007)(478600001)(66556008)(6486002)(8676002)(2906002)(41300700001)(6512007)(86362001)(52116002)(4326008)(6666004)(186003)(1076003)(2616005)(7416002)(44832011)(5660300002)(26005)(8936002)(36756003)(54906003)(110136005)(6506007)(38350700002)(38100700002)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9Icr2wjw9R/9aOw0w5KIl/wVXFJACpu/loe8nxlAXPPhN23gBInjGf7Mx9g2WVDx/OumbwCO4/SvFEb0Wo+3zJW0FR4UzyF+sLGO4eofgnyic/wOyXqGXT9WbrUEVq1kiqK6mBJOhDvz2X2ZRWlkwG1V1bkgAroali6xVlbgzukoyppegSKNFz3NKINghsaRQCIZb/rhCwzT9kSjPFZ1TCuNCtW7qKxnBJpoRWgwoj3+IkbFQvKkTk99ViyemUCHy93BH+tG34D6zOUIaYDIdgW+WCr1jizzsx25Y3LX1LasZ3IRXbYUhBAS9FO0UA2c6Xno8mTjHj+WmXs/w5Nwbtf4eX7e8frW8x0wK9ekLVA1aBCWO3U4mKPOs3hy++zcsJp+okDG77libgzVnvtig2l117H0k89peh5XbLVMxNtQ9BJ4BNk+6UXWJX8rzjvOfWMsMneKRKSYqgOpn6gdgWwnTVDhJkp+hOe6aS6ItshC8nNXj5mZ046GSspV4yl2L0izhRclXS3s4bkFnx5p5FgQy3u8yhNBxedrbiwvPQwv1QKKnf0aHzcC/CmtUma8hNeUR5rPLr5dpdU7MLirwol1SEM26t2LzTv3L6TP3Ol/2Fj9CPoCmNj+DchfFHPQ8jJ40EH4hW0CR70VhFbjN5prQlDQgTm2FLuo18/T0l1JZHQe5QPFLComEk3oy32tkyAEx3OuI9k3EkBe8omfs/hDRYMEvS75WCptgC4I7HwWmNyGw74xTxQVYqcQoNAjy0xnxd2kpT94fWuOD4edTNaijaWGJvnJ3/sdUh5fgHoYhmiIRz8HERSZb70ofPWGEOh/tDYaNIbcsvGRh9wO8o5Mch3sMf3HvsyFbO6Zh69bk6EHtx5Ap8MeCNrkXwbQpNdImUgh0zr4z2DMGck04VG5yK5ULKVr+TBRABmSLhkF9yhYfSZpCK4RwSy83o3mpamMxfb2s8R+UIHF3p3pGvBNpmQDp+6CbNmnPEaxe+S1lYIRcIF/3CXzQMWkHxSHvwldh2fY1Vv2R4E7Xb0iv/PeLQxBsrQSNQdyc1/qu4Ez/2lq9Z/84rRkZcpXAoie3WimjMcJtRuN9sU7gbMw1GOL4kL3nbc/c4DEvpvK19UfI+ICEioOjXXTd0laKlunJDBVthA/a8lVRuwdvP4SYVx/i8o19gFS46tpHubBOAgT6dULG0/54DCZQi8FDri9u40elhhYealzNLvBHMk/RApGYAq7nhMDDIjQM7mnSvce8sFhet4AarTxLFcJazE+jwLNIkulB66RHK9x7xKXlpw6hERIjNMsqER47ITJD09iu0eyCp2Jf+1SkIYrQnbJfhsKvmoBbqPpCGUo2eNHJVxsiV5U7BA26J8Ax0bvzOIswtmX9Kkdu+Rf3XmnxTLFCsRBntpyhoR8GR0sEd4XgZcHRt5GiXrhpOJyGUQCO/k9h5hknMzzsskKtjxgcLoBjjJs7jo0ULrptMj+p8+xm3ACvo5jPvBVgFm5Y3H8rTr5RX1+An1TSplx7WKbcpCp2QTc2MBVsO9pO0xbiKR6LCWIUoI9dRuXTz4pfnnMXp+iel8/H2PeKpywDrOSbc9r1YXT4e/4tf0vFGmcre+wMg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b9c7228-41d3-4724-fd48-08da81393bcc X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 16:46:44.4161 (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: KABeZjWI9Tqeq6fQJVt91S83pdbwULsjA5s3Y+O4gvgrCVyfw5wpy1JyfuHJRdnt8q47jkv9aEm79m3Sw1jSdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7649 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for rate adaptation for phys similar to the AQR107. We assume that all phys using aqr107_read_status support rate adaptation. However, it could be possible to determine support based on the firmware revision if there are phys discovered which do not support rate adaptation. However, as rate adaptation is advertised in the datasheets for these phys, I suspect it is supported most boards. Despite the name, the "config" registers are updated with the current rate adaptation method (if any). Because they appear to be updated automatically, I don't know if these registers can be used to disable rate adaptation. Signed-off-by: Sean Anderson --- (no changes since v2) Changes in v2: - Add comments clarifying the register defines - Reorder variables in aqr107_read_rate drivers/net/phy/aquantia_main.c | 51 ++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index b3a5db487e52..dd73891cf68a 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -94,6 +94,19 @@ #define VEND1_GLOBAL_FW_ID_MAJOR GENMASK(15, 8) #define VEND1_GLOBAL_FW_ID_MINOR GENMASK(7, 0) +/* The following registers all have similar layouts; first the registers... */ +#define VEND1_GLOBAL_CFG_10M 0x0310 +#define VEND1_GLOBAL_CFG_100M 0x031b +#define VEND1_GLOBAL_CFG_1G 0x031c +#define VEND1_GLOBAL_CFG_2_5G 0x031d +#define VEND1_GLOBAL_CFG_5G 0x031e +#define VEND1_GLOBAL_CFG_10G 0x031f +/* ...and now the fields */ +#define VEND1_GLOBAL_CFG_RATE_ADAPT GENMASK(8, 7) +#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_RSVD_STAT1 0xc885 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID GENMASK(7, 4) #define VEND1_GLOBAL_RSVD_STAT1_PROV_ID GENMASK(3, 0) @@ -338,40 +351,57 @@ static int aqr_read_status(struct phy_device *phydev) static int aqr107_read_rate(struct phy_device *phydev) { + u32 config_reg; int val; val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_STATUS1); if (val < 0) return val; + if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + switch (FIELD_GET(MDIO_AN_TX_VEND_STATUS1_RATE_MASK, val)) { case MDIO_AN_TX_VEND_STATUS1_10BASET: phydev->speed = SPEED_10; + config_reg = VEND1_GLOBAL_CFG_10M; break; case MDIO_AN_TX_VEND_STATUS1_100BASETX: phydev->speed = SPEED_100; + config_reg = VEND1_GLOBAL_CFG_100M; break; case MDIO_AN_TX_VEND_STATUS1_1000BASET: phydev->speed = SPEED_1000; + config_reg = VEND1_GLOBAL_CFG_1G; break; case MDIO_AN_TX_VEND_STATUS1_2500BASET: phydev->speed = SPEED_2500; + config_reg = VEND1_GLOBAL_CFG_2_5G; break; case MDIO_AN_TX_VEND_STATUS1_5000BASET: phydev->speed = SPEED_5000; + config_reg = VEND1_GLOBAL_CFG_5G; break; case MDIO_AN_TX_VEND_STATUS1_10GBASET: phydev->speed = SPEED_10000; + config_reg = VEND1_GLOBAL_CFG_10G; break; default: phydev->speed = SPEED_UNKNOWN; - break; + return 0; } - if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) - phydev->duplex = DUPLEX_FULL; + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, config_reg); + if (val < 0) + return val; + + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) == + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + phydev->rate_adaptation = RATE_ADAPT_PAUSE; else - phydev->duplex = DUPLEX_HALF; + phydev->rate_adaptation = RATE_ADAPT_NONE; return 0; } @@ -612,6 +642,16 @@ static void aqr107_link_change_notify(struct phy_device *phydev) phydev_info(phydev, "Aquantia 1000Base-T2 mode active\n"); } +static int aqr107_get_rate_adaptation(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_ADAPT_PAUSE; + return RATE_ADAPT_NONE; +} + static int aqr107_suspend(struct phy_device *phydev) { return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MDIO_CTRL1, @@ -673,6 +713,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR107), .name = "Aquantia AQR107", .probe = aqr107_probe, + .get_rate_adaptation = aqr107_get_rate_adaptation, .config_init = aqr107_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, @@ -691,6 +732,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQCS109), .name = "Aquantia AQCS109", .probe = aqr107_probe, + .get_rate_adaptation = aqr107_get_rate_adaptation, .config_init = aqcs109_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, @@ -717,6 +759,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C), .name = "Aquantia AQR113C", .probe = aqr107_probe, + .get_rate_adaptation = aqr107_get_rate_adaptation, .config_init = aqr107_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr,