X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fnet%2Fwireless%2Fipw2100.c;h=5bf9e00b070c4478706ff094c8828c80b8efb7cd;hb=5042c5070daaa6a3c033e4510439e3ac02a1df60;hp=4f19ac7d63a8ed4273eb3cdb01bfa8955c1d40ac;hpb=b69a3aa85cb7bda2eb6c5932a62c1337d0d6612c;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index 4f19ac7..5bf9e00 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved. + Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as @@ -28,8 +28,8 @@ Portions of this file are based on the Host AP project, Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - - Copyright (c) 2002-2003, Jouni Malinen + + Copyright (c) 2002-2003, Jouni Malinen Portions of ipw2100_mod_firmware_load, ipw2100_do_mod_firmware_load, and ipw2100_fw_load are loosely based on drivers/sound/sound_firmware.c @@ -134,7 +134,6 @@ that only one external action is invoked at a time. */ #include -#include #include #include #include @@ -151,7 +150,6 @@ that only one external action is invoked at a time. #include #include #include -#define __KERNEL_SYSCALLS__ #include #include #include @@ -164,20 +162,20 @@ that only one external action is invoked at a time. #include #include #include +#include #include "ipw2100.h" -#define IPW2100_VERSION "1.1.0" +#define IPW2100_VERSION "git-1.2.2" #define DRV_NAME "ipw2100" #define DRV_VERSION IPW2100_VERSION #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver" -#define DRV_COPYRIGHT "Copyright(c) 2003-2004 Intel Corporation" - +#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" /* Debugging stuff */ -#ifdef CONFIG_IPW_DEBUG -#define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */ +#ifdef CONFIG_IPW2100_DEBUG +#define IPW2100_RX_DEBUG /* Reception debugging */ #endif MODULE_DESCRIPTION(DRV_DESCRIPTION); @@ -209,7 +207,7 @@ MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); static u32 ipw2100_debug_level = IPW_DL_NONE; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG #define IPW_DEBUG(level, message...) \ do { \ if (ipw2100_debug_level & (level)) { \ @@ -220,18 +218,18 @@ do { \ } while (0) #else #define IPW_DEBUG(level, message...) do {} while (0) -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2100_DEBUG */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static const char *command_types[] = { "undefined", - "unused", /* HOST_ATTENTION */ + "unused", /* HOST_ATTENTION */ "HOST_COMPLETE", - "unused", /* SLEEP */ - "unused", /* HOST_POWER_DOWN */ + "unused", /* SLEEP */ + "unused", /* HOST_POWER_DOWN */ "unused", "SYSTEM_CONFIG", - "unused", /* SET_IMR */ + "unused", /* SET_IMR */ "SSID", "MANDATORY_BSSID", "AUTHENTICATION_TYPE", @@ -277,17 +275,16 @@ static const char *command_types[] = { "GROUP_ORDINALS", "SHORT_RETRY_LIMIT", "LONG_RETRY_LIMIT", - "unused", /* SAVE_CALIBRATION */ - "unused", /* RESTORE_CALIBRATION */ + "unused", /* SAVE_CALIBRATION */ + "unused", /* RESTORE_CALIBRATION */ "undefined", "undefined", "undefined", "HOST_PRE_POWER_DOWN", - "unused", /* HOST_INTERRUPT_COALESCING */ + "unused", /* HOST_INTERRUPT_COALESCING */ "undefined", "CARD_DISABLE_PHY_OFF", - "MSDU_TX_RATES" - "undefined", + "MSDU_TX_RATES" "undefined", "undefined", "SET_STATION_STAT_BITS", "CLEAR_STATIONS_STAT_BITS", @@ -298,7 +295,6 @@ static const char *command_types[] = { }; #endif - /* Pre-decl until we get the code solid and then we can clean it up */ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv); static void ipw2100_tx_send_data(struct ipw2100_priv *priv); @@ -320,12 +316,11 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv, struct ipw2100_fw *fw); static int ipw2100_ucode_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw); -static void ipw2100_wx_event_work(struct ipw2100_priv *priv); -static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev); +static void ipw2100_wx_event_work(struct work_struct *work); +static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev); static struct iw_handler_def ipw2100_wx_handler_def; - -static inline void read_register(struct net_device *dev, u32 reg, u32 *val) +static inline void read_register(struct net_device *dev, u32 reg, u32 * val) { *val = readl((void __iomem *)(dev->base_addr + reg)); IPW_DEBUG_IO("r: 0x%08X => 0x%08X\n", reg, *val); @@ -337,13 +332,14 @@ static inline void write_register(struct net_device *dev, u32 reg, u32 val) IPW_DEBUG_IO("w: 0x%08X <= 0x%08X\n", reg, val); } -static inline void read_register_word(struct net_device *dev, u32 reg, u16 *val) +static inline void read_register_word(struct net_device *dev, u32 reg, + u16 * val) { *val = readw((void __iomem *)(dev->base_addr + reg)); IPW_DEBUG_IO("r: 0x%08X => %04X\n", reg, *val); } -static inline void read_register_byte(struct net_device *dev, u32 reg, u8 *val) +static inline void read_register_byte(struct net_device *dev, u32 reg, u8 * val) { *val = readb((void __iomem *)(dev->base_addr + reg)); IPW_DEBUG_IO("r: 0x%08X => %02X\n", reg, *val); @@ -355,14 +351,13 @@ static inline void write_register_word(struct net_device *dev, u32 reg, u16 val) IPW_DEBUG_IO("w: 0x%08X <= %04X\n", reg, val); } - static inline void write_register_byte(struct net_device *dev, u32 reg, u8 val) { writeb(val, (void __iomem *)(dev->base_addr + reg)); IPW_DEBUG_IO("w: 0x%08X =< %02X\n", reg, val); } -static inline void read_nic_dword(struct net_device *dev, u32 addr, u32 *val) +static inline void read_nic_dword(struct net_device *dev, u32 addr, u32 * val) { write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, addr & IPW_REG_INDIRECT_ADDR_MASK); @@ -376,7 +371,7 @@ static inline void write_nic_dword(struct net_device *dev, u32 addr, u32 val) write_register(dev, IPW_REG_INDIRECT_ACCESS_DATA, val); } -static inline void read_nic_word(struct net_device *dev, u32 addr, u16 *val) +static inline void read_nic_word(struct net_device *dev, u32 addr, u16 * val) { write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, addr & IPW_REG_INDIRECT_ADDR_MASK); @@ -390,7 +385,7 @@ static inline void write_nic_word(struct net_device *dev, u32 addr, u16 val) write_register_word(dev, IPW_REG_INDIRECT_ACCESS_DATA, val); } -static inline void read_nic_byte(struct net_device *dev, u32 addr, u8 *val) +static inline void read_nic_byte(struct net_device *dev, u32 addr, u8 * val) { write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, addr & IPW_REG_INDIRECT_ADDR_MASK); @@ -415,8 +410,8 @@ static inline void write_nic_dword_auto_inc(struct net_device *dev, u32 val) write_register(dev, IPW_REG_AUTOINCREMENT_DATA, val); } -static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len, - const u8 *buf) +static void write_nic_memory(struct net_device *dev, u32 addr, u32 len, + const u8 * buf) { u32 aligned_addr; u32 aligned_len; @@ -431,32 +426,30 @@ static inline void write_nic_memory(struct net_device *dev, u32 addr, u32 len, write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = dif_len; i < 4; i++, buf++) - write_register_byte( - dev, IPW_REG_INDIRECT_ACCESS_DATA + i, - *buf); + write_register_byte(dev, + IPW_REG_INDIRECT_ACCESS_DATA + i, + *buf); len -= dif_len; aligned_addr += 4; } /* read DWs through autoincrement registers */ - write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, - aligned_addr); + write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr); aligned_len = len & (~0x3); for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - write_register( - dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *)buf); + write_register(dev, IPW_REG_AUTOINCREMENT_DATA, *(u32 *) buf); /* copy the last nibble */ dif_len = len - aligned_len; write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = 0; i < dif_len; i++, buf++) - write_register_byte( - dev, IPW_REG_INDIRECT_ACCESS_DATA + i, *buf); + write_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, + *buf); } -static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len, - u8 *buf) +static void read_nic_memory(struct net_device *dev, u32 addr, u32 len, + u8 * buf) { u32 aligned_addr; u32 aligned_len; @@ -471,39 +464,38 @@ static inline void read_nic_memory(struct net_device *dev, u32 addr, u32 len, write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = dif_len; i < 4; i++, buf++) - read_register_byte( - dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf); + read_register_byte(dev, + IPW_REG_INDIRECT_ACCESS_DATA + i, + buf); len -= dif_len; aligned_addr += 4; } /* read DWs through autoincrement registers */ - write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, - aligned_addr); + write_register(dev, IPW_REG_AUTOINCREMENT_ADDRESS, aligned_addr); aligned_len = len & (~0x3); for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - read_register(dev, IPW_REG_AUTOINCREMENT_DATA, - (u32 *)buf); + read_register(dev, IPW_REG_AUTOINCREMENT_DATA, (u32 *) buf); /* copy the last nibble */ dif_len = len - aligned_len; - write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, - aligned_addr); + write_register(dev, IPW_REG_INDIRECT_ACCESS_ADDRESS, aligned_addr); for (i = 0; i < dif_len; i++, buf++) - read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + - i, buf); + read_register_byte(dev, IPW_REG_INDIRECT_ACCESS_DATA + i, buf); } static inline int ipw2100_hw_is_adapter_in_system(struct net_device *dev) { return (dev->base_addr && - (readl((void __iomem *)(dev->base_addr + IPW_REG_DOA_DEBUG_AREA_START)) + (readl + ((void __iomem *)(dev->base_addr + + IPW_REG_DOA_DEBUG_AREA_START)) == IPW_DATA_DOA_DEBUG_VALUE)); } static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, - void *val, u32 *len) + void *val, u32 * len) { struct ipw2100_ordinals *ordinals = &priv->ordinals; u32 addr; @@ -529,8 +521,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, return -EINVAL; } - read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2), - &addr); + read_nic_dword(priv->net_dev, + ordinals->table1_addr + (ord << 2), &addr); read_nic_dword(priv->net_dev, addr, val); *len = IPW_ORD_TAB_1_ENTRY_SIZE; @@ -543,8 +535,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, ord -= IPW_START_ORD_TAB_2; /* get the address of statistic */ - read_nic_dword(priv->net_dev, ordinals->table2_addr + (ord << 3), - &addr); + read_nic_dword(priv->net_dev, + ordinals->table2_addr + (ord << 3), &addr); /* get the second DW of statistics ; * two 16-bit words - first is length, second is count */ @@ -553,10 +545,10 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, &field_info); /* get each entry length */ - field_len = *((u16 *)&field_info); + field_len = *((u16 *) & field_info); /* get number of entries */ - field_count = *(((u16 *)&field_info) + 1); + field_count = *(((u16 *) & field_info) + 1); /* abort if no enought memory */ total_length = field_len * field_count; @@ -581,8 +573,8 @@ static int ipw2100_get_ordinal(struct ipw2100_priv *priv, u32 ord, return -EINVAL; } -static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val, - u32 *len) +static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 * val, + u32 * len) { struct ipw2100_ordinals *ordinals = &priv->ordinals; u32 addr; @@ -594,8 +586,8 @@ static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val, return -EINVAL; } - read_nic_dword(priv->net_dev, ordinals->table1_addr + (ord << 2), - &addr); + read_nic_dword(priv->net_dev, + ordinals->table1_addr + (ord << 2), &addr); write_nic_dword(priv->net_dev, addr, *val); @@ -612,7 +604,7 @@ static int ipw2100_set_ordinal(struct ipw2100_priv *priv, u32 ord, u32 *val, } static char *snprint_line(char *buf, size_t count, - const u8 *data, u32 len, u32 ofs) + const u8 * data, u32 len, u32 ofs) { int out, i, j, l; char c; @@ -646,7 +638,7 @@ static char *snprint_line(char *buf, size_t count, return buf; } -static void printk_buf(int level, const u8 *data, u32 len) +static void printk_buf(int level, const u8 * data, u32 len) { char line[81]; u32 ofs = 0; @@ -662,11 +654,9 @@ static void printk_buf(int level, const u8 *data, u32 len) } } - - #define MAX_RESET_BACKOFF 10 -static inline void schedule_reset(struct ipw2100_priv *priv) +static void schedule_reset(struct ipw2100_priv *priv) { unsigned long now = get_seconds(); @@ -689,7 +679,8 @@ static inline void schedule_reset(struct ipw2100_priv *priv) queue_delayed_work(priv->workqueue, &priv->reset_work, priv->reset_backoff * HZ); else - queue_work(priv->workqueue, &priv->reset_work); + queue_delayed_work(priv->workqueue, &priv->reset_work, + 0); if (priv->reset_backoff < MAX_RESET_BACKOFF) priv->reset_backoff++; @@ -703,7 +694,7 @@ static inline void schedule_reset(struct ipw2100_priv *priv) #define HOST_COMPLETE_TIMEOUT (2 * HZ) static int ipw2100_hw_send_command(struct ipw2100_priv *priv, - struct host_command * cmd) + struct host_command *cmd) { struct list_head *element; struct ipw2100_tx_packet *packet; @@ -713,25 +704,28 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv, IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", command_types[cmd->host_command], cmd->host_command, cmd->host_command_length); - printk_buf(IPW_DL_HC, (u8*)cmd->host_command_parameters, + printk_buf(IPW_DL_HC, (u8 *) cmd->host_command_parameters, cmd->host_command_length); spin_lock_irqsave(&priv->low_lock, flags); if (priv->fatal_error) { - IPW_DEBUG_INFO("Attempt to send command while hardware in fatal error condition.\n"); + IPW_DEBUG_INFO + ("Attempt to send command while hardware in fatal error condition.\n"); err = -EIO; goto fail_unlock; } if (!(priv->status & STATUS_RUNNING)) { - IPW_DEBUG_INFO("Attempt to send command while hardware is not running.\n"); + IPW_DEBUG_INFO + ("Attempt to send command while hardware is not running.\n"); err = -EIO; goto fail_unlock; } if (priv->status & STATUS_CMD_ACTIVE) { - IPW_DEBUG_INFO("Attempt to send command while another command is pending.\n"); + IPW_DEBUG_INFO + ("Attempt to send command while another command is pending.\n"); err = -EBUSY; goto fail_unlock; } @@ -752,7 +746,8 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv, /* initialize the firmware command packet */ packet->info.c_struct.cmd->host_command_reg = cmd->host_command; packet->info.c_struct.cmd->host_command_reg1 = cmd->host_command1; - packet->info.c_struct.cmd->host_command_len_reg = cmd->host_command_length; + packet->info.c_struct.cmd->host_command_len_reg = + cmd->host_command_length; packet->info.c_struct.cmd->sequence = cmd->host_command_sequence; memcpy(packet->info.c_struct.cmd->host_command_params_reg, @@ -776,13 +771,15 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv, * then there is a problem. */ - err = wait_event_interruptible_timeout( - priv->wait_command_queue, !(priv->status & STATUS_CMD_ACTIVE), - HOST_COMPLETE_TIMEOUT); + err = + wait_event_interruptible_timeout(priv->wait_command_queue, + !(priv-> + status & STATUS_CMD_ACTIVE), + HOST_COMPLETE_TIMEOUT); if (err == 0) { IPW_DEBUG_INFO("Command completion failed out after %dms.\n", - HOST_COMPLETE_TIMEOUT / (HZ / 100)); + 1000 * (HOST_COMPLETE_TIMEOUT / HZ)); priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT; priv->status &= ~STATUS_CMD_ACTIVE; schedule_reset(priv); @@ -804,13 +801,12 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv, return 0; - fail_unlock: + fail_unlock: spin_unlock_irqrestore(&priv->low_lock, flags); return err; } - /* * Verify the values and data access of the hardware * No locks needed or used. No functions called. @@ -825,8 +821,7 @@ static int ipw2100_verify(struct ipw2100_priv *priv) /* Domain 0 check - all values should be DOA_DEBUG */ for (address = IPW_REG_DOA_DEBUG_AREA_START; - address < IPW_REG_DOA_DEBUG_AREA_END; - address += sizeof(u32)) { + address < IPW_REG_DOA_DEBUG_AREA_END; address += sizeof(u32)) { read_register(priv->net_dev, address, &data1); if (data1 != IPW_DATA_DOA_DEBUG_VALUE) return -EIO; @@ -898,7 +893,6 @@ static int ipw2100_wait_for_card_state(struct ipw2100_priv *priv, int state) return -EIO; } - /********************************************************************* Procedure : sw_reset_and_clock Purpose : Asserts s/w reset, asserts clock initialization @@ -975,17 +969,16 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) if (priv->fatal_error) { IPW_DEBUG_ERROR("%s: ipw2100_download_firmware called after " - "fatal error %d. Interface must be brought down.\n", - priv->net_dev->name, priv->fatal_error); + "fatal error %d. Interface must be brought down.\n", + priv->net_dev->name, priv->fatal_error); return -EINVAL; } - #ifdef CONFIG_PM if (!ipw2100_firmware.version) { err = ipw2100_get_firmware(priv, &ipw2100_firmware); if (err) { IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n", - priv->net_dev->name, err); + priv->net_dev->name, err); priv->fatal_error = IPW2100_ERR_FW_LOAD; goto fail; } @@ -994,7 +987,7 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) err = ipw2100_get_firmware(priv, &ipw2100_firmware); if (err) { IPW_DEBUG_ERROR("%s: ipw2100_get_firmware failed: %d\n", - priv->net_dev->name, err); + priv->net_dev->name, err); priv->fatal_error = IPW2100_ERR_FW_LOAD; goto fail; } @@ -1005,21 +998,20 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) err = sw_reset_and_clock(priv); if (err) { IPW_DEBUG_ERROR("%s: sw_reset_and_clock failed: %d\n", - priv->net_dev->name, err); + priv->net_dev->name, err); goto fail; } err = ipw2100_verify(priv); if (err) { IPW_DEBUG_ERROR("%s: ipw2100_verify failed: %d\n", - priv->net_dev->name, err); + priv->net_dev->name, err); goto fail; } /* Hold ARC */ write_nic_dword(priv->net_dev, - IPW_INTERNAL_REGISTER_HALT_AND_RESET, - 0x80000000); + IPW_INTERNAL_REGISTER_HALT_AND_RESET, 0x80000000); /* allow ARC to run */ write_register(priv->net_dev, IPW_REG_RESET_REG, 0); @@ -1034,13 +1026,13 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) /* release ARC */ write_nic_dword(priv->net_dev, - IPW_INTERNAL_REGISTER_HALT_AND_RESET, - 0x00000000); + IPW_INTERNAL_REGISTER_HALT_AND_RESET, 0x00000000); /* s/w reset and clock stabilization (again!!!) */ err = sw_reset_and_clock(priv); if (err) { - printk(KERN_ERR DRV_NAME ": %s: sw_reset_and_clock failed: %d\n", + printk(KERN_ERR DRV_NAME + ": %s: sw_reset_and_clock failed: %d\n", priv->net_dev->name, err); goto fail; } @@ -1049,10 +1041,9 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) err = ipw2100_fw_download(priv, &ipw2100_firmware); if (err) { IPW_DEBUG_ERROR("%s: Error loading firmware: %d\n", - priv->net_dev->name, err); + priv->net_dev->name, err); goto fail; } - #ifndef CONFIG_PM /* * When the .resume method of the driver is called, the other @@ -1084,7 +1075,7 @@ static int ipw2100_download_firmware(struct ipw2100_priv *priv) return 0; - fail: + fail: ipw2100_release_firmware(priv, &ipw2100_firmware); return err; } @@ -1105,7 +1096,6 @@ static inline void ipw2100_disable_interrupts(struct ipw2100_priv *priv) write_register(priv->net_dev, IPW_REG_INTA_MASK, 0x0); } - static void ipw2100_initialize_ordinals(struct ipw2100_priv *priv) { struct ipw2100_ordinals *ord = &priv->ordinals; @@ -1140,7 +1130,7 @@ static inline void ipw2100_hw_set_gpio(struct ipw2100_priv *priv) write_register(priv->net_dev, IPW_REG_GPIO, reg); } -static inline int rf_kill_active(struct ipw2100_priv *priv) +static int rf_kill_active(struct ipw2100_priv *priv) { #define MAX_RF_KILL_CHECKS 5 #define RF_KILL_CHECK_DELAY 40 @@ -1177,11 +1167,10 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv) * EEPROM_SRAM_DB_START_ADDRESS using ordinal in ordinal table 1 */ len = sizeof(addr); - if (ipw2100_get_ordinal( - priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS, - &addr, &len)) { + if (ipw2100_get_ordinal + (priv, IPW_ORD_EEPROM_SRAM_DB_BLOCK_START_ADDRESS, &addr, &len)) { IPW_DEBUG_INFO("failed querying ordinals at line %d\n", - __LINE__); + __LINE__); return -EIO; } @@ -1194,7 +1183,7 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv) priv->eeprom_version = (val >> 24) & 0xFF; IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version); - /* + /* * HW RF Kill enable is bit 0 in byte at offset 0x21 in firmware * * notice that the EEPROM bit is reverse polarity, i.e. @@ -1206,8 +1195,7 @@ static int ipw2100_get_hw_features(struct ipw2100_priv *priv) priv->hw_features |= HW_FEATURE_RFKILL; IPW_DEBUG_INFO("HW RF Kill: %ssupported.\n", - (priv->hw_features & HW_FEATURE_RFKILL) ? - "" : "not "); + (priv->hw_features & HW_FEATURE_RFKILL) ? "" : "not "); return 0; } @@ -1234,7 +1222,8 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv) * fw & dino ucode */ if (ipw2100_download_firmware(priv)) { - printk(KERN_ERR DRV_NAME ": %s: Failed to power on the adapter.\n", + printk(KERN_ERR DRV_NAME + ": %s: Failed to power on the adapter.\n", priv->net_dev->name); return -EIO; } @@ -1278,7 +1267,7 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv) IPW2100_INTA_FATAL_ERROR | IPW2100_INTA_PARITY_ERROR); } - } while (i--); + } while (--i); /* Clear out any pending INTAs since we aren't supposed to have * interrupts enabled at this point... */ @@ -1293,7 +1282,8 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv) i ? "SUCCESS" : "FAILED"); if (!i) { - printk(KERN_WARNING DRV_NAME ": %s: Firmware did not initialize.\n", + printk(KERN_WARNING DRV_NAME + ": %s: Firmware did not initialize.\n", priv->net_dev->name); return -EIO; } @@ -1326,7 +1316,6 @@ static inline void ipw2100_reset_fatalerror(struct ipw2100_priv *priv) priv->fatal_error = 0; } - /* NOTE: Our interrupt is disabled when this method is called */ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv) { @@ -1350,19 +1339,19 @@ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv) if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) break; - } while(i--); + } while (--i); priv->status &= ~STATUS_RESET_PENDING; if (!i) { - IPW_DEBUG_INFO("exit - waited too long for master assert stop\n"); + IPW_DEBUG_INFO + ("exit - waited too long for master assert stop\n"); return -EIO; } write_register(priv->net_dev, IPW_REG_RESET_REG, IPW_AUX_HOST_RESET_REG_SW_RESET); - /* Reset any fatal_error conditions */ ipw2100_reset_fatalerror(priv); @@ -1415,7 +1404,6 @@ static int ipw2100_hw_phy_off(struct ipw2100_priv *priv) return -EIO; } - static int ipw2100_enable_adapter(struct ipw2100_priv *priv) { struct host_command cmd = { @@ -1430,7 +1418,7 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv) if (priv->status & STATUS_ENABLED) return 0; - down(&priv->adapter_sem); + mutex_lock(&priv->adapter_mutex); if (rf_kill_active(priv)) { IPW_DEBUG_HC("Command aborted due to RF kill active.\n"); @@ -1445,9 +1433,8 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv) err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_ENABLED); if (err) { - IPW_DEBUG_INFO( - "%s: card not responding to init command.\n", - priv->net_dev->name); + IPW_DEBUG_INFO("%s: card not responding to init command.\n", + priv->net_dev->name); goto fail_up; } @@ -1456,8 +1443,8 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv) queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2); } -fail_up: - up(&priv->adapter_sem); + fail_up: + mutex_unlock(&priv->adapter_mutex); return err; } @@ -1488,7 +1475,8 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) err = ipw2100_hw_phy_off(priv); if (err) - printk(KERN_WARNING DRV_NAME ": Error disabling radio %d\n", err); + printk(KERN_WARNING DRV_NAME + ": Error disabling radio %d\n", err); /* * If in D0-standby mode going directly to D3 may cause a @@ -1497,7 +1485,7 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) * * Sending the PREPARE_FOR_POWER_DOWN will restrict the * hardware from going into standby mode and will transition - * out of D0-standy if it is already in that state. + * out of D0-standby if it is already in that state. * * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the * driver upon completion. Once received, the driver can @@ -1566,7 +1554,6 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) return 0; } - static int ipw2100_disable_adapter(struct ipw2100_priv *priv) { struct host_command cmd = { @@ -1589,24 +1576,26 @@ static int ipw2100_disable_adapter(struct ipw2100_priv *priv) cancel_delayed_work(&priv->hang_check); } - down(&priv->adapter_sem); + mutex_lock(&priv->adapter_mutex); err = ipw2100_hw_send_command(priv, &cmd); if (err) { - printk(KERN_WARNING DRV_NAME ": exit - failed to send CARD_DISABLE command\n"); + printk(KERN_WARNING DRV_NAME + ": exit - failed to send CARD_DISABLE command\n"); goto fail_up; } err = ipw2100_wait_for_card_state(priv, IPW_HW_STATE_DISABLED); if (err) { - printk(KERN_WARNING DRV_NAME ": exit - card failed to change to DISABLED\n"); + printk(KERN_WARNING DRV_NAME + ": exit - card failed to change to DISABLED\n"); goto fail_up; } IPW_DEBUG_INFO("TODO: implement scan state machine\n"); -fail_up: - up(&priv->adapter_sem); + fail_up: + mutex_unlock(&priv->adapter_mutex); return err; } @@ -1627,7 +1616,7 @@ static int ipw2100_set_scan_options(struct ipw2100_priv *priv) if (!(priv->config & CFG_ASSOCIATE)) cmd.host_command_parameters[0] |= IPW_SCAN_NOASSOCIATE; - if ((priv->sec.flags & SEC_ENABLED) && priv->sec.enabled) + if ((priv->ieee->sec.flags & SEC_ENABLED) && priv->ieee->sec.enabled) cmd.host_command_parameters[0] |= IPW_SCAN_MIXED_CELL; if (priv->config & CFG_PASSIVE_SCAN) cmd.host_command_parameters[0] |= IPW_SCAN_PASSIVE; @@ -1683,6 +1672,18 @@ static int ipw2100_start_scan(struct ipw2100_priv *priv) return err; } +static const struct ieee80211_geo ipw_geos[] = { + { /* Restricted */ + "---", + .bg_channels = 14, + .bg = {{2412, 1}, {2417, 2}, {2422, 3}, + {2427, 4}, {2432, 5}, {2437, 6}, + {2442, 7}, {2447, 8}, {2452, 9}, + {2457, 10}, {2462, 11}, {2467, 12}, + {2472, 13}, {2484, 14}}, + }, +}; + static int ipw2100_up(struct ipw2100_priv *priv, int deferred) { unsigned long flags; @@ -1697,6 +1698,11 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) return 0; } + /* the ipw2100 hardware really doesn't want power management delays + * longer than 175usec + */ + pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY, "ipw2100", 175); + /* If the interrupt is enabled, turn it off... */ spin_lock_irqsave(&priv->low_lock, flags); ipw2100_disable_interrupts(priv); @@ -1709,8 +1715,9 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) (priv->status & STATUS_RESET_PENDING)) { /* Power cycle the card ... */ if (ipw2100_power_cycle_adapter(priv)) { - printk(KERN_WARNING DRV_NAME ": %s: Could not cycle adapter.\n", - priv->net_dev->name); + printk(KERN_WARNING DRV_NAME + ": %s: Could not cycle adapter.\n", + priv->net_dev->name); rc = 1; goto exit; } @@ -1719,8 +1726,9 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) /* Load the firmware, start the clocks, etc. */ if (ipw2100_start_adapter(priv)) { - printk(KERN_ERR DRV_NAME ": %s: Failed to start the firmware.\n", - priv->net_dev->name); + printk(KERN_ERR DRV_NAME + ": %s: Failed to start the firmware.\n", + priv->net_dev->name); rc = 1; goto exit; } @@ -1729,16 +1737,25 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) /* Determine capabilities of this particular HW configuration */ if (ipw2100_get_hw_features(priv)) { - printk(KERN_ERR DRV_NAME ": %s: Failed to determine HW features.\n", - priv->net_dev->name); + printk(KERN_ERR DRV_NAME + ": %s: Failed to determine HW features.\n", + priv->net_dev->name); rc = 1; goto exit; } + /* Initialize the geo */ + if (ieee80211_set_geo(priv->ieee, &ipw_geos[0])) { + printk(KERN_WARNING DRV_NAME "Could not set geo\n"); + return 0; + } + priv->ieee->freq_band = IEEE80211_24GHZ_BAND; + lock = LOCK_NONE; if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) { - printk(KERN_ERR DRV_NAME ": %s: Failed to clear ordinal lock.\n", - priv->net_dev->name); + printk(KERN_ERR DRV_NAME + ": %s: Failed to clear ordinal lock.\n", + priv->net_dev->name); rc = 1; goto exit; } @@ -1751,7 +1768,8 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) if (priv->stop_rf_kill) { priv->stop_rf_kill = 0; - queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); + queue_delayed_work(priv->workqueue, &priv->rf_kill, + round_jiffies_relative(HZ)); } deferred = 1; @@ -1764,7 +1782,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) * HOST_COMPLETE */ if (ipw2100_adapter_setup(priv)) { printk(KERN_ERR DRV_NAME ": %s: Failed to start the card.\n", - priv->net_dev->name); + priv->net_dev->name); rc = 1; goto exit; } @@ -1773,20 +1791,19 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) /* Enable the adapter - sends HOST_COMPLETE */ if (ipw2100_enable_adapter(priv)) { printk(KERN_ERR DRV_NAME ": " - "%s: failed in call to enable adapter.\n", - priv->net_dev->name); + "%s: failed in call to enable adapter.\n", + priv->net_dev->name); ipw2100_hw_stop_adapter(priv); rc = 1; goto exit; } - /* Start a scan . . . */ ipw2100_set_scan_options(priv); ipw2100_start_scan(priv); } - exit: + exit: return rc; } @@ -1802,8 +1819,7 @@ static void ipw2100_down(struct ipw2100_priv *priv) unsigned long flags; union iwreq_data wrqu = { .ap_addr = { - .sa_family = ARPHRD_ETHER - } + .sa_family = ARPHRD_ETHER} }; int associated = priv->status & STATUS_ASSOCIATED; @@ -1840,13 +1856,8 @@ static void ipw2100_down(struct ipw2100_priv *priv) ipw2100_disable_interrupts(priv); spin_unlock_irqrestore(&priv->low_lock, flags); -#ifdef ACPI_CSTATE_LIMIT_DEFINED - if (priv->config & CFG_C3_DISABLED) { - IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n"); - acpi_set_cstate_limit(priv->cstate_limit); - priv->config &= ~CFG_C3_DISABLED; - } -#endif + pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY, "ipw2100", + PM_QOS_DEFAULT_VALUE); /* We have to signal any supplicant if we are disassociating */ if (associated) @@ -1857,19 +1868,19 @@ static void ipw2100_down(struct ipw2100_priv *priv) netif_stop_queue(priv->net_dev); } -static void ipw2100_reset_adapter(struct ipw2100_priv *priv) +static void ipw2100_reset_adapter(struct work_struct *work) { + struct ipw2100_priv *priv = + container_of(work, struct ipw2100_priv, reset_work.work); unsigned long flags; union iwreq_data wrqu = { .ap_addr = { - .sa_family = ARPHRD_ETHER - } + .sa_family = ARPHRD_ETHER} }; int associated = priv->status & STATUS_ASSOCIATED; spin_lock_irqsave(&priv->low_lock, flags); - IPW_DEBUG_INFO(DRV_NAME ": %s: Restarting adapter.\n", - priv->net_dev->name); + IPW_DEBUG_INFO(": %s: Restarting adapter.\n", priv->net_dev->name); priv->resets++; priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); priv->status |= STATUS_SECURITY_UPDATED; @@ -1880,7 +1891,7 @@ static void ipw2100_reset_adapter(struct ipw2100_priv *priv) priv->status |= STATUS_RESET_PENDING; spin_unlock_irqrestore(&priv->low_lock, flags); - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); /* stop timed checks so that they don't interfere with reset */ priv->stop_hang_check = 1; cancel_delayed_work(&priv->hang_check); @@ -1890,11 +1901,10 @@ static void ipw2100_reset_adapter(struct ipw2100_priv *priv) wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); ipw2100_up(priv, 0); - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); } - static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) { @@ -1904,7 +1914,8 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) u32 txrate; u32 chan; char *txratename; - u8 bssid[ETH_ALEN]; + u8 bssid[ETH_ALEN]; + DECLARE_MAC_BUF(mac); /* * TBD: BSSID is usually 00:00:00:00:00:00 here and not @@ -1918,16 +1929,15 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) essid, &essid_len); if (ret) { IPW_DEBUG_INFO("failed querying ordinals at line %d\n", - __LINE__); + __LINE__); return; } len = sizeof(u32); - ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, - &txrate, &len); + ret = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, &txrate, &len); if (ret) { IPW_DEBUG_INFO("failed querying ordinals at line %d\n", - __LINE__); + __LINE__); return; } @@ -1935,19 +1945,18 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) ret = ipw2100_get_ordinal(priv, IPW_ORD_OUR_FREQ, &chan, &len); if (ret) { IPW_DEBUG_INFO("failed querying ordinals at line %d\n", - __LINE__); + __LINE__); return; } len = ETH_ALEN; - ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, &bssid, &len); + ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, &bssid, &len); if (ret) { IPW_DEBUG_INFO("failed querying ordinals at line %d\n", - __LINE__); + __LINE__); return; } memcpy(priv->ieee->bssid, bssid, ETH_ALEN); - switch (txrate) { case TX_RATE_1_MBIT: txratename = "1Mbps"; @@ -1968,13 +1977,13 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) } IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID=" - MAC_FMT ")\n", + "%s)\n", priv->net_dev->name, escape_essid(essid, essid_len), - txratename, chan, MAC_ARG(bssid)); + txratename, chan, print_mac(mac, bssid)); /* now we copy read ssid into dev */ if (!(priv->config & CFG_STATIC_ESSID)) { - priv->essid_len = min((u8)essid_len, (u8)IW_ESSID_MAX_SIZE); + priv->essid_len = min((u8) essid_len, (u8) IW_ESSID_MAX_SIZE); memcpy(priv->essid, essid, priv->essid_len); } priv->channel = chan; @@ -1986,7 +1995,6 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) queue_delayed_work(priv->workqueue, &priv->wx_event_work, HZ / 10); } - static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, int length, int batch_mode) { @@ -2001,8 +2009,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len)); if (ssid_len) - memcpy((char*)cmd.host_command_parameters, - essid, ssid_len); + memcpy(cmd.host_command_parameters, essid, ssid_len); if (!batch_mode) { err = ipw2100_disable_adapter(priv); @@ -2014,7 +2021,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, * disable auto association -- so we cheat by setting a bogus SSID */ if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) { int i; - u8 *bogus = (u8*)cmd.host_command_parameters; + u8 *bogus = (u8 *) cmd.host_command_parameters; for (i = 0; i < IW_ESSID_MAX_SIZE; i++) bogus[i] = 0x18 + i; cmd.host_command_length = IW_ESSID_MAX_SIZE; @@ -2025,8 +2032,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, err = ipw2100_hw_send_command(priv, &cmd); if (!err) { - memset(priv->essid + ssid_len, 0, - IW_ESSID_MAX_SIZE - ssid_len); + memset(priv->essid + ssid_len, 0, IW_ESSID_MAX_SIZE - ssid_len); memcpy(priv->essid, essid, ssid_len); priv->essid_len = ssid_len; } @@ -2041,10 +2047,12 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid, static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status) { + DECLARE_MAC_BUF(mac); + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "disassociated: '%s' " MAC_FMT " \n", + "disassociated: '%s' %s \n", escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); + print_mac(mac, priv->bssid)); priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); @@ -2063,31 +2071,46 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status) return; if (priv->status & STATUS_SECURITY_UPDATED) - queue_work(priv->workqueue, &priv->security_work); + queue_delayed_work(priv->workqueue, &priv->security_work, 0); - queue_work(priv->workqueue, &priv->wx_event_work); + queue_delayed_work(priv->workqueue, &priv->wx_event_work, 0); } static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) { IPW_DEBUG_INFO("%s: RF Kill state changed to radio OFF.\n", - priv->net_dev->name); + priv->net_dev->name); /* RF_KILL is now enabled (else we wouldn't be here) */ priv->status |= STATUS_RF_KILL_HW; -#ifdef ACPI_CSTATE_LIMIT_DEFINED - if (priv->config & CFG_C3_DISABLED) { - IPW_DEBUG_INFO(DRV_NAME ": Resetting C3 transitions.\n"); - acpi_set_cstate_limit(priv->cstate_limit); - priv->config &= ~CFG_C3_DISABLED; - } -#endif - /* Make sure the RF Kill check timer is running */ priv->stop_rf_kill = 0; cancel_delayed_work(&priv->rf_kill); - queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); + queue_delayed_work(priv->workqueue, &priv->rf_kill, + round_jiffies_relative(HZ)); +} + +static void send_scan_event(void *data) +{ + struct ipw2100_priv *priv = data; + union iwreq_data wrqu; + + wrqu.data.length = 0; + wrqu.data.flags = 0; + wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); +} + +static void ipw2100_scan_event_later(struct work_struct *work) +{ + send_scan_event(container_of(work, struct ipw2100_priv, + scan_event_later.work)); +} + +static void ipw2100_scan_event_now(struct work_struct *work) +{ + send_scan_event(container_of(work, struct ipw2100_priv, + scan_event_now)); } static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) @@ -2096,22 +2119,34 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) /* Age the scan results... */ priv->ieee->scans++; priv->status &= ~STATUS_SCANNING; + + /* Only userspace-requested scan completion events go out immediately */ + if (!priv->user_requested_scan) { + if (!delayed_work_pending(&priv->scan_event_later)) + queue_delayed_work(priv->workqueue, + &priv->scan_event_later, + round_jiffies_relative(msecs_to_jiffies(4000))); + } else { + priv->user_requested_scan = 0; + cancel_delayed_work(&priv->scan_event_later); + queue_work(priv->workqueue, &priv->scan_event_now); + } } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG #define IPW2100_HANDLER(v, f) { v, f, # v } struct ipw2100_status_indicator { int status; - void (*cb)(struct ipw2100_priv *priv, u32 status); + void (*cb) (struct ipw2100_priv * priv, u32 status); char *name; }; #else #define IPW2100_HANDLER(v, f) { v, f } struct ipw2100_status_indicator { int status; - void (*cb)(struct ipw2100_priv *priv, u32 status); + void (*cb) (struct ipw2100_priv * priv, u32 status); }; -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2100_DEBUG */ static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status) { @@ -2135,7 +2170,6 @@ static const struct ipw2100_status_indicator status_handlers[] = { IPW2100_HANDLER(-1, NULL) }; - static void isr_status_change(struct ipw2100_priv *priv, int status) { int i; @@ -2153,7 +2187,7 @@ static void isr_status_change(struct ipw2100_priv *priv, int status) for (i = 0; status_handlers[i].status != -1; i++) { if (status == status_handlers[i].status) { IPW_DEBUG_NOTIF("Status change: %s\n", - status_handlers[i].name); + status_handlers[i].name); if (status_handlers[i].cb) status_handlers[i].cb(priv, status); priv->wstats.status = status; @@ -2164,11 +2198,10 @@ static void isr_status_change(struct ipw2100_priv *priv, int status) IPW_DEBUG_NOTIF("unknown status received: %04x\n", status); } -static void isr_rx_complete_command( - struct ipw2100_priv *priv, - struct ipw2100_cmd_header *cmd) +static void isr_rx_complete_command(struct ipw2100_priv *priv, + struct ipw2100_cmd_header *cmd) { -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (cmd->host_command_reg < ARRAY_SIZE(command_types)) { IPW_DEBUG_HC("Command completed '%s (%d)'\n", command_types[cmd->host_command_reg], @@ -2186,7 +2219,7 @@ static void isr_rx_complete_command( wake_up_interruptible(&priv->wait_command_queue); } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static const char *frame_types[] = { "COMMAND_STATUS_VAL", "STATUS_CHANGE_VAL", @@ -2196,10 +2229,8 @@ static const char *frame_types[] = { }; #endif - -static inline int ipw2100_alloc_skb( - struct ipw2100_priv *priv, - struct ipw2100_rx_packet *packet) +static int ipw2100_alloc_skb(struct ipw2100_priv *priv, + struct ipw2100_rx_packet *packet) { packet->skb = dev_alloc_skb(sizeof(struct ipw2100_rx)); if (!packet->skb) @@ -2215,7 +2246,6 @@ static inline int ipw2100_alloc_skb( return 0; } - #define SEARCH_ERROR 0xffffffff #define SEARCH_FAIL 0xfffffffe #define SEARCH_SUCCESS 0xfffffff0 @@ -2223,16 +2253,27 @@ static inline int ipw2100_alloc_skb( #define SEARCH_SNAPSHOT 1 #define SNAPSHOT_ADDR(ofs) (priv->snapshot[((ofs) >> 12) & 0xff] + ((ofs) & 0xfff)) -static inline int ipw2100_snapshot_alloc(struct ipw2100_priv *priv) +static void ipw2100_snapshot_free(struct ipw2100_priv *priv) +{ + int i; + if (!priv->snapshot[0]) + return; + for (i = 0; i < 0x30; i++) + kfree(priv->snapshot[i]); + priv->snapshot[0] = NULL; +} + +#ifdef IPW2100_DEBUG_C3 +static int ipw2100_snapshot_alloc(struct ipw2100_priv *priv) { int i; if (priv->snapshot[0]) return 1; for (i = 0; i < 0x30; i++) { - priv->snapshot[i] = (u8*)kmalloc(0x1000, GFP_ATOMIC); + priv->snapshot[i] = kmalloc(0x1000, GFP_ATOMIC); if (!priv->snapshot[i]) { IPW_DEBUG_INFO("%s: Error allocating snapshot " - "buffer %d\n", priv->net_dev->name, i); + "buffer %d\n", priv->net_dev->name, i); while (i > 0) kfree(priv->snapshot[--i]); priv->snapshot[0] = NULL; @@ -2243,17 +2284,7 @@ static inline int ipw2100_snapshot_alloc(struct ipw2100_priv *priv) return 1; } -static inline void ipw2100_snapshot_free(struct ipw2100_priv *priv) -{ - int i; - if (!priv->snapshot[0]) - return; - for (i = 0; i < 0x30; i++) - kfree(priv->snapshot[i]); - priv->snapshot[0] = NULL; -} - -static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf, +static u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 * in_buf, size_t len, int mode) { u32 i, j; @@ -2270,9 +2301,9 @@ static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf, for (ret = SEARCH_FAIL, i = 0; i < 0x30000; i += 4) { read_nic_dword(priv->net_dev, i, &tmp); if (mode == SEARCH_SNAPSHOT) - *(u32 *)SNAPSHOT_ADDR(i) = tmp; + *(u32 *) SNAPSHOT_ADDR(i) = tmp; if (ret == SEARCH_FAIL) { - d = (u8*)&tmp; + d = (u8 *) & tmp; for (j = 0; j < 4; j++) { if (*s != *d) { s = in_buf; @@ -2291,6 +2322,7 @@ static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf, return ret; } +#endif /* * @@ -2306,36 +2338,22 @@ static inline u32 ipw2100_match_buf(struct ipw2100_priv *priv, u8 *in_buf, * The size of the constructed ethernet * */ -#ifdef CONFIG_IPW2100_RX_DEBUG +#ifdef IPW2100_RX_DEBUG static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH]; #endif -static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, - int i) +static void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i) { -#ifdef CONFIG_IPW_DEBUG_C3 +#ifdef IPW2100_DEBUG_C3 struct ipw2100_status *status = &priv->status_queue.drv[i]; u32 match, reg; int j; #endif -#ifdef ACPI_CSTATE_LIMIT_DEFINED - int limit; -#endif - IPW_DEBUG_INFO(DRV_NAME ": PCI latency error detected at " - "0x%04zX.\n", i * sizeof(struct ipw2100_status)); - -#ifdef ACPI_CSTATE_LIMIT_DEFINED - IPW_DEBUG_INFO(DRV_NAME ": Disabling C3 transitions.\n"); - limit = acpi_get_cstate_limit(); - if (limit > 2) { - priv->cstate_limit = limit; - acpi_set_cstate_limit(2); - priv->config |= CFG_C3_DISABLED; - } -#endif + IPW_DEBUG_INFO(": PCI latency error detected at 0x%04zX.\n", + i * sizeof(struct ipw2100_status)); -#ifdef CONFIG_IPW_DEBUG_C3 +#ifdef IPW2100_DEBUG_C3 /* Halt the fimrware so we can get a good image */ write_register(priv->net_dev, IPW_REG_RESET_REG, IPW_AUX_HOST_RESET_REG_STOP_MASTER); @@ -2346,9 +2364,9 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) break; - } while (j--); + } while (j--); - match = ipw2100_match_buf(priv, (u8*)status, + match = ipw2100_match_buf(priv, (u8 *) status, sizeof(struct ipw2100_status), SEARCH_SNAPSHOT); if (match < SEARCH_SUCCESS) @@ -2360,7 +2378,7 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, IPW_DEBUG_INFO("%s: No DMA status match in " "Firmware.\n", priv->net_dev->name); - printk_buf((u8*)priv->status_queue.drv, + printk_buf((u8 *) priv->status_queue.drv, sizeof(struct ipw2100_status) * RX_QUEUE_LENGTH); #endif @@ -2369,7 +2387,7 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, schedule_reset(priv); } -static inline void isr_rx(struct ipw2100_priv *priv, int i, +static void isr_rx(struct ipw2100_priv *priv, int i, struct ieee80211_rx_stats *stats) { struct ipw2100_status *status = &priv->status_queue.drv[i]; @@ -2393,37 +2411,29 @@ static inline void isr_rx(struct ipw2100_priv *priv, int i, return; } - if (unlikely(priv->ieee->iw_mode == IW_MODE_MONITOR && - status->flags & IPW_STATUS_FLAG_CRC_ERROR)) { - IPW_DEBUG_RX("CRC error in packet. Dropping.\n"); - priv->ieee->stats.rx_errors++; - return; - } - if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR && - !(priv->status & STATUS_ASSOCIATED))) { + !(priv->status & STATUS_ASSOCIATED))) { IPW_DEBUG_DROP("Dropping packet while not associated.\n"); priv->wstats.discard.misc++; return; } - pci_unmap_single(priv->pci_dev, packet->dma_addr, - sizeof(struct ipw2100_rx), - PCI_DMA_FROMDEVICE); + sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE); skb_put(packet->skb, status->frame_size); -#ifdef CONFIG_IPW2100_RX_DEBUG +#ifdef IPW2100_RX_DEBUG /* Make a copy of the frame so we can dump it to the logs if * ieee80211_rx fails */ - memcpy(packet_data, packet->skb->data, - min_t(u32, status->frame_size, IPW_RX_NIC_BUFFER_LENGTH)); + skb_copy_from_linear_data(packet->skb, packet_data, + min_t(u32, status->frame_size, + IPW_RX_NIC_BUFFER_LENGTH)); #endif if (!ieee80211_rx(priv->ieee, packet->skb, stats)) { -#ifdef CONFIG_IPW2100_RX_DEBUG +#ifdef IPW2100_RX_DEBUG IPW_DEBUG_DROP("%s: Non consumed packet:\n", priv->net_dev->name); printk_buf(IPW_DL_DROP, packet_data, status->frame_size); @@ -2438,6 +2448,87 @@ static inline void isr_rx(struct ipw2100_priv *priv, int i, /* We need to allocate a new SKB and attach it to the RDB. */ if (unlikely(ipw2100_alloc_skb(priv, packet))) { printk(KERN_WARNING DRV_NAME ": " + "%s: Unable to allocate SKB onto RBD ring - disabling " + "adapter.\n", priv->net_dev->name); + /* TODO: schedule adapter shutdown */ + IPW_DEBUG_INFO("TODO: Shutdown adapter...\n"); + } + + /* Update the RDB entry */ + priv->rx_queue.drv[i].host_addr = packet->dma_addr; +} + +#ifdef CONFIG_IPW2100_MONITOR + +static void isr_rx_monitor(struct ipw2100_priv *priv, int i, + struct ieee80211_rx_stats *stats) +{ + struct ipw2100_status *status = &priv->status_queue.drv[i]; + struct ipw2100_rx_packet *packet = &priv->rx_buffers[i]; + + /* Magic struct that slots into the radiotap header -- no reason + * to build this manually element by element, we can write it much + * more efficiently than we can parse it. ORDER MATTERS HERE */ + struct ipw_rt_hdr { + struct ieee80211_radiotap_header rt_hdr; + s8 rt_dbmsignal; /* signal in dbM, kluged to signed */ + } *ipw_rt; + + IPW_DEBUG_RX("Handler...\n"); + + if (unlikely(status->frame_size > skb_tailroom(packet->skb) - + sizeof(struct ipw_rt_hdr))) { + IPW_DEBUG_INFO("%s: frame_size (%u) > skb_tailroom (%u)!" + " Dropping.\n", + priv->net_dev->name, + status->frame_size, + skb_tailroom(packet->skb)); + priv->ieee->stats.rx_errors++; + return; + } + + if (unlikely(!netif_running(priv->net_dev))) { + priv->ieee->stats.rx_errors++; + priv->wstats.discard.misc++; + IPW_DEBUG_DROP("Dropping packet while interface is not up.\n"); + return; + } + + if (unlikely(priv->config & CFG_CRC_CHECK && + status->flags & IPW_STATUS_FLAG_CRC_ERROR)) { + IPW_DEBUG_RX("CRC error in packet. Dropping.\n"); + priv->ieee->stats.rx_errors++; + return; + } + + pci_unmap_single(priv->pci_dev, packet->dma_addr, + sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE); + memmove(packet->skb->data + sizeof(struct ipw_rt_hdr), + packet->skb->data, status->frame_size); + + ipw_rt = (struct ipw_rt_hdr *) packet->skb->data; + + ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; + ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */ + ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct ipw_rt_hdr)); /* total hdr+data */ + + ipw_rt->rt_hdr.it_present = cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL); + + ipw_rt->rt_dbmsignal = status->rssi + IPW2100_RSSI_TO_DBM; + + skb_put(packet->skb, status->frame_size + sizeof(struct ipw_rt_hdr)); + + if (!ieee80211_rx(priv->ieee, packet->skb, stats)) { + priv->ieee->stats.rx_errors++; + + /* ieee80211_rx failed, so it didn't free the SKB */ + dev_kfree_skb_any(packet->skb); + packet->skb = NULL; + } + + /* We need to allocate a new SKB and attach it to the RDB. */ + if (unlikely(ipw2100_alloc_skb(priv, packet))) { + IPW_DEBUG_WARNING( "%s: Unable to allocate SKB onto RBD ring - disabling " "adapter.\n", priv->net_dev->name); /* TODO: schedule adapter shutdown */ @@ -2448,7 +2539,9 @@ static inline void isr_rx(struct ipw2100_priv *priv, int i, priv->rx_queue.drv[i].host_addr = packet->dma_addr; } -static inline int ipw2100_corruption_check(struct ipw2100_priv *priv, int i) +#endif + +static int ipw2100_corruption_check(struct ipw2100_priv *priv, int i) { struct ipw2100_status *status = &priv->status_queue.drv[i]; struct ipw2100_rx *u = priv->rx_buffers[i].rxp; @@ -2466,7 +2559,7 @@ static inline int ipw2100_corruption_check(struct ipw2100_priv *priv, int i) #ifdef CONFIG_IPW2100_MONITOR return 0; #else - switch (WLAN_FC_GET_TYPE(u->rx_data.header.frame_ctl)) { + switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { case IEEE80211_FTYPE_MGMT: case IEEE80211_FTYPE_CTL: return 0; @@ -2504,7 +2597,7 @@ static inline int ipw2100_corruption_check(struct ipw2100_priv *priv, int i) * The WRITE index is cached in the variable 'priv->rx_queue.next'. * */ -static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) +static void __ipw2100_rx_process(struct ipw2100_priv *priv) { struct ipw2100_bd_queue *rxq = &priv->rx_queue; struct ipw2100_status_queue *sq = &priv->status_queue; @@ -2534,11 +2627,11 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) /* Sync the DMA for the STATUS buffer so CPU is sure to get * the correct values */ - pci_dma_sync_single_for_cpu( - priv->pci_dev, - sq->nic + sizeof(struct ipw2100_status) * i, - sizeof(struct ipw2100_status), - PCI_DMA_FROMDEVICE); + pci_dma_sync_single_for_cpu(priv->pci_dev, + sq->nic + + sizeof(struct ipw2100_status) * i, + sizeof(struct ipw2100_status), + PCI_DMA_FROMDEVICE); /* Sync the DMA for the RX buffer so CPU is sure to get * the correct values */ @@ -2552,8 +2645,7 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) } u = packet->rxp; - frame_type = sq->drv[i].status_fields & - STATUS_TYPE_MASK; + frame_type = sq->drv[i].status_fields & STATUS_TYPE_MASK; stats.rssi = sq->drv[i].rssi + IPW2100_RSSI_TO_DBM; stats.len = sq->drv[i].frame_size; @@ -2562,16 +2654,14 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) stats.mask |= IEEE80211_STATMASK_RSSI; stats.freq = IEEE80211_24GHZ_BAND; - IPW_DEBUG_RX( - "%s: '%s' frame type received (%d).\n", - priv->net_dev->name, frame_types[frame_type], - stats.len); + IPW_DEBUG_RX("%s: '%s' frame type received (%d).\n", + priv->net_dev->name, frame_types[frame_type], + stats.len); switch (frame_type) { case COMMAND_STATUS_VAL: /* Reset Rx watchdog */ - isr_rx_complete_command( - priv, &u->rx_data.command); + isr_rx_complete_command(priv, &u->rx_data.command); break; case STATUS_CHANGE_VAL: @@ -2582,18 +2672,16 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) case P8023_DATA_VAL: #ifdef CONFIG_IPW2100_MONITOR if (priv->ieee->iw_mode == IW_MODE_MONITOR) { - isr_rx(priv, i, &stats); + isr_rx_monitor(priv, i, &stats); break; } #endif - if (stats.len < sizeof(u->rx_data.header)) + if (stats.len < sizeof(struct ieee80211_hdr_3addr)) break; - switch (WLAN_FC_GET_TYPE(u->rx_data.header. - frame_ctl)) { + switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { case IEEE80211_FTYPE_MGMT: ieee80211_rx_mgt(priv->ieee, - &u->rx_data.header, - &stats); + &u->rx_data.header, &stats); break; case IEEE80211_FTYPE_CTL: @@ -2607,7 +2695,7 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) break; } - increment: + increment: /* clear status field associated with this RBD */ rxq->drv[i].status.info.field = 0; @@ -2619,12 +2707,10 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) rxq->next = (i ? i : rxq->entries) - 1; write_register(priv->net_dev, - IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, - rxq->next); + IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, rxq->next); } } - /* * __ipw2100_tx_process * @@ -2664,10 +2750,10 @@ static inline void __ipw2100_rx_process(struct ipw2100_priv *priv) * for use by future command and data packets. * */ -static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) +static int __ipw2100_tx_process(struct ipw2100_priv *priv) { struct ipw2100_bd_queue *txq = &priv->tx_queue; - struct ipw2100_bd *tbd; + struct ipw2100_bd *tbd; struct list_head *element; struct ipw2100_tx_packet *packet; int descriptors_used; @@ -2680,7 +2766,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) element = priv->fw_pend_list.next; packet = list_entry(element, struct ipw2100_tx_packet, list); - tbd = &txq->drv[packet->index]; + tbd = &txq->drv[packet->index]; /* Determine how many TBD entries must be finished... */ switch (packet->type) { @@ -2693,14 +2779,14 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) case DATA: /* DATA uses two slots; advance and loop position. */ descriptors_used = tbd->num_fragments; - frag_num = tbd->num_fragments - 1; + frag_num = tbd->num_fragments - 1; e = txq->oldest + frag_num; e %= txq->entries; break; default: printk(KERN_WARNING DRV_NAME ": %s: Bad fw_pend_list entry!\n", - priv->net_dev->name); + priv->net_dev->name); return 0; } @@ -2716,13 +2802,12 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) printk(KERN_WARNING DRV_NAME ": %s: write index mismatch\n", priv->net_dev->name); - /* + /* * txq->next is the index of the last packet written txq->oldest is * the index of the r is the index of the next packet to be read by * firmware */ - /* * Quick graphic to help you visualize the following * if / else statement @@ -2747,26 +2832,23 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) list_del(element); DEC_STAT(&priv->fw_pend_stat); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG { int i = txq->oldest; - IPW_DEBUG_TX( - "TX%d V=%p P=%04X T=%04X L=%d\n", i, - &txq->drv[i], - (u32)(txq->nic + i * sizeof(struct ipw2100_bd)), - txq->drv[i].host_addr, - txq->drv[i].buf_length); + IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, + &txq->drv[i], + (u32) (txq->nic + i * sizeof(struct ipw2100_bd)), + txq->drv[i].host_addr, txq->drv[i].buf_length); if (packet->type == DATA) { i = (i + 1) % txq->entries; - IPW_DEBUG_TX( - "TX%d V=%p P=%04X T=%04X L=%d\n", i, - &txq->drv[i], - (u32)(txq->nic + i * - sizeof(struct ipw2100_bd)), - (u32)txq->drv[i].host_addr, - txq->drv[i].buf_length); + IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, + &txq->drv[i], + (u32) (txq->nic + i * + sizeof(struct ipw2100_bd)), + (u32) txq->drv[i].host_addr, + txq->drv[i].buf_length); } } #endif @@ -2780,23 +2862,18 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) priv->net_dev->name, txq->oldest, packet->index); /* DATA packet; we have to unmap and free the SKB */ - priv->ieee->stats.tx_packets++; for (i = 0; i < frag_num; i++) { - tbd = &txq->drv[(packet->index + 1 + i) % - txq->entries]; + tbd = &txq->drv[(packet->index + 1 + i) % txq->entries]; - IPW_DEBUG_TX( - "TX%d P=%08x L=%d\n", - (packet->index + 1 + i) % txq->entries, - tbd->host_addr, tbd->buf_length); + IPW_DEBUG_TX("TX%d P=%08x L=%d\n", + (packet->index + 1 + i) % txq->entries, + tbd->host_addr, tbd->buf_length); pci_unmap_single(priv->pci_dev, tbd->host_addr, - tbd->buf_length, - PCI_DMA_TODEVICE); + tbd->buf_length, PCI_DMA_TODEVICE); } - priv->ieee->stats.tx_bytes += packet->info.d_struct.txb->payload_size; ieee80211_txb_free(packet->info.d_struct.txb); packet->info.d_struct.txb = NULL; @@ -2805,13 +2882,8 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) /* We have a free slot in the Tx queue, so wake up the * transmit layer if it is stopped. */ - if (priv->status & STATUS_ASSOCIATED && - netif_queue_stopped(priv->net_dev)) { - IPW_DEBUG_INFO(KERN_INFO - "%s: Waking net queue.\n", - priv->net_dev->name); + if (priv->status & STATUS_ASSOCIATED) netif_wake_queue(priv->net_dev); - } /* A packet was processed by the hardware, so update the * watchdog */ @@ -2826,14 +2898,15 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) "something else: ids %d=%d.\n", priv->net_dev->name, txq->oldest, packet->index); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (packet->info.c_struct.cmd->host_command_reg < - sizeof(command_types) / sizeof(*command_types)) - IPW_DEBUG_TX( - "Command '%s (%d)' processed: %d.\n", - command_types[packet->info.c_struct.cmd->host_command_reg], - packet->info.c_struct.cmd->host_command_reg, - packet->info.c_struct.cmd->cmd_status_reg); + ARRAY_SIZE(command_types)) + IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n", + command_types[packet->info.c_struct.cmd-> + host_command_reg], + packet->info.c_struct.cmd-> + host_command_reg, + packet->info.c_struct.cmd->cmd_status_reg); #endif list_add_tail(element, &priv->msg_free_list); @@ -2848,17 +2921,17 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) SET_STAT(&priv->txq_stat, txq->available); IPW_DEBUG_TX("packet latency (send to process) %ld jiffies\n", - jiffies - packet->jiffy_start); + jiffies - packet->jiffy_start); return (!list_empty(&priv->fw_pend_list)); } - static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv) { int i = 0; - while (__ipw2100_tx_process(priv) && i < 200) i++; + while (__ipw2100_tx_process(priv) && i < 200) + i++; if (i == 200) { printk(KERN_WARNING DRV_NAME ": " @@ -2867,7 +2940,6 @@ static inline void __ipw2100_tx_complete(struct ipw2100_priv *priv) } } - static void ipw2100_tx_send_commands(struct ipw2100_priv *priv) { struct list_head *element; @@ -2892,13 +2964,12 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv) list_del(element); DEC_STAT(&priv->msg_pend_stat); - packet = list_entry(element, - struct ipw2100_tx_packet, list); + packet = list_entry(element, struct ipw2100_tx_packet, list); IPW_DEBUG_TX("using TBD at virt=%p, phys=%p\n", - &txq->drv[txq->next], - (void*)(txq->nic + txq->next * - sizeof(struct ipw2100_bd))); + &txq->drv[txq->next], + (void *)(txq->nic + txq->next * + sizeof(struct ipw2100_bd))); packet->index = txq->next; @@ -2911,8 +2982,8 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv) * with f/w debug version */ tbd->num_fragments = 1; tbd->status.info.field = - IPW_BD_STATUS_TX_FRAME_COMMAND | - IPW_BD_STATUS_TX_INTERRUPT_ENABLE; + IPW_BD_STATUS_TX_FRAME_COMMAND | + IPW_BD_STATUS_TX_INTERRUPT_ENABLE; /* update TBD queue counters */ txq->next++; @@ -2934,7 +3005,6 @@ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv) } } - /* * ipw2100_tx_send_data * @@ -2946,7 +3016,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) struct ipw2100_bd_queue *txq = &priv->tx_queue; struct ipw2100_bd *tbd; int next = txq->next; - int i = 0; + int i = 0; struct ipw2100_data_header *ipw_hdr; struct ieee80211_hdr_3addr *hdr; @@ -2958,20 +3028,18 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) * maintained between the r and w indexes */ element = priv->tx_pend_list.next; - packet = list_entry(element, struct ipw2100_tx_packet, list); + packet = list_entry(element, struct ipw2100_tx_packet, list); if (unlikely(1 + packet->info.d_struct.txb->nr_frags > IPW_MAX_BDS)) { /* TODO: Support merging buffers if more than * IPW_MAX_BDS are used */ - IPW_DEBUG_INFO( - "%s: Maximum BD theshold exceeded. " - "Increase fragmentation level.\n", - priv->net_dev->name); + IPW_DEBUG_INFO("%s: Maximum BD theshold exceeded. " + "Increase fragmentation level.\n", + priv->net_dev->name); } - if (txq->available <= 3 + - packet->info.d_struct.txb->nr_frags) { + if (txq->available <= 3 + packet->info.d_struct.txb->nr_frags) { IPW_DEBUG_TX("no room in tx_queue\n"); break; } @@ -2985,7 +3053,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) ipw_hdr = packet->info.d_struct.data; hdr = (struct ieee80211_hdr_3addr *)packet->info.d_struct.txb-> - fragments[0]->data; + fragments[0]->data; if (priv->ieee->iw_mode == IW_MODE_INFRA) { /* To DS: Addr1 = BSSID, Addr2 = SA, @@ -3007,7 +3075,8 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted; if (packet->info.d_struct.txb->nr_frags > 1) ipw_hdr->fragment_size = - packet->info.d_struct.txb->frag_size - IEEE80211_3ADDR_LEN; + packet->info.d_struct.txb->frag_size - + IEEE80211_3ADDR_LEN; else ipw_hdr->fragment_size = 0; @@ -3015,54 +3084,53 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) tbd->buf_length = sizeof(struct ipw2100_data_header); tbd->num_fragments = 1 + packet->info.d_struct.txb->nr_frags; tbd->status.info.field = - IPW_BD_STATUS_TX_FRAME_802_3 | - IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; + IPW_BD_STATUS_TX_FRAME_802_3 | + IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; txq->next++; txq->next %= txq->entries; - IPW_DEBUG_TX( - "data header tbd TX%d P=%08x L=%d\n", - packet->index, tbd->host_addr, - tbd->buf_length); -#ifdef CONFIG_IPW_DEBUG + IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n", + packet->index, tbd->host_addr, tbd->buf_length); +#ifdef CONFIG_IPW2100_DEBUG if (packet->info.d_struct.txb->nr_frags > 1) IPW_DEBUG_FRAG("fragment Tx: %d frames\n", packet->info.d_struct.txb->nr_frags); #endif - for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) { - tbd = &txq->drv[txq->next]; + for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) { + tbd = &txq->drv[txq->next]; if (i == packet->info.d_struct.txb->nr_frags - 1) tbd->status.info.field = - IPW_BD_STATUS_TX_FRAME_802_3 | - IPW_BD_STATUS_TX_INTERRUPT_ENABLE; + IPW_BD_STATUS_TX_FRAME_802_3 | + IPW_BD_STATUS_TX_INTERRUPT_ENABLE; else tbd->status.info.field = - IPW_BD_STATUS_TX_FRAME_802_3 | - IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; + IPW_BD_STATUS_TX_FRAME_802_3 | + IPW_BD_STATUS_TX_FRAME_NOT_LAST_FRAGMENT; tbd->buf_length = packet->info.d_struct.txb-> - fragments[i]->len - IEEE80211_3ADDR_LEN; + fragments[i]->len - IEEE80211_3ADDR_LEN; - tbd->host_addr = pci_map_single( - priv->pci_dev, - packet->info.d_struct.txb->fragments[i]->data + - IEEE80211_3ADDR_LEN, - tbd->buf_length, - PCI_DMA_TODEVICE); + tbd->host_addr = pci_map_single(priv->pci_dev, + packet->info.d_struct. + txb->fragments[i]-> + data + + IEEE80211_3ADDR_LEN, + tbd->buf_length, + PCI_DMA_TODEVICE); - IPW_DEBUG_TX( - "data frag tbd TX%d P=%08x L=%d\n", - txq->next, tbd->host_addr, tbd->buf_length); + IPW_DEBUG_TX("data frag tbd TX%d P=%08x L=%d\n", + txq->next, tbd->host_addr, + tbd->buf_length); - pci_dma_sync_single_for_device( - priv->pci_dev, tbd->host_addr, - tbd->buf_length, - PCI_DMA_TODEVICE); + pci_dma_sync_single_for_device(priv->pci_dev, + tbd->host_addr, + tbd->buf_length, + PCI_DMA_TODEVICE); txq->next++; txq->next %= txq->entries; - } + } txq->available -= 1 + packet->info.d_struct.txb->nr_frags; SET_STAT(&priv->txq_stat, txq->available); @@ -3078,7 +3146,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX, txq->next); } - return; + return; } static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) @@ -3106,11 +3174,9 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) if (inta & IPW2100_INTA_FATAL_ERROR) { printk(KERN_WARNING DRV_NAME - ": Fatal interrupt. Scheduling firmware restart.\n"); + ": Fatal interrupt. Scheduling firmware restart.\n"); priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_FATAL_ERROR); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_FATAL_ERROR); read_nic_dword(dev, IPW_NIC_FATAL_ERROR, &priv->fatal_error); IPW_DEBUG_INFO("%s: Fatal error value: 0x%08X\n", @@ -3125,11 +3191,10 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) } if (inta & IPW2100_INTA_PARITY_ERROR) { - printk(KERN_ERR DRV_NAME ": ***** PARITY ERROR INTERRUPT !!!! \n"); + printk(KERN_ERR DRV_NAME + ": ***** PARITY ERROR INTERRUPT !!!! \n"); priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_PARITY_ERROR); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_PARITY_ERROR); } if (inta & IPW2100_INTA_RX_TRANSFER) { @@ -3137,9 +3202,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) priv->rx_interrupts++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_RX_TRANSFER); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_RX_TRANSFER); __ipw2100_rx_process(priv); __ipw2100_tx_complete(priv); @@ -3150,8 +3213,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) priv->tx_interrupts++; - write_register(dev, IPW_REG_INTA, - IPW2100_INTA_TX_TRANSFER); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_TX_TRANSFER); __ipw2100_tx_complete(priv); ipw2100_tx_send_commands(priv); @@ -3161,9 +3223,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) if (inta & IPW2100_INTA_TX_COMPLETE) { IPW_DEBUG_ISR("TX complete\n"); priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_TX_COMPLETE); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_TX_COMPLETE); __ipw2100_tx_complete(priv); } @@ -3171,9 +3231,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) if (inta & IPW2100_INTA_EVENT_INTERRUPT) { /* ipw2100_handle_event(dev); */ priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_EVENT_INTERRUPT); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_EVENT_INTERRUPT); } if (inta & IPW2100_INTA_FW_INIT_DONE) { @@ -3183,30 +3241,25 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) read_register(dev, IPW_REG_INTA, &tmp); if (tmp & (IPW2100_INTA_FATAL_ERROR | IPW2100_INTA_PARITY_ERROR)) { - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_FATAL_ERROR | - IPW2100_INTA_PARITY_ERROR); + write_register(dev, IPW_REG_INTA, + IPW2100_INTA_FATAL_ERROR | + IPW2100_INTA_PARITY_ERROR); } - write_register(dev, IPW_REG_INTA, - IPW2100_INTA_FW_INIT_DONE); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_FW_INIT_DONE); } if (inta & IPW2100_INTA_STATUS_CHANGE) { IPW_DEBUG_ISR("Status change interrupt\n"); priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_STATUS_CHANGE); + write_register(dev, IPW_REG_INTA, IPW2100_INTA_STATUS_CHANGE); } if (inta & IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE) { IPW_DEBUG_ISR("slave host mode interrupt\n"); priv->inta_other++; - write_register( - dev, IPW_REG_INTA, - IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE); + write_register(dev, IPW_REG_INTA, + IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE); } priv->in_isr--; @@ -3217,9 +3270,7 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv) IPW_DEBUG_ISR("exit\n"); } - -static irqreturn_t ipw2100_interrupt(int irq, void *data, - struct pt_regs *regs) +static irqreturn_t ipw2100_interrupt(int irq, void *data) { struct ipw2100_priv *priv = data; u32 inta, inta_mask; @@ -3227,7 +3278,7 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data, if (!data) return IRQ_NONE; - spin_lock(&priv->low_lock); + spin_lock(&priv->low_lock); /* We check to see if we should be ignoring interrupts before * we touch the hardware. During ucode load if we try and handle @@ -3261,10 +3312,10 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data, ipw2100_disable_interrupts(priv); tasklet_schedule(&priv->irq_tasklet); - spin_unlock(&priv->low_lock); + spin_unlock(&priv->low_lock); return IRQ_HANDLED; - none: + none: spin_unlock(&priv->low_lock); return IRQ_NONE; } @@ -3294,10 +3345,8 @@ static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev, packet->info.d_struct.txb = txb; - IPW_DEBUG_TX("Sending fragment (%d bytes):\n", - txb->fragments[0]->len); - printk_buf(IPW_DL_TX, txb->fragments[0]->data, - txb->fragments[0]->len); + IPW_DEBUG_TX("Sending fragment (%d bytes):\n", txb->fragments[0]->len); + printk_buf(IPW_DL_TX, txb->fragments[0]->data, txb->fragments[0]->len); packet->jiffy_start = jiffies; @@ -3312,22 +3361,23 @@ static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev, spin_unlock_irqrestore(&priv->low_lock, flags); return 0; - fail_unlock: + fail_unlock: netif_stop_queue(dev); spin_unlock_irqrestore(&priv->low_lock, flags); return 1; } - static int ipw2100_msg_allocate(struct ipw2100_priv *priv) { int i, j, err = -EINVAL; void *v; dma_addr_t p; - priv->msg_buffers = (struct ipw2100_tx_packet *)kmalloc( - IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), - GFP_KERNEL); + priv->msg_buffers = + (struct ipw2100_tx_packet *)kmalloc(IPW_COMMAND_POOL_SIZE * + sizeof(struct + ipw2100_tx_packet), + GFP_KERNEL); if (!priv->msg_buffers) { printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg " "buffers.\n", priv->net_dev->name); @@ -3335,15 +3385,12 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) } for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) { - v = pci_alloc_consistent( - priv->pci_dev, - sizeof(struct ipw2100_cmd_header), - &p); + v = pci_alloc_consistent(priv->pci_dev, + sizeof(struct ipw2100_cmd_header), &p); if (!v) { printk(KERN_ERR DRV_NAME ": " "%s: PCI alloc failed for msg " - "buffers.\n", - priv->net_dev->name); + "buffers.\n", priv->net_dev->name); err = -ENOMEM; break; } @@ -3352,7 +3399,7 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) priv->msg_buffers[i].type = COMMAND; priv->msg_buffers[i].info.c_struct.cmd = - (struct ipw2100_cmd_header*)v; + (struct ipw2100_cmd_header *)v; priv->msg_buffers[i].info.c_struct.cmd_phys = p; } @@ -3360,11 +3407,11 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) return 0; for (j = 0; j < i; j++) { - pci_free_consistent( - priv->pci_dev, - sizeof(struct ipw2100_cmd_header), - priv->msg_buffers[j].info.c_struct.cmd, - priv->msg_buffers[j].info.c_struct.cmd_phys); + pci_free_consistent(priv->pci_dev, + sizeof(struct ipw2100_cmd_header), + priv->msg_buffers[j].info.c_struct.cmd, + priv->msg_buffers[j].info.c_struct. + cmd_phys); } kfree(priv->msg_buffers); @@ -3398,7 +3445,8 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv) pci_free_consistent(priv->pci_dev, sizeof(struct ipw2100_cmd_header), priv->msg_buffers[i].info.c_struct.cmd, - priv->msg_buffers[i].info.c_struct.cmd_phys); + priv->msg_buffers[i].info.c_struct. + cmd_phys); } kfree(priv->msg_buffers); @@ -3424,6 +3472,7 @@ static ssize_t show_pci(struct device *d, struct device_attribute *attr, return out - buf; } + static DEVICE_ATTR(pci, S_IRUGO, show_pci, NULL); static ssize_t show_cfg(struct device *d, struct device_attribute *attr, @@ -3432,214 +3481,274 @@ static ssize_t show_cfg(struct device *d, struct device_attribute *attr, struct ipw2100_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->config); } + static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL); static ssize_t show_status(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->status); } + static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); static ssize_t show_capability(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->capability); } -static DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL); +static DEVICE_ATTR(capability, S_IRUGO, show_capability, NULL); #define IPW2100_REG(x) { IPW_ ##x, #x } static const struct { u32 addr; const char *name; } hw_data[] = { - IPW2100_REG(REG_GP_CNTRL), - IPW2100_REG(REG_GPIO), - IPW2100_REG(REG_INTA), - IPW2100_REG(REG_INTA_MASK), - IPW2100_REG(REG_RESET_REG), -}; +IPW2100_REG(REG_GP_CNTRL), + IPW2100_REG(REG_GPIO), + IPW2100_REG(REG_INTA), + IPW2100_REG(REG_INTA_MASK), IPW2100_REG(REG_RESET_REG),}; #define IPW2100_NIC(x, s) { x, #x, s } static const struct { u32 addr; const char *name; size_t size; } nic_data[] = { - IPW2100_NIC(IPW2100_CONTROL_REG, 2), - IPW2100_NIC(0x210014, 1), - IPW2100_NIC(0x210000, 1), -}; +IPW2100_NIC(IPW2100_CONTROL_REG, 2), + IPW2100_NIC(0x210014, 1), IPW2100_NIC(0x210000, 1),}; #define IPW2100_ORD(x, d) { IPW_ORD_ ##x, #x, d } static const struct { u8 index; const char *name; const char *desc; } ord_data[] = { - IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"), - IPW2100_ORD(STAT_TX_HOST_COMPLETE, "successful Host Tx's (MSDU)"), - IPW2100_ORD(STAT_TX_DIR_DATA, "successful Directed Tx's (MSDU)"), - IPW2100_ORD(STAT_TX_DIR_DATA1, "successful Directed Tx's (MSDU) @ 1MB"), - IPW2100_ORD(STAT_TX_DIR_DATA2, "successful Directed Tx's (MSDU) @ 2MB"), - IPW2100_ORD(STAT_TX_DIR_DATA5_5, "successful Directed Tx's (MSDU) @ 5_5MB"), - IPW2100_ORD(STAT_TX_DIR_DATA11, "successful Directed Tx's (MSDU) @ 11MB"), - IPW2100_ORD(STAT_TX_NODIR_DATA1, "successful Non_Directed Tx's (MSDU) @ 1MB"), - IPW2100_ORD(STAT_TX_NODIR_DATA2, "successful Non_Directed Tx's (MSDU) @ 2MB"), - IPW2100_ORD(STAT_TX_NODIR_DATA5_5, "successful Non_Directed Tx's (MSDU) @ 5.5MB"), - IPW2100_ORD(STAT_TX_NODIR_DATA11, "successful Non_Directed Tx's (MSDU) @ 11MB"), - IPW2100_ORD(STAT_NULL_DATA, "successful NULL data Tx's"), - IPW2100_ORD(STAT_TX_RTS, "successful Tx RTS"), - IPW2100_ORD(STAT_TX_CTS, "successful Tx CTS"), - IPW2100_ORD(STAT_TX_ACK, "successful Tx ACK"), - IPW2100_ORD(STAT_TX_ASSN, "successful Association Tx's"), - IPW2100_ORD(STAT_TX_ASSN_RESP, "successful Association response Tx's"), - IPW2100_ORD(STAT_TX_REASSN, "successful Reassociation Tx's"), - IPW2100_ORD(STAT_TX_REASSN_RESP, "successful Reassociation response Tx's"), - IPW2100_ORD(STAT_TX_PROBE, "probes successfully transmitted"), - IPW2100_ORD(STAT_TX_PROBE_RESP, "probe responses successfully transmitted"), - IPW2100_ORD(STAT_TX_BEACON, "tx beacon"), - IPW2100_ORD(STAT_TX_ATIM, "Tx ATIM"), - IPW2100_ORD(STAT_TX_DISASSN, "successful Disassociation TX"), - IPW2100_ORD(STAT_TX_AUTH, "successful Authentication Tx"), - IPW2100_ORD(STAT_TX_DEAUTH, "successful Deauthentication TX"), - IPW2100_ORD(STAT_TX_TOTAL_BYTES, "Total successful Tx data bytes"), - IPW2100_ORD(STAT_TX_RETRIES, "Tx retries"), - IPW2100_ORD(STAT_TX_RETRY1, "Tx retries at 1MBPS"), - IPW2100_ORD(STAT_TX_RETRY2, "Tx retries at 2MBPS"), - IPW2100_ORD(STAT_TX_RETRY5_5, "Tx retries at 5.5MBPS"), - IPW2100_ORD(STAT_TX_RETRY11, "Tx retries at 11MBPS"), - IPW2100_ORD(STAT_TX_FAILURES, "Tx Failures"), - IPW2100_ORD(STAT_TX_MAX_TRIES_IN_HOP,"times max tries in a hop failed"), - IPW2100_ORD(STAT_TX_DISASSN_FAIL, "times disassociation failed"), - IPW2100_ORD(STAT_TX_ERR_CTS, "missed/bad CTS frames"), - IPW2100_ORD(STAT_TX_ERR_ACK, "tx err due to acks"), - IPW2100_ORD(STAT_RX_HOST, "packets passed to host"), - IPW2100_ORD(STAT_RX_DIR_DATA, "directed packets"), - IPW2100_ORD(STAT_RX_DIR_DATA1, "directed packets at 1MB"), - IPW2100_ORD(STAT_RX_DIR_DATA2, "directed packets at 2MB"), - IPW2100_ORD(STAT_RX_DIR_DATA5_5, "directed packets at 5.5MB"), - IPW2100_ORD(STAT_RX_DIR_DATA11, "directed packets at 11MB"), - IPW2100_ORD(STAT_RX_NODIR_DATA,"nondirected packets"), - IPW2100_ORD(STAT_RX_NODIR_DATA1, "nondirected packets at 1MB"), - IPW2100_ORD(STAT_RX_NODIR_DATA2, "nondirected packets at 2MB"), - IPW2100_ORD(STAT_RX_NODIR_DATA5_5, "nondirected packets at 5.5MB"), - IPW2100_ORD(STAT_RX_NODIR_DATA11, "nondirected packets at 11MB"), - IPW2100_ORD(STAT_RX_NULL_DATA, "null data rx's"), - IPW2100_ORD(STAT_RX_RTS, "Rx RTS"), - IPW2100_ORD(STAT_RX_CTS, "Rx CTS"), - IPW2100_ORD(STAT_RX_ACK, "Rx ACK"), - IPW2100_ORD(STAT_RX_CFEND, "Rx CF End"), - IPW2100_ORD(STAT_RX_CFEND_ACK, "Rx CF End + CF Ack"), - IPW2100_ORD(STAT_RX_ASSN, "Association Rx's"), - IPW2100_ORD(STAT_RX_ASSN_RESP, "Association response Rx's"), - IPW2100_ORD(STAT_RX_REASSN, "Reassociation Rx's"), - IPW2100_ORD(STAT_RX_REASSN_RESP, "Reassociation response Rx's"), - IPW2100_ORD(STAT_RX_PROBE, "probe Rx's"), - IPW2100_ORD(STAT_RX_PROBE_RESP, "probe response Rx's"), - IPW2100_ORD(STAT_RX_BEACON, "Rx beacon"), - IPW2100_ORD(STAT_RX_ATIM, "Rx ATIM"), - IPW2100_ORD(STAT_RX_DISASSN, "disassociation Rx"), - IPW2100_ORD(STAT_RX_AUTH, "authentication Rx"), - IPW2100_ORD(STAT_RX_DEAUTH, "deauthentication Rx"), - IPW2100_ORD(STAT_RX_TOTAL_BYTES,"Total rx data bytes received"), - IPW2100_ORD(STAT_RX_ERR_CRC, "packets with Rx CRC error"), - IPW2100_ORD(STAT_RX_ERR_CRC1, "Rx CRC errors at 1MB"), - IPW2100_ORD(STAT_RX_ERR_CRC2, "Rx CRC errors at 2MB"), - IPW2100_ORD(STAT_RX_ERR_CRC5_5, "Rx CRC errors at 5.5MB"), - IPW2100_ORD(STAT_RX_ERR_CRC11, "Rx CRC errors at 11MB"), - IPW2100_ORD(STAT_RX_DUPLICATE1, "duplicate rx packets at 1MB"), - IPW2100_ORD(STAT_RX_DUPLICATE2, "duplicate rx packets at 2MB"), - IPW2100_ORD(STAT_RX_DUPLICATE5_5, "duplicate rx packets at 5.5MB"), - IPW2100_ORD(STAT_RX_DUPLICATE11, "duplicate rx packets at 11MB"), - IPW2100_ORD(STAT_RX_DUPLICATE, "duplicate rx packets"), - IPW2100_ORD(PERS_DB_LOCK, "locking fw permanent db"), - IPW2100_ORD(PERS_DB_SIZE, "size of fw permanent db"), - IPW2100_ORD(PERS_DB_ADDR, "address of fw permanent db"), - IPW2100_ORD(STAT_RX_INVALID_PROTOCOL, "rx frames with invalid protocol"), - IPW2100_ORD(SYS_BOOT_TIME, "Boot time"), - IPW2100_ORD(STAT_RX_NO_BUFFER, "rx frames rejected due to no buffer"), - IPW2100_ORD(STAT_RX_MISSING_FRAG, "rx frames dropped due to missing fragment"), - IPW2100_ORD(STAT_RX_ORPHAN_FRAG, "rx frames dropped due to non-sequential fragment"), - IPW2100_ORD(STAT_RX_ORPHAN_FRAME, "rx frames dropped due to unmatched 1st frame"), - IPW2100_ORD(STAT_RX_FRAG_AGEOUT, "rx frames dropped due to uncompleted frame"), - IPW2100_ORD(STAT_RX_ICV_ERRORS, "ICV errors during decryption"), - IPW2100_ORD(STAT_PSP_SUSPENSION,"times adapter suspended"), - IPW2100_ORD(STAT_PSP_BCN_TIMEOUT, "beacon timeout"), - IPW2100_ORD(STAT_PSP_POLL_TIMEOUT, "poll response timeouts"), - IPW2100_ORD(STAT_PSP_NONDIR_TIMEOUT, "timeouts waiting for last {broad,multi}cast pkt"), - IPW2100_ORD(STAT_PSP_RX_DTIMS, "PSP DTIMs received"), - IPW2100_ORD(STAT_PSP_RX_TIMS, "PSP TIMs received"), - IPW2100_ORD(STAT_PSP_STATION_ID,"PSP Station ID"), - IPW2100_ORD(LAST_ASSN_TIME, "RTC time of last association"), - IPW2100_ORD(STAT_PERCENT_MISSED_BCNS,"current calculation of % missed beacons"), - IPW2100_ORD(STAT_PERCENT_RETRIES,"current calculation of % missed tx retries"), - IPW2100_ORD(ASSOCIATED_AP_PTR, "0 if not associated, else pointer to AP table entry"), - IPW2100_ORD(AVAILABLE_AP_CNT, "AP's decsribed in the AP table"), - IPW2100_ORD(AP_LIST_PTR, "Ptr to list of available APs"), - IPW2100_ORD(STAT_AP_ASSNS, "associations"), - IPW2100_ORD(STAT_ASSN_FAIL, "association failures"), - IPW2100_ORD(STAT_ASSN_RESP_FAIL,"failures due to response fail"), - IPW2100_ORD(STAT_FULL_SCANS, "full scans"), - IPW2100_ORD(CARD_DISABLED, "Card Disabled"), - IPW2100_ORD(STAT_ROAM_INHIBIT, "times roaming was inhibited due to activity"), - IPW2100_ORD(RSSI_AT_ASSN, "RSSI of associated AP at time of association"), - IPW2100_ORD(STAT_ASSN_CAUSE1, "reassociation: no probe response or TX on hop"), - IPW2100_ORD(STAT_ASSN_CAUSE2, "reassociation: poor tx/rx quality"), - IPW2100_ORD(STAT_ASSN_CAUSE3, "reassociation: tx/rx quality (excessive AP load"), - IPW2100_ORD(STAT_ASSN_CAUSE4, "reassociation: AP RSSI level"), - IPW2100_ORD(STAT_ASSN_CAUSE5, "reassociations due to load leveling"), - IPW2100_ORD(STAT_AUTH_FAIL, "times authentication failed"), - IPW2100_ORD(STAT_AUTH_RESP_FAIL,"times authentication response failed"), - IPW2100_ORD(STATION_TABLE_CNT, "entries in association table"), - IPW2100_ORD(RSSI_AVG_CURR, "Current avg RSSI"), - IPW2100_ORD(POWER_MGMT_MODE, "Power mode - 0=CAM, 1=PSP"), - IPW2100_ORD(COUNTRY_CODE, "IEEE country code as recv'd from beacon"), - IPW2100_ORD(COUNTRY_CHANNELS, "channels suported by country"), - IPW2100_ORD(RESET_CNT, "adapter resets (warm)"), - IPW2100_ORD(BEACON_INTERVAL, "Beacon interval"), - IPW2100_ORD(ANTENNA_DIVERSITY, "TRUE if antenna diversity is disabled"), - IPW2100_ORD(DTIM_PERIOD, "beacon intervals between DTIMs"), - IPW2100_ORD(OUR_FREQ, "current radio freq lower digits - channel ID"), - IPW2100_ORD(RTC_TIME, "current RTC time"), - IPW2100_ORD(PORT_TYPE, "operating mode"), - IPW2100_ORD(CURRENT_TX_RATE, "current tx rate"), - IPW2100_ORD(SUPPORTED_RATES, "supported tx rates"), - IPW2100_ORD(ATIM_WINDOW, "current ATIM Window"), - IPW2100_ORD(BASIC_RATES, "basic tx rates"), - IPW2100_ORD(NIC_HIGHEST_RATE, "NIC highest tx rate"), - IPW2100_ORD(AP_HIGHEST_RATE, "AP highest tx rate"), - IPW2100_ORD(CAPABILITIES, "Management frame capability field"), - IPW2100_ORD(AUTH_TYPE, "Type of authentication"), - IPW2100_ORD(RADIO_TYPE, "Adapter card platform type"), - IPW2100_ORD(RTS_THRESHOLD, "Min packet length for RTS handshaking"), - IPW2100_ORD(INT_MODE, "International mode"), - IPW2100_ORD(FRAGMENTATION_THRESHOLD, "protocol frag threshold"), - IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_START_ADDRESS, "EEPROM offset in SRAM"), - IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_SIZE, "EEPROM size in SRAM"), - IPW2100_ORD(EEPROM_SKU_CAPABILITY, "EEPROM SKU Capability"), - IPW2100_ORD(EEPROM_IBSS_11B_CHANNELS, "EEPROM IBSS 11b channel set"), - IPW2100_ORD(MAC_VERSION, "MAC Version"), - IPW2100_ORD(MAC_REVISION, "MAC Revision"), - IPW2100_ORD(RADIO_VERSION, "Radio Version"), - IPW2100_ORD(NIC_MANF_DATE_TIME, "MANF Date/Time STAMP"), - IPW2100_ORD(UCODE_VERSION, "Ucode Version"), -}; - +IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"), + IPW2100_ORD(STAT_TX_HOST_COMPLETE, + "successful Host Tx's (MSDU)"), + IPW2100_ORD(STAT_TX_DIR_DATA, + "successful Directed Tx's (MSDU)"), + IPW2100_ORD(STAT_TX_DIR_DATA1, + "successful Directed Tx's (MSDU) @ 1MB"), + IPW2100_ORD(STAT_TX_DIR_DATA2, + "successful Directed Tx's (MSDU) @ 2MB"), + IPW2100_ORD(STAT_TX_DIR_DATA5_5, + "successful Directed Tx's (MSDU) @ 5_5MB"), + IPW2100_ORD(STAT_TX_DIR_DATA11, + "successful Directed Tx's (MSDU) @ 11MB"), + IPW2100_ORD(STAT_TX_NODIR_DATA1, + "successful Non_Directed Tx's (MSDU) @ 1MB"), + IPW2100_ORD(STAT_TX_NODIR_DATA2, + "successful Non_Directed Tx's (MSDU) @ 2MB"), + IPW2100_ORD(STAT_TX_NODIR_DATA5_5, + "successful Non_Directed Tx's (MSDU) @ 5.5MB"), + IPW2100_ORD(STAT_TX_NODIR_DATA11, + "successful Non_Directed Tx's (MSDU) @ 11MB"), + IPW2100_ORD(STAT_NULL_DATA, "successful NULL data Tx's"), + IPW2100_ORD(STAT_TX_RTS, "successful Tx RTS"), + IPW2100_ORD(STAT_TX_CTS, "successful Tx CTS"), + IPW2100_ORD(STAT_TX_ACK, "successful Tx ACK"), + IPW2100_ORD(STAT_TX_ASSN, "successful Association Tx's"), + IPW2100_ORD(STAT_TX_ASSN_RESP, + "successful Association response Tx's"), + IPW2100_ORD(STAT_TX_REASSN, + "successful Reassociation Tx's"), + IPW2100_ORD(STAT_TX_REASSN_RESP, + "successful Reassociation response Tx's"), + IPW2100_ORD(STAT_TX_PROBE, + "probes successfully transmitted"), + IPW2100_ORD(STAT_TX_PROBE_RESP, + "probe responses successfully transmitted"), + IPW2100_ORD(STAT_TX_BEACON, "tx beacon"), + IPW2100_ORD(STAT_TX_ATIM, "Tx ATIM"), + IPW2100_ORD(STAT_TX_DISASSN, + "successful Disassociation TX"), + IPW2100_ORD(STAT_TX_AUTH, "successful Authentication Tx"), + IPW2100_ORD(STAT_TX_DEAUTH, + "successful Deauthentication TX"), + IPW2100_ORD(STAT_TX_TOTAL_BYTES, + "Total successful Tx data bytes"), + IPW2100_ORD(STAT_TX_RETRIES, "Tx retries"), + IPW2100_ORD(STAT_TX_RETRY1, "Tx retries at 1MBPS"), + IPW2100_ORD(STAT_TX_RETRY2, "Tx retries at 2MBPS"), + IPW2100_ORD(STAT_TX_RETRY5_5, "Tx retries at 5.5MBPS"), + IPW2100_ORD(STAT_TX_RETRY11, "Tx retries at 11MBPS"), + IPW2100_ORD(STAT_TX_FAILURES, "Tx Failures"), + IPW2100_ORD(STAT_TX_MAX_TRIES_IN_HOP, + "times max tries in a hop failed"), + IPW2100_ORD(STAT_TX_DISASSN_FAIL, + "times disassociation failed"), + IPW2100_ORD(STAT_TX_ERR_CTS, "missed/bad CTS frames"), + IPW2100_ORD(STAT_TX_ERR_ACK, "tx err due to acks"), + IPW2100_ORD(STAT_RX_HOST, "packets passed to host"), + IPW2100_ORD(STAT_RX_DIR_DATA, "directed packets"), + IPW2100_ORD(STAT_RX_DIR_DATA1, "directed packets at 1MB"), + IPW2100_ORD(STAT_RX_DIR_DATA2, "directed packets at 2MB"), + IPW2100_ORD(STAT_RX_DIR_DATA5_5, + "directed packets at 5.5MB"), + IPW2100_ORD(STAT_RX_DIR_DATA11, "directed packets at 11MB"), + IPW2100_ORD(STAT_RX_NODIR_DATA, "nondirected packets"), + IPW2100_ORD(STAT_RX_NODIR_DATA1, + "nondirected packets at 1MB"), + IPW2100_ORD(STAT_RX_NODIR_DATA2, + "nondirected packets at 2MB"), + IPW2100_ORD(STAT_RX_NODIR_DATA5_5, + "nondirected packets at 5.5MB"), + IPW2100_ORD(STAT_RX_NODIR_DATA11, + "nondirected packets at 11MB"), + IPW2100_ORD(STAT_RX_NULL_DATA, "null data rx's"), + IPW2100_ORD(STAT_RX_RTS, "Rx RTS"), IPW2100_ORD(STAT_RX_CTS, + "Rx CTS"), + IPW2100_ORD(STAT_RX_ACK, "Rx ACK"), + IPW2100_ORD(STAT_RX_CFEND, "Rx CF End"), + IPW2100_ORD(STAT_RX_CFEND_ACK, "Rx CF End + CF Ack"), + IPW2100_ORD(STAT_RX_ASSN, "Association Rx's"), + IPW2100_ORD(STAT_RX_ASSN_RESP, "Association response Rx's"), + IPW2100_ORD(STAT_RX_REASSN, "Reassociation Rx's"), + IPW2100_ORD(STAT_RX_REASSN_RESP, + "Reassociation response Rx's"), + IPW2100_ORD(STAT_RX_PROBE, "probe Rx's"), + IPW2100_ORD(STAT_RX_PROBE_RESP, "probe response Rx's"), + IPW2100_ORD(STAT_RX_BEACON, "Rx beacon"), + IPW2100_ORD(STAT_RX_ATIM, "Rx ATIM"), + IPW2100_ORD(STAT_RX_DISASSN, "disassociation Rx"), + IPW2100_ORD(STAT_RX_AUTH, "authentication Rx"), + IPW2100_ORD(STAT_RX_DEAUTH, "deauthentication Rx"), + IPW2100_ORD(STAT_RX_TOTAL_BYTES, + "Total rx data bytes received"), + IPW2100_ORD(STAT_RX_ERR_CRC, "packets with Rx CRC error"), + IPW2100_ORD(STAT_RX_ERR_CRC1, "Rx CRC errors at 1MB"), + IPW2100_ORD(STAT_RX_ERR_CRC2, "Rx CRC errors at 2MB"), + IPW2100_ORD(STAT_RX_ERR_CRC5_5, "Rx CRC errors at 5.5MB"), + IPW2100_ORD(STAT_RX_ERR_CRC11, "Rx CRC errors at 11MB"), + IPW2100_ORD(STAT_RX_DUPLICATE1, + "duplicate rx packets at 1MB"), + IPW2100_ORD(STAT_RX_DUPLICATE2, + "duplicate rx packets at 2MB"), + IPW2100_ORD(STAT_RX_DUPLICATE5_5, + "duplicate rx packets at 5.5MB"), + IPW2100_ORD(STAT_RX_DUPLICATE11, + "duplicate rx packets at 11MB"), + IPW2100_ORD(STAT_RX_DUPLICATE, "duplicate rx packets"), + IPW2100_ORD(PERS_DB_LOCK, "locking fw permanent db"), + IPW2100_ORD(PERS_DB_SIZE, "size of fw permanent db"), + IPW2100_ORD(PERS_DB_ADDR, "address of fw permanent db"), + IPW2100_ORD(STAT_RX_INVALID_PROTOCOL, + "rx frames with invalid protocol"), + IPW2100_ORD(SYS_BOOT_TIME, "Boot time"), + IPW2100_ORD(STAT_RX_NO_BUFFER, + "rx frames rejected due to no buffer"), + IPW2100_ORD(STAT_RX_MISSING_FRAG, + "rx frames dropped due to missing fragment"), + IPW2100_ORD(STAT_RX_ORPHAN_FRAG, + "rx frames dropped due to non-sequential fragment"), + IPW2100_ORD(STAT_RX_ORPHAN_FRAME, + "rx frames dropped due to unmatched 1st frame"), + IPW2100_ORD(STAT_RX_FRAG_AGEOUT, + "rx frames dropped due to uncompleted frame"), + IPW2100_ORD(STAT_RX_ICV_ERRORS, + "ICV errors during decryption"), + IPW2100_ORD(STAT_PSP_SUSPENSION, "times adapter suspended"), + IPW2100_ORD(STAT_PSP_BCN_TIMEOUT, "beacon timeout"), + IPW2100_ORD(STAT_PSP_POLL_TIMEOUT, + "poll response timeouts"), + IPW2100_ORD(STAT_PSP_NONDIR_TIMEOUT, + "timeouts waiting for last {broad,multi}cast pkt"), + IPW2100_ORD(STAT_PSP_RX_DTIMS, "PSP DTIMs received"), + IPW2100_ORD(STAT_PSP_RX_TIMS, "PSP TIMs received"), + IPW2100_ORD(STAT_PSP_STATION_ID, "PSP Station ID"), + IPW2100_ORD(LAST_ASSN_TIME, "RTC time of last association"), + IPW2100_ORD(STAT_PERCENT_MISSED_BCNS, + "current calculation of % missed beacons"), + IPW2100_ORD(STAT_PERCENT_RETRIES, + "current calculation of % missed tx retries"), + IPW2100_ORD(ASSOCIATED_AP_PTR, + "0 if not associated, else pointer to AP table entry"), + IPW2100_ORD(AVAILABLE_AP_CNT, + "AP's decsribed in the AP table"), + IPW2100_ORD(AP_LIST_PTR, "Ptr to list of available APs"), + IPW2100_ORD(STAT_AP_ASSNS, "associations"), + IPW2100_ORD(STAT_ASSN_FAIL, "association failures"), + IPW2100_ORD(STAT_ASSN_RESP_FAIL, + "failures due to response fail"), + IPW2100_ORD(STAT_FULL_SCANS, "full scans"), + IPW2100_ORD(CARD_DISABLED, "Card Disabled"), + IPW2100_ORD(STAT_ROAM_INHIBIT, + "times roaming was inhibited due to activity"), + IPW2100_ORD(RSSI_AT_ASSN, + "RSSI of associated AP at time of association"), + IPW2100_ORD(STAT_ASSN_CAUSE1, + "reassociation: no probe response or TX on hop"), + IPW2100_ORD(STAT_ASSN_CAUSE2, + "reassociation: poor tx/rx quality"), + IPW2100_ORD(STAT_ASSN_CAUSE3, + "reassociation: tx/rx quality (excessive AP load"), + IPW2100_ORD(STAT_ASSN_CAUSE4, + "reassociation: AP RSSI level"), + IPW2100_ORD(STAT_ASSN_CAUSE5, + "reassociations due to load leveling"), + IPW2100_ORD(STAT_AUTH_FAIL, "times authentication failed"), + IPW2100_ORD(STAT_AUTH_RESP_FAIL, + "times authentication response failed"), + IPW2100_ORD(STATION_TABLE_CNT, + "entries in association table"), + IPW2100_ORD(RSSI_AVG_CURR, "Current avg RSSI"), + IPW2100_ORD(POWER_MGMT_MODE, "Power mode - 0=CAM, 1=PSP"), + IPW2100_ORD(COUNTRY_CODE, + "IEEE country code as recv'd from beacon"), + IPW2100_ORD(COUNTRY_CHANNELS, + "channels suported by country"), + IPW2100_ORD(RESET_CNT, "adapter resets (warm)"), + IPW2100_ORD(BEACON_INTERVAL, "Beacon interval"), + IPW2100_ORD(ANTENNA_DIVERSITY, + "TRUE if antenna diversity is disabled"), + IPW2100_ORD(DTIM_PERIOD, "beacon intervals between DTIMs"), + IPW2100_ORD(OUR_FREQ, + "current radio freq lower digits - channel ID"), + IPW2100_ORD(RTC_TIME, "current RTC time"), + IPW2100_ORD(PORT_TYPE, "operating mode"), + IPW2100_ORD(CURRENT_TX_RATE, "current tx rate"), + IPW2100_ORD(SUPPORTED_RATES, "supported tx rates"), + IPW2100_ORD(ATIM_WINDOW, "current ATIM Window"), + IPW2100_ORD(BASIC_RATES, "basic tx rates"), + IPW2100_ORD(NIC_HIGHEST_RATE, "NIC highest tx rate"), + IPW2100_ORD(AP_HIGHEST_RATE, "AP highest tx rate"), + IPW2100_ORD(CAPABILITIES, + "Management frame capability field"), + IPW2100_ORD(AUTH_TYPE, "Type of authentication"), + IPW2100_ORD(RADIO_TYPE, "Adapter card platform type"), + IPW2100_ORD(RTS_THRESHOLD, + "Min packet length for RTS handshaking"), + IPW2100_ORD(INT_MODE, "International mode"), + IPW2100_ORD(FRAGMENTATION_THRESHOLD, + "protocol frag threshold"), + IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_START_ADDRESS, + "EEPROM offset in SRAM"), + IPW2100_ORD(EEPROM_SRAM_DB_BLOCK_SIZE, + "EEPROM size in SRAM"), + IPW2100_ORD(EEPROM_SKU_CAPABILITY, "EEPROM SKU Capability"), + IPW2100_ORD(EEPROM_IBSS_11B_CHANNELS, + "EEPROM IBSS 11b channel set"), + IPW2100_ORD(MAC_VERSION, "MAC Version"), + IPW2100_ORD(MAC_REVISION, "MAC Revision"), + IPW2100_ORD(RADIO_VERSION, "Radio Version"), + IPW2100_ORD(NIC_MANF_DATE_TIME, "MANF Date/Time STAMP"), + IPW2100_ORD(UCODE_VERSION, "Ucode Version"),}; static ssize_t show_registers(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { int i; struct ipw2100_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; - char * out = buf; + char *out = buf; u32 val = 0; out += sprintf(out, "%30s [Address ] : Hex\n", "Register"); - for (i = 0; i < (sizeof(hw_data) / sizeof(*hw_data)); i++) { + for (i = 0; i < ARRAY_SIZE(hw_data); i++) { read_register(dev, hw_data[i].addr, &val); out += sprintf(out, "%30s [%08X] : %08X\n", hw_data[i].name, hw_data[i].addr, val); @@ -3647,20 +3756,20 @@ static ssize_t show_registers(struct device *d, struct device_attribute *attr, return out - buf; } -static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL); +static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL); static ssize_t show_hardware(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; - char * out = buf; + char *out = buf; int i; out += sprintf(out, "%30s [Address ] : Hex\n", "NIC entry"); - for (i = 0; i < (sizeof(nic_data) / sizeof(*nic_data)); i++) { + for (i = 0; i < ARRAY_SIZE(nic_data); i++) { u8 tmp8; u16 tmp16; u32 tmp32; @@ -3688,11 +3797,11 @@ static ssize_t show_hardware(struct device *d, struct device_attribute *attr, } return out - buf; } -static DEVICE_ATTR(hardware, S_IRUGO, show_hardware, NULL); +static DEVICE_ATTR(hardware, S_IRUGO, show_hardware, NULL); static ssize_t show_memory(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; @@ -3708,10 +3817,13 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr, /* sysfs provides us PAGE_SIZE buffer */ while (len < PAGE_SIZE - 128 && loop < 0x30000) { - if (priv->snapshot[0]) for (i = 0; i < 4; i++) - buffer[i] = *(u32 *)SNAPSHOT_ADDR(loop + i * 4); - else for (i = 0; i < 4; i++) - read_nic_dword(dev, loop + i * 4, &buffer[i]); + if (priv->snapshot[0]) + for (i = 0; i < 4; i++) + buffer[i] = + *(u32 *) SNAPSHOT_ADDR(loop + i * 4); + else + for (i = 0; i < 4; i++) + read_nic_dword(dev, loop + i * 4, &buffer[i]); if (priv->dump_raw) len += sprintf(buf + len, @@ -3719,26 +3831,26 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr, "%c%c%c%c" "%c%c%c%c" "%c%c%c%c", - ((u8*)buffer)[0x0], - ((u8*)buffer)[0x1], - ((u8*)buffer)[0x2], - ((u8*)buffer)[0x3], - ((u8*)buffer)[0x4], - ((u8*)buffer)[0x5], - ((u8*)buffer)[0x6], - ((u8*)buffer)[0x7], - ((u8*)buffer)[0x8], - ((u8*)buffer)[0x9], - ((u8*)buffer)[0xa], - ((u8*)buffer)[0xb], - ((u8*)buffer)[0xc], - ((u8*)buffer)[0xd], - ((u8*)buffer)[0xe], - ((u8*)buffer)[0xf]); + ((u8 *) buffer)[0x0], + ((u8 *) buffer)[0x1], + ((u8 *) buffer)[0x2], + ((u8 *) buffer)[0x3], + ((u8 *) buffer)[0x4], + ((u8 *) buffer)[0x5], + ((u8 *) buffer)[0x6], + ((u8 *) buffer)[0x7], + ((u8 *) buffer)[0x8], + ((u8 *) buffer)[0x9], + ((u8 *) buffer)[0xa], + ((u8 *) buffer)[0xb], + ((u8 *) buffer)[0xc], + ((u8 *) buffer)[0xd], + ((u8 *) buffer)[0xe], + ((u8 *) buffer)[0xf]); else len += sprintf(buf + len, "%s\n", snprint_line(line, sizeof(line), - (u8*)buffer, 16, loop)); + (u8 *) buffer, 16, loop)); loop += 16; } @@ -3746,44 +3858,44 @@ static ssize_t show_memory(struct device *d, struct device_attribute *attr, } static ssize_t store_memory(struct device *d, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct ipw2100_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; const char *p = buf; + (void)dev; /* kill unused-var warning for debug-only code */ + if (count < 1) return count; if (p[0] == '1' || (count >= 2 && tolower(p[0]) == 'o' && tolower(p[1]) == 'n')) { IPW_DEBUG_INFO("%s: Setting memory dump to RAW mode.\n", - dev->name); + dev->name); priv->dump_raw = 1; } else if (p[0] == '0' || (count >= 2 && tolower(p[0]) == 'o' && - tolower(p[1]) == 'f')) { + tolower(p[1]) == 'f')) { IPW_DEBUG_INFO("%s: Setting memory dump to HEX mode.\n", - dev->name); + dev->name); priv->dump_raw = 0; } else if (tolower(p[0]) == 'r') { - IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", - dev->name); + IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", dev->name); ipw2100_snapshot_free(priv); } else IPW_DEBUG_INFO("%s: Usage: 0|on = HEX, 1|off = RAW, " - "reset = clear memory snapshot\n", - dev->name); + "reset = clear memory snapshot\n", dev->name); return count; } -static DEVICE_ATTR(memory, S_IWUSR|S_IRUGO, show_memory, store_memory); +static DEVICE_ATTR(memory, S_IWUSR | S_IRUGO, show_memory, store_memory); static ssize_t show_ordinals(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); u32 val = 0; @@ -3791,13 +3903,14 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr, u32 val_len; static int loop = 0; - if (loop >= sizeof(ord_data) / sizeof(*ord_data)) + if (priv->status & STATUS_RF_KILL_MASK) + return 0; + + if (loop >= ARRAY_SIZE(ord_data)) loop = 0; /* sysfs provides us PAGE_SIZE buffer */ - while (len < PAGE_SIZE - 128 && - loop < (sizeof(ord_data) / sizeof(*ord_data))) { - + while (len < PAGE_SIZE - 128 && loop < ARRAY_SIZE(ord_data)) { val_len = sizeof(u32); if (ipw2100_get_ordinal(priv, ord_data[loop].index, &val, @@ -3814,29 +3927,29 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr, return len; } -static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL); +static DEVICE_ATTR(ordinals, S_IRUGO, show_ordinals, NULL); static ssize_t show_stats(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); - char * out = buf; + char *out = buf; out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n", priv->interrupts, priv->tx_interrupts, priv->rx_interrupts, priv->inta_other); out += sprintf(out, "firmware resets: %d\n", priv->resets); out += sprintf(out, "firmware hangs: %d\n", priv->hangs); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG out += sprintf(out, "packet mismatch image: %s\n", priv->snapshot[0] ? "YES" : "NO"); #endif return out - buf; } -static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); +static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode) { @@ -3862,21 +3975,20 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode) #ifdef CONFIG_IPW2100_MONITOR case IW_MODE_MONITOR: priv->last_mode = priv->ieee->iw_mode; - priv->net_dev->type = ARPHRD_IEEE80211; + priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; break; -#endif /* CONFIG_IPW2100_MONITOR */ +#endif /* CONFIG_IPW2100_MONITOR */ } priv->ieee->iw_mode = mode; #ifdef CONFIG_PM - /* Indicate ipw2100_download_firmware download firmware + /* Indicate ipw2100_download_firmware download firmware * from disk instead of memory. */ ipw2100_firmware.version = 0; #endif - printk(KERN_INFO "%s: Reseting on mode change.\n", - priv->net_dev->name); + printk(KERN_INFO "%s: Reseting on mode change.\n", priv->net_dev->name); priv->reset_backoff = 0; schedule_reset(priv); @@ -3884,12 +3996,12 @@ static int ipw2100_switch_mode(struct ipw2100_priv *priv, u32 mode) } static ssize_t show_internals(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); int len = 0; -#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" # y "\n", priv-> x) +#define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x) if (priv->status & STATUS_ASSOCIATED) len += sprintf(buf + len, "connected: %lu\n", @@ -3897,54 +4009,60 @@ static ssize_t show_internals(struct device *d, struct device_attribute *attr, else len += sprintf(buf + len, "not connected\n"); - DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], p); - DUMP_VAR(status, 08lx); - DUMP_VAR(config, 08lx); - DUMP_VAR(capability, 08lx); + DUMP_VAR(ieee->crypt[priv->ieee->tx_keyidx], "p"); + DUMP_VAR(status, "08lx"); + DUMP_VAR(config, "08lx"); + DUMP_VAR(capability, "08lx"); - len += sprintf(buf + len, "last_rtc: %lu\n", (unsigned long)priv->last_rtc); + len += + sprintf(buf + len, "last_rtc: %lu\n", + (unsigned long)priv->last_rtc); - DUMP_VAR(fatal_error, d); - DUMP_VAR(stop_hang_check, d); - DUMP_VAR(stop_rf_kill, d); - DUMP_VAR(messages_sent, d); + DUMP_VAR(fatal_error, "d"); + DUMP_VAR(stop_hang_check, "d"); + DUMP_VAR(stop_rf_kill, "d"); + DUMP_VAR(messages_sent, "d"); - DUMP_VAR(tx_pend_stat.value, d); - DUMP_VAR(tx_pend_stat.hi, d); + DUMP_VAR(tx_pend_stat.value, "d"); + DUMP_VAR(tx_pend_stat.hi, "d"); - DUMP_VAR(tx_free_stat.value, d); - DUMP_VAR(tx_free_stat.lo, d); + DUMP_VAR(tx_free_stat.value, "d"); + DUMP_VAR(tx_free_stat.lo, "d"); - DUMP_VAR(msg_free_stat.value, d); - DUMP_VAR(msg_free_stat.lo, d); + DUMP_VAR(msg_free_stat.value, "d"); + DUMP_VAR(msg_free_stat.lo, "d"); - DUMP_VAR(msg_pend_stat.value, d); - DUMP_VAR(msg_pend_stat.hi, d); + DUMP_VAR(msg_pend_stat.value, "d"); + DUMP_VAR(msg_pend_stat.hi, "d"); - DUMP_VAR(fw_pend_stat.value, d); - DUMP_VAR(fw_pend_stat.hi, d); + DUMP_VAR(fw_pend_stat.value, "d"); + DUMP_VAR(fw_pend_stat.hi, "d"); - DUMP_VAR(txq_stat.value, d); - DUMP_VAR(txq_stat.lo, d); + DUMP_VAR(txq_stat.value, "d"); + DUMP_VAR(txq_stat.lo, "d"); - DUMP_VAR(ieee->scans, d); - DUMP_VAR(reset_backoff, d); + DUMP_VAR(ieee->scans, "d"); + DUMP_VAR(reset_backoff, "d"); return len; } -static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL); +static DEVICE_ATTR(internals, S_IRUGO, show_internals, NULL); static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); char essid[IW_ESSID_MAX_SIZE + 1]; u8 bssid[ETH_ALEN]; u32 chan = 0; - char * out = buf; + char *out = buf; int length; int ret; + DECLARE_MAC_BUF(mac); + + if (priv->status & STATUS_RF_KILL_MASK) + return 0; memset(essid, 0, sizeof(essid)); memset(bssid, 0, sizeof(bssid)); @@ -3969,24 +4087,22 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr, __LINE__); out += sprintf(out, "ESSID: %s\n", essid); - out += sprintf(out, "BSSID: %02x:%02x:%02x:%02x:%02x:%02x\n", - bssid[0], bssid[1], bssid[2], - bssid[3], bssid[4], bssid[5]); + out += sprintf(out, "BSSID: %s\n", print_mac(mac, bssid)); out += sprintf(out, "Channel: %d\n", chan); return out - buf; } -static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL); +static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static ssize_t show_debug_level(struct device_driver *d, char *buf) { return sprintf(buf, "0x%08X\n", ipw2100_debug_level); } -static ssize_t store_debug_level(struct device_driver *d, const char *buf, - size_t count) +static ssize_t store_debug_level(struct device_driver *d, + const char *buf, size_t count) { char *p = (char *)buf; u32 val; @@ -3999,28 +4115,26 @@ static ssize_t store_debug_level(struct device_driver *d, const char *buf, } else val = simple_strtoul(p, &p, 10); if (p == buf) - IPW_DEBUG_INFO(DRV_NAME - ": %s is not in hex or decimal form.\n", buf); + IPW_DEBUG_INFO(": %s is not in hex or decimal form.\n", buf); else ipw2100_debug_level = val; return strnlen(buf, count); } + static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, store_debug_level); -#endif /* CONFIG_IPW_DEBUG */ - +#endif /* CONFIG_IPW2100_DEBUG */ static ssize_t show_fatal_error(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); char *out = buf; int i; if (priv->fatal_error) - out += sprintf(out, "0x%08X\n", - priv->fatal_error); + out += sprintf(out, "0x%08X\n", priv->fatal_error); else out += sprintf(out, "0\n"); @@ -4038,24 +4152,26 @@ static ssize_t show_fatal_error(struct device *d, } static ssize_t store_fatal_error(struct device *d, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { struct ipw2100_priv *priv = dev_get_drvdata(d); schedule_reset(priv); return count; } -static DEVICE_ATTR(fatal_error, S_IWUSR|S_IRUGO, show_fatal_error, store_fatal_error); +static DEVICE_ATTR(fatal_error, S_IWUSR | S_IRUGO, show_fatal_error, + store_fatal_error); static ssize_t show_scan_age(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { struct ipw2100_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d\n", priv->ieee->scan_age); } static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct ipw2100_priv *priv = dev_get_drvdata(d); struct net_device *dev = priv->net_dev; @@ -4065,6 +4181,8 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, unsigned long val; char *p = buffer; + (void)dev; /* kill unused-var warning for debug-only code */ + IPW_DEBUG_INFO("enter\n"); strncpy(buffer, buf, len); @@ -4078,8 +4196,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, } else val = simple_strtoul(p, &p, 10); if (p == buffer) { - IPW_DEBUG_INFO("%s: user supplied invalid value.\n", - dev->name); + IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name); } else { priv->ieee->scan_age = val; IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); @@ -4088,11 +4205,11 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, IPW_DEBUG_INFO("exit\n"); return len; } -static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age); +static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age); static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { /* 0 - RF kill not enabled 1 - SW based RF kill active (sysfs) @@ -4100,7 +4217,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 3 - Both HW and SW baed RF kill active */ struct ipw2100_priv *priv = (struct ipw2100_priv *)d->driver_data; int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | - (rf_kill_active(priv) ? 0x2 : 0x0); + (rf_kill_active(priv) ? 0x2 : 0x0); return sprintf(buf, "%i\n", val); } @@ -4108,12 +4225,12 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) { if ((disable_radio ? 1 : 0) == (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) - return 0 ; + return 0; IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", disable_radio ? "OFF" : "ON"); - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (disable_radio) { priv->status |= STATUS_RF_KILL_SW; @@ -4127,24 +4244,24 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) priv->stop_rf_kill = 0; cancel_delayed_work(&priv->rf_kill); queue_delayed_work(priv->workqueue, &priv->rf_kill, - HZ); + round_jiffies_relative(HZ)); } else schedule_reset(priv); } - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); return 1; } static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct ipw2100_priv *priv = dev_get_drvdata(d); ipw_radio_kill_sw(priv, buf[0] == '1'); return count; } -static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill); +static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill); static struct attribute *ipw2100_sysfs_entries[] = { &dev_attr_hardware.attr, @@ -4168,7 +4285,6 @@ static struct attribute_group ipw2100_attribute_group = { .attrs = ipw2100_sysfs_entries, }; - static int status_queue_allocate(struct ipw2100_priv *priv, int entries) { struct ipw2100_status_queue *q = &priv->status_queue; @@ -4176,11 +4292,11 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries) IPW_DEBUG_INFO("enter\n"); q->size = entries * sizeof(struct ipw2100_status); - q->drv = (struct ipw2100_status *)pci_alloc_consistent( - priv->pci_dev, q->size, &q->nic); + q->drv = + (struct ipw2100_status *)pci_alloc_consistent(priv->pci_dev, + q->size, &q->nic); if (!q->drv) { - IPW_DEBUG_WARNING( - "Can not allocate status queue.\n"); + IPW_DEBUG_WARNING("Can not allocate status queue.\n"); return -ENOMEM; } @@ -4196,9 +4312,9 @@ static void status_queue_free(struct ipw2100_priv *priv) IPW_DEBUG_INFO("enter\n"); if (priv->status_queue.drv) { - pci_free_consistent( - priv->pci_dev, priv->status_queue.size, - priv->status_queue.drv, priv->status_queue.nic); + pci_free_consistent(priv->pci_dev, priv->status_queue.size, + priv->status_queue.drv, + priv->status_queue.nic); priv->status_queue.drv = NULL; } @@ -4216,7 +4332,8 @@ static int bd_queue_allocate(struct ipw2100_priv *priv, q->size = entries * sizeof(struct ipw2100_bd); q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic); if (!q->drv) { - IPW_DEBUG_INFO("can't allocate shared memory for buffer descriptors\n"); + IPW_DEBUG_INFO + ("can't allocate shared memory for buffer descriptors\n"); return -ENOMEM; } memset(q->drv, 0, q->size); @@ -4226,8 +4343,7 @@ static int bd_queue_allocate(struct ipw2100_priv *priv, return 0; } -static void bd_queue_free(struct ipw2100_priv *priv, - struct ipw2100_bd_queue *q) +static void bd_queue_free(struct ipw2100_priv *priv, struct ipw2100_bd_queue *q) { IPW_DEBUG_INFO("enter\n"); @@ -4235,21 +4351,21 @@ static void bd_queue_free(struct ipw2100_priv *priv, return; if (q->drv) { - pci_free_consistent(priv->pci_dev, - q->size, q->drv, q->nic); + pci_free_consistent(priv->pci_dev, q->size, q->drv, q->nic); q->drv = NULL; } IPW_DEBUG_INFO("exit\n"); } -static void bd_queue_initialize( - struct ipw2100_priv *priv, struct ipw2100_bd_queue * q, - u32 base, u32 size, u32 r, u32 w) +static void bd_queue_initialize(struct ipw2100_priv *priv, + struct ipw2100_bd_queue *q, u32 base, u32 size, + u32 r, u32 w) { IPW_DEBUG_INFO("enter\n"); - IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, (u32)q->nic); + IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, + (u32) q->nic); write_register(priv->net_dev, base, q->nic); write_register(priv->net_dev, size, q->entries); @@ -4269,6 +4385,7 @@ static void ipw2100_kill_workqueue(struct ipw2100_priv *priv) cancel_delayed_work(&priv->wx_event_work); cancel_delayed_work(&priv->hang_check); cancel_delayed_work(&priv->rf_kill); + cancel_delayed_work(&priv->scan_event_later); destroy_workqueue(priv->workqueue); priv->workqueue = NULL; } @@ -4285,32 +4402,38 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH); if (err) { IPW_DEBUG_ERROR("%s: failed bd_queue_allocate\n", - priv->net_dev->name); + priv->net_dev->name); return err; } - priv->tx_buffers = (struct ipw2100_tx_packet *)kmalloc( - TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet), - GFP_ATOMIC); + priv->tx_buffers = + (struct ipw2100_tx_packet *)kmalloc(TX_PENDED_QUEUE_LENGTH * + sizeof(struct + ipw2100_tx_packet), + GFP_ATOMIC); if (!priv->tx_buffers) { - printk(KERN_ERR DRV_NAME ": %s: alloc failed form tx buffers.\n", + printk(KERN_ERR DRV_NAME + ": %s: alloc failed form tx buffers.\n", priv->net_dev->name); bd_queue_free(priv, &priv->tx_queue); return -ENOMEM; } for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { - v = pci_alloc_consistent( - priv->pci_dev, sizeof(struct ipw2100_data_header), &p); + v = pci_alloc_consistent(priv->pci_dev, + sizeof(struct ipw2100_data_header), + &p); if (!v) { - printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for tx " - "buffers.\n", priv->net_dev->name); + printk(KERN_ERR DRV_NAME + ": %s: PCI alloc failed for tx " "buffers.\n", + priv->net_dev->name); err = -ENOMEM; break; } priv->tx_buffers[i].type = DATA; - priv->tx_buffers[i].info.d_struct.data = (struct ipw2100_data_header*)v; + priv->tx_buffers[i].info.d_struct.data = + (struct ipw2100_data_header *)v; priv->tx_buffers[i].info.d_struct.data_phys = p; priv->tx_buffers[i].info.d_struct.txb = NULL; } @@ -4319,11 +4442,11 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) return 0; for (j = 0; j < i; j++) { - pci_free_consistent( - priv->pci_dev, - sizeof(struct ipw2100_data_header), - priv->tx_buffers[j].info.d_struct.data, - priv->tx_buffers[j].info.d_struct.data_phys); + pci_free_consistent(priv->pci_dev, + sizeof(struct ipw2100_data_header), + priv->tx_buffers[j].info.d_struct.data, + priv->tx_buffers[j].info.d_struct. + data_phys); } kfree(priv->tx_buffers); @@ -4356,7 +4479,8 @@ static void ipw2100_tx_initialize(struct ipw2100_priv *priv) /* We simply drop any SKBs that have been queued for * transmit */ if (priv->tx_buffers[i].info.d_struct.txb) { - ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); + ieee80211_txb_free(priv->tx_buffers[i].info.d_struct. + txb); priv->tx_buffers[i].info.d_struct.txb = NULL; } @@ -4394,15 +4518,17 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv) for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) { if (priv->tx_buffers[i].info.d_struct.txb) { - ieee80211_txb_free(priv->tx_buffers[i].info.d_struct.txb); + ieee80211_txb_free(priv->tx_buffers[i].info.d_struct. + txb); priv->tx_buffers[i].info.d_struct.txb = NULL; } if (priv->tx_buffers[i].info.d_struct.data) - pci_free_consistent( - priv->pci_dev, - sizeof(struct ipw2100_data_header), - priv->tx_buffers[i].info.d_struct.data, - priv->tx_buffers[i].info.d_struct.data_phys); + pci_free_consistent(priv->pci_dev, + sizeof(struct ipw2100_data_header), + priv->tx_buffers[i].info.d_struct. + data, + priv->tx_buffers[i].info.d_struct. + data_phys); } kfree(priv->tx_buffers); @@ -4411,8 +4537,6 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv) IPW_DEBUG_INFO("exit\n"); } - - static int ipw2100_rx_allocate(struct ipw2100_priv *priv) { int i, j, err = -EINVAL; @@ -4538,20 +4662,20 @@ static void ipw2100_rx_free(struct ipw2100_priv *priv) static int ipw2100_read_mac_address(struct ipw2100_priv *priv) { u32 length = ETH_ALEN; - u8 mac[ETH_ALEN]; + u8 addr[ETH_ALEN]; + DECLARE_MAC_BUF(mac); int err; - err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, - mac, &length); + err = ipw2100_get_ordinal(priv, IPW_ORD_STAT_ADAPTER_MAC, addr, &length); if (err) { IPW_DEBUG_INFO("MAC address read failed\n"); return -EIO; } - IPW_DEBUG_INFO("card MAC is %02X:%02X:%02X:%02X:%02X:%02X\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - memcpy(priv->net_dev->dev_addr, mac, ETH_ALEN); + memcpy(priv->net_dev->dev_addr, addr, ETH_ALEN); + IPW_DEBUG_INFO("card MAC is %s\n", + print_mac(mac, priv->net_dev->dev_addr)); return 0; } @@ -4576,8 +4700,7 @@ static int ipw2100_set_mac_address(struct ipw2100_priv *priv, int batch_mode) IPW_DEBUG_INFO("enter\n"); if (priv->config & CFG_CUSTOM_MAC) { - memcpy(cmd.host_command_parameters, priv->mac_addr, - ETH_ALEN); + memcpy(cmd.host_command_parameters, priv->mac_addr, ETH_ALEN); memcpy(priv->net_dev->dev_addr, priv->mac_addr, ETH_ALEN); } else memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr, @@ -4614,7 +4737,8 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type, if (!batch_mode) { err = ipw2100_disable_adapter(priv); if (err) { - printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", + printk(KERN_ERR DRV_NAME + ": %s: Could not disable adapter %d\n", priv->net_dev->name, err); return err; } @@ -4629,7 +4753,6 @@ static int ipw2100_set_port_type(struct ipw2100_priv *priv, u32 port_type, return err; } - static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel, int batch_mode) { @@ -4660,8 +4783,7 @@ static int ipw2100_set_channel(struct ipw2100_priv *priv, u32 channel, err = ipw2100_hw_send_command(priv, &cmd); if (err) { - IPW_DEBUG_INFO("Failed to set channel to %d", - channel); + IPW_DEBUG_INFO("Failed to set channel to %d", channel); return err; } @@ -4703,15 +4825,14 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode) cmd.host_command_parameters[0] |= IPW_CFG_IBSS_AUTO_START; cmd.host_command_parameters[0] |= IPW_CFG_IBSS_MASK | - IPW_CFG_BSS_MASK | - IPW_CFG_802_1x_ENABLE; + IPW_CFG_BSS_MASK | IPW_CFG_802_1x_ENABLE; if (!(priv->config & CFG_LONG_PREAMBLE)) cmd.host_command_parameters[0] |= IPW_CFG_PREAMBLE_AUTO; err = ipw2100_get_ordinal(priv, IPW_ORD_EEPROM_IBSS_11B_CHANNELS, - &ibss_mask, &len); + &ibss_mask, &len); if (err) ibss_mask = IPW_IBSS_11B_DEFAULT_MASK; @@ -4719,7 +4840,7 @@ static int ipw2100_system_config(struct ipw2100_priv *priv, int batch_mode) cmd.host_command_parameters[2] = REG_CHANNEL_MASK & ibss_mask; /* 11b only */ - /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A;*/ + /*cmd.host_command_parameters[0] |= DIVERSITY_ANTENNA_A; */ err = ipw2100_hw_send_command(priv, &cmd); if (err) @@ -4783,8 +4904,7 @@ static int ipw2100_set_tx_rates(struct ipw2100_priv *priv, u32 rate, return 0; } -static int ipw2100_set_power_mode(struct ipw2100_priv *priv, - int power_level) +static int ipw2100_set_power_mode(struct ipw2100_priv *priv, int power_level) { struct host_command cmd = { .host_command = POWER_MODE, @@ -4804,12 +4924,11 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv, else priv->power_mode = IPW_POWER_ENABLED | power_level; -#ifdef CONFIG_IPW2100_TX_POWER - if (priv->port_type == IBSS && - priv->adhoc_power != DFTL_IBSS_TX_POWER) { +#ifdef IPW2100_TX_POWER + if (priv->port_type == IBSS && priv->adhoc_power != DFTL_IBSS_TX_POWER) { /* Set beacon interval */ cmd.host_command = TX_POWER_INDEX; - cmd.host_command_parameters[0] = (u32)priv->adhoc_power; + cmd.host_command_parameters[0] = (u32) priv->adhoc_power; err = ipw2100_hw_send_command(priv, &cmd); if (err) @@ -4820,7 +4939,6 @@ static int ipw2100_set_power_mode(struct ipw2100_priv *priv, return 0; } - static int ipw2100_set_rts_threshold(struct ipw2100_priv *priv, u32 threshold) { struct host_command cmd = { @@ -4925,8 +5043,7 @@ static int ipw2100_set_long_retry(struct ipw2100_priv *priv, u32 retry) return 0; } - -static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid, +static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 * bssid, int batch_mode) { struct host_command cmd = { @@ -4936,18 +5053,17 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid, }; int err; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG + DECLARE_MAC_BUF(mac); if (bssid != NULL) - IPW_DEBUG_HC( - "MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", - bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], - bssid[5]); + IPW_DEBUG_HC("MANDATORY_BSSID: %s\n", + print_mac(mac, bssid)); else IPW_DEBUG_HC("MANDATORY_BSSID: \n"); #endif /* if BSSID is empty then we disable mandatory bssid mode */ if (bssid != NULL) - memcpy((u8 *)cmd.host_command_parameters, bssid, ETH_ALEN); + memcpy(cmd.host_command_parameters, bssid, ETH_ALEN); if (!batch_mode) { err = ipw2100_disable_adapter(priv); @@ -4963,7 +5079,6 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 *bssid, return err; } -#ifdef CONFIG_IEEE80211_WPA static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv) { struct host_command cmd = { @@ -4987,42 +5102,10 @@ static int ipw2100_disassociate_bssid(struct ipw2100_priv *priv) return err; } -#endif - -/* - * Pseudo code for setting up wpa_frame: - */ -#if 0 -void x(struct ieee80211_assoc_frame *wpa_assoc) -{ - struct ipw2100_wpa_assoc_frame frame; - frame->fixed_ie_mask = IPW_WPA_CAPABILTIES | - IPW_WPA_LISTENINTERVAL | - IPW_WPA_AP_ADDRESS; - frame->capab_info = wpa_assoc->capab_info; - frame->lisen_interval = wpa_assoc->listent_interval; - memcpy(frame->current_ap, wpa_assoc->current_ap, ETH_ALEN); - - /* UNKNOWN -- I'm not postivive about this part; don't have any WPA - * setup here to test it with. - * - * Walk the IEs in the wpa_assoc and figure out the total size of all - * that data. Stick that into frame->var_ie_len. Then memcpy() all of - * the IEs from wpa_frame into frame. - */ - frame->var_ie_len = calculate_ie_len(wpa_assoc); - memcpy(frame->var_ie, wpa_assoc->variable, frame->var_ie_len); - - ipw2100_set_wpa_ie(priv, &frame, 0); -} -#endif - - - static int ipw2100_set_wpa_ie(struct ipw2100_priv *, struct ipw2100_wpa_assoc_frame *, int) -__attribute__ ((unused)); + __attribute__ ((unused)); static int ipw2100_set_wpa_ie(struct ipw2100_priv *priv, struct ipw2100_wpa_assoc_frame *wpa_frame, @@ -5076,7 +5159,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv, .host_command_length = sizeof(struct security_info_params) }; struct security_info_params *security = - (struct security_info_params *)&cmd.host_command_parameters; + (struct security_info_params *)&cmd.host_command_parameters; int err; memset(security, 0, sizeof(*security)); @@ -5094,25 +5177,25 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv, break; case SEC_LEVEL_1: security->allowed_ciphers = IPW_WEP40_CIPHER | - IPW_WEP104_CIPHER; + IPW_WEP104_CIPHER; break; case SEC_LEVEL_2: security->allowed_ciphers = IPW_WEP40_CIPHER | - IPW_WEP104_CIPHER | IPW_TKIP_CIPHER; + IPW_WEP104_CIPHER | IPW_TKIP_CIPHER; break; case SEC_LEVEL_2_CKIP: security->allowed_ciphers = IPW_WEP40_CIPHER | - IPW_WEP104_CIPHER | IPW_CKIP_CIPHER; + IPW_WEP104_CIPHER | IPW_CKIP_CIPHER; break; case SEC_LEVEL_3: security->allowed_ciphers = IPW_WEP40_CIPHER | - IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER; + IPW_WEP104_CIPHER | IPW_TKIP_CIPHER | IPW_CCMP_CIPHER; break; } - IPW_DEBUG_HC( - "SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n", - security->auth_mode, security->allowed_ciphers, security_level); + IPW_DEBUG_HC + ("SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n", + security->auth_mode, security->allowed_ciphers, security_level); security->replay_counters_number = 0; @@ -5130,8 +5213,7 @@ static int ipw2100_set_security_information(struct ipw2100_priv *priv, return err; } -static int ipw2100_set_tx_power(struct ipw2100_priv *priv, - u32 tx_power) +static int ipw2100_set_tx_power(struct ipw2100_priv *priv, u32 tx_power) { struct host_command cmd = { .host_command = TX_POWER_INDEX, @@ -5139,8 +5221,13 @@ static int ipw2100_set_tx_power(struct ipw2100_priv *priv, .host_command_length = 4 }; int err = 0; + u32 tmp = tx_power; - cmd.host_command_parameters[0] = tx_power; + if (tx_power != IPW_TX_POWER_DEFAULT) + tmp = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 / + (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM); + + cmd.host_command_parameters[0] = tmp; if (priv->ieee->iw_mode == IW_MODE_ADHOC) err = ipw2100_hw_send_command(priv, &cmd); @@ -5185,7 +5272,6 @@ static int ipw2100_set_ibss_beacon_interval(struct ipw2100_priv *priv, return 0; } - void ipw2100_queues_initialize(struct ipw2100_priv *priv) { ipw2100_tx_initialize(priv); @@ -5203,13 +5289,12 @@ void ipw2100_queues_free(struct ipw2100_priv *priv) int ipw2100_queues_allocate(struct ipw2100_priv *priv) { if (ipw2100_tx_allocate(priv) || - ipw2100_rx_allocate(priv) || - ipw2100_msg_allocate(priv)) + ipw2100_rx_allocate(priv) || ipw2100_msg_allocate(priv)) goto fail; return 0; - fail: + fail: ipw2100_tx_free(priv); ipw2100_rx_free(priv); ipw2100_msg_free(priv); @@ -5235,7 +5320,8 @@ static int ipw2100_set_wep_flags(struct ipw2100_priv *priv, u32 flags, if (!batch_mode) { err = ipw2100_disable_adapter(priv); if (err) { - printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", + printk(KERN_ERR DRV_NAME + ": %s: Could not disable adapter %d\n", priv->net_dev->name, err); return err; } @@ -5262,7 +5348,6 @@ struct ipw2100_wep_key { #define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4] #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] - /** * Set a the wep key * @@ -5287,14 +5372,14 @@ static int ipw2100_set_key(struct ipw2100_priv *priv, .host_command_sequence = 0, .host_command_length = sizeof(struct ipw2100_wep_key), }; - struct ipw2100_wep_key *wep_key = (void*)cmd.host_command_parameters; + struct ipw2100_wep_key *wep_key = (void *)cmd.host_command_parameters; int err; IPW_DEBUG_HC("WEP_KEY_INFO: index = %d, len = %d/%d\n", - idx, keylen, len); + idx, keylen, len); /* NOTE: We don't check cached values in case the firmware was reset - * or some other problem is occuring. If the user is setting the key, + * or some other problem is occurring. If the user is setting the key, * then we push the change */ wep_key->idx = idx; @@ -5308,22 +5393,23 @@ static int ipw2100_set_key(struct ipw2100_priv *priv, /* Will be optimized out on debug not being configured in */ if (keylen == 0) IPW_DEBUG_WEP("%s: Clearing key %d\n", - priv->net_dev->name, wep_key->idx); + priv->net_dev->name, wep_key->idx); else if (keylen == 5) IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_64 "\n", - priv->net_dev->name, wep_key->idx, wep_key->len, - WEP_STR_64(wep_key->key)); + priv->net_dev->name, wep_key->idx, wep_key->len, + WEP_STR_64(wep_key->key)); else IPW_DEBUG_WEP("%s: idx: %d, len: %d key: " WEP_FMT_128 - "\n", - priv->net_dev->name, wep_key->idx, wep_key->len, - WEP_STR_128(wep_key->key)); + "\n", + priv->net_dev->name, wep_key->idx, wep_key->len, + WEP_STR_128(wep_key->key)); if (!batch_mode) { err = ipw2100_disable_adapter(priv); /* FIXME: IPG: shouldn't this prink be in _disable_adapter()? */ if (err) { - printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", + printk(KERN_ERR DRV_NAME + ": %s: Could not disable adapter %d\n", priv->net_dev->name, err); return err; } @@ -5347,7 +5433,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv, .host_command = WEP_KEY_INDEX, .host_command_sequence = 0, .host_command_length = 4, - .host_command_parameters = { idx }, + .host_command_parameters = {idx}, }; int err; @@ -5359,7 +5445,8 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv, if (!batch_mode) { err = ipw2100_disable_adapter(priv); if (err) { - printk(KERN_ERR DRV_NAME ": %s: Could not disable adapter %d\n", + printk(KERN_ERR DRV_NAME + ": %s: Could not disable adapter %d\n", priv->net_dev->name, err); return err; } @@ -5374,9 +5461,7 @@ static int ipw2100_set_key_index(struct ipw2100_priv *priv, return err; } - -static int ipw2100_configure_security(struct ipw2100_priv *priv, - int batch_mode) +static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode) { int i, err, auth_mode, sec_level, use_group; @@ -5389,40 +5474,45 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, return err; } - if (!priv->sec.enabled) { - err = ipw2100_set_security_information( - priv, IPW_AUTH_OPEN, SEC_LEVEL_0, 0, 1); + if (!priv->ieee->sec.enabled) { + err = + ipw2100_set_security_information(priv, IPW_AUTH_OPEN, + SEC_LEVEL_0, 0, 1); } else { auth_mode = IPW_AUTH_OPEN; - if ((priv->sec.flags & SEC_AUTH_MODE) && - (priv->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) - auth_mode = IPW_AUTH_SHARED; + if (priv->ieee->sec.flags & SEC_AUTH_MODE) { + if (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY) + auth_mode = IPW_AUTH_SHARED; + else if (priv->ieee->sec.auth_mode == WLAN_AUTH_LEAP) + auth_mode = IPW_AUTH_LEAP_CISCO_ID; + } sec_level = SEC_LEVEL_0; - if (priv->sec.flags & SEC_LEVEL) - sec_level = priv->sec.level; + if (priv->ieee->sec.flags & SEC_LEVEL) + sec_level = priv->ieee->sec.level; use_group = 0; - if (priv->sec.flags & SEC_UNICAST_GROUP) - use_group = priv->sec.unicast_uses_group; + if (priv->ieee->sec.flags & SEC_UNICAST_GROUP) + use_group = priv->ieee->sec.unicast_uses_group; - err = ipw2100_set_security_information( - priv, auth_mode, sec_level, use_group, 1); + err = + ipw2100_set_security_information(priv, auth_mode, sec_level, + use_group, 1); } if (err) goto exit; - if (priv->sec.enabled) { + if (priv->ieee->sec.enabled) { for (i = 0; i < 4; i++) { - if (!(priv->sec.flags & (1 << i))) { - memset(priv->sec.keys[i], 0, WEP_KEY_LEN); - priv->sec.key_sizes[i] = 0; + if (!(priv->ieee->sec.flags & (1 << i))) { + memset(priv->ieee->sec.keys[i], 0, WEP_KEY_LEN); + priv->ieee->sec.key_sizes[i] = 0; } else { err = ipw2100_set_key(priv, i, - priv->sec.keys[i], - priv->sec.key_sizes[i], - 1); + priv->ieee->sec.keys[i], + priv->ieee->sec. + key_sizes[i], 1); if (err) goto exit; } @@ -5433,22 +5523,27 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, /* Always enable privacy so the Host can filter WEP packets if * encrypted data is sent up */ - err = ipw2100_set_wep_flags( - priv, priv->sec.enabled ? IPW_PRIVACY_CAPABLE : 0, 1); + err = + ipw2100_set_wep_flags(priv, + priv->ieee->sec. + enabled ? IPW_PRIVACY_CAPABLE : 0, 1); if (err) goto exit; priv->status &= ~STATUS_SECURITY_UPDATED; - exit: + exit: if (!batch_mode) ipw2100_enable_adapter(priv); return err; } -static void ipw2100_security_work(struct ipw2100_priv *priv) +static void ipw2100_security_work(struct work_struct *work) { + struct ipw2100_priv *priv = + container_of(work, struct ipw2100_priv, security_work.work); + /* If we happen to have reconnected before we get a chance to * process this, then update the security settings--which causes * a disassociation to occur */ @@ -5463,66 +5558,70 @@ static void shim__set_security(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); int i, force_update = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) goto done; for (i = 0; i < 4; i++) { if (sec->flags & (1 << i)) { - priv->sec.key_sizes[i] = sec->key_sizes[i]; + priv->ieee->sec.key_sizes[i] = sec->key_sizes[i]; if (sec->key_sizes[i] == 0) - priv->sec.flags &= ~(1 << i); + priv->ieee->sec.flags &= ~(1 << i); else - memcpy(priv->sec.keys[i], sec->keys[i], + memcpy(priv->ieee->sec.keys[i], sec->keys[i], sec->key_sizes[i]); - priv->sec.flags |= (1 << i); - priv->status |= STATUS_SECURITY_UPDATED; + if (sec->level == SEC_LEVEL_1) { + priv->ieee->sec.flags |= (1 << i); + priv->status |= STATUS_SECURITY_UPDATED; + } else + priv->ieee->sec.flags &= ~(1 << i); } } if ((sec->flags & SEC_ACTIVE_KEY) && - priv->sec.active_key != sec->active_key) { + priv->ieee->sec.active_key != sec->active_key) { if (sec->active_key <= 3) { - priv->sec.active_key = sec->active_key; - priv->sec.flags |= SEC_ACTIVE_KEY; + priv->ieee->sec.active_key = sec->active_key; + priv->ieee->sec.flags |= SEC_ACTIVE_KEY; } else - priv->sec.flags &= ~SEC_ACTIVE_KEY; + priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY; priv->status |= STATUS_SECURITY_UPDATED; } if ((sec->flags & SEC_AUTH_MODE) && - (priv->sec.auth_mode != sec->auth_mode)) { - priv->sec.auth_mode = sec->auth_mode; - priv->sec.flags |= SEC_AUTH_MODE; + (priv->ieee->sec.auth_mode != sec->auth_mode)) { + priv->ieee->sec.auth_mode = sec->auth_mode; + priv->ieee->sec.flags |= SEC_AUTH_MODE; priv->status |= STATUS_SECURITY_UPDATED; } - if (sec->flags & SEC_ENABLED && - priv->sec.enabled != sec->enabled) { - priv->sec.flags |= SEC_ENABLED; - priv->sec.enabled = sec->enabled; + if (sec->flags & SEC_ENABLED && priv->ieee->sec.enabled != sec->enabled) { + priv->ieee->sec.flags |= SEC_ENABLED; + priv->ieee->sec.enabled = sec->enabled; priv->status |= STATUS_SECURITY_UPDATED; force_update = 1; } - if (sec->flags & SEC_LEVEL && - priv->sec.level != sec->level) { - priv->sec.level = sec->level; - priv->sec.flags |= SEC_LEVEL; + if (sec->flags & SEC_ENCRYPT) + priv->ieee->sec.encrypt = sec->encrypt; + + if (sec->flags & SEC_LEVEL && priv->ieee->sec.level != sec->level) { + priv->ieee->sec.level = sec->level; + priv->ieee->sec.flags |= SEC_LEVEL; priv->status |= STATUS_SECURITY_UPDATED; } IPW_DEBUG_WEP("Security flags: %c %c%c%c%c %c%c%c%c\n", - priv->sec.flags & (1<<8) ? '1' : '0', - priv->sec.flags & (1<<7) ? '1' : '0', - priv->sec.flags & (1<<6) ? '1' : '0', - priv->sec.flags & (1<<5) ? '1' : '0', - priv->sec.flags & (1<<4) ? '1' : '0', - priv->sec.flags & (1<<3) ? '1' : '0', - priv->sec.flags & (1<<2) ? '1' : '0', - priv->sec.flags & (1<<1) ? '1' : '0', - priv->sec.flags & (1<<0) ? '1' : '0'); + priv->ieee->sec.flags & (1 << 8) ? '1' : '0', + priv->ieee->sec.flags & (1 << 7) ? '1' : '0', + priv->ieee->sec.flags & (1 << 6) ? '1' : '0', + priv->ieee->sec.flags & (1 << 5) ? '1' : '0', + priv->ieee->sec.flags & (1 << 4) ? '1' : '0', + priv->ieee->sec.flags & (1 << 3) ? '1' : '0', + priv->ieee->sec.flags & (1 << 2) ? '1' : '0', + priv->ieee->sec.flags & (1 << 1) ? '1' : '0', + priv->ieee->sec.flags & (1 << 0) ? '1' : '0'); /* As a temporary work around to enable WPA until we figure out why * wpa_supplicant toggles the security capability of the driver, which @@ -5531,8 +5630,8 @@ static void shim__set_security(struct net_device *dev, * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/ if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) ipw2100_configure_security(priv, 0); -done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); } static int ipw2100_adapter_setup(struct ipw2100_priv *priv) @@ -5556,7 +5655,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv) return 0; } -#endif /* CONFIG_IPW2100_MONITOR */ +#endif /* CONFIG_IPW2100_MONITOR */ err = ipw2100_read_mac_address(priv); if (err) @@ -5576,7 +5675,7 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv) return err; } - err = ipw2100_system_config(priv, batch_mode); + err = ipw2100_system_config(priv, batch_mode); if (err) return err; @@ -5614,8 +5713,10 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv) return err; if (priv->ieee->iw_mode == IW_MODE_ADHOC) { - err = ipw2100_set_ibss_beacon_interval( - priv, priv->beacon_interval, batch_mode); + err = + ipw2100_set_ibss_beacon_interval(priv, + priv->beacon_interval, + batch_mode); if (err) return err; @@ -5625,18 +5726,17 @@ static int ipw2100_adapter_setup(struct ipw2100_priv *priv) } /* - err = ipw2100_set_fragmentation_threshold( - priv, priv->frag_threshold, batch_mode); - if (err) - return err; - */ + err = ipw2100_set_fragmentation_threshold( + priv, priv->frag_threshold, batch_mode); + if (err) + return err; + */ IPW_DEBUG_INFO("exit\n"); return 0; } - /************************************************************************* * * EXTERNALLY CALLED METHODS @@ -5655,7 +5755,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); priv->config |= CFG_CUSTOM_MAC; memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); @@ -5665,12 +5765,12 @@ static int ipw2100_set_address(struct net_device *dev, void *p) goto done; priv->reset_backoff = 0; - up(&priv->action_sem); - ipw2100_reset_adapter(priv); + mutex_unlock(&priv->action_mutex); + ipw2100_reset_adapter(&priv->reset_work.work); return 0; - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -5708,7 +5808,7 @@ static int ipw2100_close(struct net_device *dev) /* Flush the TX queue ... */ while (!list_empty(&priv->tx_pend_list)) { element = priv->tx_pend_list.next; - packet = list_entry(element, struct ipw2100_tx_packet, list); + packet = list_entry(element, struct ipw2100_tx_packet, list); list_del(element); DEC_STAT(&priv->tx_pend_stat); @@ -5726,8 +5826,6 @@ static int ipw2100_close(struct net_device *dev) return 0; } - - /* * TODO: Fix this function... its just wrong */ @@ -5747,113 +5845,16 @@ static void ipw2100_tx_timeout(struct net_device *dev) schedule_reset(priv); } - -/* - * TODO: reimplement it so that it reads statistics - * from the adapter using ordinal tables - * instead of/in addition to collecting them - * in the driver - */ -static struct net_device_stats *ipw2100_stats(struct net_device *dev) +static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value) { - struct ipw2100_priv *priv = ieee80211_priv(dev); - - return &priv->ieee->stats; -} - -/* Support for wpa_supplicant. Will be replaced with WEXT once - * they get WPA support. */ -#ifdef CONFIG_IEEE80211_WPA - -/* following definitions must match definitions in driver_ipw2100.c */ - -#define IPW2100_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 - -#define IPW2100_CMD_SET_WPA_PARAM 1 -#define IPW2100_CMD_SET_WPA_IE 2 -#define IPW2100_CMD_SET_ENCRYPTION 3 -#define IPW2100_CMD_MLME 4 - -#define IPW2100_PARAM_WPA_ENABLED 1 -#define IPW2100_PARAM_TKIP_COUNTERMEASURES 2 -#define IPW2100_PARAM_DROP_UNENCRYPTED 3 -#define IPW2100_PARAM_PRIVACY_INVOKED 4 -#define IPW2100_PARAM_AUTH_ALGS 5 -#define IPW2100_PARAM_IEEE_802_1X 6 - -#define IPW2100_MLME_STA_DEAUTH 1 -#define IPW2100_MLME_STA_DISASSOC 2 - -#define IPW2100_CRYPT_ERR_UNKNOWN_ALG 2 -#define IPW2100_CRYPT_ERR_UNKNOWN_ADDR 3 -#define IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED 4 -#define IPW2100_CRYPT_ERR_KEY_SET_FAILED 5 -#define IPW2100_CRYPT_ERR_TX_KEY_SET_FAILED 6 -#define IPW2100_CRYPT_ERR_CARD_CONF_FAILED 7 - -#define IPW2100_CRYPT_ALG_NAME_LEN 16 - -struct ipw2100_param { - u32 cmd; - u8 sta_addr[ETH_ALEN]; - union { - struct { - u8 name; - u32 value; - } wpa_param; - struct { - u32 len; - u8 *data; - } wpa_ie; - struct{ - int command; - int reason_code; - } mlme; - struct { - u8 alg[IPW2100_CRYPT_ALG_NAME_LEN]; - u8 set_tx; - u32 err; - u8 idx; - u8 seq[8]; /* sequence counter (set: RX, get: TX) */ - u16 key_len; - u8 key[0]; - } crypt; - - } u; -}; - -/* end of driver_ipw2100.c code */ - -static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value){ - - struct ieee80211_device *ieee = priv->ieee; - struct ieee80211_security sec = { - .flags = SEC_LEVEL | SEC_ENABLED, - }; - int ret = 0; - - ieee->wpa_enabled = value; - - if (value){ - sec.level = SEC_LEVEL_3; - sec.enabled = 1; - } else { - sec.level = SEC_LEVEL_0; - sec.enabled = 0; - } - - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); - else - ret = -EOPNOTSUPP; - - return ret; + /* This is called when wpa_supplicant loads and closes the driver + * interface. */ + priv->ieee->wpa_enabled = value; + return 0; } -#define AUTH_ALG_OPEN_SYSTEM 0x1 -#define AUTH_ALG_SHARED_KEY 0x2 - -static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){ +static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value) +{ struct ieee80211_device *ieee = priv->ieee; struct ieee80211_security sec = { @@ -5861,13 +5862,17 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){ }; int ret = 0; - if (value & AUTH_ALG_SHARED_KEY){ + if (value & IW_AUTH_ALG_SHARED_KEY) { sec.auth_mode = WLAN_AUTH_SHARED_KEY; ieee->open_wep = 0; - } else { + } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) { sec.auth_mode = WLAN_AUTH_OPEN; ieee->open_wep = 1; - } + } else if (value & IW_AUTH_ALG_LEAP) { + sec.auth_mode = WLAN_AUTH_LEAP; + ieee->open_wep = 1; + } else + return -EINVAL; if (ieee->set_security) ieee->set_security(ieee->dev, &sec); @@ -5877,72 +5882,9 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value){ return ret; } - -static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value){ - - struct ipw2100_priv *priv = ieee80211_priv(dev); - int ret=0; - - switch(name){ - case IPW2100_PARAM_WPA_ENABLED: - ret = ipw2100_wpa_enable(priv, value); - break; - - case IPW2100_PARAM_TKIP_COUNTERMEASURES: - priv->ieee->tkip_countermeasures=value; - break; - - case IPW2100_PARAM_DROP_UNENCRYPTED: - priv->ieee->drop_unencrypted=value; - break; - - case IPW2100_PARAM_PRIVACY_INVOKED: - priv->ieee->privacy_invoked=value; - break; - - case IPW2100_PARAM_AUTH_ALGS: - ret = ipw2100_wpa_set_auth_algs(priv, value); - break; - - case IPW2100_PARAM_IEEE_802_1X: - priv->ieee->ieee802_1x=value; - break; - - default: - printk(KERN_ERR DRV_NAME ": %s: Unknown WPA param: %d\n", - dev->name, name); - ret = -EOPNOTSUPP; - } - - return ret; -} - -static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason){ - - struct ipw2100_priv *priv = ieee80211_priv(dev); - int ret=0; - - switch(command){ - case IPW2100_MLME_STA_DEAUTH: - // silently ignore - break; - - case IPW2100_MLME_STA_DISASSOC: - ipw2100_disassociate_bssid(priv); - break; - - default: - printk(KERN_ERR DRV_NAME ": %s: Unknown MLME request: %d\n", - dev->name, command); - ret = -EOPNOTSUPP; - } - - return ret; -} - - -void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, - char *wpa_ie, int wpa_ie_len){ +static void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, + char *wpa_ie, int wpa_ie_len) +{ struct ipw2100_wpa_assoc_frame frame; @@ -5957,263 +5899,6 @@ void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, ipw2100_set_wpa_ie(priv, &frame, 0); } - -static int ipw2100_wpa_set_wpa_ie(struct net_device *dev, - struct ipw2100_param *param, int plen){ - - struct ipw2100_priv *priv = ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee; - u8 *buf; - - if (! ieee->wpa_enabled) - return -EOPNOTSUPP; - - if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || - (param->u.wpa_ie.len && - param->u.wpa_ie.data==NULL)) - return -EINVAL; - - if (param->u.wpa_ie.len){ - buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; - - memcpy(buf, param->u.wpa_ie.data, param->u.wpa_ie.len); - - kfree(ieee->wpa_ie); - ieee->wpa_ie = buf; - ieee->wpa_ie_len = param->u.wpa_ie.len; - - } else { - kfree(ieee->wpa_ie); - ieee->wpa_ie = NULL; - ieee->wpa_ie_len = 0; - } - - ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len); - - return 0; -} - -/* implementation borrowed from hostap driver */ - -static int ipw2100_wpa_set_encryption(struct net_device *dev, - struct ipw2100_param *param, int param_len){ - - int ret = 0; - struct ipw2100_priv *priv = ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee; - struct ieee80211_crypto_ops *ops; - struct ieee80211_crypt_data **crypt; - - struct ieee80211_security sec = { - .flags = 0, - }; - - param->u.crypt.err = 0; - param->u.crypt.alg[IPW2100_CRYPT_ALG_NAME_LEN - 1] = '\0'; - - if (param_len != - (int) ((char *) param->u.crypt.key - (char *) param) + - param->u.crypt.key_len){ - IPW_DEBUG_INFO("Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); - return -EINVAL; - } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { - if (param->u.crypt.idx >= WEP_KEYS) - return -EINVAL; - crypt = &ieee->crypt[param->u.crypt.idx]; - } else { - return -EINVAL; - } - - if (strcmp(param->u.crypt.alg, "none") == 0) { - if (crypt){ - sec.enabled = 0; - sec.level = SEC_LEVEL_0; - sec.flags |= SEC_ENABLED | SEC_LEVEL; - ieee80211_crypt_delayed_deinit(ieee, crypt); - } - goto done; - } - sec.enabled = 1; - sec.flags |= SEC_ENABLED; - - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - } - if (ops == NULL) { - IPW_DEBUG_INFO("%s: unknown crypto alg '%s'\n", - dev->name, param->u.crypt.alg); - param->u.crypt.err = IPW2100_CRYPT_ERR_UNKNOWN_ALG; - ret = -EINVAL; - goto done; - } - - if (*crypt == NULL || (*crypt)->ops != ops) { - struct ieee80211_crypt_data *new_crypt; - - ieee80211_crypt_delayed_deinit(ieee, crypt); - - new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - new_crypt->ops = ops; - if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) - new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); - - if (new_crypt->priv == NULL) { - kfree(new_crypt); - param->u.crypt.err = - IPW2100_CRYPT_ERR_CRYPT_INIT_FAILED; - ret = -EINVAL; - goto done; - } - - *crypt = new_crypt; - } - - if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(param->u.crypt.key, - param->u.crypt.key_len, param->u.crypt.seq, - (*crypt)->priv) < 0) { - IPW_DEBUG_INFO("%s: key setting failed\n", - dev->name); - param->u.crypt.err = IPW2100_CRYPT_ERR_KEY_SET_FAILED; - ret = -EINVAL; - goto done; - } - - if (param->u.crypt.set_tx){ - ieee->tx_keyidx = param->u.crypt.idx; - sec.active_key = param->u.crypt.idx; - sec.flags |= SEC_ACTIVE_KEY; - } - - if (ops->name != NULL){ - - if (strcmp(ops->name, "WEP") == 0) { - memcpy(sec.keys[param->u.crypt.idx], param->u.crypt.key, param->u.crypt.key_len); - sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len; - sec.flags |= (1 << param->u.crypt.idx); - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (strcmp(ops->name, "TKIP") == 0) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (strcmp(ops->name, "CCMP") == 0) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - } - done: - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); - - /* Do not reset port if card is in Managed mode since resetting will - * generate new IEEE 802.11 authentication which may end up in looping - * with IEEE 802.1X. If your hardware requires a reset after WEP - * configuration (for example... Prism2), implement the reset_port in - * the callbacks structures used to initialize the 802.11 stack. */ - if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && - ieee->reset_port(dev)) { - IPW_DEBUG_INFO("%s: reset_port failed\n", dev->name); - param->u.crypt.err = IPW2100_CRYPT_ERR_CARD_CONF_FAILED; - return -EINVAL; - } - - return ret; -} - - -static int ipw2100_wpa_supplicant(struct net_device *dev, struct iw_point *p){ - - struct ipw2100_param *param; - int ret=0; - - IPW_DEBUG_IOCTL("wpa_supplicant: len=%d\n", p->length); - - if (p->length < sizeof(struct ipw2100_param) || !p->pointer) - return -EINVAL; - - param = (struct ipw2100_param *)kmalloc(p->length, GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)){ - kfree(param); - return -EFAULT; - } - - switch (param->cmd){ - - case IPW2100_CMD_SET_WPA_PARAM: - ret = ipw2100_wpa_set_param(dev, param->u.wpa_param.name, - param->u.wpa_param.value); - break; - - case IPW2100_CMD_SET_WPA_IE: - ret = ipw2100_wpa_set_wpa_ie(dev, param, p->length); - break; - - case IPW2100_CMD_SET_ENCRYPTION: - ret = ipw2100_wpa_set_encryption(dev, param, p->length); - break; - - case IPW2100_CMD_MLME: - ret = ipw2100_wpa_mlme(dev, param->u.mlme.command, - param->u.mlme.reason_code); - break; - - default: - printk(KERN_ERR DRV_NAME ": %s: Unknown WPA supplicant request: %d\n", - dev->name, param->cmd); - ret = -EOPNOTSUPP; - - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - - kfree(param); - return ret; -} -#endif /* CONFIG_IEEE80211_WPA */ - -static int ipw2100_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ -#ifdef CONFIG_IEEE80211_WPA - struct iwreq *wrq = (struct iwreq *) rq; - int ret=-1; - switch (cmd){ - case IPW2100_IOCTL_WPA_SUPPLICANT: - ret = ipw2100_wpa_supplicant(dev, &wrq->u.data); - return ret; - - default: - return -EOPNOTSUPP; - } - -#endif /* CONFIG_IEEE80211_WPA */ - - return -EOPNOTSUPP; -} - - static void ipw_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -6234,19 +5919,19 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev, static u32 ipw2100_ethtool_get_link(struct net_device *dev) { - struct ipw2100_priv *priv = ieee80211_priv(dev); - return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; + struct ipw2100_priv *priv = ieee80211_priv(dev); + return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; } - -static struct ethtool_ops ipw2100_ethtool_ops = { - .get_link = ipw2100_ethtool_get_link, - .get_drvinfo = ipw_ethtool_get_drvinfo, +static const struct ethtool_ops ipw2100_ethtool_ops = { + .get_link = ipw2100_ethtool_get_link, + .get_drvinfo = ipw_ethtool_get_drvinfo, }; -static void ipw2100_hang_check(void *adapter) +static void ipw2100_hang_check(struct work_struct *work) { - struct ipw2100_priv *priv = adapter; + struct ipw2100_priv *priv = + container_of(work, struct ipw2100_priv, hang_check.work); unsigned long flags; u32 rtc = 0xa5a5a5a5; u32 len = sizeof(rtc); @@ -6286,10 +5971,10 @@ static void ipw2100_hang_check(void *adapter) spin_unlock_irqrestore(&priv->low_lock, flags); } - -static void ipw2100_rf_kill(void *adapter) +static void ipw2100_rf_kill(struct work_struct *work) { - struct ipw2100_priv *priv = adapter; + struct ipw2100_priv *priv = + container_of(work, struct ipw2100_priv, rf_kill.work); unsigned long flags; spin_lock_irqsave(&priv->low_lock, flags); @@ -6297,7 +5982,8 @@ static void ipw2100_rf_kill(void *adapter) if (rf_kill_active(priv)) { IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); if (!priv->stop_rf_kill) - queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); + queue_delayed_work(priv->workqueue, &priv->rf_kill, + round_jiffies_relative(HZ)); goto exit_unlock; } @@ -6311,7 +5997,7 @@ static void ipw2100_rf_kill(void *adapter) IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still " "enabled\n"); - exit_unlock: + exit_unlock: spin_unlock_irqrestore(&priv->low_lock, flags); } @@ -6319,11 +6005,10 @@ static void ipw2100_irq_tasklet(struct ipw2100_priv *priv); /* Look into using netdev destructor to shutdown ieee80211? */ -static struct net_device *ipw2100_alloc_device( - struct pci_dev *pci_dev, - void __iomem *base_addr, - unsigned long mem_start, - unsigned long mem_len) +static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, + void __iomem * base_addr, + unsigned long mem_start, + unsigned long mem_len) { struct ipw2100_priv *priv; struct net_device *dev; @@ -6339,17 +6024,19 @@ static struct net_device *ipw2100_alloc_device( priv->ieee->hard_start_xmit = ipw2100_tx; priv->ieee->set_security = shim__set_security; + priv->ieee->perfect_rssi = -20; + priv->ieee->worst_rssi = -85; + dev->open = ipw2100_open; dev->stop = ipw2100_close; dev->init = ipw2100_net_init; - dev->do_ioctl = ipw2100_ioctl; - dev->get_stats = ipw2100_stats; dev->ethtool_ops = &ipw2100_ethtool_ops; dev->tx_timeout = ipw2100_tx_timeout; dev->wireless_handlers = &ipw2100_wx_handler_def; - dev->get_wireless_stats = ipw2100_wx_wireless_stats; + priv->wireless_data.ieee80211 = priv->ieee; + dev->wireless_data = &priv->wireless_data; dev->set_mac_address = ipw2100_set_address; - dev->watchdog_timeo = 3*HZ; + dev->watchdog_timeo = 3 * HZ; dev->irq = 0; dev->base_addr = (unsigned long)base_addr; @@ -6362,22 +6049,19 @@ static struct net_device *ipw2100_alloc_device( * ends up causing problems. So, we just handle * the WX extensions through the ipw2100_ioctl interface */ - - /* memset() puts everything to 0, so we only have explicitely set + /* memset() puts everything to 0, so we only have explicitly set * those values that need to be something else */ /* If power management is turned on, default to AUTO mode */ priv->power_mode = IPW_POWER_AUTO; - - -#ifdef CONFIG_IEEE80211_WPA +#ifdef CONFIG_IPW2100_MONITOR + priv->config |= CFG_CRC_CHECK; +#endif priv->ieee->wpa_enabled = 0; - priv->ieee->tkip_countermeasures = 0; priv->ieee->drop_unencrypted = 0; priv->ieee->privacy_invoked = 0; priv->ieee->ieee802_1x = 1; -#endif /* CONFIG_IEEE80211_WPA */ /* Set module parameters */ switch (mode) { @@ -6399,8 +6083,7 @@ static struct net_device *ipw2100_alloc_device( priv->status |= STATUS_RF_KILL_SW; if (channel != 0 && - ((channel >= REG_MIN_CHANNEL) && - (channel <= REG_MAX_CHANNEL))) { + ((channel >= REG_MIN_CHANNEL) && (channel <= REG_MAX_CHANNEL))) { priv->config |= CFG_STATIC_CHANNEL; priv->channel = channel; } @@ -6419,8 +6102,8 @@ static struct net_device *ipw2100_alloc_device( strcpy(priv->nick, "ipw2100"); spin_lock_init(&priv->low_lock); - sema_init(&priv->action_sem, 1); - sema_init(&priv->adapter_sem, 1); + mutex_init(&priv->action_mutex); + mutex_init(&priv->adapter_mutex); init_waitqueue_head(&priv->wait_command_queue); @@ -6439,20 +6122,15 @@ static struct net_device *ipw2100_alloc_device( INIT_LIST_HEAD(&priv->fw_pend_list); INIT_STAT(&priv->fw_pend_stat); - -#ifdef CONFIG_SOFTWARE_SUSPEND2 - priv->workqueue = create_workqueue(DRV_NAME, 0); -#else priv->workqueue = create_workqueue(DRV_NAME); -#endif - INIT_WORK(&priv->reset_work, - (void (*)(void *))ipw2100_reset_adapter, priv); - INIT_WORK(&priv->security_work, - (void (*)(void *))ipw2100_security_work, priv); - INIT_WORK(&priv->wx_event_work, - (void (*)(void *))ipw2100_wx_event_work, priv); - INIT_WORK(&priv->hang_check, ipw2100_hang_check, priv); - INIT_WORK(&priv->rf_kill, ipw2100_rf_kill, priv); + + INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter); + INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work); + INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work); + INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check); + INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill); + INIT_WORK(&priv->scan_event_now, ipw2100_scan_event_now); + INIT_DELAYED_WORK(&priv->scan_event_later, ipw2100_scan_event_later); tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) ipw2100_irq_tasklet, (unsigned long)priv); @@ -6533,7 +6211,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, return err; } - /* We disable the RETRY_TIMEOUT register (0x41) to keep + /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_read_config_dword(pci_dev, 0x40, &val); if ((val & 0x0000ff00) != 0) @@ -6557,27 +6235,23 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, /* Allocate and initialize the Tx/Rx queues and lists */ if (ipw2100_queues_allocate(priv)) { printk(KERN_WARNING DRV_NAME - "Error calilng ipw2100_queues_allocate.\n"); + "Error calling ipw2100_queues_allocate.\n"); err = -ENOMEM; goto fail; } ipw2100_queues_initialize(priv); err = request_irq(pci_dev->irq, - ipw2100_interrupt, SA_SHIRQ, - dev->name, priv); + ipw2100_interrupt, IRQF_SHARED, dev->name, priv); if (err) { printk(KERN_WARNING DRV_NAME - "Error calling request_irq: %d.\n", - pci_dev->irq); + "Error calling request_irq: %d.\n", pci_dev->irq); goto fail; } dev->irq = pci_dev->irq; IPW_DEBUG_INFO("Attempting to register device...\n"); - SET_MODULE_OWNER(dev); - printk(KERN_INFO DRV_NAME ": Detected Intel PRO/Wireless 2100 Network Connection\n"); @@ -6591,20 +6265,22 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, * member to call a function that then just turns and calls ipw2100_up. * net_dev->init is called after name allocation but before the * notifier chain is called */ - down(&priv->action_sem); err = register_netdev(dev); if (err) { printk(KERN_WARNING DRV_NAME "Error calling register_netdev.\n"); - goto fail_unlock; + goto fail; } + + mutex_lock(&priv->action_mutex); registered = 1; IPW_DEBUG_INFO("%s: Bound to %s\n", dev->name, pci_name(pci_dev)); /* perform this after register_netdev so that dev->name is set */ - sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); - netif_carrier_off(dev); + err = sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); + if (err) + goto fail_unlock; /* If the RF Kill switch is disabled, go ahead and complete the * startup sequence */ @@ -6628,14 +6304,14 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, priv->status |= STATUS_INITIALIZED; - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); return 0; - fail_unlock: - up(&priv->action_sem); + fail_unlock: + mutex_unlock(&priv->action_mutex); - fail: + fail: if (dev) { if (registered) unregister_netdev(dev); @@ -6651,7 +6327,8 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, /* These are safe to call even if they weren't allocated */ ipw2100_queues_free(priv); - sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); + sysfs_remove_group(&pci_dev->dev.kobj, + &ipw2100_attribute_group); free_ieee80211(dev); pci_set_drvdata(pci_dev, NULL); @@ -6672,12 +6349,13 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) struct net_device *dev; if (priv) { - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); priv->status &= ~STATUS_INITIALIZED; dev = priv->net_dev; - sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); + sysfs_remove_group(&pci_dev->dev.kobj, + &ipw2100_attribute_group); #ifdef CONFIG_PM if (ipw2100_firmware.version) @@ -6686,9 +6364,9 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) /* Take down the hardware */ ipw2100_down(priv); - /* Release the semaphore so that the network subsystem can + /* Release the mutex so that the network subsystem can * complete any needed calls into the driver... */ - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); /* Unregister the device first - this results in close() * being called if the device is open. If we free storage @@ -6719,21 +6397,15 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) IPW_DEBUG_INFO("exit\n"); } - #ifdef CONFIG_PM -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -static int ipw2100_suspend(struct pci_dev *pci_dev, u32 state) -#else static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state) -#endif { struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); struct net_device *dev = priv->net_dev; - IPW_DEBUG_INFO("%s: Going into suspend...\n", - dev->name); + IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name); - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (priv->status & STATUS_INITIALIZED) { /* Take down the device; powers it off, etc. */ ipw2100_down(priv); @@ -6743,10 +6415,10 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state) netif_device_detach(dev); pci_save_state(pci_dev); - pci_disable_device (pci_dev); + pci_disable_device(pci_dev); pci_set_power_state(pci_dev, PCI_D3hot); - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); return 0; } @@ -6755,18 +6427,23 @@ static int ipw2100_resume(struct pci_dev *pci_dev) { struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); struct net_device *dev = priv->net_dev; + int err; u32 val; if (IPW2100_PM_DISABLED) return 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); - IPW_DEBUG_INFO("%s: Coming out of suspend...\n", - dev->name); + IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name); pci_set_power_state(pci_dev, PCI_D0); - pci_enable_device(pci_dev); + err = pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: pci_enable_device failed on resume\n", + dev->name); + return err; + } pci_restore_state(pci_dev); /* @@ -6783,66 +6460,65 @@ static int ipw2100_resume(struct pci_dev *pci_dev) * the queue of needed */ netif_device_attach(dev); - /* Bring the device back up */ - if (!(priv->status & STATUS_RF_KILL_SW)) - ipw2100_up(priv, 0); + /* Bring the device back up */ + if (!(priv->status & STATUS_RF_KILL_SW)) + ipw2100_up(priv, 0); - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); return 0; } #endif - #define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x } static struct pci_device_id ipw2100_pci_id_table[] __devinitdata = { - IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */ - IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */ - IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */ - IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */ - IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */ - IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */ - IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */ - - IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */ - - IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */ - IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */ - IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */ - IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */ - IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */ - IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */ - IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */ - - IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */ - - IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */ - - IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */ - IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */ - IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */ - - IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */ + IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2525), /* IN 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2526), /* IN 2100A mPCI Gen A3 */ + IPW2100_DEV_ID(0x2522), /* IN 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2523), /* IN 2100 mPCI 3A */ + IPW2100_DEV_ID(0x2527), /* IN 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2528), /* IN 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2529), /* IN 2100 mPCI 3B */ + IPW2100_DEV_ID(0x252B), /* IN 2100 mPCI 3A */ + IPW2100_DEV_ID(0x252C), /* IN 2100 mPCI 3A */ + IPW2100_DEV_ID(0x252D), /* IN 2100 mPCI 3A */ + + IPW2100_DEV_ID(0x2550), /* IB 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2551), /* IB 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2553), /* IB 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2554), /* IB 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2555), /* IB 2100 mPCI 3B */ + + IPW2100_DEV_ID(0x2560), /* DE 2100A mPCI 3A */ + IPW2100_DEV_ID(0x2562), /* DE 2100A mPCI 3A */ + IPW2100_DEV_ID(0x2563), /* DE 2100A mPCI 3A */ + IPW2100_DEV_ID(0x2561), /* DE 2100 mPCI 3A */ + IPW2100_DEV_ID(0x2565), /* DE 2100 mPCI 3A */ + IPW2100_DEV_ID(0x2566), /* DE 2100 mPCI 3A */ + IPW2100_DEV_ID(0x2567), /* DE 2100 mPCI 3A */ + + IPW2100_DEV_ID(0x2570), /* GA 2100 mPCI 3B */ + + IPW2100_DEV_ID(0x2580), /* TO 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2582), /* TO 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2583), /* TO 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2581), /* TO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2585), /* TO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2586), /* TO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2587), /* TO 2100 mPCI 3B */ + + IPW2100_DEV_ID(0x2590), /* SO 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2592), /* SO 2100A mPCI 3B */ + IPW2100_DEV_ID(0x2591), /* SO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2593), /* SO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2596), /* SO 2100 mPCI 3B */ + IPW2100_DEV_ID(0x2598), /* SO 2100 mPCI 3B */ + + IPW2100_DEV_ID(0x25A0), /* HP 2100 mPCI 3B */ {0,}, }; @@ -6859,7 +6535,6 @@ static struct pci_driver ipw2100_pci_driver = { #endif }; - /** * Initialize the ipw2100 driver/module * @@ -6876,33 +6551,34 @@ static int __init ipw2100_init(void) printk(KERN_INFO DRV_NAME ": %s, %s\n", DRV_DESCRIPTION, DRV_VERSION); printk(KERN_INFO DRV_NAME ": %s\n", DRV_COPYRIGHT); -#ifdef CONFIG_IEEE80211_NOWEP - IPW_DEBUG_INFO(DRV_NAME ": Compiled with WEP disabled.\n"); -#endif - - ret = pci_module_init(&ipw2100_pci_driver); + ret = pci_register_driver(&ipw2100_pci_driver); + if (ret) + goto out; -#ifdef CONFIG_IPW_DEBUG + pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, "ipw2100", + PM_QOS_DEFAULT_VALUE); +#ifdef CONFIG_IPW2100_DEBUG ipw2100_debug_level = debug; - driver_create_file(&ipw2100_pci_driver.driver, - &driver_attr_debug_level); + ret = driver_create_file(&ipw2100_pci_driver.driver, + &driver_attr_debug_level); #endif +out: return ret; } - /** * Cleanup ipw2100 driver registration */ static void __exit ipw2100_exit(void) { /* FIXME: IPG: check that we have no instances of the devices open */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG driver_remove_file(&ipw2100_pci_driver.driver, &driver_attr_debug_level); #endif pci_unregister_driver(&ipw2100_pci_driver); + pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, "ipw2100"); } module_init(ipw2100_init); @@ -6917,8 +6593,7 @@ static const long ipw2100_frequencies[] = { 2472, 2484 }; -#define FREQ_COUNT (sizeof(ipw2100_frequencies) / \ - sizeof(ipw2100_frequencies[0])) +#define FREQ_COUNT ARRAY_SIZE(ipw2100_frequencies) static const long ipw2100_rates_11b[] = { 1000000, @@ -6927,7 +6602,7 @@ static const long ipw2100_rates_11b[] = { 11000000 }; -#define RATE_COUNT (sizeof(ipw2100_rates_11b) / sizeof(ipw2100_rates_11b[0])) +#define RATE_COUNT ARRAY_SIZE(ipw2100_rates_11b) static int ipw2100_wx_get_name(struct net_device *dev, struct iw_request_info *info, @@ -6947,7 +6622,6 @@ static int ipw2100_wx_get_name(struct net_device *dev, return 0; } - static int ipw2100_wx_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -6959,7 +6633,7 @@ static int ipw2100_wx_set_freq(struct net_device *dev, if (priv->ieee->iw_mode == IW_MODE_INFRA) return -EOPNOTSUPP; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -6967,8 +6641,7 @@ static int ipw2100_wx_set_freq(struct net_device *dev, /* if setting by freq convert to channel */ if (fwrq->e == 1) { - if ((fwrq->m >= (int) 2.412e8 && - fwrq->m <= (int) 2.487e8)) { + if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) { int f = fwrq->m / 100000; int c = 0; @@ -6982,19 +6655,19 @@ static int ipw2100_wx_set_freq(struct net_device *dev, } } - if (fwrq->e > 0 || fwrq->m > 1000) - return -EOPNOTSUPP; - else { /* Set the channel */ + if (fwrq->e > 0 || fwrq->m > 1000) { + err = -EOPNOTSUPP; + goto done; + } else { /* Set the channel */ IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); err = ipw2100_set_channel(priv, fwrq->m, 0); } - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } - static int ipw2100_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -7032,7 +6705,7 @@ static int ipw2100_wx_set_mode(struct net_device *dev, if (wrqu->mode == priv->ieee->iw_mode) return 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7043,7 +6716,7 @@ static int ipw2100_wx_set_mode(struct net_device *dev, case IW_MODE_MONITOR: err = ipw2100_switch_mode(priv, IW_MODE_MONITOR); break; -#endif /* CONFIG_IPW2100_MONITOR */ +#endif /* CONFIG_IPW2100_MONITOR */ case IW_MODE_ADHOC: err = ipw2100_switch_mode(priv, IW_MODE_ADHOC); break; @@ -7054,9 +6727,9 @@ static int ipw2100_wx_set_mode(struct net_device *dev, break; } -done: - up(&priv->action_sem); - return err; + done: + mutex_unlock(&priv->action_mutex); + return err; } static int ipw2100_wx_get_mode(struct net_device *dev, @@ -7075,7 +6748,6 @@ static int ipw2100_wx_get_mode(struct net_device *dev, return 0; } - #define POWER_MODES 5 /* Values are in microsecond */ @@ -7122,19 +6794,19 @@ static int ipw2100_wx_get_range(struct net_device *dev, /* ~5 Mb/s real (802.11b) */ range->throughput = 5 * 1000 * 1000; -// range->sensitivity; /* signal level threshold range */ +// range->sensitivity; /* signal level threshold range */ range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; range->max_qual.noise = 0; - range->max_qual.updated = 7; /* Updated all three */ + range->max_qual.updated = 7; /* Updated all three */ - range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ + range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM; range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ + range->avg_qual.updated = 7; /* Updated all three */ range->num_bitrates = RATE_COUNT; @@ -7148,64 +6820,73 @@ static int ipw2100_wx_get_range(struct net_device *dev, range->max_frag = MAX_FRAG_THRESHOLD; range->min_pmp = period_duration[0]; /* Minimal PM period */ - range->max_pmp = period_duration[POWER_MODES-1];/* Maximal PM period */ - range->min_pmt = timeout_duration[POWER_MODES-1]; /* Minimal PM timeout */ - range->max_pmt = timeout_duration[0];/* Maximal PM timeout */ + range->max_pmp = period_duration[POWER_MODES - 1]; /* Maximal PM period */ + range->min_pmt = timeout_duration[POWER_MODES - 1]; /* Minimal PM timeout */ + range->max_pmt = timeout_duration[0]; /* Maximal PM timeout */ - /* How to decode max/min PM period */ + /* How to decode max/min PM period */ range->pmp_flags = IW_POWER_PERIOD; - /* How to decode max/min PM period */ + /* How to decode max/min PM period */ range->pmt_flags = IW_POWER_TIMEOUT; /* What PM options are supported */ range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD; range->encoding_size[0] = 5; - range->encoding_size[1] = 13; /* Different token sizes */ - range->num_encoding_sizes = 2; /* Number of entry in the list */ - range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ -// range->encoding_login_index; /* token index for login token */ + range->encoding_size[1] = 13; /* Different token sizes */ + range->num_encoding_sizes = 2; /* Number of entry in the list */ + range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ +// range->encoding_login_index; /* token index for login token */ if (priv->ieee->iw_mode == IW_MODE_ADHOC) { range->txpower_capa = IW_TXPOW_DBM; range->num_txpower = IW_MAX_TXPOWER; - for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16); i < IW_MAX_TXPOWER; - i++, level -= ((IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM) * 16) / - (IW_MAX_TXPOWER - 1)) + for (i = 0, level = (IPW_TX_POWER_MAX_DBM * 16); + i < IW_MAX_TXPOWER; + i++, level -= + ((IPW_TX_POWER_MAX_DBM - + IPW_TX_POWER_MIN_DBM) * 16) / (IW_MAX_TXPOWER - 1)) range->txpower[i] = level / 16; } else { range->txpower_capa = 0; range->num_txpower = 0; } - /* Set the Wireless Extension versions */ range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 16; + range->we_version_source = 18; -// range->retry_capa; /* What retry options are supported */ -// range->retry_flags; /* How to decode max/min retry limit */ -// range->r_time_flags; /* How to decode max/min retry life */ -// range->min_retry; /* Minimal number of retries */ -// range->max_retry; /* Maximal number of retries */ -// range->min_r_time; /* Minimal retry lifetime */ -// range->max_r_time; /* Maximal retry lifetime */ +// range->retry_capa; /* What retry options are supported */ +// range->retry_flags; /* How to decode max/min retry limit */ +// range->r_time_flags; /* How to decode max/min retry life */ +// range->min_retry; /* Minimal number of retries */ +// range->max_retry; /* Maximal number of retries */ +// range->min_r_time; /* Minimal retry lifetime */ +// range->max_r_time; /* Maximal retry lifetime */ - range->num_channels = FREQ_COUNT; + range->num_channels = FREQ_COUNT; val = 0; for (i = 0; i < FREQ_COUNT; i++) { // TODO: Include only legal frequencies for some countries -// if (local->channel_mask & (1 << i)) { - range->freq[val].i = i + 1; - range->freq[val].m = ipw2100_frequencies[i] * 100000; - range->freq[val].e = 1; - val++; -// } +// if (local->channel_mask & (1 << i)) { + range->freq[val].i = i + 1; + range->freq[val].m = ipw2100_frequencies[i] * 100000; + range->freq[val].e = 1; + val++; +// } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; + /* Event capability (kernel + driver) */ + range->event_capa[0] = (IW_EVENT_CAPA_K_0 | + IW_EVENT_CAPA_MASK(SIOCGIWAP)); + range->event_capa[1] = IW_EVENT_CAPA_K_1; + + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; + IPW_DEBUG_WX("GET Range\n"); return 0; @@ -7224,12 +6905,13 @@ static int ipw2100_wx_set_wap(struct net_device *dev, static const unsigned char off[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + DECLARE_MAC_BUF(mac); // sanity checks if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) return -EINVAL; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7249,16 +6931,11 @@ static int ipw2100_wx_set_wap(struct net_device *dev, err = ipw2100_set_mandatory_bssid(priv, wrqu->ap_addr.sa_data, 0); - IPW_DEBUG_WX("SET BSSID -> %02X:%02X:%02X:%02X:%02X:%02X\n", - wrqu->ap_addr.sa_data[0] & 0xff, - wrqu->ap_addr.sa_data[1] & 0xff, - wrqu->ap_addr.sa_data[2] & 0xff, - wrqu->ap_addr.sa_data[3] & 0xff, - wrqu->ap_addr.sa_data[4] & 0xff, - wrqu->ap_addr.sa_data[5] & 0xff); + IPW_DEBUG_WX("SET BSSID -> %s\n", + print_mac(mac, wrqu->ap_addr.sa_data)); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7271,18 +6948,18 @@ static int ipw2100_wx_get_wap(struct net_device *dev, */ struct ipw2100_priv *priv = ieee80211_priv(dev); + DECLARE_MAC_BUF(mac); /* If we are associated, trying to associate, or have a statically * configured BSSID then return that; otherwise return ANY */ - if (priv->config & CFG_STATIC_BSSID || - priv->status & STATUS_ASSOCIATED) { + if (priv->config & CFG_STATIC_BSSID || priv->status & STATUS_ASSOCIATED) { wrqu->ap_addr.sa_family = ARPHRD_ETHER; - memcpy(wrqu->ap_addr.sa_data, &priv->bssid, ETH_ALEN); + memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN); } else memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT "\n", - MAC_ARG(wrqu->ap_addr.sa_data)); + IPW_DEBUG_WX("Getting WAP BSSID: %s\n", + print_mac(mac, wrqu->ap_addr.sa_data)); return 0; } @@ -7291,18 +6968,18 @@ static int ipw2100_wx_set_essid(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct ipw2100_priv *priv = ieee80211_priv(dev); - char *essid = ""; /* ANY */ + char *essid = ""; /* ANY */ int length = 0; int err = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; } if (wrqu->essid.flags && wrqu->essid.length) { - length = wrqu->essid.length - 1; + length = wrqu->essid.length; essid = extra; } @@ -7331,8 +7008,8 @@ static int ipw2100_wx_set_essid(struct net_device *dev, err = ipw2100_set_essid(priv, essid, length, 0); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7348,17 +7025,16 @@ static int ipw2100_wx_get_essid(struct net_device *dev, /* If we are associated, trying to associate, or have a statically * configured ESSID then return that; otherwise return ANY */ - if (priv->config & CFG_STATIC_ESSID || - priv->status & STATUS_ASSOCIATED) { + if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) { IPW_DEBUG_WX("Getting essid: '%s'\n", escape_essid(priv->essid, priv->essid_len)); memcpy(extra, priv->essid, priv->essid_len); wrqu->essid.length = priv->essid_len; - wrqu->essid.flags = 1; /* active */ + wrqu->essid.flags = 1; /* active */ } else { IPW_DEBUG_WX("Getting essid: ANY\n"); wrqu->essid.length = 0; - wrqu->essid.flags = 0; /* active */ + wrqu->essid.flags = 0; /* active */ } return 0; @@ -7377,9 +7053,9 @@ static int ipw2100_wx_set_nick(struct net_device *dev, if (wrqu->data.length > IW_ESSID_MAX_SIZE) return -E2BIG; - wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick)); + wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick)); memset(priv->nick, 0, sizeof(priv->nick)); - memcpy(priv->nick, extra, wrqu->data.length); + memcpy(priv->nick, extra, wrqu->data.length); IPW_DEBUG_WX("SET Nickname -> %s \n", priv->nick); @@ -7396,9 +7072,9 @@ static int ipw2100_wx_get_nick(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); - wrqu->data.length = strlen(priv->nick) + 1; + wrqu->data.length = strlen(priv->nick); memcpy(extra, priv->nick, wrqu->data.length); - wrqu->data.flags = 1; /* active */ + wrqu->data.flags = 1; /* active */ IPW_DEBUG_WX("GET Nickname -> %s \n", extra); @@ -7414,7 +7090,7 @@ static int ipw2100_wx_set_rate(struct net_device *dev, u32 rate; int err = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7440,12 +7116,11 @@ static int ipw2100_wx_set_rate(struct net_device *dev, err = ipw2100_set_tx_rates(priv, rate, 0); IPW_DEBUG_WX("SET Rate -> %04X \n", rate); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } - static int ipw2100_wx_get_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -7462,7 +7137,7 @@ static int ipw2100_wx_get_rate(struct net_device *dev, return 0; } - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7493,8 +7168,8 @@ static int ipw2100_wx_get_rate(struct net_device *dev, IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7509,7 +7184,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev, if (wrqu->rts.fixed == 0) return -EINVAL; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7518,8 +7193,7 @@ static int ipw2100_wx_set_rts(struct net_device *dev, if (wrqu->rts.disabled) value = priv->rts_threshold | RTS_DISABLED; else { - if (wrqu->rts.value < 1 || - wrqu->rts.value > 2304) { + if (wrqu->rts.value < 1 || wrqu->rts.value > 2304) { err = -EINVAL; goto done; } @@ -7529,8 +7203,8 @@ static int ipw2100_wx_set_rts(struct net_device *dev, err = ipw2100_set_rts_threshold(priv, value); IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7545,7 +7219,7 @@ static int ipw2100_wx_get_rts(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED; - wrqu->rts.fixed = 1; /* no auto select */ + wrqu->rts.fixed = 1; /* no auto select */ /* If RTS is set to the default value, then it is disabled */ wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0; @@ -7561,22 +7235,27 @@ static int ipw2100_wx_set_txpow(struct net_device *dev, { struct ipw2100_priv *priv = ieee80211_priv(dev); int err = 0, value; + + if (ipw_radio_kill_sw(priv, wrqu->txpower.disabled)) + return -EINPROGRESS; if (priv->ieee->iw_mode != IW_MODE_ADHOC) + return 0; + + if ((wrqu->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) return -EINVAL; - if (wrqu->txpower.disabled == 1 || wrqu->txpower.fixed == 0) + if (wrqu->txpower.fixed == 0) value = IPW_TX_POWER_DEFAULT; else { if (wrqu->txpower.value < IPW_TX_POWER_MIN_DBM || wrqu->txpower.value > IPW_TX_POWER_MAX_DBM) return -EINVAL; - value = (wrqu->txpower.value - IPW_TX_POWER_MIN_DBM) * 16 / - (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM); + value = wrqu->txpower.value; } - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7586,8 +7265,8 @@ static int ipw2100_wx_set_txpow(struct net_device *dev, IPW_DEBUG_WX("SET TX Power -> %d \n", value); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7601,28 +7280,19 @@ static int ipw2100_wx_get_txpow(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); - if (priv->ieee->iw_mode != IW_MODE_ADHOC) { - wrqu->power.disabled = 1; - return 0; - } + wrqu->txpower.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; if (priv->tx_power == IPW_TX_POWER_DEFAULT) { - wrqu->power.fixed = 0; - wrqu->power.value = IPW_TX_POWER_MAX_DBM; - wrqu->power.disabled = 1; + wrqu->txpower.fixed = 0; + wrqu->txpower.value = IPW_TX_POWER_MAX_DBM; } else { - wrqu->power.disabled = 0; - wrqu->power.fixed = 1; - wrqu->power.value = - (priv->tx_power * - (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM)) / - (IPW_TX_POWER_MAX - IPW_TX_POWER_MIN) + - IPW_TX_POWER_MIN_DBM; + wrqu->txpower.fixed = 1; + wrqu->txpower.value = priv->tx_power; } - wrqu->power.flags = IW_TXPOW_DBM; + wrqu->txpower.flags = IW_TXPOW_DBM; - IPW_DEBUG_WX("GET TX Power -> %d \n", wrqu->power.value); + IPW_DEBUG_WX("GET TX Power -> %d \n", wrqu->txpower.value); return 0; } @@ -7682,30 +7352,29 @@ static int ipw2100_wx_set_retry(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); int err = 0; - if (wrqu->retry.flags & IW_RETRY_LIFETIME || - wrqu->retry.disabled) + if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled) return -EINVAL; if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) return 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; } - if (wrqu->retry.flags & IW_RETRY_MIN) { + if (wrqu->retry.flags & IW_RETRY_SHORT) { err = ipw2100_set_short_retry(priv, wrqu->retry.value); IPW_DEBUG_WX("SET Short Retry Limit -> %d \n", - wrqu->retry.value); + wrqu->retry.value); goto done; } - if (wrqu->retry.flags & IW_RETRY_MAX) { + if (wrqu->retry.flags & IW_RETRY_LONG) { err = ipw2100_set_long_retry(priv, wrqu->retry.value); IPW_DEBUG_WX("SET Long Retry Limit -> %d \n", - wrqu->retry.value); + wrqu->retry.value); goto done; } @@ -7715,8 +7384,8 @@ static int ipw2100_wx_set_retry(struct net_device *dev, IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7730,20 +7399,19 @@ static int ipw2100_wx_get_retry(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); - wrqu->retry.disabled = 0; /* can't be disabled */ + wrqu->retry.disabled = 0; /* can't be disabled */ - if ((wrqu->retry.flags & IW_RETRY_TYPE) == - IW_RETRY_LIFETIME) + if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) return -EINVAL; - if (wrqu->retry.flags & IW_RETRY_MAX) { - wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX; + if (wrqu->retry.flags & IW_RETRY_LONG) { + wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG; wrqu->retry.value = priv->long_retry_limit; } else { wrqu->retry.flags = (priv->short_retry_limit != priv->long_retry_limit) ? - IW_RETRY_LIMIT & IW_RETRY_MIN : IW_RETRY_LIMIT; + IW_RETRY_LIMIT | IW_RETRY_SHORT : IW_RETRY_LIMIT; wrqu->retry.value = priv->short_retry_limit; } @@ -7760,23 +7428,24 @@ static int ipw2100_wx_set_scan(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); int err = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; } IPW_DEBUG_WX("Initiating scan...\n"); - if (ipw2100_set_scan_options(priv) || - ipw2100_start_scan(priv)) { + + priv->user_requested_scan = 1; + if (ipw2100_set_scan_options(priv) || ipw2100_start_scan(priv)) { IPW_DEBUG_WX("Start scan failed.\n"); /* TODO: Mark a scan as pending so when hardware initialized * a scan starts */ } - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7792,7 +7461,6 @@ static int ipw2100_wx_get_scan(struct net_device *dev, return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra); } - /* * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c */ @@ -7821,13 +7489,13 @@ static int ipw2100_wx_get_encode(struct net_device *dev, } static int ipw2100_wx_set_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw2100_priv *priv = ieee80211_priv(dev); int err = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7841,11 +7509,11 @@ static int ipw2100_wx_set_power(struct net_device *dev, } switch (wrqu->power.flags & IW_POWER_MODE) { - case IW_POWER_ON: /* If not specified */ - case IW_POWER_MODE: /* If set all mask */ - case IW_POWER_ALL_R: /* If explicitely state all */ + case IW_POWER_ON: /* If not specified */ + case IW_POWER_MODE: /* If set all mask */ + case IW_POWER_ALL_R: /* If explicitly state all */ break; - default: /* Otherwise we don't support it */ + default: /* Otherwise we don't support it */ IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", wrqu->power.flags); err = -EOPNOTSUPP; @@ -7857,18 +7525,17 @@ static int ipw2100_wx_set_power(struct net_device *dev, priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); - IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", - priv->power_mode); + IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } static int ipw2100_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { /* * This can be called at any time. No action lock required @@ -7876,9 +7543,9 @@ static int ipw2100_wx_get_power(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); - if (!(priv->power_mode & IPW_POWER_ENABLED)) { + if (!(priv->power_mode & IPW_POWER_ENABLED)) wrqu->power.disabled = 1; - } else { + else { wrqu->power.disabled = 0; wrqu->power.flags = 0; } @@ -7888,6 +7555,266 @@ static int ipw2100_wx_get_power(struct net_device *dev, return 0; } +/* + * WE-18 WPA support + */ + +/* SIOCSIWGENIE */ +static int ipw2100_wx_set_genie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + + struct ipw2100_priv *priv = ieee80211_priv(dev); + struct ieee80211_device *ieee = priv->ieee; + u8 *buf; + + if (!ieee->wpa_enabled) + return -EOPNOTSUPP; + + if (wrqu->data.length > MAX_WPA_IE_LEN || + (wrqu->data.length && extra == NULL)) + return -EINVAL; + + if (wrqu->data.length) { + buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + kfree(ieee->wpa_ie); + ieee->wpa_ie = buf; + ieee->wpa_ie_len = wrqu->data.length; + } else { + kfree(ieee->wpa_ie); + ieee->wpa_ie = NULL; + ieee->wpa_ie_len = 0; + } + + ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len); + + return 0; +} + +/* SIOCGIWGENIE */ +static int ipw2100_wx_get_genie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + struct ieee80211_device *ieee = priv->ieee; + + if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { + wrqu->data.length = 0; + return 0; + } + + if (wrqu->data.length < ieee->wpa_ie_len) + return -E2BIG; + + wrqu->data.length = ieee->wpa_ie_len; + memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); + + return 0; +} + +/* SIOCSIWAUTH */ +static int ipw2100_wx_set_auth(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + struct ieee80211_device *ieee = priv->ieee; + struct iw_param *param = &wrqu->param; + struct ieee80211_crypt_data *crypt; + unsigned long flags; + int ret = 0; + + switch (param->flags & IW_AUTH_INDEX) { + case IW_AUTH_WPA_VERSION: + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: + /* + * ipw2200 does not use these parameters + */ + break; + + case IW_AUTH_TKIP_COUNTERMEASURES: + crypt = priv->ieee->crypt[priv->ieee->tx_keyidx]; + if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags) + break; + + flags = crypt->ops->get_flags(crypt->priv); + + if (param->value) + flags |= IEEE80211_CRYPTO_TKIP_COUNTERMEASURES; + else + flags &= ~IEEE80211_CRYPTO_TKIP_COUNTERMEASURES; + + crypt->ops->set_flags(flags, crypt->priv); + + break; + + case IW_AUTH_DROP_UNENCRYPTED:{ + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + struct ieee80211_security sec = { + .flags = SEC_ENABLED, + .enabled = param->value, + }; + priv->ieee->drop_unencrypted = param->value; + /* We only change SEC_LEVEL for open mode. Others + * are set by ipw_wpa_set_encryption. + */ + if (!param->value) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_0; + } else { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } + if (priv->ieee->set_security) + priv->ieee->set_security(priv->ieee->dev, &sec); + break; + } + + case IW_AUTH_80211_AUTH_ALG: + ret = ipw2100_wpa_set_auth_algs(priv, param->value); + break; + + case IW_AUTH_WPA_ENABLED: + ret = ipw2100_wpa_enable(priv, param->value); + break; + + case IW_AUTH_RX_UNENCRYPTED_EAPOL: + ieee->ieee802_1x = param->value; + break; + + //case IW_AUTH_ROAMING_CONTROL: + case IW_AUTH_PRIVACY_INVOKED: + ieee->privacy_invoked = param->value; + break; + + default: + return -EOPNOTSUPP; + } + return ret; +} + +/* SIOCGIWAUTH */ +static int ipw2100_wx_get_auth(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + struct ieee80211_device *ieee = priv->ieee; + struct ieee80211_crypt_data *crypt; + struct iw_param *param = &wrqu->param; + int ret = 0; + + switch (param->flags & IW_AUTH_INDEX) { + case IW_AUTH_WPA_VERSION: + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: + /* + * wpa_supplicant will control these internally + */ + ret = -EOPNOTSUPP; + break; + + case IW_AUTH_TKIP_COUNTERMEASURES: + crypt = priv->ieee->crypt[priv->ieee->tx_keyidx]; + if (!crypt || !crypt->ops->get_flags) { + IPW_DEBUG_WARNING("Can't get TKIP countermeasures: " + "crypt not set!\n"); + break; + } + + param->value = (crypt->ops->get_flags(crypt->priv) & + IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) ? 1 : 0; + + break; + + case IW_AUTH_DROP_UNENCRYPTED: + param->value = ieee->drop_unencrypted; + break; + + case IW_AUTH_80211_AUTH_ALG: + param->value = priv->ieee->sec.auth_mode; + break; + + case IW_AUTH_WPA_ENABLED: + param->value = ieee->wpa_enabled; + break; + + case IW_AUTH_RX_UNENCRYPTED_EAPOL: + param->value = ieee->ieee802_1x; + break; + + case IW_AUTH_ROAMING_CONTROL: + case IW_AUTH_PRIVACY_INVOKED: + param->value = ieee->privacy_invoked; + break; + + default: + return -EOPNOTSUPP; + } + return 0; +} + +/* SIOCSIWENCODEEXT */ +static int ipw2100_wx_set_encodeext(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + return ieee80211_wx_set_encodeext(priv->ieee, info, wrqu, extra); +} + +/* SIOCGIWENCODEEXT */ +static int ipw2100_wx_get_encodeext(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + return ieee80211_wx_get_encodeext(priv->ieee, info, wrqu, extra); +} + +/* SIOCSIWMLME */ +static int ipw2100_wx_set_mlme(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + struct iw_mlme *mlme = (struct iw_mlme *)extra; + __le16 reason; + + reason = cpu_to_le16(mlme->reason_code); + + switch (mlme->cmd) { + case IW_MLME_DEAUTH: + // silently ignore + break; + + case IW_MLME_DISASSOC: + ipw2100_disassociate_bssid(priv); + break; + + default: + return -EOPNOTSUPP; + } + return 0; +} /* * @@ -7904,7 +7831,7 @@ static int ipw2100_wx_set_promisc(struct net_device *dev, int enable = (parms[0] > 0); int err = 0; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -7921,8 +7848,8 @@ static int ipw2100_wx_set_promisc(struct net_device *dev, if (priv->ieee->iw_mode == IW_MODE_MONITOR) err = ipw2100_switch_mode(priv, priv->last_mode); } - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7945,19 +7872,19 @@ static int ipw2100_wx_set_powermode(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); int err = 0, mode = *(int *)extra; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; } - if ((mode < 1) || (mode > POWER_MODES)) + if ((mode < 0) || (mode > POWER_MODES)) mode = IPW_POWER_AUTO; - if (priv->power_mode != mode) + if (IPW_POWER_LEVEL(priv->power_mode) != mode) err = ipw2100_set_power_mode(priv, mode); - done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } @@ -7984,8 +7911,8 @@ static int ipw2100_wx_get_powermode(struct net_device *dev, "Power save level: %d (None)", level); break; case IPW_POWER_AUTO: - snprintf(extra, MAX_POWER_STRING, - "Power save level: %d (Auto)", 0); + snprintf(extra, MAX_POWER_STRING, + "Power save level: %d (Auto)", level); break; default: timeout = timeout_duration[level - 1] / 1000; @@ -8002,7 +7929,6 @@ static int ipw2100_wx_get_powermode(struct net_device *dev, return 0; } - static int ipw2100_wx_set_preamble(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -8010,7 +7936,7 @@ static int ipw2100_wx_set_preamble(struct net_device *dev, struct ipw2100_priv *priv = ieee80211_priv(dev); int err, mode = *(int *)extra; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); if (!(priv->status & STATUS_INITIALIZED)) { err = -EIO; goto done; @@ -8027,14 +7953,14 @@ static int ipw2100_wx_set_preamble(struct net_device *dev, err = ipw2100_system_config(priv, 0); -done: - up(&priv->action_sem); + done: + mutex_unlock(&priv->action_mutex); return err; } static int ipw2100_wx_get_preamble(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { /* * This can be called at any time. No action lock required @@ -8050,54 +7976,110 @@ static int ipw2100_wx_get_preamble(struct net_device *dev, return 0; } -static iw_handler ipw2100_wx_handlers[] = -{ - NULL, /* SIOCSIWCOMMIT */ - ipw2100_wx_get_name, /* SIOCGIWNAME */ - NULL, /* SIOCSIWNWID */ - NULL, /* SIOCGIWNWID */ - ipw2100_wx_set_freq, /* SIOCSIWFREQ */ - ipw2100_wx_get_freq, /* SIOCGIWFREQ */ - ipw2100_wx_set_mode, /* SIOCSIWMODE */ - ipw2100_wx_get_mode, /* SIOCGIWMODE */ - NULL, /* SIOCSIWSENS */ - NULL, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - ipw2100_wx_get_range, /* SIOCGIWRANGE */ - NULL, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - NULL, /* SIOCSIWSPY */ - NULL, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - ipw2100_wx_set_wap, /* SIOCSIWAP */ - ipw2100_wx_get_wap, /* SIOCGIWAP */ - NULL, /* -- hole -- */ - NULL, /* SIOCGIWAPLIST -- deprecated */ - ipw2100_wx_set_scan, /* SIOCSIWSCAN */ - ipw2100_wx_get_scan, /* SIOCGIWSCAN */ - ipw2100_wx_set_essid, /* SIOCSIWESSID */ - ipw2100_wx_get_essid, /* SIOCGIWESSID */ - ipw2100_wx_set_nick, /* SIOCSIWNICKN */ - ipw2100_wx_get_nick, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - ipw2100_wx_set_rate, /* SIOCSIWRATE */ - ipw2100_wx_get_rate, /* SIOCGIWRATE */ - ipw2100_wx_set_rts, /* SIOCSIWRTS */ - ipw2100_wx_get_rts, /* SIOCGIWRTS */ - ipw2100_wx_set_frag, /* SIOCSIWFRAG */ - ipw2100_wx_get_frag, /* SIOCGIWFRAG */ - ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */ - ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */ - ipw2100_wx_set_retry, /* SIOCSIWRETRY */ - ipw2100_wx_get_retry, /* SIOCGIWRETRY */ - ipw2100_wx_set_encode, /* SIOCSIWENCODE */ - ipw2100_wx_get_encode, /* SIOCGIWENCODE */ - ipw2100_wx_set_power, /* SIOCSIWPOWER */ - ipw2100_wx_get_power, /* SIOCGIWPOWER */ +#ifdef CONFIG_IPW2100_MONITOR +static int ipw2100_wx_set_crc_check(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct ipw2100_priv *priv = ieee80211_priv(dev); + int err, mode = *(int *)extra; + + mutex_lock(&priv->action_mutex); + if (!(priv->status & STATUS_INITIALIZED)) { + err = -EIO; + goto done; + } + + if (mode == 1) + priv->config |= CFG_CRC_CHECK; + else if (mode == 0) + priv->config &= ~CFG_CRC_CHECK; + else { + err = -EINVAL; + goto done; + } + err = 0; + + done: + mutex_unlock(&priv->action_mutex); + return err; +} + +static int ipw2100_wx_get_crc_check(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + /* + * This can be called at any time. No action lock required + */ + + struct ipw2100_priv *priv = ieee80211_priv(dev); + + if (priv->config & CFG_CRC_CHECK) + snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)"); + else + snprintf(wrqu->name, IFNAMSIZ, "CRC ignored (0)"); + + return 0; +} +#endif /* CONFIG_IPW2100_MONITOR */ + +static iw_handler ipw2100_wx_handlers[] = { + NULL, /* SIOCSIWCOMMIT */ + ipw2100_wx_get_name, /* SIOCGIWNAME */ + NULL, /* SIOCSIWNWID */ + NULL, /* SIOCGIWNWID */ + ipw2100_wx_set_freq, /* SIOCSIWFREQ */ + ipw2100_wx_get_freq, /* SIOCGIWFREQ */ + ipw2100_wx_set_mode, /* SIOCSIWMODE */ + ipw2100_wx_get_mode, /* SIOCGIWMODE */ + NULL, /* SIOCSIWSENS */ + NULL, /* SIOCGIWSENS */ + NULL, /* SIOCSIWRANGE */ + ipw2100_wx_get_range, /* SIOCGIWRANGE */ + NULL, /* SIOCSIWPRIV */ + NULL, /* SIOCGIWPRIV */ + NULL, /* SIOCSIWSTATS */ + NULL, /* SIOCGIWSTATS */ + NULL, /* SIOCSIWSPY */ + NULL, /* SIOCGIWSPY */ + NULL, /* SIOCGIWTHRSPY */ + NULL, /* SIOCWIWTHRSPY */ + ipw2100_wx_set_wap, /* SIOCSIWAP */ + ipw2100_wx_get_wap, /* SIOCGIWAP */ + ipw2100_wx_set_mlme, /* SIOCSIWMLME */ + NULL, /* SIOCGIWAPLIST -- deprecated */ + ipw2100_wx_set_scan, /* SIOCSIWSCAN */ + ipw2100_wx_get_scan, /* SIOCGIWSCAN */ + ipw2100_wx_set_essid, /* SIOCSIWESSID */ + ipw2100_wx_get_essid, /* SIOCGIWESSID */ + ipw2100_wx_set_nick, /* SIOCSIWNICKN */ + ipw2100_wx_get_nick, /* SIOCGIWNICKN */ + NULL, /* -- hole -- */ + NULL, /* -- hole -- */ + ipw2100_wx_set_rate, /* SIOCSIWRATE */ + ipw2100_wx_get_rate, /* SIOCGIWRATE */ + ipw2100_wx_set_rts, /* SIOCSIWRTS */ + ipw2100_wx_get_rts, /* SIOCGIWRTS */ + ipw2100_wx_set_frag, /* SIOCSIWFRAG */ + ipw2100_wx_get_frag, /* SIOCGIWFRAG */ + ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */ + ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */ + ipw2100_wx_set_retry, /* SIOCSIWRETRY */ + ipw2100_wx_get_retry, /* SIOCGIWRETRY */ + ipw2100_wx_set_encode, /* SIOCSIWENCODE */ + ipw2100_wx_get_encode, /* SIOCGIWENCODE */ + ipw2100_wx_set_power, /* SIOCSIWPOWER */ + ipw2100_wx_get_power, /* SIOCGIWPOWER */ + NULL, /* -- hole -- */ + NULL, /* -- hole -- */ + ipw2100_wx_set_genie, /* SIOCSIWGENIE */ + ipw2100_wx_get_genie, /* SIOCGIWGENIE */ + ipw2100_wx_set_auth, /* SIOCSIWAUTH */ + ipw2100_wx_get_auth, /* SIOCGIWAUTH */ + ipw2100_wx_set_encodeext, /* SIOCSIWENCODEEXT */ + ipw2100_wx_get_encodeext, /* SIOCGIWENCODEEXT */ + NULL, /* SIOCSIWPMKSA */ }; #define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV @@ -8106,61 +8088,62 @@ static iw_handler ipw2100_wx_handlers[] = #define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3 #define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4 #define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5 +#define IPW2100_PRIV_SET_CRC_CHECK SIOCIWFIRSTPRIV+6 +#define IPW2100_PRIV_GET_CRC_CHECK SIOCIWFIRSTPRIV+7 static const struct iw_priv_args ipw2100_private_args[] = { #ifdef CONFIG_IPW2100_MONITOR { - IPW2100_PRIV_SET_MONITOR, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" - }, + IPW2100_PRIV_SET_MONITOR, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"}, { - IPW2100_PRIV_RESET, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" - }, -#endif /* CONFIG_IPW2100_MONITOR */ + IPW2100_PRIV_RESET, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"}, +#endif /* CONFIG_IPW2100_MONITOR */ { - IPW2100_PRIV_SET_POWER, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power" - }, + IPW2100_PRIV_SET_POWER, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_power"}, + { + IPW2100_PRIV_GET_POWER, + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING, + "get_power"}, { - IPW2100_PRIV_GET_POWER, - 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_POWER_STRING, "get_power" - }, + IPW2100_PRIV_SET_LONGPREAMBLE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"}, { - IPW2100_PRIV_SET_LONGPREAMBLE, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble" - }, + IPW2100_PRIV_GET_LONGPREAMBLE, + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble"}, +#ifdef CONFIG_IPW2100_MONITOR + { + IPW2100_PRIV_SET_CRC_CHECK, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_crc_check"}, { - IPW2100_PRIV_GET_LONGPREAMBLE, - 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_preamble" - }, + IPW2100_PRIV_GET_CRC_CHECK, + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "get_crc_check"}, +#endif /* CONFIG_IPW2100_MONITOR */ }; static iw_handler ipw2100_private_handler[] = { #ifdef CONFIG_IPW2100_MONITOR ipw2100_wx_set_promisc, ipw2100_wx_reset, -#else /* CONFIG_IPW2100_MONITOR */ +#else /* CONFIG_IPW2100_MONITOR */ NULL, NULL, -#endif /* CONFIG_IPW2100_MONITOR */ +#endif /* CONFIG_IPW2100_MONITOR */ ipw2100_wx_set_powermode, ipw2100_wx_get_powermode, ipw2100_wx_set_preamble, ipw2100_wx_get_preamble, -}; - -static struct iw_handler_def ipw2100_wx_handler_def = -{ - .standard = ipw2100_wx_handlers, - .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler), - .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(ipw2100_private_args) / - sizeof(struct iw_priv_args), - .private = (iw_handler *)ipw2100_private_handler, - .private_args = (struct iw_priv_args *)ipw2100_private_args, +#ifdef CONFIG_IPW2100_MONITOR + ipw2100_wx_set_crc_check, + ipw2100_wx_get_crc_check, +#else /* CONFIG_IPW2100_MONITOR */ + NULL, + NULL, +#endif /* CONFIG_IPW2100_MONITOR */ }; /* @@ -8168,7 +8151,7 @@ static struct iw_handler_def ipw2100_wx_handler_def = * Called by /proc/net/wireless * Also called by SIOCGIWSTATS */ -static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) +static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev) { enum { POOR = 30, @@ -8188,7 +8171,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) u32 ord_len = sizeof(u32); if (!priv) - return (struct iw_statistics *) NULL; + return (struct iw_statistics *)NULL; wstats = &priv->wstats; @@ -8205,7 +8188,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) wstats->qual.noise = 0; wstats->qual.updated = 7; wstats->qual.updated |= IW_QUAL_NOISE_INVALID | - IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; + IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; return wstats; } @@ -8213,7 +8196,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) &missed_beacons, &ord_len)) goto fail_get_ordinal; - /* If we don't have a connection the quality and level is 0*/ + /* If we don't have a connection the quality and level is 0 */ if (!(priv->status & STATUS_ASSOCIATED)) { wstats->qual.qual = 0; wstats->qual.level = 0; @@ -8230,10 +8213,10 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR; else if (rssi < 30) rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) / - 10 + GOOD; + 10 + GOOD; else rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) / - 10 + VERY_GOOD; + 10 + VERY_GOOD; if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_PERCENT_RETRIES, &tx_retries, &ord_len)) @@ -8247,29 +8230,29 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; else if (tx_retries > 50) tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / - 15 + GOOD; + 15 + GOOD; else tx_qual = (50 - tx_retries) * - (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; + (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; if (missed_beacons > 50) beacon_qual = (60 - missed_beacons) * POOR / 10; else if (missed_beacons > 40) beacon_qual = (50 - missed_beacons) * (FAIR - POOR) / - 10 + POOR; + 10 + POOR; else if (missed_beacons > 32) beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) / - 18 + FAIR; + 18 + FAIR; else if (missed_beacons > 20) beacon_qual = (32 - missed_beacons) * - (VERY_GOOD - GOOD) / 20 + GOOD; + (VERY_GOOD - GOOD) / 20 + GOOD; else beacon_qual = (20 - missed_beacons) * - (PERFECT - VERY_GOOD) / 20 + VERY_GOOD; + (PERFECT - VERY_GOOD) / 20 + VERY_GOOD; quality = min(beacon_qual, min(tx_qual, rssi_qual)); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (beacon_qual == quality) IPW_DEBUG_WX("Quality clamped by Missed Beacons\n"); else if (tx_qual == quality) @@ -8288,7 +8271,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) wstats->qual.updated = 7; wstats->qual.updated |= IW_QUAL_NOISE_INVALID; - /* FIXME: this is percent and not a # */ + /* FIXME: this is percent and not a # */ wstats->miss.beacon = missed_beacons; if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_TX_FAILURES, @@ -8298,25 +8281,37 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device * dev) return wstats; - fail_get_ordinal: + fail_get_ordinal: IPW_DEBUG_WX("failed querying ordinals.\n"); - return (struct iw_statistics *) NULL; + return (struct iw_statistics *)NULL; } -static void ipw2100_wx_event_work(struct ipw2100_priv *priv) +static struct iw_handler_def ipw2100_wx_handler_def = { + .standard = ipw2100_wx_handlers, + .num_standard = ARRAY_SIZE(ipw2100_wx_handlers), + .num_private = ARRAY_SIZE(ipw2100_private_handler), + .num_private_args = ARRAY_SIZE(ipw2100_private_args), + .private = (iw_handler *) ipw2100_private_handler, + .private_args = (struct iw_priv_args *)ipw2100_private_args, + .get_wireless_stats = ipw2100_wx_wireless_stats, +}; + +static void ipw2100_wx_event_work(struct work_struct *work) { + struct ipw2100_priv *priv = + container_of(work, struct ipw2100_priv, wx_event_work.work); union iwreq_data wrqu; int len = ETH_ALEN; if (priv->status & STATUS_STOPPING) return; - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); IPW_DEBUG_WX("enter\n"); - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -8324,35 +8319,30 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv) if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) || priv->status & STATUS_RF_KILL_MASK || ipw2100_get_ordinal(priv, IPW_ORD_STAT_ASSN_AP_BSSID, - &priv->bssid, &len)) { + &priv->bssid, &len)) { memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); } else { /* We now have the BSSID, so can finish setting to the full * associated state */ memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN); - memcpy(&priv->ieee->bssid, priv->bssid, ETH_ALEN); + memcpy(priv->ieee->bssid, priv->bssid, ETH_ALEN); priv->status &= ~STATUS_ASSOCIATING; priv->status |= STATUS_ASSOCIATED; netif_carrier_on(priv->net_dev); - if (netif_queue_stopped(priv->net_dev)) { - IPW_DEBUG_INFO("Waking net queue.\n"); - netif_wake_queue(priv->net_dev); - } else { - IPW_DEBUG_INFO("Starting net queue.\n"); - netif_start_queue(priv->net_dev); - } + netif_wake_queue(priv->net_dev); } if (!(priv->status & STATUS_ASSOCIATED)) { IPW_DEBUG_WX("Configuring ESSID\n"); - down(&priv->action_sem); + mutex_lock(&priv->action_mutex); /* This is a disassociation event, so kick the firmware to * look for another AP */ if (priv->config & CFG_STATIC_ESSID) - ipw2100_set_essid(priv, priv->essid, priv->essid_len, 0); + ipw2100_set_essid(priv, priv->essid, priv->essid_len, + 0); else ipw2100_set_essid(priv, NULL, 0, 0); - up(&priv->action_sem); + mutex_unlock(&priv->action_mutex); } wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); @@ -8372,7 +8362,6 @@ static void ipw2100_wx_event_work(struct ipw2100_priv *priv) #define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw" - /* BINARY FIRMWARE HEADER FORMAT @@ -8394,12 +8383,10 @@ struct ipw2100_fw_header { unsigned int uc_size; } __attribute__ ((packed)); - - static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw) { struct ipw2100_fw_header *h = - (struct ipw2100_fw_header *)fw->fw_entry->data; + (struct ipw2100_fw_header *)fw->fw_entry->data; if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) { printk(KERN_WARNING DRV_NAME ": Firmware image not compatible " @@ -8418,7 +8405,6 @@ static int ipw2100_mod_firmware_load(struct ipw2100_fw *fw) return 0; } - static int ipw2100_get_firmware(struct ipw2100_priv *priv, struct ipw2100_fw *fw) { @@ -8426,7 +8412,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv, int rc; IPW_DEBUG_INFO("%s: Using hotplug firmware load.\n", - priv->net_dev->name); + priv->net_dev->name); switch (priv->ieee->iw_mode) { case IW_MODE_ADHOC: @@ -8452,7 +8438,7 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv, return rc; } IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data, - fw->fw_entry->size); + fw->fw_entry->size); ipw2100_mod_firmware_load(fw); @@ -8468,7 +8454,6 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv, fw->fw_entry = NULL; } - static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf, size_t max) { @@ -8477,8 +8462,7 @@ static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf, u32 tmp; int i; /* firmware version is an ascii string (max len of 14) */ - if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, - ver, &len)) + if (ipw2100_get_ordinal(priv, IPW_ORD_STAT_FW_VER_NUM, ver, &len)) return -EIO; tmp = max; if (len >= max) @@ -8495,8 +8479,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf, u32 ver; u32 len = sizeof(ver); /* microcode version is a 32 bit integer */ - if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, - &ver, &len)) + if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, &ver, &len)) return -EIO; return snprintf(buf, max, "%08X", ver); } @@ -8504,8 +8487,7 @@ static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf, /* * On exit, the firmware will have been freed from the fw list */ -static int ipw2100_fw_download(struct ipw2100_priv *priv, - struct ipw2100_fw *fw) +static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw) { /* firmware is constructed of N contiguous entries, each entry is * structured as: @@ -8513,7 +8495,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv, * offset sie desc * 0 4 address to write to * 4 2 length of data run - * 6 length data + * 6 length data */ unsigned int addr; unsigned short len; @@ -8522,12 +8504,12 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv, unsigned int firmware_data_left = fw->fw.size; while (firmware_data_left > 0) { - addr = *(u32 *)(firmware_data); - firmware_data += 4; + addr = *(u32 *) (firmware_data); + firmware_data += 4; firmware_data_left -= 4; - len = *(u16 *)(firmware_data); - firmware_data += 2; + len = *(u16 *) (firmware_data); + firmware_data += 2; firmware_data_left -= 2; if (len > 32) { @@ -8538,7 +8520,7 @@ static int ipw2100_fw_download(struct ipw2100_priv *priv, } write_nic_memory(priv->net_dev, addr, len, firmware_data); - firmware_data += len; + firmware_data += len; firmware_data_left -= len; } @@ -8652,21 +8634,19 @@ static int ipw2100_ucode_download(struct ipw2100_priv *priv, for (i = 0; i < 30; i++) { /* Read alive response structure */ for (j = 0; - j < (sizeof(struct symbol_alive_response) >> 1); - j++) - read_nic_word(dev, 0x210004, - ((u16 *)&response) + j); + j < (sizeof(struct symbol_alive_response) >> 1); j++) + read_nic_word(dev, 0x210004, ((u16 *) & response) + j); - if ((response.cmd_id == 1) && - (response.ucode_valid == 0x1)) + if ((response.cmd_id == 1) && (response.ucode_valid == 0x1)) break; udelay(10); } if (i == 30) { - printk(KERN_ERR DRV_NAME ": %s: No response from Symbol - hw not alive\n", + printk(KERN_ERR DRV_NAME + ": %s: No response from Symbol - hw not alive\n", dev->name); - printk_buf(IPW_DL_ERROR, (u8*)&response, sizeof(response)); + printk_buf(IPW_DL_ERROR, (u8 *) & response, sizeof(response)); return -EIO; }