History

net: dsa: tag_8021q: support up to 8 VLANs per port using sub-VLANs

For switches that support VLAN retagging, such as sja1105, we extend dsa_8021q by encoding a "sub-VLAN" into the remaining 3 free bits in the dsa_8021q tag. A sub-VLAN is nothing more than a number in the range 0-7, which serves as an index into a per-port driver lookup table. The sub-VLAN value of zero means that traffic is untagged (this is also backwards-compatible with dsa_8021q without retagging). The switch should be configured to retag VLAN-tagged traffic that gets transmitted towards the CPU port (and towards the CPU only). Example: bridge vlan add dev sw1p0 vid 100 The switch retags frames received on port 0, going to the CPU, and having VID 100, to the VID of 1104 (0x0450). In dsa_8021q language: | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +-----------+-----+-----------------+-----------+-----------------------+ | DIR | SVL | SWITCH_ID | SUBVLAN | PORT | +-----------+-----+-----------------+-----------+-----------------------+ 0x0450 means: - DIR = 0b01: this is an RX VLAN - SUBVLAN = 0b001: this is subvlan #1 - SWITCH_ID = 0b001: this is switch 1 (see the name "sw1p0") - PORT = 0b0000: this is port 0 (see the name "sw1p0") The driver also remembers the "1 -> 100" mapping. In the hotpath, if the sub-VLAN from the tag encodes a non-untagged frame, this mapping is used to create a VLAN hwaccel tag, with the value of 100.

Vladimir Oltean committed 6 years ago

Commit 3eaae1d1 parent 38b5bee2 files · +64 −8Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/dsa/8021q.h+16−0
@@ -20,6 +20,8 @@ struct dsa_8021q_crosschip_link { · 19 unmodified lines
20 refcount_t refcount;20 refcount_t refcount;
21};21};
22 22
23#define DSA_8021Q_N_SUBVLAN 8
24
23#if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)25#if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)
24 26
25int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,27int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
@@ -42,10 +44,14 @@ u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); · 16 unmodified lines
42 44
43u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);45u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);
44 46
47u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan);
48
45int dsa_8021q_rx_switch_id(u16 vid);49int dsa_8021q_rx_switch_id(u16 vid);
46 50
47int dsa_8021q_rx_source_port(u16 vid);51int dsa_8021q_rx_source_port(u16 vid);
48 52
53u16 dsa_8021q_rx_subvlan(u16 vid);
54
49bool vid_is_dsa_8021q(u16 vid);55bool vid_is_dsa_8021q(u16 vid);
50 56
51#else57#else
@@ -88,6 +94,11 @@ u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port) · 36 unmodified lines
88 return 0;94 return 0;
89}95}
90 96
97u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan)
98{
99 return 0;
100}
101
91int dsa_8021q_rx_switch_id(u16 vid)102int dsa_8021q_rx_switch_id(u16 vid)
92{103{
93 return 0;104 return 0;
@@ -98,6 +109,11 @@ int dsa_8021q_rx_source_port(u16 vid) · 4 unmodified lines
98 return 0;109 return 0;
99}110}
100 111
112u16 dsa_8021q_rx_subvlan(u16 vid)
113{
114 return 0;
115}
116
101bool vid_is_dsa_8021q(u16 vid)117bool vid_is_dsa_8021q(u16 vid)
102{118{
103 return false;119 return false;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t