Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6477030rdb; Tue, 2 Jan 2024 03:25:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVrhMGZJVBfzSUH3xMWcwQ78V/lgWkLTGIRyQRISWymIyNk7T6FwaPL9WDhuR+rPWLFQnn X-Received: by 2002:a05:6a00:63cb:b0:6d9:c191:dc67 with SMTP id gi11-20020a056a0063cb00b006d9c191dc67mr13100237pfb.28.1704194733370; Tue, 02 Jan 2024 03:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704194733; cv=none; d=google.com; s=arc-20160816; b=PpkZ3wsgRWr0B9657WuelBh8JzhGCBo/i2C3HokufFuSDECtU5jdv9u7nhMNQq8Nkd SZnHeGl0B79/U46FKNtIAM8CzjfQoEJaQOuMvTStUs4BdpoYjUBd2c5Wge5lxKY3squK WeMthXwqQCaGO1fOEYoObQu43q9LUdiMPDSqX1I7yo08gIBtWv/5BPvckGv3l3csm/24 qEoTBR1eOB/N7M/UbYV0exCqYNK0Yp0JS1wn2/wjQlP8U3iTS4xc12KRsd6ecuk5MG09 uldhNoD/23z9RewjNqIhQ+roQIRpYdZRb7p4udW7ISkRV0UwmxwLryt6tYMrfoIKg59A B5sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=mfPmEMBE1Wpq00R+242jiaLXkWvYzNKOQ5mWEYSaTTM=; fh=2ndDZqkcUbaSzPeDhrIjlrEtZwUhUYrfwnXsRoZN9X8=; b=UoSG8n/0Vz8sMMEnq1/EId0ylgtnInEpBJww9Pyri4wuEiBxijp8Dl7x2rLiY+KcYV ooQ3g/BPiecrSmMHYHRMWidZrIEZbChtKz+ykH13zpYOnRYW0cjV8wAPUMJ6vMu1s4P7 JyKXY/Uszh81mzTJkjvfxqO9y+9IMYowMaTNDkNMQkzBrrXs8VGct4qkczZpSCxLys5T oYSo/ZndX5v4LeOvaU2Ni4TiwAuvABF4AtXOCNdBveLaatGB5HVb9KGYGPOTCCY4tmyE dxYbjYI2xKJPMIMbPlhyFs5BM8jiHK1NDRDaWXzmLLK9llBIEjaXJtRHPoNTyWySAVvX vxlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14287-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e3-20020a654783000000b005b8ef498e2bsi20198055pgs.461.2024.01.02.03.25.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 03:25:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14287-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EC4662831E4 for ; Tue, 2 Jan 2024 11:25:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C70E5E556; Tue, 2 Jan 2024 11:25:25 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 807F0DF5D; Tue, 2 Jan 2024 11:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1rKcQJ-0006IK-2M; Tue, 02 Jan 2024 10:55:04 +0000 Date: Tue, 2 Jan 2024 11:52:34 +0100 From: Daniel Golle To: Eric Woudstra Cc: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Frank Wunderlich , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH RFC net-next] net: phylink: add quirk for disabling in-band-status for mediatek pcs at 2500base-x Message-ID: References: <20240102074326.1049179-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240102074326.1049179-1-ericwouds@gmail.com> On Tue, Jan 02, 2024 at 08:43:26AM +0100, Eric Woudstra wrote: > In follow up to: net: pcs: pcs-mtk-lynxi: use 2500Base-X without AN > > MediaTek LynxI PCS, 2500Base-X will only work without inband status due to > hardware limitation. > > I understand this patch probably will not get approved as it is now, but > perhaps with some pointers in the correct direction to follow, I can change > it so it could be. It does however get the result that the rtl8221b on a > sfp module functions correctly, with and without (as optical sfp) the phy > attached and without using a quirk/ethtool to disable auto-negotiation. > > Introduce bool phylink_major_no_inband(pl,interface), a function similar to > bool phylink_phy_no_inband(phy). An option could be to use a function like > bool pcs->ops->supports_inband(interface), where if the function-pointer is > null, it means it is supported for all. This instead of using > of_device_is_compatible() inside the phylink_major_no_inband() function. > > Code added to phylink_major_config(): > > When there is no PHY attached, pl->pcs_neg_mode is set to > PHYLINK_PCS_NEG_INBAND_DISABLED. > > When there is a PHY attached, pl->cur_link_an_mode is set to MLO_AN_PHY. > To have the pcs function correctly with the rtl8221b, we need to do the > following to the in-band-status: > > We need to disable it when interface of the pcs is set to 2500base-x, > but need it enable it when switched to sgmii. > > So we get: > > [...] mtk_soc_eth ... eth1: phy link up sgmii/1Gbps/Full/none/rx/tx > [...] mtk_soc_eth ... eth1: phylink_mac_config: mode=inband/sgmii/none > adv=00,00000000,00000000,00000000 pause=03 > > [...] mtk_soc_eth ... eth1: phy link up 2500base-x/2.5Gbps/Full/none/rx/tx > [...] mtk_soc_eth ... eth1: phylink_mac_config: mode=phy/2500base-x/none > adv=00,00000000,00008000,0000606f pause=03 > > Changes to be committed: > modified: drivers/net/phy/phylink.c > > Signed-off-by: Eric Woudstra > --- > drivers/net/phy/phylink.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) Your changes should go into mtk_eth_soc.c, you sould not need to modify phylink for this and as the link being up or down is still reported correctly by the hardware, it is also ok to have phylink believe that in-band-status is being used and just not set the SGMII_AN bit in the MediaTek LynxI hardware. (ie. only auto-negotiation of speed and duplex doesn't work in 2500Base-X mode) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 298dfd6982a5..6e443eb8ee46 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -1074,6 +1074,22 @@ static void phylink_pcs_an_restart(struct phylink *pl) > pl->pcs->ops->pcs_an_restart(pl->pcs); > } > > +static bool phylink_major_no_inband(struct phylink *pl, phy_interface_t interface) > +{ > + struct device_node *node = pl->config->dev->of_node; > + > + if (!node) > + return false; > + > + if (!of_device_is_compatible(node, "mediatek,eth-mac")) > + return false; > + > + if (interface != PHY_INTERFACE_MODE_2500BASEX) > + return false; > + > + return true; > +} > + > static void phylink_major_config(struct phylink *pl, bool restart, > const struct phylink_link_state *state) > { > @@ -1085,10 +1101,22 @@ static void phylink_major_config(struct phylink *pl, bool restart, > > phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); > > + if (phylink_major_no_inband(pl, state->interface) && (!!pl->phydev)) { > + if (pl->cur_link_an_mode == MLO_AN_INBAND) > + pl->cur_link_an_mode = MLO_AN_PHY; > + else > + /* restore mode if it was changed before */ > + pl->cur_link_an_mode = pl->cfg_link_an_mode; > + } > + > pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, > state->interface, > state->advertising); > > + if (phylink_major_no_inband(pl, state->interface) && !pl->phydev && > + pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) > + pl->pcs_neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED; > + > if (pl->using_mac_select_pcs) { > pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); > if (IS_ERR(pcs)) { > @@ -1218,6 +1246,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, > struct phylink_link_state *state) > { > linkmode_copy(state->advertising, pl->link_config.advertising); > + if (pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_DISABLED) > + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, > + state->advertising); > linkmode_zero(state->lp_advertising); > state->interface = pl->link_config.interface; > state->rate_matching = pl->link_config.rate_matching; > -- > 2.42.1 >