Skip to content

Commit e045124

Browse files
LGA1150davem330
authored andcommitted
net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode
In VLAN-unaware mode, the Egress Tag (EG_TAG) field in Port VLAN Control register must be set to Consistent to let tagged frames pass through as is, otherwise their tags will be stripped. Fixes: 83163f7 ("net: dsa: mediatek: add VLAN support for MT7530") Signed-off-by: DENG Qingfang <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Tested-by: René van Dorst <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent edadedf commit e045124

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,9 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port)
773773
*/
774774
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
775775
MT7530_PORT_MATRIX_MODE);
776-
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK,
777-
VLAN_ATTR(MT7530_VLAN_TRANSPARENT));
776+
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK | PVC_EG_TAG_MASK,
777+
VLAN_ATTR(MT7530_VLAN_TRANSPARENT) |
778+
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
778779

779780
for (i = 0; i < MT7530_NUM_PORTS; i++) {
780781
if (dsa_is_user_port(ds, i) &&
@@ -790,8 +791,8 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port)
790791
if (all_user_ports_removed) {
791792
mt7530_write(priv, MT7530_PCR_P(MT7530_CPU_PORT),
792793
PCR_MATRIX(dsa_user_ports(priv->ds)));
793-
mt7530_write(priv, MT7530_PVC_P(MT7530_CPU_PORT),
794-
PORT_SPEC_TAG);
794+
mt7530_write(priv, MT7530_PVC_P(MT7530_CPU_PORT), PORT_SPEC_TAG
795+
| PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
795796
}
796797
}
797798

@@ -817,8 +818,9 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port)
817818
/* Set the port as a user port which is to be able to recognize VID
818819
* from incoming packets before fetching entry within the VLAN table.
819820
*/
820-
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK,
821-
VLAN_ATTR(MT7530_VLAN_USER));
821+
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK | PVC_EG_TAG_MASK,
822+
VLAN_ATTR(MT7530_VLAN_USER) |
823+
PVC_EG_TAG(MT7530_VLAN_EG_DISABLED));
822824
}
823825

824826
static void
@@ -1303,6 +1305,10 @@ mt7530_setup(struct dsa_switch *ds)
13031305
mt7530_cpu_port_enable(priv, i);
13041306
else
13051307
mt7530_port_disable(ds, i);
1308+
1309+
/* Enable consistent egress tag */
1310+
mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
1311+
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
13061312
}
13071313

13081314
/* Setup port 5 */

drivers/net/dsa/mt7530.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,16 @@ enum mt7530_port_mode {
172172
/* Register for port vlan control */
173173
#define MT7530_PVC_P(x) (0x2010 + ((x) * 0x100))
174174
#define PORT_SPEC_TAG BIT(5)
175+
#define PVC_EG_TAG(x) (((x) & 0x7) << 8)
176+
#define PVC_EG_TAG_MASK PVC_EG_TAG(7)
175177
#define VLAN_ATTR(x) (((x) & 0x3) << 6)
176178
#define VLAN_ATTR_MASK VLAN_ATTR(3)
177179

180+
enum mt7530_vlan_port_eg_tag {
181+
MT7530_VLAN_EG_DISABLED = 0,
182+
MT7530_VLAN_EG_CONSISTENT = 1,
183+
};
184+
178185
enum mt7530_vlan_port_attr {
179186
MT7530_VLAN_USER = 0,
180187
MT7530_VLAN_TRANSPARENT = 3,

0 commit comments

Comments
 (0)