From f3bc5ea5d91b7a501935431acb2bda68d5f51fe6 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 24 Aug 2024 13:54:10 -0700 Subject: [PATCH] ipq40xx: use nvmem for mikrotik mac address Userspace handling is deprecated. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16257 Signed-off-by: Jonas Jelonek --- .../ipq40xx/base-files/etc/board.d/02_network | 13 ---------- .../lib/preinit/05_set_iface_mac_ipq40xx.sh | 7 ----- .../linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts | 17 ++++++++++-- .../ipq40xx/dts/qcom-ipq4018-hap-ac2.dts | 26 +++++++++++++++++-- .../ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts | 14 ++++++++-- .../ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi | 17 ++++++++++-- .../dts/qcom-ipq4019-hap-ac3-lte6-kit.dts | 26 +++++++++++++++++-- .../ipq40xx/dts/qcom-ipq4019-hap-ac3.dts | 26 +++++++++++++++++-- .../ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts | 14 ++++++++-- target/linux/ipq40xx/mikrotik/config-default | 2 +- 10 files changed, 127 insertions(+), 35 deletions(-) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index 715c439a845..c3aced4df4d 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -228,19 +228,6 @@ ipq40xx_setup_macs() wan_mac=$(get_mac_label) lan_mac=$(macaddr_add "$wan_mac" 1) ;; - mikrotik,cap-ac|\ - mikrotik,hap-ac2|\ - mikrotik,hap-ac3|\ - mikrotik,hap-ac3-lte6-kit) - wan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base) - lan_mac=$(macaddr_add $wan_mac 1) - label_mac="$wan_mac" - ;; - mikrotik,lhgg-60ad|\ - mikrotik,sxtsq-5-ac) - lan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base) - label_mac="$lan_mac" - ;; netgear,rbr40|\ netgear,rbr50|\ netgear,srr60|\ diff --git a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh index 3ba21353483..4331e617dc9 100644 --- a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh +++ b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh @@ -19,13 +19,6 @@ preinit_set_mac_address() { extreme-networks,ws-ap391x) ip link set dev eth0 address $(mtd_get_mac_ascii CFG1 ethaddr) ;; - mikrotik,wap-ac|\ - mikrotik,wap-ac-lte|\ - mikrotik,wap-r-ac) - base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base) - ip link set dev sw-eth1 address "$base_mac" - ip link set dev sw-eth2 address $(macaddr_add "$base_mac" 1) - ;; teltonika,rutx50) # Vendor Bootloader removes nvmem-cells from partition, # so this needs to be done here. diff --git a/target/linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts b/target/linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts index 1d1b381be07..7124397df07 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4018-cap-ac.dts @@ -21,12 +21,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_user; led-failsafe = &led_user; led-running = &led_user; led-upgrade = &led_user; + label-mac-device = &gmac; }; soc { @@ -182,6 +181,14 @@ hard_config { read-only; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -228,6 +235,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { @@ -238,6 +248,9 @@ status = "okay"; label = "lan"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; &swport5 { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4018-hap-ac2.dts b/target/linux/ipq40xx/dts/qcom-ipq4018-hap-ac2.dts index ddf6ef2df7d..05664d5485b 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4018-hap-ac2.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4018-hap-ac2.dts @@ -21,12 +21,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_user; led-failsafe = &led_user; led-running = &led_user; led-upgrade = &led_user; + label-mac-device = &gmac; }; soc { @@ -178,6 +177,14 @@ hard_config { read-only; size = <0x2000>; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -257,6 +264,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { @@ -266,21 +276,33 @@ &swport1 { status = "okay"; label = "lan4"; + + nvmem-cells = <&macaddr_hard 4>; + nvmem-cell-names = "mac-address"; }; &swport2 { status = "okay"; label = "lan3"; + + nvmem-cells = <&macaddr_hard 3>; + nvmem-cell-names = "mac-address"; }; &swport3 { status = "okay"; label = "lan2"; + + nvmem-cells = <&macaddr_hard 2>; + nvmem-cell-names = "mac-address"; }; &swport4 { status = "okay"; label = "lan1"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; &swport5 { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts b/target/linux/ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts index be58defe961..c3f88a16fee 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4018-sxtsq-5-ac.dts @@ -21,12 +21,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_user; led-failsafe = &led_user; led-running = &led_user; led-upgrade = &led_user; + label-mac-device = &gmac; }; soc { @@ -181,6 +180,14 @@ hard_config { read-only; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -223,6 +230,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi b/target/linux/ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi index 9ce753f87de..a37808b21ca 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi +++ b/target/linux/ipq40xx/dts/qcom-ipq4018-wap-ac.dtsi @@ -18,12 +18,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_user; led-failsafe = &led_user; led-running = &led_user; led-upgrade = &led_user; + label-mac-device = &gmac; }; soc { @@ -146,6 +145,14 @@ hard_config { read-only; size = <0x2000>; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -190,6 +197,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { @@ -199,6 +209,9 @@ &swport4 { status = "okay"; label = "sw-eth2"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; &swport5 { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3-lte6-kit.dts b/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3-lte6-kit.dts index 80b536de7b4..119e71d9347 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3-lte6-kit.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3-lte6-kit.dts @@ -21,12 +21,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_status_blue; led-failsafe = &led_status_red; led-running = &led_status_blue; led-upgrade = &led_status_red; + label-mac-device = &gmac; }; soc { @@ -209,6 +208,14 @@ hard_config { size = <0x2000>; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -264,6 +271,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { @@ -273,21 +283,33 @@ &swport1 { status = "okay"; label = "lan4"; + + nvmem-cells = <&macaddr_hard 4>; + nvmem-cell-names = "mac-address"; }; &swport2 { status = "okay"; label = "lan3"; + + nvmem-cells = <&macaddr_hard 3>; + nvmem-cell-names = "mac-address"; }; &swport3 { status = "okay"; label = "lan2"; + + nvmem-cells = <&macaddr_hard 2>; + nvmem-cell-names = "mac-address"; }; &swport4 { status = "okay"; label = "lan1"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; &swport5 { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3.dts b/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3.dts index 0f311d0e2e8..c4a6622b0f6 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4019-hap-ac3.dts @@ -21,12 +21,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &led_status_blue; led-failsafe = &led_status_red; led-running = &led_status_blue; led-upgrade = &led_status_red; + label-mac-device = &gmac; }; soc { @@ -249,6 +248,14 @@ hard_config { read-only; size = <0x2000>; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -316,6 +323,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { @@ -325,21 +335,33 @@ &swport1 { status = "okay"; label = "lan4"; + + nvmem-cells = <&macaddr_hard 4>; + nvmem-cell-names = "mac-address"; }; &swport2 { status = "okay"; label = "lan3"; + + nvmem-cells = <&macaddr_hard 3>; + nvmem-cell-names = "mac-address"; }; &swport3 { status = "okay"; label = "lan2"; + + nvmem-cells = <&macaddr_hard 2>; + nvmem-cell-names = "mac-address"; }; &swport4 { status = "okay"; label = "lan1"; + + nvmem-cells = <&macaddr_hard 1>; + nvmem-cell-names = "mac-address"; }; &swport5 { diff --git a/target/linux/ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts b/target/linux/ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts index ad3509ddc54..9c17e75d8d1 100644 --- a/target/linux/ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts +++ b/target/linux/ipq40xx/dts/qcom-ipq4019-lhgg-60ad.dts @@ -35,12 +35,11 @@ }; aliases { - // TODO: Verify if the ethernet0 alias is needed - ethernet0 = &gmac; led-boot = &user; led-failsafe = &user; led-running = &user; led-upgrade = &user; + label-mac-device = &gmac; }; soc { @@ -195,6 +194,14 @@ hard_config { read-only; size = <0x2000>; + + nvmem-layout { + compatible = "mikrotik,routerboot-nvmem"; + + macaddr_hard: base-mac-address { + #nvmem-cell-cells = <1>; + }; + }; }; dtb_config { @@ -275,6 +282,9 @@ &gmac { status = "okay"; + + nvmem-cells = <&macaddr_hard 0>; + nvmem-cell-names = "mac-address"; }; &switch { diff --git a/target/linux/ipq40xx/mikrotik/config-default b/target/linux/ipq40xx/mikrotik/config-default index c334f8c2928..37bbbd0f7c1 100644 --- a/target/linux/ipq40xx/mikrotik/config-default +++ b/target/linux/ipq40xx/mikrotik/config-default @@ -11,5 +11,5 @@ CONFIG_MTD_UBI_BEB_LIMIT=20 CONFIG_MTD_UBI_BLOCK=y CONFIG_MTD_UBI_NVMEM=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 -# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set +CONFIG_NVMEM_LAYOUT_MIKROTIK=y CONFIG_UBIFS_FS=y -- 2.47.3