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 08904C021B8 for ; Tue, 4 Mar 2025 14:45:28 +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:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iRe8bA5fq5Dnerb6IrVuapdeqPHeVXv9pFZzkEkJmRo=; b=w9AGjgD4J7oVxaOOz6XQU0/vYj 2Z+HeDzceP/tF5/xAyHTOCes4BUM12aCKiBmatXme5o0pUdxr72xA2Hrb9JyGQmFDFTJmXuLAg5A8 dLf4bgKHdP6CUmDcIBdJ+gL3d11ybjyTKDNrP0Up0Is/7RAwP6XNWSUOTIuP70cD4SiP1Os/ojB5F wEq15r/o87S+WfCIiXl7t8DIMrOifO18CmBgwxah1kYlzXoUgwvUL+C09bECzb6yIYhqSNwRlb0yH Vpcy7SX44bW3QCihfvahCemGzr1Hul9QIKiwH/zEJH7iYKra1wR09yWjS9LNAeMXlrwqM0KsLuhC6 geOU7spg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpTWI-0000000534l-1wxM; Tue, 04 Mar 2025 14:45:18 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tpTUh-000000052gb-43Fp for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2025 14:43:41 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E11F544283; Tue, 4 Mar 2025 14:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1741099415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iRe8bA5fq5Dnerb6IrVuapdeqPHeVXv9pFZzkEkJmRo=; b=OjlSumgPR+Di0+R/SqIfwlocmtXNUmeGujQ9eyffd0YzGCom6RZHDLNRLH3fVl+T3moCWQ x1FdbSetA4zu0h48UeLxbePp0CAVyEd/3nW55E6OyfiNkqLm1KDucpqXd/4J+0kFmbSoDG SqJuGnZb8WOarIlXMEbCPWxqeyDpj2+VKmoK3mmEv5rAliUA2/cjRp5U3CY+086H8YNC4i ANWB9ISfQYUa9hITU4YO345eDP7GXn+mkG8pD1NrUerrOpCRZYc6ygkuNW8mLqaIBADplB xSp9wanjT23HIIF8glPrOBPJ1bxOKdqbVLBqsYDNeIwX1zVwMIUXe7T/8eXDjg== Date: Tue, 4 Mar 2025 15:43:30 +0100 From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Heiner Kallweit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Vladimir Oltean , =?UTF-8?B?S8O2cnk=?= Maincent , Oleksij Rempel , Simon Horman , Romain Gantois Subject: Re: [PATCH net-next v4 09/13] net: phylink: Use phy_caps_lookup for fixed-link configuration Message-ID: <20250304154330.6e00961b@fedora.home> In-Reply-To: <20250303090321.805785-10-maxime.chevallier@bootlin.com> References: <20250303090321.805785-1-maxime.chevallier@bootlin.com> <20250303090321.805785-10-maxime.chevallier@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutddvfedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfgjfhhoofggtgfgsehtjeertdertddvnecuhfhrohhmpeforgigihhmvgcuvehhvghvrghllhhivghruceomhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepgeevledtvdevueehhfevhfelhfekveeftdfgiedufeffieeltddtgfefuefhueeknecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehfvgguohhrrgdrhhhomhgvpdhmrghilhhfrhhomhepmhgrgihimhgvrdgthhgvvhgrlhhlihgvrhessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepudelpdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegrnhgurhgvfieslhhunhhnrdgthhdprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvgguuhhmrgiivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehprggsvghnihesrhgvughhrghtrdgtohhmpdhrtghpthhtoheplhhin hhugiesrghrmhhlihhnuhigrdhorhhgrdhukhdprhgtphhtthhopehhkhgrlhhlfigvihhtudesghhmrghilhdrtghomhdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250304_064340_299699_28A91967 X-CRM114-Status: GOOD ( 25.54 ) 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 Hi, On Mon, 3 Mar 2025 10:03:15 +0100 Maxime Chevallier wrote: > When phylink creates a fixed-link configuration, it finds a matching > linkmode to set as the advertised, lp_advertising and supported modes > based on the speed and duplex of the fixed link. > > Use the newly introduced phy_caps_lookup to get these modes instead of > phy_lookup_settings(). This has the side effect that the matched > settings and configured linkmodes may now contain several linkmodes (the > intersection of supported linkmodes from the phylink settings and the > linkmodes that match speed/duplex) instead of the one from > phy_lookup_settings(). > > Signed-off-by: Maxime Chevallier > --- Maybe before anything goes further with this patch, I'd like to get some feedback from it on a particular point. This changes the linkmodes that are reported on fixed-link interfaces. Instead of reporting one single mode, we report all modes supported by the fixed-link' speed and duplex settings. The following example is a before/after of the "ethtool ethX" output on a 1G fixed link : Before this patch : Settings for eth0: Supported ports: [ MII ] Supported link modes: 1000baseT/Full Supported pause frame use: Symmetric Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: Not reported Speed: Unknown! Duplex: Half Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: off Supports Wake-on: d Wake-on: d Link detected: no After : Supported ports: [ MII ] Supported link modes: 1000baseT/Full 1000baseKX/Full 1000baseX/Full 1000baseT1/Full Supported pause frame use: Symmetric Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: Not reported Speed: Unknown! Duplex: Half Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: off Supports Wake-on: d Wake-on: d Link detected: no The fixed-link in question is for the CPU port of a DSA switch. In my opinion, this is OK as the linkmodes expressed here don't match physical linkmodes on an actual wire, but as this is a user visible change, I'd like to make sure this is OK. Any comment here is more than welcome. Maxime > V4: Remove unnecessary linklmode_zero in phylink_set_fixed_link(), > follwing Russell's comment > > drivers/net/phy/phylink.c | 27 +++++++++++++++------------ > 1 file changed, 15 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 6c67d5c9b787..0b9585cb508e 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -805,9 +805,10 @@ static int phylink_validate(struct phylink *pl, unsigned long *supported, > static int phylink_parse_fixedlink(struct phylink *pl, > const struct fwnode_handle *fwnode) > { > + __ETHTOOL_DECLARE_LINK_MODE_MASK(match) = { 0, }; > __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; > + const struct link_capabilities *c; > struct fwnode_handle *fixed_node; > - const struct phy_setting *s; > struct gpio_desc *desc; > u32 speed; > int ret; > @@ -879,8 +880,10 @@ static int phylink_parse_fixedlink(struct phylink *pl, > linkmode_copy(pl->link_config.advertising, pl->supported); > phylink_validate(pl, pl->supported, &pl->link_config); > > - s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex, > - pl->supported, true); > + c = phy_caps_lookup(pl->link_config.speed, pl->link_config.duplex, > + pl->supported, true); > + if (c) > + linkmode_and(match, pl->supported, c->linkmodes); > > linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, mask); > linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, mask); > @@ -889,9 +892,10 @@ static int phylink_parse_fixedlink(struct phylink *pl, > > phylink_set(pl->supported, MII); > > - if (s) { > - __set_bit(s->bit, pl->supported); > - __set_bit(s->bit, pl->link_config.lp_advertising); > + if (c) { > + linkmode_or(pl->supported, pl->supported, match); > + linkmode_or(pl->link_config.lp_advertising, > + pl->link_config.lp_advertising, match); > } else { > phylink_warn(pl, "fixed link %s duplex %dMbps not recognised\n", > pl->link_config.duplex == DUPLEX_FULL ? "full" : "half", > @@ -1879,21 +1883,20 @@ static int phylink_register_sfp(struct phylink *pl, > int phylink_set_fixed_link(struct phylink *pl, > const struct phylink_link_state *state) > { > - const struct phy_setting *s; > + const struct link_capabilities *c; > unsigned long *adv; > > if (pl->cfg_link_an_mode != MLO_AN_PHY || !state || > !test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) > return -EINVAL; > > - s = phy_lookup_setting(state->speed, state->duplex, > - pl->supported, true); > - if (!s) > + c = phy_caps_lookup(state->speed, state->duplex, > + pl->supported, true); > + if (!c) > return -EINVAL; > > adv = pl->link_config.advertising; > - linkmode_zero(adv); > - linkmode_set_bit(s->bit, adv); > + linkmode_and(adv, pl->supported, c->linkmodes); > linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, adv); > > pl->link_config.speed = state->speed;