From patchwork Fri Jul 15 21:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12919835 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62E36C43334 for ; Fri, 15 Jul 2022 22:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G0X1DCmUMuBZOQOT+LdefhTEd7rJV2aAztW7atoTRxE=; b=hf6MXkf/k9lo4S ZqXJON9egZswZtHuqv8QHcBZANF0tQLJQeYqZZueQUAMSXZPch0pQPzLQYbiR3wLYTn3+UqMT2jaR jcrKGFeV9+kr2h5RAPjMuofQS3wJ3wYrWoPhdSBMlZFSaXTMzTIkE3/Zq6h4RR4Vui48AjFih0YUE wbwafZ/rBiKV5MR2JQKVCtXOkSnwmBEpW0jDmeIUKpl/RstBNepn+nv+Fk3f/5p2FLdIPOzKx66x7 2Rl484czSHAfE11EaQy6afNS8SdbF/qxOGUv3SPGwelHl5t0ehogQCbPmAI8R9QEU8S69VkDPVKi0 DjEH/C35OUi7ucWzOWyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCTVW-00AfAd-Bz; Fri, 15 Jul 2022 22:09:58 +0000 Received: from mail-eopbgr50063.outbound.protection.outlook.com ([40.107.5.63] helo=EUR03-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCTMg-00Ab8A-4F for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2022 22:00:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TjphGwh45PlM83TTl1DP25zxzX1nLIZ2tbL5t8dCGd0muKlyCpAJuQw4yUll/CXw8u8Wq7Y9yjokZxa0L9ssKCS8ZwGxpO5AJ68ClDsTRKE4Dk8g+1lWsvGLTlC1D/sfBSNCytbA15SABrJKAjK9IA2b8ZE/ekQBgL4A7q/HkbHNhP1ZUV75ES+B1O5FAHRpJ6MXpBn36/y2Ppl2FDOHlDv+SSAKIc+PTxW2oErVFzhorr4ez0tTI4VEvai/8JuiqlKUjlbREtkEJTJ0IIFEcGqn26+FfLg8XNrZN1fiqQKmOlce2pzUG9iFSmM0qFVFq79iPLqm2AphbuVcB4h9Ag== 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=rPY1njZtILUEsQez2HiDy/q4A3Gla8dBhyfomEEgm84=; b=lusYGXx5BAdHlQyu6rIgHsXde280MHnNrwQ56C0B0qiKbYv7UTQnTeHkuh4sxliVUDZNSwK7P6cuIybyOPJ0nNhsXmzk+Bz0iFNdppyEGXfwUX4z9EA9m49Ik9ADV6565Tr3CZf4FRWWRmDBo4+27pev5v4s1kxjPnT/REanQNt3v6b/UI2aeJ+w7QDMGWfqsTtPV8oc+boDh+E3N7hEegmE38mKV83qfkQdjSsJ3M9c9GSyP4PMonH/whVc9q5+9E3hqBuymfVSC4g1g8eRNwWMOC93hWPwH3rXzCQzc1PKHrwQtIsq4at/TQH8qxUF5MeLJ73MGUcKBvc+lCQsZA== 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=rPY1njZtILUEsQez2HiDy/q4A3Gla8dBhyfomEEgm84=; b=sKxr0VtlG49Vn0K1Jz7AqVL1hlkAJz5/2HXhWPF4L9mD0BpyQm7LhSFkdUu4X2dLUBGDB5CS+mIqJaKW6jQFSK9bpSGEIq4A7A3vnMVKoM2xSuDcbGMtc2t7zNDmh671gk+fanRHI0drX/bJb2fMBh2wIh8fsGfMJWy4CPvDM/BXSZC+FcrK8NMDT88Qux1JT5jljue8FWxfMDSN33/n32IxxIWIw/C1alU7qsWD+nRoe1BUXEJF7+juhzsSWOSfngqeXJRlRfC5K5DUwHr8vYJabE/k98VKLtsU/QGlR/EVxYQhovkG7s/ywPcNXOB8WaLXavK9hmFpQ/WWC9dZYQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) by DU0PR03MB8598.eurprd03.prod.outlook.com (2603:10a6:10:3e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.15; Fri, 15 Jul 2022 22:00:46 +0000 Received: from VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::5c3e:4e46:703b:8558]) by VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::5c3e:4e46:703b:8558%7]) with mapi id 15.20.5438.015; Fri, 15 Jul 2022 22:00:46 +0000 From: Sean Anderson To: "David S . Miller" , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org Cc: Paolo Abeni , Eric Dumazet , linux-arm-kernel@lists.infradead.org, Russell King , linux-kernel@vger.kernel.org, Sean Anderson , Alexandru Marginean , Andrew Lunn , Heiner Kallweit , Vladimir Oltean Subject: [PATCH net-next v3 14/47] net: phy: aquantia: Add support for rate adaptation Date: Fri, 15 Jul 2022 17:59:21 -0400 Message-Id: <20220715215954.1449214-15-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220715215954.1449214-1-sean.anderson@seco.com> References: <20220715215954.1449214-1-sean.anderson@seco.com> X-ClientProxiedBy: CH2PR10CA0009.namprd10.prod.outlook.com (2603:10b6:610:4c::19) To VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 631a5be3-786a-479a-5f9e-08da66ad7886 X-MS-TrafficTypeDiagnostic: DU0PR03MB8598:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l4Ky9M9kiKPona2NxSMDwNgjXuLuklieoEVnc7PsCgJlBdqnH5hjUittW7N6vztDWl3K9su5FGgdhLCqh3cmfZJibWknk98Yvwvt4l17JfgpK7S6ocqaQJ5uIf66LU+s8kYE4SMIYo2Evx5SiR3vaLfdMxxB7kgnuDxpOEtsrubPdyceKiEFlwNX4JgonfT+8DsjtiwplccUFYht7401Z1DSflauziXMDnTvU/jRqN3Ly/0Jf1+U2wcX0NkWHPeCZW9Z6pwtEP1VPexJN6WcaWSDsY8w+2W0rXZJh85wmjcvsvOfJGufb8Lvo5sec92zbJP6z8BQnIZ2jt1FIINhRw7ZYw+JhHfFyVmLLhfzihRGqGAGO/cW02OmciGC8GJxPjZQ+1COnjvWo0G3X8xdS4B+VIkJ3HUZNRUo1OSPDqYT1dcKgw6mrElPWNmc/MSJoLjrLm9UEDW2bPOh6BJJNGOE7+I7fj6CZwwLEQWKwvxivRTezDV5fExQkukuYIg9GoEZ375K90LUOtjZUrWg/5lhxR9k4HSyeW+Bn71M9XKLMTD/Bec1lfgsN9Mv7nUVfVfiBv5CGHpq/LWLDBNpWNgYUMOFBVT5UlM6PPPR23OhErzz5OJsYiW1b7FopvbH5juS4Q8j46RfHFQMmnLbzJwHBU6idbYAUUKNZVG2+H+yl02hrFUnaQGo9RKDeQhiRYMp2xryKrBveRPVAS41m4B4XLP8eJh/7SWUJZvNZyudKXjkkxxTJZainPlbTEnVwSByb6Sr5/YDRhpmWtMQge5jiWHUJ1Gj7M6/CvIYDu927d2kEmOmaKPRDGvR630S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB4973.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(366004)(39850400004)(376002)(346002)(396003)(5660300002)(8936002)(44832011)(7416002)(2906002)(54906003)(66556008)(4326008)(8676002)(66476007)(66946007)(110136005)(86362001)(316002)(186003)(2616005)(26005)(38350700002)(52116002)(36756003)(6666004)(41300700001)(478600001)(6486002)(1076003)(6506007)(83380400001)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1SzR9k4tEzLQymcaDuOIqtBGw2TcK/HG7R5Nu5+LM26JH7UJUXwMFg0fOyAVzoOrcH/96u/Ke4ockyBKuoTmlWpRHjrgwVRAKVJGjm3IGwrtD74mNjtxMLxcG4M2cXwa8grwkc/kpEdw4VT7gQfN1VCFjKoZQ4E902dkF6aRuv4ODiMmSbeLH4U62ljak/u40uVLdQY2xY2MDv5MV2BvHhFl/HiJCNDGQAZQSq9ARbE/i3iTHLeY1OIa02841TeImlpWyMSHiQq1wEKQz8j62wxbEa9Dec5fm+UMQ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jrDGaNEBal//PCe9ZNatshH/ochBDIkckh6mrM518u/dQKooaR/zDZOHiAy+3bxqDgLo8C7waw1+/q0BroppDzlBLKsoR2jhRqvH0sQ6OJrRMeqYieWeDt94bgIHrGywGeDTbs/ASCrq1Xz33Clerey+65p0dK8tjGZWIa94ax0S4pjlya7n3aL9udXrOxD0QbaU5fCcHqlku3TqWnT1klTj1RKmtFqXZ5njgt1hihKjEcdF2DfjvKlWFwxvZNQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 631a5be3-786a-479a-5f9e-08da66ad7886 X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB4973.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2022 22:00:46.4887 (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: SDindBxdFq0x4JMT7YkMAf5Pfxowg1nCl5pjbXdI5bxE4lqHeidrRM8yNoNtD4ZMctgiaSkENB9iqPcj7YFTLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8598 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_150050_245738_1C8487EF X-CRM114-Status: GOOD ( 18.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 v3: - New drivers/net/phy/aquantia_main.c | 49 ++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 0a2f8c4aa845..e2ddcf0a68fc 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -95,6 +95,17 @@ #define VEND1_GLOBAL_FW_ID_MAJOR GENMASK(15, 8) #define VEND1_GLOBAL_FW_ID_MINOR GENMASK(7, 0) +#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 +#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) @@ -340,39 +351,56 @@ static int aqr_read_status(struct phy_device *phydev) static int aqr107_read_rate(struct phy_device *phydev) { int val; + u32 config_reg; val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_STATUS1); if (val < 0) return val; + if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + switch (FIELD_GET(MDIO_AN_TX_VEND_STATUS1_RATE_MASK, val)) { case MDIO_AN_TX_VEND_STATUS1_10BASET: phydev->speed = SPEED_10; + config_reg = VEND1_GLOBAL_CFG_10M; break; case MDIO_AN_TX_VEND_STATUS1_100BASETX: phydev->speed = SPEED_100; + config_reg = VEND1_GLOBAL_CFG_100M; break; case MDIO_AN_TX_VEND_STATUS1_1000BASET: phydev->speed = SPEED_1000; + config_reg = VEND1_GLOBAL_CFG_1G; break; case MDIO_AN_TX_VEND_STATUS1_2500BASET: phydev->speed = SPEED_2500; + config_reg = VEND1_GLOBAL_CFG_2_5G; break; case MDIO_AN_TX_VEND_STATUS1_5000BASET: phydev->speed = SPEED_5000; + config_reg = VEND1_GLOBAL_CFG_5G; break; case MDIO_AN_TX_VEND_STATUS1_10GBASET: phydev->speed = SPEED_10000; + config_reg = VEND1_GLOBAL_CFG_10G; break; default: phydev->speed = SPEED_UNKNOWN; - break; + return 0; } - if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) - phydev->duplex = DUPLEX_FULL; + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, config_reg); + if (val < 0) + return val; + + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) == + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + phydev->rate_adaptation = RATE_ADAPT_PAUSE; else - phydev->duplex = DUPLEX_HALF; + phydev->rate_adaptation = RATE_ADAPT_NONE; return 0; } @@ -613,6 +641,16 @@ static void aqr107_link_change_notify(struct phy_device *phydev) phydev_info(phydev, "Aquantia 1000Base-T2 mode active\n"); } +static enum rate_adaptation +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, @@ -674,6 +712,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, @@ -692,6 +731,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR115), .name = "Aquantia AQR115", .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, @@ -710,6 +750,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,