spectral_ioctl.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. /*
  2. * Copyright (c) 2011, 2017-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _SPECTRAL_IOCTL_H_
  19. #define _SPECTRAL_IOCTL_H_
  20. #include <wlan_dfs_ioctl.h>
  21. #ifndef AH_MAX_CHAINS
  22. #define AH_MAX_CHAINS 3
  23. #endif
  24. /* Compile time Assert */
  25. #define SPECTRAL_COMPILE_TIME_ASSERT(assertion_name, predicate) \
  26. typedef char assertion_name[(predicate) ? 1 : -1]
  27. /*
  28. * ioctl defines
  29. */
  30. #define SPECTRAL_SET_CONFIG (DFS_LAST_IOCTL + 1)
  31. #define SPECTRAL_GET_CONFIG (DFS_LAST_IOCTL + 2)
  32. #define SPECTRAL_SHOW_INTERFERENCE (DFS_LAST_IOCTL + 3)
  33. #define SPECTRAL_ENABLE_SCAN (DFS_LAST_IOCTL + 4)
  34. #define SPECTRAL_DISABLE_SCAN (DFS_LAST_IOCTL + 5)
  35. #define SPECTRAL_ACTIVATE_SCAN (DFS_LAST_IOCTL + 6)
  36. #define SPECTRAL_STOP_SCAN (DFS_LAST_IOCTL + 7)
  37. #define SPECTRAL_SET_DEBUG_LEVEL (DFS_LAST_IOCTL + 8)
  38. #define SPECTRAL_IS_ACTIVE (DFS_LAST_IOCTL + 9)
  39. #define SPECTRAL_IS_ENABLED (DFS_LAST_IOCTL + 10)
  40. #define SPECTRAL_CLASSIFY_SCAN (DFS_LAST_IOCTL + 11)
  41. #define SPECTRAL_GET_CLASSIFIER_CONFIG (DFS_LAST_IOCTL + 12)
  42. #define SPECTRAL_EACS (DFS_LAST_IOCTL + 13)
  43. #define SPECTRAL_ACTIVATE_FULL_SCAN (DFS_LAST_IOCTL + 14)
  44. #define SPECTRAL_STOP_FULL_SCAN (DFS_LAST_IOCTL + 15)
  45. #define SPECTRAL_GET_CAPABILITY_INFO (DFS_LAST_IOCTL + 16)
  46. #define SPECTRAL_GET_DIAG_STATS (DFS_LAST_IOCTL + 17)
  47. #define SPECTRAL_GET_CHAN_WIDTH (DFS_LAST_IOCTL + 18)
  48. #define SPECTRAL_GET_CHANINFO (DFS_LAST_IOCTL + 19)
  49. #define SPECTRAL_CLEAR_CHANINFO (DFS_LAST_IOCTL + 20)
  50. #define SPECTRAL_SET_ICM_ACTIVE (DFS_LAST_IOCTL + 21)
  51. #define SPECTRAL_GET_NOMINAL_NOISEFLOOR (DFS_LAST_IOCTL + 22)
  52. #define SPECTRAL_GET_DEBUG_LEVEL (DFS_LAST_IOCTL + 23)
  53. #define SPECTRAL_SET_DMA_DEBUG (DFS_LAST_IOCTL + 24)
  54. /*
  55. * Increase spectral sub version if struct spectral_samp_msg updated.
  56. */
  57. #define SPECTRAL_VERSION (3)
  58. #define SPECTRAL_SUB_VERSION (1)
  59. /*
  60. * ioctl parameter types
  61. */
  62. enum spectral_params {
  63. SPECTRAL_PARAM_FFT_PERIOD,
  64. SPECTRAL_PARAM_SCAN_PERIOD,
  65. SPECTRAL_PARAM_SCAN_COUNT,
  66. SPECTRAL_PARAM_SHORT_REPORT,
  67. SPECTRAL_PARAM_SPECT_PRI,
  68. SPECTRAL_PARAM_FFT_SIZE,
  69. SPECTRAL_PARAM_GC_ENA,
  70. SPECTRAL_PARAM_RESTART_ENA,
  71. SPECTRAL_PARAM_NOISE_FLOOR_REF,
  72. SPECTRAL_PARAM_INIT_DELAY,
  73. SPECTRAL_PARAM_NB_TONE_THR,
  74. SPECTRAL_PARAM_STR_BIN_THR,
  75. SPECTRAL_PARAM_WB_RPT_MODE,
  76. SPECTRAL_PARAM_RSSI_RPT_MODE,
  77. SPECTRAL_PARAM_RSSI_THR,
  78. SPECTRAL_PARAM_PWR_FORMAT,
  79. SPECTRAL_PARAM_RPT_MODE,
  80. SPECTRAL_PARAM_BIN_SCALE,
  81. SPECTRAL_PARAM_DBM_ADJ,
  82. SPECTRAL_PARAM_CHN_MASK,
  83. SPECTRAL_PARAM_ACTIVE,
  84. SPECTRAL_PARAM_STOP,
  85. SPECTRAL_PARAM_ENABLE,
  86. SPECTRAL_PARAM_FREQUENCY,
  87. SPECTRAL_PARAM_CHAN_FREQUENCY,
  88. SPECTRAL_PARAM_CHAN_WIDTH,
  89. SPECTRAL_PARAM_MAX,
  90. };
  91. /**
  92. * enum spectral_report_mode: Spectral report mode
  93. * @SPECTRAL_REPORT_MODE_0: No FFT report (only spectral scan summary report)
  94. * @SPECTRAL_REPORT_MODE_1: FFT report header + spectral scan summary report
  95. * @SPECTRAL_REPORT_MODE_2: FFt report header + in-band bins per
  96. * FFT (half of the number of FFT bins), where the
  97. * FFT input is sampled at two times the channel
  98. * bandwidth + spectral scan summary report
  99. * @SPECTRAL_REPORT_MODE_3: FFT report header + all bins per FFT, where the FFT
  100. * input is sampled at two times the channel bandwidth
  101. * + spectral scan summary report
  102. * @SPECTRAL_REPORT_MODE_MAX: Max number of report modes
  103. */
  104. enum spectral_report_mode {
  105. SPECTRAL_REPORT_MODE_0,
  106. SPECTRAL_REPORT_MODE_1,
  107. SPECTRAL_REPORT_MODE_2,
  108. SPECTRAL_REPORT_MODE_3,
  109. SPECTRAL_REPORT_MODE_MAX,
  110. };
  111. /**
  112. * enum spectral_scan_priority: Spectral scan priority
  113. * @SPECTRAL_SCAN_PRIORITY_LOW: Low priority Spectral scan
  114. * @SPECTRAL_SCAN_PRIORITY_HIGH: High priority Spectral scan
  115. */
  116. enum spectral_scan_priority {
  117. SPECTRAL_SCAN_PRIORITY_LOW = 0,
  118. SPECTRAL_SCAN_PRIORITY_HIGH = 1,
  119. };
  120. /**
  121. * enum spectral_fft_size : FFT size values
  122. * @SPECTRAL_FFT_SIZE_INVALID: Invalid FFT size
  123. * @SPECTRAL_FFT_SIZE_1: FFT size 1
  124. * @SPECTRAL_FFT_SIZE_2: FFT size 2
  125. * @SPECTRAL_FFT_SIZE_3: FFT size 3
  126. * @SPECTRAL_FFT_SIZE_4: FFT size 4
  127. * @SPECTRAL_FFT_SIZE_5: FFT size 5
  128. * @SPECTRAL_FFT_SIZE_6: FFT size 6
  129. * @SPECTRAL_FFT_SIZE_7: FFT size 7
  130. * @SPECTRAL_FFT_SIZE_8: FFT size 8
  131. * @SPECTRAL_FFT_SIZE_9: FFT size 9
  132. * @SPECTRAL_FFT_SIZE_10: FFT size 10
  133. * @SPECTRAL_FFT_SIZE_MAX: Max number of FFT size
  134. */
  135. enum spectral_fft_size {
  136. SPECTRAL_FFT_SIZE_INVALID,
  137. SPECTRAL_FFT_SIZE_1,
  138. SPECTRAL_FFT_SIZE_2,
  139. SPECTRAL_FFT_SIZE_3,
  140. SPECTRAL_FFT_SIZE_4,
  141. SPECTRAL_FFT_SIZE_5,
  142. SPECTRAL_FFT_SIZE_6,
  143. SPECTRAL_FFT_SIZE_7,
  144. SPECTRAL_FFT_SIZE_8,
  145. SPECTRAL_FFT_SIZE_9,
  146. SPECTRAL_FFT_SIZE_10,
  147. SPECTRAL_FFT_SIZE_MAX,
  148. };
  149. /**
  150. * enum spectral_scan_mode - Spectral scan mode
  151. * @SPECTRAL_SCAN_MODE_NORMAL: Normal mode
  152. * @SPECTRAL_SCAN_MODE_AGILE: Agile mode
  153. * @SPECTRAL_SCAN_MODE_MAX: Max number of Spectral modes
  154. * @SPECTRAL_SCAN_MODE_INVALID: Invalid Spectral mode
  155. */
  156. enum spectral_scan_mode {
  157. SPECTRAL_SCAN_MODE_NORMAL,
  158. SPECTRAL_SCAN_MODE_AGILE,
  159. SPECTRAL_SCAN_MODE_MAX,
  160. SPECTRAL_SCAN_MODE_INVALID = 0xff,
  161. };
  162. /**
  163. * enum spectral_chan_width - Spectral-specific channel width enum
  164. * @SPECTRAL_CH_WIDTH_20MHZ: 20 mhz width
  165. * @SPECTRAL_CH_WIDTH_40MHZ: 40 mhz width
  166. * @SPECTRAL_CH_WIDTH_80MHZ: 80 mhz width
  167. * @SPECTRAL_CH_WIDTH_160MHZ: 160 mhz width
  168. * @SPECTRAL_CH_WIDTH_80P80MHZ: 80+80 mhz width
  169. * @SPECTRAL_CH_WIDTH_5MHZ: 5 mhz width
  170. * @SPECTRAL_CH_WIDTH_10MHZ: 10 mhz width
  171. * @SPECTRAL_CH_WIDTH_320MHZ: 320 mhz width
  172. * @SPECTRAL_CH_WIDTH_MAX: Max possible width
  173. * @SPECTRAL_CH_WIDTH_INVALID: invalid width
  174. */
  175. enum spectral_chan_width {
  176. SPECTRAL_CH_WIDTH_20MHZ,
  177. SPECTRAL_CH_WIDTH_40MHZ,
  178. SPECTRAL_CH_WIDTH_80MHZ,
  179. SPECTRAL_CH_WIDTH_160MHZ,
  180. SPECTRAL_CH_WIDTH_80P80MHZ,
  181. SPECTRAL_CH_WIDTH_320MHZ,
  182. SPECTRAL_CH_WIDTH_5MHZ,
  183. SPECTRAL_CH_WIDTH_10MHZ,
  184. SPECTRAL_CH_WIDTH_MAX,
  185. SPECTRAL_CH_WIDTH_INVALID,
  186. };
  187. struct spectral_ioctl_params {
  188. int16_t spectral_fft_period;
  189. int16_t pectral_period;
  190. int16_t spectral_count;
  191. uint16_t spectral_short_report;
  192. uint16_t spectral_pri;
  193. };
  194. /**
  195. * spectral_cap_hw_gen: Definitions for the Spectral hardware generation.
  196. * This corresponds to definitions in qca_wlan_vendor_spectral_scan_cap_hw_gen.
  197. * @SPECTRAL_CAP_HW_GEN_1: Generation 1
  198. * @SPECTRAL_CAP_HW_GEN_2: Generation 2
  199. * @SPECTRAL_CAP_HW_GEN_3: Generation 3
  200. */
  201. enum spectral_cap_hw_gen {
  202. SPECTRAL_CAP_HW_GEN_1 = 0,
  203. SPECTRAL_CAP_HW_GEN_2 = 1,
  204. SPECTRAL_CAP_HW_GEN_3 = 2,
  205. };
  206. /**
  207. * struct spectral_config_frequency - Spectral scan frequency
  208. * @cfreq1: Center frequency (in MHz) of the span of interest(primary 80 MHz
  209. * span for 80 + 80 agile scan request) or center frequency (in MHz)
  210. * of any WLAN channel in the span of interest.
  211. * @cfreq2: Applicable only for Agile Spectral scan request in 80+80 MHz mode.
  212. * For 80+80 mode it represents the center frequency (in MHz) of the
  213. * secondary 80 MHz span of interest or center frequency (in MHz) of
  214. * any WLAN channel in the secondary 80 MHz span of interest.
  215. */
  216. struct spectral_config_frequency {
  217. uint32_t cfreq1;
  218. uint32_t cfreq2;
  219. };
  220. /**
  221. * struct spectral_config - spectral config parameters
  222. * @ss_fft_period: Skip interval for FFT reports
  223. * @ss_period: Spectral scan period
  224. * @ss_count: # of reports to return from ss_active
  225. * @ss_short_report: Set to report only 1 set of FFT results
  226. * @radar_bin_thresh_sel: Select threshold to classify strong bin for FFT
  227. * @ss_spectral_pri: Priority, and are we doing a noise power cal ?
  228. * @ss_fft_size: Defines the number of FFT data points to compute,
  229. * defined as a log index num_fft_pts =
  230. * 2^ss_fft_size
  231. * @ss_gc_ena: Set, to enable targeted gain change before
  232. * starting the spectral scan FFT
  233. * @ss_restart_ena: Set, to enable abort of receive frames when in high
  234. * priority and a spectral scan is queued
  235. * @ss_noise_floor_ref: Noise floor reference number (signed) for the
  236. * calculation of bin power (dBm) Though stored as an
  237. * unsigned this should be treated as a signed 8-bit int.
  238. * @ss_init_delay: Disallow spectral scan triggers after tx/rx packets
  239. * by setting this delay value to roughly SIFS time
  240. * period or greater Delay timer count in units of 0.25us
  241. * @ss_nb_tone_thr: Number of strong bins (inclusive) per sub-channel,
  242. * below which a signal is declared a narrowband tone
  243. * @ss_str_bin_thr: Bin/max_bin ratio threshold over which a bin is
  244. * declared strong (for spectral scan bandwidth analysis)
  245. * @ss_wb_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER
  246. * (phy_error=36), if none of the sub-channels are
  247. * deemed narrowband
  248. * @ss_rssi_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER
  249. * (phy_error=36), if the ADC RSSI is below the
  250. * threshold ss_rssi_thr
  251. * @ss_rssi_thr: ADC RSSI must be greater than or equal to this
  252. * threshold (signed Db) to ensure spectral scan
  253. * reporting with normal phy error codes (please see
  254. * ss_rssi_rpt_mode above).Though stored as an unsigned
  255. * value, this should be treated as a signed 8-bit int
  256. * @ss_pwr_format: Format of frequency bin magnitude for spectral scan
  257. * triggered FFTs 0: linear magnitude
  258. * 1: log magnitude (20*log10(lin_mag), 1/2 dB step size)
  259. * @ss_rpt_mode: Format of per-FFT reports to software for spectral
  260. * scan triggered FFTs
  261. * 0: No FFT report (only pulse end summary)
  262. * 1: 2-dword summary of metrics for each completed FFT
  263. * 2: 2-dword summary + 1x-oversampled bins(in-band) per
  264. * FFT
  265. * 3: 2-dword summary + 2x-oversampled bins (all) per FFT
  266. * @ss_bin_scale: Number of LSBs to shift out to scale the FFT bins
  267. * for spectral scan triggered FFTs
  268. * @ss_dbm_adj: Set (with ss_pwr_format=1), to report bin
  269. * magnitudes
  270. * converted to dBm power using the noisefloor
  271. * calibration results
  272. * @ss_chn_mask: Per chain enable mask to select input ADC for search
  273. * FFT
  274. * @ss_nf_cal: nf calibrated values for ctl+ext
  275. * @ss_nf_pwr: nf pwr values for ctl+ext
  276. * @ss_nf_temp_data: temperature data taken during nf scan
  277. * @ss_frequency: This specifies the frequency span over which Spectral
  278. * scan would be carried out. Its value depends on the
  279. * Spectral scan mode.
  280. * Normal mode:-
  281. * Not applicable. Spectral scan would happen in the
  282. * operating span.
  283. * Agile mode:-
  284. * cfreq1 represents the center frequency (in MHz) of
  285. * the span of interest(primary 80 MHz span for 80 + 80
  286. * agile scan request) or center frequency (in MHz) of
  287. * any WLAN channel in the span of interest. cfreq2 is
  288. * applicable only for Agile Spectral scan request in
  289. * 80+80 MHz mode. For 80+80 mode it represents the
  290. * center frequency (in MHz) of the secondary 80 MHz
  291. * span of interest or center frequency (in MHz) of
  292. * any WLAN channel in the secondary 80 MHz span of
  293. * interest.
  294. * @ss_bandwidth: Spectral scan bandwidth
  295. */
  296. struct spectral_config {
  297. uint16_t ss_fft_period;
  298. uint16_t ss_period;
  299. uint16_t ss_count;
  300. uint16_t ss_short_report;
  301. uint8_t radar_bin_thresh_sel;
  302. uint16_t ss_spectral_pri;
  303. uint16_t ss_fft_size;
  304. uint16_t ss_gc_ena;
  305. uint16_t ss_restart_ena;
  306. uint16_t ss_noise_floor_ref;
  307. uint16_t ss_init_delay;
  308. uint16_t ss_nb_tone_thr;
  309. uint16_t ss_str_bin_thr;
  310. uint16_t ss_wb_rpt_mode;
  311. uint16_t ss_rssi_rpt_mode;
  312. uint16_t ss_rssi_thr;
  313. uint16_t ss_pwr_format;
  314. uint16_t ss_rpt_mode;
  315. uint16_t ss_bin_scale;
  316. uint16_t ss_dbm_adj;
  317. uint16_t ss_chn_mask;
  318. int8_t ss_nf_cal[AH_MAX_CHAINS * 2];
  319. int8_t ss_nf_pwr[AH_MAX_CHAINS * 2];
  320. int32_t ss_nf_temp_data;
  321. struct spectral_config_frequency ss_frequency;
  322. uint16_t ss_bandwidth;
  323. };
  324. /**
  325. * struct spectral_caps - Spectral capabilities structure
  326. * @phydiag_cap: Phydiag capability
  327. * @radar_cap: Radar detection capability
  328. * @spectral_cap: Spectral capability
  329. * @advncd_spectral_cap: Advanced spectral capability
  330. * @hw_gen: Spectral hw generation as defined in spectral_cap_hw_gen
  331. * @is_scaling_params_populated: indicates whether scaling params is populated
  332. * @formula_id: formula_id
  333. * @low_level_offset: low_level_offset
  334. * @high_level_offset: high_level_offset
  335. * @rssi_thr: rssi_thr
  336. * @default_agc_max_gain: default_agc_max_gain
  337. * @agile_spectral_cap: agile Spectral capability for 20/40/80
  338. * @agile_spectral_cap_160: agile Spectral capability for 160 MHz
  339. * @agile_spectral_cap_80p80: agile Spectral capability for 80p80
  340. * @agile_spectral_cap_320: agile Spectral capability for 320
  341. * @num_detectors_20mhz: number of Spectral detectors in 20 MHz
  342. * @num_detectors_40mhz: number of Spectral detectors in 40 MHz
  343. * @num_detectors_80mhz: number of Spectral detectors in 80 MHz
  344. * @num_detectors_160mhz: number of Spectral detectors in 160 MHz
  345. * @num_detectors_80p80mhz: number of Spectral detectors in 80p80 MHz
  346. * @num_detectors_320mhz: number of Spectral detectors in 320 MHz
  347. */
  348. struct spectral_caps {
  349. uint8_t phydiag_cap;
  350. uint8_t radar_cap;
  351. uint8_t spectral_cap;
  352. uint8_t advncd_spectral_cap;
  353. uint32_t hw_gen;
  354. bool is_scaling_params_populated;
  355. uint16_t formula_id;
  356. int16_t low_level_offset;
  357. int16_t high_level_offset;
  358. int16_t rssi_thr;
  359. uint8_t default_agc_max_gain;
  360. bool agile_spectral_cap;
  361. bool agile_spectral_cap_160;
  362. bool agile_spectral_cap_80p80;
  363. bool agile_spectral_cap_320;
  364. uint32_t num_detectors_20mhz;
  365. uint32_t num_detectors_40mhz;
  366. uint32_t num_detectors_80mhz;
  367. uint32_t num_detectors_160mhz;
  368. uint32_t num_detectors_80p80mhz;
  369. uint32_t num_detectors_320mhz;
  370. };
  371. #define SPECTRAL_IOCTL_PARAM_NOVAL (65535)
  372. #define MAX_SPECTRAL_CHAINS (3)
  373. #define MAX_NUM_BINS (2048)
  374. #define MAX_NUM_BINS_PRI80 (1024)
  375. #define MAX_NUM_BINS_SEC80 (520)
  376. #define MAX_NUM_BINS_5MHZ (32)
  377. /* 5 categories x (lower + upper) bands */
  378. #define MAX_INTERF 10
  379. #define SPECTRAL_MAC_ADDR_SIZE (6)
  380. #define MAX_NUM_FREQ_SPANS (3)
  381. #define MAX_NUM_DETECTORS (2)
  382. #define MAX_SPECTRAL_PAYLOAD (2004)
  383. /**
  384. * enum dcs_int_type - Interference type indicated by DCS
  385. * @SPECTRAL_DCS_INT_NONE: No interference
  386. * @SPECTRAL_DCS_INT_CW: CW interference
  387. * @SPECTRAL_DCS_INT_WIFI: WLAN interference
  388. */
  389. enum dcs_int_type {
  390. SPECTRAL_DCS_INT_NONE,
  391. SPECTRAL_DCS_INT_CW,
  392. SPECTRAL_DCS_INT_WIFI
  393. };
  394. /**
  395. * struct interf_rsp - Interference record
  396. * @interf_type: eINTERF_TYPE giving type of interference
  397. * @interf_min_freq: Minimum frequency in MHz at which interference has been
  398. * found
  399. * @interf_max_freq: Maximum frequency in MHz at which interference has been
  400. * found
  401. * @advncd_spectral_cap: Advanced spectral capability
  402. */
  403. struct interf_rsp {
  404. uint8_t interf_type;
  405. uint16_t interf_min_freq;
  406. uint16_t interf_max_freq;
  407. } __packed;
  408. /**
  409. * struct interf_src_rsp - List of interference sources
  410. * @count: Number of interference records
  411. * @interf: Array of interference records
  412. */
  413. struct interf_src_rsp {
  414. uint16_t count;
  415. struct interf_rsp interf[MAX_INTERF];
  416. } __packed;
  417. /**
  418. * struct spectral_classifier_params - spectral classifier parameters
  419. * @spectral_20_40_mode: Is AP in 20/40 mode?
  420. * @spectral_dc_index: DC index
  421. * @spectral_dc_in_mhz: DC in MHz
  422. * @upper_chan_in_mhz: Upper channel in MHz
  423. * @lower_chan_in_mhz: Lower channel in MHz
  424. */
  425. struct spectral_classifier_params {
  426. int spectral_20_40_mode;
  427. int spectral_dc_index;
  428. int spectral_dc_in_mhz;
  429. int upper_chan_in_mhz;
  430. int lower_chan_in_mhz;
  431. } __packed;
  432. #ifdef OPTIMIZED_SAMP_MESSAGE
  433. /**
  434. * struct samp_edge_extra_bin_info - Spectral edge extra bins Information
  435. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  436. * delivered. However, there can be additional bins reported for
  437. * AR900B version 2.0 and QCA9984 as described next:
  438. * AR900B version 2.0: An additional tone is processed on the right
  439. * hand side in order to facilitate detection of radar pulses out to
  440. * the extreme band-edge of the channel frequency.
  441. * Since the HW design processes four tones at a time,
  442. * this requires one additional Dword to be added to the
  443. * search FFT report.
  444. * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary +
  445. * 1x-oversampled bins (in-band) per FFT,
  446. * then 8 more bins (4 more on left side and 4 more on right side)
  447. * are added.
  448. *
  449. * @num_bins: Number of edge extra bins
  450. * @start_bin_idx: Indicates the start index of extra bins
  451. */
  452. struct samp_edge_extra_bin_info {
  453. uint16_t num_bins;
  454. uint16_t start_bin_idx;
  455. } __packed;
  456. /* Compile time assert to check struct size is divisible by 4 Bytes */
  457. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  458. (sizeof(struct samp_edge_extra_bin_info) % 4)
  459. == 0);
  460. /**
  461. * struct samp_detector_info - SAMP per-detector information
  462. * A detector here refers to the HW carrying out the Spectral scan, to
  463. * detect the presence of interferences.
  464. * @start_frequency: Indicates start frequency per-detector (in MHz)
  465. * @end_frequency: Indicates last frequency per-detector (in MHz)
  466. * @timestamp: Indicates Spectral HW timestamp (usec)
  467. * @last_tstamp: Indicates the last time stamp
  468. * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of
  469. * 160Mhz it will be primary 80 segment's timestamp as both primary & secondary
  470. * segment's timestamp are expected to be almost equal.
  471. * @timestamp_war_offset: Offset calculated based on reset_delay and
  472. * last_raw_timestamp. It will be added to raw_timestamp to get timestamp.
  473. * @raw_timestamp: Actual FFT timestamp reported by HW
  474. * @reset_delay: Time gap between the last spectral report before reset and the
  475. * end of reset. It is provided by FW via direct DMA framework.
  476. * @left_edge_bins: Number of extra bins on left band edge
  477. * @right_edge_bins: Number of extra bins on right band edge
  478. * @start_bin_idx: Indicates the first bin index per-detector
  479. * @end_bin_idx: Indicates the last bin index per-detector
  480. * @max_index: Indicates the index of max magnitude
  481. * @max_magnitude: Indicates the maximum magnitude
  482. * @noise_floor: Indicates the current noise floor
  483. * @rssi: Indicates RSSI
  484. * @pri80ind: Indication from hardware that the sample was received on the
  485. * primary 80 MHz segment. If this is set for smode = SPECTRAL_SCAN_MODE_AGILE,
  486. * it indicates that Spectral scan was carried out on pri80 instead of the
  487. * Agile frequency due to a channel switch - Software may choose to ignore
  488. * the sample in this case.
  489. * @is_sec80: Indicates whether the frequency span corresponds to pri80 or
  490. * sec80 (only applicable for 160/80p80 operating_bw for
  491. * smode SPECTRAL_SCAN_MODE_NORMAL)
  492. */
  493. struct samp_detector_info {
  494. uint32_t start_frequency;
  495. uint32_t end_frequency;
  496. uint32_t timestamp;
  497. uint32_t last_tstamp;
  498. uint32_t last_raw_timestamp;
  499. uint32_t timestamp_war_offset;
  500. uint32_t raw_timestamp;
  501. uint32_t reset_delay;
  502. struct samp_edge_extra_bin_info left_edge_bins;
  503. struct samp_edge_extra_bin_info right_edge_bins;
  504. uint16_t start_bin_idx;
  505. uint16_t end_bin_idx;
  506. uint16_t max_index;
  507. uint16_t max_magnitude;
  508. int16_t noise_floor;
  509. int8_t rssi;
  510. uint8_t agc_total_gain;
  511. uint8_t gainchange;
  512. uint8_t pri80ind;
  513. uint8_t is_sec80;
  514. /* Padding bits to make struct size multiple of 4 bytes */
  515. uint8_t padding_detector_info[1];
  516. } __packed;
  517. /* Compile time assert to check struct size is divisible by 4 Bytes */
  518. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  519. (sizeof(struct samp_detector_info) % 4) == 0);
  520. /**
  521. * struct samp_freq_span_info - SAMP per-frequency span information
  522. * A frequency span here refers to a contiguous span of frequencies in which
  523. * Spectral scan and interference detection is carried out.
  524. * @detector_info: Per-detector Spectral information
  525. * @num_detectors: Number of detectors per span
  526. */
  527. struct samp_freq_span_info {
  528. struct samp_detector_info detector_info[MAX_NUM_DETECTORS];
  529. uint8_t num_detectors;
  530. /* Padding bits to make struct size multiple of 4 bytes */
  531. uint8_t padding_span_info[3];
  532. } __packed;
  533. /* Compile time assert to check struct size is divisible by 4 Bytes */
  534. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  535. (sizeof(struct samp_freq_span_info) % 4) == 0);
  536. /**
  537. * struct spectral_samp_msg - Spectral SAMP message
  538. * @signature: Validates the SAMP message
  539. * @target_reset_count: Indicates the number of times target went through
  540. * reset routine after spectral was enabled.
  541. * @pri20_freq: Primary 20MHz operating frequency in MHz
  542. * @cfreq1: Segment 1 centre frequency in MHz
  543. * @cfreq2: For 80p80, indicates segment 2 centre frequency in MHz. For 160MHz,
  544. * indicates the center frequency of 160MHz span.
  545. * @sscan_cfreq1: Normal/Agile scan Center frequency for Segment 1
  546. * based on Spectral Scan mode.
  547. * @sscan_cfreq2: Normal/Agile scan Center frequency for Segment 2 in case of
  548. * 80p80, and for 160MHz center frequency of the 160MHz span based on Spectral
  549. * Scan mode.
  550. * @bin_pwr_count: Indicates the number of FFT bins
  551. * @freq_span_info: Spectral per-contiguous frequency span information
  552. * @spectral_upper_rssi: Indicates RSSI of upper band
  553. * @spectral_lower_rssi: Indicates RSSI of lower band
  554. * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas
  555. * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas
  556. * @macaddr: Indicates the device interface
  557. * @spectral_mode: Spectral scan mode
  558. * @operating_bw: Device's operating bandwidth. Values = enum phy_ch_width
  559. * @sscan_bw: Normal/Agile Scan BW based on Spectral scan mode.
  560. * Values = enum phy_ch_width
  561. * @fft_width: Indicates the number of bits representing an FFT bin
  562. * @dcs_enabled: Whether DCS is enabled
  563. * @int_type: Interference type indicated by DCS. Values = enum dcs_int_type
  564. * @num_freq_spans: Number of contiguous frequency spans in operating bandwidth
  565. * @bin_pwr: Contains FFT magnitudes
  566. */
  567. struct spectral_samp_msg {
  568. uint32_t signature;
  569. uint32_t target_reset_count;
  570. uint32_t pri20_freq;
  571. uint32_t cfreq1;
  572. uint32_t cfreq2;
  573. uint32_t sscan_cfreq1;
  574. uint32_t sscan_cfreq2;
  575. uint32_t bin_pwr_count;
  576. struct samp_freq_span_info freq_span_info[MAX_NUM_FREQ_SPANS];
  577. int8_t spectral_lower_rssi;
  578. int8_t spectral_upper_rssi;
  579. int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS];
  580. int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS];
  581. uint8_t macaddr[SPECTRAL_MAC_ADDR_SIZE];
  582. uint8_t spectral_mode;
  583. uint8_t operating_bw;
  584. uint8_t sscan_bw;
  585. uint8_t fft_width;
  586. uint8_t dcs_enabled;
  587. uint8_t int_type;
  588. uint8_t num_freq_spans;
  589. uint8_t bin_pwr[0]; /*This should be the last item in the structure*/
  590. } __packed;
  591. #else
  592. /**
  593. * struct spectral_samp_data - Spectral Analysis Messaging Protocol Data format
  594. * @spectral_data_len: Indicates the bin size
  595. * @spectral_data_len_sec80: Indicates the bin size for secondary 80 segment
  596. * @spectral_rssi: Indicates RSSI
  597. * @spectral_rssi_sec80: Indicates RSSI for secondary 80 segment
  598. * @spectral_combined_rssi: Indicates combined RSSI from all antennas
  599. * @spectral_upper_rssi: Indicates RSSI of upper band
  600. * @spectral_lower_rssi: Indicates RSSI of lower band
  601. * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas
  602. * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas
  603. * @spectral_max_scale: Indicates scale factor
  604. * @spectral_bwinfo: Indicates bandwidth info
  605. * @spectral_tstamp: Indicates timestamp
  606. * @spectral_max_index: Indicates the index of max magnitude
  607. * @spectral_max_index_sec80: Indicates the index of max magnitude for secondary
  608. * 80 segment
  609. * @spectral_max_mag: Indicates the maximum magnitude
  610. * @spectral_max_mag_sec80: Indicates the maximum magnitude for secondary 80
  611. * segment
  612. * @spectral_max_exp: Indicates the max exp
  613. * @spectral_last_tstamp: Indicates the last time stamp
  614. * @spectral_upper_max_index: Indicates the index of max mag in upper band
  615. * @spectral_lower_max_index: Indicates the index of max mag in lower band
  616. * @spectral_nb_upper: Not Used
  617. * @spectral_nb_lower: Not Used
  618. * @classifier_params: Indicates classifier parameters
  619. * @bin_pwr_count: Indicates the number of FFT bins
  620. * @lb_edge_extrabins: Number of extra bins on left band edge
  621. * @rb_edge_extrabins: Number of extra bins on right band edge
  622. * @bin_pwr_count_sec80: Indicates the number of FFT bins in secondary 80
  623. * segment
  624. * @bin_pwr: Contains FFT magnitudes
  625. * @bin_pwr_sec80: Contains FFT magnitudes for the secondary 80
  626. * segment
  627. * @interf_list: List of interfernce sources
  628. * @noise_floor: Indicates the current noise floor
  629. * @noise_floor_sec80: Indicates the current noise floor for secondary 80
  630. * segment
  631. * @ch_width: Channel width 20/40/80/160 MHz
  632. * @spectral_mode: Spectral scan mode
  633. * @spectral_pri80ind: Indication from hardware that the sample was
  634. * received on the primary 80 MHz segment. If this
  635. * is set when smode = SPECTRAL_SCAN_MODE_AGILE, it
  636. * indicates that Spectral was carried out on pri80
  637. * instead of the Agile frequency due to a
  638. * channel switch - Software may choose
  639. * to ignore the sample in this case.
  640. * @spectral_pri80ind_sec80: Indication from hardware that the sample was
  641. * received on the primary 80 MHz segment instead of
  642. * the secondary 80 MHz segment due to a channel
  643. * switch - Software may choose to ignore the sample
  644. * if this is set. Applicable only if smode =
  645. * SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz
  646. * Spectral operation.
  647. * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of
  648. * 160Mhz it will be primary 80 segment's timestamp
  649. * as both primary & secondary segment's timestamp
  650. * are expected to be almost equal.
  651. * @timestamp_war_offset: Offset calculated based on reset_delay and
  652. * last_raw_timestamp. It will be added to
  653. * raw_timestamp to get spectral_tstamp.
  654. * @raw_timestamp: Actual FFT timestamp reported by HW on primary
  655. * segment.
  656. * @raw_timestamp_sec80: Actual FFT timestamp reported by HW on sec80 MHz
  657. * segment.
  658. * @reset_delay: Time gap between the last spectral report before
  659. * reset and the end of reset. It is provided by FW
  660. * via direct DMA framework.
  661. * @target_reset_count: Indicates the number of times target went through
  662. * reset routine after spectral was enabled.
  663. * @bin_pwr_count_5mhz: Indicates the number of FFT bins in the extra
  664. * 5 MHz for 165 MHz/ Restricted 80p80 mode
  665. * @bin_pwr_5mhz: Contains FFT magnitudes corresponding to the extra
  666. * 5 MHz in 165 MHz/ Restricted 80p80 mode
  667. */
  668. struct spectral_samp_data {
  669. int16_t spectral_data_len;
  670. int16_t spectral_data_len_sec80;
  671. int16_t spectral_rssi;
  672. int16_t spectral_rssi_sec80;
  673. int8_t spectral_combined_rssi;
  674. int8_t spectral_upper_rssi;
  675. int8_t spectral_lower_rssi;
  676. int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS];
  677. int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS];
  678. uint8_t spectral_max_scale;
  679. int16_t spectral_bwinfo;
  680. int32_t spectral_tstamp;
  681. int16_t spectral_max_index;
  682. int16_t spectral_max_index_sec80;
  683. int16_t spectral_max_mag;
  684. int16_t spectral_max_mag_sec80;
  685. uint8_t spectral_max_exp;
  686. int32_t spectral_last_tstamp;
  687. int16_t spectral_upper_max_index;
  688. int16_t spectral_lower_max_index;
  689. uint8_t spectral_nb_upper;
  690. uint8_t spectral_nb_lower;
  691. struct spectral_classifier_params classifier_params;
  692. uint16_t bin_pwr_count;
  693. /*
  694. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  695. * delivered. However, there can be additional bins reported for
  696. * AR900B version 2.0 and QCA9984 as described next:
  697. *
  698. * AR900B version 2.0: An additional tone is processed on the right
  699. * hand side in order to facilitate detection of radar pulses out to
  700. * the extreme band-edge of the channel frequency.
  701. * Since the HW design processes four tones at a time,
  702. * this requires one additional Dword to be added to the
  703. * search FFT report.
  704. *
  705. * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary +
  706. * 1x-oversampled bins (in-band) per FFT,
  707. * then 8 more bins (4 more on left side and 4 more on right side)
  708. * are added.
  709. */
  710. uint8_t lb_edge_extrabins;
  711. uint8_t rb_edge_extrabins;
  712. uint16_t bin_pwr_count_sec80;
  713. uint8_t bin_pwr[MAX_NUM_BINS_PRI80];
  714. uint8_t bin_pwr_sec80[MAX_NUM_BINS_SEC80];
  715. struct interf_src_rsp interf_list;
  716. int16_t noise_floor;
  717. int16_t noise_floor_sec80;
  718. uint32_t ch_width;
  719. uint8_t spectral_agc_total_gain;
  720. uint8_t spectral_agc_total_gain_sec80;
  721. uint8_t spectral_gainchange;
  722. uint8_t spectral_gainchange_sec80;
  723. enum spectral_scan_mode spectral_mode;
  724. uint8_t spectral_pri80ind;
  725. uint8_t spectral_pri80ind_sec80;
  726. uint32_t last_raw_timestamp;
  727. uint32_t timestamp_war_offset;
  728. uint32_t raw_timestamp;
  729. uint32_t raw_timestamp_sec80;
  730. uint32_t reset_delay;
  731. uint32_t target_reset_count;
  732. uint32_t agile_ch_width;
  733. uint16_t bin_pwr_count_5mhz;
  734. uint8_t bin_pwr_5mhz[MAX_NUM_BINS_5MHZ];
  735. } __packed;
  736. /**
  737. * struct spectral_samp_msg - Spectral SAMP message
  738. * @signature: Validates the SAMP message
  739. * @freq: Operating frequency in MHz
  740. * @vhtop_ch_freq_seg1: VHT Segment 1 centre frequency in MHz
  741. * @vhtop_ch_freq_seg2: VHT Segment 2 centre frequency in MHz
  742. * @agile_freq1: Center frequency in MHz of the entire span(for 80+80 MHz
  743. * agile Scan it is primary 80 MHz span) across which
  744. * Agile Spectral is carried out. Applicable only for Agile
  745. * Spectral samples.
  746. * @agile_freq2: Center frequency in MHz of the secondary 80 MHz span
  747. * across which Agile Spectral is carried out. Applicable
  748. * only for Agile Spectral samples in 80+80 MHz mode.
  749. * @freq_loading: How busy was the channel
  750. * @dcs_enabled: Whether DCS is enabled
  751. * @int_type: Interference type indicated by DCS
  752. * @macaddr: Indicates the device interface
  753. * @samp_data: SAMP Data
  754. */
  755. struct spectral_samp_msg {
  756. uint32_t signature;
  757. uint16_t freq;
  758. uint16_t vhtop_ch_freq_seg1;
  759. uint16_t vhtop_ch_freq_seg2;
  760. uint16_t agile_freq1;
  761. uint16_t agile_freq2;
  762. uint16_t freq_loading;
  763. uint16_t dcs_enabled;
  764. enum dcs_int_type int_type;
  765. uint8_t macaddr[6];
  766. struct spectral_samp_data samp_data;
  767. } __packed;
  768. #endif /* OPTIMIZED_SAMP_MESSAGE */
  769. #endif