aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c144
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.h27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c178
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c356
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c577
7 files changed, 677 insertions, 623 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 2e54dae95751..8b2d04ed43d6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -105,6 +105,90 @@ static const u16 default_tid_to_tx_fifo[] = {
105 105
106#endif /*CONFIG_IWL4965_HT */ 106#endif /*CONFIG_IWL4965_HT */
107 107
108static int iwl4965_init_drv(struct iwl_priv *priv)
109{
110 int ret;
111 int i;
112
113 priv->antenna = (enum iwl4965_antenna)iwl4965_mod_params.antenna;
114 priv->retry_rate = 1;
115 priv->ibss_beacon = NULL;
116
117 spin_lock_init(&priv->lock);
118 spin_lock_init(&priv->power_data.lock);
119 spin_lock_init(&priv->sta_lock);
120 spin_lock_init(&priv->hcmd_lock);
121 spin_lock_init(&priv->lq_mngr.lock);
122
123 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
124 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
125
126 INIT_LIST_HEAD(&priv->free_frames);
127
128 mutex_init(&priv->mutex);
129
130 /* Clear the driver's (not device's) station table */
131 iwlcore_clear_stations_table(priv);
132
133 priv->data_retry_limit = -1;
134 priv->ieee_channels = NULL;
135 priv->ieee_rates = NULL;
136 priv->band = IEEE80211_BAND_2GHZ;
137
138 priv->iw_mode = IEEE80211_IF_TYPE_STA;
139
140 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
141 priv->valid_antenna = 0x7; /* assume all 3 connected */
142 priv->ps_mode = IWL_MIMO_PS_NONE;
143
144 /* Choose which receivers/antennas to use */
145 iwl4965_set_rxon_chain(priv);
146
147 iwlcore_reset_qos(priv);
148
149 priv->qos_data.qos_active = 0;
150 priv->qos_data.qos_cap.val = 0;
151
152 iwlcore_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
153
154 priv->rates_mask = IWL_RATES_MASK;
155 /* If power management is turned on, default to AC mode */
156 priv->power_mode = IWL_POWER_AC;
157 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
158
159 ret = iwl_init_channel_map(priv);
160 if (ret) {
161 IWL_ERROR("initializing regulatory failed: %d\n", ret);
162 goto err;
163 }
164
165 ret = iwl4965_init_geos(priv);
166 if (ret) {
167 IWL_ERROR("initializing geos failed: %d\n", ret);
168 goto err_free_channel_map;
169 }
170
171 iwl4965_rate_control_register(priv->hw);
172 ret = ieee80211_register_hw(priv->hw);
173 if (ret) {
174 IWL_ERROR("Failed to register network device (error %d)\n",
175 ret);
176 goto err_free_geos;
177 }
178
179 priv->hw->conf.beacon_int = 100;
180 priv->mac80211_registered = 1;
181
182 return 0;
183
184err_free_geos:
185 iwl4965_free_geos(priv);
186err_free_channel_map:
187 iwl_free_channel_map(priv);
188err:
189 return ret;
190}
191
108static int is_fat_channel(__le32 rxon_flags) 192static int is_fat_channel(__le32 rxon_flags)
109{ 193{
110 return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) || 194 return (rxon_flags & RXON_FLG_CHANNEL_MODE_PURE_40_MSK) ||
@@ -391,55 +475,6 @@ static int iwl4965_kw_alloc(struct iwl_priv *priv)
391 return 0; 475 return 0;
392} 476}
393 477
394#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
395 ? # x " " : "")
396
397/**
398 * iwl4965_set_fat_chan_info - Copy fat channel info into driver's priv.
399 *
400 * Does not set up a command, or touch hardware.
401 */
402int iwl4965_set_fat_chan_info(struct iwl_priv *priv,
403 enum ieee80211_band band, u16 channel,
404 const struct iwl4965_eeprom_channel *eeprom_ch,
405 u8 fat_extension_channel)
406{
407 struct iwl4965_channel_info *ch_info;
408
409 ch_info = (struct iwl4965_channel_info *)
410 iwl4965_get_channel_info(priv, band, channel);
411
412 if (!is_channel_valid(ch_info))
413 return -1;
414
415 IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x"
416 " %ddBm): Ad-Hoc %ssupported\n",
417 ch_info->channel,
418 is_channel_a_band(ch_info) ?
419 "5.2" : "2.4",
420 CHECK_AND_PRINT(IBSS),
421 CHECK_AND_PRINT(ACTIVE),
422 CHECK_AND_PRINT(RADAR),
423 CHECK_AND_PRINT(WIDE),
424 CHECK_AND_PRINT(NARROW),
425 CHECK_AND_PRINT(DFS),
426 eeprom_ch->flags,
427 eeprom_ch->max_power_avg,
428 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
429 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
430 "" : "not ");
431
432 ch_info->fat_eeprom = *eeprom_ch;
433 ch_info->fat_max_power_avg = eeprom_ch->max_power_avg;
434 ch_info->fat_curr_txpow = eeprom_ch->max_power_avg;
435 ch_info->fat_min_power = 0;
436 ch_info->fat_scan_power = eeprom_ch->max_power_avg;
437 ch_info->fat_flags = eeprom_ch->flags;
438 ch_info->fat_extension_channel = fat_extension_channel;
439
440 return 0;
441}
442
443/** 478/**
444 * iwl4965_kw_free - Free the "keep warm" buffer 479 * iwl4965_kw_free - Free the "keep warm" buffer
445 */ 480 */
@@ -2015,11 +2050,11 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage,
2015 return comp; 2050 return comp;
2016} 2051}
2017 2052
2018static const struct iwl4965_channel_info * 2053static const struct iwl_channel_info *
2019iwl4965_get_channel_txpower_info(struct iwl_priv *priv, 2054iwl4965_get_channel_txpower_info(struct iwl_priv *priv,
2020 enum ieee80211_band band, u16 channel) 2055 enum ieee80211_band band, u16 channel)
2021{ 2056{
2022 const struct iwl4965_channel_info *ch_info; 2057 const struct iwl_channel_info *ch_info;
2023 2058
2024 ch_info = iwl4965_get_channel_info(priv, band, channel); 2059 ch_info = iwl4965_get_channel_info(priv, band, channel);
2025 2060
@@ -2438,7 +2473,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
2438 s32 txatten_grp = CALIB_CH_GROUP_MAX; 2473 s32 txatten_grp = CALIB_CH_GROUP_MAX;
2439 int i; 2474 int i;
2440 int c; 2475 int c;
2441 const struct iwl4965_channel_info *ch_info = NULL; 2476 const struct iwl_channel_info *ch_info = NULL;
2442 struct iwl4965_eeprom_calib_ch_info ch_eeprom_info; 2477 struct iwl4965_eeprom_calib_ch_info ch_eeprom_info;
2443 const struct iwl4965_eeprom_calib_measure *measurement; 2478 const struct iwl4965_eeprom_calib_measure *measurement;
2444 s16 voltage; 2479 s16 voltage;
@@ -2725,7 +2760,7 @@ int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
2725 u8 is_fat = 0; 2760 u8 is_fat = 0;
2726 u8 ctrl_chan_high = 0; 2761 u8 ctrl_chan_high = 0;
2727 struct iwl4965_channel_switch_cmd cmd = { 0 }; 2762 struct iwl4965_channel_switch_cmd cmd = { 0 };
2728 const struct iwl4965_channel_info *ch_info; 2763 const struct iwl_channel_info *ch_info;
2729 2764
2730 band = priv->band == IEEE80211_BAND_2GHZ; 2765 band = priv->band == IEEE80211_BAND_2GHZ;
2731 2766
@@ -4471,7 +4506,7 @@ static u8 iwl4965_is_channel_extension(struct iwl_priv *priv,
4471 enum ieee80211_band band, 4506 enum ieee80211_band band,
4472 u16 channel, u8 extension_chan_offset) 4507 u16 channel, u8 extension_chan_offset)
4473{ 4508{
4474 const struct iwl4965_channel_info *ch_info; 4509 const struct iwl_channel_info *ch_info;
4475 4510
4476 ch_info = iwl4965_get_channel_info(priv, band, channel); 4511 ch_info = iwl4965_get_channel_info(priv, band, channel);
4477 if (!is_channel_valid(ch_info)) 4512 if (!is_channel_valid(ch_info))
@@ -4848,6 +4883,7 @@ void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv)
4848} 4883}
4849 4884
4850static struct iwl_lib_ops iwl4965_lib = { 4885static struct iwl_lib_ops iwl4965_lib = {
4886 .init_drv = iwl4965_init_drv,
4851 .eeprom_ops = { 4887 .eeprom_ops = {
4852 .verify_signature = iwlcore_eeprom_verify_signature, 4888 .verify_signature = iwlcore_eeprom_verify_signature,
4853 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 4889 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h
index 1480e1b698a4..7baed4db2f3f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.h
@@ -197,7 +197,7 @@ enum {
197 */ 197 */
198#define IWL4965_MAX_RATE (33) 198#define IWL4965_MAX_RATE (33)
199 199
200struct iwl4965_channel_info { 200struct iwl_channel_info {
201 struct iwl4965_channel_tgd_info tgd; 201 struct iwl4965_channel_tgd_info tgd;
202 struct iwl4965_channel_tgh_info tgh; 202 struct iwl4965_channel_tgh_info tgh;
203 struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */ 203 struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */
@@ -669,6 +669,8 @@ extern void iwl4965_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *sk
669 u32 decrypt_res, 669 u32 decrypt_res,
670 struct ieee80211_rx_status *stats); 670 struct ieee80211_rx_status *stats);
671extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr); 671extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
672int iwl4965_init_geos(struct iwl_priv *priv);
673void iwl4965_free_geos(struct iwl_priv *priv);
672 674
673extern const u8 iwl4965_broadcast_addr[ETH_ALEN]; 675extern const u8 iwl4965_broadcast_addr[ETH_ALEN];
674 676
@@ -755,11 +757,6 @@ extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
755extern void iwl4965_chain_noise_reset(struct iwl_priv *priv); 757extern void iwl4965_chain_noise_reset(struct iwl_priv *priv);
756extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags, 758extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags,
757 u8 force); 759 u8 force);
758extern int iwl4965_set_fat_chan_info(struct iwl_priv *priv,
759 enum ieee80211_band band,
760 u16 channel,
761 const struct iwl4965_eeprom_channel *eeprom_ch,
762 u8 fat_extension_channel);
763extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv); 760extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
764extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, 761extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv,
765 u32 rate_n_flags, 762 u32 rate_n_flags,
@@ -995,7 +992,7 @@ struct iwl_priv {
995 992
996 /* we allocate array of iwl4965_channel_info for NIC's valid channels. 993 /* we allocate array of iwl4965_channel_info for NIC's valid channels.
997 * Access via channel # using indirect index array */ 994 * Access via channel # using indirect index array */
998 struct iwl4965_channel_info *channel_info; /* channel info array */ 995 struct iwl_channel_info *channel_info; /* channel info array */
999 u8 channel_count; /* # of channels */ 996 u8 channel_count; /* # of channels */
1000 997
1001 /* each calibration channel group in the EEPROM has a derived 998 /* each calibration channel group in the EEPROM has a derived
@@ -1229,44 +1226,44 @@ static inline int iwl4965_is_associated(struct iwl_priv *priv)
1229 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 1226 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1230} 1227}
1231 1228
1232static inline int is_channel_valid(const struct iwl4965_channel_info *ch_info) 1229static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
1233{ 1230{
1234 if (ch_info == NULL) 1231 if (ch_info == NULL)
1235 return 0; 1232 return 0;
1236 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; 1233 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
1237} 1234}
1238 1235
1239static inline int is_channel_narrow(const struct iwl4965_channel_info *ch_info) 1236static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
1240{ 1237{
1241 return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0; 1238 return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
1242} 1239}
1243 1240
1244static inline int is_channel_radar(const struct iwl4965_channel_info *ch_info) 1241static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
1245{ 1242{
1246 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; 1243 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
1247} 1244}
1248 1245
1249static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info) 1246static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
1250{ 1247{
1251 return ch_info->band == IEEE80211_BAND_5GHZ; 1248 return ch_info->band == IEEE80211_BAND_5GHZ;
1252} 1249}
1253 1250
1254static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info) 1251static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
1255{ 1252{
1256 return ch_info->band == IEEE80211_BAND_2GHZ; 1253 return ch_info->band == IEEE80211_BAND_2GHZ;
1257} 1254}
1258 1255
1259static inline int is_channel_passive(const struct iwl4965_channel_info *ch) 1256static inline int is_channel_passive(const struct iwl_channel_info *ch)
1260{ 1257{
1261 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; 1258 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1262} 1259}
1263 1260
1264static inline int is_channel_ibss(const struct iwl4965_channel_info *ch) 1261static inline int is_channel_ibss(const struct iwl_channel_info *ch)
1265{ 1262{
1266 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 1263 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1267} 1264}
1268 1265
1269extern const struct iwl4965_channel_info *iwl4965_get_channel_info( 1266extern const struct iwl_channel_info *iwl4965_get_channel_info(
1270 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); 1267 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
1271 1268
1272/* Requires full declaration of iwl_priv before including */ 1269/* Requires full declaration of iwl_priv before including */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 244318af53fc..0e9c3b3d98ce 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -71,3 +71,181 @@ out:
71} 71}
72EXPORT_SYMBOL(iwl_alloc_all); 72EXPORT_SYMBOL(iwl_alloc_all);
73 73
74/**
75 * iwlcore_clear_stations_table - Clear the driver's station table
76 *
77 * NOTE: This does not clear or otherwise alter the device's station table.
78 */
79void iwlcore_clear_stations_table(struct iwl_priv *priv)
80{
81 unsigned long flags;
82
83 spin_lock_irqsave(&priv->sta_lock, flags);
84
85 priv->num_stations = 0;
86 memset(priv->stations, 0, sizeof(priv->stations));
87
88 spin_unlock_irqrestore(&priv->sta_lock, flags);
89}
90EXPORT_SYMBOL(iwlcore_clear_stations_table);
91
92void iwlcore_reset_qos(struct iwl_priv *priv)
93{
94 u16 cw_min = 15;
95 u16 cw_max = 1023;
96 u8 aifs = 2;
97 u8 is_legacy = 0;
98 unsigned long flags;
99 int i;
100
101 spin_lock_irqsave(&priv->lock, flags);
102 priv->qos_data.qos_active = 0;
103
104 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) {
105 if (priv->qos_data.qos_enable)
106 priv->qos_data.qos_active = 1;
107 if (!(priv->active_rate & 0xfff0)) {
108 cw_min = 31;
109 is_legacy = 1;
110 }
111 } else if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
112 if (priv->qos_data.qos_enable)
113 priv->qos_data.qos_active = 1;
114 } else if (!(priv->staging_rxon.flags & RXON_FLG_SHORT_SLOT_MSK)) {
115 cw_min = 31;
116 is_legacy = 1;
117 }
118
119 if (priv->qos_data.qos_active)
120 aifs = 3;
121
122 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
123 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
124 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
125 priv->qos_data.def_qos_parm.ac[0].edca_txop = 0;
126 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
127
128 if (priv->qos_data.qos_active) {
129 i = 1;
130 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
131 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
132 priv->qos_data.def_qos_parm.ac[i].aifsn = 7;
133 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
134 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
135
136 i = 2;
137 priv->qos_data.def_qos_parm.ac[i].cw_min =
138 cpu_to_le16((cw_min + 1) / 2 - 1);
139 priv->qos_data.def_qos_parm.ac[i].cw_max =
140 cpu_to_le16(cw_max);
141 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
142 if (is_legacy)
143 priv->qos_data.def_qos_parm.ac[i].edca_txop =
144 cpu_to_le16(6016);
145 else
146 priv->qos_data.def_qos_parm.ac[i].edca_txop =
147 cpu_to_le16(3008);
148 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
149
150 i = 3;
151 priv->qos_data.def_qos_parm.ac[i].cw_min =
152 cpu_to_le16((cw_min + 1) / 4 - 1);
153 priv->qos_data.def_qos_parm.ac[i].cw_max =
154 cpu_to_le16((cw_max + 1) / 2 - 1);
155 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
156 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
157 if (is_legacy)
158 priv->qos_data.def_qos_parm.ac[i].edca_txop =
159 cpu_to_le16(3264);
160 else
161 priv->qos_data.def_qos_parm.ac[i].edca_txop =
162 cpu_to_le16(1504);
163 } else {
164 for (i = 1; i < 4; i++) {
165 priv->qos_data.def_qos_parm.ac[i].cw_min =
166 cpu_to_le16(cw_min);
167 priv->qos_data.def_qos_parm.ac[i].cw_max =
168 cpu_to_le16(cw_max);
169 priv->qos_data.def_qos_parm.ac[i].aifsn = aifs;
170 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
171 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
172 }
173 }
174 IWL_DEBUG_QOS("set QoS to default \n");
175
176 spin_unlock_irqrestore(&priv->lock, flags);
177}
178EXPORT_SYMBOL(iwlcore_reset_qos);
179
180/**
181 * iwlcore_set_rxon_channel - Set the phymode and channel values in staging RXON
182 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
183 * @channel: Any channel valid for the requested phymode
184
185 * In addition to setting the staging RXON, priv->phymode is also set.
186 *
187 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
188 * in the staging RXON flag structure based on the phymode
189 */
190int iwlcore_set_rxon_channel(struct iwl_priv *priv,
191 enum ieee80211_band band,
192 u16 channel)
193{
194 if (!iwl4965_get_channel_info(priv, band, channel)) {
195 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
196 channel, band);
197 return -EINVAL;
198 }
199
200 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
201 (priv->band == band))
202 return 0;
203
204 priv->staging_rxon.channel = cpu_to_le16(channel);
205 if (band == IEEE80211_BAND_5GHZ)
206 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
207 else
208 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
209
210 priv->band = band;
211
212 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
213
214 return 0;
215}
216EXPORT_SYMBOL(iwlcore_set_rxon_channel);
217
218static void iwlcore_init_hw(struct iwl_priv *priv)
219{
220 struct ieee80211_hw *hw = priv->hw;
221 hw->rate_control_algorithm = "iwl-4965-rs";
222
223 /* Tell mac80211 and its clients (e.g. Wireless Extensions)
224 * the range of signal quality values that we'll provide.
225 * Negative values for level/noise indicate that we'll provide dBm.
226 * For WE, at least, non-0 values here *enable* display of values
227 * in app (iwconfig). */
228 hw->max_rssi = -20; /* signal level, negative indicates dBm */
229 hw->max_noise = -20; /* noise level, negative indicates dBm */
230 hw->max_signal = 100; /* link quality indication (%) */
231
232 /* Tell mac80211 our Tx characteristics */
233 hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE;
234
235 /* Default value; 4 EDCA QOS priorities */
236 hw->queues = 4;
237#ifdef CONFIG_IWL4965_HT
238 /* Enhanced value; more queues, to support 11n aggregation */
239 hw->queues = 16;
240#endif /* CONFIG_IWL4965_HT */
241}
242
243int iwl_setup(struct iwl_priv *priv)
244{
245 int ret = 0;
246 iwlcore_init_hw(priv);
247 ret = priv->cfg->ops->lib->init_drv(priv);
248 return ret;
249}
250EXPORT_SYMBOL(iwl_setup);
251
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 33bef1fecf4d..4dde4d628a80 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -76,6 +76,8 @@
76#define IWL_SKU_N 0x8 76#define IWL_SKU_N 0x8
77 77
78struct iwl_lib_ops { 78struct iwl_lib_ops {
79 /* iwlwifi driver (priv) init */
80 int (*init_drv)(struct iwl_priv *priv);
79 /* eeprom operations (as defined in iwl-eeprom.h) */ 81 /* eeprom operations (as defined in iwl-eeprom.h) */
80 struct iwl_eeprom_ops eeprom_ops; 82 struct iwl_eeprom_ops eeprom_ops;
81}; 83};
@@ -110,4 +112,12 @@ struct iwl_cfg {
110struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, 112struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
111 struct ieee80211_ops *hw_ops); 113 struct ieee80211_ops *hw_ops);
112 114
115void iwlcore_clear_stations_table(struct iwl_priv *priv);
116void iwlcore_reset_qos(struct iwl_priv *priv);
117int iwlcore_set_rxon_channel(struct iwl_priv *priv,
118 enum ieee80211_band band,
119 u16 channel);
120
121int iwl_setup(struct iwl_priv *priv);
122
113#endif /* __iwl_core_h__ */ 123#endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index ccacd489ae80..32ebec35f2af 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -75,6 +75,67 @@
75#include "iwl-eeprom.h" 75#include "iwl-eeprom.h"
76#include "iwl-4965-io.h" 76#include "iwl-4965-io.h"
77 77
78/************************** EEPROM BANDS ****************************
79 *
80 * The iwl_eeprom_band definitions below provide the mapping from the
81 * EEPROM contents to the specific channel number supported for each
82 * band.
83 *
84 * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3
85 * definition below maps to physical channel 42 in the 5.2GHz spectrum.
86 * The specific geography and calibration information for that channel
87 * is contained in the eeprom map itself.
88 *
89 * During init, we copy the eeprom information and channel map
90 * information into priv->channel_info_24/52 and priv->channel_map_24/52
91 *
92 * channel_map_24/52 provides the index in the channel_info array for a
93 * given channel. We have to have two separate maps as there is channel
94 * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and
95 * band_2
96 *
97 * A value of 0xff stored in the channel_map indicates that the channel
98 * is not supported by the hardware at all.
99 *
100 * A value of 0xfe in the channel_map indicates that the channel is not
101 * valid for Tx with the current hardware. This means that
102 * while the system can tune and receive on a given channel, it may not
103 * be able to associate or transmit any frames on that
104 * channel. There is no corresponding channel information for that
105 * entry.
106 *
107 *********************************************************************/
108
109/* 2.4 GHz */
110const u8 iwl_eeprom_band_1[14] = {
111 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
112};
113
114/* 5.2 GHz bands */
115static const u8 iwl_eeprom_band_2[] = { /* 4915-5080MHz */
116 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16
117};
118
119static const u8 iwl_eeprom_band_3[] = { /* 5170-5320MHz */
120 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
121};
122
123static const u8 iwl_eeprom_band_4[] = { /* 5500-5700MHz */
124 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
125};
126
127static const u8 iwl_eeprom_band_5[] = { /* 5725-5825MHz */
128 145, 149, 153, 157, 161, 165
129};
130
131static const u8 iwl_eeprom_band_6[] = { /* 2.4 FAT channel */
132 1, 2, 3, 4, 5, 6, 7
133};
134
135static const u8 iwl_eeprom_band_7[] = { /* 5.2 FAT channel */
136 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157
137};
138
78/****************************************************************************** 139/******************************************************************************
79 * 140 *
80 * EEPROM related functions 141 * EEPROM related functions
@@ -203,3 +264,298 @@ void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac)
203} 264}
204EXPORT_SYMBOL(iwl_eeprom_get_mac); 265EXPORT_SYMBOL(iwl_eeprom_get_mac);
205 266
267static void iwl_init_band_reference(const struct iwl_priv *priv,
268 int band,
269 int *eeprom_ch_count,
270 const struct iwl4965_eeprom_channel
271 **eeprom_ch_info,
272 const u8 **eeprom_ch_index)
273{
274 switch (band) {
275 case 1: /* 2.4GHz band */
276 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1);
277 *eeprom_ch_info = priv->eeprom.band_1_channels;
278 *eeprom_ch_index = iwl_eeprom_band_1;
279 break;
280 case 2: /* 4.9GHz band */
281 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2);
282 *eeprom_ch_info = priv->eeprom.band_2_channels;
283 *eeprom_ch_index = iwl_eeprom_band_2;
284 break;
285 case 3: /* 5.2GHz band */
286 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3);
287 *eeprom_ch_info = priv->eeprom.band_3_channels;
288 *eeprom_ch_index = iwl_eeprom_band_3;
289 break;
290 case 4: /* 5.5GHz band */
291 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4);
292 *eeprom_ch_info = priv->eeprom.band_4_channels;
293 *eeprom_ch_index = iwl_eeprom_band_4;
294 break;
295 case 5: /* 5.7GHz band */
296 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5);
297 *eeprom_ch_info = priv->eeprom.band_5_channels;
298 *eeprom_ch_index = iwl_eeprom_band_5;
299 break;
300 case 6: /* 2.4GHz FAT channels */
301 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6);
302 *eeprom_ch_info = priv->eeprom.band_24_channels;
303 *eeprom_ch_index = iwl_eeprom_band_6;
304 break;
305 case 7: /* 5 GHz FAT channels */
306 *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7);
307 *eeprom_ch_info = priv->eeprom.band_52_channels;
308 *eeprom_ch_index = iwl_eeprom_band_7;
309 break;
310 default:
311 BUG();
312 return;
313 }
314}
315
316#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \
317 ? # x " " : "")
318
319/**
320 * iwl4965_set_fat_chan_info - Copy fat channel info into driver's priv.
321 *
322 * Does not set up a command, or touch hardware.
323 */
324static int iwl4965_set_fat_chan_info(struct iwl_priv *priv,
325 enum ieee80211_band band, u16 channel,
326 const struct iwl4965_eeprom_channel *eeprom_ch,
327 u8 fat_extension_channel)
328{
329 struct iwl_channel_info *ch_info;
330
331 ch_info = (struct iwl_channel_info *)
332 iwl4965_get_channel_info(priv, band, channel);
333
334 if (!is_channel_valid(ch_info))
335 return -1;
336
337 IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x"
338 " %ddBm): Ad-Hoc %ssupported\n",
339 ch_info->channel,
340 is_channel_a_band(ch_info) ?
341 "5.2" : "2.4",
342 CHECK_AND_PRINT(IBSS),
343 CHECK_AND_PRINT(ACTIVE),
344 CHECK_AND_PRINT(RADAR),
345 CHECK_AND_PRINT(WIDE),
346 CHECK_AND_PRINT(NARROW),
347 CHECK_AND_PRINT(DFS),
348 eeprom_ch->flags,
349 eeprom_ch->max_power_avg,
350 ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS)
351 && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ?
352 "" : "not ");
353
354 ch_info->fat_eeprom = *eeprom_ch;
355 ch_info->fat_max_power_avg = eeprom_ch->max_power_avg;
356 ch_info->fat_curr_txpow = eeprom_ch->max_power_avg;
357 ch_info->fat_min_power = 0;
358 ch_info->fat_scan_power = eeprom_ch->max_power_avg;
359 ch_info->fat_flags = eeprom_ch->flags;
360 ch_info->fat_extension_channel = fat_extension_channel;
361
362 return 0;
363}
364
365#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \
366 ? # x " " : "")
367
368/**
369 * iwl_init_channel_map - Set up driver's info for all possible channels
370 */
371int iwl_init_channel_map(struct iwl_priv *priv)
372{
373 int eeprom_ch_count = 0;
374 const u8 *eeprom_ch_index = NULL;
375 const struct iwl4965_eeprom_channel *eeprom_ch_info = NULL;
376 int band, ch;
377 struct iwl_channel_info *ch_info;
378
379 if (priv->channel_count) {
380 IWL_DEBUG_INFO("Channel map already initialized.\n");
381 return 0;
382 }
383
384 if (priv->eeprom.version < 0x2f) {
385 IWL_WARNING("Unsupported EEPROM version: 0x%04X\n",
386 priv->eeprom.version);
387 return -EINVAL;
388 }
389
390 IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n");
391
392 priv->channel_count =
393 ARRAY_SIZE(iwl_eeprom_band_1) +
394 ARRAY_SIZE(iwl_eeprom_band_2) +
395 ARRAY_SIZE(iwl_eeprom_band_3) +
396 ARRAY_SIZE(iwl_eeprom_band_4) +
397 ARRAY_SIZE(iwl_eeprom_band_5);
398
399 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
400
401 priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) *
402 priv->channel_count, GFP_KERNEL);
403 if (!priv->channel_info) {
404 IWL_ERROR("Could not allocate channel_info\n");
405 priv->channel_count = 0;
406 return -ENOMEM;
407 }
408
409 ch_info = priv->channel_info;
410
411 /* Loop through the 5 EEPROM bands adding them in order to the
412 * channel map we maintain (that contains additional information than
413 * what just in the EEPROM) */
414 for (band = 1; band <= 5; band++) {
415
416 iwl_init_band_reference(priv, band, &eeprom_ch_count,
417 &eeprom_ch_info, &eeprom_ch_index);
418
419 /* Loop through each band adding each of the channels */
420 for (ch = 0; ch < eeprom_ch_count; ch++) {
421 ch_info->channel = eeprom_ch_index[ch];
422 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
423 IEEE80211_BAND_5GHZ;
424
425 /* permanently store EEPROM's channel regulatory flags
426 * and max power in channel info database. */
427 ch_info->eeprom = eeprom_ch_info[ch];
428
429 /* Copy the run-time flags so they are there even on
430 * invalid channels */
431 ch_info->flags = eeprom_ch_info[ch].flags;
432
433 if (!(is_channel_valid(ch_info))) {
434 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - "
435 "No traffic\n",
436 ch_info->channel,
437 ch_info->flags,
438 is_channel_a_band(ch_info) ?
439 "5.2" : "2.4");
440 ch_info++;
441 continue;
442 }
443
444 /* Initialize regulatory-based run-time data */
445 ch_info->max_power_avg = ch_info->curr_txpow =
446 eeprom_ch_info[ch].max_power_avg;
447 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
448 ch_info->min_power = 0;
449
450 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
451 " %ddBm): Ad-Hoc %ssupported\n",
452 ch_info->channel,
453 is_channel_a_band(ch_info) ?
454 "5.2" : "2.4",
455 CHECK_AND_PRINT_I(VALID),
456 CHECK_AND_PRINT_I(IBSS),
457 CHECK_AND_PRINT_I(ACTIVE),
458 CHECK_AND_PRINT_I(RADAR),
459 CHECK_AND_PRINT_I(WIDE),
460 CHECK_AND_PRINT_I(NARROW),
461 CHECK_AND_PRINT_I(DFS),
462 eeprom_ch_info[ch].flags,
463 eeprom_ch_info[ch].max_power_avg,
464 ((eeprom_ch_info[ch].
465 flags & EEPROM_CHANNEL_IBSS)
466 && !(eeprom_ch_info[ch].
467 flags & EEPROM_CHANNEL_RADAR))
468 ? "" : "not ");
469
470 /* Set the user_txpower_limit to the highest power
471 * supported by any channel */
472 if (eeprom_ch_info[ch].max_power_avg >
473 priv->user_txpower_limit)
474 priv->user_txpower_limit =
475 eeprom_ch_info[ch].max_power_avg;
476
477 ch_info++;
478 }
479 }
480
481 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */
482 for (band = 6; band <= 7; band++) {
483 enum ieee80211_band ieeeband;
484 u8 fat_extension_chan;
485
486 iwl_init_band_reference(priv, band, &eeprom_ch_count,
487 &eeprom_ch_info, &eeprom_ch_index);
488
489 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
490 ieeeband =
491 (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
492
493 /* Loop through each band adding each of the channels */
494 for (ch = 0; ch < eeprom_ch_count; ch++) {
495
496 if ((band == 6) &&
497 ((eeprom_ch_index[ch] == 5) ||
498 (eeprom_ch_index[ch] == 6) ||
499 (eeprom_ch_index[ch] == 7)))
500 fat_extension_chan = HT_IE_EXT_CHANNEL_MAX;
501 else
502 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE;
503
504 /* Set up driver's info for lower half */
505 iwl4965_set_fat_chan_info(priv, ieeeband,
506 eeprom_ch_index[ch],
507 &(eeprom_ch_info[ch]),
508 fat_extension_chan);
509
510 /* Set up driver's info for upper half */
511 iwl4965_set_fat_chan_info(priv, ieeeband,
512 (eeprom_ch_index[ch] + 4),
513 &(eeprom_ch_info[ch]),
514 HT_IE_EXT_CHANNEL_BELOW);
515 }
516 }
517
518 return 0;
519}
520EXPORT_SYMBOL(iwl_init_channel_map);
521
522/*
523 * iwl_free_channel_map - undo allocations in iwl4965_init_channel_map
524 */
525void iwl_free_channel_map(struct iwl_priv *priv)
526{
527 kfree(priv->channel_info);
528 priv->channel_count = 0;
529}
530EXPORT_SYMBOL(iwl_free_channel_map);
531
532/**
533 * iwl_get_channel_info - Find driver's private channel info
534 *
535 * Based on band and channel number.
536 */
537const struct iwl_channel_info *iwl4965_get_channel_info(
538 const struct iwl_priv *priv,
539 enum ieee80211_band band, u16 channel)
540{
541 int i;
542
543 switch (band) {
544 case IEEE80211_BAND_5GHZ:
545 for (i = 14; i < priv->channel_count; i++) {
546 if (priv->channel_info[i].channel == channel)
547 return &priv->channel_info[i];
548 }
549 break;
550 case IEEE80211_BAND_2GHZ:
551 if (channel >= 1 && channel <= 14)
552 return &priv->channel_info[channel - 1];
553 break;
554 default:
555 BUG();
556 }
557
558 return NULL;
559}
560EXPORT_SYMBOL(iwl4965_get_channel_info);
561
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 404c700c7c18..8a583947b2c7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -137,6 +137,8 @@ struct iwl4965_eeprom_channel {
137 * Look for this in calib_version member of struct iwl4965_eeprom. */ 137 * Look for this in calib_version member of struct iwl4965_eeprom. */
138#define EEPROM_TX_POWER_VERSION_NEW (5) 138#define EEPROM_TX_POWER_VERSION_NEW (5)
139 139
140/* 2.4 GHz */
141extern const u8 iwl_eeprom_band_1[14];
140 142
141/* 143/*
142 * 4965 factory calibration data for one txpower level, on one channel, 144 * 4965 factory calibration data for one txpower level, on one channel,
@@ -364,4 +366,10 @@ int iwlcore_eeprom_verify_signature(struct iwl_priv *priv);
364int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv); 366int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv);
365void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv); 367void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv);
366 368
369int iwl_init_channel_map(struct iwl_priv *priv);
370void iwl_free_channel_map(struct iwl_priv *priv);
371const struct iwl_channel_info *iwl4965_get_channel_info(
372 const struct iwl_priv *priv,
373 enum ieee80211_band band, u16 channel);
374
367#endif /* __iwl_eeprom_h__ */ 375#endif /* __iwl_eeprom_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a8fa1bfa570b..9cf1f204666d 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)