/* * Copyright (c) 2008-2011 Atheros Communications Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/kernel.h> #include <linux/export.h> #include "hw.h" #include "hw-ops.h" struct ani_ofdm_level_entry { … }; /* values here are relative to the INI */ /* * Legend: * * SI: Spur immunity * FS: FIR Step * WS: OFDM / CCK Weak Signal detection * MRC-CCK: Maximal Ratio Combining for CCK */ static const struct ani_ofdm_level_entry ofdm_level_table[] = …; #define ATH9K_ANI_OFDM_NUM_LEVEL … #define ATH9K_ANI_OFDM_MAX_LEVEL … #define ATH9K_ANI_OFDM_DEF_LEVEL … /* * MRC (Maximal Ratio Combining) has always been used with multi-antenna ofdm. * With OFDM for single stream you just add up all antenna inputs, you're * only interested in what you get after FFT. Signal alignment is also not * required for OFDM because any phase difference adds up in the frequency * domain. * * MRC requires extra work for use with CCK. You need to align the antenna * signals from the different antenna before you can add the signals together. * You need alignment of signals as CCK is in time domain, so addition can cancel * your signal completely if phase is 180 degrees (think of adding sine waves). * You also need to remove noise before the addition and this is where ANI * MRC CCK comes into play. One of the antenna inputs may be stronger but * lower SNR, so just adding after alignment can be dangerous. * * Regardless of alignment in time, the antenna signals add constructively after * FFT and improve your reception. For more information: * * https://en.wikipedia.org/wiki/Maximal-ratio_combining */ struct ani_cck_level_entry { … }; static const struct ani_cck_level_entry cck_level_table[] = …; #define ATH9K_ANI_CCK_NUM_LEVEL … #define ATH9K_ANI_CCK_MAX_LEVEL … #define ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI … #define ATH9K_ANI_CCK_DEF_LEVEL … static void ath9k_hw_update_mibstats(struct ath_hw *ah, struct ath9k_mib_stats *stats) { … } static void ath9k_ani_restart(struct ath_hw *ah) { … } /* Adjust the OFDM Noise Immunity Level */ static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel, bool scan) { … } static void ath9k_hw_ani_ofdm_err_trigger(struct ath_hw *ah) { … } /* * Set the ANI settings to match an CCK level. */ static void ath9k_hw_set_cck_nil(struct ath_hw *ah, u_int8_t immunityLevel, bool scan) { … } static void ath9k_hw_ani_cck_err_trigger(struct ath_hw *ah) { … } /* * only lower either OFDM or CCK errors per turn * we lower the other one next time */ static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah) { … } /* * Restore the ANI parameters in the HAL and reset the statistics. * This routine should be called for every hardware reset and for * every channel change. */ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning) { … } static bool ath9k_hw_ani_read_counters(struct ath_hw *ah) { … } void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan) { … } EXPORT_SYMBOL(…); void ath9k_enable_mib_counters(struct ath_hw *ah) { … } /* Freeze the MIB counters, get the stats and then clear them */ void ath9k_hw_disable_mib_counters(struct ath_hw *ah) { … } EXPORT_SYMBOL(…); void ath9k_hw_ani_init(struct ath_hw *ah) { … }