--- trunk/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c.ORG 2012-02-10 20:33:20.000000000 +0900 +++ trunk/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c 2012-02-25 13:31:02.000000000 +0900 @@ -626,6 +626,11 @@ if (as->vlan) { vid = as->vlan_id[as->pvid[port]]; mode = AR7240_PORT_VLAN_MODE_SECURE; + if (as->vlan_tagged & BIT(port)) { + mode = AR934X_PORT_VLAN2_8021Q_MODE_PORT_FALLBACK; + } else { + mode = AR934X_PORT_VLAN2_8021Q_MODE_SECURE; + } } else { vid = port; mode = AR7240_PORT_VLAN_MODE_PORT_ONLY; @@ -780,6 +785,50 @@ } static int +ar7240_set_learning_enable(struct switch_dev *dev, const struct switch_attr *attr, + struct switch_val *val) +{ + struct ar7240sw *as = sw_to_ar7240(dev); + int i; + u32 v; + + for (i = 0; i < AR7240_NUM_PORTS; i++) { + v = ar7240sw_reg_read(as->mii_bus, AR7240_REG_PORT_CTRL(i)); + v &= ~AR7240_PORT_CTRL_LEARN; + + if (val->value.i){ + /* Enable port learning for ALL */ + v |= AR7240_PORT_CTRL_LEARN; + } + + ar7240sw_reg_write(as->mii_bus, AR7240_REG_PORT_CTRL(i), v); + } + + return 0; +} + +static int +ar7240_get_learning_enable(struct switch_dev *dev, const struct switch_attr *attr, + struct switch_val *val) +{ + struct ar7240sw *as = sw_to_ar7240(dev); + u32 v; + + v = ar7240sw_reg_read(as->mii_bus, AR7240_REG_PORT_CTRL(0)); + + v &= AR7240_PORT_CTRL_LEARN; + + if (v == AR7240_PORT_CTRL_LEARN){ + val->value.i = 1; + } + else { + val->value.i = 0; + } + + return 0; +} + +static int ar7240_set_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) { @@ -985,6 +1034,13 @@ static struct switch_attr ar7240_globals[] = { { .type = SWITCH_TYPE_INT, + .name = "enable_learning", + .description = "Enable learning", + .set = ar7240_set_learning_enable, + .get = ar7240_get_learning_enable, + .max = 1 + }, { + .type = SWITCH_TYPE_INT, .name = "enable_vlan", .description = "Enable VLAN mode", .set = ar7240_set_vlan,