[OpenWrt-Devel] [PATCH 2/3][RFC] ar7240: report port link state changes to kernel log
Alexander Couzens
lynxis at fe80.eu
Tue Dec 9 14:21:20 EST 2014
Like other network device report link change to kernel log.
switch eth0 port 1: Link 100baseT Mbit duplex: full
---
.../net/ethernet/atheros/ag71xx/ag71xx_ar7240.c | 27 ++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
index d4ccc02..a94837a 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
@@ -300,6 +300,7 @@ struct ar7240sw {
u8 vlan_tagged;
u16 pvid[AR7240_NUM_PORTS];
char buf[80];
+ u8 link;
rwlock_t stats_lock;
struct ar7240sw_port_stat port_stats[AR7240_NUM_PORTS];
@@ -1136,9 +1137,31 @@ static void link_function(struct work_struct *work) {
continue;
link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
- if (link & BMSR_LSTATUS) {
+ link &= BMSR_LSTATUS;
+ link = !!link;
+
+ if (link && !status)
status = 1;
- break;
+
+ if ((!!(as->link & BIT(i))) != link) {
+ struct switch_port_link swlink;
+ int port = i + 1;
+ memset(&swlink, '0', sizeof(swlink));
+ /* link change */
+ if (link) {
+ as->link |= BIT(i);
+ as->swdev.ops->get_port_link(&as->swdev, port, &swlink);
+ pr_info("switch %s port %d: link %s Mbit duplex: %s\n",
+ as->swdev.netdev ? as->swdev.netdev->name : as->swdev.alias,
+ port,
+ swconfig_speed_str(swlink.speed),
+ swlink.duplex ? "full" : "half");
+ } else {
+ as->link &= ~BIT(i);
+ pr_info("switch %s port %d: link down\n",
+ as->swdev.netdev ? as->swdev.netdev->name : as->swdev.alias,
+ port);
+ }
}
}
--
2.1.3
_______________________________________________
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