Path: blob/main/sys/contrib/dev/athk/dfs_pattern_detector.h
48254 views
/*1* Copyright (c) 2012 Neratec Solutions AG2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES8* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF9* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR10* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES11* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN12* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF13* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14*/1516#ifndef DFS_PATTERN_DETECTOR_H17#define DFS_PATTERN_DETECTOR_H1819#include <linux/types.h>20#include <linux/list.h>21#include <linux/nl80211.h>2223/* tolerated deviation of radar time stamp in usecs on both sides24* TODO: this might need to be HW-dependent25*/26#define PRI_TOLERANCE 162728/**29* struct ath_dfs_pool_stats - DFS Statistics for global pools30*/31struct ath_dfs_pool_stats {32u32 pool_reference;33u32 pulse_allocated;34u32 pulse_alloc_error;35u32 pulse_used;36u32 pseq_allocated;37u32 pseq_alloc_error;38u32 pseq_used;39};4041/**42* struct pulse_event - describing pulses reported by PHY43* @ts: pulse time stamp in us44* @freq: channel frequency in MHz45* @width: pulse duration in us46* @rssi: rssi of radar event47* @chirp: chirp detected in pulse48*/49struct pulse_event {50u64 ts;51u16 freq;52u8 width;53u8 rssi;54bool chirp;55};5657/**58* struct radar_detector_specs - detector specs for a radar pattern type59* @type_id: pattern type, as defined by regulatory60* @width_min: minimum radar pulse width in [us]61* @width_max: maximum radar pulse width in [us]62* @pri_min: minimum pulse repetition interval in [us] (including tolerance)63* @pri_max: minimum pri in [us] (including tolerance)64* @num_pri: maximum number of different pri for this type65* @ppb: pulses per bursts for this type66* @ppb_thresh: number of pulses required to trigger detection67* @max_pri_tolerance: pulse time stamp tolerance on both sides [us]68* @chirp: chirp required for the radar pattern69*/70struct radar_detector_specs {71u8 type_id;72u8 width_min;73u8 width_max;74u16 pri_min;75u16 pri_max;76u8 num_pri;77u8 ppb;78u8 ppb_thresh;79u8 max_pri_tolerance;80bool chirp;81};8283/**84* struct dfs_pattern_detector - DFS pattern detector85* @exit(): destructor86* @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes87* @add_pulse(): add radar pulse to detector, returns true on detection88* @region: active DFS region, NL80211_DFS_UNSET until set89* @num_radar_types: number of different radar types90* @last_pulse_ts: time stamp of last valid pulse in usecs91* @radar_detector_specs: array of radar detection specs92* @channel_detectors: list connecting channel_detector elements93*/94struct dfs_pattern_detector {95void (*exit)(struct dfs_pattern_detector *dpd);96bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,97enum nl80211_dfs_regions region);98bool (*add_pulse)(struct dfs_pattern_detector *dpd,99struct pulse_event *pe,100struct radar_detector_specs *rs);101102struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);103enum nl80211_dfs_regions region;104u8 num_radar_types;105u64 last_pulse_ts;106/* needed for ath_dbg() */107struct ath_common *common;108109const struct radar_detector_specs *radar_spec;110struct list_head channel_detectors;111};112113/**114* dfs_pattern_detector_init() - constructor for pattern detector class115* @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation116* @return instance pointer on success, NULL otherwise117*/118extern struct dfs_pattern_detector *119dfs_pattern_detector_init(struct ath_common *common,120enum nl80211_dfs_regions region);121#endif /* DFS_PATTERN_DETECTOR_H */122123124