1 /******************************************************************************
3 Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
5 802.11 status code portion of this file from ethereal-0.10.6:
6 Copyright 2000, Axis Communications AB
7 Ethereal - Network traffic analyzer
8 By Gerald Combs <gerald@ethereal.com>
9 Copyright 1998 Gerald Combs
11 This program is free software; you can redistribute it and/or modify it
12 under the terms of version 2 of the GNU General Public License as
13 published by the Free Software Foundation.
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59
22 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 The full GNU General Public License is included in this distribution in the
28 James P. Ketrenos <ipw2100-admin@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 ******************************************************************************/
34 #include <linux/version.h>
36 #define IPW2200_VERSION "git-1.0.8"
37 #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver"
38 #define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation"
39 #define DRV_VERSION IPW2200_VERSION
41 #define ETH_P_80211_STATS (ETH_P_80211_RAW + 1)
43 MODULE_DESCRIPTION(DRV_DESCRIPTION
);
44 MODULE_VERSION(DRV_VERSION
);
45 MODULE_AUTHOR(DRV_COPYRIGHT
);
46 MODULE_LICENSE("GPL");
48 static int cmdlog
= 0;
50 static int channel
= 0;
53 static u32 ipw_debug_level
;
54 static int associate
= 1;
55 static int auto_create
= 1;
57 static int disable
= 0;
58 static int bt_coexist
= 0;
59 static int hwcrypto
= 1;
60 static int roaming
= 1;
61 static const char ipw_modes
[] = {
66 static int qos_enable
= 0;
67 static int qos_burst_enable
= 0;
68 static int qos_no_ack_mask
= 0;
69 static int burst_duration_CCK
= 0;
70 static int burst_duration_OFDM
= 0;
72 static struct ieee80211_qos_parameters def_qos_parameters_OFDM
= {
73 {QOS_TX0_CW_MIN_OFDM
, QOS_TX1_CW_MIN_OFDM
, QOS_TX2_CW_MIN_OFDM
,
75 {QOS_TX0_CW_MAX_OFDM
, QOS_TX1_CW_MAX_OFDM
, QOS_TX2_CW_MAX_OFDM
,
77 {QOS_TX0_AIFS
, QOS_TX1_AIFS
, QOS_TX2_AIFS
, QOS_TX3_AIFS
},
78 {QOS_TX0_ACM
, QOS_TX1_ACM
, QOS_TX2_ACM
, QOS_TX3_ACM
},
79 {QOS_TX0_TXOP_LIMIT_OFDM
, QOS_TX1_TXOP_LIMIT_OFDM
,
80 QOS_TX2_TXOP_LIMIT_OFDM
, QOS_TX3_TXOP_LIMIT_OFDM
}
83 static struct ieee80211_qos_parameters def_qos_parameters_CCK
= {
84 {QOS_TX0_CW_MIN_CCK
, QOS_TX1_CW_MIN_CCK
, QOS_TX2_CW_MIN_CCK
,
86 {QOS_TX0_CW_MAX_CCK
, QOS_TX1_CW_MAX_CCK
, QOS_TX2_CW_MAX_CCK
,
88 {QOS_TX0_AIFS
, QOS_TX1_AIFS
, QOS_TX2_AIFS
, QOS_TX3_AIFS
},
89 {QOS_TX0_ACM
, QOS_TX1_ACM
, QOS_TX2_ACM
, QOS_TX3_ACM
},
90 {QOS_TX0_TXOP_LIMIT_CCK
, QOS_TX1_TXOP_LIMIT_CCK
, QOS_TX2_TXOP_LIMIT_CCK
,
91 QOS_TX3_TXOP_LIMIT_CCK
}
94 static struct ieee80211_qos_parameters def_parameters_OFDM
= {
95 {DEF_TX0_CW_MIN_OFDM
, DEF_TX1_CW_MIN_OFDM
, DEF_TX2_CW_MIN_OFDM
,
97 {DEF_TX0_CW_MAX_OFDM
, DEF_TX1_CW_MAX_OFDM
, DEF_TX2_CW_MAX_OFDM
,
99 {DEF_TX0_AIFS
, DEF_TX1_AIFS
, DEF_TX2_AIFS
, DEF_TX3_AIFS
},
100 {DEF_TX0_ACM
, DEF_TX1_ACM
, DEF_TX2_ACM
, DEF_TX3_ACM
},
101 {DEF_TX0_TXOP_LIMIT_OFDM
, DEF_TX1_TXOP_LIMIT_OFDM
,
102 DEF_TX2_TXOP_LIMIT_OFDM
, DEF_TX3_TXOP_LIMIT_OFDM
}
105 static struct ieee80211_qos_parameters def_parameters_CCK
= {
106 {DEF_TX0_CW_MIN_CCK
, DEF_TX1_CW_MIN_CCK
, DEF_TX2_CW_MIN_CCK
,
108 {DEF_TX0_CW_MAX_CCK
, DEF_TX1_CW_MAX_CCK
, DEF_TX2_CW_MAX_CCK
,
110 {DEF_TX0_AIFS
, DEF_TX1_AIFS
, DEF_TX2_AIFS
, DEF_TX3_AIFS
},
111 {DEF_TX0_ACM
, DEF_TX1_ACM
, DEF_TX2_ACM
, DEF_TX3_ACM
},
112 {DEF_TX0_TXOP_LIMIT_CCK
, DEF_TX1_TXOP_LIMIT_CCK
, DEF_TX2_TXOP_LIMIT_CCK
,
113 DEF_TX3_TXOP_LIMIT_CCK
}
116 static u8 qos_oui
[QOS_OUI_LEN
] = { 0x00, 0x50, 0xF2 };
118 static int from_priority_to_tx_queue
[] = {
119 IPW_TX_QUEUE_1
, IPW_TX_QUEUE_2
, IPW_TX_QUEUE_2
, IPW_TX_QUEUE_1
,
120 IPW_TX_QUEUE_3
, IPW_TX_QUEUE_3
, IPW_TX_QUEUE_4
, IPW_TX_QUEUE_4
123 static u32
ipw_qos_get_burst_duration(struct ipw_priv
*priv
);
125 static int ipw_send_qos_params_command(struct ipw_priv
*priv
, struct ieee80211_qos_parameters
127 static int ipw_send_qos_info_command(struct ipw_priv
*priv
, struct ieee80211_qos_information_element
129 #endif /* CONFIG_IPW_QOS */
131 static struct iw_statistics
*ipw_get_wireless_stats(struct net_device
*dev
);
132 static void ipw_remove_current_network(struct ipw_priv
*priv
);
133 static void ipw_rx(struct ipw_priv
*priv
);
134 static int ipw_queue_tx_reclaim(struct ipw_priv
*priv
,
135 struct clx2_tx_queue
*txq
, int qindex
);
136 static int ipw_queue_reset(struct ipw_priv
*priv
);
138 static int ipw_queue_tx_hcmd(struct ipw_priv
*priv
, int hcmd
, void *buf
,
141 static void ipw_tx_queue_free(struct ipw_priv
*);
143 static struct ipw_rx_queue
*ipw_rx_queue_alloc(struct ipw_priv
*);
144 static void ipw_rx_queue_free(struct ipw_priv
*, struct ipw_rx_queue
*);
145 static void ipw_rx_queue_replenish(void *);
146 static int ipw_up(struct ipw_priv
*);
147 static void ipw_bg_up(void *);
148 static void ipw_down(struct ipw_priv
*);
149 static void ipw_bg_down(void *);
150 static int ipw_config(struct ipw_priv
*);
151 static int init_supported_rates(struct ipw_priv
*priv
,
152 struct ipw_supported_rates
*prates
);
153 static void ipw_set_hwcrypto_keys(struct ipw_priv
*);
154 static void ipw_send_wep_keys(struct ipw_priv
*, int);
156 static int ipw_is_valid_channel(struct ieee80211_device
*, u8
);
157 static int ipw_channel_to_index(struct ieee80211_device
*, u8
);
158 static u8
ipw_freq_to_channel(struct ieee80211_device
*, u32
);
159 static int ipw_set_geo(struct ieee80211_device
*, const struct ieee80211_geo
*);
160 static const struct ieee80211_geo
*ipw_get_geo(struct ieee80211_device
*);
162 static int snprint_line(char *buf
, size_t count
,
163 const u8
* data
, u32 len
, u32 ofs
)
168 out
= snprintf(buf
, count
, "%08X", ofs
);
170 for (l
= 0, i
= 0; i
< 2; i
++) {
171 out
+= snprintf(buf
+ out
, count
- out
, " ");
172 for (j
= 0; j
< 8 && l
< len
; j
++, l
++)
173 out
+= snprintf(buf
+ out
, count
- out
, "%02X ",
176 out
+= snprintf(buf
+ out
, count
- out
, " ");
179 out
+= snprintf(buf
+ out
, count
- out
, " ");
180 for (l
= 0, i
= 0; i
< 2; i
++) {
181 out
+= snprintf(buf
+ out
, count
- out
, " ");
182 for (j
= 0; j
< 8 && l
< len
; j
++, l
++) {
183 c
= data
[(i
* 8 + j
)];
184 if (!isascii(c
) || !isprint(c
))
187 out
+= snprintf(buf
+ out
, count
- out
, "%c", c
);
191 out
+= snprintf(buf
+ out
, count
- out
, " ");
197 static void printk_buf(int level
, const u8
* data
, u32 len
)
201 if (!(ipw_debug_level
& level
))
205 snprint_line(line
, sizeof(line
), &data
[ofs
],
207 printk(KERN_DEBUG
"%s\n", line
);
209 len
-= min(len
, 16U);
213 static int snprintk_buf(u8
* output
, size_t size
, const u8
* data
, size_t len
)
219 while (size
&& len
) {
220 out
= snprint_line(output
, size
, &data
[ofs
],
221 min_t(size_t, len
, 16U), ofs
);
226 len
-= min_t(size_t, len
, 16U);
232 /* alias for 32-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
233 static u32
_ipw_read_reg32(struct ipw_priv
*priv
, u32 reg
);
234 #define ipw_read_reg32(a, b) _ipw_read_reg32(a, b)
236 /* alias for 8-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
237 static u8
_ipw_read_reg8(struct ipw_priv
*ipw
, u32 reg
);
238 #define ipw_read_reg8(a, b) _ipw_read_reg8(a, b)
240 /* 8-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
241 static void _ipw_write_reg8(struct ipw_priv
*priv
, u32 reg
, u8 value
);
242 static inline void ipw_write_reg8(struct ipw_priv
*a
, u32 b
, u8 c
)
244 IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__
,
245 __LINE__
, (u32
) (b
), (u32
) (c
));
246 _ipw_write_reg8(a
, b
, c
);
249 /* 16-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
250 static void _ipw_write_reg16(struct ipw_priv
*priv
, u32 reg
, u16 value
);
251 static inline void ipw_write_reg16(struct ipw_priv
*a
, u32 b
, u16 c
)
253 IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__
,
254 __LINE__
, (u32
) (b
), (u32
) (c
));
255 _ipw_write_reg16(a
, b
, c
);
258 /* 32-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
259 static void _ipw_write_reg32(struct ipw_priv
*priv
, u32 reg
, u32 value
);
260 static inline void ipw_write_reg32(struct ipw_priv
*a
, u32 b
, u32 c
)
262 IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__
,
263 __LINE__
, (u32
) (b
), (u32
) (c
));
264 _ipw_write_reg32(a
, b
, c
);
267 /* 8-bit direct write (low 4K) */
268 #define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs))
270 /* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
271 #define ipw_write8(ipw, ofs, val) \
272 IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
273 _ipw_write8(ipw, ofs, val)
276 /* 16-bit direct write (low 4K) */
277 #define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs))
279 /* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
280 #define ipw_write16(ipw, ofs, val) \
281 IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
282 _ipw_write16(ipw, ofs, val)
285 /* 32-bit direct write (low 4K) */
286 #define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs))
288 /* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
289 #define ipw_write32(ipw, ofs, val) \
290 IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
291 _ipw_write32(ipw, ofs, val)
294 /* 8-bit direct read (low 4K) */
295 #define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs))
297 /* 8-bit direct read (low 4K), with debug wrapper */
298 static inline u8
__ipw_read8(char *f
, u32 l
, struct ipw_priv
*ipw
, u32 ofs
)
300 IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f
, l
, (u32
) (ofs
));
301 return _ipw_read8(ipw
, ofs
);
304 /* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */
305 #define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs)
308 /* 16-bit direct read (low 4K) */
309 #define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs))
311 /* 16-bit direct read (low 4K), with debug wrapper */
312 static inline u16
__ipw_read16(char *f
, u32 l
, struct ipw_priv
*ipw
, u32 ofs
)
314 IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f
, l
, (u32
) (ofs
));
315 return _ipw_read16(ipw
, ofs
);
318 /* alias to 16-bit direct read (low 4K of SRAM/regs), with debug wrapper */
319 #define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs)
322 /* 32-bit direct read (low 4K) */
323 #define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs))
325 /* 32-bit direct read (low 4K), with debug wrapper */
326 static inline u32
__ipw_read32(char *f
, u32 l
, struct ipw_priv
*ipw
, u32 ofs
)
328 IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f
, l
, (u32
) (ofs
));
329 return _ipw_read32(ipw
, ofs
);
332 /* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */
333 #define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs)
336 /* multi-byte read (above 4K), with debug wrapper */
337 static void _ipw_read_indirect(struct ipw_priv
*, u32
, u8
*, int);
338 static inline void __ipw_read_indirect(const char *f
, int l
,
339 struct ipw_priv
*a
, u32 b
, u8
* c
, int d
)
341 IPW_DEBUG_IO("%s %d: read_indirect(0x%08X) %d bytes\n", f
, l
, (u32
) (b
),
343 _ipw_read_indirect(a
, b
, c
, d
);
346 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
347 #define ipw_read_indirect(a, b, c, d) __ipw_read_indirect(__FILE__, __LINE__, a, b, c, d)
349 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
350 static void _ipw_write_indirect(struct ipw_priv
*priv
, u32 addr
, u8
* data
,
352 #define ipw_write_indirect(a, b, c, d) \
353 IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
354 _ipw_write_indirect(a, b, c, d)
356 /* 32-bit indirect write (above 4K) */
357 static void _ipw_write_reg32(struct ipw_priv
*priv
, u32 reg
, u32 value
)
359 IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv
, reg
, value
);
360 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, reg
);
361 _ipw_write32(priv
, IPW_INDIRECT_DATA
, value
);
364 /* 8-bit indirect write (above 4K) */
365 static void _ipw_write_reg8(struct ipw_priv
*priv
, u32 reg
, u8 value
)
367 u32 aligned_addr
= reg
& IPW_INDIRECT_ADDR_MASK
; /* dword align */
368 u32 dif_len
= reg
- aligned_addr
;
370 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg
, value
);
371 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
372 _ipw_write8(priv
, IPW_INDIRECT_DATA
+ dif_len
, value
);
375 /* 16-bit indirect write (above 4K) */
376 static void _ipw_write_reg16(struct ipw_priv
*priv
, u32 reg
, u16 value
)
378 u32 aligned_addr
= reg
& IPW_INDIRECT_ADDR_MASK
; /* dword align */
379 u32 dif_len
= (reg
- aligned_addr
) & (~0x1ul
);
381 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg
, value
);
382 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
383 _ipw_write16(priv
, IPW_INDIRECT_DATA
+ dif_len
, value
);
387 /* 8-bit indirect read (above 4K) */
388 static u8
_ipw_read_reg8(struct ipw_priv
*priv
, u32 reg
)
391 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, reg
& IPW_INDIRECT_ADDR_MASK
);
392 IPW_DEBUG_IO(" reg = 0x%8X : \n", reg
);
393 word
= _ipw_read32(priv
, IPW_INDIRECT_DATA
);
394 return (word
>> ((reg
& 0x3) * 8)) & 0xff;
397 /* 32-bit indirect read (above 4K) */
398 static u32
_ipw_read_reg32(struct ipw_priv
*priv
, u32 reg
)
402 IPW_DEBUG_IO("%p : reg = 0x%08x\n", priv
, reg
);
404 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, reg
);
405 value
= _ipw_read32(priv
, IPW_INDIRECT_DATA
);
406 IPW_DEBUG_IO(" reg = 0x%4X : value = 0x%4x \n", reg
, value
);
410 /* General purpose, no alignment requirement, iterative (multi-byte) read, */
411 /* for area above 1st 4K of SRAM/reg space */
412 static void _ipw_read_indirect(struct ipw_priv
*priv
, u32 addr
, u8
* buf
,
415 u32 aligned_addr
= addr
& IPW_INDIRECT_ADDR_MASK
; /* dword align */
416 u32 dif_len
= addr
- aligned_addr
;
419 IPW_DEBUG_IO("addr = %i, buf = %p, num = %i\n", addr
, buf
, num
);
425 /* Read the first dword (or portion) byte by byte */
426 if (unlikely(dif_len
)) {
427 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
428 /* Start reading at aligned_addr + dif_len */
429 for (i
= dif_len
; ((i
< 4) && (num
> 0)); i
++, num
--)
430 *buf
++ = _ipw_read8(priv
, IPW_INDIRECT_DATA
+ i
);
434 /* Read all of the middle dwords as dwords, with auto-increment */
435 _ipw_write32(priv
, IPW_AUTOINC_ADDR
, aligned_addr
);
436 for (; num
>= 4; buf
+= 4, aligned_addr
+= 4, num
-= 4)
437 *(u32
*) buf
= _ipw_read32(priv
, IPW_AUTOINC_DATA
);
439 /* Read the last dword (or portion) byte by byte */
441 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
442 for (i
= 0; num
> 0; i
++, num
--)
443 *buf
++ = ipw_read8(priv
, IPW_INDIRECT_DATA
+ i
);
447 /* General purpose, no alignment requirement, iterative (multi-byte) write, */
448 /* for area above 1st 4K of SRAM/reg space */
449 static void _ipw_write_indirect(struct ipw_priv
*priv
, u32 addr
, u8
* buf
,
452 u32 aligned_addr
= addr
& IPW_INDIRECT_ADDR_MASK
; /* dword align */
453 u32 dif_len
= addr
- aligned_addr
;
456 IPW_DEBUG_IO("addr = %i, buf = %p, num = %i\n", addr
, buf
, num
);
462 /* Write the first dword (or portion) byte by byte */
463 if (unlikely(dif_len
)) {
464 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
465 /* Start writing at aligned_addr + dif_len */
466 for (i
= dif_len
; ((i
< 4) && (num
> 0)); i
++, num
--, buf
++)
467 _ipw_write8(priv
, IPW_INDIRECT_DATA
+ i
, *buf
);
471 /* Write all of the middle dwords as dwords, with auto-increment */
472 _ipw_write32(priv
, IPW_AUTOINC_ADDR
, aligned_addr
);
473 for (; num
>= 4; buf
+= 4, aligned_addr
+= 4, num
-= 4)
474 _ipw_write32(priv
, IPW_AUTOINC_DATA
, *(u32
*) buf
);
476 /* Write the last dword (or portion) byte by byte */
478 _ipw_write32(priv
, IPW_INDIRECT_ADDR
, aligned_addr
);
479 for (i
= 0; num
> 0; i
++, num
--, buf
++)
480 _ipw_write8(priv
, IPW_INDIRECT_DATA
+ i
, *buf
);
484 /* General purpose, no alignment requirement, iterative (multi-byte) write, */
485 /* for 1st 4K of SRAM/regs space */
486 static void ipw_write_direct(struct ipw_priv
*priv
, u32 addr
, void *buf
,
489 memcpy_toio((priv
->hw_base
+ addr
), buf
, num
);
492 /* Set bit(s) in low 4K of SRAM/regs */
493 static inline void ipw_set_bit(struct ipw_priv
*priv
, u32 reg
, u32 mask
)
495 ipw_write32(priv
, reg
, ipw_read32(priv
, reg
) | mask
);
498 /* Clear bit(s) in low 4K of SRAM/regs */
499 static inline void ipw_clear_bit(struct ipw_priv
*priv
, u32 reg
, u32 mask
)
501 ipw_write32(priv
, reg
, ipw_read32(priv
, reg
) & ~mask
);
504 static inline void ipw_enable_interrupts(struct ipw_priv
*priv
)
506 if (priv
->status
& STATUS_INT_ENABLED
)
508 priv
->status
|= STATUS_INT_ENABLED
;
509 ipw_write32(priv
, IPW_INTA_MASK_R
, IPW_INTA_MASK_ALL
);
512 static inline void ipw_disable_interrupts(struct ipw_priv
*priv
)
514 if (!(priv
->status
& STATUS_INT_ENABLED
))
516 priv
->status
&= ~STATUS_INT_ENABLED
;
517 ipw_write32(priv
, IPW_INTA_MASK_R
, ~IPW_INTA_MASK_ALL
);
520 #ifdef CONFIG_IPW2200_DEBUG
521 static char *ipw_error_desc(u32 val
)
524 case IPW_FW_ERROR_OK
:
526 case IPW_FW_ERROR_FAIL
:
528 case IPW_FW_ERROR_MEMORY_UNDERFLOW
:
529 return "MEMORY_UNDERFLOW";
530 case IPW_FW_ERROR_MEMORY_OVERFLOW
:
531 return "MEMORY_OVERFLOW";
532 case IPW_FW_ERROR_BAD_PARAM
:
534 case IPW_FW_ERROR_BAD_CHECKSUM
:
535 return "BAD_CHECKSUM";
536 case IPW_FW_ERROR_NMI_INTERRUPT
:
537 return "NMI_INTERRUPT";
538 case IPW_FW_ERROR_BAD_DATABASE
:
539 return "BAD_DATABASE";
540 case IPW_FW_ERROR_ALLOC_FAIL
:
542 case IPW_FW_ERROR_DMA_UNDERRUN
:
543 return "DMA_UNDERRUN";
544 case IPW_FW_ERROR_DMA_STATUS
:
546 case IPW_FW_ERROR_DINO_ERROR
:
548 case IPW_FW_ERROR_EEPROM_ERROR
:
549 return "EEPROM_ERROR";
550 case IPW_FW_ERROR_SYSASSERT
:
552 case IPW_FW_ERROR_FATAL_ERROR
:
553 return "FATAL_ERROR";
555 return "UNKNOWN_ERROR";
559 static void ipw_dump_error_log(struct ipw_priv
*priv
,
560 struct ipw_fw_error
*error
)
565 IPW_ERROR("Error allocating and capturing error log. "
566 "Nothing to dump.\n");
570 IPW_ERROR("Start IPW Error Log Dump:\n");
571 IPW_ERROR("Status: 0x%08X, Config: %08X\n",
572 error
->status
, error
->config
);
574 for (i
= 0; i
< error
->elem_len
; i
++)
575 IPW_ERROR("%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
576 ipw_error_desc(error
->elem
[i
].desc
),
578 error
->elem
[i
].blink1
,
579 error
->elem
[i
].blink2
,
580 error
->elem
[i
].link1
,
581 error
->elem
[i
].link2
, error
->elem
[i
].data
);
582 for (i
= 0; i
< error
->log_len
; i
++)
583 IPW_ERROR("%i\t0x%08x\t%i\n",
585 error
->log
[i
].data
, error
->log
[i
].event
);
589 static inline int ipw_is_init(struct ipw_priv
*priv
)
591 return (priv
->status
& STATUS_INIT
) ? 1 : 0;
594 static int ipw_get_ordinal(struct ipw_priv
*priv
, u32 ord
, void *val
, u32
* len
)
596 u32 addr
, field_info
, field_len
, field_count
, total_len
;
598 IPW_DEBUG_ORD("ordinal = %i\n", ord
);
600 if (!priv
|| !val
|| !len
) {
601 IPW_DEBUG_ORD("Invalid argument\n");
605 /* verify device ordinal tables have been initialized */
606 if (!priv
->table0_addr
|| !priv
->table1_addr
|| !priv
->table2_addr
) {
607 IPW_DEBUG_ORD("Access ordinals before initialization\n");
611 switch (IPW_ORD_TABLE_ID_MASK
& ord
) {
612 case IPW_ORD_TABLE_0_MASK
:
614 * TABLE 0: Direct access to a table of 32 bit values
616 * This is a very simple table with the data directly
617 * read from the table
620 /* remove the table id from the ordinal */
621 ord
&= IPW_ORD_TABLE_VALUE_MASK
;
624 if (ord
> priv
->table0_len
) {
625 IPW_DEBUG_ORD("ordinal value (%i) longer then "
626 "max (%i)\n", ord
, priv
->table0_len
);
630 /* verify we have enough room to store the value */
631 if (*len
< sizeof(u32
)) {
632 IPW_DEBUG_ORD("ordinal buffer length too small, "
633 "need %zd\n", sizeof(u32
));
637 IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n",
638 ord
, priv
->table0_addr
+ (ord
<< 2));
642 *((u32
*) val
) = ipw_read32(priv
, priv
->table0_addr
+ ord
);
645 case IPW_ORD_TABLE_1_MASK
:
647 * TABLE 1: Indirect access to a table of 32 bit values
649 * This is a fairly large table of u32 values each
650 * representing starting addr for the data (which is
654 /* remove the table id from the ordinal */
655 ord
&= IPW_ORD_TABLE_VALUE_MASK
;
658 if (ord
> priv
->table1_len
) {
659 IPW_DEBUG_ORD("ordinal value too long\n");
663 /* verify we have enough room to store the value */
664 if (*len
< sizeof(u32
)) {
665 IPW_DEBUG_ORD("ordinal buffer length too small, "
666 "need %zd\n", sizeof(u32
));
671 ipw_read_reg32(priv
, (priv
->table1_addr
+ (ord
<< 2)));
675 case IPW_ORD_TABLE_2_MASK
:
677 * TABLE 2: Indirect access to a table of variable sized values
679 * This table consist of six values, each containing
680 * - dword containing the starting offset of the data
681 * - dword containing the lengh in the first 16bits
682 * and the count in the second 16bits
685 /* remove the table id from the ordinal */
686 ord
&= IPW_ORD_TABLE_VALUE_MASK
;
689 if (ord
> priv
->table2_len
) {
690 IPW_DEBUG_ORD("ordinal value too long\n");
694 /* get the address of statistic */
695 addr
= ipw_read_reg32(priv
, priv
->table2_addr
+ (ord
<< 3));
697 /* get the second DW of statistics ;
698 * two 16-bit words - first is length, second is count */
701 priv
->table2_addr
+ (ord
<< 3) +
704 /* get each entry length */
705 field_len
= *((u16
*) & field_info
);
707 /* get number of entries */
708 field_count
= *(((u16
*) & field_info
) + 1);
710 /* abort if not enought memory */
711 total_len
= field_len
* field_count
;
712 if (total_len
> *len
) {
721 IPW_DEBUG_ORD("addr = 0x%08x, total_len = %i, "
722 "field_info = 0x%08x\n",
723 addr
, total_len
, field_info
);
724 ipw_read_indirect(priv
, addr
, val
, total_len
);
728 IPW_DEBUG_ORD("Invalid ordinal!\n");
736 static void ipw_init_ordinals(struct ipw_priv
*priv
)
738 priv
->table0_addr
= IPW_ORDINALS_TABLE_LOWER
;
739 priv
->table0_len
= ipw_read32(priv
, priv
->table0_addr
);
741 IPW_DEBUG_ORD("table 0 offset at 0x%08x, len = %i\n",
742 priv
->table0_addr
, priv
->table0_len
);
744 priv
->table1_addr
= ipw_read32(priv
, IPW_ORDINALS_TABLE_1
);
745 priv
->table1_len
= ipw_read_reg32(priv
, priv
->table1_addr
);
747 IPW_DEBUG_ORD("table 1 offset at 0x%08x, len = %i\n",
748 priv
->table1_addr
, priv
->table1_len
);
750 priv
->table2_addr
= ipw_read32(priv
, IPW_ORDINALS_TABLE_2
);
751 priv
->table2_len
= ipw_read_reg32(priv
, priv
->table2_addr
);
752 priv
->table2_len
&= 0x0000ffff; /* use first two bytes */
754 IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n",
755 priv
->table2_addr
, priv
->table2_len
);
759 static u32
ipw_register_toggle(u32 reg
)
761 reg
&= ~IPW_START_STANDBY
;
762 if (reg
& IPW_GATE_ODMA
)
763 reg
&= ~IPW_GATE_ODMA
;
764 if (reg
& IPW_GATE_IDMA
)
765 reg
&= ~IPW_GATE_IDMA
;
766 if (reg
& IPW_GATE_ADMA
)
767 reg
&= ~IPW_GATE_ADMA
;
773 * - On radio ON, turn on any LEDs that require to be on during start
774 * - On initialization, start unassociated blink
775 * - On association, disable unassociated blink
776 * - On disassociation, start unassociated blink
777 * - On radio OFF, turn off any LEDs started during radio on
780 #define LD_TIME_LINK_ON msecs_to_jiffies(300)
781 #define LD_TIME_LINK_OFF msecs_to_jiffies(2700)
782 #define LD_TIME_ACT_ON msecs_to_jiffies(250)
784 static void ipw_led_link_on(struct ipw_priv
*priv
)
789 /* If configured to not use LEDs, or nic_type is 1,
790 * then we don't toggle a LINK led */
791 if (priv
->config
& CFG_NO_LED
|| priv
->nic_type
== EEPROM_NIC_TYPE_1
)
794 spin_lock_irqsave(&priv
->lock
, flags
);
796 if (!(priv
->status
& STATUS_RF_KILL_MASK
) &&
797 !(priv
->status
& STATUS_LED_LINK_ON
)) {
798 IPW_DEBUG_LED("Link LED On\n");
799 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
800 led
|= priv
->led_association_on
;
802 led
= ipw_register_toggle(led
);
804 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
805 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
807 priv
->status
|= STATUS_LED_LINK_ON
;
809 /* If we aren't associated, schedule turning the LED off */
810 if (!(priv
->status
& STATUS_ASSOCIATED
))
811 queue_delayed_work(priv
->workqueue
,
816 spin_unlock_irqrestore(&priv
->lock
, flags
);
819 static void ipw_bg_led_link_on(void *data
)
821 struct ipw_priv
*priv
= data
;
823 ipw_led_link_on(data
);
827 static void ipw_led_link_off(struct ipw_priv
*priv
)
832 /* If configured not to use LEDs, or nic type is 1,
833 * then we don't goggle the LINK led. */
834 if (priv
->config
& CFG_NO_LED
|| priv
->nic_type
== EEPROM_NIC_TYPE_1
)
837 spin_lock_irqsave(&priv
->lock
, flags
);
839 if (priv
->status
& STATUS_LED_LINK_ON
) {
840 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
841 led
&= priv
->led_association_off
;
842 led
= ipw_register_toggle(led
);
844 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
845 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
847 IPW_DEBUG_LED("Link LED Off\n");
849 priv
->status
&= ~STATUS_LED_LINK_ON
;
851 /* If we aren't associated and the radio is on, schedule
852 * turning the LED on (blink while unassociated) */
853 if (!(priv
->status
& STATUS_RF_KILL_MASK
) &&
854 !(priv
->status
& STATUS_ASSOCIATED
))
855 queue_delayed_work(priv
->workqueue
, &priv
->led_link_on
,
860 spin_unlock_irqrestore(&priv
->lock
, flags
);
863 static void ipw_bg_led_link_off(void *data
)
865 struct ipw_priv
*priv
= data
;
867 ipw_led_link_off(data
);
871 static void __ipw_led_activity_on(struct ipw_priv
*priv
)
875 if (priv
->config
& CFG_NO_LED
)
878 if (priv
->status
& STATUS_RF_KILL_MASK
)
881 if (!(priv
->status
& STATUS_LED_ACT_ON
)) {
882 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
883 led
|= priv
->led_activity_on
;
885 led
= ipw_register_toggle(led
);
887 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
888 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
890 IPW_DEBUG_LED("Activity LED On\n");
892 priv
->status
|= STATUS_LED_ACT_ON
;
894 cancel_delayed_work(&priv
->led_act_off
);
895 queue_delayed_work(priv
->workqueue
, &priv
->led_act_off
,
898 /* Reschedule LED off for full time period */
899 cancel_delayed_work(&priv
->led_act_off
);
900 queue_delayed_work(priv
->workqueue
, &priv
->led_act_off
,
906 void ipw_led_activity_on(struct ipw_priv
*priv
)
909 spin_lock_irqsave(&priv
->lock
, flags
);
910 __ipw_led_activity_on(priv
);
911 spin_unlock_irqrestore(&priv
->lock
, flags
);
915 static void ipw_led_activity_off(struct ipw_priv
*priv
)
920 if (priv
->config
& CFG_NO_LED
)
923 spin_lock_irqsave(&priv
->lock
, flags
);
925 if (priv
->status
& STATUS_LED_ACT_ON
) {
926 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
927 led
&= priv
->led_activity_off
;
929 led
= ipw_register_toggle(led
);
931 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
932 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
934 IPW_DEBUG_LED("Activity LED Off\n");
936 priv
->status
&= ~STATUS_LED_ACT_ON
;
939 spin_unlock_irqrestore(&priv
->lock
, flags
);
942 static void ipw_bg_led_activity_off(void *data
)
944 struct ipw_priv
*priv
= data
;
946 ipw_led_activity_off(data
);
950 static void ipw_led_band_on(struct ipw_priv
*priv
)
955 /* Only nic type 1 supports mode LEDs */
956 if (priv
->config
& CFG_NO_LED
||
957 priv
->nic_type
!= EEPROM_NIC_TYPE_1
|| !priv
->assoc_network
)
960 spin_lock_irqsave(&priv
->lock
, flags
);
962 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
963 if (priv
->assoc_network
->mode
== IEEE_A
) {
964 led
|= priv
->led_ofdm_on
;
965 led
&= priv
->led_association_off
;
966 IPW_DEBUG_LED("Mode LED On: 802.11a\n");
967 } else if (priv
->assoc_network
->mode
== IEEE_G
) {
968 led
|= priv
->led_ofdm_on
;
969 led
|= priv
->led_association_on
;
970 IPW_DEBUG_LED("Mode LED On: 802.11g\n");
972 led
&= priv
->led_ofdm_off
;
973 led
|= priv
->led_association_on
;
974 IPW_DEBUG_LED("Mode LED On: 802.11b\n");
977 led
= ipw_register_toggle(led
);
979 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
980 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
982 spin_unlock_irqrestore(&priv
->lock
, flags
);
985 static void ipw_led_band_off(struct ipw_priv
*priv
)
990 /* Only nic type 1 supports mode LEDs */
991 if (priv
->config
& CFG_NO_LED
|| priv
->nic_type
!= EEPROM_NIC_TYPE_1
)
994 spin_lock_irqsave(&priv
->lock
, flags
);
996 led
= ipw_read_reg32(priv
, IPW_EVENT_REG
);
997 led
&= priv
->led_ofdm_off
;
998 led
&= priv
->led_association_off
;
1000 led
= ipw_register_toggle(led
);
1002 IPW_DEBUG_LED("Reg: 0x%08X\n", led
);
1003 ipw_write_reg32(priv
, IPW_EVENT_REG
, led
);
1005 spin_unlock_irqrestore(&priv
->lock
, flags
);
1008 static void ipw_led_radio_on(struct ipw_priv
*priv
)
1010 ipw_led_link_on(priv
);
1013 static void ipw_led_radio_off(struct ipw_priv
*priv
)
1015 ipw_led_activity_off(priv
);
1016 ipw_led_link_off(priv
);
1019 static void ipw_led_link_up(struct ipw_priv
*priv
)
1021 /* Set the Link Led on for all nic types */
1022 ipw_led_link_on(priv
);
1025 static void ipw_led_link_down(struct ipw_priv
*priv
)
1027 ipw_led_activity_off(priv
);
1028 ipw_led_link_off(priv
);
1030 if (priv
->status
& STATUS_RF_KILL_MASK
)
1031 ipw_led_radio_off(priv
);
1034 static void ipw_led_init(struct ipw_priv
*priv
)
1036 priv
->nic_type
= priv
->eeprom
[EEPROM_NIC_TYPE
];
1038 /* Set the default PINs for the link and activity leds */
1039 priv
->led_activity_on
= IPW_ACTIVITY_LED
;
1040 priv
->led_activity_off
= ~(IPW_ACTIVITY_LED
);
1042 priv
->led_association_on
= IPW_ASSOCIATED_LED
;
1043 priv
->led_association_off
= ~(IPW_ASSOCIATED_LED
);
1045 /* Set the default PINs for the OFDM leds */
1046 priv
->led_ofdm_on
= IPW_OFDM_LED
;
1047 priv
->led_ofdm_off
= ~(IPW_OFDM_LED
);
1049 switch (priv
->nic_type
) {
1050 case EEPROM_NIC_TYPE_1
:
1051 /* In this NIC type, the LEDs are reversed.... */
1052 priv
->led_activity_on
= IPW_ASSOCIATED_LED
;
1053 priv
->led_activity_off
= ~(IPW_ASSOCIATED_LED
);
1054 priv
->led_association_on
= IPW_ACTIVITY_LED
;
1055 priv
->led_association_off
= ~(IPW_ACTIVITY_LED
);
1057 if (!(priv
->config
& CFG_NO_LED
))
1058 ipw_led_band_on(priv
);
1060 /* And we don't blink link LEDs for this nic, so
1061 * just return here */
1064 case EEPROM_NIC_TYPE_3
:
1065 case EEPROM_NIC_TYPE_2
:
1066 case EEPROM_NIC_TYPE_4
:
1067 case EEPROM_NIC_TYPE_0
:
1071 IPW_DEBUG_INFO("Unknown NIC type from EEPROM: %d\n",
1073 priv
->nic_type
= EEPROM_NIC_TYPE_0
;
1077 if (!(priv
->config
& CFG_NO_LED
)) {
1078 if (priv
->status
& STATUS_ASSOCIATED
)
1079 ipw_led_link_on(priv
);
1081 ipw_led_link_off(priv
);
1085 static void ipw_led_shutdown(struct ipw_priv
*priv
)
1087 ipw_led_activity_off(priv
);
1088 ipw_led_link_off(priv
);
1089 ipw_led_band_off(priv
);
1090 cancel_delayed_work(&priv
->led_link_on
);
1091 cancel_delayed_work(&priv
->led_link_off
);
1092 cancel_delayed_work(&priv
->led_act_off
);
1096 * The following adds a new attribute to the sysfs representation
1097 * of this device driver (i.e. a new file in /sys/bus/pci/drivers/ipw/)
1098 * used for controling the debug level.
1100 * See the level definitions in ipw for details.
1102 static ssize_t
show_debug_level(struct device_driver
*d
, char *buf
)
1104 return sprintf(buf
, "0x%08X\n", ipw_debug_level
);
1107 static ssize_t
store_debug_level(struct device_driver
*d
, const char *buf
,
1110 char *p
= (char *)buf
;
1113 if (p
[1] == 'x' || p
[1] == 'X' || p
[0] == 'x' || p
[0] == 'X') {
1115 if (p
[0] == 'x' || p
[0] == 'X')
1117 val
= simple_strtoul(p
, &p
, 16);
1119 val
= simple_strtoul(p
, &p
, 10);
1121 printk(KERN_INFO DRV_NAME
1122 ": %s is not in hex or decimal form.\n", buf
);
1124 ipw_debug_level
= val
;
1126 return strnlen(buf
, count
);
1129 static DRIVER_ATTR(debug_level
, S_IWUSR
| S_IRUGO
,
1130 show_debug_level
, store_debug_level
);
1132 static inline u32
ipw_get_event_log_len(struct ipw_priv
*priv
)
1134 /* length = 1st dword in log */
1135 return ipw_read_reg32(priv
, ipw_read32(priv
, IPW_EVENT_LOG
));
1138 static void ipw_capture_event_log(struct ipw_priv
*priv
,
1139 u32 log_len
, struct ipw_event
*log
)
1144 base
= ipw_read32(priv
, IPW_EVENT_LOG
);
1145 ipw_read_indirect(priv
, base
+ sizeof(base
) + sizeof(u32
),
1146 (u8
*) log
, sizeof(*log
) * log_len
);
1150 static struct ipw_fw_error
*ipw_alloc_error_log(struct ipw_priv
*priv
)
1152 struct ipw_fw_error
*error
;
1153 u32 log_len
= ipw_get_event_log_len(priv
);
1154 u32 base
= ipw_read32(priv
, IPW_ERROR_LOG
);
1155 u32 elem_len
= ipw_read_reg32(priv
, base
);
1157 error
= kmalloc(sizeof(*error
) +
1158 sizeof(*error
->elem
) * elem_len
+
1159 sizeof(*error
->log
) * log_len
, GFP_ATOMIC
);
1161 IPW_ERROR("Memory allocation for firmware error log "
1165 error
->jiffies
= jiffies
;
1166 error
->status
= priv
->status
;
1167 error
->config
= priv
->config
;
1168 error
->elem_len
= elem_len
;
1169 error
->log_len
= log_len
;
1170 error
->elem
= (struct ipw_error_elem
*)error
->payload
;
1171 error
->log
= (struct ipw_event
*)(error
->elem
+ elem_len
);
1173 ipw_capture_event_log(priv
, log_len
, error
->log
);
1176 ipw_read_indirect(priv
, base
+ sizeof(base
), (u8
*) error
->elem
,
1177 sizeof(*error
->elem
) * elem_len
);
1182 static void ipw_free_error_log(struct ipw_fw_error
*error
)
1188 static ssize_t
show_event_log(struct device
*d
,
1189 struct device_attribute
*attr
, char *buf
)
1191 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1192 u32 log_len
= ipw_get_event_log_len(priv
);
1193 struct ipw_event log
[log_len
];
1196 ipw_capture_event_log(priv
, log_len
, log
);
1198 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "%08X", log_len
);
1199 for (i
= 0; i
< log_len
; i
++)
1200 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1202 log
[i
].time
, log
[i
].event
, log
[i
].data
);
1203 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
1207 static DEVICE_ATTR(event_log
, S_IRUGO
, show_event_log
, NULL
);
1209 static ssize_t
show_error(struct device
*d
,
1210 struct device_attribute
*attr
, char *buf
)
1212 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1216 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1217 "%08lX%08X%08X%08X",
1218 priv
->error
->jiffies
,
1219 priv
->error
->status
,
1220 priv
->error
->config
, priv
->error
->elem_len
);
1221 for (i
= 0; i
< priv
->error
->elem_len
; i
++)
1222 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1223 "\n%08X%08X%08X%08X%08X%08X%08X",
1224 priv
->error
->elem
[i
].time
,
1225 priv
->error
->elem
[i
].desc
,
1226 priv
->error
->elem
[i
].blink1
,
1227 priv
->error
->elem
[i
].blink2
,
1228 priv
->error
->elem
[i
].link1
,
1229 priv
->error
->elem
[i
].link2
,
1230 priv
->error
->elem
[i
].data
);
1232 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1233 "\n%08X", priv
->error
->log_len
);
1234 for (i
= 0; i
< priv
->error
->log_len
; i
++)
1235 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1237 priv
->error
->log
[i
].time
,
1238 priv
->error
->log
[i
].event
,
1239 priv
->error
->log
[i
].data
);
1240 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
1244 static ssize_t
clear_error(struct device
*d
,
1245 struct device_attribute
*attr
,
1246 const char *buf
, size_t count
)
1248 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1250 ipw_free_error_log(priv
->error
);
1256 static DEVICE_ATTR(error
, S_IRUGO
| S_IWUSR
, show_error
, clear_error
);
1258 static ssize_t
show_cmd_log(struct device
*d
,
1259 struct device_attribute
*attr
, char *buf
)
1261 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1265 for (i
= (priv
->cmdlog_pos
+ 1) % priv
->cmdlog_len
;
1266 (i
!= priv
->cmdlog_pos
) && (PAGE_SIZE
- len
);
1267 i
= (i
+ 1) % priv
->cmdlog_len
) {
1269 snprintf(buf
+ len
, PAGE_SIZE
- len
,
1270 "\n%08lX%08X%08X%08X\n", priv
->cmdlog
[i
].jiffies
,
1271 priv
->cmdlog
[i
].retcode
, priv
->cmdlog
[i
].cmd
.cmd
,
1272 priv
->cmdlog
[i
].cmd
.len
);
1274 snprintk_buf(buf
+ len
, PAGE_SIZE
- len
,
1275 (u8
*) priv
->cmdlog
[i
].cmd
.param
,
1276 priv
->cmdlog
[i
].cmd
.len
);
1277 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
1279 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
1283 static DEVICE_ATTR(cmd_log
, S_IRUGO
, show_cmd_log
, NULL
);
1285 static ssize_t
show_scan_age(struct device
*d
, struct device_attribute
*attr
,
1288 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1289 return sprintf(buf
, "%d\n", priv
->ieee
->scan_age
);
1292 static ssize_t
store_scan_age(struct device
*d
, struct device_attribute
*attr
,
1293 const char *buf
, size_t count
)
1295 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1296 #ifdef CONFIG_IPW2200_DEBUG
1297 struct net_device
*dev
= priv
->net_dev
;
1299 char buffer
[] = "00000000";
1301 (sizeof(buffer
) - 1) > count
? count
: sizeof(buffer
) - 1;
1305 IPW_DEBUG_INFO("enter\n");
1307 strncpy(buffer
, buf
, len
);
1310 if (p
[1] == 'x' || p
[1] == 'X' || p
[0] == 'x' || p
[0] == 'X') {
1312 if (p
[0] == 'x' || p
[0] == 'X')
1314 val
= simple_strtoul(p
, &p
, 16);
1316 val
= simple_strtoul(p
, &p
, 10);
1318 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev
->name
);
1320 priv
->ieee
->scan_age
= val
;
1321 IPW_DEBUG_INFO("set scan_age = %u\n", priv
->ieee
->scan_age
);
1324 IPW_DEBUG_INFO("exit\n");
1328 static DEVICE_ATTR(scan_age
, S_IWUSR
| S_IRUGO
, show_scan_age
, store_scan_age
);
1330 static ssize_t
show_led(struct device
*d
, struct device_attribute
*attr
,
1333 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1334 return sprintf(buf
, "%d\n", (priv
->config
& CFG_NO_LED
) ? 0 : 1);
1337 static ssize_t
store_led(struct device
*d
, struct device_attribute
*attr
,
1338 const char *buf
, size_t count
)
1340 struct ipw_priv
*priv
= dev_get_drvdata(d
);
1342 IPW_DEBUG_INFO("enter\n");
1348 IPW_DEBUG_LED("Disabling LED control.\n");
1349 priv
->config
|= CFG_NO_LED
;
1350 ipw_led_shutdown(priv
);
1352 IPW_DEBUG_LED("Enabling LED control.\n");
1353 priv
->config
&= ~CFG_NO_LED
;
1357 IPW_DEBUG_INFO("exit\n");
1361 static DEVICE_ATTR(led
, S_IWUSR
| S_IRUGO
, show_led
, store_led
);
1363 static ssize_t
show_status(struct device
*d
,
1364 struct device_attribute
*attr
, char *buf
)
1366 struct ipw_priv
*p
= d
->driver_data
;
1367 return sprintf(buf
, "0x%08x\n", (int)p
->status
);
1370 static DEVICE_ATTR(status
, S_IRUGO
, show_status
, NULL
);
1372 static ssize_t
show_cfg(struct device
*d
, struct device_attribute
*attr
,
1375 struct ipw_priv
*p
= d
->driver_data
;
1376 return sprintf(buf
, "0x%08x\n", (int)p
->config
);
1379 static DEVICE_ATTR(cfg
, S_IRUGO
, show_cfg
, NULL
);
1381 static ssize_t
show_nic_type(struct device
*d
,
1382 struct device_attribute
*attr
, char *buf
)
1384 struct ipw_priv
*priv
= d
->driver_data
;
1385 return sprintf(buf
, "TYPE: %d\n", priv
->nic_type
);
1388 static DEVICE_ATTR(nic_type
, S_IRUGO
, show_nic_type
, NULL
);
1390 static ssize_t
show_ucode_version(struct device
*d
,
1391 struct device_attribute
*attr
, char *buf
)
1393 u32 len
= sizeof(u32
), tmp
= 0;
1394 struct ipw_priv
*p
= d
->driver_data
;
1396 if (ipw_get_ordinal(p
, IPW_ORD_STAT_UCODE_VERSION
, &tmp
, &len
))
1399 return sprintf(buf
, "0x%08x\n", tmp
);
1402 static DEVICE_ATTR(ucode_version
, S_IWUSR
| S_IRUGO
, show_ucode_version
, NULL
);
1404 static ssize_t
show_rtc(struct device
*d
, struct device_attribute
*attr
,
1407 u32 len
= sizeof(u32
), tmp
= 0;
1408 struct ipw_priv
*p
= d
->driver_data
;
1410 if (ipw_get_ordinal(p
, IPW_ORD_STAT_RTC
, &tmp
, &len
))
1413 return sprintf(buf
, "0x%08x\n", tmp
);
1416 static DEVICE_ATTR(rtc
, S_IWUSR
| S_IRUGO
, show_rtc
, NULL
);
1419 * Add a device attribute to view/control the delay between eeprom
1422 static ssize_t
show_eeprom_delay(struct device
*d
,
1423 struct device_attribute
*attr
, char *buf
)
1425 int n
= ((struct ipw_priv
*)d
->driver_data
)->eeprom_delay
;
1426 return sprintf(buf
, "%i\n", n
);
1428 static ssize_t
store_eeprom_delay(struct device
*d
,
1429 struct device_attribute
*attr
,
1430 const char *buf
, size_t count
)
1432 struct ipw_priv
*p
= d
->driver_data
;
1433 sscanf(buf
, "%i", &p
->eeprom_delay
);
1434 return strnlen(buf
, count
);
1437 static DEVICE_ATTR(eeprom_delay
, S_IWUSR
| S_IRUGO
,
1438 show_eeprom_delay
, store_eeprom_delay
);
1440 static ssize_t
show_command_event_reg(struct device
*d
,
1441 struct device_attribute
*attr
, char *buf
)
1444 struct ipw_priv
*p
= d
->driver_data
;
1446 reg
= ipw_read_reg32(p
, IPW_INTERNAL_CMD_EVENT
);
1447 return sprintf(buf
, "0x%08x\n", reg
);
1449 static ssize_t
store_command_event_reg(struct device
*d
,
1450 struct device_attribute
*attr
,
1451 const char *buf
, size_t count
)
1454 struct ipw_priv
*p
= d
->driver_data
;
1456 sscanf(buf
, "%x", ®
);
1457 ipw_write_reg32(p
, IPW_INTERNAL_CMD_EVENT
, reg
);
1458 return strnlen(buf
, count
);
1461 static DEVICE_ATTR(command_event_reg
, S_IWUSR
| S_IRUGO
,
1462 show_command_event_reg
, store_command_event_reg
);
1464 static ssize_t
show_mem_gpio_reg(struct device
*d
,
1465 struct device_attribute
*attr
, char *buf
)
1468 struct ipw_priv
*p
= d
->driver_data
;
1470 reg
= ipw_read_reg32(p
, 0x301100);
1471 return sprintf(buf
, "0x%08x\n", reg
);
1473 static ssize_t
store_mem_gpio_reg(struct device
*d
,
1474 struct device_attribute
*attr
,
1475 const char *buf
, size_t count
)
1478 struct ipw_priv
*p
= d
->driver_data
;
1480 sscanf(buf
, "%x", ®
);
1481 ipw_write_reg32(p
, 0x301100, reg
);
1482 return strnlen(buf
, count
);
1485 static DEVICE_ATTR(mem_gpio_reg
, S_IWUSR
| S_IRUGO
,
1486 show_mem_gpio_reg
, store_mem_gpio_reg
);
1488 static ssize_t
show_indirect_dword(struct device
*d
,
1489 struct device_attribute
*attr
, char *buf
)
1492 struct ipw_priv
*priv
= d
->driver_data
;
1494 if (priv
->status
& STATUS_INDIRECT_DWORD
)
1495 reg
= ipw_read_reg32(priv
, priv
->indirect_dword
);
1499 return sprintf(buf
, "0x%08x\n", reg
);
1501 static ssize_t
store_indirect_dword(struct device
*d
,
1502 struct device_attribute
*attr
,
1503 const char *buf
, size_t count
)
1505 struct ipw_priv
*priv
= d
->driver_data
;
1507 sscanf(buf
, "%x", &priv
->indirect_dword
);
1508 priv
->status
|= STATUS_INDIRECT_DWORD
;
1509 return strnlen(buf
, count
);
1512 static DEVICE_ATTR(indirect_dword
, S_IWUSR
| S_IRUGO
,
1513 show_indirect_dword
, store_indirect_dword
);
1515 static ssize_t
show_indirect_byte(struct device
*d
,
1516 struct device_attribute
*attr
, char *buf
)
1519 struct ipw_priv
*priv
= d
->driver_data
;
1521 if (priv
->status
& STATUS_INDIRECT_BYTE
)
1522 reg
= ipw_read_reg8(priv
, priv
->indirect_byte
);
1526 return sprintf(buf
, "0x%02x\n", reg
);
1528 static ssize_t
store_indirect_byte(struct device
*d
,
1529 struct device_attribute
*attr
,
1530 const char *buf
, size_t count
)
1532 struct ipw_priv
*priv
= d
->driver_data
;
1534 sscanf(buf
, "%x", &priv
->indirect_byte
);
1535 priv
->status
|= STATUS_INDIRECT_BYTE
;
1536 return strnlen(buf
, count
);
1539 static DEVICE_ATTR(indirect_byte
, S_IWUSR
| S_IRUGO
,
1540 show_indirect_byte
, store_indirect_byte
);
1542 static ssize_t
show_direct_dword(struct device
*d
,
1543 struct device_attribute
*attr
, char *buf
)
1546 struct ipw_priv
*priv
= d
->driver_data
;
1548 if (priv
->status
& STATUS_DIRECT_DWORD
)
1549 reg
= ipw_read32(priv
, priv
->direct_dword
);
1553 return sprintf(buf
, "0x%08x\n", reg
);
1555 static ssize_t
store_direct_dword(struct device
*d
,
1556 struct device_attribute
*attr
,
1557 const char *buf
, size_t count
)
1559 struct ipw_priv
*priv
= d
->driver_data
;
1561 sscanf(buf
, "%x", &priv
->direct_dword
);
1562 priv
->status
|= STATUS_DIRECT_DWORD
;
1563 return strnlen(buf
, count
);
1566 static DEVICE_ATTR(direct_dword
, S_IWUSR
| S_IRUGO
,
1567 show_direct_dword
, store_direct_dword
);
1569 static int rf_kill_active(struct ipw_priv
*priv
)
1571 if (0 == (ipw_read32(priv
, 0x30) & 0x10000))
1572 priv
->status
|= STATUS_RF_KILL_HW
;
1574 priv
->status
&= ~STATUS_RF_KILL_HW
;
1576 return (priv
->status
& STATUS_RF_KILL_HW
) ? 1 : 0;
1579 static ssize_t
show_rf_kill(struct device
*d
, struct device_attribute
*attr
,
1582 /* 0 - RF kill not enabled
1583 1 - SW based RF kill active (sysfs)
1584 2 - HW based RF kill active
1585 3 - Both HW and SW baed RF kill active */
1586 struct ipw_priv
*priv
= d
->driver_data
;
1587 int val
= ((priv
->status
& STATUS_RF_KILL_SW
) ? 0x1 : 0x0) |
1588 (rf_kill_active(priv
) ? 0x2 : 0x0);
1589 return sprintf(buf
, "%i\n", val
);
1592 static int ipw_radio_kill_sw(struct ipw_priv
*priv
, int disable_radio
)
1594 if ((disable_radio
? 1 : 0) ==
1595 ((priv
->status
& STATUS_RF_KILL_SW
) ? 1 : 0))
1598 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n",
1599 disable_radio
? "OFF" : "ON");
1601 if (disable_radio
) {
1602 priv
->status
|= STATUS_RF_KILL_SW
;
1604 if (priv
->workqueue
)
1605 cancel_delayed_work(&priv
->request_scan
);
1606 queue_work(priv
->workqueue
, &priv
->down
);
1608 priv
->status
&= ~STATUS_RF_KILL_SW
;
1609 if (rf_kill_active(priv
)) {
1610 IPW_DEBUG_RF_KILL("Can not turn radio back on - "
1611 "disabled by HW switch\n");
1612 /* Make sure the RF_KILL check timer is running */
1613 cancel_delayed_work(&priv
->rf_kill
);
1614 queue_delayed_work(priv
->workqueue
, &priv
->rf_kill
,
1617 queue_work(priv
->workqueue
, &priv
->up
);
1623 static ssize_t
store_rf_kill(struct device
*d
, struct device_attribute
*attr
,
1624 const char *buf
, size_t count
)
1626 struct ipw_priv
*priv
= d
->driver_data
;
1628 ipw_radio_kill_sw(priv
, buf
[0] == '1');
1633 static DEVICE_ATTR(rf_kill
, S_IWUSR
| S_IRUGO
, show_rf_kill
, store_rf_kill
);
1635 static ssize_t
show_speed_scan(struct device
*d
, struct device_attribute
*attr
,
1638 struct ipw_priv
*priv
= (struct ipw_priv
*)d
->driver_data
;
1639 int pos
= 0, len
= 0;
1640 if (priv
->config
& CFG_SPEED_SCAN
) {
1641 while (priv
->speed_scan
[pos
] != 0)
1642 len
+= sprintf(&buf
[len
], "%d ",
1643 priv
->speed_scan
[pos
++]);
1644 return len
+ sprintf(&buf
[len
], "\n");
1647 return sprintf(buf
, "0\n");
1650 static ssize_t
store_speed_scan(struct device
*d
, struct device_attribute
*attr
,
1651 const char *buf
, size_t count
)
1653 struct ipw_priv
*priv
= (struct ipw_priv
*)d
->driver_data
;
1654 int channel
, pos
= 0;
1655 const char *p
= buf
;
1657 /* list of space separated channels to scan, optionally ending with 0 */
1658 while ((channel
= simple_strtol(p
, NULL
, 0))) {
1659 if (pos
== MAX_SPEED_SCAN
- 1) {
1660 priv
->speed_scan
[pos
] = 0;
1664 if (ipw_is_valid_channel(priv
->ieee
, channel
))
1665 priv
->speed_scan
[pos
++] = channel
;
1667 IPW_WARNING("Skipping invalid channel request: %d\n",
1672 while (*p
== ' ' || *p
== '\t')
1677 priv
->config
&= ~CFG_SPEED_SCAN
;
1679 priv
->speed_scan_pos
= 0;
1680 priv
->config
|= CFG_SPEED_SCAN
;
1686 static DEVICE_ATTR(speed_scan
, S_IWUSR
| S_IRUGO
, show_speed_scan
,
1689 static ssize_t
show_net_stats(struct device
*d
, struct device_attribute
*attr
,
1692 struct ipw_priv
*priv
= (struct ipw_priv
*)d
->driver_data
;
1693 return sprintf(buf
, "%c\n", (priv
->config
& CFG_NET_STATS
) ? '1' : '0');
1696 static ssize_t
store_net_stats(struct device
*d
, struct device_attribute
*attr
,
1697 const char *buf
, size_t count
)
1699 struct ipw_priv
*priv
= (struct ipw_priv
*)d
->driver_data
;
1701 priv
->config
|= CFG_NET_STATS
;
1703 priv
->config
&= ~CFG_NET_STATS
;
1708 static DEVICE_ATTR(net_stats
, S_IWUSR
| S_IRUGO
,
1709 show_net_stats
, store_net_stats
);
1711 static void notify_wx_assoc_event(struct ipw_priv
*priv
)
1713 union iwreq_data wrqu
;
1714 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1715 if (priv
->status
& STATUS_ASSOCIATED
)
1716 memcpy(wrqu
.ap_addr
.sa_data
, priv
->bssid
, ETH_ALEN
);
1718 memset(wrqu
.ap_addr
.sa_data
, 0, ETH_ALEN
);
1719 wireless_send_event(priv
->net_dev
, SIOCGIWAP
, &wrqu
, NULL
);
1722 static void ipw_irq_tasklet(struct ipw_priv
*priv
)
1724 u32 inta
, inta_mask
, handled
= 0;
1725 unsigned long flags
;
1728 spin_lock_irqsave(&priv
->lock
, flags
);
1730 inta
= ipw_read32(priv
, IPW_INTA_RW
);
1731 inta_mask
= ipw_read32(priv
, IPW_INTA_MASK_R
);
1732 inta
&= (IPW_INTA_MASK_ALL
& inta_mask
);
1734 /* Add any cached INTA values that need to be handled */
1735 inta
|= priv
->isr_inta
;
1737 /* handle all the justifications for the interrupt */
1738 if (inta
& IPW_INTA_BIT_RX_TRANSFER
) {
1740 handled
|= IPW_INTA_BIT_RX_TRANSFER
;
1743 if (inta
& IPW_INTA_BIT_TX_CMD_QUEUE
) {
1744 IPW_DEBUG_HC("Command completed.\n");
1745 rc
= ipw_queue_tx_reclaim(priv
, &priv
->txq_cmd
, -1);
1746 priv
->status
&= ~STATUS_HCMD_ACTIVE
;
1747 wake_up_interruptible(&priv
->wait_command_queue
);
1748 handled
|= IPW_INTA_BIT_TX_CMD_QUEUE
;
1751 if (inta
& IPW_INTA_BIT_TX_QUEUE_1
) {
1752 IPW_DEBUG_TX("TX_QUEUE_1\n");
1753 rc
= ipw_queue_tx_reclaim(priv
, &priv
->txq
[0], 0);
1754 handled
|= IPW_INTA_BIT_TX_QUEUE_1
;
1757 if (inta
& IPW_INTA_BIT_TX_QUEUE_2
) {
1758 IPW_DEBUG_TX("TX_QUEUE_2\n");
1759 rc
= ipw_queue_tx_reclaim(priv
, &priv
->txq
[1], 1);
1760 handled
|= IPW_INTA_BIT_TX_QUEUE_2
;
1763 if (inta
& IPW_INTA_BIT_TX_QUEUE_3
) {
1764 IPW_DEBUG_TX("TX_QUEUE_3\n");
1765 rc
= ipw_queue_tx_reclaim(priv
, &priv
->txq
[2], 2);
1766 handled
|= IPW_INTA_BIT_TX_QUEUE_3
;
1769 if (inta
& IPW_INTA_BIT_TX_QUEUE_4
) {
1770 IPW_DEBUG_TX("TX_QUEUE_4\n");
1771 rc
= ipw_queue_tx_reclaim(priv
, &priv
->txq
[3], 3);
1772 handled
|= IPW_INTA_BIT_TX_QUEUE_4
;
1775 if (inta
& IPW_INTA_BIT_STATUS_CHANGE
) {
1776 IPW_WARNING("STATUS_CHANGE\n");
1777 handled
|= IPW_INTA_BIT_STATUS_CHANGE
;
1780 if (inta
& IPW_INTA_BIT_BEACON_PERIOD_EXPIRED
) {
1781 IPW_WARNING("TX_PERIOD_EXPIRED\n");
1782 handled
|= IPW_INTA_BIT_BEACON_PERIOD_EXPIRED
;
1785 if (inta
& IPW_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE
) {
1786 IPW_WARNING("HOST_CMD_DONE\n");
1787 handled
|= IPW_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE
;
1790 if (inta
& IPW_INTA_BIT_FW_INITIALIZATION_DONE
) {
1791 IPW_WARNING("FW_INITIALIZATION_DONE\n");
1792 handled
|= IPW_INTA_BIT_FW_INITIALIZATION_DONE
;
1795 if (inta
& IPW_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE
) {
1796 IPW_WARNING("PHY_OFF_DONE\n");
1797 handled
|= IPW_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE
;
1800 if (inta
& IPW_INTA_BIT_RF_KILL_DONE
) {
1801 IPW_DEBUG_RF_KILL("RF_KILL_DONE\n");
1802 priv
->status
|= STATUS_RF_KILL_HW
;
1803 wake_up_interruptible(&priv
->wait_command_queue
);
1804 priv
->status
&= ~(STATUS_ASSOCIATED
| STATUS_ASSOCIATING
);
1805 cancel_delayed_work(&priv
->request_scan
);
1806 schedule_work(&priv
->link_down
);
1807 queue_delayed_work(priv
->workqueue
, &priv
->rf_kill
, 2 * HZ
);
1808 handled
|= IPW_INTA_BIT_RF_KILL_DONE
;
1811 if (inta
& IPW_INTA_BIT_FATAL_ERROR
) {
1812 IPW_ERROR("Firmware error detected. Restarting.\n");
1814 IPW_ERROR("Sysfs 'error' log already exists.\n");
1815 #ifdef CONFIG_IPW2200_DEBUG
1816 if (ipw_debug_level
& IPW_DL_FW_ERRORS
) {
1817 struct ipw_fw_error
*error
=
1818 ipw_alloc_error_log(priv
);
1819 ipw_dump_error_log(priv
, error
);
1821 ipw_free_error_log(error
);
1825 priv
->error
= ipw_alloc_error_log(priv
);
1827 IPW_ERROR("Sysfs 'error' log captured.\n");
1829 IPW_ERROR("Error allocating sysfs 'error' "
1831 #ifdef CONFIG_IPW2200_DEBUG
1832 if (ipw_debug_level
& IPW_DL_FW_ERRORS
)
1833 ipw_dump_error_log(priv
, priv
->error
);
1837 /* XXX: If hardware encryption is for WPA/WPA2,
1838 * we have to notify the supplicant. */
1839 if (priv
->ieee
->sec
.encrypt
) {
1840 priv
->status
&= ~STATUS_ASSOCIATED
;
1841 notify_wx_assoc_event(priv
);
1844 /* Keep the restart process from trying to send host
1845 * commands by clearing the INIT status bit */
1846 priv
->status
&= ~STATUS_INIT
;
1848 /* Cancel currently queued command. */
1849 priv
->status
&= ~STATUS_HCMD_ACTIVE
;
1850 wake_up_interruptible(&priv
->wait_command_queue
);
1852 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
1853 handled
|= IPW_INTA_BIT_FATAL_ERROR
;
1856 if (inta
& IPW_INTA_BIT_PARITY_ERROR
) {
1857 IPW_ERROR("Parity error\n");
1858 handled
|= IPW_INTA_BIT_PARITY_ERROR
;
1861 if (handled
!= inta
) {
1862 IPW_ERROR("Unhandled INTA bits 0x%08x\n", inta
& ~handled
);
1865 /* enable all interrupts */
1866 ipw_enable_interrupts(priv
);
1868 spin_unlock_irqrestore(&priv
->lock
, flags
);
1871 #define IPW_CMD(x) case IPW_CMD_ ## x : return #x
1872 static char *get_cmd_string(u8 cmd
)
1875 IPW_CMD(HOST_COMPLETE
);
1876 IPW_CMD(POWER_DOWN
);
1877 IPW_CMD(SYSTEM_CONFIG
);
1878 IPW_CMD(MULTICAST_ADDRESS
);
1880 IPW_CMD(ADAPTER_ADDRESS
);
1882 IPW_CMD(RTS_THRESHOLD
);
1883 IPW_CMD(FRAG_THRESHOLD
);
1884 IPW_CMD(POWER_MODE
);
1886 IPW_CMD(TGI_TX_KEY
);
1887 IPW_CMD(SCAN_REQUEST
);
1888 IPW_CMD(SCAN_REQUEST_EXT
);
1890 IPW_CMD(SUPPORTED_RATES
);
1891 IPW_CMD(SCAN_ABORT
);
1893 IPW_CMD(QOS_PARAMETERS
);
1894 IPW_CMD(DINO_CONFIG
);
1895 IPW_CMD(RSN_CAPABILITIES
);
1897 IPW_CMD(CARD_DISABLE
);
1898 IPW_CMD(SEED_NUMBER
);
1900 IPW_CMD(COUNTRY_INFO
);
1901 IPW_CMD(AIRONET_INFO
);
1902 IPW_CMD(AP_TX_POWER
);
1904 IPW_CMD(CCX_VER_INFO
);
1905 IPW_CMD(SET_CALIBRATION
);
1906 IPW_CMD(SENSITIVITY_CALIB
);
1907 IPW_CMD(RETRY_LIMIT
);
1908 IPW_CMD(IPW_PRE_POWER_DOWN
);
1909 IPW_CMD(VAP_BEACON_TEMPLATE
);
1910 IPW_CMD(VAP_DTIM_PERIOD
);
1911 IPW_CMD(EXT_SUPPORTED_RATES
);
1912 IPW_CMD(VAP_LOCAL_TX_PWR_CONSTRAINT
);
1913 IPW_CMD(VAP_QUIET_INTERVALS
);
1914 IPW_CMD(VAP_CHANNEL_SWITCH
);
1915 IPW_CMD(VAP_MANDATORY_CHANNELS
);
1916 IPW_CMD(VAP_CELL_PWR_LIMIT
);
1917 IPW_CMD(VAP_CF_PARAM_SET
);
1918 IPW_CMD(VAP_SET_BEACONING_STATE
);
1919 IPW_CMD(MEASUREMENT
);
1920 IPW_CMD(POWER_CAPABILITY
);
1921 IPW_CMD(SUPPORTED_CHANNELS
);
1922 IPW_CMD(TPC_REPORT
);
1924 IPW_CMD(PRODUCTION_COMMAND
);
1930 #define HOST_COMPLETE_TIMEOUT HZ
1932 static int __ipw_send_cmd(struct ipw_priv
*priv
, struct host_cmd
*cmd
)
1935 unsigned long flags
;
1937 spin_lock_irqsave(&priv
->lock
, flags
);
1938 if (priv
->status
& STATUS_HCMD_ACTIVE
) {
1939 IPW_ERROR("Failed to send %s: Already sending a command.\n",
1940 get_cmd_string(cmd
->cmd
));
1941 spin_unlock_irqrestore(&priv
->lock
, flags
);
1945 priv
->status
|= STATUS_HCMD_ACTIVE
;
1948 priv
->cmdlog
[priv
->cmdlog_pos
].jiffies
= jiffies
;
1949 priv
->cmdlog
[priv
->cmdlog_pos
].cmd
.cmd
= cmd
->cmd
;
1950 priv
->cmdlog
[priv
->cmdlog_pos
].cmd
.len
= cmd
->len
;
1951 memcpy(priv
->cmdlog
[priv
->cmdlog_pos
].cmd
.param
, cmd
->param
,
1953 priv
->cmdlog
[priv
->cmdlog_pos
].retcode
= -1;
1956 IPW_DEBUG_HC("%s command (#%d) %d bytes: 0x%08X\n",
1957 get_cmd_string(cmd
->cmd
), cmd
->cmd
, cmd
->len
,
1960 #ifndef DEBUG_CMD_WEP_KEY
1961 if (cmd
->cmd
== IPW_CMD_WEP_KEY
)
1962 IPW_DEBUG_HC("WEP_KEY command masked out for secure.\n");
1965 printk_buf(IPW_DL_HOST_COMMAND
, (u8
*) cmd
->param
, cmd
->len
);
1968 rc
= ipw_queue_tx_hcmd(priv
, cmd
->cmd
, cmd
->param
, cmd
->len
, 0);
1970 priv
->status
&= ~STATUS_HCMD_ACTIVE
;
1971 IPW_ERROR("Failed to send %s: Reason %d\n",
1972 get_cmd_string(cmd
->cmd
), rc
);
1973 spin_unlock_irqrestore(&priv
->lock
, flags
);
1976 spin_unlock_irqrestore(&priv
->lock
, flags
);
1978 rc
= wait_event_interruptible_timeout(priv
->wait_command_queue
,
1980 status
& STATUS_HCMD_ACTIVE
),
1981 HOST_COMPLETE_TIMEOUT
);
1983 spin_lock_irqsave(&priv
->lock
, flags
);
1984 if (priv
->status
& STATUS_HCMD_ACTIVE
) {
1985 IPW_ERROR("Failed to send %s: Command timed out.\n",
1986 get_cmd_string(cmd
->cmd
));
1987 priv
->status
&= ~STATUS_HCMD_ACTIVE
;
1988 spin_unlock_irqrestore(&priv
->lock
, flags
);
1992 spin_unlock_irqrestore(&priv
->lock
, flags
);
1996 if (priv
->status
& STATUS_RF_KILL_HW
) {
1997 IPW_ERROR("Failed to send %s: Aborted due to RF kill switch.\n",
1998 get_cmd_string(cmd
->cmd
));
2005 priv
->cmdlog
[priv
->cmdlog_pos
++].retcode
= rc
;
2006 priv
->cmdlog_pos
%= priv
->cmdlog_len
;
2011 static int ipw_send_cmd_simple(struct ipw_priv
*priv
, u8 command
)
2013 struct host_cmd cmd
= {
2017 return __ipw_send_cmd(priv
, &cmd
);
2020 static int ipw_send_cmd_pdu(struct ipw_priv
*priv
, u8 command
, u8 len
,
2023 struct host_cmd cmd
= {
2029 return __ipw_send_cmd(priv
, &cmd
);
2032 static int ipw_send_host_complete(struct ipw_priv
*priv
)
2035 IPW_ERROR("Invalid args\n");
2039 return ipw_send_cmd_simple(priv
, IPW_CMD_HOST_COMPLETE
);
2042 static int ipw_send_system_config(struct ipw_priv
*priv
,
2043 struct ipw_sys_config
*config
)
2045 if (!priv
|| !config
) {
2046 IPW_ERROR("Invalid args\n");
2050 return ipw_send_cmd_pdu(priv
, IPW_CMD_SYSTEM_CONFIG
, sizeof(*config
),
2054 static int ipw_send_ssid(struct ipw_priv
*priv
, u8
* ssid
, int len
)
2056 if (!priv
|| !ssid
) {
2057 IPW_ERROR("Invalid args\n");
2061 return ipw_send_cmd_pdu(priv
, IPW_CMD_SSID
, min(len
, IW_ESSID_MAX_SIZE
),
2065 static int ipw_send_adapter_address(struct ipw_priv
*priv
, u8
* mac
)
2067 if (!priv
|| !mac
) {
2068 IPW_ERROR("Invalid args\n");
2072 IPW_DEBUG_INFO("%s: Setting MAC to " MAC_FMT
"\n",
2073 priv
->net_dev
->name
, MAC_ARG(mac
));
2075 return ipw_send_cmd_pdu(priv
, IPW_CMD_ADAPTER_ADDRESS
, ETH_ALEN
,
2080 * NOTE: This must be executed from our workqueue as it results in udelay
2081 * being called which may corrupt the keyboard if executed on default
2084 static void ipw_adapter_restart(void *adapter
)
2086 struct ipw_priv
*priv
= adapter
;
2088 if (priv
->status
& STATUS_RF_KILL_MASK
)
2093 if (priv
->assoc_network
&&
2094 (priv
->assoc_network
->capability
& WLAN_CAPABILITY_IBSS
))
2095 ipw_remove_current_network(priv
);
2098 IPW_ERROR("Failed to up device\n");
2103 static void ipw_bg_adapter_restart(void *data
)
2105 struct ipw_priv
*priv
= data
;
2107 ipw_adapter_restart(data
);
2111 #define IPW_SCAN_CHECK_WATCHDOG (5 * HZ)
2113 static void ipw_scan_check(void *data
)
2115 struct ipw_priv
*priv
= data
;
2116 if (priv
->status
& (STATUS_SCANNING
| STATUS_SCAN_ABORTING
)) {
2117 IPW_DEBUG_SCAN("Scan completion watchdog resetting "
2118 "adapter after (%dms).\n",
2119 jiffies_to_msecs(IPW_SCAN_CHECK_WATCHDOG
));
2120 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
2124 static void ipw_bg_scan_check(void *data
)
2126 struct ipw_priv
*priv
= data
;
2128 ipw_scan_check(data
);
2132 static int ipw_send_scan_request_ext(struct ipw_priv
*priv
,
2133 struct ipw_scan_request_ext
*request
)
2135 return ipw_send_cmd_pdu(priv
, IPW_CMD_SCAN_REQUEST_EXT
,
2136 sizeof(*request
), request
);
2139 static int ipw_send_scan_abort(struct ipw_priv
*priv
)
2142 IPW_ERROR("Invalid args\n");
2146 return ipw_send_cmd_simple(priv
, IPW_CMD_SCAN_ABORT
);
2149 static int ipw_set_sensitivity(struct ipw_priv
*priv
, u16 sens
)
2151 struct ipw_sensitivity_calib calib
= {
2152 .beacon_rssi_raw
= sens
,
2155 return ipw_send_cmd_pdu(priv
, IPW_CMD_SENSITIVITY_CALIB
, sizeof(calib
),
2159 static int ipw_send_associate(struct ipw_priv
*priv
,
2160 struct ipw_associate
*associate
)
2162 struct ipw_associate tmp_associate
;
2164 if (!priv
|| !associate
) {
2165 IPW_ERROR("Invalid args\n");
2169 memcpy(&tmp_associate
, associate
, sizeof(*associate
));
2170 tmp_associate
.policy_support
=
2171 cpu_to_le16(tmp_associate
.policy_support
);
2172 tmp_associate
.assoc_tsf_msw
= cpu_to_le32(tmp_associate
.assoc_tsf_msw
);
2173 tmp_associate
.assoc_tsf_lsw
= cpu_to_le32(tmp_associate
.assoc_tsf_lsw
);
2174 tmp_associate
.capability
= cpu_to_le16(tmp_associate
.capability
);
2175 tmp_associate
.listen_interval
=
2176 cpu_to_le16(tmp_associate
.listen_interval
);
2177 tmp_associate
.beacon_interval
=
2178 cpu_to_le16(tmp_associate
.beacon_interval
);
2179 tmp_associate
.atim_window
= cpu_to_le16(tmp_associate
.atim_window
);
2181 return ipw_send_cmd_pdu(priv
, IPW_CMD_ASSOCIATE
, sizeof(tmp_associate
),
2185 static int ipw_send_supported_rates(struct ipw_priv
*priv
,
2186 struct ipw_supported_rates
*rates
)
2188 if (!priv
|| !rates
) {
2189 IPW_ERROR("Invalid args\n");
2193 return ipw_send_cmd_pdu(priv
, IPW_CMD_SUPPORTED_RATES
, sizeof(*rates
),
2197 static int ipw_set_random_seed(struct ipw_priv
*priv
)
2202 IPW_ERROR("Invalid args\n");
2206 get_random_bytes(&val
, sizeof(val
));
2208 return ipw_send_cmd_pdu(priv
, IPW_CMD_SEED_NUMBER
, sizeof(val
), &val
);
2211 static int ipw_send_card_disable(struct ipw_priv
*priv
, u32 phy_off
)
2214 IPW_ERROR("Invalid args\n");
2218 return ipw_send_cmd_pdu(priv
, IPW_CMD_CARD_DISABLE
, sizeof(phy_off
),
2222 static int ipw_send_tx_power(struct ipw_priv
*priv
, struct ipw_tx_power
*power
)
2224 if (!priv
|| !power
) {
2225 IPW_ERROR("Invalid args\n");
2229 return ipw_send_cmd_pdu(priv
, IPW_CMD_TX_POWER
, sizeof(*power
),
2233 static int ipw_set_tx_power(struct ipw_priv
*priv
)
2235 const struct ieee80211_geo
*geo
= ipw_get_geo(priv
->ieee
);
2236 struct ipw_tx_power tx_power
;
2240 memset(&tx_power
, 0, sizeof(tx_power
));
2242 /* configure device for 'G' band */
2243 tx_power
.ieee_mode
= IPW_G_MODE
;
2244 tx_power
.num_channels
= geo
->bg_channels
;
2245 for (i
= 0; i
< geo
->bg_channels
; i
++) {
2246 max_power
= geo
->bg
[i
].max_power
;
2247 tx_power
.channels_tx_power
[i
].channel_number
=
2249 tx_power
.channels_tx_power
[i
].tx_power
= max_power
?
2250 min(max_power
, priv
->tx_power
) : priv
->tx_power
;
2252 if (ipw_send_tx_power(priv
, &tx_power
))
2255 /* configure device to also handle 'B' band */
2256 tx_power
.ieee_mode
= IPW_B_MODE
;
2257 if (ipw_send_tx_power(priv
, &tx_power
))
2260 /* configure device to also handle 'A' band */
2261 if (priv
->ieee
->abg_true
) {
2262 tx_power
.ieee_mode
= IPW_A_MODE
;
2263 tx_power
.num_channels
= geo
->a_channels
;
2264 for (i
= 0; i
< tx_power
.num_channels
; i
++) {
2265 max_power
= geo
->a
[i
].max_power
;
2266 tx_power
.channels_tx_power
[i
].channel_number
=
2268 tx_power
.channels_tx_power
[i
].tx_power
= max_power
?
2269 min(max_power
, priv
->tx_power
) : priv
->tx_power
;
2271 if (ipw_send_tx_power(priv
, &tx_power
))
2277 static int ipw_send_rts_threshold(struct ipw_priv
*priv
, u16 rts
)
2279 struct ipw_rts_threshold rts_threshold
= {
2280 .rts_threshold
= rts
,
2284 IPW_ERROR("Invalid args\n");
2288 return ipw_send_cmd_pdu(priv
, IPW_CMD_RTS_THRESHOLD
,
2289 sizeof(rts_threshold
), &rts_threshold
);
2292 static int ipw_send_frag_threshold(struct ipw_priv
*priv
, u16 frag
)
2294 struct ipw_frag_threshold frag_threshold
= {
2295 .frag_threshold
= frag
,
2299 IPW_ERROR("Invalid args\n");
2303 return ipw_send_cmd_pdu(priv
, IPW_CMD_FRAG_THRESHOLD
,
2304 sizeof(frag_threshold
), &frag_threshold
);
2307 static int ipw_send_power_mode(struct ipw_priv
*priv
, u32 mode
)
2312 IPW_ERROR("Invalid args\n");
2316 /* If on battery, set to 3, if AC set to CAM, else user
2319 case IPW_POWER_BATTERY
:
2320 param
= IPW_POWER_INDEX_3
;
2323 param
= IPW_POWER_MODE_CAM
;
2330 return ipw_send_cmd_pdu(priv
, IPW_CMD_POWER_MODE
, sizeof(param
),
2334 static int ipw_send_retry_limit(struct ipw_priv
*priv
, u8 slimit
, u8 llimit
)
2336 struct ipw_retry_limit retry_limit
= {
2337 .short_retry_limit
= slimit
,
2338 .long_retry_limit
= llimit
2342 IPW_ERROR("Invalid args\n");
2346 return ipw_send_cmd_pdu(priv
, IPW_CMD_RETRY_LIMIT
, sizeof(retry_limit
),
2351 * The IPW device contains a Microwire compatible EEPROM that stores
2352 * various data like the MAC address. Usually the firmware has exclusive
2353 * access to the eeprom, but during device initialization (before the
2354 * device driver has sent the HostComplete command to the firmware) the
2355 * device driver has read access to the EEPROM by way of indirect addressing
2356 * through a couple of memory mapped registers.
2358 * The following is a simplified implementation for pulling data out of the
2359 * the eeprom, along with some helper functions to find information in
2360 * the per device private data's copy of the eeprom.
2362 * NOTE: To better understand how these functions work (i.e what is a chip
2363 * select and why do have to keep driving the eeprom clock?), read
2364 * just about any data sheet for a Microwire compatible EEPROM.
2367 /* write a 32 bit value into the indirect accessor register */
2368 static inline void eeprom_write_reg(struct ipw_priv
*p
, u32 data
)
2370 ipw_write_reg32(p
, FW_MEM_REG_EEPROM_ACCESS
, data
);
2372 /* the eeprom requires some time to complete the operation */
2373 udelay(p
->eeprom_delay
);
2378 /* perform a chip select operation */
2379 static void eeprom_cs(struct ipw_priv
*priv
)
2381 eeprom_write_reg(priv
, 0);
2382 eeprom_write_reg(priv
, EEPROM_BIT_CS
);
2383 eeprom_write_reg(priv
, EEPROM_BIT_CS
| EEPROM_BIT_SK
);
2384 eeprom_write_reg(priv
, EEPROM_BIT_CS
);
2387 /* perform a chip select operation */
2388 static void eeprom_disable_cs(struct ipw_priv
*priv
)
2390 eeprom_write_reg(priv
, EEPROM_BIT_CS
);
2391 eeprom_write_reg(priv
, 0);
2392 eeprom_write_reg(priv
, EEPROM_BIT_SK
);
2395 /* push a single bit down to the eeprom */
2396 static inline void eeprom_write_bit(struct ipw_priv
*p
, u8 bit
)
2398 int d
= (bit
? EEPROM_BIT_DI
: 0);
2399 eeprom_write_reg(p
, EEPROM_BIT_CS
| d
);
2400 eeprom_write_reg(p
, EEPROM_BIT_CS
| d
| EEPROM_BIT_SK
);
2403 /* push an opcode followed by an address down to the eeprom */
2404 static void eeprom_op(struct ipw_priv
*priv
, u8 op
, u8 addr
)
2409 eeprom_write_bit(priv
, 1);
2410 eeprom_write_bit(priv
, op
& 2);
2411 eeprom_write_bit(priv
, op
& 1);
2412 for (i
= 7; i
>= 0; i
--) {
2413 eeprom_write_bit(priv
, addr
& (1 << i
));
2417 /* pull 16 bits off the eeprom, one bit at a time */
2418 static u16
eeprom_read_u16(struct ipw_priv
*priv
, u8 addr
)
2423 /* Send READ Opcode */
2424 eeprom_op(priv
, EEPROM_CMD_READ
, addr
);
2426 /* Send dummy bit */
2427 eeprom_write_reg(priv
, EEPROM_BIT_CS
);
2429 /* Read the byte off the eeprom one bit at a time */
2430 for (i
= 0; i
< 16; i
++) {
2432 eeprom_write_reg(priv
, EEPROM_BIT_CS
| EEPROM_BIT_SK
);
2433 eeprom_write_reg(priv
, EEPROM_BIT_CS
);
2434 data
= ipw_read_reg32(priv
, FW_MEM_REG_EEPROM_ACCESS
);
2435 r
= (r
<< 1) | ((data
& EEPROM_BIT_DO
) ? 1 : 0);
2438 /* Send another dummy bit */
2439 eeprom_write_reg(priv
, 0);
2440 eeprom_disable_cs(priv
);
2445 /* helper function for pulling the mac address out of the private */
2446 /* data's copy of the eeprom data */
2447 static void eeprom_parse_mac(struct ipw_priv
*priv
, u8
* mac
)
2449 memcpy(mac
, &priv
->eeprom
[EEPROM_MAC_ADDRESS
], 6);
2453 * Either the device driver (i.e. the host) or the firmware can
2454 * load eeprom data into the designated region in SRAM. If neither
2455 * happens then the FW will shutdown with a fatal error.
2457 * In order to signal the FW to load the EEPROM, the EEPROM_LOAD_DISABLE
2458 * bit needs region of shared SRAM needs to be non-zero.
2460 static void ipw_eeprom_init_sram(struct ipw_priv
*priv
)
2463 u16
*eeprom
= (u16
*) priv
->eeprom
;
2465 IPW_DEBUG_TRACE(">>\n");
2467 /* read entire contents of eeprom into private buffer */
2468 for (i
= 0; i
< 128; i
++)
2469 eeprom
[i
] = le16_to_cpu(eeprom_read_u16(priv
, (u8
) i
));
2472 If the data looks correct, then copy it to our private
2473 copy. Otherwise let the firmware know to perform the operation
2476 if ((priv
->eeprom
+ EEPROM_VERSION
) != 0) {
2477 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
2479 /* write the eeprom data to sram */
2480 for (i
= 0; i
< IPW_EEPROM_IMAGE_SIZE
; i
++)
2481 ipw_write8(priv
, IPW_EEPROM_DATA
+ i
, priv
->eeprom
[i
]);
2483 /* Do not load eeprom data on fatal error or suspend */
2484 ipw_write32(priv
, IPW_EEPROM_LOAD_DISABLE
, 0);
2486 IPW_DEBUG_INFO("Enabling FW initializationg of SRAM\n");
2488 /* Load eeprom data on fatal error or suspend */
2489 ipw_write32(priv
, IPW_EEPROM_LOAD_DISABLE
, 1);
2492 IPW_DEBUG_TRACE("<<\n");
2495 static void ipw_zero_memory(struct ipw_priv
*priv
, u32 start
, u32 count
)
2500 _ipw_write32(priv
, IPW_AUTOINC_ADDR
, start
);
2502 _ipw_write32(priv
, IPW_AUTOINC_DATA
, 0);
2505 static inline void ipw_fw_dma_reset_command_blocks(struct ipw_priv
*priv
)
2507 ipw_zero_memory(priv
, IPW_SHARED_SRAM_DMA_CONTROL
,
2508 CB_NUMBER_OF_ELEMENTS_SMALL
*
2509 sizeof(struct command_block
));
2512 static int ipw_fw_dma_enable(struct ipw_priv
*priv
)
2513 { /* start dma engine but no transfers yet */
2515 IPW_DEBUG_FW(">> : \n");
2518 ipw_fw_dma_reset_command_blocks(priv
);
2520 /* Write CB base address */
2521 ipw_write_reg32(priv
, IPW_DMA_I_CB_BASE
, IPW_SHARED_SRAM_DMA_CONTROL
);
2523 IPW_DEBUG_FW("<< : \n");
2527 static void ipw_fw_dma_abort(struct ipw_priv
*priv
)
2531 IPW_DEBUG_FW(">> :\n");
2533 //set the Stop and Abort bit
2534 control
= DMA_CONTROL_SMALL_CB_CONST_VALUE
| DMA_CB_STOP_AND_ABORT
;
2535 ipw_write_reg32(priv
, IPW_DMA_I_DMA_CONTROL
, control
);
2536 priv
->sram_desc
.last_cb_index
= 0;
2538 IPW_DEBUG_FW("<< \n");
2541 static int ipw_fw_dma_write_command_block(struct ipw_priv
*priv
, int index
,
2542 struct command_block
*cb
)
2545 IPW_SHARED_SRAM_DMA_CONTROL
+
2546 (sizeof(struct command_block
) * index
);
2547 IPW_DEBUG_FW(">> :\n");
2549 ipw_write_indirect(priv
, address
, (u8
*) cb
,
2550 (int)sizeof(struct command_block
));
2552 IPW_DEBUG_FW("<< :\n");
2557 static int ipw_fw_dma_kick(struct ipw_priv
*priv
)
2562 IPW_DEBUG_FW(">> :\n");
2564 for (index
= 0; index
< priv
->sram_desc
.last_cb_index
; index
++)
2565 ipw_fw_dma_write_command_block(priv
, index
,
2566 &priv
->sram_desc
.cb_list
[index
]);
2568 /* Enable the DMA in the CSR register */
2569 ipw_clear_bit(priv
, IPW_RESET_REG
,
2570 IPW_RESET_REG_MASTER_DISABLED
|
2571 IPW_RESET_REG_STOP_MASTER
);
2573 /* Set the Start bit. */
2574 control
= DMA_CONTROL_SMALL_CB_CONST_VALUE
| DMA_CB_START
;
2575 ipw_write_reg32(priv
, IPW_DMA_I_DMA_CONTROL
, control
);
2577 IPW_DEBUG_FW("<< :\n");
2581 static void ipw_fw_dma_dump_command_block(struct ipw_priv
*priv
)
2584 u32 register_value
= 0;
2585 u32 cb_fields_address
= 0;
2587 IPW_DEBUG_FW(">> :\n");
2588 address
= ipw_read_reg32(priv
, IPW_DMA_I_CURRENT_CB
);
2589 IPW_DEBUG_FW_INFO("Current CB is 0x%x \n", address
);
2591 /* Read the DMA Controlor register */
2592 register_value
= ipw_read_reg32(priv
, IPW_DMA_I_DMA_CONTROL
);
2593 IPW_DEBUG_FW_INFO("IPW_DMA_I_DMA_CONTROL is 0x%x \n", register_value
);
2595 /* Print the CB values */
2596 cb_fields_address
= address
;
2597 register_value
= ipw_read_reg32(priv
, cb_fields_address
);
2598 IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n", register_value
);
2600 cb_fields_address
+= sizeof(u32
);
2601 register_value
= ipw_read_reg32(priv
, cb_fields_address
);
2602 IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n", register_value
);
2604 cb_fields_address
+= sizeof(u32
);
2605 register_value
= ipw_read_reg32(priv
, cb_fields_address
);
2606 IPW_DEBUG_FW_INFO("Current CB Destination Field is 0x%x \n",
2609 cb_fields_address
+= sizeof(u32
);
2610 register_value
= ipw_read_reg32(priv
, cb_fields_address
);
2611 IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n", register_value
);
2613 IPW_DEBUG_FW(">> :\n");
2616 static int ipw_fw_dma_command_block_index(struct ipw_priv
*priv
)
2618 u32 current_cb_address
= 0;
2619 u32 current_cb_index
= 0;
2621 IPW_DEBUG_FW("<< :\n");
2622 current_cb_address
= ipw_read_reg32(priv
, IPW_DMA_I_CURRENT_CB
);
2624 current_cb_index
= (current_cb_address
- IPW_SHARED_SRAM_DMA_CONTROL
) /
2625 sizeof(struct command_block
);
2627 IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n",
2628 current_cb_index
, current_cb_address
);
2630 IPW_DEBUG_FW(">> :\n");
2631 return current_cb_index
;
2635 static int ipw_fw_dma_add_command_block(struct ipw_priv
*priv
,
2639 int interrupt_enabled
, int is_last
)
2642 u32 control
= CB_VALID
| CB_SRC_LE
| CB_DEST_LE
| CB_SRC_AUTOINC
|
2643 CB_SRC_IO_GATED
| CB_DEST_AUTOINC
| CB_SRC_SIZE_LONG
|
2645 struct command_block
*cb
;
2646 u32 last_cb_element
= 0;
2648 IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n",
2649 src_address
, dest_address
, length
);
2651 if (priv
->sram_desc
.last_cb_index
>= CB_NUMBER_OF_ELEMENTS_SMALL
)
2654 last_cb_element
= priv
->sram_desc
.last_cb_index
;
2655 cb
= &priv
->sram_desc
.cb_list
[last_cb_element
];
2656 priv
->sram_desc
.last_cb_index
++;
2658 /* Calculate the new CB control word */
2659 if (interrupt_enabled
)
2660 control
|= CB_INT_ENABLED
;
2663 control
|= CB_LAST_VALID
;
2667 /* Calculate the CB Element's checksum value */
2668 cb
->status
= control
^ src_address
^ dest_address
;
2670 /* Copy the Source and Destination addresses */
2671 cb
->dest_addr
= dest_address
;
2672 cb
->source_addr
= src_address
;
2674 /* Copy the Control Word last */
2675 cb
->control
= control
;
2680 static int ipw_fw_dma_add_buffer(struct ipw_priv
*priv
,
2681 u32 src_phys
, u32 dest_address
, u32 length
)
2683 u32 bytes_left
= length
;
2685 u32 dest_offset
= 0;
2687 IPW_DEBUG_FW(">> \n");
2688 IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n",
2689 src_phys
, dest_address
, length
);
2690 while (bytes_left
> CB_MAX_LENGTH
) {
2691 status
= ipw_fw_dma_add_command_block(priv
,
2692 src_phys
+ src_offset
,
2695 CB_MAX_LENGTH
, 0, 0);
2697 IPW_DEBUG_FW_INFO(": Failed\n");
2700 IPW_DEBUG_FW_INFO(": Added new cb\n");
2702 src_offset
+= CB_MAX_LENGTH
;
2703 dest_offset
+= CB_MAX_LENGTH
;
2704 bytes_left
-= CB_MAX_LENGTH
;
2707 /* add the buffer tail */
2708 if (bytes_left
> 0) {
2710 ipw_fw_dma_add_command_block(priv
, src_phys
+ src_offset
,
2711 dest_address
+ dest_offset
,
2714 IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");
2718 (": Adding new cb - the buffer tail\n");
2721 IPW_DEBUG_FW("<< \n");
2725 static int ipw_fw_dma_wait(struct ipw_priv
*priv
)
2727 u32 current_index
= 0, previous_index
;
2730 IPW_DEBUG_FW(">> : \n");
2732 current_index
= ipw_fw_dma_command_block_index(priv
);
2733 IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%08X\n",
2734 (int)priv
->sram_desc
.last_cb_index
);
2736 while (current_index
< priv
->sram_desc
.last_cb_index
) {
2738 previous_index
= current_index
;
2739 current_index
= ipw_fw_dma_command_block_index(priv
);
2741 if (previous_index
< current_index
) {
2745 if (++watchdog
> 400) {
2746 IPW_DEBUG_FW_INFO("Timeout\n");
2747 ipw_fw_dma_dump_command_block(priv
);
2748 ipw_fw_dma_abort(priv
);
2753 ipw_fw_dma_abort(priv
);
2755 /*Disable the DMA in the CSR register */
2756 ipw_set_bit(priv
, IPW_RESET_REG
,
2757 IPW_RESET_REG_MASTER_DISABLED
| IPW_RESET_REG_STOP_MASTER
);
2759 IPW_DEBUG_FW("<< dmaWaitSync \n");
2763 static void ipw_remove_current_network(struct ipw_priv
*priv
)
2765 struct list_head
*element
, *safe
;
2766 struct ieee80211_network
*network
= NULL
;
2767 unsigned long flags
;
2769 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
2770 list_for_each_safe(element
, safe
, &priv
->ieee
->network_list
) {
2771 network
= list_entry(element
, struct ieee80211_network
, list
);
2772 if (!memcmp(network
->bssid
, priv
->bssid
, ETH_ALEN
)) {
2774 list_add_tail(&network
->list
,
2775 &priv
->ieee
->network_free_list
);
2778 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
2782 * Check that card is still alive.
2783 * Reads debug register from domain0.
2784 * If card is present, pre-defined value should
2788 * @return 1 if card is present, 0 otherwise
2790 static inline int ipw_alive(struct ipw_priv
*priv
)
2792 return ipw_read32(priv
, 0x90) == 0xd55555d5;
2795 /* timeout in msec, attempted in 10-msec quanta */
2796 static int ipw_poll_bit(struct ipw_priv
*priv
, u32 addr
, u32 mask
,
2802 if ((ipw_read32(priv
, addr
) & mask
) == mask
)
2806 } while (i
< timeout
);
2811 /* These functions load the firmware and micro code for the operation of
2812 * the ipw hardware. It assumes the buffer has all the bits for the
2813 * image and the caller is handling the memory allocation and clean up.
2816 static int ipw_stop_master(struct ipw_priv
*priv
)
2820 IPW_DEBUG_TRACE(">> \n");
2821 /* stop master. typical delay - 0 */
2822 ipw_set_bit(priv
, IPW_RESET_REG
, IPW_RESET_REG_STOP_MASTER
);
2824 /* timeout is in msec, polled in 10-msec quanta */
2825 rc
= ipw_poll_bit(priv
, IPW_RESET_REG
,
2826 IPW_RESET_REG_MASTER_DISABLED
, 100);
2828 IPW_ERROR("wait for stop master failed after 100ms\n");
2832 IPW_DEBUG_INFO("stop master %dms\n", rc
);
2837 static void ipw_arc_release(struct ipw_priv
*priv
)
2839 IPW_DEBUG_TRACE(">> \n");
2842 ipw_clear_bit(priv
, IPW_RESET_REG
, CBD_RESET_REG_PRINCETON_RESET
);
2844 /* no one knows timing, for safety add some delay */
2858 #define IPW_FW_MAJOR_VERSION 2
2859 #define IPW_FW_MINOR_VERSION 4
2861 #define IPW_FW_MINOR(x) ((x & 0xff) >> 8)
2862 #define IPW_FW_MAJOR(x) (x & 0xff)
2864 #define IPW_FW_VERSION ((IPW_FW_MINOR_VERSION << 8) | IPW_FW_MAJOR_VERSION)
2866 #define IPW_FW_PREFIX "ipw-" __stringify(IPW_FW_MAJOR_VERSION) \
2867 "." __stringify(IPW_FW_MINOR_VERSION) "-"
2869 #if IPW_FW_MAJOR_VERSION >= 2 && IPW_FW_MINOR_VERSION > 0
2870 #define IPW_FW_NAME(x) IPW_FW_PREFIX "" x ".fw"
2872 #define IPW_FW_NAME(x) "ipw2200_" x ".fw"
2875 static int ipw_load_ucode(struct ipw_priv
*priv
, u8
* data
, size_t len
)
2877 int rc
= 0, i
, addr
;
2881 image
= (u16
*) data
;
2883 IPW_DEBUG_TRACE(">> \n");
2885 rc
= ipw_stop_master(priv
);
2890 // spin_lock_irqsave(&priv->lock, flags);
2892 for (addr
= IPW_SHARED_LOWER_BOUND
;
2893 addr
< IPW_REGISTER_DOMAIN1_END
; addr
+= 4) {
2894 ipw_write32(priv
, addr
, 0);
2897 /* no ucode (yet) */
2898 memset(&priv
->dino_alive
, 0, sizeof(priv
->dino_alive
));
2899 /* destroy DMA queues */
2900 /* reset sequence */
2902 ipw_write_reg32(priv
, IPW_MEM_HALT_AND_RESET
, IPW_BIT_HALT_RESET_ON
);
2903 ipw_arc_release(priv
);
2904 ipw_write_reg32(priv
, IPW_MEM_HALT_AND_RESET
, IPW_BIT_HALT_RESET_OFF
);
2908 ipw_write_reg32(priv
, IPW_INTERNAL_CMD_EVENT
, IPW_BASEBAND_POWER_DOWN
);
2911 ipw_write_reg32(priv
, IPW_INTERNAL_CMD_EVENT
, 0);
2914 /* enable ucode store */
2915 ipw_write_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
, 0x0);
2916 ipw_write_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
, DINO_ENABLE_CS
);
2922 * Do NOT set indirect address register once and then
2923 * store data to indirect data register in the loop.
2924 * It seems very reasonable, but in this case DINO do not
2925 * accept ucode. It is essential to set address each time.
2927 /* load new ipw uCode */
2928 for (i
= 0; i
< len
/ 2; i
++)
2929 ipw_write_reg16(priv
, IPW_BASEBAND_CONTROL_STORE
,
2930 cpu_to_le16(image
[i
]));
2933 ipw_write_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
, 0);
2934 ipw_write_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
, DINO_ENABLE_SYSTEM
);
2936 /* this is where the igx / win driver deveates from the VAP driver. */
2938 /* wait for alive response */
2939 for (i
= 0; i
< 100; i
++) {
2940 /* poll for incoming data */
2941 cr
= ipw_read_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
);
2942 if (cr
& DINO_RXFIFO_DATA
)
2947 if (cr
& DINO_RXFIFO_DATA
) {
2948 /* alive_command_responce size is NOT multiple of 4 */
2949 u32 response_buffer
[(sizeof(priv
->dino_alive
) + 3) / 4];
2951 for (i
= 0; i
< ARRAY_SIZE(response_buffer
); i
++)
2952 response_buffer
[i
] =
2953 le32_to_cpu(ipw_read_reg32(priv
,
2954 IPW_BASEBAND_RX_FIFO_READ
));
2955 memcpy(&priv
->dino_alive
, response_buffer
,
2956 sizeof(priv
->dino_alive
));
2957 if (priv
->dino_alive
.alive_command
== 1
2958 && priv
->dino_alive
.ucode_valid
== 1) {
2961 ("Microcode OK, rev. %d (0x%x) dev. %d (0x%x) "
2962 "of %02d/%02d/%02d %02d:%02d\n",
2963 priv
->dino_alive
.software_revision
,
2964 priv
->dino_alive
.software_revision
,
2965 priv
->dino_alive
.device_identifier
,
2966 priv
->dino_alive
.device_identifier
,
2967 priv
->dino_alive
.time_stamp
[0],
2968 priv
->dino_alive
.time_stamp
[1],
2969 priv
->dino_alive
.time_stamp
[2],
2970 priv
->dino_alive
.time_stamp
[3],
2971 priv
->dino_alive
.time_stamp
[4]);
2973 IPW_DEBUG_INFO("Microcode is not alive\n");
2977 IPW_DEBUG_INFO("No alive response from DINO\n");
2981 /* disable DINO, otherwise for some reason
2982 firmware have problem getting alive resp. */
2983 ipw_write_reg8(priv
, IPW_BASEBAND_CONTROL_STATUS
, 0);
2985 // spin_unlock_irqrestore(&priv->lock, flags);
2990 static int ipw_load_firmware(struct ipw_priv
*priv
, u8
* data
, size_t len
)
2994 struct fw_chunk
*chunk
;
2995 dma_addr_t shared_phys
;
2998 IPW_DEBUG_TRACE("<< : \n");
2999 shared_virt
= pci_alloc_consistent(priv
->pci_dev
, len
, &shared_phys
);
3004 memmove(shared_virt
, data
, len
);
3007 rc
= ipw_fw_dma_enable(priv
);
3009 if (priv
->sram_desc
.last_cb_index
> 0) {
3010 /* the DMA is already ready this would be a bug. */
3016 chunk
= (struct fw_chunk
*)(data
+ offset
);
3017 offset
+= sizeof(struct fw_chunk
);
3018 /* build DMA packet and queue up for sending */
3019 /* dma to chunk->address, the chunk->length bytes from data +
3022 rc
= ipw_fw_dma_add_buffer(priv
, shared_phys
+ offset
,
3023 le32_to_cpu(chunk
->address
),
3024 le32_to_cpu(chunk
->length
));
3026 IPW_DEBUG_INFO("dmaAddBuffer Failed\n");
3030 offset
+= le32_to_cpu(chunk
->length
);
3031 } while (offset
< len
);
3033 /* Run the DMA and wait for the answer */
3034 rc
= ipw_fw_dma_kick(priv
);
3036 IPW_ERROR("dmaKick Failed\n");
3040 rc
= ipw_fw_dma_wait(priv
);
3042 IPW_ERROR("dmaWaitSync Failed\n");
3046 pci_free_consistent(priv
->pci_dev
, len
, shared_virt
, shared_phys
);
3051 static int ipw_stop_nic(struct ipw_priv
*priv
)
3056 ipw_write32(priv
, IPW_RESET_REG
, IPW_RESET_REG_STOP_MASTER
);
3058 rc
= ipw_poll_bit(priv
, IPW_RESET_REG
,
3059 IPW_RESET_REG_MASTER_DISABLED
, 500);
3061 IPW_ERROR("wait for reg master disabled failed after 500ms\n");
3065 ipw_set_bit(priv
, IPW_RESET_REG
, CBD_RESET_REG_PRINCETON_RESET
);
3070 static void ipw_start_nic(struct ipw_priv
*priv
)
3072 IPW_DEBUG_TRACE(">>\n");
3074 /* prvHwStartNic release ARC */
3075 ipw_clear_bit(priv
, IPW_RESET_REG
,
3076 IPW_RESET_REG_MASTER_DISABLED
|
3077 IPW_RESET_REG_STOP_MASTER
|
3078 CBD_RESET_REG_PRINCETON_RESET
);
3080 /* enable power management */
3081 ipw_set_bit(priv
, IPW_GP_CNTRL_RW
,
3082 IPW_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY
);
3084 IPW_DEBUG_TRACE("<<\n");
3087 static int ipw_init_nic(struct ipw_priv
*priv
)
3091 IPW_DEBUG_TRACE(">>\n");
3094 /* set "initialization complete" bit to move adapter to D0 state */
3095 ipw_set_bit(priv
, IPW_GP_CNTRL_RW
, IPW_GP_CNTRL_BIT_INIT_DONE
);
3097 /* low-level PLL activation */
3098 ipw_write32(priv
, IPW_READ_INT_REGISTER
,
3099 IPW_BIT_INT_HOST_SRAM_READ_INT_REGISTER
);
3101 /* wait for clock stabilization */
3102 rc
= ipw_poll_bit(priv
, IPW_GP_CNTRL_RW
,
3103 IPW_GP_CNTRL_BIT_CLOCK_READY
, 250);
3105 IPW_DEBUG_INFO("FAILED wait for clock stablization\n");
3107 /* assert SW reset */
3108 ipw_set_bit(priv
, IPW_RESET_REG
, IPW_RESET_REG_SW_RESET
);
3112 /* set "initialization complete" bit to move adapter to D0 state */
3113 ipw_set_bit(priv
, IPW_GP_CNTRL_RW
, IPW_GP_CNTRL_BIT_INIT_DONE
);
3115 IPW_DEBUG_TRACE(">>\n");
3119 /* Call this function from process context, it will sleep in request_firmware.
3120 * Probe is an ok place to call this from.
3122 static int ipw_reset_nic(struct ipw_priv
*priv
)
3125 unsigned long flags
;
3127 IPW_DEBUG_TRACE(">>\n");
3129 rc
= ipw_init_nic(priv
);
3131 spin_lock_irqsave(&priv
->lock
, flags
);
3132 /* Clear the 'host command active' bit... */
3133 priv
->status
&= ~STATUS_HCMD_ACTIVE
;
3134 wake_up_interruptible(&priv
->wait_command_queue
);
3135 priv
->status
&= ~(STATUS_SCANNING
| STATUS_SCAN_ABORTING
);
3136 wake_up_interruptible(&priv
->wait_state
);
3137 spin_unlock_irqrestore(&priv
->lock
, flags
);
3139 IPW_DEBUG_TRACE("<<\n");
3143 static int ipw_get_fw(struct ipw_priv
*priv
,
3144 const struct firmware
**fw
, const char *name
)
3146 struct fw_header
*header
;
3149 /* ask firmware_class module to get the boot firmware off disk */
3150 rc
= request_firmware(fw
, name
, &priv
->pci_dev
->dev
);
3152 IPW_ERROR("%s load failed: Reason %d\n", name
, rc
);
3156 header
= (struct fw_header
*)(*fw
)->data
;
3157 if (IPW_FW_MAJOR(le32_to_cpu(header
->version
)) != IPW_FW_MAJOR_VERSION
) {
3158 IPW_ERROR("'%s' firmware version not compatible (%d != %d)\n",
3160 IPW_FW_MAJOR(le32_to_cpu(header
->version
)),
3161 IPW_FW_MAJOR_VERSION
);
3165 IPW_DEBUG_INFO("Loading firmware '%s' file v%d.%d (%zd bytes)\n",
3167 IPW_FW_MAJOR(le32_to_cpu(header
->version
)),
3168 IPW_FW_MINOR(le32_to_cpu(header
->version
)),
3169 (*fw
)->size
- sizeof(struct fw_header
));
3173 #define IPW_RX_BUF_SIZE (3000)
3175 static void ipw_rx_queue_reset(struct ipw_priv
*priv
,
3176 struct ipw_rx_queue
*rxq
)
3178 unsigned long flags
;
3181 spin_lock_irqsave(&rxq
->lock
, flags
);
3183 INIT_LIST_HEAD(&rxq
->rx_free
);
3184 INIT_LIST_HEAD(&rxq
->rx_used
);
3186 /* Fill the rx_used queue with _all_ of the Rx buffers */
3187 for (i
= 0; i
< RX_FREE_BUFFERS
+ RX_QUEUE_SIZE
; i
++) {
3188 /* In the reset function, these buffers may have been allocated
3189 * to an SKB, so we need to unmap and free potential storage */
3190 if (rxq
->pool
[i
].skb
!= NULL
) {
3191 pci_unmap_single(priv
->pci_dev
, rxq
->pool
[i
].dma_addr
,
3192 IPW_RX_BUF_SIZE
, PCI_DMA_FROMDEVICE
);
3193 dev_kfree_skb(rxq
->pool
[i
].skb
);
3194 rxq
->pool
[i
].skb
= NULL
;
3196 list_add_tail(&rxq
->pool
[i
].list
, &rxq
->rx_used
);
3199 /* Set us so that we have processed and used all buffers, but have
3200 * not restocked the Rx queue with fresh buffers */
3201 rxq
->read
= rxq
->write
= 0;
3202 rxq
->processed
= RX_QUEUE_SIZE
- 1;
3203 rxq
->free_count
= 0;
3204 spin_unlock_irqrestore(&rxq
->lock
, flags
);
3208 static int fw_loaded
= 0;
3209 static const struct firmware
*bootfw
= NULL
;
3210 static const struct firmware
*firmware
= NULL
;
3211 static const struct firmware
*ucode
= NULL
;
3213 static void free_firmware(void)
3216 release_firmware(bootfw
);
3217 release_firmware(ucode
);
3218 release_firmware(firmware
);
3219 bootfw
= ucode
= firmware
= NULL
;
3224 #define free_firmware() do {} while (0)
3227 static int ipw_load(struct ipw_priv
*priv
)
3230 const struct firmware
*bootfw
= NULL
;
3231 const struct firmware
*firmware
= NULL
;
3232 const struct firmware
*ucode
= NULL
;
3236 int rc
= 0, retries
= 3;
3238 switch (priv
->ieee
->iw_mode
) {
3240 ucode_name
= IPW_FW_NAME("ibss_ucode");
3241 fw_name
= IPW_FW_NAME("ibss");
3243 #ifdef CONFIG_IPW2200_MONITOR
3244 case IW_MODE_MONITOR
:
3245 ucode_name
= IPW_FW_NAME("sniffer_ucode");
3246 fw_name
= IPW_FW_NAME("sniffer");
3250 ucode_name
= IPW_FW_NAME("bss_ucode");
3251 fw_name
= IPW_FW_NAME("bss");
3261 priv
->rxq
= ipw_rx_queue_alloc(priv
);
3263 ipw_rx_queue_reset(priv
, priv
->rxq
);
3265 IPW_ERROR("Unable to initialize Rx queue\n");
3270 /* Ensure interrupts are disabled */
3271 ipw_write32(priv
, IPW_INTA_MASK_R
, ~IPW_INTA_MASK_ALL
);
3272 priv
->status
&= ~STATUS_INT_ENABLED
;
3274 /* ack pending interrupts */
3275 ipw_write32(priv
, IPW_INTA_RW
, IPW_INTA_MASK_ALL
);
3279 rc
= ipw_reset_nic(priv
);
3281 IPW_ERROR("Unable to reset NIC\n");
3285 ipw_zero_memory(priv
, IPW_NIC_SRAM_LOWER_BOUND
,
3286 IPW_NIC_SRAM_UPPER_BOUND
- IPW_NIC_SRAM_LOWER_BOUND
);
3291 rc
= ipw_get_fw(priv
, &bootfw
, IPW_FW_NAME("boot"));
3297 /* DMA the initial boot firmware into the device */
3298 rc
= ipw_load_firmware(priv
, bootfw
->data
+ sizeof(struct fw_header
),
3299 bootfw
->size
- sizeof(struct fw_header
));
3301 IPW_ERROR("Unable to load boot firmware: %d\n", rc
);
3305 /* kick start the device */
3306 ipw_start_nic(priv
);
3308 /* wait for the device to finish its initial startup sequence */
3309 rc
= ipw_poll_bit(priv
, IPW_INTA_RW
,
3310 IPW_INTA_BIT_FW_INITIALIZATION_DONE
, 500);
3312 IPW_ERROR("device failed to boot initial fw image\n");
3315 IPW_DEBUG_INFO("initial device response after %dms\n", rc
);
3317 /* ack fw init done interrupt */
3318 ipw_write32(priv
, IPW_INTA_RW
, IPW_INTA_BIT_FW_INITIALIZATION_DONE
);
3323 rc
= ipw_get_fw(priv
, &ucode
, ucode_name
);
3330 /* DMA the ucode into the device */
3331 rc
= ipw_load_ucode(priv
, ucode
->data
+ sizeof(struct fw_header
),
3332 ucode
->size
- sizeof(struct fw_header
));
3334 IPW_ERROR("Unable to load ucode: %d\n", rc
);
3344 rc
= ipw_get_fw(priv
, &firmware
, fw_name
);
3351 /* DMA bss firmware into the device */
3352 rc
= ipw_load_firmware(priv
, firmware
->data
+
3353 sizeof(struct fw_header
),
3354 firmware
->size
- sizeof(struct fw_header
));
3356 IPW_ERROR("Unable to load firmware: %d\n", rc
);
3364 ipw_write32(priv
, IPW_EEPROM_LOAD_DISABLE
, 0);
3366 rc
= ipw_queue_reset(priv
);
3368 IPW_ERROR("Unable to initialize queues\n");
3372 /* Ensure interrupts are disabled */
3373 ipw_write32(priv
, IPW_INTA_MASK_R
, ~IPW_INTA_MASK_ALL
);
3374 /* ack pending interrupts */
3375 ipw_write32(priv
, IPW_INTA_RW
, IPW_INTA_MASK_ALL
);
3377 /* kick start the device */
3378 ipw_start_nic(priv
);
3380 if (ipw_read32(priv
, IPW_INTA_RW
) & IPW_INTA_BIT_PARITY_ERROR
) {
3382 IPW_WARNING("Parity error. Retrying init.\n");
3387 IPW_ERROR("TODO: Handle parity error -- schedule restart?\n");
3392 /* wait for the device */
3393 rc
= ipw_poll_bit(priv
, IPW_INTA_RW
,
3394 IPW_INTA_BIT_FW_INITIALIZATION_DONE
, 500);
3396 IPW_ERROR("device failed to start within 500ms\n");
3399 IPW_DEBUG_INFO("device response after %dms\n", rc
);
3401 /* ack fw init done interrupt */
3402 ipw_write32(priv
, IPW_INTA_RW
, IPW_INTA_BIT_FW_INITIALIZATION_DONE
);
3404 /* read eeprom data and initialize the eeprom region of sram */
3405 priv
->eeprom_delay
= 1;
3406 ipw_eeprom_init_sram(priv
);
3408 /* enable interrupts */
3409 ipw_enable_interrupts(priv
);
3411 /* Ensure our queue has valid packets */
3412 ipw_rx_queue_replenish(priv
);
3414 ipw_write32(priv
, IPW_RX_READ_INDEX
, priv
->rxq
->read
);
3416 /* ack pending interrupts */
3417 ipw_write32(priv
, IPW_INTA_RW
, IPW_INTA_MASK_ALL
);
3420 release_firmware(bootfw
);
3421 release_firmware(ucode
);
3422 release_firmware(firmware
);
3428 ipw_rx_queue_free(priv
, priv
->rxq
);
3431 ipw_tx_queue_free(priv
);
3433 release_firmware(bootfw
);
3435 release_firmware(ucode
);
3437 release_firmware(firmware
);
3440 bootfw
= ucode
= firmware
= NULL
;
3449 * Theory of operation
3451 * A queue is a circular buffers with 'Read' and 'Write' pointers.
3452 * 2 empty entries always kept in the buffer to protect from overflow.
3454 * For Tx queue, there are low mark and high mark limits. If, after queuing
3455 * the packet for Tx, free space become < low mark, Tx queue stopped. When
3456 * reclaiming packets (on 'tx done IRQ), if free space become > high mark,
3459 * The IPW operates with six queues, one receive queue in the device's
3460 * sram, one transmit queue for sending commands to the device firmware,
3461 * and four transmit queues for data.
3463 * The four transmit queues allow for performing quality of service (qos)
3464 * transmissions as per the 802.11 protocol. Currently Linux does not
3465 * provide a mechanism to the user for utilizing prioritized queues, so
3466 * we only utilize the first data transmit queue (queue1).
3470 * Driver allocates buffers of this size for Rx
3473 static inline int ipw_queue_space(const struct clx2_queue
*q
)
3475 int s
= q
->last_used
- q
->first_empty
;
3478 s
-= 2; /* keep some reserve to not confuse empty and full situations */
3484 static inline int ipw_queue_inc_wrap(int index
, int n_bd
)
3486 return (++index
== n_bd
) ? 0 : index
;
3490 * Initialize common DMA queue structure
3492 * @param q queue to init
3493 * @param count Number of BD's to allocate. Should be power of 2
3494 * @param read_register Address for 'read' register
3495 * (not offset within BAR, full address)
3496 * @param write_register Address for 'write' register
3497 * (not offset within BAR, full address)
3498 * @param base_register Address for 'base' register
3499 * (not offset within BAR, full address)
3500 * @param size Address for 'size' register
3501 * (not offset within BAR, full address)
3503 static void ipw_queue_init(struct ipw_priv
*priv
, struct clx2_queue
*q
,
3504 int count
, u32 read
, u32 write
, u32 base
, u32 size
)
3508 q
->low_mark
= q
->n_bd
/ 4;
3509 if (q
->low_mark
< 4)
3512 q
->high_mark
= q
->n_bd
/ 8;
3513 if (q
->high_mark
< 2)
3516 q
->first_empty
= q
->last_used
= 0;
3520 ipw_write32(priv
, base
, q
->dma_addr
);
3521 ipw_write32(priv
, size
, count
);
3522 ipw_write32(priv
, read
, 0);
3523 ipw_write32(priv
, write
, 0);
3525 _ipw_read32(priv
, 0x90);
3528 static int ipw_queue_tx_init(struct ipw_priv
*priv
,
3529 struct clx2_tx_queue
*q
,
3530 int count
, u32 read
, u32 write
, u32 base
, u32 size
)
3532 struct pci_dev
*dev
= priv
->pci_dev
;
3534 q
->txb
= kmalloc(sizeof(q
->txb
[0]) * count
, GFP_KERNEL
);
3536 IPW_ERROR("vmalloc for auxilary BD structures failed\n");
3541 pci_alloc_consistent(dev
, sizeof(q
->bd
[0]) * count
, &q
->q
.dma_addr
);
3543 IPW_ERROR("pci_alloc_consistent(%zd) failed\n",
3544 sizeof(q
->bd
[0]) * count
);
3550 ipw_queue_init(priv
, &q
->q
, count
, read
, write
, base
, size
);
3555 * Free one TFD, those at index [txq->q.last_used].
3556 * Do NOT advance any indexes
3561 static void ipw_queue_tx_free_tfd(struct ipw_priv
*priv
,
3562 struct clx2_tx_queue
*txq
)
3564 struct tfd_frame
*bd
= &txq
->bd
[txq
->q
.last_used
];
3565 struct pci_dev
*dev
= priv
->pci_dev
;
3569 if (bd
->control_flags
.message_type
== TX_HOST_COMMAND_TYPE
)
3570 /* nothing to cleanup after for host commands */
3574 if (le32_to_cpu(bd
->u
.data
.num_chunks
) > NUM_TFD_CHUNKS
) {
3575 IPW_ERROR("Too many chunks: %i\n",
3576 le32_to_cpu(bd
->u
.data
.num_chunks
));
3577 /** @todo issue fatal error, it is quite serious situation */
3581 /* unmap chunks if any */
3582 for (i
= 0; i
< le32_to_cpu(bd
->u
.data
.num_chunks
); i
++) {
3583 pci_unmap_single(dev
, le32_to_cpu(bd
->u
.data
.chunk_ptr
[i
]),
3584 le16_to_cpu(bd
->u
.data
.chunk_len
[i
]),
3586 if (txq
->txb
[txq
->q
.last_used
]) {
3587 ieee80211_txb_free(txq
->txb
[txq
->q
.last_used
]);
3588 txq
->txb
[txq
->q
.last_used
] = NULL
;
3594 * Deallocate DMA queue.
3596 * Empty queue by removing and destroying all BD's.
3602 static void ipw_queue_tx_free(struct ipw_priv
*priv
, struct clx2_tx_queue
*txq
)
3604 struct clx2_queue
*q
= &txq
->q
;
3605 struct pci_dev
*dev
= priv
->pci_dev
;
3610 /* first, empty all BD's */
3611 for (; q
->first_empty
!= q
->last_used
;
3612 q
->last_used
= ipw_queue_inc_wrap(q
->last_used
, q
->n_bd
)) {
3613 ipw_queue_tx_free_tfd(priv
, txq
);
3616 /* free buffers belonging to queue itself */
3617 pci_free_consistent(dev
, sizeof(txq
->bd
[0]) * q
->n_bd
, txq
->bd
,
3621 /* 0 fill whole structure */
3622 memset(txq
, 0, sizeof(*txq
));
3626 * Destroy all DMA queues and structures
3630 static void ipw_tx_queue_free(struct ipw_priv
*priv
)
3633 ipw_queue_tx_free(priv
, &priv
->txq_cmd
);
3636 ipw_queue_tx_free(priv
, &priv
->txq
[0]);
3637 ipw_queue_tx_free(priv
, &priv
->txq
[1]);
3638 ipw_queue_tx_free(priv
, &priv
->txq
[2]);
3639 ipw_queue_tx_free(priv
, &priv
->txq
[3]);
3642 static void ipw_create_bssid(struct ipw_priv
*priv
, u8
* bssid
)
3644 /* First 3 bytes are manufacturer */
3645 bssid
[0] = priv
->mac_addr
[0];
3646 bssid
[1] = priv
->mac_addr
[1];
3647 bssid
[2] = priv
->mac_addr
[2];
3649 /* Last bytes are random */
3650 get_random_bytes(&bssid
[3], ETH_ALEN
- 3);
3652 bssid
[0] &= 0xfe; /* clear multicast bit */
3653 bssid
[0] |= 0x02; /* set local assignment bit (IEEE802) */
3656 static u8
ipw_add_station(struct ipw_priv
*priv
, u8
* bssid
)
3658 struct ipw_station_entry entry
;
3661 for (i
= 0; i
< priv
->num_stations
; i
++) {
3662 if (!memcmp(priv
->stations
[i
], bssid
, ETH_ALEN
)) {
3663 /* Another node is active in network */
3664 priv
->missed_adhoc_beacons
= 0;
3665 if (!(priv
->config
& CFG_STATIC_CHANNEL
))
3666 /* when other nodes drop out, we drop out */
3667 priv
->config
&= ~CFG_ADHOC_PERSIST
;
3673 if (i
== MAX_STATIONS
)
3674 return IPW_INVALID_STATION
;
3676 IPW_DEBUG_SCAN("Adding AdHoc station: " MAC_FMT
"\n", MAC_ARG(bssid
));
3679 entry
.support_mode
= 0;
3680 memcpy(entry
.mac_addr
, bssid
, ETH_ALEN
);
3681 memcpy(priv
->stations
[i
], bssid
, ETH_ALEN
);
3682 ipw_write_direct(priv
, IPW_STATION_TABLE_LOWER
+ i
* sizeof(entry
),
3683 &entry
, sizeof(entry
));
3684 priv
->num_stations
++;
3689 static u8
ipw_find_station(struct ipw_priv
*priv
, u8
* bssid
)
3693 for (i
= 0; i
< priv
->num_stations
; i
++)
3694 if (!memcmp(priv
->stations
[i
], bssid
, ETH_ALEN
))
3697 return IPW_INVALID_STATION
;
3700 static void ipw_send_disassociate(struct ipw_priv
*priv
, int quiet
)
3704 if (priv
->status
& STATUS_ASSOCIATING
) {
3705 IPW_DEBUG_ASSOC("Disassociating while associating.\n");
3706 queue_work(priv
->workqueue
, &priv
->disassociate
);
3710 if (!(priv
->status
& STATUS_ASSOCIATED
)) {
3711 IPW_DEBUG_ASSOC("Disassociating while not associated.\n");
3715 IPW_DEBUG_ASSOC("Disassocation attempt from " MAC_FMT
" "
3717 MAC_ARG(priv
->assoc_request
.bssid
),
3718 priv
->assoc_request
.channel
);
3720 priv
->status
&= ~(STATUS_ASSOCIATING
| STATUS_ASSOCIATED
);
3721 priv
->status
|= STATUS_DISASSOCIATING
;
3724 priv
->assoc_request
.assoc_type
= HC_DISASSOC_QUIET
;
3726 priv
->assoc_request
.assoc_type
= HC_DISASSOCIATE
;
3728 err
= ipw_send_associate(priv
, &priv
->assoc_request
);
3730 IPW_DEBUG_HC("Attempt to send [dis]associate command "
3737 static int ipw_disassociate(void *data
)
3739 struct ipw_priv
*priv
= data
;
3740 if (!(priv
->status
& (STATUS_ASSOCIATED
| STATUS_ASSOCIATING
)))
3742 ipw_send_disassociate(data
, 0);
3746 static void ipw_bg_disassociate(void *data
)
3748 struct ipw_priv
*priv
= data
;
3750 ipw_disassociate(data
);
3754 static void ipw_system_config(void *data
)
3756 struct ipw_priv
*priv
= data
;
3757 ipw_send_system_config(priv
, &priv
->sys_config
);
3760 struct ipw_status_code
{
3765 static const struct ipw_status_code ipw_status_codes
[] = {
3766 {0x00, "Successful"},
3767 {0x01, "Unspecified failure"},
3768 {0x0A, "Cannot support all requested capabilities in the "
3769 "Capability information field"},
3770 {0x0B, "Reassociation denied due to inability to confirm that "
3771 "association exists"},
3772 {0x0C, "Association denied due to reason outside the scope of this "
3775 "Responding station does not support the specified authentication "
3778 "Received an Authentication frame with authentication sequence "
3779 "transaction sequence number out of expected sequence"},
3780 {0x0F, "Authentication rejected because of challenge failure"},
3781 {0x10, "Authentication rejected due to timeout waiting for next "
3782 "frame in sequence"},
3783 {0x11, "Association denied because AP is unable to handle additional "
3784 "associated stations"},
3786 "Association denied due to requesting station not supporting all "
3787 "of the datarates in the BSSBasicServiceSet Parameter"},
3789 "Association denied due to requesting station not supporting "
3790 "short preamble operation"},
3792 "Association denied due to requesting station not supporting "
3795 "Association denied due to requesting station not supporting "
3798 "Association denied due to requesting station not supporting "
3799 "short slot operation"},
3801 "Association denied due to requesting station not supporting "
3802 "DSSS-OFDM operation"},
3803 {0x28, "Invalid Information Element"},
3804 {0x29, "Group Cipher is not valid"},
3805 {0x2A, "Pairwise Cipher is not valid"},
3806 {0x2B, "AKMP is not valid"},
3807 {0x2C, "Unsupported RSN IE version"},
3808 {0x2D, "Invalid RSN IE Capabilities"},
3809 {0x2E, "Cipher suite is rejected per security policy"},
3812 #ifdef CONFIG_IPW2200_DEBUG
3813 static const char *ipw_get_status_code(u16 status
)
3816 for (i
= 0; i
< ARRAY_SIZE(ipw_status_codes
); i
++)
3817 if (ipw_status_codes
[i
].status
== (status
& 0xff))
3818 return ipw_status_codes
[i
].reason
;
3819 return "Unknown status value.";
3823 static void inline average_init(struct average
*avg
)
3825 memset(avg
, 0, sizeof(*avg
));
3828 static void average_add(struct average
*avg
, s16 val
)
3830 avg
->sum
-= avg
->entries
[avg
->pos
];
3832 avg
->entries
[avg
->pos
++] = val
;
3833 if (unlikely(avg
->pos
== AVG_ENTRIES
)) {
3839 static s16
average_value(struct average
*avg
)
3841 if (!unlikely(avg
->init
)) {
3843 return avg
->sum
/ avg
->pos
;
3847 return avg
->sum
/ AVG_ENTRIES
;
3850 static void ipw_reset_stats(struct ipw_priv
*priv
)
3852 u32 len
= sizeof(u32
);
3856 average_init(&priv
->average_missed_beacons
);
3857 average_init(&priv
->average_rssi
);
3858 average_init(&priv
->average_noise
);
3860 priv
->last_rate
= 0;
3861 priv
->last_missed_beacons
= 0;
3862 priv
->last_rx_packets
= 0;
3863 priv
->last_tx_packets
= 0;
3864 priv
->last_tx_failures
= 0;
3866 /* Firmware managed, reset only when NIC is restarted, so we have to
3867 * normalize on the current value */
3868 ipw_get_ordinal(priv
, IPW_ORD_STAT_RX_ERR_CRC
,
3869 &priv
->last_rx_err
, &len
);
3870 ipw_get_ordinal(priv
, IPW_ORD_STAT_TX_FAILURE
,
3871 &priv
->last_tx_failures
, &len
);
3873 /* Driver managed, reset with each association */
3874 priv
->missed_adhoc_beacons
= 0;
3875 priv
->missed_beacons
= 0;
3876 priv
->tx_packets
= 0;
3877 priv
->rx_packets
= 0;
3881 static u32
ipw_get_max_rate(struct ipw_priv
*priv
)
3884 u32 mask
= priv
->rates_mask
;
3885 /* If currently associated in B mode, restrict the maximum
3886 * rate match to B rates */
3887 if (priv
->assoc_request
.ieee_mode
== IPW_B_MODE
)
3888 mask
&= IEEE80211_CCK_RATES_MASK
;
3890 /* TODO: Verify that the rate is supported by the current rates
3893 while (i
&& !(mask
& i
))
3896 case IEEE80211_CCK_RATE_1MB_MASK
:
3898 case IEEE80211_CCK_RATE_2MB_MASK
:
3900 case IEEE80211_CCK_RATE_5MB_MASK
:
3902 case IEEE80211_OFDM_RATE_6MB_MASK
:
3904 case IEEE80211_OFDM_RATE_9MB_MASK
:
3906 case IEEE80211_CCK_RATE_11MB_MASK
:
3908 case IEEE80211_OFDM_RATE_12MB_MASK
:
3910 case IEEE80211_OFDM_RATE_18MB_MASK
:
3912 case IEEE80211_OFDM_RATE_24MB_MASK
:
3914 case IEEE80211_OFDM_RATE_36MB_MASK
:
3916 case IEEE80211_OFDM_RATE_48MB_MASK
:
3918 case IEEE80211_OFDM_RATE_54MB_MASK
:
3922 if (priv
->ieee
->mode
== IEEE_B
)
3928 static u32
ipw_get_current_rate(struct ipw_priv
*priv
)
3930 u32 rate
, len
= sizeof(rate
);
3933 if (!(priv
->status
& STATUS_ASSOCIATED
))
3936 if (priv
->tx_packets
> IPW_REAL_RATE_RX_PACKET_THRESHOLD
) {
3937 err
= ipw_get_ordinal(priv
, IPW_ORD_STAT_TX_CURR_RATE
, &rate
,
3940 IPW_DEBUG_INFO("failed querying ordinals.\n");
3944 return ipw_get_max_rate(priv
);
3947 case IPW_TX_RATE_1MB
:
3949 case IPW_TX_RATE_2MB
:
3951 case IPW_TX_RATE_5MB
:
3953 case IPW_TX_RATE_6MB
:
3955 case IPW_TX_RATE_9MB
:
3957 case IPW_TX_RATE_11MB
:
3959 case IPW_TX_RATE_12MB
:
3961 case IPW_TX_RATE_18MB
:
3963 case IPW_TX_RATE_24MB
:
3965 case IPW_TX_RATE_36MB
:
3967 case IPW_TX_RATE_48MB
:
3969 case IPW_TX_RATE_54MB
:
3976 #define IPW_STATS_INTERVAL (2 * HZ)
3977 static void ipw_gather_stats(struct ipw_priv
*priv
)
3979 u32 rx_err
, rx_err_delta
, rx_packets_delta
;
3980 u32 tx_failures
, tx_failures_delta
, tx_packets_delta
;
3981 u32 missed_beacons_percent
, missed_beacons_delta
;
3983 u32 len
= sizeof(u32
);
3985 u32 beacon_quality
, signal_quality
, tx_quality
, rx_quality
,
3989 if (!(priv
->status
& STATUS_ASSOCIATED
)) {
3994 /* Update the statistics */
3995 ipw_get_ordinal(priv
, IPW_ORD_STAT_MISSED_BEACONS
,
3996 &priv
->missed_beacons
, &len
);
3997 missed_beacons_delta
= priv
->missed_beacons
- priv
->last_missed_beacons
;
3998 priv
->last_missed_beacons
= priv
->missed_beacons
;
3999 if (priv
->assoc_request
.beacon_interval
) {
4000 missed_beacons_percent
= missed_beacons_delta
*
4001 (HZ
* priv
->assoc_request
.beacon_interval
) /
4002 (IPW_STATS_INTERVAL
* 10);
4004 missed_beacons_percent
= 0;
4006 average_add(&priv
->average_missed_beacons
, missed_beacons_percent
);
4008 ipw_get_ordinal(priv
, IPW_ORD_STAT_RX_ERR_CRC
, &rx_err
, &len
);
4009 rx_err_delta
= rx_err
- priv
->last_rx_err
;
4010 priv
->last_rx_err
= rx_err
;
4012 ipw_get_ordinal(priv
, IPW_ORD_STAT_TX_FAILURE
, &tx_failures
, &len
);
4013 tx_failures_delta
= tx_failures
- priv
->last_tx_failures
;
4014 priv
->last_tx_failures
= tx_failures
;
4016 rx_packets_delta
= priv
->rx_packets
- priv
->last_rx_packets
;
4017 priv
->last_rx_packets
= priv
->rx_packets
;
4019 tx_packets_delta
= priv
->tx_packets
- priv
->last_tx_packets
;
4020 priv
->last_tx_packets
= priv
->tx_packets
;
4022 /* Calculate quality based on the following:
4024 * Missed beacon: 100% = 0, 0% = 70% missed
4025 * Rate: 60% = 1Mbs, 100% = Max
4026 * Rx and Tx errors represent a straight % of total Rx/Tx
4027 * RSSI: 100% = > -50, 0% = < -80
4028 * Rx errors: 100% = 0, 0% = 50% missed
4030 * The lowest computed quality is used.
4033 #define BEACON_THRESHOLD 5
4034 beacon_quality
= 100 - missed_beacons_percent
;
4035 if (beacon_quality
< BEACON_THRESHOLD
)
4038 beacon_quality
= (beacon_quality
- BEACON_THRESHOLD
) * 100 /
4039 (100 - BEACON_THRESHOLD
);
4040 IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n",
4041 beacon_quality
, missed_beacons_percent
);
4043 priv
->last_rate
= ipw_get_current_rate(priv
);
4044 max_rate
= ipw_get_max_rate(priv
);
4045 rate_quality
= priv
->last_rate
* 40 / max_rate
+ 60;
4046 IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n",
4047 rate_quality
, priv
->last_rate
/ 1000000);
4049 if (rx_packets_delta
> 100 && rx_packets_delta
+ rx_err_delta
)
4050 rx_quality
= 100 - (rx_err_delta
* 100) /
4051 (rx_packets_delta
+ rx_err_delta
);
4054 IPW_DEBUG_STATS("Rx quality : %3d%% (%u errors, %u packets)\n",
4055 rx_quality
, rx_err_delta
, rx_packets_delta
);
4057 if (tx_packets_delta
> 100 && tx_packets_delta
+ tx_failures_delta
)
4058 tx_quality
= 100 - (tx_failures_delta
* 100) /
4059 (tx_packets_delta
+ tx_failures_delta
);
4062 IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n",
4063 tx_quality
, tx_failures_delta
, tx_packets_delta
);
4065 rssi
= average_value(&priv
->average_rssi
);
4068 (priv
->ieee
->perfect_rssi
- priv
->ieee
->worst_rssi
) *
4069 (priv
->ieee
->perfect_rssi
- priv
->ieee
->worst_rssi
) -
4070 (priv
->ieee
->perfect_rssi
- rssi
) *
4071 (15 * (priv
->ieee
->perfect_rssi
- priv
->ieee
->worst_rssi
) +
4072 62 * (priv
->ieee
->perfect_rssi
- rssi
))) /
4073 ((priv
->ieee
->perfect_rssi
- priv
->ieee
->worst_rssi
) *
4074 (priv
->ieee
->perfect_rssi
- priv
->ieee
->worst_rssi
));
4075 if (signal_quality
> 100)
4076 signal_quality
= 100;
4077 else if (signal_quality
< 1)
4080 IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n",
4081 signal_quality
, rssi
);
4083 quality
= min(beacon_quality
,
4085 min(tx_quality
, min(rx_quality
, signal_quality
))));
4086 if (quality
== beacon_quality
)
4087 IPW_DEBUG_STATS("Quality (%d%%): Clamped to missed beacons.\n",
4089 if (quality
== rate_quality
)
4090 IPW_DEBUG_STATS("Quality (%d%%): Clamped to rate quality.\n",
4092 if (quality
== tx_quality
)
4093 IPW_DEBUG_STATS("Quality (%d%%): Clamped to Tx quality.\n",
4095 if (quality
== rx_quality
)
4096 IPW_DEBUG_STATS("Quality (%d%%): Clamped to Rx quality.\n",
4098 if (quality
== signal_quality
)
4099 IPW_DEBUG_STATS("Quality (%d%%): Clamped to signal quality.\n",
4102 priv
->quality
= quality
;
4104 queue_delayed_work(priv
->workqueue
, &priv
->gather_stats
,
4105 IPW_STATS_INTERVAL
);
4108 static void ipw_bg_gather_stats(void *data
)
4110 struct ipw_priv
*priv
= data
;
4112 ipw_gather_stats(data
);
4116 /* Missed beacon behavior:
4117 * 1st missed -> roaming_threshold, just wait, don't do any scan/roam.
4118 * roaming_threshold -> disassociate_threshold, scan and roam for better signal.
4119 * Above disassociate threshold, give up and stop scanning.
4120 * Roaming is disabled if disassociate_threshold <= roaming_threshold */
4121 static void ipw_handle_missed_beacon(struct ipw_priv
*priv
,
4124 priv
->notif_missed_beacons
= missed_count
;
4126 if (missed_count
> priv
->disassociate_threshold
&&
4127 priv
->status
& STATUS_ASSOCIATED
) {
4128 /* If associated and we've hit the missed
4129 * beacon threshold, disassociate, turn
4130 * off roaming, and abort any active scans */
4131 IPW_DEBUG(IPW_DL_INFO
| IPW_DL_NOTIF
|
4132 IPW_DL_STATE
| IPW_DL_ASSOC
,
4133 "Missed beacon: %d - disassociate\n", missed_count
);
4134 priv
->status
&= ~STATUS_ROAMING
;
4135 if (priv
->status
& STATUS_SCANNING
) {
4136 IPW_DEBUG(IPW_DL_INFO
| IPW_DL_NOTIF
|
4138 "Aborting scan with missed beacon.\n");
4139 queue_work(priv
->workqueue
, &priv
->abort_scan
);
4142 queue_work(priv
->workqueue
, &priv
->disassociate
);
4146 if (priv
->status
& STATUS_ROAMING
) {
4147 /* If we are currently roaming, then just
4148 * print a debug statement... */
4149 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
,
4150 "Missed beacon: %d - roam in progress\n",
4156 (missed_count
> priv
->roaming_threshold
&&
4157 missed_count
<= priv
->disassociate_threshold
)) {
4158 /* If we are not already roaming, set the ROAM
4159 * bit in the status and kick off a scan.
4160 * This can happen several times before we reach
4161 * disassociate_threshold. */
4162 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
,
4163 "Missed beacon: %d - initiate "
4164 "roaming\n", missed_count
);
4165 if (!(priv
->status
& STATUS_ROAMING
)) {
4166 priv
->status
|= STATUS_ROAMING
;
4167 if (!(priv
->status
& STATUS_SCANNING
))
4168 queue_work(priv
->workqueue
,
4169 &priv
->request_scan
);
4174 if (priv
->status
& STATUS_SCANNING
) {
4175 /* Stop scan to keep fw from getting
4176 * stuck (only if we aren't roaming --
4177 * otherwise we'll never scan more than 2 or 3
4179 IPW_DEBUG(IPW_DL_INFO
| IPW_DL_NOTIF
| IPW_DL_STATE
,
4180 "Aborting scan with missed beacon.\n");
4181 queue_work(priv
->workqueue
, &priv
->abort_scan
);
4184 IPW_DEBUG_NOTIF("Missed beacon: %d\n", missed_count
);
4188 * Handle host notification packet.
4189 * Called from interrupt routine
4191 static void ipw_rx_notification(struct ipw_priv
*priv
,
4192 struct ipw_rx_notification
*notif
)
4194 notif
->size
= le16_to_cpu(notif
->size
);
4196 IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", notif
->subtype
, notif
->size
);
4198 switch (notif
->subtype
) {
4199 case HOST_NOTIFICATION_STATUS_ASSOCIATED
:{
4200 struct notif_association
*assoc
= ¬if
->u
.assoc
;
4202 switch (assoc
->state
) {
4203 case CMAS_ASSOCIATED
:{
4204 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4206 "associated: '%s' " MAC_FMT
4208 escape_essid(priv
->essid
,
4210 MAC_ARG(priv
->bssid
));
4212 switch (priv
->ieee
->iw_mode
) {
4214 memcpy(priv
->ieee
->bssid
,
4215 priv
->bssid
, ETH_ALEN
);
4219 memcpy(priv
->ieee
->bssid
,
4220 priv
->bssid
, ETH_ALEN
);
4222 /* clear out the station table */
4223 priv
->num_stations
= 0;
4226 ("queueing adhoc check\n");
4227 queue_delayed_work(priv
->
4237 priv
->status
&= ~STATUS_ASSOCIATING
;
4238 priv
->status
|= STATUS_ASSOCIATED
;
4239 queue_work(priv
->workqueue
,
4240 &priv
->system_config
);
4242 #ifdef CONFIG_IPW_QOS
4243 #define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \
4244 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl))
4245 if ((priv
->status
& STATUS_AUTH
) &&
4246 (IPW_GET_PACKET_STYPE(¬if
->u
.raw
)
4247 == IEEE80211_STYPE_ASSOC_RESP
)) {
4250 ieee80211_assoc_response
)
4252 && (notif
->size
<= 2314)) {
4265 ieee80211_rx_mgt(priv
->
4270 ¬if
->u
.raw
, &stats
);
4275 schedule_work(&priv
->link_up
);
4280 case CMAS_AUTHENTICATED
:{
4282 status
& (STATUS_ASSOCIATED
|
4284 #ifdef CONFIG_IPW2200_DEBUG
4285 struct notif_authenticate
*auth
4287 IPW_DEBUG(IPW_DL_NOTIF
|
4290 "deauthenticated: '%s' "
4292 ": (0x%04X) - %s \n",
4297 MAC_ARG(priv
->bssid
),
4298 ntohs(auth
->status
),
4305 ~(STATUS_ASSOCIATING
|
4309 schedule_work(&priv
->link_down
);
4313 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4315 "authenticated: '%s' " MAC_FMT
4317 escape_essid(priv
->essid
,
4319 MAC_ARG(priv
->bssid
));
4324 if (priv
->status
& STATUS_AUTH
) {
4326 ieee80211_assoc_response
4330 ieee80211_assoc_response
4332 IPW_DEBUG(IPW_DL_NOTIF
|
4335 "association failed (0x%04X): %s\n",
4336 ntohs(resp
->status
),
4342 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4344 "disassociated: '%s' " MAC_FMT
4346 escape_essid(priv
->essid
,
4348 MAC_ARG(priv
->bssid
));
4351 ~(STATUS_DISASSOCIATING
|
4352 STATUS_ASSOCIATING
|
4353 STATUS_ASSOCIATED
| STATUS_AUTH
);
4354 if (priv
->assoc_network
4355 && (priv
->assoc_network
->
4357 WLAN_CAPABILITY_IBSS
))
4358 ipw_remove_current_network
4361 schedule_work(&priv
->link_down
);
4366 case CMAS_RX_ASSOC_RESP
:
4370 IPW_ERROR("assoc: unknown (%d)\n",
4378 case HOST_NOTIFICATION_STATUS_AUTHENTICATE
:{
4379 struct notif_authenticate
*auth
= ¬if
->u
.auth
;
4380 switch (auth
->state
) {
4381 case CMAS_AUTHENTICATED
:
4382 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
,
4383 "authenticated: '%s' " MAC_FMT
" \n",
4384 escape_essid(priv
->essid
,
4386 MAC_ARG(priv
->bssid
));
4387 priv
->status
|= STATUS_AUTH
;
4391 if (priv
->status
& STATUS_AUTH
) {
4392 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4394 "authentication failed (0x%04X): %s\n",
4395 ntohs(auth
->status
),
4396 ipw_get_status_code(ntohs
4400 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4402 "deauthenticated: '%s' " MAC_FMT
"\n",
4403 escape_essid(priv
->essid
,
4405 MAC_ARG(priv
->bssid
));
4407 priv
->status
&= ~(STATUS_ASSOCIATING
|
4411 schedule_work(&priv
->link_down
);
4414 case CMAS_TX_AUTH_SEQ_1
:
4415 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4416 IPW_DL_ASSOC
, "AUTH_SEQ_1\n");
4418 case CMAS_RX_AUTH_SEQ_2
:
4419 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4420 IPW_DL_ASSOC
, "AUTH_SEQ_2\n");
4422 case CMAS_AUTH_SEQ_1_PASS
:
4423 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4424 IPW_DL_ASSOC
, "AUTH_SEQ_1_PASS\n");
4426 case CMAS_AUTH_SEQ_1_FAIL
:
4427 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4428 IPW_DL_ASSOC
, "AUTH_SEQ_1_FAIL\n");
4430 case CMAS_TX_AUTH_SEQ_3
:
4431 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4432 IPW_DL_ASSOC
, "AUTH_SEQ_3\n");
4434 case CMAS_RX_AUTH_SEQ_4
:
4435 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4436 IPW_DL_ASSOC
, "RX_AUTH_SEQ_4\n");
4438 case CMAS_AUTH_SEQ_2_PASS
:
4439 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4440 IPW_DL_ASSOC
, "AUTH_SEQ_2_PASS\n");
4442 case CMAS_AUTH_SEQ_2_FAIL
:
4443 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4444 IPW_DL_ASSOC
, "AUT_SEQ_2_FAIL\n");
4447 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4448 IPW_DL_ASSOC
, "TX_ASSOC\n");
4450 case CMAS_RX_ASSOC_RESP
:
4451 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4452 IPW_DL_ASSOC
, "RX_ASSOC_RESP\n");
4455 case CMAS_ASSOCIATED
:
4456 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
|
4457 IPW_DL_ASSOC
, "ASSOCIATED\n");
4460 IPW_DEBUG_NOTIF("auth: failure - %d\n",
4467 case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT
:{
4468 struct notif_channel_result
*x
=
4469 ¬if
->u
.channel_result
;
4471 if (notif
->size
== sizeof(*x
)) {
4472 IPW_DEBUG_SCAN("Scan result for channel %d\n",
4475 IPW_DEBUG_SCAN("Scan result of wrong size %d "
4476 "(should be %zd)\n",
4477 notif
->size
, sizeof(*x
));
4482 case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED
:{
4483 struct notif_scan_complete
*x
= ¬if
->u
.scan_complete
;
4484 if (notif
->size
== sizeof(*x
)) {
4486 ("Scan completed: type %d, %d channels, "
4487 "%d status\n", x
->scan_type
,
4488 x
->num_channels
, x
->status
);
4490 IPW_ERROR("Scan completed of wrong size %d "
4491 "(should be %zd)\n",
4492 notif
->size
, sizeof(*x
));
4496 ~(STATUS_SCANNING
| STATUS_SCAN_ABORTING
);
4498 wake_up_interruptible(&priv
->wait_state
);
4499 cancel_delayed_work(&priv
->scan_check
);
4501 if (priv
->status
& STATUS_EXIT_PENDING
)
4504 priv
->ieee
->scans
++;
4506 #ifdef CONFIG_IPW2200_MONITOR
4507 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
) {
4508 priv
->status
|= STATUS_SCAN_FORCED
;
4509 queue_work(priv
->workqueue
,
4510 &priv
->request_scan
);
4513 priv
->status
&= ~STATUS_SCAN_FORCED
;
4514 #endif /* CONFIG_IPW2200_MONITOR */
4516 if (!(priv
->status
& (STATUS_ASSOCIATED
|
4517 STATUS_ASSOCIATING
|
4519 STATUS_DISASSOCIATING
)))
4520 queue_work(priv
->workqueue
, &priv
->associate
);
4521 else if (priv
->status
& STATUS_ROAMING
) {
4522 if (x
->status
== SCAN_COMPLETED_STATUS_COMPLETE
)
4523 /* If a scan completed and we are in roam mode, then
4524 * the scan that completed was the one requested as a
4525 * result of entering roam... so, schedule the
4527 queue_work(priv
->workqueue
,
4530 /* Don't schedule if we aborted the scan */
4531 priv
->status
&= ~STATUS_ROAMING
;
4532 } else if (priv
->status
& STATUS_SCAN_PENDING
)
4533 queue_work(priv
->workqueue
,
4534 &priv
->request_scan
);
4535 else if (priv
->config
& CFG_BACKGROUND_SCAN
4536 && priv
->status
& STATUS_ASSOCIATED
)
4537 queue_delayed_work(priv
->workqueue
,
4538 &priv
->request_scan
, HZ
);
4542 case HOST_NOTIFICATION_STATUS_FRAG_LENGTH
:{
4543 struct notif_frag_length
*x
= ¬if
->u
.frag_len
;
4545 if (notif
->size
== sizeof(*x
))
4546 IPW_ERROR("Frag length: %d\n",
4547 le16_to_cpu(x
->frag_length
));
4549 IPW_ERROR("Frag length of wrong size %d "
4550 "(should be %zd)\n",
4551 notif
->size
, sizeof(*x
));
4555 case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION
:{
4556 struct notif_link_deterioration
*x
=
4557 ¬if
->u
.link_deterioration
;
4559 if (notif
->size
== sizeof(*x
)) {
4560 IPW_DEBUG(IPW_DL_NOTIF
| IPW_DL_STATE
,
4561 "link deterioration: '%s' " MAC_FMT
4562 " \n", escape_essid(priv
->essid
,
4564 MAC_ARG(priv
->bssid
));
4565 memcpy(&priv
->last_link_deterioration
, x
,
4568 IPW_ERROR("Link Deterioration of wrong size %d "
4569 "(should be %zd)\n",
4570 notif
->size
, sizeof(*x
));
4575 case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE
:{
4576 IPW_ERROR("Dino config\n");
4578 && priv
->hcmd
->cmd
!= HOST_CMD_DINO_CONFIG
)
4579 IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n");
4584 case HOST_NOTIFICATION_STATUS_BEACON_STATE
:{
4585 struct notif_beacon_state
*x
= ¬if
->u
.beacon_state
;
4586 if (notif
->size
!= sizeof(*x
)) {
4588 ("Beacon state of wrong size %d (should "
4589 "be %zd)\n", notif
->size
, sizeof(*x
));
4593 if (le32_to_cpu(x
->state
) ==
4594 HOST_NOTIFICATION_STATUS_BEACON_MISSING
)
4595 ipw_handle_missed_beacon(priv
,
4602 case HOST_NOTIFICATION_STATUS_TGI_TX_KEY
:{
4603 struct notif_tgi_tx_key
*x
= ¬if
->u
.tgi_tx_key
;
4604 if (notif
->size
== sizeof(*x
)) {
4605 IPW_ERROR("TGi Tx Key: state 0x%02x sec type "
4606 "0x%02x station %d\n",
4607 x
->key_state
, x
->security_type
,
4613 ("TGi Tx Key of wrong size %d (should be %zd)\n",
4614 notif
->size
, sizeof(*x
));
4618 case HOST_NOTIFICATION_CALIB_KEEP_RESULTS
:{
4619 struct notif_calibration
*x
= ¬if
->u
.calibration
;
4621 if (notif
->size
== sizeof(*x
)) {
4622 memcpy(&priv
->calib
, x
, sizeof(*x
));
4623 IPW_DEBUG_INFO("TODO: Calibration\n");
4628 ("Calibration of wrong size %d (should be %zd)\n",
4629 notif
->size
, sizeof(*x
));
4633 case HOST_NOTIFICATION_NOISE_STATS
:{
4634 if (notif
->size
== sizeof(u32
)) {
4636 (u8
) (le32_to_cpu(notif
->u
.noise
.value
) &
4638 average_add(&priv
->average_noise
,
4644 ("Noise stat is wrong size %d (should be %zd)\n",
4645 notif
->size
, sizeof(u32
));
4650 IPW_ERROR("Unknown notification: "
4651 "subtype=%d,flags=0x%2x,size=%d\n",
4652 notif
->subtype
, notif
->flags
, notif
->size
);
4657 * Destroys all DMA structures and initialise them again
4660 * @return error code
4662 static int ipw_queue_reset(struct ipw_priv
*priv
)
4665 /** @todo customize queue sizes */
4666 int nTx
= 64, nTxCmd
= 8;
4667 ipw_tx_queue_free(priv
);
4669 rc
= ipw_queue_tx_init(priv
, &priv
->txq_cmd
, nTxCmd
,
4670 IPW_TX_CMD_QUEUE_READ_INDEX
,
4671 IPW_TX_CMD_QUEUE_WRITE_INDEX
,
4672 IPW_TX_CMD_QUEUE_BD_BASE
,
4673 IPW_TX_CMD_QUEUE_BD_SIZE
);
4675 IPW_ERROR("Tx Cmd queue init failed\n");
4679 rc
= ipw_queue_tx_init(priv
, &priv
->txq
[0], nTx
,
4680 IPW_TX_QUEUE_0_READ_INDEX
,
4681 IPW_TX_QUEUE_0_WRITE_INDEX
,
4682 IPW_TX_QUEUE_0_BD_BASE
, IPW_TX_QUEUE_0_BD_SIZE
);
4684 IPW_ERROR("Tx 0 queue init failed\n");
4687 rc
= ipw_queue_tx_init(priv
, &priv
->txq
[1], nTx
,
4688 IPW_TX_QUEUE_1_READ_INDEX
,
4689 IPW_TX_QUEUE_1_WRITE_INDEX
,
4690 IPW_TX_QUEUE_1_BD_BASE
, IPW_TX_QUEUE_1_BD_SIZE
);
4692 IPW_ERROR("Tx 1 queue init failed\n");
4695 rc
= ipw_queue_tx_init(priv
, &priv
->txq
[2], nTx
,
4696 IPW_TX_QUEUE_2_READ_INDEX
,
4697 IPW_TX_QUEUE_2_WRITE_INDEX
,
4698 IPW_TX_QUEUE_2_BD_BASE
, IPW_TX_QUEUE_2_BD_SIZE
);
4700 IPW_ERROR("Tx 2 queue init failed\n");
4703 rc
= ipw_queue_tx_init(priv
, &priv
->txq
[3], nTx
,
4704 IPW_TX_QUEUE_3_READ_INDEX
,
4705 IPW_TX_QUEUE_3_WRITE_INDEX
,
4706 IPW_TX_QUEUE_3_BD_BASE
, IPW_TX_QUEUE_3_BD_SIZE
);
4708 IPW_ERROR("Tx 3 queue init failed\n");
4712 priv
->rx_bufs_min
= 0;
4713 priv
->rx_pend_max
= 0;
4717 ipw_tx_queue_free(priv
);
4722 * Reclaim Tx queue entries no more used by NIC.
4724 * When FW adwances 'R' index, all entries between old and
4725 * new 'R' index need to be reclaimed. As result, some free space
4726 * forms. If there is enough free space (> low mark), wake Tx queue.
4728 * @note Need to protect against garbage in 'R' index
4732 * @return Number of used entries remains in the queue
4734 static int ipw_queue_tx_reclaim(struct ipw_priv
*priv
,
4735 struct clx2_tx_queue
*txq
, int qindex
)
4739 struct clx2_queue
*q
= &txq
->q
;
4741 hw_tail
= ipw_read32(priv
, q
->reg_r
);
4742 if (hw_tail
>= q
->n_bd
) {
4744 ("Read index for DMA queue (%d) is out of range [0-%d)\n",
4748 for (; q
->last_used
!= hw_tail
;
4749 q
->last_used
= ipw_queue_inc_wrap(q
->last_used
, q
->n_bd
)) {
4750 ipw_queue_tx_free_tfd(priv
, txq
);
4754 if ((ipw_queue_space(q
) > q
->low_mark
) &&
4756 (priv
->status
& STATUS_ASSOCIATED
) && netif_running(priv
->net_dev
))
4757 netif_wake_queue(priv
->net_dev
);
4758 used
= q
->first_empty
- q
->last_used
;
4765 static int ipw_queue_tx_hcmd(struct ipw_priv
*priv
, int hcmd
, void *buf
,
4768 struct clx2_tx_queue
*txq
= &priv
->txq_cmd
;
4769 struct clx2_queue
*q
= &txq
->q
;
4770 struct tfd_frame
*tfd
;
4772 if (ipw_queue_space(q
) < (sync
? 1 : 2)) {
4773 IPW_ERROR("No space for Tx\n");
4777 tfd
= &txq
->bd
[q
->first_empty
];
4778 txq
->txb
[q
->first_empty
] = NULL
;
4780 memset(tfd
, 0, sizeof(*tfd
));
4781 tfd
->control_flags
.message_type
= TX_HOST_COMMAND_TYPE
;
4782 tfd
->control_flags
.control_bits
= TFD_NEED_IRQ_MASK
;
4784 tfd
->u
.cmd
.index
= hcmd
;
4785 tfd
->u
.cmd
.length
= len
;
4786 memcpy(tfd
->u
.cmd
.payload
, buf
, len
);
4787 q
->first_empty
= ipw_queue_inc_wrap(q
->first_empty
, q
->n_bd
);
4788 ipw_write32(priv
, q
->reg_w
, q
->first_empty
);
4789 _ipw_read32(priv
, 0x90);
4795 * Rx theory of operation
4797 * The host allocates 32 DMA target addresses and passes the host address
4798 * to the firmware at register IPW_RFDS_TABLE_LOWER + N * RFD_SIZE where N is
4802 * The host/firmware share two index registers for managing the Rx buffers.
4804 * The READ index maps to the first position that the firmware may be writing
4805 * to -- the driver can read up to (but not including) this position and get
4807 * The READ index is managed by the firmware once the card is enabled.
4809 * The WRITE index maps to the last position the driver has read from -- the
4810 * position preceding WRITE is the last slot the firmware can place a packet.
4812 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
4815 * During initialization the host sets up the READ queue position to the first
4816 * INDEX position, and WRITE to the last (READ - 1 wrapped)
4818 * When the firmware places a packet in a buffer it will advance the READ index
4819 * and fire the RX interrupt. The driver can then query the READ index and
4820 * process as many packets as possible, moving the WRITE index forward as it
4821 * resets the Rx queue buffers with new memory.
4823 * The management in the driver is as follows:
4824 * + A list of pre-allocated SKBs is stored in ipw->rxq->rx_free. When
4825 * ipw->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
4826 * to replensish the ipw->rxq->rx_free.
4827 * + In ipw_rx_queue_replenish (scheduled) if 'processed' != 'read' then the
4828 * ipw->rxq is replenished and the READ INDEX is updated (updating the
4829 * 'processed' and 'read' driver indexes as well)
4830 * + A received packet is processed and handed to the kernel network stack,
4831 * detached from the ipw->rxq. The driver 'processed' index is updated.
4832 * + The Host/Firmware ipw->rxq is replenished at tasklet time from the rx_free
4833 * list. If there are no allocated buffers in ipw->rxq->rx_free, the READ
4834 * INDEX is not incremented and ipw->status(RX_STALLED) is set. If there
4835 * were enough free buffers and RX_STALLED is set it is cleared.
4840 * ipw_rx_queue_alloc() Allocates rx_free
4841 * ipw_rx_queue_replenish() Replenishes rx_free list from rx_used, and calls
4842 * ipw_rx_queue_restock
4843 * ipw_rx_queue_restock() Moves available buffers from rx_free into Rx
4844 * queue, updates firmware pointers, and updates
4845 * the WRITE index. If insufficient rx_free buffers
4846 * are available, schedules ipw_rx_queue_replenish
4848 * -- enable interrupts --
4849 * ISR - ipw_rx() Detach ipw_rx_mem_buffers from pool up to the
4850 * READ INDEX, detaching the SKB from the pool.
4851 * Moves the packet buffer from queue to rx_used.
4852 * Calls ipw_rx_queue_restock to refill any empty
4859 * If there are slots in the RX queue that need to be restocked,
4860 * and we have free pre-allocated buffers, fill the ranks as much
4861 * as we can pulling from rx_free.
4863 * This moves the 'write' index forward to catch up with 'processed', and
4864 * also updates the memory address in the firmware to reference the new
4867 static void ipw_rx_queue_restock(struct ipw_priv
*priv
)
4869 struct ipw_rx_queue
*rxq
= priv
->rxq
;
4870 struct list_head
*element
;
4871 struct ipw_rx_mem_buffer
*rxb
;
4872 unsigned long flags
;
4875 spin_lock_irqsave(&rxq
->lock
, flags
);
4877 while ((rxq
->write
!= rxq
->processed
) && (rxq
->free_count
)) {
4878 element
= rxq
->rx_free
.next
;
4879 rxb
= list_entry(element
, struct ipw_rx_mem_buffer
, list
);
4882 ipw_write32(priv
, IPW_RFDS_TABLE_LOWER
+ rxq
->write
* RFD_SIZE
,
4884 rxq
->queue
[rxq
->write
] = rxb
;
4885 rxq
->write
= (rxq
->write
+ 1) % RX_QUEUE_SIZE
;
4888 spin_unlock_irqrestore(&rxq
->lock
, flags
);
4890 /* If the pre-allocated buffer pool is dropping low, schedule to
4892 if (rxq
->free_count
<= RX_LOW_WATERMARK
)
4893 queue_work(priv
->workqueue
, &priv
->rx_replenish
);
4895 /* If we've added more space for the firmware to place data, tell it */
4896 if (write
!= rxq
->write
)
4897 ipw_write32(priv
, IPW_RX_WRITE_INDEX
, rxq
->write
);
4901 * Move all used packet from rx_used to rx_free, allocating a new SKB for each.
4902 * Also restock the Rx queue via ipw_rx_queue_restock.
4904 * This is called as a scheduled work item (except for during intialization)
4906 static void ipw_rx_queue_replenish(void *data
)
4908 struct ipw_priv
*priv
= data
;
4909 struct ipw_rx_queue
*rxq
= priv
->rxq
;
4910 struct list_head
*element
;
4911 struct ipw_rx_mem_buffer
*rxb
;
4912 unsigned long flags
;
4914 spin_lock_irqsave(&rxq
->lock
, flags
);
4915 while (!list_empty(&rxq
->rx_used
)) {
4916 element
= rxq
->rx_used
.next
;
4917 rxb
= list_entry(element
, struct ipw_rx_mem_buffer
, list
);
4918 rxb
->skb
= alloc_skb(IPW_RX_BUF_SIZE
, GFP_ATOMIC
);
4920 printk(KERN_CRIT
"%s: Can not allocate SKB buffers.\n",
4921 priv
->net_dev
->name
);
4922 /* We don't reschedule replenish work here -- we will
4923 * call the restock method and if it still needs
4924 * more buffers it will schedule replenish */
4929 rxb
->rxb
= (struct ipw_rx_buffer
*)rxb
->skb
->data
;
4931 pci_map_single(priv
->pci_dev
, rxb
->skb
->data
,
4932 IPW_RX_BUF_SIZE
, PCI_DMA_FROMDEVICE
);
4934 list_add_tail(&rxb
->list
, &rxq
->rx_free
);
4937 spin_unlock_irqrestore(&rxq
->lock
, flags
);
4939 ipw_rx_queue_restock(priv
);
4942 static void ipw_bg_rx_queue_replenish(void *data
)
4944 struct ipw_priv
*priv
= data
;
4946 ipw_rx_queue_replenish(data
);
4950 /* Assumes that the skb field of the buffers in 'pool' is kept accurate.
4951 * If an SKB has been detached, the POOL needs to have its SKB set to NULL
4952 * This free routine walks the list of POOL entries and if SKB is set to
4953 * non NULL it is unmapped and freed
4955 static void ipw_rx_queue_free(struct ipw_priv
*priv
, struct ipw_rx_queue
*rxq
)
4962 for (i
= 0; i
< RX_QUEUE_SIZE
+ RX_FREE_BUFFERS
; i
++) {
4963 if (rxq
->pool
[i
].skb
!= NULL
) {
4964 pci_unmap_single(priv
->pci_dev
, rxq
->pool
[i
].dma_addr
,
4965 IPW_RX_BUF_SIZE
, PCI_DMA_FROMDEVICE
);
4966 dev_kfree_skb(rxq
->pool
[i
].skb
);
4973 static struct ipw_rx_queue
*ipw_rx_queue_alloc(struct ipw_priv
*priv
)
4975 struct ipw_rx_queue
*rxq
;
4978 rxq
= kzalloc(sizeof(*rxq
), GFP_KERNEL
);
4979 if (unlikely(!rxq
)) {
4980 IPW_ERROR("memory allocation failed\n");
4983 spin_lock_init(&rxq
->lock
);
4984 INIT_LIST_HEAD(&rxq
->rx_free
);
4985 INIT_LIST_HEAD(&rxq
->rx_used
);
4987 /* Fill the rx_used queue with _all_ of the Rx buffers */
4988 for (i
= 0; i
< RX_FREE_BUFFERS
+ RX_QUEUE_SIZE
; i
++)
4989 list_add_tail(&rxq
->pool
[i
].list
, &rxq
->rx_used
);
4991 /* Set us so that we have processed and used all buffers, but have
4992 * not restocked the Rx queue with fresh buffers */
4993 rxq
->read
= rxq
->write
= 0;
4994 rxq
->processed
= RX_QUEUE_SIZE
- 1;
4995 rxq
->free_count
= 0;
5000 static int ipw_is_rate_in_mask(struct ipw_priv
*priv
, int ieee_mode
, u8 rate
)
5002 rate
&= ~IEEE80211_BASIC_RATE_MASK
;
5003 if (ieee_mode
== IEEE_A
) {
5005 case IEEE80211_OFDM_RATE_6MB
:
5006 return priv
->rates_mask
& IEEE80211_OFDM_RATE_6MB_MASK
?
5008 case IEEE80211_OFDM_RATE_9MB
:
5009 return priv
->rates_mask
& IEEE80211_OFDM_RATE_9MB_MASK
?
5011 case IEEE80211_OFDM_RATE_12MB
:
5013 rates_mask
& IEEE80211_OFDM_RATE_12MB_MASK
? 1 : 0;
5014 case IEEE80211_OFDM_RATE_18MB
:
5016 rates_mask
& IEEE80211_OFDM_RATE_18MB_MASK
? 1 : 0;
5017 case IEEE80211_OFDM_RATE_24MB
:
5019 rates_mask
& IEEE80211_OFDM_RATE_24MB_MASK
? 1 : 0;
5020 case IEEE80211_OFDM_RATE_36MB
:
5022 rates_mask
& IEEE80211_OFDM_RATE_36MB_MASK
? 1 : 0;
5023 case IEEE80211_OFDM_RATE_48MB
:
5025 rates_mask
& IEEE80211_OFDM_RATE_48MB_MASK
? 1 : 0;
5026 case IEEE80211_OFDM_RATE_54MB
:
5028 rates_mask
& IEEE80211_OFDM_RATE_54MB_MASK
? 1 : 0;
5036 case IEEE80211_CCK_RATE_1MB
:
5037 return priv
->rates_mask
& IEEE80211_CCK_RATE_1MB_MASK
? 1 : 0;
5038 case IEEE80211_CCK_RATE_2MB
:
5039 return priv
->rates_mask
& IEEE80211_CCK_RATE_2MB_MASK
? 1 : 0;
5040 case IEEE80211_CCK_RATE_5MB
:
5041 return priv
->rates_mask
& IEEE80211_CCK_RATE_5MB_MASK
? 1 : 0;
5042 case IEEE80211_CCK_RATE_11MB
:
5043 return priv
->rates_mask
& IEEE80211_CCK_RATE_11MB_MASK
? 1 : 0;
5046 /* If we are limited to B modulations, bail at this point */
5047 if (ieee_mode
== IEEE_B
)
5052 case IEEE80211_OFDM_RATE_6MB
:
5053 return priv
->rates_mask
& IEEE80211_OFDM_RATE_6MB_MASK
? 1 : 0;
5054 case IEEE80211_OFDM_RATE_9MB
:
5055 return priv
->rates_mask
& IEEE80211_OFDM_RATE_9MB_MASK
? 1 : 0;
5056 case IEEE80211_OFDM_RATE_12MB
:
5057 return priv
->rates_mask
& IEEE80211_OFDM_RATE_12MB_MASK
? 1 : 0;
5058 case IEEE80211_OFDM_RATE_18MB
:
5059 return priv
->rates_mask
& IEEE80211_OFDM_RATE_18MB_MASK
? 1 : 0;
5060 case IEEE80211_OFDM_RATE_24MB
:
5061 return priv
->rates_mask
& IEEE80211_OFDM_RATE_24MB_MASK
? 1 : 0;
5062 case IEEE80211_OFDM_RATE_36MB
:
5063 return priv
->rates_mask
& IEEE80211_OFDM_RATE_36MB_MASK
? 1 : 0;
5064 case IEEE80211_OFDM_RATE_48MB
:
5065 return priv
->rates_mask
& IEEE80211_OFDM_RATE_48MB_MASK
? 1 : 0;
5066 case IEEE80211_OFDM_RATE_54MB
:
5067 return priv
->rates_mask
& IEEE80211_OFDM_RATE_54MB_MASK
? 1 : 0;
5073 static int ipw_compatible_rates(struct ipw_priv
*priv
,
5074 const struct ieee80211_network
*network
,
5075 struct ipw_supported_rates
*rates
)
5079 memset(rates
, 0, sizeof(*rates
));
5080 num_rates
= min(network
->rates_len
, (u8
) IPW_MAX_RATES
);
5081 rates
->num_rates
= 0;
5082 for (i
= 0; i
< num_rates
; i
++) {
5083 if (!ipw_is_rate_in_mask(priv
, network
->mode
,
5084 network
->rates
[i
])) {
5086 if (network
->rates
[i
] & IEEE80211_BASIC_RATE_MASK
) {
5087 IPW_DEBUG_SCAN("Adding masked mandatory "
5090 rates
->supported_rates
[rates
->num_rates
++] =
5095 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
5096 network
->rates
[i
], priv
->rates_mask
);
5100 rates
->supported_rates
[rates
->num_rates
++] = network
->rates
[i
];
5103 num_rates
= min(network
->rates_ex_len
,
5104 (u8
) (IPW_MAX_RATES
- num_rates
));
5105 for (i
= 0; i
< num_rates
; i
++) {
5106 if (!ipw_is_rate_in_mask(priv
, network
->mode
,
5107 network
->rates_ex
[i
])) {
5108 if (network
->rates_ex
[i
] & IEEE80211_BASIC_RATE_MASK
) {
5109 IPW_DEBUG_SCAN("Adding masked mandatory "
5111 network
->rates_ex
[i
]);
5112 rates
->supported_rates
[rates
->num_rates
++] =
5117 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
5118 network
->rates_ex
[i
], priv
->rates_mask
);
5122 rates
->supported_rates
[rates
->num_rates
++] =
5123 network
->rates_ex
[i
];
5129 static void ipw_copy_rates(struct ipw_supported_rates
*dest
,
5130 const struct ipw_supported_rates
*src
)
5133 for (i
= 0; i
< src
->num_rates
; i
++)
5134 dest
->supported_rates
[i
] = src
->supported_rates
[i
];
5135 dest
->num_rates
= src
->num_rates
;
5138 /* TODO: Look at sniffed packets in the air to determine if the basic rate
5139 * mask should ever be used -- right now all callers to add the scan rates are
5140 * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */
5141 static void ipw_add_cck_scan_rates(struct ipw_supported_rates
*rates
,
5142 u8 modulation
, u32 rate_mask
)
5144 u8 basic_mask
= (IEEE80211_OFDM_MODULATION
== modulation
) ?
5145 IEEE80211_BASIC_RATE_MASK
: 0;
5147 if (rate_mask
& IEEE80211_CCK_RATE_1MB_MASK
)
5148 rates
->supported_rates
[rates
->num_rates
++] =
5149 IEEE80211_BASIC_RATE_MASK
| IEEE80211_CCK_RATE_1MB
;
5151 if (rate_mask
& IEEE80211_CCK_RATE_2MB_MASK
)
5152 rates
->supported_rates
[rates
->num_rates
++] =
5153 IEEE80211_BASIC_RATE_MASK
| IEEE80211_CCK_RATE_2MB
;
5155 if (rate_mask
& IEEE80211_CCK_RATE_5MB_MASK
)
5156 rates
->supported_rates
[rates
->num_rates
++] = basic_mask
|
5157 IEEE80211_CCK_RATE_5MB
;
5159 if (rate_mask
& IEEE80211_CCK_RATE_11MB_MASK
)
5160 rates
->supported_rates
[rates
->num_rates
++] = basic_mask
|
5161 IEEE80211_CCK_RATE_11MB
;
5164 static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates
*rates
,
5165 u8 modulation
, u32 rate_mask
)
5167 u8 basic_mask
= (IEEE80211_OFDM_MODULATION
== modulation
) ?
5168 IEEE80211_BASIC_RATE_MASK
: 0;
5170 if (rate_mask
& IEEE80211_OFDM_RATE_6MB_MASK
)
5171 rates
->supported_rates
[rates
->num_rates
++] = basic_mask
|
5172 IEEE80211_OFDM_RATE_6MB
;
5174 if (rate_mask
& IEEE80211_OFDM_RATE_9MB_MASK
)
5175 rates
->supported_rates
[rates
->num_rates
++] =
5176 IEEE80211_OFDM_RATE_9MB
;
5178 if (rate_mask
& IEEE80211_OFDM_RATE_12MB_MASK
)
5179 rates
->supported_rates
[rates
->num_rates
++] = basic_mask
|
5180 IEEE80211_OFDM_RATE_12MB
;
5182 if (rate_mask
& IEEE80211_OFDM_RATE_18MB_MASK
)
5183 rates
->supported_rates
[rates
->num_rates
++] =
5184 IEEE80211_OFDM_RATE_18MB
;
5186 if (rate_mask
& IEEE80211_OFDM_RATE_24MB_MASK
)
5187 rates
->supported_rates
[rates
->num_rates
++] = basic_mask
|
5188 IEEE80211_OFDM_RATE_24MB
;
5190 if (rate_mask
& IEEE80211_OFDM_RATE_36MB_MASK
)
5191 rates
->supported_rates
[rates
->num_rates
++] =
5192 IEEE80211_OFDM_RATE_36MB
;
5194 if (rate_mask
& IEEE80211_OFDM_RATE_48MB_MASK
)
5195 rates
->supported_rates
[rates
->num_rates
++] =
5196 IEEE80211_OFDM_RATE_48MB
;
5198 if (rate_mask
& IEEE80211_OFDM_RATE_54MB_MASK
)
5199 rates
->supported_rates
[rates
->num_rates
++] =
5200 IEEE80211_OFDM_RATE_54MB
;
5203 struct ipw_network_match
{
5204 struct ieee80211_network
*network
;
5205 struct ipw_supported_rates rates
;
5208 static int ipw_find_adhoc_network(struct ipw_priv
*priv
,
5209 struct ipw_network_match
*match
,
5210 struct ieee80211_network
*network
,
5213 struct ipw_supported_rates rates
;
5215 /* Verify that this network's capability is compatible with the
5216 * current mode (AdHoc or Infrastructure) */
5217 if ((priv
->ieee
->iw_mode
== IW_MODE_ADHOC
&&
5218 !(network
->capability
& WLAN_CAPABILITY_IBSS
))) {
5219 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded due to "
5220 "capability mismatch.\n",
5221 escape_essid(network
->ssid
, network
->ssid_len
),
5222 MAC_ARG(network
->bssid
));
5226 /* If we do not have an ESSID for this AP, we can not associate with
5228 if (network
->flags
& NETWORK_EMPTY_ESSID
) {
5229 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5230 "because of hidden ESSID.\n",
5231 escape_essid(network
->ssid
, network
->ssid_len
),
5232 MAC_ARG(network
->bssid
));
5236 if (unlikely(roaming
)) {
5237 /* If we are roaming, then ensure check if this is a valid
5238 * network to try and roam to */
5239 if ((network
->ssid_len
!= match
->network
->ssid_len
) ||
5240 memcmp(network
->ssid
, match
->network
->ssid
,
5241 network
->ssid_len
)) {
5242 IPW_DEBUG_MERGE("Netowrk '%s (" MAC_FMT
")' excluded "
5243 "because of non-network ESSID.\n",
5244 escape_essid(network
->ssid
,
5246 MAC_ARG(network
->bssid
));
5250 /* If an ESSID has been configured then compare the broadcast
5252 if ((priv
->config
& CFG_STATIC_ESSID
) &&
5253 ((network
->ssid_len
!= priv
->essid_len
) ||
5254 memcmp(network
->ssid
, priv
->essid
,
5255 min(network
->ssid_len
, priv
->essid_len
)))) {
5256 char escaped
[IW_ESSID_MAX_SIZE
* 2 + 1];
5259 escape_essid(network
->ssid
, network
->ssid_len
),
5261 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5262 "because of ESSID mismatch: '%s'.\n",
5263 escaped
, MAC_ARG(network
->bssid
),
5264 escape_essid(priv
->essid
,
5270 /* If the old network rate is better than this one, don't bother
5271 * testing everything else. */
5273 if (network
->time_stamp
[0] < match
->network
->time_stamp
[0]) {
5274 IPW_DEBUG_MERGE("Network '%s excluded because newer than "
5275 "current network.\n",
5276 escape_essid(match
->network
->ssid
,
5277 match
->network
->ssid_len
));
5279 } else if (network
->time_stamp
[1] < match
->network
->time_stamp
[1]) {
5280 IPW_DEBUG_MERGE("Network '%s excluded because newer than "
5281 "current network.\n",
5282 escape_essid(match
->network
->ssid
,
5283 match
->network
->ssid_len
));
5287 /* Now go through and see if the requested network is valid... */
5288 if (priv
->ieee
->scan_age
!= 0 &&
5289 time_after(jiffies
, network
->last_scanned
+ priv
->ieee
->scan_age
)) {
5290 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5291 "because of age: %ums.\n",
5292 escape_essid(network
->ssid
, network
->ssid_len
),
5293 MAC_ARG(network
->bssid
),
5294 jiffies_to_msecs(jiffies
- network
->last_scanned
));
5298 if ((priv
->config
& CFG_STATIC_CHANNEL
) &&
5299 (network
->channel
!= priv
->channel
)) {
5300 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5301 "because of channel mismatch: %d != %d.\n",
5302 escape_essid(network
->ssid
, network
->ssid_len
),
5303 MAC_ARG(network
->bssid
),
5304 network
->channel
, priv
->channel
);
5308 /* Verify privacy compatability */
5309 if (((priv
->capability
& CAP_PRIVACY_ON
) ? 1 : 0) !=
5310 ((network
->capability
& WLAN_CAPABILITY_PRIVACY
) ? 1 : 0)) {
5311 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5312 "because of privacy mismatch: %s != %s.\n",
5313 escape_essid(network
->ssid
, network
->ssid_len
),
5314 MAC_ARG(network
->bssid
),
5316 capability
& CAP_PRIVACY_ON
? "on" : "off",
5318 capability
& WLAN_CAPABILITY_PRIVACY
? "on" :
5323 if (!memcmp(network
->bssid
, priv
->bssid
, ETH_ALEN
)) {
5324 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5325 "because of the same BSSID match: " MAC_FMT
5326 ".\n", escape_essid(network
->ssid
,
5328 MAC_ARG(network
->bssid
), MAC_ARG(priv
->bssid
));
5332 /* Filter out any incompatible freq / mode combinations */
5333 if (!ieee80211_is_valid_mode(priv
->ieee
, network
->mode
)) {
5334 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5335 "because of invalid frequency/mode "
5337 escape_essid(network
->ssid
, network
->ssid_len
),
5338 MAC_ARG(network
->bssid
));
5342 /* Ensure that the rates supported by the driver are compatible with
5343 * this AP, including verification of basic rates (mandatory) */
5344 if (!ipw_compatible_rates(priv
, network
, &rates
)) {
5345 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5346 "because configured rate mask excludes "
5347 "AP mandatory rate.\n",
5348 escape_essid(network
->ssid
, network
->ssid_len
),
5349 MAC_ARG(network
->bssid
));
5353 if (rates
.num_rates
== 0) {
5354 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' excluded "
5355 "because of no compatible rates.\n",
5356 escape_essid(network
->ssid
, network
->ssid_len
),
5357 MAC_ARG(network
->bssid
));
5361 /* TODO: Perform any further minimal comparititive tests. We do not
5362 * want to put too much policy logic here; intelligent scan selection
5363 * should occur within a generic IEEE 802.11 user space tool. */
5365 /* Set up 'new' AP to this network */
5366 ipw_copy_rates(&match
->rates
, &rates
);
5367 match
->network
= network
;
5368 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT
")' is a viable match.\n",
5369 escape_essid(network
->ssid
, network
->ssid_len
),
5370 MAC_ARG(network
->bssid
));
5375 static void ipw_merge_adhoc_network(void *data
)
5377 struct ipw_priv
*priv
= data
;
5378 struct ieee80211_network
*network
= NULL
;
5379 struct ipw_network_match match
= {
5380 .network
= priv
->assoc_network
5383 if ((priv
->status
& STATUS_ASSOCIATED
) &&
5384 (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
)) {
5385 /* First pass through ROAM process -- look for a better
5387 unsigned long flags
;
5389 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
5390 list_for_each_entry(network
, &priv
->ieee
->network_list
, list
) {
5391 if (network
!= priv
->assoc_network
)
5392 ipw_find_adhoc_network(priv
, &match
, network
,
5395 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
5397 if (match
.network
== priv
->assoc_network
) {
5398 IPW_DEBUG_MERGE("No better ADHOC in this network to "
5404 if ((priv
->ieee
->iw_mode
== IW_MODE_ADHOC
)) {
5405 IPW_DEBUG_MERGE("remove network %s\n",
5406 escape_essid(priv
->essid
,
5408 ipw_remove_current_network(priv
);
5411 ipw_disassociate(priv
);
5412 priv
->assoc_network
= match
.network
;
5418 static int ipw_best_network(struct ipw_priv
*priv
,
5419 struct ipw_network_match
*match
,
5420 struct ieee80211_network
*network
, int roaming
)
5422 struct ipw_supported_rates rates
;
5424 /* Verify that this network's capability is compatible with the
5425 * current mode (AdHoc or Infrastructure) */
5426 if ((priv
->ieee
->iw_mode
== IW_MODE_INFRA
&&
5427 !(network
->capability
& WLAN_CAPABILITY_ESS
)) ||
5428 (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
&&
5429 !(network
->capability
& WLAN_CAPABILITY_IBSS
))) {
5430 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded due to "
5431 "capability mismatch.\n",
5432 escape_essid(network
->ssid
, network
->ssid_len
),
5433 MAC_ARG(network
->bssid
));
5437 /* If we do not have an ESSID for this AP, we can not associate with
5439 if (network
->flags
& NETWORK_EMPTY_ESSID
) {
5440 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5441 "because of hidden ESSID.\n",
5442 escape_essid(network
->ssid
, network
->ssid_len
),
5443 MAC_ARG(network
->bssid
));
5447 if (unlikely(roaming
)) {
5448 /* If we are roaming, then ensure check if this is a valid
5449 * network to try and roam to */
5450 if ((network
->ssid_len
!= match
->network
->ssid_len
) ||
5451 memcmp(network
->ssid
, match
->network
->ssid
,
5452 network
->ssid_len
)) {
5453 IPW_DEBUG_ASSOC("Netowrk '%s (" MAC_FMT
")' excluded "
5454 "because of non-network ESSID.\n",
5455 escape_essid(network
->ssid
,
5457 MAC_ARG(network
->bssid
));
5461 /* If an ESSID has been configured then compare the broadcast
5463 if ((priv
->config
& CFG_STATIC_ESSID
) &&
5464 ((network
->ssid_len
!= priv
->essid_len
) ||
5465 memcmp(network
->ssid
, priv
->essid
,
5466 min(network
->ssid_len
, priv
->essid_len
)))) {
5467 char escaped
[IW_ESSID_MAX_SIZE
* 2 + 1];
5469 escape_essid(network
->ssid
, network
->ssid_len
),
5471 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5472 "because of ESSID mismatch: '%s'.\n",
5473 escaped
, MAC_ARG(network
->bssid
),
5474 escape_essid(priv
->essid
,
5480 /* If the old network rate is better than this one, don't bother
5481 * testing everything else. */
5482 if (match
->network
&& match
->network
->stats
.rssi
> network
->stats
.rssi
) {
5483 char escaped
[IW_ESSID_MAX_SIZE
* 2 + 1];
5485 escape_essid(network
->ssid
, network
->ssid_len
),
5487 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded because "
5488 "'%s (" MAC_FMT
")' has a stronger signal.\n",
5489 escaped
, MAC_ARG(network
->bssid
),
5490 escape_essid(match
->network
->ssid
,
5491 match
->network
->ssid_len
),
5492 MAC_ARG(match
->network
->bssid
));
5496 /* If this network has already had an association attempt within the
5497 * last 3 seconds, do not try and associate again... */
5498 if (network
->last_associate
&&
5499 time_after(network
->last_associate
+ (HZ
* 3UL), jiffies
)) {
5500 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5501 "because of storming (%ums since last "
5502 "assoc attempt).\n",
5503 escape_essid(network
->ssid
, network
->ssid_len
),
5504 MAC_ARG(network
->bssid
),
5505 jiffies_to_msecs(jiffies
- network
->last_associate
));
5509 /* Now go through and see if the requested network is valid... */
5510 if (priv
->ieee
->scan_age
!= 0 &&
5511 time_after(jiffies
, network
->last_scanned
+ priv
->ieee
->scan_age
)) {
5512 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5513 "because of age: %ums.\n",
5514 escape_essid(network
->ssid
, network
->ssid_len
),
5515 MAC_ARG(network
->bssid
),
5516 jiffies_to_msecs(jiffies
- network
->last_scanned
));
5520 if ((priv
->config
& CFG_STATIC_CHANNEL
) &&
5521 (network
->channel
!= priv
->channel
)) {
5522 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5523 "because of channel mismatch: %d != %d.\n",
5524 escape_essid(network
->ssid
, network
->ssid_len
),
5525 MAC_ARG(network
->bssid
),
5526 network
->channel
, priv
->channel
);
5530 /* Verify privacy compatability */
5531 if (((priv
->capability
& CAP_PRIVACY_ON
) ? 1 : 0) !=
5532 ((network
->capability
& WLAN_CAPABILITY_PRIVACY
) ? 1 : 0)) {
5533 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5534 "because of privacy mismatch: %s != %s.\n",
5535 escape_essid(network
->ssid
, network
->ssid_len
),
5536 MAC_ARG(network
->bssid
),
5537 priv
->capability
& CAP_PRIVACY_ON
? "on" :
5539 network
->capability
&
5540 WLAN_CAPABILITY_PRIVACY
? "on" : "off");
5544 if (!priv
->ieee
->wpa_enabled
&& (network
->wpa_ie_len
> 0 ||
5545 network
->rsn_ie_len
> 0)) {
5546 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5547 "because of WPA capability mismatch.\n",
5548 escape_essid(network
->ssid
, network
->ssid_len
),
5549 MAC_ARG(network
->bssid
));
5553 if ((priv
->config
& CFG_STATIC_BSSID
) &&
5554 memcmp(network
->bssid
, priv
->bssid
, ETH_ALEN
)) {
5555 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5556 "because of BSSID mismatch: " MAC_FMT
".\n",
5557 escape_essid(network
->ssid
, network
->ssid_len
),
5558 MAC_ARG(network
->bssid
), MAC_ARG(priv
->bssid
));
5562 /* Filter out any incompatible freq / mode combinations */
5563 if (!ieee80211_is_valid_mode(priv
->ieee
, network
->mode
)) {
5564 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5565 "because of invalid frequency/mode "
5567 escape_essid(network
->ssid
, network
->ssid_len
),
5568 MAC_ARG(network
->bssid
));
5572 /* Filter out invalid channel in current GEO */
5573 if (!ipw_is_valid_channel(priv
->ieee
, network
->channel
)) {
5574 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5575 "because of invalid channel in current GEO\n",
5576 escape_essid(network
->ssid
, network
->ssid_len
),
5577 MAC_ARG(network
->bssid
));
5581 /* Ensure that the rates supported by the driver are compatible with
5582 * this AP, including verification of basic rates (mandatory) */
5583 if (!ipw_compatible_rates(priv
, network
, &rates
)) {
5584 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5585 "because configured rate mask excludes "
5586 "AP mandatory rate.\n",
5587 escape_essid(network
->ssid
, network
->ssid_len
),
5588 MAC_ARG(network
->bssid
));
5592 if (rates
.num_rates
== 0) {
5593 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' excluded "
5594 "because of no compatible rates.\n",
5595 escape_essid(network
->ssid
, network
->ssid_len
),
5596 MAC_ARG(network
->bssid
));
5600 /* TODO: Perform any further minimal comparititive tests. We do not
5601 * want to put too much policy logic here; intelligent scan selection
5602 * should occur within a generic IEEE 802.11 user space tool. */
5604 /* Set up 'new' AP to this network */
5605 ipw_copy_rates(&match
->rates
, &rates
);
5606 match
->network
= network
;
5608 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT
")' is a viable match.\n",
5609 escape_essid(network
->ssid
, network
->ssid_len
),
5610 MAC_ARG(network
->bssid
));
5615 static void ipw_adhoc_create(struct ipw_priv
*priv
,
5616 struct ieee80211_network
*network
)
5618 const struct ieee80211_geo
*geo
= ipw_get_geo(priv
->ieee
);
5622 * For the purposes of scanning, we can set our wireless mode
5623 * to trigger scans across combinations of bands, but when it
5624 * comes to creating a new ad-hoc network, we have tell the FW
5625 * exactly which band to use.
5627 * We also have the possibility of an invalid channel for the
5628 * chossen band. Attempting to create a new ad-hoc network
5629 * with an invalid channel for wireless mode will trigger a
5633 switch (ipw_is_valid_channel(priv
->ieee
, priv
->channel
)) {
5634 case IEEE80211_52GHZ_BAND
:
5635 network
->mode
= IEEE_A
;
5636 i
= ipw_channel_to_index(priv
->ieee
, priv
->channel
);
5639 if (geo
->a
[i
].flags
& IEEE80211_CH_PASSIVE_ONLY
) {
5640 IPW_WARNING("Overriding invalid channel\n");
5641 priv
->channel
= geo
->a
[0].channel
;
5645 case IEEE80211_24GHZ_BAND
:
5646 if (priv
->ieee
->mode
& IEEE_G
)
5647 network
->mode
= IEEE_G
;
5649 network
->mode
= IEEE_B
;
5650 i
= ipw_channel_to_index(priv
->ieee
, priv
->channel
);
5653 if (geo
->bg
[i
].flags
& IEEE80211_CH_PASSIVE_ONLY
) {
5654 IPW_WARNING("Overriding invalid channel\n");
5655 priv
->channel
= geo
->bg
[0].channel
;
5660 IPW_WARNING("Overriding invalid channel\n");
5661 if (priv
->ieee
->mode
& IEEE_A
) {
5662 network
->mode
= IEEE_A
;
5663 priv
->channel
= geo
->a
[0].channel
;
5664 } else if (priv
->ieee
->mode
& IEEE_G
) {
5665 network
->mode
= IEEE_G
;
5666 priv
->channel
= geo
->bg
[0].channel
;
5668 network
->mode
= IEEE_B
;
5669 priv
->channel
= geo
->bg
[0].channel
;
5674 network
->channel
= priv
->channel
;
5675 priv
->config
|= CFG_ADHOC_PERSIST
;
5676 ipw_create_bssid(priv
, network
->bssid
);
5677 network
->ssid_len
= priv
->essid_len
;
5678 memcpy(network
->ssid
, priv
->essid
, priv
->essid_len
);
5679 memset(&network
->stats
, 0, sizeof(network
->stats
));
5680 network
->capability
= WLAN_CAPABILITY_IBSS
;
5681 if (!(priv
->config
& CFG_PREAMBLE_LONG
))
5682 network
->capability
|= WLAN_CAPABILITY_SHORT_PREAMBLE
;
5683 if (priv
->capability
& CAP_PRIVACY_ON
)
5684 network
->capability
|= WLAN_CAPABILITY_PRIVACY
;
5685 network
->rates_len
= min(priv
->rates
.num_rates
, MAX_RATES_LENGTH
);
5686 memcpy(network
->rates
, priv
->rates
.supported_rates
, network
->rates_len
);
5687 network
->rates_ex_len
= priv
->rates
.num_rates
- network
->rates_len
;
5688 memcpy(network
->rates_ex
,
5689 &priv
->rates
.supported_rates
[network
->rates_len
],
5690 network
->rates_ex_len
);
5691 network
->last_scanned
= 0;
5693 network
->last_associate
= 0;
5694 network
->time_stamp
[0] = 0;
5695 network
->time_stamp
[1] = 0;
5696 network
->beacon_interval
= 100; /* Default */
5697 network
->listen_interval
= 10; /* Default */
5698 network
->atim_window
= 0; /* Default */
5699 network
->wpa_ie_len
= 0;
5700 network
->rsn_ie_len
= 0;
5703 static void ipw_send_tgi_tx_key(struct ipw_priv
*priv
, int type
, int index
)
5705 struct ipw_tgi_tx_key key
;
5707 if (!(priv
->ieee
->sec
.flags
& (1 << index
)))
5711 memcpy(key
.key
, priv
->ieee
->sec
.keys
[index
], SCM_TEMPORAL_KEY_LENGTH
);
5712 key
.security_type
= type
;
5713 key
.station_index
= 0; /* always 0 for BSS */
5715 /* 0 for new key; previous value of counter (after fatal error) */
5716 key
.tx_counter
[0] = 0;
5717 key
.tx_counter
[1] = 0;
5719 ipw_send_cmd_pdu(priv
, IPW_CMD_TGI_TX_KEY
, sizeof(key
), &key
);
5722 static void ipw_send_wep_keys(struct ipw_priv
*priv
, int type
)
5724 struct ipw_wep_key key
;
5727 key
.cmd_id
= DINO_CMD_WEP_KEY
;
5730 /* Note: AES keys cannot be set for multiple times.
5731 * Only set it at the first time. */
5732 for (i
= 0; i
< 4; i
++) {
5733 key
.key_index
= i
| type
;
5734 if (!(priv
->ieee
->sec
.flags
& (1 << i
))) {
5739 key
.key_size
= priv
->ieee
->sec
.key_sizes
[i
];
5740 memcpy(key
.key
, priv
->ieee
->sec
.keys
[i
], key
.key_size
);
5742 ipw_send_cmd_pdu(priv
, IPW_CMD_WEP_KEY
, sizeof(key
), &key
);
5746 static void ipw_set_hw_decrypt_unicast(struct ipw_priv
*priv
, int level
)
5748 if (priv
->ieee
->host_encrypt
)
5753 priv
->sys_config
.disable_unicast_decryption
= 0;
5754 priv
->ieee
->host_decrypt
= 0;
5757 priv
->sys_config
.disable_unicast_decryption
= 1;
5758 priv
->ieee
->host_decrypt
= 1;
5761 priv
->sys_config
.disable_unicast_decryption
= 0;
5762 priv
->ieee
->host_decrypt
= 0;
5765 priv
->sys_config
.disable_unicast_decryption
= 1;
5772 static void ipw_set_hw_decrypt_multicast(struct ipw_priv
*priv
, int level
)
5774 if (priv
->ieee
->host_encrypt
)
5779 priv
->sys_config
.disable_multicast_decryption
= 0;
5782 priv
->sys_config
.disable_multicast_decryption
= 1;
5785 priv
->sys_config
.disable_multicast_decryption
= 0;
5788 priv
->sys_config
.disable_multicast_decryption
= 1;
5795 static void ipw_set_hwcrypto_keys(struct ipw_priv
*priv
)
5797 switch (priv
->ieee
->sec
.level
) {
5799 if (priv
->ieee
->sec
.flags
& SEC_ACTIVE_KEY
)
5800 ipw_send_tgi_tx_key(priv
,
5801 DCT_FLAG_EXT_SECURITY_CCM
,
5802 priv
->ieee
->sec
.active_key
);
5804 if (!priv
->ieee
->host_mc_decrypt
)
5805 ipw_send_wep_keys(priv
, DCW_WEP_KEY_SEC_TYPE_CCM
);
5808 if (priv
->ieee
->sec
.flags
& SEC_ACTIVE_KEY
)
5809 ipw_send_tgi_tx_key(priv
,
5810 DCT_FLAG_EXT_SECURITY_TKIP
,
5811 priv
->ieee
->sec
.active_key
);
5814 ipw_send_wep_keys(priv
, DCW_WEP_KEY_SEC_TYPE_WEP
);
5815 ipw_set_hw_decrypt_unicast(priv
, priv
->ieee
->sec
.level
);
5816 ipw_set_hw_decrypt_multicast(priv
, priv
->ieee
->sec
.level
);
5824 static void ipw_adhoc_check(void *data
)
5826 struct ipw_priv
*priv
= data
;
5828 if (priv
->missed_adhoc_beacons
++ > priv
->disassociate_threshold
&&
5829 !(priv
->config
& CFG_ADHOC_PERSIST
)) {
5830 IPW_DEBUG(IPW_DL_INFO
| IPW_DL_NOTIF
|
5831 IPW_DL_STATE
| IPW_DL_ASSOC
,
5832 "Missed beacon: %d - disassociate\n",
5833 priv
->missed_adhoc_beacons
);
5834 ipw_remove_current_network(priv
);
5835 ipw_disassociate(priv
);
5839 queue_delayed_work(priv
->workqueue
, &priv
->adhoc_check
,
5840 priv
->assoc_request
.beacon_interval
);
5843 static void ipw_bg_adhoc_check(void *data
)
5845 struct ipw_priv
*priv
= data
;
5847 ipw_adhoc_check(data
);
5851 #ifdef CONFIG_IPW2200_DEBUG
5852 static void ipw_debug_config(struct ipw_priv
*priv
)
5854 IPW_DEBUG_INFO("Scan completed, no valid APs matched "
5855 "[CFG 0x%08X]\n", priv
->config
);
5856 if (priv
->config
& CFG_STATIC_CHANNEL
)
5857 IPW_DEBUG_INFO("Channel locked to %d\n", priv
->channel
);
5859 IPW_DEBUG_INFO("Channel unlocked.\n");
5860 if (priv
->config
& CFG_STATIC_ESSID
)
5861 IPW_DEBUG_INFO("ESSID locked to '%s'\n",
5862 escape_essid(priv
->essid
, priv
->essid_len
));
5864 IPW_DEBUG_INFO("ESSID unlocked.\n");
5865 if (priv
->config
& CFG_STATIC_BSSID
)
5866 IPW_DEBUG_INFO("BSSID locked to " MAC_FMT
"\n",
5867 MAC_ARG(priv
->bssid
));
5869 IPW_DEBUG_INFO("BSSID unlocked.\n");
5870 if (priv
->capability
& CAP_PRIVACY_ON
)
5871 IPW_DEBUG_INFO("PRIVACY on\n");
5873 IPW_DEBUG_INFO("PRIVACY off\n");
5874 IPW_DEBUG_INFO("RATE MASK: 0x%08X\n", priv
->rates_mask
);
5877 #define ipw_debug_config(x) do {} while (0)
5880 static void ipw_set_fixed_rate(struct ipw_priv
*priv
, int mode
)
5882 /* TODO: Verify that this works... */
5883 struct ipw_fixed_rate fr
= {
5884 .tx_rates
= priv
->rates_mask
5889 /* Identify 'current FW band' and match it with the fixed
5892 switch (priv
->ieee
->freq_band
) {
5893 case IEEE80211_52GHZ_BAND
: /* A only */
5895 if (priv
->rates_mask
& ~IEEE80211_OFDM_RATES_MASK
) {
5896 /* Invalid fixed rate mask */
5898 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
5903 fr
.tx_rates
>>= IEEE80211_OFDM_SHIFT_MASK_A
;
5906 default: /* 2.4Ghz or Mixed */
5908 if (mode
== IEEE_B
) {
5909 if (fr
.tx_rates
& ~IEEE80211_CCK_RATES_MASK
) {
5910 /* Invalid fixed rate mask */
5912 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
5919 if (fr
.tx_rates
& ~(IEEE80211_CCK_RATES_MASK
|
5920 IEEE80211_OFDM_RATES_MASK
)) {
5921 /* Invalid fixed rate mask */
5923 ("invalid fixed rate mask in ipw_set_fixed_rate\n");
5928 if (IEEE80211_OFDM_RATE_6MB_MASK
& fr
.tx_rates
) {
5929 mask
|= (IEEE80211_OFDM_RATE_6MB_MASK
>> 1);
5930 fr
.tx_rates
&= ~IEEE80211_OFDM_RATE_6MB_MASK
;
5933 if (IEEE80211_OFDM_RATE_9MB_MASK
& fr
.tx_rates
) {
5934 mask
|= (IEEE80211_OFDM_RATE_9MB_MASK
>> 1);
5935 fr
.tx_rates
&= ~IEEE80211_OFDM_RATE_9MB_MASK
;
5938 if (IEEE80211_OFDM_RATE_12MB_MASK
& fr
.tx_rates
) {
5939 mask
|= (IEEE80211_OFDM_RATE_12MB_MASK
>> 1);
5940 fr
.tx_rates
&= ~IEEE80211_OFDM_RATE_12MB_MASK
;
5943 fr
.tx_rates
|= mask
;
5947 reg
= ipw_read32(priv
, IPW_MEM_FIXED_OVERRIDE
);
5948 ipw_write_reg32(priv
, reg
, *(u32
*) & fr
);
5951 static void ipw_abort_scan(struct ipw_priv
*priv
)
5955 if (priv
->status
& STATUS_SCAN_ABORTING
) {
5956 IPW_DEBUG_HC("Ignoring concurrent scan abort request.\n");
5959 priv
->status
|= STATUS_SCAN_ABORTING
;
5961 err
= ipw_send_scan_abort(priv
);
5963 IPW_DEBUG_HC("Request to abort scan failed.\n");
5966 static void ipw_add_scan_channels(struct ipw_priv
*priv
,
5967 struct ipw_scan_request_ext
*scan
,
5970 int channel_index
= 0;
5971 const struct ieee80211_geo
*geo
;
5974 geo
= ipw_get_geo(priv
->ieee
);
5976 if (priv
->ieee
->freq_band
& IEEE80211_52GHZ_BAND
) {
5977 int start
= channel_index
;
5978 for (i
= 0; i
< geo
->a_channels
; i
++) {
5979 if ((priv
->status
& STATUS_ASSOCIATED
) &&
5980 geo
->a
[i
].channel
== priv
->channel
)
5983 scan
->channels_list
[channel_index
] = geo
->a
[i
].channel
;
5984 ipw_set_scan_type(scan
, channel_index
,
5986 flags
& IEEE80211_CH_PASSIVE_ONLY
?
5987 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
:
5991 if (start
!= channel_index
) {
5992 scan
->channels_list
[start
] = (u8
) (IPW_A_MODE
<< 6) |
5993 (channel_index
- start
);
5998 if (priv
->ieee
->freq_band
& IEEE80211_24GHZ_BAND
) {
5999 int start
= channel_index
;
6000 if (priv
->config
& CFG_SPEED_SCAN
) {
6002 u8 channels
[IEEE80211_24GHZ_CHANNELS
] = {
6003 /* nop out the list */
6008 while (channel_index
< IPW_SCAN_CHANNELS
) {
6010 priv
->speed_scan
[priv
->speed_scan_pos
];
6012 priv
->speed_scan_pos
= 0;
6013 channel
= priv
->speed_scan
[0];
6015 if ((priv
->status
& STATUS_ASSOCIATED
) &&
6016 channel
== priv
->channel
) {
6017 priv
->speed_scan_pos
++;
6021 /* If this channel has already been
6022 * added in scan, break from loop
6023 * and this will be the first channel
6026 if (channels
[channel
- 1] != 0)
6029 channels
[channel
- 1] = 1;
6030 priv
->speed_scan_pos
++;
6032 scan
->channels_list
[channel_index
] = channel
;
6034 ipw_channel_to_index(priv
->ieee
, channel
);
6035 ipw_set_scan_type(scan
, channel_index
,
6038 IEEE80211_CH_PASSIVE_ONLY
?
6039 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
6043 for (i
= 0; i
< geo
->bg_channels
; i
++) {
6044 if ((priv
->status
& STATUS_ASSOCIATED
) &&
6045 geo
->bg
[i
].channel
== priv
->channel
)
6048 scan
->channels_list
[channel_index
] =
6050 ipw_set_scan_type(scan
, channel_index
,
6053 IEEE80211_CH_PASSIVE_ONLY
?
6054 IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
6059 if (start
!= channel_index
) {
6060 scan
->channels_list
[start
] = (u8
) (IPW_B_MODE
<< 6) |
6061 (channel_index
- start
);
6066 static int ipw_request_scan(struct ipw_priv
*priv
)
6068 struct ipw_scan_request_ext scan
;
6069 int err
= 0, scan_type
;
6071 if (!(priv
->status
& STATUS_INIT
) ||
6072 (priv
->status
& STATUS_EXIT_PENDING
))
6077 if (priv
->status
& STATUS_SCANNING
) {
6078 IPW_DEBUG_HC("Concurrent scan requested. Ignoring.\n");
6079 priv
->status
|= STATUS_SCAN_PENDING
;
6083 if (!(priv
->status
& STATUS_SCAN_FORCED
) &&
6084 priv
->status
& STATUS_SCAN_ABORTING
) {
6085 IPW_DEBUG_HC("Scan request while abort pending. Queuing.\n");
6086 priv
->status
|= STATUS_SCAN_PENDING
;
6090 if (priv
->status
& STATUS_RF_KILL_MASK
) {
6091 IPW_DEBUG_HC("Aborting scan due to RF Kill activation\n");
6092 priv
->status
|= STATUS_SCAN_PENDING
;
6096 memset(&scan
, 0, sizeof(scan
));
6098 if (priv
->config
& CFG_SPEED_SCAN
)
6099 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_SCAN
] =
6102 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_SCAN
] =
6105 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN
] =
6107 scan
.dwell_time
[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
] = cpu_to_le16(120);
6109 scan
.full_scan_index
= cpu_to_le32(ieee80211_get_scans(priv
->ieee
));
6111 #ifdef CONFIG_IPW2200_MONITOR
6112 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
) {
6116 switch (ipw_is_valid_channel(priv
->ieee
, priv
->channel
)) {
6117 case IEEE80211_52GHZ_BAND
:
6118 band
= (u8
) (IPW_A_MODE
<< 6) | 1;
6119 channel
= priv
->channel
;
6122 case IEEE80211_24GHZ_BAND
:
6123 band
= (u8
) (IPW_B_MODE
<< 6) | 1;
6124 channel
= priv
->channel
;
6128 band
= (u8
) (IPW_B_MODE
<< 6) | 1;
6133 scan
.channels_list
[0] = band
;
6134 scan
.channels_list
[1] = channel
;
6135 ipw_set_scan_type(&scan
, 1, IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
);
6137 /* NOTE: The card will sit on this channel for this time
6138 * period. Scan aborts are timing sensitive and frequently
6139 * result in firmware restarts. As such, it is best to
6140 * set a small dwell_time here and just keep re-issuing
6141 * scans. Otherwise fast channel hopping will not actually
6144 * TODO: Move SPEED SCAN support to all modes and bands */
6145 scan
.dwell_time
[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
] =
6148 #endif /* CONFIG_IPW2200_MONITOR */
6149 /* If we are roaming, then make this a directed scan for the
6150 * current network. Otherwise, ensure that every other scan
6151 * is a fast channel hop scan */
6152 if ((priv
->status
& STATUS_ROAMING
)
6153 || (!(priv
->status
& STATUS_ASSOCIATED
)
6154 && (priv
->config
& CFG_STATIC_ESSID
)
6155 && (le32_to_cpu(scan
.full_scan_index
) % 2))) {
6156 err
= ipw_send_ssid(priv
, priv
->essid
, priv
->essid_len
);
6158 IPW_DEBUG_HC("Attempt to send SSID command "
6163 scan_type
= IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN
;
6165 scan_type
= IPW_SCAN_ACTIVE_BROADCAST_SCAN
;
6167 ipw_add_scan_channels(priv
, &scan
, scan_type
);
6168 #ifdef CONFIG_IPW2200_MONITOR
6172 err
= ipw_send_scan_request_ext(priv
, &scan
);
6174 IPW_DEBUG_HC("Sending scan command failed: %08X\n", err
);
6178 priv
->status
|= STATUS_SCANNING
;
6179 priv
->status
&= ~STATUS_SCAN_PENDING
;
6180 queue_delayed_work(priv
->workqueue
, &priv
->scan_check
,
6181 IPW_SCAN_CHECK_WATCHDOG
);
6187 static void ipw_bg_abort_scan(void *data
)
6189 struct ipw_priv
*priv
= data
;
6191 ipw_abort_scan(data
);
6195 static int ipw_wpa_enable(struct ipw_priv
*priv
, int value
)
6197 /* This is called when wpa_supplicant loads and closes the driver
6199 priv
->ieee
->wpa_enabled
= value
;
6203 static int ipw_wpa_set_auth_algs(struct ipw_priv
*priv
, int value
)
6205 struct ieee80211_device
*ieee
= priv
->ieee
;
6206 struct ieee80211_security sec
= {
6207 .flags
= SEC_AUTH_MODE
,
6211 if (value
& IW_AUTH_ALG_SHARED_KEY
) {
6212 sec
.auth_mode
= WLAN_AUTH_SHARED_KEY
;
6214 } else if (value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
6215 sec
.auth_mode
= WLAN_AUTH_OPEN
;
6217 } else if (value
& IW_AUTH_ALG_LEAP
) {
6218 sec
.auth_mode
= WLAN_AUTH_LEAP
;
6223 if (ieee
->set_security
)
6224 ieee
->set_security(ieee
->dev
, &sec
);
6231 static void ipw_wpa_assoc_frame(struct ipw_priv
*priv
, char *wpa_ie
,
6234 /* make sure WPA is enabled */
6235 ipw_wpa_enable(priv
, 1);
6237 ipw_disassociate(priv
);
6240 static int ipw_set_rsn_capa(struct ipw_priv
*priv
,
6241 char *capabilities
, int length
)
6243 IPW_DEBUG_HC("HOST_CMD_RSN_CAPABILITIES\n");
6245 return ipw_send_cmd_pdu(priv
, IPW_CMD_RSN_CAPABILITIES
, length
,
6254 static int ipw_wx_set_genie(struct net_device
*dev
,
6255 struct iw_request_info
*info
,
6256 union iwreq_data
*wrqu
, char *extra
)
6258 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6259 struct ieee80211_device
*ieee
= priv
->ieee
;
6263 if (wrqu
->data
.length
> MAX_WPA_IE_LEN
||
6264 (wrqu
->data
.length
&& extra
== NULL
))
6269 //if (!ieee->wpa_enabled) {
6270 // err = -EOPNOTSUPP;
6274 if (wrqu
->data
.length
) {
6275 buf
= kmalloc(wrqu
->data
.length
, GFP_KERNEL
);
6281 memcpy(buf
, extra
, wrqu
->data
.length
);
6282 kfree(ieee
->wpa_ie
);
6284 ieee
->wpa_ie_len
= wrqu
->data
.length
;
6286 kfree(ieee
->wpa_ie
);
6287 ieee
->wpa_ie
= NULL
;
6288 ieee
->wpa_ie_len
= 0;
6291 ipw_wpa_assoc_frame(priv
, ieee
->wpa_ie
, ieee
->wpa_ie_len
);
6298 static int ipw_wx_get_genie(struct net_device
*dev
,
6299 struct iw_request_info
*info
,
6300 union iwreq_data
*wrqu
, char *extra
)
6302 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6303 struct ieee80211_device
*ieee
= priv
->ieee
;
6308 //if (!ieee->wpa_enabled) {
6309 // err = -EOPNOTSUPP;
6313 if (ieee
->wpa_ie_len
== 0 || ieee
->wpa_ie
== NULL
) {
6314 wrqu
->data
.length
= 0;
6318 if (wrqu
->data
.length
< ieee
->wpa_ie_len
) {
6323 wrqu
->data
.length
= ieee
->wpa_ie_len
;
6324 memcpy(extra
, ieee
->wpa_ie
, ieee
->wpa_ie_len
);
6331 static int wext_cipher2level(int cipher
)
6334 case IW_AUTH_CIPHER_NONE
:
6336 case IW_AUTH_CIPHER_WEP40
:
6337 case IW_AUTH_CIPHER_WEP104
:
6339 case IW_AUTH_CIPHER_TKIP
:
6341 case IW_AUTH_CIPHER_CCMP
:
6349 static int ipw_wx_set_auth(struct net_device
*dev
,
6350 struct iw_request_info
*info
,
6351 union iwreq_data
*wrqu
, char *extra
)
6353 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6354 struct ieee80211_device
*ieee
= priv
->ieee
;
6355 struct iw_param
*param
= &wrqu
->param
;
6356 struct ieee80211_crypt_data
*crypt
;
6357 unsigned long flags
;
6360 switch (param
->flags
& IW_AUTH_INDEX
) {
6361 case IW_AUTH_WPA_VERSION
:
6363 case IW_AUTH_CIPHER_PAIRWISE
:
6364 ipw_set_hw_decrypt_unicast(priv
,
6365 wext_cipher2level(param
->value
));
6367 case IW_AUTH_CIPHER_GROUP
:
6368 ipw_set_hw_decrypt_multicast(priv
,
6369 wext_cipher2level(param
->value
));
6371 case IW_AUTH_KEY_MGMT
:
6373 * ipw2200 does not use these parameters
6377 case IW_AUTH_TKIP_COUNTERMEASURES
:
6378 crypt
= priv
->ieee
->crypt
[priv
->ieee
->tx_keyidx
];
6379 if (!crypt
|| !crypt
->ops
->set_flags
|| !crypt
->ops
->get_flags
)
6382 flags
= crypt
->ops
->get_flags(crypt
->priv
);
6385 flags
|= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES
;
6387 flags
&= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES
;
6389 crypt
->ops
->set_flags(flags
, crypt
->priv
);
6393 case IW_AUTH_DROP_UNENCRYPTED
:{
6396 * wpa_supplicant calls set_wpa_enabled when the driver
6397 * is loaded and unloaded, regardless of if WPA is being
6398 * used. No other calls are made which can be used to
6399 * determine if encryption will be used or not prior to
6400 * association being expected. If encryption is not being
6401 * used, drop_unencrypted is set to false, else true -- we
6402 * can use this to determine if the CAP_PRIVACY_ON bit should
6405 struct ieee80211_security sec
= {
6406 .flags
= SEC_ENABLED
,
6407 .enabled
= param
->value
,
6409 priv
->ieee
->drop_unencrypted
= param
->value
;
6410 /* We only change SEC_LEVEL for open mode. Others
6411 * are set by ipw_wpa_set_encryption.
6413 if (!param
->value
) {
6414 sec
.flags
|= SEC_LEVEL
;
6415 sec
.level
= SEC_LEVEL_0
;
6417 sec
.flags
|= SEC_LEVEL
;
6418 sec
.level
= SEC_LEVEL_1
;
6420 if (priv
->ieee
->set_security
)
6421 priv
->ieee
->set_security(priv
->ieee
->dev
, &sec
);
6425 case IW_AUTH_80211_AUTH_ALG
:
6426 ret
= ipw_wpa_set_auth_algs(priv
, param
->value
);
6429 case IW_AUTH_WPA_ENABLED
:
6430 ret
= ipw_wpa_enable(priv
, param
->value
);
6433 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
6434 ieee
->ieee802_1x
= param
->value
;
6437 //case IW_AUTH_ROAMING_CONTROL:
6438 case IW_AUTH_PRIVACY_INVOKED
:
6439 ieee
->privacy_invoked
= param
->value
;
6449 static int ipw_wx_get_auth(struct net_device
*dev
,
6450 struct iw_request_info
*info
,
6451 union iwreq_data
*wrqu
, char *extra
)
6453 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6454 struct ieee80211_device
*ieee
= priv
->ieee
;
6455 struct ieee80211_crypt_data
*crypt
;
6456 struct iw_param
*param
= &wrqu
->param
;
6459 switch (param
->flags
& IW_AUTH_INDEX
) {
6460 case IW_AUTH_WPA_VERSION
:
6461 case IW_AUTH_CIPHER_PAIRWISE
:
6462 case IW_AUTH_CIPHER_GROUP
:
6463 case IW_AUTH_KEY_MGMT
:
6465 * wpa_supplicant will control these internally
6470 case IW_AUTH_TKIP_COUNTERMEASURES
:
6471 crypt
= priv
->ieee
->crypt
[priv
->ieee
->tx_keyidx
];
6472 if (!crypt
|| !crypt
->ops
->get_flags
)
6475 param
->value
= (crypt
->ops
->get_flags(crypt
->priv
) &
6476 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES
) ? 1 : 0;
6480 case IW_AUTH_DROP_UNENCRYPTED
:
6481 param
->value
= ieee
->drop_unencrypted
;
6484 case IW_AUTH_80211_AUTH_ALG
:
6485 param
->value
= ieee
->sec
.auth_mode
;
6488 case IW_AUTH_WPA_ENABLED
:
6489 param
->value
= ieee
->wpa_enabled
;
6492 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
6493 param
->value
= ieee
->ieee802_1x
;
6496 case IW_AUTH_ROAMING_CONTROL
:
6497 case IW_AUTH_PRIVACY_INVOKED
:
6498 param
->value
= ieee
->privacy_invoked
;
6507 /* SIOCSIWENCODEEXT */
6508 static int ipw_wx_set_encodeext(struct net_device
*dev
,
6509 struct iw_request_info
*info
,
6510 union iwreq_data
*wrqu
, char *extra
)
6512 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6513 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
6516 if (ext
->alg
== IW_ENCODE_ALG_TKIP
) {
6517 /* IPW HW can't build TKIP MIC,
6518 host decryption still needed */
6519 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
6520 priv
->ieee
->host_mc_decrypt
= 1;
6522 priv
->ieee
->host_encrypt
= 0;
6523 priv
->ieee
->host_encrypt_msdu
= 1;
6524 priv
->ieee
->host_decrypt
= 1;
6527 priv
->ieee
->host_encrypt
= 0;
6528 priv
->ieee
->host_encrypt_msdu
= 0;
6529 priv
->ieee
->host_decrypt
= 0;
6530 priv
->ieee
->host_mc_decrypt
= 0;
6534 return ieee80211_wx_set_encodeext(priv
->ieee
, info
, wrqu
, extra
);
6537 /* SIOCGIWENCODEEXT */
6538 static int ipw_wx_get_encodeext(struct net_device
*dev
,
6539 struct iw_request_info
*info
,
6540 union iwreq_data
*wrqu
, char *extra
)
6542 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6543 return ieee80211_wx_get_encodeext(priv
->ieee
, info
, wrqu
, extra
);
6547 static int ipw_wx_set_mlme(struct net_device
*dev
,
6548 struct iw_request_info
*info
,
6549 union iwreq_data
*wrqu
, char *extra
)
6551 struct ipw_priv
*priv
= ieee80211_priv(dev
);
6552 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
6555 reason
= cpu_to_le16(mlme
->reason_code
);
6557 switch (mlme
->cmd
) {
6558 case IW_MLME_DEAUTH
:
6562 case IW_MLME_DISASSOC
:
6563 ipw_disassociate(priv
);
6572 #ifdef CONFIG_IPW_QOS
6576 * get the modulation type of the current network or
6577 * the card current mode
6579 u8
ipw_qos_current_mode(struct ipw_priv
* priv
)
6583 if (priv
->status
& STATUS_ASSOCIATED
) {
6584 unsigned long flags
;
6586 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
6587 mode
= priv
->assoc_network
->mode
;
6588 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
6590 mode
= priv
->ieee
->mode
;
6592 IPW_DEBUG_QOS("QoS network/card mode %d \n", mode
);
6597 * Handle management frame beacon and probe response
6599 static int ipw_qos_handle_probe_response(struct ipw_priv
*priv
,
6601 struct ieee80211_network
*network
)
6603 u32 size
= sizeof(struct ieee80211_qos_parameters
);
6605 if (network
->capability
& WLAN_CAPABILITY_IBSS
)
6606 network
->qos_data
.active
= network
->qos_data
.supported
;
6608 if (network
->flags
& NETWORK_HAS_QOS_MASK
) {
6609 if (active_network
&&
6610 (network
->flags
& NETWORK_HAS_QOS_PARAMETERS
))
6611 network
->qos_data
.active
= network
->qos_data
.supported
;
6613 if ((network
->qos_data
.active
== 1) && (active_network
== 1) &&
6614 (network
->flags
& NETWORK_HAS_QOS_PARAMETERS
) &&
6615 (network
->qos_data
.old_param_count
!=
6616 network
->qos_data
.param_count
)) {
6617 network
->qos_data
.old_param_count
=
6618 network
->qos_data
.param_count
;
6619 schedule_work(&priv
->qos_activate
);
6620 IPW_DEBUG_QOS("QoS parameters change call "
6624 if ((priv
->ieee
->mode
== IEEE_B
) || (network
->mode
== IEEE_B
))
6625 memcpy(&network
->qos_data
.parameters
,
6626 &def_parameters_CCK
, size
);
6628 memcpy(&network
->qos_data
.parameters
,
6629 &def_parameters_OFDM
, size
);
6631 if ((network
->qos_data
.active
== 1) && (active_network
== 1)) {
6632 IPW_DEBUG_QOS("QoS was disabled call qos_activate \n");
6633 schedule_work(&priv
->qos_activate
);
6636 network
->qos_data
.active
= 0;
6637 network
->qos_data
.supported
= 0;
6639 if ((priv
->status
& STATUS_ASSOCIATED
) &&
6640 (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) && (active_network
== 0)) {
6641 if (memcmp(network
->bssid
, priv
->bssid
, ETH_ALEN
))
6642 if ((network
->capability
& WLAN_CAPABILITY_IBSS
) &&
6643 !(network
->flags
& NETWORK_EMPTY_ESSID
))
6644 if ((network
->ssid_len
==
6645 priv
->assoc_network
->ssid_len
) &&
6646 !memcmp(network
->ssid
,
6647 priv
->assoc_network
->ssid
,
6648 network
->ssid_len
)) {
6649 queue_work(priv
->workqueue
,
6650 &priv
->merge_networks
);
6658 * This function set up the firmware to support QoS. It sends
6659 * IPW_CMD_QOS_PARAMETERS and IPW_CMD_WME_INFO
6661 static int ipw_qos_activate(struct ipw_priv
*priv
,
6662 struct ieee80211_qos_data
*qos_network_data
)
6665 struct ieee80211_qos_parameters qos_parameters
[QOS_QOS_SETS
];
6666 struct ieee80211_qos_parameters
*active_one
= NULL
;
6667 u32 size
= sizeof(struct ieee80211_qos_parameters
);
6672 type
= ipw_qos_current_mode(priv
);
6674 active_one
= &(qos_parameters
[QOS_PARAM_SET_DEF_CCK
]);
6675 memcpy(active_one
, priv
->qos_data
.def_qos_parm_CCK
, size
);
6676 active_one
= &(qos_parameters
[QOS_PARAM_SET_DEF_OFDM
]);
6677 memcpy(active_one
, priv
->qos_data
.def_qos_parm_OFDM
, size
);
6679 if (qos_network_data
== NULL
) {
6680 if (type
== IEEE_B
) {
6681 IPW_DEBUG_QOS("QoS activate network mode %d\n", type
);
6682 active_one
= &def_parameters_CCK
;
6684 active_one
= &def_parameters_OFDM
;
6686 memcpy(&qos_parameters
[QOS_PARAM_SET_ACTIVE
], active_one
, size
);
6687 burst_duration
= ipw_qos_get_burst_duration(priv
);
6688 for (i
= 0; i
< QOS_QUEUE_NUM
; i
++)
6689 qos_parameters
[QOS_PARAM_SET_ACTIVE
].tx_op_limit
[i
] =
6690 (u16
) burst_duration
;
6691 } else if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) {
6692 if (type
== IEEE_B
) {
6693 IPW_DEBUG_QOS("QoS activate IBSS nework mode %d\n",
6695 if (priv
->qos_data
.qos_enable
== 0)
6696 active_one
= &def_parameters_CCK
;
6698 active_one
= priv
->qos_data
.def_qos_parm_CCK
;
6700 if (priv
->qos_data
.qos_enable
== 0)
6701 active_one
= &def_parameters_OFDM
;
6703 active_one
= priv
->qos_data
.def_qos_parm_OFDM
;
6705 memcpy(&qos_parameters
[QOS_PARAM_SET_ACTIVE
], active_one
, size
);
6707 unsigned long flags
;
6710 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
6711 active_one
= &(qos_network_data
->parameters
);
6712 qos_network_data
->old_param_count
=
6713 qos_network_data
->param_count
;
6714 memcpy(&qos_parameters
[QOS_PARAM_SET_ACTIVE
], active_one
, size
);
6715 active
= qos_network_data
->supported
;
6716 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
6719 burst_duration
= ipw_qos_get_burst_duration(priv
);
6720 for (i
= 0; i
< QOS_QUEUE_NUM
; i
++)
6721 qos_parameters
[QOS_PARAM_SET_ACTIVE
].
6722 tx_op_limit
[i
] = (u16
) burst_duration
;
6726 IPW_DEBUG_QOS("QoS sending IPW_CMD_QOS_PARAMETERS\n");
6727 err
= ipw_send_qos_params_command(priv
,
6728 (struct ieee80211_qos_parameters
*)
6729 &(qos_parameters
[0]));
6731 IPW_DEBUG_QOS("QoS IPW_CMD_QOS_PARAMETERS failed\n");
6737 * send IPW_CMD_WME_INFO to the firmware
6739 static int ipw_qos_set_info_element(struct ipw_priv
*priv
)
6742 struct ieee80211_qos_information_element qos_info
;
6747 qos_info
.elementID
= QOS_ELEMENT_ID
;
6748 qos_info
.length
= sizeof(struct ieee80211_qos_information_element
) - 2;
6750 qos_info
.version
= QOS_VERSION_1
;
6751 qos_info
.ac_info
= 0;
6753 memcpy(qos_info
.qui
, qos_oui
, QOS_OUI_LEN
);
6754 qos_info
.qui_type
= QOS_OUI_TYPE
;
6755 qos_info
.qui_subtype
= QOS_OUI_INFO_SUB_TYPE
;
6757 ret
= ipw_send_qos_info_command(priv
, &qos_info
);
6759 IPW_DEBUG_QOS("QoS error calling ipw_send_qos_info_command\n");
6765 * Set the QoS parameter with the association request structure
6767 static int ipw_qos_association(struct ipw_priv
*priv
,
6768 struct ieee80211_network
*network
)
6771 struct ieee80211_qos_data
*qos_data
= NULL
;
6772 struct ieee80211_qos_data ibss_data
= {
6777 switch (priv
->ieee
->iw_mode
) {
6779 if (!(network
->capability
& WLAN_CAPABILITY_IBSS
))
6782 qos_data
= &ibss_data
;
6786 qos_data
= &network
->qos_data
;
6794 err
= ipw_qos_activate(priv
, qos_data
);
6796 priv
->assoc_request
.policy_support
&= ~HC_QOS_SUPPORT_ASSOC
;
6800 if (priv
->qos_data
.qos_enable
&& qos_data
->supported
) {
6801 IPW_DEBUG_QOS("QoS will be enabled for this association\n");
6802 priv
->assoc_request
.policy_support
|= HC_QOS_SUPPORT_ASSOC
;
6803 return ipw_qos_set_info_element(priv
);
6810 * handling the beaconing responces. if we get different QoS setting
6811 * of the network from the the associated setting adjust the QoS
6814 static int ipw_qos_association_resp(struct ipw_priv
*priv
,
6815 struct ieee80211_network
*network
)
6818 unsigned long flags
;
6819 u32 size
= sizeof(struct ieee80211_qos_parameters
);
6820 int set_qos_param
= 0;
6822 if ((priv
== NULL
) || (network
== NULL
) ||
6823 (priv
->assoc_network
== NULL
))
6826 if (!(priv
->status
& STATUS_ASSOCIATED
))
6829 if ((priv
->ieee
->iw_mode
!= IW_MODE_INFRA
))
6832 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
6833 if (network
->flags
& NETWORK_HAS_QOS_PARAMETERS
) {
6834 memcpy(&priv
->assoc_network
->qos_data
, &network
->qos_data
,
6835 sizeof(struct ieee80211_qos_data
));
6836 priv
->assoc_network
->qos_data
.active
= 1;
6837 if ((network
->qos_data
.old_param_count
!=
6838 network
->qos_data
.param_count
)) {
6840 network
->qos_data
.old_param_count
=
6841 network
->qos_data
.param_count
;
6845 if ((network
->mode
== IEEE_B
) || (priv
->ieee
->mode
== IEEE_B
))
6846 memcpy(&priv
->assoc_network
->qos_data
.parameters
,
6847 &def_parameters_CCK
, size
);
6849 memcpy(&priv
->assoc_network
->qos_data
.parameters
,
6850 &def_parameters_OFDM
, size
);
6851 priv
->assoc_network
->qos_data
.active
= 0;
6852 priv
->assoc_network
->qos_data
.supported
= 0;
6856 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
6858 if (set_qos_param
== 1)
6859 schedule_work(&priv
->qos_activate
);
6864 static u32
ipw_qos_get_burst_duration(struct ipw_priv
*priv
)
6871 if (!(priv
->ieee
->modulation
& IEEE80211_OFDM_MODULATION
))
6872 ret
= priv
->qos_data
.burst_duration_CCK
;
6874 ret
= priv
->qos_data
.burst_duration_OFDM
;
6880 * Initialize the setting of QoS global
6882 static void ipw_qos_init(struct ipw_priv
*priv
, int enable
,
6883 int burst_enable
, u32 burst_duration_CCK
,
6884 u32 burst_duration_OFDM
)
6886 priv
->qos_data
.qos_enable
= enable
;
6888 if (priv
->qos_data
.qos_enable
) {
6889 priv
->qos_data
.def_qos_parm_CCK
= &def_qos_parameters_CCK
;
6890 priv
->qos_data
.def_qos_parm_OFDM
= &def_qos_parameters_OFDM
;
6891 IPW_DEBUG_QOS("QoS is enabled\n");
6893 priv
->qos_data
.def_qos_parm_CCK
= &def_parameters_CCK
;
6894 priv
->qos_data
.def_qos_parm_OFDM
= &def_parameters_OFDM
;
6895 IPW_DEBUG_QOS("QoS is not enabled\n");
6898 priv
->qos_data
.burst_enable
= burst_enable
;
6901 priv
->qos_data
.burst_duration_CCK
= burst_duration_CCK
;
6902 priv
->qos_data
.burst_duration_OFDM
= burst_duration_OFDM
;
6904 priv
->qos_data
.burst_duration_CCK
= 0;
6905 priv
->qos_data
.burst_duration_OFDM
= 0;
6910 * map the packet priority to the right TX Queue
6912 static int ipw_get_tx_queue_number(struct ipw_priv
*priv
, u16 priority
)
6914 if (priority
> 7 || !priv
->qos_data
.qos_enable
)
6917 return from_priority_to_tx_queue
[priority
] - 1;
6921 * add QoS parameter to the TX command
6923 static int ipw_qos_set_tx_queue_command(struct ipw_priv
*priv
,
6925 struct tfd_data
*tfd
, u8 unicast
)
6928 int tx_queue_id
= 0;
6929 struct ieee80211_qos_data
*qos_data
= NULL
;
6930 int active
, supported
;
6931 unsigned long flags
;
6933 if (!(priv
->status
& STATUS_ASSOCIATED
))
6936 qos_data
= &priv
->assoc_network
->qos_data
;
6938 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
6940 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) {
6942 qos_data
->active
= 0;
6944 qos_data
->active
= qos_data
->supported
;
6947 active
= qos_data
->active
;
6948 supported
= qos_data
->supported
;
6950 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
6952 IPW_DEBUG_QOS("QoS %d network is QoS active %d supported %d "
6954 priv
->qos_data
.qos_enable
, active
, supported
, unicast
);
6955 if (active
&& priv
->qos_data
.qos_enable
) {
6956 ret
= from_priority_to_tx_queue
[priority
];
6957 tx_queue_id
= ret
- 1;
6958 IPW_DEBUG_QOS("QoS packet priority is %d \n", priority
);
6959 if (priority
<= 7) {
6960 tfd
->tx_flags_ext
|= DCT_FLAG_EXT_QOS_ENABLED
;
6961 tfd
->tfd
.tfd_26
.mchdr
.qos_ctrl
= priority
;
6962 tfd
->tfd
.tfd_26
.mchdr
.frame_ctl
|=
6963 IEEE80211_STYPE_QOS_DATA
;
6965 if (priv
->qos_data
.qos_no_ack_mask
&
6966 (1UL << tx_queue_id
)) {
6967 tfd
->tx_flags
&= ~DCT_FLAG_ACK_REQD
;
6968 tfd
->tfd
.tfd_26
.mchdr
.qos_ctrl
|=
6978 * background support to run QoS activate functionality
6980 static void ipw_bg_qos_activate(void *data
)
6982 struct ipw_priv
*priv
= data
;
6989 if (priv
->status
& STATUS_ASSOCIATED
)
6990 ipw_qos_activate(priv
, &(priv
->assoc_network
->qos_data
));
6995 static int ipw_handle_probe_response(struct net_device
*dev
,
6996 struct ieee80211_probe_response
*resp
,
6997 struct ieee80211_network
*network
)
6999 struct ipw_priv
*priv
= ieee80211_priv(dev
);
7000 int active_network
= ((priv
->status
& STATUS_ASSOCIATED
) &&
7001 (network
== priv
->assoc_network
));
7003 ipw_qos_handle_probe_response(priv
, active_network
, network
);
7008 static int ipw_handle_beacon(struct net_device
*dev
,
7009 struct ieee80211_beacon
*resp
,
7010 struct ieee80211_network
*network
)
7012 struct ipw_priv
*priv
= ieee80211_priv(dev
);
7013 int active_network
= ((priv
->status
& STATUS_ASSOCIATED
) &&
7014 (network
== priv
->assoc_network
));
7016 ipw_qos_handle_probe_response(priv
, active_network
, network
);
7021 static int ipw_handle_assoc_response(struct net_device
*dev
,
7022 struct ieee80211_assoc_response
*resp
,
7023 struct ieee80211_network
*network
)
7025 struct ipw_priv
*priv
= ieee80211_priv(dev
);
7026 ipw_qos_association_resp(priv
, network
);
7030 static int ipw_send_qos_params_command(struct ipw_priv
*priv
, struct ieee80211_qos_parameters
7033 return ipw_send_cmd_pdu(priv
, IPW_CMD_QOS_PARAMETERS
,
7034 sizeof(*qos_param
) * 3, qos_param
);
7037 static int ipw_send_qos_info_command(struct ipw_priv
*priv
, struct ieee80211_qos_information_element
7040 return ipw_send_cmd_pdu(priv
, IPW_CMD_WME_INFO
, sizeof(*qos_param
),
7044 #endif /* CONFIG_IPW_QOS */
7046 static int ipw_associate_network(struct ipw_priv
*priv
,
7047 struct ieee80211_network
*network
,
7048 struct ipw_supported_rates
*rates
, int roaming
)
7052 if (priv
->config
& CFG_FIXED_RATE
)
7053 ipw_set_fixed_rate(priv
, network
->mode
);
7055 if (!(priv
->config
& CFG_STATIC_ESSID
)) {
7056 priv
->essid_len
= min(network
->ssid_len
,
7057 (u8
) IW_ESSID_MAX_SIZE
);
7058 memcpy(priv
->essid
, network
->ssid
, priv
->essid_len
);
7061 network
->last_associate
= jiffies
;
7063 memset(&priv
->assoc_request
, 0, sizeof(priv
->assoc_request
));
7064 priv
->assoc_request
.channel
= network
->channel
;
7065 priv
->assoc_request
.auth_key
= 0;
7067 if ((priv
->capability
& CAP_PRIVACY_ON
) &&
7068 (priv
->ieee
->sec
.auth_mode
== WLAN_AUTH_SHARED_KEY
)) {
7069 priv
->assoc_request
.auth_type
= AUTH_SHARED_KEY
;
7070 priv
->assoc_request
.auth_key
= priv
->ieee
->sec
.active_key
;
7072 if ((priv
->ieee
->sec
.level
== SEC_LEVEL_1
) &&
7073 !(priv
->ieee
->host_encrypt
|| priv
->ieee
->host_decrypt
))
7074 ipw_send_wep_keys(priv
, DCW_WEP_KEY_SEC_TYPE_WEP
);
7076 } else if ((priv
->capability
& CAP_PRIVACY_ON
) &&
7077 (priv
->ieee
->sec
.auth_mode
== WLAN_AUTH_LEAP
))
7078 priv
->assoc_request
.auth_type
= AUTH_LEAP
;
7080 priv
->assoc_request
.auth_type
= AUTH_OPEN
;
7082 if (priv
->ieee
->wpa_ie_len
) {
7083 priv
->assoc_request
.policy_support
= 0x02; /* RSN active */
7084 ipw_set_rsn_capa(priv
, priv
->ieee
->wpa_ie
,
7085 priv
->ieee
->wpa_ie_len
);
7089 * It is valid for our ieee device to support multiple modes, but
7090 * when it comes to associating to a given network we have to choose
7093 if (network
->mode
& priv
->ieee
->mode
& IEEE_A
)
7094 priv
->assoc_request
.ieee_mode
= IPW_A_MODE
;
7095 else if (network
->mode
& priv
->ieee
->mode
& IEEE_G
)
7096 priv
->assoc_request
.ieee_mode
= IPW_G_MODE
;
7097 else if (network
->mode
& priv
->ieee
->mode
& IEEE_B
)
7098 priv
->assoc_request
.ieee_mode
= IPW_B_MODE
;
7100 priv
->assoc_request
.capability
= network
->capability
;
7101 if ((network
->capability
& WLAN_CAPABILITY_SHORT_PREAMBLE
)
7102 && !(priv
->config
& CFG_PREAMBLE_LONG
)) {
7103 priv
->assoc_request
.preamble_length
= DCT_FLAG_SHORT_PREAMBLE
;
7105 priv
->assoc_request
.preamble_length
= DCT_FLAG_LONG_PREAMBLE
;
7107 /* Clear the short preamble if we won't be supporting it */
7108 priv
->assoc_request
.capability
&=
7109 ~WLAN_CAPABILITY_SHORT_PREAMBLE
;
7112 /* Clear capability bits that aren't used in Ad Hoc */
7113 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
)
7114 priv
->assoc_request
.capability
&=
7115 ~WLAN_CAPABILITY_SHORT_SLOT_TIME
;
7117 IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, "
7118 "802.11%c [%d], %s[:%s], enc=%s%s%s%c%c\n",
7119 roaming
? "Rea" : "A",
7120 escape_essid(priv
->essid
, priv
->essid_len
),
7122 ipw_modes
[priv
->assoc_request
.ieee_mode
],
7124 (priv
->assoc_request
.preamble_length
==
7125 DCT_FLAG_LONG_PREAMBLE
) ? "long" : "short",
7126 network
->capability
&
7127 WLAN_CAPABILITY_SHORT_PREAMBLE
? "short" : "long",
7128 priv
->capability
& CAP_PRIVACY_ON
? "on " : "off",
7129 priv
->capability
& CAP_PRIVACY_ON
?
7130 (priv
->capability
& CAP_SHARED_KEY
? "(shared)" :
7132 priv
->capability
& CAP_PRIVACY_ON
? " key=" : "",
7133 priv
->capability
& CAP_PRIVACY_ON
?
7134 '1' + priv
->ieee
->sec
.active_key
: '.',
7135 priv
->capability
& CAP_PRIVACY_ON
? '.' : ' ');
7137 priv
->assoc_request
.beacon_interval
= network
->beacon_interval
;
7138 if ((priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) &&
7139 (network
->time_stamp
[0] == 0) && (network
->time_stamp
[1] == 0)) {
7140 priv
->assoc_request
.assoc_type
= HC_IBSS_START
;
7141 priv
->assoc_request
.assoc_tsf_msw
= 0;
7142 priv
->assoc_request
.assoc_tsf_lsw
= 0;
7144 if (unlikely(roaming
))
7145 priv
->assoc_request
.assoc_type
= HC_REASSOCIATE
;
7147 priv
->assoc_request
.assoc_type
= HC_ASSOCIATE
;
7148 priv
->assoc_request
.assoc_tsf_msw
= network
->time_stamp
[1];
7149 priv
->assoc_request
.assoc_tsf_lsw
= network
->time_stamp
[0];
7152 memcpy(priv
->assoc_request
.bssid
, network
->bssid
, ETH_ALEN
);
7154 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) {
7155 memset(&priv
->assoc_request
.dest
, 0xFF, ETH_ALEN
);
7156 priv
->assoc_request
.atim_window
= network
->atim_window
;
7158 memcpy(priv
->assoc_request
.dest
, network
->bssid
, ETH_ALEN
);
7159 priv
->assoc_request
.atim_window
= 0;
7162 priv
->assoc_request
.listen_interval
= network
->listen_interval
;
7164 err
= ipw_send_ssid(priv
, priv
->essid
, priv
->essid_len
);
7166 IPW_DEBUG_HC("Attempt to send SSID command failed.\n");
7170 rates
->ieee_mode
= priv
->assoc_request
.ieee_mode
;
7171 rates
->purpose
= IPW_RATE_CONNECT
;
7172 ipw_send_supported_rates(priv
, rates
);
7174 if (priv
->assoc_request
.ieee_mode
== IPW_G_MODE
)
7175 priv
->sys_config
.dot11g_auto_detection
= 1;
7177 priv
->sys_config
.dot11g_auto_detection
= 0;
7179 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
)
7180 priv
->sys_config
.answer_broadcast_ssid_probe
= 1;
7182 priv
->sys_config
.answer_broadcast_ssid_probe
= 0;
7184 err
= ipw_send_system_config(priv
, &priv
->sys_config
);
7186 IPW_DEBUG_HC("Attempt to send sys config command failed.\n");
7190 IPW_DEBUG_ASSOC("Association sensitivity: %d\n", network
->stats
.rssi
);
7191 err
= ipw_set_sensitivity(priv
, network
->stats
.rssi
+ IPW_RSSI_TO_DBM
);
7193 IPW_DEBUG_HC("Attempt to send associate command failed.\n");
7198 * If preemption is enabled, it is possible for the association
7199 * to complete before we return from ipw_send_associate. Therefore
7200 * we have to be sure and update our priviate data first.
7202 priv
->channel
= network
->channel
;
7203 memcpy(priv
->bssid
, network
->bssid
, ETH_ALEN
);
7204 priv
->status
|= STATUS_ASSOCIATING
;
7205 priv
->status
&= ~STATUS_SECURITY_UPDATED
;
7207 priv
->assoc_network
= network
;
7209 #ifdef CONFIG_IPW_QOS
7210 ipw_qos_association(priv
, network
);
7213 err
= ipw_send_associate(priv
, &priv
->assoc_request
);
7215 IPW_DEBUG_HC("Attempt to send associate command failed.\n");
7219 IPW_DEBUG(IPW_DL_STATE
, "associating: '%s' " MAC_FMT
" \n",
7220 escape_essid(priv
->essid
, priv
->essid_len
),
7221 MAC_ARG(priv
->bssid
));
7226 static void ipw_roam(void *data
)
7228 struct ipw_priv
*priv
= data
;
7229 struct ieee80211_network
*network
= NULL
;
7230 struct ipw_network_match match
= {
7231 .network
= priv
->assoc_network
7234 /* The roaming process is as follows:
7236 * 1. Missed beacon threshold triggers the roaming process by
7237 * setting the status ROAM bit and requesting a scan.
7238 * 2. When the scan completes, it schedules the ROAM work
7239 * 3. The ROAM work looks at all of the known networks for one that
7240 * is a better network than the currently associated. If none
7241 * found, the ROAM process is over (ROAM bit cleared)
7242 * 4. If a better network is found, a disassociation request is
7244 * 5. When the disassociation completes, the roam work is again
7245 * scheduled. The second time through, the driver is no longer
7246 * associated, and the newly selected network is sent an
7247 * association request.
7248 * 6. At this point ,the roaming process is complete and the ROAM
7249 * status bit is cleared.
7252 /* If we are no longer associated, and the roaming bit is no longer
7253 * set, then we are not actively roaming, so just return */
7254 if (!(priv
->status
& (STATUS_ASSOCIATED
| STATUS_ROAMING
)))
7257 if (priv
->status
& STATUS_ASSOCIATED
) {
7258 /* First pass through ROAM process -- look for a better
7260 unsigned long flags
;
7261 u8 rssi
= priv
->assoc_network
->stats
.rssi
;
7262 priv
->assoc_network
->stats
.rssi
= -128;
7263 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
7264 list_for_each_entry(network
, &priv
->ieee
->network_list
, list
) {
7265 if (network
!= priv
->assoc_network
)
7266 ipw_best_network(priv
, &match
, network
, 1);
7268 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
7269 priv
->assoc_network
->stats
.rssi
= rssi
;
7271 if (match
.network
== priv
->assoc_network
) {
7272 IPW_DEBUG_ASSOC("No better APs in this network to "
7274 priv
->status
&= ~STATUS_ROAMING
;
7275 ipw_debug_config(priv
);
7279 ipw_send_disassociate(priv
, 1);
7280 priv
->assoc_network
= match
.network
;
7285 /* Second pass through ROAM process -- request association */
7286 ipw_compatible_rates(priv
, priv
->assoc_network
, &match
.rates
);
7287 ipw_associate_network(priv
, priv
->assoc_network
, &match
.rates
, 1);
7288 priv
->status
&= ~STATUS_ROAMING
;
7291 static void ipw_bg_roam(void *data
)
7293 struct ipw_priv
*priv
= data
;
7299 static int ipw_associate(void *data
)
7301 struct ipw_priv
*priv
= data
;
7303 struct ieee80211_network
*network
= NULL
;
7304 struct ipw_network_match match
= {
7307 struct ipw_supported_rates
*rates
;
7308 struct list_head
*element
;
7309 unsigned long flags
;
7311 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
) {
7312 IPW_DEBUG_ASSOC("Not attempting association (monitor mode)\n");
7316 if (priv
->status
& (STATUS_ASSOCIATED
| STATUS_ASSOCIATING
)) {
7317 IPW_DEBUG_ASSOC("Not attempting association (already in "
7322 if (priv
->status
& STATUS_DISASSOCIATING
) {
7323 IPW_DEBUG_ASSOC("Not attempting association (in "
7324 "disassociating)\n ");
7325 queue_work(priv
->workqueue
, &priv
->associate
);
7329 if (!ipw_is_init(priv
) || (priv
->status
& STATUS_SCANNING
)) {
7330 IPW_DEBUG_ASSOC("Not attempting association (scanning or not "
7335 if (!(priv
->config
& CFG_ASSOCIATE
) &&
7336 !(priv
->config
& (CFG_STATIC_ESSID
|
7337 CFG_STATIC_CHANNEL
| CFG_STATIC_BSSID
))) {
7338 IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n");
7342 /* Protect our use of the network_list */
7343 spin_lock_irqsave(&priv
->ieee
->lock
, flags
);
7344 list_for_each_entry(network
, &priv
->ieee
->network_list
, list
)
7345 ipw_best_network(priv
, &match
, network
, 0);
7347 network
= match
.network
;
7348 rates
= &match
.rates
;
7350 if (network
== NULL
&&
7351 priv
->ieee
->iw_mode
== IW_MODE_ADHOC
&&
7352 priv
->config
& CFG_ADHOC_CREATE
&&
7353 priv
->config
& CFG_STATIC_ESSID
&&
7354 priv
->config
& CFG_STATIC_CHANNEL
&&
7355 !list_empty(&priv
->ieee
->network_free_list
)) {
7356 element
= priv
->ieee
->network_free_list
.next
;
7357 network
= list_entry(element
, struct ieee80211_network
, list
);
7358 ipw_adhoc_create(priv
, network
);
7359 rates
= &priv
->rates
;
7361 list_add_tail(&network
->list
, &priv
->ieee
->network_list
);
7363 spin_unlock_irqrestore(&priv
->ieee
->lock
, flags
);
7365 /* If we reached the end of the list, then we don't have any valid
7368 ipw_debug_config(priv
);
7370 if (!(priv
->status
& STATUS_SCANNING
)) {
7371 if (!(priv
->config
& CFG_SPEED_SCAN
))
7372 queue_delayed_work(priv
->workqueue
,
7373 &priv
->request_scan
,
7376 queue_work(priv
->workqueue
,
7377 &priv
->request_scan
);
7383 ipw_associate_network(priv
, network
, rates
, 0);
7388 static void ipw_bg_associate(void *data
)
7390 struct ipw_priv
*priv
= data
;
7392 ipw_associate(data
);
7396 static void ipw_rebuild_decrypted_skb(struct ipw_priv
*priv
,
7397 struct sk_buff
*skb
)
7399 struct ieee80211_hdr
*hdr
;
7402 hdr
= (struct ieee80211_hdr
*)skb
->data
;
7403 fc
= le16_to_cpu(hdr
->frame_ctl
);
7404 if (!(fc
& IEEE80211_FCTL_PROTECTED
))
7407 fc
&= ~IEEE80211_FCTL_PROTECTED
;
7408 hdr
->frame_ctl
= cpu_to_le16(fc
);
7409 switch (priv
->ieee
->sec
.level
) {
7411 /* Remove CCMP HDR */
7412 memmove(skb
->data
+ IEEE80211_3ADDR_LEN
,
7413 skb
->data
+ IEEE80211_3ADDR_LEN
+ 8,
7414 skb
->len
- IEEE80211_3ADDR_LEN
- 8);
7415 skb_trim(skb
, skb
->len
- 16); /* CCMP_HDR_LEN + CCMP_MIC_LEN */
7421 memmove(skb
->data
+ IEEE80211_3ADDR_LEN
,
7422 skb
->data
+ IEEE80211_3ADDR_LEN
+ 4,
7423 skb
->len
- IEEE80211_3ADDR_LEN
- 4);
7424 skb_trim(skb
, skb
->len
- 8); /* IV + ICV */
7429 printk(KERN_ERR
"Unknow security level %d\n",
7430 priv
->ieee
->sec
.level
);
7435 static void ipw_handle_data_packet(struct ipw_priv
*priv
,
7436 struct ipw_rx_mem_buffer
*rxb
,
7437 struct ieee80211_rx_stats
*stats
)
7439 struct ieee80211_hdr_4addr
*hdr
;
7440 struct ipw_rx_packet
*pkt
= (struct ipw_rx_packet
*)rxb
->skb
->data
;
7442 /* We received data from the HW, so stop the watchdog */
7443 priv
->net_dev
->trans_start
= jiffies
;
7445 /* We only process data packets if the
7446 * interface is open */
7447 if (unlikely((le16_to_cpu(pkt
->u
.frame
.length
) + IPW_RX_FRAME_SIZE
) >
7448 skb_tailroom(rxb
->skb
))) {
7449 priv
->ieee
->stats
.rx_errors
++;
7450 priv
->wstats
.discard
.misc
++;
7451 IPW_DEBUG_DROP("Corruption detected! Oh no!\n");
7453 } else if (unlikely(!netif_running(priv
->net_dev
))) {
7454 priv
->ieee
->stats
.rx_dropped
++;
7455 priv
->wstats
.discard
.misc
++;
7456 IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
7460 /* Advance skb->data to the start of the actual payload */
7461 skb_reserve(rxb
->skb
, offsetof(struct ipw_rx_packet
, u
.frame
.data
));
7463 /* Set the size of the skb to the size of the frame */
7464 skb_put(rxb
->skb
, le16_to_cpu(pkt
->u
.frame
.length
));
7466 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb
->skb
->len
);
7468 /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */
7469 hdr
= (struct ieee80211_hdr_4addr
*)rxb
->skb
->data
;
7470 if (priv
->ieee
->iw_mode
!= IW_MODE_MONITOR
&&
7471 (is_multicast_ether_addr(hdr
->addr1
) ?
7472 !priv
->ieee
->host_mc_decrypt
: !priv
->ieee
->host_decrypt
))
7473 ipw_rebuild_decrypted_skb(priv
, rxb
->skb
);
7475 if (!ieee80211_rx(priv
->ieee
, rxb
->skb
, stats
))
7476 priv
->ieee
->stats
.rx_errors
++;
7477 else { /* ieee80211_rx succeeded, so it now owns the SKB */
7479 __ipw_led_activity_on(priv
);
7483 #ifdef CONFIG_IEEE80211_RADIOTAP
7484 static void ipw_handle_data_packet_monitor(struct ipw_priv
*priv
,
7485 struct ipw_rx_mem_buffer
*rxb
,
7486 struct ieee80211_rx_stats
*stats
)
7488 struct ipw_rx_packet
*pkt
= (struct ipw_rx_packet
*)rxb
->skb
->data
;
7489 struct ipw_rx_frame
*frame
= &pkt
->u
.frame
;
7491 /* initial pull of some data */
7492 u16 received_channel
= frame
->received_channel
;
7493 u8 antennaAndPhy
= frame
->antennaAndPhy
;
7494 s8 antsignal
= frame
->rssi_dbm
- IPW_RSSI_TO_DBM
; /* call it signed anyhow */
7495 u16 pktrate
= frame
->rate
;
7497 /* Magic struct that slots into the radiotap header -- no reason
7498 * to build this manually element by element, we can write it much
7499 * more efficiently than we can parse it. ORDER MATTERS HERE */
7501 struct ieee80211_radiotap_header rt_hdr
;
7502 u8 rt_flags
; /* radiotap packet flags */
7503 u8 rt_rate
; /* rate in 500kb/s */
7504 u16 rt_channel
; /* channel in mhz */
7505 u16 rt_chbitmask
; /* channel bitfield */
7506 s8 rt_dbmsignal
; /* signal in dbM, kluged to signed */
7507 u8 rt_antenna
; /* antenna number */
7510 short len
= le16_to_cpu(pkt
->u
.frame
.length
);
7512 /* We received data from the HW, so stop the watchdog */
7513 priv
->net_dev
->trans_start
= jiffies
;
7515 /* We only process data packets if the
7516 * interface is open */
7517 if (unlikely((le16_to_cpu(pkt
->u
.frame
.length
) + IPW_RX_FRAME_SIZE
) >
7518 skb_tailroom(rxb
->skb
))) {
7519 priv
->ieee
->stats
.rx_errors
++;
7520 priv
->wstats
.discard
.misc
++;
7521 IPW_DEBUG_DROP("Corruption detected! Oh no!\n");
7523 } else if (unlikely(!netif_running(priv
->net_dev
))) {
7524 priv
->ieee
->stats
.rx_dropped
++;
7525 priv
->wstats
.discard
.misc
++;
7526 IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
7530 /* Libpcap 0.9.3+ can handle variable length radiotap, so we'll use
7532 if (len
> IPW_RX_BUF_SIZE
- sizeof(struct ipw_rt_hdr
)) {
7533 /* FIXME: Should alloc bigger skb instead */
7534 priv
->ieee
->stats
.rx_dropped
++;
7535 priv
->wstats
.discard
.misc
++;
7536 IPW_DEBUG_DROP("Dropping too large packet in monitor\n");
7540 /* copy the frame itself */
7541 memmove(rxb
->skb
->data
+ sizeof(struct ipw_rt_hdr
),
7542 rxb
->skb
->data
+ IPW_RX_FRAME_SIZE
, len
);
7544 /* Zero the radiotap static buffer ... We only need to zero the bytes NOT
7545 * part of our real header, saves a little time.
7547 * No longer necessary since we fill in all our data. Purge before merging
7549 * memset(rxb->skb->data + sizeof(struct ipw_rt_hdr), 0,
7550 * IEEE80211_RADIOTAP_HDRLEN - sizeof(struct ipw_rt_hdr));
7553 ipw_rt
= (struct ipw_rt_hdr
*)rxb
->skb
->data
;
7555 ipw_rt
->rt_hdr
.it_version
= PKTHDR_RADIOTAP_VERSION
;
7556 ipw_rt
->rt_hdr
.it_pad
= 0; /* always good to zero */
7557 ipw_rt
->rt_hdr
.it_len
= sizeof(struct ipw_rt_hdr
); /* total header+data */
7559 /* Big bitfield of all the fields we provide in radiotap */
7560 ipw_rt
->rt_hdr
.it_present
=
7561 ((1 << IEEE80211_RADIOTAP_FLAGS
) |
7562 (1 << IEEE80211_RADIOTAP_RATE
) |
7563 (1 << IEEE80211_RADIOTAP_CHANNEL
) |
7564 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL
) |
7565 (1 << IEEE80211_RADIOTAP_ANTENNA
));
7567 /* Zero the flags, we'll add to them as we go */
7568 ipw_rt
->rt_flags
= 0;
7570 /* Convert signal to DBM */
7571 ipw_rt
->rt_dbmsignal
= antsignal
;
7573 /* Convert the channel data and set the flags */
7574 ipw_rt
->rt_channel
= cpu_to_le16(ieee80211chan2mhz(received_channel
));
7575 if (received_channel
> 14) { /* 802.11a */
7576 ipw_rt
->rt_chbitmask
=
7577 cpu_to_le16((IEEE80211_CHAN_OFDM
| IEEE80211_CHAN_5GHZ
));
7578 } else if (antennaAndPhy
& 32) { /* 802.11b */
7579 ipw_rt
->rt_chbitmask
=
7580 cpu_to_le16((IEEE80211_CHAN_CCK
| IEEE80211_CHAN_2GHZ
));
7581 } else { /* 802.11g */
7582 ipw_rt
->rt_chbitmask
=
7583 (IEEE80211_CHAN_OFDM
| IEEE80211_CHAN_2GHZ
);
7586 /* set the rate in multiples of 500k/s */
7588 case IPW_TX_RATE_1MB
:
7589 ipw_rt
->rt_rate
= 2;
7591 case IPW_TX_RATE_2MB
:
7592 ipw_rt
->rt_rate
= 4;
7594 case IPW_TX_RATE_5MB
:
7595 ipw_rt
->rt_rate
= 10;
7597 case IPW_TX_RATE_6MB
:
7598 ipw_rt
->rt_rate
= 12;
7600 case IPW_TX_RATE_9MB
:
7601 ipw_rt
->rt_rate
= 18;
7603 case IPW_TX_RATE_11MB
:
7604 ipw_rt
->rt_rate
= 22;
7606 case IPW_TX_RATE_12MB
:
7607 ipw_rt
->rt_rate
= 24;
7609 case IPW_TX_RATE_18MB
:
7610 ipw_rt
->rt_rate
= 36;
7612 case IPW_TX_RATE_24MB
:
7613 ipw_rt
->rt_rate
= 48;
7615 case IPW_TX_RATE_36MB
:
7616 ipw_rt
->rt_rate
= 72;
7618 case IPW_TX_RATE_48MB
:
7619 ipw_rt
->rt_rate
= 96;
7621 case IPW_TX_RATE_54MB
:
7622 ipw_rt
->rt_rate
= 108;
7625 ipw_rt
->rt_rate
= 0;
7629 /* antenna number */
7630 ipw_rt
->rt_antenna
= (antennaAndPhy
& 3); /* Is this right? */
7632 /* set the preamble flag if we have it */
7633 if ((antennaAndPhy
& 64))
7634 ipw_rt
->rt_flags
|= IEEE80211_RADIOTAP_F_SHORTPRE
;
7636 /* Set the size of the skb to the size of the frame */
7637 skb_put(rxb
->skb
, len
+ sizeof(struct ipw_rt_hdr
));
7639 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb
->skb
->len
);
7641 if (!ieee80211_rx(priv
->ieee
, rxb
->skb
, stats
))
7642 priv
->ieee
->stats
.rx_errors
++;
7643 else { /* ieee80211_rx succeeded, so it now owns the SKB */
7645 /* no LED during capture */
7650 static int is_network_packet(struct ipw_priv
*priv
,
7651 struct ieee80211_hdr_4addr
*header
)
7653 /* Filter incoming packets to determine if they are targetted toward
7654 * this network, discarding packets coming from ourselves */
7655 switch (priv
->ieee
->iw_mode
) {
7656 case IW_MODE_ADHOC
: /* Header: Dest. | Source | BSSID */
7657 /* packets from our adapter are dropped (echo) */
7658 if (!memcmp(header
->addr2
, priv
->net_dev
->dev_addr
, ETH_ALEN
))
7661 /* {broad,multi}cast packets to our BSSID go through */
7662 if (is_multicast_ether_addr(header
->addr1
))
7663 return !memcmp(header
->addr3
, priv
->bssid
, ETH_ALEN
);
7665 /* packets to our adapter go through */
7666 return !memcmp(header
->addr1
, priv
->net_dev
->dev_addr
,
7669 case IW_MODE_INFRA
: /* Header: Dest. | BSSID | Source */
7670 /* packets from our adapter are dropped (echo) */
7671 if (!memcmp(header
->addr3
, priv
->net_dev
->dev_addr
, ETH_ALEN
))
7674 /* {broad,multi}cast packets to our BSS go through */
7675 if (is_multicast_ether_addr(header
->addr1
))
7676 return !memcmp(header
->addr2
, priv
->bssid
, ETH_ALEN
);
7678 /* packets to our adapter go through */
7679 return !memcmp(header
->addr1
, priv
->net_dev
->dev_addr
,
7686 #define IPW_PACKET_RETRY_TIME HZ
7688 static int is_duplicate_packet(struct ipw_priv
*priv
,
7689 struct ieee80211_hdr_4addr
*header
)
7691 u16 sc
= le16_to_cpu(header
->seq_ctl
);
7692 u16 seq
= WLAN_GET_SEQ_SEQ(sc
);
7693 u16 frag
= WLAN_GET_SEQ_FRAG(sc
);
7694 u16
*last_seq
, *last_frag
;
7695 unsigned long *last_time
;
7697 switch (priv
->ieee
->iw_mode
) {
7700 struct list_head
*p
;
7701 struct ipw_ibss_seq
*entry
= NULL
;
7702 u8
*mac
= header
->addr2
;
7703 int index
= mac
[5] % IPW_IBSS_MAC_HASH_SIZE
;
7705 __list_for_each(p
, &priv
->ibss_mac_hash
[index
]) {
7707 list_entry(p
, struct ipw_ibss_seq
, list
);
7708 if (!memcmp(entry
->mac
, mac
, ETH_ALEN
))
7711 if (p
== &priv
->ibss_mac_hash
[index
]) {
7712 entry
= kmalloc(sizeof(*entry
), GFP_ATOMIC
);
7715 ("Cannot malloc new mac entry\n");
7718 memcpy(entry
->mac
, mac
, ETH_ALEN
);
7719 entry
->seq_num
= seq
;
7720 entry
->frag_num
= frag
;
7721 entry
->packet_time
= jiffies
;
7722 list_add(&entry
->list
,
7723 &priv
->ibss_mac_hash
[index
]);
7726 last_seq
= &entry
->seq_num
;
7727 last_frag
= &entry
->frag_num
;
7728 last_time
= &entry
->packet_time
;
7732 last_seq
= &priv
->last_seq_num
;
7733 last_frag
= &priv
->last_frag_num
;
7734 last_time
= &priv
->last_packet_time
;
7739 if ((*last_seq
== seq
) &&
7740 time_after(*last_time
+ IPW_PACKET_RETRY_TIME
, jiffies
)) {
7741 if (*last_frag
== frag
)
7743 if (*last_frag
+ 1 != frag
)
7744 /* out-of-order fragment */
7750 *last_time
= jiffies
;
7754 /* Comment this line now since we observed the card receives
7755 * duplicate packets but the FCTL_RETRY bit is not set in the
7756 * IBSS mode with fragmentation enabled.
7757 BUG_ON(!(le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_RETRY)); */
7761 static void ipw_handle_mgmt_packet(struct ipw_priv
*priv
,
7762 struct ipw_rx_mem_buffer
*rxb
,
7763 struct ieee80211_rx_stats
*stats
)
7765 struct sk_buff
*skb
= rxb
->skb
;
7766 struct ipw_rx_packet
*pkt
= (struct ipw_rx_packet
*)skb
->data
;
7767 struct ieee80211_hdr_4addr
*header
= (struct ieee80211_hdr_4addr
*)
7768 (skb
->data
+ IPW_RX_FRAME_SIZE
);
7770 ieee80211_rx_mgt(priv
->ieee
, header
, stats
);
7772 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
&&
7773 ((WLAN_FC_GET_STYPE(le16_to_cpu(header
->frame_ctl
)) ==
7774 IEEE80211_STYPE_PROBE_RESP
) ||
7775 (WLAN_FC_GET_STYPE(le16_to_cpu(header
->frame_ctl
)) ==
7776 IEEE80211_STYPE_BEACON
))) {
7777 if (!memcmp(header
->addr3
, priv
->bssid
, ETH_ALEN
))
7778 ipw_add_station(priv
, header
->addr2
);
7781 if (priv
->config
& CFG_NET_STATS
) {
7782 IPW_DEBUG_HC("sending stat packet\n");
7784 /* Set the size of the skb to the size of the full
7785 * ipw header and 802.11 frame */
7786 skb_put(skb
, le16_to_cpu(pkt
->u
.frame
.length
) +
7789 /* Advance past the ipw packet header to the 802.11 frame */
7790 skb_pull(skb
, IPW_RX_FRAME_SIZE
);
7792 /* Push the ieee80211_rx_stats before the 802.11 frame */
7793 memcpy(skb_push(skb
, sizeof(*stats
)), stats
, sizeof(*stats
));
7795 skb
->dev
= priv
->ieee
->dev
;
7797 /* Point raw at the ieee80211_stats */
7798 skb
->mac
.raw
= skb
->data
;
7800 skb
->pkt_type
= PACKET_OTHERHOST
;
7801 skb
->protocol
= __constant_htons(ETH_P_80211_STATS
);
7802 memset(skb
->cb
, 0, sizeof(rxb
->skb
->cb
));
7809 * Main entry function for recieving a packet with 80211 headers. This
7810 * should be called when ever the FW has notified us that there is a new
7811 * skb in the recieve queue.
7813 static void ipw_rx(struct ipw_priv
*priv
)
7815 struct ipw_rx_mem_buffer
*rxb
;
7816 struct ipw_rx_packet
*pkt
;
7817 struct ieee80211_hdr_4addr
*header
;
7821 r
= ipw_read32(priv
, IPW_RX_READ_INDEX
);
7822 w
= ipw_read32(priv
, IPW_RX_WRITE_INDEX
);
7823 i
= (priv
->rxq
->processed
+ 1) % RX_QUEUE_SIZE
;
7826 rxb
= priv
->rxq
->queue
[i
];
7827 #ifdef CONFIG_IPW2200_DEBUG
7828 if (unlikely(rxb
== NULL
)) {
7829 printk(KERN_CRIT
"Queue not allocated!\n");
7833 priv
->rxq
->queue
[i
] = NULL
;
7835 pci_dma_sync_single_for_cpu(priv
->pci_dev
, rxb
->dma_addr
,
7837 PCI_DMA_FROMDEVICE
);
7839 pkt
= (struct ipw_rx_packet
*)rxb
->skb
->data
;
7840 IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n",
7841 pkt
->header
.message_type
,
7842 pkt
->header
.rx_seq_num
, pkt
->header
.control_bits
);
7844 switch (pkt
->header
.message_type
) {
7845 case RX_FRAME_TYPE
: /* 802.11 frame */ {
7846 struct ieee80211_rx_stats stats
= {
7848 le16_to_cpu(pkt
->u
.frame
.rssi_dbm
) -
7851 le16_to_cpu(pkt
->u
.frame
.signal
),
7853 le16_to_cpu(pkt
->u
.frame
.noise
),
7854 .rate
= pkt
->u
.frame
.rate
,
7855 .mac_time
= jiffies
,
7857 pkt
->u
.frame
.received_channel
,
7860 control
& (1 << 0)) ?
7861 IEEE80211_24GHZ_BAND
:
7862 IEEE80211_52GHZ_BAND
,
7863 .len
= le16_to_cpu(pkt
->u
.frame
.length
),
7866 if (stats
.rssi
!= 0)
7867 stats
.mask
|= IEEE80211_STATMASK_RSSI
;
7868 if (stats
.signal
!= 0)
7869 stats
.mask
|= IEEE80211_STATMASK_SIGNAL
;
7870 if (stats
.noise
!= 0)
7871 stats
.mask
|= IEEE80211_STATMASK_NOISE
;
7872 if (stats
.rate
!= 0)
7873 stats
.mask
|= IEEE80211_STATMASK_RATE
;
7877 #ifdef CONFIG_IPW2200_MONITOR
7878 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
) {
7879 #ifdef CONFIG_IEEE80211_RADIOTAP
7880 ipw_handle_data_packet_monitor(priv
,
7884 ipw_handle_data_packet(priv
, rxb
,
7892 (struct ieee80211_hdr_4addr
*)(rxb
->skb
->
7895 /* TODO: Check Ad-Hoc dest/source and make sure
7896 * that we are actually parsing these packets
7897 * correctly -- we should probably use the
7898 * frame control of the packet and disregard
7899 * the current iw_mode */
7902 is_network_packet(priv
, header
);
7903 if (network_packet
&& priv
->assoc_network
) {
7904 priv
->assoc_network
->stats
.rssi
=
7906 average_add(&priv
->average_rssi
,
7908 priv
->last_rx_rssi
= stats
.rssi
;
7911 IPW_DEBUG_RX("Frame: len=%u\n",
7912 le16_to_cpu(pkt
->u
.frame
.length
));
7914 if (le16_to_cpu(pkt
->u
.frame
.length
) <
7915 frame_hdr_len(header
)) {
7917 ("Received packet is too small. "
7919 priv
->ieee
->stats
.rx_errors
++;
7920 priv
->wstats
.discard
.misc
++;
7924 switch (WLAN_FC_GET_TYPE
7925 (le16_to_cpu(header
->frame_ctl
))) {
7927 case IEEE80211_FTYPE_MGMT
:
7928 ipw_handle_mgmt_packet(priv
, rxb
,
7932 case IEEE80211_FTYPE_CTL
:
7935 case IEEE80211_FTYPE_DATA
:
7936 if (unlikely(!network_packet
||
7937 is_duplicate_packet(priv
,
7940 IPW_DEBUG_DROP("Dropping: "
7953 ipw_handle_data_packet(priv
, rxb
,
7961 case RX_HOST_NOTIFICATION_TYPE
:{
7963 ("Notification: subtype=%02X flags=%02X size=%d\n",
7964 pkt
->u
.notification
.subtype
,
7965 pkt
->u
.notification
.flags
,
7966 pkt
->u
.notification
.size
);
7967 ipw_rx_notification(priv
, &pkt
->u
.notification
);
7972 IPW_DEBUG_RX("Bad Rx packet of type %d\n",
7973 pkt
->header
.message_type
);
7977 /* For now we just don't re-use anything. We can tweak this
7978 * later to try and re-use notification packets and SKBs that
7979 * fail to Rx correctly */
7980 if (rxb
->skb
!= NULL
) {
7981 dev_kfree_skb_any(rxb
->skb
);
7985 pci_unmap_single(priv
->pci_dev
, rxb
->dma_addr
,
7986 IPW_RX_BUF_SIZE
, PCI_DMA_FROMDEVICE
);
7987 list_add_tail(&rxb
->list
, &priv
->rxq
->rx_used
);
7989 i
= (i
+ 1) % RX_QUEUE_SIZE
;
7992 /* Backtrack one entry */
7993 priv
->rxq
->processed
= (i
? i
: RX_QUEUE_SIZE
) - 1;
7995 ipw_rx_queue_restock(priv
);
7998 #define DEFAULT_RTS_THRESHOLD 2304U
7999 #define MIN_RTS_THRESHOLD 1U
8000 #define MAX_RTS_THRESHOLD 2304U
8001 #define DEFAULT_BEACON_INTERVAL 100U
8002 #define DEFAULT_SHORT_RETRY_LIMIT 7U
8003 #define DEFAULT_LONG_RETRY_LIMIT 4U
8005 static int ipw_sw_reset(struct ipw_priv
*priv
, int init
)
8007 int band
, modulation
;
8008 int old_mode
= priv
->ieee
->iw_mode
;
8010 /* Initialize module parameter values here */
8013 /* We default to disabling the LED code as right now it causes
8014 * too many systems to lock up... */
8016 priv
->config
|= CFG_NO_LED
;
8019 priv
->config
|= CFG_ASSOCIATE
;
8021 IPW_DEBUG_INFO("Auto associate disabled.\n");
8024 priv
->config
|= CFG_ADHOC_CREATE
;
8026 IPW_DEBUG_INFO("Auto adhoc creation disabled.\n");
8028 priv
->config
&= ~CFG_STATIC_ESSID
;
8029 priv
->essid_len
= 0;
8030 memset(priv
->essid
, 0, IW_ESSID_MAX_SIZE
);
8033 priv
->status
|= STATUS_RF_KILL_SW
;
8034 IPW_DEBUG_INFO("Radio disabled.\n");
8038 priv
->config
|= CFG_STATIC_CHANNEL
;
8039 priv
->channel
= channel
;
8040 IPW_DEBUG_INFO("Bind to static channel %d\n", channel
);
8041 /* TODO: Validate that provided channel is in range */
8043 #ifdef CONFIG_IPW_QOS
8044 ipw_qos_init(priv
, qos_enable
, qos_burst_enable
,
8045 burst_duration_CCK
, burst_duration_OFDM
);
8046 #endif /* CONFIG_IPW_QOS */
8050 priv
->ieee
->iw_mode
= IW_MODE_ADHOC
;
8051 priv
->net_dev
->type
= ARPHRD_ETHER
;
8054 #ifdef CONFIG_IPW2200_MONITOR
8056 priv
->ieee
->iw_mode
= IW_MODE_MONITOR
;
8057 #ifdef CONFIG_IEEE80211_RADIOTAP
8058 priv
->net_dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
8060 priv
->net_dev
->type
= ARPHRD_IEEE80211
;
8066 priv
->net_dev
->type
= ARPHRD_ETHER
;
8067 priv
->ieee
->iw_mode
= IW_MODE_INFRA
;
8072 priv
->ieee
->host_encrypt
= 0;
8073 priv
->ieee
->host_encrypt_msdu
= 0;
8074 priv
->ieee
->host_decrypt
= 0;
8075 priv
->ieee
->host_mc_decrypt
= 0;
8077 IPW_DEBUG_INFO("Hardware crypto [%s]\n", hwcrypto
? "on" : "off");
8079 /* IPW2200/2915 is abled to do hardware fragmentation. */
8080 priv
->ieee
->host_open_frag
= 0;
8082 if ((priv
->pci_dev
->device
== 0x4223) ||
8083 (priv
->pci_dev
->device
== 0x4224)) {
8085 printk(KERN_INFO DRV_NAME
8086 ": Detected Intel PRO/Wireless 2915ABG Network "
8088 priv
->ieee
->abg_true
= 1;
8089 band
= IEEE80211_52GHZ_BAND
| IEEE80211_24GHZ_BAND
;
8090 modulation
= IEEE80211_OFDM_MODULATION
|
8091 IEEE80211_CCK_MODULATION
;
8092 priv
->adapter
= IPW_2915ABG
;
8093 priv
->ieee
->mode
= IEEE_A
| IEEE_G
| IEEE_B
;
8096 printk(KERN_INFO DRV_NAME
8097 ": Detected Intel PRO/Wireless 2200BG Network "
8100 priv
->ieee
->abg_true
= 0;
8101 band
= IEEE80211_24GHZ_BAND
;
8102 modulation
= IEEE80211_OFDM_MODULATION
|
8103 IEEE80211_CCK_MODULATION
;
8104 priv
->adapter
= IPW_2200BG
;
8105 priv
->ieee
->mode
= IEEE_G
| IEEE_B
;
8108 priv
->ieee
->freq_band
= band
;
8109 priv
->ieee
->modulation
= modulation
;
8111 priv
->rates_mask
= IEEE80211_DEFAULT_RATES_MASK
;
8113 priv
->disassociate_threshold
= IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT
;
8114 priv
->roaming_threshold
= IPW_MB_ROAMING_THRESHOLD_DEFAULT
;
8116 priv
->rts_threshold
= DEFAULT_RTS_THRESHOLD
;
8117 priv
->short_retry_limit
= DEFAULT_SHORT_RETRY_LIMIT
;
8118 priv
->long_retry_limit
= DEFAULT_LONG_RETRY_LIMIT
;
8120 /* If power management is turned on, default to AC mode */
8121 priv
->power_mode
= IPW_POWER_AC
;
8122 priv
->tx_power
= IPW_TX_POWER_DEFAULT
;
8124 return old_mode
== priv
->ieee
->iw_mode
;
8128 * This file defines the Wireless Extension handlers. It does not
8129 * define any methods of hardware manipulation and relies on the
8130 * functions defined in ipw_main to provide the HW interaction.
8132 * The exception to this is the use of the ipw_get_ordinal()
8133 * function used to poll the hardware vs. making unecessary calls.
8137 static int ipw_wx_get_name(struct net_device
*dev
,
8138 struct iw_request_info
*info
,
8139 union iwreq_data
*wrqu
, char *extra
)
8141 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8143 if (priv
->status
& STATUS_RF_KILL_MASK
)
8144 strcpy(wrqu
->name
, "radio off");
8145 else if (!(priv
->status
& STATUS_ASSOCIATED
))
8146 strcpy(wrqu
->name
, "unassociated");
8148 snprintf(wrqu
->name
, IFNAMSIZ
, "IEEE 802.11%c",
8149 ipw_modes
[priv
->assoc_request
.ieee_mode
]);
8150 IPW_DEBUG_WX("Name: %s\n", wrqu
->name
);
8155 static int ipw_set_channel(struct ipw_priv
*priv
, u8 channel
)
8158 IPW_DEBUG_INFO("Setting channel to ANY (0)\n");
8159 priv
->config
&= ~CFG_STATIC_CHANNEL
;
8160 IPW_DEBUG_ASSOC("Attempting to associate with new "
8162 ipw_associate(priv
);
8166 priv
->config
|= CFG_STATIC_CHANNEL
;
8168 if (priv
->channel
== channel
) {
8169 IPW_DEBUG_INFO("Request to set channel to current value (%d)\n",
8174 IPW_DEBUG_INFO("Setting channel to %i\n", (int)channel
);
8175 priv
->channel
= channel
;
8177 #ifdef CONFIG_IPW2200_MONITOR
8178 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
) {
8180 if (priv
->status
& STATUS_SCANNING
) {
8181 IPW_DEBUG_SCAN("Scan abort triggered due to "
8182 "channel change.\n");
8183 ipw_abort_scan(priv
);
8186 for (i
= 1000; i
&& (priv
->status
& STATUS_SCANNING
); i
--)
8189 if (priv
->status
& STATUS_SCANNING
)
8190 IPW_DEBUG_SCAN("Still scanning...\n");
8192 IPW_DEBUG_SCAN("Took %dms to abort current scan\n",
8197 #endif /* CONFIG_IPW2200_MONITOR */
8199 /* Network configuration changed -- force [re]association */
8200 IPW_DEBUG_ASSOC("[re]association triggered due to channel change.\n");
8201 if (!ipw_disassociate(priv
))
8202 ipw_associate(priv
);
8207 static int ipw_wx_set_freq(struct net_device
*dev
,
8208 struct iw_request_info
*info
,
8209 union iwreq_data
*wrqu
, char *extra
)
8211 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8212 const struct ieee80211_geo
*geo
= ipw_get_geo(priv
->ieee
);
8213 struct iw_freq
*fwrq
= &wrqu
->freq
;
8219 IPW_DEBUG_WX("SET Freq/Channel -> any\n");
8221 ret
= ipw_set_channel(priv
, 0);
8225 /* if setting by freq convert to channel */
8227 channel
= ipw_freq_to_channel(priv
->ieee
, fwrq
->m
);
8233 if (!(band
= ipw_is_valid_channel(priv
->ieee
, channel
)))
8236 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
) {
8237 i
= ipw_channel_to_index(priv
->ieee
, channel
);
8241 flags
= (band
== IEEE80211_24GHZ_BAND
) ?
8242 geo
->bg
[i
].flags
: geo
->a
[i
].flags
;
8243 if (flags
& IEEE80211_CH_PASSIVE_ONLY
) {
8244 IPW_DEBUG_WX("Invalid Ad-Hoc channel for 802.11a\n");
8249 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq
->m
);
8251 ret
= ipw_set_channel(priv
, channel
);
8256 static int ipw_wx_get_freq(struct net_device
*dev
,
8257 struct iw_request_info
*info
,
8258 union iwreq_data
*wrqu
, char *extra
)
8260 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8264 /* If we are associated, trying to associate, or have a statically
8265 * configured CHANNEL then return that; otherwise return ANY */
8267 if (priv
->config
& CFG_STATIC_CHANNEL
||
8268 priv
->status
& (STATUS_ASSOCIATING
| STATUS_ASSOCIATED
))
8269 wrqu
->freq
.m
= priv
->channel
;
8274 IPW_DEBUG_WX("GET Freq/Channel -> %d \n", priv
->channel
);
8278 static int ipw_wx_set_mode(struct net_device
*dev
,
8279 struct iw_request_info
*info
,
8280 union iwreq_data
*wrqu
, char *extra
)
8282 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8285 IPW_DEBUG_WX("Set MODE: %d\n", wrqu
->mode
);
8287 switch (wrqu
->mode
) {
8288 #ifdef CONFIG_IPW2200_MONITOR
8289 case IW_MODE_MONITOR
:
8295 wrqu
->mode
= IW_MODE_INFRA
;
8300 if (wrqu
->mode
== priv
->ieee
->iw_mode
)
8305 ipw_sw_reset(priv
, 0);
8307 #ifdef CONFIG_IPW2200_MONITOR
8308 if (priv
->ieee
->iw_mode
== IW_MODE_MONITOR
)
8309 priv
->net_dev
->type
= ARPHRD_ETHER
;
8311 if (wrqu
->mode
== IW_MODE_MONITOR
)
8312 #ifdef CONFIG_IEEE80211_RADIOTAP
8313 priv
->net_dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
8315 priv
->net_dev
->type
= ARPHRD_IEEE80211
;
8317 #endif /* CONFIG_IPW2200_MONITOR */
8319 /* Free the existing firmware and reset the fw_loaded
8320 * flag so ipw_load() will bring in the new firmawre */
8323 priv
->ieee
->iw_mode
= wrqu
->mode
;
8325 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
8330 static int ipw_wx_get_mode(struct net_device
*dev
,
8331 struct iw_request_info
*info
,
8332 union iwreq_data
*wrqu
, char *extra
)
8334 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8336 wrqu
->mode
= priv
->ieee
->iw_mode
;
8337 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu
->mode
);
8342 /* Values are in microsecond */
8343 static const s32 timeout_duration
[] = {
8351 static const s32 period_duration
[] = {
8359 static int ipw_wx_get_range(struct net_device
*dev
,
8360 struct iw_request_info
*info
,
8361 union iwreq_data
*wrqu
, char *extra
)
8363 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8364 struct iw_range
*range
= (struct iw_range
*)extra
;
8365 const struct ieee80211_geo
*geo
= ipw_get_geo(priv
->ieee
);
8368 wrqu
->data
.length
= sizeof(*range
);
8369 memset(range
, 0, sizeof(*range
));
8371 /* 54Mbs == ~27 Mb/s real (802.11g) */
8372 range
->throughput
= 27 * 1000 * 1000;
8374 range
->max_qual
.qual
= 100;
8375 /* TODO: Find real max RSSI and stick here */
8376 range
->max_qual
.level
= 0;
8377 range
->max_qual
.noise
= priv
->ieee
->worst_rssi
+ 0x100;
8378 range
->max_qual
.updated
= 7; /* Updated all three */
8380 range
->avg_qual
.qual
= 70;
8381 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
8382 range
->avg_qual
.level
= 0; /* FIXME to real average level */
8383 range
->avg_qual
.noise
= 0;
8384 range
->avg_qual
.updated
= 7; /* Updated all three */
8386 range
->num_bitrates
= min(priv
->rates
.num_rates
, (u8
) IW_MAX_BITRATES
);
8388 for (i
= 0; i
< range
->num_bitrates
; i
++)
8389 range
->bitrate
[i
] = (priv
->rates
.supported_rates
[i
] & 0x7F) *
8392 range
->max_rts
= DEFAULT_RTS_THRESHOLD
;
8393 range
->min_frag
= MIN_FRAG_THRESHOLD
;
8394 range
->max_frag
= MAX_FRAG_THRESHOLD
;
8396 range
->encoding_size
[0] = 5;
8397 range
->encoding_size
[1] = 13;
8398 range
->num_encoding_sizes
= 2;
8399 range
->max_encoding_tokens
= WEP_KEYS
;
8401 /* Set the Wireless Extension versions */
8402 range
->we_version_compiled
= WIRELESS_EXT
;
8403 range
->we_version_source
= 16;
8406 if (priv
->ieee
->mode
& (IEEE_B
| IEEE_G
)) {
8407 for (j
= 0; j
< geo
->bg_channels
&& i
< IW_MAX_FREQUENCIES
;
8409 range
->freq
[i
].i
= geo
->bg
[j
].channel
;
8410 range
->freq
[i
].m
= geo
->bg
[j
].freq
* 100000;
8411 range
->freq
[i
].e
= 1;
8415 if (priv
->ieee
->mode
& IEEE_A
) {
8416 for (j
= 0; j
< geo
->a_channels
&& i
< IW_MAX_FREQUENCIES
;
8418 range
->freq
[i
].i
= geo
->a
[j
].channel
;
8419 range
->freq
[i
].m
= geo
->a
[j
].freq
* 100000;
8420 range
->freq
[i
].e
= 1;
8424 range
->num_channels
= i
;
8425 range
->num_frequency
= i
;
8429 /* Event capability (kernel + driver) */
8430 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
8431 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
8432 IW_EVENT_CAPA_MASK(SIOCGIWAP
));
8433 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
8435 IPW_DEBUG_WX("GET Range\n");
8439 static int ipw_wx_set_wap(struct net_device
*dev
,
8440 struct iw_request_info
*info
,
8441 union iwreq_data
*wrqu
, char *extra
)
8443 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8445 static const unsigned char any
[] = {
8446 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
8448 static const unsigned char off
[] = {
8449 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
8452 if (wrqu
->ap_addr
.sa_family
!= ARPHRD_ETHER
)
8455 if (!memcmp(any
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
) ||
8456 !memcmp(off
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
)) {
8457 /* we disable mandatory BSSID association */
8458 IPW_DEBUG_WX("Setting AP BSSID to ANY\n");
8459 priv
->config
&= ~CFG_STATIC_BSSID
;
8460 IPW_DEBUG_ASSOC("Attempting to associate with new "
8462 ipw_associate(priv
);
8467 priv
->config
|= CFG_STATIC_BSSID
;
8468 if (!memcmp(priv
->bssid
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
)) {
8469 IPW_DEBUG_WX("BSSID set to current BSSID.\n");
8474 IPW_DEBUG_WX("Setting mandatory BSSID to " MAC_FMT
"\n",
8475 MAC_ARG(wrqu
->ap_addr
.sa_data
));
8477 memcpy(priv
->bssid
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
);
8479 /* Network configuration changed -- force [re]association */
8480 IPW_DEBUG_ASSOC("[re]association triggered due to BSSID change.\n");
8481 if (!ipw_disassociate(priv
))
8482 ipw_associate(priv
);
8488 static int ipw_wx_get_wap(struct net_device
*dev
,
8489 struct iw_request_info
*info
,
8490 union iwreq_data
*wrqu
, char *extra
)
8492 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8493 /* If we are associated, trying to associate, or have a statically
8494 * configured BSSID then return that; otherwise return ANY */
8496 if (priv
->config
& CFG_STATIC_BSSID
||
8497 priv
->status
& (STATUS_ASSOCIATED
| STATUS_ASSOCIATING
)) {
8498 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
8499 memcpy(wrqu
->ap_addr
.sa_data
, priv
->bssid
, ETH_ALEN
);
8501 memset(wrqu
->ap_addr
.sa_data
, 0, ETH_ALEN
);
8503 IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT
"\n",
8504 MAC_ARG(wrqu
->ap_addr
.sa_data
));
8509 static int ipw_wx_set_essid(struct net_device
*dev
,
8510 struct iw_request_info
*info
,
8511 union iwreq_data
*wrqu
, char *extra
)
8513 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8514 char *essid
= ""; /* ANY */
8517 if (wrqu
->essid
.flags
&& wrqu
->essid
.length
) {
8518 length
= wrqu
->essid
.length
- 1;
8522 IPW_DEBUG_WX("Setting ESSID to ANY\n");
8523 if ((priv
->config
& CFG_STATIC_ESSID
) &&
8524 !(priv
->status
& (STATUS_ASSOCIATED
|
8525 STATUS_ASSOCIATING
))) {
8526 IPW_DEBUG_ASSOC("Attempting to associate with new "
8528 priv
->config
&= ~CFG_STATIC_ESSID
;
8529 ipw_associate(priv
);
8535 length
= min(length
, IW_ESSID_MAX_SIZE
);
8537 priv
->config
|= CFG_STATIC_ESSID
;
8539 if (priv
->essid_len
== length
&& !memcmp(priv
->essid
, extra
, length
)) {
8540 IPW_DEBUG_WX("ESSID set to current ESSID.\n");
8545 IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid
, length
),
8548 priv
->essid_len
= length
;
8549 memcpy(priv
->essid
, essid
, priv
->essid_len
);
8551 /* Network configuration changed -- force [re]association */
8552 IPW_DEBUG_ASSOC("[re]association triggered due to ESSID change.\n");
8553 if (!ipw_disassociate(priv
))
8554 ipw_associate(priv
);
8560 static int ipw_wx_get_essid(struct net_device
*dev
,
8561 struct iw_request_info
*info
,
8562 union iwreq_data
*wrqu
, char *extra
)
8564 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8566 /* If we are associated, trying to associate, or have a statically
8567 * configured ESSID then return that; otherwise return ANY */
8569 if (priv
->config
& CFG_STATIC_ESSID
||
8570 priv
->status
& (STATUS_ASSOCIATED
| STATUS_ASSOCIATING
)) {
8571 IPW_DEBUG_WX("Getting essid: '%s'\n",
8572 escape_essid(priv
->essid
, priv
->essid_len
));
8573 memcpy(extra
, priv
->essid
, priv
->essid_len
);
8574 wrqu
->essid
.length
= priv
->essid_len
;
8575 wrqu
->essid
.flags
= 1; /* active */
8577 IPW_DEBUG_WX("Getting essid: ANY\n");
8578 wrqu
->essid
.length
= 0;
8579 wrqu
->essid
.flags
= 0; /* active */
8585 static int ipw_wx_set_nick(struct net_device
*dev
,
8586 struct iw_request_info
*info
,
8587 union iwreq_data
*wrqu
, char *extra
)
8589 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8591 IPW_DEBUG_WX("Setting nick to '%s'\n", extra
);
8592 if (wrqu
->data
.length
> IW_ESSID_MAX_SIZE
)
8595 wrqu
->data
.length
= min((size_t) wrqu
->data
.length
, sizeof(priv
->nick
));
8596 memset(priv
->nick
, 0, sizeof(priv
->nick
));
8597 memcpy(priv
->nick
, extra
, wrqu
->data
.length
);
8598 IPW_DEBUG_TRACE("<<\n");
8604 static int ipw_wx_get_nick(struct net_device
*dev
,
8605 struct iw_request_info
*info
,
8606 union iwreq_data
*wrqu
, char *extra
)
8608 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8609 IPW_DEBUG_WX("Getting nick\n");
8611 wrqu
->data
.length
= strlen(priv
->nick
) + 1;
8612 memcpy(extra
, priv
->nick
, wrqu
->data
.length
);
8613 wrqu
->data
.flags
= 1; /* active */
8618 static int ipw_wx_set_rate(struct net_device
*dev
,
8619 struct iw_request_info
*info
,
8620 union iwreq_data
*wrqu
, char *extra
)
8622 /* TODO: We should use semaphores or locks for access to priv */
8623 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8624 u32 target_rate
= wrqu
->bitrate
.value
;
8627 /* value = -1, fixed = 0 means auto only, so we should use all rates offered by AP */
8628 /* value = X, fixed = 1 means only rate X */
8629 /* value = X, fixed = 0 means all rates lower equal X */
8631 if (target_rate
== -1) {
8633 mask
= IEEE80211_DEFAULT_RATES_MASK
;
8634 /* Now we should reassociate */
8639 fixed
= wrqu
->bitrate
.fixed
;
8641 if (target_rate
== 1000000 || !fixed
)
8642 mask
|= IEEE80211_CCK_RATE_1MB_MASK
;
8643 if (target_rate
== 1000000)
8646 if (target_rate
== 2000000 || !fixed
)
8647 mask
|= IEEE80211_CCK_RATE_2MB_MASK
;
8648 if (target_rate
== 2000000)
8651 if (target_rate
== 5500000 || !fixed
)
8652 mask
|= IEEE80211_CCK_RATE_5MB_MASK
;
8653 if (target_rate
== 5500000)
8656 if (target_rate
== 6000000 || !fixed
)
8657 mask
|= IEEE80211_OFDM_RATE_6MB_MASK
;
8658 if (target_rate
== 6000000)
8661 if (target_rate
== 9000000 || !fixed
)
8662 mask
|= IEEE80211_OFDM_RATE_9MB_MASK
;
8663 if (target_rate
== 9000000)
8666 if (target_rate
== 11000000 || !fixed
)
8667 mask
|= IEEE80211_CCK_RATE_11MB_MASK
;
8668 if (target_rate
== 11000000)
8671 if (target_rate
== 12000000 || !fixed
)
8672 mask
|= IEEE80211_OFDM_RATE_12MB_MASK
;
8673 if (target_rate
== 12000000)
8676 if (target_rate
== 18000000 || !fixed
)
8677 mask
|= IEEE80211_OFDM_RATE_18MB_MASK
;
8678 if (target_rate
== 18000000)
8681 if (target_rate
== 24000000 || !fixed
)
8682 mask
|= IEEE80211_OFDM_RATE_24MB_MASK
;
8683 if (target_rate
== 24000000)
8686 if (target_rate
== 36000000 || !fixed
)
8687 mask
|= IEEE80211_OFDM_RATE_36MB_MASK
;
8688 if (target_rate
== 36000000)
8691 if (target_rate
== 48000000 || !fixed
)
8692 mask
|= IEEE80211_OFDM_RATE_48MB_MASK
;
8693 if (target_rate
== 48000000)
8696 if (target_rate
== 54000000 || !fixed
)
8697 mask
|= IEEE80211_OFDM_RATE_54MB_MASK
;
8698 if (target_rate
== 54000000)
8701 IPW_DEBUG_WX("invalid rate specified, returning error\n");
8705 IPW_DEBUG_WX("Setting rate mask to 0x%08X [%s]\n",
8706 mask
, fixed
? "fixed" : "sub-rates");
8708 if (mask
== IEEE80211_DEFAULT_RATES_MASK
) {
8709 priv
->config
&= ~CFG_FIXED_RATE
;
8710 ipw_set_fixed_rate(priv
, priv
->ieee
->mode
);
8712 priv
->config
|= CFG_FIXED_RATE
;
8714 if (priv
->rates_mask
== mask
) {
8715 IPW_DEBUG_WX("Mask set to current mask.\n");
8720 priv
->rates_mask
= mask
;
8722 /* Network configuration changed -- force [re]association */
8723 IPW_DEBUG_ASSOC("[re]association triggered due to rates change.\n");
8724 if (!ipw_disassociate(priv
))
8725 ipw_associate(priv
);
8731 static int ipw_wx_get_rate(struct net_device
*dev
,
8732 struct iw_request_info
*info
,
8733 union iwreq_data
*wrqu
, char *extra
)
8735 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8737 wrqu
->bitrate
.value
= priv
->last_rate
;
8739 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu
->bitrate
.value
);
8743 static int ipw_wx_set_rts(struct net_device
*dev
,
8744 struct iw_request_info
*info
,
8745 union iwreq_data
*wrqu
, char *extra
)
8747 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8749 if (wrqu
->rts
.disabled
)
8750 priv
->rts_threshold
= DEFAULT_RTS_THRESHOLD
;
8752 if (wrqu
->rts
.value
< MIN_RTS_THRESHOLD
||
8753 wrqu
->rts
.value
> MAX_RTS_THRESHOLD
) {
8757 priv
->rts_threshold
= wrqu
->rts
.value
;
8760 ipw_send_rts_threshold(priv
, priv
->rts_threshold
);
8762 IPW_DEBUG_WX("SET RTS Threshold -> %d \n", priv
->rts_threshold
);
8766 static int ipw_wx_get_rts(struct net_device
*dev
,
8767 struct iw_request_info
*info
,
8768 union iwreq_data
*wrqu
, char *extra
)
8770 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8772 wrqu
->rts
.value
= priv
->rts_threshold
;
8773 wrqu
->rts
.fixed
= 0; /* no auto select */
8774 wrqu
->rts
.disabled
= (wrqu
->rts
.value
== DEFAULT_RTS_THRESHOLD
);
8776 IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu
->rts
.value
);
8780 static int ipw_wx_set_txpow(struct net_device
*dev
,
8781 struct iw_request_info
*info
,
8782 union iwreq_data
*wrqu
, char *extra
)
8784 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8788 if (ipw_radio_kill_sw(priv
, wrqu
->power
.disabled
)) {
8793 if (!wrqu
->power
.fixed
)
8794 wrqu
->power
.value
= IPW_TX_POWER_DEFAULT
;
8796 if (wrqu
->power
.flags
!= IW_TXPOW_DBM
) {
8801 if ((wrqu
->power
.value
> IPW_TX_POWER_MAX
) ||
8802 (wrqu
->power
.value
< IPW_TX_POWER_MIN
)) {
8807 priv
->tx_power
= wrqu
->power
.value
;
8808 err
= ipw_set_tx_power(priv
);
8814 static int ipw_wx_get_txpow(struct net_device
*dev
,
8815 struct iw_request_info
*info
,
8816 union iwreq_data
*wrqu
, char *extra
)
8818 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8820 wrqu
->power
.value
= priv
->tx_power
;
8821 wrqu
->power
.fixed
= 1;
8822 wrqu
->power
.flags
= IW_TXPOW_DBM
;
8823 wrqu
->power
.disabled
= (priv
->status
& STATUS_RF_KILL_MASK
) ? 1 : 0;
8826 IPW_DEBUG_WX("GET TX Power -> %s %d \n",
8827 wrqu
->power
.disabled
? "OFF" : "ON", wrqu
->power
.value
);
8832 static int ipw_wx_set_frag(struct net_device
*dev
,
8833 struct iw_request_info
*info
,
8834 union iwreq_data
*wrqu
, char *extra
)
8836 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8838 if (wrqu
->frag
.disabled
)
8839 priv
->ieee
->fts
= DEFAULT_FTS
;
8841 if (wrqu
->frag
.value
< MIN_FRAG_THRESHOLD
||
8842 wrqu
->frag
.value
> MAX_FRAG_THRESHOLD
) {
8847 priv
->ieee
->fts
= wrqu
->frag
.value
& ~0x1;
8850 ipw_send_frag_threshold(priv
, wrqu
->frag
.value
);
8852 IPW_DEBUG_WX("SET Frag Threshold -> %d \n", wrqu
->frag
.value
);
8856 static int ipw_wx_get_frag(struct net_device
*dev
,
8857 struct iw_request_info
*info
,
8858 union iwreq_data
*wrqu
, char *extra
)
8860 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8862 wrqu
->frag
.value
= priv
->ieee
->fts
;
8863 wrqu
->frag
.fixed
= 0; /* no auto select */
8864 wrqu
->frag
.disabled
= (wrqu
->frag
.value
== DEFAULT_FTS
);
8866 IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu
->frag
.value
);
8871 static int ipw_wx_set_retry(struct net_device
*dev
,
8872 struct iw_request_info
*info
,
8873 union iwreq_data
*wrqu
, char *extra
)
8875 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8877 if (wrqu
->retry
.flags
& IW_RETRY_LIFETIME
|| wrqu
->retry
.disabled
)
8880 if (!(wrqu
->retry
.flags
& IW_RETRY_LIMIT
))
8883 if (wrqu
->retry
.value
< 0 || wrqu
->retry
.value
> 255)
8887 if (wrqu
->retry
.flags
& IW_RETRY_MIN
)
8888 priv
->short_retry_limit
= (u8
) wrqu
->retry
.value
;
8889 else if (wrqu
->retry
.flags
& IW_RETRY_MAX
)
8890 priv
->long_retry_limit
= (u8
) wrqu
->retry
.value
;
8892 priv
->short_retry_limit
= (u8
) wrqu
->retry
.value
;
8893 priv
->long_retry_limit
= (u8
) wrqu
->retry
.value
;
8896 ipw_send_retry_limit(priv
, priv
->short_retry_limit
,
8897 priv
->long_retry_limit
);
8899 IPW_DEBUG_WX("SET retry limit -> short:%d long:%d\n",
8900 priv
->short_retry_limit
, priv
->long_retry_limit
);
8904 static int ipw_wx_get_retry(struct net_device
*dev
,
8905 struct iw_request_info
*info
,
8906 union iwreq_data
*wrqu
, char *extra
)
8908 struct ipw_priv
*priv
= ieee80211_priv(dev
);
8911 wrqu
->retry
.disabled
= 0;
8913 if ((wrqu
->retry
.flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
8918 if (wrqu
->retry
.flags
& IW_RETRY_MAX
) {
8919 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
8920 wrqu
->retry
.value
= priv
->long_retry_limit
;
8921 } else if (wrqu
->retry
.flags
& IW_RETRY_MIN
) {
8922 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_MIN
;
8923 wrqu
->retry
.value
= priv
->short_retry_limit
;
8925 wrqu
->retry
.flags
= IW_RETRY_LIMIT
;
8926 wrqu
->retry
.value
= priv
->short_retry_limit
;
8930 IPW_DEBUG_WX("GET retry -> %d \n", wrqu
->retry
.value
);
8935 static int ipw_request_direct_scan(struct ipw_priv
*priv
, char *essid
,
8938 struct ipw_scan_request_ext scan
;
8939 int err
= 0, scan_type
;
8941 if (!(priv
->status
& STATUS_INIT
) ||
8942 (priv
->status
& STATUS_EXIT_PENDING
))
8947 if (priv
->status
& STATUS_RF_KILL_MASK
) {
8948 IPW_DEBUG_HC("Aborting scan due to RF kill activation\n");
8949 priv
->status
|= STATUS_SCAN_PENDING
;
8953 IPW_DEBUG_HC("starting request direct scan!\n");
8955 if (priv
->status
& (STATUS_SCANNING
| STATUS_SCAN_ABORTING
)) {
8956 /* We should not sleep here; otherwise we will block most
8957 * of the system (for instance, we hold rtnl_lock when we
8963 memset(&scan
, 0, sizeof(scan
));
8965 if (priv
->config
& CFG_SPEED_SCAN
)
8966 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_SCAN
] =
8969 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_SCAN
] =
8972 scan
.dwell_time
[IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN
] =
8974 scan
.dwell_time
[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN
] = cpu_to_le16(120);
8975 scan
.dwell_time
[IPW_SCAN_ACTIVE_DIRECT_SCAN
] = cpu_to_le16(20);
8977 scan
.full_scan_index
= cpu_to_le32(ieee80211_get_scans(priv
->ieee
));
8979 err
= ipw_send_ssid(priv
, essid
, essid_len
);
8981 IPW_DEBUG_HC("Attempt to send SSID command failed\n");
8984 scan_type
= IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN
;
8986 ipw_add_scan_channels(priv
, &scan
, scan_type
);
8988 err
= ipw_send_scan_request_ext(priv
, &scan
);
8990 IPW_DEBUG_HC("Sending scan command failed: %08X\n", err
);
8994 priv
->status
|= STATUS_SCANNING
;
9001 static int ipw_wx_set_scan(struct net_device
*dev
,
9002 struct iw_request_info
*info
,
9003 union iwreq_data
*wrqu
, char *extra
)
9005 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9006 struct iw_scan_req
*req
= NULL
;
9007 if (wrqu
->data
.length
9008 && wrqu
->data
.length
== sizeof(struct iw_scan_req
)) {
9009 req
= (struct iw_scan_req
*)extra
;
9010 if (wrqu
->data
.flags
& IW_SCAN_THIS_ESSID
) {
9011 ipw_request_direct_scan(priv
, req
->essid
,
9017 IPW_DEBUG_WX("Start scan\n");
9019 queue_work(priv
->workqueue
, &priv
->request_scan
);
9024 static int ipw_wx_get_scan(struct net_device
*dev
,
9025 struct iw_request_info
*info
,
9026 union iwreq_data
*wrqu
, char *extra
)
9028 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9029 return ieee80211_wx_get_scan(priv
->ieee
, info
, wrqu
, extra
);
9032 static int ipw_wx_set_encode(struct net_device
*dev
,
9033 struct iw_request_info
*info
,
9034 union iwreq_data
*wrqu
, char *key
)
9036 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9038 u32 cap
= priv
->capability
;
9041 ret
= ieee80211_wx_set_encode(priv
->ieee
, info
, wrqu
, key
);
9043 /* In IBSS mode, we need to notify the firmware to update
9044 * the beacon info after we changed the capability. */
9045 if (cap
!= priv
->capability
&&
9046 priv
->ieee
->iw_mode
== IW_MODE_ADHOC
&&
9047 priv
->status
& STATUS_ASSOCIATED
)
9048 ipw_disassociate(priv
);
9054 static int ipw_wx_get_encode(struct net_device
*dev
,
9055 struct iw_request_info
*info
,
9056 union iwreq_data
*wrqu
, char *key
)
9058 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9059 return ieee80211_wx_get_encode(priv
->ieee
, info
, wrqu
, key
);
9062 static int ipw_wx_set_power(struct net_device
*dev
,
9063 struct iw_request_info
*info
,
9064 union iwreq_data
*wrqu
, char *extra
)
9066 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9069 if (wrqu
->power
.disabled
) {
9070 priv
->power_mode
= IPW_POWER_LEVEL(priv
->power_mode
);
9071 err
= ipw_send_power_mode(priv
, IPW_POWER_MODE_CAM
);
9073 IPW_DEBUG_WX("failed setting power mode.\n");
9077 IPW_DEBUG_WX("SET Power Management Mode -> off\n");
9082 switch (wrqu
->power
.flags
& IW_POWER_MODE
) {
9083 case IW_POWER_ON
: /* If not specified */
9084 case IW_POWER_MODE
: /* If set all mask */
9085 case IW_POWER_ALL_R
: /* If explicitely state all */
9087 default: /* Otherwise we don't support it */
9088 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
9094 /* If the user hasn't specified a power management mode yet, default
9096 if (IPW_POWER_LEVEL(priv
->power_mode
) == IPW_POWER_AC
)
9097 priv
->power_mode
= IPW_POWER_ENABLED
| IPW_POWER_BATTERY
;
9099 priv
->power_mode
= IPW_POWER_ENABLED
| priv
->power_mode
;
9100 err
= ipw_send_power_mode(priv
, IPW_POWER_LEVEL(priv
->power_mode
));
9102 IPW_DEBUG_WX("failed setting power mode.\n");
9107 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv
->power_mode
);
9112 static int ipw_wx_get_power(struct net_device
*dev
,
9113 struct iw_request_info
*info
,
9114 union iwreq_data
*wrqu
, char *extra
)
9116 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9118 if (!(priv
->power_mode
& IPW_POWER_ENABLED
))
9119 wrqu
->power
.disabled
= 1;
9121 wrqu
->power
.disabled
= 0;
9124 IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv
->power_mode
);
9129 static int ipw_wx_set_powermode(struct net_device
*dev
,
9130 struct iw_request_info
*info
,
9131 union iwreq_data
*wrqu
, char *extra
)
9133 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9134 int mode
= *(int *)extra
;
9137 if ((mode
< 1) || (mode
> IPW_POWER_LIMIT
)) {
9138 mode
= IPW_POWER_AC
;
9139 priv
->power_mode
= mode
;
9141 priv
->power_mode
= IPW_POWER_ENABLED
| mode
;
9144 if (priv
->power_mode
!= mode
) {
9145 err
= ipw_send_power_mode(priv
, mode
);
9148 IPW_DEBUG_WX("failed setting power mode.\n");
9157 #define MAX_WX_STRING 80
9158 static int ipw_wx_get_powermode(struct net_device
*dev
,
9159 struct iw_request_info
*info
,
9160 union iwreq_data
*wrqu
, char *extra
)
9162 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9163 int level
= IPW_POWER_LEVEL(priv
->power_mode
);
9166 p
+= snprintf(p
, MAX_WX_STRING
, "Power save level: %d ", level
);
9170 p
+= snprintf(p
, MAX_WX_STRING
- (p
- extra
), "(AC)");
9172 case IPW_POWER_BATTERY
:
9173 p
+= snprintf(p
, MAX_WX_STRING
- (p
- extra
), "(BATTERY)");
9176 p
+= snprintf(p
, MAX_WX_STRING
- (p
- extra
),
9177 "(Timeout %dms, Period %dms)",
9178 timeout_duration
[level
- 1] / 1000,
9179 period_duration
[level
- 1] / 1000);
9182 if (!(priv
->power_mode
& IPW_POWER_ENABLED
))
9183 p
+= snprintf(p
, MAX_WX_STRING
- (p
- extra
), " OFF");
9185 wrqu
->data
.length
= p
- extra
+ 1;
9190 static int ipw_wx_set_wireless_mode(struct net_device
*dev
,
9191 struct iw_request_info
*info
,
9192 union iwreq_data
*wrqu
, char *extra
)
9194 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9195 int mode
= *(int *)extra
;
9196 u8 band
= 0, modulation
= 0;
9198 if (mode
== 0 || mode
& ~IEEE_MODE_MASK
) {
9199 IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode
);
9203 if (priv
->adapter
== IPW_2915ABG
) {
9204 priv
->ieee
->abg_true
= 1;
9205 if (mode
& IEEE_A
) {
9206 band
|= IEEE80211_52GHZ_BAND
;
9207 modulation
|= IEEE80211_OFDM_MODULATION
;
9209 priv
->ieee
->abg_true
= 0;
9211 if (mode
& IEEE_A
) {
9212 IPW_WARNING("Attempt to set 2200BG into "
9218 priv
->ieee
->abg_true
= 0;
9221 if (mode
& IEEE_B
) {
9222 band
|= IEEE80211_24GHZ_BAND
;
9223 modulation
|= IEEE80211_CCK_MODULATION
;
9225 priv
->ieee
->abg_true
= 0;
9227 if (mode
& IEEE_G
) {
9228 band
|= IEEE80211_24GHZ_BAND
;
9229 modulation
|= IEEE80211_OFDM_MODULATION
;
9231 priv
->ieee
->abg_true
= 0;
9233 priv
->ieee
->mode
= mode
;
9234 priv
->ieee
->freq_band
= band
;
9235 priv
->ieee
->modulation
= modulation
;
9236 init_supported_rates(priv
, &priv
->rates
);
9238 /* Network configuration changed -- force [re]association */
9239 IPW_DEBUG_ASSOC("[re]association triggered due to mode change.\n");
9240 if (!ipw_disassociate(priv
)) {
9241 ipw_send_supported_rates(priv
, &priv
->rates
);
9242 ipw_associate(priv
);
9245 /* Update the band LEDs */
9246 ipw_led_band_on(priv
);
9248 IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n",
9249 mode
& IEEE_A
? 'a' : '.',
9250 mode
& IEEE_B
? 'b' : '.', mode
& IEEE_G
? 'g' : '.');
9255 static int ipw_wx_get_wireless_mode(struct net_device
*dev
,
9256 struct iw_request_info
*info
,
9257 union iwreq_data
*wrqu
, char *extra
)
9259 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9261 switch (priv
->ieee
->mode
) {
9263 strncpy(extra
, "802.11a (1)", MAX_WX_STRING
);
9266 strncpy(extra
, "802.11b (2)", MAX_WX_STRING
);
9268 case IEEE_A
| IEEE_B
:
9269 strncpy(extra
, "802.11ab (3)", MAX_WX_STRING
);
9272 strncpy(extra
, "802.11g (4)", MAX_WX_STRING
);
9274 case IEEE_A
| IEEE_G
:
9275 strncpy(extra
, "802.11ag (5)", MAX_WX_STRING
);
9277 case IEEE_B
| IEEE_G
:
9278 strncpy(extra
, "802.11bg (6)", MAX_WX_STRING
);
9280 case IEEE_A
| IEEE_B
| IEEE_G
:
9281 strncpy(extra
, "802.11abg (7)", MAX_WX_STRING
);
9284 strncpy(extra
, "unknown", MAX_WX_STRING
);
9288 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra
);
9290 wrqu
->data
.length
= strlen(extra
) + 1;
9296 static int ipw_wx_set_preamble(struct net_device
*dev
,
9297 struct iw_request_info
*info
,
9298 union iwreq_data
*wrqu
, char *extra
)
9300 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9301 int mode
= *(int *)extra
;
9303 /* Switching from SHORT -> LONG requires a disassociation */
9305 if (!(priv
->config
& CFG_PREAMBLE_LONG
)) {
9306 priv
->config
|= CFG_PREAMBLE_LONG
;
9308 /* Network configuration changed -- force [re]association */
9310 ("[re]association triggered due to preamble change.\n");
9311 if (!ipw_disassociate(priv
))
9312 ipw_associate(priv
);
9318 priv
->config
&= ~CFG_PREAMBLE_LONG
;
9329 static int ipw_wx_get_preamble(struct net_device
*dev
,
9330 struct iw_request_info
*info
,
9331 union iwreq_data
*wrqu
, char *extra
)
9333 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9335 if (priv
->config
& CFG_PREAMBLE_LONG
)
9336 snprintf(wrqu
->name
, IFNAMSIZ
, "long (1)");
9338 snprintf(wrqu
->name
, IFNAMSIZ
, "auto (0)");
9343 #ifdef CONFIG_IPW2200_MONITOR
9344 static int ipw_wx_set_monitor(struct net_device
*dev
,
9345 struct iw_request_info
*info
,
9346 union iwreq_data
*wrqu
, char *extra
)
9348 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9349 int *parms
= (int *)extra
;
9350 int enable
= (parms
[0] > 0);
9352 IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable
, parms
[1]);
9354 if (priv
->ieee
->iw_mode
!= IW_MODE_MONITOR
) {
9355 #ifdef CONFIG_IEEE80211_RADIOTAP
9356 priv
->net_dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
9358 priv
->net_dev
->type
= ARPHRD_IEEE80211
;
9360 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
9363 ipw_set_channel(priv
, parms
[1]);
9365 if (priv
->ieee
->iw_mode
!= IW_MODE_MONITOR
) {
9369 priv
->net_dev
->type
= ARPHRD_ETHER
;
9370 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
9376 #endif // CONFIG_IPW2200_MONITOR
9378 static int ipw_wx_reset(struct net_device
*dev
,
9379 struct iw_request_info
*info
,
9380 union iwreq_data
*wrqu
, char *extra
)
9382 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9383 IPW_DEBUG_WX("RESET\n");
9384 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
9388 static int ipw_wx_sw_reset(struct net_device
*dev
,
9389 struct iw_request_info
*info
,
9390 union iwreq_data
*wrqu
, char *extra
)
9392 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9393 union iwreq_data wrqu_sec
= {
9395 .flags
= IW_ENCODE_DISABLED
,
9400 IPW_DEBUG_WX("SW_RESET\n");
9404 ret
= ipw_sw_reset(priv
, 0);
9407 ipw_adapter_restart(priv
);
9410 /* The SW reset bit might have been toggled on by the 'disable'
9411 * module parameter, so take appropriate action */
9412 ipw_radio_kill_sw(priv
, priv
->status
& STATUS_RF_KILL_SW
);
9415 ieee80211_wx_set_encode(priv
->ieee
, info
, &wrqu_sec
, NULL
);
9418 if (!(priv
->status
& STATUS_RF_KILL_MASK
)) {
9419 /* Configuration likely changed -- force [re]association */
9420 IPW_DEBUG_ASSOC("[re]association triggered due to sw "
9422 if (!ipw_disassociate(priv
))
9423 ipw_associate(priv
);
9431 /* Rebase the WE IOCTLs to zero for the handler array */
9432 #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
9433 static iw_handler ipw_wx_handlers
[] = {
9434 IW_IOCTL(SIOCGIWNAME
) = ipw_wx_get_name
,
9435 IW_IOCTL(SIOCSIWFREQ
) = ipw_wx_set_freq
,
9436 IW_IOCTL(SIOCGIWFREQ
) = ipw_wx_get_freq
,
9437 IW_IOCTL(SIOCSIWMODE
) = ipw_wx_set_mode
,
9438 IW_IOCTL(SIOCGIWMODE
) = ipw_wx_get_mode
,
9439 IW_IOCTL(SIOCGIWRANGE
) = ipw_wx_get_range
,
9440 IW_IOCTL(SIOCSIWAP
) = ipw_wx_set_wap
,
9441 IW_IOCTL(SIOCGIWAP
) = ipw_wx_get_wap
,
9442 IW_IOCTL(SIOCSIWSCAN
) = ipw_wx_set_scan
,
9443 IW_IOCTL(SIOCGIWSCAN
) = ipw_wx_get_scan
,
9444 IW_IOCTL(SIOCSIWESSID
) = ipw_wx_set_essid
,
9445 IW_IOCTL(SIOCGIWESSID
) = ipw_wx_get_essid
,
9446 IW_IOCTL(SIOCSIWNICKN
) = ipw_wx_set_nick
,
9447 IW_IOCTL(SIOCGIWNICKN
) = ipw_wx_get_nick
,
9448 IW_IOCTL(SIOCSIWRATE
) = ipw_wx_set_rate
,
9449 IW_IOCTL(SIOCGIWRATE
) = ipw_wx_get_rate
,
9450 IW_IOCTL(SIOCSIWRTS
) = ipw_wx_set_rts
,
9451 IW_IOCTL(SIOCGIWRTS
) = ipw_wx_get_rts
,
9452 IW_IOCTL(SIOCSIWFRAG
) = ipw_wx_set_frag
,
9453 IW_IOCTL(SIOCGIWFRAG
) = ipw_wx_get_frag
,
9454 IW_IOCTL(SIOCSIWTXPOW
) = ipw_wx_set_txpow
,
9455 IW_IOCTL(SIOCGIWTXPOW
) = ipw_wx_get_txpow
,
9456 IW_IOCTL(SIOCSIWRETRY
) = ipw_wx_set_retry
,
9457 IW_IOCTL(SIOCGIWRETRY
) = ipw_wx_get_retry
,
9458 IW_IOCTL(SIOCSIWENCODE
) = ipw_wx_set_encode
,
9459 IW_IOCTL(SIOCGIWENCODE
) = ipw_wx_get_encode
,
9460 IW_IOCTL(SIOCSIWPOWER
) = ipw_wx_set_power
,
9461 IW_IOCTL(SIOCGIWPOWER
) = ipw_wx_get_power
,
9462 IW_IOCTL(SIOCSIWSPY
) = iw_handler_set_spy
,
9463 IW_IOCTL(SIOCGIWSPY
) = iw_handler_get_spy
,
9464 IW_IOCTL(SIOCSIWTHRSPY
) = iw_handler_set_thrspy
,
9465 IW_IOCTL(SIOCGIWTHRSPY
) = iw_handler_get_thrspy
,
9466 IW_IOCTL(SIOCSIWGENIE
) = ipw_wx_set_genie
,
9467 IW_IOCTL(SIOCGIWGENIE
) = ipw_wx_get_genie
,
9468 IW_IOCTL(SIOCSIWMLME
) = ipw_wx_set_mlme
,
9469 IW_IOCTL(SIOCSIWAUTH
) = ipw_wx_set_auth
,
9470 IW_IOCTL(SIOCGIWAUTH
) = ipw_wx_get_auth
,
9471 IW_IOCTL(SIOCSIWENCODEEXT
) = ipw_wx_set_encodeext
,
9472 IW_IOCTL(SIOCGIWENCODEEXT
) = ipw_wx_get_encodeext
,
9476 IPW_PRIV_SET_POWER
= SIOCIWFIRSTPRIV
,
9480 IPW_PRIV_SET_PREAMBLE
,
9481 IPW_PRIV_GET_PREAMBLE
,
9484 #ifdef CONFIG_IPW2200_MONITOR
9485 IPW_PRIV_SET_MONITOR
,
9489 static struct iw_priv_args ipw_priv_args
[] = {
9491 .cmd
= IPW_PRIV_SET_POWER
,
9492 .set_args
= IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
9493 .name
= "set_power"},
9495 .cmd
= IPW_PRIV_GET_POWER
,
9496 .get_args
= IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| MAX_WX_STRING
,
9497 .name
= "get_power"},
9499 .cmd
= IPW_PRIV_SET_MODE
,
9500 .set_args
= IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
9501 .name
= "set_mode"},
9503 .cmd
= IPW_PRIV_GET_MODE
,
9504 .get_args
= IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| MAX_WX_STRING
,
9505 .name
= "get_mode"},
9507 .cmd
= IPW_PRIV_SET_PREAMBLE
,
9508 .set_args
= IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
9509 .name
= "set_preamble"},
9511 .cmd
= IPW_PRIV_GET_PREAMBLE
,
9512 .get_args
= IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| IFNAMSIZ
,
9513 .name
= "get_preamble"},
9516 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 0, 0, "reset"},
9519 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 0, 0, "sw_reset"},
9520 #ifdef CONFIG_IPW2200_MONITOR
9522 IPW_PRIV_SET_MONITOR
,
9523 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "monitor"},
9524 #endif /* CONFIG_IPW2200_MONITOR */
9527 static iw_handler ipw_priv_handler
[] = {
9528 ipw_wx_set_powermode
,
9529 ipw_wx_get_powermode
,
9530 ipw_wx_set_wireless_mode
,
9531 ipw_wx_get_wireless_mode
,
9532 ipw_wx_set_preamble
,
9533 ipw_wx_get_preamble
,
9536 #ifdef CONFIG_IPW2200_MONITOR
9541 static struct iw_handler_def ipw_wx_handler_def
= {
9542 .standard
= ipw_wx_handlers
,
9543 .num_standard
= ARRAY_SIZE(ipw_wx_handlers
),
9544 .num_private
= ARRAY_SIZE(ipw_priv_handler
),
9545 .num_private_args
= ARRAY_SIZE(ipw_priv_args
),
9546 .private = ipw_priv_handler
,
9547 .private_args
= ipw_priv_args
,
9548 .get_wireless_stats
= ipw_get_wireless_stats
,
9552 * Get wireless statistics.
9553 * Called by /proc/net/wireless
9554 * Also called by SIOCGIWSTATS
9556 static struct iw_statistics
*ipw_get_wireless_stats(struct net_device
*dev
)
9558 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9559 struct iw_statistics
*wstats
;
9561 wstats
= &priv
->wstats
;
9563 /* if hw is disabled, then ipw_get_ordinal() can't be called.
9564 * netdev->get_wireless_stats seems to be called before fw is
9565 * initialized. STATUS_ASSOCIATED will only be set if the hw is up
9566 * and associated; if not associcated, the values are all meaningless
9567 * anyway, so set them all to NULL and INVALID */
9568 if (!(priv
->status
& STATUS_ASSOCIATED
)) {
9569 wstats
->miss
.beacon
= 0;
9570 wstats
->discard
.retries
= 0;
9571 wstats
->qual
.qual
= 0;
9572 wstats
->qual
.level
= 0;
9573 wstats
->qual
.noise
= 0;
9574 wstats
->qual
.updated
= 7;
9575 wstats
->qual
.updated
|= IW_QUAL_NOISE_INVALID
|
9576 IW_QUAL_QUAL_INVALID
| IW_QUAL_LEVEL_INVALID
;
9580 wstats
->qual
.qual
= priv
->quality
;
9581 wstats
->qual
.level
= average_value(&priv
->average_rssi
);
9582 wstats
->qual
.noise
= average_value(&priv
->average_noise
);
9583 wstats
->qual
.updated
= IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED
|
9584 IW_QUAL_NOISE_UPDATED
;
9586 wstats
->miss
.beacon
= average_value(&priv
->average_missed_beacons
);
9587 wstats
->discard
.retries
= priv
->last_tx_failures
;
9588 wstats
->discard
.code
= priv
->ieee
->ieee_stats
.rx_discards_undecryptable
;
9590 /* if (ipw_get_ordinal(priv, IPW_ORD_STAT_TX_RETRY, &tx_retry, &len))
9591 goto fail_get_ordinal;
9592 wstats->discard.retries += tx_retry; */
9597 /* net device stuff */
9599 static void init_sys_config(struct ipw_sys_config
*sys_config
)
9601 memset(sys_config
, 0, sizeof(struct ipw_sys_config
));
9602 sys_config
->bt_coexistence
= 0;
9603 sys_config
->answer_broadcast_ssid_probe
= 0;
9604 sys_config
->accept_all_data_frames
= 0;
9605 sys_config
->accept_non_directed_frames
= 1;
9606 sys_config
->exclude_unicast_unencrypted
= 0;
9607 sys_config
->disable_unicast_decryption
= 1;
9608 sys_config
->exclude_multicast_unencrypted
= 0;
9609 sys_config
->disable_multicast_decryption
= 1;
9610 sys_config
->antenna_diversity
= CFG_SYS_ANTENNA_BOTH
;
9611 sys_config
->pass_crc_to_host
= 0; /* TODO: See if 1 gives us FCS */
9612 sys_config
->dot11g_auto_detection
= 0;
9613 sys_config
->enable_cts_to_self
= 0;
9614 sys_config
->bt_coexist_collision_thr
= 0;
9615 sys_config
->pass_noise_stats_to_host
= 1; //1 -- fix for 256
9618 static int ipw_net_open(struct net_device
*dev
)
9620 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9621 IPW_DEBUG_INFO("dev->open\n");
9622 /* we should be verifying the device is ready to be opened */
9624 if (!(priv
->status
& STATUS_RF_KILL_MASK
) &&
9625 (priv
->status
& STATUS_ASSOCIATED
))
9626 netif_start_queue(dev
);
9631 static int ipw_net_stop(struct net_device
*dev
)
9633 IPW_DEBUG_INFO("dev->close\n");
9634 netif_stop_queue(dev
);
9641 modify to send one tfd per fragment instead of using chunking. otherwise
9642 we need to heavily modify the ieee80211_skb_to_txb.
9645 static int ipw_tx_skb(struct ipw_priv
*priv
, struct ieee80211_txb
*txb
,
9648 struct ieee80211_hdr_3addr
*hdr
= (struct ieee80211_hdr_3addr
*)
9649 txb
->fragments
[0]->data
;
9651 struct tfd_frame
*tfd
;
9652 #ifdef CONFIG_IPW_QOS
9653 int tx_id
= ipw_get_tx_queue_number(priv
, pri
);
9654 struct clx2_tx_queue
*txq
= &priv
->txq
[tx_id
];
9656 struct clx2_tx_queue
*txq
= &priv
->txq
[0];
9658 struct clx2_queue
*q
= &txq
->q
;
9659 u8 id
, hdr_len
, unicast
;
9660 u16 remaining_bytes
;
9663 /* If there isn't room in the queue, we return busy and let the
9664 * network stack requeue the packet for us */
9665 if (ipw_queue_space(q
) < q
->high_mark
)
9666 return NETDEV_TX_BUSY
;
9668 switch (priv
->ieee
->iw_mode
) {
9670 hdr_len
= IEEE80211_3ADDR_LEN
;
9671 unicast
= !is_multicast_ether_addr(hdr
->addr1
);
9672 id
= ipw_find_station(priv
, hdr
->addr1
);
9673 if (id
== IPW_INVALID_STATION
) {
9674 id
= ipw_add_station(priv
, hdr
->addr1
);
9675 if (id
== IPW_INVALID_STATION
) {
9676 IPW_WARNING("Attempt to send data to "
9677 "invalid cell: " MAC_FMT
"\n",
9678 MAC_ARG(hdr
->addr1
));
9686 unicast
= !is_multicast_ether_addr(hdr
->addr3
);
9687 hdr_len
= IEEE80211_3ADDR_LEN
;
9692 tfd
= &txq
->bd
[q
->first_empty
];
9693 txq
->txb
[q
->first_empty
] = txb
;
9694 memset(tfd
, 0, sizeof(*tfd
));
9695 tfd
->u
.data
.station_number
= id
;
9697 tfd
->control_flags
.message_type
= TX_FRAME_TYPE
;
9698 tfd
->control_flags
.control_bits
= TFD_NEED_IRQ_MASK
;
9700 tfd
->u
.data
.cmd_id
= DINO_CMD_TX
;
9701 tfd
->u
.data
.len
= cpu_to_le16(txb
->payload_size
);
9702 remaining_bytes
= txb
->payload_size
;
9704 if (priv
->assoc_request
.ieee_mode
== IPW_B_MODE
)
9705 tfd
->u
.data
.tx_flags_ext
|= DCT_FLAG_EXT_MODE_CCK
;
9707 tfd
->u
.data
.tx_flags_ext
|= DCT_FLAG_EXT_MODE_OFDM
;
9709 if (priv
->assoc_request
.preamble_length
== DCT_FLAG_SHORT_PREAMBLE
)
9710 tfd
->u
.data
.tx_flags
|= DCT_FLAG_SHORT_PREAMBLE
;
9712 fc
= le16_to_cpu(hdr
->frame_ctl
);
9713 hdr
->frame_ctl
= cpu_to_le16(fc
& ~IEEE80211_FCTL_MOREFRAGS
);
9715 memcpy(&tfd
->u
.data
.tfd
.tfd_24
.mchdr
, hdr
, hdr_len
);
9717 if (likely(unicast
))
9718 tfd
->u
.data
.tx_flags
|= DCT_FLAG_ACK_REQD
;
9720 if (txb
->encrypted
&& !priv
->ieee
->host_encrypt
) {
9721 switch (priv
->ieee
->sec
.level
) {
9723 tfd
->u
.data
.tfd
.tfd_24
.mchdr
.frame_ctl
|=
9724 IEEE80211_FCTL_PROTECTED
;
9725 /* XXX: ACK flag must be set for CCMP even if it
9726 * is a multicast/broadcast packet, because CCMP
9727 * group communication encrypted by GTK is
9728 * actually done by the AP. */
9730 tfd
->u
.data
.tx_flags
|= DCT_FLAG_ACK_REQD
;
9732 tfd
->u
.data
.tx_flags
&= ~DCT_FLAG_NO_WEP
;
9733 tfd
->u
.data
.tx_flags_ext
|= DCT_FLAG_EXT_SECURITY_CCM
;
9734 tfd
->u
.data
.key_index
= 0;
9735 tfd
->u
.data
.key_index
|= DCT_WEP_INDEX_USE_IMMEDIATE
;
9738 tfd
->u
.data
.tfd
.tfd_24
.mchdr
.frame_ctl
|=
9739 IEEE80211_FCTL_PROTECTED
;
9740 tfd
->u
.data
.tx_flags
&= ~DCT_FLAG_NO_WEP
;
9741 tfd
->u
.data
.tx_flags_ext
|= DCT_FLAG_EXT_SECURITY_TKIP
;
9742 tfd
->u
.data
.key_index
= DCT_WEP_INDEX_USE_IMMEDIATE
;
9745 tfd
->u
.data
.tfd
.tfd_24
.mchdr
.frame_ctl
|=
9746 IEEE80211_FCTL_PROTECTED
;
9747 tfd
->u
.data
.key_index
= priv
->ieee
->tx_keyidx
;
9748 if (priv
->ieee
->sec
.key_sizes
[priv
->ieee
->tx_keyidx
] <=
9750 tfd
->u
.data
.key_index
|= DCT_WEP_KEY_64Bit
;
9752 tfd
->u
.data
.key_index
|= DCT_WEP_KEY_128Bit
;
9757 printk(KERN_ERR
"Unknow security level %d\n",
9758 priv
->ieee
->sec
.level
);
9762 /* No hardware encryption */
9763 tfd
->u
.data
.tx_flags
|= DCT_FLAG_NO_WEP
;
9765 #ifdef CONFIG_IPW_QOS
9766 ipw_qos_set_tx_queue_command(priv
, pri
, &(tfd
->u
.data
), unicast
);
9767 #endif /* CONFIG_IPW_QOS */
9770 tfd
->u
.data
.num_chunks
= cpu_to_le32(min((u8
) (NUM_TFD_CHUNKS
- 2),
9772 IPW_DEBUG_FRAG("%i fragments being sent as %i chunks.\n",
9773 txb
->nr_frags
, le32_to_cpu(tfd
->u
.data
.num_chunks
));
9774 for (i
= 0; i
< le32_to_cpu(tfd
->u
.data
.num_chunks
); i
++) {
9775 IPW_DEBUG_FRAG("Adding fragment %i of %i (%d bytes).\n",
9776 i
, le32_to_cpu(tfd
->u
.data
.num_chunks
),
9777 txb
->fragments
[i
]->len
- hdr_len
);
9778 IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n",
9779 i
, tfd
->u
.data
.num_chunks
,
9780 txb
->fragments
[i
]->len
- hdr_len
);
9781 printk_buf(IPW_DL_TX
, txb
->fragments
[i
]->data
+ hdr_len
,
9782 txb
->fragments
[i
]->len
- hdr_len
);
9784 tfd
->u
.data
.chunk_ptr
[i
] =
9785 cpu_to_le32(pci_map_single
9787 txb
->fragments
[i
]->data
+ hdr_len
,
9788 txb
->fragments
[i
]->len
- hdr_len
,
9790 tfd
->u
.data
.chunk_len
[i
] =
9791 cpu_to_le16(txb
->fragments
[i
]->len
- hdr_len
);
9794 if (i
!= txb
->nr_frags
) {
9795 struct sk_buff
*skb
;
9796 u16 remaining_bytes
= 0;
9799 for (j
= i
; j
< txb
->nr_frags
; j
++)
9800 remaining_bytes
+= txb
->fragments
[j
]->len
- hdr_len
;
9802 printk(KERN_INFO
"Trying to reallocate for %d bytes\n",
9804 skb
= alloc_skb(remaining_bytes
, GFP_ATOMIC
);
9806 tfd
->u
.data
.chunk_len
[i
] = cpu_to_le16(remaining_bytes
);
9807 for (j
= i
; j
< txb
->nr_frags
; j
++) {
9808 int size
= txb
->fragments
[j
]->len
- hdr_len
;
9810 printk(KERN_INFO
"Adding frag %d %d...\n",
9812 memcpy(skb_put(skb
, size
),
9813 txb
->fragments
[j
]->data
+ hdr_len
, size
);
9815 dev_kfree_skb_any(txb
->fragments
[i
]);
9816 txb
->fragments
[i
] = skb
;
9817 tfd
->u
.data
.chunk_ptr
[i
] =
9818 cpu_to_le32(pci_map_single
9819 (priv
->pci_dev
, skb
->data
,
9820 tfd
->u
.data
.chunk_len
[i
],
9823 tfd
->u
.data
.num_chunks
=
9824 cpu_to_le32(le32_to_cpu(tfd
->u
.data
.num_chunks
) +
9830 q
->first_empty
= ipw_queue_inc_wrap(q
->first_empty
, q
->n_bd
);
9831 ipw_write32(priv
, q
->reg_w
, q
->first_empty
);
9833 return NETDEV_TX_OK
;
9836 IPW_DEBUG_DROP("Silently dropping Tx packet.\n");
9837 ieee80211_txb_free(txb
);
9838 return NETDEV_TX_OK
;
9841 static int ipw_net_is_queue_full(struct net_device
*dev
, int pri
)
9843 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9844 #ifdef CONFIG_IPW_QOS
9845 int tx_id
= ipw_get_tx_queue_number(priv
, pri
);
9846 struct clx2_tx_queue
*txq
= &priv
->txq
[tx_id
];
9848 struct clx2_tx_queue
*txq
= &priv
->txq
[0];
9849 #endif /* CONFIG_IPW_QOS */
9851 if (ipw_queue_space(&txq
->q
) < txq
->q
.high_mark
)
9857 static int ipw_net_hard_start_xmit(struct ieee80211_txb
*txb
,
9858 struct net_device
*dev
, int pri
)
9860 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9861 unsigned long flags
;
9864 IPW_DEBUG_TX("dev->xmit(%d bytes)\n", txb
->payload_size
);
9865 spin_lock_irqsave(&priv
->lock
, flags
);
9867 if (!(priv
->status
& STATUS_ASSOCIATED
)) {
9868 IPW_DEBUG_INFO("Tx attempt while not associated.\n");
9869 priv
->ieee
->stats
.tx_carrier_errors
++;
9870 netif_stop_queue(dev
);
9874 ret
= ipw_tx_skb(priv
, txb
, pri
);
9875 if (ret
== NETDEV_TX_OK
)
9876 __ipw_led_activity_on(priv
);
9877 spin_unlock_irqrestore(&priv
->lock
, flags
);
9882 spin_unlock_irqrestore(&priv
->lock
, flags
);
9886 static struct net_device_stats
*ipw_net_get_stats(struct net_device
*dev
)
9888 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9890 priv
->ieee
->stats
.tx_packets
= priv
->tx_packets
;
9891 priv
->ieee
->stats
.rx_packets
= priv
->rx_packets
;
9892 return &priv
->ieee
->stats
;
9895 static void ipw_net_set_multicast_list(struct net_device
*dev
)
9900 static int ipw_net_set_mac_address(struct net_device
*dev
, void *p
)
9902 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9903 struct sockaddr
*addr
= p
;
9904 if (!is_valid_ether_addr(addr
->sa_data
))
9905 return -EADDRNOTAVAIL
;
9907 priv
->config
|= CFG_CUSTOM_MAC
;
9908 memcpy(priv
->mac_addr
, addr
->sa_data
, ETH_ALEN
);
9909 printk(KERN_INFO
"%s: Setting MAC to " MAC_FMT
"\n",
9910 priv
->net_dev
->name
, MAC_ARG(priv
->mac_addr
));
9911 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
9916 static void ipw_ethtool_get_drvinfo(struct net_device
*dev
,
9917 struct ethtool_drvinfo
*info
)
9919 struct ipw_priv
*p
= ieee80211_priv(dev
);
9924 strcpy(info
->driver
, DRV_NAME
);
9925 strcpy(info
->version
, DRV_VERSION
);
9928 ipw_get_ordinal(p
, IPW_ORD_STAT_FW_VERSION
, vers
, &len
);
9930 ipw_get_ordinal(p
, IPW_ORD_STAT_FW_DATE
, date
, &len
);
9932 snprintf(info
->fw_version
, sizeof(info
->fw_version
), "%s (%s)",
9934 strcpy(info
->bus_info
, pci_name(p
->pci_dev
));
9935 info
->eedump_len
= IPW_EEPROM_IMAGE_SIZE
;
9938 static u32
ipw_ethtool_get_link(struct net_device
*dev
)
9940 struct ipw_priv
*priv
= ieee80211_priv(dev
);
9941 return (priv
->status
& STATUS_ASSOCIATED
) != 0;
9944 static int ipw_ethtool_get_eeprom_len(struct net_device
*dev
)
9946 return IPW_EEPROM_IMAGE_SIZE
;
9949 static int ipw_ethtool_get_eeprom(struct net_device
*dev
,
9950 struct ethtool_eeprom
*eeprom
, u8
* bytes
)
9952 struct ipw_priv
*p
= ieee80211_priv(dev
);
9954 if (eeprom
->offset
+ eeprom
->len
> IPW_EEPROM_IMAGE_SIZE
)
9957 memcpy(bytes
, &p
->eeprom
[eeprom
->offset
], eeprom
->len
);
9962 static int ipw_ethtool_set_eeprom(struct net_device
*dev
,
9963 struct ethtool_eeprom
*eeprom
, u8
* bytes
)
9965 struct ipw_priv
*p
= ieee80211_priv(dev
);
9968 if (eeprom
->offset
+ eeprom
->len
> IPW_EEPROM_IMAGE_SIZE
)
9971 memcpy(&p
->eeprom
[eeprom
->offset
], bytes
, eeprom
->len
);
9972 for (i
= IPW_EEPROM_DATA
;
9973 i
< IPW_EEPROM_DATA
+ IPW_EEPROM_IMAGE_SIZE
; i
++)
9974 ipw_write8(p
, i
, p
->eeprom
[i
]);
9979 static struct ethtool_ops ipw_ethtool_ops
= {
9980 .get_link
= ipw_ethtool_get_link
,
9981 .get_drvinfo
= ipw_ethtool_get_drvinfo
,
9982 .get_eeprom_len
= ipw_ethtool_get_eeprom_len
,
9983 .get_eeprom
= ipw_ethtool_get_eeprom
,
9984 .set_eeprom
= ipw_ethtool_set_eeprom
,
9987 static irqreturn_t
ipw_isr(int irq
, void *data
, struct pt_regs
*regs
)
9989 struct ipw_priv
*priv
= data
;
9990 u32 inta
, inta_mask
;
9995 spin_lock(&priv
->lock
);
9997 if (!(priv
->status
& STATUS_INT_ENABLED
)) {
10002 inta
= ipw_read32(priv
, IPW_INTA_RW
);
10003 inta_mask
= ipw_read32(priv
, IPW_INTA_MASK_R
);
10005 if (inta
== 0xFFFFFFFF) {
10006 /* Hardware disappeared */
10007 IPW_WARNING("IRQ INTA == 0xFFFFFFFF\n");
10011 if (!(inta
& (IPW_INTA_MASK_ALL
& inta_mask
))) {
10012 /* Shared interrupt */
10016 /* tell the device to stop sending interrupts */
10017 ipw_disable_interrupts(priv
);
10019 /* ack current interrupts */
10020 inta
&= (IPW_INTA_MASK_ALL
& inta_mask
);
10021 ipw_write32(priv
, IPW_INTA_RW
, inta
);
10023 /* Cache INTA value for our tasklet */
10024 priv
->isr_inta
= inta
;
10026 tasklet_schedule(&priv
->irq_tasklet
);
10028 spin_unlock(&priv
->lock
);
10030 return IRQ_HANDLED
;
10032 spin_unlock(&priv
->lock
);
10036 static void ipw_rf_kill(void *adapter
)
10038 struct ipw_priv
*priv
= adapter
;
10039 unsigned long flags
;
10041 spin_lock_irqsave(&priv
->lock
, flags
);
10043 if (rf_kill_active(priv
)) {
10044 IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n");
10045 if (priv
->workqueue
)
10046 queue_delayed_work(priv
->workqueue
,
10047 &priv
->rf_kill
, 2 * HZ
);
10051 /* RF Kill is now disabled, so bring the device back up */
10053 if (!(priv
->status
& STATUS_RF_KILL_MASK
)) {
10054 IPW_DEBUG_RF_KILL("HW RF Kill no longer active, restarting "
10057 /* we can not do an adapter restart while inside an irq lock */
10058 queue_work(priv
->workqueue
, &priv
->adapter_restart
);
10060 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still "
10064 spin_unlock_irqrestore(&priv
->lock
, flags
);
10067 static void ipw_bg_rf_kill(void *data
)
10069 struct ipw_priv
*priv
= data
;
10075 static void ipw_link_up(struct ipw_priv
*priv
)
10077 priv
->last_seq_num
= -1;
10078 priv
->last_frag_num
= -1;
10079 priv
->last_packet_time
= 0;
10081 netif_carrier_on(priv
->net_dev
);
10082 if (netif_queue_stopped(priv
->net_dev
)) {
10083 IPW_DEBUG_NOTIF("waking queue\n");
10084 netif_wake_queue(priv
->net_dev
);
10086 IPW_DEBUG_NOTIF("starting queue\n");
10087 netif_start_queue(priv
->net_dev
);
10090 cancel_delayed_work(&priv
->request_scan
);
10091 ipw_reset_stats(priv
);
10092 /* Ensure the rate is updated immediately */
10093 priv
->last_rate
= ipw_get_current_rate(priv
);
10094 ipw_gather_stats(priv
);
10095 ipw_led_link_up(priv
);
10096 notify_wx_assoc_event(priv
);
10098 if (priv
->config
& CFG_BACKGROUND_SCAN
)
10099 queue_delayed_work(priv
->workqueue
, &priv
->request_scan
, HZ
);
10102 static void ipw_bg_link_up(void *data
)
10104 struct ipw_priv
*priv
= data
;
10110 static void ipw_link_down(struct ipw_priv
*priv
)
10112 ipw_led_link_down(priv
);
10113 netif_carrier_off(priv
->net_dev
);
10114 netif_stop_queue(priv
->net_dev
);
10115 notify_wx_assoc_event(priv
);
10117 /* Cancel any queued work ... */
10118 cancel_delayed_work(&priv
->request_scan
);
10119 cancel_delayed_work(&priv
->adhoc_check
);
10120 cancel_delayed_work(&priv
->gather_stats
);
10122 ipw_reset_stats(priv
);
10124 if (!(priv
->status
& STATUS_EXIT_PENDING
)) {
10125 /* Queue up another scan... */
10126 queue_work(priv
->workqueue
, &priv
->request_scan
);
10130 static void ipw_bg_link_down(void *data
)
10132 struct ipw_priv
*priv
= data
;
10134 ipw_link_down(data
);
10138 static int ipw_setup_deferred_work(struct ipw_priv
*priv
)
10142 priv
->workqueue
= create_workqueue(DRV_NAME
);
10143 init_waitqueue_head(&priv
->wait_command_queue
);
10144 init_waitqueue_head(&priv
->wait_state
);
10146 INIT_WORK(&priv
->adhoc_check
, ipw_bg_adhoc_check
, priv
);
10147 INIT_WORK(&priv
->associate
, ipw_bg_associate
, priv
);
10148 INIT_WORK(&priv
->disassociate
, ipw_bg_disassociate
, priv
);
10149 INIT_WORK(&priv
->system_config
, ipw_system_config
, priv
);
10150 INIT_WORK(&priv
->rx_replenish
, ipw_bg_rx_queue_replenish
, priv
);
10151 INIT_WORK(&priv
->adapter_restart
, ipw_bg_adapter_restart
, priv
);
10152 INIT_WORK(&priv
->rf_kill
, ipw_bg_rf_kill
, priv
);
10153 INIT_WORK(&priv
->up
, (void (*)(void *))ipw_bg_up
, priv
);
10154 INIT_WORK(&priv
->down
, (void (*)(void *))ipw_bg_down
, priv
);
10155 INIT_WORK(&priv
->request_scan
,
10156 (void (*)(void *))ipw_request_scan
, priv
);
10157 INIT_WORK(&priv
->gather_stats
,
10158 (void (*)(void *))ipw_bg_gather_stats
, priv
);
10159 INIT_WORK(&priv
->abort_scan
, (void (*)(void *))ipw_bg_abort_scan
, priv
);
10160 INIT_WORK(&priv
->roam
, ipw_bg_roam
, priv
);
10161 INIT_WORK(&priv
->scan_check
, ipw_bg_scan_check
, priv
);
10162 INIT_WORK(&priv
->link_up
, (void (*)(void *))ipw_bg_link_up
, priv
);
10163 INIT_WORK(&priv
->link_down
, (void (*)(void *))ipw_bg_link_down
, priv
);
10164 INIT_WORK(&priv
->led_link_on
, (void (*)(void *))ipw_bg_led_link_on
,
10166 INIT_WORK(&priv
->led_link_off
, (void (*)(void *))ipw_bg_led_link_off
,
10168 INIT_WORK(&priv
->led_act_off
, (void (*)(void *))ipw_bg_led_activity_off
,
10170 INIT_WORK(&priv
->merge_networks
,
10171 (void (*)(void *))ipw_merge_adhoc_network
, priv
);
10173 #ifdef CONFIG_IPW_QOS
10174 INIT_WORK(&priv
->qos_activate
, (void (*)(void *))ipw_bg_qos_activate
,
10176 #endif /* CONFIG_IPW_QOS */
10178 tasklet_init(&priv
->irq_tasklet
, (void (*)(unsigned long))
10179 ipw_irq_tasklet
, (unsigned long)priv
);
10184 static void shim__set_security(struct net_device
*dev
,
10185 struct ieee80211_security
*sec
)
10187 struct ipw_priv
*priv
= ieee80211_priv(dev
);
10189 for (i
= 0; i
< 4; i
++) {
10190 if (sec
->flags
& (1 << i
)) {
10191 priv
->ieee
->sec
.encode_alg
[i
] = sec
->encode_alg
[i
];
10192 priv
->ieee
->sec
.key_sizes
[i
] = sec
->key_sizes
[i
];
10193 if (sec
->key_sizes
[i
] == 0)
10194 priv
->ieee
->sec
.flags
&= ~(1 << i
);
10196 memcpy(priv
->ieee
->sec
.keys
[i
], sec
->keys
[i
],
10197 sec
->key_sizes
[i
]);
10198 priv
->ieee
->sec
.flags
|= (1 << i
);
10200 priv
->status
|= STATUS_SECURITY_UPDATED
;
10201 } else if (sec
->level
!= SEC_LEVEL_1
)
10202 priv
->ieee
->sec
.flags
&= ~(1 << i
);
10205 if (sec
->flags
& SEC_ACTIVE_KEY
) {
10206 if (sec
->active_key
<= 3) {
10207 priv
->ieee
->sec
.active_key
= sec
->active_key
;
10208 priv
->ieee
->sec
.flags
|= SEC_ACTIVE_KEY
;
10210 priv
->ieee
->sec
.flags
&= ~SEC_ACTIVE_KEY
;
10211 priv
->status
|= STATUS_SECURITY_UPDATED
;
10213 priv
->ieee
->sec
.flags
&= ~SEC_ACTIVE_KEY
;
10215 if ((sec
->flags
& SEC_AUTH_MODE
) &&
10216 (priv
->ieee
->sec
.auth_mode
!= sec
->auth_mode
)) {
10217 priv
->ieee
->sec
.auth_mode
= sec
->auth_mode
;
10218 priv
->ieee
->sec
.flags
|= SEC_AUTH_MODE
;
10219 if (sec
->auth_mode
== WLAN_AUTH_SHARED_KEY
)
10220 priv
->capability
|= CAP_SHARED_KEY
;
10222 priv
->capability
&= ~CAP_SHARED_KEY
;
10223 priv
->status
|= STATUS_SECURITY_UPDATED
;
10226 if (sec
->flags
& SEC_ENABLED
&& priv
->ieee
->sec
.enabled
!= sec
->enabled
) {
10227 priv
->ieee
->sec
.flags
|= SEC_ENABLED
;
10228 priv
->ieee
->sec
.enabled
= sec
->enabled
;
10229 priv
->status
|= STATUS_SECURITY_UPDATED
;
10231 priv
->capability
|= CAP_PRIVACY_ON
;
10233 priv
->capability
&= ~CAP_PRIVACY_ON
;
10236 if (sec
->flags
& SEC_ENCRYPT
)
10237 priv
->ieee
->sec
.encrypt
= sec
->encrypt
;
10239 if (sec
->flags
& SEC_LEVEL
&& priv
->ieee
->sec
.level
!= sec
->level
) {
10240 priv
->ieee
->sec
.level
= sec
->level
;
10241 priv
->ieee
->sec
.flags
|= SEC_LEVEL
;
10242 priv
->status
|= STATUS_SECURITY_UPDATED
;
10245 if (!priv
->ieee
->host_encrypt
&& (sec
->flags
& SEC_ENCRYPT
))
10246 ipw_set_hwcrypto_keys(priv
);
10248 /* To match current functionality of ipw2100 (which works well w/
10249 * various supplicants, we don't force a disassociate if the
10250 * privacy capability changes ... */
10252 if ((priv
->status
& (STATUS_ASSOCIATED
| STATUS_ASSOCIATING
)) &&
10253 (((priv
->assoc_request
.capability
&
10254 WLAN_CAPABILITY_PRIVACY
) && !sec
->enabled
) ||
10255 (!(priv
->assoc_request
.capability
&
10256 WLAN_CAPABILITY_PRIVACY
) && sec
->enabled
))) {
10257 IPW_DEBUG_ASSOC("Disassociating due to capability "
10259 ipw_disassociate(priv
);
10264 static int init_supported_rates(struct ipw_priv
*priv
,
10265 struct ipw_supported_rates
*rates
)
10267 /* TODO: Mask out rates based on priv->rates_mask */
10269 memset(rates
, 0, sizeof(*rates
));
10270 /* configure supported rates */
10271 switch (priv
->ieee
->freq_band
) {
10272 case IEEE80211_52GHZ_BAND
:
10273 rates
->ieee_mode
= IPW_A_MODE
;
10274 rates
->purpose
= IPW_RATE_CAPABILITIES
;
10275 ipw_add_ofdm_scan_rates(rates
, IEEE80211_CCK_MODULATION
,
10276 IEEE80211_OFDM_DEFAULT_RATES_MASK
);
10279 default: /* Mixed or 2.4Ghz */
10280 rates
->ieee_mode
= IPW_G_MODE
;
10281 rates
->purpose
= IPW_RATE_CAPABILITIES
;
10282 ipw_add_cck_scan_rates(rates
, IEEE80211_CCK_MODULATION
,
10283 IEEE80211_CCK_DEFAULT_RATES_MASK
);
10284 if (priv
->ieee
->modulation
& IEEE80211_OFDM_MODULATION
) {
10285 ipw_add_ofdm_scan_rates(rates
, IEEE80211_CCK_MODULATION
,
10286 IEEE80211_OFDM_DEFAULT_RATES_MASK
);
10294 static int ipw_config(struct ipw_priv
*priv
)
10296 /* This is only called from ipw_up, which resets/reloads the firmware
10297 so, we don't need to first disable the card before we configure
10299 if (ipw_set_tx_power(priv
))
10302 /* initialize adapter address */
10303 if (ipw_send_adapter_address(priv
, priv
->net_dev
->dev_addr
))
10306 /* set basic system config settings */
10307 init_sys_config(&priv
->sys_config
);
10309 /* Support Bluetooth if we have BT h/w on board, and user wants to.
10310 * Does not support BT priority yet (don't abort or defer our Tx) */
10312 unsigned char bt_caps
= priv
->eeprom
[EEPROM_SKU_CAPABILITY
];
10314 if (bt_caps
& EEPROM_SKU_CAP_BT_CHANNEL_SIG
)
10315 priv
->sys_config
.bt_coexistence
10316 |= CFG_BT_COEXISTENCE_SIGNAL_CHNL
;
10317 if (bt_caps
& EEPROM_SKU_CAP_BT_OOB
)
10318 priv
->sys_config
.bt_coexistence
10319 |= CFG_BT_COEXISTENCE_OOB
;
10322 if (priv
->ieee
->iw_mode
== IW_MODE_ADHOC
)
10323 priv
->sys_config
.answer_broadcast_ssid_probe
= 1;
10325 priv
->sys_config
.answer_broadcast_ssid_probe
= 0;
10327 if (ipw_send_system_config(priv
, &priv
->sys_config
))
10330 init_supported_rates(priv
, &priv
->rates
);
10331 if (ipw_send_supported_rates(priv
, &priv
->rates
))
10334 /* Set request-to-send threshold */
10335 if (priv
->rts_threshold
) {
10336 if (ipw_send_rts_threshold(priv
, priv
->rts_threshold
))
10339 #ifdef CONFIG_IPW_QOS
10340 IPW_DEBUG_QOS("QoS: call ipw_qos_activate\n");
10341 ipw_qos_activate(priv
, NULL
);
10342 #endif /* CONFIG_IPW_QOS */
10344 if (ipw_set_random_seed(priv
))
10347 /* final state transition to the RUN state */
10348 if (ipw_send_host_complete(priv
))
10351 priv
->status
|= STATUS_INIT
;
10353 ipw_led_init(priv
);
10354 ipw_led_radio_on(priv
);
10355 priv
->notif_missed_beacons
= 0;
10357 /* Set hardware WEP key if it is configured. */
10358 if ((priv
->capability
& CAP_PRIVACY_ON
) &&
10359 (priv
->ieee
->sec
.level
== SEC_LEVEL_1
) &&
10360 !(priv
->ieee
->host_encrypt
|| priv
->ieee
->host_decrypt
))
10361 ipw_set_hwcrypto_keys(priv
);
10372 * These tables have been tested in conjunction with the
10373 * Intel PRO/Wireless 2200BG and 2915ABG Network Connection Adapters.
10375 * Altering this values, using it on other hardware, or in geographies
10376 * not intended for resale of the above mentioned Intel adapters has
10380 static const struct ieee80211_geo ipw_geos
[] = {
10384 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10385 {2427, 4}, {2432, 5}, {2437, 6},
10386 {2442, 7}, {2447, 8}, {2452, 9},
10387 {2457, 10}, {2462, 11}},
10390 { /* Custom US/Canada */
10393 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10394 {2427, 4}, {2432, 5}, {2437, 6},
10395 {2442, 7}, {2447, 8}, {2452, 9},
10396 {2457, 10}, {2462, 11}},
10402 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10403 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10404 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10405 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
}},
10408 { /* Rest of World */
10411 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10412 {2427, 4}, {2432, 5}, {2437, 6},
10413 {2442, 7}, {2447, 8}, {2452, 9},
10414 {2457, 10}, {2462, 11}, {2467, 12},
10418 { /* Custom USA & Europe & High */
10421 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10422 {2427, 4}, {2432, 5}, {2437, 6},
10423 {2442, 7}, {2447, 8}, {2452, 9},
10424 {2457, 10}, {2462, 11}},
10430 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10431 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10432 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10433 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
},
10441 { /* Custom NA & Europe */
10444 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10445 {2427, 4}, {2432, 5}, {2437, 6},
10446 {2442, 7}, {2447, 8}, {2452, 9},
10447 {2457, 10}, {2462, 11}},
10453 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10454 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10455 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10456 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
},
10457 {5745, 149, IEEE80211_CH_PASSIVE_ONLY
},
10458 {5765, 153, IEEE80211_CH_PASSIVE_ONLY
},
10459 {5785, 157, IEEE80211_CH_PASSIVE_ONLY
},
10460 {5805, 161, IEEE80211_CH_PASSIVE_ONLY
},
10461 {5825, 165, IEEE80211_CH_PASSIVE_ONLY
}},
10464 { /* Custom Japan */
10467 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10468 {2427, 4}, {2432, 5}, {2437, 6},
10469 {2442, 7}, {2447, 8}, {2452, 9},
10470 {2457, 10}, {2462, 11}},
10472 .a
= {{5170, 34}, {5190, 38},
10473 {5210, 42}, {5230, 46}},
10479 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10480 {2427, 4}, {2432, 5}, {2437, 6},
10481 {2442, 7}, {2447, 8}, {2452, 9},
10482 {2457, 10}, {2462, 11}},
10488 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10489 {2427, 4}, {2432, 5}, {2437, 6},
10490 {2442, 7}, {2447, 8}, {2452, 9},
10491 {2457, 10}, {2462, 11}, {2467, 12},
10498 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10499 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10500 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10501 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
},
10502 {5500, 100, IEEE80211_CH_PASSIVE_ONLY
},
10503 {5520, 104, IEEE80211_CH_PASSIVE_ONLY
},
10504 {5540, 108, IEEE80211_CH_PASSIVE_ONLY
},
10505 {5560, 112, IEEE80211_CH_PASSIVE_ONLY
},
10506 {5580, 116, IEEE80211_CH_PASSIVE_ONLY
},
10507 {5600, 120, IEEE80211_CH_PASSIVE_ONLY
},
10508 {5620, 124, IEEE80211_CH_PASSIVE_ONLY
},
10509 {5640, 128, IEEE80211_CH_PASSIVE_ONLY
},
10510 {5660, 132, IEEE80211_CH_PASSIVE_ONLY
},
10511 {5680, 136, IEEE80211_CH_PASSIVE_ONLY
},
10512 {5700, 140, IEEE80211_CH_PASSIVE_ONLY
}},
10515 { /* Custom Japan */
10518 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10519 {2427, 4}, {2432, 5}, {2437, 6},
10520 {2442, 7}, {2447, 8}, {2452, 9},
10521 {2457, 10}, {2462, 11}, {2467, 12},
10522 {2472, 13}, {2484, 14, IEEE80211_CH_B_ONLY
}},
10524 .a
= {{5170, 34}, {5190, 38},
10525 {5210, 42}, {5230, 46}},
10528 { /* Rest of World */
10531 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10532 {2427, 4}, {2432, 5}, {2437, 6},
10533 {2442, 7}, {2447, 8}, {2452, 9},
10534 {2457, 10}, {2462, 11}, {2467, 12},
10535 {2472, 13}, {2484, 14, IEEE80211_CH_B_ONLY
|
10536 IEEE80211_CH_PASSIVE_ONLY
}},
10542 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10543 {2427, 4}, {2432, 5}, {2437, 6},
10544 {2442, 7}, {2447, 8}, {2452, 9},
10545 {2457, 10}, {2462, 11},
10546 {2467, 12, IEEE80211_CH_PASSIVE_ONLY
},
10547 {2472, 13, IEEE80211_CH_PASSIVE_ONLY
}},
10549 .a
= {{5745, 149}, {5765, 153},
10550 {5785, 157}, {5805, 161}},
10553 { /* Custom Europe */
10556 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10557 {2427, 4}, {2432, 5}, {2437, 6},
10558 {2442, 7}, {2447, 8}, {2452, 9},
10559 {2457, 10}, {2462, 11},
10560 {2467, 12}, {2472, 13}},
10562 .a
= {{5180, 36}, {5200, 40},
10563 {5220, 44}, {5240, 48}},
10569 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10570 {2427, 4}, {2432, 5}, {2437, 6},
10571 {2442, 7}, {2447, 8}, {2452, 9},
10572 {2457, 10}, {2462, 11},
10573 {2467, 12, IEEE80211_CH_PASSIVE_ONLY
},
10574 {2472, 13, IEEE80211_CH_PASSIVE_ONLY
}},
10576 .a
= {{5180, 36, IEEE80211_CH_PASSIVE_ONLY
},
10577 {5200, 40, IEEE80211_CH_PASSIVE_ONLY
},
10578 {5220, 44, IEEE80211_CH_PASSIVE_ONLY
},
10579 {5240, 48, IEEE80211_CH_PASSIVE_ONLY
},
10580 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10581 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10582 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10583 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
},
10584 {5500, 100, IEEE80211_CH_PASSIVE_ONLY
},
10585 {5520, 104, IEEE80211_CH_PASSIVE_ONLY
},
10586 {5540, 108, IEEE80211_CH_PASSIVE_ONLY
},
10587 {5560, 112, IEEE80211_CH_PASSIVE_ONLY
},
10588 {5580, 116, IEEE80211_CH_PASSIVE_ONLY
},
10589 {5600, 120, IEEE80211_CH_PASSIVE_ONLY
},
10590 {5620, 124, IEEE80211_CH_PASSIVE_ONLY
},
10591 {5640, 128, IEEE80211_CH_PASSIVE_ONLY
},
10592 {5660, 132, IEEE80211_CH_PASSIVE_ONLY
},
10593 {5680, 136, IEEE80211_CH_PASSIVE_ONLY
},
10594 {5700, 140, IEEE80211_CH_PASSIVE_ONLY
},
10595 {5745, 149, IEEE80211_CH_PASSIVE_ONLY
},
10596 {5765, 153, IEEE80211_CH_PASSIVE_ONLY
},
10597 {5785, 157, IEEE80211_CH_PASSIVE_ONLY
},
10598 {5805, 161, IEEE80211_CH_PASSIVE_ONLY
},
10599 {5825, 165, IEEE80211_CH_PASSIVE_ONLY
}},
10605 .bg
= {{2412, 1}, {2417, 2}, {2422, 3},
10606 {2427, 4}, {2432, 5}, {2437, 6},
10607 {2442, 7}, {2447, 8}, {2452, 9},
10608 {2457, 10}, {2462, 11}},
10610 .a
= {{5180, 36, IEEE80211_CH_PASSIVE_ONLY
},
10611 {5200, 40, IEEE80211_CH_PASSIVE_ONLY
},
10612 {5220, 44, IEEE80211_CH_PASSIVE_ONLY
},
10613 {5240, 48, IEEE80211_CH_PASSIVE_ONLY
},
10614 {5260, 52, IEEE80211_CH_PASSIVE_ONLY
},
10615 {5280, 56, IEEE80211_CH_PASSIVE_ONLY
},
10616 {5300, 60, IEEE80211_CH_PASSIVE_ONLY
},
10617 {5320, 64, IEEE80211_CH_PASSIVE_ONLY
},
10618 {5745, 149, IEEE80211_CH_PASSIVE_ONLY
},
10619 {5765, 153, IEEE80211_CH_PASSIVE_ONLY
},
10620 {5785, 157, IEEE80211_CH_PASSIVE_ONLY
},
10621 {5805, 161, IEEE80211_CH_PASSIVE_ONLY
},
10622 {5825, 165, IEEE80211_CH_PASSIVE_ONLY
}},
10626 /* GEO code borrowed from ieee80211_geo.c */
10627 static int ipw_is_valid_channel(struct ieee80211_device
*ieee
, u8 channel
)
10631 /* Driver needs to initialize the geography map before using
10632 * these helper functions */
10633 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
10635 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
10636 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
10637 /* NOTE: If G mode is currently supported but
10638 * this is a B only channel, we don't see it
10640 if ((ieee
->geo
.bg
[i
].channel
== channel
) &&
10641 (!(ieee
->mode
& IEEE_G
) ||
10642 !(ieee
->geo
.bg
[i
].flags
& IEEE80211_CH_B_ONLY
)))
10643 return IEEE80211_24GHZ_BAND
;
10645 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
10646 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
10647 if (ieee
->geo
.a
[i
].channel
== channel
)
10648 return IEEE80211_52GHZ_BAND
;
10653 static int ipw_channel_to_index(struct ieee80211_device
*ieee
, u8 channel
)
10657 /* Driver needs to initialize the geography map before using
10658 * these helper functions */
10659 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
10661 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
10662 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
10663 if (ieee
->geo
.bg
[i
].channel
== channel
)
10666 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
10667 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
10668 if (ieee
->geo
.a
[i
].channel
== channel
)
10674 static u8
ipw_freq_to_channel(struct ieee80211_device
*ieee
, u32 freq
)
10678 /* Driver needs to initialize the geography map before using
10679 * these helper functions */
10680 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
10684 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
10685 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
10686 if (ieee
->geo
.bg
[i
].freq
== freq
)
10687 return ieee
->geo
.bg
[i
].channel
;
10689 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
10690 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
10691 if (ieee
->geo
.a
[i
].freq
== freq
)
10692 return ieee
->geo
.a
[i
].channel
;
10697 static int ipw_set_geo(struct ieee80211_device
*ieee
,
10698 const struct ieee80211_geo
*geo
)
10700 memcpy(ieee
->geo
.name
, geo
->name
, 3);
10701 ieee
->geo
.name
[3] = '\0';
10702 ieee
->geo
.bg_channels
= geo
->bg_channels
;
10703 ieee
->geo
.a_channels
= geo
->a_channels
;
10704 memcpy(ieee
->geo
.bg
, geo
->bg
, geo
->bg_channels
*
10705 sizeof(struct ieee80211_channel
));
10706 memcpy(ieee
->geo
.a
, geo
->a
, ieee
->geo
.a_channels
*
10707 sizeof(struct ieee80211_channel
));
10711 static const struct ieee80211_geo
*ipw_get_geo(struct ieee80211_device
*ieee
)
10716 #define MAX_HW_RESTARTS 5
10717 static int ipw_up(struct ipw_priv
*priv
)
10721 if (priv
->status
& STATUS_EXIT_PENDING
)
10724 if (cmdlog
&& !priv
->cmdlog
) {
10725 priv
->cmdlog
= kmalloc(sizeof(*priv
->cmdlog
) * cmdlog
,
10727 if (priv
->cmdlog
== NULL
) {
10728 IPW_ERROR("Error allocating %d command log entries.\n",
10731 memset(priv
->cmdlog
, 0, sizeof(*priv
->cmdlog
) * cmdlog
);
10732 priv
->cmdlog_len
= cmdlog
;
10736 for (i
= 0; i
< MAX_HW_RESTARTS
; i
++) {
10737 /* Load the microcode, firmware, and eeprom.
10738 * Also start the clocks. */
10739 rc
= ipw_load(priv
);
10741 IPW_ERROR("Unable to load firmware: %d\n", rc
);
10745 ipw_init_ordinals(priv
);
10746 if (!(priv
->config
& CFG_CUSTOM_MAC
))
10747 eeprom_parse_mac(priv
, priv
->mac_addr
);
10748 memcpy(priv
->net_dev
->dev_addr
, priv
->mac_addr
, ETH_ALEN
);
10750 for (j
= 0; j
< ARRAY_SIZE(ipw_geos
); j
++) {
10751 if (!memcmp(&priv
->eeprom
[EEPROM_COUNTRY_CODE
],
10752 ipw_geos
[j
].name
, 3))
10755 if (j
== ARRAY_SIZE(ipw_geos
)) {
10756 IPW_WARNING("SKU [%c%c%c] not recognized.\n",
10757 priv
->eeprom
[EEPROM_COUNTRY_CODE
+ 0],
10758 priv
->eeprom
[EEPROM_COUNTRY_CODE
+ 1],
10759 priv
->eeprom
[EEPROM_COUNTRY_CODE
+ 2]);
10762 if (ipw_set_geo(priv
->ieee
, &ipw_geos
[j
])) {
10763 IPW_WARNING("Could not set geography.");
10767 IPW_DEBUG_INFO("Geography %03d [%s] detected.\n",
10768 j
, priv
->ieee
->geo
.name
);
10770 if (priv
->status
& STATUS_RF_KILL_SW
) {
10771 IPW_WARNING("Radio disabled by module parameter.\n");
10773 } else if (rf_kill_active(priv
)) {
10774 IPW_WARNING("Radio Frequency Kill Switch is On:\n"
10775 "Kill switch must be turned off for "
10776 "wireless networking to work.\n");
10777 queue_delayed_work(priv
->workqueue
, &priv
->rf_kill
,
10782 rc
= ipw_config(priv
);
10784 IPW_DEBUG_INFO("Configured device on count %i\n", i
);
10786 /* If configure to try and auto-associate, kick
10788 queue_work(priv
->workqueue
, &priv
->request_scan
);
10793 IPW_DEBUG_INFO("Device configuration failed: 0x%08X\n", rc
);
10794 IPW_DEBUG_INFO("Failed to config device on retry %d of %d\n",
10795 i
, MAX_HW_RESTARTS
);
10797 /* We had an error bringing up the hardware, so take it
10798 * all the way back down so we can try again */
10802 /* tried to restart and config the device for as long as our
10803 * patience could withstand */
10804 IPW_ERROR("Unable to initialize device after %d attempts.\n", i
);
10809 static void ipw_bg_up(void *data
)
10811 struct ipw_priv
*priv
= data
;
10817 static void ipw_deinit(struct ipw_priv
*priv
)
10821 if (priv
->status
& STATUS_SCANNING
) {
10822 IPW_DEBUG_INFO("Aborting scan during shutdown.\n");
10823 ipw_abort_scan(priv
);
10826 if (priv
->status
& STATUS_ASSOCIATED
) {
10827 IPW_DEBUG_INFO("Disassociating during shutdown.\n");
10828 ipw_disassociate(priv
);
10831 ipw_led_shutdown(priv
);
10833 /* Wait up to 1s for status to change to not scanning and not
10834 * associated (disassociation can take a while for a ful 802.11
10836 for (i
= 1000; i
&& (priv
->status
&
10837 (STATUS_DISASSOCIATING
|
10838 STATUS_ASSOCIATED
| STATUS_SCANNING
)); i
--)
10841 if (priv
->status
& (STATUS_DISASSOCIATING
|
10842 STATUS_ASSOCIATED
| STATUS_SCANNING
))
10843 IPW_DEBUG_INFO("Still associated or scanning...\n");
10845 IPW_DEBUG_INFO("Took %dms to de-init\n", 1000 - i
);
10847 /* Attempt to disable the card */
10848 ipw_send_card_disable(priv
, 0);
10850 priv
->status
&= ~STATUS_INIT
;
10853 static void ipw_down(struct ipw_priv
*priv
)
10855 int exit_pending
= priv
->status
& STATUS_EXIT_PENDING
;
10857 priv
->status
|= STATUS_EXIT_PENDING
;
10859 if (ipw_is_init(priv
))
10862 /* Wipe out the EXIT_PENDING status bit if we are not actually
10863 * exiting the module */
10865 priv
->status
&= ~STATUS_EXIT_PENDING
;
10867 /* tell the device to stop sending interrupts */
10868 ipw_disable_interrupts(priv
);
10870 /* Clear all bits but the RF Kill */
10871 priv
->status
&= STATUS_RF_KILL_MASK
| STATUS_EXIT_PENDING
;
10872 netif_carrier_off(priv
->net_dev
);
10873 netif_stop_queue(priv
->net_dev
);
10875 ipw_stop_nic(priv
);
10877 ipw_led_radio_off(priv
);
10880 static void ipw_bg_down(void *data
)
10882 struct ipw_priv
*priv
= data
;
10888 /* Called by register_netdev() */
10889 static int ipw_net_init(struct net_device
*dev
)
10891 struct ipw_priv
*priv
= ieee80211_priv(dev
);
10894 if (ipw_up(priv
)) {
10903 /* PCI driver stuff */
10904 static struct pci_device_id card_ids
[] = {
10905 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2701, 0, 0, 0},
10906 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2702, 0, 0, 0},
10907 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2711, 0, 0, 0},
10908 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2712, 0, 0, 0},
10909 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2721, 0, 0, 0},
10910 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2722, 0, 0, 0},
10911 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2731, 0, 0, 0},
10912 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2732, 0, 0, 0},
10913 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2741, 0, 0, 0},
10914 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x103c, 0x2741, 0, 0, 0},
10915 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2742, 0, 0, 0},
10916 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2751, 0, 0, 0},
10917 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2752, 0, 0, 0},
10918 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2753, 0, 0, 0},
10919 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2754, 0, 0, 0},
10920 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2761, 0, 0, 0},
10921 {PCI_VENDOR_ID_INTEL
, 0x1043, 0x8086, 0x2762, 0, 0, 0},
10922 {PCI_VENDOR_ID_INTEL
, 0x104f, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0},
10923 {PCI_VENDOR_ID_INTEL
, 0x4220, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, /* BG */
10924 {PCI_VENDOR_ID_INTEL
, 0x4221, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, /* BG */
10925 {PCI_VENDOR_ID_INTEL
, 0x4223, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, /* ABG */
10926 {PCI_VENDOR_ID_INTEL
, 0x4224, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, /* ABG */
10928 /* required last entry */
10932 MODULE_DEVICE_TABLE(pci
, card_ids
);
10934 static struct attribute
*ipw_sysfs_entries
[] = {
10935 &dev_attr_rf_kill
.attr
,
10936 &dev_attr_direct_dword
.attr
,
10937 &dev_attr_indirect_byte
.attr
,
10938 &dev_attr_indirect_dword
.attr
,
10939 &dev_attr_mem_gpio_reg
.attr
,
10940 &dev_attr_command_event_reg
.attr
,
10941 &dev_attr_nic_type
.attr
,
10942 &dev_attr_status
.attr
,
10943 &dev_attr_cfg
.attr
,
10944 &dev_attr_error
.attr
,
10945 &dev_attr_event_log
.attr
,
10946 &dev_attr_cmd_log
.attr
,
10947 &dev_attr_eeprom_delay
.attr
,
10948 &dev_attr_ucode_version
.attr
,
10949 &dev_attr_rtc
.attr
,
10950 &dev_attr_scan_age
.attr
,
10951 &dev_attr_led
.attr
,
10952 &dev_attr_speed_scan
.attr
,
10953 &dev_attr_net_stats
.attr
,
10957 static struct attribute_group ipw_attribute_group
= {
10958 .name
= NULL
, /* put in device directory */
10959 .attrs
= ipw_sysfs_entries
,
10962 static int ipw_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
10965 struct net_device
*net_dev
;
10966 void __iomem
*base
;
10968 struct ipw_priv
*priv
;
10971 net_dev
= alloc_ieee80211(sizeof(struct ipw_priv
));
10972 if (net_dev
== NULL
) {
10977 priv
= ieee80211_priv(net_dev
);
10978 priv
->ieee
= netdev_priv(net_dev
);
10980 priv
->net_dev
= net_dev
;
10981 priv
->pci_dev
= pdev
;
10982 #ifdef CONFIG_IPW2200_DEBUG
10983 ipw_debug_level
= debug
;
10985 spin_lock_init(&priv
->lock
);
10986 for (i
= 0; i
< IPW_IBSS_MAC_HASH_SIZE
; i
++)
10987 INIT_LIST_HEAD(&priv
->ibss_mac_hash
[i
]);
10989 init_MUTEX(&priv
->sem
);
10990 if (pci_enable_device(pdev
)) {
10992 goto out_free_ieee80211
;
10995 pci_set_master(pdev
);
10997 err
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
10999 err
= pci_set_consistent_dma_mask(pdev
, DMA_32BIT_MASK
);
11001 printk(KERN_WARNING DRV_NAME
": No suitable DMA available.\n");
11002 goto out_pci_disable_device
;
11005 pci_set_drvdata(pdev
, priv
);
11007 err
= pci_request_regions(pdev
, DRV_NAME
);
11009 goto out_pci_disable_device
;
11011 /* We disable the RETRY_TIMEOUT register (0x41) to keep
11012 * PCI Tx retries from interfering with C3 CPU state */
11013 pci_read_config_dword(pdev
, 0x40, &val
);
11014 if ((val
& 0x0000ff00) != 0)
11015 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
11017 length
= pci_resource_len(pdev
, 0);
11018 priv
->hw_len
= length
;
11020 base
= ioremap_nocache(pci_resource_start(pdev
, 0), length
);
11023 goto out_pci_release_regions
;
11026 priv
->hw_base
= base
;
11027 IPW_DEBUG_INFO("pci_resource_len = 0x%08x\n", length
);
11028 IPW_DEBUG_INFO("pci_resource_base = %p\n", base
);
11030 err
= ipw_setup_deferred_work(priv
);
11032 IPW_ERROR("Unable to setup deferred work\n");
11036 ipw_sw_reset(priv
, 1);
11038 err
= request_irq(pdev
->irq
, ipw_isr
, SA_SHIRQ
, DRV_NAME
, priv
);
11040 IPW_ERROR("Error allocating IRQ %d\n", pdev
->irq
);
11041 goto out_destroy_workqueue
;
11044 SET_MODULE_OWNER(net_dev
);
11045 SET_NETDEV_DEV(net_dev
, &pdev
->dev
);
11049 priv
->ieee
->hard_start_xmit
= ipw_net_hard_start_xmit
;
11050 priv
->ieee
->set_security
= shim__set_security
;
11051 priv
->ieee
->is_queue_full
= ipw_net_is_queue_full
;
11053 #ifdef CONFIG_IPW_QOS
11054 priv
->ieee
->handle_probe_response
= ipw_handle_beacon
;
11055 priv
->ieee
->handle_beacon
= ipw_handle_probe_response
;
11056 priv
->ieee
->handle_assoc_response
= ipw_handle_assoc_response
;
11057 #endif /* CONFIG_IPW_QOS */
11059 priv
->ieee
->perfect_rssi
= -20;
11060 priv
->ieee
->worst_rssi
= -85;
11062 net_dev
->open
= ipw_net_open
;
11063 net_dev
->stop
= ipw_net_stop
;
11064 net_dev
->init
= ipw_net_init
;
11065 net_dev
->get_stats
= ipw_net_get_stats
;
11066 net_dev
->set_multicast_list
= ipw_net_set_multicast_list
;
11067 net_dev
->set_mac_address
= ipw_net_set_mac_address
;
11068 priv
->wireless_data
.spy_data
= &priv
->ieee
->spy_data
;
11069 net_dev
->wireless_data
= &priv
->wireless_data
;
11070 net_dev
->wireless_handlers
= &ipw_wx_handler_def
;
11071 net_dev
->ethtool_ops
= &ipw_ethtool_ops
;
11072 net_dev
->irq
= pdev
->irq
;
11073 net_dev
->base_addr
= (unsigned long)priv
->hw_base
;
11074 net_dev
->mem_start
= pci_resource_start(pdev
, 0);
11075 net_dev
->mem_end
= net_dev
->mem_start
+ pci_resource_len(pdev
, 0) - 1;
11077 err
= sysfs_create_group(&pdev
->dev
.kobj
, &ipw_attribute_group
);
11079 IPW_ERROR("failed to create sysfs device attributes\n");
11081 goto out_release_irq
;
11085 err
= register_netdev(net_dev
);
11087 IPW_ERROR("failed to register network device\n");
11088 goto out_remove_sysfs
;
11093 sysfs_remove_group(&pdev
->dev
.kobj
, &ipw_attribute_group
);
11095 free_irq(pdev
->irq
, priv
);
11096 out_destroy_workqueue
:
11097 destroy_workqueue(priv
->workqueue
);
11098 priv
->workqueue
= NULL
;
11100 iounmap(priv
->hw_base
);
11101 out_pci_release_regions
:
11102 pci_release_regions(pdev
);
11103 out_pci_disable_device
:
11104 pci_disable_device(pdev
);
11105 pci_set_drvdata(pdev
, NULL
);
11106 out_free_ieee80211
:
11107 free_ieee80211(priv
->net_dev
);
11112 static void ipw_pci_remove(struct pci_dev
*pdev
)
11114 struct ipw_priv
*priv
= pci_get_drvdata(pdev
);
11115 struct list_head
*p
, *q
;
11123 priv
->status
|= STATUS_EXIT_PENDING
;
11125 sysfs_remove_group(&pdev
->dev
.kobj
, &ipw_attribute_group
);
11129 unregister_netdev(priv
->net_dev
);
11132 ipw_rx_queue_free(priv
, priv
->rxq
);
11135 ipw_tx_queue_free(priv
);
11137 if (priv
->cmdlog
) {
11138 kfree(priv
->cmdlog
);
11139 priv
->cmdlog
= NULL
;
11141 /* ipw_down will ensure that there is no more pending work
11142 * in the workqueue's, so we can safely remove them now. */
11143 cancel_delayed_work(&priv
->adhoc_check
);
11144 cancel_delayed_work(&priv
->gather_stats
);
11145 cancel_delayed_work(&priv
->request_scan
);
11146 cancel_delayed_work(&priv
->rf_kill
);
11147 cancel_delayed_work(&priv
->scan_check
);
11148 destroy_workqueue(priv
->workqueue
);
11149 priv
->workqueue
= NULL
;
11151 /* Free MAC hash list for ADHOC */
11152 for (i
= 0; i
< IPW_IBSS_MAC_HASH_SIZE
; i
++) {
11153 list_for_each_safe(p
, q
, &priv
->ibss_mac_hash
[i
]) {
11155 kfree(list_entry(p
, struct ipw_ibss_seq
, list
));
11160 ipw_free_error_log(priv
->error
);
11161 priv
->error
= NULL
;
11164 free_irq(pdev
->irq
, priv
);
11165 iounmap(priv
->hw_base
);
11166 pci_release_regions(pdev
);
11167 pci_disable_device(pdev
);
11168 pci_set_drvdata(pdev
, NULL
);
11169 free_ieee80211(priv
->net_dev
);
11174 static int ipw_pci_suspend(struct pci_dev
*pdev
, pm_message_t state
)
11176 struct ipw_priv
*priv
= pci_get_drvdata(pdev
);
11177 struct net_device
*dev
= priv
->net_dev
;
11179 printk(KERN_INFO
"%s: Going into suspend...\n", dev
->name
);
11181 /* Take down the device; powers it off, etc. */
11184 /* Remove the PRESENT state of the device */
11185 netif_device_detach(dev
);
11187 pci_save_state(pdev
);
11188 pci_disable_device(pdev
);
11189 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
11194 static int ipw_pci_resume(struct pci_dev
*pdev
)
11196 struct ipw_priv
*priv
= pci_get_drvdata(pdev
);
11197 struct net_device
*dev
= priv
->net_dev
;
11200 printk(KERN_INFO
"%s: Coming out of suspend...\n", dev
->name
);
11202 pci_set_power_state(pdev
, PCI_D0
);
11203 pci_enable_device(pdev
);
11204 pci_restore_state(pdev
);
11207 * Suspend/Resume resets the PCI configuration space, so we have to
11208 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
11209 * from interfering with C3 CPU state. pci_restore_state won't help
11210 * here since it only restores the first 64 bytes pci config header.
11212 pci_read_config_dword(pdev
, 0x40, &val
);
11213 if ((val
& 0x0000ff00) != 0)
11214 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
11216 /* Set the device back into the PRESENT state; this will also wake
11217 * the queue of needed */
11218 netif_device_attach(dev
);
11220 /* Bring the device back up */
11221 queue_work(priv
->workqueue
, &priv
->up
);
11227 /* driver initialization stuff */
11228 static struct pci_driver ipw_driver
= {
11230 .id_table
= card_ids
,
11231 .probe
= ipw_pci_probe
,
11232 .remove
= __devexit_p(ipw_pci_remove
),
11234 .suspend
= ipw_pci_suspend
,
11235 .resume
= ipw_pci_resume
,
11239 static int __init
ipw_init(void)
11243 printk(KERN_INFO DRV_NAME
": " DRV_DESCRIPTION
", " DRV_VERSION
"\n");
11244 printk(KERN_INFO DRV_NAME
": " DRV_COPYRIGHT
"\n");
11246 ret
= pci_module_init(&ipw_driver
);
11248 IPW_ERROR("Unable to initialize PCI module\n");
11252 ret
= driver_create_file(&ipw_driver
.driver
, &driver_attr_debug_level
);
11254 IPW_ERROR("Unable to create driver sysfs file\n");
11255 pci_unregister_driver(&ipw_driver
);
11262 static void __exit
ipw_exit(void)
11264 driver_remove_file(&ipw_driver
.driver
, &driver_attr_debug_level
);
11265 pci_unregister_driver(&ipw_driver
);
11268 module_param(disable
, int, 0444);
11269 MODULE_PARM_DESC(disable
, "manually disable the radio (default 0 [radio on])");
11271 module_param(associate
, int, 0444);
11272 MODULE_PARM_DESC(associate
, "auto associate when scanning (default on)");
11274 module_param(auto_create
, int, 0444);
11275 MODULE_PARM_DESC(auto_create
, "auto create adhoc network (default on)");
11277 module_param(led
, int, 0444);
11278 MODULE_PARM_DESC(led
, "enable led control on some systems (default 0 off)\n");
11280 module_param(debug
, int, 0444);
11281 MODULE_PARM_DESC(debug
, "debug output mask");
11283 module_param(channel
, int, 0444);
11284 MODULE_PARM_DESC(channel
, "channel to limit associate to (default 0 [ANY])");
11286 #ifdef CONFIG_IPW_QOS
11287 module_param(qos_enable
, int, 0444);
11288 MODULE_PARM_DESC(qos_enable
, "enable all QoS functionalitis");
11290 module_param(qos_burst_enable
, int, 0444);
11291 MODULE_PARM_DESC(qos_burst_enable
, "enable QoS burst mode");
11293 module_param(qos_no_ack_mask
, int, 0444);
11294 MODULE_PARM_DESC(qos_no_ack_mask
, "mask Tx_Queue to no ack");
11296 module_param(burst_duration_CCK
, int, 0444);
11297 MODULE_PARM_DESC(burst_duration_CCK
, "set CCK burst value");
11299 module_param(burst_duration_OFDM
, int, 0444);
11300 MODULE_PARM_DESC(burst_duration_OFDM
, "set OFDM burst value");
11301 #endif /* CONFIG_IPW_QOS */
11303 #ifdef CONFIG_IPW2200_MONITOR
11304 module_param(mode
, int, 0444);
11305 MODULE_PARM_DESC(mode
, "network mode (0=BSS,1=IBSS,2=Monitor)");
11307 module_param(mode
, int, 0444);
11308 MODULE_PARM_DESC(mode
, "network mode (0=BSS,1=IBSS)");
11311 module_param(bt_coexist
, int, 0444);
11312 MODULE_PARM_DESC(bt_coexist
, "enable bluetooth coexistence (default off)");
11314 module_param(hwcrypto
, int, 0444);
11315 MODULE_PARM_DESC(hwcrypto
, "enable hardware crypto (default on)");
11317 module_param(cmdlog
, int, 0444);
11318 MODULE_PARM_DESC(cmdlog
,
11319 "allocate a ring buffer for logging firmware commands");
11321 module_param(roaming
, int, 0444);
11322 MODULE_PARM_DESC(roaming
, "enable roaming support (default on)");
11324 module_exit(ipw_exit
);
11325 module_init(ipw_init
);