aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
authorAssaf Krauss <assaf.krauss@intel.com>2008-03-14 13:38:49 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-03-25 16:41:51 -0400
commitbf85ea4fbecab278c63f02fd102b33cc6cb21eb9 (patch)
tree11c997de3b8ecbdcb479ca143aa904f1be0dfeeb /drivers/net/wireless/iwlwifi/iwl4965-base.c
parent1d0a082d38decb62ceb3e26a4bb1a3ca78843a23 (diff)
iwlwifi: Probe Flow - Extracting hw and priv init
1. Extracting hw and priv initialization from probe function. 2. Moving some initialization functions to core module. Signed-off-by: Assaf Krauss <assaf.krauss@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.c577
1 files changed, 23 insertions, 554 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a8fa1bfa570..9cf1f204666 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -431,23 +431,6 @@ out:
431#endif 431#endif
432 432
433/** 433/**
434 * iwl4965_clear_stations_table - Clear the driver's station table
435 *
436 * NOTE: This does not clear or otherwise alter the device's station table.
437 */
438static void iwl4965_clear_stations_table(struct iwl_priv *priv)
439{
440 unsigned long flags;
441
442 spin_lock_irqsave(&priv->sta_lock, flags);
443
444 priv->num_stations = 0;
445 memset(priv->stations, 0, sizeof(priv->stations));
446
447 spin_unlock_irqrestore(&priv->sta_lock, flags);
448}
449
450/**
451 * iwl4965_add_station_flags - Add station to tables in driver and device 434 * iwl4965_add_station_flags - Add station to tables in driver and device
452 */ 435 */
453u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, 436u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr,
@@ -881,43 +864,6 @@ static int iwl4965_rxon_add_station(struct iwl_priv *priv,
881} 864}
882 865
883/** 866/**
884 * iwl4965_set_rxon_channel - Set the phymode and channel values in staging RXON
885 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
886 * @channel: Any channel valid for the requested phymode
887
888 * In addition to setting the staging RXON, priv->phymode is also set.
889 *
890 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
891 * in the staging RXON flag structure based on the phymode
892 */
893static int iwl4965_set_rxon_channel(struct iwl_priv *priv,
894 enum ieee80211_band band,
895 u16 channel)
896{
897 if (!iwl4965_get_channel_info(priv, band, channel)) {
898 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
899 channel, band);
900 return -EINVAL;
901 }
902
903 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
904 (priv->band == band))
905 return 0;
906
907 priv->staging_rxon.channel = cpu_to_le16(channel);
908 if (band == IEEE80211_BAND_5GHZ)
909 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
910 else
911 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
912
913 priv->band = band;
914
915 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
916
917 return 0;
918}
919
920/**
921 * iwl4965_check_rxon_cmd - validate RXON structure is valid 867 * iwl4965_check_rxon_cmd - validate RXON structure is valid
922 * 868 *
923 * NOTE: This is really only useful during development and can eventually 869 * NOTE: This is really only useful during development and can eventually
@@ -1186,7 +1132,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
1186 return rc; 1132 return rc;
1187 } 1133 }
1188 1134
1189 iwl4965_clear_stations_table(priv); 1135 iwlcore_clear_stations_table(priv);
1190 1136
1191#ifdef CONFIG_IWL4965_SENSITIVITY 1137#ifdef CONFIG_IWL4965_SENSITIVITY
1192 if (!priv->error_recovering) 1138 if (!priv->error_recovering)
@@ -1732,93 +1678,6 @@ static int iwl4965_send_qos_params_command(struct iwl_priv *priv,
1732 sizeof(struct iwl4965_qosparam_cmd), qos); 1678 sizeof(struct iwl4965_qosparam_cmd), qos);
1733} 1679}
1734 1680
1735static void iwl4965_reset_qos(struct iwl_priv *priv)
1736{
1737 u16 cw_min = 15;
1738 u16 cw_max = 1023;
1739 u8 aifs = 2;
1740 u8 is_legacy = 0;
1741 unsigned long flags;
1742 int i;
1743
1744 spin_lock_irqsave(&priv->lock, flags);
1745 priv->qos_data.qos_active = 0;
1746
1747 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) {
1748 if (priv->qos_data.qos_enable)
1749 priv->qos_data.qos_active = 1;
1750 if (!(priv->active_rate & 0xfff0)) {
1751 cw_min = 31;
1752 is_legacy = 1;
1753 }
1754 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
1755 if (priv->qos_data.qos_enable)
1756 priv->qos_data.qos_active = 1;
1757 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
1758 cw_min = 31;
1759 is_legacy = 1;
1760 }
1761
1762 if (priv->qos_data.qos_active)
1763 aifs = 3;
1764
1765 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
1766 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
1767 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
1768 priv->qos_data.def_qos_parm.ac[0].edca_txop = 0;
1769 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
1770
1771 if (priv->qos_data.qos_active) {
1772 i = 1;
1773 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
1774 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
1775 priv->qos_data.def_qos_parm.ac[i].aifsn = 7;
1776 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
1777 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1778
1779 i = 2;
1780 priv->qos_data.def_qos_parm.ac[i].cw_min =
1781 cpu_to_le16((cw_min + 1) / 2 - 1);
1782 priv->qos_data.def_qos_parm.ac[i].cw_max =
1783 cpu_to_le16(cw_max);
1784 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
1785 if (is_legacy)
1786 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1787 cpu_to_le16(6016);
1788 else
1789 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1790 cpu_to_le16(3008);
1791 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1792
1793 i = 3;
1794 priv->qos_data.def_qos_parm.ac[i].cw_min =
1795 cpu_to_le16((cw_min + 1) / 4 - 1);
1796 priv->qos_data.def_qos_parm.ac[i].cw_max =
1797 cpu_to_le16((cw_max + 1) / 2 - 1);
1798 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
1799 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1800 if (is_legacy)
1801 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1802 cpu_to_le16(3264);
1803 else
1804 priv->qos_data.def_qos_parm.ac[i].edca_txop =
1805 cpu_to_le16(1504);
1806 } else {
1807 for (i = 1; i < 4; i++) {
1808 priv->qos_data.def_qos_parm.ac[i].cw_min =
1809 cpu_to_le16(cw_min);
1810 priv->qos_data.def_qos_parm.ac[i].cw_max =
1811 cpu_to_le16(cw_max);
1812 priv->qos_data.def_qos_parm.ac[i].aifsn = aifs;
1813 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
1814 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
1815 }
1816 }
1817 IWL_DEBUG_QOS("set QoS to default \n");
1818
1819 spin_unlock_irqrestore(&priv->lock, flags);
1820}
1821
1822static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force) 1681static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
1823{ 1682{
1824 unsigned long flags; 1683 unsigned long flags;
@@ -2304,7 +2163,7 @@ static void iwl4965_set_flags_for_phymode(struct iwl_priv *priv,
2304 */ 2163 */
2305static void iwl4965_connection_init_rx_config(struct iwl_priv *priv) 2164static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
2306{ 2165{
2307 const struct iwl4965_channel_info *ch_info; 2166 const struct iwl_channel_info *ch_info;
2308 2167
2309 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 2168 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
2310 2169
@@ -2377,7 +2236,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
2377static int iwl4965_set_mode(struct iwl_priv *priv, int mode) 2236static int iwl4965_set_mode(struct iwl_priv *priv, int mode)
2378{ 2237{
2379 if (mode == IEEE80211_IF_TYPE_IBSS) { 2238 if (mode == IEEE80211_IF_TYPE_IBSS) {
2380 const struct iwl4965_channel_info *ch_info; 2239 const struct iwl_channel_info *ch_info;
2381 2240
2382 ch_info = iwl4965_get_channel_info(priv, 2241 ch_info = iwl4965_get_channel_info(priv,
2383 priv->band, 2242 priv->band,
@@ -2395,7 +2254,7 @@ static int iwl4965_set_mode(struct iwl_priv *priv, int mode)
2395 iwl4965_connection_init_rx_config(priv); 2254 iwl4965_connection_init_rx_config(priv);
2396 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 2255 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2397 2256
2398 iwl4965_clear_stations_table(priv); 2257 iwlcore_clear_stations_table(priv);
2399 2258
2400 /* dont commit rxon if rf-kill is on*/ 2259 /* dont commit rxon if rf-kill is on*/
2401 if (!iwl4965_is_ready_rf(priv)) 2260 if (!iwl4965_is_ready_rf(priv))
@@ -4999,308 +4858,6 @@ static irqreturn_t iwl4965_isr(int irq, void *data)
4999 return IRQ_NONE; 4858 return IRQ_NONE;
5000} 4859}
5001 4860
5002/************************** EEPROM BANDS ****************************
5003 *
5004 * The iwl4965_eeprom_band definitions below provide the mapping from the
5005 * EEPROM contents to the specific channel number supported for each
5006 * band.
5007 *
5008 * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3
5009 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
5010 * The specific geography and calibration information for that channel
5011 * is contained in the eeprom map itself.
5012 *
5013 * During init, we copy the eeprom information and channel map
5014 * information into priv->channel_info_24/52 and priv->channel_map_24/52
5015 *
5016 * channel_map_24/52 provides the index in the channel_info array for a
5017 * given channel. We have to have two separate maps as there is channel
5018 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
5019 * band_2
5020 *
5021 * A value of 0xff stored in the channel_map indicates that the channel
5022 * is not supported by the hardware at all.
5023 *
5024 * A value of 0xfe in the channel_map indicates that the channel is not
5025 * valid for Tx with the current hardware. This means that
5026 * while the system can tune and receive on a given channel, it may not
5027 * be able to associate or transmit any frames on that
5028 * channel. There is no corresponding channel information for that
5029 * entry.
5030 *
5031 *********************************************************************/
5032
5033/* 2.4 GHz */
5034static const u8 iwl4965_eeprom_band_1[14] = {
5035 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
5036};
5037
5038/* 5.2 GHz bands */
5039static const u8 iwl4965_eeprom_band_2[] = { /* 4915-5080MHz */
5040 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
5041};
5042
5043static const u8 iwl4965_eeprom_band_3[] = { /* 5170-5320MHz */
5044 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
5045};
5046
5047static const u8 iwl4965_eeprom_band_4[] = { /* 5500-5700MHz */
5048 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
5049};
5050
5051static const u8 iwl4965_eeprom_band_5[] = { /* 5725-5825MHz */
5052 145, 149, 153, 157, 161, 165
5053};
5054
5055static u8 iwl4965_eeprom_band_6[] = { /* 2.4 FAT channel */
5056 1, 2, 3, 4, 5, 6, 7
5057};
5058
5059static u8 iwl4965_eeprom_band_7[] = { /* 5.2 FAT channel */
5060 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
5061};
5062
5063static void iwl4965_init_band_reference(const struct iwl_priv *priv,
5064 int band,
5065 int *eeprom_ch_count,
5066 const struct iwl4965_eeprom_channel
5067 **eeprom_ch_info,
5068 const u8 **eeprom_ch_index)
5069{
5070 switch (band) {
5071 case 1: /* 2.4GHz band */
5072 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_1);
5073 *eeprom_ch_info = priv->eeprom.band_1_channels;
5074 *eeprom_ch_index = iwl4965_eeprom_band_1;
5075 break;
5076 case 2: /* 4.9GHz band */
5077 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_2);
5078 *eeprom_ch_info = priv->eeprom.band_2_channels;
5079 *eeprom_ch_index = iwl4965_eeprom_band_2;
5080 break;
5081 case 3: /* 5.2GHz band */
5082 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_3);
5083 *eeprom_ch_info = priv->eeprom.band_3_channels;
5084 *eeprom_ch_index = iwl4965_eeprom_band_3;
5085 break;
5086 case 4: /* 5.5GHz band */
5087 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_4);
5088 *eeprom_ch_info = priv->eeprom.band_4_channels;
5089 *eeprom_ch_index = iwl4965_eeprom_band_4;
5090 break;
5091 case 5: /* 5.7GHz band */
5092 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_5);
5093 *eeprom_ch_info = priv->eeprom.band_5_channels;
5094 *eeprom_ch_index = iwl4965_eeprom_band_5;
5095 break;
5096 case 6: /* 2.4GHz FAT channels */
5097 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_6);
5098 *eeprom_ch_info = priv->eeprom.band_24_channels;
5099 *eeprom_ch_index = iwl4965_eeprom_band_6;
5100 break;
5101 case 7: /* 5 GHz FAT channels */
5102 *eeprom_ch_count = ARRAY_SIZE(iwl4965_eeprom_band_7);
5103 *eeprom_ch_info = priv->eeprom.band_52_channels;
5104 *eeprom_ch_index = iwl4965_eeprom_band_7;
5105 break;
5106 default:
5107 BUG();
5108 return;
5109 }
5110}
5111
5112/**
5113 * iwl4965_get_channel_info - Find driver's private channel info
5114 *
5115 * Based on band and channel number.
5116 */
5117const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl_priv *priv,
5118 enum ieee80211_band band, u16 channel)
5119{
5120 int i;
5121
5122 switch (band) {
5123 case IEEE80211_BAND_5GHZ:
5124 for (i = 14; i < priv->channel_count; i++) {
5125 if (priv->channel_info[i].channel == channel)
5126 return &priv->channel_info[i];
5127 }
5128 break;
5129 case IEEE80211_BAND_2GHZ:
5130 if (channel >= 1 && channel <= 14)
5131 return &priv->channel_info[channel - 1];
5132 break;
5133 default:
5134 BUG();
5135 }
5136
5137 return NULL;
5138}
5139
5140#define CHECK_AND_PRINT(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
5141 ? # x " " : "")
5142
5143/**
5144 * iwl4965_init_channel_map - Set up driver's info for all possible channels
5145 */
5146static int iwl4965_init_channel_map(struct iwl_priv *priv)
5147{
5148 int eeprom_ch_count = 0;
5149 const u8 *eeprom_ch_index = NULL;
5150 const struct iwl4965_eeprom_channel *eeprom_ch_info = NULL;
5151 int band, ch;
5152 struct iwl4965_channel_info *ch_info;
5153
5154 if (priv->channel_count) {
5155 IWL_DEBUG_INFO("Channel map already initialized.\n");
5156 return 0;
5157 }
5158
5159 if (priv->eeprom.version < 0x2f) {
5160 IWL_WARNING("Unsupported EEPROM version: 0x%04X\n",
5161 priv->eeprom.version);
5162 return -EINVAL;
5163 }
5164
5165 IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n");
5166
5167 priv->channel_count =
5168 ARRAY_SIZE(iwl4965_eeprom_band_1) +
5169 ARRAY_SIZE(iwl4965_eeprom_band_2) +
5170 ARRAY_SIZE(iwl4965_eeprom_band_3) +
5171 ARRAY_SIZE(iwl4965_eeprom_band_4) +
5172 ARRAY_SIZE(iwl4965_eeprom_band_5);
5173
5174 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
5175
5176 priv->channel_info = kzalloc(sizeof(struct iwl4965_channel_info) *
5177 priv->channel_count, GFP_KERNEL);
5178 if (!priv->channel_info) {
5179 IWL_ERROR("Could not allocate channel_info\n");
5180 priv->channel_count = 0;
5181 return -ENOMEM;
5182 }
5183
5184 ch_info = priv->channel_info;
5185
5186 /* Loop through the 5 EEPROM bands adding them in order to the
5187 * channel map we maintain (that contains additional information than
5188 * what just in the EEPROM) */
5189 for (band = 1; band <= 5; band++) {
5190
5191 iwl4965_init_band_reference(priv, band, &eeprom_ch_count,
5192 &eeprom_ch_info, &eeprom_ch_index);
5193
5194 /* Loop through each band adding each of the channels */
5195 for (ch = 0; ch < eeprom_ch_count; ch++) {
5196 ch_info->channel = eeprom_ch_index[ch];
5197 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
5198 IEEE80211_BAND_5GHZ;
5199
5200 /* permanently store EEPROM's channel regulatory flags
5201 * and max power in channel info database. */
5202 ch_info->eeprom = eeprom_ch_info[ch];
5203
5204 /* Copy the run-time flags so they are there even on
5205 * invalid channels */
5206 ch_info->flags = eeprom_ch_info[ch].flags;
5207
5208 if (!(is_channel_valid(ch_info))) {
5209 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - "
5210 "No traffic\n",
5211 ch_info->channel,
5212 ch_info->flags,
5213 is_channel_a_band(ch_info) ?
5214 "5.2" : "2.4");
5215 ch_info++;
5216 continue;
5217 }
5218
5219 /* Initialize regulatory-based run-time data */
5220 ch_info->max_power_avg = ch_info->curr_txpow =
5221 eeprom_ch_info[ch].max_power_avg;
5222 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
5223 ch_info->min_power = 0;
5224
5225 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
5226 " %ddBm): Ad-Hoc %ssupported\n",
5227 ch_info->channel,
5228 is_channel_a_band(ch_info) ?
5229 "5.2" : "2.4",
5230 CHECK_AND_PRINT(VALID),
5231 CHECK_AND_PRINT(IBSS),
5232 CHECK_AND_PRINT(ACTIVE),
5233 CHECK_AND_PRINT(RADAR),
5234 CHECK_AND_PRINT(WIDE),
5235 CHECK_AND_PRINT(NARROW),
5236 CHECK_AND_PRINT(DFS),
5237 eeprom_ch_info[ch].flags,
5238 eeprom_ch_info[ch].max_power_avg,
5239 ((eeprom_ch_info[ch].
5240 flags & EEPROM_CHANNEL_IBSS)
5241 && !(eeprom_ch_info[ch].
5242 flags & EEPROM_CHANNEL_RADAR))
5243 ? "" : "not ");
5244
5245 /* Set the user_txpower_limit to the highest power
5246 * supported by any channel */
5247 if (eeprom_ch_info[ch].max_power_avg >
5248 priv->user_txpower_limit)
5249 priv->user_txpower_limit =
5250 eeprom_ch_info[ch].max_power_avg;
5251
5252 ch_info++;
5253 }
5254 }
5255
5256 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */
5257 for (band = 6; band <= 7; band++) {
5258 enum ieee80211_band ieeeband;
5259 u8 fat_extension_chan;
5260
5261 iwl4965_init_band_reference(priv, band, &eeprom_ch_count,
5262 &eeprom_ch_info, &eeprom_ch_index);
5263
5264 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
5265 ieeeband = (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
5266
5267 /* Loop through each band adding each of the channels */
5268 for (ch = 0; ch < eeprom_ch_count; ch++) {
5269
5270 if ((band == 6) &&
5271 ((eeprom_ch_index[ch] == 5) ||
5272 (eeprom_ch_index[ch] == 6) ||
5273 (eeprom_ch_index[ch] == 7)))
5274 fat_extension_chan = HT_IE_EXT_CHANNEL_MAX;
5275 else
5276 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE;
5277
5278 /* Set up driver's info for lower half */
5279 iwl4965_set_fat_chan_info(priv, ieeeband,
5280 eeprom_ch_index[ch],
5281 &(eeprom_ch_info[ch]),
5282 fat_extension_chan);
5283
5284 /* Set up driver's info for upper half */
5285 iwl4965_set_fat_chan_info(priv, ieeeband,
5286 (eeprom_ch_index[ch] + 4),
5287 &(eeprom_ch_info[ch]),
5288 HT_IE_EXT_CHANNEL_BELOW);
5289 }
5290 }
5291
5292 return 0;
5293}
5294
5295/*
5296 * iwl4965_free_channel_map - undo allocations in iwl4965_init_channel_map
5297 */
5298static void iwl4965_free_channel_map(struct iwl_priv *priv)
5299{
5300 kfree(priv->channel_info);
5301 priv->channel_count = 0;
5302}
5303
5304/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 4861/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
5305 * sending probe req. This should be set long enough to hear probe responses 4862 * sending probe req. This should be set long enough to hear probe responses
5306 * from more than one AP. */ 4863 * from more than one AP. */
@@ -5364,7 +4921,7 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv,
5364{ 4921{
5365 const struct ieee80211_channel *channels = NULL; 4922 const struct ieee80211_channel *channels = NULL;
5366 const struct ieee80211_supported_band *sband; 4923 const struct ieee80211_supported_band *sband;
5367 const struct iwl4965_channel_info *ch_info; 4924 const struct iwl_channel_info *ch_info;
5368 u16 passive_dwell = 0; 4925 u16 passive_dwell = 0;
5369 u16 active_dwell = 0; 4926 u16 active_dwell = 0;
5370 int added, i; 4927 int added, i;
@@ -5468,9 +5025,9 @@ static void iwl4965_init_hw_rates(struct iwl_priv *priv,
5468/** 5025/**
5469 * iwl4965_init_geos - Initialize mac80211's geo/channel info based from eeprom 5026 * iwl4965_init_geos - Initialize mac80211's geo/channel info based from eeprom
5470 */ 5027 */
5471static int iwl4965_init_geos(struct iwl_priv *priv) 5028int iwl4965_init_geos(struct iwl_priv *priv)
5472{ 5029{
5473 struct iwl4965_channel_info *ch; 5030 struct iwl_channel_info *ch;
5474 struct ieee80211_supported_band *sband; 5031 struct ieee80211_supported_band *sband;
5475 struct ieee80211_channel *channels; 5032 struct ieee80211_channel *channels;
5476 struct ieee80211_channel *geo_ch; 5033 struct ieee80211_channel *geo_ch;
@@ -5498,7 +5055,7 @@ static int iwl4965_init_geos(struct iwl_priv *priv)
5498 5055
5499 /* 5.2GHz channels start after the 2.4GHz channels */ 5056 /* 5.2GHz channels start after the 2.4GHz channels */
5500 sband = &priv->bands[IEEE80211_BAND_5GHZ]; 5057 sband = &priv->bands[IEEE80211_BAND_5GHZ];
5501 sband->channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; 5058 sband->channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)];
5502 /* just OFDM */ 5059 /* just OFDM */
5503 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; 5060 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
5504 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; 5061 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE;
@@ -5590,7 +5147,7 @@ static int iwl4965_init_geos(struct iwl_priv *priv)
5590/* 5147/*
5591 * iwl4965_free_geos - undo allocations in iwl4965_init_geos 5148 * iwl4965_free_geos - undo allocations in iwl4965_init_geos
5592 */ 5149 */
5593static void iwl4965_free_geos(struct iwl_priv *priv) 5150void iwl4965_free_geos(struct iwl_priv *priv)
5594{ 5151{
5595 kfree(priv->ieee_channels); 5152 kfree(priv->ieee_channels);
5596 kfree(priv->ieee_rates); 5153 kfree(priv->ieee_rates);
@@ -6233,7 +5790,7 @@ static void iwl4965_alive_start(struct iwl_priv *priv)
6233 goto restart; 5790 goto restart;
6234 } 5791 }
6235 5792
6236 iwl4965_clear_stations_table(priv); 5793 iwlcore_clear_stations_table(priv);
6237 5794
6238 rc = iwl4965_alive_notify(priv); 5795 rc = iwl4965_alive_notify(priv);
6239 if (rc) { 5796 if (rc) {
@@ -6310,7 +5867,7 @@ static void __iwl4965_down(struct iwl_priv *priv)
6310 if (!exit_pending) 5867 if (!exit_pending)
6311 set_bit(STATUS_EXIT_PENDING, &priv->status); 5868 set_bit(STATUS_EXIT_PENDING, &priv->status);
6312 5869
6313 iwl4965_clear_stations_table(priv); 5870 iwlcore_clear_stations_table(priv);
6314 5871
6315 /* Unblock any waiting calls */ 5872 /* Unblock any waiting calls */
6316 wake_up_interruptible_all(&priv->wait_command_queue); 5873 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -6465,7 +6022,7 @@ static int __iwl4965_up(struct iwl_priv *priv)
6465 6022
6466 for (i = 0; i < MAX_HW_RESTARTS; i++) { 6023 for (i = 0; i < MAX_HW_RESTARTS; i++) {
6467 6024
6468 iwl4965_clear_stations_table(priv); 6025 iwlcore_clear_stations_table(priv);
6469 6026
6470 /* load bootstrap state machine, 6027 /* load bootstrap state machine,
6471 * load bootstrap program into processor's memory, 6028 * load bootstrap program into processor's memory,
@@ -6911,7 +6468,7 @@ static void iwl4965_bg_post_associate(struct work_struct *data)
6911 case IEEE80211_IF_TYPE_IBSS: 6468 case IEEE80211_IF_TYPE_IBSS:
6912 6469
6913 /* clear out the station table */ 6470 /* clear out the station table */
6914 iwl4965_clear_stations_table(priv); 6471 iwlcore_clear_stations_table(priv);
6915 6472
6916 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); 6473 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0);
6917 iwl4965_rxon_add_station(priv, priv->bssid, 0); 6474 iwl4965_rxon_add_station(priv, priv->bssid, 0);
@@ -7169,7 +6726,7 @@ static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
7169static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 6726static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
7170{ 6727{
7171 struct iwl_priv *priv = hw->priv; 6728 struct iwl_priv *priv = hw->priv;
7172 const struct iwl4965_channel_info *ch_info; 6729 const struct iwl_channel_info *ch_info;
7173 unsigned long flags; 6730 unsigned long flags;
7174 int ret = 0; 6731 int ret = 0;
7175 6732
@@ -7215,7 +6772,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7215 priv->staging_rxon.flags = 0; 6772 priv->staging_rxon.flags = 0;
7216#endif /* CONFIG_IWL4965_HT */ 6773#endif /* CONFIG_IWL4965_HT */
7217 6774
7218 iwl4965_set_rxon_channel(priv, conf->channel->band, 6775 iwlcore_set_rxon_channel(priv, conf->channel->band,
7219 ieee80211_frequency_to_channel(conf->channel->center_freq)); 6776 ieee80211_frequency_to_channel(conf->channel->center_freq));
7220 6777
7221 iwl4965_set_flags_for_phymode(priv, conf->channel->band); 6778 iwl4965_set_flags_for_phymode(priv, conf->channel->band);
@@ -7736,7 +7293,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
7736 spin_unlock_irqrestore(&priv->lock, flags); 7293 spin_unlock_irqrestore(&priv->lock, flags);
7737#endif /* CONFIG_IWL4965_HT */ 7294#endif /* CONFIG_IWL4965_HT */
7738 7295
7739 iwl4965_reset_qos(priv); 7296 iwlcore_reset_qos(priv);
7740 7297
7741 cancel_delayed_work(&priv->post_associate); 7298 cancel_delayed_work(&priv->post_associate);
7742 7299
@@ -7825,7 +7382,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
7825 IWL_DEBUG_MAC80211("leave\n"); 7382 IWL_DEBUG_MAC80211("leave\n");
7826 spin_unlock_irqrestore(&priv->lock, flags); 7383 spin_unlock_irqrestore(&priv->lock, flags);
7827 7384
7828 iwl4965_reset_qos(priv); 7385 iwlcore_reset_qos(priv);
7829 7386
7830 queue_work(priv->workqueue, &priv->post_associate.work); 7387 queue_work(priv->workqueue, &priv->post_associate.work);
7831 7388
@@ -8517,7 +8074,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8517 struct iwl_priv *priv; 8074 struct iwl_priv *priv;
8518 struct ieee80211_hw *hw; 8075 struct ieee80211_hw *hw;
8519 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 8076 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
8520 int i;
8521 DECLARE_MAC_BUF(mac); 8077 DECLARE_MAC_BUF(mac);
8522 8078
8523 /************************ 8079 /************************
@@ -8634,93 +8190,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8634 * 6. Setup hw/priv 8190 * 6. Setup hw/priv
8635 *******************/ 8191 *******************/
8636 8192
8637 /* Tell mac80211 and its clients (e.g. Wireless Extensions) 8193 err = iwl_setup(priv);
8638 * the range of signal quality values that we'll provide. 8194 if (err)
8639 * Negative values for level/noise indicate that we'll provide dBm.
8640 * For WE, at least, non-0 values here *enable* display of values
8641 * in app (iwconfig). */
8642 hw->max_rssi = -20; /* signal level, negative indicates dBm */
8643 hw->max_noise = -20; /* noise level, negative indicates dBm */
8644 hw->max_signal = 100; /* link quality indication (%) */
8645
8646 /* Tell mac80211 our Tx characteristics */
8647 hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE;
8648
8649 /* Default value; 4 EDCA QOS priorities */
8650 hw->queues = 4;
8651#ifdef CONFIG_IWL4965_HT
8652 /* Enhanced value; more queues, to support 11n aggregation */
8653 hw->queues = 16;
8654#endif /* CONFIG_IWL4965_HT */
8655
8656 hw->rate_control_algorithm = "iwl-4965-rs";
8657 priv->antenna = (enum iwl4965_antenna)iwl4965_mod_params.antenna;
8658 priv->retry_rate = 1;
8659 priv->ibss_beacon = NULL;
8660
8661 spin_lock_init(&priv->lock);
8662 spin_lock_init(&priv->power_data.lock);
8663 spin_lock_init(&priv->sta_lock);
8664 spin_lock_init(&priv->hcmd_lock);
8665 spin_lock_init(&priv->lq_mngr.lock);
8666
8667 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
8668 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
8669
8670 INIT_LIST_HEAD(&priv->free_frames);
8671
8672 mutex_init(&priv->mutex);
8673
8674 /* Clear the driver's (not device's) station table */
8675 iwl4965_clear_stations_table(priv);
8676
8677 priv->data_retry_limit = -1;
8678 priv->ieee_channels = NULL;
8679 priv->ieee_rates = NULL;
8680 priv->band = IEEE80211_BAND_2GHZ;
8681
8682 priv->iw_mode = IEEE80211_IF_TYPE_STA;
8683
8684 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
8685 priv->valid_antenna = 0x7; /* assume all 3 connected */
8686 priv->ps_mode = IWL_MIMO_PS_NONE;
8687
8688 /* Choose which receivers/antennas to use */
8689 iwl4965_set_rxon_chain(priv);
8690
8691 iwl4965_reset_qos(priv);
8692
8693 priv->qos_data.qos_active = 0;
8694 priv->qos_data.qos_cap.val = 0;
8695
8696 iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
8697
8698 priv->rates_mask = IWL_RATES_MASK;
8699 /* If power management is turned on, default to AC mode */
8700 priv->power_mode = IWL_POWER_AC;
8701 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
8702
8703 err = iwl4965_init_channel_map(priv);
8704 if (err) {
8705 IWL_ERROR("initializing regulatory failed: %d\n", err);
8706 goto out_unset_hw_settings; 8195 goto out_unset_hw_settings;
8707 } 8196 /* At this point both hw and priv are initialized. */
8708
8709 err = iwl4965_init_geos(priv);
8710 if (err) {
8711 IWL_ERROR("initializing geos failed: %d\n", err);
8712 goto out_free_channel_map;
8713 }
8714
8715 iwl4965_rate_control_register(priv->hw);
8716 err = ieee80211_register_hw(priv->hw);
8717 if (err) {
8718 IWL_ERROR("Failed to register network device (error %d)\n", err);
8719 goto out_free_geos;
8720 }
8721
8722 priv->hw->conf.beacon_int = 100;
8723 priv->mac80211_registered = 1;
8724 8197
8725 /********************************** 8198 /**********************************
8726 * 7. Initialize module parameters 8199 * 7. Initialize module parameters
@@ -8743,7 +8216,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8743 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); 8216 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8744 if (err) { 8217 if (err) {
8745 IWL_ERROR("failed to create sysfs device attributes\n"); 8218 IWL_ERROR("failed to create sysfs device attributes\n");
8746 goto out_free_geos; 8219 goto out_unset_hw_settings;
8747 } 8220 }
8748 8221
8749 err = iwl_dbgfs_register(priv, DRV_NAME); 8222 err = iwl_dbgfs_register(priv, DRV_NAME);
@@ -8765,10 +8238,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8765 8238
8766 out_remove_sysfs: 8239 out_remove_sysfs:
8767 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 8240 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8768 out_free_geos:
8769 iwl4965_free_geos(priv);
8770 out_free_channel_map:
8771 iwl4965_free_channel_map(priv);
8772 out_unset_hw_settings: 8241 out_unset_hw_settings:
8773 iwl4965_unset_hw_setting(priv); 8242 iwl4965_unset_hw_setting(priv);
8774 out_iounmap: 8243 out_iounmap:
@@ -8817,7 +8286,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8817 iwl4965_hw_txq_ctx_free(priv); 8286 iwl4965_hw_txq_ctx_free(priv);
8818 8287
8819 iwl4965_unset_hw_setting(priv); 8288 iwl4965_unset_hw_setting(priv);
8820 iwl4965_clear_stations_table(priv); 8289 iwlcore_clear_stations_table(priv);
8821 8290
8822 if (priv->mac80211_registered) { 8291 if (priv->mac80211_registered) {
8823 ieee80211_unregister_hw(priv->hw); 8292 ieee80211_unregister_hw(priv->hw);
@@ -8838,7 +8307,7 @@ static void iwl4965_pci_remove(struct pci_dev *pdev)
8838 pci_disable_device(pdev); 8307 pci_disable_device(pdev);
8839 pci_set_drvdata(pdev, NULL); 8308 pci_set_drvdata(pdev, NULL);
8840 8309
8841 iwl4965_free_channel_map(priv); 8310 iwl_free_channel_map(priv);
8842 iwl4965_free_geos(priv); 8311 iwl4965_free_geos(priv);
8843 8312
8844 if (priv->ibss_beacon) 8313 if (priv->ibss_beacon)