rt2x00.h 35 KB

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