Message ID | 20221209224713.19980-6-jerry.ray@microchip.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1029988wrr; Fri, 9 Dec 2022 14:53:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7FJ/7MYSx9hT8ctV1hGoyl3KxrofbysL5RU68Y7lHnz3pSnyAK3I4hhEpbRrgiGUKSiVVx X-Received: by 2002:a17:906:eddd:b0:7c1:439:2ad4 with SMTP id sb29-20020a170906eddd00b007c104392ad4mr7168666ejb.57.1670626413117; Fri, 09 Dec 2022 14:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670626413; cv=none; d=google.com; s=arc-20160816; b=ggA7Hk3cSlBqRN1yMXlp6uU7IW/9IcFz4e47IRxKGKdmbd8Wv18Zhqv886PCFMnaM3 t+0j0OWCjJGz1pxMvXOZnzagiKduI+Ldo4lxr25pf+qhlY6SD4z0AGoxTNhvMgciENmm CTbu6B69ihAejM+gnDUdl2Ua+zD1+62EZ4KFJNojCbJmFaEWV6JpEMtBNrlw+8DlO1tz qpxNTquk3UehvjiDhUIpB51J9w8HjFK2/5BWzSQFB0J0w0ALJx0yBlSqefzk7UwjgVbh gZWjrfopitV+tTfWuXU4RPwvOkWFZhqrvEDKdR3sYQyyV8qQfpwi4/ky8dL4qTqx6XwX WTEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=Zu+X0wWblNWuSMZQH6lF+ORTq/EbVz0uqh9AM1U4qCw=; b=eNV7anW2ZkiH1r5M7yC3izT3x2mvKZBzoaIxA932aaOErdfv19N0Wz0nojGd4K9JSb jZEmqVSHX89xr7eCxRlydXV7TH+uj2jrs0VVAAe7kN1zvd8hY/luJgc7fm5bxBKB+Rzx W8V4Lxs1rqEMjiXKxpANkgSox7Rqy6zr3uC9DXmVyGYeToDbTpW9JeSRuXxGeW7juxIJ 0HWlH/HTSUS5tXR/4Mw+EnJ13VIF4IXUqAPo+MZJQCTkZE+R2mYuCHhoI1KTLiSqbyxU Aaj11hDJCzDGJZ/VQDk1umD6JHg/O7N/WadJd0Vo8erIgdc0D9kjbjo3iimhPSV64pyD C1yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zXWENwvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp16-20020a1709071b1000b007330c08fe49si743055ejc.206.2022.12.09.14.53.10; Fri, 09 Dec 2022 14:53:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zXWENwvK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbiLIWrs (ORCPT <rfc822;sophiezhao968@gmail.com> + 99 others); Fri, 9 Dec 2022 17:47:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiLIWrW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 9 Dec 2022 17:47:22 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 533761C12A; Fri, 9 Dec 2022 14:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670626042; x=1702162042; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=l7YBKmMzDz1O5Koq1YvREF/7MqTU5nkmnxEBATNyr3s=; b=zXWENwvKe+AaZCmmgO5cFca27no0p2e9STU1IIYln6Y0esS1ttIZ8QtU SSJLTuKazA+I1/XmUKr2gTjHB3y5nAPL//yAgxujAiP8kKtTUvW8ivrWx PCoAnOSzmW1niG9mlCQ2ejNI0ODRy7QtZbeBucAHS4uEC55MuGqLw26FG 3EQtQmye+YdTketwjv6qnyyee2u9Gdyk3PvOUr4zTUrpsihRd1eHY9peU PXqInpwBAYJn1/DgaZ4/B5MQpnxR25pmCKaCKis1H2N9Fz5FkVNZME3a2 qsO8B1iwMvdirH+ZuuVcE37jg8nuMKqkkpqKmNA8vvvHszoO13unOj/ve Q==; X-IronPort-AV: E=Sophos;i="5.96,232,1665471600"; d="scan'208";a="192458907" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Dec 2022 15:47:21 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 9 Dec 2022 15:47:20 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 9 Dec 2022 15:47:19 -0700 From: Jerry Ray <jerry.ray@microchip.com> To: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, <jbe@pengutronix.de>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux@armlinux.org.uk>, Jerry Ray <jerry.ray@microchip.com> Subject: [PATCH net-next v5 5/6] dsa: lan9303: Determine CPU port based on dsa_switch ptr Date: Fri, 9 Dec 2022 16:47:12 -0600 Message-ID: <20221209224713.19980-6-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221209224713.19980-1-jerry.ray@microchip.com> References: <20221209224713.19980-1-jerry.ray@microchip.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751778761729866286?= X-GMAIL-MSGID: =?utf-8?q?1751778761729866286?= |
Series |
dsa: lan9303: Move to PHYLINK
|
|
Commit Message
Jerry Ray
Dec. 9, 2022, 10:47 p.m. UTC
In preparing to move the adjust_link logic into the phylink_mac_link_up
api, change the macro used to check for the cpu port.
Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
---
drivers/net/dsa/lan9303-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On Fri, Dec 09, 2022 at 04:47:12PM -0600, Jerry Ray wrote: > In preparing to move the adjust_link logic into the phylink_mac_link_up > api, change the macro used to check for the cpu port. No justification given for why this change is made. As a counter argument, I could point out that DSA can support configurations where the CPU port is one of the 100BASE-TX PHY ports, and the MII port can be used as a regular user port where a PHY has been connected. Some people are already doing this, for example connecting a Beaglebone Black (can also be Raspberry Pi or what have you) over SPI to a VSC7512 switch evaluation board. The LAN9303 documentation makes it rather clear to me that such a configuration would be possible, because the Switch Engine Ingress Port Type Register allows any of the 3 switch ports to expect DSA tags. It's lan9303_setup_tagging() the one who hardcodes the driver configuration to be that where port 0 is the only acceptable CPU port (as well as the early check from lan9303_setup()). DSA's understanding of a CPU port is only that - a port which carries DSA-tagged traffic, and is not exposed as a net_device to user space. Nothing about MII vs internal PHY ports - that is a separate classification, and a dsa_is_cpu_port() test is simply not something relevant from phylink's perspective, to put it simply. What we see in other device drivers for phylink handling is that there is driver-level knowledge as to which ports have internal PHYs and which have xMII pins. See priv->info->supports_mii[] in sja1105, dev->info->supports_mii[] in the ksz drivers, mv88e6xxx_phy_is_internal() in mv88e6xxx, felix->info->port_modes[] in the ocelot drivers, etc etc. Hardcoding port number 0 is also better from my perspective than looking for the CPU port. That's because the switch IP was built with the idea in mind that port 0 is MII. I would very much appreciate if this driver did not make any assumptions that the internal PHY ports cannot carry DSA-tagged traffic. This assumption was true when the driver was introduced, but it changed with commit 0e27921816ad ("net: dsa: Use PHYLINK for the CPU/DSA ports"). Coincidentally, that is also the commit which started prompting the lan9303 driver for an update, via the dmesg warnings you are seeing. It looks like there is potentially more code to unlock than this simple API change, which is something you could look at. > > Signed-off-by: Jerry Ray <jerry.ray@microchip.com> > --- > drivers/net/dsa/lan9303-core.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c > index 694249aa1f19..1d22e4b74308 100644 > --- a/drivers/net/dsa/lan9303-core.c > +++ b/drivers/net/dsa/lan9303-core.c > @@ -1064,7 +1064,11 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, > struct lan9303 *chip = ds->priv; > int ctl; > > - if (!phy_is_pseudo_fixed_link(phydev)) > + /* On this device, we are only interested in doing something here if > + * this is the CPU port. All other ports are 10/100 phys using MDIO > + * to control there link settings. > + */ > + if (!dsa_is_cpu_port(ds, port)) > return; > > ctl = lan9303_phy_read(ds, port, MII_BMCR); > -- > 2.17.1 >
> > In preparing to move the adjust_link logic into the phylink_mac_link_up > > api, change the macro used to check for the cpu port. > > No justification given for why this change is made. > The phydev parameter being passed into phylink_mac_link_up for the CPU port was NULL, so I have to move to something else. > As a counter argument, I could point out that DSA can support configurations > where the CPU port is one of the 100BASE-TX PHY ports, and the MII port > can be used as a regular user port where a PHY has been connected. Some > people are already doing this, for example connecting a Beaglebone Black > (can also be Raspberry Pi or what have you) over SPI to a VSC7512 switch > evaluation board. > > The LAN9303 documentation makes it rather clear to me that such a > configuration would be possible, because the Switch Engine Ingress Port > Type Register allows any of the 3 switch ports to expect DSA tags. It's > lan9303_setup_tagging() the one who hardcodes the driver configuration > to be that where port 0 is the only acceptable CPU port (as well as the > early check from lan9303_setup()). > > DSA's understanding of a CPU port is only that - a port which carries > DSA-tagged traffic, and is not exposed as a net_device to user space. > Nothing about MII vs internal PHY ports - that is a separate classification, > and a dsa_is_cpu_port() test is simply not something relevant from > phylink's perspective, to put it simply. > > What we see in other device drivers for phylink handling is that there > is driver-level knowledge as to which ports have internal PHYs and which > have xMII pins. See priv->info->supports_mii[] in sja1105, dev->info->supports_mii[] > in the ksz drivers, mv88e6xxx_phy_is_internal() in mv88e6xxx, > felix->info->port_modes[] in the ocelot drivers, etc etc. Hardcoding > port number 0 is also better from my perspective than looking for the > CPU port. That's because the switch IP was built with the idea in mind > that port 0 is MII. > > I would very much appreciate if this driver did not make any assumptions > that the internal PHY ports cannot carry DSA-tagged traffic. This > assumption was true when the driver was introduced, but it changed with > commit 0e27921816ad ("net: dsa: Use PHYLINK for the CPU/DSA ports"). > Coincidentally, that is also the commit which started prompting the > lan9303 driver for an update, via the dmesg warnings you are seeing. > > It looks like there is potentially more code to unlock than this simple > API change, which is something you could look at. > I understand your point. The LAN9303 is very flexible, supporting an I2C method for managing the switch and allowing the xMII to operate as either MAC or PHY. The original driver was written targeting the primary configuration most widely used by our customers. The host CPU has an xMII interface and the MDIO bus is used for control. Adding in the flexibility to support other configurations is something I will investigate as I expand the driver to support LAN9353/LAN9354/LAN9355 devices. Adding the private->info->supports_mii[] as was done in the ksz drivers is the most likely approach. I see this as a separate patch series. Would you agree? I will hardcode for port 0 at this point rather than looking at CPU port. Regards, Jerry. > > > > Signed-off-by: Jerry Ray <jerry.ray@microchip.com> > > --- > > drivers/net/dsa/lan9303-core.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c > > index 694249aa1f19..1d22e4b74308 100644 > > --- a/drivers/net/dsa/lan9303-core.c > > +++ b/drivers/net/dsa/lan9303-core.c > > @@ -1064,7 +1064,11 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, > > struct lan9303 *chip = ds->priv; > > int ctl; > > > > - if (!phy_is_pseudo_fixed_link(phydev)) > > + /* On this device, we are only interested in doing something here if > > + * this is the CPU port. All other ports are 10/100 phys using MDIO > > + * to control there link settings. > > + */ > > + if (!dsa_is_cpu_port(ds, port)) > > return; > > > > ctl = lan9303_phy_read(ds, port, MII_BMCR); > > -- > > 2.17.1 > > >
On Mon, Dec 12, 2022 at 05:42:01PM +0000, Jerry.Ray@microchip.com wrote: > > It looks like there is potentially more code to unlock than this simple > > API change, which is something you could look at. > > I understand your point. The LAN9303 is very flexible, supporting an I2C > method for managing the switch and allowing the xMII to operate as either > MAC or PHY. > > The original driver was written targeting the primary configuration most > widely used by our customers. The host CPU has an xMII interface and the > MDIO bus is used for control. Adding in the flexibility to support other > configurations is something I will investigate as I expand the driver to > support LAN9353/LAN9354/LAN9355 devices. Adding the > private->info->supports_mii[] as was done in the ksz drivers is the most > likely approach. I see this as a separate patch series. Would you agree? > > I will hardcode for port 0 at this point rather than looking at CPU port. Yes, I think that would be ok. Thanks for at least not baking in any more assumptions in the driver that already exist.
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 694249aa1f19..1d22e4b74308 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1064,7 +1064,11 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, struct lan9303 *chip = ds->priv; int ctl; - if (!phy_is_pseudo_fixed_link(phydev)) + /* On this device, we are only interested in doing something here if + * this is the CPU port. All other ports are 10/100 phys using MDIO + * to control there link settings. + */ + if (!dsa_is_cpu_port(ds, port)) return; ctl = lan9303_phy_read(ds, port, MII_BMCR);