/* * Copyright (c) 2012 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 <linux/slab.h> #include <linux/export.h> #include "dfs_pattern_detector.h" #include "dfs_pri_detector.h" #include "ath.h" /** * struct radar_types - contains array of patterns defined for one DFS domain * @region: regulatory DFS region * @num_radar_types: number of radar types to follow * @radar_types: radar types array */ struct radar_types { … }; /* percentage on ppb threshold to trigger detection */ #define MIN_PPB_THRESH … #define PPB_THRESH_RATE(PPB, RATE) … #define PPB_THRESH(PPB) … #define PRF2PRI(PRF) … /* percentage of pulse width tolerance */ #define WIDTH_TOLERANCE … #define WIDTH_LOWER(X) … #define WIDTH_UPPER(X) … #define ETSI_PATTERN(ID, WMIN, WMAX, PMIN, PMAX, PRF, PPB, CHIRP) … /* radar types as defined by ETSI EN-301-893 v1.5.1 */ static const struct radar_detector_specs etsi_radar_ref_types_v15[] = …; static const struct radar_types etsi_radar_types_v15 = …; #define FCC_PATTERN(ID, WMIN, WMAX, PMIN, PMAX, PRF, PPB, CHIRP) … /* radar types released on August 14, 2014 * type 1 PRI values randomly selected within the range of 518 and 3066. * divide it to 3 groups is good enough for both of radar detection and * avoiding false detection based on practical test results * collected for more than a year. */ static const struct radar_detector_specs fcc_radar_ref_types[] = …; static const struct radar_types fcc_radar_types = …; #define JP_PATTERN(ID, WMIN, WMAX, PMIN, PMAX, PRF, PPB, RATE, CHIRP) … static const struct radar_detector_specs jp_radar_ref_types[] = …; static const struct radar_types jp_radar_types = …; static const struct radar_types *dfs_domains[] = …; /** * get_dfs_domain_radar_types() - get radar types for a given DFS domain * @region: regulatory DFS region * * Return value: radar_types ptr on success, NULL if DFS domain is not supported */ static const struct radar_types * get_dfs_domain_radar_types(enum nl80211_dfs_regions region) { … } /** * struct channel_detector - detector elements for a DFS channel * @head: list_head * @freq: frequency for this channel detector in MHz * @detectors: array of dynamically created detector elements for this freq * * Channel detectors are required to provide multi-channel DFS detection, e.g. * to support off-channel scanning. A pattern detector has a list of channels * radar pulses have been reported for in the past. */ struct channel_detector { … }; /* channel_detector_reset() - reset detector lines for a given channel */ static void channel_detector_reset(struct dfs_pattern_detector *dpd, struct channel_detector *cd) { … } /* channel_detector_exit() - destructor */ static void channel_detector_exit(struct dfs_pattern_detector *dpd, struct channel_detector *cd) { … } static struct channel_detector * channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq) { … } /** * channel_detector_get() - get channel detector for given frequency * @dpd: DPD instance pointer * @freq: freq frequency in MHz * * Return value: pointer to channel detector on success, NULL otherwise * * Return existing channel detector for the given frequency or return a * newly create one. */ static struct channel_detector * channel_detector_get(struct dfs_pattern_detector *dpd, u16 freq) { … } /* * DFS Pattern Detector */ /* dpd_reset(): reset all channel detectors */ static void dpd_reset(struct dfs_pattern_detector *dpd) { … } static void dpd_exit(struct dfs_pattern_detector *dpd) { … } static bool dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event, struct radar_detector_specs *rs) { … } static struct ath_dfs_pool_stats dpd_get_stats(struct dfs_pattern_detector *dpd) { … } static bool dpd_set_domain(struct dfs_pattern_detector *dpd, enum nl80211_dfs_regions region) { … } static const struct dfs_pattern_detector default_dpd = …; struct dfs_pattern_detector * dfs_pattern_detector_init(struct ath_common *common, enum nl80211_dfs_regions region) { … } EXPORT_SYMBOL(…);