xref: /linux/drivers/net/wireless/intel/iwlwifi/iwl-trans.h (revision f94ecbc920925d5922d68a434f76aa8ef8d7f21e)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2005-2014, 2018-2023 Intel Corporation
4  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5  * Copyright (C) 2016-2017 Intel Deutschland GmbH
6  */
7 #ifndef __iwl_trans_h__
8 #define __iwl_trans_h__
9 
10 #include <linux/ieee80211.h>
11 #include <linux/mm.h> /* for page_address */
12 #include <linux/lockdep.h>
13 #include <linux/kernel.h>
14 
15 #include "iwl-debug.h"
16 #include "iwl-config.h"
17 #include "fw/img.h"
18 #include "iwl-op-mode.h"
19 #include <linux/firmware.h>
20 #include "fw/api/cmdhdr.h"
21 #include "fw/api/txq.h"
22 #include "fw/api/dbg-tlv.h"
23 #include "iwl-dbg-tlv.h"
24 
25 /**
26  * DOC: Transport layer - what is it ?
27  *
28  * The transport layer is the layer that deals with the HW directly. It provides
29  * the PCIe access to the underlying hardwarwe. The transport layer doesn't
30  * provide any policy, algorithm or anything of this kind, but only mechanisms
31  * to make the HW do something. It is not completely stateless but close to it.
32  */
33 
34 /**
35  * DOC: Life cycle of the transport layer
36  *
37  * The transport layer has a very precise life cycle.
38  *
39  *	1) A helper function is called during the module initialization and
40  *	   registers the bus driver's ops with the transport's alloc function.
41  *	2) Bus's probe calls to the transport layer's allocation functions.
42  *	   Of course this function is bus specific.
43  *	3) This allocation functions will spawn the upper layer which will
44  *	   register mac80211.
45  *
46  *	4) At some point (i.e. mac80211's start call), the op_mode will call
47  *	   the following sequence:
48  *	   start_hw
49  *	   start_fw
50  *
51  *	5) Then when finished (or reset):
52  *	   stop_device
53  *
54  *	6) Eventually, the free function will be called.
55  */
56 
57 /* default preset 0 (start from bit 16)*/
58 #define IWL_FW_DBG_DOMAIN_POS	16
59 #define IWL_FW_DBG_DOMAIN	BIT(IWL_FW_DBG_DOMAIN_POS)
60 
61 #define IWL_TRANS_FW_DBG_DOMAIN(trans)	IWL_FW_INI_DOMAIN_ALWAYS_ON
62 
63 #define FH_RSCSR_FRAME_SIZE_MSK		0x00003FFF	/* bits 0-13 */
64 #define FH_RSCSR_FRAME_INVALID		0x55550000
65 #define FH_RSCSR_FRAME_ALIGN		0x40
66 #define FH_RSCSR_RPA_EN			BIT(25)
67 #define FH_RSCSR_RADA_EN		BIT(26)
68 #define FH_RSCSR_RXQ_POS		16
69 #define FH_RSCSR_RXQ_MASK		0x3F0000
70 
71 struct iwl_rx_packet {
72 	/*
73 	 * The first 4 bytes of the RX frame header contain both the RX frame
74 	 * size and some flags.
75 	 * Bit fields:
76 	 * 31:    flag flush RB request
77 	 * 30:    flag ignore TC (terminal counter) request
78 	 * 29:    flag fast IRQ request
79 	 * 28-27: Reserved
80 	 * 26:    RADA enabled
81 	 * 25:    Offload enabled
82 	 * 24:    RPF enabled
83 	 * 23:    RSS enabled
84 	 * 22:    Checksum enabled
85 	 * 21-16: RX queue
86 	 * 15-14: Reserved
87 	 * 13-00: RX frame size
88 	 */
89 	__le32 len_n_flags;
90 	struct iwl_cmd_header hdr;
91 	u8 data[];
92 } __packed;
93 
94 static inline u32 iwl_rx_packet_len(const struct iwl_rx_packet *pkt)
95 {
96 	return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
97 }
98 
99 static inline u32 iwl_rx_packet_payload_len(const struct iwl_rx_packet *pkt)
100 {
101 	return iwl_rx_packet_len(pkt) - sizeof(pkt->hdr);
102 }
103 
104 /**
105  * enum CMD_MODE - how to send the host commands ?
106  *
107  * @CMD_ASYNC: Return right away and don't wait for the response
108  * @CMD_WANT_SKB: Not valid with CMD_ASYNC. The caller needs the buffer of
109  *	the response. The caller needs to call iwl_free_resp when done.
110  * @CMD_SEND_IN_RFKILL: Send the command even if the NIC is in RF-kill.
111  * @CMD_BLOCK_TXQS: Block TXQs while the comment is executing.
112  * @CMD_SEND_IN_D3: Allow the command to be sent in D3 mode, relevant to
113  *	SUSPEND and RESUME commands. We are in D3 mode when we set
114  *	trans->system_pm_mode to IWL_PLAT_PM_MODE_D3.
115  */
116 enum CMD_MODE {
117 	CMD_ASYNC		= BIT(0),
118 	CMD_WANT_SKB		= BIT(1),
119 	CMD_SEND_IN_RFKILL	= BIT(2),
120 	CMD_BLOCK_TXQS		= BIT(3),
121 	CMD_SEND_IN_D3          = BIT(4),
122 };
123 
124 #define DEF_CMD_PAYLOAD_SIZE 320
125 
126 /**
127  * struct iwl_device_cmd
128  *
129  * For allocation of the command and tx queues, this establishes the overall
130  * size of the largest command we send to uCode, except for commands that
131  * aren't fully copied and use other TFD space.
132  *
133  * @hdr: command header
134  * @payload: payload for the command
135  * @hdr_wide: wide command header
136  * @payload_wide: payload for the wide command
137  */
138 struct iwl_device_cmd {
139 	union {
140 		struct {
141 			struct iwl_cmd_header hdr;	/* uCode API */
142 			u8 payload[DEF_CMD_PAYLOAD_SIZE];
143 		};
144 		struct {
145 			struct iwl_cmd_header_wide hdr_wide;
146 			u8 payload_wide[DEF_CMD_PAYLOAD_SIZE -
147 					sizeof(struct iwl_cmd_header_wide) +
148 					sizeof(struct iwl_cmd_header)];
149 		};
150 	};
151 } __packed;
152 
153 /**
154  * struct iwl_device_tx_cmd - buffer for TX command
155  * @hdr: the header
156  * @payload: the payload placeholder
157  *
158  * The actual structure is sized dynamically according to need.
159  */
160 struct iwl_device_tx_cmd {
161 	struct iwl_cmd_header hdr;
162 	u8 payload[];
163 } __packed;
164 
165 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
166 
167 /*
168  * number of transfer buffers (fragments) per transmit frame descriptor;
169  * this is just the driver's idea, the hardware supports 20
170  */
171 #define IWL_MAX_CMD_TBS_PER_TFD	2
172 
173 /**
174  * enum iwl_hcmd_dataflag - flag for each one of the chunks of the command
175  *
176  * @IWL_HCMD_DFL_NOCOPY: By default, the command is copied to the host command's
177  *	ring. The transport layer doesn't map the command's buffer to DMA, but
178  *	rather copies it to a previously allocated DMA buffer. This flag tells
179  *	the transport layer not to copy the command, but to map the existing
180  *	buffer (that is passed in) instead. This saves the memcpy and allows
181  *	commands that are bigger than the fixed buffer to be submitted.
182  *	Note that a TFD entry after a NOCOPY one cannot be a normal copied one.
183  * @IWL_HCMD_DFL_DUP: Only valid without NOCOPY, duplicate the memory for this
184  *	chunk internally and free it again after the command completes. This
185  *	can (currently) be used only once per command.
186  *	Note that a TFD entry after a DUP one cannot be a normal copied one.
187  */
188 enum iwl_hcmd_dataflag {
189 	IWL_HCMD_DFL_NOCOPY	= BIT(0),
190 	IWL_HCMD_DFL_DUP	= BIT(1),
191 };
192 
193 enum iwl_error_event_table_status {
194 	IWL_ERROR_EVENT_TABLE_LMAC1 = BIT(0),
195 	IWL_ERROR_EVENT_TABLE_LMAC2 = BIT(1),
196 	IWL_ERROR_EVENT_TABLE_UMAC = BIT(2),
197 	IWL_ERROR_EVENT_TABLE_TCM1 = BIT(3),
198 	IWL_ERROR_EVENT_TABLE_TCM2 = BIT(4),
199 	IWL_ERROR_EVENT_TABLE_RCM1 = BIT(5),
200 	IWL_ERROR_EVENT_TABLE_RCM2 = BIT(6),
201 };
202 
203 /**
204  * struct iwl_host_cmd - Host command to the uCode
205  *
206  * @data: array of chunks that composes the data of the host command
207  * @resp_pkt: response packet, if %CMD_WANT_SKB was set
208  * @_rx_page_order: (internally used to free response packet)
209  * @_rx_page_addr: (internally used to free response packet)
210  * @flags: can be CMD_*
211  * @len: array of the lengths of the chunks in data
212  * @dataflags: IWL_HCMD_DFL_*
213  * @id: command id of the host command, for wide commands encoding the
214  *	version and group as well
215  */
216 struct iwl_host_cmd {
217 	const void *data[IWL_MAX_CMD_TBS_PER_TFD];
218 	struct iwl_rx_packet *resp_pkt;
219 	unsigned long _rx_page_addr;
220 	u32 _rx_page_order;
221 
222 	u32 flags;
223 	u32 id;
224 	u16 len[IWL_MAX_CMD_TBS_PER_TFD];
225 	u8 dataflags[IWL_MAX_CMD_TBS_PER_TFD];
226 };
227 
228 static inline void iwl_free_resp(struct iwl_host_cmd *cmd)
229 {
230 	free_pages(cmd->_rx_page_addr, cmd->_rx_page_order);
231 }
232 
233 struct iwl_rx_cmd_buffer {
234 	struct page *_page;
235 	int _offset;
236 	bool _page_stolen;
237 	u32 _rx_page_order;
238 	unsigned int truesize;
239 };
240 
241 static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r)
242 {
243 	return (void *)((unsigned long)page_address(r->_page) + r->_offset);
244 }
245 
246 static inline int rxb_offset(struct iwl_rx_cmd_buffer *r)
247 {
248 	return r->_offset;
249 }
250 
251 static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r)
252 {
253 	r->_page_stolen = true;
254 	get_page(r->_page);
255 	return r->_page;
256 }
257 
258 static inline void iwl_free_rxb(struct iwl_rx_cmd_buffer *r)
259 {
260 	__free_pages(r->_page, r->_rx_page_order);
261 }
262 
263 #define MAX_NO_RECLAIM_CMDS	6
264 
265 #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
266 
267 /*
268  * Maximum number of HW queues the transport layer
269  * currently supports
270  */
271 #define IWL_MAX_HW_QUEUES		32
272 #define IWL_MAX_TVQM_QUEUES		512
273 
274 #define IWL_MAX_TID_COUNT	8
275 #define IWL_MGMT_TID		15
276 #define IWL_FRAME_LIMIT	64
277 #define IWL_MAX_RX_HW_QUEUES	16
278 #define IWL_9000_MAX_RX_HW_QUEUES	1
279 
280 /**
281  * enum iwl_d3_status - WoWLAN image/device status
282  * @IWL_D3_STATUS_ALIVE: firmware is still running after resume
283  * @IWL_D3_STATUS_RESET: device was reset while suspended
284  */
285 enum iwl_d3_status {
286 	IWL_D3_STATUS_ALIVE,
287 	IWL_D3_STATUS_RESET,
288 };
289 
290 /**
291  * enum iwl_trans_status: transport status flags
292  * @STATUS_SYNC_HCMD_ACTIVE: a SYNC command is being processed
293  * @STATUS_DEVICE_ENABLED: APM is enabled
294  * @STATUS_TPOWER_PMI: the device might be asleep (need to wake it up)
295  * @STATUS_INT_ENABLED: interrupts are enabled
296  * @STATUS_RFKILL_HW: the actual HW state of the RF-kill switch
297  * @STATUS_RFKILL_OPMODE: RF-kill state reported to opmode
298  * @STATUS_FW_ERROR: the fw is in error state
299  * @STATUS_TRANS_DEAD: trans is dead - avoid any read/write operation
300  * @STATUS_SUPPRESS_CMD_ERROR_ONCE: suppress "FW error in SYNC CMD" once,
301  *	e.g. for testing
302  */
303 enum iwl_trans_status {
304 	STATUS_SYNC_HCMD_ACTIVE,
305 	STATUS_DEVICE_ENABLED,
306 	STATUS_TPOWER_PMI,
307 	STATUS_INT_ENABLED,
308 	STATUS_RFKILL_HW,
309 	STATUS_RFKILL_OPMODE,
310 	STATUS_FW_ERROR,
311 	STATUS_TRANS_DEAD,
312 	STATUS_SUPPRESS_CMD_ERROR_ONCE,
313 };
314 
315 static inline int
316 iwl_trans_get_rb_size_order(enum iwl_amsdu_size rb_size)
317 {
318 	switch (rb_size) {
319 	case IWL_AMSDU_2K:
320 		return get_order(2 * 1024);
321 	case IWL_AMSDU_4K:
322 		return get_order(4 * 1024);
323 	case IWL_AMSDU_8K:
324 		return get_order(8 * 1024);
325 	case IWL_AMSDU_12K:
326 		return get_order(16 * 1024);
327 	default:
328 		WARN_ON(1);
329 		return -1;
330 	}
331 }
332 
333 static inline int
334 iwl_trans_get_rb_size(enum iwl_amsdu_size rb_size)
335 {
336 	switch (rb_size) {
337 	case IWL_AMSDU_2K:
338 		return 2 * 1024;
339 	case IWL_AMSDU_4K:
340 		return 4 * 1024;
341 	case IWL_AMSDU_8K:
342 		return 8 * 1024;
343 	case IWL_AMSDU_12K:
344 		return 16 * 1024;
345 	default:
346 		WARN_ON(1);
347 		return 0;
348 	}
349 }
350 
351 struct iwl_hcmd_names {
352 	u8 cmd_id;
353 	const char *const cmd_name;
354 };
355 
356 #define HCMD_NAME(x)	\
357 	{ .cmd_id = x, .cmd_name = #x }
358 
359 struct iwl_hcmd_arr {
360 	const struct iwl_hcmd_names *arr;
361 	int size;
362 };
363 
364 #define HCMD_ARR(x)	\
365 	{ .arr = x, .size = ARRAY_SIZE(x) }
366 
367 /**
368  * struct iwl_dump_sanitize_ops - dump sanitization operations
369  * @frob_txf: Scrub the TX FIFO data
370  * @frob_hcmd: Scrub a host command, the %hcmd pointer is to the header
371  *	but that might be short or long (&struct iwl_cmd_header or
372  *	&struct iwl_cmd_header_wide)
373  * @frob_mem: Scrub memory data
374  */
375 struct iwl_dump_sanitize_ops {
376 	void (*frob_txf)(void *ctx, void *buf, size_t buflen);
377 	void (*frob_hcmd)(void *ctx, void *hcmd, size_t buflen);
378 	void (*frob_mem)(void *ctx, u32 mem_addr, void *mem, size_t buflen);
379 };
380 
381 /**
382  * struct iwl_trans_config - transport configuration
383  *
384  * @op_mode: pointer to the upper layer.
385  * @cmd_queue: the index of the command queue.
386  *	Must be set before start_fw.
387  * @cmd_fifo: the fifo for host commands
388  * @cmd_q_wdg_timeout: the timeout of the watchdog timer for the command queue.
389  * @no_reclaim_cmds: Some devices erroneously don't set the
390  *	SEQ_RX_FRAME bit on some notifications, this is the
391  *	list of such notifications to filter. Max length is
392  *	%MAX_NO_RECLAIM_CMDS.
393  * @n_no_reclaim_cmds: # of commands in list
394  * @rx_buf_size: RX buffer size needed for A-MSDUs
395  *	if unset 4k will be the RX buffer size
396  * @bc_table_dword: set to true if the BC table expects the byte count to be
397  *	in DWORD (as opposed to bytes)
398  * @scd_set_active: should the transport configure the SCD for HCMD queue
399  * @command_groups: array of command groups, each member is an array of the
400  *	commands in the group; for debugging only
401  * @command_groups_size: number of command groups, to avoid illegal access
402  * @cb_data_offs: offset inside skb->cb to store transport data at, must have
403  *	space for at least two pointers
404  * @fw_reset_handshake: firmware supports reset flow handshake
405  * @queue_alloc_cmd_ver: queue allocation command version, set to 0
406  *	for using the older SCD_QUEUE_CFG, set to the version of
407  *	SCD_QUEUE_CONFIG_CMD otherwise.
408  */
409 struct iwl_trans_config {
410 	struct iwl_op_mode *op_mode;
411 
412 	u8 cmd_queue;
413 	u8 cmd_fifo;
414 	unsigned int cmd_q_wdg_timeout;
415 	const u8 *no_reclaim_cmds;
416 	unsigned int n_no_reclaim_cmds;
417 
418 	enum iwl_amsdu_size rx_buf_size;
419 	bool bc_table_dword;
420 	bool scd_set_active;
421 	const struct iwl_hcmd_arr *command_groups;
422 	int command_groups_size;
423 
424 	u8 cb_data_offs;
425 	bool fw_reset_handshake;
426 	u8 queue_alloc_cmd_ver;
427 };
428 
429 struct iwl_trans_dump_data {
430 	u32 len;
431 	u8 data[];
432 };
433 
434 struct iwl_trans;
435 
436 struct iwl_trans_txq_scd_cfg {
437 	u8 fifo;
438 	u8 sta_id;
439 	u8 tid;
440 	bool aggregate;
441 	int frame_limit;
442 };
443 
444 /**
445  * struct iwl_trans_rxq_dma_data - RX queue DMA data
446  * @fr_bd_cb: DMA address of free BD cyclic buffer
447  * @fr_bd_wid: Initial write index of the free BD cyclic buffer
448  * @urbd_stts_wrptr: DMA address of urbd_stts_wrptr
449  * @ur_bd_cb: DMA address of used BD cyclic buffer
450  */
451 struct iwl_trans_rxq_dma_data {
452 	u64 fr_bd_cb;
453 	u32 fr_bd_wid;
454 	u64 urbd_stts_wrptr;
455 	u64 ur_bd_cb;
456 };
457 
458 /* maximal number of DRAM MAP entries supported by FW */
459 #define IPC_DRAM_MAP_ENTRY_NUM_MAX 64
460 
461 /**
462  * struct iwl_pnvm_image - contains info about the parsed pnvm image
463  * @chunks: array of pointers to pnvm payloads and their sizes
464  * @n_chunks: the number of the pnvm payloads.
465  * @version: the version of the loaded PNVM image
466  */
467 struct iwl_pnvm_image {
468 	struct {
469 		const void *data;
470 		u32 len;
471 	} chunks[IPC_DRAM_MAP_ENTRY_NUM_MAX];
472 	u32 n_chunks;
473 	u32 version;
474 };
475 
476 /**
477  * enum iwl_trans_state - state of the transport layer
478  *
479  * @IWL_TRANS_NO_FW: firmware wasn't started yet, or crashed
480  * @IWL_TRANS_FW_STARTED: FW was started, but not alive yet
481  * @IWL_TRANS_FW_ALIVE: FW has sent an alive response
482  */
483 enum iwl_trans_state {
484 	IWL_TRANS_NO_FW,
485 	IWL_TRANS_FW_STARTED,
486 	IWL_TRANS_FW_ALIVE,
487 };
488 
489 /**
490  * DOC: Platform power management
491  *
492  * In system-wide power management the entire platform goes into a low
493  * power state (e.g. idle or suspend to RAM) at the same time and the
494  * device is configured as a wakeup source for the entire platform.
495  * This is usually triggered by userspace activity (e.g. the user
496  * presses the suspend button or a power management daemon decides to
497  * put the platform in low power mode).  The device's behavior in this
498  * mode is dictated by the wake-on-WLAN configuration.
499  *
500  * The terms used for the device's behavior are as follows:
501  *
502  *	- D0: the device is fully powered and the host is awake;
503  *	- D3: the device is in low power mode and only reacts to
504  *		specific events (e.g. magic-packet received or scan
505  *		results found);
506  *
507  * These terms reflect the power modes in the firmware and are not to
508  * be confused with the physical device power state.
509  */
510 
511 /**
512  * enum iwl_plat_pm_mode - platform power management mode
513  *
514  * This enumeration describes the device's platform power management
515  * behavior when in system-wide suspend (i.e WoWLAN).
516  *
517  * @IWL_PLAT_PM_MODE_DISABLED: power management is disabled for this
518  *	device.  In system-wide suspend mode, it means that the all
519  *	connections will be closed automatically by mac80211 before
520  *	the platform is suspended.
521  * @IWL_PLAT_PM_MODE_D3: the device goes into D3 mode (i.e. WoWLAN).
522  */
523 enum iwl_plat_pm_mode {
524 	IWL_PLAT_PM_MODE_DISABLED,
525 	IWL_PLAT_PM_MODE_D3,
526 };
527 
528 /**
529  * enum iwl_ini_cfg_state
530  * @IWL_INI_CFG_STATE_NOT_LOADED: no debug cfg was given
531  * @IWL_INI_CFG_STATE_LOADED: debug cfg was found and loaded
532  * @IWL_INI_CFG_STATE_CORRUPTED: debug cfg was found and some of the TLVs
533  *	are corrupted. The rest of the debug TLVs will still be used
534  */
535 enum iwl_ini_cfg_state {
536 	IWL_INI_CFG_STATE_NOT_LOADED,
537 	IWL_INI_CFG_STATE_LOADED,
538 	IWL_INI_CFG_STATE_CORRUPTED,
539 };
540 
541 /* Max time to wait for nmi interrupt */
542 #define IWL_TRANS_NMI_TIMEOUT (HZ / 4)
543 
544 /**
545  * struct iwl_dram_data
546  * @physical: page phy pointer
547  * @block: pointer to the allocated block/page
548  * @size: size of the block/page
549  */
550 struct iwl_dram_data {
551 	dma_addr_t physical;
552 	void *block;
553 	int size;
554 };
555 
556 /**
557  * struct iwl_dram_regions - DRAM regions container structure
558  * @drams: array of several DRAM areas that contains the pnvm and power
559  *	reduction table payloads.
560  * @n_regions: number of DRAM regions that were allocated
561  * @prph_scratch_mem_desc: points to a structure allocated in dram,
562  *	designed to show FW where all the payloads are.
563  */
564 struct iwl_dram_regions {
565 	struct iwl_dram_data drams[IPC_DRAM_MAP_ENTRY_NUM_MAX];
566 	struct iwl_dram_data prph_scratch_mem_desc;
567 	u8 n_regions;
568 };
569 
570 /**
571  * struct iwl_fw_mon - fw monitor per allocation id
572  * @num_frags: number of fragments
573  * @frags: an array of DRAM buffer fragments
574  */
575 struct iwl_fw_mon {
576 	u32 num_frags;
577 	struct iwl_dram_data *frags;
578 };
579 
580 /**
581  * struct iwl_self_init_dram - dram data used by self init process
582  * @fw: lmac and umac dram data
583  * @fw_cnt: total number of items in array
584  * @paging: paging dram data
585  * @paging_cnt: total number of items in array
586  */
587 struct iwl_self_init_dram {
588 	struct iwl_dram_data *fw;
589 	int fw_cnt;
590 	struct iwl_dram_data *paging;
591 	int paging_cnt;
592 };
593 
594 /**
595  * struct iwl_imr_data - imr dram data used during debug process
596  * @imr_enable: imr enable status received from fw
597  * @imr_size: imr dram size received from fw
598  * @sram_addr: sram address from debug tlv
599  * @sram_size: sram size from debug tlv
600  * @imr2sram_remainbyte: size remained after each dma transfer
601  * @imr_curr_addr: current dst address used during dma transfer
602  * @imr_base_addr: imr address received from fw
603  */
604 struct iwl_imr_data {
605 	u32 imr_enable;
606 	u32 imr_size;
607 	u32 sram_addr;
608 	u32 sram_size;
609 	u32 imr2sram_remainbyte;
610 	u64 imr_curr_addr;
611 	__le64 imr_base_addr;
612 };
613 
614 #define IWL_TRANS_CURRENT_PC_NAME_MAX_BYTES      32
615 
616 /**
617  * struct iwl_pc_data - program counter details
618  * @pc_name: cpu name
619  * @pc_address: cpu program counter
620  */
621 struct iwl_pc_data {
622 	u8  pc_name[IWL_TRANS_CURRENT_PC_NAME_MAX_BYTES];
623 	u32 pc_address;
624 };
625 
626 /**
627  * struct iwl_trans_debug - transport debug related data
628  *
629  * @n_dest_reg: num of reg_ops in %dbg_dest_tlv
630  * @rec_on: true iff there is a fw debug recording currently active
631  * @dest_tlv: points to the destination TLV for debug
632  * @conf_tlv: array of pointers to configuration TLVs for debug
633  * @trigger_tlv: array of pointers to triggers TLVs for debug
634  * @lmac_error_event_table: addrs of lmacs error tables
635  * @umac_error_event_table: addr of umac error table
636  * @tcm_error_event_table: address(es) of TCM error table(s)
637  * @rcm_error_event_table: address(es) of RCM error table(s)
638  * @error_event_table_tlv_status: bitmap that indicates what error table
639  *	pointers was recevied via TLV. uses enum &iwl_error_event_table_status
640  * @internal_ini_cfg: internal debug cfg state. Uses &enum iwl_ini_cfg_state
641  * @external_ini_cfg: external debug cfg state. Uses &enum iwl_ini_cfg_state
642  * @fw_mon_cfg: debug buffer allocation configuration
643  * @fw_mon_ini: DRAM buffer fragments per allocation id
644  * @fw_mon: DRAM buffer for firmware monitor
645  * @hw_error: equals true if hw error interrupt was received from the FW
646  * @ini_dest: debug monitor destination uses &enum iwl_fw_ini_buffer_location
647  * @unsupported_region_msk: unsupported regions out of active_regions
648  * @active_regions: active regions
649  * @debug_info_tlv_list: list of debug info TLVs
650  * @time_point: array of debug time points
651  * @periodic_trig_list: periodic triggers list
652  * @domains_bitmap: bitmap of active domains other than &IWL_FW_INI_DOMAIN_ALWAYS_ON
653  * @ucode_preset: preset based on ucode
654  * @restart_required: indicates debug restart is required
655  * @last_tp_resetfw: last handling of reset during debug timepoint
656  * @imr_data: IMR debug data allocation
657  * @dump_file_name_ext: dump file name extension
658  * @dump_file_name_ext_valid: dump file name extension if valid or not
659  * @num_pc: number of program counter for cpu
660  * @pc_data: details of the program counter
661  * @yoyo_bin_loaded: tells if a yoyo debug file has been loaded
662  */
663 struct iwl_trans_debug {
664 	u8 n_dest_reg;
665 	bool rec_on;
666 
667 	const struct iwl_fw_dbg_dest_tlv_v1 *dest_tlv;
668 	const struct iwl_fw_dbg_conf_tlv *conf_tlv[FW_DBG_CONF_MAX];
669 	struct iwl_fw_dbg_trigger_tlv * const *trigger_tlv;
670 
671 	u32 lmac_error_event_table[2];
672 	u32 umac_error_event_table;
673 	u32 tcm_error_event_table[2];
674 	u32 rcm_error_event_table[2];
675 	unsigned int error_event_table_tlv_status;
676 
677 	enum iwl_ini_cfg_state internal_ini_cfg;
678 	enum iwl_ini_cfg_state external_ini_cfg;
679 
680 	struct iwl_fw_ini_allocation_tlv fw_mon_cfg[IWL_FW_INI_ALLOCATION_NUM];
681 	struct iwl_fw_mon fw_mon_ini[IWL_FW_INI_ALLOCATION_NUM];
682 
683 	struct iwl_dram_data fw_mon;
684 
685 	bool hw_error;
686 	enum iwl_fw_ini_buffer_location ini_dest;
687 
688 	u64 unsupported_region_msk;
689 	struct iwl_ucode_tlv *active_regions[IWL_FW_INI_MAX_REGION_ID];
690 	struct list_head debug_info_tlv_list;
691 	struct iwl_dbg_tlv_time_point_data time_point[IWL_FW_INI_TIME_POINT_NUM];
692 	struct list_head periodic_trig_list;
693 
694 	u32 domains_bitmap;
695 	u32 ucode_preset;
696 	bool restart_required;
697 	u32 last_tp_resetfw;
698 	struct iwl_imr_data imr_data;
699 	u8 dump_file_name_ext[IWL_FW_INI_MAX_NAME];
700 	bool dump_file_name_ext_valid;
701 	u32 num_pc;
702 	struct iwl_pc_data *pc_data;
703 	bool yoyo_bin_loaded;
704 };
705 
706 struct iwl_dma_ptr {
707 	dma_addr_t dma;
708 	void *addr;
709 	size_t size;
710 };
711 
712 struct iwl_cmd_meta {
713 	/* only for SYNC commands, iff the reply skb is wanted */
714 	struct iwl_host_cmd *source;
715 	u32 flags;
716 	u32 tbs;
717 };
718 
719 /*
720  * The FH will write back to the first TB only, so we need to copy some data
721  * into the buffer regardless of whether it should be mapped or not.
722  * This indicates how big the first TB must be to include the scratch buffer
723  * and the assigned PN.
724  * Since PN location is 8 bytes at offset 12, it's 20 now.
725  * If we make it bigger then allocations will be bigger and copy slower, so
726  * that's probably not useful.
727  */
728 #define IWL_FIRST_TB_SIZE	20
729 #define IWL_FIRST_TB_SIZE_ALIGN ALIGN(IWL_FIRST_TB_SIZE, 64)
730 
731 struct iwl_pcie_txq_entry {
732 	void *cmd;
733 	struct sk_buff *skb;
734 	/* buffer to free after command completes */
735 	const void *free_buf;
736 	struct iwl_cmd_meta meta;
737 };
738 
739 struct iwl_pcie_first_tb_buf {
740 	u8 buf[IWL_FIRST_TB_SIZE_ALIGN];
741 };
742 
743 /**
744  * struct iwl_txq - Tx Queue for DMA
745  * @tfds: transmit frame descriptors (DMA memory)
746  * @first_tb_bufs: start of command headers, including scratch buffers, for
747  *	the writeback -- this is DMA memory and an array holding one buffer
748  *	for each command on the queue
749  * @first_tb_dma: DMA address for the first_tb_bufs start
750  * @entries: transmit entries (driver state)
751  * @lock: queue lock
752  * @stuck_timer: timer that fires if queue gets stuck
753  * @trans: pointer back to transport (for timer)
754  * @need_update: indicates need to update read/write index
755  * @ampdu: true if this queue is an ampdu queue for an specific RA/TID
756  * @wd_timeout: queue watchdog timeout (jiffies) - per queue
757  * @frozen: tx stuck queue timer is frozen
758  * @frozen_expiry_remainder: remember how long until the timer fires
759  * @block: queue is blocked
760  * @bc_tbl: byte count table of the queue (relevant only for gen2 transport)
761  * @write_ptr: 1-st empty entry (index) host_w
762  * @read_ptr: last used entry (index) host_r
763  * @dma_addr:  physical addr for BD's
764  * @n_window: safe queue window
765  * @id: queue id
766  * @low_mark: low watermark, resume queue if free space more than this
767  * @high_mark: high watermark, stop queue if free space less than this
768  * @overflow_q: overflow queue for handling frames that didn't fit on HW queue
769  * @overflow_tx: need to transmit from overflow
770  *
771  * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
772  * descriptors) and required locking structures.
773  *
774  * Note the difference between TFD_QUEUE_SIZE_MAX and n_window: the hardware
775  * always assumes 256 descriptors, so TFD_QUEUE_SIZE_MAX is always 256 (unless
776  * there might be HW changes in the future). For the normal TX
777  * queues, n_window, which is the size of the software queue data
778  * is also 256; however, for the command queue, n_window is only
779  * 32 since we don't need so many commands pending. Since the HW
780  * still uses 256 BDs for DMA though, TFD_QUEUE_SIZE_MAX stays 256.
781  * This means that we end up with the following:
782  *  HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
783  *  SW entries:           | 0      | ... | 31          |
784  * where N is a number between 0 and 7. This means that the SW
785  * data is a window overlayed over the HW queue.
786  */
787 struct iwl_txq {
788 	void *tfds;
789 	struct iwl_pcie_first_tb_buf *first_tb_bufs;
790 	dma_addr_t first_tb_dma;
791 	struct iwl_pcie_txq_entry *entries;
792 	/* lock for syncing changes on the queue */
793 	spinlock_t lock;
794 	unsigned long frozen_expiry_remainder;
795 	struct timer_list stuck_timer;
796 	struct iwl_trans *trans;
797 	bool need_update;
798 	bool frozen;
799 	bool ampdu;
800 	int block;
801 	unsigned long wd_timeout;
802 	struct sk_buff_head overflow_q;
803 	struct iwl_dma_ptr bc_tbl;
804 
805 	int write_ptr;
806 	int read_ptr;
807 	dma_addr_t dma_addr;
808 	int n_window;
809 	u32 id;
810 	int low_mark;
811 	int high_mark;
812 
813 	bool overflow_tx;
814 };
815 
816 /**
817  * struct iwl_trans - transport common data
818  *
819  * @csme_own: true if we couldn't get ownership on the device
820  * @op_mode: pointer to the op_mode
821  * @trans_cfg: the trans-specific configuration part
822  * @cfg: pointer to the configuration
823  * @drv: pointer to iwl_drv
824  * @state: current device state
825  * @status: a bit-mask of transport status flags
826  * @dev: pointer to struct device * that represents the device
827  * @max_skb_frags: maximum number of fragments an SKB can have when transmitted.
828  *	0 indicates that frag SKBs (NETIF_F_SG) aren't supported.
829  * @hw_rf_id: a u32 with the device RF ID
830  * @hw_cnv_id: a u32 with the device CNV ID
831  * @hw_crf_id: a u32 with the device CRF ID
832  * @hw_wfpm_id: a u32 with the device wfpm ID
833  * @hw_id: a u32 with the ID of the device / sub-device.
834  *	Set during transport allocation.
835  * @hw_id_str: a string with info about HW ID. Set during transport allocation.
836  * @sku_id: the SKU identifier (for PNVM matching)
837  * @pnvm_loaded: indicates PNVM was loaded
838  * @hw_rev: the revision data of the HW
839  * @hw_rev_step: The mac step of the HW
840  * @pm_support: set to true in start_hw if link pm is supported
841  * @ltr_enabled: set to true if the LTR is enabled
842  * @fail_to_parse_pnvm_image: set to true if pnvm parsing failed
843  * @reduce_power_loaded: indicates reduced power section was loaded
844  * @failed_to_load_reduce_power_image: set to true if pnvm loading failed
845  * @command_groups: pointer to command group name list array
846  * @command_groups_size: array size of @command_groups
847  * @wide_cmd_header: true when ucode supports wide command header format
848  * @wait_command_queue: wait queue for sync commands
849  * @num_rx_queues: number of RX queues allocated by the transport;
850  *	the transport must set this before calling iwl_drv_start()
851  * @iml_len: the length of the image loader
852  * @iml: a pointer to the image loader itself
853  * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only.
854  *	The user should use iwl_trans_{alloc,free}_tx_cmd.
855  * @dev_cmd_pool_name: name for the TX command allocation pool
856  * @dbgfs_dir: iwlwifi debugfs base dir for this device
857  * @sync_cmd_lockdep_map: lockdep map for checking sync commands
858  * @rx_mpdu_cmd: MPDU RX command ID, must be assigned by opmode before
859  *	starting the firmware, used for tracing
860  * @rx_mpdu_cmd_hdr_size: used for tracing, amount of data before the
861  *	start of the 802.11 header in the @rx_mpdu_cmd
862  * @dbg: additional debug data, see &struct iwl_trans_debug
863  * @init_dram: FW initialization DMA data
864  * @system_pm_mode: the system-wide power management mode in use.
865  *	This mode is set dynamically, depending on the WoWLAN values
866  *	configured from the userspace at runtime.
867  * @name: the device name
868  * @mbx_addr_0_step: step address data 0
869  * @mbx_addr_1_step: step address data 1
870  * @pcie_link_speed: current PCIe link speed (%PCI_EXP_LNKSTA_CLS_*),
871  *	only valid for discrete (not integrated) NICs
872  * @invalid_tx_cmd: invalid TX command buffer
873  * @reduced_cap_sku: reduced capability supported SKU
874  * @no_160: device not supporting 160 MHz
875  * @step_urm: STEP is in URM, no support for MCS>9 in 320 MHz
876  * @trans_specific: data for the specific transport this is allocated for/with
877  */
878 struct iwl_trans {
879 	bool csme_own;
880 	struct iwl_op_mode *op_mode;
881 	const struct iwl_cfg_trans_params *trans_cfg;
882 	const struct iwl_cfg *cfg;
883 	struct iwl_drv *drv;
884 	enum iwl_trans_state state;
885 	unsigned long status;
886 
887 	struct device *dev;
888 	u32 max_skb_frags;
889 	u32 hw_rev;
890 	u32 hw_rev_step;
891 	u32 hw_rf_id;
892 	u32 hw_crf_id;
893 	u32 hw_cnv_id;
894 	u32 hw_wfpm_id;
895 	u32 hw_id;
896 	char hw_id_str[52];
897 	u32 sku_id[3];
898 	bool reduced_cap_sku;
899 	u8 no_160:1, step_urm:1;
900 
901 	u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size;
902 
903 	bool pm_support;
904 	bool ltr_enabled;
905 	u8 pnvm_loaded:1;
906 	u8 fail_to_parse_pnvm_image:1;
907 	u8 reduce_power_loaded:1;
908 	u8 failed_to_load_reduce_power_image:1;
909 
910 	const struct iwl_hcmd_arr *command_groups;
911 	int command_groups_size;
912 	bool wide_cmd_header;
913 
914 	wait_queue_head_t wait_command_queue;
915 	u8 num_rx_queues;
916 
917 	size_t iml_len;
918 	u8 *iml;
919 
920 	/* The following fields are internal only */
921 	struct kmem_cache *dev_cmd_pool;
922 	char dev_cmd_pool_name[50];
923 
924 	struct dentry *dbgfs_dir;
925 
926 #ifdef CONFIG_LOCKDEP
927 	struct lockdep_map sync_cmd_lockdep_map;
928 #endif
929 
930 	struct iwl_trans_debug dbg;
931 	struct iwl_self_init_dram init_dram;
932 
933 	enum iwl_plat_pm_mode system_pm_mode;
934 
935 	const char *name;
936 	u32 mbx_addr_0_step;
937 	u32 mbx_addr_1_step;
938 
939 	u8 pcie_link_speed;
940 
941 	struct iwl_dma_ptr invalid_tx_cmd;
942 
943 	/* pointer to trans specific struct */
944 	/*Ensure that this pointer will always be aligned to sizeof pointer */
945 	char trans_specific[] __aligned(sizeof(void *));
946 };
947 
948 const char *iwl_get_cmd_string(struct iwl_trans *trans, u32 id);
949 int iwl_cmd_groups_verify_sorted(const struct iwl_trans_config *trans);
950 
951 void iwl_trans_configure(struct iwl_trans *trans,
952 			 const struct iwl_trans_config *trans_cfg);
953 
954 int iwl_trans_start_hw(struct iwl_trans *trans);
955 
956 void iwl_trans_op_mode_leave(struct iwl_trans *trans);
957 
958 void iwl_trans_fw_alive(struct iwl_trans *trans, u32 scd_addr);
959 
960 int iwl_trans_start_fw(struct iwl_trans *trans, const struct fw_img *fw,
961 		       bool run_in_rfkill);
962 
963 void iwl_trans_stop_device(struct iwl_trans *trans);
964 
965 int iwl_trans_d3_suspend(struct iwl_trans *trans, bool test, bool reset);
966 
967 int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status,
968 			bool test, bool reset);
969 
970 struct iwl_trans_dump_data *
971 iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask,
972 		    const struct iwl_dump_sanitize_ops *sanitize_ops,
973 		    void *sanitize_ctx);
974 
975 static inline struct iwl_device_tx_cmd *
976 iwl_trans_alloc_tx_cmd(struct iwl_trans *trans)
977 {
978 	return kmem_cache_zalloc(trans->dev_cmd_pool, GFP_ATOMIC);
979 }
980 
981 int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd);
982 
983 static inline void iwl_trans_free_tx_cmd(struct iwl_trans *trans,
984 					 struct iwl_device_tx_cmd *dev_cmd)
985 {
986 	kmem_cache_free(trans->dev_cmd_pool, dev_cmd);
987 }
988 
989 int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb,
990 		 struct iwl_device_tx_cmd *dev_cmd, int queue);
991 
992 void iwl_trans_reclaim(struct iwl_trans *trans, int queue, int ssn,
993 		       struct sk_buff_head *skbs, bool is_flush);
994 
995 void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue, int ptr);
996 
997 void iwl_trans_txq_disable(struct iwl_trans *trans, int queue,
998 			   bool configure_scd);
999 
1000 bool iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn,
1001 			      const struct iwl_trans_txq_scd_cfg *cfg,
1002 			      unsigned int queue_wdg_timeout);
1003 
1004 int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue,
1005 			       struct iwl_trans_rxq_dma_data *data);
1006 
1007 void iwl_trans_txq_free(struct iwl_trans *trans, int queue);
1008 
1009 int iwl_trans_txq_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask,
1010 			u8 tid, int size, unsigned int wdg_timeout);
1011 
1012 void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans,
1013 				   int txq_id, bool shared_mode);
1014 
1015 static inline void iwl_trans_txq_enable(struct iwl_trans *trans, int queue,
1016 					int fifo, int sta_id, int tid,
1017 					int frame_limit, u16 ssn,
1018 					unsigned int queue_wdg_timeout)
1019 {
1020 	struct iwl_trans_txq_scd_cfg cfg = {
1021 		.fifo = fifo,
1022 		.sta_id = sta_id,
1023 		.tid = tid,
1024 		.frame_limit = frame_limit,
1025 		.aggregate = sta_id >= 0,
1026 	};
1027 
1028 	iwl_trans_txq_enable_cfg(trans, queue, ssn, &cfg, queue_wdg_timeout);
1029 }
1030 
1031 static inline
1032 void iwl_trans_ac_txq_enable(struct iwl_trans *trans, int queue, int fifo,
1033 			     unsigned int queue_wdg_timeout)
1034 {
1035 	struct iwl_trans_txq_scd_cfg cfg = {
1036 		.fifo = fifo,
1037 		.sta_id = -1,
1038 		.tid = IWL_MAX_TID_COUNT,
1039 		.frame_limit = IWL_FRAME_LIMIT,
1040 		.aggregate = false,
1041 	};
1042 
1043 	iwl_trans_txq_enable_cfg(trans, queue, 0, &cfg, queue_wdg_timeout);
1044 }
1045 
1046 void iwl_trans_freeze_txq_timer(struct iwl_trans *trans,
1047 				unsigned long txqs, bool freeze);
1048 
1049 int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans, u32 txqs);
1050 
1051 int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue);
1052 
1053 void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val);
1054 
1055 void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val);
1056 
1057 u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs);
1058 
1059 u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs);
1060 
1061 void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs, u32 val);
1062 
1063 int iwl_trans_read_mem(struct iwl_trans *trans, u32 addr,
1064 		       void *buf, int dwords);
1065 
1066 int iwl_trans_read_config32(struct iwl_trans *trans, u32 ofs,
1067 			    u32 *val);
1068 
1069 #ifdef CONFIG_IWLWIFI_DEBUGFS
1070 void iwl_trans_debugfs_cleanup(struct iwl_trans *trans);
1071 #endif
1072 
1073 #define iwl_trans_read_mem_bytes(trans, addr, buf, bufsize)		      \
1074 	do {								      \
1075 		if (__builtin_constant_p(bufsize))			      \
1076 			BUILD_BUG_ON((bufsize) % sizeof(u32));		      \
1077 		iwl_trans_read_mem(trans, addr, buf, (bufsize) / sizeof(u32));\
1078 	} while (0)
1079 
1080 int iwl_trans_write_imr_mem(struct iwl_trans *trans, u32 dst_addr,
1081 			    u64 src_addr, u32 byte_cnt);
1082 
1083 static inline u32 iwl_trans_read_mem32(struct iwl_trans *trans, u32 addr)
1084 {
1085 	u32 value;
1086 
1087 	if (iwl_trans_read_mem(trans, addr, &value, 1))
1088 		return 0xa5a5a5a5;
1089 
1090 	return value;
1091 }
1092 
1093 int iwl_trans_write_mem(struct iwl_trans *trans, u32 addr,
1094 			const void *buf, int dwords);
1095 
1096 static inline u32 iwl_trans_write_mem32(struct iwl_trans *trans, u32 addr,
1097 					u32 val)
1098 {
1099 	return iwl_trans_write_mem(trans, addr, &val, 1);
1100 }
1101 
1102 void iwl_trans_set_pmi(struct iwl_trans *trans, bool state);
1103 
1104 int iwl_trans_sw_reset(struct iwl_trans *trans, bool retake_ownership);
1105 
1106 void iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg,
1107 			     u32 mask, u32 value);
1108 
1109 bool _iwl_trans_grab_nic_access(struct iwl_trans *trans);
1110 
1111 #define iwl_trans_grab_nic_access(trans)		\
1112 	__cond_lock(nic_access,				\
1113 		    likely(_iwl_trans_grab_nic_access(trans)))
1114 
1115 void __releases(nic_access)
1116 iwl_trans_release_nic_access(struct iwl_trans *trans);
1117 
1118 static inline void iwl_trans_fw_error(struct iwl_trans *trans, bool sync)
1119 {
1120 	if (WARN_ON_ONCE(!trans->op_mode))
1121 		return;
1122 
1123 	/* prevent double restarts due to the same erroneous FW */
1124 	if (!test_and_set_bit(STATUS_FW_ERROR, &trans->status)) {
1125 		iwl_op_mode_nic_error(trans->op_mode, sync);
1126 		trans->state = IWL_TRANS_NO_FW;
1127 	}
1128 }
1129 
1130 static inline bool iwl_trans_fw_running(struct iwl_trans *trans)
1131 {
1132 	return trans->state == IWL_TRANS_FW_ALIVE;
1133 }
1134 
1135 void iwl_trans_sync_nmi(struct iwl_trans *trans);
1136 
1137 void iwl_trans_sync_nmi_with_addr(struct iwl_trans *trans, u32 inta_addr,
1138 				  u32 sw_err_bit);
1139 
1140 int iwl_trans_load_pnvm(struct iwl_trans *trans,
1141 			const struct iwl_pnvm_image *pnvm_data,
1142 			const struct iwl_ucode_capabilities *capa);
1143 
1144 void iwl_trans_set_pnvm(struct iwl_trans *trans,
1145 			const struct iwl_ucode_capabilities *capa);
1146 
1147 int iwl_trans_load_reduce_power(struct iwl_trans *trans,
1148 				const struct iwl_pnvm_image *payloads,
1149 				const struct iwl_ucode_capabilities *capa);
1150 
1151 void iwl_trans_set_reduce_power(struct iwl_trans *trans,
1152 				const struct iwl_ucode_capabilities *capa);
1153 
1154 static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans)
1155 {
1156 	return trans->dbg.internal_ini_cfg != IWL_INI_CFG_STATE_NOT_LOADED ||
1157 		trans->dbg.external_ini_cfg != IWL_INI_CFG_STATE_NOT_LOADED;
1158 }
1159 
1160 void iwl_trans_interrupts(struct iwl_trans *trans, bool enable);
1161 
1162 /*****************************************************
1163  * transport helper functions
1164  *****************************************************/
1165 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
1166 			  struct device *dev,
1167 			  const struct iwl_cfg_trans_params *cfg_trans);
1168 int iwl_trans_init(struct iwl_trans *trans);
1169 void iwl_trans_free(struct iwl_trans *trans);
1170 
1171 static inline bool iwl_trans_is_hw_error_value(u32 val)
1172 {
1173 	return ((val & ~0xf) == 0xa5a5a5a0) || ((val & ~0xf) == 0x5a5a5a50);
1174 }
1175 
1176 /*****************************************************
1177  * PCIe handling
1178  *****************************************************/
1179 int __must_check iwl_pci_register_driver(void);
1180 void iwl_pci_unregister_driver(void);
1181 void iwl_trans_pcie_remove(struct iwl_trans *trans, bool rescan);
1182 
1183 int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans,
1184 			     struct iwl_host_cmd *cmd);
1185 
1186 #endif /* __iwl_trans_h__ */
1187