iwl-dev.h 37 KB

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