fca9e42fb53c0c2b26fcc6d0de7ae921897c7d4d
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / board.d / 02_network
1 !/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9 local board="$1"
10
11 case "$board" in
12 avm,fritz300e|\
13 ocedo,koala|\
14 ocedo,raccoon|\
15 pcs,cap324|\
16 pisen,wmm003n|\
17 pqi,air-pen|\
18 tplink,re450-v2|\
19 tplink,tl-mr10u|\
20 tplink,tl-mr3020-v1|\
21 tplink,tl-mr3040-v2|\
22 tplink,tl-wa901nd-v2|\
23 tplink,tl-wr703n|\
24 ubnt,bullet-m|\
25 ubnt,bullet-m-xw|\
26 ubnt,lap-120|\
27 ubnt,nanostation-ac-loco|\
28 ubnt,rocket-m|\
29 ubnt,unifiac-lite|\
30 ubnt,unifiac-mesh|\
31 ubnt,unifi|\
32 wd,mynet-wifi-rangeextender)
33 ucidef_set_interface_lan "eth0"
34 ;;
35 avm,fritz4020)
36 ucidef_set_interface_wan "eth0"
37 ucidef_add_switch "switch0" \
38 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
39 ;;
40 buffalo,bhr-4grv|\
41 buffalo,wzr-hp-g450h)
42 ucidef_add_switch "switch0" \
43 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
44 ;;
45 buffalo,bhr-4grv2)
46 ucidef_add_switch "switch0" \
47 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
48 ;;
49 buffalo,wzr-hp-ag300h)
50 ucidef_set_interface_wan "eth1"
51 ucidef_add_switch "switch0" \
52 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
53 ;;
54 buffalo,wzr-hp-g302h-a1a0)
55 ucidef_add_switch "switch0" \
56 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
57 ;;
58 dlink,dir-825-b1)
59 ucidef_set_interface_wan "eth1"
60 ucidef_add_switch "switch0" \
61 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
62 ;;
63 elecom,wrc-300ghbk2-i)
64 ucidef_add_switch "switch0" \
65 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
66 ;;
67 embeddedwireless,dorin)
68 ucidef_add_switch "switch0" \
69 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
70 ;;
71 etactica,eg200)
72 ucidef_set_interface_lan "eth0" "dhcp"
73 ;;
74 glinet,ar150|\
75 glinet,ar300m|\
76 glinet,x750)
77 ucidef_set_interfaces_lan_wan "eth1" "eth0"
78 ;;
79 iodata,etg3-r|\
80 iodata,wn-ac1167dgr|\
81 iodata,wn-ac1600dgr2|\
82 pcs,cr5000)
83 ucidef_add_switch "switch0" \
84 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
85 ;;
86 netgear,wndr3700|\
87 netgear,wndr3700v2|\
88 netgear,wndr3800)
89 ucidef_set_interfaces_lan_wan "eth0" "eth1"
90 ucidef_add_switch "switch0" \
91 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
92 ucidef_add_switch_attr "switch0" "blinkrate" 2
93 ucidef_add_switch_port_attr "switch0" 1 led 6
94 ucidef_add_switch_port_attr "switch0" 2 led 9
95 ucidef_add_switch_port_attr "switch0" 5 led 2
96 ;;
97 netgear,wnr612-v2|\
98 on,n150r)
99 ucidef_set_interface_wan "eth0"
100 ucidef_add_switch "switch0" \
101 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
102 ;;
103 pcs,cr3000)
104 ucidef_add_switch "switch0" \
105 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
106 ucidef_set_interface_wan "eth0"
107 ;;
108 phicomm,k2t)
109 ucidef_add_switch "switch0" \
110 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
111 ;;
112 tplink,archer-c7-v1|\
113 tplink,archer-c7-v2|\
114 tplink,tl-wdr4900-v2)
115 ucidef_add_switch "switch0" \
116 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
117 ;;
118 buffalo,whr-g301n|\
119 tplink,tl-mr3220-v1|\
120 tplink,tl-mr3420-v1|\
121 tplink,tl-wr841-v7)
122 ucidef_set_interface_wan "eth0"
123 ucidef_add_switch "switch0" \
124 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
125 ;;
126 tplink,tl-wdr3600|\
127 tplink,tl-wdr4300)
128 ucidef_add_switch "switch0" \
129 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
130 ;;
131 tplink,tl-wr1043nd-v1)
132 ucidef_add_switch "switch0" \
133 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
134 ;;
135 tplink,tl-wr1043nd-v2|\
136 tplink,tl-wr1043nd-v3)
137 ucidef_add_switch "switch0" \
138 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
139 ;;
140 tplink,tl-wr1043nd-v4)
141 ucidef_add_switch "switch0" \
142 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
143 ;;
144 tplink,tl-wr2543-v1)
145 ucidef_add_switch "switch0" \
146 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
147 ;;
148 tplink,tl-wr740n-v1|\
149 tplink,tl-wr740n-v3|\
150 tplink,tl-wr741-v1|\
151 tplink,tl-wr743nd-v1|\
152 tplink,tl-wr841-v5|\
153 tplink,tl-wr941-v4)
154 ucidef_set_interface_wan "eth0"
155 ucidef_add_switch "switch0" \
156 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
157 ;;
158 tplink,tl-wr740nd-v4|\
159 tplink,tl-wr741nd-v4|\
160 tplink,tl-wr841-v9|\
161 tplink,tl-wr841-v11)
162 ucidef_set_interface_wan "eth0"
163 ucidef_add_switch "switch0" \
164 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
165 ;;
166 tplink,tl-wr842n-v2)
167 ucidef_set_interface_wan "eth0"
168 ucidef_add_switch "switch0" \
169 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
170 ;;
171 tplink,tl-wr941-v2)
172 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
173 ;;
174 ubnt,routerstation)
175 ucidef_set_interfaces_lan_wan "eth1" "eth0"
176 ;;
177 ubnt,routerstation-pro)
178 ucidef_set_interface_wan "eth0"
179 ucidef_add_switch "switch0" \
180 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
181 ;;
182 ubnt,nanostation-ac|\
183 ubnt,unifiac-mesh-pro|\
184 ubnt,unifiac-pro)
185 ucidef_add_switch "switch0" \
186 "0@eth0" "2:lan" "3:wan"
187 ;;
188 *)
189 ucidef_set_interfaces_lan_wan "eth0" "eth1"
190 ;;
191 esac
192 }
193
194 ath79_setup_macs()
195 {
196 local board="$1"
197
198 case "$board" in
199 avm,fritz300e)
200 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
201 ;;
202 avm,fritz4020)
203 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
204 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
205 ;;
206 dlink,dir-825-b1)
207 lan_mac=$(mtd_get_mac_text "caldata" 65440)
208 wan_mac=$(mtd_get_mac_text "caldata" 65460)
209 ;;
210 elecom,wrc-300ghbk2-i)
211 wan_mac=$(macaddr_add "$(mtd_get_mac_binary ART 4098)" -2)
212 ;;
213 iodata,etg3-r)
214 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
215 wan_mac=$(macaddr_add "$lan_mac" -1)
216 ;;
217 iodata,wn-ac1167dgr|\
218 iodata,wn-ac1600dgr2)
219 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
220 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
221 ;;
222 netgear,wndr3700|\
223 netgear,wndr3700v2|\
224 netgear,wndr3800)
225 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
226 ;;
227 phicomm,k2t)
228 lan_mac=$(k2t_get_mac "lan_mac")
229 wan_mac=$(k2t_get_mac "wan_mac")
230 ;;
231 tplink,tl-wr1043nd-v4)
232 base_mac=$(mtd_get_mac_binary product-info 8)
233 wan_mac=$(macaddr_add "$base_mac" 1)
234 ;;
235 tplink,tl-wr941-v2)
236 base_mac=$(mtd_get_mac_binary u-boot 130048)
237 wan_mac=$(macaddr_add "$base_mac" 1)
238 ;;
239 ubnt,routerstation|\
240 ubnt,routerstation-pro)
241 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
242 lan_mac=$(macaddr_add "$wan_mac" 1)
243 ;;
244 wd,mynet-wifi-rangeextender)
245 lan_mac=$(nvram get et0macaddr)
246 ;;
247 esac
248
249 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
250 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
251 }
252
253 board_config_update
254 board=$(board_name)
255 ath79_setup_interfaces $board
256 ath79_setup_macs $board
257 board_config_flush
258
259 exit 0