core.h 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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
  122. 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; /* buffer */
  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; /* parent ath node */
  318. struct ath_rxbuf *rxbuf; /* re-ordering buffer */
  319. struct timer_list timer;
  320. spinlock_t tidlock; /* lock to protect this TID structure */
  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; /* lock on q and link */
  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. u32 axq_intrcnt; /* count to determine
  404. if descriptor should generate
  405. int on this txq. */
  406. bool stopped; /* Is mac80211 queue
  407. stopped ? */
  408. /* State for patching up CTS when bursting */
  409. struct ath_buf *axq_linkbuf; /* virtual addr of last buffer*/
  410. struct ath_desc *axq_lastdsWithCTS; /* first desc of the
  411. last descriptor that contains CTS */
  412. struct ath_desc *axq_gatingds; /* final desc of the gating desc
  413. * that determines whether lastdsWithCTS has
  414. * been DMA'ed or not */
  415. struct list_head axq_acq;
  416. };
  417. /* per TID aggregate tx state for a destination */
  418. struct ath_atx_tid {
  419. struct list_head list; /* round-robin tid entry */
  420. struct list_head buf_q; /* pending buffers */
  421. struct ath_node *an; /* parent node structure */
  422. struct ath_atx_ac *ac; /* parent access category */
  423. struct ath_buf *tx_buf[ATH_TID_MAX_BUFS];/* active tx frames */
  424. u16 seq_start; /* starting seq of BA window */
  425. u16 seq_next; /* next seq to be used */
  426. u16 baw_size; /* BA window size */
  427. int tidno; /* TID number */
  428. int baw_head; /* first un-acked tx buffer */
  429. int baw_tail; /* next unused tx buffer slot */
  430. int sched; /* TID is scheduled */
  431. int paused; /* TID is paused */
  432. int cleanup_inprogress; /* aggr of this TID is
  433. being teared down */
  434. u32 addba_exchangecomplete:1; /* ADDBA state */
  435. int32_t addba_exchangeinprogress;
  436. int addba_exchangeattempts;
  437. };
  438. /* per access-category aggregate tx state for a destination */
  439. struct ath_atx_ac {
  440. int sched; /* dest-ac is scheduled */
  441. int qnum; /* H/W queue number associated
  442. with this AC */
  443. struct list_head list; /* round-robin txq entry */
  444. struct list_head tid_q; /* queue of TIDs with buffers */
  445. };
  446. /* per dest tx state */
  447. struct ath_atx {
  448. struct ath_atx_tid tid[WME_NUM_TID];
  449. struct ath_atx_ac ac[WME_NUM_AC];
  450. };
  451. /* per-frame tx control block */
  452. struct ath_tx_control {
  453. struct ath_node *an; /* destination to sent to */
  454. int if_id; /* only valid for cab traffic */
  455. int qnum; /* h/w queue number */
  456. u32 ht:1; /* if it can be transmitted using HT */
  457. u32 ps:1; /* if one or more stations are in PS mode */
  458. u32 use_minrate:1; /* if this frame should transmitted using
  459. minimum rate */
  460. enum ath9k_pkt_type atype; /* Atheros packet type */
  461. enum ath9k_key_type keytype; /* key type */
  462. u32 flags; /* HAL flags */
  463. u16 seqno; /* sequence number */
  464. u16 tidno; /* tid number */
  465. u16 txpower; /* transmit power */
  466. u16 frmlen; /* frame length */
  467. u32 keyix; /* key index */
  468. int min_rate; /* minimum rate */
  469. int mcast_rate; /* multicast rate */
  470. u16 nextfraglen; /* next fragment length */
  471. /* below is set only by ath_dev */
  472. struct ath_softc *dev; /* device handle */
  473. dma_addr_t dmacontext;
  474. };
  475. /* per frame tx status block */
  476. struct ath_xmit_status {
  477. int retries; /* number of retries to successufully
  478. transmit this frame */
  479. int flags; /* status of transmit */
  480. #define ATH_TX_ERROR 0x01
  481. #define ATH_TX_XRETRY 0x02
  482. #define ATH_TX_BAR 0x04
  483. };
  484. struct ath_tx_stat {
  485. int rssi; /* RSSI (noise floor ajusted) */
  486. int rssictl[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  487. int rssiextn[ATH_MAX_ANTENNA]; /* RSSI (noise floor ajusted) */
  488. int rateieee; /* data rate xmitted (IEEE rate code) */
  489. int rateKbps; /* data rate xmitted (Kbps) */
  490. int ratecode; /* phy rate code */
  491. int flags; /* validity flags */
  492. /* if any of ctl,extn chain rssis are valid */
  493. #define ATH_TX_CHAIN_RSSI_VALID 0x01
  494. /* if extn chain rssis are valid */
  495. #define ATH_TX_RSSI_EXTN_VALID 0x02
  496. u32 airtime; /* time on air per final tx rate */
  497. };
  498. struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
  499. void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
  500. int ath_tx_setup(struct ath_softc *sc, int haltype);
  501. void ath_draintxq(struct ath_softc *sc, bool retry_tx);
  502. void ath_tx_draintxq(struct ath_softc *sc,
  503. struct ath_txq *txq, bool retry_tx);
  504. void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
  505. void ath_tx_node_cleanup(struct ath_softc *sc,
  506. struct ath_node *an, bool bh_flag);
  507. void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an);
  508. void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
  509. int ath_tx_init(struct ath_softc *sc, int nbufs);
  510. int ath_tx_cleanup(struct ath_softc *sc);
  511. int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype);
  512. int ath_txq_update(struct ath_softc *sc, int qnum, struct ath9k_txq_info *q);
  513. int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb);
  514. void ath_tx_tasklet(struct ath_softc *sc);
  515. u32 ath_txq_depth(struct ath_softc *sc, int qnum);
  516. u32 ath_txq_aggr_depth(struct ath_softc *sc, int qnum);
  517. void ath_notify_txq_status(struct ath_softc *sc, u16 queue_depth);
  518. void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
  519. struct ath_xmit_status *tx_status, struct ath_node *an);
  520. /**********************/
  521. /* Node / Aggregation */
  522. /**********************/
  523. /* indicates the node is clened up */
  524. #define ATH_NODE_CLEAN 0x1
  525. /* indicates the node is 80211 power save */
  526. #define ATH_NODE_PWRSAVE 0x2
  527. #define ADDBA_TIMEOUT 200 /* 200 milliseconds */
  528. #define ADDBA_EXCHANGE_ATTEMPTS 10
  529. #define ATH_AGGR_DELIM_SZ 4 /* delimiter size */
  530. #define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */
  531. /* number of delimiters for encryption padding */
  532. #define ATH_AGGR_ENCRYPTDELIM 10
  533. /* minimum h/w qdepth to be sustained to maximize aggregation */
  534. #define ATH_AGGR_MIN_QDEPTH 2
  535. #define ATH_AMPDU_SUBFRAME_DEFAULT 32
  536. #define IEEE80211_SEQ_SEQ_SHIFT 4
  537. #define IEEE80211_SEQ_MAX 4096
  538. #define IEEE80211_MIN_AMPDU_BUF 0x8
  539. /* return whether a bit at index _n in bitmap _bm is set
  540. * _sz is the size of the bitmap */
  541. #define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \
  542. ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
  543. /* return block-ack bitmap index given sequence and starting sequence */
  544. #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
  545. /* returns delimiter padding required given the packet length */
  546. #define ATH_AGGR_GET_NDELIM(_len) \
  547. (((((_len) + ATH_AGGR_DELIM_SZ) < ATH_AGGR_MINPLEN) ? \
  548. (ATH_AGGR_MINPLEN - (_len) - ATH_AGGR_DELIM_SZ) : 0) >> 2)
  549. #define BAW_WITHIN(_start, _bawsz, _seqno) \
  550. ((((_seqno) - (_start)) & 4095) < (_bawsz))
  551. #define ATH_DS_BA_SEQ(_ds) ((_ds)->ds_us.tx.ts_seqnum)
  552. #define ATH_DS_BA_BITMAP(_ds) (&(_ds)->ds_us.tx.ba_low)
  553. #define ATH_DS_TX_BA(_ds) ((_ds)->ds_us.tx.ts_flags & ATH9K_TX_BA)
  554. #define ATH_AN_2_TID(_an, _tidno) (&(_an)->an_aggr.tx.tid[(_tidno)])
  555. enum ATH_AGGR_STATUS {
  556. ATH_AGGR_DONE,
  557. ATH_AGGR_BAW_CLOSED,
  558. ATH_AGGR_LIMITED,
  559. ATH_AGGR_SHORTPKT,
  560. ATH_AGGR_8K_LIMITED,
  561. };
  562. enum ATH_AGGR_CHECK {
  563. AGGR_NOT_REQUIRED,
  564. AGGR_REQUIRED,
  565. AGGR_CLEANUP_PROGRESS,
  566. AGGR_EXCHANGE_PROGRESS,
  567. AGGR_EXCHANGE_DONE
  568. };
  569. struct aggr_rifs_param {
  570. int param_max_frames;
  571. int param_max_len;
  572. int param_rl;
  573. int param_al;
  574. struct ath_rc_series *param_rcs;
  575. };
  576. /* Per-node aggregation state */
  577. struct ath_node_aggr {
  578. struct ath_atx tx; /* node transmit state */
  579. struct ath_arx rx; /* node receive state */
  580. };
  581. /* driver-specific node state */
  582. struct ath_node {
  583. struct list_head list;
  584. struct ath_softc *an_sc; /* back pointer */
  585. atomic_t an_refcnt;
  586. struct ath_chainmask_sel an_chainmask_sel;
  587. struct ath_node_aggr an_aggr; /* A-MPDU aggregation state */
  588. u8 an_smmode; /* SM Power save mode */
  589. u8 an_flags;
  590. u8 an_addr[ETH_ALEN];
  591. };
  592. void ath_tx_resume_tid(struct ath_softc *sc,
  593. struct ath_atx_tid *tid);
  594. enum ATH_AGGR_CHECK ath_tx_aggr_check(struct ath_softc *sc,
  595. struct ath_node *an, u8 tidno);
  596. void ath_tx_aggr_teardown(struct ath_softc *sc,
  597. struct ath_node *an, u8 tidno);
  598. void ath_rx_aggr_teardown(struct ath_softc *sc,
  599. struct ath_node *an, u8 tidno);
  600. int ath_rx_aggr_start(struct ath_softc *sc,
  601. const u8 *addr,
  602. u16 tid,
  603. u16 *ssn);
  604. int ath_rx_aggr_stop(struct ath_softc *sc,
  605. const u8 *addr,
  606. u16 tid);
  607. int ath_tx_aggr_start(struct ath_softc *sc,
  608. const u8 *addr,
  609. u16 tid,
  610. u16 *ssn);
  611. int ath_tx_aggr_stop(struct ath_softc *sc,
  612. const u8 *addr,
  613. u16 tid);
  614. void ath_newassoc(struct ath_softc *sc,
  615. struct ath_node *node, int isnew, int isuapsd);
  616. struct ath_node *ath_node_attach(struct ath_softc *sc,
  617. u8 addr[ETH_ALEN], int if_id);
  618. void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
  619. struct ath_node *ath_node_get(struct ath_softc *sc, u8 addr[ETH_ALEN]);
  620. void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
  621. struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr);
  622. /*******************/
  623. /* Beacon Handling */
  624. /*******************/
  625. /*
  626. * Regardless of the number of beacons we stagger, (i.e. regardless of the
  627. * number of BSSIDs) if a given beacon does not go out even after waiting this
  628. * number of beacon intervals, the game's up.
  629. */
  630. #define BSTUCK_THRESH (9 * ATH_BCBUF)
  631. #define ATH_BCBUF 4 /* number of beacon buffers */
  632. #define ATH_DEFAULT_BINTVAL 100 /* default beacon interval in TU */
  633. #define ATH_DEFAULT_BMISS_LIMIT 10
  634. #define ATH_BEACON_AIFS_DEFAULT 0 /* Default aifs for ap beacon q */
  635. #define ATH_BEACON_CWMIN_DEFAULT 0 /* Default cwmin for ap beacon q */
  636. #define ATH_BEACON_CWMAX_DEFAULT 0 /* Default cwmax for ap beacon q */
  637. #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
  638. /* beacon configuration */
  639. struct ath_beacon_config {
  640. u16 beacon_interval;
  641. u16 listen_interval;
  642. u16 dtim_period;
  643. u16 bmiss_timeout;
  644. u8 dtim_count;
  645. u8 tim_offset;
  646. union {
  647. u64 last_tsf;
  648. u8 last_tstamp[8];
  649. } u; /* last received beacon/probe response timestamp of this BSS. */
  650. };
  651. /* offsets in a beacon frame for
  652. * quick acess of beacon content by low-level driver */
  653. struct ath_beacon_offset {
  654. u8 *bo_tim; /* start of atim/dtim */
  655. };
  656. void ath9k_beacon_tasklet(unsigned long data);
  657. void ath_beacon_config(struct ath_softc *sc, int if_id);
  658. int ath_beaconq_setup(struct ath_hal *ah);
  659. int ath_beacon_alloc(struct ath_softc *sc, int if_id);
  660. void ath_bstuck_process(struct ath_softc *sc);
  661. void ath_beacon_tasklet(struct ath_softc *sc, int *needmark);
  662. void ath_beacon_free(struct ath_softc *sc);
  663. void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp);
  664. void ath_beacon_sync(struct ath_softc *sc, int if_id);
  665. void ath_update_beacon_info(struct ath_softc *sc, int avgbrssi);
  666. void ath_get_beaconconfig(struct ath_softc *sc,
  667. int if_id,
  668. struct ath_beacon_config *conf);
  669. int ath_update_beacon(struct ath_softc *sc,
  670. int if_id,
  671. struct ath_beacon_offset *bo,
  672. struct sk_buff *skb,
  673. int mcast);
  674. /********/
  675. /* VAPs */
  676. /********/
  677. #define ATH_IF_HW_OFF 0x0001 /* hardware state needs to turn off */
  678. #define ATH_IF_HW_ON 0x0002 /* hardware state needs to turn on */
  679. /* STA only: the associated AP is HT capable */
  680. #define ATH_IF_HT 0x0004
  681. /* AP/IBSS only: current BSS has privacy on */
  682. #define ATH_IF_PRIVACY 0x0008
  683. #define ATH_IF_BEACON_ENABLE 0x0010 /* AP/IBSS only: enable beacon */
  684. #define ATH_IF_BEACON_SYNC 0x0020 /* IBSS only: need to sync beacon */
  685. /*
  686. * Define the scheme that we select MAC address for multiple
  687. * BSS on the same radio. The very first VAP will just use the MAC
  688. * address from the EEPROM. For the next 3 VAPs, we set the
  689. * U/L bit (bit 1) in MAC address, and use the next two bits as the
  690. * index of the VAP.
  691. */
  692. #define ATH_SET_VAP_BSSID_MASK(bssid_mask) \
  693. ((bssid_mask)[0] &= ~(((ATH_BCBUF-1)<<2)|0x02))
  694. /* VAP configuration (from protocol layer) */
  695. struct ath_vap_config {
  696. u32 av_fixed_rateset;
  697. u32 av_fixed_retryset;
  698. };
  699. /* driver-specific vap state */
  700. struct ath_vap {
  701. struct ieee80211_vif *av_if_data; /* interface(vap)
  702. instance from 802.11 protocal layer */
  703. enum ath9k_opmode av_opmode; /* VAP operational mode */
  704. struct ath_buf *av_bcbuf; /* beacon buffer */
  705. struct ath_beacon_offset av_boff; /* dynamic update state */
  706. struct ath_tx_control av_btxctl; /* tx control information
  707. for beacon */
  708. int av_bslot; /* beacon slot index */
  709. struct ath_txq av_mcastq; /* multicast
  710. transmit queue */
  711. struct ath_vap_config av_config; /* vap configuration
  712. parameters from 802.11 protocol layer*/
  713. struct ath_rate_node *rc_node;
  714. };
  715. int ath_vap_attach(struct ath_softc *sc,
  716. int if_id,
  717. struct ieee80211_vif *if_data,
  718. enum ath9k_opmode opmode);
  719. int ath_vap_detach(struct ath_softc *sc, int if_id);
  720. int ath_vap_config(struct ath_softc *sc,
  721. int if_id, struct ath_vap_config *if_config);
  722. int ath_vap_listen(struct ath_softc *sc, int if_id);
  723. /*********************/
  724. /* Antenna diversity */
  725. /*********************/
  726. #define ATH_ANT_DIV_MAX_CFG 2
  727. #define ATH_ANT_DIV_MIN_IDLE_US 1000000 /* us */
  728. #define ATH_ANT_DIV_MIN_SCAN_US 50000 /* us */
  729. enum ATH_ANT_DIV_STATE{
  730. ATH_ANT_DIV_IDLE,
  731. ATH_ANT_DIV_SCAN, /* evaluating antenna */
  732. };
  733. struct ath_antdiv {
  734. struct ath_softc *antdiv_sc;
  735. u8 antdiv_start;
  736. enum ATH_ANT_DIV_STATE antdiv_state;
  737. u8 antdiv_num_antcfg;
  738. u8 antdiv_curcfg;
  739. u8 antdiv_bestcfg;
  740. int32_t antdivf_rssitrig;
  741. int32_t antdiv_lastbrssi[ATH_ANT_DIV_MAX_CFG];
  742. u64 antdiv_lastbtsf[ATH_ANT_DIV_MAX_CFG];
  743. u64 antdiv_laststatetsf;
  744. u8 antdiv_bssid[ETH_ALEN];
  745. };
  746. void ath_slow_ant_div_init(struct ath_antdiv *antdiv,
  747. struct ath_softc *sc, int32_t rssitrig);
  748. void ath_slow_ant_div_start(struct ath_antdiv *antdiv,
  749. u8 num_antcfg,
  750. const u8 *bssid);
  751. void ath_slow_ant_div_stop(struct ath_antdiv *antdiv);
  752. void ath_slow_ant_div(struct ath_antdiv *antdiv,
  753. struct ieee80211_hdr *wh,
  754. struct ath_rx_status *rx_stats);
  755. void ath_setdefantenna(void *sc, u32 antenna);
  756. /********************/
  757. /* Main driver core */
  758. /********************/
  759. /*
  760. * Default cache line size, in bytes.
  761. * Used when PCI device not fully initialized by bootrom/BIOS
  762. */
  763. #define DEFAULT_CACHELINE 32
  764. #define ATH_DEFAULT_NOISE_FLOOR -95
  765. #define ATH_REGCLASSIDS_MAX 10
  766. #define ATH_CABQ_READY_TIME 80 /* % of beacon interval */
  767. #define ATH_PREAMBLE_SHORT (1<<0)
  768. #define ATH_PROTECT_ENABLE (1<<1)
  769. #define ATH_MAX_SW_RETRIES 10
  770. /* Num farmes difference in tx to flip default recv */
  771. #define ATH_ANTENNA_DIFF 2
  772. #define ATH_CHAN_MAX 255
  773. #define IEEE80211_WEP_NKID 4 /* number of key ids */
  774. #define IEEE80211_RATE_VAL 0x7f
  775. /*
  776. * The key cache is used for h/w cipher state and also for
  777. * tracking station state such as the current tx antenna.
  778. * We also setup a mapping table between key cache slot indices
  779. * and station state to short-circuit node lookups on rx.
  780. * Different parts have different size key caches. We handle
  781. * up to ATH_KEYMAX entries (could dynamically allocate state).
  782. */
  783. #define ATH_KEYMAX 128 /* max key cache size we handle */
  784. #define RESET_RETRY_TXQ 0x00000001
  785. #define ATH_IF_ID_ANY 0xff
  786. #define ATH_TXPOWER_MAX 100 /* .5 dBm units */
  787. #define RSSI_LPF_THRESHOLD -20
  788. #define ATH_RSSI_EP_MULTIPLIER (1<<7) /* pow2 to optimize out * and / */
  789. #define ATH_RATE_DUMMY_MARKER 0
  790. #define ATH_RSSI_LPF_LEN 10
  791. #define ATH_RSSI_DUMMY_MARKER 0x127
  792. #define ATH_EP_MUL(x, mul) ((x) * (mul))
  793. #define ATH_EP_RND(x, mul) \
  794. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  795. #define ATH_RSSI_OUT(x) \
  796. (((x) != ATH_RSSI_DUMMY_MARKER) ? \
  797. (ATH_EP_RND((x), ATH_RSSI_EP_MULTIPLIER)) : ATH_RSSI_DUMMY_MARKER)
  798. #define ATH_RSSI_IN(x) \
  799. (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
  800. #define ATH_LPF_RSSI(x, y, len) \
  801. ((x != ATH_RSSI_DUMMY_MARKER) ? \
  802. (((x) * ((len) - 1) + (y)) / (len)) : (y))
  803. #define ATH_RSSI_LPF(x, y) do { \
  804. if ((y) >= RSSI_LPF_THRESHOLD) \
  805. x = ATH_LPF_RSSI((x), \
  806. ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \
  807. } while (0)
  808. enum PROT_MODE {
  809. PROT_M_NONE = 0,
  810. PROT_M_RTSCTS,
  811. PROT_M_CTSONLY
  812. };
  813. enum RATE_TYPE {
  814. NORMAL_RATE = 0,
  815. HALF_RATE,
  816. QUARTER_RATE
  817. };
  818. struct ath_ht_info {
  819. enum ath9k_ht_macmode tx_chan_width;
  820. u16 maxampdu;
  821. u8 mpdudensity;
  822. u8 ext_chan_offset;
  823. };
  824. struct ath_softc {
  825. struct ieee80211_hw *hw; /* mac80211 instance */
  826. struct pci_dev *pdev; /* Bus handle */
  827. void __iomem *mem; /* address of the device */
  828. struct tasklet_struct intr_tq; /* General tasklet */
  829. struct tasklet_struct bcon_tasklet; /* Beacon tasklet */
  830. struct ath_config sc_config; /* per-instance load-time
  831. parameters */
  832. int sc_debug; /* Debug masks */
  833. struct ath_hal *sc_ah; /* HAL Instance */
  834. struct ath_rate_softc *sc_rc; /* tx rate control support */
  835. u32 sc_intrstatus; /* HAL_STATUS */
  836. enum ath9k_opmode sc_opmode; /* current operating mode */
  837. /* Properties, Config */
  838. u8 sc_invalid; /* being detached */
  839. u8 sc_beacons; /* beacons running */
  840. u8 sc_scanning; /* scanning active */
  841. u8 sc_txaggr; /* enable 11n tx aggregation */
  842. u8 sc_rxaggr; /* enable 11n rx aggregation */
  843. u8 sc_update_chainmask; /* change chain mask */
  844. u8 sc_full_reset; /* force full reset */
  845. enum wireless_mode sc_curmode; /* current phy mode */
  846. u16 sc_curtxpow; /* current tx power limit */
  847. u16 sc_curaid; /* current association id */
  848. u8 sc_curbssid[ETH_ALEN];
  849. u8 sc_myaddr[ETH_ALEN];
  850. enum PROT_MODE sc_protmode; /* protection mode */
  851. u8 sc_mcastantenna;/* Multicast antenna number */
  852. u8 sc_txantenna; /* data tx antenna
  853. (fixed or auto) */
  854. u8 sc_nbcnvaps; /* # of vaps sending beacons */
  855. u16 sc_nvaps; /* # of active virtual ap's */
  856. struct ath_vap *sc_vaps[ATH_BCBUF]; /* interface id
  857. to avp map */
  858. enum ath9k_int sc_imask; /* interrupt mask copy */
  859. u8 sc_bssidmask[ETH_ALEN];
  860. u8 sc_defant; /* current default antenna */
  861. u8 sc_rxotherant; /* rx's on non-default antenna*/
  862. u16 sc_cachelsz; /* cache line size */
  863. int sc_slotupdate; /* slot to next advance fsm */
  864. int sc_slottime; /* slot time */
  865. u8 sc_noreset;
  866. int sc_bslot[ATH_BCBUF];/* beacon xmit slots */
  867. struct ath9k_node_stats sc_halstats; /* station-mode rssi stats */
  868. struct list_head node_list;
  869. struct ath_ht_info sc_ht_info;
  870. int16_t sc_noise_floor; /* signal noise floor in dBm */
  871. enum ath9k_ht_extprotspacing sc_ht_extprotspacing;
  872. u8 sc_tx_chainmask;
  873. u8 sc_rx_chainmask;
  874. u8 sc_rxchaindetect_ref;
  875. u8 sc_rxchaindetect_thresh5GHz;
  876. u8 sc_rxchaindetect_thresh2GHz;
  877. u8 sc_rxchaindetect_delta5GHz;
  878. u8 sc_rxchaindetect_delta2GHz;
  879. u32 sc_rtsaggrlimit; /* Chipset specific
  880. aggr limit */
  881. u32 sc_flags;
  882. #ifdef CONFIG_SLOW_ANT_DIV
  883. /* Slow antenna diversity */
  884. struct ath_antdiv sc_antdiv;
  885. #endif
  886. enum {
  887. OK, /* no change needed */
  888. UPDATE, /* update pending */
  889. COMMIT /* beacon sent, commit change */
  890. } sc_updateslot; /* slot time update fsm */
  891. /* Crypto */
  892. u32 sc_keymax; /* size of key cache */
  893. DECLARE_BITMAP(sc_keymap, ATH_KEYMAX); /* key use bit map */
  894. u8 sc_splitmic; /* split TKIP MIC keys */
  895. int sc_keytype; /* type of the key being used */
  896. /* RX */
  897. struct list_head sc_rxbuf; /* receive buffer */
  898. struct ath_descdma sc_rxdma; /* RX descriptors */
  899. int sc_rxbufsize; /* rx size based on mtu */
  900. u32 *sc_rxlink; /* link ptr in last RX desc */
  901. u32 sc_rxflush; /* rx flush in progress */
  902. u64 sc_lastrx; /* tsf of last rx'd frame */
  903. /* TX */
  904. struct list_head sc_txbuf; /* transmit buffer */
  905. struct ath_txq sc_txq[ATH9K_NUM_TX_QUEUES];
  906. struct ath_descdma sc_txdma; /* TX descriptors */
  907. u32 sc_txqsetup; /* h/w queues setup */
  908. u32 sc_txintrperiod;/* tx interrupt batching */
  909. int sc_haltype2q[ATH9K_WME_AC_VO+1]; /* HAL WME
  910. AC -> h/w qnum */
  911. u32 sc_ant_tx[8]; /* recent tx frames/antenna */
  912. /* Beacon */
  913. struct ath9k_txq_info sc_beacon_qi; /* adhoc only: beacon
  914. queue parameters */
  915. struct ath_descdma sc_bdma; /* beacon descriptors */
  916. struct ath_txq *sc_cabq; /* tx q for cab frames */
  917. struct list_head sc_bbuf; /* beacon buffers */
  918. u32 sc_bhalq; /* HAL q for outgoing beacons */
  919. u32 sc_bmisscount; /* missed beacon transmits */
  920. u32 ast_be_xmit; /* beacons transmitted */
  921. /* Rate */
  922. struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
  923. const struct ath9k_rate_table *sc_rates[WIRELESS_MODE_MAX];
  924. const struct ath9k_rate_table *sc_currates; /* current rate table */
  925. u8 sc_rixmap[256]; /* IEEE to h/w
  926. rate table ix */
  927. u8 sc_minrateix; /* min h/w rate index */
  928. u8 sc_protrix; /* protection rate index */
  929. struct {
  930. u32 rateKbps; /* transfer rate in kbs */
  931. u8 ieeerate; /* IEEE rate */
  932. } sc_hwmap[256]; /* h/w rate ix mappings */
  933. /* Channel, Band */
  934. struct ieee80211_channel channels[IEEE80211_NUM_BANDS][ATH_CHAN_MAX];
  935. struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
  936. struct ath9k_channel sc_curchan; /* current h/w channel */
  937. /* Locks */
  938. spinlock_t sc_rxflushlock; /* lock of RX flush */
  939. spinlock_t sc_rxbuflock; /* rxbuf lock */
  940. spinlock_t sc_txbuflock; /* txbuf lock */
  941. spinlock_t sc_resetlock;
  942. spinlock_t node_lock;
  943. };
  944. int ath_init(u16 devid, struct ath_softc *sc);
  945. void ath_deinit(struct ath_softc *sc);
  946. int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan);
  947. int ath_suspend(struct ath_softc *sc);
  948. irqreturn_t ath_isr(int irq, void *dev);
  949. int ath_reset(struct ath_softc *sc);
  950. void ath_scan_start(struct ath_softc *sc);
  951. void ath_scan_end(struct ath_softc *sc);
  952. int ath_set_channel(struct ath_softc *sc, struct ath9k_channel *hchan);
  953. void ath_setup_rate(struct ath_softc *sc,
  954. enum wireless_mode wMode,
  955. enum RATE_TYPE type,
  956. const struct ath9k_rate_table *rt);
  957. /*********************/
  958. /* Utility Functions */
  959. /*********************/
  960. void ath_key_reset(struct ath_softc *sc, u16 keyix, int freeslot);
  961. int ath_keyset(struct ath_softc *sc,
  962. u16 keyix,
  963. struct ath9k_keyval *hk,
  964. const u8 mac[ETH_ALEN]);
  965. int ath_get_hal_qnum(u16 queue, struct ath_softc *sc);
  966. int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
  967. void ath_setslottime(struct ath_softc *sc);
  968. void ath_update_txpow(struct ath_softc *sc);
  969. int ath_cabq_update(struct ath_softc *);
  970. void ath_get_currentCountry(struct ath_softc *sc,
  971. struct ath9k_country_entry *ctry);
  972. u64 ath_extend_tsf(struct ath_softc *sc, u32 rstamp);
  973. void ath_internal_reset(struct ath_softc *sc);
  974. u32 ath_chan2flags(struct ieee80211_channel *chan, struct ath_softc *sc);
  975. dma_addr_t ath_skb_map_single(struct ath_softc *sc,
  976. struct sk_buff *skb,
  977. int direction,
  978. dma_addr_t *pa);
  979. void ath_skb_unmap_single(struct ath_softc *sc,
  980. struct sk_buff *skb,
  981. int direction,
  982. dma_addr_t *pa);
  983. void ath_mcast_merge(struct ath_softc *sc, u32 mfilt[2]);
  984. enum ath9k_ht_macmode ath_cwm_macmode(struct ath_softc *sc);
  985. #endif /* CORE_H */