From 48b5d08a483a29c4e654a08580fffe12559e41b7 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 14 Oct 2019 14:02:40 +0200 Subject: [PATCH] treewide: use a single ath10k MAC patching function with checksum 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 --- .../base-files/files/lib/functions/caldata.sh | 8 +--- .../etc/hotplug.d/firmware/11-ath10k-caldata | 44 +++++++++---------- .../etc/hotplug.d/firmware/11-ath10k-caldata | 24 +++++----- .../etc/hotplug.d/firmware/11-ath10k-caldata | 28 ++++++------ .../etc/hotplug.d/firmware/11-ath10k-caldata | 2 +- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh index 004bcfa990..1ff69ce1ae 100644 --- a/package/base-files/files/lib/functions/caldata.sh +++ b/package/base-files/files/lib/functions/caldata.sh @@ -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 diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 9d6b643a8e..8ab0f6f6ad 100644 --- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -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 ;; diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 898e0bb074..bdb12b2921 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -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 ;; diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index f8a4c98542..6013bb100c 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -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 ;; diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 244635c6db..0b48b77d41 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -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" -- 2.25.1