iwl-dev.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477
  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 iwl6000g2a_2agn_cfg;
  57. extern struct iwl_cfg iwl6000i_2agn_cfg;
  58. extern struct iwl_cfg iwl6000i_2abg_cfg;
  59. extern struct iwl_cfg iwl6000i_2bg_cfg;
  60. extern struct iwl_cfg iwl6000_3agn_cfg;
  61. extern struct iwl_cfg iwl6050_2agn_cfg;
  62. extern struct iwl_cfg iwl6050_2abg_cfg;
  63. extern struct iwl_cfg 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. struct iwl_station_priv_common {
  440. u8 sta_id;
  441. };
  442. /*
  443. * iwl_station_priv: Driver's private station information
  444. *
  445. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  446. * in the structure for use by driver. This structure is places in that
  447. * space.
  448. *
  449. * The common struct MUST be first because it is shared between
  450. * 3945 and agn!
  451. */
  452. struct iwl_station_priv {
  453. struct iwl_station_priv_common common;
  454. struct iwl_lq_sta lq_sta;
  455. atomic_t pending_frames;
  456. bool client;
  457. bool asleep;
  458. };
  459. /**
  460. * struct iwl_vif_priv - driver's private per-interface information
  461. *
  462. * When mac80211 allocates a virtual interface, it can allocate
  463. * space for us to put data into.
  464. */
  465. struct iwl_vif_priv {
  466. u8 ibss_bssid_sta_id;
  467. };
  468. /* one for each uCode image (inst/data, boot/init/runtime) */
  469. struct fw_desc {
  470. void *v_addr; /* access by driver */
  471. dma_addr_t p_addr; /* access by card's busmaster DMA */
  472. u32 len; /* bytes */
  473. };
  474. /* v1/v2 uCode file layout */
  475. struct iwl_ucode_header {
  476. __le32 ver; /* major/minor/API/serial */
  477. union {
  478. struct {
  479. __le32 inst_size; /* bytes of runtime code */
  480. __le32 data_size; /* bytes of runtime data */
  481. __le32 init_size; /* bytes of init code */
  482. __le32 init_data_size; /* bytes of init data */
  483. __le32 boot_size; /* bytes of bootstrap code */
  484. u8 data[0]; /* in same order as sizes */
  485. } v1;
  486. struct {
  487. __le32 build; /* build number */
  488. __le32 inst_size; /* bytes of runtime code */
  489. __le32 data_size; /* bytes of runtime data */
  490. __le32 init_size; /* bytes of init code */
  491. __le32 init_data_size; /* bytes of init data */
  492. __le32 boot_size; /* bytes of bootstrap code */
  493. u8 data[0]; /* in same order as sizes */
  494. } v2;
  495. } u;
  496. };
  497. /*
  498. * new TLV uCode file layout
  499. *
  500. * The new TLV file format contains TLVs, that each specify
  501. * some piece of data. To facilitate "groups", for example
  502. * different instruction image with different capabilities,
  503. * bundled with the same init image, an alternative mechanism
  504. * is provided:
  505. * When the alternative field is 0, that means that the item
  506. * is always valid. When it is non-zero, then it is only
  507. * valid in conjunction with items of the same alternative,
  508. * in which case the driver (user) selects one alternative
  509. * to use.
  510. */
  511. enum iwl_ucode_tlv_type {
  512. IWL_UCODE_TLV_INVALID = 0, /* unused */
  513. IWL_UCODE_TLV_INST = 1,
  514. IWL_UCODE_TLV_DATA = 2,
  515. IWL_UCODE_TLV_INIT = 3,
  516. IWL_UCODE_TLV_INIT_DATA = 4,
  517. IWL_UCODE_TLV_BOOT = 5,
  518. IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
  519. };
  520. struct iwl_ucode_tlv {
  521. __le16 type; /* see above */
  522. __le16 alternative; /* see comment */
  523. __le32 length; /* not including type/length fields */
  524. u8 data[0];
  525. } __attribute__ ((packed));
  526. #define IWL_TLV_UCODE_MAGIC 0x0a4c5749
  527. struct iwl_tlv_ucode_header {
  528. /*
  529. * The TLV style ucode header is distinguished from
  530. * the v1/v2 style header by first four bytes being
  531. * zero, as such is an invalid combination of
  532. * major/minor/API/serial versions.
  533. */
  534. __le32 zero;
  535. __le32 magic;
  536. u8 human_readable[64];
  537. __le32 ver; /* major/minor/API/serial */
  538. __le32 build;
  539. __le64 alternatives; /* bitmask of valid alternatives */
  540. /*
  541. * The data contained herein has a TLV layout,
  542. * see above for the TLV header and types.
  543. * Note that each TLV is padded to a length
  544. * that is a multiple of 4 for alignment.
  545. */
  546. u8 data[0];
  547. };
  548. struct iwl4965_ibss_seq {
  549. u8 mac[ETH_ALEN];
  550. u16 seq_num;
  551. u16 frag_num;
  552. unsigned long packet_time;
  553. struct list_head list;
  554. };
  555. struct iwl_sensitivity_ranges {
  556. u16 min_nrg_cck;
  557. u16 max_nrg_cck;
  558. u16 nrg_th_cck;
  559. u16 nrg_th_ofdm;
  560. u16 auto_corr_min_ofdm;
  561. u16 auto_corr_min_ofdm_mrc;
  562. u16 auto_corr_min_ofdm_x1;
  563. u16 auto_corr_min_ofdm_mrc_x1;
  564. u16 auto_corr_max_ofdm;
  565. u16 auto_corr_max_ofdm_mrc;
  566. u16 auto_corr_max_ofdm_x1;
  567. u16 auto_corr_max_ofdm_mrc_x1;
  568. u16 auto_corr_max_cck;
  569. u16 auto_corr_max_cck_mrc;
  570. u16 auto_corr_min_cck;
  571. u16 auto_corr_min_cck_mrc;
  572. u16 barker_corr_th_min;
  573. u16 barker_corr_th_min_mrc;
  574. u16 nrg_th_cca;
  575. };
  576. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  577. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  578. /**
  579. * struct iwl_hw_params
  580. * @max_txq_num: Max # Tx queues supported
  581. * @dma_chnl_num: Number of Tx DMA/FIFO channels
  582. * @scd_bc_tbls_size: size of scheduler byte count tables
  583. * @tfd_size: TFD size
  584. * @tx/rx_chains_num: Number of TX/RX chains
  585. * @valid_tx/rx_ant: usable antennas
  586. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  587. * @max_rxq_log: Log-base-2 of max_rxq_size
  588. * @rx_page_order: Rx buffer page order
  589. * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  590. * @max_stations:
  591. * @bcast_sta_id:
  592. * @ht40_channel: is 40MHz width possible in band 2.4
  593. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  594. * @sw_crypto: 0 for hw, 1 for sw
  595. * @max_xxx_size: for ucode uses
  596. * @ct_kill_threshold: temperature threshold
  597. * @calib_init_cfg: setup initial calibrations for the hw
  598. * @struct iwl_sensitivity_ranges: range of sensitivity values
  599. */
  600. struct iwl_hw_params {
  601. u8 max_txq_num;
  602. u8 dma_chnl_num;
  603. u16 scd_bc_tbls_size;
  604. u32 tfd_size;
  605. u8 tx_chains_num;
  606. u8 rx_chains_num;
  607. u8 valid_tx_ant;
  608. u8 valid_rx_ant;
  609. u16 max_rxq_size;
  610. u16 max_rxq_log;
  611. u32 rx_page_order;
  612. u32 rx_wrt_ptr_reg;
  613. u8 max_stations;
  614. u8 bcast_sta_id;
  615. u8 ht40_channel;
  616. u8 max_beacon_itrvl; /* in 1024 ms */
  617. u32 max_inst_size;
  618. u32 max_data_size;
  619. u32 max_bsm_size;
  620. u32 ct_kill_threshold; /* value in hw-dependent units */
  621. u32 ct_kill_exit_threshold; /* value in hw-dependent units */
  622. /* for 1000, 6000 series and up */
  623. u32 calib_init_cfg;
  624. const struct iwl_sensitivity_ranges *sens;
  625. };
  626. /******************************************************************************
  627. *
  628. * Functions implemented in core module which are forward declared here
  629. * for use by iwl-[4-5].c
  630. *
  631. * NOTE: The implementation of these functions are not hardware specific
  632. * which is why they are in the core module files.
  633. *
  634. * Naming convention --
  635. * iwl_ <-- Is part of iwlwifi
  636. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  637. * iwl4965_bg_ <-- Called from work queue context
  638. * iwl4965_mac_ <-- mac80211 callback
  639. *
  640. ****************************************************************************/
  641. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  642. extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
  643. extern const u8 iwl_bcast_addr[ETH_ALEN];
  644. extern int iwl_rxq_stop(struct iwl_priv *priv);
  645. extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
  646. extern int iwl_queue_space(const struct iwl_queue *q);
  647. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  648. {
  649. return q->write_ptr >= q->read_ptr ?
  650. (i >= q->read_ptr && i < q->write_ptr) :
  651. !(i < q->read_ptr && i >= q->write_ptr);
  652. }
  653. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
  654. {
  655. /*
  656. * This is for init calibration result and scan command which
  657. * required buffer > TFD_MAX_PAYLOAD_SIZE,
  658. * the big buffer at end of command array
  659. */
  660. if (is_huge)
  661. return q->n_window; /* must be power of 2 */
  662. /* Otherwise, use normal size buffers */
  663. return index & (q->n_window - 1);
  664. }
  665. struct iwl_dma_ptr {
  666. dma_addr_t dma;
  667. void *addr;
  668. size_t size;
  669. };
  670. #define IWL_OPERATION_MODE_AUTO 0
  671. #define IWL_OPERATION_MODE_HT_ONLY 1
  672. #define IWL_OPERATION_MODE_MIXED 2
  673. #define IWL_OPERATION_MODE_20MHZ 3
  674. #define IWL_TX_CRC_SIZE 4
  675. #define IWL_TX_DELIMITER_SIZE 4
  676. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  677. /* Sensitivity and chain noise calibration */
  678. #define INITIALIZATION_VALUE 0xFFFF
  679. #define IWL4965_CAL_NUM_BEACONS 20
  680. #define IWL_CAL_NUM_BEACONS 16
  681. #define MAXIMUM_ALLOWED_PATHLOSS 15
  682. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  683. #define MAX_FA_OFDM 50
  684. #define MIN_FA_OFDM 5
  685. #define MAX_FA_CCK 50
  686. #define MIN_FA_CCK 5
  687. #define AUTO_CORR_STEP_OFDM 1
  688. #define AUTO_CORR_STEP_CCK 3
  689. #define AUTO_CORR_MAX_TH_CCK 160
  690. #define NRG_DIFF 2
  691. #define NRG_STEP_CCK 2
  692. #define NRG_MARGIN 8
  693. #define MAX_NUMBER_CCK_NO_FA 100
  694. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  695. #define CHAIN_A 0
  696. #define CHAIN_B 1
  697. #define CHAIN_C 2
  698. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  699. #define ALL_BAND_FILTER 0xFF00
  700. #define IN_BAND_FILTER 0xFF
  701. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  702. #define NRG_NUM_PREV_STAT_L 20
  703. #define NUM_RX_CHAINS 3
  704. enum iwl4965_false_alarm_state {
  705. IWL_FA_TOO_MANY = 0,
  706. IWL_FA_TOO_FEW = 1,
  707. IWL_FA_GOOD_RANGE = 2,
  708. };
  709. enum iwl4965_chain_noise_state {
  710. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  711. IWL_CHAIN_NOISE_ACCUMULATE,
  712. IWL_CHAIN_NOISE_CALIBRATED,
  713. IWL_CHAIN_NOISE_DONE,
  714. };
  715. enum iwl4965_calib_enabled_state {
  716. IWL_CALIB_DISABLED = 0, /* must be 0 */
  717. IWL_CALIB_ENABLED = 1,
  718. };
  719. /*
  720. * enum iwl_calib
  721. * defines the order in which results of initial calibrations
  722. * should be sent to the runtime uCode
  723. */
  724. enum iwl_calib {
  725. IWL_CALIB_XTAL,
  726. IWL_CALIB_DC,
  727. IWL_CALIB_LO,
  728. IWL_CALIB_TX_IQ,
  729. IWL_CALIB_TX_IQ_PERD,
  730. IWL_CALIB_BASE_BAND,
  731. IWL_CALIB_MAX
  732. };
  733. /* Opaque calibration results */
  734. struct iwl_calib_result {
  735. void *buf;
  736. size_t buf_len;
  737. };
  738. enum ucode_type {
  739. UCODE_NONE = 0,
  740. UCODE_INIT,
  741. UCODE_RT
  742. };
  743. /* Sensitivity calib data */
  744. struct iwl_sensitivity_data {
  745. u32 auto_corr_ofdm;
  746. u32 auto_corr_ofdm_mrc;
  747. u32 auto_corr_ofdm_x1;
  748. u32 auto_corr_ofdm_mrc_x1;
  749. u32 auto_corr_cck;
  750. u32 auto_corr_cck_mrc;
  751. u32 last_bad_plcp_cnt_ofdm;
  752. u32 last_fa_cnt_ofdm;
  753. u32 last_bad_plcp_cnt_cck;
  754. u32 last_fa_cnt_cck;
  755. u32 nrg_curr_state;
  756. u32 nrg_prev_state;
  757. u32 nrg_value[10];
  758. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  759. u32 nrg_silence_ref;
  760. u32 nrg_energy_idx;
  761. u32 nrg_silence_idx;
  762. u32 nrg_th_cck;
  763. s32 nrg_auto_corr_silence_diff;
  764. u32 num_in_cck_no_fa;
  765. u32 nrg_th_ofdm;
  766. u16 barker_corr_th_min;
  767. u16 barker_corr_th_min_mrc;
  768. u16 nrg_th_cca;
  769. };
  770. /* Chain noise (differential Rx gain) calib data */
  771. struct iwl_chain_noise_data {
  772. u32 active_chains;
  773. u32 chain_noise_a;
  774. u32 chain_noise_b;
  775. u32 chain_noise_c;
  776. u32 chain_signal_a;
  777. u32 chain_signal_b;
  778. u32 chain_signal_c;
  779. u16 beacon_count;
  780. u8 disconn_array[NUM_RX_CHAINS];
  781. u8 delta_gain_code[NUM_RX_CHAINS];
  782. u8 radio_write;
  783. u8 state;
  784. };
  785. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  786. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  787. #define IWL_TRAFFIC_ENTRIES (256)
  788. #define IWL_TRAFFIC_ENTRY_SIZE (64)
  789. enum {
  790. MEASUREMENT_READY = (1 << 0),
  791. MEASUREMENT_ACTIVE = (1 << 1),
  792. };
  793. enum iwl_nvm_type {
  794. NVM_DEVICE_TYPE_EEPROM = 0,
  795. NVM_DEVICE_TYPE_OTP,
  796. };
  797. /*
  798. * Two types of OTP memory access modes
  799. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  800. * based on physical memory addressing
  801. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  802. * based on logical memory addressing
  803. */
  804. enum iwl_access_mode {
  805. IWL_OTP_ACCESS_ABSOLUTE,
  806. IWL_OTP_ACCESS_RELATIVE,
  807. };
  808. /**
  809. * enum iwl_pa_type - Power Amplifier type
  810. * @IWL_PA_SYSTEM: based on uCode configuration
  811. * @IWL_PA_INTERNAL: use Internal only
  812. */
  813. enum iwl_pa_type {
  814. IWL_PA_SYSTEM = 0,
  815. IWL_PA_INTERNAL = 1,
  816. };
  817. /* interrupt statistics */
  818. struct isr_statistics {
  819. u32 hw;
  820. u32 sw;
  821. u32 sw_err;
  822. u32 sch;
  823. u32 alive;
  824. u32 rfkill;
  825. u32 ctkill;
  826. u32 wakeup;
  827. u32 rx;
  828. u32 rx_handlers[REPLY_MAX];
  829. u32 tx;
  830. u32 unhandled;
  831. };
  832. #ifdef CONFIG_IWLWIFI_DEBUGFS
  833. /* management statistics */
  834. enum iwl_mgmt_stats {
  835. MANAGEMENT_ASSOC_REQ = 0,
  836. MANAGEMENT_ASSOC_RESP,
  837. MANAGEMENT_REASSOC_REQ,
  838. MANAGEMENT_REASSOC_RESP,
  839. MANAGEMENT_PROBE_REQ,
  840. MANAGEMENT_PROBE_RESP,
  841. MANAGEMENT_BEACON,
  842. MANAGEMENT_ATIM,
  843. MANAGEMENT_DISASSOC,
  844. MANAGEMENT_AUTH,
  845. MANAGEMENT_DEAUTH,
  846. MANAGEMENT_ACTION,
  847. MANAGEMENT_MAX,
  848. };
  849. /* control statistics */
  850. enum iwl_ctrl_stats {
  851. CONTROL_BACK_REQ = 0,
  852. CONTROL_BACK,
  853. CONTROL_PSPOLL,
  854. CONTROL_RTS,
  855. CONTROL_CTS,
  856. CONTROL_ACK,
  857. CONTROL_CFEND,
  858. CONTROL_CFENDACK,
  859. CONTROL_MAX,
  860. };
  861. struct traffic_stats {
  862. u32 mgmt[MANAGEMENT_MAX];
  863. u32 ctrl[CONTROL_MAX];
  864. u32 data_cnt;
  865. u64 data_bytes;
  866. };
  867. #else
  868. struct traffic_stats {
  869. u64 data_bytes;
  870. };
  871. #endif
  872. /*
  873. * iwl_switch_rxon: "channel switch" structure
  874. *
  875. * @ switch_in_progress: channel switch in progress
  876. * @ channel: new channel
  877. */
  878. struct iwl_switch_rxon {
  879. bool switch_in_progress;
  880. __le16 channel;
  881. };
  882. /*
  883. * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  884. * to perform continuous uCode event logging operation if enabled
  885. */
  886. #define UCODE_TRACE_PERIOD (100)
  887. /*
  888. * iwl_event_log: current uCode event log position
  889. *
  890. * @ucode_trace: enable/disable ucode continuous trace timer
  891. * @num_wraps: how many times the event buffer wraps
  892. * @next_entry: the entry just before the next one that uCode would fill
  893. * @non_wraps_count: counter for no wrap detected when dump ucode events
  894. * @wraps_once_count: counter for wrap once detected when dump ucode events
  895. * @wraps_more_count: counter for wrap more than once detected
  896. * when dump ucode events
  897. */
  898. struct iwl_event_log {
  899. bool ucode_trace;
  900. u32 num_wraps;
  901. u32 next_entry;
  902. int non_wraps_count;
  903. int wraps_once_count;
  904. int wraps_more_count;
  905. };
  906. /*
  907. * host interrupt timeout value
  908. * used with setting interrupt coalescing timer
  909. * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
  910. *
  911. * default interrupt coalescing timer is 64 x 32 = 2048 usecs
  912. * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
  913. */
  914. #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
  915. #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
  916. #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
  917. #define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
  918. #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
  919. #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
  920. /*
  921. * This is the threshold value of plcp error rate per 100mSecs. It is
  922. * used to set and check for the validity of plcp_delta.
  923. */
  924. #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (0)
  925. #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
  926. #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
  927. #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
  928. #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
  929. #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
  930. #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
  931. /* timer constants use to monitor and recover stuck tx queues in mSecs */
  932. #define IWL_MONITORING_PERIOD (1000)
  933. #define IWL_ONE_HUNDRED_MSECS (100)
  934. #define IWL_SIXTY_SECS (60000)
  935. enum iwl_reset {
  936. IWL_RF_RESET = 0,
  937. IWL_FW_RESET,
  938. IWL_MAX_FORCE_RESET,
  939. };
  940. struct iwl_force_reset {
  941. int reset_request_count;
  942. int reset_success_count;
  943. int reset_reject_count;
  944. unsigned long reset_duration;
  945. unsigned long last_force_reset_jiffies;
  946. };
  947. struct iwl_priv {
  948. /* ieee device used by generic ieee processing code */
  949. struct ieee80211_hw *hw;
  950. struct ieee80211_channel *ieee_channels;
  951. struct ieee80211_rate *ieee_rates;
  952. struct iwl_cfg *cfg;
  953. /* temporary frame storage list */
  954. struct list_head free_frames;
  955. int frames_count;
  956. enum ieee80211_band band;
  957. int alloc_rxb_page;
  958. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  959. struct iwl_rx_mem_buffer *rxb);
  960. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  961. /* spectrum measurement report caching */
  962. struct iwl_spectrum_notification measure_report;
  963. u8 measurement_status;
  964. /* ucode beacon time */
  965. u32 ucode_beacon_time;
  966. int missed_beacon_threshold;
  967. /* storing the jiffies when the plcp error rate is received */
  968. unsigned long plcp_jiffies;
  969. /* force reset */
  970. struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
  971. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  972. * Access via channel # using indirect index array */
  973. struct iwl_channel_info *channel_info; /* channel info array */
  974. u8 channel_count; /* # of channels */
  975. /* thermal calibration */
  976. s32 temperature; /* degrees Kelvin */
  977. s32 last_temperature;
  978. /* init calibration results */
  979. struct iwl_calib_result calib_results[IWL_CALIB_MAX];
  980. /* Scan related variables */
  981. unsigned long scan_start;
  982. unsigned long scan_start_tsf;
  983. void *scan_cmd;
  984. enum ieee80211_band scan_band;
  985. struct cfg80211_scan_request *scan_request;
  986. bool is_internal_short_scan;
  987. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  988. u8 mgmt_tx_ant;
  989. /* spinlock */
  990. spinlock_t lock; /* protect general shared data */
  991. spinlock_t hcmd_lock; /* protect hcmd */
  992. spinlock_t reg_lock; /* protect hw register access */
  993. struct mutex mutex;
  994. struct mutex sync_cmd_mutex; /* enable serialization of sync commands */
  995. /* basic pci-network driver stuff */
  996. struct pci_dev *pci_dev;
  997. /* pci hardware address support */
  998. void __iomem *hw_base;
  999. u32 hw_rev;
  1000. u32 hw_wa_rev;
  1001. u8 rev_id;
  1002. /* uCode images, save to reload in case of failure */
  1003. int fw_index; /* firmware we're trying to load */
  1004. u32 ucode_ver; /* version of ucode, copy of
  1005. iwl_ucode.ver */
  1006. struct fw_desc ucode_code; /* runtime inst */
  1007. struct fw_desc ucode_data; /* runtime data original */
  1008. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  1009. struct fw_desc ucode_init; /* initialization inst */
  1010. struct fw_desc ucode_init_data; /* initialization data */
  1011. struct fw_desc ucode_boot; /* bootstrap inst */
  1012. enum ucode_type ucode_type;
  1013. u8 ucode_write_complete; /* the image write is complete */
  1014. char firmware_name[25];
  1015. struct iwl_rxon_time_cmd rxon_timing;
  1016. /* We declare this const so it can only be
  1017. * changed via explicit cast within the
  1018. * routines that actually update the physical
  1019. * hardware */
  1020. const struct iwl_rxon_cmd active_rxon;
  1021. struct iwl_rxon_cmd staging_rxon;
  1022. struct iwl_switch_rxon switch_rxon;
  1023. /* 1st responses from initialize and runtime uCode images.
  1024. * 4965's initialize alive response contains some calibration data. */
  1025. struct iwl_init_alive_resp card_alive_init;
  1026. struct iwl_alive_resp card_alive;
  1027. unsigned long last_blink_time;
  1028. u8 last_blink_rate;
  1029. u8 allow_blinking;
  1030. u64 led_tpt;
  1031. u16 active_rate;
  1032. u8 start_calib;
  1033. struct iwl_sensitivity_data sensitivity_data;
  1034. struct iwl_chain_noise_data chain_noise_data;
  1035. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  1036. struct iwl_ht_config current_ht_config;
  1037. /* Rate scaling data */
  1038. u8 retry_rate;
  1039. wait_queue_head_t wait_command_queue;
  1040. int activity_timer_active;
  1041. /* Rx and Tx DMA processing queues */
  1042. struct iwl_rx_queue rxq;
  1043. struct iwl_tx_queue *txq;
  1044. unsigned long txq_ctx_active_msk;
  1045. struct iwl_dma_ptr kw; /* keep warm address */
  1046. struct iwl_dma_ptr scd_bc_tbls;
  1047. u32 scd_base_addr; /* scheduler sram base address */
  1048. unsigned long status;
  1049. /* counts mgmt, ctl, and data packets */
  1050. struct traffic_stats tx_stats;
  1051. struct traffic_stats rx_stats;
  1052. /* counts interrupts */
  1053. struct isr_statistics isr_stats;
  1054. struct iwl_power_mgr power_data;
  1055. struct iwl_tt_mgmt thermal_throttle;
  1056. struct iwl_notif_statistics statistics;
  1057. #ifdef CONFIG_IWLWIFI_DEBUG
  1058. struct iwl_notif_statistics accum_statistics;
  1059. struct iwl_notif_statistics delta_statistics;
  1060. struct iwl_notif_statistics max_delta;
  1061. #endif
  1062. /* context information */
  1063. u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
  1064. u8 mac_addr[ETH_ALEN];
  1065. /*station table variables */
  1066. spinlock_t sta_lock;
  1067. int num_stations;
  1068. struct iwl_station_entry stations[IWL_STATION_COUNT];
  1069. struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; /* protected by mutex */
  1070. u8 key_mapping_key;
  1071. unsigned long ucode_key_table;
  1072. /* queue refcounts */
  1073. #define IWL_MAX_HW_QUEUES 32
  1074. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  1075. /* for each AC */
  1076. atomic_t queue_stop_count[4];
  1077. /* Indication if ieee80211_ops->open has been called */
  1078. u8 is_open;
  1079. u8 mac80211_registered;
  1080. /* eeprom -- this is in the card's little endian byte order */
  1081. u8 *eeprom;
  1082. int nvm_device_type;
  1083. struct iwl_eeprom_calib_info *calib_info;
  1084. enum nl80211_iftype iw_mode;
  1085. struct sk_buff *ibss_beacon;
  1086. /* Last Rx'd beacon timestamp */
  1087. u64 timestamp;
  1088. struct ieee80211_vif *vif;
  1089. union {
  1090. #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
  1091. struct {
  1092. void *shared_virt;
  1093. dma_addr_t shared_phys;
  1094. struct delayed_work thermal_periodic;
  1095. struct delayed_work rfkill_poll;
  1096. struct iwl3945_notif_statistics statistics;
  1097. #ifdef CONFIG_IWLWIFI_DEBUG
  1098. struct iwl3945_notif_statistics accum_statistics;
  1099. struct iwl3945_notif_statistics delta_statistics;
  1100. struct iwl3945_notif_statistics max_delta;
  1101. #endif
  1102. u32 sta_supp_rates;
  1103. int last_rx_rssi; /* From Rx packet statistics */
  1104. /* Rx'd packet timing information */
  1105. u32 last_beacon_time;
  1106. u64 last_tsf;
  1107. /*
  1108. * each calibration channel group in the
  1109. * EEPROM has a derived clip setting for
  1110. * each rate.
  1111. */
  1112. const struct iwl3945_clip_group clip_groups[5];
  1113. } _3945;
  1114. #endif
  1115. #if defined(CONFIG_IWLAGN) || defined(CONFIG_IWLAGN_MODULE)
  1116. struct {
  1117. /* INT ICT Table */
  1118. __le32 *ict_tbl;
  1119. void *ict_tbl_vir;
  1120. dma_addr_t ict_tbl_dma;
  1121. dma_addr_t aligned_ict_tbl_dma;
  1122. int ict_index;
  1123. u32 inta;
  1124. bool use_ict;
  1125. /*
  1126. * reporting the number of tids has AGG on. 0 means
  1127. * no AGGREGATION
  1128. */
  1129. u8 agg_tids_count;
  1130. struct iwl_rx_phy_res last_phy_res;
  1131. bool last_phy_res_valid;
  1132. struct completion firmware_loading_complete;
  1133. } _agn;
  1134. #endif
  1135. };
  1136. struct iwl_hw_params hw_params;
  1137. u32 inta_mask;
  1138. struct iwl_qos_info qos_data;
  1139. struct workqueue_struct *workqueue;
  1140. struct work_struct restart;
  1141. struct work_struct scan_completed;
  1142. struct work_struct rx_replenish;
  1143. struct work_struct abort_scan;
  1144. struct work_struct beacon_update;
  1145. struct work_struct tt_work;
  1146. struct work_struct ct_enter;
  1147. struct work_struct ct_exit;
  1148. struct work_struct start_internal_scan;
  1149. struct tasklet_struct irq_tasklet;
  1150. struct delayed_work init_alive_start;
  1151. struct delayed_work alive_start;
  1152. struct delayed_work scan_check;
  1153. /* TX Power */
  1154. s8 tx_power_user_lmt;
  1155. s8 tx_power_device_lmt;
  1156. s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
  1157. #ifdef CONFIG_IWLWIFI_DEBUG
  1158. /* debugging info */
  1159. u32 debug_level; /* per device debugging will override global
  1160. iwl_debug_level if set */
  1161. u32 framecnt_to_us;
  1162. atomic_t restrict_refcnt;
  1163. bool disable_ht40;
  1164. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1165. /* debugfs */
  1166. u16 tx_traffic_idx;
  1167. u16 rx_traffic_idx;
  1168. u8 *tx_traffic;
  1169. u8 *rx_traffic;
  1170. struct dentry *debugfs_dir;
  1171. u32 dbgfs_sram_offset, dbgfs_sram_len;
  1172. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1173. #endif /* CONFIG_IWLWIFI_DEBUG */
  1174. struct work_struct txpower_work;
  1175. u32 disable_sens_cal;
  1176. u32 disable_chain_noise_cal;
  1177. u32 disable_tx_power_cal;
  1178. struct work_struct run_time_calib_work;
  1179. struct timer_list statistics_periodic;
  1180. struct timer_list ucode_trace;
  1181. struct timer_list monitor_recover;
  1182. bool hw_ready;
  1183. struct iwl_event_log event_log;
  1184. }; /*iwl_priv */
  1185. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  1186. {
  1187. set_bit(txq_id, &priv->txq_ctx_active_msk);
  1188. }
  1189. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  1190. {
  1191. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  1192. }
  1193. #ifdef CONFIG_IWLWIFI_DEBUG
  1194. const char *iwl_get_tx_fail_reason(u32 status);
  1195. /*
  1196. * iwl_get_debug_level: Return active debug level for device
  1197. *
  1198. * Using sysfs it is possible to set per device debug level. This debug
  1199. * level will be used if set, otherwise the global debug level which can be
  1200. * set via module parameter is used.
  1201. */
  1202. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1203. {
  1204. if (priv->debug_level)
  1205. return priv->debug_level;
  1206. else
  1207. return iwl_debug_level;
  1208. }
  1209. #else
  1210. static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
  1211. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1212. {
  1213. return iwl_debug_level;
  1214. }
  1215. #endif
  1216. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  1217. int txq_id, int idx)
  1218. {
  1219. if (priv->txq[txq_id].txb[idx].skb[0])
  1220. return (struct ieee80211_hdr *)priv->txq[txq_id].
  1221. txb[idx].skb[0]->data;
  1222. return NULL;
  1223. }
  1224. static inline int iwl_is_associated(struct iwl_priv *priv)
  1225. {
  1226. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1227. }
  1228. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1229. {
  1230. if (ch_info == NULL)
  1231. return 0;
  1232. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1233. }
  1234. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1235. {
  1236. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1237. }
  1238. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1239. {
  1240. return ch_info->band == IEEE80211_BAND_5GHZ;
  1241. }
  1242. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1243. {
  1244. return ch_info->band == IEEE80211_BAND_2GHZ;
  1245. }
  1246. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1247. {
  1248. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1249. }
  1250. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1251. {
  1252. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1253. }
  1254. static inline void __iwl_free_pages(struct iwl_priv *priv, struct page *page)
  1255. {
  1256. __free_pages(page, priv->hw_params.rx_page_order);
  1257. priv->alloc_rxb_page--;
  1258. }
  1259. static inline void iwl_free_pages(struct iwl_priv *priv, unsigned long page)
  1260. {
  1261. free_pages(page, priv->hw_params.rx_page_order);
  1262. priv->alloc_rxb_page--;
  1263. }
  1264. #endif /* __iwl_dev_h__ */