net: dsa: rtl8366: Use DSA core to set up VLAN

The current code in the RTL8366 VLAN handling code
initializes the default VLANs like this:

Ingress packets:
 port 0 lan0  -> VLAN 1 -> CPU port (5)
 port 1 lan1  -> VLAN 2 -> CPU port (5)
 port 2 lan2  -> VLAN 3 -> CPU port (5)
 port 3 lan3  -> VLAN 4 -> CPU port (5)
 port 4 wan   -> VLAN 5 -> CPU port (5)

Egress packets:
 port 5 (CPU) -> VLAN 6 -> port 0, 1, 2, 3, 4

So 5 VLANs for ingress packets and one VLAN for
egress packets. Further it sets the PVID
for each port to further restrict the packets from
a certain port to this VLAN only, and sets them
all as untagged.

This is a neat set-up in a way and a leftover
from the OpenWrt driver and the vendor code drop.

The DSA core can be instructed to assign
all ports to a default VLAN, which will be
VLAN 1. This isn't sufficient for this switch
which really need to put egress packets into
a VLAN that reaches all ports. This patch will
change the above picture to this:

Ingress packets:

 port 0 lan0  -> VLAN 1 -> CPU port (5)
 port 1 lan1  -> VLAN 2 -> CPU port (5)
 port 2 lan2  -> VLAN 3 -> CPU port (5)
 port 3 lan3  -> VLAN 4 -> CPU port (5)
 port 4 wan   -> VLAN ? -> CPU port (5) FIXME

Egress packets:
 port 5 (CPU) -> VLAN 4095 -> port 0, 1, 2, 3, 4

The tested scenarios sure work fine with this
set-up including video streaming from a NAS device.

Cc: DENG Qingfang <dqfext@gmail.com>
Cc: Mauri Sandberg <sandberg@mailfence.com>
Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Suggested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
4 files changed