Skip to content

Commit 54fa49e

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: Reconcile the meaning of TPID and TPID2 for E/T and P/Q/R/S
For first-generation switches (SJA1105E and SJA1105T): - TPID means C-Tag (typically 0x8100) - TPID2 means S-Tag (typically 0x88A8) While for the second generation switches (SJA1105P, SJA1105Q, SJA1105R, SJA1105S) it is the other way around: - TPID means S-Tag (typically 0x88A8) - TPID2 means C-Tag (typically 0x8100) In other words, E/T tags untagged traffic with TPID, and P/Q/R/S with TPID2. So the patch mentioned below fixed VLAN filtering for P/Q/R/S, but broke it for E/T. We strive for a common code path for all switches in the family, so just lie in the static config packing functions that TPID and TPID2 are at swapped bit offsets than they actually are, for P/Q/R/S. This will make both switches understand TPID to be ETH_P_8021Q and TPID2 to be ETH_P_8021AD. The meaning from the original E/T was chosen over P/Q/R/S because E/T is actually the one with public documentation available (UM10944.pdf). Fixes: f9a1a76 ("net: dsa: sja1105: Reverse TPID and TPID2") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3a323ed commit 54fa49e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,8 @@ static int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)
15691569

15701570
if (enabled) {
15711571
/* Enable VLAN filtering. */
1572-
tpid = ETH_P_8021AD;
1573-
tpid2 = ETH_P_8021Q;
1572+
tpid = ETH_P_8021Q;
1573+
tpid2 = ETH_P_8021AD;
15741574
} else {
15751575
/* Disable VLAN filtering. */
15761576
tpid = ETH_P_SJA1105;
@@ -1579,9 +1579,9 @@ static int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)
15791579

15801580
table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
15811581
general_params = table->entries;
1582-
/* EtherType used to identify outer tagged (S-tag) VLAN traffic */
1583-
general_params->tpid = tpid;
15841582
/* EtherType used to identify inner tagged (C-tag) VLAN traffic */
1583+
general_params->tpid = tpid;
1584+
/* EtherType used to identify outer tagged (S-tag) VLAN traffic */
15851585
general_params->tpid2 = tpid2;
15861586
/* When VLAN filtering is on, we need to at least be able to
15871587
* decode management traffic through the "backup plan".

drivers/net/dsa/sja1105/sja1105_static_config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ static size_t sja1105et_general_params_entry_packing(void *buf, void *entry_ptr,
142142
return size;
143143
}
144144

145+
/* TPID and TPID2 are intentionally reversed so that semantic
146+
* compatibility with E/T is kept.
147+
*/
145148
static size_t
146149
sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
147150
enum packing_op op)
@@ -166,9 +169,9 @@ sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
166169
sja1105_packing(buf, &entry->mirr_port, 141, 139, size, op);
167170
sja1105_packing(buf, &entry->vlmarker, 138, 107, size, op);
168171
sja1105_packing(buf, &entry->vlmask, 106, 75, size, op);
169-
sja1105_packing(buf, &entry->tpid, 74, 59, size, op);
172+
sja1105_packing(buf, &entry->tpid2, 74, 59, size, op);
170173
sja1105_packing(buf, &entry->ignore2stf, 58, 58, size, op);
171-
sja1105_packing(buf, &entry->tpid2, 57, 42, size, op);
174+
sja1105_packing(buf, &entry->tpid, 57, 42, size, op);
172175
sja1105_packing(buf, &entry->queue_ts, 41, 41, size, op);
173176
sja1105_packing(buf, &entry->egrmirrvid, 40, 29, size, op);
174177
sja1105_packing(buf, &entry->egrmirrpcp, 28, 26, size, op);

0 commit comments

Comments
 (0)