iwl-dev.h 34 KB

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