diff mbox series

[net-next,12/13] net: dsa: realtek: rtl8367c: use DSA CPU port

Message ID 20211216201342.25587-13-luizluca@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: realtek: MDIO interface and RTL8367S | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: kuba@kernel.org davem@davemloft.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 53 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Luiz Angelo Daros de Luca Dec. 16, 2021, 8:13 p.m. UTC
From: Luiz Angelo Daros de Luca <luizluca@gmail.com>

Instead of a fixed CPU port, assume that DSA is correct.

Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
 drivers/net/dsa/realtek/rtl8367c.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/dsa/realtek/rtl8367c.c b/drivers/net/dsa/realtek/rtl8367c.c
index f370ea948c59..a478ddc33a9e 100644
--- a/drivers/net/dsa/realtek/rtl8367c.c
+++ b/drivers/net/dsa/realtek/rtl8367c.c
@@ -91,7 +91,6 @@ 
 
 /* Chip-specific data and limits */
 #define RTL8367C_CHIP_ID_8365MB_VC		0x6367
-#define RTL8367C_CPU_PORT_NUM_8365MB_VC		6
 
 #define RTL8367C_LEARN_LIMIT_MAX	2112
 
@@ -99,7 +98,7 @@ 
 #define RTL8367C_PHYADDRMAX	7
 #define RTL8367C_NUM_PHYREGS	32
 #define RTL8367C_PHYREGMAX	(RTL8367C_NUM_PHYREGS - 1)
-#define RTL8367C_MAX_NUM_PORTS	(RTL8367C_CPU_PORT_NUM_8365MB_VC + 1)
+#define RTL8367C_MAX_NUM_PORTS  7
 
 /* Chip identification registers */
 #define RTL8367C_CHIP_ID_REG		0x1300
@@ -1816,9 +1815,18 @@  static int rtl8367c_setup(struct dsa_switch *ds)
 		dev_info(priv->dev, "no interrupt support\n");
 
 	/* Configure CPU tagging */
-	ret = rtl8367c_cpu_config(priv);
-	if (ret)
-		goto out_teardown_irq;
+	for (i = 0; i < priv->num_ports; i++) {
+		if (!(dsa_is_cpu_port(priv->ds, i)))
+			continue;
+		priv->cpu_port = i;
+		mb->cpu.mask = BIT(priv->cpu_port);
+		mb->cpu.trap_port = priv->cpu_port;
+		ret = rtl8367c_cpu_config(priv);
+		if (ret)
+			goto out_teardown_irq;
+
+		break;
+	}
 
 	/* Configure ports */
 	for (i = 0; i < priv->num_ports; i++) {
@@ -1949,8 +1957,7 @@  static int rtl8367c_detect(struct realtek_priv *priv)
 			"found an RTL8365MB-VC switch (ver=0x%04x)\n",
 			chip_ver);
 
-		priv->cpu_port = RTL8367C_CPU_PORT_NUM_8365MB_VC;
-		priv->num_ports = priv->cpu_port + 1;
+		priv->num_ports = RTL8367C_MAX_NUM_PORTS;
 
 		mb->priv = priv;
 		mb->chip_id = chip_id;
@@ -1961,8 +1968,6 @@  static int rtl8367c_detect(struct realtek_priv *priv)
 		mb->jam_size = ARRAY_SIZE(rtl8367c_init_jam_8367c);
 
 		mb->cpu.enable = 1;
-		mb->cpu.mask = BIT(priv->cpu_port);
-		mb->cpu.trap_port = priv->cpu_port;
 		mb->cpu.insert = RTL8367C_CPU_INSERT_TO_ALL;
 		mb->cpu.position = RTL8367C_CPU_POS_AFTER_SA;
 		mb->cpu.rx_length = RTL8367C_CPU_RXLEN_64BYTES;