ipq40xx: use nvmem for mikrotik mac address

Userspace handling is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2024-08-24 13:54:10 -07:00
parent 1306885968
commit 95004898db
10 changed files with 136 additions and 21 deletions

View File

@ -219,19 +219,6 @@ ipq40xx_setup_macs()
wan_mac=$(mmc_get_mac_ascii devinfo hw_mac_addr) wan_mac=$(mmc_get_mac_ascii devinfo hw_mac_addr)
lan_mac="$wan_mac" lan_mac="$wan_mac"
;; ;;
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,rbr50|\ netgear,rbr50|\
netgear,rbs50|\ netgear,rbs50|\
netgear,srr60|\ netgear,srr60|\

View File

@ -36,13 +36,6 @@ preinit_set_mac_address() {
ip link set dev lan address "$base_mac" ip link set dev lan address "$base_mac"
ip link set dev wan address "$base_mac" ip link set dev wan address "$base_mac"
;; ;;
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)
;;
zyxel,nbg6617) zyxel,nbg6617)
base_mac=$(cat /sys/class/net/eth0/address) base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth0 address $(macaddr_add "$base_mac" 2) ip link set dev eth0 address $(macaddr_add "$base_mac" 2)

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user; led-failsafe = &led_user;
led-running = &led_user; led-running = &led_user;
led-upgrade = &led_user; led-upgrade = &led_user;
label-mac_device = &swport5;
}; };
soc { soc {
@ -180,6 +181,14 @@
hard_config { hard_config {
read-only; read-only;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -226,6 +235,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {
@ -240,6 +252,9 @@
&swport5 { &swport5 {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&wifi0 { &wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user; led-failsafe = &led_user;
led-running = &led_user; led-running = &led_user;
led-upgrade = &led_user; led-upgrade = &led_user;
label-mac-device = &swport5;
}; };
soc { soc {
@ -176,6 +177,14 @@
hard_config { hard_config {
read-only; read-only;
size = <0x2000>; size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -255,6 +264,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {
@ -264,25 +276,40 @@
&swport1 { &swport1 {
status = "okay"; status = "okay";
label = "lan4"; label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
}; };
&swport2 { &swport2 {
status = "okay"; status = "okay";
label = "lan3"; label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
}; };
&swport3 { &swport3 {
status = "okay"; status = "okay";
label = "lan2"; label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
}; };
&swport4 { &swport4 {
status = "okay"; status = "okay";
label = "lan1"; label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&swport5 { &swport5 {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&wifi0 { &wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user; led-failsafe = &led_user;
led-running = &led_user; led-running = &led_user;
led-upgrade = &led_user; led-upgrade = &led_user;
label-mac-device = &gmac;
}; };
soc { soc {
@ -179,6 +180,14 @@
hard_config { hard_config {
read-only; read-only;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -221,6 +230,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {

View File

@ -22,6 +22,7 @@
led-failsafe = &led_user; led-failsafe = &led_user;
led-running = &led_user; led-running = &led_user;
led-upgrade = &led_user; led-upgrade = &led_user;
label-mac-device = &swport5;
}; };
soc { soc {
@ -144,6 +145,14 @@
hard_config { hard_config {
read-only; read-only;
size = <0x2000>; size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -197,11 +206,17 @@
&swport4 { &swport4 {
status = "okay"; status = "okay";
label = "sw-eth2"; label = "sw-eth2";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&swport5 { &swport5 {
status = "okay"; status = "okay";
label = "sw-eth1"; label = "sw-eth1";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&wifi0 { &wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_status_red; led-failsafe = &led_status_red;
led-running = &led_status_blue; led-running = &led_status_blue;
led-upgrade = &led_status_red; led-upgrade = &led_status_red;
label-mac-device = &swport5;
}; };
soc { soc {
@ -208,6 +209,14 @@
hard_config { hard_config {
size = <0x2000>; size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -263,6 +272,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {
@ -272,25 +284,40 @@
&swport1 { &swport1 {
status = "okay"; status = "okay";
label = "lan4"; label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
}; };
&swport2 { &swport2 {
status = "okay"; status = "okay";
label = "lan3"; label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
}; };
&swport3 { &swport3 {
status = "okay"; status = "okay";
label = "lan2"; label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
}; };
&swport4 { &swport4 {
status = "okay"; status = "okay";
label = "lan1"; label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&swport5 { &swport5 {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&wifi0 { &wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_status_red; led-failsafe = &led_status_red;
led-running = &led_status_blue; led-running = &led_status_blue;
led-upgrade = &led_status_red; led-upgrade = &led_status_red;
label-mac-device = &swport5;
}; };
soc { soc {
@ -247,6 +248,14 @@
hard_config { hard_config {
read-only; read-only;
size = <0x2000>; size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -314,6 +323,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {
@ -323,25 +335,40 @@
&swport1 { &swport1 {
status = "okay"; status = "okay";
label = "lan4"; label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
}; };
&swport2 { &swport2 {
status = "okay"; status = "okay";
label = "lan3"; label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
}; };
&swport3 { &swport3 {
status = "okay"; status = "okay";
label = "lan2"; label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
}; };
&swport4 { &swport4 {
status = "okay"; status = "okay";
label = "lan1"; label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
}; };
&swport5 { &swport5 {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&wifi0 { &wifi0 {

View File

@ -39,6 +39,7 @@
led-failsafe = &user; led-failsafe = &user;
led-running = &user; led-running = &user;
led-upgrade = &user; led-upgrade = &user;
label-mac-device = &gmac;
}; };
soc { soc {
@ -193,6 +194,14 @@
hard_config { hard_config {
read-only; read-only;
size = <0x2000>; size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
}; };
dtb_config { dtb_config {
@ -279,6 +288,9 @@
&gmac { &gmac {
status = "okay"; status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
}; };
&switch { &switch {

View File

@ -9,5 +9,5 @@ CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_MTD_UBI_BLOCK=y CONFIG_MTD_UBI_BLOCK=y
CONFIG_MTD_UBI_NVMEM=y CONFIG_MTD_UBI_NVMEM=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_MTD_UBI_WL_THRESHOLD=4096
# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set CONFIG_NVMEM_LAYOUT_MIKROTIK=y
CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS=y