rt2x00.h 35 KB

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