ath11k: add regdb.bin download for regdb offload

The regdomain is self-managed type for ath11k, the regdomain info is
reported from firmware, it is not from wireless regdb. Firmware fetch
the regdomain info from board data file before. Currently most of the
regdomain info has moved to another file regdb.bin from board data
file for some chips such as QCA6390 and WCN6855, so the regdomain info
left in board data file is not enough to support the feature which need
more regdomain info.

After download regdb.bin, firmware will fetch the regdomain info from
regdb.bin instead of board data file and report to ath11k. If it does
not have the file regdb.bin, it also can initialize wlan success and
firmware then fetch regdomain info from board data file.

Add download the regdb.bin before download board data for some specific
chip which support supports_regdb in hardware parameters.

download regdb.bin log:
[430082.334162] ath11k_pci 0000:05:00.0: chip_id 0x2 chip_family 0xb board_id 0x106 soc_id 0x400c0200
[430082.334169] ath11k_pci 0000:05:00.0: fw_version 0x110c8b4c fw_build_timestamp 2021-10-25 07:41 fw_build_id QC_IMAGE_VERSION_STRING=WLAN.HSP.1.1-02892-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
[430082.334414] ath11k_pci 0000:05:00.0: boot firmware request ath11k/WCN6855/hw2.0/regdb.bin size 24310

output of "iw reg get"
global
country US: DFS-FCC
        (2402 - 2472 @ 40), (N/A, 30), (N/A)
        (5170 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
        (5250 - 5330 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
        (5490 - 5730 @ 160), (N/A, 23), (0 ms), DFS
        (5735 - 5835 @ 80), (N/A, 30), (N/A)
        (57240 - 63720 @ 2160), (N/A, 40), (N/A)

phy#0 (self-managed)
country US: DFS-FCC
        (2402 - 2472 @ 40), (6, 30), (N/A)
        (5170 - 5250 @ 80), (N/A, 24), (N/A), AUTO-BW
        (5250 - 5330 @ 80), (N/A, 24), (0 ms), DFS, AUTO-BW
        (5490 - 5730 @ 160), (N/A, 24), (0 ms), DFS, AUTO-BW
        (5735 - 5895 @ 160), (N/A, 30), (N/A), AUTO-BW
        (5945 - 7125 @ 160), (N/A, 24), (N/A), NO-OUTDOOR, AUTO-BW

Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20211220062355.17021-1-quic_wgong@quicinc.com
This commit is contained in:
Wen Gong 2021-12-20 01:23:55 -05:00 committed by Kalle Valo
parent ec038c6127
commit 01417e5793
5 changed files with 52 additions and 13 deletions

View File

@ -87,6 +87,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 512, .num_peers = 512,
.supports_suspend = false, .supports_suspend = false,
.hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074), .hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074),
.supports_regdb = false,
.fix_l1ss = true, .fix_l1ss = true,
.credit_flow = false, .credit_flow = false,
.max_tx_ring = DP_TCL_NUM_RING_MAX, .max_tx_ring = DP_TCL_NUM_RING_MAX,
@ -149,6 +150,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 512, .num_peers = 512,
.supports_suspend = false, .supports_suspend = false,
.hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074), .hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074),
.supports_regdb = false,
.fix_l1ss = true, .fix_l1ss = true,
.credit_flow = false, .credit_flow = false,
.max_tx_ring = DP_TCL_NUM_RING_MAX, .max_tx_ring = DP_TCL_NUM_RING_MAX,
@ -210,6 +212,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 512, .num_peers = 512,
.supports_suspend = true, .supports_suspend = true,
.hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074), .hal_desc_sz = sizeof(struct hal_rx_desc_ipq8074),
.supports_regdb = true,
.fix_l1ss = true, .fix_l1ss = true,
.credit_flow = true, .credit_flow = true,
.max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390, .max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390,
@ -271,6 +274,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 128, .num_peers = 128,
.supports_suspend = false, .supports_suspend = false,
.hal_desc_sz = sizeof(struct hal_rx_desc_qcn9074), .hal_desc_sz = sizeof(struct hal_rx_desc_qcn9074),
.supports_regdb = false,
.fix_l1ss = true, .fix_l1ss = true,
.credit_flow = false, .credit_flow = false,
.max_tx_ring = DP_TCL_NUM_RING_MAX, .max_tx_ring = DP_TCL_NUM_RING_MAX,
@ -332,6 +336,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 512, .num_peers = 512,
.supports_suspend = true, .supports_suspend = true,
.hal_desc_sz = sizeof(struct hal_rx_desc_wcn6855), .hal_desc_sz = sizeof(struct hal_rx_desc_wcn6855),
.supports_regdb = true,
.fix_l1ss = false, .fix_l1ss = false,
.credit_flow = true, .credit_flow = true,
.max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390, .max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390,
@ -392,6 +397,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.num_peers = 512, .num_peers = 512,
.supports_suspend = true, .supports_suspend = true,
.hal_desc_sz = sizeof(struct hal_rx_desc_wcn6855), .hal_desc_sz = sizeof(struct hal_rx_desc_wcn6855),
.supports_regdb = true,
.fix_l1ss = false, .fix_l1ss = false,
.credit_flow = true, .credit_flow = true,
.max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390, .max_tx_ring = DP_TCL_NUM_RING_MAX_QCA6390,
@ -760,10 +766,12 @@ err:
return ret; return ret;
} }
static int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab, int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
struct ath11k_board_data *bd) struct ath11k_board_data *bd,
const char *name)
{ {
bd->fw = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_BOARD_FILE); bd->fw = ath11k_core_firmware_request(ab, name);
if (IS_ERR(bd->fw)) if (IS_ERR(bd->fw))
return PTR_ERR(bd->fw); return PTR_ERR(bd->fw);
@ -791,7 +799,7 @@ int ath11k_core_fetch_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd)
goto success; goto success;
ab->bd_api = 1; ab->bd_api = 1;
ret = ath11k_core_fetch_board_data_api_1(ab, bd); ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_DEFAULT_BOARD_FILE);
if (ret) { if (ret) {
ath11k_err(ab, "failed to fetch board-2.bin or board.bin from %s\n", ath11k_err(ab, "failed to fetch board-2.bin or board.bin from %s\n",
ab->hw_params.fw.dir); ab->hw_params.fw.dir);
@ -803,6 +811,18 @@ success:
return 0; return 0;
} }
int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd)
{
int ret;
ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_REGDB_FILE_NAME);
if (ret)
ath11k_dbg(ab, ATH11K_DBG_BOOT, "failed to fetch %s from %s\n",
ATH11K_REGDB_FILE_NAME, ab->hw_params.fw.dir);
return ret;
}
static void ath11k_core_stop(struct ath11k_base *ab) static void ath11k_core_stop(struct ath11k_base *ab)
{ {
if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)) if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))

View File

@ -980,6 +980,10 @@ struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,
void ath11k_core_free(struct ath11k_base *ath11k); void ath11k_core_free(struct ath11k_base *ath11k);
int ath11k_core_fetch_bdf(struct ath11k_base *ath11k, int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
struct ath11k_board_data *bd); struct ath11k_board_data *bd);
int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd);
int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
struct ath11k_board_data *bd,
const char *name);
void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
int ath11k_core_check_dt(struct ath11k_base *ath11k); int ath11k_core_check_dt(struct ath11k_base *ath11k);

View File

@ -77,6 +77,7 @@
#define ATH11K_DEFAULT_CAL_FILE "caldata.bin" #define ATH11K_DEFAULT_CAL_FILE "caldata.bin"
#define ATH11K_AMSS_FILE "amss.bin" #define ATH11K_AMSS_FILE "amss.bin"
#define ATH11K_M3_FILE "m3.bin" #define ATH11K_M3_FILE "m3.bin"
#define ATH11K_REGDB_FILE_NAME "regdb.bin"
enum ath11k_hw_rate_cck { enum ath11k_hw_rate_cck {
ATH11K_HW_RATE_CCK_LP_11M = 0, ATH11K_HW_RATE_CCK_LP_11M = 0,
@ -181,6 +182,7 @@ struct ath11k_hw_params {
u32 num_peers; u32 num_peers;
bool supports_suspend; bool supports_suspend;
u32 hal_desc_sz; u32 hal_desc_sz;
bool supports_regdb;
bool fix_l1ss; bool fix_l1ss;
bool credit_flow; bool credit_flow;
u8 max_tx_ring; u8 max_tx_ring;

View File

@ -2161,7 +2161,8 @@ err_free_req:
return ret; return ret;
} }
static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab) static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab,
bool regdb)
{ {
struct device *dev = ab->dev; struct device *dev = ab->dev;
char filename[ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE]; char filename[ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE];
@ -2172,13 +2173,21 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
const u8 *tmp; const u8 *tmp;
memset(&bd, 0, sizeof(bd)); memset(&bd, 0, sizeof(bd));
if (regdb) {
ret = ath11k_core_fetch_regdb(ab, &bd);
} else {
ret = ath11k_core_fetch_bdf(ab, &bd); ret = ath11k_core_fetch_bdf(ab, &bd);
if (ret) { if (ret)
ath11k_warn(ab, "qmi failed to fetch board file: %d\n", ret); ath11k_warn(ab, "qmi failed to fetch board file: %d\n", ret);
goto out;
} }
if (bd.len >= SELFMAG && memcmp(bd.data, ELFMAG, SELFMAG) == 0) if (ret)
goto out;
if (regdb)
bdf_type = ATH11K_QMI_BDF_TYPE_REGDB;
else if (bd.len >= SELFMAG && memcmp(bd.data, ELFMAG, SELFMAG) == 0)
bdf_type = ATH11K_QMI_BDF_TYPE_ELF; bdf_type = ATH11K_QMI_BDF_TYPE_ELF;
else else
bdf_type = ATH11K_QMI_BDF_TYPE_BIN; bdf_type = ATH11K_QMI_BDF_TYPE_BIN;
@ -2193,8 +2202,8 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
goto out; goto out;
} }
/* QCA6390 does not support cal data, skip it */ /* QCA6390/WCN6855 does not support cal data, skip it */
if (bdf_type == ATH11K_QMI_BDF_TYPE_ELF) if (bdf_type == ATH11K_QMI_BDF_TYPE_ELF || bdf_type == ATH11K_QMI_BDF_TYPE_REGDB)
goto out; goto out;
if (ab->qmi.target.eeprom_caldata) { if (ab->qmi.target.eeprom_caldata) {
@ -2626,7 +2635,10 @@ static int ath11k_qmi_event_load_bdf(struct ath11k_qmi *qmi)
return ret; return ret;
} }
ret = ath11k_qmi_load_bdf_qmi(ab); if (ab->hw_params.supports_regdb)
ath11k_qmi_load_bdf_qmi(ab, true);
ret = ath11k_qmi_load_bdf_qmi(ab, false);
if (ret < 0) { if (ret < 0) {
ath11k_warn(ab, "failed to load board data file: %d\n", ret); ath11k_warn(ab, "failed to load board data file: %d\n", ret);
return ret; return ret;

View File

@ -48,6 +48,7 @@ enum ath11k_qmi_file_type {
enum ath11k_qmi_bdf_type { enum ath11k_qmi_bdf_type {
ATH11K_QMI_BDF_TYPE_BIN = 0, ATH11K_QMI_BDF_TYPE_BIN = 0,
ATH11K_QMI_BDF_TYPE_ELF = 1, ATH11K_QMI_BDF_TYPE_ELF = 1,
ATH11K_QMI_BDF_TYPE_REGDB = 4,
}; };
enum ath11k_qmi_event_type { enum ath11k_qmi_event_type {