aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-5000.c
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2010-05-06 11:54:11 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-06-06 02:16:09 -0400
commit79d07325502e73508f917475bc1617b60979dd94 (patch)
tree7493c7db482c41b4535690c3a19fb81f3a7b2580 /drivers/net/wireless/iwlwifi/iwl-5000.c
parenta0ee74cf080389aee4fbf198ffa7e85b3480b661 (diff)
iwlwifi: support channel switch offload in driver
Support channel switch in driver as a separated mac80211 callback function instead of part of mac_config callback; by moving to this approach, uCode can have more control of channel switch timing. Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-5000.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index c320d4110fef..19bb5b89b63d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -271,10 +271,17 @@ static void iwl5150_temperature(struct iwl_priv *priv)
271 iwl_tt_handler(priv); 271 iwl_tt_handler(priv);
272} 272}
273 273
274static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel) 274static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
275 struct ieee80211_channel_switch *ch_switch)
275{ 276{
276 struct iwl5000_channel_switch_cmd cmd; 277 struct iwl5000_channel_switch_cmd cmd;
277 const struct iwl_channel_info *ch_info; 278 const struct iwl_channel_info *ch_info;
279 u32 switch_time_in_usec, ucode_switch_time;
280 u16 ch;
281 u32 tsf_low;
282 u8 switch_count;
283 u16 beacon_interval = le16_to_cpu(priv->rxon_timing.beacon_interval);
284 struct ieee80211_vif *vif = priv->vif;
278 struct iwl_host_cmd hcmd = { 285 struct iwl_host_cmd hcmd = {
279 .id = REPLY_CHANNEL_SWITCH, 286 .id = REPLY_CHANNEL_SWITCH,
280 .len = sizeof(cmd), 287 .len = sizeof(cmd),
@@ -282,22 +289,51 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel)
282 .data = &cmd, 289 .data = &cmd,
283 }; 290 };
284 291
285 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
286 priv->active_rxon.channel, channel);
287 cmd.band = priv->band == IEEE80211_BAND_2GHZ; 292 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
288 cmd.channel = cpu_to_le16(channel); 293 ch = ieee80211_frequency_to_channel(ch_switch->channel->center_freq);
294 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
295 priv->active_rxon.channel, ch);
296 cmd.channel = cpu_to_le16(ch);
289 cmd.rxon_flags = priv->staging_rxon.flags; 297 cmd.rxon_flags = priv->staging_rxon.flags;
290 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags; 298 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags;
291 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time); 299 switch_count = ch_switch->count;
292 ch_info = iwl_get_channel_info(priv, priv->band, channel); 300 tsf_low = ch_switch->timestamp & 0x0ffffffff;
301 /*
302 * calculate the ucode channel switch time
303 * adding TSF as one of the factor for when to switch
304 */
305 if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
306 if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
307 beacon_interval)) {
308 switch_count -= (priv->ucode_beacon_time -
309 tsf_low) / beacon_interval;
310 } else
311 switch_count = 0;
312 }
313 if (switch_count <= 1)
314 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
315 else {
316 switch_time_in_usec =
317 vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
318 ucode_switch_time = iwl_usecs_to_beacons(priv,
319 switch_time_in_usec,
320 beacon_interval);
321 cmd.switch_time = iwl_add_beacon_time(priv,
322 priv->ucode_beacon_time,
323 ucode_switch_time,
324 beacon_interval);
325 }
326 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
327 cmd.switch_time);
328 ch_info = iwl_get_channel_info(priv, priv->band, ch);
293 if (ch_info) 329 if (ch_info)
294 cmd.expect_beacon = is_channel_radar(ch_info); 330 cmd.expect_beacon = is_channel_radar(ch_info);
295 else { 331 else {
296 IWL_ERR(priv, "invalid channel switch from %u to %u\n", 332 IWL_ERR(priv, "invalid channel switch from %u to %u\n",
297 priv->active_rxon.channel, channel); 333 priv->active_rxon.channel, ch);
298 return -EFAULT; 334 return -EFAULT;
299 } 335 }
300 priv->switch_rxon.channel = cpu_to_le16(channel); 336 priv->switch_rxon.channel = cmd.channel;
301 priv->switch_rxon.switch_in_progress = true; 337 priv->switch_rxon.switch_in_progress = true;
302 338
303 return iwl_send_cmd_sync(priv, &hcmd); 339 return iwl_send_cmd_sync(priv, &hcmd);