wlan_dfs_ioctl.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. /*
  2. * Copyright (c) 2011, 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2024 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. * @is_fh_radar: Frequency Hopping Radar type or not.
  156. */
  157. struct dfs_bangradar_params {
  158. enum dfs_bangradar_types bangradar_type;
  159. uint8_t seg_id;
  160. uint8_t is_chirp;
  161. int32_t freq_offset;
  162. uint8_t detector_id;
  163. uint8_t is_fh_radar;
  164. };
  165. #define DFS_IOCTL_PARAM_NOVAL 65535
  166. #define DFS_IOCTL_PARAM_ENABLE 0x8000
  167. /* Random channel flags */
  168. /* Flag to exclude current operating channels */
  169. #define DFS_RANDOM_CH_FLAG_NO_CURR_OPE_CH 0x0001 /* 0000 0000 0000 0001 */
  170. /* Flag to exclude weather channels */
  171. #define DFS_RANDOM_CH_FLAG_NO_WEATHER_CH 0x0002 /* 0000 0000 0000 0010 */
  172. /* Flag to exclude indoor channels */
  173. #define DFS_RANDOM_CH_FLAG_NO_LOWER_5G_CH 0x0004 /* 0000 0000 0000 0100 */
  174. /* Flag to exclude outdoor channels */
  175. #define DFS_RANDOM_CH_FLAG_NO_UPEER_5G_CH 0x0008 /* 0000 0000 0000 1000 */
  176. /* Flag to exclude dfs channels */
  177. #define DFS_RANDOM_CH_FLAG_NO_DFS_CH 0x0010 /* 0000 0000 0001 0000 */
  178. /* Flag to exclude all 5GHz channels */
  179. #define DFS_RANDOM_CH_FLAG_NO_5GHZ_CH 0x0020 /* 0000 0000 0010 0000 */
  180. /* Flag to exclude all 2.4GHz channels */
  181. #define DFS_RANDOM_CH_FLAG_NO_2GHZ_CH 0x0040 /* 0000 0000 0100 0000 */
  182. /* Flag to enable Reduced BW Agile DFS */
  183. #define DFS_RANDOM_CH_FLAG_ENABLE_REDUCED_BW 0x0080 /* 0000 0000 1000 0000 */
  184. /* Flag to exclude Japan W53 channels */
  185. #define DFS_RANDOM_CH_FLAG_NO_JAPAN_W53_CH 0x0100 /* 0000 0001 0000 0000 */
  186. /* Restricted 80P80 MHz is enabled */
  187. #define DFS_RANDOM_CH_FLAG_RESTRICTED_80P80_ENABLED 0x0200
  188. /* 0000 0010 0000 0000 */
  189. /* Flag to exclude all 6GHz channels */
  190. #define DFS_RANDOM_CH_FLAG_NO_6GHZ_CH 0x00400 /* 0000 0100 0000 0000 */
  191. /* Flag to exclude spruce spur adjacent channels */
  192. #define DFS_RANDOM_CH_FLAG_NO_SPRUCE_SPUR_ADJ_CH \
  193. 0x0800 /* 0000 1000 0000 0000 */
  194. /**
  195. * struct wlan_dfs_caps - DFS capability structure.
  196. * @wlan_dfs_ext_chan_ok: Can radar be detected on the extension chan?
  197. * @wlan_dfs_combined_rssi_ok: Can use combined radar RSSI?
  198. * @wlan_dfs_use_enhancement: This flag is used to indicate if radar
  199. * detection scheme should use enhanced chirping
  200. * detection algorithm. This flag also determines
  201. * if certain radar data should be discarded to
  202. * minimize false detection of radar.
  203. * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
  204. * @wlan_chip_is_bb_tlv: Chip is BB TLV?
  205. * @wlan_chip_is_over_sampled: Is Over sampled.
  206. * @wlan_chip_is_ht160: IS VHT160?
  207. * @wlan_chip_is_false_detect: Is False detected?
  208. * @wlan_fastdiv_val: Goes with wlan_strong_signal_diversiry: If we
  209. * have fast diversity capability, read off
  210. * Strong Signal fast diversity count set in the
  211. * ini file, and store so we can restore the
  212. * value when radar is disabled.
  213. */
  214. struct wlan_dfs_caps {
  215. uint32_t wlan_dfs_ext_chan_ok:1,
  216. wlan_dfs_combined_rssi_ok:1,
  217. wlan_dfs_use_enhancement:1,
  218. wlan_strong_signal_diversiry:1,
  219. wlan_chip_is_bb_tlv:1,
  220. wlan_chip_is_over_sampled:1,
  221. wlan_chip_is_ht160:1,
  222. wlan_chip_is_false_detect:1;
  223. uint32_t wlan_fastdiv_val;
  224. };
  225. /**
  226. * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
  227. * @pe_firpwr: FIR pwr out threshold.
  228. * @pe_rrssi: Radar rssi thresh.
  229. * @pe_height: Pulse height thresh.
  230. * @pe_prssi: Pulse rssi thresh.
  231. * @pe_inband: Inband thresh.
  232. * @pe_relpwr: Relative power threshold in 0.5dB steps.
  233. * @pe_relstep: Pulse Relative step threshold in 0.5dB steps.
  234. * @pe_maxlen: Max length of radar sign in 0.8us units.
  235. * @pe_usefir128: Use the average in-band power measured over 128 cycles.
  236. * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
  237. * weak signal detect or pkt is detected immediately after tx
  238. * to rx transition.
  239. * @pe_enmaxrssi: Enable to use the max rssi instead of the last rssi during
  240. * fine gain changes for radar detection.
  241. */
  242. struct wlan_dfs_phyerr_param {
  243. int32_t pe_firpwr;
  244. int32_t pe_rrssi;
  245. int32_t pe_height;
  246. int32_t pe_prssi;
  247. int32_t pe_inband;
  248. uint32_t pe_relpwr;
  249. uint32_t pe_relstep;
  250. uint32_t pe_maxlen;
  251. bool pe_usefir128;
  252. bool pe_blockradar;
  253. bool pe_enmaxrssi;
  254. };
  255. /**
  256. * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace
  257. * @WLAN_EV_RADAR_DETECTED: Radar is detected
  258. * @WLAN_EV_CAC_RESET: CAC started or CAC completed status is reset
  259. * @WLAN_EV_CAC_STARTED: CAC timer has started
  260. * @WLAN_EV_CAC_COMPLETED: CAC timer completed
  261. * @WLAN_EV_NOL_STARTED: NOL started
  262. * @WLAN_EV_NOL_FINISHED: NOL Completed
  263. * @WLAN_EV_PCAC_STARTED: PreCAC Started
  264. * @WLAN_EV_PCAC_COMPLETED: PreCAC Completed
  265. *
  266. * DFS events such as radar detected, CAC started,
  267. * CAC completed, NOL started, NOL finished
  268. */
  269. enum WLAN_DFS_EVENTS {
  270. WLAN_EV_RADAR_DETECTED,
  271. WLAN_EV_CAC_RESET,
  272. WLAN_EV_CAC_STARTED,
  273. WLAN_EV_CAC_COMPLETED,
  274. WLAN_EV_NOL_STARTED,
  275. WLAN_EV_NOL_FINISHED,
  276. WLAN_EV_PCAC_STARTED,
  277. WLAN_EV_PCAC_COMPLETED,
  278. };
  279. #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR)
  280. /*
  281. * Structure of Pulse to be injected into the DFS Module
  282. * ******************************************************
  283. * Header
  284. * ======
  285. * ----------|--------------|
  286. * num_pulses| total_len_seq|
  287. * ----------|--------------|
  288. * Buffer Contents per pulse:
  289. * ==========================
  290. * ------|----------|-----------|----------|-----------|---------------|--------
  291. * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT
  292. * | | | | | |Buffer..
  293. * ------|----------|-----------|----------|-----------|---------------|--------
  294. */
  295. /**
  296. * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the
  297. * user file.
  298. * @r_rssi: RSSI of the pulse.
  299. * @r_ext_rssi: Extension Channel RSSI.
  300. * @r_rs_tstamp: Timestamp.
  301. * @r_fulltsf: TSF64.
  302. * @fft_datalen: Total len of FFT.
  303. * @total_len_pulse: Total len of the pulse.
  304. * @fft_buf: Pointer to fft data.
  305. */
  306. struct synthetic_pulse {
  307. uint8_t r_rssi;
  308. uint8_t r_ext_rssi;
  309. uint32_t r_rs_tstamp;
  310. uint64_t r_fulltsf;
  311. uint16_t fft_datalen;
  312. uint16_t total_len_pulse;
  313. unsigned char *fft_buf;
  314. } qdf_packed;
  315. /**
  316. * struct synthetic_seq - Structure to hold an array of pointers to the
  317. * pulse structure.
  318. * @num_pulses: Total num of pulses in the sequence.
  319. * @total_len_seq: Total len of the sequence.
  320. * @pulse: Array of pointers to synthetic_pulse structure.
  321. */
  322. struct synthetic_seq {
  323. uint8_t num_pulses;
  324. uint32_t total_len_seq;
  325. struct synthetic_pulse *pulse[];
  326. };
  327. /**
  328. * struct seq_store - Structure to hold an array of pointers to the synthetic
  329. * sequence structure.
  330. * @num_sequence: Total number of "sequence of pulses" in the file.
  331. * @seq_arr: Array of pointers to synthetic_seq structure.
  332. */
  333. struct seq_store {
  334. uint8_t num_sequence;
  335. struct synthetic_seq *seq_arr[];
  336. };
  337. #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */
  338. /**
  339. * enum dfs_agile_sm_evt - DFS Agile SM events.
  340. * @DFS_AGILE_SM_EV_AGILE_START: Event to start AGILE PreCAC/RCAC.
  341. * @DFS_AGILE_SM_EV_AGILE_STOP: Event to stop AGILE PreCAC/RCAC..
  342. * @DFS_AGILE_SM_EV_AGILE_DONE: Event to complete AGILE PreCAC/RCAC..
  343. * @DFS_AGILE_SM_EV_ADFS_RADAR: Event to restart AGILE PreCAC/RCAC after radar.
  344. */
  345. enum dfs_agile_sm_evt {
  346. DFS_AGILE_SM_EV_AGILE_START = 0,
  347. DFS_AGILE_SM_EV_AGILE_STOP = 1,
  348. DFS_AGILE_SM_EV_AGILE_DONE = 2,
  349. DFS_AGILE_SM_EV_ADFS_RADAR = 3,
  350. };
  351. /**
  352. * enum precac_status_for_chan - preCAC status for channels.
  353. * @DFS_NO_PRECAC_COMPLETED_CHANS: None of the channels are preCAC completed.
  354. * @DFS_PRECAC_COMPLETED_CHAN: A given channel is preCAC completed.
  355. * @DFS_PRECAC_REQUIRED_CHAN: A given channel required preCAC.
  356. * @DFS_INVALID_PRECAC_STATUS: Invalid status.
  357. *
  358. * Note: "DFS_NO_PRECAC_COMPLETED_CHANS" has more priority than
  359. * "DFS_PRECAC_COMPLETED_CHAN". This is because if the preCAC list does not
  360. * have any channel that completed preCAC, "DFS_NO_PRECAC_COMPLETED_CHANS"
  361. * is returned and search for preCAC completion (DFS_PRECAC_COMPLETED_CHAN)
  362. * for a given channel is not done.
  363. */
  364. enum precac_status_for_chan {
  365. DFS_NO_PRECAC_COMPLETED_CHANS,
  366. DFS_PRECAC_COMPLETED_CHAN,
  367. DFS_PRECAC_REQUIRED_CHAN,
  368. DFS_INVALID_PRECAC_STATUS,
  369. };
  370. #endif /* _DFS_IOCTL_H_ */