wlan_dfs_ioctl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. * Copyright (c) 2011, 2016-2019 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2010, Atheros Communications Inc.
  4. * All Rights Reserved.
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for
  7. * any purpose with or without fee is hereby granted, provided that the
  8. * above copyright notice and this permission notice appear in all
  9. * copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  12. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  13. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  14. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  15. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  16. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  17. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  18. * PERFORMANCE OF THIS SOFTWARE.
  19. */
  20. /**
  21. * DOC: This file has dfs IOCTL Defines.
  22. */
  23. #ifndef _DFS_IOCTL_H_
  24. #define _DFS_IOCTL_H_
  25. #define DFS_MUTE_TIME 1
  26. #define DFS_SET_THRESH 2
  27. #define DFS_GET_THRESH 3
  28. #define DFS_GET_USENOL 4
  29. #define DFS_SET_USENOL 5
  30. #define DFS_RADARDETECTS 6
  31. #define DFS_BANGRADAR 7
  32. #define DFS_SHOW_NOL 8
  33. #define DFS_DISABLE_DETECT 9
  34. #define DFS_ENABLE_DETECT 10
  35. #define DFS_DISABLE_FFT 11
  36. #define DFS_ENABLE_FFT 12
  37. #define DFS_SET_DEBUG_LEVEL 13
  38. #define DFS_GET_NOL 14
  39. #define DFS_SET_NOL 15
  40. #define DFS_SET_FALSE_RSSI_THRES 16
  41. #define DFS_SET_PEAK_MAG 17
  42. #define DFS_IGNORE_CAC 18
  43. #define DFS_SET_NOL_TIMEOUT 19
  44. #define DFS_GET_CAC_VALID_TIME 20
  45. #define DFS_SET_CAC_VALID_TIME 21
  46. #define DFS_SHOW_NOLHISTORY 22
  47. #define DFS_SHOW_PRECAC_LISTS 23
  48. #define DFS_RESET_PRECAC_LISTS 24
  49. #define DFS_SET_DISABLE_RADAR_MARKING 25
  50. #define DFS_GET_DISABLE_RADAR_MARKING 26
  51. #define DFS_INJECT_SEQUENCE 27
  52. #define DFS_ALLOW_HW_PULSES 28
  53. #define DFS_SET_PRI_MULTIPILER 29
  54. /*
  55. * Spectral IOCTLs use DFS_LAST_IOCTL as the base.
  56. * This must always be the last IOCTL in DFS and have
  57. * the highest value.
  58. */
  59. #define DFS_LAST_IOCTL 29
  60. #ifndef DFS_CHAN_MAX
  61. #define DFS_CHAN_MAX 1023
  62. #endif
  63. /**
  64. * struct dfsreq_nolelem - NOL elements.
  65. * @nol_freq: NOL channel frequency.
  66. * @nol_chwidth: NOL channel width.
  67. * @nol_start_ticks: OS ticks when the NOL timer started.
  68. * @nol_timeout_ms: Nol timeout value in msec.
  69. */
  70. struct dfsreq_nolelem {
  71. uint16_t nol_freq;
  72. uint16_t nol_chwidth;
  73. unsigned long nol_start_ticks;
  74. uint32_t nol_timeout_ms;
  75. };
  76. struct dfsreq_nolinfo {
  77. uint32_t dfs_ch_nchans;
  78. struct dfsreq_nolelem dfs_nol[DFS_CHAN_MAX];
  79. };
  80. /*
  81. * IOCTL parameter types
  82. */
  83. #define DFS_PARAM_FIRPWR 1
  84. #define DFS_PARAM_RRSSI 2
  85. #define DFS_PARAM_HEIGHT 3
  86. #define DFS_PARAM_PRSSI 4
  87. #define DFS_PARAM_INBAND 5
  88. /* 5413 specific parameters */
  89. #define DFS_PARAM_RELPWR 7
  90. #define DFS_PARAM_RELSTEP 8
  91. #define DFS_PARAM_MAXLEN 9
  92. /**
  93. * struct dfs_ioctl_params - DFS ioctl params.
  94. * @dfs_firpwr: FIR pwr out threshold.
  95. * @dfs_rrssi: Radar rssi thresh.
  96. * @dfs_height: Pulse height thresh.
  97. * @dfs_prssi: Pulse rssi thresh.
  98. * @dfs_inband: Inband thresh.
  99. * @dfs_relpwr: Pulse relative pwr thresh.
  100. * @dfs_relstep: Pulse relative step thresh.
  101. * @dfs_maxlen: Pulse max duration.
  102. */
  103. struct dfs_ioctl_params {
  104. int32_t dfs_firpwr;
  105. int32_t dfs_rrssi;
  106. int32_t dfs_height;
  107. int32_t dfs_prssi;
  108. int32_t dfs_inband;
  109. int32_t dfs_relpwr;
  110. int32_t dfs_relstep;
  111. int32_t dfs_maxlen;
  112. };
  113. /* Types of Bangradar commands:
  114. * @DFS_BANGRADAR_FOR_ALL_SUBCHANS : Bangradar with no arguments.
  115. * All the subchannels in the current
  116. * channel shall be added.
  117. * @DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID : Bangradar with 1 (seg_id) argument
  118. * All subchannels of the specific
  119. * seg_id shall be added.
  120. * @DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS : Bangradar with all (segment ID,
  121. * is_chirp and frequency offset)
  122. * arguments.
  123. * Only radar infected subchannels
  124. * of the specific seg_id shall be
  125. * added.
  126. *
  127. * (Unless all arguments are given, we cannot determine which specific
  128. * subchannels to simulate the radar on, hence simulate in all subchans).
  129. */
  130. enum dfs_bangradar_types {
  131. DFS_NO_BANGRADAR = 0,
  132. DFS_BANGRADAR_FOR_ALL_SUBCHANS,
  133. DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID,
  134. DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS,
  135. DFS_INVALID_BANGRADAR_TYPE
  136. };
  137. /**
  138. * struct dfs_bangradar_params - DFS bangradar params.
  139. * @bangradar_type: Type of Bangradar.
  140. * @seg_id: Segment ID information.
  141. * @is_chirp: Chirp radar or not.
  142. * @freq_offset: Frequency offset at which radar was found.
  143. */
  144. struct dfs_bangradar_params {
  145. enum dfs_bangradar_types bangradar_type;
  146. uint8_t seg_id;
  147. uint8_t is_chirp;
  148. int32_t freq_offset;
  149. };
  150. #define DFS_IOCTL_PARAM_NOVAL 65535
  151. #define DFS_IOCTL_PARAM_ENABLE 0x8000
  152. /* Random channel flags */
  153. /* Flag to exclude current operating channels */
  154. #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH 0x0001 /* 0000 0000 0000 0001 */
  155. /* Flag to exclude weather channels */
  156. #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH 0x0002 /* 0000 0000 0000 0010 */
  157. /* Flag to exclude indoor channels */
  158. #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH 0x0004 /* 0000 0000 0000 0100 */
  159. /* Flag to exclude outdoor channels */
  160. #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH 0x0008 /* 0000 0000 0000 1000 */
  161. /* Flag to exclude dfs channels */
  162. #define DFS_RANDOM_CH_FLAG_NO_DFS_CH 0x0010 /* 0000 0000 0001 0000 */
  163. /* Flag to exclude all 5GHz channels */
  164. #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH 0x0020 /* 0000 0000 0010 0000 */
  165. /* Flag to exclude all 2.4GHz channels */
  166. #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH 0x0040 /* 0000 0000 0100 0000 */
  167. /* Flag to enable Reduced BW Agile DFS */
  168. #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW 0x0080 /* 0000 0000 1000 0000 */
  169. /* Flag to exclude Japan W53 channnels */
  170. #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH 0x0100 /* 0000 0001 0000 0000 */
  171. /**
  172. * struct wlan_dfs_caps - DFS capability structure.
  173. * @wlan_dfs_ext_chan_ok: Can radar be detected on the extension chan?
  174. * @wlan_dfs_combined_rssi_ok: Can use combined radar RSSI?
  175. * @wlan_dfs_use_enhancement: This flag is used to indicate if radar
  176. * detection scheme should use enhanced chirping
  177. * detection algorithm. This flag also determines
  178. * if certain radar data should be discarded to
  179. * minimize false detection of radar.
  180. * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
  181. * @wlan_chip_is_bb_tlv: Chip is BB TLV?
  182. * @wlan_chip_is_over_sampled: Is Over sampled.
  183. * @wlan_chip_is_ht160: IS VHT160?
  184. * @wlan_chip_is_false_detect: Is False detected?
  185. * @wlan_fastdiv_val: Goes with wlan_strong_signal_diversiry: If we
  186. * have fast diversity capability, read off
  187. * Strong Signal fast diversity count set in the
  188. * ini file, and store so we can restore the
  189. * value when radar is disabled.
  190. */
  191. struct wlan_dfs_caps {
  192. uint32_t wlan_dfs_ext_chan_ok:1,
  193. wlan_dfs_combined_rssi_ok:1,
  194. wlan_dfs_use_enhancement:1,
  195. wlan_strong_signal_diversiry:1,
  196. wlan_chip_is_bb_tlv:1,
  197. wlan_chip_is_over_sampled:1,
  198. wlan_chip_is_ht160:1,
  199. wlan_chip_is_false_detect:1;
  200. uint32_t wlan_fastdiv_val;
  201. };
  202. /**
  203. * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
  204. * @pe_firpwr: FIR pwr out threshold.
  205. * @pe_rrssi: Radar rssi thresh.
  206. * @pe_height: Pulse height thresh.
  207. * @pe_prssi: Pulse rssi thresh.
  208. * @pe_inband: Inband thresh.
  209. * @pe_relpwr: Relative power threshold in 0.5dB steps.
  210. * @pe_relstep: Pulse Relative step threshold in 0.5dB steps.
  211. * @pe_maxlen: Max length of radar sign in 0.8us units.
  212. * @pe_usefir128: Use the average in-band power measured over 128 cycles.
  213. * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
  214. * weak signal detect or pkt is detected immediately after tx
  215. * to rx transition.
  216. * @pe_enmaxrssi: Enable to use the max rssi instead of the last rssi during
  217. * fine gain changes for radar detection.
  218. */
  219. struct wlan_dfs_phyerr_param {
  220. int32_t pe_firpwr;
  221. int32_t pe_rrssi;
  222. int32_t pe_height;
  223. int32_t pe_prssi;
  224. int32_t pe_inband;
  225. uint32_t pe_relpwr;
  226. uint32_t pe_relstep;
  227. uint32_t pe_maxlen;
  228. bool pe_usefir128;
  229. bool pe_blockradar;
  230. bool pe_enmaxrssi;
  231. };
  232. /**
  233. * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace
  234. * @WLAN_EV_RADAR_DETECTED: Radar is detected
  235. * @WLAN_EV_CAC_STARTED: CAC timer has started
  236. * @WLAN_EV_CAC_COMPLETED: CAC timer completed
  237. * @WLAN_EV_NOL_STARTED: NOL started
  238. * @WLAN_EV_NOL_FINISHED: NOL Completed
  239. *
  240. * DFS events such as radar detected, CAC started,
  241. * CAC completed, NOL started, NOL finished
  242. */
  243. enum WLAN_DFS_EVENTS {
  244. WLAN_EV_RADAR_DETECTED,
  245. WLAN_EV_CAC_STARTED,
  246. WLAN_EV_CAC_COMPLETED,
  247. WLAN_EV_NOL_STARTED,
  248. WLAN_EV_NOL_FINISHED,
  249. };
  250. #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR)
  251. /**
  252. * Structure of Pulse to be injected into the DFS Module
  253. * ******************************************************
  254. * Header
  255. * ======
  256. * ----------|--------------|
  257. * num_pulses| total_len_seq|
  258. * ----------|--------------|
  259. * Buffer Contents per pulse:
  260. * ==========================
  261. * ------|----------|-----------|----------|-----------|---------------|--------
  262. * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT
  263. * | | | | | |Buffer..
  264. * ------|----------|-----------|----------|-----------|---------------|--------
  265. */
  266. /**
  267. * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the
  268. * user file.
  269. * @r_rssi: RSSI of the pulse.
  270. * @r_ext_rssi: Extension Channel RSSI.
  271. * @r_rs_tstamp: Timestamp.
  272. * @r_fulltsf: TSF64.
  273. * @fft_datalen: Total len of FFT.
  274. * @total_len_pulse: Total len of the pulse.
  275. * @fft_buf: Pointer to fft data.
  276. */
  277. struct synthetic_pulse {
  278. uint8_t r_rssi;
  279. uint8_t r_ext_rssi;
  280. uint32_t r_rs_tstamp;
  281. uint64_t r_fulltsf;
  282. uint16_t fft_datalen;
  283. uint16_t total_len_pulse;
  284. unsigned char *fft_buf;
  285. } qdf_packed;
  286. /**
  287. * struct synthetic_seq - Structure to hold an array of pointers to the
  288. * pulse structure.
  289. * @num_pulses: Total num of pulses in the sequence.
  290. * @total_len_seq: Total len of the sequence.
  291. * @pulse: Array of pointers to synthetic_pulse structure.
  292. */
  293. struct synthetic_seq {
  294. uint8_t num_pulses;
  295. uint32_t total_len_seq;
  296. struct synthetic_pulse *pulse[0];
  297. };
  298. /**
  299. * struct seq_store - Structure to hold an array of pointers to the synthetic
  300. * sequence structure.
  301. * @num_sequence: Total number of "sequence of pulses" in the file.
  302. * @seq_arr: Array of pointers to synthetic_seq structure.
  303. */
  304. struct seq_store {
  305. uint8_t num_sequence;
  306. struct synthetic_seq *seq_arr[0];
  307. };
  308. #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */
  309. #endif /* _DFS_IOCTL_H_ */