From 2500e03ac84a7c597fcb55c227c36de23e12ccc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 18 Oct 2021 15:04:17 +0200 Subject: [PATCH] bcm53xx: switch to the upstream DSA-based b53 driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Drop swconfig 2. Simplify network setup 3. Verify network config 4. Disable Buffalo WZR-900DHP for now - it misses ports definition Signed-off-by: Rafał Miłecki Reviewed-By: Christian Lamparter (cherry picked from commit e9672b1a8fa4714cbc35d5964caf704b2e571f35) --- target/linux/bcm53xx/Makefile | 2 +- .../bcm53xx/base-files/etc/board.d/02_network | 78 +++---------------- .../etc/uci-defaults/03_dsa_migrate | 23 ++++++ target/linux/bcm53xx/config-5.4 | 20 +++-- 4 files changed, 49 insertions(+), 74 deletions(-) create mode 100644 target/linux/bcm53xx/base-files/etc/uci-defaults/03_dsa_migrate diff --git a/target/linux/bcm53xx/Makefile b/target/linux/bcm53xx/Makefile index 4ef8b9ace4..4fb967db0f 100644 --- a/target/linux/bcm53xx/Makefile +++ b/target/linux/bcm53xx/Makefile @@ -22,7 +22,7 @@ include $(INCLUDE_DIR)/target.mk KERNELNAME:=zImage dtbs -DEFAULT_PACKAGES += swconfig nvram \ +DEFAULT_PACKAGES += nvram \ osafeloader oseama otrx \ kmod-gpio-button-hotplug \ kmod-leds-gpio autocore-arm diff --git a/target/linux/bcm53xx/base-files/etc/board.d/02_network b/target/linux/bcm53xx/base-files/etc/board.d/02_network index 927594047a..d0dd37ce27 100755 --- a/target/linux/bcm53xx/base-files/etc/board.d/02_network +++ b/target/linux/bcm53xx/base-files/etc/board.d/02_network @@ -10,78 +10,27 @@ 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" + asus,rt-ac87u) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; asus,rt-ac88u) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "7t@eth1" + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 extsw" "wan" ;; 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" + ucidef_set_interfaces_lan_wan "lan4 lan7 lan8 extsw" "wan" ;; luxul,xap-1610-v1) - ucidef_add_switch "switch0" \ - "0:lan" "1:lan" "5@eth0" - ucidef_set_interface_lan "eth0.1" "dhcp" + ucidef_set_interface_lan "poe lan" "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" + meraki,mr32) + ucidef_set_interface_lan "poe" "dhcp" ;; phicomm,k3) - ucidef_add_switch "switch0" \ - "0:lan" "1:lan" "2:lan" "3:wan" "5@eth0" + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; *) - # 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 + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" ;; esac } @@ -91,14 +40,6 @@ 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) @@ -108,6 +49,7 @@ bcm53xx_setup_macs() [ -n "$et2macaddr" ] && ucidef_set_interface_macaddr "lan" "$et2macaddr" wan_macaddr="$(nvram get wan_hwaddr)" + case "$board" in asus,rt-ac87u) etXmacaddr=$(nvram get et1macaddr) diff --git a/target/linux/bcm53xx/base-files/etc/uci-defaults/03_dsa_migrate b/target/linux/bcm53xx/base-files/etc/uci-defaults/03_dsa_migrate new file mode 100644 index 0000000000..7350f57e5d --- /dev/null +++ b/target/linux/bcm53xx/base-files/etc/uci-defaults/03_dsa_migrate @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-only + +# Exit if network doesn't contain any swconfig section +uci -q get network.@switch[0] > /dev/null || exit 0 + +lan_proto="$(uci -q get network.lan.proto)" +lan_ipaddr="$(uci -q get network.lan.ipaddr)" +lan_netmask="$(uci -q get network.lan.netmask)" +wan_proto="$(uci -q get network.wan.proto)" +wan_ipaddr="$(uci -q get network.wan.ipaddr)" +wan_netmask="$(uci -q get network.wan.netmask)" + +rm /etc/config/network +config_generate + +uci -q batch <<-EOF + set network.lan.proto="$lan_proto" + set network.lan.ipaddr="$lan_ipaddr" + set network.lan.netmask="$lan_netmask" + set network.wan.proto="$wan_proto" + set network.wan.ipaddr="$wan_ipaddr" + set network.wan.netmask="$wan_netmask" +EOF diff --git a/target/linux/bcm53xx/config-5.4 b/target/linux/bcm53xx/config-5.4 index abfd693f39..38ac10e300 100644 --- a/target/linux/bcm53xx/config-5.4 +++ b/target/linux/bcm53xx/config-5.4 @@ -61,6 +61,12 @@ CONFIG_ARM_UNWIND=y CONFIG_ARM_VIRT_EXT=y CONFIG_ATAGS=y CONFIG_AUTO_ZRELADDR=y +CONFIG_B53=y +CONFIG_B53_MDIO_DRIVER=y +# CONFIG_B53_MMAP_DRIVER is not set +# CONFIG_B53_SERDES is not set +# CONFIG_B53_SPI_DRIVER is not set +CONFIG_B53_SRAB_DRIVER=y CONFIG_BCM47XX_NVRAM=y CONFIG_BCM47XX_SPROM=y CONFIG_BCM47XX_WDT=y @@ -172,6 +178,7 @@ CONFIG_GENERIC_STRNLEN_USER=y CONFIG_GPIOLIB=y CONFIG_GPIOLIB_IRQCHIP=y CONFIG_GPIO_74X164=y +CONFIG_GRO_CELLS=y CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDEN_BRANCH_PREDICTOR=y CONFIG_HARDIRQS_SW_RESEND=y @@ -271,7 +278,14 @@ CONFIG_MTD_UBI_BLOCK=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_MUTEX_SPIN_ON_OWNER=y CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NET_DEVLINK=y +CONFIG_NET_DSA=y +CONFIG_NET_DSA_TAG_BRCM=y +CONFIG_NET_DSA_TAG_BRCM_COMMON=y +CONFIG_NET_DSA_TAG_BRCM_LEGACY=y +CONFIG_NET_DSA_TAG_BRCM_PREPEND=y CONFIG_NET_FLOW_LIMIT=y +CONFIG_NET_SWITCHDEV=y CONFIG_NR_CPUS=2 CONFIG_NVMEM=y CONFIG_NVMEM_BRCM_NVRAM=y @@ -300,6 +314,7 @@ CONFIG_PCI_DOMAINS_GENERIC=y CONFIG_PERF_USE_VMALLOC=y CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y +CONFIG_PHYLINK=y # CONFIG_PHY_BCM_NS_USB2 is not set # CONFIG_PHY_BCM_NS_USB3 is not set # CONFIG_PHY_BCM_SR_PCIE is not set @@ -336,11 +351,6 @@ CONFIG_SPI_GPIO=y CONFIG_SPI_MASTER=y CONFIG_SPI_MEM=y CONFIG_SRCU=y -CONFIG_SWCONFIG=y -CONFIG_SWCONFIG_B53=y -CONFIG_SWCONFIG_B53_PHY_DRIVER=y -CONFIG_SWCONFIG_B53_PHY_FIXUP=y -CONFIG_SWCONFIG_B53_SRAB_DRIVER=y CONFIG_SWPHY=y CONFIG_SWP_EMULATE=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y