aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-shared.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-shared.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-shared.h349
1 files changed, 78 insertions, 271 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h
index a6441623e6b1..b515d657a0ad 100644
--- a/drivers/net/wireless/iwlwifi/iwl-shared.h
+++ b/drivers/net/wireless/iwlwifi/iwl-shared.h
@@ -65,12 +65,11 @@
65 65
66#include <linux/types.h> 66#include <linux/types.h>
67#include <linux/spinlock.h> 67#include <linux/spinlock.h>
68#include <linux/mutex.h>
69#include <linux/gfp.h> 68#include <linux/gfp.h>
70#include <linux/mm.h> /* for page_address */
71#include <net/mac80211.h> 69#include <net/mac80211.h>
72 70
73#include "iwl-commands.h" 71#include "iwl-commands.h"
72#include "iwl-fw.h"
74 73
75/** 74/**
76 * DOC: shared area - role and goal 75 * DOC: shared area - role and goal
@@ -116,7 +115,6 @@ extern struct iwl_mod_params iwlagn_mod_params;
116 * Holds the module parameters 115 * Holds the module parameters
117 * 116 *
118 * @sw_crypto: using hardware encryption, default = 0 117 * @sw_crypto: using hardware encryption, default = 0
119 * @num_of_queues: number of tx queue, HW dependent
120 * @disable_11n: disable 11n capabilities, default = 0, 118 * @disable_11n: disable 11n capabilities, default = 0,
121 * use IWL_DISABLE_HT_* constants 119 * use IWL_DISABLE_HT_* constants
122 * @amsdu_size_8K: enable 8K amsdu size, default = 1 120 * @amsdu_size_8K: enable 8K amsdu size, default = 1
@@ -138,7 +136,6 @@ extern struct iwl_mod_params iwlagn_mod_params;
138 */ 136 */
139struct iwl_mod_params { 137struct iwl_mod_params {
140 int sw_crypto; 138 int sw_crypto;
141 int num_of_queues;
142 unsigned int disable_11n; 139 unsigned int disable_11n;
143 int amsdu_size_8K; 140 int amsdu_size_8K;
144 int antenna; 141 int antenna;
@@ -163,7 +160,6 @@ struct iwl_mod_params {
163 * 160 *
164 * Holds the module parameters 161 * Holds the module parameters
165 * 162 *
166 * @max_txq_num: Max # Tx queues supported
167 * @num_ampdu_queues: num of ampdu queues 163 * @num_ampdu_queues: num of ampdu queues
168 * @tx_chains_num: Number of TX chains 164 * @tx_chains_num: Number of TX chains
169 * @rx_chains_num: Number of RX chains 165 * @rx_chains_num: Number of RX chains
@@ -177,16 +173,16 @@ struct iwl_mod_params {
177 * relevant for 1000, 6000 and up 173 * relevant for 1000, 6000 and up
178 * @wd_timeout: TX queues watchdog timeout 174 * @wd_timeout: TX queues watchdog timeout
179 * @struct iwl_sensitivity_ranges: range of sensitivity values 175 * @struct iwl_sensitivity_ranges: range of sensitivity values
176 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
180 */ 177 */
181struct iwl_hw_params { 178struct iwl_hw_params {
182 u8 max_txq_num;
183 u8 num_ampdu_queues; 179 u8 num_ampdu_queues;
184 u8 tx_chains_num; 180 u8 tx_chains_num;
185 u8 rx_chains_num; 181 u8 rx_chains_num;
186 u8 valid_tx_ant; 182 u8 valid_tx_ant;
187 u8 valid_rx_ant; 183 u8 valid_rx_ant;
188 u8 ht40_channel; 184 u8 ht40_channel;
189 bool shadow_reg_enable; 185 bool use_rts_for_aggregation;
190 u16 sku; 186 u16 sku;
191 u32 rx_page_order; 187 u32 rx_page_order;
192 u32 ct_kill_threshold; 188 u32 ct_kill_threshold;
@@ -196,62 +192,6 @@ struct iwl_hw_params {
196 const struct iwl_sensitivity_ranges *sens; 192 const struct iwl_sensitivity_ranges *sens;
197}; 193};
198 194
199/**
200 * enum iwl_ucode_type
201 *
202 * The type of ucode currently loaded on the hardware.
203 *
204 * @IWL_UCODE_NONE: No ucode loaded
205 * @IWL_UCODE_REGULAR: Normal runtime ucode
206 * @IWL_UCODE_INIT: Initial ucode
207 * @IWL_UCODE_WOWLAN: Wake on Wireless enabled ucode
208 */
209enum iwl_ucode_type {
210 IWL_UCODE_NONE,
211 IWL_UCODE_REGULAR,
212 IWL_UCODE_INIT,
213 IWL_UCODE_WOWLAN,
214};
215
216/**
217 * struct iwl_notification_wait - notification wait entry
218 * @list: list head for global list
219 * @fn: function called with the notification
220 * @cmd: command ID
221 *
222 * This structure is not used directly, to wait for a
223 * notification declare it on the stack, and call
224 * iwlagn_init_notification_wait() with appropriate
225 * parameters. Then do whatever will cause the ucode
226 * to notify the driver, and to wait for that then
227 * call iwlagn_wait_notification().
228 *
229 * Each notification is one-shot. If at some point we
230 * need to support multi-shot notifications (which
231 * can't be allocated on the stack) we need to modify
232 * the code for them.
233 */
234struct iwl_notification_wait {
235 struct list_head list;
236
237 void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt,
238 void *data);
239 void *fn_data;
240
241 u8 cmd;
242 bool triggered, aborted;
243};
244
245/**
246 * enum iwl_pa_type - Power Amplifier type
247 * @IWL_PA_SYSTEM: based on uCode configuration
248 * @IWL_PA_INTERNAL: use Internal only
249 */
250enum iwl_pa_type {
251 IWL_PA_SYSTEM = 0,
252 IWL_PA_INTERNAL = 1,
253};
254
255/* 195/*
256 * LED mode 196 * LED mode
257 * IWL_LED_DEFAULT: use device default 197 * IWL_LED_DEFAULT: use device default
@@ -268,6 +208,73 @@ enum iwl_led_mode {
268 IWL_LED_DISABLE, 208 IWL_LED_DISABLE,
269}; 209};
270 210
211/*
212 * @max_ll_items: max number of OTP blocks
213 * @shadow_ram_support: shadow support for OTP memory
214 * @led_compensation: compensate on the led on/off time per HW according
215 * to the deviation to achieve the desired led frequency.
216 * The detail algorithm is described in iwl-led.c
217 * @chain_noise_num_beacons: number of beacons used to compute chain noise
218 * @adv_thermal_throttle: support advance thermal throttle
219 * @support_ct_kill_exit: support ct kill exit condition
220 * @support_wimax_coexist: support wimax/wifi co-exist
221 * @plcp_delta_threshold: plcp error rate threshold used to trigger
222 * radio tuning when there is a high receiving plcp error rate
223 * @chain_noise_scale: default chain noise scale used for gain computation
224 * @wd_timeout: TX queues watchdog timeout
225 * @max_event_log_size: size of event log buffer size for ucode event logging
226 * @shadow_reg_enable: HW shadhow register bit
227 * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
228 * @no_idle_support: do not support idle mode
229 * wd_disable: disable watchdog timer
230 */
231struct iwl_base_params {
232 int eeprom_size;
233 int num_of_queues; /* def: HW dependent */
234 int num_of_ampdu_queues;/* def: HW dependent */
235 /* for iwl_apm_init() */
236 u32 pll_cfg_val;
237
238 const u16 max_ll_items;
239 const bool shadow_ram_support;
240 u16 led_compensation;
241 bool adv_thermal_throttle;
242 bool support_ct_kill_exit;
243 const bool support_wimax_coexist;
244 u8 plcp_delta_threshold;
245 s32 chain_noise_scale;
246 unsigned int wd_timeout;
247 u32 max_event_log_size;
248 const bool shadow_reg_enable;
249 const bool hd_v2;
250 const bool no_idle_support;
251 const bool wd_disable;
252};
253
254/*
255 * @advanced_bt_coexist: support advanced bt coexist
256 * @bt_init_traffic_load: specify initial bt traffic load
257 * @bt_prio_boost: default bt priority boost value
258 * @agg_time_limit: maximum number of uSec in aggregation
259 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
260 */
261struct iwl_bt_params {
262 bool advanced_bt_coexist;
263 u8 bt_init_traffic_load;
264 u8 bt_prio_boost;
265 u16 agg_time_limit;
266 bool bt_sco_disable;
267 bool bt_session_2;
268};
269/*
270 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
271 */
272struct iwl_ht_params {
273 const bool ht_greenfield_support; /* if used set to true */
274 bool use_rts_for_aggregation;
275 enum ieee80211_smps_mode smps_mode;
276};
277
271/** 278/**
272 * struct iwl_cfg 279 * struct iwl_cfg
273 * @name: Offical name of the device 280 * @name: Offical name of the device
@@ -282,7 +289,6 @@ enum iwl_led_mode {
282 * @max_data_size: The maximal length of the fw data section 289 * @max_data_size: The maximal length of the fw data section
283 * @valid_tx_ant: valid transmit antenna 290 * @valid_tx_ant: valid transmit antenna
284 * @valid_rx_ant: valid receive antenna 291 * @valid_rx_ant: valid receive antenna
285 * @sku: sku information from EEPROM
286 * @eeprom_ver: EEPROM version 292 * @eeprom_ver: EEPROM version
287 * @eeprom_calib_ver: EEPROM calibration version 293 * @eeprom_calib_ver: EEPROM calibration version
288 * @lib: pointer to the lib ops 294 * @lib: pointer to the lib ops
@@ -290,7 +296,6 @@ enum iwl_led_mode {
290 * @base_params: pointer to basic parameters 296 * @base_params: pointer to basic parameters
291 * @ht_params: point to ht patameters 297 * @ht_params: point to ht patameters
292 * @bt_params: pointer to bt parameters 298 * @bt_params: pointer to bt parameters
293 * @pa_type: used by 6000 series only to identify the type of Power Amplifier
294 * @need_temp_offset_calib: need to perform temperature offset calibration 299 * @need_temp_offset_calib: need to perform temperature offset calibration
295 * @no_xtal_calib: some devices do not need crystal calibration data, 300 * @no_xtal_calib: some devices do not need crystal calibration data,
296 * don't send it to those 301 * don't send it to those
@@ -321,17 +326,15 @@ struct iwl_cfg {
321 const u32 max_inst_size; 326 const u32 max_inst_size;
322 u8 valid_tx_ant; 327 u8 valid_tx_ant;
323 u8 valid_rx_ant; 328 u8 valid_rx_ant;
324 u16 sku;
325 u16 eeprom_ver; 329 u16 eeprom_ver;
326 u16 eeprom_calib_ver; 330 u16 eeprom_calib_ver;
327 const struct iwl_lib_ops *lib; 331 const struct iwl_lib_ops *lib;
328 void (*additional_nic_config)(struct iwl_priv *priv); 332 void (*additional_nic_config)(struct iwl_priv *priv);
329 /* params not likely to change within a device family */ 333 /* params not likely to change within a device family */
330 struct iwl_base_params *base_params; 334 const struct iwl_base_params *base_params;
331 /* params likely to change within a device family */ 335 /* params likely to change within a device family */
332 struct iwl_ht_params *ht_params; 336 const struct iwl_ht_params *ht_params;
333 struct iwl_bt_params *bt_params; 337 const struct iwl_bt_params *bt_params;
334 enum iwl_pa_type pa_type; /* if used set to IWL_PA_SYSTEM */
335 const bool need_temp_offset_calib; /* if used set to true */ 338 const bool need_temp_offset_calib; /* if used set to true */
336 const bool no_xtal_calib; 339 const bool no_xtal_calib;
337 u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; 340 u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
@@ -346,10 +349,6 @@ struct iwl_cfg {
346/** 349/**
347 * struct iwl_shared - shared fields for all the layers of the driver 350 * struct iwl_shared - shared fields for all the layers of the driver
348 * 351 *
349 * @dbg_level_dev: dbg level set per device. Prevails on
350 * iwlagn_mod_params.debug_level if set (!= 0)
351 * @ucode_owner: IWL_OWNERSHIP_*
352 * @cmd_queue: command queue number
353 * @status: STATUS_* 352 * @status: STATUS_*
354 * @wowlan: are we running wowlan uCode 353 * @wowlan: are we running wowlan uCode
355 * @valid_contexts: microcode/device supports multiple contexts 354 * @valid_contexts: microcode/device supports multiple contexts
@@ -360,41 +359,19 @@ struct iwl_cfg {
360 * @nic: pointer to the nic data 359 * @nic: pointer to the nic data
361 * @hw_params: see struct iwl_hw_params 360 * @hw_params: see struct iwl_hw_params
362 * @lock: protect general shared data 361 * @lock: protect general shared data
363 * @sta_lock: protects the station table.
364 * If lock and sta_lock are needed, lock must be acquired first.
365 * @mutex:
366 * @wait_command_queue: the wait_queue for SYNC host command nad uCode load
367 * @eeprom: pointer to the eeprom/OTP image 362 * @eeprom: pointer to the eeprom/OTP image
368 * @ucode_type: indicator of loaded ucode image 363 * @ucode_type: indicator of loaded ucode image
369 * @notif_waits: things waiting for notification
370 * @notif_wait_lock: lock protecting notification
371 * @notif_waitq: head of notification wait queue
372 * @device_pointers: pointers to ucode event tables 364 * @device_pointers: pointers to ucode event tables
373 */ 365 */
374struct iwl_shared { 366struct iwl_shared {
375#ifdef CONFIG_IWLWIFI_DEBUG
376 u32 dbg_level_dev;
377#endif /* CONFIG_IWLWIFI_DEBUG */
378
379#define IWL_OWNERSHIP_DRIVER 0
380#define IWL_OWNERSHIP_TM 1
381 u8 ucode_owner;
382 u8 cmd_queue;
383 unsigned long status; 367 unsigned long status;
384 bool wowlan;
385 u8 valid_contexts; 368 u8 valid_contexts;
386 369
387 struct iwl_cfg *cfg; 370 const struct iwl_cfg *cfg;
388 struct iwl_priv *priv;
389 struct iwl_trans *trans; 371 struct iwl_trans *trans;
390 struct iwl_nic *nic; 372 void *drv;
391 struct iwl_hw_params hw_params; 373 struct iwl_hw_params hw_params;
392 374 const struct iwl_fw *fw;
393 spinlock_t lock;
394 spinlock_t sta_lock;
395 struct mutex mutex;
396
397 wait_queue_head_t wait_command_queue;
398 375
399 /* eeprom -- this is in the card's little endian byte order */ 376 /* eeprom -- this is in the card's little endian byte order */
400 u8 *eeprom; 377 u8 *eeprom;
@@ -402,11 +379,6 @@ struct iwl_shared {
402 /* ucode related variables */ 379 /* ucode related variables */
403 enum iwl_ucode_type ucode_type; 380 enum iwl_ucode_type ucode_type;
404 381
405 /* notification wait support */
406 struct list_head notif_waits;
407 spinlock_t notif_wait_lock;
408 wait_queue_head_t notif_waitq;
409
410 struct { 382 struct {
411 u32 error_event_table; 383 u32 error_event_table;
412 u32 log_event_table; 384 u32 log_event_table;
@@ -415,111 +387,13 @@ struct iwl_shared {
415}; 387};
416 388
417/*Whatever _m is (iwl_trans, iwl_priv, these macros will work */ 389/*Whatever _m is (iwl_trans, iwl_priv, these macros will work */
418#define priv(_m) ((_m)->shrd->priv)
419#define cfg(_m) ((_m)->shrd->cfg) 390#define cfg(_m) ((_m)->shrd->cfg)
420#define nic(_m) ((_m)->shrd->nic)
421#define trans(_m) ((_m)->shrd->trans) 391#define trans(_m) ((_m)->shrd->trans)
422#define hw_params(_m) ((_m)->shrd->hw_params) 392#define hw_params(_m) ((_m)->shrd->hw_params)
423 393
424#ifdef CONFIG_IWLWIFI_DEBUG 394static inline bool iwl_have_debug_level(u32 level)
425/*
426 * iwl_get_debug_level: Return active debug level for device
427 *
428 * Using sysfs it is possible to set per device debug level. This debug
429 * level will be used if set, otherwise the global debug level which can be
430 * set via module parameter is used.
431 */
432static inline u32 iwl_get_debug_level(struct iwl_shared *shrd)
433{
434 if (shrd->dbg_level_dev)
435 return shrd->dbg_level_dev;
436 else
437 return iwlagn_mod_params.debug_level;
438}
439#else
440static inline u32 iwl_get_debug_level(struct iwl_shared *shrd)
441{
442 return iwlagn_mod_params.debug_level;
443}
444#endif
445
446static inline void iwl_free_pages(struct iwl_shared *shrd, unsigned long page)
447{
448 free_pages(page, shrd->hw_params.rx_page_order);
449}
450
451/**
452 * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
453 * @index -- current index
454 * @n_bd -- total number of entries in queue (must be power of 2)
455 */
456static inline int iwl_queue_inc_wrap(int index, int n_bd)
457{
458 return ++index & (n_bd - 1);
459}
460
461/**
462 * iwl_queue_dec_wrap - decrement queue index, wrap back to end
463 * @index -- current index
464 * @n_bd -- total number of entries in queue (must be power of 2)
465 */
466static inline int iwl_queue_dec_wrap(int index, int n_bd)
467{
468 return --index & (n_bd - 1);
469}
470
471struct iwl_rx_mem_buffer {
472 dma_addr_t page_dma;
473 struct page *page;
474 struct list_head list;
475};
476
477#define rxb_addr(r) page_address(r->page)
478
479/*
480 * mac80211 queues, ACs, hardware queues, FIFOs.
481 *
482 * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
483 *
484 * Mac80211 uses the following numbers, which we get as from it
485 * by way of skb_get_queue_mapping(skb):
486 *
487 * VO 0
488 * VI 1
489 * BE 2
490 * BK 3
491 *
492 *
493 * Regular (not A-MPDU) frames are put into hardware queues corresponding
494 * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
495 * own queue per aggregation session (RA/TID combination), such queues are
496 * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
497 * order to map frames to the right queue, we also need an AC->hw queue
498 * mapping. This is implemented here.
499 *
500 * Due to the way hw queues are set up (by the hw specific modules like
501 * iwl-4965.c, iwl-5000.c etc.), the AC->hw queue mapping is the identity
502 * mapping.
503 */
504
505static const u8 tid_to_ac[] = {
506 IEEE80211_AC_BE,
507 IEEE80211_AC_BK,
508 IEEE80211_AC_BK,
509 IEEE80211_AC_BE,
510 IEEE80211_AC_VI,
511 IEEE80211_AC_VI,
512 IEEE80211_AC_VO,
513 IEEE80211_AC_VO
514};
515
516static inline int get_ac_from_tid(u16 tid)
517{ 395{
518 if (likely(tid < ARRAY_SIZE(tid_to_ac))) 396 return iwlagn_mod_params.debug_level & level;
519 return tid_to_ac[tid];
520
521 /* no support for TIDs 8-15 yet */
522 return -EINVAL;
523} 397}
524 398
525enum iwl_rxon_context_id { 399enum iwl_rxon_context_id {
@@ -530,34 +404,9 @@ enum iwl_rxon_context_id {
530}; 404};
531 405
532int iwlagn_hw_valid_rtc_data_addr(u32 addr); 406int iwlagn_hw_valid_rtc_data_addr(u32 addr);
533void iwl_nic_config(struct iwl_priv *priv);
534const char *get_cmd_string(u8 cmd); 407const char *get_cmd_string(u8 cmd);
535bool iwl_check_for_ct_kill(struct iwl_priv *priv);
536
537
538/* notification wait support */
539void iwl_abort_notification_waits(struct iwl_shared *shrd);
540void __acquires(wait_entry)
541iwl_init_notification_wait(struct iwl_shared *shrd,
542 struct iwl_notification_wait *wait_entry,
543 u8 cmd,
544 void (*fn)(struct iwl_trans *trans,
545 struct iwl_rx_packet *pkt,
546 void *data),
547 void *fn_data);
548int __must_check __releases(wait_entry)
549iwl_wait_notification(struct iwl_shared *shrd,
550 struct iwl_notification_wait *wait_entry,
551 unsigned long timeout);
552void __releases(wait_entry)
553iwl_remove_notification(struct iwl_shared *shrd,
554 struct iwl_notification_wait *wait_entry);
555 408
556#define IWL_CMD(x) case x: return #x 409#define IWL_CMD(x) case x: return #x
557#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
558
559#define IWL_TRAFFIC_ENTRIES (256)
560#define IWL_TRAFFIC_ENTRY_SIZE (64)
561 410
562/***************************************************** 411/*****************************************************
563* DRIVER STATUS FUNCTIONS 412* DRIVER STATUS FUNCTIONS
@@ -583,46 +432,4 @@ iwl_remove_notification(struct iwl_shared *shrd,
583#define STATUS_CHANNEL_SWITCH_PENDING 19 432#define STATUS_CHANNEL_SWITCH_PENDING 19
584#define STATUS_SCAN_COMPLETE 20 433#define STATUS_SCAN_COMPLETE 20
585 434
586static inline int iwl_is_ready(struct iwl_shared *shrd)
587{
588 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
589 * set but EXIT_PENDING is not */
590 return test_bit(STATUS_READY, &shrd->status) &&
591 test_bit(STATUS_GEO_CONFIGURED, &shrd->status) &&
592 !test_bit(STATUS_EXIT_PENDING, &shrd->status);
593}
594
595static inline int iwl_is_alive(struct iwl_shared *shrd)
596{
597 return test_bit(STATUS_ALIVE, &shrd->status);
598}
599
600static inline int iwl_is_init(struct iwl_shared *shrd)
601{
602 return test_bit(STATUS_INIT, &shrd->status);
603}
604
605static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd)
606{
607 return test_bit(STATUS_RF_KILL_HW, &shrd->status);
608}
609
610static inline int iwl_is_rfkill(struct iwl_shared *shrd)
611{
612 return iwl_is_rfkill_hw(shrd);
613}
614
615static inline int iwl_is_ctkill(struct iwl_shared *shrd)
616{
617 return test_bit(STATUS_CT_KILL, &shrd->status);
618}
619
620static inline int iwl_is_ready_rf(struct iwl_shared *shrd)
621{
622 if (iwl_is_rfkill(shrd))
623 return 0;
624
625 return iwl_is_ready(shrd);
626}
627
628#endif /* #__iwl_shared_h__ */ 435#endif /* #__iwl_shared_h__ */