From 0edd5b44913cd0aba6f23b626b407f70bb3fb018 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Wed, 7 Sep 2005 00:48:31 -0400 Subject: [PATCH] [wireless ieee80211,ipw2200] Lindent source code No code changes, just Lindent + manual fixups. This prepares us for updating to the latest Intel driver code, plus gives the source code a nice facelift. --- drivers/net/wireless/ipw2200.c | 2270 +++++++++++++------------- drivers/net/wireless/ipw2200.h | 406 ++--- net/ieee80211/ieee80211_crypt.c | 27 +- net/ieee80211/ieee80211_crypt_ccmp.c | 47 +- net/ieee80211/ieee80211_crypt_tkip.c | 133 +- net/ieee80211/ieee80211_crypt_wep.c | 30 +- net/ieee80211/ieee80211_module.c | 40 +- net/ieee80211/ieee80211_rx.c | 310 ++-- net/ieee80211/ieee80211_tx.c | 66 +- net/ieee80211/ieee80211_wx.c | 68 +- 10 files changed, 1648 insertions(+), 1749 deletions(-) diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 2a3bd607a5..b7f275c00d 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -72,7 +72,8 @@ static void ipw_rx_queue_replenish(void *); static int ipw_up(struct ipw_priv *); static void ipw_down(struct ipw_priv *); static int ipw_config(struct ipw_priv *); -static int init_supported_rates(struct ipw_priv *priv, struct ipw_supported_rates *prates); +static int init_supported_rates(struct ipw_priv *priv, + struct ipw_supported_rates *prates); static u8 band_b_active_channel[MAX_B_CHANNELS] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 @@ -102,7 +103,7 @@ static int is_valid_channel(int mode_mask, int channel) } 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; @@ -136,7 +137,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; @@ -161,21 +162,24 @@ static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg); static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value); static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c) { - IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg8(a, b, c); } static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value); static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c) { - IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg16(a, b, c); } static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value); static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) { - IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg32(a, b, c); } @@ -195,24 +199,30 @@ static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) _ipw_write32(ipw, ofs, val) #define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) -static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32)(ofs)); +static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read8(ipw, ofs); } + #define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) #define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) -static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32)(ofs)); +static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read16(ipw, ofs); } + #define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) #define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) -static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32)(ofs)); +static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read32(ipw, ofs); } + #define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); @@ -220,34 +230,30 @@ static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); IPW_DEBUG_IO("%s %d: read_inddirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ _ipw_read_indirect(a, b, c, d) -static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *data, int num); +static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, + int num); #define ipw_write_indirect(a, b, c, d) \ IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ _ipw_write_indirect(a, b, c, d) /* indirect write s */ -static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, - u32 value) +static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) { - IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", - priv, reg, value); + IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv, reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg); _ipw_write32(priv, CX2_INDIRECT_DATA, value); } - static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value) { IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); _ipw_write8(priv, CX2_INDIRECT_DATA, value); IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n", - (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), - value); + (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), value); } -static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, - u16 value) +static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value) { IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); @@ -262,7 +268,7 @@ static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg) _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); IPW_DEBUG_IO(" reg = 0x%8X : \n", reg); word = _ipw_read32(priv, CX2_INDIRECT_DATA); - return (word >> ((reg & 0x3)*8)) & 0xff; + return (word >> ((reg & 0x3) * 8)) & 0xff; } static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg) @@ -302,7 +308,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); aligned_len = num & CX2_INDIRECT_ADDR_MASK; for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - *(u32*)buf = ipw_read32(priv, CX2_AUTOINC_DATA); + *(u32 *) buf = ipw_read32(priv, CX2_AUTOINC_DATA); /* Copy the last nibble */ dif_len = num - aligned_len; @@ -311,7 +317,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, *buf = ipw_read8(priv, CX2_INDIRECT_DATA + i); } -static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf, +static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, int num) { u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK; @@ -335,7 +341,7 @@ static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf, _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); aligned_len = num & CX2_INDIRECT_ADDR_MASK; for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32*)buf); + _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32 *) buf); /* Copy the last nibble */ dif_len = num - aligned_len; @@ -428,20 +434,18 @@ static void ipw_dump_nic_error_log(struct ipw_priv *priv) } for (i = ERROR_START_OFFSET; - i <= count * ERROR_ELEM_SIZE; - i += ERROR_ELEM_SIZE) { - desc = ipw_read_reg32(priv, base + i); - time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); - blink1 = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); - blink2 = ipw_read_reg32(priv, base + i + 3*sizeof(u32)); - ilink1 = ipw_read_reg32(priv, base + i + 4*sizeof(u32)); - ilink2 = ipw_read_reg32(priv, base + i + 5*sizeof(u32)); - idata = ipw_read_reg32(priv, base + i + 6*sizeof(u32)); + i <= count * ERROR_ELEM_SIZE; i += ERROR_ELEM_SIZE) { + desc = ipw_read_reg32(priv, base + i); + time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32)); + blink1 = ipw_read_reg32(priv, base + i + 2 * sizeof(u32)); + blink2 = ipw_read_reg32(priv, base + i + 3 * sizeof(u32)); + ilink1 = ipw_read_reg32(priv, base + i + 4 * sizeof(u32)); + ilink2 = ipw_read_reg32(priv, base + i + 5 * sizeof(u32)); + idata = ipw_read_reg32(priv, base + i + 6 * sizeof(u32)); - IPW_ERROR( - "%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", - ipw_error_desc(desc), time, blink1, blink2, - ilink1, ilink2, idata); + IPW_ERROR("%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", + ipw_error_desc(desc), time, blink1, blink2, + ilink1, ilink2, idata); } } @@ -456,11 +460,10 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv) IPW_ERROR("Start IPW Event Log Dump:\n"); for (i = EVENT_START_OFFSET; - i <= count * EVENT_ELEM_SIZE; - i += EVENT_ELEM_SIZE) { + i <= count * EVENT_ELEM_SIZE; i += EVENT_ELEM_SIZE) { ev = ipw_read_reg32(priv, base + i); - time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); - data = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); + time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32)); + data = ipw_read_reg32(priv, base + i + 2 * sizeof(u32)); #ifdef CONFIG_IPW_DEBUG IPW_ERROR("%i\t0x%08x\t%i\n", time, data, ev); @@ -468,8 +471,7 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv) } } -static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, - u32 *len) +static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, u32 * len) { u32 addr, field_info, field_len, field_count, total_len; @@ -513,11 +515,11 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, } IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n", - ord, priv->table0_addr + (ord << 2)); + ord, priv->table0_addr + (ord << 2)); *len = sizeof(u32); ord <<= 2; - *((u32 *)val) = ipw_read32(priv, priv->table0_addr + ord); + *((u32 *) val) = ipw_read32(priv, priv->table0_addr + ord); break; case IPW_ORD_TABLE_1_MASK: @@ -545,7 +547,8 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, return -EINVAL; } - *((u32 *)val) = ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); + *((u32 *) val) = + ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); *len = sizeof(u32); break; @@ -573,13 +576,16 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, /* get the second DW of statistics ; * two 16-bit words - first is length, second is count */ - field_info = ipw_read_reg32(priv, priv->table2_addr + (ord << 3) + sizeof(u32)); + field_info = + ipw_read_reg32(priv, + priv->table2_addr + (ord << 3) + + sizeof(u32)); /* 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 not enought memory */ total_len = field_len * field_count; @@ -604,7 +610,6 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, } - return 0; } @@ -624,7 +629,7 @@ static void ipw_init_ordinals(struct ipw_priv *priv) priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2); priv->table2_len = ipw_read_reg32(priv, priv->table2_addr); - priv->table2_len &= 0x0000ffff; /* use first two bytes */ + priv->table2_len &= 0x0000ffff; /* use first two bytes */ IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n", priv->table2_addr, priv->table2_len); @@ -643,7 +648,7 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf) return sprintf(buf, "0x%08X\n", ipw_debug_level); } static ssize_t store_debug_level(struct device_driver *d, - const char *buf, size_t count) + const char *buf, size_t count) { char *p = (char *)buf; u32 val; @@ -668,11 +673,12 @@ static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, store_debug_level); static ssize_t show_status(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ipw_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_cfg(struct device *d, struct device_attribute *attr, @@ -681,10 +687,11 @@ static ssize_t show_cfg(struct device *d, struct device_attribute *attr, struct ipw_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_nic_type(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ipw_priv *p = d->driver_data; u8 type = p->eeprom[EEPROM_NIC_TYPE]; @@ -704,44 +711,50 @@ static ssize_t show_nic_type(struct device *d, return sprintf(buf, "UNKNOWN\n"); } + static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL); static ssize_t dump_error_log(struct device *d, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { char *p = (char *)buf; if (p[0] == '1') - ipw_dump_nic_error_log((struct ipw_priv*)d->driver_data); + ipw_dump_nic_error_log((struct ipw_priv *)d->driver_data); return strnlen(buf, count); } + static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); static ssize_t dump_event_log(struct device *d, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { char *p = (char *)buf; if (p[0] == '1') - ipw_dump_nic_event_log((struct ipw_priv*)d->driver_data); + ipw_dump_nic_event_log((struct ipw_priv *)d->driver_data); return strnlen(buf, count); } + static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); static ssize_t show_ucode_version(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; - if(ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) + if (ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } -static DEVICE_ATTR(ucode_version, S_IWUSR|S_IRUGO, show_ucode_version, NULL); + +static DEVICE_ATTR(ucode_version, S_IWUSR | S_IRUGO, show_ucode_version, NULL); static ssize_t show_rtc(struct device *d, struct device_attribute *attr, char *buf) @@ -749,36 +762,38 @@ static ssize_t show_rtc(struct device *d, struct device_attribute *attr, u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; - if(ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) + if (ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } -static DEVICE_ATTR(rtc, S_IWUSR|S_IRUGO, show_rtc, NULL); + +static DEVICE_ATTR(rtc, S_IWUSR | S_IRUGO, show_rtc, NULL); /* * Add a device attribute to view/control the delay between eeprom * operations. */ static ssize_t show_eeprom_delay(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { - int n = ((struct ipw_priv*)d->driver_data)->eeprom_delay; + int n = ((struct ipw_priv *)d->driver_data)->eeprom_delay; return sprintf(buf, "%i\n", n); } static ssize_t store_eeprom_delay(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *p = d->driver_data; sscanf(buf, "%i", &p->eeprom_delay); return strnlen(buf, count); } -static DEVICE_ATTR(eeprom_delay, S_IWUSR|S_IRUGO, - show_eeprom_delay,store_eeprom_delay); + +static DEVICE_ATTR(eeprom_delay, S_IWUSR | S_IRUGO, + show_eeprom_delay, store_eeprom_delay); static ssize_t show_command_event_reg(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *p = d->driver_data; @@ -787,8 +802,8 @@ static ssize_t show_command_event_reg(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_command_event_reg(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { u32 reg; struct ipw_priv *p = d->driver_data; @@ -797,11 +812,12 @@ static ssize_t store_command_event_reg(struct device *d, ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg); return strnlen(buf, count); } -static DEVICE_ATTR(command_event_reg, S_IWUSR|S_IRUGO, - show_command_event_reg,store_command_event_reg); + +static DEVICE_ATTR(command_event_reg, S_IWUSR | S_IRUGO, + show_command_event_reg, store_command_event_reg); static ssize_t show_mem_gpio_reg(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *p = d->driver_data; @@ -810,8 +826,8 @@ static ssize_t show_mem_gpio_reg(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_mem_gpio_reg(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { u32 reg; struct ipw_priv *p = d->driver_data; @@ -820,11 +836,12 @@ static ssize_t store_mem_gpio_reg(struct device *d, ipw_write_reg32(p, 0x301100, reg); return strnlen(buf, count); } -static DEVICE_ATTR(mem_gpio_reg, S_IWUSR|S_IRUGO, - show_mem_gpio_reg,store_mem_gpio_reg); + +static DEVICE_ATTR(mem_gpio_reg, S_IWUSR | S_IRUGO, + show_mem_gpio_reg, store_mem_gpio_reg); static ssize_t show_indirect_dword(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -836,8 +853,8 @@ static ssize_t show_indirect_dword(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_indirect_dword(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -845,11 +862,12 @@ static ssize_t store_indirect_dword(struct device *d, priv->status |= STATUS_INDIRECT_DWORD; return strnlen(buf, count); } -static DEVICE_ATTR(indirect_dword, S_IWUSR|S_IRUGO, - show_indirect_dword,store_indirect_dword); + +static DEVICE_ATTR(indirect_dword, S_IWUSR | S_IRUGO, + show_indirect_dword, store_indirect_dword); static ssize_t show_indirect_byte(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u8 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -861,8 +879,8 @@ static ssize_t show_indirect_byte(struct device *d, return sprintf(buf, "0x%02x\n", reg); } static ssize_t store_indirect_byte(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -870,11 +888,12 @@ static ssize_t store_indirect_byte(struct device *d, priv->status |= STATUS_INDIRECT_BYTE; return strnlen(buf, count); } -static DEVICE_ATTR(indirect_byte, S_IWUSR|S_IRUGO, + +static DEVICE_ATTR(indirect_byte, S_IWUSR | S_IRUGO, show_indirect_byte, store_indirect_byte); static ssize_t show_direct_dword(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -887,8 +906,8 @@ static ssize_t show_direct_dword(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_direct_dword(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -896,9 +915,9 @@ static ssize_t store_direct_dword(struct device *d, priv->status |= STATUS_DIRECT_DWORD; return strnlen(buf, count); } -static DEVICE_ATTR(direct_dword, S_IWUSR|S_IRUGO, - show_direct_dword,store_direct_dword); +static DEVICE_ATTR(direct_dword, S_IWUSR | S_IRUGO, + show_direct_dword, store_direct_dword); static inline int rf_kill_active(struct ipw_priv *priv) { @@ -911,7 +930,7 @@ static inline int rf_kill_active(struct ipw_priv *priv) } 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) @@ -919,7 +938,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 3 - Both HW and SW baed RF kill active */ struct ipw_priv *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); } @@ -927,7 +946,7 @@ static int ipw_radio_kill_sw(struct ipw_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"); @@ -956,8 +975,8 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) return 1; } -static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -965,7 +984,8 @@ static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, 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 void ipw_irq_tasklet(struct ipw_priv *priv) { @@ -990,7 +1010,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) if (inta & CX2_INTA_BIT_TX_CMD_QUEUE) { IPW_DEBUG_HC("Command completed.\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq_cmd, -1); + rc = ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1); priv->status &= ~STATUS_HCMD_ACTIVE; wake_up_interruptible(&priv->wait_command_queue); handled |= CX2_INTA_BIT_TX_CMD_QUEUE; @@ -998,25 +1018,25 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) if (inta & CX2_INTA_BIT_TX_QUEUE_1) { IPW_DEBUG_TX("TX_QUEUE_1\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[0], 0); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[0], 0); handled |= CX2_INTA_BIT_TX_QUEUE_1; } if (inta & CX2_INTA_BIT_TX_QUEUE_2) { IPW_DEBUG_TX("TX_QUEUE_2\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[1], 1); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[1], 1); handled |= CX2_INTA_BIT_TX_QUEUE_2; } if (inta & CX2_INTA_BIT_TX_QUEUE_3) { IPW_DEBUG_TX("TX_QUEUE_3\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[2], 2); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[2], 2); handled |= CX2_INTA_BIT_TX_QUEUE_3; } if (inta & CX2_INTA_BIT_TX_QUEUE_4) { IPW_DEBUG_TX("TX_QUEUE_4\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[3], 3); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[3], 3); handled |= CX2_INTA_BIT_TX_QUEUE_4; } @@ -1074,8 +1094,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) } if (handled != inta) { - IPW_ERROR("Unhandled INTA bits 0x%08x\n", - inta & ~handled); + IPW_ERROR("Unhandled INTA bits 0x%08x\n", inta & ~handled); } /* enable all interrupts */ @@ -1143,7 +1162,7 @@ static char *get_cmd_string(u8 cmd) return "UNKNOWN"; } } -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW_DEBUG */ #define HOST_COMPLETE_TIMEOUT HZ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) @@ -1159,15 +1178,16 @@ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", get_cmd_string(cmd->cmd), cmd->cmd, cmd->len); - printk_buf(IPW_DL_HOST_COMMAND, (u8*)cmd->param, cmd->len); + printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len); rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0); if (rc) return rc; - rc = wait_event_interruptible_timeout( - priv->wait_command_queue, !(priv->status & STATUS_HCMD_ACTIVE), - HOST_COMPLETE_TIMEOUT); + rc = wait_event_interruptible_timeout(priv->wait_command_queue, + !(priv-> + status & STATUS_HCMD_ACTIVE), + HOST_COMPLETE_TIMEOUT); if (rc == 0) { IPW_DEBUG_INFO("Command completion failed out after %dms.\n", jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); @@ -1215,7 +1235,7 @@ static int ipw_send_system_config(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,config,sizeof(*config)); + memcpy(&cmd.param, config, sizeof(*config)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SYSTEM_CONFIG command\n"); return -1; @@ -1224,7 +1244,7 @@ static int ipw_send_system_config(struct ipw_priv *priv, return 0; } -static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len) +static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len) { struct host_cmd cmd = { .cmd = IPW_CMD_SSID, @@ -1245,7 +1265,7 @@ static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len) return 0; } -static int ipw_send_adapter_address(struct ipw_priv *priv, u8 *mac) +static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac) { struct host_cmd cmd = { .cmd = IPW_CMD_ADAPTER_ADDRESS, @@ -1284,9 +1304,6 @@ static void ipw_adapter_restart(void *adapter) } } - - - #define IPW_SCAN_CHECK_WATCHDOG (5 * HZ) static void ipw_scan_check(void *data) @@ -1313,7 +1330,7 @@ static int ipw_send_scan_request_ext(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,request,sizeof(*request)); + memcpy(&cmd.param, request, sizeof(*request)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SCAN_REQUEST_EXT command\n"); return -1; @@ -1351,7 +1368,7 @@ static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens) .len = sizeof(struct ipw_sensitivity_calib) }; struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *) - &cmd.param; + &cmd.param; calib->beacon_rssi_raw = sens; if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SENSITIVITY CALIB command\n"); @@ -1374,7 +1391,7 @@ static int ipw_send_associate(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,associate,sizeof(*associate)); + memcpy(&cmd.param, associate, sizeof(*associate)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send ASSOCIATE command\n"); return -1; @@ -1396,7 +1413,7 @@ static int ipw_send_supported_rates(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,rates,sizeof(*rates)); + memcpy(&cmd.param, rates, sizeof(*rates)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SUPPORTED_RATES command\n"); return -1; @@ -1440,7 +1457,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off) return -1; } - *((u32*)&cmd.param) = phy_off; + *((u32 *) & cmd.param) = phy_off; if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send CARD_DISABLE command\n"); @@ -1451,8 +1468,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off) } #endif -static int ipw_send_tx_power(struct ipw_priv *priv, - struct ipw_tx_power *power) +static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power) { struct host_cmd cmd = { .cmd = IPW_CMD_TX_POWER, @@ -1464,7 +1480,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,power,sizeof(*power)); + memcpy(&cmd.param, power, sizeof(*power)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send TX_POWER command\n"); return -1; @@ -1527,7 +1543,7 @@ static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode) .cmd = IPW_CMD_POWER_MODE, .len = sizeof(u32) }; - u32 *param = (u32*)(&cmd.param); + u32 *param = (u32 *) (&cmd.param); if (!priv) { IPW_ERROR("Invalid args\n"); @@ -1585,67 +1601,67 @@ static inline void eeprom_write_reg(struct ipw_priv *p, u32 data) } /* perform a chip select operation */ -static inline void eeprom_cs(struct ipw_priv* priv) +static inline void eeprom_cs(struct ipw_priv *priv) { - eeprom_write_reg(priv,0); - eeprom_write_reg(priv,EEPROM_BIT_CS); - eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); - eeprom_write_reg(priv,EEPROM_BIT_CS); + eeprom_write_reg(priv, 0); + eeprom_write_reg(priv, EEPROM_BIT_CS); + eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); } /* perform a chip select operation */ -static inline void eeprom_disable_cs(struct ipw_priv* priv) +static inline void eeprom_disable_cs(struct ipw_priv *priv) { - eeprom_write_reg(priv,EEPROM_BIT_CS); - eeprom_write_reg(priv,0); - eeprom_write_reg(priv,EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); + eeprom_write_reg(priv, 0); + eeprom_write_reg(priv, EEPROM_BIT_SK); } /* push a single bit down to the eeprom */ -static inline void eeprom_write_bit(struct ipw_priv *p,u8 bit) +static inline void eeprom_write_bit(struct ipw_priv *p, u8 bit) { - int d = ( bit ? EEPROM_BIT_DI : 0); - eeprom_write_reg(p,EEPROM_BIT_CS|d); - eeprom_write_reg(p,EEPROM_BIT_CS|d|EEPROM_BIT_SK); + int d = (bit ? EEPROM_BIT_DI : 0); + eeprom_write_reg(p, EEPROM_BIT_CS | d); + eeprom_write_reg(p, EEPROM_BIT_CS | d | EEPROM_BIT_SK); } /* push an opcode followed by an address down to the eeprom */ -static void eeprom_op(struct ipw_priv* priv, u8 op, u8 addr) +static void eeprom_op(struct ipw_priv *priv, u8 op, u8 addr) { int i; eeprom_cs(priv); - eeprom_write_bit(priv,1); - eeprom_write_bit(priv,op&2); - eeprom_write_bit(priv,op&1); - for ( i=7; i>=0; i-- ) { - eeprom_write_bit(priv,addr&(1<= 0; i--) { + eeprom_write_bit(priv, addr & (1 << i)); } } /* pull 16 bits off the eeprom, one bit at a time */ -static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr) +static u16 eeprom_read_u16(struct ipw_priv *priv, u8 addr) { int i; - u16 r=0; + u16 r = 0; /* Send READ Opcode */ - eeprom_op(priv,EEPROM_CMD_READ,addr); + eeprom_op(priv, EEPROM_CMD_READ, addr); /* Send dummy bit */ - eeprom_write_reg(priv,EEPROM_BIT_CS); + eeprom_write_reg(priv, EEPROM_BIT_CS); /* Read the byte off the eeprom one bit at a time */ - for ( i=0; i<16; i++ ) { + for (i = 0; i < 16; i++) { u32 data = 0; - eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); - eeprom_write_reg(priv,EEPROM_BIT_CS); - data = ipw_read_reg32(priv,FW_MEM_REG_EEPROM_ACCESS); - r = (r<<1) | ((data & EEPROM_BIT_DO)?1:0); + eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); + data = ipw_read_reg32(priv, FW_MEM_REG_EEPROM_ACCESS); + r = (r << 1) | ((data & EEPROM_BIT_DO) ? 1 : 0); } /* Send another dummy bit */ - eeprom_write_reg(priv,0); + eeprom_write_reg(priv, 0); eeprom_disable_cs(priv); return r; @@ -1653,9 +1669,9 @@ static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr) /* helper function for pulling the mac address out of the private */ /* data's copy of the eeprom data */ -static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac) +static void eeprom_parse_mac(struct ipw_priv *priv, u8 * mac) { - u8* ee = (u8*)priv->eeprom; + u8 *ee = (u8 *) priv->eeprom; memcpy(mac, &ee[EEPROM_MAC_ADDRESS], 6); } @@ -1670,26 +1686,25 @@ static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac) static void ipw_eeprom_init_sram(struct ipw_priv *priv) { int i; - u16 *eeprom = (u16 *)priv->eeprom; + u16 *eeprom = (u16 *) priv->eeprom; IPW_DEBUG_TRACE(">>\n"); /* read entire contents of eeprom into private buffer */ - for ( i=0; i<128; i++ ) - eeprom[i] = eeprom_read_u16(priv,(u8)i); + for (i = 0; i < 128; i++) + eeprom[i] = eeprom_read_u16(priv, (u8) i); /* If the data looks correct, then copy it to our private copy. Otherwise let the firmware know to perform the operation on it's own - */ + */ if ((priv->eeprom + EEPROM_VERSION) != 0) { IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); /* write the eeprom data to sram */ - for( i=0; ieeprom[i]); + for (i = 0; i < CX2_EEPROM_IMAGE_SIZE; i++) + ipw_write8(priv, IPW_EEPROM_DATA + i, priv->eeprom[i]); /* Do not load eeprom data on fatal error or suspend */ ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0); @@ -1703,11 +1718,11 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv) IPW_DEBUG_TRACE("<<\n"); } - static inline void ipw_zero_memory(struct ipw_priv *priv, u32 start, u32 count) { count >>= 2; - if (!count) return; + if (!count) + return; _ipw_write32(priv, CX2_AUTOINC_ADDR, start); while (count--) _ipw_write32(priv, CX2_AUTOINC_DATA, 0); @@ -1721,7 +1736,7 @@ static inline void ipw_fw_dma_reset_command_blocks(struct ipw_priv *priv) } static int ipw_fw_dma_enable(struct ipw_priv *priv) -{ /* start dma engine but no transfers yet*/ +{ /* start dma engine but no transfers yet */ IPW_DEBUG_FW(">> : \n"); @@ -1749,12 +1764,16 @@ static void ipw_fw_dma_abort(struct ipw_priv *priv) IPW_DEBUG_FW("<< \n"); } -static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, struct command_block *cb) +static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, + struct command_block *cb) { - u32 address = CX2_SHARED_SRAM_DMA_CONTROL + (sizeof(struct command_block) * index); + u32 address = + CX2_SHARED_SRAM_DMA_CONTROL + + (sizeof(struct command_block) * index); IPW_DEBUG_FW(">> :\n"); - ipw_write_indirect(priv, address, (u8*)cb, (int)sizeof(struct command_block)); + ipw_write_indirect(priv, address, (u8 *) cb, + (int)sizeof(struct command_block)); IPW_DEBUG_FW("<< :\n"); return 0; @@ -1764,17 +1783,20 @@ static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, stru static int ipw_fw_dma_kick(struct ipw_priv *priv) { u32 control = 0; - u32 index=0; + u32 index = 0; IPW_DEBUG_FW(">> :\n"); for (index = 0; index < priv->sram_desc.last_cb_index; index++) - ipw_fw_dma_write_command_block(priv, index, &priv->sram_desc.cb_list[index]); + ipw_fw_dma_write_command_block(priv, index, + &priv->sram_desc.cb_list[index]); /* Enable the DMA in the CSR register */ - ipw_clear_bit(priv, CX2_RESET_REG,CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); + ipw_clear_bit(priv, CX2_RESET_REG, + CX2_RESET_REG_MASTER_DISABLED | + CX2_RESET_REG_STOP_MASTER); - /* Set the Start bit. */ + /* Set the Start bit. */ control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_START; ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control); @@ -1785,25 +1807,25 @@ static int ipw_fw_dma_kick(struct ipw_priv *priv) static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv) { u32 address; - u32 register_value=0; - u32 cb_fields_address=0; + u32 register_value = 0; + u32 cb_fields_address = 0; IPW_DEBUG_FW(">> :\n"); - address = ipw_read_reg32(priv,CX2_DMA_I_CURRENT_CB); - IPW_DEBUG_FW_INFO("Current CB is 0x%x \n",address); + address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); + IPW_DEBUG_FW_INFO("Current CB is 0x%x \n", address); /* Read the DMA Controlor register */ register_value = ipw_read_reg32(priv, CX2_DMA_I_DMA_CONTROL); - IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n", register_value); - /* Print the CB values*/ + /* Print the CB values */ cb_fields_address = address; register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n", register_value); cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n", register_value); cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); @@ -1812,7 +1834,7 @@ static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv) cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n", register_value); IPW_DEBUG_FW(">> :\n"); } @@ -1823,13 +1845,13 @@ static int ipw_fw_dma_command_block_index(struct ipw_priv *priv) u32 current_cb_index = 0; IPW_DEBUG_FW("<< :\n"); - current_cb_address= ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); + current_cb_address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); - current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL )/ - sizeof (struct command_block); + current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL) / + sizeof(struct command_block); IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n", - current_cb_index, current_cb_address ); + current_cb_index, current_cb_address); IPW_DEBUG_FW(">> :\n"); return current_cb_index; @@ -1840,15 +1862,14 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, u32 src_address, u32 dest_address, u32 length, - int interrupt_enabled, - int is_last) + int interrupt_enabled, int is_last) { u32 control = CB_VALID | CB_SRC_LE | CB_DEST_LE | CB_SRC_AUTOINC | - CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG | - CB_DEST_SIZE_LONG; + CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG | + CB_DEST_SIZE_LONG; struct command_block *cb; - u32 last_cb_element=0; + u32 last_cb_element = 0; IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n", src_address, dest_address, length); @@ -1861,7 +1882,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, priv->sram_desc.last_cb_index++; /* Calculate the new CB control word */ - if (interrupt_enabled ) + if (interrupt_enabled) control |= CB_INT_ENABLED; if (is_last) @@ -1870,7 +1891,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, control |= length; /* Calculate the CB Element's checksum value */ - cb->status = control ^src_address ^dest_address; + cb->status = control ^ src_address ^ dest_address; /* Copy the Source and Destination addresses */ cb->dest_addr = dest_address; @@ -1883,22 +1904,21 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, } static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, - u32 src_phys, - u32 dest_address, - u32 length) + u32 src_phys, u32 dest_address, u32 length) { u32 bytes_left = length; - u32 src_offset=0; - u32 dest_offset=0; + u32 src_offset = 0; + u32 dest_offset = 0; int status = 0; IPW_DEBUG_FW(">> \n"); IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n", src_phys, dest_address, length); while (bytes_left > CB_MAX_LENGTH) { - status = ipw_fw_dma_add_command_block( priv, - src_phys + src_offset, - dest_address + dest_offset, - CB_MAX_LENGTH, 0, 0); + status = ipw_fw_dma_add_command_block(priv, + src_phys + src_offset, + dest_address + + dest_offset, + CB_MAX_LENGTH, 0, 0); if (status) { IPW_DEBUG_FW_INFO(": Failed\n"); return -1; @@ -1912,18 +1932,18 @@ static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, /* add the buffer tail */ if (bytes_left > 0) { - status = ipw_fw_dma_add_command_block( - priv, src_phys + src_offset, - dest_address + dest_offset, - bytes_left, 0, 0); + status = + ipw_fw_dma_add_command_block(priv, src_phys + src_offset, + dest_address + dest_offset, + bytes_left, 0, 0); if (status) { IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n"); return -1; } else - IPW_DEBUG_FW_INFO(": Adding new cb - the buffer tail\n"); + IPW_DEBUG_FW_INFO + (": Adding new cb - the buffer tail\n"); } - IPW_DEBUG_FW("<< \n"); return 0; } @@ -1937,7 +1957,7 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv) current_index = ipw_fw_dma_command_block_index(priv); IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n", - (int) priv->sram_desc.last_cb_index); + (int)priv->sram_desc.last_cb_index); while (current_index < priv->sram_desc.last_cb_index) { udelay(50); @@ -1955,8 +1975,8 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv) ipw_fw_dma_abort(priv); - /*Disable the DMA in the CSR register*/ - ipw_set_bit(priv, CX2_RESET_REG, + /*Disable the DMA in the CSR register */ + ipw_set_bit(priv, CX2_RESET_REG, CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); IPW_DEBUG_FW("<< dmaWaitSync \n"); @@ -2011,8 +2031,7 @@ static inline int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask, * image and the caller is handling the memory allocation and clean up. */ - -static int ipw_stop_master(struct ipw_priv * priv) +static int ipw_stop_master(struct ipw_priv *priv) { int rc; @@ -2071,14 +2090,13 @@ struct fw_chunk { #define IPW_FW_NAME(x) "ipw2200_" x ".fw" #endif -static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, - size_t len) +static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len) { int rc = 0, i, addr; u8 cr = 0; u16 *image; - image = (u16 *)data; + image = (u16 *) data; IPW_DEBUG_TRACE(">> \n"); @@ -2087,7 +2105,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, if (rc < 0) return rc; -// spin_lock_irqsave(&priv->lock, flags); +// spin_lock_irqsave(&priv->lock, flags); for (addr = CX2_SHARED_LOWER_BOUND; addr < CX2_REGISTER_DOMAIN1_END; addr += 4) { @@ -2099,7 +2117,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, /* destroy DMA queues */ /* reset sequence */ - ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET ,CX2_BIT_HALT_RESET_ON); + ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_ON); ipw_arc_release(priv); ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_OFF); mdelay(1); @@ -2128,13 +2146,11 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, for (i = 0; i < len / 2; i++) ipw_write_reg16(priv, CX2_BASEBAND_CONTROL_STORE, image[i]); - /* enable DINO */ ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); - ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, - DINO_ENABLE_SYSTEM ); + ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, DINO_ENABLE_SYSTEM); - /* this is where the igx / win driver deveates from the VAP driver.*/ + /* this is where the igx / win driver deveates from the VAP driver. */ /* wait for alive response */ for (i = 0; i < 100; i++) { @@ -2151,25 +2167,24 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, for (i = 0; i < ARRAY_SIZE(response_buffer); i++) response_buffer[i] = - ipw_read_reg32(priv, - CX2_BASEBAND_RX_FIFO_READ); + ipw_read_reg32(priv, CX2_BASEBAND_RX_FIFO_READ); memcpy(&priv->dino_alive, response_buffer, sizeof(priv->dino_alive)); if (priv->dino_alive.alive_command == 1 && priv->dino_alive.ucode_valid == 1) { rc = 0; - IPW_DEBUG_INFO( - "Microcode OK, rev. %d (0x%x) dev. %d (0x%x) " - "of %02d/%02d/%02d %02d:%02d\n", - priv->dino_alive.software_revision, - priv->dino_alive.software_revision, - priv->dino_alive.device_identifier, - priv->dino_alive.device_identifier, - priv->dino_alive.time_stamp[0], - priv->dino_alive.time_stamp[1], - priv->dino_alive.time_stamp[2], - priv->dino_alive.time_stamp[3], - priv->dino_alive.time_stamp[4]); + IPW_DEBUG_INFO + ("Microcode OK, rev. %d (0x%x) dev. %d (0x%x) " + "of %02d/%02d/%02d %02d:%02d\n", + priv->dino_alive.software_revision, + priv->dino_alive.software_revision, + priv->dino_alive.device_identifier, + priv->dino_alive.device_identifier, + priv->dino_alive.time_stamp[0], + priv->dino_alive.time_stamp[1], + priv->dino_alive.time_stamp[2], + priv->dino_alive.time_stamp[3], + priv->dino_alive.time_stamp[4]); } else { IPW_DEBUG_INFO("Microcode is not alive\n"); rc = -EINVAL; @@ -2183,13 +2198,12 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, firmware have problem getting alive resp. */ ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); -// spin_unlock_irqrestore(&priv->lock, flags); +// spin_unlock_irqrestore(&priv->lock, flags); return rc; } -static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, - size_t len) +static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) { int rc = -1; int offset = 0; @@ -2231,7 +2245,7 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, offset += chunk->length; } while (offset < len); - /* Run the DMA and wait for the answer*/ + /* Run the DMA and wait for the answer */ rc = ipw_fw_dma_kick(priv); if (rc) { IPW_ERROR("dmaKick Failed\n"); @@ -2243,8 +2257,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, IPW_ERROR("dmaWaitSync Failed\n"); goto out; } - out: - pci_free_consistent( priv->pci_dev, len, shared_virt, shared_phys); + out: + pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys); return rc; } @@ -2253,7 +2267,7 @@ static int ipw_stop_nic(struct ipw_priv *priv) { int rc = 0; - /* stop*/ + /* stop */ ipw_write32(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER); rc = ipw_poll_bit(priv, CX2_RESET_REG, @@ -2272,14 +2286,15 @@ static void ipw_start_nic(struct ipw_priv *priv) { IPW_DEBUG_TRACE(">>\n"); - /* prvHwStartNic release ARC*/ + /* prvHwStartNic release ARC */ ipw_clear_bit(priv, CX2_RESET_REG, CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER | CBD_RESET_REG_PRINCETON_RESET); /* enable power management */ - ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY); + ipw_set_bit(priv, CX2_GP_CNTRL_RW, + CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY); IPW_DEBUG_TRACE("<<\n"); } @@ -2295,12 +2310,13 @@ static int ipw_init_nic(struct ipw_priv *priv) ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE); /* low-level PLL activation */ - ipw_write32(priv, CX2_READ_INT_REGISTER, CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER); + ipw_write32(priv, CX2_READ_INT_REGISTER, + CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER); /* wait for clock stabilization */ rc = ipw_poll_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_CLOCK_READY, 250); - if (rc < 0 ) + if (rc < 0) IPW_DEBUG_INFO("FAILED wait for clock stablization\n"); /* assert SW reset */ @@ -2315,7 +2331,6 @@ static int ipw_init_nic(struct ipw_priv *priv) return 0; } - /* Call this function from process context, it will sleep in request_firmware. * Probe is an ok place to call this from. */ @@ -2383,8 +2398,7 @@ static inline void ipw_rx_queue_reset(struct ipw_priv *priv, * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].skb != NULL) { pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, - CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(rxq->pool[i].skb); } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -2438,12 +2452,12 @@ static int ipw_load(struct ipw_priv *priv) if (rc) goto error; - rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("sniffer")); + rc = ipw_get_fw(priv, &firmware, + IPW_FW_NAME("sniffer")); break; #endif case IW_MODE_INFRA: - rc = ipw_get_fw(priv, &ucode, - IPW_FW_NAME("bss_ucode")); + rc = ipw_get_fw(priv, &ucode, IPW_FW_NAME("bss_ucode")); if (rc) goto error; @@ -2471,7 +2485,7 @@ static int ipw_load(struct ipw_priv *priv) goto error; } - retry: + retry: /* Ensure interrupts are disabled */ ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL); priv->status &= ~STATUS_INT_ENABLED; @@ -2528,7 +2542,7 @@ static int ipw_load(struct ipw_priv *priv) rc = ipw_load_firmware(priv, firmware->data + sizeof(struct fw_header), firmware->size - sizeof(struct fw_header)); - if (rc < 0 ) { + if (rc < 0) { IPW_ERROR("Unable to load firmware\n"); goto error; } @@ -2593,7 +2607,7 @@ static int ipw_load(struct ipw_priv *priv) #endif return 0; - error: + error: if (priv->rxq) { ipw_rx_queue_free(priv, priv->rxq); priv->rxq = NULL; @@ -2671,8 +2685,7 @@ static inline int ipw_queue_inc_wrap(int index, int n_bd) * (not offset within BAR, full address) */ static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q, - int count, u32 read, u32 write, - u32 base, u32 size) + int count, u32 read, u32 write, u32 base, u32 size) { q->n_bd = count; @@ -2698,8 +2711,7 @@ static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q, static int ipw_queue_tx_init(struct ipw_priv *priv, struct clx2_tx_queue *q, - int count, u32 read, u32 write, - u32 base, u32 size) + int count, u32 read, u32 write, u32 base, u32 size) { struct pci_dev *dev = priv->pci_dev; @@ -2709,10 +2721,11 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, return -ENOMEM; } - q->bd = pci_alloc_consistent(dev,sizeof(q->bd[0])*count, &q->q.dma_addr); + q->bd = + pci_alloc_consistent(dev, sizeof(q->bd[0]) * count, &q->q.dma_addr); if (!q->bd) { IPW_ERROR("pci_alloc_consistent(%zd) failed\n", - sizeof(q->bd[0]) * count); + sizeof(q->bd[0]) * count); kfree(q->txb); q->txb = NULL; return -ENOMEM; @@ -2768,8 +2781,7 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv, * @param dev * @param q */ -static void ipw_queue_tx_free(struct ipw_priv *priv, - struct clx2_tx_queue *txq) +static void ipw_queue_tx_free(struct ipw_priv *priv, struct clx2_tx_queue *txq) { struct clx2_queue *q = &txq->q; struct pci_dev *dev = priv->pci_dev; @@ -2784,7 +2796,7 @@ static void ipw_queue_tx_free(struct ipw_priv *priv, } /* free buffers belonging to queue itself */ - pci_free_consistent(dev, sizeof(txq->bd[0])*q->n_bd, txq->bd, + pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd, q->dma_addr); kfree(txq->txb); @@ -2792,7 +2804,6 @@ static void ipw_queue_tx_free(struct ipw_priv *priv, memset(txq, 0, sizeof(*txq)); } - /** * Destroy all DMA queues and structures * @@ -2825,7 +2836,7 @@ static void inline __maybe_wake_tx(struct ipw_priv *priv) } -static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid) +static inline void ipw_create_bssid(struct ipw_priv *priv, u8 * bssid) { /* First 3 bytes are manufacturer */ bssid[0] = priv->mac_addr[0]; @@ -2833,13 +2844,13 @@ static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid) bssid[2] = priv->mac_addr[2]; /* Last bytes are random */ - get_random_bytes(&bssid[3], ETH_ALEN-3); + get_random_bytes(&bssid[3], ETH_ALEN - 3); - bssid[0] &= 0xfe; /* clear multicast bit */ - bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */ + bssid[0] &= 0xfe; /* clear multicast bit */ + bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */ } -static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid) +static inline u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid) { struct ipw_station_entry entry; int i; @@ -2866,14 +2877,13 @@ static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid) memcpy(entry.mac_addr, bssid, ETH_ALEN); memcpy(priv->stations[i], bssid, ETH_ALEN); ipw_write_direct(priv, IPW_STATION_TABLE_LOWER + i * sizeof(entry), - &entry, - sizeof(entry)); + &entry, sizeof(entry)); priv->num_stations++; return i; } -static inline u8 ipw_find_station(struct ipw_priv *priv, u8 *bssid) +static inline u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid) { int i; @@ -2944,26 +2954,34 @@ static const struct ipw_status_code ipw_status_codes[] = { "association exists"}, {0x0C, "Association denied due to reason outside the scope of this " "standard"}, - {0x0D, "Responding station does not support the specified authentication " + {0x0D, + "Responding station does not support the specified authentication " "algorithm"}, - {0x0E, "Received an Authentication frame with authentication sequence " + {0x0E, + "Received an Authentication frame with authentication sequence " "transaction sequence number out of expected sequence"}, {0x0F, "Authentication rejected because of challenge failure"}, {0x10, "Authentication rejected due to timeout waiting for next " "frame in sequence"}, {0x11, "Association denied because AP is unable to handle additional " "associated stations"}, - {0x12, "Association denied due to requesting station not supporting all " + {0x12, + "Association denied due to requesting station not supporting all " "of the datarates in the BSSBasicServiceSet Parameter"}, - {0x13, "Association denied due to requesting station not supporting " + {0x13, + "Association denied due to requesting station not supporting " "short preamble operation"}, - {0x14, "Association denied due to requesting station not supporting " + {0x14, + "Association denied due to requesting station not supporting " "PBCC encoding"}, - {0x15, "Association denied due to requesting station not supporting " + {0x15, + "Association denied due to requesting station not supporting " "channel agility"}, - {0x19, "Association denied due to requesting station not supporting " + {0x19, + "Association denied due to requesting station not supporting " "short slot operation"}, - {0x1A, "Association denied due to requesting station not supporting " + {0x1A, + "Association denied due to requesting station not supporting " "DSSS-OFDM operation"}, {0x28, "Invalid Information Element"}, {0x29, "Group Cipher is not valid"}, @@ -3043,7 +3061,6 @@ static void ipw_reset_stats(struct ipw_priv *priv) } - static inline u32 ipw_get_max_rate(struct ipw_priv *priv) { u32 i = 0x80000000; @@ -3056,20 +3073,21 @@ static inline u32 ipw_get_max_rate(struct ipw_priv *priv) /* TODO: Verify that the rate is supported by the current rates * list. */ - while (i && !(mask & i)) i >>= 1; + while (i && !(mask & i)) + i >>= 1; switch (i) { - case IEEE80211_CCK_RATE_1MB_MASK: return 1000000; - case IEEE80211_CCK_RATE_2MB_MASK: return 2000000; - case IEEE80211_CCK_RATE_5MB_MASK: return 5500000; - case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000; - case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000; - case IEEE80211_CCK_RATE_11MB_MASK: return 11000000; - case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000; - case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000; - case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000; - case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000; - case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000; - case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000; + case IEEE80211_CCK_RATE_1MB_MASK: return 1000000; + case IEEE80211_CCK_RATE_2MB_MASK: return 2000000; + case IEEE80211_CCK_RATE_5MB_MASK: return 5500000; + case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000; + case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000; + case IEEE80211_CCK_RATE_11MB_MASK: return 11000000; + case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000; + case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000; + case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000; + case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000; + case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000; + case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000; } if (priv->ieee->mode == IEEE_B) @@ -3097,18 +3115,18 @@ static u32 ipw_get_current_rate(struct ipw_priv *priv) return ipw_get_max_rate(priv); switch (rate) { - case IPW_TX_RATE_1MB: return 1000000; - case IPW_TX_RATE_2MB: return 2000000; - case IPW_TX_RATE_5MB: return 5500000; - case IPW_TX_RATE_6MB: return 6000000; - case IPW_TX_RATE_9MB: return 9000000; - case IPW_TX_RATE_11MB: return 11000000; - case IPW_TX_RATE_12MB: return 12000000; - case IPW_TX_RATE_18MB: return 18000000; - case IPW_TX_RATE_24MB: return 24000000; - case IPW_TX_RATE_36MB: return 36000000; - case IPW_TX_RATE_48MB: return 48000000; - case IPW_TX_RATE_54MB: return 54000000; + case IPW_TX_RATE_1MB: return 1000000; + case IPW_TX_RATE_2MB: return 2000000; + case IPW_TX_RATE_5MB: return 5500000; + case IPW_TX_RATE_6MB: return 6000000; + case IPW_TX_RATE_9MB: return 9000000; + case IPW_TX_RATE_11MB: return 11000000; + case IPW_TX_RATE_12MB: return 12000000; + case IPW_TX_RATE_18MB: return 18000000; + case IPW_TX_RATE_24MB: return 24000000; + case IPW_TX_RATE_36MB: return 36000000; + case IPW_TX_RATE_48MB: return 48000000; + case IPW_TX_RATE_54MB: return 54000000; } return 0; @@ -3126,7 +3144,7 @@ static void ipw_gather_stats(struct ipw_priv *priv) u32 len = sizeof(u32); s16 rssi; u32 beacon_quality, signal_quality, tx_quality, rx_quality, - rate_quality; + rate_quality; if (!(priv->status & STATUS_ASSOCIATED)) { priv->quality = 0; @@ -3136,13 +3154,12 @@ static void ipw_gather_stats(struct ipw_priv *priv) /* Update the statistics */ ipw_get_ordinal(priv, IPW_ORD_STAT_MISSED_BEACONS, &priv->missed_beacons, &len); - missed_beacons_delta = priv->missed_beacons - - priv->last_missed_beacons; + missed_beacons_delta = priv->missed_beacons - priv->last_missed_beacons; priv->last_missed_beacons = priv->missed_beacons; if (priv->assoc_request.beacon_interval) { missed_beacons_percent = missed_beacons_delta * - (HZ * priv->assoc_request.beacon_interval) / - (IPW_STATS_INTERVAL * 10); + (HZ * priv->assoc_request.beacon_interval) / + (IPW_STATS_INTERVAL * 10); } else { missed_beacons_percent = 0; } @@ -3179,28 +3196,26 @@ static void ipw_gather_stats(struct ipw_priv *priv) beacon_quality = 0; else beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 / - (100 - BEACON_THRESHOLD); + (100 - BEACON_THRESHOLD); IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n", beacon_quality, missed_beacons_percent); priv->last_rate = ipw_get_current_rate(priv); - rate_quality = priv->last_rate * 40 / priv->last_rate + 60; + rate_quality = priv->last_rate * 40 / priv->last_rate + 60; IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n", rate_quality, priv->last_rate / 1000000); - if (rx_packets_delta > 100 && - rx_packets_delta + rx_err_delta) + if (rx_packets_delta > 100 && rx_packets_delta + rx_err_delta) rx_quality = 100 - (rx_err_delta * 100) / - (rx_packets_delta + rx_err_delta); + (rx_packets_delta + rx_err_delta); else rx_quality = 100; IPW_DEBUG_STATS("Rx quality : %3d%% (%u errors, %u packets)\n", rx_quality, rx_err_delta, rx_packets_delta); - if (tx_packets_delta > 100 && - tx_packets_delta + tx_failures_delta) + if (tx_packets_delta > 100 && tx_packets_delta + tx_failures_delta) tx_quality = 100 - (tx_failures_delta * 100) / - (tx_packets_delta + tx_failures_delta); + (tx_packets_delta + tx_failures_delta); else tx_quality = 100; IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n", @@ -3213,7 +3228,7 @@ static void ipw_gather_stats(struct ipw_priv *priv) signal_quality = 0; else signal_quality = (rssi - WORST_RSSI) * 100 / - (PERFECT_RSSI - WORST_RSSI); + (PERFECT_RSSI - WORST_RSSI); IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n", signal_quality, rssi); @@ -3221,25 +3236,20 @@ static void ipw_gather_stats(struct ipw_priv *priv) min(rate_quality, min(tx_quality, min(rx_quality, signal_quality)))); if (quality == beacon_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to missed beacons.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to missed beacons.\n", + quality); if (quality == rate_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to rate quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to rate quality.\n", + quality); if (quality == tx_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to Tx quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to Tx quality.\n", + quality); if (quality == rx_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to Rx quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to Rx quality.\n", + quality); if (quality == signal_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to signal quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to signal quality.\n", + quality); priv->quality = quality; @@ -3251,402 +3261,454 @@ static void ipw_gather_stats(struct ipw_priv *priv) * Handle host notification packet. * Called from interrupt routine */ -static inline void ipw_rx_notification(struct ipw_priv* priv, +static inline void ipw_rx_notification(struct ipw_priv *priv, struct ipw_rx_notification *notif) { - IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", - notif->subtype, notif->size); + IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", notif->subtype, notif->size); switch (notif->subtype) { - case HOST_NOTIFICATION_STATUS_ASSOCIATED: { - struct notif_association *assoc = ¬if->u.assoc; - - switch (assoc->state) { - case CMAS_ASSOCIATED: { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "associated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - - switch (priv->ieee->iw_mode) { - case IW_MODE_INFRA: - memcpy(priv->ieee->bssid, priv->bssid, - ETH_ALEN); - break; - - case IW_MODE_ADHOC: - memcpy(priv->ieee->bssid, priv->bssid, - ETH_ALEN); - - /* clear out the station table */ - priv->num_stations = 0; - - IPW_DEBUG_ASSOC("queueing adhoc check\n"); - queue_delayed_work(priv->workqueue, - &priv->adhoc_check, - priv->assoc_request.beacon_interval); - break; - } - - priv->status &= ~STATUS_ASSOCIATING; - priv->status |= STATUS_ASSOCIATED; - - netif_carrier_on(priv->net_dev); - if (netif_queue_stopped(priv->net_dev)) { - IPW_DEBUG_NOTIF("waking queue\n"); - netif_wake_queue(priv->net_dev); - } else { - IPW_DEBUG_NOTIF("starting queue\n"); - netif_start_queue(priv->net_dev); - } - - ipw_reset_stats(priv); - /* Ensure the rate is updated immediately */ - priv->last_rate = ipw_get_current_rate(priv); - schedule_work(&priv->gather_stats); - notify_wx_assoc_event(priv); + case HOST_NOTIFICATION_STATUS_ASSOCIATED:{ + struct notif_association *assoc = ¬if->u.assoc; + + switch (assoc->state) { + case CMAS_ASSOCIATED:{ + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "associated: '%s' " MAC_FMT + " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + + switch (priv->ieee->iw_mode) { + case IW_MODE_INFRA: + memcpy(priv->ieee->bssid, + priv->bssid, ETH_ALEN); + break; + + case IW_MODE_ADHOC: + memcpy(priv->ieee->bssid, + priv->bssid, ETH_ALEN); + + /* clear out the station table */ + priv->num_stations = 0; + + IPW_DEBUG_ASSOC + ("queueing adhoc check\n"); + queue_delayed_work(priv-> + workqueue, + &priv-> + adhoc_check, + priv-> + assoc_request. + beacon_interval); + break; + } + + priv->status &= ~STATUS_ASSOCIATING; + priv->status |= STATUS_ASSOCIATED; + + netif_carrier_on(priv->net_dev); + if (netif_queue_stopped(priv->net_dev)) { + IPW_DEBUG_NOTIF + ("waking queue\n"); + netif_wake_queue(priv->net_dev); + } else { + IPW_DEBUG_NOTIF + ("starting queue\n"); + netif_start_queue(priv-> + net_dev); + } + + ipw_reset_stats(priv); + /* Ensure the rate is updated immediately */ + priv->last_rate = + ipw_get_current_rate(priv); + schedule_work(&priv->gather_stats); + notify_wx_assoc_event(priv); /* queue_delayed_work(priv->workqueue, &priv->request_scan, SCAN_ASSOCIATED_INTERVAL); */ - break; - } + break; + } - case CMAS_AUTHENTICATED: { - if (priv->status & (STATUS_ASSOCIATED | STATUS_AUTH)) { + case CMAS_AUTHENTICATED:{ + if (priv-> + status & (STATUS_ASSOCIATED | + STATUS_AUTH)) { #ifdef CONFIG_IPW_DEBUG - struct notif_authenticate *auth = ¬if->u.auth; - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "deauthenticated: '%s' " MAC_FMT ": (0x%04X) - %s \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid), - ntohs(auth->status), - ipw_get_status_code(ntohs(auth->status))); + struct notif_authenticate *auth + = ¬if->u.auth; + IPW_DEBUG(IPW_DL_NOTIF | + IPW_DL_STATE | + IPW_DL_ASSOC, + "deauthenticated: '%s' " + MAC_FMT + ": (0x%04X) - %s \n", + escape_essid(priv-> + essid, + priv-> + essid_len), + MAC_ARG(priv->bssid), + ntohs(auth->status), + ipw_get_status_code + (ntohs + (auth->status))); #endif - priv->status &= ~(STATUS_ASSOCIATING | - STATUS_AUTH | - STATUS_ASSOCIATED); + priv->status &= + ~(STATUS_ASSOCIATING | + STATUS_AUTH | + STATUS_ASSOCIATED); + + netif_carrier_off(priv-> + net_dev); + netif_stop_queue(priv->net_dev); + queue_work(priv->workqueue, + &priv->request_scan); + notify_wx_assoc_event(priv); + break; + } + + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "authenticated: '%s' " MAC_FMT + "\n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + break; + } + + case CMAS_INIT:{ + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "disassociated: '%s' " MAC_FMT + " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + + priv->status &= + ~(STATUS_DISASSOCIATING | + STATUS_ASSOCIATING | + STATUS_ASSOCIATED | STATUS_AUTH); + + netif_stop_queue(priv->net_dev); + if (!(priv->status & STATUS_ROAMING)) { + netif_carrier_off(priv-> + net_dev); + notify_wx_assoc_event(priv); + + /* Cancel any queued work ... */ + cancel_delayed_work(&priv-> + request_scan); + cancel_delayed_work(&priv-> + adhoc_check); + + /* Queue up another scan... */ + queue_work(priv->workqueue, + &priv->request_scan); + + cancel_delayed_work(&priv-> + gather_stats); + } else { + priv->status |= STATUS_ROAMING; + queue_work(priv->workqueue, + &priv->request_scan); + } + + ipw_reset_stats(priv); + break; + } - netif_carrier_off(priv->net_dev); - netif_stop_queue(priv->net_dev); - queue_work(priv->workqueue, &priv->request_scan); - notify_wx_assoc_event(priv); + default: + IPW_ERROR("assoc: unknown (%d)\n", + assoc->state); break; } - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "authenticated: '%s' " MAC_FMT "\n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); break; } - case CMAS_INIT: { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "disassociated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); + case HOST_NOTIFICATION_STATUS_AUTHENTICATE:{ + struct notif_authenticate *auth = ¬if->u.auth; + switch (auth->state) { + case CMAS_AUTHENTICATED: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "authenticated: '%s' " MAC_FMT " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + priv->status |= STATUS_AUTH; + break; - priv->status &= ~( - STATUS_DISASSOCIATING | - STATUS_ASSOCIATING | - STATUS_ASSOCIATED | - STATUS_AUTH); + case CMAS_INIT: + if (priv->status & STATUS_AUTH) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "authentication failed (0x%04X): %s\n", + ntohs(auth->status), + ipw_get_status_code(ntohs + (auth-> + status))); + } + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "deauthenticated: '%s' " MAC_FMT "\n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); - netif_stop_queue(priv->net_dev); - if (!(priv->status & STATUS_ROAMING)) { - netif_carrier_off(priv->net_dev); - notify_wx_assoc_event(priv); - - /* Cancel any queued work ... */ - cancel_delayed_work(&priv->request_scan); - cancel_delayed_work(&priv->adhoc_check); + priv->status &= ~(STATUS_ASSOCIATING | + STATUS_AUTH | + STATUS_ASSOCIATED); - /* Queue up another scan... */ + netif_carrier_off(priv->net_dev); + netif_stop_queue(priv->net_dev); queue_work(priv->workqueue, &priv->request_scan); + notify_wx_assoc_event(priv); + break; - cancel_delayed_work(&priv->gather_stats); - } else { - priv->status |= STATUS_ROAMING; - queue_work(priv->workqueue, - &priv->request_scan); + case CMAS_TX_AUTH_SEQ_1: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1\n"); + break; + case CMAS_RX_AUTH_SEQ_2: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_2\n"); + break; + case CMAS_AUTH_SEQ_1_PASS: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1_PASS\n"); + break; + case CMAS_AUTH_SEQ_1_FAIL: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1_FAIL\n"); + break; + case CMAS_TX_AUTH_SEQ_3: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_3\n"); + break; + case CMAS_RX_AUTH_SEQ_4: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "RX_AUTH_SEQ_4\n"); + break; + case CMAS_AUTH_SEQ_2_PASS: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_2_PASS\n"); + break; + case CMAS_AUTH_SEQ_2_FAIL: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUT_SEQ_2_FAIL\n"); + break; + case CMAS_TX_ASSOC: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "TX_ASSOC\n"); + break; + case CMAS_RX_ASSOC_RESP: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "RX_ASSOC_RESP\n"); + break; + case CMAS_ASSOCIATED: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "ASSOCIATED\n"); + break; + default: + IPW_DEBUG_NOTIF("auth: failure - %d\n", + auth->state); + break; } - - ipw_reset_stats(priv); - break; - } - - default: - IPW_ERROR("assoc: unknown (%d)\n", - assoc->state); break; } - break; - } + case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT:{ + struct notif_channel_result *x = + ¬if->u.channel_result; - case HOST_NOTIFICATION_STATUS_AUTHENTICATE: { - struct notif_authenticate *auth = ¬if->u.auth; - switch (auth->state) { - case CMAS_AUTHENTICATED: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "authenticated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - priv->status |= STATUS_AUTH; - break; - - case CMAS_INIT: - if (priv->status & STATUS_AUTH) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "authentication failed (0x%04X): %s\n", - ntohs(auth->status), - ipw_get_status_code(ntohs(auth->status))); + if (notif->size == sizeof(*x)) { + IPW_DEBUG_SCAN("Scan result for channel %d\n", + x->channel_num); + } else { + IPW_DEBUG_SCAN("Scan result of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); } - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "deauthenticated: '%s' " MAC_FMT "\n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - - priv->status &= ~(STATUS_ASSOCIATING | - STATUS_AUTH | - STATUS_ASSOCIATED); - - netif_carrier_off(priv->net_dev); - netif_stop_queue(priv->net_dev); - queue_work(priv->workqueue, &priv->request_scan); - notify_wx_assoc_event(priv); - break; - - case CMAS_TX_AUTH_SEQ_1: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1\n"); - break; - case CMAS_RX_AUTH_SEQ_2: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_2\n"); - break; - case CMAS_AUTH_SEQ_1_PASS: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1_PASS\n"); - break; - case CMAS_AUTH_SEQ_1_FAIL: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1_FAIL\n"); - break; - case CMAS_TX_AUTH_SEQ_3: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_3\n"); - break; - case CMAS_RX_AUTH_SEQ_4: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "RX_AUTH_SEQ_4\n"); - break; - case CMAS_AUTH_SEQ_2_PASS: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_2_PASS\n"); - break; - case CMAS_AUTH_SEQ_2_FAIL: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUT_SEQ_2_FAIL\n"); - break; - case CMAS_TX_ASSOC: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "TX_ASSOC\n"); - break; - case CMAS_RX_ASSOC_RESP: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "RX_ASSOC_RESP\n"); - break; - case CMAS_ASSOCIATED: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "ASSOCIATED\n"); - break; - default: - IPW_DEBUG_NOTIF("auth: failure - %d\n", auth->state); break; } - break; - } - - case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT: { - struct notif_channel_result *x = ¬if->u.channel_result; - - if (notif->size == sizeof(*x)) { - IPW_DEBUG_SCAN("Scan result for channel %d\n", - x->channel_num); - } else { - IPW_DEBUG_SCAN("Scan result of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - break; - } - case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED: { - struct notif_scan_complete* x = ¬if->u.scan_complete; - if (notif->size == sizeof(*x)) { - IPW_DEBUG_SCAN("Scan completed: type %d, %d channels, " - "%d status\n", - x->scan_type, - x->num_channels, - x->status); - } else { - IPW_ERROR("Scan completed of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - - priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); - - cancel_delayed_work(&priv->scan_check); - - if (!(priv->status & (STATUS_ASSOCIATED | - STATUS_ASSOCIATING | - STATUS_ROAMING | - STATUS_DISASSOCIATING))) - queue_work(priv->workqueue, &priv->associate); - else if (priv->status & STATUS_ROAMING) { - /* If a scan completed and we are in roam mode, then - * the scan that completed was the one requested as a - * result of entering roam... so, schedule the - * roam work */ - queue_work(priv->workqueue, &priv->roam); - } else if (priv->status & STATUS_SCAN_PENDING) - queue_work(priv->workqueue, &priv->request_scan); - - priv->ieee->scans++; - break; - } + case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED:{ + struct notif_scan_complete *x = ¬if->u.scan_complete; + if (notif->size == sizeof(*x)) { + IPW_DEBUG_SCAN + ("Scan completed: type %d, %d channels, " + "%d status\n", x->scan_type, + x->num_channels, x->status); + } else { + IPW_ERROR("Scan completed of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } - case HOST_NOTIFICATION_STATUS_FRAG_LENGTH: { - struct notif_frag_length *x = ¬if->u.frag_len; + priv->status &= + ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); + + cancel_delayed_work(&priv->scan_check); + + if (!(priv->status & (STATUS_ASSOCIATED | + STATUS_ASSOCIATING | + STATUS_ROAMING | + STATUS_DISASSOCIATING))) + queue_work(priv->workqueue, &priv->associate); + else if (priv->status & STATUS_ROAMING) { + /* If a scan completed and we are in roam mode, then + * the scan that completed was the one requested as a + * result of entering roam... so, schedule the + * roam work */ + queue_work(priv->workqueue, &priv->roam); + } else if (priv->status & STATUS_SCAN_PENDING) + queue_work(priv->workqueue, + &priv->request_scan); - if (notif->size == sizeof(*x)) { - IPW_ERROR("Frag length: %d\n", x->frag_length); - } else { - IPW_ERROR("Frag length of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); + priv->ieee->scans++; + break; } - break; - } - case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION: { - struct notif_link_deterioration *x = - ¬if->u.link_deterioration; - if (notif->size==sizeof(*x)) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "link deterioration: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - memcpy(&priv->last_link_deterioration, x, sizeof(*x)); - } else { - IPW_ERROR("Link Deterioration of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - break; - } + case HOST_NOTIFICATION_STATUS_FRAG_LENGTH:{ + struct notif_frag_length *x = ¬if->u.frag_len; - case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE: { - IPW_ERROR("Dino config\n"); - if (priv->hcmd && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) { - /* TODO: Do anything special? */ - } else { - IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n"); + if (notif->size == sizeof(*x)) { + IPW_ERROR("Frag length: %d\n", x->frag_length); + } else { + IPW_ERROR("Frag length of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } + break; } - break; - } - case HOST_NOTIFICATION_STATUS_BEACON_STATE: { - struct notif_beacon_state *x = ¬if->u.beacon_state; - if (notif->size != sizeof(*x)) { - IPW_ERROR("Beacon state of wrong size %d (should " - "be %zd)\n", notif->size, sizeof(*x)); + case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION:{ + struct notif_link_deterioration *x = + ¬if->u.link_deterioration; + if (notif->size == sizeof(*x)) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "link deterioration: '%s' " MAC_FMT + " \n", escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + memcpy(&priv->last_link_deterioration, x, + sizeof(*x)); + } else { + IPW_ERROR("Link Deterioration of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } break; } - if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) { - if (priv->status & STATUS_SCANNING) { - /* Stop scan to keep fw from getting - * stuck... */ - queue_work(priv->workqueue, - &priv->abort_scan); + case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE:{ + IPW_ERROR("Dino config\n"); + if (priv->hcmd + && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) { + /* TODO: Do anything special? */ + } else { + IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n"); } + break; + } - if (x->number > priv->missed_beacon_threshold && - priv->status & STATUS_ASSOCIATED) { - IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF | - IPW_DL_STATE, - "Missed beacon: %d - disassociate\n", - x->number); - queue_work(priv->workqueue, - &priv->disassociate); - } else if (x->number > priv->roaming_threshold) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "Missed beacon: %d - initiate " - "roaming\n", - x->number); - queue_work(priv->workqueue, - &priv->roam); - } else { - IPW_DEBUG_NOTIF("Missed beacon: %d\n", - x->number); + case HOST_NOTIFICATION_STATUS_BEACON_STATE:{ + struct notif_beacon_state *x = ¬if->u.beacon_state; + if (notif->size != sizeof(*x)) { + IPW_ERROR + ("Beacon state of wrong size %d (should " + "be %zd)\n", notif->size, sizeof(*x)); + break; } - priv->notif_missed_beacons = x->number; + if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) { + if (priv->status & STATUS_SCANNING) { + /* Stop scan to keep fw from getting + * stuck... */ + queue_work(priv->workqueue, + &priv->abort_scan); + } + + if (x->number > priv->missed_beacon_threshold && + priv->status & STATUS_ASSOCIATED) { + IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF | + IPW_DL_STATE, + "Missed beacon: %d - disassociate\n", + x->number); + queue_work(priv->workqueue, + &priv->disassociate); + } else if (x->number > priv->roaming_threshold) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "Missed beacon: %d - initiate " + "roaming\n", x->number); + queue_work(priv->workqueue, + &priv->roam); + } else { + IPW_DEBUG_NOTIF("Missed beacon: %d\n", + x->number); + } + + priv->notif_missed_beacons = x->number; - } + } + break; + } - break; - } + case HOST_NOTIFICATION_STATUS_TGI_TX_KEY:{ + struct notif_tgi_tx_key *x = ¬if->u.tgi_tx_key; + if (notif->size == sizeof(*x)) { + IPW_ERROR("TGi Tx Key: state 0x%02x sec type " + "0x%02x station %d\n", + x->key_state, x->security_type, + x->station_index); + break; + } - case HOST_NOTIFICATION_STATUS_TGI_TX_KEY: { - struct notif_tgi_tx_key *x = ¬if->u.tgi_tx_key; - if (notif->size==sizeof(*x)) { - IPW_ERROR("TGi Tx Key: state 0x%02x sec type " - "0x%02x station %d\n", - x->key_state,x->security_type, - x->station_index); + IPW_ERROR + ("TGi Tx Key of wrong size %d (should be %zd)\n", + notif->size, sizeof(*x)); break; } - IPW_ERROR("TGi Tx Key of wrong size %d (should be %zd)\n", - notif->size, sizeof(*x)); - break; - } + case HOST_NOTIFICATION_CALIB_KEEP_RESULTS:{ + struct notif_calibration *x = ¬if->u.calibration; - case HOST_NOTIFICATION_CALIB_KEEP_RESULTS: { - struct notif_calibration *x = ¬if->u.calibration; + if (notif->size == sizeof(*x)) { + memcpy(&priv->calib, x, sizeof(*x)); + IPW_DEBUG_INFO("TODO: Calibration\n"); + break; + } - if (notif->size == sizeof(*x)) { - memcpy(&priv->calib, x, sizeof(*x)); - IPW_DEBUG_INFO("TODO: Calibration\n"); + IPW_ERROR + ("Calibration of wrong size %d (should be %zd)\n", + notif->size, sizeof(*x)); break; } - IPW_ERROR("Calibration of wrong size %d (should be %zd)\n", - notif->size, sizeof(*x)); - break; - } + case HOST_NOTIFICATION_NOISE_STATS:{ + if (notif->size == sizeof(u32)) { + priv->last_noise = + (u8) (notif->u.noise.value & 0xff); + average_add(&priv->average_noise, + priv->last_noise); + break; + } - case HOST_NOTIFICATION_NOISE_STATS: { - if (notif->size == sizeof(u32)) { - priv->last_noise = (u8)(notif->u.noise.value & 0xff); - average_add(&priv->average_noise, priv->last_noise); + IPW_ERROR + ("Noise stat is wrong size %d (should be %zd)\n", + notif->size, sizeof(u32)); break; } - IPW_ERROR("Noise stat is wrong size %d (should be %zd)\n", - notif->size, sizeof(u32)); - break; - } - default: IPW_ERROR("Unknown notification: " "subtype=%d,flags=0x%2x,size=%d\n", @@ -3680,8 +3742,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx, CX2_TX_QUEUE_0_READ_INDEX, CX2_TX_QUEUE_0_WRITE_INDEX, - CX2_TX_QUEUE_0_BD_BASE, - CX2_TX_QUEUE_0_BD_SIZE); + CX2_TX_QUEUE_0_BD_BASE, CX2_TX_QUEUE_0_BD_SIZE); if (rc) { IPW_ERROR("Tx 0 queue init failed\n"); goto error; @@ -3689,8 +3750,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx, CX2_TX_QUEUE_1_READ_INDEX, CX2_TX_QUEUE_1_WRITE_INDEX, - CX2_TX_QUEUE_1_BD_BASE, - CX2_TX_QUEUE_1_BD_SIZE); + CX2_TX_QUEUE_1_BD_BASE, CX2_TX_QUEUE_1_BD_SIZE); if (rc) { IPW_ERROR("Tx 1 queue init failed\n"); goto error; @@ -3698,8 +3758,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx, CX2_TX_QUEUE_2_READ_INDEX, CX2_TX_QUEUE_2_WRITE_INDEX, - CX2_TX_QUEUE_2_BD_BASE, - CX2_TX_QUEUE_2_BD_SIZE); + CX2_TX_QUEUE_2_BD_BASE, CX2_TX_QUEUE_2_BD_SIZE); if (rc) { IPW_ERROR("Tx 2 queue init failed\n"); goto error; @@ -3707,8 +3766,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx, CX2_TX_QUEUE_3_READ_INDEX, CX2_TX_QUEUE_3_WRITE_INDEX, - CX2_TX_QUEUE_3_BD_BASE, - CX2_TX_QUEUE_3_BD_SIZE); + CX2_TX_QUEUE_3_BD_BASE, CX2_TX_QUEUE_3_BD_SIZE); if (rc) { IPW_ERROR("Tx 3 queue init failed\n"); goto error; @@ -3718,7 +3776,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) priv->rx_pend_max = 0; return rc; - error: + error: ipw_tx_queue_free(priv); return rc; } @@ -3746,8 +3804,8 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv, hw_tail = ipw_read32(priv, q->reg_r); if (hw_tail >= q->n_bd) { IPW_ERROR - ("Read index for DMA queue (%d) is out of range [0-%d)\n", - hw_tail, q->n_bd); + ("Read index for DMA queue (%d) is out of range [0-%d)\n", + hw_tail, q->n_bd); goto done; } for (; q->last_used != hw_tail; @@ -3755,7 +3813,7 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv, ipw_queue_tx_free_tfd(priv, txq); priv->tx_packets++; } - done: + done: if (ipw_queue_space(q) > q->low_mark && qindex >= 0) { __maybe_wake_tx(priv); } @@ -3795,8 +3853,6 @@ static int ipw_queue_tx_hcmd(struct ipw_priv *priv, int hcmd, void *buf, return 0; } - - /* * Rx theory of operation * @@ -3933,9 +3989,9 @@ static void ipw_rx_queue_replenish(void *data) list_del(element); rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data; - rxb->dma_addr = pci_map_single( - priv->pci_dev, rxb->skb->data, CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + rxb->dma_addr = + pci_map_single(priv->pci_dev, rxb->skb->data, + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -3950,8 +4006,7 @@ static void ipw_rx_queue_replenish(void *data) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void ipw_rx_queue_free(struct ipw_priv *priv, - struct ipw_rx_queue *rxq) +static void ipw_rx_queue_free(struct ipw_priv *priv, struct ipw_rx_queue *rxq) { int i; @@ -3961,8 +4016,7 @@ static void ipw_rx_queue_free(struct ipw_priv *priv, for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].skb != NULL) { pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, - CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(rxq->pool[i].skb); } } @@ -4001,28 +4055,28 @@ static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate) switch (rate) { case IEEE80211_OFDM_RATE_6MB: return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? - 1 : 0; + 1 : 0; case IEEE80211_OFDM_RATE_9MB: return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? - 1 : 0; + 1 : 0; case IEEE80211_OFDM_RATE_12MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_18MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_24MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_36MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_48MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_54MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0; default: return 0; } @@ -4074,10 +4128,11 @@ static int ipw_compatible_rates(struct ipw_priv *priv, int num_rates, i; memset(rates, 0, sizeof(*rates)); - num_rates = min(network->rates_len, (u8)IPW_MAX_RATES); + num_rates = min(network->rates_len, (u8) IPW_MAX_RATES); rates->num_rates = 0; for (i = 0; i < num_rates; i++) { - if (!ipw_is_rate_in_mask(priv, network->mode, network->rates[i])) { + if (!ipw_is_rate_in_mask + (priv, network->mode, network->rates[i])) { IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", network->rates[i], priv->rates_mask); continue; @@ -4086,15 +4141,18 @@ static int ipw_compatible_rates(struct ipw_priv *priv, rates->supported_rates[rates->num_rates++] = network->rates[i]; } - num_rates = min(network->rates_ex_len, (u8)(IPW_MAX_RATES - num_rates)); + num_rates = + min(network->rates_ex_len, (u8) (IPW_MAX_RATES - num_rates)); for (i = 0; i < num_rates; i++) { - if (!ipw_is_rate_in_mask(priv, network->mode, network->rates_ex[i])) { + if (!ipw_is_rate_in_mask + (priv, network->mode, network->rates_ex[i])) { IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", network->rates_ex[i], priv->rates_mask); continue; } - rates->supported_rates[rates->num_rates++] = network->rates_ex[i]; + rates->supported_rates[rates->num_rates++] = + network->rates_ex[i]; } return rates->num_rates; @@ -4113,65 +4171,65 @@ static inline void ipw_copy_rates(struct ipw_supported_rates *dest, * mask should ever be used -- right now all callers to add the scan rates are * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */ static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates, - u8 modulation, u32 rate_mask) + u8 modulation, u32 rate_mask) { u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? - IEEE80211_BASIC_RATE_MASK : 0; + IEEE80211_BASIC_RATE_MASK : 0; if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; + IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; + IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_CCK_RATE_5MB; + IEEE80211_CCK_RATE_5MB; if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_CCK_RATE_11MB; + IEEE80211_CCK_RATE_11MB; } static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates, - u8 modulation, u32 rate_mask) + u8 modulation, u32 rate_mask) { u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? - IEEE80211_BASIC_RATE_MASK : 0; + IEEE80211_BASIC_RATE_MASK : 0; if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_6MB; + IEEE80211_OFDM_RATE_6MB; if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_9MB; + IEEE80211_OFDM_RATE_9MB; if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_12MB; + IEEE80211_OFDM_RATE_12MB; if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_18MB; + IEEE80211_OFDM_RATE_18MB; if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_24MB; + IEEE80211_OFDM_RATE_24MB; if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_36MB; + IEEE80211_OFDM_RATE_36MB; if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_48MB; + IEEE80211_OFDM_RATE_48MB; if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_54MB; + IEEE80211_OFDM_RATE_54MB; } struct ipw_network_match { @@ -4179,11 +4237,9 @@ struct ipw_network_match { struct ipw_supported_rates rates; }; -static int ipw_best_network( - struct ipw_priv *priv, - struct ipw_network_match *match, - struct ieee80211_network *network, - int roaming) +static int ipw_best_network(struct ipw_priv *priv, + struct ipw_network_match *match, + struct ieee80211_network *network, int roaming) { struct ipw_supported_rates rates; @@ -4231,21 +4287,21 @@ static int ipw_best_network( memcmp(network->ssid, priv->essid, min(network->ssid_len, priv->essid_len)))) { char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; - strncpy(escaped, escape_essid( - network->ssid, network->ssid_len), + strncpy(escaped, + escape_essid(network->ssid, network->ssid_len), sizeof(escaped)); IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " "because of ESSID mismatch: '%s'.\n", escaped, MAC_ARG(network->bssid), - escape_essid(priv->essid, priv->essid_len)); + escape_essid(priv->essid, + priv->essid_len)); return 0; } } /* If the old network rate is better than this one, don't bother * testing everything else. */ - if (match->network && match->network->stats.rssi > - network->stats.rssi) { + if (match->network && match->network->stats.rssi > network->stats.rssi) { char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; strncpy(escaped, escape_essid(network->ssid, network->ssid_len), @@ -4303,7 +4359,7 @@ static int ipw_best_network( priv->capability & CAP_PRIVACY_ON ? "on" : "off", network->capability & - WLAN_CAPABILITY_PRIVACY ?"on" : "off"); + WLAN_CAPABILITY_PRIVACY ? "on" : "off"); return 0; } @@ -4312,8 +4368,7 @@ static int ipw_best_network( IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " "because of BSSID mismatch: " MAC_FMT ".\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), - MAC_ARG(priv->bssid)); + MAC_ARG(network->bssid), MAC_ARG(priv->bssid)); return 0; } @@ -4351,9 +4406,8 @@ static int ipw_best_network( return 1; } - static void ipw_adhoc_create(struct ipw_priv *priv, - struct ieee80211_network *network) + struct ieee80211_network *network) { /* * For the purposes of scanning, we can set our wireless mode @@ -4393,8 +4447,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv, if (priv->capability & CAP_PRIVACY_ON) network->capability |= WLAN_CAPABILITY_PRIVACY; network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH); - memcpy(network->rates, priv->rates.supported_rates, - network->rates_len); + memcpy(network->rates, priv->rates.supported_rates, network->rates_len); network->rates_ex_len = priv->rates.num_rates - network->rates_len; memcpy(network->rates_ex, &priv->rates.supported_rates[network->rates_len], @@ -4404,13 +4457,13 @@ static void ipw_adhoc_create(struct ipw_priv *priv, network->last_associate = 0; network->time_stamp[0] = 0; network->time_stamp[1] = 0; - network->beacon_interval = 100; /* Default */ - network->listen_interval = 10; /* Default */ - network->atim_window = 0; /* Default */ + network->beacon_interval = 100; /* Default */ + network->listen_interval = 10; /* Default */ + network->atim_window = 0; /* Default */ #ifdef CONFIG_IEEE80211_WPA network->wpa_ie_len = 0; network->rsn_ie_len = 0; -#endif /* CONFIG_IEEE80211_WPA */ +#endif /* CONFIG_IEEE80211_WPA */ } static void ipw_send_wep_keys(struct ipw_priv *priv) @@ -4464,14 +4517,12 @@ static void ipw_debug_config(struct ipw_priv *priv) IPW_DEBUG_INFO("Scan completed, no valid APs matched " "[CFG 0x%08X]\n", priv->config); if (priv->config & CFG_STATIC_CHANNEL) - IPW_DEBUG_INFO("Channel locked to %d\n", - priv->channel); + IPW_DEBUG_INFO("Channel locked to %d\n", priv->channel); else IPW_DEBUG_INFO("Channel unlocked.\n"); if (priv->config & CFG_STATIC_ESSID) IPW_DEBUG_INFO("ESSID locked to '%s'\n", - escape_essid(priv->essid, - priv->essid_len)); + escape_essid(priv->essid, priv->essid_len)); else IPW_DEBUG_INFO("ESSID unlocked.\n"); if (priv->config & CFG_STATIC_BSSID) @@ -4502,7 +4553,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, * Tx rates */ switch (priv->ieee->freq_band) { - case IEEE80211_52GHZ_BAND: /* A only */ + case IEEE80211_52GHZ_BAND: /* A only */ /* IEEE_A */ if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) { /* Invalid fixed rate mask */ @@ -4513,7 +4564,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, fr.tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A; break; - default: /* 2.4Ghz or Mixed */ + default: /* 2.4Ghz or Mixed */ /* IEEE_B */ if (network->mode == IEEE_B) { if (fr.tx_rates & ~IEEE80211_CCK_RATES_MASK) { @@ -4551,13 +4602,12 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, } reg = ipw_read32(priv, IPW_MEM_FIXED_OVERRIDE); - ipw_write_reg32(priv, reg, *(u32*)&fr); + ipw_write_reg32(priv, reg, *(u32 *) & fr); } static int ipw_associate_network(struct ipw_priv *priv, struct ieee80211_network *network, - struct ipw_supported_rates *rates, - int roaming) + struct ipw_supported_rates *rates, int roaming) { int err; @@ -4566,7 +4616,7 @@ static int ipw_associate_network(struct ipw_priv *priv, if (!(priv->config & CFG_STATIC_ESSID)) { priv->essid_len = min(network->ssid_len, - (u8)IW_ESSID_MAX_SIZE); + (u8) IW_ESSID_MAX_SIZE); memcpy(priv->essid, network->ssid, priv->essid_len); } @@ -4612,13 +4662,11 @@ static int ipw_associate_network(struct ipw_priv *priv, priv->capability & CAP_PRIVACY_ON ? " key=" : "", priv->capability & CAP_PRIVACY_ON ? '1' + priv->sec.active_key : '.', - priv->capability & CAP_PRIVACY_ON ? - '.' : ' '); + priv->capability & CAP_PRIVACY_ON ? '.' : ' '); priv->assoc_request.beacon_interval = network->beacon_interval; if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && - (network->time_stamp[0] == 0) && - (network->time_stamp[1] == 0)) { + (network->time_stamp[0] == 0) && (network->time_stamp[1] == 0)) { priv->assoc_request.assoc_type = HC_IBSS_START; priv->assoc_request.assoc_tsf_msw = 0; priv->assoc_request.assoc_tsf_lsw = 0; @@ -4637,8 +4685,7 @@ static int ipw_associate_network(struct ipw_priv *priv, memset(&priv->assoc_request.dest, 0xFF, ETH_ALEN); priv->assoc_request.atim_window = network->atim_window; } else { - memcpy(&priv->assoc_request.dest, network->bssid, - ETH_ALEN); + memcpy(&priv->assoc_request.dest, network->bssid, ETH_ALEN); priv->assoc_request.atim_window = 0; } @@ -4772,14 +4819,13 @@ static void ipw_associate(void *data) if (!(priv->config & CFG_ASSOCIATE) && !(priv->config & (CFG_STATIC_ESSID | - CFG_STATIC_CHANNEL | - CFG_STATIC_BSSID))) { + CFG_STATIC_CHANNEL | CFG_STATIC_BSSID))) { IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n"); return; } list_for_each_entry(network, &priv->ieee->network_list, list) - ipw_best_network(priv, &match, network, 0); + ipw_best_network(priv, &match, network, 0); network = match.network; rates = &match.rates; @@ -4790,8 +4836,7 @@ static void ipw_associate(void *data) priv->config & CFG_STATIC_ESSID && !list_empty(&priv->ieee->network_free_list)) { element = priv->ieee->network_free_list.next; - network = list_entry(element, struct ieee80211_network, - list); + network = list_entry(element, struct ieee80211_network, list); ipw_adhoc_create(priv, network); rates = &priv->rates; list_del(element); @@ -4813,8 +4858,8 @@ static void ipw_associate(void *data) } static inline void ipw_handle_data_packet(struct ipw_priv *priv, - struct ipw_rx_mem_buffer *rxb, - struct ieee80211_rx_stats *stats) + struct ipw_rx_mem_buffer *rxb, + struct ieee80211_rx_stats *stats) { struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; @@ -4846,11 +4891,10 @@ static inline void ipw_handle_data_packet(struct ipw_priv *priv, if (!ieee80211_rx(priv->ieee, rxb->skb, stats)) priv->ieee->stats.rx_errors++; - else /* ieee80211_rx succeeded, so it now owns the SKB */ + else /* ieee80211_rx succeeded, so it now owns the SKB */ rxb->skb = NULL; } - /* * Main entry function for recieving a packet with 80211 headers. This * should be called when ever the FW has notified us that there is a new @@ -4885,125 +4929,152 @@ static void ipw_rx(struct ipw_priv *priv) pkt = (struct ipw_rx_packet *)rxb->skb->data; IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n", pkt->header.message_type, - pkt->header.rx_seq_num, - pkt->header.control_bits); + pkt->header.rx_seq_num, pkt->header.control_bits); switch (pkt->header.message_type) { - case RX_FRAME_TYPE: /* 802.11 frame */ { - struct ieee80211_rx_stats stats = { - .rssi = pkt->u.frame.rssi_dbm - - IPW_RSSI_TO_DBM, - .signal = pkt->u.frame.signal, - .rate = pkt->u.frame.rate, - .mac_time = jiffies, - .received_channel = - pkt->u.frame.received_channel, - .freq = (pkt->u.frame.control & (1<<0)) ? - IEEE80211_24GHZ_BAND : IEEE80211_52GHZ_BAND, - .len = pkt->u.frame.length, - }; - - if (stats.rssi != 0) - stats.mask |= IEEE80211_STATMASK_RSSI; - if (stats.signal != 0) - stats.mask |= IEEE80211_STATMASK_SIGNAL; - if (stats.rate != 0) - stats.mask |= IEEE80211_STATMASK_RATE; - - priv->rx_packets++; + case RX_FRAME_TYPE: /* 802.11 frame */ { + struct ieee80211_rx_stats stats = { + .rssi = pkt->u.frame.rssi_dbm - + IPW_RSSI_TO_DBM, + .signal = pkt->u.frame.signal, + .rate = pkt->u.frame.rate, + .mac_time = jiffies, + .received_channel = + pkt->u.frame.received_channel, + .freq = + (pkt->u.frame. + control & (1 << 0)) ? + IEEE80211_24GHZ_BAND : + IEEE80211_52GHZ_BAND, + .len = pkt->u.frame.length, + }; + + if (stats.rssi != 0) + stats.mask |= IEEE80211_STATMASK_RSSI; + if (stats.signal != 0) + stats.mask |= IEEE80211_STATMASK_SIGNAL; + if (stats.rate != 0) + stats.mask |= IEEE80211_STATMASK_RATE; + + priv->rx_packets++; #ifdef CONFIG_IPW_PROMISC - if (priv->ieee->iw_mode == IW_MODE_MONITOR) { - ipw_handle_data_packet(priv, rxb, &stats); - break; - } + if (priv->ieee->iw_mode == IW_MODE_MONITOR) { + ipw_handle_data_packet(priv, rxb, + &stats); + break; + } #endif - header = (struct ieee80211_hdr *)(rxb->skb->data + - IPW_RX_FRAME_SIZE); + header = + (struct ieee80211_hdr *)(rxb->skb->data + + IPW_RX_FRAME_SIZE); /* TODO: Check Ad-Hoc dest/source and make sure * that we are actually parsing these packets * correctly -- we should probably use the * frame control of the packet and disregard * the current iw_mode */ - switch (priv->ieee->iw_mode) { - case IW_MODE_ADHOC: - network_packet = - !memcmp(header->addr1, - priv->net_dev->dev_addr, - ETH_ALEN) || - !memcmp(header->addr3, - priv->bssid, ETH_ALEN) || - is_broadcast_ether_addr(header->addr1) || - is_multicast_ether_addr(header->addr1); - break; - - case IW_MODE_INFRA: - default: - network_packet = - !memcmp(header->addr3, - priv->bssid, ETH_ALEN) || - !memcmp(header->addr1, - priv->net_dev->dev_addr, - ETH_ALEN) || - is_broadcast_ether_addr(header->addr1) || - is_multicast_ether_addr(header->addr1); + switch (priv->ieee->iw_mode) { + case IW_MODE_ADHOC: + network_packet = + !memcmp(header->addr1, + priv->net_dev->dev_addr, + ETH_ALEN) || + !memcmp(header->addr3, + priv->bssid, ETH_ALEN) || + is_broadcast_ether_addr(header-> + addr1) + || is_multicast_ether_addr(header-> + addr1); + break; + + case IW_MODE_INFRA: + default: + network_packet = + !memcmp(header->addr3, + priv->bssid, ETH_ALEN) || + !memcmp(header->addr1, + priv->net_dev->dev_addr, + ETH_ALEN) || + is_broadcast_ether_addr(header-> + addr1) + || is_multicast_ether_addr(header-> + addr1); + break; + } + + if (network_packet && priv->assoc_network) { + priv->assoc_network->stats.rssi = + stats.rssi; + average_add(&priv->average_rssi, + stats.rssi); + priv->last_rx_rssi = stats.rssi; + } + + IPW_DEBUG_RX("Frame: len=%u\n", + pkt->u.frame.length); + + if (pkt->u.frame.length < frame_hdr_len(header)) { + IPW_DEBUG_DROP + ("Received packet is too small. " + "Dropping.\n"); + priv->ieee->stats.rx_errors++; + priv->wstats.discard.misc++; + break; + } + + switch (WLAN_FC_GET_TYPE(header->frame_ctl)) { + case IEEE80211_FTYPE_MGMT: + ieee80211_rx_mgt(priv->ieee, header, + &stats); + if (priv->ieee->iw_mode == IW_MODE_ADHOC + && + ((WLAN_FC_GET_STYPE + (header->frame_ctl) == + IEEE80211_STYPE_PROBE_RESP) + || + (WLAN_FC_GET_STYPE + (header->frame_ctl) == + IEEE80211_STYPE_BEACON)) + && !memcmp(header->addr3, + priv->bssid, ETH_ALEN)) + ipw_add_station(priv, + header->addr2); + break; + + case IEEE80211_FTYPE_CTL: + break; + + case IEEE80211_FTYPE_DATA: + if (network_packet) + ipw_handle_data_packet(priv, + rxb, + &stats); + else + IPW_DEBUG_DROP("Dropping: " + MAC_FMT ", " + MAC_FMT ", " + MAC_FMT "\n", + MAC_ARG(header-> + addr1), + MAC_ARG(header-> + addr2), + MAC_ARG(header-> + addr3)); + break; + } break; } - if (network_packet && priv->assoc_network) { - priv->assoc_network->stats.rssi = stats.rssi; - average_add(&priv->average_rssi, - stats.rssi); - priv->last_rx_rssi = stats.rssi; - } - - IPW_DEBUG_RX("Frame: len=%u\n", pkt->u.frame.length); - - if (pkt->u.frame.length < frame_hdr_len(header)) { - IPW_DEBUG_DROP("Received packet is too small. " - "Dropping.\n"); - priv->ieee->stats.rx_errors++; - priv->wstats.discard.misc++; - break; - } - - switch (WLAN_FC_GET_TYPE(header->frame_ctl)) { - case IEEE80211_FTYPE_MGMT: - ieee80211_rx_mgt(priv->ieee, header, &stats); - if (priv->ieee->iw_mode == IW_MODE_ADHOC && - ((WLAN_FC_GET_STYPE(header->frame_ctl) == - IEEE80211_STYPE_PROBE_RESP) || - (WLAN_FC_GET_STYPE(header->frame_ctl) == - IEEE80211_STYPE_BEACON)) && - !memcmp(header->addr3, priv->bssid, ETH_ALEN)) - ipw_add_station(priv, header->addr2); - break; - - case IEEE80211_FTYPE_CTL: - break; - - case IEEE80211_FTYPE_DATA: - if (network_packet) - ipw_handle_data_packet(priv, rxb, &stats); - else - IPW_DEBUG_DROP("Dropping: " MAC_FMT - ", " MAC_FMT ", " MAC_FMT "\n", - MAC_ARG(header->addr1), MAC_ARG(header->addr2), - MAC_ARG(header->addr3)); - break; - } - break; - } - - case RX_HOST_NOTIFICATION_TYPE: { - IPW_DEBUG_RX("Notification: subtype=%02X flags=%02X size=%d\n", + case RX_HOST_NOTIFICATION_TYPE:{ + IPW_DEBUG_RX + ("Notification: subtype=%02X flags=%02X size=%d\n", pkt->u.notification.subtype, pkt->u.notification.flags, pkt->u.notification.size); - ipw_rx_notification(priv, &pkt->u.notification); - break; - } + ipw_rx_notification(priv, &pkt->u.notification); + break; + } default: IPW_DEBUG_RX("Bad Rx packet of type %d\n", @@ -5088,10 +5159,10 @@ static int ipw_request_scan(struct ipw_priv *priv) /* If we are roaming, then make this a directed scan for the current * network. Otherwise, ensure that every other scan is a fast * channel hop scan */ - if ((priv->status & STATUS_ROAMING) || ( - !(priv->status & STATUS_ASSOCIATED) && - (priv->config & CFG_STATIC_ESSID) && - (scan.full_scan_index % 2))) { + if ((priv->status & STATUS_ROAMING) + || (!(priv->status & STATUS_ASSOCIATED) + && (priv->config & CFG_STATIC_ESSID) + && (scan.full_scan_index % 2))) { err = ipw_send_ssid(priv, priv->essid, priv->essid_len); if (err) { IPW_DEBUG_HC("Attempt to send SSID command failed.\n"); @@ -5103,7 +5174,7 @@ static int ipw_request_scan(struct ipw_priv *priv) scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN; } - if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { + if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { int start = channel_index; for (i = 0; i < MAX_A_CHANNELS; i++) { if (band_a_active_channel[i] == 0) @@ -5113,18 +5184,18 @@ static int ipw_request_scan(struct ipw_priv *priv) continue; channel_index++; scan.channels_list[channel_index] = - band_a_active_channel[i]; + band_a_active_channel[i]; ipw_set_scan_type(&scan, channel_index, scan_type); } if (start != channel_index) { - scan.channels_list[start] = (u8)(IPW_A_MODE << 6) | - (channel_index - start); + scan.channels_list[start] = (u8) (IPW_A_MODE << 6) | + (channel_index - start); channel_index++; } } - if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { + if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { int start = channel_index; for (i = 0; i < MAX_B_CHANNELS; i++) { if (band_b_active_channel[i] == 0) @@ -5134,20 +5205,19 @@ static int ipw_request_scan(struct ipw_priv *priv) continue; channel_index++; scan.channels_list[channel_index] = - band_b_active_channel[i]; + band_b_active_channel[i]; ipw_set_scan_type(&scan, channel_index, scan_type); } if (start != channel_index) { - scan.channels_list[start] = (u8)(IPW_B_MODE << 6) | - (channel_index - start); + scan.channels_list[start] = (u8) (IPW_B_MODE << 6) | + (channel_index - start); } } err = ipw_send_scan_request_ext(priv, &scan); if (err) { - IPW_DEBUG_HC("Sending scan command failed: %08X\n", - err); + IPW_DEBUG_HC("Sending scan command failed: %08X\n", err); return -EIO; } @@ -5199,9 +5269,8 @@ static int ipw_set_channel(struct ipw_priv *priv, u8 channel) priv->config |= CFG_STATIC_CHANNEL; if (priv->channel == channel) { - IPW_DEBUG_INFO( - "Request to set channel to current value (%d)\n", - channel); + IPW_DEBUG_INFO("Request to set channel to current value (%d)\n", + channel); return 0; } @@ -5229,8 +5298,7 @@ static int ipw_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; @@ -5248,12 +5316,11 @@ static int ipw_wx_set_freq(struct net_device *dev, return -EOPNOTSUPP; IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); - return ipw_set_channel(priv, (u8)fwrq->m); + return ipw_set_channel(priv, (u8) fwrq->m); return 0; } - static int ipw_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5306,7 +5373,7 @@ static int ipw_wx_set_mode(struct net_device *dev, if (wrqu->mode == IW_MODE_MONITOR) priv->net_dev->type = ARPHRD_IEEE80211; -#endif /* CONFIG_IPW_PROMISC */ +#endif /* CONFIG_IPW_PROMISC */ #ifdef CONFIG_PM /* Free the existing firmware and reset the fw_loaded @@ -5324,12 +5391,12 @@ static int ipw_wx_set_mode(struct net_device *dev, priv->ieee->iw_mode = wrqu->mode; ipw_adapter_restart(priv); - return err; + return err; } static int ipw_wx_get_mode(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 ipw_priv *priv = ieee80211_priv(dev); @@ -5339,7 +5406,6 @@ static int ipw_wx_get_mode(struct net_device *dev, return 0; } - #define DEFAULT_RTS_THRESHOLD 2304U #define MIN_RTS_THRESHOLD 1U #define MAX_RTS_THRESHOLD 2304U @@ -5383,19 +5449,19 @@ static int ipw_wx_get_range(struct net_device *dev, /* 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; /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ - range->avg_qual.level = 0; /* FIXME to real average level */ + range->avg_qual.level = 0; /* FIXME to real average level */ range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ + range->avg_qual.updated = 7; /* Updated all three */ - range->num_bitrates = min(priv->rates.num_rates, (u8)IW_MAX_BITRATES); + range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES); for (i = 0; i < range->num_bitrates; i++) range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) * - 500000; + 500000; range->max_rts = DEFAULT_RTS_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD; @@ -5410,7 +5476,7 @@ static int ipw_wx_get_range(struct net_device *dev, range->we_version_compiled = WIRELESS_EXT; range->we_version_source = 16; - range->num_channels = FREQ_COUNT; + range->num_channels = FREQ_COUNT; val = 0; for (i = 0; i < FREQ_COUNT; i++) { @@ -5506,7 +5572,7 @@ static int ipw_wx_set_essid(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); - char *essid = ""; /* ANY */ + char *essid = ""; /* ANY */ int length = 0; if (wrqu->essid.flags && wrqu->essid.length) { @@ -5567,11 +5633,11 @@ static int ipw_wx_get_essid(struct net_device *dev, 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; @@ -5587,15 +5653,14 @@ static int ipw_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_TRACE("<<\n"); return 0; } - static int ipw_wx_get_nick(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5604,11 +5669,10 @@ static int ipw_wx_get_nick(struct net_device *dev, IPW_DEBUG_WX("Getting nick\n"); wrqu->data.length = strlen(priv->nick) + 1; memcpy(extra, priv->nick, wrqu->data.length); - wrqu->data.flags = 1; /* active */ + wrqu->data.flags = 1; /* active */ return 0; } - static int ipw_wx_set_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5621,14 +5685,13 @@ static int ipw_wx_get_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct ipw_priv * priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); wrqu->bitrate.value = priv->last_rate; IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); return 0; } - static int ipw_wx_set_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5657,14 +5720,12 @@ static int ipw_wx_get_rts(struct net_device *dev, struct ipw_priv *priv = ieee80211_priv(dev); wrqu->rts.value = priv->rts_threshold; wrqu->rts.fixed = 0; /* no auto select */ - wrqu->rts.disabled = - (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); + wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value); return 0; } - static int ipw_wx_set_txpow(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5679,8 +5740,7 @@ static int ipw_wx_set_txpow(struct net_device *dev, if (wrqu->power.flags != IW_TXPOW_DBM) return -EINVAL; - if ((wrqu->power.value > 20) || - (wrqu->power.value < -12)) + if ((wrqu->power.value > 20) || (wrqu->power.value < -12)) return -EINVAL; priv->tx_power = wrqu->power.value; @@ -5704,11 +5764,10 @@ static int ipw_wx_set_txpow(struct net_device *dev, return 0; - error: + error: return -EIO; } - static int ipw_wx_get_txpow(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5721,15 +5780,14 @@ static int ipw_wx_get_txpow(struct net_device *dev, wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; IPW_DEBUG_WX("GET TX Power -> %s %d \n", - wrqu->power.disabled ? "ON" : "OFF", - wrqu->power.value); + wrqu->power.disabled ? "ON" : "OFF", wrqu->power.value); return 0; } static int ipw_wx_set_frag(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 ipw_priv *priv = ieee80211_priv(dev); @@ -5749,14 +5807,13 @@ static int ipw_wx_set_frag(struct net_device *dev, } static int ipw_wx_get_frag(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 ipw_priv *priv = ieee80211_priv(dev); wrqu->frag.value = priv->ieee->fts; wrqu->frag.fixed = 0; /* no auto select */ - wrqu->frag.disabled = - (wrqu->frag.value == DEFAULT_FTS); + wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS); IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value); @@ -5771,7 +5828,6 @@ static int ipw_wx_set_retry(struct net_device *dev, return -EOPNOTSUPP; } - static int ipw_wx_get_retry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5780,7 +5836,6 @@ static int ipw_wx_get_retry(struct net_device *dev, return -EOPNOTSUPP; } - static int ipw_wx_set_scan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5801,24 +5856,24 @@ static int ipw_wx_get_scan(struct net_device *dev, } static int ipw_wx_set_encode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) { struct ipw_priv *priv = ieee80211_priv(dev); return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); } static int ipw_wx_get_encode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) { struct ipw_priv *priv = ieee80211_priv(dev); return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key); } static int ipw_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 ipw_priv *priv = ieee80211_priv(dev); int err; @@ -5837,11 +5892,11 @@ static int ipw_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 explicitely 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); return -EOPNOTSUPP; @@ -5849,7 +5904,7 @@ static int ipw_wx_set_power(struct net_device *dev, /* If the user hasn't specified a power management mode yet, default * to BATTERY */ - if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) + if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY; else priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; @@ -5859,15 +5914,14 @@ static int ipw_wx_set_power(struct net_device *dev, return err; } - 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); return 0; } static int ipw_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) { struct ipw_priv *priv = ieee80211_priv(dev); @@ -5883,8 +5937,8 @@ static int ipw_wx_get_power(struct net_device *dev, } static int ipw_wx_set_powermode(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 ipw_priv *priv = ieee80211_priv(dev); int mode = *(int *)extra; @@ -5911,8 +5965,8 @@ static int ipw_wx_set_powermode(struct net_device *dev, #define MAX_WX_STRING 80 static int ipw_wx_get_powermode(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 ipw_priv *priv = ieee80211_priv(dev); int level = IPW_POWER_LEVEL(priv->power_mode); @@ -5935,7 +5989,7 @@ static int ipw_wx_get_powermode(struct net_device *dev, } if (!(priv->power_mode & IPW_POWER_ENABLED)) - p += snprintf(p, MAX_WX_STRING - (p - extra)," OFF"); + p += snprintf(p, MAX_WX_STRING - (p - extra), " OFF"); wrqu->data.length = p - extra + 1; @@ -5943,16 +5997,15 @@ static int ipw_wx_get_powermode(struct net_device *dev, } static int ipw_wx_set_wireless_mode(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 ipw_priv *priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); int mode = *(int *)extra; u8 band = 0, modulation = 0; if (mode == 0 || mode & ~IEEE_MODE_MASK) { - IPW_WARNING("Attempt to set invalid wireless mode: %d\n", - mode); + IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode); return -EINVAL; } @@ -5988,31 +6041,30 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev, priv->ieee->mode = mode; priv->ieee->freq_band = band; priv->ieee->modulation = modulation; - init_supported_rates(priv, &priv->rates); + init_supported_rates(priv, &priv->rates); /* If we are currently associated, or trying to associate - * then see if this is a new configuration (causing us to + * then see if this is a new configuration (causing us to * disassociate) */ - if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { + if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { /* The resulting association will trigger * the new rates to be sent to the device */ - IPW_DEBUG_ASSOC("Disassociating due to mode change.\n"); - ipw_disassociate(priv); + IPW_DEBUG_ASSOC("Disassociating due to mode change.\n"); + ipw_disassociate(priv); } else ipw_send_supported_rates(priv, &priv->rates); IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n", mode & IEEE_A ? 'a' : '.', - mode & IEEE_B ? 'b' : '.', - mode & IEEE_G ? 'g' : '.'); + mode & IEEE_B ? 'b' : '.', mode & IEEE_G ? 'g' : '.'); return 0; } static int ipw_wx_get_wireless_mode(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 ipw_priv *priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); switch (priv->ieee->freq_band) { case IEEE80211_24GHZ_BAND: @@ -6033,7 +6085,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev, strncpy(extra, "802.11a (1)", MAX_WX_STRING); break; - default: /* Mixed Band */ + default: /* Mixed Band */ switch (priv->ieee->modulation) { case IEEE80211_CCK_MODULATION: strncpy(extra, "802.11ab (3)", MAX_WX_STRING); @@ -6050,9 +6102,9 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev, IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra); - wrqu->data.length = strlen(extra) + 1; + wrqu->data.length = strlen(extra) + 1; - return 0; + return 0; } #ifdef CONFIG_IPW_PROMISC @@ -6081,7 +6133,6 @@ static int ipw_wx_set_promisc(struct net_device *dev, return 0; } - static int ipw_wx_reset(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -6091,40 +6142,39 @@ static int ipw_wx_reset(struct net_device *dev, ipw_adapter_restart(priv); return 0; } -#endif // CONFIG_IPW_PROMISC +#endif // CONFIG_IPW_PROMISC /* Rebase the WE IOCTLs to zero for the handler array */ #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] -static iw_handler ipw_wx_handlers[] = -{ - IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, - IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, - IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, - IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, - IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, - IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, - IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, - IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, - IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, - IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, - IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, - IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, - IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, - IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, - IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, - IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, - IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, - IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, - IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, - IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, - IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, - IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, - IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, - IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, - IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, - IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, - IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, - IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power, +static iw_handler ipw_wx_handlers[] = { + IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, + IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, + IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, + IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, + IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, + IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, + IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, + IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, + IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, + IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power, }; #define IPW_PRIV_SET_POWER SIOCIWFIRSTPRIV @@ -6134,38 +6184,31 @@ static iw_handler ipw_wx_handlers[] = #define IPW_PRIV_SET_PROMISC SIOCIWFIRSTPRIV+4 #define IPW_PRIV_RESET SIOCIWFIRSTPRIV+5 - static struct iw_priv_args ipw_priv_args[] = { { - .cmd = IPW_PRIV_SET_POWER, - .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - .name = "set_power" - }, + .cmd = IPW_PRIV_SET_POWER, + .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + .name = "set_power"}, { - .cmd = IPW_PRIV_GET_POWER, - .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, - .name = "get_power" - }, + .cmd = IPW_PRIV_GET_POWER, + .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, + .name = "get_power"}, { - .cmd = IPW_PRIV_SET_MODE, - .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - .name = "set_mode" - }, + .cmd = IPW_PRIV_SET_MODE, + .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + .name = "set_mode"}, { - .cmd = IPW_PRIV_GET_MODE, - .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, - .name = "get_mode" - }, + .cmd = IPW_PRIV_GET_MODE, + .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, + .name = "get_mode"}, #ifdef CONFIG_IPW_PROMISC { - IPW_PRIV_SET_PROMISC, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" - }, + IPW_PRIV_SET_PROMISC, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"}, { - IPW_PRIV_RESET, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" - }, -#endif /* CONFIG_IPW_PROMISC */ + IPW_PRIV_RESET, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"}, +#endif /* CONFIG_IPW_PROMISC */ }; static iw_handler ipw_priv_handler[] = { @@ -6179,25 +6222,21 @@ static iw_handler ipw_priv_handler[] = { #endif }; -static struct iw_handler_def ipw_wx_handler_def = -{ - .standard = ipw_wx_handlers, - .num_standard = ARRAY_SIZE(ipw_wx_handlers), - .num_private = ARRAY_SIZE(ipw_priv_handler), - .num_private_args = ARRAY_SIZE(ipw_priv_args), - .private = ipw_priv_handler, - .private_args = ipw_priv_args, +static struct iw_handler_def ipw_wx_handler_def = { + .standard = ipw_wx_handlers, + .num_standard = ARRAY_SIZE(ipw_wx_handlers), + .num_private = ARRAY_SIZE(ipw_priv_handler), + .num_private_args = ARRAY_SIZE(ipw_priv_args), + .private = ipw_priv_handler, + .private_args = ipw_priv_args, }; - - - /* * Get wireless statistics. * Called by /proc/net/wireless * Also called by SIOCGIWSTATS */ -static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) +static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev) { struct ipw_priv *priv = ieee80211_priv(dev); struct iw_statistics *wstats; @@ -6217,7 +6256,7 @@ static struct iw_statistics *ipw_get_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; } @@ -6225,7 +6264,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) wstats->qual.level = average_value(&priv->average_rssi); wstats->qual.noise = average_value(&priv->average_noise); wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | - IW_QUAL_NOISE_UPDATED; + IW_QUAL_NOISE_UPDATED; wstats->miss.beacon = average_value(&priv->average_missed_beacons); wstats->discard.retries = priv->last_tx_failures; @@ -6238,13 +6277,12 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) return wstats; } - /* net device stuff */ static inline void init_sys_config(struct ipw_sys_config *sys_config) { - memset(sys_config, 0, sizeof(struct ipw_sys_config)); - sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ + memset(sys_config, 0, sizeof(struct ipw_sys_config)); + sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ sys_config->answer_broadcast_ssid_probe = 0; sys_config->accept_all_data_frames = 0; sys_config->accept_non_directed_frames = 1; @@ -6253,7 +6291,7 @@ static inline void init_sys_config(struct ipw_sys_config *sys_config) sys_config->exclude_multicast_unencrypted = 0; sys_config->disable_multicast_decryption = 1; sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH; - sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ + sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ sys_config->dot11g_auto_detection = 0; sys_config->enable_cts_to_self = 0; sys_config->bt_coexist_collision_thr = 0; @@ -6288,7 +6326,7 @@ we need to heavily modify the ieee80211_skb_to_txb. static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) - txb->fragments[0]->data; + txb->fragments[0]->data; int i = 0; struct tfd_frame *tfd; struct clx2_tx_queue *txq = &priv->txq[0]; @@ -6300,7 +6338,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) case IW_MODE_ADHOC: hdr_len = IEEE80211_3ADDR_LEN; unicast = !is_broadcast_ether_addr(hdr->addr1) && - !is_multicast_ether_addr(hdr->addr1); + !is_multicast_ether_addr(hdr->addr1); id = ipw_find_station(priv, hdr->addr1); if (id == IPW_INVALID_STATION) { id = ipw_add_station(priv, hdr->addr1); @@ -6316,7 +6354,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) case IW_MODE_INFRA: default: unicast = !is_broadcast_ether_addr(hdr->addr3) && - !is_multicast_ether_addr(hdr->addr3); + !is_multicast_ether_addr(hdr->addr3); hdr_len = IEEE80211_3ADDR_LEN; id = 0; break; @@ -6349,7 +6387,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len); /* payload */ - tfd->u.data.num_chunks = min((u8)(NUM_TFD_CHUNKS - 2), txb->nr_frags); + tfd->u.data.num_chunks = min((u8) (NUM_TFD_CHUNKS - 2), txb->nr_frags); for (i = 0; i < tfd->u.data.num_chunks; i++) { IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n", i, tfd->u.data.num_chunks, @@ -6357,9 +6395,11 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len, txb->fragments[i]->len - hdr_len); - tfd->u.data.chunk_ptr[i] = pci_map_single( - priv->pci_dev, txb->fragments[i]->data + hdr_len, - txb->fragments[i]->len - hdr_len, PCI_DMA_TODEVICE); + tfd->u.data.chunk_ptr[i] = + pci_map_single(priv->pci_dev, + txb->fragments[i]->data + hdr_len, + txb->fragments[i]->len - hdr_len, + PCI_DMA_TODEVICE); tfd->u.data.chunk_len[i] = txb->fragments[i]->len - hdr_len; } @@ -6379,16 +6419,16 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) for (j = i; j < txb->nr_frags; j++) { int size = txb->fragments[j]->len - hdr_len; printk(KERN_INFO "Adding frag %d %d...\n", - j, size); + j, size); memcpy(skb_put(skb, size), - txb->fragments[j]->data + hdr_len, - size); + txb->fragments[j]->data + hdr_len, size); } dev_kfree_skb_any(txb->fragments[i]); txb->fragments[i] = skb; - tfd->u.data.chunk_ptr[i] = pci_map_single( - priv->pci_dev, skb->data, - tfd->u.data.chunk_len[i], PCI_DMA_TODEVICE); + tfd->u.data.chunk_ptr[i] = + pci_map_single(priv->pci_dev, skb->data, + tfd->u.data.chunk_len[i], + PCI_DMA_TODEVICE); tfd->u.data.num_chunks++; } } @@ -6402,7 +6442,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) return; - drop: + drop: IPW_DEBUG_DROP("Silently dropping Tx packet.\n"); ieee80211_txb_free(txb); } @@ -6429,7 +6469,7 @@ static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb, spin_unlock_irqrestore(&priv->lock, flags); return 0; - fail_unlock: + fail_unlock: spin_unlock_irqrestore(&priv->lock, flags); return 1; } @@ -6478,7 +6518,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev, len = sizeof(date); ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len); - snprintf(info->fw_version, sizeof(info->fw_version),"%s (%s)", + snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)", vers, date); strcpy(info->bus_info, pci_name(p->pci_dev)); info->eedump_len = CX2_EEPROM_IMAGE_SIZE; @@ -6496,19 +6536,19 @@ static int ipw_ethtool_get_eeprom_len(struct net_device *dev) } static int ipw_ethtool_get_eeprom(struct net_device *dev, - struct ethtool_eeprom *eeprom, u8 *bytes) + struct ethtool_eeprom *eeprom, u8 * bytes) { struct ipw_priv *p = ieee80211_priv(dev); if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) return -EINVAL; - memcpy(bytes, &((u8 *)p->eeprom)[eeprom->offset], eeprom->len); + memcpy(bytes, &((u8 *) p->eeprom)[eeprom->offset], eeprom->len); return 0; } static int ipw_ethtool_set_eeprom(struct net_device *dev, - struct ethtool_eeprom *eeprom, u8 *bytes) + struct ethtool_eeprom *eeprom, u8 * bytes) { struct ipw_priv *p = ieee80211_priv(dev); int i; @@ -6516,21 +6556,20 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev, if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) return -EINVAL; - memcpy(&((u8 *)p->eeprom)[eeprom->offset], bytes, eeprom->len); + memcpy(&((u8 *) p->eeprom)[eeprom->offset], bytes, eeprom->len); for (i = IPW_EEPROM_DATA; - i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; - i++) + i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; i++) ipw_write8(p, i, p->eeprom[i]); return 0; } static struct ethtool_ops ipw_ethtool_ops = { - .get_link = ipw_ethtool_get_link, - .get_drvinfo = ipw_ethtool_get_drvinfo, - .get_eeprom_len = ipw_ethtool_get_eeprom_len, - .get_eeprom = ipw_ethtool_get_eeprom, - .set_eeprom = ipw_ethtool_set_eeprom, + .get_link = ipw_ethtool_get_link, + .get_drvinfo = ipw_ethtool_get_drvinfo, + .get_eeprom_len = ipw_ethtool_get_eeprom_len, + .get_eeprom = ipw_ethtool_get_eeprom, + .set_eeprom = ipw_ethtool_set_eeprom, }; static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs) @@ -6574,10 +6613,10 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs) tasklet_schedule(&priv->irq_tasklet); - spin_unlock(&priv->lock); + spin_unlock(&priv->lock); return IRQ_HANDLED; - none: + none: spin_unlock(&priv->lock); return IRQ_NONE; } @@ -6609,7 +6648,7 @@ static void ipw_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->lock, flags); } @@ -6642,7 +6681,6 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv) return ret; } - static void shim__set_security(struct net_device *dev, struct ieee80211_security *sec) { @@ -6683,8 +6721,7 @@ static void shim__set_security(struct net_device *dev, priv->status |= STATUS_SECURITY_UPDATED; } - if (sec->flags & SEC_ENABLED && - priv->sec.enabled != sec->enabled) { + if (sec->flags & SEC_ENABLED && priv->sec.enabled != sec->enabled) { priv->sec.flags |= SEC_ENABLED; priv->sec.enabled = sec->enabled; priv->status |= STATUS_SECURITY_UPDATED; @@ -6694,8 +6731,7 @@ static void shim__set_security(struct net_device *dev, priv->capability &= ~CAP_PRIVACY_ON; } - if (sec->flags & SEC_LEVEL && - priv->sec.level != sec->level) { + if (sec->flags & SEC_LEVEL && priv->sec.level != sec->level) { priv->sec.level = sec->level; priv->sec.flags |= SEC_LEVEL; priv->status |= STATUS_SECURITY_UPDATED; @@ -6709,7 +6745,7 @@ static void shim__set_security(struct net_device *dev, (((priv->assoc_request.capability & WLAN_CAPABILITY_PRIVACY) && !sec->enabled) || (!(priv->assoc_request.capability & - WLAN_CAPABILITY_PRIVACY) && sec->enabled))) { + WLAN_CAPABILITY_PRIVACY) && sec->enabled))) { IPW_DEBUG_ASSOC("Disassociating due to capability " "change.\n"); ipw_disassociate(priv); @@ -6723,7 +6759,7 @@ static int init_supported_rates(struct ipw_priv *priv, /* TODO: Mask out rates based on priv->rates_mask */ memset(rates, 0, sizeof(*rates)); - /* configure supported rates */ + /* configure supported rates */ switch (priv->ieee->freq_band) { case IEEE80211_52GHZ_BAND: rates->ieee_mode = IPW_A_MODE; @@ -6732,7 +6768,7 @@ static int init_supported_rates(struct ipw_priv *priv, IEEE80211_OFDM_DEFAULT_RATES_MASK); break; - default: /* Mixed or 2.4Ghz */ + default: /* Mixed or 2.4Ghz */ rates->ieee_mode = IPW_G_MODE; rates->purpose = IPW_RATE_CAPABILITIES; ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION, @@ -6783,8 +6819,8 @@ static int ipw_config(struct ipw_priv *priv) if (ipw_send_system_config(priv, &priv->sys_config)) goto error; - init_supported_rates(priv, &priv->rates); - if (ipw_send_supported_rates(priv, &priv->rates)) + init_supported_rates(priv, &priv->rates); + if (ipw_send_supported_rates(priv, &priv->rates)) goto error; /* Set request-to-send threshold */ @@ -6806,7 +6842,7 @@ static int ipw_config(struct ipw_priv *priv) return 0; - error: + error: return -EIO; } @@ -6818,13 +6854,12 @@ static int ipw_up(struct ipw_priv *priv) if (priv->status & STATUS_EXIT_PENDING) return -EIO; - for (i = 0; i < MAX_HW_RESTARTS; i++ ) { + for (i = 0; i < MAX_HW_RESTARTS; i++) { /* Load the microcode, firmware, and eeprom. * Also start the clocks. */ rc = ipw_load(priv); if (rc) { - IPW_ERROR("Unable to load firmware: 0x%08X\n", - rc); + IPW_ERROR("Unable to load firmware: 0x%08X\n", rc); return rc; } @@ -6857,8 +6892,7 @@ static int ipw_up(struct ipw_priv *priv) /* tried to restart and config the device for as long as our * patience could withstand */ - IPW_ERROR("Unable to initialize device after %d attempts.\n", - i); + IPW_ERROR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -6923,10 +6957,10 @@ static struct pci_device_id card_ids[] = { {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ - {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */ - {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ - {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ + {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ + {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */ + {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ + {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ /* required last entry */ {0,} @@ -6954,11 +6988,10 @@ static struct attribute *ipw_sysfs_entries[] = { static struct attribute_group ipw_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = ipw_sysfs_entries, + .attrs = ipw_sysfs_entries, }; -static int ipw_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0; struct net_device *net_dev; @@ -7051,7 +7084,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->config |= CFG_STATIC_CHANNEL; priv->channel = channel; IPW_DEBUG_INFO("Bind to static channel %d\n", channel); - IPW_DEBUG_INFO("Bind to static channel %d\n", channel); + IPW_DEBUG_INFO("Bind to static channel %d\n", channel); /* TODO: Validate that provided channel is in range */ } @@ -7078,9 +7111,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->ieee->abg_ture = 1; band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND; modulation = IEEE80211_OFDM_MODULATION | - IEEE80211_CCK_MODULATION; + IEEE80211_CCK_MODULATION; priv->adapter = IPW_2915ABG; - priv->ieee->mode = IEEE_A|IEEE_G|IEEE_B; + priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B; } else { if (priv->pci_dev->device == 0x4221) printk(KERN_INFO DRV_NAME @@ -7094,9 +7127,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->ieee->abg_ture = 0; band = IEEE80211_24GHZ_BAND; modulation = IEEE80211_OFDM_MODULATION | - IEEE80211_CCK_MODULATION; + IEEE80211_CCK_MODULATION; priv->adapter = IPW_2200BG; - priv->ieee->mode = IEEE_G|IEEE_B; + priv->ieee->mode = IEEE_G | IEEE_B; } priv->ieee->freq_band = band; @@ -7110,11 +7143,10 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->rts_threshold = DEFAULT_RTS_THRESHOLD; /* If power management is turned on, default to AC mode */ - priv->power_mode = IPW_POWER_AC; + priv->power_mode = IPW_POWER_AC; priv->tx_power = IPW_DEFAULT_TX_POWER; - err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, - priv); + err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, priv); if (err) { IPW_ERROR("Error allocating IRQ %d\n", pdev->irq); goto out_destroy_workqueue; @@ -7136,7 +7168,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, net_dev->wireless_handlers = &ipw_wx_handler_def; net_dev->ethtool_ops = &ipw_ethtool_ops; net_dev->irq = pdev->irq; - net_dev->base_addr = (unsigned long )priv->hw_base; + net_dev->base_addr = (unsigned long)priv->hw_base; net_dev->mem_start = pci_resource_start(pdev, 0); net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1; @@ -7154,23 +7186,23 @@ static int ipw_pci_probe(struct pci_dev *pdev, return 0; - out_remove_group: + out_remove_group: sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); - out_release_irq: + out_release_irq: free_irq(pdev->irq, priv); - out_destroy_workqueue: + out_destroy_workqueue: destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - out_iounmap: + out_iounmap: iounmap(priv->hw_base); - out_pci_release_regions: + out_pci_release_regions: pci_release_regions(pdev); - out_pci_disable_device: + out_pci_disable_device: pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - out_free_ieee80211: + out_free_ieee80211: free_ieee80211(priv->net_dev); - out: + out: return err; } @@ -7223,7 +7255,6 @@ static void ipw_pci_remove(struct pci_dev *pdev) #endif } - #ifdef CONFIG_PM static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) { @@ -7232,7 +7263,7 @@ static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) printk(KERN_INFO "%s: Going into suspend...\n", dev->name); - /* Take down the device; powers it off, etc. */ + /* Take down the device; powers it off, etc. */ ipw_down(priv); /* Remove the PRESENT state of the device */ @@ -7306,8 +7337,7 @@ static int __init ipw_init(void) return ret; } - ret = driver_create_file(&ipw_driver.driver, - &driver_attr_debug_level); + ret = driver_create_file(&ipw_driver.driver, &driver_attr_debug_level); if (ret) { IPW_ERROR("Unable to create driver sysfs file\n"); pci_unregister_driver(&ipw_driver); diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h index 66bb590353..5b00882133 100644 --- a/drivers/net/wireless/ipw2200.h +++ b/drivers/net/wireless/ipw2200.h @@ -56,8 +56,7 @@ #include /* Authentication and Association States */ -enum connection_manager_assoc_states -{ +enum connection_manager_assoc_states { CMAS_INIT = 0, CMAS_TX_AUTH_SEQ_1, CMAS_RX_AUTH_SEQ_2, @@ -74,7 +73,6 @@ enum connection_manager_assoc_states CMAS_LAST }; - #define IPW_WAIT (1<<0) #define IPW_QUIET (1<<1) #define IPW_ROAMING (1<<2) @@ -190,7 +188,6 @@ enum connection_manager_assoc_states #define DCT_FLAG_EXT_MODE_CCK 0x01 #define DCT_FLAG_EXT_MODE_OFDM 0x00 - #define TX_RX_TYPE_MASK 0xFF #define TX_FRAME_TYPE 0x00 #define TX_HOST_COMMAND_TYPE 0x01 @@ -242,107 +239,97 @@ enum connection_manager_assoc_states * Contains common data for Rx and Tx queues */ struct clx2_queue { - int n_bd; /**< number of BDs in this queue */ - int first_empty; /**< 1-st empty entry (index) */ - int last_used; /**< last used entry (index) */ - u32 reg_w; /**< 'write' reg (queue head), addr in domain 1 */ - u32 reg_r; /**< 'read' reg (queue tail), addr in domain 1 */ - dma_addr_t dma_addr; /**< physical addr for BD's */ - int low_mark; /**< low watermark, resume queue if free space more than this */ - int high_mark; /**< high watermark, stop queue if free space less than this */ + int n_bd; /**< number of BDs in this queue */ + int first_empty; /**< 1-st empty entry (index) */ + int last_used; /**< last used entry (index) */ + u32 reg_w; /**< 'write' reg (queue head), addr in domain 1 */ + u32 reg_r; /**< 'read' reg (queue tail), addr in domain 1 */ + dma_addr_t dma_addr; /**< physical addr for BD's */ + int low_mark; /**< low watermark, resume queue if free space more than this */ + int high_mark; /**< high watermark, stop queue if free space less than this */ } __attribute__ ((packed)); -struct machdr32 -{ +struct machdr32 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! - u8 addr4[ MACADRR_BYTE_LEN ]; + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! + u8 addr4[MACADRR_BYTE_LEN]; u16 qos_ctrl; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -struct machdr30 -{ +struct machdr30 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! - u8 addr4[ MACADRR_BYTE_LEN ]; -} __attribute__ ((packed)) ; - -struct machdr26 -{ + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! + u8 addr4[MACADRR_BYTE_LEN]; +} __attribute__ ((packed)); + +struct machdr26 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! u16 qos_ctrl; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -struct machdr24 -{ +struct machdr24 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! -} __attribute__ ((packed)) ; + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! +} __attribute__ ((packed)); // TX TFD with 32 byte MAC Header -struct tx_tfd_32 -{ - struct machdr32 mchdr; // 32 - u32 uivplaceholder[2]; // 8 -} __attribute__ ((packed)) ; +struct tx_tfd_32 { + struct machdr32 mchdr; // 32 + u32 uivplaceholder[2]; // 8 +} __attribute__ ((packed)); // TX TFD with 30 byte MAC Header -struct tx_tfd_30 -{ - struct machdr30 mchdr; // 30 - u8 reserved[2]; // 2 - u32 uivplaceholder[2]; // 8 -} __attribute__ ((packed)) ; +struct tx_tfd_30 { + struct machdr30 mchdr; // 30 + u8 reserved[2]; // 2 + u32 uivplaceholder[2]; // 8 +} __attribute__ ((packed)); // tx tfd with 26 byte mac header -struct tx_tfd_26 -{ - struct machdr26 mchdr; // 26 - u8 reserved1[2]; // 2 - u32 uivplaceholder[2]; // 8 - u8 reserved2[4]; // 4 -} __attribute__ ((packed)) ; +struct tx_tfd_26 { + struct machdr26 mchdr; // 26 + u8 reserved1[2]; // 2 + u32 uivplaceholder[2]; // 8 + u8 reserved2[4]; // 4 +} __attribute__ ((packed)); // tx tfd with 24 byte mac header -struct tx_tfd_24 -{ - struct machdr24 mchdr; // 24 - u32 uivplaceholder[2]; // 8 - u8 reserved[8]; // 8 -} __attribute__ ((packed)) ; - +struct tx_tfd_24 { + struct machdr24 mchdr; // 24 + u32 uivplaceholder[2]; // 8 + u8 reserved[8]; // 8 +} __attribute__ ((packed)); #define DCT_WEP_KEY_FIELD_LENGTH 16 -struct tfd_command -{ +struct tfd_command { u8 index; u8 length; u16 reserved; u8 payload[0]; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); struct tfd_data { /* Header */ u32 work_area_ptr; - u8 station_number; /* 0 for BSS */ + u8 station_number; /* 0 for BSS */ u8 reserved1; u16 reserved2; @@ -359,14 +346,13 @@ struct tfd_data { u8 antenna; u16 next_packet_duration; u16 next_frag_len; - u16 back_off_counter; //////txop; + u16 back_off_counter; //////txop; u8 retrylimit; u16 cwcurrent; u8 reserved3; /* 802.11 MAC Header */ - union - { + union { struct tx_tfd_24 tfd_24; struct tx_tfd_26 tfd_26; struct tx_tfd_30 tfd_30; @@ -379,8 +365,7 @@ struct tfd_data { u16 chunk_len[NUM_TFD_CHUNKS]; } __attribute__ ((packed)); -struct txrx_control_flags -{ +struct txrx_control_flags { u8 message_type; u8 rx_seq_num; u8 control_bits; @@ -390,17 +375,16 @@ struct txrx_control_flags #define TFD_SIZE 128 #define TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH (TFD_SIZE - sizeof(struct txrx_control_flags)) -struct tfd_frame -{ +struct tfd_frame { struct txrx_control_flags control_flags; union { struct tfd_data data; struct tfd_command cmd; u8 raw[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH]; } u; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -typedef void destructor_func(const void*); +typedef void destructor_func(const void *); /** * Tx Queue for DMA. Queue consists of circular buffer of @@ -408,7 +392,7 @@ typedef void destructor_func(const void*); */ struct clx2_tx_queue { struct clx2_queue q; - struct tfd_frame* bd; + struct tfd_frame *bd; struct ieee80211_txb **txb; }; @@ -423,8 +407,7 @@ struct clx2_tx_queue { #define SUP_RATE_11G_MAX_NUM_CHANNELS (12) // Used for passing to driver number of successes and failures per rate -struct rate_histogram -{ +struct rate_histogram { union { u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; @@ -475,12 +458,12 @@ struct notif_scan_complete { u8 num_channels; u8 status; u8 reserved; -} __attribute__ ((packed)); +} __attribute__ ((packed)); struct notif_frag_length { u16 frag_length; u16 reserved; -} __attribute__ ((packed)); +} __attribute__ ((packed)); struct notif_beacon_state { u32 state; @@ -543,11 +526,11 @@ struct ipw_rx_notification { struct ipw_rx_frame { u32 reserved1; - u8 parent_tsf[4]; // fw_use[0] is boolean for OUR_TSF_IS_GREATER - u8 received_channel; // The channel that this frame was received on. - // Note that for .11b this does not have to be - // the same as the channel that it was sent. - // Filled by LMAC + u8 parent_tsf[4]; // fw_use[0] is boolean for OUR_TSF_IS_GREATER + u8 received_channel; // The channel that this frame was received on. + // Note that for .11b this does not have to be + // the same as the channel that it was sent. + // Filled by LMAC u8 frameStatus; u8 rate; u8 rssi; @@ -556,10 +539,10 @@ struct ipw_rx_frame { u16 signal; u16 noise; u8 antennaAndPhy; - u8 control; // control bit should be on in bg - u8 rtscts_rate; // rate of rts or cts (in rts cts sequence rate - // is identical) - u8 rtscts_seen; // 0x1 RTS seen ; 0x2 CTS seen + u8 control; // control bit should be on in bg + u8 rtscts_rate; // rate of rts or cts (in rts cts sequence rate + // is identical) + u8 rtscts_seen; // 0x1 RTS seen ; 0x2 CTS seen u16 length; u8 data[0]; } __attribute__ ((packed)); @@ -571,8 +554,7 @@ struct ipw_rx_header { u8 reserved; } __attribute__ ((packed)); -struct ipw_rx_packet -{ +struct ipw_rx_packet { struct ipw_rx_header header; union { struct ipw_rx_frame frame; @@ -589,21 +571,20 @@ struct ipw_rx_mem_buffer { struct ipw_rx_buffer *rxb; struct sk_buff *skb; struct list_head list; -}; /* Not transferred over network, so not __attribute__ ((packed)) */ +}; /* Not transferred over network, so not __attribute__ ((packed)) */ struct ipw_rx_queue { struct ipw_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; struct ipw_rx_mem_buffer *queue[RX_QUEUE_SIZE]; - u32 processed; /* Internal index to last handled Rx packet */ - u32 read; /* Shared index to newest available Rx buffer */ - u32 write; /* Shared index to oldest written Rx packet */ - u32 free_count;/* Number of pre-allocated buffers in rx_free */ + u32 processed; /* Internal index to last handled Rx packet */ + u32 read; /* Shared index to newest available Rx buffer */ + u32 write; /* Shared index to oldest written Rx packet */ + u32 free_count; /* Number of pre-allocated buffers in rx_free */ /* Each of these lists is used as a FIFO for ipw_rx_mem_buffers */ - struct list_head rx_free; /* Own an SKBs */ - struct list_head rx_used; /* No SKB allocated */ + struct list_head rx_free; /* Own an SKBs */ + struct list_head rx_used; /* No SKB allocated */ spinlock_t lock; -}; /* Not transferred over network, so not __attribute__ ((packed)) */ - +}; /* Not transferred over network, so not __attribute__ ((packed)) */ struct alive_command_responce { u8 alive_command; @@ -627,8 +608,7 @@ struct ipw_rates { u8 rates[IPW_MAX_RATES]; } __attribute__ ((packed)); -struct command_block -{ +struct command_block { unsigned int control; u32 source_addr; u32 dest_addr; @@ -636,18 +616,16 @@ struct command_block } __attribute__ ((packed)); #define CB_NUMBER_OF_ELEMENTS_SMALL 64 -struct fw_image_desc -{ +struct fw_image_desc { unsigned long last_cb_index; unsigned long current_cb_index; struct command_block cb_list[CB_NUMBER_OF_ELEMENTS_SMALL]; - void * v_addr; + void *v_addr; unsigned long p_addr; unsigned long len; }; -struct ipw_sys_config -{ +struct ipw_sys_config { u8 bt_coexistence; u8 reserved1; u8 answer_broadcast_ssid_probe; @@ -670,8 +648,7 @@ struct ipw_sys_config u8 reserved3; } __attribute__ ((packed)); -struct ipw_multicast_addr -{ +struct ipw_multicast_addr { u8 num_of_multicast_addresses; u8 reserved[3]; u8 mac1[6]; @@ -680,8 +657,7 @@ struct ipw_multicast_addr u8 mac4[6]; } __attribute__ ((packed)); -struct ipw_wep_key -{ +struct ipw_wep_key { u8 cmd_id; u8 seq_num; u8 key_index; @@ -689,8 +665,7 @@ struct ipw_wep_key u8 key[16]; } __attribute__ ((packed)); -struct ipw_tgi_tx_key -{ +struct ipw_tgi_tx_key { u8 key_id; u8 security_type; u8 station_index; @@ -701,8 +676,7 @@ struct ipw_tgi_tx_key #define IPW_SCAN_CHANNELS 54 -struct ipw_scan_request -{ +struct ipw_scan_request { u8 scan_type; u16 dwell_time; u8 channels_list[IPW_SCAN_CHANNELS]; @@ -718,8 +692,7 @@ enum { IPW_SCAN_TYPES }; -struct ipw_scan_request_ext -{ +struct ipw_scan_request_ext { u32 full_scan_index; u8 channels_list[IPW_SCAN_CHANNELS]; u8 scan_type[IPW_SCAN_CHANNELS / 2]; @@ -740,19 +713,16 @@ extern inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan, { if (index % 2) scan->scan_type[index / 2] = - (scan->scan_type[index / 2] & 0xF0) | - (scan_type & 0x0F); + (scan->scan_type[index / 2] & 0xF0) | (scan_type & 0x0F); else scan->scan_type[index / 2] = - (scan->scan_type[index / 2] & 0x0F) | - ((scan_type & 0x0F) << 4); + (scan->scan_type[index / 2] & 0x0F) | + ((scan_type & 0x0F) << 4); } -struct ipw_associate -{ +struct ipw_associate { u8 channel; - u8 auth_type:4, - auth_key:4; + u8 auth_type:4, auth_key:4; u8 assoc_type; u8 reserved; u16 policy_support; @@ -771,8 +741,7 @@ struct ipw_associate u16 reserved2; } __attribute__ ((packed)); -struct ipw_supported_rates -{ +struct ipw_supported_rates { u8 ieee_mode; u8 num_rates; u8 purpose; @@ -780,42 +749,36 @@ struct ipw_supported_rates u8 supported_rates[IPW_MAX_RATES]; } __attribute__ ((packed)); -struct ipw_rts_threshold -{ +struct ipw_rts_threshold { u16 rts_threshold; u16 reserved; } __attribute__ ((packed)); -struct ipw_frag_threshold -{ +struct ipw_frag_threshold { u16 frag_threshold; u16 reserved; } __attribute__ ((packed)); -struct ipw_retry_limit -{ +struct ipw_retry_limit { u8 short_retry_limit; u8 long_retry_limit; u16 reserved; } __attribute__ ((packed)); -struct ipw_dino_config -{ +struct ipw_dino_config { u32 dino_config_addr; u16 dino_config_size; u8 dino_response; u8 reserved; } __attribute__ ((packed)); -struct ipw_aironet_info -{ +struct ipw_aironet_info { u8 id; u8 length; u16 reserved; } __attribute__ ((packed)); -struct ipw_rx_key -{ +struct ipw_rx_key { u8 station_index; u8 key_type; u8 key_id; @@ -826,23 +789,20 @@ struct ipw_rx_key u8 reserved; } __attribute__ ((packed)); -struct ipw_country_channel_info -{ +struct ipw_country_channel_info { u8 first_channel; u8 no_channels; s8 max_tx_power; } __attribute__ ((packed)); -struct ipw_country_info -{ +struct ipw_country_info { u8 id; u8 length; u8 country_str[3]; struct ipw_country_channel_info groups[7]; } __attribute__ ((packed)); -struct ipw_channel_tx_power -{ +struct ipw_channel_tx_power { u8 channel_number; s8 tx_power; } __attribute__ ((packed)); @@ -852,15 +812,13 @@ struct ipw_channel_tx_power #define MAX_A_CHANNELS 37 #define MAX_B_CHANNELS 14 -struct ipw_tx_power -{ +struct ipw_tx_power { u8 num_channels; u8 ieee_mode; struct ipw_channel_tx_power channels_tx_power[MAX_A_CHANNELS]; } __attribute__ ((packed)); -struct ipw_qos_parameters -{ +struct ipw_qos_parameters { u16 cw_min[4]; u16 cw_max[4]; u8 aifs[4]; @@ -868,15 +826,13 @@ struct ipw_qos_parameters u16 tx_op_limit[4]; } __attribute__ ((packed)); -struct ipw_rsn_capabilities -{ +struct ipw_rsn_capabilities { u8 id; u8 length; u16 version; } __attribute__ ((packed)); -struct ipw_sensitivity_calib -{ +struct ipw_sensitivity_calib { u16 beacon_rssi_raw; u16 reserved; } __attribute__ ((packed)); @@ -895,10 +851,11 @@ struct ipw_sensitivity_calib * - \a param filled with status parameters. */ struct ipw_cmd { - u32 cmd; /**< Host command */ - u32 status; /**< Status */ - u32 status_len; /**< How many 32 bit parameters in the status */ - u32 len; /**< incoming parameters length, bytes */ + u32 cmd; /**< Host command */ + u32 status;/**< Status */ + u32 status_len; + /**< How many 32 bit parameters in the status */ + u32 len; /**< incoming parameters length, bytes */ /** * command parameters. * There should be enough space for incoming and @@ -906,10 +863,10 @@ struct ipw_cmd { * Incoming parameters listed 1-st, followed by outcoming params. * nParams=(len+3)/4+status_len */ - u32 param[0]; + u32 param[0]; } __attribute__ ((packed)); -#define STATUS_HCMD_ACTIVE (1<<0) /**< host command in progress */ +#define STATUS_HCMD_ACTIVE (1<<0) /**< host command in progress */ #define STATUS_INT_ENABLED (1<<1) #define STATUS_RF_KILL_HW (1<<2) @@ -932,15 +889,15 @@ struct ipw_cmd { #define STATUS_SCANNING (1<<21) #define STATUS_SCAN_ABORTING (1<<22) -#define STATUS_INDIRECT_BYTE (1<<28) /* sysfs entry configured for access */ -#define STATUS_INDIRECT_DWORD (1<<29) /* sysfs entry configured for access */ -#define STATUS_DIRECT_DWORD (1<<30) /* sysfs entry configured for access */ +#define STATUS_INDIRECT_BYTE (1<<28) /* sysfs entry configured for access */ +#define STATUS_INDIRECT_DWORD (1<<29) /* sysfs entry configured for access */ +#define STATUS_DIRECT_DWORD (1<<30) /* sysfs entry configured for access */ -#define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */ +#define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */ -#define CFG_STATIC_CHANNEL (1<<0) /* Restrict assoc. to single channel */ -#define CFG_STATIC_ESSID (1<<1) /* Restrict assoc. to single SSID */ -#define CFG_STATIC_BSSID (1<<2) /* Restrict assoc. to single BSSID */ +#define CFG_STATIC_CHANNEL (1<<0) /* Restrict assoc. to single channel */ +#define CFG_STATIC_ESSID (1<<1) /* Restrict assoc. to single SSID */ +#define CFG_STATIC_BSSID (1<<2) /* Restrict assoc. to single BSSID */ #define CFG_CUSTOM_MAC (1<<3) #define CFG_PREAMBLE (1<<4) #define CFG_ADHOC_PERSIST (1<<5) @@ -948,8 +905,8 @@ struct ipw_cmd { #define CFG_FIXED_RATE (1<<7) #define CFG_ADHOC_CREATE (1<<8) -#define CAP_SHARED_KEY (1<<0) /* Off = OPEN */ -#define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */ +#define CAP_SHARED_KEY (1<<0) /* Off = OPEN */ +#define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */ #define MAX_STATIONS 32 #define IPW_INVALID_STATION (0xff) @@ -989,8 +946,8 @@ struct ipw_priv { /* result of ucode download */ struct alive_command_responce dino_alive; - wait_queue_head_t wait_command_queue; - wait_queue_head_t wait_state; + wait_queue_head_t wait_command_queue; + wait_queue_head_t wait_state; /* Rx and Tx DMA processing queues */ struct ipw_rx_queue *rxq; @@ -1006,9 +963,9 @@ struct ipw_priv { struct average average_rssi; struct average average_noise; u32 port_type; - int rx_bufs_min; /**< minimum number of bufs in Rx queue */ - int rx_pend_max; /**< maximum pending buffers for one IRQ */ - u32 hcmd_seq; /**< sequence number for hcmd */ + int rx_bufs_min; /**< minimum number of bufs in Rx queue */ + int rx_pend_max; /**< maximum pending buffers for one IRQ */ + u32 hcmd_seq; /**< sequence number for hcmd */ u32 missed_beacon_threshold; u32 roaming_threshold; @@ -1017,17 +974,17 @@ struct ipw_priv { unsigned long ts_scan_abort; struct ipw_supported_rates rates; - struct ipw_rates phy[3]; /**< PHY restrictions, per band */ - struct ipw_rates supp; /**< software defined */ - struct ipw_rates extended; /**< use for corresp. IE, AP only */ + struct ipw_rates phy[3]; /**< PHY restrictions, per band */ + struct ipw_rates supp; /**< software defined */ + struct ipw_rates extended; /**< use for corresp. IE, AP only */ struct notif_link_deterioration last_link_deterioration; /** for statistics */ - struct ipw_cmd* hcmd; /**< host command currently executed */ + struct ipw_cmd *hcmd; /**< host command currently executed */ wait_queue_head_t hcmd_wq; /**< host command waits for execution */ - u32 tsf_bcn[2]; /**< TSF from latest beacon */ + u32 tsf_bcn[2]; /**< TSF from latest beacon */ - struct notif_calibration calib; /**< last calibration */ + struct notif_calibration calib; /**< last calibration */ /* ordinal interface with firmware */ u32 table0_addr; @@ -1067,8 +1024,8 @@ struct ipw_priv { u32 tx_packets; u32 quality; - /* eeprom */ - u8 eeprom[0x100]; /* 256 bytes of eeprom */ + /* eeprom */ + u8 eeprom[0x100]; /* 256 bytes of eeprom */ int eeprom_delay; struct iw_statistics wstats; @@ -1091,7 +1048,6 @@ struct ipw_priv { struct tasklet_struct irq_tasklet; - #define IPW_2200BG 1 #define IPW_2915ABG 2 u8 adapter; @@ -1114,7 +1070,6 @@ struct ipw_priv { u32 indirect_byte; }; /*ipw_priv */ - /* debug macros */ #ifdef CONFIG_IPW_DEBUG @@ -1170,7 +1125,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_DL_RF_KILL (1<<17) #define IPW_DL_FW_ERRORS (1<<18) - #define IPW_DL_ORD (1<<20) #define IPW_DL_FRAG (1<<21) @@ -1184,7 +1138,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_DL_STATS (1<<29) - #define IPW_ERROR(f, a...) printk(KERN_ERR DRV_NAME ": " f, ## a) #define IPW_WARNING(f, a...) printk(KERN_WARNING DRV_NAME ": " f, ## a) #define IPW_DEBUG_INFO(f, a...) IPW_DEBUG(IPW_DL_INFO, f, ## a) @@ -1253,12 +1206,12 @@ do { if (ipw_debug_level & (level)) \ /* * RESET Register Bit Indexes */ -#define CBD_RESET_REG_PRINCETON_RESET 0x00000001 /* Bit 0 (LSB) */ -#define CX2_RESET_REG_SW_RESET 0x00000080 /* Bit 7 */ -#define CX2_RESET_REG_MASTER_DISABLED 0x00000100 /* Bit 8 */ -#define CX2_RESET_REG_STOP_MASTER 0x00000200 /* Bit 9 */ -#define CX2_ARC_KESHET_CONFIG 0x08000000 /* Bit 27 */ -#define CX2_START_STANDBY 0x00000004 /* Bit 2 */ +#define CBD_RESET_REG_PRINCETON_RESET 0x00000001 /* Bit 0 (LSB) */ +#define CX2_RESET_REG_SW_RESET 0x00000080 /* Bit 7 */ +#define CX2_RESET_REG_MASTER_DISABLED 0x00000100 /* Bit 8 */ +#define CX2_RESET_REG_STOP_MASTER 0x00000200 /* Bit 9 */ +#define CX2_ARC_KESHET_CONFIG 0x08000000 /* Bit 27 */ +#define CX2_START_STANDBY 0x00000004 /* Bit 2 */ #define CX2_CSR_CIS_UPPER_BOUND 0x00000200 #define CX2_DOMAIN_0_END 0x1000 @@ -1289,14 +1242,12 @@ do { if (ipw_debug_level & (level)) \ #define CB_SRC_SIZE_LONG 0x00200000 #define CB_DEST_SIZE_LONG 0x00020000 - /* DMA DEFINES */ #define DMA_CONTROL_SMALL_CB_CONST_VALUE 0x00540000 #define DMA_CB_STOP_AND_ABORT 0x00000C00 #define DMA_CB_START 0x00000100 - #define CX2_SHARED_SRAM_SIZE 0x00030000 #define CX2_SHARED_SRAM_DMA_CONTROL 0x00027000 #define CB_MAX_LENGTH 0x1FFF @@ -1304,7 +1255,6 @@ do { if (ipw_debug_level & (level)) \ #define CX2_HOST_EEPROM_DATA_SRAM_SIZE 0xA18 #define CX2_EEPROM_IMAGE_SIZE 0x100 - /* DMA defs */ #define CX2_DMA_I_CURRENT_CB 0x003000D0 #define CX2_DMA_O_CURRENT_CB 0x003000D4 @@ -1356,7 +1306,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_WHO_IS_AWAKE (CX2_SHARED_LOWER_BOUND + 0xB14) #define IPW_DURING_ATIM_WINDOW (CX2_SHARED_LOWER_BOUND + 0xB18) - #define MSB 1 #define LSB 0 #define WORD_TO_BYTE(_word) ((_word) * sizeof(u16)) @@ -1365,16 +1314,16 @@ do { if (ipw_debug_level & (level)) \ ( WORD_TO_BYTE(_wordoffset) + (_byteoffset) ) /* EEPROM access by BYTE */ -#define EEPROM_PME_CAPABILITY (GET_EEPROM_ADDR(0x09,MSB)) /* 1 byte */ -#define EEPROM_MAC_ADDRESS (GET_EEPROM_ADDR(0x21,LSB)) /* 6 byte */ -#define EEPROM_VERSION (GET_EEPROM_ADDR(0x24,MSB)) /* 1 byte */ -#define EEPROM_NIC_TYPE (GET_EEPROM_ADDR(0x25,LSB)) /* 1 byte */ -#define EEPROM_SKU_CAPABILITY (GET_EEPROM_ADDR(0x25,MSB)) /* 1 byte */ -#define EEPROM_COUNTRY_CODE (GET_EEPROM_ADDR(0x26,LSB)) /* 3 bytes */ -#define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB)) /* 2 bytes */ -#define EEPROM_IBSS_CHANNELS_A (GET_EEPROM_ADDR(0x29,MSB)) /* 5 bytes */ -#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */ -#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */ +#define EEPROM_PME_CAPABILITY (GET_EEPROM_ADDR(0x09,MSB)) /* 1 byte */ +#define EEPROM_MAC_ADDRESS (GET_EEPROM_ADDR(0x21,LSB)) /* 6 byte */ +#define EEPROM_VERSION (GET_EEPROM_ADDR(0x24,MSB)) /* 1 byte */ +#define EEPROM_NIC_TYPE (GET_EEPROM_ADDR(0x25,LSB)) /* 1 byte */ +#define EEPROM_SKU_CAPABILITY (GET_EEPROM_ADDR(0x25,MSB)) /* 1 byte */ +#define EEPROM_COUNTRY_CODE (GET_EEPROM_ADDR(0x26,LSB)) /* 3 bytes */ +#define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB)) /* 2 bytes */ +#define EEPROM_IBSS_CHANNELS_A (GET_EEPROM_ADDR(0x29,MSB)) /* 5 bytes */ +#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */ +#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */ /* NIC type as found in the one byte EEPROM_NIC_TYPE offset*/ #define EEPROM_NIC_TYPE_STANDARD 0 @@ -1479,7 +1428,6 @@ enum { #define IPW_RATE_CAPABILITIES 1 #define IPW_RATE_CONNECT 0 - /* * Rate values and masks */ @@ -1524,12 +1472,6 @@ enum { IPW_ORD_STAT_TX_DIR_DATA_B_11, /* Hole */ - - - - - - IPW_ORD_STAT_TX_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 19, IPW_ORD_STAT_TX_DIR_DATA_G_2, IPW_ORD_STAT_TX_DIR_DATA_G_5_5, @@ -1549,12 +1491,6 @@ enum { IPW_ORD_STAT_TX_NON_DIR_DATA_B_11, /* Hole */ - - - - - - IPW_ORD_STAT_TX_NON_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 44, IPW_ORD_STAT_TX_NON_DIR_DATA_G_2, IPW_ORD_STAT_TX_NON_DIR_DATA_G_5_5, @@ -1685,7 +1621,7 @@ struct host_cmd { #define CFG_BT_COEXISTENCE_WME_OVER_BT 0x08 #define CFG_BT_COEXISTENCE_OOB 0x10 #define CFG_BT_COEXISTENCE_MAX 0xFF -#define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM*/ +#define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM */ #define CFG_CTS_TO_ITSELF_ENABLED_MIN 0x0 #define CFG_CTS_TO_ITSELF_ENABLED_MAX 0x1 @@ -1727,11 +1663,11 @@ static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr) fc = le16_to_cpu(hdr->frame_ctl); /* - * Function ToDS FromDS - * IBSS 0 0 - * To AP 1 0 - * From AP 0 1 - * WDS (bridge) 1 1 + * Function ToDS FromDS + * IBSS 0 0 + * To AP 1 0 + * From AP 0 1 + * WDS (bridge) 1 1 * * Only WDS frames use Address4 among them. --YZ */ @@ -1741,4 +1677,4 @@ static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr) return retval; } -#endif /* __ipw2200_h__ */ +#endif /* __ipw2200_h__ */ diff --git a/net/ieee80211/ieee80211_crypt.c b/net/ieee80211/ieee80211_crypt.c index 05a6f2f298..61a9d92e45 100644 --- a/net/ieee80211/ieee80211_crypt.c +++ b/net/ieee80211/ieee80211_crypt.c @@ -30,7 +30,6 @@ struct ieee80211_crypto_alg { struct ieee80211_crypto_ops *ops; }; - struct ieee80211_crypto { struct list_head algs; spinlock_t lock; @@ -38,8 +37,7 @@ struct ieee80211_crypto { static struct ieee80211_crypto *hcrypt; -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, - int force) +void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force) { struct list_head *ptr, *n; struct ieee80211_crypt_data *entry; @@ -140,7 +138,7 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) spin_lock_irqsave(&hcrypt->lock, flags); for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + (struct ieee80211_crypto_alg *)ptr; if (alg->ops == ops) { list_del(&alg->list); del_alg = alg; @@ -158,8 +156,7 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops) return del_alg ? 0 : -1; } - -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) +struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name) { unsigned long flags; struct list_head *ptr; @@ -171,7 +168,7 @@ struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) spin_lock_irqsave(&hcrypt->lock, flags); for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) { struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + (struct ieee80211_crypto_alg *)ptr; if (strcmp(alg->ops->name, name) == 0) { found_alg = alg; break; @@ -185,9 +182,13 @@ struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name) return NULL; } - -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; } -static void ieee80211_crypt_null_deinit(void *priv) {} +static void *ieee80211_crypt_null_init(int keyidx) +{ + return (void *)1; +} +static void ieee80211_crypt_null_deinit(void *priv) +{ +} static struct ieee80211_crypto_ops ieee80211_crypt_null = { .name = "NULL", @@ -204,7 +205,6 @@ static struct ieee80211_crypto_ops ieee80211_crypt_null = { .owner = THIS_MODULE, }; - static int __init ieee80211_crypto_init(void) { int ret = -ENOMEM; @@ -222,11 +222,10 @@ static int __init ieee80211_crypto_init(void) kfree(hcrypt); hcrypt = NULL; } -out: + out: return ret; } - static void __exit ieee80211_crypto_deinit(void) { struct list_head *ptr, *n; @@ -237,7 +236,7 @@ static void __exit ieee80211_crypto_deinit(void) for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs; ptr = n, n = ptr->next) { struct ieee80211_crypto_alg *alg = - (struct ieee80211_crypto_alg *) ptr; + (struct ieee80211_crypto_alg *)ptr; list_del(ptr); printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm " "'%s' (deinit)\n", alg->ops->name); diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c index 11d15573b2..8fc13f4597 100644 --- a/net/ieee80211/ieee80211_crypt_ccmp.c +++ b/net/ieee80211/ieee80211_crypt_ccmp.c @@ -24,7 +24,6 @@ #include - #include #include @@ -55,7 +54,7 @@ struct ieee80211_ccmp_data { /* scratch buffers for virt_to_page() (crypto API) */ u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], - tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN]; + tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN]; u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; @@ -75,7 +74,7 @@ static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); } -static void * ieee80211_ccmp_init(int key_idx) +static void *ieee80211_ccmp_init(int key_idx) { struct ieee80211_ccmp_data *priv; @@ -94,7 +93,7 @@ static void * ieee80211_ccmp_init(int key_idx) return priv; -fail: + fail: if (priv) { if (priv->tfm) crypto_free_tfm(priv->tfm); @@ -104,7 +103,6 @@ fail: return NULL; } - static void ieee80211_ccmp_deinit(void *priv) { struct ieee80211_ccmp_data *_priv = priv; @@ -113,19 +111,16 @@ static void ieee80211_ccmp_deinit(void *priv) kfree(priv); } - -static inline void xor_block(u8 *b, u8 *a, size_t len) +static inline void xor_block(u8 * b, u8 * a, size_t len) { int i; for (i = 0; i < len; i++) b[i] ^= a[i]; } - static void ccmp_init_blocks(struct crypto_tfm *tfm, struct ieee80211_hdr *hdr, - u8 *pn, size_t dlen, u8 *b0, u8 *auth, - u8 *s0) + u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0) { u8 *pos, qc = 0; size_t aad_len; @@ -142,7 +137,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, if (a4_included) aad_len += 6; if (qc_included) { - pos = (u8 *) &hdr->addr4; + pos = (u8 *) & hdr->addr4; if (a4_included) pos += 6; qc = *pos & 0x0f; @@ -169,14 +164,14 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, * QC (if present) */ pos = (u8 *) hdr; - aad[0] = 0; /* aad_len >> 8 */ + aad[0] = 0; /* aad_len >> 8 */ aad[1] = aad_len & 0xff; aad[2] = pos[0] & 0x8f; aad[3] = pos[1] & 0xc7; memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN); - pos = (u8 *) &hdr->seq_ctl; + pos = (u8 *) & hdr->seq_ctl; aad[22] = pos[0] & 0x0f; - aad[23] = 0; /* all bits masked */ + aad[23] = 0; /* all bits masked */ memset(aad + 24, 0, 8); if (a4_included) memcpy(aad + 24, hdr->addr4, ETH_ALEN); @@ -196,7 +191,6 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, ieee80211_ccmp_aes_encrypt(tfm, b0, s0); } - static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; @@ -209,8 +203,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 *s0 = key->tx_s0; if (skb_headroom(skb) < CCMP_HDR_LEN || - skb_tailroom(skb) < CCMP_MIC_LEN || - skb->len < hdr_len) + skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) return -1; data_len = skb->len - hdr_len; @@ -230,13 +223,13 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = key->tx_pn[5]; *pos++ = key->tx_pn[4]; *pos++ = 0; - *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */; + *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */ ; *pos++ = key->tx_pn[3]; *pos++ = key->tx_pn[2]; *pos++ = key->tx_pn[1]; *pos++ = key->tx_pn[0]; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; @@ -261,7 +254,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) return 0; } - static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; @@ -280,7 +272,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -1; } - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { @@ -364,8 +356,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return keyidx; } - -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_set_key(void *key, int len, u8 * seq, void *priv) { struct ieee80211_ccmp_data *data = priv; int keyidx; @@ -395,8 +386,7 @@ static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) return 0; } - -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_ccmp_get_key(void *key, int len, u8 * seq, void *priv) { struct ieee80211_ccmp_data *data = priv; @@ -419,8 +409,7 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) return CCMP_TK_LEN; } - -static char * ieee80211_ccmp_print_stats(char *p, void *priv) +static char *ieee80211_ccmp_print_stats(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " @@ -436,7 +425,6 @@ static char * ieee80211_ccmp_print_stats(char *p, void *priv) return p; } - static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { .name = "CCMP", .init = ieee80211_ccmp_init, @@ -453,18 +441,15 @@ static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { .owner = THIS_MODULE, }; - static int __init ieee80211_crypto_ccmp_init(void) { return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp); } - static void __exit ieee80211_crypto_ccmp_exit(void) { ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp); } - module_init(ieee80211_crypto_ccmp_init); module_exit(ieee80211_crypto_ccmp_exit); diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c index f91d92c6df..d4f9164be1 100644 --- a/net/ieee80211/ieee80211_crypt_tkip.c +++ b/net/ieee80211/ieee80211_crypt_tkip.c @@ -23,7 +23,6 @@ #include - #include #include #include @@ -62,7 +61,7 @@ struct ieee80211_tkip_data { u8 rx_hdr[16], tx_hdr[16]; }; -static void * ieee80211_tkip_init(int key_idx) +static void *ieee80211_tkip_init(int key_idx) { struct ieee80211_tkip_data *priv; @@ -88,7 +87,7 @@ static void * ieee80211_tkip_init(int key_idx) return priv; -fail: + fail: if (priv) { if (priv->tfm_michael) crypto_free_tfm(priv->tfm_michael); @@ -100,7 +99,6 @@ fail: return NULL; } - static void ieee80211_tkip_deinit(void *priv) { struct ieee80211_tkip_data *_priv = priv; @@ -111,51 +109,42 @@ static void ieee80211_tkip_deinit(void *priv) kfree(priv); } - static inline u16 RotR1(u16 val) { return (val >> 1) | (val << 15); } - static inline u8 Lo8(u16 val) { return val & 0xff; } - static inline u8 Hi8(u16 val) { return val >> 8; } - static inline u16 Lo16(u32 val) { return val & 0xffff; } - static inline u16 Hi16(u32 val) { return val >> 16; } - static inline u16 Mk16(u8 hi, u8 lo) { return lo | (((u16) hi) << 8); } - -static inline u16 Mk16_le(u16 *v) +static inline u16 Mk16_le(u16 * v) { return le16_to_cpu(*v); } - -static const u16 Sbox[256] = -{ +static const u16 Sbox[256] = { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, @@ -190,17 +179,16 @@ static const u16 Sbox[256] = 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, }; - static inline u16 _S_(u16 v) { u16 t = Sbox[Hi8(v)]; return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8)); } - #define PHASE1_LOOP_COUNT 8 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) +static void tkip_mixing_phase1(u16 * TTAK, const u8 * TK, const u8 * TA, + u32 IV32) { int i, j; @@ -221,13 +209,12 @@ static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) } } - -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, +static void tkip_mixing_phase2(u8 * WEPSeed, const u8 * TK, const u16 * TTAK, u16 IV16) { /* Make temporary area overlap WEP seed so that the final copy can be * avoided on little endian hosts. */ - u16 *PPK = (u16 *) &WEPSeed[4]; + u16 *PPK = (u16 *) & WEPSeed[4]; /* Step 1 - make copy of TTAK and bring in TSC */ PPK[0] = TTAK[0]; @@ -238,15 +225,15 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, PPK[5] = TTAK[4] + IV16; /* Step 2 - 96-bit bijective mixing using S-box */ - PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0])); - PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2])); - PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4])); - PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6])); - PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8])); - PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10])); - - PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12])); - PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14])); + PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) & TK[0])); + PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) & TK[2])); + PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) & TK[4])); + PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) & TK[6])); + PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) & TK[8])); + PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) & TK[10])); + + PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) & TK[12])); + PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) & TK[14])); PPK[2] += RotR1(PPK[1]); PPK[3] += RotR1(PPK[2]); PPK[4] += RotR1(PPK[3]); @@ -257,7 +244,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, WEPSeed[0] = Hi8(IV16); WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F; WEPSeed[2] = Lo8(IV16); - WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1); + WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) & TK[0])) >> 1); #ifdef __BIG_ENDIAN { @@ -281,7 +268,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) skb->len < hdr_len) return -1; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; if (!tkey->tx_phase1_done) { tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, tkey->tx_iv32); @@ -298,7 +285,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = rc4key[0]; *pos++ = rc4key[1]; *pos++ = rc4key[2]; - *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */; + *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ; *pos++ = tkey->tx_iv32 & 0xff; *pos++ = (tkey->tx_iv32 >> 8) & 0xff; *pos++ = (tkey->tx_iv32 >> 16) & 0xff; @@ -341,7 +328,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (skb->len < hdr_len + 8 + 4) return -1; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { @@ -427,9 +414,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return keyidx; } - -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, - u8 *data, size_t data_len, u8 *mic) +static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr, + u8 * data, size_t data_len, u8 * mic) { struct scatterlist sg[2]; @@ -453,37 +439,37 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, return 0; } -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) +static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) { struct ieee80211_hdr *hdr11; - hdr11 = (struct ieee80211_hdr *) skb->data; + hdr11 = (struct ieee80211_hdr *)skb->data; switch (le16_to_cpu(hdr11->frame_ctl) & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_TODS: - memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ + memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ + memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ break; case IEEE80211_FCTL_FROMDS: - memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ + memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ + memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ break; case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: - memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ + memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ + memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ break; case 0: - memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ - memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ + memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ + memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ break; } - hdr[12] = 0; /* priority */ - hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */ + hdr[12] = 0; /* priority */ + hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */ } - -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) +static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, + void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 *pos; @@ -504,11 +490,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri return 0; } - #if WIRELESS_EXT >= 18 static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr *hdr, - int keyidx) + struct ieee80211_hdr *hdr, int keyidx) { union iwreq_data wrqu; struct iw_michaelmicfailure ev; @@ -524,12 +508,11 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = sizeof(ev); - wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); + wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); } #elif WIRELESS_EXT >= 15 static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr *hdr, - int keyidx) + struct ieee80211_hdr *hdr, int keyidx) { union iwreq_data wrqu; char buf[128]; @@ -542,17 +525,16 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, wrqu.data.length = strlen(buf); wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); } -#else /* WIRELESS_EXT >= 15 */ +#else /* WIRELESS_EXT >= 15 */ static inline void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr *hdr, - int keyidx) + struct ieee80211_hdr *hdr, + int keyidx) { } -#endif /* WIRELESS_EXT >= 15 */ - +#endif /* WIRELESS_EXT >= 15 */ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv) + int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 mic[8]; @@ -566,7 +548,7 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { struct ieee80211_hdr *hdr; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from " MAC_FMT " keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), @@ -587,8 +569,7 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, return 0; } - -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; int keyidx; @@ -603,10 +584,10 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) if (len == TKIP_KEY_LEN) { memcpy(tkey->key, key, TKIP_KEY_LEN); tkey->key_set = 1; - tkey->tx_iv16 = 1; /* TSC is initialized to 1 */ + tkey->tx_iv16 = 1; /* TSC is initialized to 1 */ if (seq) { tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) | - (seq[3] << 8) | seq[2]; + (seq[3] << 8) | seq[2]; tkey->rx_iv16 = (seq[1] << 8) | seq[0]; } } else if (len == 0) @@ -617,8 +598,7 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) return 0; } - -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) +static int ieee80211_tkip_get_key(void *key, int len, u8 * seq, void *priv) { struct ieee80211_tkip_data *tkey = priv; @@ -647,8 +627,7 @@ static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) return TKIP_KEY_LEN; } - -static char * ieee80211_tkip_print_stats(char *p, void *priv) +static char *ieee80211_tkip_print_stats(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -674,7 +653,6 @@ static char * ieee80211_tkip_print_stats(char *p, void *priv) return p; } - static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { .name = "TKIP", .init = ieee80211_tkip_init, @@ -686,23 +664,20 @@ static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { .set_key = ieee80211_tkip_set_key, .get_key = ieee80211_tkip_get_key, .print_stats = ieee80211_tkip_print_stats, - .extra_prefix_len = 4 + 4, /* IV + ExtIV */ - .extra_postfix_len = 8 + 4, /* MIC + ICV */ - .owner = THIS_MODULE, + .extra_prefix_len = 4 + 4, /* IV + ExtIV */ + .extra_postfix_len = 8 + 4, /* MIC + ICV */ + .owner = THIS_MODULE, }; - static int __init ieee80211_crypto_tkip_init(void) { return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); } - static void __exit ieee80211_crypto_tkip_exit(void) { ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); } - module_init(ieee80211_crypto_tkip_init); module_exit(ieee80211_crypto_tkip_exit); diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c index bec1d3470d..b4d2514a09 100644 --- a/net/ieee80211/ieee80211_crypt_wep.c +++ b/net/ieee80211/ieee80211_crypt_wep.c @@ -20,7 +20,6 @@ #include - #include #include #include @@ -29,7 +28,6 @@ MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); - struct prism2_wep_data { u32 iv; #define WEP_KEY_LEN 13 @@ -39,8 +37,7 @@ struct prism2_wep_data { struct crypto_tfm *tfm; }; - -static void * prism2_wep_init(int keyidx) +static void *prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; @@ -62,7 +59,7 @@ static void * prism2_wep_init(int keyidx) return priv; -fail: + fail: if (priv) { if (priv->tfm) crypto_free_tfm(priv->tfm); @@ -71,7 +68,6 @@ fail: return NULL; } - static void prism2_wep_deinit(void *priv) { struct prism2_wep_data *_priv = priv; @@ -80,7 +76,6 @@ static void prism2_wep_deinit(void *priv) kfree(priv); } - /* Perform WEP encryption on given skb that has at least 4 bytes of headroom * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted, * so the payload length increases with 8 bytes. @@ -143,7 +138,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) return 0; } - /* Perform WEP decryption on given buffer. Buffer includes whole WEP part of * the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. @@ -202,8 +196,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return 0; } - -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_set_key(void *key, int len, u8 * seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -216,8 +209,7 @@ static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) return 0; } - -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) +static int prism2_wep_get_key(void *key, int len, u8 * seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -229,16 +221,13 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) return wep->key_len; } - -static char * prism2_wep_print_stats(char *p, void *priv) +static char *prism2_wep_print_stats(char *p, void *priv) { struct prism2_wep_data *wep = priv; - p += sprintf(p, "key[%d] alg=WEP len=%d\n", - wep->key_idx, wep->key_len); + p += sprintf(p, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len); return p; } - static struct ieee80211_crypto_ops ieee80211_crypt_wep = { .name = "WEP", .init = prism2_wep_init, @@ -250,23 +239,20 @@ static struct ieee80211_crypto_ops ieee80211_crypt_wep = { .set_key = prism2_wep_set_key, .get_key = prism2_wep_get_key, .print_stats = prism2_wep_print_stats, - .extra_prefix_len = 4, /* IV */ - .extra_postfix_len = 4, /* ICV */ + .extra_prefix_len = 4, /* IV */ + .extra_postfix_len = 4, /* ICV */ .owner = THIS_MODULE, }; - static int __init ieee80211_crypto_wep_init(void) { return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); } - static void __exit ieee80211_crypto_wep_exit(void) { ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); } - module_init(ieee80211_crypto_wep_init); module_exit(ieee80211_crypto_wep_exit); diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c index 553acb2e93..03a47343dd 100644 --- a/net/ieee80211/ieee80211_module.c +++ b/net/ieee80211/ieee80211_module.c @@ -54,7 +54,8 @@ #include MODULE_DESCRIPTION("802.11 data/management/control stack"); -MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation "); +MODULE_AUTHOR + ("Copyright (C) 2004 Intel Corporation "); MODULE_LICENSE("GPL"); #define DRV_NAME "ieee80211" @@ -64,9 +65,9 @@ static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) if (ieee->networks) return 0; - ieee->networks = kmalloc( - MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), - GFP_KERNEL); + ieee->networks = + kmalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), + GFP_KERNEL); if (!ieee->networks) { printk(KERN_WARNING "%s: Out of memory allocating beacons\n", ieee->dev->name); @@ -94,10 +95,10 @@ static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee) INIT_LIST_HEAD(&ieee->network_free_list); INIT_LIST_HEAD(&ieee->network_list); for (i = 0; i < MAX_NETWORK_COUNT; i++) - list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); + list_add_tail(&ieee->networks[i].list, + &ieee->network_free_list); } - struct net_device *alloc_ieee80211(int sizeof_priv) { struct ieee80211_device *ieee; @@ -118,8 +119,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv) err = ieee80211_networks_allocate(ieee); if (err) { - IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", - err); + IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } ieee80211_networks_initialize(ieee); @@ -132,7 +132,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv) /* Default to enabling full open WEP with host based encrypt/decrypt */ ieee->host_encrypt = 1; ieee->host_decrypt = 1; - ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ + ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ INIT_LIST_HEAD(&ieee->crypt_deinit_list); init_timer(&ieee->crypt_deinit_timer); @@ -141,21 +141,20 @@ struct net_device *alloc_ieee80211(int sizeof_priv) spin_lock_init(&ieee->lock); - ieee->wpa_enabled = 0; - ieee->tkip_countermeasures = 0; - ieee->drop_unencrypted = 0; - ieee->privacy_invoked = 0; - ieee->ieee802_1x = 1; + ieee->wpa_enabled = 0; + ieee->tkip_countermeasures = 0; + ieee->drop_unencrypted = 0; + ieee->privacy_invoked = 0; + ieee->ieee802_1x = 1; return dev; - failed: + failed: if (dev) free_netdev(dev); return NULL; } - void free_ieee80211(struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); @@ -193,7 +192,7 @@ static int show_debug_level(char *page, char **start, off_t offset, return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char __user *buffer, +static int store_debug_level(struct file *file, const char __user * buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; @@ -264,13 +263,12 @@ static void __exit ieee80211_exit(void) module_param(debug, int, 0444); MODULE_PARM_DESC(debug, "debug output mask"); - module_exit(ieee80211_exit); module_init(ieee80211_init); #endif - -const char *escape_essid(const char *essid, u8 essid_len) { +const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; const char *s = essid; char *d = escaped; @@ -280,7 +278,7 @@ const char *escape_essid(const char *essid, u8 essid_len) { return escaped; } - essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE); + essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); while (essid_len--) { if (*s == '\0') { *d++ = '\\'; diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c index a5905f53ae..f7dcd85413 100644 --- a/net/ieee80211/ieee80211_rx.c +++ b/net/ieee80211/ieee80211_rx.c @@ -52,11 +52,14 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, netif_rx(skb); } - /* Called only as a tasklet (software IRQ) */ -static struct ieee80211_frag_entry * -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, - unsigned int frag, u8 *src, u8 *dst) +static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct + ieee80211_device + *ieee, + unsigned int seq, + unsigned int frag, + u8 * src, + u8 * dst) { struct ieee80211_frag_entry *entry; int i; @@ -65,10 +68,9 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, entry = &ieee->frag_cache[i]; if (entry->skb != NULL && time_after(jiffies, entry->first_frag_time + 2 * HZ)) { - IEEE80211_DEBUG_FRAG( - "expiring fragment cache entry " - "seq=%u last_frag=%u\n", - entry->seq, entry->last_frag); + IEEE80211_DEBUG_FRAG("expiring fragment cache entry " + "seq=%u last_frag=%u\n", + entry->seq, entry->last_frag); dev_kfree_skb_any(entry->skb); entry->skb = NULL; } @@ -84,9 +86,8 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, } /* Called only as a tasklet (software IRQ) */ -static struct sk_buff * -ieee80211_frag_cache_get(struct ieee80211_device *ieee, - struct ieee80211_hdr *hdr) +static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee, + struct ieee80211_hdr *hdr) { struct sk_buff *skb = NULL; u16 sc; @@ -101,9 +102,9 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, /* Reserve enough space to fit maximum frame length */ skb = dev_alloc_skb(ieee->dev->mtu + sizeof(struct ieee80211_hdr) + - 8 /* LLC */ + - 2 /* alignment */ + - 8 /* WEP */ + ETH_ALEN /* WDS */); + 8 /* LLC */ + + 2 /* alignment */ + + 8 /* WEP */ + ETH_ALEN /* WDS */ ); if (skb == NULL) return NULL; @@ -135,7 +136,6 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, return skb; } - /* Called only as a tasklet (software IRQ) */ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, struct ieee80211_hdr *hdr) @@ -151,9 +151,8 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, hdr->addr1); if (entry == NULL) { - IEEE80211_DEBUG_FRAG( - "could not invalidate fragment cache " - "entry (seq=%u)\n", seq); + IEEE80211_DEBUG_FRAG("could not invalidate fragment cache " + "entry (seq=%u)\n", seq); return -1; } @@ -161,7 +160,6 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, return 0; } - #ifdef NOT_YET /* ieee80211_rx_frame_mgtmt * @@ -201,7 +199,7 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, return 0; } - if (ieee->iw_mode == IW_MODE_MASTER) { + if (ieee->iw_mode == IW_MODE_MASTER) { if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) { printk(KERN_DEBUG "%s: unknown management frame " "(type=0x%02x, stype=0x%02x) dropped\n", @@ -219,14 +217,13 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, } #endif - /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +static unsigned char rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; + /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; + { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by ieee80211_rx_frame_decrypt */ @@ -241,7 +238,7 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, if (skb->len < 24) return 0; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; fc = le16_to_cpu(hdr->frame_ctl); /* check that the frame is unicast frame to us */ @@ -271,7 +268,7 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, +ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; @@ -280,12 +277,11 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) return 0; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); #ifdef CONFIG_IEEE80211_CRYPT_TKIP - if (ieee->tkip_countermeasures && - strcmp(crypt->ops->name, "TKIP") == 0) { + if (ieee->tkip_countermeasures && strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " "received packet from " MAC_FMT "\n", @@ -299,9 +295,8 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); atomic_dec(&crypt->refcnt); if (res < 0) { - IEEE80211_DEBUG_DROP( - "decryption failed (SA=" MAC_FMT - ") res=%d\n", MAC_ARG(hdr->addr2), res); + IEEE80211_DEBUG_DROP("decryption failed (SA=" MAC_FMT + ") res=%d\n", MAC_ARG(hdr->addr2), res); if (res == -2) IEEE80211_DEBUG_DROP("Decryption failed ICV " "mismatch (key %d)\n", @@ -313,11 +308,11 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, return res; } - /* Called only as a tasklet (software IRQ), by ieee80211_rx */ static inline int -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb, - int keyidx, struct ieee80211_crypt_data *crypt) +ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, + struct sk_buff *skb, int keyidx, + struct ieee80211_crypt_data *crypt) { struct ieee80211_hdr *hdr; int res, hdrlen; @@ -325,7 +320,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *s if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) return 0; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); @@ -341,7 +336,6 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *s return 0; } - /* All received frames are sent to this function. @skb contains the frame in * IEEE 802.11 format, i.e., in the format it was sent over air. * This function is called only as a tasklet (software IRQ). */ @@ -373,8 +367,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, stats = &ieee->stats; if (skb->len < 10) { - printk(KERN_INFO "%s: SKB length < 10\n", - dev->name); + printk(KERN_INFO "%s: SKB length < 10\n", dev->name); goto rx_dropped; } @@ -399,8 +392,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, /* Update spy records */ wireless_spy_update(dev, hdr->addr2, &wstats); } -#endif /* IW_WIRELESS_SPY */ -#endif /* WIRELESS_EXT > 15 */ +#endif /* IW_WIRELESS_SPY */ +#endif /* WIRELESS_EXT > 15 */ hostap_update_rx_stats(local->ap, hdr, rx_stats); #endif @@ -429,8 +422,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, * stations that do not support WEP key mapping). */ if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) - (void) hostap_handle_sta_crypto(local, hdr, &crypt, - &sta); + (void)hostap_handle_sta_crypto(local, hdr, &crypt, + &sta); #endif /* allow NULL decrypt to indicate an station specific override @@ -451,13 +444,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, goto rx_dropped; } } - #ifdef NOT_YET if (type != WLAN_FC_TYPE_DATA) { if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH && fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt && - (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) - { + (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) { printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth " "from " MAC_FMT "\n", dev->name, MAC_ARG(hdr->addr2)); @@ -507,9 +498,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } if (ieee->iw_mode == IW_MODE_MASTER && !wds && - (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS && - ieee->stadev && - memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { + (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == + IEEE80211_FCTL_FROMDS && ieee->stadev + && memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) { /* Frame from BSSID of the AP for which we are a client */ skb->dev = dev = ieee->stadev; stats = hostap_get_stats(dev); @@ -521,8 +512,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, #ifdef NOT_YET if ((ieee->iw_mode == IW_MODE_MASTER || - ieee->iw_mode == IW_MODE_REPEAT) && - !from_assoc_ap) { + ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: @@ -546,11 +536,10 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, stype != IEEE80211_STYPE_DATA_CFPOLL && stype != IEEE80211_STYPE_DATA_CFACKPOLL) { if (stype != IEEE80211_STYPE_NULLFUNC) - IEEE80211_DEBUG_DROP( - "RX: dropped data frame " - "with no data (type=0x%02x, " - "subtype=0x%02x, len=%d)\n", - type, stype, skb->len); + IEEE80211_DEBUG_DROP("RX: dropped data frame " + "with no data (type=0x%02x, " + "subtype=0x%02x, len=%d)\n", + type, stype, skb->len); goto rx_dropped; } @@ -560,7 +549,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) goto rx_dropped; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; /* skb: hdr + (possibly fragmented) plaintext payload */ // PR: FIXME: hostap has additional conditions in the "if" below: @@ -614,7 +603,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, /* this was the last fragment and the frame will be * delivered, so remove skb from fragment cache */ skb = frag_skb; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; ieee80211_frag_cache_invalidate(ieee, hdr); } @@ -624,28 +613,26 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) goto rx_dropped; - hdr = (struct ieee80211_hdr *) skb->data; + hdr = (struct ieee80211_hdr *)skb->data; if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) { - if (/*ieee->ieee802_1x &&*/ - ieee80211_is_eapol_frame(ieee, skb)) { + if ( /*ieee->ieee802_1x && */ + ieee80211_is_eapol_frame(ieee, skb)) { /* pass unencrypted EAPOL frames even if encryption is * configured */ } else { - IEEE80211_DEBUG_DROP( - "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + IEEE80211_DEBUG_DROP("encryption configured, but RX " + "frame not encrypted (SA=" MAC_FMT + ")\n", MAC_ARG(hdr->addr2)); goto rx_dropped; } } if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep && !ieee80211_is_eapol_frame(ieee, skb)) { - IEEE80211_DEBUG_DROP( - "dropped unencrypted RX data " - "frame from " MAC_FMT - " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); + IEEE80211_DEBUG_DROP("dropped unencrypted RX data " + "frame from " MAC_FMT + " (drop_unencrypted=1)\n", + MAC_ARG(hdr->addr2)); goto rx_dropped; } @@ -673,8 +660,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } else if (!frame_authorized) { printk(KERN_DEBUG "%s: dropped frame from " "unauthorized port (IEEE 802.1X): " - "ethertype=0x%04x\n", - dev->name, ethertype); + "ethertype=0x%04x\n", dev->name, ethertype); goto rx_dropped; } } @@ -702,8 +688,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, #ifdef NOT_YET if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == - IEEE80211_FCTL_TODS) && - skb->len >= ETH_HLEN + ETH_ALEN) { + IEEE80211_FCTL_TODS) && skb->len >= ETH_HLEN + ETH_ALEN) { /* Non-standard frame: get addr4 from its bogus location after * the payload */ memcpy(skb->data + ETH_ALEN, @@ -716,8 +701,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, stats->rx_bytes += skb->len; #ifdef NOT_YET - if (ieee->iw_mode == IW_MODE_MASTER && !wds && - ieee->ap->bridge_packets) { + if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) { if (dst[0] & 0x01) { /* copy multicast frame both to the higher layers and * to the wireless media */ @@ -743,25 +727,24 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, skb2->dev = dev; dev_queue_xmit(skb2); } - #endif if (skb) { skb->protocol = eth_type_trans(skb, dev); memset(skb->cb, 0, sizeof(skb->cb)); skb->dev = dev; - skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ + skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ netif_rx(skb); } - rx_exit: + rx_exit: #ifdef NOT_YET if (sta) hostap_handle_sta_release(sta); #endif return 1; - rx_dropped: + rx_dropped: stats->rx_dropped++; /* Returning 0 indicates to caller that we have not handled the SKB-- @@ -785,22 +768,21 @@ static inline int ieee80211_is_ofdm_rate(u8 rate) case IEEE80211_OFDM_RATE_54MB: return 1; } - return 0; + return 0; } - -static inline int ieee80211_network_init( - struct ieee80211_device *ieee, - struct ieee80211_probe_response *beacon, - struct ieee80211_network *network, - struct ieee80211_rx_stats *stats) +static inline int ieee80211_network_init(struct ieee80211_device *ieee, + struct ieee80211_probe_response + *beacon, + struct ieee80211_network *network, + struct ieee80211_rx_stats *stats) { #ifdef CONFIG_IEEE80211_DEBUG char rates_str[64]; char *p; #endif struct ieee80211_info_element *info_element; - u16 left; + u16 left; u8 i; /* Pull out fixed field data */ @@ -810,7 +792,7 @@ static inline int ieee80211_network_init( network->time_stamp[0] = beacon->time_stamp[0]; network->time_stamp[1] = beacon->time_stamp[1]; network->beacon_interval = beacon->beacon_interval; - /* Where to pull this? beacon->listen_interval;*/ + /* Where to pull this? beacon->listen_interval; */ network->listen_interval = 0x0A; network->rates_len = network->rates_ex_len = 0; network->last_associate = 0; @@ -824,18 +806,20 @@ static inline int ieee80211_network_init( } else network->flags |= NETWORK_HAS_CCK; - network->wpa_ie_len = 0; - network->rsn_ie_len = 0; + network->wpa_ie_len = 0; + network->rsn_ie_len = 0; - info_element = &beacon->info_element; + info_element = &beacon->info_element; left = stats->len - ((void *)info_element - (void *)beacon); while (left >= sizeof(struct ieee80211_info_element_hdr)) { - if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) { - IEEE80211_DEBUG_SCAN("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%Zd left=%d.\n", - info_element->len + sizeof(struct ieee80211_info_element), - left); + if (sizeof(struct ieee80211_info_element_hdr) + + info_element->len > left) { + IEEE80211_DEBUG_SCAN + ("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%Zd left=%d.\n", + info_element->len + + sizeof(struct ieee80211_info_element), left); return 1; - } + } switch (info_element->id) { case MFIE_TYPE_SSID: @@ -846,10 +830,11 @@ static inline int ieee80211_network_init( } network->ssid_len = min(info_element->len, - (u8)IW_ESSID_MAX_SIZE); - memcpy(network->ssid, info_element->data, network->ssid_len); - if (network->ssid_len < IW_ESSID_MAX_SIZE) - memset(network->ssid + network->ssid_len, 0, + (u8) IW_ESSID_MAX_SIZE); + memcpy(network->ssid, info_element->data, + network->ssid_len); + if (network->ssid_len < IW_ESSID_MAX_SIZE) + memset(network->ssid + network->ssid_len, 0, IW_ESSID_MAX_SIZE - network->ssid_len); IEEE80211_DEBUG_SCAN("MFIE_TYPE_SSID: '%s' len=%d.\n", @@ -860,18 +845,23 @@ static inline int ieee80211_network_init( #ifdef CONFIG_IEEE80211_DEBUG p = rates_str; #endif - network->rates_len = min(info_element->len, MAX_RATES_LENGTH); + network->rates_len = + min(info_element->len, MAX_RATES_LENGTH); for (i = 0; i < network->rates_len; i++) { network->rates[i] = info_element->data[i]; #ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); + p += snprintf(p, + sizeof(rates_str) - (p - + rates_str), + "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate + (info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) network->flags &= - ~NETWORK_HAS_CCK; + ~NETWORK_HAS_CCK; } } @@ -883,18 +873,23 @@ static inline int ieee80211_network_init( #ifdef CONFIG_IEEE80211_DEBUG p = rates_str; #endif - network->rates_ex_len = min(info_element->len, MAX_RATES_EX_LENGTH); + network->rates_ex_len = + min(info_element->len, MAX_RATES_EX_LENGTH); for (i = 0; i < network->rates_ex_len; i++) { network->rates_ex[i] = info_element->data[i]; #ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); + p += snprintf(p, + sizeof(rates_str) - (p - + rates_str), + "%02X ", network->rates[i]); #endif - if (ieee80211_is_ofdm_rate(info_element->data[i])) { + if (ieee80211_is_ofdm_rate + (info_element->data[i])) { network->flags |= NETWORK_HAS_OFDM; if (info_element->data[i] & IEEE80211_BASIC_RATE_MASK) network->flags &= - ~NETWORK_HAS_CCK; + ~NETWORK_HAS_CCK; } } @@ -903,14 +898,14 @@ static inline int ieee80211_network_init( break; case MFIE_TYPE_DS_SET: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_DS_SET: %d\n", + IEEE80211_DEBUG_SCAN("MFIE_TYPE_DS_SET: %d\n", info_element->data[0]); if (stats->freq == IEEE80211_24GHZ_BAND) network->channel = info_element->data[0]; break; - case MFIE_TYPE_FH_SET: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_FH_SET: ignored\n"); + case MFIE_TYPE_FH_SET: + IEEE80211_DEBUG_SCAN("MFIE_TYPE_FH_SET: ignored\n"); break; case MFIE_TYPE_CF_SET: @@ -932,13 +927,13 @@ static inline int ieee80211_network_init( case MFIE_TYPE_GENERIC: IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n", info_element->len); - if (info_element->len >= 4 && + if (info_element->len >= 4 && info_element->data[0] == 0x00 && info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) { network->wpa_ie_len = min(info_element->len + 2, - MAX_WPA_IE_LEN); + MAX_WPA_IE_LEN); memcpy(network->wpa_ie, info_element, network->wpa_ie_len); } @@ -948,7 +943,7 @@ static inline int ieee80211_network_init( IEEE80211_DEBUG_SCAN("MFIE_TYPE_RSN: %d bytes\n", info_element->len); network->rsn_ie_len = min(info_element->len + 2, - MAX_WPA_IE_LEN); + MAX_WPA_IE_LEN); memcpy(network->rsn_ie, info_element, network->rsn_ie_len); break; @@ -956,14 +951,14 @@ static inline int ieee80211_network_init( default: IEEE80211_DEBUG_SCAN("unsupported IE %d\n", info_element->id); - break; - } + break; + } left -= sizeof(struct ieee80211_info_element_hdr) + - info_element->len; + info_element->len; info_element = (struct ieee80211_info_element *) - &info_element->data[info_element->len]; - } + &info_element->data[info_element->len]; + } network->mode = 0; if (stats->freq == IEEE80211_52GHZ_BAND) @@ -1032,10 +1027,13 @@ static inline void update_network(struct ieee80211_network *dst, /* dst->last_associate is not overwritten */ } -static inline void ieee80211_process_probe_response( - struct ieee80211_device *ieee, - struct ieee80211_probe_response *beacon, - struct ieee80211_rx_stats *stats) +static inline void ieee80211_process_probe_response(struct ieee80211_device + *ieee, + struct + ieee80211_probe_response + *beacon, + struct ieee80211_rx_stats + *stats) { struct ieee80211_network network; struct ieee80211_network *target; @@ -1045,33 +1043,35 @@ static inline void ieee80211_process_probe_response( #endif unsigned long flags; - IEEE80211_DEBUG_SCAN( - "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", - escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), - (beacon->capability & (1<<0xf)) ? '1' : '0', - (beacon->capability & (1<<0xe)) ? '1' : '0', - (beacon->capability & (1<<0xd)) ? '1' : '0', - (beacon->capability & (1<<0xc)) ? '1' : '0', - (beacon->capability & (1<<0xb)) ? '1' : '0', - (beacon->capability & (1<<0xa)) ? '1' : '0', - (beacon->capability & (1<<0x9)) ? '1' : '0', - (beacon->capability & (1<<0x8)) ? '1' : '0', - (beacon->capability & (1<<0x7)) ? '1' : '0', - (beacon->capability & (1<<0x6)) ? '1' : '0', - (beacon->capability & (1<<0x5)) ? '1' : '0', - (beacon->capability & (1<<0x4)) ? '1' : '0', - (beacon->capability & (1<<0x3)) ? '1' : '0', - (beacon->capability & (1<<0x2)) ? '1' : '0', - (beacon->capability & (1<<0x1)) ? '1' : '0', - (beacon->capability & (1<<0x0)) ? '1' : '0'); + IEEE80211_DEBUG_SCAN("'%s' (" MAC_FMT + "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + escape_essid(info_element->data, + info_element->len), + MAC_ARG(beacon->header.addr3), + (beacon->capability & (1 << 0xf)) ? '1' : '0', + (beacon->capability & (1 << 0xe)) ? '1' : '0', + (beacon->capability & (1 << 0xd)) ? '1' : '0', + (beacon->capability & (1 << 0xc)) ? '1' : '0', + (beacon->capability & (1 << 0xb)) ? '1' : '0', + (beacon->capability & (1 << 0xa)) ? '1' : '0', + (beacon->capability & (1 << 0x9)) ? '1' : '0', + (beacon->capability & (1 << 0x8)) ? '1' : '0', + (beacon->capability & (1 << 0x7)) ? '1' : '0', + (beacon->capability & (1 << 0x6)) ? '1' : '0', + (beacon->capability & (1 << 0x5)) ? '1' : '0', + (beacon->capability & (1 << 0x4)) ? '1' : '0', + (beacon->capability & (1 << 0x3)) ? '1' : '0', + (beacon->capability & (1 << 0x2)) ? '1' : '0', + (beacon->capability & (1 << 0x1)) ? '1' : '0', + (beacon->capability & (1 << 0x0)) ? '1' : '0'); if (ieee80211_network_init(ieee, beacon, &network, stats)) { IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", escape_essid(info_element->data, info_element->len), MAC_ARG(beacon->header.addr3), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + WLAN_FC_GET_STYPE(beacon->header. + frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); return; @@ -1117,13 +1117,13 @@ static inline void ieee80211_process_probe_response( list_del(ieee->network_free_list.next); } - #ifdef CONFIG_IEEE80211_DEBUG IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", escape_essid(network.ssid, network.ssid_len), MAC_ARG(network.bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + WLAN_FC_GET_STYPE(beacon->header. + frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); #endif @@ -1134,7 +1134,8 @@ static inline void ieee80211_process_probe_response( escape_essid(target->ssid, target->ssid_len), MAC_ARG(target->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + WLAN_FC_GET_STYPE(beacon->header. + frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); update_network(target, &network); @@ -1162,16 +1163,20 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee, IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Probe response\n"); - ieee80211_process_probe_response( - ieee, (struct ieee80211_probe_response *)header, stats); + ieee80211_process_probe_response(ieee, + (struct + ieee80211_probe_response *) + header, stats); break; case IEEE80211_STYPE_BEACON: IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); IEEE80211_DEBUG_SCAN("Beacon\n"); - ieee80211_process_probe_response( - ieee, (struct ieee80211_probe_response *)header, stats); + ieee80211_process_probe_response(ieee, + (struct + ieee80211_probe_response *) + header, stats); break; default: @@ -1184,6 +1189,5 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee, } } - EXPORT_SYMBOL(ieee80211_rx_mgt); EXPORT_SYMBOL(ieee80211_rx); diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c index b7ea3e25e2..c9aaff3fea 100644 --- a/net/ieee80211/ieee80211_tx.c +++ b/net/ieee80211/ieee80211_tx.c @@ -45,10 +45,8 @@ #include - /* - 802.11 Data Frame ,-------------------------------------------------------------------. @@ -82,7 +80,6 @@ Desc. | IV | Encrypted | ICV | `-----------------------' Total: 8 non-data bytes - 802.3 Ethernet Data Frame ,-----------------------------------------. @@ -131,7 +128,7 @@ payload of each frame is reduced to 492 bytes. static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static inline int ieee80211_put_snap(u8 *data, u16 h_proto) +static inline int ieee80211_put_snap(u8 * data, u16 h_proto) { struct ieee80211_snap_hdr *snap; u8 *oui; @@ -149,17 +146,15 @@ static inline int ieee80211_put_snap(u8 *data, u16 h_proto) snap->oui[1] = oui[1]; snap->oui[2] = oui[2]; - *(u16 *)(data + SNAP_SIZE) = htons(h_proto); + *(u16 *) (data + SNAP_SIZE) = htons(h_proto); return SNAP_SIZE + sizeof(u16); } -static inline int ieee80211_encrypt_fragment( - struct ieee80211_device *ieee, - struct sk_buff *frag, - int hdr_len) +static inline int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, + struct sk_buff *frag, int hdr_len) { - struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx]; + struct ieee80211_crypt_data *crypt = ieee->crypt[ieee->tx_keyidx]; int res; #ifdef CONFIG_IEEE80211_CRYPT_TKIP @@ -167,7 +162,7 @@ static inline int ieee80211_encrypt_fragment( if (ieee->tkip_countermeasures && crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { - header = (struct ieee80211_hdr *) frag->data; + header = (struct ieee80211_hdr *)frag->data; if (net_ratelimit()) { printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " "TX packet to " MAC_FMT "\n", @@ -200,8 +195,8 @@ static inline int ieee80211_encrypt_fragment( return 0; } - -void ieee80211_txb_free(struct ieee80211_txb *txb) { +void ieee80211_txb_free(struct ieee80211_txb *txb) +{ int i; if (unlikely(!txb)) return; @@ -216,9 +211,8 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, { struct ieee80211_txb *txb; int i; - txb = kmalloc( - sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags), - gfp_mask); + txb = kmalloc(sizeof(struct ieee80211_txb) + (sizeof(u8 *) * nr_frags), + gfp_mask); if (!txb) return NULL; @@ -243,8 +237,7 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, } /* SKBs are added to the ieee->tx_queue. */ -int ieee80211_xmit(struct sk_buff *skb, - struct net_device *dev) +int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); struct ieee80211_txb *txb = NULL; @@ -255,21 +248,20 @@ int ieee80211_xmit(struct sk_buff *skb, int ether_type, encrypt; int bytes, fc, hdr_len; struct sk_buff *skb_frag; - struct ieee80211_hdr header = { /* Ensure zero initialized */ + struct ieee80211_hdr header = { /* Ensure zero initialized */ .duration_id = 0, .seq_ctl = 0 }; u8 dest[ETH_ALEN], src[ETH_ALEN]; - struct ieee80211_crypt_data* crypt; + struct ieee80211_crypt_data *crypt; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother * creating it... */ if (!ieee->hard_start_xmit) { - printk(KERN_WARNING "%s: No xmit handler.\n", - ieee->dev->name); + printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name); goto success; } @@ -284,7 +276,7 @@ int ieee80211_xmit(struct sk_buff *skb, crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && - ieee->host_encrypt && crypt && crypt->ops; + ieee->host_encrypt && crypt && crypt->ops; if (!encrypt && ieee->ieee802_1x && ieee->drop_unencrypted && ether_type != ETH_P_PAE) { @@ -294,7 +286,7 @@ int ieee80211_xmit(struct sk_buff *skb, /* Save source and destination addresses */ memcpy(&dest, skb->data, ETH_ALEN); - memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN); + memcpy(&src, skb->data + ETH_ALEN, ETH_ALEN); /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); @@ -304,7 +296,7 @@ int ieee80211_xmit(struct sk_buff *skb, if (encrypt) fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | - IEEE80211_FCTL_PROTECTED; + IEEE80211_FCTL_PROTECTED; else fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; @@ -327,8 +319,7 @@ int ieee80211_xmit(struct sk_buff *skb, /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ - if (is_multicast_ether_addr(dest) || - is_broadcast_ether_addr(dest)) + if (is_multicast_ether_addr(dest) || is_broadcast_ether_addr(dest)) frag_size = MAX_FRAG_THRESHOLD; else frag_size = ieee->fts; @@ -345,7 +336,7 @@ int ieee80211_xmit(struct sk_buff *skb, /* Each fragment may need to have room for encryptiong pre/postfix */ if (encrypt) bytes_per_frag -= crypt->ops->extra_prefix_len + - crypt->ops->extra_postfix_len; + crypt->ops->extra_postfix_len; /* Number of fragments is the total bytes_per_frag / * payload_per_fragment */ @@ -380,19 +371,19 @@ int ieee80211_xmit(struct sk_buff *skb, /* If this is not the last fragment, then add the MOREFRAGS * bit to the frame control */ if (i != nr_frags - 1) { - frag_hdr->frame_ctl = cpu_to_le16( - fc | IEEE80211_FCTL_MOREFRAGS); + frag_hdr->frame_ctl = + cpu_to_le16(fc | IEEE80211_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { /* The last fragment takes the remaining length */ bytes = bytes_last_frag; } - /* Put a SNAP header on the first fragment */ + /* Put a SNAP header on the first fragment */ if (i == 0) { - ieee80211_put_snap( - skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), - ether_type); + ieee80211_put_snap(skb_put + (skb_frag, SNAP_SIZE + sizeof(u16)), + ether_type); bytes -= SNAP_SIZE + sizeof(u16); } @@ -410,14 +401,13 @@ int ieee80211_xmit(struct sk_buff *skb, skb_put(skb_frag, 4); } - - success: + success: spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { - if ((*ieee->hard_start_xmit)(txb, dev) == 0) { + if ((*ieee->hard_start_xmit) (txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; return 0; @@ -427,7 +417,7 @@ int ieee80211_xmit(struct sk_buff *skb, return 0; - failed: + failed: spin_unlock_irqrestore(&ieee->lock, flags); netif_stop_queue(dev); stats->tx_errors++; diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c index 510a1716a4..94882f39b0 100644 --- a/net/ieee80211/ieee80211_wx.c +++ b/net/ieee80211/ieee80211_wx.c @@ -42,7 +42,7 @@ static const char *ieee80211_modes[] = { #define MAX_CUSTOM_LEN 64 static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, - char *start, char *stop, + char *start, char *stop, struct ieee80211_network *network) { char custom[MAX_CUSTOM_LEN]; @@ -66,29 +66,28 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, iwe.u.data.length = sizeof(""); start = iwe_stream_add_point(start, stop, &iwe, ""); } else { - iwe.u.data.length = min(network->ssid_len, (u8)32); + iwe.u.data.length = min(network->ssid_len, (u8) 32); start = iwe_stream_add_point(start, stop, &iwe, network->ssid); } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]); + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", + ieee80211_modes[network->mode]); start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN); - /* Add mode */ - iwe.cmd = SIOCGIWMODE; - if (network->capability & - (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + if (network->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { if (network->capability & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; - start = iwe_stream_add_event(start, stop, &iwe, - IW_EV_UINT_LEN); + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN); } - /* Add frequency/channel */ + /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; /* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ @@ -110,7 +109,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - for (i = 0, j = 0; i < network->rates_len; ) { + for (i = 0, j = 0; i < network->rates_len;) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) < (network->rates[i] & 0x7F))) @@ -133,8 +132,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, iwe.cmd = SIOCGIWRATE; iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; iwe.u.bitrate.value = max_rate * 500000; - start = iwe_stream_add_event(start, stop, &iwe, - IW_EV_PARAM_LEN); + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_PARAM_LEN); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; @@ -164,7 +162,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, if (iwe.u.data.length) start = iwe_stream_add_point(start, stop, &iwe, custom); - if (ieee->wpa_enabled && network->wpa_ie_len){ + if (ieee->wpa_enabled && network->wpa_ie_len) { char buf[MAX_WPA_IE_LEN * 2 + 30]; u8 *p = buf; @@ -179,7 +177,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, start = iwe_stream_add_point(start, stop, &iwe, buf); } - if (ieee->wpa_enabled && network->rsn_ie_len){ + if (ieee->wpa_enabled && network->rsn_ie_len) { char buf[MAX_WPA_IE_LEN * 2 + 30]; u8 *p = buf; @@ -199,12 +197,12 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee, iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), - " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); + " Last beacon: %lums ago", + (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) start = iwe_stream_add_point(start, stop, &iwe, custom); - return start; } @@ -229,18 +227,19 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, time_after(network->last_scanned + ieee->scan_age, jiffies)) ev = ipw2100_translate_scan(ieee, ev, stop, network); else - IEEE80211_DEBUG_SCAN( - "Not showing network '%s (" - MAC_FMT ")' due to age (%lums).\n", - escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), - (jiffies - network->last_scanned) / (HZ / 100)); + IEEE80211_DEBUG_SCAN("Not showing network '%s (" + MAC_FMT ")' due to age (%lums).\n", + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid), + (jiffies - + network->last_scanned) / (HZ / + 100)); } spin_unlock_irqrestore(&ieee->lock, flags); - wrqu->data.length = ev - extra; + wrqu->data.length = ev - extra; wrqu->data.flags = 0; IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i); @@ -292,8 +291,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, if (ieee->crypt[i] != NULL) { if (key_provided) break; - ieee80211_crypt_delayed_deinit( - ieee, &ieee->crypt[i]); + ieee80211_crypt_delayed_deinit(ieee, + &ieee->crypt[i]); } } @@ -306,8 +305,6 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, goto done; } - - sec.enabled = 1; sec.flags |= SEC_ENABLED; @@ -341,8 +338,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, new_crypt = NULL; printk(KERN_WARNING "%s: could not initialize WEP: " - "load module ieee80211_crypt_wep\n", - dev->name); + "load module ieee80211_crypt_wep\n", dev->name); return -EOPNOTSUPP; } *crypt = new_crypt; @@ -359,7 +355,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, key, escape_essid(sec.keys[key], len), erq->length, len); sec.key_sizes[key] = len; - (*crypt)->ops->set_key(sec.keys[key], len, NULL, + (*crypt)->ops->set_key(sec.keys[key], len, NULL, (*crypt)->priv); sec.flags |= (1 << key); /* This ensures a key will be activated if no key is @@ -382,15 +378,15 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, /* No key data - just set the default TX key index */ if (key_provided) { - IEEE80211_DEBUG_WX( - "Setting key %d to default Tx key.\n", key); + IEEE80211_DEBUG_WX + ("Setting key %d to default Tx key.\n", key); ieee->tx_keyidx = key; sec.active_key = key; sec.flags |= SEC_ACTIVE_KEY; } } - done: + done: ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; @@ -400,7 +396,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, /* For now we just support WEP, so only set that security level... * TODO: When WPA is added this is one place that needs to change */ sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */ + sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */ if (ieee->set_security) ieee->set_security(dev, &sec); -- 2.39.5