iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / drivers / net / wireless / intel / iwlwifi / mvm / fw.c
blob3fe7605a2cca438e9a63767881253a8d1d855705
1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
6 * GPL LICENSE SUMMARY
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as
15 * published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
25 * USA
27 * The full GNU General Public License is included in this distribution
28 * in the file called COPYING.
30 * Contact Information:
31 * Intel Linux Wireless <linuxwifi@intel.com>
32 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
34 * BSD LICENSE
36 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
37 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
38 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
39 * Copyright(c) 2018 Intel Corporation
40 * All rights reserved.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
44 * are met:
46 * * Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * * Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in
50 * the documentation and/or other materials provided with the
51 * distribution.
52 * * Neither the name Intel Corporation nor the names of its
53 * contributors may be used to endorse or promote products derived
54 * from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
57 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
59 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
60 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
62 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
66 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 *****************************************************************************/
69 #include <net/mac80211.h>
70 #include <linux/netdevice.h>
72 #include "iwl-trans.h"
73 #include "iwl-op-mode.h"
74 #include "fw/img.h"
75 #include "iwl-debug.h"
76 #include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */
77 #include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */
78 #include "iwl-prph.h"
79 #include "fw/acpi.h"
81 #include "mvm.h"
82 #include "fw/dbg.h"
83 #include "iwl-phy-db.h"
84 #include "iwl-modparams.h"
85 #include "iwl-nvm-parse.h"
87 #define MVM_UCODE_ALIVE_TIMEOUT HZ
88 #define MVM_UCODE_CALIB_TIMEOUT (2*HZ)
90 #define UCODE_VALID_OK cpu_to_le32(0x1)
92 struct iwl_mvm_alive_data {
93 bool valid;
94 u32 scd_base_addr;
97 static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
99 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
100 .valid = cpu_to_le32(valid_tx_ant),
103 IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant);
104 return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0,
105 sizeof(tx_ant_cmd), &tx_ant_cmd);
108 static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
110 int i;
111 struct iwl_rss_config_cmd cmd = {
112 .flags = cpu_to_le32(IWL_RSS_ENABLE),
113 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
114 IWL_RSS_HASH_TYPE_IPV4_UDP |
115 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
116 IWL_RSS_HASH_TYPE_IPV6_TCP |
117 IWL_RSS_HASH_TYPE_IPV6_UDP |
118 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
121 if (mvm->trans->num_rx_queues == 1)
122 return 0;
124 /* Do not direct RSS traffic to Q 0 which is our fallback queue */
125 for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++)
126 cmd.indirection_table[i] =
127 1 + (i % (mvm->trans->num_rx_queues - 1));
128 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
130 return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd);
133 static int iwl_configure_rxq(struct iwl_mvm *mvm)
135 int i, num_queues, size, ret;
136 struct iwl_rfh_queue_config *cmd;
137 struct iwl_host_cmd hcmd = {
138 .id = WIDE_ID(DATA_PATH_GROUP, RFH_QUEUE_CONFIG_CMD),
139 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
142 /* Do not configure default queue, it is configured via context info */
143 num_queues = mvm->trans->num_rx_queues - 1;
145 size = struct_size(cmd, data, num_queues);
147 cmd = kzalloc(size, GFP_KERNEL);
148 if (!cmd)
149 return -ENOMEM;
151 cmd->num_queues = num_queues;
153 for (i = 0; i < num_queues; i++) {
154 struct iwl_trans_rxq_dma_data data;
156 cmd->data[i].q_num = i + 1;
157 iwl_trans_get_rxq_dma_data(mvm->trans, i + 1, &data);
159 cmd->data[i].fr_bd_cb = cpu_to_le64(data.fr_bd_cb);
160 cmd->data[i].urbd_stts_wrptr =
161 cpu_to_le64(data.urbd_stts_wrptr);
162 cmd->data[i].ur_bd_cb = cpu_to_le64(data.ur_bd_cb);
163 cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid);
166 hcmd.data[0] = cmd;
167 hcmd.len[0] = size;
169 ret = iwl_mvm_send_cmd(mvm, &hcmd);
171 kfree(cmd);
173 return ret;
176 static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm)
178 struct iwl_dqa_enable_cmd dqa_cmd = {
179 .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE),
181 u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0);
182 int ret;
184 ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd);
185 if (ret)
186 IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret);
187 else
188 IWL_DEBUG_FW(mvm, "Working in DQA mode\n");
190 return ret;
193 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
194 struct iwl_rx_cmd_buffer *rxb)
196 struct iwl_rx_packet *pkt = rxb_addr(rxb);
197 struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data;
198 __le32 *dump_data = mfu_dump_notif->data;
199 int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32);
200 int i;
202 if (mfu_dump_notif->index_num == 0)
203 IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n",
204 le32_to_cpu(mfu_dump_notif->assert_id));
206 for (i = 0; i < n_words; i++)
207 IWL_DEBUG_INFO(mvm,
208 "MFUART assert dump, dword %u: 0x%08x\n",
209 le16_to_cpu(mfu_dump_notif->index_num) *
210 n_words + i,
211 le32_to_cpu(dump_data[i]));
214 static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
215 struct iwl_rx_packet *pkt, void *data)
217 struct iwl_mvm *mvm =
218 container_of(notif_wait, struct iwl_mvm, notif_wait);
219 struct iwl_mvm_alive_data *alive_data = data;
220 struct mvm_alive_resp_v3 *palive3;
221 struct mvm_alive_resp *palive;
222 struct iwl_umac_alive *umac;
223 struct iwl_lmac_alive *lmac1;
224 struct iwl_lmac_alive *lmac2 = NULL;
225 u16 status;
226 u32 umac_error_event_table;
228 if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) {
229 palive = (void *)pkt->data;
230 umac = &palive->umac_data;
231 lmac1 = &palive->lmac_data[0];
232 lmac2 = &palive->lmac_data[1];
233 status = le16_to_cpu(palive->status);
234 } else {
235 palive3 = (void *)pkt->data;
236 umac = &palive3->umac_data;
237 lmac1 = &palive3->lmac_data;
238 status = le16_to_cpu(palive3->status);
241 mvm->error_event_table[0] = le32_to_cpu(lmac1->error_event_table_ptr);
242 if (lmac2)
243 mvm->error_event_table[1] =
244 le32_to_cpu(lmac2->error_event_table_ptr);
245 mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr);
247 umac_error_event_table = le32_to_cpu(umac->error_info_addr);
249 if (!umac_error_event_table) {
250 mvm->support_umac_log = false;
251 } else if (umac_error_event_table >=
252 mvm->trans->cfg->min_umac_error_event_table) {
253 mvm->support_umac_log = true;
254 mvm->umac_error_event_table = umac_error_event_table;
255 } else {
256 IWL_ERR(mvm,
257 "Not valid error log pointer 0x%08X for %s uCode\n",
258 mvm->umac_error_event_table,
259 (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) ?
260 "Init" : "RT");
261 mvm->support_umac_log = false;
264 alive_data->scd_base_addr = le32_to_cpu(lmac1->scd_base_ptr);
265 alive_data->valid = status == IWL_ALIVE_STATUS_OK;
267 IWL_DEBUG_FW(mvm,
268 "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n",
269 status, lmac1->ver_type, lmac1->ver_subtype);
271 if (lmac2)
272 IWL_DEBUG_FW(mvm, "Alive ucode CDB\n");
274 IWL_DEBUG_FW(mvm,
275 "UMAC version: Major - 0x%x, Minor - 0x%x\n",
276 le32_to_cpu(umac->umac_major),
277 le32_to_cpu(umac->umac_minor));
279 return true;
282 static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait,
283 struct iwl_rx_packet *pkt, void *data)
285 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
287 return true;
290 static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
291 struct iwl_rx_packet *pkt, void *data)
293 struct iwl_phy_db *phy_db = data;
295 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) {
296 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
297 return true;
300 WARN_ON(iwl_phy_db_set_section(phy_db, pkt));
302 return false;
305 static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
306 enum iwl_ucode_type ucode_type)
308 struct iwl_notification_wait alive_wait;
309 struct iwl_mvm_alive_data alive_data;
310 const struct fw_img *fw;
311 int ret, i;
312 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
313 static const u16 alive_cmd[] = { MVM_ALIVE };
315 if (ucode_type == IWL_UCODE_REGULAR &&
316 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) &&
317 !(fw_has_capa(&mvm->fw->ucode_capa,
318 IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED)))
319 fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER);
320 else
321 fw = iwl_get_ucode_image(mvm->fw, ucode_type);
322 if (WARN_ON(!fw))
323 return -EINVAL;
324 iwl_fw_set_current_image(&mvm->fwrt, ucode_type);
325 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
327 iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
328 alive_cmd, ARRAY_SIZE(alive_cmd),
329 iwl_alive_fn, &alive_data);
331 ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT);
332 if (ret) {
333 iwl_fw_set_current_image(&mvm->fwrt, old_type);
334 iwl_remove_notification(&mvm->notif_wait, &alive_wait);
335 return ret;
339 * Some things may run in the background now, but we
340 * just wait for the ALIVE notification here.
342 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait,
343 MVM_UCODE_ALIVE_TIMEOUT);
344 if (ret) {
345 struct iwl_trans *trans = mvm->trans;
347 if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000)
348 IWL_ERR(mvm,
349 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
350 iwl_read_prph(trans, UMAG_SB_CPU_1_STATUS),
351 iwl_read_prph(trans, UMAG_SB_CPU_2_STATUS));
352 else if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000)
353 IWL_ERR(mvm,
354 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
355 iwl_read_prph(trans, SB_CPU_1_STATUS),
356 iwl_read_prph(trans, SB_CPU_2_STATUS));
357 iwl_fw_set_current_image(&mvm->fwrt, old_type);
358 return ret;
361 if (!alive_data.valid) {
362 IWL_ERR(mvm, "Loaded ucode is not valid!\n");
363 iwl_fw_set_current_image(&mvm->fwrt, old_type);
364 return -EIO;
367 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
370 * Note: all the queues are enabled as part of the interface
371 * initialization, but in firmware restart scenarios they
372 * could be stopped, so wake them up. In firmware restart,
373 * mac80211 will have the queues stopped as well until the
374 * reconfiguration completes. During normal startup, they
375 * will be empty.
378 memset(&mvm->queue_info, 0, sizeof(mvm->queue_info));
379 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].hw_queue_refcount = 1;
381 for (i = 0; i < IEEE80211_MAX_QUEUES; i++)
382 atomic_set(&mvm->mac80211_queue_stop_count[i], 0);
384 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
386 return 0;
389 static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
391 struct iwl_notification_wait init_wait;
392 struct iwl_nvm_access_complete_cmd nvm_complete = {};
393 struct iwl_init_extended_cfg_cmd init_cfg = {
394 .init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)),
396 static const u16 init_complete[] = {
397 INIT_COMPLETE_NOTIF,
399 int ret;
401 lockdep_assert_held(&mvm->mutex);
403 iwl_init_notification_wait(&mvm->notif_wait,
404 &init_wait,
405 init_complete,
406 ARRAY_SIZE(init_complete),
407 iwl_wait_init_complete,
408 NULL);
410 /* Will also start the device */
411 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
412 if (ret) {
413 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
414 goto error;
417 /* Send init config command to mark that we are sending NVM access
418 * commands
420 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP,
421 INIT_EXTENDED_CFG_CMD), 0,
422 sizeof(init_cfg), &init_cfg);
423 if (ret) {
424 IWL_ERR(mvm, "Failed to run init config command: %d\n",
425 ret);
426 goto error;
429 /* Load NVM to NIC if needed */
430 if (mvm->nvm_file_name) {
431 iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name,
432 mvm->nvm_sections);
433 iwl_mvm_load_nvm_to_nic(mvm);
436 if (IWL_MVM_PARSE_NVM && read_nvm) {
437 ret = iwl_nvm_init(mvm);
438 if (ret) {
439 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
440 goto error;
444 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP,
445 NVM_ACCESS_COMPLETE), 0,
446 sizeof(nvm_complete), &nvm_complete);
447 if (ret) {
448 IWL_ERR(mvm, "Failed to run complete NVM access: %d\n",
449 ret);
450 goto error;
453 /* We wait for the INIT complete notification */
454 ret = iwl_wait_notification(&mvm->notif_wait, &init_wait,
455 MVM_UCODE_ALIVE_TIMEOUT);
456 if (ret)
457 return ret;
459 /* Read the NVM only at driver load time, no need to do this twice */
460 if (!IWL_MVM_PARSE_NVM && read_nvm) {
461 mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw);
462 if (IS_ERR(mvm->nvm_data)) {
463 ret = PTR_ERR(mvm->nvm_data);
464 mvm->nvm_data = NULL;
465 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
466 return ret;
470 return 0;
472 error:
473 iwl_remove_notification(&mvm->notif_wait, &init_wait);
474 return ret;
477 static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
479 struct iwl_phy_cfg_cmd phy_cfg_cmd;
480 enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img;
482 /* Set parameters */
483 phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm));
485 /* set flags extra PHY configuration flags from the device's cfg */
486 phy_cfg_cmd.phy_cfg |= cpu_to_le32(mvm->cfg->extra_phy_cfg_flags);
488 phy_cfg_cmd.calib_control.event_trigger =
489 mvm->fw->default_calib[ucode_type].event_trigger;
490 phy_cfg_cmd.calib_control.flow_trigger =
491 mvm->fw->default_calib[ucode_type].flow_trigger;
493 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n",
494 phy_cfg_cmd.phy_cfg);
496 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0,
497 sizeof(phy_cfg_cmd), &phy_cfg_cmd);
500 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
502 struct iwl_notification_wait calib_wait;
503 static const u16 init_complete[] = {
504 INIT_COMPLETE_NOTIF,
505 CALIB_RES_NOTIF_PHY_DB
507 int ret;
509 if (iwl_mvm_has_unified_ucode(mvm))
510 return iwl_run_unified_mvm_ucode(mvm, true);
512 lockdep_assert_held(&mvm->mutex);
514 if (WARN_ON_ONCE(mvm->calibrating))
515 return 0;
517 iwl_init_notification_wait(&mvm->notif_wait,
518 &calib_wait,
519 init_complete,
520 ARRAY_SIZE(init_complete),
521 iwl_wait_phy_db_entry,
522 mvm->phy_db);
524 /* Will also start the device */
525 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT);
526 if (ret) {
527 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret);
528 goto remove_notif;
531 if (mvm->cfg->device_family < IWL_DEVICE_FAMILY_8000) {
532 ret = iwl_mvm_send_bt_init_conf(mvm);
533 if (ret)
534 goto remove_notif;
537 /* Read the NVM only at driver load time, no need to do this twice */
538 if (read_nvm) {
539 ret = iwl_nvm_init(mvm);
540 if (ret) {
541 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
542 goto remove_notif;
546 /* In case we read the NVM from external file, load it to the NIC */
547 if (mvm->nvm_file_name)
548 iwl_mvm_load_nvm_to_nic(mvm);
550 WARN_ON(iwl_nvm_check_version(mvm->nvm_data, mvm->trans));
553 * abort after reading the nvm in case RF Kill is on, we will complete
554 * the init seq later when RF kill will switch to off
556 if (iwl_mvm_is_radio_hw_killed(mvm)) {
557 IWL_DEBUG_RF_KILL(mvm,
558 "jump over all phy activities due to RF kill\n");
559 goto remove_notif;
562 mvm->calibrating = true;
564 /* Send TX valid antennas before triggering calibrations */
565 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
566 if (ret)
567 goto remove_notif;
569 ret = iwl_send_phy_cfg_cmd(mvm);
570 if (ret) {
571 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
572 ret);
573 goto remove_notif;
577 * Some things may run in the background now, but we
578 * just wait for the calibration complete notification.
580 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
581 MVM_UCODE_CALIB_TIMEOUT);
582 if (!ret)
583 goto out;
585 if (iwl_mvm_is_radio_hw_killed(mvm)) {
586 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
587 ret = 0;
588 } else {
589 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
590 ret);
593 goto out;
595 remove_notif:
596 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
597 out:
598 mvm->calibrating = false;
599 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
600 /* we want to debug INIT and we have no NVM - fake */
601 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
602 sizeof(struct ieee80211_channel) +
603 sizeof(struct ieee80211_rate),
604 GFP_KERNEL);
605 if (!mvm->nvm_data)
606 return -ENOMEM;
607 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
608 mvm->nvm_data->bands[0].n_channels = 1;
609 mvm->nvm_data->bands[0].n_bitrates = 1;
610 mvm->nvm_data->bands[0].bitrates =
611 (void *)mvm->nvm_data->channels + 1;
612 mvm->nvm_data->bands[0].bitrates->hw_value = 10;
615 return ret;
618 static int iwl_mvm_config_ltr(struct iwl_mvm *mvm)
620 struct iwl_ltr_config_cmd cmd = {
621 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
624 if (!mvm->trans->ltr_enabled)
625 return 0;
627 return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
628 sizeof(cmd), &cmd);
631 #ifdef CONFIG_ACPI
632 static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm,
633 union acpi_object *table,
634 struct iwl_mvm_sar_profile *profile,
635 bool enabled)
637 int i;
639 profile->enabled = enabled;
641 for (i = 0; i < ACPI_SAR_TABLE_SIZE; i++) {
642 if ((table[i].type != ACPI_TYPE_INTEGER) ||
643 (table[i].integer.value > U8_MAX))
644 return -EINVAL;
646 profile->table[i] = table[i].integer.value;
649 return 0;
652 static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
654 union acpi_object *wifi_pkg, *table, *data;
655 bool enabled;
656 int ret;
658 data = iwl_acpi_get_object(mvm->dev, ACPI_WRDS_METHOD);
659 if (IS_ERR(data))
660 return PTR_ERR(data);
662 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
663 ACPI_WRDS_WIFI_DATA_SIZE);
664 if (IS_ERR(wifi_pkg)) {
665 ret = PTR_ERR(wifi_pkg);
666 goto out_free;
669 if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
670 ret = -EINVAL;
671 goto out_free;
674 enabled = !!(wifi_pkg->package.elements[1].integer.value);
676 /* position of the actual table */
677 table = &wifi_pkg->package.elements[2];
679 /* The profile from WRDS is officially profile 1, but goes
680 * into sar_profiles[0] (because we don't have a profile 0).
682 ret = iwl_mvm_sar_set_profile(mvm, table, &mvm->sar_profiles[0],
683 enabled);
684 out_free:
685 kfree(data);
686 return ret;
689 static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
691 union acpi_object *wifi_pkg, *data;
692 bool enabled;
693 int i, n_profiles, ret;
695 data = iwl_acpi_get_object(mvm->dev, ACPI_EWRD_METHOD);
696 if (IS_ERR(data))
697 return PTR_ERR(data);
699 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
700 ACPI_EWRD_WIFI_DATA_SIZE);
701 if (IS_ERR(wifi_pkg)) {
702 ret = PTR_ERR(wifi_pkg);
703 goto out_free;
706 if ((wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) ||
707 (wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER)) {
708 ret = -EINVAL;
709 goto out_free;
712 enabled = !!(wifi_pkg->package.elements[1].integer.value);
713 n_profiles = wifi_pkg->package.elements[2].integer.value;
716 * Check the validity of n_profiles. The EWRD profiles start
717 * from index 1, so the maximum value allowed here is
718 * ACPI_SAR_PROFILES_NUM - 1.
720 if (n_profiles <= 0 || n_profiles >= ACPI_SAR_PROFILE_NUM) {
721 ret = -EINVAL;
722 goto out_free;
725 for (i = 0; i < n_profiles; i++) {
726 /* the tables start at element 3 */
727 int pos = 3;
729 /* The EWRD profiles officially go from 2 to 4, but we
730 * save them in sar_profiles[1-3] (because we don't
731 * have profile 0). So in the array we start from 1.
733 ret = iwl_mvm_sar_set_profile(mvm,
734 &wifi_pkg->package.elements[pos],
735 &mvm->sar_profiles[i + 1],
736 enabled);
737 if (ret < 0)
738 break;
740 /* go to the next table */
741 pos += ACPI_SAR_TABLE_SIZE;
744 out_free:
745 kfree(data);
746 return ret;
749 static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
751 union acpi_object *wifi_pkg, *data;
752 int i, j, ret;
753 int idx = 1;
755 data = iwl_acpi_get_object(mvm->dev, ACPI_WGDS_METHOD);
756 if (IS_ERR(data))
757 return PTR_ERR(data);
759 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
760 ACPI_WGDS_WIFI_DATA_SIZE);
761 if (IS_ERR(wifi_pkg)) {
762 ret = PTR_ERR(wifi_pkg);
763 goto out_free;
766 for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) {
767 for (j = 0; j < ACPI_GEO_TABLE_SIZE; j++) {
768 union acpi_object *entry;
770 entry = &wifi_pkg->package.elements[idx++];
771 if ((entry->type != ACPI_TYPE_INTEGER) ||
772 (entry->integer.value > U8_MAX)) {
773 ret = -EINVAL;
774 goto out_free;
777 mvm->geo_profiles[i].values[j] = entry->integer.value;
780 ret = 0;
781 out_free:
782 kfree(data);
783 return ret;
786 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
788 struct iwl_dev_tx_power_cmd cmd = {
789 .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS),
791 int i, j, idx;
792 int profs[ACPI_SAR_NUM_CHAIN_LIMITS] = { prof_a, prof_b };
793 int len = sizeof(cmd);
795 BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS < 2);
796 BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS * ACPI_SAR_NUM_SUB_BANDS !=
797 ACPI_SAR_TABLE_SIZE);
799 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK))
800 len = sizeof(cmd.v3);
802 for (i = 0; i < ACPI_SAR_NUM_CHAIN_LIMITS; i++) {
803 struct iwl_mvm_sar_profile *prof;
805 /* don't allow SAR to be disabled (profile 0 means disable) */
806 if (profs[i] == 0)
807 return -EPERM;
809 /* we are off by one, so allow up to ACPI_SAR_PROFILE_NUM */
810 if (profs[i] > ACPI_SAR_PROFILE_NUM)
811 return -EINVAL;
813 /* profiles go from 1 to 4, so decrement to access the array */
814 prof = &mvm->sar_profiles[profs[i] - 1];
816 /* if the profile is disabled, do nothing */
817 if (!prof->enabled) {
818 IWL_DEBUG_RADIO(mvm, "SAR profile %d is disabled.\n",
819 profs[i]);
820 /* if one of the profiles is disabled, we fail all */
821 return -ENOENT;
824 IWL_DEBUG_RADIO(mvm, " Chain[%d]:\n", i);
825 for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) {
826 idx = (i * ACPI_SAR_NUM_SUB_BANDS) + j;
827 cmd.v3.per_chain_restriction[i][j] =
828 cpu_to_le16(prof->table[idx]);
829 IWL_DEBUG_RADIO(mvm, " Band[%d] = %d * .125dBm\n",
830 j, prof->table[idx]);
834 IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n");
836 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
839 static bool iwl_mvm_sar_geo_support(struct iwl_mvm *mvm)
842 * The GEO_TX_POWER_LIMIT command is not supported on earlier
843 * firmware versions. Unfortunately, we don't have a TLV API
844 * flag to rely on, so rely on the major version which is in
845 * the first byte of ucode_ver. This was implemented
846 * initially on version 38 and then backported to 36, 29 and
847 * 17.
849 return IWL_UCODE_SERIAL(mvm->fw->ucode_ver) >= 38 ||
850 IWL_UCODE_SERIAL(mvm->fw->ucode_ver) == 36 ||
851 IWL_UCODE_SERIAL(mvm->fw->ucode_ver) == 29 ||
852 IWL_UCODE_SERIAL(mvm->fw->ucode_ver) == 17;
855 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)
857 struct iwl_geo_tx_power_profiles_resp *resp;
858 int ret;
860 struct iwl_geo_tx_power_profiles_cmd geo_cmd = {
861 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE),
863 struct iwl_host_cmd cmd = {
864 .id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT),
865 .len = { sizeof(geo_cmd), },
866 .flags = CMD_WANT_SKB,
867 .data = { &geo_cmd },
870 if (!iwl_mvm_sar_geo_support(mvm))
871 return -EOPNOTSUPP;
873 ret = iwl_mvm_send_cmd(mvm, &cmd);
874 if (ret) {
875 IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret);
876 return ret;
879 resp = (void *)cmd.resp_pkt->data;
880 ret = le32_to_cpu(resp->profile_idx);
881 if (WARN_ON(ret > ACPI_NUM_GEO_PROFILES)) {
882 ret = -EIO;
883 IWL_WARN(mvm, "Invalid geographic profile idx (%d)\n", ret);
886 iwl_free_resp(&cmd);
887 return ret;
890 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
892 struct iwl_geo_tx_power_profiles_cmd cmd = {
893 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES),
895 int ret, i, j;
896 u16 cmd_wide_id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT);
898 if (!iwl_mvm_sar_geo_support(mvm))
899 return 0;
901 ret = iwl_mvm_sar_get_wgds_table(mvm);
902 if (ret < 0) {
903 IWL_DEBUG_RADIO(mvm,
904 "Geo SAR BIOS table invalid or unavailable. (%d)\n",
905 ret);
906 /* we don't fail if the table is not available */
907 return 0;
910 IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n");
912 BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS *
913 ACPI_WGDS_TABLE_SIZE + 1 != ACPI_WGDS_WIFI_DATA_SIZE);
915 BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES > IWL_NUM_GEO_PROFILES);
917 for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) {
918 struct iwl_per_chain_offset *chain =
919 (struct iwl_per_chain_offset *)&cmd.table[i];
921 for (j = 0; j < ACPI_WGDS_NUM_BANDS; j++) {
922 u8 *value;
924 value = &mvm->geo_profiles[i].values[j *
925 ACPI_GEO_PER_CHAIN_SIZE];
926 chain[j].max_tx_power = cpu_to_le16(value[0]);
927 chain[j].chain_a = value[1];
928 chain[j].chain_b = value[2];
929 IWL_DEBUG_RADIO(mvm,
930 "SAR geographic profile[%d] Band[%d]: chain A = %d chain B = %d max_tx_power = %d\n",
931 i, j, value[1], value[2], value[0]);
934 return iwl_mvm_send_cmd_pdu(mvm, cmd_wide_id, 0, sizeof(cmd), &cmd);
937 #else /* CONFIG_ACPI */
938 static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
940 return -ENOENT;
943 static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
945 return -ENOENT;
948 static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
950 return -ENOENT;
953 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
955 return 0;
958 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a,
959 int prof_b)
961 return -ENOENT;
964 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)
966 return -ENOENT;
968 #endif /* CONFIG_ACPI */
970 static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
972 int ret;
974 ret = iwl_mvm_sar_get_wrds_table(mvm);
975 if (ret < 0) {
976 IWL_DEBUG_RADIO(mvm,
977 "WRDS SAR BIOS table invalid or unavailable. (%d)\n",
978 ret);
980 * If not available, don't fail and don't bother with EWRD.
981 * Return 1 to tell that we can't use WGDS either.
983 return 1;
986 ret = iwl_mvm_sar_get_ewrd_table(mvm);
987 /* if EWRD is not available, we can still use WRDS, so don't fail */
988 if (ret < 0)
989 IWL_DEBUG_RADIO(mvm,
990 "EWRD SAR BIOS table invalid or unavailable. (%d)\n",
991 ret);
993 /* choose profile 1 (WRDS) as default for both chains */
994 ret = iwl_mvm_sar_select_profile(mvm, 1, 1);
997 * If we don't have profile 0 from BIOS, just skip it. This
998 * means that SAR Geo will not be enabled either, even if we
999 * have other valid profiles.
1001 if (ret == -ENOENT)
1002 return 1;
1004 return ret;
1007 static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
1009 int ret;
1011 if (iwl_mvm_has_unified_ucode(mvm))
1012 return iwl_run_unified_mvm_ucode(mvm, false);
1014 ret = iwl_run_init_mvm_ucode(mvm, false);
1016 if (ret) {
1017 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
1019 if (iwlmvm_mod_params.init_dbg)
1020 return 0;
1021 return ret;
1025 * Stop and start the transport without entering low power
1026 * mode. This will save the state of other components on the
1027 * device that are triggered by the INIT firwmare (MFUART).
1029 _iwl_trans_stop_device(mvm->trans, false);
1030 ret = _iwl_trans_start_hw(mvm->trans, false);
1031 if (ret)
1032 return ret;
1034 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
1035 if (ret)
1036 return ret;
1038 return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img);
1041 int iwl_mvm_up(struct iwl_mvm *mvm)
1043 int ret, i;
1044 struct ieee80211_channel *chan;
1045 struct cfg80211_chan_def chandef;
1047 lockdep_assert_held(&mvm->mutex);
1049 ret = iwl_trans_start_hw(mvm->trans);
1050 if (ret)
1051 return ret;
1053 ret = iwl_mvm_load_rt_fw(mvm);
1054 if (ret) {
1055 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
1056 goto error;
1059 iwl_get_shared_mem_conf(&mvm->fwrt);
1061 ret = iwl_mvm_sf_update(mvm, NULL, false);
1062 if (ret)
1063 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n");
1065 mvm->fwrt.dump.conf = FW_DBG_INVALID;
1066 /* if we have a destination, assume EARLY START */
1067 if (mvm->fw->dbg_dest_tlv)
1068 mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE;
1069 iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE);
1071 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
1072 if (ret)
1073 goto error;
1075 if (!iwl_mvm_has_unified_ucode(mvm)) {
1076 /* Send phy db control command and then phy db calibration */
1077 ret = iwl_send_phy_db_data(mvm->phy_db);
1078 if (ret)
1079 goto error;
1081 ret = iwl_send_phy_cfg_cmd(mvm);
1082 if (ret)
1083 goto error;
1086 ret = iwl_mvm_send_bt_init_conf(mvm);
1087 if (ret)
1088 goto error;
1090 /* Init RSS configuration */
1091 if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) {
1092 ret = iwl_configure_rxq(mvm);
1093 if (ret) {
1094 IWL_ERR(mvm, "Failed to configure RX queues: %d\n",
1095 ret);
1096 goto error;
1100 if (iwl_mvm_has_new_rx_api(mvm)) {
1101 ret = iwl_send_rss_cfg_cmd(mvm);
1102 if (ret) {
1103 IWL_ERR(mvm, "Failed to configure RSS queues: %d\n",
1104 ret);
1105 goto error;
1109 /* init the fw <-> mac80211 STA mapping */
1110 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++)
1111 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
1113 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA;
1115 /* reset quota debouncing buffer - 0xff will yield invalid data */
1116 memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd));
1118 ret = iwl_mvm_send_dqa_cmd(mvm);
1119 if (ret)
1120 goto error;
1122 /* Add auxiliary station for scanning */
1123 ret = iwl_mvm_add_aux_sta(mvm);
1124 if (ret)
1125 goto error;
1127 /* Add all the PHY contexts */
1128 chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0];
1129 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
1130 for (i = 0; i < NUM_PHY_CTX; i++) {
1132 * The channel used here isn't relevant as it's
1133 * going to be overwritten in the other flows.
1134 * For now use the first channel we have.
1136 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i],
1137 &chandef, 1, 1);
1138 if (ret)
1139 goto error;
1142 #ifdef CONFIG_THERMAL
1143 if (iwl_mvm_is_tt_in_fw(mvm)) {
1144 /* in order to give the responsibility of ct-kill and
1145 * TX backoff to FW we need to send empty temperature reporting
1146 * cmd during init time
1148 iwl_mvm_send_temp_report_ths_cmd(mvm);
1149 } else {
1150 /* Initialize tx backoffs to the minimal possible */
1151 iwl_mvm_tt_tx_backoff(mvm, 0);
1154 /* TODO: read the budget from BIOS / Platform NVM */
1157 * In case there is no budget from BIOS / Platform NVM the default
1158 * budget should be 2000mW (cooling state 0).
1160 if (iwl_mvm_is_ctdp_supported(mvm)) {
1161 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
1162 mvm->cooling_dev.cur_state);
1163 if (ret)
1164 goto error;
1166 #else
1167 /* Initialize tx backoffs to the minimal possible */
1168 iwl_mvm_tt_tx_backoff(mvm, 0);
1169 #endif
1171 WARN_ON(iwl_mvm_config_ltr(mvm));
1173 ret = iwl_mvm_power_update_device(mvm);
1174 if (ret)
1175 goto error;
1178 * RTNL is not taken during Ct-kill, but we don't need to scan/Tx
1179 * anyway, so don't init MCC.
1181 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) {
1182 ret = iwl_mvm_init_mcc(mvm);
1183 if (ret)
1184 goto error;
1187 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
1188 mvm->scan_type = IWL_SCAN_TYPE_NOT_SET;
1189 mvm->hb_scan_type = IWL_SCAN_TYPE_NOT_SET;
1190 ret = iwl_mvm_config_scan(mvm);
1191 if (ret)
1192 goto error;
1195 /* allow FW/transport low power modes if not during restart */
1196 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1197 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
1199 ret = iwl_mvm_sar_init(mvm);
1200 if (ret == 0) {
1201 ret = iwl_mvm_sar_geo_init(mvm);
1202 } else if (ret > 0 && !iwl_mvm_sar_get_wgds_table(mvm)) {
1204 * If basic SAR is not available, we check for WGDS,
1205 * which should *not* be available either. If it is
1206 * available, issue an error, because we can't use SAR
1207 * Geo without basic SAR.
1209 IWL_ERR(mvm, "BIOS contains WGDS but no WRDS\n");
1212 if (ret < 0)
1213 goto error;
1215 iwl_mvm_leds_sync(mvm);
1217 IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
1218 return 0;
1219 error:
1220 if (!iwlmvm_mod_params.init_dbg || !ret)
1221 iwl_mvm_stop_device(mvm);
1222 return ret;
1225 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
1227 int ret, i;
1229 lockdep_assert_held(&mvm->mutex);
1231 ret = iwl_trans_start_hw(mvm->trans);
1232 if (ret)
1233 return ret;
1235 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN);
1236 if (ret) {
1237 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret);
1238 goto error;
1241 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm));
1242 if (ret)
1243 goto error;
1245 /* Send phy db control command and then phy db calibration*/
1246 ret = iwl_send_phy_db_data(mvm->phy_db);
1247 if (ret)
1248 goto error;
1250 ret = iwl_send_phy_cfg_cmd(mvm);
1251 if (ret)
1252 goto error;
1254 /* init the fw <-> mac80211 STA mapping */
1255 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++)
1256 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
1258 /* Add auxiliary station for scanning */
1259 ret = iwl_mvm_add_aux_sta(mvm);
1260 if (ret)
1261 goto error;
1263 return 0;
1264 error:
1265 iwl_mvm_stop_device(mvm);
1266 return ret;
1269 void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
1270 struct iwl_rx_cmd_buffer *rxb)
1272 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1273 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
1274 u32 flags = le32_to_cpu(card_state_notif->flags);
1276 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n",
1277 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
1278 (flags & SW_CARD_DISABLED) ? "Kill" : "On",
1279 (flags & CT_KILL_CARD_DISABLED) ?
1280 "Reached" : "Not reached");
1283 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
1284 struct iwl_rx_cmd_buffer *rxb)
1286 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1287 struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data;
1289 IWL_DEBUG_INFO(mvm,
1290 "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n",
1291 le32_to_cpu(mfuart_notif->installed_ver),
1292 le32_to_cpu(mfuart_notif->external_ver),
1293 le32_to_cpu(mfuart_notif->status),
1294 le32_to_cpu(mfuart_notif->duration));
1296 if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif))
1297 IWL_DEBUG_INFO(mvm,
1298 "MFUART: image size: 0x%08x\n",
1299 le32_to_cpu(mfuart_notif->image_size));