treewide: use a single ath10k MAC patching function with checksum
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Mon, 14 Oct 2019 12:02:40 +0000 (14:02 +0200)
committerDavid Bauer <mail@david-bauer.net>
Tue, 15 Oct 2019 16:13:54 +0000 (18:13 +0200)
While all ath10k eeproms have a checksum field, so far two
functions for patching ath10k MAC address have been present (and
been used).

This merges code to provide a single function ath10k_patch_mac
in caldata.sh, having its name in accordance with ath9k functions.
By doing so, correct MAC patching for current and future ath10k
devices should be ensured.

This patch adds checksum adjustments for several targets on
ath79 and lantiq.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
package/base-files/files/lib/functions/caldata.sh
target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata

index 004bcfa9906bae3967d3a437c2fcc24979e9d50a..1ff69ce1aedddd67e1f5003a40c3979d340e629f 100644 (file)
@@ -121,13 +121,7 @@ ath9k_patch_mac_crc() {
        caldata_patch_mac "$mac" "$mac_offset" "$chksum_offset"
 }
 
-ath10kcal_patch_mac() {
-       local mac=$1
-
-       caldata_patch_mac "$mac" 0x6
-}
-
-ath10kcal_patch_mac_crc() {
+ath10k_patch_mac() {
        local mac=$1
 
        caldata_patch_mac "$mac" 0x6 0x2
index 9d6b643a8ec0166381c9844e414af8fbb14f9288..8ab0f6f6ad2a74fa64bc6da96d85ca233f0c20ed 100644 (file)
@@ -22,54 +22,54 @@ case "$FIRMWARE" in
        devolo,dvl1750i|\
        devolo,dvl1750x)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x0) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) -1)
                ;;
        dlink,dir-859-a1)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
+               ath10k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
                ;;
        elecom,wrc-1750ghbk2-i)
                caldata_extract "art" 0x5000 0x844
                ;;
        engenius,ecb1750)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr)
+               ath10k_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr)
                ;;
        engenius,epg5000|\
        iodata,wn-ac1167dgr|\
        iodata,wn-ac1600dgr2)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
                ;;
        engenius,ews511ap)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
+               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
                ;;
        glinet,gl-ar750|\
        glinet,gl-ar750s)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
                ;;
        glinet,gl-x750)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
                ;;
        nec,wg800hp)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac_crc $(mtd_get_mac_text board_data 0x880)
+               ath10k_patch_mac $(mtd_get_mac_text board_data 0x880)
                ;;
        ocedo,koala|\
        ocedo,ursus)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(mtd_get_mac_binary art 0xc)
+               ath10k_patch_mac $(mtd_get_mac_binary art 0xc)
                ;;
        openmesh,om5p-ac-v2)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
+               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
                ;;
        qihoo,c301)
                caldata_extract "radiocfg" 0x5000 0x844
-               ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata wlan5mac)
+               ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
                ;;
        tplink,archer-a7-v5|\
        tplink,archer-c2-v3|\
@@ -77,29 +77,29 @@ case "$FIRMWARE" in
        tplink,archer-c7-v5|\
        tplink,archer-c25-v1)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) -1)
                ;;
        tplink,archer-c5-v1|\
        tplink,archer-c7-v2)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x1fc00) -1)
                ;;
        tplink,archer-d50-v1)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 0xf100) +2)
                ;;
        tplink,re350k-v1)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary config 0x10008) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary config 0x10008) +2)
                ;;
        tplink,re355-v1|\
        tplink,re450-v1)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
+               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
                ;;
        tplink,re450-v2)
                caldata_extract "art" 0x5000 0x844
-               ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary info 0x8) +1)
                ;;
        ubnt,unifiac-lite|\
        ubnt,unifiac-lr|\
@@ -118,7 +118,7 @@ case "$FIRMWARE" in
        case $board in
        comfast,cf-e313ac)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary art 0x6)
+               ath10k_patch_mac $(mtd_get_mac_binary art 0x6)
                ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
                        /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
                rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
@@ -128,18 +128,18 @@ case "$FIRMWARE" in
        dlink,dir-842-c3|\
        nec,wg1200cr)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata wlan5mac)
+               ath10k_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
                ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
                        /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
                ;;
        netgear,ex6400|\
        netgear,ex7300)
                caldata_extract "caldata" 0x5000 0x2f20
-               ath10kcal_patch_mac $(mtd_get_mac_binary caldata 0xc)
+               ath10k_patch_mac $(mtd_get_mac_binary caldata 0xc)
                ;;
        phicomm,k2t)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(k2t_get_mac "5g_mac")
+               ath10k_patch_mac $(k2t_get_mac "5g_mac")
                ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
                        /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
                ;;
@@ -150,7 +150,7 @@ case "$FIRMWARE" in
        tplink,archer-c60-v2|\
        tplink,archer-c6-v2)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary mac 0x8) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary mac 0x8) -1)
                ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
                        /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
                ;;
index 898e0bb0745392275cb9636e69edee633a25fdff..bdb12b2921b9ab892b9fe0e780f7090f4e83994f 100644 (file)
@@ -12,7 +12,7 @@ case "$FIRMWARE" in
        meraki,mr33)
                caldata_extract_ubi "ART" 0x9000 0x844
                caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
-               ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1)
+               ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1)
                ;;
        esac
        ;;
@@ -34,7 +34,7 @@ case "$FIRMWARE" in
        linksys,ea8300)
                caldata_extract "ART" 0x9000 0x2f20
                # OEM assigns 4 sequential MACs
-               ath10kcal_patch_mac_crc $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
+               ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
                ;;
        openmesh,a62)
                caldata_extract "0:ART" 0x9000 0x2f20
@@ -79,26 +79,26 @@ case "$FIRMWARE" in
                ;;
        engenius,ens620ext)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2)
                ;;
        linksys,ea8300)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
+               ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
                ;;
        meraki,mr33)
                caldata_extract_ubi "ART" 0x1000 0x2f20
                caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2)
+               ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2)
                ;;
        netgear,ex6100v2 |\
        netgear,ex6150v2)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0x0)
+               ath10k_patch_mac $(mtd_get_mac_binary dnidata 0x0)
                ;;
        zyxel,nbg6617 |\
        zyxel,wre6606)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
+               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
                ;;
        esac
        ;;
@@ -140,26 +140,26 @@ case "$FIRMWARE" in
                ;;
        engenius,ens620ext)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3)
                ;;
        linksys,ea8300)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3)
+               ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3)
                ;;
        meraki,mr33)
                caldata_extract_ubi "ART" 0x5000 0x2f20
                caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3)
+               ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3)
                ;;
        netgear,ex6100v2 |\
        netgear,ex6150v2)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0xc)
+               ath10k_patch_mac $(mtd_get_mac_binary dnidata 0xc)
                ;;
        zyxel,nbg6617 |\
        zyxel,wre6606)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
+               ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
                ;;
        esac
        ;;
index f8a4c98542cd977d90e188c5508a785f2e5e5480..6013bb100ce657107f6fe88d66c314b1b95fe1a5 100644 (file)
@@ -11,33 +11,33 @@ case "$FIRMWARE" in
        case $board in
        buffalo,wxr-2533dhp)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 0x1e)
+               ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
                ;;
        linksys,ea8500)
                caldata_extract "art" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
                ;;
        nec,wg2600hp)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1)
                ;;
        netgear,d7800 |\
        netgear,r7500v2 |\
        netgear,r7800)
                caldata_extract "art" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x6) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +1)
                ;;
        tplink,c2600)
                caldata_extract "radio" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1)
                ;;
        tplink,vr2600v)
                caldata_extract "ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1)
                ;;
        zyxel,nbg6817)
                caldata_extract "0:ART" 0x1000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
                ;;
        esac
        ;;
@@ -45,33 +45,33 @@ case "$FIRMWARE" in
        case $board in
        buffalo,wxr-2533dhp)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 0x18)
+               ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
                ;;
        linksys,ea8500)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
                ;;
        nec,wg2600hp)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 0xc)
+               ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0xc)
                ;;
        netgear,d7800 |\
        netgear,r7500v2 |\
        netgear,r7800)
                caldata_extract "art" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 0x6) +2)
+               ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +2)
                ;;
        tplink,c2600)
                caldata_extract "radio" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0x8)
+               ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x8)
                ;;
        tplink,vr2600v)
                caldata_extract "ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0x0)
+               ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x0)
                ;;
        zyxel,nbg6817)
                caldata_extract "0:ART" 0x5000 0x2f20
-               ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
+               ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
                ;;
        esac
        ;;
index 244635c6db6b89e1ff897df02126cb8234665882..0b48b77d412fd2e1b0c92aa0de5d3a6254e56dc1 100644 (file)
@@ -11,7 +11,7 @@ case "$FIRMWARE" in
        case $board in
                bt,homehub-v5a)
                        caldata_extract_ubi "caldata" 0x5000 0x844
-                       ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3)
+                       ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3)
                        ;;
                *)
                        caldata_die "board $board is not supported yet"