blob: f60b26f4dc7bc8cd8110665a266b6d48651373f7 [file] [log] [blame]
Emmanuel Grumbachab697a92011-07-11 07:35:34 -07001/******************************************************************************
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
32/*This file includes the declaration that are internal to the
33 * trans_pcie layer */
34
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -070035/**
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -070036 * struct isr_statistics - interrupt statistics
37 *
38 */
39struct isr_statistics {
40 u32 hw;
41 u32 sw;
42 u32 err_code;
43 u32 sch;
44 u32 alive;
45 u32 rfkill;
46 u32 ctkill;
47 u32 wakeup;
48 u32 rx;
49 u32 tx;
50 u32 unhandled;
51};
52
53/**
Emmanuel Grumbach5a878bf2011-08-25 23:10:51 -070054 * struct iwl_rx_queue - Rx queue
55 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
56 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
57 * @pool:
58 * @queue:
59 * @read: Shared index to newest available Rx buffer
60 * @write: Shared index to oldest written Rx packet
61 * @free_count: Number of pre-allocated buffers in rx_free
62 * @write_actual:
63 * @rx_free: list of free SKBs for use
64 * @rx_used: List of Rx buffers with no SKB
65 * @need_update: flag to indicate we need to update read/write index
66 * @rb_stts: driver's pointer to receive buffer status
67 * @rb_stts_dma: bus address of receive buffer status
68 * @lock:
69 *
70 * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
71 */
72struct iwl_rx_queue {
73 __le32 *bd;
74 dma_addr_t bd_dma;
75 struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
76 struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
77 u32 read;
78 u32 write;
79 u32 free_count;
80 u32 write_actual;
81 struct list_head rx_free;
82 struct list_head rx_used;
83 int need_update;
84 struct iwl_rb_status *rb_stts;
85 dma_addr_t rb_stts_dma;
86 spinlock_t lock;
87};
88
89/**
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -070090 * struct iwl_trans_pcie - PCIe transport specific data
Emmanuel Grumbach5a878bf2011-08-25 23:10:51 -070091 * @rxq: all the RX queue data
92 * @rx_replenish: work that will be called when buffers need to be allocated
93 * @trans: pointer to the generic transport area
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -070094 */
95struct iwl_trans_pcie {
Emmanuel Grumbach5a878bf2011-08-25 23:10:51 -070096 struct iwl_rx_queue rxq;
97 struct work_struct rx_replenish;
98 struct iwl_trans *trans;
Emmanuel Grumbach0c325762011-08-25 23:10:53 -070099
100 /* INT ICT Table */
101 __le32 *ict_tbl;
102 void *ict_tbl_vir;
103 dma_addr_t ict_tbl_dma;
104 dma_addr_t aligned_ict_tbl_dma;
105 int ict_index;
106 u32 inta;
107 bool use_ict;
108 struct tasklet_struct irq_tasklet;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700109 struct isr_statistics isr_stats;
Emmanuel Grumbach0c325762011-08-25 23:10:53 -0700110
111 u32 inta_mask;
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -0700112};
113
Emmanuel Grumbach5a878bf2011-08-25 23:10:51 -0700114#define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \
115 ((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific))
116
Emmanuel Grumbach253a6342011-07-11 07:39:46 -0700117/*****************************************************
118* RX
119******************************************************/
Emmanuel Grumbachab697a92011-07-11 07:35:34 -0700120void iwl_bg_rx_replenish(struct work_struct *data);
Emmanuel Grumbach0c325762011-08-25 23:10:53 -0700121void iwl_irq_tasklet(struct iwl_trans *trans);
Emmanuel Grumbach5a878bf2011-08-25 23:10:51 -0700122void iwlagn_rx_replenish(struct iwl_trans *trans);
123void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
Emmanuel Grumbachab697a92011-07-11 07:35:34 -0700124 struct iwl_rx_queue *q);
125
Emmanuel Grumbach253a6342011-07-11 07:39:46 -0700126/*****************************************************
Emmanuel Grumbach1a361cd2011-07-11 07:44:57 -0700127* ICT
128******************************************************/
129int iwl_reset_ict(struct iwl_priv *priv);
Emmanuel Grumbach0c325762011-08-25 23:10:53 -0700130void iwl_disable_ict(struct iwl_trans *trans);
131int iwl_alloc_isr_ict(struct iwl_trans *trans);
132void iwl_free_isr_ict(struct iwl_trans *trans);
Emmanuel Grumbach1a361cd2011-07-11 07:44:57 -0700133irqreturn_t iwl_isr_ict(int irq, void *data);
134
Emmanuel Grumbach1a361cd2011-07-11 07:44:57 -0700135/*****************************************************
Emmanuel Grumbach253a6342011-07-11 07:39:46 -0700136* TX / HCMD
137******************************************************/
138void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
139void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
140 int index);
141int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
142 struct iwl_tx_queue *txq,
143 dma_addr_t addr, u16 len, u8 reset);
144int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
145 int count, int slots_num, u32 id);
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -0700146int iwl_trans_pcie_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
147int __must_check iwl_trans_pcie_send_cmd_pdu(struct iwl_priv *priv, u8 id,
148 u32 flags, u16 len, const void *data);
Emmanuel Grumbach253a6342011-07-11 07:39:46 -0700149void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
Emmanuel Grumbach48d42c42011-07-10 10:47:01 +0300150void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
151 struct iwl_tx_queue *txq,
152 u16 byte_cnt);
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -0700153int iwl_trans_pcie_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
Emmanuel Grumbach48d42c42011-07-10 10:47:01 +0300154 u16 ssn_idx, u8 tx_fifo);
155void iwl_trans_set_wr_ptrs(struct iwl_priv *priv,
156 int txq_id, u32 index);
157void iwl_trans_tx_queue_set_status(struct iwl_priv *priv,
158 struct iwl_tx_queue *txq,
159 int tx_fifo_id, int scd_retry);
Emmanuel Grumbache6bb4c92011-08-25 23:10:48 -0700160void iwl_trans_pcie_txq_agg_setup(struct iwl_priv *priv, int sta_id, int tid,
Emmanuel Grumbach48d42c42011-07-10 10:47:01 +0300161 int frame_limit);
Emmanuel Grumbach253a6342011-07-11 07:39:46 -0700162
Emmanuel Grumbach7ff94702011-08-25 23:10:54 -0700163/*****************************************************
164* Error handling
165******************************************************/
166int iwl_dump_nic_event_log(struct iwl_priv *priv,
167 bool full_log, char **buf, bool display);
168
Emmanuel Grumbach0c325762011-08-25 23:10:53 -0700169static inline void iwl_disable_interrupts(struct iwl_trans *trans)
170{
171 clear_bit(STATUS_INT_ENABLED, &trans->shrd->status);
172
173 /* disable interrupts from uCode/NIC to host */
174 iwl_write32(priv(trans), CSR_INT_MASK, 0x00000000);
175
176 /* acknowledge/clear/reset any interrupts still pending
177 * from uCode or flow handler (Rx/Tx DMA) */
178 iwl_write32(priv(trans), CSR_INT, 0xffffffff);
179 iwl_write32(priv(trans), CSR_FH_INT_STATUS, 0xffffffff);
180 IWL_DEBUG_ISR(trans, "Disabled interrupts\n");
181}
182
183static inline void iwl_enable_interrupts(struct iwl_trans *trans)
184{
185 struct iwl_trans_pcie *trans_pcie =
186 IWL_TRANS_GET_PCIE_TRANS(trans);
187
188 IWL_DEBUG_ISR(trans, "Enabling interrupts\n");
189 set_bit(STATUS_INT_ENABLED, &trans->shrd->status);
190 iwl_write32(priv(trans), CSR_INT_MASK, trans_pcie->inta_mask);
191}
192
Emmanuel Grumbachab697a92011-07-11 07:35:34 -0700193#endif /* __iwl_trans_int_pcie_h__ */