dev.h 25 KB

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