1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 /* 3 * Copyright (C) 2012-2014, 2018-2020 Intel Corporation 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 */ 7 #include <net/mac80211.h> 8 #include <linux/netdevice.h> 9 #include <linux/dmi.h> 10 11 #include "iwl-trans.h" 12 #include "iwl-op-mode.h" 13 #include "fw/img.h" 14 #include "iwl-debug.h" 15 #include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */ 16 #include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */ 17 #include "iwl-prph.h" 18 #include "fw/acpi.h" 19 #include "fw/pnvm.h" 20 21 #include "mvm.h" 22 #include "fw/dbg.h" 23 #include "iwl-phy-db.h" 24 #include "iwl-modparams.h" 25 #include "iwl-nvm-parse.h" 26 27 #define MVM_UCODE_ALIVE_TIMEOUT (HZ) 28 #define MVM_UCODE_CALIB_TIMEOUT (2 * HZ) 29 30 #define UCODE_VALID_OK cpu_to_le32(0x1) 31 32 struct iwl_mvm_alive_data { 33 bool valid; 34 u32 scd_base_addr; 35 }; 36 37 static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant) 38 { 39 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = { 40 .valid = cpu_to_le32(valid_tx_ant), 41 }; 42 43 IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant); 44 return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0, 45 sizeof(tx_ant_cmd), &tx_ant_cmd); 46 } 47 48 static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) 49 { 50 int i; 51 struct iwl_rss_config_cmd cmd = { 52 .flags = cpu_to_le32(IWL_RSS_ENABLE), 53 .hash_mask = BIT(IWL_RSS_HASH_TYPE_IPV4_TCP) | 54 BIT(IWL_RSS_HASH_TYPE_IPV4_UDP) | 55 BIT(IWL_RSS_HASH_TYPE_IPV4_PAYLOAD) | 56 BIT(IWL_RSS_HASH_TYPE_IPV6_TCP) | 57 BIT(IWL_RSS_HASH_TYPE_IPV6_UDP) | 58 BIT(IWL_RSS_HASH_TYPE_IPV6_PAYLOAD), 59 }; 60 61 if (mvm->trans->num_rx_queues == 1) 62 return 0; 63 64 /* Do not direct RSS traffic to Q 0 which is our fallback queue */ 65 for (i = 0; i < ARRAY_SIZE(cmd.indirection_table); i++) 66 cmd.indirection_table[i] = 67 1 + (i % (mvm->trans->num_rx_queues - 1)); 68 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key)); 69 70 return iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd); 71 } 72 73 static int iwl_configure_rxq(struct iwl_mvm *mvm) 74 { 75 int i, num_queues, size, ret; 76 struct iwl_rfh_queue_config *cmd; 77 struct iwl_host_cmd hcmd = { 78 .id = WIDE_ID(DATA_PATH_GROUP, RFH_QUEUE_CONFIG_CMD), 79 .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 80 }; 81 82 /* 83 * The default queue is configured via context info, so if we 84 * have a single queue, there's nothing to do here. 85 */ 86 if (mvm->trans->num_rx_queues == 1) 87 return 0; 88 89 /* skip the default queue */ 90 num_queues = mvm->trans->num_rx_queues - 1; 91 92 size = struct_size(cmd, data, num_queues); 93 94 cmd = kzalloc(size, GFP_KERNEL); 95 if (!cmd) 96 return -ENOMEM; 97 98 cmd->num_queues = num_queues; 99 100 for (i = 0; i < num_queues; i++) { 101 struct iwl_trans_rxq_dma_data data; 102 103 cmd->data[i].q_num = i + 1; 104 iwl_trans_get_rxq_dma_data(mvm->trans, i + 1, &data); 105 106 cmd->data[i].fr_bd_cb = cpu_to_le64(data.fr_bd_cb); 107 cmd->data[i].urbd_stts_wrptr = 108 cpu_to_le64(data.urbd_stts_wrptr); 109 cmd->data[i].ur_bd_cb = cpu_to_le64(data.ur_bd_cb); 110 cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid); 111 } 112 113 hcmd.data[0] = cmd; 114 hcmd.len[0] = size; 115 116 ret = iwl_mvm_send_cmd(mvm, &hcmd); 117 118 kfree(cmd); 119 120 return ret; 121 } 122 123 static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm) 124 { 125 struct iwl_dqa_enable_cmd dqa_cmd = { 126 .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE), 127 }; 128 u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0); 129 int ret; 130 131 ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, sizeof(dqa_cmd), &dqa_cmd); 132 if (ret) 133 IWL_ERR(mvm, "Failed to send DQA enabling command: %d\n", ret); 134 else 135 IWL_DEBUG_FW(mvm, "Working in DQA mode\n"); 136 137 return ret; 138 } 139 140 void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm, 141 struct iwl_rx_cmd_buffer *rxb) 142 { 143 struct iwl_rx_packet *pkt = rxb_addr(rxb); 144 struct iwl_mfu_assert_dump_notif *mfu_dump_notif = (void *)pkt->data; 145 __le32 *dump_data = mfu_dump_notif->data; 146 int n_words = le32_to_cpu(mfu_dump_notif->data_size) / sizeof(__le32); 147 int i; 148 149 if (mfu_dump_notif->index_num == 0) 150 IWL_INFO(mvm, "MFUART assert id 0x%x occurred\n", 151 le32_to_cpu(mfu_dump_notif->assert_id)); 152 153 for (i = 0; i < n_words; i++) 154 IWL_DEBUG_INFO(mvm, 155 "MFUART assert dump, dword %u: 0x%08x\n", 156 le16_to_cpu(mfu_dump_notif->index_num) * 157 n_words + i, 158 le32_to_cpu(dump_data[i])); 159 } 160 161 static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, 162 struct iwl_rx_packet *pkt, void *data) 163 { 164 unsigned int pkt_len = iwl_rx_packet_payload_len(pkt); 165 struct iwl_mvm *mvm = 166 container_of(notif_wait, struct iwl_mvm, notif_wait); 167 struct iwl_mvm_alive_data *alive_data = data; 168 struct iwl_umac_alive *umac; 169 struct iwl_lmac_alive *lmac1; 170 struct iwl_lmac_alive *lmac2 = NULL; 171 u16 status; 172 u32 lmac_error_event_table, umac_error_table; 173 174 /* 175 * For v5 and above, we can check the version, for older 176 * versions we need to check the size. 177 */ 178 if (iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP, 179 UCODE_ALIVE_NTFY, 0) == 5) { 180 struct iwl_alive_ntf_v5 *palive; 181 182 if (pkt_len < sizeof(*palive)) 183 return false; 184 185 palive = (void *)pkt->data; 186 umac = &palive->umac_data; 187 lmac1 = &palive->lmac_data[0]; 188 lmac2 = &palive->lmac_data[1]; 189 status = le16_to_cpu(palive->status); 190 191 mvm->trans->sku_id[0] = le32_to_cpu(palive->sku_id.data[0]); 192 mvm->trans->sku_id[1] = le32_to_cpu(palive->sku_id.data[1]); 193 mvm->trans->sku_id[2] = le32_to_cpu(palive->sku_id.data[2]); 194 195 IWL_DEBUG_FW(mvm, "Got sku_id: 0x0%x 0x0%x 0x0%x\n", 196 mvm->trans->sku_id[0], 197 mvm->trans->sku_id[1], 198 mvm->trans->sku_id[2]); 199 } else if (iwl_rx_packet_payload_len(pkt) == sizeof(struct iwl_alive_ntf_v4)) { 200 struct iwl_alive_ntf_v4 *palive; 201 202 if (pkt_len < sizeof(*palive)) 203 return false; 204 205 palive = (void *)pkt->data; 206 umac = &palive->umac_data; 207 lmac1 = &palive->lmac_data[0]; 208 lmac2 = &palive->lmac_data[1]; 209 status = le16_to_cpu(palive->status); 210 } else if (iwl_rx_packet_payload_len(pkt) == 211 sizeof(struct iwl_alive_ntf_v3)) { 212 struct iwl_alive_ntf_v3 *palive3; 213 214 if (pkt_len < sizeof(*palive3)) 215 return false; 216 217 palive3 = (void *)pkt->data; 218 umac = &palive3->umac_data; 219 lmac1 = &palive3->lmac_data; 220 status = le16_to_cpu(palive3->status); 221 } else { 222 WARN(1, "unsupported alive notification (size %d)\n", 223 iwl_rx_packet_payload_len(pkt)); 224 /* get timeout later */ 225 return false; 226 } 227 228 lmac_error_event_table = 229 le32_to_cpu(lmac1->dbg_ptrs.error_event_table_ptr); 230 iwl_fw_lmac1_set_alive_err_table(mvm->trans, lmac_error_event_table); 231 232 if (lmac2) 233 mvm->trans->dbg.lmac_error_event_table[1] = 234 le32_to_cpu(lmac2->dbg_ptrs.error_event_table_ptr); 235 236 umac_error_table = le32_to_cpu(umac->dbg_ptrs.error_info_addr); 237 238 if (umac_error_table) { 239 if (umac_error_table >= 240 mvm->trans->cfg->min_umac_error_event_table) { 241 iwl_fw_umac_set_alive_err_table(mvm->trans, 242 umac_error_table); 243 } else { 244 IWL_ERR(mvm, 245 "Not valid error log pointer 0x%08X for %s uCode\n", 246 umac_error_table, 247 (mvm->fwrt.cur_fw_img == IWL_UCODE_INIT) ? 248 "Init" : "RT"); 249 } 250 } 251 252 alive_data->scd_base_addr = le32_to_cpu(lmac1->dbg_ptrs.scd_base_ptr); 253 alive_data->valid = status == IWL_ALIVE_STATUS_OK; 254 255 IWL_DEBUG_FW(mvm, 256 "Alive ucode status 0x%04x revision 0x%01X 0x%01X\n", 257 status, lmac1->ver_type, lmac1->ver_subtype); 258 259 if (lmac2) 260 IWL_DEBUG_FW(mvm, "Alive ucode CDB\n"); 261 262 IWL_DEBUG_FW(mvm, 263 "UMAC version: Major - 0x%x, Minor - 0x%x\n", 264 le32_to_cpu(umac->umac_major), 265 le32_to_cpu(umac->umac_minor)); 266 267 iwl_fwrt_update_fw_versions(&mvm->fwrt, lmac1, umac); 268 269 return true; 270 } 271 272 static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait, 273 struct iwl_rx_packet *pkt, void *data) 274 { 275 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); 276 277 return true; 278 } 279 280 static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait, 281 struct iwl_rx_packet *pkt, void *data) 282 { 283 struct iwl_phy_db *phy_db = data; 284 285 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) { 286 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF); 287 return true; 288 } 289 290 WARN_ON(iwl_phy_db_set_section(phy_db, pkt)); 291 292 return false; 293 } 294 295 static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm, 296 enum iwl_ucode_type ucode_type) 297 { 298 struct iwl_notification_wait alive_wait; 299 struct iwl_mvm_alive_data alive_data = {}; 300 const struct fw_img *fw; 301 int ret; 302 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img; 303 static const u16 alive_cmd[] = { UCODE_ALIVE_NTFY }; 304 bool run_in_rfkill = 305 ucode_type == IWL_UCODE_INIT || iwl_mvm_has_unified_ucode(mvm); 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 /* 324 * We want to load the INIT firmware even in RFKILL 325 * For the unified firmware case, the ucode_type is not 326 * INIT, but we still need to run it. 327 */ 328 ret = iwl_trans_start_fw(mvm->trans, fw, run_in_rfkill); 329 if (ret) { 330 iwl_fw_set_current_image(&mvm->fwrt, old_type); 331 iwl_remove_notification(&mvm->notif_wait, &alive_wait); 332 return ret; 333 } 334 335 /* 336 * Some things may run in the background now, but we 337 * just wait for the ALIVE notification here. 338 */ 339 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait, 340 MVM_UCODE_ALIVE_TIMEOUT); 341 if (ret) { 342 struct iwl_trans *trans = mvm->trans; 343 344 if (trans->trans_cfg->device_family >= 345 IWL_DEVICE_FAMILY_22000) { 346 IWL_ERR(mvm, 347 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", 348 iwl_read_umac_prph(trans, UMAG_SB_CPU_1_STATUS), 349 iwl_read_umac_prph(trans, 350 UMAG_SB_CPU_2_STATUS)); 351 IWL_ERR(mvm, "UMAC PC: 0x%x\n", 352 iwl_read_umac_prph(trans, 353 UREG_UMAC_CURRENT_PC)); 354 IWL_ERR(mvm, "LMAC PC: 0x%x\n", 355 iwl_read_umac_prph(trans, 356 UREG_LMAC1_CURRENT_PC)); 357 if (iwl_mvm_is_cdb_supported(mvm)) 358 IWL_ERR(mvm, "LMAC2 PC: 0x%x\n", 359 iwl_read_umac_prph(trans, 360 UREG_LMAC2_CURRENT_PC)); 361 } else if (trans->trans_cfg->device_family >= 362 IWL_DEVICE_FAMILY_8000) { 363 IWL_ERR(mvm, 364 "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n", 365 iwl_read_prph(trans, SB_CPU_1_STATUS), 366 iwl_read_prph(trans, SB_CPU_2_STATUS)); 367 } 368 369 if (ret == -ETIMEDOUT) 370 iwl_fw_dbg_error_collect(&mvm->fwrt, 371 FW_DBG_TRIGGER_ALIVE_TIMEOUT); 372 373 iwl_fw_set_current_image(&mvm->fwrt, old_type); 374 return ret; 375 } 376 377 if (!alive_data.valid) { 378 IWL_ERR(mvm, "Loaded ucode is not valid!\n"); 379 iwl_fw_set_current_image(&mvm->fwrt, old_type); 380 return -EIO; 381 } 382 383 ret = iwl_pnvm_load(mvm->trans, &mvm->notif_wait); 384 if (ret) { 385 IWL_ERR(mvm, "Timeout waiting for PNVM load!\n"); 386 iwl_fw_set_current_image(&mvm->fwrt, old_type); 387 return ret; 388 } 389 390 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); 391 392 /* 393 * Note: all the queues are enabled as part of the interface 394 * initialization, but in firmware restart scenarios they 395 * could be stopped, so wake them up. In firmware restart, 396 * mac80211 will have the queues stopped as well until the 397 * reconfiguration completes. During normal startup, they 398 * will be empty. 399 */ 400 401 memset(&mvm->queue_info, 0, sizeof(mvm->queue_info)); 402 /* 403 * Set a 'fake' TID for the command queue, since we use the 404 * hweight() of the tid_bitmap as a refcount now. Not that 405 * we ever even consider the command queue as one we might 406 * want to reuse, but be safe nevertheless. 407 */ 408 mvm->queue_info[IWL_MVM_DQA_CMD_QUEUE].tid_bitmap = 409 BIT(IWL_MAX_TID_COUNT + 2); 410 411 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 412 #ifdef CONFIG_IWLWIFI_DEBUGFS 413 iwl_fw_set_dbg_rec_on(&mvm->fwrt); 414 #endif 415 416 /* 417 * All the BSSes in the BSS table include the GP2 in the system 418 * at the beacon Rx time, this is of course no longer relevant 419 * since we are resetting the firmware. 420 * Purge all the BSS table. 421 */ 422 cfg80211_bss_flush(mvm->hw->wiphy); 423 424 return 0; 425 } 426 427 static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm) 428 { 429 struct iwl_notification_wait init_wait; 430 struct iwl_nvm_access_complete_cmd nvm_complete = {}; 431 struct iwl_init_extended_cfg_cmd init_cfg = { 432 .init_flags = cpu_to_le32(BIT(IWL_INIT_NVM)), 433 }; 434 static const u16 init_complete[] = { 435 INIT_COMPLETE_NOTIF, 436 }; 437 int ret; 438 439 if (mvm->trans->cfg->tx_with_siso_diversity) 440 init_cfg.init_flags |= cpu_to_le32(BIT(IWL_INIT_PHY)); 441 442 lockdep_assert_held(&mvm->mutex); 443 444 mvm->rfkill_safe_init_done = false; 445 446 iwl_init_notification_wait(&mvm->notif_wait, 447 &init_wait, 448 init_complete, 449 ARRAY_SIZE(init_complete), 450 iwl_wait_init_complete, 451 NULL); 452 453 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_EARLY, NULL); 454 455 /* Will also start the device */ 456 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); 457 if (ret) { 458 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 459 goto error; 460 } 461 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_AFTER_ALIVE, 462 NULL); 463 464 /* Send init config command to mark that we are sending NVM access 465 * commands 466 */ 467 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(SYSTEM_GROUP, 468 INIT_EXTENDED_CFG_CMD), 469 CMD_SEND_IN_RFKILL, 470 sizeof(init_cfg), &init_cfg); 471 if (ret) { 472 IWL_ERR(mvm, "Failed to run init config command: %d\n", 473 ret); 474 goto error; 475 } 476 477 /* Load NVM to NIC if needed */ 478 if (mvm->nvm_file_name) { 479 ret = iwl_read_external_nvm(mvm->trans, mvm->nvm_file_name, 480 mvm->nvm_sections); 481 if (ret) 482 goto error; 483 ret = iwl_mvm_load_nvm_to_nic(mvm); 484 if (ret) 485 goto error; 486 } 487 488 if (IWL_MVM_PARSE_NVM && !mvm->nvm_data) { 489 ret = iwl_nvm_init(mvm); 490 if (ret) { 491 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 492 goto error; 493 } 494 } 495 496 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP, 497 NVM_ACCESS_COMPLETE), 498 CMD_SEND_IN_RFKILL, 499 sizeof(nvm_complete), &nvm_complete); 500 if (ret) { 501 IWL_ERR(mvm, "Failed to run complete NVM access: %d\n", 502 ret); 503 goto error; 504 } 505 506 /* We wait for the INIT complete notification */ 507 ret = iwl_wait_notification(&mvm->notif_wait, &init_wait, 508 MVM_UCODE_ALIVE_TIMEOUT); 509 if (ret) 510 return ret; 511 512 /* Read the NVM only at driver load time, no need to do this twice */ 513 if (!IWL_MVM_PARSE_NVM && !mvm->nvm_data) { 514 mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw); 515 if (IS_ERR(mvm->nvm_data)) { 516 ret = PTR_ERR(mvm->nvm_data); 517 mvm->nvm_data = NULL; 518 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 519 return ret; 520 } 521 } 522 523 mvm->rfkill_safe_init_done = true; 524 525 return 0; 526 527 error: 528 iwl_remove_notification(&mvm->notif_wait, &init_wait); 529 return ret; 530 } 531 532 #ifdef CONFIG_ACPI 533 static void iwl_mvm_phy_filter_init(struct iwl_mvm *mvm, 534 struct iwl_phy_specific_cfg *phy_filters) 535 { 536 /* 537 * TODO: read specific phy config from BIOS 538 * ACPI table for this feature has not been defined yet, 539 * so for now we use hardcoded values. 540 */ 541 542 if (IWL_MVM_PHY_FILTER_CHAIN_A) { 543 phy_filters->filter_cfg_chain_a = 544 cpu_to_le32(IWL_MVM_PHY_FILTER_CHAIN_A); 545 } 546 if (IWL_MVM_PHY_FILTER_CHAIN_B) { 547 phy_filters->filter_cfg_chain_b = 548 cpu_to_le32(IWL_MVM_PHY_FILTER_CHAIN_B); 549 } 550 if (IWL_MVM_PHY_FILTER_CHAIN_C) { 551 phy_filters->filter_cfg_chain_c = 552 cpu_to_le32(IWL_MVM_PHY_FILTER_CHAIN_C); 553 } 554 if (IWL_MVM_PHY_FILTER_CHAIN_D) { 555 phy_filters->filter_cfg_chain_d = 556 cpu_to_le32(IWL_MVM_PHY_FILTER_CHAIN_D); 557 } 558 } 559 560 #else /* CONFIG_ACPI */ 561 562 static void iwl_mvm_phy_filter_init(struct iwl_mvm *mvm, 563 struct iwl_phy_specific_cfg *phy_filters) 564 { 565 } 566 #endif /* CONFIG_ACPI */ 567 568 static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm) 569 { 570 struct iwl_phy_cfg_cmd_v3 phy_cfg_cmd; 571 enum iwl_ucode_type ucode_type = mvm->fwrt.cur_fw_img; 572 struct iwl_phy_specific_cfg phy_filters = {}; 573 u8 cmd_ver; 574 size_t cmd_size; 575 576 if (iwl_mvm_has_unified_ucode(mvm) && 577 !mvm->trans->cfg->tx_with_siso_diversity) 578 return 0; 579 580 if (mvm->trans->cfg->tx_with_siso_diversity) { 581 /* 582 * TODO: currently we don't set the antenna but letting the NIC 583 * to decide which antenna to use. This should come from BIOS. 584 */ 585 phy_cfg_cmd.phy_cfg = 586 cpu_to_le32(FW_PHY_CFG_CHAIN_SAD_ENABLED); 587 } 588 589 /* Set parameters */ 590 phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm)); 591 592 /* set flags extra PHY configuration flags from the device's cfg */ 593 phy_cfg_cmd.phy_cfg |= 594 cpu_to_le32(mvm->trans->trans_cfg->extra_phy_cfg_flags); 595 596 phy_cfg_cmd.calib_control.event_trigger = 597 mvm->fw->default_calib[ucode_type].event_trigger; 598 phy_cfg_cmd.calib_control.flow_trigger = 599 mvm->fw->default_calib[ucode_type].flow_trigger; 600 601 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP, 602 PHY_CONFIGURATION_CMD, 603 IWL_FW_CMD_VER_UNKNOWN); 604 if (cmd_ver == 3) { 605 iwl_mvm_phy_filter_init(mvm, &phy_filters); 606 memcpy(&phy_cfg_cmd.phy_specific_cfg, &phy_filters, 607 sizeof(struct iwl_phy_specific_cfg)); 608 } 609 610 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n", 611 phy_cfg_cmd.phy_cfg); 612 cmd_size = (cmd_ver == 3) ? sizeof(struct iwl_phy_cfg_cmd_v3) : 613 sizeof(struct iwl_phy_cfg_cmd_v1); 614 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0, 615 cmd_size, &phy_cfg_cmd); 616 } 617 618 int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm) 619 { 620 struct iwl_notification_wait calib_wait; 621 static const u16 init_complete[] = { 622 INIT_COMPLETE_NOTIF, 623 CALIB_RES_NOTIF_PHY_DB 624 }; 625 int ret; 626 627 if (iwl_mvm_has_unified_ucode(mvm)) 628 return iwl_run_unified_mvm_ucode(mvm); 629 630 lockdep_assert_held(&mvm->mutex); 631 632 mvm->rfkill_safe_init_done = false; 633 634 iwl_init_notification_wait(&mvm->notif_wait, 635 &calib_wait, 636 init_complete, 637 ARRAY_SIZE(init_complete), 638 iwl_wait_phy_db_entry, 639 mvm->phy_db); 640 641 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_EARLY, NULL); 642 643 /* Will also start the device */ 644 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT); 645 if (ret) { 646 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret); 647 goto remove_notif; 648 } 649 650 if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_8000) { 651 ret = iwl_mvm_send_bt_init_conf(mvm); 652 if (ret) 653 goto remove_notif; 654 } 655 656 /* Read the NVM only at driver load time, no need to do this twice */ 657 if (!mvm->nvm_data) { 658 ret = iwl_nvm_init(mvm); 659 if (ret) { 660 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 661 goto remove_notif; 662 } 663 } 664 665 /* In case we read the NVM from external file, load it to the NIC */ 666 if (mvm->nvm_file_name) { 667 ret = iwl_mvm_load_nvm_to_nic(mvm); 668 if (ret) 669 goto remove_notif; 670 } 671 672 WARN_ONCE(mvm->nvm_data->nvm_version < mvm->trans->cfg->nvm_ver, 673 "Too old NVM version (0x%0x, required = 0x%0x)", 674 mvm->nvm_data->nvm_version, mvm->trans->cfg->nvm_ver); 675 676 /* 677 * abort after reading the nvm in case RF Kill is on, we will complete 678 * the init seq later when RF kill will switch to off 679 */ 680 if (iwl_mvm_is_radio_hw_killed(mvm)) { 681 IWL_DEBUG_RF_KILL(mvm, 682 "jump over all phy activities due to RF kill\n"); 683 goto remove_notif; 684 } 685 686 mvm->rfkill_safe_init_done = true; 687 688 /* Send TX valid antennas before triggering calibrations */ 689 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 690 if (ret) 691 goto remove_notif; 692 693 ret = iwl_send_phy_cfg_cmd(mvm); 694 if (ret) { 695 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", 696 ret); 697 goto remove_notif; 698 } 699 700 /* 701 * Some things may run in the background now, but we 702 * just wait for the calibration complete notification. 703 */ 704 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, 705 MVM_UCODE_CALIB_TIMEOUT); 706 if (!ret) 707 goto out; 708 709 if (iwl_mvm_is_radio_hw_killed(mvm)) { 710 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); 711 ret = 0; 712 } else { 713 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n", 714 ret); 715 } 716 717 goto out; 718 719 remove_notif: 720 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 721 out: 722 mvm->rfkill_safe_init_done = false; 723 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { 724 /* we want to debug INIT and we have no NVM - fake */ 725 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + 726 sizeof(struct ieee80211_channel) + 727 sizeof(struct ieee80211_rate), 728 GFP_KERNEL); 729 if (!mvm->nvm_data) 730 return -ENOMEM; 731 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels; 732 mvm->nvm_data->bands[0].n_channels = 1; 733 mvm->nvm_data->bands[0].n_bitrates = 1; 734 mvm->nvm_data->bands[0].bitrates = 735 (void *)mvm->nvm_data->channels + 1; 736 mvm->nvm_data->bands[0].bitrates->hw_value = 10; 737 } 738 739 return ret; 740 } 741 742 static int iwl_mvm_config_ltr(struct iwl_mvm *mvm) 743 { 744 struct iwl_ltr_config_cmd cmd = { 745 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE), 746 }; 747 748 if (!mvm->trans->ltr_enabled) 749 return 0; 750 751 return iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, 752 sizeof(cmd), &cmd); 753 } 754 755 #ifdef CONFIG_ACPI 756 int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b) 757 { 758 struct iwl_dev_tx_power_cmd cmd = { 759 .common.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_CHAINS), 760 }; 761 __le16 *per_chain; 762 int ret; 763 u16 len = 0; 764 u32 n_subbands; 765 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, LONG_GROUP, 766 REDUCE_TX_POWER_CMD, 767 IWL_FW_CMD_VER_UNKNOWN); 768 769 if (cmd_ver == 6) { 770 len = sizeof(cmd.v6); 771 n_subbands = IWL_NUM_SUB_BANDS_V2; 772 per_chain = cmd.v6.per_chain[0][0]; 773 } else if (fw_has_api(&mvm->fw->ucode_capa, 774 IWL_UCODE_TLV_API_REDUCE_TX_POWER)) { 775 len = sizeof(cmd.v5); 776 n_subbands = IWL_NUM_SUB_BANDS; 777 per_chain = cmd.v5.per_chain[0][0]; 778 } else if (fw_has_capa(&mvm->fw->ucode_capa, 779 IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) { 780 len = sizeof(cmd.v4); 781 n_subbands = IWL_NUM_SUB_BANDS; 782 per_chain = cmd.v4.per_chain[0][0]; 783 } else { 784 len = sizeof(cmd.v3); 785 n_subbands = IWL_NUM_SUB_BANDS; 786 per_chain = cmd.v3.per_chain[0][0]; 787 } 788 789 /* all structs have the same common part, add it */ 790 len += sizeof(cmd.common); 791 792 ret = iwl_sar_select_profile(&mvm->fwrt, per_chain, ACPI_SAR_NUM_TABLES, 793 n_subbands, prof_a, prof_b); 794 795 /* return on error or if the profile is disabled (positive number) */ 796 if (ret) 797 return ret; 798 799 IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n"); 800 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); 801 } 802 803 int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) 804 { 805 union iwl_geo_tx_power_profiles_cmd geo_tx_cmd; 806 struct iwl_geo_tx_power_profiles_resp *resp; 807 u16 len; 808 int ret; 809 struct iwl_host_cmd cmd; 810 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, PHY_OPS_GROUP, 811 GEO_TX_POWER_LIMIT, 812 IWL_FW_CMD_VER_UNKNOWN); 813 814 /* the ops field is at the same spot for all versions, so set in v1 */ 815 geo_tx_cmd.v1.ops = 816 cpu_to_le32(IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE); 817 818 if (cmd_ver == 3) 819 len = sizeof(geo_tx_cmd.v3); 820 else if (fw_has_api(&mvm->fwrt.fw->ucode_capa, 821 IWL_UCODE_TLV_API_SAR_TABLE_VER)) 822 len = sizeof(geo_tx_cmd.v2); 823 else 824 len = sizeof(geo_tx_cmd.v1); 825 826 if (!iwl_sar_geo_support(&mvm->fwrt)) 827 return -EOPNOTSUPP; 828 829 cmd = (struct iwl_host_cmd){ 830 .id = WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT), 831 .len = { len, }, 832 .flags = CMD_WANT_SKB, 833 .data = { &geo_tx_cmd }, 834 }; 835 836 ret = iwl_mvm_send_cmd(mvm, &cmd); 837 if (ret) { 838 IWL_ERR(mvm, "Failed to get geographic profile info %d\n", ret); 839 return ret; 840 } 841 842 resp = (void *)cmd.resp_pkt->data; 843 ret = le32_to_cpu(resp->profile_idx); 844 845 if (WARN_ON(ret > ACPI_NUM_GEO_PROFILES)) 846 ret = -EIO; 847 848 iwl_free_resp(&cmd); 849 return ret; 850 } 851 852 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) 853 { 854 union iwl_geo_tx_power_profiles_cmd cmd; 855 u16 len; 856 u32 n_bands; 857 int ret; 858 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, PHY_OPS_GROUP, 859 GEO_TX_POWER_LIMIT, 860 IWL_FW_CMD_VER_UNKNOWN); 861 862 BUILD_BUG_ON(offsetof(struct iwl_geo_tx_power_profiles_cmd_v1, ops) != 863 offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, ops) || 864 offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, ops) != 865 offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, ops)); 866 /* the ops field is at the same spot for all versions, so set in v1 */ 867 cmd.v1.ops = cpu_to_le32(IWL_PER_CHAIN_OFFSET_SET_TABLES); 868 869 if (cmd_ver == 3) { 870 len = sizeof(cmd.v3); 871 n_bands = ARRAY_SIZE(cmd.v3.table[0]); 872 } else if (fw_has_api(&mvm->fwrt.fw->ucode_capa, 873 IWL_UCODE_TLV_API_SAR_TABLE_VER)) { 874 len = sizeof(cmd.v2); 875 n_bands = ARRAY_SIZE(cmd.v2.table[0]); 876 } else { 877 len = sizeof(cmd.v1); 878 n_bands = ARRAY_SIZE(cmd.v1.table[0]); 879 } 880 881 BUILD_BUG_ON(offsetof(struct iwl_geo_tx_power_profiles_cmd_v1, table) != 882 offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, table) || 883 offsetof(struct iwl_geo_tx_power_profiles_cmd_v2, table) != 884 offsetof(struct iwl_geo_tx_power_profiles_cmd_v3, table)); 885 /* the table is at the same position for all versions, so set use v1 */ 886 ret = iwl_sar_geo_init(&mvm->fwrt, &cmd.v1.table[0][0], n_bands); 887 888 /* 889 * It is a valid scenario to not support SAR, or miss wgds table, 890 * but in that case there is no need to send the command. 891 */ 892 if (ret) 893 return 0; 894 895 /* 896 * Set the revision on versions that contain it. 897 * This must be done after calling iwl_sar_geo_init(). 898 */ 899 if (cmd_ver == 3) 900 cmd.v3.table_revision = cpu_to_le32(mvm->fwrt.geo_rev); 901 else if (fw_has_api(&mvm->fwrt.fw->ucode_capa, 902 IWL_UCODE_TLV_API_SAR_TABLE_VER)) 903 cmd.v2.table_revision = cpu_to_le32(mvm->fwrt.geo_rev); 904 905 return iwl_mvm_send_cmd_pdu(mvm, 906 WIDE_ID(PHY_OPS_GROUP, GEO_TX_POWER_LIMIT), 907 0, len, &cmd); 908 } 909 910 static int iwl_mvm_get_ppag_table(struct iwl_mvm *mvm) 911 { 912 union acpi_object *wifi_pkg, *data, *enabled; 913 int i, j, ret, tbl_rev, num_sub_bands; 914 int idx = 2; 915 s8 *gain; 916 917 /* 918 * The 'enabled' field is the same in v1 and v2 so we can just 919 * use v1 to access it. 920 */ 921 mvm->fwrt.ppag_table.v1.enabled = cpu_to_le32(0); 922 data = iwl_acpi_get_object(mvm->dev, ACPI_PPAG_METHOD); 923 if (IS_ERR(data)) 924 return PTR_ERR(data); 925 926 /* try to read ppag table revision 1 */ 927 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, 928 ACPI_PPAG_WIFI_DATA_SIZE_V2, &tbl_rev); 929 if (!IS_ERR(wifi_pkg)) { 930 if (tbl_rev != 1) { 931 ret = -EINVAL; 932 goto out_free; 933 } 934 num_sub_bands = IWL_NUM_SUB_BANDS_V2; 935 gain = mvm->fwrt.ppag_table.v2.gain[0]; 936 mvm->fwrt.ppag_ver = 2; 937 IWL_DEBUG_RADIO(mvm, "Reading PPAG table v2 (tbl_rev=1)\n"); 938 goto read_table; 939 } 940 941 /* try to read ppag table revision 0 */ 942 wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data, 943 ACPI_PPAG_WIFI_DATA_SIZE, &tbl_rev); 944 if (!IS_ERR(wifi_pkg)) { 945 if (tbl_rev != 0) { 946 ret = -EINVAL; 947 goto out_free; 948 } 949 num_sub_bands = IWL_NUM_SUB_BANDS; 950 gain = mvm->fwrt.ppag_table.v1.gain[0]; 951 mvm->fwrt.ppag_ver = 1; 952 IWL_DEBUG_RADIO(mvm, "Reading PPAG table v1 (tbl_rev=0)\n"); 953 goto read_table; 954 } 955 ret = PTR_ERR(wifi_pkg); 956 goto out_free; 957 958 read_table: 959 enabled = &wifi_pkg->package.elements[1]; 960 if (enabled->type != ACPI_TYPE_INTEGER || 961 (enabled->integer.value != 0 && enabled->integer.value != 1)) { 962 ret = -EINVAL; 963 goto out_free; 964 } 965 966 mvm->fwrt.ppag_table.v1.enabled = cpu_to_le32(enabled->integer.value); 967 if (!mvm->fwrt.ppag_table.v1.enabled) { 968 ret = 0; 969 goto out_free; 970 } 971 972 /* 973 * read, verify gain values and save them into the PPAG table. 974 * first sub-band (j=0) corresponds to Low-Band (2.4GHz), and the 975 * following sub-bands to High-Band (5GHz). 976 */ 977 for (i = 0; i < IWL_NUM_CHAIN_LIMITS; i++) { 978 for (j = 0; j < num_sub_bands; j++) { 979 union acpi_object *ent; 980 981 ent = &wifi_pkg->package.elements[idx++]; 982 if (ent->type != ACPI_TYPE_INTEGER) { 983 ret = -EINVAL; 984 goto out_free; 985 } 986 987 gain[i * num_sub_bands + j] = ent->integer.value; 988 989 if ((j == 0 && 990 (gain[i * num_sub_bands + j] > ACPI_PPAG_MAX_LB || 991 gain[i * num_sub_bands + j] < ACPI_PPAG_MIN_LB)) || 992 (j != 0 && 993 (gain[i * num_sub_bands + j] > ACPI_PPAG_MAX_HB || 994 gain[i * num_sub_bands + j] < ACPI_PPAG_MIN_HB))) { 995 mvm->fwrt.ppag_table.v1.enabled = cpu_to_le32(0); 996 ret = -EINVAL; 997 goto out_free; 998 } 999 } 1000 } 1001 ret = 0; 1002 out_free: 1003 kfree(data); 1004 return ret; 1005 } 1006 1007 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm) 1008 { 1009 u8 cmd_ver; 1010 int i, j, ret, num_sub_bands, cmd_size; 1011 s8 *gain; 1012 1013 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_PPAG)) { 1014 IWL_DEBUG_RADIO(mvm, 1015 "PPAG capability not supported by FW, command not sent.\n"); 1016 return 0; 1017 } 1018 if (!mvm->fwrt.ppag_table.v1.enabled) { 1019 IWL_DEBUG_RADIO(mvm, "PPAG not enabled, command not sent.\n"); 1020 return 0; 1021 } 1022 1023 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, PHY_OPS_GROUP, 1024 PER_PLATFORM_ANT_GAIN_CMD, 1025 IWL_FW_CMD_VER_UNKNOWN); 1026 if (cmd_ver == 1) { 1027 num_sub_bands = IWL_NUM_SUB_BANDS; 1028 gain = mvm->fwrt.ppag_table.v1.gain[0]; 1029 cmd_size = sizeof(mvm->fwrt.ppag_table.v1); 1030 if (mvm->fwrt.ppag_ver == 2) { 1031 IWL_DEBUG_RADIO(mvm, 1032 "PPAG table is v2 but FW supports v1, sending truncated table\n"); 1033 } 1034 } else if (cmd_ver == 2) { 1035 num_sub_bands = IWL_NUM_SUB_BANDS_V2; 1036 gain = mvm->fwrt.ppag_table.v2.gain[0]; 1037 cmd_size = sizeof(mvm->fwrt.ppag_table.v2); 1038 if (mvm->fwrt.ppag_ver == 1) { 1039 IWL_DEBUG_RADIO(mvm, 1040 "PPAG table is v1 but FW supports v2, sending padded table\n"); 1041 } 1042 } else { 1043 IWL_DEBUG_RADIO(mvm, "Unsupported PPAG command version\n"); 1044 return 0; 1045 } 1046 1047 for (i = 0; i < IWL_NUM_CHAIN_LIMITS; i++) { 1048 for (j = 0; j < num_sub_bands; j++) { 1049 IWL_DEBUG_RADIO(mvm, 1050 "PPAG table: chain[%d] band[%d]: gain = %d\n", 1051 i, j, gain[i * num_sub_bands + j]); 1052 } 1053 } 1054 IWL_DEBUG_RADIO(mvm, "Sending PER_PLATFORM_ANT_GAIN_CMD\n"); 1055 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP, 1056 PER_PLATFORM_ANT_GAIN_CMD), 1057 0, cmd_size, &mvm->fwrt.ppag_table); 1058 if (ret < 0) 1059 IWL_ERR(mvm, "failed to send PER_PLATFORM_ANT_GAIN_CMD (%d)\n", 1060 ret); 1061 1062 return ret; 1063 } 1064 1065 static const struct dmi_system_id dmi_ppag_approved_list[] = { 1066 { .ident = "HP", 1067 .matches = { 1068 DMI_MATCH(DMI_SYS_VENDOR, "HP"), 1069 }, 1070 }, 1071 { .ident = "SAMSUNG", 1072 .matches = { 1073 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD"), 1074 }, 1075 }, 1076 { .ident = "MSFT", 1077 .matches = { 1078 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), 1079 }, 1080 }, 1081 { .ident = "ASUS", 1082 .matches = { 1083 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek COMPUTER INC."), 1084 }, 1085 }, 1086 }; 1087 1088 static int iwl_mvm_ppag_init(struct iwl_mvm *mvm) 1089 { 1090 int ret; 1091 1092 ret = iwl_mvm_get_ppag_table(mvm); 1093 if (ret < 0) { 1094 IWL_DEBUG_RADIO(mvm, 1095 "PPAG BIOS table invalid or unavailable. (%d)\n", 1096 ret); 1097 return 0; 1098 } 1099 1100 if (!dmi_check_system(dmi_ppag_approved_list)) { 1101 IWL_DEBUG_RADIO(mvm, 1102 "System vendor '%s' is not in the approved list, disabling PPAG.\n", 1103 dmi_get_system_info(DMI_SYS_VENDOR)); 1104 mvm->fwrt.ppag_table.v1.enabled = cpu_to_le32(0); 1105 return 0; 1106 } 1107 1108 return iwl_mvm_ppag_send_cmd(mvm); 1109 } 1110 1111 static void iwl_mvm_tas_init(struct iwl_mvm *mvm) 1112 { 1113 int ret; 1114 struct iwl_tas_config_cmd cmd = {}; 1115 int list_size; 1116 1117 BUILD_BUG_ON(ARRAY_SIZE(cmd.block_list_array) < 1118 APCI_WTAS_BLACK_LIST_MAX); 1119 1120 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TAS_CFG)) { 1121 IWL_DEBUG_RADIO(mvm, "TAS not enabled in FW\n"); 1122 return; 1123 } 1124 1125 ret = iwl_acpi_get_tas(&mvm->fwrt, cmd.block_list_array, &list_size); 1126 if (ret < 0) { 1127 IWL_DEBUG_RADIO(mvm, 1128 "TAS table invalid or unavailable. (%d)\n", 1129 ret); 1130 return; 1131 } 1132 1133 if (list_size < 0) 1134 return; 1135 1136 /* list size if TAS enabled can only be non-negative */ 1137 cmd.block_list_size = cpu_to_le32((u32)list_size); 1138 1139 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP, 1140 TAS_CONFIG), 1141 0, sizeof(cmd), &cmd); 1142 if (ret < 0) 1143 IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret); 1144 } 1145 1146 static u8 iwl_mvm_eval_dsm_indonesia_5g2(struct iwl_mvm *mvm) 1147 { 1148 u8 value; 1149 1150 int ret = iwl_acpi_get_dsm_u8((&mvm->fwrt)->dev, 0, 1151 DSM_FUNC_ENABLE_INDONESIA_5G2, 1152 &iwl_guid, &value); 1153 1154 if (ret < 0) 1155 IWL_DEBUG_RADIO(mvm, 1156 "Failed to evaluate DSM function ENABLE_INDONESIA_5G2, ret=%d\n", 1157 ret); 1158 1159 else if (value >= DSM_VALUE_INDONESIA_MAX) 1160 IWL_DEBUG_RADIO(mvm, 1161 "DSM function ENABLE_INDONESIA_5G2 return invalid value, value=%d\n", 1162 value); 1163 1164 else if (value == DSM_VALUE_INDONESIA_ENABLE) { 1165 IWL_DEBUG_RADIO(mvm, 1166 "Evaluated DSM function ENABLE_INDONESIA_5G2: Enabling 5g2\n"); 1167 return DSM_VALUE_INDONESIA_ENABLE; 1168 } 1169 /* default behaviour is disabled */ 1170 return DSM_VALUE_INDONESIA_DISABLE; 1171 } 1172 1173 static u8 iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm) 1174 { 1175 u8 value; 1176 int ret = iwl_acpi_get_dsm_u8((&mvm->fwrt)->dev, 0, DSM_RFI_FUNC_ENABLE, 1177 &iwl_rfi_guid, &value); 1178 1179 if (ret < 0) { 1180 IWL_DEBUG_RADIO(mvm, "Failed to get DSM RFI, ret=%d\n", ret); 1181 1182 } else if (value >= DSM_VALUE_RFI_MAX) { 1183 IWL_DEBUG_RADIO(mvm, "DSM RFI got invalid value, ret=%d\n", 1184 value); 1185 1186 } else if (value == DSM_VALUE_RFI_ENABLE) { 1187 IWL_DEBUG_RADIO(mvm, "DSM RFI is evaluated to enable\n"); 1188 return DSM_VALUE_RFI_ENABLE; 1189 } 1190 1191 IWL_DEBUG_RADIO(mvm, "DSM RFI is disabled\n"); 1192 1193 /* default behaviour is disabled */ 1194 return DSM_VALUE_RFI_DISABLE; 1195 } 1196 1197 static u8 iwl_mvm_eval_dsm_disable_srd(struct iwl_mvm *mvm) 1198 { 1199 u8 value; 1200 int ret = iwl_acpi_get_dsm_u8((&mvm->fwrt)->dev, 0, 1201 DSM_FUNC_DISABLE_SRD, 1202 &iwl_guid, &value); 1203 1204 if (ret < 0) 1205 IWL_DEBUG_RADIO(mvm, 1206 "Failed to evaluate DSM function DISABLE_SRD, ret=%d\n", 1207 ret); 1208 1209 else if (value >= DSM_VALUE_SRD_MAX) 1210 IWL_DEBUG_RADIO(mvm, 1211 "DSM function DISABLE_SRD return invalid value, value=%d\n", 1212 value); 1213 1214 else if (value == DSM_VALUE_SRD_PASSIVE) { 1215 IWL_DEBUG_RADIO(mvm, 1216 "Evaluated DSM function DISABLE_SRD: setting SRD to passive\n"); 1217 return DSM_VALUE_SRD_PASSIVE; 1218 1219 } else if (value == DSM_VALUE_SRD_DISABLE) { 1220 IWL_DEBUG_RADIO(mvm, 1221 "Evaluated DSM function DISABLE_SRD: disabling SRD\n"); 1222 return DSM_VALUE_SRD_DISABLE; 1223 } 1224 /* default behaviour is active */ 1225 return DSM_VALUE_SRD_ACTIVE; 1226 } 1227 1228 static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm) 1229 { 1230 u8 ret; 1231 int cmd_ret; 1232 struct iwl_lari_config_change_cmd_v2 cmd = {}; 1233 1234 if (iwl_mvm_eval_dsm_indonesia_5g2(mvm) == DSM_VALUE_INDONESIA_ENABLE) 1235 cmd.config_bitmap |= 1236 cpu_to_le32(LARI_CONFIG_ENABLE_5G2_IN_INDONESIA_MSK); 1237 1238 ret = iwl_mvm_eval_dsm_disable_srd(mvm); 1239 if (ret == DSM_VALUE_SRD_PASSIVE) 1240 cmd.config_bitmap |= 1241 cpu_to_le32(LARI_CONFIG_CHANGE_ETSI_TO_PASSIVE_MSK); 1242 1243 else if (ret == DSM_VALUE_SRD_DISABLE) 1244 cmd.config_bitmap |= 1245 cpu_to_le32(LARI_CONFIG_CHANGE_ETSI_TO_DISABLED_MSK); 1246 1247 /* apply more config masks here */ 1248 1249 if (cmd.config_bitmap) { 1250 size_t cmd_size = iwl_fw_lookup_cmd_ver(mvm->fw, 1251 REGULATORY_AND_NVM_GROUP, 1252 LARI_CONFIG_CHANGE, 1) == 2 ? 1253 sizeof(struct iwl_lari_config_change_cmd_v2) : 1254 sizeof(struct iwl_lari_config_change_cmd_v1); 1255 IWL_DEBUG_RADIO(mvm, 1256 "sending LARI_CONFIG_CHANGE, config_bitmap=0x%x\n", 1257 le32_to_cpu(cmd.config_bitmap)); 1258 cmd_ret = iwl_mvm_send_cmd_pdu(mvm, 1259 WIDE_ID(REGULATORY_AND_NVM_GROUP, 1260 LARI_CONFIG_CHANGE), 1261 0, cmd_size, &cmd); 1262 if (cmd_ret < 0) 1263 IWL_DEBUG_RADIO(mvm, 1264 "Failed to send LARI_CONFIG_CHANGE (%d)\n", 1265 cmd_ret); 1266 } 1267 } 1268 #else /* CONFIG_ACPI */ 1269 1270 inline int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, 1271 int prof_a, int prof_b) 1272 { 1273 return -ENOENT; 1274 } 1275 1276 inline int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm) 1277 { 1278 return -ENOENT; 1279 } 1280 1281 static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm) 1282 { 1283 return 0; 1284 } 1285 1286 int iwl_mvm_ppag_send_cmd(struct iwl_mvm *mvm) 1287 { 1288 return -ENOENT; 1289 } 1290 1291 static int iwl_mvm_ppag_init(struct iwl_mvm *mvm) 1292 { 1293 return 0; 1294 } 1295 1296 static void iwl_mvm_tas_init(struct iwl_mvm *mvm) 1297 { 1298 } 1299 1300 static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm) 1301 { 1302 } 1303 1304 static u8 iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm) 1305 { 1306 return DSM_VALUE_RFI_DISABLE; 1307 } 1308 #endif /* CONFIG_ACPI */ 1309 1310 void iwl_mvm_send_recovery_cmd(struct iwl_mvm *mvm, u32 flags) 1311 { 1312 u32 error_log_size = mvm->fw->ucode_capa.error_log_size; 1313 int ret; 1314 u32 resp; 1315 1316 struct iwl_fw_error_recovery_cmd recovery_cmd = { 1317 .flags = cpu_to_le32(flags), 1318 .buf_size = 0, 1319 }; 1320 struct iwl_host_cmd host_cmd = { 1321 .id = WIDE_ID(SYSTEM_GROUP, FW_ERROR_RECOVERY_CMD), 1322 .flags = CMD_WANT_SKB, 1323 .data = {&recovery_cmd, }, 1324 .len = {sizeof(recovery_cmd), }, 1325 }; 1326 1327 /* no error log was defined in TLV */ 1328 if (!error_log_size) 1329 return; 1330 1331 if (flags & ERROR_RECOVERY_UPDATE_DB) { 1332 /* no buf was allocated while HW reset */ 1333 if (!mvm->error_recovery_buf) 1334 return; 1335 1336 host_cmd.data[1] = mvm->error_recovery_buf; 1337 host_cmd.len[1] = error_log_size; 1338 host_cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY; 1339 recovery_cmd.buf_size = cpu_to_le32(error_log_size); 1340 } 1341 1342 ret = iwl_mvm_send_cmd(mvm, &host_cmd); 1343 kfree(mvm->error_recovery_buf); 1344 mvm->error_recovery_buf = NULL; 1345 1346 if (ret) { 1347 IWL_ERR(mvm, "Failed to send recovery cmd %d\n", ret); 1348 return; 1349 } 1350 1351 /* skb respond is only relevant in ERROR_RECOVERY_UPDATE_DB */ 1352 if (flags & ERROR_RECOVERY_UPDATE_DB) { 1353 resp = le32_to_cpu(*(__le32 *)host_cmd.resp_pkt->data); 1354 if (resp) 1355 IWL_ERR(mvm, 1356 "Failed to send recovery cmd blob was invalid %d\n", 1357 resp); 1358 } 1359 } 1360 1361 static int iwl_mvm_sar_init(struct iwl_mvm *mvm) 1362 { 1363 int ret; 1364 1365 ret = iwl_sar_get_wrds_table(&mvm->fwrt); 1366 if (ret < 0) { 1367 IWL_DEBUG_RADIO(mvm, 1368 "WRDS SAR BIOS table invalid or unavailable. (%d)\n", 1369 ret); 1370 /* 1371 * If not available, don't fail and don't bother with EWRD. 1372 * Return 1 to tell that we can't use WGDS either. 1373 */ 1374 return 1; 1375 } 1376 1377 ret = iwl_sar_get_ewrd_table(&mvm->fwrt); 1378 /* if EWRD is not available, we can still use WRDS, so don't fail */ 1379 if (ret < 0) 1380 IWL_DEBUG_RADIO(mvm, 1381 "EWRD SAR BIOS table invalid or unavailable. (%d)\n", 1382 ret); 1383 1384 return iwl_mvm_sar_select_profile(mvm, 1, 1); 1385 } 1386 1387 static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm) 1388 { 1389 int ret; 1390 1391 if (iwl_mvm_has_unified_ucode(mvm)) 1392 return iwl_run_unified_mvm_ucode(mvm); 1393 1394 WARN_ON(!mvm->nvm_data); 1395 ret = iwl_run_init_mvm_ucode(mvm); 1396 1397 if (ret) { 1398 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 1399 1400 if (iwlmvm_mod_params.init_dbg) 1401 return 0; 1402 return ret; 1403 } 1404 1405 iwl_fw_dbg_stop_sync(&mvm->fwrt); 1406 iwl_trans_stop_device(mvm->trans); 1407 ret = iwl_trans_start_hw(mvm->trans); 1408 if (ret) 1409 return ret; 1410 1411 mvm->rfkill_safe_init_done = false; 1412 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR); 1413 if (ret) 1414 return ret; 1415 1416 mvm->rfkill_safe_init_done = true; 1417 1418 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_AFTER_ALIVE, 1419 NULL); 1420 1421 return iwl_init_paging(&mvm->fwrt, mvm->fwrt.cur_fw_img); 1422 } 1423 1424 int iwl_mvm_up(struct iwl_mvm *mvm) 1425 { 1426 int ret, i; 1427 struct ieee80211_channel *chan; 1428 struct cfg80211_chan_def chandef; 1429 struct ieee80211_supported_band *sband = NULL; 1430 1431 lockdep_assert_held(&mvm->mutex); 1432 1433 ret = iwl_trans_start_hw(mvm->trans); 1434 if (ret) 1435 return ret; 1436 1437 ret = iwl_mvm_load_rt_fw(mvm); 1438 if (ret) { 1439 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 1440 if (ret != -ERFKILL) 1441 iwl_fw_dbg_error_collect(&mvm->fwrt, 1442 FW_DBG_TRIGGER_DRIVER); 1443 goto error; 1444 } 1445 1446 iwl_get_shared_mem_conf(&mvm->fwrt); 1447 1448 ret = iwl_mvm_sf_update(mvm, NULL, false); 1449 if (ret) 1450 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n"); 1451 1452 if (!iwl_trans_dbg_ini_valid(mvm->trans)) { 1453 mvm->fwrt.dump.conf = FW_DBG_INVALID; 1454 /* if we have a destination, assume EARLY START */ 1455 if (mvm->fw->dbg.dest_tlv) 1456 mvm->fwrt.dump.conf = FW_DBG_START_FROM_ALIVE; 1457 iwl_fw_start_dbg_conf(&mvm->fwrt, FW_DBG_START_FROM_ALIVE); 1458 } 1459 1460 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 1461 if (ret) 1462 goto error; 1463 1464 if (!iwl_mvm_has_unified_ucode(mvm)) { 1465 /* Send phy db control command and then phy db calibration */ 1466 ret = iwl_send_phy_db_data(mvm->phy_db); 1467 if (ret) 1468 goto error; 1469 } 1470 1471 ret = iwl_send_phy_cfg_cmd(mvm); 1472 if (ret) 1473 goto error; 1474 1475 ret = iwl_mvm_send_bt_init_conf(mvm); 1476 if (ret) 1477 goto error; 1478 1479 if (fw_has_capa(&mvm->fw->ucode_capa, 1480 IWL_UCODE_TLV_CAPA_SOC_LATENCY_SUPPORT)) { 1481 ret = iwl_set_soc_latency(&mvm->fwrt); 1482 if (ret) 1483 goto error; 1484 } 1485 1486 /* Init RSS configuration */ 1487 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000) { 1488 ret = iwl_configure_rxq(mvm); 1489 if (ret) { 1490 IWL_ERR(mvm, "Failed to configure RX queues: %d\n", 1491 ret); 1492 goto error; 1493 } 1494 } 1495 1496 if (iwl_mvm_has_new_rx_api(mvm)) { 1497 ret = iwl_send_rss_cfg_cmd(mvm); 1498 if (ret) { 1499 IWL_ERR(mvm, "Failed to configure RSS queues: %d\n", 1500 ret); 1501 goto error; 1502 } 1503 } 1504 1505 /* init the fw <-> mac80211 STA mapping */ 1506 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) 1507 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); 1508 1509 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA; 1510 1511 /* reset quota debouncing buffer - 0xff will yield invalid data */ 1512 memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd)); 1513 1514 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_DQA_SUPPORT)) { 1515 ret = iwl_mvm_send_dqa_cmd(mvm); 1516 if (ret) 1517 goto error; 1518 } 1519 1520 /* 1521 * Add auxiliary station for scanning. 1522 * Newer versions of this command implies that the fw uses 1523 * internal aux station for all aux activities that don't 1524 * requires a dedicated data queue. 1525 */ 1526 if (iwl_fw_lookup_cmd_ver(mvm->fw, LONG_GROUP, 1527 ADD_STA, 1528 0) < 12) { 1529 /* 1530 * In old version the aux station uses mac id like other 1531 * station and not lmac id 1532 */ 1533 ret = iwl_mvm_add_aux_sta(mvm, MAC_INDEX_AUX); 1534 if (ret) 1535 goto error; 1536 } 1537 1538 /* Add all the PHY contexts */ 1539 i = 0; 1540 while (!sband && i < NUM_NL80211_BANDS) 1541 sband = mvm->hw->wiphy->bands[i++]; 1542 1543 if (WARN_ON_ONCE(!sband)) 1544 goto error; 1545 1546 chan = &sband->channels[0]; 1547 1548 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); 1549 for (i = 0; i < NUM_PHY_CTX; i++) { 1550 /* 1551 * The channel used here isn't relevant as it's 1552 * going to be overwritten in the other flows. 1553 * For now use the first channel we have. 1554 */ 1555 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i], 1556 &chandef, 1, 1); 1557 if (ret) 1558 goto error; 1559 } 1560 1561 if (iwl_mvm_is_tt_in_fw(mvm)) { 1562 /* in order to give the responsibility of ct-kill and 1563 * TX backoff to FW we need to send empty temperature reporting 1564 * cmd during init time 1565 */ 1566 iwl_mvm_send_temp_report_ths_cmd(mvm); 1567 } else { 1568 /* Initialize tx backoffs to the minimal possible */ 1569 iwl_mvm_tt_tx_backoff(mvm, 0); 1570 } 1571 1572 #ifdef CONFIG_THERMAL 1573 /* TODO: read the budget from BIOS / Platform NVM */ 1574 1575 /* 1576 * In case there is no budget from BIOS / Platform NVM the default 1577 * budget should be 2000mW (cooling state 0). 1578 */ 1579 if (iwl_mvm_is_ctdp_supported(mvm)) { 1580 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, 1581 mvm->cooling_dev.cur_state); 1582 if (ret) 1583 goto error; 1584 } 1585 #endif 1586 1587 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2)) 1588 WARN_ON(iwl_mvm_config_ltr(mvm)); 1589 1590 ret = iwl_mvm_power_update_device(mvm); 1591 if (ret) 1592 goto error; 1593 1594 iwl_mvm_lari_cfg(mvm); 1595 /* 1596 * RTNL is not taken during Ct-kill, but we don't need to scan/Tx 1597 * anyway, so don't init MCC. 1598 */ 1599 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) { 1600 ret = iwl_mvm_init_mcc(mvm); 1601 if (ret) 1602 goto error; 1603 } 1604 1605 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { 1606 mvm->scan_type = IWL_SCAN_TYPE_NOT_SET; 1607 mvm->hb_scan_type = IWL_SCAN_TYPE_NOT_SET; 1608 ret = iwl_mvm_config_scan(mvm); 1609 if (ret) 1610 goto error; 1611 } 1612 1613 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) 1614 iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_UPDATE_DB); 1615 1616 if (iwl_acpi_get_eckv(mvm->dev, &mvm->ext_clock_valid)) 1617 IWL_DEBUG_INFO(mvm, "ECKV table doesn't exist in BIOS\n"); 1618 1619 ret = iwl_mvm_ppag_init(mvm); 1620 if (ret) 1621 goto error; 1622 1623 ret = iwl_mvm_sar_init(mvm); 1624 if (ret == 0) { 1625 ret = iwl_mvm_sar_geo_init(mvm); 1626 } else if (ret == -ENOENT && !iwl_sar_get_wgds_table(&mvm->fwrt)) { 1627 /* 1628 * If basic SAR is not available, we check for WGDS, 1629 * which should *not* be available either. If it is 1630 * available, issue an error, because we can't use SAR 1631 * Geo without basic SAR. 1632 */ 1633 IWL_ERR(mvm, "BIOS contains WGDS but no WRDS\n"); 1634 } 1635 1636 if (ret < 0) 1637 goto error; 1638 1639 iwl_mvm_tas_init(mvm); 1640 iwl_mvm_leds_sync(mvm); 1641 1642 iwl_mvm_ftm_initiator_smooth_config(mvm); 1643 1644 if (fw_has_capa(&mvm->fw->ucode_capa, 1645 IWL_UCODE_TLV_CAPA_RFIM_SUPPORT)) { 1646 if (iwl_mvm_eval_dsm_rfi(mvm) == DSM_VALUE_RFI_ENABLE) 1647 iwl_rfi_send_config_cmd(mvm, NULL); 1648 } 1649 1650 IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); 1651 return 0; 1652 error: 1653 if (!iwlmvm_mod_params.init_dbg || !ret) 1654 iwl_mvm_stop_device(mvm); 1655 return ret; 1656 } 1657 1658 int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm) 1659 { 1660 int ret, i; 1661 1662 lockdep_assert_held(&mvm->mutex); 1663 1664 ret = iwl_trans_start_hw(mvm->trans); 1665 if (ret) 1666 return ret; 1667 1668 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN); 1669 if (ret) { 1670 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret); 1671 goto error; 1672 } 1673 1674 ret = iwl_send_tx_ant_cfg(mvm, iwl_mvm_get_valid_tx_ant(mvm)); 1675 if (ret) 1676 goto error; 1677 1678 /* Send phy db control command and then phy db calibration*/ 1679 ret = iwl_send_phy_db_data(mvm->phy_db); 1680 if (ret) 1681 goto error; 1682 1683 ret = iwl_send_phy_cfg_cmd(mvm); 1684 if (ret) 1685 goto error; 1686 1687 /* init the fw <-> mac80211 STA mapping */ 1688 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) 1689 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL); 1690 1691 if (iwl_fw_lookup_cmd_ver(mvm->fw, LONG_GROUP, 1692 ADD_STA, 1693 0) < 12) { 1694 /* 1695 * Add auxiliary station for scanning. 1696 * Newer versions of this command implies that the fw uses 1697 * internal aux station for all aux activities that don't 1698 * requires a dedicated data queue. 1699 * In old version the aux station uses mac id like other 1700 * station and not lmac id 1701 */ 1702 ret = iwl_mvm_add_aux_sta(mvm, MAC_INDEX_AUX); 1703 if (ret) 1704 goto error; 1705 } 1706 1707 return 0; 1708 error: 1709 iwl_mvm_stop_device(mvm); 1710 return ret; 1711 } 1712 1713 void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm, 1714 struct iwl_rx_cmd_buffer *rxb) 1715 { 1716 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1717 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; 1718 u32 flags = le32_to_cpu(card_state_notif->flags); 1719 1720 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n", 1721 (flags & HW_CARD_DISABLED) ? "Kill" : "On", 1722 (flags & SW_CARD_DISABLED) ? "Kill" : "On", 1723 (flags & CT_KILL_CARD_DISABLED) ? 1724 "Reached" : "Not reached"); 1725 } 1726 1727 void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, 1728 struct iwl_rx_cmd_buffer *rxb) 1729 { 1730 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1731 struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data; 1732 1733 IWL_DEBUG_INFO(mvm, 1734 "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n", 1735 le32_to_cpu(mfuart_notif->installed_ver), 1736 le32_to_cpu(mfuart_notif->external_ver), 1737 le32_to_cpu(mfuart_notif->status), 1738 le32_to_cpu(mfuart_notif->duration)); 1739 1740 if (iwl_rx_packet_payload_len(pkt) == sizeof(*mfuart_notif)) 1741 IWL_DEBUG_INFO(mvm, 1742 "MFUART: image size: 0x%08x\n", 1743 le32_to_cpu(mfuart_notif->image_size)); 1744 } 1745