iwl-dev.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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/kernel.h>
  34. #include <linux/wait.h>
  35. #include <linux/leds.h>
  36. #include <linux/slab.h>
  37. #include <net/ieee80211_radiotap.h>
  38. #include "iwl-eeprom.h"
  39. #include "iwl-csr.h"
  40. #include "iwl-prph.h"
  41. #include "iwl-debug.h"
  42. #include "iwl-agn-hw.h"
  43. #include "iwl-led.h"
  44. #include "iwl-power.h"
  45. #include "iwl-agn-rs.h"
  46. #include "iwl-agn-tt.h"
  47. #include "iwl-bus.h"
  48. #include "iwl-trans.h"
  49. #include "iwl-shared.h"
  50. struct iwl_tx_queue;
  51. /* CT-KILL constants */
  52. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  53. #define CT_KILL_THRESHOLD 114 /* in Celsius */
  54. #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
  55. /* Default noise level to report when noise measurement is not available.
  56. * This may be because we're:
  57. * 1) Not associated no beacon statistics being sent to driver)
  58. * 2) Scanning (noise measurement does not apply to associated channel)
  59. * Use default noise value of -127 ... this is below the range of measurable
  60. * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
  61. * Also, -127 works better than 0 when averaging frames with/without
  62. * noise info (e.g. averaging might be done in app); measured dBm values are
  63. * always negative ... using a negative value as the default keeps all
  64. * averages within an s8's (used in some apps) range of negative values. */
  65. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  66. /*
  67. * RTS threshold here is total size [2347] minus 4 FCS bytes
  68. * Per spec:
  69. * a value of 0 means RTS on all data/management packets
  70. * a value > max MSDU size means no RTS
  71. * else RTS for data/management frames where MPDU is larger
  72. * than RTS value.
  73. */
  74. #define DEFAULT_RTS_THRESHOLD 2347U
  75. #define MIN_RTS_THRESHOLD 0U
  76. #define MAX_RTS_THRESHOLD 2347U
  77. #define MAX_MSDU_SIZE 2304U
  78. #define MAX_MPDU_SIZE 2346U
  79. #define DEFAULT_BEACON_INTERVAL 200U
  80. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  81. #define DEFAULT_LONG_RETRY_LIMIT 4U
  82. #define IWL_NUM_SCAN_RATES (2)
  83. /*
  84. * One for each channel, holds all channel setup data
  85. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  86. * with one another!
  87. */
  88. struct iwl_channel_info {
  89. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  90. struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
  91. * HT40 channel */
  92. u8 channel; /* channel number */
  93. u8 flags; /* flags copied from EEPROM */
  94. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  95. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  96. s8 min_power; /* always 0 */
  97. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  98. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  99. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  100. enum ieee80211_band band;
  101. /* HT40 channel info */
  102. s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  103. u8 ht40_flags; /* flags copied from EEPROM */
  104. u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  105. };
  106. /*
  107. * Minimum number of queues. MAX_NUM is defined in hw specific files.
  108. * Set the minimum to accommodate
  109. * - 4 standard TX queues
  110. * - the command queue
  111. * - 4 PAN TX queues
  112. * - the PAN multicast queue, and
  113. * - the AUX (TX during scan dwell) queue.
  114. */
  115. #define IWL_MIN_NUM_QUEUES 11
  116. /*
  117. * Command queue depends on iPAN support.
  118. */
  119. #define IWL_DEFAULT_CMD_QUEUE_NUM 4
  120. #define IWL_IPAN_CMD_QUEUE_NUM 9
  121. #define IEEE80211_DATA_LEN 2304
  122. #define IEEE80211_4ADDR_LEN 30
  123. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  124. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  125. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  126. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  127. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  128. #define IWL_SUPPORTED_RATES_IE_LEN 8
  129. #define IWL_INVALID_RATE 0xFF
  130. #define IWL_INVALID_VALUE -1
  131. union iwl_ht_rate_supp {
  132. u16 rates;
  133. struct {
  134. u8 siso_rate;
  135. u8 mimo_rate;
  136. };
  137. };
  138. #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
  139. #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
  140. #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
  141. #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
  142. #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
  143. #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
  144. #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
  145. /*
  146. * Maximal MPDU density for TX aggregation
  147. * 4 - 2us density
  148. * 5 - 4us density
  149. * 6 - 8us density
  150. * 7 - 16us density
  151. */
  152. #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
  153. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  154. #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
  155. #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
  156. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  157. #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
  158. #define CFG_HT_MPDU_DENSITY_MIN (0x1)
  159. struct iwl_ht_config {
  160. bool single_chain_sufficient;
  161. enum ieee80211_smps_mode smps; /* current smps mode */
  162. };
  163. /* QoS structures */
  164. struct iwl_qos_info {
  165. int qos_active;
  166. struct iwl_qosparam_cmd def_qos_parm;
  167. };
  168. /*
  169. * Structure should be accessed with sta_lock held. When station addition
  170. * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
  171. * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
  172. * held.
  173. */
  174. struct iwl_station_entry {
  175. struct iwl_addsta_cmd sta;
  176. u8 used, ctxid;
  177. struct iwl_link_quality_cmd *lq;
  178. };
  179. /*
  180. * iwl_station_priv: Driver's private station information
  181. *
  182. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  183. * in the structure for use by driver. This structure is places in that
  184. * space.
  185. */
  186. struct iwl_station_priv {
  187. struct iwl_rxon_context *ctx;
  188. struct iwl_lq_sta lq_sta;
  189. atomic_t pending_frames;
  190. bool client;
  191. bool asleep;
  192. u8 max_agg_bufsize;
  193. u8 sta_id;
  194. };
  195. /**
  196. * struct iwl_vif_priv - driver's private per-interface information
  197. *
  198. * When mac80211 allocates a virtual interface, it can allocate
  199. * space for us to put data into.
  200. */
  201. struct iwl_vif_priv {
  202. struct iwl_rxon_context *ctx;
  203. u8 ibss_bssid_sta_id;
  204. };
  205. /* v1/v2 uCode file layout */
  206. struct iwl_ucode_header {
  207. __le32 ver; /* major/minor/API/serial */
  208. union {
  209. struct {
  210. __le32 inst_size; /* bytes of runtime code */
  211. __le32 data_size; /* bytes of runtime data */
  212. __le32 init_size; /* bytes of init code */
  213. __le32 init_data_size; /* bytes of init data */
  214. __le32 boot_size; /* bytes of bootstrap code */
  215. u8 data[0]; /* in same order as sizes */
  216. } v1;
  217. struct {
  218. __le32 build; /* build number */
  219. __le32 inst_size; /* bytes of runtime code */
  220. __le32 data_size; /* bytes of runtime data */
  221. __le32 init_size; /* bytes of init code */
  222. __le32 init_data_size; /* bytes of init data */
  223. __le32 boot_size; /* bytes of bootstrap code */
  224. u8 data[0]; /* in same order as sizes */
  225. } v2;
  226. } u;
  227. };
  228. /*
  229. * new TLV uCode file layout
  230. *
  231. * The new TLV file format contains TLVs, that each specify
  232. * some piece of data. To facilitate "groups", for example
  233. * different instruction image with different capabilities,
  234. * bundled with the same init image, an alternative mechanism
  235. * is provided:
  236. * When the alternative field is 0, that means that the item
  237. * is always valid. When it is non-zero, then it is only
  238. * valid in conjunction with items of the same alternative,
  239. * in which case the driver (user) selects one alternative
  240. * to use.
  241. */
  242. enum iwl_ucode_tlv_type {
  243. IWL_UCODE_TLV_INVALID = 0, /* unused */
  244. IWL_UCODE_TLV_INST = 1,
  245. IWL_UCODE_TLV_DATA = 2,
  246. IWL_UCODE_TLV_INIT = 3,
  247. IWL_UCODE_TLV_INIT_DATA = 4,
  248. IWL_UCODE_TLV_BOOT = 5,
  249. IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
  250. IWL_UCODE_TLV_PAN = 7,
  251. IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
  252. IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
  253. IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
  254. IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
  255. IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
  256. IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
  257. IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
  258. IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
  259. IWL_UCODE_TLV_WOWLAN_INST = 16,
  260. IWL_UCODE_TLV_WOWLAN_DATA = 17,
  261. IWL_UCODE_TLV_FLAGS = 18,
  262. };
  263. /**
  264. * enum iwl_ucode_tlv_flag - ucode API flags
  265. * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
  266. * was a separate TLV but moved here to save space.
  267. * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
  268. * treats good CRC threshold as a boolean
  269. * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
  270. * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
  271. */
  272. enum iwl_ucode_tlv_flag {
  273. IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
  274. IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
  275. IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
  276. IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
  277. };
  278. struct iwl_ucode_tlv {
  279. __le16 type; /* see above */
  280. __le16 alternative; /* see comment */
  281. __le32 length; /* not including type/length fields */
  282. u8 data[0];
  283. } __packed;
  284. #define IWL_TLV_UCODE_MAGIC 0x0a4c5749
  285. struct iwl_tlv_ucode_header {
  286. /*
  287. * The TLV style ucode header is distinguished from
  288. * the v1/v2 style header by first four bytes being
  289. * zero, as such is an invalid combination of
  290. * major/minor/API/serial versions.
  291. */
  292. __le32 zero;
  293. __le32 magic;
  294. u8 human_readable[64];
  295. __le32 ver; /* major/minor/API/serial */
  296. __le32 build;
  297. __le64 alternatives; /* bitmask of valid alternatives */
  298. /*
  299. * The data contained herein has a TLV layout,
  300. * see above for the TLV header and types.
  301. * Note that each TLV is padded to a length
  302. * that is a multiple of 4 for alignment.
  303. */
  304. u8 data[0];
  305. };
  306. struct iwl_sensitivity_ranges {
  307. u16 min_nrg_cck;
  308. u16 max_nrg_cck;
  309. u16 nrg_th_cck;
  310. u16 nrg_th_ofdm;
  311. u16 auto_corr_min_ofdm;
  312. u16 auto_corr_min_ofdm_mrc;
  313. u16 auto_corr_min_ofdm_x1;
  314. u16 auto_corr_min_ofdm_mrc_x1;
  315. u16 auto_corr_max_ofdm;
  316. u16 auto_corr_max_ofdm_mrc;
  317. u16 auto_corr_max_ofdm_x1;
  318. u16 auto_corr_max_ofdm_mrc_x1;
  319. u16 auto_corr_max_cck;
  320. u16 auto_corr_max_cck_mrc;
  321. u16 auto_corr_min_cck;
  322. u16 auto_corr_min_cck_mrc;
  323. u16 barker_corr_th_min;
  324. u16 barker_corr_th_min_mrc;
  325. u16 nrg_th_cca;
  326. };
  327. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  328. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  329. /******************************************************************************
  330. *
  331. * Functions implemented in core module which are forward declared here
  332. * for use by iwl-[4-5].c
  333. *
  334. * NOTE: The implementation of these functions are not hardware specific
  335. * which is why they are in the core module files.
  336. *
  337. * Naming convention --
  338. * iwl_ <-- Is part of iwlwifi
  339. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  340. *
  341. ****************************************************************************/
  342. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  343. extern const u8 iwl_bcast_addr[ETH_ALEN];
  344. #define IWL_OPERATION_MODE_AUTO 0
  345. #define IWL_OPERATION_MODE_HT_ONLY 1
  346. #define IWL_OPERATION_MODE_MIXED 2
  347. #define IWL_OPERATION_MODE_20MHZ 3
  348. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  349. /* Sensitivity and chain noise calibration */
  350. #define INITIALIZATION_VALUE 0xFFFF
  351. #define IWL_CAL_NUM_BEACONS 16
  352. #define MAXIMUM_ALLOWED_PATHLOSS 15
  353. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  354. #define MAX_FA_OFDM 50
  355. #define MIN_FA_OFDM 5
  356. #define MAX_FA_CCK 50
  357. #define MIN_FA_CCK 5
  358. #define AUTO_CORR_STEP_OFDM 1
  359. #define AUTO_CORR_STEP_CCK 3
  360. #define AUTO_CORR_MAX_TH_CCK 160
  361. #define NRG_DIFF 2
  362. #define NRG_STEP_CCK 2
  363. #define NRG_MARGIN 8
  364. #define MAX_NUMBER_CCK_NO_FA 100
  365. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  366. #define CHAIN_A 0
  367. #define CHAIN_B 1
  368. #define CHAIN_C 2
  369. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  370. #define ALL_BAND_FILTER 0xFF00
  371. #define IN_BAND_FILTER 0xFF
  372. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  373. #define NRG_NUM_PREV_STAT_L 20
  374. #define NUM_RX_CHAINS 3
  375. enum iwlagn_false_alarm_state {
  376. IWL_FA_TOO_MANY = 0,
  377. IWL_FA_TOO_FEW = 1,
  378. IWL_FA_GOOD_RANGE = 2,
  379. };
  380. enum iwlagn_chain_noise_state {
  381. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  382. IWL_CHAIN_NOISE_ACCUMULATE,
  383. IWL_CHAIN_NOISE_CALIBRATED,
  384. IWL_CHAIN_NOISE_DONE,
  385. };
  386. /* Opaque calibration results */
  387. struct iwl_calib_result {
  388. struct list_head list;
  389. size_t cmd_len;
  390. struct iwl_calib_hdr hdr;
  391. /* data follows */
  392. };
  393. /* Sensitivity calib data */
  394. struct iwl_sensitivity_data {
  395. u32 auto_corr_ofdm;
  396. u32 auto_corr_ofdm_mrc;
  397. u32 auto_corr_ofdm_x1;
  398. u32 auto_corr_ofdm_mrc_x1;
  399. u32 auto_corr_cck;
  400. u32 auto_corr_cck_mrc;
  401. u32 last_bad_plcp_cnt_ofdm;
  402. u32 last_fa_cnt_ofdm;
  403. u32 last_bad_plcp_cnt_cck;
  404. u32 last_fa_cnt_cck;
  405. u32 nrg_curr_state;
  406. u32 nrg_prev_state;
  407. u32 nrg_value[10];
  408. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  409. u32 nrg_silence_ref;
  410. u32 nrg_energy_idx;
  411. u32 nrg_silence_idx;
  412. u32 nrg_th_cck;
  413. s32 nrg_auto_corr_silence_diff;
  414. u32 num_in_cck_no_fa;
  415. u32 nrg_th_ofdm;
  416. u16 barker_corr_th_min;
  417. u16 barker_corr_th_min_mrc;
  418. u16 nrg_th_cca;
  419. };
  420. /* Chain noise (differential Rx gain) calib data */
  421. struct iwl_chain_noise_data {
  422. u32 active_chains;
  423. u32 chain_noise_a;
  424. u32 chain_noise_b;
  425. u32 chain_noise_c;
  426. u32 chain_signal_a;
  427. u32 chain_signal_b;
  428. u32 chain_signal_c;
  429. u16 beacon_count;
  430. u8 disconn_array[NUM_RX_CHAINS];
  431. u8 delta_gain_code[NUM_RX_CHAINS];
  432. u8 radio_write;
  433. u8 state;
  434. };
  435. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  436. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  437. enum {
  438. MEASUREMENT_READY = (1 << 0),
  439. MEASUREMENT_ACTIVE = (1 << 1),
  440. };
  441. enum iwl_nvm_type {
  442. NVM_DEVICE_TYPE_EEPROM = 0,
  443. NVM_DEVICE_TYPE_OTP,
  444. };
  445. /*
  446. * Two types of OTP memory access modes
  447. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  448. * based on physical memory addressing
  449. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  450. * based on logical memory addressing
  451. */
  452. enum iwl_access_mode {
  453. IWL_OTP_ACCESS_ABSOLUTE,
  454. IWL_OTP_ACCESS_RELATIVE,
  455. };
  456. /**
  457. * enum iwl_pa_type - Power Amplifier type
  458. * @IWL_PA_SYSTEM: based on uCode configuration
  459. * @IWL_PA_INTERNAL: use Internal only
  460. */
  461. enum iwl_pa_type {
  462. IWL_PA_SYSTEM = 0,
  463. IWL_PA_INTERNAL = 1,
  464. };
  465. /* reply_tx_statistics (for _agn devices) */
  466. struct reply_tx_error_statistics {
  467. u32 pp_delay;
  468. u32 pp_few_bytes;
  469. u32 pp_bt_prio;
  470. u32 pp_quiet_period;
  471. u32 pp_calc_ttak;
  472. u32 int_crossed_retry;
  473. u32 short_limit;
  474. u32 long_limit;
  475. u32 fifo_underrun;
  476. u32 drain_flow;
  477. u32 rfkill_flush;
  478. u32 life_expire;
  479. u32 dest_ps;
  480. u32 host_abort;
  481. u32 bt_retry;
  482. u32 sta_invalid;
  483. u32 frag_drop;
  484. u32 tid_disable;
  485. u32 fifo_flush;
  486. u32 insuff_cf_poll;
  487. u32 fail_hw_drop;
  488. u32 sta_color_mismatch;
  489. u32 unknown;
  490. };
  491. /* reply_agg_tx_statistics (for _agn devices) */
  492. struct reply_agg_tx_error_statistics {
  493. u32 underrun;
  494. u32 bt_prio;
  495. u32 few_bytes;
  496. u32 abort;
  497. u32 last_sent_ttl;
  498. u32 last_sent_try;
  499. u32 last_sent_bt_kill;
  500. u32 scd_query;
  501. u32 bad_crc32;
  502. u32 response;
  503. u32 dump_tx;
  504. u32 delay_tx;
  505. u32 unknown;
  506. };
  507. /* management statistics */
  508. enum iwl_mgmt_stats {
  509. MANAGEMENT_ASSOC_REQ = 0,
  510. MANAGEMENT_ASSOC_RESP,
  511. MANAGEMENT_REASSOC_REQ,
  512. MANAGEMENT_REASSOC_RESP,
  513. MANAGEMENT_PROBE_REQ,
  514. MANAGEMENT_PROBE_RESP,
  515. MANAGEMENT_BEACON,
  516. MANAGEMENT_ATIM,
  517. MANAGEMENT_DISASSOC,
  518. MANAGEMENT_AUTH,
  519. MANAGEMENT_DEAUTH,
  520. MANAGEMENT_ACTION,
  521. MANAGEMENT_MAX,
  522. };
  523. /* control statistics */
  524. enum iwl_ctrl_stats {
  525. CONTROL_BACK_REQ = 0,
  526. CONTROL_BACK,
  527. CONTROL_PSPOLL,
  528. CONTROL_RTS,
  529. CONTROL_CTS,
  530. CONTROL_ACK,
  531. CONTROL_CFEND,
  532. CONTROL_CFENDACK,
  533. CONTROL_MAX,
  534. };
  535. struct traffic_stats {
  536. #ifdef CONFIG_IWLWIFI_DEBUGFS
  537. u32 mgmt[MANAGEMENT_MAX];
  538. u32 ctrl[CONTROL_MAX];
  539. u32 data_cnt;
  540. u64 data_bytes;
  541. #endif
  542. };
  543. /*
  544. * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  545. * to perform continuous uCode event logging operation if enabled
  546. */
  547. #define UCODE_TRACE_PERIOD (100)
  548. /*
  549. * iwl_event_log: current uCode event log position
  550. *
  551. * @ucode_trace: enable/disable ucode continuous trace timer
  552. * @num_wraps: how many times the event buffer wraps
  553. * @next_entry: the entry just before the next one that uCode would fill
  554. * @non_wraps_count: counter for no wrap detected when dump ucode events
  555. * @wraps_once_count: counter for wrap once detected when dump ucode events
  556. * @wraps_more_count: counter for wrap more than once detected
  557. * when dump ucode events
  558. */
  559. struct iwl_event_log {
  560. bool ucode_trace;
  561. u32 num_wraps;
  562. u32 next_entry;
  563. int non_wraps_count;
  564. int wraps_once_count;
  565. int wraps_more_count;
  566. };
  567. /*
  568. * This is the threshold value of plcp error rate per 100mSecs. It is
  569. * used to set and check for the validity of plcp_delta.
  570. */
  571. #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
  572. #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
  573. #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
  574. #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
  575. #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
  576. #define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
  577. #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
  578. #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
  579. /* TX queue watchdog timeouts in mSecs */
  580. #define IWL_DEF_WD_TIMEOUT (2000)
  581. #define IWL_LONG_WD_TIMEOUT (10000)
  582. #define IWL_MAX_WD_TIMEOUT (120000)
  583. /* BT Antenna Coupling Threshold (dB) */
  584. #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
  585. /* Firmware reload counter and Timestamp */
  586. #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
  587. #define IWL_MAX_CONTINUE_RELOAD_CNT 4
  588. enum iwl_reset {
  589. IWL_RF_RESET = 0,
  590. IWL_FW_RESET,
  591. IWL_MAX_FORCE_RESET,
  592. };
  593. struct iwl_force_reset {
  594. int reset_request_count;
  595. int reset_success_count;
  596. int reset_reject_count;
  597. unsigned long reset_duration;
  598. unsigned long last_force_reset_jiffies;
  599. };
  600. /* extend beacon time format bit shifting */
  601. /*
  602. * for _agn devices
  603. * bits 31:22 - extended
  604. * bits 21:0 - interval
  605. */
  606. #define IWLAGN_EXT_BEACON_TIME_POS 22
  607. struct iwl_rxon_context {
  608. struct ieee80211_vif *vif;
  609. /*
  610. * We could use the vif to indicate active, but we
  611. * also need it to be active during disabling when
  612. * we already removed the vif for type setting.
  613. */
  614. bool always_active, is_active;
  615. bool ht_need_multiple_chains;
  616. enum iwl_rxon_context_id ctxid;
  617. u32 interface_modes, exclusive_interface_modes;
  618. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  619. /*
  620. * We declare this const so it can only be
  621. * changed via explicit cast within the
  622. * routines that actually update the physical
  623. * hardware.
  624. */
  625. const struct iwl_rxon_cmd active;
  626. struct iwl_rxon_cmd staging;
  627. struct iwl_rxon_time_cmd timing;
  628. struct iwl_qos_info qos_data;
  629. u8 bcast_sta_id, ap_sta_id;
  630. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  631. u8 qos_cmd;
  632. u8 wep_key_cmd;
  633. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  634. u8 key_mapping_keys;
  635. __le32 station_flags;
  636. int beacon_int;
  637. struct {
  638. bool non_gf_sta_present;
  639. u8 protection;
  640. bool enabled, is_40mhz;
  641. u8 extension_chan_offset;
  642. } ht;
  643. u8 bssid[ETH_ALEN];
  644. bool preauth_bssid;
  645. bool last_tx_rejected;
  646. };
  647. enum iwl_scan_type {
  648. IWL_SCAN_NORMAL,
  649. IWL_SCAN_RADIO_RESET,
  650. IWL_SCAN_ROC,
  651. };
  652. #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
  653. struct iwl_testmode_trace {
  654. u32 buff_size;
  655. u32 total_size;
  656. u32 num_chunks;
  657. u8 *cpu_addr;
  658. u8 *trace_addr;
  659. dma_addr_t dma_addr;
  660. bool trace_enabled;
  661. };
  662. struct iwl_testmode_sram {
  663. u32 buff_size;
  664. u32 num_chunks;
  665. u8 *buff_addr;
  666. bool sram_readed;
  667. };
  668. #endif
  669. struct iwl_wipan_noa_data {
  670. struct rcu_head rcu_head;
  671. u32 length;
  672. u8 data[];
  673. };
  674. struct iwl_priv {
  675. /*data shared among all the driver's layers */
  676. struct iwl_shared _shrd;
  677. struct iwl_shared *shrd;
  678. /* ieee device used by generic ieee processing code */
  679. struct ieee80211_hw *hw;
  680. struct ieee80211_channel *ieee_channels;
  681. struct ieee80211_rate *ieee_rates;
  682. struct kmem_cache *tx_cmd_pool;
  683. struct iwl_cfg *cfg;
  684. enum ieee80211_band band;
  685. void (*pre_rx_handler)(struct iwl_priv *priv,
  686. struct iwl_rx_mem_buffer *rxb);
  687. int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  688. struct iwl_rx_mem_buffer *rxb,
  689. struct iwl_device_cmd *cmd);
  690. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  691. /* spectrum measurement report caching */
  692. struct iwl_spectrum_notification measure_report;
  693. u8 measurement_status;
  694. /* ucode beacon time */
  695. u32 ucode_beacon_time;
  696. int missed_beacon_threshold;
  697. /* track IBSS manager (last beacon) status */
  698. u32 ibss_manager;
  699. /* jiffies when last recovery from statistics was performed */
  700. unsigned long rx_statistics_jiffies;
  701. /*counters */
  702. u32 rx_handlers_stats[REPLY_MAX];
  703. /* force reset */
  704. struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
  705. /* firmware reload counter and timestamp */
  706. unsigned long reload_jiffies;
  707. int reload_count;
  708. /* we allocate array of iwl_channel_info for NIC's valid channels.
  709. * Access via channel # using indirect index array */
  710. struct iwl_channel_info *channel_info; /* channel info array */
  711. u8 channel_count; /* # of channels */
  712. /* thermal calibration */
  713. s32 temperature; /* Celsius */
  714. s32 last_temperature;
  715. /* init calibration results */
  716. struct list_head calib_results;
  717. struct iwl_wipan_noa_data __rcu *noa_data;
  718. /* Scan related variables */
  719. unsigned long scan_start;
  720. unsigned long scan_start_tsf;
  721. void *scan_cmd;
  722. enum ieee80211_band scan_band;
  723. struct cfg80211_scan_request *scan_request;
  724. struct ieee80211_vif *scan_vif;
  725. enum iwl_scan_type scan_type;
  726. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  727. u8 mgmt_tx_ant;
  728. /* max number of station keys */
  729. u8 sta_key_max_num;
  730. bool new_scan_threshold_behaviour;
  731. /* EEPROM MAC addresses */
  732. struct mac_address addresses[2];
  733. /* uCode images, save to reload in case of failure */
  734. int fw_index; /* firmware we're trying to load */
  735. u32 ucode_ver; /* version of ucode, copy of
  736. iwl_ucode.ver */
  737. char firmware_name[25];
  738. struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
  739. __le16 switch_channel;
  740. struct {
  741. u32 error_event_table;
  742. u32 log_event_table;
  743. } device_pointers;
  744. u16 active_rate;
  745. u8 start_calib;
  746. struct iwl_sensitivity_data sensitivity_data;
  747. struct iwl_chain_noise_data chain_noise_data;
  748. bool enhance_sensitivity_table;
  749. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  750. __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
  751. struct iwl_ht_config current_ht_config;
  752. /* Rate scaling data */
  753. u8 retry_rate;
  754. int activity_timer_active;
  755. /* counts mgmt, ctl, and data packets */
  756. struct traffic_stats tx_stats;
  757. struct traffic_stats rx_stats;
  758. struct iwl_power_mgr power_data;
  759. struct iwl_tt_mgmt thermal_throttle;
  760. /* station table variables */
  761. int num_stations;
  762. struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
  763. unsigned long ucode_key_table;
  764. u8 mac80211_registered;
  765. /* Indication if ieee80211_ops->open has been called */
  766. u8 is_open;
  767. /* eeprom -- this is in the card's little endian byte order */
  768. u8 *eeprom;
  769. struct iwl_eeprom_calib_info *calib_info;
  770. enum nl80211_iftype iw_mode;
  771. /* Last Rx'd beacon timestamp */
  772. u64 timestamp;
  773. struct {
  774. __le32 flag;
  775. struct statistics_general_common common;
  776. struct statistics_rx_non_phy rx_non_phy;
  777. struct statistics_rx_phy rx_ofdm;
  778. struct statistics_rx_ht_phy rx_ofdm_ht;
  779. struct statistics_rx_phy rx_cck;
  780. struct statistics_tx tx;
  781. #ifdef CONFIG_IWLWIFI_DEBUGFS
  782. struct statistics_bt_activity bt_activity;
  783. __le32 num_bt_kills, accum_num_bt_kills;
  784. #endif
  785. } statistics;
  786. #ifdef CONFIG_IWLWIFI_DEBUGFS
  787. struct {
  788. struct statistics_general_common common;
  789. struct statistics_rx_non_phy rx_non_phy;
  790. struct statistics_rx_phy rx_ofdm;
  791. struct statistics_rx_ht_phy rx_ofdm_ht;
  792. struct statistics_rx_phy rx_cck;
  793. struct statistics_tx tx;
  794. struct statistics_bt_activity bt_activity;
  795. } accum_stats, delta_stats, max_delta_stats;
  796. #endif
  797. /*
  798. * reporting the number of tids has AGG on. 0 means
  799. * no AGGREGATION
  800. */
  801. u8 agg_tids_count;
  802. struct iwl_rx_phy_res last_phy_res;
  803. bool last_phy_res_valid;
  804. struct completion firmware_loading_complete;
  805. u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
  806. u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
  807. /*
  808. * chain noise reset and gain commands are the
  809. * two extra calibration commands follows the standard
  810. * phy calibration commands
  811. */
  812. u8 phy_calib_chain_noise_reset_cmd;
  813. u8 phy_calib_chain_noise_gain_cmd;
  814. /* counts reply_tx error */
  815. struct reply_tx_error_statistics reply_tx_stats;
  816. struct reply_agg_tx_error_statistics reply_agg_tx_stats;
  817. /* remain-on-channel offload support */
  818. struct ieee80211_channel *hw_roc_channel;
  819. struct delayed_work hw_roc_disable_work;
  820. enum nl80211_channel_type hw_roc_chantype;
  821. int hw_roc_duration;
  822. bool hw_roc_setup, hw_roc_start_notified;
  823. /* bt coex */
  824. u8 bt_enable_flag;
  825. u8 bt_status;
  826. u8 bt_traffic_load, last_bt_traffic_load;
  827. bool bt_ch_announce;
  828. bool bt_full_concurrent;
  829. bool bt_ant_couple_ok;
  830. __le32 kill_ack_mask;
  831. __le32 kill_cts_mask;
  832. __le16 bt_valid;
  833. u16 bt_on_thresh;
  834. u16 bt_duration;
  835. u16 dynamic_frag_thresh;
  836. u8 bt_ci_compliance;
  837. struct work_struct bt_traffic_change_work;
  838. bool bt_enable_pspoll;
  839. struct iwl_rxon_context *cur_rssi_ctx;
  840. bool bt_is_sco;
  841. struct work_struct restart;
  842. struct work_struct scan_completed;
  843. struct work_struct abort_scan;
  844. struct work_struct beacon_update;
  845. struct iwl_rxon_context *beacon_ctx;
  846. struct sk_buff *beacon_skb;
  847. void *beacon_cmd;
  848. struct work_struct tt_work;
  849. struct work_struct ct_enter;
  850. struct work_struct ct_exit;
  851. struct work_struct start_internal_scan;
  852. struct work_struct tx_flush;
  853. struct work_struct bt_full_concurrency;
  854. struct work_struct bt_runtime_config;
  855. struct delayed_work scan_check;
  856. /* TX Power */
  857. s8 tx_power_user_lmt;
  858. s8 tx_power_device_lmt;
  859. s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
  860. s8 tx_power_next;
  861. #ifdef CONFIG_IWLWIFI_DEBUGFS
  862. /* debugfs */
  863. u16 tx_traffic_idx;
  864. u16 rx_traffic_idx;
  865. u8 *tx_traffic;
  866. u8 *rx_traffic;
  867. struct dentry *debugfs_dir;
  868. u32 dbgfs_sram_offset, dbgfs_sram_len;
  869. bool disable_ht40;
  870. void *wowlan_sram;
  871. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  872. struct work_struct txpower_work;
  873. u32 disable_sens_cal;
  874. u32 disable_chain_noise_cal;
  875. struct work_struct run_time_calib_work;
  876. struct timer_list statistics_periodic;
  877. struct timer_list ucode_trace;
  878. struct timer_list watchdog;
  879. struct iwl_event_log event_log;
  880. struct led_classdev led;
  881. unsigned long blink_on, blink_off;
  882. bool led_registered;
  883. #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
  884. struct iwl_testmode_trace testmode_trace;
  885. struct iwl_testmode_sram testmode_sram;
  886. u32 tm_fixed_rate;
  887. #endif
  888. /* WoWLAN GTK rekey data */
  889. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  890. __le64 replay_ctr;
  891. __le16 last_seq_ctl;
  892. bool have_rekey_data;
  893. }; /*iwl_priv */
  894. extern struct iwl_mod_params iwlagn_mod_params;
  895. static inline struct iwl_rxon_context *
  896. iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  897. {
  898. struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
  899. return vif_priv->ctx;
  900. }
  901. #define for_each_context(priv, ctx) \
  902. for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
  903. ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
  904. if (priv->shrd->valid_contexts & BIT(ctx->ctxid))
  905. static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
  906. {
  907. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  908. }
  909. static inline int iwl_is_associated(struct iwl_priv *priv,
  910. enum iwl_rxon_context_id ctxid)
  911. {
  912. return iwl_is_associated_ctx(&priv->contexts[ctxid]);
  913. }
  914. static inline int iwl_is_any_associated(struct iwl_priv *priv)
  915. {
  916. struct iwl_rxon_context *ctx;
  917. for_each_context(priv, ctx)
  918. if (iwl_is_associated_ctx(ctx))
  919. return true;
  920. return false;
  921. }
  922. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  923. {
  924. if (ch_info == NULL)
  925. return 0;
  926. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  927. }
  928. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  929. {
  930. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  931. }
  932. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  933. {
  934. return ch_info->band == IEEE80211_BAND_5GHZ;
  935. }
  936. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  937. {
  938. return ch_info->band == IEEE80211_BAND_2GHZ;
  939. }
  940. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  941. {
  942. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  943. }
  944. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  945. {
  946. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  947. }
  948. #endif /* __iwl_dev_h__ */