core.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. /*
  2. * Copyright (c) 2008 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. #ifndef CORE_H
  17. #define CORE_H
  18. #include <linux/version.h>
  19. #include <linux/autoconf.h>
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/errno.h>
  24. #include <linux/skbuff.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/etherdevice.h>
  27. #include <linux/ip.h>
  28. #include <linux/tcp.h>
  29. #include <linux/in.h>
  30. #include <linux/delay.h>
  31. #include <linux/wait.h>
  32. #include <linux/pci.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/sched.h>
  35. #include <linux/list.h>
  36. #include <asm/byteorder.h>
  37. #include <linux/scatterlist.h>
  38. #include <asm/page.h>
  39. #include <net/mac80211.h>
  40. #include "ath9k.h"
  41. #include "rc.h"
  42. struct ath_node;
  43. /******************/
  44. /* Utility macros */
  45. /******************/
  46. /* Macro to expand scalars to 64-bit objects */
  47. #define ito64(x) (sizeof(x) == 8) ? \
  48. (((unsigned long long int)(x)) & (0xff)) : \
  49. (sizeof(x) == 16) ? \
  50. (((unsigned long long int)(x)) & 0xffff) : \
  51. ((sizeof(x) == 32) ? \
  52. (((unsigned long long int)(x)) & 0xffffffff) : \
  53. (unsigned long long int)(x))
  54. /* increment with wrap-around */
  55. #define INCR(_l, _sz) do { \
  56. (_l)++; \
  57. (_l) &= ((_sz) - 1); \
  58. } while (0)
  59. /* decrement with wrap-around */
  60. #define DECR(_l, _sz) do { \
  61. (_l)--; \
  62. (_l) &= ((_sz) - 1); \
  63. } while (0)
  64. #define A_MAX(a, b) ((a) > (b) ? (a) : (b))
  65. #define ASSERT(exp) do { \
  66. if (unlikely(!(exp))) { \
  67. BUG(); \
  68. } \
  69. } while (0)
  70. /* XXX: remove */
  71. #define memzero(_buf, _len) memset(_buf, 0, _len)
  72. #define get_dma_mem_context(var, field) (&((var)->field))
  73. #define copy_dma_mem_context(dst, src) (*dst = *src)
  74. #define ATH9K_BH_STATUS_INTACT 0
  75. #define ATH9K_BH_STATUS_CHANGE 1
  76. #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<<i))
  77. static inline unsigned long get_timestamp(void)
  78. {
  79. return ((jiffies / HZ) * 1000) + (jiffies % HZ) * (1000 / HZ);
  80. }
  81. /*************/
  82. /* Debugging */
  83. /*************/
  84. enum ATH_DEBUG {
  85. ATH_DBG_RESET = 0x00000001,
  86. ATH_DBG_PHY_IO = 0x00000002,
  87. ATH_DBG_REG_IO = 0x00000004,
  88. ATH_DBG_QUEUE = 0x00000008,
  89. ATH_DBG_EEPROM = 0x00000010,
  90. ATH_DBG_NF_CAL = 0x00000020,
  91. ATH_DBG_CALIBRATE = 0x00000040,
  92. ATH_DBG_CHANNEL = 0x00000080,
  93. ATH_DBG_INTERRUPT = 0x00000100,
  94. ATH_DBG_REGULATORY = 0x00000200,
  95. ATH_DBG_ANI = 0x00000400,
  96. ATH_DBG_POWER_MGMT = 0x00000800,
  97. ATH_DBG_XMIT = 0x00001000,
  98. ATH_DBG_BEACON = 0x00002000,
  99. ATH_DBG_RATE = 0x00004000,
  100. ATH_DBG_CONFIG = 0x00008000,
  101. ATH_DBG_KEYCACHE = 0x00010000,
  102. ATH_DBG_AGGR = 0x00020000,
  103. ATH_DBG_FATAL = 0x00040000,
  104. ATH_DBG_ANY = 0xffffffff
  105. };
  106. #define DBG_DEFAULT (ATH_DBG_FATAL)
  107. #define DPRINTF(sc, _m, _fmt, ...) do { \
  108. if (sc->sc_debug & (_m)) \
  109. printk(_fmt , ##__VA_ARGS__); \
  110. } while (0)
  111. /***************************/
  112. /* Load-time Configuration */
  113. /***************************/
  114. /* Per-instance load-time (note: NOT run-time) configurations
  115. * for Atheros Device */
  116. struct ath_config {
  117. u32 ath_aggr_prot;
  118. u16 txpowlimit;
  119. u16 txpowlimit_override;
  120. u8 cabqReadytime; /* Cabq Readytime % */
  121. u8 swBeaconProcess; /* Process received beacons in SW (vs HW) */
  122. };
  123. /***********************/
  124. /* Chainmask Selection */
  125. /***********************/
  126. #define ATH_CHAINMASK_SEL_TIMEOUT 6000
  127. /* Default - Number of last RSSI values that is used for
  128. * chainmask selection */
  129. #define ATH_CHAINMASK_SEL_RSSI_CNT 10
  130. /* Means use 3x3 chainmask instead of configured chainmask */
  131. #define ATH_CHAINMASK_SEL_3X3 7
  132. /* Default - Rssi threshold below which we have to switch to 3x3 */
  133. #define ATH_CHAINMASK_SEL_UP_RSSI_THRES 20
  134. /* Default - Rssi threshold above which we have to switch to
  135. * user configured values */
  136. #define ATH_CHAINMASK_SEL_DOWN_RSSI_THRES 35
  137. /* Struct to store the chainmask select related info */
  138. struct ath_chainmask_sel {
  139. struct timer_list timer;
  140. int cur_tx_mask; /* user configured or 3x3 */
  141. int cur_rx_mask; /* user configured or 3x3 */
  142. int tx_avgrssi;
  143. u8 switch_allowed:1, /* timer will set this */
  144. cm_sel_enabled : 1;
  145. };
  146. int ath_chainmask_sel_logic(struct ath_softc *sc, struct ath_node *an);
  147. void ath_update_chainmask(struct ath_softc *sc, int is_ht);
  148. /*************************/
  149. /* Descriptor Management */
  150. /*************************/
  151. /* Number of descriptors per buffer. The only case where we see skbuff
  152. chains is due to FF aggregation in the driver. */
  153. #define ATH_TXDESC 1
  154. /* if there's more fragment for this MSDU */
  155. #define ATH_BF_MORE_MPDU 1
  156. #define ATH_TXBUF_RESET(_bf) do { \
  157. (_bf)->bf_status = 0; \
  158. (_bf)->bf_lastbf = NULL; \
  159. (_bf)->bf_lastfrm = NULL; \
  160. (_bf)->bf_next = NULL; \
  161. memzero(&((_bf)->bf_state), \
  162. sizeof(struct ath_buf_state)); \
  163. } while (0)
  164. struct ath_buf_state {
  165. int bfs_nframes; /* # frames in aggregate */
  166. u16 bfs_al; /* length of aggregate */
  167. u16 bfs_frmlen; /* length of frame */
  168. int bfs_seqno; /* sequence number */
  169. int bfs_tidno; /* tid of this frame */
  170. int bfs_retries; /* current retries */
  171. struct ath_rc_series bfs_rcs[4]; /* rate series */
  172. u8 bfs_isdata:1; /* is a data frame/aggregate */
  173. u8 bfs_isaggr:1; /* is an aggregate */
  174. u8 bfs_isampdu:1; /* is an a-mpdu, aggregate or not */
  175. u8 bfs_ht:1; /* is an HT frame */
  176. u8 bfs_isretried:1; /* is retried */
  177. u8 bfs_isxretried:1; /* is excessive retried */
  178. u8 bfs_shpreamble:1; /* is short preamble */
  179. u8 bfs_isbar:1; /* is a BAR */
  180. u8 bfs_ispspoll:1; /* is a PS-Poll */
  181. u8 bfs_aggrburst:1; /* is a aggr burst */
  182. u8 bfs_calcairtime:1; /* requests airtime be calculated
  183. when set for tx frame */
  184. int bfs_rifsburst_elem; /* RIFS burst/bar */
  185. int bfs_nrifsubframes; /* # of elements in burst */
  186. /* key type use to encrypt this frame */
  187. enum ath9k_key_type bfs_keytype;
  188. };
  189. #define bf_nframes bf_state.bfs_nframes
  190. #define bf_al bf_state.bfs_al
  191. #define bf_frmlen bf_state.bfs_frmlen
  192. #define bf_retries bf_state.bfs_retries
  193. #define bf_seqno bf_state.bfs_seqno
  194. #define bf_tidno bf_state.bfs_tidno
  195. #define bf_rcs bf_state.bfs_rcs
  196. #define bf_isdata bf_state.bfs_isdata
  197. #define bf_isaggr bf_state.bfs_isaggr
  198. #define bf_isampdu bf_state.bfs_isampdu
  199. #define bf_ht bf_state.bfs_ht
  200. #define bf_isretried bf_state.bfs_isretried
  201. #define bf_isxretried bf_state.bfs_isxretried
  202. #define bf_shpreamble bf_state.bfs_shpreamble
  203. #define bf_rifsburst_elem bf_state.bfs_rifsburst_elem
  204. #define bf_nrifsubframes bf_state.bfs_nrifsubframes
  205. #define bf_keytype bf_state.bfs_keytype
  206. #define bf_isbar bf_state.bfs_isbar
  207. #define bf_ispspoll bf_state.bfs_ispspoll
  208. #define bf_aggrburst bf_state.bfs_aggrburst
  209. #define bf_calcairtime bf_state.bfs_calcairtime
  210. /*
  211. * Abstraction of a contiguous buffer to transmit/receive. There is only
  212. * a single hw descriptor encapsulated here.
  213. */
  214. struct ath_buf {
  215. struct list_head list;
  216. struct list_head *last;
  217. struct ath_buf *bf_lastbf; /* last buf of this unit (a frame or
  218. an aggregate) */
  219. struct ath_buf *bf_lastfrm; /* last buf of this frame */
  220. struct ath_buf *bf_next; /* next subframe in the aggregate */
  221. struct ath_buf *bf_rifslast; /* last buf for RIFS burst */
  222. void *bf_mpdu; /* enclosing frame structure */
  223. void *bf_node; /* pointer to the node */
  224. struct ath_desc *bf_desc; /* virtual addr of desc */
  225. dma_addr_t bf_daddr; /* physical addr of desc */
  226. dma_addr_t bf_buf_addr; /* physical addr of data buffer */
  227. u32 bf_status;
  228. u16 bf_flags; /* tx descriptor flags */
  229. struct ath_buf_state bf_state; /* buffer state */
  230. dma_addr_t bf_dmacontext;
  231. };
  232. /*
  233. * reset the rx buffer.
  234. * any new fields added to the athbuf and require
  235. * reset need to be added to this macro.
  236. * currently bf_status is the only one requires that
  237. * requires reset.
  238. */
  239. #define ATH_RXBUF_RESET(_bf) ((_bf)->bf_status = 0)
  240. /* hw processing complete, desc processed by hal */
  241. #define ATH_BUFSTATUS_DONE 0x00000001
  242. /* hw processing complete, desc hold for hw */
  243. #define ATH_BUFSTATUS_STALE 0x00000002
  244. /* Rx-only: OS is done with this packet and it's ok to queued it to hw */
  245. #define ATH_BUFSTATUS_FREE 0x00000004
  246. /* DMA state for tx/rx descriptors */
  247. struct ath_descdma {
  248. const char *dd_name;
  249. struct ath_desc *dd_desc; /* descriptors */
  250. dma_addr_t dd_desc_paddr; /* physical addr of dd_desc */
  251. u32 dd_desc_len; /* size of dd_desc */
  252. struct ath_buf *dd_bufptr; /* associated buffers */
  253. dma_addr_t dd_dmacontext;
  254. };
  255. /* Abstraction of a received RX MPDU/MMPDU, or a RX fragment */
  256. struct ath_rx_context {
  257. struct ath_buf *ctx_rxbuf; /* associated ath_buf for rx */
  258. };
  259. #define ATH_RX_CONTEXT(skb) ((struct ath_rx_context *)skb->cb)
  260. int ath_descdma_setup(struct ath_softc *sc,
  261. struct ath_descdma *dd,
  262. struct list_head *head,
  263. const char *name,
  264. int nbuf,
  265. int ndesc);
  266. int ath_desc_alloc(struct ath_softc *sc);
  267. void ath_desc_free(struct ath_softc *sc);
  268. void ath_descdma_cleanup(struct ath_softc *sc,
  269. struct ath_descdma *dd,
  270. struct list_head *head);
  271. /******/
  272. /* RX */
  273. /******/
  274. #define ATH_MAX_ANTENNA 3
  275. #define ATH_RXBUF 512
  276. #define ATH_RX_TIMEOUT 40 /* 40 milliseconds */
  277. #define WME_NUM_TID 16
  278. #define IEEE80211_BAR_CTL_TID_M 0xF000 /* tid mask */
  279. #define IEEE80211_BAR_CTL_TID_S 2 /* tid shift */
  280. enum ATH_RX_TYPE {
  281. ATH_RX_NON_CONSUMED = 0,
  282. ATH_RX_CONSUMED
  283. };
  284. /* per frame rx status block */
  285. struct ath_recv_status {
  286. u64 tsf; /* mac tsf */
  287. int8_t rssi; /* RSSI (noise floor ajusted) */
  288. int8_t rssictl[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  289. int8_t rssiextn[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  290. int8_t abs_rssi; /* absolute RSSI */
  291. u8 rateieee; /* data rate received (IEEE rate code) */
  292. u8 ratecode; /* phy rate code */
  293. int rateKbps; /* data rate received (Kbps) */
  294. int antenna; /* rx antenna */
  295. int flags; /* status of associated skb */
  296. #define ATH_RX_FCS_ERROR 0x01
  297. #define ATH_RX_MIC_ERROR 0x02
  298. #define ATH_RX_DECRYPT_ERROR 0x04
  299. #define ATH_RX_RSSI_VALID 0x08
  300. /* if any of ctl,extn chainrssis are valid */
  301. #define ATH_RX_CHAIN_RSSI_VALID 0x10
  302. /* if extn chain rssis are valid */
  303. #define ATH_RX_RSSI_EXTN_VALID 0x20
  304. /* set if 40Mhz, clear if 20Mhz */
  305. #define ATH_RX_40MHZ 0x40
  306. /* set if short GI, clear if full GI */
  307. #define ATH_RX_SHORT_GI 0x80
  308. };
  309. struct ath_rxbuf {
  310. struct sk_buff *rx_wbuf;
  311. unsigned long rx_time; /* system time when received */
  312. struct ath_recv_status rx_status; /* cached rx status */
  313. };
  314. /* Per-TID aggregate receiver state for a node */
  315. struct ath_arx_tid {
  316. struct ath_node *an;
  317. struct ath_rxbuf *rxbuf; /* re-ordering buffer */
  318. struct timer_list timer;
  319. spinlock_t tidlock;
  320. int baw_head; /* seq_next at head */
  321. int baw_tail; /* tail of block-ack window */
  322. int seq_reset; /* need to reset start sequence */
  323. int addba_exchangecomplete;
  324. u16 seq_next; /* next expected sequence */
  325. u16 baw_size; /* block-ack window size */
  326. };
  327. /* Per-node receiver aggregate state */
  328. struct ath_arx {
  329. struct ath_arx_tid tid[WME_NUM_TID];
  330. };
  331. int ath_startrecv(struct ath_softc *sc);
  332. bool ath_stoprecv(struct ath_softc *sc);
  333. void ath_flushrecv(struct ath_softc *sc);
  334. u32 ath_calcrxfilter(struct ath_softc *sc);
  335. void ath_rx_node_init(struct ath_softc *sc, struct ath_node *an);
  336. void ath_rx_node_free(struct ath_softc *sc, struct ath_node *an);
  337. void ath_rx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
  338. void ath_handle_rx_intr(struct ath_softc *sc);
  339. int ath_rx_init(struct ath_softc *sc, int nbufs);
  340. void ath_rx_cleanup(struct ath_softc *sc);
  341. int ath_rx_tasklet(struct ath_softc *sc, int flush);
  342. int ath_rx_input(struct ath_softc *sc,
  343. struct ath_node *node,
  344. int is_ampdu,
  345. struct sk_buff *skb,
  346. struct ath_recv_status *rx_status,
  347. enum ATH_RX_TYPE *status);
  348. int ath__rx_indicate(struct ath_softc *sc,
  349. struct sk_buff *skb,
  350. struct ath_recv_status *status,
  351. u16 keyix);
  352. int ath_rx_subframe(struct ath_node *an, struct sk_buff *skb,
  353. struct ath_recv_status *status);
  354. /******/
  355. /* TX */
  356. /******/
  357. #define ATH_FRAG_PER_MSDU 1
  358. #define ATH_TXBUF (512/ATH_FRAG_PER_MSDU)
  359. /* max number of transmit attempts (tries) */
  360. #define ATH_TXMAXTRY 13
  361. /* max number of 11n transmit attempts (tries) */
  362. #define ATH_11N_TXMAXTRY 10
  363. /* max number of tries for management and control frames */
  364. #define ATH_MGT_TXMAXTRY 4
  365. #define WME_BA_BMP_SIZE 64
  366. #define WME_MAX_BA WME_BA_BMP_SIZE
  367. #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA)
  368. #define TID_TO_WME_AC(_tid) \
  369. ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
  370. (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
  371. (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
  372. WME_AC_VO)
  373. /* Wireless Multimedia Extension Defines */
  374. #define WME_AC_BE 0 /* best effort */
  375. #define WME_AC_BK 1 /* background */
  376. #define WME_AC_VI 2 /* video */
  377. #define WME_AC_VO 3 /* voice */
  378. #define WME_NUM_AC 4
  379. enum ATH_SM_PWRSAV{
  380. ATH_SM_ENABLE,
  381. ATH_SM_PWRSAV_STATIC,
  382. ATH_SM_PWRSAV_DYNAMIC,
  383. };
  384. /*
  385. * Data transmit queue state. One of these exists for each
  386. * hardware transmit queue. Packets sent to us from above
  387. * are assigned to queues based on their priority. Not all
  388. * devices support a complete set of hardware transmit queues.
  389. * For those devices the array sc_ac2q will map multiple
  390. * priorities to fewer hardware queues (typically all to one
  391. * hardware queue).
  392. */
  393. struct ath_txq {
  394. u32 axq_qnum; /* hardware q number */
  395. u32 *axq_link; /* link ptr in last TX desc */
  396. struct list_head axq_q; /* transmit queue */
  397. spinlock_t axq_lock;
  398. unsigned long axq_lockflags; /* intr state when must cli */
  399. u32 axq_depth; /* queue depth */
  400. u8 axq_aggr_depth; /* aggregates queued */
  401. u32 axq_totalqueued; /* total ever queued */
  402. /* count to determine if descriptor should generate int on this txq. */
  403. u32 axq_intrcnt;
  404. bool stopped; /* Is mac80211 queue stopped ? */
  405. struct ath_buf *axq_linkbuf; /* virtual addr of last buffer*/
  406. /* first desc of the last descriptor that contains CTS */
  407. struct ath_desc *axq_lastdsWithCTS;
  408. /* final desc of the gating desc that determines whether
  409. lastdsWithCTS has been DMA'ed or not */
  410. struct ath_desc *axq_gatingds;
  411. struct list_head axq_acq;
  412. };
  413. /* per TID aggregate tx state for a destination */
  414. struct ath_atx_tid {
  415. struct list_head list; /* round-robin tid entry */
  416. struct list_head buf_q; /* pending buffers */
  417. struct ath_node *an;
  418. struct ath_atx_ac *ac;
  419. struct ath_buf *tx_buf[ATH_TID_MAX_BUFS]; /* active tx frames */
  420. u16 seq_start;
  421. u16 seq_next;
  422. u16 baw_size;
  423. int tidno;
  424. int baw_head; /* first un-acked tx buffer */
  425. int baw_tail; /* next unused tx buffer slot */
  426. int sched;
  427. int paused;
  428. int cleanup_inprogress;
  429. u32 addba_exchangecomplete:1;
  430. int32_t addba_exchangeinprogress;
  431. int addba_exchangeattempts;
  432. };
  433. /* per access-category aggregate tx state for a destination */
  434. struct ath_atx_ac {
  435. int sched; /* dest-ac is scheduled */
  436. int qnum; /* H/W queue number associated
  437. with this AC */
  438. struct list_head list; /* round-robin txq entry */
  439. struct list_head tid_q; /* queue of TIDs with buffers */
  440. };
  441. /* per dest tx state */
  442. struct ath_atx {
  443. struct ath_atx_tid tid[WME_NUM_TID];
  444. struct ath_atx_ac ac[WME_NUM_AC];
  445. };
  446. /* per-frame tx control block */
  447. struct ath_tx_control {
  448. struct ath_node *an;
  449. int if_id;
  450. int qnum;
  451. u32 ht:1;
  452. u32 ps:1;
  453. u32 use_minrate:1;
  454. enum ath9k_pkt_type atype;
  455. enum ath9k_key_type keytype;
  456. u32 flags;
  457. u16 seqno;
  458. u16 tidno;
  459. u16 txpower;
  460. u16 frmlen;
  461. u32 keyix;
  462. int min_rate;
  463. int mcast_rate;
  464. u16 nextfraglen;
  465. struct ath_softc *dev;
  466. dma_addr_t dmacontext;
  467. };
  468. /* per frame tx status block */
  469. struct ath_xmit_status {
  470. int retries; /* number of retries to successufully
  471. transmit this frame */
  472. int flags; /* status of transmit */
  473. #define ATH_TX_ERROR 0x01
  474. #define ATH_TX_XRETRY 0x02
  475. #define ATH_TX_BAR 0x04
  476. };
  477. struct ath_tx_stat {
  478. int rssi; /* RSSI (noise floor ajusted) */
  479. int rssictl[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  480. int rssiextn[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  481. int rateieee; /* data rate xmitted (IEEE rate code) */
  482. int rateKbps; /* data rate xmitted (Kbps) */
  483. int ratecode; /* phy rate code */
  484. int flags; /* validity flags */
  485. /* if any of ctl,extn chain rssis are valid */
  486. #define ATH_TX_CHAIN_RSSI_VALID 0x01
  487. /* if extn chain rssis are valid */
  488. #define ATH_TX_RSSI_EXTN_VALID 0x02
  489. u32 airtime; /* time on air per final tx rate */
  490. };
  491. struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
  492. void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
  493. int ath_tx_setup(struct ath_softc *sc, int haltype);
  494. void ath_draintxq(struct ath_softc *sc, bool retry_tx);
  495. void ath_tx_draintxq(struct ath_softc *sc,
  496. struct ath_txq *txq, bool retry_tx);
  497. void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
  498. void ath_tx_node_cleanup(struct ath_softc *sc,
  499. struct ath_node *an, bool bh_flag);
  500. void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an);
  501. void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
  502. int ath_tx_init(struct ath_softc *sc, int nbufs);
  503. int ath_tx_cleanup(struct ath_softc *sc);
  504. int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype);
  505. int ath_txq_update(struct ath_softc *sc, int qnum,
  506. struct ath9k_tx_queue_info *q);
  507. int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb);
  508. void ath_tx_tasklet(struct ath_softc *sc);
  509. u32 ath_txq_depth(struct ath_softc *sc, int qnum);
  510. u32 ath_txq_aggr_depth(struct ath_softc *sc, int qnum);
  511. void ath_notify_txq_status(struct ath_softc *sc, u16 queue_depth);
  512. void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
  513. struct ath_xmit_status *tx_status, struct ath_node *an);
  514. /**********************/
  515. /* Node / Aggregation */
  516. /**********************/
  517. /* indicates the node is clened up */
  518. #define ATH_NODE_CLEAN 0x1
  519. /* indicates the node is 80211 power save */
  520. #define ATH_NODE_PWRSAVE 0x2
  521. #define ADDBA_TIMEOUT 200 /* 200 milliseconds */
  522. #define ADDBA_EXCHANGE_ATTEMPTS 10
  523. #define ATH_AGGR_DELIM_SZ 4 /* delimiter size */
  524. #define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */
  525. /* number of delimiters for encryption padding */
  526. #define ATH_AGGR_ENCRYPTDELIM 10
  527. /* minimum h/w qdepth to be sustained to maximize aggregation */
  528. #define ATH_AGGR_MIN_QDEPTH 2
  529. #define ATH_AMPDU_SUBFRAME_DEFAULT 32
  530. #define IEEE80211_SEQ_SEQ_SHIFT 4
  531. #define IEEE80211_SEQ_MAX 4096
  532. #define IEEE80211_MIN_AMPDU_BUF 0x8
  533. /* return whether a bit at index _n in bitmap _bm is set
  534. * _sz is the size of the bitmap */
  535. #define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \
  536. ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
  537. /* return block-ack bitmap index given sequence and starting sequence */
  538. #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
  539. /* returns delimiter padding required given the packet length */
  540. #define ATH_AGGR_GET_NDELIM(_len) \
  541. (((((_len) + ATH_AGGR_DELIM_SZ) < ATH_AGGR_MINPLEN) ? \
  542. (ATH_AGGR_MINPLEN - (_len) - ATH_AGGR_DELIM_SZ) : 0) >> 2)
  543. #define BAW_WITHIN(_start, _bawsz, _seqno) \
  544. ((((_seqno) - (_start)) & 4095) < (_bawsz))
  545. #define ATH_DS_BA_SEQ(_ds) ((_ds)->ds_us.tx.ts_seqnum)
  546. #define ATH_DS_BA_BITMAP(_ds) (&(_ds)->ds_us.tx.ba_low)
  547. #define ATH_DS_TX_BA(_ds) ((_ds)->ds_us.tx.ts_flags & ATH9K_TX_BA)
  548. #define ATH_AN_2_TID(_an, _tidno) (&(_an)->an_aggr.tx.tid[(_tidno)])
  549. enum ATH_AGGR_STATUS {
  550. ATH_AGGR_DONE,
  551. ATH_AGGR_BAW_CLOSED,
  552. ATH_AGGR_LIMITED,
  553. ATH_AGGR_SHORTPKT,
  554. ATH_AGGR_8K_LIMITED,
  555. };
  556. enum ATH_AGGR_CHECK {
  557. AGGR_NOT_REQUIRED,
  558. AGGR_REQUIRED,
  559. AGGR_CLEANUP_PROGRESS,
  560. AGGR_EXCHANGE_PROGRESS,
  561. AGGR_EXCHANGE_DONE
  562. };
  563. struct aggr_rifs_param {
  564. int param_max_frames;
  565. int param_max_len;
  566. int param_rl;
  567. int param_al;
  568. struct ath_rc_series *param_rcs;
  569. };
  570. /* Per-node aggregation state */
  571. struct ath_node_aggr {
  572. struct ath_atx tx; /* node transmit state */
  573. struct ath_arx rx; /* node receive state */
  574. };
  575. /* driver-specific node state */
  576. struct ath_node {
  577. struct list_head list;
  578. struct ath_softc *an_sc;
  579. atomic_t an_refcnt;
  580. struct ath_chainmask_sel an_chainmask_sel;
  581. struct ath_node_aggr an_aggr;
  582. u8 an_smmode; /* SM Power save mode */
  583. u8 an_flags;
  584. u8 an_addr[ETH_ALEN];
  585. };
  586. void ath_tx_resume_tid(struct ath_softc *sc,
  587. struct ath_atx_tid *tid);
  588. enum ATH_AGGR_CHECK ath_tx_aggr_check(struct ath_softc *sc,
  589. struct ath_node *an, u8 tidno);
  590. void ath_tx_aggr_teardown(struct ath_softc *sc,
  591. struct ath_node *an, u8 tidno);
  592. void ath_rx_aggr_teardown(struct ath_softc *sc,
  593. struct ath_node *an, u8 tidno);
  594. int ath_rx_aggr_start(struct ath_softc *sc,
  595. const u8 *addr,
  596. u16 tid,
  597. u16 *ssn);
  598. int ath_rx_aggr_stop(struct ath_softc *sc,
  599. const u8 *addr,
  600. u16 tid);
  601. int ath_tx_aggr_start(struct ath_softc *sc,
  602. const u8 *addr,
  603. u16 tid,
  604. u16 *ssn);
  605. int ath_tx_aggr_stop(struct ath_softc *sc,
  606. const u8 *addr,
  607. u16 tid);
  608. void ath_newassoc(struct ath_softc *sc,
  609. struct ath_node *node, int isnew, int isuapsd);
  610. struct ath_node *ath_node_attach(struct ath_softc *sc,
  611. u8 addr[ETH_ALEN], int if_id);
  612. void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
  613. struct ath_node *ath_node_get(struct ath_softc *sc, u8 addr[ETH_ALEN]);
  614. void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
  615. struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr);
  616. /*******************/
  617. /* Beacon Handling */
  618. /*******************/
  619. /*
  620. * Regardless of the number of beacons we stagger, (i.e. regardless of the
  621. * number of BSSIDs) if a given beacon does not go out even after waiting this
  622. * number of beacon intervals, the game's up.
  623. */
  624. #define BSTUCK_THRESH (9 * ATH_BCBUF)
  625. #define ATH_BCBUF 4 /* number of beacon buffers */
  626. #define ATH_DEFAULT_BINTVAL 100 /* default beacon interval in TU */
  627. #define ATH_DEFAULT_BMISS_LIMIT 10
  628. #define ATH_BEACON_AIFS_DEFAULT 0 /* Default aifs for ap beacon q */
  629. #define ATH_BEACON_CWMIN_DEFAULT 0 /* Default cwmin for ap beacon q */
  630. #define ATH_BEACON_CWMAX_DEFAULT 0 /* Default cwmax for ap beacon q */
  631. #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
  632. /* beacon configuration */
  633. struct ath_beacon_config {
  634. u16 beacon_interval;
  635. u16 listen_interval;
  636. u16 dtim_period;
  637. u16 bmiss_timeout;
  638. u8 dtim_count;
  639. u8 tim_offset;
  640. union {
  641. u64 last_tsf;
  642. u8 last_tstamp[8];
  643. } u; /* last received beacon/probe response timestamp of this BSS. */
  644. };
  645. /* offsets in a beacon frame for
  646. * quick acess of beacon content by low-level driver */
  647. struct ath_beacon_offset {
  648. u8 *bo_tim; /* start of atim/dtim */
  649. };
  650. void ath9k_beacon_tasklet(unsigned long data);
  651. void ath_beacon_config(struct ath_softc *sc, int if_id);
  652. int ath_beaconq_setup(struct ath_hal *ah);
  653. int ath_beacon_alloc(struct ath_softc *sc, int if_id);
  654. void ath_bstuck_process(struct ath_softc *sc);
  655. void ath_beacon_tasklet(struct ath_softc *sc, int *needmark);
  656. void ath_beacon_free(struct ath_softc *sc);
  657. void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp);
  658. void ath_beacon_sync(struct ath_softc *sc, int if_id);
  659. void ath_update_beacon_info(struct ath_softc *sc, int avgbrssi);
  660. void ath_get_beaconconfig(struct ath_softc *sc,
  661. int if_id,
  662. struct ath_beacon_config *conf);
  663. int ath_update_beacon(struct ath_softc *sc,
  664. int if_id,
  665. struct ath_beacon_offset *bo,
  666. struct sk_buff *skb,
  667. int mcast);
  668. /********/
  669. /* VAPs */
  670. /********/
  671. /*
  672. * Define the scheme that we select MAC address for multiple
  673. * BSS on the same radio. The very first VAP will just use the MAC
  674. * address from the EEPROM. For the next 3 VAPs, we set the
  675. * U/L bit (bit 1) in MAC address, and use the next two bits as the
  676. * index of the VAP.
  677. */
  678. #define ATH_SET_VAP_BSSID_MASK(bssid_mask) \
  679. ((bssid_mask)[0] &= ~(((ATH_BCBUF-1)<<2)|0x02))
  680. /* VAP configuration (from protocol layer) */
  681. struct ath_vap_config {
  682. u32 av_fixed_rateset;
  683. u32 av_fixed_retryset;
  684. };
  685. /* driver-specific vap state */
  686. struct ath_vap {
  687. struct ieee80211_vif *av_if_data;
  688. enum ath9k_opmode av_opmode; /* VAP operational mode */
  689. struct ath_buf *av_bcbuf; /* beacon buffer */
  690. struct ath_beacon_offset av_boff; /* dynamic update state */
  691. struct ath_tx_control av_btxctl; /* txctl information for beacon */
  692. int av_bslot; /* beacon slot index */
  693. struct ath_txq av_mcastq; /* multicast transmit queue */
  694. struct ath_vap_config av_config;/* vap configuration parameters*/
  695. struct ath_rate_node *rc_node;
  696. };
  697. int ath_vap_attach(struct ath_softc *sc,
  698. int if_id,
  699. struct ieee80211_vif *if_data,
  700. enum ath9k_opmode opmode);
  701. int ath_vap_detach(struct ath_softc *sc, int if_id);
  702. int ath_vap_config(struct ath_softc *sc,
  703. int if_id, struct ath_vap_config *if_config);
  704. int ath_vap_listen(struct ath_softc *sc, int if_id);
  705. /*********************/
  706. /* Antenna diversity */
  707. /*********************/
  708. #define ATH_ANT_DIV_MAX_CFG 2
  709. #define ATH_ANT_DIV_MIN_IDLE_US 1000000 /* us */
  710. #define ATH_ANT_DIV_MIN_SCAN_US 50000 /* us */
  711. enum ATH_ANT_DIV_STATE{
  712. ATH_ANT_DIV_IDLE,
  713. ATH_ANT_DIV_SCAN, /* evaluating antenna */
  714. };
  715. struct ath_antdiv {
  716. struct ath_softc *antdiv_sc;
  717. u8 antdiv_start;
  718. enum ATH_ANT_DIV_STATE antdiv_state;
  719. u8 antdiv_num_antcfg;
  720. u8 antdiv_curcfg;
  721. u8 antdiv_bestcfg;
  722. int32_t antdivf_rssitrig;
  723. int32_t antdiv_lastbrssi[ATH_ANT_DIV_MAX_CFG];
  724. u64 antdiv_lastbtsf[ATH_ANT_DIV_MAX_CFG];
  725. u64 antdiv_laststatetsf;
  726. u8 antdiv_bssid[ETH_ALEN];
  727. };
  728. void ath_slow_ant_div_init(struct ath_antdiv *antdiv,
  729. struct ath_softc *sc, int32_t rssitrig);
  730. void ath_slow_ant_div_start(struct ath_antdiv *antdiv,
  731. u8 num_antcfg,
  732. const u8 *bssid);
  733. void ath_slow_ant_div_stop(struct ath_antdiv *antdiv);
  734. void ath_slow_ant_div(struct ath_antdiv *antdiv,
  735. struct ieee80211_hdr *wh,
  736. struct ath_rx_status *rx_stats);
  737. void ath_setdefantenna(void *sc, u32 antenna);
  738. /********************/
  739. /* Main driver core */
  740. /********************/
  741. /*
  742. * Default cache line size, in bytes.
  743. * Used when PCI device not fully initialized by bootrom/BIOS
  744. */
  745. #define DEFAULT_CACHELINE 32
  746. #define ATH_DEFAULT_NOISE_FLOOR -95
  747. #define ATH_REGCLASSIDS_MAX 10
  748. #define ATH_CABQ_READY_TIME 80 /* % of beacon interval */
  749. #define ATH_PREAMBLE_SHORT (1<<0)
  750. #define ATH_PROTECT_ENABLE (1<<1)
  751. #define ATH_MAX_SW_RETRIES 10
  752. /* Num farmes difference in tx to flip default recv */
  753. #define ATH_ANTENNA_DIFF 2
  754. #define ATH_CHAN_MAX 255
  755. #define IEEE80211_WEP_NKID 4 /* number of key ids */
  756. #define IEEE80211_RATE_VAL 0x7f
  757. /*
  758. * The key cache is used for h/w cipher state and also for
  759. * tracking station state such as the current tx antenna.
  760. * We also setup a mapping table between key cache slot indices
  761. * and station state to short-circuit node lookups on rx.
  762. * Different parts have different size key caches. We handle
  763. * up to ATH_KEYMAX entries (could dynamically allocate state).
  764. */
  765. #define ATH_KEYMAX 128 /* max key cache size we handle */
  766. #define RESET_RETRY_TXQ 0x00000001
  767. #define ATH_IF_ID_ANY 0xff
  768. #define ATH_TXPOWER_MAX 100 /* .5 dBm units */
  769. #define RSSI_LPF_THRESHOLD -20
  770. #define ATH_RSSI_EP_MULTIPLIER (1<<7) /* pow2 to optimize out * and / */
  771. #define ATH_RATE_DUMMY_MARKER 0
  772. #define ATH_RSSI_LPF_LEN 10
  773. #define ATH_RSSI_DUMMY_MARKER 0x127
  774. #define ATH_EP_MUL(x, mul) ((x) * (mul))
  775. #define ATH_EP_RND(x, mul) \
  776. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  777. #define ATH_RSSI_OUT(x) \
  778. (((x) != ATH_RSSI_DUMMY_MARKER) ? \
  779. (ATH_EP_RND((x), ATH_RSSI_EP_MULTIPLIER)) : ATH_RSSI_DUMMY_MARKER)
  780. #define ATH_RSSI_IN(x) \
  781. (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
  782. #define ATH_LPF_RSSI(x, y, len) \
  783. ((x != ATH_RSSI_DUMMY_MARKER) ? \
  784. (((x) * ((len) - 1) + (y)) / (len)) : (y))
  785. #define ATH_RSSI_LPF(x, y) do { \
  786. if ((y) >= RSSI_LPF_THRESHOLD) \
  787. x = ATH_LPF_RSSI((x), \
  788. ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \
  789. } while (0)
  790. enum PROT_MODE {
  791. PROT_M_NONE = 0,
  792. PROT_M_RTSCTS,
  793. PROT_M_CTSONLY
  794. };
  795. enum RATE_TYPE {
  796. NORMAL_RATE = 0,
  797. HALF_RATE,
  798. QUARTER_RATE
  799. };
  800. struct ath_ht_info {
  801. enum ath9k_ht_macmode tx_chan_width;
  802. u16 maxampdu;
  803. u8 mpdudensity;
  804. u8 ext_chan_offset;
  805. };
  806. struct ath_softc {
  807. struct ieee80211_hw *hw;
  808. struct pci_dev *pdev;
  809. void __iomem *mem;
  810. struct tasklet_struct intr_tq;
  811. struct tasklet_struct bcon_tasklet;
  812. struct ath_config sc_config; /* load-time parameters */
  813. int sc_debug;
  814. struct ath_hal *sc_ah;
  815. struct ath_rate_softc *sc_rc; /* tx rate control support */
  816. u32 sc_intrstatus;
  817. enum ath9k_opmode sc_opmode; /* current operating mode */
  818. u8 sc_invalid; /* being detached */
  819. u8 sc_beacons; /* beacons running */
  820. u8 sc_scanning; /* scanning active */
  821. u8 sc_txaggr; /* enable 11n tx aggregation */
  822. u8 sc_rxaggr; /* enable 11n rx aggregation */
  823. u8 sc_update_chainmask; /* change chain mask */
  824. u8 sc_full_reset; /* force full reset */
  825. enum wireless_mode sc_curmode; /* current phy mode */
  826. u16 sc_curtxpow;
  827. u16 sc_curaid;
  828. u8 sc_curbssid[ETH_ALEN];
  829. u8 sc_myaddr[ETH_ALEN];
  830. enum PROT_MODE sc_protmode;
  831. u8 sc_mcastantenna;
  832. u8 sc_txantenna; /* data tx antenna (fixed or auto) */
  833. u8 sc_nbcnvaps; /* # of vaps sending beacons */
  834. u16 sc_nvaps; /* # of active virtual ap's */
  835. struct ath_vap *sc_vaps[ATH_BCBUF];
  836. enum ath9k_int sc_imask;
  837. u8 sc_bssidmask[ETH_ALEN];
  838. u8 sc_defant; /* current default antenna */
  839. u8 sc_rxotherant; /* rx's on non-default antenna */
  840. u16 sc_cachelsz;
  841. int sc_slotupdate; /* slot to next advance fsm */
  842. int sc_slottime;
  843. u8 sc_noreset;
  844. int sc_bslot[ATH_BCBUF];
  845. struct ath9k_node_stats sc_halstats; /* station-mode rssi stats */
  846. struct list_head node_list;
  847. struct ath_ht_info sc_ht_info;
  848. int16_t sc_noise_floor; /* signal noise floor in dBm */
  849. enum ath9k_ht_extprotspacing sc_ht_extprotspacing;
  850. u8 sc_tx_chainmask;
  851. u8 sc_rx_chainmask;
  852. u8 sc_rxchaindetect_ref;
  853. u8 sc_rxchaindetect_thresh5GHz;
  854. u8 sc_rxchaindetect_thresh2GHz;
  855. u8 sc_rxchaindetect_delta5GHz;
  856. u8 sc_rxchaindetect_delta2GHz;
  857. u32 sc_rtsaggrlimit; /* Chipset specific aggr limit */
  858. u32 sc_flags;
  859. #ifdef CONFIG_SLOW_ANT_DIV
  860. struct ath_antdiv sc_antdiv;
  861. #endif
  862. enum {
  863. OK, /* no change needed */
  864. UPDATE, /* update pending */
  865. COMMIT /* beacon sent, commit change */
  866. } sc_updateslot; /* slot time update fsm */
  867. /* Crypto */
  868. u32 sc_keymax; /* size of key cache */
  869. DECLARE_BITMAP(sc_keymap, ATH_KEYMAX); /* key use bit map */
  870. u8 sc_splitmic; /* split TKIP MIC keys */
  871. int sc_keytype;
  872. /* RX */
  873. struct list_head sc_rxbuf;
  874. struct ath_descdma sc_rxdma;
  875. int sc_rxbufsize; /* rx size based on mtu */
  876. u32 *sc_rxlink; /* link ptr in last RX desc */
  877. u32 sc_rxflush; /* rx flush in progress */
  878. u64 sc_lastrx; /* tsf of last rx'd frame */
  879. /* TX */
  880. struct list_head sc_txbuf;
  881. struct ath_txq sc_txq[ATH9K_NUM_TX_QUEUES];
  882. struct ath_descdma sc_txdma;
  883. u32 sc_txqsetup;
  884. u32 sc_txintrperiod; /* tx interrupt batching */
  885. int sc_haltype2q[ATH9K_WME_AC_VO+1]; /* HAL WME AC -> h/w qnum */
  886. u32 sc_ant_tx[8]; /* recent tx frames/antenna */
  887. /* Beacon */
  888. struct ath9k_tx_queue_info sc_beacon_qi;
  889. struct ath_descdma sc_bdma;
  890. struct ath_txq *sc_cabq;
  891. struct list_head sc_bbuf;
  892. u32 sc_bhalq;
  893. u32 sc_bmisscount;
  894. u32 ast_be_xmit; /* beacons transmitted */
  895. /* Rate */
  896. struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
  897. const struct ath9k_rate_table *sc_currates;
  898. u8 sc_rixmap[256]; /* IEEE to h/w rate table ix */
  899. u8 sc_protrix; /* protection rate index */
  900. struct {
  901. u32 rateKbps; /* transfer rate in kbs */
  902. u8 ieeerate; /* IEEE rate */
  903. } sc_hwmap[256]; /* h/w rate ix mappings */
  904. /* Channel, Band */
  905. struct ieee80211_channel channels[IEEE80211_NUM_BANDS][ATH_CHAN_MAX];
  906. struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
  907. struct ath9k_channel sc_curchan;
  908. /* Locks */
  909. spinlock_t sc_rxflushlock;
  910. spinlock_t sc_rxbuflock;
  911. spinlock_t sc_txbuflock;
  912. spinlock_t sc_resetlock;
  913. spinlock_t node_lock;
  914. };
  915. int ath_init(u16 devid, struct ath_softc *sc);
  916. void ath_deinit(struct ath_softc *sc);
  917. int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan);
  918. int ath_suspend(struct ath_softc *sc);
  919. irqreturn_t ath_isr(int irq, void *dev);
  920. int ath_reset(struct ath_softc *sc);
  921. void ath_scan_start(struct ath_softc *sc);
  922. void ath_scan_end(struct ath_softc *sc);
  923. int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan);
  924. void ath_setup_rate(struct ath_softc *sc,
  925. enum wireless_mode wMode,
  926. enum RATE_TYPE type,
  927. const struct ath9k_rate_table *rt);
  928. /*********************/
  929. /* Utility Functions */
  930. /*********************/
  931. void ath_key_reset(struct ath_softc *sc, u16 keyix, int freeslot);
  932. int ath_keyset(struct ath_softc *sc,
  933. u16 keyix,
  934. struct ath9k_keyval *hk,
  935. const u8 mac[ETH_ALEN]);
  936. int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
  937. int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
  938. void ath_setslottime(struct ath_softc *sc);
  939. void ath_update_txpow(struct ath_softc *sc);
  940. int ath_cabq_update(struct ath_softc *);
  941. void ath_get_currentCountry(struct ath_softc *sc,
  942. struct ath9k_country_entry *ctry);
  943. u64 ath_extend_tsf(struct ath_softc *sc, u32 rstamp);
  944. void ath_internal_reset(struct ath_softc *sc);
  945. u32 ath_chan2flags(struct ieee80211_channel *chan, struct ath_softc *sc);
  946. dma_addr_t ath_skb_map_single(struct ath_softc *sc,
  947. struct sk_buff *skb,
  948. int direction,
  949. dma_addr_t *pa);
  950. void ath_skb_unmap_single(struct ath_softc *sc,
  951. struct sk_buff *skb,
  952. int direction,
  953. dma_addr_t *pa);
  954. void ath_mcast_merge(struct ath_softc *sc, u32 mfilt[2]);
  955. enum ath9k_ht_macmode ath_cwm_macmode(struct ath_softc *sc);
  956. #endif /* CORE_H */