From a572f1020159294fe980606996e7e3af5fa7ba9a Mon Sep 17 00:00:00 2001
From: Ziyang Huang <hzyitc@outlook.com>
Date: Wed, 14 Jan 2026 23:38:30 +0800
Subject: [PATCH 3/3] net: dsa: qca8k: implement
 ds->ops->preferred_default_local_cpu_port()

Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
---
 drivers/net/dsa/qca/qca8k-8xxx.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -1743,6 +1743,18 @@ qca8k_get_tag_protocol(struct dsa_switch
 	return DSA_TAG_PROTO_QCA;
 }
 
+static struct dsa_port *
+qca8k_preferred_default_local_cpu_port(struct dsa_switch *ds)
+{
+	if (dsa_is_cpu_port(ds, 0))
+		return dsa_to_port(ds, 0);
+
+	if (dsa_is_cpu_port(ds, 6))
+		return dsa_to_port(ds, 6);
+
+	return NULL;
+}
+
 static int qca8k_port_change_master(struct dsa_switch *ds, int port,
 				    struct net_device *master,
 				    struct netlink_ext_ack *extack)
@@ -2139,6 +2151,7 @@ static const struct dsa_switch_ops qca8k
 	.get_phy_flags		= qca8k_get_phy_flags,
 	.port_lag_join		= qca8xxx_port_lag_join,
 	.port_lag_leave		= qca8xxx_port_lag_leave,
+	.preferred_default_local_cpu_port = qca8k_preferred_default_local_cpu_port,
 	.port_change_conduit	= qca8k_port_change_master,
 	.conduit_state_change	= qca8k_conduit_change,
 	.connect_tag_protocol	= qca8k_connect_tag_protocol,
