rt2x00.h 35 KB

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