qoriq: use nvmem for MAC addresses
authorRosen Penev <rosenp@gmail.com>
Sun, 1 Sep 2024 22:33:43 +0000 (15:33 -0700)
committerStijn Tintel <stijn@linux-ipv6.be>
Sun, 13 Oct 2024 18:51:19 +0000 (21:51 +0300)
Userspace handling is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16308
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
target/linux/qoriq/base-files/etc/board.d/02_network
target/linux/qoriq/config-6.6
target/linux/qoriq/files/arch/powerpc/boot/dts/fsl/watchguard-firebox-m300.dts

index 355c8d37a4644f72737edc9b1d9757c3eaf7758f..12adca2a8d8e0ab9a08a7a8be7ddcb2e72875fb5 100644 (file)
@@ -19,15 +19,9 @@ watchguard,firebox-m300)
        ucidef_set_interfaces_lan_wan "eth1" "eth0"
        wg_set_opt_interface "eth2" "2"
 
-       sweth_mac_offset=0x186d
-
        for sweth in $(find /sys/class/net/ -name 'sweth*' -print); do
                device="$(basename "$sweth")"
-               mac="$(mtd_get_mac_text wg_cfg0 "$sweth_mac_offset")"
-               switchports="$switchports $device"
-               ucidef_set_network_device_mac "$device" "$mac"
                wg_set_opt_interface "$device" "${device#sweth}"
-               sweth_mac_offset=$(printf "0x%X\n" $(( $sweth_mac_offset + 0x14)))
        done
 
        ;;
index 3f42563db1475c9e315c341acea8544a03212ea8..750e6c6551022771ef3871bced0e6d9aff3fb93e 100644 (file)
@@ -280,6 +280,8 @@ CONFIG_NO_HZ_COMMON=y
 CONFIG_NO_HZ_IDLE=y
 CONFIG_NR_CPUS=24
 CONFIG_NR_IRQS=512
+CONFIG_NVMEM=y
+CONFIG_NVMEM_LAYOUTS=y
 CONFIG_OF=y
 CONFIG_OF_ADDRESS=y
 CONFIG_OF_EARLY_FLATTREE=y
index c611263099d54264db3142902e914bc7a3e30c5b..6628e0eb23eb76ee9f64a226e35dec61beb2e9a8 100644 (file)
                        reg = <0x10000 0x20000>;
                        label = "wg_cfg0";
                        read-only;
+
+                       nvmem-layout {
+                               compatible = "fixed-layout";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               macaddr_cfg_186c: macaddr@186c {
+                                       compatible = "mac-base";
+                                       reg = <0x186c 0x11>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+
+                               macaddr_cfg_1880: macaddr@1880 {
+                                       compatible = "mac-base";
+                                       reg = <0x1880 0x11>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+
+                               macaddr_cfg_1894: macaddr@1894 {
+                                       compatible = "mac-base";
+                                       reg = <0x1894 0x11>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+
+                               macaddr_cfg_18a8: macaddr@18a8 {
+                                       compatible = "mac-base";
+                                       reg = <0x18a8 0x11>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+
+                               macaddr_cfg_18bc: macaddr@18bc {
+                                       compatible = "mac-base";
+                                       reg = <0x18bc 0x11>;
+                                       #nvmem-cell-cells = <1>;
+                               };
+                       };
                };
 
                partition@30000 {
                                reg = <0>;
                                label = "sweth3";
                                phy-handle = <&switch0phy0>;
+
+                               nvmem-cells = <&macaddr_cfg_186c 0>;
+                               nvmem-cell-names = "mac-address";
                        };
 
                        port@1 {
                                reg = <1>;
                                label = "sweth4";
                                phy-handle = <&switch0phy1>;
+
+                               nvmem-cells = <&macaddr_cfg_1880 0>;
+                               nvmem-cell-names = "mac-address";
                        };
 
                        port@2 {
                                reg = <2>;
                                label = "sweth5";
                                phy-handle = <&switch0phy2>;
+
+                               nvmem-cells = <&macaddr_cfg_1894 0>;
+                               nvmem-cell-names = "mac-address";
                        };
 
                        port@3 {
                                reg = <3>;
                                label = "sweth6";
                                phy-handle = <&switch0phy3>;
+
+                               nvmem-cells = <&macaddr_cfg_18a8 0>;
+                               nvmem-cell-names = "mac-address";
                        };
 
                        port@4 {
                                reg = <4>;
                                label = "sweth7";
                                phy-handle = <&switch0phy4>;
+
+                               nvmem-cells = <&macaddr_cfg_18bc 0>;
+                               nvmem-cell-names = "mac-address";
                        };
 
                        // OEM bootlog suggests multiple ports are attached to switch