Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2012 Neratec Solutions AG
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef DFS_PATTERN_DETECTOR_H
0018 #define DFS_PATTERN_DETECTOR_H
0019 
0020 #include <linux/types.h>
0021 #include <linux/list.h>
0022 #include <linux/nl80211.h>
0023 
0024 /* tolerated deviation of radar time stamp in usecs on both sides
0025  * TODO: this might need to be HW-dependent
0026  */
0027 #define PRI_TOLERANCE   16
0028 
0029 /**
0030  * struct ath_dfs_pool_stats - DFS Statistics for global pools
0031  */
0032 struct ath_dfs_pool_stats {
0033     u32 pool_reference;
0034     u32 pulse_allocated;
0035     u32 pulse_alloc_error;
0036     u32 pulse_used;
0037     u32 pseq_allocated;
0038     u32 pseq_alloc_error;
0039     u32 pseq_used;
0040 };
0041 
0042 /**
0043  * struct pulse_event - describing pulses reported by PHY
0044  * @ts: pulse time stamp in us
0045  * @freq: channel frequency in MHz
0046  * @width: pulse duration in us
0047  * @rssi: rssi of radar event
0048  * @chirp: chirp detected in pulse
0049  */
0050 struct pulse_event {
0051     u64 ts;
0052     u16 freq;
0053     u8 width;
0054     u8 rssi;
0055     bool chirp;
0056 };
0057 
0058 /**
0059  * struct radar_detector_specs - detector specs for a radar pattern type
0060  * @type_id: pattern type, as defined by regulatory
0061  * @width_min: minimum radar pulse width in [us]
0062  * @width_max: maximum radar pulse width in [us]
0063  * @pri_min: minimum pulse repetition interval in [us] (including tolerance)
0064  * @pri_max: minimum pri in [us] (including tolerance)
0065  * @num_pri: maximum number of different pri for this type
0066  * @ppb: pulses per bursts for this type
0067  * @ppb_thresh: number of pulses required to trigger detection
0068  * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]
0069  * @chirp: chirp required for the radar pattern
0070  */
0071 struct radar_detector_specs {
0072     u8 type_id;
0073     u8 width_min;
0074     u8 width_max;
0075     u16 pri_min;
0076     u16 pri_max;
0077     u8 num_pri;
0078     u8 ppb;
0079     u8 ppb_thresh;
0080     u8 max_pri_tolerance;
0081     bool chirp;
0082 };
0083 
0084 /**
0085  * struct dfs_pattern_detector - DFS pattern detector
0086  * @exit(): destructor
0087  * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes
0088  * @add_pulse(): add radar pulse to detector, returns true on detection
0089  * @region: active DFS region, NL80211_DFS_UNSET until set
0090  * @num_radar_types: number of different radar types
0091  * @last_pulse_ts: time stamp of last valid pulse in usecs
0092  * @radar_detector_specs: array of radar detection specs
0093  * @channel_detectors: list connecting channel_detector elements
0094  */
0095 struct dfs_pattern_detector {
0096     void (*exit)(struct dfs_pattern_detector *dpd);
0097     bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,
0098                enum nl80211_dfs_regions region);
0099     bool (*add_pulse)(struct dfs_pattern_detector *dpd,
0100               struct pulse_event *pe,
0101               struct radar_detector_specs *rs);
0102 
0103     struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);
0104     enum nl80211_dfs_regions region;
0105     u8 num_radar_types;
0106     u64 last_pulse_ts;
0107     /* needed for ath_dbg() */
0108     struct ath_common *common;
0109 
0110     const struct radar_detector_specs *radar_spec;
0111     struct list_head channel_detectors;
0112 };
0113 
0114 /**
0115  * dfs_pattern_detector_init() - constructor for pattern detector class
0116  * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation
0117  * @return instance pointer on success, NULL otherwise
0118  */
0119 extern struct dfs_pattern_detector *
0120 dfs_pattern_detector_init(struct ath_common *common,
0121               enum nl80211_dfs_regions region);
0122 #endif /* DFS_PATTERN_DETECTOR_H */