rt2x00.h 37 KB

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