rt2x00.h 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. /*
  2. Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
  3. Copyright (C) 2004 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
  4. Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
  5. <http://rt2x00.serialmonkey.com>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the
  16. Free Software Foundation, Inc.,
  17. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. Module: rt2x00
  21. Abstract: rt2x00 global information.
  22. */
  23. #ifndef RT2X00_H
  24. #define RT2X00_H
  25. #include <linux/bitops.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/workqueue.h>
  29. #include <linux/firmware.h>
  30. #include <linux/leds.h>
  31. #include <linux/mutex.h>
  32. #include <linux/etherdevice.h>
  33. #include <linux/input-polldev.h>
  34. #include <linux/kfifo.h>
  35. #include <linux/hrtimer.h>
  36. #include <net/mac80211.h>
  37. #include "rt2x00debug.h"
  38. #include "rt2x00dump.h"
  39. #include "rt2x00leds.h"
  40. #include "rt2x00reg.h"
  41. #include "rt2x00queue.h"
  42. /*
  43. * Module information.
  44. */
  45. #define DRV_VERSION "2.3.0"
  46. #define DRV_PROJECT "http://rt2x00.serialmonkey.com"
  47. /* Debug definitions.
  48. * Debug output has to be enabled during compile time.
  49. */
  50. #ifdef CONFIG_RT2X00_DEBUG
  51. #define DEBUG
  52. #endif /* CONFIG_RT2X00_DEBUG */
  53. /* Utility printing macros
  54. * rt2x00_probe_err is for messages when rt2x00_dev is uninitialized
  55. */
  56. #define rt2x00_probe_err(fmt, ...) \
  57. printk(KERN_ERR KBUILD_MODNAME ": %s: Error - " fmt, \
  58. __func__, ##__VA_ARGS__)
  59. #define rt2x00_err(dev, fmt, ...) \
  60. wiphy_err((dev)->hw->wiphy, "%s: Error - " fmt, \
  61. __func__, ##__VA_ARGS__)
  62. #define rt2x00_warn(dev, fmt, ...) \
  63. wiphy_warn((dev)->hw->wiphy, "%s: Warning - " fmt, \
  64. __func__, ##__VA_ARGS__)
  65. #define rt2x00_info(dev, fmt, ...) \
  66. wiphy_info((dev)->hw->wiphy, "%s: Info - " fmt, \
  67. __func__, ##__VA_ARGS__)
  68. /* Various debug levels */
  69. #define rt2x00_dbg(dev, fmt, ...) \
  70. wiphy_dbg((dev)->hw->wiphy, "%s: Debug - " fmt, \
  71. __func__, ##__VA_ARGS__)
  72. #define rt2x00_eeprom_dbg(dev, fmt, ...) \
  73. wiphy_dbg((dev)->hw->wiphy, "%s: EEPROM recovery - " fmt, \
  74. __func__, ##__VA_ARGS__)
  75. /*
  76. * Duration calculations
  77. * The rate variable passed is: 100kbs.
  78. * To convert from bytes to bits we multiply size with 8,
  79. * then the size is multiplied with 10 to make the
  80. * real rate -> rate argument correction.
  81. */
  82. #define GET_DURATION(__size, __rate) (((__size) * 8 * 10) / (__rate))
  83. #define GET_DURATION_RES(__size, __rate)(((__size) * 8 * 10) % (__rate))
  84. /*
  85. * Determine the number of L2 padding bytes required between the header and
  86. * the payload.
  87. */
  88. #define L2PAD_SIZE(__hdrlen) (-(__hdrlen) & 3)
  89. /*
  90. * Determine the alignment requirement,
  91. * to make sure the 802.11 payload is padded to a 4-byte boundrary
  92. * we must determine the address of the payload and calculate the
  93. * amount of bytes needed to move the data.
  94. */
  95. #define ALIGN_SIZE(__skb, __header) \
  96. ( ((unsigned long)((__skb)->data + (__header))) & 3 )
  97. /*
  98. * Constants for extra TX headroom for alignment purposes.
  99. */
  100. #define RT2X00_ALIGN_SIZE 4 /* Only whole frame needs alignment */
  101. #define RT2X00_L2PAD_SIZE 8 /* Both header & payload need alignment */
  102. /*
  103. * Standard timing and size defines.
  104. * These values should follow the ieee80211 specifications.
  105. */
  106. #define ACK_SIZE 14
  107. #define IEEE80211_HEADER 24
  108. #define PLCP 48
  109. #define BEACON 100
  110. #define PREAMBLE 144
  111. #define SHORT_PREAMBLE 72
  112. #define SLOT_TIME 20
  113. #define SHORT_SLOT_TIME 9
  114. #define SIFS 10
  115. #define PIFS ( SIFS + SLOT_TIME )
  116. #define SHORT_PIFS ( SIFS + SHORT_SLOT_TIME )
  117. #define DIFS ( PIFS + SLOT_TIME )
  118. #define SHORT_DIFS ( SHORT_PIFS + SHORT_SLOT_TIME )
  119. #define EIFS ( SIFS + DIFS + \
  120. GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
  121. #define SHORT_EIFS ( SIFS + SHORT_DIFS + \
  122. GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
  123. /*
  124. * Structure for average calculation
  125. * The avg field contains the actual average value,
  126. * but avg_weight is internally used during calculations
  127. * to prevent rounding errors.
  128. */
  129. struct avg_val {
  130. int avg;
  131. int avg_weight;
  132. };
  133. enum rt2x00_chip_intf {
  134. RT2X00_CHIP_INTF_PCI,
  135. RT2X00_CHIP_INTF_PCIE,
  136. RT2X00_CHIP_INTF_USB,
  137. RT2X00_CHIP_INTF_SOC,
  138. };
  139. /*
  140. * Chipset identification
  141. * The chipset on the device is composed of a RT and RF chip.
  142. * The chipset combination is important for determining device capabilities.
  143. */
  144. struct rt2x00_chip {
  145. u16 rt;
  146. #define RT2460 0x2460
  147. #define RT2560 0x2560
  148. #define RT2570 0x2570
  149. #define RT2661 0x2661
  150. #define RT2573 0x2573
  151. #define RT2860 0x2860 /* 2.4GHz */
  152. #define RT2872 0x2872 /* WSOC */
  153. #define RT2883 0x2883 /* WSOC */
  154. #define RT3070 0x3070
  155. #define RT3071 0x3071
  156. #define RT3090 0x3090 /* 2.4GHz PCIe */
  157. #define RT3290 0x3290
  158. #define RT3352 0x3352 /* WSOC */
  159. #define RT3390 0x3390
  160. #define RT3572 0x3572
  161. #define RT3593 0x3593
  162. #define RT3883 0x3883 /* WSOC */
  163. #define RT5390 0x5390 /* 2.4GHz */
  164. #define RT5392 0x5392 /* 2.4GHz */
  165. #define RT5592 0x5592
  166. u16 rf;
  167. u16 rev;
  168. enum rt2x00_chip_intf intf;
  169. };
  170. /*
  171. * RF register values that belong to a particular channel.
  172. */
  173. struct rf_channel {
  174. int channel;
  175. u32 rf1;
  176. u32 rf2;
  177. u32 rf3;
  178. u32 rf4;
  179. };
  180. /*
  181. * Channel information structure
  182. */
  183. struct channel_info {
  184. unsigned int flags;
  185. #define GEOGRAPHY_ALLOWED 0x00000001
  186. short max_power;
  187. short default_power1;
  188. short default_power2;
  189. };
  190. /*
  191. * Antenna setup values.
  192. */
  193. struct antenna_setup {
  194. enum antenna rx;
  195. enum antenna tx;
  196. u8 rx_chain_num;
  197. u8 tx_chain_num;
  198. };
  199. /*
  200. * Quality statistics about the currently active link.
  201. */
  202. struct link_qual {
  203. /*
  204. * Statistics required for Link tuning by driver
  205. * The rssi value is provided by rt2x00lib during the
  206. * link_tuner() callback function.
  207. * The false_cca field is filled during the link_stats()
  208. * callback function and could be used during the
  209. * link_tuner() callback function.
  210. */
  211. int rssi;
  212. int false_cca;
  213. /*
  214. * VGC levels
  215. * Hardware driver will tune the VGC level during each call
  216. * to the link_tuner() callback function. This vgc_level is
  217. * is determined based on the link quality statistics like
  218. * average RSSI and the false CCA count.
  219. *
  220. * In some cases the drivers need to differentiate between
  221. * the currently "desired" VGC level and the level configured
  222. * in the hardware. The latter is important to reduce the
  223. * number of BBP register reads to reduce register access
  224. * overhead. For this reason we store both values here.
  225. */
  226. u8 vgc_level;
  227. u8 vgc_level_reg;
  228. /*
  229. * Statistics required for Signal quality calculation.
  230. * These fields might be changed during the link_stats()
  231. * callback function.
  232. */
  233. int rx_success;
  234. int rx_failed;
  235. int tx_success;
  236. int tx_failed;
  237. };
  238. /*
  239. * Antenna settings about the currently active link.
  240. */
  241. struct link_ant {
  242. /*
  243. * Antenna flags
  244. */
  245. unsigned int flags;
  246. #define ANTENNA_RX_DIVERSITY 0x00000001
  247. #define ANTENNA_TX_DIVERSITY 0x00000002
  248. #define ANTENNA_MODE_SAMPLE 0x00000004
  249. /*
  250. * Currently active TX/RX antenna setup.
  251. * When software diversity is used, this will indicate
  252. * which antenna is actually used at this time.
  253. */
  254. struct antenna_setup active;
  255. /*
  256. * RSSI history information for the antenna.
  257. * Used to determine when to switch antenna
  258. * when using software diversity.
  259. */
  260. int rssi_history;
  261. /*
  262. * Current RSSI average of the currently active antenna.
  263. * Similar to the avg_rssi in the link_qual structure
  264. * this value is updated by using the walking average.
  265. */
  266. struct avg_val rssi_ant;
  267. };
  268. /*
  269. * To optimize the quality of the link we need to store
  270. * the quality of received frames and periodically
  271. * optimize the link.
  272. */
  273. struct link {
  274. /*
  275. * Link tuner counter
  276. * The number of times the link has been tuned
  277. * since the radio has been switched on.
  278. */
  279. u32 count;
  280. /*
  281. * Quality measurement values.
  282. */
  283. struct link_qual qual;
  284. /*
  285. * TX/RX antenna setup.
  286. */
  287. struct link_ant ant;
  288. /*
  289. * Currently active average RSSI value
  290. */
  291. struct avg_val avg_rssi;
  292. /*
  293. * Work structure for scheduling periodic link tuning.
  294. */
  295. struct delayed_work work;
  296. /*
  297. * Work structure for scheduling periodic watchdog monitoring.
  298. * This work must be scheduled on the kernel workqueue, while
  299. * all other work structures must be queued on the mac80211
  300. * workqueue. This guarantees that the watchdog can schedule
  301. * other work structures and wait for their completion in order
  302. * to bring the device/driver back into the desired state.
  303. */
  304. struct delayed_work watchdog_work;
  305. /*
  306. * Work structure for scheduling periodic AGC adjustments.
  307. */
  308. struct delayed_work agc_work;
  309. /*
  310. * Work structure for scheduling periodic VCO calibration.
  311. */
  312. struct delayed_work vco_work;
  313. };
  314. enum rt2x00_delayed_flags {
  315. DELAYED_UPDATE_BEACON,
  316. };
  317. /*
  318. * Interface structure
  319. * Per interface configuration details, this structure
  320. * is allocated as the private data for ieee80211_vif.
  321. */
  322. struct rt2x00_intf {
  323. /*
  324. * beacon->skb must be protected with the mutex.
  325. */
  326. struct mutex beacon_skb_mutex;
  327. /*
  328. * Entry in the beacon queue which belongs to
  329. * this interface. Each interface has its own
  330. * dedicated beacon entry.
  331. */
  332. struct queue_entry *beacon;
  333. bool enable_beacon;
  334. /*
  335. * Actions that needed rescheduling.
  336. */
  337. unsigned long delayed_flags;
  338. /*
  339. * Software sequence counter, this is only required
  340. * for hardware which doesn't support hardware
  341. * sequence counting.
  342. */
  343. atomic_t seqno;
  344. };
  345. static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
  346. {
  347. return (struct rt2x00_intf *)vif->drv_priv;
  348. }
  349. /**
  350. * struct hw_mode_spec: Hardware specifications structure
  351. *
  352. * Details about the supported modes, rates and channels
  353. * of a particular chipset. This is used by rt2x00lib
  354. * to build the ieee80211_hw_mode array for mac80211.
  355. *
  356. * @supported_bands: Bitmask contained the supported bands (2.4GHz, 5.2GHz).
  357. * @supported_rates: Rate types which are supported (CCK, OFDM).
  358. * @num_channels: Number of supported channels. This is used as array size
  359. * for @tx_power_a, @tx_power_bg and @channels.
  360. * @channels: Device/chipset specific channel values (See &struct rf_channel).
  361. * @channels_info: Additional information for channels (See &struct channel_info).
  362. * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
  363. */
  364. struct hw_mode_spec {
  365. unsigned int supported_bands;
  366. #define SUPPORT_BAND_2GHZ 0x00000001
  367. #define SUPPORT_BAND_5GHZ 0x00000002
  368. unsigned int supported_rates;
  369. #define SUPPORT_RATE_CCK 0x00000001
  370. #define SUPPORT_RATE_OFDM 0x00000002
  371. unsigned int num_channels;
  372. const struct rf_channel *channels;
  373. const struct channel_info *channels_info;
  374. struct ieee80211_sta_ht_cap ht;
  375. };
  376. /*
  377. * Configuration structure wrapper around the
  378. * mac80211 configuration structure.
  379. * When mac80211 configures the driver, rt2x00lib
  380. * can precalculate values which are equal for all
  381. * rt2x00 drivers. Those values can be stored in here.
  382. */
  383. struct rt2x00lib_conf {
  384. struct ieee80211_conf *conf;
  385. struct rf_channel rf;
  386. struct channel_info channel;
  387. };
  388. /*
  389. * Configuration structure for erp settings.
  390. */
  391. struct rt2x00lib_erp {
  392. int short_preamble;
  393. int cts_protection;
  394. u32 basic_rates;
  395. int slot_time;
  396. short sifs;
  397. short pifs;
  398. short difs;
  399. short eifs;
  400. u16 beacon_int;
  401. u16 ht_opmode;
  402. };
  403. /*
  404. * Configuration structure for hardware encryption.
  405. */
  406. struct rt2x00lib_crypto {
  407. enum cipher cipher;
  408. enum set_key_cmd cmd;
  409. const u8 *address;
  410. u32 bssidx;
  411. u8 key[16];
  412. u8 tx_mic[8];
  413. u8 rx_mic[8];
  414. int wcid;
  415. };
  416. /*
  417. * Configuration structure wrapper around the
  418. * rt2x00 interface configuration handler.
  419. */
  420. struct rt2x00intf_conf {
  421. /*
  422. * Interface type
  423. */
  424. enum nl80211_iftype type;
  425. /*
  426. * TSF sync value, this is dependent on the operation type.
  427. */
  428. enum tsf_sync sync;
  429. /*
  430. * The MAC and BSSID addresses are simple array of bytes,
  431. * these arrays are little endian, so when sending the addresses
  432. * to the drivers, copy the it into a endian-signed variable.
  433. *
  434. * Note that all devices (except rt2500usb) have 32 bits
  435. * register word sizes. This means that whatever variable we
  436. * pass _must_ be a multiple of 32 bits. Otherwise the device
  437. * might not accept what we are sending to it.
  438. * This will also make it easier for the driver to write
  439. * the data to the device.
  440. */
  441. __le32 mac[2];
  442. __le32 bssid[2];
  443. };
  444. /*
  445. * Private structure for storing STA details
  446. * wcid: Wireless Client ID
  447. */
  448. struct rt2x00_sta {
  449. int wcid;
  450. };
  451. static inline struct rt2x00_sta* sta_to_rt2x00_sta(struct ieee80211_sta *sta)
  452. {
  453. return (struct rt2x00_sta *)sta->drv_priv;
  454. }
  455. /*
  456. * rt2x00lib callback functions.
  457. */
  458. struct rt2x00lib_ops {
  459. /*
  460. * Interrupt handlers.
  461. */
  462. irq_handler_t irq_handler;
  463. /*
  464. * TX status tasklet handler.
  465. */
  466. void (*txstatus_tasklet) (unsigned long data);
  467. void (*pretbtt_tasklet) (unsigned long data);
  468. void (*tbtt_tasklet) (unsigned long data);
  469. void (*rxdone_tasklet) (unsigned long data);
  470. void (*autowake_tasklet) (unsigned long data);
  471. /*
  472. * Device init handlers.
  473. */
  474. int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
  475. char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
  476. int (*check_firmware) (struct rt2x00_dev *rt2x00dev,
  477. const u8 *data, const size_t len);
  478. int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
  479. const u8 *data, const size_t len);
  480. /*
  481. * Device initialization/deinitialization handlers.
  482. */
  483. int (*initialize) (struct rt2x00_dev *rt2x00dev);
  484. void (*uninitialize) (struct rt2x00_dev *rt2x00dev);
  485. /*
  486. * queue initialization handlers
  487. */
  488. bool (*get_entry_state) (struct queue_entry *entry);
  489. void (*clear_entry) (struct queue_entry *entry);
  490. /*
  491. * Radio control handlers.
  492. */
  493. int (*set_device_state) (struct rt2x00_dev *rt2x00dev,
  494. enum dev_state state);
  495. int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
  496. void (*link_stats) (struct rt2x00_dev *rt2x00dev,
  497. struct link_qual *qual);
  498. void (*reset_tuner) (struct rt2x00_dev *rt2x00dev,
  499. struct link_qual *qual);
  500. void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
  501. struct link_qual *qual, const u32 count);
  502. void (*gain_calibration) (struct rt2x00_dev *rt2x00dev);
  503. void (*vco_calibration) (struct rt2x00_dev *rt2x00dev);
  504. /*
  505. * Data queue handlers.
  506. */
  507. void (*watchdog) (struct rt2x00_dev *rt2x00dev);
  508. void (*start_queue) (struct data_queue *queue);
  509. void (*kick_queue) (struct data_queue *queue);
  510. void (*stop_queue) (struct data_queue *queue);
  511. void (*flush_queue) (struct data_queue *queue, bool drop);
  512. void (*tx_dma_done) (struct queue_entry *entry);
  513. /*
  514. * TX control handlers
  515. */
  516. void (*write_tx_desc) (struct queue_entry *entry,
  517. struct txentry_desc *txdesc);
  518. void (*write_tx_data) (struct queue_entry *entry,
  519. struct txentry_desc *txdesc);
  520. void (*write_beacon) (struct queue_entry *entry,
  521. struct txentry_desc *txdesc);
  522. void (*clear_beacon) (struct queue_entry *entry);
  523. int (*get_tx_data_len) (struct queue_entry *entry);
  524. /*
  525. * RX control handlers
  526. */
  527. void (*fill_rxdone) (struct queue_entry *entry,
  528. struct rxdone_entry_desc *rxdesc);
  529. /*
  530. * Configuration handlers.
  531. */
  532. int (*config_shared_key) (struct rt2x00_dev *rt2x00dev,
  533. struct rt2x00lib_crypto *crypto,
  534. struct ieee80211_key_conf *key);
  535. int (*config_pairwise_key) (struct rt2x00_dev *rt2x00dev,
  536. struct rt2x00lib_crypto *crypto,
  537. struct ieee80211_key_conf *key);
  538. void (*config_filter) (struct rt2x00_dev *rt2x00dev,
  539. const unsigned int filter_flags);
  540. void (*config_intf) (struct rt2x00_dev *rt2x00dev,
  541. struct rt2x00_intf *intf,
  542. struct rt2x00intf_conf *conf,
  543. const unsigned int flags);
  544. #define CONFIG_UPDATE_TYPE ( 1 << 1 )
  545. #define CONFIG_UPDATE_MAC ( 1 << 2 )
  546. #define CONFIG_UPDATE_BSSID ( 1 << 3 )
  547. void (*config_erp) (struct rt2x00_dev *rt2x00dev,
  548. struct rt2x00lib_erp *erp,
  549. u32 changed);
  550. void (*config_ant) (struct rt2x00_dev *rt2x00dev,
  551. struct antenna_setup *ant);
  552. void (*config) (struct rt2x00_dev *rt2x00dev,
  553. struct rt2x00lib_conf *libconf,
  554. const unsigned int changed_flags);
  555. int (*sta_add) (struct rt2x00_dev *rt2x00dev,
  556. struct ieee80211_vif *vif,
  557. struct ieee80211_sta *sta);
  558. int (*sta_remove) (struct rt2x00_dev *rt2x00dev,
  559. int wcid);
  560. };
  561. /*
  562. * rt2x00 driver callback operation structure.
  563. */
  564. struct rt2x00_ops {
  565. const char *name;
  566. const unsigned int drv_data_size;
  567. const unsigned int max_ap_intf;
  568. const unsigned int eeprom_size;
  569. const unsigned int rf_size;
  570. const unsigned int tx_queues;
  571. const unsigned int extra_tx_headroom;
  572. const struct data_queue_desc *rx;
  573. const struct data_queue_desc *tx;
  574. const struct data_queue_desc *bcn;
  575. const struct data_queue_desc *atim;
  576. const struct rt2x00lib_ops *lib;
  577. const void *drv;
  578. const struct ieee80211_ops *hw;
  579. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  580. const struct rt2x00debug *debugfs;
  581. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  582. };
  583. /*
  584. * rt2x00 state flags
  585. */
  586. enum rt2x00_state_flags {
  587. /*
  588. * Device flags
  589. */
  590. DEVICE_STATE_PRESENT,
  591. DEVICE_STATE_REGISTERED_HW,
  592. DEVICE_STATE_INITIALIZED,
  593. DEVICE_STATE_STARTED,
  594. DEVICE_STATE_ENABLED_RADIO,
  595. DEVICE_STATE_SCANNING,
  596. /*
  597. * Driver configuration
  598. */
  599. CONFIG_CHANNEL_HT40,
  600. CONFIG_POWERSAVING,
  601. CONFIG_HT_DISABLED,
  602. CONFIG_QOS_DISABLED,
  603. /*
  604. * Mark we currently are sequentially reading TX_STA_FIFO register
  605. * FIXME: this is for only rt2800usb, should go to private data
  606. */
  607. TX_STATUS_READING,
  608. };
  609. /*
  610. * rt2x00 capability flags
  611. */
  612. enum rt2x00_capability_flags {
  613. /*
  614. * Requirements
  615. */
  616. REQUIRE_FIRMWARE,
  617. REQUIRE_BEACON_GUARD,
  618. REQUIRE_ATIM_QUEUE,
  619. REQUIRE_DMA,
  620. REQUIRE_COPY_IV,
  621. REQUIRE_L2PAD,
  622. REQUIRE_TXSTATUS_FIFO,
  623. REQUIRE_TASKLET_CONTEXT,
  624. REQUIRE_SW_SEQNO,
  625. REQUIRE_HT_TX_DESC,
  626. REQUIRE_PS_AUTOWAKE,
  627. /*
  628. * Capabilities
  629. */
  630. CAPABILITY_HW_BUTTON,
  631. CAPABILITY_HW_CRYPTO,
  632. CAPABILITY_POWER_LIMIT,
  633. CAPABILITY_CONTROL_FILTERS,
  634. CAPABILITY_CONTROL_FILTER_PSPOLL,
  635. CAPABILITY_PRE_TBTT_INTERRUPT,
  636. CAPABILITY_LINK_TUNING,
  637. CAPABILITY_FRAME_TYPE,
  638. CAPABILITY_RF_SEQUENCE,
  639. CAPABILITY_EXTERNAL_LNA_A,
  640. CAPABILITY_EXTERNAL_LNA_BG,
  641. CAPABILITY_DOUBLE_ANTENNA,
  642. CAPABILITY_BT_COEXIST,
  643. CAPABILITY_VCO_RECALIBRATION,
  644. };
  645. /*
  646. * Interface combinations
  647. */
  648. enum {
  649. IF_COMB_AP = 0,
  650. NUM_IF_COMB,
  651. };
  652. /*
  653. * rt2x00 device structure.
  654. */
  655. struct rt2x00_dev {
  656. /*
  657. * Device structure.
  658. * The structure stored in here depends on the
  659. * system bus (PCI or USB).
  660. * When accessing this variable, the rt2x00dev_{pci,usb}
  661. * macros should be used for correct typecasting.
  662. */
  663. struct device *dev;
  664. /*
  665. * Callback functions.
  666. */
  667. const struct rt2x00_ops *ops;
  668. /*
  669. * Driver data.
  670. */
  671. void *drv_data;
  672. /*
  673. * IEEE80211 control structure.
  674. */
  675. struct ieee80211_hw *hw;
  676. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  677. enum ieee80211_band curr_band;
  678. int curr_freq;
  679. /*
  680. * If enabled, the debugfs interface structures
  681. * required for deregistration of debugfs.
  682. */
  683. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  684. struct rt2x00debug_intf *debugfs_intf;
  685. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  686. /*
  687. * LED structure for changing the LED status
  688. * by mac8011 or the kernel.
  689. */
  690. #ifdef CONFIG_RT2X00_LIB_LEDS
  691. struct rt2x00_led led_radio;
  692. struct rt2x00_led led_assoc;
  693. struct rt2x00_led led_qual;
  694. u16 led_mcu_reg;
  695. #endif /* CONFIG_RT2X00_LIB_LEDS */
  696. /*
  697. * Device state flags.
  698. * In these flags the current status is stored.
  699. * Access to these flags should occur atomically.
  700. */
  701. unsigned long flags;
  702. /*
  703. * Device capabiltiy flags.
  704. * In these flags the device/driver capabilities are stored.
  705. * Access to these flags should occur non-atomically.
  706. */
  707. unsigned long cap_flags;
  708. /*
  709. * Device information, Bus IRQ and name (PCI, SoC)
  710. */
  711. int irq;
  712. const char *name;
  713. /*
  714. * Chipset identification.
  715. */
  716. struct rt2x00_chip chip;
  717. /*
  718. * hw capability specifications.
  719. */
  720. struct hw_mode_spec spec;
  721. /*
  722. * This is the default TX/RX antenna setup as indicated
  723. * by the device's EEPROM.
  724. */
  725. struct antenna_setup default_ant;
  726. /*
  727. * Register pointers
  728. * csr.base: CSR base register address. (PCI)
  729. * csr.cache: CSR cache for usb_control_msg. (USB)
  730. */
  731. union csr {
  732. void __iomem *base;
  733. void *cache;
  734. } csr;
  735. /*
  736. * Mutex to protect register accesses.
  737. * For PCI and USB devices it protects against concurrent indirect
  738. * register access (BBP, RF, MCU) since accessing those
  739. * registers require multiple calls to the CSR registers.
  740. * For USB devices it also protects the csr_cache since that
  741. * field is used for normal CSR access and it cannot support
  742. * multiple callers simultaneously.
  743. */
  744. struct mutex csr_mutex;
  745. /*
  746. * Current packet filter configuration for the device.
  747. * This contains all currently active FIF_* flags send
  748. * to us by mac80211 during configure_filter().
  749. */
  750. unsigned int packet_filter;
  751. /*
  752. * Interface details:
  753. * - Open ap interface count.
  754. * - Open sta interface count.
  755. * - Association count.
  756. * - Beaconing enabled count.
  757. */
  758. unsigned int intf_ap_count;
  759. unsigned int intf_sta_count;
  760. unsigned int intf_associated;
  761. unsigned int intf_beaconing;
  762. /*
  763. * Interface combinations
  764. */
  765. struct ieee80211_iface_limit if_limits_ap;
  766. struct ieee80211_iface_combination if_combinations[NUM_IF_COMB];
  767. /*
  768. * Link quality
  769. */
  770. struct link link;
  771. /*
  772. * EEPROM data.
  773. */
  774. __le16 *eeprom;
  775. /*
  776. * Active RF register values.
  777. * These are stored here so we don't need
  778. * to read the rf registers and can directly
  779. * use this value instead.
  780. * This field should be accessed by using
  781. * rt2x00_rf_read() and rt2x00_rf_write().
  782. */
  783. u32 *rf;
  784. /*
  785. * LNA gain
  786. */
  787. short lna_gain;
  788. /*
  789. * Current TX power value.
  790. */
  791. u16 tx_power;
  792. /*
  793. * Current retry values.
  794. */
  795. u8 short_retry;
  796. u8 long_retry;
  797. /*
  798. * Rssi <-> Dbm offset
  799. */
  800. u8 rssi_offset;
  801. /*
  802. * Frequency offset.
  803. */
  804. u8 freq_offset;
  805. /*
  806. * Association id.
  807. */
  808. u16 aid;
  809. /*
  810. * Beacon interval.
  811. */
  812. u16 beacon_int;
  813. /**
  814. * Timestamp of last received beacon
  815. */
  816. unsigned long last_beacon;
  817. /*
  818. * Low level statistics which will have
  819. * to be kept up to date while device is running.
  820. */
  821. struct ieee80211_low_level_stats low_level_stats;
  822. /**
  823. * Work queue for all work which should not be placed
  824. * on the mac80211 workqueue (because of dependencies
  825. * between various work structures).
  826. */
  827. struct workqueue_struct *workqueue;
  828. /*
  829. * Scheduled work.
  830. * NOTE: intf_work will use ieee80211_iterate_active_interfaces()
  831. * which means it cannot be placed on the hw->workqueue
  832. * due to RTNL locking requirements.
  833. */
  834. struct work_struct intf_work;
  835. /**
  836. * Scheduled work for TX/RX done handling (USB devices)
  837. */
  838. struct work_struct rxdone_work;
  839. struct work_struct txdone_work;
  840. /*
  841. * Powersaving work
  842. */
  843. struct delayed_work autowakeup_work;
  844. struct work_struct sleep_work;
  845. /*
  846. * Data queue arrays for RX, TX, Beacon and ATIM.
  847. */
  848. unsigned int data_queues;
  849. struct data_queue *rx;
  850. struct data_queue *tx;
  851. struct data_queue *bcn;
  852. struct data_queue *atim;
  853. /*
  854. * Firmware image.
  855. */
  856. const struct firmware *fw;
  857. /*
  858. * FIFO for storing tx status reports between isr and tasklet.
  859. */
  860. DECLARE_KFIFO_PTR(txstatus_fifo, u32);
  861. /*
  862. * Timer to ensure tx status reports are read (rt2800usb).
  863. */
  864. struct hrtimer txstatus_timer;
  865. /*
  866. * Tasklet for processing tx status reports (rt2800pci).
  867. */
  868. struct tasklet_struct txstatus_tasklet;
  869. struct tasklet_struct pretbtt_tasklet;
  870. struct tasklet_struct tbtt_tasklet;
  871. struct tasklet_struct rxdone_tasklet;
  872. struct tasklet_struct autowake_tasklet;
  873. /*
  874. * Used for VCO periodic calibration.
  875. */
  876. int rf_channel;
  877. /*
  878. * Protect the interrupt mask register.
  879. */
  880. spinlock_t irqmask_lock;
  881. /*
  882. * List of BlockAckReq TX entries that need driver BlockAck processing.
  883. */
  884. struct list_head bar_list;
  885. spinlock_t bar_list_lock;
  886. };
  887. struct rt2x00_bar_list_entry {
  888. struct list_head list;
  889. struct rcu_head head;
  890. struct queue_entry *entry;
  891. int block_acked;
  892. /* Relevant parts of the IEEE80211 BAR header */
  893. __u8 ra[6];
  894. __u8 ta[6];
  895. __le16 control;
  896. __le16 start_seq_num;
  897. };
  898. /*
  899. * Register defines.
  900. * Some registers require multiple attempts before success,
  901. * in those cases REGISTER_BUSY_COUNT attempts should be
  902. * taken with a REGISTER_BUSY_DELAY interval.
  903. */
  904. #define REGISTER_BUSY_COUNT 100
  905. #define REGISTER_BUSY_DELAY 100
  906. /*
  907. * Generic RF access.
  908. * The RF is being accessed by word index.
  909. */
  910. static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
  911. const unsigned int word, u32 *data)
  912. {
  913. BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
  914. *data = rt2x00dev->rf[word - 1];
  915. }
  916. static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev,
  917. const unsigned int word, u32 data)
  918. {
  919. BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
  920. rt2x00dev->rf[word - 1] = data;
  921. }
  922. /*
  923. * Generic EEPROM access. The EEPROM is being accessed by word or byte index.
  924. */
  925. static inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev,
  926. const unsigned int word)
  927. {
  928. return (void *)&rt2x00dev->eeprom[word];
  929. }
  930. static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev,
  931. const unsigned int word, u16 *data)
  932. {
  933. *data = le16_to_cpu(rt2x00dev->eeprom[word]);
  934. }
  935. static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev,
  936. const unsigned int word, u16 data)
  937. {
  938. rt2x00dev->eeprom[word] = cpu_to_le16(data);
  939. }
  940. static inline u8 rt2x00_eeprom_byte(struct rt2x00_dev *rt2x00dev,
  941. const unsigned int byte)
  942. {
  943. return *(((u8 *)rt2x00dev->eeprom) + byte);
  944. }
  945. /*
  946. * Chipset handlers
  947. */
  948. static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
  949. const u16 rt, const u16 rf, const u16 rev)
  950. {
  951. rt2x00dev->chip.rt = rt;
  952. rt2x00dev->chip.rf = rf;
  953. rt2x00dev->chip.rev = rev;
  954. rt2x00_info(rt2x00dev, "Chipset detected - rt: %04x, rf: %04x, rev: %04x\n",
  955. rt2x00dev->chip.rt, rt2x00dev->chip.rf,
  956. rt2x00dev->chip.rev);
  957. }
  958. static inline void rt2x00_set_rt(struct rt2x00_dev *rt2x00dev,
  959. const u16 rt, const u16 rev)
  960. {
  961. rt2x00dev->chip.rt = rt;
  962. rt2x00dev->chip.rev = rev;
  963. rt2x00_info(rt2x00dev, "RT chipset %04x, rev %04x detected\n",
  964. rt2x00dev->chip.rt, rt2x00dev->chip.rev);
  965. }
  966. static inline void rt2x00_set_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
  967. {
  968. rt2x00dev->chip.rf = rf;
  969. rt2x00_info(rt2x00dev, "RF chipset %04x detected\n",
  970. rt2x00dev->chip.rf);
  971. }
  972. static inline bool rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
  973. {
  974. return (rt2x00dev->chip.rt == rt);
  975. }
  976. static inline bool rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
  977. {
  978. return (rt2x00dev->chip.rf == rf);
  979. }
  980. static inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev)
  981. {
  982. return rt2x00dev->chip.rev;
  983. }
  984. static inline bool rt2x00_rt_rev(struct rt2x00_dev *rt2x00dev,
  985. const u16 rt, const u16 rev)
  986. {
  987. return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) == rev);
  988. }
  989. static inline bool rt2x00_rt_rev_lt(struct rt2x00_dev *rt2x00dev,
  990. const u16 rt, const u16 rev)
  991. {
  992. return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) < rev);
  993. }
  994. static inline bool rt2x00_rt_rev_gte(struct rt2x00_dev *rt2x00dev,
  995. const u16 rt, const u16 rev)
  996. {
  997. return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) >= rev);
  998. }
  999. static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev,
  1000. enum rt2x00_chip_intf intf)
  1001. {
  1002. rt2x00dev->chip.intf = intf;
  1003. }
  1004. static inline bool rt2x00_intf(struct rt2x00_dev *rt2x00dev,
  1005. enum rt2x00_chip_intf intf)
  1006. {
  1007. return (rt2x00dev->chip.intf == intf);
  1008. }
  1009. static inline bool rt2x00_is_pci(struct rt2x00_dev *rt2x00dev)
  1010. {
  1011. return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI) ||
  1012. rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
  1013. }
  1014. static inline bool rt2x00_is_pcie(struct rt2x00_dev *rt2x00dev)
  1015. {
  1016. return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
  1017. }
  1018. static inline bool rt2x00_is_usb(struct rt2x00_dev *rt2x00dev)
  1019. {
  1020. return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_USB);
  1021. }
  1022. static inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev)
  1023. {
  1024. return rt2x00_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
  1025. }
  1026. /**
  1027. * rt2x00queue_map_txskb - Map a skb into DMA for TX purposes.
  1028. * @entry: Pointer to &struct queue_entry
  1029. *
  1030. * Returns -ENOMEM if mapping fail, 0 otherwise.
  1031. */
  1032. int rt2x00queue_map_txskb(struct queue_entry *entry);
  1033. /**
  1034. * rt2x00queue_unmap_skb - Unmap a skb from DMA.
  1035. * @entry: Pointer to &struct queue_entry
  1036. */
  1037. void rt2x00queue_unmap_skb(struct queue_entry *entry);
  1038. /**
  1039. * rt2x00queue_get_tx_queue - Convert tx queue index to queue pointer
  1040. * @rt2x00dev: Pointer to &struct rt2x00_dev.
  1041. * @queue: rt2x00 queue index (see &enum data_queue_qid).
  1042. *
  1043. * Returns NULL for non tx queues.
  1044. */
  1045. static inline struct data_queue *
  1046. rt2x00queue_get_tx_queue(struct rt2x00_dev *rt2x00dev,
  1047. const enum data_queue_qid queue)
  1048. {
  1049. if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)
  1050. return &rt2x00dev->tx[queue];
  1051. if (queue == QID_ATIM)
  1052. return rt2x00dev->atim;
  1053. return NULL;
  1054. }
  1055. /**
  1056. * rt2x00queue_get_entry - Get queue entry where the given index points to.
  1057. * @queue: Pointer to &struct data_queue from where we obtain the entry.
  1058. * @index: Index identifier for obtaining the correct index.
  1059. */
  1060. struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
  1061. enum queue_index index);
  1062. /**
  1063. * rt2x00queue_pause_queue - Pause a data queue
  1064. * @queue: Pointer to &struct data_queue.
  1065. *
  1066. * This function will pause the data queue locally, preventing
  1067. * new frames to be added to the queue (while the hardware is
  1068. * still allowed to run).
  1069. */
  1070. void rt2x00queue_pause_queue(struct data_queue *queue);
  1071. /**
  1072. * rt2x00queue_unpause_queue - unpause a data queue
  1073. * @queue: Pointer to &struct data_queue.
  1074. *
  1075. * This function will unpause the data queue locally, allowing
  1076. * new frames to be added to the queue again.
  1077. */
  1078. void rt2x00queue_unpause_queue(struct data_queue *queue);
  1079. /**
  1080. * rt2x00queue_start_queue - Start a data queue
  1081. * @queue: Pointer to &struct data_queue.
  1082. *
  1083. * This function will start handling all pending frames in the queue.
  1084. */
  1085. void rt2x00queue_start_queue(struct data_queue *queue);
  1086. /**
  1087. * rt2x00queue_stop_queue - Halt a data queue
  1088. * @queue: Pointer to &struct data_queue.
  1089. *
  1090. * This function will stop all pending frames in the queue.
  1091. */
  1092. void rt2x00queue_stop_queue(struct data_queue *queue);
  1093. /**
  1094. * rt2x00queue_flush_queue - Flush a data queue
  1095. * @queue: Pointer to &struct data_queue.
  1096. * @drop: True to drop all pending frames.
  1097. *
  1098. * This function will flush the queue. After this call
  1099. * the queue is guaranteed to be empty.
  1100. */
  1101. void rt2x00queue_flush_queue(struct data_queue *queue, bool drop);
  1102. /**
  1103. * rt2x00queue_start_queues - Start all data queues
  1104. * @rt2x00dev: Pointer to &struct rt2x00_dev.
  1105. *
  1106. * This function will loop through all available queues to start them
  1107. */
  1108. void rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev);
  1109. /**
  1110. * rt2x00queue_stop_queues - Halt all data queues
  1111. * @rt2x00dev: Pointer to &struct rt2x00_dev.
  1112. *
  1113. * This function will loop through all available queues to stop
  1114. * any pending frames.
  1115. */
  1116. void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev);
  1117. /**
  1118. * rt2x00queue_flush_queues - Flush all data queues
  1119. * @rt2x00dev: Pointer to &struct rt2x00_dev.
  1120. * @drop: True to drop all pending frames.
  1121. *
  1122. * This function will loop through all available queues to flush
  1123. * any pending frames.
  1124. */
  1125. void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop);
  1126. /*
  1127. * Debugfs handlers.
  1128. */
  1129. /**
  1130. * rt2x00debug_dump_frame - Dump a frame to userspace through debugfs.
  1131. * @rt2x00dev: Pointer to &struct rt2x00_dev.
  1132. * @type: The type of frame that is being dumped.
  1133. * @skb: The skb containing the frame to be dumped.
  1134. */
  1135. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  1136. void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
  1137. enum rt2x00_dump_type type, struct sk_buff *skb);
  1138. #else
  1139. static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
  1140. enum rt2x00_dump_type type,
  1141. struct sk_buff *skb)
  1142. {
  1143. }
  1144. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  1145. /*
  1146. * Utility functions.
  1147. */
  1148. u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
  1149. struct ieee80211_vif *vif);
  1150. /*
  1151. * Interrupt context handlers.
  1152. */
  1153. void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
  1154. void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev);
  1155. void rt2x00lib_dmastart(struct queue_entry *entry);
  1156. void rt2x00lib_dmadone(struct queue_entry *entry);
  1157. void rt2x00lib_txdone(struct queue_entry *entry,
  1158. struct txdone_entry_desc *txdesc);
  1159. void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status);
  1160. void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp);
  1161. /*
  1162. * mac80211 handlers.
  1163. */
  1164. void rt2x00mac_tx(struct ieee80211_hw *hw,
  1165. struct ieee80211_tx_control *control,
  1166. struct sk_buff *skb);
  1167. int rt2x00mac_start(struct ieee80211_hw *hw);
  1168. void rt2x00mac_stop(struct ieee80211_hw *hw);
  1169. int rt2x00mac_add_interface(struct ieee80211_hw *hw,
  1170. struct ieee80211_vif *vif);
  1171. void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
  1172. struct ieee80211_vif *vif);
  1173. int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
  1174. void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
  1175. unsigned int changed_flags,
  1176. unsigned int *total_flags,
  1177. u64 multicast);
  1178. int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  1179. bool set);
  1180. #ifdef CONFIG_RT2X00_LIB_CRYPTO
  1181. int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  1182. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  1183. struct ieee80211_key_conf *key);
  1184. #else
  1185. #define rt2x00mac_set_key NULL
  1186. #endif /* CONFIG_RT2X00_LIB_CRYPTO */
  1187. int rt2x00mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1188. struct ieee80211_sta *sta);
  1189. int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1190. struct ieee80211_sta *sta);
  1191. void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw);
  1192. void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw);
  1193. int rt2x00mac_get_stats(struct ieee80211_hw *hw,
  1194. struct ieee80211_low_level_stats *stats);
  1195. void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
  1196. struct ieee80211_vif *vif,
  1197. struct ieee80211_bss_conf *bss_conf,
  1198. u32 changes);
  1199. int rt2x00mac_conf_tx(struct ieee80211_hw *hw,
  1200. struct ieee80211_vif *vif, u16 queue,
  1201. const struct ieee80211_tx_queue_params *params);
  1202. void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw);
  1203. void rt2x00mac_flush(struct ieee80211_hw *hw, u32 queues, bool drop);
  1204. int rt2x00mac_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
  1205. int rt2x00mac_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
  1206. void rt2x00mac_get_ringparam(struct ieee80211_hw *hw,
  1207. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
  1208. bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw);
  1209. /*
  1210. * Driver allocation handlers.
  1211. */
  1212. int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
  1213. void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
  1214. #ifdef CONFIG_PM
  1215. int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);
  1216. int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
  1217. #endif /* CONFIG_PM */
  1218. #endif /* RT2X00_H */