Openwrt/target/linux/bcm53xx/base-files/etc/board.d/02_network
Rafał Miłecki 53546c3e94 bcm53xx: fix Luxul XWR-3150 LAN ports numbering
Port numbers were reverted.

Fixes: c459a6bf48 ("bcm53xx: add support for Luxul FullMAC WiFi devices")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2021-04-21 07:35:10 +02:00

143 lines
3.7 KiB
Plaintext

#
# Copyright (C) 2011 OpenWrt.org
#
. /lib/functions/system.sh
. /lib/functions/uci-defaults.sh
bcm53xx_setup_interfaces()
{
local board="$1"
# On BCM4708 / BCM4709(4) there are 3 Ethernet interfaces connected to 3 switch
# ports. It's up to vendor which to use.
case "$board" in
tenda,ac9)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "8@eth0" "0:wan" "5@eth1"
;;
buffalo,wxr-1900dhp| \
buffalo,wzr-1750dhp)
ucidef_add_switch "switch0" \
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "5@eth0"
;;
dlink,dir-885l | \
netgear,r7900 | \
netgear,r8000 | \
netgear,r8500)
# NVRAM specifies port 8 (eth2) - unsupported by OpenWrt b53
# Use port 5 (eth0) as workaround
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0"
;;
linksys,panamera)
ucidef_add_switch "switch1" \
"0:lan" "1:lan:7" "2:lan:4" "3:lan:8" "4:wan" "5t@eth0"
;;
luxul,abr-4500-v1|\
luxul,xbr-4500-v1)
ucidef_add_switch "switch0" \
"0:wan" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5@eth0"
;;
luxul,xap-1610-v1)
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "5@eth0"
ucidef_set_interface_lan "eth0.1" "dhcp"
;;
luxul,xwr-3150-v1)
ucidef_add_switch "switch0" \
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "5@eth0"
;;
phicomm,k3)
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:wan" "5@eth0"
;;
*)
# NVRAM entries may contain unsorted ports, e.g. Netgear R6250 uses
# vlan1ports=3 2 1 0 5*
# vlan2ports=4 5u
# and early Netgear R8000 was using
# vlan1ports=3 2 1 0 5 7 8*
# (the enclosing echo is needed to convert newline back to space)
vlan1ports="$(echo $(nvram get vlan1ports | tr " " "\n" | sort))"
vlan2ports="$(echo $(nvram get vlan2ports | tr " " "\n" | sort))"
if echo "$vlan1ports" | egrep -q "^1 2 3 4 5" && \
echo "$vlan2ports" | egrep -q "^0 5"; then
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5t@eth0"
elif echo "$vlan1ports" | egrep -q "^1 2 3 5 7" && \
echo "$vlan2ports" | egrep -q "^0 7"; then
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "5:lan" "0:wan" "7t@eth1"
elif echo "$vlan1ports" | egrep -q "^0 1 2 3 5 7 8" && \
echo "$vlan2ports" | egrep -q "^4 8"; then
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "5:lan" "7:lan" "4:wan" "8t@eth2"
else
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0"
fi
;;
esac
}
bcm53xx_setup_macs()
{
local board="$1"
case "$board" in
dlink,dir-885l | \
linksys,panamera | \
netgear,r7900 | \
netgear,r8000 | \
netgear,r8500)
# As vendor doesn't use eth0 its MAC may be missing. Use one from eth2.
et2macaddr="$(nvram get et2macaddr)"
;;
meraki,mr32)
# The MAC is stored on an AT24C64 eeprom and not on the nvram
et2macaddr=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
;;
esac
[ -n "$et2macaddr" ] && ucidef_set_interface_macaddr "lan" "$et2macaddr"
wan_macaddr="$(nvram get wan_hwaddr)"
case "$board" in
asus,rt-ac87u)
etXmacaddr=$(nvram get et1macaddr)
offset=1
;;
dlink,dir-885l | \
linksys,panamera | \
netgear,r7900 | \
netgear,r8000 | \
netgear,r8500)
etXmacaddr=$(nvram get et2macaddr)
offset=1
;;
luxul,xwr-3100v1 | \
luxul,xwr-3150-v1)
etXmacaddr=$(nvram get et0macaddr)
offset=5
;;
*)
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