diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-07-15 13:05:50 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-07-15 13:05:50 +0000 |
commit | 48934bbd887a6708739747e7ac75f4df6b37477a (patch) | |
tree | 74d113e258bda4f1bec80d90e65e847be1fa76da /target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | |
parent | d4e0b75dda5b6293add3fe9a61286cf1dcc3a10d (diff) | |
download | mtk-20170518-48934bbd887a6708739747e7ac75f4df6b37477a.zip mtk-20170518-48934bbd887a6708739747e7ac75f4df6b37477a.tar.gz mtk-20170518-48934bbd887a6708739747e7ac75f4df6b37477a.tar.bz2 |
generic: rtl8366: add common rtl8366_sw_{get,set}_vlan_ports functions
SVN-Revision: 22204
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy/rtl8366_smi.c')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c index e46768f..341f2e9 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c @@ -830,6 +830,57 @@ int rtl8366_sw_get_vlan_info(struct switch_dev *dev, } EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_info); +int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val) +{ + struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); + struct switch_port *port; + struct rtl8366_vlan_4k vlan4k; + int i; + + if (!smi->ops->is_vlan_valid(smi, val->port_vlan)) + return -EINVAL; + + smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k); + + port = &val->value.ports[0]; + val->len = 0; + for (i = 0; i < smi->num_ports; i++) { + if (!(vlan4k.member & BIT(i))) + continue; + + port->id = i; + port->flags = (vlan4k.untag & BIT(i)) ? + 0 : BIT(SWITCH_PORT_FLAG_TAGGED); + val->len++; + port++; + } + return 0; +} +EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_ports); + +int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val) +{ + struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); + struct switch_port *port; + u32 member = 0; + u32 untag = 0; + int i; + + if (!smi->ops->is_vlan_valid(smi, val->port_vlan)) + return -EINVAL; + + port = &val->value.ports[0]; + for (i = 0; i < val->len; i++, port++) { + member |= BIT(port->id); + + if (!(port->flags & BIT(SWITCH_PORT_FLAG_TAGGED))) + untag |= BIT(port->id); + } + + return rtl8366_set_vlan(smi, val->port_vlan, member, untag, 0); +} +EXPORT_SYMBOL_GPL(rtl8366_sw_set_vlan_ports); + struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent) { struct rtl8366_smi *smi; |