diff options
author | Samuel Ortiz <samuel.ortiz@intel.com> | 2009-01-23 16:45:12 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:33 -0500 |
commit | 77fecfb88f8ad64420e06a96f1bd3b38498bfb4f (patch) | |
tree | 42f4f73214ef517c84bad6eb30e27db0dbf09568 /drivers/net/wireless/iwlwifi | |
parent | 75bcfae97d71756263ccbffc2dcdd8b3020a1a0f (diff) |
iwl3945: Use iwlcore scan code
A lot of the scanning related code is duplicated between 3945 and agn. Let's
use the iwlcore one and get rid of the 3945.
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.h | 21 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-scan.c | 42 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 289 |
3 files changed, 51 insertions, 301 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 2f23f78296ed..409caaa31bb1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -316,9 +316,30 @@ void iwl_init_scan_params(struct iwl_priv *priv); | |||
316 | int iwl_scan_cancel(struct iwl_priv *priv); | 316 | int iwl_scan_cancel(struct iwl_priv *priv); |
317 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); | 317 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); |
318 | int iwl_scan_initiate(struct iwl_priv *priv); | 318 | int iwl_scan_initiate(struct iwl_priv *priv); |
319 | u16 iwl_fill_probe_req(struct iwl_priv *priv, enum ieee80211_band band, | ||
320 | struct ieee80211_mgmt *frame, int left); | ||
319 | void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); | 321 | void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); |
322 | u16 iwl_get_active_dwell_time(struct iwl_priv *priv, | ||
323 | enum ieee80211_band band, | ||
324 | u8 n_probes); | ||
325 | u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, | ||
326 | enum ieee80211_band band); | ||
327 | void iwl_bg_scan_check(struct work_struct *data); | ||
328 | void iwl_bg_abort_scan(struct work_struct *work); | ||
329 | void iwl_bg_scan_completed(struct work_struct *work); | ||
320 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv); | 330 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv); |
321 | 331 | ||
332 | /* For faster active scanning, scan will move to the next channel if fewer than | ||
333 | * PLCP_QUIET_THRESH packets are heard on this channel within | ||
334 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | ||
335 | * time if it's a quiet channel (nothing responded to our probe, and there's | ||
336 | * no other traffic). | ||
337 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ | ||
338 | #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */ | ||
339 | #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ | ||
340 | |||
341 | #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) | ||
342 | |||
322 | /******************************************************************************* | 343 | /******************************************************************************* |
323 | * Calibrations - implemented in iwl-calib.c | 344 | * Calibrations - implemented in iwl-calib.c |
324 | ******************************************************************************/ | 345 | ******************************************************************************/ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index e510f5165992..0ce122a17341 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -46,15 +46,6 @@ | |||
46 | #define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3) | 46 | #define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3) |
47 | #define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2) | 47 | #define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2) |
48 | 48 | ||
49 | /* For faster active scanning, scan will move to the next channel if fewer than | ||
50 | * PLCP_QUIET_THRESH packets are heard on this channel within | ||
51 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | ||
52 | * time if it's a quiet channel (nothing responded to our probe, and there's | ||
53 | * no other traffic). | ||
54 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ | ||
55 | #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ | ||
56 | #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */ | ||
57 | |||
58 | /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. | 49 | /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. |
59 | * Must be set longer than active dwell time. | 50 | * Must be set longer than active dwell time. |
60 | * For the most reliable scan, set > AP beacon interval (typically 100msec). */ | 51 | * For the most reliable scan, set > AP beacon interval (typically 100msec). */ |
@@ -63,7 +54,6 @@ | |||
63 | #define IWL_PASSIVE_DWELL_BASE (100) | 54 | #define IWL_PASSIVE_DWELL_BASE (100) |
64 | #define IWL_CHANNEL_TUNE_TIME 5 | 55 | #define IWL_CHANNEL_TUNE_TIME 5 |
65 | 56 | ||
66 | #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) | ||
67 | 57 | ||
68 | 58 | ||
69 | /** | 59 | /** |
@@ -296,9 +286,9 @@ void iwl_setup_rx_scan_handlers(struct iwl_priv *priv) | |||
296 | } | 286 | } |
297 | EXPORT_SYMBOL(iwl_setup_rx_scan_handlers); | 287 | EXPORT_SYMBOL(iwl_setup_rx_scan_handlers); |
298 | 288 | ||
299 | static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv, | 289 | inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv, |
300 | enum ieee80211_band band, | 290 | enum ieee80211_band band, |
301 | u8 n_probes) | 291 | u8 n_probes) |
302 | { | 292 | { |
303 | if (band == IEEE80211_BAND_5GHZ) | 293 | if (band == IEEE80211_BAND_5GHZ) |
304 | return IWL_ACTIVE_DWELL_TIME_52 + | 294 | return IWL_ACTIVE_DWELL_TIME_52 + |
@@ -307,9 +297,10 @@ static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv, | |||
307 | return IWL_ACTIVE_DWELL_TIME_24 + | 297 | return IWL_ACTIVE_DWELL_TIME_24 + |
308 | IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); | 298 | IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); |
309 | } | 299 | } |
300 | EXPORT_SYMBOL(iwl_get_active_dwell_time); | ||
310 | 301 | ||
311 | static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, | 302 | u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, |
312 | enum ieee80211_band band) | 303 | enum ieee80211_band band) |
313 | { | 304 | { |
314 | u16 passive = (band == IEEE80211_BAND_2GHZ) ? | 305 | u16 passive = (band == IEEE80211_BAND_2GHZ) ? |
315 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : | 306 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : |
@@ -327,6 +318,7 @@ static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, | |||
327 | 318 | ||
328 | return passive; | 319 | return passive; |
329 | } | 320 | } |
321 | EXPORT_SYMBOL(iwl_get_passive_dwell_time); | ||
330 | 322 | ||
331 | static int iwl_get_channels_for_scan(struct iwl_priv *priv, | 323 | static int iwl_get_channels_for_scan(struct iwl_priv *priv, |
332 | enum ieee80211_band band, | 324 | enum ieee80211_band band, |
@@ -450,7 +442,7 @@ EXPORT_SYMBOL(iwl_scan_initiate); | |||
450 | 442 | ||
451 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) | 443 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) |
452 | 444 | ||
453 | static void iwl_bg_scan_check(struct work_struct *data) | 445 | void iwl_bg_scan_check(struct work_struct *data) |
454 | { | 446 | { |
455 | struct iwl_priv *priv = | 447 | struct iwl_priv *priv = |
456 | container_of(data, struct iwl_priv, scan_check.work); | 448 | container_of(data, struct iwl_priv, scan_check.work); |
@@ -470,6 +462,8 @@ static void iwl_bg_scan_check(struct work_struct *data) | |||
470 | } | 462 | } |
471 | mutex_unlock(&priv->mutex); | 463 | mutex_unlock(&priv->mutex); |
472 | } | 464 | } |
465 | EXPORT_SYMBOL(iwl_bg_scan_check); | ||
466 | |||
473 | /** | 467 | /** |
474 | * iwl_supported_rate_to_ie - fill in the supported rate in IE field | 468 | * iwl_supported_rate_to_ie - fill in the supported rate in IE field |
475 | * | 469 | * |
@@ -527,10 +521,10 @@ static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband, | |||
527 | * iwl_fill_probe_req - fill in all required fields and IE for probe request | 521 | * iwl_fill_probe_req - fill in all required fields and IE for probe request |
528 | */ | 522 | */ |
529 | 523 | ||
530 | static u16 iwl_fill_probe_req(struct iwl_priv *priv, | 524 | u16 iwl_fill_probe_req(struct iwl_priv *priv, |
531 | enum ieee80211_band band, | 525 | enum ieee80211_band band, |
532 | struct ieee80211_mgmt *frame, | 526 | struct ieee80211_mgmt *frame, |
533 | int left) | 527 | int left) |
534 | { | 528 | { |
535 | int len = 0; | 529 | int len = 0; |
536 | u8 *pos = NULL; | 530 | u8 *pos = NULL; |
@@ -624,6 +618,7 @@ static u16 iwl_fill_probe_req(struct iwl_priv *priv, | |||
624 | 618 | ||
625 | return (u16)len; | 619 | return (u16)len; |
626 | } | 620 | } |
621 | EXPORT_SYMBOL(iwl_fill_probe_req); | ||
627 | 622 | ||
628 | static void iwl_bg_request_scan(struct work_struct *data) | 623 | static void iwl_bg_request_scan(struct work_struct *data) |
629 | { | 624 | { |
@@ -839,7 +834,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
839 | mutex_unlock(&priv->mutex); | 834 | mutex_unlock(&priv->mutex); |
840 | } | 835 | } |
841 | 836 | ||
842 | static void iwl_bg_abort_scan(struct work_struct *work) | 837 | void iwl_bg_abort_scan(struct work_struct *work) |
843 | { | 838 | { |
844 | struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); | 839 | struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); |
845 | 840 | ||
@@ -853,8 +848,9 @@ static void iwl_bg_abort_scan(struct work_struct *work) | |||
853 | 848 | ||
854 | mutex_unlock(&priv->mutex); | 849 | mutex_unlock(&priv->mutex); |
855 | } | 850 | } |
851 | EXPORT_SYMBOL(iwl_bg_abort_scan); | ||
856 | 852 | ||
857 | static void iwl_bg_scan_completed(struct work_struct *work) | 853 | void iwl_bg_scan_completed(struct work_struct *work) |
858 | { | 854 | { |
859 | struct iwl_priv *priv = | 855 | struct iwl_priv *priv = |
860 | container_of(work, struct iwl_priv, scan_completed); | 856 | container_of(work, struct iwl_priv, scan_completed); |
@@ -872,7 +868,7 @@ static void iwl_bg_scan_completed(struct work_struct *work) | |||
872 | iwl_set_tx_power(priv, priv->tx_power_user_lmt, true); | 868 | iwl_set_tx_power(priv, priv->tx_power_user_lmt, true); |
873 | mutex_unlock(&priv->mutex); | 869 | mutex_unlock(&priv->mutex); |
874 | } | 870 | } |
875 | 871 | EXPORT_SYMBOL(iwl_bg_scan_completed); | |
876 | 872 | ||
877 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv) | 873 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv) |
878 | { | 874 | { |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 997ac33500f3..c7bb9c19a902 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -791,47 +791,6 @@ static int iwl3945_send_bt_config(struct iwl_priv *priv) | |||
791 | sizeof(bt_cmd), &bt_cmd); | 791 | sizeof(bt_cmd), &bt_cmd); |
792 | } | 792 | } |
793 | 793 | ||
794 | static int iwl3945_send_scan_abort(struct iwl_priv *priv) | ||
795 | { | ||
796 | int rc = 0; | ||
797 | struct iwl_rx_packet *res; | ||
798 | struct iwl_host_cmd cmd = { | ||
799 | .id = REPLY_SCAN_ABORT_CMD, | ||
800 | .meta.flags = CMD_WANT_SKB, | ||
801 | }; | ||
802 | |||
803 | /* If there isn't a scan actively going on in the hardware | ||
804 | * then we are in between scan bands and not actually | ||
805 | * actively scanning, so don't send the abort command */ | ||
806 | if (!test_bit(STATUS_SCAN_HW, &priv->status)) { | ||
807 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
808 | return 0; | ||
809 | } | ||
810 | |||
811 | rc = iwl_send_cmd_sync(priv, &cmd); | ||
812 | if (rc) { | ||
813 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
814 | return rc; | ||
815 | } | ||
816 | |||
817 | res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; | ||
818 | if (res->u.status != CAN_ABORT_STATUS) { | ||
819 | /* The scan abort will return 1 for success or | ||
820 | * 2 for "failure". A failure condition can be | ||
821 | * due to simply not being in an active scan which | ||
822 | * can occur if we send the scan abort before we | ||
823 | * the microcode has notified us that a scan is | ||
824 | * completed. */ | ||
825 | IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status); | ||
826 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
827 | clear_bit(STATUS_SCAN_HW, &priv->status); | ||
828 | } | ||
829 | |||
830 | dev_kfree_skb_any(cmd.meta.u.skb); | ||
831 | |||
832 | return rc; | ||
833 | } | ||
834 | |||
835 | static int iwl3945_add_sta_sync_callback(struct iwl_priv *priv, | 794 | static int iwl3945_add_sta_sync_callback(struct iwl_priv *priv, |
836 | struct iwl_cmd *cmd, struct sk_buff *skb) | 795 | struct iwl_cmd *cmd, struct sk_buff *skb) |
837 | { | 796 | { |
@@ -1168,115 +1127,6 @@ static void iwl3945_unset_hw_params(struct iwl_priv *priv) | |||
1168 | priv->shared_phys); | 1127 | priv->shared_phys); |
1169 | } | 1128 | } |
1170 | 1129 | ||
1171 | /** | ||
1172 | * iwl3945_supported_rate_to_ie - fill in the supported rate in IE field | ||
1173 | * | ||
1174 | * return : set the bit for each supported rate insert in ie | ||
1175 | */ | ||
1176 | static u16 iwl3945_supported_rate_to_ie(u8 *ie, u16 supported_rate, | ||
1177 | u16 basic_rate, int *left) | ||
1178 | { | ||
1179 | u16 ret_rates = 0, bit; | ||
1180 | int i; | ||
1181 | u8 *cnt = ie; | ||
1182 | u8 *rates = ie + 1; | ||
1183 | |||
1184 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { | ||
1185 | if (bit & supported_rate) { | ||
1186 | ret_rates |= bit; | ||
1187 | rates[*cnt] = iwl3945_rates[i].ieee | | ||
1188 | ((bit & basic_rate) ? 0x80 : 0x00); | ||
1189 | (*cnt)++; | ||
1190 | (*left)--; | ||
1191 | if ((*left <= 0) || | ||
1192 | (*cnt >= IWL_SUPPORTED_RATES_IE_LEN)) | ||
1193 | break; | ||
1194 | } | ||
1195 | } | ||
1196 | |||
1197 | return ret_rates; | ||
1198 | } | ||
1199 | |||
1200 | /** | ||
1201 | * iwl3945_fill_probe_req - fill in all required fields and IE for probe request | ||
1202 | */ | ||
1203 | static u16 iwl3945_fill_probe_req(struct iwl_priv *priv, | ||
1204 | struct ieee80211_mgmt *frame, | ||
1205 | int left) | ||
1206 | { | ||
1207 | int len = 0; | ||
1208 | u8 *pos = NULL; | ||
1209 | u16 active_rates, ret_rates, cck_rates; | ||
1210 | |||
1211 | /* Make sure there is enough space for the probe request, | ||
1212 | * two mandatory IEs and the data */ | ||
1213 | left -= 24; | ||
1214 | if (left < 0) | ||
1215 | return 0; | ||
1216 | len += 24; | ||
1217 | |||
1218 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); | ||
1219 | memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); | ||
1220 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); | ||
1221 | memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); | ||
1222 | frame->seq_ctrl = 0; | ||
1223 | |||
1224 | /* fill in our indirect SSID IE */ | ||
1225 | /* ...next IE... */ | ||
1226 | |||
1227 | left -= 2; | ||
1228 | if (left < 0) | ||
1229 | return 0; | ||
1230 | len += 2; | ||
1231 | pos = &(frame->u.probe_req.variable[0]); | ||
1232 | *pos++ = WLAN_EID_SSID; | ||
1233 | *pos++ = 0; | ||
1234 | |||
1235 | /* fill in supported rate */ | ||
1236 | /* ...next IE... */ | ||
1237 | left -= 2; | ||
1238 | if (left < 0) | ||
1239 | return 0; | ||
1240 | |||
1241 | /* ... fill it in... */ | ||
1242 | *pos++ = WLAN_EID_SUPP_RATES; | ||
1243 | *pos = 0; | ||
1244 | |||
1245 | priv->active_rate = priv->rates_mask; | ||
1246 | active_rates = priv->active_rate; | ||
1247 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; | ||
1248 | |||
1249 | cck_rates = IWL_CCK_RATES_MASK & active_rates; | ||
1250 | ret_rates = iwl3945_supported_rate_to_ie(pos, cck_rates, | ||
1251 | priv->active_rate_basic, &left); | ||
1252 | active_rates &= ~ret_rates; | ||
1253 | |||
1254 | ret_rates = iwl3945_supported_rate_to_ie(pos, active_rates, | ||
1255 | priv->active_rate_basic, &left); | ||
1256 | active_rates &= ~ret_rates; | ||
1257 | |||
1258 | len += 2 + *pos; | ||
1259 | pos += (*pos) + 1; | ||
1260 | if (active_rates == 0) | ||
1261 | goto fill_end; | ||
1262 | |||
1263 | /* fill in supported extended rate */ | ||
1264 | /* ...next IE... */ | ||
1265 | left -= 2; | ||
1266 | if (left < 0) | ||
1267 | return 0; | ||
1268 | /* ... fill it in... */ | ||
1269 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
1270 | *pos = 0; | ||
1271 | iwl3945_supported_rate_to_ie(pos, active_rates, | ||
1272 | priv->active_rate_basic, &left); | ||
1273 | if (*pos > 0) | ||
1274 | len += 2 + *pos; | ||
1275 | |||
1276 | fill_end: | ||
1277 | return (u16)len; | ||
1278 | } | ||
1279 | |||
1280 | /* | 1130 | /* |
1281 | * QoS support | 1131 | * QoS support |
1282 | */ | 1132 | */ |
@@ -3955,66 +3805,6 @@ static void iwl3945_free_channel_map(struct iwl_priv *priv) | |||
3955 | priv->channel_count = 0; | 3805 | priv->channel_count = 0; |
3956 | } | 3806 | } |
3957 | 3807 | ||
3958 | /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after | ||
3959 | * sending probe req. This should be set long enough to hear probe responses | ||
3960 | * from more than one AP. */ | ||
3961 | #define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ | ||
3962 | #define IWL_ACTIVE_DWELL_TIME_52 (20) | ||
3963 | |||
3964 | #define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3) | ||
3965 | #define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2) | ||
3966 | |||
3967 | /* For faster active scanning, scan will move to the next channel if fewer than | ||
3968 | * PLCP_QUIET_THRESH packets are heard on this channel within | ||
3969 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | ||
3970 | * time if it's a quiet channel (nothing responded to our probe, and there's | ||
3971 | * no other traffic). | ||
3972 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ | ||
3973 | #define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ | ||
3974 | #define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */ | ||
3975 | |||
3976 | /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. | ||
3977 | * Must be set longer than active dwell time. | ||
3978 | * For the most reliable scan, set > AP beacon interval (typically 100msec). */ | ||
3979 | #define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ | ||
3980 | #define IWL_PASSIVE_DWELL_TIME_52 (10) | ||
3981 | #define IWL_PASSIVE_DWELL_BASE (100) | ||
3982 | #define IWL_CHANNEL_TUNE_TIME 5 | ||
3983 | |||
3984 | #define IWL_SCAN_PROBE_MASK(n) (BIT(n) | (BIT(n) - BIT(1))) | ||
3985 | |||
3986 | static inline u16 iwl3945_get_active_dwell_time(struct iwl_priv *priv, | ||
3987 | enum ieee80211_band band, | ||
3988 | u8 n_probes) | ||
3989 | { | ||
3990 | if (band == IEEE80211_BAND_5GHZ) | ||
3991 | return IWL_ACTIVE_DWELL_TIME_52 + | ||
3992 | IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); | ||
3993 | else | ||
3994 | return IWL_ACTIVE_DWELL_TIME_24 + | ||
3995 | IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); | ||
3996 | } | ||
3997 | |||
3998 | static u16 iwl3945_get_passive_dwell_time(struct iwl_priv *priv, | ||
3999 | enum ieee80211_band band) | ||
4000 | { | ||
4001 | u16 passive = (band == IEEE80211_BAND_2GHZ) ? | ||
4002 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : | ||
4003 | IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; | ||
4004 | |||
4005 | if (iwl3945_is_associated(priv)) { | ||
4006 | /* If we're associated, we clamp the maximum passive | ||
4007 | * dwell time to be 98% of the beacon interval (minus | ||
4008 | * 2 * channel tune time) */ | ||
4009 | passive = priv->beacon_int; | ||
4010 | if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) | ||
4011 | passive = IWL_PASSIVE_DWELL_BASE; | ||
4012 | passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; | ||
4013 | } | ||
4014 | |||
4015 | return passive; | ||
4016 | } | ||
4017 | |||
4018 | static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | 3808 | static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, |
4019 | enum ieee80211_band band, | 3809 | enum ieee80211_band band, |
4020 | u8 is_active, u8 n_probes, | 3810 | u8 is_active, u8 n_probes, |
@@ -4033,8 +3823,8 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | |||
4033 | 3823 | ||
4034 | channels = sband->channels; | 3824 | channels = sband->channels; |
4035 | 3825 | ||
4036 | active_dwell = iwl3945_get_active_dwell_time(priv, band, n_probes); | 3826 | active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); |
4037 | passive_dwell = iwl3945_get_passive_dwell_time(priv, band); | 3827 | passive_dwell = iwl_get_passive_dwell_time(priv, band); |
4038 | 3828 | ||
4039 | if (passive_dwell <= active_dwell) | 3829 | if (passive_dwell <= active_dwell) |
4040 | passive_dwell = active_dwell + 1; | 3830 | passive_dwell = active_dwell + 1; |
@@ -5135,28 +4925,6 @@ static void iwl3945_rfkill_poll(struct work_struct *data) | |||
5135 | } | 4925 | } |
5136 | 4926 | ||
5137 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) | 4927 | #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) |
5138 | |||
5139 | static void iwl3945_bg_scan_check(struct work_struct *data) | ||
5140 | { | ||
5141 | struct iwl_priv *priv = | ||
5142 | container_of(data, struct iwl_priv, scan_check.work); | ||
5143 | |||
5144 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | ||
5145 | return; | ||
5146 | |||
5147 | mutex_lock(&priv->mutex); | ||
5148 | if (test_bit(STATUS_SCANNING, &priv->status) || | ||
5149 | test_bit(STATUS_SCAN_ABORTING, &priv->status)) { | ||
5150 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, | ||
5151 | "Scan completion watchdog resetting adapter (%dms)\n", | ||
5152 | jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); | ||
5153 | |||
5154 | if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) | ||
5155 | iwl3945_send_scan_abort(priv); | ||
5156 | } | ||
5157 | mutex_unlock(&priv->mutex); | ||
5158 | } | ||
5159 | |||
5160 | static void iwl3945_bg_request_scan(struct work_struct *data) | 4928 | static void iwl3945_bg_request_scan(struct work_struct *data) |
5161 | { | 4929 | { |
5162 | struct iwl_priv *priv = | 4930 | struct iwl_priv *priv = |
@@ -5284,9 +5052,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
5284 | 5052 | ||
5285 | /* We don't build a direct scan probe request; the uCode will do | 5053 | /* We don't build a direct scan probe request; the uCode will do |
5286 | * that based on the direct_mask added to each channel entry */ | 5054 | * that based on the direct_mask added to each channel entry */ |
5287 | scan->tx_cmd.len = cpu_to_le16( | ||
5288 | iwl3945_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, | ||
5289 | IWL_MAX_SCAN_SIZE - sizeof(*scan))); | ||
5290 | scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; | 5055 | scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; |
5291 | scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; | 5056 | scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; |
5292 | scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | 5057 | scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
@@ -5307,6 +5072,11 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
5307 | goto done; | 5072 | goto done; |
5308 | } | 5073 | } |
5309 | 5074 | ||
5075 | scan->tx_cmd.len = cpu_to_le16( | ||
5076 | iwl_fill_probe_req(priv, band, | ||
5077 | (struct ieee80211_mgmt *)scan->data, | ||
5078 | IWL_MAX_SCAN_SIZE - sizeof(*scan))); | ||
5079 | |||
5310 | /* select Rx antennas */ | 5080 | /* select Rx antennas */ |
5311 | scan->flags |= iwl3945_get_antenna_flags(priv); | 5081 | scan->flags |= iwl3945_get_antenna_flags(priv); |
5312 | 5082 | ||
@@ -5482,45 +5252,8 @@ static void iwl3945_post_associate(struct iwl_priv *priv) | |||
5482 | priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN; | 5252 | priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN; |
5483 | } | 5253 | } |
5484 | 5254 | ||
5485 | static void iwl3945_bg_abort_scan(struct work_struct *work) | ||
5486 | { | ||
5487 | struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); | ||
5488 | |||
5489 | if (!iwl_is_ready(priv)) | ||
5490 | return; | ||
5491 | |||
5492 | mutex_lock(&priv->mutex); | ||
5493 | |||
5494 | set_bit(STATUS_SCAN_ABORTING, &priv->status); | ||
5495 | iwl3945_send_scan_abort(priv); | ||
5496 | |||
5497 | mutex_unlock(&priv->mutex); | ||
5498 | } | ||
5499 | |||
5500 | static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed); | 5255 | static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed); |
5501 | 5256 | ||
5502 | static void iwl3945_bg_scan_completed(struct work_struct *work) | ||
5503 | { | ||
5504 | struct iwl_priv *priv = | ||
5505 | container_of(work, struct iwl_priv, scan_completed); | ||
5506 | |||
5507 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "SCAN complete scan\n"); | ||
5508 | |||
5509 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | ||
5510 | return; | ||
5511 | |||
5512 | if (test_bit(STATUS_CONF_PENDING, &priv->status)) | ||
5513 | iwl3945_mac_config(priv->hw, 0); | ||
5514 | |||
5515 | ieee80211_scan_completed(priv->hw); | ||
5516 | |||
5517 | /* Since setting the TXPOWER may have been deferred while | ||
5518 | * performing the scan, fire one off */ | ||
5519 | mutex_lock(&priv->mutex); | ||
5520 | priv->cfg->ops->lib->send_tx_power(priv); | ||
5521 | mutex_unlock(&priv->mutex); | ||
5522 | } | ||
5523 | |||
5524 | /***************************************************************************** | 5257 | /***************************************************************************** |
5525 | * | 5258 | * |
5526 | * mac80211 entry point functions | 5259 | * mac80211 entry point functions |
@@ -6821,15 +6554,15 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv) | |||
6821 | INIT_WORK(&priv->up, iwl3945_bg_up); | 6554 | INIT_WORK(&priv->up, iwl3945_bg_up); |
6822 | INIT_WORK(&priv->restart, iwl3945_bg_restart); | 6555 | INIT_WORK(&priv->restart, iwl3945_bg_restart); |
6823 | INIT_WORK(&priv->rx_replenish, iwl3945_bg_rx_replenish); | 6556 | INIT_WORK(&priv->rx_replenish, iwl3945_bg_rx_replenish); |
6824 | INIT_WORK(&priv->scan_completed, iwl3945_bg_scan_completed); | ||
6825 | INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan); | ||
6826 | INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan); | ||
6827 | INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill); | 6557 | INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill); |
6828 | INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); | 6558 | INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); |
6829 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); | 6559 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); |
6830 | INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); | 6560 | INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); |
6831 | INIT_DELAYED_WORK(&priv->scan_check, iwl3945_bg_scan_check); | ||
6832 | INIT_DELAYED_WORK(&priv->rfkill_poll, iwl3945_rfkill_poll); | 6561 | INIT_DELAYED_WORK(&priv->rfkill_poll, iwl3945_rfkill_poll); |
6562 | INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); | ||
6563 | INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan); | ||
6564 | INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); | ||
6565 | INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); | ||
6833 | 6566 | ||
6834 | iwl3945_hw_setup_deferred_work(priv); | 6567 | iwl3945_hw_setup_deferred_work(priv); |
6835 | 6568 | ||