aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2020-08-11 13:11:08 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2020-08-24 18:53:59 +0200
commit8735997686a360545f5f1c6cb54d48e85dda7707 (patch)
tree96436a1af47dd4c6993a48e9a99da2a5712aa97c /target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch
parente742a31f07f66700ae43141bd6a733718a2ad501 (diff)
downloadupstream-8735997686a360545f5f1c6cb54d48e85dda7707.tar.gz
upstream-8735997686a360545f5f1c6cb54d48e85dda7707.tar.bz2
upstream-8735997686a360545f5f1c6cb54d48e85dda7707.zip
kernel: backport RTL8366RB patches
These upstream patches makes the RTL8366RB DSA switch work properly with OpenWrt, the D-Link DIR-685 gets network and can be used as a router, and the same should be applicable for any other device that want to enable the RTL8366RB through Device Tree. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch')
-rw-r--r--target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch b/target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch
new file mode 100644
index 0000000000..b68c033bbe
--- /dev/null
+++ b/target/linux/generic/backport-5.4/758-v5.8-net-dsa-rtl8366rb-Support-the-CPU-DSA-tag.patch
@@ -0,0 +1,100 @@
+From c633ba43b7a9c2bfdb992ffd198d4c661520466f Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Wed, 8 Jul 2020 14:25:37 +0200
+Subject: [PATCH 3/5] net: dsa: rtl8366rb: Support the CPU DSA tag
+
+This activates the support to use the CPU tag to properly
+direct ingress traffic to the right port.
+
+Bit 15 in register RTL8368RB_CPU_CTRL_REG can be set to
+1 to disable the insertion of the CPU tag which is what
+the code currently does. The bit 15 define calls this
+setting RTL8368RB_CPU_INSTAG which is confusing since the
+inverse meaning is implied: programmers may think that
+setting this bit to 1 will *enable* inserting the tag
+rather than disabling it, so rename this setting in
+bit 15 to RTL8368RB_CPU_NO_TAG which is more to the
+point.
+
+After this e.g. ping works out-of-the-box with the
+RTL8366RB.
+
+Cc: DENG Qingfang <dqfext@gmail.com>
+Cc: Mauri Sandberg <sandberg@mailfence.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/Kconfig | 1 +
+ drivers/net/dsa/rtl8366rb.c | 31 ++++++++-----------------------
+ 2 files changed, 9 insertions(+), 23 deletions(-)
+
+--- a/drivers/net/dsa/Kconfig
++++ b/drivers/net/dsa/Kconfig
+@@ -66,6 +66,7 @@ config NET_DSA_QCA8K
+ config NET_DSA_REALTEK_SMI
+ tristate "Realtek SMI Ethernet switch family support"
+ depends on NET_DSA
++ select NET_DSA_TAG_RTL4_A
+ select FIXED_PHY
+ select IRQ_DOMAIN
+ select REALTEK_PHY
+--- a/drivers/net/dsa/rtl8366rb.c
++++ b/drivers/net/dsa/rtl8366rb.c
+@@ -109,8 +109,8 @@
+ /* CPU port control reg */
+ #define RTL8368RB_CPU_CTRL_REG 0x0061
+ #define RTL8368RB_CPU_PORTS_MSK 0x00FF
+-/* Enables inserting custom tag length/type 0x8899 */
+-#define RTL8368RB_CPU_INSTAG BIT(15)
++/* Disables inserting custom tag length/type 0x8899 */
++#define RTL8368RB_CPU_NO_TAG BIT(15)
+
+ #define RTL8366RB_SMAR0 0x0070 /* bits 0..15 */
+ #define RTL8366RB_SMAR1 0x0071 /* bits 16..31 */
+@@ -844,16 +844,14 @@ static int rtl8366rb_setup(struct dsa_sw
+ if (ret)
+ return ret;
+
+- /* Enable CPU port and enable inserting CPU tag
++ /* Enable CPU port with custom DSA tag 8899.
+ *
+- * Disabling RTL8368RB_CPU_INSTAG here will change the behaviour
+- * of the switch totally and it will start talking Realtek RRCP
+- * internally. It is probably possible to experiment with this,
+- * but then the kernel needs to understand and handle RRCP first.
++ * If you set RTL8368RB_CPU_NO_TAG (bit 15) in this registers
++ * the custom tag is turned off.
+ */
+ ret = regmap_update_bits(smi->map, RTL8368RB_CPU_CTRL_REG,
+ 0xFFFF,
+- RTL8368RB_CPU_INSTAG | BIT(smi->cpu_port));
++ BIT(smi->cpu_port));
+ if (ret)
+ return ret;
+
+@@ -966,21 +964,8 @@ static int rtl8366rb_setup(struct dsa_sw
+ static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds,
+ int port)
+ {
+- /* For now, the RTL switches are handled without any custom tags.
+- *
+- * It is possible to turn on "custom tags" by removing the
+- * RTL8368RB_CPU_INSTAG flag when enabling the port but what it
+- * does is unfamiliar to DSA: ethernet frames of type 8899, the Realtek
+- * Remote Control Protocol (RRCP) start to appear on the CPU port of
+- * the device. So this is not the ordinary few extra bytes in the
+- * frame. Instead it appears that the switch starts to talk Realtek
+- * RRCP internally which means a pretty complex RRCP implementation
+- * decoding and responding the RRCP protocol is needed to exploit this.
+- *
+- * The OpenRRCP project (dormant since 2009) have reverse-egineered
+- * parts of the protocol.
+- */
+- return DSA_TAG_PROTO_NONE;
++ /* This switch uses the 4 byte protocol A Realtek DSA tag */
++ return DSA_TAG_PROTO_RTL4_A;
+ }
+
+ static void rtl8366rb_adjust_link(struct dsa_switch *ds, int port,