2020-12-10 00:06:03 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
|
|
|
/*
|
2024-02-05 21:21:04 +02:00
|
|
|
* Copyright (C) 2012-2014, 2018-2024 Intel Corporation
|
2020-12-10 00:06:03 +02:00
|
|
|
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH
|
|
|
|
* Copyright (C) 2016-2017 Intel Deutschland GmbH
|
|
|
|
*/
|
2013-01-24 14:25:36 +01:00
|
|
|
#include <net/mac80211.h>
|
2016-03-22 15:55:58 +02:00
|
|
|
#include <linux/netdevice.h>
|
2021-01-31 20:22:07 +02:00
|
|
|
#include <linux/dmi.h>
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
#include "iwl-trans.h"
|
|
|
|
#include "iwl-op-mode.h"
|
2017-06-01 10:22:09 +02:00
|
|
|
#include "fw/img.h"
|
2013-01-24 14:25:36 +01:00
|
|
|
#include "iwl-debug.h"
|
2014-12-04 10:07:47 +02:00
|
|
|
#include "iwl-prph.h"
|
2017-09-19 12:35:18 +03:00
|
|
|
#include "fw/acpi.h"
|
2020-10-08 18:12:46 +03:00
|
|
|
#include "fw/pnvm.h"
|
2023-10-22 17:55:50 +03:00
|
|
|
#include "fw/uefi.h"
|
2024-01-31 10:24:39 +02:00
|
|
|
#include "fw/regulatory.h"
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
#include "mvm.h"
|
2017-06-01 16:03:19 +02:00
|
|
|
#include "fw/dbg.h"
|
2013-01-24 14:25:36 +01:00
|
|
|
#include "iwl-phy-db.h"
|
2018-01-14 19:06:09 +02:00
|
|
|
#include "iwl-modparams.h"
|
|
|
|
#include "iwl-nvm-parse.h"
|
2023-03-20 12:33:18 +02:00
|
|
|
#include "time-sync.h"
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2023-10-11 13:07:27 +03:00
|
|
|
#define MVM_UCODE_ALIVE_TIMEOUT (2 * HZ)
|
2020-10-08 18:12:46 +03:00
|
|
|
#define MVM_UCODE_CALIB_TIMEOUT (2 * HZ)
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2023-10-22 17:55:50 +03:00
|
|
|
#define IWL_UATS_VLP_AP_SUPPORTED BIT(29)
|
|
|
|
#define IWL_UATS_AFC_AP_SUPPORTED BIT(30)
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
struct iwl_mvm_alive_data {
|
|
|
|
bool valid;
|
|
|
|
u32 scd_base_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
|
|
|
|
{
|
|
|
|
struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
|
|
|
|
.valid = cpu_to_le32(valid_tx_ant),
|
|
|
|
};
|
|
|
|
|
2013-03-09 20:38:19 +02:00
|
|
|
IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant);
|
2014-05-12 11:36:41 +03:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0,
|
2013-01-24 14:25:36 +01:00
|
|
|
sizeof(tx_ant_cmd), &tx_ant_cmd);
|
|
|
|
}
|
|
|
|
|
2015-12-31 11:49:18 +02:00
|
|
|
static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct iwl_rss_config_cmd cmd = {
|
|
|
|
.flags = cpu_to_le32(IWL_RSS_ENABLE),
|
2018-12-12 09:45:11 +02:00
|
|
|
.hash_mask = BIT(IWL_RSS_HASH_TYPE_IPV4_TCP) |
|
|
|
|
BIT(IWL_RSS_HASH_TYPE_IPV4_UDP) |
|
|
|
|
BIT(IWL_RSS_HASH_TYPE_IPV4_PAYLOAD) |
|
|
|
|
BIT(IWL_RSS_HASH_TYPE_IPV6_TCP) |
|
|
|
|
BIT(IWL_RSS_HASH_TYPE_IPV6_UDP) |
|
|
|
|
BIT(IWL_RSS_HASH_TYPE_IPV6_PAYLOAD),
|
2015-12-31 11:49:18 +02:00
|
|
|
};
|
|
|
|
|
2016-05-04 14:22:10 +03:00
|
|
|
if (mvm->trans->num_rx_queues == 1)
|
|
|
|
return 0;
|
|
|
|
|
2016-03-22 15:55:58 +02:00
|
|
|
/* Do not direct RSS traffic to Q 0 which is our fallback queue */
|
2015-12-31 11:49:18 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++)
|
2016-03-22 15:55:58 +02:00
|
|
|
cmd.indirection_table[i] =
|
|
|
|
1 + (i % (mvm->trans->num_rx_queues - 1));
|
|
|
|
netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
|
2015-12-31 11:49:18 +02:00
|
|
|
|
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd);
|
|
|
|
}
|
|
|
|
|
2015-08-31 14:33:23 +03:00
|
|
|
static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
struct iwl_dqa_enable_cmd dqa_cmd = {
|
|
|
|
.cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE),
|
|
|
|
};
|
2022-01-28 15:34:23 +02:00
|
|
|
u32 cmd_id = WIDE_ID(DATA_PATH_GROUP, DQA_ENABLE_CMD);
|
2015-08-31 14:33:23 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd);
|
|
|
|
if (ret)
|
|
|
|
IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret);
|
|
|
|
else
|
|
|
|
IWL_DEBUG_FW(mvm, "Working in DQA mode\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-15 14:45:29 +02:00
|
|
|
void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_rx_cmd_buffer *rxb)
|
|
|
|
{
|
|
|
|
struct iwl_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data;
|
|
|
|
__le32 *dump_data = mfu_dump_notif->data;
|
|
|
|
int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (mfu_dump_notif->index_num == 0)
|
|
|
|
IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n",
|
|
|
|
le32_to_cpu(mfu_dump_notif->assert_id));
|
|
|
|
|
|
|
|
for (i = 0; i < n_words; i++)
|
|
|
|
IWL_DEBUG_INFO(mvm,
|
|
|
|
"MFUART assert dump, dword %u: 0x%08x\n",
|
|
|
|
le16_to_cpu(mfu_dump_notif->index_num) *
|
|
|
|
n_words + i,
|
|
|
|
le32_to_cpu(dump_data[i]));
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
|
|
|
{
|
2020-12-09 23:16:51 +02:00
|
|
|
unsigned int pkt_len = iwl_rx_packet_payload_len(pkt);
|
2013-01-24 14:25:36 +01:00
|
|
|
struct iwl_mvm *mvm =
|
|
|
|
container_of(notif_wait, struct iwl_mvm, notif_wait);
|
|
|
|
struct iwl_mvm_alive_data *alive_data = data;
|
2016-11-24 13:48:27 +02:00
|
|
|
struct iwl_umac_alive *umac;
|
|
|
|
struct iwl_lmac_alive *lmac1;
|
|
|
|
struct iwl_lmac_alive *lmac2 = NULL;
|
|
|
|
u16 status;
|
2020-09-26 00:30:49 +03:00
|
|
|
u32 lmac_error_event_table, umac_error_table;
|
2021-12-04 08:35:50 +02:00
|
|
|
u32 version = iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
|
|
|
|
UCODE_ALIVE_NTFY, 0);
|
2022-03-04 13:21:21 +02:00
|
|
|
u32 i;
|
2022-12-05 10:35:47 +02:00
|
|
|
|
2014-02-03 09:29:57 +02:00
|
|
|
|
2022-01-29 13:16:19 +02:00
|
|
|
if (version == 6) {
|
|
|
|
struct iwl_alive_ntf_v6 *palive;
|
|
|
|
|
|
|
|
if (pkt_len < sizeof(*palive))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
palive = (void *)pkt->data;
|
|
|
|
mvm->trans->dbg.imr_data.imr_enable =
|
|
|
|
le32_to_cpu(palive->imr.enabled);
|
|
|
|
mvm->trans->dbg.imr_data.imr_size =
|
|
|
|
le32_to_cpu(palive->imr.size);
|
|
|
|
mvm->trans->dbg.imr_data.imr2sram_remainbyte =
|
|
|
|
mvm->trans->dbg.imr_data.imr_size;
|
|
|
|
mvm->trans->dbg.imr_data.imr_base_addr =
|
|
|
|
palive->imr.base_addr;
|
|
|
|
mvm->trans->dbg.imr_data.imr_curr_addr =
|
|
|
|
le64_to_cpu(mvm->trans->dbg.imr_data.imr_base_addr);
|
|
|
|
IWL_DEBUG_FW(mvm, "IMR Enabled: 0x0%x size 0x0%x Address 0x%016llx\n",
|
|
|
|
mvm->trans->dbg.imr_data.imr_enable,
|
|
|
|
mvm->trans->dbg.imr_data.imr_size,
|
|
|
|
le64_to_cpu(mvm->trans->dbg.imr_data.imr_base_addr));
|
2022-03-04 13:21:21 +02:00
|
|
|
|
|
|
|
if (!mvm->trans->dbg.imr_data.imr_enable) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(mvm->trans->dbg.active_regions); i++) {
|
|
|
|
struct iwl_ucode_tlv *reg_tlv;
|
|
|
|
struct iwl_fw_ini_region_tlv *reg;
|
|
|
|
|
|
|
|
reg_tlv = mvm->trans->dbg.active_regions[i];
|
|
|
|
if (!reg_tlv)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
reg = (void *)reg_tlv->data;
|
|
|
|
/*
|
|
|
|
* We have only one DRAM IMR region, so we
|
|
|
|
* can break as soon as we find the first
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
if (reg->type == IWL_FW_INI_REGION_DRAM_IMR) {
|
|
|
|
mvm->trans->dbg.unsupported_region_msk |= BIT(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-29 13:16:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (version >= 5) {
|
2020-10-08 18:09:38 +03:00
|
|
|
struct iwl_alive_ntf_v5 *palive;
|
|
|
|
|
2020-12-09 23:16:51 +02:00
|
|
|
if (pkt_len < sizeof(*palive))
|
|
|
|
return false;
|
|
|
|
|
2020-10-08 18:09:38 +03:00
|
|
|
palive = (void *)pkt->data;
|
|
|
|
umac = &palive->umac_data;
|
|
|
|
lmac1 = &palive->lmac_data[0];
|
|
|
|
lmac2 = &palive->lmac_data[1];
|
|
|
|
status = le16_to_cpu(palive->status);
|
|
|
|
|
|
|
|
mvm->trans->sku_id[0] = le32_to_cpu(palive->sku_id.data[0]);
|
|
|
|
mvm->trans->sku_id[1] = le32_to_cpu(palive->sku_id.data[1]);
|
|
|
|
mvm->trans->sku_id[2] = le32_to_cpu(palive->sku_id.data[2]);
|
|
|
|
|
|
|
|
IWL_DEBUG_FW(mvm, "Got sku_id: 0x0%x 0x0%x 0x0%x\n",
|
|
|
|
mvm->trans->sku_id[0],
|
|
|
|
mvm->trans->sku_id[1],
|
|
|
|
mvm->trans->sku_id[2]);
|
|
|
|
} else if (iwl_rx_packet_payload_len(pkt) == sizeof(struct iwl_alive_ntf_v4)) {
|
2020-09-30 19:19:55 +03:00
|
|
|
struct iwl_alive_ntf_v4 *palive;
|
|
|
|
|
2020-12-09 23:16:51 +02:00
|
|
|
if (pkt_len < sizeof(*palive))
|
|
|
|
return false;
|
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
palive = (void *)pkt->data;
|
|
|
|
umac = &palive->umac_data;
|
|
|
|
lmac1 = &palive->lmac_data[0];
|
|
|
|
lmac2 = &palive->lmac_data[1];
|
|
|
|
status = le16_to_cpu(palive->status);
|
2020-09-30 19:19:55 +03:00
|
|
|
} else if (iwl_rx_packet_payload_len(pkt) ==
|
|
|
|
sizeof(struct iwl_alive_ntf_v3)) {
|
|
|
|
struct iwl_alive_ntf_v3 *palive3;
|
|
|
|
|
2020-12-09 23:16:51 +02:00
|
|
|
if (pkt_len < sizeof(*palive3))
|
|
|
|
return false;
|
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
palive3 = (void *)pkt->data;
|
|
|
|
umac = &palive3->umac_data;
|
|
|
|
lmac1 = &palive3->lmac_data;
|
|
|
|
status = le16_to_cpu(palive3->status);
|
2020-09-30 19:19:55 +03:00
|
|
|
} else {
|
|
|
|
WARN(1, "unsupported alive notification (size %d)\n",
|
|
|
|
iwl_rx_packet_payload_len(pkt));
|
|
|
|
/* get timeout later */
|
|
|
|
return false;
|
2016-11-24 13:48:27 +02:00
|
|
|
}
|
2014-02-03 09:29:57 +02:00
|
|
|
|
2018-04-24 13:35:59 +03:00
|
|
|
lmac_error_event_table =
|
|
|
|
le32_to_cpu(lmac1->dbg_ptrs.error_event_table_ptr);
|
|
|
|
iwl_fw_lmac1_set_alive_err_table(mvm->trans, lmac_error_event_table);
|
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
if (lmac2)
|
2019-05-13 10:13:47 +03:00
|
|
|
mvm->trans->dbg.lmac_error_event_table[1] =
|
2018-04-24 13:35:59 +03:00
|
|
|
le32_to_cpu(lmac2->dbg_ptrs.error_event_table_ptr);
|
2014-02-11 16:37:34 +02:00
|
|
|
|
2021-04-11 12:46:23 +03:00
|
|
|
umac_error_table = le32_to_cpu(umac->dbg_ptrs.error_info_addr) &
|
|
|
|
~FW_ADDR_CACHE_CONTROL;
|
2020-09-26 00:30:49 +03:00
|
|
|
|
|
|
|
if (umac_error_table) {
|
|
|
|
if (umac_error_table >=
|
2023-03-14 19:49:15 +02:00
|
|
|
mvm->trans->cfg->min_umac_error_event_table) {
|
2020-09-26 00:30:49 +03:00
|
|
|
iwl_fw_umac_set_alive_err_table(mvm->trans,
|
|
|
|
umac_error_table);
|
|
|
|
} else {
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"Not valid error log pointer 0x%08X for %s uCode\n",
|
|
|
|
umac_error_table,
|
|
|
|
(mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) ?
|
|
|
|
"Init" : "RT");
|
|
|
|
}
|
2017-10-02 16:12:23 +03:00
|
|
|
}
|
2017-10-02 15:44:20 +03:00
|
|
|
|
2018-04-24 13:35:59 +03:00
|
|
|
alive_data->scd_base_addr = le32_to_cpu(lmac1->dbg_ptrs.scd_base_ptr);
|
2016-11-24 13:48:27 +02:00
|
|
|
alive_data->valid = status == IWL_ALIVE_STATUS_OK;
|
2015-02-03 20:11:48 +02:00
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
IWL_DEBUG_FW(mvm,
|
|
|
|
"Alive ucode status 0x%04x revision 0x%01X 0x%01X\n",
|
|
|
|
status, lmac1->ver_type, lmac1->ver_subtype);
|
2015-02-03 20:11:48 +02:00
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
if (lmac2)
|
|
|
|
IWL_DEBUG_FW(mvm, "Alive ucode CDB\n");
|
2015-02-03 20:11:48 +02:00
|
|
|
|
2016-11-24 13:48:27 +02:00
|
|
|
IWL_DEBUG_FW(mvm,
|
|
|
|
"UMAC version: Major - 0x%x, Minor - 0x%x\n",
|
|
|
|
le32_to_cpu(umac->umac_major),
|
|
|
|
le32_to_cpu(umac->umac_minor));
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2019-04-18 10:24:28 +03:00
|
|
|
iwl_fwrt_update_fw_versions(&mvm->fwrt, lmac1, umac);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-31 18:13:57 +03:00
|
|
|
static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
|
|
|
{
|
|
|
|
WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
|
|
|
|
struct iwl_rx_packet *pkt, void *data)
|
|
|
|
{
|
|
|
|
struct iwl_phy_db *phy_db = data;
|
|
|
|
|
|
|
|
if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) {
|
|
|
|
WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-10 16:02:12 +03:00
|
|
|
WARN_ON(iwl_phy_db_set_section(phy_db, pkt));
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-05 11:21:34 +02:00
|
|
|
static void iwl_mvm_print_pd_notification(struct iwl_mvm *mvm)
|
|
|
|
{
|
2022-05-17 12:05:10 +03:00
|
|
|
#define IWL_FW_PRINT_REG_INFO(reg_name) \
|
|
|
|
IWL_ERR(mvm, #reg_name ": 0x%x\n", iwl_read_umac_prph(trans, reg_name))
|
|
|
|
|
2022-02-05 11:21:34 +02:00
|
|
|
struct iwl_trans *trans = mvm->trans;
|
|
|
|
enum iwl_device_family device_family = trans->trans_cfg->device_family;
|
|
|
|
|
|
|
|
if (device_family < IWL_DEVICE_FAMILY_8000)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (device_family <= IWL_DEVICE_FAMILY_9000)
|
2022-05-17 12:05:10 +03:00
|
|
|
IWL_FW_PRINT_REG_INFO(WFPM_ARC1_PD_NOTIFICATION);
|
2022-02-05 11:21:34 +02:00
|
|
|
else
|
2022-05-17 12:05:10 +03:00
|
|
|
IWL_FW_PRINT_REG_INFO(WFPM_LMAC1_PD_NOTIFICATION);
|
2022-02-05 11:21:39 +02:00
|
|
|
|
2022-05-17 12:05:10 +03:00
|
|
|
IWL_FW_PRINT_REG_INFO(HPM_SECONDARY_DEVICE_STATE);
|
2022-02-05 11:21:39 +02:00
|
|
|
|
2022-05-17 12:05:10 +03:00
|
|
|
/* print OPT info */
|
|
|
|
IWL_FW_PRINT_REG_INFO(WFPM_MAC_OTP_CFG7_ADDR);
|
|
|
|
IWL_FW_PRINT_REG_INFO(WFPM_MAC_OTP_CFG7_DATA);
|
2022-02-05 11:21:34 +02:00
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
|
|
|
|
enum iwl_ucode_type ucode_type)
|
|
|
|
{
|
|
|
|
struct iwl_notification_wait alive_wait;
|
2018-11-05 11:07:58 +02:00
|
|
|
struct iwl_mvm_alive_data alive_data = {};
|
2013-01-24 14:25:36 +01:00
|
|
|
const struct fw_img *fw;
|
2018-08-21 15:23:39 +03:00
|
|
|
int ret;
|
2017-06-02 11:56:58 +02:00
|
|
|
enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
|
2020-09-30 19:19:55 +03:00
|
|
|
static const u16 alive_cmd[] = { UCODE_ALIVE_NTFY };
|
2019-05-29 16:39:50 +03:00
|
|
|
bool run_in_rfkill =
|
|
|
|
ucode_type == IWL_UCODE_INIT || iwl_mvm_has_unified_ucode(mvm);
|
2023-04-13 21:40:21 +03:00
|
|
|
u8 count;
|
|
|
|
struct iwl_pc_data *pc_data;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2014-12-01 17:40:37 +02:00
|
|
|
if (ucode_type == IWL_UCODE_REGULAR &&
|
2016-02-23 10:34:48 +02:00
|
|
|
iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) &&
|
|
|
|
!(fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED)))
|
2016-08-03 10:55:45 +03:00
|
|
|
fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER);
|
2014-12-01 17:40:37 +02:00
|
|
|
else
|
2016-08-03 10:55:45 +03:00
|
|
|
fw = iwl_get_ucode_image(mvm->fw, ucode_type);
|
2013-10-25 12:32:51 +02:00
|
|
|
if (WARN_ON(!fw))
|
2013-01-24 14:25:36 +01:00
|
|
|
return -EINVAL;
|
2017-06-02 11:56:58 +02:00
|
|
|
iwl_fw_set_current_image(&mvm->fwrt, ucode_type);
|
2017-03-22 22:10:36 +01:00
|
|
|
clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
|
|
|
|
alive_cmd, ARRAY_SIZE(alive_cmd),
|
|
|
|
iwl_alive_fn, &alive_data);
|
|
|
|
|
2019-05-29 16:39:50 +03:00
|
|
|
/*
|
|
|
|
* We want to load the INIT firmware even in RFKILL
|
|
|
|
* For the unified firmware case, the ucode_type is not
|
|
|
|
* INIT, but we still need to run it.
|
|
|
|
*/
|
|
|
|
ret = iwl_trans_start_fw(mvm->trans, fw, run_in_rfkill);
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret) {
|
2017-06-02 11:56:58 +02:00
|
|
|
iwl_fw_set_current_image(&mvm->fwrt, old_type);
|
2013-01-24 14:25:36 +01:00
|
|
|
iwl_remove_notification(&mvm->notif_wait, &alive_wait);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some things may run in the background now, but we
|
|
|
|
* just wait for the ALIVE notification here.
|
|
|
|
*/
|
|
|
|
ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait,
|
|
|
|
MVM_UCODE_ALIVE_TIMEOUT);
|
2022-11-23 23:02:05 +02:00
|
|
|
|
|
|
|
if (mvm->trans->trans_cfg->device_family ==
|
|
|
|
IWL_DEVICE_FAMILY_AX210) {
|
|
|
|
/* print these registers regardless of alive fail/success */
|
|
|
|
IWL_INFO(mvm, "WFPM_UMAC_PD_NOTIFICATION: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(mvm->trans, WFPM_ARC1_PD_NOTIFICATION));
|
|
|
|
IWL_INFO(mvm, "WFPM_LMAC2_PD_NOTIFICATION: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(mvm->trans, WFPM_LMAC2_PD_NOTIFICATION));
|
|
|
|
IWL_INFO(mvm, "WFPM_AUTH_KEY_0: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(mvm->trans, SB_MODIFY_CFG_FLAG));
|
2022-11-23 23:02:07 +02:00
|
|
|
IWL_INFO(mvm, "CNVI_SCU_SEQ_DATA_DW9: 0x%x\n",
|
|
|
|
iwl_read_prph(mvm->trans, CNVI_SCU_SEQ_DATA_DW9));
|
2022-11-23 23:02:05 +02:00
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret) {
|
2017-01-12 11:31:25 +02:00
|
|
|
struct iwl_trans *trans = mvm->trans;
|
|
|
|
|
2021-10-17 11:43:41 +03:00
|
|
|
/* SecBoot info */
|
2019-10-29 15:45:40 +01:00
|
|
|
if (trans->trans_cfg->device_family >=
|
|
|
|
IWL_DEVICE_FAMILY_22000) {
|
2017-01-12 11:31:25 +02:00
|
|
|
IWL_ERR(mvm,
|
|
|
|
"SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
|
2019-01-01 14:03:23 +02:00
|
|
|
iwl_read_umac_prph(trans, UMAG_SB_CPU_1_STATUS),
|
|
|
|
iwl_read_umac_prph(trans,
|
|
|
|
UMAG_SB_CPU_2_STATUS));
|
2021-10-17 11:43:41 +03:00
|
|
|
} else if (trans->trans_cfg->device_family >=
|
|
|
|
IWL_DEVICE_FAMILY_8000) {
|
|
|
|
IWL_ERR(mvm,
|
|
|
|
"SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
|
|
|
|
iwl_read_prph(trans, SB_CPU_1_STATUS),
|
|
|
|
iwl_read_prph(trans, SB_CPU_2_STATUS));
|
|
|
|
}
|
|
|
|
|
2022-02-05 11:21:34 +02:00
|
|
|
iwl_mvm_print_pd_notification(mvm);
|
|
|
|
|
2021-10-17 11:43:41 +03:00
|
|
|
/* LMAC/UMAC PC info */
|
|
|
|
if (trans->trans_cfg->device_family >=
|
2023-04-13 21:40:21 +03:00
|
|
|
IWL_DEVICE_FAMILY_22000) {
|
|
|
|
pc_data = trans->dbg.pc_data;
|
|
|
|
for (count = 0; count < trans->dbg.num_pc;
|
|
|
|
count++, pc_data++)
|
|
|
|
IWL_ERR(mvm, "%s: 0x%x\n",
|
|
|
|
pc_data->pc_name,
|
|
|
|
pc_data->pc_address);
|
|
|
|
} else if (trans->trans_cfg->device_family >=
|
2021-10-17 11:43:41 +03:00
|
|
|
IWL_DEVICE_FAMILY_9000) {
|
2019-10-29 15:45:40 +01:00
|
|
|
IWL_ERR(mvm, "UMAC PC: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(trans,
|
|
|
|
UREG_UMAC_CURRENT_PC));
|
|
|
|
IWL_ERR(mvm, "LMAC PC: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(trans,
|
|
|
|
UREG_LMAC1_CURRENT_PC));
|
|
|
|
if (iwl_mvm_is_cdb_supported(mvm))
|
|
|
|
IWL_ERR(mvm, "LMAC2 PC: 0x%x\n",
|
|
|
|
iwl_read_umac_prph(trans,
|
|
|
|
UREG_LMAC2_CURRENT_PC));
|
|
|
|
}
|
|
|
|
|
2022-11-23 23:02:07 +02:00
|
|
|
if (ret == -ETIMEDOUT && !mvm->pldr_sync)
|
2019-10-29 15:45:40 +01:00
|
|
|
iwl_fw_dbg_error_collect(&mvm->fwrt,
|
|
|
|
FW_DBG_TRIGGER_ALIVE_TIMEOUT);
|
|
|
|
|
2017-06-02 11:56:58 +02:00
|
|
|
iwl_fw_set_current_image(&mvm->fwrt, old_type);
|
2013-01-24 14:25:36 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alive_data.valid) {
|
|
|
|
IWL_ERR(mvm, "Loaded ucode is not valid!\n");
|
2017-06-02 11:56:58 +02:00
|
|
|
iwl_fw_set_current_image(&mvm->fwrt, old_type);
|
2013-01-24 14:25:36 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2022-11-23 23:02:09 +02:00
|
|
|
/* if reached this point, Alive notification was received */
|
|
|
|
iwl_mei_alive_notif(true);
|
2022-11-02 16:59:55 +02:00
|
|
|
|
2023-06-06 10:43:02 +03:00
|
|
|
ret = iwl_pnvm_load(mvm->trans, &mvm->notif_wait,
|
|
|
|
&mvm->fw->ucode_capa);
|
2020-10-08 18:09:40 +03:00
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Timeout waiting for PNVM load!\n");
|
|
|
|
iwl_fw_set_current_image(&mvm->fwrt, old_type);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: all the queues are enabled as part of the interface
|
|
|
|
* initialization, but in firmware restart scenarios they
|
|
|
|
* could be stopped, so wake them up. In firmware restart,
|
|
|
|
* mac80211 will have the queues stopped as well until the
|
|
|
|
* reconfiguration completes. During normal startup, they
|
|
|
|
* will be empty.
|
|
|
|
*/
|
|
|
|
|
2015-07-14 13:36:18 +03:00
|
|
|
memset(&mvm->queue_info, 0, sizeof(mvm->queue_info));
|
2018-07-04 11:58:28 +02:00
|
|
|
/*
|
|
|
|
* Set a 'fake' TID for the command queue, since we use the
|
|
|
|
* hweight() of the tid_bitmap as a refcount now. Not that
|
|
|
|
* we ever even consider the command queue as one we might
|
|
|
|
* want to reuse, but be safe nevertheless.
|
|
|
|
*/
|
|
|
|
mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].tid_bitmap =
|
|
|
|
BIT(IWL_MAX_TID_COUNT + 2);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2017-03-22 22:10:36 +01:00
|
|
|
set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
|
2018-05-03 10:17:05 +03:00
|
|
|
#ifdef CONFIG_IWLWIFI_DEBUGFS
|
|
|
|
iwl_fw_set_dbg_rec_on(&mvm->fwrt);
|
|
|
|
#endif
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2020-12-09 23:16:50 +02:00
|
|
|
/*
|
|
|
|
* All the BSSes in the BSS table include the GP2 in the system
|
|
|
|
* at the beacon Rx time, this is of course no longer relevant
|
|
|
|
* since we are resetting the firmware.
|
|
|
|
* Purge all the BSS table.
|
|
|
|
*/
|
|
|
|
cfg80211_bss_flush(mvm->hw->wiphy);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-18 11:08:47 +03:00
|
|
|
static void iwl_mvm_phy_filter_init(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_phy_specific_cfg *phy_filters)
|
|
|
|
{
|
2023-06-14 12:41:33 +03:00
|
|
|
#ifdef CONFIG_ACPI
|
|
|
|
*phy_filters = mvm->phy_filters;
|
2020-04-18 11:08:47 +03:00
|
|
|
#endif /* CONFIG_ACPI */
|
2023-06-14 12:41:33 +03:00
|
|
|
}
|
2020-04-18 11:08:47 +03:00
|
|
|
|
2023-10-22 17:55:50 +03:00
|
|
|
static void iwl_mvm_uats_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
u8 cmd_ver;
|
|
|
|
int ret;
|
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = WIDE_ID(REGULATORY_AND_NVM_GROUP,
|
2024-05-06 10:04:15 +03:00
|
|
|
MCC_ALLOWED_AP_TYPE_CMD),
|
2023-10-22 17:55:50 +03:00
|
|
|
.flags = 0,
|
|
|
|
.data[0] = &mvm->fwrt.uats_table,
|
|
|
|
.len[0] = sizeof(mvm->fwrt.uats_table),
|
|
|
|
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!(mvm->trans->trans_cfg->device_family >=
|
|
|
|
IWL_DEVICE_FAMILY_AX210)) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "UATS feature is not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mvm->fwrt.uats_enabled) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "UATS feature is disabled\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id,
|
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
|
|
|
if (cmd_ver != 1) {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
2024-05-06 10:04:15 +03:00
|
|
|
"MCC_ALLOWED_AP_TYPE_CMD ver %d not supported\n",
|
2023-10-22 17:55:50 +03:00
|
|
|
cmd_ver);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_uefi_get_uats_table(mvm->trans, &mvm->fwrt);
|
|
|
|
if (ret < 0) {
|
|
|
|
IWL_ERR(mvm, "failed to read UATS table (%d)\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd(mvm, &cmd);
|
|
|
|
if (ret < 0)
|
2024-05-06 10:04:15 +03:00
|
|
|
IWL_ERR(mvm, "failed to send MCC_ALLOWED_AP_TYPE_CMD (%d)\n",
|
|
|
|
ret);
|
2023-10-22 17:55:50 +03:00
|
|
|
else
|
2024-05-06 10:04:15 +03:00
|
|
|
IWL_DEBUG_RADIO(mvm, "MCC_ALLOWED_AP_TYPE_CMD sent to FW\n");
|
2023-10-22 17:55:50 +03:00
|
|
|
}
|
|
|
|
|
2021-12-04 17:49:37 +02:00
|
|
|
static int iwl_mvm_sgom_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
u8 cmd_ver;
|
|
|
|
int ret;
|
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = WIDE_ID(REGULATORY_AND_NVM_GROUP,
|
|
|
|
SAR_OFFSET_MAPPING_TABLE_CMD),
|
|
|
|
.flags = 0,
|
|
|
|
.data[0] = &mvm->fwrt.sgom_table,
|
|
|
|
.len[0] = sizeof(mvm->fwrt.sgom_table),
|
|
|
|
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!mvm->fwrt.sgom_enabled) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "SGOM table is disabled\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id,
|
2021-12-04 17:49:37 +02:00
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
|
|
|
|
|
|
|
if (cmd_ver != 2) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "command version is unsupported. version = %d\n",
|
|
|
|
cmd_ver);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd(mvm, &cmd);
|
|
|
|
if (ret < 0)
|
|
|
|
IWL_ERR(mvm, "failed to send SAR_OFFSET_MAPPING_CMD (%d)\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
|
|
|
|
{
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u32 cmd_id = PHY_CONFIGURATION_CMD;
|
2020-04-18 11:08:47 +03:00
|
|
|
struct iwl_phy_cfg_cmd_v3 phy_cfg_cmd;
|
2017-06-02 11:56:58 +02:00
|
|
|
enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img;
|
2020-04-18 11:08:47 +03:00
|
|
|
u8 cmd_ver;
|
|
|
|
size_t cmd_size;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2019-11-15 09:27:25 +02:00
|
|
|
if (iwl_mvm_has_unified_ucode(mvm) &&
|
2019-11-15 09:27:28 +02:00
|
|
|
!mvm->trans->cfg->tx_with_siso_diversity)
|
2019-11-15 09:27:25 +02:00
|
|
|
return 0;
|
2019-11-15 09:27:28 +02:00
|
|
|
|
|
|
|
if (mvm->trans->cfg->tx_with_siso_diversity) {
|
2019-11-15 09:27:25 +02:00
|
|
|
/*
|
|
|
|
* TODO: currently we don't set the antenna but letting the NIC
|
|
|
|
* to decide which antenna to use. This should come from BIOS.
|
|
|
|
*/
|
|
|
|
phy_cfg_cmd.phy_cfg =
|
|
|
|
cpu_to_le32(FW_PHY_CFG_CHAIN_SAD_ENABLED);
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/* Set parameters */
|
2014-12-08 21:13:14 +02:00
|
|
|
phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm));
|
2018-02-21 22:18:59 +02:00
|
|
|
|
|
|
|
/* set flags extra PHY configuration flags from the device's cfg */
|
2019-11-04 12:31:22 +02:00
|
|
|
phy_cfg_cmd.phy_cfg |=
|
|
|
|
cpu_to_le32(mvm->trans->trans_cfg->extra_phy_cfg_flags);
|
2018-02-21 22:18:59 +02:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
phy_cfg_cmd.calib_control.event_trigger =
|
|
|
|
mvm->fw->default_calib[ucode_type].event_trigger;
|
|
|
|
phy_cfg_cmd.calib_control.flow_trigger =
|
|
|
|
mvm->fw->default_calib[ucode_type].flow_trigger;
|
|
|
|
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
|
2020-09-28 12:23:18 +03:00
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
2023-06-14 12:41:33 +03:00
|
|
|
if (cmd_ver >= 3)
|
|
|
|
iwl_mvm_phy_filter_init(mvm, &phy_cfg_cmd.phy_specific_cfg);
|
2020-04-18 11:08:47 +03:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n",
|
|
|
|
phy_cfg_cmd.phy_cfg);
|
2020-04-18 11:08:47 +03:00
|
|
|
cmd_size = (cmd_ver == 3) ? sizeof(struct iwl_phy_cfg_cmd_v3) :
|
|
|
|
sizeof(struct iwl_phy_cfg_cmd_v1);
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, cmd_size, &phy_cfg_cmd);
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2023-04-13 10:44:11 +03:00
|
|
|
static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
struct iwl_notification_wait init_wait;
|
|
|
|
struct iwl_nvm_access_complete_cmd nvm_complete = {};
|
|
|
|
struct iwl_init_extended_cfg_cmd init_cfg = {
|
|
|
|
.init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)),
|
|
|
|
};
|
|
|
|
static const u16 init_complete[] = {
|
|
|
|
INIT_COMPLETE_NOTIF,
|
|
|
|
};
|
2023-09-13 14:56:43 +03:00
|
|
|
u32 sb_cfg;
|
2023-04-13 10:44:11 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (mvm->trans->cfg->tx_with_siso_diversity)
|
|
|
|
init_cfg.init_flags |= cpu_to_le32(BIT(IWL_INIT_PHY));
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
mvm->rfkill_safe_init_done = false;
|
|
|
|
|
2023-09-21 11:58:06 +03:00
|
|
|
if (mvm->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_AX210) {
|
|
|
|
sb_cfg = iwl_read_umac_prph(mvm->trans, SB_MODIFY_CFG_FLAG);
|
|
|
|
/* if needed, we'll reset this on our way out later */
|
2023-10-04 12:36:25 +03:00
|
|
|
mvm->pldr_sync = sb_cfg == SB_CFG_RESIDES_IN_ROM;
|
2023-09-21 11:58:06 +03:00
|
|
|
if (mvm->pldr_sync && iwl_mei_pldr_req())
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
2023-09-13 14:56:43 +03:00
|
|
|
|
2023-04-13 10:44:11 +03:00
|
|
|
iwl_init_notification_wait(&mvm->notif_wait,
|
|
|
|
&init_wait,
|
|
|
|
init_complete,
|
|
|
|
ARRAY_SIZE(init_complete),
|
|
|
|
iwl_wait_init_complete,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_EARLY, NULL);
|
|
|
|
|
|
|
|
/* Will also start the device */
|
|
|
|
ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
|
2023-09-13 14:56:43 +03:00
|
|
|
|
|
|
|
/* if we needed reset then fail here, but notify and remove */
|
|
|
|
if (mvm->pldr_sync) {
|
|
|
|
iwl_mei_alive_notif(false);
|
|
|
|
iwl_trans_pcie_remove(mvm->trans, true);
|
|
|
|
}
|
|
|
|
|
2023-04-13 10:44:11 +03:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_AFTER_ALIVE,
|
|
|
|
NULL);
|
|
|
|
|
2024-04-15 11:54:37 +03:00
|
|
|
if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ)
|
2024-01-23 20:08:14 +02:00
|
|
|
mvm->trans->step_urm = !!(iwl_read_umac_prph(mvm->trans,
|
|
|
|
CNVI_PMU_STEP_FLOW) &
|
|
|
|
CNVI_PMU_STEP_FLOW_FORCE_URM);
|
|
|
|
|
2023-04-13 10:44:11 +03:00
|
|
|
/* Send init config command to mark that we are sending NVM access
|
|
|
|
* commands
|
|
|
|
*/
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP,
|
|
|
|
INIT_EXTENDED_CFG_CMD),
|
|
|
|
CMD_SEND_IN_RFKILL,
|
|
|
|
sizeof(init_cfg), &init_cfg);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to run init config command: %d\n",
|
|
|
|
ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load NVM to NIC if needed */
|
|
|
|
if (mvm->nvm_file_name) {
|
|
|
|
ret = iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name,
|
|
|
|
mvm->nvm_sections);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
ret = iwl_mvm_load_nvm_to_nic(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IWL_MVM_PARSE_NVM && !mvm->nvm_data) {
|
|
|
|
ret = iwl_nvm_init(mvm);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP,
|
|
|
|
NVM_ACCESS_COMPLETE),
|
|
|
|
CMD_SEND_IN_RFKILL,
|
|
|
|
sizeof(nvm_complete), &nvm_complete);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to run complete NVM access: %d\n",
|
|
|
|
ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2023-04-13 10:44:12 +03:00
|
|
|
ret = iwl_send_phy_cfg_cmd(mvm);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to run PHY configuration: %d\n",
|
|
|
|
ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2023-04-13 10:44:11 +03:00
|
|
|
/* We wait for the INIT complete notification */
|
|
|
|
ret = iwl_wait_notification(&mvm->notif_wait, &init_wait,
|
|
|
|
MVM_UCODE_ALIVE_TIMEOUT);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Read the NVM only at driver load time, no need to do this twice */
|
|
|
|
if (!IWL_MVM_PARSE_NVM && !mvm->nvm_data) {
|
2023-09-21 11:57:59 +03:00
|
|
|
mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw,
|
|
|
|
mvm->set_tx_ant, mvm->set_rx_ant);
|
2023-04-13 10:44:11 +03:00
|
|
|
if (IS_ERR(mvm->nvm_data)) {
|
|
|
|
ret = PTR_ERR(mvm->nvm_data);
|
|
|
|
mvm->nvm_data = NULL;
|
|
|
|
IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mvm->rfkill_safe_init_done = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
iwl_remove_notification(&mvm->notif_wait, &init_wait);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-12-09 23:16:13 +02:00
|
|
|
int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
|
|
|
struct iwl_notification_wait calib_wait;
|
2015-07-13 14:50:47 +03:00
|
|
|
static const u16 init_complete[] = {
|
2013-01-24 14:25:36 +01:00
|
|
|
INIT_COMPLETE_NOTIF,
|
|
|
|
CALIB_RES_NOTIF_PHY_DB
|
|
|
|
};
|
|
|
|
int ret;
|
|
|
|
|
2017-06-08 09:18:22 +02:00
|
|
|
if (iwl_mvm_has_unified_ucode(mvm))
|
2020-12-09 23:16:19 +02:00
|
|
|
return iwl_run_unified_mvm_ucode(mvm);
|
2017-02-20 17:47:04 +01:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
2019-05-22 12:22:35 +03:00
|
|
|
mvm->rfkill_safe_init_done = false;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
iwl_init_notification_wait(&mvm->notif_wait,
|
|
|
|
&calib_wait,
|
|
|
|
init_complete,
|
|
|
|
ARRAY_SIZE(init_complete),
|
|
|
|
iwl_wait_phy_db_entry,
|
|
|
|
mvm->phy_db);
|
|
|
|
|
2021-02-05 11:06:37 +02:00
|
|
|
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_EARLY, NULL);
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/* Will also start the device */
|
|
|
|
ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret);
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
2019-07-12 15:52:39 +03:00
|
|
|
if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_8000) {
|
2017-05-29 14:01:06 +03:00
|
|
|
ret = iwl_mvm_send_bt_init_conf(mvm);
|
|
|
|
if (ret)
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2017-05-29 14:01:06 +03:00
|
|
|
}
|
2013-01-17 09:42:25 +02:00
|
|
|
|
2013-09-11 12:39:18 +02:00
|
|
|
/* Read the NVM only at driver load time, no need to do this twice */
|
2020-12-09 23:16:13 +02:00
|
|
|
if (!mvm->nvm_data) {
|
2017-08-15 18:46:44 +03:00
|
|
|
ret = iwl_nvm_init(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 12:39:18 +02:00
|
|
|
/* In case we read the NVM from external file, load it to the NIC */
|
2021-02-10 17:15:10 +02:00
|
|
|
if (mvm->nvm_file_name) {
|
|
|
|
ret = iwl_mvm_load_nvm_to_nic(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto remove_notif;
|
|
|
|
}
|
2013-09-11 12:39:18 +02:00
|
|
|
|
2018-08-16 09:23:08 +03:00
|
|
|
WARN_ONCE(mvm->nvm_data->nvm_version < mvm->trans->cfg->nvm_ver,
|
|
|
|
"Too old NVM version (0x%0x, required = 0x%0x)",
|
|
|
|
mvm->nvm_data->nvm_version, mvm->trans->cfg->nvm_ver);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-05-13 07:53:26 +03:00
|
|
|
/*
|
|
|
|
* abort after reading the nvm in case RF Kill is on, we will complete
|
|
|
|
* the init seq later when RF kill will switch to off
|
|
|
|
*/
|
2015-09-30 11:19:55 +03:00
|
|
|
if (iwl_mvm_is_radio_hw_killed(mvm)) {
|
2013-05-13 07:53:26 +03:00
|
|
|
IWL_DEBUG_RF_KILL(mvm,
|
|
|
|
"jump over all phy activities due to RF kill\n");
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2013-05-13 07:53:26 +03:00
|
|
|
}
|
|
|
|
|
2019-05-29 16:39:50 +03:00
|
|
|
mvm->rfkill_safe_init_done = true;
|
2014-11-02 15:48:09 +02:00
|
|
|
|
2013-02-27 23:00:27 +02:00
|
|
|
/* Send TX valid antennas before triggering calibrations */
|
2014-12-08 21:13:14 +02:00
|
|
|
ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
|
2013-02-27 23:00:27 +02:00
|
|
|
if (ret)
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2013-02-27 23:00:27 +02:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
ret = iwl_send_phy_cfg_cmd(mvm);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
|
|
|
|
ret);
|
2017-07-24 14:47:52 +03:00
|
|
|
goto remove_notif;
|
2013-01-24 14:25:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some things may run in the background now, but we
|
|
|
|
* just wait for the calibration complete notification.
|
|
|
|
*/
|
|
|
|
ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
|
2017-07-24 14:47:52 +03:00
|
|
|
MVM_UCODE_CALIB_TIMEOUT);
|
|
|
|
if (!ret)
|
|
|
|
goto out;
|
2014-11-02 15:48:09 +02:00
|
|
|
|
2017-07-24 14:47:52 +03:00
|
|
|
if (iwl_mvm_is_radio_hw_killed(mvm)) {
|
2014-11-02 15:48:09 +02:00
|
|
|
IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
|
2017-07-24 14:47:52 +03:00
|
|
|
ret = 0;
|
|
|
|
} else {
|
|
|
|
IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
|
|
|
|
ret);
|
2014-11-02 15:48:09 +02:00
|
|
|
}
|
2017-07-24 14:47:52 +03:00
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
goto out;
|
|
|
|
|
2017-07-24 14:47:52 +03:00
|
|
|
remove_notif:
|
2013-01-24 14:25:36 +01:00
|
|
|
iwl_remove_notification(&mvm->notif_wait, &calib_wait);
|
|
|
|
out:
|
2019-05-29 16:39:50 +03:00
|
|
|
mvm->rfkill_safe_init_done = false;
|
2013-11-24 19:10:46 +02:00
|
|
|
if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
|
2013-01-24 14:25:36 +01:00
|
|
|
/* we want to debug INIT and we have no NVM - fake */
|
|
|
|
mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
|
|
|
|
sizeof(struct ieee80211_channel) +
|
|
|
|
sizeof(struct ieee80211_rate),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!mvm->nvm_data)
|
|
|
|
return -ENOMEM;
|
|
|
|
mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
|
|
|
|
mvm->nvm_data->bands[0].n_channels = 1;
|
|
|
|
mvm->nvm_data->bands[0].n_bitrates = 1;
|
|
|
|
mvm->nvm_data->bands[0].bitrates =
|
2023-07-23 22:24:59 +02:00
|
|
|
(void *)(mvm->nvm_data->channels + 1);
|
2013-01-24 14:25:36 +01:00
|
|
|
mvm->nvm_data->bands[0].bitrates->hw_value = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-01-13 10:16:30 +02:00
|
|
|
static int iwl_mvm_config_ltr(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
struct iwl_ltr_config_cmd cmd = {
|
|
|
|
.flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!mvm->trans->ltr_enabled)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
|
|
|
|
sizeof(cmd), &cmd);
|
|
|
|
}
|
|
|
|
|
2017-01-11 23:36:30 +02:00
|
|
|
int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
|
2016-05-30 13:00:44 +03:00
|
|
|
{
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u32 cmd_id = REDUCE_TX_POWER_CMD;
|
2020-09-28 12:23:10 +03:00
|
|
|
struct iwl_dev_tx_power_cmd cmd = {
|
|
|
|
.common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
|
2020-04-24 19:46:58 +03:00
|
|
|
};
|
2020-09-28 12:23:11 +03:00
|
|
|
__le16 *per_chain;
|
2020-04-17 13:37:11 +03:00
|
|
|
int ret;
|
2019-11-15 09:28:11 +02:00
|
|
|
u16 len = 0;
|
2020-09-28 12:23:12 +03:00
|
|
|
u32 n_subbands;
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
|
2020-09-28 12:23:18 +03:00
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
2024-03-19 10:10:18 +02:00
|
|
|
if (cmd_ver >= 7) {
|
2022-03-04 13:21:18 +02:00
|
|
|
len = sizeof(cmd.v7);
|
|
|
|
n_subbands = IWL_NUM_SUB_BANDS_V2;
|
|
|
|
per_chain = cmd.v7.per_chain[0][0];
|
|
|
|
cmd.v7.flags = cpu_to_le32(mvm->fwrt.reduced_power_flags);
|
2024-03-19 10:10:18 +02:00
|
|
|
if (cmd_ver == 8)
|
|
|
|
len = sizeof(cmd.v8);
|
2022-03-04 13:21:18 +02:00
|
|
|
} else if (cmd_ver == 6) {
|
2020-09-28 12:23:12 +03:00
|
|
|
len = sizeof(cmd.v6);
|
|
|
|
n_subbands = IWL_NUM_SUB_BANDS_V2;
|
|
|
|
per_chain = cmd.v6.per_chain[0][0];
|
|
|
|
} else if (fw_has_api(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_API_REDUCE_TX_POWER)) {
|
2018-03-29 14:13:54 +03:00
|
|
|
len = sizeof(cmd.v5);
|
2021-03-31 12:14:47 +03:00
|
|
|
n_subbands = IWL_NUM_SUB_BANDS_V1;
|
2020-09-28 12:23:11 +03:00
|
|
|
per_chain = cmd.v5.per_chain[0][0];
|
|
|
|
} else if (fw_has_capa(&mvm->fw->ucode_capa,
|
2020-09-28 12:23:12 +03:00
|
|
|
IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) {
|
2020-09-28 12:23:10 +03:00
|
|
|
len = sizeof(cmd.v4);
|
2021-03-31 12:14:47 +03:00
|
|
|
n_subbands = IWL_NUM_SUB_BANDS_V1;
|
2020-09-28 12:23:11 +03:00
|
|
|
per_chain = cmd.v4.per_chain[0][0];
|
|
|
|
} else {
|
2020-09-28 12:23:10 +03:00
|
|
|
len = sizeof(cmd.v3);
|
2021-03-31 12:14:47 +03:00
|
|
|
n_subbands = IWL_NUM_SUB_BANDS_V1;
|
2020-09-28 12:23:11 +03:00
|
|
|
per_chain = cmd.v3.per_chain[0][0];
|
|
|
|
}
|
2016-06-29 00:38:40 +03:00
|
|
|
|
2020-09-28 12:23:10 +03:00
|
|
|
/* all structs have the same common part, add it */
|
|
|
|
len += sizeof(cmd.common);
|
2016-05-30 13:00:44 +03:00
|
|
|
|
2024-01-31 10:24:37 +02:00
|
|
|
ret = iwl_sar_fill_profile(&mvm->fwrt, per_chain,
|
|
|
|
IWL_NUM_CHAIN_TABLES,
|
|
|
|
n_subbands, prof_a, prof_b);
|
2020-04-17 13:37:11 +03:00
|
|
|
|
|
|
|
/* return on error or if the profile is disabled (positive number) */
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2021-11-12 08:28:12 +02:00
|
|
|
iwl_mei_set_power_limit(per_chain);
|
|
|
|
|
2017-01-11 23:36:30 +02:00
|
|
|
IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n");
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, len, &cmd);
|
2017-01-11 23:36:30 +02:00
|
|
|
}
|
|
|
|
|
2017-03-30 11:16:17 +03:00
|
|
|
int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)
|
|
|
|
{
|
2020-09-28 12:23:13 +03:00
|
|
|
union iwl_geo_tx_power_profiles_cmd geo_tx_cmd;
|
2020-09-26 00:30:51 +03:00
|
|
|
struct iwl_geo_tx_power_profiles_resp *resp;
|
2019-02-27 16:43:45 +02:00
|
|
|
u16 len;
|
2019-11-15 09:28:11 +02:00
|
|
|
int ret;
|
2022-01-28 15:34:24 +02:00
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = WIDE_ID(PHY_OPS_GROUP, PER_CHAIN_LIMIT_OFFSET_CMD),
|
|
|
|
.flags = CMD_WANT_SKB,
|
|
|
|
.data = { &geo_tx_cmd },
|
|
|
|
};
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id,
|
2020-09-28 12:23:18 +03:00
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
2019-02-27 16:43:45 +02:00
|
|
|
|
2020-09-28 12:23:13 +03:00
|
|
|
/* the ops field is at the same spot for all versions, so set in v1 */
|
|
|
|
geo_tx_cmd.v1.ops =
|
|
|
|
cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE);
|
|
|
|
|
2021-10-24 16:55:04 +03:00
|
|
|
if (cmd_ver == 5)
|
|
|
|
len = sizeof(geo_tx_cmd.v5);
|
|
|
|
else if (cmd_ver == 4)
|
|
|
|
len = sizeof(geo_tx_cmd.v4);
|
|
|
|
else if (cmd_ver == 3)
|
2020-09-28 12:23:14 +03:00
|
|
|
len = sizeof(geo_tx_cmd.v3);
|
|
|
|
else if (fw_has_api(&mvm->fwrt.fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_API_SAR_TABLE_VER))
|
2020-09-28 12:23:13 +03:00
|
|
|
len = sizeof(geo_tx_cmd.v2);
|
|
|
|
else
|
|
|
|
len = sizeof(geo_tx_cmd.v1);
|
2017-03-30 11:16:17 +03:00
|
|
|
|
2019-11-15 09:28:11 +02:00
|
|
|
if (!iwl_sar_geo_support(&mvm->fwrt))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2022-01-28 15:34:24 +02:00
|
|
|
cmd.len[0] = len;
|
2017-03-30 11:16:17 +03:00
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd(mvm, &cmd);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2020-09-26 00:30:51 +03:00
|
|
|
|
|
|
|
resp = (void *)cmd.resp_pkt->data;
|
|
|
|
ret = le32_to_cpu(resp->profile_idx);
|
|
|
|
|
2024-01-31 10:24:37 +02:00
|
|
|
if (WARN_ON(ret > BIOS_GEO_MAX_PROFILE_NUM))
|
2020-09-26 00:30:51 +03:00
|
|
|
ret = -EIO;
|
|
|
|
|
2017-03-30 11:16:17 +03:00
|
|
|
iwl_free_resp(&cmd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-01-19 12:00:46 +02:00
|
|
|
static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u32 cmd_id = WIDE_ID(PHY_OPS_GROUP, PER_CHAIN_LIMIT_OFFSET_CMD);
|
2020-09-28 12:23:13 +03:00
|
|
|
union iwl_geo_tx_power_profiles_cmd cmd;
|
2019-11-15 09:28:11 +02:00
|
|
|
u16 len;
|
2020-10-08 18:12:44 +03:00
|
|
|
u32 n_bands;
|
2021-10-24 16:55:04 +03:00
|
|
|
u32 n_profiles;
|
2024-01-31 10:24:38 +02:00
|
|
|
__le32 sk = cpu_to_le32(0);
|
2020-03-18 08:12:54 +02:00
|
|
|
int ret;
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
|
2020-09-28 12:23:18 +03:00
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
2017-01-19 12:00:46 +02:00
|
|
|
|
2020-10-08 18:12:44 +03:00
|
|
|
BUILD_BUG_ON(offsetof(struct iwl_geo_tx_power_profiles_cmd_v1, ops) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, ops) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, ops) !=
|
2021-10-24 16:55:04 +03:00
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, ops) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, ops) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v4, ops) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v4, ops) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v5, ops));
|
|
|
|
|
2020-09-28 12:23:13 +03:00
|
|
|
/* the ops field is at the same spot for all versions, so set in v1 */
|
|
|
|
cmd.v1.ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES);
|
2019-02-27 16:43:45 +02:00
|
|
|
|
2024-01-31 10:24:38 +02:00
|
|
|
/* Only set to South Korea if the table revision is 1 */
|
|
|
|
if (mvm->fwrt.geo_rev == 1)
|
|
|
|
sk = cpu_to_le32(1);
|
|
|
|
|
2021-10-24 16:55:04 +03:00
|
|
|
if (cmd_ver == 5) {
|
|
|
|
len = sizeof(cmd.v5);
|
|
|
|
n_bands = ARRAY_SIZE(cmd.v5.table[0]);
|
2024-01-31 10:24:37 +02:00
|
|
|
n_profiles = BIOS_GEO_MAX_PROFILE_NUM;
|
2024-01-31 10:24:38 +02:00
|
|
|
cmd.v5.table_revision = sk;
|
2021-10-24 16:55:04 +03:00
|
|
|
} else if (cmd_ver == 4) {
|
|
|
|
len = sizeof(cmd.v4);
|
|
|
|
n_bands = ARRAY_SIZE(cmd.v4.table[0]);
|
2024-01-31 10:24:37 +02:00
|
|
|
n_profiles = BIOS_GEO_MAX_PROFILE_NUM;
|
2024-01-31 10:24:38 +02:00
|
|
|
cmd.v4.table_revision = sk;
|
2021-10-24 16:55:04 +03:00
|
|
|
} else if (cmd_ver == 3) {
|
2020-09-28 12:23:14 +03:00
|
|
|
len = sizeof(cmd.v3);
|
2020-10-08 18:12:44 +03:00
|
|
|
n_bands = ARRAY_SIZE(cmd.v3.table[0]);
|
2024-01-31 10:24:37 +02:00
|
|
|
n_profiles = BIOS_GEO_MIN_PROFILE_NUM;
|
2024-01-31 10:24:38 +02:00
|
|
|
cmd.v3.table_revision = sk;
|
2020-09-28 12:23:14 +03:00
|
|
|
} else if (fw_has_api(&mvm->fwrt.fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_API_SAR_TABLE_VER)) {
|
2020-09-28 12:23:13 +03:00
|
|
|
len = sizeof(cmd.v2);
|
2020-10-08 18:12:44 +03:00
|
|
|
n_bands = ARRAY_SIZE(cmd.v2.table[0]);
|
2024-01-31 10:24:37 +02:00
|
|
|
n_profiles = BIOS_GEO_MIN_PROFILE_NUM;
|
2024-01-31 10:24:38 +02:00
|
|
|
cmd.v2.table_revision = sk;
|
2019-11-15 09:28:11 +02:00
|
|
|
} else {
|
2020-09-28 12:23:13 +03:00
|
|
|
len = sizeof(cmd.v1);
|
2020-10-08 18:12:44 +03:00
|
|
|
n_bands = ARRAY_SIZE(cmd.v1.table[0]);
|
2024-01-31 10:24:37 +02:00
|
|
|
n_profiles = BIOS_GEO_MIN_PROFILE_NUM;
|
2019-02-27 16:43:45 +02:00
|
|
|
}
|
|
|
|
|
2020-10-08 18:12:44 +03:00
|
|
|
BUILD_BUG_ON(offsetof(struct iwl_geo_tx_power_profiles_cmd_v1, table) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, table) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, table) !=
|
2021-10-24 16:55:04 +03:00
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, table) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, table) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v4, table) ||
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v4, table) !=
|
|
|
|
offsetof(struct iwl_geo_tx_power_profiles_cmd_v5, table));
|
2020-10-08 18:12:44 +03:00
|
|
|
/* the table is at the same position for all versions, so set use v1 */
|
2024-01-31 10:24:37 +02:00
|
|
|
ret = iwl_sar_geo_fill_table(&mvm->fwrt, &cmd.v1.table[0][0],
|
|
|
|
n_bands, n_profiles);
|
2020-10-08 18:12:44 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* It is a valid scenario to not support SAR, or miss wgds table,
|
|
|
|
* but in that case there is no need to send the command.
|
|
|
|
*/
|
|
|
|
if (ret)
|
|
|
|
return 0;
|
|
|
|
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
return iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, len, &cmd);
|
2019-06-16 13:18:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm)
|
|
|
|
{
|
2021-12-19 12:18:18 +02:00
|
|
|
union iwl_ppag_table_cmd cmd;
|
2022-03-04 13:21:28 +02:00
|
|
|
int ret, cmd_size;
|
2019-11-07 21:23:21 +02:00
|
|
|
|
2024-01-31 10:24:40 +02:00
|
|
|
ret = iwl_fill_ppag_table(&mvm->fwrt, &cmd, &cmd_size);
|
2022-03-22 17:39:43 +02:00
|
|
|
/* Not supporting PPAG table is a valid scenario */
|
2023-03-14 19:49:30 +02:00
|
|
|
if (ret < 0)
|
2022-03-22 17:39:43 +02:00
|
|
|
return 0;
|
2019-06-16 13:18:28 +03:00
|
|
|
|
2020-09-24 16:23:39 +03:00
|
|
|
IWL_DEBUG_RADIO(mvm, "Sending PER_PLATFORM_ANT_GAIN_CMD\n");
|
2019-06-16 13:18:28 +03:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP,
|
|
|
|
PER_PLATFORM_ANT_GAIN_CMD),
|
2021-12-19 12:18:18 +02:00
|
|
|
0, cmd_size, &cmd);
|
2019-06-16 13:18:28 +03:00
|
|
|
if (ret < 0)
|
|
|
|
IWL_ERR(mvm, "failed to send PER_PLATFORM_ANT_GAIN_CMD (%d)\n",
|
|
|
|
ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iwl_mvm_ppag_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
2021-08-05 14:21:56 +03:00
|
|
|
/* no need to read the table, done in INIT stage */
|
2024-01-31 10:24:41 +02:00
|
|
|
if (!(iwl_is_ppag_approved(&mvm->fwrt)))
|
2021-01-31 20:22:07 +02:00
|
|
|
return 0;
|
|
|
|
|
2019-06-16 13:18:28 +03:00
|
|
|
return iwl_mvm_ppag_send_cmd(mvm);
|
|
|
|
}
|
|
|
|
|
2021-12-19 13:28:28 +02:00
|
|
|
static bool iwl_mvm_add_to_tas_block_list(__le32 *list, __le32 *le_size, unsigned int mcc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u32 size = le32_to_cpu(*le_size);
|
|
|
|
|
|
|
|
/* Verify that there is room for another country */
|
2024-01-31 10:24:45 +02:00
|
|
|
if (size >= IWL_WTAS_BLACK_LIST_MAX)
|
2021-12-19 13:28:28 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (list[i] == cpu_to_le32(mcc))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
list[size++] = cpu_to_le32(mcc);
|
|
|
|
*le_size = cpu_to_le32(size);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-18 11:08:50 +03:00
|
|
|
static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
u32 cmd_id = WIDE_ID(REGULATORY_AND_NVM_GROUP, TAS_CONFIG);
|
2020-04-18 11:08:50 +03:00
|
|
|
int ret;
|
2024-01-31 10:24:46 +02:00
|
|
|
struct iwl_tas_data data = {};
|
|
|
|
struct iwl_tas_config_cmd cmd = {};
|
2022-01-28 15:34:22 +02:00
|
|
|
int cmd_size, fw_ver;
|
2020-04-18 11:08:50 +03:00
|
|
|
|
2024-01-31 10:24:46 +02:00
|
|
|
BUILD_BUG_ON(ARRAY_SIZE(data.block_list_array) !=
|
|
|
|
IWL_WTAS_BLACK_LIST_MAX);
|
|
|
|
BUILD_BUG_ON(ARRAY_SIZE(cmd.common.block_list_array) !=
|
2024-01-31 10:24:45 +02:00
|
|
|
IWL_WTAS_BLACK_LIST_MAX);
|
2020-04-18 11:08:50 +03:00
|
|
|
|
|
|
|
if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TAS_CFG)) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "TAS not enabled in FW\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-31 10:24:47 +02:00
|
|
|
ret = iwl_bios_get_tas_table(&mvm->fwrt, &data);
|
2020-04-18 11:08:50 +03:00
|
|
|
if (ret < 0) {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"TAS table invalid or unavailable. (%d)\n",
|
|
|
|
ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-10 09:06:15 +02:00
|
|
|
if (ret == 0)
|
2020-04-18 11:08:50 +03:00
|
|
|
return;
|
|
|
|
|
2024-01-31 10:24:45 +02:00
|
|
|
if (!iwl_is_tas_approved()) {
|
2021-12-19 13:28:28 +02:00
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"System vendor '%s' is not in the approved list, disabling TAS in US and Canada.\n",
|
2024-02-04 10:56:27 +01:00
|
|
|
dmi_get_system_info(DMI_SYS_VENDOR) ?: "<unknown>");
|
2024-01-31 10:24:46 +02:00
|
|
|
if ((!iwl_mvm_add_to_tas_block_list(data.block_list_array,
|
|
|
|
&data.block_list_size,
|
|
|
|
IWL_MCC_US)) ||
|
|
|
|
(!iwl_mvm_add_to_tas_block_list(data.block_list_array,
|
|
|
|
&data.block_list_size,
|
|
|
|
IWL_MCC_CANADA))) {
|
2021-12-19 13:28:28 +02:00
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"Unable to add US/Canada to TAS block list, disabling TAS\n");
|
|
|
|
return;
|
|
|
|
}
|
2023-05-31 19:49:54 +03:00
|
|
|
} else {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"System vendor '%s' is in the approved list.\n",
|
2024-02-04 10:56:27 +01:00
|
|
|
dmi_get_system_info(DMI_SYS_VENDOR) ?: "<unknown>");
|
2021-12-19 13:28:28 +02:00
|
|
|
}
|
|
|
|
|
2024-01-31 10:24:46 +02:00
|
|
|
fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
|
|
|
|
IWL_FW_CMD_VER_UNKNOWN);
|
|
|
|
|
|
|
|
memcpy(&cmd.common, &data, sizeof(struct iwl_tas_config_cmd_common));
|
|
|
|
|
|
|
|
/* Set v3 or v4 specific parts. will be trunctated for fw_ver < 3 */
|
|
|
|
if (fw_ver == 4) {
|
|
|
|
cmd.v4.override_tas_iec = data.override_tas_iec;
|
|
|
|
cmd.v4.enable_tas_iec = data.enable_tas_iec;
|
|
|
|
cmd.v4.usa_tas_uhb_allowed = data.usa_tas_uhb_allowed;
|
|
|
|
} else {
|
|
|
|
cmd.v3.override_tas_iec = cpu_to_le16(data.override_tas_iec);
|
|
|
|
cmd.v3.enable_tas_iec = cpu_to_le16(data.enable_tas_iec);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_size = sizeof(struct iwl_tas_config_cmd_common);
|
|
|
|
if (fw_ver >= 3)
|
|
|
|
/* v4 is the same size as v3 */
|
|
|
|
cmd_size += sizeof(struct iwl_tas_config_cmd_v3);
|
2020-04-18 11:08:50 +03:00
|
|
|
|
iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.
This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.
Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:
@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}
@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)
@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2022-01-28 15:34:25 +02:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, cmd_size, &cmd);
|
2020-04-18 11:08:50 +03:00
|
|
|
if (ret < 0)
|
|
|
|
IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret);
|
|
|
|
}
|
2020-05-29 09:39:25 +03:00
|
|
|
|
2024-02-01 16:17:33 +02:00
|
|
|
static bool iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm)
|
2021-02-10 17:15:04 +02:00
|
|
|
{
|
wifi: iwlwifi: simplify getting DSM from ACPI
As DSMs are going to be read from UEFI too, we need a unified API
to get DSMs for both ACPI and UEFI.
The difference in getting DSM in each one of these methods (ACPI, UEFI)
is in the GUID, revision (0 for ACPI, 4 for UEFI), and size of the DSM
values (8 or 32 for ACPI, 32 for UEFI).
Therefore, change the iwl_acpi_get_dsm_x() to iwl_acpi_get_dsm() which
determines the GUID, revision (these two are the same for all WiFi DSMs),
and size (based on a func-to-size mapping) internally.
While at it, fix DSM_FUNC_RFI_CONFIG to expect a 32-bit value
(as defined in Intel BIOS spec) and not a 8-bit one.
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.1bcd7072a7a5.I344ee0a11abbc27da0c693187d1b8bee653aaeef@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2024-02-01 16:17:35 +02:00
|
|
|
u32 value = 0;
|
2024-02-01 16:17:33 +02:00
|
|
|
/* default behaviour is disabled */
|
|
|
|
bool bios_enable_rfi = false;
|
2024-02-01 16:17:37 +02:00
|
|
|
int ret = iwl_bios_get_dsm(&mvm->fwrt, DSM_FUNC_RFI_CONFIG, &value);
|
wifi: iwlwifi: simplify getting DSM from ACPI
As DSMs are going to be read from UEFI too, we need a unified API
to get DSMs for both ACPI and UEFI.
The difference in getting DSM in each one of these methods (ACPI, UEFI)
is in the GUID, revision (0 for ACPI, 4 for UEFI), and size of the DSM
values (8 or 32 for ACPI, 32 for UEFI).
Therefore, change the iwl_acpi_get_dsm_x() to iwl_acpi_get_dsm() which
determines the GUID, revision (these two are the same for all WiFi DSMs),
and size (based on a func-to-size mapping) internally.
While at it, fix DSM_FUNC_RFI_CONFIG to expect a 32-bit value
(as defined in Intel BIOS spec) and not a 8-bit one.
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.1bcd7072a7a5.I344ee0a11abbc27da0c693187d1b8bee653aaeef@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2024-02-01 16:17:35 +02:00
|
|
|
|
2021-02-10 17:15:04 +02:00
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "Failed to get DSM RFI, ret=%d\n", ret);
|
2024-02-01 16:17:33 +02:00
|
|
|
return bios_enable_rfi;
|
|
|
|
}
|
2021-02-10 17:15:04 +02:00
|
|
|
|
2024-02-01 16:17:33 +02:00
|
|
|
value &= DSM_VALUE_RFI_DISABLE;
|
|
|
|
/* RFI BIOS CONFIG value can be 0 or 3 only.
|
|
|
|
* i.e 0 means DDR and DLVR enabled. 3 means DDR and DLVR disabled.
|
|
|
|
* 1 and 2 are invalid BIOS configurations, So, it's not possible to
|
|
|
|
* disable ddr/dlvr separately.
|
|
|
|
*/
|
|
|
|
if (!value) {
|
2021-02-10 17:15:04 +02:00
|
|
|
IWL_DEBUG_RADIO(mvm, "DSM RFI is evaluated to enable\n");
|
2024-02-01 16:17:33 +02:00
|
|
|
bios_enable_rfi = true;
|
|
|
|
} else if (value == DSM_VALUE_RFI_DISABLE) {
|
|
|
|
IWL_DEBUG_RADIO(mvm, "DSM RFI is evaluated to disable\n");
|
|
|
|
} else {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"DSM RFI got invalid value, value=%d\n", value);
|
2021-02-10 17:15:04 +02:00
|
|
|
}
|
|
|
|
|
2024-02-01 16:17:33 +02:00
|
|
|
return bios_enable_rfi;
|
2021-02-10 17:15:04 +02:00
|
|
|
}
|
|
|
|
|
2020-05-29 09:39:25 +03:00
|
|
|
static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
|
|
|
|
{
|
2024-04-15 11:54:42 +03:00
|
|
|
struct iwl_lari_config_change_cmd cmd;
|
2024-04-15 11:54:40 +03:00
|
|
|
size_t cmd_size;
|
2024-04-15 11:54:42 +03:00
|
|
|
int ret;
|
2021-06-17 10:08:52 +03:00
|
|
|
|
2024-04-15 11:54:40 +03:00
|
|
|
ret = iwl_fill_lari_config(&mvm->fwrt, &cmd, &cmd_size);
|
2023-10-11 13:07:31 +03:00
|
|
|
if (!ret) {
|
2021-06-12 14:32:34 +03:00
|
|
|
ret = iwl_mvm_send_cmd_pdu(mvm,
|
|
|
|
WIDE_ID(REGULATORY_AND_NVM_GROUP,
|
|
|
|
LARI_CONFIG_CHANGE),
|
|
|
|
0, cmd_size, &cmd);
|
|
|
|
if (ret < 0)
|
2020-05-29 09:39:25 +03:00
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"Failed to send LARI_CONFIG_CHANGE (%d)\n",
|
2021-06-12 14:32:34 +03:00
|
|
|
ret);
|
2020-05-29 09:39:25 +03:00
|
|
|
}
|
2023-10-22 17:55:50 +03:00
|
|
|
|
|
|
|
if (le32_to_cpu(cmd.oem_uhb_allow_bitmap) & IWL_UATS_VLP_AP_SUPPORTED ||
|
|
|
|
le32_to_cpu(cmd.oem_uhb_allow_bitmap) & IWL_UATS_AFC_AP_SUPPORTED)
|
2024-02-08 18:58:40 +02:00
|
|
|
mvm->fwrt.uats_enabled = true;
|
2020-05-29 09:39:25 +03:00
|
|
|
}
|
2021-08-05 14:21:56 +03:00
|
|
|
|
2024-01-31 10:24:39 +02:00
|
|
|
void iwl_mvm_get_bios_tables(struct iwl_mvm *mvm)
|
2021-08-05 14:21:56 +03:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2024-01-28 08:53:59 +02:00
|
|
|
iwl_acpi_get_guid_lock_status(&mvm->fwrt);
|
|
|
|
|
2021-08-05 14:21:56 +03:00
|
|
|
/* read PPAG table */
|
2024-01-31 10:24:43 +02:00
|
|
|
ret = iwl_bios_get_ppag_table(&mvm->fwrt);
|
2021-08-05 14:21:56 +03:00
|
|
|
if (ret < 0) {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"PPAG BIOS table invalid or unavailable. (%d)\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read SAR tables */
|
2024-01-31 10:24:39 +02:00
|
|
|
ret = iwl_bios_get_wrds_table(&mvm->fwrt);
|
2021-08-05 14:21:56 +03:00
|
|
|
if (ret < 0) {
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"WRDS SAR BIOS table invalid or unavailable. (%d)\n",
|
|
|
|
ret);
|
|
|
|
/*
|
|
|
|
* If not available, don't fail and don't bother with EWRD and
|
|
|
|
* WGDS */
|
|
|
|
|
2024-01-31 10:24:39 +02:00
|
|
|
if (!iwl_bios_get_wgds_table(&mvm->fwrt)) {
|
2021-08-05 14:21:56 +03:00
|
|
|
/*
|
|
|
|
* If basic SAR is not available, we check for WGDS,
|
|
|
|
* which should *not* be available either. If it is
|
|
|
|
* available, issue an error, because we can't use SAR
|
|
|
|
* Geo without basic SAR.
|
|
|
|
*/
|
|
|
|
IWL_ERR(mvm, "BIOS contains WGDS but no WRDS\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2024-01-31 10:24:39 +02:00
|
|
|
ret = iwl_bios_get_ewrd_table(&mvm->fwrt);
|
2021-08-05 14:21:56 +03:00
|
|
|
/* if EWRD is not available, we can still use
|
|
|
|
* WRDS, so don't fail */
|
|
|
|
if (ret < 0)
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"EWRD SAR BIOS table invalid or unavailable. (%d)\n",
|
|
|
|
ret);
|
|
|
|
|
|
|
|
/* read geo SAR table */
|
|
|
|
if (iwl_sar_geo_support(&mvm->fwrt)) {
|
2024-01-31 10:24:39 +02:00
|
|
|
ret = iwl_bios_get_wgds_table(&mvm->fwrt);
|
2021-08-05 14:21:56 +03:00
|
|
|
if (ret < 0)
|
|
|
|
IWL_DEBUG_RADIO(mvm,
|
|
|
|
"Geo SAR BIOS table invalid or unavailable. (%d)\n",
|
|
|
|
ret);
|
|
|
|
/* we don't fail if the table is not available */
|
|
|
|
}
|
|
|
|
}
|
2023-06-14 12:41:33 +03:00
|
|
|
|
|
|
|
iwl_acpi_get_phy_filters(&mvm->fwrt, &mvm->phy_filters);
|
2024-02-01 16:17:32 +02:00
|
|
|
|
|
|
|
if (iwl_bios_get_eckv(&mvm->fwrt, &mvm->ext_clock_valid))
|
|
|
|
IWL_DEBUG_RADIO(mvm, "ECKV table doesn't exist in BIOS\n");
|
2021-08-05 14:21:56 +03:00
|
|
|
}
|
2017-01-12 12:43:12 +02:00
|
|
|
|
2024-01-28 08:53:56 +02:00
|
|
|
static void iwl_mvm_disconnect_iterator(void *data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
if (vif->type == NL80211_IFTYPE_STATION)
|
|
|
|
ieee80211_hw_restart_disconnect(vif);
|
|
|
|
}
|
|
|
|
|
2018-12-13 23:04:51 +02:00
|
|
|
void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags)
|
|
|
|
{
|
|
|
|
u32 error_log_size = mvm->fw->ucode_capa.error_log_size;
|
|
|
|
int ret;
|
|
|
|
u32 resp;
|
|
|
|
|
|
|
|
struct iwl_fw_error_recovery_cmd recovery_cmd = {
|
|
|
|
.flags = cpu_to_le32(flags),
|
|
|
|
.buf_size = 0,
|
|
|
|
};
|
|
|
|
struct iwl_host_cmd host_cmd = {
|
|
|
|
.id = WIDE_ID(SYSTEM_GROUP, FW_ERROR_RECOVERY_CMD),
|
|
|
|
.flags = CMD_WANT_SKB,
|
|
|
|
.data = {&recovery_cmd, },
|
|
|
|
.len = {sizeof(recovery_cmd), },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* no error log was defined in TLV */
|
|
|
|
if (!error_log_size)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (flags & ERROR_RECOVERY_UPDATE_DB) {
|
|
|
|
/* no buf was allocated while HW reset */
|
|
|
|
if (!mvm->error_recovery_buf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
host_cmd.data[1] = mvm->error_recovery_buf;
|
|
|
|
host_cmd.len[1] = error_log_size;
|
|
|
|
host_cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY;
|
|
|
|
recovery_cmd.buf_size = cpu_to_le32(error_log_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = iwl_mvm_send_cmd(mvm, &host_cmd);
|
|
|
|
kfree(mvm->error_recovery_buf);
|
|
|
|
mvm->error_recovery_buf = NULL;
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to send recovery cmd %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skb respond is only relevant in ERROR_RECOVERY_UPDATE_DB */
|
|
|
|
if (flags & ERROR_RECOVERY_UPDATE_DB) {
|
|
|
|
resp = le32_to_cpu(*(__le32 *)host_cmd.resp_pkt->data);
|
2024-01-28 08:53:56 +02:00
|
|
|
if (resp) {
|
2018-12-13 23:04:51 +02:00
|
|
|
IWL_ERR(mvm,
|
|
|
|
"Failed to send recovery cmd blob was invalid %d\n",
|
|
|
|
resp);
|
2024-01-28 08:53:56 +02:00
|
|
|
|
|
|
|
ieee80211_iterate_interfaces(mvm->hw, 0,
|
|
|
|
iwl_mvm_disconnect_iterator,
|
|
|
|
mvm);
|
|
|
|
}
|
2018-12-13 23:04:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-11 23:36:30 +02:00
|
|
|
static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
|
|
|
|
{
|
2020-04-17 13:37:11 +03:00
|
|
|
return iwl_mvm_sar_select_profile(mvm, 1, 1);
|
2016-05-30 13:00:44 +03:00
|
|
|
}
|
|
|
|
|
2016-08-31 18:13:57 +03:00
|
|
|
static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
|
2013-01-24 14:25:36 +01:00
|
|
|
{
|
2016-08-31 18:13:57 +03:00
|
|
|
int ret;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2017-06-08 09:18:22 +02:00
|
|
|
if (iwl_mvm_has_unified_ucode(mvm))
|
2020-12-09 23:16:19 +02:00
|
|
|
return iwl_run_unified_mvm_ucode(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2020-12-09 23:16:13 +02:00
|
|
|
ret = iwl_run_init_mvm_ucode(mvm);
|
2016-08-31 14:13:53 +03:00
|
|
|
|
|
|
|
if (ret) {
|
2015-04-27 10:29:31 +03:00
|
|
|
IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
|
2017-11-23 10:29:04 +02:00
|
|
|
|
|
|
|
if (iwlmvm_mod_params.init_dbg)
|
|
|
|
return 0;
|
2016-08-31 18:13:57 +03:00
|
|
|
return ret;
|
2015-04-27 10:29:31 +03:00
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2019-05-22 13:47:29 +03:00
|
|
|
iwl_fw_dbg_stop_sync(&mvm->fwrt);
|
2019-06-06 14:56:14 +03:00
|
|
|
iwl_trans_stop_device(mvm->trans);
|
|
|
|
ret = iwl_trans_start_hw(mvm->trans);
|
2016-08-31 14:13:53 +03:00
|
|
|
if (ret)
|
2016-08-31 18:13:57 +03:00
|
|
|
return ret;
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2019-05-22 12:22:35 +03:00
|
|
|
mvm->rfkill_safe_init_done = false;
|
2013-01-24 14:25:36 +01:00
|
|
|
ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
|
2016-08-31 18:13:57 +03:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-05-22 12:22:35 +03:00
|
|
|
mvm->rfkill_safe_init_done = true;
|
|
|
|
|
2019-07-22 13:04:16 +03:00
|
|
|
iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_AFTER_ALIVE,
|
|
|
|
NULL);
|
2018-06-13 15:22:48 +03:00
|
|
|
|
2017-06-02 11:56:58 +02:00
|
|
|
return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img);
|
2016-08-31 18:13:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_mvm_up(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
int ret, i;
|
2019-07-04 14:34:54 +03:00
|
|
|
struct ieee80211_supported_band *sband = NULL;
|
2016-08-31 18:13:57 +03:00
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
ret = iwl_trans_start_hw(mvm->trans);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2022-11-02 16:59:55 +02:00
|
|
|
|
2016-08-31 18:13:57 +03:00
|
|
|
ret = iwl_mvm_load_rt_fw(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
|
2022-11-23 23:02:07 +02:00
|
|
|
if (ret != -ERFKILL && !mvm->pldr_sync)
|
2019-03-25 14:11:52 +01:00
|
|
|
iwl_fw_dbg_error_collect(&mvm->fwrt,
|
|
|
|
FW_DBG_TRIGGER_DRIVER);
|
2013-01-24 14:25:36 +01:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2022-11-23 23:02:07 +02:00
|
|
|
/* FW loaded successfully */
|
|
|
|
mvm->pldr_sync = false;
|
|
|
|
|
2023-09-13 14:56:41 +03:00
|
|
|
iwl_fw_disable_dbg_asserts(&mvm->fwrt);
|
2017-06-01 14:44:40 +02:00
|
|
|
iwl_get_shared_mem_conf(&mvm->fwrt);
|
2014-12-15 17:54:16 +02:00
|
|
|
|
2013-10-06 13:03:32 +02:00
|
|
|
ret = iwl_mvm_sf_update(mvm, NULL, false);
|
|
|
|
if (ret)
|
|
|
|
IWL_ERR(mvm, "Failed to initialize Smart Fifo\n");
|
|
|
|
|
2019-06-30 09:31:22 +03:00
|
|
|
if (!iwl_trans_dbg_ini_valid(mvm->trans)) {
|
2018-06-13 15:24:13 +03:00
|
|
|
mvm->fwrt.dump.conf = FW_DBG_INVALID;
|
|
|
|
/* if we have a destination, assume EARLY START */
|
|
|
|
if (mvm->fw->dbg.dest_tlv)
|
|
|
|
mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE;
|
|
|
|
iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE);
|
|
|
|
}
|
2014-11-17 11:36:21 +02:00
|
|
|
|
2014-12-08 21:13:14 +02:00
|
|
|
ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
2017-06-08 09:18:22 +02:00
|
|
|
if (!iwl_mvm_has_unified_ucode(mvm)) {
|
|
|
|
/* Send phy db control command and then phy db calibration */
|
2016-08-31 18:13:57 +03:00
|
|
|
ret = iwl_send_phy_db_data(mvm->phy_db);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2023-04-13 10:44:12 +03:00
|
|
|
ret = iwl_send_phy_cfg_cmd(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2016-08-31 18:13:57 +03:00
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2017-05-29 14:01:06 +03:00
|
|
|
ret = iwl_mvm_send_bt_init_conf(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
2016-09-20 17:48:25 +03:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa,
|
|
|
|
IWL_UCODE_TLV_CAPA_SOC_LATENCY_SUPPORT)) {
|
2020-04-24 19:47:00 +03:00
|
|
|
ret = iwl_set_soc_latency(&mvm->fwrt);
|
2016-09-20 17:48:25 +03:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2023-06-20 13:03:58 +03:00
|
|
|
iwl_mvm_lari_cfg(mvm);
|
|
|
|
|
2015-12-31 11:49:18 +02:00
|
|
|
/* Init RSS configuration */
|
2021-03-31 12:14:49 +03:00
|
|
|
ret = iwl_configure_rxq(&mvm->fwrt);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2018-02-05 12:42:44 +02:00
|
|
|
|
|
|
|
if (iwl_mvm_has_new_rx_api(mvm)) {
|
2015-12-31 11:49:18 +02:00
|
|
|
ret = iwl_send_rss_cfg_cmd(mvm);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to configure RSS queues: %d\n",
|
|
|
|
ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 14:25:36 +01:00
|
|
|
/* init the fw <-> mac80211 STA mapping */
|
2023-03-29 10:05:21 +03:00
|
|
|
for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
|
2013-01-24 14:25:36 +01:00
|
|
|
RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
|
2023-03-29 10:05:21 +03:00
|
|
|
RCU_INIT_POINTER(mvm->fw_id_to_link_sta[i], NULL);
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2023-05-24 20:41:59 +03:00
|
|
|
for (i = 0; i < IWL_MVM_FW_MAX_LINK_ID + 1; i++)
|
|
|
|
RCU_INIT_POINTER(mvm->link_id_to_link_conf[i], NULL);
|
|
|
|
|
2023-03-28 10:59:06 +03:00
|
|
|
memset(&mvm->fw_link_ids_map, 0, sizeof(mvm->fw_link_ids_map));
|
|
|
|
|
2017-01-04 14:53:58 +02:00
|
|
|
mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA;
|
2014-10-23 18:03:10 +03:00
|
|
|
|
2014-09-08 16:42:54 +02:00
|
|
|
/* reset quota debouncing buffer - 0xff will yield invalid data */
|
|
|
|
memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd));
|
|
|
|
|
2019-05-14 17:19:06 +03:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_DQA_SUPPORT)) {
|
|
|
|
ret = iwl_mvm_send_dqa_cmd(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2015-08-31 14:33:23 +03:00
|
|
|
|
2020-10-08 18:09:47 +03:00
|
|
|
/*
|
|
|
|
* Add auxiliary station for scanning.
|
|
|
|
* Newer versions of this command implies that the fw uses
|
|
|
|
* internal aux station for all aux activities that don't
|
|
|
|
* requires a dedicated data queue.
|
|
|
|
*/
|
2023-06-13 15:57:23 +03:00
|
|
|
if (!iwl_mvm_has_new_station_api(mvm->fw)) {
|
2020-10-08 18:09:47 +03:00
|
|
|
/*
|
|
|
|
* In old version the aux station uses mac id like other
|
|
|
|
* station and not lmac id
|
|
|
|
*/
|
|
|
|
ret = iwl_mvm_add_aux_sta(mvm, MAC_INDEX_AUX);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2013-04-28 11:55:08 +03:00
|
|
|
/* Add all the PHY contexts */
|
2019-07-04 14:34:54 +03:00
|
|
|
i = 0;
|
|
|
|
while (!sband && i < NUM_NL80211_BANDS)
|
|
|
|
sband = mvm->hw->wiphy->bands[i++];
|
|
|
|
|
2021-08-16 21:39:30 +03:00
|
|
|
if (WARN_ON_ONCE(!sband)) {
|
|
|
|
ret = -ENODEV;
|
2019-07-04 14:34:54 +03:00
|
|
|
goto error;
|
2021-08-16 21:39:30 +03:00
|
|
|
}
|
2019-07-04 14:34:54 +03:00
|
|
|
|
2015-12-29 09:54:49 +02:00
|
|
|
if (iwl_mvm_is_tt_in_fw(mvm)) {
|
|
|
|
/* in order to give the responsibility of ct-kill and
|
|
|
|
* TX backoff to FW we need to send empty temperature reporting
|
|
|
|
* cmd during init time
|
|
|
|
*/
|
|
|
|
iwl_mvm_send_temp_report_ths_cmd(mvm);
|
|
|
|
} else {
|
|
|
|
/* Initialize tx backoffs to the minimal possible */
|
|
|
|
iwl_mvm_tt_tx_backoff(mvm, 0);
|
|
|
|
}
|
2016-01-05 10:34:47 +02:00
|
|
|
|
2019-06-11 15:38:13 +02:00
|
|
|
#ifdef CONFIG_THERMAL
|
2016-01-05 10:34:47 +02:00
|
|
|
/* TODO: read the budget from BIOS / Platform NVM */
|
2017-07-09 16:35:14 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In case there is no budget from BIOS / Platform NVM the default
|
|
|
|
* budget should be 2000mW (cooling state 0).
|
|
|
|
*/
|
|
|
|
if (iwl_mvm_is_ctdp_supported(mvm)) {
|
2016-01-05 10:34:47 +02:00
|
|
|
ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
|
|
|
|
mvm->cooling_dev.cur_state);
|
2016-09-14 11:54:36 +03:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2015-12-29 09:54:49 +02:00
|
|
|
#endif
|
2014-01-16 21:12:02 -05:00
|
|
|
|
2019-05-22 13:49:18 +03:00
|
|
|
if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2))
|
|
|
|
WARN_ON(iwl_mvm_config_ltr(mvm));
|
2014-09-23 23:02:41 +03:00
|
|
|
|
2014-01-28 10:17:18 +02:00
|
|
|
ret = iwl_mvm_power_update_device(mvm);
|
2013-09-03 14:18:03 +03:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
2015-03-04 15:08:00 +02:00
|
|
|
/*
|
|
|
|
* RTNL is not taken during Ct-kill, but we don't need to scan/Tx
|
|
|
|
* anyway, so don't init MCC.
|
|
|
|
*/
|
|
|
|
if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) {
|
|
|
|
ret = iwl_mvm_init_mcc(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2014-03-04 19:58:46 +02:00
|
|
|
|
2015-06-01 17:11:11 +02:00
|
|
|
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
|
2016-01-03 22:23:40 +02:00
|
|
|
mvm->scan_type = IWL_SCAN_TYPE_NOT_SET;
|
2017-01-31 10:39:44 +02:00
|
|
|
mvm->hb_scan_type = IWL_SCAN_TYPE_NOT_SET;
|
2014-05-20 12:46:37 +03:00
|
|
|
ret = iwl_mvm_config_scan(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2023-03-20 12:33:18 +02:00
|
|
|
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
|
2018-12-13 23:04:51 +02:00
|
|
|
iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_UPDATE_DB);
|
2023-05-31 19:50:06 +03:00
|
|
|
|
|
|
|
if (mvm->time_sync.active)
|
|
|
|
iwl_mvm_time_sync_config(mvm, mvm->time_sync.peer_addr,
|
|
|
|
IWL_TIME_SYNC_PROTOCOL_TM |
|
|
|
|
IWL_TIME_SYNC_PROTOCOL_FTM);
|
2023-03-20 12:33:18 +02:00
|
|
|
}
|
2018-12-13 23:04:51 +02:00
|
|
|
|
2023-03-20 12:33:02 +02:00
|
|
|
if (!mvm->ptp_data.ptp_clock)
|
|
|
|
iwl_mvm_ptp_init(mvm);
|
|
|
|
|
2019-06-16 13:18:28 +03:00
|
|
|
ret = iwl_mvm_ppag_init(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
2016-05-30 13:00:44 +03:00
|
|
|
ret = iwl_mvm_sar_init(mvm);
|
2021-08-05 14:21:56 +03:00
|
|
|
if (ret == 0)
|
2018-10-17 08:35:15 +03:00
|
|
|
ret = iwl_mvm_sar_geo_init(mvm);
|
2022-01-28 14:48:51 +02:00
|
|
|
if (ret < 0)
|
2017-01-19 12:00:46 +02:00
|
|
|
goto error;
|
|
|
|
|
2021-12-04 17:49:37 +02:00
|
|
|
ret = iwl_mvm_sgom_init(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
2020-04-18 11:08:50 +03:00
|
|
|
iwl_mvm_tas_init(mvm);
|
2017-06-28 16:19:49 +02:00
|
|
|
iwl_mvm_leds_sync(mvm);
|
2023-10-22 17:55:50 +03:00
|
|
|
iwl_mvm_uats_init(mvm);
|
2017-06-28 16:19:49 +02:00
|
|
|
|
2023-04-30 20:18:30 +03:00
|
|
|
if (iwl_rfi_supported(mvm)) {
|
2024-02-01 16:17:33 +02:00
|
|
|
if (iwl_mvm_eval_dsm_rfi(mvm))
|
2021-02-10 17:15:04 +02:00
|
|
|
iwl_rfi_send_config_cmd(mvm, NULL);
|
|
|
|
}
|
|
|
|
|
2022-10-30 19:17:41 +02:00
|
|
|
iwl_mvm_mei_device_state(mvm, true);
|
|
|
|
|
2013-04-28 11:55:08 +03:00
|
|
|
IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
|
2013-01-24 14:25:36 +01:00
|
|
|
return 0;
|
|
|
|
error:
|
2017-11-23 10:29:04 +02:00
|
|
|
if (!iwlmvm_mod_params.init_dbg || !ret)
|
2017-03-16 13:00:59 +02:00
|
|
|
iwl_mvm_stop_device(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
lockdep_assert_held(&mvm->mutex);
|
|
|
|
|
|
|
|
ret = iwl_trans_start_hw(mvm->trans);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN);
|
|
|
|
if (ret) {
|
|
|
|
IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2014-12-08 21:13:14 +02:00
|
|
|
ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
|
2013-01-24 14:25:36 +01:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Send phy db control command and then phy db calibration*/
|
|
|
|
ret = iwl_send_phy_db_data(mvm->phy_db);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret = iwl_send_phy_cfg_cmd(mvm);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* init the fw <-> mac80211 STA mapping */
|
2023-03-29 10:05:21 +03:00
|
|
|
for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
|
2013-01-24 14:25:36 +01:00
|
|
|
RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
|
2023-03-29 10:05:21 +03:00
|
|
|
RCU_INIT_POINTER(mvm->fw_id_to_link_sta[i], NULL);
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
2023-06-13 15:57:23 +03:00
|
|
|
if (!iwl_mvm_has_new_station_api(mvm->fw)) {
|
2020-10-08 18:09:47 +03:00
|
|
|
/*
|
|
|
|
* Add auxiliary station for scanning.
|
|
|
|
* Newer versions of this command implies that the fw uses
|
|
|
|
* internal aux station for all aux activities that don't
|
|
|
|
* requires a dedicated data queue.
|
|
|
|
* In old version the aux station uses mac id like other
|
|
|
|
* station and not lmac id
|
|
|
|
*/
|
|
|
|
ret = iwl_mvm_add_aux_sta(mvm, MAC_INDEX_AUX);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2013-01-24 14:25:36 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
error:
|
2016-02-22 10:21:41 +02:00
|
|
|
iwl_mvm_stop_device(mvm);
|
2013-01-24 14:25:36 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-23 21:22:09 +02:00
|
|
|
void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
|
|
|
|
struct iwl_rx_cmd_buffer *rxb)
|
2014-11-15 21:08:29 +02:00
|
|
|
{
|
|
|
|
struct iwl_rx_packet *pkt = rxb_addr(rxb);
|
|
|
|
struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data;
|
|
|
|
|
2017-01-25 15:11:30 +02:00
|
|
|
IWL_DEBUG_INFO(mvm,
|
|
|
|
"MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n",
|
|
|
|
le32_to_cpu(mfuart_notif->installed_ver),
|
|
|
|
le32_to_cpu(mfuart_notif->external_ver),
|
|
|
|
le32_to_cpu(mfuart_notif->status),
|
|
|
|
le32_to_cpu(mfuart_notif->duration));
|
|
|
|
|
2016-11-07 17:40:43 +02:00
|
|
|
if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif))
|
|
|
|
IWL_DEBUG_INFO(mvm,
|
2017-01-25 15:11:30 +02:00
|
|
|
"MFUART: image size: 0x%08x\n",
|
2016-11-07 17:40:43 +02:00
|
|
|
le32_to_cpu(mfuart_notif->image_size));
|
2014-11-15 21:08:29 +02:00
|
|
|
}
|