spectral_ioctl.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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_5MHZ,
  182. SPECTRAL_CH_WIDTH_10MHZ,
  183. #ifdef WLAN_FEATURE_11BE
  184. SPECTRAL_CH_WIDTH_320MHZ,
  185. #endif
  186. SPECTRAL_CH_WIDTH_MAX,
  187. SPECTRAL_CH_WIDTH_INVALID,
  188. };
  189. struct spectral_ioctl_params {
  190. int16_t spectral_fft_period;
  191. int16_t pectral_period;
  192. int16_t spectral_count;
  193. uint16_t spectral_short_report;
  194. uint16_t spectral_pri;
  195. };
  196. /**
  197. * spectral_cap_hw_gen: Definitions for the Spectral hardware generation.
  198. * This corresponds to definitions in qca_wlan_vendor_spectral_scan_cap_hw_gen.
  199. * @SPECTRAL_CAP_HW_GEN_1: Generation 1
  200. * @SPECTRAL_CAP_HW_GEN_2: Generation 2
  201. * @SPECTRAL_CAP_HW_GEN_3: Generation 3
  202. */
  203. enum spectral_cap_hw_gen {
  204. SPECTRAL_CAP_HW_GEN_1 = 0,
  205. SPECTRAL_CAP_HW_GEN_2 = 1,
  206. SPECTRAL_CAP_HW_GEN_3 = 2,
  207. };
  208. /**
  209. * struct spectral_config_frequency - Spectral scan frequency
  210. * @cfreq1: Center frequency (in MHz) of the span of interest(primary 80 MHz
  211. * span for 80 + 80 agile scan request) or center frequency (in MHz)
  212. * of any WLAN channel in the span of interest.
  213. * @cfreq2: Applicable only for Agile Spectral scan request in 80+80 MHz mode.
  214. * For 80+80 mode it represents the center frequency (in MHz) of the
  215. * secondary 80 MHz span of interest or center frequency (in MHz) of
  216. * any WLAN channel in the secondary 80 MHz span of interest.
  217. */
  218. struct spectral_config_frequency {
  219. uint32_t cfreq1;
  220. uint32_t cfreq2;
  221. };
  222. /**
  223. * struct spectral_config - spectral config parameters
  224. * @ss_fft_period: Skip interval for FFT reports
  225. * @ss_period: Spectral scan period
  226. * @ss_count: # of reports to return from ss_active
  227. * @ss_short_report: Set to report only 1 set of FFT results
  228. * @radar_bin_thresh_sel: Select threshold to classify strong bin for FFT
  229. * @ss_spectral_pri: Priority, and are we doing a noise power cal ?
  230. * @ss_fft_size: Defines the number of FFT data points to compute,
  231. * defined as a log index num_fft_pts =
  232. * 2^ss_fft_size
  233. * @ss_gc_ena: Set, to enable targeted gain change before
  234. * starting the spectral scan FFT
  235. * @ss_restart_ena: Set, to enable abort of receive frames when in high
  236. * priority and a spectral scan is queued
  237. * @ss_noise_floor_ref: Noise floor reference number (signed) for the
  238. * calculation of bin power (dBm) Though stored as an
  239. * unsigned this should be treated as a signed 8-bit int.
  240. * @ss_init_delay: Disallow spectral scan triggers after tx/rx packets
  241. * by setting this delay value to roughly SIFS time
  242. * period or greater Delay timer count in units of 0.25us
  243. * @ss_nb_tone_thr: Number of strong bins (inclusive) per sub-channel,
  244. * below which a signal is declared a narrowband tone
  245. * @ss_str_bin_thr: Bin/max_bin ratio threshold over which a bin is
  246. * declared strong (for spectral scan bandwidth analysis)
  247. * @ss_wb_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER
  248. * (phy_error=36), if none of the sub-channels are
  249. * deemed narrowband
  250. * @ss_rssi_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER
  251. * (phy_error=36), if the ADC RSSI is below the
  252. * threshold ss_rssi_thr
  253. * @ss_rssi_thr: ADC RSSI must be greater than or equal to this
  254. * threshold (signed Db) to ensure spectral scan
  255. * reporting with normal phy error codes (please see
  256. * ss_rssi_rpt_mode above).Though stored as an unsigned
  257. * value, this should be treated as a signed 8-bit int
  258. * @ss_pwr_format: Format of frequency bin magnitude for spectral scan
  259. * triggered FFTs 0: linear magnitude
  260. * 1: log magnitude (20*log10(lin_mag), 1/2 dB step size)
  261. * @ss_rpt_mode: Format of per-FFT reports to software for spectral
  262. * scan triggered FFTs
  263. * 0: No FFT report (only pulse end summary)
  264. * 1: 2-dword summary of metrics for each completed FFT
  265. * 2: 2-dword summary + 1x-oversampled bins(in-band) per
  266. * FFT
  267. * 3: 2-dword summary + 2x-oversampled bins (all) per FFT
  268. * @ss_bin_scale: Number of LSBs to shift out to scale the FFT bins
  269. * for spectral scan triggered FFTs
  270. * @ss_dbm_adj: Set (with ss_pwr_format=1), to report bin
  271. * magnitudes
  272. * converted to dBm power using the noisefloor
  273. * calibration results
  274. * @ss_chn_mask: Per chain enable mask to select input ADC for search
  275. * FFT
  276. * @ss_nf_cal: nf calibrated values for ctl+ext
  277. * @ss_nf_pwr: nf pwr values for ctl+ext
  278. * @ss_nf_temp_data: temperature data taken during nf scan
  279. * @ss_frequency: This specifies the frequency span over which Spectral
  280. * scan would be carried out. Its value depends on the
  281. * Spectral scan mode.
  282. * Normal mode:-
  283. * Not applicable. Spectral scan would happen in the
  284. * operating span.
  285. * Agile mode:-
  286. * cfreq1 represents the center frequency (in MHz) of
  287. * the span of interest(primary 80 MHz span for 80 + 80
  288. * agile scan request) or center frequency (in MHz) of
  289. * any WLAN channel in the span of interest. cfreq2 is
  290. * applicable only for Agile Spectral scan request in
  291. * 80+80 MHz mode. For 80+80 mode it represents the
  292. * center frequency (in MHz) of the secondary 80 MHz
  293. * span of interest or center frequency (in MHz) of
  294. * any WLAN channel in the secondary 80 MHz span of
  295. * interest.
  296. */
  297. struct spectral_config {
  298. uint16_t ss_fft_period;
  299. uint16_t ss_period;
  300. uint16_t ss_count;
  301. uint16_t ss_short_report;
  302. uint8_t radar_bin_thresh_sel;
  303. uint16_t ss_spectral_pri;
  304. uint16_t ss_fft_size;
  305. uint16_t ss_gc_ena;
  306. uint16_t ss_restart_ena;
  307. uint16_t ss_noise_floor_ref;
  308. uint16_t ss_init_delay;
  309. uint16_t ss_nb_tone_thr;
  310. uint16_t ss_str_bin_thr;
  311. uint16_t ss_wb_rpt_mode;
  312. uint16_t ss_rssi_rpt_mode;
  313. uint16_t ss_rssi_thr;
  314. uint16_t ss_pwr_format;
  315. uint16_t ss_rpt_mode;
  316. uint16_t ss_bin_scale;
  317. uint16_t ss_dbm_adj;
  318. uint16_t ss_chn_mask;
  319. int8_t ss_nf_cal[AH_MAX_CHAINS * 2];
  320. int8_t ss_nf_pwr[AH_MAX_CHAINS * 2];
  321. int32_t ss_nf_temp_data;
  322. struct spectral_config_frequency ss_frequency;
  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. * @num_detectors_20mhz: number of Spectral detectors in 20 MHz
  341. * @num_detectors_40mhz: number of Spectral detectors in 40 MHz
  342. * @num_detectors_80mhz: number of Spectral detectors in 80 MHz
  343. * @num_detectors_160mhz: number of Spectral detectors in 160 MHz
  344. * @num_detectors_80p80mhz: number of Spectral detectors in 80p80 MHz
  345. */
  346. struct spectral_caps {
  347. uint8_t phydiag_cap;
  348. uint8_t radar_cap;
  349. uint8_t spectral_cap;
  350. uint8_t advncd_spectral_cap;
  351. uint32_t hw_gen;
  352. bool is_scaling_params_populated;
  353. uint16_t formula_id;
  354. int16_t low_level_offset;
  355. int16_t high_level_offset;
  356. int16_t rssi_thr;
  357. uint8_t default_agc_max_gain;
  358. bool agile_spectral_cap;
  359. bool agile_spectral_cap_160;
  360. bool agile_spectral_cap_80p80;
  361. uint32_t num_detectors_20mhz;
  362. uint32_t num_detectors_40mhz;
  363. uint32_t num_detectors_80mhz;
  364. uint32_t num_detectors_160mhz;
  365. uint32_t num_detectors_80p80mhz;
  366. };
  367. #define SPECTRAL_IOCTL_PARAM_NOVAL (65535)
  368. #define MAX_SPECTRAL_CHAINS (3)
  369. #define MAX_NUM_BINS (2048)
  370. #define MAX_NUM_BINS_PRI80 (1024)
  371. #define MAX_NUM_BINS_SEC80 (520)
  372. #define MAX_NUM_BINS_5MHZ (32)
  373. /* 5 categories x (lower + upper) bands */
  374. #define MAX_INTERF 10
  375. #define SPECTRAL_MAC_ADDR_SIZE (6)
  376. #define MAX_NUM_FREQ_SPANS (3)
  377. #define MAX_NUM_DETECTORS (2)
  378. #define MAX_SPECTRAL_PAYLOAD (2004)
  379. /**
  380. * enum dcs_int_type - Interference type indicated by DCS
  381. * @SPECTRAL_DCS_INT_NONE: No interference
  382. * @SPECTRAL_DCS_INT_CW: CW interference
  383. * @SPECTRAL_DCS_INT_WIFI: WLAN interference
  384. */
  385. enum dcs_int_type {
  386. SPECTRAL_DCS_INT_NONE,
  387. SPECTRAL_DCS_INT_CW,
  388. SPECTRAL_DCS_INT_WIFI
  389. };
  390. /**
  391. * struct interf_rsp - Interference record
  392. * @interf_type: eINTERF_TYPE giving type of interference
  393. * @interf_min_freq: Minimum frequency in MHz at which interference has been
  394. * found
  395. * @interf_max_freq: Maximum frequency in MHz at which interference has been
  396. * found
  397. * @advncd_spectral_cap: Advanced spectral capability
  398. */
  399. struct interf_rsp {
  400. uint8_t interf_type;
  401. uint16_t interf_min_freq;
  402. uint16_t interf_max_freq;
  403. } __packed;
  404. /**
  405. * struct interf_src_rsp - List of interference sources
  406. * @count: Number of interference records
  407. * @interf: Array of interference records
  408. */
  409. struct interf_src_rsp {
  410. uint16_t count;
  411. struct interf_rsp interf[MAX_INTERF];
  412. } __packed;
  413. /**
  414. * struct spectral_classifier_params - spectral classifier parameters
  415. * @spectral_20_40_mode: Is AP in 20/40 mode?
  416. * @spectral_dc_index: DC index
  417. * @spectral_dc_in_mhz: DC in MHz
  418. * @upper_chan_in_mhz: Upper channel in MHz
  419. * @lower_chan_in_mhz: Lower channel in MHz
  420. */
  421. struct spectral_classifier_params {
  422. int spectral_20_40_mode;
  423. int spectral_dc_index;
  424. int spectral_dc_in_mhz;
  425. int upper_chan_in_mhz;
  426. int lower_chan_in_mhz;
  427. } __packed;
  428. #ifdef OPTIMIZED_SAMP_MESSAGE
  429. /**
  430. * struct samp_edge_extra_bin_info - Spectral edge extra bins Information
  431. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  432. * delivered. However, there can be additional bins reported for
  433. * AR900B version 2.0 and QCA9984 as described next:
  434. * AR900B version 2.0: An additional tone is processed on the right
  435. * hand side in order to facilitate detection of radar pulses out to
  436. * the extreme band-edge of the channel frequency.
  437. * Since the HW design processes four tones at a time,
  438. * this requires one additional Dword to be added to the
  439. * search FFT report.
  440. * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary +
  441. * 1x-oversampled bins (in-band) per FFT,
  442. * then 8 more bins (4 more on left side and 4 more on right side)
  443. * are added.
  444. *
  445. * @num_bins: Number of edge extra bins
  446. * @start_bin_idx: Indicates the start index of extra bins
  447. */
  448. struct samp_edge_extra_bin_info {
  449. uint16_t num_bins;
  450. uint16_t start_bin_idx;
  451. } __packed;
  452. /* Compile time assert to check struct size is divisible by 4 Bytes */
  453. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  454. (sizeof(struct samp_edge_extra_bin_info) % 4)
  455. == 0);
  456. /**
  457. * struct samp_detector_info - SAMP per-detector information
  458. * A detector here refers to the HW carrying out the Spectral scan, to
  459. * detect the presence of interferences.
  460. * @start_frequency: Indicates start frequency per-detector (in MHz)
  461. * @end_frequency: Indicates last frequency per-detector (in MHz)
  462. * @timestamp: Indicates Spectral HW timestamp (usec)
  463. * @last_tstamp: Indicates the last time stamp
  464. * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of
  465. * 160Mhz it will be primary 80 segment's timestamp as both primary & secondary
  466. * segment's timestamp are expected to be almost equal.
  467. * @timestamp_war_offset: Offset calculated based on reset_delay and
  468. * last_raw_timestamp. It will be added to raw_timestamp to get timestamp.
  469. * @raw_timestamp: Actual FFT timestamp reported by HW
  470. * @reset_delay: Time gap between the last spectral report before reset and the
  471. * end of reset. It is provided by FW via direct DMA framework.
  472. * @left_edge_bins: Number of extra bins on left band edge
  473. * @right_edge_bins: Number of extra bins on right band edge
  474. * @start_bin_idx: Indicates the first bin index per-detector
  475. * @end_bin_idx: Indicates the last bin index per-detector
  476. * @max_index: Indicates the index of max magnitude
  477. * @max_magnitude: Indicates the maximum magnitude
  478. * @noise_floor: Indicates the current noise floor
  479. * @rssi: Indicates RSSI
  480. * @pri80ind: Indication from hardware that the sample was received on the
  481. * primary 80 MHz segment. If this is set for smode = SPECTRAL_SCAN_MODE_AGILE,
  482. * it indicates that Spectral scan was carried out on pri80 instead of the
  483. * Agile frequency due to a channel switch - Software may choose to ignore
  484. * the sample in this case.
  485. * @is_sec80: Indicates whether the frequency span corresponds to pri80 or
  486. * sec80 (only applicable for 160/80p80 operating_bw for
  487. * smode SPECTRAL_SCAN_MODE_NORMAL)
  488. */
  489. struct samp_detector_info {
  490. uint32_t start_frequency;
  491. uint32_t end_frequency;
  492. uint32_t timestamp;
  493. uint32_t last_tstamp;
  494. uint32_t last_raw_timestamp;
  495. uint32_t timestamp_war_offset;
  496. uint32_t raw_timestamp;
  497. uint32_t reset_delay;
  498. struct samp_edge_extra_bin_info left_edge_bins;
  499. struct samp_edge_extra_bin_info right_edge_bins;
  500. uint16_t start_bin_idx;
  501. uint16_t end_bin_idx;
  502. uint16_t max_index;
  503. uint16_t max_magnitude;
  504. int16_t noise_floor;
  505. int8_t rssi;
  506. uint8_t agc_total_gain;
  507. uint8_t gainchange;
  508. uint8_t pri80ind;
  509. uint8_t is_sec80;
  510. /* Padding bits to make struct size multiple of 4 bytes */
  511. uint8_t padding_detector_info[1];
  512. } __packed;
  513. /* Compile time assert to check struct size is divisible by 4 Bytes */
  514. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  515. (sizeof(struct samp_detector_info) % 4) == 0);
  516. /**
  517. * struct samp_freq_span_info - SAMP per-frequency span information
  518. * A frequency span here refers to a contiguous span of frequencies in which
  519. * Spectral scan and interference detection is carried out.
  520. * @detector_info: Per-detector Spectral information
  521. * @num_detectors: Number of detectors per span
  522. */
  523. struct samp_freq_span_info {
  524. struct samp_detector_info detector_info[MAX_NUM_DETECTORS];
  525. uint8_t num_detectors;
  526. /* Padding bits to make struct size multiple of 4 bytes */
  527. uint8_t padding_span_info[3];
  528. } __packed;
  529. /* Compile time assert to check struct size is divisible by 4 Bytes */
  530. SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion,
  531. (sizeof(struct samp_freq_span_info) % 4) == 0);
  532. /**
  533. * struct spectral_samp_msg - Spectral SAMP message
  534. * @signature: Validates the SAMP message
  535. * @target_reset_count: Indicates the number of times target went through
  536. * reset routine after spectral was enabled.
  537. * @pri20_freq: Primary 20MHz operating frequency in MHz
  538. * @cfreq1: Segment 1 centre frequency in MHz
  539. * @cfreq2: For 80p80, indicates segment 2 centre frequency in MHz. For 160MHz,
  540. * indicates the center frequency of 160MHz span.
  541. * @sscan_cfreq1: Normal/Agile scan Center frequency for Segment 1
  542. * based on Spectral Scan mode.
  543. * @sscan_cfreq2: Normal/Agile scan Center frequency for Segment 2 in case of
  544. * 80p80, and for 160MHz center frequency of the 160MHz span based on Spectral
  545. * Scan mode.
  546. * @bin_pwr_count: Indicates the number of FFT bins
  547. * @freq_span_info: Spectral per-contiguous frequency span information
  548. * @spectral_upper_rssi: Indicates RSSI of upper band
  549. * @spectral_lower_rssi: Indicates RSSI of lower band
  550. * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas
  551. * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas
  552. * @macaddr: Indicates the device interface
  553. * @spectral_mode: Spectral scan mode
  554. * @operating_bw: Device's operating bandwidth. Values = enum phy_ch_width
  555. * @sscan_bw: Normal/Agile Scan BW based on Spectral scan mode.
  556. * Values = enum phy_ch_width
  557. * @fft_width: Indicates the number of bits representing an FFT bin
  558. * @dcs_enabled: Whether DCS is enabled
  559. * @int_type: Interference type indicated by DCS. Values = enum dcs_int_type
  560. * @num_freq_spans: Number of contiguous frequency spans in operating bandwidth
  561. * @bin_pwr: Contains FFT magnitudes
  562. */
  563. struct spectral_samp_msg {
  564. uint32_t signature;
  565. uint32_t target_reset_count;
  566. uint32_t pri20_freq;
  567. uint32_t cfreq1;
  568. uint32_t cfreq2;
  569. uint32_t sscan_cfreq1;
  570. uint32_t sscan_cfreq2;
  571. uint32_t bin_pwr_count;
  572. struct samp_freq_span_info freq_span_info[MAX_NUM_FREQ_SPANS];
  573. int8_t spectral_lower_rssi;
  574. int8_t spectral_upper_rssi;
  575. int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS];
  576. int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS];
  577. uint8_t macaddr[SPECTRAL_MAC_ADDR_SIZE];
  578. uint8_t spectral_mode;
  579. uint8_t operating_bw;
  580. uint8_t sscan_bw;
  581. uint8_t fft_width;
  582. uint8_t dcs_enabled;
  583. uint8_t int_type;
  584. uint8_t num_freq_spans;
  585. uint8_t bin_pwr[0]; /*This should be the last item in the structure*/
  586. } __packed;
  587. #else
  588. /**
  589. * struct spectral_samp_data - Spectral Analysis Messaging Protocol Data format
  590. * @spectral_data_len: Indicates the bin size
  591. * @spectral_data_len_sec80: Indicates the bin size for secondary 80 segment
  592. * @spectral_rssi: Indicates RSSI
  593. * @spectral_rssi_sec80: Indicates RSSI for secondary 80 segment
  594. * @spectral_combined_rssi: Indicates combined RSSI from all antennas
  595. * @spectral_upper_rssi: Indicates RSSI of upper band
  596. * @spectral_lower_rssi: Indicates RSSI of lower band
  597. * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas
  598. * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas
  599. * @spectral_max_scale: Indicates scale factor
  600. * @spectral_bwinfo: Indicates bandwidth info
  601. * @spectral_tstamp: Indicates timestamp
  602. * @spectral_max_index: Indicates the index of max magnitude
  603. * @spectral_max_index_sec80: Indicates the index of max magnitude for secondary
  604. * 80 segment
  605. * @spectral_max_mag: Indicates the maximum magnitude
  606. * @spectral_max_mag_sec80: Indicates the maximum magnitude for secondary 80
  607. * segment
  608. * @spectral_max_exp: Indicates the max exp
  609. * @spectral_last_tstamp: Indicates the last time stamp
  610. * @spectral_upper_max_index: Indicates the index of max mag in upper band
  611. * @spectral_lower_max_index: Indicates the index of max mag in lower band
  612. * @spectral_nb_upper: Not Used
  613. * @spectral_nb_lower: Not Used
  614. * @classifier_params: Indicates classifier parameters
  615. * @bin_pwr_count: Indicates the number of FFT bins
  616. * @lb_edge_extrabins: Number of extra bins on left band edge
  617. * @rb_edge_extrabins: Number of extra bins on right band edge
  618. * @bin_pwr_count_sec80: Indicates the number of FFT bins in secondary 80
  619. * segment
  620. * @bin_pwr: Contains FFT magnitudes
  621. * @bin_pwr_sec80: Contains FFT magnitudes for the secondary 80
  622. * segment
  623. * @interf_list: List of interfernce sources
  624. * @noise_floor: Indicates the current noise floor
  625. * @noise_floor_sec80: Indicates the current noise floor for secondary 80
  626. * segment
  627. * @ch_width: Channel width 20/40/80/160 MHz
  628. * @spectral_mode: Spectral scan mode
  629. * @spectral_pri80ind: Indication from hardware that the sample was
  630. * received on the primary 80 MHz segment. If this
  631. * is set when smode = SPECTRAL_SCAN_MODE_AGILE, it
  632. * indicates that Spectral was carried out on pri80
  633. * instead of the Agile frequency due to a
  634. * channel switch - Software may choose
  635. * to ignore the sample in this case.
  636. * @spectral_pri80ind_sec80: Indication from hardware that the sample was
  637. * received on the primary 80 MHz segment instead of
  638. * the secondary 80 MHz segment due to a channel
  639. * switch - Software may choose to ignore the sample
  640. * if this is set. Applicable only if smode =
  641. * SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz
  642. * Spectral operation.
  643. * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of
  644. * 160Mhz it will be primary 80 segment's timestamp
  645. * as both primary & secondary segment's timestamp
  646. * are expected to be almost equal.
  647. * @timestamp_war_offset: Offset calculated based on reset_delay and
  648. * last_raw_timestamp. It will be added to
  649. * raw_timestamp to get spectral_tstamp.
  650. * @raw_timestamp: Actual FFT timestamp reported by HW on primary
  651. * segment.
  652. * @raw_timestamp_sec80: Actual FFT timestamp reported by HW on sec80 MHz
  653. * segment.
  654. * @reset_delay: Time gap between the last spectral report before
  655. * reset and the end of reset. It is provided by FW
  656. * via direct DMA framework.
  657. * @target_reset_count: Indicates the number of times target went through
  658. * reset routine after spectral was enabled.
  659. * @bin_pwr_count_5mhz: Indicates the number of FFT bins in the extra
  660. * 5 MHz for 165 MHz/ Restricted 80p80 mode
  661. * @bin_pwr_5mhz: Contains FFT magnitudes corresponding to the extra
  662. * 5 MHz in 165 MHz/ Restricted 80p80 mode
  663. */
  664. struct spectral_samp_data {
  665. int16_t spectral_data_len;
  666. int16_t spectral_data_len_sec80;
  667. int16_t spectral_rssi;
  668. int16_t spectral_rssi_sec80;
  669. int8_t spectral_combined_rssi;
  670. int8_t spectral_upper_rssi;
  671. int8_t spectral_lower_rssi;
  672. int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS];
  673. int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS];
  674. uint8_t spectral_max_scale;
  675. int16_t spectral_bwinfo;
  676. int32_t spectral_tstamp;
  677. int16_t spectral_max_index;
  678. int16_t spectral_max_index_sec80;
  679. int16_t spectral_max_mag;
  680. int16_t spectral_max_mag_sec80;
  681. uint8_t spectral_max_exp;
  682. int32_t spectral_last_tstamp;
  683. int16_t spectral_upper_max_index;
  684. int16_t spectral_lower_max_index;
  685. uint8_t spectral_nb_upper;
  686. uint8_t spectral_nb_lower;
  687. struct spectral_classifier_params classifier_params;
  688. uint16_t bin_pwr_count;
  689. /*
  690. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  691. * delivered. However, there can be additional bins reported for
  692. * AR900B version 2.0 and QCA9984 as described next:
  693. *
  694. * AR900B version 2.0: An additional tone is processed on the right
  695. * hand side in order to facilitate detection of radar pulses out to
  696. * the extreme band-edge of the channel frequency.
  697. * Since the HW design processes four tones at a time,
  698. * this requires one additional Dword to be added to the
  699. * search FFT report.
  700. *
  701. * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary +
  702. * 1x-oversampled bins (in-band) per FFT,
  703. * then 8 more bins (4 more on left side and 4 more on right side)
  704. * are added.
  705. */
  706. uint8_t lb_edge_extrabins;
  707. uint8_t rb_edge_extrabins;
  708. uint16_t bin_pwr_count_sec80;
  709. uint8_t bin_pwr[MAX_NUM_BINS_PRI80];
  710. uint8_t bin_pwr_sec80[MAX_NUM_BINS_SEC80];
  711. struct interf_src_rsp interf_list;
  712. int16_t noise_floor;
  713. int16_t noise_floor_sec80;
  714. uint32_t ch_width;
  715. uint8_t spectral_agc_total_gain;
  716. uint8_t spectral_agc_total_gain_sec80;
  717. uint8_t spectral_gainchange;
  718. uint8_t spectral_gainchange_sec80;
  719. enum spectral_scan_mode spectral_mode;
  720. uint8_t spectral_pri80ind;
  721. uint8_t spectral_pri80ind_sec80;
  722. uint32_t last_raw_timestamp;
  723. uint32_t timestamp_war_offset;
  724. uint32_t raw_timestamp;
  725. uint32_t raw_timestamp_sec80;
  726. uint32_t reset_delay;
  727. uint32_t target_reset_count;
  728. uint32_t agile_ch_width;
  729. uint16_t bin_pwr_count_5mhz;
  730. uint8_t bin_pwr_5mhz[MAX_NUM_BINS_5MHZ];
  731. } __packed;
  732. /**
  733. * struct spectral_samp_msg - Spectral SAMP message
  734. * @signature: Validates the SAMP message
  735. * @freq: Operating frequency in MHz
  736. * @vhtop_ch_freq_seg1: VHT Segment 1 centre frequency in MHz
  737. * @vhtop_ch_freq_seg2: VHT Segment 2 centre frequency in MHz
  738. * @agile_freq1: Center frequency in MHz of the entire span(for 80+80 MHz
  739. * agile Scan it is primary 80 MHz span) across which
  740. * Agile Spectral is carried out. Applicable only for Agile
  741. * Spectral samples.
  742. * @agile_freq2: Center frequency in MHz of the secondary 80 MHz span
  743. * across which Agile Spectral is carried out. Applicable
  744. * only for Agile Spectral samples in 80+80 MHz mode.
  745. * @freq_loading: How busy was the channel
  746. * @dcs_enabled: Whether DCS is enabled
  747. * @int_type: Interference type indicated by DCS
  748. * @macaddr: Indicates the device interface
  749. * @samp_data: SAMP Data
  750. */
  751. struct spectral_samp_msg {
  752. uint32_t signature;
  753. uint16_t freq;
  754. uint16_t vhtop_ch_freq_seg1;
  755. uint16_t vhtop_ch_freq_seg2;
  756. uint16_t agile_freq1;
  757. uint16_t agile_freq2;
  758. uint16_t freq_loading;
  759. uint16_t dcs_enabled;
  760. enum dcs_int_type int_type;
  761. uint8_t macaddr[6];
  762. struct spectral_samp_data samp_data;
  763. } __packed;
  764. #endif /* OPTIMIZED_SAMP_MESSAGE */
  765. #endif