dev.h 23 KB

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