difos/target/linux/bcm53xx/base-files/etc/board.d/02_network
Rosen Penev 58056df84f bcm53xx: backport nvmem mac for meraki mr26
Avoids having to set the MAC in userspace.

Also added a mac-base change to set the wifi MACs. It's not clear if
upstream would want it once mac-base is upstreamed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17064
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-01-04 15:15:15 +01:00

98 lines
2 KiB
Text

#
# Copyright (C) 2011 OpenWrt.org
#
. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
bcm53xx_setup_interfaces()
{
local board="$1"
case "$board" in
asus,rt-ac87u)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
asus,rt-ac88u)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 extsw" "wan"
;;
dlink,dwl-8610ap)
ucidef_set_interface_lan "eth0 eth1" "dhcp"
;;
linksys,panamera)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5 lan6 lan7 lan8 extsw" "wan"
;;
luxul,xap-1610-v1)
ucidef_set_interface_lan "poe lan" "dhcp"
;;
meraki,mr26 | \
meraki,mr32)
ucidef_set_interface_lan "poe" "dhcp"
;;
meraki,mx64 | \
meraki,mx64-a0)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
meraki,mx65)
ucidef_set_interfaces_lan_wan \
"lan3 lan4 lan5 lan6 lan7 lan8 lan9 lan10 lan11 lan12" "wan1 wan2"
;;
phicomm,k3)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
esac
}
bcm53xx_setup_macs()
{
local board="$1"
wan_macaddr="$(nvram get wan_hwaddr)"
case "$board" in
asus,rt-ac87u)
etXmacaddr=$(nvram get et1macaddr)
offset=1
;;
dlink,dir-885l | \
linksys,ea9200 | \
linksys,panamera | \
netgear,r7900 | \
netgear,r8000 | \
netgear,r8500)
etXmacaddr=$(nvram get et2macaddr)
offset=1
;;
luxul,xwr-3100-v1 | \
luxul,xwr-3150-v1)
etXmacaddr=$(nvram get et0macaddr)
offset=5
;;
meraki,mx64 | \
meraki,mx64-a0 | \
meraki,mx65)
etXmacaddr=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
offset=1
;;
*)
etXmacaddr=$(nvram get et0macaddr)
offset=1
;;
esac
# If WAN MAC isn't explicitly set, calculate it using base MAC as reference.
[ -z "$wan_macaddr" -a -n "$etXmacaddr" ] && wan_macaddr=$(macaddr_add "$etXmacaddr" $offset)
[ -n "$wan_macaddr" ] && ucidef_set_interface_macaddr "wan" "$wan_macaddr"
}
board_config_update
board=$(board_name)
bcm53xx_setup_interfaces "$board"
bcm53xx_setup_macs "$board"
board_config_flush
exit 0