iwl-dev.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2012 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 <linux/mutex.h>
  38. #include "iwl-fw.h"
  39. #include "iwl-eeprom.h"
  40. #include "iwl-csr.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-trans.h"
  48. #include "iwl-shared.h"
  49. #include "iwl-op-mode.h"
  50. #include "iwl-notif-wait.h"
  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. * enum iwl_agg_state
  170. *
  171. * The state machine of the BA agreement establishment / tear down.
  172. * These states relate to a specific RA / TID.
  173. *
  174. * @IWL_AGG_OFF: aggregation is not used
  175. * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
  176. * @IWL_AGG_ON: aggregation session is up
  177. * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
  178. * HW queue to be empty from packets for this RA /TID.
  179. * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
  180. * HW queue to be empty from packets for this RA /TID.
  181. */
  182. enum iwl_agg_state {
  183. IWL_AGG_OFF = 0,
  184. IWL_AGG_STARTING,
  185. IWL_AGG_ON,
  186. IWL_EMPTYING_HW_QUEUE_ADDBA,
  187. IWL_EMPTYING_HW_QUEUE_DELBA,
  188. };
  189. /**
  190. * struct iwl_ht_agg - aggregation state machine
  191. * This structs holds the states for the BA agreement establishment and tear
  192. * down. It also holds the state during the BA session itself. This struct is
  193. * duplicated for each RA / TID.
  194. * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
  195. * Tx response (REPLY_TX), and the block ack notification
  196. * (REPLY_COMPRESSED_BA).
  197. * @state: state of the BA agreement establishment / tear down.
  198. * @txq_id: Tx queue used by the BA session
  199. * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
  200. * the first packet to be sent in legacy HW queue in Tx AGG stop flow.
  201. * Basically when next_reclaimed reaches ssn, we can tell mac80211 that
  202. * we are ready to finish the Tx AGG stop / start flow.
  203. * @wait_for_ba: Expect block-ack before next Tx reply
  204. */
  205. struct iwl_ht_agg {
  206. u32 rate_n_flags;
  207. enum iwl_agg_state state;
  208. u16 txq_id;
  209. u16 ssn;
  210. bool wait_for_ba;
  211. };
  212. /**
  213. * struct iwl_tid_data - one for each RA / TID
  214. * This structs holds the states for each RA / TID.
  215. * @seq_number: the next WiFi sequence number to use
  216. * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
  217. * This is basically (last acked packet++).
  218. * @agg: aggregation state machine
  219. */
  220. struct iwl_tid_data {
  221. u16 seq_number;
  222. u16 next_reclaimed;
  223. struct iwl_ht_agg agg;
  224. };
  225. /*
  226. * Structure should be accessed with sta_lock held. When station addition
  227. * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
  228. * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
  229. * held.
  230. */
  231. struct iwl_station_entry {
  232. struct iwl_addsta_cmd sta;
  233. u8 used, ctxid;
  234. struct iwl_link_quality_cmd *lq;
  235. };
  236. /*
  237. * iwl_station_priv: Driver's private station information
  238. *
  239. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  240. * in the structure for use by driver. This structure is places in that
  241. * space.
  242. */
  243. struct iwl_station_priv {
  244. struct iwl_rxon_context *ctx;
  245. struct iwl_lq_sta lq_sta;
  246. atomic_t pending_frames;
  247. bool client;
  248. bool asleep;
  249. u8 max_agg_bufsize;
  250. u8 sta_id;
  251. };
  252. /**
  253. * struct iwl_vif_priv - driver's private per-interface information
  254. *
  255. * When mac80211 allocates a virtual interface, it can allocate
  256. * space for us to put data into.
  257. */
  258. struct iwl_vif_priv {
  259. struct iwl_rxon_context *ctx;
  260. u8 ibss_bssid_sta_id;
  261. };
  262. struct iwl_sensitivity_ranges {
  263. u16 min_nrg_cck;
  264. u16 nrg_th_cck;
  265. u16 nrg_th_ofdm;
  266. u16 auto_corr_min_ofdm;
  267. u16 auto_corr_min_ofdm_mrc;
  268. u16 auto_corr_min_ofdm_x1;
  269. u16 auto_corr_min_ofdm_mrc_x1;
  270. u16 auto_corr_max_ofdm;
  271. u16 auto_corr_max_ofdm_mrc;
  272. u16 auto_corr_max_ofdm_x1;
  273. u16 auto_corr_max_ofdm_mrc_x1;
  274. u16 auto_corr_max_cck;
  275. u16 auto_corr_max_cck_mrc;
  276. u16 auto_corr_min_cck;
  277. u16 auto_corr_min_cck_mrc;
  278. u16 barker_corr_th_min;
  279. u16 barker_corr_th_min_mrc;
  280. u16 nrg_th_cca;
  281. };
  282. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  283. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  284. /******************************************************************************
  285. *
  286. * Functions implemented in core module which are forward declared here
  287. * for use by iwl-[4-5].c
  288. *
  289. * NOTE: The implementation of these functions are not hardware specific
  290. * which is why they are in the core module files.
  291. *
  292. * Naming convention --
  293. * iwl_ <-- Is part of iwlwifi
  294. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  295. *
  296. ****************************************************************************/
  297. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  298. extern const u8 iwl_bcast_addr[ETH_ALEN];
  299. #define IWL_OPERATION_MODE_AUTO 0
  300. #define IWL_OPERATION_MODE_HT_ONLY 1
  301. #define IWL_OPERATION_MODE_MIXED 2
  302. #define IWL_OPERATION_MODE_20MHZ 3
  303. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  304. /* Sensitivity and chain noise calibration */
  305. #define INITIALIZATION_VALUE 0xFFFF
  306. #define IWL_CAL_NUM_BEACONS 16
  307. #define MAXIMUM_ALLOWED_PATHLOSS 15
  308. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  309. #define MAX_FA_OFDM 50
  310. #define MIN_FA_OFDM 5
  311. #define MAX_FA_CCK 50
  312. #define MIN_FA_CCK 5
  313. #define AUTO_CORR_STEP_OFDM 1
  314. #define AUTO_CORR_STEP_CCK 3
  315. #define AUTO_CORR_MAX_TH_CCK 160
  316. #define NRG_DIFF 2
  317. #define NRG_STEP_CCK 2
  318. #define NRG_MARGIN 8
  319. #define MAX_NUMBER_CCK_NO_FA 100
  320. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  321. #define CHAIN_A 0
  322. #define CHAIN_B 1
  323. #define CHAIN_C 2
  324. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  325. #define ALL_BAND_FILTER 0xFF00
  326. #define IN_BAND_FILTER 0xFF
  327. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  328. #define NRG_NUM_PREV_STAT_L 20
  329. #define NUM_RX_CHAINS 3
  330. enum iwlagn_false_alarm_state {
  331. IWL_FA_TOO_MANY = 0,
  332. IWL_FA_TOO_FEW = 1,
  333. IWL_FA_GOOD_RANGE = 2,
  334. };
  335. enum iwlagn_chain_noise_state {
  336. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  337. IWL_CHAIN_NOISE_ACCUMULATE,
  338. IWL_CHAIN_NOISE_CALIBRATED,
  339. IWL_CHAIN_NOISE_DONE,
  340. };
  341. /* Sensitivity calib data */
  342. struct iwl_sensitivity_data {
  343. u32 auto_corr_ofdm;
  344. u32 auto_corr_ofdm_mrc;
  345. u32 auto_corr_ofdm_x1;
  346. u32 auto_corr_ofdm_mrc_x1;
  347. u32 auto_corr_cck;
  348. u32 auto_corr_cck_mrc;
  349. u32 last_bad_plcp_cnt_ofdm;
  350. u32 last_fa_cnt_ofdm;
  351. u32 last_bad_plcp_cnt_cck;
  352. u32 last_fa_cnt_cck;
  353. u32 nrg_curr_state;
  354. u32 nrg_prev_state;
  355. u32 nrg_value[10];
  356. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  357. u32 nrg_silence_ref;
  358. u32 nrg_energy_idx;
  359. u32 nrg_silence_idx;
  360. u32 nrg_th_cck;
  361. s32 nrg_auto_corr_silence_diff;
  362. u32 num_in_cck_no_fa;
  363. u32 nrg_th_ofdm;
  364. u16 barker_corr_th_min;
  365. u16 barker_corr_th_min_mrc;
  366. u16 nrg_th_cca;
  367. };
  368. /* Chain noise (differential Rx gain) calib data */
  369. struct iwl_chain_noise_data {
  370. u32 active_chains;
  371. u32 chain_noise_a;
  372. u32 chain_noise_b;
  373. u32 chain_noise_c;
  374. u32 chain_signal_a;
  375. u32 chain_signal_b;
  376. u32 chain_signal_c;
  377. u16 beacon_count;
  378. u8 disconn_array[NUM_RX_CHAINS];
  379. u8 delta_gain_code[NUM_RX_CHAINS];
  380. u8 radio_write;
  381. u8 state;
  382. };
  383. enum {
  384. MEASUREMENT_READY = (1 << 0),
  385. MEASUREMENT_ACTIVE = (1 << 1),
  386. };
  387. enum iwl_nvm_type {
  388. NVM_DEVICE_TYPE_EEPROM = 0,
  389. NVM_DEVICE_TYPE_OTP,
  390. };
  391. /*
  392. * Two types of OTP memory access modes
  393. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  394. * based on physical memory addressing
  395. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  396. * based on logical memory addressing
  397. */
  398. enum iwl_access_mode {
  399. IWL_OTP_ACCESS_ABSOLUTE,
  400. IWL_OTP_ACCESS_RELATIVE,
  401. };
  402. /* reply_tx_statistics (for _agn devices) */
  403. struct reply_tx_error_statistics {
  404. u32 pp_delay;
  405. u32 pp_few_bytes;
  406. u32 pp_bt_prio;
  407. u32 pp_quiet_period;
  408. u32 pp_calc_ttak;
  409. u32 int_crossed_retry;
  410. u32 short_limit;
  411. u32 long_limit;
  412. u32 fifo_underrun;
  413. u32 drain_flow;
  414. u32 rfkill_flush;
  415. u32 life_expire;
  416. u32 dest_ps;
  417. u32 host_abort;
  418. u32 bt_retry;
  419. u32 sta_invalid;
  420. u32 frag_drop;
  421. u32 tid_disable;
  422. u32 fifo_flush;
  423. u32 insuff_cf_poll;
  424. u32 fail_hw_drop;
  425. u32 sta_color_mismatch;
  426. u32 unknown;
  427. };
  428. /* reply_agg_tx_statistics (for _agn devices) */
  429. struct reply_agg_tx_error_statistics {
  430. u32 underrun;
  431. u32 bt_prio;
  432. u32 few_bytes;
  433. u32 abort;
  434. u32 last_sent_ttl;
  435. u32 last_sent_try;
  436. u32 last_sent_bt_kill;
  437. u32 scd_query;
  438. u32 bad_crc32;
  439. u32 response;
  440. u32 dump_tx;
  441. u32 delay_tx;
  442. u32 unknown;
  443. };
  444. /*
  445. * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  446. * to perform continuous uCode event logging operation if enabled
  447. */
  448. #define UCODE_TRACE_PERIOD (10)
  449. /*
  450. * iwl_event_log: current uCode event log position
  451. *
  452. * @ucode_trace: enable/disable ucode continuous trace timer
  453. * @num_wraps: how many times the event buffer wraps
  454. * @next_entry: the entry just before the next one that uCode would fill
  455. * @non_wraps_count: counter for no wrap detected when dump ucode events
  456. * @wraps_once_count: counter for wrap once detected when dump ucode events
  457. * @wraps_more_count: counter for wrap more than once detected
  458. * when dump ucode events
  459. */
  460. struct iwl_event_log {
  461. bool ucode_trace;
  462. u32 num_wraps;
  463. u32 next_entry;
  464. int non_wraps_count;
  465. int wraps_once_count;
  466. int wraps_more_count;
  467. };
  468. #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
  469. /* BT Antenna Coupling Threshold (dB) */
  470. #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
  471. /* Firmware reload counter and Timestamp */
  472. #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
  473. #define IWL_MAX_CONTINUE_RELOAD_CNT 4
  474. struct iwl_rf_reset {
  475. int reset_request_count;
  476. int reset_success_count;
  477. int reset_reject_count;
  478. unsigned long last_reset_jiffies;
  479. };
  480. enum iwl_rxon_context_id {
  481. IWL_RXON_CTX_BSS,
  482. IWL_RXON_CTX_PAN,
  483. NUM_IWL_RXON_CTX
  484. };
  485. /* extend beacon time format bit shifting */
  486. /*
  487. * for _agn devices
  488. * bits 31:22 - extended
  489. * bits 21:0 - interval
  490. */
  491. #define IWLAGN_EXT_BEACON_TIME_POS 22
  492. struct iwl_rxon_context {
  493. struct ieee80211_vif *vif;
  494. u8 mcast_queue;
  495. u8 ac_to_queue[IEEE80211_NUM_ACS];
  496. u8 ac_to_fifo[IEEE80211_NUM_ACS];
  497. /*
  498. * We could use the vif to indicate active, but we
  499. * also need it to be active during disabling when
  500. * we already removed the vif for type setting.
  501. */
  502. bool always_active, is_active;
  503. bool ht_need_multiple_chains;
  504. enum iwl_rxon_context_id ctxid;
  505. u32 interface_modes, exclusive_interface_modes;
  506. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  507. /*
  508. * We declare this const so it can only be
  509. * changed via explicit cast within the
  510. * routines that actually update the physical
  511. * hardware.
  512. */
  513. const struct iwl_rxon_cmd active;
  514. struct iwl_rxon_cmd staging;
  515. struct iwl_rxon_time_cmd timing;
  516. struct iwl_qos_info qos_data;
  517. u8 bcast_sta_id, ap_sta_id;
  518. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  519. u8 qos_cmd;
  520. u8 wep_key_cmd;
  521. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  522. u8 key_mapping_keys;
  523. __le32 station_flags;
  524. int beacon_int;
  525. struct {
  526. bool non_gf_sta_present;
  527. u8 protection;
  528. bool enabled, is_40mhz;
  529. u8 extension_chan_offset;
  530. } ht;
  531. };
  532. enum iwl_scan_type {
  533. IWL_SCAN_NORMAL,
  534. IWL_SCAN_RADIO_RESET,
  535. IWL_SCAN_ROC,
  536. };
  537. /**
  538. * struct iwl_hw_params
  539. *
  540. * Holds the module parameters
  541. *
  542. * @tx_chains_num: Number of TX chains
  543. * @rx_chains_num: Number of RX chains
  544. * @valid_tx_ant: usable antennas for TX
  545. * @valid_rx_ant: usable antennas for RX
  546. * @ht40_channel: is 40MHz width possible: BIT(IEEE80211_BAND_XXX)
  547. * @sku: sku read from EEPROM
  548. * @ct_kill_threshold: temperature threshold - in hw dependent unit
  549. * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
  550. * relevant for 1000, 6000 and up
  551. * @struct iwl_sensitivity_ranges: range of sensitivity values
  552. * @use_rts_for_aggregation: use rts/cts protection for HT traffic
  553. */
  554. struct iwl_hw_params {
  555. u8 tx_chains_num;
  556. u8 rx_chains_num;
  557. u8 valid_tx_ant;
  558. u8 valid_rx_ant;
  559. u8 ht40_channel;
  560. bool use_rts_for_aggregation;
  561. u16 sku;
  562. u32 ct_kill_threshold;
  563. u32 ct_kill_exit_threshold;
  564. const struct iwl_sensitivity_ranges *sens;
  565. };
  566. struct iwl_lib_ops {
  567. /* set hw dependent parameters */
  568. void (*set_hw_params)(struct iwl_priv *priv);
  569. int (*set_channel_switch)(struct iwl_priv *priv,
  570. struct ieee80211_channel_switch *ch_switch);
  571. /* device specific configuration */
  572. void (*nic_config)(struct iwl_priv *priv);
  573. /* eeprom operations (as defined in iwl-eeprom.h) */
  574. struct iwl_eeprom_ops eeprom_ops;
  575. /* temperature */
  576. void (*temperature)(struct iwl_priv *priv);
  577. };
  578. #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
  579. struct iwl_testmode_trace {
  580. u32 buff_size;
  581. u32 total_size;
  582. u32 num_chunks;
  583. u8 *cpu_addr;
  584. u8 *trace_addr;
  585. dma_addr_t dma_addr;
  586. bool trace_enabled;
  587. };
  588. struct iwl_testmode_mem {
  589. u32 buff_size;
  590. u32 num_chunks;
  591. u8 *buff_addr;
  592. bool read_in_progress;
  593. };
  594. #endif
  595. struct iwl_wipan_noa_data {
  596. struct rcu_head rcu_head;
  597. u32 length;
  598. u8 data[];
  599. };
  600. /* Calibration disabling bit mask */
  601. enum {
  602. IWL_CALIB_ENABLE_ALL = 0,
  603. IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
  604. IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
  605. IWL_TX_POWER_CALIB_DISABLED = BIT(2),
  606. IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
  607. };
  608. #define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
  609. ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
  610. #define IWL_MAC80211_GET_DVM(_hw) \
  611. ((struct iwl_priv *) ((struct iwl_op_mode *) \
  612. (_hw)->priv)->op_mode_specific)
  613. struct iwl_priv {
  614. struct iwl_trans *trans;
  615. struct device *dev; /* for debug prints only */
  616. const struct iwl_cfg *cfg;
  617. const struct iwl_fw *fw;
  618. const struct iwl_lib_ops *lib;
  619. unsigned long status;
  620. spinlock_t sta_lock;
  621. struct mutex mutex;
  622. unsigned long transport_queue_stop;
  623. bool passive_no_rx;
  624. #define IWL_INVALID_AC 0xff
  625. u8 queue_to_ac[IWL_MAX_HW_QUEUES];
  626. atomic_t ac_stop_count[IEEE80211_NUM_ACS];
  627. unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  628. /* ieee device used by generic ieee processing code */
  629. struct ieee80211_hw *hw;
  630. struct ieee80211_channel *ieee_channels;
  631. struct ieee80211_rate *ieee_rates;
  632. struct list_head calib_results;
  633. struct workqueue_struct *workqueue;
  634. struct iwl_hw_params hw_params;
  635. enum ieee80211_band band;
  636. u8 valid_contexts;
  637. void (*pre_rx_handler)(struct iwl_priv *priv,
  638. struct iwl_rx_cmd_buffer *rxb);
  639. int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  640. struct iwl_rx_cmd_buffer *rxb,
  641. struct iwl_device_cmd *cmd);
  642. struct iwl_notif_wait_data notif_wait;
  643. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  644. /* spectrum measurement report caching */
  645. struct iwl_spectrum_notification measure_report;
  646. u8 measurement_status;
  647. #define IWL_OWNERSHIP_DRIVER 0
  648. #define IWL_OWNERSHIP_TM 1
  649. u8 ucode_owner;
  650. /* ucode beacon time */
  651. u32 ucode_beacon_time;
  652. int missed_beacon_threshold;
  653. /* track IBSS manager (last beacon) status */
  654. u32 ibss_manager;
  655. /* jiffies when last recovery from statistics was performed */
  656. unsigned long rx_statistics_jiffies;
  657. /*counters */
  658. u32 rx_handlers_stats[REPLY_MAX];
  659. /* rf reset */
  660. struct iwl_rf_reset rf_reset;
  661. /* firmware reload counter and timestamp */
  662. unsigned long reload_jiffies;
  663. int reload_count;
  664. bool ucode_loaded;
  665. bool init_ucode_run; /* Don't run init uCode again */
  666. /* we allocate array of iwl_channel_info for NIC's valid channels.
  667. * Access via channel # using indirect index array */
  668. struct iwl_channel_info *channel_info; /* channel info array */
  669. u8 channel_count; /* # of channels */
  670. u8 plcp_delta_threshold;
  671. /* thermal calibration */
  672. s32 temperature; /* Celsius */
  673. s32 last_temperature;
  674. struct iwl_wipan_noa_data __rcu *noa_data;
  675. /* Scan related variables */
  676. unsigned long scan_start;
  677. unsigned long scan_start_tsf;
  678. void *scan_cmd;
  679. enum ieee80211_band scan_band;
  680. struct cfg80211_scan_request *scan_request;
  681. struct ieee80211_vif *scan_vif;
  682. enum iwl_scan_type scan_type;
  683. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  684. u8 mgmt_tx_ant;
  685. /* max number of station keys */
  686. u8 sta_key_max_num;
  687. bool new_scan_threshold_behaviour;
  688. bool wowlan;
  689. /* EEPROM MAC addresses */
  690. struct mac_address addresses[2];
  691. struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
  692. __le16 switch_channel;
  693. u8 start_calib;
  694. struct iwl_sensitivity_data sensitivity_data;
  695. struct iwl_chain_noise_data chain_noise_data;
  696. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  697. __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
  698. struct iwl_ht_config current_ht_config;
  699. /* Rate scaling data */
  700. u8 retry_rate;
  701. int activity_timer_active;
  702. struct iwl_power_mgr power_data;
  703. struct iwl_tt_mgmt thermal_throttle;
  704. /* station table variables */
  705. int num_stations;
  706. struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
  707. unsigned long ucode_key_table;
  708. struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
  709. u8 mac80211_registered;
  710. /* Indication if ieee80211_ops->open has been called */
  711. u8 is_open;
  712. enum nl80211_iftype iw_mode;
  713. /* Last Rx'd beacon timestamp */
  714. u64 timestamp;
  715. struct {
  716. __le32 flag;
  717. struct statistics_general_common common;
  718. struct statistics_rx_non_phy rx_non_phy;
  719. struct statistics_rx_phy rx_ofdm;
  720. struct statistics_rx_ht_phy rx_ofdm_ht;
  721. struct statistics_rx_phy rx_cck;
  722. struct statistics_tx tx;
  723. #ifdef CONFIG_IWLWIFI_DEBUGFS
  724. struct statistics_bt_activity bt_activity;
  725. __le32 num_bt_kills, accum_num_bt_kills;
  726. #endif
  727. spinlock_t lock;
  728. } statistics;
  729. #ifdef CONFIG_IWLWIFI_DEBUGFS
  730. struct {
  731. struct statistics_general_common common;
  732. struct statistics_rx_non_phy rx_non_phy;
  733. struct statistics_rx_phy rx_ofdm;
  734. struct statistics_rx_ht_phy rx_ofdm_ht;
  735. struct statistics_rx_phy rx_cck;
  736. struct statistics_tx tx;
  737. struct statistics_bt_activity bt_activity;
  738. } accum_stats, delta_stats, max_delta_stats;
  739. #endif
  740. /*
  741. * reporting the number of tids has AGG on. 0 means
  742. * no AGGREGATION
  743. */
  744. u8 agg_tids_count;
  745. struct iwl_rx_phy_res last_phy_res;
  746. bool last_phy_res_valid;
  747. /*
  748. * chain noise reset and gain commands are the
  749. * two extra calibration commands follows the standard
  750. * phy calibration commands
  751. */
  752. u8 phy_calib_chain_noise_reset_cmd;
  753. u8 phy_calib_chain_noise_gain_cmd;
  754. /* counts reply_tx error */
  755. struct reply_tx_error_statistics reply_tx_stats;
  756. struct reply_agg_tx_error_statistics reply_agg_tx_stats;
  757. /* remain-on-channel offload support */
  758. struct ieee80211_channel *hw_roc_channel;
  759. struct delayed_work hw_roc_disable_work;
  760. enum nl80211_channel_type hw_roc_chantype;
  761. int hw_roc_duration;
  762. bool hw_roc_setup, hw_roc_start_notified;
  763. /* bt coex */
  764. u8 bt_enable_flag;
  765. u8 bt_status;
  766. u8 bt_traffic_load, last_bt_traffic_load;
  767. bool bt_ch_announce;
  768. bool bt_full_concurrent;
  769. bool bt_ant_couple_ok;
  770. __le32 kill_ack_mask;
  771. __le32 kill_cts_mask;
  772. __le16 bt_valid;
  773. u16 bt_on_thresh;
  774. u16 bt_duration;
  775. u16 dynamic_frag_thresh;
  776. u8 bt_ci_compliance;
  777. struct work_struct bt_traffic_change_work;
  778. bool bt_enable_pspoll;
  779. struct iwl_rxon_context *cur_rssi_ctx;
  780. bool bt_is_sco;
  781. struct work_struct restart;
  782. struct work_struct scan_completed;
  783. struct work_struct abort_scan;
  784. struct work_struct beacon_update;
  785. struct iwl_rxon_context *beacon_ctx;
  786. struct sk_buff *beacon_skb;
  787. void *beacon_cmd;
  788. struct work_struct tt_work;
  789. struct work_struct ct_enter;
  790. struct work_struct ct_exit;
  791. struct work_struct start_internal_scan;
  792. struct work_struct tx_flush;
  793. struct work_struct bt_full_concurrency;
  794. struct work_struct bt_runtime_config;
  795. struct delayed_work scan_check;
  796. /* TX Power */
  797. s8 tx_power_user_lmt;
  798. s8 tx_power_device_lmt;
  799. s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
  800. s8 tx_power_next;
  801. #ifdef CONFIG_IWLWIFI_DEBUGFS
  802. /* debugfs */
  803. struct dentry *debugfs_dir;
  804. u32 dbgfs_sram_offset, dbgfs_sram_len;
  805. bool disable_ht40;
  806. void *wowlan_sram;
  807. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  808. /* eeprom -- this is in the card's little endian byte order */
  809. u8 *eeprom;
  810. enum iwl_nvm_type nvm_device_type;
  811. struct work_struct txpower_work;
  812. u32 calib_disabled;
  813. struct work_struct run_time_calib_work;
  814. struct timer_list statistics_periodic;
  815. struct timer_list ucode_trace;
  816. struct iwl_event_log event_log;
  817. struct led_classdev led;
  818. unsigned long blink_on, blink_off;
  819. bool led_registered;
  820. #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
  821. struct iwl_testmode_trace testmode_trace;
  822. struct iwl_testmode_mem testmode_mem;
  823. u32 tm_fixed_rate;
  824. #endif
  825. /* WoWLAN GTK rekey data */
  826. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  827. __le64 replay_ctr;
  828. __le16 last_seq_ctl;
  829. bool have_rekey_data;
  830. /* device_pointers: pointers to ucode event tables */
  831. struct {
  832. u32 error_event_table;
  833. u32 log_event_table;
  834. } device_pointers;
  835. /* indicator of loaded ucode image */
  836. enum iwl_ucode_type cur_ucode;
  837. }; /*iwl_priv */
  838. extern struct kmem_cache *iwl_tx_cmd_pool;
  839. static inline struct iwl_rxon_context *
  840. iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  841. {
  842. struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
  843. return vif_priv->ctx;
  844. }
  845. #define for_each_context(priv, ctx) \
  846. for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
  847. ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
  848. if (priv->valid_contexts & BIT(ctx->ctxid))
  849. static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
  850. {
  851. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  852. }
  853. static inline int iwl_is_associated(struct iwl_priv *priv,
  854. enum iwl_rxon_context_id ctxid)
  855. {
  856. return iwl_is_associated_ctx(&priv->contexts[ctxid]);
  857. }
  858. static inline int iwl_is_any_associated(struct iwl_priv *priv)
  859. {
  860. struct iwl_rxon_context *ctx;
  861. for_each_context(priv, ctx)
  862. if (iwl_is_associated_ctx(ctx))
  863. return true;
  864. return false;
  865. }
  866. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  867. {
  868. if (ch_info == NULL)
  869. return 0;
  870. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  871. }
  872. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  873. {
  874. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  875. }
  876. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  877. {
  878. return ch_info->band == IEEE80211_BAND_5GHZ;
  879. }
  880. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  881. {
  882. return ch_info->band == IEEE80211_BAND_2GHZ;
  883. }
  884. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  885. {
  886. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  887. }
  888. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  889. {
  890. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  891. }
  892. #endif /* __iwl_dev_h__ */