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