Lines Matching +full:tx +full:- +full:sec

1 // SPDX-License-Identifier: GPL-2.0-only
4 Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved.
9 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
12 Extensions 0.26 package and copyright (c) 1997-2003 Jean Tourrilhes
16 Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
18 Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
34 Tx - Commands and Data
54 The Tx flow cycle is as follows:
68 8) For each Tx interrupt received from the firmware, the READ index is checked
84 There are two locks utilized. The first is the low level lock (priv->low_lock)
87 - Access to the Tx/Rx queue lists via priv->low_lock. The lists are as follows:
89 tx_free_list : Holds pre-allocated Tx buffers.
93 tx_pend_list : Holds used Tx buffers waiting to go into the TBD ring
97 msg_free_list : Holds pre-allocated Msg (Command) buffers
105 The flow of data on the TX side is as follows:
110 The methods that work on the TBD ring are protected via priv->low_lock.
112 - The internal data state of the device itself
113 - Access to the firmware read/write indexes for the BD queues
116 All external entry functions are locked with the priv->action_lock to ensure
134 #include <linux/dma-mapping.h>
157 #define IPW2100_VERSION "git-1.2.2"
162 #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
305 /* Pre-decl until we get the code solid and then we can clean it up */
334 *val = ioread32(priv->ioaddr + reg); in read_register()
342 iowrite32(val, priv->ioaddr + reg); in write_register()
351 *val = ioread16(priv->ioaddr + reg); in read_register_word()
359 *val = ioread8(priv->ioaddr + reg); in read_register_byte()
367 iowrite16(val, priv->ioaddr + reg); in write_register_word()
375 iowrite8(val, priv->ioaddr + reg); in write_register_byte()
431 dif_len = addr - aligned_addr; in write_nic_memory()
441 len -= dif_len; in write_nic_memory()
452 dif_len = len - aligned_len; in write_nic_memory()
469 dif_len = addr - aligned_addr; in read_nic_memory()
479 len -= dif_len; in read_nic_memory()
490 dif_len = len - aligned_len; in read_nic_memory()
508 struct ipw2100_ordinals *ordinals = &priv->ordinals; in ipw2100_get_ordinal()
515 if (ordinals->table1_addr == 0) { in ipw2100_get_ordinal()
518 return -EINVAL; in ipw2100_get_ordinal()
529 return -EINVAL; in ipw2100_get_ordinal()
532 read_nic_dword(priv->net_dev, in ipw2100_get_ordinal()
533 ordinals->table1_addr + (ord << 2), &addr); in ipw2100_get_ordinal()
534 read_nic_dword(priv->net_dev, addr, val); in ipw2100_get_ordinal()
543 ord -= IPW_START_ORD_TAB_2; in ipw2100_get_ordinal()
546 read_nic_dword(priv->net_dev, in ipw2100_get_ordinal()
547 ordinals->table2_addr + (ord << 3), &addr); in ipw2100_get_ordinal()
550 * two 16-bit words - first is length, second is count */ in ipw2100_get_ordinal()
551 read_nic_dword(priv->net_dev, in ipw2100_get_ordinal()
552 ordinals->table2_addr + (ord << 3) + sizeof(u32), in ipw2100_get_ordinal()
565 return -EINVAL; in ipw2100_get_ordinal()
573 read_nic_memory(priv->net_dev, addr, total_length, val); in ipw2100_get_ordinal()
581 return -EINVAL; in ipw2100_get_ordinal()
587 struct ipw2100_ordinals *ordinals = &priv->ordinals; in ipw2100_set_ordinal()
594 return -EINVAL; in ipw2100_set_ordinal()
597 read_nic_dword(priv->net_dev, in ipw2100_set_ordinal()
598 ordinals->table1_addr + (ord << 2), &addr); in ipw2100_set_ordinal()
600 write_nic_dword(priv->net_dev, addr, *val); in ipw2100_set_ordinal()
609 return -EINVAL; in ipw2100_set_ordinal()
611 return -EINVAL; in ipw2100_set_ordinal()
623 out += scnprintf(buf + out, count - out, " "); in snprint_line()
625 out += scnprintf(buf + out, count - out, "%02X ", in snprint_line()
628 out += scnprintf(buf + out, count - out, " "); in snprint_line()
631 out += scnprintf(buf + out, count - out, " "); in snprint_line()
633 out += scnprintf(buf + out, count - out, " "); in snprint_line()
639 out += scnprintf(buf + out, count - out, "%c", c); in snprint_line()
643 out += scnprintf(buf + out, count - out, " "); in snprint_line()
661 len -= min(len, 16U); in printk_buf()
674 if (priv->reset_backoff && in schedule_reset()
675 (now - priv->last_reset > priv->reset_backoff)) in schedule_reset()
676 priv->reset_backoff = 0; in schedule_reset()
678 priv->last_reset = now; in schedule_reset()
680 if (!(priv->status & STATUS_RESET_PENDING)) { in schedule_reset()
682 priv->net_dev->name, priv->reset_backoff); in schedule_reset()
683 netif_carrier_off(priv->net_dev); in schedule_reset()
684 netif_stop_queue(priv->net_dev); in schedule_reset()
685 priv->status |= STATUS_RESET_PENDING; in schedule_reset()
686 if (priv->reset_backoff) in schedule_reset()
687 schedule_delayed_work(&priv->reset_work, in schedule_reset()
688 priv->reset_backoff * HZ); in schedule_reset()
690 schedule_delayed_work(&priv->reset_work, 0); in schedule_reset()
692 if (priv->reset_backoff < MAX_RESET_BACKOFF) in schedule_reset()
693 priv->reset_backoff++; in schedule_reset()
695 wake_up_interruptible(&priv->wait_command_queue); in schedule_reset()
698 priv->net_dev->name); in schedule_reset()
712 command_types[cmd->host_command], cmd->host_command, in ipw2100_hw_send_command()
713 cmd->host_command_length); in ipw2100_hw_send_command()
714 printk_buf(IPW_DL_HC, (u8 *) cmd->host_command_parameters, in ipw2100_hw_send_command()
715 cmd->host_command_length); in ipw2100_hw_send_command()
717 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_hw_send_command()
719 if (priv->fatal_error) { in ipw2100_hw_send_command()
722 err = -EIO; in ipw2100_hw_send_command()
726 if (!(priv->status & STATUS_RUNNING)) { in ipw2100_hw_send_command()
729 err = -EIO; in ipw2100_hw_send_command()
733 if (priv->status & STATUS_CMD_ACTIVE) { in ipw2100_hw_send_command()
736 err = -EBUSY; in ipw2100_hw_send_command()
740 if (list_empty(&priv->msg_free_list)) { in ipw2100_hw_send_command()
745 priv->status |= STATUS_CMD_ACTIVE; in ipw2100_hw_send_command()
746 priv->messages_sent++; in ipw2100_hw_send_command()
748 element = priv->msg_free_list.next; in ipw2100_hw_send_command()
751 packet->jiffy_start = jiffies; in ipw2100_hw_send_command()
754 packet->info.c_struct.cmd->host_command_reg = cmd->host_command; in ipw2100_hw_send_command()
755 packet->info.c_struct.cmd->host_command_reg1 = cmd->host_command1; in ipw2100_hw_send_command()
756 packet->info.c_struct.cmd->host_command_len_reg = in ipw2100_hw_send_command()
757 cmd->host_command_length; in ipw2100_hw_send_command()
758 packet->info.c_struct.cmd->sequence = cmd->host_command_sequence; in ipw2100_hw_send_command()
760 memcpy(packet->info.c_struct.cmd->host_command_params_reg, in ipw2100_hw_send_command()
761 cmd->host_command_parameters, in ipw2100_hw_send_command()
762 sizeof(packet->info.c_struct.cmd->host_command_params_reg)); in ipw2100_hw_send_command()
765 DEC_STAT(&priv->msg_free_stat); in ipw2100_hw_send_command()
767 list_add_tail(element, &priv->msg_pend_list); in ipw2100_hw_send_command()
768 INC_STAT(&priv->msg_pend_stat); in ipw2100_hw_send_command()
773 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_hw_send_command()
782 wait_event_interruptible_timeout(priv->wait_command_queue, in ipw2100_hw_send_command()
783 !(priv-> in ipw2100_hw_send_command()
790 priv->fatal_error = IPW2100_ERR_MSG_TIMEOUT; in ipw2100_hw_send_command()
791 priv->status &= ~STATUS_CMD_ACTIVE; in ipw2100_hw_send_command()
793 return -EIO; in ipw2100_hw_send_command()
796 if (priv->fatal_error) { in ipw2100_hw_send_command()
798 priv->net_dev->name); in ipw2100_hw_send_command()
799 return -EIO; in ipw2100_hw_send_command()
812 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_hw_send_command()
829 /* Domain 0 check - all values should be DOA_DEBUG */ in ipw2100_verify()
832 read_register(priv->net_dev, address, &data1); in ipw2100_verify()
834 return -EIO; in ipw2100_verify()
837 /* Domain 1 check - use arbitrary read/write compare */ in ipw2100_verify()
840 write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32, in ipw2100_verify()
842 write_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36, in ipw2100_verify()
844 read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x32, in ipw2100_verify()
846 read_register(priv->net_dev, IPW_REG_DOMAIN_1_OFFSET + 0x36, in ipw2100_verify()
852 return -EIO; in ipw2100_verify()
885 ((priv->status & STATUS_ENABLED) ? in ipw2100_wait_for_card_state()
888 priv->status |= STATUS_ENABLED; in ipw2100_wait_for_card_state()
890 priv->status &= ~STATUS_ENABLED; in ipw2100_wait_for_card_state()
900 return -EIO; in ipw2100_wait_for_card_state()
914 write_register(priv->net_dev, IPW_REG_RESET_REG, in sw_reset_and_clock()
922 read_register(priv->net_dev, IPW_REG_RESET_REG, &r); in sw_reset_and_clock()
928 return -EIO; // TODO: better error value in sw_reset_and_clock()
932 write_register(priv->net_dev, IPW_REG_GP_CNTRL, in sw_reset_and_clock()
940 read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r); in sw_reset_and_clock()
946 return -EIO; /* TODO: better error value */ in sw_reset_and_clock()
949 read_register(priv->net_dev, IPW_REG_GP_CNTRL, &r); in sw_reset_and_clock()
950 write_register(priv->net_dev, IPW_REG_GP_CNTRL, in sw_reset_and_clock()
964 5. zero-out shared mem
977 if (priv->fatal_error) { in ipw2100_download_firmware()
980 priv->net_dev->name, priv->fatal_error); in ipw2100_download_firmware()
981 return -EINVAL; in ipw2100_download_firmware()
988 priv->net_dev->name, err); in ipw2100_download_firmware()
989 priv->fatal_error = IPW2100_ERR_FW_LOAD; in ipw2100_download_firmware()
997 priv->net_dev->name, err); in ipw2100_download_firmware()
998 priv->fatal_error = IPW2100_ERR_FW_LOAD; in ipw2100_download_firmware()
1002 priv->firmware_version = ipw2100_firmware.version; in ipw2100_download_firmware()
1008 priv->net_dev->name, err); in ipw2100_download_firmware()
1015 priv->net_dev->name, err); in ipw2100_download_firmware()
1020 write_nic_dword(priv->net_dev, in ipw2100_download_firmware()
1024 write_register(priv->net_dev, IPW_REG_RESET_REG, 0); in ipw2100_download_firmware()
1030 priv->net_dev->name, err); in ipw2100_download_firmware()
1035 write_nic_dword(priv->net_dev, in ipw2100_download_firmware()
1043 priv->net_dev->name, err); in ipw2100_download_firmware()
1051 priv->net_dev->name, err); in ipw2100_download_firmware()
1059 * from the disk. --YZ in ipw2100_download_firmware()
1069 write_nic_dword(priv->net_dev, address, 0); in ipw2100_download_firmware()
1072 write_nic_dword(priv->net_dev, address, 0); in ipw2100_download_firmware()
1075 write_nic_dword(priv->net_dev, address, 0); in ipw2100_download_firmware()
1078 write_nic_dword(priv->net_dev, address, 0); in ipw2100_download_firmware()
1081 write_nic_dword(priv->net_dev, address, 0); in ipw2100_download_firmware()
1092 if (priv->status & STATUS_INT_ENABLED) in ipw2100_enable_interrupts()
1094 priv->status |= STATUS_INT_ENABLED; in ipw2100_enable_interrupts()
1095 write_register(priv->net_dev, IPW_REG_INTA_MASK, IPW_INTERRUPT_MASK); in ipw2100_enable_interrupts()
1100 if (!(priv->status & STATUS_INT_ENABLED)) in ipw2100_disable_interrupts()
1102 priv->status &= ~STATUS_INT_ENABLED; in ipw2100_disable_interrupts()
1103 write_register(priv->net_dev, IPW_REG_INTA_MASK, 0x0); in ipw2100_disable_interrupts()
1108 struct ipw2100_ordinals *ord = &priv->ordinals; in ipw2100_initialize_ordinals()
1112 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_ORDINALS_TABLE_1, in ipw2100_initialize_ordinals()
1113 &ord->table1_addr); in ipw2100_initialize_ordinals()
1115 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_ORDINALS_TABLE_2, in ipw2100_initialize_ordinals()
1116 &ord->table2_addr); in ipw2100_initialize_ordinals()
1118 read_nic_dword(priv->net_dev, ord->table1_addr, &ord->table1_size); in ipw2100_initialize_ordinals()
1119 read_nic_dword(priv->net_dev, ord->table2_addr, &ord->table2_size); in ipw2100_initialize_ordinals()
1121 ord->table2_size &= 0x0000FFFF; in ipw2100_initialize_ordinals()
1123 IPW_DEBUG_INFO("table 1 size: %d\n", ord->table1_size); in ipw2100_initialize_ordinals()
1124 IPW_DEBUG_INFO("table 2 size: %d\n", ord->table2_size); in ipw2100_initialize_ordinals()
1137 write_register(priv->net_dev, IPW_REG_GPIO, reg); in ipw2100_hw_set_gpio()
1149 if (!(priv->hw_features & HW_FEATURE_RFKILL)) { in rf_kill_active()
1150 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, false); in rf_kill_active()
1151 priv->status &= ~STATUS_RF_KILL_HW; in rf_kill_active()
1157 read_register(priv->net_dev, IPW_REG_GPIO, &reg); in rf_kill_active()
1162 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, true); in rf_kill_active()
1163 priv->status |= STATUS_RF_KILL_HW; in rf_kill_active()
1165 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, false); in rf_kill_active()
1166 priv->status &= ~STATUS_RF_KILL_HW; in rf_kill_active()
1185 return -EIO; in ipw2100_get_hw_features()
1193 read_nic_dword(priv->net_dev, addr + 0xFC, &val); in ipw2100_get_hw_features()
1194 priv->eeprom_version = (val >> 24) & 0xFF; in ipw2100_get_hw_features()
1195 IPW_DEBUG_INFO("EEPROM version: %d\n", priv->eeprom_version); in ipw2100_get_hw_features()
1204 read_nic_dword(priv->net_dev, addr + 0x20, &val); in ipw2100_get_hw_features()
1206 priv->hw_features |= HW_FEATURE_RFKILL; in ipw2100_get_hw_features()
1209 (priv->hw_features & HW_FEATURE_RFKILL) ? "" : "not "); in ipw2100_get_hw_features()
1227 if (priv->status & STATUS_RUNNING) in ipw2100_start_adapter()
1231 * Initialize the hw - drive adapter to DO state by setting in ipw2100_start_adapter()
1238 priv->net_dev->name); in ipw2100_start_adapter()
1239 return -EIO; in ipw2100_start_adapter()
1242 /* Clear the Tx, Rx and Msg queues and the r/w indexes in ipw2100_start_adapter()
1248 /* TODO -- Look at disabling interrupts here to make sure none in ipw2100_start_adapter()
1251 /* Release ARC - clear reset bit */ in ipw2100_start_adapter()
1252 write_register(priv->net_dev, IPW_REG_RESET_REG, 0); in ipw2100_start_adapter()
1261 read_register(priv->net_dev, IPW_REG_INTA, &inta); in ipw2100_start_adapter()
1266 write_register(priv->net_dev, IPW_REG_INTA, in ipw2100_start_adapter()
1277 write_register(priv->net_dev, IPW_REG_INTA, in ipw2100_start_adapter()
1281 } while (--i); in ipw2100_start_adapter()
1285 read_register(priv->net_dev, IPW_REG_INTA, &inta); in ipw2100_start_adapter()
1286 read_register(priv->net_dev, IPW_REG_INTA_MASK, &inta_mask); in ipw2100_start_adapter()
1290 write_register(priv->net_dev, IPW_REG_INTA, inta); in ipw2100_start_adapter()
1298 priv->net_dev->name); in ipw2100_start_adapter()
1299 return -EIO; in ipw2100_start_adapter()
1303 read_register(priv->net_dev, IPW_REG_GPIO, &gpio); in ipw2100_start_adapter()
1307 write_register(priv->net_dev, IPW_REG_GPIO, gpio); in ipw2100_start_adapter()
1310 priv->status |= STATUS_RUNNING; in ipw2100_start_adapter()
1313 priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED); in ipw2100_start_adapter()
1322 if (!priv->fatal_error) in ipw2100_reset_fatalerror()
1325 priv->fatal_errors[priv->fatal_index++] = priv->fatal_error; in ipw2100_reset_fatalerror()
1326 priv->fatal_index %= IPW2100_ERROR_QUEUE; in ipw2100_reset_fatalerror()
1327 priv->fatal_error = 0; in ipw2100_reset_fatalerror()
1341 write_register(priv->net_dev, IPW_REG_RESET_REG, in ipw2100_power_cycle_adapter()
1349 read_register(priv->net_dev, IPW_REG_RESET_REG, &reg); in ipw2100_power_cycle_adapter()
1353 } while (--i); in ipw2100_power_cycle_adapter()
1355 priv->status &= ~STATUS_RESET_PENDING; in ipw2100_power_cycle_adapter()
1359 ("exit - waited too long for master assert stop\n"); in ipw2100_power_cycle_adapter()
1360 return -EIO; in ipw2100_power_cycle_adapter()
1363 write_register(priv->net_dev, IPW_REG_RESET_REG, in ipw2100_power_cycle_adapter()
1370 priv->status &= ~(STATUS_RUNNING | STATUS_ASSOCIATING | in ipw2100_power_cycle_adapter()
1405 read_nic_dword(priv->net_dev, IPW2100_CONTROL_REG, &val1); in ipw2100_hw_phy_off()
1406 read_nic_dword(priv->net_dev, IPW2100_COMMAND, &val2); in ipw2100_hw_phy_off()
1415 return -EIO; in ipw2100_hw_phy_off()
1429 if (priv->status & STATUS_ENABLED) in ipw2100_enable_adapter()
1432 mutex_lock(&priv->adapter_mutex); in ipw2100_enable_adapter()
1448 priv->net_dev->name); in ipw2100_enable_adapter()
1452 if (priv->stop_hang_check) { in ipw2100_enable_adapter()
1453 priv->stop_hang_check = 0; in ipw2100_enable_adapter()
1454 schedule_delayed_work(&priv->hang_check, HZ / 2); in ipw2100_enable_adapter()
1458 mutex_unlock(&priv->adapter_mutex); in ipw2100_enable_adapter()
1474 if (!(priv->status & STATUS_RUNNING)) in ipw2100_hw_stop_adapter()
1477 priv->status |= STATUS_STOPPING; in ipw2100_hw_stop_adapter()
1482 if (!priv->fatal_error) { in ipw2100_hw_stop_adapter()
1493 * If in D0-standby mode going directly to D3 may cause a in ipw2100_hw_stop_adapter()
1499 * out of D0-standby if it is already in that state. in ipw2100_hw_stop_adapter()
1506 * take HW out of D0-standby and prepare it for D3 state. in ipw2100_hw_stop_adapter()
1518 priv->net_dev->name, err); in ipw2100_hw_stop_adapter()
1523 priv->status &= ~STATUS_ENABLED; in ipw2100_hw_stop_adapter()
1539 write_register(priv->net_dev, IPW_REG_RESET_REG, in ipw2100_hw_stop_adapter()
1544 for (i = 5; i > 0; i--) { in ipw2100_hw_stop_adapter()
1548 read_register(priv->net_dev, IPW_REG_RESET_REG, &reg); in ipw2100_hw_stop_adapter()
1557 priv->net_dev->name); in ipw2100_hw_stop_adapter()
1560 write_register(priv->net_dev, IPW_REG_RESET_REG, in ipw2100_hw_stop_adapter()
1563 priv->status &= ~(STATUS_RUNNING | STATUS_STOPPING); in ipw2100_hw_stop_adapter()
1579 if (!(priv->status & STATUS_ENABLED)) in ipw2100_disable_adapter()
1583 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); in ipw2100_disable_adapter()
1585 if (!priv->stop_hang_check) { in ipw2100_disable_adapter()
1586 priv->stop_hang_check = 1; in ipw2100_disable_adapter()
1587 cancel_delayed_work(&priv->hang_check); in ipw2100_disable_adapter()
1590 mutex_lock(&priv->adapter_mutex); in ipw2100_disable_adapter()
1595 ": exit - failed to send CARD_DISABLE command\n"); in ipw2100_disable_adapter()
1602 ": exit - card failed to change to DISABLED\n"); in ipw2100_disable_adapter()
1609 mutex_unlock(&priv->adapter_mutex); in ipw2100_disable_adapter()
1628 if (!(priv->config & CFG_ASSOCIATE)) in ipw2100_set_scan_options()
1630 if ((priv->ieee->sec.flags & SEC_ENABLED) && priv->ieee->sec.enabled) in ipw2100_set_scan_options()
1632 if (priv->config & CFG_PASSIVE_SCAN) in ipw2100_set_scan_options()
1635 cmd.host_command_parameters[1] = priv->channel_mask; in ipw2100_set_scan_options()
1659 if (priv->ieee->iw_mode == IW_MODE_MONITOR) in ipw2100_start_scan()
1662 if (priv->status & STATUS_SCANNING) { in ipw2100_start_scan()
1676 priv->status |= STATUS_SCANNING; in ipw2100_start_scan()
1679 priv->status &= ~STATUS_SCANNING; in ipw2100_start_scan()
1688 "---",
1706 if (priv->suspend_time) { in ipw2100_up()
1707 libipw_networks_age(priv->ieee, priv->suspend_time); in ipw2100_up()
1708 priv->suspend_time = 0; in ipw2100_up()
1712 if (priv->status & STATUS_RF_KILL_SW) { in ipw2100_up()
1714 "switch\n", priv->net_dev->name); in ipw2100_up()
1724 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_up()
1729 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_up()
1731 if (priv->status & STATUS_POWERED || in ipw2100_up()
1732 (priv->status & STATUS_RESET_PENDING)) { in ipw2100_up()
1738 priv->net_dev->name); in ipw2100_up()
1742 priv->status |= STATUS_POWERED; in ipw2100_up()
1749 priv->net_dev->name); in ipw2100_up()
1760 priv->net_dev->name); in ipw2100_up()
1765 libipw_set_geo(priv->ieee, &ipw_geos[0]); in ipw2100_up()
1766 priv->ieee->freq_band = LIBIPW_24GHZ_BAND; in ipw2100_up()
1773 priv->net_dev->name); in ipw2100_up()
1777 priv->status &= ~STATUS_SCANNING; in ipw2100_up()
1781 priv->net_dev->name); in ipw2100_up()
1783 if (priv->stop_rf_kill) { in ipw2100_up()
1784 priv->stop_rf_kill = 0; in ipw2100_up()
1785 schedule_delayed_work(&priv->rf_kill, in ipw2100_up()
1800 priv->net_dev->name); in ipw2100_up()
1805 /* Enable the adapter - sends HOST_COMPLETE */ in ipw2100_up()
1810 priv->net_dev->name); in ipw2100_up()
1831 int associated = priv->status & STATUS_ASSOCIATED; in ipw2100_down()
1834 if (!priv->stop_rf_kill) { in ipw2100_down()
1835 priv->stop_rf_kill = 1; in ipw2100_down()
1836 cancel_delayed_work(&priv->rf_kill); in ipw2100_down()
1840 if (!priv->stop_hang_check) { in ipw2100_down()
1841 priv->stop_hang_check = 1; in ipw2100_down()
1842 cancel_delayed_work(&priv->hang_check); in ipw2100_down()
1846 if (priv->status & STATUS_RESET_PENDING) in ipw2100_down()
1847 cancel_delayed_work(&priv->reset_work); in ipw2100_down()
1851 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_down()
1853 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_down()
1857 priv->net_dev->name); in ipw2100_down()
1862 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_down()
1864 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_down()
1871 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); in ipw2100_down()
1873 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); in ipw2100_down()
1874 netif_carrier_off(priv->net_dev); in ipw2100_down()
1875 netif_stop_queue(priv->net_dev); in ipw2100_down()
1881 const struct libipw_geo *geo = libipw_get_geo(priv->ieee); in ipw2100_wdev_init()
1882 struct wireless_dev *wdev = &priv->ieee->wdev; in ipw2100_wdev_init()
1885 memcpy(wdev->wiphy->perm_addr, priv->mac_addr, ETH_ALEN); in ipw2100_wdev_init()
1887 /* fill-out priv->ieee->bg_band */ in ipw2100_wdev_init()
1888 if (geo->bg_channels) { in ipw2100_wdev_init()
1889 struct ieee80211_supported_band *bg_band = &priv->ieee->bg_band; in ipw2100_wdev_init()
1891 bg_band->band = NL80211_BAND_2GHZ; in ipw2100_wdev_init()
1892 bg_band->n_channels = geo->bg_channels; in ipw2100_wdev_init()
1893 bg_band->channels = kcalloc(geo->bg_channels, in ipw2100_wdev_init()
1896 if (!bg_band->channels) { in ipw2100_wdev_init()
1898 return -ENOMEM; in ipw2100_wdev_init()
1900 /* translate geo->bg to bg_band.channels */ in ipw2100_wdev_init()
1901 for (i = 0; i < geo->bg_channels; i++) { in ipw2100_wdev_init()
1902 bg_band->channels[i].band = NL80211_BAND_2GHZ; in ipw2100_wdev_init()
1903 bg_band->channels[i].center_freq = geo->bg[i].freq; in ipw2100_wdev_init()
1904 bg_band->channels[i].hw_value = geo->bg[i].channel; in ipw2100_wdev_init()
1905 bg_band->channels[i].max_power = geo->bg[i].max_power; in ipw2100_wdev_init()
1906 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY) in ipw2100_wdev_init()
1907 bg_band->channels[i].flags |= in ipw2100_wdev_init()
1909 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS) in ipw2100_wdev_init()
1910 bg_band->channels[i].flags |= in ipw2100_wdev_init()
1912 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT) in ipw2100_wdev_init()
1913 bg_band->channels[i].flags |= in ipw2100_wdev_init()
1920 bg_band->bitrates = ipw2100_bg_rates; in ipw2100_wdev_init()
1921 bg_band->n_bitrates = RATE_COUNT; in ipw2100_wdev_init()
1923 wdev->wiphy->bands[NL80211_BAND_2GHZ] = bg_band; in ipw2100_wdev_init()
1926 wdev->wiphy->cipher_suites = ipw_cipher_suites; in ipw2100_wdev_init()
1927 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(ipw_cipher_suites); in ipw2100_wdev_init()
1929 set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev); in ipw2100_wdev_init()
1930 if (wiphy_register(wdev->wiphy)) in ipw2100_wdev_init()
1931 return -EIO; in ipw2100_wdev_init()
1944 int associated = priv->status & STATUS_ASSOCIATED; in ipw2100_reset_adapter()
1946 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_reset_adapter()
1947 IPW_DEBUG_INFO(": %s: Restarting adapter.\n", priv->net_dev->name); in ipw2100_reset_adapter()
1948 priv->resets++; in ipw2100_reset_adapter()
1949 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); in ipw2100_reset_adapter()
1950 priv->status |= STATUS_SECURITY_UPDATED; in ipw2100_reset_adapter()
1954 cancel_delayed_work(&priv->reset_work); in ipw2100_reset_adapter()
1955 priv->status |= STATUS_RESET_PENDING; in ipw2100_reset_adapter()
1956 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_reset_adapter()
1958 mutex_lock(&priv->action_mutex); in ipw2100_reset_adapter()
1960 priv->stop_hang_check = 1; in ipw2100_reset_adapter()
1961 cancel_delayed_work(&priv->hang_check); in ipw2100_reset_adapter()
1965 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); in ipw2100_reset_adapter()
1968 mutex_unlock(&priv->action_mutex); in ipw2100_reset_adapter()
2023 memcpy(priv->ieee->bssid, bssid, ETH_ALEN); in isr_indicate_associated()
2045 priv->net_dev->name, essid_len, essid, in isr_indicate_associated()
2049 if (!(priv->config & CFG_STATIC_ESSID)) { in isr_indicate_associated()
2050 priv->essid_len = min((u8) essid_len, (u8) IW_ESSID_MAX_SIZE); in isr_indicate_associated()
2051 memcpy(priv->essid, essid, priv->essid_len); in isr_indicate_associated()
2053 priv->channel = chan; in isr_indicate_associated()
2054 memcpy(priv->bssid, bssid, ETH_ALEN); in isr_indicate_associated()
2056 priv->status |= STATUS_ASSOCIATING; in isr_indicate_associated()
2057 priv->connect_start = ktime_get_boottime_seconds(); in isr_indicate_associated()
2059 schedule_delayed_work(&priv->wx_event_work, HZ / 10); in isr_indicate_associated()
2085 * disable auto association -- so we cheat by setting a bogus SSID */ in ipw2100_set_essid()
2086 if (!ssid_len && !(priv->config & CFG_ASSOCIATE)) { in ipw2100_set_essid()
2099 memset(priv->essid + ssid_len, 0, IW_ESSID_MAX_SIZE - ssid_len); in ipw2100_set_essid()
2100 memcpy(priv->essid, essid, ssid_len); in ipw2100_set_essid()
2101 priv->essid_len = ssid_len; in ipw2100_set_essid()
2106 err = -EIO; in ipw2100_set_essid()
2115 "disassociated: '%*pE' %pM\n", priv->essid_len, priv->essid, in isr_indicate_association_lost()
2116 priv->bssid); in isr_indicate_association_lost()
2118 priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); in isr_indicate_association_lost()
2120 if (priv->status & STATUS_STOPPING) { in isr_indicate_association_lost()
2125 eth_zero_addr(priv->bssid); in isr_indicate_association_lost()
2126 eth_zero_addr(priv->ieee->bssid); in isr_indicate_association_lost()
2128 netif_carrier_off(priv->net_dev); in isr_indicate_association_lost()
2129 netif_stop_queue(priv->net_dev); in isr_indicate_association_lost()
2131 if (!(priv->status & STATUS_RUNNING)) in isr_indicate_association_lost()
2134 if (priv->status & STATUS_SECURITY_UPDATED) in isr_indicate_association_lost()
2135 schedule_delayed_work(&priv->security_work, 0); in isr_indicate_association_lost()
2137 schedule_delayed_work(&priv->wx_event_work, 0); in isr_indicate_association_lost()
2143 priv->net_dev->name); in isr_indicate_rf_kill()
2146 wiphy_rfkill_set_hw_state(priv->ieee->wdev.wiphy, true); in isr_indicate_rf_kill()
2147 priv->status |= STATUS_RF_KILL_HW; in isr_indicate_rf_kill()
2150 priv->stop_rf_kill = 0; in isr_indicate_rf_kill()
2151 mod_delayed_work(system_wq, &priv->rf_kill, round_jiffies_relative(HZ)); in isr_indicate_rf_kill()
2162 wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); in ipw2100_scan_event()
2169 priv->ieee->scans++; in isr_scan_complete()
2170 priv->status &= ~STATUS_SCANNING; in isr_scan_complete()
2172 /* Only userspace-requested scan completion events go out immediately */ in isr_scan_complete()
2173 if (!priv->user_requested_scan) { in isr_scan_complete()
2174 schedule_delayed_work(&priv->scan_event, in isr_scan_complete()
2177 priv->user_requested_scan = 0; in isr_scan_complete()
2178 mod_delayed_work(system_wq, &priv->scan_event, 0); in isr_scan_complete()
2200 priv->status |= STATUS_SCANNING; in isr_indicate_scanning()
2216 IPW2100_HANDLER(-1, NULL)
2224 priv->status & STATUS_ASSOCIATED && in isr_status_change()
2225 !(priv->status & STATUS_SCANNING)) { in isr_status_change()
2233 for (i = 0; status_handlers[i].status != -1; i++) { in isr_status_change()
2239 priv->wstats.status = status; in isr_status_change()
2251 if (cmd->host_command_reg < ARRAY_SIZE(command_types)) { in isr_rx_complete_command()
2253 command_types[cmd->host_command_reg], in isr_rx_complete_command()
2254 cmd->host_command_reg); in isr_rx_complete_command()
2257 if (cmd->host_command_reg == HOST_COMPLETE) in isr_rx_complete_command()
2258 priv->status |= STATUS_ENABLED; in isr_rx_complete_command()
2260 if (cmd->host_command_reg == CARD_DISABLE) in isr_rx_complete_command()
2261 priv->status &= ~STATUS_ENABLED; in isr_rx_complete_command()
2263 priv->status &= ~STATUS_CMD_ACTIVE; in isr_rx_complete_command()
2265 wake_up_interruptible(&priv->wait_command_queue); in isr_rx_complete_command()
2281 packet->skb = dev_alloc_skb(sizeof(struct ipw2100_rx)); in ipw2100_alloc_skb()
2282 if (!packet->skb) in ipw2100_alloc_skb()
2283 return -ENOMEM; in ipw2100_alloc_skb()
2285 packet->rxp = (struct ipw2100_rx *)packet->skb->data; in ipw2100_alloc_skb()
2286 packet->dma_addr = dma_map_single(&priv->pci_dev->dev, in ipw2100_alloc_skb()
2287 packet->skb->data, in ipw2100_alloc_skb()
2290 if (dma_mapping_error(&priv->pci_dev->dev, packet->dma_addr)) { in ipw2100_alloc_skb()
2291 dev_kfree_skb(packet->skb); in ipw2100_alloc_skb()
2292 return -ENOMEM; in ipw2100_alloc_skb()
2304 #define SNAPSHOT_ADDR(ofs) (priv->snapshot[((ofs) >> 12) & 0xff] + ((ofs) & 0xfff))
2308 if (!priv->snapshot[0]) in ipw2100_snapshot_free()
2311 kfree(priv->snapshot[i]); in ipw2100_snapshot_free()
2312 priv->snapshot[0] = NULL; in ipw2100_snapshot_free()
2319 if (priv->snapshot[0]) in ipw2100_snapshot_alloc()
2322 priv->snapshot[i] = kmalloc(0x1000, GFP_ATOMIC); in ipw2100_snapshot_alloc()
2323 if (!priv->snapshot[i]) { in ipw2100_snapshot_alloc()
2325 "buffer %d\n", priv->net_dev->name, i); in ipw2100_snapshot_alloc()
2327 kfree(priv->snapshot[--i]); in ipw2100_snapshot_alloc()
2328 priv->snapshot[0] = NULL; in ipw2100_snapshot_alloc()
2351 read_nic_dword(priv->net_dev, i, &tmp); in ipw2100_match_buf()
2365 if ((s - in_buf) == len) in ipw2100_match_buf()
2366 ret = (i + j) - len + 1; in ipw2100_match_buf()
2397 struct ipw2100_status *status = &priv->status_queue.drv[i]; in ipw2100_corruption_detected()
2407 write_register(priv->net_dev, IPW_REG_RESET_REG, in ipw2100_corruption_detected()
2412 read_register(priv->net_dev, IPW_REG_RESET_REG, &reg); in ipw2100_corruption_detected()
2416 } while (j--); in ipw2100_corruption_detected()
2424 priv->net_dev->name, match, in ipw2100_corruption_detected()
2428 "Firmware.\n", priv->net_dev->name); in ipw2100_corruption_detected()
2430 printk_buf((u8 *) priv->status_queue.drv, in ipw2100_corruption_detected()
2434 priv->fatal_error = IPW2100_ERR_C3_CORRUPTION; in ipw2100_corruption_detected()
2435 priv->net_dev->stats.rx_errors++; in ipw2100_corruption_detected()
2442 struct net_device *dev = priv->net_dev; in isr_rx()
2443 struct ipw2100_status *status = &priv->status_queue.drv[i]; in isr_rx()
2444 struct ipw2100_rx_packet *packet = &priv->rx_buffers[i]; in isr_rx()
2448 if (unlikely(status->frame_size > skb_tailroom(packet->skb))) { in isr_rx()
2451 dev->name, in isr_rx()
2452 status->frame_size, skb_tailroom(packet->skb)); in isr_rx()
2453 dev->stats.rx_errors++; in isr_rx()
2458 dev->stats.rx_errors++; in isr_rx()
2459 priv->wstats.discard.misc++; in isr_rx()
2464 if (unlikely(priv->ieee->iw_mode != IW_MODE_MONITOR && in isr_rx()
2465 !(priv->status & STATUS_ASSOCIATED))) { in isr_rx()
2467 priv->wstats.discard.misc++; in isr_rx()
2471 dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr, in isr_rx()
2474 skb_put(packet->skb, status->frame_size); in isr_rx()
2479 skb_copy_from_linear_data(packet->skb, packet_data, in isr_rx()
2480 min_t(u32, status->frame_size, in isr_rx()
2484 if (!libipw_rx(priv->ieee, packet->skb, stats)) { in isr_rx()
2487 dev->name); in isr_rx()
2488 printk_buf(IPW_DL_DROP, packet_data, status->frame_size); in isr_rx()
2490 dev->stats.rx_errors++; in isr_rx()
2493 dev_kfree_skb_any(packet->skb); in isr_rx()
2494 packet->skb = NULL; in isr_rx()
2500 "%s: Unable to allocate SKB onto RBD ring - disabling " in isr_rx()
2501 "adapter.\n", dev->name); in isr_rx()
2507 priv->rx_queue.drv[i].host_addr = packet->dma_addr; in isr_rx()
2515 struct net_device *dev = priv->net_dev; in isr_rx_monitor()
2516 struct ipw2100_status *status = &priv->status_queue.drv[i]; in isr_rx_monitor()
2517 struct ipw2100_rx_packet *packet = &priv->rx_buffers[i]; in isr_rx_monitor()
2519 /* Magic struct that slots into the radiotap header -- no reason in isr_rx_monitor()
2529 if (unlikely(status->frame_size > skb_tailroom(packet->skb) - in isr_rx_monitor()
2533 dev->name, in isr_rx_monitor()
2534 status->frame_size, in isr_rx_monitor()
2535 skb_tailroom(packet->skb)); in isr_rx_monitor()
2536 dev->stats.rx_errors++; in isr_rx_monitor()
2541 dev->stats.rx_errors++; in isr_rx_monitor()
2542 priv->wstats.discard.misc++; in isr_rx_monitor()
2547 if (unlikely(priv->config & CFG_CRC_CHECK && in isr_rx_monitor()
2548 status->flags & IPW_STATUS_FLAG_CRC_ERROR)) { in isr_rx_monitor()
2550 dev->stats.rx_errors++; in isr_rx_monitor()
2554 dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr, in isr_rx_monitor()
2556 memmove(packet->skb->data + sizeof(struct ipw_rt_hdr), in isr_rx_monitor()
2557 packet->skb->data, status->frame_size); in isr_rx_monitor()
2559 ipw_rt = (struct ipw_rt_hdr *) packet->skb->data; in isr_rx_monitor()
2561 ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; in isr_rx_monitor()
2562 ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */ in isr_rx_monitor()
2563 ipw_rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct ipw_rt_hdr)); /* total hdr+data */ in isr_rx_monitor()
2565 ipw_rt->rt_hdr.it_present = cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL); in isr_rx_monitor()
2567 ipw_rt->rt_dbmsignal = status->rssi + IPW2100_RSSI_TO_DBM; in isr_rx_monitor()
2569 skb_put(packet->skb, status->frame_size + sizeof(struct ipw_rt_hdr)); in isr_rx_monitor()
2571 if (!libipw_rx(priv->ieee, packet->skb, stats)) { in isr_rx_monitor()
2572 dev->stats.rx_errors++; in isr_rx_monitor()
2575 dev_kfree_skb_any(packet->skb); in isr_rx_monitor()
2576 packet->skb = NULL; in isr_rx_monitor()
2582 "%s: Unable to allocate SKB onto RBD ring - disabling " in isr_rx_monitor()
2583 "adapter.\n", dev->name); in isr_rx_monitor()
2589 priv->rx_queue.drv[i].host_addr = packet->dma_addr; in isr_rx_monitor()
2596 struct ipw2100_status *status = &priv->status_queue.drv[i]; in ipw2100_corruption_check()
2597 struct ipw2100_rx *u = priv->rx_buffers[i].rxp; in ipw2100_corruption_check()
2598 u16 frame_type = status->status_fields & STATUS_TYPE_MASK; in ipw2100_corruption_check()
2602 return (status->frame_size != sizeof(u->rx_data.command)); in ipw2100_corruption_check()
2604 return (status->frame_size != sizeof(u->rx_data.status)); in ipw2100_corruption_check()
2606 return (status->frame_size < sizeof(u->rx_data.notification)); in ipw2100_corruption_check()
2612 switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { in ipw2100_corruption_check()
2617 return (status->frame_size > in ipw2100_corruption_check()
2633 * Read index - firmware places packet in entry identified by the
2636 * be filled--but not yet valid.
2638 * Write index - driver fills this entry with an unused RBD entry.
2647 * The WRITE index is cached in the variable 'priv->rx_queue.next'.
2652 struct ipw2100_bd_queue *rxq = &priv->rx_queue; in __ipw2100_rx_process()
2653 struct ipw2100_status_queue *sq = &priv->status_queue; in __ipw2100_rx_process()
2662 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_READ_INDEX, &r); in __ipw2100_rx_process()
2663 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, &w); in __ipw2100_rx_process()
2665 if (r >= rxq->entries) { in __ipw2100_rx_process()
2666 IPW_DEBUG_RX("exit - bad read index\n"); in __ipw2100_rx_process()
2670 i = (rxq->next + 1) % rxq->entries; in __ipw2100_rx_process()
2674 r, rxq->next, i); */ in __ipw2100_rx_process()
2676 packet = &priv->rx_buffers[i]; in __ipw2100_rx_process()
2680 dma_sync_single_for_cpu(&priv->pci_dev->dev, packet->dma_addr, in __ipw2100_rx_process()
2689 u = packet->rxp; in __ipw2100_rx_process()
2690 frame_type = sq->drv[i].status_fields & STATUS_TYPE_MASK; in __ipw2100_rx_process()
2691 stats.rssi = sq->drv[i].rssi + IPW2100_RSSI_TO_DBM; in __ipw2100_rx_process()
2692 stats.len = sq->drv[i].frame_size; in __ipw2100_rx_process()
2700 priv->net_dev->name, frame_types[frame_type], in __ipw2100_rx_process()
2706 isr_rx_complete_command(priv, &u->rx_data.command); in __ipw2100_rx_process()
2710 isr_status_change(priv, u->rx_data.status); in __ipw2100_rx_process()
2716 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in __ipw2100_rx_process()
2723 switch (WLAN_FC_GET_TYPE(le16_to_cpu(u->rx_data.header.frame_ctl))) { in __ipw2100_rx_process()
2725 libipw_rx_mgt(priv->ieee, in __ipw2100_rx_process()
2726 &u->rx_data.header, &stats); in __ipw2100_rx_process()
2742 rxq->drv[i].status.info.field = 0; in __ipw2100_rx_process()
2744 i = (i + 1) % rxq->entries; in __ipw2100_rx_process()
2749 rxq->next = (i ? i : rxq->entries) - 1; in __ipw2100_rx_process()
2751 write_register(priv->net_dev, in __ipw2100_rx_process()
2752 IPW_MEM_HOST_SHARED_RX_WRITE_INDEX, rxq->next); in __ipw2100_rx_process()
2768 * TX Queue works as follows:
2770 * Read index - points to the next TBD that the firmware will
2774 * Write index - driver fills this entry with an constructed TBD
2787 * The OLDEST index is cached in the variable 'priv->tx_queue.oldest'
2797 struct ipw2100_bd_queue *txq = &priv->tx_queue; in __ipw2100_tx_process()
2805 if (list_empty(&priv->fw_pend_list)) in __ipw2100_tx_process()
2808 element = priv->fw_pend_list.next; in __ipw2100_tx_process()
2811 tbd = &txq->drv[packet->index]; in __ipw2100_tx_process()
2814 switch (packet->type) { in __ipw2100_tx_process()
2818 e = txq->oldest; in __ipw2100_tx_process()
2823 descriptors_used = tbd->num_fragments; in __ipw2100_tx_process()
2824 frag_num = tbd->num_fragments - 1; in __ipw2100_tx_process()
2825 e = txq->oldest + frag_num; in __ipw2100_tx_process()
2826 e %= txq->entries; in __ipw2100_tx_process()
2831 priv->net_dev->name); in __ipw2100_tx_process()
2839 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_READ_INDEX, in __ipw2100_tx_process()
2841 read_register(priv->net_dev, IPW_MEM_HOST_SHARED_TX_QUEUE_WRITE_INDEX, in __ipw2100_tx_process()
2843 if (w != txq->next) in __ipw2100_tx_process()
2845 priv->net_dev->name); in __ipw2100_tx_process()
2848 * txq->next is the index of the last packet written txq->oldest is in __ipw2100_tx_process()
2857 * ===>| s---->|=============== in __ipw2100_tx_process()
2860 * r---->| in __ipw2100_tx_process()
2863 * w - updated by driver in __ipw2100_tx_process()
2864 * r - updated by firmware in __ipw2100_tx_process()
2865 * s - start of oldest BD entry (txq->oldest) in __ipw2100_tx_process()
2866 * e - end of oldest BD entry in __ipw2100_tx_process()
2870 IPW_DEBUG_TX("exit - no processed packets ready to release.\n"); in __ipw2100_tx_process()
2875 DEC_STAT(&priv->fw_pend_stat); in __ipw2100_tx_process()
2879 i = txq->oldest; in __ipw2100_tx_process()
2880 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, in __ipw2100_tx_process()
2881 &txq->drv[i], in __ipw2100_tx_process()
2882 (u32) (txq->nic + i * sizeof(struct ipw2100_bd)), in __ipw2100_tx_process()
2883 txq->drv[i].host_addr, txq->drv[i].buf_length); in __ipw2100_tx_process()
2885 if (packet->type == DATA) { in __ipw2100_tx_process()
2886 i = (i + 1) % txq->entries; in __ipw2100_tx_process()
2888 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, in __ipw2100_tx_process()
2889 &txq->drv[i], in __ipw2100_tx_process()
2890 (u32) (txq->nic + i * in __ipw2100_tx_process()
2892 (u32) txq->drv[i].host_addr, in __ipw2100_tx_process()
2893 txq->drv[i].buf_length); in __ipw2100_tx_process()
2898 switch (packet->type) { in __ipw2100_tx_process()
2900 if (txq->drv[txq->oldest].status.info.fields.txType != 0) in __ipw2100_tx_process()
2904 priv->net_dev->name, txq->oldest, packet->index); in __ipw2100_tx_process()
2908 tbd = &txq->drv[(packet->index + 1 + i) % txq->entries]; in __ipw2100_tx_process()
2910 IPW_DEBUG_TX("TX%d P=%08x L=%d\n", in __ipw2100_tx_process()
2911 (packet->index + 1 + i) % txq->entries, in __ipw2100_tx_process()
2912 tbd->host_addr, tbd->buf_length); in __ipw2100_tx_process()
2914 dma_unmap_single(&priv->pci_dev->dev, tbd->host_addr, in __ipw2100_tx_process()
2915 tbd->buf_length, DMA_TO_DEVICE); in __ipw2100_tx_process()
2918 libipw_txb_free(packet->info.d_struct.txb); in __ipw2100_tx_process()
2919 packet->info.d_struct.txb = NULL; in __ipw2100_tx_process()
2921 list_add_tail(element, &priv->tx_free_list); in __ipw2100_tx_process()
2922 INC_STAT(&priv->tx_free_stat); in __ipw2100_tx_process()
2924 /* We have a free slot in the Tx queue, so wake up the in __ipw2100_tx_process()
2926 if (priv->status & STATUS_ASSOCIATED) in __ipw2100_tx_process()
2927 netif_wake_queue(priv->net_dev); in __ipw2100_tx_process()
2931 netif_trans_update(priv->net_dev); in __ipw2100_tx_process()
2936 if (txq->drv[txq->oldest].status.info.fields.txType != 1) in __ipw2100_tx_process()
2940 priv->net_dev->name, txq->oldest, packet->index); in __ipw2100_tx_process()
2943 if (packet->info.c_struct.cmd->host_command_reg < in __ipw2100_tx_process()
2946 command_types[packet->info.c_struct.cmd-> in __ipw2100_tx_process()
2948 packet->info.c_struct.cmd-> in __ipw2100_tx_process()
2950 packet->info.c_struct.cmd->cmd_status_reg); in __ipw2100_tx_process()
2953 list_add_tail(element, &priv->msg_free_list); in __ipw2100_tx_process()
2954 INC_STAT(&priv->msg_free_stat); in __ipw2100_tx_process()
2959 txq->oldest = (e + 1) % txq->entries; in __ipw2100_tx_process()
2961 txq->available += descriptors_used; in __ipw2100_tx_process()
2962 SET_STAT(&priv->txq_stat, txq->available); in __ipw2100_tx_process()
2965 jiffies - packet->jiffy_start); in __ipw2100_tx_process()
2967 return (!list_empty(&priv->fw_pend_list)); in __ipw2100_tx_process()
2980 priv->net_dev->name, i); in __ipw2100_tx_complete()
2988 struct ipw2100_bd_queue *txq = &priv->tx_queue; in ipw2100_tx_send_commands()
2990 int next = txq->next; in ipw2100_tx_send_commands()
2992 while (!list_empty(&priv->msg_pend_list)) { in ipw2100_tx_send_commands()
2999 if (txq->available <= 3) { in ipw2100_tx_send_commands()
3004 element = priv->msg_pend_list.next; in ipw2100_tx_send_commands()
3006 DEC_STAT(&priv->msg_pend_stat); in ipw2100_tx_send_commands()
3011 &txq->drv[txq->next], in ipw2100_tx_send_commands()
3012 (u32) (txq->nic + txq->next * in ipw2100_tx_send_commands()
3015 packet->index = txq->next; in ipw2100_tx_send_commands()
3017 tbd = &txq->drv[txq->next]; in ipw2100_tx_send_commands()
3020 tbd->host_addr = packet->info.c_struct.cmd_phys; in ipw2100_tx_send_commands()
3021 tbd->buf_length = sizeof(struct ipw2100_cmd_header); in ipw2100_tx_send_commands()
3024 tbd->num_fragments = 1; in ipw2100_tx_send_commands()
3025 tbd->status.info.field = in ipw2100_tx_send_commands()
3030 txq->next++; in ipw2100_tx_send_commands()
3031 txq->next %= txq->entries; in ipw2100_tx_send_commands()
3032 txq->available--; in ipw2100_tx_send_commands()
3033 DEC_STAT(&priv->txq_stat); in ipw2100_tx_send_commands()
3035 list_add_tail(element, &priv->fw_pend_list); in ipw2100_tx_send_commands()
3036 INC_STAT(&priv->fw_pend_stat); in ipw2100_tx_send_commands()
3039 if (txq->next != next) { in ipw2100_tx_send_commands()
3043 write_register(priv->net_dev, in ipw2100_tx_send_commands()
3045 txq->next); in ipw2100_tx_send_commands()
3057 struct ipw2100_bd_queue *txq = &priv->tx_queue; in ipw2100_tx_send_data()
3059 int next = txq->next; in ipw2100_tx_send_data()
3064 while (!list_empty(&priv->tx_pend_list)) { in ipw2100_tx_send_data()
3071 element = priv->tx_pend_list.next; in ipw2100_tx_send_data()
3074 if (unlikely(1 + packet->info.d_struct.txb->nr_frags > in ipw2100_tx_send_data()
3080 priv->net_dev->name); in ipw2100_tx_send_data()
3083 if (txq->available <= 3 + packet->info.d_struct.txb->nr_frags) { in ipw2100_tx_send_data()
3089 DEC_STAT(&priv->tx_pend_stat); in ipw2100_tx_send_data()
3091 tbd = &txq->drv[txq->next]; in ipw2100_tx_send_data()
3093 packet->index = txq->next; in ipw2100_tx_send_data()
3095 ipw_hdr = packet->info.d_struct.data; in ipw2100_tx_send_data()
3096 hdr = (struct libipw_hdr_3addr *)packet->info.d_struct.txb-> in ipw2100_tx_send_data()
3097 fragments[0]->data; in ipw2100_tx_send_data()
3099 if (priv->ieee->iw_mode == IW_MODE_INFRA) { in ipw2100_tx_send_data()
3102 memcpy(ipw_hdr->src_addr, hdr->addr2, ETH_ALEN); in ipw2100_tx_send_data()
3103 memcpy(ipw_hdr->dst_addr, hdr->addr3, ETH_ALEN); in ipw2100_tx_send_data()
3104 } else if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw2100_tx_send_data()
3107 memcpy(ipw_hdr->src_addr, hdr->addr2, ETH_ALEN); in ipw2100_tx_send_data()
3108 memcpy(ipw_hdr->dst_addr, hdr->addr1, ETH_ALEN); in ipw2100_tx_send_data()
3111 ipw_hdr->host_command_reg = SEND; in ipw2100_tx_send_data()
3112 ipw_hdr->host_command_reg1 = 0; in ipw2100_tx_send_data()
3115 ipw_hdr->needs_encryption = 0; in ipw2100_tx_send_data()
3116 ipw_hdr->encrypted = packet->info.d_struct.txb->encrypted; in ipw2100_tx_send_data()
3117 if (packet->info.d_struct.txb->nr_frags > 1) in ipw2100_tx_send_data()
3118 ipw_hdr->fragment_size = in ipw2100_tx_send_data()
3119 packet->info.d_struct.txb->frag_size - in ipw2100_tx_send_data()
3122 ipw_hdr->fragment_size = 0; in ipw2100_tx_send_data()
3124 tbd->host_addr = packet->info.d_struct.data_phys; in ipw2100_tx_send_data()
3125 tbd->buf_length = sizeof(struct ipw2100_data_header); in ipw2100_tx_send_data()
3126 tbd->num_fragments = 1 + packet->info.d_struct.txb->nr_frags; in ipw2100_tx_send_data()
3127 tbd->status.info.field = in ipw2100_tx_send_data()
3130 txq->next++; in ipw2100_tx_send_data()
3131 txq->next %= txq->entries; in ipw2100_tx_send_data()
3133 IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n", in ipw2100_tx_send_data()
3134 packet->index, tbd->host_addr, tbd->buf_length); in ipw2100_tx_send_data()
3136 if (packet->info.d_struct.txb->nr_frags > 1) in ipw2100_tx_send_data()
3137 IPW_DEBUG_FRAG("fragment Tx: %d frames\n", in ipw2100_tx_send_data()
3138 packet->info.d_struct.txb->nr_frags); in ipw2100_tx_send_data()
3141 for (i = 0; i < packet->info.d_struct.txb->nr_frags; i++) { in ipw2100_tx_send_data()
3142 tbd = &txq->drv[txq->next]; in ipw2100_tx_send_data()
3143 if (i == packet->info.d_struct.txb->nr_frags - 1) in ipw2100_tx_send_data()
3144 tbd->status.info.field = in ipw2100_tx_send_data()
3148 tbd->status.info.field = in ipw2100_tx_send_data()
3152 tbd->buf_length = packet->info.d_struct.txb-> in ipw2100_tx_send_data()
3153 fragments[i]->len - LIBIPW_3ADDR_LEN; in ipw2100_tx_send_data()
3155 tbd->host_addr = dma_map_single(&priv->pci_dev->dev, in ipw2100_tx_send_data()
3156 packet->info.d_struct. in ipw2100_tx_send_data()
3157 txb->fragments[i]->data + in ipw2100_tx_send_data()
3159 tbd->buf_length, in ipw2100_tx_send_data()
3161 if (dma_mapping_error(&priv->pci_dev->dev, tbd->host_addr)) { in ipw2100_tx_send_data()
3166 IPW_DEBUG_TX("data frag tbd TX%d P=%08x L=%d\n", in ipw2100_tx_send_data()
3167 txq->next, tbd->host_addr, in ipw2100_tx_send_data()
3168 tbd->buf_length); in ipw2100_tx_send_data()
3170 dma_sync_single_for_device(&priv->pci_dev->dev, in ipw2100_tx_send_data()
3171 tbd->host_addr, in ipw2100_tx_send_data()
3172 tbd->buf_length, in ipw2100_tx_send_data()
3175 txq->next++; in ipw2100_tx_send_data()
3176 txq->next %= txq->entries; in ipw2100_tx_send_data()
3179 txq->available -= 1 + packet->info.d_struct.txb->nr_frags; in ipw2100_tx_send_data()
3180 SET_STAT(&priv->txq_stat, txq->available); in ipw2100_tx_send_data()
3182 list_add_tail(element, &priv->fw_pend_list); in ipw2100_tx_send_data()
3183 INC_STAT(&priv->fw_pend_stat); in ipw2100_tx_send_data()
3186 if (txq->next != next) { in ipw2100_tx_send_data()
3189 write_register(priv->net_dev, in ipw2100_tx_send_data()
3191 txq->next); in ipw2100_tx_send_data()
3198 struct net_device *dev = priv->net_dev; in ipw2100_irq_tasklet()
3202 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_irq_tasklet()
3207 IPW_DEBUG_ISR("enter - INTA: 0x%08lX\n", in ipw2100_irq_tasklet()
3210 priv->in_isr++; in ipw2100_irq_tasklet()
3211 priv->interrupts++; in ipw2100_irq_tasklet()
3222 priv->inta_other++; in ipw2100_irq_tasklet()
3225 read_nic_dword(dev, IPW_NIC_FATAL_ERROR, &priv->fatal_error); in ipw2100_irq_tasklet()
3227 priv->net_dev->name, priv->fatal_error); in ipw2100_irq_tasklet()
3229 read_nic_dword(dev, IPW_ERROR_ADDR(priv->fatal_error), &tmp); in ipw2100_irq_tasklet()
3231 priv->net_dev->name, tmp); in ipw2100_irq_tasklet()
3240 priv->inta_other++; in ipw2100_irq_tasklet()
3247 priv->rx_interrupts++; in ipw2100_irq_tasklet()
3256 IPW_DEBUG_ISR("TX interrupt\n"); in ipw2100_irq_tasklet()
3258 priv->tx_interrupts++; in ipw2100_irq_tasklet()
3268 IPW_DEBUG_ISR("TX complete\n"); in ipw2100_irq_tasklet()
3269 priv->inta_other++; in ipw2100_irq_tasklet()
3277 priv->inta_other++; in ipw2100_irq_tasklet()
3283 priv->inta_other++; in ipw2100_irq_tasklet()
3298 priv->inta_other++; in ipw2100_irq_tasklet()
3304 priv->inta_other++; in ipw2100_irq_tasklet()
3309 priv->in_isr--; in ipw2100_irq_tasklet()
3312 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_irq_tasklet()
3325 spin_lock(&priv->low_lock); in ipw2100_interrupt()
3331 if (!(priv->status & STATUS_INT_ENABLED)) { in ipw2100_interrupt()
3336 read_register(priv->net_dev, IPW_REG_INTA_MASK, &inta_mask); in ipw2100_interrupt()
3337 read_register(priv->net_dev, IPW_REG_INTA, &inta); in ipw2100_interrupt()
3354 * work tasklet, so if another part of the code re-enables the in ipw2100_interrupt()
3358 tasklet_schedule(&priv->irq_tasklet); in ipw2100_interrupt()
3359 spin_unlock(&priv->low_lock); in ipw2100_interrupt()
3363 spin_unlock(&priv->low_lock); in ipw2100_interrupt()
3375 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_tx()
3377 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw2100_tx()
3379 priv->net_dev->stats.tx_carrier_errors++; in ipw2100_tx()
3384 if (list_empty(&priv->tx_free_list)) in ipw2100_tx()
3387 element = priv->tx_free_list.next; in ipw2100_tx()
3390 packet->info.d_struct.txb = txb; in ipw2100_tx()
3392 IPW_DEBUG_TX("Sending fragment (%d bytes):\n", txb->fragments[0]->len); in ipw2100_tx()
3393 printk_buf(IPW_DL_TX, txb->fragments[0]->data, txb->fragments[0]->len); in ipw2100_tx()
3395 packet->jiffy_start = jiffies; in ipw2100_tx()
3398 DEC_STAT(&priv->tx_free_stat); in ipw2100_tx()
3400 list_add_tail(element, &priv->tx_pend_list); in ipw2100_tx()
3401 INC_STAT(&priv->tx_pend_stat); in ipw2100_tx()
3405 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_tx()
3410 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_tx()
3416 int i, j, err = -EINVAL; in ipw2100_msg_allocate()
3420 priv->msg_buffers = in ipw2100_msg_allocate()
3424 if (!priv->msg_buffers) in ipw2100_msg_allocate()
3425 return -ENOMEM; in ipw2100_msg_allocate()
3428 v = dma_alloc_coherent(&priv->pci_dev->dev, in ipw2100_msg_allocate()
3434 "buffers.\n", priv->net_dev->name); in ipw2100_msg_allocate()
3435 err = -ENOMEM; in ipw2100_msg_allocate()
3439 priv->msg_buffers[i].type = COMMAND; in ipw2100_msg_allocate()
3440 priv->msg_buffers[i].info.c_struct.cmd = in ipw2100_msg_allocate()
3442 priv->msg_buffers[i].info.c_struct.cmd_phys = p; in ipw2100_msg_allocate()
3449 dma_free_coherent(&priv->pci_dev->dev, in ipw2100_msg_allocate()
3451 priv->msg_buffers[j].info.c_struct.cmd, in ipw2100_msg_allocate()
3452 priv->msg_buffers[j].info.c_struct.cmd_phys); in ipw2100_msg_allocate()
3455 kfree(priv->msg_buffers); in ipw2100_msg_allocate()
3456 priv->msg_buffers = NULL; in ipw2100_msg_allocate()
3465 INIT_LIST_HEAD(&priv->msg_free_list); in ipw2100_msg_initialize()
3466 INIT_LIST_HEAD(&priv->msg_pend_list); in ipw2100_msg_initialize()
3469 list_add_tail(&priv->msg_buffers[i].list, &priv->msg_free_list); in ipw2100_msg_initialize()
3470 SET_STAT(&priv->msg_free_stat, i); in ipw2100_msg_initialize()
3479 if (!priv->msg_buffers) in ipw2100_msg_free()
3483 dma_free_coherent(&priv->pci_dev->dev, in ipw2100_msg_free()
3485 priv->msg_buffers[i].info.c_struct.cmd, in ipw2100_msg_free()
3486 priv->msg_buffers[i].info.c_struct.cmd_phys); in ipw2100_msg_free()
3489 kfree(priv->msg_buffers); in ipw2100_msg_free()
3490 priv->msg_buffers = NULL; in ipw2100_msg_free()
3510 return out - buf; in pci_show()
3519 return sprintf(buf, "0x%08x\n", (int)p->config); in cfg_show()
3528 return sprintf(buf, "0x%08x\n", (int)p->status); in status_show()
3537 return sprintf(buf, "0x%08x\n", (int)p->capability); in capability_show()
3565 IPW2100_ORD(STAT_TX_HOST_REQUESTS, "requested Host Tx's (MSDU)"),
3567 "successful Host Tx's (MSDU)"),
3569 "successful Directed Tx's (MSDU)"),
3571 "successful Directed Tx's (MSDU) @ 1MB"),
3573 "successful Directed Tx's (MSDU) @ 2MB"),
3575 "successful Directed Tx's (MSDU) @ 5_5MB"),
3577 "successful Directed Tx's (MSDU) @ 11MB"),
3579 "successful Non_Directed Tx's (MSDU) @ 1MB"),
3581 "successful Non_Directed Tx's (MSDU) @ 2MB"),
3583 "successful Non_Directed Tx's (MSDU) @ 5.5MB"),
3585 "successful Non_Directed Tx's (MSDU) @ 11MB"),
3586 IPW2100_ORD(STAT_NULL_DATA, "successful NULL data Tx's"),
3587 IPW2100_ORD(STAT_TX_RTS, "successful Tx RTS"),
3588 IPW2100_ORD(STAT_TX_CTS, "successful Tx CTS"),
3589 IPW2100_ORD(STAT_TX_ACK, "successful Tx ACK"),
3590 IPW2100_ORD(STAT_TX_ASSN, "successful Association Tx's"),
3592 "successful Association response Tx's"),
3594 "successful Reassociation Tx's"),
3596 "successful Reassociation response Tx's"),
3601 IPW2100_ORD(STAT_TX_BEACON, "tx beacon"),
3602 IPW2100_ORD(STAT_TX_ATIM, "Tx ATIM"),
3604 "successful Disassociation TX"),
3605 IPW2100_ORD(STAT_TX_AUTH, "successful Authentication Tx"),
3607 "successful Deauthentication TX"),
3609 "Total successful Tx data bytes"),
3610 IPW2100_ORD(STAT_TX_RETRIES, "Tx retries"),
3611 IPW2100_ORD(STAT_TX_RETRY1, "Tx retries at 1MBPS"),
3612 IPW2100_ORD(STAT_TX_RETRY2, "Tx retries at 2MBPS"),
3613 IPW2100_ORD(STAT_TX_RETRY5_5, "Tx retries at 5.5MBPS"),
3614 IPW2100_ORD(STAT_TX_RETRY11, "Tx retries at 11MBPS"),
3615 IPW2100_ORD(STAT_TX_FAILURES, "Tx Failures"),
3621 IPW2100_ORD(STAT_TX_ERR_ACK, "tx err due to acks"),
3683 "rx frames dropped due to non-sequential fragment"),
3703 "current calculation of % missed tx retries"),
3720 "reassociation: no probe response or TX on hop"),
3722 "reassociation: poor tx/rx quality"),
3724 "reassociation: tx/rx quality (excessive AP load"),
3735 IPW2100_ORD(POWER_MGMT_MODE, "Power mode - 0=CAM, 1=PSP"),
3746 "current radio freq lower digits - channel ID"),
3749 IPW2100_ORD(CURRENT_TX_RATE, "current tx rate"),
3750 IPW2100_ORD(SUPPORTED_RATES, "supported tx rates"),
3752 IPW2100_ORD(BASIC_RATES, "basic tx rates"),
3753 IPW2100_ORD(NIC_HIGHEST_RATE, "NIC highest tx rate"),
3754 IPW2100_ORD(AP_HIGHEST_RATE, "AP highest tx rate"),
3782 struct net_device *dev = priv->net_dev; in registers_show()
3794 return out - buf; in registers_show()
3803 struct net_device *dev = priv->net_dev; in hardware_show()
3835 return out - buf; in hardware_show()
3844 struct net_device *dev = priv->net_dev; in memory_show()
3855 while (len < PAGE_SIZE - 128 && loop < 0x30000) { in memory_show()
3857 if (priv->snapshot[0]) in memory_show()
3865 if (priv->dump_raw) in memory_show()
3901 struct net_device *dev = priv->net_dev; in memory_store()
3904 (void)dev; /* kill unused-var warning for debug-only code */ in memory_store()
3912 dev->name); in memory_store()
3913 priv->dump_raw = 1; in memory_store()
3918 dev->name); in memory_store()
3919 priv->dump_raw = 0; in memory_store()
3922 IPW_DEBUG_INFO("%s: Resetting firmware snapshot.\n", dev->name); in memory_store()
3927 "reset = clear memory snapshot\n", dev->name); in memory_store()
3943 if (priv->status & STATUS_RF_KILL_MASK) in ordinals_show()
3950 while (len < PAGE_SIZE - 128 && loop < ARRAY_SIZE(ord_data)) { in ordinals_show()
3976 out += sprintf(out, "interrupts: %d {tx: %d, rx: %d, other: %d}\n", in stats_show()
3977 priv->interrupts, priv->tx_interrupts, in stats_show()
3978 priv->rx_interrupts, priv->inta_other); in stats_show()
3979 out += sprintf(out, "firmware resets: %d\n", priv->resets); in stats_show()
3980 out += sprintf(out, "firmware hangs: %d\n", priv->hangs); in stats_show()
3983 priv->snapshot[0] ? "YES" : "NO"); in stats_show()
3986 return out - buf; in stats_show()
3995 if (mode == priv->ieee->iw_mode) in ipw2100_switch_mode()
4001 priv->net_dev->name, err); in ipw2100_switch_mode()
4007 priv->net_dev->type = ARPHRD_ETHER; in ipw2100_switch_mode()
4010 priv->net_dev->type = ARPHRD_ETHER; in ipw2100_switch_mode()
4014 priv->last_mode = priv->ieee->iw_mode; in ipw2100_switch_mode()
4015 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; in ipw2100_switch_mode()
4020 priv->ieee->iw_mode = mode; in ipw2100_switch_mode()
4028 printk(KERN_INFO "%s: Resetting on mode change.\n", priv->net_dev->name); in ipw2100_switch_mode()
4029 priv->reset_backoff = 0; in ipw2100_switch_mode()
4041 #define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x) in internals_show()
4043 if (priv->status & STATUS_ASSOCIATED) in internals_show()
4045 ktime_get_boottime_seconds() - priv->connect_start); in internals_show()
4049 DUMP_VAR(ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx], "p"); in internals_show()
4056 (unsigned long)priv->last_rtc); in internals_show()
4081 DUMP_VAR(ieee->scans, "d"); in internals_show()
4100 if (priv->status & STATUS_RF_KILL_MASK) in bssinfo_show()
4129 return out - buf; in bssinfo_show()
4164 if (priv->fatal_error) in fatal_error_show()
4165 out += sprintf(out, "0x%08X\n", priv->fatal_error); in fatal_error_show()
4170 if (!priv->fatal_errors[(priv->fatal_index - i) % in fatal_error_show()
4175 priv->fatal_errors[(priv->fatal_index - i) % in fatal_error_show()
4179 return out - buf; in fatal_error_show()
4197 return sprintf(buf, "%d\n", priv->ieee->scan_age); in scan_age_show()
4204 struct net_device *dev = priv->net_dev; in scan_age_store()
4208 (void)dev; /* kill unused-var warning for debug-only code */ in scan_age_store()
4214 IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name); in scan_age_store()
4216 priv->ieee->scan_age = val; in scan_age_store()
4217 IPW_DEBUG_INFO("set scan_age = %u\n", priv->ieee->scan_age); in scan_age_store()
4229 /* 0 - RF kill not enabled in rf_kill_show()
4230 1 - SW based RF kill active (sysfs) in rf_kill_show()
4231 2 - HW based RF kill active in rf_kill_show()
4232 3 - Both HW and SW baed RF kill active */ in rf_kill_show()
4234 int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | in rf_kill_show()
4242 (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) in ipw_radio_kill_sw()
4248 mutex_lock(&priv->action_mutex); in ipw_radio_kill_sw()
4251 priv->status |= STATUS_RF_KILL_SW; in ipw_radio_kill_sw()
4254 priv->status &= ~STATUS_RF_KILL_SW; in ipw_radio_kill_sw()
4256 IPW_DEBUG_RF_KILL("Can not turn radio back on - " in ipw_radio_kill_sw()
4259 priv->stop_rf_kill = 0; in ipw_radio_kill_sw()
4260 mod_delayed_work(system_wq, &priv->rf_kill, in ipw_radio_kill_sw()
4266 mutex_unlock(&priv->action_mutex); in ipw_radio_kill_sw()
4304 struct ipw2100_status_queue *q = &priv->status_queue; in status_queue_allocate()
4308 q->size = entries * sizeof(struct ipw2100_status); in status_queue_allocate()
4309 q->drv = dma_alloc_coherent(&priv->pci_dev->dev, q->size, &q->nic, in status_queue_allocate()
4311 if (!q->drv) { in status_queue_allocate()
4313 return -ENOMEM; in status_queue_allocate()
4325 if (priv->status_queue.drv) { in status_queue_free()
4326 dma_free_coherent(&priv->pci_dev->dev, in status_queue_free()
4327 priv->status_queue.size, in status_queue_free()
4328 priv->status_queue.drv, in status_queue_free()
4329 priv->status_queue.nic); in status_queue_free()
4330 priv->status_queue.drv = NULL; in status_queue_free()
4343 q->entries = entries; in bd_queue_allocate()
4344 q->size = entries * sizeof(struct ipw2100_bd); in bd_queue_allocate()
4345 q->drv = dma_alloc_coherent(&priv->pci_dev->dev, q->size, &q->nic, in bd_queue_allocate()
4347 if (!q->drv) { in bd_queue_allocate()
4350 return -ENOMEM; in bd_queue_allocate()
4365 if (q->drv) { in bd_queue_free()
4366 dma_free_coherent(&priv->pci_dev->dev, q->size, q->drv, in bd_queue_free()
4367 q->nic); in bd_queue_free()
4368 q->drv = NULL; in bd_queue_free()
4380 IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, in bd_queue_initialize()
4381 (u32) q->nic); in bd_queue_initialize()
4383 write_register(priv->net_dev, base, q->nic); in bd_queue_initialize()
4384 write_register(priv->net_dev, size, q->entries); in bd_queue_initialize()
4385 write_register(priv->net_dev, r, q->oldest); in bd_queue_initialize()
4386 write_register(priv->net_dev, w, q->next); in bd_queue_initialize()
4393 priv->stop_rf_kill = 1; in ipw2100_kill_works()
4394 priv->stop_hang_check = 1; in ipw2100_kill_works()
4395 cancel_delayed_work_sync(&priv->reset_work); in ipw2100_kill_works()
4396 cancel_delayed_work_sync(&priv->security_work); in ipw2100_kill_works()
4397 cancel_delayed_work_sync(&priv->wx_event_work); in ipw2100_kill_works()
4398 cancel_delayed_work_sync(&priv->hang_check); in ipw2100_kill_works()
4399 cancel_delayed_work_sync(&priv->rf_kill); in ipw2100_kill_works()
4400 cancel_delayed_work_sync(&priv->scan_event); in ipw2100_kill_works()
4411 err = bd_queue_allocate(priv, &priv->tx_queue, TX_QUEUE_LENGTH); in ipw2100_tx_allocate()
4414 priv->net_dev->name); in ipw2100_tx_allocate()
4418 priv->tx_buffers = kmalloc_array(TX_PENDED_QUEUE_LENGTH, in ipw2100_tx_allocate()
4421 if (!priv->tx_buffers) { in ipw2100_tx_allocate()
4422 bd_queue_free(priv, &priv->tx_queue); in ipw2100_tx_allocate()
4423 return -ENOMEM; in ipw2100_tx_allocate()
4427 v = dma_alloc_coherent(&priv->pci_dev->dev, in ipw2100_tx_allocate()
4432 ": %s: PCI alloc failed for tx " "buffers.\n", in ipw2100_tx_allocate()
4433 priv->net_dev->name); in ipw2100_tx_allocate()
4434 err = -ENOMEM; in ipw2100_tx_allocate()
4438 priv->tx_buffers[i].type = DATA; in ipw2100_tx_allocate()
4439 priv->tx_buffers[i].info.d_struct.data = in ipw2100_tx_allocate()
4441 priv->tx_buffers[i].info.d_struct.data_phys = p; in ipw2100_tx_allocate()
4442 priv->tx_buffers[i].info.d_struct.txb = NULL; in ipw2100_tx_allocate()
4449 dma_free_coherent(&priv->pci_dev->dev, in ipw2100_tx_allocate()
4451 priv->tx_buffers[j].info.d_struct.data, in ipw2100_tx_allocate()
4452 priv->tx_buffers[j].info.d_struct.data_phys); in ipw2100_tx_allocate()
4455 kfree(priv->tx_buffers); in ipw2100_tx_allocate()
4456 priv->tx_buffers = NULL; in ipw2100_tx_allocate()
4470 INIT_LIST_HEAD(&priv->fw_pend_list); in ipw2100_tx_initialize()
4471 INIT_STAT(&priv->fw_pend_stat); in ipw2100_tx_initialize()
4476 INIT_LIST_HEAD(&priv->tx_pend_list); in ipw2100_tx_initialize()
4477 INIT_LIST_HEAD(&priv->tx_free_list); in ipw2100_tx_initialize()
4478 INIT_STAT(&priv->tx_pend_stat); in ipw2100_tx_initialize()
4479 INIT_STAT(&priv->tx_free_stat); in ipw2100_tx_initialize()
4484 if (priv->tx_buffers[i].info.d_struct.txb) { in ipw2100_tx_initialize()
4485 libipw_txb_free(priv->tx_buffers[i].info.d_struct. in ipw2100_tx_initialize()
4487 priv->tx_buffers[i].info.d_struct.txb = NULL; in ipw2100_tx_initialize()
4490 list_add_tail(&priv->tx_buffers[i].list, &priv->tx_free_list); in ipw2100_tx_initialize()
4493 SET_STAT(&priv->tx_free_stat, i); in ipw2100_tx_initialize()
4495 priv->tx_queue.oldest = 0; in ipw2100_tx_initialize()
4496 priv->tx_queue.available = priv->tx_queue.entries; in ipw2100_tx_initialize()
4497 priv->tx_queue.next = 0; in ipw2100_tx_initialize()
4498 INIT_STAT(&priv->txq_stat); in ipw2100_tx_initialize()
4499 SET_STAT(&priv->txq_stat, priv->tx_queue.available); in ipw2100_tx_initialize()
4501 bd_queue_initialize(priv, &priv->tx_queue, in ipw2100_tx_initialize()
4517 bd_queue_free(priv, &priv->tx_queue); in ipw2100_tx_free()
4519 if (!priv->tx_buffers) in ipw2100_tx_free()
4523 if (priv->tx_buffers[i].info.d_struct.txb) { in ipw2100_tx_free()
4524 libipw_txb_free(priv->tx_buffers[i].info.d_struct. in ipw2100_tx_free()
4526 priv->tx_buffers[i].info.d_struct.txb = NULL; in ipw2100_tx_free()
4528 if (priv->tx_buffers[i].info.d_struct.data) in ipw2100_tx_free()
4529 dma_free_coherent(&priv->pci_dev->dev, in ipw2100_tx_free()
4531 priv->tx_buffers[i].info.d_struct.data, in ipw2100_tx_free()
4532 priv->tx_buffers[i].info.d_struct.data_phys); in ipw2100_tx_free()
4535 kfree(priv->tx_buffers); in ipw2100_tx_free()
4536 priv->tx_buffers = NULL; in ipw2100_tx_free()
4543 int i, j, err = -EINVAL; in ipw2100_rx_allocate()
4547 err = bd_queue_allocate(priv, &priv->rx_queue, RX_QUEUE_LENGTH); in ipw2100_rx_allocate()
4556 bd_queue_free(priv, &priv->rx_queue); in ipw2100_rx_allocate()
4563 priv->rx_buffers = kmalloc_array(RX_QUEUE_LENGTH, in ipw2100_rx_allocate()
4566 if (!priv->rx_buffers) { in ipw2100_rx_allocate()
4569 bd_queue_free(priv, &priv->rx_queue); in ipw2100_rx_allocate()
4573 return -ENOMEM; in ipw2100_rx_allocate()
4577 struct ipw2100_rx_packet *packet = &priv->rx_buffers[i]; in ipw2100_rx_allocate()
4581 err = -ENOMEM; in ipw2100_rx_allocate()
4586 priv->rx_queue.drv[i].host_addr = packet->dma_addr; in ipw2100_rx_allocate()
4587 priv->rx_queue.drv[i].buf_length = IPW_RX_NIC_BUFFER_LENGTH; in ipw2100_rx_allocate()
4588 priv->status_queue.drv[i].status_fields = 0; in ipw2100_rx_allocate()
4595 dma_unmap_single(&priv->pci_dev->dev, in ipw2100_rx_allocate()
4596 priv->rx_buffers[j].dma_addr, in ipw2100_rx_allocate()
4599 dev_kfree_skb(priv->rx_buffers[j].skb); in ipw2100_rx_allocate()
4602 kfree(priv->rx_buffers); in ipw2100_rx_allocate()
4603 priv->rx_buffers = NULL; in ipw2100_rx_allocate()
4605 bd_queue_free(priv, &priv->rx_queue); in ipw2100_rx_allocate()
4616 priv->rx_queue.oldest = 0; in ipw2100_rx_initialize()
4617 priv->rx_queue.available = priv->rx_queue.entries - 1; in ipw2100_rx_initialize()
4618 priv->rx_queue.next = priv->rx_queue.entries - 1; in ipw2100_rx_initialize()
4620 INIT_STAT(&priv->rxq_stat); in ipw2100_rx_initialize()
4621 SET_STAT(&priv->rxq_stat, priv->rx_queue.available); in ipw2100_rx_initialize()
4623 bd_queue_initialize(priv, &priv->rx_queue, in ipw2100_rx_initialize()
4630 write_register(priv->net_dev, IPW_MEM_HOST_SHARED_RX_STATUS_BASE, in ipw2100_rx_initialize()
4631 priv->status_queue.nic); in ipw2100_rx_initialize()
4642 bd_queue_free(priv, &priv->rx_queue); in ipw2100_rx_free()
4645 if (!priv->rx_buffers) in ipw2100_rx_free()
4649 if (priv->rx_buffers[i].rxp) { in ipw2100_rx_free()
4650 dma_unmap_single(&priv->pci_dev->dev, in ipw2100_rx_free()
4651 priv->rx_buffers[i].dma_addr, in ipw2100_rx_free()
4654 dev_kfree_skb(priv->rx_buffers[i].skb); in ipw2100_rx_free()
4658 kfree(priv->rx_buffers); in ipw2100_rx_free()
4659 priv->rx_buffers = NULL; in ipw2100_rx_free()
4674 return -EIO; in ipw2100_read_mac_address()
4677 eth_hw_addr_set(priv->net_dev, addr); in ipw2100_read_mac_address()
4678 IPW_DEBUG_INFO("card MAC is %pM\n", priv->net_dev->dev_addr); in ipw2100_read_mac_address()
4702 if (priv->config & CFG_CUSTOM_MAC) { in ipw2100_set_mac_address()
4703 memcpy(cmd.host_command_parameters, priv->mac_addr, ETH_ALEN); in ipw2100_set_mac_address()
4704 eth_hw_addr_set(priv->net_dev, priv->mac_addr); in ipw2100_set_mac_address()
4706 memcpy(cmd.host_command_parameters, priv->net_dev->dev_addr, in ipw2100_set_mac_address()
4735 port_type == IPW_IBSS ? "Ad-Hoc" : "Managed"); in ipw2100_set_port_type()
4742 priv->net_dev->name, err); in ipw2100_set_port_type()
4771 if (priv->ieee->iw_mode == IW_MODE_INFRA) in ipw2100_set_channel()
4776 return -EINVAL; in ipw2100_set_channel()
4791 priv->config |= CFG_STATIC_CHANNEL; in ipw2100_set_channel()
4793 priv->config &= ~CFG_STATIC_CHANNEL; in ipw2100_set_channel()
4795 priv->channel = channel; in ipw2100_set_channel()
4824 if (priv->ieee->iw_mode == IW_MODE_ADHOC) in ipw2100_system_config()
4830 if (!(priv->config & CFG_LONG_PREAMBLE)) in ipw2100_system_config()
4885 /* Set BASIC TX Rate first */ in ipw2100_set_tx_rates()
4888 /* Set TX Rate */ in ipw2100_set_tx_rates()
4892 /* Set MSDU TX Rate */ in ipw2100_set_tx_rates()
4902 priv->tx_rates = rate; in ipw2100_set_tx_rates()
4923 priv->power_mode = IPW_POWER_LEVEL(priv->power_mode); in ipw2100_set_power_mode()
4925 priv->power_mode = IPW_POWER_ENABLED | power_level; in ipw2100_set_power_mode()
4928 if (priv->port_type == IBSS && priv->adhoc_power != DFTL_IBSS_TX_POWER) { in ipw2100_set_power_mode()
4931 cmd.host_command_parameters[0] = (u32) priv->adhoc_power; in ipw2100_set_power_mode()
4960 priv->rts_threshold = threshold; in ipw2100_set_rts_threshold()
5000 priv->frag_threshold = threshold;
5021 priv->short_retry_limit = retry; in ipw2100_set_short_retry()
5041 priv->long_retry_limit = retry; in ipw2100_set_long_retry()
5092 * the currently associated AP -- but in the off chance that a future in ipw2100_disassociate_bssid()
5095 memcpy(cmd.host_command_parameters, priv->bssid, ETH_ALEN); in ipw2100_disassociate_bssid()
5132 err = -EIO; in ipw2100_set_wpa_ie()
5166 security->auth_mode = auth_mode; in ipw2100_set_security_information()
5167 security->unicast_using_group = unicast_using_group; in ipw2100_set_security_information()
5172 security->allowed_ciphers = IPW_NONE_CIPHER; in ipw2100_set_security_information()
5175 security->allowed_ciphers = IPW_WEP40_CIPHER | in ipw2100_set_security_information()
5179 security->allowed_ciphers = IPW_WEP40_CIPHER | in ipw2100_set_security_information()
5183 security->allowed_ciphers = IPW_WEP40_CIPHER | in ipw2100_set_security_information()
5187 security->allowed_ciphers = IPW_WEP40_CIPHER | in ipw2100_set_security_information()
5194 security->auth_mode, security->allowed_ciphers, security_level); in ipw2100_set_security_information()
5196 security->replay_counters_number = 0; in ipw2100_set_security_information()
5223 tmp = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 / in ipw2100_set_tx_power()
5224 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM); in ipw2100_set_tx_power()
5228 if (priv->ieee->iw_mode == IW_MODE_ADHOC) in ipw2100_set_tx_power()
5231 priv->tx_power = tx_power; in ipw2100_set_tx_power()
5250 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw2100_set_ibss_beacon_interval()
5297 return -ENOMEM; in ipw2100_queues_allocate()
5321 priv->net_dev->name, err); in ipw2100_set_wep_flags()
5342 #define WEP_FMT_64 "%02X%02X%02X%02X-%02X"
5343 #define WEP_FMT_128 "%02X%02X%02X%02X-%02X%02X%02X%02X-%02X%02X%02X"
5348 * ipw2100_set_key() - Set a the wep key
5381 wep_key->idx = idx; in ipw2100_set_key()
5382 wep_key->len = keylen; in ipw2100_set_key()
5385 memcpy(wep_key->key, key, len); in ipw2100_set_key()
5386 memset(wep_key->key + len, 0, keylen - len); in ipw2100_set_key()
5392 priv->net_dev->name, wep_key->idx); in ipw2100_set_key()
5395 priv->net_dev->name, wep_key->idx, wep_key->len, in ipw2100_set_key()
5396 WEP_STR_64(wep_key->key)); in ipw2100_set_key()
5400 priv->net_dev->name, wep_key->idx, wep_key->len, in ipw2100_set_key()
5401 WEP_STR_128(wep_key->key)); in ipw2100_set_key()
5409 priv->net_dev->name, err); in ipw2100_set_key()
5439 return -EINVAL; in ipw2100_set_key_index()
5446 priv->net_dev->name, err); in ipw2100_set_key_index()
5464 if (!(priv->status & STATUS_RUNNING)) in ipw2100_configure_security()
5473 if (!priv->ieee->sec.enabled) { in ipw2100_configure_security()
5479 if (priv->ieee->sec.flags & SEC_AUTH_MODE) { in ipw2100_configure_security()
5480 if (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY) in ipw2100_configure_security()
5482 else if (priv->ieee->sec.auth_mode == WLAN_AUTH_LEAP) in ipw2100_configure_security()
5487 if (priv->ieee->sec.flags & SEC_LEVEL) in ipw2100_configure_security()
5488 sec_level = priv->ieee->sec.level; in ipw2100_configure_security()
5491 if (priv->ieee->sec.flags & SEC_UNICAST_GROUP) in ipw2100_configure_security()
5492 use_group = priv->ieee->sec.unicast_uses_group; in ipw2100_configure_security()
5502 if (priv->ieee->sec.enabled) { in ipw2100_configure_security()
5504 if (!(priv->ieee->sec.flags & (1 << i))) { in ipw2100_configure_security()
5505 memset(priv->ieee->sec.keys[i], 0, WEP_KEY_LEN); in ipw2100_configure_security()
5506 priv->ieee->sec.key_sizes[i] = 0; in ipw2100_configure_security()
5509 priv->ieee->sec.keys[i], in ipw2100_configure_security()
5510 priv->ieee->sec. in ipw2100_configure_security()
5517 ipw2100_set_key_index(priv, priv->ieee->crypt_info.tx_keyidx, 1); in ipw2100_configure_security()
5524 priv->ieee->sec. in ipw2100_configure_security()
5529 priv->status &= ~STATUS_SECURITY_UPDATED; in ipw2100_configure_security()
5544 * process this, then update the security settings--which causes in ipw2100_security_work()
5546 if (!(priv->status & STATUS_ASSOCIATED) && in ipw2100_security_work()
5547 priv->status & STATUS_SECURITY_UPDATED) in ipw2100_security_work()
5552 struct libipw_security *sec) in shim__set_security() argument
5557 mutex_lock(&priv->action_mutex); in shim__set_security()
5558 if (!(priv->status & STATUS_INITIALIZED)) in shim__set_security()
5562 if (sec->flags & (1 << i)) { in shim__set_security()
5563 priv->ieee->sec.key_sizes[i] = sec->key_sizes[i]; in shim__set_security()
5564 if (sec->key_sizes[i] == 0) in shim__set_security()
5565 priv->ieee->sec.flags &= ~(1 << i); in shim__set_security()
5567 memcpy(priv->ieee->sec.keys[i], sec->keys[i], in shim__set_security()
5568 sec->key_sizes[i]); in shim__set_security()
5569 if (sec->level == SEC_LEVEL_1) { in shim__set_security()
5570 priv->ieee->sec.flags |= (1 << i); in shim__set_security()
5571 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
5573 priv->ieee->sec.flags &= ~(1 << i); in shim__set_security()
5577 if ((sec->flags & SEC_ACTIVE_KEY) && in shim__set_security()
5578 priv->ieee->sec.active_key != sec->active_key) { in shim__set_security()
5579 priv->ieee->sec.active_key = sec->active_key; in shim__set_security()
5580 priv->ieee->sec.flags |= SEC_ACTIVE_KEY; in shim__set_security()
5581 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
5584 if ((sec->flags & SEC_AUTH_MODE) && in shim__set_security()
5585 (priv->ieee->sec.auth_mode != sec->auth_mode)) { in shim__set_security()
5586 priv->ieee->sec.auth_mode = sec->auth_mode; in shim__set_security()
5587 priv->ieee->sec.flags |= SEC_AUTH_MODE; in shim__set_security()
5588 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
5591 if (sec->flags & SEC_ENABLED && priv->ieee->sec.enabled != sec->enabled) { in shim__set_security()
5592 priv->ieee->sec.flags |= SEC_ENABLED; in shim__set_security()
5593 priv->ieee->sec.enabled = sec->enabled; in shim__set_security()
5594 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
5597 if (sec->flags & SEC_ENCRYPT) in shim__set_security()
5598 priv->ieee->sec.encrypt = sec->encrypt; in shim__set_security()
5600 if (sec->flags & SEC_LEVEL && priv->ieee->sec.level != sec->level) { in shim__set_security()
5601 priv->ieee->sec.level = sec->level; in shim__set_security()
5602 priv->ieee->sec.flags |= SEC_LEVEL; in shim__set_security()
5603 priv->status |= STATUS_SECURITY_UPDATED; in shim__set_security()
5607 priv->ieee->sec.flags & (1 << 8) ? '1' : '0', in shim__set_security()
5608 priv->ieee->sec.flags & (1 << 7) ? '1' : '0', in shim__set_security()
5609 priv->ieee->sec.flags & (1 << 6) ? '1' : '0', in shim__set_security()
5610 priv->ieee->sec.flags & (1 << 5) ? '1' : '0', in shim__set_security()
5611 priv->ieee->sec.flags & (1 << 4) ? '1' : '0', in shim__set_security()
5612 priv->ieee->sec.flags & (1 << 3) ? '1' : '0', in shim__set_security()
5613 priv->ieee->sec.flags & (1 << 2) ? '1' : '0', in shim__set_security()
5614 priv->ieee->sec.flags & (1 << 1) ? '1' : '0', in shim__set_security()
5615 priv->ieee->sec.flags & (1 << 0) ? '1' : '0'); in shim__set_security()
5621 * if (force_update || !(priv->status & STATUS_ASSOCIATED))*/ in shim__set_security()
5622 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) in shim__set_security()
5625 mutex_unlock(&priv->action_mutex); in shim__set_security()
5640 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw2100_adapter_setup()
5641 err = ipw2100_set_channel(priv, priv->channel, batch_mode); in ipw2100_adapter_setup()
5653 return -EIO; in ipw2100_adapter_setup()
5659 err = ipw2100_set_port_type(priv, priv->ieee->iw_mode, batch_mode); in ipw2100_adapter_setup()
5663 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw2100_adapter_setup()
5664 err = ipw2100_set_channel(priv, priv->channel, batch_mode); in ipw2100_adapter_setup()
5673 err = ipw2100_set_tx_rates(priv, priv->tx_rates, batch_mode); in ipw2100_adapter_setup()
5682 err = ipw2100_set_rts_threshold(priv, priv->rts_threshold); in ipw2100_adapter_setup()
5686 if (priv->config & CFG_STATIC_BSSID) in ipw2100_adapter_setup()
5687 bssid = priv->bssid; in ipw2100_adapter_setup()
5694 if (priv->config & CFG_STATIC_ESSID) in ipw2100_adapter_setup()
5695 err = ipw2100_set_essid(priv, priv->essid, priv->essid_len, in ipw2100_adapter_setup()
5706 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw2100_adapter_setup()
5709 priv->beacon_interval, in ipw2100_adapter_setup()
5714 err = ipw2100_set_tx_power(priv, priv->tx_power); in ipw2100_adapter_setup()
5721 priv, priv->frag_threshold, batch_mode); in ipw2100_adapter_setup()
5737 /* This method is called by the network layer -- not to be confused with
5746 if (!is_valid_ether_addr(addr->sa_data)) in ipw2100_set_address()
5747 return -EADDRNOTAVAIL; in ipw2100_set_address()
5749 mutex_lock(&priv->action_mutex); in ipw2100_set_address()
5751 priv->config |= CFG_CUSTOM_MAC; in ipw2100_set_address()
5752 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); in ipw2100_set_address()
5758 priv->reset_backoff = 0; in ipw2100_set_address()
5759 mutex_unlock(&priv->action_mutex); in ipw2100_set_address()
5760 ipw2100_reset_adapter(&priv->reset_work.work); in ipw2100_set_address()
5764 mutex_unlock(&priv->action_mutex); in ipw2100_set_address()
5772 IPW_DEBUG_INFO("dev->open\n"); in ipw2100_open()
5774 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_open()
5775 if (priv->status & STATUS_ASSOCIATED) { in ipw2100_open()
5779 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_open()
5793 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_close()
5795 if (priv->status & STATUS_ASSOCIATED) in ipw2100_close()
5799 /* Flush the TX queue ... */ in ipw2100_close()
5800 while (!list_empty(&priv->tx_pend_list)) { in ipw2100_close()
5801 element = priv->tx_pend_list.next; in ipw2100_close()
5805 DEC_STAT(&priv->tx_pend_stat); in ipw2100_close()
5807 libipw_txb_free(packet->info.d_struct.txb); in ipw2100_close()
5808 packet->info.d_struct.txb = NULL; in ipw2100_close()
5810 list_add_tail(element, &priv->tx_free_list); in ipw2100_close()
5811 INC_STAT(&priv->tx_free_stat); in ipw2100_close()
5813 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_close()
5827 dev->stats.tx_errors++; in ipw2100_tx_timeout()
5830 if (priv->ieee->iw_mode == IW_MODE_MONITOR) in ipw2100_tx_timeout()
5834 IPW_DEBUG_INFO("%s: TX timed out. Scheduling firmware restart.\n", in ipw2100_tx_timeout()
5835 dev->name); in ipw2100_tx_timeout()
5843 priv->ieee->wpa_enabled = value; in ipw2100_wpa_enable()
5850 struct libipw_device *ieee = priv->ieee; in ipw2100_wpa_set_auth_algs()
5851 struct libipw_security sec = { in ipw2100_wpa_set_auth_algs() local
5857 sec.auth_mode = WLAN_AUTH_SHARED_KEY; in ipw2100_wpa_set_auth_algs()
5858 ieee->open_wep = 0; in ipw2100_wpa_set_auth_algs()
5860 sec.auth_mode = WLAN_AUTH_OPEN; in ipw2100_wpa_set_auth_algs()
5861 ieee->open_wep = 1; in ipw2100_wpa_set_auth_algs()
5863 sec.auth_mode = WLAN_AUTH_LEAP; in ipw2100_wpa_set_auth_algs()
5864 ieee->open_wep = 1; in ipw2100_wpa_set_auth_algs()
5866 return -EINVAL; in ipw2100_wpa_set_auth_algs()
5868 if (ieee->set_security) in ipw2100_wpa_set_auth_algs()
5869 ieee->set_security(ieee->dev, &sec); in ipw2100_wpa_set_auth_algs()
5871 ret = -EOPNOTSUPP; in ipw2100_wpa_set_auth_algs()
5899 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in ipw_ethtool_get_drvinfo()
5900 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in ipw_ethtool_get_drvinfo()
5905 snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s", in ipw_ethtool_get_drvinfo()
5906 fw_ver, priv->eeprom_version, ucode_ver); in ipw_ethtool_get_drvinfo()
5908 strscpy(info->bus_info, pci_name(priv->pci_dev), in ipw_ethtool_get_drvinfo()
5909 sizeof(info->bus_info)); in ipw_ethtool_get_drvinfo()
5915 return (priv->status & STATUS_ASSOCIATED) ? 1 : 0; in ipw2100_ethtool_get_link()
5932 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_hang_check()
5934 if (priv->fatal_error != 0) { in ipw2100_hang_check()
5937 priv->net_dev->name); in ipw2100_hang_check()
5941 (rtc == priv->last_rtc)) { in ipw2100_hang_check()
5944 priv->net_dev->name); in ipw2100_hang_check()
5951 priv->stop_hang_check = 1; in ipw2100_hang_check()
5952 priv->hangs++; in ipw2100_hang_check()
5958 priv->last_rtc = rtc; in ipw2100_hang_check()
5960 if (!priv->stop_hang_check) in ipw2100_hang_check()
5961 schedule_delayed_work(&priv->hang_check, HZ / 2); in ipw2100_hang_check()
5963 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_hang_check()
5972 spin_lock_irqsave(&priv->low_lock, flags); in ipw2100_rf_kill()
5976 if (!priv->stop_rf_kill) in ipw2100_rf_kill()
5977 schedule_delayed_work(&priv->rf_kill, in ipw2100_rf_kill()
5984 if (!(priv->status & STATUS_RF_KILL_MASK)) { in ipw2100_rf_kill()
5993 spin_unlock_irqrestore(&priv->low_lock, flags); in ipw2100_rf_kill()
6019 priv->ieee = netdev_priv(dev); in ipw2100_alloc_device()
6020 priv->pci_dev = pci_dev; in ipw2100_alloc_device()
6021 priv->net_dev = dev; in ipw2100_alloc_device()
6022 priv->ioaddr = ioaddr; in ipw2100_alloc_device()
6024 priv->ieee->hard_start_xmit = ipw2100_tx; in ipw2100_alloc_device()
6025 priv->ieee->set_security = shim__set_security; in ipw2100_alloc_device()
6027 priv->ieee->perfect_rssi = -20; in ipw2100_alloc_device()
6028 priv->ieee->worst_rssi = -85; in ipw2100_alloc_device()
6030 dev->netdev_ops = &ipw2100_netdev_ops; in ipw2100_alloc_device()
6031 dev->ethtool_ops = &ipw2100_ethtool_ops; in ipw2100_alloc_device()
6032 dev->wireless_handlers = &ipw2100_wx_handler_def; in ipw2100_alloc_device()
6033 priv->wireless_data.libipw = priv->ieee; in ipw2100_alloc_device()
6034 dev->wireless_data = &priv->wireless_data; in ipw2100_alloc_device()
6035 dev->watchdog_timeo = 3 * HZ; in ipw2100_alloc_device()
6036 dev->irq = 0; in ipw2100_alloc_device()
6037 dev->min_mtu = 68; in ipw2100_alloc_device()
6038 dev->max_mtu = LIBIPW_DATA_LEN; in ipw2100_alloc_device()
6050 priv->power_mode = IPW_POWER_AUTO; in ipw2100_alloc_device()
6053 priv->config |= CFG_CRC_CHECK; in ipw2100_alloc_device()
6055 priv->ieee->wpa_enabled = 0; in ipw2100_alloc_device()
6056 priv->ieee->drop_unencrypted = 0; in ipw2100_alloc_device()
6057 priv->ieee->privacy_invoked = 0; in ipw2100_alloc_device()
6058 priv->ieee->ieee802_1x = 1; in ipw2100_alloc_device()
6063 priv->ieee->iw_mode = IW_MODE_ADHOC; in ipw2100_alloc_device()
6067 priv->ieee->iw_mode = IW_MODE_MONITOR; in ipw2100_alloc_device()
6072 priv->ieee->iw_mode = IW_MODE_INFRA; in ipw2100_alloc_device()
6077 priv->status |= STATUS_RF_KILL_SW; in ipw2100_alloc_device()
6081 priv->config |= CFG_STATIC_CHANNEL; in ipw2100_alloc_device()
6082 priv->channel = channel; in ipw2100_alloc_device()
6086 priv->config |= CFG_ASSOCIATE; in ipw2100_alloc_device()
6088 priv->beacon_interval = DEFAULT_BEACON_INTERVAL; in ipw2100_alloc_device()
6089 priv->short_retry_limit = DEFAULT_SHORT_RETRY_LIMIT; in ipw2100_alloc_device()
6090 priv->long_retry_limit = DEFAULT_LONG_RETRY_LIMIT; in ipw2100_alloc_device()
6091 priv->rts_threshold = DEFAULT_RTS_THRESHOLD | RTS_DISABLED; in ipw2100_alloc_device()
6092 priv->frag_threshold = DEFAULT_FTS | FRAG_DISABLED; in ipw2100_alloc_device()
6093 priv->tx_power = IPW_TX_POWER_DEFAULT; in ipw2100_alloc_device()
6094 priv->tx_rates = DEFAULT_TX_RATES; in ipw2100_alloc_device()
6096 strcpy(priv->nick, "ipw2100"); in ipw2100_alloc_device()
6098 spin_lock_init(&priv->low_lock); in ipw2100_alloc_device()
6099 mutex_init(&priv->action_mutex); in ipw2100_alloc_device()
6100 mutex_init(&priv->adapter_mutex); in ipw2100_alloc_device()
6102 init_waitqueue_head(&priv->wait_command_queue); in ipw2100_alloc_device()
6106 INIT_LIST_HEAD(&priv->msg_free_list); in ipw2100_alloc_device()
6107 INIT_LIST_HEAD(&priv->msg_pend_list); in ipw2100_alloc_device()
6108 INIT_STAT(&priv->msg_free_stat); in ipw2100_alloc_device()
6109 INIT_STAT(&priv->msg_pend_stat); in ipw2100_alloc_device()
6111 INIT_LIST_HEAD(&priv->tx_free_list); in ipw2100_alloc_device()
6112 INIT_LIST_HEAD(&priv->tx_pend_list); in ipw2100_alloc_device()
6113 INIT_STAT(&priv->tx_free_stat); in ipw2100_alloc_device()
6114 INIT_STAT(&priv->tx_pend_stat); in ipw2100_alloc_device()
6116 INIT_LIST_HEAD(&priv->fw_pend_list); in ipw2100_alloc_device()
6117 INIT_STAT(&priv->fw_pend_stat); in ipw2100_alloc_device()
6119 INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter); in ipw2100_alloc_device()
6120 INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work); in ipw2100_alloc_device()
6121 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work); in ipw2100_alloc_device()
6122 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check); in ipw2100_alloc_device()
6123 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill); in ipw2100_alloc_device()
6124 INIT_DELAYED_WORK(&priv->scan_event, ipw2100_scan_event); in ipw2100_alloc_device()
6126 tasklet_setup(&priv->irq_tasklet, ipw2100_irq_tasklet); in ipw2100_alloc_device()
6129 priv->stop_rf_kill = 1; in ipw2100_alloc_device()
6130 priv->stop_hang_check = 1; in ipw2100_alloc_device()
6148 IPW_DEBUG_INFO("weird - resource type is not memory\n"); in ipw2100_pci_init_one()
6149 err = -ENODEV; in ipw2100_pci_init_one()
6157 err = -EIO; in ipw2100_pci_init_one()
6166 err = -ENOMEM; in ipw2100_pci_init_one()
6183 err = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); in ipw2100_pci_init_one()
6200 * PCI Tx retries from interfering with C3 CPU state */ in ipw2100_pci_init_one()
6208 err = -ENODEV; in ipw2100_pci_init_one()
6212 SET_NETDEV_DEV(dev, &pci_dev->dev); in ipw2100_pci_init_one()
6215 priv->status |= STATUS_INT_ENABLED; in ipw2100_pci_init_one()
6218 /* Allocate and initialize the Tx/Rx queues and lists */ in ipw2100_pci_init_one()
6222 err = -ENOMEM; in ipw2100_pci_init_one()
6227 err = request_irq(pci_dev->irq, in ipw2100_pci_init_one()
6228 ipw2100_interrupt, IRQF_SHARED, dev->name, priv); in ipw2100_pci_init_one()
6231 "Error calling request_irq: %d.\n", pci_dev->irq); in ipw2100_pci_init_one()
6234 dev->irq = pci_dev->irq; in ipw2100_pci_init_one()
6263 mutex_lock(&priv->action_mutex); in ipw2100_pci_init_one()
6265 IPW_DEBUG_INFO("%s: Bound to %s\n", dev->name, pci_name(pci_dev)); in ipw2100_pci_init_one()
6267 /* perform this after register_netdev so that dev->name is set */ in ipw2100_pci_init_one()
6268 err = sysfs_create_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); in ipw2100_pci_init_one()
6274 if (!(priv->status & STATUS_RF_KILL_MASK)) { in ipw2100_pci_init_one()
6275 /* Enable the adapter - sends HOST_COMPLETE */ in ipw2100_pci_init_one()
6279 priv->net_dev->name); in ipw2100_pci_init_one()
6281 err = -EIO; in ipw2100_pci_init_one()
6292 priv->status |= STATUS_INITIALIZED; in ipw2100_pci_init_one()
6294 mutex_unlock(&priv->action_mutex); in ipw2100_pci_init_one()
6299 mutex_unlock(&priv->action_mutex); in ipw2100_pci_init_one()
6306 wiphy_unregister(priv->ieee->wdev.wiphy); in ipw2100_pci_init_one()
6307 kfree(priv->ieee->bg_band.channels); in ipw2100_pci_init_one()
6314 if (dev->irq) in ipw2100_pci_init_one()
6315 free_irq(dev->irq, priv); in ipw2100_pci_init_one()
6321 sysfs_remove_group(&pci_dev->dev.kobj, in ipw2100_pci_init_one()
6337 struct net_device *dev = priv->net_dev; in ipw2100_pci_remove_one()
6339 mutex_lock(&priv->action_mutex); in ipw2100_pci_remove_one()
6341 priv->status &= ~STATUS_INITIALIZED; in ipw2100_pci_remove_one()
6343 sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group); in ipw2100_pci_remove_one()
6354 mutex_unlock(&priv->action_mutex); in ipw2100_pci_remove_one()
6356 /* Unregister the device first - this results in close() in ipw2100_pci_remove_one()
6369 free_irq(dev->irq, priv); in ipw2100_pci_remove_one()
6371 pci_iounmap(pci_dev, priv->ioaddr); in ipw2100_pci_remove_one()
6374 wiphy_unregister(priv->ieee->wdev.wiphy); in ipw2100_pci_remove_one()
6375 kfree(priv->ieee->bg_band.channels); in ipw2100_pci_remove_one()
6387 struct net_device *dev = priv->net_dev; in ipw2100_suspend()
6389 IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name); in ipw2100_suspend()
6391 mutex_lock(&priv->action_mutex); in ipw2100_suspend()
6392 if (priv->status & STATUS_INITIALIZED) { in ipw2100_suspend()
6400 priv->suspend_at = ktime_get_boottime_seconds(); in ipw2100_suspend()
6402 mutex_unlock(&priv->action_mutex); in ipw2100_suspend()
6411 struct net_device *dev = priv->net_dev; in ipw2100_resume()
6417 mutex_lock(&priv->action_mutex); in ipw2100_resume()
6419 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name); in ipw2100_resume()
6423 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries in ipw2100_resume()
6435 priv->suspend_time = ktime_get_boottime_seconds() - priv->suspend_at; in ipw2100_resume()
6438 if (!(priv->status & STATUS_RF_KILL_SW)) in ipw2100_resume()
6441 mutex_unlock(&priv->action_mutex); in ipw2100_resume()
6579 if (!(priv->status & STATUS_ASSOCIATED)) in ipw2100_wx_get_name()
6580 strcpy(wrqu->name, "unassociated"); in ipw2100_wx_get_name()
6582 snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); in ipw2100_wx_get_name()
6584 IPW_DEBUG_WX("Name: %s\n", wrqu->name); in ipw2100_wx_get_name()
6593 struct iw_freq *fwrq = &wrqu->freq; in ipw2100_wx_set_freq()
6596 if (priv->ieee->iw_mode == IW_MODE_INFRA) in ipw2100_wx_set_freq()
6597 return -EOPNOTSUPP; in ipw2100_wx_set_freq()
6599 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_freq()
6600 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_freq()
6601 err = -EIO; in ipw2100_wx_set_freq()
6606 if (fwrq->e == 1) { in ipw2100_wx_set_freq()
6607 if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) { in ipw2100_wx_set_freq()
6608 int f = fwrq->m / 100000; in ipw2100_wx_set_freq()
6616 fwrq->e = 0; in ipw2100_wx_set_freq()
6617 fwrq->m = c + 1; in ipw2100_wx_set_freq()
6621 if (fwrq->e > 0 || fwrq->m > 1000) { in ipw2100_wx_set_freq()
6622 err = -EOPNOTSUPP; in ipw2100_wx_set_freq()
6625 IPW_DEBUG_WX("SET Freq/Channel -> %d\n", fwrq->m); in ipw2100_wx_set_freq()
6626 err = ipw2100_set_channel(priv, fwrq->m, 0); in ipw2100_wx_set_freq()
6630 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_freq()
6644 wrqu->freq.e = 0; in ipw2100_wx_get_freq()
6648 if (priv->config & CFG_STATIC_CHANNEL || in ipw2100_wx_get_freq()
6649 priv->status & STATUS_ASSOCIATED) in ipw2100_wx_get_freq()
6650 wrqu->freq.m = priv->channel; in ipw2100_wx_get_freq()
6652 wrqu->freq.m = 0; in ipw2100_wx_get_freq()
6654 IPW_DEBUG_WX("GET Freq/Channel -> %d\n", priv->channel); in ipw2100_wx_get_freq()
6666 IPW_DEBUG_WX("SET Mode -> %d\n", wrqu->mode); in ipw2100_wx_set_mode()
6668 if (wrqu->mode == priv->ieee->iw_mode) in ipw2100_wx_set_mode()
6671 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_mode()
6672 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_mode()
6673 err = -EIO; in ipw2100_wx_set_mode()
6677 switch (wrqu->mode) { in ipw2100_wx_set_mode()
6694 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_mode()
6708 wrqu->mode = priv->ieee->iw_mode; in ipw2100_wx_get_mode()
6709 IPW_DEBUG_WX("GET Mode -> %d\n", wrqu->mode); in ipw2100_wx_get_mode()
6746 wrqu->data.length = sizeof(*range); in ipw2100_wx_get_range()
6758 range->throughput = 5 * 1000 * 1000; in ipw2100_wx_get_range()
6760 // range->sensitivity; /* signal level threshold range */ in ipw2100_wx_get_range()
6762 range->max_qual.qual = 100; in ipw2100_wx_get_range()
6764 range->max_qual.level = 0; in ipw2100_wx_get_range()
6765 range->max_qual.noise = 0; in ipw2100_wx_get_range()
6766 range->max_qual.updated = 7; /* Updated all three */ in ipw2100_wx_get_range()
6768 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */ in ipw2100_wx_get_range()
6770 range->avg_qual.level = 20 + IPW2100_RSSI_TO_DBM; in ipw2100_wx_get_range()
6771 range->avg_qual.noise = 0; in ipw2100_wx_get_range()
6772 range->avg_qual.updated = 7; /* Updated all three */ in ipw2100_wx_get_range()
6774 range->num_bitrates = RATE_COUNT; in ipw2100_wx_get_range()
6777 range->bitrate[i] = ipw2100_bg_rates[i].bitrate * 100 * 1000; in ipw2100_wx_get_range()
6780 range->min_rts = MIN_RTS_THRESHOLD; in ipw2100_wx_get_range()
6781 range->max_rts = MAX_RTS_THRESHOLD; in ipw2100_wx_get_range()
6782 range->min_frag = MIN_FRAG_THRESHOLD; in ipw2100_wx_get_range()
6783 range->max_frag = MAX_FRAG_THRESHOLD; in ipw2100_wx_get_range()
6785 range->min_pmp = period_duration[0]; /* Minimal PM period */ in ipw2100_wx_get_range()
6786 range->max_pmp = period_duration[POWER_MODES - 1]; /* Maximal PM period */ in ipw2100_wx_get_range()
6787 range->min_pmt = timeout_duration[POWER_MODES - 1]; /* Minimal PM timeout */ in ipw2100_wx_get_range()
6788 range->max_pmt = timeout_duration[0]; /* Maximal PM timeout */ in ipw2100_wx_get_range()
6791 range->pmp_flags = IW_POWER_PERIOD; in ipw2100_wx_get_range()
6793 range->pmt_flags = IW_POWER_TIMEOUT; in ipw2100_wx_get_range()
6795 range->pm_capa = IW_POWER_TIMEOUT | IW_POWER_PERIOD; in ipw2100_wx_get_range()
6797 range->encoding_size[0] = 5; in ipw2100_wx_get_range()
6798 range->encoding_size[1] = 13; /* Different token sizes */ in ipw2100_wx_get_range()
6799 range->num_encoding_sizes = 2; /* Number of entry in the list */ in ipw2100_wx_get_range()
6800 range->max_encoding_tokens = WEP_KEYS; /* Max number of tokens */ in ipw2100_wx_get_range()
6801 // range->encoding_login_index; /* token index for login token */ in ipw2100_wx_get_range()
6803 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { in ipw2100_wx_get_range()
6804 range->txpower_capa = IW_TXPOW_DBM; in ipw2100_wx_get_range()
6805 range->num_txpower = IW_MAX_TXPOWER; in ipw2100_wx_get_range()
6808 i++, level -= in ipw2100_wx_get_range()
6809 ((IPW_TX_POWER_MAX_DBM - in ipw2100_wx_get_range()
6810 IPW_TX_POWER_MIN_DBM) * 16) / (IW_MAX_TXPOWER - 1)) in ipw2100_wx_get_range()
6811 range->txpower[i] = level / 16; in ipw2100_wx_get_range()
6813 range->txpower_capa = 0; in ipw2100_wx_get_range()
6814 range->num_txpower = 0; in ipw2100_wx_get_range()
6818 range->we_version_compiled = WIRELESS_EXT; in ipw2100_wx_get_range()
6819 range->we_version_source = 18; in ipw2100_wx_get_range()
6821 // range->retry_capa; /* What retry options are supported */ in ipw2100_wx_get_range()
6822 // range->retry_flags; /* How to decode max/min retry limit */ in ipw2100_wx_get_range()
6823 // range->r_time_flags; /* How to decode max/min retry life */ in ipw2100_wx_get_range()
6824 // range->min_retry; /* Minimal number of retries */ in ipw2100_wx_get_range()
6825 // range->max_retry; /* Maximal number of retries */ in ipw2100_wx_get_range()
6826 // range->min_r_time; /* Minimal retry lifetime */ in ipw2100_wx_get_range()
6827 // range->max_r_time; /* Maximal retry lifetime */ in ipw2100_wx_get_range()
6829 range->num_channels = FREQ_COUNT; in ipw2100_wx_get_range()
6834 // if (local->channel_mask & (1 << i)) { in ipw2100_wx_get_range()
6835 range->freq[val].i = i + 1; in ipw2100_wx_get_range()
6836 range->freq[val].m = ipw2100_frequencies[i] * 100000; in ipw2100_wx_get_range()
6837 range->freq[val].e = 1; in ipw2100_wx_get_range()
6843 range->num_frequency = val; in ipw2100_wx_get_range()
6846 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | in ipw2100_wx_get_range()
6848 range->event_capa[1] = IW_EVENT_CAPA_K_1; in ipw2100_wx_get_range()
6850 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | in ipw2100_wx_get_range()
6866 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) in ipw2100_wx_set_wap()
6867 return -EINVAL; in ipw2100_wx_set_wap()
6869 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_wap()
6870 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_wap()
6871 err = -EIO; in ipw2100_wx_set_wap()
6875 if (is_broadcast_ether_addr(wrqu->ap_addr.sa_data) || in ipw2100_wx_set_wap()
6876 is_zero_ether_addr(wrqu->ap_addr.sa_data)) { in ipw2100_wx_set_wap()
6878 IPW_DEBUG_WX("exit - disable mandatory BSSID\n"); in ipw2100_wx_set_wap()
6879 priv->config &= ~CFG_STATIC_BSSID; in ipw2100_wx_set_wap()
6884 priv->config |= CFG_STATIC_BSSID; in ipw2100_wx_set_wap()
6885 memcpy(priv->mandatory_bssid_mac, wrqu->ap_addr.sa_data, ETH_ALEN); in ipw2100_wx_set_wap()
6887 err = ipw2100_set_mandatory_bssid(priv, wrqu->ap_addr.sa_data, 0); in ipw2100_wx_set_wap()
6889 IPW_DEBUG_WX("SET BSSID -> %pM\n", wrqu->ap_addr.sa_data); in ipw2100_wx_set_wap()
6892 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_wap()
6908 if (priv->config & CFG_STATIC_BSSID || priv->status & STATUS_ASSOCIATED) { in ipw2100_wx_get_wap()
6909 wrqu->ap_addr.sa_family = ARPHRD_ETHER; in ipw2100_wx_get_wap()
6910 memcpy(wrqu->ap_addr.sa_data, priv->bssid, ETH_ALEN); in ipw2100_wx_get_wap()
6912 eth_zero_addr(wrqu->ap_addr.sa_data); in ipw2100_wx_get_wap()
6914 IPW_DEBUG_WX("Getting WAP BSSID: %pM\n", wrqu->ap_addr.sa_data); in ipw2100_wx_get_wap()
6927 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_essid()
6928 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_essid()
6929 err = -EIO; in ipw2100_wx_set_essid()
6933 if (wrqu->essid.flags && wrqu->essid.length) { in ipw2100_wx_set_essid()
6934 length = wrqu->essid.length; in ipw2100_wx_set_essid()
6940 priv->config &= ~CFG_STATIC_ESSID; in ipw2100_wx_set_essid()
6947 priv->config |= CFG_STATIC_ESSID; in ipw2100_wx_set_essid()
6949 if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) { in ipw2100_wx_set_essid()
6957 priv->essid_len = length; in ipw2100_wx_set_essid()
6958 memcpy(priv->essid, essid, priv->essid_len); in ipw2100_wx_set_essid()
6963 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_essid()
6979 if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) { in ipw2100_wx_get_essid()
6981 priv->essid_len, priv->essid); in ipw2100_wx_get_essid()
6982 memcpy(extra, priv->essid, priv->essid_len); in ipw2100_wx_get_essid()
6983 wrqu->essid.length = priv->essid_len; in ipw2100_wx_get_essid()
6984 wrqu->essid.flags = 1; /* active */ in ipw2100_wx_get_essid()
6987 wrqu->essid.length = 0; in ipw2100_wx_get_essid()
6988 wrqu->essid.flags = 0; /* active */ in ipw2100_wx_get_essid()
7004 if (wrqu->data.length > IW_ESSID_MAX_SIZE) in ipw2100_wx_set_nick()
7005 return -E2BIG; in ipw2100_wx_set_nick()
7007 wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick)); in ipw2100_wx_set_nick()
7008 memset(priv->nick, 0, sizeof(priv->nick)); in ipw2100_wx_set_nick()
7009 memcpy(priv->nick, extra, wrqu->data.length); in ipw2100_wx_set_nick()
7011 IPW_DEBUG_WX("SET Nickname -> %s\n", priv->nick); in ipw2100_wx_set_nick()
7026 wrqu->data.length = strlen(priv->nick); in ipw2100_wx_get_nick()
7027 memcpy(extra, priv->nick, wrqu->data.length); in ipw2100_wx_get_nick()
7028 wrqu->data.flags = 1; /* active */ in ipw2100_wx_get_nick()
7030 IPW_DEBUG_WX("GET Nickname -> %s\n", extra); in ipw2100_wx_get_nick()
7040 u32 target_rate = wrqu->bitrate.value; in ipw2100_wx_set_rate()
7044 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_rate()
7045 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_rate()
7046 err = -EIO; in ipw2100_wx_set_rate()
7053 (!wrqu->bitrate.fixed && target_rate > 1000000)) in ipw2100_wx_set_rate()
7056 (!wrqu->bitrate.fixed && target_rate > 2000000)) in ipw2100_wx_set_rate()
7059 (!wrqu->bitrate.fixed && target_rate > 5500000)) in ipw2100_wx_set_rate()
7062 (!wrqu->bitrate.fixed && target_rate > 11000000)) in ipw2100_wx_set_rate()
7069 IPW_DEBUG_WX("SET Rate -> %04X\n", rate); in ipw2100_wx_set_rate()
7071 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_rate()
7084 if (!(priv->status & STATUS_ENABLED) || in ipw2100_wx_get_rate()
7085 priv->status & STATUS_RF_KILL_MASK || in ipw2100_wx_get_rate()
7086 !(priv->status & STATUS_ASSOCIATED)) { in ipw2100_wx_get_rate()
7087 wrqu->bitrate.value = 0; in ipw2100_wx_get_rate()
7091 mutex_lock(&priv->action_mutex); in ipw2100_wx_get_rate()
7092 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_get_rate()
7093 err = -EIO; in ipw2100_wx_get_rate()
7105 wrqu->bitrate.value = 1000000; in ipw2100_wx_get_rate()
7108 wrqu->bitrate.value = 2000000; in ipw2100_wx_get_rate()
7111 wrqu->bitrate.value = 5500000; in ipw2100_wx_get_rate()
7114 wrqu->bitrate.value = 11000000; in ipw2100_wx_get_rate()
7117 wrqu->bitrate.value = 0; in ipw2100_wx_get_rate()
7120 IPW_DEBUG_WX("GET Rate -> %d\n", wrqu->bitrate.value); in ipw2100_wx_get_rate()
7123 mutex_unlock(&priv->action_mutex); in ipw2100_wx_get_rate()
7135 if (wrqu->rts.fixed == 0) in ipw2100_wx_set_rts()
7136 return -EINVAL; in ipw2100_wx_set_rts()
7138 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_rts()
7139 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_rts()
7140 err = -EIO; in ipw2100_wx_set_rts()
7144 if (wrqu->rts.disabled) in ipw2100_wx_set_rts()
7145 value = priv->rts_threshold | RTS_DISABLED; in ipw2100_wx_set_rts()
7147 if (wrqu->rts.value < 1 || wrqu->rts.value > 2304) { in ipw2100_wx_set_rts()
7148 err = -EINVAL; in ipw2100_wx_set_rts()
7151 value = wrqu->rts.value; in ipw2100_wx_set_rts()
7156 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X\n", value); in ipw2100_wx_set_rts()
7158 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_rts()
7172 wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED; in ipw2100_wx_get_rts()
7173 wrqu->rts.fixed = 1; /* no auto select */ in ipw2100_wx_get_rts()
7176 wrqu->rts.disabled = (priv->rts_threshold & RTS_DISABLED) ? 1 : 0; in ipw2100_wx_get_rts()
7178 IPW_DEBUG_WX("GET RTS Threshold -> 0x%08X\n", wrqu->rts.value); in ipw2100_wx_get_rts()
7190 if (ipw_radio_kill_sw(priv, wrqu->txpower.disabled)) in ipw2100_wx_set_txpow()
7191 return -EINPROGRESS; in ipw2100_wx_set_txpow()
7193 if (priv->ieee->iw_mode != IW_MODE_ADHOC) in ipw2100_wx_set_txpow()
7196 if ((wrqu->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in ipw2100_wx_set_txpow()
7197 return -EINVAL; in ipw2100_wx_set_txpow()
7199 if (wrqu->txpower.fixed == 0) in ipw2100_wx_set_txpow()
7202 if (wrqu->txpower.value < IPW_TX_POWER_MIN_DBM || in ipw2100_wx_set_txpow()
7203 wrqu->txpower.value > IPW_TX_POWER_MAX_DBM) in ipw2100_wx_set_txpow()
7204 return -EINVAL; in ipw2100_wx_set_txpow()
7206 value = wrqu->txpower.value; in ipw2100_wx_set_txpow()
7209 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_txpow()
7210 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_txpow()
7211 err = -EIO; in ipw2100_wx_set_txpow()
7217 IPW_DEBUG_WX("SET TX Power -> %d\n", value); in ipw2100_wx_set_txpow()
7220 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_txpow()
7234 wrqu->txpower.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; in ipw2100_wx_get_txpow()
7236 if (priv->tx_power == IPW_TX_POWER_DEFAULT) { in ipw2100_wx_get_txpow()
7237 wrqu->txpower.fixed = 0; in ipw2100_wx_get_txpow()
7238 wrqu->txpower.value = IPW_TX_POWER_MAX_DBM; in ipw2100_wx_get_txpow()
7240 wrqu->txpower.fixed = 1; in ipw2100_wx_get_txpow()
7241 wrqu->txpower.value = priv->tx_power; in ipw2100_wx_get_txpow()
7244 wrqu->txpower.flags = IW_TXPOW_DBM; in ipw2100_wx_get_txpow()
7246 IPW_DEBUG_WX("GET TX Power -> %d\n", wrqu->txpower.value); in ipw2100_wx_get_txpow()
7261 if (!wrqu->frag.fixed) in ipw2100_wx_set_frag()
7262 return -EINVAL; in ipw2100_wx_set_frag()
7264 if (wrqu->frag.disabled) { in ipw2100_wx_set_frag()
7265 priv->frag_threshold |= FRAG_DISABLED; in ipw2100_wx_set_frag()
7266 priv->ieee->fts = DEFAULT_FTS; in ipw2100_wx_set_frag()
7268 if (wrqu->frag.value < MIN_FRAG_THRESHOLD || in ipw2100_wx_set_frag()
7269 wrqu->frag.value > MAX_FRAG_THRESHOLD) in ipw2100_wx_set_frag()
7270 return -EINVAL; in ipw2100_wx_set_frag()
7272 priv->ieee->fts = wrqu->frag.value & ~0x1; in ipw2100_wx_set_frag()
7273 priv->frag_threshold = priv->ieee->fts; in ipw2100_wx_set_frag()
7276 IPW_DEBUG_WX("SET Frag Threshold -> %d\n", priv->ieee->fts); in ipw2100_wx_set_frag()
7290 wrqu->frag.value = priv->frag_threshold & ~FRAG_DISABLED; in ipw2100_wx_get_frag()
7291 wrqu->frag.fixed = 0; /* no auto select */ in ipw2100_wx_get_frag()
7292 wrqu->frag.disabled = (priv->frag_threshold & FRAG_DISABLED) ? 1 : 0; in ipw2100_wx_get_frag()
7294 IPW_DEBUG_WX("GET Frag Threshold -> %d\n", wrqu->frag.value); in ipw2100_wx_get_frag()
7306 if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled) in ipw2100_wx_set_retry()
7307 return -EINVAL; in ipw2100_wx_set_retry()
7309 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) in ipw2100_wx_set_retry()
7312 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_retry()
7313 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_retry()
7314 err = -EIO; in ipw2100_wx_set_retry()
7318 if (wrqu->retry.flags & IW_RETRY_SHORT) { in ipw2100_wx_set_retry()
7319 err = ipw2100_set_short_retry(priv, wrqu->retry.value); in ipw2100_wx_set_retry()
7320 IPW_DEBUG_WX("SET Short Retry Limit -> %d\n", in ipw2100_wx_set_retry()
7321 wrqu->retry.value); in ipw2100_wx_set_retry()
7325 if (wrqu->retry.flags & IW_RETRY_LONG) { in ipw2100_wx_set_retry()
7326 err = ipw2100_set_long_retry(priv, wrqu->retry.value); in ipw2100_wx_set_retry()
7327 IPW_DEBUG_WX("SET Long Retry Limit -> %d\n", in ipw2100_wx_set_retry()
7328 wrqu->retry.value); in ipw2100_wx_set_retry()
7332 err = ipw2100_set_short_retry(priv, wrqu->retry.value); in ipw2100_wx_set_retry()
7334 err = ipw2100_set_long_retry(priv, wrqu->retry.value); in ipw2100_wx_set_retry()
7336 IPW_DEBUG_WX("SET Both Retry Limits -> %d\n", wrqu->retry.value); in ipw2100_wx_set_retry()
7339 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_retry()
7353 wrqu->retry.disabled = 0; /* can't be disabled */ in ipw2100_wx_get_retry()
7355 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) in ipw2100_wx_get_retry()
7356 return -EINVAL; in ipw2100_wx_get_retry()
7358 if (wrqu->retry.flags & IW_RETRY_LONG) { in ipw2100_wx_get_retry()
7359 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in ipw2100_wx_get_retry()
7360 wrqu->retry.value = priv->long_retry_limit; in ipw2100_wx_get_retry()
7362 wrqu->retry.flags = in ipw2100_wx_get_retry()
7363 (priv->short_retry_limit != in ipw2100_wx_get_retry()
7364 priv->long_retry_limit) ? in ipw2100_wx_get_retry()
7367 wrqu->retry.value = priv->short_retry_limit; in ipw2100_wx_get_retry()
7370 IPW_DEBUG_WX("GET Retry -> %d\n", wrqu->retry.value); in ipw2100_wx_get_retry()
7382 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_scan()
7383 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_scan()
7384 err = -EIO; in ipw2100_wx_set_scan()
7390 priv->user_requested_scan = 1; in ipw2100_wx_set_scan()
7399 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_scan()
7412 return libipw_wx_get_scan(priv->ieee, info, wrqu, extra); in ipw2100_wx_get_scan()
7416 * Implementation based on code in hostap-driver v0.1.3 hostap_ioctl.c
7427 return libipw_wx_set_encode(priv->ieee, info, wrqu, key); in ipw2100_wx_set_encode()
7439 return libipw_wx_get_encode(priv->ieee, info, wrqu, key); in ipw2100_wx_get_encode()
7449 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_power()
7450 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_power()
7451 err = -EIO; in ipw2100_wx_set_power()
7455 if (wrqu->power.disabled) { in ipw2100_wx_set_power()
7456 priv->power_mode = IPW_POWER_LEVEL(priv->power_mode); in ipw2100_wx_set_power()
7458 IPW_DEBUG_WX("SET Power Management Mode -> off\n"); in ipw2100_wx_set_power()
7462 switch (wrqu->power.flags & IW_POWER_MODE) { in ipw2100_wx_set_power()
7469 wrqu->power.flags); in ipw2100_wx_set_power()
7470 err = -EOPNOTSUPP; in ipw2100_wx_set_power()
7476 priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; in ipw2100_wx_set_power()
7477 err = ipw2100_set_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); in ipw2100_wx_set_power()
7479 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); in ipw2100_wx_set_power()
7482 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_power()
7497 if (!(priv->power_mode & IPW_POWER_ENABLED)) in ipw2100_wx_get_power()
7498 wrqu->power.disabled = 1; in ipw2100_wx_get_power()
7500 wrqu->power.disabled = 0; in ipw2100_wx_get_power()
7501 wrqu->power.flags = 0; in ipw2100_wx_get_power()
7504 IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode); in ipw2100_wx_get_power()
7510 * WE-18 WPA support
7520 struct libipw_device *ieee = priv->ieee; in ipw2100_wx_set_genie()
7523 if (!ieee->wpa_enabled) in ipw2100_wx_set_genie()
7524 return -EOPNOTSUPP; in ipw2100_wx_set_genie()
7526 if (wrqu->data.length > MAX_WPA_IE_LEN || in ipw2100_wx_set_genie()
7527 (wrqu->data.length && extra == NULL)) in ipw2100_wx_set_genie()
7528 return -EINVAL; in ipw2100_wx_set_genie()
7530 if (wrqu->data.length) { in ipw2100_wx_set_genie()
7531 buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL); in ipw2100_wx_set_genie()
7533 return -ENOMEM; in ipw2100_wx_set_genie()
7535 kfree(ieee->wpa_ie); in ipw2100_wx_set_genie()
7536 ieee->wpa_ie = buf; in ipw2100_wx_set_genie()
7537 ieee->wpa_ie_len = wrqu->data.length; in ipw2100_wx_set_genie()
7539 kfree(ieee->wpa_ie); in ipw2100_wx_set_genie()
7540 ieee->wpa_ie = NULL; in ipw2100_wx_set_genie()
7541 ieee->wpa_ie_len = 0; in ipw2100_wx_set_genie()
7544 ipw2100_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len); in ipw2100_wx_set_genie()
7555 struct libipw_device *ieee = priv->ieee; in ipw2100_wx_get_genie()
7557 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { in ipw2100_wx_get_genie()
7558 wrqu->data.length = 0; in ipw2100_wx_get_genie()
7562 if (wrqu->data.length < ieee->wpa_ie_len) in ipw2100_wx_get_genie()
7563 return -E2BIG; in ipw2100_wx_get_genie()
7565 wrqu->data.length = ieee->wpa_ie_len; in ipw2100_wx_get_genie()
7566 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); in ipw2100_wx_get_genie()
7577 struct libipw_device *ieee = priv->ieee; in ipw2100_wx_set_auth()
7578 struct iw_param *param = &wrqu->param; in ipw2100_wx_set_auth()
7583 switch (param->flags & IW_AUTH_INDEX) { in ipw2100_wx_set_auth()
7594 crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; in ipw2100_wx_set_auth()
7595 if (!crypt || !crypt->ops->set_flags || !crypt->ops->get_flags) in ipw2100_wx_set_auth()
7598 flags = crypt->ops->get_flags(crypt->priv); in ipw2100_wx_set_auth()
7600 if (param->value) in ipw2100_wx_set_auth()
7605 crypt->ops->set_flags(flags, crypt->priv); in ipw2100_wx_set_auth()
7617 * used, drop_unencrypted is set to false, else true -- we in ipw2100_wx_set_auth()
7621 struct libipw_security sec = { in ipw2100_wx_set_auth() local
7623 .enabled = param->value, in ipw2100_wx_set_auth()
7625 priv->ieee->drop_unencrypted = param->value; in ipw2100_wx_set_auth()
7629 if (!param->value) { in ipw2100_wx_set_auth()
7630 sec.flags |= SEC_LEVEL; in ipw2100_wx_set_auth()
7631 sec.level = SEC_LEVEL_0; in ipw2100_wx_set_auth()
7633 sec.flags |= SEC_LEVEL; in ipw2100_wx_set_auth()
7634 sec.level = SEC_LEVEL_1; in ipw2100_wx_set_auth()
7636 if (priv->ieee->set_security) in ipw2100_wx_set_auth()
7637 priv->ieee->set_security(priv->ieee->dev, &sec); in ipw2100_wx_set_auth()
7642 ret = ipw2100_wpa_set_auth_algs(priv, param->value); in ipw2100_wx_set_auth()
7646 ret = ipw2100_wpa_enable(priv, param->value); in ipw2100_wx_set_auth()
7650 ieee->ieee802_1x = param->value; in ipw2100_wx_set_auth()
7655 ieee->privacy_invoked = param->value; in ipw2100_wx_set_auth()
7659 return -EOPNOTSUPP; in ipw2100_wx_set_auth()
7670 struct libipw_device *ieee = priv->ieee; in ipw2100_wx_get_auth()
7672 struct iw_param *param = &wrqu->param; in ipw2100_wx_get_auth()
7674 switch (param->flags & IW_AUTH_INDEX) { in ipw2100_wx_get_auth()
7685 crypt = priv->ieee->crypt_info.crypt[priv->ieee->crypt_info.tx_keyidx]; in ipw2100_wx_get_auth()
7686 if (!crypt || !crypt->ops->get_flags) { in ipw2100_wx_get_auth()
7692 param->value = (crypt->ops->get_flags(crypt->priv) & in ipw2100_wx_get_auth()
7698 param->value = ieee->drop_unencrypted; in ipw2100_wx_get_auth()
7702 param->value = priv->ieee->sec.auth_mode; in ipw2100_wx_get_auth()
7706 param->value = ieee->wpa_enabled; in ipw2100_wx_get_auth()
7710 param->value = ieee->ieee802_1x; in ipw2100_wx_get_auth()
7715 param->value = ieee->privacy_invoked; in ipw2100_wx_get_auth()
7719 return -EOPNOTSUPP; in ipw2100_wx_get_auth()
7730 return libipw_wx_set_encodeext(priv->ieee, info, wrqu, extra); in ipw2100_wx_set_encodeext()
7739 return libipw_wx_get_encodeext(priv->ieee, info, wrqu, extra); in ipw2100_wx_get_encodeext()
7750 switch (mlme->cmd) { in ipw2100_wx_set_mlme()
7760 return -EOPNOTSUPP; in ipw2100_wx_set_mlme()
7780 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_promisc()
7781 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_promisc()
7782 err = -EIO; in ipw2100_wx_set_promisc()
7787 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { in ipw2100_wx_set_promisc()
7791 priv->channel = parms[1]; in ipw2100_wx_set_promisc()
7794 if (priv->ieee->iw_mode == IW_MODE_MONITOR) in ipw2100_wx_set_promisc()
7795 err = ipw2100_switch_mode(priv, priv->last_mode); in ipw2100_wx_set_promisc()
7798 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_promisc()
7807 if (priv->status & STATUS_INITIALIZED) in ipw2100_wx_reset()
7821 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_powermode()
7822 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_powermode()
7823 err = -EIO; in ipw2100_wx_set_powermode()
7830 if (IPW_POWER_LEVEL(priv->power_mode) != mode) in ipw2100_wx_set_powermode()
7833 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_powermode()
7847 int level = IPW_POWER_LEVEL(priv->power_mode); in ipw2100_wx_get_powermode()
7850 if (!(priv->power_mode & IPW_POWER_ENABLED)) { in ipw2100_wx_get_powermode()
7864 timeout = timeout_duration[level - 1] / 1000; in ipw2100_wx_get_powermode()
7865 period = period_duration[level - 1] / 1000; in ipw2100_wx_get_powermode()
7873 wrqu->data.length = strlen(extra) + 1; in ipw2100_wx_get_powermode()
7885 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_preamble()
7886 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_preamble()
7887 err = -EIO; in ipw2100_wx_set_preamble()
7892 priv->config |= CFG_LONG_PREAMBLE; in ipw2100_wx_set_preamble()
7894 priv->config &= ~CFG_LONG_PREAMBLE; in ipw2100_wx_set_preamble()
7896 err = -EINVAL; in ipw2100_wx_set_preamble()
7903 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_preamble()
7917 if (priv->config & CFG_LONG_PREAMBLE) in ipw2100_wx_get_preamble()
7918 snprintf(wrqu->name, IFNAMSIZ, "long (1)"); in ipw2100_wx_get_preamble()
7920 snprintf(wrqu->name, IFNAMSIZ, "auto (0)"); in ipw2100_wx_get_preamble()
7933 mutex_lock(&priv->action_mutex); in ipw2100_wx_set_crc_check()
7934 if (!(priv->status & STATUS_INITIALIZED)) { in ipw2100_wx_set_crc_check()
7935 err = -EIO; in ipw2100_wx_set_crc_check()
7940 priv->config |= CFG_CRC_CHECK; in ipw2100_wx_set_crc_check()
7942 priv->config &= ~CFG_CRC_CHECK; in ipw2100_wx_set_crc_check()
7944 err = -EINVAL; in ipw2100_wx_set_crc_check()
7950 mutex_unlock(&priv->action_mutex); in ipw2100_wx_set_crc_check()
7964 if (priv->config & CFG_CRC_CHECK) in ipw2100_wx_get_crc_check()
7965 snprintf(wrqu->name, IFNAMSIZ, "CRC checked (1)"); in ipw2100_wx_get_crc_check()
7967 snprintf(wrqu->name, IFNAMSIZ, "CRC ignored (0)"); in ipw2100_wx_get_crc_check()
8103 wstats = &priv->wstats; in ipw2100_wx_wireless_stats()
8110 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw2100_wx_wireless_stats()
8111 wstats->miss.beacon = 0; in ipw2100_wx_wireless_stats()
8112 wstats->discard.retries = 0; in ipw2100_wx_wireless_stats()
8113 wstats->qual.qual = 0; in ipw2100_wx_wireless_stats()
8114 wstats->qual.level = 0; in ipw2100_wx_wireless_stats()
8115 wstats->qual.noise = 0; in ipw2100_wx_wireless_stats()
8116 wstats->qual.updated = 7; in ipw2100_wx_wireless_stats()
8117 wstats->qual.updated |= IW_QUAL_NOISE_INVALID | in ipw2100_wx_wireless_stats()
8127 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw2100_wx_wireless_stats()
8128 wstats->qual.qual = 0; in ipw2100_wx_wireless_stats()
8129 wstats->qual.level = 0; in ipw2100_wx_wireless_stats()
8134 wstats->qual.level = rssi + IPW2100_RSSI_TO_DBM; in ipw2100_wx_wireless_stats()
8138 rssi_qual = (rssi - 10) * (FAIR - POOR) / 5 + POOR; in ipw2100_wx_wireless_stats()
8140 rssi_qual = (rssi - 15) * (GOOD - FAIR) / 5 + FAIR; in ipw2100_wx_wireless_stats()
8142 rssi_qual = (rssi - 20) * (VERY_GOOD - GOOD) / in ipw2100_wx_wireless_stats()
8145 rssi_qual = (rssi - 30) * (PERFECT - VERY_GOOD) / in ipw2100_wx_wireless_stats()
8153 tx_qual = (90 - tx_retries) * POOR / 15; in ipw2100_wx_wireless_stats()
8155 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR; in ipw2100_wx_wireless_stats()
8157 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; in ipw2100_wx_wireless_stats()
8159 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / in ipw2100_wx_wireless_stats()
8162 tx_qual = (50 - tx_retries) * in ipw2100_wx_wireless_stats()
8163 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; in ipw2100_wx_wireless_stats()
8166 beacon_qual = (60 - missed_beacons) * POOR / 10; in ipw2100_wx_wireless_stats()
8168 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) / in ipw2100_wx_wireless_stats()
8171 beacon_qual = (40 - missed_beacons) * (GOOD - FAIR) / in ipw2100_wx_wireless_stats()
8174 beacon_qual = (32 - missed_beacons) * in ipw2100_wx_wireless_stats()
8175 (VERY_GOOD - GOOD) / 20 + GOOD; in ipw2100_wx_wireless_stats()
8177 beacon_qual = (20 - missed_beacons) * in ipw2100_wx_wireless_stats()
8178 (PERFECT - VERY_GOOD) / 20 + VERY_GOOD; in ipw2100_wx_wireless_stats()
8187 IPW_DEBUG_WX("Quality clamped by Tx Retries\n"); in ipw2100_wx_wireless_stats()
8194 wstats->qual.qual = quality; in ipw2100_wx_wireless_stats()
8195 wstats->qual.level = rssi + IPW2100_RSSI_TO_DBM; in ipw2100_wx_wireless_stats()
8198 wstats->qual.noise = 0; in ipw2100_wx_wireless_stats()
8199 wstats->qual.updated = 7; in ipw2100_wx_wireless_stats()
8200 wstats->qual.updated |= IW_QUAL_NOISE_INVALID; in ipw2100_wx_wireless_stats()
8203 wstats->miss.beacon = missed_beacons; in ipw2100_wx_wireless_stats()
8208 wstats->discard.retries = tx_failures; in ipw2100_wx_wireless_stats()
8235 if (priv->status & STATUS_STOPPING) in ipw2100_wx_event_work()
8238 mutex_lock(&priv->action_mutex); in ipw2100_wx_event_work()
8242 mutex_unlock(&priv->action_mutex); in ipw2100_wx_event_work()
8247 if (!(priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) || in ipw2100_wx_event_work()
8248 priv->status & STATUS_RF_KILL_MASK || in ipw2100_wx_event_work()
8250 &priv->bssid, &len)) { in ipw2100_wx_event_work()
8255 memcpy(wrqu.ap_addr.sa_data, priv->bssid, ETH_ALEN); in ipw2100_wx_event_work()
8256 memcpy(priv->ieee->bssid, priv->bssid, ETH_ALEN); in ipw2100_wx_event_work()
8257 priv->status &= ~STATUS_ASSOCIATING; in ipw2100_wx_event_work()
8258 priv->status |= STATUS_ASSOCIATED; in ipw2100_wx_event_work()
8259 netif_carrier_on(priv->net_dev); in ipw2100_wx_event_work()
8260 netif_wake_queue(priv->net_dev); in ipw2100_wx_event_work()
8263 if (!(priv->status & STATUS_ASSOCIATED)) { in ipw2100_wx_event_work()
8265 mutex_lock(&priv->action_mutex); in ipw2100_wx_event_work()
8268 if (priv->config & CFG_STATIC_ESSID) in ipw2100_wx_event_work()
8269 ipw2100_set_essid(priv, priv->essid, priv->essid_len, in ipw2100_wx_event_work()
8273 mutex_unlock(&priv->action_mutex); in ipw2100_wx_event_work()
8276 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); in ipw2100_wx_event_work()
8288 #define IPW2100_FW_PREFIX "ipw2100-" __stringify(IPW2100_FW_MAJOR_VERSION) \
8317 (struct ipw2100_fw_header *)fw->fw_entry->data; in ipw2100_mod_firmware_load()
8319 if (IPW2100_FW_MAJOR(h->version) != IPW2100_FW_MAJOR_VERSION) { in ipw2100_mod_firmware_load()
8323 h->version); in ipw2100_mod_firmware_load()
8327 fw->version = h->version; in ipw2100_mod_firmware_load()
8328 fw->fw.data = fw->fw_entry->data + sizeof(struct ipw2100_fw_header); in ipw2100_mod_firmware_load()
8329 fw->fw.size = h->fw_size; in ipw2100_mod_firmware_load()
8330 fw->uc.data = fw->fw.data + h->fw_size; in ipw2100_mod_firmware_load()
8331 fw->uc.size = h->uc_size; in ipw2100_mod_firmware_load()
8343 priv->net_dev->name); in ipw2100_get_firmware()
8345 switch (priv->ieee->iw_mode) { in ipw2100_get_firmware()
8347 fw_name = IPW2100_FW_NAME("-i"); in ipw2100_get_firmware()
8351 fw_name = IPW2100_FW_NAME("-p"); in ipw2100_get_firmware()
8360 rc = request_firmware(&fw->fw_entry, fw_name, &priv->pci_dev->dev); in ipw2100_get_firmware()
8365 priv->net_dev->name, fw_name); in ipw2100_get_firmware()
8368 IPW_DEBUG_INFO("firmware data %p size %zd\n", fw->fw_entry->data, in ipw2100_get_firmware()
8369 fw->fw_entry->size); in ipw2100_get_firmware()
8376 MODULE_FIRMWARE(IPW2100_FW_NAME("-i"));
8378 MODULE_FIRMWARE(IPW2100_FW_NAME("-p"));
8385 fw->version = 0; in ipw2100_release_firmware()
8386 release_firmware(fw->fw_entry); in ipw2100_release_firmware()
8387 fw->fw_entry = NULL; in ipw2100_release_firmware()
8399 return -EIO; in ipw2100_get_fwversion()
8402 len = max - 1; in ipw2100_get_fwversion()
8416 return -EIO; in ipw2100_get_ucodeversion()
8436 const unsigned char *firmware_data = fw->fw.data; in ipw2100_fw_download()
8437 unsigned int firmware_data_left = fw->fw.size; in ipw2100_fw_download()
8442 firmware_data_left -= 4; in ipw2100_fw_download()
8446 firmware_data_left -= 2; in ipw2100_fw_download()
8450 "Invalid firmware run-length of %d bytes\n", in ipw2100_fw_download()
8452 return -EINVAL; in ipw2100_fw_download()
8455 write_nic_memory(priv->net_dev, addr, len, firmware_data); in ipw2100_fw_download()
8457 firmware_data_left -= len; in ipw2100_fw_download()
8483 struct net_device *dev = priv->net_dev; in ipw2100_ucode_download()
8484 const unsigned char *microcode_data = fw->uc.data; in ipw2100_ucode_download()
8485 unsigned int microcode_data_left = fw->uc.size; in ipw2100_ucode_download()
8486 void __iomem *reg = priv->ioaddr; in ipw2100_ucode_download()
8517 microcode_data_left -= 2; in ipw2100_ucode_download()
8549 /* check Symbol is enabled - upped this from 5 as it wasn't always in ipw2100_ucode_download()
8562 dev->name); in ipw2100_ucode_download()
8563 return -EIO; in ipw2100_ucode_download()
8580 ": %s: No response from Symbol - hw not alive\n", in ipw2100_ucode_download()
8581 dev->name); in ipw2100_ucode_download()
8583 return -EIO; in ipw2100_ucode_download()