dev.h 23 KB

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