63 #include <linux/slab.h>
95 il4965_sens_energy_cck(
struct il_priv *il,
u32 norm_fa,
u32 rx_enable_time,
100 u8 max_silence_rssi = 0;
102 u8 silence_rssi_a = 0;
103 u8 silence_rssi_b = 0;
104 u8 silence_rssi_c = 0;
116 u32 false_alarms = norm_fa * 200 * 1024;
136 val =
max(silence_rssi_b, silence_rssi_c);
137 max_silence_rssi =
max(silence_rssi_a, (
u8) val);
148 silence_ref =
max(silence_ref, val);
150 D_CALIB(
"silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a,
151 silence_rssi_b, silence_rssi_c, silence_ref);
169 for (i = 1; i < 10; i++)
173 D_CALIB(
"rx energy a %u, b %u, c %u, 10-bcn max/min %u\n",
179 if (false_alarms < min_false_alarms)
183 D_CALIB(
"consecutive bcns with few false alarms = %u\n",
187 if (false_alarms > max_false_alarms &&
189 D_CALIB(
"norm FA %u > max FA %u\n", false_alarms,
191 D_CALIB(
"... reducing sensitivity\n");
200 }
else if (false_alarms < min_false_alarms) {
208 D_CALIB(
"norm FA %u < min FA %u, silence diff %d\n",
209 false_alarms, min_false_alarms,
222 D_CALIB(
"... increasing sensitivity\n");
227 D_CALIB(
"... but not changing sensitivity\n");
242 D_CALIB(
"... increasing margin\n");
261 if (false_alarms > min_false_alarms) {
276 }
else if (false_alarms < min_false_alarms &&
292 il4965_sens_auto_corr_ofdm(
struct il_priv *il,
u32 norm_fa,
u32 rx_enable_time)
295 u32 false_alarms = norm_fa * 200 * 1024;
304 if (false_alarms > max_false_alarms) {
306 D_CALIB(
"norm FA %u > max FA %u)\n", false_alarms,
327 else if (false_alarms < min_false_alarms) {
329 D_CALIB(
"norm FA %u < min FA %u\n", false_alarms,
348 D_CALIB(
"min FA %u < norm FA %u < max FA %u OK\n",
349 min_false_alarms, false_alarms, max_false_alarms);
355 il4965_prepare_legacy_sensitivity_tbl(
struct il_priv *il,
382 D_CALIB(
"ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n",
393 il4965_sensitivity_write(
struct il_priv *il)
408 il4965_prepare_legacy_sensitivity_tbl(il, data, &
cmd.table[0]);
417 D_CALIB(
"No change in C_SENSITIVITY\n");
423 sizeof(
u16) * HD_TBL_SIZE);
439 D_CALIB(
"Start il4965_init_sensitivity\n");
456 for (i = 0; i < 10; i++)
479 ret |= il4965_sensitivity_write(il);
480 D_CALIB(
"<<return 0x%X\n", ret);
504 if (!il_is_any_associated(il)) {
505 D_CALIB(
"<< - not associated\n");
517 spin_unlock_irqrestore(&il->
lock, flags);
538 spin_unlock_irqrestore(&il->
lock, flags);
540 D_CALIB(
"rx_enable_time = %u usecs\n", rx_enable_time);
542 if (!rx_enable_time) {
543 D_CALIB(
"<< RX Enable Time == 0!\n");
579 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm;
580 norm_fa_cck = fa_cck + bad_plcp_cck;
582 D_CALIB(
"cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck,
583 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm);
585 il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time);
586 il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis);
588 il4965_sensitivity_write(il);
592 il4965_find_first_chain(
u8 mask)
606 il4965_find_disconn_antenna(
struct il_priv *il,
u32 * average_sig,
609 u32 active_chains = 0;
611 u16 max_average_sig_antenna_i;
618 il->
cfg->chain_noise_num_beacons;
621 il->
cfg->chain_noise_num_beacons;
624 il->
cfg->chain_noise_num_beacons;
626 if (average_sig[0] >= average_sig[1]) {
627 max_average_sig = average_sig[0];
628 max_average_sig_antenna_i = 0;
629 active_chains = (1 << max_average_sig_antenna_i);
631 max_average_sig = average_sig[1];
632 max_average_sig_antenna_i = 1;
633 active_chains = (1 << max_average_sig_antenna_i);
636 if (average_sig[2] >= max_average_sig) {
637 max_average_sig = average_sig[2];
638 max_average_sig_antenna_i = 2;
639 active_chains = (1 << max_average_sig_antenna_i);
642 D_CALIB(
"average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1],
644 D_CALIB(
"max_average_sig = %d, antenna %d\n", max_average_sig,
645 max_average_sig_antenna_i);
649 if (i != max_average_sig_antenna_i) {
650 s32 rssi_delta = (max_average_sig - average_sig[
i]);
657 active_chains |= (1 <<
i);
658 D_CALIB(
"i = %d rssiDelta = %d "
659 "disconn_array[i] = %d\n", i, rssi_delta,
674 active_chains &= il->
hw_params.valid_rx_ant;
680 u8 ant_msk = (1 <<
i);
681 if (!(il->
hw_params.valid_tx_ant & ant_msk))
688 if (num_tx_chains == il->
hw_params.tx_chains_num &&
695 il4965_find_first_chain(il->
cfg->valid_tx_ant);
697 active_chains |=
BIT(first_chain);
698 D_CALIB(
"All Tx chains are disconnected"
699 "- declare %d as connected\n", first_chain);
704 if (active_chains != il->
hw_params.valid_rx_ant &&
706 D_CALIB(
"Detected that not all antennas are connected! "
707 "Connected: %#x, valid: %#x.\n", active_chains,
712 D_CALIB(
"active_chains (bitwise) = 0x%x\n", active_chains);
716 il4965_gain_computation(
struct il_priv *il,
u32 * average_noise,
717 u16 min_average_noise_antenna_i,
u32 min_average_noise,
731 delta_g = average_noise[
i] - min_average_noise;
758 D_CALIB(
"fail sending cmd " "C_PHY_CALIBRATION\n");
808 D_CALIB(
"Wait for noise calib reset\n");
817 D_CALIB(
" << Interference data unavailable\n");
818 spin_unlock_irqrestore(&il->
lock, flags);
833 if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) {
834 D_CALIB(
"Stats not from chan=%d, band24=%d\n", rxon_chnum,
836 spin_unlock_irqrestore(&il->
lock, flags);
855 spin_unlock_irqrestore(&il->
lock, flags);
867 D_CALIB(
"chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24,
869 D_CALIB(
"chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b,
871 D_CALIB(
"chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b,
881 il4965_find_disconn_antenna(il, average_sig, data);
893 average_noise[i] <= min_average_noise) {
896 min_average_noise = average_noise[
i];
897 min_average_noise_antenna_i =
i;
901 D_CALIB(
"average_noise: a %d b %d c %d\n", average_noise[0],
902 average_noise[1], average_noise[2]);
904 D_CALIB(
"min_average_noise = %d, antenna %d\n", min_average_noise,
905 min_average_noise_antenna_i);
907 il4965_gain_computation(il, average_noise, min_average_noise_antenna_i,
909 il4965_find_first_chain(il->
cfg->valid_rx_ant));
914 if (il->
ops->update_chain_flags)
915 il->
ops->update_chain_flags(il);