diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-09-23 10:19:58 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-09-23 10:19:58 +0000 |
commit | 200e1d786d1cdd816cdf6f17e6933319c04a3ed3 (patch) | |
tree | 54305a035ead1c00d8a7662e503c96dd4aaf559b /target/linux/generic/files | |
parent | 849e774cd21face37e4daaad1fbc0e8460835c1a (diff) | |
download | upstream-200e1d786d1cdd816cdf6f17e6933319c04a3ed3.tar.gz upstream-200e1d786d1cdd816cdf6f17e6933319c04a3ed3.tar.bz2 upstream-200e1d786d1cdd816cdf6f17e6933319c04a3ed3.zip |
ar71xx: ar8216: tagged+untagged on ar8327 (#12181)
This allows tagged and untagged traffic together on the same port on ar8327
switch devices.
I looked at the first attempt to do this in r40777 (ar71xx: Fix tagged+untagged
operation on AR8327N (#12181)). I also set the vlan and port egress policies
like that change. But I change vlan_tagged in an less intrusive way. The
tagged/untagged decision is now based on the following rules:
- if vid != pvid then traffic is always tagged
- if vid == pvid then vlan_tagged stores if the traffic should be tagged
Tested on TP-Link WDR-3600 (ar8327N).
Signed-off-by: Valentin Spreckels <Valentin.Spreckels@Informatik.Uni-Oldenburg.DE>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@42653 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.c | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 3efd460c7f..bd6cc97d55 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -1748,7 +1748,7 @@ ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask) mode = AR8327_VTU_FUNC0_EG_MODE_NOT; else if (priv->vlan == 0) mode = AR8327_VTU_FUNC0_EG_MODE_KEEP; - else if (priv->vlan_tagged & BIT(i)) + else if ((priv->vlan_tagged & BIT(i)) || (priv->vlan_id[priv->pvid[i]] != vid)) mode = AR8327_VTU_FUNC0_EG_MODE_TAG; else mode = AR8327_VTU_FUNC0_EG_MODE_UNTAG; @@ -1767,10 +1767,7 @@ ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members) if (priv->vlan) { pvid = priv->vlan_id[priv->pvid[port]]; - if (priv->vlan_tagged & (1 << port)) - egress = AR8327_PORT_VLAN1_OUT_MODE_TAG; - else - egress = AR8327_PORT_VLAN1_OUT_MODE_UNTAG; + egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD; ingress = AR8216_IN_SECURE; } else { pvid = port; @@ -1903,6 +1900,30 @@ ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val) } static int +ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val) +{ + struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); + u8 ports = priv->vlan_table[val->port_vlan]; + int i; + + val->len = 0; + for (i = 0; i < dev->ports; i++) { + struct switch_port *p; + + if (!(ports & (1 << i))) + continue; + + p = &val->value.ports[val->len++]; + p->id = i; + if ((priv->vlan_tagged & (1 << i)) || (priv->pvid[i] != val->port_vlan)) + p->flags = (1 << SWITCH_PORT_FLAG_TAGGED); + else + p->flags = 0; + } + return 0; +} + +static int ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val) { struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); @@ -1933,6 +1954,31 @@ ar8xxx_sw_set_ports(struct switch_dev *dev, struct switch_val *val) return 0; } +static int +ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val) +{ + struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); + u8 *vt = &priv->vlan_table[val->port_vlan]; + int i, j; + + *vt = 0; + for (i = 0; i < val->len; i++) { + struct switch_port *p = &val->value.ports[i]; + + if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) { + if (val->port_vlan == priv->pvid[p->id]) { + priv->vlan_tagged |= (1 << p->id); + } + } else { + priv->vlan_tagged &= ~(1 << p->id); + priv->pvid[p->id] = val->port_vlan; + } + + *vt |= 1 << p->id; + } + return 0; +} + static void ar8327_set_mirror_regs(struct ar8xxx_priv *priv) { @@ -2475,8 +2521,8 @@ static const struct switch_dev_ops ar8327_sw_ops = { }, .get_port_pvid = ar8xxx_sw_get_pvid, .set_port_pvid = ar8xxx_sw_set_pvid, - .get_vlan_ports = ar8xxx_sw_get_ports, - .set_vlan_ports = ar8xxx_sw_set_ports, + .get_vlan_ports = ar8327_sw_get_ports, + .set_vlan_ports = ar8327_sw_set_ports, .apply_config = ar8xxx_sw_hw_apply, .reset_switch = ar8xxx_sw_reset_switch, .get_port_link = ar8xxx_sw_get_port_link, |