diff options
author | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2010-03-16 13:23:31 -0400 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-03-25 14:17:35 -0400 |
commit | 7dc77dba6a8bde512996824643da5669d73cbcdc (patch) | |
tree | fd230c474be5b581e0eec1f9ac8721c8d3210985 | |
parent | 81b8176eb8edac7d2135db2af03ab5fe0cb3b6f7 (diff) |
iwlwifi: move hcmd related code to separate file
Multiple iwlagn based devices shared the same hcmd related functions.
Move from iwl-5000.c to iwl-agn-hcmd.c file.
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-1000.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-5000.c | 244 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-6000.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c | 274 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.h | 2 |
6 files changed, 287 insertions, 247 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index cc4fe20c45e..46fad2d7226 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile | |||
@@ -10,7 +10,7 @@ CFLAGS_iwl-devtrace.o := -I$(src) | |||
10 | # AGN | 10 | # AGN |
11 | obj-$(CONFIG_IWLAGN) += iwlagn.o | 11 | obj-$(CONFIG_IWLAGN) += iwlagn.o |
12 | iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o | 12 | iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o |
13 | iwlagn-objs += iwl-agn-ucode.o | 13 | iwlagn-objs += iwl-agn-ucode.o iwl-agn-hcmd.o |
14 | 14 | ||
15 | iwlagn-$(CONFIG_IWL4965) += iwl-4965.o | 15 | iwlagn-$(CONFIG_IWL4965) += iwl-4965.o |
16 | iwlagn-$(CONFIG_IWL5000) += iwl-5000.o | 16 | iwlagn-$(CONFIG_IWL5000) += iwl-5000.o |
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 283c4ed1170..67d8513cff3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c | |||
@@ -220,8 +220,8 @@ static struct iwl_lib_ops iwl1000_lib = { | |||
220 | static const struct iwl_ops iwl1000_ops = { | 220 | static const struct iwl_ops iwl1000_ops = { |
221 | .ucode = &iwlagn_ucode, | 221 | .ucode = &iwlagn_ucode, |
222 | .lib = &iwl1000_lib, | 222 | .lib = &iwl1000_lib, |
223 | .hcmd = &iwl5000_hcmd, | 223 | .hcmd = &iwlagn_hcmd, |
224 | .utils = &iwl5000_hcmd_utils, | 224 | .utils = &iwlagn_hcmd_utils, |
225 | .led = &iwlagn_led_ops, | 225 | .led = &iwlagn_led_ops, |
226 | }; | 226 | }; |
227 | 227 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index bea2f46ef26..8aa382e370f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -165,108 +165,6 @@ u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv) | |||
165 | 165 | ||
166 | } | 166 | } |
167 | 167 | ||
168 | static void iwl5000_gain_computation(struct iwl_priv *priv, | ||
169 | u32 average_noise[NUM_RX_CHAINS], | ||
170 | u16 min_average_noise_antenna_i, | ||
171 | u32 min_average_noise, | ||
172 | u8 default_chain) | ||
173 | { | ||
174 | int i; | ||
175 | s32 delta_g; | ||
176 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; | ||
177 | |||
178 | /* | ||
179 | * Find Gain Code for the chains based on "default chain" | ||
180 | */ | ||
181 | for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) { | ||
182 | if ((data->disconn_array[i])) { | ||
183 | data->delta_gain_code[i] = 0; | ||
184 | continue; | ||
185 | } | ||
186 | |||
187 | delta_g = (priv->cfg->chain_noise_scale * | ||
188 | ((s32)average_noise[default_chain] - | ||
189 | (s32)average_noise[i])) / 1500; | ||
190 | |||
191 | /* bound gain by 2 bits value max, 3rd bit is sign */ | ||
192 | data->delta_gain_code[i] = | ||
193 | min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); | ||
194 | |||
195 | if (delta_g < 0) | ||
196 | /* | ||
197 | * set negative sign ... | ||
198 | * note to Intel developers: This is uCode API format, | ||
199 | * not the format of any internal device registers. | ||
200 | * Do not change this format for e.g. 6050 or similar | ||
201 | * devices. Change format only if more resolution | ||
202 | * (i.e. more than 2 bits magnitude) is needed. | ||
203 | */ | ||
204 | data->delta_gain_code[i] |= (1 << 2); | ||
205 | } | ||
206 | |||
207 | IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n", | ||
208 | data->delta_gain_code[1], data->delta_gain_code[2]); | ||
209 | |||
210 | if (!data->radio_write) { | ||
211 | struct iwl_calib_chain_noise_gain_cmd cmd; | ||
212 | |||
213 | memset(&cmd, 0, sizeof(cmd)); | ||
214 | |||
215 | cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD; | ||
216 | cmd.hdr.first_group = 0; | ||
217 | cmd.hdr.groups_num = 1; | ||
218 | cmd.hdr.data_valid = 1; | ||
219 | cmd.delta_gain_1 = data->delta_gain_code[1]; | ||
220 | cmd.delta_gain_2 = data->delta_gain_code[2]; | ||
221 | iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, | ||
222 | sizeof(cmd), &cmd, NULL); | ||
223 | |||
224 | data->radio_write = 1; | ||
225 | data->state = IWL_CHAIN_NOISE_CALIBRATED; | ||
226 | } | ||
227 | |||
228 | data->chain_noise_a = 0; | ||
229 | data->chain_noise_b = 0; | ||
230 | data->chain_noise_c = 0; | ||
231 | data->chain_signal_a = 0; | ||
232 | data->chain_signal_b = 0; | ||
233 | data->chain_signal_c = 0; | ||
234 | data->beacon_count = 0; | ||
235 | } | ||
236 | |||
237 | static void iwl5000_chain_noise_reset(struct iwl_priv *priv) | ||
238 | { | ||
239 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; | ||
240 | int ret; | ||
241 | |||
242 | if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) { | ||
243 | struct iwl_calib_chain_noise_reset_cmd cmd; | ||
244 | memset(&cmd, 0, sizeof(cmd)); | ||
245 | |||
246 | cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD; | ||
247 | cmd.hdr.first_group = 0; | ||
248 | cmd.hdr.groups_num = 1; | ||
249 | cmd.hdr.data_valid = 1; | ||
250 | ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, | ||
251 | sizeof(cmd), &cmd); | ||
252 | if (ret) | ||
253 | IWL_ERR(priv, | ||
254 | "Could not send REPLY_PHY_CALIBRATION_CMD\n"); | ||
255 | data->state = IWL_CHAIN_NOISE_ACCUMULATE; | ||
256 | IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info, | ||
261 | __le32 *tx_flags) | ||
262 | { | ||
263 | if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || | ||
264 | (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) | ||
265 | *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK; | ||
266 | else | ||
267 | *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK; | ||
268 | } | ||
269 | |||
270 | static struct iwl_sensitivity_ranges iwl5000_sensitivity = { | 168 | static struct iwl_sensitivity_ranges iwl5000_sensitivity = { |
271 | .min_nrg_cck = 95, | 169 | .min_nrg_cck = 95, |
272 | .max_nrg_cck = 0, /* not used, set to 0 */ | 170 | .max_nrg_cck = 0, /* not used, set to 0 */ |
@@ -832,17 +730,6 @@ int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, | |||
832 | return 0; | 730 | return 0; |
833 | } | 731 | } |
834 | 732 | ||
835 | u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | ||
836 | { | ||
837 | u16 size = (u16)sizeof(struct iwl_addsta_cmd); | ||
838 | struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data; | ||
839 | memcpy(addsta, cmd, size); | ||
840 | /* resrved in 5000 */ | ||
841 | addsta->rate_n_flags = cpu_to_le16(0); | ||
842 | return size; | ||
843 | } | ||
844 | |||
845 | |||
846 | /* | 733 | /* |
847 | * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask | 734 | * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask |
848 | * must be called under priv->lock and mac access | 735 | * must be called under priv->lock and mac access |
@@ -1064,12 +951,6 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv, | |||
1064 | IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); | 951 | IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); |
1065 | } | 952 | } |
1066 | 953 | ||
1067 | /* Currently 5000 is the superset of everything */ | ||
1068 | u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len) | ||
1069 | { | ||
1070 | return len; | ||
1071 | } | ||
1072 | |||
1073 | void iwl5000_setup_deferred_work(struct iwl_priv *priv) | 954 | void iwl5000_setup_deferred_work(struct iwl_priv *priv) |
1074 | { | 955 | { |
1075 | /* in 5000 the tx power calibration is done in uCode */ | 956 | /* in 5000 the tx power calibration is done in uCode */ |
@@ -1093,52 +974,6 @@ int iwl5000_hw_valid_rtc_data_addr(u32 addr) | |||
1093 | (addr < IWL50_RTC_DATA_UPPER_BOUND); | 974 | (addr < IWL50_RTC_DATA_UPPER_BOUND); |
1094 | } | 975 | } |
1095 | 976 | ||
1096 | static int iwl5000_send_rxon_assoc(struct iwl_priv *priv) | ||
1097 | { | ||
1098 | int ret = 0; | ||
1099 | struct iwl5000_rxon_assoc_cmd rxon_assoc; | ||
1100 | const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; | ||
1101 | const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; | ||
1102 | |||
1103 | if ((rxon1->flags == rxon2->flags) && | ||
1104 | (rxon1->filter_flags == rxon2->filter_flags) && | ||
1105 | (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && | ||
1106 | (rxon1->ofdm_ht_single_stream_basic_rates == | ||
1107 | rxon2->ofdm_ht_single_stream_basic_rates) && | ||
1108 | (rxon1->ofdm_ht_dual_stream_basic_rates == | ||
1109 | rxon2->ofdm_ht_dual_stream_basic_rates) && | ||
1110 | (rxon1->ofdm_ht_triple_stream_basic_rates == | ||
1111 | rxon2->ofdm_ht_triple_stream_basic_rates) && | ||
1112 | (rxon1->acquisition_data == rxon2->acquisition_data) && | ||
1113 | (rxon1->rx_chain == rxon2->rx_chain) && | ||
1114 | (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { | ||
1115 | IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); | ||
1116 | return 0; | ||
1117 | } | ||
1118 | |||
1119 | rxon_assoc.flags = priv->staging_rxon.flags; | ||
1120 | rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; | ||
1121 | rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; | ||
1122 | rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; | ||
1123 | rxon_assoc.reserved1 = 0; | ||
1124 | rxon_assoc.reserved2 = 0; | ||
1125 | rxon_assoc.reserved3 = 0; | ||
1126 | rxon_assoc.ofdm_ht_single_stream_basic_rates = | ||
1127 | priv->staging_rxon.ofdm_ht_single_stream_basic_rates; | ||
1128 | rxon_assoc.ofdm_ht_dual_stream_basic_rates = | ||
1129 | priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; | ||
1130 | rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; | ||
1131 | rxon_assoc.ofdm_ht_triple_stream_basic_rates = | ||
1132 | priv->staging_rxon.ofdm_ht_triple_stream_basic_rates; | ||
1133 | rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data; | ||
1134 | |||
1135 | ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, | ||
1136 | sizeof(rxon_assoc), &rxon_assoc, NULL); | ||
1137 | if (ret) | ||
1138 | return ret; | ||
1139 | |||
1140 | return ret; | ||
1141 | } | ||
1142 | int iwl5000_send_tx_power(struct iwl_priv *priv) | 977 | int iwl5000_send_tx_power(struct iwl_priv *priv) |
1143 | { | 978 | { |
1144 | struct iwl5000_tx_power_dbm_cmd tx_power_cmd; | 979 | struct iwl5000_tx_power_dbm_cmd tx_power_cmd; |
@@ -1194,61 +1029,6 @@ static void iwl5150_temperature(struct iwl_priv *priv) | |||
1194 | iwl_tt_handler(priv); | 1029 | iwl_tt_handler(priv); |
1195 | } | 1030 | } |
1196 | 1031 | ||
1197 | /* Calc max signal level (dBm) among 3 possible receivers */ | ||
1198 | int iwl5000_calc_rssi(struct iwl_priv *priv, | ||
1199 | struct iwl_rx_phy_res *rx_resp) | ||
1200 | { | ||
1201 | /* data from PHY/DSP regarding signal strength, etc., | ||
1202 | * contents are always there, not configurable by host | ||
1203 | */ | ||
1204 | struct iwl5000_non_cfg_phy *ncphy = | ||
1205 | (struct iwl5000_non_cfg_phy *)rx_resp->non_cfg_phy_buf; | ||
1206 | u32 val, rssi_a, rssi_b, rssi_c, max_rssi; | ||
1207 | u8 agc; | ||
1208 | |||
1209 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_AGC_IDX]); | ||
1210 | agc = (val & IWL50_OFDM_AGC_MSK) >> IWL50_OFDM_AGC_BIT_POS; | ||
1211 | |||
1212 | /* Find max rssi among 3 possible receivers. | ||
1213 | * These values are measured by the digital signal processor (DSP). | ||
1214 | * They should stay fairly constant even as the signal strength varies, | ||
1215 | * if the radio's automatic gain control (AGC) is working right. | ||
1216 | * AGC value (see below) will provide the "interesting" info. | ||
1217 | */ | ||
1218 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_AB_IDX]); | ||
1219 | rssi_a = (val & IWL50_OFDM_RSSI_A_MSK) >> IWL50_OFDM_RSSI_A_BIT_POS; | ||
1220 | rssi_b = (val & IWL50_OFDM_RSSI_B_MSK) >> IWL50_OFDM_RSSI_B_BIT_POS; | ||
1221 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_C_IDX]); | ||
1222 | rssi_c = (val & IWL50_OFDM_RSSI_C_MSK) >> IWL50_OFDM_RSSI_C_BIT_POS; | ||
1223 | |||
1224 | max_rssi = max_t(u32, rssi_a, rssi_b); | ||
1225 | max_rssi = max_t(u32, max_rssi, rssi_c); | ||
1226 | |||
1227 | IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", | ||
1228 | rssi_a, rssi_b, rssi_c, max_rssi, agc); | ||
1229 | |||
1230 | /* dBm = max_rssi dB - agc dB - constant. | ||
1231 | * Higher AGC (higher radio gain) means lower signal. */ | ||
1232 | return max_rssi - agc - IWL49_RSSI_OFFSET; | ||
1233 | } | ||
1234 | |||
1235 | static int iwl5000_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) | ||
1236 | { | ||
1237 | struct iwl_tx_ant_config_cmd tx_ant_cmd = { | ||
1238 | .valid = cpu_to_le32(valid_tx_ant), | ||
1239 | }; | ||
1240 | |||
1241 | if (IWL_UCODE_API(priv->ucode_ver) > 1) { | ||
1242 | IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); | ||
1243 | return iwl_send_cmd_pdu(priv, TX_ANT_CONFIGURATION_CMD, | ||
1244 | sizeof(struct iwl_tx_ant_config_cmd), | ||
1245 | &tx_ant_cmd); | ||
1246 | } else { | ||
1247 | IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n"); | ||
1248 | return -EOPNOTSUPP; | ||
1249 | } | ||
1250 | } | ||
1251 | |||
1252 | static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel) | 1032 | static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel) |
1253 | { | 1033 | { |
1254 | struct iwl5000_channel_switch_cmd cmd; | 1034 | struct iwl5000_channel_switch_cmd cmd; |
@@ -1281,22 +1061,6 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel) | |||
1281 | return iwl_send_cmd_sync(priv, &hcmd); | 1061 | return iwl_send_cmd_sync(priv, &hcmd); |
1282 | } | 1062 | } |
1283 | 1063 | ||
1284 | struct iwl_hcmd_ops iwl5000_hcmd = { | ||
1285 | .rxon_assoc = iwl5000_send_rxon_assoc, | ||
1286 | .commit_rxon = iwl_commit_rxon, | ||
1287 | .set_rxon_chain = iwl_set_rxon_chain, | ||
1288 | .set_tx_ant = iwl5000_send_tx_ant_config, | ||
1289 | }; | ||
1290 | |||
1291 | struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { | ||
1292 | .get_hcmd_size = iwl5000_get_hcmd_size, | ||
1293 | .build_addsta_hcmd = iwl5000_build_addsta_hcmd, | ||
1294 | .gain_computation = iwl5000_gain_computation, | ||
1295 | .chain_noise_reset = iwl5000_chain_noise_reset, | ||
1296 | .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag, | ||
1297 | .calc_rssi = iwl5000_calc_rssi, | ||
1298 | }; | ||
1299 | |||
1300 | struct iwl_lib_ops iwl5000_lib = { | 1064 | struct iwl_lib_ops iwl5000_lib = { |
1301 | .set_hw_params = iwl5000_hw_set_hw_params, | 1065 | .set_hw_params = iwl5000_hw_set_hw_params, |
1302 | .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, | 1066 | .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, |
@@ -1415,16 +1179,16 @@ static struct iwl_lib_ops iwl5150_lib = { | |||
1415 | static const struct iwl_ops iwl5000_ops = { | 1179 | static const struct iwl_ops iwl5000_ops = { |
1416 | .ucode = &iwlagn_ucode, | 1180 | .ucode = &iwlagn_ucode, |
1417 | .lib = &iwl5000_lib, | 1181 | .lib = &iwl5000_lib, |
1418 | .hcmd = &iwl5000_hcmd, | 1182 | .hcmd = &iwlagn_hcmd, |
1419 | .utils = &iwl5000_hcmd_utils, | 1183 | .utils = &iwlagn_hcmd_utils, |
1420 | .led = &iwlagn_led_ops, | 1184 | .led = &iwlagn_led_ops, |
1421 | }; | 1185 | }; |
1422 | 1186 | ||
1423 | static const struct iwl_ops iwl5150_ops = { | 1187 | static const struct iwl_ops iwl5150_ops = { |
1424 | .ucode = &iwlagn_ucode, | 1188 | .ucode = &iwlagn_ucode, |
1425 | .lib = &iwl5150_lib, | 1189 | .lib = &iwl5150_lib, |
1426 | .hcmd = &iwl5000_hcmd, | 1190 | .hcmd = &iwlagn_hcmd, |
1427 | .utils = &iwl5000_hcmd_utils, | 1191 | .utils = &iwlagn_hcmd_utils, |
1428 | .led = &iwlagn_led_ops, | 1192 | .led = &iwlagn_led_ops, |
1429 | }; | 1193 | }; |
1430 | 1194 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index b7297177c05..aff46b08703 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c | |||
@@ -286,8 +286,8 @@ static struct iwl_lib_ops iwl6000_lib = { | |||
286 | static const struct iwl_ops iwl6000_ops = { | 286 | static const struct iwl_ops iwl6000_ops = { |
287 | .ucode = &iwlagn_ucode, | 287 | .ucode = &iwlagn_ucode, |
288 | .lib = &iwl6000_lib, | 288 | .lib = &iwl6000_lib, |
289 | .hcmd = &iwl5000_hcmd, | 289 | .hcmd = &iwlagn_hcmd, |
290 | .utils = &iwl5000_hcmd_utils, | 290 | .utils = &iwlagn_hcmd_utils, |
291 | .led = &iwlagn_led_ops, | 291 | .led = &iwlagn_led_ops, |
292 | }; | 292 | }; |
293 | 293 | ||
@@ -354,8 +354,8 @@ static struct iwl_lib_ops iwl6050_lib = { | |||
354 | static const struct iwl_ops iwl6050_ops = { | 354 | static const struct iwl_ops iwl6050_ops = { |
355 | .ucode = &iwlagn_ucode, | 355 | .ucode = &iwlagn_ucode, |
356 | .lib = &iwl6050_lib, | 356 | .lib = &iwl6050_lib, |
357 | .hcmd = &iwl5000_hcmd, | 357 | .hcmd = &iwlagn_hcmd, |
358 | .utils = &iwl5000_hcmd_utils, | 358 | .utils = &iwlagn_hcmd_utils, |
359 | .led = &iwlagn_led_ops, | 359 | .led = &iwlagn_led_ops, |
360 | }; | 360 | }; |
361 | 361 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c new file mode 100644 index 00000000000..3ac010b1b1c --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c | |||
@@ -0,0 +1,274 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * GPL LICENSE SUMMARY | ||
4 | * | ||
5 | * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of version 2 of the GNU General Public License as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | ||
19 | * USA | ||
20 | * | ||
21 | * The full GNU General Public License is included in this distribution | ||
22 | * in the file called LICENSE.GPL. | ||
23 | * | ||
24 | * Contact Information: | ||
25 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
27 | * | ||
28 | *****************************************************************************/ | ||
29 | |||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/sched.h> | ||
34 | |||
35 | #include "iwl-dev.h" | ||
36 | #include "iwl-core.h" | ||
37 | #include "iwl-io.h" | ||
38 | #include "iwl-5000-hw.h" | ||
39 | |||
40 | static int iwlagn_send_rxon_assoc(struct iwl_priv *priv) | ||
41 | { | ||
42 | int ret = 0; | ||
43 | struct iwl5000_rxon_assoc_cmd rxon_assoc; | ||
44 | const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; | ||
45 | const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; | ||
46 | |||
47 | if ((rxon1->flags == rxon2->flags) && | ||
48 | (rxon1->filter_flags == rxon2->filter_flags) && | ||
49 | (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && | ||
50 | (rxon1->ofdm_ht_single_stream_basic_rates == | ||
51 | rxon2->ofdm_ht_single_stream_basic_rates) && | ||
52 | (rxon1->ofdm_ht_dual_stream_basic_rates == | ||
53 | rxon2->ofdm_ht_dual_stream_basic_rates) && | ||
54 | (rxon1->ofdm_ht_triple_stream_basic_rates == | ||
55 | rxon2->ofdm_ht_triple_stream_basic_rates) && | ||
56 | (rxon1->acquisition_data == rxon2->acquisition_data) && | ||
57 | (rxon1->rx_chain == rxon2->rx_chain) && | ||
58 | (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { | ||
59 | IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | rxon_assoc.flags = priv->staging_rxon.flags; | ||
64 | rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; | ||
65 | rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; | ||
66 | rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; | ||
67 | rxon_assoc.reserved1 = 0; | ||
68 | rxon_assoc.reserved2 = 0; | ||
69 | rxon_assoc.reserved3 = 0; | ||
70 | rxon_assoc.ofdm_ht_single_stream_basic_rates = | ||
71 | priv->staging_rxon.ofdm_ht_single_stream_basic_rates; | ||
72 | rxon_assoc.ofdm_ht_dual_stream_basic_rates = | ||
73 | priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; | ||
74 | rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; | ||
75 | rxon_assoc.ofdm_ht_triple_stream_basic_rates = | ||
76 | priv->staging_rxon.ofdm_ht_triple_stream_basic_rates; | ||
77 | rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data; | ||
78 | |||
79 | ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, | ||
80 | sizeof(rxon_assoc), &rxon_assoc, NULL); | ||
81 | if (ret) | ||
82 | return ret; | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) | ||
88 | { | ||
89 | struct iwl_tx_ant_config_cmd tx_ant_cmd = { | ||
90 | .valid = cpu_to_le32(valid_tx_ant), | ||
91 | }; | ||
92 | |||
93 | if (IWL_UCODE_API(priv->ucode_ver) > 1) { | ||
94 | IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); | ||
95 | return iwl_send_cmd_pdu(priv, TX_ANT_CONFIGURATION_CMD, | ||
96 | sizeof(struct iwl_tx_ant_config_cmd), | ||
97 | &tx_ant_cmd); | ||
98 | } else { | ||
99 | IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n"); | ||
100 | return -EOPNOTSUPP; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /* Currently this is the superset of everything */ | ||
105 | static u16 iwlagn_get_hcmd_size(u8 cmd_id, u16 len) | ||
106 | { | ||
107 | return len; | ||
108 | } | ||
109 | |||
110 | static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | ||
111 | { | ||
112 | u16 size = (u16)sizeof(struct iwl_addsta_cmd); | ||
113 | struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data; | ||
114 | memcpy(addsta, cmd, size); | ||
115 | /* resrved in 5000 */ | ||
116 | addsta->rate_n_flags = cpu_to_le16(0); | ||
117 | return size; | ||
118 | } | ||
119 | |||
120 | static void iwlagn_gain_computation(struct iwl_priv *priv, | ||
121 | u32 average_noise[NUM_RX_CHAINS], | ||
122 | u16 min_average_noise_antenna_i, | ||
123 | u32 min_average_noise, | ||
124 | u8 default_chain) | ||
125 | { | ||
126 | int i; | ||
127 | s32 delta_g; | ||
128 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; | ||
129 | |||
130 | /* | ||
131 | * Find Gain Code for the chains based on "default chain" | ||
132 | */ | ||
133 | for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) { | ||
134 | if ((data->disconn_array[i])) { | ||
135 | data->delta_gain_code[i] = 0; | ||
136 | continue; | ||
137 | } | ||
138 | |||
139 | delta_g = (priv->cfg->chain_noise_scale * | ||
140 | ((s32)average_noise[default_chain] - | ||
141 | (s32)average_noise[i])) / 1500; | ||
142 | |||
143 | /* bound gain by 2 bits value max, 3rd bit is sign */ | ||
144 | data->delta_gain_code[i] = | ||
145 | min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); | ||
146 | |||
147 | if (delta_g < 0) | ||
148 | /* | ||
149 | * set negative sign ... | ||
150 | * note to Intel developers: This is uCode API format, | ||
151 | * not the format of any internal device registers. | ||
152 | * Do not change this format for e.g. 6050 or similar | ||
153 | * devices. Change format only if more resolution | ||
154 | * (i.e. more than 2 bits magnitude) is needed. | ||
155 | */ | ||
156 | data->delta_gain_code[i] |= (1 << 2); | ||
157 | } | ||
158 | |||
159 | IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n", | ||
160 | data->delta_gain_code[1], data->delta_gain_code[2]); | ||
161 | |||
162 | if (!data->radio_write) { | ||
163 | struct iwl_calib_chain_noise_gain_cmd cmd; | ||
164 | |||
165 | memset(&cmd, 0, sizeof(cmd)); | ||
166 | |||
167 | cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD; | ||
168 | cmd.hdr.first_group = 0; | ||
169 | cmd.hdr.groups_num = 1; | ||
170 | cmd.hdr.data_valid = 1; | ||
171 | cmd.delta_gain_1 = data->delta_gain_code[1]; | ||
172 | cmd.delta_gain_2 = data->delta_gain_code[2]; | ||
173 | iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, | ||
174 | sizeof(cmd), &cmd, NULL); | ||
175 | |||
176 | data->radio_write = 1; | ||
177 | data->state = IWL_CHAIN_NOISE_CALIBRATED; | ||
178 | } | ||
179 | |||
180 | data->chain_noise_a = 0; | ||
181 | data->chain_noise_b = 0; | ||
182 | data->chain_noise_c = 0; | ||
183 | data->chain_signal_a = 0; | ||
184 | data->chain_signal_b = 0; | ||
185 | data->chain_signal_c = 0; | ||
186 | data->beacon_count = 0; | ||
187 | } | ||
188 | |||
189 | static void iwlagn_chain_noise_reset(struct iwl_priv *priv) | ||
190 | { | ||
191 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; | ||
192 | int ret; | ||
193 | |||
194 | if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) { | ||
195 | struct iwl_calib_chain_noise_reset_cmd cmd; | ||
196 | memset(&cmd, 0, sizeof(cmd)); | ||
197 | |||
198 | cmd.hdr.op_code = IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD; | ||
199 | cmd.hdr.first_group = 0; | ||
200 | cmd.hdr.groups_num = 1; | ||
201 | cmd.hdr.data_valid = 1; | ||
202 | ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, | ||
203 | sizeof(cmd), &cmd); | ||
204 | if (ret) | ||
205 | IWL_ERR(priv, | ||
206 | "Could not send REPLY_PHY_CALIBRATION_CMD\n"); | ||
207 | data->state = IWL_CHAIN_NOISE_ACCUMULATE; | ||
208 | IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | static void iwlagn_rts_tx_cmd_flag(struct ieee80211_tx_info *info, | ||
213 | __le32 *tx_flags) | ||
214 | { | ||
215 | if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || | ||
216 | (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) | ||
217 | *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK; | ||
218 | else | ||
219 | *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK; | ||
220 | } | ||
221 | |||
222 | /* Calc max signal level (dBm) among 3 possible receivers */ | ||
223 | static int iwlagn_calc_rssi(struct iwl_priv *priv, | ||
224 | struct iwl_rx_phy_res *rx_resp) | ||
225 | { | ||
226 | /* data from PHY/DSP regarding signal strength, etc., | ||
227 | * contents are always there, not configurable by host | ||
228 | */ | ||
229 | struct iwl5000_non_cfg_phy *ncphy = | ||
230 | (struct iwl5000_non_cfg_phy *)rx_resp->non_cfg_phy_buf; | ||
231 | u32 val, rssi_a, rssi_b, rssi_c, max_rssi; | ||
232 | u8 agc; | ||
233 | |||
234 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_AGC_IDX]); | ||
235 | agc = (val & IWL50_OFDM_AGC_MSK) >> IWL50_OFDM_AGC_BIT_POS; | ||
236 | |||
237 | /* Find max rssi among 3 possible receivers. | ||
238 | * These values are measured by the digital signal processor (DSP). | ||
239 | * They should stay fairly constant even as the signal strength varies, | ||
240 | * if the radio's automatic gain control (AGC) is working right. | ||
241 | * AGC value (see below) will provide the "interesting" info. | ||
242 | */ | ||
243 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_AB_IDX]); | ||
244 | rssi_a = (val & IWL50_OFDM_RSSI_A_MSK) >> IWL50_OFDM_RSSI_A_BIT_POS; | ||
245 | rssi_b = (val & IWL50_OFDM_RSSI_B_MSK) >> IWL50_OFDM_RSSI_B_BIT_POS; | ||
246 | val = le32_to_cpu(ncphy->non_cfg_phy[IWL50_RX_RES_RSSI_C_IDX]); | ||
247 | rssi_c = (val & IWL50_OFDM_RSSI_C_MSK) >> IWL50_OFDM_RSSI_C_BIT_POS; | ||
248 | |||
249 | max_rssi = max_t(u32, rssi_a, rssi_b); | ||
250 | max_rssi = max_t(u32, max_rssi, rssi_c); | ||
251 | |||
252 | IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", | ||
253 | rssi_a, rssi_b, rssi_c, max_rssi, agc); | ||
254 | |||
255 | /* dBm = max_rssi dB - agc dB - constant. | ||
256 | * Higher AGC (higher radio gain) means lower signal. */ | ||
257 | return max_rssi - agc - IWL49_RSSI_OFFSET; | ||
258 | } | ||
259 | |||
260 | struct iwl_hcmd_ops iwlagn_hcmd = { | ||
261 | .rxon_assoc = iwlagn_send_rxon_assoc, | ||
262 | .commit_rxon = iwl_commit_rxon, | ||
263 | .set_rxon_chain = iwl_set_rxon_chain, | ||
264 | .set_tx_ant = iwlagn_send_tx_ant_config, | ||
265 | }; | ||
266 | |||
267 | struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = { | ||
268 | .get_hcmd_size = iwlagn_get_hcmd_size, | ||
269 | .build_addsta_hcmd = iwlagn_build_addsta_hcmd, | ||
270 | .gain_computation = iwlagn_gain_computation, | ||
271 | .chain_noise_reset = iwlagn_chain_noise_reset, | ||
272 | .rts_tx_cmd_flag = iwlagn_rts_tx_cmd_flag, | ||
273 | .calc_rssi = iwlagn_calc_rssi, | ||
274 | }; | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5af528dd3c6..51e49df3644 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h | |||
@@ -66,6 +66,8 @@ | |||
66 | #include "iwl-dev.h" | 66 | #include "iwl-dev.h" |
67 | 67 | ||
68 | extern struct iwl_ucode_ops iwlagn_ucode; | 68 | extern struct iwl_ucode_ops iwlagn_ucode; |
69 | extern struct iwl_hcmd_ops iwlagn_hcmd; | ||
70 | extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils; | ||
69 | 71 | ||
70 | int iwl_reset_ict(struct iwl_priv *priv); | 72 | int iwl_reset_ict(struct iwl_priv *priv); |
71 | void iwl_disable_ict(struct iwl_priv *priv); | 73 | void iwl_disable_ict(struct iwl_priv *priv); |