From patchwork Tue Jul 19 23:49: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: 12923171 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 C2CCFC433EF for ; Tue, 19 Jul 2022 23:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237378AbiGSXud (ORCPT ); Tue, 19 Jul 2022 19:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236622AbiGSXua (ORCPT ); Tue, 19 Jul 2022 19:50:30 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9146F25C57; Tue, 19 Jul 2022 16:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ERPAiC4LOOy4PC14BDqzO74oDp2akDHpR2z/jsomPMpVvI8CJsGPGr1UwwmnWSYLS5C7PmElzR5RVkAeR4hQSLf1RGuP1LmC3qiX7B/x+PaJlU4Y9qQMTR5aDktYYhCo3XblwgXiu3D7AsmvJLRQyFdGtQXnGT3hIC5oVYUfeC5AB253RsmtusYeM+Dtv9kNZ7bCJpO0aHVaC5OamxSruCV9RiLtChjg+CV4GLP+fQtoA9xU3NBmSnpJ268r1veSyJjtxDCb79BCOMFdszDzx2JcSiz+PTF2tq4W/APa3JAp4Ve4emflWbj0Aofcdhhlw2QE/IHzjZjHR6o+eMl7DQ== 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=4wThwakpFgpW6if1xxFDuJvsnxfSpFG1WdwhSDBloCQ=; b=dKsyYy8rpgj2lfQF8QwUQUJypU+SWgD53RredWf8DB1Xfm5Ee35fuO7AmcAlI9LK29ejqnM+HqYcIXdlzc/mbDH0TosQXa1Ke4kB5KAqOtcHQqBbKhvRxiKGkoLU9A7PjeS+HwLCAe9MHJGvwKgo1cb5BwxWEWxJ6VJhD9UrTEBE6yEExxxXSpQlpWCqDJ67vk4qbJetM6PB6D+1w57bmdtKWcYOjR5Zyem/sjaxGGilUoUB0Rl4N8MCuaDQzP2IqG22fNUN5LBEdtZwb5gWFgyE9lGng/KKtr3nOIxeIL+qWLllOCm3cC0NYwcnl9fi3Fez7cziZdkVvw9wTxUhLA== 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=4wThwakpFgpW6if1xxFDuJvsnxfSpFG1WdwhSDBloCQ=; b=qb8B3depuzjPAfxxdj35klFTjuGvCFq7zU/AMF+qHtEn54Xx2Ne7E9zFuZ9khPhyO3s9wH+1fD1ke4wBwhwQo0XE7asmwJ/g2GEA7w14NEV2ZORSJe++YzopebJuh5k3hGKMu32EAB5uPC4bvIKqFUXEJOhBEJ6Mfz0/HSQZSMgSWG0dMJpLrcadlSqE1pZOecv0TirIxREHU1r3Nhf9cyERO8BnKAxjOsun53QP3F1dAc8phTrAjiBemoNja7kvxETHmId5ENZR5yUM0S4InKKtaAn2qPXaKJucPgA+SwcAYgoR7+dsTr5R6aoVgt5ygra6Y0arKV3WYnDGRbSMmw== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:25 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:25 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson , Bhadram Varka , Madalin Bucur Subject: [PATCH v2 01/11] net: dpaa: Fix <1G ethernet on LS1046ARDB Date: Tue, 19 Jul 2022 19:49:51 -0400 Message-Id: <20220719235002.1944800-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: a50748dc-96af-46f1-ea19-08da69e1739c X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q/KbhXJ+vRLenkZDnN+UrCy9fuIam1uL5RILYL5HdhD3pDj3+s3cPzIQ19KtdTwCSMxkqsqO61con+TjbWWnyeSdTBdbx5RcOstBDRstaLzKjxuis3d0uX6A8uYq4SBljIqLFB/eK7SoCePi6p6yEqNAvVfy0StRFO7kYordL5SW0WTEAYS3AeznqakR4XhDinIm1Ema069BnANmXtX8sPfYj3WSvglMPo43AOLVOjpWHXxmJXEwIG4aOfqUhNJmBbY+25+RmpWIkVwJ7vjewyL6mgHFU/+knDsu5paK8V5GIECSQw0rkAvfJMgsdDMM7Jk4YtQxQBUrb6w7uUzh8bcVzzeBwGEka+0AfbJB/qztmFnmwzPS6tQOocmjhWMuSymLnmZbM7WKM0NaNWcJX73+fTk+yq9UIyGviGPIbKhhwX98kdZUTqVCP//8QWBRO6aMERim2ohcqMqm26O6Ki7pbaGiYwFvK1+IISjtg+MtsCgI+mWKo9MtulQxkkrGYxO7AYP8sajtd7+ZbLvnA0o31qmEx9z5Nucg4hMEr+8/B219eVp1CfLzwNccft4KiPgFt+IgRavRVa9mL5dP2DT4Dl62Hui0yKzdx5xROoyol0GzcOQsBv156NEjn2/k2EQ/35befwO1wF9a6kdriribQE2MKAxiO4vdDxU5sQyc/tJsl3jXX+/pWR+kPaS8Ihxwo2RY6VN6D1MOVaTkbGEfLujDz2L5zi2+xmzNtbd4y3VLa9IkjgFTM6YXkhHDDYSGvjTjV3cVgtNiVa/BlnZp5jyxf9dhZt7zJ3tP/m0iOQEYgVEgDE2L/B+OrZu3 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /aYL3dfiOyqtETHmRW+ytMUc1jhvhLWZVnvOrOXoAJR6uf92/rCpD7SeOvOpo2yEVB4RwsT1aTysPC6SIL8w0ONpnGAZ3xYrpbq21GVeriQia+sh9knl6wnEcqAUQICZKzp3sOm2t5l/kRELXBB0Uty1vHf4VTH3QXTy/WO9+ABFicHnwJv8Xj6aEIymeSAUWA9PesgKJaM7AYpqaEsYf2ma97MDpoYQZpDDnvErZAIfi8Xxx2WzEUIo2ytrdbUHk4IhmR4MwGipTUrS6fgVoOhIdaBlUhHfOL7ApLMRgAk3nrY59Mre5Az+vW8UZMcBZwTSkEZWClEHWUwuZQDFMJ+5H+DA+JxKaxVdizE5erHYzG874Pv/g3U0sSNQsMxRbfFmbWW5cba2NHScLXnJVEKVeq5PJiYusoC5qIX0HBHDCGmMLo5Hh6Cq5NjvPRcL3osgSeXhibB11WRqyWSD7NY2ldOFn7nHwDR0eVPclFLT//MpGKCxpmycFnrJEv7GUMwgPiz/liZtofUKWg9S6XFM+dIIrTd6uwoBrcJ72qHqQSOVOLMEdoMpiVqBOXln5/v4Q1b4OgJFa4461hZY5ho7XxyhiJVd7kxcJAu/mf4bXMjC00WKbUMCuinmQzWDuVhAAjfjC7fKvlIvu80uj6s8oU6HLNNkQm1KpKggDTB0Ehidj5NUlez+8BANhqhTF9fdW0ZJ5v701AJNb3C28weAG0atlxR8oXy/6WDI1r8bBXofZ+O8jMRf4ohO4bHWCACs3N9xKcFEUN2V18YOAzB0udRP/GcDXuV3w2RyDu9HQAd/uQi3jiO5RIscfEF6M2I9wpaWfgFnQNY+yosXzDa4nWEYuoTZHlHJTZGAuhio/nL4IdPA+OTTeGP3URWCLyJ0nJEfyqC0mrwTKBrzloghxkXCqd/QNYpLJA3hCmXbXECypEpVjlnB/n4IY95FqLp1FKH4b74aHadAvwnYoeofMENvzTh8yoMbYewXwCHur+T9N5mrWhj05W589uFRHJOEgFiLIOdYpKbPDhyLsRVJVu8dbYNnn9ZX+FRE3NDpHjCmPvByp9qXtE+YZ4ogqXRbR2aAm1hLZwBYwaKnSHcsg/t4N/+ruRrK8Jgk4ttbDBDpEbinqm9AtlT74JyX1bLZnvbilSGjuBSNSuNtalbWPRE0l0OYssjqDqDH7DRMuxjy0DUX3AIwFCsmVnXlgUD7Q5zhVPzTB6KOtHOu/l7XX0yyTEQd2CY0PVHKOdiWzFycASs/fxaMcl+kvfvLcd6jGyQKVcP0iypnJUcUaiIM1kCmVmta3BsPq1yrOY0IdrfxZuMPEiV6Zauqn7/k9785ZUF9K2xiiILhz7rkF1y5ggWiTZJ6+Frgrb79mUas2aTlIGQyU7gJPojVtpFDuyl+zKNH/zkf3sOGwPqKDcixdUoqwoHlvLh2IzlDkQzF7NC5+ppwhrfTZdAYLd+7imIPgC6TZ737Yi7TAyZGkgflm+GgCpDwxA9a5RHmuFxLFmbpUvqIJiy8Se24fvjrGn4nF80tdnLXWKxYfF/tXxiv9dMiOeqKI0pWBhIyIIe4n9meGYdng6tCmZTte6lPskrsytrEDrzN0bwalvc6tQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: a50748dc-96af-46f1-ea19-08da69e1739c X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:25.5661 (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: PlD7akeWgDRnEkUR71wSbzf45JPyqVAzyz/KsYeC5rb/8IsNKIYOT7QnYHfdroIQeB/UJTw7Vci4r6+jUIoQfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org As discussed in commit 73a21fa817f0 ("dpaa_eth: support all modes with rate adapting PHYs"), we must add a workaround for Aquantia phys with in-tree support in order to keep 1G support working. Update this workaround for the AQR113C phy found on revision C LS1046ARDB boards. Fixes: 12cf1b89a668 ("net: phy: Add support for AQR113C EPHY") Signed-off-by: Sean Anderson Acked-by: Camelia Groza --- In a previous version of this commit, I referred to an AQR115, however on further inspection this appears to be an AQR113C. Confusingly, the higher-numbered phys support lower data rates. (no changes since v1) drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 45634579adb6..a770bab4d1ed 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2886,6 +2886,7 @@ static void dpaa_adjust_link(struct net_device *net_dev) /* The Aquantia PHYs are capable of performing rate adaptation */ #define PHY_VEND_AQUANTIA 0x03a1b400 +#define PHY_VEND_AQUANTIA2 0x31c31c00 static int dpaa_phy_init(struct net_device *net_dev) { @@ -2893,6 +2894,7 @@ static int dpaa_phy_init(struct net_device *net_dev) struct mac_device *mac_dev; struct phy_device *phy_dev; struct dpaa_priv *priv; + u32 phy_vendor; priv = netdev_priv(net_dev); mac_dev = priv->mac_dev; @@ -2905,9 +2907,11 @@ static int dpaa_phy_init(struct net_device *net_dev) return -ENODEV; } + phy_vendor = phy_dev->drv->phy_id & GENMASK(31, 10); /* Unless the PHY is capable of rate adaptation */ if (mac_dev->phy_if != PHY_INTERFACE_MODE_XGMII || - ((phy_dev->drv->phy_id & GENMASK(31, 10)) != PHY_VEND_AQUANTIA)) { + (phy_vendor != PHY_VEND_AQUANTIA && + phy_vendor != PHY_VEND_AQUANTIA2)) { /* remove any features not supported by the controller */ ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support); From patchwork Tue Jul 19 23:49: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: 12923172 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 A9CE9C433EF for ; Tue, 19 Jul 2022 23:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238043AbiGSXuq (ORCPT ); Tue, 19 Jul 2022 19:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235353AbiGSXub (ORCPT ); Tue, 19 Jul 2022 19:50:31 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A48532057; Tue, 19 Jul 2022 16:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ditGNTEa0vIlSRicM19M8c6teaSI+tw6OJAhv13OD+jpa9xoT4K8aNH1nlXe4tzwVP0ROLEcAhHm0mU7vY7tG594MxzsjuHHkVbMkF7p04VhTDsUWhysn7TPn1lJoVhItoxOpVCjoGVqo19FrtmBb2QxWb3PVoMQxsBOemOCoJagQKU9OfqYDxEctaFjrQCh6CI+lCMTqNdlBFsJHzEBy9/vP38X+aQs94dzjYw/crjgGMzdfI3uDe5Z39KO8M9iCUWv1wlEtlkfA5NpC0KcGoGolSyqlyNcAyGscNM2i6g7drOkhIFOusgtgVA292/79onjT7sDCFaicHkM2KZijw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zVN3RE4YPj3naLmLY7q0GTywVhKdcECxcsV/A7K37bA=; b=Zks381DFdugW4NmhMBSSpeeHTMpVVEy3LOZapfGH7J7jYx24bjZtE1XoQEJx/E9pzi7E0UFVymmdSTkjbEWuVTIdbm4eNb9qoyQMJYr690oFBiwDey64Bc957Oxy3F+UOWlRfBo/RA5X4Y3sutyiXalNQzmzacy3xVZ8mQKxQIR4KmgRJSUkLMWHn24u1jCGzZaRWkg/N9QpZ4fpt9y4+EntEYHhH867rXvQ0WNdVJN5rQbn8XOmG+Ut4A9/HINXD5YTtemrX28gsjN2Lq3GQ0GofHILmQ2U7syZO8iTwRpb7vQ0af0fDovPaBr5fJpijRO6nnUaSxMEzY54qZ/KDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zVN3RE4YPj3naLmLY7q0GTywVhKdcECxcsV/A7K37bA=; b=iWGIXvmHZypiwKrRXjX/dwhhf9cGhs/ueGr0uXzS4KRwmJKQ2geW7xm2LbLUDJL25uEabgl+YKgbW9vPnyYFqR+SlA0Qpoif9rMLUP6ziYtTmX7HLE2OlSZSxMT4kawHEvHy6poGJCfzxBlR6xqytjzLBWPCnzKv8czgvsgf86uNtuNdhuyuOsGN8z3BoznYbnvehen0ddHQBWVUDRy0JO1l+VIbr0Cl3I0JeVTcLWy5M750p5l4Y4Eml6aI+dnRQHhKu8Dw34ElLKjhAVVmNTPl9iFCc+JFolOVef3que/55dmfBfHPBhIlke2zlAJSMEnVn+uxmf8RuoKFvpnhPw== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:27 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:27 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 02/11] net: phy: Add 1000BASE-KX interface mode Date: Tue, 19 Jul 2022 19:49:52 -0400 Message-Id: <20220719235002.1944800-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 2856a7ff-af83-490b-17c0-08da69e17471 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EkFdIfjPHV1FQV60/825EArw68wyjdS229+UnIBbMkZPZllAJ9t01D8kJd9NkfOhp6Upszh2PhqE2hcBavGnvQmF10FfpyEFaT7nb88QLZI+WVQG009vwVZI5BAmY9cTgtXbZ9IUleRxlDG+dgFqZ0FjiRV9yAP12mpMnbHUAzArFCc8Hb/VGYj7Zu9C2m0F/t6rztj/pfaqvTpFgdtEBSN9+PvAyaWXOZCxAnPR9HUZ58J+d4RAvSn95VvpYYaaz+BoA1GLN6nsQDnp075btZ0yfteTZcooXfqLN2P9zPmG5iPbb8mMkdjUElpvPk1IoJVzz6Ubrozwu0ppaaGhRBRISPL6ey+RoVLutFzmnrWQud0Yhss3fMhNcnSVKn59o0i3tqfL2UUANjUZ8kV31Xe5KxAgDyKdtgZGQcS2VK7vn2j9eJjtLFOPSXtHF81AgivuZ8qieMtfSKdx77wLSfL30iorNBfWLpw9cDVWeaQNN74/T2HPe9aXVLQLyu+JvaC22mIQbJC4uSP1Bq69Tshep/RaP9O+2t75i2PsY8FsnyakMOaO3L3KlYPfc7oiUZeuLHkbPngwEK43Aq+mVYF7O4RJ5xT13T0PMahxaiWLOKux+Y9qEXoet/QcmJButUPaGcvIEfWee4qrN2udOtJJkBzMEMCViZhzgiSXC62BgwPBBd5W7infQXSIdygwYMemwhzajHgflsr1CC3IKFpOm7QebJbNN1kJFDLY6bLnhyFqrLo3oafR9GXmv5U3ju/aDzn8HjYHZ4L4TjykbBNa45+DujAhzs20/pyX+RiVvRvfUUFwu322NOKLasU+ 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9/5446gi4+iJFAQp90tYDkiQ9d2zwhZwWUlHpxJYElQ0x9hSqR1wZdLWdvzag5Hq763rVDpiqMcu9fR4QzV5ErDkdhVIeolz0u3+QpLohVZdyi8aQtQePV9SM9TR6jgM89KzNGT6q9T56pCMI8nPo/qY7f71oQE23phJoBvbac4yVZVfKa8RU5Ge5O8zTZrgRG9TX6sRs5aVHrOewjLz8uXeN5YfVxRRdGak02i+lnGJHL+b6FSYKpotYQAHYvAz1165EHQYeMh26hk0fcumFi0qfrk+8I0btiVBv7meFDQZDd6YP6oAa5Khvx6jyDCrLDKx1W+1Cy++4TM3r68HY263C2L9JqQGL/qoTzgFcPOpcMUTuynxY0xNC5ZESmO1ffrJOohNkLrKogD/Fi/Nv8HuwIAmSImGtsNzhPl2CLA5xYBhwokM1GKkdcT1hRB0RwG9DeC648wLNaEQvszvhcT2SB1s5N2bxgBAyi5812FOibgOfcDi7d4rgFdpxFFGtKQuH503HTBHSbHKay7E+mGIaJ7oW4dAuvCxRRhXGPT1/Qkxi6hBer9HF6ZsvzYHuzTcfaLOW/Iz+8PNuLE4iZ+DJaD4Puu+WTvwPQb4w7Ef4e/QDubs0tzgLRRuLMKs0k0M25It6dlAO40o4yLVurdRpqlrWozYBgOy9m4cAbXsbMgVLfiUIhtvubY6/FUfH3jRqkjfUpbbbBY+XdLu68u5+FdQE4iCDNObY/MjTfEvEIolv5NfbkCmETFbqFNvH2ClpgOzgiAgyYv7crFwvJqL+Bp2kVwixrVMwp68xTWJ18eO3SePxcZJmy36WKUk/GGgAFscC/LHREQPZjRDhXgB9LuxJJON7W8FpJFG/gLWkcmlaQ4VsPXKanulk7xJNXIffNbGmUISqDCKy2rBtf6/ZJhEwuwWGp8aq08I2E26jWOa/DqLLf3EsYFor+FVzSr5+t74sWtiSfXAIn/588UWcO7v+igW0QixpbHLAVleifXbpXH3WvVDy4XqSannERxxIqJAeJ+fDMW6Lqd+OqJDaqeajam+pfG1/cj+FhwFfcMrMrUQRqZiXLrMONsV6PAVXsWzkVRUJRnKxMcRdzaQGjw/sT+pnGabEFNmVpFke3plHED4+rfrjgl8yMyGwfO478TYdXtVVFlRsKPEGmviLbEoz44mtc488sWCvGF43YrCBhp9sbk7r3L+wTSJzRH2R5gIGv6Ui74vzMrXdNqTVQ4TwimEfPIEkXuvZ2sqOlSYxkBpzpKqXR32b5KCP31lzRsDRSeNKMQ6EYBlVXzH4DD0DaEU01YLF/bqLJCYUX+RlW63s5m/1xU1f3EHdMBoKeMH63by2y6NZyRSB5b00qdeIjZm9SlL1f+W7w22CoZJfpYfoM9nh4tLI2P2L8Pvdp/QtwOIBCJrPOcIoiUP3+VTIxBaQmRcyynw5/qhsoRGvDjagUcx2RE9GGsip5gAWCnDg1qP3MnR/qDvbD2gJT5Fi//RxpOCn0EGHvXVtCG8XsEtLW3gxZjElTkjsAAmZKfi0MtNtG0jraVW7Vwonfvifrl9Lpi1ZOCK83Hfcs9GkhnzorPhTHNfH682tBK08XfJiR0iKr3hFmDa3A== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2856a7ff-af83-490b-17c0-08da69e17471 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:26.9410 (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: B+ZH0aqnDbtSh1bF49IXIUAr1/6gaKCHJaYR4AEVJKSuMbGkyxryaE9pl+MHx5Z00u6d0iMPhyFQQLgUWoTpRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add 1000BASE-KX interface mode. This 1G backplane ethernet as described in clause 70. Clause 73 autonegotiation is mandatory, and only full duplex operation is supported. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 1 + include/linux/phy.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9bd69328dc4d..b08716fe22c1 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -344,6 +344,7 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, case PHY_INTERFACE_MODE_1000BASEX: caps |= MAC_1000HD; fallthrough; + case PHY_INTERFACE_MODE_1000BASEKX: case PHY_INTERFACE_MODE_TRGMII: caps |= MAC_1000FD; break; diff --git a/include/linux/phy.h b/include/linux/phy.h index 87638c55d844..81ce76c3e799 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -115,6 +115,7 @@ extern const int phy_10gbit_features_array[1]; * @PHY_INTERFACE_MODE_25GBASER: 25G BaseR * @PHY_INTERFACE_MODE_USXGMII: Universal Serial 10GE MII * @PHY_INTERFACE_MODE_10GKR: 10GBASE-KR - with Clause 73 AN + * @PHY_INTERFACE_MODE_1000BASEKX: 1000Base-KX - with Clause 73 AN * @PHY_INTERFACE_MODE_MAX: Book keeping * * Describes the interface between the MAC and PHY. @@ -152,6 +153,7 @@ typedef enum { PHY_INTERFACE_MODE_USXGMII, /* 10GBASE-KR - with Clause 73 AN */ PHY_INTERFACE_MODE_10GKR, + PHY_INTERFACE_MODE_1000BASEKX, PHY_INTERFACE_MODE_MAX, } phy_interface_t; @@ -249,6 +251,8 @@ static inline const char *phy_modes(phy_interface_t interface) return "trgmii"; case PHY_INTERFACE_MODE_1000BASEX: return "1000base-x"; + case PHY_INTERFACE_MODE_1000BASEKX: + return "1000base-kx"; case PHY_INTERFACE_MODE_2500BASEX: return "2500base-x"; case PHY_INTERFACE_MODE_5GBASER: From patchwork Tue Jul 19 23:49:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923173 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 63FDAC43334 for ; Tue, 19 Jul 2022 23:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239236AbiGSXvA (ORCPT ); Tue, 19 Jul 2022 19:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237785AbiGSXuo (ORCPT ); Tue, 19 Jul 2022 19:50:44 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3C5F4D4DA; Tue, 19 Jul 2022 16:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=chepCmvrReGEEK97zTfgQ4fzIEi/q08cr+uxO0sXe+Tw7k5tjOedeboCjDe6GAFOGCxA//gzsXPGkG3Fdphuu7MEe/0nd2v/kHgB1QliyAvm+MOvvhWz+gIm8G88KUYJV4820tTCYMNMogiVf5grrD0DGHsSmy9m77UvOqntnmyF+0mGOiFYwEe9FUIz2Oi4hPxnY14WEVFquID7ol11IQpdUWtIUQwKajOtRfZdAxKQXvJyfY32sh1s4klEFvDQzlXNqsTA73QtcygzdQ7aEvT5egmbT/XoQDIpqzZKWaKNZUrRSGOo+KgeUsdr9cExgiYw+AAZaPP79MNl37fNUg== 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=uFDtpGtwbedTvq8d4hMdfkybv2JwhXtyyXNL6eikGRA=; b=QfatMWHnW/fvjUn/GYizHCotHdCVbchXbJ7LZlVKjphGHgYKF5jGVtCrvi6HSID14+T4fP66zfrXmMbsgVTUik7Ajvl9bPKhQQuhUyQKDyIB1AeYMwFx7cnWAtBD2fZ/tEj2NVM82wEqleSxO4mN5Fc+P9Foxoivw+3XAE98Y5PNpQ9cx77x5Yu5oFm6G+cO2KphR8W5caM2haBJCTAlv1aUgoxti7tDJbWuUVR0EIqwHFZw2yGH+atSzkbuJws7tdV1+7tl/j9smNFu4jtk/T9i2pzdAcEq6TUSiOmianAflKqG5O7QqV5G3hmzGRCjfb1xjtqfeKU3qej/JxWncg== 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=uFDtpGtwbedTvq8d4hMdfkybv2JwhXtyyXNL6eikGRA=; b=VkuXFmHgQSwcZLM0Sw3FJDgzz8elR0OkMkl8MBM0CnXvONGqFSNL2LANx/j5m1nbkML0ImUp6KrUnONxX9D6Wj/uSvpcTKgLTP7q6up/9Rx/PUC09AfgrYQeMFBott9IYz6BG7Tndyz0y7vlUri4zsZMEEzRfTaGxVCdaHE7VESFLpixJL/m6rB+jWelC1lC5ZFyu//qWfeNRZcA4m1qP5lTm19PicRiiquBxVj1hXViOUt/WbgTNhi7ETy9oD11daKO+IJKfS0p/GujEx3WQifCzlDpIPngPI6dtt9FQuRHLLMaEM09cRS79teRi1PWK3ZF2dldbq8NzA5/2zJ7gA== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:28 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:28 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 03/11] net: phylink: Export phylink_caps_to_linkmodes Date: Tue, 19 Jul 2022 19:49:53 -0400 Message-Id: <20220719235002.1944800-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 382ab98f-04ef-4db6-80e8-08da69e17540 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1h1bWQZ/z44pdHRptY6oEaCmOjOXEnz4vpY+s/tAm4UqErmhu5F/4HCcFEAe7OOjdFEKFSYI91Bm8cDehPkQV/PLSOc2F1lMZkTtAbRvDraa30dBbdVgePKWhMULEz3xwDHwKMMXsQwGiBKtu8AxnrS1rVAlKElQw9bX7PhSGklEIaJTHTbgYAg2UGxgN3mZK3z4+R//pOve5PNzIEZU4qMrqUL41v5chWIRG7XosZmbGiE26jh0PeYS95XSFeGD460hUdBc2qWm01QmhfuDtqSjq5ScxJ6iDquXa4u5qzLU5ezLGzHebPRbHbIe+E2tcSbWII/e4eWJxqN8UXLcFvmn9y9uCojcun94D541Lvsbi8mRCGToQ1i1WiBQdRrkX+Le5XHDA0DrSZ0QGSqjc+q9WJdjYyjreWyQuiDya3ZeoHyTsjGYwuJtbIubWko4d5EG1FFqgECN5H6Af+ScKi2HoNdoDWC8Oegq7I/3vCGRunSDG8Wl90m5GnYT3/g7hchCsROvatYvK27ILGMXBHFP+1jVRSWlHCz6BbCe5eSQDJ04UXwbWdiwhBvITWRH8hhNswbUR/OCmEhI8AURDPqHyRMCTBh2KPSuQpB0AKYFDDn8KzFJ00dfO0ew9cHapSP24Fdb6KtBYVKgmDXMu1nBQFMsSCn4TzekUD4azfPIWmcey1ILk20enzf0fMeyeWFfv2pqaOB+L9pFsNU7MEiM8z2Ghcytm7WL1SLdY1/6h4xN2OEI7MHmKq6K1gMi03lyi2My9LZWjclKYOp3I4TnzAS87REQMN2ETI4yItNU4JwclaT/e/UNa1ieMcrS 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pw55dhqwQBcKqit/g8jRUGvF8819Fq6/oB0oCnQUT4IRUgWGtrnGTV85v9RZUZEyQYU/KpwY8AphKwctINNRPnV9E9UJLU0iLva/K48hHXqO+cEgEWe0BQgiFRQXtaA02LTb2/l4Xz9AzsrgbJ+7IE6JEyXn9MGCjrgVJadK0fq4sTj4kRzbrSsdSZBMUZYMOiaMActOmPF6cusL8RMQEe6or8vCGNVWVwelxad5m7TdizsCf93xtFInqXFCctr4DGupovcQTD0gYwBrQKIfe/VLmbqxaGmw2aeMLsHzpOQ8xLR+XGakQzDHHv1rqXVZLd4NHAVrVSxX8nuvB/Td1Vz1GWYKiXe236lq7h6DKRcr29iV+gVb12Cpf8gmM9fTZLpJQNHNsXh4PcrAYi75Ej7XvTf4jcJ3yQB4JkLEsUntcxHxeC+jK+cZLmGNj8+ZJxnnMFMp3BVOkcnAFQ8G37SrApOb1QCuqZHNHYe0lQ+7gDYrGZ0XqzrQApGoKmtVkJgA8BzZ/hEE6XOy+UohT56EiQn8dEWzMz+LS8F2RolBolwrSlLvs5rAQiPsJV0UjxjEl0T82lSHEOLM9Xlx2yjvbKCRdSpBFLin+JyEsXnSqXfZX8674IdUMYkyrmfdBxW2C0dIvDSRwQxYFUS3K3Er9Q6kNc78BG/3F9RJH8v0KQ8WC/GdWq8hjZK0FyE1Co0YaRvtm4/yo6klIQfpJMEVScH0TYzYABmKxJqu5XW/ranCgpjhJ9+fEcE7QQdquSZXLPhFeVeAlQuq0mtT3fp7mTzxuYCmDtrgZrI9xPTo9bfoGRbPva2wET4tPflZtxhElT8XBErNqIlK6QF7ByyjY2K4rduWhs5WQyoiTrubwHLipyGV+hBUwjwnNffmedglM9n0DkRlEeB3kZDxNJocBkv5IYDeGAiQugaf6kjBXesHm+z4d4sCMsPjx+znPRPpNRL5KunwQWaxZvkp9GN6RFiXpdaYSx5Z+SX6rKwUZ0GbGbSMcoUGd/eTJUoCn9rSw1ZmWhSOJ+4Rm3HIRy6rpiX0j1ofIsvIZlCfnXrNQ0L66GhSeR1IBS+vMAAcGDZFObgUoEx4jCdRDcXG1GMkVQu7G+A+51gnuto0sJifTA1yklinDi0ox7mzvyZdw0KmpxHxF/a57JRpO477VzMouGag8dzgeU1xQdtmh97aL3YdMiqbFqJhI5mtLJ/0TtNfDLEWimkp/35yxDKW7QOveWje8wVIGahwpx5EkZY2ODSL1wjOC7kCYjTXjKzfvMmgyxuDU/9Qtoo74oJgQEx9pqmbrQYqpqC4xNOhjqx5MeiOVxXRRUgnXsJQeZbjno+NfrL8mhZGwwORgU70uNZQmESOj7QDmdN9U12NmUUmSZJAMtFj+Wj63A8/JhL/xab/kmbMXwoYjNRTjUARsYDGmGuQe2JlU1G+yzTKT0nDr0oEIMx3DPR5Xh0HeVF+YdSp/AButA/wbr12wGm08AKNyq44KLB7N+jmknYFo2hNSDgnIzVZepdQ03Ml5w831ls84kfAqpxBXo7OYTaeJ8+2spXxWB+LkvxIXSkBcQ+io9FPICHkAigYEx9ri7au4gu9Ud1e8BCXrS/vDp67+A== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 382ab98f-04ef-4db6-80e8-08da69e17540 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:28.2847 (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: 0yLVjOeasON3kgARVxXirv1FxIdES4PKJ9UfeqKiMaAAQxv8vJ92WCBpNNJTeZ+7f8NdENnz2bRQN8excJXCUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This function is convenient for MAC drivers. They can use it to add or remove particular link modes based on capabilities (such as if half duplex is not supported for a particular interface mode). Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 12 ++++++++++-- include/linux/phylink.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index b08716fe22c1..51e66320526f 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,8 +155,15 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } -static void phylink_caps_to_linkmodes(unsigned long *linkmodes, - unsigned long caps) +/** + * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes + * @linkmodes: ethtool linkmode mask (must be already initialised) + * @caps: bitmask of MAC capabilities + * + * Set all possible pause, speed and duplex linkmodes in @linkmodes that are + * supported by the @caps. @linkmodes must have been initialised previously. + */ +void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) { if (caps & MAC_SYM_PAUSE) __set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes); @@ -295,6 +302,7 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes, __set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes); } } +EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** * phylink_get_linkmodes() - get acceptable link modes diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6d06896fc20d..6463bd64eaa4 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -518,6 +518,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 Jul 19 23:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923174 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 486B0C43334 for ; Tue, 19 Jul 2022 23:51:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240190AbiGSXvW (ORCPT ); Tue, 19 Jul 2022 19:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233963AbiGSXuz (ORCPT ); Tue, 19 Jul 2022 19:50:55 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F94B4F6B3; Tue, 19 Jul 2022 16:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZYbXUmr86JuL79PWLOM1sxYZAENI7v1ErxXpEgVWsFwGK76M33sOLkKlzVQLnmpT446yTVJcuMA5ShWfvcxYKd4xlM1y8W7oEfhKNIblC3bUqdFAudEJxFa51MR+n3rBc4BjGglJv4RnWWdedKO2SsOqniuVA0q3UIrzWQw2mRj5/D2NIXwbqNCXFKkknI8jS1OsT/c406ypcbEuSoiI+n8NxUgN3r0EG7m81LOE0WY7zb3S5Lmhp04XOKl8Sz9HlDrbidby1v3PUTdBo2raV6x6WbnlgDrhZ2tubQV/RXcNRYHFC1EiX4qPJ91DOL18fafWEbgBSnuK/eMj3a272A== 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=hfgEXjmmgUTHgHiOHUqZP5+NPPP4N8pVOkbBKMOZSN0=; b=R30bfkDRvzd8AxV1Ckn+gFmHRNb+lZtUR4nTvnwsepx8/abI2NKYXVwcnReV1T5gutm0xUiaGhCtx6grSpchtCEWKJ+zKS+oemOFu+pjaIwKHodZoKHygC+qyoxOHPTuw760glT+rN3E3/wcMCSUHZ6+9GSoTu89UzDfe8yMtRWak0p72X2DKbftSZueudL6jmh8CEJc5og0T83g/LEu2HjQqSR+096/NgYWUmEklifyeBRlfNOEgll+60hwF/Wwa3pQZe5R9oX7e8iG7zM9rvDsc7oCosKsu9p6Zz2qiSpGAKHBsdr5Rj1dysscQDQcshtYVacXixDaZW30FN4BTw== 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=hfgEXjmmgUTHgHiOHUqZP5+NPPP4N8pVOkbBKMOZSN0=; b=IgKqBDnlJomNx2bA213osDqsPAJ6SbZnYFKymwNtOlDDkgIt5TDMfEp35JdvvW5EDJcPUjO5eg6CQ9Ku6whVSJQAQoH+eXzP3tO820WLMkSCdklkyQlsFOEv3g0XGW6n7mJ7E6nP3YBxSH7BLZgzi14b2PmjUqOZNehBWQ/NgvrX5qM66rF9iV44q6dkr9ZIzxUgVDarSy30MBNZKcooo9dLmE+sRoEwxFZjBG9hIGY5Z06tyfsfzhCxPNXLJ9w2Z5a9Gr5Esx+iiiXjhCOmPbJBkFeosjp1Q9AISfMEJ38/3TpAULmPIApNw3sm6C+hsr5pAoeiUI8lt6MV9Uzp2g== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:29 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:29 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 04/11] net: phylink: Generate caps and convert to linkmodes separately Date: Tue, 19 Jul 2022 19:49:54 -0400 Message-Id: <20220719235002.1944800-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: e03d630a-d2d0-4015-ae9c-08da69e17614 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w2UnMyPl3j4HxJ3Xfubh3u7ypAKMfRuntOFPG2kv3Gbr5SFh+ZZ7jLS+hslX88fo3Tuc2BQsti0xnxPP6EO5MlQw1fBC+/Q/G/ajQFNhddbFnboytSaRWPPSwoWmPSEON5X8jqinJDgFJbG+xd6IhTFMiPJutrjM3Vm+V8dvwkaOofUgFW4zXIN1PwOminDk52yC0BpT9ZTCfNpna/CYGsJFxWRN5pNmCZtE86lptcThqQbuWZhRaImXIpM/lfytfRnjio8wQO3tI/NsmqNkyh3WIemiD4zk1wuT2dBDhtUav2UtP+cva8NxU1mbtESP64h57UbzxKZ39ZC73V/z2kfROvHg6zf0XZlZL7J8NUjMZXPXPezh52JdQNpXpKXxmeID3LzY7Dqw4J80SvE8GhFvM+LRlnIFaQd4TduPSOKwuSHEA4A1SCxiaaCkJ0ZH3hKkQytvX7z2p0kntdQRh0qZSOBzsuNNRH27WgatB15F1bRtaBQWAHzFyo8EK3eXr5TWFfCpewZ56lPUw59fbEuKSGWirjnGgpebgPAFhdhJtVJ9MULCNCownKql7E5A4dLIC1iRAYHhk8XlBaCyvlMmzcx8WUpYuf1PXzTSVhkiePXH4sqzSdNpue0LNRAFqdeleUbA6ARaKTmGgtp+d5yetnU8yc5sDOOkDJvZ9tGYJqxZYer/hL9H4+jlpFnlycfhGFJ8ZkiEjJsUYALkY9CeKDYVEPxhtDnFZKPSZD7VjCaKstdvAJCx0+IY8t4QEcyHzwyncpWj+tVQ0lLezaG3simYCnDlMvgBSyIa7cEK9nptYV2Pib02JvDySmEw 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JPPESdLgtipoFOG9cBqJQ+Ng4fajCQQXBPhELLPKk1WRfkhyevmPx0BJY9Pdnm6oje5HsEgYTmlV5T6vKlhTxcJT+7sSKwxtazQh89BkjLPbSujAEndP27kxuKAFD98rZ4rf8gm6J3WU4h0jg7pBIFMpcT1g/GGjlifAWd3tagbR6FwfcTF17VmhhN+JkLzHlazIMvG6hwlY+5vzSkcEU5upPApwmdSGSmxqGPBN1uLSvLQKr2iMglwAGGkKWUiBjvE2oBSTKR8X9ViXEKQi0h3y0Icn0xVyuSb66oDoKNhj5pIpOFYN9aB0HV8FoDgNImLKujR16PlLxp5d9hccZA1yoEv/l3Dw9Xigd7TCU/nWP1sB1SE8oFGcKco7oCVaYUs3jI3oTf9TgYXqMlF07peg+tX12iFRrrp8zTrOmF8tAXPhR9cF6Ol0DyOKcFKPKgK81VuXESuXkOLjBlXjYrldLCj+NLxQAC27ydZYa68k2LtUm2uK8VAaY0sC69Wt6WLbMY3PyIaUMXa1RwzV4PzfXo04XoIQPAoCcHu6iTos1tMFe9/Uy/iJAMtwbEGS3XFlY76cQRECIE6D3Ry1LoyuG6Z/MlL5NUmrCckjwj3U4prlnb0kFXZHG4WexTwits9pAYqgmAH07Jh5RJ+aHcnnVFJ+Dv+uSr9Ui/lY+duWpJ4Tyep3byei2El4neqda55IYMVyM6jAjeNOq7u/23gJf5R8NyE9hPMiPXcTtgZFMwIvfDgdSgOfjdrG4cZArmDJ+6N74MHDa1ewv8tMzZ6FEqGeq239nXLALVGmUqOAIuw1NDyF7RxFzmZVvdsz2DMdd9qpeX5X2HSvi7UR05Gj2ILoHtiMKnHsb3tf5eDUTFkzUWpadyYuyIg7lqJQ0OhPPuNWHnjKKe0fJn9kYdf32mhOGysUO+L1TFzJwXKqCGcTWOez3WQyYLue596izdGW9qxhvADXyBva7h0oVAarbfoCs8/9NNi5KI8MjxBVmEOVPhlO8Na0ErISfPpZeWsiMEUkhqh0CkcSSjH2i4ax3J9LtpoML4b7p87NUYjZmjAoA/6k8BSsEkzRjjPzOmdjQ/dhibuUZtbhuUXMXOjORKMPn0RN4gPXih2GSnyoD8on3UP7ATTO5bW4Qf0o0+pvdtuozYTz4uQPLLNTfn5HmO0cSX0j6/VzSkPczw0+0lCZP69mZ+zjJUptOZ74EwBvaVmB1p64b7uZPHNDpXtaEdua4tGYDRBO9en4hYKa6SHGeKC18gS4sVK/rgQiPBH3BUfjkPFTVPUJBZN50tPd/cURkVSS9SXfPZJgzHLKV7fdW/p1245wD4Wp83yGqrzoIRPYTJ9Wfa2NQO0o/gexHl2gyg+Bkk4ovXi7Hz2d4gdh7qXoYHN4ORcvQOcobfkWwPWOrPMa8fj8YaelZgpm+O8ASVcbPplIVtwbKOSW5njhVgd8rKfkjtWk5LMqj+AlX4Ay2Sz3yfp9F/vqF6YFYG5qD0mCj3PI36iDXt/FMMsd33uyKMhqfJm8HHmJKe/+tzOyZ8OlVZ+QlcXUyNyXnlHV7YKpAIYLhJqG80famqcgwu0KkZEL+pUwXdg4YEne8Q3Ia/HAb2EL0KfrEg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e03d630a-d2d0-4015-ae9c-08da69e17614 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:29.7065 (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: o6EjeOwYb5Yrf3IrN8r7S9V9fGZbbJKpyguC8g9WVjoij4QVPY76VWiOQj7gMqmSRjCEsPj3gfzv1CVvLBLpnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If we call phylink_caps_to_linkmodes directly from phylink_get_linkmodes, it is difficult to re-use this functionality in MAC drivers. This is because MAC drivers must then work with an ethtool linkmode bitmap, instead of with mac capabilities. Instead, let the caller of phylink_get_linkmodes do the conversion. To reflect this change, rename the function to phylink_get_capabilities. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 21 +++++++++++---------- include/linux/phylink.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 51e66320526f..68a58ab6a8ed 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -305,17 +305,15 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** - * phylink_get_linkmodes() - get acceptable link modes - * @linkmodes: ethtool linkmode mask (must be already initialised) + * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t * @mac_capabilities: bitmask of MAC capabilities * - * Set all possible pause, speed and duplex linkmodes in @linkmodes that - * are supported by the @interface mode and @mac_capabilities. @linkmodes - * must have been initialised previously. + * Get the MAC capabilities that are supported by the @interface mode and + * @mac_capabilities. */ -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities) +unsigned long phylink_get_capabilities(phy_interface_t interface, + unsigned long mac_capabilities) { unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; @@ -390,9 +388,9 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, break; } - phylink_caps_to_linkmodes(linkmodes, caps & mac_capabilities); + return caps & mac_capabilities; } -EXPORT_SYMBOL_GPL(phylink_get_linkmodes); +EXPORT_SYMBOL_GPL(phylink_get_capabilities); /** * phylink_generic_validate() - generic validate() callback implementation @@ -408,11 +406,14 @@ void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { + unsigned long caps; __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; phylink_set_port_modes(mask); phylink_set(mask, Autoneg); - phylink_get_linkmodes(mask, state->interface, config->mac_capabilities); + caps = phylink_get_capabilities(state->interface, + config->mac_capabilities); + phylink_caps_to_linkmodes(mask, caps); linkmode_and(supported, supported, mask); linkmode_and(state->advertising, state->advertising, mask); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6463bd64eaa4..5008ec3dcade 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -519,8 +519,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 Jul 19 23:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923175 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 50896C43334 for ; Tue, 19 Jul 2022 23:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239633AbiGSXv0 (ORCPT ); Tue, 19 Jul 2022 19:51:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239629AbiGSXvS (ORCPT ); Tue, 19 Jul 2022 19:51:18 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACC05B780; Tue, 19 Jul 2022 16:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WKziDgFsx4mBZd0iDmx78qEPkdWUZzvVq/pZMMatHd8pF2QNB6D5a9RXhVBvT7BHf6X+fcXxzsdkwIzA8Q8L0ZcsWXf6lYSKFA7ShY3RDiG7AWX4rovzBNqoim5En2Orw8srRc+xAZ8oFYjzCEHzbuiNMmIB094majlOSbAq7D/gliyle9GO4pSabCgUh8S+okCZnbMxPOaMaBqtxhPwXB8+y0khB7doGUJAmg6URvY7cnJ412vQY5RZTmPM69ZRQKc8zNUh3pcIr4UQuQO6ot21xZi7Clts0Cx6nVMXcZ8vlttq3P/JgW1NrNbhYuUKShdyUkiXeIhELeOD6ZpURQ== 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=kqTPfITZdN4NPa8I4g1GQWuYXIWkClu8zOxxUyRBNNk=; b=A3eAmTUePh3ZWMP/4G1vNXDkgiveRXZhnIP0SpOZRla8eg8DrcydRzOrIlJhMQKaA4yKcBTJruIkv7BcqL18WoVKKpNeNj6AQarS1MBqomKUN31haLvDJv6OVwG1kx9876dcfajAze0cfJT39MebF9/SW7TyXJrDEcg9U4T8zBLl/hPxbTDGepeJEMGb1hZjSLYx7ay2Er0H978YgqY2yqg+E66oijvViqlN0UyEAmv/V5AKs6MP61LY8txeBgExvXVS0kCZkzYiY2LEo8Y/48T4d25g7fbbiQKJo+DB9xkGQOt5VH4LXETurpDwzt6uRfXaNrIBCuuSEzYMG9dsHg== 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=kqTPfITZdN4NPa8I4g1GQWuYXIWkClu8zOxxUyRBNNk=; b=fJvIaWM8UchEBXtCjqHerMvVuaHuRDKS0XSpzSsjosIxxBgWzKiHuIZJ/Ww1j1Z7OZf/neV7al2lVvjnhnMwQYLycnN7PwJ1S5iU+ExmPimh0i0XpqVqLw0GMUpbkraSntcUV+kLe0nNU2fmo4VvYat2Zt3rB+ngZ/PATvEOalyA+8SXNXG+6DQ3pHhaMAlbxkSbIz250KhZ7FsUYCDdV9YU59ZfPuPCg5lwUHmppi8YOP9nAS0MXgYN1/PyP+V5KY4jTpee2s9lMlRgTosXTMHu34kwKRsv0DuPTCA72u9bhb24hQni8BT7V5f/M+ZQTC/dof5/D3pvtabbPagaSw== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:31 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:31 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH v2 05/11] net: phy: Add support for rate adaptation Date: Tue, 19 Jul 2022 19:49:55 -0400 Message-Id: <20220719235002.1944800-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 1cc5a6c9-5535-4542-8c88-08da69e176f9 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HHAT1xaeRZZkBU6kcT361SP9ZlhOBNJm5OHFf8Dg3lQOy7bFzRSkg6B8ee0p8e4qY3myxo+0DKhvjnFlQxzA5b1gEOxuKv5hVI+pKsNsE5oP6QDtf3h3uh4mPSAZ8OyzCyErhWOAM+w9jTJJPsPDT4bDl4RBKSjB+T7MRMp+9vh0/WP3wnQgPznXpX3Lxl+NBkrKSI18gCi2HDwTsCdak3NsuLn5dDpUJf2K5eAW5kSeH6D1X+Bq9cGyh05HxeDW8HPf04zGwhFxbct+s0u510mTvNn/Y/NShqsQUl3+1ALGx8LcS9Fltl3APG8dcEnLqmOplLzeuvZVyO2oir0plRQZDNV3y9pjlOnXuep1c265OeuehLRGo6Q0Fnv+MYyMqETd3tFXYvYB1mwmf/FySrPwqWI7VweUd0AVu0nGYfEHc1V3QmAhfdVIDS+EalC73S4Fo826kMcOCRBoDYVeYX/sE9bKhnC+aHIqf+gI9m3mkJqbKlSYaQlPqyUoLj8/BlkLjdXPosLCyen5oGICa7NKzejqnQ5Tkol4OhNkq/mKFgXR4KrxXzCYwAb5zWwC7C+wkyQJLkpxgYNFW+e5P3ZzMIMA3hpRUdO0Hv7HHlCJpbsxZBRbRNA9fFoZ+smFKCMjQFufBCMt8gxNLRqRSgBqVg1BsQrBk5PxKOad6d+p7U334L2pXUHKF9U6Lz/msWlJEvSVPfm6NbKLho3elOMlGSKkaxnaw7VKoikSP8K2ZJpGa6naZ6kOMseovBFYeIjxsguZgRV8toYoxY38zD1y98BLVj6SlIvtW7HOo/I= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(30864003)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aMBd31NJ0v0Acdo8yb5kU5xUp0UKpF5I7WncnAewDTXtWrSfMZMtY4TI+Khcec866os/1bPv7jIIxd6YeZ7LYGrF5qc9dE4wtOOipwDLxAloBtrbkK4rdRAh3yxDHdnXhzLh0mTfdn8WYfRaSsMJc8kk8yJyyZH5eJxb4X32bxhordAYh7cWrnzTFkjC6vMVxXwiG/xkrpG+/BNR3HUH2B0/kJ+ockPp9XlpVfmk1dyGHVUeftOHAgu5OsiqeliIfBsSy+7EM672eAao16NKtORi3T3UPzH4HdSf1gOzGBuU/ERGoCe6qFr/32MpeWGxVYek3CYm9If7Z65UnHt3U7l1V4MF0XVFuvRxmYeUw2PZ7n1E2Kq5UCW7+M6gRKjAgYSLZh8DqoIMwPI7OJFSUpqM+sUMPbquuWp4jpQQciFc4XNswkryBR4+UsU/yI0eex/6By1aaXoMEDvp93VZdZil64QmT0nRkKmaeEZ90OXuzdeNJcdgZgCuIjFGgI7p8PyMKQk4UrH8wZkNOdPdan6tYBaZ7hNEh9Sdbz75wCWog3d2JgK9M3akxsoi69EBwhnKYj4BXs7r/+Jsqs6LJoB/gWL2PVR70RKSpwtSVnwm9WqTjyeJeHmrJUHAHs4E3w2iRwwy2vcefXgXIuyz+r/Sm8s284X4sjfsgBpQ/NdoARYopJFZ/nWb0v1iSG+YF7WqrpsoQ1C2/kmbqkxhNgIM9dUOxjBKloezXrOD9MLAdZvEUc71F8NK2hcH0RPEybsRPcWFE4oEBmtRSPl/pDxaeVdm2WpjNabTQBF9XHBx4RJ7Jsk647QtQqOIWo5kVBOlJukksqTYpSjgRLv0T2MmvMdwGBaI+b8Jomr1uXB0vBHD7dPtpdJUMXHRs43C3LGkdTXrzWpiwou7QOzm16C0yydaSvLq5/x0NI/smfrVs8tRA/1nn6fcIe+u2no0NgVDe6SIbcDEhozOd2AJdJj88rntmPytuGPRTAqY3mhvYF7ngTeTalGBtns7zuMMWqrVfJ99OzX1GU0H/usxCt2bVrOda5snNeHQ+SfUBEbOYHs262cvFajbSDOWU8yNYgPGOTLcGbVujt+Y+FCd+xJrk8swJiS/x6gR//Nw5QQbf8lV/ISqzR4NPXYOlQvVUGZhF4UfZQ4pKwdrJNhM866cm9a9hDJ1wYL4ZyQi5S5ZPGpGEDZB1YnvG/R6IbBU61eyaocQLjADnqU+D04ECW3wj77D5mzONrHgIohG4yaELKddDuS+qsjz6WvmBN2aives05lhooCwHLOZy5dlnOx76GYxJt/jmWL7t+0wGS8C3nJKB9OM50B59tPwW6Ow2MU5LOrUlz8+3QMNRrYuWlvSrfysP2ujMKRGfgDQRHepLAY3MlcP3S5BBTRskQIinyNzd5QP4kMi1lNRmyf/DUTzfV/A8wHoWf0rX9XkXYFsQW/8kORUP/doES1ZOUzSVo6l3fJ973yEvBkjO9gz/WnLWycd57IwIVFFWNySijtND3kvj79ZOxynm04QpsvQfQw4jnYXtmaa/JKb6vqkL2YRGMbKnVrHqXgWAsBayy6swmnHYAgkKFAe0OLmP1npqodlUHl/6M7jNMDc9plxFg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc5a6c9-5535-4542-8c88-08da69e176f9 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:31.2220 (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: vtgVgd3p7mCKP8xuVVLIYXAtGyx3olLbZN8lLTuJ2xyjo9obFWxelMp7irMgQpnxaETB/9bJZn01ZTM4gC8DMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 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 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 | 15 +++++++++++ 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, 89 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index dbca3e9ec782..65ed29e78499 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -426,6 +426,7 @@ Kernel response contents: ``ETHTOOL_A_LINKMODES_DUPLEX`` u8 duplex mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG`` u8 Master/slave port mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE`` u8 Master/slave port state + ``ETHTOOL_A_LINKMODES_RATE_ADAPTATION`` u8 PHY rate adaptation ========================================== ====== ========================== For ``ETHTOOL_A_LINKMODES_OURS``, value represents advertised modes and mask @@ -449,6 +450,7 @@ Request contents: ``ETHTOOL_A_LINKMODES_SPEED`` u32 link speed (Mb/s) ``ETHTOOL_A_LINKMODES_DUPLEX`` u8 duplex mode ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG`` u8 Master/slave port mode + ``ETHTOOL_A_LINKMODES_RATE_ADAPTATION`` u8 PHY rate adaptation ``ETHTOOL_A_LINKMODES_LANES`` u32 lanes ========================================== ====== ========================== diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 1f2531a1a876..dc70a9088544 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -74,6 +74,21 @@ const char *phy_duplex_to_str(unsigned int duplex) } EXPORT_SYMBOL_GPL(phy_duplex_to_str); +const char *phy_rate_adaptation_to_str(int rate_adaptation) +{ + switch (rate_adaptation) { + case RATE_ADAPT_NONE: + return "none"; + case RATE_ADAPT_PAUSE: + return "pause"; + case RATE_ADAPT_CRS: + return "crs"; + case RATE_ADAPT_OPEN_LOOP: + return "open-loop"; + } + return "Unsupported (update phy-core.c)"; +} + /* A mapping of all SUPPORTED settings to speed/duplex. This table * must be grouped by speed and sorted in descending match priority * - iow, descending speed. diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 8d3ee3a6495b..77cbf07852e6 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -114,6 +114,33 @@ void phy_print_status(struct phy_device *phydev) } EXPORT_SYMBOL(phy_print_status); +/** + * phy_get_rate_adaptation - determine if rate adaptation is supported + * @phydev: The phy device to return rate adaptation for + * @iface: The interface mode to use + * + * This determines the type of rate adaptation (if any) that @phy supports + * using @iface. @iface may be %PHY_INTERFACE_MODE_NA to determine if any + * interface supports rate adaptation. + * + * Return: The type of rate adaptation @phy supports for @iface, or + * %RATE_ADAPT_NONE. + */ +int phy_get_rate_adaptation(struct phy_device *phydev, + phy_interface_t iface) +{ + int ret = RATE_ADAPT_NONE; + + if (phydev->drv->get_rate_adaptation) { + mutex_lock(&phydev->lock); + ret = phydev->drv->get_rate_adaptation(phydev, iface); + mutex_unlock(&phydev->lock); + } + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_rate_adaptation); + /** * phy_config_interrupt - configure the PHY device for the requested interrupts * @phydev: the phy_device struct @@ -256,6 +283,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev, cmd->base.duplex = phydev->duplex; cmd->base.master_slave_cfg = phydev->master_slave_get; cmd->base.master_slave_state = phydev->master_slave_state; + cmd->base.rate_adaptation = phydev->rate_adaptation; if (phydev->interface == PHY_INTERFACE_MODE_MOCA) cmd->base.port = PORT_BNC; else diff --git a/include/linux/phy.h b/include/linux/phy.h index 81ce76c3e799..4ba8126b64f3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -276,7 +276,6 @@ static inline const char *phy_modes(phy_interface_t interface) } } - #define PHY_INIT_TIMEOUT 100000 #define PHY_FORCE_TIMEOUT 10 @@ -570,6 +569,7 @@ struct macsec_ops; * @lp_advertising: Current link partner advertised linkmodes * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited * @autoneg: Flag autoneg being used + * @rate_adaptation: Current rate adaptation mode * @link: Current link state * @autoneg_complete: Flag auto negotiation of the link has completed * @mdix: Current crossover @@ -637,6 +637,8 @@ struct phy_device { unsigned irq_suspended:1; unsigned irq_rerun:1; + int rate_adaptation; + enum phy_state state; u32 dev_flags; @@ -801,6 +803,21 @@ struct phy_driver { */ int (*get_features)(struct phy_device *phydev); + /** + * @get_rate_adaptation: Get the supported type of rate adaptation for a + * particular phy interface. This is used by phy consumers to determine + * whether to advertise lower-speed modes for that interface. It is + * assumed that if a rate adaptation mode is supported on an interface, + * then that interface's rate can be adapted to all slower link speeds + * supported by the phy. If iface is %PHY_INTERFACE_MODE_NA, and the phy + * supports any kind of rate adaptation for any interface, then it must + * return that rate adaptation mode (preferring %RATE_ADAPT_PAUSE, to + * %RATE_ADAPT_CRS). If the interface is not supported, this should + * return %RATE_ADAPT_NONE. + */ + int (*get_rate_adaptation)(struct phy_device *phydev, + phy_interface_t iface); + /* PHY Power Management */ /** @suspend: Suspend the hardware, saving state if needed */ int (*suspend)(struct phy_device *phydev); @@ -967,6 +984,7 @@ struct phy_fixup { const char *phy_speed_to_str(int speed); const char *phy_duplex_to_str(unsigned int duplex); +const char *phy_rate_adaptation_to_str(int rate_adaptation); /* A structure for mapping a particular speed and duplex * combination to a particular SUPPORTED and ADVERTISED value @@ -1681,6 +1699,8 @@ int phy_disable_interrupts(struct phy_device *phydev); void phy_request_interrupt(struct phy_device *phydev); void phy_free_interrupt(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); +int phy_get_rate_adaptation(struct phy_device *phydev, + phy_interface_t iface); void phy_set_max_speed(struct phy_device *phydev, u32 max_speed); void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode); void phy_advertise_supported(struct phy_device *phydev); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index e0f0ee9bc89e..3978f9c3fb83 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[0]; /* layout of link_mode_masks fields: diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index d2fb4f7be61b..3a5d81769ff4 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -242,6 +242,7 @@ enum { ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, /* u8 */ ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, /* u8 */ ETHTOOL_A_LINKMODES_LANES, /* u32 */ + ETHTOOL_A_LINKMODES_RATE_ADAPTATION, /* u8 */ /* add new constants above here */ __ETHTOOL_A_LINKMODES_CNT, diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 6a7308de192d..ef0ad300393a 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -571,6 +571,7 @@ static int ethtool_get_link_ksettings(struct net_device *dev, = __ETHTOOL_LINK_MODE_MASK_NU32; link_ksettings.base.master_slave_cfg = MASTER_SLAVE_CFG_UNSUPPORTED; link_ksettings.base.master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; + link_ksettings.base.rate_adaptation = RATE_ADAPT_NONE; return store_link_ksettings_for_user(useraddr, &link_ksettings); } diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c index 99b29b4fe947..7905bd985c7f 100644 --- a/net/ethtool/linkmodes.c +++ b/net/ethtool/linkmodes.c @@ -70,6 +70,7 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base, + nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */ + nla_total_size(sizeof(u32)) /* LINKMODES_LANES */ + nla_total_size(sizeof(u8)) /* LINKMODES_DUPLEX */ + + nla_total_size(sizeof(u8)) /* LINKMODES_RATE_ADAPTATION */ + 0; ret = ethnl_bitset_size(ksettings->link_modes.advertising, ksettings->link_modes.supported, @@ -143,6 +144,10 @@ static int linkmodes_fill_reply(struct sk_buff *skb, lsettings->master_slave_state)) return -EMSGSIZE; + if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_RATE_ADAPTATION, + lsettings->rate_adaptation)) + return -EMSGSIZE; + return 0; } From patchwork Tue Jul 19 23:49:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923176 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 D6192C433EF for ; Tue, 19 Jul 2022 23:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238595AbiGSXvo (ORCPT ); Tue, 19 Jul 2022 19:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239844AbiGSXvV (ORCPT ); Tue, 19 Jul 2022 19:51:21 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2051.outbound.protection.outlook.com [40.107.21.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C0E061D8C; Tue, 19 Jul 2022 16:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TMh9H/UU47odcuOJzAZtFG1OCnxrkzWymGcesS2UzM4DxK5U0XjLsaxcej0I/unRVdXrGGLXuvL4k3UEKphxQXBPz+x8oFLpBSs1J89v4SFqClojKc+dLAMsoxugrioPOTblk+1Ee+637ATlQGmuLwqFBnY3io0PoFQzQZUAWDGq7efSyLgmCcdlkcrRYtQgoHu+uXqh8XI5N/UkD9bR3gXmgGp1ksSmMtpr5DEWhUeDszkPl1Jza0cEFaWBczU/p6GVgfWPushzZsOhELUJal2PKYTU4X1dNKOoMPNhC6H+/4+DgK6WxfCSIw5E5d7wiZtUA8Xeal6ytcwpiG3kcQ== 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=SvunlWU2KE9Mn2hRVJ2Xi1ezKFam+0gIWSW3QXPlWHE=; b=HzVQO5tFG88YKj+h73k1Tkpv709s+zjaGUeDDFpjTELNUywBkwl1FtUcVKwF9t2ct31BuoxuNznDsyT//ItWtdDwrdqCQeliNDrdj48L6/rKgD54enyxA3BrxiIL6QZqDv0II3X6TF3TXxcp0x2szfcd5knBdpbuegd2O2UTvJHF0rR/3PBeSBAJxLYwwskL03yLlmzWbCMvktHMbOJIcsoe7TO0fbJ/6k6neYzF70dXRRyunnXc+Rtki3+q+OMEIBuI407xGUXcofUOlD6ZVVSXivDyLohwzxJPFBpJI0icbGW6POHKH87NADiFbQv26k1crzVf8sIUfhAnfQgAuA== 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=SvunlWU2KE9Mn2hRVJ2Xi1ezKFam+0gIWSW3QXPlWHE=; b=NCmZWv6dhBocIf+IQ+Yfk9U+qXCxSnSU71A9OzSJ64HSAnQKaAxSc6yFKj8Poh4QYkhQxTXXRtfkDVbKeMDG6eiUu/3+9GPOGKXlhZz2q6jXebfUCKfOI1aT4qfM4spod8XWWCpkWVgruPGtIqoDW/RgZyxU0rbpU3GhUymwfWxDs9M5P69v+8kLrDgtKSZEHrWhAANWMQQmbwyqQAVuGN3JBzP4gHEdZovaag5Rxxx21BXceAZtOstkgea9W0oAp2WOqJIg0NEJYTnHv1jQazCjGfZXhN8vkE2EUssYBAhzj19zBAVzy/NEsb8Sse3qAFRaSWPzqfqcrHZIXpbSrQ== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:32 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:32 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 06/11] net: phylink: Support differing link/interface speed/duplex Date: Tue, 19 Jul 2022 19:49:56 -0400 Message-Id: <20220719235002.1944800-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 8fb7843e-45fb-4bd7-f5a1-08da69e177c8 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UOz5YPtWlOOiubzPVPDfXh2YeL+JlLT2suM07pkoyUfREN6SaeHHulhLuJ1ytqTd2eg800P5wj+seybu6Ia4miAc19bdZA+rQJ/eZChv8aa85f3rrODqe6+mYNJf986qnkWbJVeClJnzF7vX5L93GSFjvqmGgR8lRQEPOkEwFDNIFOdTUB48HI8zfoudlCAQ3hNRP/C38eEePE3Ym9utb95Rffzx+X1gjGNsRCGfFwwYu61xlQt4w4TycqrybvoYUsnCYutYI0R1B7mbObHUS0KVUDbgxoMKscrAMvcG4SeIq0H+DVfWlv1OkzqWHAn3TT0/LUYQMxGctfa+FA7uUUhXBPK3zqto8iUEUz0YKF0i7FvKTosFjtMf5jtwjvEfO5y/PTawXackH3epJIAPEgjbsINO7HpI+olnvDOMKy2paXxfOMTSyOOW8VMeCPGX0q+3LYuFOzc33m/xBQw66BPtgTP2QWKy924o3YpOFmvLcEM6PDFC0kl2UF7MfTl1BxyV+2BJOQ0Or7GiPL9M0sNGWWD45CbAhxUb+KTihjls4WxoQ3cBbQGe2Agg2dInd+VYm3VYASd1Bm9xDXKjiiyKXKIb4iMApIj27wdoSR3soed+VlDdmOLewC2OSPDJhTKL+cMW3mjF+6Bqe67HbyfdkRqWbICmF+M9TIf5tUR8ujbZ/ICGG7knocRXJpGkRgiVH/IkXRbKb6oIuWW6ApI1MLV39nN4sngehyEHmap3FCjCXSrI/caHYkIHcyl29p9YW/cUsrw2vBjsq4lWxtzpsiedcUPsRBftaUziN5MxwDlsh09Fe5ncwpOnKIwzwAPZMz9fZkl9zuZQy3rW8A== 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(30864003)(38100700002)(6486002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LzmLu36Tl8PwQF0BMgwEAIkgzKQwkA7IBxhGC0tG9NwmFp28BHUQCOuQKatdy+bgdbbBk3NU6i65jZ1CUUtsSZBAxHsY8yuoeB5Ed/vJmc53dwGBXBxSXdAjQJV2je7k1x14erh2XrfF0UJXR7IdR8XsG/sImXbbTJKtpaWxYrGoYDxBMs17hwrQBcmaQXX3AR3rO5VNMaEnRSg/YzDQOcVmdHRIag8VWLxJ6CYWMMPr1CrDpgdmBvOq1raL2wyW8K+rj7VYDv0p77xbjagHYNxX3L0SntVx7DeZYP2zjH2jV207yHxLMdTa215LBnR57yfol41yzfErHdAM5HVeIOsEqftrLUIlfSqjQGG8a1cfyS5ihoqqxwBvZkUD5ED6afrfGvWtfAHuBNYNm7qcNtTkIRqpTtErUuFKFhIAPoRnguO8OZo/u3amrCkT/daL9+eMiPdX9IIibZkgNxgIAecGAL1w3Yyc3QL/wa3ZM3tzc0U+mWtdqg01sXjwane3OmNU8Vnw7cC3BX03xQYcgpZYveu2hisP+timnAx2BsQvJqGjNZ4soeel+m45vCJA4CTeAgvc2JGPxa1TY5A2fL/KXwu2sInVG+pCVwIqZIa5dSOgOwzg0boJlXSrgMPz1t9rxNeK77LqPRnP42Y1AwH07biBYpB/4siI3ae1msuxCROZKzdQKgEzUo+FbkSi7c4ovndIb0U0pLRfKq5uRqYnbLjOrGS7zdwO/JUeJjpj0t6CaHXnX/SYMGvo4mpBWfG4dV/trfshrqBON1k/U/KHmaWlMeznnbeDtomE4b+NtHQ5ap0M4qhPcEvqUSuwzQfhkQRcokccw31ogylluUHY1gmPlSE2lZUcCPBLYuvUN49qmZtsKpzxa3Fhapr26FTtnqPCxyk0fERoWzMylyD6gcFuOmhtF5YVbv/xwaIOJwNhyJObo6Xxn9D/KPSVNl87/Xxt5kDS+5l1zfh5P/M79rDhiP0F7n2EJfqJ0N1mDXgI1/1hBHWdVqYx1fUybCMxH8+OgPrc4hMK4OIGNwWtAEmAo3azdKqmOzU8K7emtMg1ykjlgvmrHGpn4VRcD1rkRAehz/LiQlcIwznb6ydXaAM7SphqPJSalncJRUJPhGn8YLlZX0hR6rQSBiQatwJ70Xj+m0BjCQeNEGXJWKtLX9HMmtZtCyq4ijkYjzMc/7pbEwShpIRaJ5cZnyJRWoquBzxy5rKk5zStWtu3vfBHA1IoI69kM1k7OiarzoNA0IO8AnbpVHNhC5VeIfs9h5SWph2tmDh2GHAuKxj6ly1xwgOyD1iWx4sh7RX7+i+QGW18B2sE4XlNQcg22fXktkEptlLQ+EqlbkPwZY++20sVzREPem6zqa76ttCOPjTPDmiK0fOdWiHkV0lvg52YYvw/6saph/XlwcMckdAPsyKmOPrMXWsepapKGtNKGmsiro1YS6Qd/svVo14q5Ubnabqi5Ux0FdLlCxFQZOHKBzzitSdhV/C5J65k1pqHEt1vVEpo1OEdHuryOLjhkPrIhUcTLifwdU5U2UaDJwO7soWeJYKAH+eRlByb6bKj3/vIZY3P97ZvVFh1A9+GKl76MEg14wK47l6J4IKWnRu/jA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fb7843e-45fb-4bd7-f5a1-08da69e177c8 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:32.6125 (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: VqJ8rschuGQjJwNVQepVXeqttDfJ/60SkxCIW7iEQ7w9vxWlLpdWVV08uRO8ZgM5685Qi7WkipPzWmRPe0H+/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for cases when the link speed or duplex differs from the speed or duplex of the phy interface mode. Such cases can occur when some kind of rate adaptation is occurring. The following terms are used within this and the following patches. I do not believe the meaning of these terms are uncommon or surprising, but for maximum clarity I would like to be explicit: - Phy interface mode: the protocol used to communicate between the MAC or PCS (if used) and the phy. If no phy is in use, this is the same as the link mode. Each phy interface mode supported by Linux is a member of phy_interface_t. - Link mode: the protocol used to communicate between the local phy (or PCS) and the remote phy (or PCS) over the physical medium. Each link mode supported by Linux is a member of ethtool_link_mode_bit_indices. - Phy interface mode speed: the speed of unidirectional data transfer over a phy interface mode, including encoding overhead, but excluding protocol and flow-control overhead. The speed of a phy interface mode may vary. For example, SGMII may have a speed of 10, 100, or 1000 Mbit/s. - Link mode speed: similarly, the speed of unidirectional data transfer over a physical medium, including overhead, but excluding protocol and flow-control overhead. The speed of a link mode is usually fixed, but some exceptional link modes (such as 2BASE-TL) may vary their speed depending on the medium characteristics. Before this patch, phylink assumed that the link mode speed was the same as the phy interface mode speed. This is typically the case; however, some phys have the ability to adapt between differing link mode and phy interface mode speeds. To support these phys, this patch removes this assumption, and adds a separate variable for link speed. Additionally, to support rate adaptation, a MAC may need to have a certain duplex (such as half or full). This may be different from the link's duplex. To keep track of this distunction, this patch adds another variable to track link duplex. Signed-off-by: Sean Anderson --- Changes in v2: - Support keeping track of link duplex - Rewrite commit message for clarity - Expand documentation of (link_)?(speed|duplex) - Fix handling of speed/duplex gotten from MAC drivers drivers/net/phy/phylink.c | 112 ++++++++++++++++++++++++++------------ include/linux/phylink.h | 14 ++++- 2 files changed, 88 insertions(+), 38 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 68a58ab6a8ed..da0623d94a64 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,6 +155,23 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } +/** + * phylink_state_fill_speed_duplex() - Update a state's interface speed and duplex + * @state: A link state + * + * Update the .speed and .duplex members of @state. We can determine them based + * on the .link_speed and .link_duplex. This function should be called whenever + * .link_speed and .link_duplex are updated. For example, userspace deals with + * link speed and duplex, and not the interface speed and duplex. Similarly, + * phys deal with link speed and duplex and only implicitly the interface speed + * and duplex. + */ +static void phylink_state_fill_speed_duplex(struct phylink_link_state *state) +{ + state->speed = state->link_speed; + state->duplex = state->link_duplex; +} + /** * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes * @linkmodes: ethtool linkmode mask (must be already initialised) @@ -524,11 +541,11 @@ static int phylink_parse_fixedlink(struct phylink *pl, if (fixed_node) { ret = fwnode_property_read_u32(fixed_node, "speed", &speed); - pl->link_config.speed = speed; - pl->link_config.duplex = DUPLEX_HALF; + pl->link_config.link_speed = speed; + pl->link_config.link_duplex = DUPLEX_HALF; if (fwnode_property_read_bool(fixed_node, "full-duplex")) - pl->link_config.duplex = DUPLEX_FULL; + pl->link_config.link_duplex = DUPLEX_FULL; /* We treat the "pause" and "asym-pause" terminology as * defining the link partner's ability. @@ -566,9 +583,9 @@ static int phylink_parse_fixedlink(struct phylink *pl, ret = fwnode_property_read_u32_array(fwnode, "fixed-link", prop, ARRAY_SIZE(prop)); if (!ret) { - pl->link_config.duplex = prop[1] ? + pl->link_config.link_duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF; - pl->link_config.speed = prop[2]; + pl->link_config.link_speed = prop[2]; if (prop[3]) __set_bit(ETHTOOL_LINK_MODE_Pause_BIT, pl->link_config.lp_advertising); @@ -578,16 +595,18 @@ static int phylink_parse_fixedlink(struct phylink *pl, } } - if (pl->link_config.speed > SPEED_1000 && - pl->link_config.duplex != DUPLEX_FULL) + if (pl->link_config.link_speed > SPEED_1000 && + pl->link_config.link_duplex != DUPLEX_FULL) phylink_warn(pl, "fixed link specifies half duplex for %dMbps link?\n", - pl->link_config.speed); + pl->link_config.link_speed); + phylink_state_fill_speed_duplex(&pl->link_config); bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS); linkmode_copy(pl->link_config.advertising, pl->supported); phylink_validate(pl, pl->supported, &pl->link_config); - s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex, + s = phy_lookup_setting(pl->link_config.link_speed, + pl->link_config.link_duplex, pl->supported, true); linkmode_zero(pl->supported); phylink_set(pl->supported, MII); @@ -599,8 +618,8 @@ static int phylink_parse_fixedlink(struct phylink *pl, __set_bit(s->bit, pl->link_config.lp_advertising); } else { phylink_warn(pl, "fixed link %s duplex %dMbps not recognised\n", - pl->link_config.duplex == DUPLEX_FULL ? "full" : "half", - pl->link_config.speed); + pl->link_config.link_duplex == DUPLEX_FULL ? "full" : "half", + pl->link_config.link_speed); } linkmode_and(pl->link_config.advertising, pl->link_config.advertising, @@ -757,7 +776,7 @@ static void phylink_resolve_flow(struct phylink_link_state *state) bool tx_pause, rx_pause; state->pause = MLO_PAUSE_NONE; - if (state->duplex == DUPLEX_FULL) { + if (state->link_duplex == DUPLEX_FULL) { linkmode_resolve_pause(state->advertising, state->lp_advertising, &tx_pause, &rx_pause); @@ -925,12 +944,16 @@ 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) { + if (state->an_enabled) { + state->link_speed = SPEED_UNKNOWN; + state->link_duplex = DUPLEX_UNKNOWN; state->speed = SPEED_UNKNOWN; state->duplex = DUPLEX_UNKNOWN; state->pause = MLO_PAUSE_NONE; } else { - state->speed = pl->link_config.speed; + state->link_speed = pl->link_config.link_speed; + state->link_duplex = pl->link_config.link_duplex; + state->speed = pl->link_config.speed; state->duplex = pl->link_config.duplex; state->pause = pl->link_config.pause; } @@ -944,6 +967,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, pl->mac_ops->mac_pcs_get_state(pl->config, state); else state->link = 0; + + state->link_speed = state->speed; + state->link_duplex = state->duplex; } /* The fixed state is... fixed except for the link state, @@ -953,10 +979,17 @@ static void phylink_get_fixed_state(struct phylink *pl, struct phylink_link_state *state) { *state = pl->link_config; - if (pl->config->get_fixed_state) + if (pl->config->get_fixed_state) { pl->config->get_fixed_state(pl->config, state); - else if (pl->link_gpio) + /* FIXME: these should not be updated, but + * bcm_sf2_sw_fixed_state does it anyway + */ + state->link_speed = state->speed; + state->link_duplex = state->duplex; + phylink_state_fill_speed_duplex(state); + } else if (pl->link_gpio) { state->link = !!gpiod_get_value_cansleep(pl->link_gpio); + } phylink_resolve_flow(state); } @@ -1027,8 +1060,8 @@ static void phylink_link_up(struct phylink *pl, phylink_info(pl, "Link is Up - %s/%s - flow control %s\n", - phy_speed_to_str(link_state.speed), - phy_duplex_to_str(link_state.duplex), + phy_speed_to_str(link_state.link_speed), + phy_duplex_to_str(link_state.link_duplex), phylink_pause_to_str(link_state.pause)); } @@ -1279,8 +1312,9 @@ struct phylink *phylink_create(struct phylink_config *config, pl->link_port = PORT_MII; pl->link_config.interface = iface; pl->link_config.pause = MLO_PAUSE_AN; - pl->link_config.speed = SPEED_UNKNOWN; - pl->link_config.duplex = DUPLEX_UNKNOWN; + pl->link_config.link_speed = SPEED_UNKNOWN; + pl->link_config.link_duplex = DUPLEX_UNKNOWN; + phylink_state_fill_speed_duplex(&pl->link_config); pl->link_config.an_enabled = true; pl->mac_ops = mac_ops; __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); @@ -1344,8 +1378,8 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) phy_get_pause(phydev, &tx_pause, &rx_pause); mutex_lock(&pl->state_mutex); - pl->phy_state.speed = phydev->speed; - pl->phy_state.duplex = phydev->duplex; + pl->phy_state.link_speed = phydev->speed; + pl->phy_state.link_duplex = phydev->duplex; pl->phy_state.pause = MLO_PAUSE_NONE; if (tx_pause) pl->phy_state.pause |= MLO_PAUSE_TX; @@ -1353,6 +1387,7 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) pl->phy_state.pause |= MLO_PAUSE_RX; pl->phy_state.interface = phydev->interface; pl->phy_state.link = up; + phylink_state_fill_speed_duplex(&pl->phy_state); mutex_unlock(&pl->state_mutex); phylink_run_resolve(pl); @@ -1422,8 +1457,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, pl->phydev = phy; pl->phy_state.interface = interface; pl->phy_state.pause = MLO_PAUSE_NONE; - pl->phy_state.speed = SPEED_UNKNOWN; - pl->phy_state.duplex = DUPLEX_UNKNOWN; + pl->phy_state.link_speed = SPEED_UNKNOWN; + pl->phy_state.link_duplex = DUPLEX_UNKNOWN; + phylink_state_fill_speed_duplex(&pl->phy_state); linkmode_copy(pl->supported, supported); linkmode_copy(pl->link_config.advertising, config.advertising); @@ -1866,8 +1902,8 @@ 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; + kset->base.speed = state->link_speed; + kset->base.duplex = state->link_duplex; kset->base.autoneg = state->an_enabled ? AUTONEG_ENABLE : AUTONEG_DISABLE; } @@ -1983,14 +2019,14 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, * If the link parameters match, accept them but do nothing. */ if (pl->cur_link_an_mode == MLO_AN_FIXED) { - if (s->speed != pl->link_config.speed || - s->duplex != pl->link_config.duplex) + if (s->speed != pl->link_config.link_speed || + s->duplex != pl->link_config.link_duplex) return -EINVAL; return 0; } - config.speed = s->speed; - config.duplex = s->duplex; + config.link_speed = s->speed; + config.link_duplex = s->duplex; break; case AUTONEG_ENABLE: @@ -2005,8 +2041,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, return 0; } - config.speed = SPEED_UNKNOWN; - config.duplex = DUPLEX_UNKNOWN; + config.link_speed = SPEED_UNKNOWN; + config.link_duplex = DUPLEX_UNKNOWN; break; default: @@ -2036,6 +2072,7 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, } /* Revalidate with the selected interface */ + phylink_state_fill_speed_duplex(&config); linkmode_copy(support, pl->supported); if (phylink_validate(pl, support, &config)) { phylink_err(pl, "validation of %s/%s with support %*pb failed\n", @@ -2046,6 +2083,7 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, } } else { /* Validate without changing the current supported mask. */ + phylink_state_fill_speed_duplex(&config); linkmode_copy(support, pl->supported); if (phylink_validate(pl, support, &config)) return -EINVAL; @@ -2056,9 +2094,10 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, return -EINVAL; mutex_lock(&pl->state_mutex); - pl->link_config.speed = config.speed; - pl->link_config.duplex = config.duplex; + pl->link_config.link_speed = config.link_speed; + pl->link_config.link_duplex = config.link_duplex; pl->link_config.an_enabled = config.an_enabled; + phylink_state_fill_speed_duplex(&pl->link_config); if (pl->link_config.interface != config.interface) { /* The interface changed, e.g. 1000base-X <-> 2500base-X */ @@ -2597,10 +2636,11 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode, memset(&config, 0, sizeof(config)); linkmode_copy(config.advertising, advertising); config.interface = PHY_INTERFACE_MODE_NA; - config.speed = SPEED_UNKNOWN; - config.duplex = DUPLEX_UNKNOWN; + config.link_speed = SPEED_UNKNOWN; + config.link_duplex = DUPLEX_UNKNOWN; config.pause = MLO_PAUSE_AN; config.an_enabled = pl->link_config.an_enabled; + phylink_state_fill_speed_duplex(&config); /* Ignore errors if we're expecting a PHY to attach later */ ret = phylink_validate(pl, support, &config); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 5008ec3dcade..ab5edc1e5330 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -56,8 +56,16 @@ static inline bool phylink_autoneg_inband(unsigned int mode) * @lp_advertising: ethtool bitmask containing link partner advertised link * modes * @interface: link &typedef phy_interface_t mode - * @speed: link speed, one of the SPEED_* constants. - * @duplex: link duplex mode, one of DUPLEX_* constants. + * @speed: interface speed, one of the SPEED_* constants. This is the speed of + * the host-side interface to the phy. If @rate_adaptation is being + * performed, this will be different from @link_speed. + * @link_speed: link speed, one of the SPEED_* constants. This is the speed of + * the line-side interface to the link partner. + * @duplex: interface duplex mode, one of DUPLEX_* constants. This is the + * duplex of then host-side interface to the phy. If @rate_adaptation is + * being performed, this may be different from @link_duplex. + * @link_duplex: link duplex, one of the DUPLEX_* constants. This is the duplex + * of the line-side interface to the link partner. * @pause: link pause state, described by MLO_PAUSE_* constants. * @link: true if the link is up. * @an_enabled: true if autonegotiation is enabled/desired. @@ -68,7 +76,9 @@ struct phylink_link_state { __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); phy_interface_t interface; int speed; + int link_speed; int duplex; + int link_duplex; int pause; unsigned int link:1; unsigned int an_enabled:1; From patchwork Tue Jul 19 23:49:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923177 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 599ECC43334 for ; Tue, 19 Jul 2022 23:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240398AbiGSXvp (ORCPT ); Tue, 19 Jul 2022 19:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239881AbiGSXvV (ORCPT ); Tue, 19 Jul 2022 19:51:21 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C782861DB0; Tue, 19 Jul 2022 16:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nz1Dh5ej1SSgktCHE1zmgqNvb1yp8Q23VAEUYSO8J+NGq3irxCUQirUmaO+zyndpuFtIBvn5rJk7xDYJU4fFyddZwQ0+9/7PfcftII4Yetca/U8F9gSoyMPp1BQmxeCPyH+6h8tTVL9X6WjPVh3aOrXUS1eI5AGYO/tDUs6o00/fpvBUAEJdmDCxFUws445cY6vBQ6D7vHQBOqagVNuwbAMb1BJlEQ/UhcaPNf4G4Qw6GTOnZJXdBptOZT8WQqEqA69ACZ6wcbfDvg1U5o7DfU4HZ/+0D9ED/f/inh6bKk3seCOgECaOKlhDTnKrQ2jqvZmeNXWUW40RJjyWm5k7pg== 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=muenqxh0QkBSPg9xKgGudRNTjup5zs7BA7/AafM8Jys=; b=QlIqbR1umBedc80X0SBGGMINgFKQCEKlLFjsVRS2gsdzb0BvzCaUq6EXukoMPuOK8FOdrfgM+OAFs1FHHYDjVBUC8S0SrKhKrrQSgKL8hPSMJ2Xmjn6kI+o/+OULj6lgsdwzHyF8zl8XJ54EqPNYF6h6SgHGiIZWgvfmzBv2nCLc1RXKdoEzHMrvDx08sriOx/+aLp/9YLvSWohLuJIeHtM3t+I3h2prlxB6vyZnZzBcLSedDMlIt9FPM1pKTwp1pkZgJHgXFneVEBLrdgdywY1J54TTIV7Bg90QB8tgsOkgq5u6WpKbsFwBuKYawzMir/zHM4Y8wrV+V3q/2a90xg== 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=muenqxh0QkBSPg9xKgGudRNTjup5zs7BA7/AafM8Jys=; b=TVAqM3Zf3q5dCDvuHHXq1NcNP9PY9FH0J2IGv7NcAzDorOG9I+b0egKMKlMwAHO5e0ejzikcoEd3NIr8xS7IHq5h4axRcpB5NXJVlQ8TrpmUeL8Ggdq9ZgkGgShA2e6Y8dr9lugYPP/0ErPC80Eg9JQ3ApYbM0OFf6SeEDCdrIFme1+q6BTTmQ9tp/xvXyOBa/N5hBZKLyx0T+7gvO9qkbOhdWiTt+0GMQyMXZJ6Gpjn5nyMxQL9V6jSCOH2HeWy+yYdj6+0W4IE1Y9IhXEQKilJvsVG9FBvI1CQwObKA2IQuvbtwiJcWRP/FAfUNpDkKBOjeVkzKFbeJF8TAH6dMQ== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:34 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:34 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 07/11] net: phylink: Adjust link settings based on rate adaptation Date: Tue, 19 Jul 2022 19:49:57 -0400 Message-Id: <20220719235002.1944800-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 976668bb-2b5c-4faa-5cd2-08da69e178b7 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B42cGMLO5yJ3jalCHlWYRhhtTEqf+ERlGfaNpZu5zIYZMNNZDr4Nv9b5mrn5jFZkYhbo7bfsS0FdDkamSIEUl42VpryiolICFf5G3QlcUpG6Pqs/T+2eyE7eEVHw4Iu3zrhE5Y6JAAZnvBKYdpgVlOcluPFFFjvd7hNbvK6OJ1KjWOuEN/fmmx79rt4xA3rrbaWyqrlBNzxuHYSrJWZuanXKzw052d2k3KBGMdn1cd3U0UPvnKUTJSX2nv46uf7OiNxT10kY+zixTLYHd928Fr3ydRrqj6GuDsXKKl/0RkcEqdHaNXbskI16+VBLyLddoFC8NA5GyjR4UQQvpBNjVgO0bjjdZbSsdX/WrqbaFTn3M4CGlp9QdEFlL95gsO4uyWYP/afuJLGyQHzmk9zg6j4e5+aKsejk5XgrK/zwFdpXIznDUykmDwTxZ42N3RjN4geEyOULq54jzLz96LxFOL5JXDAbKo74YjocnZPBcRSByiQQZ9t2w49M8UYT/nzAuohsscmKP5iJEEa6n3fMPHns7H3RX4lrzZR8vuymBP8PBnuHIrPAe+3J5ZbNELmduTyqcYEiVBFtg8C2ZHcojF/iefTLEuC+XZis4piP5Syvbpheplsr7RzqneofCqpGdINkjMJ/yp6FWqnSWAaoIS3viW5a1pkkvi82oQanh1QRVvvZdPk7oWnBaEOJSx9ORIUfvJVR4GKn6Q2Z3pNaXI7R3D6LB8bGc/2KYdnWlgt5Yyg1/AouK8WQXlSL76StwETnWB8Za782KNeEXgVZRWv444G223rFa0KTKW9zxpA= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9vkz5dtgkZA9DnNV2HMy431ozFMxA5KgCdPCoI/ulsAUnnEkIP7yBdm4tRQVi5Je4f3cntxtmUz1cxP2fHCj9bEtulDHT6AR+YLdtI+6uIaXFr6XDAJnD/mGwF8mZVGeeahPa7fI26TKv5n5bNLWuI/PWtf1SvzXhuDi4BajtqUcjMqS7JIc6ZLGTuWw3VwN94gR7XoQ9pypohp1JthMp5TX7jrzT7P7R/f10T5/emdx+oD1DkrC9FnXVwYQ63TzXKWHRJ9Dfol5gXF7rJjPjCgp/b7Kgig7jVkoM8OqnG2MNM6so9CFy+04H0OeGqWLwbjBEOxnpXMGGu0bL5KfaO2o6QQTq/o0LBvmyyUqNZdOFZUQDnACRo+yL+TNJgMC57VdsSX7sZt/jr0FolaKnXWR8XGaks07VoM8wo49+01E58TNxzCXQpAfS6cmZBCU40lCGSJeaRZRTj3UGUrHdOJ2jk/98+SBRgCuUOfgYlmk4iziog6meY6EW5qooDaTiPdjWX/H468PRK1UjBgcuAarN48KYGagEWMWScF5mxx5L5i/L/GIag556EmS2HwWMnkV/Mt2qX0PxjB8zCn1a3sX96UEapQZLA+yJwR/j1LJim0AfKHR1JQ2vODJ7u8jNt09JqZ2YslM8ffWvCuAxfxSl4IWUZ7ujDS1VDRKPFkcN87vMfLiqtuTUwHjXsN9zkgY4f4gcnvtwXDxRul01G7VN8QM8v2krMimCMiBoFb1A2qnEvwtpmT0FYGU2UwLHKU25rtWppZB6+HhO4RWKtp4wYFsKvu1vekbK0/V3HzyV5WQB8nX8ln9g7NZpaK5ObuGZcHM7iDeKMmq1tx0S2sSpFWVCfkD0UTwk7vGkoERHSJTSJhUc/6hEZNLe33vi2bYRAUC5V0/yIV+iXUFVqxg+ftPdIlgYQ0kxecHSElinYIEbfDJLbun7dJJPW6/kcy3LkdSx6nmeFZzAkUkLJJrPfuLm71pJCwoxf8XuL5FqEuw/wScijL7NvhIwkFqw9+qlAKS99yJOuje5Q2Ri5UEuVx/rBpWNfw+77JfzCeouS7iTXxBj9clpANB2U9IN0LSwbyiu6DinpR7x82YJKulEKxpbXYaDc5w7vkuCLYWgshmFFTfXsNzjMyAaYhx954WOpyDMSnWQ2KeW0KbVnKekSCGYYxBTZ+d0bbw52Ra9vvYm6t1bXV5Emf4HLCRuvyjWS1cj8b/PcSEVp8kpQKM6p8oLuDUFroeehHbvtRoh2a6fHZiicmRVr/U4b9/geDFyLWCUV0TQvEDvkYu17qjxH2pJX5mCGsJkxCFt7nOZNDKbD0AEdVlmCU1CCf+BoW0afIr6mF+hWZTsDK0Jo9yn8IbY0rTD3bg6niRPt/ujjYANLeLL1ZxchwKwrWgzO2xwsYNtjdXzqdnlocf334oszNbqPtAYOFerZVyQZiC/Au0J6fpT5cFA+KVDBYm1M9nlDc6UCZaUy3H7UDemVvPcZHCk9icbrsiHknOD6NU0fr/NC5LGoVn8gbAsATW32KqrmP0qRlb2F6JnSYGeZlsJfCNSae2QOxE6el/4nFy5B/Zacubzf2b1aBnnIUg4ogKf3a+9C+8iTbmcLfVWw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 976668bb-2b5c-4faa-5cd2-08da69e178b7 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:34.1281 (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: 6B1fSfwBVsPK15CSvSwG96r3JNys8bdR/DqPAdhmL8Rb+pSMxd742Uwrg1vEFxGTWCzu0k6+Fpwt/Zdf+OUU+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 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. Signed-off-by: Sean Anderson Reported-by: kernel test robot Reported-by: kernel test robot --- 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 | 126 ++++++++++++++++++++++++++++++++++---- include/linux/phylink.h | 1 + 2 files changed, 114 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index da0623d94a64..619ef553476f 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -160,16 +160,93 @@ static const char *phylink_an_mode_str(unsigned int mode) * @state: A link state * * Update the .speed and .duplex members of @state. We can determine them based - * on the .link_speed and .link_duplex. This function should be called whenever - * .link_speed and .link_duplex are updated. For example, userspace deals with - * link speed and duplex, and not the interface speed and duplex. Similarly, - * phys deal with link speed and duplex and only implicitly the interface speed - * and duplex. + * on the .link_speed, .link_duplex, .interface, and .rate_adaptation. This + * function should be called whenever .link_speed and .link_duplex are updated. + * For example, userspace deals with link speed and duplex, and not the + * interface speed and duplex. Similarly, phys deal with link speed and duplex + * and only implicitly the interface speed and duplex. */ static void phylink_state_fill_speed_duplex(struct phylink_link_state *state) { - state->speed = state->link_speed; - state->duplex = state->link_duplex; + switch (state->rate_adaptation) { + case RATE_ADAPT_NONE: + state->speed = state->link_speed; + state->duplex = state->link_duplex; + return; + case RATE_ADAPT_PAUSE: + state->duplex = DUPLEX_FULL; + break; + case RATE_ADAPT_CRS: + state->duplex = DUPLEX_HALF; + break; + case RATE_ADAPT_OPEN_LOOP: + state->duplex = state->link_duplex; + break; + } + + /* Use the max speed of the interface */ + switch (state->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: + state->speed = SPEED_100; + return; + + 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: + state->speed = SPEED_1000; + return; + + case PHY_INTERFACE_MODE_2500BASEX: + state->speed = SPEED_2500; + return; + + case PHY_INTERFACE_MODE_5GBASER: + state->speed = SPEED_5000; + return; + + 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: + state->speed = SPEED_10000; + return; + + case PHY_INTERFACE_MODE_25GBASER: + state->speed = SPEED_25000; + return; + + case PHY_INTERFACE_MODE_XLGMII: + state->speed = SPEED_40000; + return; + + case PHY_INTERFACE_MODE_INTERNAL: + state->speed = state->link_speed; + return; + + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_MAX: + state->speed = SPEED_UNKNOWN; + return; + } + + WARN_ON(1); } /** @@ -803,11 +880,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); @@ -944,6 +1022,7 @@ 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; + state->rate_adaptation = pl->link_config.rate_adaptation; if (state->an_enabled) { state->link_speed = SPEED_UNKNOWN; state->link_duplex = DUPLEX_UNKNOWN; @@ -968,8 +1047,10 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, else state->link = 0; - state->link_speed = state->speed; - state->link_duplex = state->duplex; + if (state->rate_adaptation == RATE_ADAPT_NONE) { + state->link_speed = state->speed; + state->link_duplex = state->duplex; + } } /* The fixed state is... fixed except for the link state, @@ -1043,6 +1124,8 @@ static void phylink_link_up(struct phylink *pl, struct net_device *ndev = pl->netdev; 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, @@ -1145,6 +1228,18 @@ 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.link_speed = + pl->phy_state.link_speed; + link_state.link_duplex = + pl->phy_state.link_duplex; + } + /* If we have a PHY, we need to update with * the PHY flow control bits. */ @@ -1380,6 +1475,7 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) mutex_lock(&pl->state_mutex); pl->phy_state.link_speed = phydev->speed; pl->phy_state.link_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; @@ -1392,10 +1488,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)); } @@ -1459,6 +1556,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, pl->phy_state.pause = MLO_PAUSE_NONE; pl->phy_state.link_speed = SPEED_UNKNOWN; pl->phy_state.link_duplex = DUPLEX_UNKNOWN; + pl->phy_state.rate_adaptation = RATE_ADAPT_NONE; phylink_state_fill_speed_duplex(&pl->phy_state); linkmode_copy(pl->supported, supported); linkmode_copy(pl->link_config.advertising, config.advertising); @@ -1902,8 +2000,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->link_speed; - kset->base.duplex = state->link_duplex; + if (kset->base.rate_adaptation == RATE_ADAPT_NONE) { + kset->base.speed = state->link_speed; + kset->base.duplex = state->link_duplex; + } kset->base.autoneg = state->an_enabled ? AUTONEG_ENABLE : AUTONEG_DISABLE; } diff --git a/include/linux/phylink.h b/include/linux/phylink.h index ab5edc1e5330..f32b97f27ddc 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -80,6 +80,7 @@ struct phylink_link_state { int duplex; int link_duplex; int pause; + int rate_adaptation; unsigned int link:1; unsigned int an_enabled:1; unsigned int an_complete:1; From patchwork Tue Jul 19 23:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923178 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 E4D56C433EF for ; Tue, 19 Jul 2022 23:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240285AbiGSXwH (ORCPT ); Tue, 19 Jul 2022 19:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240261AbiGSXvX (ORCPT ); Tue, 19 Jul 2022 19:51:23 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2051.outbound.protection.outlook.com [40.107.21.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C77D65550; Tue, 19 Jul 2022 16:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nqvlVUgrEQnvlvUWwiksGIbr/NIHafRAk/MoxrNspL8xlBv6KZ6LBX0qni7nT+1fsTst7uJCdygh5NSIcPi88Ft5wzaGEo258gQLoteUNut+JaiKhrL3dXRjNZFdTqqcUiq8J2OO3UIbAOoyk1YWQBxiUMW3R1O46MFKmAZG8SuujWgPxMzUsZs4oZF51+FDSwiYOcjupg8BVVj4hYN352FdzZwEHpeqjwD8By+HZn+dYHsO8rU58G8xcL1OVuNpSCkNgPyagE5lGP1fepfZBmNIAX0wEDyKT6gCVYQP04PH7y7UJXk1z/50zEkroBRvR54RLBwzLEhEPQ857I3Nvw== 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=OiSNoFcIGt6ZJWGY3wZhQzMrtAHg9IgdPPelA5lUqd4=; b=KYaEv/MGFZc7Iw5E3Popz5/RGOKCyn50ce4GVj3yTWnbvGHHYow5QlHWijscfwJ63ISmXWAa3jFCwBFdpxXcW6+ypLGV2VQwD7w/zigC5Z/Gxy09KjWt4nDcM2J6q/H+717KvZMinQePOyv2/A8xVfcldvFj3MemQeiXG3H2/ymhVsKfPbVKDuW1hx8F1dFSHqG92Py9wFGoHA0y6bkJrgCY8vw7WEuxQDWtT3zwTN5lHCzSpImsVcefjrJAxWDMLIAFGhl3K2Ghr0s0sQ9v4SdSjaGIpSz2qjK0ygxATY+od3pUkEs32uAtH/6Ml/ysL/Os1FbLzPesEX+QqcKERg== 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=OiSNoFcIGt6ZJWGY3wZhQzMrtAHg9IgdPPelA5lUqd4=; b=HElgw8dhBk7//CB3hjyGar0wg4IdsG16mX7zEePTOKfMNzdRJhZmYDm3z1LmjpDd9ycFgB2SSX6rIjNZIuV3O9JNKRKzu0e/7r0XSSg7lbuGFSC2tZ8qxVCXtln2vHLGVX6bb4q2iRO+8NpG4wD/u8xjQvuhcSQzuZWZi9lJ6ZJmUcJs9gQczxkexCcSzBabwKlBoN8DTbDVLYSjBDV08YLfKMFOvTMkliFPxZORtp9Tikn0mpTRbDkhYZw3rBlhmTvpkaIX/fcZwv5Uf8ISn7AcpKLre+aVmTuKLrzRYKpUGwF2R+kqpRzfLLgIOZEzzY0V4ctuQ4Z67oIX944VOQ== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:35 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:35 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 08/11] net: phylink: Adjust advertisement based on rate adaptation Date: Tue, 19 Jul 2022 19:49:58 -0400 Message-Id: <20220719235002.1944800-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 2d4c710b-20c3-49c2-8aa3-08da69e1798b X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l/s1iLHveR/5xJB0Io65DYcFCrhti9ncuJaUg1hTWCuAwaQRYknr5WWG7Qdtdpil7Wmzxv2Ag4Ll6KqYr77prOzy5cguNexY1hpb+aTZgizeqBULIF2h8aGEsvN9P1wsLVT1dz8+vo0j5DM2gpsqT/PFzMITrpXsuWWHK3w0aR9Zz/3/SG5nsqCvRMRidbf8Pq6R3eFwbxWflEVILxYcCj2g9PX9DaYetXcZoPetLJVIykaPEk8p0sK/SefzInFAh92r84xUf2Ae6ZBEIwb7QgF1LVX22JIpuW5n8sEiJ08Dc+8zbeqUIpc/hdgfLmDOC5Z/gq9JYNGZMgfDTaF58kySBfGI9xD3EpkV/jgi8JPyEPEVK8wf7+lDHvlezjjxVk5QMr4DsOE71O8fOtPwoA+7sBvkA/L69cjGYiccGqe9r8L17eEtSZdbxdZll1QWDox2n4K4HxqVmzTV4Y7ZgHt0XdZLtyHGCOjm+Idh+07x8K3PFtKo2BfM2HAtWY2sW5+xb5YXt9dKAnUUesciYUrSGwVL7pcgRnl2zU2k/tkzeStSlhVJmoqAjRryr82hmctPPHBDlnetlHgczqniKPgAZ/mX1IhvozzZO+nAR9aArBpIHxAI//dN7Aiu5hhf8zfCSfBgXC7Um6nV7eR4F7R/XpJHk3n0JPRs3ZOHxACqlYouZzsDYwzJgTsc1Eu8cfGbSL3A4h/B1nKxhdS15an5+su5dQx14B37h4c15jYHt/fAFC15sti29yPL4Ykx4h68StSwIX/I0qcgNK6yOlREYZQHhV9fbMvMlRqdMr4= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Rex5lVY9kaHMTQ35E1KN8c8OSzKUZZOmu5xsQqAet8qLeHkpGCHk0K2Qw3Z9VXAN/4e2n2ofxoJbqQRvNLDi0ROWXBj9ULrWb5peI/fws972Qfoyj6/UxrFAxuay6c0xclcvCJKNXfLgk7WPoFdqAY6hSZPDnLPfwx2KyRGLatUpmRI6TV2HYoz4gi02/Swj1gOSD8MXvCKiOBFpL5g4MdyvYbd9kMz9GV4HSpIis9IwsKwpoE8byDfvS85IDPOYHbOR0WlaaefNM+bMnQL+BmBlIvLhFMn7gpA2qzxnYs/SqZbEXDS6/fM7SrtI0nZpPDvgtAJXKAn2M7YmvMauPKt3IySfWp7JSvYep+1s41ZPKNFEDfBrVhaKhEussv0p8OFTX2AG1Rn7aIK2NEI44HnikIsLkY7XgHm6bwbg74RUjCc5pVSWyUplUFmudEmL9DKCAqKaG4liYbZHwqNj4r6S+sJ4DdoyUzjjE8zryIoXvLI6J2pwfFMQ3dkqARzUVIDa68JQMP4sLEM9fKPfjn2UAa/8bXCyYavONZl+e7Us++rlzQo6FhjgqKTHW2gHIji8M71lQReisUH2BayEjuuNIfAQA6BQ8yfzebA+lsSgEadSUOj8FcJyBHe4y7gltz8n85eGEybpDbx8HpW48SY3CI7ZcFLR6QgEkN2AyDIgfKTcNCW8nOdAegAtLhcyc4o1aaDHYp32XBiAvNBa/xL2O/3PamTHPYhJTG8ajHfJ84Rd6x48kw+HvrXpvn5g9p+gBM/X5IVODcKXrdcve91FRmT9RQXvH2Tn+1lGm5qY1Rp82FEpvEn8XKWUriMCDfCBnsOObUJANYiGlgDhJWLqHgxeb3HhJ8x/OpcaXsj+FjYf/HYIKL0euY5xpGA2Rc9kN0JhAAyyVsk/D9ERZHAsBiEnv/t0klzth4X0xUZpHAElrS6v1BgVmby0f4BSdmYhFcZOPjo1lkdSLHVbFK6X9BmPqnKB2loA2wYEcNShtTrqOVaV/1NTDOiK7MRWg6it+GoUKeZztN6YmDVHFUBsCgvNKXzdDiCJPEZfHR737d1zk1AfPX2AqRgwGDe6PJea9pkpgVySpV+3oBxIRilZ5US22Ozx/CtCILCPYBJBEee2RPBSjyE3qh0ttoKT0TJHV4hgxTkq70SARYRGJRy24iIyPv3QtDEiK1DgYtI/Rektqo7nisiaoiRGxLzgt/RSgBV6LfLD8Y7FGQapzh000bpX83yIjhdyWv+x0AgZC4ye+3Sb8CJTLY1pFS/m4Vpdb2DZTQsJ6WC/X/LvuRuyG8Larfamcoe+13LjBNCvhOOCd7T0y17DaCxlnut0/Jn/17vMwG0lxzIKvcmDCf2Y1QZZPUf62heI23fX3p/dPHZN4QgWYpzuGPXcFofNYwHrE/bl2hyvBlEMiUjJTKprthxPnu+Z9FfkPzCI/HoEaywu2d5sJgJoLiEEd8mpwDfNTTqci2/Gne3aXSumwecWSRL6bmpoFAoLIRxbhSQO1zn32n1z9OspNa8dzxu0Dnssis55WSUC6zuq842r2h1LJr58MDZHcivDfScRgJv8pq2aqnRj6b+BfosCHzG00n2BiBMcxCfPGABRrxzdQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d4c710b-20c3-49c2-8aa3-08da69e1798b X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:35.5811 (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: JAJrOJaz4HGF7OpARQQ01SlTYdi5+iKB2brqu1uIcJq8JUXu+reRSNVMy6V4PEZK81iuYR8Vp67BZZoUbS3wDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 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 v2: - Determine the interface speed and max mac speed directly instead of guessing based on the caps. drivers/net/phy/phylink.c | 87 +++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 5 ++- 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 619ef553476f..f61040c93f3c 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -398,18 +398,65 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) } EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); +static int phylink_caps_to_speed(unsigned long caps) +{ + unsigned int max_cap = __fls(caps); + + if (max_cap == __fls(MAC_10HD) || max_cap == __fls(MAC_10FD)) + return SPEED_10; + if (max_cap == __fls(MAC_100HD) || max_cap == __fls(MAC_100FD)) + return SPEED_100; + if (max_cap == __fls(MAC_1000HD) || max_cap == __fls(MAC_1000FD)) + return SPEED_1000; + if (max_cap == __fls(MAC_2500FD)) + return SPEED_2500; + if (max_cap == __fls(MAC_5000FD)) + return SPEED_5000; + if (max_cap == __fls(MAC_10000FD)) + return SPEED_10000; + if (max_cap == __fls(MAC_20000FD)) + return SPEED_20000; + if (max_cap == __fls(MAC_25000FD)) + return SPEED_25000; + if (max_cap == __fls(MAC_40000FD)) + return SPEED_40000; + if (max_cap == __fls(MAC_50000FD)) + return SPEED_50000; + if (max_cap == __fls(MAC_56000FD)) + return SPEED_56000; + if (max_cap == __fls(MAC_100000FD)) + return SPEED_100000; + if (max_cap == __fls(MAC_200000FD)) + return SPEED_200000; + if (max_cap == __fls(MAC_400000FD)) + return SPEED_400000; + return SPEED_UNKNOWN; +} + /** * 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) { unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; + unsigned long adapted_caps = 0; + struct phylink_link_state state = { + .interface = interface, + .rate_adaptation = rate_adaptation, + .link_speed = SPEED_UNKNOWN, + .link_duplex = DUPLEX_UNKNOWN, + }; + + /* Look up the interface speed */ + phylink_state_fill_speed_duplex(&state); switch (interface) { case PHY_INTERFACE_MODE_USXGMII: @@ -482,7 +529,39 @@ unsigned long phylink_get_capabilities(phy_interface_t interface, break; } - return caps & mac_capabilities; + switch (rate_adaptation) { + case RATE_ADAPT_NONE: + 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. + */ + if (!(mac_capabilities & MAC_SYM_PAUSE) || + !(mac_capabilities & MAC_ASYM_PAUSE)) + break; + + /* Can't adapt if the MAC doesn't support the interface's max + * speed + */ + if (state.speed != phylink_caps_to_speed(mac_capabilities)) + break; + + adapted_caps = GENMASK(__fls(caps), __fls(MAC_10HD)); + /* We can't use pause frames in half-duplex mode */ + adapted_caps &= ~(MAC_1000HD | MAC_100HD | MAC_10HD); + break; + } + case RATE_ADAPT_CRS: + /* TODO */ + break; + case RATE_ADAPT_OPEN_LOOP: + /* TODO */ + break; + } + + return (caps & mac_capabilities) | adapted_caps; } EXPORT_SYMBOL_GPL(phylink_get_capabilities); @@ -506,7 +585,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); @@ -1529,6 +1609,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 f32b97f27ddc..73e1aa73e30f 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -70,6 +70,8 @@ static inline bool phylink_autoneg_inband(unsigned int mode) * @link: true if the link is up. * @an_enabled: true if autonegotiation is enabled/desired. * @an_complete: true if autonegotiation has completed. + * @rate_adaptation: method of throttling @interface_speed to @speed, one of + * RATE_ADAPT_* constants. */ struct phylink_link_state { __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); @@ -531,7 +533,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 Jul 19 23:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923179 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 B1B4EC43334 for ; Tue, 19 Jul 2022 23:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240538AbiGSXwI (ORCPT ); Tue, 19 Jul 2022 19:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240274AbiGSXvY (ORCPT ); Tue, 19 Jul 2022 19:51:24 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2930F4B49A; Tue, 19 Jul 2022 16:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TneW34d3a2486u7NtP44H2MYMxbEOUFLmZusGyToYP8LBINc/WWaF/kiHxLCxixT423ymHxzRWvRp6QB221yNMn3zVvxTrw7/TNA6OJKJNPuQ+pGZPbK8NNw7q1cKo7cIhU++lSAqo/lfI1F2HC/4+0eWZ59Hq6tDzJugi57KQIBsss90BPKe6P/AYypl5ZNMt/wki2E22VWwYXzXsg/+aqHs4eR6vFgNv0edjs/rFPPoG7E4sXaFoBU7dh8AqpecxtxvZOm0IuJS8roESrHaALYYxd6TJ8oDs/fHjpfjJ6J1052w8T4qKuT+ZtXOhaww2KflfXiPO7GAqtQzLkggQ== 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=Sprp+V6GTFcU7jLzXBVWxu3favnUpiL20Gw7qI8FApo=; b=FvsprF6VcEoCHIqRuhVKzQtWU2+J340dFh1H1SIe85EwS4po7blf5/l+prmmoE3DAmD/KdpsGYBYYynZTEUS49vmviMFIlhEq2e4C8LiE+onrIDKDo6KrnR0nnxe5HMh2I77hPa67z85jvo7PS87qSQovzJ7NUir33Sqv/hN5VThG2G4F3FGh27u7M+A3lQpOJGmhCmoknaTVo85JxxpdfKCGpHsr39vw1KjL3+Fx6ctLRpzfF85C8EuDVy3sAB47RlPmr2O9n+8YeDpXkmlGf4EKhxcedxIXDtmjE23hz+3MBNMEC27u56IXR11egMuUCDB4wHAxy+gGs5OUvvziw== 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=Sprp+V6GTFcU7jLzXBVWxu3favnUpiL20Gw7qI8FApo=; b=k9QYGCSVF8CM+ViMy8UcOVqXSLZyJ5avgTYyXHNAhCIlBwH5WJwHOrO00XQdUbod3ZQ2l+0cu79icsMrwM/Hmgz26Vso62qoqR690SP3PIWSyvEYUxc3sf6nwOc4KmY9HcKKcQIzVeQ5XVAjdYmKxwtRHPwxG9buDJ6vSHqgGkEhIMOxNcoxG/kW1yGsz7DfZsVjCvFHRYMgwNe1Zb0gbkbuvl/NBtL5q1N3s7BZt5TegpycsqYhO9blKcL35CqZYcXGtsviESIm3JBAPz7TEWIMoxdD3DDpJj7rN0fqqGwIDqpBwkuKX4UCwzasXjgYBYYnAq3A2j6lBkpG1y2vCA== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:37 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:37 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 09/11] [RFC] net: phylink: Add support for CRS-based rate adaptation Date: Tue, 19 Jul 2022 19:49:59 -0400 Message-Id: <20220719235002.1944800-10-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 532bfd38-3b5d-4ebe-0634-08da69e17a6e X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ETCQAifnR6H/nmen9eS87gfvMEkg1fYHQyv/YvXszpm2u6neEEPod/VeAotw7s3wxzrmWKyGfhQwK/KcjfyPjFqJDjUfXtQ6gHTbz6gdGjvEKyHyTOPVci9RCYl0kYv+v4t4ciVxcsQWsO2QOkM492vkLoQ7hnbM8JWlPrZ+l5l1kmKOKIAgCU1uojzbkfOSa2V22SCMY6Za6yf5OiqX75WH1zAnM0cQZn7Fb64xSWnW3SZhbWSxP3nRuD3nKK+UVwYJHY9b9UwM8ZgBWJPJYSzKrhMoFrBKMwFtiRmRO4c8AbxngiCQQEqYRd93i6ZIkIC7BFfLfmWjbE4fVH1V1Ofrb5H8ForE4iOLiuIB8jKZ1PsejVSqVMXQaRzHzrerbs83EXHKogyjCrMlQxLXBQATJbBe9QXfa4KCxM8FjQDYgOpzhm33wPjHJngT8VKZGxMU6RyI1wvtKgodIdH2v4MT1nEU1WKbZJp02KbMpxapfeHPnvsjJfbCaeRkZCX8wJDT2+mMp5BrXd1FJpENBRUozcSwFnZDyRTUym0I/OosRk+27ihvbWQ9Xx/jyzH4MG9EaZu4+zcJbwoTArGP1HJ5fxw1CWn6i8bZCW9Q+cr7OIkCSCl8w07L9mfnk+RTu06TErD7Us5yvgQrFzZFL84Z1gtD4a2k0rYeSs04nBeqg+DhYJVni8ANsJvE4CTo0bLaQN0tG59xh3eORDV/tsa/dZWh8MKe/W+Nq19WjXx5XjijxNbcjs4MIGwnKjeNA+7/2OIF53sN60pf/sou7q/6AEDw/CDYVMYYspuSZ8E= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WcDEQF14gUcJkhexos9EXWATQyD6uP3W2JHvb1bDJL8UHAZ+45BqYcF3R+eshFKx9PibYoYf5Gv8ZZoytlpydsyp9vOLotBYhWjVqS959u/npMcrLsb5QUN89hbyShbWTRvhWZE0RRXwnWPomnY2isAVYLOrmwHDMNXzdgljPxp43Usmw+QpGrpbROXtn5NFbKD2fDa6OA4ZwrhKKz2NTcyn11T4znYZYSQVAVDvvBU/feVYl8pTJLntw/nk/Pf8W6i4YGhRparpTjbimwIILqyvWCI1Cpew0btG+9iZLhG2x/VGrNj6n6aYRgebjXdV4qQzWDKNpOWOks3PrYFNatjKR8+clk6ZLAKR/vuw44c1kXXgTIbb+9g9a3GV3S4slx2hiAb1QEDO9IYmYH/IAfhGdZp/tEDEvbgvUpblLLUMDQVKNybsXDhznF7KfRrsRENUjM/GlLFQhCd36I244RaAx2vniPEu85qc1hXCorTclB+//Lo9h+HfnYPfxyerKJuuwf+zHjC7+rNGBowhnzIxP/R99lSy3LYYu/W64sDrVajsOK3BFMzN89Qe3Ud4ftoqR86tRgfa7gTT3Wumx0IVWLOaNYEMCeTUHwfoVqq17pSzbcHE9g2O5v+hh5hEYTSrmfe4oyKvu7q2CY0nqGYIjLnynbde3mdQkMiJRsEHpIW3eNHv+zimRrDodDBwNdXEmMgXRTz1dH5hIltC0360qUjbFd+LchWZXbm0TjY+iQdzFY2Stcr1WlSh4wuZsXsdT/I3U9qo6liiPCrlZzYoFSH4ttadBSM1tfIY1gE4Rn0NVaoW+b9NFa4k0OP9Cl6CW4pdRfczJdXB6nyWGMrqSKCFDAj6K/nlxegEJ141Soz/hIE5DqdpsechjJ2oRGLxyVlfUBOcRFLdqKzzpfpqCwtmNV5dZyHj2fbJ5kuWYM3S6T65fR0L/bkVCxRniE6C0TG69l1VrzoyBgjMxWlHfI1vxPp4PiI3IlgcgFJbOYCBRRtE6US8QLLUWC9gRswW2XV0Ps146UGI1bX9hZVZ4WZaPvsOZDYszaVkYr10p+KaGCHgOCvRPD+e5JZg15Ab/nx1kZiQYVR/fBE7HFzLy8kaYIhjOY1LUO5HStGsujqtJX+I3K0mmhKDuMRPJ6QwTG5MRDjFvQLAjjPWz6IIZcvd1oPzoY5aOiJS07kQ45YkqUobFv6toQUcc1i3JVHG6/XgwJZNYpPS2TguXR1s+IcBj9n23s/VwnGK0Nx03Lp/fdsNI0bBElllkWGM6P5nDpAOpUJiao63tBarKxQE7M48I2/90IfU/mv8xf9Dyf2COr65+N7rAugAKSFhD/areualykboWB8bxUlB3ZejL783C8/T54fQPuapvHM87kCYQKjJOt93d3WTg4Vn8DmbHOlozvqteW3NSjNgktRM5giSofqPYu0bVB2iKARPyCmOthgylA6D8+qM5kLgzOfYFf88uCoC6oyQozBvgY2zd824mM40gyeZ+llfpxmfCqIwoJxkvTRSSfk0RjHuGFrgPE2SfBM1Fr0PL4CcwHmKY/FPlXm7dAjpAWxBsA0AsP5X6yMfw7wVaS/lfCAwjKU1m8IWgfwwn3NdOM8hLw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 532bfd38-3b5d-4ebe-0634-08da69e17a6e X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:37.0966 (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: ndGhlla++iTaYPm9eQa4Pr1tbm/4bpg0cHZtg4zIP5Gj63a/R0PsnZqwuXHbztcf+9u1fNhbnNYELez9xEY5mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for CRS-based rate adaptation, such as the type used for 10PASS-TS and 2BASE-TL. As these link modes are not supported by any in-tree phy, this patch is marked as RFC. It serves chiefly to illustrate the approach to adding support for another rate adaptation type. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index f61040c93f3c..75b4994d68c8 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -553,9 +553,18 @@ unsigned long phylink_get_capabilities(phy_interface_t interface, adapted_caps &= ~(MAC_1000HD | MAC_100HD | MAC_10HD); break; } - case RATE_ADAPT_CRS: - /* TODO */ + case RATE_ADAPT_CRS: { + /* The MAC must support half duplex at the interface speed */ + if (state.speed == SPEED_1000) { + if (mac_capabilities & MAC_1000HD) + adapted_caps = MAC_100 | MAC_10; + } else if (state.speed == SPEED_1000) { + if (mac_capabilities & MAC_100HD) + adapted_caps = MAC_10; + } + adapted_caps &= mac_capabilities; break; + } case RATE_ADAPT_OPEN_LOOP: /* TODO */ break; From patchwork Tue Jul 19 23:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923180 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 53C36C433EF for ; Tue, 19 Jul 2022 23:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240360AbiGSXw1 (ORCPT ); Tue, 19 Jul 2022 19:52:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239923AbiGSXvo (ORCPT ); Tue, 19 Jul 2022 19:51:44 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2051.outbound.protection.outlook.com [40.107.21.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359CE65588; Tue, 19 Jul 2022 16:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VlKEN9YR2JBM+TA1guPwo3wVmsjllTYtIVuCpHwnA++ovi7J/u4csR+OnvOIpgfqnSnApRWxHSqcNbkPR3enI0MAqG8VcfFJod06a0QHw+jnHKaHcMWLGzc11IWo3wZy3RlLA6BhFtSPzSNm/Fnn/2qN3LVYwZurtNZRICRrKqUw4OINfKpv/jA+unlV854PSP5FPVx+pbwDJu2VSPHvRFSMaEg1E/k6xhi8UXp5ye8eDnYSZc/b0eobtCLH294cvYzORlVDzTLwB2LNjzGefRRbE12QCSq/iaAPGxio87WC9D3SDVsiaVLjuNPKR6p0Nvb/pCCWrYMIyt2apuXEvQ== 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=oVy7nVSWqRIeR70nLj9MPIyvrl4E3rMb27p44Yx2C34=; b=RlsHlW2ivDmDnisB6qy1dTF8Inz4E+F9j/7sSC4P4PS3KD9pVgd4yBYZg2zpXSHJoEslBVpnvl3eIXz6Vy6mB9O/IjAXCuTxyToAObFN/vLkLbEkMldTNXLulYUmobWTGdeofgGJayl/v1FxjcA4gIjLI6ZiFPLCKrQhUNzb1lJSshLLoHMxhfkx5IGYlTE1H4kvtrF//LWbA568mpibAwrvIaFJaGww8fOIDWxL9+Xbby04yOX2ax+ny19m6/EBR8uJAmpW9Kpxk5pJKNI4tszbbmFtHD4fO8+76NYe+VWMcjpCGzvb/RfAKyWN0dXC5itmHek6dFAAIWBhN80snQ== 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=oVy7nVSWqRIeR70nLj9MPIyvrl4E3rMb27p44Yx2C34=; b=AaD9NEsO3RuStZ2vRxRwiLbw/Kwex1i8CSvpeYvRNRUVE4oC4tBscbJSrDaQFOWVQIrMvQh9ltSsXltKXfFbLmD6KDdNq+Zlu+V0VZT/o+qCbrKKMaLDwTUBBGntLQWggDOibe7RrcyKwC9kyxs6qcmJR1fExKNXYb/ldzCxiAmim04vJdhmoTiCb69dgPBIQkfuANp/G9pQHWa9bj27N770u1KhkHQ/2xHudtO+nrCP6NmCeWb7V0XsXeqAa85rLwIVwWY9oZYMvBXIjcELLQtznHfg6Rkc/Y3Lew86KBDAURg6frqB9PeVsaJhdtNN9yIAs6vi1RxeEkp40sImTA== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:38 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:38 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 10/11] net: phy: aquantia: Add some additional phy interfaces Date: Tue, 19 Jul 2022 19:50:00 -0400 Message-Id: <20220719235002.1944800-11-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: cc5b7c82-544b-45fe-9448-08da69e17b63 X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 65UAEm+322HHuncdR+ZXAE4jS6LNCJcVFV2sQCUJzbWjJ77r/agJfkpoQvqFCb/qAYUIgKcTWafcqzwlRKCKdqFZS/ZFUugkOfvfS1aWuJrkLvGmzdvlsIMaj+B7q7H6+eebgHq6lq3+TBVzR3QjGMP56rCWbdBS5UudghebuzHGiPdPu/Do1PRkJrKOtaByAgS/Fub2ixaHFcvk6KAiKFirQ1wzPrg3aXXwgj9X6c8JRk6wDgUeNMFqVrTJedz84PzREZIGu15yam5RF4kHYUyThYuKWNNRPzYNz7Khu0rNNSdS4z5UorMjo+cpOCeCKWv1SjEqn2jroLZw4U7Tt0/HQJONb3leRx2YNGwK5MmlPBeA4gOw0rylpJPI0I85c5hjGSweyuMVmD3V7BLFeGCukO6/LKq7MsRL6PYux3vvJylaLxbMfkwRkQzjIctZlAW/L/Sm2KimMqgO61AHhQm8HCZjcu3NSF4pv/3znHvQMrJ5RmuNeB2TkYe6aox0+Qv5KcdKtp8nYAnKLtQ9wgTgXqTl+Gl/TrbyJdV9H1gyDnXlLrlL0/TZwqxeURjbRvFPuuCh6A1QOONCwEoUHyeGu8R7UTyjbN/dkjliTPzdLeUB3FVYNtxrbjfmivXeVTHvZ59SSue6xreTlwV6YgyQuKEOReCZ2gzCiPy+Vg8AYdUzudrGZjgwjenGntq7uZzUWMOZNfrxZM49541NRpHEEuVDCkH18odhRTSHNltxrAhVdIJVSlS5iGtM3v/J8wgb0YyNYi/33Mu9fRsS483bX/yZkHdoPsCtlf9zHSU= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TWIqpKtpVI2RP22ycVnzRBzr6Cqa90O9RR1Z4MAALfwXXFmIYhBYW7E+bunRwRSMB/L1D64mVli34Y1Zgbfv7okjkMdcoZ2jWe4WUTd0C9uSKNnWPzrmAUHtM/86WfZHqoCgPqbCCebwDBUzWuWEUyOBT1jBQge6Fcb4/W7tgA3S1YYyN7WjVpQzjeJoHl0eLFY6OHOghKa23nJO6ODo5Q9F0b0RZoUXCIljqftHvNoasGk5mIqBHY6vB32dHfgnrTesfJzXd0mNXVMidAsstAZFQdABG2rwuW35jkB7b/XBLRZPieY0RvIPDRD/g+AIE4A43EvjXrvyoslMr6Vb4HKwyiw0ibIIWJjRv7fG6ojRmhi7G0C4ipP5y4Kval/JDYjncd21oGhJMQvQSNcyzRe3QrhchGCIM9eO6Smf5ZnDJ59wVsxpSTjoXavWhEwG/91ut3TiN8EPohYTADHUnTwS2gyiKV+eMtsiBFgAVBtsIEIsEZ526pmyMaKYMPYb+eWGqVuEatURCqpGpXGGLkrKS7ij6100nQ5lsd5orhOH6E7d0yFdPMDKm1H5tbijyO24ppk3JVeMHJl4m66Gep4g+MZ5BrHk5MT9pTrDAR0X+T44tTWRgGGjL8Pd0tzTcqlVUhfoetvBPvkVopiehhdhzgvVqsei+RKWly27mwNG+1tEd6tFiilaMvobwogxDixUw1I31xQC++XdcAKWnBjO2tXGTCaJl5rmVkfP5oJteTfkL7/Qrxr2p27uCSw1wdtIYhBIqFQkoCBZfGRBUQeIsd7u+JTaSCgnVbGW4JHp5MiT2mhIJSTgfcQLQ2B7ZydCebE8KB4HcodK7UorHePTqUlbKmtwUE82hlTnPBmvLhydWWTga+JW1qh30vc3yBzhU4Std+lKHXBwGVVswbN8P4FoRW7WgvUQHE98Sbx3s069wTGoZUgOypu8egjt9aEC/aezvGLeV1LWTuzk/OgGysCtuEGDDCOBUAQloxhGIFtYCTxUSMv7H53W3RM7NEcGBW/BcdyWn1jqLqoK+qMHPNFetTh9sboPMM+hj+jSUNprnTNsjMi872OKgMHVndHK8Vmc/gJOhfkp00Z5Fi8EbxEDPH1WVKmbxlELR4XGSY0Uje4T3FJKTepwEF0NXYUD8uqFlnrv1XoEQAl7KaIewNkwixT3DIH9lQg8IOSpCYcyLIw8w0gHKJpIxXOsDrehEyC/3LPemGuvWdFSGIkVDDLPOB847gY40kOs6wdxrT+A4lyEWGbA71GQC/mpkyl6IUZtBbMPJsoW1r6Aomt3B1RfSbJFo8cNkRJKAF5l6ygGcSS9o5mAp9xNzweRJYQmzN2UNvQjctDWVCiM4a2tH1Et5bFTlpQYTFl5uxm07u1WcX6qd2Stc1g5MbcrlztO+suetW2ME/6/iREerkpln3u5n/Wh7v4smaAItEA19fytnafDowl1dmYyOp8vCAtNLSHQepmuq4Gx3LZUnFCyw2cH09TlaBxN8JyMPWfdRbA2xLc2EnjveaheQrGjow5YQDPj7vYRS6aw2HCtuQIxHwVk43iXd8xWqWtSvYEPfhjgVC983N6HtJ/d5rJIehSfjtU4VrRs5PG7dYGVtQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc5b7c82-544b-45fe-9448-08da69e17b63 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:38.5965 (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: Zq+Nn6xBst+QDkQ4PONEWv3jclV6d3/zS1XwiASpdGqb3f8o6znEWIkWlIyHGcH8rc00QTNTu4JlrGt3yI/Npw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 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 v1) drivers/net/phy/aquantia_main.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 8b7a46db30e0..1e7036945a4e 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 @@ -91,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) @@ -335,6 +351,7 @@ 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); @@ -392,15 +409,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 +539,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 Jul 19 23:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12923181 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 B0693C43334 for ; Tue, 19 Jul 2022 23:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240661AbiGSXw2 (ORCPT ); Tue, 19 Jul 2022 19:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238688AbiGSXvp (ORCPT ); Tue, 19 Jul 2022 19:51:45 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507F365593; Tue, 19 Jul 2022 16:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YBIp0DlM7ckQDXgnakGSe/qYQ2iV6Tiit8xsWHcUlZ/D/i7LSTKEm66iJ//lvh1QX9DsqQ+XoHlYwdsz91XEJnV+2nhcxpmah83AE4y7v5rvTlOz6diOUNSTcBOda44ZYDZfB0zse+cL78nk5VkKdat0qG4bdf1doLRZtuWCGEOReQTKZDVNrGZx9/vMQOXYnz8WFtJbhBUUXgmm356DT0MJ49DXp0Bijlv63SmiyA3x/ESRQuxos0wyOu9BlyVp7ipOfAs+8UAWM4HMpbOVoPPQiILA/ALnhOwQ81yK3Rsd/n7hE6GJ8GgSrD2OcHzToqM+ZRxTo6H1OA5lqA8zEQ== 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=CwqgF/VSthAT9ESWw2ffD+n6n8x4GWkSvUBruY6zJ8A=; b=X7d8V7vpY6lYQkgY0D9Do4b9YzdQ+hUHB0URTco8l8iFJD7m0JkwGzPdQec0gdlIQSVwJcOc6DnTI5X5EkHC2FjxR0a+SUhjLqPMtATW2Z/G6fUEk+2vvmXHGe1gcmSJNCq/1MFDpT7mrGUCwgO6bJmUkYFtjiFJS40vIXoHbTQsPHuJm+BpQls6ObOWDdssKVmLenQdBwkRJTCNwmjc+oSXEIQf1aE2TBjRapCRyGeOKhz6A11Pc2OzEdERXu7V4txP37rSTNiLJIRGjl6RjQZ9iJ4qllCWSHX0/5205lhgDOWARgufOzYdtsVQHoQm8fLO+b5fJI8B4RGnU0fe9A== 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=CwqgF/VSthAT9ESWw2ffD+n6n8x4GWkSvUBruY6zJ8A=; b=PbXBfyK0+y43glmBc9UVC5zs2rNtDKfNEeWkt0maRIqaGQqqCkTiWAQQ0WiYknb+b4JrxfCF3R3vOlce5Sja/onA0iXMGaRSZg7Y59u6CQSXzJQI9wND/03fkbQO10kZq8RjL4BZNmAxulHSZF7XD3wC/t4Q6IBkvvd1Wm1xwoHHjtrQP2FHSzBRWMc5xIEbIbURkSmAmV0JK940Wxk/ziTEag7pRxaPrAKXyfEUrdHGZC9aw9fiiaur3Xrnak6AR5fmhUw1ij+QXPd79e5XhBu/N5BWlcC/Ko7/uv6UeXz41Ey8GBaJ/xLv9t+oG7NJFL8/wZlCpzHY0Hj8PUqqgg== 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 DB7PR03MB4811.eurprd03.prod.outlook.com (2603:10a6:10:30::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Tue, 19 Jul 2022 23:50:40 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::757e:b75f:3449:45b1%6]) with mapi id 15.20.5438.023; Tue, 19 Jul 2022 23:50:40 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Alexandru Marginean , Paolo Abeni , "David S . Miller" , linux-kernel@vger.kernel.org, Vladimir Oltean , Eric Dumazet , Jakub Kicinski , Sean Anderson Subject: [PATCH v2 11/11] net: phy: aquantia: Add support for rate adaptation Date: Tue, 19 Jul 2022 19:50:01 -0400 Message-Id: <20220719235002.1944800-12-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com> References: <20220719235002.1944800-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0227.namprd13.prod.outlook.com (2603:10b6:208:2bf::22) 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: 360f166e-64ac-4dc5-38e8-08da69e17c2e X-MS-TrafficTypeDiagnostic: DB7PR03MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8JhJZuoRw0c9OPjWzD0wQaAJ7k8H2hJ2GsrXbBSKDh5mdyvJjpb5qUSUoIbkIo60nTEU9/WY10R4N2+Nf1bJ5DIFeYVIlOLe1aIz5W+5M8hHhFCDQrmGw1RjXdS8A01pDgwd2WiEvOx56wgPZK5sdYsiargIukZu3rC0gi4yjpsusZUIan7ghJKB4uDuW188OCbwxdC2sS4N6P0xxKCkOXnekPi+rzNt1BpGqxZAMeYtgg/AUPSoaawkWUIkyXpG95yKHVSq3NpHucVAIBFsrJO5MZYD8AI380ABYLcPnglC9ttCaFKP+7Q+2UQC54xehMFZEcyIo3HxjVfVZrdt4YpQkH5Pqqoq+Mt6WN/hV7e4kMgf4NWWNLrRJkVehy6SaW40oapgYfP17lMijSh9Tg2huw9TyLgPN884f6h/exia1RLzHgDmir3XxRgQlppysqMuoJaZPFdOkHSJElNrS78SfuR+ff6usUs4qwV/WwJbmQFjirUk0Qf1agd+u6qxMNQccPIq0vK+c64vlAazo6RPCrJmuztgqZ3qr2q0/kVHj7ylRghrrCC5PcFPyJc0wXZb/Wdqr5jqjvq/rgeajManJbwUFrZi+Q9hzK4hmdkAo/kgaO0gTAsAgVMKcztM1rBobOtNR09QWojy97HOlkpanpZ3XBxafMSJj8WzpuD6rGmLwViwjCyiF2C+6opUIW2ffvO4uUJzVj8f+2GURGWvLjRRitv3N0TcuVGqBFFx4JdpRweHZIE9pXa3yWtC7K7cAnu7/+nQmfqzNlx7x+gC8R2pNRujlwiEJ5s3gt0= 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)(366004)(136003)(39850400004)(396003)(376002)(346002)(54906003)(2906002)(1076003)(83380400001)(186003)(66476007)(66946007)(8676002)(6666004)(4326008)(110136005)(36756003)(66556008)(52116002)(26005)(6512007)(6506007)(2616005)(107886003)(38350700002)(478600001)(86362001)(41300700001)(44832011)(5660300002)(316002)(7416002)(8936002)(38100700002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xX5Np3fXK1NgogAnI79r2anrZYCERhHqmtA0yaqFTTK5NLImhga7Tz2bdJKaehhNqb+hF/KW7oKJENyeZp7+YPNCqkAEiyHlA69VW0HxtUU+qF+NsU7CzdHjXmdcsgJmtmVl3FBhymEo/VFQsgdwhFlG7pqAwofhUKTGAYkjobkb2dGWcV9WOuXpSwBwwEUDPFAMXWs4qh8LwAD40SY5h6YSxwui6nlgQlBpRX9jDFnxK1an3qBoYBTdtKkmI+PmPz4zDtLPkm4OS8SzKEm3dbbo8JyWbh4WD3DkqeBCiYJAMfhrfHlyWusGpzTDZSeMbKwq+pp/RuXP4NzwfWH9r0TiZjam6MZwfwwfXFMKxmGz165zV7rF0z9R+LGdDfkWjzfFWEOMZXLWtmRVijouKg+nFtPcJwlavSZKDD+Z6mShoup4zS+WMjAckQI6qBWqVAe7Kf7lBTBNkSBvzaby5tnM+wvDmg2Q+z6/2mqEpyhezl+TB/s86BDwcwRwdXFwsYbjQHeqc+OlEvuci+TnYi6Jt+LPC5+psLY1hF11dQ34/fxe76Ux0gAr9nXxlq4VsQsG6qxigtQtTyQ+vZtV5FlQUByHYj5Oj8QBO2iL2cnW2tlS7aEwYsgxCGrXMFJWbIhDpx2S5yFbA3U8xVdUjzGQ8J77nnM8NoVjrXo3ZDKb8WkLgfC5YsVt+xUx1sKLruD+H4SEJH0xUvevXdcZbepMwQtREJaLnu1thfMCFDl6yqpNEfDYhgJ4LSZGGGGAl56QnKLHoTy9tOD6jYEV0caWDomeSJPbWKqGvjqG1MilQtDf2Viz2sW9TSqwpy8VZPTNBosnGzS8RXlVkl/G4u8H/KRqznOucjHFktxb0/dzu0fgEBE1FfUcNeYmVvQ7JwXCwfQAjNloUGV8xRghLdM3HiFygzquXtx8CzBfHgzCE7Yozo+3E+k7euwy2eUTCVNMvlowKwWts3SknDkNGhmPPqS0SNQ8Jk7heYN8MiR1GffxieM9E9+u0U75k2ieUDpP5GciCcdMcHs6zw0RQu5s/jWp6qtb3YUSVE9Gt7qzfO2E0oxB5573nFyZLzlyiBxcutXwahrKvdovy23+ngRZpOGrfCqXlwCrXoCg/3sm5gD8V5gwJYPP/xfAUO0laAjCLveTWa6MS1fOg4ekGw8ta9QvFoO2+4CO0cUQ6lkTCm9L89z8JOFGoow6LB+QsOTS0teY2gs/RzJ74nH4J0e3SNk/xmgaGEXzEp17kzsgTKnmEBPqRqzK2WzUDkwTar9h2LYqZ2HB1txRD/dQ2s5bUDCQnm64v2SIwXrsSsPJQSrC8VqH0mfC+Jv/hTqZoywJUbbuaq4FdRb8d57nhEjciDFKP3RIk6FmfjqT4JrHfAYT/Z3en4QsS6CNlIyU78Pk1ZT2M0N4SinPqTrqgtRryLT9T1qJkmHikaZBvwObZwGbc1KEHqFSAtoerXF+NNWUlSkqgBCrY9xo0DTLH9GdC5b548JCHHU+0iCu8OkntdenwmQFQe5FukCzI4Ny0/pev/C7dcpEytwgwqZR5RHHLtxidPTx0pt4LsQ04Tqv710Tn4pagJaNc6UX2g31nuPa5KQc0WNPThfhWAfi2g== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 360f166e-64ac-4dc5-38e8-08da69e17c2e X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2022 23:50:39.9870 (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: OEDnxC0yIy5GnnGkUEnyv/c0K1Ep/xbiDGkTdYr4iCsxDxoMXp23YlPDAqyVQUKu8DHDizaLYQRc/6m7c1QMYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB4811 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 --- Changes in v2: - Add comments clarifying the register defines - Reorder variables in aqr107_read_rate drivers/net/phy/aquantia_main.c | 37 +++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 1e7036945a4e..dd73891cf68a 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -358,34 +358,50 @@ static int aqr107_read_rate(struct phy_device *phydev) 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; } @@ -626,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, @@ -687,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, @@ -705,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, @@ -731,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,