From patchwork Fri Nov 18 00:01:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047495 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 B4536C4332F for ; Fri, 18 Nov 2022 00:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234992AbiKRACI (ORCPT ); Thu, 17 Nov 2022 19:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiKRACG (ORCPT ); Thu, 17 Nov 2022 19:02:06 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2046.outbound.protection.outlook.com [40.107.21.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0461170A3D for ; Thu, 17 Nov 2022 16:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vet931L4Ma/ToYkH+OFeqzaHYojHGyNtd8FtnYdwZV9XHxCIBW08cA8lkFJYbYDzLW1sjCb23Ld3bcdv/cCDh1B12ctYsOGPF8kHZhK4qHI97oMPKZjTXYx/DEfXiGik6E/zwsZXAbS4c8QjxJ/KFGCynpVi1PecqkAZvLVUDuy32TfdApKtl6gzWYmGRCq+hf4/FMr2mlcd4DM+eKw0Y7qq8Wh/2hGK8PqxeQ8PUQLN3Wpf8sx5tjzCIKtYzHpBuHlnu9l9LzpHzzC32yfuy6oUt3FNIubST0LvI6QrRQu2gvL9YK8YmXHhRKOOxl5fXO5XWe7/YIbBg2DCGk+Brg== 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=2cBipMJyYxBcqsePrv461rVjzPpBbO+BXezzzn80OJQ=; b=nBebdc0K7hZr77DZ7OH3LMK8o/t5GxsVugJk5vgjjNzMGNwcdNB5LfavjvIkBDzH5qNDvSj8DOUcfqGCxIN2ve4BuPi5mu36c68FBCC+OyhBvixnSMft3J9rzcuGfXRwM7fID+xpV8n81USsgKQILvEfJc8BpezTnu+Q8qxPhVx3fCEgTWC2tdvKCfM+liQRaHOXGTSn+QEvmuHVy43X6wiEqGMK4nGibJ298WH67nU5QSrAHiZgbp03FoHMXFpwaswm4C7ClTxOZHleqVWy2qt32MaUk8CMjNOD8OSgaxx6aG9p8LTRNl4xUo/AyJolW+ityTeUYvtcBGEhEjbJwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2cBipMJyYxBcqsePrv461rVjzPpBbO+BXezzzn80OJQ=; b=UrX6NP9DxG8JdC6ohRxcAY+AEkM0KRxckWe6zEpz2lIZR6uEIqouK5dx91CaiFwQzkb9ils9AGswfrNmSZC6wFRJdKs+tlJzgdDvIVMYx4j40sPJPY71gUTW862X5hw0HgUbEbaEPPJKKnb570wes/Itu0POUBaHaSFuM2L+F7s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:04 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 1/8] net: phylink: let phylink_sfp_config_phy() determine the MLO_AN_* mode to use Date: Fri, 18 Nov 2022 02:01:17 +0200 Message-Id: <20221118000124.2754581-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 24f54b68-7d32-4b90-bfed-08dac8f81fe7 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QWu11a390RxihxSQkAmmMYcFpbq1TRAp/DXsEO+FjDWUk9VS24s7t0wnCawU6ADuDrJTv4YpZqu+Ro7jIYQKGLHNOCQ2A7NZkU4fgbPIPuwzLBSE2jq8aVqPyJsn82T9STvXNRmi+otTXRXLFvB2Y3ZR8qcpqF/YYucpiy6iJ//XYPYnd2sjqpqDGt3ptFkUuwzMA8oO+Lz8RF/7X2MBP7vkimEvmfodfWBGz6gkIb0E8pZPiqTim9d8VUBHWr8J727bNp7OFBM2eGaTxqmFHsRp0XQm/mYGxwdMzdwU0Y7YvMSUhJB055XjZGGvOaqu8mSJK6t/CTIdubuQ2SKJC8yS24ZfXvNkqkHS/iM3p7gr/Om/SFdCSpzeJIddpzkPvuFN4ImIIW8NtXlUhmFObc+zR13Yw/s1l+jFbbumSWDsxfWnjUeBpHdZxcpK9zG7MlDHHgUy96DV/0BI7rjTLF6u9pflFQ/mSRPQYA+uWRzUuFNxy2ePXAno41D+j7MmK0UV2/8QNdq8gCFjdg+a3th4VLZfxjCeI6MLKvkj4jGnTkapB9eLy+uI1ITIBTwvF3jewLnjijm9VvrDVq04snAP0KjB1tBSX10vYeXYhhruY/XGOwaws9jR8iWrlECrUtfpCHeOs7rKEUSbESdLoQLBkVaBejmJVNR+qGBhwRRGgq/5e5uhAKGdZiaXnM8j X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-Anti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zX04j/0dwuc8PKc0CYbEwJah4hcFg/5zbCVrZp490RPe+N3xlpalfbcPQNKBVtZno06iAO954HuXLs+iwueYb55RNYNjefzHpuIqhzHnkKvYXJWJFBKIXe6h8CzboDSM/d5UUAB29OmTkFhY1lmvO5fonGTaVa5mlIfhmIQi9Wf3/Dz9LL9PqF7j6P1lluVJeFwqVrgxgpYCbXyIDrIYVUBpaTElxq7LgKWfl/ZKxn9xJZSHVkGm1FxEYAFTGMVK+w5EpcuEsF9IeDz0zAalbpckUGFRbZgZJWHpoIdc3IleqXA9P3ypt1ENUTkfL8WoI9PbWGWF/T2ezwwag1z1dlagz7VIrMp4YFKTqc+BWXvKNVdR/7UpglbPvy/CPADGjPj+BolXt7CUfv4Q1d5GF33EwTMYT01uhJIhrS2EdPufVVEloW6LiQ2ZPvFhxRJRQYYxVScen1aOAhgylxGvm3BzZC4PId42a86fkk/oLHLqMf66uoBMYmRlk394VB2abzzObubI2XZEKJiE30OKLqy0HNsdaLVv8AlqAqo4Om9DvCy8FB6GkPFhWieJ3oCdj5YKlTE8Ty9UTLhhycA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24f54b68-7d32-4b90-bfed-08dac8f81fe7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:04.1416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2Ca8m3ydrhKBpLCZQtzew9byjxmAnXvfa9kLHCitRvpO6PnG7LUfzInglwJIKYkjK+MUpzM2j9K6vpj3B4WQFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For now, the "mode" is assumed to be MLO_AN_INBAND unless there is a PHY, and that PHY has broken inband capabilities. So, since phylink_sfp_config() already has the PHY pointer, we can drop the "mode" argument and deduce it locally. We'll want to make the in-band capability determination also based on the interface mode in use. Move the phy_no_inband() check inside phylink_sfp_config(), right after the PHY mode was determined by sfp_select_interface(). To avoid a forward-declaration, this change also moves phylink_phy_no_inband() above phylink_sfp_config_phy(). Signed-off-by: Vladimir Oltean --- v3->v4: phylink_sfp_config() got split into phylink_sfp_config_phy() and phylink_sfp_config_optical(), we now move the code to _phy() drivers/net/phy/phylink.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 25feab1802ee..9e4b2dfc98d8 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2811,6 +2811,15 @@ int phylink_speed_up(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_speed_up); +/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII + * or 802.3z control word, so inband will not work. + */ +static bool phylink_phy_no_inband(struct phy_device *phy) +{ + return phy->is_c45 && + (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; +} + static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus) { struct phylink *pl = upstream; @@ -2891,13 +2900,13 @@ static void phylink_sfp_set_config(struct phylink *pl, u8 mode, phylink_mac_initial_config(pl, false); } -static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, - struct phy_device *phy) +static int phylink_sfp_config_phy(struct phylink *pl, struct phy_device *phy) { __ETHTOOL_DECLARE_LINK_MODE_MASK(support1); __ETHTOOL_DECLARE_LINK_MODE_MASK(support); struct phylink_link_state config; phy_interface_t iface; + u8 mode; int ret; linkmode_copy(support, phy->supported); @@ -2927,6 +2936,11 @@ static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, return -EINVAL; } + if (phylink_phy_no_inband(phy)) + mode = MLO_AN_PHY; + else + mode = MLO_AN_INBAND; + config.interface = iface; linkmode_copy(support1, support); ret = phylink_validate(pl, support1, &config); @@ -3082,20 +3096,10 @@ static void phylink_sfp_link_up(void *upstream) phylink_enable_and_run_resolve(pl, PHYLINK_DISABLE_LINK); } -/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII - * or 802.3z control word, so inband will not work. - */ -static bool phylink_phy_no_inband(struct phy_device *phy) -{ - return phy->is_c45 && - (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; -} - static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) { struct phylink *pl = upstream; phy_interface_t interface; - u8 mode; int ret; /* @@ -3107,17 +3111,12 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) */ phy_support_asym_pause(phy); - if (phylink_phy_no_inband(phy)) - mode = MLO_AN_PHY; - else - mode = MLO_AN_INBAND; - /* Set the PHY's host supported interfaces */ phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces, pl->config->supported_interfaces); /* Do the initial configuration */ - ret = phylink_sfp_config_phy(pl, mode, phy); + ret = phylink_sfp_config_phy(pl, phy); if (ret < 0) return ret; From patchwork Fri Nov 18 00:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047497 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 0D097C4332F for ; Fri, 18 Nov 2022 00:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235058AbiKRACT (ORCPT ); Thu, 17 Nov 2022 19:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiKRACJ (ORCPT ); Thu, 17 Nov 2022 19:02:09 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69C870A3D for ; Thu, 17 Nov 2022 16:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XSqLr03e2UROUCvFV598VOB2LmKjmqWtumoqjGXI8JqmSrghjqumBAupO4L/dWy4sLXiWYTQlevjbLtqwNAWYaYt51wsTFi6iV1g/O8S3WAN0njNNy47Ka4X82ELIduQZcEbOt8EBXDDVbD4k0HMeU2j5JMfgR/V4E5dkwYQPrMHthtm3iQhgPcL4l08jF4YrKUqSirxkRBmyTRe6bz5KhqEROk71pRfvxzA0Mjk+u45ZlGN9yargblAA3C52t7jh/13140MYF1EyajSQ3yHJ3OMGd7qcVay4sFHK6TWl3RIksVcRjv3Ey159OHZ+Ma9XoSWxMvWrMqwCtTd8FmjWA== 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=DEgFNu/12zWZx/LJYWUjjs28ForFgD+UKF3WxHJ1ToU=; b=diITORCq26pY26sV2lOyam0nIET4jJNq+74CPBc5R1an4uPa4rerzgJRq+oV5K4X6hNqgutb2xwkK/jDcfyfb93tOx3GteWSN77pkrURAoV05IDEYfW2gaJWcqqNqzf3jME4qXbnM7HCJwKhj4hFhVhtE3uJ0aOgHX+Ow2lBHDHfpqb9FgjyqXAJ1P79KC5cEmPxsfypxWExs0gwGaCUwzgxjMHA4CTbgxREemEo/V8uc/LPpWA08zGbpIBwF+AgukQDR+tUSg4gkKxWXxUoxpZGa5+LA7yACNdNK5Lkbj4Kqym5fQa9uwIgoAjHgpjYa6a1tas5PB71RDVKi28VQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DEgFNu/12zWZx/LJYWUjjs28ForFgD+UKF3WxHJ1ToU=; b=qbVDhjWDjcqHDS+4Iw6pQm332I47EkUidPBqGmVp8ZYcnl7qDjuB2MsQtsejSraBuBGahNO+lepNQZ4kW6hpm2vMahYEn6KBEGZrl/U5BX3OGbcFITLCM6Ppivau9Ur+5IfLGXeux7M7fKhXdCKL9XImxLRkvFvXK8V9oKak6Ao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 2/8] net: phylink: introduce generic method to query PHY in-band autoneg capability Date: Fri, 18 Nov 2022 02:01:18 +0200 Message-Id: <20221118000124.2754581-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 76609c53-5a0f-4708-fbd5-08dac8f8210c X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hxq7KO/lxrs2T4FNCYGB+vfJtlixWJV0mL1b/xoo/lw899elAU5g0LaGuFMEB/JwER+LtLHTyXJZC03tRhwGy9RBFoWCP8WIwnHkgm9neE4dZOm+JkYjr1bhz1o2UmsZlte9xg1KSEVE/uO9BKBmXpC0KUbb+3XFEEwOwncaq1WV9vv0AjSb0TPu1SZZ/DwtmVHZmmnQp0j248soNIfbFOmbrEhxgKTIKI85c1fufDmileCdbwSZtf8pOaq0SkzBcjbhhILXeeWDKm0KnXdvsmbnOX6nfq77hDV63zHn3UXBhc6S51ctW1Q2OkUCF0uKL5r0hW0WIPYsdgqIgn8PQ9cGtDKsryPzIitssBluFak4f0Aa6gaVtIGyvCykrxvfSPcCmJkNKNwlQKFxLvgBhYyfAege+Vhvfn/RVJcZF5aPNu+FgDtvD4MGlB1PBFp53U74DyBmOvGzhSq+8ESo1GJGPUwtgbUkzhdsjWGMu6+x2TEMeq6NzDDppgJ/gb8qr/mF0UulYYMedv+PdU62PawMoeH7lANowWSpyn/IGPJYuhaOJOChpKax4xGdh6XrBermw9NWhITrOioO42+wvqypgFH8XZ8L5NdYDNnMdosl2X5qq40g8DuM4Jyekn2/W8B3Sy8eelvRyY7A5bV7ONzq2fvt1afVmPp3iUUcAJWBXkp2PuLXJnLBF23YqrYgA0hd6X7FcGXQnr/MnngIbYa7ip/0IffRj8uAaM+8eBQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k5fLdKJlLK9l3yxQp91jwULQ26A33y6ABE/EUj12QNLB9LvZ/BRUXbBv2r5agycA8teYrgMScDr2QpwX3fa1BkrBDdNs43YZDOYgAXfOSW3f5BA2GBjsk1+uq7L01sMJ8CM8ReGKByxuj+bSWT96EW03BLLhL8pydzGlkBGFHdJTHnVJuooaRGS2I4gtKGdXgO2Vw+6h0mFRgim/6WdQxoAk0/BxkpoVnGNeNtb8yd7MoXhcS7cLpRWu+SYkZRqV8K7a4m58xFgpKA79IW236AkiVJgkHE5ROz6Zmfq9CgPx6PdcN9G5dlcdTbHFDtJwggQ6RtYlovE+6o2gIsptLN2t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oEUE+1uO7D58I1AJNBe+1Dpi49Dgjs8MsW85cnqu1f18AC0sBfZ6Pe0NdsfZ9oFmXgIECWMMpE2BpESSio8Tpf0EfhQoz1yI1JQfp7MprwnbssSuxnS5ks+mo0sp4wnp2xvn6DoyxAusyHvp3eFodN7er5JC+LdazjXXZ7R4v8lnGntWZxUmAd4Zb95szNf+K+VGNizzrLDg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76609c53-5a0f-4708-fbd5-08dac8f8210c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:06.0321 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: E2aniAjS74PulFhnEv1EdBoscGHsTnar9wv5vej3vOGbFj4tnTtKLjqJs15eaRFsxug4NrmcLaYKggXywS/+0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently, phylink requires that fwnodes with links to SFP cages have the 'managed = "in-band-status"' property, and based on this, the initial pl->cfg_link_an_mode gets set to MLO_AN_INBAND. However, some PHYs on SFP modules may have broken in-band autoneg, and in that case, phylink selects a pl->cur_link_an_mode which is MLO_AN_PHY, to tell the MAC/PCS side to disable in-band autoneg (link speed/status will come over the MDIO side channel). The check for PHY in-band autoneg capability is currently open-coded based on a PHY ID comparison against the BCM84881. But the same problem will also be need to solved in another case, where syncing in-band autoneg will be desired between the MAC/PCS and an on-board PHY. So the approach needs to be generalized, and eventually what is done for the BCM84881 needs to be replaced with a more generic solution. Add new API to the PHY device structure which allows it to report what it supports in terms of in-band autoneg (whether it can operate with it on, and whether it can operate with it off). The assumption is that there is a Clause 37 compatible state machine in the PHY's PCS, and it requires that the autoneg process completes before the lane transitions to data mode. If we have a mismatch between in-band autoneg modes, the system side link will be broken. Signed-off-by: Vladimir Oltean --- v3->v4: - split the SFP cur_link_an_mode fixup to separate patch (this one) - s/inband_aneg/an_inband/ to be more in line with phylink terminology - clearer documentation, added kerneldocs - don't return -EIO in phy_validate_an_inband(), this breaks with the Generic PHY driver because the expected return code is a bit mask, not a negative integer drivers/net/phy/phy.c | 25 +++++++++++++++++++++++++ drivers/net/phy/phylink.c | 20 +++++++++++++++++--- include/linux/phy.h | 17 +++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index e5b6cb1a77f9..2abbacf2c7cb 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -733,6 +733,31 @@ static int phy_check_link_status(struct phy_device *phydev) return 0; } +/** + * phy_validate_an_inband - validate which in-band autoneg modes are supported + * @phydev: the phy_device struct + * @interface: the MAC-side interface type + * + * Returns @PHY_AN_INBAND_UNKNOWN if it is unknown what in-band autoneg setting + * is required for the given PHY mode, or a bit mask of @PHY_AN_INBAND_OFF (if + * the PHY is able to work with in-band AN turned off) and @PHY_AN_INBAND_ON + * (if it works with the feature turned on). With the Generic PHY driver, the + * result will always be @PHY_AN_INBAND_UNKNOWN. + */ +int phy_validate_an_inband(struct phy_device *phydev, + phy_interface_t interface) +{ + /* We may be called before phy_attach_direct() force-binds the + * generic PHY driver to this device. In that case, report an unknown + * setting rather than -EIO as most other functions do. + */ + if (!phydev->drv || !phydev->drv->validate_an_inband) + return PHY_AN_INBAND_UNKNOWN; + + return phydev->drv->validate_an_inband(phydev, interface); +} +EXPORT_SYMBOL_GPL(phy_validate_an_inband); + /** * _phy_start_aneg - start auto-negotiation for this PHY device * @phydev: the phy_device struct diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9e4b2dfc98d8..40b7e730fb33 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2936,10 +2936,24 @@ static int phylink_sfp_config_phy(struct phylink *pl, struct phy_device *phy) return -EINVAL; } - if (phylink_phy_no_inband(phy)) - mode = MLO_AN_PHY; - else + /* Select whether to operate in in-band mode or not, based on the + * capability of the PHY in the current link mode. + */ + ret = phy_validate_an_inband(phy, iface); + if (ret == PHY_AN_INBAND_UNKNOWN) { + if (phylink_phy_no_inband(phy)) + mode = MLO_AN_PHY; + else + mode = MLO_AN_INBAND; + + phylink_dbg(pl, + "PHY driver does not report in-band autoneg capability, assuming %s\n", + phylink_autoneg_inband(mode) ? "true" : "false"); + } else if (ret & PHY_AN_INBAND_ON) { mode = MLO_AN_INBAND; + } else { + mode = MLO_AN_PHY; + } config.interface = iface; linkmode_copy(support1, support); diff --git a/include/linux/phy.h b/include/linux/phy.h index 9a3752c0c444..56a431d88dd9 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -761,6 +761,12 @@ struct phy_tdr_config { }; #define PHY_PAIR_ALL -1 +enum phy_an_inband { + PHY_AN_INBAND_UNKNOWN = BIT(0), + PHY_AN_INBAND_OFF = BIT(1), + PHY_AN_INBAND_ON = BIT(2), +}; + /** * struct phy_driver - Driver structure for a particular PHY type * @@ -845,6 +851,15 @@ struct phy_driver { */ int (*config_aneg)(struct phy_device *phydev); + /** + * @validate_an_inband: Report what types of in-band auto-negotiation + * are available for the given PHY interface type. Returns a bit mask + * of type enum phy_an_inband. Returning negative error codes is not + * permitted. + */ + int (*validate_an_inband)(struct phy_device *phydev, + phy_interface_t interface); + /** @aneg_done: Determines the auto negotiation result */ int (*aneg_done)(struct phy_device *phydev); @@ -1540,6 +1555,8 @@ void phy_stop(struct phy_device *phydev); int phy_config_aneg(struct phy_device *phydev); int phy_start_aneg(struct phy_device *phydev); int phy_aneg_done(struct phy_device *phydev); +int phy_validate_an_inband(struct phy_device *phydev, + phy_interface_t interface); int phy_speed_down(struct phy_device *phydev, bool sync); int phy_speed_up(struct phy_device *phydev); From patchwork Fri Nov 18 00:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047498 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 9BBA3C433FE for ; Fri, 18 Nov 2022 00:02:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235103AbiKRACX (ORCPT ); Thu, 17 Nov 2022 19:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234918AbiKRACK (ORCPT ); Thu, 17 Nov 2022 19:02:10 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7D887EBF4 for ; Thu, 17 Nov 2022 16:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L0ZLcic4Nx4BHvoLGahKtt7pAys8tZC2RDOQdV7ZNaCljJXNYj9ef5aOL2zBDwujz0IVaFEapgIZ7SXsj52BVDKxJaBJBwALZLFrnKbaDZGCVkq3QhJ8VZCjQmAPUgOvsV2KcJ1WyOcCLlXf8kRl73YiUlZt4tlUK5nq2Gizv1Mw+zcck8ZcfR1clenACiOFCxpmkT7zY2ZLyGpXNaakVK86MGZWra7RULh9MA3tcTAVe65o6XRSLhUfatKlEE+zBEYwJVGG7Omm0AspBWMXFvwgEEi66cfkGOG3Yp54hAZ2RnZbx+BtJAucd3fVWIQG/V93AMb0WCYcmWKiq4J9/w== 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=0hBkZ2Bwmkcr6JwQWk+d4BMKyOTn03ON4HwMRurIMhA=; b=O93gZl8Ekr72PJeuzzXNHzIBcOJLOnO5rjBMmOzSDFUmpaiayOGByItZO8EU7ZupnOgTpnIT9GG/EoUPOFOR0b/MhQ4yP+UU84ca5enKFoapJaxz/kiX6vXICvg3LCqyrT5VV0liHtLpc1UIgFAYUbmEDHVM8XpPn5lAfHDLL9yva31DyXIE5/EUSSHYxrLKAW+hmnz5TMVRL4v5HFDAEAs9coi7JJheTV4IwQ0DQNaOMXPQRfmExwH4sLuxeZGPau7G5+Oj99TrBNWqq611vBeUhx17Ew9+uCpJ6/Mvo4wzP2eW24anXVk3LRR51HRp/xNWYC59jTTfzwXIs9ODeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0hBkZ2Bwmkcr6JwQWk+d4BMKyOTn03ON4HwMRurIMhA=; b=kQBGGQ4jpif+yhDO26ALW1LK1v4hNnzs5Q2/DpGWwIprWw7AUGnGfwja/Ap+fzyoXIxfEvTlI4M7WdMBawkI23My4Xdn1YsZYHZG5cLWnsB8xJrWHJNtBED7rfOCUmbIkgsTdmjLH/T1ydC7FP94XwaOiZHxH7aZVftTh4L9Qoc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:08 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 3/8] net: phy: bcm84881: move the in-band capability check where it belongs Date: Fri, 18 Nov 2022 02:01:19 +0200 Message-Id: <20221118000124.2754581-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 896c20af-2f54-456c-7328-08dac8f8222d X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9vwb3Lk8pgWIrMuNRDD8XaLtydN0RFCHBCJt2/NTvdd1W/OoXo33lGyoqXpZHj8oyHRU10scisMkVSDtj72fHth3TVo79miIafkcYRT7dbzqbH1V95pUVBTxDoGquUSMVxemJfO5CBnMMh1xJACxSuFSQ6IhSXCDNmm3UQOJOvLpHJtcDmG/qRIdOMerqa9ASaFCiOGY51TPs0BB0DD5oVjLtIlJnBJijHfsYnpymdvPJ71/3w0u3S6jqftDCC2OrzSb+UHeMm8KXpmuAzPVCdAraM/6vAc+6bydburmaawQRMkaDogWH4FoTmZJmXnkUEIjkUrGGZw23f9p5Fy2TBCIzfNTbqf/0OrlUrElqobZEENBv6GxujcHy5gxKVTWewhWAIPnn2BEtDjYybzkFiKjdHJe1F4g8qqKLCYvrFCos/poCFM7vPAqiDhNcKY/qa1WS0l8yqsmIIDiIcr9mk/jJSa866e7qD37vkFgR63EDlFkR5PnCEFrkrg4KWXwJLhqjAdgzfOfAodVhZvGdYHypUlzEEvnRrxKDh2UeXmBQLBNMyYxI7/pB6Pjko2/Id3n/JzVpIu/bx62Yt2RM4olAgYNcr27XbCAn7HslvDMr2dSOrmX/D2eKImlJKBx/mjTH+iDOSqTHuevH9YTsXwxEhSH46rjUrbMFHywOtuh+EHqGMqkmoXVO/QmLvN0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J5ntwpxx6mqlKAnMeDp7PyI48vwMqnlalzwonWEg/F56B9H12u9g22ScjcIn018Itb8FAQ3EK6BIAZyAhNgUz8V7u7SqeAmkMF/hjHP+22sn6QjMqBNQPOLAWuzqfNuGk3aJ9KHIZDFtbtz2PUp5mPs+pMe1mQ4SxXi/f3kqsiOguSt3Wv2I/YbLSYg44052pftsgwCTW6Az0ZU1+SPJ9ZwB3jiUAnTWu5Id4LxtVDqmW2YCrm2NQ312Bc6mwxhQFf5/wiTLU5O09ZfNqB6USFXH8ApUUUPIxX+9NEwl1FEoXT5/bZgcb/dIoppy4JqDrapg+5uERUwYoAy0nmrNnOpNH//kV4fe0srM5LNO8H9JUn2B8nBT63kdF/24sw+O9eKkT1do5NeP/s/fZXggfBeeXgV3AbrahWytFaUqEqbtPfBpoHI1RjW+Dgzz4LQrYauSjquPNgfR+pKt/K5YLCS+xSoPaRRdTUcKkkU1UFJ7FkDHWt7HQdDrDQmNF7PR2XWoeFIPXIc4g3phZId4GhJ+fpY4o2aupTFCgvFJm93xdbvEHyshS+/c2LN8xalzTvq/7VPG2iuD51JjsfUccbYfsnE2oEuS/7L/fm/g27HKiO99bFwTdesaY8RppSm7S36RFMh8AWuC2FA2Hit5gh/5q++7ARr/Gc/S4NhggyUfdwNB+6ikgGdjM9Eb9ZQxUgg+EE5uzP1Qto9q8/OdfmfuNKtrDkdaWICunfJCpZYTANf99SgixgvGvwX4GWSTsE54Wve7Vdgjl64tpWqZBZwpVfBYzc1mK1ZIYG3odCyWolhWDQhsrBYWXswHZLP7lml5eTl6gN7oaA2Epebtj01h9/fQldEVKu9bEp8hJ5I+Q6eP3A8ugLS1SmPYOAHlxRfk2U9Xi/J+LunROukjr2gCbYizwMrgBqh8D2Ppw+TXXpefHfzNsHHPomDEOJosga/vhWjU+yrXkYJTiVFWxPZQ5xxtB73EQUtW6qyMyLSXYgJUhYm8YwJRoM4EX9jPWwoVZJFCd9dEL2+B2YG0XIH6wM2rpSrWsP4EKjrd9mHbii5i/ycuu26kPJRxbpLwU8h+IRGyMMCuLgGcXko7nqzTqlme0rH/7TlRxX6RbHt5U3c7KLE1PkEyOsGSQP++kKJ5ENSoh0Mk+DUng8bwoh4Swih2XyODEBXVrb9ic9+irCIJ9gKZE7nru8ZMONc1L70QYDhITAbjS9TXs3kpKl4nAAnfEeq7Amd/FWnfbOo8idyRA9KyBBXLIcWOKSHP8KZJ10YH0bnmJRquIYqc191hKJEzPz4uCNQhE+EGSiLaO+o5GJSLc6H1Ljgl1WCldTXXrlJabTSWafdylLpGYrbJvZBzhDuXU9f4dpe8TRMNv7b3kCrHnSZC8WPzXWVgFcK1spm2+iPYpAlVu91Z8eslnzIFFHVE3Oc9h2F1v0KGdr/5+KZ1I+z7MZhIKlvmCVftfmJKXsL4OgwWePLVNMxdWPftl3jX887N8hpUoSEIfdtY+1UeP9ZzBsBikns4dNyvDDXhacMg9Z9Zdzrc1BS3ZKaBlZvc3iMJdUUDhgG5idRFBy+fX6+pCkmzKfT1YhrEqOz9jebNdgUVY3Q/OA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 896c20af-2f54-456c-7328-08dac8f8222d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:07.9069 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bBR50/YR+cTYBVoVq5lFCnoxRq0dMfgZdi44LSCPxgWjzpZu53UqI+GmF2vUJgRsZoZ2wJkYMxaXRHb/bkZEUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now that there is a generic interface through which phylink can query PHY drivers whether they support various forms of in-band autoneg, use that and delete the special case from phylink.c. Signed-off-by: Vladimir Oltean Signed-off-by: Russell King (Oracle) --- v3->v4: - since we are now in phylink_sfp_config_phy() rather than phylink_sfp_config(), drop "if (phy)" check - s/inband_aneg/an_inband/ drivers/net/phy/bcm84881.c | 10 ++++++++++ drivers/net/phy/phylink.c | 17 ++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/phy/bcm84881.c b/drivers/net/phy/bcm84881.c index 9717a1626f3f..ab03acee77ea 100644 --- a/drivers/net/phy/bcm84881.c +++ b/drivers/net/phy/bcm84881.c @@ -223,6 +223,15 @@ static int bcm84881_read_status(struct phy_device *phydev) return genphy_c45_read_mdix(phydev); } +/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII + * or 802.3z control word, so inband will not work. + */ +static int bcm84881_validate_an_inband(struct phy_device *phydev, + phy_interface_t interface) +{ + return PHY_AN_INBAND_OFF; +} + static struct phy_driver bcm84881_drivers[] = { { .phy_id = 0xae025150, @@ -234,6 +243,7 @@ static struct phy_driver bcm84881_drivers[] = { .config_aneg = bcm84881_config_aneg, .aneg_done = bcm84881_aneg_done, .read_status = bcm84881_read_status, + .validate_an_inband = bcm84881_validate_an_inband, }, }; diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 40b7e730fb33..bf2a5ebfc4f4 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2811,15 +2811,6 @@ int phylink_speed_up(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_speed_up); -/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII - * or 802.3z control word, so inband will not work. - */ -static bool phylink_phy_no_inband(struct phy_device *phy) -{ - return phy->is_c45 && - (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; -} - static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus) { struct phylink *pl = upstream; @@ -2941,14 +2932,10 @@ static int phylink_sfp_config_phy(struct phylink *pl, struct phy_device *phy) */ ret = phy_validate_an_inband(phy, iface); if (ret == PHY_AN_INBAND_UNKNOWN) { - if (phylink_phy_no_inband(phy)) - mode = MLO_AN_PHY; - else - mode = MLO_AN_INBAND; + mode = MLO_AN_INBAND; phylink_dbg(pl, - "PHY driver does not report in-band autoneg capability, assuming %s\n", - phylink_autoneg_inband(mode) ? "true" : "false"); + "PHY driver does not report in-band autoneg capability, assuming true\n"); } else if (ret & PHY_AN_INBAND_ON) { mode = MLO_AN_INBAND; } else { From patchwork Fri Nov 18 00:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047499 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 BD156C4332F for ; Fri, 18 Nov 2022 00:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239374AbiKRACh (ORCPT ); Thu, 17 Nov 2022 19:02:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235041AbiKRACQ (ORCPT ); Thu, 17 Nov 2022 19:02:16 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80055.outbound.protection.outlook.com [40.107.8.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7989382210 for ; Thu, 17 Nov 2022 16:02:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=INNbVLgvhqpv8+6mJ2bj/1ZFJBZPO/ySPR7dVGYh+CJVWjhoWj9rSAqjWeO9+14MkYQtqIeXd0nlaKwCMku4kpeYGnvJJxF/ZY0KjPfzR+VZiQ9wQbpicKGRHf9/HuYoPqb/AsdZ+omtc7xr4HEBGFXL3+WWeVJmTHgsqfpLG7NV373+skwnOPEGAJVUhPaCzcEjxzQ52LktDJOTpFMGVoi8HUHCWloPkNuk6vFJESYI4Q9QMfWILQmgXcxYnCvrPfZrWd9sHNA8uFpQWvkd2uJ+964yDbVtJyTT9hTg3iu73ZumWqsPAsIap7J2pRquBNtrD6MF/W/o4la0C1NmVg== 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=d98lzkpGhp0QenrHW8ucPX1119el6MMPyrH9jsJC284=; b=Z9WJGZqgcMu17hqf8VpRRs1U6xTLrXBqh+gqLA+WxMEHxbwCCSjaQUq3vlqucLb/aj9HAMa8WdJBKG3SA2NFNlTus6FLzWrgvuoJONriJche5xVo85qCIp4v3MIya8ObQW3BRolIfXcVZJH5MCdI+CH653ScNqTQ+E3zMDVyJj7v2fNdEiqYlU5YYsVIpBh7sODLKdJft+Ip5UU7ead4HJHkAO67jC0vS0g1Ff0cmKhMNDzW+SU86Gb9GZ2lTABStVVIyuMcgWufzWIwDepBnhyHvCksRR4VIqRXG7PjFNsy+8iVC320yaeLZoBUj0Rb3lOC50RupqMnVAHbnMrmjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d98lzkpGhp0QenrHW8ucPX1119el6MMPyrH9jsJC284=; b=MLpC1C5EVpGMzD5qKpJAgY1u+xHRrxXkRbFgPFpYit/KhSzPmHHQI8OTdS65mr4P4WW04tvft9ryjbcfwEFyZB6joZamyHE5ON0RU6xovgcCTuqdOGXs2UtFgtTxpf+gDQxC8nLH02ZOMKlF/hDyZBaMBfSb2B/oQ7OKD5rokCU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:10 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 4/8] net: phylink: add option to sync in-band autoneg setting between PCS and PHY Date: Fri, 18 Nov 2022 02:01:20 +0200 Message-Id: <20221118000124.2754581-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dea0ee1-eacf-4aa6-4cc2-08dac8f82350 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NzfYNySVAD5lY8Hgax3z7e57DWvJovkFpbg2DTA8QozTfVQHizXzjUJBAukz0n3q782ok84C30socka2WStUh0yTasbe23sXUXRNsecAKnIQV9L8uZiyPK/NUu5LYyeHbuPvZnfcQvv2vzzhZYlmMYHwfrSiXYgyp+LYKc+lo3LkyGngFNjHZ8BFdbJmh2pO7YP7WbHdrC8QjYcaOztAHkF3iUt4F119USeMzDbBbQ3JgXf+mvk+xYkv6W7jwmhcOdm9Z9Fvn6BEkMU7UUFBBHumrV+DxmGFDLZEVD1c3hoNeTLnrcb9YJlhCrqvs8I1PjQVSu/nsD4ZicBeyq4N685ABC7F6fERprZTqqCt6e5S8flVSle7ZNuYj4fIraMK2YmVpqFz1YjZJ4eI9d4IwsieQNhYZ9aXgS1W3TrNBsACUPU+WTUghj12t2r1XGiXWFdtBIbq6dWVHuhZ4UQdthyUSg8UemyrrYlMjciRHIET+Gn/7agNNZk1NyV1YGubatIWH9zAuzbcXGoz5x9C/TX0ZwDYXy3bEqQogS3TaMBG5HIIpBEXPMuNxP2JWDb0dbeJlzaCh9P8GML2c6ZXplrsCBuHEAHUKKkAEkh2Ur5OIlOktztWxYvQdh3c5IQ3sdw/Y9GIDO+xqXXiD5xgAFrbOtDsxPmzj0tK81zCH0uJzKEbmNTCMqbw0N11Km2STIM+KOsAeH6FrGN2n0FRIA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001)(21314003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3L0gIIBHRYPor5pmgyKnRHJIzyqHzxBncjv9p4Fw+53J1aOhHm1JN27I9zJF2nU4MVkHFJgl7uGRWRnLMttQpxJRYsf8fl5XOlhvbSqddPvT9pizOfCyORvX93HSZsIgN9qrMnjXBL/NHoU8UTFprj886HvrrxmlKIftFEHg3QqGAITN7+7o0I6WDZpgnrQPsPbyrpj80taMQNqEURuufOjUkU4CzTlA++e3uxc71kPcAh4ISBWYmDLI1J8fsy+D5h6CZCfqnmFzgDIVKsvpN4YnKJZfVH3NwxZBTO5DEPraNfcgN+mj434zijASNm247xfCx0lRj1yln+lmfJ+LUEtHo+t23YZ2BzMJHhKKX+m/f+qj/qaqiXlPHw035KMEi+sB0YzAq/LQBPhBSM/8PiFLqB0ixmNEmQXUDWrbWlqmcTlWEBErH/lfi8AHO/Eq+Oc760JfJq5/LwRDJmaYMBdHkSUiviI9UB6XejocSFCCiRGVDErgpLxOmAqArCPH1vD+xfwwzjb3/xV8iDjR3lPgXNyOPT+k1/UhaC551+W3HcCeKe0R7Q8D+wTygjpniFuMDeEXzFqYEiKlHFm556Pa5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ac8f82350 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:09.8599 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Rz7Owsnw+Ol7prAuii3SbiEYfTmi5PaHUJxBj9AzBR2s+cjpfAWMQeR0d5bZ9QjHJQgtparPGQWvW9g6HyT4Yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the case of an on-board PHY (not on SFP module), phylink parses the 'managed = "in-band-status"' property (which may or may not be present in addition to the 'phy-handle' property), and based on this, selects pl->cfg_link_an_mode to be MLO_AN_PHY or MLO_AN_INBAND. Drivers which make use of phylink can use MLO_AN_PHY as an indication to disable in-band autoneg when connected to an on-board PHY, and MLO_AN_INBAND to enable it. That's what most of the drivers seem to do, except macb_mac_config() which seems to always force in-band autoneg except for MLO_AN_FIXED. If one assumes purely Clause 37 compatible state machines in the PHY-side PCS and in the MAC-side PCS, then in-band autoneg needs to be enabled in both places, or disabled in both places, to establish a successful system-side link. The exception seems to be mvneta, which has a hardware-based fallback on no-inband when inband autoneg was enabled but failed. Nonetheless, this is not a generally available feature. While in the case of an SFP module, in-band autoneg is genuinely useful in passing the link information through the Ethernet channel when we lack an I2C/MDIO side channel, in the case of on-board PHYs it is perhaps less so. Nonetheless, settings must be in sync for a functional link. There is currently a lack of information within the kernel as to whether in-band autoneg should be used between a certain MAC and PHY. We rely on the fwnode specification for this. Most of the platforms are seemingly okay with the status quo, but there are 2 real life scenarios where it has limitations: - A driver recently converted from phylib to phylink. The device trees in circulation will not have the 'managed' property (since it's phylink specific), but some PHYs will require in-band autoneg enabled in the MAC-side PCS to work with them. - The PHY in-band autoneg setting is not really fixed but configurable, and therefore, the property should not really belong to device tree. Matters are made worse when PHY drivers in bootloaders (U-Boot) also enable/disable this setting, and this can cause what is specified in the device tree to be out of sync with reality. Linux PHY drivers do not currently configure in-band autoneg according to the 'managed' property of the attached MAC. This change introduces a new opt-in feature called sync_an_inband which may override the in-band autoneg setting passed to phylink callbacks, but not to 'true' as ovr_an_inband does, but rather to what the PHY reports as supported (with a fallback to what was in the device tree, if the PHY driver reports nothing). It's quite possible that one more call to phylink_sync_inband_aneg() is needed when the PHY changes its pl->phy_state.interface and this results in a change to pl->link_config.interface. This is the phylink_major_config() code path, and if the PHY has different in-band autoneg requirements for the new SERDES protocol, we are currently not informed about those. Unfortunately I don't have access to any board which supports SERDES protocol change of an on-board PHY, and I don't know without testing where that extra sync call should be put, so I haven't put it anywhere. Signed-off-by: Vladimir Oltean --- v3->v4: - split the on-board PHY part out of previous patch 2/6 which combines them - phylink_fixup_inband_aneg() renamed to phylink_sync_an_inband() - opt-in via phylink_config :: sync_an_inband - look at pl->link_config.interface rather than pl->link_interface - clearer comments, add kerneldocs drivers/net/phy/phylink.c | 49 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 7 ++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index bf2a5ebfc4f4..598f5feb661e 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -156,6 +156,45 @@ static const char *phylink_an_mode_str(unsigned int mode) return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; } +/** + * phylink_sync_an_inband() - Sync in-band autoneg between PCS and PHY + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @phy: a pointer to a &struct phy_device + * + * Query the in-band autoneg capability of an on-board PHY in an attempt to + * sync the PCS-side link autoneg mode with the PHY autoneg mode. Set the + * current link autoneg mode to the mode configured through the fwnode if the + * PHY supports it or if its capabilities are unknown, or to an alternative + * mode that the PHY can operate in. + */ +static void phylink_sync_an_inband(struct phylink *pl, struct phy_device *phy) +{ + unsigned int mode = pl->cfg_link_an_mode; + int ret; + + if (!pl->config->sync_an_inband) + return; + + ret = phy_validate_an_inband(phy, pl->link_config.interface); + if (ret == PHY_AN_INBAND_UNKNOWN) { + phylink_dbg(pl, + "PHY driver does not report in-band autoneg capability, assuming %s\n", + phylink_autoneg_inband(mode) ? "true" : "false"); + } else if (phylink_autoneg_inband(mode) && !(ret & PHY_AN_INBAND_ON)) { + phylink_err(pl, + "Requested in-band autoneg but driver does not support this, disabling it.\n"); + + mode = MLO_AN_PHY; + } else if (!phylink_autoneg_inband(mode) && !(ret & PHY_AN_INBAND_OFF)) { + phylink_dbg(pl, + "PHY driver requests in-band autoneg, force-enabling it.\n"); + + mode = MLO_AN_INBAND; + } + + pl->cur_link_an_mode = mode; +} + /** * phylink_interface_max_speed() - get the maximum speed of a phy interface * @interface: phy interface mode defined by &typedef phy_interface_t @@ -1475,6 +1514,12 @@ struct phylink *phylink_create(struct phylink_config *config, struct phylink *pl; int ret; + if (config->ovr_an_inband && config->sync_an_inband) { + dev_err(config->dev, + "phylink: error: ovr_an_inband and sync_an_inband cannot be used simultaneously\n"); + return ERR_PTR(-EINVAL); + } + if (mac_ops->mac_select_pcs && mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) != ERR_PTR(-EOPNOTSUPP)) @@ -1725,6 +1770,8 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) pl->link_config.interface = pl->link_interface; } + phylink_sync_an_inband(pl, phy); + ret = phylink_attach_phy(pl, phy, pl->link_interface); if (ret < 0) return ret; @@ -1800,6 +1847,8 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_config.interface = pl->link_interface; } + phylink_sync_an_inband(pl, phy_dev); + ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); if (ret) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..d4b931bdfdfe 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -124,6 +124,12 @@ enum phylink_op_type { * if MAC link is at %MLO_AN_FIXED mode. * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM. * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND + * @sync_an_inband: if true, select between %MLO_AN_INBAND and %MLO_AN_PHY + * according to the capability of the attached on-board PHY + * (if both modes are supported, the mode deduced from the + * fwnode specification is used). With PHYs on SFP modules, + * the automatic selection takes place regardless of this + * setting. Mutually exclusive with &ovr_an_inband. * @get_fixed_state: callback to execute to determine the fixed link state, * if MAC link is at %MLO_AN_FIXED mode. * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx @@ -137,6 +143,7 @@ struct phylink_config { bool poll_fixed_state; bool mac_managed_pm; bool ovr_an_inband; + bool sync_an_inband; void (*get_fixed_state)(struct phylink_config *config, struct phylink_link_state *state); DECLARE_PHY_INTERFACE_MASK(supported_interfaces); From patchwork Fri Nov 18 00:01:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047501 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 C2EF2C433FE for ; Fri, 18 Nov 2022 00:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235031AbiKRACn (ORCPT ); Thu, 17 Nov 2022 19:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbiKRACW (ORCPT ); Thu, 17 Nov 2022 19:02:22 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80055.outbound.protection.outlook.com [40.107.8.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE97385ED6 for ; Thu, 17 Nov 2022 16:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kpLS6nKN0/mLULuh4ZVpX7EyAH2Lx/JcnQJwZVSrbUXmfz/pHApHy2tB/x4ariUbodhwWdlv7GAKDkvRjl5Aehl+53YjeohNy67kKzE1fy4a92UTk+9g39spAs+8RT+eoHuj/ChbgQYpIq0sesIpqRp5fVQW+XbKKd1PRZnwaidHj82T2jU26hxnQ1nv9m64xgBsjpJLEh4o1tCWksgyIQh0OzEKKvoVGZ0xs3zx0umsqALw0UWmTgfQLIF6/FuKEE2Fp6OzuUepnWZAx6eEwKBdn4Mrn+qeZNqIa+stRZixyrZb9gaI3pTVMOWOrdLLmwu701EU+AkiKwa/yLG5Yw== 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=bNELLzRNlgEkIiH2tAt7ZyTWCW71XVxUZU5dY+ux7z4=; b=XPegmth1W0EI8+dA7FkZht2C6X11dUBobONpasv4Tk4oAPsCHZfp0yjCUBy0NP4HP7MzNP8uB2b+c4HKN17SpdUYeWcyGWC6pJ4igU3hUsHyNj8Hb7v6qQQbuGUMejyPnu4Qje+PuWscg/zGAcY6VfGeU80TZB4qvz3dj2LuL0Zn0uQsBliwnne+5hYgU/bH3Yfed0tnVAmPVQ0E6sSWj4gqqiyc5bjKsBTowJSyuEcUIvaZ8xvYyAQVVjqqvSfWQWyfXPcNT1ThUe43G1gpykYO9u/3kHGLPC54D7dQg9hNT+8ZOo6D6JX0H0JpR9VZKC/t5Je/PgB46L4eVCFIMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bNELLzRNlgEkIiH2tAt7ZyTWCW71XVxUZU5dY+ux7z4=; b=SuCiElQK8c0ZIliPRqJeyBcWUc3F8fC5Nfab3q7RcarK2Zom106kOtlBKfbiMXUAjpAWeHOgXzDAWoN0KmlKRSpkz8PD1Xsb1ceC7jNO98Lppf4pUGwC6RVFKcoIAWrXfytqzAdXFNhIZozm/XBd5NBDPJm1wj/anLv30TPYtbg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:12 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:11 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 5/8] net: phylink: explicitly configure in-band autoneg for on-board PHYs Date: Fri, 18 Nov 2022 02:01:21 +0200 Message-Id: <20221118000124.2754581-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 21470a44-bbfe-4cf7-4d52-08dac8f8247a X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SPO0cxaKeN9wiFiJVmXmWas7mr+kOqabKmPyoTi+16o9u/4r/4W4ExUKzYZiAT4VXstUnt8EpE9bjoyrxJ4e+6z/E2vPffnVitHgZyGkdeBFb28l3TBgd4J9j029fpBnAkY0qKUSDmiBR/zXVhq6MMfFpfKpE6D5ujlxyFO1lYLubQcJYKxKSLffsxwjT6FAzwkEDbe+oxmjmxGzej5UPonbNjo6t8XvdAoL1Idr6sLa/9iPlPaDMjCqLDKuxLOTcy2QxHAXNUcM3cVqDXJaTq1XMtK4cy67u8QtCA6q7pU5wPumO2ZYLxlRkrUV0hb7avA4jz4OdA9Xh8DS+AshgGnZC1oXCK5SPYsxeSp6L/lYFEBpIXJ7xqU7JCxevLVBr7oNkOpvw1k3SI3AXsCcTyvPYpwPFYhPqmGaPxteCyLcnpdvwIK0LVZJNugWJN6QNftaK2/+ptwb3gmY4zh0jRADfdXqbYXDHEkmMOe3wnd00Wy/PX82F89N5vMfyP154LeKY3borZBEz0dA6wJdmU1evib0s5oH7RkeRpYMSPtguBPhpr5Tj+GFDtJcSbDF9U4yCJu4OG/TRzKJ/y2P966L/rxhbmjPsfPJ+VTGp+b51QrgCJ694rPqVR8GYqV2SbgLMSQVNe8qHK7dqF9fNXhoJv4Y6zs6lGoNc9Tu2iuPg+sQy2nlMkJRlu5NbBrf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KJKSj4tZBa0kAYEzHtU6WaCZGKLg/43/YtDgtOrLBwM21qjknjIu3vgyZrlWRdxPNUTFyDqahgR9yxW9e62YRfmpggHSVJ9jug1jsceqluFRKyy2JqGeFhSoDgyhqii4vgcJSHeC+TydvBkUd31+RZg9kkiVLtYTmouIqYhkmvGRR6TWvtwN1a13QTVf35WujvgsoOkOionpQm5+UF05E+6LLspGsj1Jrs5s34PCVM2PNL3Bupw6T+EKw2988odwQxm2mjyIl08gQShGdLsSuzEBzzmvhTfjKe0+2Y3Wg0EZJJ5+e36LTDp/OJNRt24JIFtxptW075jHQvXxAgqo5eAPVZ7xvZrtMSEMs7Fd6m4ApR1Z01w8gimupYixu8fDwrK3KuGu+ltHliC8WXLjyw30gJgD30GeWZyUzpwtA0hPXyzK8ZZvhJRw5QvbfyOoAGbYnrlgmxdB0hJYcl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Z96wDfNCjuS7dnGzQyjY7FS26DCVbd49SlXLVmnz3wzmn5D7uA7A7VEcM3ceTKg/wbXM5CyqBw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21470a44-bbfe-4cf7-4d52-08dac8f8247a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:11.8442 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kNMqmgrs3fiGVp/eOwZDcR9RWnUPfnpjRWsou5lqUH5th9sVu7jE0jLjCXIS67Czrv3wVEhyY2vlxZIAswplvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently Linux has no control over whether a MAC-to-PHY interface uses in-band signaling or not, even though phylink has the managed = "in-band-status"; property which denotes that the MAC expects in-band signaling to be used. The problem is that if the in-band signaling is configurable in both the PHY and the MAC, there is a risk that they are out of sync unless phylink manages them both (setting in PHY may have come from out-of-reset value, or from bootloader configuration). Most in-band autoneg state machines follow IEEE 802.3 clause 37, which means that they will not change the operating mode of the SERDES lane from control to data mode unless in-band AN completed successfully. Therefore traffic will not work. To ensure that systems operate under full control of this particular setting and not depend on what some other entity has done, let's introduce a new PHY driver method for configuring in-band autoneg. The first user will be phylink; the main PHY library does not call phy_config_inband_autoneg(), because it does not know what to configure it to. Presumably, individual non-phylink drivers can also call phy_config_inband_autoneg() individually. To avoid regressions with board device trees which may rely on fragile mechanisms, gate the phy_config_inband_autoneg() call with the bool sync_an_inband opt-in. Also skip doing it for PHYs on SFP modules. I don't see a need for those, so don't risk making a change there. Signed-off-by: Vladimir Oltean --- v3->v4: - s/inband_aneg/an_inband/ - clearer comments, added kerneldocs - opt-in via phylink_config :: sync_an_inband drivers/net/phy/phy.c | 26 ++++++++++++++++++++++++++ drivers/net/phy/phylink.c | 12 ++++++++++++ include/linux/phy.h | 10 ++++++++++ 3 files changed, 48 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 2abbacf2c7cb..37cdd9afd7e1 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -758,6 +758,32 @@ int phy_validate_an_inband(struct phy_device *phydev, } EXPORT_SYMBOL_GPL(phy_validate_an_inband); +/** + * phy_config_an_inband - modify in-band autoneg setting + * @phydev: the phy_device struct + * @interface: the MAC-side interface type + * @enabled: selects whether in-band autoneg is used or not + * + * Configures the PHY to enable or disable in-band autoneg for the given + * interface type. @enabled can be passed as true only if the bit mask returned + * by @phy_validate_an_inband() contains @PHY_AN_INBAND_ON, and false only if + * it contains @PHY_AN_INBAND_OFF. + * + * Returns 0 on success, negative error otherwise. + */ +int phy_config_an_inband(struct phy_device *phydev, phy_interface_t interface, + bool enabled) +{ + if (!phydev->drv) + return -EIO; + + if (!phydev->drv->config_an_inband) + return -EOPNOTSUPP; + + return phydev->drv->config_an_inband(phydev, interface, enabled); +} +EXPORT_SYMBOL_GPL(phy_config_an_inband); + /** * _phy_start_aneg - start auto-negotiation for this PHY device * @phydev: the phy_device struct diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 598f5feb661e..ca3facc4f1a7 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1691,6 +1691,18 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, return ret; } + if (pl->config->sync_an_inband && !phy_on_sfp(phy)) { + bool use_inband = phylink_autoneg_inband(pl->cur_link_an_mode); + + ret = phy_config_an_inband(phy, interface, use_inband); + if (ret && ret != -EOPNOTSUPP) { + phylink_err(pl, + "failed to configure PHY in-band autoneg: %pe\n", + ERR_PTR(ret)); + return ret; + } + } + phy->phylink = pl; phy->phy_link_change = phylink_phy_change; diff --git a/include/linux/phy.h b/include/linux/phy.h index 56a431d88dd9..6f8d5765cf0c 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -860,6 +860,14 @@ struct phy_driver { int (*validate_an_inband)(struct phy_device *phydev, phy_interface_t interface); + /** + * @config_an_inband: Enable or disable in-band auto-negotiation for + * the system-side interface if the PHY operates in a mode that + * requires it: (Q)SGMII, USXGMII, 1000Base-X, etc. + */ + int (*config_an_inband)(struct phy_device *phydev, + phy_interface_t interface, bool enabled); + /** @aneg_done: Determines the auto negotiation result */ int (*aneg_done)(struct phy_device *phydev); @@ -1557,6 +1565,8 @@ int phy_start_aneg(struct phy_device *phydev); int phy_aneg_done(struct phy_device *phydev); int phy_validate_an_inband(struct phy_device *phydev, phy_interface_t interface); +int phy_config_an_inband(struct phy_device *phydev, phy_interface_t interface, + bool enabled); int phy_speed_down(struct phy_device *phydev, bool sync); int phy_speed_up(struct phy_device *phydev); From patchwork Fri Nov 18 00:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047500 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 D6C68C433FE for ; Fri, 18 Nov 2022 00:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234932AbiKRACk (ORCPT ); Thu, 17 Nov 2022 19:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234918AbiKRACf (ORCPT ); Thu, 17 Nov 2022 19:02:35 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80055.outbound.protection.outlook.com [40.107.8.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A0170A3D for ; Thu, 17 Nov 2022 16:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RDrno0dViFrOievCkPeeui891zrcyKIDOYu62ZJaevM5B0zRL25+qbDeJ75KGYjAdGazEU0nCwzR7J7kW9aBhc/mJysY4p8F/p60oOignn4yjB1ANMTfShC39ZOqRNg71AO/X3olWEod1VFh9PCTLOl758ic1nMo5HNIurikxp8hhY1GThgRbM+gYegu6HMkPKV9H32P6YKpiwhNMkqK2LALHtC54Qe/KMIjhVGPL6UYCeMDOS7ETaAWUMobfYWhdVRiC/a2RuqxnZNdmq8qOeMktNP3xJ580eldV8Q1Xd0sJbJTNXlRfdm1rpVbUi7gG52CsQNZe+pTtQFcJ0I5nQ== 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=kipTAyY2yTKAxDyz93sKuyP8zYe29Z4rE2FHylNMarA=; b=EFg3QL8Bs+151hYEVW4hE+VAMfMEQKU6u+lIJ4hqR6mFnprASAwfPNbodU12r/VAiOV/cTZYaiVXgg95kK3y37D3fzqsWhccpTwUFQ+u6Q5uLFZbUTfbnJL5UjJRRjX8OREFpcVVBM1bZd3pFf8hkiOpmd6cMz5iGaxIEOuDvXHSNI3QjOa1pfcJI5WuisAXiFpNVxw4JHEAwEjJt3iqpMlYTjkunLKNGlH2w+V6vaZsvKb3QkcrLnZRFi7LAjY5z0zdiTNoE8Tsy7INXkOOq9DwioW6dnJUw8A0kd0dKturUthx8EWWkLuUUQEHA4IbdQ3tC4zf3oS6CfxCfTbaJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kipTAyY2yTKAxDyz93sKuyP8zYe29Z4rE2FHylNMarA=; b=hksyEOa9ikvLuQ3vTmSZEWetNu4ifUzrKK58OdwICb8mTHVvM0Viw2mOJMwFgI+w75A64a5IZylD3yNgmi8i7W9pH9Q5ctuXkAt9jOu/sA4tJlaegLm+zE+a598QzyLR3/QIhinzgiv2pGoubo2ELTAT5PfCHg4Z+wyTjvDl39A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:14 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:13 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 6/8] net: phy: mscc: configure in-band auto-negotiation for VSC8514 Date: Fri, 18 Nov 2022 02:01:22 +0200 Message-Id: <20221118000124.2754581-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 226176f5-30dd-46f3-d71d-08dac8f825ad X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FP2mYW7OxRnU5vsAcBUBXkIGavxpbjy/PxWaL9L8nf78Hg4X83SARhjlWrEPnWVaWpYYXD1WWsXJX6uM9nEYXMnbyiihX9wrzAv/HXNmn+mjKkkhByvSOh5wsnke2T8voO9cWyjpDTlGWV/6uTxzkikkT63KQEw+GuXUzPZ9nTWbu+j4i9RkZn5cr7KbPtSwo/ErumhIHHGaVTXAyNy5ulgNxLI06HSaolKd6OOZzI9Y+wthpQiyaPhRUJSNyC89sG6vO3C9pJy06vUjbBxl0cpZgfMFV/rSfR+qV1pNOtKbov/99JYQNmLrZS2HJmlhEa1eybSha3Ki4SATe0BvReP5Qb0jcOU4r4xF73AuZzCLqNFvRdlAle8Z2aDG2nBb4DqXxxh8+crKG2m/zTcy6kxxMVjV5Rv6XCGLmRF0/eRqX0TQxnj96SS1CLk5d3gPNHJyGwgruub8tkZYE7za39UGGSpn1nue8E5agvG3sZ8n0QUMtCsRhQPa+Mgt48TQK3zYBpzeSTjwdUhUoM4kcskPaX4p4PnnH8SlrctOyamJR8/8j/AYJ/Cfe624YdeCDIPYARYz3RxUIuqY5CN+fFmU34PxxQmS+7bFTsL52wS7d33BUslenbENdCdWLJqctLeKsTvXIiZHICnz+wEOnM/LUBQMIaniKwJebQfSApstM9C8XOko2YNJUou53WtG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NjJbk3Z6T+0X8x7vmq8mgRPRMJwJyhy5T3ZfcGlVIeCV6QmhxNaHjdmEL+HBsQWi2N68HKeb4+QTCEESSA9dBguqC2w5h4/7uBKAH7dTmbul/84j4Z7T/3vp5J5snPxlOIg0RqaK9tTJ6k34l9Ar03c+Zo0rTmwhLU6ONUFH9+BsHgOt2qFUQgGwh4X/JkxKsw0xg6BIc693YttWj/DP1lrO0UcdmEyYUp+gr7xtn7QJbhWaSpyfQniAOXqOJli8EsiEgjZqbjhIBY57K0sUxVoTI7zV3uM132HWJz0o+/Xc19Dlv8bSr+IOQtcovZj4GExOpcu+NSkHBwE2SwH+ykWF2ofjkkqsPZn74/D5s53c0K/L/76OH6Cl2nLBoBJH/j11NA4TQxFbmpjGnRo4y8M3GDiftO8mt3smjxozAt8BisfgZLxH8iUJdCJ05/XE4cf7Z9KJjPN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nXTuMsP7blpH9un+A/LaxXg4cuF8e3OjJcKZuevFWOa5PUhoDS1w5NoQ9tWTFt+i7+lqjHk7usf22wH89w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 226176f5-30dd-46f3-d71d-08dac8f825ad X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:13.7972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IzXw1/ruFzjTB5fgCrdJov2nTFTuutEeH3FZKtn6UNYPaHvMa77uDtsTwjvdY3it5eWMEveONzq6lSmxw+D6nA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add the in-band validation and configuration knobs for the VSC8514 quad PHY. Supporting both ON and OFF means that the mode which gets used in the end depends squarely on device tree, and the PHY adapts to that. Tested with QSGMII in-band AN both on and off on NXP LS1028A-RDB and T1040-RDB. Signed-off-by: Vladimir Oltean --- v3->v4: s/inband_aneg/an_inband/ drivers/net/phy/mscc/mscc.h | 2 ++ drivers/net/phy/mscc/mscc_main.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h index a50235fdf7d9..366db1425561 100644 --- a/drivers/net/phy/mscc/mscc.h +++ b/drivers/net/phy/mscc/mscc.h @@ -195,6 +195,8 @@ enum rgmii_clock_delay { #define MSCC_PHY_EXTENDED_INT_MS_EGR BIT(9) /* Extended Page 3 Registers */ +#define MSCC_PHY_SERDES_PCS_CTRL 16 +#define MSCC_PHY_SERDES_ANEG BIT(7) #define MSCC_PHY_SERDES_TX_VALID_CNT 21 #define MSCC_PHY_SERDES_TX_CRC_ERR_CNT 22 #define MSCC_PHY_SERDES_RX_VALID_CNT 28 diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c index 8a13b1ad9a33..f136782fd995 100644 --- a/drivers/net/phy/mscc/mscc_main.c +++ b/drivers/net/phy/mscc/mscc_main.c @@ -2189,6 +2189,25 @@ static int vsc85xx_read_status(struct phy_device *phydev) return genphy_read_status(phydev); } +static int vsc8514_validate_an_inband(struct phy_device *phydev, + phy_interface_t interface) +{ + return PHY_AN_INBAND_OFF | PHY_AN_INBAND_ON; +} + +static int vsc8514_config_an_inband(struct phy_device *phydev, + phy_interface_t interface, bool enabled) +{ + int reg_val = 0; + + if (enabled) + reg_val = MSCC_PHY_SERDES_ANEG; + + return phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_3, + MSCC_PHY_SERDES_PCS_CTRL, MSCC_PHY_SERDES_ANEG, + reg_val); +} + static int vsc8514_probe(struct phy_device *phydev) { struct vsc8531_private *vsc8531; @@ -2395,6 +2414,8 @@ static struct phy_driver vsc85xx_driver[] = { .get_sset_count = &vsc85xx_get_sset_count, .get_strings = &vsc85xx_get_strings, .get_stats = &vsc85xx_get_stats, + .validate_an_inband = vsc8514_validate_an_inband, + .config_an_inband = vsc8514_config_an_inband, }, { .phy_id = PHY_ID_VSC8530, From patchwork Fri Nov 18 00:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047502 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 15F2FC433FE for ; Fri, 18 Nov 2022 00:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239145AbiKRADE (ORCPT ); Thu, 17 Nov 2022 19:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbiKRACh (ORCPT ); Thu, 17 Nov 2022 19:02:37 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80055.outbound.protection.outlook.com [40.107.8.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A744B85EE6 for ; Thu, 17 Nov 2022 16:02:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReiOQpDe+44764rpNyKicRhUNH48cRSGaeb2MWRlXLwqOyDe+xx+ISzThGXgKiiDD8O+DiZaLZPD69k/il7y7h9kUU8R1m8MW2E4tsF8IgIa/8odI7QcZTG+3v8076bk7sVBbtve1G5bZp/gjpKWUze1Ov79gLKtshPcLlZ10d9SkObGa8AZxifK4O9nGjDLJhR2sRALtG77rCAhGkLwrRQU/8ukgZa7tLC/g0TFX1QWa8sMYgBv6Mlb1z1dlEbHoxutbLfS6gv2i0FOc1+ZQWdE40UY3g7wGUL0u7YXn9Btx4j6MgLCioMQ5lcA+0bbQkh4ukqv7McYkAhcLYnlKg== 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=D8PojE3JIbTS1j4f1EyOrFsVgSisa8C9hc4iU3XHaJU=; b=hSMuedZwadQRGRwJiioIJUy7dFBZD1Bo74nF0dZe0COHMR3BR8SKhDuIjAZ+5sfJKswhaLqhEnefSjQQ6jDbNOmI48kzyQuw7dvWpFWcriHqJogBV4x/gn0f7A5E8NEKyMkjKM9ZwMskRJ399NmV//KU+gC0C2aQjnglkp5OpAbiTkEqfqB65jLiVFGnsAKNDyFQk4lyrNvwPBfnCTjfQeYEfyauAZUGP+epI/hqgWqHcr+NKrIgTaN+LwIc9q8UIU0oFKrjupHwb5iJxy3RdgxTXL8c0S/30RMpOuDeiJNVe4BbqpoITwzg/BlLJPLGsI/Kak8X0t0T8NjJsfd8Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D8PojE3JIbTS1j4f1EyOrFsVgSisa8C9hc4iU3XHaJU=; b=AlPhDEQ0iYcjvDSPb317jUMCjmqkDDmRp0Dksy5UoxeU3otTqwg0d4B7/2vv8OmwwFLEnv83PPI3EAM2ncowKih5ADrG9BpAYXjB1TddzZHbc+pA8k1BjRtn3jfthFCM2Amnvs0+CNiPd+UYYU8ZnU20/ymbY9l4degXadvE/oo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:15 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:15 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 7/8] net: phy: at803x: validate in-band autoneg for AT8031/AT8033 Date: Fri, 18 Nov 2022 02:01:23 +0200 Message-Id: <20221118000124.2754581-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: 429a3131-95d5-4ba3-ec1e-08dac8f826cb X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XaIe4XypwfYrB+gUk4CrvfQPsx7H4m+2SS42sLpN2Tzn+MVQRe4mwsrdotN7JPPAz/wmVcKJgnzSg7XNDBVwLtncCsTE0cvhw1cyVg+P43yZ/SCjvP679EQa8lvAuuC+Y9Su+dHbiJt/4xoqjYR72YDKc89mX1cYY6kolZ/QA4xaQMwZ/3xKZe7xM/HMJ9RAKI3vnzIbOP8SYbSEZCDJ5mpc4hzKrYVWcGa+C0hP3Rs9RtjKqB7LXYCrEfO4SXWxr02kzhcSwfuP5Nu6iSu/wptcal9/ZxcxnGLiozKHERI9V9l7UmvzWTCNiIq9LlEvseomFMrT3SGWGvrLIMQ1CRyakLxvRKDxJLZFz3yIgo1iffyRKt4nDl6ebAYi8G8KDNwe4yQAruqK7bIXE7OkYMJoHn5Vb0CbsI1PirmcapGISnpxpnHEGkuvqkdJ8lwhSngx9qqeGaBO71gH+65X/lzVDDvafXlS+fViNnJcdCQLqyPjvyy7orsMcLjImvQLgrAhH0ZuAuxKlnFRv9zaYhikof0IqQC+K2bdYDFfG7/Y5U2YhSMw20UAUVPuXMk/Kwcz+Sd54o8Mtcr96/jwX3zMyTpoIQL9CVhi4XYCrlTfhWnaH+d1cdelPmNZvWq+3w+l5WI7XTHJ4BN2Q1i2ujQ1Wr8lGSYbCGgUtt97Fq0kvXGU7DdsaC6+fYWJVcJPEmTTCbvtkl188xEKj6KSV11AnpIc13kc8xDpIlBgbKc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(966005)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(15650500001)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n+czTti1tdbncreoJ1K4hhgijUFZD7XCoVjJWNxCcSxh2Jin0U2U6IolQcVTQltSq3v9gUxGOeDPRcxinjalxT0OdoJEQMwTxPCBR+iOIgMtwYT2FPScNcNcWc9SptGD65iehAXsBN4+oULF+fyhgzvF8PemkTJpUHO+pTeKf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R09wvtjcz3HT4F2Zr+f7YwGCH02QCR2EcT79DYCTXp/BQ3a2+ZccLDeKMVY2UpvJJ0BHLPIJQv8AdEWQ5AxdVXs8tzkMsYfm+NtIHLnOxiWhA2LeOV7+4WVmpe3xBUDGpviumcPGgGkBDfMaZqENs9u6xoeCfuBMDw5ZjfC+EDhCd0BiJJNojTD1fx0+fdc33I+LjvQ33fCweNihzuNNIzd0VvaR0iGXws7hBKjd7xWNaR4FYILgc3Bsf0XFfZiaehyzdcRwmTzueBNq9lJTZUnJJ2fNq3oDz4VmZVQO6R51RLX7R7qPZpsoCI7lrvl0XXgnul+nzQtdIX5dSc15RuQX1nj7bGNpss02GPXylix5MpIodv54ZhzBk+0glgxYMAB9Pw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 429a3131-95d5-4ba3-ec1e-08dac8f826cb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:15.6876 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LWEM0mJZbHcILn3ViSezx+mgUK8HHPkqcw401NcpZLtF7b4R9YVY/FlS9fbgsnctCo7i1ZClyqOcnmE2wND4PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Allow drivers which migrate from phylib to phylink and have old device tree blobs to work with the AR8031/AT8033 on-board PHY in the SGMII SERDES side mode. This would allow DT breakage like the one fixed by commit df392aefe96b ("arm64: dts: fsl-ls1028a-kontron-sl28: specify in-band mode for ENETC") to be avoided in the future. We know from experimentation with NXP SoCs that the PHY doesn't pass traffic if in-band autoneg is enabled but fails to complete. We also know that it is in principle possible to disable in-band autoneg in the PHY. This would require disabling autoneg in the fiber page, and then keeping the fiber and copper page speeds in sync, as explained by Michael Walle here: https://patchwork.kernel.org/project/netdevbpf/patch/20210212172341.3489046-2-olteanv@gmail.com/ But since the PHY driver does not currently handle the complexity of keeping those speeds in sync, we can safely say that no MAC attached to the AT8031/AT8033 in SGMII mode has in-band autoneg disabled. I have no motivation to add support for disabled in-band autoneg. I just need the driver to report that it requires this enabled, which will make phylink promote a MLO_AN_PHY connection to MLO_AN_INBAND. This is enough to keep everyone happy. These PHYs also support RGMII, and for that mode, we report that in-band AN is unknown, which means that phylink will not change the mode from the device tree. Since commit d73ffc08824d ("net: phylink: allow RGMII/RTBI in-band status"), RGMII in-band status is a thing, and I don't want to meddle with that unless I have a reason for it. Signed-off-by: Vladimir Oltean --- v3->v4: - s/inband_aneg/an_inband/ - drop unnecessary support for PHY_AN_INBAND_OFF drivers/net/phy/at803x.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 349b7b1dbbf2..2ef6ac92fecb 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1355,6 +1355,15 @@ static int at803x_config_aneg(struct phy_device *phydev) return __genphy_config_aneg(phydev, ret); } +static int at803x_validate_an_inband(struct phy_device *phydev, + phy_interface_t interface) +{ + if (interface == PHY_INTERFACE_MODE_SGMII) + return PHY_AN_INBAND_ON; + + return PHY_AN_INBAND_UNKNOWN; +} + static int at803x_get_downshift(struct phy_device *phydev, u8 *d) { int val; @@ -2076,6 +2085,7 @@ static struct phy_driver at803x_driver[] = { .set_tunable = at803x_set_tunable, .cable_test_start = at803x_cable_test_start, .cable_test_get_status = at803x_cable_test_get_status, + .validate_an_inband = at803x_validate_an_inband, }, { /* Qualcomm Atheros AR8032 */ PHY_ID_MATCH_EXACT(ATH8032_PHY_ID), From patchwork Fri Nov 18 00:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13047503 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 E41E9C433FE for ; Fri, 18 Nov 2022 00:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240437AbiKRADH (ORCPT ); Thu, 17 Nov 2022 19:03:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239809AbiKRACh (ORCPT ); Thu, 17 Nov 2022 19:02:37 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80055.outbound.protection.outlook.com [40.107.8.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9FE85EF2 for ; Thu, 17 Nov 2022 16:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M23HgAjU8fBU9WxEH/yYXQJmDrBS/RUc6agMvy2rOjImhzM6LRVLUp/tCKnNF0+jaSbN54kS1uS1zv9bJTVkwmsiIsvzAL+/5BGc96HpZ3Cfhhh2dekeoyAAI4JFstAI6hDUGXFeaUgs9wJYNJ5n1oQ8iFcfu9Zs2Dkttrf8fQT3whSCcVMVLWchX0FbvCnjNEjlZxYSBVzG8Qblk58aHCzQrY4Jr3rg34X6p9QdBduKfdW10sUfNOGQBeHq0qUvZcjOrCNAmG7SLMM8bfWtfvoOu38RCmT5tysvrsw1CWVhtsIMYb/WQFuDsLdKrz96+G5TvIyFj+87U7yNVeZD6Q== 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=q+/1l92qO7xH2CsN9qdGpylmgxPKoDmzkxE6/s8Z2zo=; b=X5+SNe/SWtRaz8/jRRzX1kGgQDHa2JrT9UxEhSdIwCfoy2YfEUyF34eRl1SemH5habFjP6T6QwTljnKWDQSrCR5oHOLtfolwRgCeVuU4Ixfnhb8qp1No1RV+d/18fu/pM84XGNOshXehIyBJJo0IdhrlbK3EN1Fxc8Gnqfhp57kr84gt9PZZyaJMOgjQNPPtOu/f08A5Gl3695pDuviDF/fcBvF/mY5lbxaMPIGtnyge7Vm1pdxQV8BunfqC5Gy6sa7b24nfFrf8UgGcbwR4zFeLUoeRC8+7oSAqMv6ymkk+uX/MLBsw64x5gmpiWrmBA2GeMCEJbAcm6sC6epHUew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q+/1l92qO7xH2CsN9qdGpylmgxPKoDmzkxE6/s8Z2zo=; b=Gz/RDYZDF9yHHtjw0FcGKltsYwefc9krfa6813jrIOQzyGXXZokH0w1EXxBGSVEMz42n2WXjb9TWSB02AIikmZ0424F3yfB4QW6zKCmoaUKlGPNsqLtP3jJT/klmyJrBDGfOQoe2rHoLi9x8nbWTeunFsmEZN9mxxPmo7bXP8hY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8542.eurprd04.prod.outlook.com (2603:10a6:102:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 18 Nov 2022 00:02:17 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::9317:77dc:9be2:63b%7]) with mapi id 15.20.5813.018; Fri, 18 Nov 2022 00:02:17 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Andrew Lunn , Russell King , Florian Fainelli , UNGLinuxDriver@microchip.com, bcm-kernel-feedback-list@broadcom.com, Madalin Bucur , Camelia Groza , Claudiu Manoil , Ioana Ciornei , Maxim Kochetkov , Sean Anderson , Antoine Tenart , Michael Walle , Raag Jadav , Siddharth Vadapalli , Ong Boon Leong , Colin Foster , Marek Behun Subject: [PATCH v4 net-next 8/8] net: opt MAC drivers which use Lynx PCS into phylink sync_an_inband Date: Fri, 18 Nov 2022 02:01:24 +0200 Message-Id: <20221118000124.2754581-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118000124.2754581-1-vladimir.oltean@nxp.com> References: <20221118000124.2754581-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BEXP281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::16) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8542:EE_ X-MS-Office365-Filtering-Correlation-Id: ee5ca32e-06c9-4216-c5b7-08dac8f827ee X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P8qIiPHhP3vz8jqpKc2aEfVJtci1bb9h6hn2s4ld6rLrSUlk5UkDBJ/mTWTP+9HJlfwl1d+/Z08tm37lL1YQTHo2sw2oNkmCBZfpKSWUGnsNvemv2qdplRvfOq1csAVOPzQuCZqzCrFF1O6C8wQ+TSD2Ojav/jBRSqIYS2ODUUA056dUxceA7SogUm7rNx5Ua0AC+7L56MonvZzuKY/evcjijdvH0D93D4MhyihimquVRUPuprlDo7Xzb+7w133kYyziH0QgUA4iVFjnH2++VsvadrcgUqgH07R90ukcNd7+98Pkm89vtrx6CDspzM35tmb0y9xeHdtJoLTRdHCupCuFVcYIEXs2g2eilewX9EgjJR+CEr5aGxa7s8H/yv2MCB5LOmd2UkDRhDjHTaBw60Fn2E2krfpHEZc9kf44Q0Y1GKPwIJveznbnl2CFwluzNdX4KO1xuX+4Eo7kilDKXjtoIzuTOZ866P8DG/mu5+YOiFcLVi5rJ/1pO5DOKvYJ3XU1tGLmLZg3rQYp9Oj2VG+TKyyY1xsRADLL0LvlfONoaM6f1trF36gUDJErqsLrNZGbqu7hNasxcEWYopaQmjjwrX55D7ReAdIyV9r4K1kscaQogMAyukJwZ6uYTkIwyYbab9KBBzb8PmyIAeFkA9bsq14ASDOuqnDWbBSQVLcgUT2BXcGFvS9aWco+3XuY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(366004)(39860400002)(376002)(451199015)(478600001)(26005)(41300700001)(6506007)(6666004)(36756003)(8676002)(52116002)(6486002)(4326008)(38100700002)(44832011)(7416002)(8936002)(2616005)(66946007)(66556008)(38350700002)(6512007)(66476007)(186003)(316002)(1076003)(2906002)(54906003)(6916009)(86362001)(5660300002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSp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SYe9tETPmxVCBe4w3Balx1+uiJ3kwAyD8CvF7uaCmawkLhGxxYo8FAQcs4zLkfsFMu00jVag95L5Dw25hzCHQ6PuI7jjvXXlhhwWUS5bQk5b42ltN2UPWipzCldY7pU93F6FWgEGPAryfGlfz/HkJvg6fKxohy9t2w3Mz+YuC57X3rZpzhE99Xi4UuP1OIqsW3sfWh+rgF4ePYMBqMg+O0A6fGs0a27u2SmpaFkUZeT+avXjExqk7OkVgKK0TlryGb5bgzS4qOeNBRjxdVlsynYcDt3r/x26YsgCFBciJKbRMqaY80z2Xf0ZSWSqp9ZMZKHv+rvDLHfULqxBFUrciTQJ9L16LvBLOfiepEgo7177nNAYhQjlkss5tWkk+5eaQ9moTd8kTmabPGY3yXju3SRyGyqFreOudwZLu+0WE0odjuUkBhuANmOXjJ66oE3dUPf6wp4xn8b+xN6UCoNO6w4HRZzr4y16wRoIHwBGxijzo3bjFouV6MGTIZp3RiAUVPx4MwzhAtkNAo3nn+HTScNkUh44PIwmo2tlKB4GE8wJ/1pa9NlIL2tNd1TnAxpbTw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee5ca32e-06c9-4216-c5b7-08dac8f827ee X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 00:02:17.5625 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dtaYdTW9uDNNByRdbwOYiGxW0ibp08yzCpw5JHkLD+lAEqtj1NblX6kmzwsktf9a8lNHlFyC6LtT+D76ESAwlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8542 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org lynx_pcs_config_giga() enables "SGMII AN" only when used in the MLO_AN_INBAND mode. If it's connected to a PHY, it expects that the PHY has the in-band autoneg setting in sync with it. To fulfill those expectations, set the sync_an_inband field in the phylink_config structure, to opt into the new phylink behavior which does the following to help with that: (1) queries PHY driver to figure out a mode supported by both ends (2) configures in-band autoneg in the PHY to something supported by both ends The Lynx PCS is integrated in DPAA1 and DPAA2 SoCs, as well as in LS1028A (ENETC + Felix switch) and in the T1040 Seville switch. It seems that the DPAA1 phylink conversion already took steps to prevent breakage with old DT blobs, by using ovr_an_inband. That is partially sufficient, partially insufficient (there is still no guarantee that PHY really has in-band AN enabled). Remove that logic and simply set sync_an_inband instead (setting both isn't allowed anyway). Signed-off-by: Vladimir Oltean --- v3->v4: patch is new drivers/net/dsa/ocelot/felix.c | 2 ++ drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 1 + drivers/net/ethernet/freescale/enetc/enetc_pf.c | 1 + drivers/net/ethernet/freescale/fman/fman_memac.c | 16 +--------------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 44e160f32067..6deff681c02d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1042,6 +1042,8 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; + config->sync_an_inband = true; + /* This driver does not make use of the speed, duplex, pause or the * advertisement in its mac_config, so it is safe to mark this driver * as non-legacy. diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 51c9da8e1be2..61d31ffb5d97 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -406,6 +406,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) memset(&mac->phylink_config, 0, sizeof(mac->phylink_config)); mac->phylink_config.dev = &net_dev->dev; mac->phylink_config.type = PHYLINK_NETDEV; + mac->phylink_config.sync_an_inband = true; mac->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10FD | MAC_100FD | MAC_1000FD | MAC_2500FD | MAC_5000FD | diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 9f6c4f5c0a6c..c0d4fff00987 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1126,6 +1126,7 @@ static int enetc_phylink_create(struct enetc_ndev_priv *priv, pf->phylink_config.dev = &priv->ndev->dev; pf->phylink_config.type = PHYLINK_NETDEV; + pf->phylink_config.sync_an_inband = true; pf->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD; diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 9349f841bd06..e4a707a7d7f4 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -1075,7 +1075,6 @@ int memac_initialization(struct mac_device *mac_dev, struct fman_mac_params *params) { int err; - struct device_node *fixed; struct phylink_pcs *pcs; struct fman_mac *memac; unsigned long capabilities; @@ -1219,6 +1218,7 @@ int memac_initialization(struct mac_device *mac_dev, capabilities &= ~(MAC_10HD | MAC_100HD); mac_dev->phylink_config.mac_capabilities = capabilities; + mac_dev->phylink_config.sync_an_inband = true; /* The T2080 and T4240 don't support half duplex RGMII. There is no * other way to identify these SoCs, so just use the machine @@ -1231,20 +1231,6 @@ int memac_initialization(struct mac_device *mac_dev, of_machine_is_compatible("fsl,T4240RDB")) memac->rgmii_no_half_duplex = true; - /* Most boards should use MLO_AN_INBAND, but existing boards don't have - * a managed property. Default to MLO_AN_INBAND if nothing else is - * specified. We need to be careful and not enable this if we have a - * fixed link or if we are using MII or RGMII, since those - * configurations modes don't use in-band autonegotiation. - */ - fixed = of_get_child_by_name(mac_node, "fixed-link"); - if (!fixed && !of_property_read_bool(mac_node, "fixed-link") && - !of_property_read_bool(mac_node, "managed") && - mac_dev->phy_if != PHY_INTERFACE_MODE_MII && - !phy_interface_mode_is_rgmii(mac_dev->phy_if)) - mac_dev->phylink_config.ovr_an_inband = true; - of_node_put(fixed); - err = memac_init(mac_dev->fman_mac); if (err < 0) goto _return_fm_mac_free;