From patchwork Fri Feb 12 17:23:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 382710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FF30C433E0 for ; Fri, 12 Feb 2021 17:26:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B18464E89 for ; Fri, 12 Feb 2021 17:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231339AbhBLRZh (ORCPT ); Fri, 12 Feb 2021 12:25:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbhBLRZ1 (ORCPT ); Fri, 12 Feb 2021 12:25:27 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0092C061756 for ; Fri, 12 Feb 2021 09:24:46 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id w1so351996ejf.11 for ; Fri, 12 Feb 2021 09:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P4V6Y9BMlBScqu2WRe4FMpH2XCbfD+bQLjaALaGEcX0=; b=gGl763Bta1PpfzwbHCXlrHScA6EM5FwrVFxbMasBLOC+ciUPRQ1MeH4/E6/IyOWCaI CZAt61dwKudsUlqyKCgSxr8yLmLb7bmGPPXsRsCJ4Pb0MfiNuihzb1rirOQjfuhezTvo P9LbNcj2ME+5RUWa8m+fOa6J30UNeJq0gMPG/4AXgnjL/ubstOMWWCR+izc/r73x4mg3 fpZEErBZwhqz/34vt0Q5E8dCvL/1GVKnLqbwIfx8QR8YrtWrH6Sg99f4HfTo2x6Rn/+m Fc05Nfnj+XaP2VskrdV18kaovXvo8M28BtK7kjxUL/f4+M8/g0qaTdTCF7NhtQxXiKrg uoxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P4V6Y9BMlBScqu2WRe4FMpH2XCbfD+bQLjaALaGEcX0=; b=nIlopKWTcjb0wgNSKG1RjFYPG9G8MW2iirk6o+OZUwU/V4xhS4xcgJskgop/kWLmu/ ZD+o51LfWxpbAjrqMXTd829Pb4Dr+2XdlTTjFm66nEY69PtVpOdIyk+wckZlhVNOcCr1 U1v7DfHyAwhrZVXkgfioYqf9nRPj3/X0ybPVHlFs9BVIHglZXC7639lXet9pYlfp9MrS TC+LO4KMjfAOLwk20xgAqAB72CHdmnLevy02AlKgWP51/f3e//dlwU5CXJB3Qd4LcTbi JFJ39Ixf9g3HPnx0kzrKnyVxczoLgdp1pVoaMW13AQ2CecyQNibdEvHWErU9KxreuI6v 0cag== X-Gm-Message-State: AOAM532lzqPxgrKIx9svUc/ixybVxoxA/SEDP3Ju8jD0i3Z+wwgyZnt+ 0KQljugwnM8OmgdQBIwWgS0= X-Google-Smtp-Source: ABdhPJy/ksvidVyQEWOvUxOWc5JGkim09qK8wMPbuPcwOi+kwrikLNeV3MLt5n/yZf92T7mEScNNTA== X-Received: by 2002:a17:906:1447:: with SMTP id q7mr4203966ejc.27.1613150685653; Fri, 12 Feb 2021 09:24:45 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id x25sm6061616edv.65.2021.02.12.09.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 09:24:45 -0800 (PST) From: Vladimir Oltean To: "David S. Miller" , Jakub Kicinski Cc: Antoine Tenart , Quentin Schulz , Michael Walle , netdev@vger.kernel.org, Heiner Kallweit , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Ioana Ciornei , Maxim Kochetkov , Bjarni Jonasson , Steen Hegelund , UNGLinuxDriver@microchip.com Subject: [PATCH net-next 1/2] net: phylink: explicitly configure in-band autoneg for PHYs that support it Date: Fri, 12 Feb 2021 19:23:40 +0200 Message-Id: <20210212172341.3489046-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212172341.3489046-1-olteanv@gmail.com> References: <20210212172341.3489046-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean 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 really 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. Most if not all 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. It is particularly unpleasant that currently, we assume that PHYs which have configurable in-band AN come pre-configured from a prior boot stage such as U-Boot, because once the bootloader changes, all bets are off. Let's introduce a new PHY driver method for configuring in-band autoneg, and make phylink be its first user. The main PHY library does not call phy_config_inband_autoneg, because it does not know what to configure it to. Presumably, non-phylink drivers can also call phy_config_inband_autoneg individually. Signed-off-by: Vladimir Oltean --- drivers/net/phy/phy.c | 12 ++++++++++++ drivers/net/phy/phylink.c | 8 ++++++++ include/linux/phy.h | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index fdb914b5b857..d6c63c54943e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -748,6 +748,18 @@ static int phy_check_link_status(struct phy_device *phydev) return 0; } +int phy_config_inband_aneg(struct phy_device *phydev, bool enabled) +{ + if (!phydev->drv) + return -EIO; + + if (!phydev->drv->config_inband_aneg) + return -EOPNOTSUPP; + + return phydev->drv->config_inband_aneg(phydev, enabled); +} +EXPORT_SYMBOL(phy_config_inband_aneg); + /** * 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 84f6e197f965..ef3e947d5019 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -978,6 +978,14 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, return ret; } + ret = phy_config_inband_aneg(phy, + (pl->cur_link_an_mode == MLO_AN_INBAND)); + if (ret && ret != -EOPNOTSUPP) { + phylink_warn(pl, "failed to configure PHY in-band autoneg: %d\n", + 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 c130788306c8..2260b512ffbf 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -746,6 +746,13 @@ struct phy_driver { */ int (*config_aneg)(struct phy_device *phydev); + /** + * @config_inband_aneg: 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_inband_aneg)(struct phy_device *phydev, bool enabled); + /** @aneg_done: Determines the auto negotiation result */ int (*aneg_done)(struct phy_device *phydev); @@ -1394,6 +1401,7 @@ void phy_detach(struct phy_device *phydev); void phy_start(struct phy_device *phydev); void phy_stop(struct phy_device *phydev); int phy_start_aneg(struct phy_device *phydev); +int phy_config_inband_aneg(struct phy_device *phydev, bool enabled); int phy_aneg_done(struct phy_device *phydev); int phy_speed_down(struct phy_device *phydev, bool sync); int phy_speed_up(struct phy_device *phydev); From patchwork Fri Feb 12 17:23:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 382232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 914B2C433DB for ; Fri, 12 Feb 2021 17:26:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2817A64E92 for ; Fri, 12 Feb 2021 17:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231557AbhBLRZt (ORCPT ); Fri, 12 Feb 2021 12:25:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbhBLRZ2 (ORCPT ); Fri, 12 Feb 2021 12:25:28 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 377FEC0613D6 for ; Fri, 12 Feb 2021 09:24:48 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id y18so551537edw.13 for ; Fri, 12 Feb 2021 09:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bh0BqV3JwCvPqAI5uWtLopwKQ8wNwNF0Xbt77Fqb3FA=; b=fgYRXdXY33swqusM2bbQp1Hpi/TQy2LfxVUoJ8186Hm/aISCaIvZ+52z6jT5tX6mkl tfPMaSSdGNulfd7vnObIcRLN5NtbhKFfQLyB4A9UgPpVhxPr4r5AVwWmf+1W4tRLeoDG uW+5io9y9OEgboG1Q/Dp8XMhpDd3pm6V5AYSXbiYzeupKyptX+fLCBjOzH4FJN72Seya b5Bk+0647twYiXDwlH0NJ9KdqUYq5R260Rv8kuXQ933mBurX3PIVdbuI/DF6CPS/m6Pv 52sjiv92Jvl8qrH4hf6douaVXttLfqnaYwD7d1uZg1ofyJEVffNwnfuoSxbpXXsqV1P8 Dw1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bh0BqV3JwCvPqAI5uWtLopwKQ8wNwNF0Xbt77Fqb3FA=; b=JONA4aeN5dQqvUkiEBysIy1ISXmujwkfrl+7gQjr28kfL5vhotWMda73Ec2Rui9j4K //Mhr6OHzzdqgbyM20ncTND46XQZhR0agH1dvMU84cF7VuM+WI1vgj8g5IvwRamU8xHF EyaNkKAtwaIMU9beOSDlDKg3wiMk+/oNTOEr8OMVezyAPaoOUyGO1WgZ33oiYW6DHR0w BZ5bJi2zX3n84m6/tpk467O/iAref7qW8b5yfRE8IwQJJynCSQEcWBNUvRJp6XTcPH2a Kwv6LVb0eb/JHn7BINI0oTUKARKK7gP7PQpMvI/5u8tZpXAjNAeR8lrhd07n2NnZaNkO fbug== X-Gm-Message-State: AOAM53058pMN1of4uA0vbvPlyPcAvjfmX1oMHD4Bre+4gmlFBJWWqiH3 a7g27tEI+vsI4nDu3CsBkVQ= X-Google-Smtp-Source: ABdhPJxCnWVNR9VfJrXHiyiVZcVQzcpWndkGrHYLDYPpD2uq//mU8zNmMfrfGxIuMlD6AGwjZRc/mw== X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr4308573edb.16.1613150686998; Fri, 12 Feb 2021 09:24:46 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id x25sm6061616edv.65.2021.02.12.09.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 09:24:46 -0800 (PST) From: Vladimir Oltean To: "David S. Miller" , Jakub Kicinski Cc: Antoine Tenart , Quentin Schulz , Michael Walle , netdev@vger.kernel.org, Heiner Kallweit , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Ioana Ciornei , Maxim Kochetkov , Bjarni Jonasson , Steen Hegelund , UNGLinuxDriver@microchip.com Subject: [PATCH net-next 2/2] net: phy: mscc: configure in-band auto-negotiation for VSC8514 Date: Fri, 12 Feb 2021 19:23:41 +0200 Message-Id: <20210212172341.3489046-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212172341.3489046-1-olteanv@gmail.com> References: <20210212172341.3489046-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean Add the in-band configuration knob for the VSC8514 quad PHY. Tested with QSGMII in-band AN both on and off on NXP LS1028A-RDB and T1040-RDB. Signed-off-by: Vladimir Oltean --- drivers/net/phy/mscc/mscc.h | 2 ++ drivers/net/phy/mscc/mscc_main.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h index 9481bce94c2e..44d1d8f28481 100644 --- a/drivers/net/phy/mscc/mscc.h +++ b/drivers/net/phy/mscc/mscc.h @@ -187,6 +187,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 2f2157e3deab..2951ed216620 100644 --- a/drivers/net/phy/mscc/mscc_main.c +++ b/drivers/net/phy/mscc/mscc_main.c @@ -1986,6 +1986,18 @@ static int vsc85xx_read_status(struct phy_device *phydev) return genphy_read_status(phydev); } +static int vsc8514_config_inband_aneg(struct phy_device *phydev, 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; @@ -2176,6 +2188,7 @@ static struct phy_driver vsc85xx_driver[] = { .phy_id_mask = 0xfffffff0, .soft_reset = &genphy_soft_reset, .config_init = &vsc8514_config_init, + .config_inband_aneg = vsc8514_config_inband_aneg, .config_aneg = &vsc85xx_config_aneg, .read_status = &vsc85xx_read_status, .handle_interrupt = vsc85xx_handle_interrupt,