diff options
author | Hauke Mehrtens <hauke@openwrt.org> | 2013-02-13 16:05:13 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@openwrt.org> | 2013-02-13 16:05:13 +0000 |
commit | 9cb4b87ca1cb100ce81c1655d68ba1efde56ff43 (patch) | |
tree | f0ec1e885042ba3afb54b8abb668a033eb3f76cc | |
parent | 50eb7c5b1866577437d48593054b23ab7613e5ec (diff) | |
download | upstream-9cb4b87ca1cb100ce81c1655d68ba1efde56ff43.tar.gz upstream-9cb4b87ca1cb100ce81c1655d68ba1efde56ff43.tar.bz2 upstream-9cb4b87ca1cb100ce81c1655d68ba1efde56ff43.zip |
switch: resetting and enabling vlan write for gigabit switches
This patch makes it possible to reset and enable writing vlans to recent switchs.
This is based on a patch by jcharest and the Broadcom SDK.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35585 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | package/switch/src/switch-robo.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c index aaccdd9f6b..2aacc36663 100644 --- a/package/switch/src/switch-robo.c +++ b/package/switch/src/switch-robo.c @@ -693,12 +693,16 @@ static int handle_enable_vlan_read(void *driver, char *buf, int nr) static int handle_enable_vlan_write(void *driver, char *buf, int nr) { + __u16 val16; int disable = ((buf[0] != '1') ? 1 : 0); + val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 : - (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */); + val16 | (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */); + + val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 : - (robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) : + val16 | (robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) : 0) | (1 << 2) | (1 << 3)); /* RSV multicast */ if (robo.devid != ROBO_DEVICE_ID_5325) @@ -712,15 +716,11 @@ static int handle_enable_vlan_write(void *driver, char *buf, int nr) return 0; } -static int handle_reset(void *driver, char *buf, int nr) +static void handle_reset_old(switch_driver *d, char *buf, int nr) { - switch_driver *d = (switch_driver *) driver; int j; __u16 val16; - /* disable switching */ - set_switch(0); - /* reset vlans */ for (j = 0; j <= ((robo.is_5365) ? VLAN_ID_MAX_5365 : VLAN_ID_MAX); j++) { /* write config now */ @@ -733,6 +733,44 @@ static int handle_reset(void *driver, char *buf, int nr) ROBO_VLAN_TABLE_ACCESS, val16); } +} + +static void handle_reset_new(switch_driver *d, char *buf, int nr) +{ + int j; + __u8 vtbl_entry, vtbl_index, vtbl_access; + + if ((robo.devid == ROBO_DEVICE_ID_5395) || + (robo.devid == ROBO_DEVICE_ID_53115)) { + vtbl_access = ROBO_VTBL_ACCESS_5395; + vtbl_index = ROBO_VTBL_INDX_5395; + vtbl_entry = ROBO_VTBL_ENTRY_5395; + } else { + vtbl_access = ROBO_VTBL_ACCESS; + vtbl_index = ROBO_VTBL_INDX; + vtbl_entry = ROBO_VTBL_ENTRY; + } + + for (j = 0; j <= VLAN_ID_MAX; j++) { + /* write config now */ + robo_write32(ROBO_ARLIO_PAGE, vtbl_entry, 0); + robo_write16(ROBO_ARLIO_PAGE, vtbl_index, j); + robo_write16(ROBO_ARLIO_PAGE, vtbl_access, 1 << 7); + } +} + +static int handle_reset(void *driver, char *buf, int nr) +{ + int j; + switch_driver *d = (switch_driver *) driver; + + /* disable switching */ + set_switch(0); + + if (robo.devid != ROBO_DEVICE_ID_5325) + handle_reset_new(d, buf, nr); + else + handle_reset_old(d, buf, nr); /* reset ports to a known good state */ for (j = 0; j < d->ports; j++) { |