aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2009-06-19 16:52:45 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-10 15:01:57 -0400
commit2c2f3b33888419fb9e7d015b9dc67b9db4437efa (patch)
tree35b4bb6bd4844ed66ccccf52dffbbed972aa4e9d /drivers/net/wireless
parent4e05c2347a50f1d0892ff3475d7609eec428f781 (diff)
iwlwifi: unify iwl_setup_rxon_timing
This patch unifies setup_rxon_timing funcions of AGN and 3945. HWs differ only in supported maximal beacon interval. This is reflected in hw_paras.max_beacon_itrvl Signed-off-by: Tomas Winkler <tomas.winkler@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')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c59
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c74
7 files changed, 66 insertions, 136 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8cfc83055aa0..b0246dbda99a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2563,6 +2563,7 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv)
2563 priv->hw_params.bcast_sta_id = IWL3945_BROADCAST_ID; 2563 priv->hw_params.bcast_sta_id = IWL3945_BROADCAST_ID;
2564 2564
2565 priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; 2565 priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR;
2566 priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL;
2566 2567
2567 return 0; 2568 return 0;
2568} 2569}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index d9285615c679..1d4e9cadb088 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -512,70 +512,6 @@ int iwl_hw_tx_queue_init(struct iwl_priv *priv,
512 return 0; 512 return 0;
513} 513}
514 514
515
516/******************************************************************************
517 *
518 * Misc. internal state and helper functions
519 *
520 ******************************************************************************/
521
522#define MAX_UCODE_BEACON_INTERVAL 4096
523
524static u16 iwl_adjust_beacon_interval(u16 beacon_val)
525{
526 u16 new_val = 0;
527 u16 beacon_factor = 0;
528
529 beacon_factor = (beacon_val + MAX_UCODE_BEACON_INTERVAL)
530 / MAX_UCODE_BEACON_INTERVAL;
531 new_val = beacon_val / beacon_factor;
532
533 if (!new_val)
534 new_val = MAX_UCODE_BEACON_INTERVAL;
535
536 return new_val;
537}
538
539static void iwl_setup_rxon_timing(struct iwl_priv *priv)
540{
541 u64 tsf;
542 s32 interval_tm, rem;
543 unsigned long flags;
544 struct ieee80211_conf *conf = NULL;
545 u16 beacon_int = 0;
546
547 conf = ieee80211_get_hw_conf(priv->hw);
548
549 spin_lock_irqsave(&priv->lock, flags);
550 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
551 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
552
553 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
554 beacon_int = iwl_adjust_beacon_interval(priv->beacon_int);
555 priv->rxon_timing.atim_window = 0;
556 } else {
557 beacon_int = iwl_adjust_beacon_interval(
558 priv->vif->bss_conf.beacon_int);
559
560 /* TODO: we need to get atim_window from upper stack
561 * for now we set to 0 */
562 priv->rxon_timing.atim_window = 0;
563 }
564
565 priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int);
566
567 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
568 interval_tm = beacon_int * 1024;
569 rem = do_div(tsf, interval_tm);
570 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
571
572 spin_unlock_irqrestore(&priv->lock, flags);
573 IWL_DEBUG_ASSOC(priv, "beacon interval %d beacon timer %d beacon tim %d\n",
574 le16_to_cpu(priv->rxon_timing.beacon_interval),
575 le32_to_cpu(priv->rxon_timing.beacon_init_val),
576 le16_to_cpu(priv->rxon_timing.atim_window));
577}
578
579/****************************************************************************** 515/******************************************************************************
580 * 516 *
581 * Generic RX handler implementations 517 * Generic RX handler implementations
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index c87033bf3ad2..6e9b8a8356ea 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -765,6 +765,8 @@ struct iwl5000_rxon_assoc_cmd {
765} __attribute__ ((packed)); 765} __attribute__ ((packed));
766 766
767#define IWL_CONN_MAX_LISTEN_INTERVAL 10 767#define IWL_CONN_MAX_LISTEN_INTERVAL 10
768#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
769#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */
768 770
769/* 771/*
770 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) 772 * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 11a19692f33b..7e528a0a15e3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -635,6 +635,63 @@ u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
635} 635}
636EXPORT_SYMBOL(iwl_is_fat_tx_allowed); 636EXPORT_SYMBOL(iwl_is_fat_tx_allowed);
637 637
638static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
639{
640 u16 new_val = 0;
641 u16 beacon_factor = 0;
642
643 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
644 new_val = beacon_val / beacon_factor;
645
646 if (!new_val)
647 new_val = max_beacon_val;
648
649 return new_val;
650}
651
652void iwl_setup_rxon_timing(struct iwl_priv *priv)
653{
654 u64 tsf;
655 s32 interval_tm, rem;
656 unsigned long flags;
657 struct ieee80211_conf *conf = NULL;
658 u16 beacon_int;
659
660 conf = ieee80211_get_hw_conf(priv->hw);
661
662 spin_lock_irqsave(&priv->lock, flags);
663 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
664 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
665
666 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
667 beacon_int = priv->beacon_int;
668 priv->rxon_timing.atim_window = 0;
669 } else {
670 beacon_int = priv->vif->bss_conf.beacon_int;
671
672 /* TODO: we need to get atim_window from upper stack
673 * for now we set to 0 */
674 priv->rxon_timing.atim_window = 0;
675 }
676
677 beacon_int = iwl_adjust_beacon_interval(beacon_int,
678 priv->hw_params.max_beacon_itrvl * 1024);
679 priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int);
680
681 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
682 interval_tm = beacon_int * 1024;
683 rem = do_div(tsf, interval_tm);
684 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
685
686 spin_unlock_irqrestore(&priv->lock, flags);
687 IWL_DEBUG_ASSOC(priv,
688 "beacon interval %d beacon timer %d beacon tim %d\n",
689 le16_to_cpu(priv->rxon_timing.beacon_interval),
690 le32_to_cpu(priv->rxon_timing.beacon_init_val),
691 le16_to_cpu(priv->rxon_timing.atim_window));
692}
693EXPORT_SYMBOL(iwl_setup_rxon_timing);
694
638void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) 695void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
639{ 696{
640 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 697 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
@@ -1369,6 +1426,8 @@ int iwl_set_hw_params(struct iwl_priv *priv)
1369 priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_4K; 1426 priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_4K;
1370 priv->hw_params.max_pkt_size = priv->hw_params.rx_buf_size - 256; 1427 priv->hw_params.max_pkt_size = priv->hw_params.rx_buf_size - 256;
1371 1428
1429 priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL;
1430
1372 if (priv->cfg->mod_params->disable_11n) 1431 if (priv->cfg->mod_params->disable_11n)
1373 priv->cfg->sku &= ~IWL_SKU_N; 1432 priv->cfg->sku &= ~IWL_SKU_N;
1374 1433
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 356d4e3aec7e..a658410e66a4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -554,6 +554,7 @@ extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
554void iwl_rx_reply_compressed_ba(struct iwl_priv *priv, 554void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
555 struct iwl_rx_mem_buffer *rxb); 555 struct iwl_rx_mem_buffer *rxb);
556 556
557void iwl_setup_rxon_timing(struct iwl_priv *priv);
557static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) 558static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
558{ 559{
559 return priv->cfg->ops->hcmd->rxon_assoc(priv); 560 return priv->cfg->ops->hcmd->rxon_assoc(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 5da60e402f7b..1a2fe37d4735 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -608,6 +608,7 @@ struct iwl_hw_params {
608 u8 max_stations; 608 u8 max_stations;
609 u8 bcast_sta_id; 609 u8 bcast_sta_id;
610 u8 fat_channel; 610 u8 fat_channel;
611 u8 max_beacon_itrvl; /* in 1024 ms */
611 u32 max_inst_size; 612 u32 max_inst_size;
612 u32 max_data_size; 613 u32 max_data_size;
613 u32 max_bsm_size; 614 u32 max_bsm_size;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 016567f3e88e..303c4b483f5b 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -361,76 +361,6 @@ static void iwl3945_unset_hw_params(struct iwl_priv *priv)
361 priv->shared_phys); 361 priv->shared_phys);
362} 362}
363 363
364#define MAX_UCODE_BEACON_INTERVAL 1024
365#define INTEL_CONN_LISTEN_INTERVAL cpu_to_le16(0xA)
366
367static __le16 iwl3945_adjust_beacon_interval(u16 beacon_val)
368{
369 u16 new_val = 0;
370 u16 beacon_factor = 0;
371
372 beacon_factor =
373 (beacon_val + MAX_UCODE_BEACON_INTERVAL)
374 / MAX_UCODE_BEACON_INTERVAL;
375 new_val = beacon_val / beacon_factor;
376
377 return cpu_to_le16(new_val);
378}
379
380static void iwl3945_setup_rxon_timing(struct iwl_priv *priv)
381{
382 u64 interval_tm_unit;
383 u64 tsf, result;
384 unsigned long flags;
385 struct ieee80211_conf *conf = NULL;
386 u16 beacon_int = 0;
387
388 conf = ieee80211_get_hw_conf(priv->hw);
389
390 spin_lock_irqsave(&priv->lock, flags);
391 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
392 priv->rxon_timing.listen_interval = INTEL_CONN_LISTEN_INTERVAL;
393
394 tsf = priv->timestamp;
395
396 beacon_int = priv->beacon_int;
397 spin_unlock_irqrestore(&priv->lock, flags);
398
399 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
400 if (beacon_int == 0) {
401 priv->rxon_timing.beacon_interval = cpu_to_le16(100);
402 priv->rxon_timing.beacon_init_val = cpu_to_le32(102400);
403 } else {
404 priv->rxon_timing.beacon_interval =
405 cpu_to_le16(beacon_int);
406 priv->rxon_timing.beacon_interval =
407 iwl3945_adjust_beacon_interval(
408 le16_to_cpu(priv->rxon_timing.beacon_interval));
409 }
410
411 priv->rxon_timing.atim_window = 0;
412 } else {
413 priv->rxon_timing.beacon_interval =
414 iwl3945_adjust_beacon_interval(
415 priv->vif->bss_conf.beacon_int);
416 /* TODO: we need to get atim_window from upper stack
417 * for now we set to 0 */
418 priv->rxon_timing.atim_window = 0;
419 }
420
421 interval_tm_unit =
422 (le16_to_cpu(priv->rxon_timing.beacon_interval) * 1024);
423 result = do_div(tsf, interval_tm_unit);
424 priv->rxon_timing.beacon_init_val =
425 cpu_to_le32((u32) ((u64) interval_tm_unit - result));
426
427 IWL_DEBUG_ASSOC(priv,
428 "beacon interval %d beacon timer %d beacon tim %d\n",
429 le16_to_cpu(priv->rxon_timing.beacon_interval),
430 le32_to_cpu(priv->rxon_timing.beacon_init_val),
431 le16_to_cpu(priv->rxon_timing.atim_window));
432}
433
434static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, 364static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
435 struct ieee80211_tx_info *info, 365 struct ieee80211_tx_info *info,
436 struct iwl_cmd *cmd, 366 struct iwl_cmd *cmd,
@@ -3066,7 +2996,7 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3066 iwlcore_commit_rxon(priv); 2996 iwlcore_commit_rxon(priv);
3067 2997
3068 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 2998 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3069 iwl3945_setup_rxon_timing(priv); 2999 iwl_setup_rxon_timing(priv);
3070 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3000 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3071 sizeof(priv->rxon_timing), &priv->rxon_timing); 3001 sizeof(priv->rxon_timing), &priv->rxon_timing);
3072 if (rc) 3002 if (rc)
@@ -3261,7 +3191,7 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3261 3191
3262 /* RXON Timing */ 3192 /* RXON Timing */
3263 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3193 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
3264 iwl3945_setup_rxon_timing(priv); 3194 iwl_setup_rxon_timing(priv);
3265 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3195 rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
3266 sizeof(priv->rxon_timing), 3196 sizeof(priv->rxon_timing),
3267 &priv->rxon_timing); 3197 &priv->rxon_timing);