dev.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2014 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 (dev.h) for driver implementation definitions.
  28. * Please use 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-parse.h"
  40. #include "iwl-csr.h"
  41. #include "iwl-debug.h"
  42. #include "iwl-agn-hw.h"
  43. #include "iwl-op-mode.h"
  44. #include "iwl-notif-wait.h"
  45. #include "iwl-trans.h"
  46. #include "led.h"
  47. #include "power.h"
  48. #include "rs.h"
  49. #include "tt.h"
  50. /* CT-KILL constants */
  51. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  52. #define CT_KILL_THRESHOLD 114 /* in Celsius */
  53. #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
  54. /* Default noise level to report when noise measurement is not available.
  55. * This may be because we're:
  56. * 1) Not associated no beacon statistics being sent to driver)
  57. * 2) Scanning (noise measurement does not apply to associated channel)
  58. * Use default noise value of -127 ... this is below the range of measurable
  59. * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
  60. * Also, -127 works better than 0 when averaging frames with/without
  61. * noise info (e.g. averaging might be done in app); measured dBm values are
  62. * always negative ... using a negative value as the default keeps all
  63. * averages within an s8's (used in some apps) range of negative values. */
  64. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  65. /*
  66. * RTS threshold here is total size [2347] minus 4 FCS bytes
  67. * Per spec:
  68. * a value of 0 means RTS on all data/management packets
  69. * a value > max MSDU size means no RTS
  70. * else RTS for data/management frames where MPDU is larger
  71. * than RTS value.
  72. */
  73. #define DEFAULT_RTS_THRESHOLD 2347U
  74. #define MIN_RTS_THRESHOLD 0U
  75. #define MAX_RTS_THRESHOLD 2347U
  76. #define MAX_MSDU_SIZE 2304U
  77. #define MAX_MPDU_SIZE 2346U
  78. #define DEFAULT_BEACON_INTERVAL 200U
  79. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  80. #define DEFAULT_LONG_RETRY_LIMIT 4U
  81. #define IWL_NUM_SCAN_RATES (2)
  82. #define IEEE80211_DATA_LEN 2304
  83. #define IEEE80211_4ADDR_LEN 30
  84. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  85. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  86. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  87. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  88. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  89. #define IWL_SUPPORTED_RATES_IE_LEN 8
  90. #define IWL_INVALID_RATE 0xFF
  91. #define IWL_INVALID_VALUE -1
  92. union iwl_ht_rate_supp {
  93. u16 rates;
  94. struct {
  95. u8 siso_rate;
  96. u8 mimo_rate;
  97. };
  98. };
  99. struct iwl_ht_config {
  100. bool single_chain_sufficient;
  101. enum ieee80211_smps_mode smps; /* current smps mode */
  102. };
  103. /* QoS structures */
  104. struct iwl_qos_info {
  105. int qos_active;
  106. struct iwl_qosparam_cmd def_qos_parm;
  107. };
  108. /**
  109. * enum iwl_agg_state
  110. *
  111. * The state machine of the BA agreement establishment / tear down.
  112. * These states relate to a specific RA / TID.
  113. *
  114. * @IWL_AGG_OFF: aggregation is not used
  115. * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
  116. * @IWL_AGG_ON: aggregation session is up
  117. * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
  118. * HW queue to be empty from packets for this RA /TID.
  119. * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
  120. * HW queue to be empty from packets for this RA /TID.
  121. */
  122. enum iwl_agg_state {
  123. IWL_AGG_OFF = 0,
  124. IWL_AGG_STARTING,
  125. IWL_AGG_ON,
  126. IWL_EMPTYING_HW_QUEUE_ADDBA,
  127. IWL_EMPTYING_HW_QUEUE_DELBA,
  128. };
  129. /**
  130. * struct iwl_ht_agg - aggregation state machine
  131. * This structs holds the states for the BA agreement establishment and tear
  132. * down. It also holds the state during the BA session itself. This struct is
  133. * duplicated for each RA / TID.
  134. * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
  135. * Tx response (REPLY_TX), and the block ack notification
  136. * (REPLY_COMPRESSED_BA).
  137. * @state: state of the BA agreement establishment / tear down.
  138. * @txq_id: Tx queue used by the BA session
  139. * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
  140. * the first packet to be sent in legacy HW queue in Tx AGG stop flow.
  141. * Basically when next_reclaimed reaches ssn, we can tell mac80211 that
  142. * we are ready to finish the Tx AGG stop / start flow.
  143. * @wait_for_ba: Expect block-ack before next Tx reply
  144. */
  145. struct iwl_ht_agg {
  146. u32 rate_n_flags;
  147. enum iwl_agg_state state;
  148. u16 txq_id;
  149. u16 ssn;
  150. bool wait_for_ba;
  151. };
  152. /**
  153. * struct iwl_tid_data - one for each RA / TID
  154. * This structs holds the states for each RA / TID.
  155. * @seq_number: the next WiFi sequence number to use
  156. * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
  157. * This is basically (last acked packet++).
  158. * @agg: aggregation state machine
  159. */
  160. struct iwl_tid_data {
  161. u16 seq_number;
  162. u16 next_reclaimed;
  163. struct iwl_ht_agg agg;
  164. };
  165. /*
  166. * Structure should be accessed with sta_lock held. When station addition
  167. * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
  168. * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
  169. * held.
  170. */
  171. struct iwl_station_entry {
  172. struct iwl_addsta_cmd sta;
  173. u8 used, ctxid;
  174. struct iwl_link_quality_cmd *lq;
  175. };
  176. /*
  177. * iwl_station_priv: Driver's private station information
  178. *
  179. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  180. * in the structure for use by driver. This structure is places in that
  181. * space.
  182. */
  183. struct iwl_station_priv {
  184. struct iwl_rxon_context *ctx;
  185. struct iwl_lq_sta lq_sta;
  186. atomic_t pending_frames;
  187. bool client;
  188. bool asleep;
  189. u8 max_agg_bufsize;
  190. u8 sta_id;
  191. };
  192. /**
  193. * struct iwl_vif_priv - driver's private per-interface information
  194. *
  195. * When mac80211 allocates a virtual interface, it can allocate
  196. * space for us to put data into.
  197. */
  198. struct iwl_vif_priv {
  199. struct iwl_rxon_context *ctx;
  200. u8 ibss_bssid_sta_id;
  201. };
  202. struct iwl_sensitivity_ranges {
  203. u16 min_nrg_cck;
  204. u16 nrg_th_cck;
  205. u16 nrg_th_ofdm;
  206. u16 auto_corr_min_ofdm;
  207. u16 auto_corr_min_ofdm_mrc;
  208. u16 auto_corr_min_ofdm_x1;
  209. u16 auto_corr_min_ofdm_mrc_x1;
  210. u16 auto_corr_max_ofdm;
  211. u16 auto_corr_max_ofdm_mrc;
  212. u16 auto_corr_max_ofdm_x1;
  213. u16 auto_corr_max_ofdm_mrc_x1;
  214. u16 auto_corr_max_cck;
  215. u16 auto_corr_max_cck_mrc;
  216. u16 auto_corr_min_cck;
  217. u16 auto_corr_min_cck_mrc;
  218. u16 barker_corr_th_min;
  219. u16 barker_corr_th_min_mrc;
  220. u16 nrg_th_cca;
  221. };
  222. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  223. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  224. /******************************************************************************
  225. *
  226. * Functions implemented in core module which are forward declared here
  227. * for use by iwl-[4-5].c
  228. *
  229. * NOTE: The implementation of these functions are not hardware specific
  230. * which is why they are in the core module files.
  231. *
  232. * Naming convention --
  233. * iwl_ <-- Is part of iwlwifi
  234. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  235. *
  236. ****************************************************************************/
  237. void iwl_update_chain_flags(struct iwl_priv *priv);
  238. extern const u8 iwl_bcast_addr[ETH_ALEN];
  239. #define IWL_OPERATION_MODE_AUTO 0
  240. #define IWL_OPERATION_MODE_HT_ONLY 1
  241. #define IWL_OPERATION_MODE_MIXED 2
  242. #define IWL_OPERATION_MODE_20MHZ 3
  243. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  244. /* Sensitivity and chain noise calibration */
  245. #define INITIALIZATION_VALUE 0xFFFF
  246. #define IWL_CAL_NUM_BEACONS 16
  247. #define MAXIMUM_ALLOWED_PATHLOSS 15
  248. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  249. #define MAX_FA_OFDM 50
  250. #define MIN_FA_OFDM 5
  251. #define MAX_FA_CCK 50
  252. #define MIN_FA_CCK 5
  253. #define AUTO_CORR_STEP_OFDM 1
  254. #define AUTO_CORR_STEP_CCK 3
  255. #define AUTO_CORR_MAX_TH_CCK 160
  256. #define NRG_DIFF 2
  257. #define NRG_STEP_CCK 2
  258. #define NRG_MARGIN 8
  259. #define MAX_NUMBER_CCK_NO_FA 100
  260. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  261. #define CHAIN_A 0
  262. #define CHAIN_B 1
  263. #define CHAIN_C 2
  264. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  265. #define ALL_BAND_FILTER 0xFF00
  266. #define IN_BAND_FILTER 0xFF
  267. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  268. #define NRG_NUM_PREV_STAT_L 20
  269. #define NUM_RX_CHAINS 3
  270. enum iwlagn_false_alarm_state {
  271. IWL_FA_TOO_MANY = 0,
  272. IWL_FA_TOO_FEW = 1,
  273. IWL_FA_GOOD_RANGE = 2,
  274. };
  275. enum iwlagn_chain_noise_state {
  276. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  277. IWL_CHAIN_NOISE_ACCUMULATE,
  278. IWL_CHAIN_NOISE_CALIBRATED,
  279. IWL_CHAIN_NOISE_DONE,
  280. };
  281. /* Sensitivity calib data */
  282. struct iwl_sensitivity_data {
  283. u32 auto_corr_ofdm;
  284. u32 auto_corr_ofdm_mrc;
  285. u32 auto_corr_ofdm_x1;
  286. u32 auto_corr_ofdm_mrc_x1;
  287. u32 auto_corr_cck;
  288. u32 auto_corr_cck_mrc;
  289. u32 last_bad_plcp_cnt_ofdm;
  290. u32 last_fa_cnt_ofdm;
  291. u32 last_bad_plcp_cnt_cck;
  292. u32 last_fa_cnt_cck;
  293. u32 nrg_curr_state;
  294. u32 nrg_prev_state;
  295. u32 nrg_value[10];
  296. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  297. u32 nrg_silence_ref;
  298. u32 nrg_energy_idx;
  299. u32 nrg_silence_idx;
  300. u32 nrg_th_cck;
  301. s32 nrg_auto_corr_silence_diff;
  302. u32 num_in_cck_no_fa;
  303. u32 nrg_th_ofdm;
  304. u16 barker_corr_th_min;
  305. u16 barker_corr_th_min_mrc;
  306. u16 nrg_th_cca;
  307. };
  308. /* Chain noise (differential Rx gain) calib data */
  309. struct iwl_chain_noise_data {
  310. u32 active_chains;
  311. u32 chain_noise_a;
  312. u32 chain_noise_b;
  313. u32 chain_noise_c;
  314. u32 chain_signal_a;
  315. u32 chain_signal_b;
  316. u32 chain_signal_c;
  317. u16 beacon_count;
  318. u8 disconn_array[NUM_RX_CHAINS];
  319. u8 delta_gain_code[NUM_RX_CHAINS];
  320. u8 radio_write;
  321. u8 state;
  322. };
  323. enum {
  324. MEASUREMENT_READY = (1 << 0),
  325. MEASUREMENT_ACTIVE = (1 << 1),
  326. };
  327. /* reply_tx_statistics (for _agn devices) */
  328. struct reply_tx_error_statistics {
  329. u32 pp_delay;
  330. u32 pp_few_bytes;
  331. u32 pp_bt_prio;
  332. u32 pp_quiet_period;
  333. u32 pp_calc_ttak;
  334. u32 int_crossed_retry;
  335. u32 short_limit;
  336. u32 long_limit;
  337. u32 fifo_underrun;
  338. u32 drain_flow;
  339. u32 rfkill_flush;
  340. u32 life_expire;
  341. u32 dest_ps;
  342. u32 host_abort;
  343. u32 bt_retry;
  344. u32 sta_invalid;
  345. u32 frag_drop;
  346. u32 tid_disable;
  347. u32 fifo_flush;
  348. u32 insuff_cf_poll;
  349. u32 fail_hw_drop;
  350. u32 sta_color_mismatch;
  351. u32 unknown;
  352. };
  353. /* reply_agg_tx_statistics (for _agn devices) */
  354. struct reply_agg_tx_error_statistics {
  355. u32 underrun;
  356. u32 bt_prio;
  357. u32 few_bytes;
  358. u32 abort;
  359. u32 last_sent_ttl;
  360. u32 last_sent_try;
  361. u32 last_sent_bt_kill;
  362. u32 scd_query;
  363. u32 bad_crc32;
  364. u32 response;
  365. u32 dump_tx;
  366. u32 delay_tx;
  367. u32 unknown;
  368. };
  369. /*
  370. * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  371. * to perform continuous uCode event logging operation if enabled
  372. */
  373. #define UCODE_TRACE_PERIOD (10)
  374. /*
  375. * iwl_event_log: current uCode event log position
  376. *
  377. * @ucode_trace: enable/disable ucode continuous trace timer
  378. * @num_wraps: how many times the event buffer wraps
  379. * @next_entry: the entry just before the next one that uCode would fill
  380. * @non_wraps_count: counter for no wrap detected when dump ucode events
  381. * @wraps_once_count: counter for wrap once detected when dump ucode events
  382. * @wraps_more_count: counter for wrap more than once detected
  383. * when dump ucode events
  384. */
  385. struct iwl_event_log {
  386. bool ucode_trace;
  387. u32 num_wraps;
  388. u32 next_entry;
  389. int non_wraps_count;
  390. int wraps_once_count;
  391. int wraps_more_count;
  392. };
  393. #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
  394. /* BT Antenna Coupling Threshold (dB) */
  395. #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
  396. /* Firmware reload counter and Timestamp */
  397. #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
  398. #define IWL_MAX_CONTINUE_RELOAD_CNT 4
  399. struct iwl_rf_reset {
  400. int reset_request_count;
  401. int reset_success_count;
  402. int reset_reject_count;
  403. unsigned long last_reset_jiffies;
  404. };
  405. enum iwl_rxon_context_id {
  406. IWL_RXON_CTX_BSS,
  407. IWL_RXON_CTX_PAN,
  408. NUM_IWL_RXON_CTX
  409. };
  410. /* extend beacon time format bit shifting */
  411. /*
  412. * for _agn devices
  413. * bits 31:22 - extended
  414. * bits 21:0 - interval
  415. */
  416. #define IWLAGN_EXT_BEACON_TIME_POS 22
  417. struct iwl_rxon_context {
  418. struct ieee80211_vif *vif;
  419. u8 mcast_queue;
  420. u8 ac_to_queue[IEEE80211_NUM_ACS];
  421. u8 ac_to_fifo[IEEE80211_NUM_ACS];
  422. /*
  423. * We could use the vif to indicate active, but we
  424. * also need it to be active during disabling when
  425. * we already removed the vif for type setting.
  426. */
  427. bool always_active, is_active;
  428. bool ht_need_multiple_chains;
  429. enum iwl_rxon_context_id ctxid;
  430. u32 interface_modes, exclusive_interface_modes;
  431. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  432. /*
  433. * We declare this const so it can only be
  434. * changed via explicit cast within the
  435. * routines that actually update the physical
  436. * hardware.
  437. */
  438. const struct iwl_rxon_cmd active;
  439. struct iwl_rxon_cmd staging;
  440. struct iwl_rxon_time_cmd timing;
  441. struct iwl_qos_info qos_data;
  442. u8 bcast_sta_id, ap_sta_id;
  443. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  444. u8 qos_cmd;
  445. u8 wep_key_cmd;
  446. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  447. u8 key_mapping_keys;
  448. __le32 station_flags;
  449. int beacon_int;
  450. struct {
  451. bool non_gf_sta_present;
  452. u8 protection;
  453. bool enabled, is_40mhz;
  454. u8 extension_chan_offset;
  455. } ht;
  456. };
  457. enum iwl_scan_type {
  458. IWL_SCAN_NORMAL,
  459. IWL_SCAN_RADIO_RESET,
  460. };
  461. /**
  462. * struct iwl_hw_params
  463. *
  464. * Holds the module parameters
  465. *
  466. * @tx_chains_num: Number of TX chains
  467. * @rx_chains_num: Number of RX chains
  468. * @ct_kill_threshold: temperature threshold - in hw dependent unit
  469. * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
  470. * relevant for 1000, 6000 and up
  471. * @struct iwl_sensitivity_ranges: range of sensitivity values
  472. * @use_rts_for_aggregation: use rts/cts protection for HT traffic
  473. */
  474. struct iwl_hw_params {
  475. u8 tx_chains_num;
  476. u8 rx_chains_num;
  477. bool use_rts_for_aggregation;
  478. u32 ct_kill_threshold;
  479. u32 ct_kill_exit_threshold;
  480. const struct iwl_sensitivity_ranges *sens;
  481. };
  482. /**
  483. * struct iwl_dvm_bt_params - DVM specific BT (coex) parameters
  484. * @advanced_bt_coexist: support advanced bt coexist
  485. * @bt_init_traffic_load: specify initial bt traffic load
  486. * @bt_prio_boost: default bt priority boost value
  487. * @agg_time_limit: maximum number of uSec in aggregation
  488. * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
  489. */
  490. struct iwl_dvm_bt_params {
  491. bool advanced_bt_coexist;
  492. u8 bt_init_traffic_load;
  493. u32 bt_prio_boost;
  494. u16 agg_time_limit;
  495. bool bt_sco_disable;
  496. bool bt_session_2;
  497. };
  498. /**
  499. * struct iwl_dvm_cfg - DVM firmware specific device configuration
  500. * @set_hw_params: set hardware parameters
  501. * @set_channel_switch: send channel switch command
  502. * @nic_config: apply device specific configuration
  503. * @temperature: read temperature
  504. * @adv_thermal_throttle: support advance thermal throttle
  505. * @support_ct_kill_exit: support ct kill exit condition
  506. * @plcp_delta_threshold: plcp error rate threshold used to trigger
  507. * radio tuning when there is a high receiving plcp error rate
  508. * @chain_noise_scale: default chain noise scale used for gain computation
  509. * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
  510. * @no_idle_support: do not support idle mode
  511. * @bt_params: pointer to BT parameters
  512. * @need_temp_offset_calib: need to perform temperature offset calibration
  513. * @no_xtal_calib: some devices do not need crystal calibration data,
  514. * don't send it to those
  515. * @temp_offset_v2: support v2 of temperature offset calibration
  516. * @adv_pm: advanced power management
  517. */
  518. struct iwl_dvm_cfg {
  519. void (*set_hw_params)(struct iwl_priv *priv);
  520. int (*set_channel_switch)(struct iwl_priv *priv,
  521. struct ieee80211_channel_switch *ch_switch);
  522. void (*nic_config)(struct iwl_priv *priv);
  523. void (*temperature)(struct iwl_priv *priv);
  524. const struct iwl_dvm_bt_params *bt_params;
  525. s32 chain_noise_scale;
  526. u8 plcp_delta_threshold;
  527. bool adv_thermal_throttle;
  528. bool support_ct_kill_exit;
  529. bool hd_v2;
  530. bool no_idle_support;
  531. bool need_temp_offset_calib;
  532. bool no_xtal_calib;
  533. bool temp_offset_v2;
  534. bool adv_pm;
  535. };
  536. struct iwl_wipan_noa_data {
  537. struct rcu_head rcu_head;
  538. u32 length;
  539. u8 data[];
  540. };
  541. /* Calibration disabling bit mask */
  542. enum {
  543. IWL_CALIB_ENABLE_ALL = 0,
  544. IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
  545. IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
  546. IWL_TX_POWER_CALIB_DISABLED = BIT(2),
  547. IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
  548. };
  549. #define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
  550. ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
  551. #define IWL_MAC80211_GET_DVM(_hw) \
  552. ((struct iwl_priv *) ((struct iwl_op_mode *) \
  553. (_hw)->priv)->op_mode_specific)
  554. struct iwl_priv {
  555. struct iwl_trans *trans;
  556. struct device *dev; /* for debug prints only */
  557. const struct iwl_cfg *cfg;
  558. const struct iwl_fw *fw;
  559. const struct iwl_dvm_cfg *lib;
  560. unsigned long status;
  561. spinlock_t sta_lock;
  562. struct mutex mutex;
  563. unsigned long transport_queue_stop;
  564. bool passive_no_rx;
  565. #define IWL_INVALID_MAC80211_QUEUE 0xff
  566. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  567. atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
  568. unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  569. /* ieee device used by generic ieee processing code */
  570. struct ieee80211_hw *hw;
  571. struct list_head calib_results;
  572. struct workqueue_struct *workqueue;
  573. struct iwl_hw_params hw_params;
  574. enum ieee80211_band band;
  575. u8 valid_contexts;
  576. int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  577. struct iwl_rx_cmd_buffer *rxb,
  578. struct iwl_device_cmd *cmd);
  579. struct iwl_notif_wait_data notif_wait;
  580. /* spectrum measurement report caching */
  581. struct iwl_spectrum_notification measure_report;
  582. u8 measurement_status;
  583. /* ucode beacon time */
  584. u32 ucode_beacon_time;
  585. int missed_beacon_threshold;
  586. /* track IBSS manager (last beacon) status */
  587. u32 ibss_manager;
  588. /* jiffies when last recovery from statistics was performed */
  589. unsigned long rx_statistics_jiffies;
  590. /*counters */
  591. u32 rx_handlers_stats[REPLY_MAX];
  592. /* rf reset */
  593. struct iwl_rf_reset rf_reset;
  594. /* firmware reload counter and timestamp */
  595. unsigned long reload_jiffies;
  596. int reload_count;
  597. bool ucode_loaded;
  598. u8 plcp_delta_threshold;
  599. /* thermal calibration */
  600. s32 temperature; /* Celsius */
  601. s32 last_temperature;
  602. struct iwl_wipan_noa_data __rcu *noa_data;
  603. /* Scan related variables */
  604. unsigned long scan_start;
  605. unsigned long scan_start_tsf;
  606. void *scan_cmd;
  607. enum ieee80211_band scan_band;
  608. struct cfg80211_scan_request *scan_request;
  609. struct ieee80211_vif *scan_vif;
  610. enum iwl_scan_type scan_type;
  611. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  612. u8 mgmt_tx_ant;
  613. /* max number of station keys */
  614. u8 sta_key_max_num;
  615. bool new_scan_threshold_behaviour;
  616. bool wowlan;
  617. /* EEPROM MAC addresses */
  618. struct mac_address addresses[2];
  619. struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
  620. __le16 switch_channel;
  621. u8 start_calib;
  622. struct iwl_sensitivity_data sensitivity_data;
  623. struct iwl_chain_noise_data chain_noise_data;
  624. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  625. __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
  626. struct iwl_ht_config current_ht_config;
  627. /* Rate scaling data */
  628. u8 retry_rate;
  629. int activity_timer_active;
  630. struct iwl_power_mgr power_data;
  631. struct iwl_tt_mgmt thermal_throttle;
  632. /* station table variables */
  633. int num_stations;
  634. struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
  635. unsigned long ucode_key_table;
  636. struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
  637. atomic_t num_aux_in_flight;
  638. u8 mac80211_registered;
  639. /* Indication if ieee80211_ops->open has been called */
  640. u8 is_open;
  641. enum nl80211_iftype iw_mode;
  642. /* Last Rx'd beacon timestamp */
  643. u64 timestamp;
  644. struct {
  645. __le32 flag;
  646. struct statistics_general_common common;
  647. struct statistics_rx_non_phy rx_non_phy;
  648. struct statistics_rx_phy rx_ofdm;
  649. struct statistics_rx_ht_phy rx_ofdm_ht;
  650. struct statistics_rx_phy rx_cck;
  651. struct statistics_tx tx;
  652. #ifdef CONFIG_IWLWIFI_DEBUGFS
  653. struct statistics_bt_activity bt_activity;
  654. __le32 num_bt_kills, accum_num_bt_kills;
  655. #endif
  656. spinlock_t lock;
  657. } statistics;
  658. #ifdef CONFIG_IWLWIFI_DEBUGFS
  659. struct {
  660. struct statistics_general_common common;
  661. struct statistics_rx_non_phy rx_non_phy;
  662. struct statistics_rx_phy rx_ofdm;
  663. struct statistics_rx_ht_phy rx_ofdm_ht;
  664. struct statistics_rx_phy rx_cck;
  665. struct statistics_tx tx;
  666. struct statistics_bt_activity bt_activity;
  667. } accum_stats, delta_stats, max_delta_stats;
  668. #endif
  669. /*
  670. * reporting the number of tids has AGG on. 0 means
  671. * no AGGREGATION
  672. */
  673. u8 agg_tids_count;
  674. struct iwl_rx_phy_res last_phy_res;
  675. u32 ampdu_ref;
  676. bool last_phy_res_valid;
  677. /*
  678. * chain noise reset and gain commands are the
  679. * two extra calibration commands follows the standard
  680. * phy calibration commands
  681. */
  682. u8 phy_calib_chain_noise_reset_cmd;
  683. u8 phy_calib_chain_noise_gain_cmd;
  684. /* counts reply_tx error */
  685. struct reply_tx_error_statistics reply_tx_stats;
  686. struct reply_agg_tx_error_statistics reply_agg_tx_stats;
  687. /* bt coex */
  688. u8 bt_enable_flag;
  689. u8 bt_status;
  690. u8 bt_traffic_load, last_bt_traffic_load;
  691. bool bt_ch_announce;
  692. bool bt_full_concurrent;
  693. bool bt_ant_couple_ok;
  694. __le32 kill_ack_mask;
  695. __le32 kill_cts_mask;
  696. __le16 bt_valid;
  697. bool reduced_txpower;
  698. u16 bt_on_thresh;
  699. u16 bt_duration;
  700. u16 dynamic_frag_thresh;
  701. u8 bt_ci_compliance;
  702. struct work_struct bt_traffic_change_work;
  703. bool bt_enable_pspoll;
  704. struct iwl_rxon_context *cur_rssi_ctx;
  705. bool bt_is_sco;
  706. struct work_struct restart;
  707. struct work_struct scan_completed;
  708. struct work_struct abort_scan;
  709. struct work_struct beacon_update;
  710. struct iwl_rxon_context *beacon_ctx;
  711. struct sk_buff *beacon_skb;
  712. void *beacon_cmd;
  713. struct work_struct tt_work;
  714. struct work_struct ct_enter;
  715. struct work_struct ct_exit;
  716. struct work_struct start_internal_scan;
  717. struct work_struct tx_flush;
  718. struct work_struct bt_full_concurrency;
  719. struct work_struct bt_runtime_config;
  720. struct delayed_work scan_check;
  721. /* TX Power settings */
  722. s8 tx_power_user_lmt;
  723. s8 tx_power_next;
  724. #ifdef CONFIG_IWLWIFI_DEBUGFS
  725. /* debugfs */
  726. struct dentry *debugfs_dir;
  727. u32 dbgfs_sram_offset, dbgfs_sram_len;
  728. bool disable_ht40;
  729. void *wowlan_sram;
  730. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  731. struct iwl_nvm_data *nvm_data;
  732. /* eeprom blob for debugfs */
  733. u8 *eeprom_blob;
  734. size_t eeprom_blob_size;
  735. struct work_struct txpower_work;
  736. u32 calib_disabled;
  737. struct work_struct run_time_calib_work;
  738. struct timer_list statistics_periodic;
  739. struct timer_list ucode_trace;
  740. struct iwl_event_log event_log;
  741. #ifdef CONFIG_IWLWIFI_LEDS
  742. struct led_classdev led;
  743. unsigned long blink_on, blink_off;
  744. bool led_registered;
  745. #endif
  746. /* WoWLAN GTK rekey data */
  747. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  748. __le64 replay_ctr;
  749. __le16 last_seq_ctl;
  750. bool have_rekey_data;
  751. #ifdef CONFIG_PM_SLEEP
  752. struct wiphy_wowlan_support wowlan_support;
  753. #endif
  754. /* device_pointers: pointers to ucode event tables */
  755. struct {
  756. u32 error_event_table;
  757. u32 log_event_table;
  758. } device_pointers;
  759. /* indicator of loaded ucode image */
  760. enum iwl_ucode_type cur_ucode;
  761. }; /*iwl_priv */
  762. static inline struct iwl_rxon_context *
  763. iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  764. {
  765. struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
  766. return vif_priv->ctx;
  767. }
  768. #define for_each_context(priv, ctx) \
  769. for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
  770. ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
  771. if (priv->valid_contexts & BIT(ctx->ctxid))
  772. static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
  773. {
  774. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  775. }
  776. static inline int iwl_is_associated(struct iwl_priv *priv,
  777. enum iwl_rxon_context_id ctxid)
  778. {
  779. return iwl_is_associated_ctx(&priv->contexts[ctxid]);
  780. }
  781. static inline int iwl_is_any_associated(struct iwl_priv *priv)
  782. {
  783. struct iwl_rxon_context *ctx;
  784. for_each_context(priv, ctx)
  785. if (iwl_is_associated_ctx(ctx))
  786. return true;
  787. return false;
  788. }
  789. #endif /* __iwl_dev_h__ */