Message ID | 20221114210740.3332937-1-sean.anderson@seco.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2368483wru; Mon, 14 Nov 2022 13:15:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GfX4dl++o5Vb03dVWFxOjU1wyCWAkhM4fPdiC+xLqXfZWoYIYwJlXQkeIVM96UY5HTnqK X-Received: by 2002:a17:906:e0c6:b0:78d:3a04:e41d with SMTP id gl6-20020a170906e0c600b0078d3a04e41dmr11852295ejb.39.1668460506264; Mon, 14 Nov 2022 13:15:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668460506; cv=pass; d=google.com; s=arc-20160816; b=MJpYPpKc20lqcYbTmgQklWxDIBanBDs0S26fwbqu7udLS1cP+teFGw/CZpz9Bnba8b Xo8f09ZWkeoK6J+d9bAozDcJUsBUYMQIYLVf7zdn8ng9uCSwQ7GoFkj7oGaXAVvOYkLx ifrdp3/rMwR6j2ZDKoDWuR2Q+eOUowLP/uevGFurO0ZZ0QA5/37xlz6NB8bTzJ8PxDLQ w/Qz4FHi9n7KDr2ayjh9daLbAlzlhvlZT3TzpjWmtNy5obqP9pr+Xj4nR6WZQbX3jzS/ HpKaO++SWT7j7kyEqxXCwI6Gb12Vo/2IPi/vAkNeltF2mCO2hmE/fkeI2OqoPNh+PVSz lfrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=UjxcSIvL12nFFTzPtR1SUf+QUdxX+clFcMTQR2hZNJA=; b=fOuqyv+tiqswI2hJR0sToAk8tC9E1NxvxwV+Iga/yKW9LcLLBBybnSq0DBCHQc338U T261O7B9aw7QhSgBGOQDKDb8QSZatk58JxAcKTN8uw3PMQJX9+3vyvtWgu3+fPXcl2IV rdChOTPC1U3w7aq7INBBMcgWq9dYis1/SYSgbiwawPNX9t/+RuqeL4tNwFwUwXgYCVFj DhITmpD0iKyv9zoYV9JbwPrROGUxxNqJ2xjBGpuf0q/qB4cP0QPSCLH0gfkPnNCT0IB4 3iYGgOPbYHKXfjGJB6SWd6UE2MXGeVabH+hRH83F++ItWPKN8vfRpXNm02SNGxryag78 4GvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@seco.com header.s=selector1 header.b=z6CWTFQc; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc32-20020a17090716a000b007ae3958c7c9si10711088ejc.999.2022.11.14.13.14.41; Mon, 14 Nov 2022 13:15:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@seco.com header.s=selector1 header.b=z6CWTFQc; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237398AbiKNVIE (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Mon, 14 Nov 2022 16:08:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237315AbiKNVIA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 16:08:00 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50DF41114; Mon, 14 Nov 2022 13:07:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4/VOTO17YLDRa2YPhGrq36/1Ri2L5txaiOB51bb4YRQ4NTWQcfI/RwPzl9DpZF4LSF8GbmpId6fyCGzEBiIeFEZ/COpiN4ky9qQGU81p/RFXSXCgx747bOixsq83qLzeHE+TWMPK5sqVRwwpw3bIBo9yA/hLTqz67e//0Tr2hCWHz/ntfmxj/lcGklLW8t5r2sSFtw/j0Ncj5972taTo8sZe+xGImpdaO6+pbaZzdDT5Td+/Dwib3696XfVVdGpa8sHhjLFl45nTh8SDpc9ADOA6yzmt6xSd4xSiqwmZcrqPljW/0ZFDYC5j7jK4VoxIXqZA7psfm0PWQZDE6cYNQ== 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=UjxcSIvL12nFFTzPtR1SUf+QUdxX+clFcMTQR2hZNJA=; b=KbvKgo4Gy4MXOprrIilytacjgJ9SfeAzUwI8Ag1AhIrHn8L8bME86hfaZ2fV1kniTCeAsnUFbBjJBcsJP+INVwJ2VoBhjbEqU+u64dyu38DPGtLR83LhRHTgUEw/lm0/mUA5adk2OnJiWvLwojAOaD+RLGyN0W0/j7Gs3Bpn9n5YhNPgdSkm1DzNzP1ZeSJ4Cd+PV+fP9cXQ2EKI6HqsHial0tVrNkTQcPMFZaWNpquD3MMCXHlNtqzZ9LwkUBbrafJ/rTdf4O3gEqkMWjqsV7UJdDjCDmBf4vjurJK9nutx+KmD6FcYdOes0T8Eg5sIcIfRk+s7atIr/HfhRjawZQ== 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=UjxcSIvL12nFFTzPtR1SUf+QUdxX+clFcMTQR2hZNJA=; b=z6CWTFQcdWLl+PQr4Of4S0sbZPiQbUzbfkmcJ8UK0HyZNjFTN+od1gY1Vo8X4w0xWZCQDVtxv3zwlFpYEF807j/LdyNS6ngaYvkLCX7L1AIWfm04BxbusC5+6j/OzgW/mb2zdo21iVuQHhivB88CatMIrK3S2bWTJ1BDI3Wa7o+UwZ8QvxdIhP/1yKcaLlDgda/vHj7wI3B2WxpQPO1Y6WA4gnokJ9i419rhpwrOxmJzAfmb+HfF3SGOAY2fELK+8PHrG89AKz3g3KJQXesYn7rEgvAKC+H3cymzr6MaOuu4IpIZfa8UTkOLDHUKIlXtT3Pj1Ez/8XPWEdfZiqWzHQ== 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 PAWPR03MB9177.eurprd03.prod.outlook.com (2603:10a6:102:341::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.15; Mon, 14 Nov 2022 21:07:54 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::e9d6:22e1:489a:c23d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::e9d6:22e1:489a:c23d%4]) with mapi id 15.20.5813.018; Mon, 14 Nov 2022 21:07:54 +0000 From: Sean Anderson <sean.anderson@seco.com> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, netdev@vger.kernel.org Cc: Eric Dumazet <edumazet@google.com>, Vladimir Oltean <olteanv@gmail.com>, Tim Harvey <tharvey@gateworks.com>, "David S . Miller" <davem@davemloft.net>, linux-kernel@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Sean Anderson <sean.anderson@seco.com> Subject: [PATCH] phy: aquantia: Configure SERDES mode by default Date: Mon, 14 Nov 2022 16:07:39 -0500 Message-Id: <20221114210740.3332937-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR07CA0012.namprd07.prod.outlook.com (2603:10b6:208:1a0::22) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|PAWPR03MB9177:EE_ X-MS-Office365-Filtering-Correlation-Id: bd78b9d9-4fdf-444e-ba71-08dac6844bc5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HChHyHr9pwFIvihC4jAZJgx0dbiMA4ChIdbG9YkYfHGB0/uq1UxAPgMuStAdwz/+inivtqWOtM4UNXIigXsNpkbLCT5HCw+HqSK32m5CvOAfkLJojhEhTzaqgewDfA7TzRM3yHvnclhys37garLx5eUeAvL60kzPCkNWCtv6SbtwonwuAgpeODty4SdP66GovNQgxfT1sKnzrZ0ygHPqrciJFXSnfCs26UhhF+rllsECHbpupjc+61klxktojVh7GB4EYvVxkf0DLTNHGAUn8T7X1Obbo5SPgTm2e5FNc28pxFH8YS+MVrXXwvtcC5ER4mcNDiyLoPDfgYWnPEypqH+XKToG/KioBalkFMkPLt5Adu9EKK3khqIf+3iBryC4FNiJ0l8Y0/nVrphad7oduQIwkr1QOAeQZBmouDEd1IPG5Zq++3mX9CU7sIGiPAosvzG8FB/58ERrs7uwB3G1w8uruOUrm0/YHoVHsw7qCbiWUHW6AmXPIZdVOBxpmm4nyeHsVHrMdHj9aFskmbbJOf+Tz/0YDnjvRQKJ9WpwYtvY05Uh3ytX7U3nskettXlXxE8q4Ng/t9RFz1nwm/AhuD1cfR4T0CmAFifZDdt+zmjT4H1TSSm7xEj5jSg7vPTAP8kZQieyjmS61UMahBIWNG0QVCq7Pv5rna8070+pVDR9/IWRKlRCEZDjlZ60/4jIX/SGB2+9M3CpF6jZeBrp03sFt0lIRGE1RnHyhAhEI4CLPH6zc6KASxxBafvJiM3O 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:(13230022)(136003)(396003)(376002)(39850400004)(366004)(346002)(451199015)(41300700001)(8676002)(4326008)(316002)(6512007)(66946007)(66476007)(66556008)(36756003)(44832011)(5660300002)(7416002)(2616005)(52116002)(8936002)(186003)(1076003)(26005)(38350700002)(86362001)(38100700002)(2906002)(6666004)(107886003)(478600001)(6486002)(6506007)(54906003)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EyD0NFc8HAtQXizyjCgRdoR7xq7Ic8kk7P+xKwTXntww1UxLHaxEHZK/t3HN7M3eBwlm0j4daZmhkXhIamnsUX/FFqt9lNpmuK1QWtJoscgZtKpV2A68sAK3Ib//TIxE9bahvjDjHigBgbqbl/dSXY6Tgh21wB4rVWIEc0EO6wiv/4hkjTeQGuynH8EksYOvNOqp5Ef5ffTwlj/w3lpHTGZN4X372xxNFCa1OPmXrMOmYta7Hh4JHZ7AR6x8Ez94xKFW71dL5mt3XCIHrpmCkZd76+G1vpYiDv4hlXjKAFnPgUEVShaYZB48QakfD8597PHwlD/h5s9nWYiDeAjJd3qpo2SNsAI4WrmGJCYHTJa5YvKOJ68Ax4W1dMCLyi4HfyLgaOMlccav4Wgfz+j8f1xdhz+9ALt0YsB+aN8eVTusvHDwLQg2N2WHIu26HUfX/ksNnlr/fUnnvIpxVrTDUz75/wU/5o6VbS+eeLI7/NGfdRV7MO51S6Otzi5sRqndgLELnf94Pb4yrU5nB3+/dHxIipnMi21iE0/H/PiE3e871v4A5cebRL3OZcv9RcjX6Ao09cQQkS2+cCYLbgx3E4Wgs5PSJ4dOzrnCXODY2IEnLPYAdTZ7KQFLvRfVjrKZyXNNP2FwrTlaxDSsVU/5d7RIFsBMhG+BpiX0UMA4cHVs+5gWLPrCINATBrpTKwSbLGQk7PefhWyZT+OS6J74VKEEaQ7NUgx8fPD3IA1J7HPxzXHNhUp8U0OYgtPSMvpSPGfHCdePN/7enD+RfY7IpNtZL1INHI0jEp9k4aEenqUqY/XS90zYu/dbCTDr4I/9Ltcsjh8Mvc5Ea6Xl86uXtDL/0jHf9lhl++SIiSfv0swuy5IMs5nRX4klvZUfUSCaOtNc4yKyAhhqQ2l1j5JapoxIC3s35hB+5EEPY5W+3sZw3bEx5+CPrX8PxvUW+v2QfuUnTX7trJYrZ/ZBb9Z0wInHcxcTikLReT5EcZk/CJcpc50mk2rZ7aN3Draqwupk3x6dRR+euo5nNdsML86dC8exQ1aQ7D5qhin3XVL7X52VBT5L8m32fJtQoavHfur+NT5/00uq4ze0HYhXRJyIwKV/TecS/+b3/q3oNQcvXFNJFtIsNYnGQhRFc0o7LY9T1yU7D2oK+0bWP93Fl37Up14l8FpfIuepZqEmHDN4aZp4TU+IWuUrQiYcEux2nfhrC5zAcYEmJBriwNffEA/8ra0TxXRpv9hVOp2Xrbta1GNhVuibs0RmiDdR/a0bZstk2QLOlLFIx7iLeUbs5gXSPDry33ptM0vdkOPuejbjrm0rg87tlyjSkPx2LE0KFLg0eNs5lvEnIMbDsNvy18pCn6P3rdtwITRzr7/IQXtiW1gFge9rfIoegEcD2YkATjAD1AYfbTZH1rLqGVMEC4ojmg2ySm3FstYFi7Q1Bn62tNGx1rVXOc31Rj/uo4hVJRmTZNmyS5mGkqCdpF1rCbVK+y01U+iTWFwRpPaQ3o2HRheDfTByLvt+TrtgQjsrMyT36wZJWp/Qw5DaXbAkjjLx/R3UW55CcjjhIQrH2DS2YogY2TOp/N0W7pw+PKzOTBEzWwLtUbzETRecMH29Ao8mYQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd78b9d9-4fdf-444e-ba71-08dac6844bc5 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 21:07:53.9953 (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: HfJKD7NIoAV+U+wzvjsXoHiOr+hpoQbV/GAtWenEKIiqyBOppUWs2oEnlu9JJUuKGnSlFXvjLUZP8Eo0GXcTVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR03MB9177 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749507643913860433?= X-GMAIL-MSGID: =?utf-8?q?1749507643913860433?= |
Series |
phy: aquantia: Configure SERDES mode by default
|
|
Commit Message
Sean Anderson
Nov. 14, 2022, 9:07 p.m. UTC
When autonegotiation completes, the phy interface will be set based on
the global config register for that speed. If the SERDES mode is set to
something which the MAC does not support, then the link will not come
up. The register reference says that the SERDES mode should default to
XFI, but for some phys lower speeds default to XFI/2 (5G XFI). To ensure
the link comes up correctly, configure the SERDES mode.
We use the same configuration for all interfaces. We don't advertise
any speeds faster than the interface mode, so they won't be selected.
We default to pause-based rate adaptation, but enable USXGMII rate
adaptation for USXGMII. I'm not sure if this is correct for
SGMII; it might need USXGMII adaptation instead.
This effectively disables switching interface mode depending on the
speed, in favor of using rate adaptation. If this is not desired, we
would need some kind of API to configure things.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
drivers/net/phy/aquantia_main.c | 65 +++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
Comments
On Mon, Nov 14, 2022 at 04:07:39PM -0500, Sean Anderson wrote: > When autonegotiation completes, the phy interface will be set based on > the global config register for that speed. If the SERDES mode is set to > something which the MAC does not support, then the link will not come > up. The register reference says that the SERDES mode should default to > XFI, but for some phys lower speeds default to XFI/2 (5G XFI). To ensure > the link comes up correctly, configure the SERDES mode. > > We use the same configuration for all interfaces. We don't advertise > any speeds faster than the interface mode, so they won't be selected. > We default to pause-based rate adaptation, but enable USXGMII rate > adaptation for USXGMII. I'm not sure if this is correct for > SGMII; it might need USXGMII adaptation instead. > > This effectively disables switching interface mode depending on the > speed, in favor of using rate adaptation. If this is not desired, we > would need some kind of API to configure things. > > Signed-off-by: Sean Anderson <sean.anderson@seco.com> > --- Was this patch tested and confirmed to do something sane on any platform at all?
On 11/15/22 17:37, Vladimir Oltean wrote: > On Mon, Nov 14, 2022 at 04:07:39PM -0500, Sean Anderson wrote: >> When autonegotiation completes, the phy interface will be set based on >> the global config register for that speed. If the SERDES mode is set to >> something which the MAC does not support, then the link will not come >> up. The register reference says that the SERDES mode should default to >> XFI, but for some phys lower speeds default to XFI/2 (5G XFI). To ensure >> the link comes up correctly, configure the SERDES mode. >> >> We use the same configuration for all interfaces. We don't advertise >> any speeds faster than the interface mode, so they won't be selected. >> We default to pause-based rate adaptation, but enable USXGMII rate >> adaptation for USXGMII. I'm not sure if this is correct for >> SGMII; it might need USXGMII adaptation instead. >> >> This effectively disables switching interface mode depending on the >> speed, in favor of using rate adaptation. If this is not desired, we >> would need some kind of API to configure things. >> >> Signed-off-by: Sean Anderson <sean.anderson@seco.com> >> --- > > Was this patch tested and confirmed to do something sane on any platform > at all? This was mainly intended for Tim to test and see if it fixed his problem. --Sean
On Tue, Nov 15, 2022 at 05:46:54PM -0500, Sean Anderson wrote: > On 11/15/22 17:37, Vladimir Oltean wrote: > > Was this patch tested and confirmed to do something sane on any platform > > at all? > > This was mainly intended for Tim to test and see if it fixed his problem. And that is stated where? Does Tim know he should test it? If you don't have the certainty that it works, do maintainers know not to apply it, as many times unfortunately happens when there is no review comment and the change looks innocuous? Even if the change works, why would it be a good idea to overwrite some random registers which are supposed to be configured correctly by the firmware provided for the board? If the Linux fixup works for one board with one firmware, how do we know it also works for another board with the same PHY, but different firmware? Are you willing to take the risk to break someone's system to find out? As long as the Aquantia PHY driver doesn't contain all the necessary steps for bringing the PHY up from a clean slate, but works on top of what the firmware has done, changes like this make me very uncomfortable to add any PHY ID to the Aquantia driver. I'd rather leave them with the Generic C45 driver, even if that means I'll lose interrupt support, rate matching and things like that.
On 11/15/22 18:02, Vladimir Oltean wrote: > On Tue, Nov 15, 2022 at 05:46:54PM -0500, Sean Anderson wrote: >> On 11/15/22 17:37, Vladimir Oltean wrote: >> > Was this patch tested and confirmed to do something sane on any platform >> > at all? >> >> This was mainly intended for Tim to test and see if it fixed his problem. > > And that is stated where? Does Tim know he should test it? > If you don't have the certainty that it works, do maintainers know not > to apply it, as many times unfortunately happens when there is no review > comment and the change looks innocuous? Sorry, I should have done a better job communicating this (probably by marking it RFC). > Even if the change works, why would it be a good idea to overwrite some > random registers which are supposed to be configured correctly by the > firmware provided for the board? They're not random registers. They happen to be exactly the same registers we use to determine if rate adaptation is enabled. > If the Linux fixup works for one board > with one firmware, how do we know it also works for another board with > the same PHY, but different firmware? How do we know if a fix on one board for any hardware works on another board? > Are you willing to take the risk to break someone's system to find out? I hope it doesn't come to that. I would much rather get some feedback/testing so I can be more confident in whatever we end up doing (or not). Well, part of my goal in sending out this patch is to get some feedback on the right thing to do here. As I see it, there are three ways of configuring this phy: - Always rate adapt to whatever the initial phy interface mode is - Switch phy interfaces depending on the link speed - Do whatever the firmware sets up On my system, the last option happens to be the same as the first. However, on Tim's system it's not. I had originally considered doing this kind of configuration in my initial rate adaptation patch. However, I deferred it since nothing needed to be configured for me. The problem here is that if we advertise like we are in the first mode, but we are not actually, then we can end up negotiating a link mode which we don't support. I think there are a few ways to address this: - Always enable rate adaptation, since that's what we tell phylink we do. This is what this patch does. It's a bit risky (since it departs from "do whatever the firmware does"). It's also a bit rigid (what if - We can check all the registers to ensure we are actually going to rate adapt. If we aren't, we tell phylink we don't support it. This is the least risky, but we can end up not bringing up the link even in circumstances where we could if we configured things properly. And we generally know the right way to configure things. - Add a configuration option (devicetree? ethtool?) on which option above to pick. This is probably what we will want to do in the long term, but I feel like we have enough information to determine the right thing to do most of the time (without needing manual intervention). > As long as the Aquantia PHY driver doesn't contain all the necessary > steps for bringing the PHY up from a clean slate, but works on top of > what the firmware has done, changes like this make me very uncomfortable > to add any PHY ID to the Aquantia driver. I'd rather leave them with the > Generic C45 driver, even if that means I'll lose interrupt support, rate > matching and things like that. I think these registers should be viewed as configuration for the phy as a whole, rather than as guts which should be configure by firmware. At least for the fields we're working with, it seems clear to me what's going on. --Sean
> Well, part of my goal in sending out this patch is to get some feedback > on the right thing to do here. As I see it, there are three ways of > configuring this phy: > > - Always rate adapt to whatever the initial phy interface mode is > - Switch phy interfaces depending on the link speed > - Do whatever the firmware sets up My understanding of the aQuantia firmware is that it is split into two parts. The first is the actual firmware that runs on the PHY. The second is provisioning, which seems to be a bunch of instructions to put value X in register Y. It seems like aQuantia, now Marvell, give different provisioning to different customers. What this means is, you cannot really trust any register contains what you want, that your devices does the same as somebody elses' device in its reset state. So i would say, "Do whatever the firmware sets up" is the worst choice. Assume nothing, set every register which is important to the correct value. Andrew
On Thu, Nov 17, 2022 at 06:40:02PM -0500, Sean Anderson wrote: > > Even if the change works, why would it be a good idea to overwrite some > > random registers which are supposed to be configured correctly by the > > firmware provided for the board? > > They're not random registers. They happen to be exactly the same registers > we use to determine if rate adaptation is enabled. As far as I'm concerned, this is just poking in places where there is no guarantee that the end result will be a known state. FWIW, for internal testing of multiple SERDES modes all with the same Aquantia firmware, the NXP SDK also has a quick-and-dirty patch to change the SERDES protocol on the Aquantia PHY based on device tree: https://source.codeaurora.org/external/qoriq/qoriq-components/linux/tree/drivers/net/phy/aquantia_main.c?h=lf-5.15.y#n288 but we decided to not upstream such a thing, specifically because it might react in exotic ways with firmware images shipped by Aquantia to some of their other customers. I don't work for Aquantia, I am not a fan of their model of customizing firmware for everyone, and I don't want to have to support the ensuing breakage, I wouldn't have time for basically anything else. If you do, I'm not going to stop you. Just be prepared to help me too ;) > > If the Linux fixup works for one board > > with one firmware, how do we know it also works for another board with > > the same PHY, but different firmware? > > How do we know if a fix on one board for any hardware works on another board? If both boards start from the same state X and make the same transition T, they end in the same state Y, no? Aquantia PHYs don't all start from the same state. Not sure what you'd like me to say. > Well, part of my goal in sending out this patch is to get some feedback > on the right thing to do here. As I see it, there are three ways of > configuring this phy: > > - Always rate adapt to whatever the initial phy interface mode is > - Switch phy interfaces depending on the link speed > - Do whatever the firmware sets up "Do whatever the firmware sets up", which means either bullet 1, or bullet 2, or a combination of both (unlikely but AFAIU possible). > > On my system, the last option happens to be the same as the first. > However, on Tim's system it's not. I had originally considered doing > this kind of configuration in my initial rate adaptation patch. However, > I deferred it since nothing needed to be configured for me. > > The problem here is that if we advertise like we are in the first mode, > but we are not actually, then we can end up negotiating a link mode > which we don't support. I didn't quite understand in your patch set why there exists a phydev->rate_matching as well as a phy_get_rate_matching() procedure. It seems like that's at the root of all issues here? Couldn't phy_get_rate_matching() be made to look at the hardware registers for the given interface? > I think there are a few ways to address this: > > - Always enable rate adaptation, since that's what we tell phylink we > do. This is what this patch does. It's a bit risky (since it departs > from "do whatever the firmware does"). It's also a bit rigid (what if I think the mistake is that we tell phylink we support rate matching when the firmware provisioning doesn't agree. > - We can check all the registers to ensure we are actually going to rate > adapt. If we aren't, we tell phylink we don't support it. This is the > least risky, but we can end up not bringing up the link even in > circumstances where we could if we configured things properly. And we > generally know the right way to configure things. Like when? > - Add a configuration option (devicetree? ethtool?) on which option > above to pick. This is probably what we will want to do in the long > term, but I feel like we have enough information to determine the > right thing to do most of the time (without needing manual > intervention). Not sure I see the need, when long-term there is no volunteer to make the Linux driver bring Aquantia PHYs to a known state regardless of vendor provisioning. Until then, there is just no reason to even attempt this. > > As long as the Aquantia PHY driver doesn't contain all the necessary > > steps for bringing the PHY up from a clean slate, but works on top of > > what the firmware has done, changes like this make me very uncomfortable > > to add any PHY ID to the Aquantia driver. I'd rather leave them with the > > Generic C45 driver, even if that means I'll lose interrupt support, rate > > matching and things like that. > > I think these registers should be viewed as configuration for the phy as > a whole, rather than as guts which should be configure by firmware. At > least for the fields we're working with, it seems clear to me what's > going on. Until you look at the procedure in the NXP SDK and see that things are a bit more complicated to get right, like put the PHY in low power mode, sleep for a while. I think a large part of that was determined experimentally, out of laziness to change PHY firmware on some riser cards more than anything. We still expect the production boards to have a good firmware, and Linux to read what that does and adapt accordingly.
On 11/18/22 11:49, Vladimir Oltean wrote: > On Thu, Nov 17, 2022 at 06:40:02PM -0500, Sean Anderson wrote: >> > Even if the change works, why would it be a good idea to overwrite some >> > random registers which are supposed to be configured correctly by the >> > firmware provided for the board? >> >> They're not random registers. They happen to be exactly the same registers >> we use to determine if rate adaptation is enabled. > > As far as I'm concerned, this is just poking in places where there is no > guarantee that the end result will be a known state. > > FWIW, for internal testing of multiple SERDES modes all with the same > Aquantia firmware, the NXP SDK also has a quick-and-dirty patch to > change the SERDES protocol on the Aquantia PHY based on device tree: > https://source.codeaurora.org/external/qoriq/qoriq-components/linux/tree/drivers/net/phy/aquantia_main.c?h=lf-5.15.y#n288 > > but we decided to not upstream such a thing, specifically because > it might react in exotic ways with firmware images shipped by Aquantia > to some of their other customers. I don't work for Aquantia, I am not a > fan of their model of customizing firmware for everyone, and I don't > want to have to support the ensuing breakage, I wouldn't have time for > basically anything else. If you do, I'm not going to stop you. Just be > prepared to help me too ;) > >> > If the Linux fixup works for one board >> > with one firmware, how do we know it also works for another board with >> > the same PHY, but different firmware? >> >> How do we know if a fix on one board for any hardware works on another board? > > If both boards start from the same state X and make the same transition > T, they end in the same state Y, no? Aquantia PHYs don't all start from > the same state. Not sure what you'd like me to say. > >> Well, part of my goal in sending out this patch is to get some feedback >> on the right thing to do here. As I see it, there are three ways of >> configuring this phy: >> >> - Always rate adapt to whatever the initial phy interface mode is >> - Switch phy interfaces depending on the link speed >> - Do whatever the firmware sets up > > "Do whatever the firmware sets up", which means either bullet 1, or > bullet 2, or a combination of both (unlikely but AFAIU possible). Happened to Tim. >> >> On my system, the last option happens to be the same as the first. >> However, on Tim's system it's not. I had originally considered doing >> this kind of configuration in my initial rate adaptation patch. However, >> I deferred it since nothing needed to be configured for me. >> >> The problem here is that if we advertise like we are in the first mode, >> but we are not actually, then we can end up negotiating a link mode >> which we don't support. > > I didn't quite understand in your patch set why there exists a > phydev->rate_matching as well as a phy_get_rate_matching() procedure. > It seems like that's at the root of all issues here? Couldn't > phy_get_rate_matching() be made to look at the hardware registers for > the given interface? This is what I propose below as strategy 2. I didn't do this originally, because it was more complex and I didn't have evidence that we would need it. >> I think there are a few ways to address this: >> >> - Always enable rate adaptation, since that's what we tell phylink we >> do. This is what this patch does. It's a bit risky (since it departs >> from "do whatever the firmware does"). It's also a bit rigid (what if > > I think the mistake is that we tell phylink we support rate matching > when the firmware provisioning doesn't agree. > >> - We can check all the registers to ensure we are actually going to rate >> adapt. If we aren't, we tell phylink we don't support it. This is the >> least risky, but we can end up not bringing up the link even in >> circumstances where we could if we configured things properly. And we >> generally know the right way to configure things. > > Like when? Well, like whenever the phy says "Please do XFI/2" or some other mode we don't have a phy interface mode for. We will never be able to tell the MAC "Please do XFI/2" (until we add an interface mode for it), so that's obviously wrong. >> - Add a configuration option (devicetree? ethtool?) on which option >> above to pick. This is probably what we will want to do in the long >> term, but I feel like we have enough information to determine the >> right thing to do most of the time (without needing manual >> intervention). > > Not sure I see the need, when long-term there is no volunteer to make > the Linux driver bring Aquantia PHYs to a known state regardless of > vendor provisioning. Until then, there is just no reason to even attempt > this. I mean a config for option 1 vs 2 above. >> > As long as the Aquantia PHY driver doesn't contain all the necessary >> > steps for bringing the PHY up from a clean slate, but works on top of >> > what the firmware has done, changes like this make me very uncomfortable >> > to add any PHY ID to the Aquantia driver. I'd rather leave them with the >> > Generic C45 driver, even if that means I'll lose interrupt support, rate >> > matching and things like that. >> >> I think these registers should be viewed as configuration for the phy as >> a whole, rather than as guts which should be configure by firmware. At >> least for the fields we're working with, it seems clear to me what's >> going on. > > Until you look at the procedure in the NXP SDK and see that things are a > bit more complicated to get right, like put the PHY in low power mode, > sleep for a while. I think a large part of that was determined experimentally, > out of laziness to change PHY firmware on some riser cards more than anything. > We still expect the production boards to have a good firmware, and Linux > to read what that does and adapt accordingly. Alas, if only Marvell put stuff like this in a manual... All I have is a spec sheet and the register reference, and my company has an NDA... We aren't even using this phy on our board, so I am fine disabling rate adaptation for funky firmwares. --Sean
On Fri, Nov 18, 2022 at 01:02:29AM +0100, Andrew Lunn wrote: > > Well, part of my goal in sending out this patch is to get some feedback > > on the right thing to do here. As I see it, there are three ways of > > configuring this phy: > > > > - Always rate adapt to whatever the initial phy interface mode is > > - Switch phy interfaces depending on the link speed > > - Do whatever the firmware sets up > > My understanding of the aQuantia firmware is that it is split into two > parts. The first is the actual firmware that runs on the PHY. The > second is provisioning, which seems to be a bunch of instructions to > put value X in register Y. It seems like aQuantia, now Marvell, give > different provisioning to different customers. > > What this means is, you cannot really trust any register contains what > you want, that your devices does the same as somebody elses' device in > its reset state. > > So i would say, "Do whatever the firmware sets up" is the worst > choice. Assume nothing, set every register which is important to the > correct value. If "do whatever the firmware sets up" is the worst choice, it means you think it's worse than "doing whatever the firmware sets up, except a few fixups here and there which worked on my board". Whereas I think _that's_ actually even worse. What might be an even bigger offence than giving different provisioning to different customers is giving different documentation to different customers. In the Aquantia Register Specification for Gen4 PHYs given to NXP, the SerDes mode field in register 1E.31C cannot even _take_ the value of 6. They're all documented only from 0 to 5. I only learned that 6 (XFI/2) was a thing from the discussion between Sean and Tim.
On Fri, Nov 18, 2022 at 12:11:30PM -0500, Sean Anderson wrote: > >> - We can check all the registers to ensure we are actually going to rate > >> adapt. If we aren't, we tell phylink we don't support it. This is the > >> least risky, but we can end up not bringing up the link even in > >> circumstances where we could if we configured things properly. And we > >> generally know the right way to configure things. > > > > Like when? > > Well, like whenever the phy says "Please do XFI/2" or some other mode we > don't have a phy interface mode for. We will never be able to tell the MAC > "Please do XFI/2" (until we add an interface mode for it), so that's > obviously wrong. Add an interface mode for it then... But note that I have absolutely no clue what XFI/2 is. Apparently Aquantia doesn't want NXP to know.... > >> - Add a configuration option (devicetree? ethtool?) on which option > >> above to pick. This is probably what we will want to do in the long > >> term, but I feel like we have enough information to determine the > >> right thing to do most of the time (without needing manual > >> intervention). > > > > Not sure I see the need, when long-term there is no volunteer to make > > the Linux driver bring Aquantia PHYs to a known state regardless of > > vendor provisioning. Until then, there is just no reason to even attempt > > this. > > I mean a config for option 1 vs 2 above. How would this interact with Marek's proposal for phy-mode to be an array, and some middle entity (phylink?) selects the SERDES protocol and rate matching algorithm to use for each medium side link speed? https://patchwork.kernel.org/project/netdevbpf/cover/20211123164027.15618-1-kabel@kernel.org/ > > Until you look at the procedure in the NXP SDK and see that things are a > > bit more complicated to get right, like put the PHY in low power mode, > > sleep for a while. I think a large part of that was determined experimentally, > > out of laziness to change PHY firmware on some riser cards more than anything. > > We still expect the production boards to have a good firmware, and Linux > > to read what that does and adapt accordingly. > > Alas, if only Marvell put stuff like this in a manual... All I have is a spec > sheet and the register reference, and my company has an NDA... Can't help with much more than providing this hint, sorry. All I can say is that SERDES protocol override from Linux is possible with care, at least on some systems. But it may be riddled with landmines. > We aren't even using this phy on our board, so I am fine disabling rate adaptation > for funky firmwares. Disabling rate adaptation is one thing. But there's also the unresolved XFI/2 issue?
On 11/18/22 12:30, Vladimir Oltean wrote: > On Fri, Nov 18, 2022 at 12:11:30PM -0500, Sean Anderson wrote: >> >> - We can check all the registers to ensure we are actually going to rate >> >> adapt. If we aren't, we tell phylink we don't support it. This is the >> >> least risky, but we can end up not bringing up the link even in >> >> circumstances where we could if we configured things properly. And we >> >> generally know the right way to configure things. >> > >> > Like when? >> >> Well, like whenever the phy says "Please do XFI/2" or some other mode we >> don't have a phy interface mode for. We will never be able to tell the MAC >> "Please do XFI/2" (until we add an interface mode for it), so that's >> obviously wrong. > > Add an interface mode for it then... > But note that I have absolutely no clue what XFI/2 is. Apparently > Aquantia doesn't want NXP to know.... SERDES Mode [2:0] 0 = XFI 1 = Reserved 2 = Reserved 3 = SGMII 4 = OCSGMII 5 = Low Power 6 = XFI/2 (i.e. XFI 5G) 7 = XFI*2 (i.e. XFI 20G) This is about it (aside from a mention in the PHY XS System Interface Connection Status register). I assume it's over/underclocked XFI, much like how 2500BASE-X is over/underclocked "SGMII." I got my manual from Marvell's customer portal (okta). My document is dated March 10, 2022. >> >> - Add a configuration option (devicetree? ethtool?) on which option >> >> above to pick. This is probably what we will want to do in the long >> >> term, but I feel like we have enough information to determine the >> >> right thing to do most of the time (without needing manual >> >> intervention). >> > >> > Not sure I see the need, when long-term there is no volunteer to make >> > the Linux driver bring Aquantia PHYs to a known state regardless of >> > vendor provisioning. Until then, there is just no reason to even attempt >> > this. >> >> I mean a config for option 1 vs 2 above. > > How would this interact with Marek's proposal for phy-mode to be an > array, and some middle entity (phylink?) selects the SERDES protocol and > rate matching algorithm to use for each medium side link speed? > https://patchwork.kernel.org/project/netdevbpf/cover/20211123164027.15618-1-kabel@kernel.org/ Yeah, this is what I was referring to in the other thread [1]. In order to implement this properly, we'd need to know what interfaces are supported, electrically, by the board. [1] https://lore.kernel.org/netdev/ea320070-a949-c737-22c4-14fd199fdc23@seco.com/ >> > Until you look at the procedure in the NXP SDK and see that things are a >> > bit more complicated to get right, like put the PHY in low power mode, >> > sleep for a while. I think a large part of that was determined experimentally, >> > out of laziness to change PHY firmware on some riser cards more than anything. >> > We still expect the production boards to have a good firmware, and Linux >> > to read what that does and adapt accordingly. >> >> Alas, if only Marvell put stuff like this in a manual... All I have is a spec >> sheet and the register reference, and my company has an NDA... > > Can't help with much more than providing this hint, sorry. All I can say > is that SERDES protocol override from Linux is possible with care, at > least on some systems. But it may be riddled with landmines. > >> We aren't even using this phy on our board, so I am fine disabling rate adaptation >> for funky firmwares. > > Disabling rate adaptation is one thing. But there's also the unresolved > XFI/2 issue? I had in mind something like diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 47a76df36b74..18dfc09e80ef 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -109,6 +109,12 @@ #define VEND1_GLOBAL_CFG_RATE_ADAPT_NONE 0 #define VEND1_GLOBAL_CFG_RATE_ADAPT_USX 1 #define VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE 2 +#define VEND1_GLOBAL_CFG_SERDES_MODE GENMASK(2, 0) +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI 0 +#define VEND1_GLOBAL_CFG_SERDES_MODE_SGMII 3 +#define VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII 4 +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI5G 6 +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI20G 7 #define VEND1_GLOBAL_RSVD_STAT1 0xc885 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID GENMASK(7, 4) @@ -675,14 +681,69 @@ static int aqr107_wait_processor_intensive_op(struct phy_device *phydev) return 0; } +static int aqr107_global_config_serdes_speed(int global_config) +{ + switch (FIELD_GET(VEND1_GLOBAL_CFG_SERDES_MODE, global_config)) { + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI: + return SPEED_10000; + case VEND1_GLOBAL_CFG_SERDES_MODE_SGMII: + return SPEED_1000; + case VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII: + return SPEED_2500; + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI5G: + return SPEED_5000; + case VEND1_GLOBAL_CFG_SERDES_MODE_XFI20G: + return SPEED_20000; + default: + return SPEED_UNKNOWN; + } +} + +static bool aqr107_rate_adapt_ok(struct phy_device *phydev, u16 reg, int speed) +{ + int val; + + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, reg); + if (val < 0) { + phydev_warn(phydev, "could not read register %x:%x (err = %d)\n", + MDIO_MMD_VEND1, reg, val); + return false; + } + + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) != + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + return false; + + if (aqr107_global_config_serdes_speed(val) != speed) + return false; + + return true; +} + static int aqr107_get_rate_matching(struct phy_device *phydev, phy_interface_t iface) { - if (iface == PHY_INTERFACE_MODE_10GBASER || - iface == PHY_INTERFACE_MODE_2500BASEX || - iface == PHY_INTERFACE_MODE_NA) + int speed = phy_interface_max_speed(iface); + + switch (speed) { + case SPEED_10000: + if (!aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_10G, speed) || + !aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_5G, speed)) + return RATE_MATCH_NONE; + fallthrough; + case SPEED_2500: + if (!aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_2_5G, speed)) + return RATE_MATCH_NONE; + fallthrough; + case SPEED_1000: + if (!aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_1G, speed) || + !aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_100M, speed) || + !aqr107_rate_adapt_ok(phydev, VEND1_GLOBAL_CFG_10M, speed)) + return RATE_MATCH_NONE; return RATE_MATCH_PAUSE; - return RATE_MATCH_NONE; + default: + return RATE_MATCH_NONE; + }; } static int aqr107_suspend(struct phy_device *phydev)
> What might be an even bigger offence than giving different provisioning > to different customers is giving different documentation to different > customers. In the Aquantia Register Specification for Gen4 PHYs given > to NXP, the SerDes mode field in register 1E.31C cannot even _take_ the > value of 6. They're all documented only from 0 to 5. I only learned that > 6 (XFI/2) was a thing from the discussion between Sean and Tim. At some point we just have to declare the hardware unsupportable in mainline, too many landmines. We simply stop any further development on it. If it works for you, great. Otherwise use the vendor crap driver and complain loudly to the vendor. The way out could be Marvell puts firmware in linux-firmware with no provisioning, or a known provisioning. We load that firmware at probe time, and we only support that. But do Marvell actually care about mainline? I guess not. Microchip seem like the better vendor if you care about mainline. Open datasheets, engagement with the community, etc. Andrew
On Thu, Nov 17, 2022 at 4:03 PM Andrew Lunn <andrew@lunn.ch> wrote: > > > Well, part of my goal in sending out this patch is to get some feedback > > on the right thing to do here. As I see it, there are three ways of > > configuring this phy: > > > > - Always rate adapt to whatever the initial phy interface mode is > > - Switch phy interfaces depending on the link speed > > - Do whatever the firmware sets up > > My understanding of the aQuantia firmware is that it is split into two > parts. The first is the actual firmware that runs on the PHY. The > second is provisioning, which seems to be a bunch of instructions to > put value X in register Y. It seems like aQuantia, now Marvell, give > different provisioning to different customers. > > What this means is, you cannot really trust any register contains what > you want, that your devices does the same as somebody elses' device in > its reset state. > > So i would say, "Do whatever the firmware sets up" is the worst > choice. Assume nothing, set every register which is important to the > correct value. > > Andrew Andrew, Sorry for the late reply! That's exactly what the firmware is doing. According to a Marvell FAE they add 'provisioning' of registers to the firmware to ease their support effort. That didn't at all ease things for me because I was pointed to the wrong firmware by another FAE which led to all of this. In my case my device-tree is setting the interface to xfi (10g) yet the firmware has provisioned the link for xfi/2 (5g) - a warning would have probably helped us all understand the issue but again I was just pointed to the wrong firmware without an explanation of how their firmware works. Tim
diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 47a76df36b74..88a3defb632c 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -109,6 +109,10 @@ #define VEND1_GLOBAL_CFG_RATE_ADAPT_NONE 0 #define VEND1_GLOBAL_CFG_RATE_ADAPT_USX 1 #define VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE 2 +#define VEND1_GLOBAL_CFG_SERDES_MODE GENMASK(2, 0) +#define VEND1_GLOBAL_CFG_SERDES_MODE_XFI 0 +#define VEND1_GLOBAL_CFG_SERDES_MODE_SGMII 3 +#define VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII 4 #define VEND1_GLOBAL_RSVD_STAT1 0xc885 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID GENMASK(7, 4) @@ -558,6 +562,63 @@ static void aqr107_chip_info(struct phy_device *phydev) fw_major, fw_minor, build_id, prov_id); } +static int aqr107_global_config_init(struct phy_device *phydev) +{ + u16 mask = VEND1_GLOBAL_CFG_RATE_ADAPT | VEND1_GLOBAL_CFG_SERDES_MODE; + u16 val, serdes_mode, rate_adapt = VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE; + u16 config_regs[] = { + VEND1_GLOBAL_CFG_10M, + VEND1_GLOBAL_CFG_100M, + VEND1_GLOBAL_CFG_1G, + VEND1_GLOBAL_CFG_2_5G, + VEND1_GLOBAL_CFG_5G, + VEND1_GLOBAL_CFG_10G, + }; + int i, ret; + + switch (phydev->interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_1000BASEKX: + rate_adapt = VEND1_GLOBAL_CFG_RATE_ADAPT_USX; + serdes_mode = VEND1_GLOBAL_CFG_SERDES_MODE_SGMII; + break; + + case PHY_INTERFACE_MODE_2500BASEX: + serdes_mode = VEND1_GLOBAL_CFG_SERDES_MODE_OCSGMII; + break; + + case PHY_INTERFACE_MODE_USXGMII: + rate_adapt = VEND1_GLOBAL_CFG_RATE_ADAPT_USX; + fallthrough; + case PHY_INTERFACE_MODE_XGMII: + case PHY_INTERFACE_MODE_10GKR: + case PHY_INTERFACE_MODE_10GBASER: + case PHY_INTERFACE_MODE_XAUI: + case PHY_INTERFACE_MODE_RXAUI: + serdes_mode = VEND1_GLOBAL_CFG_SERDES_MODE_XFI; + break; + + default: + WARN_ON_ONCE(1); + return -EINVAL; + } + + val = FIELD_PREP(VEND1_GLOBAL_CFG_RATE_ADAPT, rate_adapt); + val |= FIELD_PREP(VEND1_GLOBAL_CFG_SERDES_MODE, serdes_mode); + + for (i = 0; i < ARRAY_SIZE(config_regs); i++) { + ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, config_regs[i], + mask, val); + if (ret) { + phydev_err(phydev, "could not initialize register %x\n", + config_regs[i]); + return ret; + } + } + + return 0; +} + static int aqr107_config_init(struct phy_device *phydev) { int ret; @@ -581,6 +642,10 @@ static int aqr107_config_init(struct phy_device *phydev) if (!ret) aqr107_chip_info(phydev); + ret = aqr107_global_config_init(phydev); + if (ret) + return ret; + return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); }