ath79: add support for Netgear EX6400 and EX7300
[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 devolo,dvl1200i|\
14 devolo,dvl1750c|\
15 devolo,dvl1750i|\
16 glinet,ar300m-lite|\
17 netgear,ex6400|\
18 netgear,ex7300|\
19 ocedo,koala|\
20 ocedo,raccoon|\
21 pcs,cap324|\
22 pisen,wmm003n|\
23 pqi,air-pen|\
24 tplink,cpe210-v2|\
25 tplink,cpe210-v3|\
26 tplink,re350k-v1|\
27 tplink,re450-v2|\
28 tplink,tl-mr10u|\
29 tplink,tl-mr3020-v1|\
30 tplink,tl-mr3040-v2|\
31 tplink,tl-wa901nd-v2|\
32 tplink,tl-wr703n|\
33 ubnt,bullet-m|\
34 ubnt,bullet-m-xw|\
35 ubnt,lap-120|\
36 ubnt,nanobeam-ac|\
37 ubnt,nanostation-ac-loco|\
38 ubnt,rocket-m|\
39 ubnt,unifiac-lite|\
40 ubnt,unifiac-mesh|\
41 ubnt,unifi|\
42 wd,mynet-wifi-rangeextender|\
43 winchannel,wb2000)
44 ucidef_set_interface_lan "eth0"
45 ;;
46 avm,fritz4020|\
47 pcs,cr3000|\
48 tplink,archer-c58-v1|\
49 tplink,archer-c59-v1)
50 ucidef_set_interface_wan "eth0"
51 ucidef_add_switch "switch0" \
52 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
53 ;;
54 buffalo,bhr-4grv|\
55 buffalo,wzr-hp-g450h)
56 ucidef_add_switch "switch0" \
57 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
58 ;;
59 buffalo,bhr-4grv2)
60 ucidef_add_switch "switch0" \
61 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
62 ;;
63 buffalo,wzr-hp-ag300h)
64 ucidef_set_interface_wan "eth1"
65 ucidef_add_switch "switch0" \
66 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
67 ;;
68 buffalo,wzr-hp-g302h-a1a0)
69 ucidef_add_switch "switch0" \
70 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
71 ;;
72 comfast,cf-e5|\
73 glinet,gl-ar150|\
74 glinet,gl-ar300m-nand|\
75 glinet,gl-ar300m-nor|\
76 glinet,gl-x750|\
77 tplink,tl-wr810n-v1|\
78 tplink,tl-wr810n-v2|\
79 ubnt,routerstation|\
80 yuncore,a770)
81 ucidef_set_interfaces_lan_wan "eth1" "eth0"
82 ;;
83 devolo,dvl1200e|\
84 devolo,dvl1750e|\
85 ocedo,ursus)
86 ucidef_set_interface_lan "eth0 eth1"
87 ;;
88 dlink,dir-825-b1)
89 ucidef_set_interface_wan "eth1"
90 ucidef_add_switch "switch0" \
91 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
92 ;;
93 dlink,dir-825-c1|\
94 dlink,dir-835-a1|\
95 dlink,dir-859-a1|\
96 engenius,epg5000|\
97 tplink,archer-c2-v3|\
98 tplink,tl-wr1043nd-v4)
99 ucidef_add_switch "switch0" \
100 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
101 ;;
102 elecom,wrc-1750ghbk2-i|\
103 elecom,wrc-300ghbk2-i)
104 ucidef_add_switch "switch0" \
105 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
106 ;;
107 embeddedwireless,dorin)
108 ucidef_add_switch "switch0" \
109 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
110 ;;
111 engenius,ews511ap)
112 ucidef_set_interface_lan "eth0 eth1" "dhcp"
113 ;;
114 etactica,eg200)
115 ucidef_set_interface_lan "eth0" "dhcp"
116 ;;
117 glinet,gl-ar750s)
118 ucidef_add_switch "switch0" \
119 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
120 ;;
121 iodata,etg3-r|\
122 iodata,wn-ac1167dgr|\
123 iodata,wn-ac1600dgr|\
124 iodata,wn-ac1600dgr2|\
125 iodata,wn-ag300dgr|\
126 pcs,cr5000)
127 ucidef_add_switch "switch0" \
128 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
129 ;;
130 librerouter,librerouter-v1)
131 ucidef_add_switch "switch0" \
132 "0@eth0" "5:wan" "6@eth1" "4:lan"
133 ;;
134 nec,wg1200cr|\
135 ubnt,nanostation-ac|\
136 ubnt,unifiac-mesh-pro|\
137 ubnt,unifiac-pro)
138 ucidef_add_switch "switch0" \
139 "0@eth0" "2:lan" "3:wan"
140 ;;
141 nec,wg800hp)
142 ucidef_add_switch "switch0" \
143 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
144 ;;
145 netgear,wndr3700|\
146 netgear,wndr3700v2|\
147 netgear,wndr3800)
148 ucidef_set_interfaces_lan_wan "eth0" "eth1"
149 ucidef_add_switch "switch0" \
150 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
151 ucidef_add_switch_attr "switch0" "blinkrate" 2
152 ucidef_add_switch_port_attr "switch0" 1 led 6
153 ucidef_add_switch_port_attr "switch0" 2 led 9
154 ucidef_add_switch_port_attr "switch0" 5 led 2
155 ;;
156 netgear,wnr612-v2|\
157 on,n150r|\
158 tplink,tl-wr841-v7)
159 ucidef_set_interface_wan "eth0"
160 ucidef_add_switch "switch0" \
161 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
162 ;;
163 phicomm,k2t)
164 ucidef_add_switch "switch0" \
165 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
166 ;;
167 rosinson,wr818)
168 ucidef_add_switch "switch0" \
169 "0@eth0" "1:lan" "2:lan" "3:wan"
170 ;;
171 tplink,archer-c5-v1|\
172 tplink,archer-c7-v1|\
173 tplink,archer-c7-v2|\
174 tplink,tl-wdr4900-v2)
175 ucidef_add_switch "switch0" \
176 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
177 ;;
178 buffalo,whr-g301n|\
179 tplink,tl-mr3220-v1|\
180 tplink,tl-mr3420-v1|\
181 tplink,tl-wr841-v9|\
182 tplink,tl-wr841-v11|\
183 ubnt,airrouter)
184 ucidef_set_interface_wan "eth0"
185 ucidef_add_switch "switch0" \
186 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
187 ;;
188 tplink,archer-a7-v5|\
189 tplink,archer-c6-v2|\
190 tplink,archer-c7-v4|\
191 tplink,archer-c7-v5|\
192 tplink,tl-wdr3600|\
193 tplink,tl-wdr4300|\
194 tplink,tl-wr941n-v7-cn)
195 ucidef_add_switch "switch0" \
196 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
197 ;;
198 tplink,tl-wr1043nd-v1)
199 ucidef_add_switch "switch0" \
200 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
201 ;;
202 tplink,tl-wr1043nd-v2|\
203 tplink,tl-wr1043nd-v3)
204 ucidef_add_switch "switch0" \
205 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
206 ;;
207 tplink,tl-wr2543-v1)
208 ucidef_add_switch "switch0" \
209 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
210 ;;
211 tplink,tl-wr740n-v1|\
212 tplink,tl-wr740n-v3|\
213 tplink,tl-wr741-v1|\
214 tplink,tl-wr743nd-v1|\
215 tplink,tl-wr841-v5|\
216 tplink,tl-wr941-v4)
217 ucidef_set_interface_wan "eth0"
218 ucidef_add_switch "switch0" \
219 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
220 ;;
221 tplink,tl-wr710n-v1)
222 ucidef_set_interface_wan "eth0"
223 ucidef_add_switch "switch0" \
224 "0@eth1" "3:lan"
225 ;;
226 tplink,tl-wr740n-v4|\
227 tplink,tl-wr741nd-v4|\
228 tplink,tl-wr841-v8|\
229 tplink,tl-wr842n-v1|\
230 tplink,tl-wr842n-v2)
231 ucidef_set_interface_wan "eth0"
232 ucidef_add_switch "switch0" \
233 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
234 ;;
235 tplink,tl-wr941-v2)
236 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
237 ;;
238 ubnt,acb-isp)
239 ucidef_set_interface_wan "eth0"
240 ucidef_add_switch "switch0" \
241 "0@eth1" "2:lan:1" "3:lan:3" "4:lan:2"
242 ;;
243 ubnt,routerstation-pro)
244 ucidef_set_interface_wan "eth0"
245 ucidef_add_switch "switch0" \
246 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
247 ;;
248 ubnt,nanostation-m-xw)
249 ucidef_add_switch "switch0" \
250 "0@eth0" "5:lan" "1:wan"
251 ;;
252 xiaomi,mi-router-4q)
253 ucidef_set_interface_wan "eth0"
254 ucidef_add_switch "switch0" \
255 "0@eth1" "3:lan:1" "4:lan:2"
256 ;;
257 *)
258 ucidef_set_interfaces_lan_wan "eth0" "eth1"
259 ;;
260 esac
261 }
262
263 ath79_setup_macs()
264 {
265 local board="$1"
266
267 case "$board" in
268 avm,fritz300e)
269 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
270 ;;
271 avm,fritz4020)
272 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
273 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
274 ;;
275 dlink,dir-825-b1)
276 lan_mac=$(mtd_get_mac_text "caldata" 65440)
277 wan_mac=$(mtd_get_mac_text "caldata" 65460)
278 ;;
279 dlink,dir-825-c1|\
280 dlink,dir-835-a1)
281 lan_mac=$(mtd_get_mac_text "mac" 4)
282 wan_mac=$(mtd_get_mac_text "mac" 24)
283 ;;
284 dlink,dir-859-a1|\
285 nec,wg1200cr)
286 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
287 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
288 ;;
289 elecom,wrc-1750ghbk2-i|\
290 elecom,wrc-300ghbk2-i)
291 wan_mac=$(macaddr_add "$(mtd_get_mac_binary ART 4098)" -2)
292 ;;
293 engenius,epg5000|\
294 iodata,wn-ac1167dgr|\
295 iodata,wn-ac1600dgr|\
296 iodata,wn-ac1600dgr2|\
297 iodata,wn-ag300dgr)
298 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
299 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
300 ;;
301 engenius,ews511ap)
302 lan_mac=$(mtd_get_mac_text "u-boot-env" 233)
303 eth1_mac=$(macaddr_add "$lan_mac" 1)
304 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
305 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
306 ;;
307 iodata,etg3-r)
308 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
309 wan_mac=$(macaddr_add "$lan_mac" -1)
310 ;;
311 jjplus,ja76pf2)
312 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
313 lan_mac=$(macaddr_add "$wan_mac" 1)
314 ;;
315 nec,wg800hp)
316 lan_mac=$(mtd_get_mac_text board_data 640)
317 wan_mac=$(mtd_get_mac_text board_data 1152)
318 ;;
319 netgear,wndr3700|\
320 netgear,wndr3700v2|\
321 netgear,wndr3800)
322 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
323 ;;
324 phicomm,k2t)
325 lan_mac=$(k2t_get_mac "lan_mac")
326 wan_mac=$(k2t_get_mac "wan_mac")
327 ;;
328 rosinson,wr818)
329 wan_mac=$(mtd_get_mac_binary factory 0)
330 lan_mac=$(macaddr_setbit_la "$wan_mac")
331 ;;
332 tplink,archer-a7-v5|\
333 tplink,archer-c7-v5)
334 base_mac=$(mtd_get_mac_binary info 8)
335 wan_mac=$(macaddr_add "$base_mac" 1)
336 ;;
337 tplink,archer-c7-v4)
338 base_mac=$(mtd_get_mac_binary config 8)
339 wan_mac=$(macaddr_add "$base_mac" 1)
340 ;;
341 tplink,tl-wr1043nd-v4)
342 base_mac=$(mtd_get_mac_binary product-info 8)
343 wan_mac=$(macaddr_add "$base_mac" 1)
344 ;;
345 tplink,tl-wr941-v2|\
346 tplink,tl-wr941n-v7-cn)
347 base_mac=$(mtd_get_mac_binary u-boot 130048)
348 wan_mac=$(macaddr_add "$base_mac" 1)
349 ;;
350 ubnt,routerstation|\
351 ubnt,routerstation-pro)
352 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
353 lan_mac=$(macaddr_add "$wan_mac" 1)
354 ;;
355 wd,mynet-wifi-rangeextender)
356 lan_mac=$(nvram get et0macaddr)
357 ;;
358 esac
359
360 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
361 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
362 }
363
364 board_config_update
365 board=$(board_name)
366 ath79_setup_interfaces $board
367 ath79_setup_macs $board
368 board_config_flush
369
370 exit 0