generic: ar8216: fix unknown packet flooding for ar8229/ar8236
[openwrt/openwrt.git] / target / linux / generic / files / drivers / net / phy / ar8216.c
index 683241cf1cee041ace2934b5963f63a68e44ec2f..9ac0d8fd4538951c6881615c342409ac54fdd83a 100644 (file)
@@ -943,10 +943,14 @@ ar8229_init_globals(struct ar8xxx_priv *priv)
        ar8xxx_reg_set(priv, AR8229_REG_QM_CTRL,
                       AR8229_QM_CTRL_ARP_EN);
 
-       /* Enable Broadcast/Multicast frames transmitted to the CPU */
+       /*
+        * Enable Broadcast/unknown multicast and unicast frames
+        * transmitted to the CPU port.
+        */
        ar8xxx_reg_set(priv, AR8216_REG_FLOOD_MASK,
                       AR8229_FLOOD_MASK_BC_DP(0) |
-                      AR8229_FLOOD_MASK_MC_DP(0));
+                      AR8229_FLOOD_MASK_MC_DP(0) |
+                      AR8229_FLOOD_MASK_UC_DP(0));
 
        /* setup MTU */
        ar8xxx_rmw(priv, AR8216_REG_GLOBAL_CTRL,
@@ -1008,7 +1012,7 @@ ar7240sw_init_globals(struct ar8xxx_priv *priv)
 
        /* Enable Broadcast frames transmitted to the CPU */
        ar8xxx_reg_set(priv, AR8216_REG_FLOOD_MASK,
-                      AR8236_FM_CPU_BROADCAST_EN);
+                      AR8216_FM_CPU_BROADCAST_EN);
 
        /* setup MTU */
        ar8xxx_rmw(priv, AR8216_REG_GLOBAL_CTRL,
@@ -1074,9 +1078,14 @@ ar8236_init_globals(struct ar8xxx_priv *priv)
        ar8xxx_reg_set(priv, AR8216_REG_ATU_CTRL,
                   AR8236_ATU_CTRL_RES);
 
-       /* enable cpu port to receive multicast and broadcast frames */
+       /*
+        * Enable Broadcast/unknown multicast and unicast frames
+        * transmitted to the CPU port.
+        */
        ar8xxx_reg_set(priv, AR8216_REG_FLOOD_MASK,
-                  AR8236_FM_CPU_BROADCAST_EN | AR8236_FM_CPU_BCAST_FWD_EN);
+                      AR8229_FLOOD_MASK_BC_DP(0) |
+                      AR8229_FLOOD_MASK_MC_DP(0) |
+                      AR8229_FLOOD_MASK_UC_DP(0));
 
        /* Enable MIB counters */
        ar8xxx_rmw(priv, AR8216_REG_MIB_FUNC, AR8216_MIB_FUNC | AR8236_MIB_EN,
@@ -1204,7 +1213,7 @@ ar8xxx_sw_set_vid(struct switch_dev *dev, const struct switch_attr *attr,
 {
        struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
 
-       if (val->port_vlan >= AR8X16_MAX_VLANS)
+       if (val->port_vlan >= dev->vlans)
                return -EINVAL;
 
        priv->vlan_id[val->port_vlan] = val->value.i;
@@ -1237,7 +1246,7 @@ ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
        u8 ports;
        int i;
 
-       if (val->port_vlan >= AR8X16_MAX_VLANS)
+       if (val->port_vlan >= dev->vlans)
                return -EINVAL;
 
        ports = priv->vlan_table[val->port_vlan];
@@ -1277,7 +1286,7 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val)
 
                        /* make sure that an untagged port does not
                         * appear in other vlans */
-                       for (j = 0; j < AR8X16_MAX_VLANS; j++) {
+                       for (j = 0; j < dev->vlans; j++) {
                                if (j == val->port_vlan)
                                        continue;
                                priv->vlan_table[j] &= ~(1 << p->id);
@@ -1356,7 +1365,7 @@ ar8xxx_sw_hw_apply(struct switch_dev *dev)
        if (!priv->init) {
                /* calculate the port destination masks and load vlans
                 * into the vlan translation unit */
-               for (j = 0; j < AR8X16_MAX_VLANS; j++) {
+               for (j = 0; j < dev->vlans; j++) {
                        u8 vp = priv->vlan_table[j];
 
                        if (!vp)
@@ -1409,7 +1418,7 @@ ar8xxx_sw_reset_switch(struct switch_dev *dev)
        memset(&priv->vlan, 0, sizeof(struct ar8xxx_priv) -
                offsetof(struct ar8xxx_priv, vlan));
 
-       for (i = 0; i < AR8X16_MAX_VLANS; i++)
+       for (i = 0; i < dev->vlans; i++)
                priv->vlan_id[i] = i;
 
        /* Configure all ports */