5c176d4963d5fa4b435a6d7ecc9fb14193e1fef7
[openwrt/openwrt.git] / target / linux / mvebu / cortexa9 / base-files / etc / board.d / 02_network
1 #
2 # Copyright (C) 2014-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-Project.org
4 #
5
6 . /lib/functions.sh
7 . /lib/functions/uci-defaults.sh
8 . /lib/functions/system.sh
9
10 mvebu_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 ctera,c200-v2)
16 ucidef_set_interface_lan "eth0" "dhcp"
17 ;;
18 cznic,turris-omnia)
19 ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4" "eth2"
20 ;;
21 fortinet,fg-30e|\
22 linksys,wrt1200ac|\
23 linksys,wrt1900ac-v1|\
24 linksys,wrt1900ac-v2|\
25 linksys,wrt1900acs|\
26 linksys,wrt3200acm|\
27 linksys,wrt32x)
28 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
29 ;;
30 fortinet,fg-50e)
31 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" "eth1 eth2"
32 ;;
33 iij,sa-w2)
34 ucidef_set_interfaces_lan_wan "ge1_0 ge1_1 ge1_2 ge1_3" "ge0"
35 ;;
36 iptime,nas1dual)
37 ucidef_set_interface_lan "eth0 eth1" "dhcp"
38 ;;
39 marvell,a385-db-ap)
40 ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
41 ;;
42 marvell,axp-gp)
43 ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
44 ;;
45 solidrun,clearfog-base-a1)
46 # eth0 is standalone ethernet
47 # eth1 is standalone ethernet
48 # eth2 is SFP
49 ucidef_set_interfaces_lan_wan "eth1" "eth0 eth2"
50 ;;
51 solidrun,clearfog-pro-a1)
52 # eth0 is standalone ethernet
53 # eth1 is switch
54 # eth2 is SFP
55 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5 lan6" "eth0 eth2"
56 ;;
57 *)
58 ucidef_set_interface_lan "eth0"
59 ;;
60 esac
61 }
62
63 mvebu_setup_macs()
64 {
65 local board="$1"
66 local lan_mac=""
67 local wan_mac=""
68 local label_mac=""
69
70 case "$board" in
71 buffalo,ls220de|\
72 buffalo,ls421de)
73 lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr)
74 ;;
75 ctera,c200-v2)
76 label_mac=$(mtd_get_mac_ascii dev_params mac)
77 lan_mac=$label_mac
78 ;;
79 linksys,wrt1200ac|\
80 linksys,wrt1900ac-v2|\
81 linksys,wrt1900acs|\
82 linksys,wrt3200acm|\
83 linksys,wrt32x)
84 label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
85 wan_mac=$(macaddr_setbit_la $label_mac)
86 ;;
87 linksys,wrt1900ac-v1)
88 label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
89 lan_mac=$label_mac
90 wan_mac=$label_mac
91 ;;
92 esac
93
94 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
95 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
96 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
97 }
98
99 board_config_update
100 board=$(board_name)
101 mvebu_setup_interfaces $board
102 mvebu_setup_macs $board
103 board_config_flush
104
105 exit 0