aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ipw2100.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-11-09 00:47:08 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-11-09 00:47:08 -0500
commiteedb9f09e92598c165de37a8c210434d270ca3a6 (patch)
tree11f4ab9bcc75210c2b4a15dc33c3f4d6a612deec /drivers/net/wireless/ipw2100.c
parentf24e09754bcb4d367664ea635c0c4ccde6ec4df5 (diff)
parent826d2abe9945372c8838398bfd88a1caa5844d41 (diff)
Merge rsync://bughost.org/repos/ipw-delta/
Diffstat (limited to 'drivers/net/wireless/ipw2100.c')
-rw-r--r--drivers/net/wireless/ipw2100.c2850
1 files changed, 1562 insertions, 1288 deletions
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 4f19ac7d63a8..877ac514aa07 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,7 +3742,7 @@ 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;
@@ -3758,32 +3754,30 @@ static ssize_t store_memory(struct device *d, struct device_attribute *attr,
3758 if (p[0] == '1' || 3754 if (p[0] == '1' ||
3759 (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) { 3755 (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) {
3760 IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n", 3756 IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n",
3761 dev->name); 3757 dev->name);
3762 priv->dump_raw = 1; 3758 priv->dump_raw = 1;
3763 3759
3764 } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' && 3760 } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' &&
3765 tolower(p[1]) == 'f')) { 3761 tolower(p[1]) == 'f')) {
3766 IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n", 3762 IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n",
3767 dev->name); 3763 dev->name);
3768 priv->dump_raw = 0; 3764 priv->dump_raw = 0;
3769 3765
3770 } else if (tolower(p[0]) == 'r') { 3766 } else if (tolower(p[0]) == 'r') {
3771 IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", 3767 IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", dev->name);
3772 dev->name);
3773 ipw2100_snapshot_free(priv); 3768 ipw2100_snapshot_free(priv);
3774 3769
3775 } else 3770 } else
3776 IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, " 3771 IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, "
3777 "reset = clear memory snapshot\n", 3772 "reset = clear memory snapshot\n", dev->name);
3778 dev->name);
3779 3773
3780 return count; 3774 return count;
3781} 3775}
3782static DEVICE_ATTR(memory, S_IWUSR|S_IRUGO, show_memory, store_memory);
3783 3776
3777static DEVICE_ATTR(memory, S_IWUSR | S_IRUGO, show_memory, store_memory);
3784 3778
3785static ssize_t show_ordinals(struct device *d, struct device_attribute *attr, 3779static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3786 char *buf) 3780 char *buf)
3787{ 3781{
3788 struct ipw2100_priv *priv = dev_get_drvdata(d); 3782 struct ipw2100_priv *priv = dev_get_drvdata(d);
3789 u32 val = 0; 3783 u32 val = 0;
@@ -3791,6 +3785,9 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3791 u32 val_len; 3785 u32 val_len;
3792 static int loop = 0; 3786 static int loop = 0;
3793 3787
3788 if (priv->status & STATUS_RF_KILL_MASK)
3789 return 0;
3790
3794 if (loop >= sizeof(ord_data) / sizeof(*ord_data)) 3791 if (loop >= sizeof(ord_data) / sizeof(*ord_data))
3795 loop = 0; 3792 loop = 0;
3796 3793
@@ -3814,14 +3811,14 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,
3814 3811
3815 return len; 3812 return len;
3816} 3813}
3817static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL);
3818 3814
3815static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL);
3819 3816
3820static ssize_t show_stats(struct device *d, struct device_attribute *attr, 3817static ssize_t show_stats(struct device *d, struct device_attribute *attr,
3821 char *buf) 3818 char *buf)
3822{ 3819{
3823 struct ipw2100_priv *priv = dev_get_drvdata(d); 3820 struct ipw2100_priv *priv = dev_get_drvdata(d);
3824 char * out = buf; 3821 char *out = buf;
3825 3822
3826 out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n", 3823 out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n",
3827 priv->interrupts, priv->tx_interrupts, 3824 priv->interrupts, priv->tx_interrupts,
@@ -3835,8 +3832,8 @@ static ssize_t show_stats(struct device *d, struct device_attribute *attr,
3835 3832
3836 return out - buf; 3833 return out - buf;
3837} 3834}
3838static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
3839 3835
3836static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
3840 3837
3841static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode) 3838static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3842{ 3839{
@@ -3864,19 +3861,18 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3864 priv->last_mode = priv->ieee->iw_mode; 3861 priv->last_mode = priv->ieee->iw_mode;
3865 priv->net_dev->type = ARPHRD_IEEE80211; 3862 priv->net_dev->type = ARPHRD_IEEE80211;
3866 break; 3863 break;
3867#endif /* CONFIG_IPW2100_MONITOR */ 3864#endif /* CONFIG_IPW2100_MONITOR */
3868 } 3865 }
3869 3866
3870 priv->ieee->iw_mode = mode; 3867 priv->ieee->iw_mode = mode;
3871 3868
3872#ifdef CONFIG_PM 3869#ifdef CONFIG_PM
3873 /* Indicate ipw2100_download_firmware download firmware 3870 /* Indicate ipw2100_download_firmware download firmware
3874 * from disk instead of memory. */ 3871 * from disk instead of memory. */
3875 ipw2100_firmware.version = 0; 3872 ipw2100_firmware.version = 0;
3876#endif 3873#endif
3877 3874
3878 printk(KERN_INFO "%s: Reseting on mode change.\n", 3875 printk(KERN_INFO "%s: Reseting on mode change.\n", priv->net_dev->name);
3879 priv->net_dev->name);
3880 priv->reset_backoff = 0; 3876 priv->reset_backoff = 0;
3881 schedule_reset(priv); 3877 schedule_reset(priv);
3882 3878
@@ -3884,12 +3880,12 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode)
3884} 3880}
3885 3881
3886static ssize_t show_internals(struct device *d, struct device_attribute *attr, 3882static ssize_t show_internals(struct device *d, struct device_attribute *attr,
3887 char *buf) 3883 char *buf)
3888{ 3884{
3889 struct ipw2100_priv *priv = dev_get_drvdata(d); 3885 struct ipw2100_priv *priv = dev_get_drvdata(d);
3890 int len = 0; 3886 int len = 0;
3891 3887
3892#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" # y "\n", priv-> x) 3888#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x)
3893 3889
3894 if (priv->status & STATUS_ASSOCIATED) 3890 if (priv->status & STATUS_ASSOCIATED)
3895 len += sprintf(buf + len, "connected: %lu\n", 3891 len += sprintf(buf + len, "connected: %lu\n",
@@ -3897,55 +3893,60 @@ static ssize_t show_internals(struct device *d, struct device_attribute *attr,
3897 else 3893 else
3898 len += sprintf(buf + len, "not connected\n"); 3894 len += sprintf(buf + len, "not connected\n");
3899 3895
3900 DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], p); 3896 DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], "p");
3901 DUMP_VAR(status, 08lx); 3897 DUMP_VAR(status, "08lx");
3902 DUMP_VAR(config, 08lx); 3898 DUMP_VAR(config, "08lx");
3903 DUMP_VAR(capability, 08lx); 3899 DUMP_VAR(capability, "08lx");
3904 3900
3905 len += sprintf(buf + len, "last_rtc: %lu\n", (unsigned long)priv->last_rtc); 3901 len +=
3902 sprintf(buf + len, "last_rtc: %lu\n",
3903 (unsigned long)priv->last_rtc);
3906 3904
3907 DUMP_VAR(fatal_error, d); 3905 DUMP_VAR(fatal_error, "d");
3908 DUMP_VAR(stop_hang_check, d); 3906 DUMP_VAR(stop_hang_check, "d");
3909 DUMP_VAR(stop_rf_kill, d); 3907 DUMP_VAR(stop_rf_kill, "d");
3910 DUMP_VAR(messages_sent, d); 3908 DUMP_VAR(messages_sent, "d");
3911 3909
3912 DUMP_VAR(tx_pend_stat.value, d); 3910 DUMP_VAR(tx_pend_stat.value, "d");
3913 DUMP_VAR(tx_pend_stat.hi, d); 3911 DUMP_VAR(tx_pend_stat.hi, "d");
3914 3912
3915 DUMP_VAR(tx_free_stat.value, d); 3913 DUMP_VAR(tx_free_stat.value, "d");
3916 DUMP_VAR(tx_free_stat.lo, d); 3914 DUMP_VAR(tx_free_stat.lo, "d");
3917 3915
3918 DUMP_VAR(msg_free_stat.value, d); 3916 DUMP_VAR(msg_free_stat.value, "d");
3919 DUMP_VAR(msg_free_stat.lo, d); 3917 DUMP_VAR(msg_free_stat.lo, "d");
3920 3918
3921 DUMP_VAR(msg_pend_stat.value, d); 3919 DUMP_VAR(msg_pend_stat.value, "d");
3922 DUMP_VAR(msg_pend_stat.hi, d); 3920 DUMP_VAR(msg_pend_stat.hi, "d");
3923 3921
3924 DUMP_VAR(fw_pend_stat.value, d); 3922 DUMP_VAR(fw_pend_stat.value, "d");
3925 DUMP_VAR(fw_pend_stat.hi, d); 3923 DUMP_VAR(fw_pend_stat.hi, "d");
3926 3924
3927 DUMP_VAR(txq_stat.value, d); 3925 DUMP_VAR(txq_stat.value, "d");
3928 DUMP_VAR(txq_stat.lo, d); 3926 DUMP_VAR(txq_stat.lo, "d");
3929 3927
3930 DUMP_VAR(ieee->scans, d); 3928 DUMP_VAR(ieee->scans, "d");
3931 DUMP_VAR(reset_backoff, d); 3929 DUMP_VAR(reset_backoff, "d");
3932 3930
3933 return len; 3931 return len;
3934} 3932}
3935static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL);
3936 3933
3934static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL);
3937 3935
3938static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr, 3936static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
3939 char *buf) 3937 char *buf)
3940{ 3938{
3941 struct ipw2100_priv *priv = dev_get_drvdata(d); 3939 struct ipw2100_priv *priv = dev_get_drvdata(d);
3942 char essid[IW_ESSID_MAX_SIZE + 1]; 3940 char essid[IW_ESSID_MAX_SIZE + 1];
3943 u8 bssid[ETH_ALEN]; 3941 u8 bssid[ETH_ALEN];
3944 u32 chan = 0; 3942 u32 chan = 0;
3945 char * out = buf; 3943 char *out = buf;
3946 int length; 3944 int length;
3947 int ret; 3945 int ret;
3948 3946
3947 if (priv->status & STATUS_RF_KILL_MASK)
3948 return 0;
3949
3949 memset(essid, 0, sizeof(essid)); 3950 memset(essid, 0, sizeof(essid));
3950 memset(bssid, 0, sizeof(bssid)); 3951 memset(bssid, 0, sizeof(bssid));
3951 3952
@@ -3976,8 +3977,8 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
3976 3977
3977 return out - buf; 3978 return out - buf;
3978} 3979}
3979static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
3980 3980
3981static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
3981 3982
3982#ifdef CONFIG_IPW_DEBUG 3983#ifdef CONFIG_IPW_DEBUG
3983static ssize_t show_debug_level(struct device_driver *d, char *buf) 3984static ssize_t show_debug_level(struct device_driver *d, char *buf)
@@ -3985,8 +3986,8 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf)
3985 return sprintf(buf, "0x%08X\n", ipw2100_debug_level); 3986 return sprintf(buf, "0x%08X\n", ipw2100_debug_level);
3986} 3987}
3987 3988
3988static ssize_t store_debug_level(struct device_driver *d, const char *buf, 3989static ssize_t store_debug_level(struct device_driver *d,
3989 size_t count) 3990 const char *buf, size_t count)
3990{ 3991{
3991 char *p = (char *)buf; 3992 char *p = (char *)buf;
3992 u32 val; 3993 u32 val;
@@ -3999,28 +4000,26 @@ static ssize_t store_debug_level(struct device_driver *d, const char *buf,
3999 } else 4000 } else
4000 val = simple_strtoul(p, &p, 10); 4001 val = simple_strtoul(p, &p, 10);
4001 if (p == buf) 4002 if (p == buf)
4002 IPW_DEBUG_INFO(DRV_NAME 4003 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 4004 else
4005 ipw2100_debug_level = val; 4005 ipw2100_debug_level = val;
4006 4006
4007 return strnlen(buf, count); 4007 return strnlen(buf, count);
4008} 4008}
4009
4009static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, 4010static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level,
4010 store_debug_level); 4011 store_debug_level);
4011#endif /* CONFIG_IPW_DEBUG */ 4012#endif /* CONFIG_IPW_DEBUG */
4012
4013 4013
4014static ssize_t show_fatal_error(struct device *d, 4014static ssize_t show_fatal_error(struct device *d,
4015 struct device_attribute *attr, char *buf) 4015 struct device_attribute *attr, char *buf)
4016{ 4016{
4017 struct ipw2100_priv *priv = dev_get_drvdata(d); 4017 struct ipw2100_priv *priv = dev_get_drvdata(d);
4018 char *out = buf; 4018 char *out = buf;
4019 int i; 4019 int i;
4020 4020
4021 if (priv->fatal_error) 4021 if (priv->fatal_error)
4022 out += sprintf(out, "0x%08X\n", 4022 out += sprintf(out, "0x%08X\n", priv->fatal_error);
4023 priv->fatal_error);
4024 else 4023 else
4025 out += sprintf(out, "0\n"); 4024 out += sprintf(out, "0\n");
4026 4025
@@ -4038,24 +4037,26 @@ static ssize_t show_fatal_error(struct device *d,
4038} 4037}
4039 4038
4040static ssize_t store_fatal_error(struct device *d, 4039static ssize_t store_fatal_error(struct device *d,
4041 struct device_attribute *attr, const char *buf, size_t count) 4040 struct device_attribute *attr, const char *buf,
4041 size_t count)
4042{ 4042{
4043 struct ipw2100_priv *priv = dev_get_drvdata(d); 4043 struct ipw2100_priv *priv = dev_get_drvdata(d);
4044 schedule_reset(priv); 4044 schedule_reset(priv);
4045 return count; 4045 return count;
4046} 4046}
4047static DEVICE_ATTR(fatal_error, S_IWUSR|S_IRUGO, show_fatal_error, store_fatal_error);
4048 4047
4048static DEVICE_ATTR(fatal_error, S_IWUSR | S_IRUGO, show_fatal_error,
4049 store_fatal_error);
4049 4050
4050static ssize_t show_scan_age(struct device *d, struct device_attribute *attr, 4051static ssize_t show_scan_age(struct device *d, struct device_attribute *attr,
4051 char *buf) 4052 char *buf)
4052{ 4053{
4053 struct ipw2100_priv *priv = dev_get_drvdata(d); 4054 struct ipw2100_priv *priv = dev_get_drvdata(d);
4054 return sprintf(buf, "%d\n", priv->ieee->scan_age); 4055 return sprintf(buf, "%d\n", priv->ieee->scan_age);
4055} 4056}
4056 4057
4057static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, 4058static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4058 const char *buf, size_t count) 4059 const char *buf, size_t count)
4059{ 4060{
4060 struct ipw2100_priv *priv = dev_get_drvdata(d); 4061 struct ipw2100_priv *priv = dev_get_drvdata(d);
4061 struct net_device *dev = priv->net_dev; 4062 struct net_device *dev = priv->net_dev;
@@ -4078,8 +4079,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4078 } else 4079 } else
4079 val = simple_strtoul(p, &p, 10); 4080 val = simple_strtoul(p, &p, 10);
4080 if (p == buffer) { 4081 if (p == buffer) {
4081 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", 4082 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name);
4082 dev->name);
4083 } else { 4083 } else {
4084 priv->ieee->scan_age = val; 4084 priv->ieee->scan_age = val;
4085 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); 4085 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age);
@@ -4088,11 +4088,11 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4088 IPW_DEBUG_INFO("exit\n"); 4088 IPW_DEBUG_INFO("exit\n");
4089 return len; 4089 return len;
4090} 4090}
4091static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
4092 4091
4092static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
4093 4093
4094static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 4094static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
4095 char *buf) 4095 char *buf)
4096{ 4096{
4097 /* 0 - RF kill not enabled 4097 /* 0 - RF kill not enabled
4098 1 - SW based RF kill active (sysfs) 4098 1 - SW based RF kill active (sysfs)
@@ -4100,7 +4100,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr,
4100 3 - Both HW and SW baed RF kill active */ 4100 3 - Both HW and SW baed RF kill active */
4101 struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data; 4101 struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data;
4102 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | 4102 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) |
4103 (rf_kill_active(priv) ? 0x2 : 0x0); 4103 (rf_kill_active(priv) ? 0x2 : 0x0);
4104 return sprintf(buf, "%i\n", val); 4104 return sprintf(buf, "%i\n", val);
4105} 4105}
4106 4106
@@ -4108,7 +4108,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4108{ 4108{
4109 if ((disable_radio ? 1 : 0) == 4109 if ((disable_radio ? 1 : 0) ==
4110 (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) 4110 (priv->status & STATUS_RF_KILL_SW ? 1 : 0))
4111 return 0 ; 4111 return 0;
4112 4112
4113 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", 4113 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n",
4114 disable_radio ? "OFF" : "ON"); 4114 disable_radio ? "OFF" : "ON");
@@ -4126,8 +4126,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4126 /* Make sure the RF_KILL check timer is running */ 4126 /* Make sure the RF_KILL check timer is running */
4127 priv->stop_rf_kill = 0; 4127 priv->stop_rf_kill = 0;
4128 cancel_delayed_work(&priv->rf_kill); 4128 cancel_delayed_work(&priv->rf_kill);
4129 queue_delayed_work(priv->workqueue, &priv->rf_kill, 4129 queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ);
4130 HZ);
4131 } else 4130 } else
4132 schedule_reset(priv); 4131 schedule_reset(priv);
4133 } 4132 }
@@ -4137,14 +4136,14 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
4137} 4136}
4138 4137
4139static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, 4138static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr,
4140 const char *buf, size_t count) 4139 const char *buf, size_t count)
4141{ 4140{
4142 struct ipw2100_priv *priv = dev_get_drvdata(d); 4141 struct ipw2100_priv *priv = dev_get_drvdata(d);
4143 ipw_radio_kill_sw(priv, buf[0] == '1'); 4142 ipw_radio_kill_sw(priv, buf[0] == '1');
4144 return count; 4143 return count;
4145} 4144}
4146static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill);
4147 4145
4146static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill);
4148 4147
4149static struct attribute *ipw2100_sysfs_entries[] = { 4148static struct attribute *ipw2100_sysfs_entries[] = {
4150 &dev_attr_hardware.attr, 4149 &dev_attr_hardware.attr,
@@ -4168,7 +4167,6 @@ static struct attribute_group ipw2100_attribute_group = {
4168 .attrs = ipw2100_sysfs_entries, 4167 .attrs = ipw2100_sysfs_entries,
4169}; 4168};
4170 4169
4171
4172static int status_queue_allocate(struct ipw2100_priv *priv, int entries) 4170static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
4173{ 4171{
4174 struct ipw2100_status_queue *q = &priv->status_queue; 4172 struct ipw2100_status_queue *q = &priv->status_queue;
@@ -4176,11 +4174,11 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
4176 IPW_DEBUG_INFO("enter\n"); 4174 IPW_DEBUG_INFO("enter\n");
4177 4175
4178 q->size = entries * sizeof(struct ipw2100_status); 4176 q->size = entries * sizeof(struct ipw2100_status);
4179 q->drv = (struct ipw2100_status *)pci_alloc_consistent( 4177 q->drv =
4180 priv->pci_dev, q->size, &q->nic); 4178 (struct ipw2100_status *)pci_alloc_consistent(priv->pci_dev,
4179 q->size, &q->nic);
4181 if (!q->drv) { 4180 if (!q->drv) {
4182 IPW_DEBUG_WARNING( 4181 IPW_DEBUG_WARNING("Can not allocate status queue.\n");
4183 "Can not allocate status queue.\n");
4184 return -ENOMEM; 4182 return -ENOMEM;
4185 } 4183 }
4186 4184
@@ -4196,9 +4194,9 @@ static void status_queue_free(struct ipw2100_priv *priv)
4196 IPW_DEBUG_INFO("enter\n"); 4194 IPW_DEBUG_INFO("enter\n");
4197 4195
4198 if (priv->status_queue.drv) { 4196 if (priv->status_queue.drv) {
4199 pci_free_consistent( 4197 pci_free_consistent(priv->pci_dev, priv->status_queue.size,
4200 priv->pci_dev, priv->status_queue.size, 4198 priv->status_queue.drv,
4201 priv->status_queue.drv, priv->status_queue.nic); 4199 priv->status_queue.nic);
4202 priv->status_queue.drv = NULL; 4200 priv->status_queue.drv = NULL;
4203 } 4201 }
4204 4202
@@ -4216,7 +4214,8 @@ static int bd_queue_allocate(struct ipw2100_priv *priv,
4216 q->size = entries * sizeof(struct ipw2100_bd); 4214 q->size = entries * sizeof(struct ipw2100_bd);
4217 q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic); 4215 q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic);
4218 if (!q->drv) { 4216 if (!q->drv) {
4219 IPW_DEBUG_INFO("can't allocate shared memory for buffer descriptors\n"); 4217 IPW_DEBUG_INFO
4218 ("can't allocate shared memory for buffer descriptors\n");
4220 return -ENOMEM; 4219 return -ENOMEM;
4221 } 4220 }
4222 memset(q->drv, 0, q->size); 4221 memset(q->drv, 0, q->size);
@@ -4226,8 +4225,7 @@ static int bd_queue_allocate(struct ipw2100_priv *priv,
4226 return 0; 4225 return 0;
4227} 4226}
4228 4227
4229static void bd_queue_free(struct ipw2100_priv *priv, 4228static void bd_queue_free(struct ipw2100_priv *priv, struct ipw2100_bd_queue *q)
4230 struct ipw2100_bd_queue *q)
4231{ 4229{
4232 IPW_DEBUG_INFO("enter\n"); 4230 IPW_DEBUG_INFO("enter\n");
4233 4231
@@ -4235,21 +4233,21 @@ static void bd_queue_free(struct ipw2100_priv *priv,
4235 return; 4233 return;
4236 4234
4237 if (q->drv) { 4235 if (q->drv) {
4238 pci_free_consistent(priv->pci_dev, 4236 pci_free_consistent(priv->pci_dev, q->size, q->drv, q->nic);
4239 q->size, q->drv, q->nic);
4240 q->drv = NULL; 4237 q->drv = NULL;
4241 } 4238 }
4242 4239
4243 IPW_DEBUG_INFO("exit\n"); 4240 IPW_DEBUG_INFO("exit\n");
4244} 4241}
4245 4242
4246static void bd_queue_initialize( 4243static void bd_queue_initialize(struct ipw2100_priv *priv,
4247 struct ipw2100_priv *priv, struct ipw2100_bd_queue * q, 4244 struct ipw2100_bd_queue *q, u32 base, u32 size,
4248 u32 base, u32 size, u32 r, u32 w) 4245 u32 r, u32 w)
4249{ 4246{
4250 IPW_DEBUG_INFO("enter\n"); 4247 IPW_DEBUG_INFO("enter\n");
4251 4248
4252 IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, (u32)q->nic); 4249 IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv,
4250 (u32) q->nic);
4253 4251
4254 write_register(priv->net_dev, base, q->nic); 4252 write_register(priv->net_dev, base, q->nic);
4255 write_register(priv->net_dev, size, q->entries); 4253 write_register(priv->net_dev, size, q->entries);
@@ -4285,32 +4283,38 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
4285 err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH); 4283 err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH);
4286 if (err) { 4284 if (err) {
4287 IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n", 4285 IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n",
4288 priv->net_dev->name); 4286 priv->net_dev->name);
4289 return err; 4287 return err;
4290 } 4288 }
4291 4289
4292 priv->tx_buffers = (struct ipw2100_tx_packet *)kmalloc( 4290 priv->tx_buffers =
4293 TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet), 4291 (struct ipw2100_tx_packet *)kmalloc(TX_PENDED_QUEUE_LENGTH *
4294 GFP_ATOMIC); 4292 sizeof(struct
4293 ipw2100_tx_packet),
4294 GFP_ATOMIC);
4295 if (!priv->tx_buffers) { 4295 if (!priv->tx_buffers) {
4296 printk(KERN_ERR DRV_NAME ": %s: alloc failed form tx buffers.\n", 4296 printk(KERN_ERR DRV_NAME
4297 ": %s: alloc failed form tx buffers.\n",
4297 priv->net_dev->name); 4298 priv->net_dev->name);
4298 bd_queue_free(priv, &priv->tx_queue); 4299 bd_queue_free(priv, &priv->tx_queue);
4299 return -ENOMEM; 4300 return -ENOMEM;
4300 } 4301 }
4301 4302
4302 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { 4303 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4303 v = pci_alloc_consistent( 4304 v = pci_alloc_consistent(priv->pci_dev,
4304 priv->pci_dev, sizeof(struct ipw2100_data_header), &p); 4305 sizeof(struct ipw2100_data_header),
4306 &p);
4305 if (!v) { 4307 if (!v) {
4306 printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for tx " 4308 printk(KERN_ERR DRV_NAME
4307 "buffers.\n", priv->net_dev->name); 4309 ": %s: PCI alloc failed for tx " "buffers.\n",
4310 priv->net_dev->name);
4308 err = -ENOMEM; 4311 err = -ENOMEM;
4309 break; 4312 break;
4310 } 4313 }
4311 4314
4312 priv->tx_buffers[i].type = DATA; 4315 priv->tx_buffers[i].type = DATA;
4313 priv->tx_buffers[i].info.d_struct.data = (struct ipw2100_data_header*)v; 4316 priv->tx_buffers[i].info.d_struct.data =
4317 (struct ipw2100_data_header *)v;
4314 priv->tx_buffers[i].info.d_struct.data_phys = p; 4318 priv->tx_buffers[i].info.d_struct.data_phys = p;
4315 priv->tx_buffers[i].info.d_struct.txb = NULL; 4319 priv->tx_buffers[i].info.d_struct.txb = NULL;
4316 } 4320 }
@@ -4319,11 +4323,11 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
4319 return 0; 4323 return 0;
4320 4324
4321 for (j = 0; j < i; j++) { 4325 for (j = 0; j < i; j++) {
4322 pci_free_consistent( 4326 pci_free_consistent(priv->pci_dev,
4323 priv->pci_dev, 4327 sizeof(struct ipw2100_data_header),
4324 sizeof(struct ipw2100_data_header), 4328 priv->tx_buffers[j].info.d_struct.data,
4325 priv->tx_buffers[j].info.d_struct.data, 4329 priv->tx_buffers[j].info.d_struct.
4326 priv->tx_buffers[j].info.d_struct.data_phys); 4330 data_phys);
4327 } 4331 }
4328 4332
4329 kfree(priv->tx_buffers); 4333 kfree(priv->tx_buffers);
@@ -4356,7 +4360,8 @@ static void ipw2100_tx_initialize(struct ipw2100_priv *priv)
4356 /* We simply drop any SKBs that have been queued for 4360 /* We simply drop any SKBs that have been queued for
4357 * transmit */ 4361 * transmit */
4358 if (priv->tx_buffers[i].info.d_struct.txb) { 4362 if (priv->tx_buffers[i].info.d_struct.txb) {
4359 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); 4363 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.
4364 txb);
4360 priv->tx_buffers[i].info.d_struct.txb = NULL; 4365 priv->tx_buffers[i].info.d_struct.txb = NULL;
4361 } 4366 }
4362 4367
@@ -4394,15 +4399,17 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv)
4394 4399
4395 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { 4400 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4396 if (priv->tx_buffers[i].info.d_struct.txb) { 4401 if (priv->tx_buffers[i].info.d_struct.txb) {
4397 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); 4402 ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.
4403 txb);
4398 priv->tx_buffers[i].info.d_struct.txb = NULL; 4404 priv->tx_buffers[i].info.d_struct.txb = NULL;
4399 } 4405 }
4400 if (priv->tx_buffers[i].info.d_struct.data) 4406 if (priv->tx_buffers[i].info.d_struct.data)
4401 pci_free_consistent( 4407 pci_free_consistent(priv->pci_dev,
4402 priv->pci_dev, 4408 sizeof(struct ipw2100_data_header),
4403 sizeof(struct ipw2100_data_header), 4409 priv->tx_buffers[i].info.d_struct.
4404 priv->tx_buffers[i].info.d_struct.data, 4410 data,
4405 priv->tx_buffers[i].info.d_struct.data_phys); 4411 priv->tx_buffers[i].info.d_struct.
4412 data_phys);
4406 } 4413 }
4407 4414
4408 kfree(priv->tx_buffers); 4415 kfree(priv->tx_buffers);
@@ -4411,8 +4418,6 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv)
4411 IPW_DEBUG_INFO("exit\n"); 4418 IPW_DEBUG_INFO("exit\n");
4412} 4419}
4413 4420
4414
4415
4416static int ipw2100_rx_allocate(struct ipw2100_priv *priv) 4421static int ipw2100_rx_allocate(struct ipw2100_priv *priv)
4417{ 4422{
4418 int i, j, err = -EINVAL; 4423 int i, j, err = -EINVAL;
@@ -4542,14 +4547,13 @@ static int ipw2100_read_mac_address(struct ipw2100_priv *priv)
4542 4547
4543 int err; 4548 int err;
4544 4549
4545 err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, 4550 err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, mac, &length);
4546 mac, &length);
4547 if (err) { 4551 if (err) {
4548 IPW_DEBUG_INFO("MAC address read failed\n"); 4552 IPW_DEBUG_INFO("MAC address read failed\n");
4549 return -EIO; 4553 return -EIO;
4550 } 4554 }
4551 IPW_DEBUG_INFO("card MAC is %02X:%02X:%02X:%02X:%02X:%02X\n", 4555 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]); 4556 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
4553 4557
4554 memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN); 4558 memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN);
4555 4559
@@ -4576,8 +4580,7 @@ static int ipw2100_set_mac_address(struct ipw2100_priv *priv, int batch_mode)
4576 IPW_DEBUG_INFO("enter\n"); 4580 IPW_DEBUG_INFO("enter\n");
4577 4581
4578 if (priv->config & CFG_CUSTOM_MAC) { 4582 if (priv->config & CFG_CUSTOM_MAC) {
4579 memcpy(cmd.host_command_parameters, priv->mac_addr, 4583 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); 4584 memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN);
4582 } else 4585 } else
4583 memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr, 4586 memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr,
@@ -4614,7 +4617,8 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type,
4614 if (!batch_mode) { 4617 if (!batch_mode) {
4615 err = ipw2100_disable_adapter(priv); 4618 err = ipw2100_disable_adapter(priv);
4616 if (err) { 4619 if (err) {
4617 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 4620 printk(KERN_ERR DRV_NAME
4621 ": %s: Could not disable adapter %d\n",
4618 priv->net_dev->name, err); 4622 priv->net_dev->name, err);
4619 return err; 4623 return err;
4620 } 4624 }
@@ -4629,7 +4633,6 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type,
4629 return err; 4633 return err;
4630} 4634}
4631 4635
4632
4633static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel, 4636static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel,
4634 int batch_mode) 4637 int batch_mode)
4635{ 4638{
@@ -4660,8 +4663,7 @@ static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel,
4660 4663
4661 err = ipw2100_hw_send_command(priv, &cmd); 4664 err = ipw2100_hw_send_command(priv, &cmd);
4662 if (err) { 4665 if (err) {
4663 IPW_DEBUG_INFO("Failed to set channel to %d", 4666 IPW_DEBUG_INFO("Failed to set channel to %d", channel);
4664 channel);
4665 return err; 4667 return err;
4666 } 4668 }
4667 4669
@@ -4703,15 +4705,14 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)
4703 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START; 4705 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START;
4704 4706
4705 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK | 4707 cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK |
4706 IPW_CFG_BSS_MASK | 4708 IPW_CFG_BSS_MASK | IPW_CFG_802_1x_ENABLE;
4707 IPW_CFG_802_1x_ENABLE;
4708 4709
4709 if (!(priv->config & CFG_LONG_PREAMBLE)) 4710 if (!(priv->config & CFG_LONG_PREAMBLE))
4710 cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO; 4711 cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO;
4711 4712
4712 err = ipw2100_get_ordinal(priv, 4713 err = ipw2100_get_ordinal(priv,
4713 IPW_ORD_EEPROM_IBSS_11B_CHANNELS, 4714 IPW_ORD_EEPROM_IBSS_11B_CHANNELS,
4714 &ibss_mask, &len); 4715 &ibss_mask, &len);
4715 if (err) 4716 if (err)
4716 ibss_mask = IPW_IBSS_11B_DEFAULT_MASK; 4717 ibss_mask = IPW_IBSS_11B_DEFAULT_MASK;
4717 4718
@@ -4719,7 +4720,7 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode)
4719 cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask; 4720 cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask;
4720 4721
4721 /* 11b only */ 4722 /* 11b only */
4722 /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A;*/ 4723 /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A; */
4723 4724
4724 err = ipw2100_hw_send_command(priv, &cmd); 4725 err = ipw2100_hw_send_command(priv, &cmd);
4725 if (err) 4726 if (err)
@@ -4783,8 +4784,7 @@ static int ipw2100_set_tx_rates(struct ipw2100_priv *priv, u32 rate,
4783 return 0; 4784 return 0;
4784} 4785}
4785 4786
4786static int ipw2100_set_power_mode(struct ipw2100_priv *priv, 4787static int ipw2100_set_power_mode(struct ipw2100_priv *priv, int power_level)
4787 int power_level)
4788{ 4788{
4789 struct host_command cmd = { 4789 struct host_command cmd = {
4790 .host_command = POWER_MODE, 4790 .host_command = POWER_MODE,
@@ -4805,11 +4805,10 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv,
4805 priv->power_mode = IPW_POWER_ENABLED | power_level; 4805 priv->power_mode = IPW_POWER_ENABLED | power_level;
4806 4806
4807#ifdef CONFIG_IPW2100_TX_POWER 4807#ifdef CONFIG_IPW2100_TX_POWER
4808 if (priv->port_type == IBSS && 4808 if (priv->port_type == IBSS && priv->adhoc_power != DFTL_IBSS_TX_POWER) {
4809 priv->adhoc_power != DFTL_IBSS_TX_POWER) {
4810 /* Set beacon interval */ 4809 /* Set beacon interval */
4811 cmd.host_command = TX_POWER_INDEX; 4810 cmd.host_command = TX_POWER_INDEX;
4812 cmd.host_command_parameters[0] = (u32)priv->adhoc_power; 4811 cmd.host_command_parameters[0] = (u32) priv->adhoc_power;
4813 4812
4814 err = ipw2100_hw_send_command(priv, &cmd); 4813 err = ipw2100_hw_send_command(priv, &cmd);
4815 if (err) 4814 if (err)
@@ -4820,7 +4819,6 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv,
4820 return 0; 4819 return 0;
4821} 4820}
4822 4821
4823
4824static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold) 4822static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold)
4825{ 4823{
4826 struct host_command cmd = { 4824 struct host_command cmd = {
@@ -4925,8 +4923,7 @@ static int ipw2100_set_long_retry(struct ipw2100_priv *priv, u32 retry)
4925 return 0; 4923 return 0;
4926} 4924}
4927 4925
4928 4926static 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) 4927 int batch_mode)
4931{ 4928{
4932 struct host_command cmd = { 4929 struct host_command cmd = {
@@ -4938,16 +4935,15 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
4938 4935
4939#ifdef CONFIG_IPW_DEBUG 4936#ifdef CONFIG_IPW_DEBUG
4940 if (bssid != NULL) 4937 if (bssid != NULL)
4941 IPW_DEBUG_HC( 4938 IPW_DEBUG_HC("MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n",
4942 "MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", 4939 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4],
4943 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], 4940 bssid[5]);
4944 bssid[5]);
4945 else 4941 else
4946 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n"); 4942 IPW_DEBUG_HC("MANDATORY_BSSID: <clear>\n");
4947#endif 4943#endif
4948 /* if BSSID is empty then we disable mandatory bssid mode */ 4944 /* if BSSID is empty then we disable mandatory bssid mode */
4949 if (bssid != NULL) 4945 if (bssid != NULL)
4950 memcpy((u8 *)cmd.host_command_parameters, bssid, ETH_ALEN); 4946 memcpy(cmd.host_command_parameters, bssid, ETH_ALEN);
4951 4947
4952 if (!batch_mode) { 4948 if (!batch_mode) {
4953 err = ipw2100_disable_adapter(priv); 4949 err = ipw2100_disable_adapter(priv);
@@ -4963,7 +4959,6 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid,
4963 return err; 4959 return err;
4964} 4960}
4965 4961
4966#ifdef CONFIG_IEEE80211_WPA
4967static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv) 4962static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv)
4968{ 4963{
4969 struct host_command cmd = { 4964 struct host_command cmd = {
@@ -4987,42 +4982,10 @@ static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv)
4987 4982
4988 return err; 4983 return err;
4989} 4984}
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 4985
5023static int ipw2100_set_wpa_ie(struct ipw2100_priv *, 4986static int ipw2100_set_wpa_ie(struct ipw2100_priv *,
5024 struct ipw2100_wpa_assoc_frame *, int) 4987 struct ipw2100_wpa_assoc_frame *, int)
5025__attribute__ ((unused)); 4988 __attribute__ ((unused));
5026 4989
5027static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv, 4990static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv,
5028 struct ipw2100_wpa_assoc_frame *wpa_frame, 4991 struct ipw2100_wpa_assoc_frame *wpa_frame,
@@ -5076,7 +5039,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5076 .host_command_length = sizeof(struct security_info_params) 5039 .host_command_length = sizeof(struct security_info_params)
5077 }; 5040 };
5078 struct security_info_params *security = 5041 struct security_info_params *security =
5079 (struct security_info_params *)&cmd.host_command_parameters; 5042 (struct security_info_params *)&cmd.host_command_parameters;
5080 int err; 5043 int err;
5081 memset(security, 0, sizeof(*security)); 5044 memset(security, 0, sizeof(*security));
5082 5045
@@ -5094,25 +5057,25 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5094 break; 5057 break;
5095 case SEC_LEVEL_1: 5058 case SEC_LEVEL_1:
5096 security->allowed_ciphers = IPW_WEP40_CIPHER | 5059 security->allowed_ciphers = IPW_WEP40_CIPHER |
5097 IPW_WEP104_CIPHER; 5060 IPW_WEP104_CIPHER;
5098 break; 5061 break;
5099 case SEC_LEVEL_2: 5062 case SEC_LEVEL_2:
5100 security->allowed_ciphers = IPW_WEP40_CIPHER | 5063 security->allowed_ciphers = IPW_WEP40_CIPHER |
5101 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER; 5064 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER;
5102 break; 5065 break;
5103 case SEC_LEVEL_2_CKIP: 5066 case SEC_LEVEL_2_CKIP:
5104 security->allowed_ciphers = IPW_WEP40_CIPHER | 5067 security->allowed_ciphers = IPW_WEP40_CIPHER |
5105 IPW_WEP104_CIPHER | IPW_CKIP_CIPHER; 5068 IPW_WEP104_CIPHER | IPW_CKIP_CIPHER;
5106 break; 5069 break;
5107 case SEC_LEVEL_3: 5070 case SEC_LEVEL_3:
5108 security->allowed_ciphers = IPW_WEP40_CIPHER | 5071 security->allowed_ciphers = IPW_WEP40_CIPHER |
5109 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER; 5072 IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER;
5110 break; 5073 break;
5111 } 5074 }
5112 5075
5113 IPW_DEBUG_HC( 5076 IPW_DEBUG_HC
5114 "SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n", 5077 ("SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n",
5115 security->auth_mode, security->allowed_ciphers, security_level); 5078 security->auth_mode, security->allowed_ciphers, security_level);
5116 5079
5117 security->replay_counters_number = 0; 5080 security->replay_counters_number = 0;
5118 5081
@@ -5130,8 +5093,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv,
5130 return err; 5093 return err;
5131} 5094}
5132 5095
5133static int ipw2100_set_tx_power(struct ipw2100_priv *priv, 5096static int ipw2100_set_tx_power(struct ipw2100_priv *priv, u32 tx_power)
5134 u32 tx_power)
5135{ 5097{
5136 struct host_command cmd = { 5098 struct host_command cmd = {
5137 .host_command = TX_POWER_INDEX, 5099 .host_command = TX_POWER_INDEX,
@@ -5140,6 +5102,10 @@ static int ipw2100_set_tx_power(struct ipw2100_priv *priv,
5140 }; 5102 };
5141 int err = 0; 5103 int err = 0;
5142 5104
5105 if (tx_power != IPW_TX_POWER_DEFAULT)
5106 tx_power = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 /
5107 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
5108
5143 cmd.host_command_parameters[0] = tx_power; 5109 cmd.host_command_parameters[0] = tx_power;
5144 5110
5145 if (priv->ieee->iw_mode == IW_MODE_ADHOC) 5111 if (priv->ieee->iw_mode == IW_MODE_ADHOC)
@@ -5185,7 +5151,6 @@ static int ipw2100_set_ibss_beacon_interval(struct ipw2100_priv *priv,
5185 return 0; 5151 return 0;
5186} 5152}
5187 5153
5188
5189void ipw2100_queues_initialize(struct ipw2100_priv *priv) 5154void ipw2100_queues_initialize(struct ipw2100_priv *priv)
5190{ 5155{
5191 ipw2100_tx_initialize(priv); 5156 ipw2100_tx_initialize(priv);
@@ -5203,13 +5168,12 @@ void ipw2100_queues_free(struct ipw2100_priv *priv)
5203int ipw2100_queues_allocate(struct ipw2100_priv *priv) 5168int ipw2100_queues_allocate(struct ipw2100_priv *priv)
5204{ 5169{
5205 if (ipw2100_tx_allocate(priv) || 5170 if (ipw2100_tx_allocate(priv) ||
5206 ipw2100_rx_allocate(priv) || 5171 ipw2100_rx_allocate(priv) || ipw2100_msg_allocate(priv))
5207 ipw2100_msg_allocate(priv))
5208 goto fail; 5172 goto fail;
5209 5173
5210 return 0; 5174 return 0;
5211 5175
5212 fail: 5176 fail:
5213 ipw2100_tx_free(priv); 5177 ipw2100_tx_free(priv);
5214 ipw2100_rx_free(priv); 5178 ipw2100_rx_free(priv);
5215 ipw2100_msg_free(priv); 5179 ipw2100_msg_free(priv);
@@ -5235,7 +5199,8 @@ static int ipw2100_set_wep_flags(struct ipw2100_priv *priv, u32 flags,
5235 if (!batch_mode) { 5199 if (!batch_mode) {
5236 err = ipw2100_disable_adapter(priv); 5200 err = ipw2100_disable_adapter(priv);
5237 if (err) { 5201 if (err) {
5238 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5202 printk(KERN_ERR DRV_NAME
5203 ": %s: Could not disable adapter %d\n",
5239 priv->net_dev->name, err); 5204 priv->net_dev->name, err);
5240 return err; 5205 return err;
5241 } 5206 }
@@ -5262,7 +5227,6 @@ struct ipw2100_wep_key {
5262#define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4] 5227#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] 5228#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 5229
5265
5266/** 5230/**
5267 * Set a the wep key 5231 * Set a the wep key
5268 * 5232 *
@@ -5287,11 +5251,11 @@ static int ipw2100_set_key(struct ipw2100_priv *priv,
5287 .host_command_sequence = 0, 5251 .host_command_sequence = 0,
5288 .host_command_length = sizeof(struct ipw2100_wep_key), 5252 .host_command_length = sizeof(struct ipw2100_wep_key),
5289 }; 5253 };
5290 struct ipw2100_wep_key *wep_key = (void*)cmd.host_command_parameters; 5254 struct ipw2100_wep_key *wep_key = (void *)cmd.host_command_parameters;
5291 int err; 5255 int err;
5292 5256
5293 IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n", 5257 IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n",
5294 idx, keylen, len); 5258 idx, keylen, len);
5295 5259
5296 /* NOTE: We don't check cached values in case the firmware was reset 5260 /* 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, 5261 * or some other problem is occuring. If the user is setting the key,
@@ -5308,22 +5272,23 @@ static int ipw2100_set_key(struct ipw2100_priv *priv,
5308 /* Will be optimized out on debug not being configured in */ 5272 /* Will be optimized out on debug not being configured in */
5309 if (keylen == 0) 5273 if (keylen == 0)
5310 IPW_DEBUG_WEP("%s: Clearing key %d\n", 5274 IPW_DEBUG_WEP("%s: Clearing key %d\n",
5311 priv->net_dev->name, wep_key->idx); 5275 priv->net_dev->name, wep_key->idx);
5312 else if (keylen == 5) 5276 else if (keylen == 5)
5313 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n", 5277 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n",
5314 priv->net_dev->name, wep_key->idx, wep_key->len, 5278 priv->net_dev->name, wep_key->idx, wep_key->len,
5315 WEP_STR_64(wep_key->key)); 5279 WEP_STR_64(wep_key->key));
5316 else 5280 else
5317 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128 5281 IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128
5318 "\n", 5282 "\n",
5319 priv->net_dev->name, wep_key->idx, wep_key->len, 5283 priv->net_dev->name, wep_key->idx, wep_key->len,
5320 WEP_STR_128(wep_key->key)); 5284 WEP_STR_128(wep_key->key));
5321 5285
5322 if (!batch_mode) { 5286 if (!batch_mode) {
5323 err = ipw2100_disable_adapter(priv); 5287 err = ipw2100_disable_adapter(priv);
5324 /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */ 5288 /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */
5325 if (err) { 5289 if (err) {
5326 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5290 printk(KERN_ERR DRV_NAME
5291 ": %s: Could not disable adapter %d\n",
5327 priv->net_dev->name, err); 5292 priv->net_dev->name, err);
5328 return err; 5293 return err;
5329 } 5294 }
@@ -5347,7 +5312,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5347 .host_command = WEP_KEY_INDEX, 5312 .host_command = WEP_KEY_INDEX,
5348 .host_command_sequence = 0, 5313 .host_command_sequence = 0,
5349 .host_command_length = 4, 5314 .host_command_length = 4,
5350 .host_command_parameters = { idx }, 5315 .host_command_parameters = {idx},
5351 }; 5316 };
5352 int err; 5317 int err;
5353 5318
@@ -5359,7 +5324,8 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5359 if (!batch_mode) { 5324 if (!batch_mode) {
5360 err = ipw2100_disable_adapter(priv); 5325 err = ipw2100_disable_adapter(priv);
5361 if (err) { 5326 if (err) {
5362 printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", 5327 printk(KERN_ERR DRV_NAME
5328 ": %s: Could not disable adapter %d\n",
5363 priv->net_dev->name, err); 5329 priv->net_dev->name, err);
5364 return err; 5330 return err;
5365 } 5331 }
@@ -5374,9 +5340,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv,
5374 return err; 5340 return err;
5375} 5341}
5376 5342
5377 5343static 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{ 5344{
5381 int i, err, auth_mode, sec_level, use_group; 5345 int i, err, auth_mode, sec_level, use_group;
5382 5346
@@ -5389,40 +5353,42 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv,
5389 return err; 5353 return err;
5390 } 5354 }
5391 5355
5392 if (!priv->sec.enabled) { 5356 if (!priv->ieee->sec.enabled) {
5393 err = ipw2100_set_security_information( 5357 err =
5394 priv, IPW_AUTH_OPEN, SEC_LEVEL_0, 0, 1); 5358 ipw2100_set_security_information(priv, IPW_AUTH_OPEN,
5359 SEC_LEVEL_0, 0, 1);
5395 } else { 5360 } else {
5396 auth_mode = IPW_AUTH_OPEN; 5361 auth_mode = IPW_AUTH_OPEN;
5397 if ((priv->sec.flags & SEC_AUTH_MODE) && 5362 if ((priv->ieee->sec.flags & SEC_AUTH_MODE) &&
5398 (priv->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) 5363 (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY))
5399 auth_mode = IPW_AUTH_SHARED; 5364 auth_mode = IPW_AUTH_SHARED;
5400 5365
5401 sec_level = SEC_LEVEL_0; 5366 sec_level = SEC_LEVEL_0;
5402 if (priv->sec.flags & SEC_LEVEL) 5367 if (priv->ieee->sec.flags & SEC_LEVEL)
5403 sec_level = priv->sec.level; 5368 sec_level = priv->ieee->sec.level;
5404 5369
5405 use_group = 0; 5370 use_group = 0;
5406 if (priv->sec.flags & SEC_UNICAST_GROUP) 5371 if (priv->ieee->sec.flags & SEC_UNICAST_GROUP)
5407 use_group = priv->sec.unicast_uses_group; 5372 use_group = priv->ieee->sec.unicast_uses_group;
5408 5373
5409 err = ipw2100_set_security_information( 5374 err =
5410 priv, auth_mode, sec_level, use_group, 1); 5375 ipw2100_set_security_information(priv, auth_mode, sec_level,
5376 use_group, 1);
5411 } 5377 }
5412 5378
5413 if (err) 5379 if (err)
5414 goto exit; 5380 goto exit;
5415 5381
5416 if (priv->sec.enabled) { 5382 if (priv->ieee->sec.enabled) {
5417 for (i = 0; i < 4; i++) { 5383 for (i = 0; i < 4; i++) {
5418 if (!(priv->sec.flags & (1 << i))) { 5384 if (!(priv->ieee->sec.flags & (1 << i))) {
5419 memset(priv->sec.keys[i], 0, WEP_KEY_LEN); 5385 memset(priv->ieee->sec.keys[i], 0, WEP_KEY_LEN);
5420 priv->sec.key_sizes[i] = 0; 5386 priv->ieee->sec.key_sizes[i] = 0;
5421 } else { 5387 } else {
5422 err = ipw2100_set_key(priv, i, 5388 err = ipw2100_set_key(priv, i,
5423 priv->sec.keys[i], 5389 priv->ieee->sec.keys[i],
5424 priv->sec.key_sizes[i], 5390 priv->ieee->sec.
5425 1); 5391 key_sizes[i], 1);
5426 if (err) 5392 if (err)
5427 goto exit; 5393 goto exit;
5428 } 5394 }
@@ -5433,14 +5399,16 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv,
5433 5399
5434 /* Always enable privacy so the Host can filter WEP packets if 5400 /* Always enable privacy so the Host can filter WEP packets if
5435 * encrypted data is sent up */ 5401 * encrypted data is sent up */
5436 err = ipw2100_set_wep_flags( 5402 err =
5437 priv, priv->sec.enabled ? IPW_PRIVACY_CAPABLE : 0, 1); 5403 ipw2100_set_wep_flags(priv,
5404 priv->ieee->sec.
5405 enabled ? IPW_PRIVACY_CAPABLE : 0, 1);
5438 if (err) 5406 if (err)
5439 goto exit; 5407 goto exit;
5440 5408
5441 priv->status &= ~STATUS_SECURITY_UPDATED; 5409 priv->status &= ~STATUS_SECURITY_UPDATED;
5442 5410
5443 exit: 5411 exit:
5444 if (!batch_mode) 5412 if (!batch_mode)
5445 ipw2100_enable_adapter(priv); 5413 ipw2100_enable_adapter(priv);
5446 5414
@@ -5469,60 +5437,64 @@ static void shim__set_security(struct net_device *dev,
5469 5437
5470 for (i = 0; i < 4; i++) { 5438 for (i = 0; i < 4; i++) {
5471 if (sec->flags & (1 << i)) { 5439 if (sec->flags & (1 << i)) {
5472 priv->sec.key_sizes[i] = sec->key_sizes[i]; 5440 priv->ieee->sec.key_sizes[i] = sec->key_sizes[i];
5473 if (sec->key_sizes[i] == 0) 5441 if (sec->key_sizes[i] == 0)
5474 priv->sec.flags &= ~(1 << i); 5442 priv->ieee->sec.flags &= ~(1 << i);
5475 else 5443 else
5476 memcpy(priv->sec.keys[i], sec->keys[i], 5444 memcpy(priv->ieee->sec.keys[i], sec->keys[i],
5477 sec->key_sizes[i]); 5445 sec->key_sizes[i]);
5478 priv->sec.flags |= (1 << i); 5446 if (sec->level == SEC_LEVEL_1) {
5479 priv->status |= STATUS_SECURITY_UPDATED; 5447 priv->ieee->sec.flags |= (1 << i);
5448 priv->status |= STATUS_SECURITY_UPDATED;
5449 } else
5450 priv->ieee->sec.flags &= ~(1 << i);
5480 } 5451 }
5481 } 5452 }
5482 5453
5483 if ((sec->flags & SEC_ACTIVE_KEY) && 5454 if ((sec->flags & SEC_ACTIVE_KEY) &&
5484 priv->sec.active_key != sec->active_key) { 5455 priv->ieee->sec.active_key != sec->active_key) {
5485 if (sec->active_key <= 3) { 5456 if (sec->active_key <= 3) {
5486 priv->sec.active_key = sec->active_key; 5457 priv->ieee->sec.active_key = sec->active_key;
5487 priv->sec.flags |= SEC_ACTIVE_KEY; 5458 priv->ieee->sec.flags |= SEC_ACTIVE_KEY;
5488 } else 5459 } else
5489 priv->sec.flags &= ~SEC_ACTIVE_KEY; 5460 priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY;
5490 5461
5491 priv->status |= STATUS_SECURITY_UPDATED; 5462 priv->status |= STATUS_SECURITY_UPDATED;
5492 } 5463 }
5493 5464
5494 if ((sec->flags & SEC_AUTH_MODE) && 5465 if ((sec->flags & SEC_AUTH_MODE) &&
5495 (priv->sec.auth_mode != sec->auth_mode)) { 5466 (priv->ieee->sec.auth_mode != sec->auth_mode)) {
5496 priv->sec.auth_mode = sec->auth_mode; 5467 priv->ieee->sec.auth_mode = sec->auth_mode;
5497 priv->sec.flags |= SEC_AUTH_MODE; 5468 priv->ieee->sec.flags |= SEC_AUTH_MODE;
5498 priv->status |= STATUS_SECURITY_UPDATED; 5469 priv->status |= STATUS_SECURITY_UPDATED;
5499 } 5470 }
5500 5471
5501 if (sec->flags & SEC_ENABLED && 5472 if (sec->flags & SEC_ENABLED && priv->ieee->sec.enabled != sec->enabled) {
5502 priv->sec.enabled != sec->enabled) { 5473 priv->ieee->sec.flags |= SEC_ENABLED;
5503 priv->sec.flags |= SEC_ENABLED; 5474 priv->ieee->sec.enabled = sec->enabled;
5504 priv->sec.enabled = sec->enabled;
5505 priv->status |= STATUS_SECURITY_UPDATED; 5475 priv->status |= STATUS_SECURITY_UPDATED;
5506 force_update = 1; 5476 force_update = 1;
5507 } 5477 }
5508 5478
5509 if (sec->flags & SEC_LEVEL && 5479 if (sec->flags & SEC_ENCRYPT)
5510 priv->sec.level != sec->level) { 5480 priv->ieee->sec.encrypt = sec->encrypt;
5511 priv->sec.level = sec->level; 5481
5512 priv->sec.flags |= SEC_LEVEL; 5482 if (sec->flags & SEC_LEVEL && priv->ieee->sec.level != sec->level) {
5483 priv->ieee->sec.level = sec->level;
5484 priv->ieee->sec.flags |= SEC_LEVEL;
5513 priv->status |= STATUS_SECURITY_UPDATED; 5485 priv->status |= STATUS_SECURITY_UPDATED;
5514 } 5486 }
5515 5487
5516 IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n", 5488 IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n",
5517 priv->sec.flags & (1<<8) ? '1' : '0', 5489 priv->ieee->sec.flags & (1 << 8) ? '1' : '0',
5518 priv->sec.flags & (1<<7) ? '1' : '0', 5490 priv->ieee->sec.flags & (1 << 7) ? '1' : '0',
5519 priv->sec.flags & (1<<6) ? '1' : '0', 5491 priv->ieee->sec.flags & (1 << 6) ? '1' : '0',
5520 priv->sec.flags & (1<<5) ? '1' : '0', 5492 priv->ieee->sec.flags & (1 << 5) ? '1' : '0',
5521 priv->sec.flags & (1<<4) ? '1' : '0', 5493 priv->ieee->sec.flags & (1 << 4) ? '1' : '0',
5522 priv->sec.flags & (1<<3) ? '1' : '0', 5494 priv->ieee->sec.flags & (1 << 3) ? '1' : '0',
5523 priv->sec.flags & (1<<2) ? '1' : '0', 5495 priv->ieee->sec.flags & (1 << 2) ? '1' : '0',
5524 priv->sec.flags & (1<<1) ? '1' : '0', 5496 priv->ieee->sec.flags & (1 << 1) ? '1' : '0',
5525 priv->sec.flags & (1<<0) ? '1' : '0'); 5497 priv->ieee->sec.flags & (1 << 0) ? '1' : '0');
5526 5498
5527/* As a temporary work around to enable WPA until we figure out why 5499/* As a temporary work around to enable WPA until we figure out why
5528 * wpa_supplicant toggles the security capability of the driver, which 5500 * wpa_supplicant toggles the security capability of the driver, which
@@ -5531,7 +5503,7 @@ static void shim__set_security(struct net_device *dev,
5531 * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/ 5503 * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/
5532 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) 5504 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)))
5533 ipw2100_configure_security(priv, 0); 5505 ipw2100_configure_security(priv, 0);
5534done: 5506 done:
5535 up(&priv->action_sem); 5507 up(&priv->action_sem);
5536} 5508}
5537 5509
@@ -5556,7 +5528,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5556 5528
5557 return 0; 5529 return 0;
5558 } 5530 }
5559#endif /* CONFIG_IPW2100_MONITOR */ 5531#endif /* CONFIG_IPW2100_MONITOR */
5560 5532
5561 err = ipw2100_read_mac_address(priv); 5533 err = ipw2100_read_mac_address(priv);
5562 if (err) 5534 if (err)
@@ -5576,7 +5548,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5576 return err; 5548 return err;
5577 } 5549 }
5578 5550
5579 err = ipw2100_system_config(priv, batch_mode); 5551 err = ipw2100_system_config(priv, batch_mode);
5580 if (err) 5552 if (err)
5581 return err; 5553 return err;
5582 5554
@@ -5614,8 +5586,10 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5614 return err; 5586 return err;
5615 5587
5616 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 5588 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
5617 err = ipw2100_set_ibss_beacon_interval( 5589 err =
5618 priv, priv->beacon_interval, batch_mode); 5590 ipw2100_set_ibss_beacon_interval(priv,
5591 priv->beacon_interval,
5592 batch_mode);
5619 if (err) 5593 if (err)
5620 return err; 5594 return err;
5621 5595
@@ -5625,18 +5599,17 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv)
5625 } 5599 }
5626 5600
5627 /* 5601 /*
5628 err = ipw2100_set_fragmentation_threshold( 5602 err = ipw2100_set_fragmentation_threshold(
5629 priv, priv->frag_threshold, batch_mode); 5603 priv, priv->frag_threshold, batch_mode);
5630 if (err) 5604 if (err)
5631 return err; 5605 return err;
5632 */ 5606 */
5633 5607
5634 IPW_DEBUG_INFO("exit\n"); 5608 IPW_DEBUG_INFO("exit\n");
5635 5609
5636 return 0; 5610 return 0;
5637} 5611}
5638 5612
5639
5640/************************************************************************* 5613/*************************************************************************
5641 * 5614 *
5642 * EXTERNALLY CALLED METHODS 5615 * EXTERNALLY CALLED METHODS
@@ -5669,7 +5642,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5669 ipw2100_reset_adapter(priv); 5642 ipw2100_reset_adapter(priv);
5670 return 0; 5643 return 0;
5671 5644
5672 done: 5645 done:
5673 up(&priv->action_sem); 5646 up(&priv->action_sem);
5674 return err; 5647 return err;
5675} 5648}
@@ -5708,7 +5681,7 @@ static int ipw2100_close(struct net_device *dev)
5708 /* Flush the TX queue ... */ 5681 /* Flush the TX queue ... */
5709 while (!list_empty(&priv->tx_pend_list)) { 5682 while (!list_empty(&priv->tx_pend_list)) {
5710 element = priv->tx_pend_list.next; 5683 element = priv->tx_pend_list.next;
5711 packet = list_entry(element, struct ipw2100_tx_packet, list); 5684 packet = list_entry(element, struct ipw2100_tx_packet, list);
5712 5685
5713 list_del(element); 5686 list_del(element);
5714 DEC_STAT(&priv->tx_pend_stat); 5687 DEC_STAT(&priv->tx_pend_stat);
@@ -5726,8 +5699,6 @@ static int ipw2100_close(struct net_device *dev)
5726 return 0; 5699 return 0;
5727} 5700}
5728 5701
5729
5730
5731/* 5702/*
5732 * TODO: Fix this function... its just wrong 5703 * TODO: Fix this function... its just wrong
5733 */ 5704 */
@@ -5747,7 +5718,6 @@ static void ipw2100_tx_timeout(struct net_device *dev)
5747 schedule_reset(priv); 5718 schedule_reset(priv);
5748} 5719}
5749 5720
5750
5751/* 5721/*
5752 * TODO: reimplement it so that it reads statistics 5722 * TODO: reimplement it so that it reads statistics
5753 * from the adapter using ordinal tables 5723 * from the adapter using ordinal tables
@@ -5761,11 +5731,10 @@ static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5761 return &priv->ieee->stats; 5731 return &priv->ieee->stats;
5762} 5732}
5763 5733
5764/* Support for wpa_supplicant. Will be replaced with WEXT once 5734#if WIRELESS_EXT < 18
5765 * they get WPA support. */ 5735/* Support for wpa_supplicant before WE-18, deprecated. */
5766#ifdef CONFIG_IEEE80211_WPA
5767 5736
5768/* following definitions must match definitions in driver_ipw2100.c */ 5737/* following definitions must match definitions in driver_ipw.c */
5769 5738
5770#define IPW2100_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 5739#define IPW2100_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
5771 5740
@@ -5796,25 +5765,26 @@ static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5796struct ipw2100_param { 5765struct ipw2100_param {
5797 u32 cmd; 5766 u32 cmd;
5798 u8 sta_addr[ETH_ALEN]; 5767 u8 sta_addr[ETH_ALEN];
5799 union { 5768 union {
5800 struct { 5769 struct {
5801 u8 name; 5770 u8 name;
5802 u32 value; 5771 u32 value;
5803 } wpa_param; 5772 } wpa_param;
5804 struct { 5773 struct {
5805 u32 len; 5774 u32 len;
5806 u8 *data; 5775 u8 reserved[32];
5776 u8 data[0];
5807 } wpa_ie; 5777 } wpa_ie;
5808 struct{ 5778 struct {
5809 int command; 5779 u32 command;
5810 int reason_code; 5780 u32 reason_code;
5811 } mlme; 5781 } mlme;
5812 struct { 5782 struct {
5813 u8 alg[IPW2100_CRYPT_ALG_NAME_LEN]; 5783 u8 alg[IPW2100_CRYPT_ALG_NAME_LEN];
5814 u8 set_tx; 5784 u8 set_tx;
5815 u32 err; 5785 u32 err;
5816 u8 idx; 5786 u8 idx;
5817 u8 seq[8]; /* sequence counter (set: RX, get: TX) */ 5787 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
5818 u16 key_len; 5788 u16 key_len;
5819 u8 key[0]; 5789 u8 key[0];
5820 } crypt; 5790 } crypt;
@@ -5822,38 +5792,24 @@ struct ipw2100_param {
5822 } u; 5792 } u;
5823}; 5793};
5824 5794
5825/* end of driver_ipw2100.c code */ 5795/* end of driver_ipw.c code */
5796#endif /* WIRELESS_EXT < 18 */
5826 5797
5827static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value){ 5798static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
5828 5799{
5829 struct ieee80211_device *ieee = priv->ieee; 5800 /* This is called when wpa_supplicant loads and closes the driver
5830 struct ieee80211_security sec = { 5801 * interface. */
5831 .flags = SEC_LEVEL | SEC_ENABLED, 5802 priv->ieee->wpa_enabled = value;
5832 }; 5803 return 0;
5833 int ret = 0;
5834
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} 5804}
5852 5805
5853#define AUTH_ALG_OPEN_SYSTEM 0x1 5806#if WIRELESS_EXT < 18
5854#define AUTH_ALG_SHARED_KEY 0x2 5807#define IW_AUTH_ALG_OPEN_SYSTEM 0x1
5808#define IW_AUTH_ALG_SHARED_KEY 0x2
5809#endif
5855 5810
5856static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){ 5811static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
5812{
5857 5813
5858 struct ieee80211_device *ieee = priv->ieee; 5814 struct ieee80211_device *ieee = priv->ieee;
5859 struct ieee80211_security sec = { 5815 struct ieee80211_security sec = {
@@ -5861,13 +5817,14 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){
5861 }; 5817 };
5862 int ret = 0; 5818 int ret = 0;
5863 5819
5864 if (value & AUTH_ALG_SHARED_KEY){ 5820 if (value & IW_AUTH_ALG_SHARED_KEY) {
5865 sec.auth_mode = WLAN_AUTH_SHARED_KEY; 5821 sec.auth_mode = WLAN_AUTH_SHARED_KEY;
5866 ieee->open_wep = 0; 5822 ieee->open_wep = 0;
5867 } else { 5823 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) {
5868 sec.auth_mode = WLAN_AUTH_OPEN; 5824 sec.auth_mode = WLAN_AUTH_OPEN;
5869 ieee->open_wep = 1; 5825 ieee->open_wep = 1;
5870 } 5826 } else
5827 return -EINVAL;
5871 5828
5872 if (ieee->set_security) 5829 if (ieee->set_security)
5873 ieee->set_security(ieee->dev, &sec); 5830 ieee->set_security(ieee->dev, &sec);
@@ -5877,103 +5834,135 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){
5877 return ret; 5834 return ret;
5878} 5835}
5879 5836
5837void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv,
5838 char *wpa_ie, int wpa_ie_len)
5839{
5880 5840
5881static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value){ 5841 struct ipw2100_wpa_assoc_frame frame;
5882
5883 struct ipw2100_priv *priv = ieee80211_priv(dev);
5884 int ret=0;
5885 5842
5886 switch(name){ 5843 frame.fixed_ie_mask = 0;
5887 case IPW2100_PARAM_WPA_ENABLED:
5888 ret = ipw2100_wpa_enable(priv, value);
5889 break;
5890 5844
5891 case IPW2100_PARAM_TKIP_COUNTERMEASURES: 5845 /* copy WPA IE */
5892 priv->ieee->tkip_countermeasures=value; 5846 memcpy(frame.var_ie, wpa_ie, wpa_ie_len);
5893 break; 5847 frame.var_ie_len = wpa_ie_len;
5894 5848
5895 case IPW2100_PARAM_DROP_UNENCRYPTED: 5849 /* make sure WPA is enabled */
5896 priv->ieee->drop_unencrypted=value; 5850 ipw2100_wpa_enable(priv, 1);
5897 break; 5851 ipw2100_set_wpa_ie(priv, &frame, 0);
5852}
5898 5853
5899 case IPW2100_PARAM_PRIVACY_INVOKED: 5854#if WIRELESS_EXT < 18
5900 priv->ieee->privacy_invoked=value; 5855static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value)
5901 break; 5856{
5857 struct ipw2100_priv *priv = ieee80211_priv(dev);
5858 struct ieee80211_crypt_data *crypt;
5859 unsigned long flags;
5860 int ret = 0;
5902 5861
5903 case IPW2100_PARAM_AUTH_ALGS: 5862 switch (name) {
5904 ret = ipw2100_wpa_set_auth_algs(priv, value); 5863 case IPW2100_PARAM_WPA_ENABLED:
5905 break; 5864 ret = ipw2100_wpa_enable(priv, value);
5865 break;
5906 5866
5907 case IPW2100_PARAM_IEEE_802_1X: 5867 case IPW2100_PARAM_TKIP_COUNTERMEASURES:
5908 priv->ieee->ieee802_1x=value; 5868 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
5869 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags)
5909 break; 5870 break;
5910 5871
5911 default: 5872 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 5873
5917 return ret; 5874 if (value)
5918} 5875 flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
5876 else
5877 flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
5919 5878
5920static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason){ 5879 crypt->ops->set_flags(flags, crypt->priv);
5921 5880
5922 struct ipw2100_priv *priv = ieee80211_priv(dev); 5881 break;
5923 int ret=0;
5924 5882
5925 switch(command){ 5883 case IPW2100_PARAM_DROP_UNENCRYPTED:{
5926 case IPW2100_MLME_STA_DEAUTH: 5884 /* See IW_AUTH_DROP_UNENCRYPTED handling for details */
5927 // silently ignore 5885 struct ieee80211_security sec = {
5886 .flags = SEC_ENABLED,
5887 .enabled = value,
5888 };
5889 priv->ieee->drop_unencrypted = value;
5890 /* We only change SEC_LEVEL for open mode. Others
5891 * are set by ipw_wpa_set_encryption.
5892 */
5893 if (!value) {
5894 sec.flags |= SEC_LEVEL;
5895 sec.level = SEC_LEVEL_0;
5896 } else {
5897 sec.flags |= SEC_LEVEL;
5898 sec.level = SEC_LEVEL_1;
5899 }
5900 if (priv->ieee->set_security)
5901 priv->ieee->set_security(priv->ieee->dev, &sec);
5928 break; 5902 break;
5903 }
5929 5904
5930 case IPW2100_MLME_STA_DISASSOC: 5905 case IPW2100_PARAM_PRIVACY_INVOKED:
5931 ipw2100_disassociate_bssid(priv); 5906 priv->ieee->privacy_invoked = value;
5932 break; 5907 break;
5933 5908
5934 default: 5909 case IPW2100_PARAM_AUTH_ALGS:
5935 printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n", 5910 ret = ipw2100_wpa_set_auth_algs(priv, value);
5936 dev->name, command); 5911 break;
5937 ret = -EOPNOTSUPP; 5912
5913 case IPW2100_PARAM_IEEE_802_1X:
5914 priv->ieee->ieee802_1x = value;
5915 break;
5916
5917 default:
5918 printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n",
5919 dev->name, name);
5920 ret = -EOPNOTSUPP;
5938 } 5921 }
5939 5922
5940 return ret; 5923 return ret;
5941} 5924}
5942 5925
5926static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason)
5927{
5943 5928
5944void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, 5929 struct ipw2100_priv *priv = ieee80211_priv(dev);
5945 char *wpa_ie, int wpa_ie_len){ 5930 int ret = 0;
5946 5931
5947 struct ipw2100_wpa_assoc_frame frame; 5932 switch (command) {
5933 case IPW2100_MLME_STA_DEAUTH:
5934 // silently ignore
5935 break;
5948 5936
5949 frame.fixed_ie_mask = 0; 5937 case IPW2100_MLME_STA_DISASSOC:
5938 ipw2100_disassociate_bssid(priv);
5939 break;
5950 5940
5951 /* copy WPA IE */ 5941 default:
5952 memcpy(frame.var_ie, wpa_ie, wpa_ie_len); 5942 printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n",
5953 frame.var_ie_len = wpa_ie_len; 5943 dev->name, command);
5944 ret = -EOPNOTSUPP;
5945 }
5954 5946
5955 /* make sure WPA is enabled */ 5947 return ret;
5956 ipw2100_wpa_enable(priv, 1);
5957 ipw2100_set_wpa_ie(priv, &frame, 0);
5958} 5948}
5959 5949
5960
5961static int ipw2100_wpa_set_wpa_ie(struct net_device *dev, 5950static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
5962 struct ipw2100_param *param, int plen){ 5951 struct ipw2100_param *param, int plen)
5952{
5963 5953
5964 struct ipw2100_priv *priv = ieee80211_priv(dev); 5954 struct ipw2100_priv *priv = ieee80211_priv(dev);
5965 struct ieee80211_device *ieee = priv->ieee; 5955 struct ieee80211_device *ieee = priv->ieee;
5966 u8 *buf; 5956 u8 *buf;
5967 5957
5968 if (! ieee->wpa_enabled) 5958 if (!ieee->wpa_enabled)
5969 return -EOPNOTSUPP; 5959 return -EOPNOTSUPP;
5970 5960
5971 if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || 5961 if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
5972 (param->u.wpa_ie.len && 5962 (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
5973 param->u.wpa_ie.data==NULL))
5974 return -EINVAL; 5963 return -EINVAL;
5975 5964
5976 if (param->u.wpa_ie.len){ 5965 if (param->u.wpa_ie.len) {
5977 buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL); 5966 buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL);
5978 if (buf == NULL) 5967 if (buf == NULL)
5979 return -ENOMEM; 5968 return -ENOMEM;
@@ -5998,8 +5987,9 @@ static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
5998/* implementation borrowed from hostap driver */ 5987/* implementation borrowed from hostap driver */
5999 5988
6000static int ipw2100_wpa_set_encryption(struct net_device *dev, 5989static int ipw2100_wpa_set_encryption(struct net_device *dev,
6001 struct ipw2100_param *param, int param_len){ 5990 struct ipw2100_param *param,
6002 5991 int param_len)
5992{
6003 int ret = 0; 5993 int ret = 0;
6004 struct ipw2100_priv *priv = ieee80211_priv(dev); 5994 struct ipw2100_priv *priv = ieee80211_priv(dev);
6005 struct ieee80211_device *ieee = priv->ieee; 5995 struct ieee80211_device *ieee = priv->ieee;
@@ -6014,9 +6004,10 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6014 param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0'; 6004 param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0';
6015 6005
6016 if (param_len != 6006 if (param_len !=
6017 (int) ((char *) param->u.crypt.key - (char *) param) + 6007 (int)((char *)param->u.crypt.key - (char *)param) +
6018 param->u.crypt.key_len){ 6008 param->u.crypt.key_len) {
6019 IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); 6009 IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len,
6010 param->u.crypt.key_len);
6020 return -EINVAL; 6011 return -EINVAL;
6021 } 6012 }
6022 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && 6013 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
@@ -6029,17 +6020,19 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6029 return -EINVAL; 6020 return -EINVAL;
6030 } 6021 }
6031 6022
6023 sec.flags |= SEC_ENABLED | SEC_ENCRYPT;
6032 if (strcmp(param->u.crypt.alg, "none") == 0) { 6024 if (strcmp(param->u.crypt.alg, "none") == 0) {
6033 if (crypt){ 6025 if (crypt) {
6034 sec.enabled = 0; 6026 sec.enabled = 0;
6027 sec.encrypt = 0;
6035 sec.level = SEC_LEVEL_0; 6028 sec.level = SEC_LEVEL_0;
6036 sec.flags |= SEC_ENABLED | SEC_LEVEL; 6029 sec.flags |= SEC_LEVEL;
6037 ieee80211_crypt_delayed_deinit(ieee, crypt); 6030 ieee80211_crypt_delayed_deinit(ieee, crypt);
6038 } 6031 }
6039 goto done; 6032 goto done;
6040 } 6033 }
6041 sec.enabled = 1; 6034 sec.enabled = 1;
6042 sec.flags |= SEC_ENABLED; 6035 sec.encrypt = 1;
6043 6036
6044 ops = ieee80211_get_crypto_ops(param->u.crypt.alg); 6037 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
6045 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { 6038 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
@@ -6054,7 +6047,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6054 } 6047 }
6055 if (ops == NULL) { 6048 if (ops == NULL) {
6056 IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n", 6049 IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n",
6057 dev->name, param->u.crypt.alg); 6050 dev->name, param->u.crypt.alg);
6058 param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG; 6051 param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG;
6059 ret = -EINVAL; 6052 ret = -EINVAL;
6060 goto done; 6053 goto done;
@@ -6072,12 +6065,13 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6072 } 6065 }
6073 new_crypt->ops = ops; 6066 new_crypt->ops = ops;
6074 if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) 6067 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
6075 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); 6068 new_crypt->priv =
6069 new_crypt->ops->init(param->u.crypt.idx);
6076 6070
6077 if (new_crypt->priv == NULL) { 6071 if (new_crypt->priv == NULL) {
6078 kfree(new_crypt); 6072 kfree(new_crypt);
6079 param->u.crypt.err = 6073 param->u.crypt.err =
6080 IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED; 6074 IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED;
6081 ret = -EINVAL; 6075 ret = -EINVAL;
6082 goto done; 6076 goto done;
6083 } 6077 }
@@ -6089,24 +6083,25 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6089 (*crypt)->ops->set_key(param->u.crypt.key, 6083 (*crypt)->ops->set_key(param->u.crypt.key,
6090 param->u.crypt.key_len, param->u.crypt.seq, 6084 param->u.crypt.key_len, param->u.crypt.seq,
6091 (*crypt)->priv) < 0) { 6085 (*crypt)->priv) < 0) {
6092 IPW_DEBUG_INFO("%s: key setting failed\n", 6086 IPW_DEBUG_INFO("%s: key setting failed\n", dev->name);
6093 dev->name);
6094 param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED; 6087 param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED;
6095 ret = -EINVAL; 6088 ret = -EINVAL;
6096 goto done; 6089 goto done;
6097 } 6090 }
6098 6091
6099 if (param->u.crypt.set_tx){ 6092 if (param->u.crypt.set_tx) {
6100 ieee->tx_keyidx = param->u.crypt.idx; 6093 ieee->tx_keyidx = param->u.crypt.idx;
6101 sec.active_key = param->u.crypt.idx; 6094 sec.active_key = param->u.crypt.idx;
6102 sec.flags |= SEC_ACTIVE_KEY; 6095 sec.flags |= SEC_ACTIVE_KEY;
6103 } 6096 }
6104 6097
6105 if (ops->name != NULL){ 6098 if (ops->name != NULL) {
6106 6099
6107 if (strcmp(ops->name, "WEP") == 0) { 6100 if (strcmp(ops->name, "WEP") == 0) {
6108 memcpy(sec.keys[param->u.crypt.idx], param->u.crypt.key, param->u.crypt.key_len); 6101 memcpy(sec.keys[param->u.crypt.idx],
6109 sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len; 6102 param->u.crypt.key, param->u.crypt.key_len);
6103 sec.key_sizes[param->u.crypt.idx] =
6104 param->u.crypt.key_len;
6110 sec.flags |= (1 << param->u.crypt.idx); 6105 sec.flags |= (1 << param->u.crypt.idx);
6111 sec.flags |= SEC_LEVEL; 6106 sec.flags |= SEC_LEVEL;
6112 sec.level = SEC_LEVEL_1; 6107 sec.level = SEC_LEVEL_1;
@@ -6118,7 +6113,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6118 sec.level = SEC_LEVEL_3; 6113 sec.level = SEC_LEVEL_3;
6119 } 6114 }
6120 } 6115 }
6121 done: 6116 done:
6122 if (ieee->set_security) 6117 if (ieee->set_security)
6123 ieee->set_security(ieee->dev, &sec); 6118 ieee->set_security(ieee->dev, &sec);
6124 6119
@@ -6129,8 +6124,7 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6129 * the callbacks structures used to initialize the 802.11 stack. */ 6124 * the callbacks structures used to initialize the 802.11 stack. */
6130 if (ieee->reset_on_keychange && 6125 if (ieee->reset_on_keychange &&
6131 ieee->iw_mode != IW_MODE_INFRA && 6126 ieee->iw_mode != IW_MODE_INFRA &&
6132 ieee->reset_port && 6127 ieee->reset_port && ieee->reset_port(dev)) {
6133 ieee->reset_port(dev)) {
6134 IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name); 6128 IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name);
6135 param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED; 6129 param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED;
6136 return -EINVAL; 6130 return -EINVAL;
@@ -6139,11 +6133,11 @@ static int ipw2100_wpa_set_encryption(struct net_device *dev,
6139 return ret; 6133 return ret;
6140} 6134}
6141 6135
6142 6136static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p)
6143static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){ 6137{
6144 6138
6145 struct ipw2100_param *param; 6139 struct ipw2100_param *param;
6146 int ret=0; 6140 int ret = 0;
6147 6141
6148 IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length); 6142 IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length);
6149 6143
@@ -6154,12 +6148,12 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6154 if (param == NULL) 6148 if (param == NULL)
6155 return -ENOMEM; 6149 return -ENOMEM;
6156 6150
6157 if (copy_from_user(param, p->pointer, p->length)){ 6151 if (copy_from_user(param, p->pointer, p->length)) {
6158 kfree(param); 6152 kfree(param);
6159 return -EFAULT; 6153 return -EFAULT;
6160 } 6154 }
6161 6155
6162 switch (param->cmd){ 6156 switch (param->cmd) {
6163 6157
6164 case IPW2100_CMD_SET_WPA_PARAM: 6158 case IPW2100_CMD_SET_WPA_PARAM:
6165 ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name, 6159 ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name,
@@ -6180,8 +6174,9 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6180 break; 6174 break;
6181 6175
6182 default: 6176 default:
6183 printk(KERN_ERR DRV_NAME ": %s: Unknown WPA supplicant request: %d\n", 6177 printk(KERN_ERR DRV_NAME
6184 dev->name, param->cmd); 6178 ": %s: Unknown WPA supplicant request: %d\n", dev->name,
6179 param->cmd);
6185 ret = -EOPNOTSUPP; 6180 ret = -EOPNOTSUPP;
6186 6181
6187 } 6182 }
@@ -6192,27 +6187,23 @@ static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){
6192 kfree(param); 6187 kfree(param);
6193 return ret; 6188 return ret;
6194} 6189}
6195#endif /* CONFIG_IEEE80211_WPA */
6196 6190
6197static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 6191static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6198{ 6192{
6199#ifdef CONFIG_IEEE80211_WPA 6193 struct iwreq *wrq = (struct iwreq *)rq;
6200 struct iwreq *wrq = (struct iwreq *) rq; 6194 int ret = -1;
6201 int ret=-1; 6195 switch (cmd) {
6202 switch (cmd){ 6196 case IPW2100_IOCTL_WPA_SUPPLICANT:
6203 case IPW2100_IOCTL_WPA_SUPPLICANT:
6204 ret = ipw2100_wpa_supplicant(dev, &wrq->u.data); 6197 ret = ipw2100_wpa_supplicant(dev, &wrq->u.data);
6205 return ret; 6198 return ret;
6206 6199
6207 default: 6200 default:
6208 return -EOPNOTSUPP; 6201 return -EOPNOTSUPP;
6209 } 6202 }
6210 6203
6211#endif /* CONFIG_IEEE80211_WPA */
6212
6213 return -EOPNOTSUPP; 6204 return -EOPNOTSUPP;
6214} 6205}
6215 6206#endif /* WIRELESS_EXT < 18 */
6216 6207
6217static void ipw_ethtool_get_drvinfo(struct net_device *dev, 6208static void ipw_ethtool_get_drvinfo(struct net_device *dev,
6218 struct ethtool_drvinfo *info) 6209 struct ethtool_drvinfo *info)
@@ -6234,14 +6225,13 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
6234 6225
6235static u32 ipw2100_ethtool_get_link(struct net_device *dev) 6226static u32 ipw2100_ethtool_get_link(struct net_device *dev)
6236{ 6227{
6237 struct ipw2100_priv *priv = ieee80211_priv(dev); 6228 struct ipw2100_priv *priv = ieee80211_priv(dev);
6238 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; 6229 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0;
6239} 6230}
6240 6231
6241
6242static struct ethtool_ops ipw2100_ethtool_ops = { 6232static struct ethtool_ops ipw2100_ethtool_ops = {
6243 .get_link = ipw2100_ethtool_get_link, 6233 .get_link = ipw2100_ethtool_get_link,
6244 .get_drvinfo = ipw_ethtool_get_drvinfo, 6234 .get_drvinfo = ipw_ethtool_get_drvinfo,
6245}; 6235};
6246 6236
6247static void ipw2100_hang_check(void *adapter) 6237static void ipw2100_hang_check(void *adapter)
@@ -6286,7 +6276,6 @@ static void ipw2100_hang_check(void *adapter)
6286 spin_unlock_irqrestore(&priv->low_lock, flags); 6276 spin_unlock_irqrestore(&priv->low_lock, flags);
6287} 6277}
6288 6278
6289
6290static void ipw2100_rf_kill(void *adapter) 6279static void ipw2100_rf_kill(void *adapter)
6291{ 6280{
6292 struct ipw2100_priv *priv = adapter; 6281 struct ipw2100_priv *priv = adapter;
@@ -6311,7 +6300,7 @@ static void ipw2100_rf_kill(void *adapter)
6311 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still " 6300 IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still "
6312 "enabled\n"); 6301 "enabled\n");
6313 6302
6314 exit_unlock: 6303 exit_unlock:
6315 spin_unlock_irqrestore(&priv->low_lock, flags); 6304 spin_unlock_irqrestore(&priv->low_lock, flags);
6316} 6305}
6317 6306
@@ -6319,11 +6308,10 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv);
6319 6308
6320/* Look into using netdev destructor to shutdown ieee80211? */ 6309/* Look into using netdev destructor to shutdown ieee80211? */
6321 6310
6322static struct net_device *ipw2100_alloc_device( 6311static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6323 struct pci_dev *pci_dev, 6312 void __iomem * base_addr,
6324 void __iomem *base_addr, 6313 unsigned long mem_start,
6325 unsigned long mem_start, 6314 unsigned long mem_len)
6326 unsigned long mem_len)
6327{ 6315{
6328 struct ipw2100_priv *priv; 6316 struct ipw2100_priv *priv;
6329 struct net_device *dev; 6317 struct net_device *dev;
@@ -6339,17 +6327,22 @@ static struct net_device *ipw2100_alloc_device(
6339 priv->ieee->hard_start_xmit = ipw2100_tx; 6327 priv->ieee->hard_start_xmit = ipw2100_tx;
6340 priv->ieee->set_security = shim__set_security; 6328 priv->ieee->set_security = shim__set_security;
6341 6329
6330 priv->ieee->perfect_rssi = -20;
6331 priv->ieee->worst_rssi = -85;
6332
6342 dev->open = ipw2100_open; 6333 dev->open = ipw2100_open;
6343 dev->stop = ipw2100_close; 6334 dev->stop = ipw2100_close;
6344 dev->init = ipw2100_net_init; 6335 dev->init = ipw2100_net_init;
6336#if WIRELESS_EXT < 18
6345 dev->do_ioctl = ipw2100_ioctl; 6337 dev->do_ioctl = ipw2100_ioctl;
6338#endif
6346 dev->get_stats = ipw2100_stats; 6339 dev->get_stats = ipw2100_stats;
6347 dev->ethtool_ops = &ipw2100_ethtool_ops; 6340 dev->ethtool_ops = &ipw2100_ethtool_ops;
6348 dev->tx_timeout = ipw2100_tx_timeout; 6341 dev->tx_timeout = ipw2100_tx_timeout;
6349 dev->wireless_handlers = &ipw2100_wx_handler_def; 6342 dev->wireless_handlers = &ipw2100_wx_handler_def;
6350 dev->get_wireless_stats = ipw2100_wx_wireless_stats; 6343 dev->get_wireless_stats = ipw2100_wx_wireless_stats;
6351 dev->set_mac_address = ipw2100_set_address; 6344 dev->set_mac_address = ipw2100_set_address;
6352 dev->watchdog_timeo = 3*HZ; 6345 dev->watchdog_timeo = 3 * HZ;
6353 dev->irq = 0; 6346 dev->irq = 0;
6354 6347
6355 dev->base_addr = (unsigned long)base_addr; 6348 dev->base_addr = (unsigned long)base_addr;
@@ -6362,22 +6355,19 @@ static struct net_device *ipw2100_alloc_device(
6362 * ends up causing problems. So, we just handle 6355 * ends up causing problems. So, we just handle
6363 * the WX extensions through the ipw2100_ioctl interface */ 6356 * the WX extensions through the ipw2100_ioctl interface */
6364 6357
6365
6366 /* memset() puts everything to 0, so we only have explicitely set 6358 /* memset() puts everything to 0, so we only have explicitely set
6367 * those values that need to be something else */ 6359 * those values that need to be something else */
6368 6360
6369 /* If power management is turned on, default to AUTO mode */ 6361 /* If power management is turned on, default to AUTO mode */
6370 priv->power_mode = IPW_POWER_AUTO; 6362 priv->power_mode = IPW_POWER_AUTO;
6371 6363
6372 6364#ifdef CONFIG_IPW2100_MONITOR
6373 6365 priv->config |= CFG_CRC_CHECK;
6374#ifdef CONFIG_IEEE80211_WPA 6366#endif
6375 priv->ieee->wpa_enabled = 0; 6367 priv->ieee->wpa_enabled = 0;
6376 priv->ieee->tkip_countermeasures = 0;
6377 priv->ieee->drop_unencrypted = 0; 6368 priv->ieee->drop_unencrypted = 0;
6378 priv->ieee->privacy_invoked = 0; 6369 priv->ieee->privacy_invoked = 0;
6379 priv->ieee->ieee802_1x = 1; 6370 priv->ieee->ieee802_1x = 1;
6380#endif /* CONFIG_IEEE80211_WPA */
6381 6371
6382 /* Set module parameters */ 6372 /* Set module parameters */
6383 switch (mode) { 6373 switch (mode) {
@@ -6399,8 +6389,7 @@ static struct net_device *ipw2100_alloc_device(
6399 priv->status |= STATUS_RF_KILL_SW; 6389 priv->status |= STATUS_RF_KILL_SW;
6400 6390
6401 if (channel != 0 && 6391 if (channel != 0 &&
6402 ((channel >= REG_MIN_CHANNEL) && 6392 ((channel >= REG_MIN_CHANNEL) && (channel <= REG_MAX_CHANNEL))) {
6403 (channel <= REG_MAX_CHANNEL))) {
6404 priv->config |= CFG_STATIC_CHANNEL; 6393 priv->config |= CFG_STATIC_CHANNEL;
6405 priv->channel = channel; 6394 priv->channel = channel;
6406 } 6395 }
@@ -6439,12 +6428,8 @@ static struct net_device *ipw2100_alloc_device(
6439 INIT_LIST_HEAD(&priv->fw_pend_list); 6428 INIT_LIST_HEAD(&priv->fw_pend_list);
6440 INIT_STAT(&priv->fw_pend_stat); 6429 INIT_STAT(&priv->fw_pend_stat);
6441 6430
6442
6443#ifdef CONFIG_SOFTWARE_SUSPEND2
6444 priv->workqueue = create_workqueue(DRV_NAME, 0);
6445#else
6446 priv->workqueue = create_workqueue(DRV_NAME); 6431 priv->workqueue = create_workqueue(DRV_NAME);
6447#endif 6432
6448 INIT_WORK(&priv->reset_work, 6433 INIT_WORK(&priv->reset_work,
6449 (void (*)(void *))ipw2100_reset_adapter, priv); 6434 (void (*)(void *))ipw2100_reset_adapter, priv);
6450 INIT_WORK(&priv->security_work, 6435 INIT_WORK(&priv->security_work,
@@ -6533,7 +6518,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6533 return err; 6518 return err;
6534 } 6519 }
6535 6520
6536 /* We disable the RETRY_TIMEOUT register (0x41) to keep 6521 /* We disable the RETRY_TIMEOUT register (0x41) to keep
6537 * PCI Tx retries from interfering with C3 CPU state */ 6522 * PCI Tx retries from interfering with C3 CPU state */
6538 pci_read_config_dword(pci_dev, 0x40, &val); 6523 pci_read_config_dword(pci_dev, 0x40, &val);
6539 if ((val & 0x0000ff00) != 0) 6524 if ((val & 0x0000ff00) != 0)
@@ -6564,12 +6549,10 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6564 ipw2100_queues_initialize(priv); 6549 ipw2100_queues_initialize(priv);
6565 6550
6566 err = request_irq(pci_dev->irq, 6551 err = request_irq(pci_dev->irq,
6567 ipw2100_interrupt, SA_SHIRQ, 6552 ipw2100_interrupt, SA_SHIRQ, dev->name, priv);
6568 dev->name, priv);
6569 if (err) { 6553 if (err) {
6570 printk(KERN_WARNING DRV_NAME 6554 printk(KERN_WARNING DRV_NAME
6571 "Error calling request_irq: %d.\n", 6555 "Error calling request_irq: %d.\n", pci_dev->irq);
6572 pci_dev->irq);
6573 goto fail; 6556 goto fail;
6574 } 6557 }
6575 dev->irq = pci_dev->irq; 6558 dev->irq = pci_dev->irq;
@@ -6604,7 +6587,6 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6604 6587
6605 /* perform this after register_netdev so that dev->name is set */ 6588 /* perform this after register_netdev so that dev->name is set */
6606 sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6589 sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
6607 netif_carrier_off(dev);
6608 6590
6609 /* If the RF Kill switch is disabled, go ahead and complete the 6591 /* If the RF Kill switch is disabled, go ahead and complete the
6610 * startup sequence */ 6592 * startup sequence */
@@ -6632,10 +6614,10 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6632 6614
6633 return 0; 6615 return 0;
6634 6616
6635 fail_unlock: 6617 fail_unlock:
6636 up(&priv->action_sem); 6618 up(&priv->action_sem);
6637 6619
6638 fail: 6620 fail:
6639 if (dev) { 6621 if (dev) {
6640 if (registered) 6622 if (registered)
6641 unregister_netdev(dev); 6623 unregister_netdev(dev);
@@ -6651,7 +6633,8 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6651 6633
6652 /* These are safe to call even if they weren't allocated */ 6634 /* These are safe to call even if they weren't allocated */
6653 ipw2100_queues_free(priv); 6635 ipw2100_queues_free(priv);
6654 sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6636 sysfs_remove_group(&pci_dev->dev.kobj,
6637 &ipw2100_attribute_group);
6655 6638
6656 free_ieee80211(dev); 6639 free_ieee80211(dev);
6657 pci_set_drvdata(pci_dev, NULL); 6640 pci_set_drvdata(pci_dev, NULL);
@@ -6677,7 +6660,8 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6677 priv->status &= ~STATUS_INITIALIZED; 6660 priv->status &= ~STATUS_INITIALIZED;
6678 6661
6679 dev = priv->net_dev; 6662 dev = priv->net_dev;
6680 sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); 6663 sysfs_remove_group(&pci_dev->dev.kobj,
6664 &ipw2100_attribute_group);
6681 6665
6682#ifdef CONFIG_PM 6666#ifdef CONFIG_PM
6683 if (ipw2100_firmware.version) 6667 if (ipw2100_firmware.version)
@@ -6719,19 +6703,13 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6719 IPW_DEBUG_INFO("exit\n"); 6703 IPW_DEBUG_INFO("exit\n");
6720} 6704}
6721 6705
6722
6723#ifdef CONFIG_PM 6706#ifdef CONFIG_PM
6724#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
6725static int ipw2100_suspend(struct pci_dev *pci_dev, u32 state)
6726#else
6727static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state) 6707static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
6728#endif
6729{ 6708{
6730 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); 6709 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
6731 struct net_device *dev = priv->net_dev; 6710 struct net_device *dev = priv->net_dev;
6732 6711
6733 IPW_DEBUG_INFO("%s: Going into suspend...\n", 6712 IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name);
6734 dev->name);
6735 6713
6736 down(&priv->action_sem); 6714 down(&priv->action_sem);
6737 if (priv->status & STATUS_INITIALIZED) { 6715 if (priv->status & STATUS_INITIALIZED) {
@@ -6743,7 +6721,7 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
6743 netif_device_detach(dev); 6721 netif_device_detach(dev);
6744 6722
6745 pci_save_state(pci_dev); 6723 pci_save_state(pci_dev);
6746 pci_disable_device (pci_dev); 6724 pci_disable_device(pci_dev);
6747 pci_set_power_state(pci_dev, PCI_D3hot); 6725 pci_set_power_state(pci_dev, PCI_D3hot);
6748 6726
6749 up(&priv->action_sem); 6727 up(&priv->action_sem);
@@ -6762,8 +6740,7 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6762 6740
6763 down(&priv->action_sem); 6741 down(&priv->action_sem);
6764 6742
6765 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", 6743 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
6766 dev->name);
6767 6744
6768 pci_set_power_state(pci_dev, PCI_D0); 6745 pci_set_power_state(pci_dev, PCI_D0);
6769 pci_enable_device(pci_dev); 6746 pci_enable_device(pci_dev);
@@ -6783,9 +6760,9 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6783 * the queue of needed */ 6760 * the queue of needed */
6784 netif_device_attach(dev); 6761 netif_device_attach(dev);
6785 6762
6786 /* Bring the device back up */ 6763 /* Bring the device back up */
6787 if (!(priv->status & STATUS_RF_KILL_SW)) 6764 if (!(priv->status & STATUS_RF_KILL_SW))
6788 ipw2100_up(priv, 0); 6765 ipw2100_up(priv, 0);
6789 6766
6790 up(&priv->action_sem); 6767 up(&priv->action_sem);
6791 6768
@@ -6793,56 +6770,55 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6793} 6770}
6794#endif 6771#endif
6795 6772
6796
6797#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x } 6773#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x }
6798 6774
6799static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = { 6775static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = {
6800 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */ 6776 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */
6801 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */ 6777 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */
6802 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */ 6778 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */
6803 IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */ 6779 IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */
6804 IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */ 6780 IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */
6805 IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */ 6781 IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */
6806 IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */ 6782 IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */
6807 IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */ 6783 IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */
6808 IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */ 6784 IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */
6809 IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */ 6785 IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */
6810 IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */ 6786 IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */
6811 IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */ 6787 IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */
6812 IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */ 6788 IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */
6813 6789
6814 IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */ 6790 IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */
6815 IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */ 6791 IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */
6816 IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */ 6792 IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */
6817 IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */ 6793 IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */
6818 IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */ 6794 IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */
6819 6795
6820 IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */ 6796 IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */
6821 IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */ 6797 IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */
6822 IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */ 6798 IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */
6823 IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */ 6799 IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */
6824 IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */ 6800 IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */
6825 IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */ 6801 IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */
6826 IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */ 6802 IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */
6827 6803
6828 IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */ 6804 IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */
6829 6805
6830 IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */ 6806 IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */
6831 IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */ 6807 IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */
6832 IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */ 6808 IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */
6833 IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */ 6809 IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */
6834 IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */ 6810 IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */
6835 IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */ 6811 IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */
6836 IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */ 6812 IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */
6837 6813
6838 IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */ 6814 IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */
6839 IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */ 6815 IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */
6840 IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */ 6816 IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */
6841 IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */ 6817 IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */
6842 IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */ 6818 IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */
6843 IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */ 6819 IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */
6844 6820
6845 IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */ 6821 IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */
6846 {0,}, 6822 {0,},
6847}; 6823};
6848 6824
@@ -6859,7 +6835,6 @@ static struct pci_driver ipw2100_pci_driver = {
6859#endif 6835#endif
6860}; 6836};
6861 6837
6862
6863/** 6838/**
6864 * Initialize the ipw2100 driver/module 6839 * Initialize the ipw2100 driver/module
6865 * 6840 *
@@ -6876,10 +6851,6 @@ static int __init ipw2100_init(void)
6876 printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 6851 printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
6877 printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT); 6852 printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT);
6878 6853
6879#ifdef CONFIG_IEEE80211_NOWEP
6880 IPW_DEBUG_INFO(DRV_NAME ": Compiled with WEP disabled.\n");
6881#endif
6882
6883 ret = pci_module_init(&ipw2100_pci_driver); 6854 ret = pci_module_init(&ipw2100_pci_driver);
6884 6855
6885#ifdef CONFIG_IPW_DEBUG 6856#ifdef CONFIG_IPW_DEBUG
@@ -6891,7 +6862,6 @@ static int __init ipw2100_init(void)
6891 return ret; 6862 return ret;
6892} 6863}
6893 6864
6894
6895/** 6865/**
6896 * Cleanup ipw2100 driver registration 6866 * Cleanup ipw2100 driver registration
6897 */ 6867 */
@@ -6947,7 +6917,6 @@ static int ipw2100_wx_get_name(struct net_device *dev,
6947 return 0; 6917 return 0;
6948} 6918}
6949 6919
6950
6951static int ipw2100_wx_set_freq(struct net_device *dev, 6920static int ipw2100_wx_set_freq(struct net_device *dev,
6952 struct iw_request_info *info, 6921 struct iw_request_info *info,
6953 union iwreq_data *wrqu, char *extra) 6922 union iwreq_data *wrqu, char *extra)
@@ -6967,8 +6936,7 @@ static int ipw2100_wx_set_freq(struct net_device *dev,
6967 6936
6968 /* if setting by freq convert to channel */ 6937 /* if setting by freq convert to channel */
6969 if (fwrq->e == 1) { 6938 if (fwrq->e == 1) {
6970 if ((fwrq->m >= (int) 2.412e8 && 6939 if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) {
6971 fwrq->m <= (int) 2.487e8)) {
6972 int f = fwrq->m / 100000; 6940 int f = fwrq->m / 100000;
6973 int c = 0; 6941 int c = 0;
6974 6942
@@ -6982,19 +6950,19 @@ static int ipw2100_wx_set_freq(struct net_device *dev,
6982 } 6950 }
6983 } 6951 }
6984 6952
6985 if (fwrq->e > 0 || fwrq->m > 1000) 6953 if (fwrq->e > 0 || fwrq->m > 1000) {
6986 return -EOPNOTSUPP; 6954 err = -EOPNOTSUPP;
6987 else { /* Set the channel */ 6955 goto done;
6956 } else { /* Set the channel */
6988 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); 6957 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
6989 err = ipw2100_set_channel(priv, fwrq->m, 0); 6958 err = ipw2100_set_channel(priv, fwrq->m, 0);
6990 } 6959 }
6991 6960
6992 done: 6961 done:
6993 up(&priv->action_sem); 6962 up(&priv->action_sem);
6994 return err; 6963 return err;
6995} 6964}
6996 6965
6997
6998static int ipw2100_wx_get_freq(struct net_device *dev, 6966static int ipw2100_wx_get_freq(struct net_device *dev,
6999 struct iw_request_info *info, 6967 struct iw_request_info *info,
7000 union iwreq_data *wrqu, char *extra) 6968 union iwreq_data *wrqu, char *extra)
@@ -7043,7 +7011,7 @@ static int ipw2100_wx_set_mode(struct net_device *dev,
7043 case IW_MODE_MONITOR: 7011 case IW_MODE_MONITOR:
7044 err = ipw2100_switch_mode(priv, IW_MODE_MONITOR); 7012 err = ipw2100_switch_mode(priv, IW_MODE_MONITOR);
7045 break; 7013 break;
7046#endif /* CONFIG_IPW2100_MONITOR */ 7014#endif /* CONFIG_IPW2100_MONITOR */
7047 case IW_MODE_ADHOC: 7015 case IW_MODE_ADHOC:
7048 err = ipw2100_switch_mode(priv, IW_MODE_ADHOC); 7016 err = ipw2100_switch_mode(priv, IW_MODE_ADHOC);
7049 break; 7017 break;
@@ -7054,9 +7022,9 @@ static int ipw2100_wx_set_mode(struct net_device *dev,
7054 break; 7022 break;
7055 } 7023 }
7056 7024
7057done: 7025 done:
7058 up(&priv->action_sem); 7026 up(&priv->action_sem);
7059 return err; 7027 return err;
7060} 7028}
7061 7029
7062static int ipw2100_wx_get_mode(struct net_device *dev, 7030static int ipw2100_wx_get_mode(struct net_device *dev,
@@ -7075,7 +7043,6 @@ static int ipw2100_wx_get_mode(struct net_device *dev,
7075 return 0; 7043 return 0;
7076} 7044}
7077 7045
7078
7079#define POWER_MODES 5 7046#define POWER_MODES 5
7080 7047
7081/* Values are in microsecond */ 7048/* Values are in microsecond */
@@ -7122,19 +7089,19 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7122 /* ~5 Mb/s real (802.11b) */ 7089 /* ~5 Mb/s real (802.11b) */
7123 range->throughput = 5 * 1000 * 1000; 7090 range->throughput = 5 * 1000 * 1000;
7124 7091
7125// range->sensitivity; /* signal level threshold range */ 7092// range->sensitivity; /* signal level threshold range */
7126 7093
7127 range->max_qual.qual = 100; 7094 range->max_qual.qual = 100;
7128 /* TODO: Find real max RSSI and stick here */ 7095 /* TODO: Find real max RSSI and stick here */
7129 range->max_qual.level = 0; 7096 range->max_qual.level = 0;
7130 range->max_qual.noise = 0; 7097 range->max_qual.noise = 0;
7131 range->max_qual.updated = 7; /* Updated all three */ 7098 range->max_qual.updated = 7; /* Updated all three */
7132 7099
7133 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ 7100 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
7134 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ 7101 /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
7135 range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM; 7102 range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM;
7136 range->avg_qual.noise = 0; 7103 range->avg_qual.noise = 0;
7137 range->avg_qual.updated = 7; /* Updated all three */ 7104 range->avg_qual.updated = 7; /* Updated all three */
7138 7105
7139 range->num_bitrates = RATE_COUNT; 7106 range->num_bitrates = RATE_COUNT;
7140 7107
@@ -7148,61 +7115,62 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7148 range->max_frag = MAX_FRAG_THRESHOLD; 7115 range->max_frag = MAX_FRAG_THRESHOLD;
7149 7116
7150 range->min_pmp = period_duration[0]; /* Minimal PM period */ 7117 range->min_pmp = period_duration[0]; /* Minimal PM period */
7151 range->max_pmp = period_duration[POWER_MODES-1];/* Maximal PM period */ 7118 range->max_pmp = period_duration[POWER_MODES - 1]; /* Maximal PM period */
7152 range->min_pmt = timeout_duration[POWER_MODES-1]; /* Minimal PM timeout */ 7119 range->min_pmt = timeout_duration[POWER_MODES - 1]; /* Minimal PM timeout */
7153 range->max_pmt = timeout_duration[0];/* Maximal PM timeout */ 7120 range->max_pmt = timeout_duration[0]; /* Maximal PM timeout */
7154 7121
7155 /* How to decode max/min PM period */ 7122 /* How to decode max/min PM period */
7156 range->pmp_flags = IW_POWER_PERIOD; 7123 range->pmp_flags = IW_POWER_PERIOD;
7157 /* How to decode max/min PM period */ 7124 /* How to decode max/min PM period */
7158 range->pmt_flags = IW_POWER_TIMEOUT; 7125 range->pmt_flags = IW_POWER_TIMEOUT;
7159 /* What PM options are supported */ 7126 /* What PM options are supported */
7160 range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD; 7127 range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD;
7161 7128
7162 range->encoding_size[0] = 5; 7129 range->encoding_size[0] = 5;
7163 range->encoding_size[1] = 13; /* Different token sizes */ 7130 range->encoding_size[1] = 13; /* Different token sizes */
7164 range->num_encoding_sizes = 2; /* Number of entry in the list */ 7131 range->num_encoding_sizes = 2; /* Number of entry in the list */
7165 range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ 7132 range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */
7166// range->encoding_login_index; /* token index for login token */ 7133// range->encoding_login_index; /* token index for login token */
7167 7134
7168 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 7135 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
7169 range->txpower_capa = IW_TXPOW_DBM; 7136 range->txpower_capa = IW_TXPOW_DBM;
7170 range->num_txpower = IW_MAX_TXPOWER; 7137 range->num_txpower = IW_MAX_TXPOWER;
7171 for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16); i < IW_MAX_TXPOWER; 7138 for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16);
7172 i++, level -= ((IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM) * 16) / 7139 i < IW_MAX_TXPOWER;
7173 (IW_MAX_TXPOWER - 1)) 7140 i++, level -=
7141 ((IPW_TX_POWER_MAX_DBM -
7142 IPW_TX_POWER_MIN_DBM) * 16) / (IW_MAX_TXPOWER - 1))
7174 range->txpower[i] = level / 16; 7143 range->txpower[i] = level / 16;
7175 } else { 7144 } else {
7176 range->txpower_capa = 0; 7145 range->txpower_capa = 0;
7177 range->num_txpower = 0; 7146 range->num_txpower = 0;
7178 } 7147 }
7179 7148
7180
7181 /* Set the Wireless Extension versions */ 7149 /* Set the Wireless Extension versions */
7182 range->we_version_compiled = WIRELESS_EXT; 7150 range->we_version_compiled = WIRELESS_EXT;
7183 range->we_version_source = 16; 7151 range->we_version_source = 16;
7184 7152
7185// range->retry_capa; /* What retry options are supported */ 7153// range->retry_capa; /* What retry options are supported */
7186// range->retry_flags; /* How to decode max/min retry limit */ 7154// range->retry_flags; /* How to decode max/min retry limit */
7187// range->r_time_flags; /* How to decode max/min retry life */ 7155// range->r_time_flags; /* How to decode max/min retry life */
7188// range->min_retry; /* Minimal number of retries */ 7156// range->min_retry; /* Minimal number of retries */
7189// range->max_retry; /* Maximal number of retries */ 7157// range->max_retry; /* Maximal number of retries */
7190// range->min_r_time; /* Minimal retry lifetime */ 7158// range->min_r_time; /* Minimal retry lifetime */
7191// range->max_r_time; /* Maximal retry lifetime */ 7159// range->max_r_time; /* Maximal retry lifetime */
7192 7160
7193 range->num_channels = FREQ_COUNT; 7161 range->num_channels = FREQ_COUNT;
7194 7162
7195 val = 0; 7163 val = 0;
7196 for (i = 0; i < FREQ_COUNT; i++) { 7164 for (i = 0; i < FREQ_COUNT; i++) {
7197 // TODO: Include only legal frequencies for some countries 7165 // TODO: Include only legal frequencies for some countries
7198// if (local->channel_mask & (1 << i)) { 7166// if (local->channel_mask & (1 << i)) {
7199 range->freq[val].i = i + 1; 7167 range->freq[val].i = i + 1;
7200 range->freq[val].m = ipw2100_frequencies[i] * 100000; 7168 range->freq[val].m = ipw2100_frequencies[i] * 100000;
7201 range->freq[val].e = 1; 7169 range->freq[val].e = 1;
7202 val++; 7170 val++;
7203// } 7171// }
7204 if (val == IW_MAX_FREQUENCIES) 7172 if (val == IW_MAX_FREQUENCIES)
7205 break; 7173 break;
7206 } 7174 }
7207 range->num_frequency = val; 7175 range->num_frequency = val;
7208 7176
@@ -7257,7 +7225,7 @@ static int ipw2100_wx_set_wap(struct net_device *dev,
7257 wrqu->ap_addr.sa_data[4] & 0xff, 7225 wrqu->ap_addr.sa_data[4] & 0xff,
7258 wrqu->ap_addr.sa_data[5] & 0xff); 7226 wrqu->ap_addr.sa_data[5] & 0xff);
7259 7227
7260 done: 7228 done:
7261 up(&priv->action_sem); 7229 up(&priv->action_sem);
7262 return err; 7230 return err;
7263} 7231}
@@ -7274,10 +7242,9 @@ static int ipw2100_wx_get_wap(struct net_device *dev,
7274 7242
7275 /* If we are associated, trying to associate, or have a statically 7243 /* If we are associated, trying to associate, or have a statically
7276 * configured BSSID then return that; otherwise return ANY */ 7244 * configured BSSID then return that; otherwise return ANY */
7277 if (priv->config & CFG_STATIC_BSSID || 7245 if (priv->config & CFG_STATIC_BSSID || priv->status & STATUS_ASSOCIATED) {
7278 priv->status & STATUS_ASSOCIATED) {
7279 wrqu->ap_addr.sa_family = ARPHRD_ETHER; 7246 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
7280 memcpy(wrqu->ap_addr.sa_data, &priv->bssid, ETH_ALEN); 7247 memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN);
7281 } else 7248 } else
7282 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); 7249 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
7283 7250
@@ -7291,7 +7258,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
7291 union iwreq_data *wrqu, char *extra) 7258 union iwreq_data *wrqu, char *extra)
7292{ 7259{
7293 struct ipw2100_priv *priv = ieee80211_priv(dev); 7260 struct ipw2100_priv *priv = ieee80211_priv(dev);
7294 char *essid = ""; /* ANY */ 7261 char *essid = ""; /* ANY */
7295 int length = 0; 7262 int length = 0;
7296 int err = 0; 7263 int err = 0;
7297 7264
@@ -7331,7 +7298,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
7331 7298
7332 err = ipw2100_set_essid(priv, essid, length, 0); 7299 err = ipw2100_set_essid(priv, essid, length, 0);
7333 7300
7334 done: 7301 done:
7335 up(&priv->action_sem); 7302 up(&priv->action_sem);
7336 return err; 7303 return err;
7337} 7304}
@@ -7348,17 +7315,16 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
7348 7315
7349 /* If we are associated, trying to associate, or have a statically 7316 /* If we are associated, trying to associate, or have a statically
7350 * configured ESSID then return that; otherwise return ANY */ 7317 * configured ESSID then return that; otherwise return ANY */
7351 if (priv->config & CFG_STATIC_ESSID || 7318 if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
7352 priv->status & STATUS_ASSOCIATED) {
7353 IPW_DEBUG_WX("Getting essid: '%s'\n", 7319 IPW_DEBUG_WX("Getting essid: '%s'\n",
7354 escape_essid(priv->essid, priv->essid_len)); 7320 escape_essid(priv->essid, priv->essid_len));
7355 memcpy(extra, priv->essid, priv->essid_len); 7321 memcpy(extra, priv->essid, priv->essid_len);
7356 wrqu->essid.length = priv->essid_len; 7322 wrqu->essid.length = priv->essid_len;
7357 wrqu->essid.flags = 1; /* active */ 7323 wrqu->essid.flags = 1; /* active */
7358 } else { 7324 } else {
7359 IPW_DEBUG_WX("Getting essid: ANY\n"); 7325 IPW_DEBUG_WX("Getting essid: ANY\n");
7360 wrqu->essid.length = 0; 7326 wrqu->essid.length = 0;
7361 wrqu->essid.flags = 0; /* active */ 7327 wrqu->essid.flags = 0; /* active */
7362 } 7328 }
7363 7329
7364 return 0; 7330 return 0;
@@ -7377,9 +7343,9 @@ static int ipw2100_wx_set_nick(struct net_device *dev,
7377 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 7343 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
7378 return -E2BIG; 7344 return -E2BIG;
7379 7345
7380 wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick)); 7346 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
7381 memset(priv->nick, 0, sizeof(priv->nick)); 7347 memset(priv->nick, 0, sizeof(priv->nick));
7382 memcpy(priv->nick, extra, wrqu->data.length); 7348 memcpy(priv->nick, extra, wrqu->data.length);
7383 7349
7384 IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick); 7350 IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick);
7385 7351
@@ -7398,7 +7364,7 @@ static int ipw2100_wx_get_nick(struct net_device *dev,
7398 7364
7399 wrqu->data.length = strlen(priv->nick) + 1; 7365 wrqu->data.length = strlen(priv->nick) + 1;
7400 memcpy(extra, priv->nick, wrqu->data.length); 7366 memcpy(extra, priv->nick, wrqu->data.length);
7401 wrqu->data.flags = 1; /* active */ 7367 wrqu->data.flags = 1; /* active */
7402 7368
7403 IPW_DEBUG_WX("GET Nickname -> %s \n", extra); 7369 IPW_DEBUG_WX("GET Nickname -> %s \n", extra);
7404 7370
@@ -7440,12 +7406,11 @@ static int ipw2100_wx_set_rate(struct net_device *dev,
7440 err = ipw2100_set_tx_rates(priv, rate, 0); 7406 err = ipw2100_set_tx_rates(priv, rate, 0);
7441 7407
7442 IPW_DEBUG_WX("SET Rate -> %04X \n", rate); 7408 IPW_DEBUG_WX("SET Rate -> %04X \n", rate);
7443 done: 7409 done:
7444 up(&priv->action_sem); 7410 up(&priv->action_sem);
7445 return err; 7411 return err;
7446} 7412}
7447 7413
7448
7449static int ipw2100_wx_get_rate(struct net_device *dev, 7414static int ipw2100_wx_get_rate(struct net_device *dev,
7450 struct iw_request_info *info, 7415 struct iw_request_info *info,
7451 union iwreq_data *wrqu, char *extra) 7416 union iwreq_data *wrqu, char *extra)
@@ -7493,7 +7458,7 @@ static int ipw2100_wx_get_rate(struct net_device *dev,
7493 7458
7494 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 7459 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
7495 7460
7496 done: 7461 done:
7497 up(&priv->action_sem); 7462 up(&priv->action_sem);
7498 return err; 7463 return err;
7499} 7464}
@@ -7518,8 +7483,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev,
7518 if (wrqu->rts.disabled) 7483 if (wrqu->rts.disabled)
7519 value = priv->rts_threshold | RTS_DISABLED; 7484 value = priv->rts_threshold | RTS_DISABLED;
7520 else { 7485 else {
7521 if (wrqu->rts.value < 1 || 7486 if (wrqu->rts.value < 1 || wrqu->rts.value > 2304) {
7522 wrqu->rts.value > 2304) {
7523 err = -EINVAL; 7487 err = -EINVAL;
7524 goto done; 7488 goto done;
7525 } 7489 }
@@ -7529,7 +7493,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev,
7529 err = ipw2100_set_rts_threshold(priv, value); 7493 err = ipw2100_set_rts_threshold(priv, value);
7530 7494
7531 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value); 7495 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value);
7532 done: 7496 done:
7533 up(&priv->action_sem); 7497 up(&priv->action_sem);
7534 return err; 7498 return err;
7535} 7499}
@@ -7545,7 +7509,7 @@ static int ipw2100_wx_get_rts(struct net_device *dev,
7545 struct ipw2100_priv *priv = ieee80211_priv(dev); 7509 struct ipw2100_priv *priv = ieee80211_priv(dev);
7546 7510
7547 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED; 7511 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
7548 wrqu->rts.fixed = 1; /* no auto select */ 7512 wrqu->rts.fixed = 1; /* no auto select */
7549 7513
7550 /* If RTS is set to the default value, then it is disabled */ 7514 /* If RTS is set to the default value, then it is disabled */
7551 wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0; 7515 wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0;
@@ -7572,8 +7536,7 @@ static int ipw2100_wx_set_txpow(struct net_device *dev,
7572 wrqu->txpower.value > IPW_TX_POWER_MAX_DBM) 7536 wrqu->txpower.value > IPW_TX_POWER_MAX_DBM)
7573 return -EINVAL; 7537 return -EINVAL;
7574 7538
7575 value = (wrqu->txpower.value - IPW_TX_POWER_MIN_DBM) * 16 / 7539 value = wrqu->txpower.value;
7576 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
7577 } 7540 }
7578 7541
7579 down(&priv->action_sem); 7542 down(&priv->action_sem);
@@ -7586,7 +7549,7 @@ static int ipw2100_wx_set_txpow(struct net_device *dev,
7586 7549
7587 IPW_DEBUG_WX("SET TX Power -> %d \n", value); 7550 IPW_DEBUG_WX("SET TX Power -> %d \n", value);
7588 7551
7589 done: 7552 done:
7590 up(&priv->action_sem); 7553 up(&priv->action_sem);
7591 return err; 7554 return err;
7592} 7555}
@@ -7613,11 +7576,7 @@ static int ipw2100_wx_get_txpow(struct net_device *dev,
7613 } else { 7576 } else {
7614 wrqu->power.disabled = 0; 7577 wrqu->power.disabled = 0;
7615 wrqu->power.fixed = 1; 7578 wrqu->power.fixed = 1;
7616 wrqu->power.value = 7579 wrqu->power.value = priv->tx_power;
7617 (priv->tx_power *
7618 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM)) /
7619 (IPW_TX_POWER_MAX - IPW_TX_POWER_MIN) +
7620 IPW_TX_POWER_MIN_DBM;
7621 } 7580 }
7622 7581
7623 wrqu->power.flags = IW_TXPOW_DBM; 7582 wrqu->power.flags = IW_TXPOW_DBM;
@@ -7682,8 +7641,7 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7682 struct ipw2100_priv *priv = ieee80211_priv(dev); 7641 struct ipw2100_priv *priv = ieee80211_priv(dev);
7683 int err = 0; 7642 int err = 0;
7684 7643
7685 if (wrqu->retry.flags & IW_RETRY_LIFETIME || 7644 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled)
7686 wrqu->retry.disabled)
7687 return -EINVAL; 7645 return -EINVAL;
7688 7646
7689 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) 7647 if (!(wrqu->retry.flags & IW_RETRY_LIMIT))
@@ -7698,14 +7656,14 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7698 if (wrqu->retry.flags & IW_RETRY_MIN) { 7656 if (wrqu->retry.flags & IW_RETRY_MIN) {
7699 err = ipw2100_set_short_retry(priv, wrqu->retry.value); 7657 err = ipw2100_set_short_retry(priv, wrqu->retry.value);
7700 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n", 7658 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n",
7701 wrqu->retry.value); 7659 wrqu->retry.value);
7702 goto done; 7660 goto done;
7703 } 7661 }
7704 7662
7705 if (wrqu->retry.flags & IW_RETRY_MAX) { 7663 if (wrqu->retry.flags & IW_RETRY_MAX) {
7706 err = ipw2100_set_long_retry(priv, wrqu->retry.value); 7664 err = ipw2100_set_long_retry(priv, wrqu->retry.value);
7707 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n", 7665 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n",
7708 wrqu->retry.value); 7666 wrqu->retry.value);
7709 goto done; 7667 goto done;
7710 } 7668 }
7711 7669
@@ -7715,7 +7673,7 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7715 7673
7716 IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value); 7674 IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value);
7717 7675
7718 done: 7676 done:
7719 up(&priv->action_sem); 7677 up(&priv->action_sem);
7720 return err; 7678 return err;
7721} 7679}
@@ -7730,20 +7688,19 @@ static int ipw2100_wx_get_retry(struct net_device *dev,
7730 7688
7731 struct ipw2100_priv *priv = ieee80211_priv(dev); 7689 struct ipw2100_priv *priv = ieee80211_priv(dev);
7732 7690
7733 wrqu->retry.disabled = 0; /* can't be disabled */ 7691 wrqu->retry.disabled = 0; /* can't be disabled */
7734 7692
7735 if ((wrqu->retry.flags & IW_RETRY_TYPE) == 7693 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
7736 IW_RETRY_LIFETIME)
7737 return -EINVAL; 7694 return -EINVAL;
7738 7695
7739 if (wrqu->retry.flags & IW_RETRY_MAX) { 7696 if (wrqu->retry.flags & IW_RETRY_MAX) {
7740 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; 7697 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
7741 wrqu->retry.value = priv->long_retry_limit; 7698 wrqu->retry.value = priv->long_retry_limit;
7742 } else { 7699 } else {
7743 wrqu->retry.flags = 7700 wrqu->retry.flags =
7744 (priv->short_retry_limit != 7701 (priv->short_retry_limit !=
7745 priv->long_retry_limit) ? 7702 priv->long_retry_limit) ?
7746 IW_RETRY_LIMIT & IW_RETRY_MIN : IW_RETRY_LIMIT; 7703 IW_RETRY_LIMIT | IW_RETRY_MIN : IW_RETRY_LIMIT;
7747 7704
7748 wrqu->retry.value = priv->short_retry_limit; 7705 wrqu->retry.value = priv->short_retry_limit;
7749 } 7706 }
@@ -7767,15 +7724,14 @@ static int ipw2100_wx_set_scan(struct net_device *dev,
7767 } 7724 }
7768 7725
7769 IPW_DEBUG_WX("Initiating scan...\n"); 7726 IPW_DEBUG_WX("Initiating scan...\n");
7770 if (ipw2100_set_scan_options(priv) || 7727 if (ipw2100_set_scan_options(priv) || ipw2100_start_scan(priv)) {
7771 ipw2100_start_scan(priv)) {
7772 IPW_DEBUG_WX("Start scan failed.\n"); 7728 IPW_DEBUG_WX("Start scan failed.\n");
7773 7729
7774 /* TODO: Mark a scan as pending so when hardware initialized 7730 /* TODO: Mark a scan as pending so when hardware initialized
7775 * a scan starts */ 7731 * a scan starts */
7776 } 7732 }
7777 7733
7778 done: 7734 done:
7779 up(&priv->action_sem); 7735 up(&priv->action_sem);
7780 return err; 7736 return err;
7781} 7737}
@@ -7792,7 +7748,6 @@ static int ipw2100_wx_get_scan(struct net_device *dev,
7792 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra); 7748 return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
7793} 7749}
7794 7750
7795
7796/* 7751/*
7797 * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c 7752 * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c
7798 */ 7753 */
@@ -7821,8 +7776,8 @@ static int ipw2100_wx_get_encode(struct net_device *dev,
7821} 7776}
7822 7777
7823static int ipw2100_wx_set_power(struct net_device *dev, 7778static int ipw2100_wx_set_power(struct net_device *dev,
7824 struct iw_request_info *info, 7779 struct iw_request_info *info,
7825 union iwreq_data *wrqu, char *extra) 7780 union iwreq_data *wrqu, char *extra)
7826{ 7781{
7827 struct ipw2100_priv *priv = ieee80211_priv(dev); 7782 struct ipw2100_priv *priv = ieee80211_priv(dev);
7828 int err = 0; 7783 int err = 0;
@@ -7841,11 +7796,11 @@ static int ipw2100_wx_set_power(struct net_device *dev,
7841 } 7796 }
7842 7797
7843 switch (wrqu->power.flags & IW_POWER_MODE) { 7798 switch (wrqu->power.flags & IW_POWER_MODE) {
7844 case IW_POWER_ON: /* If not specified */ 7799 case IW_POWER_ON: /* If not specified */
7845 case IW_POWER_MODE: /* If set all mask */ 7800 case IW_POWER_MODE: /* If set all mask */
7846 case IW_POWER_ALL_R: /* If explicitely state all */ 7801 case IW_POWER_ALL_R: /* If explicitely state all */
7847 break; 7802 break;
7848 default: /* Otherwise we don't support it */ 7803 default: /* Otherwise we don't support it */
7849 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", 7804 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
7850 wrqu->power.flags); 7805 wrqu->power.flags);
7851 err = -EOPNOTSUPP; 7806 err = -EOPNOTSUPP;
@@ -7857,18 +7812,17 @@ static int ipw2100_wx_set_power(struct net_device *dev,
7857 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; 7812 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode;
7858 err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); 7813 err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
7859 7814
7860 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", 7815 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode);
7861 priv->power_mode);
7862 7816
7863 done: 7817 done:
7864 up(&priv->action_sem); 7818 up(&priv->action_sem);
7865 return err; 7819 return err;
7866 7820
7867} 7821}
7868 7822
7869static int ipw2100_wx_get_power(struct net_device *dev, 7823static int ipw2100_wx_get_power(struct net_device *dev,
7870 struct iw_request_info *info, 7824 struct iw_request_info *info,
7871 union iwreq_data *wrqu, char *extra) 7825 union iwreq_data *wrqu, char *extra)
7872{ 7826{
7873 /* 7827 /*
7874 * This can be called at any time. No action lock required 7828 * This can be called at any time. No action lock required
@@ -7876,9 +7830,9 @@ static int ipw2100_wx_get_power(struct net_device *dev,
7876 7830
7877 struct ipw2100_priv *priv = ieee80211_priv(dev); 7831 struct ipw2100_priv *priv = ieee80211_priv(dev);
7878 7832
7879 if (!(priv->power_mode & IPW_POWER_ENABLED)) { 7833 if (!(priv->power_mode & IPW_POWER_ENABLED))
7880 wrqu->power.disabled = 1; 7834 wrqu->power.disabled = 1;
7881 } else { 7835 else {
7882 wrqu->power.disabled = 0; 7836 wrqu->power.disabled = 0;
7883 wrqu->power.flags = 0; 7837 wrqu->power.flags = 0;
7884 } 7838 }
@@ -7888,6 +7842,269 @@ static int ipw2100_wx_get_power(struct net_device *dev,
7888 return 0; 7842 return 0;
7889} 7843}
7890 7844
7845#if WIRELESS_EXT > 17
7846/*
7847 * WE-18 WPA support
7848 */
7849
7850/* SIOCSIWGENIE */
7851static int ipw2100_wx_set_genie(struct net_device *dev,
7852 struct iw_request_info *info,
7853 union iwreq_data *wrqu, char *extra)
7854{
7855
7856 struct ipw2100_priv *priv = ieee80211_priv(dev);
7857 struct ieee80211_device *ieee = priv->ieee;
7858 u8 *buf;
7859
7860 if (!ieee->wpa_enabled)
7861 return -EOPNOTSUPP;
7862
7863 if (wrqu->data.length > MAX_WPA_IE_LEN ||
7864 (wrqu->data.length && extra == NULL))
7865 return -EINVAL;
7866
7867 if (wrqu->data.length) {
7868 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
7869 if (buf == NULL)
7870 return -ENOMEM;
7871
7872 memcpy(buf, extra, wrqu->data.length);
7873 kfree(ieee->wpa_ie);
7874 ieee->wpa_ie = buf;
7875 ieee->wpa_ie_len = wrqu->data.length;
7876 } else {
7877 kfree(ieee->wpa_ie);
7878 ieee->wpa_ie = NULL;
7879 ieee->wpa_ie_len = 0;
7880 }
7881
7882 ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len);
7883
7884 return 0;
7885}
7886
7887/* SIOCGIWGENIE */
7888static int ipw2100_wx_get_genie(struct net_device *dev,
7889 struct iw_request_info *info,
7890 union iwreq_data *wrqu, char *extra)
7891{
7892 struct ipw2100_priv *priv = ieee80211_priv(dev);
7893 struct ieee80211_device *ieee = priv->ieee;
7894
7895 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
7896 wrqu->data.length = 0;
7897 return 0;
7898 }
7899
7900 if (wrqu->data.length < ieee->wpa_ie_len)
7901 return -E2BIG;
7902
7903 wrqu->data.length = ieee->wpa_ie_len;
7904 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
7905
7906 return 0;
7907}
7908
7909/* SIOCSIWAUTH */
7910static int ipw2100_wx_set_auth(struct net_device *dev,
7911 struct iw_request_info *info,
7912 union iwreq_data *wrqu, char *extra)
7913{
7914 struct ipw2100_priv *priv = ieee80211_priv(dev);
7915 struct ieee80211_device *ieee = priv->ieee;
7916 struct iw_param *param = &wrqu->param;
7917 struct ieee80211_crypt_data *crypt;
7918 unsigned long flags;
7919 int ret = 0;
7920
7921 switch (param->flags & IW_AUTH_INDEX) {
7922 case IW_AUTH_WPA_VERSION:
7923 case IW_AUTH_CIPHER_PAIRWISE:
7924 case IW_AUTH_CIPHER_GROUP:
7925 case IW_AUTH_KEY_MGMT:
7926 /*
7927 * ipw2200 does not use these parameters
7928 */
7929 break;
7930
7931 case IW_AUTH_TKIP_COUNTERMEASURES:
7932 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
7933 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags)
7934 break;
7935
7936 flags = crypt->ops->get_flags(crypt->priv);
7937
7938 if (param->value)
7939 flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
7940 else
7941 flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES;
7942
7943 crypt->ops->set_flags(flags, crypt->priv);
7944
7945 break;
7946
7947 case IW_AUTH_DROP_UNENCRYPTED:{
7948 /* HACK:
7949 *
7950 * wpa_supplicant calls set_wpa_enabled when the driver
7951 * is loaded and unloaded, regardless of if WPA is being
7952 * used. No other calls are made which can be used to
7953 * determine if encryption will be used or not prior to
7954 * association being expected. If encryption is not being
7955 * used, drop_unencrypted is set to false, else true -- we
7956 * can use this to determine if the CAP_PRIVACY_ON bit should
7957 * be set.
7958 */
7959 struct ieee80211_security sec = {
7960 .flags = SEC_ENABLED,
7961 .enabled = param->value,
7962 };
7963 priv->ieee->drop_unencrypted = param->value;
7964 /* We only change SEC_LEVEL for open mode. Others
7965 * are set by ipw_wpa_set_encryption.
7966 */
7967 if (!param->value) {
7968 sec.flags |= SEC_LEVEL;
7969 sec.level = SEC_LEVEL_0;
7970 } else {
7971 sec.flags |= SEC_LEVEL;
7972 sec.level = SEC_LEVEL_1;
7973 }
7974 if (priv->ieee->set_security)
7975 priv->ieee->set_security(priv->ieee->dev, &sec);
7976 break;
7977 }
7978
7979 case IW_AUTH_80211_AUTH_ALG:
7980 ret = ipw2100_wpa_set_auth_algs(priv, param->value);
7981 break;
7982
7983 case IW_AUTH_WPA_ENABLED:
7984 ret = ipw2100_wpa_enable(priv, param->value);
7985 break;
7986
7987 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
7988 ieee->ieee802_1x = param->value;
7989 break;
7990
7991 //case IW_AUTH_ROAMING_CONTROL:
7992 case IW_AUTH_PRIVACY_INVOKED:
7993 ieee->privacy_invoked = param->value;
7994 break;
7995
7996 default:
7997 return -EOPNOTSUPP;
7998 }
7999 return ret;
8000}
8001
8002/* SIOCGIWAUTH */
8003static int ipw2100_wx_get_auth(struct net_device *dev,
8004 struct iw_request_info *info,
8005 union iwreq_data *wrqu, char *extra)
8006{
8007 struct ipw2100_priv *priv = ieee80211_priv(dev);
8008 struct ieee80211_device *ieee = priv->ieee;
8009 struct ieee80211_crypt_data *crypt;
8010 struct iw_param *param = &wrqu->param;
8011 int ret = 0;
8012
8013 switch (param->flags & IW_AUTH_INDEX) {
8014 case IW_AUTH_WPA_VERSION:
8015 case IW_AUTH_CIPHER_PAIRWISE:
8016 case IW_AUTH_CIPHER_GROUP:
8017 case IW_AUTH_KEY_MGMT:
8018 /*
8019 * wpa_supplicant will control these internally
8020 */
8021 ret = -EOPNOTSUPP;
8022 break;
8023
8024 case IW_AUTH_TKIP_COUNTERMEASURES:
8025 crypt = priv->ieee->crypt[priv->ieee->tx_keyidx];
8026 if (!crypt || !crypt->ops->get_flags) {
8027 IPW_DEBUG_WARNING("Can't get TKIP countermeasures: "
8028 "crypt not set!\n");
8029 break;
8030 }
8031
8032 param->value = (crypt->ops->get_flags(crypt->priv) &
8033 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) ? 1 : 0;
8034
8035 break;
8036
8037 case IW_AUTH_DROP_UNENCRYPTED:
8038 param->value = ieee->drop_unencrypted;
8039 break;
8040
8041 case IW_AUTH_80211_AUTH_ALG:
8042 param->value = priv->ieee->sec.auth_mode;
8043 break;
8044
8045 case IW_AUTH_WPA_ENABLED:
8046 param->value = ieee->wpa_enabled;
8047 break;
8048
8049 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
8050 param->value = ieee->ieee802_1x;
8051 break;
8052
8053 case IW_AUTH_ROAMING_CONTROL:
8054 case IW_AUTH_PRIVACY_INVOKED:
8055 param->value = ieee->privacy_invoked;
8056 break;
8057
8058 default:
8059 return -EOPNOTSUPP;
8060 }
8061 return 0;
8062}
8063
8064/* SIOCSIWENCODEEXT */
8065static int ipw2100_wx_set_encodeext(struct net_device *dev,
8066 struct iw_request_info *info,
8067 union iwreq_data *wrqu, char *extra)
8068{
8069 struct ipw2100_priv *priv = ieee80211_priv(dev);
8070 return ieee80211_wx_set_encodeext(priv->ieee, info, wrqu, extra);
8071}
8072
8073/* SIOCGIWENCODEEXT */
8074static int ipw2100_wx_get_encodeext(struct net_device *dev,
8075 struct iw_request_info *info,
8076 union iwreq_data *wrqu, char *extra)
8077{
8078 struct ipw2100_priv *priv = ieee80211_priv(dev);
8079 return ieee80211_wx_get_encodeext(priv->ieee, info, wrqu, extra);
8080}
8081
8082/* SIOCSIWMLME */
8083static int ipw2100_wx_set_mlme(struct net_device *dev,
8084 struct iw_request_info *info,
8085 union iwreq_data *wrqu, char *extra)
8086{
8087 struct ipw2100_priv *priv = ieee80211_priv(dev);
8088 struct iw_mlme *mlme = (struct iw_mlme *)extra;
8089 u16 reason;
8090
8091 reason = cpu_to_le16(mlme->reason_code);
8092
8093 switch (mlme->cmd) {
8094 case IW_MLME_DEAUTH:
8095 // silently ignore
8096 break;
8097
8098 case IW_MLME_DISASSOC:
8099 ipw2100_disassociate_bssid(priv);
8100 break;
8101
8102 default:
8103 return -EOPNOTSUPP;
8104 }
8105 return 0;
8106}
8107#endif /* WIRELESS_EXT > 17 */
7891 8108
7892/* 8109/*
7893 * 8110 *
@@ -7921,7 +8138,7 @@ static int ipw2100_wx_set_promisc(struct net_device *dev,
7921 if (priv->ieee->iw_mode == IW_MODE_MONITOR) 8138 if (priv->ieee->iw_mode == IW_MODE_MONITOR)
7922 err = ipw2100_switch_mode(priv, priv->last_mode); 8139 err = ipw2100_switch_mode(priv, priv->last_mode);
7923 } 8140 }
7924 done: 8141 done:
7925 up(&priv->action_sem); 8142 up(&priv->action_sem);
7926 return err; 8143 return err;
7927} 8144}
@@ -7956,7 +8173,7 @@ static int ipw2100_wx_set_powermode(struct net_device *dev,
7956 8173
7957 if (priv->power_mode != mode) 8174 if (priv->power_mode != mode)
7958 err = ipw2100_set_power_mode(priv, mode); 8175 err = ipw2100_set_power_mode(priv, mode);
7959 done: 8176 done:
7960 up(&priv->action_sem); 8177 up(&priv->action_sem);
7961 return err; 8178 return err;
7962} 8179}
@@ -7984,8 +8201,8 @@ static int ipw2100_wx_get_powermode(struct net_device *dev,
7984 "Power save level: %d (None)", level); 8201 "Power save level: %d (None)", level);
7985 break; 8202 break;
7986 case IPW_POWER_AUTO: 8203 case IPW_POWER_AUTO:
7987 snprintf(extra, MAX_POWER_STRING, 8204 snprintf(extra, MAX_POWER_STRING,
7988 "Power save level: %d (Auto)", 0); 8205 "Power save level: %d (Auto)", 0);
7989 break; 8206 break;
7990 default: 8207 default:
7991 timeout = timeout_duration[level - 1] / 1000; 8208 timeout = timeout_duration[level - 1] / 1000;
@@ -8002,7 +8219,6 @@ static int ipw2100_wx_get_powermode(struct net_device *dev,
8002 return 0; 8219 return 0;
8003} 8220}
8004 8221
8005
8006static int ipw2100_wx_set_preamble(struct net_device *dev, 8222static int ipw2100_wx_set_preamble(struct net_device *dev,
8007 struct iw_request_info *info, 8223 struct iw_request_info *info,
8008 union iwreq_data *wrqu, char *extra) 8224 union iwreq_data *wrqu, char *extra)
@@ -8027,14 +8243,14 @@ static int ipw2100_wx_set_preamble(struct net_device *dev,
8027 8243
8028 err = ipw2100_system_config(priv, 0); 8244 err = ipw2100_system_config(priv, 0);
8029 8245
8030done: 8246 done:
8031 up(&priv->action_sem); 8247 up(&priv->action_sem);
8032 return err; 8248 return err;
8033} 8249}
8034 8250
8035static int ipw2100_wx_get_preamble(struct net_device *dev, 8251static int ipw2100_wx_get_preamble(struct net_device *dev,
8036 struct iw_request_info *info, 8252 struct iw_request_info *info,
8037 union iwreq_data *wrqu, char *extra) 8253 union iwreq_data *wrqu, char *extra)
8038{ 8254{
8039 /* 8255 /*
8040 * This can be called at any time. No action lock required 8256 * This can be called at any time. No action lock required
@@ -8050,54 +8266,116 @@ static int ipw2100_wx_get_preamble(struct net_device *dev,
8050 return 0; 8266 return 0;
8051} 8267}
8052 8268
8053static iw_handler ipw2100_wx_handlers[] = 8269#ifdef CONFIG_IPW2100_MONITOR
8054{ 8270static int ipw2100_wx_set_crc_check(struct net_device *dev,
8055 NULL, /* SIOCSIWCOMMIT */ 8271 struct iw_request_info *info,
8056 ipw2100_wx_get_name, /* SIOCGIWNAME */ 8272 union iwreq_data *wrqu, char *extra)
8057 NULL, /* SIOCSIWNWID */ 8273{
8058 NULL, /* SIOCGIWNWID */ 8274 struct ipw2100_priv *priv = ieee80211_priv(dev);
8059 ipw2100_wx_set_freq, /* SIOCSIWFREQ */ 8275 int err, mode = *(int *)extra;
8060 ipw2100_wx_get_freq, /* SIOCGIWFREQ */ 8276
8061 ipw2100_wx_set_mode, /* SIOCSIWMODE */ 8277 down(&priv->action_sem);
8062 ipw2100_wx_get_mode, /* SIOCGIWMODE */ 8278 if (!(priv->status & STATUS_INITIALIZED)) {
8063 NULL, /* SIOCSIWSENS */ 8279 err = -EIO;
8064 NULL, /* SIOCGIWSENS */ 8280 goto done;
8065 NULL, /* SIOCSIWRANGE */ 8281 }
8066 ipw2100_wx_get_range, /* SIOCGIWRANGE */ 8282
8067 NULL, /* SIOCSIWPRIV */ 8283 if (mode == 1)
8068 NULL, /* SIOCGIWPRIV */ 8284 priv->config |= CFG_CRC_CHECK;
8069 NULL, /* SIOCSIWSTATS */ 8285 else if (mode == 0)
8070 NULL, /* SIOCGIWSTATS */ 8286 priv->config &= ~CFG_CRC_CHECK;
8071 NULL, /* SIOCSIWSPY */ 8287 else {
8072 NULL, /* SIOCGIWSPY */ 8288 err = -EINVAL;
8073 NULL, /* SIOCGIWTHRSPY */ 8289 goto done;
8074 NULL, /* SIOCWIWTHRSPY */ 8290 }
8075 ipw2100_wx_set_wap, /* SIOCSIWAP */ 8291 err = 0;
8076 ipw2100_wx_get_wap, /* SIOCGIWAP */ 8292
8077 NULL, /* -- hole -- */ 8293 done:
8078 NULL, /* SIOCGIWAPLIST -- deprecated */ 8294 up(&priv->action_sem);
8079 ipw2100_wx_set_scan, /* SIOCSIWSCAN */ 8295 return err;
8080 ipw2100_wx_get_scan, /* SIOCGIWSCAN */ 8296}
8081 ipw2100_wx_set_essid, /* SIOCSIWESSID */ 8297
8082 ipw2100_wx_get_essid, /* SIOCGIWESSID */ 8298static int ipw2100_wx_get_crc_check(struct net_device *dev,
8083 ipw2100_wx_set_nick, /* SIOCSIWNICKN */ 8299 struct iw_request_info *info,
8084 ipw2100_wx_get_nick, /* SIOCGIWNICKN */ 8300 union iwreq_data *wrqu, char *extra)
8085 NULL, /* -- hole -- */ 8301{
8086 NULL, /* -- hole -- */ 8302 /*
8087 ipw2100_wx_set_rate, /* SIOCSIWRATE */ 8303 * This can be called at any time. No action lock required
8088 ipw2100_wx_get_rate, /* SIOCGIWRATE */ 8304 */
8089 ipw2100_wx_set_rts, /* SIOCSIWRTS */ 8305
8090 ipw2100_wx_get_rts, /* SIOCGIWRTS */ 8306 struct ipw2100_priv *priv = ieee80211_priv(dev);
8091 ipw2100_wx_set_frag, /* SIOCSIWFRAG */ 8307
8092 ipw2100_wx_get_frag, /* SIOCGIWFRAG */ 8308 if (priv->config & CFG_CRC_CHECK)
8093 ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */ 8309 snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)");
8094 ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */ 8310 else
8095 ipw2100_wx_set_retry, /* SIOCSIWRETRY */ 8311 snprintf(wrqu->name, IFNAMSIZ, "CRC ignored (0)");
8096 ipw2100_wx_get_retry, /* SIOCGIWRETRY */ 8312
8097 ipw2100_wx_set_encode, /* SIOCSIWENCODE */ 8313 return 0;
8098 ipw2100_wx_get_encode, /* SIOCGIWENCODE */ 8314}
8099 ipw2100_wx_set_power, /* SIOCSIWPOWER */ 8315#endif /* CONFIG_IPW2100_MONITOR */
8100 ipw2100_wx_get_power, /* SIOCGIWPOWER */ 8316
8317static iw_handler ipw2100_wx_handlers[] = {
8318 NULL, /* SIOCSIWCOMMIT */
8319 ipw2100_wx_get_name, /* SIOCGIWNAME */
8320 NULL, /* SIOCSIWNWID */
8321 NULL, /* SIOCGIWNWID */
8322 ipw2100_wx_set_freq, /* SIOCSIWFREQ */
8323 ipw2100_wx_get_freq, /* SIOCGIWFREQ */
8324 ipw2100_wx_set_mode, /* SIOCSIWMODE */
8325 ipw2100_wx_get_mode, /* SIOCGIWMODE */
8326 NULL, /* SIOCSIWSENS */
8327 NULL, /* SIOCGIWSENS */
8328 NULL, /* SIOCSIWRANGE */
8329 ipw2100_wx_get_range, /* SIOCGIWRANGE */
8330 NULL, /* SIOCSIWPRIV */
8331 NULL, /* SIOCGIWPRIV */
8332 NULL, /* SIOCSIWSTATS */
8333 NULL, /* SIOCGIWSTATS */
8334 NULL, /* SIOCSIWSPY */
8335 NULL, /* SIOCGIWSPY */
8336 NULL, /* SIOCGIWTHRSPY */
8337 NULL, /* SIOCWIWTHRSPY */
8338 ipw2100_wx_set_wap, /* SIOCSIWAP */
8339 ipw2100_wx_get_wap, /* SIOCGIWAP */
8340#if WIRELESS_EXT > 17
8341 ipw2100_wx_set_mlme, /* SIOCSIWMLME */
8342#else
8343 NULL, /* -- hole -- */
8344#endif
8345 NULL, /* SIOCGIWAPLIST -- deprecated */
8346 ipw2100_wx_set_scan, /* SIOCSIWSCAN */
8347 ipw2100_wx_get_scan, /* SIOCGIWSCAN */
8348 ipw2100_wx_set_essid, /* SIOCSIWESSID */
8349 ipw2100_wx_get_essid, /* SIOCGIWESSID */
8350 ipw2100_wx_set_nick, /* SIOCSIWNICKN */
8351 ipw2100_wx_get_nick, /* SIOCGIWNICKN */
8352 NULL, /* -- hole -- */
8353 NULL, /* -- hole -- */
8354 ipw2100_wx_set_rate, /* SIOCSIWRATE */
8355 ipw2100_wx_get_rate, /* SIOCGIWRATE */
8356 ipw2100_wx_set_rts, /* SIOCSIWRTS */
8357 ipw2100_wx_get_rts, /* SIOCGIWRTS */
8358 ipw2100_wx_set_frag, /* SIOCSIWFRAG */
8359 ipw2100_wx_get_frag, /* SIOCGIWFRAG */
8360 ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */
8361 ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */
8362 ipw2100_wx_set_retry, /* SIOCSIWRETRY */
8363 ipw2100_wx_get_retry, /* SIOCGIWRETRY */
8364 ipw2100_wx_set_encode, /* SIOCSIWENCODE */
8365 ipw2100_wx_get_encode, /* SIOCGIWENCODE */
8366 ipw2100_wx_set_power, /* SIOCSIWPOWER */
8367 ipw2100_wx_get_power, /* SIOCGIWPOWER */
8368#if WIRELESS_EXT > 17
8369 NULL, /* -- hole -- */
8370 NULL, /* -- hole -- */
8371 ipw2100_wx_set_genie, /* SIOCSIWGENIE */
8372 ipw2100_wx_get_genie, /* SIOCGIWGENIE */
8373 ipw2100_wx_set_auth, /* SIOCSIWAUTH */
8374 ipw2100_wx_get_auth, /* SIOCGIWAUTH */
8375 ipw2100_wx_set_encodeext, /* SIOCSIWENCODEEXT */
8376 ipw2100_wx_get_encodeext, /* SIOCGIWENCODEEXT */
8377 NULL, /* SIOCSIWPMKSA */
8378#endif
8101}; 8379};
8102 8380
8103#define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV 8381#define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV
@@ -8106,60 +8384,71 @@ static iw_handler ipw2100_wx_handlers[] =
8106#define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3 8384#define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3
8107#define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4 8385#define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4
8108#define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5 8386#define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5
8387#define IPW2100_PRIV_SET_CRC_CHECK SIOCIWFIRSTPRIV+6
8388#define IPW2100_PRIV_GET_CRC_CHECK SIOCIWFIRSTPRIV+7
8109 8389
8110static const struct iw_priv_args ipw2100_private_args[] = { 8390static const struct iw_priv_args ipw2100_private_args[] = {
8111 8391
8112#ifdef CONFIG_IPW2100_MONITOR 8392#ifdef CONFIG_IPW2100_MONITOR
8113 { 8393 {
8114 IPW2100_PRIV_SET_MONITOR, 8394 IPW2100_PRIV_SET_MONITOR,
8115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" 8395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"},
8116 },
8117 { 8396 {
8118 IPW2100_PRIV_RESET, 8397 IPW2100_PRIV_RESET,
8119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" 8398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"},
8120 }, 8399#endif /* CONFIG_IPW2100_MONITOR */
8121#endif /* CONFIG_IPW2100_MONITOR */
8122 8400
8123 { 8401 {
8124 IPW2100_PRIV_SET_POWER, 8402 IPW2100_PRIV_SET_POWER,
8125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power" 8403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power"},
8126 },
8127 { 8404 {
8128 IPW2100_PRIV_GET_POWER, 8405 IPW2100_PRIV_GET_POWER,
8129 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING, "get_power" 8406 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING,
8130 }, 8407 "get_power"},
8131 { 8408 {
8132 IPW2100_PRIV_SET_LONGPREAMBLE, 8409 IPW2100_PRIV_SET_LONGPREAMBLE,
8133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble" 8410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"},
8134 },
8135 { 8411 {
8136 IPW2100_PRIV_GET_LONGPREAMBLE, 8412 IPW2100_PRIV_GET_LONGPREAMBLE,
8137 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble" 8413 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble"},
8138 }, 8414#ifdef CONFIG_IPW2100_MONITOR
8415 {
8416 IPW2100_PRIV_SET_CRC_CHECK,
8417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_crc_check"},
8418 {
8419 IPW2100_PRIV_GET_CRC_CHECK,
8420 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_crc_check"},
8421#endif /* CONFIG_IPW2100_MONITOR */
8139}; 8422};
8140 8423
8141static iw_handler ipw2100_private_handler[] = { 8424static iw_handler ipw2100_private_handler[] = {
8142#ifdef CONFIG_IPW2100_MONITOR 8425#ifdef CONFIG_IPW2100_MONITOR
8143 ipw2100_wx_set_promisc, 8426 ipw2100_wx_set_promisc,
8144 ipw2100_wx_reset, 8427 ipw2100_wx_reset,
8145#else /* CONFIG_IPW2100_MONITOR */ 8428#else /* CONFIG_IPW2100_MONITOR */
8146 NULL, 8429 NULL,
8147 NULL, 8430 NULL,
8148#endif /* CONFIG_IPW2100_MONITOR */ 8431#endif /* CONFIG_IPW2100_MONITOR */
8149 ipw2100_wx_set_powermode, 8432 ipw2100_wx_set_powermode,
8150 ipw2100_wx_get_powermode, 8433 ipw2100_wx_get_powermode,
8151 ipw2100_wx_set_preamble, 8434 ipw2100_wx_set_preamble,
8152 ipw2100_wx_get_preamble, 8435 ipw2100_wx_get_preamble,
8436#ifdef CONFIG_IPW2100_MONITOR
8437 ipw2100_wx_set_crc_check,
8438 ipw2100_wx_get_crc_check,
8439#else /* CONFIG_IPW2100_MONITOR */
8440 NULL,
8441 NULL,
8442#endif /* CONFIG_IPW2100_MONITOR */
8153}; 8443};
8154 8444
8155static struct iw_handler_def ipw2100_wx_handler_def = 8445static struct iw_handler_def ipw2100_wx_handler_def = {
8156{
8157 .standard = ipw2100_wx_handlers, 8446 .standard = ipw2100_wx_handlers,
8158 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler), 8447 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8159 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler), 8448 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8160 .num_private_args = sizeof(ipw2100_private_args) / 8449 .num_private_args = sizeof(ipw2100_private_args) /
8161 sizeof(struct iw_priv_args), 8450 sizeof(struct iw_priv_args),
8162 .private = (iw_handler *)ipw2100_private_handler, 8451 .private = (iw_handler *) ipw2100_private_handler,
8163 .private_args = (struct iw_priv_args *)ipw2100_private_args, 8452 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8164}; 8453};
8165 8454
@@ -8168,7 +8457,7 @@ static struct iw_handler_def ipw2100_wx_handler_def =
8168 * Called by /proc/net/wireless 8457 * Called by /proc/net/wireless
8169 * Also called by SIOCGIWSTATS 8458 * Also called by SIOCGIWSTATS
8170 */ 8459 */
8171static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) 8460static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8172{ 8461{
8173 enum { 8462 enum {
8174 POOR = 30, 8463 POOR = 30,
@@ -8188,7 +8477,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8188 u32 ord_len = sizeof(u32); 8477 u32 ord_len = sizeof(u32);
8189 8478
8190 if (!priv) 8479 if (!priv)
8191 return (struct iw_statistics *) NULL; 8480 return (struct iw_statistics *)NULL;
8192 8481
8193 wstats = &priv->wstats; 8482 wstats = &priv->wstats;
8194 8483
@@ -8205,7 +8494,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8205 wstats->qual.noise = 0; 8494 wstats->qual.noise = 0;
8206 wstats->qual.updated = 7; 8495 wstats->qual.updated = 7;
8207 wstats->qual.updated |= IW_QUAL_NOISE_INVALID | 8496 wstats->qual.updated |= IW_QUAL_NOISE_INVALID |
8208 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; 8497 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
8209 return wstats; 8498 return wstats;
8210 } 8499 }
8211 8500
@@ -8213,7 +8502,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8213 &missed_beacons, &ord_len)) 8502 &missed_beacons, &ord_len))
8214 goto fail_get_ordinal; 8503 goto fail_get_ordinal;
8215 8504
8216 /* If we don't have a connection the quality and level is 0*/ 8505 /* If we don't have a connection the quality and level is 0 */
8217 if (!(priv->status & STATUS_ASSOCIATED)) { 8506 if (!(priv->status & STATUS_ASSOCIATED)) {
8218 wstats->qual.qual = 0; 8507 wstats->qual.qual = 0;
8219 wstats->qual.level = 0; 8508 wstats->qual.level = 0;
@@ -8230,10 +8519,10 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8230 rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR; 8519 rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR;
8231 else if (rssi < 30) 8520 else if (rssi < 30)
8232 rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) / 8521 rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) /
8233 10 + GOOD; 8522 10 + GOOD;
8234 else 8523 else
8235 rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) / 8524 rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) /
8236 10 + VERY_GOOD; 8525 10 + VERY_GOOD;
8237 8526
8238 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES, 8527 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES,
8239 &tx_retries, &ord_len)) 8528 &tx_retries, &ord_len))
@@ -8247,25 +8536,25 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8247 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; 8536 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
8248 else if (tx_retries > 50) 8537 else if (tx_retries > 50)
8249 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / 8538 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
8250 15 + GOOD; 8539 15 + GOOD;
8251 else 8540 else
8252 tx_qual = (50 - tx_retries) * 8541 tx_qual = (50 - tx_retries) *
8253 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; 8542 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
8254 8543
8255 if (missed_beacons > 50) 8544 if (missed_beacons > 50)
8256 beacon_qual = (60 - missed_beacons) * POOR / 10; 8545 beacon_qual = (60 - missed_beacons) * POOR / 10;
8257 else if (missed_beacons > 40) 8546 else if (missed_beacons > 40)
8258 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) / 8547 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) /
8259 10 + POOR; 8548 10 + POOR;
8260 else if (missed_beacons > 32) 8549 else if (missed_beacons > 32)
8261 beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) / 8550 beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) /
8262 18 + FAIR; 8551 18 + FAIR;
8263 else if (missed_beacons > 20) 8552 else if (missed_beacons > 20)
8264 beacon_qual = (32 - missed_beacons) * 8553 beacon_qual = (32 - missed_beacons) *
8265 (VERY_GOOD - GOOD) / 20 + GOOD; 8554 (VERY_GOOD - GOOD) / 20 + GOOD;
8266 else 8555 else
8267 beacon_qual = (20 - missed_beacons) * 8556 beacon_qual = (20 - missed_beacons) *
8268 (PERFECT - VERY_GOOD) / 20 + VERY_GOOD; 8557 (PERFECT - VERY_GOOD) / 20 + VERY_GOOD;
8269 8558
8270 quality = min(beacon_qual, min(tx_qual, rssi_qual)); 8559 quality = min(beacon_qual, min(tx_qual, rssi_qual));
8271 8560
@@ -8288,7 +8577,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8288 wstats->qual.updated = 7; 8577 wstats->qual.updated = 7;
8289 wstats->qual.updated |= IW_QUAL_NOISE_INVALID; 8578 wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
8290 8579
8291 /* FIXME: this is percent and not a # */ 8580 /* FIXME: this is percent and not a # */
8292 wstats->miss.beacon = missed_beacons; 8581 wstats->miss.beacon = missed_beacons;
8293 8582
8294 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES, 8583 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES,
@@ -8298,10 +8587,10 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev)
8298 8587
8299 return wstats; 8588 return wstats;
8300 8589
8301 fail_get_ordinal: 8590 fail_get_ordinal:
8302 IPW_DEBUG_WX("failed querying ordinals.\n"); 8591 IPW_DEBUG_WX("failed querying ordinals.\n");
8303 8592
8304 return (struct iw_statistics *) NULL; 8593 return (struct iw_statistics *)NULL;
8305} 8594}
8306 8595
8307static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8596static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
@@ -8324,23 +8613,17 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8324 if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) || 8613 if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) ||
8325 priv->status & STATUS_RF_KILL_MASK || 8614 priv->status & STATUS_RF_KILL_MASK ||
8326 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, 8615 ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID,
8327 &priv->bssid, &len)) { 8616 &priv->bssid, &len)) {
8328 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); 8617 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
8329 } else { 8618 } else {
8330 /* We now have the BSSID, so can finish setting to the full 8619 /* We now have the BSSID, so can finish setting to the full
8331 * associated state */ 8620 * associated state */
8332 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN); 8621 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN);
8333 memcpy(&priv->ieee->bssid, priv->bssid, ETH_ALEN); 8622 memcpy(priv->ieee->bssid, priv->bssid, ETH_ALEN);
8334 priv->status &= ~STATUS_ASSOCIATING; 8623 priv->status &= ~STATUS_ASSOCIATING;
8335 priv->status |= STATUS_ASSOCIATED; 8624 priv->status |= STATUS_ASSOCIATED;
8336 netif_carrier_on(priv->net_dev); 8625 netif_carrier_on(priv->net_dev);
8337 if (netif_queue_stopped(priv->net_dev)) { 8626 netif_wake_queue(priv->net_dev);
8338 IPW_DEBUG_INFO("Waking net queue.\n");
8339 netif_wake_queue(priv->net_dev);
8340 } else {
8341 IPW_DEBUG_INFO("Starting net queue.\n");
8342 netif_start_queue(priv->net_dev);
8343 }
8344 } 8627 }
8345 8628
8346 if (!(priv->status & STATUS_ASSOCIATED)) { 8629 if (!(priv->status & STATUS_ASSOCIATED)) {
@@ -8349,7 +8632,8 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8349 /* This is a disassociation event, so kick the firmware to 8632 /* This is a disassociation event, so kick the firmware to
8350 * look for another AP */ 8633 * look for another AP */
8351 if (priv->config & CFG_STATIC_ESSID) 8634 if (priv->config & CFG_STATIC_ESSID)
8352 ipw2100_set_essid(priv, priv->essid, priv->essid_len, 0); 8635 ipw2100_set_essid(priv, priv->essid, priv->essid_len,
8636 0);
8353 else 8637 else
8354 ipw2100_set_essid(priv, NULL, 0, 0); 8638 ipw2100_set_essid(priv, NULL, 0, 0);
8355 up(&priv->action_sem); 8639 up(&priv->action_sem);
@@ -8372,7 +8656,6 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8372 8656
8373#define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw" 8657#define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw"
8374 8658
8375
8376/* 8659/*
8377 8660
8378BINARY FIRMWARE HEADER FORMAT 8661BINARY FIRMWARE HEADER FORMAT
@@ -8394,12 +8677,10 @@ struct ipw2100_fw_header {
8394 unsigned int uc_size; 8677 unsigned int uc_size;
8395} __attribute__ ((packed)); 8678} __attribute__ ((packed));
8396 8679
8397
8398
8399static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw) 8680static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw)
8400{ 8681{
8401 struct ipw2100_fw_header *h = 8682 struct ipw2100_fw_header *h =
8402 (struct ipw2100_fw_header *)fw->fw_entry->data; 8683 (struct ipw2100_fw_header *)fw->fw_entry->data;
8403 8684
8404 if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) { 8685 if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) {
8405 printk(KERN_WARNING DRV_NAME ": Firmware image not compatible " 8686 printk(KERN_WARNING DRV_NAME ": Firmware image not compatible "
@@ -8418,7 +8699,6 @@ static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw)
8418 return 0; 8699 return 0;
8419} 8700}
8420 8701
8421
8422static int ipw2100_get_firmware(struct ipw2100_priv *priv, 8702static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8423 struct ipw2100_fw *fw) 8703 struct ipw2100_fw *fw)
8424{ 8704{
@@ -8426,7 +8706,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8426 int rc; 8706 int rc;
8427 8707
8428 IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n", 8708 IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n",
8429 priv->net_dev->name); 8709 priv->net_dev->name);
8430 8710
8431 switch (priv->ieee->iw_mode) { 8711 switch (priv->ieee->iw_mode) {
8432 case IW_MODE_ADHOC: 8712 case IW_MODE_ADHOC:
@@ -8452,7 +8732,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv,
8452 return rc; 8732 return rc;
8453 } 8733 }
8454 IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data, 8734 IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data,
8455 fw->fw_entry->size); 8735 fw->fw_entry->size);
8456 8736
8457 ipw2100_mod_firmware_load(fw); 8737 ipw2100_mod_firmware_load(fw);
8458 8738
@@ -8468,7 +8748,6 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
8468 fw->fw_entry = NULL; 8748 fw->fw_entry = NULL;
8469} 8749}
8470 8750
8471
8472static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf, 8751static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
8473 size_t max) 8752 size_t max)
8474{ 8753{
@@ -8477,8 +8756,7 @@ static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
8477 u32 tmp; 8756 u32 tmp;
8478 int i; 8757 int i;
8479 /* firmware version is an ascii string (max len of 14) */ 8758 /* firmware version is an ascii string (max len of 14) */
8480 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, 8759 if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, ver, &len))
8481 ver, &len))
8482 return -EIO; 8760 return -EIO;
8483 tmp = max; 8761 tmp = max;
8484 if (len >= max) 8762 if (len >= max)
@@ -8495,8 +8773,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
8495 u32 ver; 8773 u32 ver;
8496 u32 len = sizeof(ver); 8774 u32 len = sizeof(ver);
8497 /* microcode version is a 32 bit integer */ 8775 /* microcode version is a 32 bit integer */
8498 if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, 8776 if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, &ver, &len))
8499 &ver, &len))
8500 return -EIO; 8777 return -EIO;
8501 return snprintf(buf, max, "%08X", ver); 8778 return snprintf(buf, max, "%08X", ver);
8502} 8779}
@@ -8504,8 +8781,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
8504/* 8781/*
8505 * On exit, the firmware will have been freed from the fw list 8782 * On exit, the firmware will have been freed from the fw list
8506 */ 8783 */
8507static int ipw2100_fw_download(struct ipw2100_priv *priv, 8784static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
8508 struct ipw2100_fw *fw)
8509{ 8785{
8510 /* firmware is constructed of N contiguous entries, each entry is 8786 /* firmware is constructed of N contiguous entries, each entry is
8511 * structured as: 8787 * structured as:
@@ -8513,7 +8789,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8513 * offset sie desc 8789 * offset sie desc
8514 * 0 4 address to write to 8790 * 0 4 address to write to
8515 * 4 2 length of data run 8791 * 4 2 length of data run
8516 * 6 length data 8792 * 6 length data
8517 */ 8793 */
8518 unsigned int addr; 8794 unsigned int addr;
8519 unsigned short len; 8795 unsigned short len;
@@ -8522,12 +8798,12 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8522 unsigned int firmware_data_left = fw->fw.size; 8798 unsigned int firmware_data_left = fw->fw.size;
8523 8799
8524 while (firmware_data_left > 0) { 8800 while (firmware_data_left > 0) {
8525 addr = *(u32 *)(firmware_data); 8801 addr = *(u32 *) (firmware_data);
8526 firmware_data += 4; 8802 firmware_data += 4;
8527 firmware_data_left -= 4; 8803 firmware_data_left -= 4;
8528 8804
8529 len = *(u16 *)(firmware_data); 8805 len = *(u16 *) (firmware_data);
8530 firmware_data += 2; 8806 firmware_data += 2;
8531 firmware_data_left -= 2; 8807 firmware_data_left -= 2;
8532 8808
8533 if (len > 32) { 8809 if (len > 32) {
@@ -8538,7 +8814,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv,
8538 } 8814 }
8539 8815
8540 write_nic_memory(priv->net_dev, addr, len, firmware_data); 8816 write_nic_memory(priv->net_dev, addr, len, firmware_data);
8541 firmware_data += len; 8817 firmware_data += len;
8542 firmware_data_left -= len; 8818 firmware_data_left -= len;
8543 } 8819 }
8544 8820
@@ -8652,21 +8928,19 @@ static int ipw2100_ucode_download(struct ipw2100_priv *priv,
8652 for (i = 0; i < 30; i++) { 8928 for (i = 0; i < 30; i++) {
8653 /* Read alive response structure */ 8929 /* Read alive response structure */
8654 for (j = 0; 8930 for (j = 0;
8655 j < (sizeof(struct symbol_alive_response) >> 1); 8931 j < (sizeof(struct symbol_alive_response) >> 1); j++)
8656 j++) 8932 read_nic_word(dev, 0x210004, ((u16 *) & response) + j);
8657 read_nic_word(dev, 0x210004,
8658 ((u16 *)&response) + j);
8659 8933
8660 if ((response.cmd_id == 1) && 8934 if ((response.cmd_id == 1) && (response.ucode_valid == 0x1))
8661 (response.ucode_valid == 0x1))
8662 break; 8935 break;
8663 udelay(10); 8936 udelay(10);
8664 } 8937 }
8665 8938
8666 if (i == 30) { 8939 if (i == 30) {
8667 printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n", 8940 printk(KERN_ERR DRV_NAME
8941 ": %s: No response from Symbol - hw not alive\n",
8668 dev->name); 8942 dev->name);
8669 printk_buf(IPW_DL_ERROR, (u8*)&response, sizeof(response)); 8943 printk_buf(IPW_DL_ERROR, (u8 *) & response, sizeof(response));
8670 return -EIO; 8944 return -EIO;
8671 } 8945 }
8672 8946