brintos

brintos / linux-shallow public Read only

0
0
Text · 3.9 KiB · 18db6f4 Raw
123 lines · c
1/*2 * Copyright (c) 2012 Neratec Solutions AG3 *4 * Permission to use, copy, modify, and/or distribute this software for any5 * purpose with or without fee is hereby granted, provided that the above6 * copyright notice and this permission notice appear in all copies.7 *8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.15 */16 17#ifndef DFS_PATTERN_DETECTOR_H18#define DFS_PATTERN_DETECTOR_H19 20#include <linux/types.h>21#include <linux/list.h>22#include <linux/nl80211.h>23 24/* tolerated deviation of radar time stamp in usecs on both sides25 * TODO: this might need to be HW-dependent26 */27#define PRI_TOLERANCE	1628 29/**30 * struct ath_dfs_pool_stats - DFS Statistics for global pools31 */32struct ath_dfs_pool_stats {33	u32 pool_reference;34	u32 pulse_allocated;35	u32 pulse_alloc_error;36	u32 pulse_used;37	u32 pseq_allocated;38	u32 pseq_alloc_error;39	u32 pseq_used;40};41 42/**43 * struct pulse_event - describing pulses reported by PHY44 * @ts: pulse time stamp in us45 * @freq: channel frequency in MHz46 * @width: pulse duration in us47 * @rssi: rssi of radar event48 * @chirp: chirp detected in pulse49 */50struct pulse_event {51	u64 ts;52	u16 freq;53	u8 width;54	u8 rssi;55	bool chirp;56};57 58/**59 * struct radar_detector_specs - detector specs for a radar pattern type60 * @type_id: pattern type, as defined by regulatory61 * @width_min: minimum radar pulse width in [us]62 * @width_max: maximum radar pulse width in [us]63 * @pri_min: minimum pulse repetition interval in [us] (including tolerance)64 * @pri_max: minimum pri in [us] (including tolerance)65 * @num_pri: maximum number of different pri for this type66 * @ppb: pulses per bursts for this type67 * @ppb_thresh: number of pulses required to trigger detection68 * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]69 * @chirp: chirp required for the radar pattern70 */71struct radar_detector_specs {72	u8 type_id;73	u8 width_min;74	u8 width_max;75	u16 pri_min;76	u16 pri_max;77	u8 num_pri;78	u8 ppb;79	u8 ppb_thresh;80	u8 max_pri_tolerance;81	bool chirp;82};83 84/**85 * struct dfs_pattern_detector - DFS pattern detector86 * @exit(): destructor87 * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes88 * @add_pulse(): add radar pulse to detector, returns true on detection89 * @region: active DFS region, NL80211_DFS_UNSET until set90 * @num_radar_types: number of different radar types91 * @last_pulse_ts: time stamp of last valid pulse in usecs92 * @radar_detector_specs: array of radar detection specs93 * @channel_detectors: list connecting channel_detector elements94 */95struct dfs_pattern_detector {96	void (*exit)(struct dfs_pattern_detector *dpd);97	bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,98			   enum nl80211_dfs_regions region);99	bool (*add_pulse)(struct dfs_pattern_detector *dpd,100			  struct pulse_event *pe,101			  struct radar_detector_specs *rs);102 103	struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);104	enum nl80211_dfs_regions region;105	u8 num_radar_types;106	u64 last_pulse_ts;107	/* needed for ath_dbg() */108	struct ath_common *common;109 110	const struct radar_detector_specs *radar_spec;111	struct list_head channel_detectors;112};113 114/**115 * dfs_pattern_detector_init() - constructor for pattern detector class116 * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation117 * @return instance pointer on success, NULL otherwise118 */119extern struct dfs_pattern_detector *120dfs_pattern_detector_init(struct ath_common *common,121			  enum nl80211_dfs_regions region);122#endif /* DFS_PATTERN_DETECTOR_H */123