aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlegacy/iwl-4965-calib.c')
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-calib.c220
1 files changed, 110 insertions, 110 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
index 115eeb3d7c39..7807dc59e9c5 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
@@ -80,14 +80,14 @@ struct statistics_general_data {
80 u32 beacon_energy_c; 80 u32 beacon_energy_c;
81}; 81};
82 82
83void il4965_calib_free_results(struct il_priv *priv) 83void il4965_calib_free_results(struct il_priv *il)
84{ 84{
85 int i; 85 int i;
86 86
87 for (i = 0; i < IL_CALIB_MAX; i++) { 87 for (i = 0; i < IL_CALIB_MAX; i++) {
88 kfree(priv->calib_results[i].buf); 88 kfree(il->calib_results[i].buf);
89 priv->calib_results[i].buf = NULL; 89 il->calib_results[i].buf = NULL;
90 priv->calib_results[i].buf_len = 0; 90 il->calib_results[i].buf_len = 0;
91 } 91 }
92} 92}
93 93
@@ -103,7 +103,7 @@ void il4965_calib_free_results(struct il_priv *priv)
103 * enough to receive all of our own network traffic, but not so 103 * enough to receive all of our own network traffic, but not so
104 * high that our DSP gets too busy trying to lock onto non-network 104 * high that our DSP gets too busy trying to lock onto non-network
105 * activity/noise. */ 105 * activity/noise. */
106static int il4965_sens_energy_cck(struct il_priv *priv, 106static int il4965_sens_energy_cck(struct il_priv *il,
107 u32 norm_fa, 107 u32 norm_fa,
108 u32 rx_enable_time, 108 u32 rx_enable_time,
109 struct statistics_general_data *rx_info) 109 struct statistics_general_data *rx_info)
@@ -130,9 +130,9 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
130 u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; 130 u32 max_false_alarms = MAX_FA_CCK * rx_enable_time;
131 u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; 131 u32 min_false_alarms = MIN_FA_CCK * rx_enable_time;
132 struct il_sensitivity_data *data = NULL; 132 struct il_sensitivity_data *data = NULL;
133 const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; 133 const struct il_sensitivity_ranges *ranges = il->hw_params.sens;
134 134
135 data = &(priv->sensitivity_data); 135 data = &(il->sensitivity_data);
136 136
137 data->nrg_auto_corr_silence_diff = 0; 137 data->nrg_auto_corr_silence_diff = 0;
138 138
@@ -160,7 +160,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
160 val = data->nrg_silence_rssi[i]; 160 val = data->nrg_silence_rssi[i];
161 silence_ref = max(silence_ref, val); 161 silence_ref = max(silence_ref, val);
162 } 162 }
163 IL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", 163 IL_DEBUG_CALIB(il, "silence a %u, b %u, c %u, 20-bcn max %u\n",
164 silence_rssi_a, silence_rssi_b, silence_rssi_c, 164 silence_rssi_a, silence_rssi_b, silence_rssi_c,
165 silence_ref); 165 silence_ref);
166 166
@@ -184,7 +184,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
184 max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); 184 max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i]));
185 max_nrg_cck += 6; 185 max_nrg_cck += 6;
186 186
187 IL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", 187 IL_DEBUG_CALIB(il, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n",
188 rx_info->beacon_energy_a, rx_info->beacon_energy_b, 188 rx_info->beacon_energy_a, rx_info->beacon_energy_b,
189 rx_info->beacon_energy_c, max_nrg_cck - 6); 189 rx_info->beacon_energy_c, max_nrg_cck - 6);
190 190
@@ -194,15 +194,15 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
194 data->num_in_cck_no_fa++; 194 data->num_in_cck_no_fa++;
195 else 195 else
196 data->num_in_cck_no_fa = 0; 196 data->num_in_cck_no_fa = 0;
197 IL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", 197 IL_DEBUG_CALIB(il, "consecutive bcns with few false alarms = %u\n",
198 data->num_in_cck_no_fa); 198 data->num_in_cck_no_fa);
199 199
200 /* If we got too many false alarms this time, reduce sensitivity */ 200 /* If we got too many false alarms this time, reduce sensitivity */
201 if ((false_alarms > max_false_alarms) && 201 if ((false_alarms > max_false_alarms) &&
202 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { 202 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) {
203 IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", 203 IL_DEBUG_CALIB(il, "norm FA %u > max FA %u\n",
204 false_alarms, max_false_alarms); 204 false_alarms, max_false_alarms);
205 IL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); 205 IL_DEBUG_CALIB(il, "... reducing sensitivity\n");
206 data->nrg_curr_state = IL_FA_TOO_MANY; 206 data->nrg_curr_state = IL_FA_TOO_MANY;
207 /* Store for "fewer than desired" on later beacon */ 207 /* Store for "fewer than desired" on later beacon */
208 data->nrg_silence_ref = silence_ref; 208 data->nrg_silence_ref = silence_ref;
@@ -219,7 +219,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
219 data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - 219 data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref -
220 (s32)silence_ref; 220 (s32)silence_ref;
221 221
222 IL_DEBUG_CALIB(priv, 222 IL_DEBUG_CALIB(il,
223 "norm FA %u < min FA %u, silence diff %d\n", 223 "norm FA %u < min FA %u, silence diff %d\n",
224 false_alarms, min_false_alarms, 224 false_alarms, min_false_alarms,
225 data->nrg_auto_corr_silence_diff); 225 data->nrg_auto_corr_silence_diff);
@@ -234,18 +234,18 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
234 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || 234 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) ||
235 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { 235 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) {
236 236
237 IL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); 237 IL_DEBUG_CALIB(il, "... increasing sensitivity\n");
238 /* Increase nrg value to increase sensitivity */ 238 /* Increase nrg value to increase sensitivity */
239 val = data->nrg_th_cck + NRG_STEP_CCK; 239 val = data->nrg_th_cck + NRG_STEP_CCK;
240 data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); 240 data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val);
241 } else { 241 } else {
242 IL_DEBUG_CALIB(priv, 242 IL_DEBUG_CALIB(il,
243 "... but not changing sensitivity\n"); 243 "... but not changing sensitivity\n");
244 } 244 }
245 245
246 /* Else we got a healthy number of false alarms, keep status quo */ 246 /* Else we got a healthy number of false alarms, keep status quo */
247 } else { 247 } else {
248 IL_DEBUG_CALIB(priv, " FA in safe zone\n"); 248 IL_DEBUG_CALIB(il, " FA in safe zone\n");
249 data->nrg_curr_state = IL_FA_GOOD_RANGE; 249 data->nrg_curr_state = IL_FA_GOOD_RANGE;
250 250
251 /* Store for use in "fewer than desired" with later beacon */ 251 /* Store for use in "fewer than desired" with later beacon */
@@ -255,7 +255,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
255 * give it some extra margin by reducing sensitivity again 255 * give it some extra margin by reducing sensitivity again
256 * (but don't go below measured energy of desired Rx) */ 256 * (but don't go below measured energy of desired Rx) */
257 if (IL_FA_TOO_MANY == data->nrg_prev_state) { 257 if (IL_FA_TOO_MANY == data->nrg_prev_state) {
258 IL_DEBUG_CALIB(priv, "... increasing margin\n"); 258 IL_DEBUG_CALIB(il, "... increasing margin\n");
259 if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) 259 if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN))
260 data->nrg_th_cck -= NRG_MARGIN; 260 data->nrg_th_cck -= NRG_MARGIN;
261 else 261 else
@@ -269,7 +269,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
269 * Lower value is higher energy, so we use max()! 269 * Lower value is higher energy, so we use max()!
270 */ 270 */
271 data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); 271 data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck);
272 IL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); 272 IL_DEBUG_CALIB(il, "new nrg_th_cck %u\n", data->nrg_th_cck);
273 273
274 data->nrg_prev_state = data->nrg_curr_state; 274 data->nrg_prev_state = data->nrg_curr_state;
275 275
@@ -306,7 +306,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv,
306} 306}
307 307
308 308
309static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, 309static int il4965_sens_auto_corr_ofdm(struct il_priv *il,
310 u32 norm_fa, 310 u32 norm_fa,
311 u32 rx_enable_time) 311 u32 rx_enable_time)
312{ 312{
@@ -315,14 +315,14 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv,
315 u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; 315 u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time;
316 u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; 316 u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time;
317 struct il_sensitivity_data *data = NULL; 317 struct il_sensitivity_data *data = NULL;
318 const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; 318 const struct il_sensitivity_ranges *ranges = il->hw_params.sens;
319 319
320 data = &(priv->sensitivity_data); 320 data = &(il->sensitivity_data);
321 321
322 /* If we got too many false alarms this time, reduce sensitivity */ 322 /* If we got too many false alarms this time, reduce sensitivity */
323 if (false_alarms > max_false_alarms) { 323 if (false_alarms > max_false_alarms) {
324 324
325 IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", 325 IL_DEBUG_CALIB(il, "norm FA %u > max FA %u)\n",
326 false_alarms, max_false_alarms); 326 false_alarms, max_false_alarms);
327 327
328 val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; 328 val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM;
@@ -345,7 +345,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv,
345 /* Else if we got fewer than desired, increase sensitivity */ 345 /* Else if we got fewer than desired, increase sensitivity */
346 else if (false_alarms < min_false_alarms) { 346 else if (false_alarms < min_false_alarms) {
347 347
348 IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", 348 IL_DEBUG_CALIB(il, "norm FA %u < min FA %u\n",
349 false_alarms, min_false_alarms); 349 false_alarms, min_false_alarms);
350 350
351 val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; 351 val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM;
@@ -364,13 +364,13 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv,
364 data->auto_corr_ofdm_mrc_x1 = 364 data->auto_corr_ofdm_mrc_x1 =
365 max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); 365 max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val);
366 } else { 366 } else {
367 IL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", 367 IL_DEBUG_CALIB(il, "min FA %u < norm FA %u < max FA %u OK\n",
368 min_false_alarms, false_alarms, max_false_alarms); 368 min_false_alarms, false_alarms, max_false_alarms);
369 } 369 }
370 return 0; 370 return 0;
371} 371}
372 372
373static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, 373static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il,
374 struct il_sensitivity_data *data, 374 struct il_sensitivity_data *data,
375 __le16 *tbl) 375 __le16 *tbl)
376{ 376{
@@ -400,18 +400,18 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv,
400 tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = 400 tbl[HD_OFDM_ENERGY_TH_IN_INDEX] =
401 cpu_to_le16(data->nrg_th_cca); 401 cpu_to_le16(data->nrg_th_cca);
402 402
403 IL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", 403 IL_DEBUG_CALIB(il, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n",
404 data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, 404 data->auto_corr_ofdm, data->auto_corr_ofdm_mrc,
405 data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, 405 data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1,
406 data->nrg_th_ofdm); 406 data->nrg_th_ofdm);
407 407
408 IL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", 408 IL_DEBUG_CALIB(il, "cck: ac %u mrc %u thresh %u\n",
409 data->auto_corr_cck, data->auto_corr_cck_mrc, 409 data->auto_corr_cck, data->auto_corr_cck_mrc,
410 data->nrg_th_cck); 410 data->nrg_th_cck);
411} 411}
412 412
413/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 413/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
414static int il4965_sensitivity_write(struct il_priv *priv) 414static int il4965_sensitivity_write(struct il_priv *il)
415{ 415{
416 struct il_sensitivity_cmd cmd; 416 struct il_sensitivity_cmd cmd;
417 struct il_sensitivity_data *data = NULL; 417 struct il_sensitivity_data *data = NULL;
@@ -422,43 +422,43 @@ static int il4965_sensitivity_write(struct il_priv *priv)
422 .data = &cmd, 422 .data = &cmd,
423 }; 423 };
424 424
425 data = &(priv->sensitivity_data); 425 data = &(il->sensitivity_data);
426 426
427 memset(&cmd, 0, sizeof(cmd)); 427 memset(&cmd, 0, sizeof(cmd));
428 428
429 il4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); 429 il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]);
430 430
431 /* Update uCode's "work" table, and copy it to DSP */ 431 /* Update uCode's "work" table, and copy it to DSP */
432 cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; 432 cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE;
433 433
434 /* Don't send command to uCode if nothing has changed */ 434 /* Don't send command to uCode if nothing has changed */
435 if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), 435 if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]),
436 sizeof(u16)*HD_TABLE_SIZE)) { 436 sizeof(u16)*HD_TABLE_SIZE)) {
437 IL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); 437 IL_DEBUG_CALIB(il, "No change in SENSITIVITY_CMD\n");
438 return 0; 438 return 0;
439 } 439 }
440 440
441 /* Copy table for comparison next time */ 441 /* Copy table for comparison next time */
442 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), 442 memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]),
443 sizeof(u16)*HD_TABLE_SIZE); 443 sizeof(u16)*HD_TABLE_SIZE);
444 444
445 return il_send_cmd(priv, &cmd_out); 445 return il_send_cmd(il, &cmd_out);
446} 446}
447 447
448void il4965_init_sensitivity(struct il_priv *priv) 448void il4965_init_sensitivity(struct il_priv *il)
449{ 449{
450 int ret = 0; 450 int ret = 0;
451 int i; 451 int i;
452 struct il_sensitivity_data *data = NULL; 452 struct il_sensitivity_data *data = NULL;
453 const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; 453 const struct il_sensitivity_ranges *ranges = il->hw_params.sens;
454 454
455 if (priv->disable_sens_cal) 455 if (il->disable_sens_cal)
456 return; 456 return;
457 457
458 IL_DEBUG_CALIB(priv, "Start il4965_init_sensitivity\n"); 458 IL_DEBUG_CALIB(il, "Start il4965_init_sensitivity\n");
459 459
460 /* Clear driver's sensitivity algo data */ 460 /* Clear driver's sensitivity algo data */
461 data = &(priv->sensitivity_data); 461 data = &(il->sensitivity_data);
462 462
463 if (ranges == NULL) 463 if (ranges == NULL)
464 return; 464 return;
@@ -495,11 +495,11 @@ void il4965_init_sensitivity(struct il_priv *priv)
495 data->last_bad_plcp_cnt_cck = 0; 495 data->last_bad_plcp_cnt_cck = 0;
496 data->last_fa_cnt_cck = 0; 496 data->last_fa_cnt_cck = 0;
497 497
498 ret |= il4965_sensitivity_write(priv); 498 ret |= il4965_sensitivity_write(il);
499 IL_DEBUG_CALIB(priv, "<<return 0x%X\n", ret); 499 IL_DEBUG_CALIB(il, "<<return 0x%X\n", ret);
500} 500}
501 501
502void il4965_sensitivity_calibration(struct il_priv *priv, void *resp) 502void il4965_sensitivity_calibration(struct il_priv *il, void *resp)
503{ 503{
504 u32 rx_enable_time; 504 u32 rx_enable_time;
505 u32 fa_cck; 505 u32 fa_cck;
@@ -514,25 +514,25 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp)
514 unsigned long flags; 514 unsigned long flags;
515 struct statistics_general_data statis; 515 struct statistics_general_data statis;
516 516
517 if (priv->disable_sens_cal) 517 if (il->disable_sens_cal)
518 return; 518 return;
519 519
520 data = &(priv->sensitivity_data); 520 data = &(il->sensitivity_data);
521 521
522 if (!il_is_any_associated(priv)) { 522 if (!il_is_any_associated(il)) {
523 IL_DEBUG_CALIB(priv, "<< - not associated\n"); 523 IL_DEBUG_CALIB(il, "<< - not associated\n");
524 return; 524 return;
525 } 525 }
526 526
527 spin_lock_irqsave(&priv->lock, flags); 527 spin_lock_irqsave(&il->lock, flags);
528 528
529 rx_info = &(((struct il_notif_statistics *)resp)->rx.general); 529 rx_info = &(((struct il_notif_statistics *)resp)->rx.general);
530 ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); 530 ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm);
531 cck = &(((struct il_notif_statistics *)resp)->rx.cck); 531 cck = &(((struct il_notif_statistics *)resp)->rx.cck);
532 532
533 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 533 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
534 IL_DEBUG_CALIB(priv, "<< invalid data.\n"); 534 IL_DEBUG_CALIB(il, "<< invalid data.\n");
535 spin_unlock_irqrestore(&priv->lock, flags); 535 spin_unlock_irqrestore(&il->lock, flags);
536 return; 536 return;
537 } 537 }
538 538
@@ -556,12 +556,12 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp)
556 statis.beacon_energy_c = 556 statis.beacon_energy_c =
557 le32_to_cpu(rx_info->beacon_energy_c); 557 le32_to_cpu(rx_info->beacon_energy_c);
558 558
559 spin_unlock_irqrestore(&priv->lock, flags); 559 spin_unlock_irqrestore(&il->lock, flags);
560 560
561 IL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); 561 IL_DEBUG_CALIB(il, "rx_enable_time = %u usecs\n", rx_enable_time);
562 562
563 if (!rx_enable_time) { 563 if (!rx_enable_time) {
564 IL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); 564 IL_DEBUG_CALIB(il, "<< RX Enable Time == 0!\n");
565 return; 565 return;
566 } 566 }
567 567
@@ -600,14 +600,14 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp)
600 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; 600 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm;
601 norm_fa_cck = fa_cck + bad_plcp_cck; 601 norm_fa_cck = fa_cck + bad_plcp_cck;
602 602
603 IL_DEBUG_CALIB(priv, 603 IL_DEBUG_CALIB(il,
604 "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, 604 "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck,
605 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); 605 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm);
606 606
607 il4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); 607 il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time);
608 il4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); 608 il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis);
609 609
610 il4965_sensitivity_write(priv); 610 il4965_sensitivity_write(il);
611} 611}
612 612
613static inline u8 il4965_find_first_chain(u8 mask) 613static inline u8 il4965_find_first_chain(u8 mask)
@@ -624,7 +624,7 @@ static inline u8 il4965_find_first_chain(u8 mask)
624 * disconnected. 624 * disconnected.
625 */ 625 */
626static void 626static void
627il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, 627il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig,
628 struct il_chain_noise_data *data) 628 struct il_chain_noise_data *data)
629{ 629{
630 u32 active_chains = 0; 630 u32 active_chains = 0;
@@ -635,11 +635,11 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig,
635 u16 i = 0; 635 u16 i = 0;
636 636
637 average_sig[0] = data->chain_signal_a / 637 average_sig[0] = data->chain_signal_a /
638 priv->cfg->base_params->chain_noise_num_beacons; 638 il->cfg->base_params->chain_noise_num_beacons;
639 average_sig[1] = data->chain_signal_b / 639 average_sig[1] = data->chain_signal_b /
640 priv->cfg->base_params->chain_noise_num_beacons; 640 il->cfg->base_params->chain_noise_num_beacons;
641 average_sig[2] = data->chain_signal_c / 641 average_sig[2] = data->chain_signal_c /
642 priv->cfg->base_params->chain_noise_num_beacons; 642 il->cfg->base_params->chain_noise_num_beacons;
643 643
644 if (average_sig[0] >= average_sig[1]) { 644 if (average_sig[0] >= average_sig[1]) {
645 max_average_sig = average_sig[0]; 645 max_average_sig = average_sig[0];
@@ -657,9 +657,9 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig,
657 active_chains = (1 << max_average_sig_antenna_i); 657 active_chains = (1 << max_average_sig_antenna_i);
658 } 658 }
659 659
660 IL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", 660 IL_DEBUG_CALIB(il, "average_sig: a %d b %d c %d\n",
661 average_sig[0], average_sig[1], average_sig[2]); 661 average_sig[0], average_sig[1], average_sig[2]);
662 IL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", 662 IL_DEBUG_CALIB(il, "max_average_sig = %d, antenna %d\n",
663 max_average_sig, max_average_sig_antenna_i); 663 max_average_sig, max_average_sig_antenna_i);
664 664
665 /* Compare signal strengths for all 3 receivers. */ 665 /* Compare signal strengths for all 3 receivers. */
@@ -673,7 +673,7 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig,
673 data->disconn_array[i] = 1; 673 data->disconn_array[i] = 1;
674 else 674 else
675 active_chains |= (1 << i); 675 active_chains |= (1 << i);
676 IL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " 676 IL_DEBUG_CALIB(il, "i = %d rssiDelta = %d "
677 "disconn_array[i] = %d\n", 677 "disconn_array[i] = %d\n",
678 i, rssi_delta, data->disconn_array[i]); 678 i, rssi_delta, data->disconn_array[i]);
679 } 679 }
@@ -689,58 +689,58 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig,
689 * To be safe, simply mask out any chains that we know 689 * To be safe, simply mask out any chains that we know
690 * are not on the device. 690 * are not on the device.
691 */ 691 */
692 active_chains &= priv->hw_params.valid_rx_ant; 692 active_chains &= il->hw_params.valid_rx_ant;
693 693
694 num_tx_chains = 0; 694 num_tx_chains = 0;
695 for (i = 0; i < NUM_RX_CHAINS; i++) { 695 for (i = 0; i < NUM_RX_CHAINS; i++) {
696 /* loops on all the bits of 696 /* loops on all the bits of
697 * priv->hw_setting.valid_tx_ant */ 697 * il->hw_setting.valid_tx_ant */
698 u8 ant_msk = (1 << i); 698 u8 ant_msk = (1 << i);
699 if (!(priv->hw_params.valid_tx_ant & ant_msk)) 699 if (!(il->hw_params.valid_tx_ant & ant_msk))
700 continue; 700 continue;
701 701
702 num_tx_chains++; 702 num_tx_chains++;
703 if (data->disconn_array[i] == 0) 703 if (data->disconn_array[i] == 0)
704 /* there is a Tx antenna connected */ 704 /* there is a Tx antenna connected */
705 break; 705 break;
706 if (num_tx_chains == priv->hw_params.tx_chains_num && 706 if (num_tx_chains == il->hw_params.tx_chains_num &&
707 data->disconn_array[i]) { 707 data->disconn_array[i]) {
708 /* 708 /*
709 * If all chains are disconnected 709 * If all chains are disconnected
710 * connect the first valid tx chain 710 * connect the first valid tx chain
711 */ 711 */
712 first_chain = 712 first_chain =
713 il4965_find_first_chain(priv->cfg->valid_tx_ant); 713 il4965_find_first_chain(il->cfg->valid_tx_ant);
714 data->disconn_array[first_chain] = 0; 714 data->disconn_array[first_chain] = 0;
715 active_chains |= BIT(first_chain); 715 active_chains |= BIT(first_chain);
716 IL_DEBUG_CALIB(priv, 716 IL_DEBUG_CALIB(il,
717 "All Tx chains are disconnected W/A - declare %d as connected\n", 717 "All Tx chains are disconnected W/A - declare %d as connected\n",
718 first_chain); 718 first_chain);
719 break; 719 break;
720 } 720 }
721 } 721 }
722 722
723 if (active_chains != priv->hw_params.valid_rx_ant && 723 if (active_chains != il->hw_params.valid_rx_ant &&
724 active_chains != priv->chain_noise_data.active_chains) 724 active_chains != il->chain_noise_data.active_chains)
725 IL_DEBUG_CALIB(priv, 725 IL_DEBUG_CALIB(il,
726 "Detected that not all antennas are connected! " 726 "Detected that not all antennas are connected! "
727 "Connected: %#x, valid: %#x.\n", 727 "Connected: %#x, valid: %#x.\n",
728 active_chains, priv->hw_params.valid_rx_ant); 728 active_chains, il->hw_params.valid_rx_ant);
729 729
730 /* Save for use within RXON, TX, SCAN commands, etc. */ 730 /* Save for use within RXON, TX, SCAN commands, etc. */
731 data->active_chains = active_chains; 731 data->active_chains = active_chains;
732 IL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", 732 IL_DEBUG_CALIB(il, "active_chains (bitwise) = 0x%x\n",
733 active_chains); 733 active_chains);
734} 734}
735 735
736static void il4965_gain_computation(struct il_priv *priv, 736static void il4965_gain_computation(struct il_priv *il,
737 u32 *average_noise, 737 u32 *average_noise,
738 u16 min_average_noise_antenna_i, 738 u16 min_average_noise_antenna_i,
739 u32 min_average_noise, 739 u32 min_average_noise,
740 u8 default_chain) 740 u8 default_chain)
741{ 741{
742 int i, ret; 742 int i, ret;
743 struct il_chain_noise_data *data = &priv->chain_noise_data; 743 struct il_chain_noise_data *data = &il->chain_noise_data;
744 744
745 data->delta_gain_code[min_average_noise_antenna_i] = 0; 745 data->delta_gain_code[min_average_noise_antenna_i] = 0;
746 746
@@ -762,7 +762,7 @@ static void il4965_gain_computation(struct il_priv *priv,
762 data->delta_gain_code[i] = 0; 762 data->delta_gain_code[i] = 0;
763 } 763 }
764 } 764 }
765 IL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", 765 IL_DEBUG_CALIB(il, "delta_gain_codes: a %d b %d c %d\n",
766 data->delta_gain_code[0], 766 data->delta_gain_code[0],
767 data->delta_gain_code[1], 767 data->delta_gain_code[1],
768 data->delta_gain_code[2]); 768 data->delta_gain_code[2]);
@@ -777,10 +777,10 @@ static void il4965_gain_computation(struct il_priv *priv,
777 cmd.diff_gain_a = data->delta_gain_code[0]; 777 cmd.diff_gain_a = data->delta_gain_code[0];
778 cmd.diff_gain_b = data->delta_gain_code[1]; 778 cmd.diff_gain_b = data->delta_gain_code[1];
779 cmd.diff_gain_c = data->delta_gain_code[2]; 779 cmd.diff_gain_c = data->delta_gain_code[2];
780 ret = il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 780 ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD,
781 sizeof(cmd), &cmd); 781 sizeof(cmd), &cmd);
782 if (ret) 782 if (ret)
783 IL_DEBUG_CALIB(priv, "fail sending cmd " 783 IL_DEBUG_CALIB(il, "fail sending cmd "
784 "REPLY_PHY_CALIBRATION_CMD\n"); 784 "REPLY_PHY_CALIBRATION_CMD\n");
785 785
786 /* TODO we might want recalculate 786 /* TODO we might want recalculate
@@ -799,7 +799,7 @@ static void il4965_gain_computation(struct il_priv *priv,
799 * 1) Which antennas are connected. 799 * 1) Which antennas are connected.
800 * 2) Differential rx gain settings to balance the 3 receivers. 800 * 2) Differential rx gain settings to balance the 3 receivers.
801 */ 801 */
802void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) 802void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
803{ 803{
804 struct il_chain_noise_data *data = NULL; 804 struct il_chain_noise_data *data = NULL;
805 805
@@ -821,12 +821,12 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
821 unsigned long flags; 821 unsigned long flags;
822 struct statistics_rx_non_phy *rx_info; 822 struct statistics_rx_non_phy *rx_info;
823 823
824 struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; 824 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
825 825
826 if (priv->disable_chain_noise_cal) 826 if (il->disable_chain_noise_cal)
827 return; 827 return;
828 828
829 data = &(priv->chain_noise_data); 829 data = &(il->chain_noise_data);
830 830
831 /* 831 /*
832 * Accumulate just the first "chain_noise_num_beacons" after 832 * Accumulate just the first "chain_noise_num_beacons" after
@@ -834,18 +834,18 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
834 */ 834 */
835 if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { 835 if (data->state != IL_CHAIN_NOISE_ACCUMULATE) {
836 if (data->state == IL_CHAIN_NOISE_ALIVE) 836 if (data->state == IL_CHAIN_NOISE_ALIVE)
837 IL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); 837 IL_DEBUG_CALIB(il, "Wait for noise calib reset\n");
838 return; 838 return;
839 } 839 }
840 840
841 spin_lock_irqsave(&priv->lock, flags); 841 spin_lock_irqsave(&il->lock, flags);
842 842
843 rx_info = &(((struct il_notif_statistics *)stat_resp)-> 843 rx_info = &(((struct il_notif_statistics *)stat_resp)->
844 rx.general); 844 rx.general);
845 845
846 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 846 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
847 IL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); 847 IL_DEBUG_CALIB(il, " << Interference data unavailable\n");
848 spin_unlock_irqrestore(&priv->lock, flags); 848 spin_unlock_irqrestore(&il->lock, flags);
849 return; 849 return;
850 } 850 }
851 851
@@ -861,9 +861,9 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
861 /* Make sure we accumulate data for just the associated channel 861 /* Make sure we accumulate data for just the associated channel
862 * (even if scanning). */ 862 * (even if scanning). */
863 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { 863 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) {
864 IL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", 864 IL_DEBUG_CALIB(il, "Stats not from chan=%d, band24=%d\n",
865 rxon_chnum, rxon_band24); 865 rxon_chnum, rxon_band24);
866 spin_unlock_irqrestore(&priv->lock, flags); 866 spin_unlock_irqrestore(&il->lock, flags);
867 return; 867 return;
868 } 868 }
869 869
@@ -882,7 +882,7 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
882 chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; 882 chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER;
883 chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; 883 chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER;
884 884
885 spin_unlock_irqrestore(&priv->lock, flags); 885 spin_unlock_irqrestore(&il->lock, flags);
886 886
887 data->beacon_count++; 887 data->beacon_count++;
888 888
@@ -894,30 +894,30 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
894 data->chain_signal_b = (chain_sig_b + data->chain_signal_b); 894 data->chain_signal_b = (chain_sig_b + data->chain_signal_b);
895 data->chain_signal_c = (chain_sig_c + data->chain_signal_c); 895 data->chain_signal_c = (chain_sig_c + data->chain_signal_c);
896 896
897 IL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", 897 IL_DEBUG_CALIB(il, "chan=%d, band24=%d, beacon=%d\n",
898 rxon_chnum, rxon_band24, data->beacon_count); 898 rxon_chnum, rxon_band24, data->beacon_count);
899 IL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", 899 IL_DEBUG_CALIB(il, "chain_sig: a %d b %d c %d\n",
900 chain_sig_a, chain_sig_b, chain_sig_c); 900 chain_sig_a, chain_sig_b, chain_sig_c);
901 IL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", 901 IL_DEBUG_CALIB(il, "chain_noise: a %d b %d c %d\n",
902 chain_noise_a, chain_noise_b, chain_noise_c); 902 chain_noise_a, chain_noise_b, chain_noise_c);
903 903
904 /* If this is the "chain_noise_num_beacons", determine: 904 /* If this is the "chain_noise_num_beacons", determine:
905 * 1) Disconnected antennas (using signal strengths) 905 * 1) Disconnected antennas (using signal strengths)
906 * 2) Differential gain (using silence noise) to balance receivers */ 906 * 2) Differential gain (using silence noise) to balance receivers */
907 if (data->beacon_count != 907 if (data->beacon_count !=
908 priv->cfg->base_params->chain_noise_num_beacons) 908 il->cfg->base_params->chain_noise_num_beacons)
909 return; 909 return;
910 910
911 /* Analyze signal for disconnected antenna */ 911 /* Analyze signal for disconnected antenna */
912 il4965_find_disconn_antenna(priv, average_sig, data); 912 il4965_find_disconn_antenna(il, average_sig, data);
913 913
914 /* Analyze noise for rx balance */ 914 /* Analyze noise for rx balance */
915 average_noise[0] = data->chain_noise_a / 915 average_noise[0] = data->chain_noise_a /
916 priv->cfg->base_params->chain_noise_num_beacons; 916 il->cfg->base_params->chain_noise_num_beacons;
917 average_noise[1] = data->chain_noise_b / 917 average_noise[1] = data->chain_noise_b /
918 priv->cfg->base_params->chain_noise_num_beacons; 918 il->cfg->base_params->chain_noise_num_beacons;
919 average_noise[2] = data->chain_noise_c / 919 average_noise[2] = data->chain_noise_c /
920 priv->cfg->base_params->chain_noise_num_beacons; 920 il->cfg->base_params->chain_noise_num_beacons;
921 921
922 for (i = 0; i < NUM_RX_CHAINS; i++) { 922 for (i = 0; i < NUM_RX_CHAINS; i++) {
923 if (!(data->disconn_array[i]) && 923 if (!(data->disconn_array[i]) &&
@@ -929,39 +929,39 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp)
929 } 929 }
930 } 930 }
931 931
932 IL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", 932 IL_DEBUG_CALIB(il, "average_noise: a %d b %d c %d\n",
933 average_noise[0], average_noise[1], 933 average_noise[0], average_noise[1],
934 average_noise[2]); 934 average_noise[2]);
935 935
936 IL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", 936 IL_DEBUG_CALIB(il, "min_average_noise = %d, antenna %d\n",
937 min_average_noise, min_average_noise_antenna_i); 937 min_average_noise, min_average_noise_antenna_i);
938 938
939 il4965_gain_computation(priv, average_noise, 939 il4965_gain_computation(il, average_noise,
940 min_average_noise_antenna_i, min_average_noise, 940 min_average_noise_antenna_i, min_average_noise,
941 il4965_find_first_chain(priv->cfg->valid_rx_ant)); 941 il4965_find_first_chain(il->cfg->valid_rx_ant));
942 942
943 /* Some power changes may have been made during the calibration. 943 /* Some power changes may have been made during the calibration.
944 * Update and commit the RXON 944 * Update and commit the RXON
945 */ 945 */
946 if (priv->cfg->ops->lib->update_chain_flags) 946 if (il->cfg->ops->lib->update_chain_flags)
947 priv->cfg->ops->lib->update_chain_flags(priv); 947 il->cfg->ops->lib->update_chain_flags(il);
948 948
949 data->state = IL_CHAIN_NOISE_DONE; 949 data->state = IL_CHAIN_NOISE_DONE;
950 il_power_update_mode(priv, false); 950 il_power_update_mode(il, false);
951} 951}
952 952
953void il4965_reset_run_time_calib(struct il_priv *priv) 953void il4965_reset_run_time_calib(struct il_priv *il)
954{ 954{
955 int i; 955 int i;
956 memset(&(priv->sensitivity_data), 0, 956 memset(&(il->sensitivity_data), 0,
957 sizeof(struct il_sensitivity_data)); 957 sizeof(struct il_sensitivity_data));
958 memset(&(priv->chain_noise_data), 0, 958 memset(&(il->chain_noise_data), 0,
959 sizeof(struct il_chain_noise_data)); 959 sizeof(struct il_chain_noise_data));
960 for (i = 0; i < NUM_RX_CHAINS; i++) 960 for (i = 0; i < NUM_RX_CHAINS; i++)
961 priv->chain_noise_data.delta_gain_code[i] = 961 il->chain_noise_data.delta_gain_code[i] =
962 CHAIN_NOISE_DELTA_GAIN_INIT_VAL; 962 CHAIN_NOISE_DELTA_GAIN_INIT_VAL;
963 963
964 /* Ask for statistics now, the uCode will send notification 964 /* Ask for statistics now, the uCode will send notification
965 * periodically after association */ 965 * periodically after association */
966 il_send_statistics_request(priv, CMD_ASYNC, true); 966 il_send_statistics_request(il, CMD_ASYNC, true);
967} 967}