wlan_dfs_ioctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /*
  2. * Copyright (c) 2011, 2016-2020 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. #define RESTRICTED_80P80_START_FREQ 5660
  55. #define RESTRICTED_80P80_END_FREQ 5805
  56. /* Check if the given frequencies are within restricted 80P80 start freq(5660)
  57. * and end freq (5805).
  58. */
  59. #define CHAN_WITHIN_RESTRICTED_80P80(cfreq1, cfreq2) \
  60. ((((cfreq1) >= RESTRICTED_80P80_START_FREQ) && \
  61. ((cfreq1) <= RESTRICTED_80P80_END_FREQ) && \
  62. ((cfreq2) >= RESTRICTED_80P80_START_FREQ) && \
  63. ((cfreq2) <= RESTRICTED_80P80_END_FREQ)) ? true : false)
  64. /*
  65. * Spectral IOCTLs use DFS_LAST_IOCTL as the base.
  66. * This must always be the last IOCTL in DFS and have
  67. * the highest value.
  68. */
  69. #define DFS_LAST_IOCTL 29
  70. #ifndef DFS_CHAN_MAX
  71. #define DFS_CHAN_MAX 25
  72. #endif
  73. /**
  74. * struct dfsreq_nolelem - NOL elements.
  75. * @nol_freq: NOL channel frequency.
  76. * @nol_chwidth: NOL channel width.
  77. * @nol_start_us: OS microseconds when the NOL timer started.
  78. * @nol_timeout_ms: Nol timeout value in msec.
  79. */
  80. struct dfsreq_nolelem {
  81. uint16_t nol_freq;
  82. uint16_t nol_chwidth;
  83. uint64_t nol_start_us;
  84. uint32_t nol_timeout_ms;
  85. };
  86. struct dfsreq_nolinfo {
  87. uint32_t dfs_ch_nchans;
  88. struct dfsreq_nolelem dfs_nol[DFS_CHAN_MAX];
  89. };
  90. /*
  91. * IOCTL parameter types
  92. */
  93. #define DFS_PARAM_FIRPWR 1
  94. #define DFS_PARAM_RRSSI 2
  95. #define DFS_PARAM_HEIGHT 3
  96. #define DFS_PARAM_PRSSI 4
  97. #define DFS_PARAM_INBAND 5
  98. /* 5413 specific parameters */
  99. #define DFS_PARAM_RELPWR 7
  100. #define DFS_PARAM_RELSTEP 8
  101. #define DFS_PARAM_MAXLEN 9
  102. /**
  103. * struct dfs_ioctl_params - DFS ioctl params.
  104. * @dfs_firpwr: FIR pwr out threshold.
  105. * @dfs_rrssi: Radar rssi thresh.
  106. * @dfs_height: Pulse height thresh.
  107. * @dfs_prssi: Pulse rssi thresh.
  108. * @dfs_inband: Inband thresh.
  109. * @dfs_relpwr: Pulse relative pwr thresh.
  110. * @dfs_relstep: Pulse relative step thresh.
  111. * @dfs_maxlen: Pulse max duration.
  112. */
  113. struct dfs_ioctl_params {
  114. int32_t dfs_firpwr;
  115. int32_t dfs_rrssi;
  116. int32_t dfs_height;
  117. int32_t dfs_prssi;
  118. int32_t dfs_inband;
  119. int32_t dfs_relpwr;
  120. int32_t dfs_relstep;
  121. int32_t dfs_maxlen;
  122. };
  123. /* Types of Bangradar commands:
  124. * @DFS_BANGRADAR_FOR_ALL_SUBCHANS : Bangradar with no arguments.
  125. * All the subchannels in the current
  126. * channel shall be added.
  127. * @DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID : Bangradar with 1 (seg_id) argument
  128. * All subchannels of the specific
  129. * seg_id shall be added.
  130. * @DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS : Bangradar with all (segment ID,
  131. * is_chirp and frequency offset)
  132. * arguments.
  133. * Only radar infected subchannels
  134. * of the specific seg_id shall be
  135. * added.
  136. *
  137. * (Unless all arguments are given, we cannot determine which specific
  138. * subchannels to simulate the radar on, hence simulate in all subchans).
  139. */
  140. enum dfs_bangradar_types {
  141. DFS_NO_BANGRADAR = 0,
  142. DFS_BANGRADAR_FOR_ALL_SUBCHANS,
  143. DFS_BANGRADAR_FOR_ALL_SUBCHANS_OF_SEGID,
  144. DFS_BANGRADAR_FOR_SPECIFIC_SUBCHANS,
  145. DFS_INVALID_BANGRADAR_TYPE
  146. };
  147. /**
  148. * struct dfs_bangradar_params - DFS bangradar params.
  149. * @bangradar_type: Type of Bangradar.
  150. * @seg_id: Segment ID information.
  151. * @is_chirp: Chirp radar or not.
  152. * @freq_offset: Frequency offset at which radar was found.
  153. * @detector_id: Detector ID corresponding to primary/agile detectors.
  154. */
  155. struct dfs_bangradar_params {
  156. enum dfs_bangradar_types bangradar_type;
  157. uint8_t seg_id;
  158. uint8_t is_chirp;
  159. int32_t freq_offset;
  160. uint8_t detector_id;
  161. };
  162. #define DFS_IOCTL_PARAM_NOVAL 65535
  163. #define DFS_IOCTL_PARAM_ENABLE 0x8000
  164. /* Random channel flags */
  165. /* Flag to exclude current operating channels */
  166. #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH 0x0001 /* 0000 0000 0000 0001 */
  167. /* Flag to exclude weather channels */
  168. #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH 0x0002 /* 0000 0000 0000 0010 */
  169. /* Flag to exclude indoor channels */
  170. #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH 0x0004 /* 0000 0000 0000 0100 */
  171. /* Flag to exclude outdoor channels */
  172. #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH 0x0008 /* 0000 0000 0000 1000 */
  173. /* Flag to exclude dfs channels */
  174. #define DFS_RANDOM_CH_FLAG_NO_DFS_CH 0x0010 /* 0000 0000 0001 0000 */
  175. /* Flag to exclude all 5GHz channels */
  176. #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH 0x0020 /* 0000 0000 0010 0000 */
  177. /* Flag to exclude all 2.4GHz channels */
  178. #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH 0x0040 /* 0000 0000 0100 0000 */
  179. /* Flag to enable Reduced BW Agile DFS */
  180. #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW 0x0080 /* 0000 0000 1000 0000 */
  181. /* Flag to exclude Japan W53 channnels */
  182. #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH 0x0100 /* 0000 0001 0000 0000 */
  183. /* Restricted 80P80 MHz is enabled */
  184. #define DFS_RANDOM_CH_FLAG_RESTRICTED_80P80_ENABLED 0x0200
  185. /* 0000 0010 0000 0000 */
  186. /**
  187. * struct wlan_dfs_caps - DFS capability structure.
  188. * @wlan_dfs_ext_chan_ok: Can radar be detected on the extension chan?
  189. * @wlan_dfs_combined_rssi_ok: Can use combined radar RSSI?
  190. * @wlan_dfs_use_enhancement: This flag is used to indicate if radar
  191. * detection scheme should use enhanced chirping
  192. * detection algorithm. This flag also determines
  193. * if certain radar data should be discarded to
  194. * minimize false detection of radar.
  195. * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
  196. * @wlan_chip_is_bb_tlv: Chip is BB TLV?
  197. * @wlan_chip_is_over_sampled: Is Over sampled.
  198. * @wlan_chip_is_ht160: IS VHT160?
  199. * @wlan_chip_is_false_detect: Is False detected?
  200. * @wlan_fastdiv_val: Goes with wlan_strong_signal_diversiry: If we
  201. * have fast diversity capability, read off
  202. * Strong Signal fast diversity count set in the
  203. * ini file, and store so we can restore the
  204. * value when radar is disabled.
  205. */
  206. struct wlan_dfs_caps {
  207. uint32_t wlan_dfs_ext_chan_ok:1,
  208. wlan_dfs_combined_rssi_ok:1,
  209. wlan_dfs_use_enhancement:1,
  210. wlan_strong_signal_diversiry:1,
  211. wlan_chip_is_bb_tlv:1,
  212. wlan_chip_is_over_sampled:1,
  213. wlan_chip_is_ht160:1,
  214. wlan_chip_is_false_detect:1;
  215. uint32_t wlan_fastdiv_val;
  216. };
  217. /**
  218. * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
  219. * @pe_firpwr: FIR pwr out threshold.
  220. * @pe_rrssi: Radar rssi thresh.
  221. * @pe_height: Pulse height thresh.
  222. * @pe_prssi: Pulse rssi thresh.
  223. * @pe_inband: Inband thresh.
  224. * @pe_relpwr: Relative power threshold in 0.5dB steps.
  225. * @pe_relstep: Pulse Relative step threshold in 0.5dB steps.
  226. * @pe_maxlen: Max length of radar sign in 0.8us units.
  227. * @pe_usefir128: Use the average in-band power measured over 128 cycles.
  228. * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
  229. * weak signal detect or pkt is detected immediately after tx
  230. * to rx transition.
  231. * @pe_enmaxrssi: Enable to use the max rssi instead of the last rssi during
  232. * fine gain changes for radar detection.
  233. */
  234. struct wlan_dfs_phyerr_param {
  235. int32_t pe_firpwr;
  236. int32_t pe_rrssi;
  237. int32_t pe_height;
  238. int32_t pe_prssi;
  239. int32_t pe_inband;
  240. uint32_t pe_relpwr;
  241. uint32_t pe_relstep;
  242. uint32_t pe_maxlen;
  243. bool pe_usefir128;
  244. bool pe_blockradar;
  245. bool pe_enmaxrssi;
  246. };
  247. /**
  248. * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace
  249. * @WLAN_EV_RADAR_DETECTED: Radar is detected
  250. * @WLAN_EV_CAC_STARTED: CAC timer has started
  251. * @WLAN_EV_CAC_COMPLETED: CAC timer completed
  252. * @WLAN_EV_NOL_STARTED: NOL started
  253. * @WLAN_EV_NOL_FINISHED: NOL Completed
  254. *
  255. * DFS events such as radar detected, CAC started,
  256. * CAC completed, NOL started, NOL finished
  257. */
  258. enum WLAN_DFS_EVENTS {
  259. WLAN_EV_RADAR_DETECTED,
  260. WLAN_EV_CAC_STARTED,
  261. WLAN_EV_CAC_COMPLETED,
  262. WLAN_EV_NOL_STARTED,
  263. WLAN_EV_NOL_FINISHED,
  264. };
  265. #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR)
  266. /**
  267. * Structure of Pulse to be injected into the DFS Module
  268. * ******************************************************
  269. * Header
  270. * ======
  271. * ----------|--------------|
  272. * num_pulses| total_len_seq|
  273. * ----------|--------------|
  274. * Buffer Contents per pulse:
  275. * ==========================
  276. * ------|----------|-----------|----------|-----------|---------------|--------
  277. * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT
  278. * | | | | | |Buffer..
  279. * ------|----------|-----------|----------|-----------|---------------|--------
  280. */
  281. /**
  282. * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the
  283. * user file.
  284. * @r_rssi: RSSI of the pulse.
  285. * @r_ext_rssi: Extension Channel RSSI.
  286. * @r_rs_tstamp: Timestamp.
  287. * @r_fulltsf: TSF64.
  288. * @fft_datalen: Total len of FFT.
  289. * @total_len_pulse: Total len of the pulse.
  290. * @fft_buf: Pointer to fft data.
  291. */
  292. struct synthetic_pulse {
  293. uint8_t r_rssi;
  294. uint8_t r_ext_rssi;
  295. uint32_t r_rs_tstamp;
  296. uint64_t r_fulltsf;
  297. uint16_t fft_datalen;
  298. uint16_t total_len_pulse;
  299. unsigned char *fft_buf;
  300. } qdf_packed;
  301. /**
  302. * struct synthetic_seq - Structure to hold an array of pointers to the
  303. * pulse structure.
  304. * @num_pulses: Total num of pulses in the sequence.
  305. * @total_len_seq: Total len of the sequence.
  306. * @pulse: Array of pointers to synthetic_pulse structure.
  307. */
  308. struct synthetic_seq {
  309. uint8_t num_pulses;
  310. uint32_t total_len_seq;
  311. struct synthetic_pulse *pulse[0];
  312. };
  313. /**
  314. * struct seq_store - Structure to hold an array of pointers to the synthetic
  315. * sequence structure.
  316. * @num_sequence: Total number of "sequence of pulses" in the file.
  317. * @seq_arr: Array of pointers to synthetic_seq structure.
  318. */
  319. struct seq_store {
  320. uint8_t num_sequence;
  321. struct synthetic_seq *seq_arr[0];
  322. };
  323. #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */
  324. /**
  325. * enum dfs_agile_sm_evt - DFS Agile SM events.
  326. * @DFS_AGILE_SM_EV_AGILE_START: Event to start AGILE PreCAC/RCAC.
  327. * @DFS_AGILE_SM_EV_AGILE_DOWN: Event to stop AGILE PreCAC/RCAC..
  328. * @DFS_AGILE_SM_EV_AGILE_DONE: Event to complete AGILE PreCAC/RCAC..
  329. * @DFS_AGILE_SM_EV_ADFS_RADAR: Event to restart AGILE PreCAC/RCAC after radar.
  330. */
  331. enum dfs_agile_sm_evt {
  332. DFS_AGILE_SM_EV_AGILE_START = 0,
  333. DFS_AGILE_SM_EV_AGILE_STOP = 1,
  334. DFS_AGILE_SM_EV_AGILE_DONE = 2,
  335. DFS_AGILE_SM_EV_ADFS_RADAR = 3,
  336. };
  337. /**
  338. * enum precac_status_for_chan - preCAC status for channels.
  339. * @DFS_NO_PRECAC_COMPLETED_CHANS: None of the channels are preCAC completed.
  340. * @DFS_PRECAC_COMPLETED_CHAN: A given channel is preCAC completed.
  341. * @DFS_PRECAC_REQUIRED_CHAN: A given channel required preCAC.
  342. * @DFS_INVALID_PRECAC_STATUS: Invalid status.
  343. *
  344. * Note: "DFS_NO_PRECAC_COMPLETED_CHANS" has more priority than
  345. * "DFS_PRECAC_COMPLETED_CHAN". This is because if the preCAC list does not
  346. * have any channel that completed preCAC, "DFS_NO_PRECAC_COMPLETED_CHANS"
  347. * is returned and search for preCAC completion (DFS_PRECAC_COMPLETED_CHAN)
  348. * for a given channel is not done.
  349. */
  350. enum precac_status_for_chan {
  351. DFS_NO_PRECAC_COMPLETED_CHANS,
  352. DFS_PRECAC_COMPLETED_CHAN,
  353. DFS_PRECAC_REQUIRED_CHAN,
  354. DFS_INVALID_PRECAC_STATUS,
  355. };
  356. #endif /* _DFS_IOCTL_H_ */