[OpenWrt-Devel] [PATCH] b53: add 'flush_arl' command per port

Alexandru Ardelean ardeleanalex at gmail.com
Fri Nov 27 06:52:00 EST 2015


This would in essence re-use the current b53_flush_arl() function
with the added part that we can select a single port to flush ARL for.

Signed-off-by: Alexandru Ardelean <ardeleanalex at gmail.com>

---
 .../generic/files/drivers/net/phy/b53/b53_common.c | 29 ++++++++++++++++++----
 .../generic/files/drivers/net/phy/b53/b53_regs.h   |  4 +++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
index 859d8d1..8c8d217 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
@@ -336,12 +336,17 @@ static int b53_set_jumbo(struct b53_device *dev, int enable, int allow_10_100)
 	return b53_write16(dev, B53_JUMBO_PAGE, dev->jumbo_size_reg, max_size);
 }
 
-static int b53_flush_arl(struct b53_device *dev)
+static int b53_flush_arl(struct b53_device *dev, int port)
 {
 	unsigned int i;
+	u8 age_ctrl = FAST_AGE_DONE | FAST_AGE_DYNAMIC | FAST_AGE_STATIC;
 
-	b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_CTRL,
-		   FAST_AGE_DONE | FAST_AGE_DYNAMIC | FAST_AGE_STATIC);
+	if (port > -1 && port < B53_N_PORTS) {
+		b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_PORT_CTRL, FAST_AGE_SINGLE_PORT(port));
+		age_ctrl |= FAST_AGE_PORT;
+	}
+
+	b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_CTRL, age_ctrl);
 
 	for (i = 0; i < 10; i++) {
 		u8 fast_age_ctrl;
@@ -355,7 +360,7 @@ static int b53_flush_arl(struct b53_device *dev)
 		mdelay(1);
 	}
 
-	pr_warn("time out while flushing ARL\n");
+	pr_warn("time out while flushing ARL, port %d\n", port);
 
 	return -EINVAL;
 }
@@ -565,7 +570,7 @@ static int b53_switch_reset(struct b53_device *dev)
 
 	b53_enable_mib(dev);
 
-	return b53_flush_arl(dev);
+	return b53_flush_arl(dev, -1);
 }
 
 /*
@@ -890,6 +895,14 @@ static int b53_port_get_mib(struct switch_dev *sw_dev,
 	return 0;
 }
 
+static int b53_port_flush_arl(struct switch_dev *sw_dev,
+			    const struct switch_attr *attr,
+			    struct switch_val *val)
+{
+	struct b53_device *dev = sw_to_b53(sw_dev);
+	return b53_flush_arl(dev, val->port_vlan);
+}
+
 static struct switch_attr b53_global_ops_25[] = {
 	{
 		.type = SWITCH_TYPE_INT,
@@ -976,6 +989,12 @@ static struct switch_attr b53_port_ops[] = {
 		.description = "Get port's MIB counters",
 		.get = b53_port_get_mib,
 	},
+	{
+		.type = SWITCH_TYPE_NOVAL,
+		.name = "flush_arl",
+		.description = "Flush ARL",
+		.set = b53_port_flush_arl,
+	},
 };
 
 static struct switch_attr b53_no_ops[] = {
diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h b/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
index 144e1c8..138d26b 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
@@ -135,6 +135,10 @@
 #define   FAST_AGE_MC			BIT(5)
 #define   FAST_AGE_DONE			BIT(7)
 
+/* Fast Aging Port Control register (8 bit) */
+#define B53_FAST_AGE_PORT_CTRL		0x89
+#define   FAST_AGE_SINGLE_PORT(p)	((u8)(0xf & p))
+
 /*************************************************************************
  * Status Page registers
  *************************************************************************/
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list