aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-11-24 10:01:21 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-11-24 10:01:21 +0000
commit8120006c058487889fb829ed240b6ca663a420d4 (patch)
treef68f6a795022ea038b4a0e3cb5c76dc126babc98
parent404b68fcd2ce817d0a866c786b93fe4b34289f00 (diff)
downloadupstream-8120006c058487889fb829ed240b6ca663a420d4.tar.gz
upstream-8120006c058487889fb829ed240b6ca663a420d4.tar.bz2
upstream-8120006c058487889fb829ed240b6ca663a420d4.zip
generic: add rtl8366rb switch vlan fid support
Allows to use fids 0 to 7. Default is 0. Those who will use this don't forget to `set vlan fid` every time after `set vlan ports` if you want non default behavior. Minor changes. Version bump. Signed-off-by: Roman Yeryomin <roman@advem.lv> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24125 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.c46
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.h6
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c21
3 files changed, 66 insertions, 7 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 dc83ba7d42..e60b708d74 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -972,6 +972,52 @@ int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val)
}
EXPORT_SYMBOL_GPL(rtl8366_sw_set_vlan_ports);
+int rtl8366_sw_get_vlan_fid(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val)
+{
+ struct rtl8366_vlan_4k vlan4k;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ int err;
+
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
+ return -EINVAL;
+
+ err = smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
+ if (err)
+ return err;
+
+ val->value.i = vlan4k.fid;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_get_vlan_fid);
+
+int rtl8366_sw_set_vlan_fid(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val)
+{
+ struct rtl8366_vlan_4k vlan4k;
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ int err;
+
+ if (!smi->ops->is_vlan_valid(smi, val->port_vlan))
+ return -EINVAL;
+
+ if (val->value.i < 0 || val->value.i > attr->max)
+ return -EINVAL;
+
+ err = smi->ops->get_vlan_4k(smi, val->port_vlan, &vlan4k);
+ if (err)
+ return err;
+
+ return rtl8366_set_vlan(smi, val->port_vlan,
+ vlan4k.member,
+ vlan4k.untag,
+ val->value.i);
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_set_vlan_fid);
+
int rtl8366_sw_get_vlan_enable(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
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 af02cfd200..bdc7dfb023 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -120,6 +120,12 @@ int rtl8366_sw_get_port_mib(struct switch_dev *dev,
int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val);
+int rtl8366_sw_get_vlan_fid(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val);
+int rtl8366_sw_set_vlan_fid(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val);
int rtl8366_sw_get_vlan_ports(struct switch_dev *dev, struct switch_val *val);
int rtl8366_sw_set_vlan_ports(struct switch_dev *dev, struct switch_val *val);
int rtl8366_sw_get_vlan_enable(struct switch_dev *dev,
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index ae6d429254..55731baf31 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -1,5 +1,5 @@
/*
- * Platform driver for the Realtek RTL8366S ethernet switch
+ * Platform driver for the Realtek RTL8366RB ethernet switch
*
* Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2010 Antti Seppälä <a.seppala@gmail.com>
@@ -21,7 +21,7 @@
#include "rtl8366_smi.h"
#define RTL8366RB_DRIVER_DESC "Realtek RTL8366RB ethernet switch driver"
-#define RTL8366RB_DRIVER_VER "0.2.2"
+#define RTL8366RB_DRIVER_VER "0.2.3"
#define RTL8366RB_PHY_NO_MAX 4
#define RTL8366RB_PHY_PAGE_MAX 7
@@ -182,7 +182,7 @@
#define RTL8366RB_EB_PREIFG_MASK (1 << RTL8366RB_EB_PREIFG_OFFSET)
#define RTL8366RB_BDTH_SW_MAX 1048512
-#define RTL8366RB_BDTH_BASE 64
+#define RTL8366RB_BDTH_UNIT 64
#define RTL8366RB_BDTH_REG_DEFAULT 16383
/* QOS */
@@ -825,7 +825,7 @@ static int rtl8366rb_sw_set_port_rate_in(struct switch_dev *dev,
return -EINVAL;
if (val->value.i > 0 && val->value.i < RTL8366RB_BDTH_SW_MAX)
- val->value.i = (val->value.i - 1) / RTL8366RB_BDTH_BASE;
+ val->value.i = (val->value.i - 1) / RTL8366RB_BDTH_UNIT;
else
val->value.i = RTL8366RB_BDTH_REG_DEFAULT;
@@ -851,7 +851,7 @@ static int rtl8366rb_sw_get_port_rate_in(struct switch_dev *dev,
if (data < RTL8366RB_IB_BDTH_MASK)
data += 1;
- val->value.i = (int)data * RTL8366RB_BDTH_BASE;
+ val->value.i = (int)data * RTL8366RB_BDTH_UNIT;
return 0;
}
@@ -870,7 +870,7 @@ static int rtl8366rb_sw_set_port_rate_out(struct switch_dev *dev,
(RTL8366RB_QOS_DEFAULT_PREIFG << RTL8366RB_EB_PREIFG_OFFSET));
if (val->value.i > 0 && val->value.i < RTL8366RB_BDTH_SW_MAX)
- val->value.i = (val->value.i - 1) / RTL8366RB_BDTH_BASE;
+ val->value.i = (val->value.i - 1) / RTL8366RB_BDTH_UNIT;
else
val->value.i = RTL8366RB_BDTH_REG_DEFAULT;
@@ -894,7 +894,7 @@ static int rtl8366rb_sw_get_port_rate_out(struct switch_dev *dev,
if (data < RTL8366RB_EB_BDTH_MASK)
data += 1;
- val->value.i = (int)data * RTL8366RB_BDTH_BASE;
+ val->value.i = (int)data * RTL8366RB_BDTH_UNIT;
return 0;
}
@@ -1065,6 +1065,13 @@ static struct switch_attr rtl8366rb_vlan[] = {
.max = 1,
.set = NULL,
.get = rtl8366_sw_get_vlan_info,
+ }, {
+ .type = SWITCH_TYPE_INT,
+ .name = "fid",
+ .description = "Get/Set vlan FID",
+ .max = RTL8366RB_FIDMAX,
+ .set = rtl8366_sw_set_vlan_fid,
+ .get = rtl8366_sw_get_vlan_fid,
},
};