mvebu: use ucidef to set up MAC address
authorDENG Qingfang <dengqf6@mail2.sysu.edu.cn>
Sun, 19 Apr 2020 07:53:03 +0000 (15:53 +0800)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Wed, 3 Jun 2020 18:34:15 +0000 (20:34 +0200)
Use ucidef to set up MAC address instead of preinit script

Signed-off-by: DENG Qingfang <dengqf6@mail2.sysu.edu.cn>
target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network

index a2290ce532befff1f1fe6df8135a1732a5158dc5..89ccedae3fb2bc25d1e5a096fab104cd41847bb4 100755 (executable)
@@ -4,49 +4,86 @@
 # Copyright (C) 2016 LEDE-Project.org
 #
 
+. /lib/functions.sh
 . /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
 
-board_config_update
+mvebu_setup_interfaces()
+{
+       local board="$1"
 
-board=$(board_name)
+       case "$board" in
+       cznic,turris-omnia)
+               ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4" "eth2"
+               ;;
+       linksys,caiman|\
+       linksys,cobra|\
+       linksys,mamba|\
+       linksys,rango|\
+       linksys,shelby|\
+       linksys,venom)
+               ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
+               ;;
+       marvell,a385-db-ap)
+               ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
+               ;;
+       marvell,axp-gp)
+               ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
+               ;;
+       solidrun,clearfog-a1|\
+       solidrun,clearfog-pro-a1)
+               # eth0 is standalone ethernet
+               # eth1 is switch
+               # eth2 is SFP
+               ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5 lan6" "eth0 eth2"
+               ;;
+       solidrun,clearfog-base-a1)
+               # eth0 is standalone ethernet
+               # eth1 is standalone ethernet
+               # eth2 is SFP
+               ucidef_set_interfaces_lan_wan "eth1" "eth0 eth2"
+               ;;
+       *)
+               ucidef_set_interface_lan "eth0"
+               ;;
+       esac
+}
+
+mvebu_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+       local wan_mac=""
+       local label_mac=""
 
-case "$board" in
-cznic,turris-omnia)
-       ucidef_set_interface_lan "lan0 lan1 lan2 lan3 lan4"
-       ucidef_set_interface_wan "eth2"
-       ;;
-linksys,caiman|\
-linksys,cobra|\
-linksys,mamba|\
-linksys,rango|\
-linksys,shelby|\
-linksys,venom)
-       ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
-       ;;
-marvell,a385-db-ap)
-       ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
-       ;;
-marvell,axp-gp)
-       ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
-       ;;
-solidrun,clearfog-a1|\
-solidrun,clearfog-pro-a1)
-       # eth0 is standalone ethernet
-       # eth1 is switch
-       # eth2 is SFP
-       ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5 lan6" "eth0 eth2"
-       ;;
-solidrun,clearfog-base-a1)
-       # eth0 is standalone ethernet
-       # eth1 is standalone ethernet
-       # eth2 is SFP
-       ucidef_set_interfaces_lan_wan "eth1" "eth0 eth2"
-       ;;
-*)
-       ucidef_set_interface_lan "eth0"
-       ;;
-esac
+       case "$board" in
+       buffalo,ls421de)
+               lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr)
+               ;;
+       linksys,caiman|\
+       linksys,cobra|\
+       linksys,rango|\
+       linksys,shelby|\
+       linksys,venom)
+               label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+               wan_mac=$(macaddr_setbit_la $label_mac)
+               ;;
+       linksys,mamba)
+               label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
+               lan_mac=$label_mac
+               wan_mac=$label_mac
+               ;;
+       esac
 
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+       [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+       [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
+}
+
+board_config_update
+board=$(board_name)
+mvebu_setup_interfaces $board
+mvebu_setup_macs $board
 board_config_flush
 
 exit 0