aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ipw2100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ipw2100.c')
-rw-r--r--drivers/net/wireless/ipw2100.c2858
1 files changed, 1567 insertions, 1291 deletions
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index ad7f8cd76db9..a2e6214169e9 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -167,17 +167,16 @@ that only one external action is invoked at a time.
167 167
168#include "ipw2100.h" 168#include "ipw2100.h"
169 169
170#define IPW2100_VERSION "1.1.0" 170#define IPW2100_VERSION "1.1.3"
171 171
172#define DRV_NAME "ipw2100" 172#define DRV_NAME "ipw2100"
173#define DRV_VERSION IPW2100_VERSION 173#define DRV_VERSION IPW2100_VERSION
174#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver" 174#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"
175#define DRV_COPYRIGHT "Copyright(c) 2003-2004 Intel Corporation" 175#define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation"
176
177 176
178/* Debugging stuff */ 177/* Debugging stuff */
179#ifdef CONFIG_IPW_DEBUG 178#ifdef CONFIG_IPW_DEBUG
180#define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */ 179#define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */
181#endif 180#endif
182 181
183MODULE_DESCRIPTION(DRV_DESCRIPTION); 182MODULE_DESCRIPTION(DRV_DESCRIPTION);
@@ -220,18 +219,18 @@ do { \
220} while (0) 219} while (0)
221#else 220#else
222#define IPW_DEBUG(level, message...) do {} while (0) 221#define IPW_DEBUG(level, message...) do {} while (0)
223#endif /* CONFIG_IPW_DEBUG */ 222#endif /* CONFIG_IPW_DEBUG */
224 223
225#ifdef CONFIG_IPW_DEBUG 224#ifdef CONFIG_IPW_DEBUG
226static const char *command_types[] = { 225static const char *command_types[] = {
227 "undefined", 226 "undefined",
228 "unused", /* HOST_ATTENTION */ 227 "unused", /* HOST_ATTENTION */
229 "HOST_COMPLETE", 228 "HOST_COMPLETE",
230 "unused", /* SLEEP */ 229 "unused", /* SLEEP */
231 "unused", /* HOST_POWER_DOWN */ 230 "unused", /* HOST_POWER_DOWN */
232 "unused", 231 "unused",
233 "SYSTEM_CONFIG", 232 "SYSTEM_CONFIG",
234 "unused", /* SET_IMR */ 233 "unused", /* SET_IMR */
235 "SSID", 234 "SSID",
236 "MANDATORY_BSSID", 235 "MANDATORY_BSSID",
237 "AUTHENTICATION_TYPE", 236 "AUTHENTICATION_TYPE",
@@ -277,17 +276,16 @@ static const char *command_types[] = {
277 "GROUP_ORDINALS", 276 "GROUP_ORDINALS",
278 "SHORT_RETRY_LIMIT", 277 "SHORT_RETRY_LIMIT",
279 "LONG_RETRY_LIMIT", 278 "LONG_RETRY_LIMIT",
280 "unused", /* SAVE_CALIBRATION */ 279 "unused", /* SAVE_CALIBRATION */
281 "unused", /* RESTORE_CALIBRATION */ 280 "unused", /* RESTORE_CALIBRATION */
282 "undefined", 281 "undefined",
283 "undefined", 282 "undefined",
284 "undefined", 283 "undefined",
285 "HOST_PRE_POWER_DOWN", 284 "HOST_PRE_POWER_DOWN",
286 "unused", /* HOST_INTERRUPT_COALESCING */ 285 "unused", /* HOST_INTERRUPT_COALESCING */
287 "undefined", 286 "undefined",
288 "CARD_DISABLE_PHY_OFF", 287 "CARD_DISABLE_PHY_OFF",
289 "MSDU_TX_RATES" 288 "MSDU_TX_RATES" "undefined",
290 "undefined",
291 "undefined", 289 "undefined",
292 "SET_STATION_STAT_BITS", 290 "SET_STATION_STAT_BITS",
293 "CLEAR_STATIONS_STAT_BITS", 291 "CLEAR_STATIONS_STAT_BITS",
@@ -298,7 +296,6 @@ static const char *command_types[] = {
298}; 296};
299#endif 297#endif
300 298
301
302/* Pre-decl until we get the code solid and then we can clean it up */ 299/* Pre-decl until we get the code solid and then we can clean it up */
303static void ipw2100_tx_send_commands(struct ipw2100_priv *priv); 300static void ipw2100_tx_send_commands(struct ipw2100_priv *priv);
304static void ipw2100_tx_send_data(struct ipw2100_priv *priv); 301static void ipw2100_tx_send_data(struct ipw2100_priv *priv);
@@ -321,11 +318,10 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
321static int ipw2100_ucode_download(struct ipw2100_priv *priv, 318static int ipw2100_ucode_download(struct ipw2100_priv *priv,
322 struct ipw2100_fw *fw); 319 struct ipw2100_fw *fw);
323static void ipw2100_wx_event_work(struct ipw2100_priv *priv); 320static void ipw2100_wx_event_work(struct ipw2100_priv *priv);
324static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev); 321static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev);
325static struct iw_handler_def ipw2100_wx_handler_def; 322static struct iw_handler_def ipw2100_wx_handler_def;
326 323
327 324static inline void read_register(struct net_device *dev, u32 reg, u32 * val)
328static inline void read_register(struct net_device *dev, u32 reg, u32 *val)
329{ 325{
330 *val = readl((void __iomem *)(dev->base_addr + reg)); 326 *val = readl((void __iomem *)(dev->base_addr + reg));
331 IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val); 327 IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val);
@@ -337,13 +333,14 @@ static inline void write_register(struct net_device *dev, u32 reg, u32 val)
337 IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val); 333 IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val);
338} 334}
339 335
340static inline void read_register_word(struct net_device *dev, u32 reg, u16 *val) 336static inline void read_register_word(struct net_device *dev, u32 reg,
337 u16 * val)
341{ 338{
342 *val = readw((void __iomem *)(dev->base_addr + reg)); 339 *val = readw((void __iomem *)(dev->base_addr + reg));
343 IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val); 340 IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val);
344} 341}
345 342
346static inline void read_register_byte(struct net_device *dev, u32 reg, u8 *val) 343static inline void read_register_byte(struct net_device *dev, u32 reg, u8 * val)
347{ 344{
348 *val = readb((void __iomem *)(dev->base_addr + reg)); 345 *val = readb((void __iomem *)(dev->base_addr + reg));
349 IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val); 346 IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val);
@@ -355,14 +352,13 @@ static inline void write_register_word(struct net_device *dev, u32 reg, u16 val)
355 IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val); 352 IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val);
356} 353}
357 354
358
359static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val) 355static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val)
360{ 356{
361 writeb(val, (void __iomem *)(dev->base_addr + reg)); 357 writeb(val, (void __iomem *)(dev->base_addr + reg));
362 IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val); 358 IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val);
363} 359}
364 360
365static inline void read_nic_dword(struct net_device *dev, u32 addr, u32 *val) 361static inline void read_nic_dword(struct net_device *dev, u32 addr, u32 * val)
366{ 362{
367 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 363 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
368 addr & IPW_REG_INDIRECT_ADDR_MASK); 364 addr & IPW_REG_INDIRECT_ADDR_MASK);
@@ -376,7 +372,7 @@ static inline void write_nic_dword(struct net_device *dev, u32 addr, u32 val)
376 write_register(dev, IPW_REG_INDIRECT_ACCESS_DATA, val); 372 write_register(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
377} 373}
378 374
379static inline void read_nic_word(struct net_device *dev, u32 addr, u16 *val) 375static inline void read_nic_word(struct net_device *dev, u32 addr, u16 * val)
380{ 376{
381 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 377 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
382 addr & IPW_REG_INDIRECT_ADDR_MASK); 378 addr & IPW_REG_INDIRECT_ADDR_MASK);
@@ -390,7 +386,7 @@ static inline void write_nic_word(struct net_device *dev, u32 addr, u16 val)
390 write_register_word(dev, IPW_REG_INDIRECT_ACCESS_DATA, val); 386 write_register_word(dev, IPW_REG_INDIRECT_ACCESS_DATA, val);
391} 387}
392 388
393static inline void read_nic_byte(struct net_device *dev, u32 addr, u8 *val) 389static inline void read_nic_byte(struct net_device *dev, u32 addr, u8 * val)
394{ 390{
395 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 391 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
396 addr & IPW_REG_INDIRECT_ADDR_MASK); 392 addr & IPW_REG_INDIRECT_ADDR_MASK);
@@ -416,7 +412,7 @@ static inline void write_nic_dword_auto_inc(struct net_device *dev, u32 val)
416} 412}
417 413
418static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len, 414static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len,
419 const u8 *buf) 415 const u8 * buf)
420{ 416{
421 u32 aligned_addr; 417 u32 aligned_addr;
422 u32 aligned_len; 418 u32 aligned_len;
@@ -431,32 +427,30 @@ static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len,
431 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 427 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
432 aligned_addr); 428 aligned_addr);
433 for (i = dif_len; i < 4; i++, buf++) 429 for (i = dif_len; i < 4; i++, buf++)
434 write_register_byte( 430 write_register_byte(dev,
435 dev, IPW_REG_INDIRECT_ACCESS_DATA + i, 431 IPW_REG_INDIRECT_ACCESS_DATA + i,
436 *buf); 432 *buf);
437 433
438 len -= dif_len; 434 len -= dif_len;
439 aligned_addr += 4; 435 aligned_addr += 4;
440 } 436 }
441 437
442 /* read DWs through autoincrement registers */ 438 /* read DWs through autoincrement registers */
443 write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, 439 write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr);
444 aligned_addr);
445 aligned_len = len & (~0x3); 440 aligned_len = len & (~0x3);
446 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) 441 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
447 write_register( 442 write_register(dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *) buf);
448 dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *)buf);
449 443
450 /* copy the last nibble */ 444 /* copy the last nibble */
451 dif_len = len - aligned_len; 445 dif_len = len - aligned_len;
452 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); 446 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr);
453 for (i = 0; i < dif_len; i++, buf++) 447 for (i = 0; i < dif_len; i++, buf++)
454 write_register_byte( 448 write_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i,
455 dev, IPW_REG_INDIRECT_ACCESS_DATA + i, *buf); 449 *buf);
456} 450}
457 451
458static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len, 452static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len,
459 u8 *buf) 453 u8 * buf)
460{ 454{
461 u32 aligned_addr; 455 u32 aligned_addr;
462 u32 aligned_len; 456 u32 aligned_len;
@@ -471,39 +465,38 @@ static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len,
471 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 465 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS,
472 aligned_addr); 466 aligned_addr);
473 for (i = dif_len; i < 4; i++, buf++) 467 for (i = dif_len; i < 4; i++, buf++)
474 read_register_byte( 468 read_register_byte(dev,
475 dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf); 469 IPW_REG_INDIRECT_ACCESS_DATA + i,
470 buf);
476 471
477 len -= dif_len; 472 len -= dif_len;
478 aligned_addr += 4; 473 aligned_addr += 4;
479 } 474 }
480 475
481 /* read DWs through autoincrement registers */ 476 /* read DWs through autoincrement registers */
482 write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, 477 write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr);
483 aligned_addr);
484 aligned_len = len & (~0x3); 478 aligned_len = len & (~0x3);
485 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) 479 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
486 read_register(dev, IPW_REG_AUTOINCREMENT_DATA, 480 read_register(dev, IPW_REG_AUTOINCREMENT_DATA, (u32 *) buf);
487 (u32 *)buf);
488 481
489 /* copy the last nibble */ 482 /* copy the last nibble */
490 dif_len = len - aligned_len; 483 dif_len = len - aligned_len;
491 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, 484 write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr);
492 aligned_addr);
493 for (i = 0; i < dif_len; i++, buf++) 485 for (i = 0; i < dif_len; i++, buf++)
494 read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + 486 read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf);
495 i, buf);
496} 487}
497 488
498static inline int ipw2100_hw_is_adapter_in_system(struct net_device *dev) 489static inline int ipw2100_hw_is_adapter_in_system(struct net_device *dev)
499{ 490{
500 return (dev->base_addr && 491 return (dev->base_addr &&
501 (readl((void __iomem *)(dev->base_addr + IPW_REG_DOA_DEBUG_AREA_START)) 492 (readl
493 ((void __iomem *)(dev->base_addr +
494 IPW_REG_DOA_DEBUG_AREA_START))
502 == IPW_DATA_DOA_DEBUG_VALUE)); 495 == IPW_DATA_DOA_DEBUG_VALUE));
503} 496}
504 497
505static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, 498static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
506 void *val, u32 *len) 499 void *val, u32 * len)
507{ 500{
508 struct ipw2100_ordinals *ordinals = &priv->ordinals; 501 struct ipw2100_ordinals *ordinals = &priv->ordinals;
509 u32 addr; 502 u32 addr;
@@ -529,8 +522,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
529 return -EINVAL; 522 return -EINVAL;
530 } 523 }
531 524
532 read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2), 525 read_nic_dword(priv->net_dev,
533 &addr); 526 ordinals->table1_addr + (ord << 2), &addr);
534 read_nic_dword(priv->net_dev, addr, val); 527 read_nic_dword(priv->net_dev, addr, val);
535 528
536 *len = IPW_ORD_TAB_1_ENTRY_SIZE; 529 *len = IPW_ORD_TAB_1_ENTRY_SIZE;
@@ -543,8 +536,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
543 ord -= IPW_START_ORD_TAB_2; 536 ord -= IPW_START_ORD_TAB_2;
544 537
545 /* get the address of statistic */ 538 /* get the address of statistic */
546 read_nic_dword(priv->net_dev, ordinals->table2_addr + (ord << 3), 539 read_nic_dword(priv->net_dev,
547 &addr); 540 ordinals->table2_addr + (ord << 3), &addr);
548 541
549 /* get the second DW of statistics ; 542 /* get the second DW of statistics ;
550 * two 16-bit words - first is length, second is count */ 543 * two 16-bit words - first is length, second is count */
@@ -553,10 +546,10 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
553 &field_info); 546 &field_info);
554 547
555 /* get each entry length */ 548 /* get each entry length */
556 field_len = *((u16 *)&field_info); 549 field_len = *((u16 *) & field_info);
557 550
558 /* get number of entries */ 551 /* get number of entries */
559 field_count = *(((u16 *)&field_info) + 1); 552 field_count = *(((u16 *) & field_info) + 1);
560 553
561 /* abort if no enought memory */ 554 /* abort if no enought memory */
562 total_length = field_len * field_count; 555 total_length = field_len * field_count;
@@ -581,8 +574,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord,
581 return -EINVAL; 574 return -EINVAL;
582} 575}
583 576
584static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val, 577static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 * val,
585 u32 *len) 578 u32 * len)
586{ 579{
587 struct ipw2100_ordinals *ordinals = &priv->ordinals; 580 struct ipw2100_ordinals *ordinals = &priv->ordinals;
588 u32 addr; 581 u32 addr;
@@ -594,8 +587,8 @@ static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val,
594 return -EINVAL; 587 return -EINVAL;
595 } 588 }
596 589
597 read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2), 590 read_nic_dword(priv->net_dev,
598 &addr); 591 ordinals->table1_addr + (ord << 2), &addr);
599 592
600 write_nic_dword(priv->net_dev, addr, *val); 593 write_nic_dword(priv->net_dev, addr, *val);
601 594
@@ -612,7 +605,7 @@ static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val,
612} 605}
613 606
614static char *snprint_line(char *buf, size_t count, 607static char *snprint_line(char *buf, size_t count,
615 const u8 *data, u32 len, u32 ofs) 608 const u8 * data, u32 len, u32 ofs)
616{ 609{
617 int out, i, j, l; 610 int out, i, j, l;
618 char c; 611 char c;
@@ -646,7 +639,7 @@ static char *snprint_line(char *buf, size_t count,
646 return buf; 639 return buf;
647} 640}
648 641
649static void printk_buf(int level, const u8 *data, u32 len) 642static void printk_buf(int level, const u8 * data, u32 len)
650{ 643{
651 char line[81]; 644 char line[81];
652 u32 ofs = 0; 645 u32 ofs = 0;
@@ -662,8 +655,6 @@ static void printk_buf(int level, const u8 *data, u32 len)
662 } 655 }
663} 656}
664 657
665
666
667#define MAX_RESET_BACKOFF 10 658#define MAX_RESET_BACKOFF 10
668 659
669static inline void schedule_reset(struct ipw2100_priv *priv) 660static inline void schedule_reset(struct ipw2100_priv *priv)
@@ -703,7 +694,7 @@ static inline void schedule_reset(struct ipw2100_priv *priv)
703 694
704#define HOST_COMPLETE_TIMEOUT (2 * HZ) 695#define HOST_COMPLETE_TIMEOUT (2 * HZ)
705static int ipw2100_hw_send_command(struct ipw2100_priv *priv, 696static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
706 struct host_command * cmd) 697 struct host_command *cmd)
707{ 698{
708 struct list_head *element; 699 struct list_head *element;
709 struct ipw2100_tx_packet *packet; 700 struct ipw2100_tx_packet *packet;
@@ -713,25 +704,28 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
713 IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", 704 IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n",
714 command_types[cmd->host_command], cmd->host_command, 705 command_types[cmd->host_command], cmd->host_command,
715 cmd->host_command_length); 706 cmd->host_command_length);
716 printk_buf(IPW_DL_HC, (u8*)cmd->host_command_parameters, 707 printk_buf(IPW_DL_HC, (u8 *) cmd->host_command_parameters,
717 cmd->host_command_length); 708 cmd->host_command_length);
718 709
719 spin_lock_irqsave(&priv->low_lock, flags); 710 spin_lock_irqsave(&priv->low_lock, flags);
720 711
721 if (priv->fatal_error) { 712 if (priv->fatal_error) {
722 IPW_DEBUG_INFO("Attempt to send command while hardware in fatal error condition.\n"); 713 IPW_DEBUG_INFO
714 ("Attempt to send command while hardware in fatal error condition.\n");
723 err = -EIO; 715 err = -EIO;
724 goto fail_unlock; 716 goto fail_unlock;
725 } 717 }
726 718
727 if (!(priv->status & STATUS_RUNNING)) { 719 if (!(priv->status & STATUS_RUNNING)) {
728 IPW_DEBUG_INFO("Attempt to send command while hardware is not running.\n"); 720 IPW_DEBUG_INFO
721 ("Attempt to send command while hardware is not running.\n");
729 err = -EIO; 722 err = -EIO;
730 goto fail_unlock; 723 goto fail_unlock;
731 } 724 }
732 725
733 if (priv->status & STATUS_CMD_ACTIVE) { 726 if (priv->status & STATUS_CMD_ACTIVE) {
734 IPW_DEBUG_INFO("Attempt to send command while another command is pending.\n"); 727 IPW_DEBUG_INFO
728 ("Attempt to send command while another command is pending.\n");
735 err = -EBUSY; 729 err = -EBUSY;
736 goto fail_unlock; 730 goto fail_unlock;
737 } 731 }
@@ -752,7 +746,8 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
752 /* initialize the firmware command packet */ 746 /* initialize the firmware command packet */
753 packet->info.c_struct.cmd->host_command_reg = cmd->host_command; 747 packet->info.c_struct.cmd->host_command_reg = cmd->host_command;
754 packet->info.c_struct.cmd->host_command_reg1 = cmd->host_command1; 748 packet->info.c_struct.cmd->host_command_reg1 = cmd->host_command1;
755 packet->info.c_struct.cmd->host_command_len_reg = cmd->host_command_length; 749 packet->info.c_struct.cmd->host_command_len_reg =
750 cmd->host_command_length;
756 packet->info.c_struct.cmd->sequence = cmd->host_command_sequence; 751 packet->info.c_struct.cmd->sequence = cmd->host_command_sequence;
757 752
758 memcpy(packet->info.c_struct.cmd->host_command_params_reg, 753 memcpy(packet->info.c_struct.cmd->host_command_params_reg,
@@ -776,13 +771,15 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
776 * then there is a problem. 771 * then there is a problem.
777 */ 772 */
778 773
779 err = wait_event_interruptible_timeout( 774 err =
780 priv->wait_command_queue, !(priv->status & STATUS_CMD_ACTIVE), 775 wait_event_interruptible_timeout(priv->wait_command_queue,
781 HOST_COMPLETE_TIMEOUT); 776 !(priv->
777 status & STATUS_CMD_ACTIVE),
778 HOST_COMPLETE_TIMEOUT);
782 779
783 if (err == 0) { 780 if (err == 0) {
784 IPW_DEBUG_INFO("Command completion failed out after %dms.\n", 781 IPW_DEBUG_INFO("Command completion failed out after %dms.\n",
785 HOST_COMPLETE_TIMEOUT / (HZ / 100)); 782 1000 * (HOST_COMPLETE_TIMEOUT / HZ));
786 priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT; 783 priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT;
787 priv->status &= ~STATUS_CMD_ACTIVE; 784 priv->status &= ~STATUS_CMD_ACTIVE;
788 schedule_reset(priv); 785 schedule_reset(priv);
@@ -804,13 +801,12 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
804 801
805 return 0; 802 return 0;
806 803
807 fail_unlock: 804 fail_unlock:
808 spin_unlock_irqrestore(&priv->low_lock, flags); 805 spin_unlock_irqrestore(&priv->low_lock, flags);
809 806
810 return err; 807 return err;
811} 808}
812 809
813
814/* 810/*
815 * Verify the values and data access of the hardware 811 * Verify the values and data access of the hardware
816 * No locks needed or used. No functions called. 812 * No locks needed or used. No functions called.
@@ -825,8 +821,7 @@ static int ipw2100_verify(struct ipw2100_priv *priv)
825 821
826 /* Domain 0 check - all values should be DOA_DEBUG */ 822 /* Domain 0 check - all values should be DOA_DEBUG */
827 for (address = IPW_REG_DOA_DEBUG_AREA_START; 823 for (address = IPW_REG_DOA_DEBUG_AREA_START;
828 address < IPW_REG_DOA_DEBUG_AREA_END; 824 address < IPW_REG_DOA_DEBUG_AREA_END; address += sizeof(u32)) {
829 address += sizeof(u32)) {
830 read_register(priv->net_dev, address, &data1); 825 read_register(priv->net_dev, address, &data1);
831 if (data1 != IPW_DATA_DOA_DEBUG_VALUE) 826 if (data1 != IPW_DATA_DOA_DEBUG_VALUE)
832 return -EIO; 827 return -EIO;
@@ -898,7 +893,6 @@ static int ipw2100_wait_for_card_state(struct ipw2100_priv *priv, int state)
898 return -EIO; 893 return -EIO;
899} 894}
900 895
901
902/********************************************************************* 896/*********************************************************************
903 Procedure : sw_reset_and_clock 897 Procedure : sw_reset_and_clock
904 Purpose : Asserts s/w reset, asserts clock initialization 898 Purpose : Asserts s/w reset, asserts clock initialization
@@ -975,17 +969,16 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
975 969
976 if (priv->fatal_error) { 970 if (priv->fatal_error) {
977 IPW_DEBUG_ERROR("%s: ipw2100_download_firmware called after " 971 IPW_DEBUG_ERROR("%s: ipw2100_download_firmware called after "
978 "fatal error %d. Interface must be brought down.\n", 972 "fatal error %d. Interface must be brought down.\n",
979 priv->net_dev->name, priv->fatal_error); 973 priv->net_dev->name, priv->fatal_error);
980 return -EINVAL; 974 return -EINVAL;
981 } 975 }
982
983#ifdef CONFIG_PM 976#ifdef CONFIG_PM
984 if (!ipw2100_firmware.version) { 977 if (!ipw2100_firmware.version) {
985 err = ipw2100_get_firmware(priv, &ipw2100_firmware); 978 err = ipw2100_get_firmware(priv, &ipw2100_firmware);
986 if (err) { 979 if (err) {
987 IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n", 980 IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
988 priv->net_dev->name, err); 981 priv->net_dev->name, err);
989 priv->fatal_error = IPW2100_ERR_FW_LOAD; 982 priv->fatal_error = IPW2100_ERR_FW_LOAD;
990 goto fail; 983 goto fail;
991 } 984 }
@@ -994,7 +987,7 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
994 err = ipw2100_get_firmware(priv, &ipw2100_firmware); 987 err = ipw2100_get_firmware(priv, &ipw2100_firmware);
995 if (err) { 988 if (err) {
996 IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n", 989 IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n",
997 priv->net_dev->name, err); 990 priv->net_dev->name, err);
998 priv->fatal_error = IPW2100_ERR_FW_LOAD; 991 priv->fatal_error = IPW2100_ERR_FW_LOAD;
999 goto fail; 992 goto fail;
1000 } 993 }
@@ -1005,21 +998,20 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
1005 err = sw_reset_and_clock(priv); 998 err = sw_reset_and_clock(priv);
1006 if (err) { 999 if (err) {
1007 IPW_DEBUG_ERROR("%s: sw_reset_and_clock failed: %d\n", 1000 IPW_DEBUG_ERROR("%s: sw_reset_and_clock failed: %d\n",
1008 priv->net_dev->name, err); 1001 priv->net_dev->name, err);
1009 goto fail; 1002 goto fail;
1010 } 1003 }
1011 1004
1012 err = ipw2100_verify(priv); 1005 err = ipw2100_verify(priv);
1013 if (err) { 1006 if (err) {
1014 IPW_DEBUG_ERROR("%s: ipw2100_verify failed: %d\n", 1007 IPW_DEBUG_ERROR("%s: ipw2100_verify failed: %d\n",
1015 priv->net_dev->name, err); 1008 priv->net_dev->name, err);
1016 goto fail; 1009 goto fail;
1017 } 1010 }
1018 1011
1019 /* Hold ARC */ 1012 /* Hold ARC */
1020 write_nic_dword(priv->net_dev, 1013 write_nic_dword(priv->net_dev,
1021 IPW_INTERNAL_REGISTER_HALT_AND_RESET, 1014 IPW_INTERNAL_REGISTER_HALT_AND_RESET, 0x80000000);
1022 0x80000000);
1023 1015
1024 /* allow ARC to run */ 1016 /* allow ARC to run */
1025 write_register(priv->net_dev, IPW_REG_RESET_REG, 0); 1017 write_register(priv->net_dev, IPW_REG_RESET_REG, 0);
@@ -1034,13 +1026,13 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
1034 1026
1035 /* release ARC */ 1027 /* release ARC */
1036 write_nic_dword(priv->net_dev, 1028 write_nic_dword(priv->net_dev,
1037 IPW_INTERNAL_REGISTER_HALT_AND_RESET, 1029 IPW_INTERNAL_REGISTER_HALT_AND_RESET, 0x00000000);
1038 0x00000000);
1039 1030
1040 /* s/w reset and clock stabilization (again!!!) */ 1031 /* s/w reset and clock stabilization (again!!!) */
1041 err = sw_reset_and_clock(priv); 1032 err = sw_reset_and_clock(priv);
1042 if (err) { 1033 if (err) {
1043 printk(KERN_ERR DRV_NAME ": %s: sw_reset_and_clock failed: %d\n", 1034 printk(KERN_ERR DRV_NAME
1035 ": %s: sw_reset_and_clock failed: %d\n",
1044 priv->net_dev->name, err); 1036 priv->net_dev->name, err);
1045 goto fail; 1037 goto fail;
1046 } 1038 }
@@ -1049,10 +1041,9 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
1049 err = ipw2100_fw_download(priv, &ipw2100_firmware); 1041 err = ipw2100_fw_download(priv, &ipw2100_firmware);
1050 if (err) { 1042 if (err) {
1051 IPW_DEBUG_ERROR("%s: Error loading firmware: %d\n", 1043 IPW_DEBUG_ERROR("%s: Error loading firmware: %d\n",
1052 priv->net_dev->name, err); 1044 priv->net_dev->name, err);
1053 goto fail; 1045 goto fail;
1054 } 1046 }
1055
1056#ifndef CONFIG_PM 1047#ifndef CONFIG_PM
1057 /* 1048 /*
1058 * When the .resume method of the driver is called, the other 1049 * When the .resume method of the driver is called, the other
@@ -1084,7 +1075,7 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv)
1084 1075
1085 return 0; 1076 return 0;
1086 1077
1087 fail: 1078 fail:
1088 ipw2100_release_firmware(priv, &ipw2100_firmware); 1079 ipw2100_release_firmware(priv, &ipw2100_firmware);
1089 return err; 1080 return err;
1090} 1081}
@@ -1105,7 +1096,6 @@ static inline void ipw2100_disable_interrupts(struct ipw2100_priv *priv)
1105 write_register(priv->net_dev, IPW_REG_INTA_MASK, 0x0); 1096 write_register(priv->net_dev, IPW_REG_INTA_MASK, 0x0);
1106} 1097}
1107 1098
1108
1109static void ipw2100_initialize_ordinals(struct ipw2100_priv *priv) 1099static void ipw2100_initialize_ordinals(struct ipw2100_priv *priv)
1110{ 1100{
1111 struct ipw2100_ordinals *ord = &priv->ordinals; 1101 struct ipw2100_ordinals *ord = &priv->ordinals;
@@ -1177,11 +1167,10 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv)
1177 * EEPROM_SRAM_DB_START_ADDRESS using ordinal in ordinal table 1 1167 * EEPROM_SRAM_DB_START_ADDRESS using ordinal in ordinal table 1
1178 */ 1168 */
1179 len = sizeof(addr); 1169 len = sizeof(addr);
1180 if (ipw2100_get_ordinal( 1170 if (ipw2100_get_ordinal
1181 priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS, 1171 (priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS, &addr, &len)) {
1182 &addr, &len)) {
1183 IPW_DEBUG_INFO("failed querying ordinals at line %d\n", 1172 IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
1184 __LINE__); 1173 __LINE__);
1185 return -EIO; 1174 return -EIO;
1186 } 1175 }
1187 1176
@@ -1194,7 +1183,7 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv)
1194 priv->eeprom_version = (val >> 24) & 0xFF; 1183 priv->eeprom_version = (val >> 24) & 0xFF;
1195 IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version); 1184 IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version);
1196 1185
1197 /* 1186 /*
1198 * HW RF Kill enable is bit 0 in byte at offset 0x21 in firmware 1187 * HW RF Kill enable is bit 0 in byte at offset 0x21 in firmware
1199 * 1188 *
1200 * notice that the EEPROM bit is reverse polarity, i.e. 1189 * notice that the EEPROM bit is reverse polarity, i.e.
@@ -1206,8 +1195,7 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv)
1206 priv->hw_features |= HW_FEATURE_RFKILL; 1195 priv->hw_features |= HW_FEATURE_RFKILL;
1207 1196
1208 IPW_DEBUG_INFO("HW RF Kill: %ssupported.\n", 1197 IPW_DEBUG_INFO("HW RF Kill: %ssupported.\n",
1209 (priv->hw_features & HW_FEATURE_RFKILL) ? 1198 (priv->hw_features & HW_FEATURE_RFKILL) ? "" : "not ");
1210 "" : "not ");
1211 1199
1212 return 0; 1200 return 0;
1213} 1201}
@@ -1234,7 +1222,8 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv)
1234 * fw & dino ucode 1222 * fw & dino ucode
1235 */ 1223 */
1236 if (ipw2100_download_firmware(priv)) { 1224 if (ipw2100_download_firmware(priv)) {
1237 printk(KERN_ERR DRV_NAME ": %s: Failed to power on the adapter.\n", 1225 printk(KERN_ERR DRV_NAME
1226 ": %s: Failed to power on the adapter.\n",
1238 priv->net_dev->name); 1227 priv->net_dev->name);
1239 return -EIO; 1228 return -EIO;
1240 } 1229 }
@@ -1293,7 +1282,8 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv)
1293 i ? "SUCCESS" : "FAILED"); 1282 i ? "SUCCESS" : "FAILED");
1294 1283
1295 if (!i) { 1284 if (!i) {
1296 printk(KERN_WARNING DRV_NAME ": %s: Firmware did not initialize.\n", 1285 printk(KERN_WARNING DRV_NAME
1286 ": %s: Firmware did not initialize.\n",
1297 priv->net_dev->name); 1287 priv->net_dev->name);
1298 return -EIO; 1288 return -EIO;
1299 } 1289 }
@@ -1326,7 +1316,6 @@ static inline void ipw2100_reset_fatalerror(struct ipw2100_priv *priv)
1326 priv->fatal_error = 0; 1316 priv->fatal_error = 0;
1327} 1317}
1328 1318
1329
1330/* NOTE: Our interrupt is disabled when this method is called */ 1319/* NOTE: Our interrupt is disabled when this method is called */
1331static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv) 1320static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
1332{ 1321{
@@ -1350,19 +1339,19 @@ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
1350 1339
1351 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) 1340 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
1352 break; 1341 break;
1353 } while(i--); 1342 } while (i--);
1354 1343
1355 priv->status &= ~STATUS_RESET_PENDING; 1344 priv->status &= ~STATUS_RESET_PENDING;
1356 1345
1357 if (!i) { 1346 if (!i) {
1358 IPW_DEBUG_INFO("exit - waited too long for master assert stop\n"); 1347 IPW_DEBUG_INFO
1348 ("exit - waited too long for master assert stop\n");
1359 return -EIO; 1349 return -EIO;
1360 } 1350 }
1361 1351
1362 write_register(priv->net_dev, IPW_REG_RESET_REG, 1352 write_register(priv->net_dev, IPW_REG_RESET_REG,
1363 IPW_AUX_HOST_RESET_REG_SW_RESET); 1353 IPW_AUX_HOST_RESET_REG_SW_RESET);
1364 1354
1365
1366 /* Reset any fatal_error conditions */ 1355 /* Reset any fatal_error conditions */
1367 ipw2100_reset_fatalerror(priv); 1356 ipw2100_reset_fatalerror(priv);
1368 1357
@@ -1415,7 +1404,6 @@ static int ipw2100_hw_phy_off(struct ipw2100_priv *priv)
1415 return -EIO; 1404 return -EIO;
1416} 1405}
1417 1406
1418
1419static int ipw2100_enable_adapter(struct ipw2100_priv *priv) 1407static int ipw2100_enable_adapter(struct ipw2100_priv *priv)
1420{ 1408{
1421 struct host_command cmd = { 1409 struct host_command cmd = {
@@ -1445,9 +1433,8 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv)
1445 1433
1446 err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_ENABLED); 1434 err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_ENABLED);
1447 if (err) { 1435 if (err) {
1448 IPW_DEBUG_INFO( 1436 IPW_DEBUG_INFO("%s: card not responding to init command.\n",
1449 "%s: card not responding to init command.\n", 1437 priv->net_dev->name);
1450 priv->net_dev->name);
1451 goto fail_up; 1438 goto fail_up;
1452 } 1439 }
1453 1440
@@ -1456,7 +1443,7 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv)
1456 queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2); 1443 queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2);
1457 } 1444 }
1458 1445
1459fail_up: 1446 fail_up:
1460 up(&priv->adapter_sem); 1447 up(&priv->adapter_sem);
1461 return err; 1448 return err;
1462} 1449}
@@ -1488,7 +1475,8 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
1488 1475
1489 err = ipw2100_hw_phy_off(priv); 1476 err = ipw2100_hw_phy_off(priv);
1490 if (err) 1477 if (err)
1491 printk(KERN_WARNING DRV_NAME ": Error disabling radio %d\n", err); 1478 printk(KERN_WARNING DRV_NAME
1479 ": Error disabling radio %d\n", err);
1492 1480
1493 /* 1481 /*
1494 * If in D0-standby mode going directly to D3 may cause a 1482 * If in D0-standby mode going directly to D3 may cause a
@@ -1566,7 +1554,6 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
1566 return 0; 1554 return 0;
1567} 1555}
1568 1556
1569
1570static int ipw2100_disable_adapter(struct ipw2100_priv *priv) 1557static int ipw2100_disable_adapter(struct ipw2100_priv *priv)
1571{ 1558{
1572 struct host_command cmd = { 1559 struct host_command cmd = {
@@ -1593,19 +1580,21 @@ static int ipw2100_disable_adapter(struct ipw2100_priv *priv)
1593 1580
1594 err = ipw2100_hw_send_command(priv, &cmd); 1581 err = ipw2100_hw_send_command(priv, &cmd);
1595 if (err) { 1582 if (err) {
1596 printk(KERN_WARNING DRV_NAME ": exit - failed to send CARD_DISABLE command\n"); 1583 printk(KERN_WARNING DRV_NAME
1584 ": exit - failed to send CARD_DISABLE command\n");
1597 goto fail_up; 1585 goto fail_up;
1598 } 1586 }
1599 1587
1600 err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_DISABLED); 1588 err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_DISABLED);
1601 if (err) { 1589 if (err) {
1602 printk(KERN_WARNING DRV_NAME ": exit - card failed to change to DISABLED\n"); 1590 printk(KERN_WARNING DRV_NAME
1591 ": exit - card failed to change to DISABLED\n");
1603 goto fail_up; 1592 goto fail_up;
1604 } 1593 }
1605 1594
1606 IPW_DEBUG_INFO("TODO: implement scan state machine\n"); 1595 IPW_DEBUG_INFO("TODO: implement scan state machine\n");
1607 1596
1608fail_up: 1597 fail_up:
1609 up(&priv->adapter_sem); 1598 up(&priv->adapter_sem);
1610 return err; 1599 return err;
1611} 1600}
@@ -1627,7 +1616,7 @@ static int ipw2100_set_scan_options(struct ipw2100_priv *priv)
1627 1616
1628 if (!(priv->config & CFG_ASSOCIATE)) 1617 if (!(priv->config & CFG_ASSOCIATE))
1629 cmd.host_command_parameters[0] |= IPW_SCAN_NOASSOCIATE; 1618 cmd.host_command_parameters[0] |= IPW_SCAN_NOASSOCIATE;
1630 if ((priv->sec.flags & SEC_ENABLED) && priv->sec.enabled) 1619 if ((priv->ieee->sec.flags & SEC_ENABLED) && priv->ieee->sec.enabled)
1631 cmd.host_command_parameters[0] |= IPW_SCAN_MIXED_CELL; 1620 cmd.host_command_parameters[0] |= IPW_SCAN_MIXED_CELL;
1632 if (priv->config & CFG_PASSIVE_SCAN) 1621 if (priv->config & CFG_PASSIVE_SCAN)
1633 cmd.host_command_parameters[0] |= IPW_SCAN_PASSIVE; 1622 cmd.host_command_parameters[0] |= IPW_SCAN_PASSIVE;
@@ -1709,8 +1698,9 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1709 (priv->status & STATUS_RESET_PENDING)) { 1698 (priv->status & STATUS_RESET_PENDING)) {
1710 /* Power cycle the card ... */ 1699 /* Power cycle the card ... */
1711 if (ipw2100_power_cycle_adapter(priv)) { 1700 if (ipw2100_power_cycle_adapter(priv)) {
1712 printk(KERN_WARNING DRV_NAME ": %s: Could not cycle adapter.\n", 1701 printk(KERN_WARNING DRV_NAME
1713 priv->net_dev->name); 1702 ": %s: Could not cycle adapter.\n",
1703 priv->net_dev->name);
1714 rc = 1; 1704 rc = 1;
1715 goto exit; 1705 goto exit;
1716 } 1706 }
@@ -1719,8 +1709,9 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1719 1709
1720 /* Load the firmware, start the clocks, etc. */ 1710 /* Load the firmware, start the clocks, etc. */
1721 if (ipw2100_start_adapter(priv)) { 1711 if (ipw2100_start_adapter(priv)) {
1722 printk(KERN_ERR DRV_NAME ": %s: Failed to start the firmware.\n", 1712 printk(KERN_ERR DRV_NAME
1723 priv->net_dev->name); 1713 ": %s: Failed to start the firmware.\n",
1714 priv->net_dev->name);
1724 rc = 1; 1715 rc = 1;
1725 goto exit; 1716 goto exit;
1726 } 1717 }
@@ -1729,16 +1720,18 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1729 1720
1730 /* Determine capabilities of this particular HW configuration */ 1721 /* Determine capabilities of this particular HW configuration */
1731 if (ipw2100_get_hw_features(priv)) { 1722 if (ipw2100_get_hw_features(priv)) {
1732 printk(KERN_ERR DRV_NAME ": %s: Failed to determine HW features.\n", 1723 printk(KERN_ERR DRV_NAME
1733 priv->net_dev->name); 1724 ": %s: Failed to determine HW features.\n",
1725 priv->net_dev->name);
1734 rc = 1; 1726 rc = 1;
1735 goto exit; 1727 goto exit;
1736 } 1728 }
1737 1729
1738 lock = LOCK_NONE; 1730 lock = LOCK_NONE;
1739 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) { 1731 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) {
1740 printk(KERN_ERR DRV_NAME ": %s: Failed to clear ordinal lock.\n", 1732 printk(KERN_ERR DRV_NAME
1741 priv->net_dev->name); 1733 ": %s: Failed to clear ordinal lock.\n",
1734 priv->net_dev->name);
1742 rc = 1; 1735 rc = 1;
1743 goto exit; 1736 goto exit;
1744 } 1737 }
@@ -1764,7 +1757,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1764 * HOST_COMPLETE */ 1757 * HOST_COMPLETE */
1765 if (ipw2100_adapter_setup(priv)) { 1758 if (ipw2100_adapter_setup(priv)) {
1766 printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n", 1759 printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n",
1767 priv->net_dev->name); 1760 priv->net_dev->name);
1768 rc = 1; 1761 rc = 1;
1769 goto exit; 1762 goto exit;
1770 } 1763 }
@@ -1773,20 +1766,19 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1773 /* Enable the adapter - sends HOST_COMPLETE */ 1766 /* Enable the adapter - sends HOST_COMPLETE */
1774 if (ipw2100_enable_adapter(priv)) { 1767 if (ipw2100_enable_adapter(priv)) {
1775 printk(KERN_ERR DRV_NAME ": " 1768 printk(KERN_ERR DRV_NAME ": "
1776 "%s: failed in call to enable adapter.\n", 1769 "%s: failed in call to enable adapter.\n",
1777 priv->net_dev->name); 1770 priv->net_dev->name);
1778 ipw2100_hw_stop_adapter(priv); 1771 ipw2100_hw_stop_adapter(priv);
1779 rc = 1; 1772 rc = 1;
1780 goto exit; 1773 goto exit;
1781 } 1774 }
1782 1775
1783
1784 /* Start a scan . . . */ 1776 /* Start a scan . . . */
1785 ipw2100_set_scan_options(priv); 1777 ipw2100_set_scan_options(priv);
1786 ipw2100_start_scan(priv); 1778 ipw2100_start_scan(priv);
1787 } 1779 }
1788 1780
1789 exit: 1781 exit:
1790 return rc; 1782 return rc;
1791} 1783}
1792 1784
@@ -1802,8 +1794,7 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1802 unsigned long flags; 1794 unsigned long flags;
1803 union iwreq_data wrqu = { 1795 union iwreq_data wrqu = {
1804 .ap_addr = { 1796 .ap_addr = {
1805 .sa_family = ARPHRD_ETHER 1797 .sa_family = ARPHRD_ETHER}
1806 }
1807 }; 1798 };
1808 int associated = priv->status & STATUS_ASSOCIATED; 1799 int associated = priv->status & STATUS_ASSOCIATED;
1809 1800
@@ -1842,7 +1833,7 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1842 1833
1843#ifdef ACPI_CSTATE_LIMIT_DEFINED 1834#ifdef ACPI_CSTATE_LIMIT_DEFINED
1844 if (priv->config & CFG_C3_DISABLED) { 1835 if (priv->config & CFG_C3_DISABLED) {
1845 IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n"); 1836 IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
1846 acpi_set_cstate_limit(priv->cstate_limit); 1837 acpi_set_cstate_limit(priv->cstate_limit);
1847 priv->config &= ~CFG_C3_DISABLED; 1838 priv->config &= ~CFG_C3_DISABLED;
1848 } 1839 }
@@ -1862,14 +1853,12 @@ static void ipw2100_reset_adapter(struct ipw2100_priv *priv)
1862 unsigned long flags; 1853 unsigned long flags;
1863 union iwreq_data wrqu = { 1854 union iwreq_data wrqu = {
1864 .ap_addr = { 1855 .ap_addr = {
1865 .sa_family = ARPHRD_ETHER 1856 .sa_family = ARPHRD_ETHER}
1866 }
1867 }; 1857 };
1868 int associated = priv->status & STATUS_ASSOCIATED; 1858 int associated = priv->status & STATUS_ASSOCIATED;
1869 1859
1870 spin_lock_irqsave(&priv->low_lock, flags); 1860 spin_lock_irqsave(&priv->low_lock, flags);
1871 IPW_DEBUG_INFO(DRV_NAME ": %s: Restarting adapter.\n", 1861 IPW_DEBUG_INFO(": %s: Restarting adapter.\n", priv->net_dev->name);
1872 priv->net_dev->name);
1873 priv->resets++; 1862 priv->resets++;
1874 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); 1863 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
1875 priv->status |= STATUS_SECURITY_UPDATED; 1864 priv->status |= STATUS_SECURITY_UPDATED;
@@ -1894,7 +1883,6 @@ static void ipw2100_reset_adapter(struct ipw2100_priv *priv)
1894 1883
1895} 1884}
1896 1885
1897
1898static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) 1886static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1899{ 1887{
1900 1888
@@ -1904,7 +1892,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1904 u32 txrate; 1892 u32 txrate;
1905 u32 chan; 1893 u32 chan;
1906 char *txratename; 1894 char *txratename;
1907 u8 bssid[ETH_ALEN]; 1895 u8 bssid[ETH_ALEN];
1908 1896
1909 /* 1897 /*
1910 * TBD: BSSID is usually 00:00:00:00:00:00 here and not 1898 * TBD: BSSID is usually 00:00:00:00:00:00 here and not
@@ -1918,16 +1906,15 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1918 essid, &essid_len); 1906 essid, &essid_len);
1919 if (ret) { 1907 if (ret) {
1920 IPW_DEBUG_INFO("failed querying ordinals at line %d\n", 1908 IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
1921 __LINE__); 1909 __LINE__);
1922 return; 1910 return;
1923 } 1911 }
1924 1912
1925 len = sizeof(u32); 1913 len = sizeof(u32);
1926 ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, 1914 ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, &txrate, &len);
1927 &txrate, &len);
1928 if (ret) { 1915 if (ret) {
1929 IPW_DEBUG_INFO("failed querying ordinals at line %d\n", 1916 IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
1930 __LINE__); 1917 __LINE__);
1931 return; 1918 return;
1932 } 1919 }
1933 1920
@@ -1935,19 +1922,18 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1935 ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &len); 1922 ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &len);
1936 if (ret) { 1923 if (ret) {
1937 IPW_DEBUG_INFO("failed querying ordinals at line %d\n", 1924 IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
1938 __LINE__); 1925 __LINE__);
1939 return; 1926 return;
1940 } 1927 }
1941 len = ETH_ALEN; 1928 len = ETH_ALEN;
1942 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, &bssid, &len); 1929 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, &bssid, &len);
1943 if (ret) { 1930 if (ret) {
1944 IPW_DEBUG_INFO("failed querying ordinals at line %d\n", 1931 IPW_DEBUG_INFO("failed querying ordinals at line %d\n",
1945 __LINE__); 1932 __LINE__);
1946 return; 1933 return;
1947 } 1934 }
1948 memcpy(priv->ieee->bssid, bssid, ETH_ALEN); 1935 memcpy(priv->ieee->bssid, bssid, ETH_ALEN);
1949 1936
1950
1951 switch (txrate) { 1937 switch (txrate) {
1952 case TX_RATE_1_MBIT: 1938 case TX_RATE_1_MBIT:
1953 txratename = "1Mbps"; 1939 txratename = "1Mbps";
@@ -1974,7 +1960,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1974 1960
1975 /* now we copy read ssid into dev */ 1961 /* now we copy read ssid into dev */
1976 if (!(priv->config & CFG_STATIC_ESSID)) { 1962 if (!(priv->config & CFG_STATIC_ESSID)) {
1977 priv->essid_len = min((u8)essid_len, (u8)IW_ESSID_MAX_SIZE); 1963 priv->essid_len = min((u8) essid_len, (u8) IW_ESSID_MAX_SIZE);
1978 memcpy(priv->essid, essid, priv->essid_len); 1964 memcpy(priv->essid, essid, priv->essid_len);
1979 } 1965 }
1980 priv->channel = chan; 1966 priv->channel = chan;
@@ -1986,7 +1972,6 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
1986 queue_delayed_work(priv->workqueue, &priv->wx_event_work, HZ / 10); 1972 queue_delayed_work(priv->workqueue, &priv->wx_event_work, HZ / 10);
1987} 1973}
1988 1974
1989
1990static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, 1975static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
1991 int length, int batch_mode) 1976 int length, int batch_mode)
1992{ 1977{
@@ -2001,8 +1986,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
2001 IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len)); 1986 IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len));
2002 1987
2003 if (ssid_len) 1988 if (ssid_len)
2004 memcpy((char*)cmd.host_command_parameters, 1989 memcpy(cmd.host_command_parameters, essid, ssid_len);
2005 essid, ssid_len);
2006 1990
2007 if (!batch_mode) { 1991 if (!batch_mode) {
2008 err = ipw2100_disable_adapter(priv); 1992 err = ipw2100_disable_adapter(priv);
@@ -2014,7 +1998,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
2014 * disable auto association -- so we cheat by setting a bogus SSID */ 1998 * disable auto association -- so we cheat by setting a bogus SSID */
2015 if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) { 1999 if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) {
2016 int i; 2000 int i;
2017 u8 *bogus = (u8*)cmd.host_command_parameters; 2001 u8 *bogus = (u8 *) cmd.host_command_parameters;
2018 for (i = 0; i < IW_ESSID_MAX_SIZE; i++) 2002 for (i = 0; i < IW_ESSID_MAX_SIZE; i++)
2019 bogus[i] = 0x18 + i; 2003 bogus[i] = 0x18 + i;
2020 cmd.host_command_length = IW_ESSID_MAX_SIZE; 2004 cmd.host_command_length = IW_ESSID_MAX_SIZE;
@@ -2025,8 +2009,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
2025 2009
2026 err = ipw2100_hw_send_command(priv, &cmd); 2010 err = ipw2100_hw_send_command(priv, &cmd);
2027 if (!err) { 2011 if (!err) {
2028 memset(priv->essid + ssid_len, 0, 2012 memset(priv->essid + ssid_len, 0, IW_ESSID_MAX_SIZE - ssid_len);
2029 IW_ESSID_MAX_SIZE - ssid_len);
2030 memcpy(priv->essid, essid, ssid_len); 2013 memcpy(priv->essid, essid, ssid_len);
2031 priv->essid_len = ssid_len; 2014 priv->essid_len = ssid_len;
2032 } 2015 }
@@ -2071,14 +2054,14 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
2071static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) 2054static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
2072{ 2055{
2073 IPW_DEBUG_INFO("%s: RF Kill state changed to radio OFF.\n", 2056 IPW_DEBUG_INFO("%s: RF Kill state changed to radio OFF.\n",
2074 priv->net_dev->name); 2057 priv->net_dev->name);
2075 2058
2076 /* RF_KILL is now enabled (else we wouldn't be here) */ 2059 /* RF_KILL is now enabled (else we wouldn't be here) */
2077 priv->status |= STATUS_RF_KILL_HW; 2060 priv->status |= STATUS_RF_KILL_HW;
2078 2061
2079#ifdef ACPI_CSTATE_LIMIT_DEFINED 2062#ifdef ACPI_CSTATE_LIMIT_DEFINED
2080 if (priv->config & CFG_C3_DISABLED) { 2063 if (priv->config & CFG_C3_DISABLED) {
2081 IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n"); 2064 IPW_DEBUG_INFO(": Resetting C3 transitions.\n");
2082 acpi_set_cstate_limit(priv->cstate_limit); 2065 acpi_set_cstate_limit(priv->cstate_limit);
2083 priv->config &= ~CFG_C3_DISABLED; 2066 priv->config &= ~CFG_C3_DISABLED;
2084 } 2067 }
@@ -2102,16 +2085,16 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
2102#define IPW2100_HANDLER(v, f) { v, f, # v } 2085#define IPW2100_HANDLER(v, f) { v, f, # v }
2103struct ipw2100_status_indicator { 2086struct ipw2100_status_indicator {
2104 int status; 2087 int status;
2105 void (*cb)(struct ipw2100_priv *priv, u32 status); 2088 void (*cb) (struct ipw2100_priv * priv, u32 status);
2106 char *name; 2089 char *name;
2107}; 2090};
2108#else 2091#else
2109#define IPW2100_HANDLER(v, f) { v, f } 2092#define IPW2100_HANDLER(v, f) { v, f }
2110struct ipw2100_status_indicator { 2093struct ipw2100_status_indicator {
2111 int status; 2094 int status;
2112 void (*cb)(struct ipw2100_priv *priv, u32 status); 2095 void (*cb) (struct ipw2100_priv * priv, u32 status);
2113}; 2096};
2114#endif /* CONFIG_IPW_DEBUG */ 2097#endif /* CONFIG_IPW_DEBUG */
2115 2098
2116static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status) 2099static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status)
2117{ 2100{
@@ -2135,7 +2118,6 @@ static const struct ipw2100_status_indicator status_handlers[] = {
2135 IPW2100_HANDLER(-1, NULL) 2118 IPW2100_HANDLER(-1, NULL)
2136}; 2119};
2137 2120
2138
2139static void isr_status_change(struct ipw2100_priv *priv, int status) 2121static void isr_status_change(struct ipw2100_priv *priv, int status)
2140{ 2122{
2141 int i; 2123 int i;
@@ -2153,7 +2135,7 @@ static void isr_status_change(struct ipw2100_priv *priv, int status)
2153 for (i = 0; status_handlers[i].status != -1; i++) { 2135 for (i = 0; status_handlers[i].status != -1; i++) {
2154 if (status == status_handlers[i].status) { 2136 if (status == status_handlers[i].status) {
2155 IPW_DEBUG_NOTIF("Status change: %s\n", 2137 IPW_DEBUG_NOTIF("Status change: %s\n",
2156 status_handlers[i].name); 2138 status_handlers[i].name);
2157 if (status_handlers[i].cb) 2139 if (status_handlers[i].cb)
2158 status_handlers[i].cb(priv, status); 2140 status_handlers[i].cb(priv, status);
2159 priv->wstats.status = status; 2141 priv->wstats.status = status;
@@ -2164,9 +2146,8 @@ static void isr_status_change(struct ipw2100_priv *priv, int status)
2164 IPW_DEBUG_NOTIF("unknown status received: %04x\n", status); 2146 IPW_DEBUG_NOTIF("unknown status received: %04x\n", status);
2165} 2147}
2166 2148
2167static void isr_rx_complete_command( 2149static void isr_rx_complete_command(struct ipw2100_priv *priv,
2168 struct ipw2100_priv *priv, 2150 struct ipw2100_cmd_header *cmd)
2169 struct ipw2100_cmd_header *cmd)
2170{ 2151{
2171#ifdef CONFIG_IPW_DEBUG 2152#ifdef CONFIG_IPW_DEBUG
2172 if (cmd->host_command_reg < ARRAY_SIZE(command_types)) { 2153 if (cmd->host_command_reg < ARRAY_SIZE(command_types)) {
@@ -2196,10 +2177,8 @@ static const char *frame_types[] = {
2196}; 2177};
2197#endif 2178#endif
2198 2179
2199 2180static inline int ipw2100_alloc_skb(struct ipw2100_priv *priv,
2200static inline int ipw2100_alloc_skb( 2181 struct ipw2100_rx_packet *packet)
2201 struct ipw2100_priv *priv,
2202 struct ipw2100_rx_packet *packet)
2203{ 2182{
2204 packet->skb = dev_alloc_skb(sizeof(struct ipw2100_rx)); 2183 packet->skb = dev_alloc_skb(sizeof(struct ipw2100_rx));
2205 if (!packet->skb) 2184 if (!packet->skb)
@@ -2215,7 +2194,6 @@ static inline int ipw2100_alloc_skb(
2215 return 0; 2194 return 0;
2216} 2195}
2217 2196
2218
2219#define SEARCH_ERROR 0xffffffff 2197#define SEARCH_ERROR 0xffffffff
2220#define SEARCH_FAIL 0xfffffffe 2198#define SEARCH_FAIL 0xfffffffe
2221#define SEARCH_SUCCESS 0xfffffff0 2199#define SEARCH_SUCCESS 0xfffffff0
@@ -2229,10 +2207,10 @@ static inline int ipw2100_snapshot_alloc(struct ipw2100_priv *priv)
2229 if (priv->snapshot[0]) 2207 if (priv->snapshot[0])
2230 return 1; 2208 return 1;
2231 for (i = 0; i < 0x30; i++) { 2209 for (i = 0; i < 0x30; i++) {
2232 priv->snapshot[i] = (u8*)kmalloc(0x1000, GFP_ATOMIC); 2210 priv->snapshot[i] = (u8 *) kmalloc(0x1000, GFP_ATOMIC);
2233 if (!priv->snapshot[i]) { 2211 if (!priv->snapshot[i]) {
2234 IPW_DEBUG_INFO("%s: Error allocating snapshot " 2212 IPW_DEBUG_INFO("%s: Error allocating snapshot "
2235 "buffer %d\n", priv->net_dev->name, i); 2213 "buffer %d\n", priv->net_dev->name, i);
2236 while (i > 0) 2214 while (i > 0)
2237 kfree(priv->snapshot[--i]); 2215 kfree(priv->snapshot[--i]);
2238 priv->snapshot[0] = NULL; 2216 priv->snapshot[0] = NULL;
@@ -2253,7 +2231,7 @@ static inline void ipw2100_snapshot_free(struct ipw2100_priv *priv)
2253 priv->snapshot[0] = NULL; 2231 priv->snapshot[0] = NULL;
2254} 2232}
2255 2233
2256static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf, 2234static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 * in_buf,
2257 size_t len, int mode) 2235 size_t len, int mode)
2258{ 2236{
2259 u32 i, j; 2237 u32 i, j;
@@ -2270,9 +2248,9 @@ static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf,
2270 for (ret = SEARCH_FAIL, i = 0; i < 0x30000; i += 4) { 2248 for (ret = SEARCH_FAIL, i = 0; i < 0x30000; i += 4) {
2271 read_nic_dword(priv->net_dev, i, &tmp); 2249 read_nic_dword(priv->net_dev, i, &tmp);
2272 if (mode == SEARCH_SNAPSHOT) 2250 if (mode == SEARCH_SNAPSHOT)
2273 *(u32 *)SNAPSHOT_ADDR(i) = tmp; 2251 *(u32 *) SNAPSHOT_ADDR(i) = tmp;
2274 if (ret == SEARCH_FAIL) { 2252 if (ret == SEARCH_FAIL) {
2275 d = (u8*)&tmp; 2253 d = (u8 *) & tmp;
2276 for (j = 0; j < 4; j++) { 2254 for (j = 0; j < 4; j++) {
2277 if (*s != *d) { 2255 if (*s != *d) {
2278 s = in_buf; 2256 s = in_buf;
@@ -2310,8 +2288,7 @@ static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf,
2310static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH]; 2288static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH];
2311#endif 2289#endif
2312 2290
2313static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, 2291static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
2314 int i)
2315{ 2292{
2316#ifdef CONFIG_IPW_DEBUG_C3 2293#ifdef CONFIG_IPW_DEBUG_C3
2317 struct ipw2100_status *status = &priv->status_queue.drv[i]; 2294 struct ipw2100_status *status = &priv->status_queue.drv[i];
@@ -2322,11 +2299,11 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv,
2322 int limit; 2299 int limit;
2323#endif 2300#endif
2324 2301
2325 IPW_DEBUG_INFO(DRV_NAME ": PCI latency error detected at " 2302 IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n",
2326 "0x%04zX.\n", i * sizeof(struct ipw2100_status)); 2303 i * sizeof(struct ipw2100_status));
2327 2304
2328#ifdef ACPI_CSTATE_LIMIT_DEFINED 2305#ifdef ACPI_CSTATE_LIMIT_DEFINED
2329 IPW_DEBUG_INFO(DRV_NAME ": Disabling C3 transitions.\n"); 2306 IPW_DEBUG_INFO(": Disabling C3 transitions.\n");
2330 limit = acpi_get_cstate_limit(); 2307 limit = acpi_get_cstate_limit();
2331 if (limit > 2) { 2308 if (limit > 2) {
2332 priv->cstate_limit = limit; 2309 priv->cstate_limit = limit;
@@ -2346,9 +2323,9 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv,
2346 2323
2347 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) 2324 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
2348 break; 2325 break;
2349 } while (j--); 2326 } while (j--);
2350 2327
2351 match = ipw2100_match_buf(priv, (u8*)status, 2328 match = ipw2100_match_buf(priv, (u8 *) status,
2352 sizeof(struct ipw2100_status), 2329 sizeof(struct ipw2100_status),
2353 SEARCH_SNAPSHOT); 2330 SEARCH_SNAPSHOT);
2354 if (match < SEARCH_SUCCESS) 2331 if (match < SEARCH_SUCCESS)
@@ -2360,7 +2337,7 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv,
2360 IPW_DEBUG_INFO("%s: No DMA status match in " 2337 IPW_DEBUG_INFO("%s: No DMA status match in "
2361 "Firmware.\n", priv->net_dev->name); 2338 "Firmware.\n", priv->net_dev->name);
2362 2339
2363 printk_buf((u8*)priv->status_queue.drv, 2340 printk_buf((u8 *) priv->status_queue.drv,
2364 sizeof(struct ipw2100_status) * RX_QUEUE_LENGTH); 2341 sizeof(struct ipw2100_status) * RX_QUEUE_LENGTH);
2365#endif 2342#endif
2366 2343
@@ -2392,26 +2369,26 @@ static inline void isr_rx(struct ipw2100_priv *priv, int i,
2392 IPW_DEBUG_DROP("Dropping packet while interface is not up.\n"); 2369 IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
2393 return; 2370 return;
2394 } 2371 }
2395 2372#ifdef CONFIG_IPW2100_MONITOR
2396 if (unlikely(priv->ieee->iw_mode == IW_MODE_MONITOR && 2373 if (unlikely(priv->ieee->iw_mode == IW_MODE_MONITOR &&
2374 priv->config & CFG_CRC_CHECK &&
2397 status->flags & IPW_STATUS_FLAG_CRC_ERROR)) { 2375 status->flags & IPW_STATUS_FLAG_CRC_ERROR)) {
2398 IPW_DEBUG_RX("CRC error in packet. Dropping.\n"); 2376 IPW_DEBUG_RX("CRC error in packet. Dropping.\n");
2399 priv->ieee->stats.rx_errors++; 2377 priv->ieee->stats.rx_errors++;
2400 return; 2378 return;
2401 } 2379 }
2380#endif
2402 2381
2403 if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR && 2382 if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR &&
2404 !(priv->status & STATUS_ASSOCIATED))) { 2383 !(priv->status & STATUS_ASSOCIATED))) {
2405 IPW_DEBUG_DROP("Dropping packet while not associated.\n"); 2384 IPW_DEBUG_DROP("Dropping packet while not associated.\n");
2406 priv->wstats.discard.misc++; 2385 priv->wstats.discard.misc++;
2407 return; 2386 return;
2408 } 2387 }
2409 2388
2410
2411 pci_unmap_single(priv->pci_dev, 2389 pci_unmap_single(priv->pci_dev,
2412 packet->dma_addr, 2390 packet->dma_addr,
2413 sizeof(struct ipw2100_rx), 2391 sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE);
2414 PCI_DMA_FROMDEVICE);
2415 2392
2416 skb_put(packet->skb, status->frame_size); 2393 skb_put(packet->skb, status->frame_size);
2417 2394
@@ -2438,8 +2415,8 @@ static inline void isr_rx(struct ipw2100_priv *priv, int i,
2438 /* We need to allocate a new SKB and attach it to the RDB. */ 2415 /* We need to allocate a new SKB and attach it to the RDB. */
2439 if (unlikely(ipw2100_alloc_skb(priv, packet))) { 2416 if (unlikely(ipw2100_alloc_skb(priv, packet))) {
2440 printk(KERN_WARNING DRV_NAME ": " 2417 printk(KERN_WARNING DRV_NAME ": "
2441 "%s: Unable to allocate SKB onto RBD ring - disabling " 2418 "%s: Unable to allocate SKB onto RBD ring - disabling "
2442 "adapter.\n", priv->net_dev->name); 2419 "adapter.\n", priv->net_dev->name);
2443 /* TODO: schedule adapter shutdown */ 2420 /* TODO: schedule adapter shutdown */
2444 IPW_DEBUG_INFO("TODO: Shutdown adapter...\n"); 2421 IPW_DEBUG_INFO("TODO: Shutdown adapter...\n");
2445 } 2422 }
@@ -2534,11 +2511,11 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2534 2511
2535 /* Sync the DMA for the STATUS buffer so CPU is sure to get 2512 /* Sync the DMA for the STATUS buffer so CPU is sure to get
2536 * the correct values */ 2513 * the correct values */
2537 pci_dma_sync_single_for_cpu( 2514 pci_dma_sync_single_for_cpu(priv->pci_dev,
2538 priv->pci_dev, 2515 sq->nic +
2539 sq->nic + sizeof(struct ipw2100_status) * i, 2516 sizeof(struct ipw2100_status) * i,
2540 sizeof(struct ipw2100_status), 2517 sizeof(struct ipw2100_status),
2541 PCI_DMA_FROMDEVICE); 2518 PCI_DMA_FROMDEVICE);
2542 2519
2543 /* Sync the DMA for the RX buffer so CPU is sure to get 2520 /* Sync the DMA for the RX buffer so CPU is sure to get
2544 * the correct values */ 2521 * the correct values */
@@ -2552,8 +2529,7 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2552 } 2529 }
2553 2530
2554 u = packet->rxp; 2531 u = packet->rxp;
2555 frame_type = sq->drv[i].status_fields & 2532 frame_type = sq->drv[i].status_fields & STATUS_TYPE_MASK;
2556 STATUS_TYPE_MASK;
2557 stats.rssi = sq->drv[i].rssi + IPW2100_RSSI_TO_DBM; 2533 stats.rssi = sq->drv[i].rssi + IPW2100_RSSI_TO_DBM;
2558 stats.len = sq->drv[i].frame_size; 2534 stats.len = sq->drv[i].frame_size;
2559 2535
@@ -2562,16 +2538,14 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2562 stats.mask |= IEEE80211_STATMASK_RSSI; 2538 stats.mask |= IEEE80211_STATMASK_RSSI;
2563 stats.freq = IEEE80211_24GHZ_BAND; 2539 stats.freq = IEEE80211_24GHZ_BAND;
2564 2540
2565 IPW_DEBUG_RX( 2541 IPW_DEBUG_RX("%s: '%s' frame type received (%d).\n",
2566 "%s: '%s' frame type received (%d).\n", 2542 priv->net_dev->name, frame_types[frame_type],
2567 priv->net_dev->name, frame_types[frame_type], 2543 stats.len);
2568 stats.len);
2569 2544
2570 switch (frame_type) { 2545 switch (frame_type) {
2571 case COMMAND_STATUS_VAL: 2546 case COMMAND_STATUS_VAL:
2572 /* Reset Rx watchdog */ 2547 /* Reset Rx watchdog */
2573 isr_rx_complete_command( 2548 isr_rx_complete_command(priv, &u->rx_data.command);
2574 priv, &u->rx_data.command);
2575 break; 2549 break;
2576 2550
2577 case STATUS_CHANGE_VAL: 2551 case STATUS_CHANGE_VAL:
@@ -2588,12 +2562,10 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2588#endif 2562#endif
2589 if (stats.len < sizeof(u->rx_data.header)) 2563 if (stats.len < sizeof(u->rx_data.header))
2590 break; 2564 break;
2591 switch (WLAN_FC_GET_TYPE(u->rx_data.header. 2565 switch (WLAN_FC_GET_TYPE(u->rx_data.header.frame_ctl)) {
2592 frame_ctl)) {
2593 case IEEE80211_FTYPE_MGMT: 2566 case IEEE80211_FTYPE_MGMT:
2594 ieee80211_rx_mgt(priv->ieee, 2567 ieee80211_rx_mgt(priv->ieee,
2595 &u->rx_data.header, 2568 &u->rx_data.header, &stats);
2596 &stats);
2597 break; 2569 break;
2598 2570
2599 case IEEE80211_FTYPE_CTL: 2571 case IEEE80211_FTYPE_CTL:
@@ -2607,7 +2579,7 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2607 break; 2579 break;
2608 } 2580 }
2609 2581
2610 increment: 2582 increment:
2611 /* clear status field associated with this RBD */ 2583 /* clear status field associated with this RBD */
2612 rxq->drv[i].status.info.field = 0; 2584 rxq->drv[i].status.info.field = 0;
2613 2585
@@ -2619,12 +2591,10 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2619 rxq->next = (i ? i : rxq->entries) - 1; 2591 rxq->next = (i ? i : rxq->entries) - 1;
2620 2592
2621 write_register(priv->net_dev, 2593 write_register(priv->net_dev,
2622 IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, 2594 IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, rxq->next);
2623 rxq->next);
2624 } 2595 }
2625} 2596}
2626 2597
2627
2628/* 2598/*
2629 * __ipw2100_tx_process 2599 * __ipw2100_tx_process
2630 * 2600 *
@@ -2667,7 +2637,7 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv)
2667static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) 2637static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2668{ 2638{
2669 struct ipw2100_bd_queue *txq = &priv->tx_queue; 2639 struct ipw2100_bd_queue *txq = &priv->tx_queue;
2670 struct ipw2100_bd *tbd; 2640 struct ipw2100_bd *tbd;
2671 struct list_head *element; 2641 struct list_head *element;
2672 struct ipw2100_tx_packet *packet; 2642 struct ipw2100_tx_packet *packet;
2673 int descriptors_used; 2643 int descriptors_used;
@@ -2680,7 +2650,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2680 element = priv->fw_pend_list.next; 2650 element = priv->fw_pend_list.next;
2681 2651
2682 packet = list_entry(element, struct ipw2100_tx_packet, list); 2652 packet = list_entry(element, struct ipw2100_tx_packet, list);
2683 tbd = &txq->drv[packet->index]; 2653 tbd = &txq->drv[packet->index];
2684 2654
2685 /* Determine how many TBD entries must be finished... */ 2655 /* Determine how many TBD entries must be finished... */
2686 switch (packet->type) { 2656 switch (packet->type) {
@@ -2693,14 +2663,14 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2693 case DATA: 2663 case DATA:
2694 /* DATA uses two slots; advance and loop position. */ 2664 /* DATA uses two slots; advance and loop position. */
2695 descriptors_used = tbd->num_fragments; 2665 descriptors_used = tbd->num_fragments;
2696 frag_num = tbd->num_fragments - 1; 2666 frag_num = tbd->num_fragments - 1;
2697 e = txq->oldest + frag_num; 2667 e = txq->oldest + frag_num;
2698 e %= txq->entries; 2668 e %= txq->entries;
2699 break; 2669 break;
2700 2670
2701 default: 2671 default:
2702 printk(KERN_WARNING DRV_NAME ": %s: Bad fw_pend_list entry!\n", 2672 printk(KERN_WARNING DRV_NAME ": %s: Bad fw_pend_list entry!\n",
2703 priv->net_dev->name); 2673 priv->net_dev->name);
2704 return 0; 2674 return 0;
2705 } 2675 }
2706 2676
@@ -2716,13 +2686,12 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2716 printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n", 2686 printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n",
2717 priv->net_dev->name); 2687 priv->net_dev->name);
2718 2688
2719 /* 2689 /*
2720 * txq->next is the index of the last packet written txq->oldest is 2690 * txq->next is the index of the last packet written txq->oldest is
2721 * the index of the r is the index of the next packet to be read by 2691 * the index of the r is the index of the next packet to be read by
2722 * firmware 2692 * firmware
2723 */ 2693 */
2724 2694
2725
2726 /* 2695 /*
2727 * Quick graphic to help you visualize the following 2696 * Quick graphic to help you visualize the following
2728 * if / else statement 2697 * if / else statement
@@ -2750,23 +2719,20 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2750#ifdef CONFIG_IPW_DEBUG 2719#ifdef CONFIG_IPW_DEBUG
2751 { 2720 {
2752 int i = txq->oldest; 2721 int i = txq->oldest;
2753 IPW_DEBUG_TX( 2722 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i,
2754 "TX%d V=%p P=%04X T=%04X L=%d\n", i, 2723 &txq->drv[i],
2755 &txq->drv[i], 2724 (u32) (txq->nic + i * sizeof(struct ipw2100_bd)),
2756 (u32)(txq->nic + i * sizeof(struct ipw2100_bd)), 2725 txq->drv[i].host_addr, txq->drv[i].buf_length);
2757 txq->drv[i].host_addr,
2758 txq->drv[i].buf_length);
2759 2726
2760 if (packet->type == DATA) { 2727 if (packet->type == DATA) {
2761 i = (i + 1) % txq->entries; 2728 i = (i + 1) % txq->entries;
2762 2729
2763 IPW_DEBUG_TX( 2730 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i,
2764 "TX%d V=%p P=%04X T=%04X L=%d\n", i, 2731 &txq->drv[i],
2765 &txq->drv[i], 2732 (u32) (txq->nic + i *
2766 (u32)(txq->nic + i * 2733 sizeof(struct ipw2100_bd)),
2767 sizeof(struct ipw2100_bd)), 2734 (u32) txq->drv[i].host_addr,
2768 (u32)txq->drv[i].host_addr, 2735 txq->drv[i].buf_length);
2769 txq->drv[i].buf_length);
2770 } 2736 }
2771 } 2737 }
2772#endif 2738#endif
@@ -2780,23 +2746,18 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2780 priv->net_dev->name, txq->oldest, packet->index); 2746 priv->net_dev->name, txq->oldest, packet->index);
2781 2747
2782 /* DATA packet; we have to unmap and free the SKB */ 2748 /* DATA packet; we have to unmap and free the SKB */
2783 priv->ieee->stats.tx_packets++;
2784 for (i = 0; i < frag_num; i++) { 2749 for (i = 0; i < frag_num; i++) {
2785 tbd = &txq->drv[(packet->index + 1 + i) % 2750 tbd = &txq->drv[(packet->index + 1 + i) % txq->entries];
2786 txq->entries];
2787 2751
2788 IPW_DEBUG_TX( 2752 IPW_DEBUG_TX("TX%d P=%08x L=%d\n",
2789 "TX%d P=%08x L=%d\n", 2753 (packet->index + 1 + i) % txq->entries,
2790 (packet->index + 1 + i) % txq->entries, 2754 tbd->host_addr, tbd->buf_length);
2791 tbd->host_addr, tbd->buf_length);
2792 2755
2793 pci_unmap_single(priv->pci_dev, 2756 pci_unmap_single(priv->pci_dev,
2794 tbd->host_addr, 2757 tbd->host_addr,
2795 tbd->buf_length, 2758 tbd->buf_length, PCI_DMA_TODEVICE);
2796 PCI_DMA_TODEVICE);
2797 } 2759 }
2798 2760
2799 priv->ieee->stats.tx_bytes += packet->info.d_struct.txb->payload_size;
2800 ieee80211_txb_free(packet->info.d_struct.txb); 2761 ieee80211_txb_free(packet->info.d_struct.txb);
2801 packet->info.d_struct.txb = NULL; 2762 packet->info.d_struct.txb = NULL;
2802 2763
@@ -2805,13 +2766,8 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2805 2766
2806 /* We have a free slot in the Tx queue, so wake up the 2767 /* We have a free slot in the Tx queue, so wake up the
2807 * transmit layer if it is stopped. */ 2768 * transmit layer if it is stopped. */
2808 if (priv->status & STATUS_ASSOCIATED && 2769 if (priv->status & STATUS_ASSOCIATED)
2809 netif_queue_stopped(priv->net_dev)) {
2810 IPW_DEBUG_INFO(KERN_INFO
2811 "%s: Waking net queue.\n",
2812 priv->net_dev->name);
2813 netif_wake_queue(priv->net_dev); 2770 netif_wake_queue(priv->net_dev);
2814 }
2815 2771
2816 /* A packet was processed by the hardware, so update the 2772 /* A packet was processed by the hardware, so update the
2817 * watchdog */ 2773 * watchdog */
@@ -2829,11 +2785,12 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2829#ifdef CONFIG_IPW_DEBUG 2785#ifdef CONFIG_IPW_DEBUG
2830 if (packet->info.c_struct.cmd->host_command_reg < 2786 if (packet->info.c_struct.cmd->host_command_reg <
2831 sizeof(command_types) / sizeof(*command_types)) 2787 sizeof(command_types) / sizeof(*command_types))
2832 IPW_DEBUG_TX( 2788 IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n",
2833 "Command '%s (%d)' processed: %d.\n", 2789 command_types[packet->info.c_struct.cmd->
2834 command_types[packet->info.c_struct.cmd->host_command_reg], 2790 host_command_reg],
2835 packet->info.c_struct.cmd->host_command_reg, 2791 packet->info.c_struct.cmd->
2836 packet->info.c_struct.cmd->cmd_status_reg); 2792 host_command_reg,
2793 packet->info.c_struct.cmd->cmd_status_reg);
2837#endif 2794#endif
2838 2795
2839 list_add_tail(element, &priv->msg_free_list); 2796 list_add_tail(element, &priv->msg_free_list);
@@ -2848,17 +2805,17 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2848 SET_STAT(&priv->txq_stat, txq->available); 2805 SET_STAT(&priv->txq_stat, txq->available);
2849 2806
2850 IPW_DEBUG_TX("packet latency (send to process) %ld jiffies\n", 2807 IPW_DEBUG_TX("packet latency (send to process) %ld jiffies\n",
2851 jiffies - packet->jiffy_start); 2808 jiffies - packet->jiffy_start);
2852 2809
2853 return (!list_empty(&priv->fw_pend_list)); 2810 return (!list_empty(&priv->fw_pend_list));
2854} 2811}
2855 2812
2856
2857static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv) 2813static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv)
2858{ 2814{
2859 int i = 0; 2815 int i = 0;
2860 2816
2861 while (__ipw2100_tx_process(priv) && i < 200) i++; 2817 while (__ipw2100_tx_process(priv) && i < 200)
2818 i++;
2862 2819
2863 if (i == 200) { 2820 if (i == 200) {
2864 printk(KERN_WARNING DRV_NAME ": " 2821 printk(KERN_WARNING DRV_NAME ": "
@@ -2867,7 +2824,6 @@ static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv)
2867 } 2824 }
2868} 2825}
2869 2826
2870
2871static void ipw2100_tx_send_commands(struct ipw2100_priv *priv) 2827static void ipw2100_tx_send_commands(struct ipw2100_priv *priv)
2872{ 2828{
2873 struct list_head *element; 2829 struct list_head *element;
@@ -2892,13 +2848,12 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv)
2892 list_del(element); 2848 list_del(element);
2893 DEC_STAT(&priv->msg_pend_stat); 2849 DEC_STAT(&priv->msg_pend_stat);
2894 2850
2895 packet = list_entry(element, 2851 packet = list_entry(element, struct ipw2100_tx_packet, list);
2896 struct ipw2100_tx_packet, list);
2897 2852
2898 IPW_DEBUG_TX("using TBD at virt=%p, phys=%p\n", 2853 IPW_DEBUG_TX("using TBD at virt=%p, phys=%p\n",
2899 &txq->drv[txq->next], 2854 &txq->drv[txq->next],
2900 (void*)(txq->nic + txq->next * 2855 (void *)(txq->nic + txq->next *
2901 sizeof(struct ipw2100_bd))); 2856 sizeof(struct ipw2100_bd)));
2902 2857
2903 packet->index = txq->next; 2858 packet->index = txq->next;
2904 2859
@@ -2911,8 +2866,8 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv)
2911 * with f/w debug version */ 2866 * with f/w debug version */
2912 tbd->num_fragments = 1; 2867 tbd->num_fragments = 1;
2913 tbd->status.info.field = 2868 tbd->status.info.field =
2914 IPW_BD_STATUS_TX_FRAME_COMMAND | 2869 IPW_BD_STATUS_TX_FRAME_COMMAND |
2915 IPW_BD_STATUS_TX_INTERRUPT_ENABLE; 2870 IPW_BD_STATUS_TX_INTERRUPT_ENABLE;
2916 2871
2917 /* update TBD queue counters */ 2872 /* update TBD queue counters */
2918 txq->next++; 2873 txq->next++;
@@ -2934,7 +2889,6 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv)
2934 } 2889 }
2935} 2890}
2936 2891
2937
2938/* 2892/*
2939 * ipw2100_tx_send_data 2893 * ipw2100_tx_send_data
2940 * 2894 *
@@ -2946,7 +2900,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2946 struct ipw2100_bd_queue *txq = &priv->tx_queue; 2900 struct ipw2100_bd_queue *txq = &priv->tx_queue;
2947 struct ipw2100_bd *tbd; 2901 struct ipw2100_bd *tbd;
2948 int next = txq->next; 2902 int next = txq->next;
2949 int i = 0; 2903 int i = 0;
2950 struct ipw2100_data_header *ipw_hdr; 2904 struct ipw2100_data_header *ipw_hdr;
2951 struct ieee80211_hdr_3addr *hdr; 2905 struct ieee80211_hdr_3addr *hdr;
2952 2906
@@ -2958,20 +2912,18 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2958 * maintained between the r and w indexes 2912 * maintained between the r and w indexes
2959 */ 2913 */
2960 element = priv->tx_pend_list.next; 2914 element = priv->tx_pend_list.next;
2961 packet = list_entry(element, struct ipw2100_tx_packet, list); 2915 packet = list_entry(element, struct ipw2100_tx_packet, list);
2962 2916
2963 if (unlikely(1 + packet->info.d_struct.txb->nr_frags > 2917 if (unlikely(1 + packet->info.d_struct.txb->nr_frags >
2964 IPW_MAX_BDS)) { 2918 IPW_MAX_BDS)) {
2965 /* TODO: Support merging buffers if more than 2919 /* TODO: Support merging buffers if more than
2966 * IPW_MAX_BDS are used */ 2920 * IPW_MAX_BDS are used */
2967 IPW_DEBUG_INFO( 2921 IPW_DEBUG_INFO("%s: Maximum BD theshold exceeded. "
2968 "%s: Maximum BD theshold exceeded. " 2922 "Increase fragmentation level.\n",
2969 "Increase fragmentation level.\n", 2923 priv->net_dev->name);
2970 priv->net_dev->name);
2971 } 2924 }
2972 2925
2973 if (txq->available <= 3 + 2926 if (txq->available <= 3 + packet->info.d_struct.txb->nr_frags) {
2974 packet->info.d_struct.txb->nr_frags) {
2975 IPW_DEBUG_TX("no room in tx_queue\n"); 2927 IPW_DEBUG_TX("no room in tx_queue\n");
2976 break; 2928 break;
2977 } 2929 }
@@ -2985,7 +2937,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2985 2937
2986 ipw_hdr = packet->info.d_struct.data; 2938 ipw_hdr = packet->info.d_struct.data;
2987 hdr = (struct ieee80211_hdr_3addr *)packet->info.d_struct.txb-> 2939 hdr = (struct ieee80211_hdr_3addr *)packet->info.d_struct.txb->
2988 fragments[0]->data; 2940 fragments[0]->data;
2989 2941
2990 if (priv->ieee->iw_mode == IW_MODE_INFRA) { 2942 if (priv->ieee->iw_mode == IW_MODE_INFRA) {
2991 /* To DS: Addr1 = BSSID, Addr2 = SA, 2943 /* To DS: Addr1 = BSSID, Addr2 = SA,
@@ -3007,7 +2959,8 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3007 ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted; 2959 ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted;
3008 if (packet->info.d_struct.txb->nr_frags > 1) 2960 if (packet->info.d_struct.txb->nr_frags > 1)
3009 ipw_hdr->fragment_size = 2961 ipw_hdr->fragment_size =
3010 packet->info.d_struct.txb->frag_size - IEEE80211_3ADDR_LEN; 2962 packet->info.d_struct.txb->frag_size -
2963 IEEE80211_3ADDR_LEN;
3011 else 2964 else
3012 ipw_hdr->fragment_size = 0; 2965 ipw_hdr->fragment_size = 0;
3013 2966
@@ -3015,54 +2968,53 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3015 tbd->buf_length = sizeof(struct ipw2100_data_header); 2968 tbd->buf_length = sizeof(struct ipw2100_data_header);
3016 tbd->num_fragments = 1 + packet->info.d_struct.txb->nr_frags; 2969 tbd->num_fragments = 1 + packet->info.d_struct.txb->nr_frags;
3017 tbd->status.info.field = 2970 tbd->status.info.field =
3018 IPW_BD_STATUS_TX_FRAME_802_3 | 2971 IPW_BD_STATUS_TX_FRAME_802_3 |
3019 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; 2972 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT;
3020 txq->next++; 2973 txq->next++;
3021 txq->next %= txq->entries; 2974 txq->next %= txq->entries;
3022 2975
3023 IPW_DEBUG_TX( 2976 IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n",
3024 "data header tbd TX%d P=%08x L=%d\n", 2977 packet->index, tbd->host_addr, tbd->buf_length);
3025 packet->index, tbd->host_addr,
3026 tbd->buf_length);
3027#ifdef CONFIG_IPW_DEBUG 2978#ifdef CONFIG_IPW_DEBUG
3028 if (packet->info.d_struct.txb->nr_frags > 1) 2979 if (packet->info.d_struct.txb->nr_frags > 1)
3029 IPW_DEBUG_FRAG("fragment Tx: %d frames\n", 2980 IPW_DEBUG_FRAG("fragment Tx: %d frames\n",
3030 packet->info.d_struct.txb->nr_frags); 2981 packet->info.d_struct.txb->nr_frags);
3031#endif 2982#endif
3032 2983
3033 for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) { 2984 for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) {
3034 tbd = &txq->drv[txq->next]; 2985 tbd = &txq->drv[txq->next];
3035 if (i == packet->info.d_struct.txb->nr_frags - 1) 2986 if (i == packet->info.d_struct.txb->nr_frags - 1)
3036 tbd->status.info.field = 2987 tbd->status.info.field =
3037 IPW_BD_STATUS_TX_FRAME_802_3 | 2988 IPW_BD_STATUS_TX_FRAME_802_3 |
3038 IPW_BD_STATUS_TX_INTERRUPT_ENABLE; 2989 IPW_BD_STATUS_TX_INTERRUPT_ENABLE;
3039 else 2990 else
3040 tbd->status.info.field = 2991 tbd->status.info.field =
3041 IPW_BD_STATUS_TX_FRAME_802_3 | 2992 IPW_BD_STATUS_TX_FRAME_802_3 |
3042 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; 2993 IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT;
3043 2994
3044 tbd->buf_length = packet->info.d_struct.txb-> 2995 tbd->buf_length = packet->info.d_struct.txb->
3045 fragments[i]->len - IEEE80211_3ADDR_LEN; 2996 fragments[i]->len - IEEE80211_3ADDR_LEN;
3046 2997
3047 tbd->host_addr = pci_map_single( 2998 tbd->host_addr = pci_map_single(priv->pci_dev,
3048 priv->pci_dev, 2999 packet->info.d_struct.
3049 packet->info.d_struct.txb->fragments[i]->data + 3000 txb->fragments[i]->
3050 IEEE80211_3ADDR_LEN, 3001 data +
3051 tbd->buf_length, 3002 IEEE80211_3ADDR_LEN,
3052 PCI_DMA_TODEVICE); 3003 tbd->buf_length,
3004 PCI_DMA_TODEVICE);
3053 3005
3054 IPW_DEBUG_TX( 3006 IPW_DEBUG_TX("data frag tbd TX%d P=%08x L=%d\n",
3055 "data frag tbd TX%d P=%08x L=%d\n", 3007 txq->next, tbd->host_addr,
3056 txq->next, tbd->host_addr, tbd->buf_length); 3008 tbd->buf_length);
3057 3009
3058 pci_dma_sync_single_for_device( 3010 pci_dma_sync_single_for_device(priv->pci_dev,
3059 priv->pci_dev, tbd->host_addr, 3011 tbd->host_addr,
3060 tbd->buf_length, 3012 tbd->buf_length,
3061 PCI_DMA_TODEVICE); 3013 PCI_DMA_TODEVICE);
3062 3014
3063 txq->next++; 3015 txq->next++;
3064 txq->next %= txq->entries; 3016 txq->next %= txq->entries;
3065 } 3017 }
3066 3018
3067 txq->available -= 1 + packet->info.d_struct.txb->nr_frags; 3019 txq->available -= 1 + packet->info.d_struct.txb->nr_frags;
3068 SET_STAT(&priv->txq_stat, txq->available); 3020 SET_STAT(&priv->txq_stat, txq->available);
@@ -3078,7 +3030,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
3078 IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX, 3030 IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX,
3079 txq->next); 3031 txq->next);
3080 } 3032 }
3081 return; 3033 return;
3082} 3034}
3083 3035
3084static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) 3036static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
@@ -3106,11 +3058,9 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3106 3058
3107 if (inta & IPW2100_INTA_FATAL_ERROR) { 3059 if (inta & IPW2100_INTA_FATAL_ERROR) {
3108 printk(KERN_WARNING DRV_NAME 3060 printk(KERN_WARNING DRV_NAME
3109 ": Fatal interrupt. Scheduling firmware restart.\n"); 3061 ": Fatal interrupt. Scheduling firmware restart.\n");
3110 priv->inta_other++; 3062 priv->inta_other++;
3111 write_register( 3063 write_register(dev, IPW_REG_INTA, IPW2100_INTA_FATAL_ERROR);
3112 dev, IPW_REG_INTA,
3113 IPW2100_INTA_FATAL_ERROR);
3114 3064
3115 read_nic_dword(dev, IPW_NIC_FATAL_ERROR, &priv->fatal_error); 3065 read_nic_dword(dev, IPW_NIC_FATAL_ERROR, &priv->fatal_error);
3116 IPW_DEBUG_INFO("%s: Fatal error value: 0x%08X\n", 3066 IPW_DEBUG_INFO("%s: Fatal error value: 0x%08X\n",
@@ -3125,11 +3075,10 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3125 } 3075 }
3126 3076
3127 if (inta & IPW2100_INTA_PARITY_ERROR) { 3077 if (inta & IPW2100_INTA_PARITY_ERROR) {
3128 printk(KERN_ERR DRV_NAME ": ***** PARITY ERROR INTERRUPT !!!! \n"); 3078 printk(KERN_ERR DRV_NAME
3079 ": ***** PARITY ERROR INTERRUPT !!!! \n");
3129 priv->inta_other++; 3080 priv->inta_other++;
3130 write_register( 3081 write_register(dev, IPW_REG_INTA, IPW2100_INTA_PARITY_ERROR);
3131 dev, IPW_REG_INTA,
3132 IPW2100_INTA_PARITY_ERROR);
3133 } 3082 }
3134 3083
3135 if (inta & IPW2100_INTA_RX_TRANSFER) { 3084 if (inta & IPW2100_INTA_RX_TRANSFER) {
@@ -3137,9 +3086,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3137 3086
3138 priv->rx_interrupts++; 3087 priv->rx_interrupts++;
3139 3088
3140 write_register( 3089 write_register(dev, IPW_REG_INTA, IPW2100_INTA_RX_TRANSFER);
3141 dev, IPW_REG_INTA,
3142 IPW2100_INTA_RX_TRANSFER);
3143 3090
3144 __ipw2100_rx_process(priv); 3091 __ipw2100_rx_process(priv);
3145 __ipw2100_tx_complete(priv); 3092 __ipw2100_tx_complete(priv);
@@ -3150,8 +3097,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3150 3097
3151 priv->tx_interrupts++; 3098 priv->tx_interrupts++;
3152 3099
3153 write_register(dev, IPW_REG_INTA, 3100 write_register(dev, IPW_REG_INTA, IPW2100_INTA_TX_TRANSFER);
3154 IPW2100_INTA_TX_TRANSFER);
3155 3101
3156 __ipw2100_tx_complete(priv); 3102 __ipw2100_tx_complete(priv);
3157 ipw2100_tx_send_commands(priv); 3103 ipw2100_tx_send_commands(priv);
@@ -3161,9 +3107,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3161 if (inta & IPW2100_INTA_TX_COMPLETE) { 3107 if (inta & IPW2100_INTA_TX_COMPLETE) {
3162 IPW_DEBUG_ISR("TX complete\n"); 3108 IPW_DEBUG_ISR("TX complete\n");
3163 priv->inta_other++; 3109 priv->inta_other++;
3164 write_register( 3110 write_register(dev, IPW_REG_INTA, IPW2100_INTA_TX_COMPLETE);
3165 dev, IPW_REG_INTA,
3166 IPW2100_INTA_TX_COMPLETE);
3167 3111
3168 __ipw2100_tx_complete(priv); 3112 __ipw2100_tx_complete(priv);
3169 } 3113 }
@@ -3171,9 +3115,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3171 if (inta & IPW2100_INTA_EVENT_INTERRUPT) { 3115 if (inta & IPW2100_INTA_EVENT_INTERRUPT) {
3172 /* ipw2100_handle_event(dev); */ 3116 /* ipw2100_handle_event(dev); */
3173 priv->inta_other++; 3117 priv->inta_other++;
3174 write_register( 3118 write_register(dev, IPW_REG_INTA, IPW2100_INTA_EVENT_INTERRUPT);
3175 dev, IPW_REG_INTA,
3176 IPW2100_INTA_EVENT_INTERRUPT);
3177 } 3119 }
3178 3120
3179 if (inta & IPW2100_INTA_FW_INIT_DONE) { 3121 if (inta & IPW2100_INTA_FW_INIT_DONE) {
@@ -3183,30 +3125,25 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3183 read_register(dev, IPW_REG_INTA, &tmp); 3125 read_register(dev, IPW_REG_INTA, &tmp);
3184 if (tmp & (IPW2100_INTA_FATAL_ERROR | 3126 if (tmp & (IPW2100_INTA_FATAL_ERROR |
3185 IPW2100_INTA_PARITY_ERROR)) { 3127 IPW2100_INTA_PARITY_ERROR)) {
3186 write_register( 3128 write_register(dev, IPW_REG_INTA,
3187 dev, IPW_REG_INTA, 3129 IPW2100_INTA_FATAL_ERROR |
3188 IPW2100_INTA_FATAL_ERROR | 3130 IPW2100_INTA_PARITY_ERROR);
3189 IPW2100_INTA_PARITY_ERROR);
3190 } 3131 }
3191 3132
3192 write_register(dev, IPW_REG_INTA, 3133 write_register(dev, IPW_REG_INTA, IPW2100_INTA_FW_INIT_DONE);
3193 IPW2100_INTA_FW_INIT_DONE);
3194 } 3134 }
3195 3135
3196 if (inta & IPW2100_INTA_STATUS_CHANGE) { 3136 if (inta & IPW2100_INTA_STATUS_CHANGE) {
3197 IPW_DEBUG_ISR("Status change interrupt\n"); 3137 IPW_DEBUG_ISR("Status change interrupt\n");
3198 priv->inta_other++; 3138 priv->inta_other++;
3199 write_register( 3139 write_register(dev, IPW_REG_INTA, IPW2100_INTA_STATUS_CHANGE);
3200 dev, IPW_REG_INTA,
3201 IPW2100_INTA_STATUS_CHANGE);
3202 } 3140 }
3203 3141
3204 if (inta & IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE) { 3142 if (inta & IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE) {
3205 IPW_DEBUG_ISR("slave host mode interrupt\n"); 3143 IPW_DEBUG_ISR("slave host mode interrupt\n");
3206 priv->inta_other++; 3144 priv->inta_other++;
3207 write_register( 3145 write_register(dev, IPW_REG_INTA,
3208 dev, IPW_REG_INTA, 3146 IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE);
3209 IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE);
3210 } 3147 }
3211 3148
3212 priv->in_isr--; 3149 priv->in_isr--;
@@ -3217,9 +3154,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv)
3217 IPW_DEBUG_ISR("exit\n"); 3154 IPW_DEBUG_ISR("exit\n");
3218} 3155}
3219 3156
3220 3157static irqreturn_t ipw2100_interrupt(int irq, void *data, struct pt_regs *regs)
3221static irqreturn_t ipw2100_interrupt(int irq, void *data,
3222 struct pt_regs *regs)
3223{ 3158{
3224 struct ipw2100_priv *priv = data; 3159 struct ipw2100_priv *priv = data;
3225 u32 inta, inta_mask; 3160 u32 inta, inta_mask;
@@ -3227,7 +3162,7 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data,
3227 if (!data) 3162 if (!data)
3228 return IRQ_NONE; 3163 return IRQ_NONE;
3229 3164
3230 spin_lock(&priv->low_lock); 3165 spin_lock(&priv->low_lock);
3231 3166
3232 /* We check to see if we should be ignoring interrupts before 3167 /* We check to see if we should be ignoring interrupts before
3233 * we touch the hardware. During ucode load if we try and handle 3168 * we touch the hardware. During ucode load if we try and handle
@@ -3261,10 +3196,10 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data,
3261 ipw2100_disable_interrupts(priv); 3196 ipw2100_disable_interrupts(priv);
3262 3197
3263 tasklet_schedule(&priv->irq_tasklet); 3198 tasklet_schedule(&priv->irq_tasklet);
3264 spin_unlock(&priv->low_lock); 3199 spin_unlock(&priv->low_lock);
3265 3200
3266 return IRQ_HANDLED; 3201 return IRQ_HANDLED;
3267 none: 3202 none:
3268 spin_unlock(&priv->low_lock); 3203 spin_unlock(&priv->low_lock);
3269 return IRQ_NONE; 3204 return IRQ_NONE;
3270} 3205}
@@ -3294,10 +3229,8 @@ static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev,
3294 3229
3295 packet->info.d_struct.txb = txb; 3230 packet->info.d_struct.txb = txb;
3296 3231
3297 IPW_DEBUG_TX("Sending fragment (%d bytes):\n", 3232 IPW_DEBUG_TX("Sending fragment (%d bytes):\n", txb->fragments[0]->len);
3298 txb->fragments[0]->len); 3233 printk_buf(IPW_DL_TX, txb->fragments[0]->data, txb->fragments[0]->len);
3299 printk_buf(IPW_DL_TX, txb->fragments[0]->data,
3300 txb->fragments[0]->len);
3301 3234
3302 packet->jiffy_start = jiffies; 3235 packet->jiffy_start = jiffies;
3303 3236
@@ -3312,22 +3245,23 @@ static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev,
3312 spin_unlock_irqrestore(&priv->low_lock, flags); 3245 spin_unlock_irqrestore(&priv->low_lock, flags);
3313 return 0; 3246 return 0;
3314 3247
3315 fail_unlock: 3248 fail_unlock:
3316 netif_stop_queue(dev); 3249 netif_stop_queue(dev);
3317 spin_unlock_irqrestore(&priv->low_lock, flags); 3250 spin_unlock_irqrestore(&priv->low_lock, flags);
3318 return 1; 3251 return 1;
3319} 3252}
3320 3253
3321
3322static int ipw2100_msg_allocate(struct ipw2100_priv *priv) 3254static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3323{ 3255{
3324 int i, j, err = -EINVAL; 3256 int i, j, err = -EINVAL;
3325 void *v; 3257 void *v;
3326 dma_addr_t p; 3258 dma_addr_t p;
3327 3259
3328 priv->msg_buffers = (struct ipw2100_tx_packet *)kmalloc( 3260 priv->msg_buffers =
3329 IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), 3261 (struct ipw2100_tx_packet *)kmalloc(IPW_COMMAND_POOL_SIZE *
3330 GFP_KERNEL); 3262 sizeof(struct
3263 ipw2100_tx_packet),
3264 GFP_KERNEL);
3331 if (!priv->msg_buffers) { 3265 if (!priv->msg_buffers) {
3332 printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg " 3266 printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg "
3333 "buffers.\n", priv->net_dev->name); 3267 "buffers.\n", priv->net_dev->name);
@@ -3335,15 +3269,12 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3335 } 3269 }
3336 3270
3337 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) { 3271 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3338 v = pci_alloc_consistent( 3272 v = pci_alloc_consistent(priv->pci_dev,
3339 priv->pci_dev, 3273 sizeof(struct ipw2100_cmd_header), &p);
3340 sizeof(struct ipw2100_cmd_header),
3341 &p);
3342 if (!v) { 3274 if (!v) {
3343 printk(KERN_ERR DRV_NAME ": " 3275 printk(KERN_ERR DRV_NAME ": "
3344 "%s: PCI alloc failed for msg " 3276 "%s: PCI alloc failed for msg "
3345 "buffers.\n", 3277 "buffers.\n", priv->net_dev->name);
3346 priv->net_dev->name);
3347 err = -ENOMEM; 3278 err = -ENOMEM;
3348 break; 3279 break;
3349 } 3280 }
@@ -3352,7 +3283,7 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3352 3283
3353 priv->msg_buffers[i].type = COMMAND; 3284 priv->msg_buffers[i].type = COMMAND;
3354 priv->msg_buffers[i].info.c_struct.cmd = 3285 priv->msg_buffers[i].info.c_struct.cmd =
3355 (struct ipw2100_cmd_header*)v; 3286 (struct ipw2100_cmd_header *)v;
3356 priv->msg_buffers[i].info.c_struct.cmd_phys = p; 3287 priv->msg_buffers[i].info.c_struct.cmd_phys = p;
3357 } 3288 }
3358 3289
@@ -3360,11 +3291,11 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3360 return 0; 3291 return 0;
3361 3292
3362 for (j = 0; j < i; j++) { 3293 for (j = 0; j < i; j++) {
3363 pci_free_consistent( 3294 pci_free_consistent(priv->pci_dev,
3364 priv->pci_dev, 3295 sizeof(struct ipw2100_cmd_header),
3365 sizeof(struct ipw2100_cmd_header), 3296 priv->msg_buffers[j].info.c_struct.cmd,
3366 priv->msg_buffers[j].info.c_struct.cmd, 3297 priv->msg_buffers[j].info.c_struct.
3367 priv->msg_buffers[j].info.c_struct.cmd_phys); 3298 cmd_phys);
3368 } 3299 }
3369 3300
3370 kfree(priv->msg_buffers); 3301 kfree(priv->msg_buffers);
@@ -3398,7 +3329,8 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv)
3398 pci_free_consistent(priv->pci_dev, 3329 pci_free_consistent(priv->pci_dev,
3399 sizeof(struct ipw2100_cmd_header), 3330 sizeof(struct ipw2100_cmd_header),
3400 priv->msg_buffers[i].info.c_struct.cmd, 3331 priv->msg_buffers[i].info.c_struct.cmd,
3401 priv->msg_buffers[i].info.c_struct.cmd_phys); 3332 priv->msg_buffers[i].info.c_struct.
3333 cmd_phys);
3402 } 3334 }
3403 3335
3404 kfree(priv->msg_buffers); 3336 kfree(priv->msg_buffers);
@@ -3424,6 +3356,7 @@ static ssize_t show_pci(struct device *d, struct device_attribute *attr,
3424 3356
3425 return out - buf; 3357 return out - buf;
3426} 3358}
3359
3427static DEVICE_ATTR(pci, S_IRUGO, show_pci, NULL); 3360static DEVICE_ATTR(pci, S_IRUGO, show_pci, NULL);
3428 3361
3429static ssize_t show_cfg(struct device *d, struct device_attribute *attr, 3362static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
@@ -3432,209 +3365,269 @@ static ssize_t show_cfg(struct device *d, struct device_attribute *attr,
3432 struct ipw2100_priv *p = d->driver_data; 3365 struct ipw2100_priv *p = d->driver_data;
3433 return sprintf(buf, "0x%08x\n", (int)p->config); 3366 return sprintf(buf, "0x%08x\n", (int)p->config);
3434} 3367}
3368
3435static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL); 3369static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL);
3436 3370
3437static ssize_t show_status(struct device *d, struct device_attribute *attr, 3371static ssize_t show_status(struct device *d, struct device_attribute *attr,
3438 char *buf) 3372 char *buf)
3439{ 3373{
3440 struct ipw2100_priv *p = d->driver_data; 3374 struct ipw2100_priv *p = d->driver_data;
3441 return sprintf(buf, "0x%08x\n", (int)p->status); 3375 return sprintf(buf, "0x%08x\n", (int)p->status);
3442} 3376}
3377
3443static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); 3378static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
3444 3379
3445static ssize_t show_capability(struct device *d, struct device_attribute *attr, 3380static ssize_t show_capability(struct device *d, struct device_attribute *attr,
3446 char *buf) 3381 char *buf)
3447{ 3382{
3448 struct ipw2100_priv *p = d->driver_data; 3383 struct ipw2100_priv *p = d->driver_data;
3449 return sprintf(buf, "0x%08x\n", (int)p->capability); 3384 return sprintf(buf, "0x%08x\n", (int)p->capability);
3450} 3385}
3451static DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL);
3452 3386
3387static DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL);
3453 3388
3454#define IPW2100_REG(x) { IPW_ ##x, #x } 3389#define IPW2100_REG(x) { IPW_ ##x, #x }
3455static const struct { 3390static const struct {
3456 u32 addr; 3391 u32 addr;
3457 const char *name; 3392 const char *name;
3458} hw_data[] = { 3393} hw_data[] = {
3459 IPW2100_REG(REG_GP_CNTRL), 3394IPW2100_REG(REG_GP_CNTRL),
3460 IPW2100_REG(REG_GPIO), 3395 IPW2100_REG(REG_GPIO),
3461 IPW2100_REG(REG_INTA), 3396 IPW2100_REG(REG_INTA),
3462 IPW2100_REG(REG_INTA_MASK), 3397 IPW2100_REG(REG_INTA_MASK), IPW2100_REG(REG_RESET_REG),};
3463 IPW2100_REG(REG_RESET_REG),
3464};
3465#define IPW2100_NIC(x, s) { x, #x, s } 3398#define IPW2100_NIC(x, s) { x, #x, s }
3466static const struct { 3399static const struct {
3467 u32 addr; 3400 u32 addr;
3468 const char *name; 3401 const char *name;
3469 size_t size; 3402 size_t size;
3470} nic_data[] = { 3403} nic_data[] = {
3471 IPW2100_NIC(IPW2100_CONTROL_REG, 2), 3404IPW2100_NIC(IPW2100_CONTROL_REG, 2),
3472 IPW2100_NIC(0x210014, 1), 3405 IPW2100_NIC(0x210014, 1), IPW2100_NIC(0x210000, 1),};
3473 IPW2100_NIC(0x210000, 1),
3474};
3475#define IPW2100_ORD(x, d) { IPW_ORD_ ##x, #x, d } 3406#define IPW2100_ORD(x, d) { IPW_ORD_ ##x, #x, d }
3476static const struct { 3407static const struct {
3477 u8 index; 3408 u8 index;
3478 const char *name; 3409 const char *name;
3479 const char *desc; 3410 const char *desc;
3480} ord_data[] = { 3411} ord_data[] = {
3481 IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"), 3412IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"),
3482 IPW2100_ORD(STAT_TX_HOST_COMPLETE, "successful Host Tx's (MSDU)"), 3413 IPW2100_ORD(STAT_TX_HOST_COMPLETE,
3483 IPW2100_ORD(STAT_TX_DIR_DATA, "successful Directed Tx's (MSDU)"), 3414 "successful Host Tx's (MSDU)"),
3484 IPW2100_ORD(STAT_TX_DIR_DATA1, "successful Directed Tx's (MSDU) @ 1MB"), 3415 IPW2100_ORD(STAT_TX_DIR_DATA,
3485 IPW2100_ORD(STAT_TX_DIR_DATA2, "successful Directed Tx's (MSDU) @ 2MB"), 3416 "successful Directed Tx's (MSDU)"),
3486 IPW2100_ORD(STAT_TX_DIR_DATA5_5, "successful Directed Tx's (MSDU) @ 5_5MB"), 3417 IPW2100_ORD(STAT_TX_DIR_DATA1,
3487 IPW2100_ORD(STAT_TX_DIR_DATA11, "successful Directed Tx's (MSDU) @ 11MB"), 3418 "successful Directed Tx's (MSDU) @ 1MB"),
3488 IPW2100_ORD(STAT_TX_NODIR_DATA1, "successful Non_Directed Tx's (MSDU) @ 1MB"), 3419 IPW2100_ORD(STAT_TX_DIR_DATA2,
3489 IPW2100_ORD(STAT_TX_NODIR_DATA2, "successful Non_Directed Tx's (MSDU) @ 2MB"), 3420 "successful Directed Tx's (MSDU) @ 2MB"),
3490 IPW2100_ORD(STAT_TX_NODIR_DATA5_5, "successful Non_Directed Tx's (MSDU) @ 5.5MB"), 3421 IPW2100_ORD(STAT_TX_DIR_DATA5_5,
3491 IPW2100_ORD(STAT_TX_NODIR_DATA11, "successful Non_Directed Tx's (MSDU) @ 11MB"), 3422 "successful Directed Tx's (MSDU) @ 5_5MB"),
3492 IPW2100_ORD(STAT_NULL_DATA, "successful NULL data Tx's"), 3423 IPW2100_ORD(STAT_TX_DIR_DATA11,
3493 IPW2100_ORD(STAT_TX_RTS, "successful Tx RTS"), 3424 "successful Directed Tx's (MSDU) @ 11MB"),
3494 IPW2100_ORD(STAT_TX_CTS, "successful Tx CTS"), 3425 IPW2100_ORD(STAT_TX_NODIR_DATA1,
3495 IPW2100_ORD(STAT_TX_ACK, "successful Tx ACK"), 3426 "successful Non_Directed Tx's (MSDU) @ 1MB"),
3496 IPW2100_ORD(STAT_TX_ASSN, "successful Association Tx's"), 3427 IPW2100_ORD(STAT_TX_NODIR_DATA2,
3497 IPW2100_ORD(STAT_TX_ASSN_RESP, "successful Association response Tx's"), 3428 "successful Non_Directed Tx's (MSDU) @ 2MB"),
3498 IPW2100_ORD(STAT_TX_REASSN, "successful Reassociation Tx's"), 3429 IPW2100_ORD(STAT_TX_NODIR_DATA5_5,
3499 IPW2100_ORD(STAT_TX_REASSN_RESP, "successful Reassociation response Tx's"), 3430 "successful Non_Directed Tx's (MSDU) @ 5.5MB"),
3500 IPW2100_ORD(STAT_TX_PROBE, "probes successfully transmitted"), 3431 IPW2100_ORD(STAT_TX_NODIR_DATA11,
3501 IPW2100_ORD(STAT_TX_PROBE_RESP, "probe responses successfully transmitted"), 3432 "successful Non_Directed Tx's (MSDU) @ 11MB"),
3502 IPW2100_ORD(STAT_TX_BEACON, "tx beacon"), 3433 IPW2100_ORD(STAT_NULL_DATA, "successful NULL data Tx's"),
3503 IPW2100_ORD(STAT_TX_ATIM, "Tx ATIM"), 3434 IPW2100_ORD(STAT_TX_RTS, "successful Tx RTS"),
3504 IPW2100_ORD(STAT_TX_DISASSN, "successful Disassociation TX"), 3435 IPW2100_ORD(STAT_TX_CTS, "successful Tx CTS"),
3505 IPW2100_ORD(STAT_TX_AUTH, "successful Authentication Tx"), 3436 IPW2100_ORD(STAT_TX_ACK, "successful Tx ACK"),
3506 IPW2100_ORD(STAT_TX_DEAUTH, "successful Deauthentication TX"), 3437 IPW2100_ORD(STAT_TX_ASSN, "successful Association Tx's"),
3507 IPW2100_ORD(STAT_TX_TOTAL_BYTES, "Total successful Tx data bytes"), 3438 IPW2100_ORD(STAT_TX_ASSN_RESP,
3508 IPW2100_ORD(STAT_TX_RETRIES, "Tx retries"), 3439 "successful Association response Tx's"),
3509 IPW2100_ORD(STAT_TX_RETRY1, "Tx retries at 1MBPS"), 3440 IPW2100_ORD(STAT_TX_REASSN,
3510 IPW2100_ORD(STAT_TX_RETRY2, "Tx retries at 2MBPS"), 3441 "successful Reassociation Tx's"),
3511 IPW2100_ORD(STAT_TX_RETRY5_5, "Tx retries at 5.5MBPS"), 3442 IPW2100_ORD(STAT_TX_REASSN_RESP,
3512 IPW2100_ORD(STAT_TX_RETRY11, "Tx retries at 11MBPS"), 3443 "successful Reassociation response Tx's"),
3513 IPW2100_ORD(STAT_TX_FAILURES, "Tx Failures"), 3444 IPW2100_ORD(STAT_TX_PROBE,
3514 IPW2100_ORD(STAT_TX_MAX_TRIES_IN_HOP,"times max tries in a hop failed"), 3445 "probes successfully transmitted"),
3515 IPW2100_ORD(STAT_TX_DISASSN_FAIL, "times disassociation failed"), 3446 IPW2100_ORD(STAT_TX_PROBE_RESP,
3516 IPW2100_ORD(STAT_TX_ERR_CTS, "missed/bad CTS frames"), 3447 "probe responses successfully transmitted"),
3517 IPW2100_ORD(STAT_TX_ERR_ACK, "tx err due to acks"), 3448 IPW2100_ORD(STAT_TX_BEACON, "tx beacon"),
3518 IPW2100_ORD(STAT_RX_HOST, "packets passed to host"), 3449 IPW2100_ORD(STAT_TX_ATIM, "Tx ATIM"),
3519 IPW2100_ORD(STAT_RX_DIR_DATA, "directed packets"), 3450 IPW2100_ORD(STAT_TX_DISASSN,
3520 IPW2100_ORD(STAT_RX_DIR_DATA1, "directed packets at 1MB"), 3451 "successful Disassociation TX"),
3521 IPW2100_ORD(STAT_RX_DIR_DATA2, "directed packets at 2MB"), 3452 IPW2100_ORD(STAT_TX_AUTH, "successful Authentication Tx"),
3522 IPW2100_ORD(STAT_RX_DIR_DATA5_5, "directed packets at 5.5MB"), 3453 IPW2100_ORD(STAT_TX_DEAUTH,
3523 IPW2100_ORD(STAT_RX_DIR_DATA11, "directed packets at 11MB"), 3454 "successful Deauthentication TX"),
3524 IPW2100_ORD(STAT_RX_NODIR_DATA,"nondirected packets"), 3455 IPW2100_ORD(STAT_TX_TOTAL_BYTES,
3525 IPW2100_ORD(STAT_RX_NODIR_DATA1, "nondirected packets at 1MB"), 3456 "Total successful Tx data bytes"),
3526 IPW2100_ORD(STAT_RX_NODIR_DATA2, "nondirected packets at 2MB"), 3457 IPW2100_ORD(STAT_TX_RETRIES, "Tx retries"),
3527 IPW2100_ORD(STAT_RX_NODIR_DATA5_5, "nondirected packets at 5.5MB"), 3458 IPW2100_ORD(STAT_TX_RETRY1, "Tx retries at 1MBPS"),
3528 IPW2100_ORD(STAT_RX_NODIR_DATA11, "nondirected packets at 11MB"), 3459 IPW2100_ORD(STAT_TX_RETRY2, "Tx retries at 2MBPS"),
3529 IPW2100_ORD(STAT_RX_NULL_DATA, "null data rx's"), 3460 IPW2100_ORD(STAT_TX_RETRY5_5, "Tx retries at 5.5MBPS"),
3530 IPW2100_ORD(STAT_RX_RTS, "Rx RTS"), 3461 IPW2100_ORD(STAT_TX_RETRY11, "Tx retries at 11MBPS"),
3531 IPW2100_ORD(STAT_RX_CTS, "Rx CTS"), 3462 IPW2100_ORD(STAT_TX_FAILURES, "Tx Failures"),
3532 IPW2100_ORD(STAT_RX_ACK, "Rx ACK"), 3463 IPW2100_ORD(STAT_TX_MAX_TRIES_IN_HOP,
3533 IPW2100_ORD(STAT_RX_CFEND, "Rx CF End"), 3464 "times max tries in a hop failed"),
3534 IPW2100_ORD(STAT_RX_CFEND_ACK, "Rx CF End + CF Ack"), 3465 IPW2100_ORD(STAT_TX_DISASSN_FAIL,
3535 IPW2100_ORD(STAT_RX_ASSN, "Association Rx's"), 3466 "times disassociation failed"),
3536 IPW2100_ORD(STAT_RX_ASSN_RESP, "Association response Rx's"), 3467 IPW2100_ORD(STAT_TX_ERR_CTS, "missed/bad CTS frames"),
3537 IPW2100_ORD(STAT_RX_REASSN, "Reassociation Rx's"), 3468 IPW2100_ORD(STAT_TX_ERR_ACK, "tx err due to acks"),
3538 IPW2100_ORD(STAT_RX_REASSN_RESP, "Reassociation response Rx's"), 3469 IPW2100_ORD(STAT_RX_HOST, "packets passed to host"),
3539 IPW2100_ORD(STAT_RX_PROBE, "probe Rx's"), 3470 IPW2100_ORD(STAT_RX_DIR_DATA, "directed packets"),
3540 IPW2100_ORD(STAT_RX_PROBE_RESP, "probe response Rx's"), 3471 IPW2100_ORD(STAT_RX_DIR_DATA1, "directed packets at 1MB"),
3541 IPW2100_ORD(STAT_RX_BEACON, "Rx beacon"), 3472 IPW2100_ORD(STAT_RX_DIR_DATA2, "directed packets at 2MB"),
3542 IPW2100_ORD(STAT_RX_ATIM, "Rx ATIM"), 3473 IPW2100_ORD(STAT_RX_DIR_DATA5_5,
3543 IPW2100_ORD(STAT_RX_DISASSN, "disassociation Rx"), 3474 "directed packets at 5.5MB"),
3544 IPW2100_ORD(STAT_RX_AUTH, "authentication Rx"), 3475 IPW2100_ORD(STAT_RX_DIR_DATA11, "directed packets at 11MB"),
3545 IPW2100_ORD(STAT_RX_DEAUTH, "deauthentication Rx"), 3476 IPW2100_ORD(STAT_RX_NODIR_DATA, "nondirected packets"),
3546 IPW2100_ORD(STAT_RX_TOTAL_BYTES,"Total rx data bytes received"), 3477 IPW2100_ORD(STAT_RX_NODIR_DATA1,
3547 IPW2100_ORD(STAT_RX_ERR_CRC, "packets with Rx CRC error"), 3478 "nondirected packets at 1MB"),
3548 IPW2100_ORD(STAT_RX_ERR_CRC1, "Rx CRC errors at 1MB"), 3479 IPW2100_ORD(STAT_RX_NODIR_DATA2,
3549 IPW2100_ORD(STAT_RX_ERR_CRC2, "Rx CRC errors at 2MB"), 3480 "nondirected packets at 2MB"),
3550 IPW2100_ORD(STAT_RX_ERR_CRC5_5, "Rx CRC errors at 5.5MB"), 3481 IPW2100_ORD(STAT_RX_NODIR_DATA5_5,
3551 IPW2100_ORD(STAT_RX_ERR_CRC11, "Rx CRC errors at 11MB"), 3482 "nondirected packets at 5.5MB"),
3552 IPW2100_ORD(STAT_RX_DUPLICATE1, "duplicate rx packets at 1MB"), 3483 IPW2100_ORD(STAT_RX_NODIR_DATA11,
3553 IPW2100_ORD(STAT_RX_DUPLICATE2, "duplicate rx packets at 2MB"), 3484 "nondirected packets at 11MB"),
3554 IPW2100_ORD(STAT_RX_DUPLICATE5_5, "duplicate rx packets at 5.5MB"), 3485 IPW2100_ORD(STAT_RX_NULL_DATA, "null data rx's"),
3555 IPW2100_ORD(STAT_RX_DUPLICATE11, "duplicate rx packets at 11MB"), 3486 IPW2100_ORD(STAT_RX_RTS, "Rx RTS"), IPW2100_ORD(STAT_RX_CTS,
3556 IPW2100_ORD(STAT_RX_DUPLICATE, "duplicate rx packets"), 3487 "Rx CTS"),
3557 IPW2100_ORD(PERS_DB_LOCK, "locking fw permanent db"), 3488 IPW2100_ORD(STAT_RX_ACK, "Rx ACK"),
3558 IPW2100_ORD(PERS_DB_SIZE, "size of fw permanent db"), 3489 IPW2100_ORD(STAT_RX_CFEND, "Rx CF End"),
3559 IPW2100_ORD(PERS_DB_ADDR, "address of fw permanent db"), 3490 IPW2100_ORD(STAT_RX_CFEND_ACK, "Rx CF End + CF Ack"),
3560 IPW2100_ORD(STAT_RX_INVALID_PROTOCOL, "rx frames with invalid protocol"), 3491 IPW2100_ORD(STAT_RX_ASSN, "Association Rx's"),
3561 IPW2100_ORD(SYS_BOOT_TIME, "Boot time"), 3492 IPW2100_ORD(STAT_RX_ASSN_RESP, "Association response Rx's"),
3562 IPW2100_ORD(STAT_RX_NO_BUFFER, "rx frames rejected due to no buffer"), 3493 IPW2100_ORD(STAT_RX_REASSN, "Reassociation Rx's"),
3563 IPW2100_ORD(STAT_RX_MISSING_FRAG, "rx frames dropped due to missing fragment"), 3494 IPW2100_ORD(STAT_RX_REASSN_RESP,
3564 IPW2100_ORD(STAT_RX_ORPHAN_FRAG, "rx frames dropped due to non-sequential fragment"), 3495 "Reassociation response Rx's"),
3565 IPW2100_ORD(STAT_RX_ORPHAN_FRAME, "rx frames dropped due to unmatched 1st frame"), 3496 IPW2100_ORD(STAT_RX_PROBE, "probe Rx's"),
3566 IPW2100_ORD(STAT_RX_FRAG_AGEOUT, "rx frames dropped due to uncompleted frame"), 3497 IPW2100_ORD(STAT_RX_PROBE_RESP, "probe response Rx's"),
3567 IPW2100_ORD(STAT_RX_ICV_ERRORS, "ICV errors during decryption"), 3498 IPW2100_ORD(STAT_RX_BEACON, "Rx beacon"),
3568 IPW2100_ORD(STAT_PSP_SUSPENSION,"times adapter suspended"), 3499 IPW2100_ORD(STAT_RX_ATIM, "Rx ATIM"),
3569 IPW2100_ORD(STAT_PSP_BCN_TIMEOUT, "beacon timeout"), 3500 IPW2100_ORD(STAT_RX_DISASSN, "disassociation Rx"),
3570 IPW2100_ORD(STAT_PSP_POLL_TIMEOUT, "poll response timeouts"), 3501 IPW2100_ORD(STAT_RX_AUTH, "authentication Rx"),
3571 IPW2100_ORD(STAT_PSP_NONDIR_TIMEOUT, "timeouts waiting for last {broad,multi}cast pkt"), 3502 IPW2100_ORD(STAT_RX_DEAUTH, "deauthentication Rx"),
3572 IPW2100_ORD(STAT_PSP_RX_DTIMS, "PSP DTIMs received"), 3503 IPW2100_ORD(STAT_RX_TOTAL_BYTES,
3573 IPW2100_ORD(STAT_PSP_RX_TIMS, "PSP TIMs received"), 3504 "Total rx data bytes received"),
3574 IPW2100_ORD(STAT_PSP_STATION_ID,"PSP Station ID"), 3505 IPW2100_ORD(STAT_RX_ERR_CRC, "packets with Rx CRC error"),
3575 IPW2100_ORD(LAST_ASSN_TIME, "RTC time of last association"), 3506 IPW2100_ORD(STAT_RX_ERR_CRC1, "Rx CRC errors at 1MB"),
3576 IPW2100_ORD(STAT_PERCENT_MISSED_BCNS,"current calculation of % missed beacons"), 3507 IPW2100_ORD(STAT_RX_ERR_CRC2, "Rx CRC errors at 2MB"),
3577 IPW2100_ORD(STAT_PERCENT_RETRIES,"current calculation of % missed tx retries"), 3508 IPW2100_ORD(STAT_RX_ERR_CRC5_5, "Rx CRC errors at 5.5MB"),
3578 IPW2100_ORD(ASSOCIATED_AP_PTR, "0 if not associated, else pointer to AP table entry"), 3509 IPW2100_ORD(STAT_RX_ERR_CRC11, "Rx CRC errors at 11MB"),
3579 IPW2100_ORD(AVAILABLE_AP_CNT, "AP's decsribed in the AP table"), 3510 IPW2100_ORD(STAT_RX_DUPLICATE1,
3580 IPW2100_ORD(AP_LIST_PTR, "Ptr to list of available APs"), 3511 "duplicate rx packets at 1MB"),
3581 IPW2100_ORD(STAT_AP_ASSNS, "associations"), 3512 IPW2100_ORD(STAT_RX_DUPLICATE2,
3582 IPW2100_ORD(STAT_ASSN_FAIL, "association failures"), 3513 "duplicate rx packets at 2MB"),
3583 IPW2100_ORD(STAT_ASSN_RESP_FAIL,"failures due to response fail"), 3514 IPW2100_ORD(STAT_RX_DUPLICATE5_5,
3584 IPW2100_ORD(STAT_FULL_SCANS, "full scans"), 3515 "duplicate rx packets at 5.5MB"),
3585 IPW2100_ORD(CARD_DISABLED, "Card Disabled"), 3516 IPW2100_ORD(STAT_RX_DUPLICATE11,
3586 IPW2100_ORD(STAT_ROAM_INHIBIT, "times roaming was inhibited due to activity"), 3517 "duplicate rx packets at 11MB"),
3587 IPW2100_ORD(RSSI_AT_ASSN, "RSSI of associated AP at time of association"), 3518 IPW2100_ORD(STAT_RX_DUPLICATE, "duplicate rx packets"),
3588 IPW2100_ORD(STAT_ASSN_CAUSE1, "reassociation: no probe response or TX on hop"), 3519 IPW2100_ORD(PERS_DB_LOCK, "locking fw permanent db"),
3589 IPW2100_ORD(STAT_ASSN_CAUSE2, "reassociation: poor tx/rx quality"), 3520 IPW2100_ORD(PERS_DB_SIZE, "size of fw permanent db"),
3590 IPW2100_ORD(STAT_ASSN_CAUSE3, "reassociation: tx/rx quality (excessive AP load"), 3521 IPW2100_ORD(PERS_DB_ADDR, "address of fw permanent db"),
3591 IPW2100_ORD(STAT_ASSN_CAUSE4, "reassociation: AP RSSI level"), 3522 IPW2100_ORD(STAT_RX_INVALID_PROTOCOL,
3592 IPW2100_ORD(STAT_ASSN_CAUSE5, "reassociations due to load leveling"), 3523 "rx frames with invalid protocol"),
3593 IPW2100_ORD(STAT_AUTH_FAIL, "times authentication failed"), 3524 IPW2100_ORD(SYS_BOOT_TIME, "Boot time"),
3594 IPW2100_ORD(STAT_AUTH_RESP_FAIL,"times authentication response failed"), 3525 IPW2100_ORD(STAT_RX_NO_BUFFER,
3595 IPW2100_ORD(STATION_TABLE_CNT, "entries in association table"), 3526 "rx frames rejected due to no buffer"),
3596 IPW2100_ORD(RSSI_AVG_CURR, "Current avg RSSI"), 3527 IPW2100_ORD(STAT_RX_MISSING_FRAG,
3597 IPW2100_ORD(POWER_MGMT_MODE, "Power mode - 0=CAM, 1=PSP"), 3528 "rx frames dropped due to missing fragment"),
3598 IPW2100_ORD(COUNTRY_CODE, "IEEE country code as recv'd from beacon"), 3529 IPW2100_ORD(STAT_RX_ORPHAN_FRAG,
3599 IPW2100_ORD(COUNTRY_CHANNELS, "channels suported by country"), 3530 "rx frames dropped due to non-sequential fragment"),
3600 IPW2100_ORD(RESET_CNT, "adapter resets (warm)"), 3531 IPW2100_ORD(STAT_RX_ORPHAN_FRAME,
3601 IPW2100_ORD(BEACON_INTERVAL, "Beacon interval"), 3532 "rx frames dropped due to unmatched 1st frame"),
3602 IPW2100_ORD(ANTENNA_DIVERSITY, "TRUE if antenna diversity is disabled"), 3533 IPW2100_ORD(STAT_RX_FRAG_AGEOUT,
3603 IPW2100_ORD(DTIM_PERIOD, "beacon intervals between DTIMs"), 3534 "rx frames dropped due to uncompleted frame"),
3604 IPW2100_ORD(OUR_FREQ, "current radio freq lower digits - channel ID"), 3535 IPW2100_ORD(STAT_RX_ICV_ERRORS,
3605 IPW2100_ORD(RTC_TIME, "current RTC time"), 3536 "ICV errors during decryption"),
3606 IPW2100_ORD(PORT_TYPE, "operating mode"), 3537 IPW2100_ORD(STAT_PSP_SUSPENSION, "times adapter suspended"),
3607 IPW2100_ORD(CURRENT_TX_RATE, "current tx rate"), 3538 IPW2100_ORD(STAT_PSP_BCN_TIMEOUT, "beacon timeout"),
3608 IPW2100_ORD(SUPPORTED_RATES, "supported tx rates"), 3539 IPW2100_ORD(STAT_PSP_POLL_TIMEOUT,
3609 IPW2100_ORD(ATIM_WINDOW, "current ATIM Window"), 3540 "poll response timeouts"),
3610 IPW2100_ORD(BASIC_RATES, "basic tx rates"), 3541 IPW2100_ORD(STAT_PSP_NONDIR_TIMEOUT,
3611 IPW2100_ORD(NIC_HIGHEST_RATE, "NIC highest tx rate"), 3542 "timeouts waiting for last {broad,multi}cast pkt"),
3612 IPW2100_ORD(AP_HIGHEST_RATE, "AP highest tx rate"), 3543 IPW2100_ORD(STAT_PSP_RX_DTIMS, "PSP DTIMs received"),
3613 IPW2100_ORD(CAPABILITIES, "Management frame capability field"), 3544 IPW2100_ORD(STAT_PSP_RX_TIMS, "PSP TIMs received"),
3614 IPW2100_ORD(AUTH_TYPE, "Type of authentication"), 3545 IPW2100_ORD(STAT_PSP_STATION_ID, "PSP Station ID"),
3615 IPW2100_ORD(RADIO_TYPE, "Adapter card platform type"), 3546 IPW2100_ORD(LAST_ASSN_TIME, "RTC time of last association"),
3616 IPW2100_ORD(RTS_THRESHOLD, "Min packet length for RTS handshaking"), 3547 IPW2100_ORD(STAT_PERCENT_MISSED_BCNS,
3617 IPW2100_ORD(INT_MODE, "International mode"), 3548 "current calculation of % missed beacons"),
3618 IPW2100_ORD(FRAGMENTATION_THRESHOLD, "protocol frag threshold"), 3549 IPW2100_ORD(STAT_PERCENT_RETRIES,
3619 IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_START_ADDRESS, "EEPROM offset in SRAM"), 3550 "current calculation of % missed tx retries"),
3620 IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_SIZE, "EEPROM size in SRAM"), 3551 IPW2100_ORD(ASSOCIATED_AP_PTR,
3621 IPW2100_ORD(EEPROM_SKU_CAPABILITY, "EEPROM SKU Capability"), 3552 "0 if not associated, else pointer to AP table entry"),
3622 IPW2100_ORD(EEPROM_IBSS_11B_CHANNELS, "EEPROM IBSS 11b channel set"), 3553 IPW2100_ORD(AVAILABLE_AP_CNT,
3623 IPW2100_ORD(MAC_VERSION, "MAC Version"), 3554 "AP's decsribed in the AP table"),
3624 IPW2100_ORD(MAC_REVISION, "MAC Revision"), 3555 IPW2100_ORD(AP_LIST_PTR, "Ptr to list of available APs"),
3625 IPW2100_ORD(RADIO_VERSION, "Radio Version"), 3556 IPW2100_ORD(STAT_AP_ASSNS, "associations"),
3626 IPW2100_ORD(NIC_MANF_DATE_TIME, "MANF Date/Time STAMP"), 3557 IPW2100_ORD(STAT_ASSN_FAIL, "association failures"),
3627 IPW2100_ORD(UCODE_VERSION, "Ucode Version"), 3558 IPW2100_ORD(STAT_ASSN_RESP_FAIL,
3628}; 3559 "failures due to response fail"),
3629 3560 IPW2100_ORD(STAT_FULL_SCANS, "full scans"),
3561 IPW2100_ORD(CARD_DISABLED, "Card Disabled"),
3562 IPW2100_ORD(STAT_ROAM_INHIBIT,
3563 "times roaming was inhibited due to activity"),
3564 IPW2100_ORD(RSSI_AT_ASSN,
3565 "RSSI of associated AP at time of association"),
3566 IPW2100_ORD(STAT_ASSN_CAUSE1,
3567 "reassociation: no probe response or TX on hop"),
3568 IPW2100_ORD(STAT_ASSN_CAUSE2,
3569 "reassociation: poor tx/rx quality"),
3570 IPW2100_ORD(STAT_ASSN_CAUSE3,
3571 "reassociation: tx/rx quality (excessive AP load"),
3572 IPW2100_ORD(STAT_ASSN_CAUSE4,
3573 "reassociation: AP RSSI level"),
3574 IPW2100_ORD(STAT_ASSN_CAUSE5,
3575 "reassociations due to load leveling"),
3576 IPW2100_ORD(STAT_AUTH_FAIL, "times authentication failed"),
3577 IPW2100_ORD(STAT_AUTH_RESP_FAIL,
3578 "times authentication response failed"),
3579 IPW2100_ORD(STATION_TABLE_CNT,
3580 "entries in association table"),
3581 IPW2100_ORD(RSSI_AVG_CURR, "Current avg RSSI"),
3582 IPW2100_ORD(POWER_MGMT_MODE, "Power mode - 0=CAM, 1=PSP"),
3583 IPW2100_ORD(COUNTRY_CODE,
3584 "IEEE country code as recv'd from beacon"),
3585 IPW2100_ORD(COUNTRY_CHANNELS,
3586 "channels suported by country"),
3587 IPW2100_ORD(RESET_CNT, "adapter resets (warm)"),
3588 IPW2100_ORD(BEACON_INTERVAL, "Beacon interval"),
3589 IPW2100_ORD(ANTENNA_DIVERSITY,
3590 "TRUE if antenna diversity is disabled"),
3591 IPW2100_ORD(DTIM_PERIOD, "beacon intervals between DTIMs"),
3592 IPW2100_ORD(OUR_FREQ,
3593 "current radio freq lower digits - channel ID"),
3594 IPW2100_ORD(RTC_TIME, "current RTC time"),
3595 IPW2100_ORD(PORT_TYPE, "operating mode"),
3596 IPW2100_ORD(CURRENT_TX_RATE, "current tx rate"),
3597 IPW2100_ORD(SUPPORTED_RATES, "supported tx rates"),
3598 IPW2100_ORD(ATIM_WINDOW, "current ATIM Window"),
3599 IPW2100_ORD(BASIC_RATES, "basic tx rates"),
3600 IPW2100_ORD(NIC_HIGHEST_RATE, "NIC highest tx rate"),
3601 IPW2100_ORD(AP_HIGHEST_RATE, "AP highest tx rate"),
3602 IPW2100_ORD(CAPABILITIES,
3603 "Management frame capability field"),
3604 IPW2100_ORD(AUTH_TYPE, "Type of authentication"),
3605 IPW2100_ORD(RADIO_TYPE, "Adapter card platform type"),
3606 IPW2100_ORD(RTS_THRESHOLD,
3607 "Min packet length for RTS handshaking"),
3608 IPW2100_ORD(INT_MODE, "International mode"),
3609 IPW2100_ORD(FRAGMENTATION_THRESHOLD,
3610 "protocol frag threshold"),
3611 IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_START_ADDRESS,
3612 "EEPROM offset in SRAM"),
3613 IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_SIZE,
3614 "EEPROM size in SRAM"),
3615 IPW2100_ORD(EEPROM_SKU_CAPABILITY, "EEPROM SKU Capability"),
3616 IPW2100_ORD(EEPROM_IBSS_11B_CHANNELS,
3617 "EEPROM IBSS 11b channel set"),
3618 IPW2100_ORD(MAC_VERSION, "MAC Version"),
3619 IPW2100_ORD(MAC_REVISION, "MAC Revision"),
3620 IPW2100_ORD(RADIO_VERSION, "Radio Version"),
3621 IPW2100_ORD(NIC_MANF_DATE_TIME, "MANF Date/Time STAMP"),
3622 IPW2100_ORD(UCODE_VERSION, "Ucode Version"),};
3630 3623
3631static ssize_t show_registers(struct device *d, struct device_attribute *attr, 3624static ssize_t show_registers(struct device *d, struct device_attribute *attr,
3632 char *buf) 3625 char *buf)
3633{ 3626{
3634 int i; 3627 int i;
3635 struct ipw2100_priv *priv = dev_get_drvdata(d); 3628 struct ipw2100_priv *priv = dev_get_drvdata(d);
3636 struct net_device *dev = priv->net_dev; 3629 struct net_device *dev = priv->net_dev;
3637 char * out = buf; 3630 char *out = buf;
3638 u32 val = 0; 3631 u32 val = 0;
3639 3632
3640 out += sprintf(out, "%30s [Address ] : Hex\n", "Register"); 3633 out += sprintf(out, "%30s [Address ] : Hex\n", "Register");
@@ -3647,15 +3640,15 @@ static ssize_t show_registers(struct device *d, struct device_attribute *attr,
3647 3640
3648 return out - buf; 3641 return out - buf;
3649} 3642}
3650static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
3651 3643
3644static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
3652 3645
3653static ssize_t show_hardware(struct device *d, struct device_attribute *attr, 3646static ssize_t show_hardware(struct device *d, struct device_attribute *attr,
3654 char *buf) 3647 char *buf)
3655{ 3648{
3656 struct ipw2100_priv *priv = dev_get_drvdata(d); 3649 struct ipw2100_priv *priv = dev_get_drvdata(d);
3657 struct net_device *dev = priv->net_dev; 3650 struct net_device *dev = priv->net_dev;
3658 char * out = buf; 3651 char *out = buf;
3659 int i; 3652 int i;
3660 3653
3661 out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry"); 3654 out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry");
@@ -3688,11 +3681,11 @@ static ssize_t show_hardware(struct device *d, struct device_attribute *attr,
3688 } 3681 }
3689 return out - buf; 3682 return out - buf;
3690} 3683}
3691static DEVICE_ATTR(hardware, S_IRUGO, show_hardware, NULL);
3692 3684
3685static DEVICE_ATTR(hardware, S_IRUGO, show_hardware, NULL);
3693 3686
3694static ssize_t show_memory(struct device *d, struct device_attribute *attr, 3687static ssize_t show_memory(struct device *d, struct device_attribute *attr,
3695 char *buf) 3688 char *buf)
3696{ 3689{
3697 struct ipw2100_priv *priv = dev_get_drvdata(d); 3690 struct ipw2100_priv *priv = dev_get_drvdata(d);
3698 struct net_device *dev = priv->net_dev; 3691 struct net_device *dev = priv->net_dev;
@@ -3708,10 +3701,13 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr,
3708 /* sysfs provides us PAGE_SIZE buffer */ 3701 /* sysfs provides us PAGE_SIZE buffer */
3709 while (len < PAGE_SIZE - 128 && loop < 0x30000) { 3702 while (len < PAGE_SIZE - 128 && loop < 0x30000) {
3710 3703
3711 if (priv->snapshot[0]) for (i = 0; i < 4; i++) 3704 if (priv->snapshot[0])
3712 buffer[i] = *(u32 *)SNAPSHOT_ADDR(loop + i * 4); 3705 for (i = 0; i < 4; i++)
3713 else for (i = 0; i < 4; i++) 3706 buffer[i] =
3714 read_nic_dword(dev, loop + i * 4, &buffer[i]); 3707 *(u32 *) SNAPSHOT_ADDR(loop + i * 4);
3708 else
3709 for (i = 0; i < 4; i++)
3710 read_nic_dword(dev, loop + i * 4, &buffer[i]);
3715 3711
3716 if (priv->dump_raw) 3712 if (priv->dump_raw)
3717 len += sprintf(buf + len, 3713 len += sprintf(buf + len,
@@ -3719,26 +3715,26 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr,
3719 "%c%c%c%c" 3715 "%c%c%c%c"
3720 "%c%c%c%c" 3716 "%c%c%c%c"
3721 "%c%c%c%c", 3717 "%c%c%c%c",
3722 ((u8*)buffer)[0x0], 3718 ((u8 *) buffer)[0x0],
3723 ((u8*)buffer)[0x1], 3719 ((u8 *) buffer)[0x1],
3724 ((u8*)buffer)[0x2], 3720 ((u8 *) buffer)[0x2],
3725 ((u8*)buffer)[0x3], 3721 ((u8 *) buffer)[0x3],
3726 ((u8*)buffer)[0x4], 3722 ((u8 *) buffer)[0x4],
3727 ((u8*)buffer)[0x5], 3723 ((u8 *) buffer)[0x5],
3728 ((u8*)buffer)[0x6], 3724 ((u8 *) buffer)[0x6],
3729 ((u8*)buffer)[0x7], 3725 ((u8 *) buffer)[0x7],
3730 ((u8*)buffer)[0x8], 3726 ((u8 *) buffer)[0x8],
3731 ((u8*)buffer)[0x9], 3727 ((u8 *) buffer)[0x9],
3732 ((u8*)buffer)[0xa], 3728 ((u8 *) buffer)[0xa],
3733 ((u8*)buffer)[0xb], 3729 ((u8 *) buffer)[0xb],
3734 ((u8*)buffer)[0xc], 3730 ((u8 *) buffer)[0xc],
3735 ((u8*)buffer)[0xd], 3731 ((u8 *) buffer)[0xd],
3736 ((u8*)buffer)[0xe], 3732 ((u8 *) buffer)[0xe],
3737 ((u8*)buffer)[0xf]); 3733 ((u8 *) buffer)[0xf]);
3738 else 3734 else
3739 len += sprintf(buf + len, "%s\n", 3735 len += sprintf(buf + len, "%s\n",
3740 snprint_line(line, sizeof(line), 3736 snprint_line(line, sizeof(line),
3741 (u8*)buffer, 16, loop)); 3737 (u8 *) buffer, 16, loop));
3742 loop += 16; 3738 loop += 16;
3743 } 3739 }
3744 3740
@@ -3746,44 +3742,44 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr,
3746} 3742}
3747 3743
3748static ssize_t store_memory(struct device *d, struct device_attribute *attr, 3744static ssize_t store_memory(struct device *d, struct device_attribute *attr,
3749 const char *buf, size_t count) 3745 const char *buf, size_t count)
3750{ 3746{
3751 struct ipw2100_priv *priv = dev_get_drvdata(d); 3747 struct ipw2100_priv *priv = dev_get_drvdata(d);
3752 struct net_device *dev = priv->net_dev; 3748 struct net_device *dev = priv->net_dev;
3753 const char *p = buf; 3749 const char *p = buf;
3754 3750
3751 (void) dev; /* kill unused-var warning for debug-only code */
3752
3755 if (count < 1) 3753 if (count < 1)
3756 return count; 3754 return count;
3757 3755
3758 if (p[0] == '1' || 3756 if (p[0] == '1' ||
3759 (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) { 3757 (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) {
3760 IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n", 3758 IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n",
3761 dev->name); 3759 dev->name);
3762 priv->dump_raw = 1; 3760 priv->dump_raw = 1;
3763 3761
3764 } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' && 3762 } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' &&
3765 tolower(p[1]) == 'f')) { 3763 tolower(p[1]) == 'f')) {
3766 IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n", 3764 IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n",
3767 dev->name); 3765 dev->name);
3768 priv->dump_raw = 0; 3766 priv->dump_raw = 0;
3769 3767
3770 } else if (tolower(p[0]) == 'r') { 3768 } else if (tolower(p[0]) == 'r') {
3771 IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", 3769 IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", dev->name);
3772 dev->name);
3773 ipw2100_snapshot_free(priv); 3770 ipw2100_snapshot_free(priv);
3774 3771
3775 } else 3772 } else
3776 IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, " 3773 IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, "
3777 "reset = clear memory snapshot\n", 3774 "reset = clear memory snapshot\n", dev->name);
3778 dev->name);
3779 3775
3780 return count; 3776 return count;
3781} 3777}
3782static DEVICE_ATTR(memory, S_IWUSR|S_IRUGO, show_memory, store_memory);
3783 3778
3779static DEVICE_ATTR(memory, S_IWUSR | S_IRUGO, show_memory, store_memory);
3784 3780
3785static ssize_t show_ordinals(struct device *d, struct device_attribute *attr, 3781static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3786 char *buf) 3782 char *buf)
3787{ 3783{
3788 struct ipw2100_priv *priv = dev_get_drvdata(d); 3784 struct ipw2100_priv *priv = dev_get_drvdata(d);
3789 u32 val = 0; 3785 u32 val = 0;
@@ -3791,6 +3787,9 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3791 u32 val_len; 3787 u32 val_len;
3792 static int loop = 0; 3788 static int loop = 0;
3793 3789
3790 if (priv->status & STATUS_RF_KILL_MASK)
3791 return 0;
3792
3794 if (loop >= sizeof(ord_data) / sizeof(*ord_data)) 3793 if (loop >= sizeof(ord_data) / sizeof(*ord_data))
3795 loop = 0; 3794 loop = 0;
3796 3795
@@ -3814,14 +3813,14 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3814 3813
3815 return len; 3814 return len;
3816} 3815}
3817static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL);
3818 3816
3817static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL);
3819 3818
3820static ssize_t show_stats(struct device *d, struct device_attribute *attr, 3819static ssize_t show_stats(struct device *d, struct device_attribute *attr,
3821 char *buf) 3820 char *buf)
3822{ 3821{
3823 struct ipw2100_priv *priv = dev_get_drvdata(d); 3822 struct ipw2100_priv *priv = dev_get_drvdata(d);
3824 char * out = buf; 3823 char *out = buf;
3825 3824
3826 out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n", 3825 out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n",
3827 priv->interrupts, priv->tx_interrupts, 3826 priv->interrupts, priv->tx_interrupts,
@@ -3835,8 +3834,8 @@ static ssize_t show_stats(struct device *d, struct device_attribute *attr,
3835 3834
3836 return out - buf; 3835 return out - buf;
3837} 3836}
3838static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
3839 3837
3838static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
3840 3839
3841static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode) 3840static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3842{ 3841{
@@ -3864,19 +3863,18 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3864 priv->last_mode = priv->ieee->iw_mode; 3863 priv->last_mode = priv->ieee->iw_mode;
3865 priv->net_dev->type = ARPHRD_IEEE80211; 3864 priv->net_dev->type = ARPHRD_IEEE80211;
3866 break; 3865 break;
3867#endif /* CONFIG_IPW2100_MONITOR */ 3866#endif /* CONFIG_IPW2100_MONITOR */
3868 } 3867 }
3869 3868
3870 priv->ieee->iw_mode = mode; 3869 priv->ieee->iw_mode = mode;
3871 3870
3872#ifdef CONFIG_PM 3871#ifdef CONFIG_PM
3873 /* Indicate ipw2100_download_firmware download firmware 3872 /* Indicate ipw2100_download_firmware download firmware
3874 * from disk instead of memory. */ 3873 * from disk instead of memory. */
3875 ipw2100_firmware.version = 0; 3874 ipw2100_firmware.version = 0;
3876#endif 3875#endif
3877 3876
3878 printk(KERN_INFO "%s: Reseting on mode change.\n", 3877 printk(KERN_INFO "%s: Reseting on mode change.\n", priv->net_dev->name);
3879 priv->net_dev->name);
3880 priv->reset_backoff = 0; 3878 priv->reset_backoff = 0;
3881 schedule_reset(priv); 3879 schedule_reset(priv);
3882 3880
@@ -3884,12 +3882,12 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3884} 3882}
3885 3883
3886static ssize_t show_internals(struct device *d, struct device_attribute *attr, 3884static ssize_t show_internals(struct device *d, struct device_attribute *attr,
3887 char *buf) 3885 char *buf)
3888{ 3886{
3889 struct ipw2100_priv *priv = dev_get_drvdata(d); 3887 struct ipw2100_priv *priv = dev_get_drvdata(d);
3890 int len = 0; 3888 int len = 0;
3891 3889
3892#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" # y "\n", priv-> x) 3890#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x)
3893 3891
3894 if (priv->status & STATUS_ASSOCIATED) 3892 if (priv->status & STATUS_ASSOCIATED)
3895 len += sprintf(buf + len, "connected: %lu\n", 3893 len += sprintf(buf + len, "connected: %lu\n",
@@ -3897,55 +3895,60 @@ static ssize_t show_internals(struct device *d, struct device_attribute *attr,
3897 else 3895 else
3898 len += sprintf(buf + len, "not connected\n"); 3896 len += sprintf(buf + len, "not connected\n");
3899 3897
3900 DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], p); 3898 DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], "p");
3901 DUMP_VAR(status, 08lx); 3899 DUMP_VAR(status, "08lx");
3902 DUMP_VAR(config, 08lx); 3900 DUMP_VAR(config, "08lx");
3903 DUMP_VAR(capability, 08lx); 3901 DUMP_VAR(capability, "08lx");
3904 3902
3905 len += sprintf(buf + len, "last_rtc: %lu\n", (unsigned long)priv->last_rtc); 3903 len +=
3904 sprintf(buf + len, "last_rtc: %lu\n",
3905 (unsigned long)priv->last_rtc);
3906 3906
3907 DUMP_VAR(fatal_error, d); 3907 DUMP_VAR(fatal_error, "d");
3908 DUMP_VAR(stop_hang_check, d); 3908 DUMP_VAR(stop_hang_check, "d");
3909 DUMP_VAR(stop_rf_kill, d); 3909 DUMP_VAR(stop_rf_kill, "d");
3910 DUMP_VAR(messages_sent, d); 3910 DUMP_VAR(messages_sent, "d");
3911 3911
3912 DUMP_VAR(tx_pend_stat.value, d); 3912 DUMP_VAR(tx_pend_stat.value, "d");
3913 DUMP_VAR(tx_pend_stat.hi, d); 3913 DUMP_VAR(tx_pend_stat.hi, "d");
3914 3914
3915 DUMP_VAR(tx_free_stat.value, d); 3915 DUMP_VAR(tx_free_stat.value, "d");
3916 DUMP_VAR(tx_free_stat.lo, d); 3916 DUMP_VAR(tx_free_stat.lo, "d");
3917 3917
3918 DUMP_VAR(msg_free_stat.value, d); 3918 DUMP_VAR(msg_free_stat.value, "d");
3919 DUMP_VAR(msg_free_stat.lo, d); 3919 DUMP_VAR(msg_free_stat.lo, "d");
3920 3920
3921 DUMP_VAR(msg_pend_stat.value, d); 3921 DUMP_VAR(msg_pend_stat.value, "d");
3922 DUMP_VAR(msg_pend_stat.hi, d); 3922 DUMP_VAR(msg_pend_stat.hi, "d");
3923 3923
3924 DUMP_VAR(fw_pend_stat.value, d); 3924 DUMP_VAR(fw_pend_stat.value, "d");
3925 DUMP_VAR(fw_pend_stat.hi, d); 3925 DUMP_VAR(fw_pend_stat.hi, "d");
3926 3926
3927 DUMP_VAR(txq_stat.value, d); 3927 DUMP_VAR(txq_stat.value, "d");
3928 DUMP_VAR(txq_stat.lo, d); 3928 DUMP_VAR(txq_stat.lo, "d");
3929 3929
3930 DUMP_VAR(ieee->scans, d); 3930 DUMP_VAR(ieee->scans, "d");
3931 DUMP_VAR(reset_backoff, d); 3931 DUMP_VAR(reset_backoff, "d");
3932 3932
3933 return len; 3933 return len;
3934} 3934}
3935static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL);
3936 3935
3936static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL);
3937 3937
3938static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr, 3938static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
3939 char *buf) 3939 char *buf)
3940{ 3940{
3941 struct ipw2100_priv *priv = dev_get_drvdata(d); 3941 struct ipw2100_priv *priv = dev_get_drvdata(d);
3942 char essid[IW_ESSID_MAX_SIZE + 1]; 3942 char essid[IW_ESSID_MAX_SIZE + 1];
3943 u8 bssid[ETH_ALEN]; 3943 u8 bssid[ETH_ALEN];
3944 u32 chan = 0; 3944 u32 chan = 0;
3945 char * out = buf; 3945 char *out = buf;
3946 int length; 3946 int length;
3947 int ret; 3947 int ret;
3948 3948
3949 if (priv->status & STATUS_RF_KILL_MASK)
3950 return 0;
3951
3949 memset(essid, 0, sizeof(essid)); 3952 memset(essid, 0, sizeof(essid));
3950 memset(bssid, 0, sizeof(bssid)); 3953 memset(bssid, 0, sizeof(bssid));
3951 3954
@@ -3976,8 +3979,8 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
3976 3979
3977 return out - buf; 3980 return out - buf;
3978} 3981}
3979static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
3980 3982
3983static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
3981 3984
3982#ifdef CONFIG_IPW_DEBUG 3985#ifdef CONFIG_IPW_DEBUG
3983static ssize_t show_debug_level(struct device_driver *d, char *buf) 3986static ssize_t show_debug_level(struct device_driver *d, char *buf)
@@ -3985,8 +3988,8 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf)
3985 return sprintf(buf, "0x%08X\n", ipw2100_debug_level); 3988 return sprintf(buf, "0x%08X\n", ipw2100_debug_level);
3986} 3989}
3987 3990
3988static ssize_t store_debug_level(struct device_driver *d, const char *buf, 3991static ssize_t store_debug_level(struct device_driver *d,
3989 size_t count) 3992 const char *buf, size_t count)
3990{ 3993{
3991 char *p = (char *)buf; 3994 char *p = (char *)buf;
3992 u32 val; 3995 u32 val;
@@ -3999,28 +4002,26 @@ static ssize_t store_debug_level(struct device_driver *d, const char *buf,
3999 } else 4002 } else
4000 val = simple_strtoul(p, &p, 10); 4003 val = simple_strtoul(p, &p, 10);
4001 if (p == buf) 4004 if (p == buf)
4002 IPW_DEBUG_INFO(DRV_NAME 4005 IPW_DEBUG_INFO(": %s is not in hex or decimal form.\n", buf);
4003 ": %s is not in hex or decimal form.\n", buf);
4004 else 4006 else
4005 ipw2100_debug_level = val; 4007 ipw2100_debug_level = val;
4006 4008
4007 return strnlen(buf, count); 4009 return strnlen(buf, count);
4008} 4010}
4011
4009static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, 4012static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level,
4010 store_debug_level); 4013 store_debug_level);
4011#endif /* CONFIG_IPW_DEBUG */ 4014#endif /* CONFIG_IPW_DEBUG */
4012
4013 4015
4014static ssize_t show_fatal_error(struct device *d, 4016static ssize_t show_fatal_error(struct device *d,
4015 struct device_attribute *attr, char *buf) 4017 struct device_attribute *attr, char *buf)
4016{ 4018{
4017 struct ipw2100_priv *priv = dev_get_drvdata(d); 4019 struct ipw2100_priv *priv = dev_get_drvdata(d);
4018 char *out = buf; 4020 char *out = buf;
4019 int i; 4021 int i;
4020 4022
4021 if (priv->fatal_error) 4023 if (priv->fatal_error)
4022 out += sprintf(out, "0x%08X\n", 4024 out += sprintf(out, "0x%08X\n", priv->fatal_error);
4023 priv->fatal_error);
4024 else 4025 else
4025 out += sprintf(out, "0\n"); 4026 out += sprintf(out, "0\n");
4026 4027
@@ -4038,24 +4039,26 @@ static ssize_t show_fatal_error(struct device *d,
4038} 4039}
4039 4040
4040static ssize_t store_fatal_error(struct device *d, 4041static ssize_t store_fatal_error(struct device *d,
4041 struct device_attribute *attr, const char *buf, size_t count) 4042 struct device_attribute *attr, const char *buf,
4043 size_t count)
4042{ 4044{
4043 struct ipw2100_priv *priv = dev_get_drvdata(d); 4045 struct ipw2100_priv *priv = dev_get_drvdata(d);
4044 schedule_reset(priv); 4046 schedule_reset(priv);
4045 return count; 4047 return count;
4046} 4048}
4047static DEVICE_ATTR(fatal_error, S_IWUSR|S_IRUGO, show_fatal_error, store_fatal_error);
4048 4049
4050static DEVICE_ATTR(fatal_error, S_IWUSR | S_IRUGO, show_fatal_error,
4051 store_fatal_error);
4049 4052
4050static ssize_t show_scan_age(struct device *d, struct device_attribute *attr, 4053static ssize_t show_scan_age(struct device *d, struct device_attribute *attr,
4051 char *buf) 4054 char *buf)
4052{ 4055{
4053 struct ipw2100_priv *priv = dev_get_drvdata(d); 4056 struct ipw2100_priv *priv = dev_get_drvdata(d);
4054 return sprintf(buf, "%d\n", priv->ieee->scan_age); 4057 return sprintf(buf, "%d\n", priv->ieee->scan_age);
4055} 4058}
4056 4059
4057static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, 4060static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4058 const char *buf, size_t count) 4061 const char *buf, size_t count)
4059{ 4062{
4060 struct ipw2100_priv *priv = dev_get_drvdata(d); 4063 struct ipw2100_priv *priv = dev_get_drvdata(d);
4061 struct net_device *dev = priv->net_dev; 4064 struct net_device *dev = priv->net_dev;
@@ -4065,6 +4068,8 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4065 unsigned long val; 4068 unsigned long val;
4066 char *p = buffer; 4069 char *p = buffer;
4067 4070
4071 (void) dev; /* kill unused-var warning for debug-only code */
4072
4068 IPW_DEBUG_INFO("enter\n"); 4073 IPW_DEBUG_INFO("enter\n");
4069 4074
4070 strncpy(buffer, buf, len); 4075 strncpy(buffer, buf, len);
@@ -4078,8 +4083,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4078 } else 4083 } else
4079 val = simple_strtoul(p, &p, 10); 4084 val = simple_strtoul(p, &p, 10);
4080 if (p == buffer) { 4085 if (p == buffer) {
4081 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", 4086 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name);
4082 dev->name);
4083 } else { 4087 } else {
4084 priv->ieee->scan_age = val; 4088 priv->ieee->scan_age = val;
4085 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); 4089 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age);
@@ -4088,11 +4092,11 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4088 IPW_DEBUG_INFO("exit\n"); 4092 IPW_DEBUG_INFO("exit\n");
4089 return len; 4093 return len;
4090} 4094}
4091static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
4092 4095
4096static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
4093 4097
4094static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 4098static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
4095 char *buf) 4099 char *buf)
4096{ 4100{
4097 /* 0 - RF kill not enabled 4101 /* 0 - RF kill not enabled
4098 1 - SW based RF kill active (sysfs) 4102 1 - SW based RF kill active (sysfs)
@@ -4100,7 +4104,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
4100 3 - Both HW and SW baed RF kill active */ 4104 3 - Both HW and SW baed RF kill active */
4101 struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data; 4105 struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data;
4102 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | 4106 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
4103 (rf_kill_active(priv) ? 0x2 : 0x0); 4107 (rf_kill_active(priv) ? 0x2 : 0x0);
4104 return sprintf(buf, "%i\n", val); 4108 return sprintf(buf, "%i\n", val);
4105} 4109}
4106 4110
@@ -4108,7 +4112,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4108{ 4112{
4109 if ((disable_radio ? 1 : 0) == 4113 if ((disable_radio ? 1 : 0) ==
4110 (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) 4114 (priv->status & STATUS_RF_KILL_SW ? 1 : 0))
4111 return 0 ; 4115 return 0;
4112 4116
4113 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", 4117 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n",
4114 disable_radio ? "OFF" : "ON"); 4118 disable_radio ? "OFF" : "ON");
@@ -4126,8 +4130,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4126 /* Make sure the RF_KILL check timer is running */ 4130 /* Make sure the RF_KILL check timer is running */
4127 priv->stop_rf_kill = 0; 4131 priv->stop_rf_kill = 0;
4128 cancel_delayed_work(&priv->rf_kill); 4132 cancel_delayed_work(&priv->rf_kill);
4129 queue_delayed_work(priv->workqueue, &priv->rf_kill, 4133 queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ);
4130 HZ);
4131 } else 4134 } else
4132 schedule_reset(priv); 4135 schedule_reset(priv);
4133 } 4136 }
@@ -4137,14 +4140,14 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4137} 4140}
4138 4141
4139static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, 4142static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
4140 const char *buf, size_t count) 4143 const char *buf, size_t count)
4141{ 4144{
4142 struct ipw2100_priv *priv = dev_get_drvdata(d); 4145 struct ipw2100_priv *priv = dev_get_drvdata(d);
4143 ipw_radio_kill_sw(priv, buf[0] == '1'); 4146 ipw_radio_kill_sw(priv, buf[0] == '1');
4144 return count; 4147 return count;
4145} 4148}
4146static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill);
4147 4149
4150static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);
4148 4151
4149static struct attribute *ipw2100_sysfs_entries[] = { 4152static struct attribute *ipw2100_sysfs_entries[] = {
4150 &dev_attr_hardware.attr, 4153 &dev_attr_hardware.attr,
@@ -4168,7 +4171,6 @@ static struct attribute_group ipw2100_attribute_group = {
4168 .attrs = ipw2100_sysfs_entries, 4171 .attrs = ipw2100_sysfs_entries,
4169}; 4172};
4170 4173
4171
4172static int status_queue_allocate(struct ipw2100_priv *priv, int entries) 4174static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
4173{ 4175{
4174 struct ipw2100_status_queue *q = &priv->status_queue; 4176 struct ipw2100_status_queue *q = &priv->status_queue;
@@ -4176,11 +4178,11 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
4176 IPW_DEBUG_INFO("enter\n"); 4178 IPW_DEBUG_INFO("enter\n");
4177 4179
4178 q->size = entries * sizeof(struct ipw2100_status); 4180 q->size = entries * sizeof(struct ipw2100_status);
4179 q->drv = (struct ipw2100_status *)pci_alloc_consistent( 4181 q->drv =
4180 priv->pci_dev, q->size, &q->nic); 4182 (struct ipw2100_status *)pci_alloc_consistent(priv->pci_dev,
4183 q->size, &q->nic);
4181 if (!q->drv) { 4184 if (!q->drv) {
4182 IPW_DEBUG_WARNING( 4185 IPW_DEBUG_WARNING("Can not allocate status queue.\n");
4183 "Can not allocate status queue.\n");
4184 return -ENOMEM; 4186 return -ENOMEM;
4185 } 4187 }
4186 4188
@@ -4196,9 +4198,9 @@ static void status_queue_free(struct ipw2100_priv *priv)
4196 IPW_DEBUG_INFO("enter\n"); 4198 IPW_DEBUG_INFO("enter\n");
4197 4199
4198 if (priv->status_queue.drv) { 4200 if (priv->status_queue.drv) {
4199 pci_free_consistent( 4201 pci_free_consistent(priv->pci_dev, priv->status_queue.size,
4200 priv->pci_dev, priv->status_queue.size, 4202 priv->status_queue.drv,
4201 priv->status_queue.drv, priv->status_queue.nic); 4203 priv->status_queue.nic);
4202 priv->status_queue.drv = NULL; 4204 priv->status_queue.drv = NULL;
4203 } 4205 }
4204 4206
@@ -4216,7 +4218,8 @@ static int bd_queue_allocate(struct ipw2100_priv *priv,
4216 q->size = entries * sizeof(struct ipw2100_bd); 4218 q->size = entries * sizeof(struct ipw2100_bd);
4217 q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic); 4219 q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic);
4218 if (!q->drv) { 4220 if (!q->drv) {
4219 IPW_DEBUG_INFO("can't allocate shared memory for buffer descriptors\n"); 4221 IPW_DEBUG_INFO
4222 ("can't allocate shared memory for buffer descriptors\n");
4220 return -ENOMEM; 4223 return -ENOMEM;
4221 } 4224 }
4222 memset(q->drv, 0, q->size); 4225 memset(q->drv, 0, q->size);
@@ -4226,8 +4229,7 @@ static int bd_queue_allocate(struct ipw2100_priv *priv,
4226 return 0; 4229 return 0;
4227} 4230}
4228 4231
4229static void bd_queue_free(struct ipw2100_priv *priv, 4232static void bd_queue_free(struct ipw2100_priv *priv, struct ipw2100_bd_queue *q)
4230 struct ipw2100_bd_queue *q)
4231{ 4233{
4232 IPW_DEBUG_INFO("enter\n"); 4234 IPW_DEBUG_INFO("enter\n");
4233 4235
@@ -4235,21 +4237,21 @@ static void bd_queue_free(struct ipw2100_priv *priv,
4235 return; 4237 return;
4236 4238
4237 if (q->drv) { 4239 if (q->drv) {
4238 pci_free_consistent(priv->pci_dev, 4240 pci_free_consistent(priv->pci_dev, q->size, q->drv, q->nic);
4239 q->size, q->drv, q->nic);
4240 q->drv = NULL; 4241 q->drv = NULL;
4241 } 4242 }
4242 4243
4243 IPW_DEBUG_INFO("exit\n"); 4244 IPW_DEBUG_INFO("exit\n");
4244} 4245}
4245 4246
4246static void bd_queue_initialize( 4247static void bd_queue_initialize(struct ipw2100_priv *priv,
4247 struct ipw2100_priv *priv, struct ipw2100_bd_queue * q, 4248 struct ipw2100_bd_queue *q, u32 base, u32 size,
4248 u32 base, u32 size, u32 r, u32 w) 4249 u32 r, u32 w)
4249{ 4250{
4250 IPW_DEBUG_INFO("enter\n"); 4251 IPW_DEBUG_INFO("enter\n");
4251 4252
4252 IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, (u32)q->nic); 4253 IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv,
4254 (u32) q->nic);
4253 4255
4254 write_register(priv->net_dev, base, q->nic); 4256 write_register(priv->net_dev, base, q->nic);
4255 write_register(priv->net_dev, size, q->entries); 4257 write_register(priv->net_dev, size, q->entries);
@@ -4285,32 +4287,38 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
4285 err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH); 4287 err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH);
4286 if (err) { 4288 if (err) {
4287 IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n", 4289 IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n",
4288 priv->net_dev->name); 4290 priv->net_dev->name);
4289 return err; 4291 return err;
4290 } 4292 }
4291 4293
4292 priv->tx_buffers = (struct ipw2100_tx_packet *)kmalloc( 4294 priv->tx_buffers =
4293 TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet), 4295 (struct ipw2100_tx_packet *)kmalloc(TX_PENDED_QUEUE_LENGTH *
4294 GFP_ATOMIC); 4296 sizeof(struct
4297 ipw2100_tx_packet),
4298 GFP_ATOMIC);
4295 if (!priv->tx_buffers) { 4299 if (!priv->tx_buffers) {
4296 printk(KERN_ERR DRV_NAME ": %s: alloc failed form tx buffers.\n", 4300 printk(KERN_ERR DRV_NAME
4301 ": %s: alloc failed form tx buffers.\n",
4297 priv->net_dev->name); 4302 priv->net_dev->name);
4298 bd_queue_free(priv, &priv->tx_queue); 4303 bd_queue_free(priv, &priv->tx_queue);
4299 return -ENOMEM; 4304 return -ENOMEM;
4300 } 4305 }
4301 4306
4302 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { 4307 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4303 v = pci_alloc_consistent( 4308 v = pci_alloc_consistent(priv->pci_dev,
4304 priv->pci_dev, sizeof(struct ipw2100_data_header), &p); 4309 sizeof(struct ipw2100_data_header),
4310 &p);
4305 if (!v) { 4311 if (!v) {
4306 printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for tx " 4312 printk(KERN_ERR DRV_NAME
4307 "buffers.\n", priv->net_dev->name); 4313 ": %s: PCI alloc failed for tx " "buffers.\n",
4314 priv->net_dev->name);
4308 err = -ENOMEM; 4315 err = -ENOMEM;
4309 break; 4316 break;
4310 } 4317 }
4311 4318
4312 priv->tx_buffers[i].type = DATA; 4319 priv->tx_buffers[i].type = DATA;
4313 priv->tx_buffers[i].info.d_struct.data = (struct ipw2100_data_header*)v; 4320 priv->tx_buffers[i].info.d_struct.data =
4321 (struct ipw2100_data_header *)v;
4314 priv->tx_buffers[i].info.d_struct.data_phys = p; 4322 priv->tx_buffers[i].info.d_struct.data_phys = p;
4315 priv->tx_buffers[i].info.d_struct.txb = NULL; 4323 priv->tx_buffers[i].info.d_struct.txb = NULL;
4316 } 4324 }
@@ -4319,11 +4327,11 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
4319 return 0; 4327 return 0;
4320 4328
4321 for (j = 0; j < i; j++) { 4329 for (j = 0; j < i; j++) {
4322 pci_free_consistent( 4330 pci_free_consistent(priv->pci_dev,
4323 priv->pci_dev, 4331 sizeof(struct ipw2100_data_header),
4324 sizeof(struct ipw2100_data_header), 4332 priv->tx_buffers[j].info.d_struct.data,
4325 priv->tx_buffers[j].info.d_struct.data, 4333 priv->tx_buffers[j].info.d_struct.
4326 priv->tx_buffers[j].info.d_struct.data_phys); 4334 data_phys);
4327 } 4335 }
4328 4336
4329 kfree(priv->tx_buffers); 4337 kfree(priv->tx_buffers);
@@ -4356,7 +4364,8 @@ static void ipw2100_tx_initialize(struct ipw2100_priv *priv)
4356 /* We simply drop any SKBs that have been queued for 4364 /* We simply drop any SKBs that have been queued for
4357 * transmit */ 4365 * transmit */
4358 if (priv->tx_buffers[i].info.d_struct.txb) { 4366 if (priv->tx_buffers[i].info.d_struct.txb) {
4359 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); 4367 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.
4368 txb);
4360 priv->tx_buffers[i].info.d_struct.txb = NULL; 4369 priv->tx_buffers[i].info.d_struct.txb = NULL;
4361 } 4370 }
4362 4371
@@ -4394,15 +4403,17 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv)
4394 4403
4395 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { 4404 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4396 if (priv->tx_buffers[i].info.d_struct.txb) { 4405 if (priv->tx_buffers[i].info.d_struct.txb) {
4397 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); 4406 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.
4407 txb);
4398 priv->tx_buffers[i].info.d_struct.txb = NULL; 4408 priv->tx_buffers[i].info.d_struct.txb = NULL;
4399 } 4409 }
4400 if (priv->tx_buffers[i].info.d_struct.data) 4410 if (priv->tx_buffers[i].info.d_struct.data)
4401 pci_free_consistent( 4411 pci_free_consistent(priv->pci_dev,
4402 priv->pci_dev, 4412 sizeof(struct ipw2100_data_header),
4403 sizeof(struct ipw2100_data_header), 4413 priv->tx_buffers[i].info.d_struct.
4404 priv->tx_buffers[i].info.d_struct.data, 4414 data,
4405 priv->tx_buffers[i].info.d_struct.data_phys); 4415 priv->tx_buffers[i].info.d_struct.
4416 data_phys);
4406 } 4417 }
4407 4418
4408 kfree(priv->tx_buffers); 4419 kfree(priv->tx_buffers);
@@ -4411,8 +4422,6 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv)
4411 IPW_DEBUG_INFO("exit\n"); 4422 IPW_DEBUG_INFO("exit\n");
4412} 4423}
4413 4424
4414
4415
4416static int ipw2100_rx_allocate(struct ipw2100_priv *priv) 4425static int ipw2100_rx_allocate(struct ipw2100_priv *priv)
4417{ 4426{
4418 int i, j, err = -EINVAL; 4427 int i, j, err = -EINVAL;
@@ -4542,14 +4551,13 @@ static int ipw2100_read_mac_address(struct ipw2100_priv *priv)
4542 4551
4543 int err; 4552 int err;
4544 4553
4545 err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, 4554 err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, mac, &length);
4546 mac, &length);
4547 if (err) { 4555 if (err) {
4548 IPW_DEBUG_INFO("MAC address read failed\n"); 4556 IPW_DEBUG_INFO("MAC address read failed\n");
4549 return -EIO; 4557 return -EIO;
4550 } 4558 }
4551 IPW_DEBUG_INFO("card MAC is %02X:%02X:%02X:%02X:%02X:%02X\n", 4559 IPW_DEBUG_INFO("card MAC is %02X:%02X:%02X:%02X:%02X:%02X\n",
4552 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 4560 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
4553 4561
4554 memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN); 4562 memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN);
4555 4563
@@ -4576,8 +4584,7 @@ static int ipw2100_set_mac_address(struct ipw2100_priv *priv, int batch_mode)
4576 IPW_DEBUG_INFO("enter\n"); 4584 IPW_DEBUG_INFO("enter\n");
4577 4585
4578 if (priv->config & CFG_CUSTOM_MAC) { 4586 if (priv->config & CFG_CUSTOM_MAC) {
4579 memcpy(cmd.host_command_parameters, priv->mac_addr, 4587 memcpy(cmd.host_command_parameters, priv->mac_addr, ETH_ALEN);
4580 ETH_ALEN);
4581 memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN); 4588 memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
4582 } else 4589 } else
4583 memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr, 4590 memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr,
@@ -4614,7 +4621,8 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type,
4614 if (!batch_mode) { 4621 if (!batch_mode) {
4615 err = ipw2100_disable_adapter(priv); 4622 err = ipw2100_disable_adapter(priv);
4616 if (err) { 4623 if (err) {
4617 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 4624 printk(KERN_ERR DRV_NAME
4625 ": %s: Could not disable adapter %d\n",
4618 priv->net_dev->name, err); 4626 priv->net_dev->name, err);
4619 return err; 4627 return err;
4620 } 4628 }
@@ -4629,7 +4637,6 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type,
4629 return err; 4637 return err;
4630} 4638}
4631 4639
4632
4633static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel, 4640static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel,
4634 int batch_mode) 4641 int batch_mode)
4635{ 4642{
@@ -4660,8 +4667,7 @@ static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel,
4660 4667
4661 err = ipw2100_hw_send_command(priv, &cmd); 4668 err = ipw2100_hw_send_command(priv, &cmd);
4662 if (err) { 4669 if (err) {
4663 IPW_DEBUG_INFO("Failed to set channel to %d", 4670 IPW_DEBUG_INFO("Failed to set channel to %d", channel);
4664 channel);
4665 return err; 4671 return err;
4666 } 4672 }
4667 4673
@@ -4703,15 +4709,14 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)
4703 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START; 4709 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START;
4704 4710
4705 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK | 4711 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK |
4706 IPW_CFG_BSS_MASK | 4712 IPW_CFG_BSS_MASK | IPW_CFG_802_1x_ENABLE;
4707 IPW_CFG_802_1x_ENABLE;
4708 4713
4709 if (!(priv->config & CFG_LONG_PREAMBLE)) 4714 if (!(priv->config & CFG_LONG_PREAMBLE))
4710 cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO; 4715 cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO;
4711 4716
4712 err = ipw2100_get_ordinal(priv, 4717 err = ipw2100_get_ordinal(priv,
4713 IPW_ORD_EEPROM_IBSS_11B_CHANNELS, 4718 IPW_ORD_EEPROM_IBSS_11B_CHANNELS,
4714 &ibss_mask, &len); 4719 &ibss_mask, &len);
4715 if (err) 4720 if (err)
4716 ibss_mask = IPW_IBSS_11B_DEFAULT_MASK; 4721 ibss_mask = IPW_IBSS_11B_DEFAULT_MASK;
4717 4722
@@ -4719,7 +4724,7 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)
4719 cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask; 4724 cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask;
4720 4725
4721 /* 11b only */ 4726 /* 11b only */
4722 /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A;*/ 4727 /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A; */
4723 4728
4724 err = ipw2100_hw_send_command(priv, &cmd); 4729 err = ipw2100_hw_send_command(priv, &cmd);
4725 if (err) 4730 if (err)
@@ -4783,8 +4788,7 @@ static int ipw2100_set_tx_rates(struct ipw2100_priv *priv, u32 rate,
4783 return 0; 4788 return 0;
4784} 4789}
4785 4790
4786static int ipw2100_set_power_mode(struct ipw2100_priv *priv, 4791static int ipw2100_set_power_mode(struct ipw2100_priv *priv, int power_level)
4787 int power_level)
4788{ 4792{
4789 struct host_command cmd = { 4793 struct host_command cmd = {
4790 .host_command = POWER_MODE, 4794 .host_command = POWER_MODE,
@@ -4805,11 +4809,10 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv,
4805 priv->power_mode = IPW_POWER_ENABLED | power_level; 4809 priv->power_mode = IPW_POWER_ENABLED | power_level;
4806 4810
4807#ifdef CONFIG_IPW2100_TX_POWER 4811#ifdef CONFIG_IPW2100_TX_POWER
4808 if (priv->port_type == IBSS && 4812 if (priv->port_type == IBSS && priv->adhoc_power != DFTL_IBSS_TX_POWER) {
4809 priv->adhoc_power != DFTL_IBSS_TX_POWER) {
4810 /* Set beacon interval */ 4813 /* Set beacon interval */
4811 cmd.host_command = TX_POWER_INDEX; 4814 cmd.host_command = TX_POWER_INDEX;
4812 cmd.host_command_parameters[0] = (u32)priv->adhoc_power; 4815 cmd.host_command_parameters[0] = (u32) priv->adhoc_power;
4813 4816
4814 err = ipw2100_hw_send_command(priv, &cmd); 4817 err = ipw2100_hw_send_command(priv, &cmd);
4815 if (err) 4818 if (err)
@@ -4820,7 +4823,6 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv,
4820 return 0; 4823 return 0;
4821} 4824}
4822 4825
4823
4824static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold) 4826static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold)
4825{ 4827{
4826 struct host_command cmd = { 4828 struct host_command cmd = {
@@ -4925,8 +4927,7 @@ static int ipw2100_set_long_retry(struct ipw2100_priv *priv, u32 retry)
4925 return 0; 4927 return 0;
4926} 4928}
4927 4929
4928 4930static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 * bssid,
4929static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
4930 int batch_mode) 4931 int batch_mode)
4931{ 4932{
4932 struct host_command cmd = { 4933 struct host_command cmd = {
@@ -4938,16 +4939,15 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
4938 4939
4939#ifdef CONFIG_IPW_DEBUG 4940#ifdef CONFIG_IPW_DEBUG
4940 if (bssid != NULL) 4941 if (bssid != NULL)
4941 IPW_DEBUG_HC( 4942 IPW_DEBUG_HC("MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n",
4942 "MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", 4943 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4],
4943 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], 4944 bssid[5]);
4944 bssid[5]);
4945 else 4945 else
4946 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n"); 4946 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n");
4947#endif 4947#endif
4948 /* if BSSID is empty then we disable mandatory bssid mode */ 4948 /* if BSSID is empty then we disable mandatory bssid mode */
4949 if (bssid != NULL) 4949 if (bssid != NULL)
4950 memcpy((u8 *)cmd.host_command_parameters, bssid, ETH_ALEN); 4950 memcpy(cmd.host_command_parameters, bssid, ETH_ALEN);
4951 4951
4952 if (!batch_mode) { 4952 if (!batch_mode) {
4953 err = ipw2100_disable_adapter(priv); 4953 err = ipw2100_disable_adapter(priv);
@@ -4963,7 +4963,6 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
4963 return err; 4963 return err;
4964} 4964}
4965 4965
4966#ifdef CONFIG_IEEE80211_WPA
4967static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv) 4966static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv)
4968{ 4967{
4969 struct host_command cmd = { 4968 struct host_command cmd = {
@@ -4987,42 +4986,10 @@ static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv)
4987 4986
4988 return err; 4987 return err;
4989} 4988}
4990#endif
4991
4992/*
4993 * Pseudo code for setting up wpa_frame:
4994 */
4995#if 0
4996void x(struct ieee80211_assoc_frame *wpa_assoc)
4997{
4998 struct ipw2100_wpa_assoc_frame frame;
4999 frame->fixed_ie_mask = IPW_WPA_CAPABILTIES |
5000 IPW_WPA_LISTENINTERVAL |
5001 IPW_WPA_AP_ADDRESS;
5002 frame->capab_info = wpa_assoc->capab_info;
5003 frame->lisen_interval = wpa_assoc->listent_interval;
5004 memcpy(frame->current_ap, wpa_assoc->current_ap, ETH_ALEN);
5005
5006 /* UNKNOWN -- I'm not postivive about this part; don't have any WPA
5007 * setup here to test it with.
5008 *
5009 * Walk the IEs in the wpa_assoc and figure out the total size of all
5010 * that data. Stick that into frame->var_ie_len. Then memcpy() all of
5011 * the IEs from wpa_frame into frame.
5012 */
5013 frame->var_ie_len = calculate_ie_len(wpa_assoc);
5014 memcpy(frame->var_ie, wpa_assoc->variable, frame->var_ie_len);
5015
5016 ipw2100_set_wpa_ie(priv, &frame, 0);
5017}
5018#endif
5019
5020
5021
5022 4989
5023static int ipw2100_set_wpa_ie(struct ipw2100_priv *, 4990static int ipw2100_set_wpa_ie(struct ipw2100_priv *,
5024 struct ipw2100_wpa_assoc_frame *, int) 4991 struct ipw2100_wpa_assoc_frame *, int)
5025__attribute__ ((unused)); 4992 __attribute__ ((unused));
5026 4993
5027static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv, 4994static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv,
5028 struct ipw2100_wpa_assoc_frame *wpa_frame, 4995 struct ipw2100_wpa_assoc_frame *wpa_frame,
@@ -5076,7 +5043,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5076 .host_command_length = sizeof(struct security_info_params) 5043 .host_command_length = sizeof(struct security_info_params)
5077 }; 5044 };
5078 struct security_info_params *security = 5045 struct security_info_params *security =
5079 (struct security_info_params *)&cmd.host_command_parameters; 5046 (struct security_info_params *)&cmd.host_command_parameters;
5080 int err; 5047 int err;
5081 memset(security, 0, sizeof(*security)); 5048 memset(security, 0, sizeof(*security));
5082 5049
@@ -5094,25 +5061,25 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5094 break; 5061 break;
5095 case SEC_LEVEL_1: 5062 case SEC_LEVEL_1:
5096 security->allowed_ciphers = IPW_WEP40_CIPHER | 5063 security->allowed_ciphers = IPW_WEP40_CIPHER |
5097 IPW_WEP104_CIPHER; 5064 IPW_WEP104_CIPHER;
5098 break; 5065 break;
5099 case SEC_LEVEL_2: 5066 case SEC_LEVEL_2:
5100 security->allowed_ciphers = IPW_WEP40_CIPHER | 5067 security->allowed_ciphers = IPW_WEP40_CIPHER |
5101 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER; 5068 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER;
5102 break; 5069 break;
5103 case SEC_LEVEL_2_CKIP: 5070 case SEC_LEVEL_2_CKIP:
5104 security->allowed_ciphers = IPW_WEP40_CIPHER | 5071 security->allowed_ciphers = IPW_WEP40_CIPHER |
5105 IPW_WEP104_CIPHER | IPW_CKIP_CIPHER; 5072 IPW_WEP104_CIPHER | IPW_CKIP_CIPHER;
5106 break; 5073 break;
5107 case SEC_LEVEL_3: 5074 case SEC_LEVEL_3:
5108 security->allowed_ciphers = IPW_WEP40_CIPHER | 5075 security->allowed_ciphers = IPW_WEP40_CIPHER |
5109 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER; 5076 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER;
5110 break; 5077 break;
5111 } 5078 }
5112 5079
5113 IPW_DEBUG_HC( 5080 IPW_DEBUG_HC
5114 "SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n", 5081 ("SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n",
5115 security->auth_mode, security->allowed_ciphers, security_level); 5082 security->auth_mode, security->allowed_ciphers, security_level);
5116 5083
5117 security->replay_counters_number = 0; 5084 security->replay_counters_number = 0;
5118 5085
@@ -5130,8 +5097,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5130 return err; 5097 return err;
5131} 5098}
5132 5099
5133static int ipw2100_set_tx_power(struct ipw2100_priv *priv, 5100static int ipw2100_set_tx_power(struct ipw2100_priv *priv, u32 tx_power)
5134 u32 tx_power)
5135{ 5101{
5136 struct host_command cmd = { 5102 struct host_command cmd = {
5137 .host_command = TX_POWER_INDEX, 5103 .host_command = TX_POWER_INDEX,
@@ -5140,6 +5106,10 @@ static int ipw2100_set_tx_power(struct ipw2100_priv *priv,
5140 }; 5106 };
5141 int err = 0; 5107 int err = 0;
5142 5108
5109 if (tx_power != IPW_TX_POWER_DEFAULT)
5110 tx_power = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 /
5111 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
5112
5143 cmd.host_command_parameters[0] = tx_power; 5113 cmd.host_command_parameters[0] = tx_power;
5144 5114
5145 if (priv->ieee->iw_mode == IW_MODE_ADHOC) 5115 if (priv->ieee->iw_mode == IW_MODE_ADHOC)
@@ -5185,7 +5155,6 @@ static int ipw2100_set_ibss_beacon_interval(struct ipw2100_priv *priv,
5185 return 0; 5155 return 0;
5186} 5156}
5187 5157
5188
5189void ipw2100_queues_initialize(struct ipw2100_priv *priv) 5158void ipw2100_queues_initialize(struct ipw2100_priv *priv)
5190{ 5159{
5191 ipw2100_tx_initialize(priv); 5160 ipw2100_tx_initialize(priv);
@@ -5203,13 +5172,12 @@ void ipw2100_queues_free(struct ipw2100_priv *priv)
5203int ipw2100_queues_allocate(struct ipw2100_priv *priv) 5172int ipw2100_queues_allocate(struct ipw2100_priv *priv)
5204{ 5173{
5205 if (ipw2100_tx_allocate(priv) || 5174 if (ipw2100_tx_allocate(priv) ||
5206 ipw2100_rx_allocate(priv) || 5175 ipw2100_rx_allocate(priv) || ipw2100_msg_allocate(priv))
5207 ipw2100_msg_allocate(priv))
5208 goto fail; 5176 goto fail;
5209 5177
5210 return 0; 5178 return 0;
5211 5179
5212 fail: 5180 fail:
5213 ipw2100_tx_free(priv); 5181 ipw2100_tx_free(priv);
5214 ipw2100_rx_free(priv); 5182 ipw2100_rx_free(priv);
5215 ipw2100_msg_free(priv); 5183 ipw2100_msg_free(priv);
@@ -5235,7 +5203,8 @@ static int ipw2100_set_wep_flags(struct ipw2100_priv *priv, u32 flags,
5235 if (!batch_mode) { 5203 if (!batch_mode) {
5236 err = ipw2100_disable_adapter(priv); 5204 err = ipw2100_disable_adapter(priv);
5237 if (err) { 5205 if (err) {
5238 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5206 printk(KERN_ERR DRV_NAME
5207 ": %s: Could not disable adapter %d\n",
5239 priv->net_dev->name, err); 5208 priv->net_dev->name, err);
5240 return err; 5209 return err;
5241 } 5210 }
@@ -5262,7 +5231,6 @@ struct ipw2100_wep_key {
5262#define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4] 5231#define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4]
5263#define WEP_STR_128(x) x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10] 5232#define WEP_STR_128(x) x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10]
5264 5233
5265
5266/** 5234/**
5267 * Set a the wep key 5235 * Set a the wep key
5268 * 5236 *
@@ -5287,11 +5255,11 @@ static int ipw2100_set_key(struct ipw2100_priv *priv,
5287 .host_command_sequence = 0, 5255 .host_command_sequence = 0,
5288 .host_command_length = sizeof(struct ipw2100_wep_key), 5256 .host_command_length = sizeof(struct ipw2100_wep_key),
5289 }; 5257 };
5290 struct ipw2100_wep_key *wep_key = (void*)cmd.host_command_parameters; 5258 struct ipw2100_wep_key *wep_key = (void *)cmd.host_command_parameters;
5291 int err; 5259 int err;
5292 5260
5293 IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n", 5261 IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n",
5294 idx, keylen, len); 5262 idx, keylen, len);
5295 5263
5296 /* NOTE: We don't check cached values in case the firmware was reset 5264 /* NOTE: We don't check cached values in case the firmware was reset
5297 * or some other problem is occuring. If the user is setting the key, 5265 * or some other problem is occuring. If the user is setting the key,
@@ -5308,22 +5276,23 @@ static int ipw2100_set_key(struct ipw2100_priv *priv,
5308 /* Will be optimized out on debug not being configured in */ 5276 /* Will be optimized out on debug not being configured in */
5309 if (keylen == 0) 5277 if (keylen == 0)
5310 IPW_DEBUG_WEP("%s: Clearing key %d\n", 5278 IPW_DEBUG_WEP("%s: Clearing key %d\n",
5311 priv->net_dev->name, wep_key->idx); 5279 priv->net_dev->name, wep_key->idx);
5312 else if (keylen == 5) 5280 else if (keylen == 5)
5313 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n", 5281 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n",
5314 priv->net_dev->name, wep_key->idx, wep_key->len, 5282 priv->net_dev->name, wep_key->idx, wep_key->len,
5315 WEP_STR_64(wep_key->key)); 5283 WEP_STR_64(wep_key->key));
5316 else 5284 else
5317 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128 5285 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128
5318 "\n", 5286 "\n",
5319 priv->net_dev->name, wep_key->idx, wep_key->len, 5287 priv->net_dev->name, wep_key->idx, wep_key->len,
5320 WEP_STR_128(wep_key->key)); 5288 WEP_STR_128(wep_key->key));
5321 5289
5322 if (!batch_mode) { 5290 if (!batch_mode) {
5323 err = ipw2100_disable_adapter(priv); 5291 err = ipw2100_disable_adapter(priv);
5324 /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */ 5292 /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */
5325 if (err) { 5293 if (err) {
5326 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5294 printk(KERN_ERR DRV_NAME
5295 ": %s: Could not disable adapter %d\n",
5327 priv->net_dev->name, err); 5296 priv->net_dev->name, err);
5328 return err; 5297 return err;
5329 } 5298 }
@@ -5347,7 +5316,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5347 .host_command = WEP_KEY_INDEX, 5316 .host_command = WEP_KEY_INDEX,
5348 .host_command_sequence = 0, 5317 .host_command_sequence = 0,
5349 .host_command_length = 4, 5318 .host_command_length = 4,
5350 .host_command_parameters = { idx }, 5319 .host_command_parameters = {idx},
5351 }; 5320 };
5352 int err; 5321 int err;
5353 5322
@@ -5359,7 +5328,8 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5359 if (!batch_mode) { 5328 if (!batch_mode) {
5360 err = ipw2100_disable_adapter(priv); 5329 err = ipw2100_disable_adapter(priv);
5361 if (err) { 5330 if (err) {
5362 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5331 printk(KERN_ERR DRV_NAME
5332 ": %s: Could not disable adapter %d\n",
5363 priv->net_dev->name, err); 5333 priv->net_dev->name, err);
5364 return err; 5334 return err;
5365 } 5335 }
@@ -5374,9 +5344,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5374 return err; 5344 return err;
5375} 5345}
5376 5346
5377 5347static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
5378static int ipw2100_configure_security(struct ipw2100_priv *priv,
5379 int batch_mode)
5380{ 5348{
5381 int i, err, auth_mode, sec_level, use_group; 5349 int i, err, auth_mode, sec_level, use_group;
5382 5350
@@ -5389,40 +5357,42 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv,
5389 return err; 5357 return err;
5390 } 5358 }
5391 5359
5392 if (!priv->sec.enabled) { 5360 if (!priv->ieee->sec.enabled) {
5393 err = ipw2100_set_security_information( 5361 err =
5394 priv, IPW_AUTH_OPEN, SEC_LEVEL_0, 0, 1); 5362 ipw2100_set_security_information(priv, IPW_AUTH_OPEN,
5363 SEC_LEVEL_0, 0, 1);
5395 } else { 5364 } else {
5396 auth_mode = IPW_AUTH_OPEN; 5365 auth_mode = IPW_AUTH_OPEN;
5397 if ((priv->sec.flags & SEC_AUTH_MODE) && 5366 if ((priv->ieee->sec.flags & SEC_AUTH_MODE) &&
5398 (priv->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) 5367 (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY))
5399 auth_mode = IPW_AUTH_SHARED; 5368 auth_mode = IPW_AUTH_SHARED;
5400 5369
5401 sec_level = SEC_LEVEL_0; 5370 sec_level = SEC_LEVEL_0;
5402 if (priv->sec.flags & SEC_LEVEL) 5371 if (priv->ieee->sec.flags & SEC_LEVEL)
5403 sec_level = priv->sec.level; 5372 sec_level = priv->ieee->sec.level;
5404 5373
5405 use_group = 0; 5374 use_group = 0;
5406 if (priv->sec.flags & SEC_UNICAST_GROUP) 5375 if (priv->ieee->sec.flags & SEC_UNICAST_GROUP)
5407 use_group = priv->sec.unicast_uses_group; 5376 use_group = priv->ieee->sec.unicast_uses_group;
5408 5377
5409 err = ipw2100_set_security_information( 5378 err =
5410 priv, auth_mode, sec_level, use_group, 1); 5379 ipw2100_set_security_information(priv, auth_mode, sec_level,
5380 use_group, 1);
5411 } 5381 }
5412 5382
5413 if (err) 5383 if (err)
5414 goto exit; 5384 goto exit;
5415 5385
5416 if (priv->sec.enabled) { 5386 if (priv->ieee->sec.enabled) {
5417 for (i = 0; i < 4; i++) { 5387 for (i = 0; i < 4; i++) {
5418 if (!(priv->sec.flags & (1 << i))) { 5388 if (!(priv->ieee->sec.flags & (1 << i))) {
5419 memset(priv->sec.keys[i], 0, WEP_KEY_LEN); 5389 memset(priv->ieee->sec.keys[i], 0, WEP_KEY_LEN);
5420 priv->sec.key_sizes[i] = 0; 5390 priv->ieee->sec.key_sizes[i] = 0;
5421 } else { 5391 } else {
5422 err = ipw2100_set_key(priv, i, 5392 err = ipw2100_set_key(priv, i,
5423 priv->sec.keys[i], 5393 priv->ieee->sec.keys[i],
5424 priv->sec.key_sizes[i], 5394 priv->ieee->sec.
5425 1); 5395 key_sizes[i], 1);
5426 if (err) 5396 if (err)
5427 goto exit; 5397 goto exit;
5428 } 5398 }
@@ -5433,14 +5403,16 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv,
5433 5403
5434 /* Always enable privacy so the Host can filter WEP packets if 5404 /* Always enable privacy so the Host can filter WEP packets if
5435 * encrypted data is sent up */ 5405 * encrypted data is sent up */
5436 err = ipw2100_set_wep_flags( 5406 err =
5437 priv, priv->sec.enabled ? IPW_PRIVACY_CAPABLE : 0, 1); 5407 ipw2100_set_wep_flags(priv,
5408 priv->ieee->sec.
5409 enabled ? IPW_PRIVACY_CAPABLE : 0, 1);
5438 if (err) 5410 if (err)
5439 goto exit; 5411 goto exit;
5440 5412
5441 priv->status &= ~STATUS_SECURITY_UPDATED; 5413 priv->status &= ~STATUS_SECURITY_UPDATED;
5442 5414
5443 exit: 5415 exit:
5444 if (!batch_mode) 5416 if (!batch_mode)
5445 ipw2100_enable_adapter(priv); 5417 ipw2100_enable_adapter(priv);
5446 5418
@@ -5469,60 +5441,64 @@ static void shim__set_security(struct net_device *dev,
5469 5441
5470 for (i = 0; i < 4; i++) { 5442 for (i = 0; i < 4; i++) {
5471 if (sec->flags & (1 << i)) { 5443 if (sec->flags & (1 << i)) {
5472 priv->sec.key_sizes[i] = sec->key_sizes[i]; 5444 priv->ieee->sec.key_sizes[i] = sec->key_sizes[i];
5473 if (sec->key_sizes[i] == 0) 5445 if (sec->key_sizes[i] == 0)
5474 priv->sec.flags &= ~(1 << i); 5446 priv->ieee->sec.flags &= ~(1 << i);
5475 else 5447 else
5476 memcpy(priv->sec.keys[i], sec->keys[i], 5448 memcpy(priv->ieee->sec.keys[i], sec->keys[i],
5477 sec->key_sizes[i]); 5449 sec->key_sizes[i]);
5478 priv->sec.flags |= (1 << i); 5450 if (sec->level == SEC_LEVEL_1) {
5479 priv->status |= STATUS_SECURITY_UPDATED; 5451 priv->ieee->sec.flags |= (1 << i);
5452 priv->status |= STATUS_SECURITY_UPDATED;
5453 } else
5454 priv->ieee->sec.flags &= ~(1 << i);
5480 } 5455 }
5481 } 5456 }
5482 5457
5483 if ((sec->flags & SEC_ACTIVE_KEY) && 5458 if ((sec->flags & SEC_ACTIVE_KEY) &&
5484 priv->sec.active_key != sec->active_key) { 5459 priv->ieee->sec.active_key != sec->active_key) {
5485 if (sec->active_key <= 3) { 5460 if (sec->active_key <= 3) {
5486 priv->sec.active_key = sec->active_key; 5461 priv->ieee->sec.active_key = sec->active_key;
5487 priv->sec.flags |= SEC_ACTIVE_KEY; 5462 priv->ieee->sec.flags |= SEC_ACTIVE_KEY;
5488 } else 5463 } else
5489 priv->sec.flags &= ~SEC_ACTIVE_KEY; 5464 priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY;
5490 5465
5491 priv->status |= STATUS_SECURITY_UPDATED; 5466 priv->status |= STATUS_SECURITY_UPDATED;
5492 } 5467 }
5493 5468
5494 if ((sec->flags & SEC_AUTH_MODE) && 5469 if ((sec->flags & SEC_AUTH_MODE) &&
5495 (priv->sec.auth_mode != sec->auth_mode)) { 5470 (priv->ieee->sec.auth_mode != sec->auth_mode)) {
5496 priv->sec.auth_mode = sec->auth_mode; 5471 priv->ieee->sec.auth_mode = sec->auth_mode;
5497 priv->sec.flags |= SEC_AUTH_MODE; 5472 priv->ieee->sec.flags |= SEC_AUTH_MODE;
5498 priv->status |= STATUS_SECURITY_UPDATED; 5473 priv->status |= STATUS_SECURITY_UPDATED;
5499 } 5474 }
5500 5475
5501 if (sec->flags & SEC_ENABLED && 5476 if (sec->flags & SEC_ENABLED && priv->ieee->sec.enabled != sec->enabled) {
5502 priv->sec.enabled != sec->enabled) { 5477 priv->ieee->sec.flags |= SEC_ENABLED;
5503 priv->sec.flags |= SEC_ENABLED; 5478 priv->ieee->sec.enabled = sec->enabled;
5504 priv->sec.enabled = sec->enabled;
5505 priv->status |= STATUS_SECURITY_UPDATED; 5479 priv->status |= STATUS_SECURITY_UPDATED;
5506 force_update = 1; 5480 force_update = 1;
5507 } 5481 }
5508 5482
5509 if (sec->flags & SEC_LEVEL && 5483 if (sec->flags & SEC_ENCRYPT)
5510 priv->sec.level != sec->level) { 5484 priv->ieee->sec.encrypt = sec->encrypt;
5511 priv->sec.level = sec->level; 5485
5512 priv->sec.flags |= SEC_LEVEL; 5486 if (sec->flags & SEC_LEVEL && priv->ieee->sec.level != sec->level) {
5487 priv->ieee->sec.level = sec->level;
5488 priv->ieee->sec.flags |= SEC_LEVEL;
5513 priv->status |= STATUS_SECURITY_UPDATED; 5489 priv->status |= STATUS_SECURITY_UPDATED;
5514 } 5490 }
5515 5491
5516 IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n", 5492 IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n",
5517 priv->sec.flags & (1<<8) ? '1' : '0', 5493 priv->ieee->sec.flags & (1 << 8) ? '1' : '0',
5518 priv->sec.flags & (1<<7) ? '1' : '0', 5494 priv->ieee->sec.flags & (1 << 7) ? '1' : '0',
5519 priv->sec.flags & (1<<6) ? '1' : '0', 5495 priv->ieee->sec.flags & (1 << 6) ? '1' : '0',
5520 priv->sec.flags & (1<<5) ? '1' : '0', 5496 priv->ieee->sec.flags & (1 << 5) ? '1' : '0',
5521 priv->sec.flags & (1<<4) ? '1' : '0', 5497 priv->ieee->sec.flags & (1 << 4) ? '1' : '0',
5522 priv->sec.flags & (1<<3) ? '1' : '0', 5498 priv->ieee->sec.flags & (1 << 3) ? '1' : '0',
5523 priv->sec.flags & (1<<2) ? '1' : '0', 5499 priv->ieee->sec.flags & (1 << 2) ? '1' : '0',
5524 priv->sec.flags & (1<<1) ? '1' : '0', 5500 priv->ieee->sec.flags & (1 << 1) ? '1' : '0',
5525 priv->sec.flags & (1<<0) ? '1' : '0'); 5501 priv->ieee->sec.flags & (1 << 0) ? '1' : '0');
5526 5502
5527/* As a temporary work around to enable WPA until we figure out why 5503/* As a temporary work around to enable WPA until we figure out why
5528 * wpa_supplicant toggles the security capability of the driver, which 5504 * wpa_supplicant toggles the security capability of the driver, which
@@ -5531,7 +5507,7 @@ static void shim__set_security(struct net_device *dev,
5531 * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/ 5507 * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/
5532 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) 5508 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)))
5533 ipw2100_configure_security(priv, 0); 5509 ipw2100_configure_security(priv, 0);
5534done: 5510 done:
5535 up(&priv->action_sem); 5511 up(&priv->action_sem);
5536} 5512}
5537 5513
@@ -5556,7 +5532,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5556 5532
5557 return 0; 5533 return 0;
5558 } 5534 }
5559#endif /* CONFIG_IPW2100_MONITOR */ 5535#endif /* CONFIG_IPW2100_MONITOR */
5560 5536
5561 err = ipw2100_read_mac_address(priv); 5537 err = ipw2100_read_mac_address(priv);
5562 if (err) 5538 if (err)
@@ -5576,7 +5552,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5576 return err; 5552 return err;
5577 } 5553 }
5578 5554
5579 err = ipw2100_system_config(priv, batch_mode); 5555 err = ipw2100_system_config(priv, batch_mode);
5580 if (err) 5556 if (err)
5581 return err; 5557 return err;
5582 5558
@@ -5614,8 +5590,10 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5614 return err; 5590 return err;
5615 5591
5616 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 5592 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
5617 err = ipw2100_set_ibss_beacon_interval( 5593 err =
5618 priv, priv->beacon_interval, batch_mode); 5594 ipw2100_set_ibss_beacon_interval(priv,
5595 priv->beacon_interval,
5596 batch_mode);
5619 if (err) 5597 if (err)
5620 return err; 5598 return err;
5621 5599
@@ -5625,18 +5603,17 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5625 } 5603 }
5626 5604
5627 /* 5605 /*
5628 err = ipw2100_set_fragmentation_threshold( 5606 err = ipw2100_set_fragmentation_threshold(
5629 priv, priv->frag_threshold, batch_mode); 5607 priv, priv->frag_threshold, batch_mode);
5630 if (err) 5608 if (err)
5631 return err; 5609 return err;
5632 */ 5610 */
5633 5611
5634 IPW_DEBUG_INFO("exit\n"); 5612 IPW_DEBUG_INFO("exit\n");
5635 5613
5636 return 0; 5614 return 0;
5637} 5615}
5638 5616
5639
5640/************************************************************************* 5617/*************************************************************************
5641 * 5618 *
5642 * EXTERNALLY CALLED METHODS 5619 * EXTERNALLY CALLED METHODS
@@ -5669,7 +5646,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5669 ipw2100_reset_adapter(priv); 5646 ipw2100_reset_adapter(priv);
5670 return 0; 5647 return 0;
5671 5648
5672 done: 5649 done:
5673 up(&priv->action_sem); 5650 up(&priv->action_sem);
5674 return err; 5651 return err;
5675} 5652}
@@ -5708,7 +5685,7 @@ static int ipw2100_close(struct net_device *dev)
5708 /* Flush the TX queue ... */ 5685 /* Flush the TX queue ... */
5709 while (!list_empty(&priv->tx_pend_list)) { 5686 while (!list_empty(&priv->tx_pend_list)) {
5710 element = priv->tx_pend_list.next; 5687 element = priv->tx_pend_list.next;
5711 packet = list_entry(element, struct ipw2100_tx_packet, list); 5688 packet = list_entry(element, struct ipw2100_tx_packet, list);
5712 5689
5713 list_del(element); 5690 list_del(element);
5714 DEC_STAT(&priv->tx_pend_stat); 5691 DEC_STAT(&priv->tx_pend_stat);
@@ -5726,8 +5703,6 @@ static int ipw2100_close(struct net_device *dev)
5726 return 0; 5703 return 0;
5727} 5704}
5728 5705
5729
5730
5731/* 5706/*
5732 * TODO: Fix this function... its just wrong 5707 * TODO: Fix this function... its just wrong
5733 */ 5708 */
@@ -5747,7 +5722,6 @@ static void ipw2100_tx_timeout(struct net_device *dev)
5747 schedule_reset(priv); 5722 schedule_reset(priv);
5748} 5723}
5749 5724
5750
5751/* 5725/*
5752 * TODO: reimplement it so that it reads statistics 5726 * TODO: reimplement it so that it reads statistics
5753 * from the adapter using ordinal tables 5727 * from the adapter using ordinal tables
@@ -5761,11 +5735,10 @@ static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5761 return &priv->ieee->stats; 5735 return &priv->ieee->stats;
5762} 5736}
5763 5737
5764/* Support for wpa_supplicant. Will be replaced with WEXT once 5738#if WIRELESS_EXT < 18
5765 * they get WPA support. */ 5739/* Support for wpa_supplicant before WE-18, deprecated. */
5766#ifdef CONFIG_IEEE80211_WPA
5767 5740
5768/* following definitions must match definitions in driver_ipw2100.c */ 5741/* following definitions must match definitions in driver_ipw.c */
5769 5742
5770#define IPW2100_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 5743#define IPW2100_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
5771 5744
@@ -5796,25 +5769,26 @@ static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5796struct ipw2100_param { 5769struct ipw2100_param {
5797 u32 cmd; 5770 u32 cmd;
5798 u8 sta_addr[ETH_ALEN]; 5771 u8 sta_addr[ETH_ALEN];
5799 union { 5772 union {
5800 struct { 5773 struct {
5801 u8 name; 5774 u8 name;
5802 u32 value; 5775 u32 value;
5803 } wpa_param; 5776 } wpa_param;
5804 struct { 5777 struct {
5805 u32 len; 5778 u32 len;
5806 u8 *data; 5779 u8 reserved[32];
5780 u8 data[0];
5807 } wpa_ie; 5781 } wpa_ie;
5808 struct{ 5782 struct {
5809 int command; 5783 u32 command;
5810 int reason_code; 5784 u32 reason_code;
5811 } mlme; 5785 } mlme;
5812 struct { 5786 struct {
5813 u8 alg[IPW2100_CRYPT_ALG_NAME_LEN]; 5787 u8 alg[IPW2100_CRYPT_ALG_NAME_LEN];
5814 u8 set_tx; 5788 u8 set_tx;
5815 u32 err; 5789 u32 err;
5816 u8 idx; 5790 u8 idx;
5817 u8 seq[8]; /* sequence counter (set: RX, get: TX) */ 5791 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
5818 u16 key_len; 5792 u16 key_len;
5819 u8 key[0]; 5793 u8 key[0];
5820 } crypt; 5794 } crypt;
@@ -5822,38 +5796,24 @@ struct ipw2100_param {
5822 } u; 5796 } u;
5823}; 5797};
5824 5798
5825/* end of driver_ipw2100.c code */ 5799/* end of driver_ipw.c code */
5826 5800#endif /* WIRELESS_EXT < 18 */
5827static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value){
5828 5801
5829 struct ieee80211_device *ieee = priv->ieee; 5802static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
5830 struct ieee80211_security sec = { 5803{
5831 .flags = SEC_LEVEL | SEC_ENABLED, 5804 /* This is called when wpa_supplicant loads and closes the driver
5832 }; 5805 * interface. */
5833 int ret = 0; 5806 priv->ieee->wpa_enabled = value;
5834 5807 return 0;
5835 ieee->wpa_enabled = value;
5836
5837 if (value){
5838 sec.level = SEC_LEVEL_3;
5839 sec.enabled = 1;
5840 } else {
5841 sec.level = SEC_LEVEL_0;
5842 sec.enabled = 0;
5843 }
5844
5845 if (ieee->set_security)
5846 ieee->set_security(ieee->dev, &sec);
5847 else
5848 ret = -EOPNOTSUPP;
5849
5850 return ret;
5851} 5808}
5852 5809
5853#define AUTH_ALG_OPEN_SYSTEM 0x1 5810#if WIRELESS_EXT < 18
5854#define AUTH_ALG_SHARED_KEY 0x2 5811#define IW_AUTH_ALG_OPEN_SYSTEM 0x1
5812#define IW_AUTH_ALG_SHARED_KEY 0x2
5813#endif
5855 5814
5856static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){ 5815static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
5816{
5857 5817
5858 struct ieee80211_device *ieee = priv->ieee; 5818 struct ieee80211_device *ieee = priv->ieee;
5859 struct ieee80211_security sec = { 5819 struct ieee80211_security sec = {
@@ -5861,13 +5821,14 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){
5861 }; 5821 };
5862 int ret = 0; 5822 int ret = 0;
5863 5823
5864 if (value & AUTH_ALG_SHARED_KEY){ 5824 if (value & IW_AUTH_ALG_SHARED_KEY) {
5865 sec.auth_mode = WLAN_AUTH_SHARED_KEY; 5825 sec.auth_mode = WLAN_AUTH_SHARED_KEY;
5866 ieee->open_wep = 0; 5826 ieee->open_wep = 0;
5867 } else { 5827 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) {
5868 sec.auth_mode = WLAN_AUTH_OPEN; 5828 sec.auth_mode = WLAN_AUTH_OPEN;
5869 ieee->open_wep = 1; 5829 ieee->open_wep = 1;
5870 } 5830 } else
5831 return -EINVAL;
5871 5832
5872 if (ieee->set_security) 5833 if (ieee->set_security)
5873 ieee->set_security(ieee->dev, &sec); 5834 ieee->set_security(ieee->dev, &sec);
@@ -5877,103 +5838,135 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){
5877 return ret; 5838 return ret;
5878} 5839}
5879 5840
5841void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv,
5842 char *wpa_ie, int wpa_ie_len)
5843{
5880 5844
5881static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value){ 5845 struct ipw2100_wpa_assoc_frame frame;
5882
5883 struct ipw2100_priv *priv = ieee80211_priv(dev);
5884 int ret=0;
5885 5846
5886 switch(name){ 5847 frame.fixed_ie_mask = 0;
5887 case IPW2100_PARAM_WPA_ENABLED:
5888 ret = ipw2100_wpa_enable(priv, value);
5889 break;
5890 5848
5891 case IPW2100_PARAM_TKIP_COUNTERMEASURES: 5849 /* copy WPA IE */
5892 priv->ieee->tkip_countermeasures=value; 5850 memcpy(frame.var_ie, wpa_ie, wpa_ie_len);
5893 break; 5851 frame.var_ie_len = wpa_ie_len;
5894 5852
5895 case IPW2100_PARAM_DROP_UNENCRYPTED: 5853 /* make sure WPA is enabled */
5896 priv->ieee->drop_unencrypted=value; 5854 ipw2100_wpa_enable(priv, 1);
5897 break; 5855 ipw2100_set_wpa_ie(priv, &frame, 0);
5856}
5898 5857
5899 case IPW2100_PARAM_PRIVACY_INVOKED: 5858#if WIRELESS_EXT < 18
5900 priv->ieee->privacy_invoked=value; 5859static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value)
5901 break; 5860{
5861 struct ipw2100_priv *priv = ieee80211_priv(dev);
5862 struct ieee80211_crypt_data *crypt;
5863 unsigned long flags;
5864 int ret = 0;
5902 5865
5903 case IPW2100_PARAM_AUTH_ALGS: 5866 switch (name) {
5904 ret = ipw2100_wpa_set_auth_algs(priv, value); 5867 case IPW2100_PARAM_WPA_ENABLED:
5905 break; 5868 ret = ipw2100_wpa_enable(priv, value);
5869 break;
5906 5870
5907 case IPW2100_PARAM_IEEE_802_1X: 5871 case IPW2100_PARAM_TKIP_COUNTERMEASURES:
5908 priv->ieee->ieee802_1x=value; 5872 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
5873 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags)
5909 break; 5874 break;
5910 5875
5911 default: 5876 flags = crypt->ops->get_flags(crypt->priv);
5912 printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n",
5913 dev->name, name);
5914 ret = -EOPNOTSUPP;
5915 }
5916 5877
5917 return ret; 5878 if (value)
5918} 5879 flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
5880 else
5881 flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
5919 5882
5920static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason){ 5883 crypt->ops->set_flags(flags, crypt->priv);
5921 5884
5922 struct ipw2100_priv *priv = ieee80211_priv(dev); 5885 break;
5923 int ret=0;
5924 5886
5925 switch(command){ 5887 case IPW2100_PARAM_DROP_UNENCRYPTED:{
5926 case IPW2100_MLME_STA_DEAUTH: 5888 /* See IW_AUTH_DROP_UNENCRYPTED handling for details */
5927 // silently ignore 5889 struct ieee80211_security sec = {
5890 .flags = SEC_ENABLED,
5891 .enabled = value,
5892 };
5893 priv->ieee->drop_unencrypted = value;
5894 /* We only change SEC_LEVEL for open mode. Others
5895 * are set by ipw_wpa_set_encryption.
5896 */
5897 if (!value) {
5898 sec.flags |= SEC_LEVEL;
5899 sec.level = SEC_LEVEL_0;
5900 } else {
5901 sec.flags |= SEC_LEVEL;
5902 sec.level = SEC_LEVEL_1;
5903 }
5904 if (priv->ieee->set_security)
5905 priv->ieee->set_security(priv->ieee->dev, &sec);
5928 break; 5906 break;
5907 }
5929 5908
5930 case IPW2100_MLME_STA_DISASSOC: 5909 case IPW2100_PARAM_PRIVACY_INVOKED:
5931 ipw2100_disassociate_bssid(priv); 5910 priv->ieee->privacy_invoked = value;
5932 break; 5911 break;
5933 5912
5934 default: 5913 case IPW2100_PARAM_AUTH_ALGS:
5935 printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n", 5914 ret = ipw2100_wpa_set_auth_algs(priv, value);
5936 dev->name, command); 5915 break;
5937 ret = -EOPNOTSUPP; 5916
5917 case IPW2100_PARAM_IEEE_802_1X:
5918 priv->ieee->ieee802_1x = value;
5919 break;
5920
5921 default:
5922 printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n",
5923 dev->name, name);
5924 ret = -EOPNOTSUPP;
5938 } 5925 }
5939 5926
5940 return ret; 5927 return ret;
5941} 5928}
5942 5929
5930static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason)
5931{
5943 5932
5944void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, 5933 struct ipw2100_priv *priv = ieee80211_priv(dev);
5945 char *wpa_ie, int wpa_ie_len){ 5934 int ret = 0;
5946 5935
5947 struct ipw2100_wpa_assoc_frame frame; 5936 switch (command) {
5937 case IPW2100_MLME_STA_DEAUTH:
5938 // silently ignore
5939 break;
5948 5940
5949 frame.fixed_ie_mask = 0; 5941 case IPW2100_MLME_STA_DISASSOC:
5942 ipw2100_disassociate_bssid(priv);
5943 break;
5950 5944
5951 /* copy WPA IE */ 5945 default:
5952 memcpy(frame.var_ie, wpa_ie, wpa_ie_len); 5946 printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n",
5953 frame.var_ie_len = wpa_ie_len; 5947 dev->name, command);
5948 ret = -EOPNOTSUPP;
5949 }
5954 5950
5955 /* make sure WPA is enabled */ 5951 return ret;
5956 ipw2100_wpa_enable(priv, 1);
5957 ipw2100_set_wpa_ie(priv, &frame, 0);
5958} 5952}
5959 5953
5960
5961static int ipw2100_wpa_set_wpa_ie(struct net_device *dev, 5954static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
5962 struct ipw2100_param *param, int plen){ 5955 struct ipw2100_param *param, int plen)
5956{
5963 5957
5964 struct ipw2100_priv *priv = ieee80211_priv(dev); 5958 struct ipw2100_priv *priv = ieee80211_priv(dev);
5965 struct ieee80211_device *ieee = priv->ieee; 5959 struct ieee80211_device *ieee = priv->ieee;
5966 u8 *buf; 5960 u8 *buf;
5967 5961
5968 if (! ieee->wpa_enabled) 5962 if (!ieee->wpa_enabled)
5969 return -EOPNOTSUPP; 5963 return -EOPNOTSUPP;
5970 5964
5971 if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || 5965 if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
5972 (param->u.wpa_ie.len && 5966 (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
5973 param->u.wpa_ie.data==NULL))
5974 return -EINVAL; 5967 return -EINVAL;
5975 5968
5976 if (param->u.wpa_ie.len){ 5969 if (param->u.wpa_ie.len) {
5977 buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL); 5970 buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL);
5978 if (buf == NULL) 5971 if (buf == NULL)
5979 return -ENOMEM; 5972 return -ENOMEM;
@@ -5998,8 +5991,9 @@ static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
5998/* implementation borrowed from hostap driver */ 5991/* implementation borrowed from hostap driver */
5999 5992
6000static int ipw2100_wpa_set_encryption(struct net_device *dev, 5993static int ipw2100_wpa_set_encryption(struct net_device *dev,
6001 struct ipw2100_param *param, int param_len){ 5994 struct ipw2100_param *param,
6002 5995 int param_len)
5996{
6003 int ret = 0; 5997 int ret = 0;
6004 struct ipw2100_priv *priv = ieee80211_priv(dev); 5998 struct ipw2100_priv *priv = ieee80211_priv(dev);
6005 struct ieee80211_device *ieee = priv->ieee; 5999 struct ieee80211_device *ieee = priv->ieee;
@@ -6014,9 +6008,10 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6014 param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0'; 6008 param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0';
6015 6009
6016 if (param_len != 6010 if (param_len !=
6017 (int) ((char *) param->u.crypt.key - (char *) param) + 6011 (int)((char *)param->u.crypt.key - (char *)param) +
6018 param->u.crypt.key_len){ 6012 param->u.crypt.key_len) {
6019 IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); 6013 IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len,
6014 param->u.crypt.key_len);
6020 return -EINVAL; 6015 return -EINVAL;
6021 } 6016 }
6022 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && 6017 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
@@ -6029,17 +6024,19 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6029 return -EINVAL; 6024 return -EINVAL;
6030 } 6025 }
6031 6026
6027 sec.flags |= SEC_ENABLED | SEC_ENCRYPT;
6032 if (strcmp(param->u.crypt.alg, "none") == 0) { 6028 if (strcmp(param->u.crypt.alg, "none") == 0) {
6033 if (crypt){ 6029 if (crypt) {
6034 sec.enabled = 0; 6030 sec.enabled = 0;
6031 sec.encrypt = 0;
6035 sec.level = SEC_LEVEL_0; 6032 sec.level = SEC_LEVEL_0;
6036 sec.flags |= SEC_ENABLED | SEC_LEVEL; 6033 sec.flags |= SEC_LEVEL;
6037 ieee80211_crypt_delayed_deinit(ieee, crypt); 6034 ieee80211_crypt_delayed_deinit(ieee, crypt);
6038 } 6035 }
6039 goto done; 6036 goto done;
6040 } 6037 }
6041 sec.enabled = 1; 6038 sec.enabled = 1;
6042 sec.flags |= SEC_ENABLED; 6039 sec.encrypt = 1;
6043 6040
6044 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 6041 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
6045 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { 6042 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
@@ -6054,7 +6051,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6054 } 6051 }
6055 if (ops == NULL) { 6052 if (ops == NULL) {
6056 IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n", 6053 IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n",
6057 dev->name, param->u.crypt.alg); 6054 dev->name, param->u.crypt.alg);
6058 param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG; 6055 param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG;
6059 ret = -EINVAL; 6056 ret = -EINVAL;
6060 goto done; 6057 goto done;
@@ -6065,21 +6062,20 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6065 6062
6066 ieee80211_crypt_delayed_deinit(ieee, crypt); 6063 ieee80211_crypt_delayed_deinit(ieee, crypt);
6067 6064
6068 new_crypt = (struct ieee80211_crypt_data *) 6065 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL);
6069 kmalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL);
6070 if (new_crypt == NULL) { 6066 if (new_crypt == NULL) {
6071 ret = -ENOMEM; 6067 ret = -ENOMEM;
6072 goto done; 6068 goto done;
6073 } 6069 }
6074 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
6075 new_crypt->ops = ops; 6070 new_crypt->ops = ops;
6076 if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) 6071 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
6077 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); 6072 new_crypt->priv =
6073 new_crypt->ops->init(param->u.crypt.idx);
6078 6074
6079 if (new_crypt->priv == NULL) { 6075 if (new_crypt->priv == NULL) {
6080 kfree(new_crypt); 6076 kfree(new_crypt);
6081 param->u.crypt.err = 6077 param->u.crypt.err =
6082 IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED; 6078 IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED;
6083 ret = -EINVAL; 6079 ret = -EINVAL;
6084 goto done; 6080 goto done;
6085 } 6081 }
@@ -6091,24 +6087,25 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6091 (*crypt)->ops->set_key(param->u.crypt.key, 6087 (*crypt)->ops->set_key(param->u.crypt.key,
6092 param->u.crypt.key_len, param->u.crypt.seq, 6088 param->u.crypt.key_len, param->u.crypt.seq,
6093 (*crypt)->priv) < 0) { 6089 (*crypt)->priv) < 0) {
6094 IPW_DEBUG_INFO("%s: key setting failed\n", 6090 IPW_DEBUG_INFO("%s: key setting failed\n", dev->name);
6095 dev->name);
6096 param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED; 6091 param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED;
6097 ret = -EINVAL; 6092 ret = -EINVAL;
6098 goto done; 6093 goto done;
6099 } 6094 }
6100 6095
6101 if (param->u.crypt.set_tx){ 6096 if (param->u.crypt.set_tx) {
6102 ieee->tx_keyidx = param->u.crypt.idx; 6097 ieee->tx_keyidx = param->u.crypt.idx;
6103 sec.active_key = param->u.crypt.idx; 6098 sec.active_key = param->u.crypt.idx;
6104 sec.flags |= SEC_ACTIVE_KEY; 6099 sec.flags |= SEC_ACTIVE_KEY;
6105 } 6100 }
6106 6101
6107 if (ops->name != NULL){ 6102 if (ops->name != NULL) {
6108 6103
6109 if (strcmp(ops->name, "WEP") == 0) { 6104 if (strcmp(ops->name, "WEP") == 0) {
6110 memcpy(sec.keys[param->u.crypt.idx], param->u.crypt.key, param->u.crypt.key_len); 6105 memcpy(sec.keys[param->u.crypt.idx],
6111 sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len; 6106 param->u.crypt.key, param->u.crypt.key_len);
6107 sec.key_sizes[param->u.crypt.idx] =
6108 param->u.crypt.key_len;
6112 sec.flags |= (1 << param->u.crypt.idx); 6109 sec.flags |= (1 << param->u.crypt.idx);
6113 sec.flags |= SEC_LEVEL; 6110 sec.flags |= SEC_LEVEL;
6114 sec.level = SEC_LEVEL_1; 6111 sec.level = SEC_LEVEL_1;
@@ -6120,7 +6117,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6120 sec.level = SEC_LEVEL_3; 6117 sec.level = SEC_LEVEL_3;
6121 } 6118 }
6122 } 6119 }
6123 done: 6120 done:
6124 if (ieee->set_security) 6121 if (ieee->set_security)
6125 ieee->set_security(ieee->dev, &sec); 6122 ieee->set_security(ieee->dev, &sec);
6126 6123
@@ -6131,8 +6128,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6131 * the callbacks structures used to initialize the 802.11 stack. */ 6128 * the callbacks structures used to initialize the 802.11 stack. */
6132 if (ieee->reset_on_keychange && 6129 if (ieee->reset_on_keychange &&
6133 ieee->iw_mode != IW_MODE_INFRA && 6130 ieee->iw_mode != IW_MODE_INFRA &&
6134 ieee->reset_port && 6131 ieee->reset_port && ieee->reset_port(dev)) {
6135 ieee->reset_port(dev)) {
6136 IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name); 6132 IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name);
6137 param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED; 6133 param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED;
6138 return -EINVAL; 6134 return -EINVAL;
@@ -6141,11 +6137,11 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6141 return ret; 6137 return ret;
6142} 6138}
6143 6139
6144 6140static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p)
6145static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){ 6141{
6146 6142
6147 struct ipw2100_param *param; 6143 struct ipw2100_param *param;
6148 int ret=0; 6144 int ret = 0;
6149 6145
6150 IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length); 6146 IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length);
6151 6147
@@ -6156,12 +6152,12 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6156 if (param == NULL) 6152 if (param == NULL)
6157 return -ENOMEM; 6153 return -ENOMEM;
6158 6154
6159 if (copy_from_user(param, p->pointer, p->length)){ 6155 if (copy_from_user(param, p->pointer, p->length)) {
6160 kfree(param); 6156 kfree(param);
6161 return -EFAULT; 6157 return -EFAULT;
6162 } 6158 }
6163 6159
6164 switch (param->cmd){ 6160 switch (param->cmd) {
6165 6161
6166 case IPW2100_CMD_SET_WPA_PARAM: 6162 case IPW2100_CMD_SET_WPA_PARAM:
6167 ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name, 6163 ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name,
@@ -6182,8 +6178,9 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6182 break; 6178 break;
6183 6179
6184 default: 6180 default:
6185 printk(KERN_ERR DRV_NAME ": %s: Unknown WPA supplicant request: %d\n", 6181 printk(KERN_ERR DRV_NAME
6186 dev->name, param->cmd); 6182 ": %s: Unknown WPA supplicant request: %d\n", dev->name,
6183 param->cmd);
6187 ret = -EOPNOTSUPP; 6184 ret = -EOPNOTSUPP;
6188 6185
6189 } 6186 }
@@ -6194,27 +6191,23 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6194 kfree(param); 6191 kfree(param);
6195 return ret; 6192 return ret;
6196} 6193}
6197#endif /* CONFIG_IEEE80211_WPA */
6198 6194
6199static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 6195static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6200{ 6196{
6201#ifdef CONFIG_IEEE80211_WPA 6197 struct iwreq *wrq = (struct iwreq *)rq;
6202 struct iwreq *wrq = (struct iwreq *) rq; 6198 int ret = -1;
6203 int ret=-1; 6199 switch (cmd) {
6204 switch (cmd){ 6200 case IPW2100_IOCTL_WPA_SUPPLICANT:
6205 case IPW2100_IOCTL_WPA_SUPPLICANT:
6206 ret = ipw2100_wpa_supplicant(dev, &wrq->u.data); 6201 ret = ipw2100_wpa_supplicant(dev, &wrq->u.data);
6207 return ret; 6202 return ret;
6208 6203
6209 default: 6204 default:
6210 return -EOPNOTSUPP; 6205 return -EOPNOTSUPP;
6211 } 6206 }
6212 6207
6213#endif /* CONFIG_IEEE80211_WPA */
6214
6215 return -EOPNOTSUPP; 6208 return -EOPNOTSUPP;
6216} 6209}
6217 6210#endif /* WIRELESS_EXT < 18 */
6218 6211
6219static void ipw_ethtool_get_drvinfo(struct net_device *dev, 6212static void ipw_ethtool_get_drvinfo(struct net_device *dev,
6220 struct ethtool_drvinfo *info) 6213 struct ethtool_drvinfo *info)
@@ -6236,14 +6229,13 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
6236 6229
6237static u32 ipw2100_ethtool_get_link(struct net_device *dev) 6230static u32 ipw2100_ethtool_get_link(struct net_device *dev)
6238{ 6231{
6239 struct ipw2100_priv *priv = ieee80211_priv(dev); 6232 struct ipw2100_priv *priv = ieee80211_priv(dev);
6240 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; 6233 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0;
6241} 6234}
6242 6235
6243
6244static struct ethtool_ops ipw2100_ethtool_ops = { 6236static struct ethtool_ops ipw2100_ethtool_ops = {
6245 .get_link = ipw2100_ethtool_get_link, 6237 .get_link = ipw2100_ethtool_get_link,
6246 .get_drvinfo = ipw_ethtool_get_drvinfo, 6238 .get_drvinfo = ipw_ethtool_get_drvinfo,
6247}; 6239};
6248 6240
6249static void ipw2100_hang_check(void *adapter) 6241static void ipw2100_hang_check(void *adapter)
@@ -6288,7 +6280,6 @@ static void ipw2100_hang_check(void *adapter)
6288 spin_unlock_irqrestore(&priv->low_lock, flags); 6280 spin_unlock_irqrestore(&priv->low_lock, flags);
6289} 6281}
6290 6282
6291
6292static void ipw2100_rf_kill(void *adapter) 6283static void ipw2100_rf_kill(void *adapter)
6293{ 6284{
6294 struct ipw2100_priv *priv = adapter; 6285 struct ipw2100_priv *priv = adapter;
@@ -6313,7 +6304,7 @@ static void ipw2100_rf_kill(void *adapter)
6313 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still " 6304 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still "
6314 "enabled\n"); 6305 "enabled\n");
6315 6306
6316 exit_unlock: 6307 exit_unlock:
6317 spin_unlock_irqrestore(&priv->low_lock, flags); 6308 spin_unlock_irqrestore(&priv->low_lock, flags);
6318} 6309}
6319 6310
@@ -6321,11 +6312,10 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
6321 6312
6322/* Look into using netdev destructor to shutdown ieee80211? */ 6313/* Look into using netdev destructor to shutdown ieee80211? */
6323 6314
6324static struct net_device *ipw2100_alloc_device( 6315static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6325 struct pci_dev *pci_dev, 6316 void __iomem * base_addr,
6326 void __iomem *base_addr, 6317 unsigned long mem_start,
6327 unsigned long mem_start, 6318 unsigned long mem_len)
6328 unsigned long mem_len)
6329{ 6319{
6330 struct ipw2100_priv *priv; 6320 struct ipw2100_priv *priv;
6331 struct net_device *dev; 6321 struct net_device *dev;
@@ -6341,17 +6331,22 @@ static struct net_device *ipw2100_alloc_device(
6341 priv->ieee->hard_start_xmit = ipw2100_tx; 6331 priv->ieee->hard_start_xmit = ipw2100_tx;
6342 priv->ieee->set_security = shim__set_security; 6332 priv->ieee->set_security = shim__set_security;
6343 6333
6334 priv->ieee->perfect_rssi = -20;
6335 priv->ieee->worst_rssi = -85;
6336
6344 dev->open = ipw2100_open; 6337 dev->open = ipw2100_open;
6345 dev->stop = ipw2100_close; 6338 dev->stop = ipw2100_close;
6346 dev->init = ipw2100_net_init; 6339 dev->init = ipw2100_net_init;
6340#if WIRELESS_EXT < 18
6347 dev->do_ioctl = ipw2100_ioctl; 6341 dev->do_ioctl = ipw2100_ioctl;
6342#endif
6348 dev->get_stats = ipw2100_stats; 6343 dev->get_stats = ipw2100_stats;
6349 dev->ethtool_ops = &ipw2100_ethtool_ops; 6344 dev->ethtool_ops = &ipw2100_ethtool_ops;
6350 dev->tx_timeout = ipw2100_tx_timeout; 6345 dev->tx_timeout = ipw2100_tx_timeout;
6351 dev->wireless_handlers = &ipw2100_wx_handler_def; 6346 dev->wireless_handlers = &ipw2100_wx_handler_def;
6352 dev->get_wireless_stats = ipw2100_wx_wireless_stats; 6347 dev->get_wireless_stats = ipw2100_wx_wireless_stats;
6353 dev->set_mac_address = ipw2100_set_address; 6348 dev->set_mac_address = ipw2100_set_address;
6354 dev->watchdog_timeo = 3*HZ; 6349 dev->watchdog_timeo = 3 * HZ;
6355 dev->irq = 0; 6350 dev->irq = 0;
6356 6351
6357 dev->base_addr = (unsigned long)base_addr; 6352 dev->base_addr = (unsigned long)base_addr;
@@ -6364,22 +6359,19 @@ static struct net_device *ipw2100_alloc_device(
6364 * ends up causing problems. So, we just handle 6359 * ends up causing problems. So, we just handle
6365 * the WX extensions through the ipw2100_ioctl interface */ 6360 * the WX extensions through the ipw2100_ioctl interface */
6366 6361
6367
6368 /* memset() puts everything to 0, so we only have explicitely set 6362 /* memset() puts everything to 0, so we only have explicitely set
6369 * those values that need to be something else */ 6363 * those values that need to be something else */
6370 6364
6371 /* If power management is turned on, default to AUTO mode */ 6365 /* If power management is turned on, default to AUTO mode */
6372 priv->power_mode = IPW_POWER_AUTO; 6366 priv->power_mode = IPW_POWER_AUTO;
6373 6367
6374 6368#ifdef CONFIG_IPW2100_MONITOR
6375 6369 priv->config |= CFG_CRC_CHECK;
6376#ifdef CONFIG_IEEE80211_WPA 6370#endif
6377 priv->ieee->wpa_enabled = 0; 6371 priv->ieee->wpa_enabled = 0;
6378 priv->ieee->tkip_countermeasures = 0;
6379 priv->ieee->drop_unencrypted = 0; 6372 priv->ieee->drop_unencrypted = 0;
6380 priv->ieee->privacy_invoked = 0; 6373 priv->ieee->privacy_invoked = 0;
6381 priv->ieee->ieee802_1x = 1; 6374 priv->ieee->ieee802_1x = 1;
6382#endif /* CONFIG_IEEE80211_WPA */
6383 6375
6384 /* Set module parameters */ 6376 /* Set module parameters */
6385 switch (mode) { 6377 switch (mode) {
@@ -6401,8 +6393,7 @@ static struct net_device *ipw2100_alloc_device(
6401 priv->status |= STATUS_RF_KILL_SW; 6393 priv->status |= STATUS_RF_KILL_SW;
6402 6394
6403 if (channel != 0 && 6395 if (channel != 0 &&
6404 ((channel >= REG_MIN_CHANNEL) && 6396 ((channel >= REG_MIN_CHANNEL) && (channel <= REG_MAX_CHANNEL))) {
6405 (channel <= REG_MAX_CHANNEL))) {
6406 priv->config |= CFG_STATIC_CHANNEL; 6397 priv->config |= CFG_STATIC_CHANNEL;
6407 priv->channel = channel; 6398 priv->channel = channel;
6408 } 6399 }
@@ -6441,12 +6432,8 @@ static struct net_device *ipw2100_alloc_device(
6441 INIT_LIST_HEAD(&priv->fw_pend_list); 6432 INIT_LIST_HEAD(&priv->fw_pend_list);
6442 INIT_STAT(&priv->fw_pend_stat); 6433 INIT_STAT(&priv->fw_pend_stat);
6443 6434
6444
6445#ifdef CONFIG_SOFTWARE_SUSPEND2
6446 priv->workqueue = create_workqueue(DRV_NAME, 0);
6447#else
6448 priv->workqueue = create_workqueue(DRV_NAME); 6435 priv->workqueue = create_workqueue(DRV_NAME);
6449#endif 6436
6450 INIT_WORK(&priv->reset_work, 6437 INIT_WORK(&priv->reset_work,
6451 (void (*)(void *))ipw2100_reset_adapter, priv); 6438 (void (*)(void *))ipw2100_reset_adapter, priv);
6452 INIT_WORK(&priv->security_work, 6439 INIT_WORK(&priv->security_work,
@@ -6535,7 +6522,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6535 return err; 6522 return err;
6536 } 6523 }
6537 6524
6538 /* We disable the RETRY_TIMEOUT register (0x41) to keep 6525 /* We disable the RETRY_TIMEOUT register (0x41) to keep
6539 * PCI Tx retries from interfering with C3 CPU state */ 6526 * PCI Tx retries from interfering with C3 CPU state */
6540 pci_read_config_dword(pci_dev, 0x40, &val); 6527 pci_read_config_dword(pci_dev, 0x40, &val);
6541 if ((val & 0x0000ff00) != 0) 6528 if ((val & 0x0000ff00) != 0)
@@ -6566,12 +6553,10 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6566 ipw2100_queues_initialize(priv); 6553 ipw2100_queues_initialize(priv);
6567 6554
6568 err = request_irq(pci_dev->irq, 6555 err = request_irq(pci_dev->irq,
6569 ipw2100_interrupt, SA_SHIRQ, 6556 ipw2100_interrupt, SA_SHIRQ, dev->name, priv);
6570 dev->name, priv);
6571 if (err) { 6557 if (err) {
6572 printk(KERN_WARNING DRV_NAME 6558 printk(KERN_WARNING DRV_NAME
6573 "Error calling request_irq: %d.\n", 6559 "Error calling request_irq: %d.\n", pci_dev->irq);
6574 pci_dev->irq);
6575 goto fail; 6560 goto fail;
6576 } 6561 }
6577 dev->irq = pci_dev->irq; 6562 dev->irq = pci_dev->irq;
@@ -6606,7 +6591,6 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6606 6591
6607 /* perform this after register_netdev so that dev->name is set */ 6592 /* perform this after register_netdev so that dev->name is set */
6608 sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6593 sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
6609 netif_carrier_off(dev);
6610 6594
6611 /* If the RF Kill switch is disabled, go ahead and complete the 6595 /* If the RF Kill switch is disabled, go ahead and complete the
6612 * startup sequence */ 6596 * startup sequence */
@@ -6634,10 +6618,10 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6634 6618
6635 return 0; 6619 return 0;
6636 6620
6637 fail_unlock: 6621 fail_unlock:
6638 up(&priv->action_sem); 6622 up(&priv->action_sem);
6639 6623
6640 fail: 6624 fail:
6641 if (dev) { 6625 if (dev) {
6642 if (registered) 6626 if (registered)
6643 unregister_netdev(dev); 6627 unregister_netdev(dev);
@@ -6653,7 +6637,8 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6653 6637
6654 /* These are safe to call even if they weren't allocated */ 6638 /* These are safe to call even if they weren't allocated */
6655 ipw2100_queues_free(priv); 6639 ipw2100_queues_free(priv);
6656 sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6640 sysfs_remove_group(&pci_dev->dev.kobj,
6641 &ipw2100_attribute_group);
6657 6642
6658 free_ieee80211(dev); 6643 free_ieee80211(dev);
6659 pci_set_drvdata(pci_dev, NULL); 6644 pci_set_drvdata(pci_dev, NULL);
@@ -6679,7 +6664,8 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6679 priv->status &= ~STATUS_INITIALIZED; 6664 priv->status &= ~STATUS_INITIALIZED;
6680 6665
6681 dev = priv->net_dev; 6666 dev = priv->net_dev;
6682 sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6667 sysfs_remove_group(&pci_dev->dev.kobj,
6668 &ipw2100_attribute_group);
6683 6669
6684#ifdef CONFIG_PM 6670#ifdef CONFIG_PM
6685 if (ipw2100_firmware.version) 6671 if (ipw2100_firmware.version)
@@ -6721,19 +6707,13 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6721 IPW_DEBUG_INFO("exit\n"); 6707 IPW_DEBUG_INFO("exit\n");
6722} 6708}
6723 6709
6724
6725#ifdef CONFIG_PM 6710#ifdef CONFIG_PM
6726#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
6727static int ipw2100_suspend(struct pci_dev *pci_dev, u32 state)
6728#else
6729static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state) 6711static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
6730#endif
6731{ 6712{
6732 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); 6713 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
6733 struct net_device *dev = priv->net_dev; 6714 struct net_device *dev = priv->net_dev;
6734 6715
6735 IPW_DEBUG_INFO("%s: Going into suspend...\n", 6716 IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name);
6736 dev->name);
6737 6717
6738 down(&priv->action_sem); 6718 down(&priv->action_sem);
6739 if (priv->status & STATUS_INITIALIZED) { 6719 if (priv->status & STATUS_INITIALIZED) {
@@ -6745,7 +6725,7 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
6745 netif_device_detach(dev); 6725 netif_device_detach(dev);
6746 6726
6747 pci_save_state(pci_dev); 6727 pci_save_state(pci_dev);
6748 pci_disable_device (pci_dev); 6728 pci_disable_device(pci_dev);
6749 pci_set_power_state(pci_dev, PCI_D3hot); 6729 pci_set_power_state(pci_dev, PCI_D3hot);
6750 6730
6751 up(&priv->action_sem); 6731 up(&priv->action_sem);
@@ -6764,8 +6744,7 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6764 6744
6765 down(&priv->action_sem); 6745 down(&priv->action_sem);
6766 6746
6767 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", 6747 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
6768 dev->name);
6769 6748
6770 pci_set_power_state(pci_dev, PCI_D0); 6749 pci_set_power_state(pci_dev, PCI_D0);
6771 pci_enable_device(pci_dev); 6750 pci_enable_device(pci_dev);
@@ -6785,9 +6764,9 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6785 * the queue of needed */ 6764 * the queue of needed */
6786 netif_device_attach(dev); 6765 netif_device_attach(dev);
6787 6766
6788 /* Bring the device back up */ 6767 /* Bring the device back up */
6789 if (!(priv->status & STATUS_RF_KILL_SW)) 6768 if (!(priv->status & STATUS_RF_KILL_SW))
6790 ipw2100_up(priv, 0); 6769 ipw2100_up(priv, 0);
6791 6770
6792 up(&priv->action_sem); 6771 up(&priv->action_sem);
6793 6772
@@ -6795,56 +6774,55 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6795} 6774}
6796#endif 6775#endif
6797 6776
6798
6799#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x } 6777#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x }
6800 6778
6801static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = { 6779static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = {
6802 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */ 6780 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */
6803 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */ 6781 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */
6804 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */ 6782 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */
6805 IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */ 6783 IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */
6806 IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */ 6784 IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */
6807 IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */ 6785 IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */
6808 IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */ 6786 IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */
6809 IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */ 6787 IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */
6810 IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */ 6788 IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */
6811 IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */ 6789 IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */
6812 IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */ 6790 IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */
6813 IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */ 6791 IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */
6814 IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */ 6792 IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */
6815 6793
6816 IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */ 6794 IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */
6817 IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */ 6795 IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */
6818 IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */ 6796 IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */
6819 IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */ 6797 IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */
6820 IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */ 6798 IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */
6821 6799
6822 IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */ 6800 IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */
6823 IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */ 6801 IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */
6824 IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */ 6802 IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */
6825 IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */ 6803 IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */
6826 IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */ 6804 IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */
6827 IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */ 6805 IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */
6828 IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */ 6806 IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */
6829 6807
6830 IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */ 6808 IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */
6831 6809
6832 IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */ 6810 IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */
6833 IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */ 6811 IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */
6834 IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */ 6812 IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */
6835 IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */ 6813 IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */
6836 IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */ 6814 IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */
6837 IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */ 6815 IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */
6838 IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */ 6816 IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */
6839 6817
6840 IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */ 6818 IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */
6841 IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */ 6819 IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */
6842 IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */ 6820 IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */
6843 IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */ 6821 IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */
6844 IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */ 6822 IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */
6845 IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */ 6823 IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */
6846 6824
6847 IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */ 6825 IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */
6848 {0,}, 6826 {0,},
6849}; 6827};
6850 6828
@@ -6861,7 +6839,6 @@ static struct pci_driver ipw2100_pci_driver = {
6861#endif 6839#endif
6862}; 6840};
6863 6841
6864
6865/** 6842/**
6866 * Initialize the ipw2100 driver/module 6843 * Initialize the ipw2100 driver/module
6867 * 6844 *
@@ -6878,10 +6855,6 @@ static int __init ipw2100_init(void)
6878 printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 6855 printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
6879 printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT); 6856 printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT);
6880 6857
6881#ifdef CONFIG_IEEE80211_NOWEP
6882 IPW_DEBUG_INFO(DRV_NAME ": Compiled with WEP disabled.\n");
6883#endif
6884
6885 ret = pci_module_init(&ipw2100_pci_driver); 6858 ret = pci_module_init(&ipw2100_pci_driver);
6886 6859
6887#ifdef CONFIG_IPW_DEBUG 6860#ifdef CONFIG_IPW_DEBUG
@@ -6893,7 +6866,6 @@ static int __init ipw2100_init(void)
6893 return ret; 6866 return ret;
6894} 6867}
6895 6868
6896
6897/** 6869/**
6898 * Cleanup ipw2100 driver registration 6870 * Cleanup ipw2100 driver registration
6899 */ 6871 */
@@ -6949,7 +6921,6 @@ static int ipw2100_wx_get_name(struct net_device *dev,
6949 return 0; 6921 return 0;
6950} 6922}
6951 6923
6952
6953static int ipw2100_wx_set_freq(struct net_device *dev, 6924static int ipw2100_wx_set_freq(struct net_device *dev,
6954 struct iw_request_info *info, 6925 struct iw_request_info *info,
6955 union iwreq_data *wrqu, char *extra) 6926 union iwreq_data *wrqu, char *extra)
@@ -6969,8 +6940,7 @@ static int ipw2100_wx_set_freq(struct net_device *dev,
6969 6940
6970 /* if setting by freq convert to channel */ 6941 /* if setting by freq convert to channel */
6971 if (fwrq->e == 1) { 6942 if (fwrq->e == 1) {
6972 if ((fwrq->m >= (int) 2.412e8 && 6943 if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) {
6973 fwrq->m <= (int) 2.487e8)) {
6974 int f = fwrq->m / 100000; 6944 int f = fwrq->m / 100000;
6975 int c = 0; 6945 int c = 0;
6976 6946
@@ -6984,19 +6954,19 @@ static int ipw2100_wx_set_freq(struct net_device *dev,
6984 } 6954 }
6985 } 6955 }
6986 6956
6987 if (fwrq->e > 0 || fwrq->m > 1000) 6957 if (fwrq->e > 0 || fwrq->m > 1000) {
6988 return -EOPNOTSUPP; 6958 err = -EOPNOTSUPP;
6989 else { /* Set the channel */ 6959 goto done;
6960 } else { /* Set the channel */
6990 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); 6961 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
6991 err = ipw2100_set_channel(priv, fwrq->m, 0); 6962 err = ipw2100_set_channel(priv, fwrq->m, 0);
6992 } 6963 }
6993 6964
6994 done: 6965 done:
6995 up(&priv->action_sem); 6966 up(&priv->action_sem);
6996 return err; 6967 return err;
6997} 6968}
6998 6969
6999
7000static int ipw2100_wx_get_freq(struct net_device *dev, 6970static int ipw2100_wx_get_freq(struct net_device *dev,
7001 struct iw_request_info *info, 6971 struct iw_request_info *info,
7002 union iwreq_data *wrqu, char *extra) 6972 union iwreq_data *wrqu, char *extra)
@@ -7045,7 +7015,7 @@ static int ipw2100_wx_set_mode(struct net_device *dev,
7045 case IW_MODE_MONITOR: 7015 case IW_MODE_MONITOR:
7046 err = ipw2100_switch_mode(priv, IW_MODE_MONITOR); 7016 err = ipw2100_switch_mode(priv, IW_MODE_MONITOR);
7047 break; 7017 break;
7048#endif /* CONFIG_IPW2100_MONITOR */ 7018#endif /* CONFIG_IPW2100_MONITOR */
7049 case IW_MODE_ADHOC: 7019 case IW_MODE_ADHOC:
7050 err = ipw2100_switch_mode(priv, IW_MODE_ADHOC); 7020 err = ipw2100_switch_mode(priv, IW_MODE_ADHOC);
7051 break; 7021 break;
@@ -7056,9 +7026,9 @@ static int ipw2100_wx_set_mode(struct net_device *dev,
7056 break; 7026 break;
7057 } 7027 }
7058 7028
7059done: 7029 done:
7060 up(&priv->action_sem); 7030 up(&priv->action_sem);
7061 return err; 7031 return err;
7062} 7032}
7063 7033
7064static int ipw2100_wx_get_mode(struct net_device *dev, 7034static int ipw2100_wx_get_mode(struct net_device *dev,
@@ -7077,7 +7047,6 @@ static int ipw2100_wx_get_mode(struct net_device *dev,
7077 return 0; 7047 return 0;
7078} 7048}
7079 7049
7080
7081#define POWER_MODES 5 7050#define POWER_MODES 5
7082 7051
7083/* Values are in microsecond */ 7052/* Values are in microsecond */
@@ -7124,19 +7093,19 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7124 /* ~5 Mb/s real (802.11b) */ 7093 /* ~5 Mb/s real (802.11b) */
7125 range->throughput = 5 * 1000 * 1000; 7094 range->throughput = 5 * 1000 * 1000;
7126 7095
7127// range->sensitivity; /* signal level threshold range */ 7096// range->sensitivity; /* signal level threshold range */
7128 7097
7129 range->max_qual.qual = 100; 7098 range->max_qual.qual = 100;
7130 /* TODO: Find real max RSSI and stick here */ 7099 /* TODO: Find real max RSSI and stick here */
7131 range->max_qual.level = 0; 7100 range->max_qual.level = 0;
7132 range->max_qual.noise = 0; 7101 range->max_qual.noise = 0;
7133 range->max_qual.updated = 7; /* Updated all three */ 7102 range->max_qual.updated = 7; /* Updated all three */
7134 7103
7135 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ 7104 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
7136 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ 7105 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
7137 range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM; 7106 range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM;
7138 range->avg_qual.noise = 0; 7107 range->avg_qual.noise = 0;
7139 range->avg_qual.updated = 7; /* Updated all three */ 7108 range->avg_qual.updated = 7; /* Updated all three */
7140 7109
7141 range->num_bitrates = RATE_COUNT; 7110 range->num_bitrates = RATE_COUNT;
7142 7111
@@ -7150,61 +7119,62 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7150 range->max_frag = MAX_FRAG_THRESHOLD; 7119 range->max_frag = MAX_FRAG_THRESHOLD;
7151 7120
7152 range->min_pmp = period_duration[0]; /* Minimal PM period */ 7121 range->min_pmp = period_duration[0]; /* Minimal PM period */
7153 range->max_pmp = period_duration[POWER_MODES-1];/* Maximal PM period */ 7122 range->max_pmp = period_duration[POWER_MODES - 1]; /* Maximal PM period */
7154 range->min_pmt = timeout_duration[POWER_MODES-1]; /* Minimal PM timeout */ 7123 range->min_pmt = timeout_duration[POWER_MODES - 1]; /* Minimal PM timeout */
7155 range->max_pmt = timeout_duration[0];/* Maximal PM timeout */ 7124 range->max_pmt = timeout_duration[0]; /* Maximal PM timeout */
7156 7125
7157 /* How to decode max/min PM period */ 7126 /* How to decode max/min PM period */
7158 range->pmp_flags = IW_POWER_PERIOD; 7127 range->pmp_flags = IW_POWER_PERIOD;
7159 /* How to decode max/min PM period */ 7128 /* How to decode max/min PM period */
7160 range->pmt_flags = IW_POWER_TIMEOUT; 7129 range->pmt_flags = IW_POWER_TIMEOUT;
7161 /* What PM options are supported */ 7130 /* What PM options are supported */
7162 range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD; 7131 range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD;
7163 7132
7164 range->encoding_size[0] = 5; 7133 range->encoding_size[0] = 5;
7165 range->encoding_size[1] = 13; /* Different token sizes */ 7134 range->encoding_size[1] = 13; /* Different token sizes */
7166 range->num_encoding_sizes = 2; /* Number of entry in the list */ 7135 range->num_encoding_sizes = 2; /* Number of entry in the list */
7167 range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ 7136 range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */
7168// range->encoding_login_index; /* token index for login token */ 7137// range->encoding_login_index; /* token index for login token */
7169 7138
7170 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 7139 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
7171 range->txpower_capa = IW_TXPOW_DBM; 7140 range->txpower_capa = IW_TXPOW_DBM;
7172 range->num_txpower = IW_MAX_TXPOWER; 7141 range->num_txpower = IW_MAX_TXPOWER;
7173 for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16); i < IW_MAX_TXPOWER; 7142 for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16);
7174 i++, level -= ((IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM) * 16) / 7143 i < IW_MAX_TXPOWER;
7175 (IW_MAX_TXPOWER - 1)) 7144 i++, level -=
7145 ((IPW_TX_POWER_MAX_DBM -
7146 IPW_TX_POWER_MIN_DBM) * 16) / (IW_MAX_TXPOWER - 1))
7176 range->txpower[i] = level / 16; 7147 range->txpower[i] = level / 16;
7177 } else { 7148 } else {
7178 range->txpower_capa = 0; 7149 range->txpower_capa = 0;
7179 range->num_txpower = 0; 7150 range->num_txpower = 0;
7180 } 7151 }
7181 7152
7182
7183 /* Set the Wireless Extension versions */ 7153 /* Set the Wireless Extension versions */
7184 range->we_version_compiled = WIRELESS_EXT; 7154 range->we_version_compiled = WIRELESS_EXT;
7185 range->we_version_source = 16; 7155 range->we_version_source = 16;
7186 7156
7187// range->retry_capa; /* What retry options are supported */ 7157// range->retry_capa; /* What retry options are supported */
7188// range->retry_flags; /* How to decode max/min retry limit */ 7158// range->retry_flags; /* How to decode max/min retry limit */
7189// range->r_time_flags; /* How to decode max/min retry life */ 7159// range->r_time_flags; /* How to decode max/min retry life */
7190// range->min_retry; /* Minimal number of retries */ 7160// range->min_retry; /* Minimal number of retries */
7191// range->max_retry; /* Maximal number of retries */ 7161// range->max_retry; /* Maximal number of retries */
7192// range->min_r_time; /* Minimal retry lifetime */ 7162// range->min_r_time; /* Minimal retry lifetime */
7193// range->max_r_time; /* Maximal retry lifetime */ 7163// range->max_r_time; /* Maximal retry lifetime */
7194 7164
7195 range->num_channels = FREQ_COUNT; 7165 range->num_channels = FREQ_COUNT;
7196 7166
7197 val = 0; 7167 val = 0;
7198 for (i = 0; i < FREQ_COUNT; i++) { 7168 for (i = 0; i < FREQ_COUNT; i++) {
7199 // TODO: Include only legal frequencies for some countries 7169 // TODO: Include only legal frequencies for some countries
7200// if (local->channel_mask & (1 << i)) { 7170// if (local->channel_mask & (1 << i)) {
7201 range->freq[val].i = i + 1; 7171 range->freq[val].i = i + 1;
7202 range->freq[val].m = ipw2100_frequencies[i] * 100000; 7172 range->freq[val].m = ipw2100_frequencies[i] * 100000;
7203 range->freq[val].e = 1; 7173 range->freq[val].e = 1;
7204 val++; 7174 val++;
7205// } 7175// }
7206 if (val == IW_MAX_FREQUENCIES) 7176 if (val == IW_MAX_FREQUENCIES)
7207 break; 7177 break;
7208 } 7178 }
7209 range->num_frequency = val; 7179 range->num_frequency = val;
7210 7180
@@ -7259,7 +7229,7 @@ static int ipw2100_wx_set_wap(struct net_device *dev,
7259 wrqu->ap_addr.sa_data[4] & 0xff, 7229 wrqu->ap_addr.sa_data[4] & 0xff,
7260 wrqu->ap_addr.sa_data[5] & 0xff); 7230 wrqu->ap_addr.sa_data[5] & 0xff);
7261 7231
7262 done: 7232 done:
7263 up(&priv->action_sem); 7233 up(&priv->action_sem);
7264 return err; 7234 return err;
7265} 7235}
@@ -7276,10 +7246,9 @@ static int ipw2100_wx_get_wap(struct net_device *dev,
7276 7246
7277 /* If we are associated, trying to associate, or have a statically 7247 /* If we are associated, trying to associate, or have a statically
7278 * configured BSSID then return that; otherwise return ANY */ 7248 * configured BSSID then return that; otherwise return ANY */
7279 if (priv->config & CFG_STATIC_BSSID || 7249 if (priv->config & CFG_STATIC_BSSID || priv->status & STATUS_ASSOCIATED) {
7280 priv->status & STATUS_ASSOCIATED) {
7281 wrqu->ap_addr.sa_family = ARPHRD_ETHER; 7250 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
7282 memcpy(wrqu->ap_addr.sa_data, &priv->bssid, ETH_ALEN); 7251 memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN);
7283 } else 7252 } else
7284 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); 7253 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
7285 7254
@@ -7293,7 +7262,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
7293 union iwreq_data *wrqu, char *extra) 7262 union iwreq_data *wrqu, char *extra)
7294{ 7263{
7295 struct ipw2100_priv *priv = ieee80211_priv(dev); 7264 struct ipw2100_priv *priv = ieee80211_priv(dev);
7296 char *essid = ""; /* ANY */ 7265 char *essid = ""; /* ANY */
7297 int length = 0; 7266 int length = 0;
7298 int err = 0; 7267 int err = 0;
7299 7268
@@ -7333,7 +7302,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
7333 7302
7334 err = ipw2100_set_essid(priv, essid, length, 0); 7303 err = ipw2100_set_essid(priv, essid, length, 0);
7335 7304
7336 done: 7305 done:
7337 up(&priv->action_sem); 7306 up(&priv->action_sem);
7338 return err; 7307 return err;
7339} 7308}
@@ -7350,17 +7319,16 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
7350 7319
7351 /* If we are associated, trying to associate, or have a statically 7320 /* If we are associated, trying to associate, or have a statically
7352 * configured ESSID then return that; otherwise return ANY */ 7321 * configured ESSID then return that; otherwise return ANY */
7353 if (priv->config & CFG_STATIC_ESSID || 7322 if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
7354 priv->status & STATUS_ASSOCIATED) {
7355 IPW_DEBUG_WX("Getting essid: '%s'\n", 7323 IPW_DEBUG_WX("Getting essid: '%s'\n",
7356 escape_essid(priv->essid, priv->essid_len)); 7324 escape_essid(priv->essid, priv->essid_len));
7357 memcpy(extra, priv->essid, priv->essid_len); 7325 memcpy(extra, priv->essid, priv->essid_len);
7358 wrqu->essid.length = priv->essid_len; 7326 wrqu->essid.length = priv->essid_len;
7359 wrqu->essid.flags = 1; /* active */ 7327 wrqu->essid.flags = 1; /* active */
7360 } else { 7328 } else {
7361 IPW_DEBUG_WX("Getting essid: ANY\n"); 7329 IPW_DEBUG_WX("Getting essid: ANY\n");
7362 wrqu->essid.length = 0; 7330 wrqu->essid.length = 0;
7363 wrqu->essid.flags = 0; /* active */ 7331 wrqu->essid.flags = 0; /* active */
7364 } 7332 }
7365 7333
7366 return 0; 7334 return 0;
@@ -7379,9 +7347,9 @@ static int ipw2100_wx_set_nick(struct net_device *dev,
7379 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 7347 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
7380 return -E2BIG; 7348 return -E2BIG;
7381 7349
7382 wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick)); 7350 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
7383 memset(priv->nick, 0, sizeof(priv->nick)); 7351 memset(priv->nick, 0, sizeof(priv->nick));
7384 memcpy(priv->nick, extra, wrqu->data.length); 7352 memcpy(priv->nick, extra, wrqu->data.length);
7385 7353
7386 IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick); 7354 IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick);
7387 7355
@@ -7400,7 +7368,7 @@ static int ipw2100_wx_get_nick(struct net_device *dev,
7400 7368
7401 wrqu->data.length = strlen(priv->nick) + 1; 7369 wrqu->data.length = strlen(priv->nick) + 1;
7402 memcpy(extra, priv->nick, wrqu->data.length); 7370 memcpy(extra, priv->nick, wrqu->data.length);
7403 wrqu->data.flags = 1; /* active */ 7371 wrqu->data.flags = 1; /* active */
7404 7372
7405 IPW_DEBUG_WX("GET Nickname -> %s \n", extra); 7373 IPW_DEBUG_WX("GET Nickname -> %s \n", extra);
7406 7374
@@ -7442,12 +7410,11 @@ static int ipw2100_wx_set_rate(struct net_device *dev,
7442 err = ipw2100_set_tx_rates(priv, rate, 0); 7410 err = ipw2100_set_tx_rates(priv, rate, 0);
7443 7411
7444 IPW_DEBUG_WX("SET Rate -> %04X \n", rate); 7412 IPW_DEBUG_WX("SET Rate -> %04X \n", rate);
7445 done: 7413 done:
7446 up(&priv->action_sem); 7414 up(&priv->action_sem);
7447 return err; 7415 return err;
7448} 7416}
7449 7417
7450
7451static int ipw2100_wx_get_rate(struct net_device *dev, 7418static int ipw2100_wx_get_rate(struct net_device *dev,
7452 struct iw_request_info *info, 7419 struct iw_request_info *info,
7453 union iwreq_data *wrqu, char *extra) 7420 union iwreq_data *wrqu, char *extra)
@@ -7495,7 +7462,7 @@ static int ipw2100_wx_get_rate(struct net_device *dev,
7495 7462
7496 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 7463 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
7497 7464
7498 done: 7465 done:
7499 up(&priv->action_sem); 7466 up(&priv->action_sem);
7500 return err; 7467 return err;
7501} 7468}
@@ -7520,8 +7487,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev,
7520 if (wrqu->rts.disabled) 7487 if (wrqu->rts.disabled)
7521 value = priv->rts_threshold | RTS_DISABLED; 7488 value = priv->rts_threshold | RTS_DISABLED;
7522 else { 7489 else {
7523 if (wrqu->rts.value < 1 || 7490 if (wrqu->rts.value < 1 || wrqu->rts.value > 2304) {
7524 wrqu->rts.value > 2304) {
7525 err = -EINVAL; 7491 err = -EINVAL;
7526 goto done; 7492 goto done;
7527 } 7493 }
@@ -7531,7 +7497,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev,
7531 err = ipw2100_set_rts_threshold(priv, value); 7497 err = ipw2100_set_rts_threshold(priv, value);
7532 7498
7533 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value); 7499 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value);
7534 done: 7500 done:
7535 up(&priv->action_sem); 7501 up(&priv->action_sem);
7536 return err; 7502 return err;
7537} 7503}
@@ -7547,7 +7513,7 @@ static int ipw2100_wx_get_rts(struct net_device *dev,
7547 struct ipw2100_priv *priv = ieee80211_priv(dev); 7513 struct ipw2100_priv *priv = ieee80211_priv(dev);
7548 7514
7549 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED; 7515 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
7550 wrqu->rts.fixed = 1; /* no auto select */ 7516 wrqu->rts.fixed = 1; /* no auto select */
7551 7517
7552 /* If RTS is set to the default value, then it is disabled */ 7518 /* If RTS is set to the default value, then it is disabled */
7553 wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0; 7519 wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0;
@@ -7574,8 +7540,7 @@ static int ipw2100_wx_set_txpow(struct net_device *dev,
7574 wrqu->txpower.value > IPW_TX_POWER_MAX_DBM) 7540 wrqu->txpower.value > IPW_TX_POWER_MAX_DBM)
7575 return -EINVAL; 7541 return -EINVAL;
7576 7542
7577 value = (wrqu->txpower.value - IPW_TX_POWER_MIN_DBM) * 16 / 7543 value = wrqu->txpower.value;
7578 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
7579 } 7544 }
7580 7545
7581 down(&priv->action_sem); 7546 down(&priv->action_sem);
@@ -7588,7 +7553,7 @@ static int ipw2100_wx_set_txpow(struct net_device *dev,
7588 7553
7589 IPW_DEBUG_WX("SET TX Power -> %d \n", value); 7554 IPW_DEBUG_WX("SET TX Power -> %d \n", value);
7590 7555
7591 done: 7556 done:
7592 up(&priv->action_sem); 7557 up(&priv->action_sem);
7593 return err; 7558 return err;
7594} 7559}
@@ -7615,11 +7580,7 @@ static int ipw2100_wx_get_txpow(struct net_device *dev,
7615 } else { 7580 } else {
7616 wrqu->power.disabled = 0; 7581 wrqu->power.disabled = 0;
7617 wrqu->power.fixed = 1; 7582 wrqu->power.fixed = 1;
7618 wrqu->power.value = 7583 wrqu->power.value = priv->tx_power;
7619 (priv->tx_power *
7620 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM)) /
7621 (IPW_TX_POWER_MAX - IPW_TX_POWER_MIN) +
7622 IPW_TX_POWER_MIN_DBM;
7623 } 7584 }
7624 7585
7625 wrqu->power.flags = IW_TXPOW_DBM; 7586 wrqu->power.flags = IW_TXPOW_DBM;
@@ -7684,8 +7645,7 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7684 struct ipw2100_priv *priv = ieee80211_priv(dev); 7645 struct ipw2100_priv *priv = ieee80211_priv(dev);
7685 int err = 0; 7646 int err = 0;
7686 7647
7687 if (wrqu->retry.flags & IW_RETRY_LIFETIME || 7648 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled)
7688 wrqu->retry.disabled)
7689 return -EINVAL; 7649 return -EINVAL;
7690 7650
7691 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) 7651 if (!(wrqu->retry.flags & IW_RETRY_LIMIT))
@@ -7700,14 +7660,14 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7700 if (wrqu->retry.flags & IW_RETRY_MIN) { 7660 if (wrqu->retry.flags & IW_RETRY_MIN) {
7701 err = ipw2100_set_short_retry(priv, wrqu->retry.value); 7661 err = ipw2100_set_short_retry(priv, wrqu->retry.value);
7702 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n", 7662 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n",
7703 wrqu->retry.value); 7663 wrqu->retry.value);
7704 goto done; 7664 goto done;
7705 } 7665 }
7706 7666
7707 if (wrqu->retry.flags & IW_RETRY_MAX) { 7667 if (wrqu->retry.flags & IW_RETRY_MAX) {
7708 err = ipw2100_set_long_retry(priv, wrqu->retry.value); 7668 err = ipw2100_set_long_retry(priv, wrqu->retry.value);
7709 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n", 7669 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n",
7710 wrqu->retry.value); 7670 wrqu->retry.value);
7711 goto done; 7671 goto done;
7712 } 7672 }
7713 7673
@@ -7717,7 +7677,7 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7717 7677
7718 IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value); 7678 IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value);
7719 7679
7720 done: 7680 done:
7721 up(&priv->action_sem); 7681 up(&priv->action_sem);
7722 return err; 7682 return err;
7723} 7683}
@@ -7732,20 +7692,19 @@ static int ipw2100_wx_get_retry(struct net_device *dev,
7732 7692
7733 struct ipw2100_priv *priv = ieee80211_priv(dev); 7693 struct ipw2100_priv *priv = ieee80211_priv(dev);
7734 7694
7735 wrqu->retry.disabled = 0; /* can't be disabled */ 7695 wrqu->retry.disabled = 0; /* can't be disabled */
7736 7696
7737 if ((wrqu->retry.flags & IW_RETRY_TYPE) == 7697 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
7738 IW_RETRY_LIFETIME)
7739 return -EINVAL; 7698 return -EINVAL;
7740 7699
7741 if (wrqu->retry.flags & IW_RETRY_MAX) { 7700 if (wrqu->retry.flags & IW_RETRY_MAX) {
7742 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; 7701 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
7743 wrqu->retry.value = priv->long_retry_limit; 7702 wrqu->retry.value = priv->long_retry_limit;
7744 } else { 7703 } else {
7745 wrqu->retry.flags = 7704 wrqu->retry.flags =
7746 (priv->short_retry_limit != 7705 (priv->short_retry_limit !=
7747 priv->long_retry_limit) ? 7706 priv->long_retry_limit) ?
7748 IW_RETRY_LIMIT & IW_RETRY_MIN : IW_RETRY_LIMIT; 7707 IW_RETRY_LIMIT | IW_RETRY_MIN : IW_RETRY_LIMIT;
7749 7708
7750 wrqu->retry.value = priv->short_retry_limit; 7709 wrqu->retry.value = priv->short_retry_limit;
7751 } 7710 }
@@ -7769,15 +7728,14 @@ static int ipw2100_wx_set_scan(struct net_device *dev,
7769 } 7728 }
7770 7729
7771 IPW_DEBUG_WX("Initiating scan...\n"); 7730 IPW_DEBUG_WX("Initiating scan...\n");
7772 if (ipw2100_set_scan_options(priv) || 7731 if (ipw2100_set_scan_options(priv) || ipw2100_start_scan(priv)) {
7773 ipw2100_start_scan(priv)) {
7774 IPW_DEBUG_WX("Start scan failed.\n"); 7732 IPW_DEBUG_WX("Start scan failed.\n");
7775 7733
7776 /* TODO: Mark a scan as pending so when hardware initialized 7734 /* TODO: Mark a scan as pending so when hardware initialized
7777 * a scan starts */ 7735 * a scan starts */
7778 } 7736 }
7779 7737
7780 done: 7738 done:
7781 up(&priv->action_sem); 7739 up(&priv->action_sem);
7782 return err; 7740 return err;
7783} 7741}
@@ -7794,7 +7752,6 @@ static int ipw2100_wx_get_scan(struct net_device *dev,
7794 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra); 7752 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
7795} 7753}
7796 7754
7797
7798/* 7755/*
7799 * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c 7756 * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c
7800 */ 7757 */
@@ -7823,8 +7780,8 @@ static int ipw2100_wx_get_encode(struct net_device *dev,
7823} 7780}
7824 7781
7825static int ipw2100_wx_set_power(struct net_device *dev, 7782static int ipw2100_wx_set_power(struct net_device *dev,
7826 struct iw_request_info *info, 7783 struct iw_request_info *info,
7827 union iwreq_data *wrqu, char *extra) 7784 union iwreq_data *wrqu, char *extra)
7828{ 7785{
7829 struct ipw2100_priv *priv = ieee80211_priv(dev); 7786 struct ipw2100_priv *priv = ieee80211_priv(dev);
7830 int err = 0; 7787 int err = 0;
@@ -7843,11 +7800,11 @@ static int ipw2100_wx_set_power(struct net_device *dev,
7843 } 7800 }
7844 7801
7845 switch (wrqu->power.flags & IW_POWER_MODE) { 7802 switch (wrqu->power.flags & IW_POWER_MODE) {
7846 case IW_POWER_ON: /* If not specified */ 7803 case IW_POWER_ON: /* If not specified */
7847 case IW_POWER_MODE: /* If set all mask */ 7804 case IW_POWER_MODE: /* If set all mask */
7848 case IW_POWER_ALL_R: /* If explicitely state all */ 7805 case IW_POWER_ALL_R: /* If explicitely state all */
7849 break; 7806 break;
7850 default: /* Otherwise we don't support it */ 7807 default: /* Otherwise we don't support it */
7851 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", 7808 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
7852 wrqu->power.flags); 7809 wrqu->power.flags);
7853 err = -EOPNOTSUPP; 7810 err = -EOPNOTSUPP;
@@ -7859,18 +7816,17 @@ static int ipw2100_wx_set_power(struct net_device *dev,
7859 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; 7816 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
7860 err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); 7817 err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
7861 7818
7862 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", 7819 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode);
7863 priv->power_mode);
7864 7820
7865 done: 7821 done:
7866 up(&priv->action_sem); 7822 up(&priv->action_sem);
7867 return err; 7823 return err;
7868 7824
7869} 7825}
7870 7826
7871static int ipw2100_wx_get_power(struct net_device *dev, 7827static int ipw2100_wx_get_power(struct net_device *dev,
7872 struct iw_request_info *info, 7828 struct iw_request_info *info,
7873 union iwreq_data *wrqu, char *extra) 7829 union iwreq_data *wrqu, char *extra)
7874{ 7830{
7875 /* 7831 /*
7876 * This can be called at any time. No action lock required 7832 * This can be called at any time. No action lock required
@@ -7878,9 +7834,9 @@ static int ipw2100_wx_get_power(struct net_device *dev,
7878 7834
7879 struct ipw2100_priv *priv = ieee80211_priv(dev); 7835 struct ipw2100_priv *priv = ieee80211_priv(dev);
7880 7836
7881 if (!(priv->power_mode & IPW_POWER_ENABLED)) { 7837 if (!(priv->power_mode & IPW_POWER_ENABLED))
7882 wrqu->power.disabled = 1; 7838 wrqu->power.disabled = 1;
7883 } else { 7839 else {
7884 wrqu->power.disabled = 0; 7840 wrqu->power.disabled = 0;
7885 wrqu->power.flags = 0; 7841 wrqu->power.flags = 0;
7886 } 7842 }
@@ -7890,6 +7846,269 @@ static int ipw2100_wx_get_power(struct net_device *dev,
7890 return 0; 7846 return 0;
7891} 7847}
7892 7848
7849#if WIRELESS_EXT > 17
7850/*
7851 * WE-18 WPA support
7852 */
7853
7854/* SIOCSIWGENIE */
7855static int ipw2100_wx_set_genie(struct net_device *dev,
7856 struct iw_request_info *info,
7857 union iwreq_data *wrqu, char *extra)
7858{
7859
7860 struct ipw2100_priv *priv = ieee80211_priv(dev);
7861 struct ieee80211_device *ieee = priv->ieee;
7862 u8 *buf;
7863
7864 if (!ieee->wpa_enabled)
7865 return -EOPNOTSUPP;
7866
7867 if (wrqu->data.length > MAX_WPA_IE_LEN ||
7868 (wrqu->data.length && extra == NULL))
7869 return -EINVAL;
7870
7871 if (wrqu->data.length) {
7872 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
7873 if (buf == NULL)
7874 return -ENOMEM;
7875
7876 memcpy(buf, extra, wrqu->data.length);
7877 kfree(ieee->wpa_ie);
7878 ieee->wpa_ie = buf;
7879 ieee->wpa_ie_len = wrqu->data.length;
7880 } else {
7881 kfree(ieee->wpa_ie);
7882 ieee->wpa_ie = NULL;
7883 ieee->wpa_ie_len = 0;
7884 }
7885
7886 ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len);
7887
7888 return 0;
7889}
7890
7891/* SIOCGIWGENIE */
7892static int ipw2100_wx_get_genie(struct net_device *dev,
7893 struct iw_request_info *info,
7894 union iwreq_data *wrqu, char *extra)
7895{
7896 struct ipw2100_priv *priv = ieee80211_priv(dev);
7897 struct ieee80211_device *ieee = priv->ieee;
7898
7899 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
7900 wrqu->data.length = 0;
7901 return 0;
7902 }
7903
7904 if (wrqu->data.length < ieee->wpa_ie_len)
7905 return -E2BIG;
7906
7907 wrqu->data.length = ieee->wpa_ie_len;
7908 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
7909
7910 return 0;
7911}
7912
7913/* SIOCSIWAUTH */
7914static int ipw2100_wx_set_auth(struct net_device *dev,
7915 struct iw_request_info *info,
7916 union iwreq_data *wrqu, char *extra)
7917{
7918 struct ipw2100_priv *priv = ieee80211_priv(dev);
7919 struct ieee80211_device *ieee = priv->ieee;
7920 struct iw_param *param = &wrqu->param;
7921 struct ieee80211_crypt_data *crypt;
7922 unsigned long flags;
7923 int ret = 0;
7924
7925 switch (param->flags & IW_AUTH_INDEX) {
7926 case IW_AUTH_WPA_VERSION:
7927 case IW_AUTH_CIPHER_PAIRWISE:
7928 case IW_AUTH_CIPHER_GROUP:
7929 case IW_AUTH_KEY_MGMT:
7930 /*
7931 * ipw2200 does not use these parameters
7932 */
7933 break;
7934
7935 case IW_AUTH_TKIP_COUNTERMEASURES:
7936 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
7937 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags)
7938 break;
7939
7940 flags = crypt->ops->get_flags(crypt->priv);
7941
7942 if (param->value)
7943 flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
7944 else
7945 flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
7946
7947 crypt->ops->set_flags(flags, crypt->priv);
7948
7949 break;
7950
7951 case IW_AUTH_DROP_UNENCRYPTED:{
7952 /* HACK:
7953 *
7954 * wpa_supplicant calls set_wpa_enabled when the driver
7955 * is loaded and unloaded, regardless of if WPA is being
7956 * used. No other calls are made which can be used to
7957 * determine if encryption will be used or not prior to
7958 * association being expected. If encryption is not being
7959 * used, drop_unencrypted is set to false, else true -- we
7960 * can use this to determine if the CAP_PRIVACY_ON bit should
7961 * be set.
7962 */
7963 struct ieee80211_security sec = {
7964 .flags = SEC_ENABLED,
7965 .enabled = param->value,
7966 };
7967 priv->ieee->drop_unencrypted = param->value;
7968 /* We only change SEC_LEVEL for open mode. Others
7969 * are set by ipw_wpa_set_encryption.
7970 */
7971 if (!param->value) {
7972 sec.flags |= SEC_LEVEL;
7973 sec.level = SEC_LEVEL_0;
7974 } else {
7975 sec.flags |= SEC_LEVEL;
7976 sec.level = SEC_LEVEL_1;
7977 }
7978 if (priv->ieee->set_security)
7979 priv->ieee->set_security(priv->ieee->dev, &sec);
7980 break;
7981 }
7982
7983 case IW_AUTH_80211_AUTH_ALG:
7984 ret = ipw2100_wpa_set_auth_algs(priv, param->value);
7985 break;
7986
7987 case IW_AUTH_WPA_ENABLED:
7988 ret = ipw2100_wpa_enable(priv, param->value);
7989 break;
7990
7991 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
7992 ieee->ieee802_1x = param->value;
7993 break;
7994
7995 //case IW_AUTH_ROAMING_CONTROL:
7996 case IW_AUTH_PRIVACY_INVOKED:
7997 ieee->privacy_invoked = param->value;
7998 break;
7999
8000 default:
8001 return -EOPNOTSUPP;
8002 }
8003 return ret;
8004}
8005
8006/* SIOCGIWAUTH */
8007static int ipw2100_wx_get_auth(struct net_device *dev,
8008 struct iw_request_info *info,
8009 union iwreq_data *wrqu, char *extra)
8010{
8011 struct ipw2100_priv *priv = ieee80211_priv(dev);
8012 struct ieee80211_device *ieee = priv->ieee;
8013 struct ieee80211_crypt_data *crypt;
8014 struct iw_param *param = &wrqu->param;
8015 int ret = 0;
8016
8017 switch (param->flags & IW_AUTH_INDEX) {
8018 case IW_AUTH_WPA_VERSION:
8019 case IW_AUTH_CIPHER_PAIRWISE:
8020 case IW_AUTH_CIPHER_GROUP:
8021 case IW_AUTH_KEY_MGMT:
8022 /*
8023 * wpa_supplicant will control these internally
8024 */
8025 ret = -EOPNOTSUPP;
8026 break;
8027
8028 case IW_AUTH_TKIP_COUNTERMEASURES:
8029 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
8030 if (!crypt || !crypt->ops->get_flags) {
8031 IPW_DEBUG_WARNING("Can't get TKIP countermeasures: "
8032 "crypt not set!\n");
8033 break;
8034 }
8035
8036 param->value = (crypt->ops->get_flags(crypt->priv) &
8037 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) ? 1 : 0;
8038
8039 break;
8040
8041 case IW_AUTH_DROP_UNENCRYPTED:
8042 param->value = ieee->drop_unencrypted;
8043 break;
8044
8045 case IW_AUTH_80211_AUTH_ALG:
8046 param->value = priv->ieee->sec.auth_mode;
8047 break;
8048
8049 case IW_AUTH_WPA_ENABLED:
8050 param->value = ieee->wpa_enabled;
8051 break;
8052
8053 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
8054 param->value = ieee->ieee802_1x;
8055 break;
8056
8057 case IW_AUTH_ROAMING_CONTROL:
8058 case IW_AUTH_PRIVACY_INVOKED:
8059 param->value = ieee->privacy_invoked;
8060 break;
8061
8062 default:
8063 return -EOPNOTSUPP;
8064 }
8065 return 0;
8066}
8067
8068/* SIOCSIWENCODEEXT */
8069static int ipw2100_wx_set_encodeext(struct net_device *dev,
8070 struct iw_request_info *info,
8071 union iwreq_data *wrqu, char *extra)
8072{
8073 struct ipw2100_priv *priv = ieee80211_priv(dev);
8074 return ieee80211_wx_set_encodeext(priv->ieee, info, wrqu, extra);
8075}
8076
8077/* SIOCGIWENCODEEXT */
8078static int ipw2100_wx_get_encodeext(struct net_device *dev,
8079 struct iw_request_info *info,
8080 union iwreq_data *wrqu, char *extra)
8081{
8082 struct ipw2100_priv *priv = ieee80211_priv(dev);
8083 return ieee80211_wx_get_encodeext(priv->ieee, info, wrqu, extra);
8084}
8085
8086/* SIOCSIWMLME */
8087static int ipw2100_wx_set_mlme(struct net_device *dev,
8088 struct iw_request_info *info,
8089 union iwreq_data *wrqu, char *extra)
8090{
8091 struct ipw2100_priv *priv = ieee80211_priv(dev);
8092 struct iw_mlme *mlme = (struct iw_mlme *)extra;
8093 u16 reason;
8094
8095 reason = cpu_to_le16(mlme->reason_code);
8096
8097 switch (mlme->cmd) {
8098 case IW_MLME_DEAUTH:
8099 // silently ignore
8100 break;
8101
8102 case IW_MLME_DISASSOC:
8103 ipw2100_disassociate_bssid(priv);
8104 break;
8105
8106 default:
8107 return -EOPNOTSUPP;
8108 }
8109 return 0;
8110}
8111#endif /* WIRELESS_EXT > 17 */
7893 8112
7894/* 8113/*
7895 * 8114 *
@@ -7923,7 +8142,7 @@ static int ipw2100_wx_set_promisc(struct net_device *dev,
7923 if (priv->ieee->iw_mode == IW_MODE_MONITOR) 8142 if (priv->ieee->iw_mode == IW_MODE_MONITOR)
7924 err = ipw2100_switch_mode(priv, priv->last_mode); 8143 err = ipw2100_switch_mode(priv, priv->last_mode);
7925 } 8144 }
7926 done: 8145 done:
7927 up(&priv->action_sem); 8146 up(&priv->action_sem);
7928 return err; 8147 return err;
7929} 8148}
@@ -7958,7 +8177,7 @@ static int ipw2100_wx_set_powermode(struct net_device *dev,
7958 8177
7959 if (priv->power_mode != mode) 8178 if (priv->power_mode != mode)
7960 err = ipw2100_set_power_mode(priv, mode); 8179 err = ipw2100_set_power_mode(priv, mode);
7961 done: 8180 done:
7962 up(&priv->action_sem); 8181 up(&priv->action_sem);
7963 return err; 8182 return err;
7964} 8183}
@@ -7986,8 +8205,8 @@ static int ipw2100_wx_get_powermode(struct net_device *dev,
7986 "Power save level: %d (None)", level); 8205 "Power save level: %d (None)", level);
7987 break; 8206 break;
7988 case IPW_POWER_AUTO: 8207 case IPW_POWER_AUTO:
7989 snprintf(extra, MAX_POWER_STRING, 8208 snprintf(extra, MAX_POWER_STRING,
7990 "Power save level: %d (Auto)", 0); 8209 "Power save level: %d (Auto)", 0);
7991 break; 8210 break;
7992 default: 8211 default:
7993 timeout = timeout_duration[level - 1] / 1000; 8212 timeout = timeout_duration[level - 1] / 1000;
@@ -8004,7 +8223,6 @@ static int ipw2100_wx_get_powermode(struct net_device *dev,
8004 return 0; 8223 return 0;
8005} 8224}
8006 8225
8007
8008static int ipw2100_wx_set_preamble(struct net_device *dev, 8226static int ipw2100_wx_set_preamble(struct net_device *dev,
8009 struct iw_request_info *info, 8227 struct iw_request_info *info,
8010 union iwreq_data *wrqu, char *extra) 8228 union iwreq_data *wrqu, char *extra)
@@ -8029,14 +8247,14 @@ static int ipw2100_wx_set_preamble(struct net_device *dev,
8029 8247
8030 err = ipw2100_system_config(priv, 0); 8248 err = ipw2100_system_config(priv, 0);
8031 8249
8032done: 8250 done:
8033 up(&priv->action_sem); 8251 up(&priv->action_sem);
8034 return err; 8252 return err;
8035} 8253}
8036 8254
8037static int ipw2100_wx_get_preamble(struct net_device *dev, 8255static int ipw2100_wx_get_preamble(struct net_device *dev,
8038 struct iw_request_info *info, 8256 struct iw_request_info *info,
8039 union iwreq_data *wrqu, char *extra) 8257 union iwreq_data *wrqu, char *extra)
8040{ 8258{
8041 /* 8259 /*
8042 * This can be called at any time. No action lock required 8260 * This can be called at any time. No action lock required
@@ -8052,54 +8270,116 @@ static int ipw2100_wx_get_preamble(struct net_device *dev,
8052 return 0; 8270 return 0;
8053} 8271}
8054 8272
8055static iw_handler ipw2100_wx_handlers[] = 8273#ifdef CONFIG_IPW2100_MONITOR
8056{ 8274static int ipw2100_wx_set_crc_check(struct net_device *dev,
8057 NULL, /* SIOCSIWCOMMIT */ 8275 struct iw_request_info *info,
8058 ipw2100_wx_get_name, /* SIOCGIWNAME */ 8276 union iwreq_data *wrqu, char *extra)
8059 NULL, /* SIOCSIWNWID */ 8277{
8060 NULL, /* SIOCGIWNWID */ 8278 struct ipw2100_priv *priv = ieee80211_priv(dev);
8061 ipw2100_wx_set_freq, /* SIOCSIWFREQ */ 8279 int err, mode = *(int *)extra;
8062 ipw2100_wx_get_freq, /* SIOCGIWFREQ */ 8280
8063 ipw2100_wx_set_mode, /* SIOCSIWMODE */ 8281 down(&priv->action_sem);
8064 ipw2100_wx_get_mode, /* SIOCGIWMODE */ 8282 if (!(priv->status & STATUS_INITIALIZED)) {
8065 NULL, /* SIOCSIWSENS */ 8283 err = -EIO;
8066 NULL, /* SIOCGIWSENS */ 8284 goto done;
8067 NULL, /* SIOCSIWRANGE */ 8285 }
8068 ipw2100_wx_get_range, /* SIOCGIWRANGE */ 8286
8069 NULL, /* SIOCSIWPRIV */ 8287 if (mode == 1)
8070 NULL, /* SIOCGIWPRIV */ 8288 priv->config |= CFG_CRC_CHECK;
8071 NULL, /* SIOCSIWSTATS */ 8289 else if (mode == 0)
8072 NULL, /* SIOCGIWSTATS */ 8290 priv->config &= ~CFG_CRC_CHECK;
8073 NULL, /* SIOCSIWSPY */ 8291 else {
8074 NULL, /* SIOCGIWSPY */ 8292 err = -EINVAL;
8075 NULL, /* SIOCGIWTHRSPY */ 8293 goto done;
8076 NULL, /* SIOCWIWTHRSPY */ 8294 }
8077 ipw2100_wx_set_wap, /* SIOCSIWAP */ 8295 err = 0;
8078 ipw2100_wx_get_wap, /* SIOCGIWAP */ 8296
8079 NULL, /* -- hole -- */ 8297 done:
8080 NULL, /* SIOCGIWAPLIST -- deprecated */ 8298 up(&priv->action_sem);
8081 ipw2100_wx_set_scan, /* SIOCSIWSCAN */ 8299 return err;
8082 ipw2100_wx_get_scan, /* SIOCGIWSCAN */ 8300}
8083 ipw2100_wx_set_essid, /* SIOCSIWESSID */ 8301
8084 ipw2100_wx_get_essid, /* SIOCGIWESSID */ 8302static int ipw2100_wx_get_crc_check(struct net_device *dev,
8085 ipw2100_wx_set_nick, /* SIOCSIWNICKN */ 8303 struct iw_request_info *info,
8086 ipw2100_wx_get_nick, /* SIOCGIWNICKN */ 8304 union iwreq_data *wrqu, char *extra)
8087 NULL, /* -- hole -- */ 8305{
8088 NULL, /* -- hole -- */ 8306 /*
8089 ipw2100_wx_set_rate, /* SIOCSIWRATE */ 8307 * This can be called at any time. No action lock required
8090 ipw2100_wx_get_rate, /* SIOCGIWRATE */ 8308 */
8091 ipw2100_wx_set_rts, /* SIOCSIWRTS */ 8309
8092 ipw2100_wx_get_rts, /* SIOCGIWRTS */ 8310 struct ipw2100_priv *priv = ieee80211_priv(dev);
8093 ipw2100_wx_set_frag, /* SIOCSIWFRAG */ 8311
8094 ipw2100_wx_get_frag, /* SIOCGIWFRAG */ 8312 if (priv->config & CFG_CRC_CHECK)
8095 ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */ 8313 snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)");
8096 ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */ 8314 else
8097 ipw2100_wx_set_retry, /* SIOCSIWRETRY */ 8315 snprintf(wrqu->name, IFNAMSIZ, "CRC ignored (0)");
8098 ipw2100_wx_get_retry, /* SIOCGIWRETRY */ 8316
8099 ipw2100_wx_set_encode, /* SIOCSIWENCODE */ 8317 return 0;
8100 ipw2100_wx_get_encode, /* SIOCGIWENCODE */ 8318}
8101 ipw2100_wx_set_power, /* SIOCSIWPOWER */ 8319#endif /* CONFIG_IPW2100_MONITOR */
8102 ipw2100_wx_get_power, /* SIOCGIWPOWER */ 8320
8321static iw_handler ipw2100_wx_handlers[] = {
8322 NULL, /* SIOCSIWCOMMIT */
8323 ipw2100_wx_get_name, /* SIOCGIWNAME */
8324 NULL, /* SIOCSIWNWID */
8325 NULL, /* SIOCGIWNWID */
8326 ipw2100_wx_set_freq, /* SIOCSIWFREQ */
8327 ipw2100_wx_get_freq, /* SIOCGIWFREQ */
8328 ipw2100_wx_set_mode, /* SIOCSIWMODE */
8329 ipw2100_wx_get_mode, /* SIOCGIWMODE */
8330 NULL, /* SIOCSIWSENS */
8331 NULL, /* SIOCGIWSENS */
8332 NULL, /* SIOCSIWRANGE */
8333 ipw2100_wx_get_range, /* SIOCGIWRANGE */
8334 NULL, /* SIOCSIWPRIV */
8335 NULL, /* SIOCGIWPRIV */
8336 NULL, /* SIOCSIWSTATS */
8337 NULL, /* SIOCGIWSTATS */
8338 NULL, /* SIOCSIWSPY */
8339 NULL, /* SIOCGIWSPY */
8340 NULL, /* SIOCGIWTHRSPY */
8341 NULL, /* SIOCWIWTHRSPY */
8342 ipw2100_wx_set_wap, /* SIOCSIWAP */
8343 ipw2100_wx_get_wap, /* SIOCGIWAP */
8344#if WIRELESS_EXT > 17
8345 ipw2100_wx_set_mlme, /* SIOCSIWMLME */
8346#else
8347 NULL, /* -- hole -- */
8348#endif
8349 NULL, /* SIOCGIWAPLIST -- deprecated */
8350 ipw2100_wx_set_scan, /* SIOCSIWSCAN */
8351 ipw2100_wx_get_scan, /* SIOCGIWSCAN */
8352 ipw2100_wx_set_essid, /* SIOCSIWESSID */
8353 ipw2100_wx_get_essid, /* SIOCGIWESSID */
8354 ipw2100_wx_set_nick, /* SIOCSIWNICKN */
8355 ipw2100_wx_get_nick, /* SIOCGIWNICKN */
8356 NULL, /* -- hole -- */
8357 NULL, /* -- hole -- */
8358 ipw2100_wx_set_rate, /* SIOCSIWRATE */
8359 ipw2100_wx_get_rate, /* SIOCGIWRATE */
8360 ipw2100_wx_set_rts, /* SIOCSIWRTS */
8361 ipw2100_wx_get_rts, /* SIOCGIWRTS */
8362 ipw2100_wx_set_frag, /* SIOCSIWFRAG */
8363 ipw2100_wx_get_frag, /* SIOCGIWFRAG */
8364 ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */
8365 ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */
8366 ipw2100_wx_set_retry, /* SIOCSIWRETRY */
8367 ipw2100_wx_get_retry, /* SIOCGIWRETRY */
8368 ipw2100_wx_set_encode, /* SIOCSIWENCODE */
8369 ipw2100_wx_get_encode, /* SIOCGIWENCODE */
8370 ipw2100_wx_set_power, /* SIOCSIWPOWER */
8371 ipw2100_wx_get_power, /* SIOCGIWPOWER */
8372#if WIRELESS_EXT > 17
8373 NULL, /* -- hole -- */
8374 NULL, /* -- hole -- */
8375 ipw2100_wx_set_genie, /* SIOCSIWGENIE */
8376 ipw2100_wx_get_genie, /* SIOCGIWGENIE */
8377 ipw2100_wx_set_auth, /* SIOCSIWAUTH */
8378 ipw2100_wx_get_auth, /* SIOCGIWAUTH */
8379 ipw2100_wx_set_encodeext, /* SIOCSIWENCODEEXT */
8380 ipw2100_wx_get_encodeext, /* SIOCGIWENCODEEXT */
8381 NULL, /* SIOCSIWPMKSA */
8382#endif
8103}; 8383};
8104 8384
8105#define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV 8385#define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV
@@ -8108,60 +8388,71 @@ static iw_handler ipw2100_wx_handlers[] =
8108#define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3 8388#define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3
8109#define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4 8389#define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4
8110#define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5 8390#define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5
8391#define IPW2100_PRIV_SET_CRC_CHECK SIOCIWFIRSTPRIV+6
8392#define IPW2100_PRIV_GET_CRC_CHECK SIOCIWFIRSTPRIV+7
8111 8393
8112static const struct iw_priv_args ipw2100_private_args[] = { 8394static const struct iw_priv_args ipw2100_private_args[] = {
8113 8395
8114#ifdef CONFIG_IPW2100_MONITOR 8396#ifdef CONFIG_IPW2100_MONITOR
8115 { 8397 {
8116 IPW2100_PRIV_SET_MONITOR, 8398 IPW2100_PRIV_SET_MONITOR,
8117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" 8399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"},
8118 },
8119 { 8400 {
8120 IPW2100_PRIV_RESET, 8401 IPW2100_PRIV_RESET,
8121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" 8402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"},
8122 }, 8403#endif /* CONFIG_IPW2100_MONITOR */
8123#endif /* CONFIG_IPW2100_MONITOR */
8124 8404
8125 { 8405 {
8126 IPW2100_PRIV_SET_POWER, 8406 IPW2100_PRIV_SET_POWER,
8127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power" 8407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power"},
8128 },
8129 { 8408 {
8130 IPW2100_PRIV_GET_POWER, 8409 IPW2100_PRIV_GET_POWER,
8131 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING, "get_power" 8410 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING,
8132 }, 8411 "get_power"},
8133 { 8412 {
8134 IPW2100_PRIV_SET_LONGPREAMBLE, 8413 IPW2100_PRIV_SET_LONGPREAMBLE,
8135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble" 8414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"},
8136 },
8137 { 8415 {
8138 IPW2100_PRIV_GET_LONGPREAMBLE, 8416 IPW2100_PRIV_GET_LONGPREAMBLE,
8139 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble" 8417 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble"},
8140 }, 8418#ifdef CONFIG_IPW2100_MONITOR
8419 {
8420 IPW2100_PRIV_SET_CRC_CHECK,
8421 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_crc_check"},
8422 {
8423 IPW2100_PRIV_GET_CRC_CHECK,
8424 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_crc_check"},
8425#endif /* CONFIG_IPW2100_MONITOR */
8141}; 8426};
8142 8427
8143static iw_handler ipw2100_private_handler[] = { 8428static iw_handler ipw2100_private_handler[] = {
8144#ifdef CONFIG_IPW2100_MONITOR 8429#ifdef CONFIG_IPW2100_MONITOR
8145 ipw2100_wx_set_promisc, 8430 ipw2100_wx_set_promisc,
8146 ipw2100_wx_reset, 8431 ipw2100_wx_reset,
8147#else /* CONFIG_IPW2100_MONITOR */ 8432#else /* CONFIG_IPW2100_MONITOR */
8148 NULL, 8433 NULL,
8149 NULL, 8434 NULL,
8150#endif /* CONFIG_IPW2100_MONITOR */ 8435#endif /* CONFIG_IPW2100_MONITOR */
8151 ipw2100_wx_set_powermode, 8436 ipw2100_wx_set_powermode,
8152 ipw2100_wx_get_powermode, 8437 ipw2100_wx_get_powermode,
8153 ipw2100_wx_set_preamble, 8438 ipw2100_wx_set_preamble,
8154 ipw2100_wx_get_preamble, 8439 ipw2100_wx_get_preamble,
8440#ifdef CONFIG_IPW2100_MONITOR
8441 ipw2100_wx_set_crc_check,
8442 ipw2100_wx_get_crc_check,
8443#else /* CONFIG_IPW2100_MONITOR */
8444 NULL,
8445 NULL,
8446#endif /* CONFIG_IPW2100_MONITOR */
8155}; 8447};
8156 8448
8157static struct iw_handler_def ipw2100_wx_handler_def = 8449static struct iw_handler_def ipw2100_wx_handler_def = {
8158{
8159 .standard = ipw2100_wx_handlers, 8450 .standard = ipw2100_wx_handlers,
8160 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler), 8451 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8161 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler), 8452 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8162 .num_private_args = sizeof(ipw2100_private_args) / 8453 .num_private_args = sizeof(ipw2100_private_args) /
8163 sizeof(struct iw_priv_args), 8454 sizeof(struct iw_priv_args),
8164 .private = (iw_handler *)ipw2100_private_handler, 8455 .private = (iw_handler *) ipw2100_private_handler,
8165 .private_args = (struct iw_priv_args *)ipw2100_private_args, 8456 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8166}; 8457};
8167 8458
@@ -8170,7 +8461,7 @@ static struct iw_handler_def ipw2100_wx_handler_def =
8170 * Called by /proc/net/wireless 8461 * Called by /proc/net/wireless
8171 * Also called by SIOCGIWSTATS 8462 * Also called by SIOCGIWSTATS
8172 */ 8463 */
8173static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) 8464static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8174{ 8465{
8175 enum { 8466 enum {
8176 POOR = 30, 8467 POOR = 30,
@@ -8190,7 +8481,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8190 u32 ord_len = sizeof(u32); 8481 u32 ord_len = sizeof(u32);
8191 8482
8192 if (!priv) 8483 if (!priv)
8193 return (struct iw_statistics *) NULL; 8484 return (struct iw_statistics *)NULL;
8194 8485
8195 wstats = &priv->wstats; 8486 wstats = &priv->wstats;
8196 8487
@@ -8207,7 +8498,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8207 wstats->qual.noise = 0; 8498 wstats->qual.noise = 0;
8208 wstats->qual.updated = 7; 8499 wstats->qual.updated = 7;
8209 wstats->qual.updated |= IW_QUAL_NOISE_INVALID | 8500 wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
8210 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; 8501 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
8211 return wstats; 8502 return wstats;
8212 } 8503 }
8213 8504
@@ -8215,7 +8506,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8215 &missed_beacons, &ord_len)) 8506 &missed_beacons, &ord_len))
8216 goto fail_get_ordinal; 8507 goto fail_get_ordinal;
8217 8508
8218 /* If we don't have a connection the quality and level is 0*/ 8509 /* If we don't have a connection the quality and level is 0 */
8219 if (!(priv->status & STATUS_ASSOCIATED)) { 8510 if (!(priv->status & STATUS_ASSOCIATED)) {
8220 wstats->qual.qual = 0; 8511 wstats->qual.qual = 0;
8221 wstats->qual.level = 0; 8512 wstats->qual.level = 0;
@@ -8232,10 +8523,10 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8232 rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR; 8523 rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR;
8233 else if (rssi < 30) 8524 else if (rssi < 30)
8234 rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) / 8525 rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) /
8235 10 + GOOD; 8526 10 + GOOD;
8236 else 8527 else
8237 rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) / 8528 rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) /
8238 10 + VERY_GOOD; 8529 10 + VERY_GOOD;
8239 8530
8240 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES, 8531 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES,
8241 &tx_retries, &ord_len)) 8532 &tx_retries, &ord_len))
@@ -8249,25 +8540,25 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8249 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; 8540 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
8250 else if (tx_retries > 50) 8541 else if (tx_retries > 50)
8251 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / 8542 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
8252 15 + GOOD; 8543 15 + GOOD;
8253 else 8544 else
8254 tx_qual = (50 - tx_retries) * 8545 tx_qual = (50 - tx_retries) *
8255 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; 8546 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
8256 8547
8257 if (missed_beacons > 50) 8548 if (missed_beacons > 50)
8258 beacon_qual = (60 - missed_beacons) * POOR / 10; 8549 beacon_qual = (60 - missed_beacons) * POOR / 10;
8259 else if (missed_beacons > 40) 8550 else if (missed_beacons > 40)
8260 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) / 8551 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) /
8261 10 + POOR; 8552 10 + POOR;
8262 else if (missed_beacons > 32) 8553 else if (missed_beacons > 32)
8263 beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) / 8554 beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) /
8264 18 + FAIR; 8555 18 + FAIR;
8265 else if (missed_beacons > 20) 8556 else if (missed_beacons > 20)
8266 beacon_qual = (32 - missed_beacons) * 8557 beacon_qual = (32 - missed_beacons) *
8267 (VERY_GOOD - GOOD) / 20 + GOOD; 8558 (VERY_GOOD - GOOD) / 20 + GOOD;
8268 else 8559 else
8269 beacon_qual = (20 - missed_beacons) * 8560 beacon_qual = (20 - missed_beacons) *
8270 (PERFECT - VERY_GOOD) / 20 + VERY_GOOD; 8561 (PERFECT - VERY_GOOD) / 20 + VERY_GOOD;
8271 8562
8272 quality = min(beacon_qual, min(tx_qual, rssi_qual)); 8563 quality = min(beacon_qual, min(tx_qual, rssi_qual));
8273 8564
@@ -8290,7 +8581,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8290 wstats->qual.updated = 7; 8581 wstats->qual.updated = 7;
8291 wstats->qual.updated |= IW_QUAL_NOISE_INVALID; 8582 wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
8292 8583
8293 /* FIXME: this is percent and not a # */ 8584 /* FIXME: this is percent and not a # */
8294 wstats->miss.beacon = missed_beacons; 8585 wstats->miss.beacon = missed_beacons;
8295 8586
8296 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES, 8587 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES,
@@ -8300,10 +8591,10 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8300 8591
8301 return wstats; 8592 return wstats;
8302 8593
8303 fail_get_ordinal: 8594 fail_get_ordinal:
8304 IPW_DEBUG_WX("failed querying ordinals.\n"); 8595 IPW_DEBUG_WX("failed querying ordinals.\n");
8305 8596
8306 return (struct iw_statistics *) NULL; 8597 return (struct iw_statistics *)NULL;
8307} 8598}
8308 8599
8309static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8600static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
@@ -8326,23 +8617,17 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8326 if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) || 8617 if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) ||
8327 priv->status & STATUS_RF_KILL_MASK || 8618 priv->status & STATUS_RF_KILL_MASK ||
8328 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, 8619 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
8329 &priv->bssid, &len)) { 8620 &priv->bssid, &len)) {
8330 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); 8621 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
8331 } else { 8622 } else {
8332 /* We now have the BSSID, so can finish setting to the full 8623 /* We now have the BSSID, so can finish setting to the full
8333 * associated state */ 8624 * associated state */
8334 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN); 8625 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN);
8335 memcpy(&priv->ieee->bssid, priv->bssid, ETH_ALEN); 8626 memcpy(priv->ieee->bssid, priv->bssid, ETH_ALEN);
8336 priv->status &= ~STATUS_ASSOCIATING; 8627 priv->status &= ~STATUS_ASSOCIATING;
8337 priv->status |= STATUS_ASSOCIATED; 8628 priv->status |= STATUS_ASSOCIATED;
8338 netif_carrier_on(priv->net_dev); 8629 netif_carrier_on(priv->net_dev);
8339 if (netif_queue_stopped(priv->net_dev)) { 8630 netif_wake_queue(priv->net_dev);
8340 IPW_DEBUG_INFO("Waking net queue.\n");
8341 netif_wake_queue(priv->net_dev);
8342 } else {
8343 IPW_DEBUG_INFO("Starting net queue.\n");
8344 netif_start_queue(priv->net_dev);
8345 }
8346 } 8631 }
8347 8632
8348 if (!(priv->status & STATUS_ASSOCIATED)) { 8633 if (!(priv->status & STATUS_ASSOCIATED)) {
@@ -8351,7 +8636,8 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8351 /* This is a disassociation event, so kick the firmware to 8636 /* This is a disassociation event, so kick the firmware to
8352 * look for another AP */ 8637 * look for another AP */
8353 if (priv->config & CFG_STATIC_ESSID) 8638 if (priv->config & CFG_STATIC_ESSID)
8354 ipw2100_set_essid(priv, priv->essid, priv->essid_len, 0); 8639 ipw2100_set_essid(priv, priv->essid, priv->essid_len,
8640 0);
8355 else 8641 else
8356 ipw2100_set_essid(priv, NULL, 0, 0); 8642 ipw2100_set_essid(priv, NULL, 0, 0);
8357 up(&priv->action_sem); 8643 up(&priv->action_sem);
@@ -8374,7 +8660,6 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8374 8660
8375#define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw" 8661#define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw"
8376 8662
8377
8378/* 8663/*
8379 8664
8380BINARY FIRMWARE HEADER FORMAT 8665BINARY FIRMWARE HEADER FORMAT
@@ -8396,12 +8681,10 @@ struct ipw2100_fw_header {
8396 unsigned int uc_size; 8681 unsigned int uc_size;
8397} __attribute__ ((packed)); 8682} __attribute__ ((packed));
8398 8683
8399
8400
8401static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw) 8684static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw)
8402{ 8685{
8403 struct ipw2100_fw_header *h = 8686 struct ipw2100_fw_header *h =
8404 (struct ipw2100_fw_header *)fw->fw_entry->data; 8687 (struct ipw2100_fw_header *)fw->fw_entry->data;
8405 8688
8406 if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) { 8689 if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) {
8407 printk(KERN_WARNING DRV_NAME ": Firmware image not compatible " 8690 printk(KERN_WARNING DRV_NAME ": Firmware image not compatible "
@@ -8420,7 +8703,6 @@ static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw)
8420 return 0; 8703 return 0;
8421} 8704}
8422 8705
8423
8424static int ipw2100_get_firmware(struct ipw2100_priv *priv, 8706static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8425 struct ipw2100_fw *fw) 8707 struct ipw2100_fw *fw)
8426{ 8708{
@@ -8428,7 +8710,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8428 int rc; 8710 int rc;
8429 8711
8430 IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n", 8712 IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n",
8431 priv->net_dev->name); 8713 priv->net_dev->name);
8432 8714
8433 switch (priv->ieee->iw_mode) { 8715 switch (priv->ieee->iw_mode) {
8434 case IW_MODE_ADHOC: 8716 case IW_MODE_ADHOC:
@@ -8454,7 +8736,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8454 return rc; 8736 return rc;
8455 } 8737 }
8456 IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data, 8738 IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data,
8457 fw->fw_entry->size); 8739 fw->fw_entry->size);
8458 8740
8459 ipw2100_mod_firmware_load(fw); 8741 ipw2100_mod_firmware_load(fw);
8460 8742
@@ -8470,7 +8752,6 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
8470 fw->fw_entry = NULL; 8752 fw->fw_entry = NULL;
8471} 8753}
8472 8754
8473
8474static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf, 8755static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
8475 size_t max) 8756 size_t max)
8476{ 8757{
@@ -8479,8 +8760,7 @@ static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
8479 u32 tmp; 8760 u32 tmp;
8480 int i; 8761 int i;
8481 /* firmware version is an ascii string (max len of 14) */ 8762 /* firmware version is an ascii string (max len of 14) */
8482 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, 8763 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, ver, &len))
8483 ver, &len))
8484 return -EIO; 8764 return -EIO;
8485 tmp = max; 8765 tmp = max;
8486 if (len >= max) 8766 if (len >= max)
@@ -8497,8 +8777,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
8497 u32 ver; 8777 u32 ver;
8498 u32 len = sizeof(ver); 8778 u32 len = sizeof(ver);
8499 /* microcode version is a 32 bit integer */ 8779 /* microcode version is a 32 bit integer */
8500 if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, 8780 if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, &ver, &len))
8501 &ver, &len))
8502 return -EIO; 8781 return -EIO;
8503 return snprintf(buf, max, "%08X", ver); 8782 return snprintf(buf, max, "%08X", ver);
8504} 8783}
@@ -8506,8 +8785,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
8506/* 8785/*
8507 * On exit, the firmware will have been freed from the fw list 8786 * On exit, the firmware will have been freed from the fw list
8508 */ 8787 */
8509static int ipw2100_fw_download(struct ipw2100_priv *priv, 8788static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
8510 struct ipw2100_fw *fw)
8511{ 8789{
8512 /* firmware is constructed of N contiguous entries, each entry is 8790 /* firmware is constructed of N contiguous entries, each entry is
8513 * structured as: 8791 * structured as:
@@ -8515,7 +8793,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8515 * offset sie desc 8793 * offset sie desc
8516 * 0 4 address to write to 8794 * 0 4 address to write to
8517 * 4 2 length of data run 8795 * 4 2 length of data run
8518 * 6 length data 8796 * 6 length data
8519 */ 8797 */
8520 unsigned int addr; 8798 unsigned int addr;
8521 unsigned short len; 8799 unsigned short len;
@@ -8524,12 +8802,12 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8524 unsigned int firmware_data_left = fw->fw.size; 8802 unsigned int firmware_data_left = fw->fw.size;
8525 8803
8526 while (firmware_data_left > 0) { 8804 while (firmware_data_left > 0) {
8527 addr = *(u32 *)(firmware_data); 8805 addr = *(u32 *) (firmware_data);
8528 firmware_data += 4; 8806 firmware_data += 4;
8529 firmware_data_left -= 4; 8807 firmware_data_left -= 4;
8530 8808
8531 len = *(u16 *)(firmware_data); 8809 len = *(u16 *) (firmware_data);
8532 firmware_data += 2; 8810 firmware_data += 2;
8533 firmware_data_left -= 2; 8811 firmware_data_left -= 2;
8534 8812
8535 if (len > 32) { 8813 if (len > 32) {
@@ -8540,7 +8818,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8540 } 8818 }
8541 8819
8542 write_nic_memory(priv->net_dev, addr, len, firmware_data); 8820 write_nic_memory(priv->net_dev, addr, len, firmware_data);
8543 firmware_data += len; 8821 firmware_data += len;
8544 firmware_data_left -= len; 8822 firmware_data_left -= len;
8545 } 8823 }
8546 8824
@@ -8654,21 +8932,19 @@ static int ipw2100_ucode_download(struct ipw2100_priv *priv,
8654 for (i = 0; i < 30; i++) { 8932 for (i = 0; i < 30; i++) {
8655 /* Read alive response structure */ 8933 /* Read alive response structure */
8656 for (j = 0; 8934 for (j = 0;
8657 j < (sizeof(struct symbol_alive_response) >> 1); 8935 j < (sizeof(struct symbol_alive_response) >> 1); j++)
8658 j++) 8936 read_nic_word(dev, 0x210004, ((u16 *) & response) + j);
8659 read_nic_word(dev, 0x210004,
8660 ((u16 *)&response) + j);
8661 8937
8662 if ((response.cmd_id == 1) && 8938 if ((response.cmd_id == 1) && (response.ucode_valid == 0x1))
8663 (response.ucode_valid == 0x1))
8664 break; 8939 break;
8665 udelay(10); 8940 udelay(10);
8666 } 8941 }
8667 8942
8668 if (i == 30) { 8943 if (i == 30) {
8669 printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n", 8944 printk(KERN_ERR DRV_NAME
8945 ": %s: No response from Symbol - hw not alive\n",
8670 dev->name); 8946 dev->name);
8671 printk_buf(IPW_DL_ERROR, (u8*)&response, sizeof(response)); 8947 printk_buf(IPW_DL_ERROR, (u8 *) & response, sizeof(response));
8672 return -EIO; 8948 return -EIO;
8673 } 8949 }
8674 8950