21 #include <linux/device.h>
40 #define ito64(x) (sizeof(x) == 1) ? \
41 (((unsigned long long int)(x)) & (0xff)) : \
43 (((unsigned long long int)(x)) & 0xffff) : \
45 (((unsigned long long int)(x)) & 0xffffffff) : \
46 (unsigned long long int)(x))
49 #define INCR(_l, _sz) do { \
51 (_l) &= ((_sz) - 1); \
55 #define DECR(_l, _sz) do { \
57 (_l) &= ((_sz) - 1); \
60 #define TSF_TO_TU(_h,_l) \
61 ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
63 #define ATH_TXQ_SETUP(sc, i) ((sc)->tx.txqsetup & (1<<i))
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)); \
82 #define ATH_RXBUF_RESET(_bf) do { \
83 (_bf)->bf_stale = false; \
98 #define bf_isampdu(bf) (bf->bf_state.bf_type & BUF_AMPDU)
99 #define bf_isaggr(bf) (bf->bf_state.bf_type & BUF_AGGR)
101 #define ATH_TXSTATUS_RING_SIZE 512
103 #define DS2PHYS(_dd, _ds) \
104 ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
105 #define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0)
106 #define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096)
117 int nbuf,
int ndesc,
bool is_tx);
125 #define ATH_RXBUF 512
126 #define ATH_TXBUF 512
127 #define ATH_TXBUF_RESERVE 5
128 #define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
129 #define ATH_TXMAXTRY 13
131 #define TID_TO_WME_AC(_tid) \
132 ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
133 (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
134 (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
137 #define ATH_AGGR_DELIM_SZ 4
138 #define ATH_AGGR_MINPLEN 256
140 #define ATH_AGGR_ENCRYPTDELIM 10
142 #define ATH_AGGR_MIN_QDEPTH 2
143 #define ATH_AMPDU_SUBFRAME_DEFAULT 32
145 #define IEEE80211_SEQ_SEQ_SHIFT 4
146 #define IEEE80211_SEQ_MAX 4096
147 #define IEEE80211_WEP_IVLEN 3
148 #define IEEE80211_WEP_KIDLEN 1
149 #define IEEE80211_WEP_CRCLEN 4
150 #define IEEE80211_MAX_MPDU_LEN (3840 + FCS_LEN + \
151 (IEEE80211_WEP_IVLEN + \
152 IEEE80211_WEP_KIDLEN + \
153 IEEE80211_WEP_CRCLEN))
157 #define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \
158 ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
161 #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
164 #define ATH_BA_INDEX2SEQ(_seq, _offset) (((_seq) + (_offset)) & (IEEE80211_SEQ_MAX - 1))
167 #define ATH_AGGR_GET_NDELIM(_len) \
168 (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \
169 DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ))
171 #define BAW_WITHIN(_start, _bawsz, _seqno) \
172 ((((_seqno) - (_start)) & 4095) < (_bawsz))
174 #define ATH_AN_2_TID(_an, _tidno) (&(_an)->tid[(_tidno)])
176 #define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e))
178 #define ATH_TX_COMPLETE_POLL_INT 1000
186 #define ATH_TXFIFO_DEPTH 8
262 #ifdef CONFIG_ATH9K_DEBUGFS
277 #define AGGR_CLEANUP BIT(1)
278 #define AGGR_ADDBA_COMPLETE BIT(2)
279 #define AGGR_ADDBA_PROGRESS BIT(3)
288 #define ATH_TX_ERROR 0x01
341 struct ath_txq *txq,
bool retry_tx);
383 #define BSTUCK_THRESH 9
385 #define ATH_DEFAULT_BINTVAL 100
386 #define ATH_DEFAULT_BMISS_LIMIT 10
387 #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
433 #define ATH_STA_SHORT_CALINTERVAL 1000
434 #define ATH_AP_SHORT_CALINTERVAL 100
435 #define ATH_ANI_POLLINTERVAL_OLD 100
436 #define ATH_ANI_POLLINTERVAL_NEW 1000
437 #define ATH_LONG_CALINTERVAL_INT 1000
438 #define ATH_LONG_CALINTERVAL 30000
439 #define ATH_RESTART_CALINTERVAL 1200000
441 #define ATH_PAPRD_TIMEOUT 100
442 #define ATH_PLL_WORK_INTERVAL 100
485 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
490 void ath9k_btcoex_timer_resume(
struct ath_softc *
sc);
491 void ath9k_btcoex_timer_pause(
struct ath_softc *
sc);
494 void ath9k_btcoex_stop_gen_timer(
struct ath_softc *
sc);
496 static inline int ath9k_init_btcoex(
struct ath_softc *
sc)
500 static inline void ath9k_deinit_btcoex(
struct ath_softc *
sc)
503 static inline void ath9k_start_btcoex(
struct ath_softc *
sc)
506 static inline void ath9k_stop_btcoex(
struct ath_softc *
sc)
509 static inline void ath9k_btcoex_handle_interrupt(
struct ath_softc *
sc,
514 u32 max_4ms_framelen)
518 static inline void ath9k_btcoex_stop_gen_timer(
struct ath_softc *
sc)
533 #define ATH_LED_PIN_DEF 1
534 #define ATH_LED_PIN_9287 8
535 #define ATH_LED_PIN_9300 10
536 #define ATH_LED_PIN_9485 6
537 #define ATH_LED_PIN_9462 4
539 #ifdef CONFIG_MAC80211_LEDS
544 static inline void ath_init_leds(
struct ath_softc *
sc)
548 static inline void ath_deinit_leds(
struct ath_softc *
sc)
551 static inline void ath_fill_led_pin(
struct ath_softc *
sc)
560 #define ATH_ANT_RX_CURRENT_SHIFT 4
561 #define ATH_ANT_RX_MAIN_SHIFT 2
562 #define ATH_ANT_RX_MASK 0x3
564 #define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50
565 #define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100
566 #define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200
567 #define ATH_ANT_DIV_COMB_INIT_COUNT 95
568 #define ATH_ANT_DIV_COMB_MAX_COUNT 100
569 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
570 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
572 #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
573 #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
574 #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
575 #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
621 #define DEFAULT_CACHELINE 32
622 #define ATH_REGCLASSIDS_MAX 10
623 #define ATH_CABQ_READY_TIME 80
624 #define ATH_MAX_SW_RETRIES 30
625 #define ATH_CHAN_MAX 255
627 #define ATH_TXPOWER_MAX 100
628 #define ATH_RATE_DUMMY_MARKER 0
640 #define PS_WAIT_FOR_BEACON BIT(0)
641 #define PS_WAIT_FOR_CAB BIT(1)
642 #define PS_WAIT_FOR_PSPOLL_DATA BIT(2)
643 #define PS_WAIT_FOR_TX_ACK BIT(3)
644 #define PS_BEACON_SYNC BIT(4)
700 #ifdef CONFIG_MAC80211_LEDS
709 #ifdef CONFIG_ATH9K_DEBUGFS
710 struct ath9k_debug
debug;
713 unsigned int tx_complete_poll_work_seen;
720 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
733 #ifdef CONFIG_PM_SLEEP
736 u32 wow_intr_before_sleep;
745 common->
bus_ops->read_cachesize(common, csz);
763 #ifdef CONFIG_ATH9K_PCI
771 #ifdef CONFIG_ATH9K_AHB