Support Enable/Disable Learning for AR8216/AR8316 switch
Signed-off-by: Chun-Yeow Yeoh <[email protected]>
Index: target/linux/generic-2.6/files/drivers/net/phy/ar8216.c
===================================================================
--- target/linux/generic-2.6/files/drivers/net/phy/ar8216.c (revision 24194)
+++ target/linux/generic-2.6/files/drivers/net/phy/ar8216.c (working copy)
@@ -156,6 +156,50 @@
}
static int
+ar8216_set_learning_enable(struct switch_dev *dev, const struct
switch_attr *attr,
+ struct switch_val *val)
+{
+ struct ar8216_priv *priv = to_ar8216(dev);
+ int i;
+ u32 v;
+
+ for (i = 0; i < AR8216_NUM_PORTS; i++) {
+ v = priv->read(priv, AR8216_REG_PORT_CTRL(i));
+ v &= ~AR8216_PORT_CTRL_LEARN;
+
+ if (val->value.i){
+ /* Enable port learning for ALL */
+ v |= AR8216_PORT_CTRL_LEARN;
+ }
+
+ priv->write(priv, AR8216_REG_PORT_CTRL(i), v);
+ }
+
+ return 0;
+}
+
+static int
+ar8216_get_learning_enable(struct switch_dev *dev, const struct
switch_attr *attr,
+ struct switch_val *val)
+{
+ struct ar8216_priv *priv = to_ar8216(dev);
+ u32 v;
+
+ v = priv->read(priv, AR8216_REG_PORT_CTRL(0));
+
+ v &= AR8216_PORT_CTRL_LEARN;
+
+ if (v == AR8216_PORT_CTRL_LEARN){
+ val->value.i = 1;
+ }
+ else {
+ val->value.i = 0;
+ }
+
+ return 0;
+}
+
+static int
ar8216_set_vlan(struct switch_dev *dev, const struct switch_attr *attr,
struct switch_val *val)
{
@@ -313,7 +357,14 @@
static struct switch_attr ar8216_globals[] = {
- {
+ {
+ .type = SWITCH_TYPE_INT,
+ .name = "enable_learning",
+ .description = "Enable learning",
+ .set = ar8216_set_learning_enable,
+ .get = ar8216_get_learning_enable,
+ .max = 1
+ }, {
.type = SWITCH_TYPE_INT,
.name = "enable_vlan",
.description = "Enable VLAN mode",
@@ -483,6 +534,11 @@
}
if (priv->vlan) {
ingress = AR8216_IN_SECURE;
+ if (priv->vlan_tagged & (1 << i)) {
+ ingress = AR8216_IN_PORT_FALLBACK;
+ } else {
+ ingress = AR8216_IN_SECURE;
+ }
} else {
ingress = AR8216_IN_PORT_ONLY;
}
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel