iwl-dev.h 37 KB

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