rt2x00.h 34 KB

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