iwl-dev.h 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 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. */
  30. #ifndef __iwl_dev_h__
  31. #define __iwl_dev_h__
  32. #include <linux/interrupt.h>
  33. #include <linux/pci.h> /* for struct pci_device_id */
  34. #include <linux/kernel.h>
  35. #include <linux/wait.h>
  36. #include <linux/leds.h>
  37. #include <net/ieee80211_radiotap.h>
  38. #include "iwl-eeprom.h"
  39. #include "iwl-csr.h"
  40. #include "iwl-prph.h"
  41. #include "iwl-debug.h"
  42. #include "iwl-agn-hw.h"
  43. #include "iwl-led.h"
  44. #include "iwl-power.h"
  45. #include "iwl-agn-rs.h"
  46. #include "iwl-agn-tt.h"
  47. #include "iwl-bus.h"
  48. #include "iwl-trans.h"
  49. #include "iwl-shared.h"
  50. struct iwl_tx_queue;
  51. /* CT-KILL constants */
  52. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  53. #define CT_KILL_THRESHOLD 114 /* in Celsius */
  54. #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
  55. /* Default noise level to report when noise measurement is not available.
  56. * This may be because we're:
  57. * 1) Not associated (4965, no beacon statistics being sent to driver)
  58. * 2) Scanning (noise measurement does not apply to associated channel)
  59. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  60. * Use default noise value of -127 ... this is below the range of measurable
  61. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  62. * Also, -127 works better than 0 when averaging frames with/without
  63. * noise info (e.g. averaging might be done in app); measured dBm values are
  64. * always negative ... using a negative value as the default keeps all
  65. * averages within an s8's (used in some apps) range of negative values. */
  66. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  67. /*
  68. * RTS threshold here is total size [2347] minus 4 FCS bytes
  69. * Per spec:
  70. * a value of 0 means RTS on all data/management packets
  71. * a value > max MSDU size means no RTS
  72. * else RTS for data/management frames where MPDU is larger
  73. * than RTS value.
  74. */
  75. #define DEFAULT_RTS_THRESHOLD 2347U
  76. #define MIN_RTS_THRESHOLD 0U
  77. #define MAX_RTS_THRESHOLD 2347U
  78. #define MAX_MSDU_SIZE 2304U
  79. #define MAX_MPDU_SIZE 2346U
  80. #define DEFAULT_BEACON_INTERVAL 200U
  81. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  82. #define DEFAULT_LONG_RETRY_LIMIT 4U
  83. /* defined below */
  84. struct iwl_device_cmd;
  85. struct iwl_cmd_meta {
  86. /* only for SYNC commands, iff the reply skb is wanted */
  87. struct iwl_host_cmd *source;
  88. /*
  89. * only for ASYNC commands
  90. * (which is somewhat stupid -- look at iwl-sta.c for instance
  91. * which duplicates a bunch of code because the callback isn't
  92. * invoked for SYNC commands, if it were and its result passed
  93. * through it would be simpler...)
  94. */
  95. void (*callback)(struct iwl_priv *priv,
  96. struct iwl_device_cmd *cmd,
  97. struct iwl_rx_packet *pkt);
  98. u32 flags;
  99. DEFINE_DMA_UNMAP_ADDR(mapping);
  100. DEFINE_DMA_UNMAP_LEN(len);
  101. };
  102. /*
  103. * Generic queue structure
  104. *
  105. * Contains common data for Rx and Tx queues.
  106. *
  107. * Note the difference between n_bd and n_window: the hardware
  108. * always assumes 256 descriptors, so n_bd is always 256 (unless
  109. * there might be HW changes in the future). For the normal TX
  110. * queues, n_window, which is the size of the software queue data
  111. * is also 256; however, for the command queue, n_window is only
  112. * 32 since we don't need so many commands pending. Since the HW
  113. * still uses 256 BDs for DMA though, n_bd stays 256. As a result,
  114. * the software buffers (in the variables @meta, @txb in struct
  115. * iwl_tx_queue) only have 32 entries, while the HW buffers (@tfds
  116. * in the same struct) have 256.
  117. * This means that we end up with the following:
  118. * HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
  119. * SW entries: | 0 | ... | 31 |
  120. * where N is a number between 0 and 7. This means that the SW
  121. * data is a window overlayed over the HW queue.
  122. */
  123. struct iwl_queue {
  124. int n_bd; /* number of BDs in this queue */
  125. int write_ptr; /* 1-st empty entry (index) host_w*/
  126. int read_ptr; /* last used entry (index) host_r*/
  127. /* use for monitoring and recovering the stuck queue */
  128. dma_addr_t dma_addr; /* physical addr for BD's */
  129. int n_window; /* safe queue window */
  130. u32 id;
  131. int low_mark; /* low watermark, resume queue if free
  132. * space more than this */
  133. int high_mark; /* high watermark, stop queue if free
  134. * space less than this */
  135. };
  136. /**
  137. * struct iwl_tx_queue - Tx Queue for DMA
  138. * @q: generic Rx/Tx queue descriptor
  139. * @bd: base of circular buffer of TFDs
  140. * @cmd: array of command/TX buffer pointers
  141. * @meta: array of meta data for each command/tx buffer
  142. * @dma_addr_cmd: physical address of cmd/tx buffer array
  143. * @txb: array of per-TFD driver data
  144. * @time_stamp: time (in jiffies) of last read_ptr change
  145. * @need_update: indicates need to update read/write index
  146. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  147. * @sta_id: valid if sched_retry is set
  148. * @tid: valid if sched_retry is set
  149. *
  150. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  151. * descriptors) and required locking structures.
  152. */
  153. #define TFD_TX_CMD_SLOTS 256
  154. #define TFD_CMD_SLOTS 32
  155. struct iwl_tx_queue {
  156. struct iwl_queue q;
  157. struct iwl_tfd *tfds;
  158. struct iwl_device_cmd **cmd;
  159. struct iwl_cmd_meta *meta;
  160. struct sk_buff **skbs;
  161. unsigned long time_stamp;
  162. u8 need_update;
  163. u8 sched_retry;
  164. u8 active;
  165. u8 swq_id;
  166. u16 sta_id;
  167. u16 tid;
  168. };
  169. #define IWL_NUM_SCAN_RATES (2)
  170. /*
  171. * One for each channel, holds all channel setup data
  172. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  173. * with one another!
  174. */
  175. struct iwl_channel_info {
  176. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  177. struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
  178. * HT40 channel */
  179. u8 channel; /* channel number */
  180. u8 flags; /* flags copied from EEPROM */
  181. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  182. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  183. s8 min_power; /* always 0 */
  184. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  185. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  186. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  187. enum ieee80211_band band;
  188. /* HT40 channel info */
  189. s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  190. u8 ht40_flags; /* flags copied from EEPROM */
  191. u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  192. };
  193. #define IWL_TX_FIFO_BK 0 /* shared */
  194. #define IWL_TX_FIFO_BE 1
  195. #define IWL_TX_FIFO_VI 2 /* shared */
  196. #define IWL_TX_FIFO_VO 3
  197. #define IWL_TX_FIFO_BK_IPAN IWL_TX_FIFO_BK
  198. #define IWL_TX_FIFO_BE_IPAN 4
  199. #define IWL_TX_FIFO_VI_IPAN IWL_TX_FIFO_VI
  200. #define IWL_TX_FIFO_VO_IPAN 5
  201. /* re-uses the VO FIFO, uCode will properly flush/schedule */
  202. #define IWL_TX_FIFO_AUX 5
  203. #define IWL_TX_FIFO_UNUSED -1
  204. /* AUX (TX during scan dwell) queue */
  205. #define IWL_AUX_QUEUE 10
  206. /*
  207. * Minimum number of queues. MAX_NUM is defined in hw specific files.
  208. * Set the minimum to accommodate
  209. * - 4 standard TX queues
  210. * - the command queue
  211. * - 4 PAN TX queues
  212. * - the PAN multicast queue, and
  213. * - the AUX (TX during scan dwell) queue.
  214. */
  215. #define IWL_MIN_NUM_QUEUES 11
  216. /*
  217. * Command queue depends on iPAN support.
  218. */
  219. #define IWL_DEFAULT_CMD_QUEUE_NUM 4
  220. #define IWL_IPAN_CMD_QUEUE_NUM 9
  221. /*
  222. * This queue number is required for proper operation
  223. * because the ucode will stop/start the scheduler as
  224. * required.
  225. */
  226. #define IWL_IPAN_MCAST_QUEUE 8
  227. #define IEEE80211_DATA_LEN 2304
  228. #define IEEE80211_4ADDR_LEN 30
  229. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  230. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  231. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  232. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  233. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  234. enum {
  235. CMD_SYNC = 0,
  236. CMD_ASYNC = BIT(0),
  237. CMD_WANT_SKB = BIT(1),
  238. CMD_ON_DEMAND = BIT(2),
  239. };
  240. #define DEF_CMD_PAYLOAD_SIZE 320
  241. /**
  242. * struct iwl_device_cmd
  243. *
  244. * For allocation of the command and tx queues, this establishes the overall
  245. * size of the largest command we send to uCode, except for commands that
  246. * aren't fully copied and use other TFD space.
  247. */
  248. struct iwl_device_cmd {
  249. struct iwl_cmd_header hdr; /* uCode API */
  250. union {
  251. u32 flags;
  252. u8 val8;
  253. u16 val16;
  254. u32 val32;
  255. struct iwl_tx_cmd tx;
  256. struct iwl6000_channel_switch_cmd chswitch;
  257. u8 payload[DEF_CMD_PAYLOAD_SIZE];
  258. } __packed cmd;
  259. } __packed;
  260. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
  261. #define IWL_MAX_CMD_TFDS 2
  262. enum iwl_hcmd_dataflag {
  263. IWL_HCMD_DFL_NOCOPY = BIT(0),
  264. };
  265. /**
  266. * struct iwl_host_cmd - Host command to the uCode
  267. * @data: array of chunks that composes the data of the host command
  268. * @reply_page: pointer to the page that holds the response to the host command
  269. * @callback:
  270. * @flags: can be CMD_* note CMD_WANT_SKB is incompatible withe CMD_ASYNC
  271. * @len: array of the lenths of the chunks in data
  272. * @dataflags:
  273. * @id: id of the host command
  274. */
  275. struct iwl_host_cmd {
  276. const void *data[IWL_MAX_CMD_TFDS];
  277. unsigned long reply_page;
  278. void (*callback)(struct iwl_priv *priv,
  279. struct iwl_device_cmd *cmd,
  280. struct iwl_rx_packet *pkt);
  281. u32 flags;
  282. u16 len[IWL_MAX_CMD_TFDS];
  283. u8 dataflags[IWL_MAX_CMD_TFDS];
  284. u8 id;
  285. };
  286. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  287. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  288. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  289. #define IWL_SUPPORTED_RATES_IE_LEN 8
  290. #define IWL_INVALID_RATE 0xFF
  291. #define IWL_INVALID_VALUE -1
  292. union iwl_ht_rate_supp {
  293. u16 rates;
  294. struct {
  295. u8 siso_rate;
  296. u8 mimo_rate;
  297. };
  298. };
  299. #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
  300. #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
  301. #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
  302. #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
  303. #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
  304. #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
  305. #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
  306. /*
  307. * Maximal MPDU density for TX aggregation
  308. * 4 - 2us density
  309. * 5 - 4us density
  310. * 6 - 8us density
  311. * 7 - 16us density
  312. */
  313. #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
  314. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  315. #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
  316. #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
  317. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  318. #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
  319. #define CFG_HT_MPDU_DENSITY_MIN (0x1)
  320. struct iwl_ht_config {
  321. bool single_chain_sufficient;
  322. enum ieee80211_smps_mode smps; /* current smps mode */
  323. };
  324. /* QoS structures */
  325. struct iwl_qos_info {
  326. int qos_active;
  327. struct iwl_qosparam_cmd def_qos_parm;
  328. };
  329. /*
  330. * Structure should be accessed with sta_lock held. When station addition
  331. * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
  332. * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
  333. * held.
  334. */
  335. struct iwl_station_entry {
  336. struct iwl_addsta_cmd sta;
  337. u8 used, ctxid;
  338. struct iwl_link_quality_cmd *lq;
  339. };
  340. struct iwl_station_priv_common {
  341. struct iwl_rxon_context *ctx;
  342. u8 sta_id;
  343. };
  344. /*
  345. * iwl_station_priv: Driver's private station information
  346. *
  347. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  348. * in the structure for use by driver. This structure is places in that
  349. * space.
  350. */
  351. struct iwl_station_priv {
  352. struct iwl_station_priv_common common;
  353. struct iwl_lq_sta lq_sta;
  354. atomic_t pending_frames;
  355. bool client;
  356. bool asleep;
  357. u8 max_agg_bufsize;
  358. };
  359. /**
  360. * struct iwl_vif_priv - driver's private per-interface information
  361. *
  362. * When mac80211 allocates a virtual interface, it can allocate
  363. * space for us to put data into.
  364. */
  365. struct iwl_vif_priv {
  366. struct iwl_rxon_context *ctx;
  367. u8 ibss_bssid_sta_id;
  368. };
  369. /* one for each uCode image (inst/data, boot/init/runtime) */
  370. struct fw_desc {
  371. void *v_addr; /* access by driver */
  372. dma_addr_t p_addr; /* access by card's busmaster DMA */
  373. u32 len; /* bytes */
  374. };
  375. struct fw_img {
  376. struct fw_desc code, data;
  377. };
  378. /* v1/v2 uCode file layout */
  379. struct iwl_ucode_header {
  380. __le32 ver; /* major/minor/API/serial */
  381. union {
  382. struct {
  383. __le32 inst_size; /* bytes of runtime code */
  384. __le32 data_size; /* bytes of runtime data */
  385. __le32 init_size; /* bytes of init code */
  386. __le32 init_data_size; /* bytes of init data */
  387. __le32 boot_size; /* bytes of bootstrap code */
  388. u8 data[0]; /* in same order as sizes */
  389. } v1;
  390. struct {
  391. __le32 build; /* build number */
  392. __le32 inst_size; /* bytes of runtime code */
  393. __le32 data_size; /* bytes of runtime data */
  394. __le32 init_size; /* bytes of init code */
  395. __le32 init_data_size; /* bytes of init data */
  396. __le32 boot_size; /* bytes of bootstrap code */
  397. u8 data[0]; /* in same order as sizes */
  398. } v2;
  399. } u;
  400. };
  401. /*
  402. * new TLV uCode file layout
  403. *
  404. * The new TLV file format contains TLVs, that each specify
  405. * some piece of data. To facilitate "groups", for example
  406. * different instruction image with different capabilities,
  407. * bundled with the same init image, an alternative mechanism
  408. * is provided:
  409. * When the alternative field is 0, that means that the item
  410. * is always valid. When it is non-zero, then it is only
  411. * valid in conjunction with items of the same alternative,
  412. * in which case the driver (user) selects one alternative
  413. * to use.
  414. */
  415. enum iwl_ucode_tlv_type {
  416. IWL_UCODE_TLV_INVALID = 0, /* unused */
  417. IWL_UCODE_TLV_INST = 1,
  418. IWL_UCODE_TLV_DATA = 2,
  419. IWL_UCODE_TLV_INIT = 3,
  420. IWL_UCODE_TLV_INIT_DATA = 4,
  421. IWL_UCODE_TLV_BOOT = 5,
  422. IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
  423. IWL_UCODE_TLV_PAN = 7,
  424. IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
  425. IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
  426. IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
  427. IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
  428. IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
  429. IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
  430. IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
  431. IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
  432. IWL_UCODE_TLV_WOWLAN_INST = 16,
  433. IWL_UCODE_TLV_WOWLAN_DATA = 17,
  434. IWL_UCODE_TLV_FLAGS = 18,
  435. };
  436. /**
  437. * enum iwl_ucode_tlv_flag - ucode API flags
  438. * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
  439. * was a separate TLV but moved here to save space.
  440. * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
  441. * treats good CRC threshold as a boolean
  442. * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
  443. * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
  444. */
  445. enum iwl_ucode_tlv_flag {
  446. IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
  447. IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
  448. IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
  449. IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
  450. };
  451. struct iwl_ucode_tlv {
  452. __le16 type; /* see above */
  453. __le16 alternative; /* see comment */
  454. __le32 length; /* not including type/length fields */
  455. u8 data[0];
  456. } __packed;
  457. #define IWL_TLV_UCODE_MAGIC 0x0a4c5749
  458. struct iwl_tlv_ucode_header {
  459. /*
  460. * The TLV style ucode header is distinguished from
  461. * the v1/v2 style header by first four bytes being
  462. * zero, as such is an invalid combination of
  463. * major/minor/API/serial versions.
  464. */
  465. __le32 zero;
  466. __le32 magic;
  467. u8 human_readable[64];
  468. __le32 ver; /* major/minor/API/serial */
  469. __le32 build;
  470. __le64 alternatives; /* bitmask of valid alternatives */
  471. /*
  472. * The data contained herein has a TLV layout,
  473. * see above for the TLV header and types.
  474. * Note that each TLV is padded to a length
  475. * that is a multiple of 4 for alignment.
  476. */
  477. u8 data[0];
  478. };
  479. struct iwl_sensitivity_ranges {
  480. u16 min_nrg_cck;
  481. u16 max_nrg_cck;
  482. u16 nrg_th_cck;
  483. u16 nrg_th_ofdm;
  484. u16 auto_corr_min_ofdm;
  485. u16 auto_corr_min_ofdm_mrc;
  486. u16 auto_corr_min_ofdm_x1;
  487. u16 auto_corr_min_ofdm_mrc_x1;
  488. u16 auto_corr_max_ofdm;
  489. u16 auto_corr_max_ofdm_mrc;
  490. u16 auto_corr_max_ofdm_x1;
  491. u16 auto_corr_max_ofdm_mrc_x1;
  492. u16 auto_corr_max_cck;
  493. u16 auto_corr_max_cck_mrc;
  494. u16 auto_corr_min_cck;
  495. u16 auto_corr_min_cck_mrc;
  496. u16 barker_corr_th_min;
  497. u16 barker_corr_th_min_mrc;
  498. u16 nrg_th_cca;
  499. };
  500. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  501. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  502. /******************************************************************************
  503. *
  504. * Functions implemented in core module which are forward declared here
  505. * for use by iwl-[4-5].c
  506. *
  507. * NOTE: The implementation of these functions are not hardware specific
  508. * which is why they are in the core module files.
  509. *
  510. * Naming convention --
  511. * iwl_ <-- Is part of iwlwifi
  512. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  513. *
  514. ****************************************************************************/
  515. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  516. extern const u8 iwl_bcast_addr[ETH_ALEN];
  517. extern int iwl_queue_space(const struct iwl_queue *q);
  518. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  519. {
  520. return q->write_ptr >= q->read_ptr ?
  521. (i >= q->read_ptr && i < q->write_ptr) :
  522. !(i < q->read_ptr && i >= q->write_ptr);
  523. }
  524. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index)
  525. {
  526. return index & (q->n_window - 1);
  527. }
  528. #define IWL_OPERATION_MODE_AUTO 0
  529. #define IWL_OPERATION_MODE_HT_ONLY 1
  530. #define IWL_OPERATION_MODE_MIXED 2
  531. #define IWL_OPERATION_MODE_20MHZ 3
  532. #define IWL_TX_CRC_SIZE 4
  533. #define IWL_TX_DELIMITER_SIZE 4
  534. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  535. /* Sensitivity and chain noise calibration */
  536. #define INITIALIZATION_VALUE 0xFFFF
  537. #define IWL_CAL_NUM_BEACONS 16
  538. #define MAXIMUM_ALLOWED_PATHLOSS 15
  539. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  540. #define MAX_FA_OFDM 50
  541. #define MIN_FA_OFDM 5
  542. #define MAX_FA_CCK 50
  543. #define MIN_FA_CCK 5
  544. #define AUTO_CORR_STEP_OFDM 1
  545. #define AUTO_CORR_STEP_CCK 3
  546. #define AUTO_CORR_MAX_TH_CCK 160
  547. #define NRG_DIFF 2
  548. #define NRG_STEP_CCK 2
  549. #define NRG_MARGIN 8
  550. #define MAX_NUMBER_CCK_NO_FA 100
  551. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  552. #define CHAIN_A 0
  553. #define CHAIN_B 1
  554. #define CHAIN_C 2
  555. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  556. #define ALL_BAND_FILTER 0xFF00
  557. #define IN_BAND_FILTER 0xFF
  558. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  559. #define NRG_NUM_PREV_STAT_L 20
  560. #define NUM_RX_CHAINS 3
  561. enum iwlagn_false_alarm_state {
  562. IWL_FA_TOO_MANY = 0,
  563. IWL_FA_TOO_FEW = 1,
  564. IWL_FA_GOOD_RANGE = 2,
  565. };
  566. enum iwlagn_chain_noise_state {
  567. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  568. IWL_CHAIN_NOISE_ACCUMULATE,
  569. IWL_CHAIN_NOISE_CALIBRATED,
  570. IWL_CHAIN_NOISE_DONE,
  571. };
  572. /*
  573. * enum iwl_calib
  574. * defines the order in which results of initial calibrations
  575. * should be sent to the runtime uCode
  576. */
  577. enum iwl_calib {
  578. IWL_CALIB_XTAL,
  579. IWL_CALIB_DC,
  580. IWL_CALIB_LO,
  581. IWL_CALIB_TX_IQ,
  582. IWL_CALIB_TX_IQ_PERD,
  583. IWL_CALIB_BASE_BAND,
  584. IWL_CALIB_TEMP_OFFSET,
  585. IWL_CALIB_MAX
  586. };
  587. /* Opaque calibration results */
  588. struct iwl_calib_result {
  589. void *buf;
  590. size_t buf_len;
  591. };
  592. /* Sensitivity calib data */
  593. struct iwl_sensitivity_data {
  594. u32 auto_corr_ofdm;
  595. u32 auto_corr_ofdm_mrc;
  596. u32 auto_corr_ofdm_x1;
  597. u32 auto_corr_ofdm_mrc_x1;
  598. u32 auto_corr_cck;
  599. u32 auto_corr_cck_mrc;
  600. u32 last_bad_plcp_cnt_ofdm;
  601. u32 last_fa_cnt_ofdm;
  602. u32 last_bad_plcp_cnt_cck;
  603. u32 last_fa_cnt_cck;
  604. u32 nrg_curr_state;
  605. u32 nrg_prev_state;
  606. u32 nrg_value[10];
  607. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  608. u32 nrg_silence_ref;
  609. u32 nrg_energy_idx;
  610. u32 nrg_silence_idx;
  611. u32 nrg_th_cck;
  612. s32 nrg_auto_corr_silence_diff;
  613. u32 num_in_cck_no_fa;
  614. u32 nrg_th_ofdm;
  615. u16 barker_corr_th_min;
  616. u16 barker_corr_th_min_mrc;
  617. u16 nrg_th_cca;
  618. };
  619. /* Chain noise (differential Rx gain) calib data */
  620. struct iwl_chain_noise_data {
  621. u32 active_chains;
  622. u32 chain_noise_a;
  623. u32 chain_noise_b;
  624. u32 chain_noise_c;
  625. u32 chain_signal_a;
  626. u32 chain_signal_b;
  627. u32 chain_signal_c;
  628. u16 beacon_count;
  629. u8 disconn_array[NUM_RX_CHAINS];
  630. u8 delta_gain_code[NUM_RX_CHAINS];
  631. u8 radio_write;
  632. u8 state;
  633. };
  634. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  635. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  636. #define IWL_TRAFFIC_ENTRIES (256)
  637. #define IWL_TRAFFIC_ENTRY_SIZE (64)
  638. enum {
  639. MEASUREMENT_READY = (1 << 0),
  640. MEASUREMENT_ACTIVE = (1 << 1),
  641. };
  642. enum iwl_nvm_type {
  643. NVM_DEVICE_TYPE_EEPROM = 0,
  644. NVM_DEVICE_TYPE_OTP,
  645. };
  646. /*
  647. * Two types of OTP memory access modes
  648. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  649. * based on physical memory addressing
  650. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  651. * based on logical memory addressing
  652. */
  653. enum iwl_access_mode {
  654. IWL_OTP_ACCESS_ABSOLUTE,
  655. IWL_OTP_ACCESS_RELATIVE,
  656. };
  657. /**
  658. * enum iwl_pa_type - Power Amplifier type
  659. * @IWL_PA_SYSTEM: based on uCode configuration
  660. * @IWL_PA_INTERNAL: use Internal only
  661. */
  662. enum iwl_pa_type {
  663. IWL_PA_SYSTEM = 0,
  664. IWL_PA_INTERNAL = 1,
  665. };
  666. /* reply_tx_statistics (for _agn devices) */
  667. struct reply_tx_error_statistics {
  668. u32 pp_delay;
  669. u32 pp_few_bytes;
  670. u32 pp_bt_prio;
  671. u32 pp_quiet_period;
  672. u32 pp_calc_ttak;
  673. u32 int_crossed_retry;
  674. u32 short_limit;
  675. u32 long_limit;
  676. u32 fifo_underrun;
  677. u32 drain_flow;
  678. u32 rfkill_flush;
  679. u32 life_expire;
  680. u32 dest_ps;
  681. u32 host_abort;
  682. u32 bt_retry;
  683. u32 sta_invalid;
  684. u32 frag_drop;
  685. u32 tid_disable;
  686. u32 fifo_flush;
  687. u32 insuff_cf_poll;
  688. u32 fail_hw_drop;
  689. u32 sta_color_mismatch;
  690. u32 unknown;
  691. };
  692. /* reply_agg_tx_statistics (for _agn devices) */
  693. struct reply_agg_tx_error_statistics {
  694. u32 underrun;
  695. u32 bt_prio;
  696. u32 few_bytes;
  697. u32 abort;
  698. u32 last_sent_ttl;
  699. u32 last_sent_try;
  700. u32 last_sent_bt_kill;
  701. u32 scd_query;
  702. u32 bad_crc32;
  703. u32 response;
  704. u32 dump_tx;
  705. u32 delay_tx;
  706. u32 unknown;
  707. };
  708. /* management statistics */
  709. enum iwl_mgmt_stats {
  710. MANAGEMENT_ASSOC_REQ = 0,
  711. MANAGEMENT_ASSOC_RESP,
  712. MANAGEMENT_REASSOC_REQ,
  713. MANAGEMENT_REASSOC_RESP,
  714. MANAGEMENT_PROBE_REQ,
  715. MANAGEMENT_PROBE_RESP,
  716. MANAGEMENT_BEACON,
  717. MANAGEMENT_ATIM,
  718. MANAGEMENT_DISASSOC,
  719. MANAGEMENT_AUTH,
  720. MANAGEMENT_DEAUTH,
  721. MANAGEMENT_ACTION,
  722. MANAGEMENT_MAX,
  723. };
  724. /* control statistics */
  725. enum iwl_ctrl_stats {
  726. CONTROL_BACK_REQ = 0,
  727. CONTROL_BACK,
  728. CONTROL_PSPOLL,
  729. CONTROL_RTS,
  730. CONTROL_CTS,
  731. CONTROL_ACK,
  732. CONTROL_CFEND,
  733. CONTROL_CFENDACK,
  734. CONTROL_MAX,
  735. };
  736. struct traffic_stats {
  737. #ifdef CONFIG_IWLWIFI_DEBUGFS
  738. u32 mgmt[MANAGEMENT_MAX];
  739. u32 ctrl[CONTROL_MAX];
  740. u32 data_cnt;
  741. u64 data_bytes;
  742. #endif
  743. };
  744. /*
  745. * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  746. * to perform continuous uCode event logging operation if enabled
  747. */
  748. #define UCODE_TRACE_PERIOD (100)
  749. /*
  750. * iwl_event_log: current uCode event log position
  751. *
  752. * @ucode_trace: enable/disable ucode continuous trace timer
  753. * @num_wraps: how many times the event buffer wraps
  754. * @next_entry: the entry just before the next one that uCode would fill
  755. * @non_wraps_count: counter for no wrap detected when dump ucode events
  756. * @wraps_once_count: counter for wrap once detected when dump ucode events
  757. * @wraps_more_count: counter for wrap more than once detected
  758. * when dump ucode events
  759. */
  760. struct iwl_event_log {
  761. bool ucode_trace;
  762. u32 num_wraps;
  763. u32 next_entry;
  764. int non_wraps_count;
  765. int wraps_once_count;
  766. int wraps_more_count;
  767. };
  768. /*
  769. * host interrupt timeout value
  770. * used with setting interrupt coalescing timer
  771. * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
  772. *
  773. * default interrupt coalescing timer is 64 x 32 = 2048 usecs
  774. * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
  775. */
  776. #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
  777. #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
  778. #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
  779. #define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
  780. #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
  781. #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
  782. /*
  783. * This is the threshold value of plcp error rate per 100mSecs. It is
  784. * used to set and check for the validity of plcp_delta.
  785. */
  786. #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
  787. #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
  788. #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
  789. #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
  790. #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
  791. #define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
  792. #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
  793. #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
  794. /* TX queue watchdog timeouts in mSecs */
  795. #define IWL_DEF_WD_TIMEOUT (2000)
  796. #define IWL_LONG_WD_TIMEOUT (10000)
  797. #define IWL_MAX_WD_TIMEOUT (120000)
  798. /* BT Antenna Coupling Threshold (dB) */
  799. #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
  800. /* Firmware reload counter and Timestamp */
  801. #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
  802. #define IWL_MAX_CONTINUE_RELOAD_CNT 4
  803. enum iwl_reset {
  804. IWL_RF_RESET = 0,
  805. IWL_FW_RESET,
  806. IWL_MAX_FORCE_RESET,
  807. };
  808. struct iwl_force_reset {
  809. int reset_request_count;
  810. int reset_success_count;
  811. int reset_reject_count;
  812. unsigned long reset_duration;
  813. unsigned long last_force_reset_jiffies;
  814. };
  815. /* extend beacon time format bit shifting */
  816. /*
  817. * for _agn devices
  818. * bits 31:22 - extended
  819. * bits 21:0 - interval
  820. */
  821. #define IWLAGN_EXT_BEACON_TIME_POS 22
  822. /**
  823. * struct iwl_notification_wait - notification wait entry
  824. * @list: list head for global list
  825. * @fn: function called with the notification
  826. * @cmd: command ID
  827. *
  828. * This structure is not used directly, to wait for a
  829. * notification declare it on the stack, and call
  830. * iwlagn_init_notification_wait() with appropriate
  831. * parameters. Then do whatever will cause the ucode
  832. * to notify the driver, and to wait for that then
  833. * call iwlagn_wait_notification().
  834. *
  835. * Each notification is one-shot. If at some point we
  836. * need to support multi-shot notifications (which
  837. * can't be allocated on the stack) we need to modify
  838. * the code for them.
  839. */
  840. struct iwl_notification_wait {
  841. struct list_head list;
  842. void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt,
  843. void *data);
  844. void *fn_data;
  845. u8 cmd;
  846. bool triggered, aborted;
  847. };
  848. enum iwl_rxon_context_id {
  849. IWL_RXON_CTX_BSS,
  850. IWL_RXON_CTX_PAN,
  851. NUM_IWL_RXON_CTX
  852. };
  853. struct iwl_rxon_context {
  854. struct ieee80211_vif *vif;
  855. const u8 *ac_to_fifo;
  856. const u8 *ac_to_queue;
  857. u8 mcast_queue;
  858. /*
  859. * We could use the vif to indicate active, but we
  860. * also need it to be active during disabling when
  861. * we already removed the vif for type setting.
  862. */
  863. bool always_active, is_active;
  864. bool ht_need_multiple_chains;
  865. enum iwl_rxon_context_id ctxid;
  866. u32 interface_modes, exclusive_interface_modes;
  867. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  868. /*
  869. * We declare this const so it can only be
  870. * changed via explicit cast within the
  871. * routines that actually update the physical
  872. * hardware.
  873. */
  874. const struct iwl_rxon_cmd active;
  875. struct iwl_rxon_cmd staging;
  876. struct iwl_rxon_time_cmd timing;
  877. struct iwl_qos_info qos_data;
  878. u8 bcast_sta_id, ap_sta_id;
  879. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  880. u8 qos_cmd;
  881. u8 wep_key_cmd;
  882. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  883. u8 key_mapping_keys;
  884. __le32 station_flags;
  885. int beacon_int;
  886. struct {
  887. bool non_gf_sta_present;
  888. u8 protection;
  889. bool enabled, is_40mhz;
  890. u8 extension_chan_offset;
  891. } ht;
  892. bool last_tx_rejected;
  893. };
  894. enum iwl_scan_type {
  895. IWL_SCAN_NORMAL,
  896. IWL_SCAN_RADIO_RESET,
  897. IWL_SCAN_ROC,
  898. };
  899. enum iwlagn_ucode_type {
  900. IWL_UCODE_NONE,
  901. IWL_UCODE_REGULAR,
  902. IWL_UCODE_INIT,
  903. IWL_UCODE_WOWLAN,
  904. };
  905. #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
  906. struct iwl_testmode_trace {
  907. u32 buff_size;
  908. u32 total_size;
  909. u32 num_chunks;
  910. u8 *cpu_addr;
  911. u8 *trace_addr;
  912. dma_addr_t dma_addr;
  913. bool trace_enabled;
  914. };
  915. #endif
  916. struct iwl_priv {
  917. /*data shared among all the driver's layers */
  918. struct iwl_shared _shrd;
  919. struct iwl_shared *shrd;
  920. /* ieee device used by generic ieee processing code */
  921. struct ieee80211_hw *hw;
  922. struct ieee80211_channel *ieee_channels;
  923. struct ieee80211_rate *ieee_rates;
  924. struct iwl_cfg *cfg;
  925. enum ieee80211_band band;
  926. void (*pre_rx_handler)(struct iwl_priv *priv,
  927. struct iwl_rx_mem_buffer *rxb);
  928. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  929. struct iwl_rx_mem_buffer *rxb);
  930. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  931. /* spectrum measurement report caching */
  932. struct iwl_spectrum_notification measure_report;
  933. u8 measurement_status;
  934. /* ucode beacon time */
  935. u32 ucode_beacon_time;
  936. int missed_beacon_threshold;
  937. /* track IBSS manager (last beacon) status */
  938. u32 ibss_manager;
  939. /* jiffies when last recovery from statistics was performed */
  940. unsigned long rx_statistics_jiffies;
  941. /*counters */
  942. u32 rx_handlers_stats[REPLY_MAX];
  943. /* force reset */
  944. struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
  945. /* firmware reload counter and timestamp */
  946. unsigned long reload_jiffies;
  947. int reload_count;
  948. /* we allocate array of iwl_channel_info for NIC's valid channels.
  949. * Access via channel # using indirect index array */
  950. struct iwl_channel_info *channel_info; /* channel info array */
  951. u8 channel_count; /* # of channels */
  952. /* thermal calibration */
  953. s32 temperature; /* degrees Kelvin */
  954. s32 last_temperature;
  955. /* init calibration results */
  956. struct iwl_calib_result calib_results[IWL_CALIB_MAX];
  957. /* Scan related variables */
  958. unsigned long scan_start;
  959. unsigned long scan_start_tsf;
  960. void *scan_cmd;
  961. enum ieee80211_band scan_band;
  962. struct cfg80211_scan_request *scan_request;
  963. struct ieee80211_vif *scan_vif;
  964. enum iwl_scan_type scan_type;
  965. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  966. u8 mgmt_tx_ant;
  967. /*TODO: remove these pointers - use bus(priv) instead */
  968. struct iwl_bus *bus; /* bus specific data */
  969. /* microcode/device supports multiple contexts */
  970. u8 valid_contexts;
  971. /* max number of station keys */
  972. u8 sta_key_max_num;
  973. bool new_scan_threshold_behaviour;
  974. /* EEPROM MAC addresses */
  975. struct mac_address addresses[2];
  976. /* uCode images, save to reload in case of failure */
  977. int fw_index; /* firmware we're trying to load */
  978. u32 ucode_ver; /* version of ucode, copy of
  979. iwl_ucode.ver */
  980. struct fw_img ucode_rt;
  981. struct fw_img ucode_init;
  982. struct fw_img ucode_wowlan;
  983. enum iwlagn_ucode_type ucode_type;
  984. u8 ucode_write_complete; /* the image write is complete */
  985. char firmware_name[25];
  986. struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
  987. __le16 switch_channel;
  988. struct {
  989. u32 error_event_table;
  990. u32 log_event_table;
  991. } device_pointers;
  992. u16 active_rate;
  993. u8 start_calib;
  994. struct iwl_sensitivity_data sensitivity_data;
  995. struct iwl_chain_noise_data chain_noise_data;
  996. bool enhance_sensitivity_table;
  997. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  998. __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
  999. struct iwl_ht_config current_ht_config;
  1000. /* Rate scaling data */
  1001. u8 retry_rate;
  1002. wait_queue_head_t wait_command_queue;
  1003. int activity_timer_active;
  1004. /* Tx DMA processing queues */
  1005. struct iwl_tx_queue *txq;
  1006. unsigned long txq_ctx_active_msk;
  1007. /* counts mgmt, ctl, and data packets */
  1008. struct traffic_stats tx_stats;
  1009. struct traffic_stats rx_stats;
  1010. struct iwl_power_mgr power_data;
  1011. struct iwl_tt_mgmt thermal_throttle;
  1012. /* station table variables */
  1013. int num_stations;
  1014. struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
  1015. unsigned long ucode_key_table;
  1016. /* queue refcounts */
  1017. #define IWL_MAX_HW_QUEUES 32
  1018. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  1019. /* for each AC */
  1020. atomic_t queue_stop_count[4];
  1021. /* Indication if ieee80211_ops->open has been called */
  1022. u8 is_open;
  1023. u8 mac80211_registered;
  1024. /* eeprom -- this is in the card's little endian byte order */
  1025. u8 *eeprom;
  1026. int nvm_device_type;
  1027. struct iwl_eeprom_calib_info *calib_info;
  1028. enum nl80211_iftype iw_mode;
  1029. /* Last Rx'd beacon timestamp */
  1030. u64 timestamp;
  1031. struct {
  1032. __le32 flag;
  1033. struct statistics_general_common common;
  1034. struct statistics_rx_non_phy rx_non_phy;
  1035. struct statistics_rx_phy rx_ofdm;
  1036. struct statistics_rx_ht_phy rx_ofdm_ht;
  1037. struct statistics_rx_phy rx_cck;
  1038. struct statistics_tx tx;
  1039. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1040. struct statistics_bt_activity bt_activity;
  1041. __le32 num_bt_kills, accum_num_bt_kills;
  1042. #endif
  1043. } statistics;
  1044. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1045. struct {
  1046. struct statistics_general_common common;
  1047. struct statistics_rx_non_phy rx_non_phy;
  1048. struct statistics_rx_phy rx_ofdm;
  1049. struct statistics_rx_ht_phy rx_ofdm_ht;
  1050. struct statistics_rx_phy rx_cck;
  1051. struct statistics_tx tx;
  1052. struct statistics_bt_activity bt_activity;
  1053. } accum_stats, delta_stats, max_delta_stats;
  1054. #endif
  1055. /*
  1056. * reporting the number of tids has AGG on. 0 means
  1057. * no AGGREGATION
  1058. */
  1059. u8 agg_tids_count;
  1060. struct iwl_rx_phy_res last_phy_res;
  1061. bool last_phy_res_valid;
  1062. struct completion firmware_loading_complete;
  1063. u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
  1064. u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
  1065. /*
  1066. * chain noise reset and gain commands are the
  1067. * two extra calibration commands follows the standard
  1068. * phy calibration commands
  1069. */
  1070. u8 phy_calib_chain_noise_reset_cmd;
  1071. u8 phy_calib_chain_noise_gain_cmd;
  1072. /* counts reply_tx error */
  1073. struct reply_tx_error_statistics reply_tx_stats;
  1074. struct reply_agg_tx_error_statistics reply_agg_tx_stats;
  1075. /* notification wait support */
  1076. struct list_head notif_waits;
  1077. spinlock_t notif_wait_lock;
  1078. wait_queue_head_t notif_waitq;
  1079. /* remain-on-channel offload support */
  1080. struct ieee80211_channel *hw_roc_channel;
  1081. struct delayed_work hw_roc_disable_work;
  1082. enum nl80211_channel_type hw_roc_chantype;
  1083. int hw_roc_duration;
  1084. bool hw_roc_setup;
  1085. /* bt coex */
  1086. u8 bt_enable_flag;
  1087. u8 bt_status;
  1088. u8 bt_traffic_load, last_bt_traffic_load;
  1089. bool bt_ch_announce;
  1090. bool bt_full_concurrent;
  1091. bool bt_ant_couple_ok;
  1092. __le32 kill_ack_mask;
  1093. __le32 kill_cts_mask;
  1094. __le16 bt_valid;
  1095. u16 bt_on_thresh;
  1096. u16 bt_duration;
  1097. u16 dynamic_frag_thresh;
  1098. u8 bt_ci_compliance;
  1099. struct work_struct bt_traffic_change_work;
  1100. bool bt_enable_pspoll;
  1101. struct iwl_rxon_context *cur_rssi_ctx;
  1102. bool bt_is_sco;
  1103. struct work_struct restart;
  1104. struct work_struct scan_completed;
  1105. struct work_struct abort_scan;
  1106. struct work_struct beacon_update;
  1107. struct iwl_rxon_context *beacon_ctx;
  1108. struct sk_buff *beacon_skb;
  1109. void *beacon_cmd;
  1110. struct work_struct tt_work;
  1111. struct work_struct ct_enter;
  1112. struct work_struct ct_exit;
  1113. struct work_struct start_internal_scan;
  1114. struct work_struct tx_flush;
  1115. struct work_struct bt_full_concurrency;
  1116. struct work_struct bt_runtime_config;
  1117. struct delayed_work scan_check;
  1118. /* TX Power */
  1119. s8 tx_power_user_lmt;
  1120. s8 tx_power_device_lmt;
  1121. s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
  1122. s8 tx_power_next;
  1123. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1124. /* debugfs */
  1125. u16 tx_traffic_idx;
  1126. u16 rx_traffic_idx;
  1127. u8 *tx_traffic;
  1128. u8 *rx_traffic;
  1129. struct dentry *debugfs_dir;
  1130. u32 dbgfs_sram_offset, dbgfs_sram_len;
  1131. bool disable_ht40;
  1132. void *wowlan_sram;
  1133. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1134. struct work_struct txpower_work;
  1135. u32 disable_sens_cal;
  1136. u32 disable_chain_noise_cal;
  1137. struct work_struct run_time_calib_work;
  1138. struct timer_list statistics_periodic;
  1139. struct timer_list ucode_trace;
  1140. struct timer_list watchdog;
  1141. struct iwl_event_log event_log;
  1142. struct led_classdev led;
  1143. unsigned long blink_on, blink_off;
  1144. bool led_registered;
  1145. #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
  1146. struct iwl_testmode_trace testmode_trace;
  1147. u32 tm_fixed_rate;
  1148. #endif
  1149. /* WoWLAN GTK rekey data */
  1150. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  1151. __le64 replay_ctr;
  1152. __le16 last_seq_ctl;
  1153. bool have_rekey_data;
  1154. }; /*iwl_priv */
  1155. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  1156. {
  1157. set_bit(txq_id, &priv->txq_ctx_active_msk);
  1158. }
  1159. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  1160. {
  1161. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  1162. }
  1163. extern struct iwl_mod_params iwlagn_mod_params;
  1164. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  1165. int txq_id, int idx)
  1166. {
  1167. if (priv->txq[txq_id].skbs[idx])
  1168. return (struct ieee80211_hdr *)priv->txq[txq_id].
  1169. skbs[idx]->data;
  1170. return NULL;
  1171. }
  1172. static inline struct iwl_rxon_context *
  1173. iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  1174. {
  1175. struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
  1176. return vif_priv->ctx;
  1177. }
  1178. #define for_each_context(priv, ctx) \
  1179. for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
  1180. ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
  1181. if (priv->valid_contexts & BIT(ctx->ctxid))
  1182. static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
  1183. {
  1184. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1185. }
  1186. static inline int iwl_is_associated(struct iwl_priv *priv,
  1187. enum iwl_rxon_context_id ctxid)
  1188. {
  1189. return iwl_is_associated_ctx(&priv->contexts[ctxid]);
  1190. }
  1191. static inline int iwl_is_any_associated(struct iwl_priv *priv)
  1192. {
  1193. struct iwl_rxon_context *ctx;
  1194. for_each_context(priv, ctx)
  1195. if (iwl_is_associated_ctx(ctx))
  1196. return true;
  1197. return false;
  1198. }
  1199. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1200. {
  1201. if (ch_info == NULL)
  1202. return 0;
  1203. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1204. }
  1205. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1206. {
  1207. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1208. }
  1209. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1210. {
  1211. return ch_info->band == IEEE80211_BAND_5GHZ;
  1212. }
  1213. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1214. {
  1215. return ch_info->band == IEEE80211_BAND_2GHZ;
  1216. }
  1217. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1218. {
  1219. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1220. }
  1221. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1222. {
  1223. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1224. }
  1225. #endif /* __iwl_dev_h__ */