/* * Copyright (c) 2008-2011 Atheros Communications Inc. * Copyright (c) 2011 Neratec Solutions AG * * 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 "hw.h" #include "hw-ops.h" #include "ath9k.h" #include "dfs.h" #include "dfs_debug.h" /* internal struct to pass radar data */ struct ath_radar_data { … }; /**** begin: CHIRP ************************************************************/ /* min and max gradients for defined FCC chirping pulses, given by * - 20MHz chirp width over a pulse width of 50us * - 5MHz chirp width over a pulse width of 100us */ static const int BIN_DELTA_MIN = …; static const int BIN_DELTA_MAX = …; /* we need at least 3 deltas / 4 samples for a reliable chirp detection */ #define NUM_DIFFS … #define FFT_NUM_SAMPLES … /* Threshold for difference of delta peaks */ static const int MAX_DIFF = …; /* width range to be checked for chirping */ static const int MIN_CHIRP_PULSE_WIDTH = …; static const int MAX_CHIRP_PULSE_WIDTH = …; struct ath9k_dfs_fft_20 { … } __packed; struct ath9k_dfs_fft_40 { … } __packed; static inline int fft_max_index(u8 *bins) { … } static inline int fft_max_magnitude(u8 *bins) { … } static inline u8 fft_bitmap_weight(u8 *bins) { … } static int ath9k_get_max_index_ht40(struct ath9k_dfs_fft_40 *fft, bool is_ctl, bool is_ext) { … } static bool ath9k_check_chirping(struct ath_softc *sc, u8 *data, int datalen, bool is_ctl, bool is_ext) { … } /**** end: CHIRP **************************************************************/ /* convert pulse duration to usecs, considering clock mode */ static u32 dur_to_usecs(struct ath_hw *ah, u32 dur) { … } #define PRI_CH_RADAR_FOUND … #define EXT_CH_RADAR_FOUND … static bool ath9k_postprocess_radar_event(struct ath_softc *sc, struct ath_radar_data *ard, struct pulse_event *pe) { … } static void ath9k_dfs_process_radar_pulse(struct ath_softc *sc, struct pulse_event *pe) { … } /* * DFS: check PHY-error for radar pulse and feed the detector */ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, struct ath_rx_status *rs, u64 mactime) { … } #undef PRI_CH_RADAR_FOUND #undef EXT_CH_RADAR_FOUND