spectral_ioctl.h 31 KB

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