internal.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2015 Intel Corporation. All rights reserved.
  4. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  5. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  6. * Copyright(c) 2018 Intel Corporation
  7. *
  8. * Portions of this file are derived from the ipw3945 project, as well
  9. * as portions of the ieee80211 subsystem header files.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  18. * more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along with
  21. * this program.
  22. *
  23. * The full GNU General Public License is included in this distribution in the
  24. * file called LICENSE.
  25. *
  26. * Contact Information:
  27. * Intel Linux Wireless <linuxwifi@intel.com>
  28. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  29. *
  30. *****************************************************************************/
  31. #ifndef __iwl_trans_int_pcie_h__
  32. #define __iwl_trans_int_pcie_h__
  33. #include <linux/spinlock.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/skbuff.h>
  36. #include <linux/wait.h>
  37. #include <linux/pci.h>
  38. #include <linux/timer.h>
  39. #include <linux/cpu.h>
  40. #include "iwl-fh.h"
  41. #include "iwl-csr.h"
  42. #include "iwl-trans.h"
  43. #include "iwl-debug.h"
  44. #include "iwl-io.h"
  45. #include "iwl-op-mode.h"
  46. #include "iwl-drv.h"
  47. /* We need 2 entries for the TX command and header, and another one might
  48. * be needed for potential data in the SKB's head. The remaining ones can
  49. * be used for frags.
  50. */
  51. #define IWL_PCIE_MAX_FRAGS(x) (x->max_tbs - 3)
  52. /*
  53. * RX related structures and functions
  54. */
  55. #define RX_NUM_QUEUES 1
  56. #define RX_POST_REQ_ALLOC 2
  57. #define RX_CLAIM_REQ_ALLOC 8
  58. #define RX_PENDING_WATERMARK 16
  59. #define FIRST_RX_QUEUE 512
  60. struct iwl_host_cmd;
  61. /*This file includes the declaration that are internal to the
  62. * trans_pcie layer */
  63. /**
  64. * struct iwl_rx_mem_buffer
  65. * @page_dma: bus address of rxb page
  66. * @page: driver's pointer to the rxb page
  67. * @invalid: rxb is in driver ownership - not owned by HW
  68. * @vid: index of this rxb in the global table
  69. * @size: size used from the buffer
  70. */
  71. struct iwl_rx_mem_buffer {
  72. dma_addr_t page_dma;
  73. struct page *page;
  74. u16 vid;
  75. bool invalid;
  76. struct list_head list;
  77. u32 size;
  78. };
  79. /**
  80. * struct isr_statistics - interrupt statistics
  81. *
  82. */
  83. struct isr_statistics {
  84. u32 hw;
  85. u32 sw;
  86. u32 err_code;
  87. u32 sch;
  88. u32 alive;
  89. u32 rfkill;
  90. u32 ctkill;
  91. u32 wakeup;
  92. u32 rx;
  93. u32 tx;
  94. u32 unhandled;
  95. };
  96. #define IWL_CD_STTS_OPTIMIZED_POS 0
  97. #define IWL_CD_STTS_OPTIMIZED_MSK 0x01
  98. #define IWL_CD_STTS_TRANSFER_STATUS_POS 1
  99. #define IWL_CD_STTS_TRANSFER_STATUS_MSK 0x0E
  100. #define IWL_CD_STTS_WIFI_STATUS_POS 4
  101. #define IWL_CD_STTS_WIFI_STATUS_MSK 0xF0
  102. /**
  103. * enum iwl_completion_desc_transfer_status - transfer status (bits 1-3)
  104. * @IWL_CD_STTS_END_TRANSFER: successful transfer complete.
  105. * In sniffer mode, when split is used, set in last CD completion. (RX)
  106. * @IWL_CD_STTS_OVERFLOW: In sniffer mode, when using split - used for
  107. * all CD completion. (RX)
  108. * @IWL_CD_STTS_ABORTED: CR abort / close flow. (RX)
  109. */
  110. enum iwl_completion_desc_transfer_status {
  111. IWL_CD_STTS_UNUSED,
  112. IWL_CD_STTS_UNUSED_2,
  113. IWL_CD_STTS_END_TRANSFER,
  114. IWL_CD_STTS_OVERFLOW,
  115. IWL_CD_STTS_ABORTED,
  116. IWL_CD_STTS_ERROR,
  117. };
  118. /**
  119. * enum iwl_completion_desc_wifi_status - wifi status (bits 4-7)
  120. * @IWL_CD_STTS_VALID: the packet is valid (RX)
  121. * @IWL_CD_STTS_FCS_ERR: frame check sequence error (RX)
  122. * @IWL_CD_STTS_SEC_KEY_ERR: error handling the security key of rx (RX)
  123. * @IWL_CD_STTS_DECRYPTION_ERR: error decrypting the frame (RX)
  124. * @IWL_CD_STTS_DUP: duplicate packet (RX)
  125. * @IWL_CD_STTS_ICV_MIC_ERR: MIC error (RX)
  126. * @IWL_CD_STTS_INTERNAL_SNAP_ERR: problems removing the snap (RX)
  127. * @IWL_CD_STTS_SEC_PORT_FAIL: security port fail (RX)
  128. * @IWL_CD_STTS_BA_OLD_SN: block ack received old SN (RX)
  129. * @IWL_CD_STTS_QOS_NULL: QoS null packet (RX)
  130. * @IWL_CD_STTS_MAC_HDR_ERR: MAC header conversion error (RX)
  131. * @IWL_CD_STTS_MAX_RETRANS: reached max number of retransmissions (TX)
  132. * @IWL_CD_STTS_EX_LIFETIME: exceeded lifetime (TX)
  133. * @IWL_CD_STTS_NOT_USED: completed but not used (RX)
  134. * @IWL_CD_STTS_REPLAY_ERR: pn check failed, replay error (RX)
  135. */
  136. enum iwl_completion_desc_wifi_status {
  137. IWL_CD_STTS_VALID,
  138. IWL_CD_STTS_FCS_ERR,
  139. IWL_CD_STTS_SEC_KEY_ERR,
  140. IWL_CD_STTS_DECRYPTION_ERR,
  141. IWL_CD_STTS_DUP,
  142. IWL_CD_STTS_ICV_MIC_ERR,
  143. IWL_CD_STTS_INTERNAL_SNAP_ERR,
  144. IWL_CD_STTS_SEC_PORT_FAIL,
  145. IWL_CD_STTS_BA_OLD_SN,
  146. IWL_CD_STTS_QOS_NULL,
  147. IWL_CD_STTS_MAC_HDR_ERR,
  148. IWL_CD_STTS_MAX_RETRANS,
  149. IWL_CD_STTS_EX_LIFETIME,
  150. IWL_CD_STTS_NOT_USED,
  151. IWL_CD_STTS_REPLAY_ERR,
  152. };
  153. #define IWL_RX_TD_TYPE_MSK 0xff000000
  154. #define IWL_RX_TD_SIZE_MSK 0x00ffffff
  155. #define IWL_RX_TD_SIZE_2K BIT(11)
  156. #define IWL_RX_TD_TYPE 0
  157. /**
  158. * struct iwl_rx_transfer_desc - transfer descriptor
  159. * @type_n_size: buffer type (bit 0: external buff valid,
  160. * bit 1: optional footer valid, bit 2-7: reserved)
  161. * and buffer size
  162. * @addr: ptr to free buffer start address
  163. * @rbid: unique tag of the buffer
  164. * @reserved: reserved
  165. */
  166. struct iwl_rx_transfer_desc {
  167. __le32 type_n_size;
  168. __le64 addr;
  169. __le16 rbid;
  170. __le16 reserved;
  171. } __packed;
  172. #define IWL_RX_CD_SIZE 0xffffff00
  173. /**
  174. * struct iwl_rx_completion_desc - completion descriptor
  175. * @type: buffer type (bit 0: external buff valid,
  176. * bit 1: optional footer valid, bit 2-7: reserved)
  177. * @status: status of the completion
  178. * @reserved1: reserved
  179. * @rbid: unique tag of the received buffer
  180. * @size: buffer size, masked by IWL_RX_CD_SIZE
  181. * @reserved2: reserved
  182. */
  183. struct iwl_rx_completion_desc {
  184. u8 type;
  185. u8 status;
  186. __le16 reserved1;
  187. __le16 rbid;
  188. __le32 size;
  189. u8 reserved2[22];
  190. } __packed;
  191. /**
  192. * struct iwl_rxq - Rx queue
  193. * @id: queue index
  194. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd).
  195. * Address size is 32 bit in pre-9000 devices and 64 bit in 9000 devices.
  196. * In 22560 devices it is a pointer to a list of iwl_rx_transfer_desc's
  197. * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
  198. * @ubd: driver's pointer to buffer of used receive buffer descriptors (rbd)
  199. * @ubd_dma: physical address of buffer of used receive buffer descriptors (rbd)
  200. * @tr_tail: driver's pointer to the transmission ring tail buffer
  201. * @tr_tail_dma: physical address of the buffer for the transmission ring tail
  202. * @cr_tail: driver's pointer to the completion ring tail buffer
  203. * @cr_tail_dma: physical address of the buffer for the completion ring tail
  204. * @read: Shared index to newest available Rx buffer
  205. * @write: Shared index to oldest written Rx packet
  206. * @free_count: Number of pre-allocated buffers in rx_free
  207. * @used_count: Number of RBDs handled to allocator to use for allocation
  208. * @write_actual:
  209. * @rx_free: list of RBDs with allocated RB ready for use
  210. * @rx_used: list of RBDs with no RB attached
  211. * @need_update: flag to indicate we need to update read/write index
  212. * @rb_stts: driver's pointer to receive buffer status
  213. * @rb_stts_dma: bus address of receive buffer status
  214. * @lock:
  215. * @queue: actual rx queue. Not used for multi-rx queue.
  216. *
  217. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  218. */
  219. struct iwl_rxq {
  220. int id;
  221. void *bd;
  222. dma_addr_t bd_dma;
  223. union {
  224. void *used_bd;
  225. __le32 *bd_32;
  226. struct iwl_rx_completion_desc *cd;
  227. };
  228. dma_addr_t used_bd_dma;
  229. __le16 *tr_tail;
  230. dma_addr_t tr_tail_dma;
  231. __le16 *cr_tail;
  232. dma_addr_t cr_tail_dma;
  233. u32 read;
  234. u32 write;
  235. u32 free_count;
  236. u32 used_count;
  237. u32 write_actual;
  238. u32 queue_size;
  239. struct list_head rx_free;
  240. struct list_head rx_used;
  241. bool need_update;
  242. void *rb_stts;
  243. dma_addr_t rb_stts_dma;
  244. spinlock_t lock;
  245. struct napi_struct napi;
  246. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  247. };
  248. /**
  249. * struct iwl_rb_allocator - Rx allocator
  250. * @req_pending: number of requests the allcator had not processed yet
  251. * @req_ready: number of requests honored and ready for claiming
  252. * @rbd_allocated: RBDs with pages allocated and ready to be handled to
  253. * the queue. This is a list of &struct iwl_rx_mem_buffer
  254. * @rbd_empty: RBDs with no page attached for allocator use. This is a list
  255. * of &struct iwl_rx_mem_buffer
  256. * @lock: protects the rbd_allocated and rbd_empty lists
  257. * @alloc_wq: work queue for background calls
  258. * @rx_alloc: work struct for background calls
  259. */
  260. struct iwl_rb_allocator {
  261. atomic_t req_pending;
  262. atomic_t req_ready;
  263. struct list_head rbd_allocated;
  264. struct list_head rbd_empty;
  265. spinlock_t lock;
  266. struct workqueue_struct *alloc_wq;
  267. struct work_struct rx_alloc;
  268. };
  269. struct iwl_dma_ptr {
  270. dma_addr_t dma;
  271. void *addr;
  272. size_t size;
  273. };
  274. /**
  275. * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
  276. * @index -- current index
  277. */
  278. static inline int iwl_queue_inc_wrap(struct iwl_trans *trans, int index)
  279. {
  280. return ++index & (trans->cfg->base_params->max_tfd_queue_size - 1);
  281. }
  282. /**
  283. * iwl_get_closed_rb_stts - get closed rb stts from different structs
  284. * @rxq - the rxq to get the rb stts from
  285. */
  286. static inline __le16 iwl_get_closed_rb_stts(struct iwl_trans *trans,
  287. struct iwl_rxq *rxq)
  288. {
  289. if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) {
  290. __le16 *rb_stts = rxq->rb_stts;
  291. return READ_ONCE(*rb_stts);
  292. } else {
  293. struct iwl_rb_status *rb_stts = rxq->rb_stts;
  294. return READ_ONCE(rb_stts->closed_rb_num);
  295. }
  296. }
  297. /**
  298. * iwl_queue_dec_wrap - decrement queue index, wrap back to end
  299. * @index -- current index
  300. */
  301. static inline int iwl_queue_dec_wrap(struct iwl_trans *trans, int index)
  302. {
  303. return --index & (trans->cfg->base_params->max_tfd_queue_size - 1);
  304. }
  305. struct iwl_cmd_meta {
  306. /* only for SYNC commands, iff the reply skb is wanted */
  307. struct iwl_host_cmd *source;
  308. u32 flags;
  309. u32 tbs;
  310. };
  311. #define TFD_TX_CMD_SLOTS 256
  312. #define TFD_CMD_SLOTS 32
  313. /*
  314. * The FH will write back to the first TB only, so we need to copy some data
  315. * into the buffer regardless of whether it should be mapped or not.
  316. * This indicates how big the first TB must be to include the scratch buffer
  317. * and the assigned PN.
  318. * Since PN location is 8 bytes at offset 12, it's 20 now.
  319. * If we make it bigger then allocations will be bigger and copy slower, so
  320. * that's probably not useful.
  321. */
  322. #define IWL_FIRST_TB_SIZE 20
  323. #define IWL_FIRST_TB_SIZE_ALIGN ALIGN(IWL_FIRST_TB_SIZE, 64)
  324. struct iwl_pcie_txq_entry {
  325. struct iwl_device_cmd *cmd;
  326. struct sk_buff *skb;
  327. /* buffer to free after command completes */
  328. const void *free_buf;
  329. struct iwl_cmd_meta meta;
  330. };
  331. struct iwl_pcie_first_tb_buf {
  332. u8 buf[IWL_FIRST_TB_SIZE_ALIGN];
  333. };
  334. /**
  335. * struct iwl_txq - Tx Queue for DMA
  336. * @q: generic Rx/Tx queue descriptor
  337. * @tfds: transmit frame descriptors (DMA memory)
  338. * @first_tb_bufs: start of command headers, including scratch buffers, for
  339. * the writeback -- this is DMA memory and an array holding one buffer
  340. * for each command on the queue
  341. * @first_tb_dma: DMA address for the first_tb_bufs start
  342. * @entries: transmit entries (driver state)
  343. * @lock: queue lock
  344. * @stuck_timer: timer that fires if queue gets stuck
  345. * @trans_pcie: pointer back to transport (for timer)
  346. * @need_update: indicates need to update read/write index
  347. * @ampdu: true if this queue is an ampdu queue for an specific RA/TID
  348. * @wd_timeout: queue watchdog timeout (jiffies) - per queue
  349. * @frozen: tx stuck queue timer is frozen
  350. * @frozen_expiry_remainder: remember how long until the timer fires
  351. * @bc_tbl: byte count table of the queue (relevant only for gen2 transport)
  352. * @write_ptr: 1-st empty entry (index) host_w
  353. * @read_ptr: last used entry (index) host_r
  354. * @dma_addr: physical addr for BD's
  355. * @n_window: safe queue window
  356. * @id: queue id
  357. * @low_mark: low watermark, resume queue if free space more than this
  358. * @high_mark: high watermark, stop queue if free space less than this
  359. *
  360. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  361. * descriptors) and required locking structures.
  362. *
  363. * Note the difference between TFD_QUEUE_SIZE_MAX and n_window: the hardware
  364. * always assumes 256 descriptors, so TFD_QUEUE_SIZE_MAX is always 256 (unless
  365. * there might be HW changes in the future). For the normal TX
  366. * queues, n_window, which is the size of the software queue data
  367. * is also 256; however, for the command queue, n_window is only
  368. * 32 since we don't need so many commands pending. Since the HW
  369. * still uses 256 BDs for DMA though, TFD_QUEUE_SIZE_MAX stays 256.
  370. * This means that we end up with the following:
  371. * HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
  372. * SW entries: | 0 | ... | 31 |
  373. * where N is a number between 0 and 7. This means that the SW
  374. * data is a window overlayed over the HW queue.
  375. */
  376. struct iwl_txq {
  377. void *tfds;
  378. struct iwl_pcie_first_tb_buf *first_tb_bufs;
  379. dma_addr_t first_tb_dma;
  380. struct iwl_pcie_txq_entry *entries;
  381. spinlock_t lock;
  382. unsigned long frozen_expiry_remainder;
  383. struct timer_list stuck_timer;
  384. struct iwl_trans_pcie *trans_pcie;
  385. bool need_update;
  386. bool frozen;
  387. bool ampdu;
  388. int block;
  389. unsigned long wd_timeout;
  390. struct sk_buff_head overflow_q;
  391. struct iwl_dma_ptr bc_tbl;
  392. int write_ptr;
  393. int read_ptr;
  394. dma_addr_t dma_addr;
  395. int n_window;
  396. u32 id;
  397. int low_mark;
  398. int high_mark;
  399. };
  400. static inline dma_addr_t
  401. iwl_pcie_get_first_tb_dma(struct iwl_txq *txq, int idx)
  402. {
  403. return txq->first_tb_dma +
  404. sizeof(struct iwl_pcie_first_tb_buf) * idx;
  405. }
  406. struct iwl_tso_hdr_page {
  407. struct page *page;
  408. u8 *pos;
  409. };
  410. /**
  411. * enum iwl_shared_irq_flags - level of sharing for irq
  412. * @IWL_SHARED_IRQ_NON_RX: interrupt vector serves non rx causes.
  413. * @IWL_SHARED_IRQ_FIRST_RSS: interrupt vector serves first RSS queue.
  414. */
  415. enum iwl_shared_irq_flags {
  416. IWL_SHARED_IRQ_NON_RX = BIT(0),
  417. IWL_SHARED_IRQ_FIRST_RSS = BIT(1),
  418. };
  419. /**
  420. * enum iwl_image_response_code - image response values
  421. * @IWL_IMAGE_RESP_DEF: the default value of the register
  422. * @IWL_IMAGE_RESP_SUCCESS: iml was read successfully
  423. * @IWL_IMAGE_RESP_FAIL: iml reading failed
  424. */
  425. enum iwl_image_response_code {
  426. IWL_IMAGE_RESP_DEF = 0,
  427. IWL_IMAGE_RESP_SUCCESS = 1,
  428. IWL_IMAGE_RESP_FAIL = 2,
  429. };
  430. /**
  431. * struct iwl_dram_data
  432. * @physical: page phy pointer
  433. * @block: pointer to the allocated block/page
  434. * @size: size of the block/page
  435. */
  436. struct iwl_dram_data {
  437. dma_addr_t physical;
  438. void *block;
  439. int size;
  440. };
  441. /**
  442. * struct iwl_self_init_dram - dram data used by self init process
  443. * @fw: lmac and umac dram data
  444. * @fw_cnt: total number of items in array
  445. * @paging: paging dram data
  446. * @paging_cnt: total number of items in array
  447. */
  448. struct iwl_self_init_dram {
  449. struct iwl_dram_data *fw;
  450. int fw_cnt;
  451. struct iwl_dram_data *paging;
  452. int paging_cnt;
  453. };
  454. /**
  455. * struct iwl_trans_pcie - PCIe transport specific data
  456. * @rxq: all the RX queue data
  457. * @rx_pool: initial pool of iwl_rx_mem_buffer for all the queues
  458. * @global_table: table mapping received VID from hw to rxb
  459. * @rba: allocator for RX replenishing
  460. * @ctxt_info: context information for FW self init
  461. * @ctxt_info_gen3: context information for gen3 devices
  462. * @prph_info: prph info for self init
  463. * @prph_scratch: prph scratch for self init
  464. * @ctxt_info_dma_addr: dma addr of context information
  465. * @prph_info_dma_addr: dma addr of prph info
  466. * @prph_scratch_dma_addr: dma addr of prph scratch
  467. * @ctxt_info_dma_addr: dma addr of context information
  468. * @init_dram: DRAM data of firmware image (including paging).
  469. * Context information addresses will be taken from here.
  470. * This is driver's local copy for keeping track of size and
  471. * count for allocating and freeing the memory.
  472. * @trans: pointer to the generic transport area
  473. * @scd_base_addr: scheduler sram base address in SRAM
  474. * @scd_bc_tbls: pointer to the byte count table of the scheduler
  475. * @kw: keep warm address
  476. * @pci_dev: basic pci-network driver stuff
  477. * @hw_base: pci hardware address support
  478. * @ucode_write_complete: indicates that the ucode has been copied.
  479. * @ucode_write_waitq: wait queue for uCode load
  480. * @cmd_queue - command queue number
  481. * @rx_buf_size: Rx buffer size
  482. * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes)
  483. * @scd_set_active: should the transport configure the SCD for HCMD queue
  484. * @sw_csum_tx: if true, then the transport will compute the csum of the TXed
  485. * frame.
  486. * @rx_page_order: page order for receive buffer size
  487. * @reg_lock: protect hw register access
  488. * @mutex: to protect stop_device / start_fw / start_hw
  489. * @cmd_in_flight: true when we have a host command in flight
  490. * @fw_mon_phys: physical address of the buffer for the firmware monitor
  491. * @fw_mon_page: points to the first page of the buffer for the firmware monitor
  492. * @fw_mon_size: size of the buffer for the firmware monitor
  493. * @msix_entries: array of MSI-X entries
  494. * @msix_enabled: true if managed to enable MSI-X
  495. * @shared_vec_mask: the type of causes the shared vector handles
  496. * (see iwl_shared_irq_flags).
  497. * @alloc_vecs: the number of interrupt vectors allocated by the OS
  498. * @def_irq: default irq for non rx causes
  499. * @fh_init_mask: initial unmasked fh causes
  500. * @hw_init_mask: initial unmasked hw causes
  501. * @fh_mask: current unmasked fh causes
  502. * @hw_mask: current unmasked hw causes
  503. * @in_rescan: true if we have triggered a device rescan
  504. * @scheduled_for_removal: true if we have scheduled a device removal
  505. */
  506. struct iwl_trans_pcie {
  507. struct iwl_rxq *rxq;
  508. struct iwl_rx_mem_buffer rx_pool[RX_POOL_SIZE];
  509. struct iwl_rx_mem_buffer *global_table[RX_POOL_SIZE];
  510. struct iwl_rb_allocator rba;
  511. union {
  512. struct iwl_context_info *ctxt_info;
  513. struct iwl_context_info_gen3 *ctxt_info_gen3;
  514. };
  515. struct iwl_prph_info *prph_info;
  516. struct iwl_prph_scratch *prph_scratch;
  517. dma_addr_t ctxt_info_dma_addr;
  518. dma_addr_t prph_info_dma_addr;
  519. dma_addr_t prph_scratch_dma_addr;
  520. dma_addr_t iml_dma_addr;
  521. struct iwl_self_init_dram init_dram;
  522. struct iwl_trans *trans;
  523. struct net_device napi_dev;
  524. struct __percpu iwl_tso_hdr_page *tso_hdr_page;
  525. /* INT ICT Table */
  526. __le32 *ict_tbl;
  527. dma_addr_t ict_tbl_dma;
  528. int ict_index;
  529. bool use_ict;
  530. bool is_down, opmode_down;
  531. bool debug_rfkill;
  532. struct isr_statistics isr_stats;
  533. spinlock_t irq_lock;
  534. struct mutex mutex;
  535. u32 inta_mask;
  536. u32 scd_base_addr;
  537. struct iwl_dma_ptr scd_bc_tbls;
  538. struct iwl_dma_ptr kw;
  539. struct iwl_txq *txq_memory;
  540. struct iwl_txq *txq[IWL_MAX_TVQM_QUEUES];
  541. unsigned long queue_used[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)];
  542. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)];
  543. /* PCI bus related data */
  544. struct pci_dev *pci_dev;
  545. void __iomem *hw_base;
  546. bool ucode_write_complete;
  547. wait_queue_head_t ucode_write_waitq;
  548. wait_queue_head_t wait_command_queue;
  549. wait_queue_head_t d0i3_waitq;
  550. u8 page_offs, dev_cmd_offs;
  551. u8 cmd_queue;
  552. u8 cmd_fifo;
  553. unsigned int cmd_q_wdg_timeout;
  554. u8 n_no_reclaim_cmds;
  555. u8 no_reclaim_cmds[MAX_NO_RECLAIM_CMDS];
  556. u8 max_tbs;
  557. u16 tfd_size;
  558. enum iwl_amsdu_size rx_buf_size;
  559. bool bc_table_dword;
  560. bool scd_set_active;
  561. bool sw_csum_tx;
  562. bool pcie_dbg_dumped_once;
  563. u32 rx_page_order;
  564. /*protect hw register */
  565. spinlock_t reg_lock;
  566. bool cmd_hold_nic_awake;
  567. bool ref_cmd_in_flight;
  568. dma_addr_t fw_mon_phys;
  569. struct page *fw_mon_page;
  570. u32 fw_mon_size;
  571. struct msix_entry msix_entries[IWL_MAX_RX_HW_QUEUES];
  572. bool msix_enabled;
  573. u8 shared_vec_mask;
  574. u32 alloc_vecs;
  575. u32 def_irq;
  576. u32 fh_init_mask;
  577. u32 hw_init_mask;
  578. u32 fh_mask;
  579. u32 hw_mask;
  580. cpumask_t affinity_mask[IWL_MAX_RX_HW_QUEUES];
  581. u16 tx_cmd_queue_size;
  582. bool in_rescan;
  583. bool scheduled_for_removal;
  584. };
  585. static inline struct iwl_trans_pcie *
  586. IWL_TRANS_GET_PCIE_TRANS(struct iwl_trans *trans)
  587. {
  588. return (void *)trans->trans_specific;
  589. }
  590. static inline void iwl_pcie_clear_irq(struct iwl_trans *trans,
  591. struct msix_entry *entry)
  592. {
  593. /*
  594. * Before sending the interrupt the HW disables it to prevent
  595. * a nested interrupt. This is done by writing 1 to the corresponding
  596. * bit in the mask register. After handling the interrupt, it should be
  597. * re-enabled by clearing this bit. This register is defined as
  598. * write 1 clear (W1C) register, meaning that it's being clear
  599. * by writing 1 to the bit.
  600. */
  601. iwl_write32(trans, CSR_MSIX_AUTOMASK_ST_AD, BIT(entry->entry));
  602. }
  603. static inline struct iwl_trans *
  604. iwl_trans_pcie_get_trans(struct iwl_trans_pcie *trans_pcie)
  605. {
  606. return container_of((void *)trans_pcie, struct iwl_trans,
  607. trans_specific);
  608. }
  609. /*
  610. * Convention: trans API functions: iwl_trans_pcie_XXX
  611. * Other functions: iwl_pcie_XXX
  612. */
  613. struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
  614. const struct pci_device_id *ent,
  615. const struct iwl_cfg *cfg);
  616. void iwl_trans_pcie_free(struct iwl_trans *trans);
  617. /*****************************************************
  618. * RX
  619. ******************************************************/
  620. int iwl_pcie_rx_init(struct iwl_trans *trans);
  621. int iwl_pcie_gen2_rx_init(struct iwl_trans *trans);
  622. irqreturn_t iwl_pcie_msix_isr(int irq, void *data);
  623. irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id);
  624. irqreturn_t iwl_pcie_irq_msix_handler(int irq, void *dev_id);
  625. irqreturn_t iwl_pcie_irq_rx_msix_handler(int irq, void *dev_id);
  626. int iwl_pcie_rx_stop(struct iwl_trans *trans);
  627. void iwl_pcie_rx_free(struct iwl_trans *trans);
  628. void iwl_pcie_free_rbs_pool(struct iwl_trans *trans);
  629. void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq);
  630. int iwl_pcie_dummy_napi_poll(struct napi_struct *napi, int budget);
  631. void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority,
  632. struct iwl_rxq *rxq);
  633. /*****************************************************
  634. * ICT - interrupt handling
  635. ******************************************************/
  636. irqreturn_t iwl_pcie_isr(int irq, void *data);
  637. int iwl_pcie_alloc_ict(struct iwl_trans *trans);
  638. void iwl_pcie_free_ict(struct iwl_trans *trans);
  639. void iwl_pcie_reset_ict(struct iwl_trans *trans);
  640. void iwl_pcie_disable_ict(struct iwl_trans *trans);
  641. /*****************************************************
  642. * TX / HCMD
  643. ******************************************************/
  644. int iwl_pcie_tx_init(struct iwl_trans *trans);
  645. int iwl_pcie_gen2_tx_init(struct iwl_trans *trans);
  646. void iwl_pcie_tx_start(struct iwl_trans *trans, u32 scd_base_addr);
  647. int iwl_pcie_tx_stop(struct iwl_trans *trans);
  648. void iwl_pcie_tx_free(struct iwl_trans *trans);
  649. bool iwl_trans_pcie_txq_enable(struct iwl_trans *trans, int queue, u16 ssn,
  650. const struct iwl_trans_txq_scd_cfg *cfg,
  651. unsigned int wdg_timeout);
  652. void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int queue,
  653. bool configure_scd);
  654. void iwl_trans_pcie_txq_set_shared_mode(struct iwl_trans *trans, u32 txq_id,
  655. bool shared_mode);
  656. void iwl_trans_pcie_log_scd_error(struct iwl_trans *trans,
  657. struct iwl_txq *txq);
  658. int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
  659. struct iwl_device_cmd *dev_cmd, int txq_id);
  660. void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans);
  661. int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd);
  662. void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
  663. struct iwl_rx_cmd_buffer *rxb);
  664. void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
  665. struct sk_buff_head *skbs);
  666. void iwl_trans_pcie_tx_reset(struct iwl_trans *trans);
  667. static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_trans *trans, void *_tfd,
  668. u8 idx)
  669. {
  670. if (trans->cfg->use_tfh) {
  671. struct iwl_tfh_tfd *tfd = _tfd;
  672. struct iwl_tfh_tb *tb = &tfd->tbs[idx];
  673. return le16_to_cpu(tb->tb_len);
  674. } else {
  675. struct iwl_tfd *tfd = _tfd;
  676. struct iwl_tfd_tb *tb = &tfd->tbs[idx];
  677. return le16_to_cpu(tb->hi_n_len) >> 4;
  678. }
  679. }
  680. /*****************************************************
  681. * Error handling
  682. ******************************************************/
  683. void iwl_pcie_dump_csr(struct iwl_trans *trans);
  684. /*****************************************************
  685. * Helpers
  686. ******************************************************/
  687. static inline void _iwl_disable_interrupts(struct iwl_trans *trans)
  688. {
  689. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  690. clear_bit(STATUS_INT_ENABLED, &trans->status);
  691. if (!trans_pcie->msix_enabled) {
  692. /* disable interrupts from uCode/NIC to host */
  693. iwl_write32(trans, CSR_INT_MASK, 0x00000000);
  694. /* acknowledge/clear/reset any interrupts still pending
  695. * from uCode or flow handler (Rx/Tx DMA) */
  696. iwl_write32(trans, CSR_INT, 0xffffffff);
  697. iwl_write32(trans, CSR_FH_INT_STATUS, 0xffffffff);
  698. } else {
  699. /* disable all the interrupt we might use */
  700. iwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD,
  701. trans_pcie->fh_init_mask);
  702. iwl_write32(trans, CSR_MSIX_HW_INT_MASK_AD,
  703. trans_pcie->hw_init_mask);
  704. }
  705. IWL_DEBUG_ISR(trans, "Disabled interrupts\n");
  706. }
  707. #define IWL_NUM_OF_COMPLETION_RINGS 31
  708. #define IWL_NUM_OF_TRANSFER_RINGS 527
  709. static inline int iwl_pcie_get_num_sections(const struct fw_img *fw,
  710. int start)
  711. {
  712. int i = 0;
  713. while (start < fw->num_sec &&
  714. fw->sec[start].offset != CPU1_CPU2_SEPARATOR_SECTION &&
  715. fw->sec[start].offset != PAGING_SEPARATOR_SECTION) {
  716. start++;
  717. i++;
  718. }
  719. return i;
  720. }
  721. static inline int iwl_pcie_ctxt_info_alloc_dma(struct iwl_trans *trans,
  722. const struct fw_desc *sec,
  723. struct iwl_dram_data *dram)
  724. {
  725. dram->block = dma_alloc_coherent(trans->dev, sec->len,
  726. &dram->physical,
  727. GFP_KERNEL);
  728. if (!dram->block)
  729. return -ENOMEM;
  730. dram->size = sec->len;
  731. memcpy(dram->block, sec->data, sec->len);
  732. return 0;
  733. }
  734. static inline void iwl_pcie_ctxt_info_free_fw_img(struct iwl_trans *trans)
  735. {
  736. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  737. struct iwl_self_init_dram *dram = &trans_pcie->init_dram;
  738. int i;
  739. if (!dram->fw) {
  740. WARN_ON(dram->fw_cnt);
  741. return;
  742. }
  743. for (i = 0; i < dram->fw_cnt; i++)
  744. dma_free_coherent(trans->dev, dram->fw[i].size,
  745. dram->fw[i].block, dram->fw[i].physical);
  746. kfree(dram->fw);
  747. dram->fw_cnt = 0;
  748. dram->fw = NULL;
  749. }
  750. static inline void iwl_disable_interrupts(struct iwl_trans *trans)
  751. {
  752. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  753. spin_lock(&trans_pcie->irq_lock);
  754. _iwl_disable_interrupts(trans);
  755. spin_unlock(&trans_pcie->irq_lock);
  756. }
  757. static inline void _iwl_enable_interrupts(struct iwl_trans *trans)
  758. {
  759. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  760. IWL_DEBUG_ISR(trans, "Enabling interrupts\n");
  761. set_bit(STATUS_INT_ENABLED, &trans->status);
  762. if (!trans_pcie->msix_enabled) {
  763. trans_pcie->inta_mask = CSR_INI_SET_MASK;
  764. iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
  765. } else {
  766. /*
  767. * fh/hw_mask keeps all the unmasked causes.
  768. * Unlike msi, in msix cause is enabled when it is unset.
  769. */
  770. trans_pcie->hw_mask = trans_pcie->hw_init_mask;
  771. trans_pcie->fh_mask = trans_pcie->fh_init_mask;
  772. iwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD,
  773. ~trans_pcie->fh_mask);
  774. iwl_write32(trans, CSR_MSIX_HW_INT_MASK_AD,
  775. ~trans_pcie->hw_mask);
  776. }
  777. }
  778. static inline void iwl_enable_interrupts(struct iwl_trans *trans)
  779. {
  780. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  781. spin_lock(&trans_pcie->irq_lock);
  782. _iwl_enable_interrupts(trans);
  783. spin_unlock(&trans_pcie->irq_lock);
  784. }
  785. static inline void iwl_enable_hw_int_msk_msix(struct iwl_trans *trans, u32 msk)
  786. {
  787. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  788. iwl_write32(trans, CSR_MSIX_HW_INT_MASK_AD, ~msk);
  789. trans_pcie->hw_mask = msk;
  790. }
  791. static inline void iwl_enable_fh_int_msk_msix(struct iwl_trans *trans, u32 msk)
  792. {
  793. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  794. iwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD, ~msk);
  795. trans_pcie->fh_mask = msk;
  796. }
  797. static inline void iwl_enable_fw_load_int(struct iwl_trans *trans)
  798. {
  799. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  800. IWL_DEBUG_ISR(trans, "Enabling FW load interrupt\n");
  801. if (!trans_pcie->msix_enabled) {
  802. trans_pcie->inta_mask = CSR_INT_BIT_FH_TX;
  803. iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
  804. } else {
  805. iwl_write32(trans, CSR_MSIX_HW_INT_MASK_AD,
  806. trans_pcie->hw_init_mask);
  807. iwl_enable_fh_int_msk_msix(trans,
  808. MSIX_FH_INT_CAUSES_D2S_CH0_NUM);
  809. }
  810. }
  811. static inline u16 iwl_pcie_get_cmd_index(const struct iwl_txq *q, u32 index)
  812. {
  813. return index & (q->n_window - 1);
  814. }
  815. static inline void *iwl_pcie_get_tfd(struct iwl_trans *trans,
  816. struct iwl_txq *txq, int idx)
  817. {
  818. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  819. if (trans->cfg->use_tfh)
  820. idx = iwl_pcie_get_cmd_index(txq, idx);
  821. return txq->tfds + trans_pcie->tfd_size * idx;
  822. }
  823. static inline const char *queue_name(struct device *dev,
  824. struct iwl_trans_pcie *trans_p, int i)
  825. {
  826. if (trans_p->shared_vec_mask) {
  827. int vec = trans_p->shared_vec_mask &
  828. IWL_SHARED_IRQ_FIRST_RSS ? 1 : 0;
  829. if (i == 0)
  830. return DRV_NAME ": shared IRQ";
  831. return devm_kasprintf(dev, GFP_KERNEL,
  832. DRV_NAME ": queue %d", i + vec);
  833. }
  834. if (i == 0)
  835. return DRV_NAME ": default queue";
  836. if (i == trans_p->alloc_vecs - 1)
  837. return DRV_NAME ": exception";
  838. return devm_kasprintf(dev, GFP_KERNEL,
  839. DRV_NAME ": queue %d", i);
  840. }
  841. static inline void iwl_enable_rfkill_int(struct iwl_trans *trans)
  842. {
  843. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  844. IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n");
  845. if (!trans_pcie->msix_enabled) {
  846. trans_pcie->inta_mask = CSR_INT_BIT_RF_KILL;
  847. iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
  848. } else {
  849. iwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD,
  850. trans_pcie->fh_init_mask);
  851. iwl_enable_hw_int_msk_msix(trans,
  852. MSIX_HW_INT_CAUSES_REG_RF_KILL);
  853. }
  854. if (trans->cfg->device_family == IWL_DEVICE_FAMILY_9000) {
  855. /*
  856. * On 9000-series devices this bit isn't enabled by default, so
  857. * when we power down the device we need set the bit to allow it
  858. * to wake up the PCI-E bus for RF-kill interrupts.
  859. */
  860. iwl_set_bit(trans, CSR_GP_CNTRL,
  861. CSR_GP_CNTRL_REG_FLAG_RFKILL_WAKE_L1A_EN);
  862. }
  863. }
  864. void iwl_pcie_handle_rfkill_irq(struct iwl_trans *trans);
  865. static inline void iwl_wake_queue(struct iwl_trans *trans,
  866. struct iwl_txq *txq)
  867. {
  868. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  869. if (test_and_clear_bit(txq->id, trans_pcie->queue_stopped)) {
  870. IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d\n", txq->id);
  871. iwl_op_mode_queue_not_full(trans->op_mode, txq->id);
  872. }
  873. }
  874. static inline void iwl_stop_queue(struct iwl_trans *trans,
  875. struct iwl_txq *txq)
  876. {
  877. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  878. if (!test_and_set_bit(txq->id, trans_pcie->queue_stopped)) {
  879. iwl_op_mode_queue_full(trans->op_mode, txq->id);
  880. IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d\n", txq->id);
  881. } else
  882. IWL_DEBUG_TX_QUEUES(trans, "hwq %d already stopped\n",
  883. txq->id);
  884. }
  885. static inline bool iwl_queue_used(const struct iwl_txq *q, int i)
  886. {
  887. int index = iwl_pcie_get_cmd_index(q, i);
  888. int r = iwl_pcie_get_cmd_index(q, q->read_ptr);
  889. int w = iwl_pcie_get_cmd_index(q, q->write_ptr);
  890. return w >= r ?
  891. (index >= r && index < w) :
  892. !(index < r && index >= w);
  893. }
  894. static inline bool iwl_is_rfkill_set(struct iwl_trans *trans)
  895. {
  896. struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  897. lockdep_assert_held(&trans_pcie->mutex);
  898. if (trans_pcie->debug_rfkill)
  899. return true;
  900. return !(iwl_read32(trans, CSR_GP_CNTRL) &
  901. CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
  902. }
  903. static inline void __iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans,
  904. u32 reg, u32 mask, u32 value)
  905. {
  906. u32 v;
  907. #ifdef CONFIG_IWLWIFI_DEBUG
  908. WARN_ON_ONCE(value & ~mask);
  909. #endif
  910. v = iwl_read32(trans, reg);
  911. v &= ~mask;
  912. v |= value;
  913. iwl_write32(trans, reg, v);
  914. }
  915. static inline void __iwl_trans_pcie_clear_bit(struct iwl_trans *trans,
  916. u32 reg, u32 mask)
  917. {
  918. __iwl_trans_pcie_set_bits_mask(trans, reg, mask, 0);
  919. }
  920. static inline void __iwl_trans_pcie_set_bit(struct iwl_trans *trans,
  921. u32 reg, u32 mask)
  922. {
  923. __iwl_trans_pcie_set_bits_mask(trans, reg, mask, mask);
  924. }
  925. void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state);
  926. #ifdef CONFIG_IWLWIFI_DEBUGFS
  927. int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans);
  928. #else
  929. static inline int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans)
  930. {
  931. return 0;
  932. }
  933. #endif
  934. int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans);
  935. int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans);
  936. void iwl_pcie_enable_rx_wake(struct iwl_trans *trans, bool enable);
  937. void iwl_pcie_rx_allocator_work(struct work_struct *data);
  938. /* common functions that are used by gen2 transport */
  939. void iwl_pcie_apm_config(struct iwl_trans *trans);
  940. int iwl_pcie_prepare_card_hw(struct iwl_trans *trans);
  941. void iwl_pcie_synchronize_irqs(struct iwl_trans *trans);
  942. bool iwl_pcie_check_hw_rf_kill(struct iwl_trans *trans);
  943. void iwl_trans_pcie_handle_stop_rfkill(struct iwl_trans *trans,
  944. bool was_in_rfkill);
  945. void iwl_pcie_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq);
  946. int iwl_queue_space(struct iwl_trans *trans, const struct iwl_txq *q);
  947. void iwl_pcie_apm_stop_master(struct iwl_trans *trans);
  948. void iwl_pcie_conf_msix_hw(struct iwl_trans_pcie *trans_pcie);
  949. int iwl_pcie_txq_init(struct iwl_trans *trans, struct iwl_txq *txq,
  950. int slots_num, bool cmd_queue);
  951. int iwl_pcie_txq_alloc(struct iwl_trans *trans,
  952. struct iwl_txq *txq, int slots_num, bool cmd_queue);
  953. int iwl_pcie_alloc_dma_ptr(struct iwl_trans *trans,
  954. struct iwl_dma_ptr *ptr, size_t size);
  955. void iwl_pcie_free_dma_ptr(struct iwl_trans *trans, struct iwl_dma_ptr *ptr);
  956. void iwl_pcie_apply_destination(struct iwl_trans *trans);
  957. void iwl_pcie_free_tso_page(struct iwl_trans_pcie *trans_pcie,
  958. struct sk_buff *skb);
  959. #ifdef CONFIG_INET
  960. struct iwl_tso_hdr_page *get_page_hdr(struct iwl_trans *trans, size_t len);
  961. #endif
  962. /* common functions that are used by gen3 transport */
  963. void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans, u8 max_power);
  964. /* transport gen 2 exported functions */
  965. int iwl_trans_pcie_gen2_start_fw(struct iwl_trans *trans,
  966. const struct fw_img *fw, bool run_in_rfkill);
  967. void iwl_trans_pcie_gen2_fw_alive(struct iwl_trans *trans, u32 scd_addr);
  968. int iwl_trans_pcie_dyn_txq_alloc(struct iwl_trans *trans,
  969. struct iwl_tx_queue_cfg_cmd *cmd,
  970. int cmd_id, int size,
  971. unsigned int timeout);
  972. void iwl_trans_pcie_dyn_txq_free(struct iwl_trans *trans, int queue);
  973. int iwl_trans_pcie_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb,
  974. struct iwl_device_cmd *dev_cmd, int txq_id);
  975. int iwl_trans_pcie_gen2_send_hcmd(struct iwl_trans *trans,
  976. struct iwl_host_cmd *cmd);
  977. void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans,
  978. bool low_power);
  979. void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power);
  980. void iwl_pcie_gen2_txq_unmap(struct iwl_trans *trans, int txq_id);
  981. void iwl_pcie_gen2_tx_free(struct iwl_trans *trans);
  982. void iwl_pcie_gen2_tx_stop(struct iwl_trans *trans);
  983. #endif /* __iwl_trans_int_pcie_h__ */