iwl-dev.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365
  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-led.h"
  44. #include "iwl-power.h"
  45. #include "iwl-agn-rs.h"
  46. /* configuration for the iwl4965 */
  47. extern struct iwl_cfg iwl4965_agn_cfg;
  48. extern struct iwl_cfg iwl5300_agn_cfg;
  49. extern struct iwl_cfg iwl5100_agn_cfg;
  50. extern struct iwl_cfg iwl5350_agn_cfg;
  51. extern struct iwl_cfg iwl5100_bg_cfg;
  52. extern struct iwl_cfg iwl5100_abg_cfg;
  53. extern struct iwl_cfg iwl5150_agn_cfg;
  54. extern struct iwl_cfg iwl6000h_2agn_cfg;
  55. extern struct iwl_cfg iwl6000h_2abg_cfg;
  56. extern struct iwl_cfg iwl6000h_2bg_cfg;
  57. extern struct iwl_cfg iwl6000i_2agn_cfg;
  58. extern struct iwl_cfg iwl6000i_2abg_cfg;
  59. extern struct iwl_cfg iwl6000i_2bg_cfg;
  60. extern struct iwl_cfg iwl6000_3agn_cfg;
  61. extern struct iwl_cfg iwl6050_2agn_cfg;
  62. extern struct iwl_cfg iwl6050_2abg_cfg;
  63. extern struct iwl_cfg iwl6050_3agn_cfg;
  64. extern struct iwl_cfg iwl1000_bgn_cfg;
  65. extern struct iwl_cfg iwl1000_bg_cfg;
  66. struct iwl_tx_queue;
  67. /* shared structures from iwl-5000.c */
  68. extern struct iwl_mod_params iwl50_mod_params;
  69. extern struct iwl_ucode_ops iwl5000_ucode;
  70. extern struct iwl_lib_ops iwl5000_lib;
  71. extern struct iwl_hcmd_ops iwl5000_hcmd;
  72. extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
  73. /* shared functions from iwl-5000.c */
  74. extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
  75. extern u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd,
  76. u8 *data);
  77. extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
  78. __le32 *tx_flags);
  79. extern int iwl5000_calc_rssi(struct iwl_priv *priv,
  80. struct iwl_rx_phy_res *rx_resp);
  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 page_dma;
  138. struct page *page;
  139. struct list_head list;
  140. };
  141. #define rxb_addr(r) page_address(r->page)
  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 iwl_rx_packet *pkt);
  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 ht40_eeprom; /* EEPROM regulatory limit for
  255. * HT40 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. /* HT40 channel info */
  266. s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  267. s8 ht40_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  268. s8 ht40_min_power; /* always 0 */
  269. s8 ht40_scan_power; /* (dBm) eeprom, direct scans, any rate */
  270. u8 ht40_flags; /* flags copied from EEPROM */
  271. u8 ht40_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. /*
  291. * Queue #4 is the command queue for 3945/4965/5x00/1000/6x00,
  292. * the driver maps it into the appropriate device FIFO for the
  293. * uCode.
  294. */
  295. #define IWL_CMD_QUEUE_NUM 4
  296. /* Power management (not Tx power) structures */
  297. enum iwl_pwr_src {
  298. IWL_PWR_SRC_VMAIN,
  299. IWL_PWR_SRC_VAUX,
  300. };
  301. #define IEEE80211_DATA_LEN 2304
  302. #define IEEE80211_4ADDR_LEN 30
  303. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  304. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  305. struct iwl_frame {
  306. union {
  307. struct ieee80211_hdr frame;
  308. struct iwl_tx_beacon_cmd beacon;
  309. u8 raw[IEEE80211_FRAME_LEN];
  310. u8 cmd[360];
  311. } u;
  312. struct list_head list;
  313. };
  314. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  315. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  316. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  317. enum {
  318. CMD_SYNC = 0,
  319. CMD_SIZE_NORMAL = 0,
  320. CMD_NO_SKB = 0,
  321. CMD_SIZE_HUGE = (1 << 0),
  322. CMD_ASYNC = (1 << 1),
  323. CMD_WANT_SKB = (1 << 2),
  324. };
  325. #define DEF_CMD_PAYLOAD_SIZE 320
  326. /*
  327. * IWL_LINK_HDR_MAX should include ieee80211_hdr, radiotap header,
  328. * SNAP header and alignment. It should also be big enough for 802.11
  329. * control frames.
  330. */
  331. #define IWL_LINK_HDR_MAX 64
  332. /**
  333. * struct iwl_device_cmd
  334. *
  335. * For allocation of the command and tx queues, this establishes the overall
  336. * size of the largest command we send to uCode, except for a scan command
  337. * (which is relatively huge; space is allocated separately).
  338. */
  339. struct iwl_device_cmd {
  340. struct iwl_cmd_header hdr; /* uCode API */
  341. union {
  342. u32 flags;
  343. u8 val8;
  344. u16 val16;
  345. u32 val32;
  346. struct iwl_tx_cmd tx;
  347. struct iwl6000_channel_switch_cmd chswitch;
  348. u8 payload[DEF_CMD_PAYLOAD_SIZE];
  349. } __attribute__ ((packed)) cmd;
  350. } __attribute__ ((packed));
  351. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
  352. struct iwl_host_cmd {
  353. const void *data;
  354. unsigned long reply_page;
  355. void (*callback)(struct iwl_priv *priv,
  356. struct iwl_device_cmd *cmd,
  357. struct iwl_rx_packet *pkt);
  358. u32 flags;
  359. u16 len;
  360. u8 id;
  361. };
  362. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  363. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  364. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  365. /**
  366. * struct iwl_rx_queue - Rx queue
  367. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
  368. * @dma_addr: bus address of buffer of receive buffer descriptors (rbd)
  369. * @read: Shared index to newest available Rx buffer
  370. * @write: Shared index to oldest written Rx packet
  371. * @free_count: Number of pre-allocated buffers in rx_free
  372. * @rx_free: list of free SKBs for use
  373. * @rx_used: List of Rx buffers with no SKB
  374. * @need_update: flag to indicate we need to update read/write index
  375. * @rb_stts: driver's pointer to receive buffer status
  376. * @rb_stts_dma: bus address of receive buffer status
  377. *
  378. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  379. */
  380. struct iwl_rx_queue {
  381. __le32 *bd;
  382. dma_addr_t dma_addr;
  383. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  384. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  385. u32 read;
  386. u32 write;
  387. u32 free_count;
  388. u32 write_actual;
  389. struct list_head rx_free;
  390. struct list_head rx_used;
  391. int need_update;
  392. struct iwl_rb_status *rb_stts;
  393. dma_addr_t rb_stts_dma;
  394. spinlock_t lock;
  395. };
  396. #define IWL_SUPPORTED_RATES_IE_LEN 8
  397. #define MAX_TID_COUNT 9
  398. #define IWL_INVALID_RATE 0xFF
  399. #define IWL_INVALID_VALUE -1
  400. /**
  401. * struct iwl_ht_agg -- aggregation status while waiting for block-ack
  402. * @txq_id: Tx queue used for Tx attempt
  403. * @frame_count: # frames attempted by Tx command
  404. * @wait_for_ba: Expect block-ack before next Tx reply
  405. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
  406. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
  407. * @bitmap1: High order, one bit for each frame pending ACK in Tx window
  408. * @rate_n_flags: Rate at which Tx was attempted
  409. *
  410. * If REPLY_TX indicates that aggregation was attempted, driver must wait
  411. * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
  412. * until block ack arrives.
  413. */
  414. struct iwl_ht_agg {
  415. u16 txq_id;
  416. u16 frame_count;
  417. u16 wait_for_ba;
  418. u16 start_idx;
  419. u64 bitmap;
  420. u32 rate_n_flags;
  421. #define IWL_AGG_OFF 0
  422. #define IWL_AGG_ON 1
  423. #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
  424. #define IWL_EMPTYING_HW_QUEUE_DELBA 3
  425. u8 state;
  426. };
  427. struct iwl_tid_data {
  428. u16 seq_number;
  429. u16 tfds_in_queue;
  430. struct iwl_ht_agg agg;
  431. };
  432. struct iwl_hw_key {
  433. enum ieee80211_key_alg alg;
  434. int keylen;
  435. u8 keyidx;
  436. u8 key[32];
  437. };
  438. union iwl_ht_rate_supp {
  439. u16 rates;
  440. struct {
  441. u8 siso_rate;
  442. u8 mimo_rate;
  443. };
  444. };
  445. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  446. /*
  447. * Maximal MPDU density for TX aggregation
  448. * 4 - 2us density
  449. * 5 - 4us density
  450. * 6 - 8us density
  451. * 7 - 16us density
  452. */
  453. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  454. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  455. struct iwl_ht_config {
  456. /* self configuration data */
  457. bool is_ht;
  458. bool is_40mhz;
  459. bool single_chain_sufficient;
  460. u8 sm_ps;
  461. /* BSS related data */
  462. u8 extension_chan_offset;
  463. u8 ht_protection;
  464. u8 non_GF_STA_present;
  465. };
  466. union iwl_qos_capabity {
  467. struct {
  468. u8 edca_count:4; /* bit 0-3 */
  469. u8 q_ack:1; /* bit 4 */
  470. u8 queue_request:1; /* bit 5 */
  471. u8 txop_request:1; /* bit 6 */
  472. u8 reserved:1; /* bit 7 */
  473. } q_AP;
  474. struct {
  475. u8 acvo_APSD:1; /* bit 0 */
  476. u8 acvi_APSD:1; /* bit 1 */
  477. u8 ac_bk_APSD:1; /* bit 2 */
  478. u8 ac_be_APSD:1; /* bit 3 */
  479. u8 q_ack:1; /* bit 4 */
  480. u8 max_len:2; /* bit 5-6 */
  481. u8 more_data_ack:1; /* bit 7 */
  482. } q_STA;
  483. u8 val;
  484. };
  485. /* QoS structures */
  486. struct iwl_qos_info {
  487. int qos_active;
  488. union iwl_qos_capabity qos_cap;
  489. struct iwl_qosparam_cmd def_qos_parm;
  490. };
  491. #define STA_PS_STATUS_WAKE 0
  492. #define STA_PS_STATUS_SLEEP 1
  493. struct iwl3945_station_entry {
  494. struct iwl3945_addsta_cmd sta;
  495. struct iwl_tid_data tid[MAX_TID_COUNT];
  496. u8 used;
  497. u8 ps_status;
  498. struct iwl_hw_key keyinfo;
  499. };
  500. struct iwl_station_entry {
  501. struct iwl_addsta_cmd sta;
  502. struct iwl_tid_data tid[MAX_TID_COUNT];
  503. u8 used;
  504. u8 ps_status;
  505. struct iwl_hw_key keyinfo;
  506. };
  507. /*
  508. * iwl_station_priv: Driver's private station information
  509. *
  510. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  511. * in the structure for use by driver. This structure is places in that
  512. * space.
  513. *
  514. * At the moment use it for the station's rate scaling information.
  515. */
  516. struct iwl_station_priv {
  517. struct iwl_lq_sta lq_sta;
  518. };
  519. /* one for each uCode image (inst/data, boot/init/runtime) */
  520. struct fw_desc {
  521. void *v_addr; /* access by driver */
  522. dma_addr_t p_addr; /* access by card's busmaster DMA */
  523. u32 len; /* bytes */
  524. };
  525. /* uCode file layout */
  526. struct iwl_ucode_header {
  527. __le32 ver; /* major/minor/API/serial */
  528. union {
  529. struct {
  530. __le32 inst_size; /* bytes of runtime code */
  531. __le32 data_size; /* bytes of runtime data */
  532. __le32 init_size; /* bytes of init code */
  533. __le32 init_data_size; /* bytes of init data */
  534. __le32 boot_size; /* bytes of bootstrap code */
  535. u8 data[0]; /* in same order as sizes */
  536. } v1;
  537. struct {
  538. __le32 build; /* build number */
  539. __le32 inst_size; /* bytes of runtime code */
  540. __le32 data_size; /* bytes of runtime data */
  541. __le32 init_size; /* bytes of init code */
  542. __le32 init_data_size; /* bytes of init data */
  543. __le32 boot_size; /* bytes of bootstrap code */
  544. u8 data[0]; /* in same order as sizes */
  545. } v2;
  546. } u;
  547. };
  548. #define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28)
  549. struct iwl4965_ibss_seq {
  550. u8 mac[ETH_ALEN];
  551. u16 seq_num;
  552. u16 frag_num;
  553. unsigned long packet_time;
  554. struct list_head list;
  555. };
  556. struct iwl_sensitivity_ranges {
  557. u16 min_nrg_cck;
  558. u16 max_nrg_cck;
  559. u16 nrg_th_cck;
  560. u16 nrg_th_ofdm;
  561. u16 auto_corr_min_ofdm;
  562. u16 auto_corr_min_ofdm_mrc;
  563. u16 auto_corr_min_ofdm_x1;
  564. u16 auto_corr_min_ofdm_mrc_x1;
  565. u16 auto_corr_max_ofdm;
  566. u16 auto_corr_max_ofdm_mrc;
  567. u16 auto_corr_max_ofdm_x1;
  568. u16 auto_corr_max_ofdm_mrc_x1;
  569. u16 auto_corr_max_cck;
  570. u16 auto_corr_max_cck_mrc;
  571. u16 auto_corr_min_cck;
  572. u16 auto_corr_min_cck_mrc;
  573. u16 barker_corr_th_min;
  574. u16 barker_corr_th_min_mrc;
  575. u16 nrg_th_cca;
  576. };
  577. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  578. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  579. /**
  580. * struct iwl_hw_params
  581. * @max_txq_num: Max # Tx queues supported
  582. * @dma_chnl_num: Number of Tx DMA/FIFO channels
  583. * @scd_bc_tbls_size: size of scheduler byte count tables
  584. * @tfd_size: TFD size
  585. * @tx/rx_chains_num: Number of TX/RX chains
  586. * @valid_tx/rx_ant: usable antennas
  587. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  588. * @max_rxq_log: Log-base-2 of max_rxq_size
  589. * @rx_page_order: Rx buffer page order
  590. * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  591. * @max_stations:
  592. * @bcast_sta_id:
  593. * @ht40_channel: is 40MHz width possible in band 2.4
  594. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  595. * @sw_crypto: 0 for hw, 1 for sw
  596. * @max_xxx_size: for ucode uses
  597. * @ct_kill_threshold: temperature threshold
  598. * @calib_init_cfg: setup initial calibrations for the hw
  599. * @struct iwl_sensitivity_ranges: range of sensitivity values
  600. */
  601. struct iwl_hw_params {
  602. u8 max_txq_num;
  603. u8 dma_chnl_num;
  604. u16 scd_bc_tbls_size;
  605. u32 tfd_size;
  606. u8 tx_chains_num;
  607. u8 rx_chains_num;
  608. u8 valid_tx_ant;
  609. u8 valid_rx_ant;
  610. u16 max_rxq_size;
  611. u16 max_rxq_log;
  612. u32 rx_page_order;
  613. u32 rx_wrt_ptr_reg;
  614. u8 max_stations;
  615. u8 bcast_sta_id;
  616. u8 ht40_channel;
  617. u8 max_beacon_itrvl; /* in 1024 ms */
  618. u32 max_inst_size;
  619. u32 max_data_size;
  620. u32 max_bsm_size;
  621. u32 ct_kill_threshold; /* value in hw-dependent units */
  622. u32 ct_kill_exit_threshold; /* value in hw-dependent units */
  623. /* for 1000, 6000 series and up */
  624. u32 calib_init_cfg;
  625. const struct iwl_sensitivity_ranges *sens;
  626. };
  627. /******************************************************************************
  628. *
  629. * Functions implemented in core module which are forward declared here
  630. * for use by iwl-[4-5].c
  631. *
  632. * NOTE: The implementation of these functions are not hardware specific
  633. * which is why they are in the core module files.
  634. *
  635. * Naming convention --
  636. * iwl_ <-- Is part of iwlwifi
  637. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  638. * iwl4965_bg_ <-- Called from work queue context
  639. * iwl4965_mac_ <-- mac80211 callback
  640. *
  641. ****************************************************************************/
  642. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  643. extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
  644. extern const u8 iwl_bcast_addr[ETH_ALEN];
  645. extern int iwl_rxq_stop(struct iwl_priv *priv);
  646. extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
  647. extern int iwl_queue_space(const struct iwl_queue *q);
  648. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  649. {
  650. return q->write_ptr > q->read_ptr ?
  651. (i >= q->read_ptr && i < q->write_ptr) :
  652. !(i < q->read_ptr && i >= q->write_ptr);
  653. }
  654. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
  655. {
  656. /*
  657. * This is for init calibration result and scan command which
  658. * required buffer > TFD_MAX_PAYLOAD_SIZE,
  659. * the big buffer at end of command array
  660. */
  661. if (is_huge)
  662. return q->n_window; /* must be power of 2 */
  663. /* Otherwise, use normal size buffers */
  664. return index & (q->n_window - 1);
  665. }
  666. struct iwl_dma_ptr {
  667. dma_addr_t dma;
  668. void *addr;
  669. size_t size;
  670. };
  671. #define IWL_OPERATION_MODE_AUTO 0
  672. #define IWL_OPERATION_MODE_HT_ONLY 1
  673. #define IWL_OPERATION_MODE_MIXED 2
  674. #define IWL_OPERATION_MODE_20MHZ 3
  675. #define IWL_TX_CRC_SIZE 4
  676. #define IWL_TX_DELIMITER_SIZE 4
  677. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  678. /* Sensitivity and chain noise calibration */
  679. #define INITIALIZATION_VALUE 0xFFFF
  680. #define IWL4965_CAL_NUM_BEACONS 20
  681. #define IWL_CAL_NUM_BEACONS 16
  682. #define MAXIMUM_ALLOWED_PATHLOSS 15
  683. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  684. #define MAX_FA_OFDM 50
  685. #define MIN_FA_OFDM 5
  686. #define MAX_FA_CCK 50
  687. #define MIN_FA_CCK 5
  688. #define AUTO_CORR_STEP_OFDM 1
  689. #define AUTO_CORR_STEP_CCK 3
  690. #define AUTO_CORR_MAX_TH_CCK 160
  691. #define NRG_DIFF 2
  692. #define NRG_STEP_CCK 2
  693. #define NRG_MARGIN 8
  694. #define MAX_NUMBER_CCK_NO_FA 100
  695. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  696. #define CHAIN_A 0
  697. #define CHAIN_B 1
  698. #define CHAIN_C 2
  699. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  700. #define ALL_BAND_FILTER 0xFF00
  701. #define IN_BAND_FILTER 0xFF
  702. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  703. #define NRG_NUM_PREV_STAT_L 20
  704. #define NUM_RX_CHAINS 3
  705. enum iwl4965_false_alarm_state {
  706. IWL_FA_TOO_MANY = 0,
  707. IWL_FA_TOO_FEW = 1,
  708. IWL_FA_GOOD_RANGE = 2,
  709. };
  710. enum iwl4965_chain_noise_state {
  711. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  712. IWL_CHAIN_NOISE_ACCUMULATE,
  713. IWL_CHAIN_NOISE_CALIBRATED,
  714. IWL_CHAIN_NOISE_DONE,
  715. };
  716. enum iwl4965_calib_enabled_state {
  717. IWL_CALIB_DISABLED = 0, /* must be 0 */
  718. IWL_CALIB_ENABLED = 1,
  719. };
  720. /*
  721. * enum iwl_calib
  722. * defines the order in which results of initial calibrations
  723. * should be sent to the runtime uCode
  724. */
  725. enum iwl_calib {
  726. IWL_CALIB_XTAL,
  727. IWL_CALIB_DC,
  728. IWL_CALIB_LO,
  729. IWL_CALIB_TX_IQ,
  730. IWL_CALIB_TX_IQ_PERD,
  731. IWL_CALIB_BASE_BAND,
  732. IWL_CALIB_MAX
  733. };
  734. /* Opaque calibration results */
  735. struct iwl_calib_result {
  736. void *buf;
  737. size_t buf_len;
  738. };
  739. enum ucode_type {
  740. UCODE_NONE = 0,
  741. UCODE_INIT,
  742. UCODE_RT
  743. };
  744. /* Sensitivity calib data */
  745. struct iwl_sensitivity_data {
  746. u32 auto_corr_ofdm;
  747. u32 auto_corr_ofdm_mrc;
  748. u32 auto_corr_ofdm_x1;
  749. u32 auto_corr_ofdm_mrc_x1;
  750. u32 auto_corr_cck;
  751. u32 auto_corr_cck_mrc;
  752. u32 last_bad_plcp_cnt_ofdm;
  753. u32 last_fa_cnt_ofdm;
  754. u32 last_bad_plcp_cnt_cck;
  755. u32 last_fa_cnt_cck;
  756. u32 nrg_curr_state;
  757. u32 nrg_prev_state;
  758. u32 nrg_value[10];
  759. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  760. u32 nrg_silence_ref;
  761. u32 nrg_energy_idx;
  762. u32 nrg_silence_idx;
  763. u32 nrg_th_cck;
  764. s32 nrg_auto_corr_silence_diff;
  765. u32 num_in_cck_no_fa;
  766. u32 nrg_th_ofdm;
  767. u16 barker_corr_th_min;
  768. u16 barker_corr_th_min_mrc;
  769. u16 nrg_th_cca;
  770. };
  771. /* Chain noise (differential Rx gain) calib data */
  772. struct iwl_chain_noise_data {
  773. u32 active_chains;
  774. u32 chain_noise_a;
  775. u32 chain_noise_b;
  776. u32 chain_noise_c;
  777. u32 chain_signal_a;
  778. u32 chain_signal_b;
  779. u32 chain_signal_c;
  780. u16 beacon_count;
  781. u8 disconn_array[NUM_RX_CHAINS];
  782. u8 delta_gain_code[NUM_RX_CHAINS];
  783. u8 radio_write;
  784. u8 state;
  785. };
  786. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  787. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  788. #define IWL_TRAFFIC_ENTRIES (256)
  789. #define IWL_TRAFFIC_ENTRY_SIZE (64)
  790. enum {
  791. MEASUREMENT_READY = (1 << 0),
  792. MEASUREMENT_ACTIVE = (1 << 1),
  793. };
  794. enum iwl_nvm_type {
  795. NVM_DEVICE_TYPE_EEPROM = 0,
  796. NVM_DEVICE_TYPE_OTP,
  797. };
  798. /*
  799. * Two types of OTP memory access modes
  800. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  801. * based on physical memory addressing
  802. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  803. * based on logical memory addressing
  804. */
  805. enum iwl_access_mode {
  806. IWL_OTP_ACCESS_ABSOLUTE,
  807. IWL_OTP_ACCESS_RELATIVE,
  808. };
  809. /**
  810. * enum iwl_pa_type - Power Amplifier type
  811. * @IWL_PA_SYSTEM: based on uCode configuration
  812. * @IWL_PA_HYBRID: use both Internal and external PA
  813. * @IWL_PA_INTERNAL: use Internal only
  814. */
  815. enum iwl_pa_type {
  816. IWL_PA_SYSTEM = 0,
  817. IWL_PA_HYBRID = 1,
  818. IWL_PA_INTERNAL = 2,
  819. };
  820. /* interrupt statistics */
  821. struct isr_statistics {
  822. u32 hw;
  823. u32 sw;
  824. u32 sw_err;
  825. u32 sch;
  826. u32 alive;
  827. u32 rfkill;
  828. u32 ctkill;
  829. u32 wakeup;
  830. u32 rx;
  831. u32 rx_handlers[REPLY_MAX];
  832. u32 tx;
  833. u32 unhandled;
  834. };
  835. #ifdef CONFIG_IWLWIFI_DEBUGFS
  836. /* management statistics */
  837. enum iwl_mgmt_stats {
  838. MANAGEMENT_ASSOC_REQ = 0,
  839. MANAGEMENT_ASSOC_RESP,
  840. MANAGEMENT_REASSOC_REQ,
  841. MANAGEMENT_REASSOC_RESP,
  842. MANAGEMENT_PROBE_REQ,
  843. MANAGEMENT_PROBE_RESP,
  844. MANAGEMENT_BEACON,
  845. MANAGEMENT_ATIM,
  846. MANAGEMENT_DISASSOC,
  847. MANAGEMENT_AUTH,
  848. MANAGEMENT_DEAUTH,
  849. MANAGEMENT_ACTION,
  850. MANAGEMENT_MAX,
  851. };
  852. /* control statistics */
  853. enum iwl_ctrl_stats {
  854. CONTROL_BACK_REQ = 0,
  855. CONTROL_BACK,
  856. CONTROL_PSPOLL,
  857. CONTROL_RTS,
  858. CONTROL_CTS,
  859. CONTROL_ACK,
  860. CONTROL_CFEND,
  861. CONTROL_CFENDACK,
  862. CONTROL_MAX,
  863. };
  864. struct traffic_stats {
  865. u32 mgmt[MANAGEMENT_MAX];
  866. u32 ctrl[CONTROL_MAX];
  867. u32 data_cnt;
  868. u64 data_bytes;
  869. };
  870. #else
  871. struct traffic_stats {
  872. u64 data_bytes;
  873. };
  874. #endif
  875. struct iwl_priv {
  876. /* ieee device used by generic ieee processing code */
  877. struct ieee80211_hw *hw;
  878. struct ieee80211_channel *ieee_channels;
  879. struct ieee80211_rate *ieee_rates;
  880. struct iwl_cfg *cfg;
  881. /* temporary frame storage list */
  882. struct list_head free_frames;
  883. int frames_count;
  884. enum ieee80211_band band;
  885. int alloc_rxb_page;
  886. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  887. struct iwl_rx_mem_buffer *rxb);
  888. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  889. #if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT)
  890. /* spectrum measurement report caching */
  891. struct iwl_spectrum_notification measure_report;
  892. u8 measurement_status;
  893. #endif
  894. /* ucode beacon time */
  895. u32 ucode_beacon_time;
  896. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  897. * Access via channel # using indirect index array */
  898. struct iwl_channel_info *channel_info; /* channel info array */
  899. u8 channel_count; /* # of channels */
  900. /* each calibration channel group in the EEPROM has a derived
  901. * clip setting for each rate. 3945 only.*/
  902. const struct iwl3945_clip_group clip39_groups[5];
  903. /* thermal calibration */
  904. s32 temperature; /* degrees Kelvin */
  905. s32 last_temperature;
  906. /* init calibration results */
  907. struct iwl_calib_result calib_results[IWL_CALIB_MAX];
  908. /* Scan related variables */
  909. unsigned long last_scan_jiffies;
  910. unsigned long next_scan_jiffies;
  911. unsigned long scan_start;
  912. unsigned long scan_pass_start;
  913. unsigned long scan_start_tsf;
  914. void *scan;
  915. int scan_bands;
  916. struct cfg80211_scan_request *scan_request;
  917. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  918. u8 mgmt_tx_ant;
  919. /* spinlock */
  920. spinlock_t lock; /* protect general shared data */
  921. spinlock_t hcmd_lock; /* protect hcmd */
  922. spinlock_t reg_lock; /* protect hw register access */
  923. struct mutex mutex;
  924. /* basic pci-network driver stuff */
  925. struct pci_dev *pci_dev;
  926. /* pci hardware address support */
  927. void __iomem *hw_base;
  928. u32 hw_rev;
  929. u32 hw_wa_rev;
  930. u8 rev_id;
  931. /* uCode images, save to reload in case of failure */
  932. u32 ucode_ver; /* version of ucode, copy of
  933. iwl_ucode.ver */
  934. struct fw_desc ucode_code; /* runtime inst */
  935. struct fw_desc ucode_data; /* runtime data original */
  936. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  937. struct fw_desc ucode_init; /* initialization inst */
  938. struct fw_desc ucode_init_data; /* initialization data */
  939. struct fw_desc ucode_boot; /* bootstrap inst */
  940. enum ucode_type ucode_type;
  941. u8 ucode_write_complete; /* the image write is complete */
  942. struct iwl_rxon_time_cmd rxon_timing;
  943. /* We declare this const so it can only be
  944. * changed via explicit cast within the
  945. * routines that actually update the physical
  946. * hardware */
  947. const struct iwl_rxon_cmd active_rxon;
  948. struct iwl_rxon_cmd staging_rxon;
  949. struct iwl_rxon_cmd recovery_rxon;
  950. /* 1st responses from initialize and runtime uCode images.
  951. * 4965's initialize alive response contains some calibration data. */
  952. struct iwl_init_alive_resp card_alive_init;
  953. struct iwl_alive_resp card_alive;
  954. unsigned long last_blink_time;
  955. u8 last_blink_rate;
  956. u8 allow_blinking;
  957. u64 led_tpt;
  958. u16 active_rate;
  959. u16 active_rate_basic;
  960. u8 assoc_station_added;
  961. u8 start_calib;
  962. struct iwl_sensitivity_data sensitivity_data;
  963. struct iwl_chain_noise_data chain_noise_data;
  964. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  965. struct iwl_ht_config current_ht_config;
  966. u8 last_phy_res[100];
  967. /* Rate scaling data */
  968. u8 retry_rate;
  969. wait_queue_head_t wait_command_queue;
  970. int activity_timer_active;
  971. /* Rx and Tx DMA processing queues */
  972. struct iwl_rx_queue rxq;
  973. struct iwl_tx_queue *txq;
  974. unsigned long txq_ctx_active_msk;
  975. struct iwl_dma_ptr kw; /* keep warm address */
  976. struct iwl_dma_ptr scd_bc_tbls;
  977. u32 scd_base_addr; /* scheduler sram base address */
  978. unsigned long status;
  979. int last_rx_rssi; /* From Rx packet statistics */
  980. int last_rx_noise; /* From beacon statistics */
  981. /* counts mgmt, ctl, and data packets */
  982. struct traffic_stats tx_stats;
  983. struct traffic_stats rx_stats;
  984. /* counts interrupts */
  985. struct isr_statistics isr_stats;
  986. struct iwl_power_mgr power_data;
  987. struct iwl_tt_mgmt thermal_throttle;
  988. struct iwl_notif_statistics statistics;
  989. #ifdef CONFIG_IWLWIFI_DEBUG
  990. struct iwl_notif_statistics accum_statistics;
  991. #endif
  992. /* context information */
  993. u16 rates_mask;
  994. u8 bssid[ETH_ALEN];
  995. u16 rts_threshold;
  996. u8 mac_addr[ETH_ALEN];
  997. /*station table variables */
  998. spinlock_t sta_lock;
  999. int num_stations;
  1000. struct iwl_station_entry stations[IWL_STATION_COUNT];
  1001. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  1002. u8 default_wep_key;
  1003. u8 key_mapping_key;
  1004. unsigned long ucode_key_table;
  1005. /* queue refcounts */
  1006. #define IWL_MAX_HW_QUEUES 32
  1007. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  1008. /* for each AC */
  1009. atomic_t queue_stop_count[4];
  1010. /* Indication if ieee80211_ops->open has been called */
  1011. u8 is_open;
  1012. u8 mac80211_registered;
  1013. /* Rx'd packet timing information */
  1014. u32 last_beacon_time;
  1015. u64 last_tsf;
  1016. /* eeprom */
  1017. u8 *eeprom;
  1018. int nvm_device_type;
  1019. struct iwl_eeprom_calib_info *calib_info;
  1020. enum nl80211_iftype iw_mode;
  1021. struct sk_buff *ibss_beacon;
  1022. /* Last Rx'd beacon timestamp */
  1023. u64 timestamp;
  1024. u16 beacon_int;
  1025. struct ieee80211_vif *vif;
  1026. /*Added for 3945 */
  1027. void *shared_virt;
  1028. dma_addr_t shared_phys;
  1029. /*End*/
  1030. struct iwl_hw_params hw_params;
  1031. /* INT ICT Table */
  1032. __le32 *ict_tbl;
  1033. dma_addr_t ict_tbl_dma;
  1034. dma_addr_t aligned_ict_tbl_dma;
  1035. int ict_index;
  1036. void *ict_tbl_vir;
  1037. u32 inta;
  1038. bool use_ict;
  1039. u32 inta_mask;
  1040. /* Current association information needed to configure the
  1041. * hardware */
  1042. u16 assoc_id;
  1043. u16 assoc_capability;
  1044. struct iwl_qos_info qos_data;
  1045. struct workqueue_struct *workqueue;
  1046. struct work_struct up;
  1047. struct work_struct restart;
  1048. struct work_struct calibrated_work;
  1049. struct work_struct scan_completed;
  1050. struct work_struct rx_replenish;
  1051. struct work_struct abort_scan;
  1052. struct work_struct update_link_led;
  1053. struct work_struct auth_work;
  1054. struct work_struct report_work;
  1055. struct work_struct request_scan;
  1056. struct work_struct beacon_update;
  1057. struct work_struct tt_work;
  1058. struct work_struct ct_enter;
  1059. struct work_struct ct_exit;
  1060. struct tasklet_struct irq_tasklet;
  1061. struct delayed_work init_alive_start;
  1062. struct delayed_work alive_start;
  1063. struct delayed_work scan_check;
  1064. /*For 3945 only*/
  1065. struct delayed_work thermal_periodic;
  1066. struct delayed_work rfkill_poll;
  1067. /* TX Power */
  1068. s8 tx_power_user_lmt;
  1069. s8 tx_power_device_lmt;
  1070. #ifdef CONFIG_IWLWIFI_DEBUG
  1071. /* debugging info */
  1072. u32 debug_level; /* per device debugging will override global
  1073. iwl_debug_level if set */
  1074. u32 framecnt_to_us;
  1075. atomic_t restrict_refcnt;
  1076. bool disable_ht40;
  1077. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1078. /* debugfs */
  1079. u16 tx_traffic_idx;
  1080. u16 rx_traffic_idx;
  1081. u8 *tx_traffic;
  1082. u8 *rx_traffic;
  1083. struct iwl_debugfs *dbgfs;
  1084. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1085. #endif /* CONFIG_IWLWIFI_DEBUG */
  1086. struct work_struct txpower_work;
  1087. u32 disable_sens_cal;
  1088. u32 disable_chain_noise_cal;
  1089. u32 disable_tx_power_cal;
  1090. struct work_struct run_time_calib_work;
  1091. struct timer_list statistics_periodic;
  1092. bool hw_ready;
  1093. /*For 3945*/
  1094. #define IWL_DEFAULT_TX_POWER 0x0F
  1095. struct iwl3945_notif_statistics statistics_39;
  1096. u32 sta_supp_rates;
  1097. }; /*iwl_priv */
  1098. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  1099. {
  1100. set_bit(txq_id, &priv->txq_ctx_active_msk);
  1101. }
  1102. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  1103. {
  1104. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  1105. }
  1106. #ifdef CONFIG_IWLWIFI_DEBUG
  1107. const char *iwl_get_tx_fail_reason(u32 status);
  1108. /*
  1109. * iwl_get_debug_level: Return active debug level for device
  1110. *
  1111. * Using sysfs it is possible to set per device debug level. This debug
  1112. * level will be used if set, otherwise the global debug level which can be
  1113. * set via module parameter is used.
  1114. */
  1115. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1116. {
  1117. if (priv->debug_level)
  1118. return priv->debug_level;
  1119. else
  1120. return iwl_debug_level;
  1121. }
  1122. #else
  1123. static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
  1124. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1125. {
  1126. return iwl_debug_level;
  1127. }
  1128. #endif
  1129. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  1130. int txq_id, int idx)
  1131. {
  1132. if (priv->txq[txq_id].txb[idx].skb[0])
  1133. return (struct ieee80211_hdr *)priv->txq[txq_id].
  1134. txb[idx].skb[0]->data;
  1135. return NULL;
  1136. }
  1137. static inline int iwl_is_associated(struct iwl_priv *priv)
  1138. {
  1139. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1140. }
  1141. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1142. {
  1143. if (ch_info == NULL)
  1144. return 0;
  1145. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1146. }
  1147. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1148. {
  1149. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1150. }
  1151. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1152. {
  1153. return ch_info->band == IEEE80211_BAND_5GHZ;
  1154. }
  1155. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1156. {
  1157. return ch_info->band == IEEE80211_BAND_2GHZ;
  1158. }
  1159. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1160. {
  1161. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1162. }
  1163. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1164. {
  1165. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1166. }
  1167. #endif /* __iwl_dev_h__ */