ath9k: remove bfs_keyix from struct ath_buf_state
[linux-flexiantxendom0-natty.git] / drivers / net / wireless / ath / ath9k / ath9k.h
1 /*
2  * Copyright (c) 2008-2009 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef ATH9K_H
18 #define ATH9K_H
19
20 #include <linux/etherdevice.h>
21 #include <linux/device.h>
22 #include <linux/leds.h>
23 #include <linux/completion.h>
24
25 #include "debug.h"
26 #include "common.h"
27
28 /*
29  * Header for the ath9k.ko driver core *only* -- hw code nor any other driver
30  * should rely on this file or its contents.
31  */
32
33 struct ath_node;
34
35 /* Macro to expand scalars to 64-bit objects */
36
37 #define ito64(x) (sizeof(x) == 1) ?                     \
38         (((unsigned long long int)(x)) & (0xff)) :      \
39         (sizeof(x) == 2) ?                              \
40         (((unsigned long long int)(x)) & 0xffff) :      \
41         ((sizeof(x) == 4) ?                             \
42          (((unsigned long long int)(x)) & 0xffffffff) : \
43          (unsigned long long int)(x))
44
45 /* increment with wrap-around */
46 #define INCR(_l, _sz)   do {                    \
47                 (_l)++;                         \
48                 (_l) &= ((_sz) - 1);            \
49         } while (0)
50
51 /* decrement with wrap-around */
52 #define DECR(_l,  _sz)  do {                    \
53                 (_l)--;                         \
54                 (_l) &= ((_sz) - 1);            \
55         } while (0)
56
57 #define A_MAX(a, b) ((a) > (b) ? (a) : (b))
58
59 #define TSF_TO_TU(_h,_l) \
60         ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
61
62 #define ATH_TXQ_SETUP(sc, i)        ((sc)->tx.txqsetup & (1<<i))
63
64 struct ath_config {
65         u32 ath_aggr_prot;
66         u16 txpowlimit;
67         u8 cabqReadytime;
68 };
69
70 /*************************/
71 /* Descriptor Management */
72 /*************************/
73
74 #define ATH_TXBUF_RESET(_bf) do {                               \
75                 (_bf)->bf_stale = false;                        \
76                 (_bf)->bf_lastbf = NULL;                        \
77                 (_bf)->bf_next = NULL;                          \
78                 memset(&((_bf)->bf_state), 0,                   \
79                        sizeof(struct ath_buf_state));           \
80         } while (0)
81
82 #define ATH_RXBUF_RESET(_bf) do {               \
83                 (_bf)->bf_stale = false;        \
84         } while (0)
85
86 /**
87  * enum buffer_type - Buffer type flags
88  *
89  * @BUF_HT: Send this buffer using HT capabilities
90  * @BUF_AMPDU: This buffer is an ampdu, as part of an aggregate (during TX)
91  * @BUF_AGGR: Indicates whether the buffer can be aggregated
92  *      (used in aggregation scheduling)
93  * @BUF_RETRY: Indicates whether the buffer is retried
94  * @BUF_XRETRY: To denote excessive retries of the buffer
95  */
96 enum buffer_type {
97         BUF_HT                  = BIT(1),
98         BUF_AMPDU               = BIT(2),
99         BUF_AGGR                = BIT(3),
100         BUF_RETRY               = BIT(4),
101         BUF_XRETRY              = BIT(5),
102 };
103
104 #define bf_nframes              bf_state.bfs_nframes
105 #define bf_al                   bf_state.bfs_al
106 #define bf_frmlen               bf_state.bfs_frmlen
107 #define bf_retries              bf_state.bfs_retries
108 #define bf_isht(bf)             (bf->bf_state.bf_type & BUF_HT)
109 #define bf_isampdu(bf)          (bf->bf_state.bf_type & BUF_AMPDU)
110 #define bf_isaggr(bf)           (bf->bf_state.bf_type & BUF_AGGR)
111 #define bf_isretried(bf)        (bf->bf_state.bf_type & BUF_RETRY)
112 #define bf_isxretried(bf)       (bf->bf_state.bf_type & BUF_XRETRY)
113
114 #define ATH_TXSTATUS_RING_SIZE 64
115
116 struct ath_descdma {
117         void *dd_desc;
118         dma_addr_t dd_desc_paddr;
119         u32 dd_desc_len;
120         struct ath_buf *dd_bufptr;
121 };
122
123 int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
124                       struct list_head *head, const char *name,
125                       int nbuf, int ndesc, bool is_tx);
126 void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
127                          struct list_head *head);
128
129 /***********/
130 /* RX / TX */
131 /***********/
132
133 #define ATH_MAX_ANTENNA         3
134 #define ATH_RXBUF               512
135 #define ATH_TXBUF               512
136 #define ATH_TXBUF_RESERVE       5
137 #define ATH_MAX_QDEPTH          (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
138 #define ATH_TXMAXTRY            13
139 #define ATH_MGT_TXMAXTRY        4
140
141 #define TID_TO_WME_AC(_tid)                             \
142         ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
143          (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
144          (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
145          WME_AC_VO)
146
147 #define ADDBA_EXCHANGE_ATTEMPTS    10
148 #define ATH_AGGR_DELIM_SZ          4
149 #define ATH_AGGR_MINPLEN           256 /* in bytes, minimum packet length */
150 /* number of delimiters for encryption padding */
151 #define ATH_AGGR_ENCRYPTDELIM      10
152 /* minimum h/w qdepth to be sustained to maximize aggregation */
153 #define ATH_AGGR_MIN_QDEPTH        2
154 #define ATH_AMPDU_SUBFRAME_DEFAULT 32
155
156 #define IEEE80211_SEQ_SEQ_SHIFT    4
157 #define IEEE80211_SEQ_MAX          4096
158 #define IEEE80211_WEP_IVLEN        3
159 #define IEEE80211_WEP_KIDLEN       1
160 #define IEEE80211_WEP_CRCLEN       4
161 #define IEEE80211_MAX_MPDU_LEN     (3840 + FCS_LEN +            \
162                                     (IEEE80211_WEP_IVLEN +      \
163                                      IEEE80211_WEP_KIDLEN +     \
164                                      IEEE80211_WEP_CRCLEN))
165
166 /* return whether a bit at index _n in bitmap _bm is set
167  * _sz is the size of the bitmap  */
168 #define ATH_BA_ISSET(_bm, _n)  (((_n) < (WME_BA_BMP_SIZE)) &&           \
169                                 ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
170
171 /* return block-ack bitmap index given sequence and starting sequence */
172 #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
173
174 /* returns delimiter padding required given the packet length */
175 #define ATH_AGGR_GET_NDELIM(_len)                                       \
176        (((_len) >= ATH_AGGR_MINPLEN) ? 0 :                             \
177         DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ))
178
179 #define BAW_WITHIN(_start, _bawsz, _seqno) \
180         ((((_seqno) - (_start)) & 4095) < (_bawsz))
181
182 #define ATH_AN_2_TID(_an, _tidno)  (&(_an)->tid[(_tidno)])
183
184 #define ATH_TX_COMPLETE_POLL_INT        1000
185
186 enum ATH_AGGR_STATUS {
187         ATH_AGGR_DONE,
188         ATH_AGGR_BAW_CLOSED,
189         ATH_AGGR_LIMITED,
190 };
191
192 #define ATH_TXFIFO_DEPTH 8
193 struct ath_txq {
194         u32 axq_qnum;
195         u32 *axq_link;
196         struct list_head axq_q;
197         spinlock_t axq_lock;
198         u32 axq_depth;
199         bool stopped;
200         bool axq_tx_inprogress;
201         struct list_head axq_acq;
202         struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
203         struct list_head txq_fifo_pending;
204         u8 txq_headidx;
205         u8 txq_tailidx;
206         int pending_frames;
207 };
208
209 struct ath_atx_ac {
210         struct ath_txq *txq;
211         int sched;
212         struct list_head list;
213         struct list_head tid_q;
214 };
215
216 struct ath_buf_state {
217         int bfs_nframes;
218         u16 bfs_al;
219         u16 bfs_frmlen;
220         int bfs_retries;
221         u8 bf_type;
222         u8 bfs_paprd;
223         enum ath9k_internal_frame_type bfs_ftype;
224 };
225
226 struct ath_buf {
227         struct list_head list;
228         struct ath_buf *bf_lastbf;      /* last buf of this unit (a frame or
229                                            an aggregate) */
230         struct ath_buf *bf_next;        /* next subframe in the aggregate */
231         struct sk_buff *bf_mpdu;        /* enclosing frame structure */
232         void *bf_desc;                  /* virtual addr of desc */
233         dma_addr_t bf_daddr;            /* physical addr of desc */
234         dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
235         bool bf_stale;
236         bool bf_tx_aborted;
237         u16 bf_flags;
238         struct ath_buf_state bf_state;
239         struct ath_wiphy *aphy;
240 };
241
242 struct ath_atx_tid {
243         struct list_head list;
244         struct list_head buf_q;
245         struct ath_node *an;
246         struct ath_atx_ac *ac;
247         unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
248         u16 seq_start;
249         u16 seq_next;
250         u16 baw_size;
251         int tidno;
252         int baw_head;   /* first un-acked tx buffer */
253         int baw_tail;   /* next unused tx buffer slot */
254         int sched;
255         int paused;
256         u8 state;
257 };
258
259 struct ath_node {
260         struct ath_common *common;
261         struct ath_atx_tid tid[WME_NUM_TID];
262         struct ath_atx_ac ac[WME_NUM_AC];
263         u16 maxampdu;
264         u8 mpdudensity;
265 };
266
267 #define AGGR_CLEANUP         BIT(1)
268 #define AGGR_ADDBA_COMPLETE  BIT(2)
269 #define AGGR_ADDBA_PROGRESS  BIT(3)
270
271 struct ath_tx_control {
272         struct ath_txq *txq;
273         int if_id;
274         enum ath9k_internal_frame_type frame_type;
275         u8 paprd;
276 };
277
278 #define ATH_TX_ERROR        0x01
279 #define ATH_TX_XRETRY       0x02
280 #define ATH_TX_BAR          0x04
281
282 struct ath_tx {
283         u16 seq_no;
284         u32 txqsetup;
285         spinlock_t txbuflock;
286         struct list_head txbuf;
287         struct ath_txq txq[ATH9K_NUM_TX_QUEUES];
288         struct ath_descdma txdma;
289         struct ath_txq *txq_map[WME_NUM_AC];
290 };
291
292 struct ath_rx_edma {
293         struct sk_buff_head rx_fifo;
294         struct sk_buff_head rx_buffers;
295         u32 rx_fifo_hwsize;
296 };
297
298 struct ath_rx {
299         u8 defant;
300         u8 rxotherant;
301         u32 *rxlink;
302         unsigned int rxfilter;
303         spinlock_t rxbuflock;
304         struct list_head rxbuf;
305         struct ath_descdma rxdma;
306         struct ath_buf *rx_bufptr;
307         struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
308 };
309
310 int ath_startrecv(struct ath_softc *sc);
311 bool ath_stoprecv(struct ath_softc *sc);
312 void ath_flushrecv(struct ath_softc *sc);
313 u32 ath_calcrxfilter(struct ath_softc *sc);
314 int ath_rx_init(struct ath_softc *sc, int nbufs);
315 void ath_rx_cleanup(struct ath_softc *sc);
316 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
317 struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
318 void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
319 void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
320 void ath_draintxq(struct ath_softc *sc,
321                      struct ath_txq *txq, bool retry_tx);
322 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
323 void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
324 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
325 int ath_tx_init(struct ath_softc *sc, int nbufs);
326 void ath_tx_cleanup(struct ath_softc *sc);
327 int ath_txq_update(struct ath_softc *sc, int qnum,
328                    struct ath9k_tx_queue_info *q);
329 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
330                  struct ath_tx_control *txctl);
331 void ath_tx_tasklet(struct ath_softc *sc);
332 void ath_tx_edma_tasklet(struct ath_softc *sc);
333 void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb);
334 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
335                       u16 tid, u16 *ssn);
336 void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
337 void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
338
339 /********/
340 /* VIFs */
341 /********/
342
343 struct ath_vif {
344         int av_bslot;
345         __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
346         enum nl80211_iftype av_opmode;
347         struct ath_buf *av_bcbuf;
348         struct ath_tx_control av_btxctl;
349         u8 bssid[ETH_ALEN]; /* current BSSID from config_interface */
350 };
351
352 /*******************/
353 /* Beacon Handling */
354 /*******************/
355
356 /*
357  * Regardless of the number of beacons we stagger, (i.e. regardless of the
358  * number of BSSIDs) if a given beacon does not go out even after waiting this
359  * number of beacon intervals, the game's up.
360  */
361 #define BSTUCK_THRESH                   (9 * ATH_BCBUF)
362 #define ATH_BCBUF                       4
363 #define ATH_DEFAULT_BINTVAL             100 /* TU */
364 #define ATH_DEFAULT_BMISS_LIMIT         10
365 #define IEEE80211_MS_TO_TU(x)           (((x) * 1000) / 1024)
366
367 struct ath_beacon_config {
368         u16 beacon_interval;
369         u16 listen_interval;
370         u16 dtim_period;
371         u16 bmiss_timeout;
372         u8 dtim_count;
373 };
374
375 struct ath_beacon {
376         enum {
377                 OK,             /* no change needed */
378                 UPDATE,         /* update pending */
379                 COMMIT          /* beacon sent, commit change */
380         } updateslot;           /* slot time update fsm */
381
382         u32 beaconq;
383         u32 bmisscnt;
384         u32 ast_be_xmit;
385         u64 bc_tstamp;
386         struct ieee80211_vif *bslot[ATH_BCBUF];
387         struct ath_wiphy *bslot_aphy[ATH_BCBUF];
388         int slottime;
389         int slotupdate;
390         struct ath9k_tx_queue_info beacon_qi;
391         struct ath_descdma bdma;
392         struct ath_txq *cabq;
393         struct list_head bbuf;
394 };
395
396 void ath_beacon_tasklet(unsigned long data);
397 void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
398 int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif);
399 void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp);
400 int ath_beaconq_config(struct ath_softc *sc);
401
402 /*******/
403 /* ANI */
404 /*******/
405
406 #define ATH_STA_SHORT_CALINTERVAL 1000    /* 1 second */
407 #define ATH_AP_SHORT_CALINTERVAL  100     /* 100 ms */
408 #define ATH_ANI_POLLINTERVAL_OLD  100     /* 100 ms */
409 #define ATH_ANI_POLLINTERVAL_NEW  1000    /* 1000 ms */
410 #define ATH_LONG_CALINTERVAL_INT  1000    /* 1000 ms */
411 #define ATH_LONG_CALINTERVAL      30000   /* 30 seconds */
412 #define ATH_RESTART_CALINTERVAL   1200000 /* 20 minutes */
413
414 #define ATH_PAPRD_TIMEOUT       100 /* msecs */
415
416 void ath_hw_check(struct work_struct *work);
417 void ath_paprd_calibrate(struct work_struct *work);
418 void ath_ani_calibrate(unsigned long data);
419
420 /**********/
421 /* BTCOEX */
422 /**********/
423
424 struct ath_btcoex {
425         bool hw_timer_enabled;
426         spinlock_t btcoex_lock;
427         struct timer_list period_timer; /* Timer for BT period */
428         u32 bt_priority_cnt;
429         unsigned long bt_priority_time;
430         int bt_stomp_type; /* Types of BT stomping */
431         u32 btcoex_no_stomp; /* in usec */
432         u32 btcoex_period; /* in usec */
433         u32 btscan_no_stomp; /* in usec */
434         struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */
435 };
436
437 int ath_init_btcoex_timer(struct ath_softc *sc);
438 void ath9k_btcoex_timer_resume(struct ath_softc *sc);
439 void ath9k_btcoex_timer_pause(struct ath_softc *sc);
440
441 /********************/
442 /*   LED Control    */
443 /********************/
444
445 #define ATH_LED_PIN_DEF                 1
446 #define ATH_LED_PIN_9287                8
447 #define ATH_LED_ON_DURATION_IDLE        350     /* in msecs */
448 #define ATH_LED_OFF_DURATION_IDLE       250     /* in msecs */
449
450 enum ath_led_type {
451         ATH_LED_RADIO,
452         ATH_LED_ASSOC,
453         ATH_LED_TX,
454         ATH_LED_RX
455 };
456
457 struct ath_led {
458         struct ath_softc *sc;
459         struct led_classdev led_cdev;
460         enum ath_led_type led_type;
461         char name[32];
462         bool registered;
463 };
464
465 void ath_init_leds(struct ath_softc *sc);
466 void ath_deinit_leds(struct ath_softc *sc);
467
468 /* Antenna diversity/combining */
469 #define ATH_ANT_RX_CURRENT_SHIFT 4
470 #define ATH_ANT_RX_MAIN_SHIFT 2
471 #define ATH_ANT_RX_MASK 0x3
472
473 #define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50
474 #define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100
475 #define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200
476 #define ATH_ANT_DIV_COMB_INIT_COUNT 95
477 #define ATH_ANT_DIV_COMB_MAX_COUNT 100
478 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
479 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
480
481 #define ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA -3
482 #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
483 #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
484 #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
485 #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
486
487 enum ath9k_ant_div_comb_lna_conf {
488         ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
489         ATH_ANT_DIV_COMB_LNA2,
490         ATH_ANT_DIV_COMB_LNA1,
491         ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
492 };
493
494 struct ath_ant_comb {
495         u16 count;
496         u16 total_pkt_count;
497         bool scan;
498         bool scan_not_start;
499         int main_total_rssi;
500         int alt_total_rssi;
501         int alt_recv_cnt;
502         int main_recv_cnt;
503         int rssi_lna1;
504         int rssi_lna2;
505         int rssi_add;
506         int rssi_sub;
507         int rssi_first;
508         int rssi_second;
509         int rssi_third;
510         bool alt_good;
511         int quick_scan_cnt;
512         int main_conf;
513         enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf;
514         enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf;
515         int first_bias;
516         int second_bias;
517         bool first_ratio;
518         bool second_ratio;
519         unsigned long scan_start_time;
520 };
521
522 /********************/
523 /* Main driver core */
524 /********************/
525
526 /*
527  * Default cache line size, in bytes.
528  * Used when PCI device not fully initialized by bootrom/BIOS
529 */
530 #define DEFAULT_CACHELINE       32
531 #define ATH_REGCLASSIDS_MAX     10
532 #define ATH_CABQ_READY_TIME     80      /* % of beacon interval */
533 #define ATH_MAX_SW_RETRIES      10
534 #define ATH_CHAN_MAX            255
535 #define IEEE80211_WEP_NKID      4       /* number of key ids */
536
537 #define ATH_TXPOWER_MAX         100     /* .5 dBm units */
538 #define ATH_RATE_DUMMY_MARKER   0
539
540 #define SC_OP_INVALID                BIT(0)
541 #define SC_OP_BEACONS                BIT(1)
542 #define SC_OP_RXAGGR                 BIT(2)
543 #define SC_OP_TXAGGR                 BIT(3)
544 #define SC_OP_OFFCHANNEL             BIT(4)
545 #define SC_OP_PREAMBLE_SHORT         BIT(5)
546 #define SC_OP_PROTECT_ENABLE         BIT(6)
547 #define SC_OP_RXFLUSH                BIT(7)
548 #define SC_OP_LED_ASSOCIATED         BIT(8)
549 #define SC_OP_LED_ON                 BIT(9)
550 #define SC_OP_TSF_RESET              BIT(11)
551 #define SC_OP_BT_PRIORITY_DETECTED   BIT(12)
552 #define SC_OP_BT_SCAN                BIT(13)
553 #define SC_OP_ANI_RUN                BIT(14)
554
555 /* Powersave flags */
556 #define PS_WAIT_FOR_BEACON        BIT(0)
557 #define PS_WAIT_FOR_CAB           BIT(1)
558 #define PS_WAIT_FOR_PSPOLL_DATA   BIT(2)
559 #define PS_WAIT_FOR_TX_ACK        BIT(3)
560 #define PS_BEACON_SYNC            BIT(4)
561
562 struct ath_wiphy;
563 struct ath_rate_table;
564
565 struct ath_softc {
566         struct ieee80211_hw *hw;
567         struct device *dev;
568
569         spinlock_t wiphy_lock; /* spinlock to protect ath_wiphy data */
570         struct ath_wiphy *pri_wiphy;
571         struct ath_wiphy **sec_wiphy; /* secondary wiphys (virtual radios); may
572                                        * have NULL entries */
573         int num_sec_wiphy; /* number of sec_wiphy pointers in the array */
574         int chan_idx;
575         int chan_is_ht;
576         struct ath_wiphy *next_wiphy;
577         struct work_struct chan_work;
578         int wiphy_select_failures;
579         unsigned long wiphy_select_first_fail;
580         struct delayed_work wiphy_work;
581         unsigned long wiphy_scheduler_int;
582         int wiphy_scheduler_index;
583         struct survey_info *cur_survey;
584         struct survey_info survey[ATH9K_NUM_CHANNELS];
585
586         struct tasklet_struct intr_tq;
587         struct tasklet_struct bcon_tasklet;
588         struct ath_hw *sc_ah;
589         void __iomem *mem;
590         int irq;
591         spinlock_t sc_serial_rw;
592         spinlock_t sc_pm_lock;
593         spinlock_t sc_pcu_lock;
594         struct mutex mutex;
595         struct work_struct paprd_work;
596         struct work_struct hw_check_work;
597         struct completion paprd_complete;
598         bool paprd_pending;
599
600         u32 intrstatus;
601         u32 sc_flags; /* SC_OP_* */
602         u16 ps_flags; /* PS_* */
603         u16 curtxpow;
604         u8 nbcnvifs;
605         u16 nvifs;
606         bool ps_enabled;
607         bool ps_idle;
608         unsigned long ps_usecount;
609
610         struct ath_config config;
611         struct ath_rx rx;
612         struct ath_tx tx;
613         struct ath_beacon beacon;
614         struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
615
616         struct ath_led radio_led;
617         struct ath_led assoc_led;
618         struct ath_led tx_led;
619         struct ath_led rx_led;
620         struct delayed_work ath_led_blink_work;
621         int led_on_duration;
622         int led_off_duration;
623         int led_on_cnt;
624         int led_off_cnt;
625
626         int beacon_interval;
627
628 #ifdef CONFIG_ATH9K_DEBUGFS
629         struct ath9k_debug debug;
630 #endif
631         struct ath_beacon_config cur_beacon_conf;
632         struct delayed_work tx_complete_work;
633         struct ath_btcoex btcoex;
634
635         struct ath_descdma txsdma;
636
637         struct ath_ant_comb ant_comb;
638 };
639
640 struct ath_wiphy {
641         struct ath_softc *sc; /* shared for all virtual wiphys */
642         struct ieee80211_hw *hw;
643         struct ath9k_hw_cal_data caldata;
644         enum ath_wiphy_state {
645                 ATH_WIPHY_INACTIVE,
646                 ATH_WIPHY_ACTIVE,
647                 ATH_WIPHY_PAUSING,
648                 ATH_WIPHY_PAUSED,
649                 ATH_WIPHY_SCAN,
650         } state;
651         bool idle;
652         int chan_idx;
653         int chan_is_ht;
654         int last_rssi;
655 };
656
657 void ath9k_tasklet(unsigned long data);
658 int ath_reset(struct ath_softc *sc, bool retry_tx);
659 int ath_cabq_update(struct ath_softc *);
660
661 static inline void ath_read_cachesize(struct ath_common *common, int *csz)
662 {
663         common->bus_ops->read_cachesize(common, csz);
664 }
665
666 extern struct ieee80211_ops ath9k_ops;
667 extern int modparam_nohwcrypt;
668 extern int led_blink;
669
670 irqreturn_t ath_isr(int irq, void *dev);
671 int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
672                     const struct ath_bus_ops *bus_ops);
673 void ath9k_deinit_device(struct ath_softc *sc);
674 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw);
675 void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
676                            struct ath9k_channel *ichan);
677 void ath_update_chainmask(struct ath_softc *sc, int is_ht);
678 int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
679                     struct ath9k_channel *hchan);
680
681 void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw);
682 void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw);
683 bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode);
684
685 #ifdef CONFIG_PCI
686 int ath_pci_init(void);
687 void ath_pci_exit(void);
688 #else
689 static inline int ath_pci_init(void) { return 0; };
690 static inline void ath_pci_exit(void) {};
691 #endif
692
693 #ifdef CONFIG_ATHEROS_AR71XX
694 int ath_ahb_init(void);
695 void ath_ahb_exit(void);
696 #else
697 static inline int ath_ahb_init(void) { return 0; };
698 static inline void ath_ahb_exit(void) {};
699 #endif
700
701 void ath9k_ps_wakeup(struct ath_softc *sc);
702 void ath9k_ps_restore(struct ath_softc *sc);
703
704 void ath9k_set_bssid_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
705 int ath9k_wiphy_add(struct ath_softc *sc);
706 int ath9k_wiphy_del(struct ath_wiphy *aphy);
707 void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype);
708 int ath9k_wiphy_pause(struct ath_wiphy *aphy);
709 int ath9k_wiphy_unpause(struct ath_wiphy *aphy);
710 int ath9k_wiphy_select(struct ath_wiphy *aphy);
711 void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int);
712 void ath9k_wiphy_chan_work(struct work_struct *work);
713 bool ath9k_wiphy_started(struct ath_softc *sc);
714 void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
715                                   struct ath_wiphy *selected);
716 bool ath9k_wiphy_scanning(struct ath_softc *sc);
717 void ath9k_wiphy_work(struct work_struct *work);
718 bool ath9k_all_wiphys_idle(struct ath_softc *sc);
719 void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle);
720
721 void ath_mac80211_stop_queue(struct ath_softc *sc, u16 skb_queue);
722 bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue);
723
724 void ath_start_rfkill_poll(struct ath_softc *sc);
725 extern void ath9k_rfkill_poll_state(struct ieee80211_hw *hw);
726
727 #endif /* ATH9K_H */