This is the same switch as in the Dlink DIR-825.
I have discovered this port layout:
0 -> Physical port tag 4
1 -> Physical port tag 3
2 -> Physical port tag 2
3 -> Physical port tag 1
4 -> Physical port tag Internet (eth1)
5 -> Internal connected to the CPU (eth0)
port 4 is NOT connected to the switch and shall not be used with swconfig, use regular vconfig to add Q tags to it
The switch are capable of 16 VLANs and can have VLAN id 0-4095.
The command "swconfig dev rtl8366s port 0 set pvid 4095"
Give this result:
swconfig dev rtl8366s vlan 3 show
VLAN 3:
info: VLAN 3: Ports: 0
vid prio member untag fid
MC: 4095 0 0x0021 0x001f 0
4K: 4095 0x0021 0x001f 0
ports: 0 5t
This shows that it adds port 0 to VLAN number 3, not VLAN q-tag 3, and sets the vid (Q-tag) to 4095.
The first "Ports" line tells which ports in the VLAN that the Q-tag isn't sent out to, regular untagged packets.
It adds 0 5t to the second ports line that seems to which ports are allowed in the VLAN and the 5t tags traffic to the internal interface (eth0)
It takes the first VLAN number that doesn't have any ports assigned to it, that's why it's VLAN #3
If i then run:
swconfig dev rtl8366s vlan 3 set ports '0t 5t'
I got this result:
VLAN 3:
info: VLAN 3: Ports:
vid prio member untag fid
MC: 4095 0 0x0021 0x0000 0
4K: 4095 0x0021 0x0000 0
ports: 0t 5t
No untagged ports are configured and port 0 are removed as untagged and moved to the second "ports" line as a tagged port.
A port cannot belong to the same vlan as both tagged and untagged, that's why it moved.
If I the run the command:
swconfig dev rtl8366s port 0 set pvid 2
I got this:
VLAN 1:
info: VLAN 1: Ports: 02
vid prio member untag fid
MC: 2 0 0x0025 0x001f 0
4K: 2 0x0025 0x001f 0
ports: 0 2 5t
VLAN 1 was already configured and had vid 2 already set and port 2 was sending out packets untagged.
With this configuration i have VLAN 3 sending out packets to port 0 as tagged on VLAN 4095
Untagged packets on port 0 and 2 belongs to VLAN 1 with vid 2.
To have VLAN 1 and VLAN 3 handled in the router itself you have to create the virtual interfaces with vconfig command.
"vconfig add eth0 2" adds an interface with vid 2
"vconfig add eth0 4095" adds an interface with vid 4095
This creates eth0.2 and eth0.4095
From my point the parsing of the network configuration file is wrong for the switch configuration, but it's still a beta :-)