From 9b34ea4f62bb4c4ad16b791c24e905775f2a52fd Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Sun, 19 Apr 2020 15:53:03 +0800 Subject: [PATCH] mvebu: use ucidef to set up MAC address Use ucidef to set up MAC address instead of preinit script Signed-off-by: DENG Qingfang --- .../base-files/etc/board.d/02_network | 113 ++++++++++++------ 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network index a2290ce532..89ccedae3f 100755 --- a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network +++ b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network @@ -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 -- 2.30.2