X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/4ddc3f5a08e7059d98bea0f06038a2bd0af902dd..00ad106a7b28019587065f49895f94dc46e94e09:/target/linux/package/switch/src/switch-robo.c?ds=inline diff --git a/target/linux/package/switch/src/switch-robo.c b/target/linux/package/switch/src/switch-robo.c index 63110d7c9..b23fca644 100644 --- a/target/linux/package/switch/src/switch-robo.c +++ b/target/linux/package/switch/src/switch-robo.c @@ -51,10 +51,12 @@ #define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9) #define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10) +static char *device; static int use_et = 0; static int is_5350 = 0; static struct ifreq ifr; static struct net_device *dev; +static unsigned char port[6] = { 0, 1, 2, 3, 4, 8 }; static int do_ioctl(int cmd, void *buf) { @@ -278,8 +280,15 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr) if ((val32 & (1 << 20)) /* valid */) { for (j = 0; j < 6; j++) { if (val32 & (1 << j)) { - len += sprintf(buf + len, "%d%s\t", j, - (val32 & (1 << (j + 6))) ? (j == 5 ? "u" : "") : "t"); + len += sprintf(buf + len, "%d", j); + if (val32 & (1 << (j + 6))) { + if (j == 5) buf[len++] = 'u'; + } else { + buf[len++] = 't'; + if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr) + buf[len++] = '*'; + } + buf[len++] = '\t'; } } len += sprintf(buf + len, "\n"); @@ -291,8 +300,15 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr) if ((val16 & (1 << 14)) /* valid */) { for (j = 0; j < 6; j++) { if (val16 & (1 << j)) { - len += sprintf(buf + len, "%d%s\t", j, (val16 & (1 << (j + 7))) ? - (j == 5 ? "u" : "") : "t"); + len += sprintf(buf + len, "%d", j); + if (val16 & (1 << (j + 7))) { + if (j == 5) buf[len++] = 'u'; + } else { + buf[len++] = 't'; + if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr) + buf[len++] = '*'; + } + buf[len++] = '\t'; } } len += sprintf(buf + len, "\n"); @@ -392,7 +408,13 @@ static int handle_reset(void *driver, char *buf, int nr) robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0); robo_write16(ROBO_VLAN_PAGE, (is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 : ROBO_VLAN_TABLE_ACCESS), val16); } - + + /* reset ports to a known good state */ + for (j = 0; j < d->ports; j++) { + robo_write16(ROBO_CTRL_PAGE, port[j], 0x0000); + robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0); + } + /* enable switching */ set_switch(1); @@ -404,18 +426,19 @@ static int handle_reset(void *driver, char *buf, int nr) static int __init robo_init() { - char *device = "ethX"; int notfound = 1; + device = strdup("ethX"); for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) { notfound = robo_probe(device); } device[3]--; - if (notfound) + if (notfound) { + kfree(device); return -ENODEV; - else { - switch_config main[] = { + } else { + switch_config cfg[] = { {"enable", handle_enable_read, handle_enable_write}, {"enable_vlan", handle_enable_vlan_read, handle_enable_vlan_write}, {"reset", NULL, handle_reset}, @@ -432,7 +455,7 @@ static int __init robo_init() cpuport: 5, ports: 6, vlans: 16, - driver_handlers: main, + driver_handlers: cfg, port_handlers: NULL, vlan_handlers: vlan, }; @@ -444,6 +467,7 @@ static int __init robo_init() static void __exit robo_exit() { switch_unregister_driver(DRIVER_NAME); + kfree(device); }