mac80211: ath10k: backport bus and device specific API 1 BDF selection
authorRobert Marko <robimarko@gmail.com>
Tue, 30 Nov 2021 09:37:41 +0000 (10:37 +0100)
committerBaptiste Jonglez <git@bitsofnetworks.org>
Fri, 1 Jul 2022 10:46:45 +0000 (12:46 +0200)
Some ath10k IPQ40xx devices like the MikroTik hAP ac2 and ac3 require the
BDF-s to be extracted from the device storage instead of shipping packaged
API 2 BDF-s.

This is required as MikroTik has started shipping boards that require BDF-s
to be updated, as otherwise their WLAN performance really suffers.
This is however impossible as the devices that require this are release under
the same revision and its not possible to differentiate them from devices
using the older BDF-s.

In OpenWrt we are extracting the calibration data during runtime and we are
able to extract the BDF-s in the same manner, however we cannot package the
BDF-s to API 2 format on the fly and can only use API 1 to provide BDF-s on
the fly.
This is an issue as the ath10k driver explicitly looks only for the board.bin
file and not for something like board-bus-device.bin like it does for pre-cal
data.
Due to this we have no way of providing correct BDF-s on the fly, so lets
extend the ath10k driver to first look for BDF-s in the board-bus-device.bin
format, for example: board-ahb-a800000.wifi.bin
If that fails, look for the default board file name as defined previously.

So, backport the upstream ath10k patch.

Signed-off-by: Robert Marko <robimarko@gmail.com>
(cherry picked from commit 3daf2d477ee728b5b066fe7f31808a5f19bb98a1)
[prune unrelated patch refreshes]
Signed-off-by: Thibaut VARĂˆNE <hacks@slashdirt.org>
package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch [new file with mode: 0644]

diff --git a/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch b/package/kernel/mac80211/patches/ath10k/100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch
new file mode 100644 (file)
index 0000000..74d5b37
--- /dev/null
@@ -0,0 +1,65 @@
+From f2a7064a78b22f2b68b9fcbc8a6f4c5e61c5ba64 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Sun, 10 Oct 2021 00:17:11 +0200
+Subject: [PATCH] ath10k: support bus and device specific API 1 BDF selection
+
+Some ath10k IPQ40xx devices like the MikroTik hAP ac2 and ac3 require the
+BDF-s to be extracted from the device storage instead of shipping packaged
+API 2 BDF-s.
+
+This is required as MikroTik has started shipping boards that require BDF-s
+to be updated, as otherwise their WLAN performance really suffers.
+This is however impossible as the devices that require this are release
+under the same revision and its not possible to differentiate them from
+devices using the older BDF-s.
+
+In OpenWrt we are extracting the calibration data during runtime and we are
+able to extract the BDF-s in the same manner, however we cannot package the
+BDF-s to API 2 format on the fly and can only use API 1 to provide BDF-s on
+the fly.
+This is an issue as the ath10k driver explicitly looks only for the
+board.bin file and not for something like board-bus-device.bin like it does
+for pre-cal data.
+Due to this we have no way of providing correct BDF-s on the fly, so lets
+extend the ath10k driver to first look for BDF-s in the
+board-bus-device.bin format, for example: board-ahb-a800000.wifi.bin
+If that fails, look for the default board file name as defined previously.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
+Link: https://lore.kernel.org/r/20211009221711.2315352-1-robimarko@gmail.com
+---
+ drivers/net/wireless/ath/ath10k/core.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath/ath10k/core.c
++++ b/drivers/net/wireless/ath/ath10k/core.c
+@@ -1199,6 +1199,7 @@ success:
+ static int ath10k_core_fetch_board_data_api_1(struct ath10k *ar, int bd_ie_type)
+ {
+       const struct firmware *fw;
++      char boardname[100];
+       if (bd_ie_type == ATH10K_BD_IE_BOARD) {
+               if (!ar->hw_params.fw.board) {
+@@ -1206,9 +1207,19 @@ static int ath10k_core_fetch_board_data_
+                       return -EINVAL;
+               }
++              scnprintf(boardname, sizeof(boardname), "board-%s-%s.bin",
++                        ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
++
+               ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar,
+                                                               ar->hw_params.fw.dir,
+-                                                              ar->hw_params.fw.board);
++                                                              boardname);
++              if (IS_ERR(ar->normal_mode_fw.board)) {
++                      fw = ath10k_fetch_fw_file(ar,
++                                                ar->hw_params.fw.dir,
++                                                ar->hw_params.fw.board);
++                      ar->normal_mode_fw.board = fw;
++              }
++
+               if (IS_ERR(ar->normal_mode_fw.board))
+                       return PTR_ERR(ar->normal_mode_fw.board);