diff mbox series

ath11k: add read variant from SMBIOS for download board data

Message ID 20211011082433.30415-1-wgong@codeaurora.org (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series ath11k: add read variant from SMBIOS for download board data | expand

Commit Message

Wen Gong Oct. 11, 2021, 8:24 a.m. UTC
This is to read variant from SMBIOS such as read from DT, the variant
string will be used to one part of string which used to search board
data from board-2.bin.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1

Signed-off-by: Wen Gong <wgong@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/core.c | 74 ++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/core.h | 11 ++++
 drivers/net/wireless/ath/ath11k/qmi.c  |  4 ++
 3 files changed, 89 insertions(+)

Comments

Kalle Valo Nov. 17, 2021, 8:54 a.m. UTC | #1
Wen Gong <wgong@codeaurora.org> wrote:

> This is to read variant from SMBIOS such as read from DT, the variant
> string will be used to one part of string which used to search board
> data from board-2.bin.
> 
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
> 
> Signed-off-by: Wen Gong <wgong@codeaurora.org>

I'm dropping all patches listed below in one go. I didn't manage to
apply any of these without conflicts, please remember to always use
ath.git master branch as the baseline to avoid conflicts.

9 patches set to Changes Requested.

12549401 ath11k: add read variant from SMBIOS for download board data
12549415 ath11k: add wait operation for tx management packets for flush from mac80211
12549419 ath11k: change to treat alpha code na as world wide regdomain
12549431 ath11k: report rssi of each chain to mac80211
12549433 ath11k: Add signal report to mac80211 for QCA6390 and WCN6855
12549449 ath11k: report tx bitrate for iw wlan station dump
12554953 ath11k: add support for hardware rfkill for QCA6390
12583807 ath11k: add 11d scan offload support
12583809 ath11k: calculate the correct NSS of peer for HE capabilities
Wen Gong Nov. 18, 2021, 10:25 a.m. UTC | #2
On 2021-11-17 16:54, Kalle Valo wrote:
> Wen Gong <wgong@codeaurora.org> wrote:
> 
>> This is to read variant from SMBIOS such as read from DT, the variant
>> string will be used to one part of string which used to search board
>> data from board-2.bin.
>> 
>> Tested-on: WCN6855 hw2.0 PCI 
>> WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>> 
>> Signed-off-by: Wen Gong <wgong@codeaurora.org>
> 
> I'm dropping all patches listed below in one go. I didn't manage to
> apply any of these without conflicts, please remember to always use
> ath.git master branch as the baseline to avoid conflicts.
> 
> 9 patches set to Changes Requested.
> 
> 12549401 ath11k: add read variant from SMBIOS for download board data
> 12549415 ath11k: add wait operation for tx management packets for
> flush from mac80211
> 12549419 ath11k: change to treat alpha code na as world wide regdomain
> 12549431 ath11k: report rssi of each chain to mac80211
> 12549433 ath11k: Add signal report to mac80211 for QCA6390 and WCN6855
> 12549449 ath11k: report tx bitrate for iw wlan station dump
> 12554953 ath11k: add support for hardware rfkill for QCA6390
> 12583807 ath11k: add 11d scan offload support
> 12583809 ath11k: calculate the correct NSS of peer for HE capabilities

I have rebased to latest ath.git master ath-202111170737 and resend v2 
for below patches:
[v2] ath11k: report rssi of each chain to mac80211
[v2,0/2] ath11k: add 11d scan offload support for QCA6390/WCN6855
[v2] ath11k: add read variant from SMBIOS for download board data
[v2] ath11k: skip sending vdev down for channel switch
[v2] ath11k: fix read fail for htt_stats and htt_peer_stats for single 
pdev
[v2] ath11k: calculate the correct NSS of peer for HE capabilities
[v2] ath11k: add wait operation for tx management packets for flush from 
mac80211
[v2] ath11k: change to treat alpha code na as world wide regdomain

I will rebase the left patches after these patches upstream, otherwise 
the left patches will have conflict with these patches
because they change same location but actually have no logic relation.
Wen Gong Nov. 19, 2021, 7:58 a.m. UTC | #3
On 2021-11-18 18:25, Wen Gong wrote:
> On 2021-11-17 16:54, Kalle Valo wrote:
>> Wen Gong <wgong@codeaurora.org> wrote:
>> 
>>> This is to read variant from SMBIOS such as read from DT, the variant
>>> string will be used to one part of string which used to search board
>>> data from board-2.bin.
>>> 
>>> Tested-on: WCN6855 hw2.0 PCI 
>>> WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>>> 
>>> Signed-off-by: Wen Gong <wgong@codeaurora.org>
>> 
>> I'm dropping all patches listed below in one go. I didn't manage to
>> apply any of these without conflicts, please remember to always use
>> ath.git master branch as the baseline to avoid conflicts.
>> 
>> 9 patches set to Changes Requested.
>> 
>> 12549401 ath11k: add read variant from SMBIOS for download board data
>> 12549415 ath11k: add wait operation for tx management packets for
>> flush from mac80211
>> 12549419 ath11k: change to treat alpha code na as world wide regdomain
>> 12549431 ath11k: report rssi of each chain to mac80211
>> 12549433 ath11k: Add signal report to mac80211 for QCA6390 and WCN6855
>> 12549449 ath11k: report tx bitrate for iw wlan station dump
>> 12554953 ath11k: add support for hardware rfkill for QCA6390
>> 12583807 ath11k: add 11d scan offload support
>> 12583809 ath11k: calculate the correct NSS of peer for HE capabilities
> 
> I have rebased to latest ath.git master ath-202111170737 and resend v2
> for below patches:
> [v2] ath11k: report rssi of each chain to mac80211
> [v2,0/2] ath11k: add 11d scan offload support for QCA6390/WCN6855
> [v2] ath11k: add read variant from SMBIOS for download board data
> [v2] ath11k: skip sending vdev down for channel switch
> [v2] ath11k: fix read fail for htt_stats and htt_peer_stats for single 
> pdev
> [v2] ath11k: calculate the correct NSS of peer for HE capabilities
> [v2] ath11k: add wait operation for tx management packets for flush
> from mac80211
> [v2] ath11k: change to treat alpha code na as world wide regdomain
> 
> I will rebase the left patches after these patches upstream, otherwise
> the left patches will have conflict with these patches
> because they change same location but actually have no logic relation.

Hi Kalle,

I have tested in my local git, all the above v2 patches only have one 
conflict
between "[v2,2/2] ath11k: add 11d scan offload support"
and "[v2] ath11k: report rssi of each chain to mac80211"
in wmi_tlv_policies of wmi.c because they both add a item in the struct.
patch -p1 -i xxx.patch will auto fix this type conflict.

+       [WMI_TAG_11D_NEW_COUNTRY_EVENT] = {
+               .min_len = sizeof(struct wmi_11d_new_cc_ev) },

+       [WMI_TAG_PER_CHAIN_RSSI_STATS] = {
+               .min_len = sizeof(struct wmi_per_chain_rssi_stats) },
Kalle Valo Nov. 19, 2021, 1:18 p.m. UTC | #4
Wen Gong <wgong@codeaurora.org> writes:

> On 2021-11-18 18:25, Wen Gong wrote:
>> On 2021-11-17 16:54, Kalle Valo wrote:
>>> Wen Gong <wgong@codeaurora.org> wrote:
>>>
>>>> This is to read variant from SMBIOS such as read from DT, the variant
>>>> string will be used to one part of string which used to search board
>>>> data from board-2.bin.
>>>>
>>>> Tested-on: WCN6855 hw2.0 PCI
>>>> WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>>>>
>>>> Signed-off-by: Wen Gong <wgong@codeaurora.org>
>>>
>>> I'm dropping all patches listed below in one go. I didn't manage to
>>> apply any of these without conflicts, please remember to always use
>>> ath.git master branch as the baseline to avoid conflicts.
>>>
>>> 9 patches set to Changes Requested.
>>>
>>> 12549401 ath11k: add read variant from SMBIOS for download board data
>>> 12549415 ath11k: add wait operation for tx management packets for
>>> flush from mac80211
>>> 12549419 ath11k: change to treat alpha code na as world wide regdomain
>>> 12549431 ath11k: report rssi of each chain to mac80211
>>> 12549433 ath11k: Add signal report to mac80211 for QCA6390 and WCN6855
>>> 12549449 ath11k: report tx bitrate for iw wlan station dump
>>> 12554953 ath11k: add support for hardware rfkill for QCA6390
>>> 12583807 ath11k: add 11d scan offload support
>>> 12583809 ath11k: calculate the correct NSS of peer for HE capabilities
>>
>> I have rebased to latest ath.git master ath-202111170737 and resend v2
>> for below patches:
>> [v2] ath11k: report rssi of each chain to mac80211
>> [v2,0/2] ath11k: add 11d scan offload support for QCA6390/WCN6855
>> [v2] ath11k: add read variant from SMBIOS for download board data
>> [v2] ath11k: skip sending vdev down for channel switch
>> [v2] ath11k: fix read fail for htt_stats and htt_peer_stats for
>> single pdev
>> [v2] ath11k: calculate the correct NSS of peer for HE capabilities
>> [v2] ath11k: add wait operation for tx management packets for flush
>> from mac80211
>> [v2] ath11k: change to treat alpha code na as world wide regdomain
>>
>> I will rebase the left patches after these patches upstream, otherwise
>> the left patches will have conflict with these patches
>> because they change same location but actually have no logic relation.
>
> Hi Kalle,
>
> I have tested in my local git, all the above v2 patches only have one
> conflict
> between "[v2,2/2] ath11k: add 11d scan offload support"
> and "[v2] ath11k: report rssi of each chain to mac80211"
> in wmi_tlv_policies of wmi.c because they both add a item in the struct.
> patch -p1 -i xxx.patch will auto fix this type conflict.
>
> +       [WMI_TAG_11D_NEW_COUNTRY_EVENT] = {
> +               .min_len = sizeof(struct wmi_11d_new_cc_ev) },
>
> +       [WMI_TAG_PER_CHAIN_RSSI_STATS] = {
> +               .min_len = sizeof(struct wmi_per_chain_rssi_stats) },

Thanks, this was very helpful. I have the patches now in the pending
branch, I'll test and review them next week.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index 354ad84a2bb8..ae2f52b4373d 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -8,6 +8,9 @@ 
 #include <linux/remoteproc.h>
 #include <linux/firmware.h>
 #include <linux/of.h>
+#include <linux/dmi.h>
+#include <linux/ctype.h>
+
 #include "core.h"
 #include "dp_tx.h"
 #include "dp_rx.h"
@@ -372,6 +375,77 @@  int ath11k_core_resume(struct ath11k_base *ab)
 }
 EXPORT_SYMBOL(ath11k_core_resume);
 
+static void ath11k_core_check_bdfext(const struct dmi_header *hdr, void *data)
+{
+	struct ath11k_base *ab = data;
+	const char *bdf_ext;
+	const char *magic = ATH11K_SMBIOS_BDF_EXT_MAGIC;
+	u8 bdf_enabled;
+	int i;
+	size_t len;
+
+	if (ab->qmi.target.bdf_ext[0] != '\0')
+		return;
+
+	if (hdr->type != ATH11K_SMBIOS_BDF_EXT_TYPE)
+		return;
+
+	if (hdr->length != ATH11K_SMBIOS_BDF_EXT_LENGTH) {
+		ath11k_dbg(ab, ATH11K_DBG_BOOT,
+			   "wrong smbios bdf ext type length (%d).\n",
+			   hdr->length);
+		return;
+	}
+
+	bdf_enabled = *((u8 *)hdr + ATH11K_SMBIOS_BDF_EXT_OFFSET);
+	if (!bdf_enabled) {
+		ath11k_dbg(ab, ATH11K_DBG_BOOT, "bdf variant name not found.\n");
+		return;
+	}
+
+	/* Only one string exists (per spec) */
+	bdf_ext = (char *)hdr + hdr->length;
+
+	if (memcmp(bdf_ext, magic, strlen(magic)) != 0) {
+		ath11k_dbg(ab, ATH11K_DBG_BOOT,
+			   "bdf variant magic does not match.\n");
+		return;
+	}
+
+	len = strlen(bdf_ext);
+	for (i = 0; i < len; i++) {
+		if (!isascii(bdf_ext[i]) || !isprint(bdf_ext[i])) {
+			ath11k_dbg(ab, ATH11K_DBG_BOOT,
+				   "bdf variant name contains non ascii chars.\n");
+			return;
+		}
+	}
+
+	/* Copy extension name without magic prefix */
+	if (strscpy(ab->qmi.target.bdf_ext, bdf_ext + strlen(magic),
+		    sizeof(ab->qmi.target.bdf_ext)) < 0) {
+		ath11k_dbg(ab, ATH11K_DBG_BOOT,
+			   "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
+			    bdf_ext);
+		return;
+	}
+
+	ath11k_dbg(ab, ATH11K_DBG_BOOT,
+		   "found and validated bdf variant smbios_type 0x%x bdf %s\n",
+		   ATH11K_SMBIOS_BDF_EXT_TYPE, bdf_ext);
+}
+
+int ath11k_core_check_smbios(struct ath11k_base *ab)
+{
+	ab->qmi.target.bdf_ext[0] = '\0';
+	dmi_walk(ath11k_core_check_bdfext, ab);
+
+	if (ab->qmi.target.bdf_ext[0] == '\0')
+		return -ENODATA;
+
+	return 0;
+}
+
 int ath11k_core_check_dt(struct ath11k_base *ab)
 {
 	size_t max_len = sizeof(ab->qmi.target.bdf_ext);
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 63d569672cd2..dcc54d4cc096 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -1044,7 +1044,18 @@  int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
 				       char *name);
 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
 int ath11k_core_check_dt(struct ath11k_base *ath11k);
+/* SMBIOS type containing Board Data File Name Extension */
+#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
 
+/* SMBIOS type structure length (excluding strings-set) */
+#define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
+
+/* Offset pointing to Board Data File Name Extension */
+#define ATH11K_SMBIOS_BDF_EXT_OFFSET 0x8
+
+/* The magic used by QCA spec */
+#define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
+int ath11k_core_check_smbios(struct ath11k_base *ab);
 void ath11k_core_halt(struct ath11k *ar);
 int ath11k_core_resume(struct ath11k_base *ab);
 int ath11k_core_suspend(struct ath11k_base *ab);
diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index d9db74e597b5..77880ddc4d77 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -2089,6 +2089,10 @@  static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
 		    ab->qmi.target.fw_build_timestamp,
 		    ab->qmi.target.fw_build_id);
 
+	r = ath11k_core_check_smbios(ab);
+	if (r)
+		ath11k_dbg(ab, ATH11K_DBG_QMI, "SMBIOS bdf variant name not set.\n");
+
 	r = ath11k_core_check_dt(ab);
 	if (r)
 		ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n");