AR8x16 doesn't allow setting VLAN ID > 127

Hi,

Please change:

/* size of the vlan table */
#define AR8X16_MAX_VLANS	128

to

/* size of the vlan table */
#define AR8X16_MAX_VLANS	4096

Despite indicating amount of VLANs limited 128, it now also limits -usage- of VLAN ID > 127. Swconfig shows pvid 0 whenever VLAN ID > 127 and no traffic is (un)tagged on the port.

Confirmed on Mikrotik RB450G (AR8216 switch), when changed to 4096 it works as expected:

root@OpenWrt:/etc/config# swconfig dev switch0 show
Global attributes:
        enable_vlan: 1
        ar8xxx_mib_poll_interval: 0
        ar8xxx_mib_type: 0
        enable_mirror_rx: 0
        enable_mirror_tx: 0
        mirror_monitor_port: 0
        mirror_source_port: 0
        arl_table: address resolution table
Port 0: MAC 4c:5e:0c:47:5c:94

Port 0:
        mib: ???
        pvid: 0
        link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
        mib: ???
        pvid: 188
        link: port:1 link:down
Port 2:
        mib: ???
        pvid: 1
        link: port:2 link:down
Port 3:
        mib: ???
        pvid: 1
        link: port:3 link:down
Port 4:
        mib: ???
        pvid: 1
        link: port:4 link:down
VLAN 1:
        vid: 1
        ports: 0t 2 3 4
VLAN 188:
        vid: 188
        ports: 0t 1
1 Like

Hi hvandrie,

You can test this by specifying a vid, but keeping the vlan number below the table limit.
Example section (untested) of /etc/config/network:

config 'switch_vlan'
   option 'vlan'       '10'
   option 'vid'       '188'
   option 'device'     'switch0'
   option 'ports'      '0t 1'

When I use your proposed config, it messes up VLAN configuration completely.
Here's output with your config:

Global attributes:
enable_vlan: 1
ar8xxx_mib_poll_interval: 0
ar8xxx_mib_type: 0
enable_mirror_rx: 0
enable_mirror_tx: 0
mirror_monitor_port: 0
mirror_source_port: 0
arl_table: address resolution table
Port 0: MAC 4c:5e:0c:47:5c:93
Port 0: MAC 4c:5e:0c:47:5c:94
Port 1: MAC 00:0e:c6:89:a8:71

Port 0:
mib: ???
pvid: 0
link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
mib: ???
pvid: 10
link: port:1 link:up speed:1000baseT full-duplex auto
Port 2:
mib: ???
pvid: 1
link: port:2 link:down
Port 3:
mib: ???
pvid: 1
link: port:3 link:down
Port 4:
mib: ???
pvid: 10
link: port:4 link:down
VLAN 1:
vid: 1
ports: 0t 2 3
VLAN 10:
vid: 188
ports: 0t 1 4

When I compile my own firmware using 19.08.7 source and configured ar8216.h:

#define AR8X16_MAX_VLANS 4096

My anticipated config below works as expected without even need to define switch_port:

config switch_vlan
option device 'switch0'
option vlan '188'
option vid '188'
option ports '1 4 0t'

So try it without the switch_port, using a different value in vlan and vid

I already tried that before posting here.
Whenever VLAN ID =< 127, it works. But once > 127, ie 128, it breaks.