wlan_dfs_ioctl.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. /* Flag to exclude all 6GHz channels */
  187. #define DFS_RANDOM_CH_FLAG_NO_6GHZ_CH 0x00400 /* 0000 0100 0000 0000 */
  188. /**
  189. * struct wlan_dfs_caps - DFS capability structure.
  190. * @wlan_dfs_ext_chan_ok: Can radar be detected on the extension chan?
  191. * @wlan_dfs_combined_rssi_ok: Can use combined radar RSSI?
  192. * @wlan_dfs_use_enhancement: This flag is used to indicate if radar
  193. * detection scheme should use enhanced chirping
  194. * detection algorithm. This flag also determines
  195. * if certain radar data should be discarded to
  196. * minimize false detection of radar.
  197. * @wlan_strong_signal_diversiry: Strong Signal fast diversity count.
  198. * @wlan_chip_is_bb_tlv: Chip is BB TLV?
  199. * @wlan_chip_is_over_sampled: Is Over sampled.
  200. * @wlan_chip_is_ht160: IS VHT160?
  201. * @wlan_chip_is_false_detect: Is False detected?
  202. * @wlan_fastdiv_val: Goes with wlan_strong_signal_diversiry: If we
  203. * have fast diversity capability, read off
  204. * Strong Signal fast diversity count set in the
  205. * ini file, and store so we can restore the
  206. * value when radar is disabled.
  207. */
  208. struct wlan_dfs_caps {
  209. uint32_t wlan_dfs_ext_chan_ok:1,
  210. wlan_dfs_combined_rssi_ok:1,
  211. wlan_dfs_use_enhancement:1,
  212. wlan_strong_signal_diversiry:1,
  213. wlan_chip_is_bb_tlv:1,
  214. wlan_chip_is_over_sampled:1,
  215. wlan_chip_is_ht160:1,
  216. wlan_chip_is_false_detect:1;
  217. uint32_t wlan_fastdiv_val;
  218. };
  219. /**
  220. * struct wlan_dfs_phyerr_param - DFS Phyerr structure.
  221. * @pe_firpwr: FIR pwr out threshold.
  222. * @pe_rrssi: Radar rssi thresh.
  223. * @pe_height: Pulse height thresh.
  224. * @pe_prssi: Pulse rssi thresh.
  225. * @pe_inband: Inband thresh.
  226. * @pe_relpwr: Relative power threshold in 0.5dB steps.
  227. * @pe_relstep: Pulse Relative step threshold in 0.5dB steps.
  228. * @pe_maxlen: Max length of radar sign in 0.8us units.
  229. * @pe_usefir128: Use the average in-band power measured over 128 cycles.
  230. * @pe_blockradar: Enable to block radar check if pkt detect is done via OFDM
  231. * weak signal detect or pkt is detected immediately after tx
  232. * to rx transition.
  233. * @pe_enmaxrssi: Enable to use the max rssi instead of the last rssi during
  234. * fine gain changes for radar detection.
  235. */
  236. struct wlan_dfs_phyerr_param {
  237. int32_t pe_firpwr;
  238. int32_t pe_rrssi;
  239. int32_t pe_height;
  240. int32_t pe_prssi;
  241. int32_t pe_inband;
  242. uint32_t pe_relpwr;
  243. uint32_t pe_relstep;
  244. uint32_t pe_maxlen;
  245. bool pe_usefir128;
  246. bool pe_blockradar;
  247. bool pe_enmaxrssi;
  248. };
  249. /**
  250. * enum WLAN_DFS_EVENTS - DFS Events that will be sent to userspace
  251. * @WLAN_EV_RADAR_DETECTED: Radar is detected
  252. * @WLAN_EV_CAC_STARTED: CAC timer has started
  253. * @WLAN_EV_CAC_COMPLETED: CAC timer completed
  254. * @WLAN_EV_NOL_STARTED: NOL started
  255. * @WLAN_EV_NOL_FINISHED: NOL Completed
  256. *
  257. * DFS events such as radar detected, CAC started,
  258. * CAC completed, NOL started, NOL finished
  259. */
  260. enum WLAN_DFS_EVENTS {
  261. WLAN_EV_RADAR_DETECTED,
  262. WLAN_EV_CAC_STARTED,
  263. WLAN_EV_CAC_COMPLETED,
  264. WLAN_EV_NOL_STARTED,
  265. WLAN_EV_NOL_FINISHED,
  266. };
  267. #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(WLAN_DFS_SYNTHETIC_RADAR)
  268. /**
  269. * Structure of Pulse to be injected into the DFS Module
  270. * ******************************************************
  271. * Header
  272. * ======
  273. * ----------|--------------|
  274. * num_pulses| total_len_seq|
  275. * ----------|--------------|
  276. * Buffer Contents per pulse:
  277. * ==========================
  278. * ------|----------|-----------|----------|-----------|---------------|--------
  279. * r_rssi|r_ext_rssi|r_rs_tstamp|r_fulltsf |fft_datalen|total_len_pulse|FFT
  280. * | | | | | |Buffer..
  281. * ------|----------|-----------|----------|-----------|---------------|--------
  282. */
  283. /**
  284. * struct synthetic_pulse - Radar Pulse Structure to be filled on reading the
  285. * user file.
  286. * @r_rssi: RSSI of the pulse.
  287. * @r_ext_rssi: Extension Channel RSSI.
  288. * @r_rs_tstamp: Timestamp.
  289. * @r_fulltsf: TSF64.
  290. * @fft_datalen: Total len of FFT.
  291. * @total_len_pulse: Total len of the pulse.
  292. * @fft_buf: Pointer to fft data.
  293. */
  294. struct synthetic_pulse {
  295. uint8_t r_rssi;
  296. uint8_t r_ext_rssi;
  297. uint32_t r_rs_tstamp;
  298. uint64_t r_fulltsf;
  299. uint16_t fft_datalen;
  300. uint16_t total_len_pulse;
  301. unsigned char *fft_buf;
  302. } qdf_packed;
  303. /**
  304. * struct synthetic_seq - Structure to hold an array of pointers to the
  305. * pulse structure.
  306. * @num_pulses: Total num of pulses in the sequence.
  307. * @total_len_seq: Total len of the sequence.
  308. * @pulse: Array of pointers to synthetic_pulse structure.
  309. */
  310. struct synthetic_seq {
  311. uint8_t num_pulses;
  312. uint32_t total_len_seq;
  313. struct synthetic_pulse *pulse[0];
  314. };
  315. /**
  316. * struct seq_store - Structure to hold an array of pointers to the synthetic
  317. * sequence structure.
  318. * @num_sequence: Total number of "sequence of pulses" in the file.
  319. * @seq_arr: Array of pointers to synthetic_seq structure.
  320. */
  321. struct seq_store {
  322. uint8_t num_sequence;
  323. struct synthetic_seq *seq_arr[0];
  324. };
  325. #endif /* WLAN_DFS_PARTIAL_OFFLOAD && WLAN_DFS_SYNTHETIC_RADAR */
  326. /**
  327. * enum dfs_agile_sm_evt - DFS Agile SM events.
  328. * @DFS_AGILE_SM_EV_AGILE_START: Event to start AGILE PreCAC/RCAC.
  329. * @DFS_AGILE_SM_EV_AGILE_DOWN: Event to stop AGILE PreCAC/RCAC..
  330. * @DFS_AGILE_SM_EV_AGILE_DONE: Event to complete AGILE PreCAC/RCAC..
  331. * @DFS_AGILE_SM_EV_ADFS_RADAR: Event to restart AGILE PreCAC/RCAC after radar.
  332. */
  333. enum dfs_agile_sm_evt {
  334. DFS_AGILE_SM_EV_AGILE_START = 0,
  335. DFS_AGILE_SM_EV_AGILE_STOP = 1,
  336. DFS_AGILE_SM_EV_AGILE_DONE = 2,
  337. DFS_AGILE_SM_EV_ADFS_RADAR = 3,
  338. };
  339. /**
  340. * enum precac_status_for_chan - preCAC status for channels.
  341. * @DFS_NO_PRECAC_COMPLETED_CHANS: None of the channels are preCAC completed.
  342. * @DFS_PRECAC_COMPLETED_CHAN: A given channel is preCAC completed.
  343. * @DFS_PRECAC_REQUIRED_CHAN: A given channel required preCAC.
  344. * @DFS_INVALID_PRECAC_STATUS: Invalid status.
  345. *
  346. * Note: "DFS_NO_PRECAC_COMPLETED_CHANS" has more priority than
  347. * "DFS_PRECAC_COMPLETED_CHAN". This is because if the preCAC list does not
  348. * have any channel that completed preCAC, "DFS_NO_PRECAC_COMPLETED_CHANS"
  349. * is returned and search for preCAC completion (DFS_PRECAC_COMPLETED_CHAN)
  350. * for a given channel is not done.
  351. */
  352. enum precac_status_for_chan {
  353. DFS_NO_PRECAC_COMPLETED_CHANS,
  354. DFS_PRECAC_COMPLETED_CHAN,
  355. DFS_PRECAC_REQUIRED_CHAN,
  356. DFS_INVALID_PRECAC_STATUS,
  357. };
  358. #endif /* _DFS_IOCTL_H_ */