b440fb388a9755946a30bfd3c8895f6c1d3b0887
[openwrt/svn-archive/archive.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults-new.sh
6 . /lib/functions/system.sh
7
8 ramips_setup_rt3x5x_vlans()
9 {
10 if [ ! -x /sbin/swconfig ]; then
11 # legacy default
12 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
13 return
14 fi
15 local wanports=""
16 local lanports=""
17 for port in 5 4 3 2 1 0; do
18 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
19 continue
20 fi
21 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
22 wanports="$port $wanports"
23 else
24 lanports="$port $lanports"
25 fi
26 done
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "rt305x" "1" "1"
29 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
30 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
31 }
32
33 ramips_setup_interfaces()
34 {
35 local board="$1"
36
37 ucidef_set_interface_loopback
38
39 case $board in
40 a5-v11)
41 ucidef_set_interface_lan "eth0.1"
42 ucidef_add_switch "switch0" "1" "1"
43 ucidef_add_switch_vlan "switch0" "1" "0 6t"
44 ;;
45
46 3g300m | \
47 w150m | \
48 all0256n | \
49 all5002 | \
50 all5003 | \
51 broadway | \
52 dcs-930| \
53 ht-tm02| \
54 ncs601w | \
55 wnce2001)
56 ucidef_add_switch "switch0" "1" "0"
57 ucidef_set_interface_lan "eth0"
58 ;;
59
60 3g-6200nl | \
61 mlw221)
62 ucidef_set_interface_lan "eth0.2"
63 ;;
64 mlwg2)
65 ucidef_set_interface_lan "eth0.1"
66 ;;
67
68 m2m)
69 ucidef_add_switch "switch0" "4"
70 ucidef_set_interface_lan "eth0"
71 ;;
72
73 wizard8800 | \
74 wl-330n | \
75 wmr300)
76 ucidef_set_interface_lan "eth0.1"
77 ;;
78
79 b2c | \
80 nw718 | \
81 psr-680w | \
82 sl-r7205 | \
83 w502u | \
84 wr6202)
85 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
86 ;;
87
88 awapn2403)
89 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
90 ucidef_add_switch "switch0" "1" "1"
91 ucidef_add_switch_vlan "switch0" "1" "0 6t"
92 ucidef_add_switch_vlan "switch0" "2" "1 6t"
93 ;;
94
95 br-6475nd)
96 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
97 ucidef_add_switch "switch0" "1" "1"
98 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
99 ucidef_add_switch_vlan "switch0" "2" "0 9t"
100 ;;
101
102 asl26555)
103 ucidef_set_interface_lan "eth0.1"
104 ucidef_add_switch "switch0" "1" "1"
105 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
106 ;;
107
108 cy-swr1100)
109 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
110 ucidef_add_switch "switch0" "1" "1"
111 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
112 ucidef_add_switch_vlan "switch0" "2" "4 9t"
113 ;;
114
115 3g-6200n | \
116 ai-br100 | \
117 dir-610-a1 | \
118 dir-300-b7 | \
119 dir-320-b1 | \
120 dir-615-h1 | \
121 hlk-rm04 | \
122 mt7621 | \
123 mt7628 | \
124 mzk-w300nh2 | \
125 mzk-750dhp | \
126 whr-300hp2 | \
127 whr-600d | \
128 wsr-600 | \
129 wsr-1166 | \
130 wt1520 | \
131 y1)
132 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
133 ucidef_add_switch "switch0" "1" "1"
134 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
135 ucidef_add_switch_vlan "switch0" "2" "4 6t"
136 ;;
137
138 whr-1166d)
139 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
140 ucidef_add_switch "switch0" "1" "1"
141 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
142 ucidef_add_switch_vlan "switch0" "2" "5 6t"
143 ;;
144
145 awm002-evb | \
146 awm003-evb | \
147 argus-atp52b | \
148 dir-645 | \
149 dir-860l-b1 | \
150 f5d8235-v1 | \
151 f5d8235-v2 | \
152 hg255d | \
153 rt-n14u | \
154 wrtnode | \
155 wt3020 | \
156 ur-326n4g | \
157 zbt-wa05)
158 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
159 ucidef_add_switch "switch0" "1" "1"
160 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
161 ucidef_add_switch_vlan "switch0" "2" "0 6t"
162 ;;
163
164 ur-336un)
165 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
166 ;;
167
168 br6524n | \
169 v11st-fe)
170 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
171 ucidef_add_switch "switch0" "1" "1"
172 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
173 ucidef_add_switch_vlan "switch0" "2" "0 5t"
174 ;;
175
176 ar670w | \
177 ar725w | \
178 rt-n15 | \
179 wl-351)
180 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
181 ucidef_add_switch "switch0" "1" "1"
182 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
183 ucidef_add_switch_vlan "switch0" "2" "4 5t"
184 ;;
185
186 rt-n56u)
187 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
188 ucidef_add_switch "switch0" "1" "1"
189 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
190 ucidef_add_switch_vlan "switch0" "2" "4 8t"
191 ;;
192
193 tew-691gr|\
194 tew-692gr)
195 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
196 ucidef_add_switch "switch0" "1" "1"
197 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
198 ucidef_add_switch_vlan "switch0" "2" "0t 5"
199 ;;
200
201 vocore)
202 ucidef_set_interface_lan "eth0.1"
203 ucidef_add_switch "switch0" "1" "1"
204 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
205 ;;
206
207 wcr-150gn)
208 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
209 ucidef_add_switch "switch0" "1" "1"
210 ucidef_add_switch_vlan "switch0" "1" "0 6t"
211 ucidef_add_switch_vlan "switch0" "2" "6t"
212 ;;
213
214 wr8305rt)
215 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
216 ucidef_add_switch "switch0" "1" "1"
217 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
218 ucidef_add_switch_vlan "switch0" "2" "4 6t"
219 ;;
220
221 y1s)
222 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
223 ucidef_add_switch "switch0" "1" "1"
224 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
225 ucidef_add_switch_vlan "switch0" "2" "0 6t"
226 ;;
227 d105 | \
228 na930 | \
229 omni-emb-hpm|\
230 wli-tx4-ag300n)
231 ucidef_set_interface_lan "eth0"
232 ;;
233
234 e1700 | \
235 mt7620a_mt7530)
236 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
237 ucidef_add_switch "switch1" "1" "1"
238 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
239 ucidef_add_switch_vlan "switch1" "2" "4 6t"
240 ;;
241
242 *)
243 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
244 if [ -n "${RT3X5X}" ]; then
245 ramips_setup_rt3x5x_vlans
246 else
247 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
248 fi
249 ;;
250 esac
251 }
252
253 ramips_setup_macs()
254 {
255 local board="$1"
256 local lan_mac=""
257 local wan_mac=""
258
259 case $board in
260 br-6475nd)
261 lan_mac=$(cat /sys/class/net/eth0/address)
262 wan_mac=$(mtd_get_mac_binary devdata 7)
263 ;;
264
265 w306r-v20)
266 lan_mac=$(cat /sys/class/net/eth0/address)
267 wan_mac=$(macaddr_add "$lan_mac" 5)
268 ;;
269
270 tew-691gr)
271 lan_mac=$(cat /sys/class/net/eth0/address)
272 wan_mac=$(macaddr_add "$lan_mac" 3)
273 ;;
274
275 tew-692gr)
276 lan_mac=$(cat /sys/class/net/eth0/address)
277 wan_mac=$(macaddr_add "$lan_mac" 4)
278 ;;
279
280 m3 |\
281 m4 |\
282 x5 |\
283 x8)
284 lan_mac=$(cat /sys/class/net/eth0/address)
285 lan_mac=$(macaddr_add "$lan_mac" -2)
286 ;;
287
288 a5-v11 |\
289 bc2 |\
290 broadway |\
291 d105 |\
292 dir-620-a1 |\
293 esr-9753 |\
294 freestation5 |\
295 hlk-rm04 | \
296 mpr-a1 | \
297 mpr-a2 | \
298 dir-300-b7 | \
299 dir-320-b1 | \
300 psr-680w |\
301 sl-r7205 |\
302 y1 |\
303 y1s)
304 lan_mac=$(cat /sys/class/net/eth0/address)
305 lan_mac=$(macaddr_setbit_la "$lan_mac")
306 wan_mac=$(macaddr_add "$lan_mac" 1)
307 ;;
308
309 ht-tm02)
310 lan_mac=$(cat /sys/class/net/eth0/address)
311 ;;
312
313 cy-swr1100 | \
314 dir-645)
315 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
316 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
317 ;;
318
319 e1700)
320 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
321 ;;
322
323 wcr-150gn)
324 wan_mac=$(mtd_get_mac_binary factory 40)
325 ;;
326
327 rt-n56u)
328 lan_mac=$(cat /sys/class/net/eth0/address)
329 lan_mac=$(macaddr_setbit_la "$lan_mac")
330 wan_mac=$(mtd_get_mac_binary factory 32772)
331 ;;
332
333 all0239-3g | \
334 carambola | \
335 freestation5 | \
336 w502u | \
337 wnce2001)
338 wan_mac=$(mtd_get_mac_binary factory 46)
339 ;;
340
341 *)
342 lan_mac=$(cat /sys/class/net/eth0/address)
343 wan_mac=$(macaddr_add "$lan_mac" 1)
344 ;;
345
346 esac
347
348 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
349 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
350 }
351
352 board_config_update
353 board=$(ramips_board_name)
354 ramips_setup_interfaces $board
355 ramips_setup_macs $board
356 board_config_flush
357
358 exit 0