From patchwork Tue Sep 20 22:12:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982677 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 B727FC54EE9 for ; Tue, 20 Sep 2022 22:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbiITWNE (ORCPT ); Tue, 20 Sep 2022 18:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiITWMy (ORCPT ); Tue, 20 Sep 2022 18:12:54 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1046EF31; Tue, 20 Sep 2022 15:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fz6F+Uc+x7J/D8pktAQcTwfgZNszioSHz9AhFfIRa2+uu1OMmYdTplYUnCaXTF5OCeUvnsrmpiRCO9HrL9sbYkTlaWlSIgwU1VIwFRLnktj5Go2Jf/wA+PzscTMWo/DgHL6NnI5XBwafCmT/gJEgxWosfK/vR1xX5JTNjxRtWOcvt6PoX8PryAnDOETn3F/j/Ali+CIAwiHsjLszlzUv4aM4KVFMZHsfYsqCldoC3OF///CpzBc+iJ9hfqQKk0t7Q+MUHQoUzCKWs+8/hCLwuvNVQCCmPzMHjhhBD8K3RpX2RcIaoWYT8AUu23J3QeELcAWTUNdmn9pzxOLujTcCAA== 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=6apz+0663ewfrtoWRAeKbmoPGedQUwBkRJNtZGIpaeg=; b=SnHpgCpYzUGroFVjIYcYgXg9JtDsH97gMhvA5efOYNrUXMs4qgPuJw2RUPoVeJHIWYqppGGIpwhpBTHiPRQbSXkKfvBhnFD2emAWnc/+KtMVQ9v9CoY3UlotNhIynZNxwkl524GabW/ig6DXkOiY16zSjquxioLax0z6EgzshvBdKeMFMcTHGtvc+Amow3SJ3TBXfgZKdUWeRbYWgHWJ05gU22PQN0ulC+zg27Q6dECArLDb0BjsisSv17Eg/EEsxDIiKwxd80VmaaStlBiXxCIqyTWa/5FCRvqNSr+FIYgGBUFb7+QKmbxu2YDOA92aXZoUT5f1oTDoeCDVLYwjew== 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=6apz+0663ewfrtoWRAeKbmoPGedQUwBkRJNtZGIpaeg=; b=mktR/gEoAMm3SRgPcRzdsSLaG1/TmCM6SujzWesCg04p1mnvHRP1rx+CRCd3wNvs5m2Y867cDTXM/l6vNjlMIcbXhTJyDgj2v7hmrQpq4EU/eVPiCywIYAWUioSNeAePH1S6eIbB21bvX17lr+XWa6/IhiGfQ5UtFonepOTIKCYj+bcoeadR2pHF+BRo5DZUKctu0D7R39lyvamkwciaEGgvpPw0ZrVnB4SC7yypTTpUcBGtS6auxtX4Pwtq561SJopDFI6Y9TDHpnyOe1O94YS1wOdIkRdeJfc/ayUsp4wbY0IVvRAhOPr+HRUocZz9XThO/kRkvbjmG+iqmQxUzQ== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:48 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:48 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson Subject: [PATCH net-next v6 1/8] net: phylink: Document MAC_(A)SYM_PAUSE Date: Tue, 20 Sep 2022 18:12:28 -0400 Message-Id: <20220920221235.1487501-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 53c20186-7f6e-4da4-3930-08da9b554044 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ehj+SlJDszo3a6wWsVMVKruVBeoTAmoyaLrLR0emW+lrkE9k1t1ZX6PA/9vCcdfQt7zCqEjPPxAOfiY6Tfp0kSE3wxG+jX30zJpEiPg3GnVg7m54XT9O49JjDjxA5R3G2Piv++uIdGgMDk2LK5FNrnmVgVNCoyYxlCdcfu1XNOETI6F3WfdDEgrgEdZSTUN2xAmVjKk/+Vwq7GrRS/1mLDBmIjuWrTh2K2+2NKr+UQIS+RsumgBX+bfpRCGM9V1B5FvhholzrBg093aFKuRuL8OEyPKXSYw5nU5jnfHCDF0P4fPb6RSGIptnSrNYYqQe7Euf18x4MOCwGDt6lbDPSGTrufmBIyxLhH2Y8dW3EPaerauDjwPEH8O7KLH8dMca4AzTTOTagortOfVcpszSjXNVq5Z2/NWEhPHTxd0p6PjTITVv0QzsLHnoygGOgT9WJFkwsNkrCf2UUXbYK9ObKg/Dc4+850zRdi9Uso8NiqJ08+0PMoWgz2OYCJsHEsoAm0o50R++edPjV+JT2+OO+nZBV/mt+gFJ5+Vx8zB2NBGciJ6dan001tt3H/BIhIgPn9BXbigx/578dV8Q+VTl9I43vAR0z9ibmKMLntK1p9YWzbokQ597+h2VjhhznQvJrdkgBK8Ms+C0xqKYKo8hxwSBRQBVLZSJydxub0VVvhaZwGJQnf8Slp0NzsWn+Q8YsnflmK7zTGDTYfkICUCWar8hvi95dwbRmfUBKmo1CZXm05p5WNR58jYghTW84d8BJd/5M2zbJAcy9UdVhomd8Q== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(107886003)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pWdAreTjRDUBv7KD24F1XRjl2mpKFi6GNkmiEWZZVm025vEbCIycrG/ExNGCW9dOC2+WiEptAgaj2Rp023HpbNSkKXI/NLrTyM+PdfpDjFHp39h8yLWIgrz9EY7DPOs1/ffPzFI0k/ec7d41kbrj2/Vrfh8hxxCaWVTG+M9ODGTrQ51rmG7wwntNLqNz5xJRLfTR2NEj2vBVn6Lxm3jGs46Ui0M+97KKoXGjA8j2En5coWq/un0exbhMNYtm6UAQ9RTlS7Fcfcf+TUmACfkQK1YNqd3NBVo6bR+26/i/ZOS8BMLrlN6Gsx/KuW31cXLKinB2UD0vgYjrwvXP5zBk4jRm7BPaqSwKMf9CysffI+4V8yEaYPTqzCXQ8r4IcjV702BrITmbTI4Homx1TKSULIg6q/B+WJ2lyERTO8YO6xZLtyCc06f0PEedhXqc+ax7r8SQhGNcXFbk140pbvizm+NNE04dstJo+EapOh1c+HmkxM2VOHStlEPixAuKu1caHUs1+edQ3QhFhEwUV8sOpfj2TYCmEXqdqpMiGR9mHn/Vt8JInUEqV/wiv9KzHk5Nq2875VUJDOjjim+wgBEt5rIM7l6vUfA+9wT4+cczAOpAgfJCS7u8Y3UqNoWNCsx2g6lqwabVVcMbpgiUoNpk4QimSRBvpDDyZmqFQaMg8qRcQQqHTXf+cuGFX0eqX+ELV9z3wKCiSsN20HgCpRwGvkxkaLxnM+GqXEB9phQg4Bx+IZQh/v8zBNOSnrqMe2PZwocFi8dW1p2UXvdLyh3D7L4isC30LJ+GEs9G6M/w+6ZHMjTFxpmzkaewt8JliS42eahAS07yfetGrKxpU3b2n1aesDtwbftd8hYBX8itciOrZs3GRMOGQGFsICBAGEtlrdnwGHGyolJLDxwjh5420kc9vEr6tcayXohaQMdLM17jsNRSml828V5VoV9UjIClG6PYZh4ePRmcnY9a2XlMI8uJD9s82EMSZp8xJKhocgn8Fom+Um3CI30u8CQEL3TGXN9eVPC8gQ+NfXdZNq3miSBV321fn+dd1aQuQKf0TQ4SxPX0CUeGjZFNDZ91QlhiR8NrsbGdA/srxbwXyN/Tb2sPybWUyFtdzVD2PxNKxlOAdtDtJHF+5/b4a6cCJgoAExuJQjSLa97jrhzgthJurB8wfwmG85KHC2DZ0OdzxnSCMPBdmwYDlBn23jfc1NYdbj2JAlz4ic5KkVwQKiyuJcS3dSH6cXqauKwa+w5YxnhnQ+voU9iqBLBHXdiUUUZ+8MG34XUF6EPiTYFtXzBJB5/mqcWSK8RVr+9kVxzTRzGlzV3X3+SLIA5ybXCqlClbWRn1MRPm0DcmIiKSORbQ0Ky9BpLcnRnvYU348e5XYqh2tH16YmZCYViKKkbCrO7WvoHWYJ39ioqAehBJouanJl7r0i7ajRP8KtVMEBA7ULyQxtJ0O4ijxjHW9CJSe76BGzreK/6TPBSoWWADMi64+8CWR8oEVUWgAU8yurDejFuMr5HkqWKq8ssdVenzDIe4VQIESzH2RreAnMFxBDF2E56O1ZnphE+bgeZtsn85LJFQTO9wCeJY4dTjTd83QtIWq3Apzd3k6nRLtG8BDy+eYQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53c20186-7f6e-4da4-3930-08da9b554044 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:47.9866 (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: 7jxOchBr6qlq47gjUh3yqGsq8UOg+OfKCLX972YUrNjCuUq8+utG7qftXKqnkIO3LN1D93+1C9RCQtlDDshY0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This documents the possible MLO_PAUSE_* settings which can result from different combinations of MAC_(A)SYM_PAUSE. Special note is paid to settings which can result from user configuration (MLO_PAUSE_AN). The autonegotiation results are more-or-less a direct consequence of IEEE 802.3 Table 28B-2. Signed-off-by: Sean Anderson --- Changes in v6: - Reword documentation, (hopefully) taking into account feedback Changes in v3: - New include/linux/phylink.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6d06896fc20d..1f997e14bf80 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -21,6 +21,35 @@ enum { MLO_AN_FIXED, /* Fixed-link mode */ MLO_AN_INBAND, /* In-band protocol */ + /* MAC_SYM_PAUSE and MAC_ASYM_PAUSE are used when configuring our + * autonegotiation advertisement. They correspond to the PAUSE and + * ASM_DIR bits defined by 802.3, respectively. + * + * The following table lists the values of tx_pause and rx_pause which + * might be requested in mac_link_up. The exact values depend on either + * the results of autonegotation (if MLO_PAUSE_AN is set) or user + * configuration (if MLO_PAUSE_AN is not set). + * + * MAC_SYM_PAUSE MAC_ASYM_PAUSE MLO_PAUSE_AN tx_pause/rx_pause + * ============= ============== ============ ================== + * 0 0 0 0/0 + * 0 0 1 0/0 + * 0 1 0 0/0, 0/1, 1/0, 1/1 + * 0 1 1 0/0, 1/0 + * 1 0 0 0/0, 1/1 + * 1 0 1 0/0, 1/1 + * 1 1 0 0/0, 0/1, 1/0, 1/1 + * 1 1 1 0/0, 0/1, 1/1 + * + * If you set MAC_ASYM_PAUSE, the user may request any combination of + * tx_pause and rx_pause. You do not have to support these + * combinations. + * + * However, you should support combinations of tx_pause and rx_pause + * which might be the result of autonegotation. For example, don't set + * MAC_SYM_PAUSE unless your device can support tx_pause and rx_pause + * at the same time. + */ MAC_SYM_PAUSE = BIT(0), MAC_ASYM_PAUSE = BIT(1), MAC_10HD = BIT(2), From patchwork Tue Sep 20 22:12:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982678 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 10037C54EE9 for ; Tue, 20 Sep 2022 22:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiITWNH (ORCPT ); Tue, 20 Sep 2022 18:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230218AbiITWM4 (ORCPT ); Tue, 20 Sep 2022 18:12:56 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F597823C; Tue, 20 Sep 2022 15:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AO0/TyLt01fZALMNLiv+NLyvG+bneENZzqTAo9BzEWdxFsVNcZR4f7E3aIRGD27QfG/s3FqQSSrSwsTr5K2EK0/MI482pqamT5dhcNV34sCRbzc4HtKZOhsQOK80fVtIgtNiwH7zPul+y2hkdw8ft6wTj7o1E2Pdoa8Cb61n8tj761PPUkGrcw9Ueu+n/KNwrG2YD2a/hzsotGl4dHLEY1euD9/q1iKWiMSlXZA6b20tQwqYUmgDrf6CiDCUXmC90lA3zAXJxs5/+1DgkJ1vvbttO/bvOndW8AH5SbitZ3QCTvrD9o8q3If7URGUbvgqlkSGbuSdHSaYyo9h68QbuA== 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=NaYsVKs9r9KfgfIMpIRhZvi8pdLuJebHaGka+7RepRI=; b=DCfVAHveQ/jYPZ7v3XAPkK2eIzxbaXe31gq5ZUYS+RxyQJ40oEUsJ1ncNwZWZsugOTDpTHjp2K5ngpikqBDVnA7AsUfJITQG1caCUCKx5c5c6vLP7XhfzWYVVzWF/Ms8XWnj7qq7gqjq3Z74xjN839g85F1G2iNmvvMfE47+mzcXjE50fxOGeNyrqppug7esOJJBiYfgEO6HQA9dnj3PbL+8isPkz48ZcwlxIsYCD7ew8tt1R/ZtOAZWD58cwo2HNyfODV7M64eBMUBmh/UpInt57oJTwHRWztGjO1KiHQqaY74xT6blpQxPZgsR1WwOiL/cYguHKe99TNbdLSYuUw== 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=NaYsVKs9r9KfgfIMpIRhZvi8pdLuJebHaGka+7RepRI=; b=gcSvBPnoaE4pgb0gkCm9FBlzhaQLR5LX7vE1SRLo2tclAbm34bcSfRw45cM0A5yV2kc/79Nhu8WA599dMRFfbo+MY0nJii48gAuWg5TMwdc7WpKEepfioMCY/CGxBz0mS8LD7BSF5Hu+yTm1hgMdUiyUadDN+GjBs9wFPJ6459v/gXfio9umOmWAUFzh7D9/9bfTu5CQWaikZuF+VggQx65F61mcxRyH7loPC/1seECVymtSJ+MTosrrSM3Tra0iJA3ksQZRaAYHqrJvfeAqLfd3VTMvDjYPUKp3XgT8NbmEtEJDX5DRGXrRMuHS2Ow0WyiwBHmZ5zbpImEe2lj4Hw== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:49 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:49 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson Subject: [PATCH net-next v6 2/8] net: phylink: Export phylink_caps_to_linkmodes Date: Tue, 20 Sep 2022 18:12:29 -0400 Message-Id: <20220920221235.1487501-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 76eb4337-0bec-48dd-a22b-08da9b554113 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8Wn8kISpcd8NYC6xdAZ3plzg2JOgJ+2GCUB50ZIDpE+udI6rhwnJoJBRHvpYk/SkA/VLC8Ls4hHrmniITKlEWKk4913xleYHSx5wG6pWh2bt7/ypTHLNVRWssNBVZoukye1rFOy8nbF8C9dWycLzovV1fMJzOamcp5qYaH1Sr7zSEmaWgCZgGuf0+7JGyHulwsRDbsFrSEqHfm+13uzu/gV027mgE8cK9PrbTciXEhoX86c7JlsdYMNTKXPkhibs6jaZRF76k8P7o2q8MPPQocA1taR3VBOv8jHuNkGcDrFLQU58gtvcug49cT7UdohaU31d7AVKujkNOpLwsShaGCh1iOxYfkST5Y09rTJOzNwLpNcJnBuoguC/yxRU9zzfRBHPNYnyxLTAuAJDZv+urj5mXPBjxgtp7GajvNxDy5SSE3n0XohC02EnjbAYyWSLRCFbz0hjAPTbPp41tJ35jjtxfJ6S1V6CzjJyW8UdhET3gAI5HlRICk7AMdC8XoKNCyKFx/UcvPX/TLMJDTCFZWcQQi5nMGj8ATI+Qcls8B9HOb2+dmiAQ1/lxhVrGXD0oa05af1KgPq7K1rX8sF+7xL168JOcLRjFoL53d56FJ/YsyA/u5Gk+JgXYGnS+ciX/F5tGk7x4HJvYC/OuP4lVfCNAwAdeLybTeVKZ9uBhf2SGi7Z272j/uwya6+m6PKjI4cnjehFjdwF8G7ASry1J9RVzV4uUiM2IW77kinjvnuhUvz1IKFKme7ofB38Us00XQGiyKgo2A8G1ynNvtevZg== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(107886003)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /hHb413YzabwH1nMf6CD3BmQ04YqFMdPxMdsCNeEY73IQShcAoGCupcpK5YOldj5y0ORfPM09+14WYh4u6akwrEGfpMnK16BqdNbI297m6RP6TJTTwMjIK0Yq6j/vNE14jFBDRskCLj4RKstqLwLrwY4FXd+UfzuuSCi3YE+EXPm0kox/EtD3RiWabps+Jlrsy57fM2HIhbWrRjf+LvxqODrQT41ZmrxdgeYn2HVu2jy1yM7njSuVYFKFEm2JIa75TBnTlMM6J1uOv2knMA+hEVWLDByAUJE7p9zuAmPI6f9yFM2I8cy8SfgcD5Ml0qxhSVuxMD07KtJP8EDX/zZi+JHCXs66eutErqCGneMca9BXGu/9Bmz+LjeNSA5A+4gmje9uV9DM42cQFWICJZv4qg5AS4NY5kSkgYT63+b4ypeZaPb0ZHsZy/xU16gKvZ2NDeav2Psh3l2yervxRpHvg0fJj8FQxi+UA9M9z8/dHEe7rZGHyQtxcQcGK6zlLrNz3hLnnv4WAgOjxcd5WVVzjmQj/ofn04zFYBTvlEhqLGpkGFXzikyycf+x+bJ6AljikQYJVAaacsVLtHdDssCu+gqaOPNWxgO/j2dJP0bR36NaVWprLUH5QgPMS5CBtH0boUDeNuv6uzJCbipzCLbYSZRFOAMeh786OgXpli628O39I1pEIjj+RNTxDzsVDtXc9mXuSIdoHCqUJuwCNhTnzlf88O8z4ifSOUzdAv2kKt4avzCuN+8gueOQVXAGEfbe270Kr+8s8okvDMEbCmkMCPc4vms+0wTS5X8LEyMnNCmJd1OxtnbbZVW8v58LcZBc5bYiZapSUsER+tWdly+uu3Zehkoe7FVYbSstYsTpoCfPwK4G3GBbfInxs3D7XMBAaFIIYtHJGU9vh1MfjPP3LHslw96jpDU10OFRHmuf4oLjDLIL9xfOx0OgKC3zrzm+o+P2mLNCHy9gBI2eijk9yNivonzB1EPTllG70RfS1Kk2rNXIv5rGAm4zMGn4Xx8vr+AnZ8nMZxL0vYqMU4dR4djOc8Rm8gxrv59m0Mk7PkO+Z9pVgh3HGZ4oMiOxfFK24q6xCxRYiWuDlO4gaBHKUUW0KCRK2cY+0wA9htH8BOvJBwbBJYsY6ZVxEoG24ui3QwclFhhFdRanp76IxM3+3QISulLWOYMcygFOgl85TsdtlROdysrVVGkM4/cQKm2OcHgt+8vAa6Ukv7JtMOeXEK64PUMCG+O61qR3uZBtLqcxPSJ8D7Uwpfly48DeGodP5qwFRygqKWe5N2Iv1HQxq0+sZXTgWsYy+feB2/G9+gufIws4wCkT8uyZiSfqwJUBVuLAmP8nphZDGokuSp3T/LlX4C/P9BND0SNGnQrgXmucc48nieV86voAB2WovqzsxnfGMFOBcJKex8ZYV3YxgSjoQSxxJ+aTbh0h1JYuk0UDz8cjWWWit38i9KKrjkd508WFgos9d0AnGyW5AM2wSOjk9V4oU7P+r/BNXabH+Ny4FlMOSRUOIplAZiYHUuiYkZRHcpEmR0XqISl0H0zt3dZAL0WphU2is9hocqw11u7YmaVn/W8Z4RdCUM6xHG/yJjtQYN+LuYFP9Vrim0RlA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76eb4337-0bec-48dd-a22b-08da9b554113 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:49.3615 (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: x2TV8D8P+zVlf5h5JMTdznSDLseEOqu21aY7BrDtkoKNhNyzy2lcd5QPvzYWtj5LyYkATCgA7M2rtaOSpn0xJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This function is convenient for MAC drivers. They can use it to add or remove particular link modes based on capabilities (such as if half duplex is not supported for a particular interface mode). Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/phy/phylink.c | 12 ++++++++++-- include/linux/phylink.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index e9d62f9598f9..c5c3f0b62d7f 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,8 +155,15 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } -static void phylink_caps_to_linkmodes(unsigned long *linkmodes, - unsigned long caps) +/** + * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes + * @linkmodes: ethtool linkmode mask (must be already initialised) + * @caps: bitmask of MAC capabilities + * + * Set all possible pause, speed and duplex linkmodes in @linkmodes that are + * supported by the @caps. @linkmodes must have been initialised previously. + */ +void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) { if (caps & MAC_SYM_PAUSE) __set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes); @@ -295,6 +302,7 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes, __set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes); } } +EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** * phylink_get_linkmodes() - get acceptable link modes diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 1f997e14bf80..7cf26d7a522d 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -547,6 +547,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); #endif +void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, From patchwork Tue Sep 20 22:12:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982679 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 8C0B2C6FA91 for ; Tue, 20 Sep 2022 22:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiITWNL (ORCPT ); Tue, 20 Sep 2022 18:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbiITWND (ORCPT ); Tue, 20 Sep 2022 18:13:03 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C84F67823F; Tue, 20 Sep 2022 15:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YZOdRn0hITOkoX9+x/IfwHJzolaCSKt0w/71TpMme3y6ALNVmZe6ob1jayBgkQLxh0UYHXeTb5GOS5f+Ilu1/gEKBduKSL07/XMDGkJzXjOGAteAD15vk5tOn+/izQbYJFhd6+Ig8RuuwxWSlXpwYzUovnNiktjflmCIQWmam7jrAN3TlgeM/hDZVGKwCi2wPxHL3l96PbA9NL32POyK24c1STr4gD99XC8LvA1dlAu7qfFMd6VZ9x3eEB8uXZCulCOjABKJI8/FVWNNw0Jlw5v60noRmdfvRMfBM8v71n1uSQz3qis05jqbvxZTo3u5UimJhuRTlJS1+60bm6nDNQ== 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=9p9/gcvaRGgI23Z9aVU4mf9+CgF+4Fo3AzUvtoGWAgg=; b=T7WBjizQ+DArrjwcybOgVMyXbQwLnQ7C9F6wPIDTyj5ZhyX/LLaiXiHy7oCD6aQLXJQ5p69phQiKpoANKp8NM2rfjfINJLtf9C2KwTW04cQXBby3DcYNPkWvGwrqjUZFzO1EnLrPig8TKP5u13fOjqPDbKDagJUMzIsL3eOf+EZQeL8C8P+J0ZLxPkzfuMOtLTSwTC/0KLcEDjRTqjNJObxQ/XBgi/q3f7hZ29ejD90gO/+8ntWd77mvADDjtparqcDuxikEOgkVGejhBUp2wrTAL9/JjskkoWDi9r4IiQ4U/WbYXn12kidoyyNrC3nGPrFOxfa/LaQbGl0nS8rnMg== 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=9p9/gcvaRGgI23Z9aVU4mf9+CgF+4Fo3AzUvtoGWAgg=; b=gOa2+CcLlZKEcCRQ/81mrlPmSa/XyJgBcZtb70Gg8zVGDxbYLMC98RgMITfu5lLXzn12wf29goEUP+BbMsB5gX874RA3BpXzICtbrXjW0jbSOnthBtHWDn6JtZIdI0EU0Gt3OlJNe2BO2nBW+FSiuQvLWIaJaZOtSSQ0JoyN84+ruW8V0l5Jta7AcN6FCMMgjoDTVICxiQFz8/E9dAKzgEfBd74YxWZMJxTa7EKyRYFWvxFrmjurqZD9wuxrAz1BR6XB8E63t0oVl+5ZgzVHoYaPTeA1iEOOZfiAliec7ZAkO1Gpg7Nd1fSR/8VsYToLIhZkNC/jyfpAXwQsn8fxFA== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:50 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:50 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson Subject: [PATCH net-next v6 3/8] net: phylink: Generate caps and convert to linkmodes separately Date: Tue, 20 Sep 2022 18:12:30 -0400 Message-Id: <20220920221235.1487501-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a32aca2-7369-436f-0b38-08da9b5541e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZw+/sXnVl9IGVoFEs9QGKVKZ1jjrzBMHdhZ4NtYTBIJBo2HcHcRhLIXrrPZnsf8qg9DKspf+kyxgHqPn7f5V29S+M7/riPQr30ZFqPvgP1A2YBPHwjstC+N/C81zTEKamvYlQjfrRvhM97ennQWPWm2XPJF+xGPFQMihCgXMc41/VBwAgFQgz1O7N6xRquJF0fBXcZa3iQoh3QSKSDvl1qLKr2YZPRxCa+jjUX7/s5Aa1fq04euKB6AJep1s1CQHkDg/+FRo4kROqytYIOLgqXzA/ddpBA53QABNZVWLjzzm21h1tCcKJRstKdJZOKD2Jr5jB+Hxt8fQwa5Wqdg1/sKEkMqsgTO3BIT1HwGENj0rOCCh5qX+d9uTNVfwwSYSkjesW95BW9krPzSpvQL1t6VfPzIvogPvSi7RqljBFMSnDI48bVFlVAlFDQMQCgo7hdEelz6fMb/miUSDN9xxSoNTMLXuLhnTxHlf+WEIVocEBIYIfWPSiXCNSVkuImpNu4oFC/0T5K4f4K5X6iDiPelcsbtyRkwoXfl9P56GUDmKw1SOV9w6wFNcTYSQPHHoXfDwpS2Zmx7+/3g2QlgZqB8o0RvxdkpTpbsvMlZ8G/ePqnQX2ja5U4P000hi2w97jcr1QIYdUVgQds1EuIEwGZ1cEtEbhMEuQTbsEpA7XpGtonhN2Y8y6+8Qr4Cq31x5S5ZtINUKVeDsSO99a/8LkfJDOcDow/ROTco0hqMjO988jTbLUWwfpIxDmKmbHenVxHLpALx3kAvZQJyLPrlJw== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(107886003)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SFBKb/emaltYRuris5D+fRfz2P7nmZ+cvceXudVtR+EC5hZij01bzkYkh4xkLdpZe/hVIonUEh+RGy2i4sTGkAZhEoZtEVGbZaVv1LStCz1BbxBRcPV2HVGPws4h+Jk9dYzxu3g2BfNl08j/DG+DCwpY4Nm2Qiq1SPTIRpBnbyCsoVUwIu2i8V4EkZjXySqeXmAOHVxId6dh9QkAF6vRHLQYRqB4gsO9JOX6HKCeWgUCJ9oQKCWIK0Tm1Dl4sgWLtwGQor6C5TP/yZiJfEByWQDbSJjKz8XmxHZmDgVwF51Zq9X6ZuOgnkps++SDAxbaZilzLFAD1WSzZQ9MHfU+sE7jLbYjd/1u+ekEm44WRhlv7JUr2VFiez/BC3erAcVuFsUGr+4IQM4FDv+ow984Aj1B6ahTMofOEGiabgn5icaxCvFtiw7pe2qYGEpMGWe6ZKMaX10oGGZGmdNLJzYSp0PL0IBpciiBnZkZAkQ3su7LL9UKrj/StamoTCQMyGLTYIMw5KOqtZ3FmZOzqFSMsdPz9xvdLF9c43iAH0GOlqBasi3zZJ7q+6uUepZImzjM2XG00rZu3aHD/vTe5hjyb+iGq/i0UnRSCM3S/nmLODv8257UjX9HkUd9VNZC998LpVY3mPzgGuzhAWJfcezmWYfwLgnu5B5fk2FL8loxDOoN58E/zdCSpSC0y4K4UJTuTFtkUQrUpB5/wRwpI2m1x+YOOzmaHMXtLnkrsYTgwM1ivchVzMMGRvKXdqVClS9Lsl8RNNlsjFCNjRfxiWxuwiGM/IZ/5YsU9LLKw9+sypePwHjARcZU8zBloRgV1zgjq46QagjX1Rro46Nwi46tm3SQHQ/v5D3vRxedl0bi0Dli1A95zC/zTyZfl+C6+2UHNcWsbgMC2bviuZ4uJSIKYGlT2DtRQnRawoxfyNCXJExXQJ9f4B2BMc9VYKI3I1hzFidSk9VKT1K4e67pjI98VmGHSfN0BqNKbtBxTmRb0e8YKzQJNC8sngrcOQOYpiE49kePcpNwgLL7VaMTnbhEKtWBXtx6hmPTdcGzRLrWdt1pgKukT8RxsSV4Vt8IT6O9MPKUr246SRrB7YmIeGxpDgxmlzishnH9aGwi4FLaPe/oth1PllQlhR2dJ1H1BWUtz66RTOnE41VhFddgOvms7XzyoYcl9Lqfbct1EeAZJ/220TtObDA5X3ycLkIJDXggYpDMRILMHioltCLVTyQs/no2SwGRa1OGtNMghPIjkeUtJC+ueXSxSxJMf6HW3e6kMnyDyqnFQ1gO08maOmSCB7cqCfWiaWRhWESOmIgkV1J0zDdYpL20byefKVcvowqGj2qYo2uyQ7Es8un/ZP5lUGsFBYjtCCSNgquVH0g5HHfZZzekf0Fy39hTSeFCZ0JEaFK0X2gcA7PTHE7IGr2ylPF4acR3xrqa2KaOzWr++gEeHqASP9GaMPEqIVf9AlRXoh3av4GBpdODrjaoADA9b4ezM3c0d83G6g75SE5EYQ0oY/tjDut+FAa1tgWQ4/0XB0eQVq7K/2AzQlKojd6WJXLeZ9fhwek2UqsVM9+mpMB9MH4skZalh7BTNhpB+QAL3fqgNLg8EdxHR2GJtjKDLQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a32aca2-7369-436f-0b38-08da9b5541e3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:50.7364 (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: Oi3ikSKNBKqABeCYDGGIOFnV2Z+UJeeeJ3fel+H2ed5zuPCxuJn27FOxDn0MTKzXZjhLbwLwDMHOvtGjZhhg4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 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 --- Changes in v6: - Merry Christmas drivers/net/phy/phylink.c | 21 +++++++++++---------- include/linux/phylink.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index c5c3f0b62d7f..7f0c49c2b09d 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -305,17 +305,15 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); /** - * phylink_get_linkmodes() - get acceptable link modes - * @linkmodes: ethtool linkmode mask (must be already initialised) + * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t * @mac_capabilities: bitmask of MAC capabilities * - * Set all possible pause, speed and duplex linkmodes in @linkmodes that - * are supported by the @interface mode and @mac_capabilities. @linkmodes - * must have been initialised previously. + * Get the MAC capabilities that are supported by the @interface mode and + * @mac_capabilities. */ -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities) +unsigned long phylink_get_capabilities(phy_interface_t interface, + unsigned long mac_capabilities) { unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; @@ -391,9 +389,9 @@ void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, break; } - phylink_caps_to_linkmodes(linkmodes, caps & mac_capabilities); + return caps & mac_capabilities; } -EXPORT_SYMBOL_GPL(phylink_get_linkmodes); +EXPORT_SYMBOL_GPL(phylink_get_capabilities); /** * phylink_generic_validate() - generic validate() callback implementation @@ -410,10 +408,13 @@ void phylink_generic_validate(struct phylink_config *config, struct phylink_link_state *state) { __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; + unsigned long caps; 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 7cf26d7a522d..cc039ae7e80c 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -548,8 +548,8 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, #endif void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); -void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, - unsigned long mac_capabilities); +unsigned long phylink_get_capabilities(phy_interface_t interface, + unsigned long mac_capabilities); void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state); From patchwork Tue Sep 20 22:12:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982680 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 63A8AC54EE9 for ; Tue, 20 Sep 2022 22:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbiITWNO (ORCPT ); Tue, 20 Sep 2022 18:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbiITWND (ORCPT ); Tue, 20 Sep 2022 18:13:03 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFFE7820F; Tue, 20 Sep 2022 15:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EKsyU+v4yiZ0ImVyYBTSWJRVwefW5wy6V2sXnV5zUQAr+XaKEF5R9Y8TUyXmibH7na4ZxILR/Ymj/uKQpYY3F0EXkBUbUZbTg7zcYgwm5LZeWTq/vH3qJBoP1J4P26qXf2mpNiQCIylsS0V8Q2z08s7dyvfbc04gopOQ+NFZQ90u89Jhy5c1wKp58DXEsGXbGi6DJDTmR4uPRXFY1I1xvSEVq/xbnrg78/Ej0lG1JjQSstS5zmC91j4A6l8CVieTxQkps5ZYapdHVmhjoengq0vqqNmmaLGBSo6n5FUHbsfgO713mmNWq8ofjoXgQmTGQiQIaKi5E1l9OEkWS84sDw== 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=/5K0hzmaZzN6bSEjCsP4V2owVLaqDc9PfcuemAwb0l0=; b=FDmIHt2fVpSDa92L1gxuKPfBusgvw5IP2h+9+ZB87mbxVrOkiEZCPsvz3Efb9XhuKXxAO/TtV3xa/nNkAtIZeS2QczM4HWjV3TDx8poom1HN2hCRQ4X+dXKFXH8o+jUnd2jbLunZGLxfxihzAs2oPKKElnr1SCollCMKHmmCtWP7/xF1u80GQnmrFNyt79oXQMpP+gWKgjm25DSZpOwlr/C2G8NihukB5130of4X8Ba3Tp3HbVtiVYOFIkFJQDoyliVOQoE6jpF/zLv1JLuZMZ/5EP2ffh+m4AbPl5mR3PdqTRiOqQXn06zQRb8bkzXJjf/C2Zzmk4B48R2eAAAxUA== 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=/5K0hzmaZzN6bSEjCsP4V2owVLaqDc9PfcuemAwb0l0=; b=kwun7EeoikwkW9y6XzLCHK4a8ucLpe7x9bq2wqjxWFaZqL+VfHn7iwPbzVL9SsOADSup1XVYMkZkgq+eN+HrdR89QaqsPh+wjV16gGU1GVEixDO9OmU391zoL1rxOx21x5/COc56hbH/G7CwYG5Vc5v/gxLqWAshmkq+5dPoE3/ArJgpxTxo1OsF/kQcdd8RpkZndPoJp3bp94kbEof/XbsuLapUuCMiyhjV0wnptXfoUIDUo3GtZZlYjH55FGalJObclB/MDY/O6hf51hB5jZFvkTgfzHtMiAj82ujCFPmMPOvYycBtO98lhybzMUIgsXcMQPun3BWQjBbaQWvrIg== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:52 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:52 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH net-next v6 4/8] net: phy: Add support for rate matching Date: Tue, 20 Sep 2022 18:12:31 -0400 Message-Id: <20220920221235.1487501-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 36b62ef9-5957-491b-0ffa-08da9b5542cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: caql6kLrz6Nj8HtdP9xFiO9gz3c6boJG0k/0FFSnXyLfAksJ7+FpuOXfY8Jbf+kdDFlqVWR4EjozPHUfki7KP51lyQtVYmQKM7N/Iu/tq5G35xe6jRt8hb3pdOknnyDy6aGCq3LUbLATvtCjYsdZTL694gT5BumvBReWAPDqtGmUb1Mdl0AT+Rfg7YEn+99zKPkEJ6JQRmUEYgP3sY5Ds1xoAjoaSUrnrzobZGk0i/8IIb+EvtelRn++UrmXz35SG1IW6eBBJUPDp4xq3s70cWAX9Yn8b43YmERdIn6UJXL2iBqNJ2BYTdVdQvClEc9pThviqyXG1chrNg1Nb6JoyjhdTc613qFyPWMONqkT6gDEnJo2WNprv0/UIN/wlbgwh490PKsStOollkHsSG84IsmNLFsluu9vD+uM5WJrAOfT4Q7wmC/9+VH8B4VlIx4G2qUjPy03c2hviYJDX8q+jg1CLSO24jYQP6A1y4TjUOn0uT+9rOmq+uboIvxekgu4Wk7ELex/sm5tW4QDW9KIIrVRl0c0vGep8m2zG2zfHh5a4a9BXVxNBHZFiPFUsoP9NjV2KYXZxg8YQMYG5sGedeMQ/t05glXAuXkfXp8UWHwxoa6G3Twsjvz0sFQfDSeVrsNPTAn6SkDBr/xraOqKPpovc8/Q4u3xrG9+BDtylAeXBEC6gmhOscLZC1k05BHSg56kyy4KAz5nGGCgKxys2tShTSppbKjkgSYyhzjeSkRyOvhhmJ3APcj6ktlBpghX22+jhSpu8l3dpQwXJRb0mg== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(30864003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gy/KYm4cW9/P1vFKk9iMRyMwB7/4FPxSvleOEcwfhUhSEPus2DgBwIxRqtup7GzEhRPj6BMOlZ4kbGTyPcsc8OebNtqRVp/bOFx5JiAVLvhffJxkNAKKMJyXwSfM+WDEXq5W+TPUmZ3u8ZYA6LmOeMLjAp8sCS5P1GRNyA+iS8PAxPJs2gOUqyFqScn5Bk829RLL/BH/AjIw6vOkqkh89oBqMVRqGq0DaFw99K0UeyIFRSnKAFFpgXooJvC3cUcBv54ug5lSP4+CTN6KxY8++0SJYPLFbs/a9rFC2fW940NjvbFMx5530Ce67eTwwyr3pUQKn3o8YFXF7YSkuw9JFp15Gm9XsSxX9uwHmKA0KZtTfDklmIojaV4KaYlmlZUBmKO1y66V6gSOJGNUs8N/RV5w5rO66c1OGjsnTYvN/3qmhOulMVOlFmgp5kEEGGVV5cPPZ/aQAttV7egQMbMti09aBilLoAyq9487PeO+CwolxsqMkoAafpNNwBIKVL0fdSNI75OHjYG5PQYSe+EWy3KTl5p2AfHNW9I5NmvKPcTdsPuLYfjSgl9/3IqKkYDYVYTyzUlAKgEYsRmUKEhPtVg+mixV1UspWpoRY582izlYJZrxtcVBBetTJ38b2+80PJo/mnjyxfbhXPPXxeaWAJ05EWmyXp1jjoZGlNBvtUoDQq/h/cGVzlWisKNFCKn7M0YXCVLDlvyilBj6tZGZfb8q90m3Xun8jcOYnwXcxi7/LKStgOlxx8AVqjNmaVadkjHF0WjT7jj1/PYzFjY3pSAoxiR4QboF2E8hMVkbWlzgih7gZZEIzYW4/1Yk/pDiy+SxaO4IQCbZtQw8xxQChgA3sMLDRCqSnsjWlTPV32/dCjpYuTP8bJeqUS2iSpUv5G57lnyll5VguhX2QozectRyciUyJxbexRUl5J5Kile9nFSQYaGJT14roju2oHr933S567BoXYU75kYlKs7HFokt+LNTQ6i7wOXaHXSf+B1gdjA1OeN5QXrGMVA0aNysPJ64TPAD9EWGs8+uVqDXDq/k0qfOl3hb1WJMA+YVTqPOCw4su3xCigHt3+5KpDoL4c6KGOWE/B0Tj3HIL0WeTJeXdKKyDdpqyto5lZ05n+wgAkC4Okq/Wrm18VtdJ9APFrAHYz0kFjfYY92dd/Jqs2odjyCQZXDaVaHtACAMX20JwXryl7ZnpfokG8xbsEv9Ce0i4hsUW59VrdWWloo8LLcRN3LLr7sbXeU+3JIpwuFZ6aVsn413JHSidaPd5uG3AeKpc0iU3ZGibfUgotd2xNiPfT38CzTU9sYlaJpiuZuLNPeEzQ9f1AmdByFXLozYWjYOPz7Q+JV/atqfgqKlRcUtb31tXwmIO4uvMBRcKxqFMGrniWwx9wQD9WakaSe7caxkcgVUY0sxjv8EGKx5/DKxsbWQx39216A64r39Vh2x4cc4EPX/Ammdvp/0bF3yYO7h5zqqVIsrcTPy1sCnFBpFsv06lirp9mNqiOZCuPFA7ExLEsrwHv7pfrQLzq3HLK+3xxLyTjLEmdGIvz91r0H5S2KoQH3tELPg02DBnNdjeAgzxj/Ufl8yku88S8EjkSvLYMdjpC8z+jgc+gFLgQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36b62ef9-5957-491b-0ffa-08da9b5542cf X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:52.3144 (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: gv/1vyApYZg4acc7fbr4TPR/DrEJEdurK+BhV1bIwcuSaJd2mvlulSsJdocOgceJmYFBUYbx4jA8jqLt8BmHGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for rate matching (also known as 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 matching available. First, it assumes that different phys may use different forms of rate matching. Second, it assumes that phys can use rate matching 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 matching. Fourth, it does not assume that all phy devices will support rate matching (even if 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 matching, then a bitmask of interface modes supportting rate matching would suffice. For some better visibility into the process, the current rate matching 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 matching can be disabled altogether by adjusting the advertisement. 802.3 calls this feature "rate adaptation" in clause 49 (10GBASE-R) and "rate matching" in clause 61 (10PASS-TL and 2BASE-TS). Aquantia also calls this feature "rate adaptation". I chose "rate matching" because it is shorter, and because Russell doesn't think "adaptation" is correct in this context. Signed-off-by: Sean Anderson --- Should the unimplemented adaptation modes be kept in? Changes in v6: - Rename rate adaptation to rate matching Changes in v5: - Document phy_rate_adaptation_to_str - Remove unnecessary comma Changes in v4: - Export phy_rate_adaptation_to_str Changes in v2: - Add (read-only) ethtool support for rate adaptation - Add locking to phy_get_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. - Use int/defines instead of enum to allow for use in ioctls/netlink Documentation/networking/ethtool-netlink.rst | 2 ++ drivers/net/phy/phy-core.c | 21 +++++++++++++++ drivers/net/phy/phy.c | 28 ++++++++++++++++++++ include/linux/phy.h | 22 ++++++++++++++- include/uapi/linux/ethtool.h | 18 +++++++++++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/ioctl.c | 1 + net/ethtool/linkmodes.c | 5 ++++ 8 files changed, 95 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index dbca3e9ec782..09fb1d5ba67f 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_MATCHING`` u8 PHY rate matching ========================================== ====== ========================== 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_MATCHING`` u8 PHY rate matching ``ETHTOOL_A_LINKMODES_LANES`` u32 lanes ========================================== ====== ========================== diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 2a2924bc8f76..2c8bf438ea61 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -74,6 +74,27 @@ const char *phy_duplex_to_str(unsigned int duplex) } EXPORT_SYMBOL_GPL(phy_duplex_to_str); +/** + * phy_rate_matching_to_str - Return a string describing the rate matching + * + * @rate_matching: Type of rate matching to describe + */ +const char *phy_rate_matching_to_str(int rate_matching) +{ + switch (rate_matching) { + case RATE_MATCH_NONE: + return "none"; + case RATE_MATCH_PAUSE: + return "pause"; + case RATE_MATCH_CRS: + return "crs"; + case RATE_MATCH_OPEN_LOOP: + return "open-loop"; + } + return "Unsupported (update phy-core.c)"; +} +EXPORT_SYMBOL_GPL(phy_rate_matching_to_str); + /** * phy_interface_num_ports - Return the number of links that can be carried by * a given MAC-PHY physical link. Returns 0 if this is diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 8d3ee3a6495b..e741d8aebffe 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_matching - determine if rate matching is supported + * @phydev: The phy device to return rate matching for + * @iface: The interface mode to use + * + * This determines the type of rate matching (if any) that @phy supports + * using @iface. @iface may be %PHY_INTERFACE_MODE_NA to determine if any + * interface supports rate matching. + * + * Return: The type of rate matching @phy supports for @iface, or + * %RATE_MATCH_NONE. + */ +int phy_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface) +{ + int ret = RATE_MATCH_NONE; + + if (phydev->drv->get_rate_matching) { + mutex_lock(&phydev->lock); + ret = phydev->drv->get_rate_matching(phydev, iface); + mutex_unlock(&phydev->lock); + } + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_rate_matching); + /** * 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_matching = phydev->rate_matching; if (phydev->interface == PHY_INTERFACE_MODE_MOCA) cmd->base.port = PORT_BNC; else diff --git a/include/linux/phy.h b/include/linux/phy.h index 337230c135f7..9c66f357f489 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -280,7 +280,6 @@ static inline const char *phy_modes(phy_interface_t interface) } } - #define PHY_INIT_TIMEOUT 100000 #define PHY_FORCE_TIMEOUT 10 @@ -574,6 +573,7 @@ struct macsec_ops; * @lp_advertising: Current link partner advertised linkmodes * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited * @autoneg: Flag autoneg being used + * @rate_matching: Current rate matching mode * @link: Current link state * @autoneg_complete: Flag auto negotiation of the link has completed * @mdix: Current crossover @@ -641,6 +641,8 @@ struct phy_device { unsigned irq_suspended:1; unsigned irq_rerun:1; + int rate_matching; + enum phy_state state; u32 dev_flags; @@ -805,6 +807,21 @@ struct phy_driver { */ int (*get_features)(struct phy_device *phydev); + /** + * @get_rate_matching: Get the supported type of rate matching 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 matching 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 matching for any interface, then it must + * return that rate matching mode (preferring %RATE_MATCH_PAUSE to + * %RATE_MATCH_CRS). If the interface is not supported, this should + * return %RATE_MATCH_NONE. + */ + int (*get_rate_matching)(struct phy_device *phydev, + phy_interface_t iface); + /* PHY Power Management */ /** @suspend: Suspend the hardware, saving state if needed */ int (*suspend)(struct phy_device *phydev); @@ -971,6 +988,7 @@ struct phy_fixup { const char *phy_speed_to_str(int speed); const char *phy_duplex_to_str(unsigned int duplex); +const char *phy_rate_matching_to_str(int rate_matching); int phy_interface_num_ports(phy_interface_t interface); @@ -1687,6 +1705,8 @@ int phy_disable_interrupts(struct phy_device *phydev); void phy_request_interrupt(struct phy_device *phydev); void phy_free_interrupt(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); +int phy_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface); void phy_set_max_speed(struct phy_device *phydev, u32 max_speed); void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode); void phy_advertise_supported(struct phy_device *phydev); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 2d5741fd44bb..fe9893d1485d 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 matching performed. */ +#define RATE_MATCH_NONE 0 +/* The phy sends pause frames to throttle the MAC. */ +#define RATE_MATCH_PAUSE 1 +/* The phy asserts CRS to prevent the MAC from transmitting. */ +#define RATE_MATCH_CRS 2 +/* The MAC is programmed with a sufficiently-large IPG. */ +#define RATE_MATCH_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_matching: 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_matching; __u32 reserved[7]; __u32 link_mode_masks[]; /* layout of link_mode_masks fields: diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index d2fb4f7be61b..408a664fad59 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_MATCHING, /* u8 */ /* add new constants above here */ __ETHTOOL_A_LINKMODES_CNT, diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 9298eb3251cb..57e7238a4136 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_matching = RATE_MATCH_NONE; return store_link_ksettings_for_user(useraddr, &link_ksettings); } diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c index 99b29b4fe947..126e06c713a3 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_MATCHING */ + 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_MATCHING, + lsettings->rate_matching)) + return -EMSGSIZE; + return 0; } From patchwork Tue Sep 20 22:12:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982681 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 BA207C6FA82 for ; Tue, 20 Sep 2022 22:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230442AbiITWNQ (ORCPT ); Tue, 20 Sep 2022 18:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiITWND (ORCPT ); Tue, 20 Sep 2022 18:13:03 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D34A878233; Tue, 20 Sep 2022 15:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q8m6Vt3hKmPFeuXlwspo3zKNdVbSseYHxuZNKiKNkBGLJceFp5yF5Gxs/dxJ66fv2mhiljcihBKvEALvvVXqYDAdeowZUYmqQISFgissCzdY1gN8vUdA0gn5AfIeIOBzYvoOeX3FxJzQh7aFHw+n+akawo9/iTLDZoJmDnkkYzTg9COjBT4yUej7SczTDEjSM12XRXgrg+6a/g7MrLsifrVIwzHy/FuJZY75XRQeBFAGzlBb+c7c2DQ+jrj65UzOC1MVzje+CIJx/GCHgDqPgNCFYlYcWa4WhhvyFnTTEbHWTF4X6F7ve0BssCGOuVKBr3CtOUuy07VvQuHkXfhAHQ== 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=eJxMvkQ9hIoBvFna+ofuSFcQfePiG1W7265Nn/3taas=; b=NdDVdiDgJmIkDsyn2DQUYm7uQcijV9Jrz9uDJ6+NYYETps2jcOO7I/TpcTA6gO/w75iVFsdz8HSTJJMDzkuhYUaaTBB52aWJz+sjsnbZ5VMHn5HEn2HM8TRTyNqLPI7HXHm9eDRM1yG/FA9AwcHEsOt9vdg+vLlBX8+ghYyqC3LtFnYzW3nBTICT+obXDy0ECovZBW4Z2fM501L6W8an9wYZJfCOqMmqj+LiJ0fXiVvirl7pHeFjCx910636MkwwedRro0hCxzx7fC2lbiXDNs/ij2ZM/mSOWVjXUsDm9ZAlL/RJtK+o1I4ZN9STSd0/5+6sRk5Z9/LgsZ32SFnkZg== 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=eJxMvkQ9hIoBvFna+ofuSFcQfePiG1W7265Nn/3taas=; b=X6bWniUZNG8FlNilKbykbJAFx0SwgE2vwN1NlZF60RJnnQ3hHYcW5U1YhSVAoGuDxTe0hSZ670/VF+CNGakS6aqIxRNpTmTKogtAHXgvHhbFmRemY+YFS1iKHLtFqsHuekyVFatdewLR+hMwp+eINt23KtQ/2CmvtRT3GNbBGxlkjZ7U+MK6HkiGDQvcJqGc8IORBlv+LpzLeDQ+g606VbPA9jlvJp/uEEaHK6ZKmVf1MgtdaQeMsGitpgoTosKnEF6/DEOuUBiZJZ9NIClUW4YO4W48OhjpAfUg8+zvNWYqrYMkKbf/s/gWT4ztmiLrh+pRfmiIeMJo07b6IW4e1A== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:53 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:53 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson Subject: [PATCH net-next v6 5/8] net: phylink: Adjust link settings based on rate matching Date: Tue, 20 Sep 2022 18:12:32 -0400 Message-Id: <20220920221235.1487501-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: bd703b46-8d2e-4851-9ff4-08da9b5543a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tilVrqIHDs/HjRIBDETQloJkJODSEd04bbeMyhuKn0cFI5eCKmyiuupN9UtuSNmKyR6UfuedcRGlGPYes4asvSsZrlhjk7SiehzGYZOWNX9sBbowNhVsRPlRS1aFskURqFAshPQiqoPJ5SJs9vkp8Wd3PrIcgxLYHg3QApVPPGkNykY6vgkwSXcmRvy8NdUuyJF4b6ePgVrrW4Zg364ka8X9VKqwfqitAKCZ3ho7zYYrz72vRTrXpY2W5aw0O5GrbRXJx1w6nu86Yetxb67Vf7rv8ZPD0zadTufcWT0gsrihOefuE0dAMPTWSW0w3t0NXCojw58RjeDHPmAdxvroqo36Bxyqi+JbsSem8ihhQbHTLIzatj8TSvUsrGVPDyiwMfQRIcq5VJAsGzglI6qyffBUdqJzMrmKmKa5xb/5+hvAWfN6K23u2DAMenTzRdkSzc5xFJZezLU7zEstK3es2A7NnvxX5Dqmjgp8jhYktolF9WLR4GG+tUQiC2rUqfxTt5VX2ZqDHonPPACLlf0Y5ZQ+1iwZDB81NlR1cBaAwpOPIdKh06WHp3ZTLl4w3o69zKGnCybEg2qwbbxNgVv1iNtLx+HTYxIv1IRfsSGs4eb63gmmV72oWRhOvJT0qFzpNc3ydrjnkSNMyzO7T4/H/S4YIqtUbUzhIa0tsvxsNWlesyMUwkCrdbI0iPH+NnjYYXDyc7xN52wG+oLmDsFTvvs/gHXhiMab1keyaEmNbk/Mr4lpV0KBb/9oSBvYLc67wDKLmdrm2qK2DYwk+ee9ow== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(84040400005)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(107886003)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: irsz6bnEdtuNoMBrHurQ+isAx7+hYJMRLffBK8RClbqd1nv76wP4Zt361QKfEPBSWh84WCwu34yRZgeb/t2StBluXsk6i3U/ds2LgJgv7w6g8v9byQzE/dUulndFJVhTlNdf5s3CXxVChGVTp3vZmGlyfPTrs1RSumI3xj/+Z3r3YWSu4PFAe8gPKZVq/HMtGUjt7CV7mfF9JB99eNcr97o0NCJzVUaafObMrZ+oHLj9l10nlmq8y52EsBWC+LnXidARDDGl7EVjXsem5CphoCXsL3jDbIr+ubCpPioDC4Ss/pgi9c+rSX8+fjS0THRcDLIrF0iU6byZ8FsDqvu8AyhZG8zhNKzsF2aC/Rt3FPPVnoO2irf8rkkLorKD/2BPMHsAep4R26POYF3T2bgpqXmiBdfOGDainOmoUl8J5SOa1KE65XQJ922vHDIFgOq/3+SnXrPW3iWQqdToRfCznHHzZQ0x/3fzSOpJvjDdUYVEEveb8ZMAIsF37k4zMOr2lq3ngm8NHRdMv1zwaKHCF9tUOo123EUof6391eUi7WKM9CG9m3q1Gmphzh2N8uEaUZgSVLd4+DRPNKYFCTNbeYlp3BmKQHUWQW12HaraTSrLNVEBiYuQw5MCPBKvy3k7U/10wbpGgh4XvpIga6fOPzqqI5T2wDdoXcPqsE/K/qPfLha/3NUzOkuk5tK5tHy9PH+jH6RwAYSIgWMKWtABBwFjV11+tsNL3E5fG+HnzIEXd/Li4kiiHn1N+N/FQz9HTMzJ+FBkDxccBy7xdjCN7duBgDxT4sKUjhDVZyhb/nLwwXyTSvLzXzL15SUeMJNZhwsfG3A6xU5ZsAeXy/eWPhvdXakJYS55rHTqG1QaEVFfhVUt8OWzN2x2R1PHqwb4CbNz+mmqlnRrI6FG8dakoqcc6M21tLTQ3DE2vPrYeNQ9lhfl/akSHJcEVR5e2s52fUeqjBdY4QK5JxDaGx9v+FSyN1sOHJGlNlyKdr0AQ4pEKODdc2M1b4YEzeFOWM8JNhQNmcktavhFORndfCcUJ0gr92Upl5c/1lUFw9ZbNoO4DdFN3VjgFwrhRT4eAYSfq+mddgVyMBMczaCGbvQrgTUdTCFPEZolvA9PxFnpTYb/+ZO9Gd/tjE/Q6AlpyXTR8A/Qt82p0In50rBH0xlcc9/qmngwoEuxDnMSlLEQbIyMoWDlp8JMWD7FlfwnbKv/cAYakJIgWKjBh/N3IVzxjxfzRuMHI0SMyg0ZfaXVfnCHukLlXRno6+7ez+Eni6H2z8nAeDPvc6mVAVbPjOJGr0477BVdSzwB1xyiuy8szTI5ttZzTjlqwY4ix+0ZPBwP0/SDdn4UmTUldwJv2mj7DKpwUCUT8aifn9rLZlZf+Nohr0wm1XpsWmv3NtpGMS1ZtLrxSnuqS3couZ00sE+h4lsTN5Fo65Dn9mJY7tucfa7x9rxvBI5htPWJuOVxpj4uCmeitQI050/tcV7lRpvtgRrZdkO8+s4387SsntMTZFCOYrRHm2jtQJxg3q2OcXCyfloMt03Z3zaJsGwf6KTJ76nfIhmd7pO7DNqntpyfkq/DDm1n3hxehnLzbYwHIr0INwJoNyz/cZoGos01DINKTQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd703b46-8d2e-4851-9ff4-08da9b5543a5 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:53.6737 (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: P88eS/jRf80XM3HQalydOnVSo24i0QPfvuwG5j+fHTmlTbmzPYc0l10nXpfCHIOsjEAqhYc8Xxd4QphPPR/C+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 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 matching, ensure that the link is full duplex with pause frame reception enabled. As suggested, if pause-based rate matching is enabled by the phy, then pause reception is unconditionally enabled. The interface duplex is determined based on the rate matching type. When rate matching is enabled, so is the speed. We assume the maximum interface speed is used. This is only relevant for MLO_AN_PHY. For MLO_AN_INBAND, the MAC/PCS's view of the interface speed will be used. Although there are no RATE_ADAPT_CRS phys in-tree, it has been added for comparison (and the implementation is quite simple). Co-developed-by: Russell King Signed-off-by: Sean Anderson --- Russell, I need your SoB as well as RB, since you wrote some of this. Changes in v6: - Don't announce that we've enabled pause frames for rate adaptation - Rename rate adaptation to rate matching Changes in v4: - Remove phylink_interface_max_speed, which was accidentally added Changes in v3: - Modify link settings directly in phylink_link_up, instead of doing things more indirectly via link_*. Changes in v2: - Always use the rate adaptation setting to determine the interface speed/duplex (instead of sometimes using the interface mode). - 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. drivers/net/phy/phylink.c | 135 ++++++++++++++++++++++++++++++++++---- include/linux/phylink.h | 5 ++ 2 files changed, 128 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 7f0c49c2b09d..4576395aaeb0 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -155,6 +155,75 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } +/** + * phylink_interface_max_speed() - get the maximum speed of a phy interface + * @interface: phy interface mode defined by &typedef phy_interface_t + * + * Determine the maximum speed of a phy interface. This is intended to help + * determine the correct speed to pass to the MAC when the phy is performing + * rate matching. + * + * Return: The maximum speed of @interface + */ +static int phylink_interface_max_speed(phy_interface_t interface) +{ + switch (interface) { + case PHY_INTERFACE_MODE_100BASEX: + case PHY_INTERFACE_MODE_REVRMII: + case PHY_INTERFACE_MODE_RMII: + case PHY_INTERFACE_MODE_SMII: + case PHY_INTERFACE_MODE_REVMII: + case PHY_INTERFACE_MODE_MII: + return SPEED_100; + + case PHY_INTERFACE_MODE_TBI: + case PHY_INTERFACE_MODE_MOCA: + case PHY_INTERFACE_MODE_RTBI: + case PHY_INTERFACE_MODE_1000BASEX: + case PHY_INTERFACE_MODE_1000BASEKX: + case PHY_INTERFACE_MODE_TRGMII: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_QSGMII: + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_GMII: + return SPEED_1000; + + case PHY_INTERFACE_MODE_2500BASEX: + return SPEED_2500; + + case PHY_INTERFACE_MODE_5GBASER: + return SPEED_5000; + + case PHY_INTERFACE_MODE_XGMII: + case PHY_INTERFACE_MODE_RXAUI: + case PHY_INTERFACE_MODE_XAUI: + case PHY_INTERFACE_MODE_10GBASER: + case PHY_INTERFACE_MODE_10GKR: + case PHY_INTERFACE_MODE_USXGMII: + case PHY_INTERFACE_MODE_QUSGMII: + return SPEED_10000; + + case PHY_INTERFACE_MODE_25GBASER: + return SPEED_25000; + + case PHY_INTERFACE_MODE_XLGMII: + return SPEED_40000; + + case PHY_INTERFACE_MODE_INTERNAL: + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_MAX: + /* No idea! Garbage in, unknown out */ + return SPEED_UNKNOWN; + } + + /* If we get here, someone forgot to add an interface mode above */ + WARN_ON_ONCE(1); + return SPEED_UNKNOWN; +} + /** * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes * @linkmodes: ethtool linkmode mask (must be already initialised) @@ -791,11 +860,12 @@ static void phylink_mac_config(struct phylink *pl, const struct phylink_link_state *state) { phylink_dbg(pl, - "%s: mode=%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n", + "%s: mode=%s/%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n", __func__, phylink_an_mode_str(pl->cur_link_an_mode), phy_modes(state->interface), phy_speed_to_str(state->speed), phy_duplex_to_str(state->duplex), + phy_rate_matching_to_str(state->rate_matching), __ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising, state->pause, state->link, state->an_enabled); @@ -932,7 +1002,8 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, linkmode_zero(state->lp_advertising); state->interface = pl->link_config.interface; state->an_enabled = pl->link_config.an_enabled; - if (state->an_enabled) { + state->rate_matching = pl->link_config.rate_matching; + if (state->an_enabled) { state->speed = SPEED_UNKNOWN; state->duplex = DUPLEX_UNKNOWN; state->pause = MLO_PAUSE_NONE; @@ -1015,19 +1086,43 @@ static void phylink_link_up(struct phylink *pl, struct phylink_link_state link_state) { struct net_device *ndev = pl->netdev; + int speed, duplex; + bool rx_pause; + + speed = link_state.speed; + duplex = link_state.duplex; + rx_pause = !!(link_state.pause & MLO_PAUSE_RX); + + switch (link_state.rate_matching) { + case RATE_MATCH_PAUSE: + /* The PHY is doing rate matchion from the media rate (in + * the link_state) to the interface speed, and will send + * pause frames to the MAC to limit its transmission speed. + */ + speed = phylink_interface_max_speed(link_state.interface); + duplex = DUPLEX_FULL; + rx_pause = true; + break; + + case RATE_MATCH_CRS: + /* The PHY is doing rate matchion from the media rate (in + * the link_state) to the interface speed, and will cause + * collisions to the MAC to limit its transmission speed. + */ + speed = phylink_interface_max_speed(link_state.interface); + duplex = DUPLEX_HALF; + break; + } pl->cur_interface = link_state.interface; if (pl->pcs && pl->pcs->ops->pcs_link_up) pl->pcs->ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode, - pl->cur_interface, - link_state.speed, link_state.duplex); + pl->cur_interface, speed, duplex); - pl->mac_ops->mac_link_up(pl->config, pl->phydev, - pl->cur_link_an_mode, pl->cur_interface, - link_state.speed, link_state.duplex, - !!(link_state.pause & MLO_PAUSE_TX), - !!(link_state.pause & MLO_PAUSE_RX)); + pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode, + pl->cur_interface, speed, duplex, + !!(link_state.pause & MLO_PAUSE_TX), rx_pause); if (ndev) netif_carrier_on(ndev); @@ -1119,6 +1214,17 @@ static void phylink_resolve(struct work_struct *w) } link_state.interface = pl->phy_state.interface; + /* If we are doing rate matching, then the + * link speed/duplex comes from the PHY + */ + if (pl->phy_state.rate_matching) { + link_state.rate_matching = + pl->phy_state.rate_matching; + link_state.speed = pl->phy_state.speed; + link_state.duplex = + pl->phy_state.duplex; + } + /* If we have a PHY, we need to update with * the PHY flow control bits. */ @@ -1353,6 +1459,7 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) mutex_lock(&pl->state_mutex); pl->phy_state.speed = phydev->speed; pl->phy_state.duplex = phydev->duplex; + pl->phy_state.rate_matching = phydev->rate_matching; pl->phy_state.pause = MLO_PAUSE_NONE; if (tx_pause) pl->phy_state.pause |= MLO_PAUSE_TX; @@ -1364,10 +1471,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_matching_to_str(phydev->rate_matching), phylink_pause_to_str(pl->phy_state.pause)); } @@ -1431,6 +1539,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, pl->phy_state.pause = MLO_PAUSE_NONE; pl->phy_state.speed = SPEED_UNKNOWN; pl->phy_state.duplex = DUPLEX_UNKNOWN; + pl->phy_state.rate_matching = RATE_MATCH_NONE; linkmode_copy(pl->supported, supported); linkmode_copy(pl->link_config.advertising, config.advertising); @@ -1873,8 +1982,10 @@ static void phylink_get_ksettings(const struct phylink_link_state *state, { phylink_merge_link_mode(kset->link_modes.advertising, state->advertising); linkmode_copy(kset->link_modes.lp_advertising, state->lp_advertising); - kset->base.speed = state->speed; - kset->base.duplex = state->duplex; + if (kset->base.rate_matching == RATE_MATCH_NONE) { + kset->base.speed = state->speed; + kset->base.duplex = state->duplex; + } kset->base.autoneg = state->an_enabled ? AUTONEG_ENABLE : AUTONEG_DISABLE; } diff --git a/include/linux/phylink.h b/include/linux/phylink.h index cc039ae7e80c..5c99c21e42b5 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -88,6 +88,10 @@ static inline bool phylink_autoneg_inband(unsigned int mode) * @speed: link speed, one of the SPEED_* constants. * @duplex: link duplex mode, one of DUPLEX_* constants. * @pause: link pause state, described by MLO_PAUSE_* constants. + * @rate_matching: rate matching being performed, one of the RATE_MATCH_* + * constants. If rate matching is taking place, then the speed/duplex of + * the medium link mode (@speed and @duplex) and the speed/duplex of the phy + * interface mode (@interface) are different. * @link: true if the link is up. * @an_enabled: true if autonegotiation is enabled/desired. * @an_complete: true if autonegotiation has completed. @@ -99,6 +103,7 @@ struct phylink_link_state { int speed; int duplex; int pause; + int rate_matching; unsigned int link:1; unsigned int an_enabled:1; unsigned int an_complete:1; From patchwork Tue Sep 20 22:12:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982683 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 22934C6FA82 for ; Tue, 20 Sep 2022 22:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbiITWNS (ORCPT ); Tue, 20 Sep 2022 18:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbiITWNE (ORCPT ); Tue, 20 Sep 2022 18:13:04 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7437821A; Tue, 20 Sep 2022 15:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZF4AuA640KI7pBir4Qhar3k9hqry5eGAFVKz1oIaqbU+meEqvoB6YfmJ7s8ixNBKcTSJhzxMq2WLBE0C6Wo35EbvFjlnYno71hpLi/sut4Sma3Snqgq6faVsqFTgfP8HRoXCzsnqCLtdXk4j/sfH9QTsUushYtJTYBUfjX7RqcGVMalQjdNX+vleUnWUVfv0j2wIBk3tPbnSfRzd2GMMe2tvi/L9tJ+pLi2e0/YvrRSIo/kNJIAZLSy/Mtr2b+bJVCP+ExMw7KyMuS021ef/psKH5lVRI6ZL0dMtn6vwoFQGO68Iie29+6erqQIutngr9T672K9qxnx1kOiMiHk18g== 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=9895JIXESIDlhteTNyrchzjEQ0f6oR/6lCW/y3B86QE=; b=cyd5HjRj5GjCFmuDRbzuObQLFJc7OMimxtbZ0Y5LSExjDbNt407x2ksSVXmnxxrSY8AVASML4eKO1HDZByasn2Rxjx73TjK14xLNOnRGedQPibVdAKGuF4B2o5HwLv+XbEbg14VgxkhfKFelxP0ahPTyCF0ELKLaZdpRiIA3gIVOiOmcGe21PBuEZ/fVrF2/2/HGMhsiTbudj8z0KMdC06jZ93aHgtOzQdzx+zVx+2lR2b8JVWyxevSVpkdBRtNgZT8a55O+djxD0pQFHMc+Z/d2jOWGhvURXhe2raT98pn6LCzuZsPthtx3C7O/YnD5r9YGDsfRQjcP7oCU80SuQA== 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=9895JIXESIDlhteTNyrchzjEQ0f6oR/6lCW/y3B86QE=; b=RwVRffCDimiWVmw8FNa8sArXl4u6j7hH79DN1Q14Sw6Y8NZgxQkHTZL+5E7B56yGHXtNJgnKUE3OJfCvurLaqMx6Kq/W4xzNgod0rGCBzLaIXF2qRiV5Xv9QFQcZ/Gfc5Nzmxs6YkNtRKySA2eAFyxk7ZO2LEBSX24eiQMKwCccVznXrq2mJKamkjmO7YvI9/83m209l8gv9XRFAxL+5BxJGUowhoFzdD12AwsX1hwbQQE0d3jxJRfagUhM5R8adna21t2Iix7SOycYgwE5BmG24820CR2sKtwBF9flRKNM1vvYuW4kZAxIeRBEmAt7Q9Qgt+Xq3N8XXxE9muhHNZA== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:55 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:55 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson Subject: [PATCH net-next v6 6/8] net: phylink: Adjust advertisement based on rate matching Date: Tue, 20 Sep 2022 18:12:33 -0400 Message-Id: <20220920221235.1487501-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cf2b51c-c3e7-4423-cd94-08da9b554479 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5xCOGeLkS5Uu1i+JrOsily/uGXmtMH4vF3wHD5Wthv43wa283fOv6rfaEQNY0DkLMCaDWNiQEDHIMYyLo3b2VGZu0LbWZJznCu0tLza+uqFzCT4/U7lukxAnbDnu05AX/rabh2JoY9khC9P7/g5KenO3XxkG66+GCiiIH7vQiyR3A0Go5fsivrTg+SnmxkfcwBcvWtVe1HbUl1RWieMYE/oC96jlZYeh9kkrCIShbF5pWd4WN0O78lkwDv+fjc/oaOvCXjNIDnSZ0vMc6PF8yw8pL7UxE3+ZPJKpOMDncm3N8mAKmhvoglnLsluQ5cxyhxbAOYwgMDQAuQ9vQUuVDo4tA4Yo+ydjmEDSIsvxi6kG6bUSkf4dpuStnQ8TpBKV8sK0GIiLqqyatnqc60mA3cRFC4rrdFXG8nxg3zMIdft2jdYT62gL7ji8lgh3rz42Kjh2jR4KMf8clYAcKRFdb9JCW747DQtmQg7m5mF28WlSXU07rrgWholSS6hJ7tTmRdE/EDuar3NnKUnrLPx/xPXCo1k9eYqEESuOYxrJTyORwNiWYtb6/vsDd6rNBGXi8WJypsQWjkKuoOQjIvXJQ/eCf5pPXAQpFpHHprsRERFCcj8gHsu1KCZRnDPIq/SOWCX62FubDgvJLy9eq3n4lHNT/Ki6hYuOUK3VaPoEBD9w4vkN+AmuOTSH8ihGTvb12vZ2//UCDTGZQA7EHUAn9HOzlDauTTgGXVRth7O34wVyxipT8A/MjfonSgzFgsiGMVZIxJveG83mNQQR9Cbbng== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(107886003)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZHX+1zcaSnpHR4XleLsliIdV4YI3ekn/awmxBX//NR/MLeX/ywZiA76Ss371qnEWUKS+xxW2zGxXnyJNFyGuhxZRtXYe6F3y09WE7R8OcUE/Umfh39ePzDSFdJJqeMihC3WMFWUdx0IW3mCYPJuNaat+alPYNoSP0nME6acHxAlOIzQPS6JE+k/FDqFl/RFpuHtdmHhRISReJ45A6TPGzQbNvBxmUg+HHCpVyGHqFS81Q+Xc5478EdvVJBlMXveSWQY6EOcO7p7Wk8ViGUW+ZuFckSfc11QaKgUIUgoQDIFhfddBH/oRTEa3dIIEzUZY9amncD+TTWn25YKVwrjVKfS6IRUotceYO1z0iDfuVQ17qctHHDkF8kgKcfTdCdpiuOxDTpVU/ORRAtrtRG+lQjmxjMo+EWjWdwhyu1yusOT3Sry8gnCKfiQ5eswvRWsg7tNe7XZ38+ECnsm23uaDgD9PuNfHnisisSrcgsQPzBNh2bV3IOGPucTRe1jEMxz0D1pTX7Z0JAivPBHIMQv3+kB3hkQzlZhZ/zAvdC6sdLK6xAXtsCziQKFaLCTB1If0XhmyuuameMKYfYof8DG4fKIemKG8ZbbWbha0T8uM+Y1G+dwey/noZONzfx3ubeQjrp3zCsitJM4MH0H2VJoKhSJiwbw4sScghmNssnmshIv7l/5m0GFX7Km4zbPv+By7HYwx9OlCs/YCh8q48KLLmk+/uzunP+vMuYoGaOtuAojoowJ4MKrqfJzEH3mYoeiM1JOPs1vkKCSiVtOL/YbFE82S7BpAsulZNyXkgQVKlurX+219QA8RoEodbCiN5MhMdEeBDUWHrRbSGNdKV/fz7GcpccZiPhTWqvF+8OGkhpnR6ALlo6S7rUkaCCGgdy3S8n7Hv/nBz1UU7hBSjHMM4O1dhY5xYhNPvC6di1hFLdtcy41xp9J7b5hwWhp5+ZUJ8tuprkJ3SZh5vk0Xjelc9nGJiJOhSvyuxjVC4qhbYmHqWTDTj4Pyo0ZlISWrMafR8qJ0QdllY9xrV2m9lN4jVtwgMFUwCG/LO/iIY4pa+ViA9CSU+Ha0Cmol4cDDwWpQOE0eSR9G2fNVEjF9BzkKdetZqwjemmQX/iAJC5swvhz/fEc20XA7wp81yApx17Qd740voiaXSfpho8w210OE4XfuYlAPPuU8DZU1n5cuENfZQAU1pFaHHq3ZU2c5llvveB8aK3VjrOpx22cuFKqZxt/ACkkW3U6uHgcjxTmxmB9N6CzyYyXSBRpcCA+7SF9UX1V1QfikJVe56/iWDtUDzgEU8/lS3vqarb/9maMRCTm8qosLS6W1XOavBEzCBAylDsb6GAqnmqGTz/c9tZosbxDBO5F9ebVJe5/HY5iVZ3gtZzKqm9h7y6kt05taai03ccDtQnnnwQwul83kKeHBbAaR3on1Af6CjGc+iqL7myBAFL1XlyduuUIBql0M7bJVlMk8aFMLMlFrG9RYd+Sm3oR9s8OPgj03dwtz/xCkYT1/472ftXwLrBxcO2uMAFK7K6sQMFqa5HSV55Jb0MxU3pIcfzuW2L2tEa1aDj2LyzeYiyyEvUr8E9h13ihI7yGfB/tUL2ajFDCwFNIVIqshEw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cf2b51c-c3e7-4423-cd94-08da9b554479 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:55.0798 (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: 83u3Oy1LDWiJqQJRf4LpttNtCZYcNFR6VHhWe0ju+o9NXSRSqQX1uqpOLqg49iN4bymrMYFnu/G9QnpIUWLSOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 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 matching. 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 v6: - Rename rate adaptation to rate matching Changes in v5: - Move phylink_cap_from_speed_duplex to this commit Changes in v3: - Add phylink_cap_from_speed_duplex to look up the mac capability corresponding to the interface's speed. - Include RATE_ADAPT_CRS; it's a few lines and it doesn't hurt. Changes in v2: - Determine the interface speed and max mac speed directly instead of guessing based on the caps. drivers/net/phy/phylink.c | 106 ++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 3 +- 2 files changed, 105 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 4576395aaeb0..d0af026c9afa 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -373,18 +373,70 @@ void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps) } EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes); +static struct { + unsigned long mask; + int speed; + unsigned int duplex; +} phylink_caps_params[] = { + { MAC_400000FD, SPEED_400000, DUPLEX_FULL }, + { MAC_200000FD, SPEED_200000, DUPLEX_FULL }, + { MAC_100000FD, SPEED_100000, DUPLEX_FULL }, + { MAC_56000FD, SPEED_56000, DUPLEX_FULL }, + { MAC_50000FD, SPEED_50000, DUPLEX_FULL }, + { MAC_40000FD, SPEED_40000, DUPLEX_FULL }, + { MAC_25000FD, SPEED_25000, DUPLEX_FULL }, + { MAC_20000FD, SPEED_20000, DUPLEX_FULL }, + { MAC_10000FD, SPEED_10000, DUPLEX_FULL }, + { MAC_5000FD, SPEED_5000, DUPLEX_FULL }, + { MAC_2500FD, SPEED_2500, DUPLEX_FULL }, + { MAC_1000FD, SPEED_1000, DUPLEX_FULL }, + { MAC_1000HD, SPEED_1000, DUPLEX_HALF }, + { MAC_100FD, SPEED_100, DUPLEX_FULL }, + { MAC_100HD, SPEED_100, DUPLEX_HALF }, + { MAC_10FD, SPEED_10, DUPLEX_FULL }, + { MAC_10HD, SPEED_10, DUPLEX_HALF }, +}; + +/** + * phylink_cap_from_speed_duplex - Get mac capability from speed/duplex + * @speed: the speed to search for + * @duplex: the duplex to search for + * + * Find the mac capability for a given speed and duplex. + * + * Return: A mask with the mac capability patching @speed and @duplex, or 0 if + * there were no matches. + */ +static unsigned long phylink_cap_from_speed_duplex(int speed, + unsigned int duplex) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) { + if (speed == phylink_caps_params[i].speed && + duplex == phylink_caps_params[i].duplex) + return phylink_caps_params[i].mask; + } + + return 0; +} + /** * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t * @mac_capabilities: bitmask of MAC capabilities + * @rate_matching: type of rate matching 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_matching) { + int max_speed = phylink_interface_max_speed(interface); unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; + unsigned long matched_caps = 0; switch (interface) { case PHY_INTERFACE_MODE_USXGMII: @@ -458,7 +510,53 @@ unsigned long phylink_get_capabilities(phy_interface_t interface, break; } - return caps & mac_capabilities; + switch (rate_matching) { + case RATE_MATCH_OPEN_LOOP: + /* TODO */ + fallthrough; + case RATE_MATCH_NONE: + matched_caps = 0; + break; + case RATE_MATCH_PAUSE: { + /* The MAC must support asymmetric pause towards the local + * device for this. We could allow just symmetric pause, but + * then we might have to renegotiate if the link partner + * doesn't support pause. This is because there's no way to + * accept pause frames without transmitting them if we only + * support symmetric pause. + */ + if (!(mac_capabilities & MAC_SYM_PAUSE) || + !(mac_capabilities & MAC_ASYM_PAUSE)) + break; + + /* We can't adapt if the MAC doesn't support the interface's + * max speed at full duplex. + */ + if (mac_capabilities & + phylink_cap_from_speed_duplex(max_speed, DUPLEX_FULL)) { + /* Although a duplex-matching phy might exist, we + * conservatively remove these modes because the MAC + * will not be aware of the half-duplex nature of the + * link. + */ + matched_caps = GENMASK(__fls(caps), __fls(MAC_10HD)); + matched_caps &= ~(MAC_1000HD | MAC_100HD | MAC_10HD); + } + break; + } + case RATE_MATCH_CRS: + /* The MAC must support half duplex at the interface's max + * speed. + */ + if (mac_capabilities & + phylink_cap_from_speed_duplex(max_speed, DUPLEX_HALF)) { + matched_caps = GENMASK(__fls(caps), __fls(MAC_10HD)); + matched_caps &= mac_capabilities; + } + break; + } + + return (caps & mac_capabilities) | matched_caps; } EXPORT_SYMBOL_GPL(phylink_get_capabilities); @@ -482,7 +580,8 @@ void phylink_generic_validate(struct phylink_config *config, phylink_set_port_modes(mask); phylink_set(mask, Autoneg); caps = phylink_get_capabilities(state->interface, - config->mac_capabilities); + config->mac_capabilities, + state->rate_matching); phylink_caps_to_linkmodes(mask, caps); linkmode_and(supported, supported, mask); @@ -1512,6 +1611,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_matching = phy_get_rate_matching(phy, config.interface); ret = phylink_validate(pl, supported, &config); if (ret) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 5c99c21e42b5..664dd409feb9 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -554,7 +554,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_matching); void phylink_generic_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state); From patchwork Tue Sep 20 22:12:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982682 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 3C0C8C6FA8E for ; Tue, 20 Sep 2022 22:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbiITWNR (ORCPT ); Tue, 20 Sep 2022 18:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbiITWNE (ORCPT ); Tue, 20 Sep 2022 18:13:04 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BC7878220; Tue, 20 Sep 2022 15:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gPKyje60+nnAHkxkMJ7+Do/AdFXa7mLcB4RXxNccwBzv9KFzv8bttQYwGvsxwA+s1zUUKhGoCEkLcgfU2FV++PbKLU4UXL9zV1d5bKFEmV0MHuD6VZv1tMNQ6PAMYC64KrSnAG+YWwUWxLjohKSa4sREPMUUnhj2/wxO2Er8VjuDciZ05WWF7huAUzxQIhIdH/c3z7kv36kyA8Y16SkgPIabXez4CG0WuUS3yW925YEcgw+fNL9Ylk9XV2RlOGeYwyO2K8hZxTxq+rlRhLsOKL7wX1xTZXgROsImpk83QffoCicUFAkH6KY3kmSK++DYy3q3yYtJS6+m4iNorXV2NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=msiT+UkpoCrjHVQp2GSjV0d6CwJSb1xGjry1C/EbVZU=; b=JJMAwYo52hSWtNDPkoR+s2/w6TMclZEN2pGORJc9T2l8wchiHHnCeQwtyu2NnGTrwsuE297246It01HihzyIxGv1MVX3GeN+EYH0n6KPwxu1oiAXfpFsaqHt9zDt0tu7WXH8Vl85KL0o2MZ0iH527B8Z9d6h57JCTuiTbzstygHMeUvxIVQnGLEJSmYFQVF+rhLE8bmapJBiwigvuUC2TvR9U1KqWROr/l/owuibOenm3ob9ArSfQ0yI6YbDRZUHmTyccrVgj8fpe5PYOZDeAzpFnhKmC0eeuqndjRuF1OUUUIDCctnLl+Iq5xOXqnOdhbJTRq91OEc/vbCxgDAZdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=msiT+UkpoCrjHVQp2GSjV0d6CwJSb1xGjry1C/EbVZU=; b=0xxGXEVW4z2ke+RE0CpHWOyocfBdxV7dDB1aa8rsqTDWz/GyBmtn/RULGaiP4rW/1803+5l/idaoItTSenEUkgEQHr4mfEEPr/VGy5jR24Ji5E3ouBMSqNeK6Kk2FXtO78m7INoG7sDMmut1yAacP4u6c1iL89iswWjy7tBjM1MXKwgTZrfVJ9kIJiDrVhKtukS5uVVF7I7U3yH91EmYAUhGKUc1+CxRF5HDmbLHOBNrJ32yfdKxGbDl8XcPwV6JeA9e+z/Zp42vEiYrwt5AjcBdtiJS4Yj0Dzbgs4L5U0JB8GbkdpqBEqHyEhTnCRAWmWOrmoBOZV1joRAYj9Hbiw== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:56 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:56 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v6 7/8] net: phy: aquantia: Add some additional phy interfaces Date: Tue, 20 Sep 2022 18:12:34 -0400 Message-Id: <20220920221235.1487501-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 11a322be-d729-4736-d248-08da9b554565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BUAxC918XZIzs95g356UbrZ8kGnG8gzghYcqzfAtSji8tjFiO97y2sI7aDtCSfFZVdfwBkBDylFcsjWlT+fwaRb0fAeKMh11P+dngM/ECe1cPjx6YbQB8sPjhsgP+XfzHUgndprybCzc3jEkyCaGkqFntMP7DmHvuUIHa8GlDiQ7EkKAOnVH7pAWI3jFfd5xYr4CpyuLUZCwP61B6HzjTyaB3qKGv1pT9I8VuTdlDOSoC2c0PTeV/k8UC59UjJNnTCFfpjWBgCehb0na4rQuBrI/+d7nXRWWer7wonIi/BBmLSPKfCGSnhMHtyJPZMAKHM0nxy7Pr9UYlT0EeUucpgennBv3Nta4yBKd+Ud2OEsRPnG2QrYRw8EbdH+HtNUmdxM2pG290iYXS5gnXCnoesw0dDpgr6mW87ZNFUQHfCh7L/i5aDWf54KWhw4J6IQJIGqbbRa+jpvCcNjNHqkQtUHaSKiJdUyddf234vMRmxB4TXUeiP2ajDYRu31+bFsoiPKqLkfAjf4Awua/B+BLopMnC6jLfGNhfCC/JeRlxYcvIY3rZpAoX6zhMMDa6cohfWDW9zp7w/duZIMtuL9Iwls4+laFZoQ0ujaEjHu3E6qlzKDDMWUAdJYSz6m47Te80U97BoJORfHxd1JRhZPITE3UwI7k8jxG+VKHXJ4eyy4PxPZQLRj7ojbnVBz3hsjeelyKGinKy22T+l/pnFOpMEWZ4anKwbiFxNbWRdu5Y46scXqkDky8s+bhK/HSxoibGbPeSLgmPhY6F0k59aIpsg== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yfSwIPht9BEis1Azh5NPHr4D/9NYP6KTaCDnw4qzn5fmn7p6fMocFIqRBPOezDuaY9BiT+J+jT1Rl+m8Oy24c8Wzi8bbr6S6zYfEa0s1U2bC96dmxNjkDGRrkz9IevlcS840SRBBXwG4A62qLJ33wugzQP+92LPGeC/fZfUO93W53xxdcQojWeWdLs1xllla8jvBh1KDNu/Pd7ZOhdNMFH/F14go1UJzXU9lE4BsxUNrktr86v836m1x7lpczw7pD3scAYTyzPBUSY19Hrt1Zjyu1rxoHWdEcxcuuBtGKc4stO7BrLQZ+vZZNbqY1aMRfcZ60/NrnlQaX9HktXhFYxYhCL+dRRGZCRThH9seuQFbpb96GM/EDW6VhaofR3kSMkX2YaaeVYDrNa1LG/oMWh1lYkFJXDwccY8MXo6Rn9OEnWMtCa2t+izr3xYui3utL6iwy0ATApUyRDxg9r7zdpx8aSscxKt5pJ/rDTOWLBDT2QRuZH3giVqxR/EmA4NLmj7uMLV6ToR9n/oCvXz3n3cm8va0FEi2I9Nwo+fgIbPtZhRdaDO1uAIl6US43IuGeeyt0t1Dy2xGFznQI8sg6bZCVi3RW3+3aJp7ouD25rIpar8Q21WDEfp/19llCjg5ndhQdWAPXvzXvaBpYzOJlSeVxfmjbuDCaJ61dWviYzLYkFrPqrV5FiwNEX19i77u0cldnSF3fhXd4VsVAKdf1pZizaQwfeHo9E1Qg+2Fzz1V86vm3BI/zsvpKw5dwmysEuu3/nJ0kkDWctGVnrYVWdftT9qq548bjr1wnmgl/JZTSBk+b0iS5Bqri/BIZL+yKVKjV/Bck0FaPCpd4YTCII432yJFH+3IfEXbtF3Sc3uz6G6DyogTCc44Itg00EboM0BFYGKpKQYvnhuiT/Ezu7IDoWb/gpsc4WURNoGdIPlnxscsyjSHRYZ13IUQcpTqvC380PYwaeYDmsjIsZKOQmguPtFdWTXHr7IPKE5Mc4LTKuDrsfb9WpW2FungmQ/Iohfi+xNoEzdKmTrBujQNr/zrotSLwOiL12Nno+99fjtjadLFVwVU/4IGuVEOnvOpB2e2gI41tGLzkb3D9wmzww4VXT7lYsziZVL4ovM+H+apjaVG8UB++NQEY531RUWT1BIcjGDLh/Aj6auBRiYnKQ8WffuX32f6MRDWfOLtFnp59U1Xb2hpqgJuUS47K6tItoFVBAYC+qLSHmXGIUBWH4POQ2YRlivuec/iMFbJkc4Qx62Aj3Zz3uuulwkTFpKT9MEP4on+Acl7FRcjpZyXyyG2YFQJCpqGOyt+RQHUngQqdGUWWbLXRIYsONKvBq7gv84Ha3Mon54l60EK+uEDCi9eqgnsq2Xwq0bX9u2miQhuDWibz+JYpYVHS0lgcMulvZJNWxC2T2iyPpQ9/zE+QcuzIIekiy6JPN7F8HCgvjv4yyNxImwLP2QkQVAEoimMAcmbB3SbVCMLXUcLIQPYXYKN0KZSzvrCF/+Sr65b3i6vEvSFTk5UOazum09sG07ho1ULbInWqlqQkwyUKkRRgOU53VumV0oP3qthRYHb+8Os0sh9wHTq/nvMx+Cyx335dlkhEogjhSdrfCDrKoW6wA== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11a322be-d729-4736-d248-08da9b554565 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:56.6110 (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: UdDilI8oT08mR66fsbPeByyRd7KVaBw8C5LGz3NZKUbNxIGxPLALD5gu5YvRP7I6O8I1R39EzH+BlmtWnkDa5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These are documented in the AQR115 register reference. I haven't tested them, but perhaps they'll be useful to someone. Signed-off-by: Sean Anderson Reviewed-by: Andrew Lunn --- (no changes since v3) Changes in v3: - Move unused defines to next commit (where they will be used) drivers/net/phy/aquantia_main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 8b7a46db30e0..b3a5db487e52 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -27,9 +27,12 @@ #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR 0 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_KX 1 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI 2 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII 3 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_XAUI 4 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII 6 +#define MDIO_PHYXS_VEND_IF_STATUS_TYPE_RXAUI 7 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII 10 #define MDIO_AN_VEND_PROV 0xc400 @@ -392,15 +395,24 @@ static int aqr107_read_status(struct phy_device *phydev) case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR: phydev->interface = PHY_INTERFACE_MODE_10GKR; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KX: + phydev->interface = PHY_INTERFACE_MODE_1000BASEKX; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XFI: phydev->interface = PHY_INTERFACE_MODE_10GBASER; break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_USXGMII: phydev->interface = PHY_INTERFACE_MODE_USXGMII; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_XAUI: + phydev->interface = PHY_INTERFACE_MODE_XAUI; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_SGMII: phydev->interface = PHY_INTERFACE_MODE_SGMII; break; + case MDIO_PHYXS_VEND_IF_STATUS_TYPE_RXAUI: + phydev->interface = PHY_INTERFACE_MODE_RXAUI; + break; case MDIO_PHYXS_VEND_IF_STATUS_TYPE_OCSGMII: phydev->interface = PHY_INTERFACE_MODE_2500BASEX; break; @@ -513,11 +525,14 @@ static int aqr107_config_init(struct phy_device *phydev) /* Check that the PHY interface type is compatible */ if (phydev->interface != PHY_INTERFACE_MODE_SGMII && + phydev->interface != PHY_INTERFACE_MODE_1000BASEKX && phydev->interface != PHY_INTERFACE_MODE_2500BASEX && phydev->interface != PHY_INTERFACE_MODE_XGMII && phydev->interface != PHY_INTERFACE_MODE_USXGMII && phydev->interface != PHY_INTERFACE_MODE_10GKR && - phydev->interface != PHY_INTERFACE_MODE_10GBASER) + phydev->interface != PHY_INTERFACE_MODE_10GBASER && + phydev->interface != PHY_INTERFACE_MODE_XAUI && + phydev->interface != PHY_INTERFACE_MODE_RXAUI) return -ENODEV; WARN(phydev->interface == PHY_INTERFACE_MODE_XGMII, From patchwork Tue Sep 20 22:12:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12982684 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 E776DC6FA91 for ; Tue, 20 Sep 2022 22:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbiITWNV (ORCPT ); Tue, 20 Sep 2022 18:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbiITWNE (ORCPT ); Tue, 20 Sep 2022 18:13:04 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150077.outbound.protection.outlook.com [40.107.15.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8665E6EF31; Tue, 20 Sep 2022 15:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H9z6b02gaIpGCjrOPO/m5WAH1u2ckd5QxE3BuwhgBZ/LYCgVjIOVj2Om5OUGkW5EjwfLeDO0WZEJGt08ZZcuKOlga9OI/sAXdJRDPoOhaOLi5dFOPoKJkQQeSGoa4v5at5enw/YCdSRGYZdSYU8Zpn1l53QrI0LLkdbLCQkQxwoW8LMCJOHY2nNmPZBufDfwTAZ6KYi7eg8uMGks4+zj5gSbXu34VY/7Ji1jGRhiXU6nZkf3UsY/IJjb/deF17Uxm7RjeK1djJQDEbly0Yu9JpDk5zSe5oCLtVVdXZ2wzpTDn+UJ65Ye9pXAcp5OkYp0q/RXhIWA0YBdM3t5qme5qw== 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=JErFfUQ1xu2g9TF8RcVSZhbD/Bd6qxZ0p5OOaat821M=; b=Vwfr1sfYDHBbkPn59xAcftjliWVg9qh/rgX1eaza0d+zK4UujRmG+PF5PI3D/3VOuOm5mSZzt7hahWQYoeDG0bsARrtiFuSh+Cdorg5ssLEU+S8NqF3ya75EtnjpvQ86zAMRN8nYf+xtYslHMXywBQcyljcw0qfHPsXCxuA9oZ/47Y7vOj3jGQaEW35xUQh87+uPPNys2oBVhtSV/HOQ7uSdlpa1J+MUBV/mHWIiamjlVTTb7chqia+U1AZusHuMbUQmaB8CeSFZCmw4ILCYVo8uxEl83zY+wXyHQL/8v2vCOATNwIcDeCdzC7slw/5xfknPPD8+YGwIWqMGa3BBOw== 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=JErFfUQ1xu2g9TF8RcVSZhbD/Bd6qxZ0p5OOaat821M=; b=P2HKm0JW44xK/azxGHrM+oLbPWhH8W7DNoPQO6m3tJZxsr0XPoQ9wvArRNofrmGYHt6+FHWBOoZc9w2A0P89h/P6ZYZSbK7SZlTbC8vR8z7jOwGqIehaiVwdtpm04jTb2FcGGPBItL8C+fsbbdf/g9FhD7N+rroZTrluG0AWcN9jlZcQROOXKJgIpvutPkNVRT5ZgmngxvyolY4+SRaLIVPk/qinSHIzqd2JLWs9eQM3VdXcAv+CXhpPtcwLzh4/VfBZ+kUYRpx09ykjDWpb8LoCBIEtZLaGta2XDG4CWTDY3TaDOBi2DiSRXmRL/QV4KRAwKT/ZQyF/6MF5lwgcSA== 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 AS4PR03MB8179.eurprd03.prod.outlook.com (2603:10a6:20b:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Tue, 20 Sep 2022 22:12:58 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5654.014; Tue, 20 Sep 2022 22:12:58 +0000 From: Sean Anderson To: netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King Cc: Vladimir Oltean , Eric Dumazet , linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , Alexandru Marginean , "David S . Miller" , Sean Anderson , Claudiu Manoil , Ioana Ciornei Subject: [PATCH net-next v6 8/8] net: phy: aquantia: Add support for rate matching Date: Tue, 20 Sep 2022 18:12:35 -0400 Message-Id: <20220920221235.1487501-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220920221235.1487501-1-sean.anderson@seco.com> References: <20220920221235.1487501-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS4PR03MB8179:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e1476fa-578b-4d8d-b024-08da9b55464a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AJ7+ti7w95nnRNP2MNzM59nf5WUA9gux2YVpeAYDEOg4JqThmwXxvcVmZUa1VYKb9YavdgfOou9RYpBT3KQxeGgRcWPRaXRvDSiqN0f3dL5I69lPBTt5W6K7zXyRMxNiuQGNPPXH9B2C0TFreE0qkJXBYWl7raXnQAWtkoV2At8oT1qGsH4A/0ZeP/k5b9tlEs8Rr3V8m9Z8ldJZ6+8rzpbGBKBOC9kwxEOTKf9t8JPG/kOdcI/jC5XK46mEIhd4hsvmm57CGeIPTQV+xRRfOSXhgUj3tlxWr9Fb6c6VJipymEvbJDDh8MBcy5FsLGvvzxlPymuP3D/wVSrhQ2c6OJRvOh8kDj4pL04m/ndj96yIdLfEC88PWoKx4YZ2EUCH8NhUl8+LxMkfANSyiFJN9Wkk7P0aqtp3guVbn+Jy2x7j+ESkpQcC/hDqrzc0AwydT3HqeNTyccmVH9YNNBD7LRn4hdAmKKi8SLDNc6oWFsMb73gSJerb0u2PpN0Hn7DGvTLK4xdKPuEG/VZS8Buqf5TVewCFDyoEQIcHyvk6ZtIZftP6GjQ9U6c9pj3uIuecSNWLLidkphOqSG+I9jRXJghkT/HJp7pc4Aus2lbcFguf20DbEVp/+9Cl6A4TRdN5F2YkvIcpXAp/avKTFFD1taID+ruIxGcZxN/AD3cMqYHRkGSmKjZofVFdqGNgpuYkO9usU48ApgcfR06MEms4XkVEjXX4j0vr4UqK2ehhM6i3axxUp9yKiPeMC6ywBPX17t8uUqrfrzrYOUaMOyFVzQ== 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)(39850400004)(366004)(396003)(376002)(346002)(136003)(451199015)(7416002)(8676002)(186003)(478600001)(1076003)(66476007)(66556008)(66946007)(4326008)(5660300002)(2616005)(44832011)(86362001)(8936002)(83380400001)(6486002)(26005)(316002)(54906003)(2906002)(6512007)(36756003)(110136005)(6506007)(38350700002)(6666004)(41300700001)(38100700002)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W/n58PjEx9T70Mm/33nX7e4jZJwXp3J7UTwZAx2tc36Bah7kM5tcs/5c+7Dbq3y6TgfRJ2p+YqSvZpofAgrZ3ldUTX21Mix2ZNNt/KUQ0Nuk+L2MMZFQCekbYRWlMmNj3LuHuC7PMXsjpu+7J6iwYYLeBmhCH3Vf11prXoh7q5Q+HSu1OQDpMq3adb70eysi5zQGWsS7s7MPNTCOGY0SrBQ/VoQqk+l/0oIGARWU192Mkwceso1bSligg//ajFKC4gHwPO1YaXxWDCWFXAm6QWpvJWbzAsDSRXm60pduGO7qmMjB4hMQ6/aAyPw0iCNwipUUwO8Ot+jzdMSJFTGkixKXj0sOxCjsz5tTAY0cP5r7fdtCvc70poW5XRHRvsDKS8ZENNXQ6yUXKftJAs/jMDhEhsjMs7IJezJtR8EnTXEHVFj4vBsaGV2svVOdMCoYv2sF1Z3K7Il4orOg3rY55fOMVAgyfMN0i062AzqXHyBs+XZ3hyvuVGtI2sh5fYrt0io7xKxy9r1dW48ylXRCEB/qFhYqxMBd9YjXHeXYBQegRX/DxmNb3QAw1G6jz8L/DJ2YSQ9XLlWgjn4Iq2riuNlJy/p1JAPm9BUx+qq4+xMoUdFdylhRljCKhRDWH6PYd5olxuyIM8EH5G/3J5U6iZZ2TkEX53wE26bouMcn/hqB58rRMlmvvQfTTsXr3Ykk2AO+hBIExToeLS+2cGtLP0iXO3mMuPnDxFE7rP7O8cTrTJT5pxy/O1uDdkXf1kMigoZKjLJLZyS6pCP7EWpjw9hLVSBGjrBU2bY/+PGjyVqi+OdAPSgvdDV0KvY/UOYG5Z7h5iONw0ZkIBo/XkuqfW1RCxDKh6u0R8m3HNFAA/fdgRb+kYuEHwWVRjgWDjYsFVL58B362xx9TuPu7IUx+XP1KuGt84x4JswRHV9NRdUGyI8qIIOdgONTjSgoXlpDGV33AvYt06yD1M6ZT/80a93kZ73vbl6H/Eadtr1n4wKdQR1OANuBAawjDtTvBy+NbU0yp8IpE5vLYgvw/vl+RXzlFkxlyuVFt5ZFRrn4IWCoKE6OcFRUFpm8tD/kZAqzQr6kjqhwm6fxN6Y2St+QTkwOz56NrF+qJHn55KwABsi5nLM6a69SGoBFNnlui0fDl1OxGxt+HRa0E5KUL2QvRMeuLCj2ZK9UVNhSdkL4zyo15KnH0QySwGTOOo0LdCQPgpRwK8Goji2ApafxZG6d6h43xsOH2XuYHohY5sAOshb21s8HoXZ5nQCMyDxoCKuSrnJ3BdHi4+FDd/sfzSL4yFhSEHEOw1Jxv3We2IS2pfpA/JKWSL2MGIXEYCARS9iMdezBFPgN9hwFtu8S/xjQi7MYIh3GTJhlcYSvmbHpwFUIS5URx2j0Zw88qBFCkdtpn+/drAolZeo4Z8y1hR+Jkwpo/FB8BrTQ1eMBO3PljiMMudFwscJJXDi8vm0B2L9M7dM1bDEtb0XIicosdjAXrjf8E+3w0CpDpuxXDf7ScdDCZ5BJoZzDwRI6PeBz61BJMIU7+PFQA7o76v19ZDTLXWVJGWq4ZdFHRp4hdkrHxvi1/UmTaEq7NbLI/R7HRb75plrnh/HK3ygoIH32GBY8qg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e1476fa-578b-4d8d-b024-08da9b55464a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 22:12:58.1109 (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: O7PVt4E69eX8hvoLP7bKlS/4xuWw0vwDwIDoCROOJFN7c4xB60gtR+vgrjUsFDvjNG9j3Fu2n7mIaqNuqUWyrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for rate matching for phys similar to the AQR107. We assume that all phys using aqr107_read_status support rate matching. However, it could be possible to determine support based on the firmware revision if there are phys discovered which do not support rate matching. However, as rate matching 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 matching method (if any). Because they appear to be updated automatically, I don't know if these registers can be used to disable rate matching. Signed-off-by: Sean Anderson --- Changes in v6: - Rename rate adaptation to rate matching Changes in v2: - Add comments clarifying the register defines - Reorder variables in aqr107_read_rate drivers/net/phy/aquantia_main.c | 51 ++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index b3a5db487e52..b0aac1b8cede 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -94,6 +94,19 @@ #define VEND1_GLOBAL_FW_ID_MAJOR GENMASK(15, 8) #define VEND1_GLOBAL_FW_ID_MINOR GENMASK(7, 0) +/* The following registers all have similar layouts; first the registers... */ +#define VEND1_GLOBAL_CFG_10M 0x0310 +#define VEND1_GLOBAL_CFG_100M 0x031b +#define VEND1_GLOBAL_CFG_1G 0x031c +#define VEND1_GLOBAL_CFG_2_5G 0x031d +#define VEND1_GLOBAL_CFG_5G 0x031e +#define VEND1_GLOBAL_CFG_10G 0x031f +/* ...and now the fields */ +#define VEND1_GLOBAL_CFG_RATE_ADAPT GENMASK(8, 7) +#define VEND1_GLOBAL_CFG_RATE_ADAPT_NONE 0 +#define VEND1_GLOBAL_CFG_RATE_ADAPT_USX 1 +#define VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE 2 + #define VEND1_GLOBAL_RSVD_STAT1 0xc885 #define VEND1_GLOBAL_RSVD_STAT1_FW_BUILD_ID GENMASK(7, 4) #define VEND1_GLOBAL_RSVD_STAT1_PROV_ID GENMASK(3, 0) @@ -338,40 +351,57 @@ static int aqr_read_status(struct phy_device *phydev) static int aqr107_read_rate(struct phy_device *phydev) { + u32 config_reg; int val; val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_TX_VEND_STATUS1); if (val < 0) return val; + if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + switch (FIELD_GET(MDIO_AN_TX_VEND_STATUS1_RATE_MASK, val)) { case MDIO_AN_TX_VEND_STATUS1_10BASET: phydev->speed = SPEED_10; + config_reg = VEND1_GLOBAL_CFG_10M; break; case MDIO_AN_TX_VEND_STATUS1_100BASETX: phydev->speed = SPEED_100; + config_reg = VEND1_GLOBAL_CFG_100M; break; case MDIO_AN_TX_VEND_STATUS1_1000BASET: phydev->speed = SPEED_1000; + config_reg = VEND1_GLOBAL_CFG_1G; break; case MDIO_AN_TX_VEND_STATUS1_2500BASET: phydev->speed = SPEED_2500; + config_reg = VEND1_GLOBAL_CFG_2_5G; break; case MDIO_AN_TX_VEND_STATUS1_5000BASET: phydev->speed = SPEED_5000; + config_reg = VEND1_GLOBAL_CFG_5G; break; case MDIO_AN_TX_VEND_STATUS1_10GBASET: phydev->speed = SPEED_10000; + config_reg = VEND1_GLOBAL_CFG_10G; break; default: phydev->speed = SPEED_UNKNOWN; - break; + return 0; } - if (val & MDIO_AN_TX_VEND_STATUS1_FULL_DUPLEX) - phydev->duplex = DUPLEX_FULL; + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, config_reg); + if (val < 0) + return val; + + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) == + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + phydev->rate_matching = RATE_MATCH_PAUSE; else - phydev->duplex = DUPLEX_HALF; + phydev->rate_matching = RATE_MATCH_NONE; return 0; } @@ -612,6 +642,16 @@ static void aqr107_link_change_notify(struct phy_device *phydev) phydev_info(phydev, "Aquantia 1000Base-T2 mode active\n"); } +static int aqr107_get_rate_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) + return RATE_MATCH_PAUSE; + return RATE_MATCH_NONE; +} + static int aqr107_suspend(struct phy_device *phydev) { return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MDIO_CTRL1, @@ -673,6 +713,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR107), .name = "Aquantia AQR107", .probe = aqr107_probe, + .get_rate_matching = aqr107_get_rate_matching, .config_init = aqr107_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, @@ -691,6 +732,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQCS109), .name = "Aquantia AQCS109", .probe = aqr107_probe, + .get_rate_matching = aqr107_get_rate_matching, .config_init = aqcs109_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, @@ -717,6 +759,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C), .name = "Aquantia AQR113C", .probe = aqr107_probe, + .get_rate_matching = aqr107_get_rate_matching, .config_init = aqr107_config_init, .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr,