From patchwork Tue Sep 6 16:18:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967779 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 3B801ECAAA1 for ; Tue, 6 Sep 2022 16:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234258AbiIFQlR (ORCPT ); Tue, 6 Sep 2022 12:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234407AbiIFQkq (ORCPT ); Tue, 6 Sep 2022 12:40:46 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2076.outbound.protection.outlook.com [40.107.104.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4750F86C32; Tue, 6 Sep 2022 09:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZidSmAHGIcOvST8aIPSSshZ0Yg7DR85LUbn/EBoicjnCVRIBqLxlEJfiMCr/ld+VxHbv7POpLKYbWhxEWRbTmKPIt98RWLPo6k1AtrRp6SLf+aTIwiDcO4WgrjnTsDVmSj90Q2d/b5g/2fEpspmadd8PzePxsr7EeQj0mqlcPVfLIT3hElJaikGhzcs6xKh+kzEwb+3YCuJ0snrUkgv/9JtUvJOduaIOdDOOQpRr4sWUWMfxkglzuZ3/vbFwjgrP0wYsNxIfLN0MCXmVDyl9eJsL/J2Os+dYr2MYchXK+Shb63rlzEEqS8r8lagH9USDn9tnzMT5+AhHGsdyvyI/7A== 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=wxDmg6qikYu4QbaUo/BH/zYEJpPBspYcp6K1wav/omI=; b=dlObrz2XuCxaFckno9odiaGvLShuBscu54uI13n/iRuKsFdBCSG+40+xHmTx6jo0LYJn+C2V4CoZgUQ4XVl/uHxm4VaESh2K0wJY9mZbagoB/cQnXuxtZthR91a9MQLGCTe1XrjYZnLladUHHyYy9PKPVo48sQ3LyXfhEdOqEpjEDWWCLSgI2qQtT4N1ea2aOhrwDsIYei0yadxCsDxeYnl2h3f26OJsqF/u/6LstcaZset0tWFdb9VLNkklVSnYJ7uOncEni/MWOeVt5R44kgoTfATFwCfsZ8nFvDtbr2bwWHNMcI+v6vW0f38QhoUP9oZ5dNjzEomBPOPpUs8kSg== 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=wxDmg6qikYu4QbaUo/BH/zYEJpPBspYcp6K1wav/omI=; b=JjndIRot23LKS9zpLcnRs2niL7WM0Xe6dUV/0IuifZ32quK6Er7g6lS/Z2BiEja3Tg9TtaStOXo1JSlQZxQD0yFno1aEPZBtxGyUO9aNIakwv+LubE2GYjSO0O6jSxsGQI8hA4gRWYnLRtANz4hIRvndFbU8fl33UvBQsl2jQcTE1FjGGUxiXZ9AxHVjFCoN2VQXhJvZrQMfyIuZUjHwjqjhN+gPXXUylj7HJ6BnRE5VADSDtei9SU5nyUqb0RD1Wod9MoRfpNYEeHB0x5SR3YaBrUKB289m9pt9gXDM5b5+pFMuT93jixp6UDU/CEHfj7dApJsiV1B19ls3fK3j6Q== 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 VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Tue, 6 Sep 2022 16:19:10 +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.5588.018; Tue, 6 Sep 2022 16:19:10 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v5 1/8] net: phylink: Document MAC_(A)SYM_PAUSE Date: Tue, 6 Sep 2022 12:18:45 -0400 Message-Id: <20220906161852.1538270-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 71c39cd6-55db-4faf-3db3-08da902384da X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u5yRGPrPkDb8RSggs31Mvnrb+830AdDNSo9qpoY978n4rVN5kvnxcHjLnqN7bu1QndinEs+6KVf5hTwmSe9SEP0H4IzAZaLo76fB38yjXH0nDn8mfSXaW/bYDbWm8gh6MSGdj+7JNbtq0yF0sPlEoEawIb3DTKjnHRPL6zy7vUQoAZquW4OuRhYnYStwiXTCUcVlYpmhnr5z802xLOUWZmF6Ur+Eux5JpfXwpaTCTa0R9dDENIsPkq4/kplfrtbgugaBSlxHqPa4Kvk1dchWrganpNaP3cTEb5FYtq1Ia2PwXzM3k3GEJyJ6FpPoOf5KZ5ZV/U4Fsmy9ZlXzpTvAFZTS4IBkpuCWlU7Vu2lo/pTu9Ai9Ixz3XLq+Wrz8JnGRdnjxkG3q0oE+H/YiyaLaMPui0dxQtDhjs+vvK116bfiPmTB1CYcrYcNYE/kputupyl01VUIikFkYfbzfaYjyOqKEdlIS2tZyIF8PwXgICl7Iekb73tu5NYmCWcwMl/estVHBdTLaC7OXilFmyoVCDUZEQP+pYTcoLR6QhncqRxYxatKkYr/gg9SQKn8aI8iK6Ujpc3x98u3YjJ7PiEj+hZYCKYrJiLtM5LmMsttZF2bhYtr5JE+aheZw9G48k3fLClR23MhjqyadcNUiElvcJfPeO/IpYAncKpeU8XHKB6wLAuyXbKrV3i+KZ5FE/M/deGmARkeeN/EtNpcOy99aP110Yeh6upcdb6GgRfr+QJ7PDhDYL2Fu34xvUSkCkrrx 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)(376002)(346002)(366004)(396003)(136003)(39850400004)(38100700002)(54906003)(38350700002)(110136005)(83380400001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(2906002)(44832011)(7416002)(8936002)(6506007)(5660300002)(2616005)(1076003)(52116002)(186003)(478600001)(41300700001)(6666004)(86362001)(6512007)(26005)(6486002)(107886003)(36756003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EfB099Rucx2st7RBU2UdNcix3oa3FpggUoy5ZVvhuBwV7QDjnTM9n2SM+buzEnEO1HGwQBJ8FpfDGtlfUhITjhT3fDLX0hQBOOpNXI3rfOJDEZcegIkEI7MrQhPtiyo0LyviGD1X05icT4COSL47GLfCdZC7mdbh3Aq3j4bEDnv7kCechipnGbZhLSPUU4CybtemJiwmvB7OAjlAvhNCIWQdz+/XSRcmNbd2N1LGKSJ894F2rt/JkLp9S8Yf6OFOnqmtYCRT1nUa18aPuo0mwporqSbV+A4cIFctcSifH00C0H0htezeCLwC2gnp29BVD2OoarSRMhxWu8lQUqxloVdb+u0BSFYsB8aM6QdU7JVEKtQmQ0GkakXVsXBzRBXa9v2GSUe7WL8BBC3pM7Onsm+4nwoOlowTfK7j4GHw7mLyh0d2doco3DIlsn5bBAO9Mn0NG4iSj8rIv1kDqUvpHP9gWJ/Vz6r3dWiWob8aF+l+eygCEdmt2O/wJkad423N7oqb5gWrOkjQFqn9mLxVaG+/MKT5ZdCJ5eh1loxRGWrg67Syv9UapEUl7vfM09cFNhYyrQexfC5371bEfLh7c2zfteGR3yvmZgSPsbQc5sHsTm8Jw7IfGhw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71c39cd6-55db-4faf-3db3-08da902384da X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:05.4746 (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: TkEX/vPeBhYiW55bWTITPTORYSacvbucGAPJWkkgl19sSHMq4oamIfJbvd5UNAtifqplkuYfV0nrND8D5/7vGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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 IEEE 802.3 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..a431a0b0d217 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 IEEE 802.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 Tue Sep 6 16:18:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967781 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 79DE3ECAAD5 for ; Tue, 6 Sep 2022 16:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234279AbiIFQlV (ORCPT ); Tue, 6 Sep 2022 12:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234681AbiIFQkx (ORCPT ); Tue, 6 Sep 2022 12:40:53 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2076.outbound.protection.outlook.com [40.107.104.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011D886725; Tue, 6 Sep 2022 09:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ifBlvtGXzBe3+9nR4kTQMrko4N9gH+G0UOFCmk3HWvUpBpv/D6q+AF8r7lz78qDaHTsaAA6WI2nDGBVp3BSewLpYwc2CZMWpbSR58efM/nA6vvhMoPt2k7+9A03okPmQsUvC1dzxo5Q+MHeukfFDB/A9WDJVQKpRzCljFSWplrmqSveoEsb5o9BjJAF/ReBe3PEdlly+RCbbaQNxrtPyXre+CHP7r1ZUp+WoW1dUDBIlUoeBm1V3+gAo/I5fxuR9HH5baX3KlEnWwrMyX1NMp5cvFofp2yLX40tkDg2YZoxZJd5tENuQROhv9Vv7rNazw0mZygaNb5YU1LyGeBN0yg== 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=vTzUpk9Ba8o0OnVKPUc1NcZf0NditoVZqMddjpYNG78=; b=iw9rCNL18EqpqcNflHcqBqw0+6D1M1X8Hf5r4gaZwP7+eMyk11WLDsPtPlkUOObODiJvtHvcRBU4J/QpXOtk1jCBeKjj0uu6Q48vb6BglQfVNhbcHeuwSsIcxuTG8QlNWpNhjvWsxaPLBIND3YCfGWwYkUlu7Ed0k+NYFJ+/4sJS1J9LzU7XwRWf0sgGM3m0TziHK3DY2Gwh2fWcrzUs4yENhWRcgFaBmRqw/jR7K7bda4102k8uIRmY0OFGTYZeRqmd75zzhpbeKDwOjvAO1VQ8uZ2Y8U9MO/6/OIrzThNk/a848FFWRUdDvBpMJj0mAkgsHDKoVlwZVHyWCdOOww== 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=vTzUpk9Ba8o0OnVKPUc1NcZf0NditoVZqMddjpYNG78=; b=nmJxzELFlMqzMumvkAewJuPc/gnqVuIuCtK6MaEjdwoqCkpXKXrKUGyjk+wx4DNDnEJE+TpMahEQhmC8MjrxEsY/Xcdj8fxVcnIzFyUvYH/lGW5CUZOsJMaMCcVUWyTPRCElGlyXfdxjvp2txDvSBAyxl0SvBlrlmb+r9RfD4ZTN87E9xQ3BEMkb59MQv2W6SNN64RBoYqFtKvU1QApZGi2vtZBNywc4R9nXTiaosJ03pB5SkZECNwhuAqGLQPV6CXMBEHA+SQ0y1hagXYILR4lxj7RFc/JIz/1VxsIcCt4wFKnVL7Emp01oKCf/UTXXa5ay8cG5Kcg6dsVAHNCNJQ== 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 VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Tue, 6 Sep 2022 16:19:11 +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.5588.018; Tue, 6 Sep 2022 16:19:11 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v5 2/8] net: phylink: Export phylink_caps_to_linkmodes Date: Tue, 6 Sep 2022 12:18:46 -0400 Message-Id: <20220906161852.1538270-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 2ce101ab-ed05-4125-cdbc-08da902385b0 X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2DIdmau9VjNqWEIy8YG3/KW3jeNTHXMnNEXJ/cxJqKiIkvm75cbVMGYXcowLNE34J35iEpeKCu4724wiIJSnBszQkksMf84fYF+iq6/h0RaaqmfL+TwUPmeglEyN9+dfqgcIKBFIOJeQW/Zxvahz8gyYNG39qTckbkgNrphCR3S2lRTAnLzGyI9E8KAvVsPUAz/DCyZsnkKssWLHRpdpqwUAFb8VRyEs3nopoTK0AlLyNtq8qUFCWt1Ki9yJAMbGKfmtOksRLyZ0OPd0IZjMxcp3SERCgbFKTi6yShXOnQvHfzsWJMc+lVcH55A3C07hJfVpsybyxsNACi95ezmeo58wMKa8BjTFbZIYUDdvMw7JGhOLEju0yVTEVmCXVGU0RejwXAR7CCnyhLjpo/yJ6fnalBAMxqIwafPsHN4vAp9bht6jcjQqLBVqjD0bkrGlEEXFQg/0p5nlnMW3EVfPkCeZu3VMWyZ1jH2ecFhF8H1wz8VYIGAp0s1JgyypxVI08j2f3y7z8roMYmJ6iNJk/BKPg6oNIE5Ml420Ha6cGNDNCOH26VZELU1OEk+q+nUDwrXsRWN8m84HBJJgUYeReJJsOIE6z9QmkVaK4kFyWAJ63Z1rn/9m40UEXwTKWFcxX93V9EiS3kk+py4W8oFRHIolO2Z/9gbCqApYW+eNpvGB4lEq/9cfodFd6rs+BFNGEsU3O+hqxXTOktpmiESLBBqShQPPTxUh97obkOftgHhfJUAJO0UQM6IyvkBNFJaDRMzBxvm+qJLR7AadhI9AtA== 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)(376002)(346002)(366004)(396003)(136003)(39850400004)(38100700002)(54906003)(38350700002)(110136005)(83380400001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(2906002)(44832011)(7416002)(8936002)(6506007)(5660300002)(2616005)(1076003)(52116002)(186003)(478600001)(41300700001)(6666004)(86362001)(6512007)(26005)(6486002)(107886003)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F9q89wX7l/g693oy5vKZSqyTAxFlpcfwmTM1t55VvmGlbjBgfWWA4u/R7/smO7L+uBpWaZThihXeSo9Mdu8HBY5dzHlb81/JwFJXw+1ZZLTi+CIDqoLV+8u1wqeRUslnui00g6Iz2DMNMPobotrSHUHWcyrk32R8Vpq/k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ay4FvdaGPqUN5fH98aSR9TkIQWARDfPXbVQTMveQcOwkDGi+RFN8heRo8lmP32wAyrCvoUdcMutQpEU3QoVZMvuTOtq/xWlQRII74pfVg1syFOV/hvNAXuQCZFTok+hlx137fDcLtea7KduSlt0ZoioAxfDdYE+VNouWwWaQARgukH9KdUpO9pGXWeQZVNps8tLDC9QnbvlbV1YjHvnr66XnyJy3x7okg4eTBL3ggXkArSdgL3MlKxkMNOddkw9Somo8SCwb6rdPpFP/cD4UL5LdKBwOg/vvkT4csy0D0MSqJCcLinJ9R3biDrt+/JhLZZqOeheAmYlH/5mjdajA1RduAnLsaPtd4p0AGFJ+epeHpjTNLCUuOyw/2Pw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ce101ab-ed05-4125-cdbc-08da902385b0 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:06.8495 (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: bWLYJk+2iSipuuUUPMO65Z1RerfNQ2d1F6CuSscEqIBuZnh4chlWnhNW/s5mBKmvMFPIDh3IeOMXaLKR7MPU4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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 e9d62f9598f9..c5c3f0b62d7f 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 a431a0b0d217..9bb088e0ef3e 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 Tue Sep 6 16:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967783 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 2686EC6FA83 for ; Tue, 6 Sep 2022 16:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236175AbiIFQlz (ORCPT ); Tue, 6 Sep 2022 12:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235439AbiIFQky (ORCPT ); Tue, 6 Sep 2022 12:40:54 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2076.outbound.protection.outlook.com [40.107.104.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C97D112E; Tue, 6 Sep 2022 09:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cbs0ITyB8VB5GW0Wlwqjpo/Qe7mQGgDOUrH1ETxZW+KDhpDlZc+IuagpUPGwPfvUiHfIYjMIC2Rw5JrYorS7oKOWfnzAJR5LQNwQTlcB4nFYnufgL4zXbY2akOUurLzlYLvwLjckZfX8PsOjyZc9sPC98rC0S9ct6t0+OLC3DSyZ3tTxcBSpze0B0/js/IOiB4mC1j0TJQqNCBLdkOjzMQM3LUxjneDS9+J/7/xApR8MAU68j5HO7wKEjF+rzwJLV7E7qzzHC1DfgyyCA1ATAra+0UrRkcMFMr6C6uyHiNV8uwAeGY6DEWhBC0k+neZ9l1NWwh648Io6F/R1aXdJAw== 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=fJCF7ljDrTc1FW1nQ7/4QSEadMl/TpmNqM0XeZPW+CQ=; b=I5W2UY5jRZisYSOdgE7OnVtMq1yFNGyQ57vaphXsGpIV/Y+aglvl/jeauGWmc14qDencHLKAF8FlqwYaKy4XdOymFbi6VEEgDb8GyobeaEriBMyzrpbVPQSX+duF9wEBVS9VgpZTESvmH3D00jUc4NO0eg5cHe1YeS3g97+a17Ql2UyzWJjMFbCH8V0ceiTyJsRvuinj9Fitj7/0tGiKiNRKpUmI2H6V0uweddhoNc9EiWVB3nPO+O8mZGG9r82Gvr1YFSMQ7AXqfa1CSdiDTi/bH9zkc9X1BxwjFO0hlKJ1OHBIIs7azm/Yo8vow2URpQNyQw0+u6abhGHddcclCQ== 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=fJCF7ljDrTc1FW1nQ7/4QSEadMl/TpmNqM0XeZPW+CQ=; b=kPNibe54+NM/TgOUI7n7+jBIyC/HtIiIPaa3obJtxFTRgFXgtlGbRZNFNfq/tbJRKtx00MWT8recSSAcJaFUkiKPFUHi5YN2FPKUQGtLQZODMvVVwyc5kKvk0TNc1DxIZpNo7WjHKbnzUby+iCEyjMGSFY7LNgGj7ddHLd2XSOh54Q1xUqMm87SH46xnYJVVuoOYUCNtPJWvEJQIAWIA+TbslZPmIRt87F0KkGgzD3Qda351OsCXMxrvhNI0CNl8vk/uW2g0ptXzkjQjLjIPVSJRb6s/91Kt/ApxRqI5qGAmoX/DW8R8kyj6qnKSaTJ4W9b6ejH7UbDJksKAnmqHQg== 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 VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Tue, 6 Sep 2022 16:19:11 +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.5588.018; Tue, 6 Sep 2022 16:19:11 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v5 3/8] net: phylink: Generate caps and convert to linkmodes separately Date: Tue, 6 Sep 2022 12:18:47 -0400 Message-Id: <20220906161852.1538270-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: f0e92ac1-8766-429e-d481-08da9023867d X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: znfF2KmBfJK2OtPh40Hke/1Pj/U3+t6fmgrGbVo322SCyPBnz4lLJKH+JEot39kT5trlg+V1EEoUzroSIB8zEeV315Sfk4PuWPeIEBBQkD9qLH07eiiSt4zN5mvvFUymcmA3NlAkzPzXnduQoBPEHXJQTpjrlJqI02GiRcyi4E8ULcvp3t/W3Wdw6pPfuvaOGUbo4rVQA9VVIU7toyja9uPHk2F00f9na0cx/u/kIsjyRYdD2EuETP3ocO84vQFqzpS21GQARhDgavPDHZqrooExdTMoZ9cSf4KEbc6dbH4LPpKeYhpwtUu6CHtf5oog7ZSweeVZs2CJGLbl2CoMsqZGwNmx2NwCETxXlLdayud9/jXC5wZxidQJRZwAHLv5dtdO6AMNDx61pQmMy0vszVoA+GnQpRWOb2BvFvLEoHF/2oK0jfnBKAUIcLEAjbe0n4Q1v9AFoaSXw4SYhFeafXjCAGpMDu64Hku+m533/pJBQOZoZMdZRR3Xpb3ycwZVZB84WbgC8Fx/zrsewsIFJwCnPLjfdJkYSkyaxv5340DFvuloGaBCoibv93dm715FdhkyWvgzw5VkUi4a73ISC+JikE8zpRdSWX2CH8ZztGCstJUPHM8ZNMGbydOYA9E+o0Bad6Y6+S1k02/690HQAt3cFnLomkw5xbf/jic0PusZXdaun8JgEuNW9CFeEvfHLrW8F6oRw5wzLlF6ELtT6vpAZj/A5tsASff2eERTlm7oWE40QDZD1ZViL8CLJjntAoORpmgbhkQobZ0lhGzUVg== 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)(376002)(346002)(366004)(396003)(136003)(39850400004)(38100700002)(54906003)(38350700002)(110136005)(83380400001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(2906002)(44832011)(7416002)(8936002)(6506007)(5660300002)(2616005)(1076003)(52116002)(186003)(478600001)(41300700001)(6666004)(86362001)(6512007)(26005)(6486002)(107886003)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S4DblGvbEr882mHy5X9ZsJw4tzB0dRcT9SKa9XklNvudOjTrbml0xy4qhlmau0WjLprWzjc5k8z1K11erSy+ANITIsqg/oS+A3gXzA29ytIBa0UUiU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cQZJkgJw0BeXqIHH4QebuuGpDlFoyQlJCDVvED+IhH6eUVwwMHH465I4Drs/8mLElRsZqM4KdQ9fLq33BSmE9Ge2QlyFEg/+Z88NvvMN3mXah8883xxwgQ3usY95NLuVb94bHWvzQWakAZOmTBK9L99PQC5DJDysdtQ0uwzBVZvPvpPoXxctSadWT3DeJjZBgcU03WIZDdxPaNDsS5ZsKsFP0zIHk739MzQ0klNWaU6vvZMFqeZJxMwqOoNzo45cmPZr+A1yG1Zc+Bs+54vHewiP7qDW4I/ZfQJAtMw5dPaHszKBDX/f1hUzjkiWsksBW1Ud6LkiBfY4YFXAAw0RKoFx+OfwbLUA1mQomJ8uWKrGMht6MqHAaJQES55njPhPWVDTbvdQy0C2SVbjIg68H09SVyfm94j2roj+r9dtHTtg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0e92ac1-8766-429e-d481-08da9023867d X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:08.2713 (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: kkXLY7daYZbDHi1Xg9qucyGmroFlmXWWhZ6Ubda5jBBDv80JWanfPmqqDoiwK3+HeNQDNL6G6WO1H7ZKBtOWkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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 c5c3f0b62d7f..1f022e5d01ba 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; @@ -391,9 +389,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 @@ -409,11 +407,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 9bb088e0ef3e..c2aa49c692a0 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 Tue Sep 6 16:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967807 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 4DE68ECAAA1 for ; Tue, 6 Sep 2022 16:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231543AbiIFQl7 (ORCPT ); Tue, 6 Sep 2022 12:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236566AbiIFQk4 (ORCPT ); Tue, 6 Sep 2022 12:40:56 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2076.outbound.protection.outlook.com [40.107.104.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CABB1180E; Tue, 6 Sep 2022 09:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YERYhQjdHh83GfqZBlS7JpGpcsWkO2vGXYO3PN4h+LR2WGISuLQuHXq+Pn+ny0Mlpkhj+0iZ9TxbkmFMVnb6GN6UUdLYPnwNzSFf2AIi00nU8WN9YnhLkILdIP2vAkNq/m5CsXkMGVdj4UYdHibHnVYrvezKA9QGCmJDvl3oKR8NwPSNZojia3X63xW6D+LdlxNZu/1jx9mFQi/kl+qPW9Mr9QR6sR5Ga8RbbM9VnU1j+cdYWuDflYHI2C0a1LEXCQHHRZP/RtOF7QCVVlz/0SoTN29PkWpxA5TGGmF/dHXxElUmxync63TwJa4XGCouauKDOhXkaoZG5XeZQZ/7Qg== 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=T9ab12zLu+CoupxeVw1PyM77upmEUbTnNz6ECUzXr98=; b=c4MINsEtHrF+/CDRz5FkFAe92CrQxXK+lK4l/PIjgLx+1J/eEzpvatOKtz2q0cPcJD9+vKkQwlArmAPy8TrmY60uml8yr8KNGlXGzFN3plHBJNjcjo8RzH3TBbK25yzGYuz0IMYgZ2iaegDGowJP3qhVBCazOjYp4qAwsMp3z4On8jIghmVmLNG9+z1NH/5DG+nm7o6KaDzy407ZoYrQNXcW2WyM+bAw+agA4LSFlO7p9E0gpEuzHMR6nJGJ0etQD8h52MexVU0TnvJwALWfhyjLIwBYa2paN/JcJCtJlqJLBgn6WQp3H5ESVjKY9BsWIMVsJaxclGijbShich4FBA== 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=T9ab12zLu+CoupxeVw1PyM77upmEUbTnNz6ECUzXr98=; b=pUfuTXrw0I+gfVq9KgnleHI3RMjLp40T6/dMhQeLXkYW9ldJ3ujqQ0wWCSt43UBmBvJYzZvjitVf3HLySvmkb8NLMcV57MuQLnayFR+6a42RVONZ5ZeAWRtlMRHfLsE0/lyKAbcjpvMFQWpU8emg+eKlHdyfISnlAlqtmdIF+i1wMo27LmNbozyJg5gWzEpeXCdez9m+WEJOmIKBsgv73zgZ9tdp4Eq8sfceV4kV0qoKI0WyNZTKTVeNemOgu1J1RBVtLEDUqdGg0wmNyhsr9RM/v0lj3Sh/BU57xL2K0pjFYoqWR8l8CMcV7yumbNqDIwAjdhnZVnTSDJmGIDefWA== 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 VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Tue, 6 Sep 2022 16:19:12 +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.5588.018; Tue, 6 Sep 2022 16:19:12 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH net-next v5 4/8] net: phy: Add support for rate adaptation Date: Tue, 6 Sep 2022 12:18:48 -0400 Message-Id: <20220906161852.1538270-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 5cd29cf2-7f25-452a-0044-08da90238771 X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zjxYidZU3zZDy/uOjEsgFDG+8Wny/vSyvjuGRRap6yo4ONieU9lXd1PJnYW7DF1kPnW8Ej5U13vgtKk5c46PAYak3a6IiUk7YqPbdp4i/6kw6GsSF580BvDJGnvWAGA/jqp5izuOc4lkY/siAc5w3nZJ4ukpOeGpdt0A3rsUnyPjfNj841DdUl99WJZCzu3ZvlNBHUzR+ATToY7FL/BIvA6pTQDML2E3UKu+cLs8UTtvXSZFkBX5F+I7lPz1GG7/vpiuk17cJDzSkGa4121dwAKj0pv2raZtMWUSyBxlUGx6qaPnhr+EurJxWbmTHX7evbFpb5dgomG3kqB9EDOcn7ikDgCMp2DR5geXWwUBTacQAM6UBtv8V04CipJcqkvKOLI4EiUSm3Dc6OTG7A51xd2hZ0WiXYzu1QkFQoRwQRpaTrTaOsKO8EjkwKVxjY8RzPF/uPNpuksy+A6gh+xvOotS3NH/c7mRb/q45LdQBauryQpUi530Es7oT4FLhMaFPddR+TSZCSdQKh5FBUQDZJlykfTNcSeRpM+SjVwNQfUpnJc5qIVgNq50DDCQSRynus4Y6mfyPYlVmy0C6aUdkGpVOdhsPVCSLklklqdwCCS8eV0G5hd90BEhaJDRqLBgmpjBDzRNek5sbK2CPD/u44Mj5MrT/mnnPu5oANBzH0AAZOjHSC0BhdPF465G6UGaaGAiXmHHO+QkLgEQ8wFCwc5EGC6U9UY3aK+Z3h+uNUW8pSLc3oEP7kGDLkFwQF5PYY0Z2rhvj6sj9SzwPlJYyw== 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)(376002)(346002)(366004)(396003)(136003)(39850400004)(38100700002)(54906003)(38350700002)(110136005)(83380400001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(2906002)(44832011)(7416002)(8936002)(6506007)(30864003)(5660300002)(2616005)(1076003)(52116002)(186003)(478600001)(41300700001)(6666004)(86362001)(6512007)(26005)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DSXNQFRTzI1yEcguylYHnuWwLF/7U6cqUWunKUBoXvjbKl/ykzqnMFF8laVYohNoHubkiFFajvMP43bM6H+qWB5FmSBUvJcJLJT7++WEMIDM/kXNovmHyPIbC0kQ0cBborG3zvt9p+/KduAupnoRKKpE5+POlSImMudxqCJGpQtie0Far2zdbTrZzMKUI1kGh/W7/Zny2FOK3MkMw4imJvavVXZ+06sBd/2GlekQiRB8u9b+ZlLbUdGHGFsKQPNBm4xrFnWF1KZUc5w5vBIDkrXYSSuRrwL0sao5N31gIxYi9gdPJjL+EuYwmkm4TeHnb1pAbpKeEiAgntirGYIQ7OoylOJ1mTz4itcKBKoXpxvBIz2VGvWk7z/S48/t3ijwy+Qj6aEsVEzFarAoKg2ckpwAsv7MXy/T5o1OCXarz8Jij0QHEG7BNZ0RlShXnBIQw6Z0yLN7K6p/Cx1KHx0E4a9//tUQXJNKI7z3IQn6G8yzqhBF/HB+O7iG4vWH+UnekNl+VGMD0FZsEkGV9mwtxIthzMUmOafmxIHp+90x7BkgtG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seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cd29cf2-7f25-452a-0044-08da90238771 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:09.8493 (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: xr3hpWBIXOTlrbzKPYdkeAuUFJfM/Nj9TfrymZN2jny/a26sWd1/kQWo2JgBoHQW45N9K/shjTV3ew+HwEHXPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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 v5: - Document phy_rate_adaptation_to_str - Remove unnecessary comma 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 | 21 +++++++++++++++ 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, 95 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 2a2924bc8f76..b1c9c40fe378 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -74,6 +74,27 @@ const char *phy_duplex_to_str(unsigned int duplex) } EXPORT_SYMBOL_GPL(phy_duplex_to_str); +/** + * phy_rate_adaptation_to_str - Return a string describing the rate adaptation + * + * @rate_adaptation: Type of rate adaptation to describe + */ +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); + /** * phy_interface_num_ports - Return the number of links that can be carried by * a given MAC-PHY physical link. Returns 0 if this is 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 337230c135f7..3e784137b2f3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -280,7 +280,6 @@ static inline const char *phy_modes(phy_interface_t interface) } } - #define PHY_INIT_TIMEOUT 100000 #define PHY_FORCE_TIMEOUT 10 @@ -574,6 +573,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 @@ -641,6 +641,8 @@ struct phy_device { unsigned irq_suspended:1; unsigned irq_rerun:1; + int rate_adaptation; + enum phy_state state; u32 dev_flags; @@ -805,6 +807,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); @@ -971,6 +988,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); int phy_interface_num_ports(phy_interface_t interface); @@ -1687,6 +1705,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 9298eb3251cb..6166f3e6b8d5 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 Tue Sep 6 16:18:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967780 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 4AFDBECAAD5 for ; Tue, 6 Sep 2022 16:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232848AbiIFQlT (ORCPT ); Tue, 6 Sep 2022 12:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234649AbiIFQku (ORCPT ); Tue, 6 Sep 2022 12:40:50 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60081.outbound.protection.outlook.com [40.107.6.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78027861FD; Tue, 6 Sep 2022 09:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T7en/RGPGghQqxFa/qOjClVlHmZkCZDLNc9ofyz3wmMzKxsc1keuXfhgoSRkJArUXxgwWFJZwvgrWjHihZ4EkJgWrpaHZ671Nki/J+VlKHa+jLXeBD3C1PAGFnPwoVmrh0zSkL/qclabJW1ewLqv0r85AZHU+wgSTjK6Nlfyd3Bvb+khsLj0fus8lopTjxRMFOCweq9aVBFTu7NpowA9KaO4RBjgxQ+HWX9C8bSOsHaNLFlWqvSAjAmUK9oSnwc/u6zgFjCDNDVucAxpXLRp+/o8aF01284tCPU2qhCyGouKe2tNNBzZL9DraGIKhqlKMtIIkqOGS6JCmL9musT9NA== 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=oBB1mhdyh9YzU2vFlFtwpeLoSGrAGLifLsj76S8Kvck=; b=Q3tOPzodWkeAoafLRe7RFo3BVCao8hcWfCMWAxpow8wXbE02zufUK+eNgcWSuZUMFL4eiAqEZ2CucvFnZUrRABCMPmhhYDoVAdwm/ffRk880Jg1668fErjTflwQglJUxtYb09b5Y2Ty8CwvkjB6FLLvnBxdjgAXwsiie2jXUY4stlllHVlJrpiEe6kXzG+H/PurdvFBttVG+DcUyQf+DGxOddAQV2+4kFBBFZRz+qlXsniOh20kCQwrgLDWTSBG+jM2CqiJLkxXMlAVVzYP8oJKG5ex2uDT082RAuYq7qhIgjdj0os4CrJPs3nAe3s0YVHYITHwsSuA+d4X1ZdDtkw== 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=oBB1mhdyh9YzU2vFlFtwpeLoSGrAGLifLsj76S8Kvck=; b=gFrbdt4USrx8PNk8JaLic55QU277k49GEVRgsiYOyOIzZRLICdYirG4jmf+nzLsXH4BkXh6iouMLfnE4rvec7mIkJN+uDUbxBXr3k53AUNdgAnYdXJKNfc4PZrdxnMgQ8vgRlg+TsJXx1XfBbRd6lULTkItdXFQ+nhYpsGzFSqLDAupNli2Ofaz2VYadYsyUQKaETmBws3Eaw1wJkfM5n/Un7QBb55oWAvpJnYtUW//faMPWnr03sCYnf7pxmQN6OHkW0sTPrSiAz90Ytuof2DbH/uQdRQLSZVCph37cmRPyQw+pvrzBx3e0pg4c0mUXm55etHOVQyws6DiTvj52pw== 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 VE1PR03MB5664.eurprd03.prod.outlook.com (2603:10a6:803:11d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.17; Tue, 6 Sep 2022 16:19:13 +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.5588.018; Tue, 6 Sep 2022 16:19:12 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v5 5/8] net: phylink: Adjust link settings based on rate adaptation Date: Tue, 6 Sep 2022 12:18:49 -0400 Message-Id: <20220906161852.1538270-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 4e206706-702b-4811-54f2-08da9023884c X-MS-TrafficTypeDiagnostic: VE1PR03MB5664:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VC/0VzGFQsdlJn1JxTX1R2MkFsBj6maWUViQeeF1kcn4RiffvU7i7lOy2F+m6foclIpjqOumMoihenlpCk5mZ32m+qULOIFcuyvDEB8nTdXgeADO5JZQnfE7nyHVmwuYqNQQnDXiSa6cNt+alzf7RP14D3dUaYaa0wFxe3N7jk7BAG7QGMHT3esVALnOOHJ9r2HWYucTnm0IcpaABAn4lgF/OnW8P4PtRyUk+TvgEHxb7vToGZPeGXdT8wlBbSuEqPNkrbWBu+11bNRWY4YuIm7aj43GxkQPpxqBtD0feTlrmxZ/b3cBnAXuMykLyCemwQ7TCMsrV/WgujCikCfKd8TrTG0uMdiq7tEXX65uRSApItjGhdHnWjeoyqGSHf+6tpb4dk/ZMWce22ewvM30Td7UZ9pYEZ7WsB1w/I3ilaGc8N1oHY4fRMYKfJEN6zmXIKR8WD7vbrIF1fKEERS8OpjHkgRUuRycluUBdMGux83aulDDB6QSMpejdwsStz8/+Rt5T58XL3ZrooSrna9woaoyv7fUItjvpGgq3m0gWfCHmMAfdfNm/zMR99UuopKZ2LCB4zT0YDJg2+r6kRp8FgOCMDhXa9Kbw2cUUIRnNuA40Z7i5YtG1NDSWKyMq4quDJgQLDLK5IVcFcJmw5IKU1Zf5MXWqXP+cOxqVP1HqPvsCZaWRQJeHwN37K5kZp/PfyzDkaB7Ptm5YiI2a4fm294xG9UHLO3Dzod/OGVjpExAM9sW46m9MKP2A/ViXhf8rLPtgCUrE7IezF3YnJ1o0w== 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)(136003)(376002)(39850400004)(346002)(366004)(396003)(84040400005)(6666004)(26005)(6512007)(6506007)(41300700001)(107886003)(2906002)(38350700002)(83380400001)(478600001)(38100700002)(6486002)(36756003)(4326008)(7416002)(66556008)(66946007)(110136005)(54906003)(316002)(5660300002)(44832011)(8676002)(66476007)(86362001)(8936002)(186003)(52116002)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ApEAcZj84PVtFFh+99NfUiui3UFD85bD3I2tx3jIuwMjvy3mmLFCSXMJSiDZt0f1EtZhohJllN7t0U9x/hPM/hyNczlnihYXJ3Ylz9rsVIoaJtTOLMxEoTrWlKMzf0JSZMa5u4WyqXHL2R6+bjnmnQBkPBkTiDwAcsX33TuMDqq5IZJYND5hT39r5MS3bu6JwJpbHB71oTfJN6M3PuKgAiGpCEyys3+j0If+0o5xXljIgh5d0P71b0JzLRJ04Pv+7oZ3tkArz271ZPHk9VOx6xuMCClIDE3HqP4e/XynpRo07jcKXrjHwh+5z9oaqpbsHOIfPb9OfyUU7OvVnFpiKtgDiNtkWYAu05RR8yND8Rc5cysP6yoHsQsLOVqsiQSrq1RXmSAmjrQt4CK7zu5E+v8LT89iGrVI5DwXKAUjEcBDfPvSUQXU5s44VcxEit3GET9qqxIwUGS4WZTTzpgzg58uA0/pCfJEpHdtE/us+UcEs0eAefBJlelxx3HrTd0L7XXlyBqz5vkmstCoqGM5SvOuMWXoOUuXjvT1KzvmERnJxS50y0FCCtboP20ebH23rmmRzQebtkjy1WL6Md1lDGwlaGVoRPLYT+kz5aTg9umfLuGO7KBotDGe5kjbsvnJV6fwyFeyD2ccukGcn145p+6uk0wqiJ1+m+wStZBBff5njxyamqYNwoapN5NMntvXN+CeEsSEHivxxEzMLlvAfWVRGfSOuGn+jJfNSlpzWoNx/FmpEuSu+iwbxg0QsEIknSYeW7ZAMNTxuyEcDOROJkZ8MA1WCGv/L1Ejp8ibSid0xrCeUSWs6VFQFCCa2Njx3kMeJsRux4aHxsNj7ixqctEZeSisCzz1XK5QggLPFycTUhI9g9akSZEXxtlAusEYth59X9lRJvPoS4sSfPhTvsXNO/eVAZdy/4a+T6S+fVgcVw2hSYK6p+nvcyb5/NGZX33tWVyBR+trXNQHIIPePpIjf/AYygzTgLirhzNQv3Zymk8ifBAKyRtJnd1fdQM9inOwW8OYNkfRtBwWY3N88sgd0EGOfZ53K8cgBJLJ69LWbU84fN94hQ/eiXidRd2gcqZImPJ5Tk2v4xPPidds1RpUNHY73RzArb/+EJoPME+OMFVFYxsVMnWoSzHLwVHvqsJG41eC+xpHSujbY6LfYH2R64kLy3LgL5TZ9jnUIus/Tza8kqNOE5wFH77z2Q6CGuoVTlr1zC2FtsG3zRJNnYPQ2H7xOTXTbjBk/XkAl6rLac4pbPZJfHDUQPtPM0Nt8gQYHKpEeOCECC1I0tXXso2a42CnhwF0LIm4JtvmhSJszdQKb5174VjHMG6RMvcObp/7P1wOCafarMDVhQ0o917L9Y1hgWLrVNkqoH9zuxs/wd30MC895BvE7hGXM9Fbqo9mvExtYbe2f7k4eq8NQ31lZPGQrTyTh/j7b4t6r7Lts2ByyF4de5ILTpiHMFoFcUXiDTvTtHfCxLivjOUXG6y84hvq6GrRl0btAKCyp81IL4GmSAC775xGGsvjA9f2/CxSOOTCeClwcsAYTtDeTIJpbrCmAW3UnhNT7AaCH/q8dfL2IT8DQnXnuwh4iAl68VKYsODoWNQTm54aGYpoog== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e206706-702b-4811-54f2-08da9023884c X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:11.3024 (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: ZurZZAG0Xr3FmxckW5IGVtK54TKN1epSglG/+j7JXYR/Z4+R8puvVMmrHnOxzDyqdpJNCskx6hq8IJw1uQZ/iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5664 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. (no changes since v4) 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 | 137 ++++++++++++++++++++++++++++++++++---- include/linux/phylink.h | 5 ++ 2 files changed, 130 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 1f022e5d01ba..8ce110c7be5c 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,6 +155,75 @@ 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: + case PHY_INTERFACE_MODE_QUSGMII: + return SPEED_10000; + + case PHY_INTERFACE_MODE_25GBASER: + return SPEED_25000; + + case PHY_INTERFACE_MODE_XLGMII: + return SPEED_40000; + + case PHY_INTERFACE_MODE_INTERNAL: + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_MAX: + /* No idea! Garbage in, unknown out */ + return SPEED_UNKNOWN; + } + + /* If we get here, someone forgot to add an interface mode above */ + WARN_ON_ONCE(1); + return SPEED_UNKNOWN; +} + /** * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes * @linkmodes: ethtool linkmode mask (must be already initialised) @@ -791,11 +860,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); @@ -932,7 +1002,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; @@ -1015,19 +1086,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); @@ -1119,6 +1216,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. */ @@ -1353,6 +1461,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; @@ -1364,10 +1473,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)); } @@ -1431,6 +1541,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); @@ -1873,8 +1984,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 c2aa49c692a0..1524846e01b4 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 Tue Sep 6 16:18:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967782 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 B7266ECAAD5 for ; Tue, 6 Sep 2022 16:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234739AbiIFQly (ORCPT ); Tue, 6 Sep 2022 12:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234995AbiIFQky (ORCPT ); Tue, 6 Sep 2022 12:40:54 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60081.outbound.protection.outlook.com [40.107.6.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60DD627B; Tue, 6 Sep 2022 09:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jGCG9dbjSHyAfTOWeX150BNuKxo5rVg8UWNDd91EljMtS5gBfQBfVzbzIR2obb6iIdpgMWZi42LHdcaR7j6qoN8LZ+L9c5+CHhFje6OFxPLxUlBqQuVVAHCBAxhObC6Qlvgtw7CW6mHlZNOxbsZgkcJUUvRkjpQCN7V4QEObwkWAHM/99cSz1gxDUNH0krhPokY6CLyLrwdjUDWwjmnFK8h/AQkfxiO+ymhqRsFG1Tdk8Vpej5R2XxUUB18AHBDPORswaOzFKu807shvbC1xMl7sHJ9xbfl+lZe8FFDLT57uXYZnJkUT1HIUPwxUWswrlUxskGP2Vr5/SbFMj51jFA== 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=mmLYKPSYvbRrWjRq6VGz2IrxF9ZKCDiZflh00EyAwjE=; b=Ub/vbDJrDSE4odhHdzFe1Ljz+KgJFu4ZTa734+Z42/0FbTCvxKkNh5R212P7CrDhzO5h9l+BdrYQAYOqmPUD/jHrqvnXQUwHqiSkE3pLfFn3rquxpkIbZmRVitT9KV84Epx9AtyXCcXtE+3mIs+w3hRXQXfg7vPRBn0F5OQwtA2vFvGuDVfvVPvZiaHBRknPmFQjmGCzS9ybQ9GD9pq+BwBNgr5j4IlK2Cz2u1D+ZP1JETlAHu0rVld7tCK/4Eq/bqhHbSX6YqVirm4nfdrVtL+n2Y73/JQNyxskjwkxQ3Om5345imNUh8T4zR+AKdgiydrRU9HEakdyoxotS6m3YQ== 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=mmLYKPSYvbRrWjRq6VGz2IrxF9ZKCDiZflh00EyAwjE=; b=jgM/c7/RrRgXQqndmgvQ/qisf33W0howe9xNBX3s6WsAl0KiA9cZcHumrnyZP2fk8p127Yhh1+9YOagpqSNuAJ4aD1wlDp4+Wrkp9fUijBjXBwS0ID9WGRg6H9G1ZgqC3HxE8Cp57FQLvDii+2QmHFsaKaaslvNd1smu1m7qGVkGvTG0LufYa583l9pIo9qOc82am2RIWhbmstuLKBDxsyLxJeWDtWZv+UcTUBJ0WahZCpn4TtEQL5Odi7eCKdQSxrB9aqwPdGkR87xGheOCSCOGBDWciTxNiiKKnsJK7rJqU+DRoxR4yOc+7wWp9fJMqNo8sM4Yw0Xm+QXp+niTjA== 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 VE1PR03MB5664.eurprd03.prod.outlook.com (2603:10a6:803:11d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.17; Tue, 6 Sep 2022 16:19:15 +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.5588.018; Tue, 6 Sep 2022 16:19:15 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson Subject: [PATCH net-next v5 6/8] net: phylink: Adjust advertisement based on rate adaptation Date: Tue, 6 Sep 2022 12:18:50 -0400 Message-Id: <20220906161852.1538270-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 0892517a-3cab-4b3d-0bd7-08da9023892a X-MS-TrafficTypeDiagnostic: VE1PR03MB5664:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qr2E1h8GnXhs5YHAbgXpYR3dDezQwEFl+MG13AXUSm+37BPIpSTvVzgN4QGkW+ZdhTh3mkc11c4nH654cft9HpT5NQDBrw7T26nlh7460Uw9l5ZzkzFTDipw1gnYV71MnIbbIceEwaNoiJzmp+gZs4uw2RUGjYL0nzW5xVWBO3LNmr05S/u1hxLkE+MnPttTzMSvWbpCAvzxdKiQsNBYcMiT1YLLPFgNzmfEXBKIu7gk4i6E35shwsOpeyNepXofFlwTXWQIROOCX3erT4K+xBVLNaeXEgC6MRU81tENQ2IeAF2z0tIlSLynObr5KyeuldwIPw85eYZ+bjMUTdARnOPSSHIMUVWHVQSuJygCAvQU8Fxwr/zddwCs/HRfHX620/VulMTvcTaSaCzhRaKVnnu0Ziy0Hb/R0RQw8hoAoRg5EbeWy/A9Ddp8lx7Yu53xuo0sOsfV3xRxZ7W2km1tgiFH9oGM203P+aALF3/QkPrXuOP7P+/qeAKgrVui5qk5e8xT3j+3EPrXEFZVf5QC5ExUUpsygaSYbCnRjK0bSdW0HnKBL1rapvoatSGW7q0nNYKdbfe1/YYVunc/kyt4/MRm2/mQMKsQE1GCDYh45TGrIoO5HRMu/7Nn52Q6hzrL1Tag2SGiznaNM/N6E4s8kT2qJY9RYIQZqNhDUk33I0HGg7cYYv6Rc2e/5lm4NeEbyO2x+Uql/dED8NYXvxtX0HDSQA6NSX3R9e7SgjHxxNk4THHb3RgBfEHXVs6OKdjniajKL5PVAYS0x6IFOLaYTw== 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)(136003)(376002)(39850400004)(346002)(366004)(396003)(6666004)(26005)(6512007)(6506007)(41300700001)(107886003)(2906002)(38350700002)(83380400001)(478600001)(38100700002)(6486002)(36756003)(4326008)(7416002)(66556008)(66946007)(110136005)(54906003)(316002)(5660300002)(44832011)(8676002)(66476007)(86362001)(8936002)(186003)(52116002)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MchPToAOgcteDt+FpJ4764OV7zOGhelOTStzZXrfZ031Akt7K83YDqEQkrp891PnRQKalW9SDSXvmdVhBxS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Se9i1lH8CrXZuRTke9xHdYW9Ks+fdgcsa3TSc0yytJD21KffDYBm52j1Rt/Y7hyX5p3BmGHY6OxLuLdsQRoRyo97l2EHNsDtprBkXUTqZSvOBim6Wu6JtB4DW/gd5vhaGpI1DGidAHVjxjA3klO1Gothu/Z1UtPBc2jGcfcxp5adso2hM6Mu8FxXDMB31bRruyIwom5eqvzTgXjRQ4607zkfqJdGklmlqnATJXi1u0oBBvtkQhicfIHfZaI9TnLJhtf7i9RLBsynCSvcaZbLw7SZfq6mGargeIPZLlLLG9nla41u3ien99VFMzarCNDAjTd/KNt+9ueAe99IbdKp23h4sg2b1/kpWHSHYEjZy9KKvA66pyXF8/ceSQ8zY/uKQ0O1g/tsGQzXV5gRZdWVN82Kh81qVpPeCJU0cbYzku7GgblBJe9JODyEMmJTHRzPA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0892517a-3cab-4b3d-0bd7-08da9023892a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:12.8491 (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: iEbnYmQTuidYwPywFlSRL9EcIvDtOkVU7JxAN9OOoHCKPPDhmsGOUkvsh7V4exTtz0XJ8IdbDWJ7O7RfzJZfpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5664 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 --- Changes in v5: - Move phylink_cap_from_speed_duplex to this commit 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 | 106 ++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 3 +- 2 files changed, 105 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 8ce110c7be5c..4d73a58f4854 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -373,18 +373,70 @@ 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_cap_from_speed_duplex - Get mac capability from speed/duplex + * @speed: the speed to search for + * @duplex: the duplex to search for + * + * Find the mac capability for a given speed and duplex. + * + * Return: A mask with the mac capability patching @speed and @duplex, or 0 if + * there were no matches. + */ +static unsigned long phylink_cap_from_speed_duplex(int speed, + unsigned int duplex) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) { + if (speed == phylink_caps_params[i].speed && + duplex == phylink_caps_params[i].duplex) + return phylink_caps_params[i].mask; + } + + return 0; +} + /** * 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: @@ -458,7 +510,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); @@ -482,7 +580,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); @@ -1514,6 +1613,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 1524846e01b4..c67a67620c8e 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -541,7 +541,8 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); 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 Tue Sep 6 16:18:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967784 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 8FB68C6FA83 for ; Tue, 6 Sep 2022 16:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234302AbiIFQl4 (ORCPT ); Tue, 6 Sep 2022 12:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236580AbiIFQkz (ORCPT ); Tue, 6 Sep 2022 12:40:55 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60081.outbound.protection.outlook.com [40.107.6.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B45C11800; Tue, 6 Sep 2022 09:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cnHOePxcC2p5Y8nkFbP48+ZMF2WEcdHv2TxZsgwh7+Ca9l8VuC3MvFCa0jUpNAfzakUwt0N+sfLRHeXaT0WPuyBsRJDJSw6fG3/RPrA1QqbWcNqSOU1PSoiyQYAKA6YVwWNMvCIusCeyOe3reLt02WXtibFh506y+OdeDZp11mWh+bmJqnAqRB4NKpUSMxo2nCjz3tdyXez5XXMtK6PQXyprogsRwsnZCLkm8xpu1RWfleogcyvwkaCsQIuAb70BkW4Rh5r5JQJCVqbhi4bE1k4bpIeRaKAte3vJgUY9TN2L9cYx44lOGo8af2FKjufJjq/NEWtIjez3vE9v8DshIg== 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=fAAAIAyEQSlGDLu1NDtLboTnnZN/DS5/Jnsp/xW/C+HHLhlELHq1B6hPvJrgTeCay3aBgeEmXtzWO2b067Y5EDiO1vbP86nZL1PcajNMHUeGXSTz7PzqL++g3V5mSZpA8y8Y9iTAlUeDWrTVRCJHrmRGjHN46EAZEUN6iC2Wi7c25sHLyrqhd+46AeTXcgvFUQAeBQ6pgkTrc4KBi37w9V+ZjzADist2ysmLwWkFYv3JQzi4Rz4n2MdIQiRni7E98BFI2hSeZbES0ltCqW2hW1Oom9XzLWbQ4clqf3MTbZyDbxXegvT5tBW46BJk1oi96fsCuOHhBk0AKOICkZF0yQ== 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=zTR5JNE9DY9fAAzSmtO276HYmUbrfuCBZMpaxfljqUGQiQNjcJVrwTFx9ohh+/dBocq/4Tz4DGofgMbNhXR6Gt9B8bIP9VBIYSgOBVj5GiHVctEMFIWoEdyg6dErsedGdRIOycKmmvnULCjaCpXUIyEmU/WK5A0BVF54qxvzYRsfpvoni2O54E7aaZkBKv+IGPEAYJX3JrtRGMGRDtV7PeXhjcv7ajtzoGsP7k/jHIDGaIm7FqbNpA7XIlpD/xUg63eo+g5gHr4L1I/VspPsluBsDwugatUMdvV1kL9iSfEuBUrVV+28OFH5QACKj+UZxcqsP8r74vPY4y3A/iL9wQ== 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 VE1PR03MB5664.eurprd03.prod.outlook.com (2603:10a6:803:11d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.17; Tue, 6 Sep 2022 16:19:18 +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.5588.018; Tue, 6 Sep 2022 16:19:18 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v5 7/8] net: phy: aquantia: Add some additional phy interfaces Date: Tue, 6 Sep 2022 12:18:51 -0400 Message-Id: <20220906161852.1538270-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: a9a3cb16-b3a0-4d2a-ac61-08da90238a32 X-MS-TrafficTypeDiagnostic: VE1PR03MB5664:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /TE6v/DCCqjtX3c+1ETdBII382QbwJjrr3jR1Gbdd7zQU3bM2Yzqspqonl67AC5PP4I5wU47ODNEbL5XBOvB+V35Wr8b/TvVzO2nnlg0YfytsRSXYeH7wCQ36gmnTK7u0mHkDK7dRFtJ1fFLyuAahYGYjcxrELBmMcAA4YMITP2E9W3+LjNwxgcVPoERfTtBByRZ0gJb6h0m+ZN1JS/rZWnPL+hxUnQkJQz+Ioz6V6FF+GSxddy8dMqYIj8XS1Vafrny1Doe0A5G74rdTTTcV9Bi0FjBtovAXRb6vNs8vuVtJAJhdBtu4Fu51h3TZYiDWij3v2h9DXWPFB6iww3AwbWDEAFgERcw5NY6bnCvRcLNZLTf5gUOACMNbpHc8YACEgRMsU7eFyalpQ/TORc34cREKgYblkNpP70qEoZM2JlDWREnL4B/WGU0TScVJmEqmNhXETC3TdM8qiJfQpv4yr/c+M0iGcRru1o/tZEZ0KAG6vMv0+WO6/mhZfAmt8DiZ0ep9wI/LLQbuz+CQfXdR6mucj42jNiI9CGfFjSRLTExBAQn0MsWm8gOKnjfknMw9xZOJuwCd5eCqLV995uMsvvcPlOEb4HTUJjASrD0ZGA1hQbnzGgQbQQEMOka+7Wj7h/56zCjVYpGX4LqP/jF0V/RxI7FISdqpqtQhiLcVM7eFUD6peoacPiJAGW3fAy/yfAJZweziho8wrdZd6iIvwCTbiNYYyLl4fCi6kHmjtD/hCAuJEAXK/dkQbesUeeOPS14/WabUQxqrSF1a5ceEQ== 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)(136003)(376002)(39850400004)(346002)(366004)(396003)(6666004)(26005)(6512007)(6506007)(41300700001)(2906002)(38350700002)(83380400001)(478600001)(38100700002)(6486002)(36756003)(4326008)(7416002)(66556008)(66946007)(110136005)(54906003)(316002)(5660300002)(44832011)(8676002)(66476007)(86362001)(8936002)(186003)(52116002)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sVpGdw/Ph8Mj4FjnBpQ7s3VW5Un0Ua6TJthMmtzOeBdIgQe1wJcufADA2zE5MPQl1t4j+1jJ1xbhepgvMB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uy07mEgfGqqBp2//46Z46eHN23eShHj6kLJH+R1oFt0nHgLiWlyjk4CA3u0rPU2O67dq4lKiXdXEBX6dZtYq/Ms5bqG8AjlGOEJOYCKb5uOFn5p72Cn1Uja/CjcprvDt3oOsc45S5pIfgnFkZRzj+w5nlx2Zd9b0bAvclETZFltqBo6RfP4nEtQOBdSzN6wfaYuA557FrvztgofvQ2WK7eQFafz6+J26b+LEaPtW/3dUlii6HcMMZmiE+8JNnyCuv1YokGnzoaaYetm5IDBCjhO7uDm2WnLhCeoBJGOuammnCi9zwGNS7rxyCAg2BOUFQNIRqjh7H6u4ghwvZVyHru2RslNSMWiwPpO0F3v2Js++RcavIGJ1GenqhodhDyCJA7IgaXlRqlINoITpm/6iX5VdVtVIgIKUy7RKTQT90eKF1WmuRWS47tfIWOv8G4g== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9a3cb16-b3a0-4d2a-ac61-08da90238a32 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:14.4428 (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: CMknJOM58K7vcrwcGX7Fb8rT+IUlD+erNk2YdP9WZZZTusPkXIcssrX7bk+WTULTVkFI35OK5ilkujeNyOehLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5664 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 Tue Sep 6 16:18:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12967808 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 400B3ECAAA1 for ; Tue, 6 Sep 2022 16:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235879AbiIFQmE (ORCPT ); Tue, 6 Sep 2022 12:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbiIFQlF (ORCPT ); Tue, 6 Sep 2022 12:41:05 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60081.outbound.protection.outlook.com [40.107.6.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F20651758E; Tue, 6 Sep 2022 09:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K8eAusa6+8ogAFLEsv5Cx4t+u5cH23ZXr6lgNRFd/+AuGxr/5tzI0WiOYJvaaBXJ5FjC5sOBQzODK5wpUYqa5cghtQJHW/IQ7n+LpPGeLEBzh0AIgMpJ030EjBZiWbKZzbIjcOHqAEJE4WwsMC0sHH2QRQrLx9smemnoNl4L4f1iYXWUsoYwmfnyhYKnJNLEQlLRs1orZ68klUGlpwdqxot6CIEkrlq3C6FCda07z7/bPQthI9NLsYQa9Yce/zRrvGxflDaZ8DtB1EdnzCMMInEHgQvSSUsEmHEuCPAA/uVLl9Su26TkVV+/NtLT1qZUcYrCgh+Kj1eHSxRB+3qnQA== 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=QiAffapZikW7L6fYrZmH9Frw4qiWqwQ8MgkCGD7xWYaiP/QbdBIuDlpI6NmzKbZWBwBpj1kfQg+QPRFirNYBdpECdWDSrGTX2NEcNRD64glJCAUTo1fKRL2gDHjo0qaiyi+Agc6sSem009ZfyMQg0A+iEhU9aQ4mVJF9oafD2UV+dlfwm5Qw4X2fm+VuhOIofi75OSNKM5T8uYChnRDFT/ADXuxASKOXPbn0F3WGChLtx6vsqeZAG+Vn06eheM3QivJ7keg+EEb1XVcBoiz4KRycLmXrMbX5e3BfkYIwCr9p1R9TY5ha+tYlufr+NFK5bzg7aBCyFLstfqvc7+CRIw== 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=lV9LP7mOJOoQKbyAGs+EhbgEKFG9/csTJ7EHMrxsMy96hlMMZ0bEpPDrmgcV5mmcINv/4XK0fy5sSVh1zEV14SSACIfikg9fT5utbzKR0fBfNYyCsBNUPdDCqhLe5JpBDWDCJEUOgyI/+Nd4EnTDbPpmgxZ/qCWy4AG/k7IHOfYiV4SoXXW0b2deK1e6B5fX7mNPCvJTDNwyYTyizoVByJ7/m4eGDVv4IwDrZRpYizynsKn0y+2uBDQN5s3RusP0PIV7NFahIGfrPDIEpJqHfKM+2xlwLi6RBtkLokqd/eTIU33kgyQfSIcczbt+OCEQrhdI9N4KP7NYN+XroOCYMg== 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 VE1PR03MB5664.eurprd03.prod.outlook.com (2603:10a6:803:11d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.17; Tue, 6 Sep 2022 16:19:19 +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.5588.018; Tue, 6 Sep 2022 16:19:19 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Alexandru Marginean , linux-kernel@vger.kernel.org, "David S . Miller" , Eric Dumazet , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v5 8/8] net: phy: aquantia: Add support for rate adaptation Date: Tue, 6 Sep 2022 12:18:52 -0400 Message-Id: <20220906161852.1538270-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220906161852.1538270-1-sean.anderson@seco.com> References: <20220906161852.1538270-1-sean.anderson@seco.com> X-ClientProxiedBy: BL0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:207:3d::23) 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: 4d1a6a4a-df2b-4df4-75d3-08da90238b23 X-MS-TrafficTypeDiagnostic: VE1PR03MB5664:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bu1Bd+tn0qdA7MRBrW9WkEEzWklEYzpSXwtIwPcXEqHVMmgDifkw1DIAts5cvijzMMTOW/8GicLFJ41UBUfD86z9C7sVKQj6rvCncYuUdy6iOwPILzKzZbhOwj1qz5u4Cw9ebOPm4MNHMn2c6RUZkuraS3onesepu+HNr6UcbR010R0qupTkz4I+kTvqT18/q6pqz0C3OPJw3FwXaY9CWm6MOo08kBwSNTVJ0Za8OWwp8lfHWfg3/9hedhrwAR6Yk6c0jayJxdCJnCM3kB2rww5wFqCAuOhPwX9nw6ZpRc3giYjPrktrxxkncQKiAUmHQH1pGNuMG01Hur+RxPMnmzh8LcWUQc33uoDs1fETI6hJH7T5dWWUCKPRy6raOHnf8pu3ZHuTbsXAEYSAE8eEE9dis543AKre0KxhL7L1M2EunyYLel1tw8xIIKakx2kIEfzH50WFuoOwAoiIb9ikqkZrEGlkol63AL2BOq03RcT/ECe4MHtSlMG9KVP1gIgXCqR7FcEDTckF6XFbhQvSms02ZufoCwayG7mrWApG/F42Zw1JAQL3PQpXOriX8I85SkLdb2JH1NnyR/nNQpXlxaK8eBZKt3VQPd8b1gwFCE9jMg/L807Pbv+OmwzEvuDzdo4Khg6VX6+TKiEBTq4ciH8fZmlqo8Sn6VAKI7AD48iz+aSxonVVMZGhwI1kMEd0nlpWdL/UKv7YQW4Vo3FQRK8FEmup+IkTy8vkpExXrS/+eJ+NuMYsT6WJluv6Lu0lJ0i78EmZZKD2iEDvQ0DkUQ== 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)(136003)(376002)(39850400004)(346002)(366004)(396003)(6666004)(26005)(6512007)(6506007)(41300700001)(2906002)(38350700002)(83380400001)(478600001)(38100700002)(6486002)(36756003)(4326008)(7416002)(66556008)(66946007)(110136005)(54906003)(316002)(5660300002)(44832011)(8676002)(66476007)(86362001)(8936002)(186003)(52116002)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FGVsqDtKQhSFiKsWNwXv6pPjwWpgduA48FFZsmhS/g58SiZwROLq2YCAjl+smHvanSvs2aYk7GxZIauVk77NQBKYq6er3SLjw9j4qEHQYkAdfEvNopAlRtzu/6LroXkj2bwaa3apJA8NkEWTZv1MiJGQK44009esOi6z6DJprWCd0v/cxUBGvnayGCMa3i6uYT/+2j6q+yLlWPTzIhZBUZG7NTnJlq8UvoyTEDlizXXDqw+AOKv1qP1DI3YsHDzAYhV7s4lQACeTakEF4kp2/g+wZZGPs/2jWIky3bNHAWUcjsbULAxkPh0qyA+PpZDoqvI4GMNooTa/ayZipbis8OvyJdOpgaIx0KbdHLyALZJ0JMK2CUMtM/x0/asUxq8GZtUc9j3pgOxfq9t4gbwVmEq9ncQ/Z/agNJGZCaYX7V+w9Y2TPz3pBIC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lL9lnQTGXaRYKv66spCPnKOJjea58JXjadpHTnBtYfqrMnb/bJBWpBCWEQmPoCinJdndszUCfqSTnIFYnZpc8XqBpIw8luyXxyoY9z72xIYMoEOB9g== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d1a6a4a-df2b-4df4-75d3-08da90238b23 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 16:19:15.9895 (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: 3FJ+8TbRKB+X9/Ng8GrdVJcWeJ90MluNF7uFcfs0vo7qfK/0wZtD0hmxh1wm8TXELvT08QBEbm1UCvoRPDwSPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5664 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,