Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dev.h
Go to the documentation of this file.
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 <[email protected]>
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 
31 #ifndef __iwl_dev_h__
32 #define __iwl_dev_h__
33 
34 #include <linux/interrupt.h>
35 #include <linux/kernel.h>
36 #include <linux/wait.h>
37 #include <linux/leds.h>
38 #include <linux/slab.h>
39 #include <linux/mutex.h>
40 
41 #include "iwl-fw.h"
42 #include "iwl-eeprom-parse.h"
43 #include "iwl-csr.h"
44 #include "iwl-debug.h"
45 #include "iwl-agn-hw.h"
46 #include "iwl-op-mode.h"
47 #include "iwl-notif-wait.h"
48 #include "iwl-trans.h"
49 
50 #include "led.h"
51 #include "power.h"
52 #include "rs.h"
53 #include "tt.h"
54 
55 #include "iwl-test.h"
56 
57 /* CT-KILL constants */
58 #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
59 #define CT_KILL_THRESHOLD 114 /* in Celsius */
60 #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
61 
62 /* Default noise level to report when noise measurement is not available.
63  * This may be because we're:
64  * 1) Not associated no beacon statistics being sent to driver)
65  * 2) Scanning (noise measurement does not apply to associated channel)
66  * Use default noise value of -127 ... this is below the range of measurable
67  * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
68  * Also, -127 works better than 0 when averaging frames with/without
69  * noise info (e.g. averaging might be done in app); measured dBm values are
70  * always negative ... using a negative value as the default keeps all
71  * averages within an s8's (used in some apps) range of negative values. */
72 #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
73 
74 /*
75  * RTS threshold here is total size [2347] minus 4 FCS bytes
76  * Per spec:
77  * a value of 0 means RTS on all data/management packets
78  * a value > max MSDU size means no RTS
79  * else RTS for data/management frames where MPDU is larger
80  * than RTS value.
81  */
82 #define DEFAULT_RTS_THRESHOLD 2347U
83 #define MIN_RTS_THRESHOLD 0U
84 #define MAX_RTS_THRESHOLD 2347U
85 #define MAX_MSDU_SIZE 2304U
86 #define MAX_MPDU_SIZE 2346U
87 #define DEFAULT_BEACON_INTERVAL 200U
88 #define DEFAULT_SHORT_RETRY_LIMIT 7U
89 #define DEFAULT_LONG_RETRY_LIMIT 4U
90 
91 #define IWL_NUM_SCAN_RATES (2)
92 
93 
94 #define IEEE80211_DATA_LEN 2304
95 #define IEEE80211_4ADDR_LEN 30
96 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
97 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
98 
99 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
100 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
101 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
102 
103 #define IWL_SUPPORTED_RATES_IE_LEN 8
104 
105 #define IWL_INVALID_RATE 0xFF
106 #define IWL_INVALID_VALUE -1
107 
110  struct {
113  };
114 };
115 
118  enum ieee80211_smps_mode smps; /* current smps mode */
119 };
120 
121 /* QoS structures */
122 struct iwl_qos_info {
125 };
126 
147 };
148 
167 struct iwl_ht_agg {
173 };
174 
185 struct iwl_tid_data {
188  struct iwl_ht_agg agg;
189 };
190 
191 /*
192  * Structure should be accessed with sta_lock held. When station addition
193  * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
194  * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
195  * held.
196  */
201 };
202 
203 /*
204  * iwl_station_priv: Driver's private station information
205  *
206  * When mac80211 creates a station it reserves some space (hw->sta_data_size)
207  * in the structure for use by driver. This structure is places in that
208  * space.
209  */
214  bool client;
215  bool asleep;
218 };
219 
226 struct iwl_vif_priv {
229 };
230 
233 
236 
241 
246 
251 
255 };
256 
257 
258 #define KELVIN_TO_CELSIUS(x) ((x)-273)
259 #define CELSIUS_TO_KELVIN(x) ((x)+273)
260 
261 
262 /******************************************************************************
263  *
264  * Functions implemented in core module which are forward declared here
265  * for use by iwl-[4-5].c
266  *
267  * NOTE: The implementation of these functions are not hardware specific
268  * which is why they are in the core module files.
269  *
270  * Naming convention --
271  * iwl_ <-- Is part of iwlwifi
272  * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
273  *
274  ****************************************************************************/
275 extern void iwl_update_chain_flags(struct iwl_priv *priv);
276 extern const u8 iwl_bcast_addr[ETH_ALEN];
277 
278 #define IWL_OPERATION_MODE_AUTO 0
279 #define IWL_OPERATION_MODE_HT_ONLY 1
280 #define IWL_OPERATION_MODE_MIXED 2
281 #define IWL_OPERATION_MODE_20MHZ 3
282 
283 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
284 
285 /* Sensitivity and chain noise calibration */
286 #define INITIALIZATION_VALUE 0xFFFF
287 #define IWL_CAL_NUM_BEACONS 16
288 #define MAXIMUM_ALLOWED_PATHLOSS 15
289 
290 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
291 
292 #define MAX_FA_OFDM 50
293 #define MIN_FA_OFDM 5
294 #define MAX_FA_CCK 50
295 #define MIN_FA_CCK 5
296 
297 #define AUTO_CORR_STEP_OFDM 1
298 
299 #define AUTO_CORR_STEP_CCK 3
300 #define AUTO_CORR_MAX_TH_CCK 160
301 
302 #define NRG_DIFF 2
303 #define NRG_STEP_CCK 2
304 #define NRG_MARGIN 8
305 #define MAX_NUMBER_CCK_NO_FA 100
306 
307 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
308 
309 #define CHAIN_A 0
310 #define CHAIN_B 1
311 #define CHAIN_C 2
312 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
313 #define ALL_BAND_FILTER 0xFF00
314 #define IN_BAND_FILTER 0xFF
315 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
316 
317 #define NRG_NUM_PREV_STAT_L 20
318 #define NUM_RX_CHAINS 3
319 
324 };
325 
327  IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
331 };
332 
333 /* Sensitivity calib data */
341 
346 
358 
362 };
363 
364 /* Chain noise (differential Rx gain) calib data */
378 };
379 
380 enum {
381  MEASUREMENT_READY = (1 << 0),
382  MEASUREMENT_ACTIVE = (1 << 1),
383 };
384 
385 /* reply_tx_statistics (for _agn devices) */
410 };
411 
412 /* reply_agg_tx_statistics (for _agn devices) */
427 };
428 
429 /*
430  * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
431  * to perform continuous uCode event logging operation if enabled
432  */
433 #define UCODE_TRACE_PERIOD (10)
434 
435 /*
436  * iwl_event_log: current uCode event log position
437  *
438  * @ucode_trace: enable/disable ucode continuous trace timer
439  * @num_wraps: how many times the event buffer wraps
440  * @next_entry: the entry just before the next one that uCode would fill
441  * @non_wraps_count: counter for no wrap detected when dump ucode events
442  * @wraps_once_count: counter for wrap once detected when dump ucode events
443  * @wraps_more_count: counter for wrap more than once detected
444  * when dump ucode events
445  */
453 };
454 
455 #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
456 
457 /* BT Antenna Coupling Threshold (dB) */
458 #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
459 
460 /* Firmware reload counter and Timestamp */
461 #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
462 #define IWL_MAX_CONTINUE_RELOAD_CNT 4
463 
464 
465 struct iwl_rf_reset {
469  unsigned long last_reset_jiffies;
470 };
471 
475 
477 };
478 
479 /* extend beacon time format bit shifting */
480 /*
481  * for _agn devices
482  * bits 31:22 - extended
483  * bits 21:0 - interval
484  */
485 #define IWLAGN_EXT_BEACON_TIME_POS 22
486 
489 
493 
494  /*
495  * We could use the vif to indicate active, but we
496  * also need it to be active during disabling when
497  * we already removed the vif for type setting.
498  */
500 
502 
504 
507 
508  /*
509  * We declare this const so it can only be
510  * changed via explicit cast within the
511  * routines that actually update the physical
512  * hardware.
513  */
514  const struct iwl_rxon_cmd active;
516 
518 
520 
522 
526 
529 
531 
533 
534  struct {
539  } ht;
540 };
541 
546 };
547 
567 
569 };
570 
571 struct iwl_lib_ops {
572  /* set hw dependent parameters */
575  struct ieee80211_channel_switch *ch_switch);
576  /* device specific configuration */
578 
579  /* temperature */
581 };
582 
586  u8 data[];
587 };
588 
589 /* Calibration disabling bit mask */
590 enum {
592 
596 
597  IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
598 };
599 
600 #define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
601  ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
602 
603 #define IWL_MAC80211_GET_DVM(_hw) \
604  ((struct iwl_priv *) ((struct iwl_op_mode *) \
605  (_hw)->priv)->op_mode_specific)
606 
607 struct iwl_priv {
608 
609  struct iwl_trans *trans;
610  struct device *dev; /* for debug prints only */
611  const struct iwl_cfg *cfg;
612  const struct iwl_fw *fw;
613  const struct iwl_lib_ops *lib;
614  unsigned long status;
615 
617  struct mutex mutex;
618 
619  unsigned long transport_queue_stop;
621 #define IWL_INVALID_MAC80211_QUEUE 0xff
624 
626 
627  /* ieee device used by generic ieee processing code */
628  struct ieee80211_hw *hw;
629 
631 
633 
635 
638 
640  struct iwl_rx_cmd_buffer *rxb,
641  struct iwl_device_cmd *cmd);
642 
644 
645  /* spectrum measurement report caching */
648 
649 #define IWL_OWNERSHIP_DRIVER 0
650 #define IWL_OWNERSHIP_TM 1
652 
653  /* ucode beacon time */
656 
657  /* track IBSS manager (last beacon) status */
659 
660  /* jiffies when last recovery from statistics was performed */
661  unsigned long rx_statistics_jiffies;
662 
663  /*counters */
665 
666  /* rf reset */
668 
669  /* firmware reload counter and timestamp */
670  unsigned long reload_jiffies;
673  bool init_ucode_run; /* Don't run init uCode again */
674 
676 
677  /* thermal calibration */
678  s32 temperature; /* Celsius */
680 
682 
683  /* Scan related variables */
684  unsigned long scan_start;
685  unsigned long scan_start_tsf;
686  void *scan_cmd;
693 
694  /* max number of station keys */
696 
698 
699  bool wowlan;
700 
701  /* EEPROM MAC addresses */
703 
705 
707 
713 
715 
716  /* Rate scaling data */
718 
720 
723 
724  /* station table variables */
727  unsigned long ucode_key_table;
730 
732 
733  /* Indication if ieee80211_ops->open has been called */
735 
737 
738  /* Last Rx'd beacon timestamp */
740 
741  struct {
749 #ifdef CONFIG_IWLWIFI_DEBUGFS
750  struct statistics_bt_activity bt_activity;
751  __le32 num_bt_kills, accum_num_bt_kills;
752 #endif
754  } statistics;
755 #ifdef CONFIG_IWLWIFI_DEBUGFS
756  struct {
757  struct statistics_general_common common;
758  struct statistics_rx_non_phy rx_non_phy;
759  struct statistics_rx_phy rx_ofdm;
760  struct statistics_rx_ht_phy rx_ofdm_ht;
761  struct statistics_rx_phy rx_cck;
762  struct statistics_tx tx;
763  struct statistics_bt_activity bt_activity;
764  } accum_stats, delta_stats, max_delta_stats;
765 #endif
766 
767  /*
768  * reporting the number of tids has AGG on. 0 means
769  * no AGGREGATION
770  */
772 
776 
777  /*
778  * chain noise reset and gain commands are the
779  * two extra calibration commands follows the standard
780  * phy calibration commands
781  */
784 
785  /* counts reply_tx error */
788 
789  /* remain-on-channel offload support */
795 
796  /* bt coex */
814  bool bt_is_sco;
815 
819 
823  void *beacon_cmd;
824 
832 
834 
835  /* TX Power settings */
838 
839 #ifdef CONFIG_IWLWIFI_DEBUGFS
840  /* debugfs */
841  struct dentry *debugfs_dir;
842  u32 dbgfs_sram_offset, dbgfs_sram_len;
843  bool disable_ht40;
844  void *wowlan_sram;
845 #endif /* CONFIG_IWLWIFI_DEBUGFS */
846 
848  /* eeprom blob for debugfs/testmode */
851 
857 
859 
861  unsigned long blink_on, blink_off;
863 
864 #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
865  struct iwl_test tst;
866  u32 tm_fixed_rate;
867 #endif
868 
869  /* WoWLAN GTK rekey data */
874 
875  /* device_pointers: pointers to ucode event tables */
876  struct {
879  } device_pointers;
880 
881  /* indicator of loaded ucode image */
883 }; /*iwl_priv */
884 
885 static inline struct iwl_rxon_context *
886 iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
887 {
888  struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
889 
890  return vif_priv->ctx;
891 }
892 
893 #define for_each_context(priv, ctx) \
894  for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
895  ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
896  if (priv->valid_contexts & BIT(ctx->ctxid))
897 
898 static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
899 {
900  return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
901 }
902 
903 static inline int iwl_is_associated(struct iwl_priv *priv,
904  enum iwl_rxon_context_id ctxid)
905 {
906  return iwl_is_associated_ctx(&priv->contexts[ctxid]);
907 }
908 
909 static inline int iwl_is_any_associated(struct iwl_priv *priv)
910 {
911  struct iwl_rxon_context *ctx;
912  for_each_context(priv, ctx)
913  if (iwl_is_associated_ctx(ctx))
914  return true;
915  return false;
916 }
917 
918 #endif /* __iwl_dev_h__ */