From e3a81c46a5b399e5579144aec5222d3c82055a63 Mon Sep 17 00:00:00 2001 From: hauke Date: Thu, 3 Jan 2013 01:58:01 +0000 Subject: switch: ROBO Switch Gigabit MII Support I wrote this patch some time ago because I had a need for one of the Gigabit ports (Linksys E3000) to be forced to 100FD. This is based on the robocfg sources included w/ the RT-N16 sources from ASUS. Since work is progressing on a BGMAC driver that could be included in OpenWRT, this may be useful to someone else. In testing, forcing the speed to 10/100 or 1000 worked fine; however, when trying to force full-duplex mode, the result was always half-duplex. I was not able to isolate the source of the problem (this patch, driver or H/W limitation). The only way I could get it to work was to set the port to Auto, but then only advertise 100FD (not included in this patch). I have a modified version of the robocfg package as well, I'd have to clean it up a little first (remove the full-duplex hack) before submitting it if there is interest. Signed-off-by: Nathan Hintz git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34992 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/switch/src/switch-core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'package/switch/src/switch-core.c') diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index 79b4e93f0..c77e4bba4 100644 --- a/package/switch/src/switch-core.c +++ b/package/switch/src/switch-core.c @@ -26,7 +26,7 @@ * enable_vlan: "0", "1" * port// * enabled: "0", "1" - * media: "AUTO", "100FD", "100HD", "10FD", "10HD" + * media: "AUTO", "1000FD", "1000HD", "100FD", "100HD", "10FD", "10HD" * vlan// * ports: same syntax as for nvram's vlan*ports (eg. "1 2 3 4 5*") */ @@ -305,6 +305,10 @@ int switch_parse_media(char *buf) if (strncmp(str, "AUTO", 4) == 0) return SWITCH_MEDIA_AUTO; + else if (strncmp(str, "1000FD", 6) == 0) + return SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD; + else if (strncmp(str, "1000HD", 6) == 0) + return SWITCH_MEDIA_1000; else if (strncmp(str, "100FD", 5) == 0) return SWITCH_MEDIA_100 | SWITCH_MEDIA_FD; else if (strncmp(str, "100HD", 5) == 0) @@ -322,14 +326,18 @@ int switch_print_media(char *buf, int media) if (media & SWITCH_MEDIA_AUTO) len = sprintf(buf, "Auto"); + else if (media == (SWITCH_MEDIA_1000 | SWITCH_MEDIA_FD)) + len = sprintf(buf, "1000FD"); + else if (media == SWITCH_MEDIA_1000) + len = sprintf(buf, "1000HD"); else if (media == (SWITCH_MEDIA_100 | SWITCH_MEDIA_FD)) len = sprintf(buf, "100FD"); else if (media == SWITCH_MEDIA_100) - len = sprintf(buf, "100HD"); + len = sprintf(buf, "100HD"); else if (media == SWITCH_MEDIA_FD) - len = sprintf(buf, "10FD"); + len = sprintf(buf, "10FD"); else if (media == 0) - len = sprintf(buf, "10HD"); + len = sprintf(buf, "10HD"); else len = sprintf(buf, "Invalid"); -- cgit v1.2.3 From 03eaf681abe52e6ea4bf52670f0a69baceb30245 Mon Sep 17 00:00:00 2001 From: hauke Date: Thu, 14 Feb 2013 12:36:13 +0000 Subject: switch: export cpuport, ports and vlans via /proc git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35595 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/switch/src/switch-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'package/switch/src/switch-core.c') diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index c77e4bba4..ab0754c94 100644 --- a/package/switch/src/switch-core.c +++ b/package/switch/src/switch-core.c @@ -138,6 +138,24 @@ static int handle_driver_version(void *driver, char *buf, int nr) return sprintf(buf, "%s\n", version); } +static int handle_driver_cpuport(void *driver, char *buf, int nr) +{ + int cpuport = ((switch_driver *) driver)->cpuport; + return sprintf(buf, "%i\n", cpuport); +} + +static int handle_driver_ports(void *driver, char *buf, int nr) +{ + int ports = ((switch_driver *) driver)->ports; + return sprintf(buf, "%i\n", ports); +} + +static int handle_driver_vlans(void *driver, char *buf, int nr) +{ + int vlans = ((switch_driver *) driver)->vlans; + return sprintf(buf, "%i\n", vlans); +} + static void add_handler(switch_driver *driver, const switch_config *handler, struct proc_dir_entry *parent, int nr) { switch_priv *priv = (switch_priv *) driver->data; @@ -221,6 +239,9 @@ static void do_unregister(switch_driver *driver) switch_config global_driver_handlers[] = { {"driver", handle_driver_name, NULL}, {"version", handle_driver_version, NULL}, + {"cpuport", handle_driver_cpuport, NULL}, + {"ports", handle_driver_ports, NULL}, + {"vlans", handle_driver_vlans, NULL}, {NULL, NULL, NULL} }; -- cgit v1.2.3 From d8af1489e0e3cbeba49897e8f6dee1572295dd43 Mon Sep 17 00:00:00 2001 From: hauke Date: Thu, 14 Feb 2013 12:36:52 +0000 Subject: switch: export name of device found via /proc git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35596 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/switch/src/switch-core.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'package/switch/src/switch-core.c') diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index ab0754c94..fc8a6bf2c 100644 --- a/package/switch/src/switch-core.c +++ b/package/switch/src/switch-core.c @@ -156,6 +156,12 @@ static int handle_driver_vlans(void *driver, char *buf, int nr) return sprintf(buf, "%i\n", vlans); } +static int handle_driver_dev_name(void *driver, char *buf, int nr) +{ + char *dev_name = ((switch_driver *) driver)->dev_name; + return sprintf(buf, "%s\n", dev_name); +} + static void add_handler(switch_driver *driver, const switch_config *handler, struct proc_dir_entry *parent, int nr) { switch_priv *priv = (switch_priv *) driver->data; @@ -242,6 +248,7 @@ switch_config global_driver_handlers[] = { {"cpuport", handle_driver_cpuport, NULL}, {"ports", handle_driver_ports, NULL}, {"vlans", handle_driver_vlans, NULL}, + {"dev_name", handle_driver_dev_name, NULL}, {NULL, NULL, NULL} }; -- cgit v1.2.3