iwl-dev.h 36 KB

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