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
2020 refcount_t refcount;
2121 };
2222
23+#define DSA_8021Q_N_SUBVLAN 8
24+
2325 #if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)
2426
2527 int 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
4244
4345 u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);
4446
47+u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan);
48+
4549 int dsa_8021q_rx_switch_id(u16 vid);
4650
4751 int dsa_8021q_rx_source_port(u16 vid);
4852
53+u16 dsa_8021q_rx_subvlan(u16 vid);
54+
4955 bool vid_is_dsa_8021q(u16 vid);
5056
5157 #else
@@ -88,6 +94,11 @@ u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port) · 36 unmodified lines
8894 return 0;
8995 }
9096
97+u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan)
98+{
99+ return 0;
100+}
101+
91102 int dsa_8021q_rx_switch_id(u16 vid)
92103 {
93104 return 0;
@@ -98,6 +109,11 @@ int dsa_8021q_rx_source_port(u16 vid) · 4 unmodified lines
98109 return 0;
99110 }
100111
112+u16 dsa_8021q_rx_subvlan(u16 vid)
113+{
114+ return 0;
115+}
116+
101117 bool vid_is_dsa_8021q(u16 vid)
102118 {
103119 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