Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[linux-2.6] / drivers / net / wireless / iwlwifi / iwlwifi.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
4  *
5  * Portions of this file are derived from the ipw3945 project, as well
6  * as portions of the ieee80211 subsystem header files.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of version 2 of the GNU General Public License as
10  * published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20  *
21  * The full GNU General Public License is included in this distribution in the
22  * file called LICENSE.
23  *
24  * Contact Information:
25  * James P. Ketrenos <ipw2100-admin@linux.intel.com>
26  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27  *
28  *****************************************************************************/
29
30 #ifndef __iwlwifi_h__
31 #define __iwlwifi_h__
32
33 #include <linux/pci.h> /* for struct pci_device_id */
34 #include <linux/kernel.h>
35 #include <net/ieee80211_radiotap.h>
36
37 struct iwl_priv;
38
39 /* Hardware specific file defines the PCI IDs table for that hardware module */
40 extern struct pci_device_id iwl_hw_card_ids[];
41
42 #if IWL == 3945
43
44 #define DRV_NAME        "iwl3945"
45 #include "iwl-hw.h"
46 #include "iwl-3945-hw.h"
47
48 #elif IWL == 4965
49
50 #define DRV_NAME        "iwl4965"
51 #include "iwl-hw.h"
52 #include "iwl-4965-hw.h"
53
54 #endif
55
56 #include "iwl-prph.h"
57
58 /*
59  * Driver implementation data structures, constants, inline
60  * functions
61  *
62  * NOTE:  DO NOT PUT HARDWARE/UCODE SPECIFIC DECLRATIONS HERE
63  *
64  * Hardware specific declrations go into iwl-*hw.h
65  *
66  */
67
68 #include "iwl-debug.h"
69
70 /* Default noise level to report when noise measurement is not available.
71  *   This may be because we're:
72  *   1)  Not associated (4965, no beacon statistics being sent to driver)
73  *   2)  Scanning (noise measurement does not apply to associated channel)
74  *   3)  Receiving CCK (3945 delivers noise info only for OFDM frames)
75  * Use default noise value of -127 ... this is below the range of measurable
76  *   Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
77  *   Also, -127 works better than 0 when averaging frames with/without
78  *   noise info (e.g. averaging might be done in app); measured dBm values are
79  *   always negative ... using a negative value as the default keeps all
80  *   averages within an s8's (used in some apps) range of negative values. */
81 #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
82
83 /* Module parameters accessible from iwl-*.c */
84 extern int iwl_param_disable_hw_scan;
85 extern int iwl_param_debug;
86 extern int iwl_param_mode;
87 extern int iwl_param_disable;
88 extern int iwl_param_antenna;
89 extern int iwl_param_hwcrypto;
90 extern int iwl_param_qos_enable;
91 extern int iwl_param_queues_num;
92
93 enum iwl_antenna {
94         IWL_ANTENNA_DIVERSITY,
95         IWL_ANTENNA_MAIN,
96         IWL_ANTENNA_AUX
97 };
98
99 /*
100  * RTS threshold here is total size [2347] minus 4 FCS bytes
101  * Per spec:
102  *   a value of 0 means RTS on all data/management packets
103  *   a value > max MSDU size means no RTS
104  * else RTS for data/management frames where MPDU is larger
105  *   than RTS value.
106  */
107 #define DEFAULT_RTS_THRESHOLD     2347U
108 #define MIN_RTS_THRESHOLD         0U
109 #define MAX_RTS_THRESHOLD         2347U
110 #define MAX_MSDU_SIZE             2304U
111 #define MAX_MPDU_SIZE             2346U
112 #define DEFAULT_BEACON_INTERVAL   100U
113 #define DEFAULT_SHORT_RETRY_LIMIT 7U
114 #define DEFAULT_LONG_RETRY_LIMIT  4U
115
116 struct iwl_rx_mem_buffer {
117         dma_addr_t dma_addr;
118         struct sk_buff *skb;
119         struct list_head list;
120 };
121
122 struct iwl_rt_rx_hdr {
123         struct ieee80211_radiotap_header rt_hdr;
124         __le64 rt_tsf;          /* TSF */
125         u8 rt_flags;            /* radiotap packet flags */
126         u8 rt_rate;             /* rate in 500kb/s */
127         __le16 rt_channelMHz;   /* channel in MHz */
128         __le16 rt_chbitmask;    /* channel bitfield */
129         s8 rt_dbmsignal;        /* signal in dBm, kluged to signed */
130         s8 rt_dbmnoise;
131         u8 rt_antenna;          /* antenna number */
132         u8 payload[0];          /* payload... */
133 } __attribute__ ((packed));
134
135 struct iwl_rt_tx_hdr {
136         struct ieee80211_radiotap_header rt_hdr;
137         u8 rt_rate;             /* rate in 500kb/s */
138         __le16 rt_channel;      /* channel in mHz */
139         __le16 rt_chbitmask;    /* channel bitfield */
140         s8 rt_dbmsignal;        /* signal in dBm, kluged to signed */
141         u8 rt_antenna;          /* antenna number */
142         u8 payload[0];          /* payload... */
143 } __attribute__ ((packed));
144
145 /*
146  * Generic queue structure
147  *
148  * Contains common data for Rx and Tx queues
149  */
150 struct iwl_queue {
151         int n_bd;              /* number of BDs in this queue */
152         int first_empty;       /* 1-st empty entry (index) host_w*/
153         int last_used;         /* last used entry (index) host_r*/
154         dma_addr_t dma_addr;   /* physical addr for BD's */
155         int n_window;          /* safe queue window */
156         u32 id;
157         int low_mark;          /* low watermark, resume queue if free
158                                 * space more than this */
159         int high_mark;         /* high watermark, stop queue if free
160                                 * space less than this */
161 } __attribute__ ((packed));
162
163 #define MAX_NUM_OF_TBS          (20)
164
165 struct iwl_tx_info {
166         struct ieee80211_tx_status status;
167         struct sk_buff *skb[MAX_NUM_OF_TBS];
168 };
169
170 /**
171  * struct iwl_tx_queue - Tx Queue for DMA
172  * @need_update: need to update read/write index
173  * @shed_retry: queue is HT AGG enabled
174  *
175  * Queue consists of circular buffer of BD's and required locking structures.
176  */
177 struct iwl_tx_queue {
178         struct iwl_queue q;
179         struct iwl_tfd_frame *bd;
180         struct iwl_cmd *cmd;
181         dma_addr_t dma_addr_cmd;
182         struct iwl_tx_info *txb;
183         int need_update;
184         int sched_retry;
185         int active;
186 };
187
188 #include "iwl-channel.h"
189
190 #if IWL == 3945
191 #include "iwl-3945-rs.h"
192 #else
193 #include "iwl-4965-rs.h"
194 #endif
195
196 #define IWL_TX_FIFO_AC0 0
197 #define IWL_TX_FIFO_AC1 1
198 #define IWL_TX_FIFO_AC2 2
199 #define IWL_TX_FIFO_AC3 3
200 #define IWL_TX_FIFO_HCCA_1      5
201 #define IWL_TX_FIFO_HCCA_2      6
202 #define IWL_TX_FIFO_NONE        7
203
204 /* Minimum number of queues. MAX_NUM is defined in hw specific files */
205 #define IWL_MIN_NUM_QUEUES      4
206
207 /* Power management (not Tx power) structures */
208
209 struct iwl_power_vec_entry {
210         struct iwl_powertable_cmd cmd;
211         u8 no_dtim;
212 };
213 #define IWL_POWER_RANGE_0  (0)
214 #define IWL_POWER_RANGE_1  (1)
215
216 #define IWL_POWER_MODE_CAM      0x00    /* Continuously Aware Mode, always on */
217 #define IWL_POWER_INDEX_3       0x03
218 #define IWL_POWER_INDEX_5       0x05
219 #define IWL_POWER_AC            0x06
220 #define IWL_POWER_BATTERY       0x07
221 #define IWL_POWER_LIMIT         0x07
222 #define IWL_POWER_MASK          0x0F
223 #define IWL_POWER_ENABLED       0x10
224 #define IWL_POWER_LEVEL(x)      ((x) & IWL_POWER_MASK)
225
226 struct iwl_power_mgr {
227         spinlock_t lock;
228         struct iwl_power_vec_entry pwr_range_0[IWL_POWER_AC];
229         struct iwl_power_vec_entry pwr_range_1[IWL_POWER_AC];
230         u8 active_index;
231         u32 dtim_val;
232 };
233
234 #define IEEE80211_DATA_LEN              2304
235 #define IEEE80211_4ADDR_LEN             30
236 #define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
237 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
238
239 struct iwl_frame {
240         union {
241                 struct ieee80211_hdr frame;
242                 struct iwl_tx_beacon_cmd beacon;
243                 u8 raw[IEEE80211_FRAME_LEN];
244                 u8 cmd[360];
245         } u;
246         struct list_head list;
247 };
248
249 #define SEQ_TO_QUEUE(x)  ((x >> 8) & 0xbf)
250 #define QUEUE_TO_SEQ(x)  ((x & 0xbf) << 8)
251 #define SEQ_TO_INDEX(x) (x & 0xff)
252 #define INDEX_TO_SEQ(x) (x & 0xff)
253 #define SEQ_HUGE_FRAME  (0x4000)
254 #define SEQ_RX_FRAME    __constant_cpu_to_le16(0x8000)
255 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
256 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
257 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
258
259 enum {
260         /* CMD_SIZE_NORMAL = 0, */
261         CMD_SIZE_HUGE = (1 << 0),
262         /* CMD_SYNC = 0, */
263         CMD_ASYNC = (1 << 1),
264         /* CMD_NO_SKB = 0, */
265         CMD_WANT_SKB = (1 << 2),
266 };
267
268 struct iwl_cmd;
269 struct iwl_priv;
270
271 struct iwl_cmd_meta {
272         struct iwl_cmd_meta *source;
273         union {
274                 struct sk_buff *skb;
275                 int (*callback)(struct iwl_priv *priv,
276                                 struct iwl_cmd *cmd, struct sk_buff *skb);
277         } __attribute__ ((packed)) u;
278
279         /* The CMD_SIZE_HUGE flag bit indicates that the command
280          * structure is stored at the end of the shared queue memory. */
281         u32 flags;
282
283 } __attribute__ ((packed));
284
285 struct iwl_cmd {
286         struct iwl_cmd_meta meta;
287         struct iwl_cmd_header hdr;
288         union {
289                 struct iwl_addsta_cmd addsta;
290                 struct iwl_led_cmd led;
291                 u32 flags;
292                 u8 val8;
293                 u16 val16;
294                 u32 val32;
295                 struct iwl_bt_cmd bt;
296                 struct iwl_rxon_time_cmd rxon_time;
297                 struct iwl_powertable_cmd powertable;
298                 struct iwl_qosparam_cmd qosparam;
299                 struct iwl_tx_cmd tx;
300                 struct iwl_tx_beacon_cmd tx_beacon;
301                 struct iwl_rxon_assoc_cmd rxon_assoc;
302                 u8 *indirect;
303                 u8 payload[360];
304         } __attribute__ ((packed)) cmd;
305 } __attribute__ ((packed));
306
307 struct iwl_host_cmd {
308         u8 id;
309         u16 len;
310         struct iwl_cmd_meta meta;
311         const void *data;
312 };
313
314 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
315                               sizeof(struct iwl_cmd_meta))
316
317 /*
318  * RX related structures and functions
319  */
320 #define RX_FREE_BUFFERS 64
321 #define RX_LOW_WATERMARK 8
322
323 #define SUP_RATE_11A_MAX_NUM_CHANNELS  8
324 #define SUP_RATE_11B_MAX_NUM_CHANNELS  4
325 #define SUP_RATE_11G_MAX_NUM_CHANNELS  12
326
327 /**
328  * struct iwl_rx_queue - Rx queue
329  * @processed: Internal index to last handled Rx packet
330  * @read: Shared index to newest available Rx buffer
331  * @write: Shared index to oldest written Rx packet
332  * @free_count: Number of pre-allocated buffers in rx_free
333  * @rx_free: list of free SKBs for use
334  * @rx_used: List of Rx buffers with no SKB
335  * @need_update: flag to indicate we need to update read/write index
336  *
337  * NOTE:  rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
338  */
339 struct iwl_rx_queue {
340         __le32 *bd;
341         dma_addr_t dma_addr;
342         struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
343         struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
344         u32 processed;
345         u32 read;
346         u32 write;
347         u32 free_count;
348         struct list_head rx_free;
349         struct list_head rx_used;
350         int need_update;
351         spinlock_t lock;
352 };
353
354 #define IWL_SUPPORTED_RATES_IE_LEN         8
355
356 #define SCAN_INTERVAL 100
357
358 #define MAX_A_CHANNELS  252
359 #define MIN_A_CHANNELS  7
360
361 #define MAX_B_CHANNELS  14
362 #define MIN_B_CHANNELS  1
363
364 #define STATUS_HCMD_ACTIVE      0       /* host command in progress */
365 #define STATUS_INT_ENABLED      1
366 #define STATUS_RF_KILL_HW       2
367 #define STATUS_RF_KILL_SW       3
368 #define STATUS_INIT             4
369 #define STATUS_ALIVE            5
370 #define STATUS_READY            6
371 #define STATUS_TEMPERATURE      7
372 #define STATUS_GEO_CONFIGURED   8
373 #define STATUS_EXIT_PENDING     9
374 #define STATUS_IN_SUSPEND       10
375 #define STATUS_STATISTICS       11
376 #define STATUS_SCANNING         12
377 #define STATUS_SCAN_ABORTING    13
378 #define STATUS_SCAN_HW          14
379 #define STATUS_POWER_PMI        15
380 #define STATUS_FW_ERROR         16
381
382 #define MAX_TID_COUNT        9
383
384 #define IWL_INVALID_RATE     0xFF
385 #define IWL_INVALID_VALUE    -1
386
387 #if IWL == 4965
388 #ifdef CONFIG_IWLWIFI_HT
389 #ifdef CONFIG_IWLWIFI_HT_AGG
390 struct iwl_ht_agg {
391         u16 txq_id;
392         u16 frame_count;
393         u16 wait_for_ba;
394         u16 start_idx;
395         u32 bitmap0;
396         u32 bitmap1;
397         u32 rate_n_flags;
398 };
399 #endif /* CONFIG_IWLWIFI_HT_AGG */
400 #endif /* CONFIG_IWLWIFI_HT */
401 #endif
402
403 struct iwl_tid_data {
404         u16 seq_number;
405 #if IWL == 4965
406 #ifdef CONFIG_IWLWIFI_HT
407 #ifdef CONFIG_IWLWIFI_HT_AGG
408         struct iwl_ht_agg agg;
409 #endif  /* CONFIG_IWLWIFI_HT_AGG */
410 #endif /* CONFIG_IWLWIFI_HT */
411 #endif
412 };
413
414 struct iwl_hw_key {
415         enum ieee80211_key_alg alg;
416         int keylen;
417         u8 key[32];
418 };
419
420 union iwl_ht_rate_supp {
421         u16 rates;
422         struct {
423                 u8 siso_rate;
424                 u8 mimo_rate;
425         };
426 };
427
428 #ifdef CONFIG_IWLWIFI_HT
429 #define CFG_HT_RX_AMPDU_FACTOR_DEF  (0x3)
430 #define HT_IE_MAX_AMSDU_SIZE_4K     (0)
431 #define CFG_HT_MPDU_DENSITY_2USEC   (0x5)
432 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
433
434 struct sta_ht_info {
435         u8 is_ht;
436         u16 rx_mimo_ps_mode;
437         u16 tx_mimo_ps_mode;
438         u16 control_channel;
439         u8 max_amsdu_size;
440         u8 ampdu_factor;
441         u8 mpdu_density;
442         u8 operating_mode;
443         u8 supported_chan_width;
444         u8 extension_chan_offset;
445         u8 is_green_field;
446         u8 sgf;
447         u8 supp_rates[16];
448         u8 tx_chan_width;
449         u8 chan_width_cap;
450 };
451 #endif                          /*CONFIG_IWLWIFI_HT */
452
453 #ifdef CONFIG_IWLWIFI_QOS
454
455 union iwl_qos_capabity {
456         struct {
457                 u8 edca_count:4;        /* bit 0-3 */
458                 u8 q_ack:1;             /* bit 4 */
459                 u8 queue_request:1;     /* bit 5 */
460                 u8 txop_request:1;      /* bit 6 */
461                 u8 reserved:1;          /* bit 7 */
462         } q_AP;
463         struct {
464                 u8 acvo_APSD:1;         /* bit 0 */
465                 u8 acvi_APSD:1;         /* bit 1 */
466                 u8 ac_bk_APSD:1;        /* bit 2 */
467                 u8 ac_be_APSD:1;        /* bit 3 */
468                 u8 q_ack:1;             /* bit 4 */
469                 u8 max_len:2;           /* bit 5-6 */
470                 u8 more_data_ack:1;     /* bit 7 */
471         } q_STA;
472         u8 val;
473 };
474
475 /* QoS sturctures */
476 struct iwl_qos_info {
477         int qos_enable;
478         int qos_active;
479         union iwl_qos_capabity qos_cap;
480         struct iwl_qosparam_cmd def_qos_parm;
481 };
482 #endif /*CONFIG_IWLWIFI_QOS */
483
484 #define STA_PS_STATUS_WAKE             0
485 #define STA_PS_STATUS_SLEEP            1
486
487 struct iwl_station_entry {
488         struct iwl_addsta_cmd sta;
489         struct iwl_tid_data tid[MAX_TID_COUNT];
490 #if IWL == 3945
491         union {
492                 struct {
493                         u8 rate;
494                         u8 flags;
495                 } s;
496                 u16 rate_n_flags;
497         } current_rate;
498 #endif
499         u8 used;
500         u8 ps_status;
501         struct iwl_hw_key keyinfo;
502 };
503
504 /* one for each uCode image (inst/data, boot/init/runtime) */
505 struct fw_image_desc {
506         void *v_addr;           /* access by driver */
507         dma_addr_t p_addr;      /* access by card's busmaster DMA */
508         u32 len;                /* bytes */
509 };
510
511 /* uCode file layout */
512 struct iwl_ucode {
513         __le32 ver;             /* major/minor/subminor */
514         __le32 inst_size;       /* bytes of runtime instructions */
515         __le32 data_size;       /* bytes of runtime data */
516         __le32 init_size;       /* bytes of initialization instructions */
517         __le32 init_data_size;  /* bytes of initialization data */
518         __le32 boot_size;       /* bytes of bootstrap instructions */
519         u8 data[0];             /* data in same order as "size" elements */
520 };
521
522 #define IWL_IBSS_MAC_HASH_SIZE 32
523
524 struct iwl_ibss_seq {
525         u8 mac[ETH_ALEN];
526         u16 seq_num;
527         u16 frag_num;
528         unsigned long packet_time;
529         struct list_head list;
530 };
531
532 struct iwl_driver_hw_info {
533         u16 max_txq_num;
534         u16 ac_queue_count;
535         u32 rx_buffer_size;
536         u16 tx_cmd_len;
537         u16 max_rxq_size;
538         u16 max_rxq_log;
539         u32 cck_flag;
540         u8  max_stations;
541         u8  bcast_sta_id;
542         void *shared_virt;
543         dma_addr_t shared_phys;
544 };
545
546
547 #define STA_FLG_RTS_MIMO_PROT_MSK       __constant_cpu_to_le32(1 << 17)
548 #define STA_FLG_AGG_MPDU_8US_MSK        __constant_cpu_to_le32(1 << 18)
549 #define STA_FLG_MAX_AGG_SIZE_POS        (19)
550 #define STA_FLG_MAX_AGG_SIZE_MSK        __constant_cpu_to_le32(3 << 19)
551 #define STA_FLG_FAT_EN_MSK              __constant_cpu_to_le32(1 << 21)
552 #define STA_FLG_MIMO_DIS_MSK            __constant_cpu_to_le32(1 << 22)
553 #define STA_FLG_AGG_MPDU_DENSITY_POS    (23)
554 #define STA_FLG_AGG_MPDU_DENSITY_MSK    __constant_cpu_to_le32(7 << 23)
555 #define HT_SHORT_GI_20MHZ_ONLY          (1 << 0)
556 #define HT_SHORT_GI_40MHZ_ONLY          (1 << 1)
557
558
559 #include "iwl-priv.h"
560
561 /* Requires full declaration of iwl_priv before including */
562 #include "iwl-io.h"
563
564 #define IWL_RX_HDR(x) ((struct iwl_rx_frame_hdr *)(\
565                        x->u.rx_frame.stats.payload + \
566                        x->u.rx_frame.stats.phy_count))
567 #define IWL_RX_END(x) ((struct iwl_rx_frame_end *)(\
568                        IWL_RX_HDR(x)->payload + \
569                        le16_to_cpu(IWL_RX_HDR(x)->len)))
570 #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
571 #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
572
573
574 /******************************************************************************
575  *
576  * Functions implemented in iwl-base.c which are forward declared here
577  * for use by iwl-*.c
578  *
579  *****************************************************************************/
580 struct iwl_addsta_cmd;
581 extern int iwl_send_add_station(struct iwl_priv *priv,
582                                 struct iwl_addsta_cmd *sta, u8 flags);
583 extern const char *iwl_get_tx_fail_reason(u32 status);
584 extern u8 iwl_add_station(struct iwl_priv *priv, const u8 *bssid,
585                           int is_ap, u8 flags);
586 extern int iwl_is_network_packet(struct iwl_priv *priv,
587                                  struct ieee80211_hdr *header);
588 extern int iwl_power_init_handle(struct iwl_priv *priv);
589 extern int iwl_eeprom_init(struct iwl_priv *priv);
590 #ifdef CONFIG_IWLWIFI_DEBUG
591 extern void iwl_report_frame(struct iwl_priv *priv,
592                              struct iwl_rx_packet *pkt,
593                              struct ieee80211_hdr *header, int group100);
594 #else
595 static inline void iwl_report_frame(struct iwl_priv *priv,
596                                     struct iwl_rx_packet *pkt,
597                                     struct ieee80211_hdr *header,
598                                     int group100) {}
599 #endif
600 extern int iwl_tx_queue_update_write_ptr(struct iwl_priv *priv,
601                                          struct iwl_tx_queue *txq);
602 extern void iwl_handle_data_packet_monitor(struct iwl_priv *priv,
603                                            struct iwl_rx_mem_buffer *rxb,
604                                            void *data, short len,
605                                            struct ieee80211_rx_status *stats,
606                                            u16 phy_flags);
607 extern int is_duplicate_packet(struct iwl_priv *priv, struct ieee80211_hdr
608                                *header);
609 extern void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
610 extern int iwl_rx_queue_alloc(struct iwl_priv *priv);
611 extern void iwl_rx_queue_reset(struct iwl_priv *priv,
612                                struct iwl_rx_queue *rxq);
613 extern int iwl_calc_db_from_ratio(int sig_ratio);
614 extern int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm);
615 extern int iwl_tx_queue_init(struct iwl_priv *priv,
616                              struct iwl_tx_queue *txq, int count, u32 id);
617 extern int iwl_rx_queue_restock(struct iwl_priv *priv);
618 extern void iwl_rx_replenish(void *data);
619 extern void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq);
620 extern int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len,
621                             const void *data);
622 extern int __must_check iwl_send_cmd_async(struct iwl_priv *priv,
623                 struct iwl_host_cmd *cmd);
624 extern int __must_check iwl_send_cmd_sync(struct iwl_priv *priv,
625                 struct iwl_host_cmd *cmd);
626 extern int __must_check iwl_send_cmd(struct iwl_priv *priv,
627                 struct iwl_host_cmd *cmd);
628 extern unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
629                                         struct ieee80211_hdr *hdr,
630                                         const u8 *dest, int left);
631 extern int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
632                                          struct iwl_rx_queue *q);
633 extern int iwl_send_statistics_request(struct iwl_priv *priv);
634 extern void iwl_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
635                                    u32 decrypt_res,
636                                    struct ieee80211_rx_status *stats);
637 extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
638
639 extern const u8 BROADCAST_ADDR[ETH_ALEN];
640
641 /*
642  * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
643  * call this... todo... fix that.
644 */
645 extern u8 iwl_sync_station(struct iwl_priv *priv, int sta_id,
646                            u16 tx_rate, u8 flags);
647
648 static inline int iwl_is_associated(struct iwl_priv *priv)
649 {
650         return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
651 }
652
653 /******************************************************************************
654  *
655  * Functions implemented in iwl-[34]*.c which are forward declared here
656  * for use by iwl-base.c
657  *
658  * NOTE:  The implementation of these functions are hardware specific
659  * which is why they are in the hardware specific files (vs. iwl-base.c)
660  *
661  * Naming convention --
662  * iwl_         <-- Its part of iwlwifi (should be changed to iwl_)
663  * iwl_hw_      <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
664  * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
665  * iwl_bg_      <-- Called from work queue context
666  * iwl_mac_     <-- mac80211 callback
667  *
668  ****************************************************************************/
669 extern void iwl_hw_rx_handler_setup(struct iwl_priv *priv);
670 extern void iwl_hw_setup_deferred_work(struct iwl_priv *priv);
671 extern void iwl_hw_cancel_deferred_work(struct iwl_priv *priv);
672 extern int iwl_hw_rxq_stop(struct iwl_priv *priv);
673 extern int iwl_hw_set_hw_setting(struct iwl_priv *priv);
674 extern int iwl_hw_nic_init(struct iwl_priv *priv);
675 extern void iwl_hw_card_show_info(struct iwl_priv *priv);
676 extern int iwl_hw_nic_stop_master(struct iwl_priv *priv);
677 extern void iwl_hw_txq_ctx_free(struct iwl_priv *priv);
678 extern void iwl_hw_txq_ctx_stop(struct iwl_priv *priv);
679 extern int iwl_hw_nic_reset(struct iwl_priv *priv);
680 extern int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
681                                         dma_addr_t addr, u16 len);
682 extern int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
683 extern int iwl_hw_get_temperature(struct iwl_priv *priv);
684 extern int iwl_hw_tx_queue_init(struct iwl_priv *priv,
685                                 struct iwl_tx_queue *txq);
686 extern unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
687                                  struct iwl_frame *frame, u8 rate);
688 extern int iwl_hw_get_rx_read(struct iwl_priv *priv);
689 extern void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv,
690                                      struct iwl_cmd *cmd,
691                                      struct ieee80211_tx_control *ctrl,
692                                      struct ieee80211_hdr *hdr,
693                                      int sta_id, int tx_id);
694 extern int iwl_hw_reg_send_txpower(struct iwl_priv *priv);
695 extern int iwl_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
696 extern void iwl_hw_rx_statistics(struct iwl_priv *priv,
697                                  struct iwl_rx_mem_buffer *rxb);
698 extern void iwl_disable_events(struct iwl_priv *priv);
699 extern int iwl4965_get_temperature(const struct iwl_priv *priv);
700
701 /**
702  * iwl_hw_find_station - Find station id for a given BSSID
703  * @bssid: MAC address of station ID to find
704  *
705  * NOTE:  This should not be hardware specific but the code has
706  * not yet been merged into a single common layer for managing the
707  * station tables.
708  */
709 extern u8 iwl_hw_find_station(struct iwl_priv *priv, const u8 *bssid);
710
711 extern int iwl_hw_channel_switch(struct iwl_priv *priv, u16 channel);
712 extern int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
713 #endif