aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl3945-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c406
1 files changed, 194 insertions, 212 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index b74a56c48d26..3e5bffb6034f 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -352,11 +352,11 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
352 352
353static void iwl3945_unset_hw_params(struct iwl_priv *priv) 353static void iwl3945_unset_hw_params(struct iwl_priv *priv)
354{ 354{
355 if (priv->shared_virt) 355 if (priv->_3945.shared_virt)
356 dma_free_coherent(&priv->pci_dev->dev, 356 dma_free_coherent(&priv->pci_dev->dev,
357 sizeof(struct iwl3945_shared), 357 sizeof(struct iwl3945_shared),
358 priv->shared_virt, 358 priv->_3945.shared_virt,
359 priv->shared_phys); 359 priv->_3945.shared_phys);
360} 360}
361 361
362static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, 362static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
@@ -505,24 +505,15 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
505 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 505 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
506#endif 506#endif
507 507
508 /* drop all non-injected data frame if we are not associated */
509 if (ieee80211_is_data(fc) &&
510 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
511 (!iwl_is_associated(priv) ||
512 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
513 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
514 goto drop_unlock;
515 }
516
517 spin_unlock_irqrestore(&priv->lock, flags); 508 spin_unlock_irqrestore(&priv->lock, flags);
518 509
519 hdr_len = ieee80211_hdrlen(fc); 510 hdr_len = ieee80211_hdrlen(fc);
520 511
521 /* Find (or create) index into station table for destination station */ 512 /* Find index into station table for destination station */
522 if (info->flags & IEEE80211_TX_CTL_INJECTED) 513 if (!info->control.sta)
523 sta_id = priv->hw_params.bcast_sta_id; 514 sta_id = priv->hw_params.bcast_sta_id;
524 else 515 else
525 sta_id = iwl_get_sta_id(priv, hdr); 516 sta_id = iwl_sta_id(info->control.sta);
526 if (sta_id == IWL_INVALID_STATION) { 517 if (sta_id == IWL_INVALID_STATION) {
527 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 518 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
528 hdr->addr1); 519 hdr->addr1);
@@ -607,9 +598,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
607 txq->need_update = 0; 598 txq->need_update = 0;
608 } 599 }
609 600
610 IWL_DEBUG_TX(priv, "sequence nr = 0X%x \n", 601 IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n",
611 le16_to_cpu(out_cmd->hdr.sequence)); 602 le16_to_cpu(out_cmd->hdr.sequence));
612 IWL_DEBUG_TX(priv, "tx_flags = 0X%x \n", le32_to_cpu(tx_cmd->tx_flags)); 603 IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags));
613 iwl_print_hex_dump(priv, IWL_DL_TX, tx_cmd, sizeof(*tx_cmd)); 604 iwl_print_hex_dump(priv, IWL_DL_TX, tx_cmd, sizeof(*tx_cmd));
614 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, 605 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr,
615 ieee80211_hdrlen(fc)); 606 ieee80211_hdrlen(fc));
@@ -754,7 +745,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
754 if (iwl_is_associated(priv)) 745 if (iwl_is_associated(priv))
755 add_time = 746 add_time =
756 iwl3945_usecs_to_beacons( 747 iwl3945_usecs_to_beacons(
757 le64_to_cpu(params->start_time) - priv->last_tsf, 748 le64_to_cpu(params->start_time) - priv->_3945.last_tsf,
758 le16_to_cpu(priv->rxon_timing.beacon_interval)); 749 le16_to_cpu(priv->rxon_timing.beacon_interval));
759 750
760 memset(&spectrum, 0, sizeof(spectrum)); 751 memset(&spectrum, 0, sizeof(spectrum));
@@ -768,7 +759,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
768 759
769 if (iwl_is_associated(priv)) 760 if (iwl_is_associated(priv))
770 spectrum.start_time = 761 spectrum.start_time =
771 iwl3945_add_beacon_time(priv->last_beacon_time, 762 iwl3945_add_beacon_time(priv->_3945.last_beacon_time,
772 add_time, 763 add_time,
773 le16_to_cpu(priv->rxon_timing.beacon_interval)); 764 le16_to_cpu(priv->rxon_timing.beacon_interval));
774 else 765 else
@@ -857,7 +848,6 @@ static void iwl3945_rx_reply_add_sta(struct iwl_priv *priv,
857#endif 848#endif
858 849
859 IWL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); 850 IWL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status);
860 return;
861} 851}
862 852
863static void iwl3945_bg_beacon_update(struct work_struct *work) 853static void iwl3945_bg_beacon_update(struct work_struct *work)
@@ -966,7 +956,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv)
966 * statistics request from the host as well as for the periodic 956 * statistics request from the host as well as for the periodic
967 * statistics notifications (after received beacons) from the uCode. 957 * statistics notifications (after received beacons) from the uCode.
968 */ 958 */
969 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics; 959 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_reply_statistics;
970 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; 960 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics;
971 961
972 iwl_setup_rx_scan_handlers(priv); 962 iwl_setup_rx_scan_handlers(priv);
@@ -1613,9 +1603,6 @@ static int iwl3945_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
1613 return pos; 1603 return pos;
1614} 1604}
1615 1605
1616/* For sanity check only. Actual size is determined by uCode, typ. 512 */
1617#define IWL3945_MAX_EVENT_LOG_SIZE (512)
1618
1619#define DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES (20) 1606#define DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES (20)
1620 1607
1621int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log, 1608int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
@@ -1642,16 +1629,16 @@ int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1642 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); 1629 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
1643 next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); 1630 next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
1644 1631
1645 if (capacity > IWL3945_MAX_EVENT_LOG_SIZE) { 1632 if (capacity > priv->cfg->max_event_log_size) {
1646 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n", 1633 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
1647 capacity, IWL3945_MAX_EVENT_LOG_SIZE); 1634 capacity, priv->cfg->max_event_log_size);
1648 capacity = IWL3945_MAX_EVENT_LOG_SIZE; 1635 capacity = priv->cfg->max_event_log_size;
1649 } 1636 }
1650 1637
1651 if (next_entry > IWL3945_MAX_EVENT_LOG_SIZE) { 1638 if (next_entry > priv->cfg->max_event_log_size) {
1652 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n", 1639 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
1653 next_entry, IWL3945_MAX_EVENT_LOG_SIZE); 1640 next_entry, priv->cfg->max_event_log_size);
1654 next_entry = IWL3945_MAX_EVENT_LOG_SIZE; 1641 next_entry = priv->cfg->max_event_log_size;
1655 } 1642 }
1656 1643
1657 size = num_wraps ? capacity : next_entry; 1644 size = num_wraps ? capacity : next_entry;
@@ -1860,7 +1847,8 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1860static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, 1847static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1861 enum ieee80211_band band, 1848 enum ieee80211_band band,
1862 u8 is_active, u8 n_probes, 1849 u8 is_active, u8 n_probes,
1863 struct iwl3945_scan_channel *scan_ch) 1850 struct iwl3945_scan_channel *scan_ch,
1851 struct ieee80211_vif *vif)
1864{ 1852{
1865 struct ieee80211_channel *chan; 1853 struct ieee80211_channel *chan;
1866 const struct ieee80211_supported_band *sband; 1854 const struct ieee80211_supported_band *sband;
@@ -1874,7 +1862,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1874 return 0; 1862 return 0;
1875 1863
1876 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); 1864 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
1877 passive_dwell = iwl_get_passive_dwell_time(priv, band); 1865 passive_dwell = iwl_get_passive_dwell_time(priv, band, vif);
1878 1866
1879 if (passive_dwell <= active_dwell) 1867 if (passive_dwell <= active_dwell)
1880 passive_dwell = active_dwell + 1; 1868 passive_dwell = active_dwell + 1;
@@ -1947,7 +1935,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1947 added++; 1935 added++;
1948 } 1936 }
1949 1937
1950 IWL_DEBUG_SCAN(priv, "total channels to scan %d \n", added); 1938 IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added);
1951 return added; 1939 return added;
1952} 1940}
1953 1941
@@ -2122,6 +2110,28 @@ static void iwl3945_nic_start(struct iwl_priv *priv)
2122 iwl_write32(priv, CSR_RESET, 0); 2110 iwl_write32(priv, CSR_RESET, 0);
2123} 2111}
2124 2112
2113#define IWL3945_UCODE_GET(item) \
2114static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\
2115{ \
2116 return le32_to_cpu(ucode->u.v1.item); \
2117}
2118
2119static u32 iwl3945_ucode_get_header_size(u32 api_ver)
2120{
2121 return 24;
2122}
2123
2124static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode)
2125{
2126 return (u8 *) ucode->u.v1.data;
2127}
2128
2129IWL3945_UCODE_GET(inst_size);
2130IWL3945_UCODE_GET(data_size);
2131IWL3945_UCODE_GET(init_size);
2132IWL3945_UCODE_GET(init_data_size);
2133IWL3945_UCODE_GET(boot_size);
2134
2125/** 2135/**
2126 * iwl3945_read_ucode - Read uCode images from disk file. 2136 * iwl3945_read_ucode - Read uCode images from disk file.
2127 * 2137 *
@@ -2170,7 +2180,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2170 goto error; 2180 goto error;
2171 2181
2172 /* Make sure that we got at least our header! */ 2182 /* Make sure that we got at least our header! */
2173 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 2183 if (ucode_raw->size < iwl3945_ucode_get_header_size(1)) {
2174 IWL_ERR(priv, "File size way too small!\n"); 2184 IWL_ERR(priv, "File size way too small!\n");
2175 ret = -EINVAL; 2185 ret = -EINVAL;
2176 goto err_release; 2186 goto err_release;
@@ -2181,13 +2191,12 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2181 2191
2182 priv->ucode_ver = le32_to_cpu(ucode->ver); 2192 priv->ucode_ver = le32_to_cpu(ucode->ver);
2183 api_ver = IWL_UCODE_API(priv->ucode_ver); 2193 api_ver = IWL_UCODE_API(priv->ucode_ver);
2184 inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver); 2194 inst_size = iwl3945_ucode_get_inst_size(ucode);
2185 data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver); 2195 data_size = iwl3945_ucode_get_data_size(ucode);
2186 init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver); 2196 init_size = iwl3945_ucode_get_init_size(ucode);
2187 init_data_size = 2197 init_data_size = iwl3945_ucode_get_init_data_size(ucode);
2188 priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver); 2198 boot_size = iwl3945_ucode_get_boot_size(ucode);
2189 boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver); 2199 src = iwl3945_ucode_get_data(ucode);
2190 src = priv->cfg->ops->ucode->get_data(ucode, api_ver);
2191 2200
2192 /* api_ver should match the api version forming part of the 2201 /* api_ver should match the api version forming part of the
2193 * firmware filename ... but we don't check for that and only rely 2202 * firmware filename ... but we don't check for that and only rely
@@ -2236,7 +2245,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
2236 2245
2237 2246
2238 /* Verify size of file vs. image size info in file's header */ 2247 /* Verify size of file vs. image size info in file's header */
2239 if (ucode_raw->size != priv->cfg->ops->ucode->get_header_size(api_ver) + 2248 if (ucode_raw->size != iwl3945_ucode_get_header_size(api_ver) +
2240 inst_size + data_size + init_size + 2249 inst_size + data_size + init_size +
2241 init_data_size + boot_size) { 2250 init_data_size + boot_size) {
2242 2251
@@ -2490,8 +2499,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2490 goto restart; 2499 goto restart;
2491 } 2500 }
2492 2501
2493 iwl_clear_stations_table(priv);
2494
2495 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG); 2502 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG);
2496 IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); 2503 IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill);
2497 2504
@@ -2513,13 +2520,19 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2513 /* After the ALIVE response, we can send commands to 3945 uCode */ 2520 /* After the ALIVE response, we can send commands to 3945 uCode */
2514 set_bit(STATUS_ALIVE, &priv->status); 2521 set_bit(STATUS_ALIVE, &priv->status);
2515 2522
2523 if (priv->cfg->ops->lib->recover_from_tx_stall) {
2524 /* Enable timer to monitor the driver queues */
2525 mod_timer(&priv->monitor_recover,
2526 jiffies +
2527 msecs_to_jiffies(priv->cfg->monitor_recover_period));
2528 }
2529
2516 if (iwl_is_rfkill(priv)) 2530 if (iwl_is_rfkill(priv))
2517 return; 2531 return;
2518 2532
2519 ieee80211_wake_queues(priv->hw); 2533 ieee80211_wake_queues(priv->hw);
2520 2534
2521 priv->active_rate = priv->rates_mask; 2535 priv->active_rate = IWL_RATES_MASK;
2522 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK;
2523 2536
2524 iwl_power_update_mode(priv, true); 2537 iwl_power_update_mode(priv, true);
2525 2538
@@ -2531,11 +2544,11 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2531 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2544 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2532 } else { 2545 } else {
2533 /* Initialize our rx_config data */ 2546 /* Initialize our rx_config data */
2534 iwl_connection_init_rx_config(priv, priv->iw_mode); 2547 iwl_connection_init_rx_config(priv, NULL);
2535 } 2548 }
2536 2549
2537 /* Configure Bluetooth device coexistence support */ 2550 /* Configure Bluetooth device coexistence support */
2538 iwl_send_bt_config(priv); 2551 priv->cfg->ops->hcmd->send_bt_config(priv);
2539 2552
2540 /* Configure the adapter for unassociated operation */ 2553 /* Configure the adapter for unassociated operation */
2541 iwlcore_commit_rxon(priv); 2554 iwlcore_commit_rxon(priv);
@@ -2548,17 +2561,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2548 set_bit(STATUS_READY, &priv->status); 2561 set_bit(STATUS_READY, &priv->status);
2549 wake_up_interruptible(&priv->wait_command_queue); 2562 wake_up_interruptible(&priv->wait_command_queue);
2550 2563
2551 /* reassociate for ADHOC mode */
2552 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
2553 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
2554 priv->vif);
2555 if (beacon)
2556 iwl_mac_beacon_update(priv->hw, beacon);
2557 }
2558
2559 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
2560 iwl_set_mode(priv, priv->iw_mode);
2561
2562 return; 2564 return;
2563 2565
2564 restart: 2566 restart:
@@ -2580,7 +2582,10 @@ static void __iwl3945_down(struct iwl_priv *priv)
2580 if (!exit_pending) 2582 if (!exit_pending)
2581 set_bit(STATUS_EXIT_PENDING, &priv->status); 2583 set_bit(STATUS_EXIT_PENDING, &priv->status);
2582 2584
2583 iwl_clear_stations_table(priv); 2585 /* Station information will now be cleared in device */
2586 iwl_clear_ucode_stations(priv);
2587 iwl_dealloc_bcast_station(priv);
2588 iwl_clear_driver_stations(priv);
2584 2589
2585 /* Unblock any waiting calls */ 2590 /* Unblock any waiting calls */
2586 wake_up_interruptible_all(&priv->wait_command_queue); 2591 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2661,6 +2666,10 @@ static int __iwl3945_up(struct iwl_priv *priv)
2661{ 2666{
2662 int rc, i; 2667 int rc, i;
2663 2668
2669 rc = iwl_alloc_bcast_station(priv, false);
2670 if (rc)
2671 return rc;
2672
2664 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 2673 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2665 IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); 2674 IWL_WARN(priv, "Exit pending; will not bring the NIC up\n");
2666 return -EIO; 2675 return -EIO;
@@ -2714,12 +2723,10 @@ static int __iwl3945_up(struct iwl_priv *priv)
2714 2723
2715 for (i = 0; i < MAX_HW_RESTARTS; i++) { 2724 for (i = 0; i < MAX_HW_RESTARTS; i++) {
2716 2725
2717 iwl_clear_stations_table(priv);
2718
2719 /* load bootstrap state machine, 2726 /* load bootstrap state machine,
2720 * load bootstrap program into processor's memory, 2727 * load bootstrap program into processor's memory,
2721 * prepare to load the "initialize" uCode */ 2728 * prepare to load the "initialize" uCode */
2722 priv->cfg->ops->lib->load_ucode(priv); 2729 rc = priv->cfg->ops->lib->load_ucode(priv);
2723 2730
2724 if (rc) { 2731 if (rc) {
2725 IWL_ERR(priv, 2732 IWL_ERR(priv,
@@ -2787,7 +2794,7 @@ static void iwl3945_bg_alive_start(struct work_struct *data)
2787static void iwl3945_rfkill_poll(struct work_struct *data) 2794static void iwl3945_rfkill_poll(struct work_struct *data)
2788{ 2795{
2789 struct iwl_priv *priv = 2796 struct iwl_priv *priv =
2790 container_of(data, struct iwl_priv, rfkill_poll.work); 2797 container_of(data, struct iwl_priv, _3945.rfkill_poll.work);
2791 bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); 2798 bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status);
2792 bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL) 2799 bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL)
2793 & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); 2800 & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
@@ -2806,22 +2813,18 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2806 2813
2807 /* Keep this running, even if radio now enabled. This will be 2814 /* Keep this running, even if radio now enabled. This will be
2808 * cancelled in mac_start() if system decides to start again */ 2815 * cancelled in mac_start() if system decides to start again */
2809 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 2816 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
2810 round_jiffies_relative(2 * HZ)); 2817 round_jiffies_relative(2 * HZ));
2811 2818
2812} 2819}
2813 2820
2814#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 2821void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2815static void iwl3945_bg_request_scan(struct work_struct *data)
2816{ 2822{
2817 struct iwl_priv *priv =
2818 container_of(data, struct iwl_priv, request_scan);
2819 struct iwl_host_cmd cmd = { 2823 struct iwl_host_cmd cmd = {
2820 .id = REPLY_SCAN_CMD, 2824 .id = REPLY_SCAN_CMD,
2821 .len = sizeof(struct iwl3945_scan_cmd), 2825 .len = sizeof(struct iwl3945_scan_cmd),
2822 .flags = CMD_SIZE_HUGE, 2826 .flags = CMD_SIZE_HUGE,
2823 }; 2827 };
2824 int rc = 0;
2825 struct iwl3945_scan_cmd *scan; 2828 struct iwl3945_scan_cmd *scan;
2826 struct ieee80211_conf *conf = NULL; 2829 struct ieee80211_conf *conf = NULL;
2827 u8 n_probes = 0; 2830 u8 n_probes = 0;
@@ -2830,8 +2833,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2830 2833
2831 conf = ieee80211_get_hw_conf(priv->hw); 2834 conf = ieee80211_get_hw_conf(priv->hw);
2832 2835
2833 mutex_lock(&priv->mutex);
2834
2835 cancel_delayed_work(&priv->scan_check); 2836 cancel_delayed_work(&priv->scan_check);
2836 2837
2837 if (!iwl_is_ready(priv)) { 2838 if (!iwl_is_ready(priv)) {
@@ -2849,7 +2850,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2849 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 2850 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
2850 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests " 2851 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests "
2851 "Ignoring second request.\n"); 2852 "Ignoring second request.\n");
2852 rc = -EIO;
2853 goto done; 2853 goto done;
2854 } 2854 }
2855 2855
@@ -2875,20 +2875,15 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2875 goto done; 2875 goto done;
2876 } 2876 }
2877 2877
2878 if (!priv->scan_bands) { 2878 if (!priv->scan_cmd) {
2879 IWL_DEBUG_HC(priv, "Aborting scan due to no requested bands\n"); 2879 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2880 goto done; 2880 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2881 } 2881 if (!priv->scan_cmd) {
2882 2882 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
2883 if (!priv->scan) {
2884 priv->scan = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2885 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2886 if (!priv->scan) {
2887 rc = -ENOMEM;
2888 goto done; 2883 goto done;
2889 } 2884 }
2890 } 2885 }
2891 scan = priv->scan; 2886 scan = priv->scan_cmd;
2892 memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE); 2887 memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE);
2893 2888
2894 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 2889 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
@@ -2904,7 +2899,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2904 IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); 2899 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
2905 2900
2906 spin_lock_irqsave(&priv->lock, flags); 2901 spin_lock_irqsave(&priv->lock, flags);
2907 interval = priv->beacon_int; 2902 interval = vif ? vif->bss_conf.beacon_int : 0;
2908 spin_unlock_irqrestore(&priv->lock, flags); 2903 spin_unlock_irqrestore(&priv->lock, flags);
2909 2904
2910 scan->suspend_time = 0; 2905 scan->suspend_time = 0;
@@ -2927,7 +2922,9 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2927 scan_suspend_time, interval); 2922 scan_suspend_time, interval);
2928 } 2923 }
2929 2924
2930 if (priv->scan_request->n_ssids) { 2925 if (priv->is_internal_short_scan) {
2926 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
2927 } else if (priv->scan_request->n_ssids) {
2931 int i, p = 0; 2928 int i, p = 0;
2932 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 2929 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
2933 for (i = 0; i < priv->scan_request->n_ssids; i++) { 2930 for (i = 0; i < priv->scan_request->n_ssids; i++) {
@@ -2955,12 +2952,14 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2955 2952
2956 /* flags + rate selection */ 2953 /* flags + rate selection */
2957 2954
2958 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) { 2955 switch (priv->scan_band) {
2956 case IEEE80211_BAND_2GHZ:
2959 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 2957 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
2960 scan->tx_cmd.rate = IWL_RATE_1M_PLCP; 2958 scan->tx_cmd.rate = IWL_RATE_1M_PLCP;
2961 scan->good_CRC_th = 0; 2959 scan->good_CRC_th = 0;
2962 band = IEEE80211_BAND_2GHZ; 2960 band = IEEE80211_BAND_2GHZ;
2963 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { 2961 break;
2962 case IEEE80211_BAND_5GHZ:
2964 scan->tx_cmd.rate = IWL_RATE_6M_PLCP; 2963 scan->tx_cmd.rate = IWL_RATE_6M_PLCP;
2965 /* 2964 /*
2966 * If active scaning is requested but a certain channel 2965 * If active scaning is requested but a certain channel
@@ -2970,27 +2969,32 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2970 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : 2969 scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
2971 IWL_GOOD_CRC_TH_DISABLED; 2970 IWL_GOOD_CRC_TH_DISABLED;
2972 band = IEEE80211_BAND_5GHZ; 2971 band = IEEE80211_BAND_5GHZ;
2973 } else { 2972 break;
2974 IWL_WARN(priv, "Invalid scan band count\n"); 2973 default:
2974 IWL_WARN(priv, "Invalid scan band\n");
2975 goto done; 2975 goto done;
2976 } 2976 }
2977 2977
2978 scan->tx_cmd.len = cpu_to_le16( 2978 if (!priv->is_internal_short_scan) {
2979 scan->tx_cmd.len = cpu_to_le16(
2979 iwl_fill_probe_req(priv, 2980 iwl_fill_probe_req(priv,
2980 (struct ieee80211_mgmt *)scan->data, 2981 (struct ieee80211_mgmt *)scan->data,
2981 priv->scan_request->ie, 2982 priv->scan_request->ie,
2982 priv->scan_request->ie_len, 2983 priv->scan_request->ie_len,
2983 IWL_MAX_SCAN_SIZE - sizeof(*scan))); 2984 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2984 2985 } else {
2986 scan->tx_cmd.len = cpu_to_le16(
2987 iwl_fill_probe_req(priv,
2988 (struct ieee80211_mgmt *)scan->data,
2989 NULL, 0,
2990 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2991 }
2985 /* select Rx antennas */ 2992 /* select Rx antennas */
2986 scan->flags |= iwl3945_get_antenna_flags(priv); 2993 scan->flags |= iwl3945_get_antenna_flags(priv);
2987 2994
2988 if (iwl_is_monitor_mode(priv))
2989 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
2990
2991 scan->channel_count = 2995 scan->channel_count =
2992 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, 2996 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
2993 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 2997 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif);
2994 2998
2995 if (scan->channel_count == 0) { 2999 if (scan->channel_count == 0) {
2996 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 3000 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
@@ -3003,14 +3007,12 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
3003 scan->len = cpu_to_le16(cmd.len); 3007 scan->len = cpu_to_le16(cmd.len);
3004 3008
3005 set_bit(STATUS_SCAN_HW, &priv->status); 3009 set_bit(STATUS_SCAN_HW, &priv->status);
3006 rc = iwl_send_cmd_sync(priv, &cmd); 3010 if (iwl_send_cmd_sync(priv, &cmd))
3007 if (rc)
3008 goto done; 3011 goto done;
3009 3012
3010 queue_delayed_work(priv->workqueue, &priv->scan_check, 3013 queue_delayed_work(priv->workqueue, &priv->scan_check,
3011 IWL_SCAN_CHECK_WATCHDOG); 3014 IWL_SCAN_CHECK_WATCHDOG);
3012 3015
3013 mutex_unlock(&priv->mutex);
3014 return; 3016 return;
3015 3017
3016 done: 3018 done:
@@ -3024,7 +3026,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
3024 3026
3025 /* inform mac80211 scan aborted */ 3027 /* inform mac80211 scan aborted */
3026 queue_work(priv->workqueue, &priv->scan_completed); 3028 queue_work(priv->workqueue, &priv->scan_completed);
3027 mutex_unlock(&priv->mutex);
3028} 3029}
3029 3030
3030static void iwl3945_bg_restart(struct work_struct *data) 3031static void iwl3945_bg_restart(struct work_struct *data)
@@ -3066,28 +3067,25 @@ static void iwl3945_bg_rx_replenish(struct work_struct *data)
3066 mutex_unlock(&priv->mutex); 3067 mutex_unlock(&priv->mutex);
3067} 3068}
3068 3069
3069#define IWL_DELAY_NEXT_SCAN (HZ*2) 3070void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3070
3071void iwl3945_post_associate(struct iwl_priv *priv)
3072{ 3071{
3073 int rc = 0; 3072 int rc = 0;
3074 struct ieee80211_conf *conf = NULL; 3073 struct ieee80211_conf *conf = NULL;
3075 3074
3076 if (priv->iw_mode == NL80211_IFTYPE_AP) { 3075 if (!vif || !priv->is_open)
3076 return;
3077
3078 if (vif->type == NL80211_IFTYPE_AP) {
3077 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__); 3079 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__);
3078 return; 3080 return;
3079 } 3081 }
3080 3082
3081
3082 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", 3083 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
3083 priv->assoc_id, priv->active_rxon.bssid_addr); 3084 vif->bss_conf.aid, priv->active_rxon.bssid_addr);
3084 3085
3085 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3086 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3086 return; 3087 return;
3087 3088
3088 if (!priv->vif || !priv->is_open)
3089 return;
3090
3091 iwl_scan_cancel_timeout(priv, 200); 3089 iwl_scan_cancel_timeout(priv, 200);
3092 3090
3093 conf = ieee80211_get_hw_conf(priv->hw); 3091 conf = ieee80211_get_hw_conf(priv->hw);
@@ -3096,7 +3094,7 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3096 iwlcore_commit_rxon(priv); 3094 iwlcore_commit_rxon(priv);
3097 3095
3098 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3096 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3099 iwl_setup_rxon_timing(priv); 3097 iwl_setup_rxon_timing(priv, vif);
3100 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3098 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3101 sizeof(priv->rxon_timing), &priv->rxon_timing); 3099 sizeof(priv->rxon_timing), &priv->rxon_timing);
3102 if (rc) 3100 if (rc)
@@ -3105,57 +3103,40 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3105 3103
3106 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3104 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
3107 3105
3108 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3106 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid);
3109 3107
3110 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 3108 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
3111 priv->assoc_id, priv->beacon_int); 3109 vif->bss_conf.aid, vif->bss_conf.beacon_int);
3112 3110
3113 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3111 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
3114 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3112 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
3115 else 3113 else
3116 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3114 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
3117 3115
3118 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3116 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
3119 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 3117 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
3120 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 3118 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
3121 else 3119 else
3122 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3120 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3123 3121
3124 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3122 if (vif->type == NL80211_IFTYPE_ADHOC)
3125 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3123 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3126
3127 } 3124 }
3128 3125
3129 iwlcore_commit_rxon(priv); 3126 iwlcore_commit_rxon(priv);
3130 3127
3131 switch (priv->iw_mode) { 3128 switch (vif->type) {
3132 case NL80211_IFTYPE_STATION: 3129 case NL80211_IFTYPE_STATION:
3133 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID); 3130 iwl3945_rate_scale_init(priv->hw, IWL_AP_ID);
3134 break; 3131 break;
3135
3136 case NL80211_IFTYPE_ADHOC: 3132 case NL80211_IFTYPE_ADHOC:
3137
3138 priv->assoc_id = 1;
3139 iwl_add_station(priv, priv->bssid, 0, CMD_SYNC, NULL);
3140 iwl3945_sync_sta(priv, IWL_STA_ID,
3141 (priv->band == IEEE80211_BAND_5GHZ) ?
3142 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP,
3143 CMD_ASYNC);
3144 iwl3945_rate_scale_init(priv->hw, IWL_STA_ID);
3145 iwl3945_send_beacon_cmd(priv); 3133 iwl3945_send_beacon_cmd(priv);
3146
3147 break; 3134 break;
3148
3149 default: 3135 default:
3150 IWL_ERR(priv, "%s Should not be called in %d mode\n", 3136 IWL_ERR(priv, "%s Should not be called in %d mode\n",
3151 __func__, priv->iw_mode); 3137 __func__, vif->type);
3152 break; 3138 break;
3153 } 3139 }
3154
3155 iwl_activate_qos(priv, 0);
3156
3157 /* we have just associated, don't start scan too early */
3158 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
3159} 3140}
3160 3141
3161/***************************************************************************** 3142/*****************************************************************************
@@ -3214,7 +3195,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
3214 3195
3215 /* ucode is running and will send rfkill notifications, 3196 /* ucode is running and will send rfkill notifications,
3216 * no need to poll the killswitch state anymore */ 3197 * no need to poll the killswitch state anymore */
3217 cancel_delayed_work(&priv->rfkill_poll); 3198 cancel_delayed_work(&priv->_3945.rfkill_poll);
3218 3199
3219 iwl_led_start(priv); 3200 iwl_led_start(priv);
3220 3201
@@ -3255,7 +3236,7 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
3255 flush_workqueue(priv->workqueue); 3236 flush_workqueue(priv->workqueue);
3256 3237
3257 /* start polling the killswitch state again */ 3238 /* start polling the killswitch state again */
3258 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 3239 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
3259 round_jiffies_relative(2 * HZ)); 3240 round_jiffies_relative(2 * HZ));
3260 3241
3261 IWL_DEBUG_MAC80211(priv, "leave\n"); 3242 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -3277,7 +3258,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3277 return NETDEV_TX_OK; 3258 return NETDEV_TX_OK;
3278} 3259}
3279 3260
3280void iwl3945_config_ap(struct iwl_priv *priv) 3261void iwl3945_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
3281{ 3262{
3282 int rc = 0; 3263 int rc = 0;
3283 3264
@@ -3293,7 +3274,7 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3293 3274
3294 /* RXON Timing */ 3275 /* RXON Timing */
3295 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3276 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3296 iwl_setup_rxon_timing(priv); 3277 iwl_setup_rxon_timing(priv, vif);
3297 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3278 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3298 sizeof(priv->rxon_timing), 3279 sizeof(priv->rxon_timing),
3299 &priv->rxon_timing); 3280 &priv->rxon_timing);
@@ -3301,9 +3282,10 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3301 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3282 IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
3302 "Attempting to continue.\n"); 3283 "Attempting to continue.\n");
3303 3284
3304 /* FIXME: what should be the assoc_id for AP? */ 3285 priv->staging_rxon.assoc_id = 0;
3305 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3286
3306 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3287 if (vif->bss_conf.assoc_capability &
3288 WLAN_CAPABILITY_SHORT_PREAMBLE)
3307 priv->staging_rxon.flags |= 3289 priv->staging_rxon.flags |=
3308 RXON_FLG_SHORT_PREAMBLE_MSK; 3290 RXON_FLG_SHORT_PREAMBLE_MSK;
3309 else 3291 else
@@ -3311,22 +3293,21 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3311 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3293 ~RXON_FLG_SHORT_PREAMBLE_MSK;
3312 3294
3313 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3295 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
3314 if (priv->assoc_capability & 3296 if (vif->bss_conf.assoc_capability &
3315 WLAN_CAPABILITY_SHORT_SLOT_TIME) 3297 WLAN_CAPABILITY_SHORT_SLOT_TIME)
3316 priv->staging_rxon.flags |= 3298 priv->staging_rxon.flags |=
3317 RXON_FLG_SHORT_SLOT_MSK; 3299 RXON_FLG_SHORT_SLOT_MSK;
3318 else 3300 else
3319 priv->staging_rxon.flags &= 3301 priv->staging_rxon.flags &=
3320 ~RXON_FLG_SHORT_SLOT_MSK; 3302 ~RXON_FLG_SHORT_SLOT_MSK;
3321 3303
3322 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3304 if (vif->type == NL80211_IFTYPE_ADHOC)
3323 priv->staging_rxon.flags &= 3305 priv->staging_rxon.flags &=
3324 ~RXON_FLG_SHORT_SLOT_MSK; 3306 ~RXON_FLG_SHORT_SLOT_MSK;
3325 } 3307 }
3326 /* restore RXON assoc */ 3308 /* restore RXON assoc */
3327 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3309 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
3328 iwlcore_commit_rxon(priv); 3310 iwlcore_commit_rxon(priv);
3329 iwl_add_station(priv, iwl_bcast_addr, 0, CMD_SYNC, NULL);
3330 } 3311 }
3331 iwl3945_send_beacon_cmd(priv); 3312 iwl3945_send_beacon_cmd(priv);
3332 3313
@@ -3341,7 +3322,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3341 struct ieee80211_key_conf *key) 3322 struct ieee80211_key_conf *key)
3342{ 3323{
3343 struct iwl_priv *priv = hw->priv; 3324 struct iwl_priv *priv = hw->priv;
3344 const u8 *addr;
3345 int ret = 0; 3325 int ret = 0;
3346 u8 sta_id = IWL_INVALID_STATION; 3326 u8 sta_id = IWL_INVALID_STATION;
3347 u8 static_key; 3327 u8 static_key;
@@ -3353,21 +3333,24 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3353 return -EOPNOTSUPP; 3333 return -EOPNOTSUPP;
3354 } 3334 }
3355 3335
3356 addr = sta ? sta->addr : iwl_bcast_addr;
3357 static_key = !iwl_is_associated(priv); 3336 static_key = !iwl_is_associated(priv);
3358 3337
3359 if (!static_key) { 3338 if (!static_key) {
3360 sta_id = iwl_find_station(priv, addr); 3339 if (!sta) {
3361 if (sta_id == IWL_INVALID_STATION) { 3340 sta_id = priv->hw_params.bcast_sta_id;
3362 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n", 3341 } else {
3363 addr); 3342 sta_id = iwl_sta_id(sta);
3364 return -EINVAL; 3343 if (sta_id == IWL_INVALID_STATION) {
3344 IWL_DEBUG_MAC80211(priv,
3345 "leave - %pM not in station map.\n",
3346 sta->addr);
3347 return -EINVAL;
3348 }
3365 } 3349 }
3366 } 3350 }
3367 3351
3368 mutex_lock(&priv->mutex); 3352 mutex_lock(&priv->mutex);
3369 iwl_scan_cancel_timeout(priv, 100); 3353 iwl_scan_cancel_timeout(priv, 100);
3370 mutex_unlock(&priv->mutex);
3371 3354
3372 switch (cmd) { 3355 switch (cmd) {
3373 case SET_KEY: 3356 case SET_KEY:
@@ -3388,11 +3371,45 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3388 ret = -EINVAL; 3371 ret = -EINVAL;
3389 } 3372 }
3390 3373
3374 mutex_unlock(&priv->mutex);
3391 IWL_DEBUG_MAC80211(priv, "leave\n"); 3375 IWL_DEBUG_MAC80211(priv, "leave\n");
3392 3376
3393 return ret; 3377 return ret;
3394} 3378}
3395 3379
3380static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3381 struct ieee80211_vif *vif,
3382 struct ieee80211_sta *sta)
3383{
3384 struct iwl_priv *priv = hw->priv;
3385 struct iwl3945_sta_priv *sta_priv = (void *)sta->drv_priv;
3386 int ret;
3387 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3388 u8 sta_id;
3389
3390 sta_priv->common.sta_id = IWL_INVALID_STATION;
3391
3392 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3393 sta->addr);
3394
3395 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap,
3396 &sta_id);
3397 if (ret) {
3398 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3399 sta->addr, ret);
3400 /* Should we return success if return code is EEXIST ? */
3401 return ret;
3402 }
3403
3404 sta_priv->common.sta_id = sta_id;
3405
3406 /* Initialize rate scaling */
3407 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3408 sta->addr);
3409 iwl3945_rs_rate_init(priv, sta, sta_id);
3410
3411 return 0;
3412}
3396/***************************************************************************** 3413/*****************************************************************************
3397 * 3414 *
3398 * sysfs attributes 3415 * sysfs attributes
@@ -3592,7 +3609,7 @@ static ssize_t store_measurement(struct device *d,
3592 struct iwl_priv *priv = dev_get_drvdata(d); 3609 struct iwl_priv *priv = dev_get_drvdata(d);
3593 struct ieee80211_measurement_params params = { 3610 struct ieee80211_measurement_params params = {
3594 .channel = le16_to_cpu(priv->active_rxon.channel), 3611 .channel = le16_to_cpu(priv->active_rxon.channel),
3595 .start_time = cpu_to_le64(priv->last_tsf), 3612 .start_time = cpu_to_le64(priv->_3945.last_tsf),
3596 .duration = cpu_to_le16(1), 3613 .duration = cpu_to_le16(1),
3597 }; 3614 };
3598 u8 type = IWL_MEASURE_BASIC; 3615 u8 type = IWL_MEASURE_BASIC;
@@ -3656,44 +3673,6 @@ static ssize_t show_channels(struct device *d,
3656 3673
3657static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); 3674static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);
3658 3675
3659static ssize_t show_statistics(struct device *d,
3660 struct device_attribute *attr, char *buf)
3661{
3662 struct iwl_priv *priv = dev_get_drvdata(d);
3663 u32 size = sizeof(struct iwl3945_notif_statistics);
3664 u32 len = 0, ofs = 0;
3665 u8 *data = (u8 *)&priv->statistics_39;
3666 int rc = 0;
3667
3668 if (!iwl_is_alive(priv))
3669 return -EAGAIN;
3670
3671 mutex_lock(&priv->mutex);
3672 rc = iwl_send_statistics_request(priv, CMD_SYNC, false);
3673 mutex_unlock(&priv->mutex);
3674
3675 if (rc) {
3676 len = sprintf(buf,
3677 "Error sending statistics request: 0x%08X\n", rc);
3678 return len;
3679 }
3680
3681 while (size && (PAGE_SIZE - len)) {
3682 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
3683 PAGE_SIZE - len, 1);
3684 len = strlen(buf);
3685 if (PAGE_SIZE - len)
3686 buf[len++] = '\n';
3687
3688 ofs += 16;
3689 size -= min(size, 16U);
3690 }
3691
3692 return len;
3693}
3694
3695static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
3696
3697static ssize_t show_antenna(struct device *d, 3676static ssize_t show_antenna(struct device *d,
3698 struct device_attribute *attr, char *buf) 3677 struct device_attribute *attr, char *buf)
3699{ 3678{
@@ -3775,14 +3754,21 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
3775 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); 3754 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update);
3776 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); 3755 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start);
3777 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); 3756 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
3778 INIT_DELAYED_WORK(&priv->rfkill_poll, iwl3945_rfkill_poll); 3757 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll);
3779 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 3758 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
3780 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan);
3781 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 3759 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
3760 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
3782 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 3761 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
3783 3762
3784 iwl3945_hw_setup_deferred_work(priv); 3763 iwl3945_hw_setup_deferred_work(priv);
3785 3764
3765 if (priv->cfg->ops->lib->recover_from_tx_stall) {
3766 init_timer(&priv->monitor_recover);
3767 priv->monitor_recover.data = (unsigned long)priv;
3768 priv->monitor_recover.function =
3769 priv->cfg->ops->lib->recover_from_tx_stall;
3770 }
3771
3786 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 3772 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
3787 iwl3945_irq_tasklet, (unsigned long)priv); 3773 iwl3945_irq_tasklet, (unsigned long)priv);
3788} 3774}
@@ -3794,7 +3780,10 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
3794 cancel_delayed_work_sync(&priv->init_alive_start); 3780 cancel_delayed_work_sync(&priv->init_alive_start);
3795 cancel_delayed_work(&priv->scan_check); 3781 cancel_delayed_work(&priv->scan_check);
3796 cancel_delayed_work(&priv->alive_start); 3782 cancel_delayed_work(&priv->alive_start);
3783 cancel_work_sync(&priv->start_internal_scan);
3797 cancel_work_sync(&priv->beacon_update); 3784 cancel_work_sync(&priv->beacon_update);
3785 if (priv->cfg->ops->lib->recover_from_tx_stall)
3786 del_timer_sync(&priv->monitor_recover);
3798} 3787}
3799 3788
3800static struct attribute *iwl3945_sysfs_entries[] = { 3789static struct attribute *iwl3945_sysfs_entries[] = {
@@ -3805,7 +3794,6 @@ static struct attribute *iwl3945_sysfs_entries[] = {
3805 &dev_attr_filter_flags.attr, 3794 &dev_attr_filter_flags.attr,
3806 &dev_attr_measurement.attr, 3795 &dev_attr_measurement.attr,
3807 &dev_attr_retry_rate.attr, 3796 &dev_attr_retry_rate.attr,
3808 &dev_attr_statistics.attr,
3809 &dev_attr_status.attr, 3797 &dev_attr_status.attr,
3810 &dev_attr_temperature.attr, 3798 &dev_attr_temperature.attr,
3811 &dev_attr_tx_power.attr, 3799 &dev_attr_tx_power.attr,
@@ -3832,7 +3820,9 @@ static struct ieee80211_ops iwl3945_hw_ops = {
3832 .conf_tx = iwl_mac_conf_tx, 3820 .conf_tx = iwl_mac_conf_tx,
3833 .reset_tsf = iwl_mac_reset_tsf, 3821 .reset_tsf = iwl_mac_reset_tsf,
3834 .bss_info_changed = iwl_bss_info_changed, 3822 .bss_info_changed = iwl_bss_info_changed,
3835 .hw_scan = iwl_mac_hw_scan 3823 .hw_scan = iwl_mac_hw_scan,
3824 .sta_add = iwl3945_mac_sta_add,
3825 .sta_remove = iwl_mac_sta_remove,
3836}; 3826};
3837 3827
3838static int iwl3945_init_drv(struct iwl_priv *priv) 3828static int iwl3945_init_drv(struct iwl_priv *priv)
@@ -3851,9 +3841,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3851 mutex_init(&priv->mutex); 3841 mutex_init(&priv->mutex);
3852 mutex_init(&priv->sync_cmd_mutex); 3842 mutex_init(&priv->sync_cmd_mutex);
3853 3843
3854 /* Clear the driver's (not device's) station table */
3855 iwl_clear_stations_table(priv);
3856
3857 priv->ieee_channels = NULL; 3844 priv->ieee_channels = NULL;
3858 priv->ieee_rates = NULL; 3845 priv->ieee_rates = NULL;
3859 priv->band = IEEE80211_BAND_2GHZ; 3846 priv->band = IEEE80211_BAND_2GHZ;
@@ -3861,12 +3848,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3861 priv->iw_mode = NL80211_IFTYPE_STATION; 3848 priv->iw_mode = NL80211_IFTYPE_STATION;
3862 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3849 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3863 3850
3864 iwl_reset_qos(priv);
3865
3866 priv->qos_data.qos_active = 0;
3867 priv->qos_data.qos_cap.val = 0;
3868
3869 priv->rates_mask = IWL_RATES_MASK;
3870 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER; 3851 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
3871 3852
3872 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { 3853 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
@@ -3902,6 +3883,8 @@ err:
3902 return ret; 3883 return ret;
3903} 3884}
3904 3885
3886#define IWL3945_MAX_PROBE_REQUEST 200
3887
3905static int iwl3945_setup_mac(struct iwl_priv *priv) 3888static int iwl3945_setup_mac(struct iwl_priv *priv)
3906{ 3889{
3907 int ret; 3890 int ret;
@@ -3909,10 +3892,10 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3909 3892
3910 hw->rate_control_algorithm = "iwl-3945-rs"; 3893 hw->rate_control_algorithm = "iwl-3945-rs";
3911 hw->sta_data_size = sizeof(struct iwl3945_sta_priv); 3894 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
3895 hw->vif_data_size = sizeof(struct iwl_vif_priv);
3912 3896
3913 /* Tell mac80211 our characteristics */ 3897 /* Tell mac80211 our characteristics */
3914 hw->flags = IEEE80211_HW_SIGNAL_DBM | 3898 hw->flags = IEEE80211_HW_SIGNAL_DBM |
3915 IEEE80211_HW_NOISE_DBM |
3916 IEEE80211_HW_SPECTRUM_MGMT; 3899 IEEE80211_HW_SPECTRUM_MGMT;
3917 3900
3918 if (!priv->cfg->broken_powersave) 3901 if (!priv->cfg->broken_powersave)
@@ -3928,7 +3911,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3928 3911
3929 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; 3912 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
3930 /* we create the 802.11 header and a zero-length SSID element */ 3913 /* we create the 802.11 header and a zero-length SSID element */
3931 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 3914 hw->wiphy->max_scan_ie_len = IWL3945_MAX_PROBE_REQUEST - 24 - 2;
3932 3915
3933 /* Default value; 4 EDCA QOS priorities */ 3916 /* Default value; 4 EDCA QOS priorities */
3934 hw->queues = 4; 3917 hw->queues = 4;
@@ -4131,7 +4114,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4131 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); 4114 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
4132 4115
4133 /* Start monitoring the killswitch */ 4116 /* Start monitoring the killswitch */
4134 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 4117 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
4135 2 * HZ); 4118 2 * HZ);
4136 4119
4137 return 0; 4120 return 0;
@@ -4205,7 +4188,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4205 4188
4206 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 4189 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
4207 4190
4208 cancel_delayed_work_sync(&priv->rfkill_poll); 4191 cancel_delayed_work_sync(&priv->_3945.rfkill_poll);
4209 4192
4210 iwl3945_dealloc_ucode_pci(priv); 4193 iwl3945_dealloc_ucode_pci(priv);
4211 4194
@@ -4214,7 +4197,6 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4214 iwl3945_hw_txq_ctx_free(priv); 4197 iwl3945_hw_txq_ctx_free(priv);
4215 4198
4216 iwl3945_unset_hw_params(priv); 4199 iwl3945_unset_hw_params(priv);
4217 iwl_clear_stations_table(priv);
4218 4200
4219 /*netif_stop_queue(dev); */ 4201 /*netif_stop_queue(dev); */
4220 flush_workqueue(priv->workqueue); 4202 flush_workqueue(priv->workqueue);
@@ -4236,7 +4218,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4236 4218
4237 iwl_free_channel_map(priv); 4219 iwl_free_channel_map(priv);
4238 iwlcore_free_geos(priv); 4220 iwlcore_free_geos(priv);
4239 kfree(priv->scan); 4221 kfree(priv->scan_cmd);
4240 if (priv->ibss_beacon) 4222 if (priv->ibss_beacon)
4241 dev_kfree_skb(priv->ibss_beacon); 4223 dev_kfree_skb(priv->ibss_beacon);
4242 4224