1 /****************************************************************************** 2 * 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. 5 * 6 * GPL LICENSE SUMMARY 7 * 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 12 * 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. 16 * 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. 21 * 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 26 * 27 * The full GNU General Public License is included in this distribution 28 * in the file called COPYING. 29 * 30 * Contact Information: 31 * Intel Linux Wireless <linuxwifi@intel.com> 32 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 33 * 34 * BSD LICENSE 35 * 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. 41 * 42 * Redistribution and use in source and binary forms, with or without 43 * modification, are permitted provided that the following conditions 44 * are met: 45 * 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. 55 * 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. 67 * 68 *****************************************************************************/ 69 #include <net/mac80211.h> 70 #include <linux/netdevice.h> 71 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" 80 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" 86 87 #define MVM_UCODE_ALIVE_TIMEOUT HZ 88 #define MVM_UCODE_CALIB_TIMEOUT (2*HZ) 89 90 #define UCODE_VALID_OK cpu_to_le32(0x1) 91 92 struct iwl_mvm_alive_data { 93 bool valid; 94 u32 scd_base_addr; 95 }; 96 97 static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) 98 { 99 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { 100 .valid = cpu_to_le32(valid_tx_ant), 101 }; 102 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); 106 } 107 108 static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) 109 { 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, 119 }; 120 121 if (mvm->trans->num_rx_queues == 1) 122 return 0; 123 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)); 129 130 return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd); 131 } 132 133 static int iwl_configure_rxq(struct iwl_mvm *mvm) 134 { 135 int i, num_queues, size; 136 struct iwl_rfh_queue_config *cmd; 137 138 /* Do not configure default queue, it is configured via context info */ 139 num_queues = mvm->trans->num_rx_queues - 1; 140 141 size = sizeof(*cmd) + num_queues * sizeof(struct iwl_rfh_queue_data); 142 143 cmd = kzalloc(size, GFP_KERNEL); 144 if (!cmd) 145 return -ENOMEM; 146 147 cmd->num_queues = num_queues; 148 149 for (i = 0; i < num_queues; i++) { 150 struct iwl_trans_rxq_dma_data data; 151 152 cmd->data[i].q_num = i + 1; 153 iwl_trans_get_rxq_dma_data(mvm->trans, i + 1, &data); 154 155 cmd->data[i].fr_bd_cb = cpu_to_le64(data.fr_bd_cb); 156 cmd->data[i].urbd_stts_wrptr = 157 cpu_to_le64(data.urbd_stts_wrptr); 158 cmd->data[i].ur_bd_cb = cpu_to_le64(data.ur_bd_cb); 159 cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid); 160 } 161 162 return iwl_mvm_send_cmd_pdu(mvm, 163 WIDE_ID(DATA_PATH_GROUP, 164 RFH_QUEUE_CONFIG_CMD), 165 0, size, cmd); 166 } 167 168 static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm) 169 { 170 struct iwl_dqa_enable_cmd dqa_cmd = { 171 .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE), 172 }; 173 u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0); 174 int ret; 175 176 ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd); 177 if (ret) 178 IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret); 179 else 180 IWL_DEBUG_FW(mvm, "Working in DQA mode\n"); 181 182 return ret; 183 } 184 185 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm, 186 struct iwl_rx_cmd_buffer *rxb) 187 { 188 struct iwl_rx_packet *pkt = rxb_addr(rxb); 189 struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data; 190 __le32 *dump_data = mfu_dump_notif->data; 191 int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32); 192 int i; 193 194 if (mfu_dump_notif->index_num == 0) 195 IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n", 196 le32_to_cpu(mfu_dump_notif->assert_id)); 197 198 for (i = 0; i < n_words; i++) 199 IWL_DEBUG_INFO(mvm, 200 "MFUART assert dump, dword %u: 0x%08x\n", 201 le16_to_cpu(mfu_dump_notif->index_num) * 202 n_words + i, 203 le32_to_cpu(dump_data[i])); 204 } 205 206 static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, 207 struct iwl_rx_packet *pkt, void *data) 208 { 209 struct iwl_mvm *mvm = 210 container_of(notif_wait, struct iwl_mvm, notif_wait); 211 struct iwl_mvm_alive_data *alive_data = data; 212 struct mvm_alive_resp_v3 *palive3; 213 struct mvm_alive_resp *palive; 214 struct iwl_umac_alive *umac; 215 struct iwl_lmac_alive *lmac1; 216 struct iwl_lmac_alive *lmac2 = NULL; 217 u16 status; 218 u32 umac_error_event_table; 219 220 if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) { 221 palive = (void *)pkt->data; 222 umac = &palive->umac_data; 223 lmac1 = &palive->lmac_data[0]; 224 lmac2 = &palive->lmac_data[1]; 225 status = le16_to_cpu(palive->status); 226 } else { 227 palive3 = (void *)pkt->data; 228 umac = &palive3->umac_data; 229 lmac1 = &palive3->lmac_data; 230 status = le16_to_cpu(palive3->status); 231 } 232 233 mvm->error_event_table[0] = le32_to_cpu(lmac1->error_event_table_ptr); 234 if (lmac2) 235 mvm->error_event_table[1] = 236 le32_to_cpu(lmac2->error_event_table_ptr); 237 mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr); 238 239 umac_error_event_table = le32_to_cpu(umac->error_info_addr); 240 241 if (!umac_error_event_table) { 242 mvm->support_umac_log = false; 243 } else if (umac_error_event_table >= 244 mvm->trans->cfg->min_umac_error_event_table) { 245 mvm->support_umac_log = true; 246 mvm->umac_error_event_table = umac_error_event_table; 247 } else { 248 IWL_ERR(mvm, 249 "Not valid error log pointer 0x%08X for %s uCode\n", 250 mvm->umac_error_event_table, 251 (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) ? 252 "Init" : "RT"); 253 mvm->support_umac_log = false; 254 } 255 256 alive_data->scd_base_addr = le32_to_cpu(lmac1->scd_base_ptr); 257 alive_data->valid = status == IWL_ALIVE_STATUS_OK; 258 259 IWL_DEBUG_FW(mvm, 260 "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n", 261 status, lmac1->ver_type, lmac1->ver_subtype); 262 263 if (lmac2) 264 IWL_DEBUG_FW(mvm, "Alive ucode CDB\n"); 265 266 IWL_DEBUG_FW(mvm, 267 "UMAC version: Major - 0x%x, Minor - 0x%x\n", 268 le32_to_cpu(umac->umac_major), 269 le32_to_cpu(umac->umac_minor)); 270 271 return true; 272 } 273 274 static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait, 275 struct iwl_rx_packet *pkt, void *data) 276 { 277 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); 278 279 return true; 280 } 281 282 static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, 283 struct iwl_rx_packet *pkt, void *data) 284 { 285 struct iwl_phy_db *phy_db = data; 286 287 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { 288 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); 289 return true; 290 } 291 292 WARN_ON(iwl_phy_db_set_section(phy_db, pkt)); 293 294 return false; 295 } 296 297 static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, 298 enum iwl_ucode_type ucode_type) 299 { 300 struct iwl_notification_wait alive_wait; 301 struct iwl_mvm_alive_data alive_data; 302 const struct fw_img *fw; 303 int ret, i; 304 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img; 305 static const u16 alive_cmd[] = { MVM_ALIVE }; 306 307 if (ucode_type == IWL_UCODE_REGULAR && 308 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) && 309 !(fw_has_capa(&mvm->fw->ucode_capa, 310 IWL_UCODE_TLV_CAPA_USNIFFER_UNIFIED))) 311 fw = iwl_get_ucode_image(mvm->fw, IWL_UCODE_REGULAR_USNIFFER); 312 else 313 fw = iwl_get_ucode_image(mvm->fw, ucode_type); 314 if (WARN_ON(!fw)) 315 return -EINVAL; 316 iwl_fw_set_current_image(&mvm->fwrt, ucode_type); 317 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 318 319 iwl_init_notification_wait(&mvm->notif_wait, &alive_wait, 320 alive_cmd, ARRAY_SIZE(alive_cmd), 321 iwl_alive_fn, &alive_data); 322 323 ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT); 324 if (ret) { 325 iwl_fw_set_current_image(&mvm->fwrt, old_type); 326 iwl_remove_notification(&mvm->notif_wait, &alive_wait); 327 return ret; 328 } 329 330 /* 331 * Some things may run in the background now, but we 332 * just wait for the ALIVE notification here. 333 */ 334 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, 335 MVM_UCODE_ALIVE_TIMEOUT); 336 if (ret) { 337 struct iwl_trans *trans = mvm->trans; 338 339 if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) 340 IWL_ERR(mvm, 341 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", 342 iwl_read_prph(trans, UMAG_SB_CPU_1_STATUS), 343 iwl_read_prph(trans, UMAG_SB_CPU_2_STATUS)); 344 else if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_8000) 345 IWL_ERR(mvm, 346 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", 347 iwl_read_prph(trans, SB_CPU_1_STATUS), 348 iwl_read_prph(trans, SB_CPU_2_STATUS)); 349 iwl_fw_set_current_image(&mvm->fwrt, old_type); 350 return ret; 351 } 352 353 if (!alive_data.valid) { 354 IWL_ERR(mvm, "Loaded ucode is not valid!\n"); 355 iwl_fw_set_current_image(&mvm->fwrt, old_type); 356 return -EIO; 357 } 358 359 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); 360 361 /* 362 * Note: all the queues are enabled as part of the interface 363 * initialization, but in firmware restart scenarios they 364 * could be stopped, so wake them up. In firmware restart, 365 * mac80211 will have the queues stopped as well until the 366 * reconfiguration completes. During normal startup, they 367 * will be empty. 368 */ 369 370 memset(&mvm->queue_info, 0, sizeof(mvm->queue_info)); 371 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].hw_queue_refcount = 1; 372 373 for (i = 0; i < IEEE80211_MAX_QUEUES; i++) 374 atomic_set(&mvm->mac80211_queue_stop_count[i], 0); 375 376 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 377 378 return 0; 379 } 380 381 static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) 382 { 383 struct iwl_notification_wait init_wait; 384 struct iwl_nvm_access_complete_cmd nvm_complete = {}; 385 struct iwl_init_extended_cfg_cmd init_cfg = { 386 .init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)), 387 }; 388 static const u16 init_complete[] = { 389 INIT_COMPLETE_NOTIF, 390 }; 391 int ret; 392 393 lockdep_assert_held(&mvm->mutex); 394 395 iwl_init_notification_wait(&mvm->notif_wait, 396 &init_wait, 397 init_complete, 398 ARRAY_SIZE(init_complete), 399 iwl_wait_init_complete, 400 NULL); 401 402 /* Will also start the device */ 403 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); 404 if (ret) { 405 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 406 goto error; 407 } 408 409 /* Send init config command to mark that we are sending NVM access 410 * commands 411 */ 412 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP, 413 INIT_EXTENDED_CFG_CMD), 0, 414 sizeof(init_cfg), &init_cfg); 415 if (ret) { 416 IWL_ERR(mvm, "Failed to run init config command: %d\n", 417 ret); 418 goto error; 419 } 420 421 /* Load NVM to NIC if needed */ 422 if (mvm->nvm_file_name) { 423 iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name, 424 mvm->nvm_sections); 425 iwl_mvm_load_nvm_to_nic(mvm); 426 } 427 428 if (IWL_MVM_PARSE_NVM && read_nvm) { 429 ret = iwl_nvm_init(mvm); 430 if (ret) { 431 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 432 goto error; 433 } 434 } 435 436 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP, 437 NVM_ACCESS_COMPLETE), 0, 438 sizeof(nvm_complete), &nvm_complete); 439 if (ret) { 440 IWL_ERR(mvm, "Failed to run complete NVM access: %d\n", 441 ret); 442 goto error; 443 } 444 445 /* We wait for the INIT complete notification */ 446 ret = iwl_wait_notification(&mvm->notif_wait, &init_wait, 447 MVM_UCODE_ALIVE_TIMEOUT); 448 if (ret) 449 return ret; 450 451 /* Read the NVM only at driver load time, no need to do this twice */ 452 if (!IWL_MVM_PARSE_NVM && read_nvm) { 453 mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw); 454 if (IS_ERR(mvm->nvm_data)) { 455 ret = PTR_ERR(mvm->nvm_data); 456 mvm->nvm_data = NULL; 457 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 458 return ret; 459 } 460 } 461 462 return 0; 463 464 error: 465 iwl_remove_notification(&mvm->notif_wait, &init_wait); 466 return ret; 467 } 468 469 static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) 470 { 471 struct iwl_phy_cfg_cmd phy_cfg_cmd; 472 enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img; 473 474 /* Set parameters */ 475 phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm)); 476 477 /* set flags extra PHY configuration flags from the device's cfg */ 478 phy_cfg_cmd.phy_cfg |= cpu_to_le32(mvm->cfg->extra_phy_cfg_flags); 479 480 phy_cfg_cmd.calib_control.event_trigger = 481 mvm->fw->default_calib[ucode_type].event_trigger; 482 phy_cfg_cmd.calib_control.flow_trigger = 483 mvm->fw->default_calib[ucode_type].flow_trigger; 484 485 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", 486 phy_cfg_cmd.phy_cfg); 487 488 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0, 489 sizeof(phy_cfg_cmd), &phy_cfg_cmd); 490 } 491 492 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) 493 { 494 struct iwl_notification_wait calib_wait; 495 static const u16 init_complete[] = { 496 INIT_COMPLETE_NOTIF, 497 CALIB_RES_NOTIF_PHY_DB 498 }; 499 int ret; 500 501 if (iwl_mvm_has_unified_ucode(mvm)) 502 return iwl_run_unified_mvm_ucode(mvm, true); 503 504 lockdep_assert_held(&mvm->mutex); 505 506 if (WARN_ON_ONCE(mvm->calibrating)) 507 return 0; 508 509 iwl_init_notification_wait(&mvm->notif_wait, 510 &calib_wait, 511 init_complete, 512 ARRAY_SIZE(init_complete), 513 iwl_wait_phy_db_entry, 514 mvm->phy_db); 515 516 /* Will also start the device */ 517 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); 518 if (ret) { 519 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); 520 goto remove_notif; 521 } 522 523 if (mvm->cfg->device_family < IWL_DEVICE_FAMILY_8000) { 524 ret = iwl_mvm_send_bt_init_conf(mvm); 525 if (ret) 526 goto remove_notif; 527 } 528 529 /* Read the NVM only at driver load time, no need to do this twice */ 530 if (read_nvm) { 531 ret = iwl_nvm_init(mvm); 532 if (ret) { 533 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 534 goto remove_notif; 535 } 536 } 537 538 /* In case we read the NVM from external file, load it to the NIC */ 539 if (mvm->nvm_file_name) 540 iwl_mvm_load_nvm_to_nic(mvm); 541 542 WARN_ON(iwl_nvm_check_version(mvm->nvm_data, mvm->trans)); 543 544 /* 545 * abort after reading the nvm in case RF Kill is on, we will complete 546 * the init seq later when RF kill will switch to off 547 */ 548 if (iwl_mvm_is_radio_hw_killed(mvm)) { 549 IWL_DEBUG_RF_KILL(mvm, 550 "jump over all phy activities due to RF kill\n"); 551 goto remove_notif; 552 } 553 554 mvm->calibrating = true; 555 556 /* Send TX valid antennas before triggering calibrations */ 557 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 558 if (ret) 559 goto remove_notif; 560 561 ret = iwl_send_phy_cfg_cmd(mvm); 562 if (ret) { 563 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", 564 ret); 565 goto remove_notif; 566 } 567 568 /* 569 * Some things may run in the background now, but we 570 * just wait for the calibration complete notification. 571 */ 572 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, 573 MVM_UCODE_CALIB_TIMEOUT); 574 if (!ret) 575 goto out; 576 577 if (iwl_mvm_is_radio_hw_killed(mvm)) { 578 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); 579 ret = 0; 580 } else { 581 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", 582 ret); 583 } 584 585 goto out; 586 587 remove_notif: 588 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 589 out: 590 mvm->calibrating = false; 591 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { 592 /* we want to debug INIT and we have no NVM - fake */ 593 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + 594 sizeof(struct ieee80211_channel) + 595 sizeof(struct ieee80211_rate), 596 GFP_KERNEL); 597 if (!mvm->nvm_data) 598 return -ENOMEM; 599 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; 600 mvm->nvm_data->bands[0].n_channels = 1; 601 mvm->nvm_data->bands[0].n_bitrates = 1; 602 mvm->nvm_data->bands[0].bitrates = 603 (void *)mvm->nvm_data->channels + 1; 604 mvm->nvm_data->bands[0].bitrates->hw_value = 10; 605 } 606 607 return ret; 608 } 609 610 static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) 611 { 612 struct iwl_ltr_config_cmd cmd = { 613 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), 614 }; 615 616 if (!mvm->trans->ltr_enabled) 617 return 0; 618 619 return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, 620 sizeof(cmd), &cmd); 621 } 622 623 #ifdef CONFIG_ACPI 624 static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm, 625 union acpi_object *table, 626 struct iwl_mvm_sar_profile *profile, 627 bool enabled) 628 { 629 int i; 630 631 profile->enabled = enabled; 632 633 for (i = 0; i < ACPI_SAR_TABLE_SIZE; i++) { 634 if ((table[i].type != ACPI_TYPE_INTEGER) || 635 (table[i].integer.value > U8_MAX)) 636 return -EINVAL; 637 638 profile->table[i] = table[i].integer.value; 639 } 640 641 return 0; 642 } 643 644 static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm) 645 { 646 union acpi_object *wifi_pkg, *table, *data; 647 bool enabled; 648 int ret; 649 650 data = iwl_acpi_get_object(mvm->dev, ACPI_WRDS_METHOD); 651 if (IS_ERR(data)) 652 return PTR_ERR(data); 653 654 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, 655 ACPI_WRDS_WIFI_DATA_SIZE); 656 if (IS_ERR(wifi_pkg)) { 657 ret = PTR_ERR(wifi_pkg); 658 goto out_free; 659 } 660 661 if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) { 662 ret = -EINVAL; 663 goto out_free; 664 } 665 666 enabled = !!(wifi_pkg->package.elements[1].integer.value); 667 668 /* position of the actual table */ 669 table = &wifi_pkg->package.elements[2]; 670 671 /* The profile from WRDS is officially profile 1, but goes 672 * into sar_profiles[0] (because we don't have a profile 0). 673 */ 674 ret = iwl_mvm_sar_set_profile(mvm, table, &mvm->sar_profiles[0], 675 enabled); 676 out_free: 677 kfree(data); 678 return ret; 679 } 680 681 static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm) 682 { 683 union acpi_object *wifi_pkg, *data; 684 bool enabled; 685 int i, n_profiles, ret; 686 687 data = iwl_acpi_get_object(mvm->dev, ACPI_EWRD_METHOD); 688 if (IS_ERR(data)) 689 return PTR_ERR(data); 690 691 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, 692 ACPI_EWRD_WIFI_DATA_SIZE); 693 if (IS_ERR(wifi_pkg)) { 694 ret = PTR_ERR(wifi_pkg); 695 goto out_free; 696 } 697 698 if ((wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) || 699 (wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER)) { 700 ret = -EINVAL; 701 goto out_free; 702 } 703 704 enabled = !!(wifi_pkg->package.elements[1].integer.value); 705 n_profiles = wifi_pkg->package.elements[2].integer.value; 706 707 /* in case of BIOS bug */ 708 if (n_profiles <= 0) { 709 ret = -EINVAL; 710 goto out_free; 711 } 712 713 for (i = 0; i < n_profiles; i++) { 714 /* the tables start at element 3 */ 715 static int pos = 3; 716 717 /* The EWRD profiles officially go from 2 to 4, but we 718 * save them in sar_profiles[1-3] (because we don't 719 * have profile 0). So in the array we start from 1. 720 */ 721 ret = iwl_mvm_sar_set_profile(mvm, 722 &wifi_pkg->package.elements[pos], 723 &mvm->sar_profiles[i + 1], 724 enabled); 725 if (ret < 0) 726 break; 727 728 /* go to the next table */ 729 pos += ACPI_SAR_TABLE_SIZE; 730 } 731 732 out_free: 733 kfree(data); 734 return ret; 735 } 736 737 static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm) 738 { 739 union acpi_object *wifi_pkg, *data; 740 int i, j, ret; 741 int idx = 1; 742 743 data = iwl_acpi_get_object(mvm->dev, ACPI_WGDS_METHOD); 744 if (IS_ERR(data)) 745 return PTR_ERR(data); 746 747 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, 748 ACPI_WGDS_WIFI_DATA_SIZE); 749 if (IS_ERR(wifi_pkg)) { 750 ret = PTR_ERR(wifi_pkg); 751 goto out_free; 752 } 753 754 for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) { 755 for (j = 0; j < ACPI_GEO_TABLE_SIZE; j++) { 756 union acpi_object *entry; 757 758 entry = &wifi_pkg->package.elements[idx++]; 759 if ((entry->type != ACPI_TYPE_INTEGER) || 760 (entry->integer.value > U8_MAX)) { 761 ret = -EINVAL; 762 goto out_free; 763 } 764 765 mvm->geo_profiles[i].values[j] = entry->integer.value; 766 } 767 } 768 ret = 0; 769 out_free: 770 kfree(data); 771 return ret; 772 } 773 774 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b) 775 { 776 struct iwl_dev_tx_power_cmd cmd = { 777 .v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS), 778 }; 779 int i, j, idx; 780 int profs[ACPI_SAR_NUM_CHAIN_LIMITS] = { prof_a, prof_b }; 781 int len = sizeof(cmd); 782 783 BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS < 2); 784 BUILD_BUG_ON(ACPI_SAR_NUM_CHAIN_LIMITS * ACPI_SAR_NUM_SUB_BANDS != 785 ACPI_SAR_TABLE_SIZE); 786 787 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) 788 len = sizeof(cmd.v3); 789 790 for (i = 0; i < ACPI_SAR_NUM_CHAIN_LIMITS; i++) { 791 struct iwl_mvm_sar_profile *prof; 792 793 /* don't allow SAR to be disabled (profile 0 means disable) */ 794 if (profs[i] == 0) 795 return -EPERM; 796 797 /* we are off by one, so allow up to ACPI_SAR_PROFILE_NUM */ 798 if (profs[i] > ACPI_SAR_PROFILE_NUM) 799 return -EINVAL; 800 801 /* profiles go from 1 to 4, so decrement to access the array */ 802 prof = &mvm->sar_profiles[profs[i] - 1]; 803 804 /* if the profile is disabled, do nothing */ 805 if (!prof->enabled) { 806 IWL_DEBUG_RADIO(mvm, "SAR profile %d is disabled.\n", 807 profs[i]); 808 /* if one of the profiles is disabled, we fail all */ 809 return -ENOENT; 810 } 811 812 IWL_DEBUG_RADIO(mvm, " Chain[%d]:\n", i); 813 for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) { 814 idx = (i * ACPI_SAR_NUM_SUB_BANDS) + j; 815 cmd.v3.per_chain_restriction[i][j] = 816 cpu_to_le16(prof->table[idx]); 817 IWL_DEBUG_RADIO(mvm, " Band[%d] = %d * .125dBm\n", 818 j, prof->table[idx]); 819 } 820 } 821 822 IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n"); 823 824 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); 825 } 826 827 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) 828 { 829 struct iwl_geo_tx_power_profiles_resp *resp; 830 int ret; 831 832 struct iwl_geo_tx_power_profiles_cmd geo_cmd = { 833 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE), 834 }; 835 struct iwl_host_cmd cmd = { 836 .id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT), 837 .len = { sizeof(geo_cmd), }, 838 .flags = CMD_WANT_SKB, 839 .data = { &geo_cmd }, 840 }; 841 842 ret = iwl_mvm_send_cmd(mvm, &cmd); 843 if (ret) { 844 IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret); 845 return ret; 846 } 847 848 resp = (void *)cmd.resp_pkt->data; 849 ret = le32_to_cpu(resp->profile_idx); 850 if (WARN_ON(ret > ACPI_NUM_GEO_PROFILES)) { 851 ret = -EIO; 852 IWL_WARN(mvm, "Invalid geographic profile idx (%d)\n", ret); 853 } 854 855 iwl_free_resp(&cmd); 856 return ret; 857 } 858 859 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) 860 { 861 struct iwl_geo_tx_power_profiles_cmd cmd = { 862 .ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES), 863 }; 864 int ret, i, j; 865 u16 cmd_wide_id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT); 866 867 ret = iwl_mvm_sar_get_wgds_table(mvm); 868 if (ret < 0) { 869 IWL_DEBUG_RADIO(mvm, 870 "Geo SAR BIOS table invalid or unavailable. (%d)\n", 871 ret); 872 /* we don't fail if the table is not available */ 873 return 0; 874 } 875 876 IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n"); 877 878 BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS * 879 ACPI_WGDS_TABLE_SIZE != ACPI_WGDS_WIFI_DATA_SIZE); 880 881 BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES > IWL_NUM_GEO_PROFILES); 882 883 for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) { 884 struct iwl_per_chain_offset *chain = 885 (struct iwl_per_chain_offset *)&cmd.table[i]; 886 887 for (j = 0; j < ACPI_WGDS_NUM_BANDS; j++) { 888 u8 *value; 889 890 value = &mvm->geo_profiles[i].values[j * 891 ACPI_GEO_PER_CHAIN_SIZE]; 892 chain[j].max_tx_power = cpu_to_le16(value[0]); 893 chain[j].chain_a = value[1]; 894 chain[j].chain_b = value[2]; 895 IWL_DEBUG_RADIO(mvm, 896 "SAR geographic profile[%d] Band[%d]: chain A = %d chain B = %d max_tx_power = %d\n", 897 i, j, value[1], value[2], value[0]); 898 } 899 } 900 return iwl_mvm_send_cmd_pdu(mvm, cmd_wide_id, 0, sizeof(cmd), &cmd); 901 } 902 903 #else /* CONFIG_ACPI */ 904 static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm) 905 { 906 return -ENOENT; 907 } 908 909 static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm) 910 { 911 return -ENOENT; 912 } 913 914 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) 915 { 916 return 0; 917 } 918 919 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, 920 int prof_b) 921 { 922 return -ENOENT; 923 } 924 925 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) 926 { 927 return -ENOENT; 928 } 929 #endif /* CONFIG_ACPI */ 930 931 static int iwl_mvm_sar_init(struct iwl_mvm *mvm) 932 { 933 int ret; 934 935 ret = iwl_mvm_sar_get_wrds_table(mvm); 936 if (ret < 0) { 937 IWL_DEBUG_RADIO(mvm, 938 "WRDS SAR BIOS table invalid or unavailable. (%d)\n", 939 ret); 940 /* if not available, don't fail and don't bother with EWRD */ 941 return 0; 942 } 943 944 ret = iwl_mvm_sar_get_ewrd_table(mvm); 945 /* if EWRD is not available, we can still use WRDS, so don't fail */ 946 if (ret < 0) 947 IWL_DEBUG_RADIO(mvm, 948 "EWRD SAR BIOS table invalid or unavailable. (%d)\n", 949 ret); 950 951 /* choose profile 1 (WRDS) as default for both chains */ 952 ret = iwl_mvm_sar_select_profile(mvm, 1, 1); 953 954 /* if we don't have profile 0 from BIOS, just skip it */ 955 if (ret == -ENOENT) 956 return 0; 957 958 return ret; 959 } 960 961 static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm) 962 { 963 int ret; 964 965 if (iwl_mvm_has_unified_ucode(mvm)) 966 return iwl_run_unified_mvm_ucode(mvm, false); 967 968 ret = iwl_run_init_mvm_ucode(mvm, false); 969 970 if (ret) { 971 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 972 973 if (iwlmvm_mod_params.init_dbg) 974 return 0; 975 return ret; 976 } 977 978 /* 979 * Stop and start the transport without entering low power 980 * mode. This will save the state of other components on the 981 * device that are triggered by the INIT firwmare (MFUART). 982 */ 983 _iwl_trans_stop_device(mvm->trans, false); 984 ret = _iwl_trans_start_hw(mvm->trans, false); 985 if (ret) 986 return ret; 987 988 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); 989 if (ret) 990 return ret; 991 992 return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img); 993 } 994 995 int iwl_mvm_up(struct iwl_mvm *mvm) 996 { 997 int ret, i; 998 struct ieee80211_channel *chan; 999 struct cfg80211_chan_def chandef; 1000 1001 lockdep_assert_held(&mvm->mutex); 1002 1003 ret = iwl_trans_start_hw(mvm->trans); 1004 if (ret) 1005 return ret; 1006 1007 ret = iwl_mvm_load_rt_fw(mvm); 1008 if (ret) { 1009 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 1010 goto error; 1011 } 1012 1013 iwl_get_shared_mem_conf(&mvm->fwrt); 1014 1015 ret = iwl_mvm_sf_update(mvm, NULL, false); 1016 if (ret) 1017 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); 1018 1019 mvm->fwrt.dump.conf = FW_DBG_INVALID; 1020 /* if we have a destination, assume EARLY START */ 1021 if (mvm->fw->dbg_dest_tlv) 1022 mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE; 1023 iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE); 1024 1025 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 1026 if (ret) 1027 goto error; 1028 1029 if (!iwl_mvm_has_unified_ucode(mvm)) { 1030 /* Send phy db control command and then phy db calibration */ 1031 ret = iwl_send_phy_db_data(mvm->phy_db); 1032 if (ret) 1033 goto error; 1034 1035 ret = iwl_send_phy_cfg_cmd(mvm); 1036 if (ret) 1037 goto error; 1038 } 1039 1040 ret = iwl_mvm_send_bt_init_conf(mvm); 1041 if (ret) 1042 goto error; 1043 1044 /* Init RSS configuration */ 1045 if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) { 1046 ret = iwl_configure_rxq(mvm); 1047 if (ret) { 1048 IWL_ERR(mvm, "Failed to configure RX queues: %d\n", 1049 ret); 1050 goto error; 1051 } 1052 } 1053 1054 if (iwl_mvm_has_new_rx_api(mvm)) { 1055 ret = iwl_send_rss_cfg_cmd(mvm); 1056 if (ret) { 1057 IWL_ERR(mvm, "Failed to configure RSS queues: %d\n", 1058 ret); 1059 goto error; 1060 } 1061 } 1062 1063 /* init the fw <-> mac80211 STA mapping */ 1064 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) 1065 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); 1066 1067 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA; 1068 1069 /* reset quota debouncing buffer - 0xff will yield invalid data */ 1070 memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd)); 1071 1072 ret = iwl_mvm_send_dqa_cmd(mvm); 1073 if (ret) 1074 goto error; 1075 1076 /* Add auxiliary station for scanning */ 1077 ret = iwl_mvm_add_aux_sta(mvm); 1078 if (ret) 1079 goto error; 1080 1081 /* Add all the PHY contexts */ 1082 chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0]; 1083 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); 1084 for (i = 0; i < NUM_PHY_CTX; i++) { 1085 /* 1086 * The channel used here isn't relevant as it's 1087 * going to be overwritten in the other flows. 1088 * For now use the first channel we have. 1089 */ 1090 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], 1091 &chandef, 1, 1); 1092 if (ret) 1093 goto error; 1094 } 1095 1096 #ifdef CONFIG_THERMAL 1097 if (iwl_mvm_is_tt_in_fw(mvm)) { 1098 /* in order to give the responsibility of ct-kill and 1099 * TX backoff to FW we need to send empty temperature reporting 1100 * cmd during init time 1101 */ 1102 iwl_mvm_send_temp_report_ths_cmd(mvm); 1103 } else { 1104 /* Initialize tx backoffs to the minimal possible */ 1105 iwl_mvm_tt_tx_backoff(mvm, 0); 1106 } 1107 1108 /* TODO: read the budget from BIOS / Platform NVM */ 1109 1110 /* 1111 * In case there is no budget from BIOS / Platform NVM the default 1112 * budget should be 2000mW (cooling state 0). 1113 */ 1114 if (iwl_mvm_is_ctdp_supported(mvm)) { 1115 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, 1116 mvm->cooling_dev.cur_state); 1117 if (ret) 1118 goto error; 1119 } 1120 #else 1121 /* Initialize tx backoffs to the minimal possible */ 1122 iwl_mvm_tt_tx_backoff(mvm, 0); 1123 #endif 1124 1125 WARN_ON(iwl_mvm_config_ltr(mvm)); 1126 1127 ret = iwl_mvm_power_update_device(mvm); 1128 if (ret) 1129 goto error; 1130 1131 /* 1132 * RTNL is not taken during Ct-kill, but we don't need to scan/Tx 1133 * anyway, so don't init MCC. 1134 */ 1135 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) { 1136 ret = iwl_mvm_init_mcc(mvm); 1137 if (ret) 1138 goto error; 1139 } 1140 1141 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { 1142 mvm->scan_type = IWL_SCAN_TYPE_NOT_SET; 1143 mvm->hb_scan_type = IWL_SCAN_TYPE_NOT_SET; 1144 ret = iwl_mvm_config_scan(mvm); 1145 if (ret) 1146 goto error; 1147 } 1148 1149 /* allow FW/transport low power modes if not during restart */ 1150 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) 1151 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); 1152 1153 ret = iwl_mvm_sar_init(mvm); 1154 if (ret) 1155 goto error; 1156 1157 ret = iwl_mvm_sar_geo_init(mvm); 1158 if (ret) 1159 goto error; 1160 1161 iwl_mvm_leds_sync(mvm); 1162 1163 IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); 1164 return 0; 1165 error: 1166 if (!iwlmvm_mod_params.init_dbg || !ret) 1167 iwl_mvm_stop_device(mvm); 1168 return ret; 1169 } 1170 1171 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) 1172 { 1173 int ret, i; 1174 1175 lockdep_assert_held(&mvm->mutex); 1176 1177 ret = iwl_trans_start_hw(mvm->trans); 1178 if (ret) 1179 return ret; 1180 1181 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); 1182 if (ret) { 1183 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); 1184 goto error; 1185 } 1186 1187 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 1188 if (ret) 1189 goto error; 1190 1191 /* Send phy db control command and then phy db calibration*/ 1192 ret = iwl_send_phy_db_data(mvm->phy_db); 1193 if (ret) 1194 goto error; 1195 1196 ret = iwl_send_phy_cfg_cmd(mvm); 1197 if (ret) 1198 goto error; 1199 1200 /* init the fw <-> mac80211 STA mapping */ 1201 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) 1202 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); 1203 1204 /* Add auxiliary station for scanning */ 1205 ret = iwl_mvm_add_aux_sta(mvm); 1206 if (ret) 1207 goto error; 1208 1209 return 0; 1210 error: 1211 iwl_mvm_stop_device(mvm); 1212 return ret; 1213 } 1214 1215 void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, 1216 struct iwl_rx_cmd_buffer *rxb) 1217 { 1218 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1219 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; 1220 u32 flags = le32_to_cpu(card_state_notif->flags); 1221 1222 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", 1223 (flags & HW_CARD_DISABLED) ? "Kill" : "On", 1224 (flags & SW_CARD_DISABLED) ? "Kill" : "On", 1225 (flags & CT_KILL_CARD_DISABLED) ? 1226 "Reached" : "Not reached"); 1227 } 1228 1229 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, 1230 struct iwl_rx_cmd_buffer *rxb) 1231 { 1232 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1233 struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data; 1234 1235 IWL_DEBUG_INFO(mvm, 1236 "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n", 1237 le32_to_cpu(mfuart_notif->installed_ver), 1238 le32_to_cpu(mfuart_notif->external_ver), 1239 le32_to_cpu(mfuart_notif->status), 1240 le32_to_cpu(mfuart_notif->duration)); 1241 1242 if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif)) 1243 IWL_DEBUG_INFO(mvm, 1244 "MFUART: image size: 0x%08x\n", 1245 le32_to_cpu(mfuart_notif->image_size)); 1246 } 1247