rt2x00.h 37 KB

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