rt2x00.h 37 KB

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