iwl-dev.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. /*
  27. * Please use this file (iwl-dev.h) for driver implementation definitions.
  28. * Please use iwl-commands.h for uCode API definitions.
  29. * Please use iwl-4965-hw.h for hardware-related definitions.
  30. */
  31. #ifndef __iwl_dev_h__
  32. #define __iwl_dev_h__
  33. #include <linux/pci.h> /* for struct pci_device_id */
  34. #include <linux/kernel.h>
  35. #include <net/ieee80211_radiotap.h>
  36. #include "iwl-eeprom.h"
  37. #include "iwl-csr.h"
  38. #include "iwl-prph.h"
  39. #include "iwl-fh.h"
  40. #include "iwl-debug.h"
  41. #include "iwl-4965-hw.h"
  42. #include "iwl-3945-hw.h"
  43. #include "iwl-3945-led.h"
  44. #include "iwl-led.h"
  45. #include "iwl-power.h"
  46. #include "iwl-agn-rs.h"
  47. /* configuration for the iwl4965 */
  48. extern struct iwl_cfg iwl4965_agn_cfg;
  49. extern struct iwl_cfg iwl5300_agn_cfg;
  50. extern struct iwl_cfg iwl5100_agn_cfg;
  51. extern struct iwl_cfg iwl5350_agn_cfg;
  52. extern struct iwl_cfg iwl5100_bg_cfg;
  53. extern struct iwl_cfg iwl5100_abg_cfg;
  54. extern struct iwl_cfg iwl5150_agn_cfg;
  55. extern struct iwl_cfg iwl6000h_2agn_cfg;
  56. extern struct iwl_cfg iwl6000i_2agn_cfg;
  57. extern struct iwl_cfg iwl6000_3agn_cfg;
  58. extern struct iwl_cfg iwl6050_2agn_cfg;
  59. extern struct iwl_cfg iwl6050_3agn_cfg;
  60. extern struct iwl_cfg iwl1000_bgn_cfg;
  61. struct iwl_tx_queue;
  62. /* shared structures from iwl-5000.c */
  63. extern struct iwl_mod_params iwl50_mod_params;
  64. extern struct iwl_ops iwl5000_ops;
  65. extern struct iwl_ucode_ops iwl5000_ucode;
  66. extern struct iwl_lib_ops iwl5000_lib;
  67. extern struct iwl_hcmd_ops iwl5000_hcmd;
  68. extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
  69. /* shared functions from iwl-5000.c */
  70. extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
  71. extern u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd,
  72. u8 *data);
  73. extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
  74. __le32 *tx_flags);
  75. extern int iwl5000_calc_rssi(struct iwl_priv *priv,
  76. struct iwl_rx_phy_res *rx_resp);
  77. extern int iwl5000_apm_init(struct iwl_priv *priv);
  78. extern void iwl5000_apm_stop(struct iwl_priv *priv);
  79. extern int iwl5000_apm_reset(struct iwl_priv *priv);
  80. extern void iwl5000_nic_config(struct iwl_priv *priv);
  81. extern u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv);
  82. extern const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
  83. size_t offset);
  84. extern void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  85. struct iwl_tx_queue *txq,
  86. u16 byte_cnt);
  87. extern void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  88. struct iwl_tx_queue *txq);
  89. extern int iwl5000_load_ucode(struct iwl_priv *priv);
  90. extern void iwl5000_init_alive_start(struct iwl_priv *priv);
  91. extern int iwl5000_alive_notify(struct iwl_priv *priv);
  92. extern int iwl5000_hw_set_hw_params(struct iwl_priv *priv);
  93. extern int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  94. int tx_fifo, int sta_id, int tid, u16 ssn_idx);
  95. extern int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  96. u16 ssn_idx, u8 tx_fifo);
  97. extern void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask);
  98. extern void iwl5000_setup_deferred_work(struct iwl_priv *priv);
  99. extern void iwl5000_rx_handler_setup(struct iwl_priv *priv);
  100. extern int iwl5000_hw_valid_rtc_data_addr(u32 addr);
  101. extern int iwl5000_send_tx_power(struct iwl_priv *priv);
  102. extern void iwl5000_temperature(struct iwl_priv *priv);
  103. /* CT-KILL constants */
  104. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  105. #define CT_KILL_THRESHOLD 114 /* in Celsius */
  106. #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
  107. /* Default noise level to report when noise measurement is not available.
  108. * This may be because we're:
  109. * 1) Not associated (4965, no beacon statistics being sent to driver)
  110. * 2) Scanning (noise measurement does not apply to associated channel)
  111. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  112. * Use default noise value of -127 ... this is below the range of measurable
  113. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  114. * Also, -127 works better than 0 when averaging frames with/without
  115. * noise info (e.g. averaging might be done in app); measured dBm values are
  116. * always negative ... using a negative value as the default keeps all
  117. * averages within an s8's (used in some apps) range of negative values. */
  118. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  119. /*
  120. * RTS threshold here is total size [2347] minus 4 FCS bytes
  121. * Per spec:
  122. * a value of 0 means RTS on all data/management packets
  123. * a value > max MSDU size means no RTS
  124. * else RTS for data/management frames where MPDU is larger
  125. * than RTS value.
  126. */
  127. #define DEFAULT_RTS_THRESHOLD 2347U
  128. #define MIN_RTS_THRESHOLD 0U
  129. #define MAX_RTS_THRESHOLD 2347U
  130. #define MAX_MSDU_SIZE 2304U
  131. #define MAX_MPDU_SIZE 2346U
  132. #define DEFAULT_BEACON_INTERVAL 100U
  133. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  134. #define DEFAULT_LONG_RETRY_LIMIT 4U
  135. struct iwl_rx_mem_buffer {
  136. dma_addr_t real_dma_addr;
  137. dma_addr_t aligned_dma_addr;
  138. struct sk_buff *skb;
  139. struct list_head list;
  140. };
  141. /* defined below */
  142. struct iwl_device_cmd;
  143. struct iwl_cmd_meta {
  144. /* only for SYNC commands, iff the reply skb is wanted */
  145. struct iwl_host_cmd *source;
  146. /*
  147. * only for ASYNC commands
  148. * (which is somewhat stupid -- look at iwl-sta.c for instance
  149. * which duplicates a bunch of code because the callback isn't
  150. * invoked for SYNC commands, if it were and its result passed
  151. * through it would be simpler...)
  152. */
  153. void (*callback)(struct iwl_priv *priv,
  154. struct iwl_device_cmd *cmd,
  155. struct sk_buff *skb);
  156. /* The CMD_SIZE_HUGE flag bit indicates that the command
  157. * structure is stored at the end of the shared queue memory. */
  158. u32 flags;
  159. DECLARE_PCI_UNMAP_ADDR(mapping)
  160. DECLARE_PCI_UNMAP_LEN(len)
  161. };
  162. /*
  163. * Generic queue structure
  164. *
  165. * Contains common data for Rx and Tx queues
  166. */
  167. struct iwl_queue {
  168. int n_bd; /* number of BDs in this queue */
  169. int write_ptr; /* 1-st empty entry (index) host_w*/
  170. int read_ptr; /* last used entry (index) host_r*/
  171. dma_addr_t dma_addr; /* physical addr for BD's */
  172. int n_window; /* safe queue window */
  173. u32 id;
  174. int low_mark; /* low watermark, resume queue if free
  175. * space more than this */
  176. int high_mark; /* high watermark, stop queue if free
  177. * space less than this */
  178. } __attribute__ ((packed));
  179. /* One for each TFD */
  180. struct iwl_tx_info {
  181. struct sk_buff *skb[IWL_NUM_OF_TBS - 1];
  182. };
  183. /**
  184. * struct iwl_tx_queue - Tx Queue for DMA
  185. * @q: generic Rx/Tx queue descriptor
  186. * @bd: base of circular buffer of TFDs
  187. * @cmd: array of command/TX buffer pointers
  188. * @meta: array of meta data for each command/tx buffer
  189. * @dma_addr_cmd: physical address of cmd/tx buffer array
  190. * @txb: array of per-TFD driver data
  191. * @need_update: indicates need to update read/write index
  192. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  193. *
  194. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  195. * descriptors) and required locking structures.
  196. */
  197. #define TFD_TX_CMD_SLOTS 256
  198. #define TFD_CMD_SLOTS 32
  199. struct iwl_tx_queue {
  200. struct iwl_queue q;
  201. void *tfds;
  202. struct iwl_device_cmd **cmd;
  203. struct iwl_cmd_meta *meta;
  204. struct iwl_tx_info *txb;
  205. u8 need_update;
  206. u8 sched_retry;
  207. u8 active;
  208. u8 swq_id;
  209. };
  210. #define IWL_NUM_SCAN_RATES (2)
  211. struct iwl4965_channel_tgd_info {
  212. u8 type;
  213. s8 max_power;
  214. };
  215. struct iwl4965_channel_tgh_info {
  216. s64 last_radar_time;
  217. };
  218. #define IWL4965_MAX_RATE (33)
  219. struct iwl3945_clip_group {
  220. /* maximum power level to prevent clipping for each rate, derived by
  221. * us from this band's saturation power in EEPROM */
  222. const s8 clip_powers[IWL_MAX_RATES];
  223. };
  224. /* current Tx power values to use, one for each rate for each channel.
  225. * requested power is limited by:
  226. * -- regulatory EEPROM limits for this channel
  227. * -- hardware capabilities (clip-powers)
  228. * -- spectrum management
  229. * -- user preference (e.g. iwconfig)
  230. * when requested power is set, base power index must also be set. */
  231. struct iwl3945_channel_power_info {
  232. struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
  233. s8 power_table_index; /* actual (compenst'd) index into gain table */
  234. s8 base_power_index; /* gain index for power at factory temp. */
  235. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  236. };
  237. /* current scan Tx power values to use, one for each scan rate for each
  238. * channel. */
  239. struct iwl3945_scan_power_info {
  240. struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
  241. s8 power_table_index; /* actual (compenst'd) index into gain table */
  242. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  243. };
  244. /*
  245. * One for each channel, holds all channel setup data
  246. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  247. * with one another!
  248. */
  249. struct iwl_channel_info {
  250. struct iwl4965_channel_tgd_info tgd;
  251. struct iwl4965_channel_tgh_info tgh;
  252. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  253. struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  254. * FAT channel */
  255. u8 channel; /* channel number */
  256. u8 flags; /* flags copied from EEPROM */
  257. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  258. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  259. s8 min_power; /* always 0 */
  260. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  261. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  262. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  263. enum ieee80211_band band;
  264. /* FAT channel info */
  265. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  266. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  267. s8 fat_min_power; /* always 0 */
  268. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  269. u8 fat_flags; /* flags copied from EEPROM */
  270. u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  271. /* Radio/DSP gain settings for each "normal" data Tx rate.
  272. * These include, in addition to RF and DSP gain, a few fields for
  273. * remembering/modifying gain settings (indexes). */
  274. struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
  275. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  276. struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  277. };
  278. #define IWL_TX_FIFO_AC0 0
  279. #define IWL_TX_FIFO_AC1 1
  280. #define IWL_TX_FIFO_AC2 2
  281. #define IWL_TX_FIFO_AC3 3
  282. #define IWL_TX_FIFO_HCCA_1 5
  283. #define IWL_TX_FIFO_HCCA_2 6
  284. #define IWL_TX_FIFO_NONE 7
  285. /* Minimum number of queues. MAX_NUM is defined in hw specific files.
  286. * Set the minimum to accommodate the 4 standard TX queues, 1 command
  287. * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
  288. #define IWL_MIN_NUM_QUEUES 10
  289. /* Power management (not Tx power) structures */
  290. enum iwl_pwr_src {
  291. IWL_PWR_SRC_VMAIN,
  292. IWL_PWR_SRC_VAUX,
  293. };
  294. #define IEEE80211_DATA_LEN 2304
  295. #define IEEE80211_4ADDR_LEN 30
  296. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  297. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  298. struct iwl_frame {
  299. union {
  300. struct ieee80211_hdr frame;
  301. struct iwl_tx_beacon_cmd beacon;
  302. u8 raw[IEEE80211_FRAME_LEN];
  303. u8 cmd[360];
  304. } u;
  305. struct list_head list;
  306. };
  307. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  308. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  309. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  310. enum {
  311. CMD_SYNC = 0,
  312. CMD_SIZE_NORMAL = 0,
  313. CMD_NO_SKB = 0,
  314. CMD_SIZE_HUGE = (1 << 0),
  315. CMD_ASYNC = (1 << 1),
  316. CMD_WANT_SKB = (1 << 2),
  317. };
  318. #define IWL_CMD_MAX_PAYLOAD 320
  319. /**
  320. * struct iwl_device_cmd
  321. *
  322. * For allocation of the command and tx queues, this establishes the overall
  323. * size of the largest command we send to uCode, except for a scan command
  324. * (which is relatively huge; space is allocated separately).
  325. */
  326. struct iwl_device_cmd {
  327. struct iwl_cmd_header hdr; /* uCode API */
  328. union {
  329. u32 flags;
  330. u8 val8;
  331. u16 val16;
  332. u32 val32;
  333. struct iwl_tx_cmd tx;
  334. u8 payload[IWL_CMD_MAX_PAYLOAD];
  335. } __attribute__ ((packed)) cmd;
  336. } __attribute__ ((packed));
  337. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
  338. struct iwl_host_cmd {
  339. const void *data;
  340. struct sk_buff *reply_skb;
  341. void (*callback)(struct iwl_priv *priv,
  342. struct iwl_device_cmd *cmd,
  343. struct sk_buff *skb);
  344. u32 flags;
  345. u16 len;
  346. u8 id;
  347. };
  348. /*
  349. * RX related structures and functions
  350. */
  351. #define RX_FREE_BUFFERS 64
  352. #define RX_LOW_WATERMARK 8
  353. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  354. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  355. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  356. /**
  357. * struct iwl_rx_queue - Rx queue
  358. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
  359. * @dma_addr: bus address of buffer of receive buffer descriptors (rbd)
  360. * @read: Shared index to newest available Rx buffer
  361. * @write: Shared index to oldest written Rx packet
  362. * @free_count: Number of pre-allocated buffers in rx_free
  363. * @rx_free: list of free SKBs for use
  364. * @rx_used: List of Rx buffers with no SKB
  365. * @need_update: flag to indicate we need to update read/write index
  366. * @rb_stts: driver's pointer to receive buffer status
  367. * @rb_stts_dma: bus address of receive buffer status
  368. *
  369. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  370. */
  371. struct iwl_rx_queue {
  372. __le32 *bd;
  373. dma_addr_t dma_addr;
  374. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  375. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  376. u32 read;
  377. u32 write;
  378. u32 free_count;
  379. u32 write_actual;
  380. struct list_head rx_free;
  381. struct list_head rx_used;
  382. int need_update;
  383. struct iwl_rb_status *rb_stts;
  384. dma_addr_t rb_stts_dma;
  385. spinlock_t lock;
  386. };
  387. #define IWL_SUPPORTED_RATES_IE_LEN 8
  388. #define MAX_TID_COUNT 9
  389. #define IWL_INVALID_RATE 0xFF
  390. #define IWL_INVALID_VALUE -1
  391. /**
  392. * struct iwl_ht_agg -- aggregation status while waiting for block-ack
  393. * @txq_id: Tx queue used for Tx attempt
  394. * @frame_count: # frames attempted by Tx command
  395. * @wait_for_ba: Expect block-ack before next Tx reply
  396. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
  397. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
  398. * @bitmap1: High order, one bit for each frame pending ACK in Tx window
  399. * @rate_n_flags: Rate at which Tx was attempted
  400. *
  401. * If REPLY_TX indicates that aggregation was attempted, driver must wait
  402. * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
  403. * until block ack arrives.
  404. */
  405. struct iwl_ht_agg {
  406. u16 txq_id;
  407. u16 frame_count;
  408. u16 wait_for_ba;
  409. u16 start_idx;
  410. u64 bitmap;
  411. u32 rate_n_flags;
  412. #define IWL_AGG_OFF 0
  413. #define IWL_AGG_ON 1
  414. #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
  415. #define IWL_EMPTYING_HW_QUEUE_DELBA 3
  416. u8 state;
  417. };
  418. struct iwl_tid_data {
  419. u16 seq_number;
  420. u16 tfds_in_queue;
  421. struct iwl_ht_agg agg;
  422. };
  423. struct iwl_hw_key {
  424. enum ieee80211_key_alg alg;
  425. int keylen;
  426. u8 keyidx;
  427. u8 key[32];
  428. };
  429. union iwl_ht_rate_supp {
  430. u16 rates;
  431. struct {
  432. u8 siso_rate;
  433. u8 mimo_rate;
  434. };
  435. };
  436. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  437. /*
  438. * Maximal MPDU density for TX aggregation
  439. * 4 - 2us density
  440. * 5 - 4us density
  441. * 6 - 8us density
  442. * 7 - 16us density
  443. */
  444. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  445. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  446. struct iwl_ht_info {
  447. /* self configuration data */
  448. u8 is_ht;
  449. u8 supported_chan_width;
  450. u8 sm_ps;
  451. u8 is_green_field;
  452. u8 sgf; /* HT_SHORT_GI_* short guard interval */
  453. u8 max_amsdu_size;
  454. u8 ampdu_factor;
  455. u8 mpdu_density;
  456. struct ieee80211_mcs_info mcs;
  457. /* BSS related data */
  458. u8 extension_chan_offset;
  459. u8 tx_chan_width;
  460. u8 ht_protection;
  461. u8 non_GF_STA_present;
  462. };
  463. union iwl_qos_capabity {
  464. struct {
  465. u8 edca_count:4; /* bit 0-3 */
  466. u8 q_ack:1; /* bit 4 */
  467. u8 queue_request:1; /* bit 5 */
  468. u8 txop_request:1; /* bit 6 */
  469. u8 reserved:1; /* bit 7 */
  470. } q_AP;
  471. struct {
  472. u8 acvo_APSD:1; /* bit 0 */
  473. u8 acvi_APSD:1; /* bit 1 */
  474. u8 ac_bk_APSD:1; /* bit 2 */
  475. u8 ac_be_APSD:1; /* bit 3 */
  476. u8 q_ack:1; /* bit 4 */
  477. u8 max_len:2; /* bit 5-6 */
  478. u8 more_data_ack:1; /* bit 7 */
  479. } q_STA;
  480. u8 val;
  481. };
  482. /* QoS structures */
  483. struct iwl_qos_info {
  484. int qos_active;
  485. union iwl_qos_capabity qos_cap;
  486. struct iwl_qosparam_cmd def_qos_parm;
  487. };
  488. #define STA_PS_STATUS_WAKE 0
  489. #define STA_PS_STATUS_SLEEP 1
  490. struct iwl3945_station_entry {
  491. struct iwl3945_addsta_cmd sta;
  492. struct iwl_tid_data tid[MAX_TID_COUNT];
  493. u8 used;
  494. u8 ps_status;
  495. struct iwl_hw_key keyinfo;
  496. };
  497. struct iwl_station_entry {
  498. struct iwl_addsta_cmd sta;
  499. struct iwl_tid_data tid[MAX_TID_COUNT];
  500. u8 used;
  501. u8 ps_status;
  502. struct iwl_hw_key keyinfo;
  503. };
  504. /* one for each uCode image (inst/data, boot/init/runtime) */
  505. struct fw_desc {
  506. void *v_addr; /* access by driver */
  507. dma_addr_t p_addr; /* access by card's busmaster DMA */
  508. u32 len; /* bytes */
  509. };
  510. /* uCode file layout */
  511. struct iwl_ucode_header {
  512. __le32 ver; /* major/minor/API/serial */
  513. union {
  514. struct {
  515. __le32 inst_size; /* bytes of runtime code */
  516. __le32 data_size; /* bytes of runtime data */
  517. __le32 init_size; /* bytes of init code */
  518. __le32 init_data_size; /* bytes of init data */
  519. __le32 boot_size; /* bytes of bootstrap code */
  520. u8 data[0]; /* in same order as sizes */
  521. } v1;
  522. struct {
  523. __le32 build; /* build number */
  524. __le32 inst_size; /* bytes of runtime code */
  525. __le32 data_size; /* bytes of runtime data */
  526. __le32 init_size; /* bytes of init code */
  527. __le32 init_data_size; /* bytes of init data */
  528. __le32 boot_size; /* bytes of bootstrap code */
  529. u8 data[0]; /* in same order as sizes */
  530. } v2;
  531. } u;
  532. };
  533. #define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28)
  534. struct iwl4965_ibss_seq {
  535. u8 mac[ETH_ALEN];
  536. u16 seq_num;
  537. u16 frag_num;
  538. unsigned long packet_time;
  539. struct list_head list;
  540. };
  541. struct iwl_sensitivity_ranges {
  542. u16 min_nrg_cck;
  543. u16 max_nrg_cck;
  544. u16 nrg_th_cck;
  545. u16 nrg_th_ofdm;
  546. u16 auto_corr_min_ofdm;
  547. u16 auto_corr_min_ofdm_mrc;
  548. u16 auto_corr_min_ofdm_x1;
  549. u16 auto_corr_min_ofdm_mrc_x1;
  550. u16 auto_corr_max_ofdm;
  551. u16 auto_corr_max_ofdm_mrc;
  552. u16 auto_corr_max_ofdm_x1;
  553. u16 auto_corr_max_ofdm_mrc_x1;
  554. u16 auto_corr_max_cck;
  555. u16 auto_corr_max_cck_mrc;
  556. u16 auto_corr_min_cck;
  557. u16 auto_corr_min_cck_mrc;
  558. };
  559. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  560. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  561. /**
  562. * struct iwl_hw_params
  563. * @max_txq_num: Max # Tx queues supported
  564. * @dma_chnl_num: Number of Tx DMA/FIFO channels
  565. * @scd_bc_tbls_size: size of scheduler byte count tables
  566. * @tfd_size: TFD size
  567. * @tx/rx_chains_num: Number of TX/RX chains
  568. * @valid_tx/rx_ant: usable antennas
  569. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  570. * @max_rxq_log: Log-base-2 of max_rxq_size
  571. * @rx_buf_size: Rx buffer size
  572. * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  573. * @max_stations:
  574. * @bcast_sta_id:
  575. * @fat_channel: is 40MHz width possible in band 2.4
  576. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  577. * @sw_crypto: 0 for hw, 1 for sw
  578. * @max_xxx_size: for ucode uses
  579. * @ct_kill_threshold: temperature threshold
  580. * @calib_init_cfg: setup initial calibrations for the hw
  581. * @struct iwl_sensitivity_ranges: range of sensitivity values
  582. */
  583. struct iwl_hw_params {
  584. u8 max_txq_num;
  585. u8 dma_chnl_num;
  586. u16 scd_bc_tbls_size;
  587. u32 tfd_size;
  588. u8 tx_chains_num;
  589. u8 rx_chains_num;
  590. u8 valid_tx_ant;
  591. u8 valid_rx_ant;
  592. u16 max_rxq_size;
  593. u16 max_rxq_log;
  594. u32 rx_buf_size;
  595. u32 rx_wrt_ptr_reg;
  596. u32 max_pkt_size;
  597. u8 max_stations;
  598. u8 bcast_sta_id;
  599. u8 fat_channel;
  600. u8 max_beacon_itrvl; /* in 1024 ms */
  601. u32 max_inst_size;
  602. u32 max_data_size;
  603. u32 max_bsm_size;
  604. u32 ct_kill_threshold; /* value in hw-dependent units */
  605. u32 ct_kill_exit_threshold; /* value in hw-dependent units */
  606. /* for 1000, 6000 series and up */
  607. u32 calib_init_cfg;
  608. const struct iwl_sensitivity_ranges *sens;
  609. };
  610. /******************************************************************************
  611. *
  612. * Functions implemented in core module which are forward declared here
  613. * for use by iwl-[4-5].c
  614. *
  615. * NOTE: The implementation of these functions are not hardware specific
  616. * which is why they are in the core module files.
  617. *
  618. * Naming convention --
  619. * iwl_ <-- Is part of iwlwifi
  620. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  621. * iwl4965_bg_ <-- Called from work queue context
  622. * iwl4965_mac_ <-- mac80211 callback
  623. *
  624. ****************************************************************************/
  625. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  626. extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
  627. extern const u8 iwl_bcast_addr[ETH_ALEN];
  628. extern int iwl_rxq_stop(struct iwl_priv *priv);
  629. extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
  630. extern int iwl_queue_space(const struct iwl_queue *q);
  631. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  632. {
  633. return q->write_ptr > q->read_ptr ?
  634. (i >= q->read_ptr && i < q->write_ptr) :
  635. !(i < q->read_ptr && i >= q->write_ptr);
  636. }
  637. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
  638. {
  639. /* This is for scan command, the big buffer at end of command array */
  640. if (is_huge)
  641. return q->n_window; /* must be power of 2 */
  642. /* Otherwise, use normal size buffers */
  643. return index & (q->n_window - 1);
  644. }
  645. struct iwl_dma_ptr {
  646. dma_addr_t dma;
  647. void *addr;
  648. size_t size;
  649. };
  650. #define HT_SHORT_GI_20MHZ (1 << 0)
  651. #define HT_SHORT_GI_40MHZ (1 << 1)
  652. #define IWL_CHANNEL_WIDTH_20MHZ 0
  653. #define IWL_CHANNEL_WIDTH_40MHZ 1
  654. #define IWL_OPERATION_MODE_AUTO 0
  655. #define IWL_OPERATION_MODE_HT_ONLY 1
  656. #define IWL_OPERATION_MODE_MIXED 2
  657. #define IWL_OPERATION_MODE_20MHZ 3
  658. #define IWL_TX_CRC_SIZE 4
  659. #define IWL_TX_DELIMITER_SIZE 4
  660. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  661. /* Sensitivity and chain noise calibration */
  662. #define INITIALIZATION_VALUE 0xFFFF
  663. #define CAL_NUM_OF_BEACONS 20
  664. #define MAXIMUM_ALLOWED_PATHLOSS 15
  665. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  666. #define MAX_FA_OFDM 50
  667. #define MIN_FA_OFDM 5
  668. #define MAX_FA_CCK 50
  669. #define MIN_FA_CCK 5
  670. #define AUTO_CORR_STEP_OFDM 1
  671. #define AUTO_CORR_STEP_CCK 3
  672. #define AUTO_CORR_MAX_TH_CCK 160
  673. #define NRG_DIFF 2
  674. #define NRG_STEP_CCK 2
  675. #define NRG_MARGIN 8
  676. #define MAX_NUMBER_CCK_NO_FA 100
  677. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  678. #define CHAIN_A 0
  679. #define CHAIN_B 1
  680. #define CHAIN_C 2
  681. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  682. #define ALL_BAND_FILTER 0xFF00
  683. #define IN_BAND_FILTER 0xFF
  684. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  685. #define NRG_NUM_PREV_STAT_L 20
  686. #define NUM_RX_CHAINS 3
  687. enum iwl4965_false_alarm_state {
  688. IWL_FA_TOO_MANY = 0,
  689. IWL_FA_TOO_FEW = 1,
  690. IWL_FA_GOOD_RANGE = 2,
  691. };
  692. enum iwl4965_chain_noise_state {
  693. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  694. IWL_CHAIN_NOISE_ACCUMULATE,
  695. IWL_CHAIN_NOISE_CALIBRATED,
  696. IWL_CHAIN_NOISE_DONE,
  697. };
  698. enum iwl4965_calib_enabled_state {
  699. IWL_CALIB_DISABLED = 0, /* must be 0 */
  700. IWL_CALIB_ENABLED = 1,
  701. };
  702. /*
  703. * enum iwl_calib
  704. * defines the order in which results of initial calibrations
  705. * should be sent to the runtime uCode
  706. */
  707. enum iwl_calib {
  708. IWL_CALIB_XTAL,
  709. IWL_CALIB_DC,
  710. IWL_CALIB_LO,
  711. IWL_CALIB_TX_IQ,
  712. IWL_CALIB_TX_IQ_PERD,
  713. IWL_CALIB_BASE_BAND,
  714. IWL_CALIB_MAX
  715. };
  716. /* Opaque calibration results */
  717. struct iwl_calib_result {
  718. void *buf;
  719. size_t buf_len;
  720. };
  721. #define UCODE_ALIVE_TIMEOUT (5 * HZ)
  722. enum ucode_type {
  723. UCODE_NONE = 0,
  724. UCODE_INIT,
  725. UCODE_RT
  726. };
  727. /* Sensitivity calib data */
  728. struct iwl_sensitivity_data {
  729. u32 auto_corr_ofdm;
  730. u32 auto_corr_ofdm_mrc;
  731. u32 auto_corr_ofdm_x1;
  732. u32 auto_corr_ofdm_mrc_x1;
  733. u32 auto_corr_cck;
  734. u32 auto_corr_cck_mrc;
  735. u32 last_bad_plcp_cnt_ofdm;
  736. u32 last_fa_cnt_ofdm;
  737. u32 last_bad_plcp_cnt_cck;
  738. u32 last_fa_cnt_cck;
  739. u32 nrg_curr_state;
  740. u32 nrg_prev_state;
  741. u32 nrg_value[10];
  742. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  743. u32 nrg_silence_ref;
  744. u32 nrg_energy_idx;
  745. u32 nrg_silence_idx;
  746. u32 nrg_th_cck;
  747. s32 nrg_auto_corr_silence_diff;
  748. u32 num_in_cck_no_fa;
  749. u32 nrg_th_ofdm;
  750. };
  751. /* Chain noise (differential Rx gain) calib data */
  752. struct iwl_chain_noise_data {
  753. u32 active_chains;
  754. u32 chain_noise_a;
  755. u32 chain_noise_b;
  756. u32 chain_noise_c;
  757. u32 chain_signal_a;
  758. u32 chain_signal_b;
  759. u32 chain_signal_c;
  760. u16 beacon_count;
  761. u8 disconn_array[NUM_RX_CHAINS];
  762. u8 delta_gain_code[NUM_RX_CHAINS];
  763. u8 radio_write;
  764. u8 state;
  765. };
  766. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  767. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  768. enum {
  769. MEASUREMENT_READY = (1 << 0),
  770. MEASUREMENT_ACTIVE = (1 << 1),
  771. };
  772. enum iwl_nvm_type {
  773. NVM_DEVICE_TYPE_EEPROM = 0,
  774. NVM_DEVICE_TYPE_OTP,
  775. };
  776. /**
  777. * enum iwl_pa_type - Power Amplifier type
  778. * @IWL_PA_SYSTEM: based on uCode configuration
  779. * @IWL_PA_HYBRID: use both Internal and external PA
  780. * @IWL_PA_INTERNAL: use Internal only
  781. */
  782. enum iwl_pa_type {
  783. IWL_PA_SYSTEM = 0,
  784. IWL_PA_HYBRID = 1,
  785. IWL_PA_INTERNAL = 2,
  786. };
  787. /* interrupt statistics */
  788. struct isr_statistics {
  789. u32 hw;
  790. u32 sw;
  791. u32 sw_err;
  792. u32 sch;
  793. u32 alive;
  794. u32 rfkill;
  795. u32 ctkill;
  796. u32 wakeup;
  797. u32 rx;
  798. u32 rx_handlers[REPLY_MAX];
  799. u32 tx;
  800. u32 unhandled;
  801. };
  802. #define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
  803. struct iwl_priv {
  804. /* ieee device used by generic ieee processing code */
  805. struct ieee80211_hw *hw;
  806. struct ieee80211_channel *ieee_channels;
  807. struct ieee80211_rate *ieee_rates;
  808. struct iwl_cfg *cfg;
  809. /* temporary frame storage list */
  810. struct list_head free_frames;
  811. int frames_count;
  812. enum ieee80211_band band;
  813. int alloc_rxb_skb;
  814. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  815. struct iwl_rx_mem_buffer *rxb);
  816. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  817. #if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT)
  818. /* spectrum measurement report caching */
  819. struct iwl_spectrum_notification measure_report;
  820. u8 measurement_status;
  821. #endif
  822. /* ucode beacon time */
  823. u32 ucode_beacon_time;
  824. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  825. * Access via channel # using indirect index array */
  826. struct iwl_channel_info *channel_info; /* channel info array */
  827. u8 channel_count; /* # of channels */
  828. /* each calibration channel group in the EEPROM has a derived
  829. * clip setting for each rate. 3945 only.*/
  830. const struct iwl3945_clip_group clip39_groups[5];
  831. /* thermal calibration */
  832. s32 temperature; /* degrees Kelvin */
  833. s32 last_temperature;
  834. /* init calibration results */
  835. struct iwl_calib_result calib_results[IWL_CALIB_MAX];
  836. /* Scan related variables */
  837. unsigned long last_scan_jiffies;
  838. unsigned long next_scan_jiffies;
  839. unsigned long scan_start;
  840. unsigned long scan_pass_start;
  841. unsigned long scan_start_tsf;
  842. void *scan;
  843. int scan_bands;
  844. struct cfg80211_scan_request *scan_request;
  845. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  846. u8 mgmt_tx_ant;
  847. /* spinlock */
  848. spinlock_t lock; /* protect general shared data */
  849. spinlock_t hcmd_lock; /* protect hcmd */
  850. spinlock_t reg_lock; /* protect hw register access */
  851. struct mutex mutex;
  852. /* basic pci-network driver stuff */
  853. struct pci_dev *pci_dev;
  854. /* pci hardware address support */
  855. void __iomem *hw_base;
  856. u32 hw_rev;
  857. u32 hw_wa_rev;
  858. u8 rev_id;
  859. /* uCode images, save to reload in case of failure */
  860. u32 ucode_ver; /* version of ucode, copy of
  861. iwl_ucode.ver */
  862. struct fw_desc ucode_code; /* runtime inst */
  863. struct fw_desc ucode_data; /* runtime data original */
  864. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  865. struct fw_desc ucode_init; /* initialization inst */
  866. struct fw_desc ucode_init_data; /* initialization data */
  867. struct fw_desc ucode_boot; /* bootstrap inst */
  868. enum ucode_type ucode_type;
  869. u8 ucode_write_complete; /* the image write is complete */
  870. struct iwl_rxon_time_cmd rxon_timing;
  871. /* We declare this const so it can only be
  872. * changed via explicit cast within the
  873. * routines that actually update the physical
  874. * hardware */
  875. const struct iwl_rxon_cmd active_rxon;
  876. struct iwl_rxon_cmd staging_rxon;
  877. struct iwl_rxon_cmd recovery_rxon;
  878. /* 1st responses from initialize and runtime uCode images.
  879. * 4965's initialize alive response contains some calibration data. */
  880. struct iwl_init_alive_resp card_alive_init;
  881. struct iwl_alive_resp card_alive;
  882. #ifdef CONFIG_IWLWIFI_LEDS
  883. unsigned long last_blink_time;
  884. u8 last_blink_rate;
  885. u8 allow_blinking;
  886. u64 led_tpt;
  887. struct iwl_led led[IWL_LED_TRG_MAX];
  888. unsigned int rxtxpackets;
  889. #endif
  890. u16 active_rate;
  891. u16 active_rate_basic;
  892. u8 assoc_station_added;
  893. u8 start_calib;
  894. struct iwl_sensitivity_data sensitivity_data;
  895. struct iwl_chain_noise_data chain_noise_data;
  896. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  897. struct iwl_ht_info current_ht_config;
  898. u8 last_phy_res[100];
  899. /* Rate scaling data */
  900. s8 data_retry_limit;
  901. u8 retry_rate;
  902. wait_queue_head_t wait_command_queue;
  903. int activity_timer_active;
  904. /* Rx and Tx DMA processing queues */
  905. struct iwl_rx_queue rxq;
  906. struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
  907. unsigned long txq_ctx_active_msk;
  908. struct iwl_dma_ptr kw; /* keep warm address */
  909. struct iwl_dma_ptr scd_bc_tbls;
  910. u32 scd_base_addr; /* scheduler sram base address */
  911. unsigned long status;
  912. int last_rx_rssi; /* From Rx packet statistics */
  913. int last_rx_noise; /* From beacon statistics */
  914. /* counts mgmt, ctl, and data packets */
  915. struct traffic_stats {
  916. u32 cnt;
  917. u64 bytes;
  918. } tx_stats[3], rx_stats[3];
  919. /* counts interrupts */
  920. struct isr_statistics isr_stats;
  921. struct iwl_power_mgr power_data;
  922. struct iwl_notif_statistics statistics;
  923. unsigned long last_statistics_time;
  924. /* context information */
  925. u16 rates_mask;
  926. u32 power_mode;
  927. u8 bssid[ETH_ALEN];
  928. u16 rts_threshold;
  929. u8 mac_addr[ETH_ALEN];
  930. /*station table variables */
  931. spinlock_t sta_lock;
  932. int num_stations;
  933. struct iwl_station_entry stations[IWL_STATION_COUNT];
  934. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  935. u8 default_wep_key;
  936. u8 key_mapping_key;
  937. unsigned long ucode_key_table;
  938. /* queue refcounts */
  939. #define IWL_MAX_HW_QUEUES 32
  940. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  941. /* for each AC */
  942. atomic_t queue_stop_count[4];
  943. /* Indication if ieee80211_ops->open has been called */
  944. u8 is_open;
  945. u8 mac80211_registered;
  946. /* Rx'd packet timing information */
  947. u32 last_beacon_time;
  948. u64 last_tsf;
  949. /* eeprom */
  950. u8 *eeprom;
  951. int nvm_device_type;
  952. struct iwl_eeprom_calib_info *calib_info;
  953. enum nl80211_iftype iw_mode;
  954. struct sk_buff *ibss_beacon;
  955. /* Last Rx'd beacon timestamp */
  956. u64 timestamp;
  957. u16 beacon_int;
  958. struct ieee80211_vif *vif;
  959. /*Added for 3945 */
  960. void *shared_virt;
  961. dma_addr_t shared_phys;
  962. /*End*/
  963. struct iwl_hw_params hw_params;
  964. /* INT ICT Table */
  965. u32 *ict_tbl;
  966. dma_addr_t ict_tbl_dma;
  967. dma_addr_t aligned_ict_tbl_dma;
  968. int ict_index;
  969. void *ict_tbl_vir;
  970. u32 inta;
  971. bool use_ict;
  972. u32 inta_mask;
  973. /* Current association information needed to configure the
  974. * hardware */
  975. u16 assoc_id;
  976. u16 assoc_capability;
  977. struct iwl_qos_info qos_data;
  978. struct workqueue_struct *workqueue;
  979. struct work_struct up;
  980. struct work_struct restart;
  981. struct work_struct calibrated_work;
  982. struct work_struct scan_completed;
  983. struct work_struct rx_replenish;
  984. struct work_struct abort_scan;
  985. struct work_struct update_link_led;
  986. struct work_struct auth_work;
  987. struct work_struct report_work;
  988. struct work_struct request_scan;
  989. struct work_struct beacon_update;
  990. struct tasklet_struct irq_tasklet;
  991. struct delayed_work init_alive_start;
  992. struct delayed_work alive_start;
  993. struct delayed_work scan_check;
  994. /*For 3945 only*/
  995. struct delayed_work thermal_periodic;
  996. struct delayed_work rfkill_poll;
  997. /* TX Power */
  998. s8 tx_power_user_lmt;
  999. s8 tx_power_channel_lmt;
  1000. #ifdef CONFIG_IWLWIFI_DEBUG
  1001. /* debugging info */
  1002. u32 framecnt_to_us;
  1003. atomic_t restrict_refcnt;
  1004. bool disable_ht40;
  1005. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1006. /* debugfs */
  1007. struct iwl_debugfs *dbgfs;
  1008. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1009. #endif /* CONFIG_IWLWIFI_DEBUG */
  1010. struct work_struct txpower_work;
  1011. u32 disable_sens_cal;
  1012. u32 disable_chain_noise_cal;
  1013. u32 disable_tx_power_cal;
  1014. struct work_struct run_time_calib_work;
  1015. struct timer_list statistics_periodic;
  1016. bool hw_ready;
  1017. /*For 3945*/
  1018. #define IWL_DEFAULT_TX_POWER 0x0F
  1019. struct iwl3945_notif_statistics statistics_39;
  1020. u32 sta_supp_rates;
  1021. }; /*iwl_priv */
  1022. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  1023. {
  1024. set_bit(txq_id, &priv->txq_ctx_active_msk);
  1025. }
  1026. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  1027. {
  1028. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  1029. }
  1030. #ifdef CONFIG_IWLWIFI_DEBUG
  1031. const char *iwl_get_tx_fail_reason(u32 status);
  1032. #else
  1033. static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
  1034. #endif
  1035. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  1036. int txq_id, int idx)
  1037. {
  1038. if (priv->txq[txq_id].txb[idx].skb[0])
  1039. return (struct ieee80211_hdr *)priv->txq[txq_id].
  1040. txb[idx].skb[0]->data;
  1041. return NULL;
  1042. }
  1043. static inline int iwl_is_associated(struct iwl_priv *priv)
  1044. {
  1045. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1046. }
  1047. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1048. {
  1049. if (ch_info == NULL)
  1050. return 0;
  1051. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1052. }
  1053. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1054. {
  1055. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1056. }
  1057. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1058. {
  1059. return ch_info->band == IEEE80211_BAND_5GHZ;
  1060. }
  1061. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1062. {
  1063. return ch_info->band == IEEE80211_BAND_2GHZ;
  1064. }
  1065. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1066. {
  1067. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1068. }
  1069. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1070. {
  1071. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1072. }
  1073. #endif /* __iwl_dev_h__ */