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