iwl-trans-int-pcie.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  4. *
  5. * Portions of this file are derived from the ipw3945 project, as well
  6. * as portions of the ieee80211 subsystem header files.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of version 2 of the GNU General Public License as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  20. *
  21. * The full GNU General Public License is included in this distribution in the
  22. * file called LICENSE.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. *****************************************************************************/
  29. #ifndef __iwl_trans_int_pcie_h__
  30. #define __iwl_trans_int_pcie_h__
  31. /*This file includes the declaration that are internal to the
  32. * trans_pcie layer */
  33. /**
  34. * struct isr_statistics - interrupt statistics
  35. *
  36. */
  37. struct isr_statistics {
  38. u32 hw;
  39. u32 sw;
  40. u32 err_code;
  41. u32 sch;
  42. u32 alive;
  43. u32 rfkill;
  44. u32 ctkill;
  45. u32 wakeup;
  46. u32 rx;
  47. u32 tx;
  48. u32 unhandled;
  49. };
  50. /**
  51. * struct iwl_rx_queue - Rx queue
  52. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
  53. * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
  54. * @pool:
  55. * @queue:
  56. * @read: Shared index to newest available Rx buffer
  57. * @write: Shared index to oldest written Rx packet
  58. * @free_count: Number of pre-allocated buffers in rx_free
  59. * @write_actual:
  60. * @rx_free: list of free SKBs for use
  61. * @rx_used: List of Rx buffers with no SKB
  62. * @need_update: flag to indicate we need to update read/write index
  63. * @rb_stts: driver's pointer to receive buffer status
  64. * @rb_stts_dma: bus address of receive buffer status
  65. * @lock:
  66. *
  67. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  68. */
  69. struct iwl_rx_queue {
  70. __le32 *bd;
  71. dma_addr_t bd_dma;
  72. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  73. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  74. u32 read;
  75. u32 write;
  76. u32 free_count;
  77. u32 write_actual;
  78. struct list_head rx_free;
  79. struct list_head rx_used;
  80. int need_update;
  81. struct iwl_rb_status *rb_stts;
  82. dma_addr_t rb_stts_dma;
  83. spinlock_t lock;
  84. };
  85. /**
  86. * struct iwl_trans_pcie - PCIe transport specific data
  87. * @rxq: all the RX queue data
  88. * @rx_replenish: work that will be called when buffers need to be allocated
  89. * @trans: pointer to the generic transport area
  90. * @scd_base_addr: scheduler sram base address in SRAM
  91. * @scd_bc_tbls: pointer to the byte count table of the scheduler
  92. */
  93. struct iwl_trans_pcie {
  94. struct iwl_rx_queue rxq;
  95. struct work_struct rx_replenish;
  96. struct iwl_trans *trans;
  97. /* INT ICT Table */
  98. __le32 *ict_tbl;
  99. void *ict_tbl_vir;
  100. dma_addr_t ict_tbl_dma;
  101. dma_addr_t aligned_ict_tbl_dma;
  102. int ict_index;
  103. u32 inta;
  104. bool use_ict;
  105. struct tasklet_struct irq_tasklet;
  106. struct isr_statistics isr_stats;
  107. u32 inta_mask;
  108. u32 scd_base_addr;
  109. struct iwl_dma_ptr scd_bc_tbls;
  110. };
  111. #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \
  112. ((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific))
  113. /*****************************************************
  114. * RX
  115. ******************************************************/
  116. void iwl_bg_rx_replenish(struct work_struct *data);
  117. void iwl_irq_tasklet(struct iwl_trans *trans);
  118. void iwlagn_rx_replenish(struct iwl_trans *trans);
  119. void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
  120. struct iwl_rx_queue *q);
  121. /*****************************************************
  122. * ICT
  123. ******************************************************/
  124. int iwl_reset_ict(struct iwl_priv *priv);
  125. void iwl_disable_ict(struct iwl_trans *trans);
  126. int iwl_alloc_isr_ict(struct iwl_trans *trans);
  127. void iwl_free_isr_ict(struct iwl_trans *trans);
  128. irqreturn_t iwl_isr_ict(int irq, void *data);
  129. /*****************************************************
  130. * TX / HCMD
  131. ******************************************************/
  132. void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  133. int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
  134. struct iwl_tx_queue *txq,
  135. dma_addr_t addr, u16 len, u8 reset);
  136. int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
  137. int count, int slots_num, u32 id);
  138. int iwl_trans_pcie_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
  139. int __must_check iwl_trans_pcie_send_cmd_pdu(struct iwl_priv *priv, u8 id,
  140. u32 flags, u16 len, const void *data);
  141. void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
  142. void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  143. struct iwl_tx_queue *txq,
  144. u16 byte_cnt);
  145. int iwl_trans_pcie_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  146. u16 ssn_idx, u8 tx_fifo);
  147. void iwl_trans_set_wr_ptrs(struct iwl_priv *priv,
  148. int txq_id, u32 index);
  149. void iwl_trans_tx_queue_set_status(struct iwl_priv *priv,
  150. struct iwl_tx_queue *txq,
  151. int tx_fifo_id, int scd_retry);
  152. void iwl_trans_pcie_txq_agg_setup(struct iwl_priv *priv, int sta_id, int tid,
  153. int frame_limit);
  154. void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
  155. int index);
  156. void iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index,
  157. struct sk_buff_head *skbs);
  158. /*****************************************************
  159. * Error handling
  160. ******************************************************/
  161. int iwl_dump_nic_event_log(struct iwl_priv *priv,
  162. bool full_log, char **buf, bool display);
  163. static inline void iwl_disable_interrupts(struct iwl_trans *trans)
  164. {
  165. clear_bit(STATUS_INT_ENABLED, &trans->shrd->status);
  166. /* disable interrupts from uCode/NIC to host */
  167. iwl_write32(priv(trans), CSR_INT_MASK, 0x00000000);
  168. /* acknowledge/clear/reset any interrupts still pending
  169. * from uCode or flow handler (Rx/Tx DMA) */
  170. iwl_write32(priv(trans), CSR_INT, 0xffffffff);
  171. iwl_write32(priv(trans), CSR_FH_INT_STATUS, 0xffffffff);
  172. IWL_DEBUG_ISR(trans, "Disabled interrupts\n");
  173. }
  174. static inline void iwl_enable_interrupts(struct iwl_trans *trans)
  175. {
  176. struct iwl_trans_pcie *trans_pcie =
  177. IWL_TRANS_GET_PCIE_TRANS(trans);
  178. IWL_DEBUG_ISR(trans, "Enabling interrupts\n");
  179. set_bit(STATUS_INT_ENABLED, &trans->shrd->status);
  180. iwl_write32(priv(trans), CSR_INT_MASK, trans_pcie->inta_mask);
  181. }
  182. #endif /* __iwl_trans_int_pcie_h__ */