aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIoana Ciornei <ioana.ciornei@nxp.com>2019-05-29 17:42:30 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-30 17:47:14 -0400
commitd34d2baa9173f6e0c0f22d005d18e83d1cb54d8d (patch)
tree6faa3f16bcf1c7b9d598f3345fde3da5d11555dc
parent21808437214637952b61beaba6034d97880fbeb3 (diff)
net: dsa: tag_8021q: Change order of rx_vid setup
The 802.1Q tagging performs an unbalanced setup in terms of RX VIDs on the CPU port. For the ingress path of a 802.1Q switch to work, the RX VID of a port needs to be seen as tagged egress on the CPU port. While configuring the other front-panel ports to be part of this VID, for bridge scenarios, the untagged flag is applied even on the CPU port in dsa_switch_vlan_add. This happens because DSA applies the same flags on the CPU port as on the (bridge-controlled) slave ports, and the effect in this case is that the CPU port tagged settings get deleted. Instead of fixing DSA by introducing a way to control VLAN flags on the CPU port (and hence stop inheriting from the slave ports) - a hard, perhaps intractable problem - avoid this situation by moving the setup part of the RX VID on the CPU port after all the other front-panel ports have been added to the VID. Fixes: f9bbe4477c30 ("net: dsa: Optional VLAN-based port separation for switches without tagging") Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/dsa/tag_8021q.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index 8ae48c7e1e76..4adec6bbfe59 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -128,10 +128,7 @@ int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int port, bool enabled)
128 u16 flags; 128 u16 flags;
129 129
130 if (i == upstream) 130 if (i == upstream)
131 /* CPU port needs to see this port's RX VID 131 continue;
132 * as tagged egress.
133 */
134 flags = 0;
135 else if (i == port) 132 else if (i == port)
136 /* The RX VID is pvid on this port */ 133 /* The RX VID is pvid on this port */
137 flags = BRIDGE_VLAN_INFO_UNTAGGED | 134 flags = BRIDGE_VLAN_INFO_UNTAGGED |
@@ -150,6 +147,20 @@ int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int port, bool enabled)
150 return err; 147 return err;
151 } 148 }
152 } 149 }
150
151 /* CPU port needs to see this port's RX VID
152 * as tagged egress.
153 */
154 if (enabled)
155 err = dsa_port_vid_add(upstream_dp, rx_vid, 0);
156 else
157 err = dsa_port_vid_del(upstream_dp, rx_vid);
158 if (err) {
159 dev_err(ds->dev, "Failed to apply RX VID %d to port %d: %d\n",
160 rx_vid, port, err);
161 return err;
162 }
163
153 /* Finally apply the TX VID on this port and on the CPU port */ 164 /* Finally apply the TX VID on this port and on the CPU port */
154 if (enabled) 165 if (enabled)
155 err = dsa_port_vid_add(dp, tx_vid, BRIDGE_VLAN_INFO_UNTAGGED); 166 err = dsa_port_vid_add(dp, tx_vid, BRIDGE_VLAN_INFO_UNTAGGED);