brcm47xx: fix switch handling
[openwrt/openwrt.git] / target / linux / brcm47xx / base-files / lib / preinit / 15_set_preinit_interface_brcm
1 #!/bin/sh
2
3 preinit_net_echo_send() {
4 preinit_ip
5
6 [ -d /proc/switch/eth0 ] && [ "$pi_ifname" = "eth0" ] && {
7
8 echo 1 > /proc/switch/eth0/reset
9 echo 1 > /proc/switch/eth0/enable
10 echo 1 > /proc/switch/eth0/enable_vlan
11
12 # this would be easier if we blasted the message across all ports
13 # but we don't want packets leaking across interfaces
14 for port in $(seq 0 4); do {
15
16 echo "$port ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/1/ports
17 sleep 1
18
19 netmsg $pi_broadcast "$1"
20 }; done
21
22 } || netmsg $pi_broadcast "$1"
23 }
24
25 preinit_net_echo() {
26 [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
27 {
28 [ "$pi_preinit_net_messages" = "y" ] || {
29 [ "$pi_failsafe_net_message" = "true" ] &&
30 [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
31 }
32 } && preinit_net_echo_send $1
33 }
34 }