OpenWrt Forum Archive

Topic: mt7621 switch : impossible to set vid

The content of this topic has been archived on 9 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm not able to set vid (vlan-id) on MT7621A based router (D-Link DIR-860L). Vid is always "default vlan" i.e. the vlan number.

For instance, this config is not working:

config switch_vlan
        option device 'switch0'
        option vlan '3'
        option vid '40'
        option ports '2t 6t'

=> operational vid is 3, not 40.

The following command has no effect:
swconfig dev switch0 vlan 3 set vid 40

And the show command always reports "vid = 0" :
swconfig dev switch0 vlan 3 show

VLAN 3:
        vid: 0
        ports: 2t 6t

According to this changeset, this behavious should be fixed: https://dev.openwrt.org/changeset/41331

I've tested in CC15.5.1 and last trunk build: not working.

Could you help me with this situation ?

(Last edited by nague on 13 May 2016, 12:11)

After further research, my understanding is that the 41331 changeset for vid support was committed on the "old" driver. Since 47899, a "new" driver has been released, and vid has not been ported yet: "This driver is very basic and only provides basic init and irq support."

https://dev.openwrt.org/log/trunk/targe … 7621.patch

nague wrote:

After further research, my understanding is that the 41331 changeset for vid support was committed on the "old" driver. Since 47899, a "new" driver has been released, and vid has not been ported yet: "This driver is very basic and only provides basic init and irq support."

https://dev.openwrt.org/log/trunk/targe … 7621.patch

ive checked the previous driver and can say it contains logic for mt7620 switch, not for mt7530 gsw
the general fault is here: 7620 have 16 vlan table entries and requires assigning vlan id to each table index, for 7621 you can use any of 4094 entries. "old" driver writes vlan index instead of vlan id to the register used for vlan id in case of 7621, so if you are using vlan id's over 16 it will not work properly.
It can be fixed by a one edit but it will broke a compatibility with 7620. If you don't care you can do it by yrself

--- mt7530.c.orig    2016-03-12 20:01:15.000000000 +0300
+++ mt7530.c    2016-05-13 13:02:38.142315256 +0300
@@ -542,6 +542,7 @@
         u32 val;
 
         /* vid of vlan */
+/* #its a 7620 code, 7621 don't need it
         val = mt7530_r32(priv, REG_ESW_VLAN_VTIM(i));
         if (i % 2 == 0) {
             val &= 0xfff000;
@@ -551,7 +552,7 @@
             val |= (vid << 12);
         }
         mt7530_w32(priv, REG_ESW_VLAN_VTIM(i), val);
-
+*/
         /* vlan port membership */
         if (member)
             mt7530_w32(priv, REG_ESW_VLAN_VAWD1, REG_ESW_VLAN_VAWD1_IVL_MAC |
@@ -571,7 +572,7 @@
         mt7530_w32(priv, REG_ESW_VLAN_VAWD2, val);
 
         /* write to vlan table */
-        mt7530_vtcr(priv, 1, i);
+        mt7530_vtcr(priv, 1, vid); // write vlan id instead of table index
     }
 
     /* Port Default PVID */

not tested, but in general it have to work )))

Hi stas2z, I tested your patch on my dir 860l router (it took me few hours to understand how to compile it), and it works! Thanks a lot.
But now, with my own build, trunk packages are not installing anymore. Do you think we can find an elegant way to commit this patch in trunk ? I mean, without breaking 7620 devices ?

nague wrote:

Hi stas2z, I tested your patch on my dir 860l router (it took me few hours to understand how to compile it), and it works! Thanks a lot.
But now, with my own build, trunk packages are not installing anymore. Do you think we can find an elegant way to commit this patch in trunk ? I mean, without breaking 7620 devices ?

as 7621 is mips 1004kc arch and 7620 is mips 24kec arch and it will be different toolchain/build_dir etc so it can be done by preprocessor directives like ifdef

#ifdef CONFIG_TARGET_ramips_mt7621
... // 7621 code
#else
.. // 7620 and others
#endif

if anyone here is interested in commiting this patch to mainline - feel free to do it
also you can enable vlan4k for mt7621 with my patch

(Last edited by stas2z on 1 Jun 2016, 10:22)

Hey guys, I am a noob in OpenWRT and have been using it for a little bit more than a year. But, after buying DIR-860L which looked like it would be much more of an upgrade from my previous router. I was wondering if you could provide a build that I can flash on my DIR-860L so I can use VID as it is very important for my use case

Hi yathavan101
Sorry for this late answer. I can push you the build I've compiled to use VID, based on 15.05.1.
What could be great, is that someone commit the patch in trunk...

Hi stas2z, I tested LEDE first stable release : VLAN ID is not fixed... This patch sould be commit in the 17.01 release, right ?

The discussion might have continued from here.