iwl-dev.h 39 KB

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