Skip to content

Commit

Permalink
wifi: ath12k: add read variant from SMBIOS for download board data
Browse files Browse the repository at this point in the history
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: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4

Signed-off-by: Wen Gong <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Wen Gong authored and kvalo committed Oct 2, 2023
1 parent 1e55298 commit 7d9832e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
69 changes: 69 additions & 0 deletions drivers/net/wireless/ath/ath12k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,75 @@ static void ath12k_core_stop(struct ath12k_base *ab)
/* De-Init of components as needed */
}

static void ath12k_core_check_bdfext(const struct dmi_header *hdr, void *data)
{
struct ath12k_base *ab = data;
const char *magic = ATH12K_SMBIOS_BDF_EXT_MAGIC;
struct ath12k_smbios_bdf *smbios = (struct ath12k_smbios_bdf *)hdr;
ssize_t copied;
size_t len;
int i;

if (ab->qmi.target.bdf_ext[0] != '\0')
return;

if (hdr->type != ATH12K_SMBIOS_BDF_EXT_TYPE)
return;

if (hdr->length != ATH12K_SMBIOS_BDF_EXT_LENGTH) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"wrong smbios bdf ext type length (%d).\n",
hdr->length);
return;
}

if (!smbios->bdf_enabled) {
ath12k_dbg(ab, ATH12K_DBG_BOOT, "bdf variant name not found.\n");
return;
}

/* Only one string exists (per spec) */
if (memcmp(smbios->bdf_ext, magic, strlen(magic)) != 0) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"bdf variant magic does not match.\n");
return;
}

len = min_t(size_t,
strlen(smbios->bdf_ext), sizeof(ab->qmi.target.bdf_ext));
for (i = 0; i < len; i++) {
if (!isascii(smbios->bdf_ext[i]) || !isprint(smbios->bdf_ext[i])) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"bdf variant name contains non ascii chars.\n");
return;
}
}

/* Copy extension name without magic prefix */
copied = strscpy(ab->qmi.target.bdf_ext, smbios->bdf_ext + strlen(magic),
sizeof(ab->qmi.target.bdf_ext));
if (copied < 0) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"bdf variant string is longer than the buffer can accommodate\n");
return;
}

ath12k_dbg(ab, ATH12K_DBG_BOOT,
"found and validated bdf variant smbios_type 0x%x bdf %s\n",
ATH12K_SMBIOS_BDF_EXT_TYPE, ab->qmi.target.bdf_ext);
}

int ath12k_core_check_smbios(struct ath12k_base *ab)
{
ab->qmi.target.bdf_ext[0] = '\0';
dmi_walk(ath12k_core_check_bdfext, ab);

if (ab->qmi.target.bdf_ext[0] == '\0')
return -ENODATA;

return 0;
}

static int ath12k_core_soc_create(struct ath12k_base *ab)
{
int ret;
Expand Down
21 changes: 20 additions & 1 deletion drivers/net/wireless/ath/ath12k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/bitfield.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
#include "qmi.h"
#include "htc.h"
#include "wmi.h"
Expand All @@ -32,6 +34,15 @@
/* Pending management packets threshold for dropping probe responses */
#define ATH12K_PRB_RSP_DROP_THRESHOLD ((ATH12K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)

/* SMBIOS type containing Board Data File Name Extension */
#define ATH12K_SMBIOS_BDF_EXT_TYPE 0xF8

/* SMBIOS type structure length (excluding strings-set) */
#define ATH12K_SMBIOS_BDF_EXT_LENGTH 0x9

/* The magic used by QCA spec */
#define ATH12K_SMBIOS_BDF_EXT_MAGIC "BDF_"

#define ATH12K_INVALID_HW_MAC_ID 0xFF
#define ATH12K_RX_RATE_TABLE_NUM 320
#define ATH12K_RX_RATE_TABLE_11AX_NUM 576
Expand Down Expand Up @@ -129,6 +140,13 @@ struct ath12k_ext_irq_grp {
struct net_device napi_ndev;
};

struct ath12k_smbios_bdf {
struct dmi_header hdr;
u32 padding;
u8 bdf_enabled;
u8 bdf_ext[];
} __packed;

#define HEHANDLE_CAP_PHYINFO_SIZE 3
#define HECAP_PHYINFO_SIZE 9
#define HECAP_MACINFO_SIZE 5
Expand Down Expand Up @@ -792,7 +810,8 @@ int ath12k_core_fetch_board_data_api_1(struct ath12k_base *ab,
int ath12k_core_fetch_bdf(struct ath12k_base *ath12k,
struct ath12k_board_data *bd);
void ath12k_core_free_bdf(struct ath12k_base *ab, struct ath12k_board_data *bd);

int ath12k_core_check_dt(struct ath12k_base *ath12k);
int ath12k_core_check_smbios(struct ath12k_base *ab);
void ath12k_core_halt(struct ath12k *ar);
int ath12k_core_resume(struct ath12k_base *ab);
int ath12k_core_suspend(struct ath12k_base *ab);
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/ath/ath12k/qmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,7 @@ static int ath12k_qmi_request_target_cap(struct ath12k_base *ab)
struct qmi_txn txn = {};
unsigned int board_id = ATH12K_BOARD_ID_DEFAULT;
int ret = 0;
int r;
int i;

memset(&req, 0, sizeof(req));
Expand Down Expand Up @@ -2297,6 +2298,10 @@ static int ath12k_qmi_request_target_cap(struct ath12k_base *ab)
ab->qmi.target.fw_build_timestamp,
ab->qmi.target.fw_build_id);

r = ath12k_core_check_smbios(ab);
if (r)
ath12k_dbg(ab, ATH12K_DBG_QMI, "SMBIOS bdf variant name not set.\n");

out:
return ret;
}
Expand Down

0 comments on commit 7d9832e

Please sign in to comment.