aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
authorRon Rindjunsky <ron.rindjunsky@intel.com>2008-04-23 20:15:05 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-07 15:02:20 -0400
commitc7de35cd1c8b135398899f42475fa8e9d672d46e (patch)
tree14fe2e46d79e2fde48c8010cb8521fc0332d26f5 /drivers/net/wireless/iwlwifi/iwl4965-base.c
parent038669e49c30867956a7fa0d06c6e0e72bb38fa8 (diff)
iwlwifi: unify init driver flow
This patch does the following: 1 - moving init_drv from handler to regular function call 2 - move the init driver flow from iwl4965 to iwlcore, thus unify it to all iwl family as a single flow 3 - move some general purpose functions from iwl4965 to iwlcore Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c175
1 files changed, 9 insertions, 166 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 89b0950f02f0..e24527313ab6 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -882,7 +882,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
882void iwl4965_update_chain_flags(struct iwl_priv *priv) 882void iwl4965_update_chain_flags(struct iwl_priv *priv)
883{ 883{
884 884
885 iwl4965_set_rxon_chain(priv); 885 iwl_set_rxon_chain(priv);
886 iwl4965_commit_rxon(priv); 886 iwl4965_commit_rxon(priv);
887} 887}
888 888
@@ -1735,7 +1735,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
1735 memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN); 1735 memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
1736 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff; 1736 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
1737 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff; 1737 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
1738 iwl4965_set_rxon_chain(priv); 1738 iwl_set_rxon_chain(priv);
1739} 1739}
1740 1740
1741static int iwl4965_set_mode(struct iwl_priv *priv, int mode) 1741static int iwl4965_set_mode(struct iwl_priv *priv, int mode)
@@ -4496,163 +4496,6 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv,
4496 return added; 4496 return added;
4497} 4497}
4498 4498
4499static void iwl4965_init_hw_rates(struct iwl_priv *priv,
4500 struct ieee80211_rate *rates)
4501{
4502 int i;
4503
4504 for (i = 0; i < IWL_RATE_COUNT; i++) {
4505 rates[i].bitrate = iwl4965_rates[i].ieee * 5;
4506 rates[i].hw_value = i; /* Rate scaling will work on indexes */
4507 rates[i].hw_value_short = i;
4508 rates[i].flags = 0;
4509 if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) {
4510 /*
4511 * If CCK != 1M then set short preamble rate flag.
4512 */
4513 rates[i].flags |=
4514 (iwl4965_rates[i].plcp == IWL_RATE_1M_PLCP) ?
4515 0 : IEEE80211_RATE_SHORT_PREAMBLE;
4516 }
4517 }
4518}
4519
4520/**
4521 * iwl4965_init_geos - Initialize mac80211's geo/channel info based from eeprom
4522 */
4523int iwl4965_init_geos(struct iwl_priv *priv)
4524{
4525 struct iwl_channel_info *ch;
4526 struct ieee80211_supported_band *sband;
4527 struct ieee80211_channel *channels;
4528 struct ieee80211_channel *geo_ch;
4529 struct ieee80211_rate *rates;
4530 int i = 0;
4531
4532 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
4533 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
4534 IWL_DEBUG_INFO("Geography modes already initialized.\n");
4535 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
4536 return 0;
4537 }
4538
4539 channels = kzalloc(sizeof(struct ieee80211_channel) *
4540 priv->channel_count, GFP_KERNEL);
4541 if (!channels)
4542 return -ENOMEM;
4543
4544 rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_RATE_COUNT + 1)),
4545 GFP_KERNEL);
4546 if (!rates) {
4547 kfree(channels);
4548 return -ENOMEM;
4549 }
4550
4551 /* 5.2GHz channels start after the 2.4GHz channels */
4552 sband = &priv->bands[IEEE80211_BAND_5GHZ];
4553 sband->channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)];
4554 /* just OFDM */
4555 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
4556 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE;
4557
4558 iwl4965_init_ht_hw_capab(priv, &sband->ht_info, IEEE80211_BAND_5GHZ);
4559
4560 sband = &priv->bands[IEEE80211_BAND_2GHZ];
4561 sband->channels = channels;
4562 /* OFDM & CCK */
4563 sband->bitrates = rates;
4564 sband->n_bitrates = IWL_RATE_COUNT;
4565
4566 iwl4965_init_ht_hw_capab(priv, &sband->ht_info, IEEE80211_BAND_2GHZ);
4567
4568 priv->ieee_channels = channels;
4569 priv->ieee_rates = rates;
4570
4571 iwl4965_init_hw_rates(priv, rates);
4572
4573 for (i = 0; i < priv->channel_count; i++) {
4574 ch = &priv->channel_info[i];
4575
4576 /* FIXME: might be removed if scan is OK */
4577 if (!is_channel_valid(ch))
4578 continue;
4579
4580 if (is_channel_a_band(ch))
4581 sband = &priv->bands[IEEE80211_BAND_5GHZ];
4582 else
4583 sband = &priv->bands[IEEE80211_BAND_2GHZ];
4584
4585 geo_ch = &sband->channels[sband->n_channels++];
4586
4587 geo_ch->center_freq = ieee80211_channel_to_frequency(ch->channel);
4588 geo_ch->max_power = ch->max_power_avg;
4589 geo_ch->max_antenna_gain = 0xff;
4590 geo_ch->hw_value = ch->channel;
4591
4592 if (is_channel_valid(ch)) {
4593 if (!(ch->flags & EEPROM_CHANNEL_IBSS))
4594 geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
4595
4596 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
4597 geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
4598
4599 if (ch->flags & EEPROM_CHANNEL_RADAR)
4600 geo_ch->flags |= IEEE80211_CHAN_RADAR;
4601
4602 if (ch->max_power_avg > priv->max_channel_txpower_limit)
4603 priv->max_channel_txpower_limit =
4604 ch->max_power_avg;
4605 } else {
4606 geo_ch->flags |= IEEE80211_CHAN_DISABLED;
4607 }
4608
4609 /* Save flags for reg domain usage */
4610 geo_ch->orig_flags = geo_ch->flags;
4611
4612 IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0%X\n",
4613 ch->channel, geo_ch->center_freq,
4614 is_channel_a_band(ch) ? "5.2" : "2.4",
4615 geo_ch->flags & IEEE80211_CHAN_DISABLED ?
4616 "restricted" : "valid",
4617 geo_ch->flags);
4618 }
4619
4620 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
4621 priv->cfg->sku & IWL_SKU_A) {
4622 printk(KERN_INFO DRV_NAME
4623 ": Incorrectly detected BG card as ABG. Please send "
4624 "your PCI ID 0x%04X:0x%04X to maintainer.\n",
4625 priv->pci_dev->device, priv->pci_dev->subsystem_device);
4626 priv->cfg->sku &= ~IWL_SKU_A;
4627 }
4628
4629 printk(KERN_INFO DRV_NAME
4630 ": Tunable channels: %d 802.11bg, %d 802.11a channels\n",
4631 priv->bands[IEEE80211_BAND_2GHZ].n_channels,
4632 priv->bands[IEEE80211_BAND_5GHZ].n_channels);
4633
4634 if (priv->bands[IEEE80211_BAND_2GHZ].n_channels)
4635 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
4636 &priv->bands[IEEE80211_BAND_2GHZ];
4637 if (priv->bands[IEEE80211_BAND_5GHZ].n_channels)
4638 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
4639 &priv->bands[IEEE80211_BAND_5GHZ];
4640
4641 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
4642
4643 return 0;
4644}
4645
4646/*
4647 * iwl4965_free_geos - undo allocations in iwl4965_init_geos
4648 */
4649void iwl4965_free_geos(struct iwl_priv *priv)
4650{
4651 kfree(priv->ieee_channels);
4652 kfree(priv->ieee_rates);
4653 clear_bit(STATUS_GEO_CONFIGURED, &priv->status);
4654}
4655
4656/****************************************************************************** 4499/******************************************************************************
4657 * 4500 *
4658 * uCode download functions 4501 * uCode download functions
@@ -5807,7 +5650,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
5807 if (priv->current_ht_config.is_ht) 5650 if (priv->current_ht_config.is_ht)
5808 iwl4965_set_rxon_ht(priv, &priv->current_ht_config); 5651 iwl4965_set_rxon_ht(priv, &priv->current_ht_config);
5809#endif /* CONFIG_IWL4965_HT*/ 5652#endif /* CONFIG_IWL4965_HT*/
5810 iwl4965_set_rxon_chain(priv); 5653 iwl_set_rxon_chain(priv);
5811 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 5654 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
5812 5655
5813 IWL_DEBUG_ASSOC("assoc id %d beacon interval %d\n", 5656 IWL_DEBUG_ASSOC("assoc id %d beacon interval %d\n",
@@ -6153,7 +5996,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
6153 priv->staging_rxon.flags = 0; 5996 priv->staging_rxon.flags = 0;
6154#endif /* CONFIG_IWL4965_HT */ 5997#endif /* CONFIG_IWL4965_HT */
6155 5998
6156 iwlcore_set_rxon_channel(priv, conf->channel->band, 5999 iwl_set_rxon_channel(priv, conf->channel->band,
6157 ieee80211_frequency_to_channel(conf->channel->center_freq)); 6000 ieee80211_frequency_to_channel(conf->channel->center_freq));
6158 6001
6159 iwl4965_set_flags_for_phymode(priv, conf->channel->band); 6002 iwl4965_set_flags_for_phymode(priv, conf->channel->band);
@@ -6225,7 +6068,7 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
6225 IWL_WARNING("REPLY_RXON_TIMING failed - " 6068 IWL_WARNING("REPLY_RXON_TIMING failed - "
6226 "Attempting to continue.\n"); 6069 "Attempting to continue.\n");
6227 6070
6228 iwl4965_set_rxon_chain(priv); 6071 iwl_set_rxon_chain(priv);
6229 6072
6230 /* FIXME: what should be the assoc_id for AP? */ 6073 /* FIXME: what should be the assoc_id for AP? */
6231 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 6074 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
@@ -6437,7 +6280,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
6437 if (changes & BSS_CHANGED_HT) { 6280 if (changes & BSS_CHANGED_HT) {
6438 IWL_DEBUG_MAC80211("HT %d\n", bss_conf->assoc_ht); 6281 IWL_DEBUG_MAC80211("HT %d\n", bss_conf->assoc_ht);
6439 iwl4965_ht_conf(priv, bss_conf); 6282 iwl4965_ht_conf(priv, bss_conf);
6440 iwl4965_set_rxon_chain(priv); 6283 iwl_set_rxon_chain(priv);
6441 } 6284 }
6442 6285
6443 if (changes & BSS_CHANGED_ASSOC) { 6286 if (changes & BSS_CHANGED_ASSOC) {
@@ -6761,7 +6604,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
6761 spin_unlock_irqrestore(&priv->lock, flags); 6604 spin_unlock_irqrestore(&priv->lock, flags);
6762#endif /* CONFIG_IWL4965_HT */ 6605#endif /* CONFIG_IWL4965_HT */
6763 6606
6764 iwlcore_reset_qos(priv); 6607 iwl_reset_qos(priv);
6765 6608
6766 cancel_delayed_work(&priv->post_associate); 6609 cancel_delayed_work(&priv->post_associate);
6767 6610
@@ -6848,7 +6691,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
6848 IWL_DEBUG_MAC80211("leave\n"); 6691 IWL_DEBUG_MAC80211("leave\n");
6849 spin_unlock_irqrestore(&priv->lock, flags); 6692 spin_unlock_irqrestore(&priv->lock, flags);
6850 6693
6851 iwlcore_reset_qos(priv); 6694 iwl_reset_qos(priv);
6852 6695
6853 queue_work(priv->workqueue, &priv->post_associate.work); 6696 queue_work(priv->workqueue, &priv->post_associate.work);
6854 6697
@@ -7636,7 +7479,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
7636 pci_set_drvdata(pdev, NULL); 7479 pci_set_drvdata(pdev, NULL);
7637 7480
7638 iwl_free_channel_map(priv); 7481 iwl_free_channel_map(priv);
7639 iwl4965_free_geos(priv); 7482 iwlcore_free_geos(priv);
7640 7483
7641 if (priv->ibss_beacon) 7484 if (priv->ibss_beacon)
7642 dev_kfree_skb(priv->ibss_beacon); 7485 dev_kfree_skb(priv->ibss_beacon);