aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-06-08 20:18:38 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-06-08 20:18:38 +0000
commitd577cfa397c08d961c5fa5e3faef1ea8cd7a53b7 (patch)
tree1062119eec6134a7ab7be0f6c65ce04633b81803 /target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
parentd08093b8b3370b67b68420af2c68e0c298e10de3 (diff)
downloadupstream-d577cfa397c08d961c5fa5e3faef1ea8cd7a53b7.tar.gz
upstream-d577cfa397c08d961c5fa5e3faef1ea8cd7a53b7.tar.bz2
upstream-d577cfa397c08d961c5fa5e3faef1ea8cd7a53b7.zip
ip17xx: Add VLAN tag field
Since IP175D uses tag-based VLANs, we need an ability to set VLAN tag of every VLAN. Signed-off-by: Martin Mares <mj@ucw.cz> Signed-off-by: Patrick Horn <patrick.horn@gmail.com> SVN-Revision: 21718
Diffstat (limited to 'target/linux/generic-2.6/files/drivers/net/phy/ip175c.c')
-rw-r--r--target/linux/generic-2.6/files/drivers/net/phy/ip175c.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/target/linux/generic-2.6/files/drivers/net/phy/ip175c.c b/target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
index 187fcfeaf5..706c973c1c 100644
--- a/target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
+++ b/target/linux/generic-2.6/files/drivers/net/phy/ip175c.c
@@ -278,6 +278,7 @@ struct ip175c_state {
int num_vlans;
struct vlan_state {
unsigned int ports;
+ unsigned int tag; // VLAN tag (IP175D only)
} vlans[MAX_VLANS];
const struct register_mappings *regs;
reg proc_mii; // phy/reg for the low level register access via swconfig
@@ -743,8 +744,10 @@ static void ip175c_reset_vlan_config(struct ip175c_state *state)
state->remove_tag = (state->vlan_enabled ? ((1<<state->regs->NUM_PORTS)-1) : 0x0000);
state->add_tag = 0x0000;
- for (i = 0; i < MAX_VLANS; i++)
+ for (i = 0; i < MAX_VLANS; i++) {
state->vlans[i].ports = 0x0000;
+ state->vlans[i].tag = (i ? i : 16);
+ }
for (i = 0; i < MAX_PORTS; i++)
state->ports[i].pvid = 0;
}
@@ -1012,6 +1015,34 @@ static int ip175c_read_name(struct switch_dev *dev, const struct switch_attr *at
return 0;
}
+static int ip175c_get_tag(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
+{
+ struct ip175c_state *state = dev->priv;
+ int vlan = val->port_vlan;
+
+ if (vlan < 0 || vlan >= MAX_VLANS)
+ return -EINVAL;
+
+ val->value.i = state->vlans[vlan].tag;
+ return 0;
+}
+
+static int ip175c_set_tag(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
+{
+ struct ip175c_state *state = dev->priv;
+ int vlan = val->port_vlan;
+ int tag = val->value.i;
+
+ if (vlan < 0 || vlan >= MAX_VLANS)
+ return -EINVAL;
+
+ if (tag < 0 || tag > 4095)
+ return -EINVAL;
+
+ state->vlans[vlan].tag = tag;
+ return state->regs->update_state(state);
+}
+
static int ip175c_set_port_speed(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
{
struct ip175c_state *state = dev->priv;
@@ -1162,6 +1193,10 @@ enum Globals {
IP175C_REGISTER_ERRNO,
};
+enum Vlans {
+ IP175C_VLAN_TAG,
+};
+
static const struct switch_attr ip175c_global[] = {
[IP175C_ENABLE_VLAN] = {
.id = IP175C_ENABLE_VLAN,
@@ -1207,6 +1242,14 @@ static const struct switch_attr ip175c_global[] = {
};
static const struct switch_attr ip175c_vlan[] = {
+ [IP175C_VLAN_TAG] = {
+ .id = IP175C_VLAN_TAG,
+ .type = SWITCH_TYPE_INT,
+ .description = "VLAN tag (0-4095) [IP175D only]",
+ .name = "tag",
+ .get = ip175c_get_tag,
+ .set = ip175c_set_tag,
+ }
};
static const struct switch_attr ip175c_port[] = {