ramips: properly map pvid for vlans with remapped vid on mt7530/762x switches
[openwrt/staging/kaloz.git] / target / linux / ramips / files-4.9 / drivers / net / ethernet / mtk / mt7530.c
index e61f9fd8d32e5e2deb66f9bb79ef35497d439dbb..21f892655a5a3d8a8fbf61623657e44654b9f4b0 100644 (file)
@@ -616,10 +616,16 @@ mt7530_apply_config(struct switch_dev *dev)
 
        /* Port Default PVID */
        for (i = 0; i < MT7530_NUM_PORTS; i++) {
+               int vlan = priv->port_entries[i].pvid;
+               u16 pvid = 0;
                u32 val;
+
+               if (vlan < MT7530_NUM_VLANS && priv->vlan_entries[vlan].member)
+                       pvid = priv->vlan_entries[vlan].vid;
+
                val = mt7530_r32(priv, REG_ESW_PORT_PPBV1(i));
                val &= ~0xfff;
-               val |= priv->port_entries[i].pvid;
+               val |= pvid;
                mt7530_w32(priv, REG_ESW_PORT_PPBV1(i), val);
        }