From: Yongzhao Chen <yongzhao.derek@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew@lunn.ch, olteanv@gmail.com, ansuelsmth@gmail.com,
hkallweit1@gmail.com, linux@armlinux.org.uk,
florian.fainelli@broadcom.com, jonas.gorski@gmail.com,
woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
hzyitc@outlook.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, Yongzhao Chen <yongzhao.derek@gmail.com>
Subject: [RFC PATCH net-next v2 2/5] net: dsa: qca8k: support an internal PHY as the CPU port
Date: Tue, 22 Sep 2026 22:26:50 +0200 [thread overview]
Message-ID: <20260922202653.1153-3-yongzhao.derek@gmail.com> (raw)
In-Reply-To: <20260922202653.1153-1-yongzhao.derek@gmail.com>
From: Ziyang Huang <hzyitc@outlook.com>
A PHY-to-PHY CPU link connects the SoC PHY to an internal switch PHY.
QCA8337 supports header mode on these ports, and the existing phylink
callbacks already support their internal interfaces.
Allow CPU port selection to find ports 1 through 5 after checking the
MAC-only ports. Include internal CPU PHYs when deciding how to access
the PHYs, without changing the treatment of MAC-only or user ports.
This supports a single internal CPU PHY with an explicit phy-handle and
phy-mode = "internal". The conduit uses its own PHY at the other end of
the MDI connection. Existing single-CPU forwarding then uses the selected
port for flooding and port membership without additional routing changes.
Adapted from the OpenWrt PHY-to-PHY CPU link patch; narrow the MDIO
filter change to retain existing external user-port handling.
[yongzhao: preserve external user-port handling on port 6]
Assisted-by: LLM
Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
Signed-off-by: Yongzhao Chen <yongzhao.derek@gmail.com>
---
drivers/net/dsa/qca/qca8k-8xxx.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 60f2a615a..17704cb53 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -1014,7 +1014,8 @@ qca8k_setup_mdio_bus(struct qca8k_priv *priv)
return ret;
}
- if (!dsa_is_user_port(priv->ds, reg))
+ if (!dsa_is_user_port(priv->ds, reg) &&
+ !(reg > 0 && reg < 6 && dsa_is_cpu_port(priv->ds, reg)))
continue;
of_get_phy_mode(port, &mode);
@@ -1089,17 +1090,19 @@ qca8k_setup_mac_pwr_sel(struct qca8k_priv *priv)
static int qca8k_find_cpu_port(struct dsa_switch *ds)
{
- struct qca8k_priv *priv = ds->priv;
+ int port;
- /* Find the connected cpu port. Valid port are 0 or 6 */
if (dsa_is_cpu_port(ds, 0))
return 0;
- dev_dbg(priv->dev, "port 0 is not the CPU port. Checking port 6");
-
if (dsa_is_cpu_port(ds, 6))
return 6;
+ /* An internal PHY can provide a PHY-to-PHY CPU link. */
+ for (port = 1; port < 6; port++)
+ if (dsa_is_cpu_port(ds, port))
+ return port;
+
return -EINVAL;
}
@@ -1849,7 +1852,7 @@ qca8k_setup(struct dsa_switch *ds)
cpu_port = qca8k_find_cpu_port(ds);
if (cpu_port < 0) {
- dev_err(priv->dev, "No cpu port configured in both cpu port0 and port6");
+ dev_err(priv->dev, "No CPU port configured");
return cpu_port;
}
--
2.43.0
next prev parent reply other threads:[~2026-09-22 20:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:26 [RFC PATCH net-next v2 0/5] net: dsa: qca8k: add a QCA8337 CPU PHY consumer Yongzhao Chen
2026-09-22 20:26 ` [RFC PATCH net-next v2 1/5] net: dsa: pass PHY flags when connecting shared ports Yongzhao Chen
2026-09-22 21:49 ` Florian Fainelli
2026-09-22 20:26 ` Yongzhao Chen [this message]
2026-09-22 20:26 ` [RFC PATCH net-next v2 3/5] net: dsa: qca8k: serialize CPU MAC pause during MTU changes Yongzhao Chen
2026-09-22 20:58 ` Andrew Lunn
2026-09-23 21:57 ` Yongzhao Chen
2026-09-22 20:26 ` [RFC PATCH net-next v2 4/5] net: dsa: qca8k: flag QCA8337 internal CPU PHYs for SmartSpeed Yongzhao Chen
2026-09-22 21:00 ` Andrew Lunn
2026-09-23 21:57 ` Yongzhao Chen
2026-09-22 20:26 ` [RFC PATCH net-next v2 5/5] net: phy: qca83xx: disable SmartSpeed before resetting CPU PHYs Yongzhao Chen
2026-09-22 21:06 ` Andrew Lunn
2026-09-23 21:57 ` Yongzhao Chen
2026-09-24 12:30 ` Andrew Lunn
2026-09-24 23:48 ` Yongzhao Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922202653.1153-3-yongzhao.derek@gmail.com \
--to=yongzhao.derek@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=hzyitc@outlook.com \
--cc=jonas.gorski@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox