From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D9ECC2BD09 for ; Fri, 28 Jun 2024 14:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Dn8dd9XofEX3Uhxe0baYs+HlRiMw0xmll7rakGvzy50=; b=Y81ezlZcPgHgjRZHv8+cGNVvmV mJDXySCU/TdMHoMGbBQxYn1P5oKI3ijkbiZ4rmXDZ8Ri/4j/ZPziTZ5QCa5nG3+bnSdc2vd+gn9T5 RMMbImt37WaOz4WtRVVedPcjyzfkTbEd1YiLjaCDNd4WyU8hdGJ+NcuM2w7xwN8g4FGBhbnphgXFM 8TYPlnT6qRkFMD83ib1dDQt3tU3LTzsO4EBx/2jDbypPxgNB+xMYh8e3WutTCNAs2o2uSvt3XBeeP QJ/JeH4ua5JD1ZLwyaNymXLEN7elDIPDMcO/BhQAVb/QJGQJtGB6VRgPFRyOkHlg6f+4v67sa6AyV H329R7aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNCic-0000000E2YJ-23sb; Fri, 28 Jun 2024 14:36:54 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNCiS-0000000E2VO-2ES3 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 14:36:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Dn8dd9XofEX3Uhxe0baYs+HlRiMw0xmll7rakGvzy50=; b=Cqv4ThO5K430oyZ2P6/0xKye2t dcVwpn/gglUa0CJqhAN+opJSD6fX3NJv+GbcL5k/c4EwzwND43nPnDy+bpoIqtGo+vLKI2FOubIqs Fvk74xjycJ9/p6rbCTdrQngllERV7m92ztiQsm0d5x2t2e3LC6gMsCLiGO/ckIZnQ2AprJa5/Ve1x 7nVuXuVCk1Eck2s+1es8VUVhYFZ/5YC8VxXfqplKesv5yRcQRzKkv9urI632OyjgKKQdtyERinlCZ hOSoxViS6lcjxxxu6qSstM5r1CijGBQv3xhaYtMKdyTxvuyOVdXATGeQwcfbbru1AsdTgVxxnG0YD DgriEQQw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:57500) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sNCi4-0006kX-1r; Fri, 28 Jun 2024 15:36:20 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sNCi4-0006Zb-BR; Fri, 28 Jun 2024 15:36:20 +0100 Date: Fri, 28 Jun 2024 15:36:20 +0100 From: "Russell King (Oracle)" To: Serge Semin Cc: Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC net-next v2 16/17] net: stmmac: Move internal PCS init method to stmmac_pcs.c Message-ID: References: <20240624132802.14238-8-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240624132802.14238-8-fancer.lancer@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_073644_591958_3EC68D97 X-CRM114-Status: GOOD ( 22.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 24, 2024 at 04:26:33PM +0300, Serge Semin wrote: > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 72c2d3e2c121..743d356f6d12 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -950,13 +950,16 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, > { > struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); > > + if (priv->hw->pcs) > + return &priv->hw->mac_pcs; > + > if (priv->hw->xpcs) > return &priv->hw->xpcs->pcs; > > if (priv->hw->phylink_pcs) > return priv->hw->phylink_pcs; > > - return stmmac_mac_phylink_select_pcs(priv, interface); > + return NULL; I really really don't like this due to: 1. I spent a long time working out what the priority here should be, and you've just thrown all that work away by changing it - to something that I believe is incorrect. 2. I want to eventually see this function checking the interface type before just handing out a random PCS, and it was my intention to eventually that into the MACs own select_pcs() methods. Getting rid of those methods means that the MACs themselves now can't make the decision which is where that should be. 3. When operating in RGMII "inband" mode, the .pcs_config etc doesn't make much sense (we're probably accessing registers that don't exist) and I had plans to split this into a RGMII "PCS" which was just a PCS that implemented .pcs_get_state(), a stub .pcs_config(), and a separate fully-featured "SGMII PCS". So, I would like to eventually see here something like: if (priv->hw->xpcs) return &priv->hw->xpcs->pcs; if (priv->hw->phylink_pcs) return priv->hw->phylink_pcs; if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS)) { if (phy_interface_mode_is_rgmii(priv->plat->mac_interface)) return &priv->hw->mac_rgmii_pcs; if (priv->dma_cap.pcs && priv->plat->mac_interface == PHY_INTERFACE_MODE_SGMII) return &priv->hw->mac_sgmii_pcs; } return NULL; > +void dwmac_pcs_init(struct mac_device_info *hw) > +{ > + struct stmmac_priv *priv = hw->priv; > + int interface = priv->plat->mac_interface; > + > + if (priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) > + return; > + else if (phy_interface_mode_is_rgmii(interface)) > + hw->pcs = STMMAC_PCS_RGMII; > + else if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) > + hw->pcs = STMMAC_PCS_SGMII; > + > + hw->mac_pcs.neg_mode = true; > +} Please move "hw->mac_pcs.neg_mode = true;" to where the PCS method functions are implemented - it determines whether the PCS method functions take the AN mode or the neg mode, and this is a property of their implementations. It should not be split away from them. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!