wlan_dfs_ioctl.h 14 KB

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