spectral_ioctl.h 33 KB

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