aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ipw2200.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ipw2200.c')
-rw-r--r--drivers/net/wireless/ipw2200.c2274
1 files changed, 1152 insertions, 1122 deletions
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 6d0b6b1df4ca..b7f275c00de3 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -72,7 +72,8 @@ static void ipw_rx_queue_replenish(void *);
72static int ipw_up(struct ipw_priv *); 72static int ipw_up(struct ipw_priv *);
73static void ipw_down(struct ipw_priv *); 73static void ipw_down(struct ipw_priv *);
74static int ipw_config(struct ipw_priv *); 74static int ipw_config(struct ipw_priv *);
75static int init_supported_rates(struct ipw_priv *priv, struct ipw_supported_rates *prates); 75static int init_supported_rates(struct ipw_priv *priv,
76 struct ipw_supported_rates *prates);
76 77
77static u8 band_b_active_channel[MAX_B_CHANNELS] = { 78static u8 band_b_active_channel[MAX_B_CHANNELS] = {
78 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 79 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0
@@ -102,7 +103,7 @@ static int is_valid_channel(int mode_mask, int channel)
102} 103}
103 104
104static char *snprint_line(char *buf, size_t count, 105static char *snprint_line(char *buf, size_t count,
105 const u8 *data, u32 len, u32 ofs) 106 const u8 * data, u32 len, u32 ofs)
106{ 107{
107 int out, i, j, l; 108 int out, i, j, l;
108 char c; 109 char c;
@@ -136,7 +137,7 @@ static char *snprint_line(char *buf, size_t count,
136 return buf; 137 return buf;
137} 138}
138 139
139static void printk_buf(int level, const u8 *data, u32 len) 140static void printk_buf(int level, const u8 * data, u32 len)
140{ 141{
141 char line[81]; 142 char line[81];
142 u32 ofs = 0; 143 u32 ofs = 0;
@@ -161,21 +162,24 @@ static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg);
161static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value); 162static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value);
162static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c) 163static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c)
163{ 164{
164 IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); 165 IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__,
166 __LINE__, (u32) (b), (u32) (c));
165 _ipw_write_reg8(a, b, c); 167 _ipw_write_reg8(a, b, c);
166} 168}
167 169
168static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value); 170static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value);
169static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c) 171static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c)
170{ 172{
171 IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); 173 IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__,
174 __LINE__, (u32) (b), (u32) (c));
172 _ipw_write_reg16(a, b, c); 175 _ipw_write_reg16(a, b, c);
173} 176}
174 177
175static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value); 178static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value);
176static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) 179static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c)
177{ 180{
178 IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); 181 IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__,
182 __LINE__, (u32) (b), (u32) (c));
179 _ipw_write_reg32(a, b, c); 183 _ipw_write_reg32(a, b, c);
180} 184}
181 185
@@ -195,24 +199,30 @@ static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c)
195 _ipw_write32(ipw, ofs, val) 199 _ipw_write32(ipw, ofs, val)
196 200
197#define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) 201#define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs))
198static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { 202static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
199 IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32)(ofs)); 203{
204 IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs));
200 return _ipw_read8(ipw, ofs); 205 return _ipw_read8(ipw, ofs);
201} 206}
207
202#define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) 208#define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs)
203 209
204#define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) 210#define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs))
205static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { 211static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
206 IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32)(ofs)); 212{
213 IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs));
207 return _ipw_read16(ipw, ofs); 214 return _ipw_read16(ipw, ofs);
208} 215}
216
209#define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) 217#define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs)
210 218
211#define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) 219#define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs))
212static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { 220static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
213 IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32)(ofs)); 221{
222 IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs));
214 return _ipw_read32(ipw, ofs); 223 return _ipw_read32(ipw, ofs);
215} 224}
225
216#define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) 226#define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs)
217 227
218static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); 228static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int);
@@ -220,34 +230,30 @@ static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int);
220 IPW_DEBUG_IO("%s %d: read_inddirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ 230 IPW_DEBUG_IO("%s %d: read_inddirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
221 _ipw_read_indirect(a, b, c, d) 231 _ipw_read_indirect(a, b, c, d)
222 232
223static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *data, int num); 233static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data,
234 int num);
224#define ipw_write_indirect(a, b, c, d) \ 235#define ipw_write_indirect(a, b, c, d) \
225 IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ 236 IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
226 _ipw_write_indirect(a, b, c, d) 237 _ipw_write_indirect(a, b, c, d)
227 238
228/* indirect write s */ 239/* indirect write s */
229static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, 240static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value)
230 u32 value)
231{ 241{
232 IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", 242 IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv, reg, value);
233 priv, reg, value);
234 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg); 243 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg);
235 _ipw_write32(priv, CX2_INDIRECT_DATA, value); 244 _ipw_write32(priv, CX2_INDIRECT_DATA, value);
236} 245}
237 246
238
239static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value) 247static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value)
240{ 248{
241 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); 249 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
242 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); 250 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
243 _ipw_write8(priv, CX2_INDIRECT_DATA, value); 251 _ipw_write8(priv, CX2_INDIRECT_DATA, value);
244 IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n", 252 IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n",
245 (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), 253 (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), value);
246 value);
247} 254}
248 255
249static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, 256static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value)
250 u16 value)
251{ 257{
252 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); 258 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
253 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); 259 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
@@ -262,7 +268,7 @@ static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg)
262 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); 268 _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
263 IPW_DEBUG_IO(" reg = 0x%8X : \n", reg); 269 IPW_DEBUG_IO(" reg = 0x%8X : \n", reg);
264 word = _ipw_read32(priv, CX2_INDIRECT_DATA); 270 word = _ipw_read32(priv, CX2_INDIRECT_DATA);
265 return (word >> ((reg & 0x3)*8)) & 0xff; 271 return (word >> ((reg & 0x3) * 8)) & 0xff;
266} 272}
267 273
268static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg) 274static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg)
@@ -302,7 +308,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
302 _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); 308 _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr);
303 aligned_len = num & CX2_INDIRECT_ADDR_MASK; 309 aligned_len = num & CX2_INDIRECT_ADDR_MASK;
304 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) 310 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
305 *(u32*)buf = ipw_read32(priv, CX2_AUTOINC_DATA); 311 *(u32 *) buf = ipw_read32(priv, CX2_AUTOINC_DATA);
306 312
307 /* Copy the last nibble */ 313 /* Copy the last nibble */
308 dif_len = num - aligned_len; 314 dif_len = num - aligned_len;
@@ -311,7 +317,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
311 *buf = ipw_read8(priv, CX2_INDIRECT_DATA + i); 317 *buf = ipw_read8(priv, CX2_INDIRECT_DATA + i);
312} 318}
313 319
314static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf, 320static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
315 int num) 321 int num)
316{ 322{
317 u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK; 323 u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK;
@@ -335,7 +341,7 @@ static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf,
335 _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); 341 _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr);
336 aligned_len = num & CX2_INDIRECT_ADDR_MASK; 342 aligned_len = num & CX2_INDIRECT_ADDR_MASK;
337 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) 343 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
338 _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32*)buf); 344 _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32 *) buf);
339 345
340 /* Copy the last nibble */ 346 /* Copy the last nibble */
341 dif_len = num - aligned_len; 347 dif_len = num - aligned_len;
@@ -428,20 +434,18 @@ static void ipw_dump_nic_error_log(struct ipw_priv *priv)
428 } 434 }
429 435
430 for (i = ERROR_START_OFFSET; 436 for (i = ERROR_START_OFFSET;
431 i <= count * ERROR_ELEM_SIZE; 437 i <= count * ERROR_ELEM_SIZE; i += ERROR_ELEM_SIZE) {
432 i += ERROR_ELEM_SIZE) { 438 desc = ipw_read_reg32(priv, base + i);
433 desc = ipw_read_reg32(priv, base + i); 439 time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32));
434 time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); 440 blink1 = ipw_read_reg32(priv, base + i + 2 * sizeof(u32));
435 blink1 = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); 441 blink2 = ipw_read_reg32(priv, base + i + 3 * sizeof(u32));
436 blink2 = ipw_read_reg32(priv, base + i + 3*sizeof(u32)); 442 ilink1 = ipw_read_reg32(priv, base + i + 4 * sizeof(u32));
437 ilink1 = ipw_read_reg32(priv, base + i + 4*sizeof(u32)); 443 ilink2 = ipw_read_reg32(priv, base + i + 5 * sizeof(u32));
438 ilink2 = ipw_read_reg32(priv, base + i + 5*sizeof(u32)); 444 idata = ipw_read_reg32(priv, base + i + 6 * sizeof(u32));
439 idata = ipw_read_reg32(priv, base + i + 6*sizeof(u32));
440 445
441 IPW_ERROR( 446 IPW_ERROR("%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
442 "%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", 447 ipw_error_desc(desc), time, blink1, blink2,
443 ipw_error_desc(desc), time, blink1, blink2, 448 ilink1, ilink2, idata);
444 ilink1, ilink2, idata);
445 } 449 }
446} 450}
447 451
@@ -456,11 +460,10 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv)
456 IPW_ERROR("Start IPW Event Log Dump:\n"); 460 IPW_ERROR("Start IPW Event Log Dump:\n");
457 461
458 for (i = EVENT_START_OFFSET; 462 for (i = EVENT_START_OFFSET;
459 i <= count * EVENT_ELEM_SIZE; 463 i <= count * EVENT_ELEM_SIZE; i += EVENT_ELEM_SIZE) {
460 i += EVENT_ELEM_SIZE) {
461 ev = ipw_read_reg32(priv, base + i); 464 ev = ipw_read_reg32(priv, base + i);
462 time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); 465 time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32));
463 data = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); 466 data = ipw_read_reg32(priv, base + i + 2 * sizeof(u32));
464 467
465#ifdef CONFIG_IPW_DEBUG 468#ifdef CONFIG_IPW_DEBUG
466 IPW_ERROR("%i\t0x%08x\t%i\n", time, data, ev); 469 IPW_ERROR("%i\t0x%08x\t%i\n", time, data, ev);
@@ -468,8 +471,7 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv)
468 } 471 }
469} 472}
470 473
471static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, 474static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, u32 * len)
472 u32 *len)
473{ 475{
474 u32 addr, field_info, field_len, field_count, total_len; 476 u32 addr, field_info, field_len, field_count, total_len;
475 477
@@ -513,11 +515,11 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val,
513 } 515 }
514 516
515 IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n", 517 IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n",
516 ord, priv->table0_addr + (ord << 2)); 518 ord, priv->table0_addr + (ord << 2));
517 519
518 *len = sizeof(u32); 520 *len = sizeof(u32);
519 ord <<= 2; 521 ord <<= 2;
520 *((u32 *)val) = ipw_read32(priv, priv->table0_addr + ord); 522 *((u32 *) val) = ipw_read32(priv, priv->table0_addr + ord);
521 break; 523 break;
522 524
523 case IPW_ORD_TABLE_1_MASK: 525 case IPW_ORD_TABLE_1_MASK:
@@ -545,7 +547,8 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val,
545 return -EINVAL; 547 return -EINVAL;
546 } 548 }
547 549
548 *((u32 *)val) = ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); 550 *((u32 *) val) =
551 ipw_read_reg32(priv, (priv->table1_addr + (ord << 2)));
549 *len = sizeof(u32); 552 *len = sizeof(u32);
550 break; 553 break;
551 554
@@ -573,13 +576,16 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val,
573 576
574 /* get the second DW of statistics ; 577 /* get the second DW of statistics ;
575 * two 16-bit words - first is length, second is count */ 578 * two 16-bit words - first is length, second is count */
576 field_info = ipw_read_reg32(priv, priv->table2_addr + (ord << 3) + sizeof(u32)); 579 field_info =
580 ipw_read_reg32(priv,
581 priv->table2_addr + (ord << 3) +
582 sizeof(u32));
577 583
578 /* get each entry length */ 584 /* get each entry length */
579 field_len = *((u16 *)&field_info); 585 field_len = *((u16 *) & field_info);
580 586
581 /* get number of entries */ 587 /* get number of entries */
582 field_count = *(((u16 *)&field_info) + 1); 588 field_count = *(((u16 *) & field_info) + 1);
583 589
584 /* abort if not enought memory */ 590 /* abort if not enought memory */
585 total_len = field_len * field_count; 591 total_len = field_len * field_count;
@@ -604,7 +610,6 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val,
604 610
605 } 611 }
606 612
607
608 return 0; 613 return 0;
609} 614}
610 615
@@ -624,7 +629,7 @@ static void ipw_init_ordinals(struct ipw_priv *priv)
624 629
625 priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2); 630 priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2);
626 priv->table2_len = ipw_read_reg32(priv, priv->table2_addr); 631 priv->table2_len = ipw_read_reg32(priv, priv->table2_addr);
627 priv->table2_len &= 0x0000ffff; /* use first two bytes */ 632 priv->table2_len &= 0x0000ffff; /* use first two bytes */
628 633
629 IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n", 634 IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n",
630 priv->table2_addr, priv->table2_len); 635 priv->table2_addr, priv->table2_len);
@@ -643,7 +648,7 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf)
643 return sprintf(buf, "0x%08X\n", ipw_debug_level); 648 return sprintf(buf, "0x%08X\n", ipw_debug_level);
644} 649}
645static ssize_t store_debug_level(struct device_driver *d, 650static ssize_t store_debug_level(struct device_driver *d,
646 const char *buf, size_t count) 651 const char *buf, size_t count)
647{ 652{
648 char *p = (char *)buf; 653 char *p = (char *)buf;
649 u32 val; 654 u32 val;
@@ -668,11 +673,12 @@ static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO,
668 show_debug_level, store_debug_level); 673 show_debug_level, store_debug_level);
669 674
670static ssize_t show_status(struct device *d, 675static ssize_t show_status(struct device *d,
671 struct device_attribute *attr, char *buf) 676 struct device_attribute *attr, char *buf)
672{ 677{
673 struct ipw_priv *p = d->driver_data; 678 struct ipw_priv *p = d->driver_data;
674 return sprintf(buf, "0x%08x\n", (int)p->status); 679 return sprintf(buf, "0x%08x\n", (int)p->status);
675} 680}
681
676static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); 682static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
677 683
678static ssize_t show_cfg(struct device *d, struct device_attribute *attr, 684static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
@@ -681,10 +687,11 @@ static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
681 struct ipw_priv *p = d->driver_data; 687 struct ipw_priv *p = d->driver_data;
682 return sprintf(buf, "0x%08x\n", (int)p->config); 688 return sprintf(buf, "0x%08x\n", (int)p->config);
683} 689}
690
684static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL); 691static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
685 692
686static ssize_t show_nic_type(struct device *d, 693static ssize_t show_nic_type(struct device *d,
687 struct device_attribute *attr, char *buf) 694 struct device_attribute *attr, char *buf)
688{ 695{
689 struct ipw_priv *p = d->driver_data; 696 struct ipw_priv *p = d->driver_data;
690 u8 type = p->eeprom[EEPROM_NIC_TYPE]; 697 u8 type = p->eeprom[EEPROM_NIC_TYPE];
@@ -704,44 +711,50 @@ static ssize_t show_nic_type(struct device *d,
704 711
705 return sprintf(buf, "UNKNOWN\n"); 712 return sprintf(buf, "UNKNOWN\n");
706} 713}
714
707static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL); 715static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL);
708 716
709static ssize_t dump_error_log(struct device *d, 717static ssize_t dump_error_log(struct device *d,
710 struct device_attribute *attr, const char *buf, size_t count) 718 struct device_attribute *attr, const char *buf,
719 size_t count)
711{ 720{
712 char *p = (char *)buf; 721 char *p = (char *)buf;
713 722
714 if (p[0] == '1') 723 if (p[0] == '1')
715 ipw_dump_nic_error_log((struct ipw_priv*)d->driver_data); 724 ipw_dump_nic_error_log((struct ipw_priv *)d->driver_data);
716 725
717 return strnlen(buf, count); 726 return strnlen(buf, count);
718} 727}
728
719static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); 729static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log);
720 730
721static ssize_t dump_event_log(struct device *d, 731static ssize_t dump_event_log(struct device *d,
722 struct device_attribute *attr, const char *buf, size_t count) 732 struct device_attribute *attr, const char *buf,
733 size_t count)
723{ 734{
724 char *p = (char *)buf; 735 char *p = (char *)buf;
725 736
726 if (p[0] == '1') 737 if (p[0] == '1')
727 ipw_dump_nic_event_log((struct ipw_priv*)d->driver_data); 738 ipw_dump_nic_event_log((struct ipw_priv *)d->driver_data);
728 739
729 return strnlen(buf, count); 740 return strnlen(buf, count);
730} 741}
742
731static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); 743static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log);
732 744
733static ssize_t show_ucode_version(struct device *d, 745static ssize_t show_ucode_version(struct device *d,
734 struct device_attribute *attr, char *buf) 746 struct device_attribute *attr, char *buf)
735{ 747{
736 u32 len = sizeof(u32), tmp = 0; 748 u32 len = sizeof(u32), tmp = 0;
737 struct ipw_priv *p = d->driver_data; 749 struct ipw_priv *p = d->driver_data;
738 750
739 if(ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) 751 if (ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len))
740 return 0; 752 return 0;
741 753
742 return sprintf(buf, "0x%08x\n", tmp); 754 return sprintf(buf, "0x%08x\n", tmp);
743} 755}
744static DEVICE_ATTR(ucode_version, S_IWUSR|S_IRUGO, show_ucode_version, NULL); 756
757static DEVICE_ATTR(ucode_version, S_IWUSR | S_IRUGO, show_ucode_version, NULL);
745 758
746static ssize_t show_rtc(struct device *d, struct device_attribute *attr, 759static ssize_t show_rtc(struct device *d, struct device_attribute *attr,
747 char *buf) 760 char *buf)
@@ -749,36 +762,38 @@ static ssize_t show_rtc(struct device *d, struct device_attribute *attr,
749 u32 len = sizeof(u32), tmp = 0; 762 u32 len = sizeof(u32), tmp = 0;
750 struct ipw_priv *p = d->driver_data; 763 struct ipw_priv *p = d->driver_data;
751 764
752 if(ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) 765 if (ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len))
753 return 0; 766 return 0;
754 767
755 return sprintf(buf, "0x%08x\n", tmp); 768 return sprintf(buf, "0x%08x\n", tmp);
756} 769}
757static DEVICE_ATTR(rtc, S_IWUSR|S_IRUGO, show_rtc, NULL); 770
771static DEVICE_ATTR(rtc, S_IWUSR | S_IRUGO, show_rtc, NULL);
758 772
759/* 773/*
760 * Add a device attribute to view/control the delay between eeprom 774 * Add a device attribute to view/control the delay between eeprom
761 * operations. 775 * operations.
762 */ 776 */
763static ssize_t show_eeprom_delay(struct device *d, 777static ssize_t show_eeprom_delay(struct device *d,
764 struct device_attribute *attr, char *buf) 778 struct device_attribute *attr, char *buf)
765{ 779{
766 int n = ((struct ipw_priv*)d->driver_data)->eeprom_delay; 780 int n = ((struct ipw_priv *)d->driver_data)->eeprom_delay;
767 return sprintf(buf, "%i\n", n); 781 return sprintf(buf, "%i\n", n);
768} 782}
769static ssize_t store_eeprom_delay(struct device *d, 783static ssize_t store_eeprom_delay(struct device *d,
770 struct device_attribute *attr, const char *buf, 784 struct device_attribute *attr,
771 size_t count) 785 const char *buf, size_t count)
772{ 786{
773 struct ipw_priv *p = d->driver_data; 787 struct ipw_priv *p = d->driver_data;
774 sscanf(buf, "%i", &p->eeprom_delay); 788 sscanf(buf, "%i", &p->eeprom_delay);
775 return strnlen(buf, count); 789 return strnlen(buf, count);
776} 790}
777static DEVICE_ATTR(eeprom_delay, S_IWUSR|S_IRUGO, 791
778 show_eeprom_delay,store_eeprom_delay); 792static DEVICE_ATTR(eeprom_delay, S_IWUSR | S_IRUGO,
793 show_eeprom_delay, store_eeprom_delay);
779 794
780static ssize_t show_command_event_reg(struct device *d, 795static ssize_t show_command_event_reg(struct device *d,
781 struct device_attribute *attr, char *buf) 796 struct device_attribute *attr, char *buf)
782{ 797{
783 u32 reg = 0; 798 u32 reg = 0;
784 struct ipw_priv *p = d->driver_data; 799 struct ipw_priv *p = d->driver_data;
@@ -787,8 +802,8 @@ static ssize_t show_command_event_reg(struct device *d,
787 return sprintf(buf, "0x%08x\n", reg); 802 return sprintf(buf, "0x%08x\n", reg);
788} 803}
789static ssize_t store_command_event_reg(struct device *d, 804static ssize_t store_command_event_reg(struct device *d,
790 struct device_attribute *attr, const char *buf, 805 struct device_attribute *attr,
791 size_t count) 806 const char *buf, size_t count)
792{ 807{
793 u32 reg; 808 u32 reg;
794 struct ipw_priv *p = d->driver_data; 809 struct ipw_priv *p = d->driver_data;
@@ -797,11 +812,12 @@ static ssize_t store_command_event_reg(struct device *d,
797 ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg); 812 ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg);
798 return strnlen(buf, count); 813 return strnlen(buf, count);
799} 814}
800static DEVICE_ATTR(command_event_reg, S_IWUSR|S_IRUGO, 815
801 show_command_event_reg,store_command_event_reg); 816static DEVICE_ATTR(command_event_reg, S_IWUSR | S_IRUGO,
817 show_command_event_reg, store_command_event_reg);
802 818
803static ssize_t show_mem_gpio_reg(struct device *d, 819static ssize_t show_mem_gpio_reg(struct device *d,
804 struct device_attribute *attr, char *buf) 820 struct device_attribute *attr, char *buf)
805{ 821{
806 u32 reg = 0; 822 u32 reg = 0;
807 struct ipw_priv *p = d->driver_data; 823 struct ipw_priv *p = d->driver_data;
@@ -810,8 +826,8 @@ static ssize_t show_mem_gpio_reg(struct device *d,
810 return sprintf(buf, "0x%08x\n", reg); 826 return sprintf(buf, "0x%08x\n", reg);
811} 827}
812static ssize_t store_mem_gpio_reg(struct device *d, 828static ssize_t store_mem_gpio_reg(struct device *d,
813 struct device_attribute *attr, const char *buf, 829 struct device_attribute *attr,
814 size_t count) 830 const char *buf, size_t count)
815{ 831{
816 u32 reg; 832 u32 reg;
817 struct ipw_priv *p = d->driver_data; 833 struct ipw_priv *p = d->driver_data;
@@ -820,11 +836,12 @@ static ssize_t store_mem_gpio_reg(struct device *d,
820 ipw_write_reg32(p, 0x301100, reg); 836 ipw_write_reg32(p, 0x301100, reg);
821 return strnlen(buf, count); 837 return strnlen(buf, count);
822} 838}
823static DEVICE_ATTR(mem_gpio_reg, S_IWUSR|S_IRUGO, 839
824 show_mem_gpio_reg,store_mem_gpio_reg); 840static DEVICE_ATTR(mem_gpio_reg, S_IWUSR | S_IRUGO,
841 show_mem_gpio_reg, store_mem_gpio_reg);
825 842
826static ssize_t show_indirect_dword(struct device *d, 843static ssize_t show_indirect_dword(struct device *d,
827 struct device_attribute *attr, char *buf) 844 struct device_attribute *attr, char *buf)
828{ 845{
829 u32 reg = 0; 846 u32 reg = 0;
830 struct ipw_priv *priv = d->driver_data; 847 struct ipw_priv *priv = d->driver_data;
@@ -836,8 +853,8 @@ static ssize_t show_indirect_dword(struct device *d,
836 return sprintf(buf, "0x%08x\n", reg); 853 return sprintf(buf, "0x%08x\n", reg);
837} 854}
838static ssize_t store_indirect_dword(struct device *d, 855static ssize_t store_indirect_dword(struct device *d,
839 struct device_attribute *attr, const char *buf, 856 struct device_attribute *attr,
840 size_t count) 857 const char *buf, size_t count)
841{ 858{
842 struct ipw_priv *priv = d->driver_data; 859 struct ipw_priv *priv = d->driver_data;
843 860
@@ -845,11 +862,12 @@ static ssize_t store_indirect_dword(struct device *d,
845 priv->status |= STATUS_INDIRECT_DWORD; 862 priv->status |= STATUS_INDIRECT_DWORD;
846 return strnlen(buf, count); 863 return strnlen(buf, count);
847} 864}
848static DEVICE_ATTR(indirect_dword, S_IWUSR|S_IRUGO, 865
849 show_indirect_dword,store_indirect_dword); 866static DEVICE_ATTR(indirect_dword, S_IWUSR | S_IRUGO,
867 show_indirect_dword, store_indirect_dword);
850 868
851static ssize_t show_indirect_byte(struct device *d, 869static ssize_t show_indirect_byte(struct device *d,
852 struct device_attribute *attr, char *buf) 870 struct device_attribute *attr, char *buf)
853{ 871{
854 u8 reg = 0; 872 u8 reg = 0;
855 struct ipw_priv *priv = d->driver_data; 873 struct ipw_priv *priv = d->driver_data;
@@ -861,8 +879,8 @@ static ssize_t show_indirect_byte(struct device *d,
861 return sprintf(buf, "0x%02x\n", reg); 879 return sprintf(buf, "0x%02x\n", reg);
862} 880}
863static ssize_t store_indirect_byte(struct device *d, 881static ssize_t store_indirect_byte(struct device *d,
864 struct device_attribute *attr, const char *buf, 882 struct device_attribute *attr,
865 size_t count) 883 const char *buf, size_t count)
866{ 884{
867 struct ipw_priv *priv = d->driver_data; 885 struct ipw_priv *priv = d->driver_data;
868 886
@@ -870,11 +888,12 @@ static ssize_t store_indirect_byte(struct device *d,
870 priv->status |= STATUS_INDIRECT_BYTE; 888 priv->status |= STATUS_INDIRECT_BYTE;
871 return strnlen(buf, count); 889 return strnlen(buf, count);
872} 890}
873static DEVICE_ATTR(indirect_byte, S_IWUSR|S_IRUGO, 891
892static DEVICE_ATTR(indirect_byte, S_IWUSR | S_IRUGO,
874 show_indirect_byte, store_indirect_byte); 893 show_indirect_byte, store_indirect_byte);
875 894
876static ssize_t show_direct_dword(struct device *d, 895static ssize_t show_direct_dword(struct device *d,
877 struct device_attribute *attr, char *buf) 896 struct device_attribute *attr, char *buf)
878{ 897{
879 u32 reg = 0; 898 u32 reg = 0;
880 struct ipw_priv *priv = d->driver_data; 899 struct ipw_priv *priv = d->driver_data;
@@ -887,8 +906,8 @@ static ssize_t show_direct_dword(struct device *d,
887 return sprintf(buf, "0x%08x\n", reg); 906 return sprintf(buf, "0x%08x\n", reg);
888} 907}
889static ssize_t store_direct_dword(struct device *d, 908static ssize_t store_direct_dword(struct device *d,
890 struct device_attribute *attr, const char *buf, 909 struct device_attribute *attr,
891 size_t count) 910 const char *buf, size_t count)
892{ 911{
893 struct ipw_priv *priv = d->driver_data; 912 struct ipw_priv *priv = d->driver_data;
894 913
@@ -896,9 +915,9 @@ static ssize_t store_direct_dword(struct device *d,
896 priv->status |= STATUS_DIRECT_DWORD; 915 priv->status |= STATUS_DIRECT_DWORD;
897 return strnlen(buf, count); 916 return strnlen(buf, count);
898} 917}
899static DEVICE_ATTR(direct_dword, S_IWUSR|S_IRUGO,
900 show_direct_dword,store_direct_dword);
901 918
919static DEVICE_ATTR(direct_dword, S_IWUSR | S_IRUGO,
920 show_direct_dword, store_direct_dword);
902 921
903static inline int rf_kill_active(struct ipw_priv *priv) 922static inline int rf_kill_active(struct ipw_priv *priv)
904{ 923{
@@ -911,7 +930,7 @@ static inline int rf_kill_active(struct ipw_priv *priv)
911} 930}
912 931
913static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 932static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
914 char *buf) 933 char *buf)
915{ 934{
916 /* 0 - RF kill not enabled 935 /* 0 - RF kill not enabled
917 1 - SW based RF kill active (sysfs) 936 1 - SW based RF kill active (sysfs)
@@ -919,7 +938,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
919 3 - Both HW and SW baed RF kill active */ 938 3 - Both HW and SW baed RF kill active */
920 struct ipw_priv *priv = d->driver_data; 939 struct ipw_priv *priv = d->driver_data;
921 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | 940 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
922 (rf_kill_active(priv) ? 0x2 : 0x0); 941 (rf_kill_active(priv) ? 0x2 : 0x0);
923 return sprintf(buf, "%i\n", val); 942 return sprintf(buf, "%i\n", val);
924} 943}
925 944
@@ -927,7 +946,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio)
927{ 946{
928 if ((disable_radio ? 1 : 0) == 947 if ((disable_radio ? 1 : 0) ==
929 (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) 948 (priv->status & STATUS_RF_KILL_SW ? 1 : 0))
930 return 0 ; 949 return 0;
931 950
932 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", 951 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n",
933 disable_radio ? "OFF" : "ON"); 952 disable_radio ? "OFF" : "ON");
@@ -956,8 +975,8 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio)
956 return 1; 975 return 1;
957} 976}
958 977
959static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, 978static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
960 const char *buf, size_t count) 979 const char *buf, size_t count)
961{ 980{
962 struct ipw_priv *priv = d->driver_data; 981 struct ipw_priv *priv = d->driver_data;
963 982
@@ -965,7 +984,8 @@ static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
965 984
966 return count; 985 return count;
967} 986}
968static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill); 987
988static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);
969 989
970static void ipw_irq_tasklet(struct ipw_priv *priv) 990static void ipw_irq_tasklet(struct ipw_priv *priv)
971{ 991{
@@ -990,7 +1010,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
990 1010
991 if (inta & CX2_INTA_BIT_TX_CMD_QUEUE) { 1011 if (inta & CX2_INTA_BIT_TX_CMD_QUEUE) {
992 IPW_DEBUG_HC("Command completed.\n"); 1012 IPW_DEBUG_HC("Command completed.\n");
993 rc = ipw_queue_tx_reclaim( priv, &priv->txq_cmd, -1); 1013 rc = ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1);
994 priv->status &= ~STATUS_HCMD_ACTIVE; 1014 priv->status &= ~STATUS_HCMD_ACTIVE;
995 wake_up_interruptible(&priv->wait_command_queue); 1015 wake_up_interruptible(&priv->wait_command_queue);
996 handled |= CX2_INTA_BIT_TX_CMD_QUEUE; 1016 handled |= CX2_INTA_BIT_TX_CMD_QUEUE;
@@ -998,25 +1018,25 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
998 1018
999 if (inta & CX2_INTA_BIT_TX_QUEUE_1) { 1019 if (inta & CX2_INTA_BIT_TX_QUEUE_1) {
1000 IPW_DEBUG_TX("TX_QUEUE_1\n"); 1020 IPW_DEBUG_TX("TX_QUEUE_1\n");
1001 rc = ipw_queue_tx_reclaim( priv, &priv->txq[0], 0); 1021 rc = ipw_queue_tx_reclaim(priv, &priv->txq[0], 0);
1002 handled |= CX2_INTA_BIT_TX_QUEUE_1; 1022 handled |= CX2_INTA_BIT_TX_QUEUE_1;
1003 } 1023 }
1004 1024
1005 if (inta & CX2_INTA_BIT_TX_QUEUE_2) { 1025 if (inta & CX2_INTA_BIT_TX_QUEUE_2) {
1006 IPW_DEBUG_TX("TX_QUEUE_2\n"); 1026 IPW_DEBUG_TX("TX_QUEUE_2\n");
1007 rc = ipw_queue_tx_reclaim( priv, &priv->txq[1], 1); 1027 rc = ipw_queue_tx_reclaim(priv, &priv->txq[1], 1);
1008 handled |= CX2_INTA_BIT_TX_QUEUE_2; 1028 handled |= CX2_INTA_BIT_TX_QUEUE_2;
1009 } 1029 }
1010 1030
1011 if (inta & CX2_INTA_BIT_TX_QUEUE_3) { 1031 if (inta & CX2_INTA_BIT_TX_QUEUE_3) {
1012 IPW_DEBUG_TX("TX_QUEUE_3\n"); 1032 IPW_DEBUG_TX("TX_QUEUE_3\n");
1013 rc = ipw_queue_tx_reclaim( priv, &priv->txq[2], 2); 1033 rc = ipw_queue_tx_reclaim(priv, &priv->txq[2], 2);
1014 handled |= CX2_INTA_BIT_TX_QUEUE_3; 1034 handled |= CX2_INTA_BIT_TX_QUEUE_3;
1015 } 1035 }
1016 1036
1017 if (inta & CX2_INTA_BIT_TX_QUEUE_4) { 1037 if (inta & CX2_INTA_BIT_TX_QUEUE_4) {
1018 IPW_DEBUG_TX("TX_QUEUE_4\n"); 1038 IPW_DEBUG_TX("TX_QUEUE_4\n");
1019 rc = ipw_queue_tx_reclaim( priv, &priv->txq[3], 3); 1039 rc = ipw_queue_tx_reclaim(priv, &priv->txq[3], 3);
1020 handled |= CX2_INTA_BIT_TX_QUEUE_4; 1040 handled |= CX2_INTA_BIT_TX_QUEUE_4;
1021 } 1041 }
1022 1042
@@ -1074,8 +1094,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
1074 } 1094 }
1075 1095
1076 if (handled != inta) { 1096 if (handled != inta) {
1077 IPW_ERROR("Unhandled INTA bits 0x%08x\n", 1097 IPW_ERROR("Unhandled INTA bits 0x%08x\n", inta & ~handled);
1078 inta & ~handled);
1079 } 1098 }
1080 1099
1081 /* enable all interrupts */ 1100 /* enable all interrupts */
@@ -1143,7 +1162,7 @@ static char *get_cmd_string(u8 cmd)
1143 return "UNKNOWN"; 1162 return "UNKNOWN";
1144 } 1163 }
1145} 1164}
1146#endif /* CONFIG_IPW_DEBUG */ 1165#endif /* CONFIG_IPW_DEBUG */
1147 1166
1148#define HOST_COMPLETE_TIMEOUT HZ 1167#define HOST_COMPLETE_TIMEOUT HZ
1149static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) 1168static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
@@ -1159,15 +1178,16 @@ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1159 1178
1160 IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", 1179 IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n",
1161 get_cmd_string(cmd->cmd), cmd->cmd, cmd->len); 1180 get_cmd_string(cmd->cmd), cmd->cmd, cmd->len);
1162 printk_buf(IPW_DL_HOST_COMMAND, (u8*)cmd->param, cmd->len); 1181 printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len);
1163 1182
1164 rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0); 1183 rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0);
1165 if (rc) 1184 if (rc)
1166 return rc; 1185 return rc;
1167 1186
1168 rc = wait_event_interruptible_timeout( 1187 rc = wait_event_interruptible_timeout(priv->wait_command_queue,
1169 priv->wait_command_queue, !(priv->status & STATUS_HCMD_ACTIVE), 1188 !(priv->
1170 HOST_COMPLETE_TIMEOUT); 1189 status & STATUS_HCMD_ACTIVE),
1190 HOST_COMPLETE_TIMEOUT);
1171 if (rc == 0) { 1191 if (rc == 0) {
1172 IPW_DEBUG_INFO("Command completion failed out after %dms.\n", 1192 IPW_DEBUG_INFO("Command completion failed out after %dms.\n",
1173 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); 1193 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
@@ -1215,7 +1235,7 @@ static int ipw_send_system_config(struct ipw_priv *priv,
1215 return -1; 1235 return -1;
1216 } 1236 }
1217 1237
1218 memcpy(&cmd.param,config,sizeof(*config)); 1238 memcpy(&cmd.param, config, sizeof(*config));
1219 if (ipw_send_cmd(priv, &cmd)) { 1239 if (ipw_send_cmd(priv, &cmd)) {
1220 IPW_ERROR("failed to send SYSTEM_CONFIG command\n"); 1240 IPW_ERROR("failed to send SYSTEM_CONFIG command\n");
1221 return -1; 1241 return -1;
@@ -1224,7 +1244,7 @@ static int ipw_send_system_config(struct ipw_priv *priv,
1224 return 0; 1244 return 0;
1225} 1245}
1226 1246
1227static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len) 1247static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
1228{ 1248{
1229 struct host_cmd cmd = { 1249 struct host_cmd cmd = {
1230 .cmd = IPW_CMD_SSID, 1250 .cmd = IPW_CMD_SSID,
@@ -1245,7 +1265,7 @@ static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len)
1245 return 0; 1265 return 0;
1246} 1266}
1247 1267
1248static int ipw_send_adapter_address(struct ipw_priv *priv, u8 *mac) 1268static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
1249{ 1269{
1250 struct host_cmd cmd = { 1270 struct host_cmd cmd = {
1251 .cmd = IPW_CMD_ADAPTER_ADDRESS, 1271 .cmd = IPW_CMD_ADAPTER_ADDRESS,
@@ -1284,9 +1304,6 @@ static void ipw_adapter_restart(void *adapter)
1284 } 1304 }
1285} 1305}
1286 1306
1287
1288
1289
1290#define IPW_SCAN_CHECK_WATCHDOG (5 * HZ) 1307#define IPW_SCAN_CHECK_WATCHDOG (5 * HZ)
1291 1308
1292static void ipw_scan_check(void *data) 1309static void ipw_scan_check(void *data)
@@ -1313,7 +1330,7 @@ static int ipw_send_scan_request_ext(struct ipw_priv *priv,
1313 return -1; 1330 return -1;
1314 } 1331 }
1315 1332
1316 memcpy(&cmd.param,request,sizeof(*request)); 1333 memcpy(&cmd.param, request, sizeof(*request));
1317 if (ipw_send_cmd(priv, &cmd)) { 1334 if (ipw_send_cmd(priv, &cmd)) {
1318 IPW_ERROR("failed to send SCAN_REQUEST_EXT command\n"); 1335 IPW_ERROR("failed to send SCAN_REQUEST_EXT command\n");
1319 return -1; 1336 return -1;
@@ -1351,7 +1368,7 @@ static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens)
1351 .len = sizeof(struct ipw_sensitivity_calib) 1368 .len = sizeof(struct ipw_sensitivity_calib)
1352 }; 1369 };
1353 struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *) 1370 struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *)
1354 &cmd.param; 1371 &cmd.param;
1355 calib->beacon_rssi_raw = sens; 1372 calib->beacon_rssi_raw = sens;
1356 if (ipw_send_cmd(priv, &cmd)) { 1373 if (ipw_send_cmd(priv, &cmd)) {
1357 IPW_ERROR("failed to send SENSITIVITY CALIB command\n"); 1374 IPW_ERROR("failed to send SENSITIVITY CALIB command\n");
@@ -1374,7 +1391,7 @@ static int ipw_send_associate(struct ipw_priv *priv,
1374 return -1; 1391 return -1;
1375 } 1392 }
1376 1393
1377 memcpy(&cmd.param,associate,sizeof(*associate)); 1394 memcpy(&cmd.param, associate, sizeof(*associate));
1378 if (ipw_send_cmd(priv, &cmd)) { 1395 if (ipw_send_cmd(priv, &cmd)) {
1379 IPW_ERROR("failed to send ASSOCIATE command\n"); 1396 IPW_ERROR("failed to send ASSOCIATE command\n");
1380 return -1; 1397 return -1;
@@ -1396,7 +1413,7 @@ static int ipw_send_supported_rates(struct ipw_priv *priv,
1396 return -1; 1413 return -1;
1397 } 1414 }
1398 1415
1399 memcpy(&cmd.param,rates,sizeof(*rates)); 1416 memcpy(&cmd.param, rates, sizeof(*rates));
1400 if (ipw_send_cmd(priv, &cmd)) { 1417 if (ipw_send_cmd(priv, &cmd)) {
1401 IPW_ERROR("failed to send SUPPORTED_RATES command\n"); 1418 IPW_ERROR("failed to send SUPPORTED_RATES command\n");
1402 return -1; 1419 return -1;
@@ -1440,7 +1457,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off)
1440 return -1; 1457 return -1;
1441 } 1458 }
1442 1459
1443 *((u32*)&cmd.param) = phy_off; 1460 *((u32 *) & cmd.param) = phy_off;
1444 1461
1445 if (ipw_send_cmd(priv, &cmd)) { 1462 if (ipw_send_cmd(priv, &cmd)) {
1446 IPW_ERROR("failed to send CARD_DISABLE command\n"); 1463 IPW_ERROR("failed to send CARD_DISABLE command\n");
@@ -1451,8 +1468,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off)
1451} 1468}
1452#endif 1469#endif
1453 1470
1454static int ipw_send_tx_power(struct ipw_priv *priv, 1471static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power)
1455 struct ipw_tx_power *power)
1456{ 1472{
1457 struct host_cmd cmd = { 1473 struct host_cmd cmd = {
1458 .cmd = IPW_CMD_TX_POWER, 1474 .cmd = IPW_CMD_TX_POWER,
@@ -1464,7 +1480,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv,
1464 return -1; 1480 return -1;
1465 } 1481 }
1466 1482
1467 memcpy(&cmd.param,power,sizeof(*power)); 1483 memcpy(&cmd.param, power, sizeof(*power));
1468 if (ipw_send_cmd(priv, &cmd)) { 1484 if (ipw_send_cmd(priv, &cmd)) {
1469 IPW_ERROR("failed to send TX_POWER command\n"); 1485 IPW_ERROR("failed to send TX_POWER command\n");
1470 return -1; 1486 return -1;
@@ -1527,7 +1543,7 @@ static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode)
1527 .cmd = IPW_CMD_POWER_MODE, 1543 .cmd = IPW_CMD_POWER_MODE,
1528 .len = sizeof(u32) 1544 .len = sizeof(u32)
1529 }; 1545 };
1530 u32 *param = (u32*)(&cmd.param); 1546 u32 *param = (u32 *) (&cmd.param);
1531 1547
1532 if (!priv) { 1548 if (!priv) {
1533 IPW_ERROR("Invalid args\n"); 1549 IPW_ERROR("Invalid args\n");
@@ -1585,67 +1601,67 @@ static inline void eeprom_write_reg(struct ipw_priv *p, u32 data)
1585} 1601}
1586 1602
1587/* perform a chip select operation */ 1603/* perform a chip select operation */
1588static inline void eeprom_cs(struct ipw_priv* priv) 1604static inline void eeprom_cs(struct ipw_priv *priv)
1589{ 1605{
1590 eeprom_write_reg(priv,0); 1606 eeprom_write_reg(priv, 0);
1591 eeprom_write_reg(priv,EEPROM_BIT_CS); 1607 eeprom_write_reg(priv, EEPROM_BIT_CS);
1592 eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); 1608 eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK);
1593 eeprom_write_reg(priv,EEPROM_BIT_CS); 1609 eeprom_write_reg(priv, EEPROM_BIT_CS);
1594} 1610}
1595 1611
1596/* perform a chip select operation */ 1612/* perform a chip select operation */
1597static inline void eeprom_disable_cs(struct ipw_priv* priv) 1613static inline void eeprom_disable_cs(struct ipw_priv *priv)
1598{ 1614{
1599 eeprom_write_reg(priv,EEPROM_BIT_CS); 1615 eeprom_write_reg(priv, EEPROM_BIT_CS);
1600 eeprom_write_reg(priv,0); 1616 eeprom_write_reg(priv, 0);
1601 eeprom_write_reg(priv,EEPROM_BIT_SK); 1617 eeprom_write_reg(priv, EEPROM_BIT_SK);
1602} 1618}
1603 1619
1604/* push a single bit down to the eeprom */ 1620/* push a single bit down to the eeprom */
1605static inline void eeprom_write_bit(struct ipw_priv *p,u8 bit) 1621static inline void eeprom_write_bit(struct ipw_priv *p, u8 bit)
1606{ 1622{
1607 int d = ( bit ? EEPROM_BIT_DI : 0); 1623 int d = (bit ? EEPROM_BIT_DI : 0);
1608 eeprom_write_reg(p,EEPROM_BIT_CS|d); 1624 eeprom_write_reg(p, EEPROM_BIT_CS | d);
1609 eeprom_write_reg(p,EEPROM_BIT_CS|d|EEPROM_BIT_SK); 1625 eeprom_write_reg(p, EEPROM_BIT_CS | d | EEPROM_BIT_SK);
1610} 1626}
1611 1627
1612/* push an opcode followed by an address down to the eeprom */ 1628/* push an opcode followed by an address down to the eeprom */
1613static void eeprom_op(struct ipw_priv* priv, u8 op, u8 addr) 1629static void eeprom_op(struct ipw_priv *priv, u8 op, u8 addr)
1614{ 1630{
1615 int i; 1631 int i;
1616 1632
1617 eeprom_cs(priv); 1633 eeprom_cs(priv);
1618 eeprom_write_bit(priv,1); 1634 eeprom_write_bit(priv, 1);
1619 eeprom_write_bit(priv,op&2); 1635 eeprom_write_bit(priv, op & 2);
1620 eeprom_write_bit(priv,op&1); 1636 eeprom_write_bit(priv, op & 1);
1621 for ( i=7; i>=0; i-- ) { 1637 for (i = 7; i >= 0; i--) {
1622 eeprom_write_bit(priv,addr&(1<<i)); 1638 eeprom_write_bit(priv, addr & (1 << i));
1623 } 1639 }
1624} 1640}
1625 1641
1626/* pull 16 bits off the eeprom, one bit at a time */ 1642/* pull 16 bits off the eeprom, one bit at a time */
1627static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr) 1643static u16 eeprom_read_u16(struct ipw_priv *priv, u8 addr)
1628{ 1644{
1629 int i; 1645 int i;
1630 u16 r=0; 1646 u16 r = 0;
1631 1647
1632 /* Send READ Opcode */ 1648 /* Send READ Opcode */
1633 eeprom_op(priv,EEPROM_CMD_READ,addr); 1649 eeprom_op(priv, EEPROM_CMD_READ, addr);
1634 1650
1635 /* Send dummy bit */ 1651 /* Send dummy bit */
1636 eeprom_write_reg(priv,EEPROM_BIT_CS); 1652 eeprom_write_reg(priv, EEPROM_BIT_CS);
1637 1653
1638 /* Read the byte off the eeprom one bit at a time */ 1654 /* Read the byte off the eeprom one bit at a time */
1639 for ( i=0; i<16; i++ ) { 1655 for (i = 0; i < 16; i++) {
1640 u32 data = 0; 1656 u32 data = 0;
1641 eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); 1657 eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK);
1642 eeprom_write_reg(priv,EEPROM_BIT_CS); 1658 eeprom_write_reg(priv, EEPROM_BIT_CS);
1643 data = ipw_read_reg32(priv,FW_MEM_REG_EEPROM_ACCESS); 1659 data = ipw_read_reg32(priv, FW_MEM_REG_EEPROM_ACCESS);
1644 r = (r<<1) | ((data & EEPROM_BIT_DO)?1:0); 1660 r = (r << 1) | ((data & EEPROM_BIT_DO) ? 1 : 0);
1645 } 1661 }
1646 1662
1647 /* Send another dummy bit */ 1663 /* Send another dummy bit */
1648 eeprom_write_reg(priv,0); 1664 eeprom_write_reg(priv, 0);
1649 eeprom_disable_cs(priv); 1665 eeprom_disable_cs(priv);
1650 1666
1651 return r; 1667 return r;
@@ -1653,9 +1669,9 @@ static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr)
1653 1669
1654/* helper function for pulling the mac address out of the private */ 1670/* helper function for pulling the mac address out of the private */
1655/* data's copy of the eeprom data */ 1671/* data's copy of the eeprom data */
1656static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac) 1672static void eeprom_parse_mac(struct ipw_priv *priv, u8 * mac)
1657{ 1673{
1658 u8* ee = (u8*)priv->eeprom; 1674 u8 *ee = (u8 *) priv->eeprom;
1659 memcpy(mac, &ee[EEPROM_MAC_ADDRESS], 6); 1675 memcpy(mac, &ee[EEPROM_MAC_ADDRESS], 6);
1660} 1676}
1661 1677
@@ -1670,26 +1686,25 @@ static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac)
1670static void ipw_eeprom_init_sram(struct ipw_priv *priv) 1686static void ipw_eeprom_init_sram(struct ipw_priv *priv)
1671{ 1687{
1672 int i; 1688 int i;
1673 u16 *eeprom = (u16 *)priv->eeprom; 1689 u16 *eeprom = (u16 *) priv->eeprom;
1674 1690
1675 IPW_DEBUG_TRACE(">>\n"); 1691 IPW_DEBUG_TRACE(">>\n");
1676 1692
1677 /* read entire contents of eeprom into private buffer */ 1693 /* read entire contents of eeprom into private buffer */
1678 for ( i=0; i<128; i++ ) 1694 for (i = 0; i < 128; i++)
1679 eeprom[i] = eeprom_read_u16(priv,(u8)i); 1695 eeprom[i] = eeprom_read_u16(priv, (u8) i);
1680 1696
1681 /* 1697 /*
1682 If the data looks correct, then copy it to our private 1698 If the data looks correct, then copy it to our private
1683 copy. Otherwise let the firmware know to perform the operation 1699 copy. Otherwise let the firmware know to perform the operation
1684 on it's own 1700 on it's own
1685 */ 1701 */
1686 if ((priv->eeprom + EEPROM_VERSION) != 0) { 1702 if ((priv->eeprom + EEPROM_VERSION) != 0) {
1687 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); 1703 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
1688 1704
1689 /* write the eeprom data to sram */ 1705 /* write the eeprom data to sram */
1690 for( i=0; i<CX2_EEPROM_IMAGE_SIZE; i++ ) 1706 for (i = 0; i < CX2_EEPROM_IMAGE_SIZE; i++)
1691 ipw_write8(priv, IPW_EEPROM_DATA + i, 1707 ipw_write8(priv, IPW_EEPROM_DATA + i, priv->eeprom[i]);
1692 priv->eeprom[i]);
1693 1708
1694 /* Do not load eeprom data on fatal error or suspend */ 1709 /* Do not load eeprom data on fatal error or suspend */
1695 ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0); 1710 ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0);
@@ -1703,11 +1718,11 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv)
1703 IPW_DEBUG_TRACE("<<\n"); 1718 IPW_DEBUG_TRACE("<<\n");
1704} 1719}
1705 1720
1706
1707static inline void ipw_zero_memory(struct ipw_priv *priv, u32 start, u32 count) 1721static inline void ipw_zero_memory(struct ipw_priv *priv, u32 start, u32 count)
1708{ 1722{
1709 count >>= 2; 1723 count >>= 2;
1710 if (!count) return; 1724 if (!count)
1725 return;
1711 _ipw_write32(priv, CX2_AUTOINC_ADDR, start); 1726 _ipw_write32(priv, CX2_AUTOINC_ADDR, start);
1712 while (count--) 1727 while (count--)
1713 _ipw_write32(priv, CX2_AUTOINC_DATA, 0); 1728 _ipw_write32(priv, CX2_AUTOINC_DATA, 0);
@@ -1721,7 +1736,7 @@ static inline void ipw_fw_dma_reset_command_blocks(struct ipw_priv *priv)
1721} 1736}
1722 1737
1723static int ipw_fw_dma_enable(struct ipw_priv *priv) 1738static int ipw_fw_dma_enable(struct ipw_priv *priv)
1724{ /* start dma engine but no transfers yet*/ 1739{ /* start dma engine but no transfers yet */
1725 1740
1726 IPW_DEBUG_FW(">> : \n"); 1741 IPW_DEBUG_FW(">> : \n");
1727 1742
@@ -1749,12 +1764,16 @@ static void ipw_fw_dma_abort(struct ipw_priv *priv)
1749 IPW_DEBUG_FW("<< \n"); 1764 IPW_DEBUG_FW("<< \n");
1750} 1765}
1751 1766
1752static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, struct command_block *cb) 1767static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index,
1768 struct command_block *cb)
1753{ 1769{
1754 u32 address = CX2_SHARED_SRAM_DMA_CONTROL + (sizeof(struct command_block) * index); 1770 u32 address =
1771 CX2_SHARED_SRAM_DMA_CONTROL +
1772 (sizeof(struct command_block) * index);
1755 IPW_DEBUG_FW(">> :\n"); 1773 IPW_DEBUG_FW(">> :\n");
1756 1774
1757 ipw_write_indirect(priv, address, (u8*)cb, (int)sizeof(struct command_block)); 1775 ipw_write_indirect(priv, address, (u8 *) cb,
1776 (int)sizeof(struct command_block));
1758 1777
1759 IPW_DEBUG_FW("<< :\n"); 1778 IPW_DEBUG_FW("<< :\n");
1760 return 0; 1779 return 0;
@@ -1764,17 +1783,20 @@ static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, stru
1764static int ipw_fw_dma_kick(struct ipw_priv *priv) 1783static int ipw_fw_dma_kick(struct ipw_priv *priv)
1765{ 1784{
1766 u32 control = 0; 1785 u32 control = 0;
1767 u32 index=0; 1786 u32 index = 0;
1768 1787
1769 IPW_DEBUG_FW(">> :\n"); 1788 IPW_DEBUG_FW(">> :\n");
1770 1789
1771 for (index = 0; index < priv->sram_desc.last_cb_index; index++) 1790 for (index = 0; index < priv->sram_desc.last_cb_index; index++)
1772 ipw_fw_dma_write_command_block(priv, index, &priv->sram_desc.cb_list[index]); 1791 ipw_fw_dma_write_command_block(priv, index,
1792 &priv->sram_desc.cb_list[index]);
1773 1793
1774 /* Enable the DMA in the CSR register */ 1794 /* Enable the DMA in the CSR register */
1775 ipw_clear_bit(priv, CX2_RESET_REG,CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); 1795 ipw_clear_bit(priv, CX2_RESET_REG,
1796 CX2_RESET_REG_MASTER_DISABLED |
1797 CX2_RESET_REG_STOP_MASTER);
1776 1798
1777 /* Set the Start bit. */ 1799 /* Set the Start bit. */
1778 control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_START; 1800 control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_START;
1779 ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control); 1801 ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control);
1780 1802
@@ -1785,25 +1807,25 @@ static int ipw_fw_dma_kick(struct ipw_priv *priv)
1785static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv) 1807static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv)
1786{ 1808{
1787 u32 address; 1809 u32 address;
1788 u32 register_value=0; 1810 u32 register_value = 0;
1789 u32 cb_fields_address=0; 1811 u32 cb_fields_address = 0;
1790 1812
1791 IPW_DEBUG_FW(">> :\n"); 1813 IPW_DEBUG_FW(">> :\n");
1792 address = ipw_read_reg32(priv,CX2_DMA_I_CURRENT_CB); 1814 address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB);
1793 IPW_DEBUG_FW_INFO("Current CB is 0x%x \n",address); 1815 IPW_DEBUG_FW_INFO("Current CB is 0x%x \n", address);
1794 1816
1795 /* Read the DMA Controlor register */ 1817 /* Read the DMA Controlor register */
1796 register_value = ipw_read_reg32(priv, CX2_DMA_I_DMA_CONTROL); 1818 register_value = ipw_read_reg32(priv, CX2_DMA_I_DMA_CONTROL);
1797 IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n",register_value); 1819 IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n", register_value);
1798 1820
1799 /* Print the CB values*/ 1821 /* Print the CB values */
1800 cb_fields_address = address; 1822 cb_fields_address = address;
1801 register_value = ipw_read_reg32(priv, cb_fields_address); 1823 register_value = ipw_read_reg32(priv, cb_fields_address);
1802 IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n",register_value); 1824 IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n", register_value);
1803 1825
1804 cb_fields_address += sizeof(u32); 1826 cb_fields_address += sizeof(u32);
1805 register_value = ipw_read_reg32(priv, cb_fields_address); 1827 register_value = ipw_read_reg32(priv, cb_fields_address);
1806 IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n",register_value); 1828 IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n", register_value);
1807 1829
1808 cb_fields_address += sizeof(u32); 1830 cb_fields_address += sizeof(u32);
1809 register_value = ipw_read_reg32(priv, cb_fields_address); 1831 register_value = ipw_read_reg32(priv, cb_fields_address);
@@ -1812,7 +1834,7 @@ static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv)
1812 1834
1813 cb_fields_address += sizeof(u32); 1835 cb_fields_address += sizeof(u32);
1814 register_value = ipw_read_reg32(priv, cb_fields_address); 1836 register_value = ipw_read_reg32(priv, cb_fields_address);
1815 IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n",register_value); 1837 IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n", register_value);
1816 1838
1817 IPW_DEBUG_FW(">> :\n"); 1839 IPW_DEBUG_FW(">> :\n");
1818} 1840}
@@ -1823,13 +1845,13 @@ static int ipw_fw_dma_command_block_index(struct ipw_priv *priv)
1823 u32 current_cb_index = 0; 1845 u32 current_cb_index = 0;
1824 1846
1825 IPW_DEBUG_FW("<< :\n"); 1847 IPW_DEBUG_FW("<< :\n");
1826 current_cb_address= ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); 1848 current_cb_address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB);
1827 1849
1828 current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL )/ 1850 current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL) /
1829 sizeof (struct command_block); 1851 sizeof(struct command_block);
1830 1852
1831 IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n", 1853 IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n",
1832 current_cb_index, current_cb_address ); 1854 current_cb_index, current_cb_address);
1833 1855
1834 IPW_DEBUG_FW(">> :\n"); 1856 IPW_DEBUG_FW(">> :\n");
1835 return current_cb_index; 1857 return current_cb_index;
@@ -1840,15 +1862,14 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
1840 u32 src_address, 1862 u32 src_address,
1841 u32 dest_address, 1863 u32 dest_address,
1842 u32 length, 1864 u32 length,
1843 int interrupt_enabled, 1865 int interrupt_enabled, int is_last)
1844 int is_last)
1845{ 1866{
1846 1867
1847 u32 control = CB_VALID | CB_SRC_LE | CB_DEST_LE | CB_SRC_AUTOINC | 1868 u32 control = CB_VALID | CB_SRC_LE | CB_DEST_LE | CB_SRC_AUTOINC |
1848 CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG | 1869 CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG |
1849 CB_DEST_SIZE_LONG; 1870 CB_DEST_SIZE_LONG;
1850 struct command_block *cb; 1871 struct command_block *cb;
1851 u32 last_cb_element=0; 1872 u32 last_cb_element = 0;
1852 1873
1853 IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n", 1874 IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n",
1854 src_address, dest_address, length); 1875 src_address, dest_address, length);
@@ -1861,7 +1882,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
1861 priv->sram_desc.last_cb_index++; 1882 priv->sram_desc.last_cb_index++;
1862 1883
1863 /* Calculate the new CB control word */ 1884 /* Calculate the new CB control word */
1864 if (interrupt_enabled ) 1885 if (interrupt_enabled)
1865 control |= CB_INT_ENABLED; 1886 control |= CB_INT_ENABLED;
1866 1887
1867 if (is_last) 1888 if (is_last)
@@ -1870,7 +1891,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
1870 control |= length; 1891 control |= length;
1871 1892
1872 /* Calculate the CB Element's checksum value */ 1893 /* Calculate the CB Element's checksum value */
1873 cb->status = control ^src_address ^dest_address; 1894 cb->status = control ^ src_address ^ dest_address;
1874 1895
1875 /* Copy the Source and Destination addresses */ 1896 /* Copy the Source and Destination addresses */
1876 cb->dest_addr = dest_address; 1897 cb->dest_addr = dest_address;
@@ -1883,22 +1904,21 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
1883} 1904}
1884 1905
1885static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, 1906static int ipw_fw_dma_add_buffer(struct ipw_priv *priv,
1886 u32 src_phys, 1907 u32 src_phys, u32 dest_address, u32 length)
1887 u32 dest_address,
1888 u32 length)
1889{ 1908{
1890 u32 bytes_left = length; 1909 u32 bytes_left = length;
1891 u32 src_offset=0; 1910 u32 src_offset = 0;
1892 u32 dest_offset=0; 1911 u32 dest_offset = 0;
1893 int status = 0; 1912 int status = 0;
1894 IPW_DEBUG_FW(">> \n"); 1913 IPW_DEBUG_FW(">> \n");
1895 IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n", 1914 IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n",
1896 src_phys, dest_address, length); 1915 src_phys, dest_address, length);
1897 while (bytes_left > CB_MAX_LENGTH) { 1916 while (bytes_left > CB_MAX_LENGTH) {
1898 status = ipw_fw_dma_add_command_block( priv, 1917 status = ipw_fw_dma_add_command_block(priv,
1899 src_phys + src_offset, 1918 src_phys + src_offset,
1900 dest_address + dest_offset, 1919 dest_address +
1901 CB_MAX_LENGTH, 0, 0); 1920 dest_offset,
1921 CB_MAX_LENGTH, 0, 0);
1902 if (status) { 1922 if (status) {
1903 IPW_DEBUG_FW_INFO(": Failed\n"); 1923 IPW_DEBUG_FW_INFO(": Failed\n");
1904 return -1; 1924 return -1;
@@ -1912,18 +1932,18 @@ static int ipw_fw_dma_add_buffer(struct ipw_priv *priv,
1912 1932
1913 /* add the buffer tail */ 1933 /* add the buffer tail */
1914 if (bytes_left > 0) { 1934 if (bytes_left > 0) {
1915 status = ipw_fw_dma_add_command_block( 1935 status =
1916 priv, src_phys + src_offset, 1936 ipw_fw_dma_add_command_block(priv, src_phys + src_offset,
1917 dest_address + dest_offset, 1937 dest_address + dest_offset,
1918 bytes_left, 0, 0); 1938 bytes_left, 0, 0);
1919 if (status) { 1939 if (status) {
1920 IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n"); 1940 IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");
1921 return -1; 1941 return -1;
1922 } else 1942 } else
1923 IPW_DEBUG_FW_INFO(": Adding new cb - the buffer tail\n"); 1943 IPW_DEBUG_FW_INFO
1944 (": Adding new cb - the buffer tail\n");
1924 } 1945 }
1925 1946
1926
1927 IPW_DEBUG_FW("<< \n"); 1947 IPW_DEBUG_FW("<< \n");
1928 return 0; 1948 return 0;
1929} 1949}
@@ -1937,7 +1957,7 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv)
1937 1957
1938 current_index = ipw_fw_dma_command_block_index(priv); 1958 current_index = ipw_fw_dma_command_block_index(priv);
1939 IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n", 1959 IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n",
1940 (int) priv->sram_desc.last_cb_index); 1960 (int)priv->sram_desc.last_cb_index);
1941 1961
1942 while (current_index < priv->sram_desc.last_cb_index) { 1962 while (current_index < priv->sram_desc.last_cb_index) {
1943 udelay(50); 1963 udelay(50);
@@ -1955,8 +1975,8 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv)
1955 1975
1956 ipw_fw_dma_abort(priv); 1976 ipw_fw_dma_abort(priv);
1957 1977
1958 /*Disable the DMA in the CSR register*/ 1978 /*Disable the DMA in the CSR register */
1959 ipw_set_bit(priv, CX2_RESET_REG, 1979 ipw_set_bit(priv, CX2_RESET_REG,
1960 CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); 1980 CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER);
1961 1981
1962 IPW_DEBUG_FW("<< dmaWaitSync \n"); 1982 IPW_DEBUG_FW("<< dmaWaitSync \n");
@@ -2011,8 +2031,7 @@ static inline int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask,
2011 * image and the caller is handling the memory allocation and clean up. 2031 * image and the caller is handling the memory allocation and clean up.
2012 */ 2032 */
2013 2033
2014 2034static int ipw_stop_master(struct ipw_priv *priv)
2015static int ipw_stop_master(struct ipw_priv * priv)
2016{ 2035{
2017 int rc; 2036 int rc;
2018 2037
@@ -2071,14 +2090,13 @@ struct fw_chunk {
2071#define IPW_FW_NAME(x) "ipw2200_" x ".fw" 2090#define IPW_FW_NAME(x) "ipw2200_" x ".fw"
2072#endif 2091#endif
2073 2092
2074static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, 2093static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
2075 size_t len)
2076{ 2094{
2077 int rc = 0, i, addr; 2095 int rc = 0, i, addr;
2078 u8 cr = 0; 2096 u8 cr = 0;
2079 u16 *image; 2097 u16 *image;
2080 2098
2081 image = (u16 *)data; 2099 image = (u16 *) data;
2082 2100
2083 IPW_DEBUG_TRACE(">> \n"); 2101 IPW_DEBUG_TRACE(">> \n");
2084 2102
@@ -2087,7 +2105,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
2087 if (rc < 0) 2105 if (rc < 0)
2088 return rc; 2106 return rc;
2089 2107
2090// spin_lock_irqsave(&priv->lock, flags); 2108// spin_lock_irqsave(&priv->lock, flags);
2091 2109
2092 for (addr = CX2_SHARED_LOWER_BOUND; 2110 for (addr = CX2_SHARED_LOWER_BOUND;
2093 addr < CX2_REGISTER_DOMAIN1_END; addr += 4) { 2111 addr < CX2_REGISTER_DOMAIN1_END; addr += 4) {
@@ -2099,7 +2117,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
2099 /* destroy DMA queues */ 2117 /* destroy DMA queues */
2100 /* reset sequence */ 2118 /* reset sequence */
2101 2119
2102 ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET ,CX2_BIT_HALT_RESET_ON); 2120 ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_ON);
2103 ipw_arc_release(priv); 2121 ipw_arc_release(priv);
2104 ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_OFF); 2122 ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_OFF);
2105 mdelay(1); 2123 mdelay(1);
@@ -2128,13 +2146,11 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
2128 for (i = 0; i < len / 2; i++) 2146 for (i = 0; i < len / 2; i++)
2129 ipw_write_reg16(priv, CX2_BASEBAND_CONTROL_STORE, image[i]); 2147 ipw_write_reg16(priv, CX2_BASEBAND_CONTROL_STORE, image[i]);
2130 2148
2131
2132 /* enable DINO */ 2149 /* enable DINO */
2133 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); 2150 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0);
2134 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 2151 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, DINO_ENABLE_SYSTEM);
2135 DINO_ENABLE_SYSTEM );
2136 2152
2137 /* this is where the igx / win driver deveates from the VAP driver.*/ 2153 /* this is where the igx / win driver deveates from the VAP driver. */
2138 2154
2139 /* wait for alive response */ 2155 /* wait for alive response */
2140 for (i = 0; i < 100; i++) { 2156 for (i = 0; i < 100; i++) {
@@ -2151,25 +2167,24 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
2151 2167
2152 for (i = 0; i < ARRAY_SIZE(response_buffer); i++) 2168 for (i = 0; i < ARRAY_SIZE(response_buffer); i++)
2153 response_buffer[i] = 2169 response_buffer[i] =
2154 ipw_read_reg32(priv, 2170 ipw_read_reg32(priv, CX2_BASEBAND_RX_FIFO_READ);
2155 CX2_BASEBAND_RX_FIFO_READ);
2156 memcpy(&priv->dino_alive, response_buffer, 2171 memcpy(&priv->dino_alive, response_buffer,
2157 sizeof(priv->dino_alive)); 2172 sizeof(priv->dino_alive));
2158 if (priv->dino_alive.alive_command == 1 2173 if (priv->dino_alive.alive_command == 1
2159 && priv->dino_alive.ucode_valid == 1) { 2174 && priv->dino_alive.ucode_valid == 1) {
2160 rc = 0; 2175 rc = 0;
2161 IPW_DEBUG_INFO( 2176 IPW_DEBUG_INFO
2162 "Microcode OK, rev. %d (0x%x) dev. %d (0x%x) " 2177 ("Microcode OK, rev. %d (0x%x) dev. %d (0x%x) "
2163 "of %02d/%02d/%02d %02d:%02d\n", 2178 "of %02d/%02d/%02d %02d:%02d\n",
2164 priv->dino_alive.software_revision, 2179 priv->dino_alive.software_revision,
2165 priv->dino_alive.software_revision, 2180 priv->dino_alive.software_revision,
2166 priv->dino_alive.device_identifier, 2181 priv->dino_alive.device_identifier,
2167 priv->dino_alive.device_identifier, 2182 priv->dino_alive.device_identifier,
2168 priv->dino_alive.time_stamp[0], 2183 priv->dino_alive.time_stamp[0],
2169 priv->dino_alive.time_stamp[1], 2184 priv->dino_alive.time_stamp[1],
2170 priv->dino_alive.time_stamp[2], 2185 priv->dino_alive.time_stamp[2],
2171 priv->dino_alive.time_stamp[3], 2186 priv->dino_alive.time_stamp[3],
2172 priv->dino_alive.time_stamp[4]); 2187 priv->dino_alive.time_stamp[4]);
2173 } else { 2188 } else {
2174 IPW_DEBUG_INFO("Microcode is not alive\n"); 2189 IPW_DEBUG_INFO("Microcode is not alive\n");
2175 rc = -EINVAL; 2190 rc = -EINVAL;
@@ -2183,13 +2198,12 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data,
2183 firmware have problem getting alive resp. */ 2198 firmware have problem getting alive resp. */
2184 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); 2199 ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0);
2185 2200
2186// spin_unlock_irqrestore(&priv->lock, flags); 2201// spin_unlock_irqrestore(&priv->lock, flags);
2187 2202
2188 return rc; 2203 return rc;
2189} 2204}
2190 2205
2191static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, 2206static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
2192 size_t len)
2193{ 2207{
2194 int rc = -1; 2208 int rc = -1;
2195 int offset = 0; 2209 int offset = 0;
@@ -2231,7 +2245,7 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data,
2231 offset += chunk->length; 2245 offset += chunk->length;
2232 } while (offset < len); 2246 } while (offset < len);
2233 2247
2234 /* Run the DMA and wait for the answer*/ 2248 /* Run the DMA and wait for the answer */
2235 rc = ipw_fw_dma_kick(priv); 2249 rc = ipw_fw_dma_kick(priv);
2236 if (rc) { 2250 if (rc) {
2237 IPW_ERROR("dmaKick Failed\n"); 2251 IPW_ERROR("dmaKick Failed\n");
@@ -2243,8 +2257,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data,
2243 IPW_ERROR("dmaWaitSync Failed\n"); 2257 IPW_ERROR("dmaWaitSync Failed\n");
2244 goto out; 2258 goto out;
2245 } 2259 }
2246 out: 2260 out:
2247 pci_free_consistent( priv->pci_dev, len, shared_virt, shared_phys); 2261 pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys);
2248 return rc; 2262 return rc;
2249} 2263}
2250 2264
@@ -2253,7 +2267,7 @@ static int ipw_stop_nic(struct ipw_priv *priv)
2253{ 2267{
2254 int rc = 0; 2268 int rc = 0;
2255 2269
2256 /* stop*/ 2270 /* stop */
2257 ipw_write32(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER); 2271 ipw_write32(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER);
2258 2272
2259 rc = ipw_poll_bit(priv, CX2_RESET_REG, 2273 rc = ipw_poll_bit(priv, CX2_RESET_REG,
@@ -2272,14 +2286,15 @@ static void ipw_start_nic(struct ipw_priv *priv)
2272{ 2286{
2273 IPW_DEBUG_TRACE(">>\n"); 2287 IPW_DEBUG_TRACE(">>\n");
2274 2288
2275 /* prvHwStartNic release ARC*/ 2289 /* prvHwStartNic release ARC */
2276 ipw_clear_bit(priv, CX2_RESET_REG, 2290 ipw_clear_bit(priv, CX2_RESET_REG,
2277 CX2_RESET_REG_MASTER_DISABLED | 2291 CX2_RESET_REG_MASTER_DISABLED |
2278 CX2_RESET_REG_STOP_MASTER | 2292 CX2_RESET_REG_STOP_MASTER |
2279 CBD_RESET_REG_PRINCETON_RESET); 2293 CBD_RESET_REG_PRINCETON_RESET);
2280 2294
2281 /* enable power management */ 2295 /* enable power management */
2282 ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY); 2296 ipw_set_bit(priv, CX2_GP_CNTRL_RW,
2297 CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY);
2283 2298
2284 IPW_DEBUG_TRACE("<<\n"); 2299 IPW_DEBUG_TRACE("<<\n");
2285} 2300}
@@ -2295,12 +2310,13 @@ static int ipw_init_nic(struct ipw_priv *priv)
2295 ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE); 2310 ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE);
2296 2311
2297 /* low-level PLL activation */ 2312 /* low-level PLL activation */
2298 ipw_write32(priv, CX2_READ_INT_REGISTER, CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER); 2313 ipw_write32(priv, CX2_READ_INT_REGISTER,
2314 CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER);
2299 2315
2300 /* wait for clock stabilization */ 2316 /* wait for clock stabilization */
2301 rc = ipw_poll_bit(priv, CX2_GP_CNTRL_RW, 2317 rc = ipw_poll_bit(priv, CX2_GP_CNTRL_RW,
2302 CX2_GP_CNTRL_BIT_CLOCK_READY, 250); 2318 CX2_GP_CNTRL_BIT_CLOCK_READY, 250);
2303 if (rc < 0 ) 2319 if (rc < 0)
2304 IPW_DEBUG_INFO("FAILED wait for clock stablization\n"); 2320 IPW_DEBUG_INFO("FAILED wait for clock stablization\n");
2305 2321
2306 /* assert SW reset */ 2322 /* assert SW reset */
@@ -2315,7 +2331,6 @@ static int ipw_init_nic(struct ipw_priv *priv)
2315 return 0; 2331 return 0;
2316} 2332}
2317 2333
2318
2319/* Call this function from process context, it will sleep in request_firmware. 2334/* Call this function from process context, it will sleep in request_firmware.
2320 * Probe is an ok place to call this from. 2335 * Probe is an ok place to call this from.
2321 */ 2336 */
@@ -2383,8 +2398,7 @@ static inline void ipw_rx_queue_reset(struct ipw_priv *priv,
2383 * to an SKB, so we need to unmap and free potential storage */ 2398 * to an SKB, so we need to unmap and free potential storage */
2384 if (rxq->pool[i].skb != NULL) { 2399 if (rxq->pool[i].skb != NULL) {
2385 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, 2400 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
2386 CX2_RX_BUF_SIZE, 2401 CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
2387 PCI_DMA_FROMDEVICE);
2388 dev_kfree_skb(rxq->pool[i].skb); 2402 dev_kfree_skb(rxq->pool[i].skb);
2389 } 2403 }
2390 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); 2404 list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
@@ -2438,12 +2452,12 @@ static int ipw_load(struct ipw_priv *priv)
2438 if (rc) 2452 if (rc)
2439 goto error; 2453 goto error;
2440 2454
2441 rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("sniffer")); 2455 rc = ipw_get_fw(priv, &firmware,
2456 IPW_FW_NAME("sniffer"));
2442 break; 2457 break;
2443#endif 2458#endif
2444 case IW_MODE_INFRA: 2459 case IW_MODE_INFRA:
2445 rc = ipw_get_fw(priv, &ucode, 2460 rc = ipw_get_fw(priv, &ucode, IPW_FW_NAME("bss_ucode"));
2446 IPW_FW_NAME("bss_ucode"));
2447 if (rc) 2461 if (rc)
2448 goto error; 2462 goto error;
2449 2463
@@ -2471,7 +2485,7 @@ static int ipw_load(struct ipw_priv *priv)
2471 goto error; 2485 goto error;
2472 } 2486 }
2473 2487
2474 retry: 2488 retry:
2475 /* Ensure interrupts are disabled */ 2489 /* Ensure interrupts are disabled */
2476 ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL); 2490 ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL);
2477 priv->status &= ~STATUS_INT_ENABLED; 2491 priv->status &= ~STATUS_INT_ENABLED;
@@ -2528,7 +2542,7 @@ static int ipw_load(struct ipw_priv *priv)
2528 rc = ipw_load_firmware(priv, firmware->data + 2542 rc = ipw_load_firmware(priv, firmware->data +
2529 sizeof(struct fw_header), 2543 sizeof(struct fw_header),
2530 firmware->size - sizeof(struct fw_header)); 2544 firmware->size - sizeof(struct fw_header));
2531 if (rc < 0 ) { 2545 if (rc < 0) {
2532 IPW_ERROR("Unable to load firmware\n"); 2546 IPW_ERROR("Unable to load firmware\n");
2533 goto error; 2547 goto error;
2534 } 2548 }
@@ -2593,7 +2607,7 @@ static int ipw_load(struct ipw_priv *priv)
2593#endif 2607#endif
2594 return 0; 2608 return 0;
2595 2609
2596 error: 2610 error:
2597 if (priv->rxq) { 2611 if (priv->rxq) {
2598 ipw_rx_queue_free(priv, priv->rxq); 2612 ipw_rx_queue_free(priv, priv->rxq);
2599 priv->rxq = NULL; 2613 priv->rxq = NULL;
@@ -2671,8 +2685,7 @@ static inline int ipw_queue_inc_wrap(int index, int n_bd)
2671 * (not offset within BAR, full address) 2685 * (not offset within BAR, full address)
2672 */ 2686 */
2673static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q, 2687static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q,
2674 int count, u32 read, u32 write, 2688 int count, u32 read, u32 write, u32 base, u32 size)
2675 u32 base, u32 size)
2676{ 2689{
2677 q->n_bd = count; 2690 q->n_bd = count;
2678 2691
@@ -2698,8 +2711,7 @@ static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q,
2698 2711
2699static int ipw_queue_tx_init(struct ipw_priv *priv, 2712static int ipw_queue_tx_init(struct ipw_priv *priv,
2700 struct clx2_tx_queue *q, 2713 struct clx2_tx_queue *q,
2701 int count, u32 read, u32 write, 2714 int count, u32 read, u32 write, u32 base, u32 size)
2702 u32 base, u32 size)
2703{ 2715{
2704 struct pci_dev *dev = priv->pci_dev; 2716 struct pci_dev *dev = priv->pci_dev;
2705 2717
@@ -2709,10 +2721,11 @@ static int ipw_queue_tx_init(struct ipw_priv *priv,
2709 return -ENOMEM; 2721 return -ENOMEM;
2710 } 2722 }
2711 2723
2712 q->bd = pci_alloc_consistent(dev,sizeof(q->bd[0])*count, &q->q.dma_addr); 2724 q->bd =
2725 pci_alloc_consistent(dev, sizeof(q->bd[0]) * count, &q->q.dma_addr);
2713 if (!q->bd) { 2726 if (!q->bd) {
2714 IPW_ERROR("pci_alloc_consistent(%zd) failed\n", 2727 IPW_ERROR("pci_alloc_consistent(%zd) failed\n",
2715 sizeof(q->bd[0]) * count); 2728 sizeof(q->bd[0]) * count);
2716 kfree(q->txb); 2729 kfree(q->txb);
2717 q->txb = NULL; 2730 q->txb = NULL;
2718 return -ENOMEM; 2731 return -ENOMEM;
@@ -2768,8 +2781,7 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv,
2768 * @param dev 2781 * @param dev
2769 * @param q 2782 * @param q
2770 */ 2783 */
2771static void ipw_queue_tx_free(struct ipw_priv *priv, 2784static void ipw_queue_tx_free(struct ipw_priv *priv, struct clx2_tx_queue *txq)
2772 struct clx2_tx_queue *txq)
2773{ 2785{
2774 struct clx2_queue *q = &txq->q; 2786 struct clx2_queue *q = &txq->q;
2775 struct pci_dev *dev = priv->pci_dev; 2787 struct pci_dev *dev = priv->pci_dev;
@@ -2784,7 +2796,7 @@ static void ipw_queue_tx_free(struct ipw_priv *priv,
2784 } 2796 }
2785 2797
2786 /* free buffers belonging to queue itself */ 2798 /* free buffers belonging to queue itself */
2787 pci_free_consistent(dev, sizeof(txq->bd[0])*q->n_bd, txq->bd, 2799 pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd,
2788 q->dma_addr); 2800 q->dma_addr);
2789 kfree(txq->txb); 2801 kfree(txq->txb);
2790 2802
@@ -2792,7 +2804,6 @@ static void ipw_queue_tx_free(struct ipw_priv *priv,
2792 memset(txq, 0, sizeof(*txq)); 2804 memset(txq, 0, sizeof(*txq));
2793} 2805}
2794 2806
2795
2796/** 2807/**
2797 * Destroy all DMA queues and structures 2808 * Destroy all DMA queues and structures
2798 * 2809 *
@@ -2825,7 +2836,7 @@ static void inline __maybe_wake_tx(struct ipw_priv *priv)
2825 2836
2826} 2837}
2827 2838
2828static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid) 2839static inline void ipw_create_bssid(struct ipw_priv *priv, u8 * bssid)
2829{ 2840{
2830 /* First 3 bytes are manufacturer */ 2841 /* First 3 bytes are manufacturer */
2831 bssid[0] = priv->mac_addr[0]; 2842 bssid[0] = priv->mac_addr[0];
@@ -2833,13 +2844,13 @@ static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid)
2833 bssid[2] = priv->mac_addr[2]; 2844 bssid[2] = priv->mac_addr[2];
2834 2845
2835 /* Last bytes are random */ 2846 /* Last bytes are random */
2836 get_random_bytes(&bssid[3], ETH_ALEN-3); 2847 get_random_bytes(&bssid[3], ETH_ALEN - 3);
2837 2848
2838 bssid[0] &= 0xfe; /* clear multicast bit */ 2849 bssid[0] &= 0xfe; /* clear multicast bit */
2839 bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */ 2850 bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */
2840} 2851}
2841 2852
2842static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid) 2853static inline u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid)
2843{ 2854{
2844 struct ipw_station_entry entry; 2855 struct ipw_station_entry entry;
2845 int i; 2856 int i;
@@ -2866,14 +2877,13 @@ static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid)
2866 memcpy(entry.mac_addr, bssid, ETH_ALEN); 2877 memcpy(entry.mac_addr, bssid, ETH_ALEN);
2867 memcpy(priv->stations[i], bssid, ETH_ALEN); 2878 memcpy(priv->stations[i], bssid, ETH_ALEN);
2868 ipw_write_direct(priv, IPW_STATION_TABLE_LOWER + i * sizeof(entry), 2879 ipw_write_direct(priv, IPW_STATION_TABLE_LOWER + i * sizeof(entry),
2869 &entry, 2880 &entry, sizeof(entry));
2870 sizeof(entry));
2871 priv->num_stations++; 2881 priv->num_stations++;
2872 2882
2873 return i; 2883 return i;
2874} 2884}
2875 2885
2876static inline u8 ipw_find_station(struct ipw_priv *priv, u8 *bssid) 2886static inline u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid)
2877{ 2887{
2878 int i; 2888 int i;
2879 2889
@@ -2944,26 +2954,34 @@ static const struct ipw_status_code ipw_status_codes[] = {
2944 "association exists"}, 2954 "association exists"},
2945 {0x0C, "Association denied due to reason outside the scope of this " 2955 {0x0C, "Association denied due to reason outside the scope of this "
2946 "standard"}, 2956 "standard"},
2947 {0x0D, "Responding station does not support the specified authentication " 2957 {0x0D,
2958 "Responding station does not support the specified authentication "
2948 "algorithm"}, 2959 "algorithm"},
2949 {0x0E, "Received an Authentication frame with authentication sequence " 2960 {0x0E,
2961 "Received an Authentication frame with authentication sequence "
2950 "transaction sequence number out of expected sequence"}, 2962 "transaction sequence number out of expected sequence"},
2951 {0x0F, "Authentication rejected because of challenge failure"}, 2963 {0x0F, "Authentication rejected because of challenge failure"},
2952 {0x10, "Authentication rejected due to timeout waiting for next " 2964 {0x10, "Authentication rejected due to timeout waiting for next "
2953 "frame in sequence"}, 2965 "frame in sequence"},
2954 {0x11, "Association denied because AP is unable to handle additional " 2966 {0x11, "Association denied because AP is unable to handle additional "
2955 "associated stations"}, 2967 "associated stations"},
2956 {0x12, "Association denied due to requesting station not supporting all " 2968 {0x12,
2969 "Association denied due to requesting station not supporting all "
2957 "of the datarates in the BSSBasicServiceSet Parameter"}, 2970 "of the datarates in the BSSBasicServiceSet Parameter"},
2958 {0x13, "Association denied due to requesting station not supporting " 2971 {0x13,
2972 "Association denied due to requesting station not supporting "
2959 "short preamble operation"}, 2973 "short preamble operation"},
2960 {0x14, "Association denied due to requesting station not supporting " 2974 {0x14,
2975 "Association denied due to requesting station not supporting "
2961 "PBCC encoding"}, 2976 "PBCC encoding"},
2962 {0x15, "Association denied due to requesting station not supporting " 2977 {0x15,
2978 "Association denied due to requesting station not supporting "
2963 "channel agility"}, 2979 "channel agility"},
2964 {0x19, "Association denied due to requesting station not supporting " 2980 {0x19,
2981 "Association denied due to requesting station not supporting "
2965 "short slot operation"}, 2982 "short slot operation"},
2966 {0x1A, "Association denied due to requesting station not supporting " 2983 {0x1A,
2984 "Association denied due to requesting station not supporting "
2967 "DSSS-OFDM operation"}, 2985 "DSSS-OFDM operation"},
2968 {0x28, "Invalid Information Element"}, 2986 {0x28, "Invalid Information Element"},
2969 {0x29, "Group Cipher is not valid"}, 2987 {0x29, "Group Cipher is not valid"},
@@ -3043,7 +3061,6 @@ static void ipw_reset_stats(struct ipw_priv *priv)
3043 3061
3044} 3062}
3045 3063
3046
3047static inline u32 ipw_get_max_rate(struct ipw_priv *priv) 3064static inline u32 ipw_get_max_rate(struct ipw_priv *priv)
3048{ 3065{
3049 u32 i = 0x80000000; 3066 u32 i = 0x80000000;
@@ -3056,20 +3073,21 @@ static inline u32 ipw_get_max_rate(struct ipw_priv *priv)
3056 /* TODO: Verify that the rate is supported by the current rates 3073 /* TODO: Verify that the rate is supported by the current rates
3057 * list. */ 3074 * list. */
3058 3075
3059 while (i && !(mask & i)) i >>= 1; 3076 while (i && !(mask & i))
3077 i >>= 1;
3060 switch (i) { 3078 switch (i) {
3061 case IEEE80211_CCK_RATE_1MB_MASK: return 1000000; 3079 case IEEE80211_CCK_RATE_1MB_MASK: return 1000000;
3062 case IEEE80211_CCK_RATE_2MB_MASK: return 2000000; 3080 case IEEE80211_CCK_RATE_2MB_MASK: return 2000000;
3063 case IEEE80211_CCK_RATE_5MB_MASK: return 5500000; 3081 case IEEE80211_CCK_RATE_5MB_MASK: return 5500000;
3064 case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000; 3082 case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000;
3065 case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000; 3083 case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000;
3066 case IEEE80211_CCK_RATE_11MB_MASK: return 11000000; 3084 case IEEE80211_CCK_RATE_11MB_MASK: return 11000000;
3067 case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000; 3085 case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000;
3068 case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000; 3086 case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000;
3069 case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000; 3087 case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000;
3070 case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000; 3088 case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000;
3071 case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000; 3089 case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000;
3072 case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000; 3090 case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000;
3073 } 3091 }
3074 3092
3075 if (priv->ieee->mode == IEEE_B) 3093 if (priv->ieee->mode == IEEE_B)
@@ -3097,18 +3115,18 @@ static u32 ipw_get_current_rate(struct ipw_priv *priv)
3097 return ipw_get_max_rate(priv); 3115 return ipw_get_max_rate(priv);
3098 3116
3099 switch (rate) { 3117 switch (rate) {
3100 case IPW_TX_RATE_1MB: return 1000000; 3118 case IPW_TX_RATE_1MB: return 1000000;
3101 case IPW_TX_RATE_2MB: return 2000000; 3119 case IPW_TX_RATE_2MB: return 2000000;
3102 case IPW_TX_RATE_5MB: return 5500000; 3120 case IPW_TX_RATE_5MB: return 5500000;
3103 case IPW_TX_RATE_6MB: return 6000000; 3121 case IPW_TX_RATE_6MB: return 6000000;
3104 case IPW_TX_RATE_9MB: return 9000000; 3122 case IPW_TX_RATE_9MB: return 9000000;
3105 case IPW_TX_RATE_11MB: return 11000000; 3123 case IPW_TX_RATE_11MB: return 11000000;
3106 case IPW_TX_RATE_12MB: return 12000000; 3124 case IPW_TX_RATE_12MB: return 12000000;
3107 case IPW_TX_RATE_18MB: return 18000000; 3125 case IPW_TX_RATE_18MB: return 18000000;
3108 case IPW_TX_RATE_24MB: return 24000000; 3126 case IPW_TX_RATE_24MB: return 24000000;
3109 case IPW_TX_RATE_36MB: return 36000000; 3127 case IPW_TX_RATE_36MB: return 36000000;
3110 case IPW_TX_RATE_48MB: return 48000000; 3128 case IPW_TX_RATE_48MB: return 48000000;
3111 case IPW_TX_RATE_54MB: return 54000000; 3129 case IPW_TX_RATE_54MB: return 54000000;
3112 } 3130 }
3113 3131
3114 return 0; 3132 return 0;
@@ -3126,7 +3144,7 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3126 u32 len = sizeof(u32); 3144 u32 len = sizeof(u32);
3127 s16 rssi; 3145 s16 rssi;
3128 u32 beacon_quality, signal_quality, tx_quality, rx_quality, 3146 u32 beacon_quality, signal_quality, tx_quality, rx_quality,
3129 rate_quality; 3147 rate_quality;
3130 3148
3131 if (!(priv->status & STATUS_ASSOCIATED)) { 3149 if (!(priv->status & STATUS_ASSOCIATED)) {
3132 priv->quality = 0; 3150 priv->quality = 0;
@@ -3136,13 +3154,12 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3136 /* Update the statistics */ 3154 /* Update the statistics */
3137 ipw_get_ordinal(priv, IPW_ORD_STAT_MISSED_BEACONS, 3155 ipw_get_ordinal(priv, IPW_ORD_STAT_MISSED_BEACONS,
3138 &priv->missed_beacons, &len); 3156 &priv->missed_beacons, &len);
3139 missed_beacons_delta = priv->missed_beacons - 3157 missed_beacons_delta = priv->missed_beacons - priv->last_missed_beacons;
3140 priv->last_missed_beacons;
3141 priv->last_missed_beacons = priv->missed_beacons; 3158 priv->last_missed_beacons = priv->missed_beacons;
3142 if (priv->assoc_request.beacon_interval) { 3159 if (priv->assoc_request.beacon_interval) {
3143 missed_beacons_percent = missed_beacons_delta * 3160 missed_beacons_percent = missed_beacons_delta *
3144 (HZ * priv->assoc_request.beacon_interval) / 3161 (HZ * priv->assoc_request.beacon_interval) /
3145 (IPW_STATS_INTERVAL * 10); 3162 (IPW_STATS_INTERVAL * 10);
3146 } else { 3163 } else {
3147 missed_beacons_percent = 0; 3164 missed_beacons_percent = 0;
3148 } 3165 }
@@ -3179,28 +3196,26 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3179 beacon_quality = 0; 3196 beacon_quality = 0;
3180 else 3197 else
3181 beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 / 3198 beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 /
3182 (100 - BEACON_THRESHOLD); 3199 (100 - BEACON_THRESHOLD);
3183 IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n", 3200 IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n",
3184 beacon_quality, missed_beacons_percent); 3201 beacon_quality, missed_beacons_percent);
3185 3202
3186 priv->last_rate = ipw_get_current_rate(priv); 3203 priv->last_rate = ipw_get_current_rate(priv);
3187 rate_quality = priv->last_rate * 40 / priv->last_rate + 60; 3204 rate_quality = priv->last_rate * 40 / priv->last_rate + 60;
3188 IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n", 3205 IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n",
3189 rate_quality, priv->last_rate / 1000000); 3206 rate_quality, priv->last_rate / 1000000);
3190 3207
3191 if (rx_packets_delta > 100 && 3208 if (rx_packets_delta > 100 && rx_packets_delta + rx_err_delta)
3192 rx_packets_delta + rx_err_delta)
3193 rx_quality = 100 - (rx_err_delta * 100) / 3209 rx_quality = 100 - (rx_err_delta * 100) /
3194 (rx_packets_delta + rx_err_delta); 3210 (rx_packets_delta + rx_err_delta);
3195 else 3211 else
3196 rx_quality = 100; 3212 rx_quality = 100;
3197 IPW_DEBUG_STATS("Rx quality : %3d%% (%u errors, %u packets)\n", 3213 IPW_DEBUG_STATS("Rx quality : %3d%% (%u errors, %u packets)\n",
3198 rx_quality, rx_err_delta, rx_packets_delta); 3214 rx_quality, rx_err_delta, rx_packets_delta);
3199 3215
3200 if (tx_packets_delta > 100 && 3216 if (tx_packets_delta > 100 && tx_packets_delta + tx_failures_delta)
3201 tx_packets_delta + tx_failures_delta)
3202 tx_quality = 100 - (tx_failures_delta * 100) / 3217 tx_quality = 100 - (tx_failures_delta * 100) /
3203 (tx_packets_delta + tx_failures_delta); 3218 (tx_packets_delta + tx_failures_delta);
3204 else 3219 else
3205 tx_quality = 100; 3220 tx_quality = 100;
3206 IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n", 3221 IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n",
@@ -3213,7 +3228,7 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3213 signal_quality = 0; 3228 signal_quality = 0;
3214 else 3229 else
3215 signal_quality = (rssi - WORST_RSSI) * 100 / 3230 signal_quality = (rssi - WORST_RSSI) * 100 /
3216 (PERFECT_RSSI - WORST_RSSI); 3231 (PERFECT_RSSI - WORST_RSSI);
3217 IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n", 3232 IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n",
3218 signal_quality, rssi); 3233 signal_quality, rssi);
3219 3234
@@ -3221,25 +3236,20 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3221 min(rate_quality, 3236 min(rate_quality,
3222 min(tx_quality, min(rx_quality, signal_quality)))); 3237 min(tx_quality, min(rx_quality, signal_quality))));
3223 if (quality == beacon_quality) 3238 if (quality == beacon_quality)
3224 IPW_DEBUG_STATS( 3239 IPW_DEBUG_STATS("Quality (%d%%): Clamped to missed beacons.\n",
3225 "Quality (%d%%): Clamped to missed beacons.\n", 3240 quality);
3226 quality);
3227 if (quality == rate_quality) 3241 if (quality == rate_quality)
3228 IPW_DEBUG_STATS( 3242 IPW_DEBUG_STATS("Quality (%d%%): Clamped to rate quality.\n",
3229 "Quality (%d%%): Clamped to rate quality.\n", 3243 quality);
3230 quality);
3231 if (quality == tx_quality) 3244 if (quality == tx_quality)
3232 IPW_DEBUG_STATS( 3245 IPW_DEBUG_STATS("Quality (%d%%): Clamped to Tx quality.\n",
3233 "Quality (%d%%): Clamped to Tx quality.\n", 3246 quality);
3234 quality);
3235 if (quality == rx_quality) 3247 if (quality == rx_quality)
3236 IPW_DEBUG_STATS( 3248 IPW_DEBUG_STATS("Quality (%d%%): Clamped to Rx quality.\n",
3237 "Quality (%d%%): Clamped to Rx quality.\n", 3249 quality);
3238 quality);
3239 if (quality == signal_quality) 3250 if (quality == signal_quality)
3240 IPW_DEBUG_STATS( 3251 IPW_DEBUG_STATS("Quality (%d%%): Clamped to signal quality.\n",
3241 "Quality (%d%%): Clamped to signal quality.\n", 3252 quality);
3242 quality);
3243 3253
3244 priv->quality = quality; 3254 priv->quality = quality;
3245 3255
@@ -3251,402 +3261,454 @@ static void ipw_gather_stats(struct ipw_priv *priv)
3251 * Handle host notification packet. 3261 * Handle host notification packet.
3252 * Called from interrupt routine 3262 * Called from interrupt routine
3253 */ 3263 */
3254static inline void ipw_rx_notification(struct ipw_priv* priv, 3264static inline void ipw_rx_notification(struct ipw_priv *priv,
3255 struct ipw_rx_notification *notif) 3265 struct ipw_rx_notification *notif)
3256{ 3266{
3257 IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", 3267 IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", notif->subtype, notif->size);
3258 notif->subtype, notif->size);
3259 3268
3260 switch (notif->subtype) { 3269 switch (notif->subtype) {
3261 case HOST_NOTIFICATION_STATUS_ASSOCIATED: { 3270 case HOST_NOTIFICATION_STATUS_ASSOCIATED:{
3262 struct notif_association *assoc = &notif->u.assoc; 3271 struct notif_association *assoc = &notif->u.assoc;
3263 3272
3264 switch (assoc->state) { 3273 switch (assoc->state) {
3265 case CMAS_ASSOCIATED: { 3274 case CMAS_ASSOCIATED:{
3266 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, 3275 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3267 "associated: '%s' " MAC_FMT " \n", 3276 IPW_DL_ASSOC,
3268 escape_essid(priv->essid, priv->essid_len), 3277 "associated: '%s' " MAC_FMT
3269 MAC_ARG(priv->bssid)); 3278 " \n",
3270 3279 escape_essid(priv->essid,
3271 switch (priv->ieee->iw_mode) { 3280 priv->essid_len),
3272 case IW_MODE_INFRA: 3281 MAC_ARG(priv->bssid));
3273 memcpy(priv->ieee->bssid, priv->bssid, 3282
3274 ETH_ALEN); 3283 switch (priv->ieee->iw_mode) {
3275 break; 3284 case IW_MODE_INFRA:
3276 3285 memcpy(priv->ieee->bssid,
3277 case IW_MODE_ADHOC: 3286 priv->bssid, ETH_ALEN);
3278 memcpy(priv->ieee->bssid, priv->bssid, 3287 break;
3279 ETH_ALEN); 3288
3280 3289 case IW_MODE_ADHOC:
3281 /* clear out the station table */ 3290 memcpy(priv->ieee->bssid,
3282 priv->num_stations = 0; 3291 priv->bssid, ETH_ALEN);
3283 3292
3284 IPW_DEBUG_ASSOC("queueing adhoc check\n"); 3293 /* clear out the station table */
3285 queue_delayed_work(priv->workqueue, 3294 priv->num_stations = 0;
3286 &priv->adhoc_check, 3295
3287 priv->assoc_request.beacon_interval); 3296 IPW_DEBUG_ASSOC
3288 break; 3297 ("queueing adhoc check\n");
3289 } 3298 queue_delayed_work(priv->
3290 3299 workqueue,
3291 priv->status &= ~STATUS_ASSOCIATING; 3300 &priv->
3292 priv->status |= STATUS_ASSOCIATED; 3301 adhoc_check,
3293 3302 priv->
3294 netif_carrier_on(priv->net_dev); 3303 assoc_request.
3295 if (netif_queue_stopped(priv->net_dev)) { 3304 beacon_interval);
3296 IPW_DEBUG_NOTIF("waking queue\n"); 3305 break;
3297 netif_wake_queue(priv->net_dev); 3306 }
3298 } else { 3307
3299 IPW_DEBUG_NOTIF("starting queue\n"); 3308 priv->status &= ~STATUS_ASSOCIATING;
3300 netif_start_queue(priv->net_dev); 3309 priv->status |= STATUS_ASSOCIATED;
3301 } 3310
3302 3311 netif_carrier_on(priv->net_dev);
3303 ipw_reset_stats(priv); 3312 if (netif_queue_stopped(priv->net_dev)) {
3304 /* Ensure the rate is updated immediately */ 3313 IPW_DEBUG_NOTIF
3305 priv->last_rate = ipw_get_current_rate(priv); 3314 ("waking queue\n");
3306 schedule_work(&priv->gather_stats); 3315 netif_wake_queue(priv->net_dev);
3307 notify_wx_assoc_event(priv); 3316 } else {
3317 IPW_DEBUG_NOTIF
3318 ("starting queue\n");
3319 netif_start_queue(priv->
3320 net_dev);
3321 }
3322
3323 ipw_reset_stats(priv);
3324 /* Ensure the rate is updated immediately */
3325 priv->last_rate =
3326 ipw_get_current_rate(priv);
3327 schedule_work(&priv->gather_stats);
3328 notify_wx_assoc_event(priv);
3308 3329
3309/* queue_delayed_work(priv->workqueue, 3330/* queue_delayed_work(priv->workqueue,
3310 &priv->request_scan, 3331 &priv->request_scan,
3311 SCAN_ASSOCIATED_INTERVAL); 3332 SCAN_ASSOCIATED_INTERVAL);
3312*/ 3333*/
3313 break; 3334 break;
3314 } 3335 }
3315 3336
3316 case CMAS_AUTHENTICATED: { 3337 case CMAS_AUTHENTICATED:{
3317 if (priv->status & (STATUS_ASSOCIATED | STATUS_AUTH)) { 3338 if (priv->
3339 status & (STATUS_ASSOCIATED |
3340 STATUS_AUTH)) {
3318#ifdef CONFIG_IPW_DEBUG 3341#ifdef CONFIG_IPW_DEBUG
3319 struct notif_authenticate *auth = &notif->u.auth; 3342 struct notif_authenticate *auth
3320 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, 3343 = &notif->u.auth;
3321 "deauthenticated: '%s' " MAC_FMT ": (0x%04X) - %s \n", 3344 IPW_DEBUG(IPW_DL_NOTIF |
3322 escape_essid(priv->essid, priv->essid_len), 3345 IPW_DL_STATE |
3323 MAC_ARG(priv->bssid), 3346 IPW_DL_ASSOC,
3324 ntohs(auth->status), 3347 "deauthenticated: '%s' "
3325 ipw_get_status_code(ntohs(auth->status))); 3348 MAC_FMT
3349 ": (0x%04X) - %s \n",
3350 escape_essid(priv->
3351 essid,
3352 priv->
3353 essid_len),
3354 MAC_ARG(priv->bssid),
3355 ntohs(auth->status),
3356 ipw_get_status_code
3357 (ntohs
3358 (auth->status)));
3326#endif 3359#endif
3327 3360
3328 priv->status &= ~(STATUS_ASSOCIATING | 3361 priv->status &=
3329 STATUS_AUTH | 3362 ~(STATUS_ASSOCIATING |
3330 STATUS_ASSOCIATED); 3363 STATUS_AUTH |
3364 STATUS_ASSOCIATED);
3365
3366 netif_carrier_off(priv->
3367 net_dev);
3368 netif_stop_queue(priv->net_dev);
3369 queue_work(priv->workqueue,
3370 &priv->request_scan);
3371 notify_wx_assoc_event(priv);
3372 break;
3373 }
3374
3375 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3376 IPW_DL_ASSOC,
3377 "authenticated: '%s' " MAC_FMT
3378 "\n",
3379 escape_essid(priv->essid,
3380 priv->essid_len),
3381 MAC_ARG(priv->bssid));
3382 break;
3383 }
3384
3385 case CMAS_INIT:{
3386 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3387 IPW_DL_ASSOC,
3388 "disassociated: '%s' " MAC_FMT
3389 " \n",
3390 escape_essid(priv->essid,
3391 priv->essid_len),
3392 MAC_ARG(priv->bssid));
3393
3394 priv->status &=
3395 ~(STATUS_DISASSOCIATING |
3396 STATUS_ASSOCIATING |
3397 STATUS_ASSOCIATED | STATUS_AUTH);
3398
3399 netif_stop_queue(priv->net_dev);
3400 if (!(priv->status & STATUS_ROAMING)) {
3401 netif_carrier_off(priv->
3402 net_dev);
3403 notify_wx_assoc_event(priv);
3404
3405 /* Cancel any queued work ... */
3406 cancel_delayed_work(&priv->
3407 request_scan);
3408 cancel_delayed_work(&priv->
3409 adhoc_check);
3410
3411 /* Queue up another scan... */
3412 queue_work(priv->workqueue,
3413 &priv->request_scan);
3414
3415 cancel_delayed_work(&priv->
3416 gather_stats);
3417 } else {
3418 priv->status |= STATUS_ROAMING;
3419 queue_work(priv->workqueue,
3420 &priv->request_scan);
3421 }
3422
3423 ipw_reset_stats(priv);
3424 break;
3425 }
3331 3426
3332 netif_carrier_off(priv->net_dev); 3427 default:
3333 netif_stop_queue(priv->net_dev); 3428 IPW_ERROR("assoc: unknown (%d)\n",
3334 queue_work(priv->workqueue, &priv->request_scan); 3429 assoc->state);
3335 notify_wx_assoc_event(priv);
3336 break; 3430 break;
3337 } 3431 }
3338 3432
3339 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3340 "authenticated: '%s' " MAC_FMT "\n",
3341 escape_essid(priv->essid, priv->essid_len),
3342 MAC_ARG(priv->bssid));
3343 break; 3433 break;
3344 } 3434 }
3345 3435
3346 case CMAS_INIT: { 3436 case HOST_NOTIFICATION_STATUS_AUTHENTICATE:{
3347 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, 3437 struct notif_authenticate *auth = &notif->u.auth;
3348 "disassociated: '%s' " MAC_FMT " \n", 3438 switch (auth->state) {
3349 escape_essid(priv->essid, priv->essid_len), 3439 case CMAS_AUTHENTICATED:
3350 MAC_ARG(priv->bssid)); 3440 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
3441 "authenticated: '%s' " MAC_FMT " \n",
3442 escape_essid(priv->essid,
3443 priv->essid_len),
3444 MAC_ARG(priv->bssid));
3445 priv->status |= STATUS_AUTH;
3446 break;
3351 3447
3352 priv->status &= ~( 3448 case CMAS_INIT:
3353 STATUS_DISASSOCIATING | 3449 if (priv->status & STATUS_AUTH) {
3354 STATUS_ASSOCIATING | 3450 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3355 STATUS_ASSOCIATED | 3451 IPW_DL_ASSOC,
3356 STATUS_AUTH); 3452 "authentication failed (0x%04X): %s\n",
3453 ntohs(auth->status),
3454 ipw_get_status_code(ntohs
3455 (auth->
3456 status)));
3457 }
3458 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3459 IPW_DL_ASSOC,
3460 "deauthenticated: '%s' " MAC_FMT "\n",
3461 escape_essid(priv->essid,
3462 priv->essid_len),
3463 MAC_ARG(priv->bssid));
3357 3464
3358 netif_stop_queue(priv->net_dev); 3465 priv->status &= ~(STATUS_ASSOCIATING |
3359 if (!(priv->status & STATUS_ROAMING)) { 3466 STATUS_AUTH |
3360 netif_carrier_off(priv->net_dev); 3467 STATUS_ASSOCIATED);
3361 notify_wx_assoc_event(priv);
3362
3363 /* Cancel any queued work ... */
3364 cancel_delayed_work(&priv->request_scan);
3365 cancel_delayed_work(&priv->adhoc_check);
3366 3468
3367 /* Queue up another scan... */ 3469 netif_carrier_off(priv->net_dev);
3470 netif_stop_queue(priv->net_dev);
3368 queue_work(priv->workqueue, 3471 queue_work(priv->workqueue,
3369 &priv->request_scan); 3472 &priv->request_scan);
3473 notify_wx_assoc_event(priv);
3474 break;
3370 3475
3371 cancel_delayed_work(&priv->gather_stats); 3476 case CMAS_TX_AUTH_SEQ_1:
3372 } else { 3477 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3373 priv->status |= STATUS_ROAMING; 3478 IPW_DL_ASSOC, "AUTH_SEQ_1\n");
3374 queue_work(priv->workqueue, 3479 break;
3375 &priv->request_scan); 3480 case CMAS_RX_AUTH_SEQ_2:
3481 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3482 IPW_DL_ASSOC, "AUTH_SEQ_2\n");
3483 break;
3484 case CMAS_AUTH_SEQ_1_PASS:
3485 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3486 IPW_DL_ASSOC, "AUTH_SEQ_1_PASS\n");
3487 break;
3488 case CMAS_AUTH_SEQ_1_FAIL:
3489 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3490 IPW_DL_ASSOC, "AUTH_SEQ_1_FAIL\n");
3491 break;
3492 case CMAS_TX_AUTH_SEQ_3:
3493 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3494 IPW_DL_ASSOC, "AUTH_SEQ_3\n");
3495 break;
3496 case CMAS_RX_AUTH_SEQ_4:
3497 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3498 IPW_DL_ASSOC, "RX_AUTH_SEQ_4\n");
3499 break;
3500 case CMAS_AUTH_SEQ_2_PASS:
3501 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3502 IPW_DL_ASSOC, "AUTH_SEQ_2_PASS\n");
3503 break;
3504 case CMAS_AUTH_SEQ_2_FAIL:
3505 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3506 IPW_DL_ASSOC, "AUT_SEQ_2_FAIL\n");
3507 break;
3508 case CMAS_TX_ASSOC:
3509 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3510 IPW_DL_ASSOC, "TX_ASSOC\n");
3511 break;
3512 case CMAS_RX_ASSOC_RESP:
3513 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3514 IPW_DL_ASSOC, "RX_ASSOC_RESP\n");
3515 break;
3516 case CMAS_ASSOCIATED:
3517 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
3518 IPW_DL_ASSOC, "ASSOCIATED\n");
3519 break;
3520 default:
3521 IPW_DEBUG_NOTIF("auth: failure - %d\n",
3522 auth->state);
3523 break;
3376 } 3524 }
3377
3378 ipw_reset_stats(priv);
3379 break;
3380 }
3381
3382 default:
3383 IPW_ERROR("assoc: unknown (%d)\n",
3384 assoc->state);
3385 break; 3525 break;
3386 } 3526 }
3387 3527
3388 break; 3528 case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT:{
3389 } 3529 struct notif_channel_result *x =
3530 &notif->u.channel_result;
3390 3531
3391 case HOST_NOTIFICATION_STATUS_AUTHENTICATE: { 3532 if (notif->size == sizeof(*x)) {
3392 struct notif_authenticate *auth = &notif->u.auth; 3533 IPW_DEBUG_SCAN("Scan result for channel %d\n",
3393 switch (auth->state) { 3534 x->channel_num);
3394 case CMAS_AUTHENTICATED: 3535 } else {
3395 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, 3536 IPW_DEBUG_SCAN("Scan result of wrong size %d "
3396 "authenticated: '%s' " MAC_FMT " \n", 3537 "(should be %zd)\n",
3397 escape_essid(priv->essid, priv->essid_len), 3538 notif->size, sizeof(*x));
3398 MAC_ARG(priv->bssid));
3399 priv->status |= STATUS_AUTH;
3400 break;
3401
3402 case CMAS_INIT:
3403 if (priv->status & STATUS_AUTH) {
3404 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3405 "authentication failed (0x%04X): %s\n",
3406 ntohs(auth->status),
3407 ipw_get_status_code(ntohs(auth->status)));
3408 } 3539 }
3409 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3410 "deauthenticated: '%s' " MAC_FMT "\n",
3411 escape_essid(priv->essid, priv->essid_len),
3412 MAC_ARG(priv->bssid));
3413
3414 priv->status &= ~(STATUS_ASSOCIATING |
3415 STATUS_AUTH |
3416 STATUS_ASSOCIATED);
3417
3418 netif_carrier_off(priv->net_dev);
3419 netif_stop_queue(priv->net_dev);
3420 queue_work(priv->workqueue, &priv->request_scan);
3421 notify_wx_assoc_event(priv);
3422 break;
3423
3424 case CMAS_TX_AUTH_SEQ_1:
3425 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3426 "AUTH_SEQ_1\n");
3427 break;
3428 case CMAS_RX_AUTH_SEQ_2:
3429 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3430 "AUTH_SEQ_2\n");
3431 break;
3432 case CMAS_AUTH_SEQ_1_PASS:
3433 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3434 "AUTH_SEQ_1_PASS\n");
3435 break;
3436 case CMAS_AUTH_SEQ_1_FAIL:
3437 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3438 "AUTH_SEQ_1_FAIL\n");
3439 break;
3440 case CMAS_TX_AUTH_SEQ_3:
3441 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3442 "AUTH_SEQ_3\n");
3443 break;
3444 case CMAS_RX_AUTH_SEQ_4:
3445 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3446 "RX_AUTH_SEQ_4\n");
3447 break;
3448 case CMAS_AUTH_SEQ_2_PASS:
3449 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3450 "AUTH_SEQ_2_PASS\n");
3451 break;
3452 case CMAS_AUTH_SEQ_2_FAIL:
3453 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3454 "AUT_SEQ_2_FAIL\n");
3455 break;
3456 case CMAS_TX_ASSOC:
3457 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3458 "TX_ASSOC\n");
3459 break;
3460 case CMAS_RX_ASSOC_RESP:
3461 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3462 "RX_ASSOC_RESP\n");
3463 break;
3464 case CMAS_ASSOCIATED:
3465 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
3466 "ASSOCIATED\n");
3467 break;
3468 default:
3469 IPW_DEBUG_NOTIF("auth: failure - %d\n", auth->state);
3470 break; 3540 break;
3471 } 3541 }
3472 break;
3473 }
3474
3475 case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT: {
3476 struct notif_channel_result *x = &notif->u.channel_result;
3477
3478 if (notif->size == sizeof(*x)) {
3479 IPW_DEBUG_SCAN("Scan result for channel %d\n",
3480 x->channel_num);
3481 } else {
3482 IPW_DEBUG_SCAN("Scan result of wrong size %d "
3483 "(should be %zd)\n",
3484 notif->size, sizeof(*x));
3485 }
3486 break;
3487 }
3488 3542
3489 case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED: { 3543 case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED:{
3490 struct notif_scan_complete* x = &notif->u.scan_complete; 3544 struct notif_scan_complete *x = &notif->u.scan_complete;
3491 if (notif->size == sizeof(*x)) { 3545 if (notif->size == sizeof(*x)) {
3492 IPW_DEBUG_SCAN("Scan completed: type %d, %d channels, " 3546 IPW_DEBUG_SCAN
3493 "%d status\n", 3547 ("Scan completed: type %d, %d channels, "
3494 x->scan_type, 3548 "%d status\n", x->scan_type,
3495 x->num_channels, 3549 x->num_channels, x->status);
3496 x->status); 3550 } else {
3497 } else { 3551 IPW_ERROR("Scan completed of wrong size %d "
3498 IPW_ERROR("Scan completed of wrong size %d " 3552 "(should be %zd)\n",
3499 "(should be %zd)\n", 3553 notif->size, sizeof(*x));
3500 notif->size, sizeof(*x)); 3554 }
3501 }
3502
3503 priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING);
3504
3505 cancel_delayed_work(&priv->scan_check);
3506
3507 if (!(priv->status & (STATUS_ASSOCIATED |
3508 STATUS_ASSOCIATING |
3509 STATUS_ROAMING |
3510 STATUS_DISASSOCIATING)))
3511 queue_work(priv->workqueue, &priv->associate);
3512 else if (priv->status & STATUS_ROAMING) {
3513 /* If a scan completed and we are in roam mode, then
3514 * the scan that completed was the one requested as a
3515 * result of entering roam... so, schedule the
3516 * roam work */
3517 queue_work(priv->workqueue, &priv->roam);
3518 } else if (priv->status & STATUS_SCAN_PENDING)
3519 queue_work(priv->workqueue, &priv->request_scan);
3520
3521 priv->ieee->scans++;
3522 break;
3523 }
3524 3555
3525 case HOST_NOTIFICATION_STATUS_FRAG_LENGTH: { 3556 priv->status &=
3526 struct notif_frag_length *x = &notif->u.frag_len; 3557 ~(STATUS_SCANNING | STATUS_SCAN_ABORTING);
3558
3559 cancel_delayed_work(&priv->scan_check);
3560
3561 if (!(priv->status & (STATUS_ASSOCIATED |
3562 STATUS_ASSOCIATING |
3563 STATUS_ROAMING |
3564 STATUS_DISASSOCIATING)))
3565 queue_work(priv->workqueue, &priv->associate);
3566 else if (priv->status & STATUS_ROAMING) {
3567 /* If a scan completed and we are in roam mode, then
3568 * the scan that completed was the one requested as a
3569 * result of entering roam... so, schedule the
3570 * roam work */
3571 queue_work(priv->workqueue, &priv->roam);
3572 } else if (priv->status & STATUS_SCAN_PENDING)
3573 queue_work(priv->workqueue,
3574 &priv->request_scan);
3527 3575
3528 if (notif->size == sizeof(*x)) { 3576 priv->ieee->scans++;
3529 IPW_ERROR("Frag length: %d\n", x->frag_length); 3577 break;
3530 } else {
3531 IPW_ERROR("Frag length of wrong size %d "
3532 "(should be %zd)\n",
3533 notif->size, sizeof(*x));
3534 } 3578 }
3535 break;
3536 }
3537 3579
3538 case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION: { 3580 case HOST_NOTIFICATION_STATUS_FRAG_LENGTH:{
3539 struct notif_link_deterioration *x = 3581 struct notif_frag_length *x = &notif->u.frag_len;
3540 &notif->u.link_deterioration;
3541 if (notif->size==sizeof(*x)) {
3542 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
3543 "link deterioration: '%s' " MAC_FMT " \n",
3544 escape_essid(priv->essid, priv->essid_len),
3545 MAC_ARG(priv->bssid));
3546 memcpy(&priv->last_link_deterioration, x, sizeof(*x));
3547 } else {
3548 IPW_ERROR("Link Deterioration of wrong size %d "
3549 "(should be %zd)\n",
3550 notif->size, sizeof(*x));
3551 }
3552 break;
3553 }
3554 3582
3555 case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE: { 3583 if (notif->size == sizeof(*x)) {
3556 IPW_ERROR("Dino config\n"); 3584 IPW_ERROR("Frag length: %d\n", x->frag_length);
3557 if (priv->hcmd && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) { 3585 } else {
3558 /* TODO: Do anything special? */ 3586 IPW_ERROR("Frag length of wrong size %d "
3559 } else { 3587 "(should be %zd)\n",
3560 IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n"); 3588 notif->size, sizeof(*x));
3589 }
3590 break;
3561 } 3591 }
3562 break;
3563 }
3564 3592
3565 case HOST_NOTIFICATION_STATUS_BEACON_STATE: { 3593 case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION:{
3566 struct notif_beacon_state *x = &notif->u.beacon_state; 3594 struct notif_link_deterioration *x =
3567 if (notif->size != sizeof(*x)) { 3595 &notif->u.link_deterioration;
3568 IPW_ERROR("Beacon state of wrong size %d (should " 3596 if (notif->size == sizeof(*x)) {
3569 "be %zd)\n", notif->size, sizeof(*x)); 3597 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
3598 "link deterioration: '%s' " MAC_FMT
3599 " \n", escape_essid(priv->essid,
3600 priv->essid_len),
3601 MAC_ARG(priv->bssid));
3602 memcpy(&priv->last_link_deterioration, x,
3603 sizeof(*x));
3604 } else {
3605 IPW_ERROR("Link Deterioration of wrong size %d "
3606 "(should be %zd)\n",
3607 notif->size, sizeof(*x));
3608 }
3570 break; 3609 break;
3571 } 3610 }
3572 3611
3573 if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) { 3612 case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE:{
3574 if (priv->status & STATUS_SCANNING) { 3613 IPW_ERROR("Dino config\n");
3575 /* Stop scan to keep fw from getting 3614 if (priv->hcmd
3576 * stuck... */ 3615 && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) {
3577 queue_work(priv->workqueue, 3616 /* TODO: Do anything special? */
3578 &priv->abort_scan); 3617 } else {
3618 IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n");
3579 } 3619 }
3620 break;
3621 }
3580 3622
3581 if (x->number > priv->missed_beacon_threshold && 3623 case HOST_NOTIFICATION_STATUS_BEACON_STATE:{
3582 priv->status & STATUS_ASSOCIATED) { 3624 struct notif_beacon_state *x = &notif->u.beacon_state;
3583 IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF | 3625 if (notif->size != sizeof(*x)) {
3584 IPW_DL_STATE, 3626 IPW_ERROR
3585 "Missed beacon: %d - disassociate\n", 3627 ("Beacon state of wrong size %d (should "
3586 x->number); 3628 "be %zd)\n", notif->size, sizeof(*x));
3587 queue_work(priv->workqueue, 3629 break;
3588 &priv->disassociate);
3589 } else if (x->number > priv->roaming_threshold) {
3590 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
3591 "Missed beacon: %d - initiate "
3592 "roaming\n",
3593 x->number);
3594 queue_work(priv->workqueue,
3595 &priv->roam);
3596 } else {
3597 IPW_DEBUG_NOTIF("Missed beacon: %d\n",
3598 x->number);
3599 } 3630 }
3600 3631
3601 priv->notif_missed_beacons = x->number; 3632 if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) {
3633 if (priv->status & STATUS_SCANNING) {
3634 /* Stop scan to keep fw from getting
3635 * stuck... */
3636 queue_work(priv->workqueue,
3637 &priv->abort_scan);
3638 }
3639
3640 if (x->number > priv->missed_beacon_threshold &&
3641 priv->status & STATUS_ASSOCIATED) {
3642 IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF |
3643 IPW_DL_STATE,
3644 "Missed beacon: %d - disassociate\n",
3645 x->number);
3646 queue_work(priv->workqueue,
3647 &priv->disassociate);
3648 } else if (x->number > priv->roaming_threshold) {
3649 IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
3650 "Missed beacon: %d - initiate "
3651 "roaming\n", x->number);
3652 queue_work(priv->workqueue,
3653 &priv->roam);
3654 } else {
3655 IPW_DEBUG_NOTIF("Missed beacon: %d\n",
3656 x->number);
3657 }
3658
3659 priv->notif_missed_beacons = x->number;
3602 3660
3603 } 3661 }
3604 3662
3663 break;
3664 }
3605 3665
3606 break; 3666 case HOST_NOTIFICATION_STATUS_TGI_TX_KEY:{
3607 } 3667 struct notif_tgi_tx_key *x = &notif->u.tgi_tx_key;
3668 if (notif->size == sizeof(*x)) {
3669 IPW_ERROR("TGi Tx Key: state 0x%02x sec type "
3670 "0x%02x station %d\n",
3671 x->key_state, x->security_type,
3672 x->station_index);
3673 break;
3674 }
3608 3675
3609 case HOST_NOTIFICATION_STATUS_TGI_TX_KEY: { 3676 IPW_ERROR
3610 struct notif_tgi_tx_key *x = &notif->u.tgi_tx_key; 3677 ("TGi Tx Key of wrong size %d (should be %zd)\n",
3611 if (notif->size==sizeof(*x)) { 3678 notif->size, sizeof(*x));
3612 IPW_ERROR("TGi Tx Key: state 0x%02x sec type "
3613 "0x%02x station %d\n",
3614 x->key_state,x->security_type,
3615 x->station_index);
3616 break; 3679 break;
3617 } 3680 }
3618 3681
3619 IPW_ERROR("TGi Tx Key of wrong size %d (should be %zd)\n", 3682 case HOST_NOTIFICATION_CALIB_KEEP_RESULTS:{
3620 notif->size, sizeof(*x)); 3683 struct notif_calibration *x = &notif->u.calibration;
3621 break;
3622 }
3623 3684
3624 case HOST_NOTIFICATION_CALIB_KEEP_RESULTS: { 3685 if (notif->size == sizeof(*x)) {
3625 struct notif_calibration *x = &notif->u.calibration; 3686 memcpy(&priv->calib, x, sizeof(*x));
3687 IPW_DEBUG_INFO("TODO: Calibration\n");
3688 break;
3689 }
3626 3690
3627 if (notif->size == sizeof(*x)) { 3691 IPW_ERROR
3628 memcpy(&priv->calib, x, sizeof(*x)); 3692 ("Calibration of wrong size %d (should be %zd)\n",
3629 IPW_DEBUG_INFO("TODO: Calibration\n"); 3693 notif->size, sizeof(*x));
3630 break; 3694 break;
3631 } 3695 }
3632 3696
3633 IPW_ERROR("Calibration of wrong size %d (should be %zd)\n", 3697 case HOST_NOTIFICATION_NOISE_STATS:{
3634 notif->size, sizeof(*x)); 3698 if (notif->size == sizeof(u32)) {
3635 break; 3699 priv->last_noise =
3636 } 3700 (u8) (notif->u.noise.value & 0xff);
3701 average_add(&priv->average_noise,
3702 priv->last_noise);
3703 break;
3704 }
3637 3705
3638 case HOST_NOTIFICATION_NOISE_STATS: { 3706 IPW_ERROR
3639 if (notif->size == sizeof(u32)) { 3707 ("Noise stat is wrong size %d (should be %zd)\n",
3640 priv->last_noise = (u8)(notif->u.noise.value & 0xff); 3708 notif->size, sizeof(u32));
3641 average_add(&priv->average_noise, priv->last_noise);
3642 break; 3709 break;
3643 } 3710 }
3644 3711
3645 IPW_ERROR("Noise stat is wrong size %d (should be %zd)\n",
3646 notif->size, sizeof(u32));
3647 break;
3648 }
3649
3650 default: 3712 default:
3651 IPW_ERROR("Unknown notification: " 3713 IPW_ERROR("Unknown notification: "
3652 "subtype=%d,flags=0x%2x,size=%d\n", 3714 "subtype=%d,flags=0x%2x,size=%d\n",
@@ -3680,8 +3742,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
3680 rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx, 3742 rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx,
3681 CX2_TX_QUEUE_0_READ_INDEX, 3743 CX2_TX_QUEUE_0_READ_INDEX,
3682 CX2_TX_QUEUE_0_WRITE_INDEX, 3744 CX2_TX_QUEUE_0_WRITE_INDEX,
3683 CX2_TX_QUEUE_0_BD_BASE, 3745 CX2_TX_QUEUE_0_BD_BASE, CX2_TX_QUEUE_0_BD_SIZE);
3684 CX2_TX_QUEUE_0_BD_SIZE);
3685 if (rc) { 3746 if (rc) {
3686 IPW_ERROR("Tx 0 queue init failed\n"); 3747 IPW_ERROR("Tx 0 queue init failed\n");
3687 goto error; 3748 goto error;
@@ -3689,8 +3750,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
3689 rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx, 3750 rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx,
3690 CX2_TX_QUEUE_1_READ_INDEX, 3751 CX2_TX_QUEUE_1_READ_INDEX,
3691 CX2_TX_QUEUE_1_WRITE_INDEX, 3752 CX2_TX_QUEUE_1_WRITE_INDEX,
3692 CX2_TX_QUEUE_1_BD_BASE, 3753 CX2_TX_QUEUE_1_BD_BASE, CX2_TX_QUEUE_1_BD_SIZE);
3693 CX2_TX_QUEUE_1_BD_SIZE);
3694 if (rc) { 3754 if (rc) {
3695 IPW_ERROR("Tx 1 queue init failed\n"); 3755 IPW_ERROR("Tx 1 queue init failed\n");
3696 goto error; 3756 goto error;
@@ -3698,8 +3758,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
3698 rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx, 3758 rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx,
3699 CX2_TX_QUEUE_2_READ_INDEX, 3759 CX2_TX_QUEUE_2_READ_INDEX,
3700 CX2_TX_QUEUE_2_WRITE_INDEX, 3760 CX2_TX_QUEUE_2_WRITE_INDEX,
3701 CX2_TX_QUEUE_2_BD_BASE, 3761 CX2_TX_QUEUE_2_BD_BASE, CX2_TX_QUEUE_2_BD_SIZE);
3702 CX2_TX_QUEUE_2_BD_SIZE);
3703 if (rc) { 3762 if (rc) {
3704 IPW_ERROR("Tx 2 queue init failed\n"); 3763 IPW_ERROR("Tx 2 queue init failed\n");
3705 goto error; 3764 goto error;
@@ -3707,8 +3766,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
3707 rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx, 3766 rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx,
3708 CX2_TX_QUEUE_3_READ_INDEX, 3767 CX2_TX_QUEUE_3_READ_INDEX,
3709 CX2_TX_QUEUE_3_WRITE_INDEX, 3768 CX2_TX_QUEUE_3_WRITE_INDEX,
3710 CX2_TX_QUEUE_3_BD_BASE, 3769 CX2_TX_QUEUE_3_BD_BASE, CX2_TX_QUEUE_3_BD_SIZE);
3711 CX2_TX_QUEUE_3_BD_SIZE);
3712 if (rc) { 3770 if (rc) {
3713 IPW_ERROR("Tx 3 queue init failed\n"); 3771 IPW_ERROR("Tx 3 queue init failed\n");
3714 goto error; 3772 goto error;
@@ -3718,7 +3776,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
3718 priv->rx_pend_max = 0; 3776 priv->rx_pend_max = 0;
3719 return rc; 3777 return rc;
3720 3778
3721 error: 3779 error:
3722 ipw_tx_queue_free(priv); 3780 ipw_tx_queue_free(priv);
3723 return rc; 3781 return rc;
3724} 3782}
@@ -3746,8 +3804,8 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv,
3746 hw_tail = ipw_read32(priv, q->reg_r); 3804 hw_tail = ipw_read32(priv, q->reg_r);
3747 if (hw_tail >= q->n_bd) { 3805 if (hw_tail >= q->n_bd) {
3748 IPW_ERROR 3806 IPW_ERROR
3749 ("Read index for DMA queue (%d) is out of range [0-%d)\n", 3807 ("Read index for DMA queue (%d) is out of range [0-%d)\n",
3750 hw_tail, q->n_bd); 3808 hw_tail, q->n_bd);
3751 goto done; 3809 goto done;
3752 } 3810 }
3753 for (; q->last_used != hw_tail; 3811 for (; q->last_used != hw_tail;
@@ -3755,7 +3813,7 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv,
3755 ipw_queue_tx_free_tfd(priv, txq); 3813 ipw_queue_tx_free_tfd(priv, txq);
3756 priv->tx_packets++; 3814 priv->tx_packets++;
3757 } 3815 }
3758 done: 3816 done:
3759 if (ipw_queue_space(q) > q->low_mark && qindex >= 0) { 3817 if (ipw_queue_space(q) > q->low_mark && qindex >= 0) {
3760 __maybe_wake_tx(priv); 3818 __maybe_wake_tx(priv);
3761 } 3819 }
@@ -3795,8 +3853,6 @@ static int ipw_queue_tx_hcmd(struct ipw_priv *priv, int hcmd, void *buf,
3795 return 0; 3853 return 0;
3796} 3854}
3797 3855
3798
3799
3800/* 3856/*
3801 * Rx theory of operation 3857 * Rx theory of operation
3802 * 3858 *
@@ -3933,9 +3989,9 @@ static void ipw_rx_queue_replenish(void *data)
3933 list_del(element); 3989 list_del(element);
3934 3990
3935 rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data; 3991 rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data;
3936 rxb->dma_addr = pci_map_single( 3992 rxb->dma_addr =
3937 priv->pci_dev, rxb->skb->data, CX2_RX_BUF_SIZE, 3993 pci_map_single(priv->pci_dev, rxb->skb->data,
3938 PCI_DMA_FROMDEVICE); 3994 CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
3939 3995
3940 list_add_tail(&rxb->list, &rxq->rx_free); 3996 list_add_tail(&rxb->list, &rxq->rx_free);
3941 rxq->free_count++; 3997 rxq->free_count++;
@@ -3950,8 +4006,7 @@ static void ipw_rx_queue_replenish(void *data)
3950 * This free routine walks the list of POOL entries and if SKB is set to 4006 * This free routine walks the list of POOL entries and if SKB is set to
3951 * non NULL it is unmapped and freed 4007 * non NULL it is unmapped and freed
3952 */ 4008 */
3953static void ipw_rx_queue_free(struct ipw_priv *priv, 4009static void ipw_rx_queue_free(struct ipw_priv *priv, struct ipw_rx_queue *rxq)
3954 struct ipw_rx_queue *rxq)
3955{ 4010{
3956 int i; 4011 int i;
3957 4012
@@ -3961,8 +4016,7 @@ static void ipw_rx_queue_free(struct ipw_priv *priv,
3961 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { 4016 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
3962 if (rxq->pool[i].skb != NULL) { 4017 if (rxq->pool[i].skb != NULL) {
3963 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, 4018 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
3964 CX2_RX_BUF_SIZE, 4019 CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
3965 PCI_DMA_FROMDEVICE);
3966 dev_kfree_skb(rxq->pool[i].skb); 4020 dev_kfree_skb(rxq->pool[i].skb);
3967 } 4021 }
3968 } 4022 }
@@ -4001,28 +4055,28 @@ static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate)
4001 switch (rate) { 4055 switch (rate) {
4002 case IEEE80211_OFDM_RATE_6MB: 4056 case IEEE80211_OFDM_RATE_6MB:
4003 return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? 4057 return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ?
4004 1 : 0; 4058 1 : 0;
4005 case IEEE80211_OFDM_RATE_9MB: 4059 case IEEE80211_OFDM_RATE_9MB:
4006 return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? 4060 return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ?
4007 1 : 0; 4061 1 : 0;
4008 case IEEE80211_OFDM_RATE_12MB: 4062 case IEEE80211_OFDM_RATE_12MB:
4009 return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 4063 return priv->
4010 1 : 0; 4064 rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0;
4011 case IEEE80211_OFDM_RATE_18MB: 4065 case IEEE80211_OFDM_RATE_18MB:
4012 return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 4066 return priv->
4013 1 : 0; 4067 rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0;
4014 case IEEE80211_OFDM_RATE_24MB: 4068 case IEEE80211_OFDM_RATE_24MB:
4015 return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 4069 return priv->
4016 1 : 0; 4070 rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0;
4017 case IEEE80211_OFDM_RATE_36MB: 4071 case IEEE80211_OFDM_RATE_36MB:
4018 return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 4072 return priv->
4019 1 : 0; 4073 rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0;
4020 case IEEE80211_OFDM_RATE_48MB: 4074 case IEEE80211_OFDM_RATE_48MB:
4021 return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 4075 return priv->
4022 1 : 0; 4076 rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0;
4023 case IEEE80211_OFDM_RATE_54MB: 4077 case IEEE80211_OFDM_RATE_54MB:
4024 return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 4078 return priv->
4025 1 : 0; 4079 rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0;
4026 default: 4080 default:
4027 return 0; 4081 return 0;
4028 } 4082 }
@@ -4074,10 +4128,11 @@ static int ipw_compatible_rates(struct ipw_priv *priv,
4074 int num_rates, i; 4128 int num_rates, i;
4075 4129
4076 memset(rates, 0, sizeof(*rates)); 4130 memset(rates, 0, sizeof(*rates));
4077 num_rates = min(network->rates_len, (u8)IPW_MAX_RATES); 4131 num_rates = min(network->rates_len, (u8) IPW_MAX_RATES);
4078 rates->num_rates = 0; 4132 rates->num_rates = 0;
4079 for (i = 0; i < num_rates; i++) { 4133 for (i = 0; i < num_rates; i++) {
4080 if (!ipw_is_rate_in_mask(priv, network->mode, network->rates[i])) { 4134 if (!ipw_is_rate_in_mask
4135 (priv, network->mode, network->rates[i])) {
4081 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", 4136 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
4082 network->rates[i], priv->rates_mask); 4137 network->rates[i], priv->rates_mask);
4083 continue; 4138 continue;
@@ -4086,15 +4141,18 @@ static int ipw_compatible_rates(struct ipw_priv *priv,
4086 rates->supported_rates[rates->num_rates++] = network->rates[i]; 4141 rates->supported_rates[rates->num_rates++] = network->rates[i];
4087 } 4142 }
4088 4143
4089 num_rates = min(network->rates_ex_len, (u8)(IPW_MAX_RATES - num_rates)); 4144 num_rates =
4145 min(network->rates_ex_len, (u8) (IPW_MAX_RATES - num_rates));
4090 for (i = 0; i < num_rates; i++) { 4146 for (i = 0; i < num_rates; i++) {
4091 if (!ipw_is_rate_in_mask(priv, network->mode, network->rates_ex[i])) { 4147 if (!ipw_is_rate_in_mask
4148 (priv, network->mode, network->rates_ex[i])) {
4092 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", 4149 IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n",
4093 network->rates_ex[i], priv->rates_mask); 4150 network->rates_ex[i], priv->rates_mask);
4094 continue; 4151 continue;
4095 } 4152 }
4096 4153
4097 rates->supported_rates[rates->num_rates++] = network->rates_ex[i]; 4154 rates->supported_rates[rates->num_rates++] =
4155 network->rates_ex[i];
4098 } 4156 }
4099 4157
4100 return rates->num_rates; 4158 return rates->num_rates;
@@ -4113,65 +4171,65 @@ static inline void ipw_copy_rates(struct ipw_supported_rates *dest,
4113 * mask should ever be used -- right now all callers to add the scan rates are 4171 * mask should ever be used -- right now all callers to add the scan rates are
4114 * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */ 4172 * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */
4115static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates, 4173static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates,
4116 u8 modulation, u32 rate_mask) 4174 u8 modulation, u32 rate_mask)
4117{ 4175{
4118 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? 4176 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ?
4119 IEEE80211_BASIC_RATE_MASK : 0; 4177 IEEE80211_BASIC_RATE_MASK : 0;
4120 4178
4121 if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK) 4179 if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK)
4122 rates->supported_rates[rates->num_rates++] = 4180 rates->supported_rates[rates->num_rates++] =
4123 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; 4181 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
4124 4182
4125 if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK) 4183 if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK)
4126 rates->supported_rates[rates->num_rates++] = 4184 rates->supported_rates[rates->num_rates++] =
4127 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; 4185 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
4128 4186
4129 if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK) 4187 if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK)
4130 rates->supported_rates[rates->num_rates++] = basic_mask | 4188 rates->supported_rates[rates->num_rates++] = basic_mask |
4131 IEEE80211_CCK_RATE_5MB; 4189 IEEE80211_CCK_RATE_5MB;
4132 4190
4133 if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK) 4191 if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK)
4134 rates->supported_rates[rates->num_rates++] = basic_mask | 4192 rates->supported_rates[rates->num_rates++] = basic_mask |
4135 IEEE80211_CCK_RATE_11MB; 4193 IEEE80211_CCK_RATE_11MB;
4136} 4194}
4137 4195
4138static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates, 4196static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates,
4139 u8 modulation, u32 rate_mask) 4197 u8 modulation, u32 rate_mask)
4140{ 4198{
4141 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? 4199 u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ?
4142 IEEE80211_BASIC_RATE_MASK : 0; 4200 IEEE80211_BASIC_RATE_MASK : 0;
4143 4201
4144 if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK) 4202 if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK)
4145 rates->supported_rates[rates->num_rates++] = basic_mask | 4203 rates->supported_rates[rates->num_rates++] = basic_mask |
4146 IEEE80211_OFDM_RATE_6MB; 4204 IEEE80211_OFDM_RATE_6MB;
4147 4205
4148 if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK) 4206 if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK)
4149 rates->supported_rates[rates->num_rates++] = 4207 rates->supported_rates[rates->num_rates++] =
4150 IEEE80211_OFDM_RATE_9MB; 4208 IEEE80211_OFDM_RATE_9MB;
4151 4209
4152 if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK) 4210 if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK)
4153 rates->supported_rates[rates->num_rates++] = basic_mask | 4211 rates->supported_rates[rates->num_rates++] = basic_mask |
4154 IEEE80211_OFDM_RATE_12MB; 4212 IEEE80211_OFDM_RATE_12MB;
4155 4213
4156 if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK) 4214 if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK)
4157 rates->supported_rates[rates->num_rates++] = 4215 rates->supported_rates[rates->num_rates++] =
4158 IEEE80211_OFDM_RATE_18MB; 4216 IEEE80211_OFDM_RATE_18MB;
4159 4217
4160 if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK) 4218 if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK)
4161 rates->supported_rates[rates->num_rates++] = basic_mask | 4219 rates->supported_rates[rates->num_rates++] = basic_mask |
4162 IEEE80211_OFDM_RATE_24MB; 4220 IEEE80211_OFDM_RATE_24MB;
4163 4221
4164 if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK) 4222 if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK)
4165 rates->supported_rates[rates->num_rates++] = 4223 rates->supported_rates[rates->num_rates++] =
4166 IEEE80211_OFDM_RATE_36MB; 4224 IEEE80211_OFDM_RATE_36MB;
4167 4225
4168 if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK) 4226 if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK)
4169 rates->supported_rates[rates->num_rates++] = 4227 rates->supported_rates[rates->num_rates++] =
4170 IEEE80211_OFDM_RATE_48MB; 4228 IEEE80211_OFDM_RATE_48MB;
4171 4229
4172 if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK) 4230 if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK)
4173 rates->supported_rates[rates->num_rates++] = 4231 rates->supported_rates[rates->num_rates++] =
4174 IEEE80211_OFDM_RATE_54MB; 4232 IEEE80211_OFDM_RATE_54MB;
4175} 4233}
4176 4234
4177struct ipw_network_match { 4235struct ipw_network_match {
@@ -4179,11 +4237,9 @@ struct ipw_network_match {
4179 struct ipw_supported_rates rates; 4237 struct ipw_supported_rates rates;
4180}; 4238};
4181 4239
4182static int ipw_best_network( 4240static int ipw_best_network(struct ipw_priv *priv,
4183 struct ipw_priv *priv, 4241 struct ipw_network_match *match,
4184 struct ipw_network_match *match, 4242 struct ieee80211_network *network, int roaming)
4185 struct ieee80211_network *network,
4186 int roaming)
4187{ 4243{
4188 struct ipw_supported_rates rates; 4244 struct ipw_supported_rates rates;
4189 4245
@@ -4231,21 +4287,21 @@ static int ipw_best_network(
4231 memcmp(network->ssid, priv->essid, 4287 memcmp(network->ssid, priv->essid,
4232 min(network->ssid_len, priv->essid_len)))) { 4288 min(network->ssid_len, priv->essid_len)))) {
4233 char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 4289 char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
4234 strncpy(escaped, escape_essid( 4290 strncpy(escaped,
4235 network->ssid, network->ssid_len), 4291 escape_essid(network->ssid, network->ssid_len),
4236 sizeof(escaped)); 4292 sizeof(escaped));
4237 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " 4293 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
4238 "because of ESSID mismatch: '%s'.\n", 4294 "because of ESSID mismatch: '%s'.\n",
4239 escaped, MAC_ARG(network->bssid), 4295 escaped, MAC_ARG(network->bssid),
4240 escape_essid(priv->essid, priv->essid_len)); 4296 escape_essid(priv->essid,
4297 priv->essid_len));
4241 return 0; 4298 return 0;
4242 } 4299 }
4243 } 4300 }
4244 4301
4245 /* If the old network rate is better than this one, don't bother 4302 /* If the old network rate is better than this one, don't bother
4246 * testing everything else. */ 4303 * testing everything else. */
4247 if (match->network && match->network->stats.rssi > 4304 if (match->network && match->network->stats.rssi > network->stats.rssi) {
4248 network->stats.rssi) {
4249 char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 4305 char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
4250 strncpy(escaped, 4306 strncpy(escaped,
4251 escape_essid(network->ssid, network->ssid_len), 4307 escape_essid(network->ssid, network->ssid_len),
@@ -4303,7 +4359,7 @@ static int ipw_best_network(
4303 priv->capability & CAP_PRIVACY_ON ? "on" : 4359 priv->capability & CAP_PRIVACY_ON ? "on" :
4304 "off", 4360 "off",
4305 network->capability & 4361 network->capability &
4306 WLAN_CAPABILITY_PRIVACY ?"on" : "off"); 4362 WLAN_CAPABILITY_PRIVACY ? "on" : "off");
4307 return 0; 4363 return 0;
4308 } 4364 }
4309 4365
@@ -4312,8 +4368,7 @@ static int ipw_best_network(
4312 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " 4368 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
4313 "because of BSSID mismatch: " MAC_FMT ".\n", 4369 "because of BSSID mismatch: " MAC_FMT ".\n",
4314 escape_essid(network->ssid, network->ssid_len), 4370 escape_essid(network->ssid, network->ssid_len),
4315 MAC_ARG(network->bssid), 4371 MAC_ARG(network->bssid), MAC_ARG(priv->bssid));
4316 MAC_ARG(priv->bssid));
4317 return 0; 4372 return 0;
4318 } 4373 }
4319 4374
@@ -4351,9 +4406,8 @@ static int ipw_best_network(
4351 return 1; 4406 return 1;
4352} 4407}
4353 4408
4354
4355static void ipw_adhoc_create(struct ipw_priv *priv, 4409static void ipw_adhoc_create(struct ipw_priv *priv,
4356 struct ieee80211_network *network) 4410 struct ieee80211_network *network)
4357{ 4411{
4358 /* 4412 /*
4359 * For the purposes of scanning, we can set our wireless mode 4413 * For the purposes of scanning, we can set our wireless mode
@@ -4393,8 +4447,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
4393 if (priv->capability & CAP_PRIVACY_ON) 4447 if (priv->capability & CAP_PRIVACY_ON)
4394 network->capability |= WLAN_CAPABILITY_PRIVACY; 4448 network->capability |= WLAN_CAPABILITY_PRIVACY;
4395 network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH); 4449 network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH);
4396 memcpy(network->rates, priv->rates.supported_rates, 4450 memcpy(network->rates, priv->rates.supported_rates, network->rates_len);
4397 network->rates_len);
4398 network->rates_ex_len = priv->rates.num_rates - network->rates_len; 4451 network->rates_ex_len = priv->rates.num_rates - network->rates_len;
4399 memcpy(network->rates_ex, 4452 memcpy(network->rates_ex,
4400 &priv->rates.supported_rates[network->rates_len], 4453 &priv->rates.supported_rates[network->rates_len],
@@ -4404,13 +4457,13 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
4404 network->last_associate = 0; 4457 network->last_associate = 0;
4405 network->time_stamp[0] = 0; 4458 network->time_stamp[0] = 0;
4406 network->time_stamp[1] = 0; 4459 network->time_stamp[1] = 0;
4407 network->beacon_interval = 100; /* Default */ 4460 network->beacon_interval = 100; /* Default */
4408 network->listen_interval = 10; /* Default */ 4461 network->listen_interval = 10; /* Default */
4409 network->atim_window = 0; /* Default */ 4462 network->atim_window = 0; /* Default */
4410#ifdef CONFIG_IEEE80211_WPA 4463#ifdef CONFIG_IEEE80211_WPA
4411 network->wpa_ie_len = 0; 4464 network->wpa_ie_len = 0;
4412 network->rsn_ie_len = 0; 4465 network->rsn_ie_len = 0;
4413#endif /* CONFIG_IEEE80211_WPA */ 4466#endif /* CONFIG_IEEE80211_WPA */
4414} 4467}
4415 4468
4416static void ipw_send_wep_keys(struct ipw_priv *priv) 4469static void ipw_send_wep_keys(struct ipw_priv *priv)
@@ -4464,14 +4517,12 @@ static void ipw_debug_config(struct ipw_priv *priv)
4464 IPW_DEBUG_INFO("Scan completed, no valid APs matched " 4517 IPW_DEBUG_INFO("Scan completed, no valid APs matched "
4465 "[CFG 0x%08X]\n", priv->config); 4518 "[CFG 0x%08X]\n", priv->config);
4466 if (priv->config & CFG_STATIC_CHANNEL) 4519 if (priv->config & CFG_STATIC_CHANNEL)
4467 IPW_DEBUG_INFO("Channel locked to %d\n", 4520 IPW_DEBUG_INFO("Channel locked to %d\n", priv->channel);
4468 priv->channel);
4469 else 4521 else
4470 IPW_DEBUG_INFO("Channel unlocked.\n"); 4522 IPW_DEBUG_INFO("Channel unlocked.\n");
4471 if (priv->config & CFG_STATIC_ESSID) 4523 if (priv->config & CFG_STATIC_ESSID)
4472 IPW_DEBUG_INFO("ESSID locked to '%s'\n", 4524 IPW_DEBUG_INFO("ESSID locked to '%s'\n",
4473 escape_essid(priv->essid, 4525 escape_essid(priv->essid, priv->essid_len));
4474 priv->essid_len));
4475 else 4526 else
4476 IPW_DEBUG_INFO("ESSID unlocked.\n"); 4527 IPW_DEBUG_INFO("ESSID unlocked.\n");
4477 if (priv->config & CFG_STATIC_BSSID) 4528 if (priv->config & CFG_STATIC_BSSID)
@@ -4502,7 +4553,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv,
4502 * Tx rates */ 4553 * Tx rates */
4503 4554
4504 switch (priv->ieee->freq_band) { 4555 switch (priv->ieee->freq_band) {
4505 case IEEE80211_52GHZ_BAND: /* A only */ 4556 case IEEE80211_52GHZ_BAND: /* A only */
4506 /* IEEE_A */ 4557 /* IEEE_A */
4507 if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) { 4558 if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) {
4508 /* Invalid fixed rate mask */ 4559 /* Invalid fixed rate mask */
@@ -4513,7 +4564,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv,
4513 fr.tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A; 4564 fr.tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A;
4514 break; 4565 break;
4515 4566
4516 default: /* 2.4Ghz or Mixed */ 4567 default: /* 2.4Ghz or Mixed */
4517 /* IEEE_B */ 4568 /* IEEE_B */
4518 if (network->mode == IEEE_B) { 4569 if (network->mode == IEEE_B) {
4519 if (fr.tx_rates & ~IEEE80211_CCK_RATES_MASK) { 4570 if (fr.tx_rates & ~IEEE80211_CCK_RATES_MASK) {
@@ -4551,13 +4602,12 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv,
4551 } 4602 }
4552 4603
4553 reg = ipw_read32(priv, IPW_MEM_FIXED_OVERRIDE); 4604 reg = ipw_read32(priv, IPW_MEM_FIXED_OVERRIDE);
4554 ipw_write_reg32(priv, reg, *(u32*)&fr); 4605 ipw_write_reg32(priv, reg, *(u32 *) & fr);
4555} 4606}
4556 4607
4557static int ipw_associate_network(struct ipw_priv *priv, 4608static int ipw_associate_network(struct ipw_priv *priv,
4558 struct ieee80211_network *network, 4609 struct ieee80211_network *network,
4559 struct ipw_supported_rates *rates, 4610 struct ipw_supported_rates *rates, int roaming)
4560 int roaming)
4561{ 4611{
4562 int err; 4612 int err;
4563 4613
@@ -4566,7 +4616,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
4566 4616
4567 if (!(priv->config & CFG_STATIC_ESSID)) { 4617 if (!(priv->config & CFG_STATIC_ESSID)) {
4568 priv->essid_len = min(network->ssid_len, 4618 priv->essid_len = min(network->ssid_len,
4569 (u8)IW_ESSID_MAX_SIZE); 4619 (u8) IW_ESSID_MAX_SIZE);
4570 memcpy(priv->essid, network->ssid, priv->essid_len); 4620 memcpy(priv->essid, network->ssid, priv->essid_len);
4571 } 4621 }
4572 4622
@@ -4612,13 +4662,11 @@ static int ipw_associate_network(struct ipw_priv *priv,
4612 priv->capability & CAP_PRIVACY_ON ? " key=" : "", 4662 priv->capability & CAP_PRIVACY_ON ? " key=" : "",
4613 priv->capability & CAP_PRIVACY_ON ? 4663 priv->capability & CAP_PRIVACY_ON ?
4614 '1' + priv->sec.active_key : '.', 4664 '1' + priv->sec.active_key : '.',
4615 priv->capability & CAP_PRIVACY_ON ? 4665 priv->capability & CAP_PRIVACY_ON ? '.' : ' ');
4616 '.' : ' ');
4617 4666
4618 priv->assoc_request.beacon_interval = network->beacon_interval; 4667 priv->assoc_request.beacon_interval = network->beacon_interval;
4619 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && 4668 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
4620 (network->time_stamp[0] == 0) && 4669 (network->time_stamp[0] == 0) && (network->time_stamp[1] == 0)) {
4621 (network->time_stamp[1] == 0)) {
4622 priv->assoc_request.assoc_type = HC_IBSS_START; 4670 priv->assoc_request.assoc_type = HC_IBSS_START;
4623 priv->assoc_request.assoc_tsf_msw = 0; 4671 priv->assoc_request.assoc_tsf_msw = 0;
4624 priv->assoc_request.assoc_tsf_lsw = 0; 4672 priv->assoc_request.assoc_tsf_lsw = 0;
@@ -4637,8 +4685,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
4637 memset(&priv->assoc_request.dest, 0xFF, ETH_ALEN); 4685 memset(&priv->assoc_request.dest, 0xFF, ETH_ALEN);
4638 priv->assoc_request.atim_window = network->atim_window; 4686 priv->assoc_request.atim_window = network->atim_window;
4639 } else { 4687 } else {
4640 memcpy(&priv->assoc_request.dest, network->bssid, 4688 memcpy(&priv->assoc_request.dest, network->bssid, ETH_ALEN);
4641 ETH_ALEN);
4642 priv->assoc_request.atim_window = 0; 4689 priv->assoc_request.atim_window = 0;
4643 } 4690 }
4644 4691
@@ -4772,14 +4819,13 @@ static void ipw_associate(void *data)
4772 4819
4773 if (!(priv->config & CFG_ASSOCIATE) && 4820 if (!(priv->config & CFG_ASSOCIATE) &&
4774 !(priv->config & (CFG_STATIC_ESSID | 4821 !(priv->config & (CFG_STATIC_ESSID |
4775 CFG_STATIC_CHANNEL | 4822 CFG_STATIC_CHANNEL | CFG_STATIC_BSSID))) {
4776 CFG_STATIC_BSSID))) {
4777 IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n"); 4823 IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n");
4778 return; 4824 return;
4779 } 4825 }
4780 4826
4781 list_for_each_entry(network, &priv->ieee->network_list, list) 4827 list_for_each_entry(network, &priv->ieee->network_list, list)
4782 ipw_best_network(priv, &match, network, 0); 4828 ipw_best_network(priv, &match, network, 0);
4783 4829
4784 network = match.network; 4830 network = match.network;
4785 rates = &match.rates; 4831 rates = &match.rates;
@@ -4790,8 +4836,7 @@ static void ipw_associate(void *data)
4790 priv->config & CFG_STATIC_ESSID && 4836 priv->config & CFG_STATIC_ESSID &&
4791 !list_empty(&priv->ieee->network_free_list)) { 4837 !list_empty(&priv->ieee->network_free_list)) {
4792 element = priv->ieee->network_free_list.next; 4838 element = priv->ieee->network_free_list.next;
4793 network = list_entry(element, struct ieee80211_network, 4839 network = list_entry(element, struct ieee80211_network, list);
4794 list);
4795 ipw_adhoc_create(priv, network); 4840 ipw_adhoc_create(priv, network);
4796 rates = &priv->rates; 4841 rates = &priv->rates;
4797 list_del(element); 4842 list_del(element);
@@ -4813,8 +4858,8 @@ static void ipw_associate(void *data)
4813} 4858}
4814 4859
4815static inline void ipw_handle_data_packet(struct ipw_priv *priv, 4860static inline void ipw_handle_data_packet(struct ipw_priv *priv,
4816 struct ipw_rx_mem_buffer *rxb, 4861 struct ipw_rx_mem_buffer *rxb,
4817 struct ieee80211_rx_stats *stats) 4862 struct ieee80211_rx_stats *stats)
4818{ 4863{
4819 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; 4864 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
4820 4865
@@ -4846,11 +4891,10 @@ static inline void ipw_handle_data_packet(struct ipw_priv *priv,
4846 4891
4847 if (!ieee80211_rx(priv->ieee, rxb->skb, stats)) 4892 if (!ieee80211_rx(priv->ieee, rxb->skb, stats))
4848 priv->ieee->stats.rx_errors++; 4893 priv->ieee->stats.rx_errors++;
4849 else /* ieee80211_rx succeeded, so it now owns the SKB */ 4894 else /* ieee80211_rx succeeded, so it now owns the SKB */
4850 rxb->skb = NULL; 4895 rxb->skb = NULL;
4851} 4896}
4852 4897
4853
4854/* 4898/*
4855 * Main entry function for recieving a packet with 80211 headers. This 4899 * Main entry function for recieving a packet with 80211 headers. This
4856 * should be called when ever the FW has notified us that there is a new 4900 * should be called when ever the FW has notified us that there is a new
@@ -4885,125 +4929,152 @@ static void ipw_rx(struct ipw_priv *priv)
4885 pkt = (struct ipw_rx_packet *)rxb->skb->data; 4929 pkt = (struct ipw_rx_packet *)rxb->skb->data;
4886 IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n", 4930 IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n",
4887 pkt->header.message_type, 4931 pkt->header.message_type,
4888 pkt->header.rx_seq_num, 4932 pkt->header.rx_seq_num, pkt->header.control_bits);
4889 pkt->header.control_bits);
4890 4933
4891 switch (pkt->header.message_type) { 4934 switch (pkt->header.message_type) {
4892 case RX_FRAME_TYPE: /* 802.11 frame */ { 4935 case RX_FRAME_TYPE: /* 802.11 frame */ {
4893 struct ieee80211_rx_stats stats = { 4936 struct ieee80211_rx_stats stats = {
4894 .rssi = pkt->u.frame.rssi_dbm - 4937 .rssi = pkt->u.frame.rssi_dbm -
4895 IPW_RSSI_TO_DBM, 4938 IPW_RSSI_TO_DBM,
4896 .signal = pkt->u.frame.signal, 4939 .signal = pkt->u.frame.signal,
4897 .rate = pkt->u.frame.rate, 4940 .rate = pkt->u.frame.rate,
4898 .mac_time = jiffies, 4941 .mac_time = jiffies,
4899 .received_channel = 4942 .received_channel =
4900 pkt->u.frame.received_channel, 4943 pkt->u.frame.received_channel,
4901 .freq = (pkt->u.frame.control & (1<<0)) ? 4944 .freq =
4902 IEEE80211_24GHZ_BAND : IEEE80211_52GHZ_BAND, 4945 (pkt->u.frame.
4903 .len = pkt->u.frame.length, 4946 control & (1 << 0)) ?
4904 }; 4947 IEEE80211_24GHZ_BAND :
4905 4948 IEEE80211_52GHZ_BAND,
4906 if (stats.rssi != 0) 4949 .len = pkt->u.frame.length,
4907 stats.mask |= IEEE80211_STATMASK_RSSI; 4950 };
4908 if (stats.signal != 0) 4951
4909 stats.mask |= IEEE80211_STATMASK_SIGNAL; 4952 if (stats.rssi != 0)
4910 if (stats.rate != 0) 4953 stats.mask |= IEEE80211_STATMASK_RSSI;
4911 stats.mask |= IEEE80211_STATMASK_RATE; 4954 if (stats.signal != 0)
4912 4955 stats.mask |= IEEE80211_STATMASK_SIGNAL;
4913 priv->rx_packets++; 4956 if (stats.rate != 0)
4957 stats.mask |= IEEE80211_STATMASK_RATE;
4958
4959 priv->rx_packets++;
4914 4960
4915#ifdef CONFIG_IPW_PROMISC 4961#ifdef CONFIG_IPW_PROMISC
4916 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 4962 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
4917 ipw_handle_data_packet(priv, rxb, &stats); 4963 ipw_handle_data_packet(priv, rxb,
4918 break; 4964 &stats);
4919 } 4965 break;
4966 }
4920#endif 4967#endif
4921 4968
4922 header = (struct ieee80211_hdr *)(rxb->skb->data + 4969 header =
4923 IPW_RX_FRAME_SIZE); 4970 (struct ieee80211_hdr *)(rxb->skb->data +
4971 IPW_RX_FRAME_SIZE);
4924 /* TODO: Check Ad-Hoc dest/source and make sure 4972 /* TODO: Check Ad-Hoc dest/source and make sure
4925 * that we are actually parsing these packets 4973 * that we are actually parsing these packets
4926 * correctly -- we should probably use the 4974 * correctly -- we should probably use the
4927 * frame control of the packet and disregard 4975 * frame control of the packet and disregard
4928 * the current iw_mode */ 4976 * the current iw_mode */
4929 switch (priv->ieee->iw_mode) { 4977 switch (priv->ieee->iw_mode) {
4930 case IW_MODE_ADHOC: 4978 case IW_MODE_ADHOC:
4931 network_packet = 4979 network_packet =
4932 !memcmp(header->addr1, 4980 !memcmp(header->addr1,
4933 priv->net_dev->dev_addr, 4981 priv->net_dev->dev_addr,
4934 ETH_ALEN) || 4982 ETH_ALEN) ||
4935 !memcmp(header->addr3, 4983 !memcmp(header->addr3,
4936 priv->bssid, ETH_ALEN) || 4984 priv->bssid, ETH_ALEN) ||
4937 is_broadcast_ether_addr(header->addr1) || 4985 is_broadcast_ether_addr(header->
4938 is_multicast_ether_addr(header->addr1); 4986 addr1)
4939 break; 4987 || is_multicast_ether_addr(header->
4940 4988 addr1);
4941 case IW_MODE_INFRA: 4989 break;
4942 default: 4990
4943 network_packet = 4991 case IW_MODE_INFRA:
4944 !memcmp(header->addr3, 4992 default:
4945 priv->bssid, ETH_ALEN) || 4993 network_packet =
4946 !memcmp(header->addr1, 4994 !memcmp(header->addr3,
4947 priv->net_dev->dev_addr, 4995 priv->bssid, ETH_ALEN) ||
4948 ETH_ALEN) || 4996 !memcmp(header->addr1,
4949 is_broadcast_ether_addr(header->addr1) || 4997 priv->net_dev->dev_addr,
4950 is_multicast_ether_addr(header->addr1); 4998 ETH_ALEN) ||
4999 is_broadcast_ether_addr(header->
5000 addr1)
5001 || is_multicast_ether_addr(header->
5002 addr1);
5003 break;
5004 }
5005
5006 if (network_packet && priv->assoc_network) {
5007 priv->assoc_network->stats.rssi =
5008 stats.rssi;
5009 average_add(&priv->average_rssi,
5010 stats.rssi);
5011 priv->last_rx_rssi = stats.rssi;
5012 }
5013
5014 IPW_DEBUG_RX("Frame: len=%u\n",
5015 pkt->u.frame.length);
5016
5017 if (pkt->u.frame.length < frame_hdr_len(header)) {
5018 IPW_DEBUG_DROP
5019 ("Received packet is too small. "
5020 "Dropping.\n");
5021 priv->ieee->stats.rx_errors++;
5022 priv->wstats.discard.misc++;
5023 break;
5024 }
5025
5026 switch (WLAN_FC_GET_TYPE(header->frame_ctl)) {
5027 case IEEE80211_FTYPE_MGMT:
5028 ieee80211_rx_mgt(priv->ieee, header,
5029 &stats);
5030 if (priv->ieee->iw_mode == IW_MODE_ADHOC
5031 &&
5032 ((WLAN_FC_GET_STYPE
5033 (header->frame_ctl) ==
5034 IEEE80211_STYPE_PROBE_RESP)
5035 ||
5036 (WLAN_FC_GET_STYPE
5037 (header->frame_ctl) ==
5038 IEEE80211_STYPE_BEACON))
5039 && !memcmp(header->addr3,
5040 priv->bssid, ETH_ALEN))
5041 ipw_add_station(priv,
5042 header->addr2);
5043 break;
5044
5045 case IEEE80211_FTYPE_CTL:
5046 break;
5047
5048 case IEEE80211_FTYPE_DATA:
5049 if (network_packet)
5050 ipw_handle_data_packet(priv,
5051 rxb,
5052 &stats);
5053 else
5054 IPW_DEBUG_DROP("Dropping: "
5055 MAC_FMT ", "
5056 MAC_FMT ", "
5057 MAC_FMT "\n",
5058 MAC_ARG(header->
5059 addr1),
5060 MAC_ARG(header->
5061 addr2),
5062 MAC_ARG(header->
5063 addr3));
5064 break;
5065 }
4951 break; 5066 break;
4952 } 5067 }
4953 5068
4954 if (network_packet && priv->assoc_network) { 5069 case RX_HOST_NOTIFICATION_TYPE:{
4955 priv->assoc_network->stats.rssi = stats.rssi; 5070 IPW_DEBUG_RX
4956 average_add(&priv->average_rssi, 5071 ("Notification: subtype=%02X flags=%02X size=%d\n",
4957 stats.rssi);
4958 priv->last_rx_rssi = stats.rssi;
4959 }
4960
4961 IPW_DEBUG_RX("Frame: len=%u\n", pkt->u.frame.length);
4962
4963 if (pkt->u.frame.length < frame_hdr_len(header)) {
4964 IPW_DEBUG_DROP("Received packet is too small. "
4965 "Dropping.\n");
4966 priv->ieee->stats.rx_errors++;
4967 priv->wstats.discard.misc++;
4968 break;
4969 }
4970
4971 switch (WLAN_FC_GET_TYPE(header->frame_ctl)) {
4972 case IEEE80211_FTYPE_MGMT:
4973 ieee80211_rx_mgt(priv->ieee, header, &stats);
4974 if (priv->ieee->iw_mode == IW_MODE_ADHOC &&
4975 ((WLAN_FC_GET_STYPE(header->frame_ctl) ==
4976 IEEE80211_STYPE_PROBE_RESP) ||
4977 (WLAN_FC_GET_STYPE(header->frame_ctl) ==
4978 IEEE80211_STYPE_BEACON)) &&
4979 !memcmp(header->addr3, priv->bssid, ETH_ALEN))
4980 ipw_add_station(priv, header->addr2);
4981 break;
4982
4983 case IEEE80211_FTYPE_CTL:
4984 break;
4985
4986 case IEEE80211_FTYPE_DATA:
4987 if (network_packet)
4988 ipw_handle_data_packet(priv, rxb, &stats);
4989 else
4990 IPW_DEBUG_DROP("Dropping: " MAC_FMT
4991 ", " MAC_FMT ", " MAC_FMT "\n",
4992 MAC_ARG(header->addr1), MAC_ARG(header->addr2),
4993 MAC_ARG(header->addr3));
4994 break;
4995 }
4996 break;
4997 }
4998
4999 case RX_HOST_NOTIFICATION_TYPE: {
5000 IPW_DEBUG_RX("Notification: subtype=%02X flags=%02X size=%d\n",
5001 pkt->u.notification.subtype, 5072 pkt->u.notification.subtype,
5002 pkt->u.notification.flags, 5073 pkt->u.notification.flags,
5003 pkt->u.notification.size); 5074 pkt->u.notification.size);
5004 ipw_rx_notification(priv, &pkt->u.notification); 5075 ipw_rx_notification(priv, &pkt->u.notification);
5005 break; 5076 break;
5006 } 5077 }
5007 5078
5008 default: 5079 default:
5009 IPW_DEBUG_RX("Bad Rx packet of type %d\n", 5080 IPW_DEBUG_RX("Bad Rx packet of type %d\n",
@@ -5088,10 +5159,10 @@ static int ipw_request_scan(struct ipw_priv *priv)
5088 /* If we are roaming, then make this a directed scan for the current 5159 /* If we are roaming, then make this a directed scan for the current
5089 * network. Otherwise, ensure that every other scan is a fast 5160 * network. Otherwise, ensure that every other scan is a fast
5090 * channel hop scan */ 5161 * channel hop scan */
5091 if ((priv->status & STATUS_ROAMING) || ( 5162 if ((priv->status & STATUS_ROAMING)
5092 !(priv->status & STATUS_ASSOCIATED) && 5163 || (!(priv->status & STATUS_ASSOCIATED)
5093 (priv->config & CFG_STATIC_ESSID) && 5164 && (priv->config & CFG_STATIC_ESSID)
5094 (scan.full_scan_index % 2))) { 5165 && (scan.full_scan_index % 2))) {
5095 err = ipw_send_ssid(priv, priv->essid, priv->essid_len); 5166 err = ipw_send_ssid(priv, priv->essid, priv->essid_len);
5096 if (err) { 5167 if (err) {
5097 IPW_DEBUG_HC("Attempt to send SSID command failed.\n"); 5168 IPW_DEBUG_HC("Attempt to send SSID command failed.\n");
@@ -5103,7 +5174,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
5103 scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN; 5174 scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN;
5104 } 5175 }
5105 5176
5106 if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { 5177 if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) {
5107 int start = channel_index; 5178 int start = channel_index;
5108 for (i = 0; i < MAX_A_CHANNELS; i++) { 5179 for (i = 0; i < MAX_A_CHANNELS; i++) {
5109 if (band_a_active_channel[i] == 0) 5180 if (band_a_active_channel[i] == 0)
@@ -5113,18 +5184,18 @@ static int ipw_request_scan(struct ipw_priv *priv)
5113 continue; 5184 continue;
5114 channel_index++; 5185 channel_index++;
5115 scan.channels_list[channel_index] = 5186 scan.channels_list[channel_index] =
5116 band_a_active_channel[i]; 5187 band_a_active_channel[i];
5117 ipw_set_scan_type(&scan, channel_index, scan_type); 5188 ipw_set_scan_type(&scan, channel_index, scan_type);
5118 } 5189 }
5119 5190
5120 if (start != channel_index) { 5191 if (start != channel_index) {
5121 scan.channels_list[start] = (u8)(IPW_A_MODE << 6) | 5192 scan.channels_list[start] = (u8) (IPW_A_MODE << 6) |
5122 (channel_index - start); 5193 (channel_index - start);
5123 channel_index++; 5194 channel_index++;
5124 } 5195 }
5125 } 5196 }
5126 5197
5127 if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { 5198 if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) {
5128 int start = channel_index; 5199 int start = channel_index;
5129 for (i = 0; i < MAX_B_CHANNELS; i++) { 5200 for (i = 0; i < MAX_B_CHANNELS; i++) {
5130 if (band_b_active_channel[i] == 0) 5201 if (band_b_active_channel[i] == 0)
@@ -5134,20 +5205,19 @@ static int ipw_request_scan(struct ipw_priv *priv)
5134 continue; 5205 continue;
5135 channel_index++; 5206 channel_index++;
5136 scan.channels_list[channel_index] = 5207 scan.channels_list[channel_index] =
5137 band_b_active_channel[i]; 5208 band_b_active_channel[i];
5138 ipw_set_scan_type(&scan, channel_index, scan_type); 5209 ipw_set_scan_type(&scan, channel_index, scan_type);
5139 } 5210 }
5140 5211
5141 if (start != channel_index) { 5212 if (start != channel_index) {
5142 scan.channels_list[start] = (u8)(IPW_B_MODE << 6) | 5213 scan.channels_list[start] = (u8) (IPW_B_MODE << 6) |
5143 (channel_index - start); 5214 (channel_index - start);
5144 } 5215 }
5145 } 5216 }
5146 5217
5147 err = ipw_send_scan_request_ext(priv, &scan); 5218 err = ipw_send_scan_request_ext(priv, &scan);
5148 if (err) { 5219 if (err) {
5149 IPW_DEBUG_HC("Sending scan command failed: %08X\n", 5220 IPW_DEBUG_HC("Sending scan command failed: %08X\n", err);
5150 err);
5151 return -EIO; 5221 return -EIO;
5152 } 5222 }
5153 5223
@@ -5199,9 +5269,8 @@ static int ipw_set_channel(struct ipw_priv *priv, u8 channel)
5199 priv->config |= CFG_STATIC_CHANNEL; 5269 priv->config |= CFG_STATIC_CHANNEL;
5200 5270
5201 if (priv->channel == channel) { 5271 if (priv->channel == channel) {
5202 IPW_DEBUG_INFO( 5272 IPW_DEBUG_INFO("Request to set channel to current value (%d)\n",
5203 "Request to set channel to current value (%d)\n", 5273 channel);
5204 channel);
5205 return 0; 5274 return 0;
5206 } 5275 }
5207 5276
@@ -5229,8 +5298,7 @@ static int ipw_wx_set_freq(struct net_device *dev,
5229 5298
5230 /* if setting by freq convert to channel */ 5299 /* if setting by freq convert to channel */
5231 if (fwrq->e == 1) { 5300 if (fwrq->e == 1) {
5232 if ((fwrq->m >= (int) 2.412e8 && 5301 if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) {
5233 fwrq->m <= (int) 2.487e8)) {
5234 int f = fwrq->m / 100000; 5302 int f = fwrq->m / 100000;
5235 int c = 0; 5303 int c = 0;
5236 5304
@@ -5248,12 +5316,11 @@ static int ipw_wx_set_freq(struct net_device *dev,
5248 return -EOPNOTSUPP; 5316 return -EOPNOTSUPP;
5249 5317
5250 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); 5318 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
5251 return ipw_set_channel(priv, (u8)fwrq->m); 5319 return ipw_set_channel(priv, (u8) fwrq->m);
5252 5320
5253 return 0; 5321 return 0;
5254} 5322}
5255 5323
5256
5257static int ipw_wx_get_freq(struct net_device *dev, 5324static int ipw_wx_get_freq(struct net_device *dev,
5258 struct iw_request_info *info, 5325 struct iw_request_info *info,
5259 union iwreq_data *wrqu, char *extra) 5326 union iwreq_data *wrqu, char *extra)
@@ -5306,7 +5373,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
5306 5373
5307 if (wrqu->mode == IW_MODE_MONITOR) 5374 if (wrqu->mode == IW_MODE_MONITOR)
5308 priv->net_dev->type = ARPHRD_IEEE80211; 5375 priv->net_dev->type = ARPHRD_IEEE80211;
5309#endif /* CONFIG_IPW_PROMISC */ 5376#endif /* CONFIG_IPW_PROMISC */
5310 5377
5311#ifdef CONFIG_PM 5378#ifdef CONFIG_PM
5312 /* Free the existing firmware and reset the fw_loaded 5379 /* Free the existing firmware and reset the fw_loaded
@@ -5324,12 +5391,12 @@ static int ipw_wx_set_mode(struct net_device *dev,
5324 priv->ieee->iw_mode = wrqu->mode; 5391 priv->ieee->iw_mode = wrqu->mode;
5325 ipw_adapter_restart(priv); 5392 ipw_adapter_restart(priv);
5326 5393
5327 return err; 5394 return err;
5328} 5395}
5329 5396
5330static int ipw_wx_get_mode(struct net_device *dev, 5397static int ipw_wx_get_mode(struct net_device *dev,
5331 struct iw_request_info *info, 5398 struct iw_request_info *info,
5332 union iwreq_data *wrqu, char *extra) 5399 union iwreq_data *wrqu, char *extra)
5333{ 5400{
5334 struct ipw_priv *priv = ieee80211_priv(dev); 5401 struct ipw_priv *priv = ieee80211_priv(dev);
5335 5402
@@ -5339,7 +5406,6 @@ static int ipw_wx_get_mode(struct net_device *dev,
5339 return 0; 5406 return 0;
5340} 5407}
5341 5408
5342
5343#define DEFAULT_RTS_THRESHOLD 2304U 5409#define DEFAULT_RTS_THRESHOLD 2304U
5344#define MIN_RTS_THRESHOLD 1U 5410#define MIN_RTS_THRESHOLD 1U
5345#define MAX_RTS_THRESHOLD 2304U 5411#define MAX_RTS_THRESHOLD 2304U
@@ -5383,19 +5449,19 @@ static int ipw_wx_get_range(struct net_device *dev,
5383 /* TODO: Find real max RSSI and stick here */ 5449 /* TODO: Find real max RSSI and stick here */
5384 range->max_qual.level = 0; 5450 range->max_qual.level = 0;
5385 range->max_qual.noise = 0; 5451 range->max_qual.noise = 0;
5386 range->max_qual.updated = 7; /* Updated all three */ 5452 range->max_qual.updated = 7; /* Updated all three */
5387 5453
5388 range->avg_qual.qual = 70; 5454 range->avg_qual.qual = 70;
5389 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ 5455 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
5390 range->avg_qual.level = 0; /* FIXME to real average level */ 5456 range->avg_qual.level = 0; /* FIXME to real average level */
5391 range->avg_qual.noise = 0; 5457 range->avg_qual.noise = 0;
5392 range->avg_qual.updated = 7; /* Updated all three */ 5458 range->avg_qual.updated = 7; /* Updated all three */
5393 5459
5394 range->num_bitrates = min(priv->rates.num_rates, (u8)IW_MAX_BITRATES); 5460 range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES);
5395 5461
5396 for (i = 0; i < range->num_bitrates; i++) 5462 for (i = 0; i < range->num_bitrates; i++)
5397 range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) * 5463 range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) *
5398 500000; 5464 500000;
5399 5465
5400 range->max_rts = DEFAULT_RTS_THRESHOLD; 5466 range->max_rts = DEFAULT_RTS_THRESHOLD;
5401 range->min_frag = MIN_FRAG_THRESHOLD; 5467 range->min_frag = MIN_FRAG_THRESHOLD;
@@ -5410,7 +5476,7 @@ static int ipw_wx_get_range(struct net_device *dev,
5410 range->we_version_compiled = WIRELESS_EXT; 5476 range->we_version_compiled = WIRELESS_EXT;
5411 range->we_version_source = 16; 5477 range->we_version_source = 16;
5412 5478
5413 range->num_channels = FREQ_COUNT; 5479 range->num_channels = FREQ_COUNT;
5414 5480
5415 val = 0; 5481 val = 0;
5416 for (i = 0; i < FREQ_COUNT; i++) { 5482 for (i = 0; i < FREQ_COUNT; i++) {
@@ -5506,7 +5572,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
5506 union iwreq_data *wrqu, char *extra) 5572 union iwreq_data *wrqu, char *extra)
5507{ 5573{
5508 struct ipw_priv *priv = ieee80211_priv(dev); 5574 struct ipw_priv *priv = ieee80211_priv(dev);
5509 char *essid = ""; /* ANY */ 5575 char *essid = ""; /* ANY */
5510 int length = 0; 5576 int length = 0;
5511 5577
5512 if (wrqu->essid.flags && wrqu->essid.length) { 5578 if (wrqu->essid.flags && wrqu->essid.length) {
@@ -5567,11 +5633,11 @@ static int ipw_wx_get_essid(struct net_device *dev,
5567 escape_essid(priv->essid, priv->essid_len)); 5633 escape_essid(priv->essid, priv->essid_len));
5568 memcpy(extra, priv->essid, priv->essid_len); 5634 memcpy(extra, priv->essid, priv->essid_len);
5569 wrqu->essid.length = priv->essid_len; 5635 wrqu->essid.length = priv->essid_len;
5570 wrqu->essid.flags = 1; /* active */ 5636 wrqu->essid.flags = 1; /* active */
5571 } else { 5637 } else {
5572 IPW_DEBUG_WX("Getting essid: ANY\n"); 5638 IPW_DEBUG_WX("Getting essid: ANY\n");
5573 wrqu->essid.length = 0; 5639 wrqu->essid.length = 0;
5574 wrqu->essid.flags = 0; /* active */ 5640 wrqu->essid.flags = 0; /* active */
5575 } 5641 }
5576 5642
5577 return 0; 5643 return 0;
@@ -5587,15 +5653,14 @@ static int ipw_wx_set_nick(struct net_device *dev,
5587 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 5653 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
5588 return -E2BIG; 5654 return -E2BIG;
5589 5655
5590 wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick)); 5656 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
5591 memset(priv->nick, 0, sizeof(priv->nick)); 5657 memset(priv->nick, 0, sizeof(priv->nick));
5592 memcpy(priv->nick, extra, wrqu->data.length); 5658 memcpy(priv->nick, extra, wrqu->data.length);
5593 IPW_DEBUG_TRACE("<<\n"); 5659 IPW_DEBUG_TRACE("<<\n");
5594 return 0; 5660 return 0;
5595 5661
5596} 5662}
5597 5663
5598
5599static int ipw_wx_get_nick(struct net_device *dev, 5664static int ipw_wx_get_nick(struct net_device *dev,
5600 struct iw_request_info *info, 5665 struct iw_request_info *info,
5601 union iwreq_data *wrqu, char *extra) 5666 union iwreq_data *wrqu, char *extra)
@@ -5604,11 +5669,10 @@ static int ipw_wx_get_nick(struct net_device *dev,
5604 IPW_DEBUG_WX("Getting nick\n"); 5669 IPW_DEBUG_WX("Getting nick\n");
5605 wrqu->data.length = strlen(priv->nick) + 1; 5670 wrqu->data.length = strlen(priv->nick) + 1;
5606 memcpy(extra, priv->nick, wrqu->data.length); 5671 memcpy(extra, priv->nick, wrqu->data.length);
5607 wrqu->data.flags = 1; /* active */ 5672 wrqu->data.flags = 1; /* active */
5608 return 0; 5673 return 0;
5609} 5674}
5610 5675
5611
5612static int ipw_wx_set_rate(struct net_device *dev, 5676static int ipw_wx_set_rate(struct net_device *dev,
5613 struct iw_request_info *info, 5677 struct iw_request_info *info,
5614 union iwreq_data *wrqu, char *extra) 5678 union iwreq_data *wrqu, char *extra)
@@ -5621,14 +5685,13 @@ static int ipw_wx_get_rate(struct net_device *dev,
5621 struct iw_request_info *info, 5685 struct iw_request_info *info,
5622 union iwreq_data *wrqu, char *extra) 5686 union iwreq_data *wrqu, char *extra)
5623{ 5687{
5624 struct ipw_priv * priv = ieee80211_priv(dev); 5688 struct ipw_priv *priv = ieee80211_priv(dev);
5625 wrqu->bitrate.value = priv->last_rate; 5689 wrqu->bitrate.value = priv->last_rate;
5626 5690
5627 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 5691 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
5628 return 0; 5692 return 0;
5629} 5693}
5630 5694
5631
5632static int ipw_wx_set_rts(struct net_device *dev, 5695static int ipw_wx_set_rts(struct net_device *dev,
5633 struct iw_request_info *info, 5696 struct iw_request_info *info,
5634 union iwreq_data *wrqu, char *extra) 5697 union iwreq_data *wrqu, char *extra)
@@ -5657,14 +5720,12 @@ static int ipw_wx_get_rts(struct net_device *dev,
5657 struct ipw_priv *priv = ieee80211_priv(dev); 5720 struct ipw_priv *priv = ieee80211_priv(dev);
5658 wrqu->rts.value = priv->rts_threshold; 5721 wrqu->rts.value = priv->rts_threshold;
5659 wrqu->rts.fixed = 0; /* no auto select */ 5722 wrqu->rts.fixed = 0; /* no auto select */
5660 wrqu->rts.disabled = 5723 wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
5661 (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
5662 5724
5663 IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value); 5725 IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value);
5664 return 0; 5726 return 0;
5665} 5727}
5666 5728
5667
5668static int ipw_wx_set_txpow(struct net_device *dev, 5729static int ipw_wx_set_txpow(struct net_device *dev,
5669 struct iw_request_info *info, 5730 struct iw_request_info *info,
5670 union iwreq_data *wrqu, char *extra) 5731 union iwreq_data *wrqu, char *extra)
@@ -5679,8 +5740,7 @@ static int ipw_wx_set_txpow(struct net_device *dev,
5679 if (wrqu->power.flags != IW_TXPOW_DBM) 5740 if (wrqu->power.flags != IW_TXPOW_DBM)
5680 return -EINVAL; 5741 return -EINVAL;
5681 5742
5682 if ((wrqu->power.value > 20) || 5743 if ((wrqu->power.value > 20) || (wrqu->power.value < -12))
5683 (wrqu->power.value < -12))
5684 return -EINVAL; 5744 return -EINVAL;
5685 5745
5686 priv->tx_power = wrqu->power.value; 5746 priv->tx_power = wrqu->power.value;
@@ -5704,11 +5764,10 @@ static int ipw_wx_set_txpow(struct net_device *dev,
5704 5764
5705 return 0; 5765 return 0;
5706 5766
5707 error: 5767 error:
5708 return -EIO; 5768 return -EIO;
5709} 5769}
5710 5770
5711
5712static int ipw_wx_get_txpow(struct net_device *dev, 5771static int ipw_wx_get_txpow(struct net_device *dev,
5713 struct iw_request_info *info, 5772 struct iw_request_info *info,
5714 union iwreq_data *wrqu, char *extra) 5773 union iwreq_data *wrqu, char *extra)
@@ -5721,15 +5780,14 @@ static int ipw_wx_get_txpow(struct net_device *dev,
5721 wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; 5780 wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0;
5722 5781
5723 IPW_DEBUG_WX("GET TX Power -> %s %d \n", 5782 IPW_DEBUG_WX("GET TX Power -> %s %d \n",
5724 wrqu->power.disabled ? "ON" : "OFF", 5783 wrqu->power.disabled ? "ON" : "OFF", wrqu->power.value);
5725 wrqu->power.value);
5726 5784
5727 return 0; 5785 return 0;
5728} 5786}
5729 5787
5730static int ipw_wx_set_frag(struct net_device *dev, 5788static int ipw_wx_set_frag(struct net_device *dev,
5731 struct iw_request_info *info, 5789 struct iw_request_info *info,
5732 union iwreq_data *wrqu, char *extra) 5790 union iwreq_data *wrqu, char *extra)
5733{ 5791{
5734 struct ipw_priv *priv = ieee80211_priv(dev); 5792 struct ipw_priv *priv = ieee80211_priv(dev);
5735 5793
@@ -5749,14 +5807,13 @@ static int ipw_wx_set_frag(struct net_device *dev,
5749} 5807}
5750 5808
5751static int ipw_wx_get_frag(struct net_device *dev, 5809static int ipw_wx_get_frag(struct net_device *dev,
5752 struct iw_request_info *info, 5810 struct iw_request_info *info,
5753 union iwreq_data *wrqu, char *extra) 5811 union iwreq_data *wrqu, char *extra)
5754{ 5812{
5755 struct ipw_priv *priv = ieee80211_priv(dev); 5813 struct ipw_priv *priv = ieee80211_priv(dev);
5756 wrqu->frag.value = priv->ieee->fts; 5814 wrqu->frag.value = priv->ieee->fts;
5757 wrqu->frag.fixed = 0; /* no auto select */ 5815 wrqu->frag.fixed = 0; /* no auto select */
5758 wrqu->frag.disabled = 5816 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS);
5759 (wrqu->frag.value == DEFAULT_FTS);
5760 5817
5761 IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value); 5818 IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value);
5762 5819
@@ -5771,7 +5828,6 @@ static int ipw_wx_set_retry(struct net_device *dev,
5771 return -EOPNOTSUPP; 5828 return -EOPNOTSUPP;
5772} 5829}
5773 5830
5774
5775static int ipw_wx_get_retry(struct net_device *dev, 5831static int ipw_wx_get_retry(struct net_device *dev,
5776 struct iw_request_info *info, 5832 struct iw_request_info *info,
5777 union iwreq_data *wrqu, char *extra) 5833 union iwreq_data *wrqu, char *extra)
@@ -5780,7 +5836,6 @@ static int ipw_wx_get_retry(struct net_device *dev,
5780 return -EOPNOTSUPP; 5836 return -EOPNOTSUPP;
5781} 5837}
5782 5838
5783
5784static int ipw_wx_set_scan(struct net_device *dev, 5839static int ipw_wx_set_scan(struct net_device *dev,
5785 struct iw_request_info *info, 5840 struct iw_request_info *info,
5786 union iwreq_data *wrqu, char *extra) 5841 union iwreq_data *wrqu, char *extra)
@@ -5801,24 +5856,24 @@ static int ipw_wx_get_scan(struct net_device *dev,
5801} 5856}
5802 5857
5803static int ipw_wx_set_encode(struct net_device *dev, 5858static int ipw_wx_set_encode(struct net_device *dev,
5804 struct iw_request_info *info, 5859 struct iw_request_info *info,
5805 union iwreq_data *wrqu, char *key) 5860 union iwreq_data *wrqu, char *key)
5806{ 5861{
5807 struct ipw_priv *priv = ieee80211_priv(dev); 5862 struct ipw_priv *priv = ieee80211_priv(dev);
5808 return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); 5863 return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
5809} 5864}
5810 5865
5811static int ipw_wx_get_encode(struct net_device *dev, 5866static int ipw_wx_get_encode(struct net_device *dev,
5812 struct iw_request_info *info, 5867 struct iw_request_info *info,
5813 union iwreq_data *wrqu, char *key) 5868 union iwreq_data *wrqu, char *key)
5814{ 5869{
5815 struct ipw_priv *priv = ieee80211_priv(dev); 5870 struct ipw_priv *priv = ieee80211_priv(dev);
5816 return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key); 5871 return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key);
5817} 5872}
5818 5873
5819static int ipw_wx_set_power(struct net_device *dev, 5874static int ipw_wx_set_power(struct net_device *dev,
5820 struct iw_request_info *info, 5875 struct iw_request_info *info,
5821 union iwreq_data *wrqu, char *extra) 5876 union iwreq_data *wrqu, char *extra)
5822{ 5877{
5823 struct ipw_priv *priv = ieee80211_priv(dev); 5878 struct ipw_priv *priv = ieee80211_priv(dev);
5824 int err; 5879 int err;
@@ -5837,11 +5892,11 @@ static int ipw_wx_set_power(struct net_device *dev,
5837 } 5892 }
5838 5893
5839 switch (wrqu->power.flags & IW_POWER_MODE) { 5894 switch (wrqu->power.flags & IW_POWER_MODE) {
5840 case IW_POWER_ON: /* If not specified */ 5895 case IW_POWER_ON: /* If not specified */
5841 case IW_POWER_MODE: /* If set all mask */ 5896 case IW_POWER_MODE: /* If set all mask */
5842 case IW_POWER_ALL_R: /* If explicitely state all */ 5897 case IW_POWER_ALL_R: /* If explicitely state all */
5843 break; 5898 break;
5844 default: /* Otherwise we don't support it */ 5899 default: /* Otherwise we don't support it */
5845 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", 5900 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
5846 wrqu->power.flags); 5901 wrqu->power.flags);
5847 return -EOPNOTSUPP; 5902 return -EOPNOTSUPP;
@@ -5849,7 +5904,7 @@ static int ipw_wx_set_power(struct net_device *dev,
5849 5904
5850 /* If the user hasn't specified a power management mode yet, default 5905 /* If the user hasn't specified a power management mode yet, default
5851 * to BATTERY */ 5906 * to BATTERY */
5852 if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) 5907 if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC)
5853 priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY; 5908 priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY;
5854 else 5909 else
5855 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; 5910 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
@@ -5859,15 +5914,14 @@ static int ipw_wx_set_power(struct net_device *dev,
5859 return err; 5914 return err;
5860 } 5915 }
5861 5916
5862 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", 5917 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode);
5863 priv->power_mode);
5864 5918
5865 return 0; 5919 return 0;
5866} 5920}
5867 5921
5868static int ipw_wx_get_power(struct net_device *dev, 5922static int ipw_wx_get_power(struct net_device *dev,
5869 struct iw_request_info *info, 5923 struct iw_request_info *info,
5870 union iwreq_data *wrqu, char *extra) 5924 union iwreq_data *wrqu, char *extra)
5871{ 5925{
5872 struct ipw_priv *priv = ieee80211_priv(dev); 5926 struct ipw_priv *priv = ieee80211_priv(dev);
5873 5927
@@ -5883,8 +5937,8 @@ static int ipw_wx_get_power(struct net_device *dev,
5883} 5937}
5884 5938
5885static int ipw_wx_set_powermode(struct net_device *dev, 5939static int ipw_wx_set_powermode(struct net_device *dev,
5886 struct iw_request_info *info, 5940 struct iw_request_info *info,
5887 union iwreq_data *wrqu, char *extra) 5941 union iwreq_data *wrqu, char *extra)
5888{ 5942{
5889 struct ipw_priv *priv = ieee80211_priv(dev); 5943 struct ipw_priv *priv = ieee80211_priv(dev);
5890 int mode = *(int *)extra; 5944 int mode = *(int *)extra;
@@ -5911,8 +5965,8 @@ static int ipw_wx_set_powermode(struct net_device *dev,
5911 5965
5912#define MAX_WX_STRING 80 5966#define MAX_WX_STRING 80
5913static int ipw_wx_get_powermode(struct net_device *dev, 5967static int ipw_wx_get_powermode(struct net_device *dev,
5914 struct iw_request_info *info, 5968 struct iw_request_info *info,
5915 union iwreq_data *wrqu, char *extra) 5969 union iwreq_data *wrqu, char *extra)
5916{ 5970{
5917 struct ipw_priv *priv = ieee80211_priv(dev); 5971 struct ipw_priv *priv = ieee80211_priv(dev);
5918 int level = IPW_POWER_LEVEL(priv->power_mode); 5972 int level = IPW_POWER_LEVEL(priv->power_mode);
@@ -5935,7 +5989,7 @@ static int ipw_wx_get_powermode(struct net_device *dev,
5935 } 5989 }
5936 5990
5937 if (!(priv->power_mode & IPW_POWER_ENABLED)) 5991 if (!(priv->power_mode & IPW_POWER_ENABLED))
5938 p += snprintf(p, MAX_WX_STRING - (p - extra)," OFF"); 5992 p += snprintf(p, MAX_WX_STRING - (p - extra), " OFF");
5939 5993
5940 wrqu->data.length = p - extra + 1; 5994 wrqu->data.length = p - extra + 1;
5941 5995
@@ -5943,16 +5997,15 @@ static int ipw_wx_get_powermode(struct net_device *dev,
5943} 5997}
5944 5998
5945static int ipw_wx_set_wireless_mode(struct net_device *dev, 5999static int ipw_wx_set_wireless_mode(struct net_device *dev,
5946 struct iw_request_info *info, 6000 struct iw_request_info *info,
5947 union iwreq_data *wrqu, char *extra) 6001 union iwreq_data *wrqu, char *extra)
5948{ 6002{
5949 struct ipw_priv *priv = ieee80211_priv(dev); 6003 struct ipw_priv *priv = ieee80211_priv(dev);
5950 int mode = *(int *)extra; 6004 int mode = *(int *)extra;
5951 u8 band = 0, modulation = 0; 6005 u8 band = 0, modulation = 0;
5952 6006
5953 if (mode == 0 || mode & ~IEEE_MODE_MASK) { 6007 if (mode == 0 || mode & ~IEEE_MODE_MASK) {
5954 IPW_WARNING("Attempt to set invalid wireless mode: %d\n", 6008 IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode);
5955 mode);
5956 return -EINVAL; 6009 return -EINVAL;
5957 } 6010 }
5958 6011
@@ -5988,31 +6041,30 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
5988 priv->ieee->mode = mode; 6041 priv->ieee->mode = mode;
5989 priv->ieee->freq_band = band; 6042 priv->ieee->freq_band = band;
5990 priv->ieee->modulation = modulation; 6043 priv->ieee->modulation = modulation;
5991 init_supported_rates(priv, &priv->rates); 6044 init_supported_rates(priv, &priv->rates);
5992 6045
5993 /* If we are currently associated, or trying to associate 6046 /* If we are currently associated, or trying to associate
5994 * then see if this is a new configuration (causing us to 6047 * then see if this is a new configuration (causing us to
5995 * disassociate) */ 6048 * disassociate) */
5996 if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { 6049 if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
5997 /* The resulting association will trigger 6050 /* The resulting association will trigger
5998 * the new rates to be sent to the device */ 6051 * the new rates to be sent to the device */
5999 IPW_DEBUG_ASSOC("Disassociating due to mode change.\n"); 6052 IPW_DEBUG_ASSOC("Disassociating due to mode change.\n");
6000 ipw_disassociate(priv); 6053 ipw_disassociate(priv);
6001 } else 6054 } else
6002 ipw_send_supported_rates(priv, &priv->rates); 6055 ipw_send_supported_rates(priv, &priv->rates);
6003 6056
6004 IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n", 6057 IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n",
6005 mode & IEEE_A ? 'a' : '.', 6058 mode & IEEE_A ? 'a' : '.',
6006 mode & IEEE_B ? 'b' : '.', 6059 mode & IEEE_B ? 'b' : '.', mode & IEEE_G ? 'g' : '.');
6007 mode & IEEE_G ? 'g' : '.');
6008 return 0; 6060 return 0;
6009} 6061}
6010 6062
6011static int ipw_wx_get_wireless_mode(struct net_device *dev, 6063static int ipw_wx_get_wireless_mode(struct net_device *dev,
6012 struct iw_request_info *info, 6064 struct iw_request_info *info,
6013 union iwreq_data *wrqu, char *extra) 6065 union iwreq_data *wrqu, char *extra)
6014{ 6066{
6015 struct ipw_priv *priv = ieee80211_priv(dev); 6067 struct ipw_priv *priv = ieee80211_priv(dev);
6016 6068
6017 switch (priv->ieee->freq_band) { 6069 switch (priv->ieee->freq_band) {
6018 case IEEE80211_24GHZ_BAND: 6070 case IEEE80211_24GHZ_BAND:
@@ -6033,7 +6085,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
6033 strncpy(extra, "802.11a (1)", MAX_WX_STRING); 6085 strncpy(extra, "802.11a (1)", MAX_WX_STRING);
6034 break; 6086 break;
6035 6087
6036 default: /* Mixed Band */ 6088 default: /* Mixed Band */
6037 switch (priv->ieee->modulation) { 6089 switch (priv->ieee->modulation) {
6038 case IEEE80211_CCK_MODULATION: 6090 case IEEE80211_CCK_MODULATION:
6039 strncpy(extra, "802.11ab (3)", MAX_WX_STRING); 6091 strncpy(extra, "802.11ab (3)", MAX_WX_STRING);
@@ -6050,9 +6102,9 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
6050 6102
6051 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra); 6103 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra);
6052 6104
6053 wrqu->data.length = strlen(extra) + 1; 6105 wrqu->data.length = strlen(extra) + 1;
6054 6106
6055 return 0; 6107 return 0;
6056} 6108}
6057 6109
6058#ifdef CONFIG_IPW_PROMISC 6110#ifdef CONFIG_IPW_PROMISC
@@ -6081,7 +6133,6 @@ static int ipw_wx_set_promisc(struct net_device *dev,
6081 return 0; 6133 return 0;
6082} 6134}
6083 6135
6084
6085static int ipw_wx_reset(struct net_device *dev, 6136static int ipw_wx_reset(struct net_device *dev,
6086 struct iw_request_info *info, 6137 struct iw_request_info *info,
6087 union iwreq_data *wrqu, char *extra) 6138 union iwreq_data *wrqu, char *extra)
@@ -6091,40 +6142,39 @@ static int ipw_wx_reset(struct net_device *dev,
6091 ipw_adapter_restart(priv); 6142 ipw_adapter_restart(priv);
6092 return 0; 6143 return 0;
6093} 6144}
6094#endif // CONFIG_IPW_PROMISC 6145#endif // CONFIG_IPW_PROMISC
6095 6146
6096/* Rebase the WE IOCTLs to zero for the handler array */ 6147/* Rebase the WE IOCTLs to zero for the handler array */
6097#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] 6148#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
6098static iw_handler ipw_wx_handlers[] = 6149static iw_handler ipw_wx_handlers[] = {
6099{ 6150 IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name,
6100 IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, 6151 IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq,
6101 IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, 6152 IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq,
6102 IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, 6153 IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode,
6103 IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, 6154 IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode,
6104 IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, 6155 IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range,
6105 IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, 6156 IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap,
6106 IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, 6157 IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap,
6107 IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, 6158 IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan,
6108 IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, 6159 IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan,
6109 IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, 6160 IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid,
6110 IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, 6161 IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid,
6111 IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, 6162 IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick,
6112 IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, 6163 IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick,
6113 IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, 6164 IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate,
6114 IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, 6165 IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate,
6115 IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, 6166 IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts,
6116 IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, 6167 IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts,
6117 IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, 6168 IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag,
6118 IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, 6169 IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag,
6119 IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, 6170 IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow,
6120 IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, 6171 IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow,
6121 IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, 6172 IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry,
6122 IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, 6173 IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry,
6123 IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, 6174 IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode,
6124 IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, 6175 IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode,
6125 IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, 6176 IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power,
6126 IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, 6177 IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power,
6127 IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power,
6128}; 6178};
6129 6179
6130#define IPW_PRIV_SET_POWER SIOCIWFIRSTPRIV 6180#define IPW_PRIV_SET_POWER SIOCIWFIRSTPRIV
@@ -6134,38 +6184,31 @@ static iw_handler ipw_wx_handlers[] =
6134#define IPW_PRIV_SET_PROMISC SIOCIWFIRSTPRIV+4 6184#define IPW_PRIV_SET_PROMISC SIOCIWFIRSTPRIV+4
6135#define IPW_PRIV_RESET SIOCIWFIRSTPRIV+5 6185#define IPW_PRIV_RESET SIOCIWFIRSTPRIV+5
6136 6186
6137
6138static struct iw_priv_args ipw_priv_args[] = { 6187static struct iw_priv_args ipw_priv_args[] = {
6139 { 6188 {
6140 .cmd = IPW_PRIV_SET_POWER, 6189 .cmd = IPW_PRIV_SET_POWER,
6141 .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 6190 .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6142 .name = "set_power" 6191 .name = "set_power"},
6143 },
6144 { 6192 {
6145 .cmd = IPW_PRIV_GET_POWER, 6193 .cmd = IPW_PRIV_GET_POWER,
6146 .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, 6194 .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
6147 .name = "get_power" 6195 .name = "get_power"},
6148 },
6149 { 6196 {
6150 .cmd = IPW_PRIV_SET_MODE, 6197 .cmd = IPW_PRIV_SET_MODE,
6151 .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 6198 .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
6152 .name = "set_mode" 6199 .name = "set_mode"},
6153 },
6154 { 6200 {
6155 .cmd = IPW_PRIV_GET_MODE, 6201 .cmd = IPW_PRIV_GET_MODE,
6156 .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, 6202 .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
6157 .name = "get_mode" 6203 .name = "get_mode"},
6158 },
6159#ifdef CONFIG_IPW_PROMISC 6204#ifdef CONFIG_IPW_PROMISC
6160 { 6205 {
6161 IPW_PRIV_SET_PROMISC, 6206 IPW_PRIV_SET_PROMISC,
6162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" 6207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"},
6163 },
6164 { 6208 {
6165 IPW_PRIV_RESET, 6209 IPW_PRIV_RESET,
6166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" 6210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"},
6167 }, 6211#endif /* CONFIG_IPW_PROMISC */
6168#endif /* CONFIG_IPW_PROMISC */
6169}; 6212};
6170 6213
6171static iw_handler ipw_priv_handler[] = { 6214static iw_handler ipw_priv_handler[] = {
@@ -6179,25 +6222,21 @@ static iw_handler ipw_priv_handler[] = {
6179#endif 6222#endif
6180}; 6223};
6181 6224
6182static struct iw_handler_def ipw_wx_handler_def = 6225static struct iw_handler_def ipw_wx_handler_def = {
6183{ 6226 .standard = ipw_wx_handlers,
6184 .standard = ipw_wx_handlers, 6227 .num_standard = ARRAY_SIZE(ipw_wx_handlers),
6185 .num_standard = ARRAY_SIZE(ipw_wx_handlers), 6228 .num_private = ARRAY_SIZE(ipw_priv_handler),
6186 .num_private = ARRAY_SIZE(ipw_priv_handler), 6229 .num_private_args = ARRAY_SIZE(ipw_priv_args),
6187 .num_private_args = ARRAY_SIZE(ipw_priv_args), 6230 .private = ipw_priv_handler,
6188 .private = ipw_priv_handler, 6231 .private_args = ipw_priv_args,
6189 .private_args = ipw_priv_args,
6190}; 6232};
6191 6233
6192
6193
6194
6195/* 6234/*
6196 * Get wireless statistics. 6235 * Get wireless statistics.
6197 * Called by /proc/net/wireless 6236 * Called by /proc/net/wireless
6198 * Also called by SIOCGIWSTATS 6237 * Also called by SIOCGIWSTATS
6199 */ 6238 */
6200static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) 6239static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev)
6201{ 6240{
6202 struct ipw_priv *priv = ieee80211_priv(dev); 6241 struct ipw_priv *priv = ieee80211_priv(dev);
6203 struct iw_statistics *wstats; 6242 struct iw_statistics *wstats;
@@ -6217,7 +6256,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev)
6217 wstats->qual.noise = 0; 6256 wstats->qual.noise = 0;
6218 wstats->qual.updated = 7; 6257 wstats->qual.updated = 7;
6219 wstats->qual.updated |= IW_QUAL_NOISE_INVALID | 6258 wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
6220 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; 6259 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
6221 return wstats; 6260 return wstats;
6222 } 6261 }
6223 6262
@@ -6225,7 +6264,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev)
6225 wstats->qual.level = average_value(&priv->average_rssi); 6264 wstats->qual.level = average_value(&priv->average_rssi);
6226 wstats->qual.noise = average_value(&priv->average_noise); 6265 wstats->qual.noise = average_value(&priv->average_noise);
6227 wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | 6266 wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
6228 IW_QUAL_NOISE_UPDATED; 6267 IW_QUAL_NOISE_UPDATED;
6229 6268
6230 wstats->miss.beacon = average_value(&priv->average_missed_beacons); 6269 wstats->miss.beacon = average_value(&priv->average_missed_beacons);
6231 wstats->discard.retries = priv->last_tx_failures; 6270 wstats->discard.retries = priv->last_tx_failures;
@@ -6238,13 +6277,12 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev)
6238 return wstats; 6277 return wstats;
6239} 6278}
6240 6279
6241
6242/* net device stuff */ 6280/* net device stuff */
6243 6281
6244static inline void init_sys_config(struct ipw_sys_config *sys_config) 6282static inline void init_sys_config(struct ipw_sys_config *sys_config)
6245{ 6283{
6246 memset(sys_config, 0, sizeof(struct ipw_sys_config)); 6284 memset(sys_config, 0, sizeof(struct ipw_sys_config));
6247 sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ 6285 sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */
6248 sys_config->answer_broadcast_ssid_probe = 0; 6286 sys_config->answer_broadcast_ssid_probe = 0;
6249 sys_config->accept_all_data_frames = 0; 6287 sys_config->accept_all_data_frames = 0;
6250 sys_config->accept_non_directed_frames = 1; 6288 sys_config->accept_non_directed_frames = 1;
@@ -6253,7 +6291,7 @@ static inline void init_sys_config(struct ipw_sys_config *sys_config)
6253 sys_config->exclude_multicast_unencrypted = 0; 6291 sys_config->exclude_multicast_unencrypted = 0;
6254 sys_config->disable_multicast_decryption = 1; 6292 sys_config->disable_multicast_decryption = 1;
6255 sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH; 6293 sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH;
6256 sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ 6294 sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */
6257 sys_config->dot11g_auto_detection = 0; 6295 sys_config->dot11g_auto_detection = 0;
6258 sys_config->enable_cts_to_self = 0; 6296 sys_config->enable_cts_to_self = 0;
6259 sys_config->bt_coexist_collision_thr = 0; 6297 sys_config->bt_coexist_collision_thr = 0;
@@ -6288,7 +6326,7 @@ we need to heavily modify the ieee80211_skb_to_txb.
6288static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) 6326static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6289{ 6327{
6290 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) 6328 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)
6291 txb->fragments[0]->data; 6329 txb->fragments[0]->data;
6292 int i = 0; 6330 int i = 0;
6293 struct tfd_frame *tfd; 6331 struct tfd_frame *tfd;
6294 struct clx2_tx_queue *txq = &priv->txq[0]; 6332 struct clx2_tx_queue *txq = &priv->txq[0];
@@ -6300,7 +6338,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6300 case IW_MODE_ADHOC: 6338 case IW_MODE_ADHOC:
6301 hdr_len = IEEE80211_3ADDR_LEN; 6339 hdr_len = IEEE80211_3ADDR_LEN;
6302 unicast = !is_broadcast_ether_addr(hdr->addr1) && 6340 unicast = !is_broadcast_ether_addr(hdr->addr1) &&
6303 !is_multicast_ether_addr(hdr->addr1); 6341 !is_multicast_ether_addr(hdr->addr1);
6304 id = ipw_find_station(priv, hdr->addr1); 6342 id = ipw_find_station(priv, hdr->addr1);
6305 if (id == IPW_INVALID_STATION) { 6343 if (id == IPW_INVALID_STATION) {
6306 id = ipw_add_station(priv, hdr->addr1); 6344 id = ipw_add_station(priv, hdr->addr1);
@@ -6316,7 +6354,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6316 case IW_MODE_INFRA: 6354 case IW_MODE_INFRA:
6317 default: 6355 default:
6318 unicast = !is_broadcast_ether_addr(hdr->addr3) && 6356 unicast = !is_broadcast_ether_addr(hdr->addr3) &&
6319 !is_multicast_ether_addr(hdr->addr3); 6357 !is_multicast_ether_addr(hdr->addr3);
6320 hdr_len = IEEE80211_3ADDR_LEN; 6358 hdr_len = IEEE80211_3ADDR_LEN;
6321 id = 0; 6359 id = 0;
6322 break; 6360 break;
@@ -6349,7 +6387,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6349 memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len); 6387 memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len);
6350 6388
6351 /* payload */ 6389 /* payload */
6352 tfd->u.data.num_chunks = min((u8)(NUM_TFD_CHUNKS - 2), txb->nr_frags); 6390 tfd->u.data.num_chunks = min((u8) (NUM_TFD_CHUNKS - 2), txb->nr_frags);
6353 for (i = 0; i < tfd->u.data.num_chunks; i++) { 6391 for (i = 0; i < tfd->u.data.num_chunks; i++) {
6354 IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n", 6392 IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n",
6355 i, tfd->u.data.num_chunks, 6393 i, tfd->u.data.num_chunks,
@@ -6357,9 +6395,11 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6357 printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len, 6395 printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len,
6358 txb->fragments[i]->len - hdr_len); 6396 txb->fragments[i]->len - hdr_len);
6359 6397
6360 tfd->u.data.chunk_ptr[i] = pci_map_single( 6398 tfd->u.data.chunk_ptr[i] =
6361 priv->pci_dev, txb->fragments[i]->data + hdr_len, 6399 pci_map_single(priv->pci_dev,
6362 txb->fragments[i]->len - hdr_len, PCI_DMA_TODEVICE); 6400 txb->fragments[i]->data + hdr_len,
6401 txb->fragments[i]->len - hdr_len,
6402 PCI_DMA_TODEVICE);
6363 tfd->u.data.chunk_len[i] = txb->fragments[i]->len - hdr_len; 6403 tfd->u.data.chunk_len[i] = txb->fragments[i]->len - hdr_len;
6364 } 6404 }
6365 6405
@@ -6379,16 +6419,16 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6379 for (j = i; j < txb->nr_frags; j++) { 6419 for (j = i; j < txb->nr_frags; j++) {
6380 int size = txb->fragments[j]->len - hdr_len; 6420 int size = txb->fragments[j]->len - hdr_len;
6381 printk(KERN_INFO "Adding frag %d %d...\n", 6421 printk(KERN_INFO "Adding frag %d %d...\n",
6382 j, size); 6422 j, size);
6383 memcpy(skb_put(skb, size), 6423 memcpy(skb_put(skb, size),
6384 txb->fragments[j]->data + hdr_len, 6424 txb->fragments[j]->data + hdr_len, size);
6385 size);
6386 } 6425 }
6387 dev_kfree_skb_any(txb->fragments[i]); 6426 dev_kfree_skb_any(txb->fragments[i]);
6388 txb->fragments[i] = skb; 6427 txb->fragments[i] = skb;
6389 tfd->u.data.chunk_ptr[i] = pci_map_single( 6428 tfd->u.data.chunk_ptr[i] =
6390 priv->pci_dev, skb->data, 6429 pci_map_single(priv->pci_dev, skb->data,
6391 tfd->u.data.chunk_len[i], PCI_DMA_TODEVICE); 6430 tfd->u.data.chunk_len[i],
6431 PCI_DMA_TODEVICE);
6392 tfd->u.data.num_chunks++; 6432 tfd->u.data.num_chunks++;
6393 } 6433 }
6394 } 6434 }
@@ -6402,7 +6442,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6402 6442
6403 return; 6443 return;
6404 6444
6405 drop: 6445 drop:
6406 IPW_DEBUG_DROP("Silently dropping Tx packet.\n"); 6446 IPW_DEBUG_DROP("Silently dropping Tx packet.\n");
6407 ieee80211_txb_free(txb); 6447 ieee80211_txb_free(txb);
6408} 6448}
@@ -6429,7 +6469,7 @@ static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
6429 spin_unlock_irqrestore(&priv->lock, flags); 6469 spin_unlock_irqrestore(&priv->lock, flags);
6430 return 0; 6470 return 0;
6431 6471
6432 fail_unlock: 6472 fail_unlock:
6433 spin_unlock_irqrestore(&priv->lock, flags); 6473 spin_unlock_irqrestore(&priv->lock, flags);
6434 return 1; 6474 return 1;
6435} 6475}
@@ -6478,7 +6518,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
6478 len = sizeof(date); 6518 len = sizeof(date);
6479 ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len); 6519 ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len);
6480 6520
6481 snprintf(info->fw_version, sizeof(info->fw_version),"%s (%s)", 6521 snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
6482 vers, date); 6522 vers, date);
6483 strcpy(info->bus_info, pci_name(p->pci_dev)); 6523 strcpy(info->bus_info, pci_name(p->pci_dev));
6484 info->eedump_len = CX2_EEPROM_IMAGE_SIZE; 6524 info->eedump_len = CX2_EEPROM_IMAGE_SIZE;
@@ -6496,19 +6536,19 @@ static int ipw_ethtool_get_eeprom_len(struct net_device *dev)
6496} 6536}
6497 6537
6498static int ipw_ethtool_get_eeprom(struct net_device *dev, 6538static int ipw_ethtool_get_eeprom(struct net_device *dev,
6499 struct ethtool_eeprom *eeprom, u8 *bytes) 6539 struct ethtool_eeprom *eeprom, u8 * bytes)
6500{ 6540{
6501 struct ipw_priv *p = ieee80211_priv(dev); 6541 struct ipw_priv *p = ieee80211_priv(dev);
6502 6542
6503 if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) 6543 if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
6504 return -EINVAL; 6544 return -EINVAL;
6505 6545
6506 memcpy(bytes, &((u8 *)p->eeprom)[eeprom->offset], eeprom->len); 6546 memcpy(bytes, &((u8 *) p->eeprom)[eeprom->offset], eeprom->len);
6507 return 0; 6547 return 0;
6508} 6548}
6509 6549
6510static int ipw_ethtool_set_eeprom(struct net_device *dev, 6550static int ipw_ethtool_set_eeprom(struct net_device *dev,
6511 struct ethtool_eeprom *eeprom, u8 *bytes) 6551 struct ethtool_eeprom *eeprom, u8 * bytes)
6512{ 6552{
6513 struct ipw_priv *p = ieee80211_priv(dev); 6553 struct ipw_priv *p = ieee80211_priv(dev);
6514 int i; 6554 int i;
@@ -6516,21 +6556,20 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev,
6516 if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) 6556 if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
6517 return -EINVAL; 6557 return -EINVAL;
6518 6558
6519 memcpy(&((u8 *)p->eeprom)[eeprom->offset], bytes, eeprom->len); 6559 memcpy(&((u8 *) p->eeprom)[eeprom->offset], bytes, eeprom->len);
6520 for (i = IPW_EEPROM_DATA; 6560 for (i = IPW_EEPROM_DATA;
6521 i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; 6561 i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; i++)
6522 i++)
6523 ipw_write8(p, i, p->eeprom[i]); 6562 ipw_write8(p, i, p->eeprom[i]);
6524 6563
6525 return 0; 6564 return 0;
6526} 6565}
6527 6566
6528static struct ethtool_ops ipw_ethtool_ops = { 6567static struct ethtool_ops ipw_ethtool_ops = {
6529 .get_link = ipw_ethtool_get_link, 6568 .get_link = ipw_ethtool_get_link,
6530 .get_drvinfo = ipw_ethtool_get_drvinfo, 6569 .get_drvinfo = ipw_ethtool_get_drvinfo,
6531 .get_eeprom_len = ipw_ethtool_get_eeprom_len, 6570 .get_eeprom_len = ipw_ethtool_get_eeprom_len,
6532 .get_eeprom = ipw_ethtool_get_eeprom, 6571 .get_eeprom = ipw_ethtool_get_eeprom,
6533 .set_eeprom = ipw_ethtool_set_eeprom, 6572 .set_eeprom = ipw_ethtool_set_eeprom,
6534}; 6573};
6535 6574
6536static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs) 6575static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
@@ -6574,10 +6613,10 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
6574 6613
6575 tasklet_schedule(&priv->irq_tasklet); 6614 tasklet_schedule(&priv->irq_tasklet);
6576 6615
6577 spin_unlock(&priv->lock); 6616 spin_unlock(&priv->lock);
6578 6617
6579 return IRQ_HANDLED; 6618 return IRQ_HANDLED;
6580 none: 6619 none:
6581 spin_unlock(&priv->lock); 6620 spin_unlock(&priv->lock);
6582 return IRQ_NONE; 6621 return IRQ_NONE;
6583} 6622}
@@ -6609,7 +6648,7 @@ static void ipw_rf_kill(void *adapter)
6609 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still " 6648 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still "
6610 "enabled\n"); 6649 "enabled\n");
6611 6650
6612 exit_unlock: 6651 exit_unlock:
6613 spin_unlock_irqrestore(&priv->lock, flags); 6652 spin_unlock_irqrestore(&priv->lock, flags);
6614} 6653}
6615 6654
@@ -6642,7 +6681,6 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
6642 return ret; 6681 return ret;
6643} 6682}
6644 6683
6645
6646static void shim__set_security(struct net_device *dev, 6684static void shim__set_security(struct net_device *dev,
6647 struct ieee80211_security *sec) 6685 struct ieee80211_security *sec)
6648{ 6686{
@@ -6683,8 +6721,7 @@ static void shim__set_security(struct net_device *dev,
6683 priv->status |= STATUS_SECURITY_UPDATED; 6721 priv->status |= STATUS_SECURITY_UPDATED;
6684 } 6722 }
6685 6723
6686 if (sec->flags & SEC_ENABLED && 6724 if (sec->flags & SEC_ENABLED && priv->sec.enabled != sec->enabled) {
6687 priv->sec.enabled != sec->enabled) {
6688 priv->sec.flags |= SEC_ENABLED; 6725 priv->sec.flags |= SEC_ENABLED;
6689 priv->sec.enabled = sec->enabled; 6726 priv->sec.enabled = sec->enabled;
6690 priv->status |= STATUS_SECURITY_UPDATED; 6727 priv->status |= STATUS_SECURITY_UPDATED;
@@ -6694,8 +6731,7 @@ static void shim__set_security(struct net_device *dev,
6694 priv->capability &= ~CAP_PRIVACY_ON; 6731 priv->capability &= ~CAP_PRIVACY_ON;
6695 } 6732 }
6696 6733
6697 if (sec->flags & SEC_LEVEL && 6734 if (sec->flags & SEC_LEVEL && priv->sec.level != sec->level) {
6698 priv->sec.level != sec->level) {
6699 priv->sec.level = sec->level; 6735 priv->sec.level = sec->level;
6700 priv->sec.flags |= SEC_LEVEL; 6736 priv->sec.flags |= SEC_LEVEL;
6701 priv->status |= STATUS_SECURITY_UPDATED; 6737 priv->status |= STATUS_SECURITY_UPDATED;
@@ -6709,7 +6745,7 @@ static void shim__set_security(struct net_device *dev,
6709 (((priv->assoc_request.capability & 6745 (((priv->assoc_request.capability &
6710 WLAN_CAPABILITY_PRIVACY) && !sec->enabled) || 6746 WLAN_CAPABILITY_PRIVACY) && !sec->enabled) ||
6711 (!(priv->assoc_request.capability & 6747 (!(priv->assoc_request.capability &
6712 WLAN_CAPABILITY_PRIVACY) && sec->enabled))) { 6748 WLAN_CAPABILITY_PRIVACY) && sec->enabled))) {
6713 IPW_DEBUG_ASSOC("Disassociating due to capability " 6749 IPW_DEBUG_ASSOC("Disassociating due to capability "
6714 "change.\n"); 6750 "change.\n");
6715 ipw_disassociate(priv); 6751 ipw_disassociate(priv);
@@ -6723,7 +6759,7 @@ static int init_supported_rates(struct ipw_priv *priv,
6723 /* TODO: Mask out rates based on priv->rates_mask */ 6759 /* TODO: Mask out rates based on priv->rates_mask */
6724 6760
6725 memset(rates, 0, sizeof(*rates)); 6761 memset(rates, 0, sizeof(*rates));
6726 /* configure supported rates */ 6762 /* configure supported rates */
6727 switch (priv->ieee->freq_band) { 6763 switch (priv->ieee->freq_band) {
6728 case IEEE80211_52GHZ_BAND: 6764 case IEEE80211_52GHZ_BAND:
6729 rates->ieee_mode = IPW_A_MODE; 6765 rates->ieee_mode = IPW_A_MODE;
@@ -6732,7 +6768,7 @@ static int init_supported_rates(struct ipw_priv *priv,
6732 IEEE80211_OFDM_DEFAULT_RATES_MASK); 6768 IEEE80211_OFDM_DEFAULT_RATES_MASK);
6733 break; 6769 break;
6734 6770
6735 default: /* Mixed or 2.4Ghz */ 6771 default: /* Mixed or 2.4Ghz */
6736 rates->ieee_mode = IPW_G_MODE; 6772 rates->ieee_mode = IPW_G_MODE;
6737 rates->purpose = IPW_RATE_CAPABILITIES; 6773 rates->purpose = IPW_RATE_CAPABILITIES;
6738 ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION, 6774 ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION,
@@ -6783,8 +6819,8 @@ static int ipw_config(struct ipw_priv *priv)
6783 if (ipw_send_system_config(priv, &priv->sys_config)) 6819 if (ipw_send_system_config(priv, &priv->sys_config))
6784 goto error; 6820 goto error;
6785 6821
6786 init_supported_rates(priv, &priv->rates); 6822 init_supported_rates(priv, &priv->rates);
6787 if (ipw_send_supported_rates(priv, &priv->rates)) 6823 if (ipw_send_supported_rates(priv, &priv->rates))
6788 goto error; 6824 goto error;
6789 6825
6790 /* Set request-to-send threshold */ 6826 /* Set request-to-send threshold */
@@ -6806,7 +6842,7 @@ static int ipw_config(struct ipw_priv *priv)
6806 6842
6807 return 0; 6843 return 0;
6808 6844
6809 error: 6845 error:
6810 return -EIO; 6846 return -EIO;
6811} 6847}
6812 6848
@@ -6818,13 +6854,12 @@ static int ipw_up(struct ipw_priv *priv)
6818 if (priv->status & STATUS_EXIT_PENDING) 6854 if (priv->status & STATUS_EXIT_PENDING)
6819 return -EIO; 6855 return -EIO;
6820 6856
6821 for (i = 0; i < MAX_HW_RESTARTS; i++ ) { 6857 for (i = 0; i < MAX_HW_RESTARTS; i++) {
6822 /* Load the microcode, firmware, and eeprom. 6858 /* Load the microcode, firmware, and eeprom.
6823 * Also start the clocks. */ 6859 * Also start the clocks. */
6824 rc = ipw_load(priv); 6860 rc = ipw_load(priv);
6825 if (rc) { 6861 if (rc) {
6826 IPW_ERROR("Unable to load firmware: 0x%08X\n", 6862 IPW_ERROR("Unable to load firmware: 0x%08X\n", rc);
6827 rc);
6828 return rc; 6863 return rc;
6829 } 6864 }
6830 6865
@@ -6857,8 +6892,7 @@ static int ipw_up(struct ipw_priv *priv)
6857 6892
6858 /* tried to restart and config the device for as long as our 6893 /* tried to restart and config the device for as long as our
6859 * patience could withstand */ 6894 * patience could withstand */
6860 IPW_ERROR("Unable to initialize device after %d attempts.\n", 6895 IPW_ERROR("Unable to initialize device after %d attempts.\n", i);
6861 i);
6862 return -EIO; 6896 return -EIO;
6863} 6897}
6864 6898
@@ -6923,10 +6957,10 @@ static struct pci_device_id card_ids[] = {
6923 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, 6957 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0},
6924 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, 6958 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0},
6925 {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 6959 {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
6926 {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ 6960 {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */
6927 {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */ 6961 {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */
6928 {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ 6962 {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */
6929 {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ 6963 {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */
6930 6964
6931 /* required last entry */ 6965 /* required last entry */
6932 {0,} 6966 {0,}
@@ -6954,11 +6988,10 @@ static struct attribute *ipw_sysfs_entries[] = {
6954 6988
6955static struct attribute_group ipw_attribute_group = { 6989static struct attribute_group ipw_attribute_group = {
6956 .name = NULL, /* put in device directory */ 6990 .name = NULL, /* put in device directory */
6957 .attrs = ipw_sysfs_entries, 6991 .attrs = ipw_sysfs_entries,
6958}; 6992};
6959 6993
6960static int ipw_pci_probe(struct pci_dev *pdev, 6994static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
6961 const struct pci_device_id *ent)
6962{ 6995{
6963 int err = 0; 6996 int err = 0;
6964 struct net_device *net_dev; 6997 struct net_device *net_dev;
@@ -7051,7 +7084,7 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7051 priv->config |= CFG_STATIC_CHANNEL; 7084 priv->config |= CFG_STATIC_CHANNEL;
7052 priv->channel = channel; 7085 priv->channel = channel;
7053 IPW_DEBUG_INFO("Bind to static channel %d\n", channel); 7086 IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
7054 IPW_DEBUG_INFO("Bind to static channel %d\n", channel); 7087 IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
7055 /* TODO: Validate that provided channel is in range */ 7088 /* TODO: Validate that provided channel is in range */
7056 } 7089 }
7057 7090
@@ -7078,9 +7111,9 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7078 priv->ieee->abg_ture = 1; 7111 priv->ieee->abg_ture = 1;
7079 band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND; 7112 band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND;
7080 modulation = IEEE80211_OFDM_MODULATION | 7113 modulation = IEEE80211_OFDM_MODULATION |
7081 IEEE80211_CCK_MODULATION; 7114 IEEE80211_CCK_MODULATION;
7082 priv->adapter = IPW_2915ABG; 7115 priv->adapter = IPW_2915ABG;
7083 priv->ieee->mode = IEEE_A|IEEE_G|IEEE_B; 7116 priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B;
7084 } else { 7117 } else {
7085 if (priv->pci_dev->device == 0x4221) 7118 if (priv->pci_dev->device == 0x4221)
7086 printk(KERN_INFO DRV_NAME 7119 printk(KERN_INFO DRV_NAME
@@ -7094,9 +7127,9 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7094 priv->ieee->abg_ture = 0; 7127 priv->ieee->abg_ture = 0;
7095 band = IEEE80211_24GHZ_BAND; 7128 band = IEEE80211_24GHZ_BAND;
7096 modulation = IEEE80211_OFDM_MODULATION | 7129 modulation = IEEE80211_OFDM_MODULATION |
7097 IEEE80211_CCK_MODULATION; 7130 IEEE80211_CCK_MODULATION;
7098 priv->adapter = IPW_2200BG; 7131 priv->adapter = IPW_2200BG;
7099 priv->ieee->mode = IEEE_G|IEEE_B; 7132 priv->ieee->mode = IEEE_G | IEEE_B;
7100 } 7133 }
7101 7134
7102 priv->ieee->freq_band = band; 7135 priv->ieee->freq_band = band;
@@ -7110,11 +7143,10 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7110 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; 7143 priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
7111 7144
7112 /* If power management is turned on, default to AC mode */ 7145 /* If power management is turned on, default to AC mode */
7113 priv->power_mode = IPW_POWER_AC; 7146 priv->power_mode = IPW_POWER_AC;
7114 priv->tx_power = IPW_DEFAULT_TX_POWER; 7147 priv->tx_power = IPW_DEFAULT_TX_POWER;
7115 7148
7116 err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, 7149 err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, priv);
7117 priv);
7118 if (err) { 7150 if (err) {
7119 IPW_ERROR("Error allocating IRQ %d\n", pdev->irq); 7151 IPW_ERROR("Error allocating IRQ %d\n", pdev->irq);
7120 goto out_destroy_workqueue; 7152 goto out_destroy_workqueue;
@@ -7136,7 +7168,7 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7136 net_dev->wireless_handlers = &ipw_wx_handler_def; 7168 net_dev->wireless_handlers = &ipw_wx_handler_def;
7137 net_dev->ethtool_ops = &ipw_ethtool_ops; 7169 net_dev->ethtool_ops = &ipw_ethtool_ops;
7138 net_dev->irq = pdev->irq; 7170 net_dev->irq = pdev->irq;
7139 net_dev->base_addr = (unsigned long )priv->hw_base; 7171 net_dev->base_addr = (unsigned long)priv->hw_base;
7140 net_dev->mem_start = pci_resource_start(pdev, 0); 7172 net_dev->mem_start = pci_resource_start(pdev, 0);
7141 net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1; 7173 net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1;
7142 7174
@@ -7154,23 +7186,23 @@ static int ipw_pci_probe(struct pci_dev *pdev,
7154 7186
7155 return 0; 7187 return 0;
7156 7188
7157 out_remove_group: 7189 out_remove_group:
7158 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); 7190 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group);
7159 out_release_irq: 7191 out_release_irq:
7160 free_irq(pdev->irq, priv); 7192 free_irq(pdev->irq, priv);
7161 out_destroy_workqueue: 7193 out_destroy_workqueue:
7162 destroy_workqueue(priv->workqueue); 7194 destroy_workqueue(priv->workqueue);
7163 priv->workqueue = NULL; 7195 priv->workqueue = NULL;
7164 out_iounmap: 7196 out_iounmap:
7165 iounmap(priv->hw_base); 7197 iounmap(priv->hw_base);
7166 out_pci_release_regions: 7198 out_pci_release_regions:
7167 pci_release_regions(pdev); 7199 pci_release_regions(pdev);
7168 out_pci_disable_device: 7200 out_pci_disable_device:
7169 pci_disable_device(pdev); 7201 pci_disable_device(pdev);
7170 pci_set_drvdata(pdev, NULL); 7202 pci_set_drvdata(pdev, NULL);
7171 out_free_ieee80211: 7203 out_free_ieee80211:
7172 free_ieee80211(priv->net_dev); 7204 free_ieee80211(priv->net_dev);
7173 out: 7205 out:
7174 return err; 7206 return err;
7175} 7207}
7176 7208
@@ -7223,16 +7255,15 @@ static void ipw_pci_remove(struct pci_dev *pdev)
7223#endif 7255#endif
7224} 7256}
7225 7257
7226
7227#ifdef CONFIG_PM 7258#ifdef CONFIG_PM
7228static int ipw_pci_suspend(struct pci_dev *pdev, u32 state) 7259static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state)
7229{ 7260{
7230 struct ipw_priv *priv = pci_get_drvdata(pdev); 7261 struct ipw_priv *priv = pci_get_drvdata(pdev);
7231 struct net_device *dev = priv->net_dev; 7262 struct net_device *dev = priv->net_dev;
7232 7263
7233 printk(KERN_INFO "%s: Going into suspend...\n", dev->name); 7264 printk(KERN_INFO "%s: Going into suspend...\n", dev->name);
7234 7265
7235 /* Take down the device; powers it off, etc. */ 7266 /* Take down the device; powers it off, etc. */
7236 ipw_down(priv); 7267 ipw_down(priv);
7237 7268
7238 /* Remove the PRESENT state of the device */ 7269 /* Remove the PRESENT state of the device */
@@ -7240,7 +7271,7 @@ static int ipw_pci_suspend(struct pci_dev *pdev, u32 state)
7240 7271
7241 pci_save_state(pdev); 7272 pci_save_state(pdev);
7242 pci_disable_device(pdev); 7273 pci_disable_device(pdev);
7243 pci_set_power_state(pdev, state); 7274 pci_set_power_state(pdev, pci_choose_state(pdev, state));
7244 7275
7245 return 0; 7276 return 0;
7246} 7277}
@@ -7306,8 +7337,7 @@ static int __init ipw_init(void)
7306 return ret; 7337 return ret;
7307 } 7338 }
7308 7339
7309 ret = driver_create_file(&ipw_driver.driver, 7340 ret = driver_create_file(&ipw_driver.driver, &driver_attr_debug_level);
7310 &driver_attr_debug_level);
7311 if (ret) { 7341 if (ret) {
7312 IPW_ERROR("Unable to create driver sysfs file\n"); 7342 IPW_ERROR("Unable to create driver sysfs file\n");
7313 pci_unregister_driver(&ipw_driver); 7343 pci_unregister_driver(&ipw_driver);