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