From 2b88563ee5aafd9571d965b7f2093a0f58d98a31 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 26 Nov 2020 12:02:21 +0100
Subject: realtek dsa/phy: Increase max ports for RTL839X/RTL931X

Linux standard can only support up to 12 ports per DSA switch. This is
not enough for the large RTL839X and RTL931X devices. Increase the max
values accordingly. Additionally take care about the DSA functions that 
work on port bit masks. For this enhance the mask type from u32 to u64.

Submitted-by: Bert Vermeulen <bert@biot.com>
Submitted-by: Birger Koblitz <mail@birger-koblitz.de>
Submitted-by: Sander Vanheule <sander@svanheule.net>
Submitted-by: Bjørn Mork <bjorn@mork.no>
Submitted-by: John Crispin <john@phrozen.org>
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
---
 include/linux/platform_data/dsa.h |  2 +-
 include/net/dsa.h                 | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

--- a/include/linux/platform_data/dsa.h
+++ b/include/linux/platform_data/dsa.h
@@ -6,7 +6,7 @@ struct device;
 struct net_device;
 
 #define DSA_MAX_SWITCHES	4
-#define DSA_MAX_PORTS		12
+#define DSA_MAX_PORTS		56
 #define DSA_RTABLE_NONE		-1
 
 struct dsa_chip_data {
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -480,7 +480,7 @@ struct dsa_switch {
 	/*
 	 * User mii_bus and devices for the individual ports.
 	 */
-	u32			phys_mii_mask;
+	u64			phys_mii_mask;
 	struct mii_bus		*user_mii_bus;
 
 	/* Ageing Time limits in msecs */
@@ -616,24 +616,24 @@ static inline bool dsa_is_user_port(stru
 	dsa_switch_for_each_port_continue_reverse((_dp), (_ds)) \
 		if (dsa_port_is_cpu((_dp)))
 
-static inline u32 dsa_user_ports(struct dsa_switch *ds)
+static inline u64 dsa_user_ports(struct dsa_switch *ds)
 {
 	struct dsa_port *dp;
-	u32 mask = 0;
+	u64 mask = 0;
 
 	dsa_switch_for_each_user_port(dp, ds)
-		mask |= BIT(dp->index);
+		mask |= BIT_ULL(dp->index);
 
 	return mask;
 }
 
-static inline u32 dsa_cpu_ports(struct dsa_switch *ds)
+static inline u64 dsa_cpu_ports(struct dsa_switch *ds)
 {
 	struct dsa_port *cpu_dp;
-	u32 mask = 0;
+	u64 mask = 0;
 
 	dsa_switch_for_each_cpu_port(cpu_dp, ds)
-		mask |= BIT(cpu_dp->index);
+		mask |= BIT_ULL(cpu_dp->index);
 
 	return mask;
 }
