rt2x00.h 34 KB

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