3 # Copyright (C) 2011 OpenWrt.org
6 . /lib/functions/system.sh
7 . /lib/functions/uci-defaults.sh
9 bcm53xx_setup_interfaces()
13 # On BCM4708 / BCM4709(4) there are 3 Ethernet interfaces connected to 3 switch
14 # ports. It's up to vendor which to use.
17 ucidef_add_switch "switch0" \
18 "1:lan" "2:lan" "3:lan" "4:lan" "8@eth0" "0:wan" "5@eth1"
20 buffalo,wxr-1900dhp| \
22 ucidef_add_switch "switch0" \
23 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "5@eth0"
29 # NVRAM specifies port 8 (eth2) - unsupported by OpenWrt b53
30 # Use port 5 (eth0) as workaround
31 ucidef_add_switch "switch0" \
32 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0"
36 ucidef_add_switch "switch0" \
37 "0:wan" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5@eth0"
40 ucidef_add_switch "switch0" \
41 "0:lan" "1:lan" "5@eth0"
42 ucidef_set_interface_lan "eth0.1" "dhcp"
45 ucidef_add_switch "switch0" \
46 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan" "5@eth0"
49 ucidef_add_switch "switch0" \
50 "0:lan" "1:lan" "2:lan" "3:wan" "5@eth0"
53 # NVRAM entries may contain unsorted ports, e.g. Netgear R6250 uses
54 # vlan1ports=3 2 1 0 5*
56 # and early Netgear R8000 was using
57 # vlan1ports=3 2 1 0 5 7 8*
58 # (the enclosing echo is needed to convert newline back to space)
59 vlan1ports="$(echo $(nvram get vlan1ports | tr " " "\n" | sort))"
60 vlan2ports="$(echo $(nvram get vlan2ports | tr " " "\n" | sort))"
61 if echo "$vlan1ports" | egrep -q "^1 2 3 4 5" && \
62 echo "$vlan2ports" | egrep -q "^0 5"; then
63 ucidef_add_switch "switch0" \
64 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5t@eth0"
65 elif echo "$vlan1ports" | egrep -q "^1 2 3 5 7" && \
66 echo "$vlan2ports" | egrep -q "^0 7"; then
67 ucidef_add_switch "switch0" \
68 "1:lan" "2:lan" "3:lan" "5:lan" "0:wan" "7t@eth1"
69 elif echo "$vlan1ports" | egrep -q "^0 1 2 3 5 7 8" && \
70 echo "$vlan2ports" | egrep -q "^4 8"; then
71 ucidef_add_switch "switch0" \
72 "0:lan" "1:lan" "2:lan" "3:lan" "5:lan" "7:lan" "4:wan" "8t@eth2"
74 ucidef_add_switch "switch0" \
75 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0"
90 # As vendor doesn't use eth0 its MAC may be missing. Use one from eth2.
91 et2macaddr="$(nvram get et2macaddr)"
92 [ -n "$et2macaddr" ] && ucidef_set_interface_macaddr "lan" "$et2macaddr"
96 wan_macaddr="$(nvram get wan_hwaddr)"
99 etXmacaddr=$(nvram get et1macaddr)
106 etXmacaddr=$(nvram get et2macaddr)
111 etXmacaddr=$(nvram get et0macaddr)
115 etXmacaddr=$(nvram get et0macaddr)
120 # If WAN MAC isn't explicitly set, calculate it using base MAC as reference.
121 [ -z "$wan_macaddr" -a -n "$etXmacaddr" ] && wan_macaddr=$(macaddr_add "$etXmacaddr" $offset)
123 [ -n "$wan_macaddr" ] && ucidef_set_interface_macaddr "wan" "$wan_macaddr"
128 bcm53xx_setup_interfaces "$board"
129 bcm53xx_setup_macs "$board"