diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl4965-base.c | 881 |
1 files changed, 24 insertions, 857 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index af448197cc05..4183bd5ebe32 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -87,46 +87,6 @@ MODULE_VERSION(DRV_VERSION); | |||
87 | MODULE_AUTHOR(DRV_COPYRIGHT); | 87 | MODULE_AUTHOR(DRV_COPYRIGHT); |
88 | MODULE_LICENSE("GPL"); | 88 | MODULE_LICENSE("GPL"); |
89 | 89 | ||
90 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) | ||
91 | { | ||
92 | /* Single white space is for Linksys APs */ | ||
93 | if (essid_len == 1 && essid[0] == ' ') | ||
94 | return 1; | ||
95 | |||
96 | /* Otherwise, if the entire essid is 0, we assume it is hidden */ | ||
97 | while (essid_len) { | ||
98 | essid_len--; | ||
99 | if (essid[essid_len] != '\0') | ||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | return 1; | ||
104 | } | ||
105 | |||
106 | static const char *iwl4965_escape_essid(const char *essid, u8 essid_len) | ||
107 | { | ||
108 | static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; | ||
109 | const char *s = essid; | ||
110 | char *d = escaped; | ||
111 | |||
112 | if (iwl4965_is_empty_essid(essid, essid_len)) { | ||
113 | memcpy(escaped, "<hidden>", sizeof("<hidden>")); | ||
114 | return escaped; | ||
115 | } | ||
116 | |||
117 | essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); | ||
118 | while (essid_len--) { | ||
119 | if (*s == '\0') { | ||
120 | *d++ = '\\'; | ||
121 | *d++ = '0'; | ||
122 | s++; | ||
123 | } else | ||
124 | *d++ = *s++; | ||
125 | } | ||
126 | *d = '\0'; | ||
127 | return escaped; | ||
128 | } | ||
129 | |||
130 | /*************** STATION TABLE MANAGEMENT **** | 90 | /*************** STATION TABLE MANAGEMENT **** |
131 | * mac80211 should be examined to determine if sta_info is duplicating | 91 | * mac80211 should be examined to determine if sta_info is duplicating |
132 | * the functionality provided here | 92 | * the functionality provided here |
@@ -419,47 +379,6 @@ static int iwl4965_send_bt_config(struct iwl_priv *priv) | |||
419 | sizeof(struct iwl4965_bt_cmd), &bt_cmd); | 379 | sizeof(struct iwl4965_bt_cmd), &bt_cmd); |
420 | } | 380 | } |
421 | 381 | ||
422 | static int iwl4965_send_scan_abort(struct iwl_priv *priv) | ||
423 | { | ||
424 | int ret = 0; | ||
425 | struct iwl_rx_packet *res; | ||
426 | struct iwl_host_cmd cmd = { | ||
427 | .id = REPLY_SCAN_ABORT_CMD, | ||
428 | .meta.flags = CMD_WANT_SKB, | ||
429 | }; | ||
430 | |||
431 | /* If there isn't a scan actively going on in the hardware | ||
432 | * then we are in between scan bands and not actually | ||
433 | * actively scanning, so don't send the abort command */ | ||
434 | if (!test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
435 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | ret = iwl_send_cmd_sync(priv, &cmd); | ||
440 | if (ret) { | ||
441 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
442 | return ret; | ||
443 | } | ||
444 | |||
445 | res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; | ||
446 | if (res->u.status != CAN_ABORT_STATUS) { | ||
447 | /* The scan abort will return 1 for success or | ||
448 | * 2 for "failure". A failure condition can be | ||
449 | * due to simply not being in an active scan which | ||
450 | * can occur if we send the scan abort before we | ||
451 | * the microcode has notified us that a scan is | ||
452 | * completed. */ | ||
453 | IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status); | ||
454 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
455 | clear_bit(STATUS_SCAN_HW, &priv->status); | ||
456 | } | ||
457 | |||
458 | dev_kfree_skb_any(cmd.meta.u.skb); | ||
459 | |||
460 | return ret; | ||
461 | } | ||
462 | |||
463 | /* | 382 | /* |
464 | * CARD_STATE_CMD | 383 | * CARD_STATE_CMD |
465 | * | 384 | * |
@@ -605,35 +524,6 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) | |||
605 | * | 524 | * |
606 | ******************************************************************************/ | 525 | ******************************************************************************/ |
607 | 526 | ||
608 | /** | ||
609 | * iwl4965_supported_rate_to_ie - fill in the supported rate in IE field | ||
610 | * | ||
611 | * return : set the bit for each supported rate insert in ie | ||
612 | */ | ||
613 | static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate, | ||
614 | u16 basic_rate, int *left) | ||
615 | { | ||
616 | u16 ret_rates = 0, bit; | ||
617 | int i; | ||
618 | u8 *cnt = ie; | ||
619 | u8 *rates = ie + 1; | ||
620 | |||
621 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { | ||
622 | if (bit & supported_rate) { | ||
623 | ret_rates |= bit; | ||
624 | rates[*cnt] = iwl_rates[i].ieee | | ||
625 | ((bit & basic_rate) ? 0x80 : 0x00); | ||
626 | (*cnt)++; | ||
627 | (*left)--; | ||
628 | if ((*left <= 0) || | ||
629 | (*cnt >= IWL_SUPPORTED_RATES_IE_LEN)) | ||
630 | break; | ||
631 | } | ||
632 | } | ||
633 | |||
634 | return ret_rates; | ||
635 | } | ||
636 | |||
637 | static void iwl4965_ht_conf(struct iwl_priv *priv, | 527 | static void iwl4965_ht_conf(struct iwl_priv *priv, |
638 | struct ieee80211_bss_conf *bss_conf) | 528 | struct ieee80211_bss_conf *bss_conf) |
639 | { | 529 | { |
@@ -686,140 +576,6 @@ static void iwl4965_ht_conf(struct iwl_priv *priv, | |||
686 | IWL_DEBUG_MAC80211("leave\n"); | 576 | IWL_DEBUG_MAC80211("leave\n"); |
687 | } | 577 | } |
688 | 578 | ||
689 | static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband, | ||
690 | u8 *pos, int *left) | ||
691 | { | ||
692 | struct ieee80211_ht_cap *ht_cap; | ||
693 | |||
694 | if (!sband || !sband->ht_info.ht_supported) | ||
695 | return; | ||
696 | |||
697 | if (*left < sizeof(struct ieee80211_ht_cap)) | ||
698 | return; | ||
699 | |||
700 | *pos++ = sizeof(struct ieee80211_ht_cap); | ||
701 | ht_cap = (struct ieee80211_ht_cap *) pos; | ||
702 | |||
703 | ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap); | ||
704 | memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16); | ||
705 | ht_cap->ampdu_params_info = | ||
706 | (sband->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) | | ||
707 | ((sband->ht_info.ampdu_density << 2) & | ||
708 | IEEE80211_HT_CAP_AMPDU_DENSITY); | ||
709 | *left -= sizeof(struct ieee80211_ht_cap); | ||
710 | } | ||
711 | |||
712 | /** | ||
713 | * iwl4965_fill_probe_req - fill in all required fields and IE for probe request | ||
714 | */ | ||
715 | static u16 iwl4965_fill_probe_req(struct iwl_priv *priv, | ||
716 | enum ieee80211_band band, | ||
717 | struct ieee80211_mgmt *frame, | ||
718 | int left, int is_direct) | ||
719 | { | ||
720 | int len = 0; | ||
721 | u8 *pos = NULL; | ||
722 | u16 active_rates, ret_rates, cck_rates, active_rate_basic; | ||
723 | const struct ieee80211_supported_band *sband = | ||
724 | iwl_get_hw_mode(priv, band); | ||
725 | |||
726 | /* Make sure there is enough space for the probe request, | ||
727 | * two mandatory IEs and the data */ | ||
728 | left -= 24; | ||
729 | if (left < 0) | ||
730 | return 0; | ||
731 | len += 24; | ||
732 | |||
733 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); | ||
734 | memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); | ||
735 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); | ||
736 | memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); | ||
737 | frame->seq_ctrl = 0; | ||
738 | |||
739 | /* fill in our indirect SSID IE */ | ||
740 | /* ...next IE... */ | ||
741 | |||
742 | left -= 2; | ||
743 | if (left < 0) | ||
744 | return 0; | ||
745 | len += 2; | ||
746 | pos = &(frame->u.probe_req.variable[0]); | ||
747 | *pos++ = WLAN_EID_SSID; | ||
748 | *pos++ = 0; | ||
749 | |||
750 | /* fill in our direct SSID IE... */ | ||
751 | if (is_direct) { | ||
752 | /* ...next IE... */ | ||
753 | left -= 2 + priv->essid_len; | ||
754 | if (left < 0) | ||
755 | return 0; | ||
756 | /* ... fill it in... */ | ||
757 | *pos++ = WLAN_EID_SSID; | ||
758 | *pos++ = priv->essid_len; | ||
759 | memcpy(pos, priv->essid, priv->essid_len); | ||
760 | pos += priv->essid_len; | ||
761 | len += 2 + priv->essid_len; | ||
762 | } | ||
763 | |||
764 | /* fill in supported rate */ | ||
765 | /* ...next IE... */ | ||
766 | left -= 2; | ||
767 | if (left < 0) | ||
768 | return 0; | ||
769 | |||
770 | /* ... fill it in... */ | ||
771 | *pos++ = WLAN_EID_SUPP_RATES; | ||
772 | *pos = 0; | ||
773 | |||
774 | /* exclude 60M rate */ | ||
775 | active_rates = priv->rates_mask; | ||
776 | active_rates &= ~IWL_RATE_60M_MASK; | ||
777 | |||
778 | active_rate_basic = active_rates & IWL_BASIC_RATES_MASK; | ||
779 | |||
780 | cck_rates = IWL_CCK_RATES_MASK & active_rates; | ||
781 | ret_rates = iwl4965_supported_rate_to_ie(pos, cck_rates, | ||
782 | active_rate_basic, &left); | ||
783 | active_rates &= ~ret_rates; | ||
784 | |||
785 | ret_rates = iwl4965_supported_rate_to_ie(pos, active_rates, | ||
786 | active_rate_basic, &left); | ||
787 | active_rates &= ~ret_rates; | ||
788 | |||
789 | len += 2 + *pos; | ||
790 | pos += (*pos) + 1; | ||
791 | if (active_rates == 0) | ||
792 | goto fill_end; | ||
793 | |||
794 | /* fill in supported extended rate */ | ||
795 | /* ...next IE... */ | ||
796 | left -= 2; | ||
797 | if (left < 0) | ||
798 | return 0; | ||
799 | /* ... fill it in... */ | ||
800 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
801 | *pos = 0; | ||
802 | iwl4965_supported_rate_to_ie(pos, active_rates, | ||
803 | active_rate_basic, &left); | ||
804 | if (*pos > 0) | ||
805 | len += 2 + *pos; | ||
806 | |||
807 | fill_end: | ||
808 | /* fill in HT IE */ | ||
809 | left -= 2; | ||
810 | if (left < 0) | ||
811 | return 0; | ||
812 | |||
813 | *pos++ = WLAN_EID_HT_CAPABILITY; | ||
814 | *pos = 0; | ||
815 | |||
816 | iwl_ht_cap_to_ie(sband, pos, &left); | ||
817 | |||
818 | if (*pos > 0) | ||
819 | len += 2 + *pos; | ||
820 | return (u16)len; | ||
821 | } | ||
822 | |||
823 | /* | 579 | /* |
824 | * QoS support | 580 | * QoS support |
825 | */ | 581 | */ |
@@ -897,60 +653,6 @@ int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *heade | |||
897 | return 1; | 653 | return 1; |
898 | } | 654 | } |
899 | 655 | ||
900 | |||
901 | |||
902 | /** | ||
903 | * iwl4965_scan_cancel - Cancel any currently executing HW scan | ||
904 | * | ||
905 | * NOTE: priv->mutex is not required before calling this function | ||
906 | */ | ||
907 | static int iwl4965_scan_cancel(struct iwl_priv *priv) | ||
908 | { | ||
909 | if (!test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
910 | clear_bit(STATUS_SCANNING, &priv->status); | ||
911 | return 0; | ||
912 | } | ||
913 | |||
914 | if (test_bit(STATUS_SCANNING, &priv->status)) { | ||
915 | if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
916 | IWL_DEBUG_SCAN("Queuing scan abort.\n"); | ||
917 | set_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
918 | queue_work(priv->workqueue, &priv->abort_scan); | ||
919 | |||
920 | } else | ||
921 | IWL_DEBUG_SCAN("Scan abort already in progress.\n"); | ||
922 | |||
923 | return test_bit(STATUS_SCANNING, &priv->status); | ||
924 | } | ||
925 | |||
926 | return 0; | ||
927 | } | ||
928 | |||
929 | /** | ||
930 | * iwl4965_scan_cancel_timeout - Cancel any currently executing HW scan | ||
931 | * @ms: amount of time to wait (in milliseconds) for scan to abort | ||
932 | * | ||
933 | * NOTE: priv->mutex must be held before calling this function | ||
934 | */ | ||
935 | static int iwl4965_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) | ||
936 | { | ||
937 | unsigned long now = jiffies; | ||
938 | int ret; | ||
939 | |||
940 | ret = iwl4965_scan_cancel(priv); | ||
941 | if (ret && ms) { | ||
942 | mutex_unlock(&priv->mutex); | ||
943 | while (!time_after(jiffies, now + msecs_to_jiffies(ms)) && | ||
944 | test_bit(STATUS_SCANNING, &priv->status)) | ||
945 | msleep(1); | ||
946 | mutex_lock(&priv->mutex); | ||
947 | |||
948 | return test_bit(STATUS_SCANNING, &priv->status); | ||
949 | } | ||
950 | |||
951 | return ret; | ||
952 | } | ||
953 | |||
954 | static void iwl4965_sequence_reset(struct iwl_priv *priv) | 656 | static void iwl4965_sequence_reset(struct iwl_priv *priv) |
955 | { | 657 | { |
956 | /* Reset ieee stats */ | 658 | /* Reset ieee stats */ |
@@ -962,7 +664,7 @@ static void iwl4965_sequence_reset(struct iwl_priv *priv) | |||
962 | priv->last_frag_num = -1; | 664 | priv->last_frag_num = -1; |
963 | priv->last_packet_time = 0; | 665 | priv->last_packet_time = 0; |
964 | 666 | ||
965 | iwl4965_scan_cancel(priv); | 667 | iwl_scan_cancel(priv); |
966 | } | 668 | } |
967 | 669 | ||
968 | #define MAX_UCODE_BEACON_INTERVAL 4096 | 670 | #define MAX_UCODE_BEACON_INTERVAL 4096 |
@@ -1037,41 +739,6 @@ static void iwl4965_setup_rxon_timing(struct iwl_priv *priv) | |||
1037 | le16_to_cpu(priv->rxon_timing.atim_window)); | 739 | le16_to_cpu(priv->rxon_timing.atim_window)); |
1038 | } | 740 | } |
1039 | 741 | ||
1040 | static int iwl4965_scan_initiate(struct iwl_priv *priv) | ||
1041 | { | ||
1042 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { | ||
1043 | IWL_ERROR("APs don't scan.\n"); | ||
1044 | return 0; | ||
1045 | } | ||
1046 | |||
1047 | if (!iwl_is_ready_rf(priv)) { | ||
1048 | IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); | ||
1049 | return -EIO; | ||
1050 | } | ||
1051 | |||
1052 | if (test_bit(STATUS_SCANNING, &priv->status)) { | ||
1053 | IWL_DEBUG_SCAN("Scan already in progress.\n"); | ||
1054 | return -EAGAIN; | ||
1055 | } | ||
1056 | |||
1057 | if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
1058 | IWL_DEBUG_SCAN("Scan request while abort pending. " | ||
1059 | "Queuing.\n"); | ||
1060 | return -EAGAIN; | ||
1061 | } | ||
1062 | |||
1063 | IWL_DEBUG_INFO("Starting scan...\n"); | ||
1064 | priv->scan_bands = 2; | ||
1065 | set_bit(STATUS_SCANNING, &priv->status); | ||
1066 | priv->scan_start = jiffies; | ||
1067 | priv->scan_pass_start = priv->scan_start; | ||
1068 | |||
1069 | queue_work(priv->workqueue, &priv->request_scan); | ||
1070 | |||
1071 | return 0; | ||
1072 | } | ||
1073 | |||
1074 | |||
1075 | static void iwl_set_flags_for_band(struct iwl_priv *priv, | 742 | static void iwl_set_flags_for_band(struct iwl_priv *priv, |
1076 | enum ieee80211_band band) | 743 | enum ieee80211_band band) |
1077 | { | 744 | { |
@@ -1191,7 +858,7 @@ static int iwl4965_set_mode(struct iwl_priv *priv, int mode) | |||
1191 | return -EAGAIN; | 858 | return -EAGAIN; |
1192 | 859 | ||
1193 | cancel_delayed_work(&priv->scan_check); | 860 | cancel_delayed_work(&priv->scan_check); |
1194 | if (iwl4965_scan_cancel_timeout(priv, 100)) { | 861 | if (iwl_scan_cancel_timeout(priv, 100)) { |
1195 | IWL_WARNING("Aborted scan still in progress after 100ms\n"); | 862 | IWL_WARNING("Aborted scan still in progress after 100ms\n"); |
1196 | IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); | 863 | IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); |
1197 | return -EAGAIN; | 864 | return -EAGAIN; |
@@ -1260,7 +927,7 @@ int iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio) | |||
1260 | disable_radio ? "OFF" : "ON"); | 927 | disable_radio ? "OFF" : "ON"); |
1261 | 928 | ||
1262 | if (disable_radio) { | 929 | if (disable_radio) { |
1263 | iwl4965_scan_cancel(priv); | 930 | iwl_scan_cancel(priv); |
1264 | /* FIXME: This is a workaround for AP */ | 931 | /* FIXME: This is a workaround for AP */ |
1265 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | 932 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { |
1266 | spin_lock_irqsave(&priv->lock, flags); | 933 | spin_lock_irqsave(&priv->lock, flags); |
@@ -1680,118 +1347,6 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, | |||
1680 | queue_work(priv->workqueue, &priv->beacon_update); | 1347 | queue_work(priv->workqueue, &priv->beacon_update); |
1681 | } | 1348 | } |
1682 | 1349 | ||
1683 | /* Service response to REPLY_SCAN_CMD (0x80) */ | ||
1684 | static void iwl4965_rx_reply_scan(struct iwl_priv *priv, | ||
1685 | struct iwl_rx_mem_buffer *rxb) | ||
1686 | { | ||
1687 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
1688 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1689 | struct iwl4965_scanreq_notification *notif = | ||
1690 | (struct iwl4965_scanreq_notification *)pkt->u.raw; | ||
1691 | |||
1692 | IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status); | ||
1693 | #endif | ||
1694 | } | ||
1695 | |||
1696 | /* Service SCAN_START_NOTIFICATION (0x82) */ | ||
1697 | static void iwl4965_rx_scan_start_notif(struct iwl_priv *priv, | ||
1698 | struct iwl_rx_mem_buffer *rxb) | ||
1699 | { | ||
1700 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1701 | struct iwl4965_scanstart_notification *notif = | ||
1702 | (struct iwl4965_scanstart_notification *)pkt->u.raw; | ||
1703 | priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); | ||
1704 | IWL_DEBUG_SCAN("Scan start: " | ||
1705 | "%d [802.11%s] " | ||
1706 | "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", | ||
1707 | notif->channel, | ||
1708 | notif->band ? "bg" : "a", | ||
1709 | notif->tsf_high, | ||
1710 | notif->tsf_low, notif->status, notif->beacon_timer); | ||
1711 | } | ||
1712 | |||
1713 | /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ | ||
1714 | static void iwl4965_rx_scan_results_notif(struct iwl_priv *priv, | ||
1715 | struct iwl_rx_mem_buffer *rxb) | ||
1716 | { | ||
1717 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1718 | struct iwl4965_scanresults_notification *notif = | ||
1719 | (struct iwl4965_scanresults_notification *)pkt->u.raw; | ||
1720 | |||
1721 | IWL_DEBUG_SCAN("Scan ch.res: " | ||
1722 | "%d [802.11%s] " | ||
1723 | "(TSF: 0x%08X:%08X) - %d " | ||
1724 | "elapsed=%lu usec (%dms since last)\n", | ||
1725 | notif->channel, | ||
1726 | notif->band ? "bg" : "a", | ||
1727 | le32_to_cpu(notif->tsf_high), | ||
1728 | le32_to_cpu(notif->tsf_low), | ||
1729 | le32_to_cpu(notif->statistics[0]), | ||
1730 | le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, | ||
1731 | jiffies_to_msecs(elapsed_jiffies | ||
1732 | (priv->last_scan_jiffies, jiffies))); | ||
1733 | |||
1734 | priv->last_scan_jiffies = jiffies; | ||
1735 | priv->next_scan_jiffies = 0; | ||
1736 | } | ||
1737 | |||
1738 | /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ | ||
1739 | static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, | ||
1740 | struct iwl_rx_mem_buffer *rxb) | ||
1741 | { | ||
1742 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1743 | struct iwl4965_scancomplete_notification *scan_notif = (void *)pkt->u.raw; | ||
1744 | |||
1745 | IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", | ||
1746 | scan_notif->scanned_channels, | ||
1747 | scan_notif->tsf_low, | ||
1748 | scan_notif->tsf_high, scan_notif->status); | ||
1749 | |||
1750 | /* The HW is no longer scanning */ | ||
1751 | clear_bit(STATUS_SCAN_HW, &priv->status); | ||
1752 | |||
1753 | /* The scan completion notification came in, so kill that timer... */ | ||
1754 | cancel_delayed_work(&priv->scan_check); | ||
1755 | |||
1756 | IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", | ||
1757 | (priv->scan_bands == 2) ? "2.4" : "5.2", | ||
1758 | jiffies_to_msecs(elapsed_jiffies | ||
1759 | (priv->scan_pass_start, jiffies))); | ||
1760 | |||
1761 | /* Remove this scanned band from the list | ||
1762 | * of pending bands to scan */ | ||
1763 | priv->scan_bands--; | ||
1764 | |||
1765 | /* If a request to abort was given, or the scan did not succeed | ||
1766 | * then we reset the scan state machine and terminate, | ||
1767 | * re-queuing another scan if one has been requested */ | ||
1768 | if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
1769 | IWL_DEBUG_INFO("Aborted scan completed.\n"); | ||
1770 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
1771 | } else { | ||
1772 | /* If there are more bands on this scan pass reschedule */ | ||
1773 | if (priv->scan_bands > 0) | ||
1774 | goto reschedule; | ||
1775 | } | ||
1776 | |||
1777 | priv->last_scan_jiffies = jiffies; | ||
1778 | priv->next_scan_jiffies = 0; | ||
1779 | IWL_DEBUG_INFO("Setting scan to off\n"); | ||
1780 | |||
1781 | clear_bit(STATUS_SCANNING, &priv->status); | ||
1782 | |||
1783 | IWL_DEBUG_INFO("Scan took %dms\n", | ||
1784 | jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); | ||
1785 | |||
1786 | queue_work(priv->workqueue, &priv->scan_completed); | ||
1787 | |||
1788 | return; | ||
1789 | |||
1790 | reschedule: | ||
1791 | priv->scan_pass_start = jiffies; | ||
1792 | queue_work(priv->workqueue, &priv->request_scan); | ||
1793 | } | ||
1794 | |||
1795 | /* Handle notification from uCode that card's power state is changing | 1350 | /* Handle notification from uCode that card's power state is changing |
1796 | * due to software, hardware, or critical temperature RFKILL */ | 1351 | * due to software, hardware, or critical temperature RFKILL */ |
1797 | static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | 1352 | static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, |
@@ -1852,7 +1407,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | |||
1852 | clear_bit(STATUS_RF_KILL_SW, &priv->status); | 1407 | clear_bit(STATUS_RF_KILL_SW, &priv->status); |
1853 | 1408 | ||
1854 | if (!(flags & RXON_CARD_DISABLED)) | 1409 | if (!(flags & RXON_CARD_DISABLED)) |
1855 | iwl4965_scan_cancel(priv); | 1410 | iwl_scan_cancel(priv); |
1856 | 1411 | ||
1857 | if ((test_bit(STATUS_RF_KILL_HW, &status) != | 1412 | if ((test_bit(STATUS_RF_KILL_HW, &status) != |
1858 | test_bit(STATUS_RF_KILL_HW, &priv->status)) || | 1413 | test_bit(STATUS_RF_KILL_HW, &priv->status)) || |
@@ -1902,13 +1457,9 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | |||
1902 | */ | 1457 | */ |
1903 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; | 1458 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; |
1904 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; | 1459 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; |
1905 | /* scan handlers */ | 1460 | |
1906 | priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; | 1461 | iwl_setup_rx_scan_handlers(priv); |
1907 | priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; | 1462 | |
1908 | priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = | ||
1909 | iwl4965_rx_scan_results_notif; | ||
1910 | priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = | ||
1911 | iwl4965_rx_scan_complete_notif; | ||
1912 | /* status change handler */ | 1463 | /* status change handler */ |
1913 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; | 1464 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; |
1914 | 1465 | ||
@@ -2456,138 +2007,6 @@ static irqreturn_t iwl4965_isr(int irq, void *data) | |||
2456 | return IRQ_NONE; | 2007 | return IRQ_NONE; |
2457 | } | 2008 | } |
2458 | 2009 | ||
2459 | /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after | ||
2460 | * sending probe req. This should be set long enough to hear probe responses | ||
2461 | * from more than one AP. */ | ||
2462 | #define IWL_ACTIVE_DWELL_TIME_24 (20) /* all times in msec */ | ||
2463 | #define IWL_ACTIVE_DWELL_TIME_52 (10) | ||
2464 | |||
2465 | /* For faster active scanning, scan will move to the next channel if fewer than | ||
2466 | * PLCP_QUIET_THRESH packets are heard on this channel within | ||
2467 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | ||
2468 | * time if it's a quiet channel (nothing responded to our probe, and there's | ||
2469 | * no other traffic). | ||
2470 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ | ||
2471 | #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ | ||
2472 | #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(5) /* msec */ | ||
2473 | |||
2474 | /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. | ||
2475 | * Must be set longer than active dwell time. | ||
2476 | * For the most reliable scan, set > AP beacon interval (typically 100msec). */ | ||
2477 | #define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ | ||
2478 | #define IWL_PASSIVE_DWELL_TIME_52 (10) | ||
2479 | #define IWL_PASSIVE_DWELL_BASE (100) | ||
2480 | #define IWL_CHANNEL_TUNE_TIME 5 | ||
2481 | |||
2482 | static inline u16 iwl4965_get_active_dwell_time(struct iwl_priv *priv, | ||
2483 | enum ieee80211_band band) | ||
2484 | { | ||
2485 | if (band == IEEE80211_BAND_5GHZ) | ||
2486 | return IWL_ACTIVE_DWELL_TIME_52; | ||
2487 | else | ||
2488 | return IWL_ACTIVE_DWELL_TIME_24; | ||
2489 | } | ||
2490 | |||
2491 | static u16 iwl4965_get_passive_dwell_time(struct iwl_priv *priv, | ||
2492 | enum ieee80211_band band) | ||
2493 | { | ||
2494 | u16 active = iwl4965_get_active_dwell_time(priv, band); | ||
2495 | u16 passive = (band != IEEE80211_BAND_5GHZ) ? | ||
2496 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : | ||
2497 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; | ||
2498 | |||
2499 | if (iwl_is_associated(priv)) { | ||
2500 | /* If we're associated, we clamp the maximum passive | ||
2501 | * dwell time to be 98% of the beacon interval (minus | ||
2502 | * 2 * channel tune time) */ | ||
2503 | passive = priv->beacon_int; | ||
2504 | if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) | ||
2505 | passive = IWL_PASSIVE_DWELL_BASE; | ||
2506 | passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; | ||
2507 | } | ||
2508 | |||
2509 | if (passive <= active) | ||
2510 | passive = active + 1; | ||
2511 | |||
2512 | return passive; | ||
2513 | } | ||
2514 | |||
2515 | static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, | ||
2516 | enum ieee80211_band band, | ||
2517 | u8 is_active, u8 direct_mask, | ||
2518 | struct iwl4965_scan_channel *scan_ch) | ||
2519 | { | ||
2520 | const struct ieee80211_channel *channels = NULL; | ||
2521 | const struct ieee80211_supported_band *sband; | ||
2522 | const struct iwl_channel_info *ch_info; | ||
2523 | u16 passive_dwell = 0; | ||
2524 | u16 active_dwell = 0; | ||
2525 | int added, i; | ||
2526 | |||
2527 | sband = iwl_get_hw_mode(priv, band); | ||
2528 | if (!sband) | ||
2529 | return 0; | ||
2530 | |||
2531 | channels = sband->channels; | ||
2532 | |||
2533 | active_dwell = iwl4965_get_active_dwell_time(priv, band); | ||
2534 | passive_dwell = iwl4965_get_passive_dwell_time(priv, band); | ||
2535 | |||
2536 | for (i = 0, added = 0; i < sband->n_channels; i++) { | ||
2537 | if (channels[i].flags & IEEE80211_CHAN_DISABLED) | ||
2538 | continue; | ||
2539 | |||
2540 | scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); | ||
2541 | |||
2542 | ch_info = iwl_get_channel_info(priv, band, | ||
2543 | scan_ch->channel); | ||
2544 | if (!is_channel_valid(ch_info)) { | ||
2545 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", | ||
2546 | scan_ch->channel); | ||
2547 | continue; | ||
2548 | } | ||
2549 | |||
2550 | if (!is_active || is_channel_passive(ch_info) || | ||
2551 | (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) | ||
2552 | scan_ch->type = 0; /* passive */ | ||
2553 | else | ||
2554 | scan_ch->type = 1; /* active */ | ||
2555 | |||
2556 | if (scan_ch->type & 1) | ||
2557 | scan_ch->type |= (direct_mask << 1); | ||
2558 | |||
2559 | scan_ch->active_dwell = cpu_to_le16(active_dwell); | ||
2560 | scan_ch->passive_dwell = cpu_to_le16(passive_dwell); | ||
2561 | |||
2562 | /* Set txpower levels to defaults */ | ||
2563 | scan_ch->tpc.dsp_atten = 110; | ||
2564 | /* scan_pwr_info->tpc.dsp_atten; */ | ||
2565 | |||
2566 | /*scan_pwr_info->tpc.tx_gain; */ | ||
2567 | if (band == IEEE80211_BAND_5GHZ) | ||
2568 | scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; | ||
2569 | else { | ||
2570 | scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); | ||
2571 | /* NOTE: if we were doing 6Mb OFDM for scans we'd use | ||
2572 | * power level: | ||
2573 | * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; | ||
2574 | */ | ||
2575 | } | ||
2576 | |||
2577 | IWL_DEBUG_SCAN("Scanning %d [%s %d]\n", | ||
2578 | scan_ch->channel, | ||
2579 | (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", | ||
2580 | (scan_ch->type & 1) ? | ||
2581 | active_dwell : passive_dwell); | ||
2582 | |||
2583 | scan_ch++; | ||
2584 | added++; | ||
2585 | } | ||
2586 | |||
2587 | IWL_DEBUG_SCAN("total channels to scan %d \n", added); | ||
2588 | return added; | ||
2589 | } | ||
2590 | |||
2591 | /****************************************************************************** | 2010 | /****************************************************************************** |
2592 | * | 2011 | * |
2593 | * uCode download functions | 2012 | * uCode download functions |
@@ -3200,243 +2619,6 @@ static void iwl4965_bg_set_monitor(struct work_struct *work) | |||
3200 | mutex_unlock(&priv->mutex); | 2619 | mutex_unlock(&priv->mutex); |
3201 | } | 2620 | } |
3202 | 2621 | ||
3203 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) | ||
3204 | |||
3205 | static void iwl4965_bg_scan_check(struct work_struct *data) | ||
3206 | { | ||
3207 | struct iwl_priv *priv = | ||
3208 | container_of(data, struct iwl_priv, scan_check.work); | ||
3209 | |||
3210 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | ||
3211 | return; | ||
3212 | |||
3213 | mutex_lock(&priv->mutex); | ||
3214 | if (test_bit(STATUS_SCANNING, &priv->status) || | ||
3215 | test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
3216 | IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting " | ||
3217 | "adapter (%dms)\n", | ||
3218 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | ||
3219 | |||
3220 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | ||
3221 | iwl4965_send_scan_abort(priv); | ||
3222 | } | ||
3223 | mutex_unlock(&priv->mutex); | ||
3224 | } | ||
3225 | |||
3226 | static void iwl4965_bg_request_scan(struct work_struct *data) | ||
3227 | { | ||
3228 | struct iwl_priv *priv = | ||
3229 | container_of(data, struct iwl_priv, request_scan); | ||
3230 | struct iwl_host_cmd cmd = { | ||
3231 | .id = REPLY_SCAN_CMD, | ||
3232 | .len = sizeof(struct iwl4965_scan_cmd), | ||
3233 | .meta.flags = CMD_SIZE_HUGE, | ||
3234 | }; | ||
3235 | struct iwl4965_scan_cmd *scan; | ||
3236 | struct ieee80211_conf *conf = NULL; | ||
3237 | u16 cmd_len; | ||
3238 | enum ieee80211_band band; | ||
3239 | u8 direct_mask; | ||
3240 | int ret = 0; | ||
3241 | |||
3242 | conf = ieee80211_get_hw_conf(priv->hw); | ||
3243 | |||
3244 | mutex_lock(&priv->mutex); | ||
3245 | |||
3246 | if (!iwl_is_ready(priv)) { | ||
3247 | IWL_WARNING("request scan called when driver not ready.\n"); | ||
3248 | goto done; | ||
3249 | } | ||
3250 | |||
3251 | /* Make sure the scan wasn't cancelled before this queued work | ||
3252 | * was given the chance to run... */ | ||
3253 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
3254 | goto done; | ||
3255 | |||
3256 | /* This should never be called or scheduled if there is currently | ||
3257 | * a scan active in the hardware. */ | ||
3258 | if (test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
3259 | IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " | ||
3260 | "Ignoring second request.\n"); | ||
3261 | ret = -EIO; | ||
3262 | goto done; | ||
3263 | } | ||
3264 | |||
3265 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { | ||
3266 | IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n"); | ||
3267 | goto done; | ||
3268 | } | ||
3269 | |||
3270 | if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
3271 | IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n"); | ||
3272 | goto done; | ||
3273 | } | ||
3274 | |||
3275 | if (iwl_is_rfkill(priv)) { | ||
3276 | IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n"); | ||
3277 | goto done; | ||
3278 | } | ||
3279 | |||
3280 | if (!test_bit(STATUS_READY, &priv->status)) { | ||
3281 | IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n"); | ||
3282 | goto done; | ||
3283 | } | ||
3284 | |||
3285 | if (!priv->scan_bands) { | ||
3286 | IWL_DEBUG_HC("Aborting scan due to no requested bands\n"); | ||
3287 | goto done; | ||
3288 | } | ||
3289 | |||
3290 | if (!priv->scan) { | ||
3291 | priv->scan = kmalloc(sizeof(struct iwl4965_scan_cmd) + | ||
3292 | IWL_MAX_SCAN_SIZE, GFP_KERNEL); | ||
3293 | if (!priv->scan) { | ||
3294 | ret = -ENOMEM; | ||
3295 | goto done; | ||
3296 | } | ||
3297 | } | ||
3298 | scan = priv->scan; | ||
3299 | memset(scan, 0, sizeof(struct iwl4965_scan_cmd) + IWL_MAX_SCAN_SIZE); | ||
3300 | |||
3301 | scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; | ||
3302 | scan->quiet_time = IWL_ACTIVE_QUIET_TIME; | ||
3303 | |||
3304 | if (iwl_is_associated(priv)) { | ||
3305 | u16 interval = 0; | ||
3306 | u32 extra; | ||
3307 | u32 suspend_time = 100; | ||
3308 | u32 scan_suspend_time = 100; | ||
3309 | unsigned long flags; | ||
3310 | |||
3311 | IWL_DEBUG_INFO("Scanning while associated...\n"); | ||
3312 | |||
3313 | spin_lock_irqsave(&priv->lock, flags); | ||
3314 | interval = priv->beacon_int; | ||
3315 | spin_unlock_irqrestore(&priv->lock, flags); | ||
3316 | |||
3317 | scan->suspend_time = 0; | ||
3318 | scan->max_out_time = cpu_to_le32(200 * 1024); | ||
3319 | if (!interval) | ||
3320 | interval = suspend_time; | ||
3321 | |||
3322 | extra = (suspend_time / interval) << 22; | ||
3323 | scan_suspend_time = (extra | | ||
3324 | ((suspend_time % interval) * 1024)); | ||
3325 | scan->suspend_time = cpu_to_le32(scan_suspend_time); | ||
3326 | IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n", | ||
3327 | scan_suspend_time, interval); | ||
3328 | } | ||
3329 | |||
3330 | /* We should add the ability for user to lock to PASSIVE ONLY */ | ||
3331 | if (priv->one_direct_scan) { | ||
3332 | IWL_DEBUG_SCAN | ||
3333 | ("Kicking off one direct scan for '%s'\n", | ||
3334 | iwl4965_escape_essid(priv->direct_ssid, | ||
3335 | priv->direct_ssid_len)); | ||
3336 | scan->direct_scan[0].id = WLAN_EID_SSID; | ||
3337 | scan->direct_scan[0].len = priv->direct_ssid_len; | ||
3338 | memcpy(scan->direct_scan[0].ssid, | ||
3339 | priv->direct_ssid, priv->direct_ssid_len); | ||
3340 | direct_mask = 1; | ||
3341 | } else if (!iwl_is_associated(priv) && priv->essid_len) { | ||
3342 | IWL_DEBUG_SCAN | ||
3343 | ("Kicking off one direct scan for '%s' when not associated\n", | ||
3344 | iwl4965_escape_essid(priv->essid, priv->essid_len)); | ||
3345 | scan->direct_scan[0].id = WLAN_EID_SSID; | ||
3346 | scan->direct_scan[0].len = priv->essid_len; | ||
3347 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | ||
3348 | direct_mask = 1; | ||
3349 | } else { | ||
3350 | IWL_DEBUG_SCAN("Kicking off one indirect scan.\n"); | ||
3351 | direct_mask = 0; | ||
3352 | } | ||
3353 | |||
3354 | scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; | ||
3355 | scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; | ||
3356 | scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | ||
3357 | |||
3358 | |||
3359 | switch (priv->scan_bands) { | ||
3360 | case 2: | ||
3361 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; | ||
3362 | scan->tx_cmd.rate_n_flags = | ||
3363 | iwl4965_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, | ||
3364 | RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); | ||
3365 | |||
3366 | scan->good_CRC_th = 0; | ||
3367 | band = IEEE80211_BAND_2GHZ; | ||
3368 | break; | ||
3369 | |||
3370 | case 1: | ||
3371 | scan->tx_cmd.rate_n_flags = | ||
3372 | iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, | ||
3373 | RATE_MCS_ANT_B_MSK); | ||
3374 | scan->good_CRC_th = IWL_GOOD_CRC_TH; | ||
3375 | band = IEEE80211_BAND_5GHZ; | ||
3376 | break; | ||
3377 | |||
3378 | default: | ||
3379 | IWL_WARNING("Invalid scan band count\n"); | ||
3380 | goto done; | ||
3381 | } | ||
3382 | |||
3383 | /* We don't build a direct scan probe request; the uCode will do | ||
3384 | * that based on the direct_mask added to each channel entry */ | ||
3385 | cmd_len = iwl4965_fill_probe_req(priv, band, | ||
3386 | (struct ieee80211_mgmt *)scan->data, | ||
3387 | IWL_MAX_SCAN_SIZE - sizeof(*scan), 0); | ||
3388 | |||
3389 | scan->tx_cmd.len = cpu_to_le16(cmd_len); | ||
3390 | /* select Rx chains */ | ||
3391 | |||
3392 | /* Force use of chains B and C (0x6) for scan Rx. | ||
3393 | * Avoid A (0x1) because of its off-channel reception on A-band. | ||
3394 | * MIMO is not used here, but value is required to make uCode happy. */ | ||
3395 | scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK | | ||
3396 | cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) | | ||
3397 | (0x6 << RXON_RX_CHAIN_FORCE_SEL_POS) | | ||
3398 | (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS)); | ||
3399 | |||
3400 | if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) | ||
3401 | scan->filter_flags = RXON_FILTER_PROMISC_MSK; | ||
3402 | |||
3403 | if (direct_mask) | ||
3404 | scan->channel_count = | ||
3405 | iwl4965_get_channels_for_scan( | ||
3406 | priv, band, 1, /* active */ | ||
3407 | direct_mask, | ||
3408 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); | ||
3409 | else | ||
3410 | scan->channel_count = | ||
3411 | iwl4965_get_channels_for_scan( | ||
3412 | priv, band, 0, /* passive */ | ||
3413 | direct_mask, | ||
3414 | (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); | ||
3415 | |||
3416 | scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | | ||
3417 | RXON_FILTER_BCON_AWARE_MSK); | ||
3418 | cmd.len += le16_to_cpu(scan->tx_cmd.len) + | ||
3419 | scan->channel_count * sizeof(struct iwl4965_scan_channel); | ||
3420 | cmd.data = scan; | ||
3421 | scan->len = cpu_to_le16(cmd.len); | ||
3422 | |||
3423 | set_bit(STATUS_SCAN_HW, &priv->status); | ||
3424 | ret = iwl_send_cmd_sync(priv, &cmd); | ||
3425 | if (ret) | ||
3426 | goto done; | ||
3427 | |||
3428 | queue_delayed_work(priv->workqueue, &priv->scan_check, | ||
3429 | IWL_SCAN_CHECK_WATCHDOG); | ||
3430 | |||
3431 | mutex_unlock(&priv->mutex); | ||
3432 | return; | ||
3433 | |||
3434 | done: | ||
3435 | /* inform mac80211 scan aborted */ | ||
3436 | queue_work(priv->workqueue, &priv->scan_completed); | ||
3437 | mutex_unlock(&priv->mutex); | ||
3438 | } | ||
3439 | |||
3440 | static void iwl_bg_run_time_calib_work(struct work_struct *work) | 2622 | static void iwl_bg_run_time_calib_work(struct work_struct *work) |
3441 | { | 2623 | { |
3442 | struct iwl_priv *priv = container_of(work, struct iwl_priv, | 2624 | struct iwl_priv *priv = container_of(work, struct iwl_priv, |
@@ -3521,7 +2703,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv) | |||
3521 | if (!priv->vif || !priv->is_open) | 2703 | if (!priv->vif || !priv->is_open) |
3522 | return; | 2704 | return; |
3523 | 2705 | ||
3524 | iwl4965_scan_cancel_timeout(priv, 200); | 2706 | iwl_scan_cancel_timeout(priv, 200); |
3525 | 2707 | ||
3526 | conf = ieee80211_get_hw_conf(priv->hw); | 2708 | conf = ieee80211_get_hw_conf(priv->hw); |
3527 | 2709 | ||
@@ -3615,24 +2797,9 @@ static void iwl4965_bg_post_associate(struct work_struct *data) | |||
3615 | 2797 | ||
3616 | } | 2798 | } |
3617 | 2799 | ||
3618 | static void iwl4965_bg_abort_scan(struct work_struct *work) | ||
3619 | { | ||
3620 | struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); | ||
3621 | |||
3622 | if (!iwl_is_ready(priv)) | ||
3623 | return; | ||
3624 | |||
3625 | mutex_lock(&priv->mutex); | ||
3626 | |||
3627 | set_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
3628 | iwl4965_send_scan_abort(priv); | ||
3629 | |||
3630 | mutex_unlock(&priv->mutex); | ||
3631 | } | ||
3632 | |||
3633 | static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); | 2800 | static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); |
3634 | 2801 | ||
3635 | static void iwl4965_bg_scan_completed(struct work_struct *work) | 2802 | static void iwl_bg_scan_completed(struct work_struct *work) |
3636 | { | 2803 | { |
3637 | struct iwl_priv *priv = | 2804 | struct iwl_priv *priv = |
3638 | container_of(work, struct iwl_priv, scan_completed); | 2805 | container_of(work, struct iwl_priv, scan_completed); |
@@ -3759,7 +2926,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw) | |||
3759 | * RXON_FILTER_ASSOC_MSK BIT | 2926 | * RXON_FILTER_ASSOC_MSK BIT |
3760 | */ | 2927 | */ |
3761 | mutex_lock(&priv->mutex); | 2928 | mutex_lock(&priv->mutex); |
3762 | iwl4965_scan_cancel_timeout(priv, 100); | 2929 | iwl_scan_cancel_timeout(priv, 100); |
3763 | cancel_delayed_work(&priv->post_associate); | 2930 | cancel_delayed_work(&priv->post_associate); |
3764 | mutex_unlock(&priv->mutex); | 2931 | mutex_unlock(&priv->mutex); |
3765 | } | 2932 | } |
@@ -4071,7 +3238,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, | |||
4071 | !is_multicast_ether_addr(conf->bssid)) { | 3238 | !is_multicast_ether_addr(conf->bssid)) { |
4072 | /* If there is currently a HW scan going on in the background | 3239 | /* If there is currently a HW scan going on in the background |
4073 | * then we need to cancel it else the RXON below will fail. */ | 3240 | * then we need to cancel it else the RXON below will fail. */ |
4074 | if (iwl4965_scan_cancel_timeout(priv, 100)) { | 3241 | if (iwl_scan_cancel_timeout(priv, 100)) { |
4075 | IWL_WARNING("Aborted scan still in progress " | 3242 | IWL_WARNING("Aborted scan still in progress " |
4076 | "after 100ms\n"); | 3243 | "after 100ms\n"); |
4077 | IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); | 3244 | IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); |
@@ -4096,7 +3263,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, | |||
4096 | } | 3263 | } |
4097 | 3264 | ||
4098 | } else { | 3265 | } else { |
4099 | iwl4965_scan_cancel_timeout(priv, 100); | 3266 | iwl_scan_cancel_timeout(priv, 100); |
4100 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 3267 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
4101 | iwl4965_commit_rxon(priv); | 3268 | iwl4965_commit_rxon(priv); |
4102 | } | 3269 | } |
@@ -4154,7 +3321,7 @@ static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw, | |||
4154 | mutex_lock(&priv->mutex); | 3321 | mutex_lock(&priv->mutex); |
4155 | 3322 | ||
4156 | if (iwl_is_ready_rf(priv)) { | 3323 | if (iwl_is_ready_rf(priv)) { |
4157 | iwl4965_scan_cancel_timeout(priv, 100); | 3324 | iwl_scan_cancel_timeout(priv, 100); |
4158 | cancel_delayed_work(&priv->post_associate); | 3325 | cancel_delayed_work(&priv->post_associate); |
4159 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 3326 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
4160 | iwl4965_commit_rxon(priv); | 3327 | iwl4965_commit_rxon(priv); |
@@ -4268,7 +3435,7 @@ static int iwl4965_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
4268 | } | 3435 | } |
4269 | if (len) { | 3436 | if (len) { |
4270 | IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", | 3437 | IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", |
4271 | iwl4965_escape_essid(ssid, len), (int)len); | 3438 | iwl_escape_essid(ssid, len), (int)len); |
4272 | 3439 | ||
4273 | priv->one_direct_scan = 1; | 3440 | priv->one_direct_scan = 1; |
4274 | priv->direct_ssid_len = (u8) | 3441 | priv->direct_ssid_len = (u8) |
@@ -4277,7 +3444,7 @@ static int iwl4965_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
4277 | } else | 3444 | } else |
4278 | priv->one_direct_scan = 0; | 3445 | priv->one_direct_scan = 0; |
4279 | 3446 | ||
4280 | rc = iwl4965_scan_initiate(priv); | 3447 | rc = iwl_scan_initiate(priv); |
4281 | 3448 | ||
4282 | IWL_DEBUG_MAC80211("leave\n"); | 3449 | IWL_DEBUG_MAC80211("leave\n"); |
4283 | 3450 | ||
@@ -4308,7 +3475,7 @@ static void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, | |||
4308 | return; | 3475 | return; |
4309 | } | 3476 | } |
4310 | 3477 | ||
4311 | iwl4965_scan_cancel_timeout(priv, 100); | 3478 | iwl_scan_cancel_timeout(priv, 100); |
4312 | 3479 | ||
4313 | key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); | 3480 | key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); |
4314 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); | 3481 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); |
@@ -4366,7 +3533,7 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
4366 | } | 3533 | } |
4367 | 3534 | ||
4368 | mutex_lock(&priv->mutex); | 3535 | mutex_lock(&priv->mutex); |
4369 | iwl4965_scan_cancel_timeout(priv, 100); | 3536 | iwl_scan_cancel_timeout(priv, 100); |
4370 | mutex_unlock(&priv->mutex); | 3537 | mutex_unlock(&priv->mutex); |
4371 | 3538 | ||
4372 | /* If we are getting WEP group key and we didn't receive any key mapping | 3539 | /* If we are getting WEP group key and we didn't receive any key mapping |
@@ -4562,7 +3729,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw) | |||
4562 | * clear RXON_FILTER_ASSOC_MSK bit | 3729 | * clear RXON_FILTER_ASSOC_MSK bit |
4563 | */ | 3730 | */ |
4564 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { | 3731 | if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { |
4565 | iwl4965_scan_cancel_timeout(priv, 100); | 3732 | iwl_scan_cancel_timeout(priv, 100); |
4566 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 3733 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
4567 | iwl4965_commit_rxon(priv); | 3734 | iwl4965_commit_rxon(priv); |
4568 | } | 3735 | } |
@@ -4759,7 +3926,7 @@ static ssize_t store_flags(struct device *d, | |||
4759 | mutex_lock(&priv->mutex); | 3926 | mutex_lock(&priv->mutex); |
4760 | if (le32_to_cpu(priv->staging_rxon.flags) != flags) { | 3927 | if (le32_to_cpu(priv->staging_rxon.flags) != flags) { |
4761 | /* Cancel any currently running scans... */ | 3928 | /* Cancel any currently running scans... */ |
4762 | if (iwl4965_scan_cancel_timeout(priv, 100)) | 3929 | if (iwl_scan_cancel_timeout(priv, 100)) |
4763 | IWL_WARNING("Could not cancel scan.\n"); | 3930 | IWL_WARNING("Could not cancel scan.\n"); |
4764 | else { | 3931 | else { |
4765 | IWL_DEBUG_INFO("Committing rxon.flags = 0x%04X\n", | 3932 | IWL_DEBUG_INFO("Committing rxon.flags = 0x%04X\n", |
@@ -4794,7 +3961,7 @@ static ssize_t store_filter_flags(struct device *d, | |||
4794 | mutex_lock(&priv->mutex); | 3961 | mutex_lock(&priv->mutex); |
4795 | if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) { | 3962 | if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) { |
4796 | /* Cancel any currently running scans... */ | 3963 | /* Cancel any currently running scans... */ |
4797 | if (iwl4965_scan_cancel_timeout(priv, 100)) | 3964 | if (iwl_scan_cancel_timeout(priv, 100)) |
4798 | IWL_WARNING("Could not cancel scan.\n"); | 3965 | IWL_WARNING("Could not cancel scan.\n"); |
4799 | else { | 3966 | else { |
4800 | IWL_DEBUG_INFO("Committing rxon.filter_flags = " | 3967 | IWL_DEBUG_INFO("Committing rxon.filter_flags = " |
@@ -5062,9 +4229,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) | |||
5062 | INIT_WORK(&priv->up, iwl4965_bg_up); | 4229 | INIT_WORK(&priv->up, iwl4965_bg_up); |
5063 | INIT_WORK(&priv->restart, iwl4965_bg_restart); | 4230 | INIT_WORK(&priv->restart, iwl4965_bg_restart); |
5064 | INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); | 4231 | INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); |
5065 | INIT_WORK(&priv->scan_completed, iwl4965_bg_scan_completed); | ||
5066 | INIT_WORK(&priv->request_scan, iwl4965_bg_request_scan); | ||
5067 | INIT_WORK(&priv->abort_scan, iwl4965_bg_abort_scan); | ||
5068 | INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); | 4232 | INIT_WORK(&priv->rf_kill, iwl4965_bg_rf_kill); |
5069 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); | 4233 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); |
5070 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); | 4234 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); |
@@ -5072,7 +4236,10 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) | |||
5072 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); | 4236 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); |
5073 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); | 4237 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); |
5074 | INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); | 4238 | INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); |
5075 | INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); | 4239 | |
4240 | /* FIXME : remove when resolved PENDING */ | ||
4241 | INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); | ||
4242 | iwl_setup_scan_deferred_work(priv); | ||
5076 | 4243 | ||
5077 | if (priv->cfg->ops->lib->setup_deferred_work) | 4244 | if (priv->cfg->ops->lib->setup_deferred_work) |
5078 | priv->cfg->ops->lib->setup_deferred_work(priv); | 4245 | priv->cfg->ops->lib->setup_deferred_work(priv); |