Lines Matching +full:noise +full:- +full:sensitive
1 // SPDX-License-Identifier: GPL-2.0-only
4 Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved.
6 802.11 status code portion of this file from ethereal-0.10.6:
8 Ethereal - Network traffic analyzer
15 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
21 #include <net/cfg80211-wext.h>
64 #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
73 MODULE_FIRMWARE("ipw2200-ibss.fw");
75 MODULE_FIRMWARE("ipw2200-sniffer.fw");
77 MODULE_FIRMWARE("ipw2200-bss.fw");
98 static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */
229 out += scnprintf(buf + out, count - out, " "); in snprint_line()
231 out += scnprintf(buf + out, count - out, "%02X ", in snprint_line()
234 out += scnprintf(buf + out, count - out, " "); in snprint_line()
237 out += scnprintf(buf + out, count - out, " "); in snprint_line()
239 out += scnprintf(buf + out, count - out, " "); in snprint_line()
245 out += scnprintf(buf + out, count - out, "%c", c); in snprint_line()
249 out += scnprintf(buf + out, count - out, " "); in snprint_line()
267 len -= min(len, 16U); in printk_buf()
283 size -= out; in snprintk_buf()
284 len -= min_t(size_t, len, 16U); in snprintk_buf()
290 /* alias for 32-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
294 /* alias for 8-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
298 /* 8-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
307 /* 16-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
316 /* 32-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
325 /* 8-bit direct write (low 4K) */
329 writeb(val, ipw->hw_base + ofs); in _ipw_write8()
332 /* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
339 /* 16-bit direct write (low 4K) */
343 writew(val, ipw->hw_base + ofs); in _ipw_write16()
346 /* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
353 /* 32-bit direct write (low 4K) */
357 writel(val, ipw->hw_base + ofs); in _ipw_write32()
360 /* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
367 /* 8-bit direct read (low 4K) */
370 return readb(ipw->hw_base + ofs); in _ipw_read8()
373 /* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */
380 /* 32-bit direct read (low 4K) */
383 return readl(ipw->hw_base + ofs); in _ipw_read32()
386 /* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */
394 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
401 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
410 /* 32-bit indirect write (above 4K) */
418 /* 8-bit indirect write (above 4K) */
422 u32 dif_len = reg - aligned_addr; in _ipw_write_reg8()
429 /* 16-bit indirect write (above 4K) */
433 u32 dif_len = (reg - aligned_addr) & (~0x1ul); in _ipw_write_reg16()
440 /* 8-bit indirect read (above 4K) */
450 /* 32-bit indirect read (above 4K) */
463 /* General purpose, no alignment requirement, iterative (multi-byte) read, */
469 u32 dif_len = addr - aligned_addr; in _ipw_read_indirect()
482 for (i = dif_len; ((i < 4) && (num > 0)); i++, num--) in _ipw_read_indirect()
487 /* Read all of the middle dwords as dwords, with auto-increment */ in _ipw_read_indirect()
489 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4) in _ipw_read_indirect()
495 for (i = 0; num > 0; i++, num--) in _ipw_read_indirect()
500 /* General purpose, no alignment requirement, iterative (multi-byte) write, */
506 u32 dif_len = addr - aligned_addr; in _ipw_write_indirect()
519 for (i = dif_len; ((i < 4) && (num > 0)); i++, num--, buf++) in _ipw_write_indirect()
524 /* Write all of the middle dwords as dwords, with auto-increment */ in _ipw_write_indirect()
526 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4) in _ipw_write_indirect()
532 for (i = 0; num > 0; i++, num--, buf++) in _ipw_write_indirect()
537 /* General purpose, no alignment requirement, iterative (multi-byte) write, */
542 memcpy_toio((priv->hw_base + addr), buf, num); in ipw_write_direct()
559 if (priv->status & STATUS_INT_ENABLED) in __ipw_enable_interrupts()
561 priv->status |= STATUS_INT_ENABLED; in __ipw_enable_interrupts()
567 if (!(priv->status & STATUS_INT_ENABLED)) in __ipw_disable_interrupts()
569 priv->status &= ~STATUS_INT_ENABLED; in __ipw_disable_interrupts()
577 spin_lock_irqsave(&priv->irq_lock, flags); in ipw_enable_interrupts()
579 spin_unlock_irqrestore(&priv->irq_lock, flags); in ipw_enable_interrupts()
586 spin_lock_irqsave(&priv->irq_lock, flags); in ipw_disable_interrupts()
588 spin_unlock_irqrestore(&priv->irq_lock, flags); in ipw_disable_interrupts()
642 error->status, error->config); in ipw_dump_error_log()
644 for (i = 0; i < error->elem_len; i++) in ipw_dump_error_log()
646 ipw_error_desc(error->elem[i].desc), in ipw_dump_error_log()
647 error->elem[i].time, in ipw_dump_error_log()
648 error->elem[i].blink1, in ipw_dump_error_log()
649 error->elem[i].blink2, in ipw_dump_error_log()
650 error->elem[i].link1, in ipw_dump_error_log()
651 error->elem[i].link2, error->elem[i].data); in ipw_dump_error_log()
652 for (i = 0; i < error->log_len; i++) in ipw_dump_error_log()
654 error->log[i].time, in ipw_dump_error_log()
655 error->log[i].data, error->log[i].event); in ipw_dump_error_log()
660 return (priv->status & STATUS_INIT) ? 1 : 0; in ipw_is_init()
671 return -EINVAL; in ipw_get_ordinal()
675 if (!priv->table0_addr || !priv->table1_addr || !priv->table2_addr) { in ipw_get_ordinal()
677 return -EINVAL; in ipw_get_ordinal()
693 if (ord > priv->table0_len) { in ipw_get_ordinal()
695 "max (%i)\n", ord, priv->table0_len); in ipw_get_ordinal()
696 return -EINVAL; in ipw_get_ordinal()
703 return -EINVAL; in ipw_get_ordinal()
707 ord, priv->table0_addr + (ord << 2)); in ipw_get_ordinal()
711 *((u32 *) val) = ipw_read32(priv, priv->table0_addr + ord); in ipw_get_ordinal()
727 if (ord > priv->table1_len) { in ipw_get_ordinal()
729 return -EINVAL; in ipw_get_ordinal()
736 return -EINVAL; in ipw_get_ordinal()
740 ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); in ipw_get_ordinal()
749 * - dword containing the starting offset of the data in ipw_get_ordinal()
750 * - dword containing the lengh in the first 16bits in ipw_get_ordinal()
758 if (ord > priv->table2_len) { in ipw_get_ordinal()
760 return -EINVAL; in ipw_get_ordinal()
764 addr = ipw_read_reg32(priv, priv->table2_addr + (ord << 3)); in ipw_get_ordinal()
767 * two 16-bit words - first is length, second is count */ in ipw_get_ordinal()
770 priv->table2_addr + (ord << 3) + in ipw_get_ordinal()
783 return -EINVAL; in ipw_get_ordinal()
798 return -EINVAL; in ipw_get_ordinal()
807 priv->table0_addr = IPW_ORDINALS_TABLE_LOWER; in ipw_init_ordinals()
808 priv->table0_len = ipw_read32(priv, priv->table0_addr); in ipw_init_ordinals()
811 priv->table0_addr, priv->table0_len); in ipw_init_ordinals()
813 priv->table1_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_1); in ipw_init_ordinals()
814 priv->table1_len = ipw_read_reg32(priv, priv->table1_addr); in ipw_init_ordinals()
817 priv->table1_addr, priv->table1_len); in ipw_init_ordinals()
819 priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2); in ipw_init_ordinals()
820 priv->table2_len = ipw_read_reg32(priv, priv->table2_addr); in ipw_init_ordinals()
821 priv->table2_len &= 0x0000ffff; /* use first two bytes */ in ipw_init_ordinals()
824 priv->table2_addr, priv->table2_len); in ipw_init_ordinals()
842 * - On radio ON, turn on any LEDs that require to be on during start
843 * - On initialization, start unassociated blink
844 * - On association, disable unassociated blink
845 * - On disassociation, start unassociated blink
846 * - On radio OFF, turn off any LEDs started during radio on
860 if (priv->config & CFG_NO_LED || priv->nic_type == EEPROM_NIC_TYPE_1) in ipw_led_link_on()
863 spin_lock_irqsave(&priv->lock, flags); in ipw_led_link_on()
865 if (!(priv->status & STATUS_RF_KILL_MASK) && in ipw_led_link_on()
866 !(priv->status & STATUS_LED_LINK_ON)) { in ipw_led_link_on()
869 led |= priv->led_association_on; in ipw_led_link_on()
876 priv->status |= STATUS_LED_LINK_ON; in ipw_led_link_on()
879 if (!(priv->status & STATUS_ASSOCIATED)) in ipw_led_link_on()
880 schedule_delayed_work(&priv->led_link_off, in ipw_led_link_on()
884 spin_unlock_irqrestore(&priv->lock, flags); in ipw_led_link_on()
891 mutex_lock(&priv->mutex); in ipw_bg_led_link_on()
893 mutex_unlock(&priv->mutex); in ipw_bg_led_link_on()
903 if (priv->config & CFG_NO_LED || priv->nic_type == EEPROM_NIC_TYPE_1) in ipw_led_link_off()
906 spin_lock_irqsave(&priv->lock, flags); in ipw_led_link_off()
908 if (priv->status & STATUS_LED_LINK_ON) { in ipw_led_link_off()
910 led &= priv->led_association_off; in ipw_led_link_off()
918 priv->status &= ~STATUS_LED_LINK_ON; in ipw_led_link_off()
922 if (!(priv->status & STATUS_RF_KILL_MASK) && in ipw_led_link_off()
923 !(priv->status & STATUS_ASSOCIATED)) in ipw_led_link_off()
924 schedule_delayed_work(&priv->led_link_on, in ipw_led_link_off()
929 spin_unlock_irqrestore(&priv->lock, flags); in ipw_led_link_off()
936 mutex_lock(&priv->mutex); in ipw_bg_led_link_off()
938 mutex_unlock(&priv->mutex); in ipw_bg_led_link_off()
945 if (priv->config & CFG_NO_LED) in __ipw_led_activity_on()
948 if (priv->status & STATUS_RF_KILL_MASK) in __ipw_led_activity_on()
951 if (!(priv->status & STATUS_LED_ACT_ON)) { in __ipw_led_activity_on()
953 led |= priv->led_activity_on; in __ipw_led_activity_on()
962 priv->status |= STATUS_LED_ACT_ON; in __ipw_led_activity_on()
964 cancel_delayed_work(&priv->led_act_off); in __ipw_led_activity_on()
965 schedule_delayed_work(&priv->led_act_off, LD_TIME_ACT_ON); in __ipw_led_activity_on()
968 cancel_delayed_work(&priv->led_act_off); in __ipw_led_activity_on()
969 schedule_delayed_work(&priv->led_act_off, LD_TIME_ACT_ON); in __ipw_led_activity_on()
977 spin_lock_irqsave(&priv->lock, flags);
979 spin_unlock_irqrestore(&priv->lock, flags);
988 if (priv->config & CFG_NO_LED) in ipw_led_activity_off()
991 spin_lock_irqsave(&priv->lock, flags); in ipw_led_activity_off()
993 if (priv->status & STATUS_LED_ACT_ON) { in ipw_led_activity_off()
995 led &= priv->led_activity_off; in ipw_led_activity_off()
1004 priv->status &= ~STATUS_LED_ACT_ON; in ipw_led_activity_off()
1007 spin_unlock_irqrestore(&priv->lock, flags); in ipw_led_activity_off()
1014 mutex_lock(&priv->mutex); in ipw_bg_led_activity_off()
1016 mutex_unlock(&priv->mutex); in ipw_bg_led_activity_off()
1025 if (priv->config & CFG_NO_LED || in ipw_led_band_on()
1026 priv->nic_type != EEPROM_NIC_TYPE_1 || !priv->assoc_network) in ipw_led_band_on()
1029 spin_lock_irqsave(&priv->lock, flags); in ipw_led_band_on()
1032 if (priv->assoc_network->mode == IEEE_A) { in ipw_led_band_on()
1033 led |= priv->led_ofdm_on; in ipw_led_band_on()
1034 led &= priv->led_association_off; in ipw_led_band_on()
1036 } else if (priv->assoc_network->mode == IEEE_G) { in ipw_led_band_on()
1037 led |= priv->led_ofdm_on; in ipw_led_band_on()
1038 led |= priv->led_association_on; in ipw_led_band_on()
1041 led &= priv->led_ofdm_off; in ipw_led_band_on()
1042 led |= priv->led_association_on; in ipw_led_band_on()
1051 spin_unlock_irqrestore(&priv->lock, flags); in ipw_led_band_on()
1060 if (priv->config & CFG_NO_LED || priv->nic_type != EEPROM_NIC_TYPE_1) in ipw_led_band_off()
1063 spin_lock_irqsave(&priv->lock, flags); in ipw_led_band_off()
1066 led &= priv->led_ofdm_off; in ipw_led_band_off()
1067 led &= priv->led_association_off; in ipw_led_band_off()
1074 spin_unlock_irqrestore(&priv->lock, flags); in ipw_led_band_off()
1099 if (priv->status & STATUS_RF_KILL_MASK) in ipw_led_link_down()
1105 priv->nic_type = priv->eeprom[EEPROM_NIC_TYPE]; in ipw_led_init()
1108 priv->led_activity_on = IPW_ACTIVITY_LED; in ipw_led_init()
1109 priv->led_activity_off = ~(IPW_ACTIVITY_LED); in ipw_led_init()
1111 priv->led_association_on = IPW_ASSOCIATED_LED; in ipw_led_init()
1112 priv->led_association_off = ~(IPW_ASSOCIATED_LED); in ipw_led_init()
1115 priv->led_ofdm_on = IPW_OFDM_LED; in ipw_led_init()
1116 priv->led_ofdm_off = ~(IPW_OFDM_LED); in ipw_led_init()
1118 switch (priv->nic_type) { in ipw_led_init()
1121 priv->led_activity_on = IPW_ASSOCIATED_LED; in ipw_led_init()
1122 priv->led_activity_off = ~(IPW_ASSOCIATED_LED); in ipw_led_init()
1123 priv->led_association_on = IPW_ACTIVITY_LED; in ipw_led_init()
1124 priv->led_association_off = ~(IPW_ACTIVITY_LED); in ipw_led_init()
1126 if (!(priv->config & CFG_NO_LED)) in ipw_led_init()
1141 priv->nic_type); in ipw_led_init()
1142 priv->nic_type = EEPROM_NIC_TYPE_0; in ipw_led_init()
1146 if (!(priv->config & CFG_NO_LED)) { in ipw_led_init()
1147 if (priv->status & STATUS_ASSOCIATED) in ipw_led_init()
1159 cancel_delayed_work(&priv->led_link_on); in ipw_led_shutdown()
1160 cancel_delayed_work(&priv->led_link_off); in ipw_led_shutdown()
1161 cancel_delayed_work(&priv->led_act_off); in ipw_led_shutdown()
1183 if (result == -EINVAL) in debug_level_store()
1186 else if (result == -ERANGE) in debug_level_store()
1222 array_size(sizeof(*error->log), log_len)), in ipw_alloc_error_log()
1229 error->jiffies = jiffies; in ipw_alloc_error_log()
1230 error->status = priv->status; in ipw_alloc_error_log()
1231 error->config = priv->config; in ipw_alloc_error_log()
1232 error->elem_len = elem_len; in ipw_alloc_error_log()
1233 error->log_len = log_len; in ipw_alloc_error_log()
1234 error->log = (struct ipw_event *)(error->elem + elem_len); in ipw_alloc_error_log()
1236 ipw_capture_event_log(priv, log_len, error->log); in ipw_alloc_error_log()
1239 ipw_read_indirect(priv, base + sizeof(base), (u8 *) error->elem, in ipw_alloc_error_log()
1240 sizeof(*error->elem) * elem_len); in ipw_alloc_error_log()
1265 len += scnprintf(buf + len, PAGE_SIZE - len, "%08X", log_len); in event_log_show()
1267 len += scnprintf(buf + len, PAGE_SIZE - len, in event_log_show()
1270 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); in event_log_show()
1282 if (!priv->error) in error_show()
1284 len += scnprintf(buf + len, PAGE_SIZE - len, in error_show()
1286 priv->error->jiffies, in error_show()
1287 priv->error->status, in error_show()
1288 priv->error->config, priv->error->elem_len); in error_show()
1289 for (i = 0; i < priv->error->elem_len; i++) in error_show()
1290 len += scnprintf(buf + len, PAGE_SIZE - len, in error_show()
1292 priv->error->elem[i].time, in error_show()
1293 priv->error->elem[i].desc, in error_show()
1294 priv->error->elem[i].blink1, in error_show()
1295 priv->error->elem[i].blink2, in error_show()
1296 priv->error->elem[i].link1, in error_show()
1297 priv->error->elem[i].link2, in error_show()
1298 priv->error->elem[i].data); in error_show()
1300 len += scnprintf(buf + len, PAGE_SIZE - len, in error_show()
1301 "\n%08X", priv->error->log_len); in error_show()
1302 for (i = 0; i < priv->error->log_len; i++) in error_show()
1303 len += scnprintf(buf + len, PAGE_SIZE - len, in error_show()
1305 priv->error->log[i].time, in error_show()
1306 priv->error->log[i].event, in error_show()
1307 priv->error->log[i].data); in error_show()
1308 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); in error_show()
1318 kfree(priv->error); in error_store()
1319 priv->error = NULL; in error_store()
1330 if (!priv->cmdlog) in cmd_log_show()
1332 for (i = (priv->cmdlog_pos + 1) % priv->cmdlog_len; in cmd_log_show()
1333 (i != priv->cmdlog_pos) && (len < PAGE_SIZE); in cmd_log_show()
1334 i = (i + 1) % priv->cmdlog_len) { in cmd_log_show()
1336 scnprintf(buf + len, PAGE_SIZE - len, in cmd_log_show()
1337 "\n%08lX%08X%08X%08X\n", priv->cmdlog[i].jiffies, in cmd_log_show()
1338 priv->cmdlog[i].retcode, priv->cmdlog[i].cmd.cmd, in cmd_log_show()
1339 priv->cmdlog[i].cmd.len); in cmd_log_show()
1341 snprintk_buf(buf + len, PAGE_SIZE - len, in cmd_log_show()
1342 (u8 *) priv->cmdlog[i].cmd.param, in cmd_log_show()
1343 priv->cmdlog[i].cmd.len); in cmd_log_show()
1344 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); in cmd_log_show()
1346 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); in cmd_log_show()
1363 return -EINVAL; in rtap_iface_store()
1370 if (netif_running(priv->prom_net_dev)) { in rtap_iface_store()
1389 return -EINVAL; in rtap_iface_store()
1406 return sprintf(buf, "%s", priv->prom_net_dev->name); in rtap_iface_show()
1408 buf[0] = '-'; in rtap_iface_show()
1423 if (!priv->prom_priv) { in rtap_filter_store()
1426 return -EPERM; in rtap_filter_store()
1429 priv->prom_priv->filter = simple_strtol(buf, NULL, 0); in rtap_filter_store()
1432 BIT_ARG16(priv->prom_priv->filter)); in rtap_filter_store()
1443 priv->prom_priv ? priv->prom_priv->filter : 0); in rtap_filter_show()
1453 return sprintf(buf, "%d\n", priv->ieee->scan_age); in scan_age_show()
1460 struct net_device *dev = priv->net_dev; in scan_age_store()
1467 if (result == -EINVAL || result == -ERANGE) { in scan_age_store()
1468 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name); in scan_age_store()
1470 priv->ieee->scan_age = val; in scan_age_store()
1471 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); in scan_age_store()
1484 return sprintf(buf, "%d\n", (priv->config & CFG_NO_LED) ? 0 : 1); in led_show()
1499 priv->config |= CFG_NO_LED; in led_store()
1503 priv->config &= ~CFG_NO_LED; in led_store()
1517 return sprintf(buf, "0x%08x\n", (int)p->status); in status_show()
1526 return sprintf(buf, "0x%08x\n", (int)p->config); in cfg_show()
1535 return sprintf(buf, "TYPE: %d\n", priv->nic_type); in nic_type_show()
1576 int n = p->eeprom_delay; in eeprom_delay_show()
1584 sscanf(buf, "%i", &p->eeprom_delay); in eeprom_delay_store()
1642 if (priv->status & STATUS_INDIRECT_DWORD) in indirect_dword_show()
1643 reg = ipw_read_reg32(priv, priv->indirect_dword); in indirect_dword_show()
1655 sscanf(buf, "%x", &priv->indirect_dword); in indirect_dword_store()
1656 priv->status |= STATUS_INDIRECT_DWORD; in indirect_dword_store()
1668 if (priv->status & STATUS_INDIRECT_BYTE) in indirect_byte_show()
1669 reg = ipw_read_reg8(priv, priv->indirect_byte); in indirect_byte_show()
1681 sscanf(buf, "%x", &priv->indirect_byte); in indirect_byte_store()
1682 priv->status |= STATUS_INDIRECT_BYTE; in indirect_byte_store()
1694 if (priv->status & STATUS_DIRECT_DWORD) in direct_dword_show()
1695 reg = ipw_read32(priv, priv->direct_dword); in direct_dword_show()
1707 sscanf(buf, "%x", &priv->direct_dword); in direct_dword_store()
1708 priv->status |= STATUS_DIRECT_DWORD; in direct_dword_store()
1717 priv->status |= STATUS_RF_KILL_HW; in rf_kill_active()
1718 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, true); in rf_kill_active()
1720 priv->status &= ~STATUS_RF_KILL_HW; in rf_kill_active()
1721 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, false); in rf_kill_active()
1724 return (priv->status & STATUS_RF_KILL_HW) ? 1 : 0; in rf_kill_active()
1730 /* 0 - RF kill not enabled in rf_kill_show()
1731 1 - SW based RF kill active (sysfs) in rf_kill_show()
1732 2 - HW based RF kill active in rf_kill_show()
1733 3 - Both HW and SW baed RF kill active */ in rf_kill_show()
1735 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | in rf_kill_show()
1743 ((priv->status & STATUS_RF_KILL_SW) ? 1 : 0)) in ipw_radio_kill_sw()
1750 priv->status |= STATUS_RF_KILL_SW; in ipw_radio_kill_sw()
1752 cancel_delayed_work(&priv->request_scan); in ipw_radio_kill_sw()
1753 cancel_delayed_work(&priv->request_direct_scan); in ipw_radio_kill_sw()
1754 cancel_delayed_work(&priv->request_passive_scan); in ipw_radio_kill_sw()
1755 cancel_delayed_work(&priv->scan_event); in ipw_radio_kill_sw()
1756 schedule_work(&priv->down); in ipw_radio_kill_sw()
1758 priv->status &= ~STATUS_RF_KILL_SW; in ipw_radio_kill_sw()
1760 IPW_DEBUG_RF_KILL("Can not turn radio back on - " in ipw_radio_kill_sw()
1763 cancel_delayed_work(&priv->rf_kill); in ipw_radio_kill_sw()
1764 schedule_delayed_work(&priv->rf_kill, in ipw_radio_kill_sw()
1767 schedule_work(&priv->up); in ipw_radio_kill_sw()
1790 if (priv->config & CFG_SPEED_SCAN) { in speed_scan_show()
1791 while (priv->speed_scan[pos] != 0) in speed_scan_show()
1793 priv->speed_scan[pos++]); in speed_scan_show()
1809 if (pos == MAX_SPEED_SCAN - 1) { in speed_scan_store()
1810 priv->speed_scan[pos] = 0; in speed_scan_store()
1814 if (libipw_is_valid_channel(priv->ieee, channel)) in speed_scan_store()
1815 priv->speed_scan[pos++] = channel; in speed_scan_store()
1827 priv->config &= ~CFG_SPEED_SCAN; in speed_scan_store()
1829 priv->speed_scan_pos = 0; in speed_scan_store()
1830 priv->config |= CFG_SPEED_SCAN; in speed_scan_store()
1842 return sprintf(buf, "%c\n", (priv->config & CFG_NET_STATS) ? '1' : '0'); in net_stats_show()
1850 priv->config |= CFG_NET_STATS; in net_stats_store()
1852 priv->config &= ~CFG_NET_STATS; in net_stats_store()
1864 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in channels_show()
1869 "(802.11bg):\n", geo->bg_channels); in channels_show()
1871 for (i = 0; i < geo->bg_channels; i++) { in channels_show()
1873 geo->bg[i].channel, in channels_show()
1874 geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT ? in channels_show()
1876 ((geo->bg[i].flags & LIBIPW_CH_NO_IBSS) || in channels_show()
1877 (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)) in channels_show()
1879 geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY ? in channels_show()
1881 geo->bg[i].flags & LIBIPW_CH_B_ONLY ? in channels_show()
1887 "(802.11a):\n", geo->a_channels); in channels_show()
1888 for (i = 0; i < geo->a_channels; i++) { in channels_show()
1890 geo->a[i].channel, in channels_show()
1891 geo->a[i].flags & LIBIPW_CH_RADAR_DETECT ? in channels_show()
1893 ((geo->a[i].flags & LIBIPW_CH_NO_IBSS) || in channels_show()
1894 (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT)) in channels_show()
1896 geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY ? in channels_show()
1909 if (priv->status & STATUS_ASSOCIATED) in notify_wx_assoc_event()
1910 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN); in notify_wx_assoc_event()
1913 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); in notify_wx_assoc_event()
1922 spin_lock_irqsave(&priv->irq_lock, flags); in ipw_irq_tasklet()
1936 inta |= priv->isr_inta; in ipw_irq_tasklet()
1938 spin_unlock_irqrestore(&priv->irq_lock, flags); in ipw_irq_tasklet()
1940 spin_lock_irqsave(&priv->lock, flags); in ipw_irq_tasklet()
1950 ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1); in ipw_irq_tasklet()
1951 priv->status &= ~STATUS_HCMD_ACTIVE; in ipw_irq_tasklet()
1952 wake_up_interruptible(&priv->wait_command_queue); in ipw_irq_tasklet()
1958 ipw_queue_tx_reclaim(priv, &priv->txq[0], 0); in ipw_irq_tasklet()
1964 ipw_queue_tx_reclaim(priv, &priv->txq[1], 1); in ipw_irq_tasklet()
1970 ipw_queue_tx_reclaim(priv, &priv->txq[2], 2); in ipw_irq_tasklet()
1976 ipw_queue_tx_reclaim(priv, &priv->txq[3], 3); in ipw_irq_tasklet()
2007 priv->status |= STATUS_RF_KILL_HW; in ipw_irq_tasklet()
2008 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, true); in ipw_irq_tasklet()
2009 wake_up_interruptible(&priv->wait_command_queue); in ipw_irq_tasklet()
2010 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); in ipw_irq_tasklet()
2011 cancel_delayed_work(&priv->request_scan); in ipw_irq_tasklet()
2012 cancel_delayed_work(&priv->request_direct_scan); in ipw_irq_tasklet()
2013 cancel_delayed_work(&priv->request_passive_scan); in ipw_irq_tasklet()
2014 cancel_delayed_work(&priv->scan_event); in ipw_irq_tasklet()
2015 schedule_work(&priv->link_down); in ipw_irq_tasklet()
2016 schedule_delayed_work(&priv->rf_kill, 2 * HZ); in ipw_irq_tasklet()
2022 if (priv->error) { in ipw_irq_tasklet()
2031 priv->error = ipw_alloc_error_log(priv); in ipw_irq_tasklet()
2032 if (priv->error) in ipw_irq_tasklet()
2038 ipw_dump_error_log(priv, priv->error); in ipw_irq_tasklet()
2043 if (priv->ieee->sec.encrypt) { in ipw_irq_tasklet()
2044 priv->status &= ~STATUS_ASSOCIATED; in ipw_irq_tasklet()
2050 priv->status &= ~STATUS_INIT; in ipw_irq_tasklet()
2053 priv->status &= ~STATUS_HCMD_ACTIVE; in ipw_irq_tasklet()
2054 wake_up_interruptible(&priv->wait_command_queue); in ipw_irq_tasklet()
2056 schedule_work(&priv->adapter_restart); in ipw_irq_tasklet()
2069 spin_unlock_irqrestore(&priv->lock, flags); in ipw_irq_tasklet()
2142 spin_lock_irqsave(&priv->lock, flags); in __ipw_send_cmd()
2143 if (priv->status & STATUS_HCMD_ACTIVE) { in __ipw_send_cmd()
2145 get_cmd_string(cmd->cmd)); in __ipw_send_cmd()
2146 spin_unlock_irqrestore(&priv->lock, flags); in __ipw_send_cmd()
2147 return -EAGAIN; in __ipw_send_cmd()
2150 priv->status |= STATUS_HCMD_ACTIVE; in __ipw_send_cmd()
2152 if (priv->cmdlog) { in __ipw_send_cmd()
2153 priv->cmdlog[priv->cmdlog_pos].jiffies = jiffies; in __ipw_send_cmd()
2154 priv->cmdlog[priv->cmdlog_pos].cmd.cmd = cmd->cmd; in __ipw_send_cmd()
2155 priv->cmdlog[priv->cmdlog_pos].cmd.len = cmd->len; in __ipw_send_cmd()
2156 memcpy(priv->cmdlog[priv->cmdlog_pos].cmd.param, cmd->param, in __ipw_send_cmd()
2157 cmd->len); in __ipw_send_cmd()
2158 priv->cmdlog[priv->cmdlog_pos].retcode = -1; in __ipw_send_cmd()
2162 get_cmd_string(cmd->cmd), cmd->cmd, cmd->len, in __ipw_send_cmd()
2163 priv->status); in __ipw_send_cmd()
2166 if (cmd->cmd == IPW_CMD_WEP_KEY) in __ipw_send_cmd()
2170 printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len); in __ipw_send_cmd()
2172 rc = ipw_queue_tx_hcmd(priv, cmd->cmd, cmd->param, cmd->len, 0); in __ipw_send_cmd()
2174 priv->status &= ~STATUS_HCMD_ACTIVE; in __ipw_send_cmd()
2176 get_cmd_string(cmd->cmd), rc); in __ipw_send_cmd()
2177 spin_unlock_irqrestore(&priv->lock, flags); in __ipw_send_cmd()
2180 spin_unlock_irqrestore(&priv->lock, flags); in __ipw_send_cmd()
2185 rc = wait_event_interruptible_timeout(priv->wait_command_queue, in __ipw_send_cmd()
2186 !(priv-> in __ipw_send_cmd()
2188 end - now); in __ipw_send_cmd()
2197 spin_lock_irqsave(&priv->lock, flags); in __ipw_send_cmd()
2198 if (priv->status & STATUS_HCMD_ACTIVE) { in __ipw_send_cmd()
2200 get_cmd_string(cmd->cmd)); in __ipw_send_cmd()
2201 priv->status &= ~STATUS_HCMD_ACTIVE; in __ipw_send_cmd()
2202 spin_unlock_irqrestore(&priv->lock, flags); in __ipw_send_cmd()
2203 rc = -EIO; in __ipw_send_cmd()
2206 spin_unlock_irqrestore(&priv->lock, flags); in __ipw_send_cmd()
2210 if (priv->status & STATUS_RF_KILL_HW) { in __ipw_send_cmd()
2212 get_cmd_string(cmd->cmd)); in __ipw_send_cmd()
2213 rc = -EIO; in __ipw_send_cmd()
2218 if (priv->cmdlog) { in __ipw_send_cmd()
2219 priv->cmdlog[priv->cmdlog_pos++].retcode = rc; in __ipw_send_cmd()
2220 priv->cmdlog_pos %= priv->cmdlog_len; in __ipw_send_cmd()
2250 return -1; in ipw_send_host_complete()
2259 sizeof(priv->sys_config), in ipw_send_system_config()
2260 &priv->sys_config); in ipw_send_system_config()
2267 return -1; in ipw_send_ssid()
2278 return -1; in ipw_send_adapter_address()
2282 priv->net_dev->name, mac); in ipw_send_adapter_address()
2291 if (priv->status & STATUS_RF_KILL_MASK) in ipw_adapter_restart()
2296 if (priv->assoc_network && in ipw_adapter_restart()
2297 (priv->assoc_network->capability & WLAN_CAPABILITY_IBSS)) in ipw_adapter_restart()
2310 mutex_lock(&priv->mutex); in ipw_bg_adapter_restart()
2312 mutex_unlock(&priv->mutex); in ipw_bg_adapter_restart()
2323 if (priv->status & STATUS_SCAN_ABORTING) { in ipw_scan_check()
2327 schedule_work(&priv->adapter_restart); in ipw_scan_check()
2328 } else if (priv->status & STATUS_SCANNING) { in ipw_scan_check()
2333 schedule_delayed_work(&priv->scan_check, HZ); in ipw_scan_check()
2341 mutex_lock(&priv->mutex); in ipw_bg_scan_check()
2343 mutex_unlock(&priv->mutex); in ipw_bg_scan_check()
2357 return -1; in ipw_send_scan_abort()
2378 return -1; in ipw_send_associate()
2390 return -1; in ipw_send_supported_rates()
2403 return -1; in ipw_set_random_seed()
2416 return -1; in ipw_send_card_disable()
2426 return -1; in ipw_send_tx_power()
2434 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw_set_tx_power()
2443 tx_power.num_channels = geo->bg_channels; in ipw_set_tx_power()
2444 for (i = 0; i < geo->bg_channels; i++) { in ipw_set_tx_power()
2445 max_power = geo->bg[i].max_power; in ipw_set_tx_power()
2447 geo->bg[i].channel; in ipw_set_tx_power()
2449 min(max_power, priv->tx_power) : priv->tx_power; in ipw_set_tx_power()
2452 return -EIO; in ipw_set_tx_power()
2457 return -EIO; in ipw_set_tx_power()
2460 if (priv->ieee->abg_true) { in ipw_set_tx_power()
2462 tx_power.num_channels = geo->a_channels; in ipw_set_tx_power()
2464 max_power = geo->a[i].max_power; in ipw_set_tx_power()
2466 geo->a[i].channel; in ipw_set_tx_power()
2468 min(max_power, priv->tx_power) : priv->tx_power; in ipw_set_tx_power()
2471 return -EIO; in ipw_set_tx_power()
2484 return -1; in ipw_send_rts_threshold()
2499 return -1; in ipw_send_frag_threshold()
2512 return -1; in ipw_send_power_mode()
2542 return -1; in ipw_send_retry_limit()
2572 udelay(p->eeprom_delay); in eeprom_write_reg()
2609 for (i = 7; i >= 0; i--) { in eeprom_op()
2646 memcpy(mac, &priv->eeprom[EEPROM_MAC_ADDRESS], ETH_ALEN); in eeprom_parse_mac()
2652 __le16 *eeprom = (__le16 *) priv->eeprom; in ipw_read_eeprom()
2669 * bit needs region of shared SRAM needs to be non-zero.
2682 if (priv->eeprom[EEPROM_VERSION] != 0) { in ipw_eeprom_init_sram()
2687 ipw_write8(priv, IPW_EEPROM_DATA + i, priv->eeprom[i]); in ipw_eeprom_init_sram()
2707 while (count--) in ipw_zero_memory()
2742 priv->sram_desc.last_cb_index = 0; in ipw_fw_dma_abort()
2770 for (index = 0; index < priv->sram_desc.last_cb_index; index++) in ipw_fw_dma_kick()
2772 &priv->sram_desc.cb_list[index]); in ipw_fw_dma_kick()
2830 current_cb_index = (current_cb_address - IPW_SHARED_SRAM_DMA_CONTROL) / in ipw_fw_dma_command_block_index()
2857 if (priv->sram_desc.last_cb_index >= CB_NUMBER_OF_ELEMENTS_SMALL) in ipw_fw_dma_add_command_block()
2858 return -1; in ipw_fw_dma_add_command_block()
2860 last_cb_element = priv->sram_desc.last_cb_index; in ipw_fw_dma_add_command_block()
2861 cb = &priv->sram_desc.cb_list[last_cb_element]; in ipw_fw_dma_add_command_block()
2862 priv->sram_desc.last_cb_index++; in ipw_fw_dma_add_command_block()
2874 cb->status = control ^ src_address ^ dest_address; in ipw_fw_dma_add_command_block()
2877 cb->dest_addr = dest_address; in ipw_fw_dma_add_command_block()
2878 cb->source_addr = src_address; in ipw_fw_dma_add_command_block()
2881 cb->control = control; in ipw_fw_dma_add_command_block()
2897 size = min_t(u32, len - i * CB_MAX_LENGTH, CB_MAX_LENGTH); in ipw_fw_dma_add_buffer()
2904 return -1; in ipw_fw_dma_add_buffer()
2922 (int)priv->sram_desc.last_cb_index); in ipw_fw_dma_wait()
2924 while (current_index < priv->sram_desc.last_cb_index) { in ipw_fw_dma_wait()
2937 return -1; in ipw_fw_dma_wait()
2957 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_remove_current_network()
2958 list_for_each_safe(element, safe, &priv->ieee->network_list) { in ipw_remove_current_network()
2960 if (ether_addr_equal(network->bssid, priv->bssid)) { in ipw_remove_current_network()
2962 list_add_tail(&network->list, in ipw_remove_current_network()
2963 &priv->ieee->network_free_list); in ipw_remove_current_network()
2966 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_remove_current_network()
2969 /* timeout in msec, attempted in 10-msec quanta */
2982 return -ETIME; in ipw_poll_bit()
2995 /* stop master. typical delay - 0 */ in ipw_stop_master()
2998 /* timeout is in msec, polled in 10-msec quanta */ in ipw_stop_master()
3003 return -1; in ipw_stop_master()
3048 memset(&priv->dino_alive, 0, sizeof(priv->dino_alive)); in ipw_load_ucode()
3099 __le32 response_buffer[(sizeof(priv->dino_alive) + 3) / 4]; in ipw_load_ucode()
3105 memcpy(&priv->dino_alive, response_buffer, in ipw_load_ucode()
3106 sizeof(priv->dino_alive)); in ipw_load_ucode()
3107 if (priv->dino_alive.alive_command == 1 in ipw_load_ucode()
3108 && priv->dino_alive.ucode_valid == 1) { in ipw_load_ucode()
3113 priv->dino_alive.software_revision, in ipw_load_ucode()
3114 priv->dino_alive.software_revision, in ipw_load_ucode()
3115 priv->dino_alive.device_identifier, in ipw_load_ucode()
3116 priv->dino_alive.device_identifier, in ipw_load_ucode()
3117 priv->dino_alive.time_stamp[0], in ipw_load_ucode()
3118 priv->dino_alive.time_stamp[1], in ipw_load_ucode()
3119 priv->dino_alive.time_stamp[2], in ipw_load_ucode()
3120 priv->dino_alive.time_stamp[3], in ipw_load_ucode()
3121 priv->dino_alive.time_stamp[4]); in ipw_load_ucode()
3124 rc = -EINVAL; in ipw_load_ucode()
3128 rc = -ETIME; in ipw_load_ucode()
3140 int ret = -1; in ipw_load_firmware()
3154 return -ENOMEM; in ipw_load_firmware()
3160 return -ENOMEM; in ipw_load_firmware()
3162 pool = dma_pool_create("ipw2200", &priv->pci_dev->dev, CB_MAX_LENGTH, 0, in ipw_load_firmware()
3168 return -ENOMEM; in ipw_load_firmware()
3175 BUG_ON(priv->sram_desc.last_cb_index > 0); in ipw_load_firmware()
3185 chunk_len = le32_to_cpu(chunk->length); in ipw_load_firmware()
3188 nr = (chunk_len + CB_MAX_LENGTH - 1) / CB_MAX_LENGTH; in ipw_load_firmware()
3193 ret = -ENOMEM; in ipw_load_firmware()
3196 size = min_t(u32, chunk_len - i * CB_MAX_LENGTH, in ipw_load_firmware()
3206 /* dma to chunk->address, the chunk->length bytes from data + in ipw_load_firmware()
3209 ret = ipw_fw_dma_add_buffer(priv, &phys[total_nr - nr], in ipw_load_firmware()
3210 nr, le32_to_cpu(chunk->address), in ipw_load_firmware()
3290 /* low-level PLL activation */ in ipw_init_nic()
3324 spin_lock_irqsave(&priv->lock, flags); in ipw_reset_nic()
3326 priv->status &= ~STATUS_HCMD_ACTIVE; in ipw_reset_nic()
3327 wake_up_interruptible(&priv->wait_command_queue); in ipw_reset_nic()
3328 priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); in ipw_reset_nic()
3329 wake_up_interruptible(&priv->wait_state); in ipw_reset_nic()
3330 spin_unlock_irqrestore(&priv->lock, flags); in ipw_reset_nic()
3352 rc = request_firmware(raw, name, &priv->pci_dev->dev); in ipw_get_fw()
3358 if ((*raw)->size < sizeof(*fw)) { in ipw_get_fw()
3359 IPW_ERROR("%s is too small (%zd)\n", name, (*raw)->size); in ipw_get_fw()
3360 return -EINVAL; in ipw_get_fw()
3363 fw = (void *)(*raw)->data; in ipw_get_fw()
3365 if ((*raw)->size < sizeof(*fw) + le32_to_cpu(fw->boot_size) + in ipw_get_fw()
3366 le32_to_cpu(fw->ucode_size) + le32_to_cpu(fw->fw_size)) { in ipw_get_fw()
3368 name, (*raw)->size); in ipw_get_fw()
3369 return -EINVAL; in ipw_get_fw()
3374 le32_to_cpu(fw->ver) >> 16, in ipw_get_fw()
3375 le32_to_cpu(fw->ver) & 0xff, in ipw_get_fw()
3376 (*raw)->size - sizeof(*fw)); in ipw_get_fw()
3388 spin_lock_irqsave(&rxq->lock, flags); in ipw_rx_queue_reset()
3390 INIT_LIST_HEAD(&rxq->rx_free); in ipw_rx_queue_reset()
3391 INIT_LIST_HEAD(&rxq->rx_used); in ipw_rx_queue_reset()
3397 if (rxq->pool[i].skb != NULL) { in ipw_rx_queue_reset()
3398 dma_unmap_single(&priv->pci_dev->dev, in ipw_rx_queue_reset()
3399 rxq->pool[i].dma_addr, in ipw_rx_queue_reset()
3401 dev_kfree_skb_irq(rxq->pool[i].skb); in ipw_rx_queue_reset()
3402 rxq->pool[i].skb = NULL; in ipw_rx_queue_reset()
3404 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); in ipw_rx_queue_reset()
3409 rxq->read = rxq->write = 0; in ipw_rx_queue_reset()
3410 rxq->free_count = 0; in ipw_rx_queue_reset()
3411 spin_unlock_irqrestore(&rxq->lock, flags); in ipw_rx_queue_reset()
3440 switch (priv->ieee->iw_mode) { in ipw_load()
3442 name = "ipw2200-ibss.fw"; in ipw_load()
3446 name = "ipw2200-sniffer.fw"; in ipw_load()
3450 name = "ipw2200-bss.fw"; in ipw_load()
3455 rc = -EINVAL; in ipw_load()
3469 fw = (void *)raw->data; in ipw_load()
3470 boot_img = &fw->data[0]; in ipw_load()
3471 ucode_img = &fw->data[le32_to_cpu(fw->boot_size)]; in ipw_load()
3472 fw_img = &fw->data[le32_to_cpu(fw->boot_size) + in ipw_load()
3473 le32_to_cpu(fw->ucode_size)]; in ipw_load()
3475 if (!priv->rxq) in ipw_load()
3476 priv->rxq = ipw_rx_queue_alloc(priv); in ipw_load()
3478 ipw_rx_queue_reset(priv, priv->rxq); in ipw_load()
3479 if (!priv->rxq) { in ipw_load()
3481 rc = -ENOMEM; in ipw_load()
3488 priv->status &= ~STATUS_INT_ENABLED; in ipw_load()
3502 IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND); in ipw_load()
3505 rc = ipw_load_firmware(priv, boot_img, le32_to_cpu(fw->boot_size)); in ipw_load()
3527 rc = ipw_load_ucode(priv, ucode_img, le32_to_cpu(fw->ucode_size)); in ipw_load()
3537 rc = ipw_load_firmware(priv, fw_img, le32_to_cpu(fw->fw_size)); in ipw_load()
3565 retries--; in ipw_load()
3569 IPW_ERROR("TODO: Handle parity error -- schedule restart?\n"); in ipw_load()
3570 rc = -EIO; in ipw_load()
3587 priv->eeprom_delay = 1; in ipw_load()
3598 ipw_write32(priv, IPW_RX_READ_INDEX, priv->rxq->read); in ipw_load()
3609 if (priv->rxq) { in ipw_load()
3610 ipw_rx_queue_free(priv, priv->rxq); in ipw_load()
3611 priv->rxq = NULL; in ipw_load()
3651 * ipw_rx_queue_space - Return number of free slots available in queue.
3655 int s = q->read - q->write; in ipw_rx_queue_space()
3659 s -= 2; in ipw_rx_queue_space()
3667 int s = q->last_used - q->first_empty; in ipw_tx_queue_space()
3669 s += q->n_bd; in ipw_tx_queue_space()
3670 s -= 2; /* keep some reserve to not confuse empty and full situations */ in ipw_tx_queue_space()
3698 q->n_bd = count; in ipw_queue_init()
3700 q->low_mark = q->n_bd / 4; in ipw_queue_init()
3701 if (q->low_mark < 4) in ipw_queue_init()
3702 q->low_mark = 4; in ipw_queue_init()
3704 q->high_mark = q->n_bd / 8; in ipw_queue_init()
3705 if (q->high_mark < 2) in ipw_queue_init()
3706 q->high_mark = 2; in ipw_queue_init()
3708 q->first_empty = q->last_used = 0; in ipw_queue_init()
3709 q->reg_r = read; in ipw_queue_init()
3710 q->reg_w = write; in ipw_queue_init()
3712 ipw_write32(priv, base, q->dma_addr); in ipw_queue_init()
3724 struct pci_dev *dev = priv->pci_dev; in ipw_queue_tx_init()
3726 q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL); in ipw_queue_tx_init()
3727 if (!q->txb) in ipw_queue_tx_init()
3728 return -ENOMEM; in ipw_queue_tx_init()
3730 q->bd = in ipw_queue_tx_init()
3731 dma_alloc_coherent(&dev->dev, sizeof(q->bd[0]) * count, in ipw_queue_tx_init()
3732 &q->q.dma_addr, GFP_KERNEL); in ipw_queue_tx_init()
3733 if (!q->bd) { in ipw_queue_tx_init()
3735 sizeof(q->bd[0]) * count); in ipw_queue_tx_init()
3736 kfree(q->txb); in ipw_queue_tx_init()
3737 q->txb = NULL; in ipw_queue_tx_init()
3738 return -ENOMEM; in ipw_queue_tx_init()
3741 ipw_queue_init(priv, &q->q, count, read, write, base, size); in ipw_queue_tx_init()
3746 * Free one TFD, those at index [txq->q.last_used].
3755 struct tfd_frame *bd = &txq->bd[txq->q.last_used]; in ipw_queue_tx_free_tfd()
3756 struct pci_dev *dev = priv->pci_dev; in ipw_queue_tx_free_tfd()
3760 if (bd->control_flags.message_type == TX_HOST_COMMAND_TYPE) in ipw_queue_tx_free_tfd()
3765 if (le32_to_cpu(bd->u.data.num_chunks) > NUM_TFD_CHUNKS) { in ipw_queue_tx_free_tfd()
3767 le32_to_cpu(bd->u.data.num_chunks)); in ipw_queue_tx_free_tfd()
3773 for (i = 0; i < le32_to_cpu(bd->u.data.num_chunks); i++) { in ipw_queue_tx_free_tfd()
3774 dma_unmap_single(&dev->dev, in ipw_queue_tx_free_tfd()
3775 le32_to_cpu(bd->u.data.chunk_ptr[i]), in ipw_queue_tx_free_tfd()
3776 le16_to_cpu(bd->u.data.chunk_len[i]), in ipw_queue_tx_free_tfd()
3778 if (txq->txb[txq->q.last_used]) { in ipw_queue_tx_free_tfd()
3779 libipw_txb_free(txq->txb[txq->q.last_used]); in ipw_queue_tx_free_tfd()
3780 txq->txb[txq->q.last_used] = NULL; in ipw_queue_tx_free_tfd()
3796 struct clx2_queue *q = &txq->q; in ipw_queue_tx_free()
3797 struct pci_dev *dev = priv->pci_dev; in ipw_queue_tx_free()
3799 if (q->n_bd == 0) in ipw_queue_tx_free()
3803 for (; q->first_empty != q->last_used; in ipw_queue_tx_free()
3804 q->last_used = ipw_queue_inc_wrap(q->last_used, q->n_bd)) { in ipw_queue_tx_free()
3809 dma_free_coherent(&dev->dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd, in ipw_queue_tx_free()
3810 q->dma_addr); in ipw_queue_tx_free()
3811 kfree(txq->txb); in ipw_queue_tx_free()
3825 ipw_queue_tx_free(priv, &priv->txq_cmd); in ipw_tx_queue_free()
3828 ipw_queue_tx_free(priv, &priv->txq[0]); in ipw_tx_queue_free()
3829 ipw_queue_tx_free(priv, &priv->txq[1]); in ipw_tx_queue_free()
3830 ipw_queue_tx_free(priv, &priv->txq[2]); in ipw_tx_queue_free()
3831 ipw_queue_tx_free(priv, &priv->txq[3]); in ipw_tx_queue_free()
3837 bssid[0] = priv->mac_addr[0]; in ipw_create_bssid()
3838 bssid[1] = priv->mac_addr[1]; in ipw_create_bssid()
3839 bssid[2] = priv->mac_addr[2]; in ipw_create_bssid()
3842 get_random_bytes(&bssid[3], ETH_ALEN - 3); in ipw_create_bssid()
3853 for (i = 0; i < priv->num_stations; i++) { in ipw_add_station()
3854 if (ether_addr_equal(priv->stations[i], bssid)) { in ipw_add_station()
3856 priv->missed_adhoc_beacons = 0; in ipw_add_station()
3857 if (!(priv->config & CFG_STATIC_CHANNEL)) in ipw_add_station()
3859 priv->config &= ~CFG_ADHOC_PERSIST; in ipw_add_station()
3873 memcpy(priv->stations[i], bssid, ETH_ALEN); in ipw_add_station()
3876 priv->num_stations++; in ipw_add_station()
3885 for (i = 0; i < priv->num_stations; i++) in ipw_find_station()
3886 if (ether_addr_equal(priv->stations[i], bssid)) in ipw_find_station()
3896 if (priv->status & STATUS_ASSOCIATING) { in ipw_send_disassociate()
3898 schedule_work(&priv->disassociate); in ipw_send_disassociate()
3902 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw_send_disassociate()
3909 priv->assoc_request.bssid, in ipw_send_disassociate()
3910 priv->assoc_request.channel); in ipw_send_disassociate()
3912 priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED); in ipw_send_disassociate()
3913 priv->status |= STATUS_DISASSOCIATING; in ipw_send_disassociate()
3916 priv->assoc_request.assoc_type = HC_DISASSOC_QUIET; in ipw_send_disassociate()
3918 priv->assoc_request.assoc_type = HC_DISASSOCIATE; in ipw_send_disassociate()
3920 err = ipw_send_associate(priv, &priv->assoc_request); in ipw_send_disassociate()
3932 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) in ipw_disassociate()
3935 netif_carrier_off(priv->net_dev); in ipw_disassociate()
3943 mutex_lock(&priv->mutex); in ipw_bg_disassociate()
3945 mutex_unlock(&priv->mutex); in ipw_bg_disassociate()
3954 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) { in ipw_system_config()
3955 priv->sys_config.accept_all_data_frames = 1; in ipw_system_config()
3956 priv->sys_config.accept_non_directed_frames = 1; in ipw_system_config()
3957 priv->sys_config.accept_all_mgmt_bcpr = 1; in ipw_system_config()
3958 priv->sys_config.accept_all_mgmt_frames = 1; in ipw_system_config()
4007 "DSSS-OFDM operation"},
4035 return ((depth-1)*prev_avg + val)/depth; in exponential_average()
4040 avg->sum -= avg->entries[avg->pos]; in average_add()
4041 avg->sum += val; in average_add()
4042 avg->entries[avg->pos++] = val; in average_add()
4043 if (unlikely(avg->pos == AVG_ENTRIES)) { in average_add()
4044 avg->init = 1; in average_add()
4045 avg->pos = 0; in average_add()
4051 if (!unlikely(avg->init)) { in average_value()
4052 if (avg->pos) in average_value()
4053 return avg->sum / avg->pos; in average_value()
4057 return avg->sum / AVG_ENTRIES; in average_value()
4064 priv->quality = 0; in ipw_reset_stats()
4066 average_init(&priv->average_missed_beacons); in ipw_reset_stats()
4067 priv->exp_avg_rssi = -60; in ipw_reset_stats()
4068 priv->exp_avg_noise = -85 + 0x100; in ipw_reset_stats()
4070 priv->last_rate = 0; in ipw_reset_stats()
4071 priv->last_missed_beacons = 0; in ipw_reset_stats()
4072 priv->last_rx_packets = 0; in ipw_reset_stats()
4073 priv->last_tx_packets = 0; in ipw_reset_stats()
4074 priv->last_tx_failures = 0; in ipw_reset_stats()
4079 &priv->last_rx_err, &len); in ipw_reset_stats()
4081 &priv->last_tx_failures, &len); in ipw_reset_stats()
4084 priv->missed_adhoc_beacons = 0; in ipw_reset_stats()
4085 priv->missed_beacons = 0; in ipw_reset_stats()
4086 priv->tx_packets = 0; in ipw_reset_stats()
4087 priv->rx_packets = 0; in ipw_reset_stats()
4094 u32 mask = priv->rates_mask; in ipw_get_max_rate()
4097 if (priv->assoc_request.ieee_mode == IPW_B_MODE) in ipw_get_max_rate()
4132 if (priv->ieee->mode == IEEE_B) in ipw_get_max_rate()
4143 if (!(priv->status & STATUS_ASSOCIATED)) in ipw_get_current_rate()
4146 if (priv->tx_packets > IPW_REAL_RATE_RX_PACKET_THRESHOLD) { in ipw_get_current_rate()
4199 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw_gather_stats()
4200 priv->quality = 0; in ipw_gather_stats()
4206 &priv->missed_beacons, &len); in ipw_gather_stats()
4207 missed_beacons_delta = priv->missed_beacons - priv->last_missed_beacons; in ipw_gather_stats()
4208 priv->last_missed_beacons = priv->missed_beacons; in ipw_gather_stats()
4209 if (priv->assoc_request.beacon_interval) { in ipw_gather_stats()
4211 (HZ * le16_to_cpu(priv->assoc_request.beacon_interval)) / in ipw_gather_stats()
4216 average_add(&priv->average_missed_beacons, missed_beacons_percent); in ipw_gather_stats()
4219 rx_err_delta = rx_err - priv->last_rx_err; in ipw_gather_stats()
4220 priv->last_rx_err = rx_err; in ipw_gather_stats()
4223 tx_failures_delta = tx_failures - priv->last_tx_failures; in ipw_gather_stats()
4224 priv->last_tx_failures = tx_failures; in ipw_gather_stats()
4226 rx_packets_delta = priv->rx_packets - priv->last_rx_packets; in ipw_gather_stats()
4227 priv->last_rx_packets = priv->rx_packets; in ipw_gather_stats()
4229 tx_packets_delta = priv->tx_packets - priv->last_tx_packets; in ipw_gather_stats()
4230 priv->last_tx_packets = priv->tx_packets; in ipw_gather_stats()
4237 * RSSI: 100% = > -50, 0% = < -80 in ipw_gather_stats()
4244 beacon_quality = 100 - missed_beacons_percent; in ipw_gather_stats()
4248 beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 / in ipw_gather_stats()
4249 (100 - BEACON_THRESHOLD); in ipw_gather_stats()
4253 priv->last_rate = ipw_get_current_rate(priv); in ipw_gather_stats()
4255 rate_quality = priv->last_rate * 40 / max_rate + 60; in ipw_gather_stats()
4257 rate_quality, priv->last_rate / 1000000); in ipw_gather_stats()
4260 rx_quality = 100 - (rx_err_delta * 100) / in ipw_gather_stats()
4268 tx_quality = 100 - (tx_failures_delta * 100) / in ipw_gather_stats()
4275 rssi = priv->exp_avg_rssi; in ipw_gather_stats()
4278 (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) * in ipw_gather_stats()
4279 (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) - in ipw_gather_stats()
4280 (priv->ieee->perfect_rssi - rssi) * in ipw_gather_stats()
4281 (15 * (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) + in ipw_gather_stats()
4282 62 * (priv->ieee->perfect_rssi - rssi))) / in ipw_gather_stats()
4283 ((priv->ieee->perfect_rssi - priv->ieee->worst_rssi) * in ipw_gather_stats()
4284 (priv->ieee->perfect_rssi - priv->ieee->worst_rssi)); in ipw_gather_stats()
4313 priv->quality = quality; in ipw_gather_stats()
4315 schedule_delayed_work(&priv->gather_stats, IPW_STATS_INTERVAL); in ipw_gather_stats()
4322 mutex_lock(&priv->mutex); in ipw_bg_gather_stats()
4324 mutex_unlock(&priv->mutex); in ipw_bg_gather_stats()
4328 * 1st missed -> roaming_threshold, just wait, don't do any scan/roam.
4329 * roaming_threshold -> disassociate_threshold, scan and roam for better signal.
4335 priv->notif_missed_beacons = missed_count; in ipw_handle_missed_beacon()
4337 if (missed_count > priv->disassociate_threshold && in ipw_handle_missed_beacon()
4338 priv->status & STATUS_ASSOCIATED) { in ipw_handle_missed_beacon()
4344 "Missed beacon: %d - disassociate\n", missed_count); in ipw_handle_missed_beacon()
4345 priv->status &= ~STATUS_ROAMING; in ipw_handle_missed_beacon()
4346 if (priv->status & STATUS_SCANNING) { in ipw_handle_missed_beacon()
4350 schedule_work(&priv->abort_scan); in ipw_handle_missed_beacon()
4353 schedule_work(&priv->disassociate); in ipw_handle_missed_beacon()
4357 if (priv->status & STATUS_ROAMING) { in ipw_handle_missed_beacon()
4361 "Missed beacon: %d - roam in progress\n", in ipw_handle_missed_beacon()
4367 (missed_count > priv->roaming_threshold && in ipw_handle_missed_beacon()
4368 missed_count <= priv->disassociate_threshold)) { in ipw_handle_missed_beacon()
4374 "Missed beacon: %d - initiate " in ipw_handle_missed_beacon()
4376 if (!(priv->status & STATUS_ROAMING)) { in ipw_handle_missed_beacon()
4377 priv->status |= STATUS_ROAMING; in ipw_handle_missed_beacon()
4378 if (!(priv->status & STATUS_SCANNING)) in ipw_handle_missed_beacon()
4379 schedule_delayed_work(&priv->request_scan, 0); in ipw_handle_missed_beacon()
4384 if (priv->status & STATUS_SCANNING && in ipw_handle_missed_beacon()
4387 * stuck (only if we aren't roaming -- in ipw_handle_missed_beacon()
4392 schedule_work(&priv->abort_scan); in ipw_handle_missed_beacon()
4407 wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); in ipw_scan_event()
4412 /* Only userspace-requested scan completion events go out immediately */ in handle_scan_event()
4413 if (!priv->user_requested_scan) { in handle_scan_event()
4414 schedule_delayed_work(&priv->scan_event, in handle_scan_event()
4417 priv->user_requested_scan = 0; in handle_scan_event()
4418 mod_delayed_work(system_wq, &priv->scan_event, 0); in handle_scan_event()
4429 u16 size = le16_to_cpu(notif->size); in ipw_rx_notification()
4431 IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", notif->subtype, size); in ipw_rx_notification()
4433 switch (notif->subtype) { in ipw_rx_notification()
4435 struct notif_association *assoc = ¬if->u.assoc; in ipw_rx_notification()
4437 switch (assoc->state) { in ipw_rx_notification()
4442 priv->essid_len, priv->essid, in ipw_rx_notification()
4443 priv->bssid); in ipw_rx_notification()
4445 switch (priv->ieee->iw_mode) { in ipw_rx_notification()
4447 memcpy(priv->ieee->bssid, in ipw_rx_notification()
4448 priv->bssid, ETH_ALEN); in ipw_rx_notification()
4452 memcpy(priv->ieee->bssid, in ipw_rx_notification()
4453 priv->bssid, ETH_ALEN); in ipw_rx_notification()
4456 priv->num_stations = 0; in ipw_rx_notification()
4461 &priv->adhoc_check, in ipw_rx_notification()
4462 le16_to_cpu(priv-> in ipw_rx_notification()
4468 priv->status &= ~STATUS_ASSOCIATING; in ipw_rx_notification()
4469 priv->status |= STATUS_ASSOCIATED; in ipw_rx_notification()
4470 schedule_work(&priv->system_config); in ipw_rx_notification()
4474 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_control)) in ipw_rx_notification()
4475 if ((priv->status & STATUS_AUTH) && in ipw_rx_notification()
4476 (IPW_GET_PACKET_STYPE(¬if->u.raw) in ipw_rx_notification()
4486 .len = size - 1, in ipw_rx_notification()
4492 libipw_rx_mgt(priv-> in ipw_rx_notification()
4497 ¬if->u.raw, &stats); in ipw_rx_notification()
4502 schedule_work(&priv->link_up); in ipw_rx_notification()
4508 if (priv-> in ipw_rx_notification()
4512 = ¬if->u.auth; in ipw_rx_notification()
4516 "deauthenticated: '%*pE' %pM: (0x%04X) - %s\n", in ipw_rx_notification()
4517 priv->essid_len, in ipw_rx_notification()
4518 priv->essid, in ipw_rx_notification()
4519 priv->bssid, in ipw_rx_notification()
4520 le16_to_cpu(auth->status), in ipw_rx_notification()
4523 (auth->status))); in ipw_rx_notification()
4525 priv->status &= in ipw_rx_notification()
4530 schedule_work(&priv->link_down); in ipw_rx_notification()
4537 priv->essid_len, priv->essid, in ipw_rx_notification()
4538 priv->bssid); in ipw_rx_notification()
4543 if (priv->status & STATUS_AUTH) { in ipw_rx_notification()
4550 *)¬if->u.raw; in ipw_rx_notification()
4555 le16_to_cpu(resp->status), in ipw_rx_notification()
4558 (resp->status))); in ipw_rx_notification()
4564 priv->essid_len, priv->essid, in ipw_rx_notification()
4565 priv->bssid); in ipw_rx_notification()
4567 priv->status &= in ipw_rx_notification()
4571 if (priv->assoc_network in ipw_rx_notification()
4572 && (priv->assoc_network-> in ipw_rx_notification()
4578 schedule_work(&priv->link_down); in ipw_rx_notification()
4588 assoc->state); in ipw_rx_notification()
4596 struct notif_authenticate *auth = ¬if->u.auth; in ipw_rx_notification()
4597 switch (auth->state) { in ipw_rx_notification()
4601 priv->essid_len, priv->essid, in ipw_rx_notification()
4602 priv->bssid); in ipw_rx_notification()
4603 priv->status |= STATUS_AUTH; in ipw_rx_notification()
4607 if (priv->status & STATUS_AUTH) { in ipw_rx_notification()
4611 le16_to_cpu(auth->status), in ipw_rx_notification()
4613 (auth-> in ipw_rx_notification()
4619 priv->essid_len, priv->essid, in ipw_rx_notification()
4620 priv->bssid); in ipw_rx_notification()
4622 priv->status &= ~(STATUS_ASSOCIATING | in ipw_rx_notification()
4626 schedule_work(&priv->link_down); in ipw_rx_notification()
4675 IPW_DEBUG_NOTIF("auth: failure - %d\n", in ipw_rx_notification()
4676 auth->state); in ipw_rx_notification()
4684 ¬if->u.channel_result; in ipw_rx_notification()
4688 x->channel_num); in ipw_rx_notification()
4698 struct notif_scan_complete *x = ¬if->u.scan_complete; in ipw_rx_notification()
4702 "%d status\n", x->scan_type, in ipw_rx_notification()
4703 x->num_channels, x->status); in ipw_rx_notification()
4710 priv->status &= in ipw_rx_notification()
4713 wake_up_interruptible(&priv->wait_state); in ipw_rx_notification()
4714 cancel_delayed_work(&priv->scan_check); in ipw_rx_notification()
4716 if (priv->status & STATUS_EXIT_PENDING) in ipw_rx_notification()
4719 priv->ieee->scans++; in ipw_rx_notification()
4722 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw_rx_notification()
4723 priv->status |= STATUS_SCAN_FORCED; in ipw_rx_notification()
4724 schedule_delayed_work(&priv->request_scan, 0); in ipw_rx_notification()
4727 priv->status &= ~STATUS_SCAN_FORCED; in ipw_rx_notification()
4731 if (priv->status & STATUS_DIRECT_SCAN_PENDING) in ipw_rx_notification()
4732 schedule_delayed_work(&priv->request_direct_scan, 0); in ipw_rx_notification()
4734 if (!(priv->status & (STATUS_ASSOCIATED | in ipw_rx_notification()
4738 schedule_work(&priv->associate); in ipw_rx_notification()
4739 else if (priv->status & STATUS_ROAMING) { in ipw_rx_notification()
4740 if (x->status == SCAN_COMPLETED_STATUS_COMPLETE) in ipw_rx_notification()
4745 schedule_work(&priv->roam); in ipw_rx_notification()
4748 priv->status &= ~STATUS_ROAMING; in ipw_rx_notification()
4749 } else if (priv->status & STATUS_SCAN_PENDING) in ipw_rx_notification()
4750 schedule_delayed_work(&priv->request_scan, 0); in ipw_rx_notification()
4751 else if (priv->config & CFG_BACKGROUND_SCAN in ipw_rx_notification()
4752 && priv->status & STATUS_ASSOCIATED) in ipw_rx_notification()
4753 schedule_delayed_work(&priv->request_scan, in ipw_rx_notification()
4765 if (x->status == SCAN_COMPLETED_STATUS_COMPLETE) in ipw_rx_notification()
4771 struct notif_frag_length *x = ¬if->u.frag_len; in ipw_rx_notification()
4775 le16_to_cpu(x->frag_length)); in ipw_rx_notification()
4785 ¬if->u.link_deterioration; in ipw_rx_notification()
4790 x->silence_notification_type, in ipw_rx_notification()
4791 x->silence_count); in ipw_rx_notification()
4792 memcpy(&priv->last_link_deterioration, x, in ipw_rx_notification()
4804 if (priv->hcmd in ipw_rx_notification()
4805 && priv->hcmd->cmd != HOST_CMD_DINO_CONFIG) in ipw_rx_notification()
4812 struct notif_beacon_state *x = ¬if->u.beacon_state; in ipw_rx_notification()
4820 if (le32_to_cpu(x->state) == in ipw_rx_notification()
4823 le32_to_cpu(x-> in ipw_rx_notification()
4830 struct notif_tgi_tx_key *x = ¬if->u.tgi_tx_key; in ipw_rx_notification()
4834 x->key_state, x->security_type, in ipw_rx_notification()
4835 x->station_index); in ipw_rx_notification()
4846 struct notif_calibration *x = ¬if->u.calibration; in ipw_rx_notification()
4849 memcpy(&priv->calib, x, sizeof(*x)); in ipw_rx_notification()
4862 priv->exp_avg_noise = in ipw_rx_notification()
4863 exponential_average(priv->exp_avg_noise, in ipw_rx_notification()
4864 (u8) (le32_to_cpu(notif->u.noise.value) & 0xff), in ipw_rx_notification()
4870 ("Noise stat is wrong size %d (should be %zd)\n", in ipw_rx_notification()
4878 notif->subtype, notif->flags, size); in ipw_rx_notification()
4895 rc = ipw_queue_tx_init(priv, &priv->txq_cmd, nTxCmd, in ipw_queue_reset()
4905 rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx, in ipw_queue_reset()
4913 rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx, in ipw_queue_reset()
4921 rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx, in ipw_queue_reset()
4929 rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx, in ipw_queue_reset()
4938 priv->rx_bufs_min = 0; in ipw_queue_reset()
4939 priv->rx_pend_max = 0; in ipw_queue_reset()
4965 struct clx2_queue *q = &txq->q; in ipw_queue_tx_reclaim()
4967 hw_tail = ipw_read32(priv, q->reg_r); in ipw_queue_tx_reclaim()
4968 if (hw_tail >= q->n_bd) { in ipw_queue_tx_reclaim()
4970 ("Read index for DMA queue (%d) is out of range [0-%d)\n", in ipw_queue_tx_reclaim()
4971 hw_tail, q->n_bd); in ipw_queue_tx_reclaim()
4974 for (; q->last_used != hw_tail; in ipw_queue_tx_reclaim()
4975 q->last_used = ipw_queue_inc_wrap(q->last_used, q->n_bd)) { in ipw_queue_tx_reclaim()
4977 priv->tx_packets++; in ipw_queue_tx_reclaim()
4980 if ((ipw_tx_queue_space(q) > q->low_mark) && in ipw_queue_tx_reclaim()
4982 netif_wake_queue(priv->net_dev); in ipw_queue_tx_reclaim()
4983 used = q->first_empty - q->last_used; in ipw_queue_tx_reclaim()
4985 used += q->n_bd; in ipw_queue_tx_reclaim()
4993 struct clx2_tx_queue *txq = &priv->txq_cmd; in ipw_queue_tx_hcmd()
4994 struct clx2_queue *q = &txq->q; in ipw_queue_tx_hcmd()
4999 return -EBUSY; in ipw_queue_tx_hcmd()
5002 tfd = &txq->bd[q->first_empty]; in ipw_queue_tx_hcmd()
5003 txq->txb[q->first_empty] = NULL; in ipw_queue_tx_hcmd()
5006 tfd->control_flags.message_type = TX_HOST_COMMAND_TYPE; in ipw_queue_tx_hcmd()
5007 tfd->control_flags.control_bits = TFD_NEED_IRQ_MASK; in ipw_queue_tx_hcmd()
5008 priv->hcmd_seq++; in ipw_queue_tx_hcmd()
5009 tfd->u.cmd.index = hcmd; in ipw_queue_tx_hcmd()
5010 tfd->u.cmd.length = len; in ipw_queue_tx_hcmd()
5011 memcpy(tfd->u.cmd.payload, buf, len); in ipw_queue_tx_hcmd()
5012 q->first_empty = ipw_queue_inc_wrap(q->first_empty, q->n_bd); in ipw_queue_tx_hcmd()
5013 ipw_write32(priv, q->reg_w, q->first_empty); in ipw_queue_tx_hcmd()
5030 * to -- the driver can read up to (but not including) this position and get
5034 * The WRITE index maps to the last position the driver has read from -- the
5037 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
5041 * INDEX position, and WRITE to the last (READ - 1 wrapped)
5049 * + A list of pre-allocated SKBs is stored in ipw->rxq->rx_free. When
5050 * ipw->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
5051 * to replensish the ipw->rxq->rx_free.
5053 * ipw->rxq is replenished and the READ INDEX is updated (updating the
5056 * detached from the ipw->rxq. The driver 'processed' index is updated.
5057 * + The Host/Firmware ipw->rxq is replenished at tasklet time from the rx_free
5058 * list. If there are no allocated buffers in ipw->rxq->rx_free, the READ
5059 * INDEX is not incremented and ipw->status(RX_STALLED) is set. If there
5073 * -- enable interrupts --
5074 * ISR - ipw_rx() Detach ipw_rx_mem_buffers from pool up to the
5085 * and we have free pre-allocated buffers, fill the ranks as much
5094 struct ipw_rx_queue *rxq = priv->rxq; in ipw_rx_queue_restock()
5100 spin_lock_irqsave(&rxq->lock, flags); in ipw_rx_queue_restock()
5101 write = rxq->write; in ipw_rx_queue_restock()
5102 while ((ipw_rx_queue_space(rxq) > 0) && (rxq->free_count)) { in ipw_rx_queue_restock()
5103 element = rxq->rx_free.next; in ipw_rx_queue_restock()
5107 ipw_write32(priv, IPW_RFDS_TABLE_LOWER + rxq->write * RFD_SIZE, in ipw_rx_queue_restock()
5108 rxb->dma_addr); in ipw_rx_queue_restock()
5109 rxq->queue[rxq->write] = rxb; in ipw_rx_queue_restock()
5110 rxq->write = (rxq->write + 1) % RX_QUEUE_SIZE; in ipw_rx_queue_restock()
5111 rxq->free_count--; in ipw_rx_queue_restock()
5113 spin_unlock_irqrestore(&rxq->lock, flags); in ipw_rx_queue_restock()
5115 /* If the pre-allocated buffer pool is dropping low, schedule to in ipw_rx_queue_restock()
5117 if (rxq->free_count <= RX_LOW_WATERMARK) in ipw_rx_queue_restock()
5118 schedule_work(&priv->rx_replenish); in ipw_rx_queue_restock()
5121 if (write != rxq->write) in ipw_rx_queue_restock()
5122 ipw_write32(priv, IPW_RX_WRITE_INDEX, rxq->write); in ipw_rx_queue_restock()
5134 struct ipw_rx_queue *rxq = priv->rxq; in ipw_rx_queue_replenish()
5139 spin_lock_irqsave(&rxq->lock, flags); in ipw_rx_queue_replenish()
5140 while (!list_empty(&rxq->rx_used)) { in ipw_rx_queue_replenish()
5141 element = rxq->rx_used.next; in ipw_rx_queue_replenish()
5143 rxb->skb = alloc_skb(IPW_RX_BUF_SIZE, GFP_ATOMIC); in ipw_rx_queue_replenish()
5144 if (!rxb->skb) { in ipw_rx_queue_replenish()
5146 priv->net_dev->name); in ipw_rx_queue_replenish()
5147 /* We don't reschedule replenish work here -- we will in ipw_rx_queue_replenish()
5154 rxb->dma_addr = in ipw_rx_queue_replenish()
5155 dma_map_single(&priv->pci_dev->dev, rxb->skb->data, in ipw_rx_queue_replenish()
5158 list_add_tail(&rxb->list, &rxq->rx_free); in ipw_rx_queue_replenish()
5159 rxq->free_count++; in ipw_rx_queue_replenish()
5161 spin_unlock_irqrestore(&rxq->lock, flags); in ipw_rx_queue_replenish()
5170 mutex_lock(&priv->mutex); in ipw_bg_rx_queue_replenish()
5172 mutex_unlock(&priv->mutex); in ipw_bg_rx_queue_replenish()
5188 if (rxq->pool[i].skb != NULL) { in ipw_rx_queue_free()
5189 dma_unmap_single(&priv->pci_dev->dev, in ipw_rx_queue_free()
5190 rxq->pool[i].dma_addr, in ipw_rx_queue_free()
5192 dev_kfree_skb(rxq->pool[i].skb); in ipw_rx_queue_free()
5209 spin_lock_init(&rxq->lock); in ipw_rx_queue_alloc()
5210 INIT_LIST_HEAD(&rxq->rx_free); in ipw_rx_queue_alloc()
5211 INIT_LIST_HEAD(&rxq->rx_used); in ipw_rx_queue_alloc()
5215 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); in ipw_rx_queue_alloc()
5219 rxq->read = rxq->write = 0; in ipw_rx_queue_alloc()
5220 rxq->free_count = 0; in ipw_rx_queue_alloc()
5231 return priv->rates_mask & LIBIPW_OFDM_RATE_6MB_MASK ? in ipw_is_rate_in_mask()
5234 return priv->rates_mask & LIBIPW_OFDM_RATE_9MB_MASK ? in ipw_is_rate_in_mask()
5237 return priv-> in ipw_is_rate_in_mask()
5240 return priv-> in ipw_is_rate_in_mask()
5243 return priv-> in ipw_is_rate_in_mask()
5246 return priv-> in ipw_is_rate_in_mask()
5249 return priv-> in ipw_is_rate_in_mask()
5252 return priv-> in ipw_is_rate_in_mask()
5262 return priv->rates_mask & LIBIPW_CCK_RATE_1MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5264 return priv->rates_mask & LIBIPW_CCK_RATE_2MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5266 return priv->rates_mask & LIBIPW_CCK_RATE_5MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5268 return priv->rates_mask & LIBIPW_CCK_RATE_11MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5278 return priv->rates_mask & LIBIPW_OFDM_RATE_6MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5280 return priv->rates_mask & LIBIPW_OFDM_RATE_9MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5282 return priv->rates_mask & LIBIPW_OFDM_RATE_12MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5284 return priv->rates_mask & LIBIPW_OFDM_RATE_18MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5286 return priv->rates_mask & LIBIPW_OFDM_RATE_24MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5288 return priv->rates_mask & LIBIPW_OFDM_RATE_36MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5290 return priv->rates_mask & LIBIPW_OFDM_RATE_48MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5292 return priv->rates_mask & LIBIPW_OFDM_RATE_54MB_MASK ? 1 : 0; in ipw_is_rate_in_mask()
5305 num_rates = min(network->rates_len, (u8) IPW_MAX_RATES); in ipw_compatible_rates()
5306 rates->num_rates = 0; in ipw_compatible_rates()
5308 if (!ipw_is_rate_in_mask(priv, network->mode, in ipw_compatible_rates()
5309 network->rates[i])) { in ipw_compatible_rates()
5311 if (network->rates[i] & LIBIPW_BASIC_RATE_MASK) { in ipw_compatible_rates()
5314 network->rates[i]); in ipw_compatible_rates()
5315 rates->supported_rates[rates->num_rates++] = in ipw_compatible_rates()
5316 network->rates[i]; in ipw_compatible_rates()
5321 network->rates[i], priv->rates_mask); in ipw_compatible_rates()
5325 rates->supported_rates[rates->num_rates++] = network->rates[i]; in ipw_compatible_rates()
5328 num_rates = min(network->rates_ex_len, in ipw_compatible_rates()
5329 (u8) (IPW_MAX_RATES - num_rates)); in ipw_compatible_rates()
5331 if (!ipw_is_rate_in_mask(priv, network->mode, in ipw_compatible_rates()
5332 network->rates_ex[i])) { in ipw_compatible_rates()
5333 if (network->rates_ex[i] & LIBIPW_BASIC_RATE_MASK) { in ipw_compatible_rates()
5336 network->rates_ex[i]); in ipw_compatible_rates()
5337 rates->supported_rates[rates->num_rates++] = in ipw_compatible_rates()
5338 network->rates[i]; in ipw_compatible_rates()
5343 network->rates_ex[i], priv->rates_mask); in ipw_compatible_rates()
5347 rates->supported_rates[rates->num_rates++] = in ipw_compatible_rates()
5348 network->rates_ex[i]; in ipw_compatible_rates()
5358 for (i = 0; i < src->num_rates; i++) in ipw_copy_rates()
5359 dest->supported_rates[i] = src->supported_rates[i]; in ipw_copy_rates()
5360 dest->num_rates = src->num_rates; in ipw_copy_rates()
5364 * mask should ever be used -- right now all callers to add the scan rates are
5373 rates->supported_rates[rates->num_rates++] = in ipw_add_cck_scan_rates()
5377 rates->supported_rates[rates->num_rates++] = in ipw_add_cck_scan_rates()
5381 rates->supported_rates[rates->num_rates++] = basic_mask | in ipw_add_cck_scan_rates()
5385 rates->supported_rates[rates->num_rates++] = basic_mask | in ipw_add_cck_scan_rates()
5396 rates->supported_rates[rates->num_rates++] = basic_mask | in ipw_add_ofdm_scan_rates()
5400 rates->supported_rates[rates->num_rates++] = in ipw_add_ofdm_scan_rates()
5404 rates->supported_rates[rates->num_rates++] = basic_mask | in ipw_add_ofdm_scan_rates()
5408 rates->supported_rates[rates->num_rates++] = in ipw_add_ofdm_scan_rates()
5412 rates->supported_rates[rates->num_rates++] = basic_mask | in ipw_add_ofdm_scan_rates()
5416 rates->supported_rates[rates->num_rates++] = in ipw_add_ofdm_scan_rates()
5420 rates->supported_rates[rates->num_rates++] = in ipw_add_ofdm_scan_rates()
5424 rates->supported_rates[rates->num_rates++] = in ipw_add_ofdm_scan_rates()
5442 if ((priv->ieee->iw_mode == IW_MODE_ADHOC && in ipw_find_adhoc_network()
5443 !(network->capability & WLAN_CAPABILITY_IBSS))) { in ipw_find_adhoc_network()
5445 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5446 network->bssid); in ipw_find_adhoc_network()
5453 if ((network->ssid_len != match->network->ssid_len) || in ipw_find_adhoc_network()
5454 memcmp(network->ssid, match->network->ssid, in ipw_find_adhoc_network()
5455 network->ssid_len)) { in ipw_find_adhoc_network()
5456 IPW_DEBUG_MERGE("Network '%*pE (%pM)' excluded because of non-network ESSID.\n", in ipw_find_adhoc_network()
5457 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5458 network->bssid); in ipw_find_adhoc_network()
5464 if ((priv->config & CFG_STATIC_ESSID) && in ipw_find_adhoc_network()
5465 ((network->ssid_len != priv->essid_len) || in ipw_find_adhoc_network()
5466 memcmp(network->ssid, priv->essid, in ipw_find_adhoc_network()
5467 min(network->ssid_len, priv->essid_len)))) { in ipw_find_adhoc_network()
5469 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5470 network->bssid, priv->essid_len, in ipw_find_adhoc_network()
5471 priv->essid); in ipw_find_adhoc_network()
5479 if (network->time_stamp[0] < match->network->time_stamp[0]) { in ipw_find_adhoc_network()
5481 match->network->ssid_len, match->network->ssid); in ipw_find_adhoc_network()
5483 } else if (network->time_stamp[1] < match->network->time_stamp[1]) { in ipw_find_adhoc_network()
5485 match->network->ssid_len, match->network->ssid); in ipw_find_adhoc_network()
5490 if (priv->ieee->scan_age != 0 && in ipw_find_adhoc_network()
5491 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { in ipw_find_adhoc_network()
5493 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5494 network->bssid, in ipw_find_adhoc_network()
5495 jiffies_to_msecs(jiffies - in ipw_find_adhoc_network()
5496 network->last_scanned)); in ipw_find_adhoc_network()
5500 if ((priv->config & CFG_STATIC_CHANNEL) && in ipw_find_adhoc_network()
5501 (network->channel != priv->channel)) { in ipw_find_adhoc_network()
5503 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5504 network->bssid, in ipw_find_adhoc_network()
5505 network->channel, priv->channel); in ipw_find_adhoc_network()
5510 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) != in ipw_find_adhoc_network()
5511 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) { in ipw_find_adhoc_network()
5513 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5514 network->bssid, in ipw_find_adhoc_network()
5515 priv-> in ipw_find_adhoc_network()
5517 network-> in ipw_find_adhoc_network()
5523 if (ether_addr_equal(network->bssid, priv->bssid)) { in ipw_find_adhoc_network()
5525 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5526 network->bssid, priv->bssid); in ipw_find_adhoc_network()
5531 if (!libipw_is_valid_mode(priv->ieee, network->mode)) { in ipw_find_adhoc_network()
5533 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5534 network->bssid); in ipw_find_adhoc_network()
5542 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5543 network->bssid); in ipw_find_adhoc_network()
5549 network->ssid_len, network->ssid, in ipw_find_adhoc_network()
5550 network->bssid); in ipw_find_adhoc_network()
5559 ipw_copy_rates(&match->rates, &rates); in ipw_find_adhoc_network()
5560 match->network = network; in ipw_find_adhoc_network()
5562 network->ssid_len, network->ssid, network->bssid); in ipw_find_adhoc_network()
5573 .network = priv->assoc_network in ipw_merge_adhoc_network()
5576 if ((priv->status & STATUS_ASSOCIATED) && in ipw_merge_adhoc_network()
5577 (priv->ieee->iw_mode == IW_MODE_ADHOC)) { in ipw_merge_adhoc_network()
5578 /* First pass through ROAM process -- look for a better in ipw_merge_adhoc_network()
5582 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_merge_adhoc_network()
5583 list_for_each_entry(network, &priv->ieee->network_list, list) { in ipw_merge_adhoc_network()
5584 if (network != priv->assoc_network) in ipw_merge_adhoc_network()
5588 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_merge_adhoc_network()
5590 if (match.network == priv->assoc_network) { in ipw_merge_adhoc_network()
5596 mutex_lock(&priv->mutex); in ipw_merge_adhoc_network()
5597 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw_merge_adhoc_network()
5599 priv->essid_len, priv->essid); in ipw_merge_adhoc_network()
5604 priv->assoc_network = match.network; in ipw_merge_adhoc_network()
5605 mutex_unlock(&priv->mutex); in ipw_merge_adhoc_network()
5618 if ((priv->ieee->iw_mode == IW_MODE_INFRA && in ipw_best_network()
5619 !(network->capability & WLAN_CAPABILITY_ESS)) || in ipw_best_network()
5620 (priv->ieee->iw_mode == IW_MODE_ADHOC && in ipw_best_network()
5621 !(network->capability & WLAN_CAPABILITY_IBSS))) { in ipw_best_network()
5623 network->ssid_len, network->ssid, in ipw_best_network()
5624 network->bssid); in ipw_best_network()
5631 if ((network->ssid_len != match->network->ssid_len) || in ipw_best_network()
5632 memcmp(network->ssid, match->network->ssid, in ipw_best_network()
5633 network->ssid_len)) { in ipw_best_network()
5634 IPW_DEBUG_ASSOC("Network '%*pE (%pM)' excluded because of non-network ESSID.\n", in ipw_best_network()
5635 network->ssid_len, network->ssid, in ipw_best_network()
5636 network->bssid); in ipw_best_network()
5642 if ((priv->config & CFG_STATIC_ESSID) && in ipw_best_network()
5643 ((network->ssid_len != priv->essid_len) || in ipw_best_network()
5644 memcmp(network->ssid, priv->essid, in ipw_best_network()
5645 min(network->ssid_len, priv->essid_len)))) { in ipw_best_network()
5647 network->ssid_len, network->ssid, in ipw_best_network()
5648 network->bssid, priv->essid_len, in ipw_best_network()
5649 priv->essid); in ipw_best_network()
5656 if (match->network && match->network->stats.rssi > network->stats.rssi) { in ipw_best_network()
5658 network->ssid_len, network->ssid, in ipw_best_network()
5659 network->bssid, match->network->ssid_len, in ipw_best_network()
5660 match->network->ssid, match->network->bssid); in ipw_best_network()
5666 if (network->last_associate && in ipw_best_network()
5667 time_after(network->last_associate + (HZ * 3UL), jiffies)) { in ipw_best_network()
5669 network->ssid_len, network->ssid, in ipw_best_network()
5670 network->bssid, in ipw_best_network()
5671 jiffies_to_msecs(jiffies - in ipw_best_network()
5672 network->last_associate)); in ipw_best_network()
5677 if (priv->ieee->scan_age != 0 && in ipw_best_network()
5678 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { in ipw_best_network()
5680 network->ssid_len, network->ssid, in ipw_best_network()
5681 network->bssid, in ipw_best_network()
5682 jiffies_to_msecs(jiffies - in ipw_best_network()
5683 network->last_scanned)); in ipw_best_network()
5687 if ((priv->config & CFG_STATIC_CHANNEL) && in ipw_best_network()
5688 (network->channel != priv->channel)) { in ipw_best_network()
5690 network->ssid_len, network->ssid, in ipw_best_network()
5691 network->bssid, in ipw_best_network()
5692 network->channel, priv->channel); in ipw_best_network()
5697 if (((priv->capability & CAP_PRIVACY_ON) ? 1 : 0) != in ipw_best_network()
5698 ((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) { in ipw_best_network()
5700 network->ssid_len, network->ssid, in ipw_best_network()
5701 network->bssid, in ipw_best_network()
5702 priv->capability & CAP_PRIVACY_ON ? "on" : in ipw_best_network()
5704 network->capability & in ipw_best_network()
5709 if ((priv->config & CFG_STATIC_BSSID) && in ipw_best_network()
5710 !ether_addr_equal(network->bssid, priv->bssid)) { in ipw_best_network()
5712 network->ssid_len, network->ssid, in ipw_best_network()
5713 network->bssid, priv->bssid); in ipw_best_network()
5718 if (!libipw_is_valid_mode(priv->ieee, network->mode)) { in ipw_best_network()
5720 network->ssid_len, network->ssid, in ipw_best_network()
5721 network->bssid); in ipw_best_network()
5726 if (!libipw_is_valid_channel(priv->ieee, network->channel)) { in ipw_best_network()
5728 network->ssid_len, network->ssid, in ipw_best_network()
5729 network->bssid); in ipw_best_network()
5737 network->ssid_len, network->ssid, in ipw_best_network()
5738 network->bssid); in ipw_best_network()
5744 network->ssid_len, network->ssid, in ipw_best_network()
5745 network->bssid); in ipw_best_network()
5754 ipw_copy_rates(&match->rates, &rates); in ipw_best_network()
5755 match->network = network; in ipw_best_network()
5758 network->ssid_len, network->ssid, network->bssid); in ipw_best_network()
5766 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw_adhoc_create()
5772 * comes to creating a new ad-hoc network, we have tell the FW in ipw_adhoc_create()
5776 * chossen band. Attempting to create a new ad-hoc network in ipw_adhoc_create()
5781 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) { in ipw_adhoc_create()
5783 network->mode = IEEE_A; in ipw_adhoc_create()
5784 i = libipw_channel_to_index(priv->ieee, priv->channel); in ipw_adhoc_create()
5785 BUG_ON(i == -1); in ipw_adhoc_create()
5786 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY) { in ipw_adhoc_create()
5788 priv->channel = geo->a[0].channel; in ipw_adhoc_create()
5793 if (priv->ieee->mode & IEEE_G) in ipw_adhoc_create()
5794 network->mode = IEEE_G; in ipw_adhoc_create()
5796 network->mode = IEEE_B; in ipw_adhoc_create()
5797 i = libipw_channel_to_index(priv->ieee, priv->channel); in ipw_adhoc_create()
5798 BUG_ON(i == -1); in ipw_adhoc_create()
5799 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY) { in ipw_adhoc_create()
5801 priv->channel = geo->bg[0].channel; in ipw_adhoc_create()
5807 if (priv->ieee->mode & IEEE_A) { in ipw_adhoc_create()
5808 network->mode = IEEE_A; in ipw_adhoc_create()
5809 priv->channel = geo->a[0].channel; in ipw_adhoc_create()
5810 } else if (priv->ieee->mode & IEEE_G) { in ipw_adhoc_create()
5811 network->mode = IEEE_G; in ipw_adhoc_create()
5812 priv->channel = geo->bg[0].channel; in ipw_adhoc_create()
5814 network->mode = IEEE_B; in ipw_adhoc_create()
5815 priv->channel = geo->bg[0].channel; in ipw_adhoc_create()
5820 network->channel = priv->channel; in ipw_adhoc_create()
5821 priv->config |= CFG_ADHOC_PERSIST; in ipw_adhoc_create()
5822 ipw_create_bssid(priv, network->bssid); in ipw_adhoc_create()
5823 network->ssid_len = priv->essid_len; in ipw_adhoc_create()
5824 memcpy(network->ssid, priv->essid, priv->essid_len); in ipw_adhoc_create()
5825 memset(&network->stats, 0, sizeof(network->stats)); in ipw_adhoc_create()
5826 network->capability = WLAN_CAPABILITY_IBSS; in ipw_adhoc_create()
5827 if (!(priv->config & CFG_PREAMBLE_LONG)) in ipw_adhoc_create()
5828 network->capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; in ipw_adhoc_create()
5829 if (priv->capability & CAP_PRIVACY_ON) in ipw_adhoc_create()
5830 network->capability |= WLAN_CAPABILITY_PRIVACY; in ipw_adhoc_create()
5831 network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH); in ipw_adhoc_create()
5832 memcpy(network->rates, priv->rates.supported_rates, network->rates_len); in ipw_adhoc_create()
5833 network->rates_ex_len = priv->rates.num_rates - network->rates_len; in ipw_adhoc_create()
5834 memcpy(network->rates_ex, in ipw_adhoc_create()
5835 &priv->rates.supported_rates[network->rates_len], in ipw_adhoc_create()
5836 network->rates_ex_len); in ipw_adhoc_create()
5837 network->last_scanned = 0; in ipw_adhoc_create()
5838 network->flags = 0; in ipw_adhoc_create()
5839 network->last_associate = 0; in ipw_adhoc_create()
5840 network->time_stamp[0] = 0; in ipw_adhoc_create()
5841 network->time_stamp[1] = 0; in ipw_adhoc_create()
5842 network->beacon_interval = 100; /* Default */ in ipw_adhoc_create()
5843 network->listen_interval = 10; /* Default */ in ipw_adhoc_create()
5844 network->atim_window = 0; /* Default */ in ipw_adhoc_create()
5845 network->wpa_ie_len = 0; in ipw_adhoc_create()
5846 network->rsn_ie_len = 0; in ipw_adhoc_create()
5853 if (!(priv->ieee->sec.flags & (1 << index))) in ipw_send_tgi_tx_key()
5857 memcpy(key.key, priv->ieee->sec.keys[index], SCM_TEMPORAL_KEY_LENGTH); in ipw_send_tgi_tx_key()
5880 if (!(priv->ieee->sec.flags & (1 << i))) { in ipw_send_wep_keys()
5885 key.key_size = priv->ieee->sec.key_sizes[i]; in ipw_send_wep_keys()
5886 memcpy(key.key, priv->ieee->sec.keys[i], key.key_size); in ipw_send_wep_keys()
5894 if (priv->ieee->host_encrypt) in ipw_set_hw_decrypt_unicast()
5899 priv->sys_config.disable_unicast_decryption = 0; in ipw_set_hw_decrypt_unicast()
5900 priv->ieee->host_decrypt = 0; in ipw_set_hw_decrypt_unicast()
5903 priv->sys_config.disable_unicast_decryption = 1; in ipw_set_hw_decrypt_unicast()
5904 priv->ieee->host_decrypt = 1; in ipw_set_hw_decrypt_unicast()
5907 priv->sys_config.disable_unicast_decryption = 0; in ipw_set_hw_decrypt_unicast()
5908 priv->ieee->host_decrypt = 0; in ipw_set_hw_decrypt_unicast()
5911 priv->sys_config.disable_unicast_decryption = 1; in ipw_set_hw_decrypt_unicast()
5920 if (priv->ieee->host_encrypt) in ipw_set_hw_decrypt_multicast()
5925 priv->sys_config.disable_multicast_decryption = 0; in ipw_set_hw_decrypt_multicast()
5928 priv->sys_config.disable_multicast_decryption = 1; in ipw_set_hw_decrypt_multicast()
5931 priv->sys_config.disable_multicast_decryption = 0; in ipw_set_hw_decrypt_multicast()
5934 priv->sys_config.disable_multicast_decryption = 1; in ipw_set_hw_decrypt_multicast()
5943 switch (priv->ieee->sec.level) { in ipw_set_hwcrypto_keys()
5945 if (priv->ieee->sec.flags & SEC_ACTIVE_KEY) in ipw_set_hwcrypto_keys()
5948 priv->ieee->sec.active_key); in ipw_set_hwcrypto_keys()
5950 if (!priv->ieee->host_mc_decrypt) in ipw_set_hwcrypto_keys()
5954 if (priv->ieee->sec.flags & SEC_ACTIVE_KEY) in ipw_set_hwcrypto_keys()
5957 priv->ieee->sec.active_key); in ipw_set_hwcrypto_keys()
5961 ipw_set_hw_decrypt_unicast(priv, priv->ieee->sec.level); in ipw_set_hwcrypto_keys()
5962 ipw_set_hw_decrypt_multicast(priv, priv->ieee->sec.level); in ipw_set_hwcrypto_keys()
5974 if (priv->missed_adhoc_beacons++ > priv->disassociate_threshold && in ipw_adhoc_check()
5975 !(priv->config & CFG_ADHOC_PERSIST)) { in ipw_adhoc_check()
5978 "Missed beacon: %d - disassociate\n", in ipw_adhoc_check()
5979 priv->missed_adhoc_beacons); in ipw_adhoc_check()
5985 schedule_delayed_work(&priv->adhoc_check, in ipw_adhoc_check()
5986 le16_to_cpu(priv->assoc_request.beacon_interval)); in ipw_adhoc_check()
5993 mutex_lock(&priv->mutex); in ipw_bg_adhoc_check()
5995 mutex_unlock(&priv->mutex); in ipw_bg_adhoc_check()
6001 "[CFG 0x%08X]\n", priv->config); in ipw_debug_config()
6002 if (priv->config & CFG_STATIC_CHANNEL) in ipw_debug_config()
6003 IPW_DEBUG_INFO("Channel locked to %d\n", priv->channel); in ipw_debug_config()
6006 if (priv->config & CFG_STATIC_ESSID) in ipw_debug_config()
6008 priv->essid_len, priv->essid); in ipw_debug_config()
6011 if (priv->config & CFG_STATIC_BSSID) in ipw_debug_config()
6012 IPW_DEBUG_INFO("BSSID locked to %pM\n", priv->bssid); in ipw_debug_config()
6015 if (priv->capability & CAP_PRIVACY_ON) in ipw_debug_config()
6019 IPW_DEBUG_INFO("RATE MASK: 0x%08X\n", priv->rates_mask); in ipw_debug_config()
6028 u16 new_tx_rates = priv->rates_mask; in ipw_set_fixed_rate()
6033 switch (priv->ieee->freq_band) { in ipw_set_fixed_rate()
6036 if (priv->rates_mask & ~LIBIPW_OFDM_RATES_MASK) { in ipw_set_fixed_rate()
6098 if (priv->status & STATUS_SCAN_ABORTING) { in ipw_abort_scan()
6102 priv->status |= STATUS_SCAN_ABORTING; in ipw_abort_scan()
6117 geo = libipw_get_geo(priv->ieee); in ipw_add_scan_channels()
6119 if (priv->ieee->freq_band & LIBIPW_52GHZ_BAND) { in ipw_add_scan_channels()
6121 for (i = 0; i < geo->a_channels; i++) { in ipw_add_scan_channels()
6122 if ((priv->status & STATUS_ASSOCIATED) && in ipw_add_scan_channels()
6123 geo->a[i].channel == priv->channel) in ipw_add_scan_channels()
6126 scan->channels_list[channel_index] = geo->a[i].channel; in ipw_add_scan_channels()
6128 geo->a[i]. in ipw_add_scan_channels()
6135 scan->channels_list[start] = (u8) (IPW_A_MODE << 6) | in ipw_add_scan_channels()
6136 (channel_index - start); in ipw_add_scan_channels()
6141 if (priv->ieee->freq_band & LIBIPW_24GHZ_BAND) { in ipw_add_scan_channels()
6143 if (priv->config & CFG_SPEED_SCAN) { in ipw_add_scan_channels()
6151 while (channel_index < IPW_SCAN_CHANNELS - 1) { in ipw_add_scan_channels()
6153 priv->speed_scan[priv->speed_scan_pos]; in ipw_add_scan_channels()
6155 priv->speed_scan_pos = 0; in ipw_add_scan_channels()
6156 channel = priv->speed_scan[0]; in ipw_add_scan_channels()
6158 if ((priv->status & STATUS_ASSOCIATED) && in ipw_add_scan_channels()
6159 channel == priv->channel) { in ipw_add_scan_channels()
6160 priv->speed_scan_pos++; in ipw_add_scan_channels()
6169 if (channels[channel - 1] != 0) in ipw_add_scan_channels()
6172 channels[channel - 1] = 1; in ipw_add_scan_channels()
6173 priv->speed_scan_pos++; in ipw_add_scan_channels()
6175 scan->channels_list[channel_index] = channel; in ipw_add_scan_channels()
6177 libipw_channel_to_index(priv->ieee, channel); in ipw_add_scan_channels()
6179 geo->bg[index]. in ipw_add_scan_channels()
6186 for (i = 0; i < geo->bg_channels; i++) { in ipw_add_scan_channels()
6187 if ((priv->status & STATUS_ASSOCIATED) && in ipw_add_scan_channels()
6188 geo->bg[i].channel == priv->channel) in ipw_add_scan_channels()
6191 scan->channels_list[channel_index] = in ipw_add_scan_channels()
6192 geo->bg[i].channel; in ipw_add_scan_channels()
6194 geo->bg[i]. in ipw_add_scan_channels()
6203 scan->channels_list[start] = (u8) (IPW_B_MODE << 6) | in ipw_add_scan_channels()
6204 (channel_index - start); in ipw_add_scan_channels()
6216 if (priv->status & STATUS_ASSOCIATED in ipw_passive_dwell_time()
6217 && priv->assoc_network->beacon_interval > 10) in ipw_passive_dwell_time()
6218 return priv->assoc_network->beacon_interval - 10; in ipw_passive_dwell_time()
6228 if (!(priv->status & STATUS_INIT) || in ipw_request_scan_helper()
6229 (priv->status & STATUS_EXIT_PENDING)) in ipw_request_scan_helper()
6232 mutex_lock(&priv->mutex); in ipw_request_scan_helper()
6234 if (direct && (priv->direct_scan_ssid_len == 0)) { in ipw_request_scan_helper()
6236 priv->status &= ~STATUS_DIRECT_SCAN_PENDING; in ipw_request_scan_helper()
6240 if (priv->status & STATUS_SCANNING) { in ipw_request_scan_helper()
6242 priv->status |= direct ? STATUS_DIRECT_SCAN_PENDING : in ipw_request_scan_helper()
6247 if (!(priv->status & STATUS_SCAN_FORCED) && in ipw_request_scan_helper()
6248 priv->status & STATUS_SCAN_ABORTING) { in ipw_request_scan_helper()
6250 priv->status |= direct ? STATUS_DIRECT_SCAN_PENDING : in ipw_request_scan_helper()
6255 if (priv->status & STATUS_RF_KILL_MASK) { in ipw_request_scan_helper()
6257 priv->status |= direct ? STATUS_DIRECT_SCAN_PENDING : in ipw_request_scan_helper()
6263 scan.full_scan_index = cpu_to_le32(libipw_get_scans(priv->ieee)); in ipw_request_scan_helper()
6275 if (priv->config & CFG_SPEED_SCAN) in ipw_request_scan_helper()
6290 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw_request_scan_helper()
6294 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) { in ipw_request_scan_helper()
6297 channel = priv->channel; in ipw_request_scan_helper()
6302 channel = priv->channel; in ipw_request_scan_helper()
6316 * period. Scan aborts are timing sensitive and frequently in ipw_request_scan_helper()
6318 * set a small dwell_time here and just keep re-issuing in ipw_request_scan_helper()
6331 err = ipw_send_ssid(priv, priv->direct_scan_ssid, in ipw_request_scan_helper()
6332 priv->direct_scan_ssid_len); in ipw_request_scan_helper()
6340 } else if ((priv->status & STATUS_ROAMING) in ipw_request_scan_helper()
6341 || (!(priv->status & STATUS_ASSOCIATED) in ipw_request_scan_helper()
6342 && (priv->config & CFG_STATIC_ESSID) in ipw_request_scan_helper()
6344 err = ipw_send_ssid(priv, priv->essid, priv->essid_len); in ipw_request_scan_helper()
6367 priv->status |= STATUS_SCANNING; in ipw_request_scan_helper()
6369 priv->status &= ~STATUS_DIRECT_SCAN_PENDING; in ipw_request_scan_helper()
6370 priv->direct_scan_ssid_len = 0; in ipw_request_scan_helper()
6372 priv->status &= ~STATUS_SCAN_PENDING; in ipw_request_scan_helper()
6374 schedule_delayed_work(&priv->scan_check, IPW_SCAN_CHECK_WATCHDOG); in ipw_request_scan_helper()
6376 mutex_unlock(&priv->mutex); in ipw_request_scan_helper()
6405 mutex_lock(&priv->mutex); in ipw_bg_abort_scan()
6407 mutex_unlock(&priv->mutex); in ipw_bg_abort_scan()
6414 priv->ieee->wpa_enabled = value; in ipw_wpa_enable()
6420 struct libipw_device *ieee = priv->ieee; in ipw_wpa_set_auth_algs()
6428 ieee->open_wep = 0; in ipw_wpa_set_auth_algs()
6431 ieee->open_wep = 1; in ipw_wpa_set_auth_algs()
6434 ieee->open_wep = 1; in ipw_wpa_set_auth_algs()
6436 return -EINVAL; in ipw_wpa_set_auth_algs()
6438 if (ieee->set_security) in ipw_wpa_set_auth_algs()
6439 ieee->set_security(ieee->dev, &sec); in ipw_wpa_set_auth_algs()
6441 ret = -EOPNOTSUPP; in ipw_wpa_set_auth_algs()
6463 * WE-18 support
6472 struct libipw_device *ieee = priv->ieee; in ipw_wx_set_genie()
6476 if (wrqu->data.length > MAX_WPA_IE_LEN || in ipw_wx_set_genie()
6477 (wrqu->data.length && extra == NULL)) in ipw_wx_set_genie()
6478 return -EINVAL; in ipw_wx_set_genie()
6480 if (wrqu->data.length) { in ipw_wx_set_genie()
6481 buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL); in ipw_wx_set_genie()
6483 err = -ENOMEM; in ipw_wx_set_genie()
6487 kfree(ieee->wpa_ie); in ipw_wx_set_genie()
6488 ieee->wpa_ie = buf; in ipw_wx_set_genie()
6489 ieee->wpa_ie_len = wrqu->data.length; in ipw_wx_set_genie()
6491 kfree(ieee->wpa_ie); in ipw_wx_set_genie()
6492 ieee->wpa_ie = NULL; in ipw_wx_set_genie()
6493 ieee->wpa_ie_len = 0; in ipw_wx_set_genie()
6496 ipw_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len); in ipw_wx_set_genie()
6507 struct libipw_device *ieee = priv->ieee; in ipw_wx_get_genie()
6510 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { in ipw_wx_get_genie()
6511 wrqu->data.length = 0; in ipw_wx_get_genie()
6515 if (wrqu->data.length < ieee->wpa_ie_len) { in ipw_wx_get_genie()
6516 err = -E2BIG; in ipw_wx_get_genie()
6520 wrqu->data.length = ieee->wpa_ie_len; in ipw_wx_get_genie()
6521 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); in ipw_wx_get_genie()
6540 return -1; in wext_cipher2level()
6550 struct libipw_device *ieee = priv->ieee; in ipw_wx_set_auth()
6551 struct iw_param *param = &wrqu->param; in ipw_wx_set_auth()
6556 switch (param->flags & IW_AUTH_INDEX) { in ipw_wx_set_auth()
6561 wext_cipher2level(param->value)); in ipw_wx_set_auth()
6565 wext_cipher2level(param->value)); in ipw_wx_set_auth()
6574 crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; in ipw_wx_set_auth()
6575 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags) in ipw_wx_set_auth()
6578 flags = crypt->ops->get_flags(crypt->priv); in ipw_wx_set_auth()
6580 if (param->value) in ipw_wx_set_auth()
6585 crypt->ops->set_flags(flags, crypt->priv); in ipw_wx_set_auth()
6597 * used, drop_unencrypted is set to false, else true -- we in ipw_wx_set_auth()
6603 .enabled = param->value, in ipw_wx_set_auth()
6605 priv->ieee->drop_unencrypted = param->value; in ipw_wx_set_auth()
6609 if (!param->value) { in ipw_wx_set_auth()
6616 if (priv->ieee->set_security) in ipw_wx_set_auth()
6617 priv->ieee->set_security(priv->ieee->dev, &sec); in ipw_wx_set_auth()
6622 ret = ipw_wpa_set_auth_algs(priv, param->value); in ipw_wx_set_auth()
6626 ret = ipw_wpa_enable(priv, param->value); in ipw_wx_set_auth()
6631 ieee->ieee802_1x = param->value; in ipw_wx_set_auth()
6635 ieee->privacy_invoked = param->value; in ipw_wx_set_auth()
6639 return -EOPNOTSUPP; in ipw_wx_set_auth()
6650 struct libipw_device *ieee = priv->ieee; in ipw_wx_get_auth()
6652 struct iw_param *param = &wrqu->param; in ipw_wx_get_auth()
6654 switch (param->flags & IW_AUTH_INDEX) { in ipw_wx_get_auth()
6662 return -EOPNOTSUPP; in ipw_wx_get_auth()
6665 crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; in ipw_wx_get_auth()
6666 if (!crypt || !crypt->ops->get_flags) in ipw_wx_get_auth()
6669 param->value = (crypt->ops->get_flags(crypt->priv) & in ipw_wx_get_auth()
6675 param->value = ieee->drop_unencrypted; in ipw_wx_get_auth()
6679 param->value = ieee->sec.auth_mode; in ipw_wx_get_auth()
6683 param->value = ieee->wpa_enabled; in ipw_wx_get_auth()
6687 param->value = ieee->ieee802_1x; in ipw_wx_get_auth()
6692 param->value = ieee->privacy_invoked; in ipw_wx_get_auth()
6696 return -EOPNOTSUPP; in ipw_wx_get_auth()
6710 if (ext->alg == IW_ENCODE_ALG_TKIP) { in ipw_wx_set_encodeext()
6713 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) in ipw_wx_set_encodeext()
6714 priv->ieee->host_mc_decrypt = 1; in ipw_wx_set_encodeext()
6716 priv->ieee->host_encrypt = 0; in ipw_wx_set_encodeext()
6717 priv->ieee->host_encrypt_msdu = 1; in ipw_wx_set_encodeext()
6718 priv->ieee->host_decrypt = 1; in ipw_wx_set_encodeext()
6721 priv->ieee->host_encrypt = 0; in ipw_wx_set_encodeext()
6722 priv->ieee->host_encrypt_msdu = 0; in ipw_wx_set_encodeext()
6723 priv->ieee->host_decrypt = 0; in ipw_wx_set_encodeext()
6724 priv->ieee->host_mc_decrypt = 0; in ipw_wx_set_encodeext()
6728 return libipw_wx_set_encodeext(priv->ieee, info, wrqu, extra); in ipw_wx_set_encodeext()
6737 return libipw_wx_get_encodeext(priv->ieee, info, wrqu, extra); in ipw_wx_get_encodeext()
6748 switch (mlme->cmd) { in ipw_wx_set_mlme()
6758 return -EOPNOTSUPP; in ipw_wx_set_mlme()
6774 if (priv->status & STATUS_ASSOCIATED) { in ipw_qos_current_mode()
6777 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_qos_current_mode()
6778 mode = priv->assoc_network->mode; in ipw_qos_current_mode()
6779 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_qos_current_mode()
6781 mode = priv->ieee->mode; in ipw_qos_current_mode()
6796 if (network->capability & WLAN_CAPABILITY_IBSS) in ipw_qos_handle_probe_response()
6797 network->qos_data.active = network->qos_data.supported; in ipw_qos_handle_probe_response()
6799 if (network->flags & NETWORK_HAS_QOS_MASK) { in ipw_qos_handle_probe_response()
6801 (network->flags & NETWORK_HAS_QOS_PARAMETERS)) in ipw_qos_handle_probe_response()
6802 network->qos_data.active = network->qos_data.supported; in ipw_qos_handle_probe_response()
6804 if ((network->qos_data.active == 1) && (active_network == 1) && in ipw_qos_handle_probe_response()
6805 (network->flags & NETWORK_HAS_QOS_PARAMETERS) && in ipw_qos_handle_probe_response()
6806 (network->qos_data.old_param_count != in ipw_qos_handle_probe_response()
6807 network->qos_data.param_count)) { in ipw_qos_handle_probe_response()
6808 network->qos_data.old_param_count = in ipw_qos_handle_probe_response()
6809 network->qos_data.param_count; in ipw_qos_handle_probe_response()
6810 schedule_work(&priv->qos_activate); in ipw_qos_handle_probe_response()
6815 if ((priv->ieee->mode == IEEE_B) || (network->mode == IEEE_B)) in ipw_qos_handle_probe_response()
6816 memcpy(&network->qos_data.parameters, in ipw_qos_handle_probe_response()
6819 memcpy(&network->qos_data.parameters, in ipw_qos_handle_probe_response()
6822 if ((network->qos_data.active == 1) && (active_network == 1)) { in ipw_qos_handle_probe_response()
6824 schedule_work(&priv->qos_activate); in ipw_qos_handle_probe_response()
6827 network->qos_data.active = 0; in ipw_qos_handle_probe_response()
6828 network->qos_data.supported = 0; in ipw_qos_handle_probe_response()
6830 if ((priv->status & STATUS_ASSOCIATED) && in ipw_qos_handle_probe_response()
6831 (priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) { in ipw_qos_handle_probe_response()
6832 if (!ether_addr_equal(network->bssid, priv->bssid)) in ipw_qos_handle_probe_response()
6833 if (network->capability & WLAN_CAPABILITY_IBSS) in ipw_qos_handle_probe_response()
6834 if ((network->ssid_len == in ipw_qos_handle_probe_response()
6835 priv->assoc_network->ssid_len) && in ipw_qos_handle_probe_response()
6836 !memcmp(network->ssid, in ipw_qos_handle_probe_response()
6837 priv->assoc_network->ssid, in ipw_qos_handle_probe_response()
6838 network->ssid_len)) { in ipw_qos_handle_probe_response()
6839 schedule_work(&priv->merge_networks); in ipw_qos_handle_probe_response()
6864 memcpy(active_one, priv->qos_data.def_qos_parm_CCK, size); in ipw_qos_activate()
6866 memcpy(active_one, priv->qos_data.def_qos_parm_OFDM, size); in ipw_qos_activate()
6880 } else if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw_qos_activate()
6884 if (priv->qos_data.qos_enable == 0) in ipw_qos_activate()
6887 active_one = priv->qos_data.def_qos_parm_CCK; in ipw_qos_activate()
6889 if (priv->qos_data.qos_enable == 0) in ipw_qos_activate()
6892 active_one = priv->qos_data.def_qos_parm_OFDM; in ipw_qos_activate()
6899 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_qos_activate()
6900 active_one = &(qos_network_data->parameters); in ipw_qos_activate()
6901 qos_network_data->old_param_count = in ipw_qos_activate()
6902 qos_network_data->param_count; in ipw_qos_activate()
6904 active = qos_network_data->supported; in ipw_qos_activate()
6905 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_qos_activate()
6932 return -1; in ipw_qos_set_info_element()
6935 qos_info.length = sizeof(struct libipw_qos_information_element) - 2; in ipw_qos_set_info_element()
6964 switch (priv->ieee->iw_mode) { in ipw_qos_association()
6966 BUG_ON(!(network->capability & WLAN_CAPABILITY_IBSS)); in ipw_qos_association()
6972 qos_data = &network->qos_data; in ipw_qos_association()
6982 priv->assoc_request.policy_support &= ~HC_QOS_SUPPORT_ASSOC; in ipw_qos_association()
6986 if (priv->qos_data.qos_enable && qos_data->supported) { in ipw_qos_association()
6988 priv->assoc_request.policy_support |= HC_QOS_SUPPORT_ASSOC; in ipw_qos_association()
7008 (priv->assoc_network == NULL)) in ipw_qos_association_resp()
7011 if (!(priv->status & STATUS_ASSOCIATED)) in ipw_qos_association_resp()
7014 if ((priv->ieee->iw_mode != IW_MODE_INFRA)) in ipw_qos_association_resp()
7017 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_qos_association_resp()
7018 if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { in ipw_qos_association_resp()
7019 memcpy(&priv->assoc_network->qos_data, &network->qos_data, in ipw_qos_association_resp()
7021 priv->assoc_network->qos_data.active = 1; in ipw_qos_association_resp()
7022 if ((network->qos_data.old_param_count != in ipw_qos_association_resp()
7023 network->qos_data.param_count)) { in ipw_qos_association_resp()
7025 network->qos_data.old_param_count = in ipw_qos_association_resp()
7026 network->qos_data.param_count; in ipw_qos_association_resp()
7030 if ((network->mode == IEEE_B) || (priv->ieee->mode == IEEE_B)) in ipw_qos_association_resp()
7031 memcpy(&priv->assoc_network->qos_data.parameters, in ipw_qos_association_resp()
7034 memcpy(&priv->assoc_network->qos_data.parameters, in ipw_qos_association_resp()
7036 priv->assoc_network->qos_data.active = 0; in ipw_qos_association_resp()
7037 priv->assoc_network->qos_data.supported = 0; in ipw_qos_association_resp()
7041 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_qos_association_resp()
7044 schedule_work(&priv->qos_activate); in ipw_qos_association_resp()
7054 if (!(priv->ieee->modulation & LIBIPW_OFDM_MODULATION)) in ipw_qos_get_burst_duration()
7055 ret = priv->qos_data.burst_duration_CCK; in ipw_qos_get_burst_duration()
7057 ret = priv->qos_data.burst_duration_OFDM; in ipw_qos_get_burst_duration()
7069 priv->qos_data.qos_enable = enable; in ipw_qos_init()
7071 if (priv->qos_data.qos_enable) { in ipw_qos_init()
7072 priv->qos_data.def_qos_parm_CCK = &def_qos_parameters_CCK; in ipw_qos_init()
7073 priv->qos_data.def_qos_parm_OFDM = &def_qos_parameters_OFDM; in ipw_qos_init()
7076 priv->qos_data.def_qos_parm_CCK = &def_parameters_CCK; in ipw_qos_init()
7077 priv->qos_data.def_qos_parm_OFDM = &def_parameters_OFDM; in ipw_qos_init()
7081 priv->qos_data.burst_enable = burst_enable; in ipw_qos_init()
7084 priv->qos_data.burst_duration_CCK = burst_duration_CCK; in ipw_qos_init()
7085 priv->qos_data.burst_duration_OFDM = burst_duration_OFDM; in ipw_qos_init()
7087 priv->qos_data.burst_duration_CCK = 0; in ipw_qos_init()
7088 priv->qos_data.burst_duration_OFDM = 0; in ipw_qos_init()
7097 if (priority > 7 || !priv->qos_data.qos_enable) in ipw_get_tx_queue_number()
7100 return from_priority_to_tx_queue[priority] - 1; in ipw_get_tx_queue_number()
7109 u8 *daddr = skb->data + ETH_ALEN; in ipw_is_qos_active()
7112 if (!(priv->status & STATUS_ASSOCIATED)) in ipw_is_qos_active()
7115 qos_data = &priv->assoc_network->qos_data; in ipw_is_qos_active()
7117 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw_is_qos_active()
7119 qos_data->active = 0; in ipw_is_qos_active()
7121 qos_data->active = qos_data->supported; in ipw_is_qos_active()
7123 active = qos_data->active; in ipw_is_qos_active()
7124 supported = qos_data->supported; in ipw_is_qos_active()
7127 priv->qos_data.qos_enable, active, supported, unicast); in ipw_is_qos_active()
7128 if (active && priv->qos_data.qos_enable) in ipw_is_qos_active()
7144 tx_queue_id = from_priority_to_tx_queue[priority] - 1; in ipw_qos_set_tx_queue_command()
7145 tfd->tx_flags_ext |= DCT_FLAG_EXT_QOS_ENABLED; in ipw_qos_set_tx_queue_command()
7147 if (priv->qos_data.qos_no_ack_mask & (1UL << tx_queue_id)) { in ipw_qos_set_tx_queue_command()
7148 tfd->tx_flags &= ~DCT_FLAG_ACK_REQD; in ipw_qos_set_tx_queue_command()
7149 tfd->tfd.tfd_26.mchdr.qos_ctrl |= cpu_to_le16(CTRL_QOS_NO_ACK); in ipw_qos_set_tx_queue_command()
7162 mutex_lock(&priv->mutex); in ipw_bg_qos_activate()
7164 if (priv->status & STATUS_ASSOCIATED) in ipw_bg_qos_activate()
7165 ipw_qos_activate(priv, &(priv->assoc_network->qos_data)); in ipw_bg_qos_activate()
7167 mutex_unlock(&priv->mutex); in ipw_bg_qos_activate()
7175 int active_network = ((priv->status & STATUS_ASSOCIATED) && in ipw_handle_probe_response()
7176 (network == priv->assoc_network)); in ipw_handle_probe_response()
7188 int active_network = ((priv->status & STATUS_ASSOCIATED) && in ipw_handle_beacon()
7189 (network == priv->assoc_network)); in ipw_handle_beacon()
7227 if (priv->config & CFG_FIXED_RATE) in ipw_associate_network()
7228 ipw_set_fixed_rate(priv, network->mode); in ipw_associate_network()
7230 if (!(priv->config & CFG_STATIC_ESSID)) { in ipw_associate_network()
7231 priv->essid_len = min(network->ssid_len, in ipw_associate_network()
7233 memcpy(priv->essid, network->ssid, priv->essid_len); in ipw_associate_network()
7236 network->last_associate = jiffies; in ipw_associate_network()
7238 memset(&priv->assoc_request, 0, sizeof(priv->assoc_request)); in ipw_associate_network()
7239 priv->assoc_request.channel = network->channel; in ipw_associate_network()
7240 priv->assoc_request.auth_key = 0; in ipw_associate_network()
7242 if ((priv->capability & CAP_PRIVACY_ON) && in ipw_associate_network()
7243 (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) { in ipw_associate_network()
7244 priv->assoc_request.auth_type = AUTH_SHARED_KEY; in ipw_associate_network()
7245 priv->assoc_request.auth_key = priv->ieee->sec.active_key; in ipw_associate_network()
7247 if (priv->ieee->sec.level == SEC_LEVEL_1) in ipw_associate_network()
7250 } else if ((priv->capability & CAP_PRIVACY_ON) && in ipw_associate_network()
7251 (priv->ieee->sec.auth_mode == WLAN_AUTH_LEAP)) in ipw_associate_network()
7252 priv->assoc_request.auth_type = AUTH_LEAP; in ipw_associate_network()
7254 priv->assoc_request.auth_type = AUTH_OPEN; in ipw_associate_network()
7256 if (priv->ieee->wpa_ie_len) { in ipw_associate_network()
7257 priv->assoc_request.policy_support = cpu_to_le16(0x02); /* RSN active */ in ipw_associate_network()
7258 ipw_set_rsn_capa(priv, priv->ieee->wpa_ie, in ipw_associate_network()
7259 priv->ieee->wpa_ie_len); in ipw_associate_network()
7267 if (network->mode & priv->ieee->mode & IEEE_A) in ipw_associate_network()
7268 priv->assoc_request.ieee_mode = IPW_A_MODE; in ipw_associate_network()
7269 else if (network->mode & priv->ieee->mode & IEEE_G) in ipw_associate_network()
7270 priv->assoc_request.ieee_mode = IPW_G_MODE; in ipw_associate_network()
7271 else if (network->mode & priv->ieee->mode & IEEE_B) in ipw_associate_network()
7272 priv->assoc_request.ieee_mode = IPW_B_MODE; in ipw_associate_network()
7274 priv->assoc_request.capability = cpu_to_le16(network->capability); in ipw_associate_network()
7275 if ((network->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) in ipw_associate_network()
7276 && !(priv->config & CFG_PREAMBLE_LONG)) { in ipw_associate_network()
7277 priv->assoc_request.preamble_length = DCT_FLAG_SHORT_PREAMBLE; in ipw_associate_network()
7279 priv->assoc_request.preamble_length = DCT_FLAG_LONG_PREAMBLE; in ipw_associate_network()
7282 priv->assoc_request.capability &= in ipw_associate_network()
7287 if (priv->ieee->iw_mode == IW_MODE_ADHOC) in ipw_associate_network()
7288 priv->assoc_request.capability &= in ipw_associate_network()
7293 priv->essid_len, priv->essid, in ipw_associate_network()
7294 network->channel, in ipw_associate_network()
7295 ipw_modes[priv->assoc_request.ieee_mode], in ipw_associate_network()
7296 rates->num_rates, in ipw_associate_network()
7297 (priv->assoc_request.preamble_length == in ipw_associate_network()
7299 network->capability & in ipw_associate_network()
7301 priv->capability & CAP_PRIVACY_ON ? "on " : "off", in ipw_associate_network()
7302 priv->capability & CAP_PRIVACY_ON ? in ipw_associate_network()
7303 (priv->capability & CAP_SHARED_KEY ? "(shared)" : in ipw_associate_network()
7305 priv->capability & CAP_PRIVACY_ON ? " key=" : "", in ipw_associate_network()
7306 priv->capability & CAP_PRIVACY_ON ? in ipw_associate_network()
7307 '1' + priv->ieee->sec.active_key : '.', in ipw_associate_network()
7308 priv->capability & CAP_PRIVACY_ON ? '.' : ' '); in ipw_associate_network()
7310 priv->assoc_request.beacon_interval = cpu_to_le16(network->beacon_interval); in ipw_associate_network()
7311 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && in ipw_associate_network()
7312 (network->time_stamp[0] == 0) && (network->time_stamp[1] == 0)) { in ipw_associate_network()
7313 priv->assoc_request.assoc_type = HC_IBSS_START; in ipw_associate_network()
7314 priv->assoc_request.assoc_tsf_msw = 0; in ipw_associate_network()
7315 priv->assoc_request.assoc_tsf_lsw = 0; in ipw_associate_network()
7318 priv->assoc_request.assoc_type = HC_REASSOCIATE; in ipw_associate_network()
7320 priv->assoc_request.assoc_type = HC_ASSOCIATE; in ipw_associate_network()
7321 priv->assoc_request.assoc_tsf_msw = cpu_to_le32(network->time_stamp[1]); in ipw_associate_network()
7322 priv->assoc_request.assoc_tsf_lsw = cpu_to_le32(network->time_stamp[0]); in ipw_associate_network()
7325 memcpy(priv->assoc_request.bssid, network->bssid, ETH_ALEN); in ipw_associate_network()
7327 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw_associate_network()
7328 eth_broadcast_addr(priv->assoc_request.dest); in ipw_associate_network()
7329 priv->assoc_request.atim_window = cpu_to_le16(network->atim_window); in ipw_associate_network()
7331 memcpy(priv->assoc_request.dest, network->bssid, ETH_ALEN); in ipw_associate_network()
7332 priv->assoc_request.atim_window = 0; in ipw_associate_network()
7335 priv->assoc_request.listen_interval = cpu_to_le16(network->listen_interval); in ipw_associate_network()
7337 err = ipw_send_ssid(priv, priv->essid, priv->essid_len); in ipw_associate_network()
7343 rates->ieee_mode = priv->assoc_request.ieee_mode; in ipw_associate_network()
7344 rates->purpose = IPW_RATE_CONNECT; in ipw_associate_network()
7347 if (priv->assoc_request.ieee_mode == IPW_G_MODE) in ipw_associate_network()
7348 priv->sys_config.dot11g_auto_detection = 1; in ipw_associate_network()
7350 priv->sys_config.dot11g_auto_detection = 0; in ipw_associate_network()
7352 if (priv->ieee->iw_mode == IW_MODE_ADHOC) in ipw_associate_network()
7353 priv->sys_config.answer_broadcast_ssid_probe = 1; in ipw_associate_network()
7355 priv->sys_config.answer_broadcast_ssid_probe = 0; in ipw_associate_network()
7363 IPW_DEBUG_ASSOC("Association sensitivity: %d\n", network->stats.rssi); in ipw_associate_network()
7364 err = ipw_set_sensitivity(priv, network->stats.rssi + IPW_RSSI_TO_DBM); in ipw_associate_network()
7375 priv->channel = network->channel; in ipw_associate_network()
7376 memcpy(priv->bssid, network->bssid, ETH_ALEN); in ipw_associate_network()
7377 priv->status |= STATUS_ASSOCIATING; in ipw_associate_network()
7378 priv->status &= ~STATUS_SECURITY_UPDATED; in ipw_associate_network()
7380 priv->assoc_network = network; in ipw_associate_network()
7386 err = ipw_send_associate(priv, &priv->assoc_request); in ipw_associate_network()
7393 priv->essid_len, priv->essid, priv->bssid); in ipw_associate_network()
7403 .network = priv->assoc_network in ipw_roam()
7426 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ROAMING))) in ipw_roam()
7429 if (priv->status & STATUS_ASSOCIATED) { in ipw_roam()
7430 /* First pass through ROAM process -- look for a better in ipw_roam()
7433 u8 rssi = priv->assoc_network->stats.rssi; in ipw_roam()
7434 priv->assoc_network->stats.rssi = -128; in ipw_roam()
7435 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_roam()
7436 list_for_each_entry(network, &priv->ieee->network_list, list) { in ipw_roam()
7437 if (network != priv->assoc_network) in ipw_roam()
7440 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_roam()
7441 priv->assoc_network->stats.rssi = rssi; in ipw_roam()
7443 if (match.network == priv->assoc_network) { in ipw_roam()
7446 priv->status &= ~STATUS_ROAMING; in ipw_roam()
7452 priv->assoc_network = match.network; in ipw_roam()
7457 /* Second pass through ROAM process -- request association */ in ipw_roam()
7458 ipw_compatible_rates(priv, priv->assoc_network, &match.rates); in ipw_roam()
7459 ipw_associate_network(priv, priv->assoc_network, &match.rates, 1); in ipw_roam()
7460 priv->status &= ~STATUS_ROAMING; in ipw_roam()
7467 mutex_lock(&priv->mutex); in ipw_bg_roam()
7469 mutex_unlock(&priv->mutex); in ipw_bg_roam()
7484 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw_associate()
7489 if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { in ipw_associate()
7495 if (priv->status & STATUS_DISASSOCIATING) { in ipw_associate()
7497 schedule_work(&priv->associate); in ipw_associate()
7501 if (!ipw_is_init(priv) || (priv->status & STATUS_SCANNING)) { in ipw_associate()
7507 if (!(priv->config & CFG_ASSOCIATE) && in ipw_associate()
7508 !(priv->config & (CFG_STATIC_ESSID | CFG_STATIC_BSSID))) { in ipw_associate()
7514 spin_lock_irqsave(&priv->ieee->lock, flags); in ipw_associate()
7515 list_for_each_entry(network, &priv->ieee->network_list, list) in ipw_associate()
7522 priv->ieee->iw_mode == IW_MODE_ADHOC && in ipw_associate()
7523 priv->config & CFG_ADHOC_CREATE && in ipw_associate()
7524 priv->config & CFG_STATIC_ESSID && in ipw_associate()
7525 priv->config & CFG_STATIC_CHANNEL) { in ipw_associate()
7527 if (list_empty(&priv->ieee->network_free_list)) { in ipw_associate()
7531 list_for_each_entry(target, &priv->ieee->network_list, list) { in ipw_associate()
7533 (target->last_scanned < oldest->last_scanned)) in ipw_associate()
7538 list_del(&oldest->list); in ipw_associate()
7541 target->ssid_len, target->ssid, in ipw_associate()
7542 target->bssid); in ipw_associate()
7543 list_add_tail(&target->list, in ipw_associate()
7544 &priv->ieee->network_free_list); in ipw_associate()
7547 element = priv->ieee->network_free_list.next; in ipw_associate()
7550 rates = &priv->rates; in ipw_associate()
7552 list_add_tail(&network->list, &priv->ieee->network_list); in ipw_associate()
7554 spin_unlock_irqrestore(&priv->ieee->lock, flags); in ipw_associate()
7561 if (!(priv->status & STATUS_SCANNING)) { in ipw_associate()
7562 if (!(priv->config & CFG_SPEED_SCAN)) in ipw_associate()
7563 schedule_delayed_work(&priv->request_scan, in ipw_associate()
7566 schedule_delayed_work(&priv->request_scan, 0); in ipw_associate()
7581 mutex_lock(&priv->mutex); in ipw_bg_associate()
7583 mutex_unlock(&priv->mutex); in ipw_bg_associate()
7592 hdr = (struct ieee80211_hdr *)skb->data; in ipw_rebuild_decrypted_skb()
7593 fc = le16_to_cpu(hdr->frame_control); in ipw_rebuild_decrypted_skb()
7598 hdr->frame_control = cpu_to_le16(fc); in ipw_rebuild_decrypted_skb()
7599 switch (priv->ieee->sec.level) { in ipw_rebuild_decrypted_skb()
7602 memmove(skb->data + LIBIPW_3ADDR_LEN, in ipw_rebuild_decrypted_skb()
7603 skb->data + LIBIPW_3ADDR_LEN + 8, in ipw_rebuild_decrypted_skb()
7604 skb->len - LIBIPW_3ADDR_LEN - 8); in ipw_rebuild_decrypted_skb()
7605 skb_trim(skb, skb->len - 16); /* CCMP_HDR_LEN + CCMP_MIC_LEN */ in ipw_rebuild_decrypted_skb()
7611 memmove(skb->data + LIBIPW_3ADDR_LEN, in ipw_rebuild_decrypted_skb()
7612 skb->data + LIBIPW_3ADDR_LEN + 4, in ipw_rebuild_decrypted_skb()
7613 skb->len - LIBIPW_3ADDR_LEN - 4); in ipw_rebuild_decrypted_skb()
7614 skb_trim(skb, skb->len - 8); /* IV + ICV */ in ipw_rebuild_decrypted_skb()
7620 priv->ieee->sec.level); in ipw_rebuild_decrypted_skb()
7629 struct net_device *dev = priv->net_dev; in ipw_handle_data_packet()
7631 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; in ipw_handle_data_packet()
7638 if (unlikely((le16_to_cpu(pkt->u.frame.length) + IPW_RX_FRAME_SIZE) > in ipw_handle_data_packet()
7639 skb_tailroom(rxb->skb))) { in ipw_handle_data_packet()
7640 dev->stats.rx_errors++; in ipw_handle_data_packet()
7641 priv->wstats.discard.misc++; in ipw_handle_data_packet()
7644 } else if (unlikely(!netif_running(priv->net_dev))) { in ipw_handle_data_packet()
7645 dev->stats.rx_dropped++; in ipw_handle_data_packet()
7646 priv->wstats.discard.misc++; in ipw_handle_data_packet()
7651 /* Advance skb->data to the start of the actual payload */ in ipw_handle_data_packet()
7652 skb_reserve(rxb->skb, offsetof(struct ipw_rx_packet, u.frame.data)); in ipw_handle_data_packet()
7655 skb_put(rxb->skb, le16_to_cpu(pkt->u.frame.length)); in ipw_handle_data_packet()
7657 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len); in ipw_handle_data_packet()
7660 hdr = (struct libipw_hdr_4addr *)rxb->skb->data; in ipw_handle_data_packet()
7661 if (priv->ieee->iw_mode != IW_MODE_MONITOR && in ipw_handle_data_packet()
7662 (is_multicast_ether_addr(hdr->addr1) ? in ipw_handle_data_packet()
7663 !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt)) in ipw_handle_data_packet()
7664 ipw_rebuild_decrypted_skb(priv, rxb->skb); in ipw_handle_data_packet()
7666 if (!libipw_rx(priv->ieee, rxb->skb, stats)) in ipw_handle_data_packet()
7667 dev->stats.rx_errors++; in ipw_handle_data_packet()
7669 rxb->skb = NULL; in ipw_handle_data_packet()
7679 struct net_device *dev = priv->net_dev; in ipw_handle_data_packet_monitor()
7680 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; in ipw_handle_data_packet_monitor()
7681 struct ipw_rx_frame *frame = &pkt->u.frame; in ipw_handle_data_packet_monitor()
7684 u16 received_channel = frame->received_channel; in ipw_handle_data_packet_monitor()
7685 u8 antennaAndPhy = frame->antennaAndPhy; in ipw_handle_data_packet_monitor()
7686 s8 antsignal = frame->rssi_dbm - IPW_RSSI_TO_DBM; /* call it signed anyhow */ in ipw_handle_data_packet_monitor()
7687 u16 pktrate = frame->rate; in ipw_handle_data_packet_monitor()
7689 /* Magic struct that slots into the radiotap header -- no reason in ipw_handle_data_packet_monitor()
7694 unsigned short len = le16_to_cpu(pkt->u.frame.length); in ipw_handle_data_packet_monitor()
7701 if (unlikely((le16_to_cpu(pkt->u.frame.length) + IPW_RX_FRAME_SIZE) > in ipw_handle_data_packet_monitor()
7702 skb_tailroom(rxb->skb))) { in ipw_handle_data_packet_monitor()
7703 dev->stats.rx_errors++; in ipw_handle_data_packet_monitor()
7704 priv->wstats.discard.misc++; in ipw_handle_data_packet_monitor()
7707 } else if (unlikely(!netif_running(priv->net_dev))) { in ipw_handle_data_packet_monitor()
7708 dev->stats.rx_dropped++; in ipw_handle_data_packet_monitor()
7709 priv->wstats.discard.misc++; in ipw_handle_data_packet_monitor()
7716 if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) { in ipw_handle_data_packet_monitor()
7718 dev->stats.rx_dropped++; in ipw_handle_data_packet_monitor()
7719 priv->wstats.discard.misc++; in ipw_handle_data_packet_monitor()
7725 memmove(rxb->skb->data + sizeof(struct ipw_rt_hdr), in ipw_handle_data_packet_monitor()
7726 rxb->skb->data + IPW_RX_FRAME_SIZE, len); in ipw_handle_data_packet_monitor()
7728 ipw_rt = (struct ipw_rt_hdr *)rxb->skb->data; in ipw_handle_data_packet_monitor()
7730 ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; in ipw_handle_data_packet_monitor()
7731 ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */ in ipw_handle_data_packet_monitor()
7732 ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct ipw_rt_hdr)); /* total header+data */ in ipw_handle_data_packet_monitor()
7735 ipw_rt->rt_hdr.it_present = cpu_to_le32( in ipw_handle_data_packet_monitor()
7745 ipw_rt->rt_flags = 0; in ipw_handle_data_packet_monitor()
7746 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 | in ipw_handle_data_packet_monitor()
7747 frame->parent_tsf[2] << 16 | in ipw_handle_data_packet_monitor()
7748 frame->parent_tsf[1] << 8 | in ipw_handle_data_packet_monitor()
7749 frame->parent_tsf[0]); in ipw_handle_data_packet_monitor()
7752 ipw_rt->rt_dbmsignal = antsignal; in ipw_handle_data_packet_monitor()
7753 ipw_rt->rt_dbmnoise = (s8) le16_to_cpu(frame->noise); in ipw_handle_data_packet_monitor()
7756 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel)); in ipw_handle_data_packet_monitor()
7758 ipw_rt->rt_chbitmask = in ipw_handle_data_packet_monitor()
7761 ipw_rt->rt_chbitmask = in ipw_handle_data_packet_monitor()
7764 ipw_rt->rt_chbitmask = in ipw_handle_data_packet_monitor()
7771 ipw_rt->rt_rate = 2; in ipw_handle_data_packet_monitor()
7774 ipw_rt->rt_rate = 4; in ipw_handle_data_packet_monitor()
7777 ipw_rt->rt_rate = 10; in ipw_handle_data_packet_monitor()
7780 ipw_rt->rt_rate = 12; in ipw_handle_data_packet_monitor()
7783 ipw_rt->rt_rate = 18; in ipw_handle_data_packet_monitor()
7786 ipw_rt->rt_rate = 22; in ipw_handle_data_packet_monitor()
7789 ipw_rt->rt_rate = 24; in ipw_handle_data_packet_monitor()
7792 ipw_rt->rt_rate = 36; in ipw_handle_data_packet_monitor()
7795 ipw_rt->rt_rate = 48; in ipw_handle_data_packet_monitor()
7798 ipw_rt->rt_rate = 72; in ipw_handle_data_packet_monitor()
7801 ipw_rt->rt_rate = 96; in ipw_handle_data_packet_monitor()
7804 ipw_rt->rt_rate = 108; in ipw_handle_data_packet_monitor()
7807 ipw_rt->rt_rate = 0; in ipw_handle_data_packet_monitor()
7812 ipw_rt->rt_antenna = (antennaAndPhy & 3); /* Is this right? */ in ipw_handle_data_packet_monitor()
7816 ipw_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ipw_handle_data_packet_monitor()
7819 skb_put(rxb->skb, len + sizeof(struct ipw_rt_hdr)); in ipw_handle_data_packet_monitor()
7821 IPW_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len); in ipw_handle_data_packet_monitor()
7823 if (!libipw_rx(priv->ieee, rxb->skb, stats)) in ipw_handle_data_packet_monitor()
7824 dev->stats.rx_errors++; in ipw_handle_data_packet_monitor()
7826 rxb->skb = NULL; in ipw_handle_data_packet_monitor()
7856 struct net_device *dev = priv->prom_net_dev; in ipw_handle_promiscuous_rx()
7857 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; in ipw_handle_promiscuous_rx()
7858 struct ipw_rx_frame *frame = &pkt->u.frame; in ipw_handle_promiscuous_rx()
7864 u16 channel = frame->received_channel; in ipw_handle_promiscuous_rx()
7865 u8 phy_flags = frame->antennaAndPhy; in ipw_handle_promiscuous_rx()
7866 s8 signal = frame->rssi_dbm - IPW_RSSI_TO_DBM; in ipw_handle_promiscuous_rx()
7867 s8 noise = (s8) le16_to_cpu(frame->noise); in ipw_handle_promiscuous_rx() local
7868 u8 rate = frame->rate; in ipw_handle_promiscuous_rx()
7869 unsigned short len = le16_to_cpu(pkt->u.frame.length); in ipw_handle_promiscuous_rx()
7872 u16 filter = priv->prom_priv->filter; in ipw_handle_promiscuous_rx()
7881 if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb))) { in ipw_handle_promiscuous_rx()
7882 dev->stats.rx_errors++; in ipw_handle_promiscuous_rx()
7889 dev->stats.rx_dropped++; in ipw_handle_promiscuous_rx()
7896 if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) { in ipw_handle_promiscuous_rx()
7898 dev->stats.rx_dropped++; in ipw_handle_promiscuous_rx()
7903 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE; in ipw_handle_promiscuous_rx()
7904 if (libipw_is_management(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_rx()
7909 } else if (libipw_is_control(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_rx()
7914 } else if (libipw_is_data(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_rx()
7922 skb = skb_copy(rxb->skb, GFP_ATOMIC); in ipw_handle_promiscuous_rx()
7929 ipw_rt = (void *)skb->data; in ipw_handle_promiscuous_rx()
7932 len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_control)); in ipw_handle_promiscuous_rx()
7934 memcpy(ipw_rt->payload, hdr, len); in ipw_handle_promiscuous_rx()
7936 ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; in ipw_handle_promiscuous_rx()
7937 ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */ in ipw_handle_promiscuous_rx()
7938 ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(*ipw_rt)); /* total header+data */ in ipw_handle_promiscuous_rx()
7944 ipw_rt->rt_hdr.it_present = cpu_to_le32( in ipw_handle_promiscuous_rx()
7954 ipw_rt->rt_flags = 0; in ipw_handle_promiscuous_rx()
7955 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 | in ipw_handle_promiscuous_rx()
7956 frame->parent_tsf[2] << 16 | in ipw_handle_promiscuous_rx()
7957 frame->parent_tsf[1] << 8 | in ipw_handle_promiscuous_rx()
7958 frame->parent_tsf[0]); in ipw_handle_promiscuous_rx()
7961 ipw_rt->rt_dbmsignal = signal; in ipw_handle_promiscuous_rx()
7962 ipw_rt->rt_dbmnoise = noise; in ipw_handle_promiscuous_rx()
7965 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(channel)); in ipw_handle_promiscuous_rx()
7967 ipw_rt->rt_chbitmask = in ipw_handle_promiscuous_rx()
7970 ipw_rt->rt_chbitmask = in ipw_handle_promiscuous_rx()
7973 ipw_rt->rt_chbitmask = in ipw_handle_promiscuous_rx()
7980 ipw_rt->rt_rate = 2; in ipw_handle_promiscuous_rx()
7983 ipw_rt->rt_rate = 4; in ipw_handle_promiscuous_rx()
7986 ipw_rt->rt_rate = 10; in ipw_handle_promiscuous_rx()
7989 ipw_rt->rt_rate = 12; in ipw_handle_promiscuous_rx()
7992 ipw_rt->rt_rate = 18; in ipw_handle_promiscuous_rx()
7995 ipw_rt->rt_rate = 22; in ipw_handle_promiscuous_rx()
7998 ipw_rt->rt_rate = 24; in ipw_handle_promiscuous_rx()
8001 ipw_rt->rt_rate = 36; in ipw_handle_promiscuous_rx()
8004 ipw_rt->rt_rate = 48; in ipw_handle_promiscuous_rx()
8007 ipw_rt->rt_rate = 72; in ipw_handle_promiscuous_rx()
8010 ipw_rt->rt_rate = 96; in ipw_handle_promiscuous_rx()
8013 ipw_rt->rt_rate = 108; in ipw_handle_promiscuous_rx()
8016 ipw_rt->rt_rate = 0; in ipw_handle_promiscuous_rx()
8021 ipw_rt->rt_antenna = (phy_flags & 3); in ipw_handle_promiscuous_rx()
8025 ipw_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ipw_handle_promiscuous_rx()
8027 IPW_DEBUG_RX("Rx packet of %d bytes.\n", skb->len); in ipw_handle_promiscuous_rx()
8029 if (!libipw_rx(priv->prom_priv->ieee, skb, stats)) { in ipw_handle_promiscuous_rx()
8030 dev->stats.rx_errors++; in ipw_handle_promiscuous_rx()
8041 switch (priv->ieee->iw_mode) { in is_network_packet()
8044 if (ether_addr_equal(header->addr2, priv->net_dev->dev_addr)) in is_network_packet()
8048 if (is_multicast_ether_addr(header->addr1)) in is_network_packet()
8049 return ether_addr_equal(header->addr3, priv->bssid); in is_network_packet()
8052 return ether_addr_equal(header->addr1, in is_network_packet()
8053 priv->net_dev->dev_addr); in is_network_packet()
8057 if (ether_addr_equal(header->addr3, priv->net_dev->dev_addr)) in is_network_packet()
8061 if (is_multicast_ether_addr(header->addr1)) in is_network_packet()
8062 return ether_addr_equal(header->addr2, priv->bssid); in is_network_packet()
8065 return ether_addr_equal(header->addr1, in is_network_packet()
8066 priv->net_dev->dev_addr); in is_network_packet()
8077 u16 sc = le16_to_cpu(header->seq_ctl); in is_duplicate_packet()
8083 switch (priv->ieee->iw_mode) { in is_duplicate_packet()
8088 u8 *mac = header->addr2; in is_duplicate_packet()
8091 list_for_each(p, &priv->ibss_mac_hash[index]) { in is_duplicate_packet()
8094 if (ether_addr_equal(entry->mac, mac)) in is_duplicate_packet()
8097 if (p == &priv->ibss_mac_hash[index]) { in is_duplicate_packet()
8104 memcpy(entry->mac, mac, ETH_ALEN); in is_duplicate_packet()
8105 entry->seq_num = seq; in is_duplicate_packet()
8106 entry->frag_num = frag; in is_duplicate_packet()
8107 entry->packet_time = jiffies; in is_duplicate_packet()
8108 list_add(&entry->list, in is_duplicate_packet()
8109 &priv->ibss_mac_hash[index]); in is_duplicate_packet()
8112 last_seq = &entry->seq_num; in is_duplicate_packet()
8113 last_frag = &entry->frag_num; in is_duplicate_packet()
8114 last_time = &entry->packet_time; in is_duplicate_packet()
8118 last_seq = &priv->last_seq_num; in is_duplicate_packet()
8119 last_frag = &priv->last_frag_num; in is_duplicate_packet()
8120 last_time = &priv->last_packet_time; in is_duplicate_packet()
8130 /* out-of-order fragment */ in is_duplicate_packet()
8143 BUG_ON(!(le16_to_cpu(header->frame_control) & IEEE80211_FCTL_RETRY)); */ in is_duplicate_packet()
8151 struct sk_buff *skb = rxb->skb; in ipw_handle_mgmt_packet()
8152 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)skb->data; in ipw_handle_mgmt_packet()
8154 (skb->data + IPW_RX_FRAME_SIZE); in ipw_handle_mgmt_packet()
8156 libipw_rx_mgt(priv->ieee, header, stats); in ipw_handle_mgmt_packet()
8158 if (priv->ieee->iw_mode == IW_MODE_ADHOC && in ipw_handle_mgmt_packet()
8159 ((WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) == in ipw_handle_mgmt_packet()
8161 (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) == in ipw_handle_mgmt_packet()
8163 if (ether_addr_equal(header->addr3, priv->bssid)) in ipw_handle_mgmt_packet()
8164 ipw_add_station(priv, header->addr2); in ipw_handle_mgmt_packet()
8167 if (priv->config & CFG_NET_STATS) { in ipw_handle_mgmt_packet()
8172 skb_put(skb, le16_to_cpu(pkt->u.frame.length) + in ipw_handle_mgmt_packet()
8181 skb->dev = priv->ieee->dev; in ipw_handle_mgmt_packet()
8186 skb->pkt_type = PACKET_OTHERHOST; in ipw_handle_mgmt_packet()
8187 skb->protocol = cpu_to_be16(ETH_P_80211_STATS); in ipw_handle_mgmt_packet()
8188 memset(skb->cb, 0, sizeof(rxb->skb->cb)); in ipw_handle_mgmt_packet()
8190 rxb->skb = NULL; in ipw_handle_mgmt_packet()
8210 i = priv->rxq->read; in ipw_rx()
8212 if (ipw_rx_queue_space (priv->rxq) > (RX_QUEUE_SIZE / 2)) in ipw_rx()
8216 rxb = priv->rxq->queue[i]; in ipw_rx()
8221 priv->rxq->queue[i] = NULL; in ipw_rx()
8223 dma_sync_single_for_cpu(&priv->pci_dev->dev, rxb->dma_addr, in ipw_rx()
8226 pkt = (struct ipw_rx_packet *)rxb->skb->data; in ipw_rx()
8228 pkt->header.message_type, in ipw_rx()
8229 pkt->header.rx_seq_num, pkt->header.control_bits); in ipw_rx()
8231 switch (pkt->header.message_type) { in ipw_rx()
8234 .rssi = pkt->u.frame.rssi_dbm - in ipw_rx()
8237 pkt->u.frame.rssi_dbm - in ipw_rx()
8239 .noise = in ipw_rx()
8240 le16_to_cpu(pkt->u.frame.noise), in ipw_rx()
8241 .rate = pkt->u.frame.rate, in ipw_rx()
8244 pkt->u.frame.received_channel, in ipw_rx()
8246 (pkt->u.frame. in ipw_rx()
8250 .len = le16_to_cpu(pkt->u.frame.length), in ipw_rx()
8257 if (stats.noise != 0) in ipw_rx()
8262 priv->rx_packets++; in ipw_rx()
8265 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) in ipw_rx()
8270 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw_rx()
8285 (struct libipw_hdr_4addr *)(rxb->skb-> in ipw_rx()
8288 /* TODO: Check Ad-Hoc dest/source and make sure in ipw_rx()
8290 * correctly -- we should probably use the in ipw_rx()
8296 if (network_packet && priv->assoc_network) { in ipw_rx()
8297 priv->assoc_network->stats.rssi = in ipw_rx()
8299 priv->exp_avg_rssi = in ipw_rx()
8300 exponential_average(priv->exp_avg_rssi, in ipw_rx()
8305 le16_to_cpu(pkt->u.frame.length)); in ipw_rx()
8307 if (le16_to_cpu(pkt->u.frame.length) < in ipw_rx()
8309 header->frame_ctl))) { in ipw_rx()
8313 priv->net_dev->stats.rx_errors++; in ipw_rx()
8314 priv->wstats.discard.misc++; in ipw_rx()
8319 (le16_to_cpu(header->frame_ctl))) { in ipw_rx()
8338 header->addr1, in ipw_rx()
8339 header->addr2, in ipw_rx()
8340 header->addr3); in ipw_rx()
8355 pkt->u.notification.subtype, in ipw_rx()
8356 pkt->u.notification.flags, in ipw_rx()
8357 le16_to_cpu(pkt->u.notification.size)); in ipw_rx()
8358 ipw_rx_notification(priv, &pkt->u.notification); in ipw_rx()
8364 pkt->header.message_type); in ipw_rx()
8368 /* For now we just don't re-use anything. We can tweak this in ipw_rx()
8369 * later to try and re-use notification packets and SKBs that in ipw_rx()
8371 if (rxb->skb != NULL) { in ipw_rx()
8372 dev_kfree_skb_any(rxb->skb); in ipw_rx()
8373 rxb->skb = NULL; in ipw_rx()
8376 dma_unmap_single(&priv->pci_dev->dev, rxb->dma_addr, in ipw_rx()
8378 list_add_tail(&rxb->list, &priv->rxq->rx_used); in ipw_rx()
8385 priv->rxq->read = i; in ipw_rx()
8391 priv->rxq->read = i; in ipw_rx()
8412 int old_mode = priv->ieee->iw_mode; in ipw_sw_reset()
8415 priv->config = 0; in ipw_sw_reset()
8420 priv->config |= CFG_NO_LED; in ipw_sw_reset()
8423 priv->config |= CFG_ASSOCIATE; in ipw_sw_reset()
8428 priv->config |= CFG_ADHOC_CREATE; in ipw_sw_reset()
8432 priv->config &= ~CFG_STATIC_ESSID; in ipw_sw_reset()
8433 priv->essid_len = 0; in ipw_sw_reset()
8434 memset(priv->essid, 0, IW_ESSID_MAX_SIZE); in ipw_sw_reset()
8437 priv->status |= STATUS_RF_KILL_SW; in ipw_sw_reset()
8442 priv->config |= CFG_STATIC_CHANNEL; in ipw_sw_reset()
8443 priv->channel = default_channel; in ipw_sw_reset()
8454 priv->ieee->iw_mode = IW_MODE_ADHOC; in ipw_sw_reset()
8455 priv->net_dev->type = ARPHRD_ETHER; in ipw_sw_reset()
8460 priv->ieee->iw_mode = IW_MODE_MONITOR; in ipw_sw_reset()
8462 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; in ipw_sw_reset()
8464 priv->net_dev->type = ARPHRD_IEEE80211; in ipw_sw_reset()
8470 priv->net_dev->type = ARPHRD_ETHER; in ipw_sw_reset()
8471 priv->ieee->iw_mode = IW_MODE_INFRA; in ipw_sw_reset()
8476 priv->ieee->host_encrypt = 0; in ipw_sw_reset()
8477 priv->ieee->host_encrypt_msdu = 0; in ipw_sw_reset()
8478 priv->ieee->host_decrypt = 0; in ipw_sw_reset()
8479 priv->ieee->host_mc_decrypt = 0; in ipw_sw_reset()
8484 priv->ieee->host_open_frag = 0; in ipw_sw_reset()
8486 if ((priv->pci_dev->device == 0x4223) || in ipw_sw_reset()
8487 (priv->pci_dev->device == 0x4224)) { in ipw_sw_reset()
8492 priv->ieee->abg_true = 1; in ipw_sw_reset()
8496 priv->adapter = IPW_2915ABG; in ipw_sw_reset()
8497 priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B; in ipw_sw_reset()
8504 priv->ieee->abg_true = 0; in ipw_sw_reset()
8508 priv->adapter = IPW_2200BG; in ipw_sw_reset()
8509 priv->ieee->mode = IEEE_G | IEEE_B; in ipw_sw_reset()
8512 priv->ieee->freq_band = band; in ipw_sw_reset()
8513 priv->ieee->modulation = modulation; in ipw_sw_reset()
8515 priv->rates_mask = LIBIPW_DEFAULT_RATES_MASK; in ipw_sw_reset()
8517 priv->disassociate_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT; in ipw_sw_reset()
8518 priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT; in ipw_sw_reset()
8520 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; in ipw_sw_reset()
8521 priv->short_retry_limit = DEFAULT_SHORT_RETRY_LIMIT; in ipw_sw_reset()
8522 priv->long_retry_limit = DEFAULT_LONG_RETRY_LIMIT; in ipw_sw_reset()
8525 priv->power_mode = IPW_POWER_AC; in ipw_sw_reset()
8526 priv->tx_power = IPW_TX_POWER_DEFAULT; in ipw_sw_reset()
8528 return old_mode == priv->ieee->iw_mode; in ipw_sw_reset()
8545 priv->config &= ~CFG_STATIC_CHANNEL; in ipw_set_channel()
8552 priv->config |= CFG_STATIC_CHANNEL; in ipw_set_channel()
8554 if (priv->channel == channel) { in ipw_set_channel()
8561 priv->channel = channel; in ipw_set_channel()
8564 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw_set_channel()
8566 if (priv->status & STATUS_SCANNING) { in ipw_set_channel()
8572 for (i = 1000; i && (priv->status & STATUS_SCANNING); i--) in ipw_set_channel()
8575 if (priv->status & STATUS_SCANNING) in ipw_set_channel()
8579 1000 - i); in ipw_set_channel()
8585 /* Network configuration changed -- force [re]association */ in ipw_set_channel()
8598 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw_wx_set_freq()
8599 struct iw_freq *fwrq = &wrqu->freq; in ipw_wx_set_freq()
8604 if (fwrq->m == 0) { in ipw_wx_set_freq()
8605 IPW_DEBUG_WX("SET Freq/Channel -> any\n"); in ipw_wx_set_freq()
8606 mutex_lock(&priv->mutex); in ipw_wx_set_freq()
8608 mutex_unlock(&priv->mutex); in ipw_wx_set_freq()
8612 if (fwrq->e == 1) { in ipw_wx_set_freq()
8613 channel = libipw_freq_to_channel(priv->ieee, fwrq->m); in ipw_wx_set_freq()
8615 return -EINVAL; in ipw_wx_set_freq()
8617 channel = fwrq->m; in ipw_wx_set_freq()
8619 if (!(band = libipw_is_valid_channel(priv->ieee, channel))) in ipw_wx_set_freq()
8620 return -EINVAL; in ipw_wx_set_freq()
8622 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw_wx_set_freq()
8623 i = libipw_channel_to_index(priv->ieee, channel); in ipw_wx_set_freq()
8624 if (i == -1) in ipw_wx_set_freq()
8625 return -EINVAL; in ipw_wx_set_freq()
8628 geo->bg[i].flags : geo->a[i].flags; in ipw_wx_set_freq()
8630 IPW_DEBUG_WX("Invalid Ad-Hoc channel for 802.11a\n"); in ipw_wx_set_freq()
8631 return -EINVAL; in ipw_wx_set_freq()
8635 IPW_DEBUG_WX("SET Freq/Channel -> %d\n", fwrq->m); in ipw_wx_set_freq()
8636 mutex_lock(&priv->mutex); in ipw_wx_set_freq()
8638 mutex_unlock(&priv->mutex); in ipw_wx_set_freq()
8648 wrqu->freq.e = 0; in ipw_wx_get_freq()
8652 mutex_lock(&priv->mutex); in ipw_wx_get_freq()
8653 if (priv->config & CFG_STATIC_CHANNEL || in ipw_wx_get_freq()
8654 priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) { in ipw_wx_get_freq()
8657 i = libipw_channel_to_index(priv->ieee, priv->channel); in ipw_wx_get_freq()
8658 BUG_ON(i == -1); in ipw_wx_get_freq()
8659 wrqu->freq.e = 1; in ipw_wx_get_freq()
8661 switch (libipw_is_valid_channel(priv->ieee, priv->channel)) { in ipw_wx_get_freq()
8663 wrqu->freq.m = priv->ieee->geo.a[i].freq * 100000; in ipw_wx_get_freq()
8667 wrqu->freq.m = priv->ieee->geo.bg[i].freq * 100000; in ipw_wx_get_freq()
8674 wrqu->freq.m = 0; in ipw_wx_get_freq()
8676 mutex_unlock(&priv->mutex); in ipw_wx_get_freq()
8677 IPW_DEBUG_WX("GET Freq/Channel -> %d\n", priv->channel); in ipw_wx_get_freq()
8688 IPW_DEBUG_WX("Set MODE: %d\n", wrqu->mode); in ipw_wx_set_mode()
8690 switch (wrqu->mode) { in ipw_wx_set_mode()
8698 wrqu->mode = IW_MODE_INFRA; in ipw_wx_set_mode()
8701 return -EINVAL; in ipw_wx_set_mode()
8703 if (wrqu->mode == priv->ieee->iw_mode) in ipw_wx_set_mode()
8706 mutex_lock(&priv->mutex); in ipw_wx_set_mode()
8711 if (priv->ieee->iw_mode == IW_MODE_MONITOR) in ipw_wx_set_mode()
8712 priv->net_dev->type = ARPHRD_ETHER; in ipw_wx_set_mode()
8714 if (wrqu->mode == IW_MODE_MONITOR) in ipw_wx_set_mode()
8716 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; in ipw_wx_set_mode()
8718 priv->net_dev->type = ARPHRD_IEEE80211; in ipw_wx_set_mode()
8726 priv->ieee->iw_mode = wrqu->mode; in ipw_wx_set_mode()
8728 schedule_work(&priv->adapter_restart); in ipw_wx_set_mode()
8729 mutex_unlock(&priv->mutex); in ipw_wx_set_mode()
8738 mutex_lock(&priv->mutex); in ipw_wx_get_mode()
8739 wrqu->mode = priv->ieee->iw_mode; in ipw_wx_get_mode()
8740 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode); in ipw_wx_get_mode()
8741 mutex_unlock(&priv->mutex); in ipw_wx_get_mode()
8768 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw_wx_get_range()
8771 wrqu->data.length = sizeof(*range); in ipw_wx_get_range()
8775 range->throughput = 27 * 1000 * 1000; in ipw_wx_get_range()
8777 range->max_qual.qual = 100; in ipw_wx_get_range()
8779 range->max_qual.level = 0; in ipw_wx_get_range()
8780 range->max_qual.noise = 0; in ipw_wx_get_range()
8781 range->max_qual.updated = 7; /* Updated all three */ in ipw_wx_get_range()
8783 range->avg_qual.qual = 70; in ipw_wx_get_range()
8785 range->avg_qual.level = 0; /* FIXME to real average level */ in ipw_wx_get_range()
8786 range->avg_qual.noise = 0; in ipw_wx_get_range()
8787 range->avg_qual.updated = 7; /* Updated all three */ in ipw_wx_get_range()
8788 mutex_lock(&priv->mutex); in ipw_wx_get_range()
8789 range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES); in ipw_wx_get_range()
8791 for (i = 0; i < range->num_bitrates; i++) in ipw_wx_get_range()
8792 range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) * in ipw_wx_get_range()
8795 range->max_rts = DEFAULT_RTS_THRESHOLD; in ipw_wx_get_range()
8796 range->min_frag = MIN_FRAG_THRESHOLD; in ipw_wx_get_range()
8797 range->max_frag = MAX_FRAG_THRESHOLD; in ipw_wx_get_range()
8799 range->encoding_size[0] = 5; in ipw_wx_get_range()
8800 range->encoding_size[1] = 13; in ipw_wx_get_range()
8801 range->num_encoding_sizes = 2; in ipw_wx_get_range()
8802 range->max_encoding_tokens = WEP_KEYS; in ipw_wx_get_range()
8805 range->we_version_compiled = WIRELESS_EXT; in ipw_wx_get_range()
8806 range->we_version_source = 18; in ipw_wx_get_range()
8809 if (priv->ieee->mode & (IEEE_B | IEEE_G)) { in ipw_wx_get_range()
8810 for (j = 0; j < geo->bg_channels && i < IW_MAX_FREQUENCIES; j++) { in ipw_wx_get_range()
8811 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && in ipw_wx_get_range()
8812 (geo->bg[j].flags & LIBIPW_CH_PASSIVE_ONLY)) in ipw_wx_get_range()
8815 range->freq[i].i = geo->bg[j].channel; in ipw_wx_get_range()
8816 range->freq[i].m = geo->bg[j].freq * 100000; in ipw_wx_get_range()
8817 range->freq[i].e = 1; in ipw_wx_get_range()
8822 if (priv->ieee->mode & IEEE_A) { in ipw_wx_get_range()
8823 for (j = 0; j < geo->a_channels && i < IW_MAX_FREQUENCIES; j++) { in ipw_wx_get_range()
8824 if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && in ipw_wx_get_range()
8825 (geo->a[j].flags & LIBIPW_CH_PASSIVE_ONLY)) in ipw_wx_get_range()
8828 range->freq[i].i = geo->a[j].channel; in ipw_wx_get_range()
8829 range->freq[i].m = geo->a[j].freq * 100000; in ipw_wx_get_range()
8830 range->freq[i].e = 1; in ipw_wx_get_range()
8835 range->num_channels = i; in ipw_wx_get_range()
8836 range->num_frequency = i; in ipw_wx_get_range()
8838 mutex_unlock(&priv->mutex); in ipw_wx_get_range()
8841 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | in ipw_wx_get_range()
8845 range->event_capa[1] = IW_EVENT_CAPA_K_1; in ipw_wx_get_range()
8847 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | in ipw_wx_get_range()
8850 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; in ipw_wx_get_range()
8862 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) in ipw_wx_set_wap()
8863 return -EINVAL; in ipw_wx_set_wap()
8864 mutex_lock(&priv->mutex); in ipw_wx_set_wap()
8865 if (is_broadcast_ether_addr(wrqu->ap_addr.sa_data) || in ipw_wx_set_wap()
8866 is_zero_ether_addr(wrqu->ap_addr.sa_data)) { in ipw_wx_set_wap()
8869 priv->config &= ~CFG_STATIC_BSSID; in ipw_wx_set_wap()
8873 mutex_unlock(&priv->mutex); in ipw_wx_set_wap()
8877 priv->config |= CFG_STATIC_BSSID; in ipw_wx_set_wap()
8878 if (ether_addr_equal(priv->bssid, wrqu->ap_addr.sa_data)) { in ipw_wx_set_wap()
8880 mutex_unlock(&priv->mutex); in ipw_wx_set_wap()
8885 wrqu->ap_addr.sa_data); in ipw_wx_set_wap()
8887 memcpy(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN); in ipw_wx_set_wap()
8889 /* Network configuration changed -- force [re]association */ in ipw_wx_set_wap()
8894 mutex_unlock(&priv->mutex); in ipw_wx_set_wap()
8906 mutex_lock(&priv->mutex); in ipw_wx_get_wap()
8907 if (priv->config & CFG_STATIC_BSSID || in ipw_wx_get_wap()
8908 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { in ipw_wx_get_wap()
8909 wrqu->ap_addr.sa_family = ARPHRD_ETHER; in ipw_wx_get_wap()
8910 memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN); in ipw_wx_get_wap()
8912 eth_zero_addr(wrqu->ap_addr.sa_data); in ipw_wx_get_wap()
8915 wrqu->ap_addr.sa_data); in ipw_wx_get_wap()
8916 mutex_unlock(&priv->mutex); in ipw_wx_get_wap()
8927 mutex_lock(&priv->mutex); in ipw_wx_set_essid()
8929 if (!wrqu->essid.flags) in ipw_wx_set_essid()
8933 priv->config &= ~CFG_STATIC_ESSID; in ipw_wx_set_essid()
8935 mutex_unlock(&priv->mutex); in ipw_wx_set_essid()
8939 length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); in ipw_wx_set_essid()
8941 priv->config |= CFG_STATIC_ESSID; in ipw_wx_set_essid()
8943 if (priv->essid_len == length && !memcmp(priv->essid, extra, length) in ipw_wx_set_essid()
8944 && (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) { in ipw_wx_set_essid()
8946 mutex_unlock(&priv->mutex); in ipw_wx_set_essid()
8952 priv->essid_len = length; in ipw_wx_set_essid()
8953 memcpy(priv->essid, extra, priv->essid_len); in ipw_wx_set_essid()
8955 /* Network configuration changed -- force [re]association */ in ipw_wx_set_essid()
8960 mutex_unlock(&priv->mutex); in ipw_wx_set_essid()
8972 mutex_lock(&priv->mutex); in ipw_wx_get_essid()
8973 if (priv->config & CFG_STATIC_ESSID || in ipw_wx_get_essid()
8974 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { in ipw_wx_get_essid()
8976 priv->essid_len, priv->essid); in ipw_wx_get_essid()
8977 memcpy(extra, priv->essid, priv->essid_len); in ipw_wx_get_essid()
8978 wrqu->essid.length = priv->essid_len; in ipw_wx_get_essid()
8979 wrqu->essid.flags = 1; /* active */ in ipw_wx_get_essid()
8982 wrqu->essid.length = 0; in ipw_wx_get_essid()
8983 wrqu->essid.flags = 0; /* active */ in ipw_wx_get_essid()
8985 mutex_unlock(&priv->mutex); in ipw_wx_get_essid()
8996 if (wrqu->data.length > IW_ESSID_MAX_SIZE) in ipw_wx_set_nick()
8997 return -E2BIG; in ipw_wx_set_nick()
8998 mutex_lock(&priv->mutex); in ipw_wx_set_nick()
8999 wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick)); in ipw_wx_set_nick()
9000 memset(priv->nick, 0, sizeof(priv->nick)); in ipw_wx_set_nick()
9001 memcpy(priv->nick, extra, wrqu->data.length); in ipw_wx_set_nick()
9003 mutex_unlock(&priv->mutex); in ipw_wx_set_nick()
9014 mutex_lock(&priv->mutex); in ipw_wx_get_nick()
9015 wrqu->data.length = strlen(priv->nick); in ipw_wx_get_nick()
9016 memcpy(extra, priv->nick, wrqu->data.length); in ipw_wx_get_nick()
9017 wrqu->data.flags = 1; /* active */ in ipw_wx_get_nick()
9018 mutex_unlock(&priv->mutex); in ipw_wx_get_nick()
9029 IPW_DEBUG_WX("Setting roaming threshold to %d\n", wrqu->sens.value); in ipw_wx_set_sens()
9030 IPW_DEBUG_WX("Setting disassociate threshold to %d\n", 3*wrqu->sens.value); in ipw_wx_set_sens()
9031 mutex_lock(&priv->mutex); in ipw_wx_set_sens()
9033 if (wrqu->sens.fixed == 0) in ipw_wx_set_sens()
9035 priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT; in ipw_wx_set_sens()
9036 priv->disassociate_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT; in ipw_wx_set_sens()
9039 if ((wrqu->sens.value > IPW_MB_ROAMING_THRESHOLD_MAX) || in ipw_wx_set_sens()
9040 (wrqu->sens.value < IPW_MB_ROAMING_THRESHOLD_MIN)) { in ipw_wx_set_sens()
9041 err = -EINVAL; in ipw_wx_set_sens()
9045 priv->roaming_threshold = wrqu->sens.value; in ipw_wx_set_sens()
9046 priv->disassociate_threshold = 3*wrqu->sens.value; in ipw_wx_set_sens()
9048 mutex_unlock(&priv->mutex); in ipw_wx_set_sens()
9057 mutex_lock(&priv->mutex); in ipw_wx_get_sens()
9058 wrqu->sens.fixed = 1; in ipw_wx_get_sens()
9059 wrqu->sens.value = priv->roaming_threshold; in ipw_wx_get_sens()
9060 mutex_unlock(&priv->mutex); in ipw_wx_get_sens()
9062 IPW_DEBUG_WX("GET roaming threshold -> %s %d\n", in ipw_wx_get_sens()
9063 wrqu->power.disabled ? "OFF" : "ON", wrqu->power.value); in ipw_wx_get_sens()
9074 u32 target_rate = wrqu->bitrate.value; in ipw_wx_set_rate()
9077 /* value = -1, fixed = 0 means auto only, so we should use all rates offered by AP */ in ipw_wx_set_rate()
9081 if (target_rate == -1) { in ipw_wx_set_rate()
9089 fixed = wrqu->bitrate.fixed; in ipw_wx_set_rate()
9152 return -EINVAL; in ipw_wx_set_rate()
9156 mask, fixed ? "fixed" : "sub-rates"); in ipw_wx_set_rate()
9157 mutex_lock(&priv->mutex); in ipw_wx_set_rate()
9159 priv->config &= ~CFG_FIXED_RATE; in ipw_wx_set_rate()
9160 ipw_set_fixed_rate(priv, priv->ieee->mode); in ipw_wx_set_rate()
9162 priv->config |= CFG_FIXED_RATE; in ipw_wx_set_rate()
9164 if (priv->rates_mask == mask) { in ipw_wx_set_rate()
9166 mutex_unlock(&priv->mutex); in ipw_wx_set_rate()
9170 priv->rates_mask = mask; in ipw_wx_set_rate()
9172 /* Network configuration changed -- force [re]association */ in ipw_wx_set_rate()
9177 mutex_unlock(&priv->mutex); in ipw_wx_set_rate()
9186 mutex_lock(&priv->mutex); in ipw_wx_get_rate()
9187 wrqu->bitrate.value = priv->last_rate; in ipw_wx_get_rate()
9188 wrqu->bitrate.fixed = (priv->config & CFG_FIXED_RATE) ? 1 : 0; in ipw_wx_get_rate()
9189 mutex_unlock(&priv->mutex); in ipw_wx_get_rate()
9190 IPW_DEBUG_WX("GET Rate -> %d\n", wrqu->bitrate.value); in ipw_wx_get_rate()
9199 mutex_lock(&priv->mutex); in ipw_wx_set_rts()
9200 if (wrqu->rts.disabled || !wrqu->rts.fixed) in ipw_wx_set_rts()
9201 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; in ipw_wx_set_rts()
9203 if (wrqu->rts.value < MIN_RTS_THRESHOLD || in ipw_wx_set_rts()
9204 wrqu->rts.value > MAX_RTS_THRESHOLD) { in ipw_wx_set_rts()
9205 mutex_unlock(&priv->mutex); in ipw_wx_set_rts()
9206 return -EINVAL; in ipw_wx_set_rts()
9208 priv->rts_threshold = wrqu->rts.value; in ipw_wx_set_rts()
9211 ipw_send_rts_threshold(priv, priv->rts_threshold); in ipw_wx_set_rts()
9212 mutex_unlock(&priv->mutex); in ipw_wx_set_rts()
9213 IPW_DEBUG_WX("SET RTS Threshold -> %d\n", priv->rts_threshold); in ipw_wx_set_rts()
9222 mutex_lock(&priv->mutex); in ipw_wx_get_rts()
9223 wrqu->rts.value = priv->rts_threshold; in ipw_wx_get_rts()
9224 wrqu->rts.fixed = 0; /* no auto select */ in ipw_wx_get_rts()
9225 wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); in ipw_wx_get_rts()
9226 mutex_unlock(&priv->mutex); in ipw_wx_get_rts()
9227 IPW_DEBUG_WX("GET RTS Threshold -> %d\n", wrqu->rts.value); in ipw_wx_get_rts()
9238 mutex_lock(&priv->mutex); in ipw_wx_set_txpow()
9239 if (ipw_radio_kill_sw(priv, wrqu->power.disabled)) { in ipw_wx_set_txpow()
9240 err = -EINPROGRESS; in ipw_wx_set_txpow()
9244 if (!wrqu->power.fixed) in ipw_wx_set_txpow()
9245 wrqu->power.value = IPW_TX_POWER_DEFAULT; in ipw_wx_set_txpow()
9247 if (wrqu->power.flags != IW_TXPOW_DBM) { in ipw_wx_set_txpow()
9248 err = -EINVAL; in ipw_wx_set_txpow()
9252 if ((wrqu->power.value > IPW_TX_POWER_MAX) || in ipw_wx_set_txpow()
9253 (wrqu->power.value < IPW_TX_POWER_MIN)) { in ipw_wx_set_txpow()
9254 err = -EINVAL; in ipw_wx_set_txpow()
9258 priv->tx_power = wrqu->power.value; in ipw_wx_set_txpow()
9261 mutex_unlock(&priv->mutex); in ipw_wx_set_txpow()
9270 mutex_lock(&priv->mutex); in ipw_wx_get_txpow()
9271 wrqu->power.value = priv->tx_power; in ipw_wx_get_txpow()
9272 wrqu->power.fixed = 1; in ipw_wx_get_txpow()
9273 wrqu->power.flags = IW_TXPOW_DBM; in ipw_wx_get_txpow()
9274 wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; in ipw_wx_get_txpow()
9275 mutex_unlock(&priv->mutex); in ipw_wx_get_txpow()
9277 IPW_DEBUG_WX("GET TX Power -> %s %d\n", in ipw_wx_get_txpow()
9278 wrqu->power.disabled ? "OFF" : "ON", wrqu->power.value); in ipw_wx_get_txpow()
9288 mutex_lock(&priv->mutex); in ipw_wx_set_frag()
9289 if (wrqu->frag.disabled || !wrqu->frag.fixed) in ipw_wx_set_frag()
9290 priv->ieee->fts = DEFAULT_FTS; in ipw_wx_set_frag()
9292 if (wrqu->frag.value < MIN_FRAG_THRESHOLD || in ipw_wx_set_frag()
9293 wrqu->frag.value > MAX_FRAG_THRESHOLD) { in ipw_wx_set_frag()
9294 mutex_unlock(&priv->mutex); in ipw_wx_set_frag()
9295 return -EINVAL; in ipw_wx_set_frag()
9298 priv->ieee->fts = wrqu->frag.value & ~0x1; in ipw_wx_set_frag()
9301 ipw_send_frag_threshold(priv, wrqu->frag.value); in ipw_wx_set_frag()
9302 mutex_unlock(&priv->mutex); in ipw_wx_set_frag()
9303 IPW_DEBUG_WX("SET Frag Threshold -> %d\n", wrqu->frag.value); in ipw_wx_set_frag()
9312 mutex_lock(&priv->mutex); in ipw_wx_get_frag()
9313 wrqu->frag.value = priv->ieee->fts; in ipw_wx_get_frag()
9314 wrqu->frag.fixed = 0; /* no auto select */ in ipw_wx_get_frag()
9315 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS); in ipw_wx_get_frag()
9316 mutex_unlock(&priv->mutex); in ipw_wx_get_frag()
9317 IPW_DEBUG_WX("GET Frag Threshold -> %d\n", wrqu->frag.value); in ipw_wx_get_frag()
9328 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled) in ipw_wx_set_retry()
9329 return -EINVAL; in ipw_wx_set_retry()
9331 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) in ipw_wx_set_retry()
9334 if (wrqu->retry.value < 0 || wrqu->retry.value >= 255) in ipw_wx_set_retry()
9335 return -EINVAL; in ipw_wx_set_retry()
9337 mutex_lock(&priv->mutex); in ipw_wx_set_retry()
9338 if (wrqu->retry.flags & IW_RETRY_SHORT) in ipw_wx_set_retry()
9339 priv->short_retry_limit = (u8) wrqu->retry.value; in ipw_wx_set_retry()
9340 else if (wrqu->retry.flags & IW_RETRY_LONG) in ipw_wx_set_retry()
9341 priv->long_retry_limit = (u8) wrqu->retry.value; in ipw_wx_set_retry()
9343 priv->short_retry_limit = (u8) wrqu->retry.value; in ipw_wx_set_retry()
9344 priv->long_retry_limit = (u8) wrqu->retry.value; in ipw_wx_set_retry()
9347 ipw_send_retry_limit(priv, priv->short_retry_limit, in ipw_wx_set_retry()
9348 priv->long_retry_limit); in ipw_wx_set_retry()
9349 mutex_unlock(&priv->mutex); in ipw_wx_set_retry()
9350 IPW_DEBUG_WX("SET retry limit -> short:%d long:%d\n", in ipw_wx_set_retry()
9351 priv->short_retry_limit, priv->long_retry_limit); in ipw_wx_set_retry()
9361 mutex_lock(&priv->mutex); in ipw_wx_get_retry()
9362 wrqu->retry.disabled = 0; in ipw_wx_get_retry()
9364 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { in ipw_wx_get_retry()
9365 mutex_unlock(&priv->mutex); in ipw_wx_get_retry()
9366 return -EINVAL; in ipw_wx_get_retry()
9369 if (wrqu->retry.flags & IW_RETRY_LONG) { in ipw_wx_get_retry()
9370 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in ipw_wx_get_retry()
9371 wrqu->retry.value = priv->long_retry_limit; in ipw_wx_get_retry()
9372 } else if (wrqu->retry.flags & IW_RETRY_SHORT) { in ipw_wx_get_retry()
9373 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT; in ipw_wx_get_retry()
9374 wrqu->retry.value = priv->short_retry_limit; in ipw_wx_get_retry()
9376 wrqu->retry.flags = IW_RETRY_LIMIT; in ipw_wx_get_retry()
9377 wrqu->retry.value = priv->short_retry_limit; in ipw_wx_get_retry()
9379 mutex_unlock(&priv->mutex); in ipw_wx_get_retry()
9381 IPW_DEBUG_WX("GET retry -> %d\n", wrqu->retry.value); in ipw_wx_get_retry()
9394 mutex_lock(&priv->mutex); in ipw_wx_set_scan()
9396 priv->user_requested_scan = 1; in ipw_wx_set_scan()
9398 if (wrqu->data.length == sizeof(struct iw_scan_req)) { in ipw_wx_set_scan()
9399 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { in ipw_wx_set_scan()
9400 int len = min((int)req->essid_len, in ipw_wx_set_scan()
9401 (int)sizeof(priv->direct_scan_ssid)); in ipw_wx_set_scan()
9402 memcpy(priv->direct_scan_ssid, req->essid, len); in ipw_wx_set_scan()
9403 priv->direct_scan_ssid_len = len; in ipw_wx_set_scan()
9404 work = &priv->request_direct_scan; in ipw_wx_set_scan()
9405 } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { in ipw_wx_set_scan()
9406 work = &priv->request_passive_scan; in ipw_wx_set_scan()
9410 work = &priv->request_scan; in ipw_wx_set_scan()
9413 mutex_unlock(&priv->mutex); in ipw_wx_set_scan()
9427 return libipw_wx_get_scan(priv->ieee, info, wrqu, extra); in ipw_wx_get_scan()
9436 u32 cap = priv->capability; in ipw_wx_set_encode()
9438 mutex_lock(&priv->mutex); in ipw_wx_set_encode()
9439 ret = libipw_wx_set_encode(priv->ieee, info, wrqu, key); in ipw_wx_set_encode()
9443 if (cap != priv->capability && in ipw_wx_set_encode()
9444 priv->ieee->iw_mode == IW_MODE_ADHOC && in ipw_wx_set_encode()
9445 priv->status & STATUS_ASSOCIATED) in ipw_wx_set_encode()
9448 mutex_unlock(&priv->mutex); in ipw_wx_set_encode()
9457 return libipw_wx_get_encode(priv->ieee, info, wrqu, key); in ipw_wx_get_encode()
9466 mutex_lock(&priv->mutex); in ipw_wx_set_power()
9467 if (wrqu->power.disabled) { in ipw_wx_set_power()
9468 priv->power_mode = IPW_POWER_LEVEL(priv->power_mode); in ipw_wx_set_power()
9472 mutex_unlock(&priv->mutex); in ipw_wx_set_power()
9475 IPW_DEBUG_WX("SET Power Management Mode -> off\n"); in ipw_wx_set_power()
9476 mutex_unlock(&priv->mutex); in ipw_wx_set_power()
9480 switch (wrqu->power.flags & IW_POWER_MODE) { in ipw_wx_set_power()
9487 wrqu->power.flags); in ipw_wx_set_power()
9488 mutex_unlock(&priv->mutex); in ipw_wx_set_power()
9489 return -EOPNOTSUPP; in ipw_wx_set_power()
9494 if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) in ipw_wx_set_power()
9495 priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY; in ipw_wx_set_power()
9497 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; in ipw_wx_set_power()
9499 err = ipw_send_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); in ipw_wx_set_power()
9502 mutex_unlock(&priv->mutex); in ipw_wx_set_power()
9506 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); in ipw_wx_set_power()
9507 mutex_unlock(&priv->mutex); in ipw_wx_set_power()
9516 mutex_lock(&priv->mutex); in ipw_wx_get_power()
9517 if (!(priv->power_mode & IPW_POWER_ENABLED)) in ipw_wx_get_power()
9518 wrqu->power.disabled = 1; in ipw_wx_get_power()
9520 wrqu->power.disabled = 0; in ipw_wx_get_power()
9522 mutex_unlock(&priv->mutex); in ipw_wx_get_power()
9523 IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode); in ipw_wx_get_power()
9536 mutex_lock(&priv->mutex); in ipw_wx_set_powermode()
9540 if (IPW_POWER_LEVEL(priv->power_mode) != mode) { in ipw_wx_set_powermode()
9544 mutex_unlock(&priv->mutex); in ipw_wx_set_powermode()
9547 priv->power_mode = IPW_POWER_ENABLED | mode; in ipw_wx_set_powermode()
9549 mutex_unlock(&priv->mutex); in ipw_wx_set_powermode()
9559 int level = IPW_POWER_LEVEL(priv->power_mode); in ipw_wx_get_powermode()
9566 p += scnprintf(p, MAX_WX_STRING - (p - extra), "(AC)"); in ipw_wx_get_powermode()
9569 p += scnprintf(p, MAX_WX_STRING - (p - extra), "(BATTERY)"); in ipw_wx_get_powermode()
9572 p += scnprintf(p, MAX_WX_STRING - (p - extra), in ipw_wx_get_powermode()
9574 timeout_duration[level - 1] / 1000, in ipw_wx_get_powermode()
9575 period_duration[level - 1] / 1000); in ipw_wx_get_powermode()
9578 if (!(priv->power_mode & IPW_POWER_ENABLED)) in ipw_wx_get_powermode()
9579 p += scnprintf(p, MAX_WX_STRING - (p - extra), " OFF"); in ipw_wx_get_powermode()
9581 wrqu->data.length = p - extra + 1; in ipw_wx_get_powermode()
9596 return -EINVAL; in ipw_wx_set_wireless_mode()
9598 mutex_lock(&priv->mutex); in ipw_wx_set_wireless_mode()
9599 if (priv->adapter == IPW_2915ABG) { in ipw_wx_set_wireless_mode()
9600 priv->ieee->abg_true = 1; in ipw_wx_set_wireless_mode()
9605 priv->ieee->abg_true = 0; in ipw_wx_set_wireless_mode()
9610 mutex_unlock(&priv->mutex); in ipw_wx_set_wireless_mode()
9611 return -EINVAL; in ipw_wx_set_wireless_mode()
9614 priv->ieee->abg_true = 0; in ipw_wx_set_wireless_mode()
9621 priv->ieee->abg_true = 0; in ipw_wx_set_wireless_mode()
9627 priv->ieee->abg_true = 0; in ipw_wx_set_wireless_mode()
9629 priv->ieee->mode = mode; in ipw_wx_set_wireless_mode()
9630 priv->ieee->freq_band = band; in ipw_wx_set_wireless_mode()
9631 priv->ieee->modulation = modulation; in ipw_wx_set_wireless_mode()
9632 init_supported_rates(priv, &priv->rates); in ipw_wx_set_wireless_mode()
9634 /* Network configuration changed -- force [re]association */ in ipw_wx_set_wireless_mode()
9637 ipw_send_supported_rates(priv, &priv->rates); in ipw_wx_set_wireless_mode()
9647 mutex_unlock(&priv->mutex); in ipw_wx_set_wireless_mode()
9656 mutex_lock(&priv->mutex); in ipw_wx_get_wireless_mode()
9657 switch (priv->ieee->mode) { in ipw_wx_get_wireless_mode()
9686 wrqu->data.length = strlen(extra) + 1; in ipw_wx_get_wireless_mode()
9687 mutex_unlock(&priv->mutex); in ipw_wx_get_wireless_mode()
9698 mutex_lock(&priv->mutex); in ipw_wx_set_preamble()
9699 /* Switching from SHORT -> LONG requires a disassociation */ in ipw_wx_set_preamble()
9701 if (!(priv->config & CFG_PREAMBLE_LONG)) { in ipw_wx_set_preamble()
9702 priv->config |= CFG_PREAMBLE_LONG; in ipw_wx_set_preamble()
9704 /* Network configuration changed -- force [re]association */ in ipw_wx_set_preamble()
9714 priv->config &= ~CFG_PREAMBLE_LONG; in ipw_wx_set_preamble()
9717 mutex_unlock(&priv->mutex); in ipw_wx_set_preamble()
9718 return -EINVAL; in ipw_wx_set_preamble()
9721 mutex_unlock(&priv->mutex); in ipw_wx_set_preamble()
9730 mutex_lock(&priv->mutex); in ipw_wx_get_preamble()
9731 if (priv->config & CFG_PREAMBLE_LONG) in ipw_wx_get_preamble()
9732 snprintf(wrqu->name, IFNAMSIZ, "long (1)"); in ipw_wx_get_preamble()
9734 snprintf(wrqu->name, IFNAMSIZ, "auto (0)"); in ipw_wx_get_preamble()
9735 mutex_unlock(&priv->mutex); in ipw_wx_get_preamble()
9747 mutex_lock(&priv->mutex); in ipw_wx_set_monitor()
9750 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { in ipw_wx_set_monitor()
9752 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; in ipw_wx_set_monitor()
9754 priv->net_dev->type = ARPHRD_IEEE80211; in ipw_wx_set_monitor()
9756 schedule_work(&priv->adapter_restart); in ipw_wx_set_monitor()
9761 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { in ipw_wx_set_monitor()
9762 mutex_unlock(&priv->mutex); in ipw_wx_set_monitor()
9765 priv->net_dev->type = ARPHRD_ETHER; in ipw_wx_set_monitor()
9766 schedule_work(&priv->adapter_restart); in ipw_wx_set_monitor()
9768 mutex_unlock(&priv->mutex); in ipw_wx_set_monitor()
9780 schedule_work(&priv->adapter_restart); in ipw_wx_reset()
9798 mutex_lock(&priv->mutex); in ipw_wx_sw_reset()
9808 ipw_radio_kill_sw(priv, priv->status & STATUS_RF_KILL_SW); in ipw_wx_sw_reset()
9810 mutex_unlock(&priv->mutex); in ipw_wx_sw_reset()
9811 libipw_wx_set_encode(priv->ieee, info, &wrqu_sec, NULL); in ipw_wx_sw_reset()
9812 mutex_lock(&priv->mutex); in ipw_wx_sw_reset()
9814 if (!(priv->status & STATUS_RF_KILL_MASK)) { in ipw_wx_sw_reset()
9815 /* Configuration likely changed -- force [re]association */ in ipw_wx_sw_reset()
9822 mutex_unlock(&priv->mutex); in ipw_wx_sw_reset()
9958 wstats = &priv->wstats; in ipw_get_wireless_stats()
9961 * netdev->get_wireless_stats seems to be called before fw is in ipw_get_wireless_stats()
9965 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw_get_wireless_stats()
9966 wstats->miss.beacon = 0; in ipw_get_wireless_stats()
9967 wstats->discard.retries = 0; in ipw_get_wireless_stats()
9968 wstats->qual.qual = 0; in ipw_get_wireless_stats()
9969 wstats->qual.level = 0; in ipw_get_wireless_stats()
9970 wstats->qual.noise = 0; in ipw_get_wireless_stats()
9971 wstats->qual.updated = 7; in ipw_get_wireless_stats()
9972 wstats->qual.updated |= IW_QUAL_NOISE_INVALID | in ipw_get_wireless_stats()
9977 wstats->qual.qual = priv->quality; in ipw_get_wireless_stats()
9978 wstats->qual.level = priv->exp_avg_rssi; in ipw_get_wireless_stats()
9979 wstats->qual.noise = priv->exp_avg_noise; in ipw_get_wireless_stats()
9980 wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | in ipw_get_wireless_stats()
9983 wstats->miss.beacon = average_value(&priv->average_missed_beacons); in ipw_get_wireless_stats()
9984 wstats->discard.retries = priv->last_tx_failures; in ipw_get_wireless_stats()
9985 wstats->discard.code = priv->ieee->ieee_stats.rx_discards_undecryptable; in ipw_get_wireless_stats()
9989 wstats->discard.retries += tx_retry; */ in ipw_get_wireless_stats()
9999 sys_config->bt_coexistence = 0; in init_sys_config()
10000 sys_config->answer_broadcast_ssid_probe = 0; in init_sys_config()
10001 sys_config->accept_all_data_frames = 0; in init_sys_config()
10002 sys_config->accept_non_directed_frames = 1; in init_sys_config()
10003 sys_config->exclude_unicast_unencrypted = 0; in init_sys_config()
10004 sys_config->disable_unicast_decryption = 1; in init_sys_config()
10005 sys_config->exclude_multicast_unencrypted = 0; in init_sys_config()
10006 sys_config->disable_multicast_decryption = 1; in init_sys_config()
10009 sys_config->antenna_diversity = antenna; in init_sys_config()
10010 sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ in init_sys_config()
10011 sys_config->dot11g_auto_detection = 0; in init_sys_config()
10012 sys_config->enable_cts_to_self = 0; in init_sys_config()
10013 sys_config->bt_coexist_collision_thr = 0; in init_sys_config()
10014 sys_config->pass_noise_stats_to_host = 1; /* 1 -- fix for 256 */ in init_sys_config()
10015 sys_config->silence_threshold = 0x1e; in init_sys_config()
10020 IPW_DEBUG_INFO("dev->open\n"); in ipw_net_open()
10027 IPW_DEBUG_INFO("dev->close\n"); in ipw_net_stop()
10043 txb->fragments[0]->data; in ipw_tx_skb()
10048 struct clx2_tx_queue *txq = &priv->txq[tx_id]; in ipw_tx_skb()
10050 struct clx2_tx_queue *txq = &priv->txq[0]; in ipw_tx_skb()
10052 struct clx2_queue *q = &txq->q; in ipw_tx_skb()
10056 if (!(priv->status & STATUS_ASSOCIATED)) in ipw_tx_skb()
10059 hdr_len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); in ipw_tx_skb()
10060 switch (priv->ieee->iw_mode) { in ipw_tx_skb()
10062 unicast = !is_multicast_ether_addr(hdr->addr1); in ipw_tx_skb()
10063 id = ipw_find_station(priv, hdr->addr1); in ipw_tx_skb()
10065 id = ipw_add_station(priv, hdr->addr1); in ipw_tx_skb()
10069 hdr->addr1); in ipw_tx_skb()
10077 unicast = !is_multicast_ether_addr(hdr->addr3); in ipw_tx_skb()
10082 tfd = &txq->bd[q->first_empty]; in ipw_tx_skb()
10083 txq->txb[q->first_empty] = txb; in ipw_tx_skb()
10085 tfd->u.data.station_number = id; in ipw_tx_skb()
10087 tfd->control_flags.message_type = TX_FRAME_TYPE; in ipw_tx_skb()
10088 tfd->control_flags.control_bits = TFD_NEED_IRQ_MASK; in ipw_tx_skb()
10090 tfd->u.data.cmd_id = DINO_CMD_TX; in ipw_tx_skb()
10091 tfd->u.data.len = cpu_to_le16(txb->payload_size); in ipw_tx_skb()
10093 if (priv->assoc_request.ieee_mode == IPW_B_MODE) in ipw_tx_skb()
10094 tfd->u.data.tx_flags_ext |= DCT_FLAG_EXT_MODE_CCK; in ipw_tx_skb()
10096 tfd->u.data.tx_flags_ext |= DCT_FLAG_EXT_MODE_OFDM; in ipw_tx_skb()
10098 if (priv->assoc_request.preamble_length == DCT_FLAG_SHORT_PREAMBLE) in ipw_tx_skb()
10099 tfd->u.data.tx_flags |= DCT_FLAG_SHORT_PREAMBLE; in ipw_tx_skb()
10101 fc = le16_to_cpu(hdr->frame_ctl); in ipw_tx_skb()
10102 hdr->frame_ctl = cpu_to_le16(fc & ~IEEE80211_FCTL_MOREFRAGS); in ipw_tx_skb()
10104 memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len); in ipw_tx_skb()
10107 tfd->u.data.tx_flags |= DCT_FLAG_ACK_REQD; in ipw_tx_skb()
10109 if (txb->encrypted && !priv->ieee->host_encrypt) { in ipw_tx_skb()
10110 switch (priv->ieee->sec.level) { in ipw_tx_skb()
10112 tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |= in ipw_tx_skb()
10119 tfd->u.data.tx_flags |= DCT_FLAG_ACK_REQD; in ipw_tx_skb()
10121 tfd->u.data.tx_flags &= ~DCT_FLAG_NO_WEP; in ipw_tx_skb()
10122 tfd->u.data.tx_flags_ext |= DCT_FLAG_EXT_SECURITY_CCM; in ipw_tx_skb()
10123 tfd->u.data.key_index = 0; in ipw_tx_skb()
10124 tfd->u.data.key_index |= DCT_WEP_INDEX_USE_IMMEDIATE; in ipw_tx_skb()
10127 tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |= in ipw_tx_skb()
10129 tfd->u.data.tx_flags &= ~DCT_FLAG_NO_WEP; in ipw_tx_skb()
10130 tfd->u.data.tx_flags_ext |= DCT_FLAG_EXT_SECURITY_TKIP; in ipw_tx_skb()
10131 tfd->u.data.key_index = DCT_WEP_INDEX_USE_IMMEDIATE; in ipw_tx_skb()
10134 tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |= in ipw_tx_skb()
10136 tfd->u.data.key_index = priv->ieee->crypt_info.tx_keyidx; in ipw_tx_skb()
10137 if (priv->ieee->sec.key_sizes[priv->ieee->crypt_info.tx_keyidx] <= in ipw_tx_skb()
10139 tfd->u.data.key_index |= DCT_WEP_KEY_64Bit; in ipw_tx_skb()
10141 tfd->u.data.key_index |= DCT_WEP_KEY_128Bit; in ipw_tx_skb()
10147 priv->ieee->sec.level); in ipw_tx_skb()
10152 tfd->u.data.tx_flags |= DCT_FLAG_NO_WEP; in ipw_tx_skb()
10156 ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data)); in ipw_tx_skb()
10160 tfd->u.data.num_chunks = cpu_to_le32(min((u8) (NUM_TFD_CHUNKS - 2), in ipw_tx_skb()
10161 txb->nr_frags)); in ipw_tx_skb()
10163 txb->nr_frags, le32_to_cpu(tfd->u.data.num_chunks)); in ipw_tx_skb()
10164 for (i = 0; i < le32_to_cpu(tfd->u.data.num_chunks); i++) { in ipw_tx_skb()
10166 i, le32_to_cpu(tfd->u.data.num_chunks), in ipw_tx_skb()
10167 txb->fragments[i]->len - hdr_len); in ipw_tx_skb()
10169 i, tfd->u.data.num_chunks, in ipw_tx_skb()
10170 txb->fragments[i]->len - hdr_len); in ipw_tx_skb()
10171 printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len, in ipw_tx_skb()
10172 txb->fragments[i]->len - hdr_len); in ipw_tx_skb()
10174 tfd->u.data.chunk_ptr[i] = in ipw_tx_skb()
10175 cpu_to_le32(dma_map_single(&priv->pci_dev->dev, in ipw_tx_skb()
10176 txb->fragments[i]->data + hdr_len, in ipw_tx_skb()
10177 txb->fragments[i]->len - hdr_len, in ipw_tx_skb()
10179 tfd->u.data.chunk_len[i] = in ipw_tx_skb()
10180 cpu_to_le16(txb->fragments[i]->len - hdr_len); in ipw_tx_skb()
10183 if (i != txb->nr_frags) { in ipw_tx_skb()
10188 for (j = i; j < txb->nr_frags; j++) in ipw_tx_skb()
10189 remaining_bytes += txb->fragments[j]->len - hdr_len; in ipw_tx_skb()
10195 tfd->u.data.chunk_len[i] = cpu_to_le16(remaining_bytes); in ipw_tx_skb()
10196 for (j = i; j < txb->nr_frags; j++) { in ipw_tx_skb()
10197 int size = txb->fragments[j]->len - hdr_len; in ipw_tx_skb()
10202 txb->fragments[j]->data + hdr_len, in ipw_tx_skb()
10205 dev_kfree_skb_any(txb->fragments[i]); in ipw_tx_skb()
10206 txb->fragments[i] = skb; in ipw_tx_skb()
10207 tfd->u.data.chunk_ptr[i] = in ipw_tx_skb()
10208 cpu_to_le32(dma_map_single(&priv->pci_dev->dev, in ipw_tx_skb()
10209 skb->data, in ipw_tx_skb()
10213 le32_add_cpu(&tfd->u.data.num_chunks, 1); in ipw_tx_skb()
10218 q->first_empty = ipw_queue_inc_wrap(q->first_empty, q->n_bd); in ipw_tx_skb()
10219 ipw_write32(priv, q->reg_w, q->first_empty); in ipw_tx_skb()
10221 if (ipw_tx_queue_space(q) < q->high_mark) in ipw_tx_skb()
10222 netif_stop_queue(priv->net_dev); in ipw_tx_skb()
10237 struct clx2_tx_queue *txq = &priv->txq[tx_id]; in ipw_net_is_queue_full()
10239 struct clx2_tx_queue *txq = &priv->txq[0]; in ipw_net_is_queue_full()
10242 if (ipw_tx_queue_space(&txq->q) < txq->q.high_mark) in ipw_net_is_queue_full()
10255 u16 filter = priv->prom_priv->filter; in ipw_handle_promiscuous_tx()
10264 hdr = (void *)txb->fragments[0]->data; in ipw_handle_promiscuous_tx()
10265 if (libipw_is_management(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_tx()
10270 } else if (libipw_is_control(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_tx()
10275 } else if (libipw_is_data(le16_to_cpu(hdr->frame_control))) { in ipw_handle_promiscuous_tx()
10282 for(n=0; n<txb->nr_frags; ++n) { in ipw_handle_promiscuous_tx()
10283 struct sk_buff *src = txb->fragments[n]; in ipw_handle_promiscuous_tx()
10289 hdr = (void *)src->data; in ipw_handle_promiscuous_tx()
10290 len = libipw_get_hdrlen(le16_to_cpu(hdr->frame_control)); in ipw_handle_promiscuous_tx()
10292 len = src->len; in ipw_handle_promiscuous_tx()
10300 rt_hdr->it_version = PKTHDR_RADIOTAP_VERSION; in ipw_handle_promiscuous_tx()
10301 rt_hdr->it_pad = 0; in ipw_handle_promiscuous_tx()
10302 rt_hdr->it_present = 0; /* after all, it's just an idea */ in ipw_handle_promiscuous_tx()
10303 rt_hdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_CHANNEL); in ipw_handle_promiscuous_tx()
10306 ieee80211chan2mhz(priv->channel)); in ipw_handle_promiscuous_tx()
10307 if (priv->channel > 14) /* 802.11a */ in ipw_handle_promiscuous_tx()
10311 else if (priv->ieee->mode == IEEE_B) /* 802.11b */ in ipw_handle_promiscuous_tx()
10320 rt_hdr->it_len = cpu_to_le16(dst->len); in ipw_handle_promiscuous_tx()
10324 if (!libipw_rx(priv->prom_priv->ieee, dst, &dummystats)) in ipw_handle_promiscuous_tx()
10337 IPW_DEBUG_TX("dev->xmit(%d bytes)\n", txb->payload_size); in ipw_net_hard_start_xmit()
10338 spin_lock_irqsave(&priv->lock, flags); in ipw_net_hard_start_xmit()
10341 if (rtap_iface && netif_running(priv->prom_net_dev)) in ipw_net_hard_start_xmit()
10348 spin_unlock_irqrestore(&priv->lock, flags); in ipw_net_hard_start_xmit()
10363 if (!is_valid_ether_addr(addr->sa_data)) in ipw_net_set_mac_address()
10364 return -EADDRNOTAVAIL; in ipw_net_set_mac_address()
10365 mutex_lock(&priv->mutex); in ipw_net_set_mac_address()
10366 priv->config |= CFG_CUSTOM_MAC; in ipw_net_set_mac_address()
10367 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); in ipw_net_set_mac_address()
10369 priv->net_dev->name, priv->mac_addr); in ipw_net_set_mac_address()
10370 schedule_work(&priv->adapter_restart); in ipw_net_set_mac_address()
10371 mutex_unlock(&priv->mutex); in ipw_net_set_mac_address()
10382 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in ipw_ethtool_get_drvinfo()
10383 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in ipw_ethtool_get_drvinfo()
10388 strscpy(info->fw_version, vers, sizeof(info->fw_version)); in ipw_ethtool_get_drvinfo()
10389 strscpy(info->bus_info, pci_name(p->pci_dev), in ipw_ethtool_get_drvinfo()
10390 sizeof(info->bus_info)); in ipw_ethtool_get_drvinfo()
10396 return (priv->status & STATUS_ASSOCIATED) != 0; in ipw_ethtool_get_link()
10409 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) in ipw_ethtool_get_eeprom()
10410 return -EINVAL; in ipw_ethtool_get_eeprom()
10411 mutex_lock(&p->mutex); in ipw_ethtool_get_eeprom()
10412 memcpy(bytes, &p->eeprom[eeprom->offset], eeprom->len); in ipw_ethtool_get_eeprom()
10413 mutex_unlock(&p->mutex); in ipw_ethtool_get_eeprom()
10423 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) in ipw_ethtool_set_eeprom()
10424 return -EINVAL; in ipw_ethtool_set_eeprom()
10425 mutex_lock(&p->mutex); in ipw_ethtool_set_eeprom()
10426 memcpy(&p->eeprom[eeprom->offset], bytes, eeprom->len); in ipw_ethtool_set_eeprom()
10428 ipw_write8(p, i + IPW_EEPROM_DATA, p->eeprom[i]); in ipw_ethtool_set_eeprom()
10429 mutex_unlock(&p->mutex); in ipw_ethtool_set_eeprom()
10449 spin_lock(&priv->irq_lock); in ipw_isr()
10451 if (!(priv->status & STATUS_INT_ENABLED)) { in ipw_isr()
10478 priv->isr_inta = inta; in ipw_isr()
10480 tasklet_schedule(&priv->irq_tasklet); in ipw_isr()
10482 spin_unlock(&priv->irq_lock); in ipw_isr()
10486 spin_unlock(&priv->irq_lock); in ipw_isr()
10495 spin_lock_irqsave(&priv->lock, flags); in ipw_rf_kill()
10499 schedule_delayed_work(&priv->rf_kill, 2 * HZ); in ipw_rf_kill()
10505 if (!(priv->status & STATUS_RF_KILL_MASK)) { in ipw_rf_kill()
10510 schedule_work(&priv->adapter_restart); in ipw_rf_kill()
10516 spin_unlock_irqrestore(&priv->lock, flags); in ipw_rf_kill()
10523 mutex_lock(&priv->mutex); in ipw_bg_rf_kill()
10525 mutex_unlock(&priv->mutex); in ipw_bg_rf_kill()
10530 priv->last_seq_num = -1; in ipw_link_up()
10531 priv->last_frag_num = -1; in ipw_link_up()
10532 priv->last_packet_time = 0; in ipw_link_up()
10534 netif_carrier_on(priv->net_dev); in ipw_link_up()
10536 cancel_delayed_work(&priv->request_scan); in ipw_link_up()
10537 cancel_delayed_work(&priv->request_direct_scan); in ipw_link_up()
10538 cancel_delayed_work(&priv->request_passive_scan); in ipw_link_up()
10539 cancel_delayed_work(&priv->scan_event); in ipw_link_up()
10542 priv->last_rate = ipw_get_current_rate(priv); in ipw_link_up()
10547 if (priv->config & CFG_BACKGROUND_SCAN) in ipw_link_up()
10548 schedule_delayed_work(&priv->request_scan, HZ); in ipw_link_up()
10555 mutex_lock(&priv->mutex); in ipw_bg_link_up()
10557 mutex_unlock(&priv->mutex); in ipw_bg_link_up()
10563 netif_carrier_off(priv->net_dev); in ipw_link_down()
10567 cancel_delayed_work(&priv->request_scan); in ipw_link_down()
10568 cancel_delayed_work(&priv->request_direct_scan); in ipw_link_down()
10569 cancel_delayed_work(&priv->request_passive_scan); in ipw_link_down()
10570 cancel_delayed_work(&priv->adhoc_check); in ipw_link_down()
10571 cancel_delayed_work(&priv->gather_stats); in ipw_link_down()
10575 if (!(priv->status & STATUS_EXIT_PENDING)) { in ipw_link_down()
10577 schedule_delayed_work(&priv->request_scan, 0); in ipw_link_down()
10579 cancel_delayed_work(&priv->scan_event); in ipw_link_down()
10586 mutex_lock(&priv->mutex); in ipw_bg_link_down()
10588 mutex_unlock(&priv->mutex); in ipw_bg_link_down()
10593 init_waitqueue_head(&priv->wait_command_queue); in ipw_setup_deferred_work()
10594 init_waitqueue_head(&priv->wait_state); in ipw_setup_deferred_work()
10596 INIT_DELAYED_WORK(&priv->adhoc_check, ipw_bg_adhoc_check); in ipw_setup_deferred_work()
10597 INIT_WORK(&priv->associate, ipw_bg_associate); in ipw_setup_deferred_work()
10598 INIT_WORK(&priv->disassociate, ipw_bg_disassociate); in ipw_setup_deferred_work()
10599 INIT_WORK(&priv->system_config, ipw_system_config); in ipw_setup_deferred_work()
10600 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish); in ipw_setup_deferred_work()
10601 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart); in ipw_setup_deferred_work()
10602 INIT_DELAYED_WORK(&priv->rf_kill, ipw_bg_rf_kill); in ipw_setup_deferred_work()
10603 INIT_WORK(&priv->up, ipw_bg_up); in ipw_setup_deferred_work()
10604 INIT_WORK(&priv->down, ipw_bg_down); in ipw_setup_deferred_work()
10605 INIT_DELAYED_WORK(&priv->request_scan, ipw_request_scan); in ipw_setup_deferred_work()
10606 INIT_DELAYED_WORK(&priv->request_direct_scan, ipw_request_direct_scan); in ipw_setup_deferred_work()
10607 INIT_DELAYED_WORK(&priv->request_passive_scan, ipw_request_passive_scan); in ipw_setup_deferred_work()
10608 INIT_DELAYED_WORK(&priv->scan_event, ipw_scan_event); in ipw_setup_deferred_work()
10609 INIT_DELAYED_WORK(&priv->gather_stats, ipw_bg_gather_stats); in ipw_setup_deferred_work()
10610 INIT_WORK(&priv->abort_scan, ipw_bg_abort_scan); in ipw_setup_deferred_work()
10611 INIT_WORK(&priv->roam, ipw_bg_roam); in ipw_setup_deferred_work()
10612 INIT_DELAYED_WORK(&priv->scan_check, ipw_bg_scan_check); in ipw_setup_deferred_work()
10613 INIT_WORK(&priv->link_up, ipw_bg_link_up); in ipw_setup_deferred_work()
10614 INIT_WORK(&priv->link_down, ipw_bg_link_down); in ipw_setup_deferred_work()
10615 INIT_DELAYED_WORK(&priv->led_link_on, ipw_bg_led_link_on); in ipw_setup_deferred_work()
10616 INIT_DELAYED_WORK(&priv->led_link_off, ipw_bg_led_link_off); in ipw_setup_deferred_work()
10617 INIT_DELAYED_WORK(&priv->led_act_off, ipw_bg_led_activity_off); in ipw_setup_deferred_work()
10618 INIT_WORK(&priv->merge_networks, ipw_merge_adhoc_network); in ipw_setup_deferred_work()
10621 INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate); in ipw_setup_deferred_work()
10624 tasklet_setup(&priv->irq_tasklet, ipw_irq_tasklet); in ipw_setup_deferred_work()
10633 if (sec->flags & (1 << i)) { in shim__set_security()
10634 priv->ieee->sec.encode_alg[i] = sec->encode_alg[i]; in shim__set_security()
10635 priv->ieee->sec.key_sizes[i] = sec->key_sizes[i]; in shim__set_security()
10636 if (sec->key_sizes[i] == 0) in shim__set_security()
10637 priv->ieee->sec.flags &= ~(1 << i); in shim__set_security()
10639 memcpy(priv->ieee->sec.keys[i], sec->keys[i], in shim__set_security()
10640 sec->key_sizes[i]); in shim__set_security()
10641 priv->ieee->sec.flags |= (1 << i); in shim__set_security()
10643 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
10644 } else if (sec->level != SEC_LEVEL_1) in shim__set_security()
10645 priv->ieee->sec.flags &= ~(1 << i); in shim__set_security()
10648 if (sec->flags & SEC_ACTIVE_KEY) { in shim__set_security()
10649 priv->ieee->sec.active_key = sec->active_key; in shim__set_security()
10650 priv->ieee->sec.flags |= SEC_ACTIVE_KEY; in shim__set_security()
10651 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
10653 priv->ieee->sec.flags &= ~SEC_ACTIVE_KEY; in shim__set_security()
10655 if ((sec->flags & SEC_AUTH_MODE) && in shim__set_security()
10656 (priv->ieee->sec.auth_mode != sec->auth_mode)) { in shim__set_security()
10657 priv->ieee->sec.auth_mode = sec->auth_mode; in shim__set_security()
10658 priv->ieee->sec.flags |= SEC_AUTH_MODE; in shim__set_security()
10659 if (sec->auth_mode == WLAN_AUTH_SHARED_KEY) in shim__set_security()
10660 priv->capability |= CAP_SHARED_KEY; in shim__set_security()
10662 priv->capability &= ~CAP_SHARED_KEY; in shim__set_security()
10663 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
10666 if (sec->flags & SEC_ENABLED && priv->ieee->sec.enabled != sec->enabled) { in shim__set_security()
10667 priv->ieee->sec.flags |= SEC_ENABLED; in shim__set_security()
10668 priv->ieee->sec.enabled = sec->enabled; in shim__set_security()
10669 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
10670 if (sec->enabled) in shim__set_security()
10671 priv->capability |= CAP_PRIVACY_ON; in shim__set_security()
10673 priv->capability &= ~CAP_PRIVACY_ON; in shim__set_security()
10676 if (sec->flags & SEC_ENCRYPT) in shim__set_security()
10677 priv->ieee->sec.encrypt = sec->encrypt; in shim__set_security()
10679 if (sec->flags & SEC_LEVEL && priv->ieee->sec.level != sec->level) { in shim__set_security()
10680 priv->ieee->sec.level = sec->level; in shim__set_security()
10681 priv->ieee->sec.flags |= SEC_LEVEL; in shim__set_security()
10682 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
10685 if (!priv->ieee->host_encrypt && (sec->flags & SEC_ENCRYPT)) in shim__set_security()
10692 if ((priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) && in shim__set_security()
10693 (((priv->assoc_request.capability & in shim__set_security()
10694 cpu_to_le16(WLAN_CAPABILITY_PRIVACY)) && !sec->enabled) || in shim__set_security()
10695 (!(priv->assoc_request.capability & in shim__set_security()
10696 cpu_to_le16(WLAN_CAPABILITY_PRIVACY)) && sec->enabled))) { in shim__set_security()
10707 /* TODO: Mask out rates based on priv->rates_mask */ in init_supported_rates()
10711 switch (priv->ieee->freq_band) { in init_supported_rates()
10713 rates->ieee_mode = IPW_A_MODE; in init_supported_rates()
10714 rates->purpose = IPW_RATE_CAPABILITIES; in init_supported_rates()
10720 rates->ieee_mode = IPW_G_MODE; in init_supported_rates()
10721 rates->purpose = IPW_RATE_CAPABILITIES; in init_supported_rates()
10724 if (priv->ieee->modulation & LIBIPW_OFDM_MODULATION) { in init_supported_rates()
10743 if (ipw_send_adapter_address(priv, priv->net_dev->dev_addr)) in ipw_config()
10747 init_sys_config(&priv->sys_config); in ipw_config()
10752 unsigned char bt_caps = priv->eeprom[EEPROM_SKU_CAPABILITY]; in ipw_config()
10755 priv->sys_config.bt_coexistence in ipw_config()
10758 priv->sys_config.bt_coexistence in ipw_config()
10763 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) { in ipw_config()
10764 priv->sys_config.accept_all_data_frames = 1; in ipw_config()
10765 priv->sys_config.accept_non_directed_frames = 1; in ipw_config()
10766 priv->sys_config.accept_all_mgmt_bcpr = 1; in ipw_config()
10767 priv->sys_config.accept_all_mgmt_frames = 1; in ipw_config()
10771 if (priv->ieee->iw_mode == IW_MODE_ADHOC) in ipw_config()
10772 priv->sys_config.answer_broadcast_ssid_probe = 1; in ipw_config()
10774 priv->sys_config.answer_broadcast_ssid_probe = 0; in ipw_config()
10779 init_supported_rates(priv, &priv->rates); in ipw_config()
10780 if (ipw_send_supported_rates(priv, &priv->rates)) in ipw_config()
10783 /* Set request-to-send threshold */ in ipw_config()
10784 if (priv->rts_threshold) { in ipw_config()
10785 if (ipw_send_rts_threshold(priv, priv->rts_threshold)) in ipw_config()
10800 priv->status |= STATUS_INIT; in ipw_config()
10804 priv->notif_missed_beacons = 0; in ipw_config()
10807 if ((priv->capability & CAP_PRIVACY_ON) && in ipw_config()
10808 (priv->ieee->sec.level == SEC_LEVEL_1) && in ipw_config()
10809 !(priv->ieee->host_encrypt || priv->ieee->host_decrypt)) in ipw_config()
10815 return -EIO; in ipw_config()
10834 "---",
11083 if (!memcmp(&priv->eeprom[EEPROM_COUNTRY_CODE], in ipw_set_geo()
11090 priv->eeprom[EEPROM_COUNTRY_CODE + 0], in ipw_set_geo()
11091 priv->eeprom[EEPROM_COUNTRY_CODE + 1], in ipw_set_geo()
11092 priv->eeprom[EEPROM_COUNTRY_CODE + 2]); in ipw_set_geo()
11096 libipw_set_geo(priv->ieee, &ipw_geos[j]); in ipw_set_geo()
11105 if (priv->suspend_time) { in ipw_up()
11106 libipw_networks_age(priv->ieee, priv->suspend_time); in ipw_up()
11107 priv->suspend_time = 0; in ipw_up()
11110 if (priv->status & STATUS_EXIT_PENDING) in ipw_up()
11111 return -EIO; in ipw_up()
11113 if (cmdlog && !priv->cmdlog) { in ipw_up()
11114 priv->cmdlog = kcalloc(cmdlog, sizeof(*priv->cmdlog), in ipw_up()
11116 if (priv->cmdlog == NULL) { in ipw_up()
11119 return -ENOMEM; in ipw_up()
11121 priv->cmdlog_len = cmdlog; in ipw_up()
11135 if (!(priv->config & CFG_CUSTOM_MAC)) in ipw_up()
11136 eeprom_parse_mac(priv, priv->mac_addr); in ipw_up()
11137 eth_hw_addr_set(priv->net_dev, priv->mac_addr); in ipw_up()
11141 if (priv->status & STATUS_RF_KILL_SW) { in ipw_up()
11148 schedule_delayed_work(&priv->rf_kill, 2 * HZ); in ipw_up()
11156 /* If configure to try and auto-associate, kick in ipw_up()
11158 schedule_delayed_work(&priv->request_scan, 0); in ipw_up()
11176 return -EIO; in ipw_up()
11183 mutex_lock(&priv->mutex); in ipw_bg_up()
11185 mutex_unlock(&priv->mutex); in ipw_bg_up()
11192 if (priv->status & STATUS_SCANNING) { in ipw_deinit()
11197 if (priv->status & STATUS_ASSOCIATED) { in ipw_deinit()
11207 for (i = 1000; i && (priv->status & in ipw_deinit()
11209 STATUS_ASSOCIATED | STATUS_SCANNING)); i--) in ipw_deinit()
11212 if (priv->status & (STATUS_DISASSOCIATING | in ipw_deinit()
11216 IPW_DEBUG_INFO("Took %dms to de-init\n", 1000 - i); in ipw_deinit()
11221 priv->status &= ~STATUS_INIT; in ipw_deinit()
11226 int exit_pending = priv->status & STATUS_EXIT_PENDING; in ipw_down()
11228 priv->status |= STATUS_EXIT_PENDING; in ipw_down()
11236 priv->status &= ~STATUS_EXIT_PENDING; in ipw_down()
11242 priv->status &= STATUS_RF_KILL_MASK | STATUS_EXIT_PENDING; in ipw_down()
11243 netif_carrier_off(priv->net_dev); in ipw_down()
11254 mutex_lock(&priv->mutex); in ipw_bg_down()
11256 mutex_unlock(&priv->mutex); in ipw_bg_down()
11263 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw_wdev_init()
11264 struct wireless_dev *wdev = &priv->ieee->wdev; in ipw_wdev_init()
11266 memcpy(wdev->wiphy->perm_addr, priv->mac_addr, ETH_ALEN); in ipw_wdev_init()
11268 /* fill-out priv->ieee->bg_band */ in ipw_wdev_init()
11269 if (geo->bg_channels) { in ipw_wdev_init()
11270 struct ieee80211_supported_band *bg_band = &priv->ieee->bg_band; in ipw_wdev_init()
11272 bg_band->band = NL80211_BAND_2GHZ; in ipw_wdev_init()
11273 bg_band->n_channels = geo->bg_channels; in ipw_wdev_init()
11274 bg_band->channels = kcalloc(geo->bg_channels, in ipw_wdev_init()
11277 if (!bg_band->channels) { in ipw_wdev_init()
11278 rc = -ENOMEM; in ipw_wdev_init()
11281 /* translate geo->bg to bg_band.channels */ in ipw_wdev_init()
11282 for (i = 0; i < geo->bg_channels; i++) { in ipw_wdev_init()
11283 bg_band->channels[i].band = NL80211_BAND_2GHZ; in ipw_wdev_init()
11284 bg_band->channels[i].center_freq = geo->bg[i].freq; in ipw_wdev_init()
11285 bg_band->channels[i].hw_value = geo->bg[i].channel; in ipw_wdev_init()
11286 bg_band->channels[i].max_power = geo->bg[i].max_power; in ipw_wdev_init()
11287 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY) in ipw_wdev_init()
11288 bg_band->channels[i].flags |= in ipw_wdev_init()
11290 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS) in ipw_wdev_init()
11291 bg_band->channels[i].flags |= in ipw_wdev_init()
11293 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT) in ipw_wdev_init()
11294 bg_band->channels[i].flags |= in ipw_wdev_init()
11301 bg_band->bitrates = ipw2200_bg_rates; in ipw_wdev_init()
11302 bg_band->n_bitrates = ipw2200_num_bg_rates; in ipw_wdev_init()
11304 wdev->wiphy->bands[NL80211_BAND_2GHZ] = bg_band; in ipw_wdev_init()
11307 /* fill-out priv->ieee->a_band */ in ipw_wdev_init()
11308 if (geo->a_channels) { in ipw_wdev_init()
11309 struct ieee80211_supported_band *a_band = &priv->ieee->a_band; in ipw_wdev_init()
11311 a_band->band = NL80211_BAND_5GHZ; in ipw_wdev_init()
11312 a_band->n_channels = geo->a_channels; in ipw_wdev_init()
11313 a_band->channels = kcalloc(geo->a_channels, in ipw_wdev_init()
11316 if (!a_band->channels) { in ipw_wdev_init()
11317 rc = -ENOMEM; in ipw_wdev_init()
11320 /* translate geo->a to a_band.channels */ in ipw_wdev_init()
11321 for (i = 0; i < geo->a_channels; i++) { in ipw_wdev_init()
11322 a_band->channels[i].band = NL80211_BAND_5GHZ; in ipw_wdev_init()
11323 a_band->channels[i].center_freq = geo->a[i].freq; in ipw_wdev_init()
11324 a_band->channels[i].hw_value = geo->a[i].channel; in ipw_wdev_init()
11325 a_band->channels[i].max_power = geo->a[i].max_power; in ipw_wdev_init()
11326 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY) in ipw_wdev_init()
11327 a_band->channels[i].flags |= in ipw_wdev_init()
11329 if (geo->a[i].flags & LIBIPW_CH_NO_IBSS) in ipw_wdev_init()
11330 a_band->channels[i].flags |= in ipw_wdev_init()
11332 if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT) in ipw_wdev_init()
11333 a_band->channels[i].flags |= in ipw_wdev_init()
11340 a_band->bitrates = ipw2200_a_rates; in ipw_wdev_init()
11341 a_band->n_bitrates = ipw2200_num_a_rates; in ipw_wdev_init()
11343 wdev->wiphy->bands[NL80211_BAND_5GHZ] = a_band; in ipw_wdev_init()
11346 wdev->wiphy->cipher_suites = ipw_cipher_suites; in ipw_wdev_init()
11347 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(ipw_cipher_suites); in ipw_wdev_init()
11349 set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev); in ipw_wdev_init()
11352 rc = wiphy_register(wdev->wiphy); in ipw_wdev_init()
11358 kfree(priv->ieee->a_band.channels); in ipw_wdev_init()
11359 kfree(priv->ieee->bg_band.channels); in ipw_wdev_init()
11431 struct ipw_priv *priv = prom_priv->priv; in ipw_prom_open()
11433 IPW_DEBUG_INFO("prom dev->open\n"); in ipw_prom_open()
11436 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { in ipw_prom_open()
11437 priv->sys_config.accept_all_data_frames = 1; in ipw_prom_open()
11438 priv->sys_config.accept_non_directed_frames = 1; in ipw_prom_open()
11439 priv->sys_config.accept_all_mgmt_bcpr = 1; in ipw_prom_open()
11440 priv->sys_config.accept_all_mgmt_frames = 1; in ipw_prom_open()
11451 struct ipw_priv *priv = prom_priv->priv; in ipw_prom_stop()
11453 IPW_DEBUG_INFO("prom dev->stop\n"); in ipw_prom_stop()
11455 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { in ipw_prom_stop()
11456 priv->sys_config.accept_all_data_frames = 0; in ipw_prom_stop()
11457 priv->sys_config.accept_non_directed_frames = 0; in ipw_prom_stop()
11458 priv->sys_config.accept_all_mgmt_bcpr = 0; in ipw_prom_stop()
11459 priv->sys_config.accept_all_mgmt_frames = 0; in ipw_prom_stop()
11470 IPW_DEBUG_INFO("prom dev->xmit\n"); in ipw_prom_hard_start_xmit()
11487 if (priv->prom_net_dev) in ipw_prom_alloc()
11488 return -EPERM; in ipw_prom_alloc()
11490 priv->prom_net_dev = alloc_libipw(sizeof(struct ipw_prom_priv), 1); in ipw_prom_alloc()
11491 if (priv->prom_net_dev == NULL) in ipw_prom_alloc()
11492 return -ENOMEM; in ipw_prom_alloc()
11494 priv->prom_priv = libipw_priv(priv->prom_net_dev); in ipw_prom_alloc()
11495 priv->prom_priv->ieee = netdev_priv(priv->prom_net_dev); in ipw_prom_alloc()
11496 priv->prom_priv->priv = priv; in ipw_prom_alloc()
11498 strcpy(priv->prom_net_dev->name, "rtap%d"); in ipw_prom_alloc()
11499 eth_hw_addr_set(priv->prom_net_dev, priv->mac_addr); in ipw_prom_alloc()
11501 priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP; in ipw_prom_alloc()
11502 priv->prom_net_dev->netdev_ops = &ipw_prom_netdev_ops; in ipw_prom_alloc()
11504 priv->prom_net_dev->min_mtu = 68; in ipw_prom_alloc()
11505 priv->prom_net_dev->max_mtu = LIBIPW_DATA_LEN; in ipw_prom_alloc()
11507 priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR; in ipw_prom_alloc()
11508 SET_NETDEV_DEV(priv->prom_net_dev, &priv->pci_dev->dev); in ipw_prom_alloc()
11510 rc = register_netdev(priv->prom_net_dev); in ipw_prom_alloc()
11512 free_libipw(priv->prom_net_dev, 1); in ipw_prom_alloc()
11513 priv->prom_net_dev = NULL; in ipw_prom_alloc()
11522 if (!priv->prom_net_dev) in ipw_prom_free()
11525 unregister_netdev(priv->prom_net_dev); in ipw_prom_free()
11526 free_libipw(priv->prom_net_dev, 1); in ipw_prom_free()
11528 priv->prom_net_dev = NULL; in ipw_prom_free()
11554 err = -ENOMEM; in ipw_pci_probe()
11559 priv->ieee = netdev_priv(net_dev); in ipw_pci_probe()
11561 priv->net_dev = net_dev; in ipw_pci_probe()
11562 priv->pci_dev = pdev; in ipw_pci_probe()
11564 spin_lock_init(&priv->irq_lock); in ipw_pci_probe()
11565 spin_lock_init(&priv->lock); in ipw_pci_probe()
11567 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]); in ipw_pci_probe()
11569 mutex_init(&priv->mutex); in ipw_pci_probe()
11571 err = -ENODEV; in ipw_pci_probe()
11577 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in ipw_pci_probe()
11579 err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); in ipw_pci_probe()
11598 priv->hw_len = length; in ipw_pci_probe()
11602 err = -ENODEV; in ipw_pci_probe()
11606 priv->hw_base = base; in ipw_pci_probe()
11614 err = request_irq(pdev->irq, ipw_isr, IRQF_SHARED, DRV_NAME, priv); in ipw_pci_probe()
11616 IPW_ERROR("Error allocating IRQ %d\n", pdev->irq); in ipw_pci_probe()
11620 SET_NETDEV_DEV(net_dev, &pdev->dev); in ipw_pci_probe()
11622 mutex_lock(&priv->mutex); in ipw_pci_probe()
11624 priv->ieee->hard_start_xmit = ipw_net_hard_start_xmit; in ipw_pci_probe()
11625 priv->ieee->set_security = shim__set_security; in ipw_pci_probe()
11626 priv->ieee->is_queue_full = ipw_net_is_queue_full; in ipw_pci_probe()
11629 priv->ieee->is_qos_active = ipw_is_qos_active; in ipw_pci_probe()
11630 priv->ieee->handle_probe_response = ipw_handle_beacon; in ipw_pci_probe()
11631 priv->ieee->handle_beacon = ipw_handle_probe_response; in ipw_pci_probe()
11632 priv->ieee->handle_assoc_response = ipw_handle_assoc_response; in ipw_pci_probe()
11635 priv->ieee->perfect_rssi = -20; in ipw_pci_probe()
11636 priv->ieee->worst_rssi = -85; in ipw_pci_probe()
11638 net_dev->netdev_ops = &ipw_netdev_ops; in ipw_pci_probe()
11639 priv->wireless_data.spy_data = &priv->ieee->spy_data; in ipw_pci_probe()
11640 net_dev->wireless_data = &priv->wireless_data; in ipw_pci_probe()
11641 net_dev->wireless_handlers = &ipw_wx_handler_def; in ipw_pci_probe()
11642 net_dev->ethtool_ops = &ipw_ethtool_ops; in ipw_pci_probe()
11644 net_dev->min_mtu = 68; in ipw_pci_probe()
11645 net_dev->max_mtu = LIBIPW_DATA_LEN; in ipw_pci_probe()
11647 err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group); in ipw_pci_probe()
11650 mutex_unlock(&priv->mutex); in ipw_pci_probe()
11655 mutex_unlock(&priv->mutex); in ipw_pci_probe()
11656 err = -EIO; in ipw_pci_probe()
11660 mutex_unlock(&priv->mutex); in ipw_pci_probe()
11680 unregister_netdev(priv->net_dev); in ipw_pci_probe()
11688 priv->ieee->geo.name, priv->ieee->geo.bg_channels, in ipw_pci_probe()
11689 priv->ieee->geo.a_channels); in ipw_pci_probe()
11694 wiphy_unregister(priv->ieee->wdev.wiphy); in ipw_pci_probe()
11695 kfree(priv->ieee->a_band.channels); in ipw_pci_probe()
11696 kfree(priv->ieee->bg_band.channels); in ipw_pci_probe()
11698 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); in ipw_pci_probe()
11700 free_irq(pdev->irq, priv); in ipw_pci_probe()
11702 iounmap(priv->hw_base); in ipw_pci_probe()
11708 free_libipw(priv->net_dev, 0); in ipw_pci_probe()
11722 mutex_lock(&priv->mutex); in ipw_pci_remove()
11724 priv->status |= STATUS_EXIT_PENDING; in ipw_pci_remove()
11726 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); in ipw_pci_remove()
11728 mutex_unlock(&priv->mutex); in ipw_pci_remove()
11730 unregister_netdev(priv->net_dev); in ipw_pci_remove()
11732 if (priv->rxq) { in ipw_pci_remove()
11733 ipw_rx_queue_free(priv, priv->rxq); in ipw_pci_remove()
11734 priv->rxq = NULL; in ipw_pci_remove()
11738 if (priv->cmdlog) { in ipw_pci_remove()
11739 kfree(priv->cmdlog); in ipw_pci_remove()
11740 priv->cmdlog = NULL; in ipw_pci_remove()
11744 cancel_delayed_work_sync(&priv->adhoc_check); in ipw_pci_remove()
11745 cancel_work_sync(&priv->associate); in ipw_pci_remove()
11746 cancel_work_sync(&priv->disassociate); in ipw_pci_remove()
11747 cancel_work_sync(&priv->system_config); in ipw_pci_remove()
11748 cancel_work_sync(&priv->rx_replenish); in ipw_pci_remove()
11749 cancel_work_sync(&priv->adapter_restart); in ipw_pci_remove()
11750 cancel_delayed_work_sync(&priv->rf_kill); in ipw_pci_remove()
11751 cancel_work_sync(&priv->up); in ipw_pci_remove()
11752 cancel_work_sync(&priv->down); in ipw_pci_remove()
11753 cancel_delayed_work_sync(&priv->request_scan); in ipw_pci_remove()
11754 cancel_delayed_work_sync(&priv->request_direct_scan); in ipw_pci_remove()
11755 cancel_delayed_work_sync(&priv->request_passive_scan); in ipw_pci_remove()
11756 cancel_delayed_work_sync(&priv->scan_event); in ipw_pci_remove()
11757 cancel_delayed_work_sync(&priv->gather_stats); in ipw_pci_remove()
11758 cancel_work_sync(&priv->abort_scan); in ipw_pci_remove()
11759 cancel_work_sync(&priv->roam); in ipw_pci_remove()
11760 cancel_delayed_work_sync(&priv->scan_check); in ipw_pci_remove()
11761 cancel_work_sync(&priv->link_up); in ipw_pci_remove()
11762 cancel_work_sync(&priv->link_down); in ipw_pci_remove()
11763 cancel_delayed_work_sync(&priv->led_link_on); in ipw_pci_remove()
11764 cancel_delayed_work_sync(&priv->led_link_off); in ipw_pci_remove()
11765 cancel_delayed_work_sync(&priv->led_act_off); in ipw_pci_remove()
11766 cancel_work_sync(&priv->merge_networks); in ipw_pci_remove()
11770 list_for_each_safe(p, q, &priv->ibss_mac_hash[i]) { in ipw_pci_remove()
11776 kfree(priv->error); in ipw_pci_remove()
11777 priv->error = NULL; in ipw_pci_remove()
11783 free_irq(pdev->irq, priv); in ipw_pci_remove()
11784 iounmap(priv->hw_base); in ipw_pci_remove()
11788 wiphy_unregister(priv->ieee->wdev.wiphy); in ipw_pci_remove()
11789 kfree(priv->ieee->a_band.channels); in ipw_pci_remove()
11790 kfree(priv->ieee->bg_band.channels); in ipw_pci_remove()
11791 free_libipw(priv->net_dev, 0); in ipw_pci_remove()
11798 struct net_device *dev = priv->net_dev; in ipw_pci_suspend()
11800 printk(KERN_INFO "%s: Going into suspend...\n", dev->name); in ipw_pci_suspend()
11808 priv->suspend_at = ktime_get_boottime_seconds(); in ipw_pci_suspend()
11817 struct net_device *dev = priv->net_dev; in ipw_pci_resume()
11820 printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name); in ipw_pci_resume()
11824 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries in ipw_pci_resume()
11836 priv->suspend_time = ktime_get_boottime_seconds() - priv->suspend_at; in ipw_pci_resume()
11839 schedule_work(&priv->up); in ipw_pci_resume()
11915 MODULE_PARM_DESC(rtap_iface, "create the rtap interface (1 - create, default 0)");
11957 …a 1=Main, 3=Aux, default 0 [both], 2=slow_diversity (choose the one with lower background noise)");