aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:47 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-07-15 13:05:47 +0000
commitd4e0b75dda5b6293add3fe9a61286cf1dcc3a10d (patch)
tree26da327008d568738d100d7f792051b524c0d266 /target
parenta59fa57985cf73c3c475bfbbb375dd9aac1815bd (diff)
downloadupstream-d4e0b75dda5b6293add3fe9a61286cf1dcc3a10d.tar.gz
upstream-d4e0b75dda5b6293add3fe9a61286cf1dcc3a10d.tar.bz2
upstream-d4e0b75dda5b6293add3fe9a61286cf1dcc3a10d.zip
generic: rtl8366: add common rtl8366_sw_get_vlan_info
SVN-Revision: 22203
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.c42
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.h3
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c43
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366s.c43
4 files changed, 47 insertions, 84 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 a45c844cad..e46768f827 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -788,6 +788,48 @@ int rtl8366_sw_get_port_mib(struct switch_dev *dev,
}
EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_mib);
+int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val)
+{
+ int i;
+ u32 len = 0;
+ struct rtl8366_vlan_4k vlan4k;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ char *buf = smi->buf;
+ int err;
+
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
+ return -EINVAL;
+
+ memset(buf, '\0', sizeof(smi->buf));
+
+ err = smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
+ if (err)
+ return err;
+
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
+ "VLAN %d: Ports: '", vlan4k.vid);
+
+ for (i = 0; i < smi->num_ports; i++) {
+ if (!(vlan4k.member & (1 << i)))
+ continue;
+
+ len += snprintf(buf + len, sizeof(smi->buf) - len, "%d%s", i,
+ (vlan4k.untag & (1 << i)) ? "" : "t");
+ }
+
+ len += snprintf(buf + len, sizeof(smi->buf) - len,
+ "', members=%04x, untag=%04x, fid=%u",
+ vlan4k.member, vlan4k.untag, vlan4k.fid);
+
+ val->value.s = buf;
+ val->len = len;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_info);
+
struct rtl8366_smi *rtl8366_smi_alloc(struct device *parent)
{
struct rtl8366_smi *smi;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
index b53c5010ce..ae3b7db6f2 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -114,5 +114,8 @@ int rtl8366_sw_set_port_pvid(struct switch_dev *dev, int port, int val);
int rtl8366_sw_get_port_mib(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val);
+int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val);
#endif /* _RTL8366_SMI_H */
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index ae976f45b2..231e482912 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -705,47 +705,6 @@ static int rtl8366rb_sw_get_port_link(struct switch_dev *dev,
return 0;
}
-static int rtl8366rb_sw_get_vlan_info(struct switch_dev *dev,
- const struct switch_attr *attr,
- struct switch_val *val)
-{
- int i;
- u32 len = 0;
- struct rtl8366_vlan_4k vlan4k;
- struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
- char *buf = smi->buf;
- int err;
-
- if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
- return -EINVAL;
-
- memset(buf, '\0', sizeof(smi->buf));
-
- err = smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
- if (err)
- return err;
-
- len += snprintf(buf + len, sizeof(smi->buf) - len,
- "VLAN %d: Ports: '", vlan4k.vid);
-
- for (i = 0; i < smi->num_ports; i++) {
- if (!(vlan4k.member & (1 << i)))
- continue;
-
- len += snprintf(buf + len, sizeof(smi->buf) - len, "%d%s", i,
- (vlan4k.untag & (1 << i)) ? "" : "t");
- }
-
- len += snprintf(buf + len, sizeof(smi->buf) - len,
- "', members=%04x, untag=%04x, fid=%u",
- vlan4k.member, vlan4k.untag, vlan4k.fid);
-
- val->value.s = buf;
- val->len = len;
-
- return 0;
-}
-
static int rtl8366rb_sw_set_port_led(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
@@ -937,7 +896,7 @@ static struct switch_attr rtl8366rb_vlan[] = {
.description = "Get vlan information",
.max = 1,
.set = NULL,
- .get = rtl8366rb_sw_get_vlan_info,
+ .get = rtl8366_sw_get_vlan_info,
},
};
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 4ac675ea50..167f34f8c3 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -730,47 +730,6 @@ static int rtl8366s_sw_get_port_link(struct switch_dev *dev,
return 0;
}
-static int rtl8366s_sw_get_vlan_info(struct switch_dev *dev,
- const struct switch_attr *attr,
- struct switch_val *val)
-{
- int i;
- u32 len = 0;
- struct rtl8366_vlan_4k vlan4k;
- struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
- char *buf = smi->buf;
- int err;
-
- if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
- return -EINVAL;
-
- memset(buf, '\0', sizeof(smi->buf));
-
- err = smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
- if (err)
- return err;
-
- len += snprintf(buf + len, sizeof(smi->buf) - len,
- "VLAN %d: Ports: '", vlan4k.vid);
-
- for (i = 0; i < smi->num_ports; i++) {
- if (!(vlan4k.member & (1 << i)))
- continue;
-
- len += snprintf(buf + len, sizeof(smi->buf) - len, "%d%s", i,
- (vlan4k.untag & (1 << i)) ? "" : "t");
- }
-
- len += snprintf(buf + len, sizeof(smi->buf) - len,
- "', members=%04x, untag=%04x, fid=%u",
- vlan4k.member, vlan4k.untag, vlan4k.fid);
-
- val->value.s = buf;
- val->len = len;
-
- return 0;
-}
-
static int rtl8366s_sw_set_port_led(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
@@ -964,7 +923,7 @@ static struct switch_attr rtl8366s_vlan[] = {
.description = "Get vlan information",
.max = 1,
.set = NULL,
- .get = rtl8366s_sw_get_vlan_info,
+ .get = rtl8366_sw_get_vlan_info,
},
};