diff mbox series

[net-next,5/5] net: dsa: rtl8366: Use top VLANs for default

Message ID 20200602205456.2392024-5-linus.walleij@linaro.org
State Deferred
Delegated to: David Miller
Headers show
Series [net-next,1/5] net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag | expand

Commit Message

Linus Walleij June 2, 2020, 8:54 p.m. UTC
The RTL8366 DSA switches will not work unless we set
up a default VLAN for each port. We are currently using
e.g. VLAN 1..6 for a 5-port switch as default VLANs.

This is not very helpful for users, move it to allocate
the top VLANs for default instead, for example on
RTL8366RB there are 16 VLANs so instead of using
VLAN 1..6 as default use VLAN 10..15 so VLAN 1
thru VLAN 9 is available for users.

Cc: DENG Qingfang <dqfext@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/dsa/rtl8366.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Qingfang Deng June 3, 2020, 2:19 a.m. UTC | #1
Hi Linus

On Wed, Jun 3, 2020 at 4:55 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The RTL8366 DSA switches will not work unless we set
> up a default VLAN for each port. We are currently using
> e.g. VLAN 1..6 for a 5-port switch as default VLANs.
>
> This is not very helpful for users, move it to allocate
> the top VLANs for default instead, for example on
> RTL8366RB there are 16 VLANs so instead of using

RTL8366RB has full 4K vlan entry but you have to enable it manually.
https://github.com/openwrt/openwrt/blob/e73c61a978c56d41a2cdae4b5a2ca660aec4931b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c#L43

> VLAN 1..6 as default use VLAN 10..15 so VLAN 1
> thru VLAN 9 is available for users.
>
> Cc: DENG Qingfang <dqfext@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/net/dsa/rtl8366.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
> index 7f0691a6da13..4e7562b41598 100644
> --- a/drivers/net/dsa/rtl8366.c
> +++ b/drivers/net/dsa/rtl8366.c
> @@ -260,8 +260,8 @@ static int rtl8366_set_default_vlan_and_pvid(struct realtek_smi *smi,
>         u16 vid;
>         int ret;
>
> -       /* This is the reserved default VLAN for this port */
> -       vid = port + 1;
> +       /* Use the top VLANs for per-port default VLAN */
> +       vid = smi->num_vlan_mc - smi->num_ports + port;
>
>         if (port == smi->cpu_port)
>                 /* For the CPU port, make all ports members of this
> --
> 2.26.2
>
Linus Walleij June 3, 2020, 8:33 a.m. UTC | #2
On Wed, Jun 3, 2020 at 4:19 AM DENG Qingfang <dqfext@gmail.com> wrote:

> RTL8366RB has full 4K vlan entry but you have to enable it manually.
> https://github.com/openwrt/openwrt/blob/e73c61a978c56d41a2cdae4b5a2ca660aec4931b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c#L43

Yep fixing up the 4K VLAN support is on my (slowly processed) TODO.
I will do that with a separate series later.

Thanks!
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
index 7f0691a6da13..4e7562b41598 100644
--- a/drivers/net/dsa/rtl8366.c
+++ b/drivers/net/dsa/rtl8366.c
@@ -260,8 +260,8 @@  static int rtl8366_set_default_vlan_and_pvid(struct realtek_smi *smi,
 	u16 vid;
 	int ret;
 
-	/* This is the reserved default VLAN for this port */
-	vid = port + 1;
+	/* Use the top VLANs for per-port default VLAN */
+	vid = smi->num_vlan_mc - smi->num_ports + port;
 
 	if (port == smi->cpu_port)
 		/* For the CPU port, make all ports members of this