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