target_if_spectral.h 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  1. /*
  2. * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved.
  3. *
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _TARGET_IF_SPECTRAL_H_
  20. #define _TARGET_IF_SPECTRAL_H_
  21. #include <wlan_objmgr_cmn.h>
  22. #include <wlan_objmgr_psoc_obj.h>
  23. #include <wlan_objmgr_pdev_obj.h>
  24. #include <wlan_objmgr_vdev_obj.h>
  25. #include <qdf_lock.h>
  26. #include <wlan_spectral_public_structs.h>
  27. #include <reg_services_public_struct.h>
  28. #ifdef DIRECT_BUF_RX_ENABLE
  29. #include <target_if_direct_buf_rx_api.h>
  30. #endif
  31. #ifdef WIN32
  32. #pragma pack(push, target_if_spectral, 1)
  33. #define __ATTRIB_PACK
  34. #else
  35. #ifndef __ATTRIB_PACK
  36. #define __ATTRIB_PACK __attribute__ ((packed))
  37. #endif
  38. #endif
  39. #include <spectral_defs_i.h>
  40. #define STATUS_PASS 1
  41. #define STATUS_FAIL 0
  42. #undef spectral_dbg_line
  43. #define spectral_dbg_line() \
  44. spectral_debug("----------------------------------------------------")
  45. #undef spectral_ops_not_registered
  46. #define spectral_ops_not_registered(str) \
  47. spectral_info("SPECTRAL : %s not registered\n", (str))
  48. #undef not_yet_implemented
  49. #define not_yet_implemented() \
  50. spectral_info("SPECTRAL : %s : %d Not yet implemented\n", \
  51. __func__, __LINE__)
  52. #define SPECTRAL_HT20_NUM_BINS 56
  53. #define SPECTRAL_HT20_FFT_LEN 56
  54. #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2)
  55. #define SPECTRAL_HT20_DATA_LEN 60
  56. #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3)
  57. #define SPECTRAL_HT40_TOTAL_NUM_BINS 128
  58. #define SPECTRAL_HT40_DATA_LEN 135
  59. #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3)
  60. #define SPECTRAL_HT40_FFT_LEN 128
  61. #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2)
  62. /*
  63. * Used for the SWAR to obtain approximate combined rssi
  64. * in secondary 80Mhz segment
  65. */
  66. #define OFFSET_CH_WIDTH_20 65
  67. #define OFFSET_CH_WIDTH_40 62
  68. #define OFFSET_CH_WIDTH_80 56
  69. #define OFFSET_CH_WIDTH_160 50
  70. #ifdef BIG_ENDIAN_HOST
  71. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \
  72. int j; \
  73. uint32_t *src, *dest; \
  74. src = (uint32_t *)(srcp); \
  75. dest = (uint32_t *)(destp); \
  76. for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \
  77. *(dest + j) = qdf_le32_to_cpu(*(src + j)); \
  78. } \
  79. } while (0)
  80. #else
  81. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \
  82. OS_MEMCPY((destp), (srcp), (len));
  83. #endif
  84. #define DUMMY_NF_VALUE (-123)
  85. /* 5 categories x (lower + upper) bands */
  86. #define MAX_INTERF 10
  87. #define HOST_MAX_ANTENNA 3
  88. /* Mask for time stamp from descriptor */
  89. #define SPECTRAL_TSMASK 0xFFFFFFFF
  90. #define SPECTRAL_SIGNATURE 0xdeadbeef
  91. /* START of spectral GEN II HW specific details */
  92. #define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb
  93. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2 0xF9
  94. #define TLV_TAG_ADC_REPORT_GEN2 0xFA
  95. #define TLV_TAG_SEARCH_FFT_REPORT_GEN2 0xFB
  96. /**
  97. * struct spectral_search_fft_info_gen2 - spectral search fft report for gen2
  98. * @relpwr_db: Total bin power in db
  99. * @num_str_bins_ib: Number of strong bins
  100. * @base_pwr: Base power
  101. * @total_gain_info: Total gain
  102. * @fft_chn_idx: FFT chain on which report is originated
  103. * @avgpwr_db: Average power in db
  104. * @peak_mag: Peak power seen in the bins
  105. * @peak_inx: Index of bin holding peak power
  106. */
  107. struct spectral_search_fft_info_gen2 {
  108. uint32_t relpwr_db;
  109. uint32_t num_str_bins_ib;
  110. uint32_t base_pwr;
  111. uint32_t total_gain_info;
  112. uint32_t fft_chn_idx;
  113. uint32_t avgpwr_db;
  114. uint32_t peak_mag;
  115. int16_t peak_inx;
  116. };
  117. /*
  118. * XXX Check if we should be handling the endinness difference in some
  119. * other way opaque to the host
  120. */
  121. #ifdef BIG_ENDIAN_HOST
  122. /**
  123. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for big endian host
  124. * @signature: signature
  125. * @tag: tag
  126. * @length: length
  127. */
  128. struct spectral_phyerr_tlv_gen2 {
  129. uint8_t signature;
  130. uint8_t tag;
  131. uint16_t length;
  132. } __ATTRIB_PACK;
  133. #else
  134. /**
  135. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for little endian host
  136. * @length: length
  137. * @tag: tag
  138. * @signature: signature
  139. */
  140. struct spectral_phyerr_tlv_gen2 {
  141. uint16_t length;
  142. uint8_t tag;
  143. uint8_t signature;
  144. } __ATTRIB_PACK;
  145. #endif /* BIG_ENDIAN_HOST */
  146. /**
  147. * struct spectral_phyerr_hdr_gen2 - phyerr header for gen2 HW
  148. * @hdr_a: Header[0:31]
  149. * @hdr_b: Header[32:63]
  150. */
  151. struct spectral_phyerr_hdr_gen2 {
  152. uint32_t hdr_a;
  153. uint32_t hdr_b;
  154. };
  155. /*
  156. * Segment ID information for 80+80.
  157. *
  158. * If the HW micro-architecture specification extends this DWORD for other
  159. * purposes, then redefine+rename accordingly. For now, the specification
  160. * mentions only segment ID (though this doesn't require an entire DWORD)
  161. * without mention of any generic terminology for the DWORD, or any reservation.
  162. * We use nomenclature accordingly.
  163. */
  164. typedef uint32_t SPECTRAL_SEGID_INFO;
  165. /**
  166. * struct spectral_phyerr_fft_gen2 - fft info in phyerr event
  167. * @buf: fft report
  168. */
  169. struct spectral_phyerr_fft_gen2 {
  170. uint8_t buf[0];
  171. };
  172. /* END of spectral GEN II HW specific details */
  173. /* START of spectral GEN III HW specific details */
  174. #define get_bitfield(value, size, pos) \
  175. (((value) >> (pos)) & ((1 << (size)) - 1))
  176. #define unsigned_to_signed(value, width) \
  177. (((value) >= (1 << ((width) - 1))) ? \
  178. (value - (1 << (width))) : (value))
  179. #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA)
  180. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02)
  181. #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03)
  182. #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4)
  183. #define PHYERR_HDR_SIG_POS \
  184. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_sig))
  185. #define PHYERR_HDR_TAG_POS \
  186. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_tag))
  187. #define SPECTRAL_FFT_BINS_POS \
  188. (offsetof(struct spectral_phyerr_fft_report_gen3, buf))
  189. /**
  190. * struct phyerr_info - spectral search fft report for gen3
  191. * @data: handle to phyerror buffer
  192. * @datalen: length of phyerror bufer
  193. * @p_rfqual: rf quality matrices
  194. * @p_chaninfo: pointer to chaninfo
  195. * @tsf64: 64 bit TSF
  196. * @acs_stats: acs stats
  197. */
  198. struct phyerr_info {
  199. uint8_t *data;
  200. uint32_t datalen;
  201. struct target_if_spectral_rfqual_info *p_rfqual;
  202. struct target_if_spectral_chan_info *p_chaninfo;
  203. uint64_t tsf64;
  204. struct target_if_spectral_acs_stats *acs_stats;
  205. };
  206. /**
  207. * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3
  208. * @timestamp: Timestamp at which fft report was generated
  209. * @fft_detector_id: Which radio generated this report
  210. * @fft_num: The FFT count number. Set to 0 for short FFT.
  211. * @fft_radar_check: NA for spectral
  212. * @fft_peak_sidx: Index of bin with maximum power
  213. * @fft_chn_idx: Rx chain index
  214. * @fft_base_pwr_db: Base power in dB
  215. * @fft_total_gain_db: Total gain in dB
  216. * @fft_num_str_bins_ib: Number of strong bins in the report
  217. * @fft_peak_mag: Peak magnitude
  218. * @fft_avgpwr_db: Average power in dB
  219. * @fft_relpwr_db: Relative power in dB
  220. */
  221. struct spectral_search_fft_info_gen3 {
  222. uint32_t timestamp;
  223. uint32_t fft_detector_id;
  224. uint32_t fft_num;
  225. uint32_t fft_radar_check;
  226. int32_t fft_peak_sidx;
  227. uint32_t fft_chn_idx;
  228. uint32_t fft_base_pwr_db;
  229. uint32_t fft_total_gain_db;
  230. uint32_t fft_num_str_bins_ib;
  231. int32_t fft_peak_mag;
  232. uint32_t fft_avgpwr_db;
  233. uint32_t fft_relpwr_db;
  234. };
  235. /**
  236. * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event
  237. * @fft_timestamp: Timestamp at which fft report was generated
  238. * @fft_hdr_sig: signature
  239. * @fft_hdr_tag: tag
  240. * @fft_hdr_length: length
  241. * @hdr_a: Header[0:31]
  242. * @hdr_b: Header[32:63]
  243. * @hdr_c: Header[64:95]
  244. * @resv: Header[96:127]
  245. * @buf: fft bins
  246. */
  247. struct spectral_phyerr_fft_report_gen3 {
  248. uint32_t fft_timestamp;
  249. #ifdef BIG_ENDIAN_HOST
  250. uint8_t fft_hdr_sig;
  251. uint8_t fft_hdr_tag;
  252. uint16_t fft_hdr_length;
  253. #else
  254. uint16_t fft_hdr_length;
  255. uint8_t fft_hdr_tag;
  256. uint8_t fft_hdr_sig;
  257. #endif /* BIG_ENDIAN_HOST */
  258. uint32_t hdr_a;
  259. uint32_t hdr_b;
  260. uint32_t hdr_c;
  261. uint32_t resv;
  262. uint8_t buf[0];
  263. } __ATTRIB_PACK;
  264. /**
  265. * struct spectral_sscan_report_gen3 - spectral report in phyerr event
  266. * @sscan_timestamp: Timestamp at which fft report was generated
  267. * @sscan_hdr_sig: signature
  268. * @sscan_hdr_tag: tag
  269. * @sscan_hdr_length: length
  270. * @hdr_a: Header[0:31]
  271. * @resv: Header[32:63]
  272. * @hdr_b: Header[64:95]
  273. * @resv: Header[96:127]
  274. */
  275. struct spectral_sscan_report_gen3 {
  276. u_int32_t sscan_timestamp;
  277. #ifdef BIG_ENDIAN_HOST
  278. u_int8_t sscan_hdr_sig;
  279. u_int8_t sscan_hdr_tag;
  280. u_int16_t sscan_hdr_length;
  281. #else
  282. u_int16_t sscan_hdr_length;
  283. u_int8_t sscan_hdr_tag;
  284. u_int8_t sscan_hdr_sig;
  285. #endif /* BIG_ENDIAN_HOST */
  286. u_int32_t hdr_a;
  287. u_int32_t res1;
  288. u_int32_t hdr_b;
  289. u_int32_t res2;
  290. } __ATTRIB_PACK;
  291. #ifdef DIRECT_BUF_RX_ENABLE
  292. /**
  293. * struct Spectral_report - spectral report
  294. * @data: Report buffer
  295. * @noisefloor: Noise floor values
  296. */
  297. struct spectral_report {
  298. uint8_t *data;
  299. int32_t noisefloor[DBR_MAX_CHAINS];
  300. };
  301. #endif
  302. /* END of spectral GEN III HW specific details */
  303. typedef signed char pwr_dbm;
  304. /**
  305. * enum spectral_gen - spectral hw generation
  306. * @SPECTRAL_GEN1 : spectral hw gen 1
  307. * @SPECTRAL_GEN2 : spectral hw gen 2
  308. * @SPECTRAL_GEN3 : spectral hw gen 3
  309. */
  310. enum spectral_gen {
  311. SPECTRAL_GEN1,
  312. SPECTRAL_GEN2,
  313. SPECTRAL_GEN3,
  314. };
  315. #if ATH_PERF_PWR_OFFLOAD
  316. /**
  317. * enum target_if_spectral_info - Enumerations for specifying which spectral
  318. * information (among parameters and states)
  319. * is desired.
  320. * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active
  321. * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled
  322. * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params
  323. */
  324. enum target_if_spectral_info {
  325. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  326. TARGET_IF_SPECTRAL_INFO_ENABLED,
  327. TARGET_IF_SPECTRAL_INFO_PARAMS,
  328. };
  329. #endif /* ATH_PERF_PWR_OFFLOAD */
  330. /* forward declaration */
  331. struct target_if_spectral;
  332. /**
  333. * struct target_if_spectral_chan_info - Channel information
  334. * @center_freq1: center frequency 1 in MHz
  335. * @center_freq2: center frequency 2 in MHz -valid only for
  336. * 11ACVHT 80PLUS80 mode
  337. * @chan_width: channel width in MHz
  338. */
  339. struct target_if_spectral_chan_info {
  340. uint16_t center_freq1;
  341. uint16_t center_freq2;
  342. uint8_t chan_width;
  343. };
  344. /**
  345. * struct target_if_spectral_acs_stats - EACS stats from spectral samples
  346. * @nfc_ctl_rssi: Control chan rssi
  347. * @nfc_ext_rssi: Extension chan rssi
  348. * @ctrl_nf: Control chan Noise Floor
  349. * @ext_nf: Extension chan Noise Floor
  350. */
  351. struct target_if_spectral_acs_stats {
  352. int8_t nfc_ctl_rssi;
  353. int8_t nfc_ext_rssi;
  354. int8_t ctrl_nf;
  355. int8_t ext_nf;
  356. };
  357. /**
  358. * struct target_if_spectral_perchain_rssi_info - per chain rssi info
  359. * @rssi_pri20: Rssi of primary 20 Mhz
  360. * @rssi_sec20: Rssi of secondary 20 Mhz
  361. * @rssi_sec40: Rssi of secondary 40 Mhz
  362. * @rssi_sec80: Rssi of secondary 80 Mhz
  363. */
  364. struct target_if_spectral_perchain_rssi_info {
  365. int8_t rssi_pri20;
  366. int8_t rssi_sec20;
  367. int8_t rssi_sec40;
  368. int8_t rssi_sec80;
  369. };
  370. /**
  371. * struct target_if_spectral_rfqual_info - RF measurement information
  372. * @rssi_comb: RSSI Information
  373. * @pc_rssi_info: XXX : For now, we know we are getting information
  374. * for only 4 chains at max. For future extensions
  375. * use a define
  376. * @noise_floor: Noise floor information
  377. */
  378. struct target_if_spectral_rfqual_info {
  379. int8_t rssi_comb;
  380. struct target_if_spectral_perchain_rssi_info pc_rssi_info[4];
  381. int16_t noise_floor[4];
  382. };
  383. #define GET_TARGET_IF_SPECTRAL_OPS(spectral) \
  384. ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops)))
  385. /**
  386. * struct target_if_spectral_ops - spectral low level ops table
  387. * @get_tsf64: Get 64 bit TSF value
  388. * @get_capability: Get capability info
  389. * @set_rxfilter: Set rx filter
  390. * @get_rxfilter: Get rx filter
  391. * @is_spectral_active: Check whether icm is active
  392. * @is_spectral_enabled: Check whether spectral is enabled
  393. * @start_spectral_scan: Start spectral scan
  394. * @stop_spectral_scan: Stop spectral scan
  395. * @get_extension_channel: Get extension channel
  396. * @get_ctl_noisefloor: Get control noise floor
  397. * @get_ext_noisefloor: Get extension noise floor
  398. * @configure_spectral: Set spectral configurations
  399. * @get_spectral_config: Get spectral configurations
  400. * @get_ent_spectral_mask: Get spectral mask
  401. * @get_mac_address: Get mac address
  402. * @get_current_channel: Get current channel
  403. * @reset_hw: Reset HW
  404. * @get_chain_noise_floor: Get Channel noise floor
  405. * @spectral_process_phyerr: Process phyerr event
  406. * @process_spectral_report: Process spectral report
  407. */
  408. struct target_if_spectral_ops {
  409. uint64_t (*get_tsf64)(void *arg);
  410. uint32_t (*get_capability)(
  411. void *arg, enum spectral_capability_type type);
  412. uint32_t (*set_rxfilter)(void *arg, int rxfilter);
  413. uint32_t (*get_rxfilter)(void *arg);
  414. uint32_t (*is_spectral_active)(void *arg);
  415. uint32_t (*is_spectral_enabled)(void *arg);
  416. uint32_t (*start_spectral_scan)(void *arg);
  417. uint32_t (*stop_spectral_scan)(void *arg);
  418. uint32_t (*get_extension_channel)(void *arg);
  419. int8_t (*get_ctl_noisefloor)(void *arg);
  420. int8_t (*get_ext_noisefloor)(void *arg);
  421. uint32_t (*configure_spectral)(
  422. void *arg,
  423. struct spectral_config *params);
  424. uint32_t (*get_spectral_config)(
  425. void *arg,
  426. struct spectral_config *params);
  427. uint32_t (*get_ent_spectral_mask)(void *arg);
  428. uint32_t (*get_mac_address)(void *arg, char *addr);
  429. uint32_t (*get_current_channel)(void *arg);
  430. uint32_t (*reset_hw)(void *arg);
  431. uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf);
  432. int (*spectral_process_phyerr)(struct target_if_spectral *spectral,
  433. uint8_t *data, uint32_t datalen,
  434. struct target_if_spectral_rfqual_info *p_rfqual,
  435. struct target_if_spectral_chan_info *p_chaninfo,
  436. uint64_t tsf64,
  437. struct target_if_spectral_acs_stats *acs_stats);
  438. int (*process_spectral_report)(struct wlan_objmgr_pdev *pdev,
  439. void *payload);
  440. };
  441. /**
  442. * struct target_if_spectral_stats - spectral stats info
  443. * @num_spectral_detects: Total num. of spectral detects
  444. * @total_phy_errors: Total number of phyerrors
  445. * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets
  446. * @pri_phy_errors: Phyerrors in primary channel
  447. * @ext_phy_errors: Phyerrors in secondary channel
  448. * @dc_phy_errors: Phyerrors due to dc
  449. * @early_ext_phy_errors: Early secondary channel phyerrors
  450. * @bwinfo_errors: Bandwidth info errors
  451. * @datalen_discards: Invalid data length errors, seen in gen1 chipsets
  452. * @rssi_discards bw: Indicates reports dropped due to RSSI threshold
  453. * @last_reset_tstamp: Last reset time stamp
  454. */
  455. struct target_if_spectral_stats {
  456. uint32_t num_spectral_detects;
  457. uint32_t total_phy_errors;
  458. uint32_t owl_phy_errors;
  459. uint32_t pri_phy_errors;
  460. uint32_t ext_phy_errors;
  461. uint32_t dc_phy_errors;
  462. uint32_t early_ext_phy_errors;
  463. uint32_t bwinfo_errors;
  464. uint32_t datalen_discards;
  465. uint32_t rssi_discards;
  466. uint64_t last_reset_tstamp;
  467. };
  468. /**
  469. * struct target_if_spectral_event - spectral event structure
  470. * @se_ts: Original 15 bit recv timestamp
  471. * @se_full_ts: 64-bit full timestamp from interrupt time
  472. * @se_rssi: Rssi of spectral event
  473. * @se_bwinfo: Rssi of spectral event
  474. * @se_dur: Duration of spectral pulse
  475. * @se_chanindex: Channel of event
  476. * @se_list: List of spectral events
  477. */
  478. struct target_if_spectral_event {
  479. uint32_t se_ts;
  480. uint64_t se_full_ts;
  481. uint8_t se_rssi;
  482. uint8_t se_bwinfo;
  483. uint8_t se_dur;
  484. uint8_t se_chanindex;
  485. STAILQ_ENTRY(spectral_event) se_list;
  486. };
  487. /**
  488. * struct target_if_chain_noise_pwr_info - Noise power info for each channel
  489. * @rptcount: Count of reports in pwr array
  490. * @un_cal_nf: Uncalibrated noise floor
  491. * @factory_cal_nf: Noise floor as calibrated at the factory for module
  492. * @median_pwr: Median power (median of pwr array)
  493. * @pwr: Power reports
  494. */
  495. struct target_if_chain_noise_pwr_info {
  496. int rptcount;
  497. pwr_dbm un_cal_nf;
  498. pwr_dbm factory_cal_nf;
  499. pwr_dbm median_pwr;
  500. pwr_dbm pwr[];
  501. } __ATTRIB_PACK;
  502. /**
  503. * struct target_if_spectral_chan_stats - Channel information
  504. * @cycle_count: Cycle count
  505. * @channel_load: Channel load
  506. * @per: Period
  507. * @noisefloor: Noise floor
  508. * @comp_usablity: Computed usability
  509. * @maxregpower: Maximum allowed regulatary power
  510. * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
  511. * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz
  512. */
  513. struct target_if_spectral_chan_stats {
  514. int cycle_count;
  515. int channel_load;
  516. int per;
  517. int noisefloor;
  518. uint16_t comp_usablity;
  519. int8_t maxregpower;
  520. uint16_t comp_usablity_sec80;
  521. int8_t maxregpower_sec80;
  522. };
  523. #if ATH_PERF_PWR_OFFLOAD
  524. /**
  525. * struct target_if_spectral_cache - Cache used to minimize WMI operations
  526. * in offload architecture
  527. * @osc_spectral_enabled: Whether Spectral is enabled
  528. * @osc_spectral_active: Whether spectral is active
  529. * XXX: Ideally, we should NOT cache this
  530. * since the hardware can self clear the bit,
  531. * the firmware can possibly stop spectral due to
  532. * intermittent off-channel activity, etc
  533. * A WMI read command should be introduced to handle
  534. * this This will be discussed.
  535. * @osc_params: Spectral parameters
  536. * @osc_is_valid: Whether the cache is valid
  537. */
  538. struct target_if_spectral_cache {
  539. uint8_t osc_spectral_enabled;
  540. uint8_t osc_spectral_active;
  541. struct spectral_config osc_params;
  542. uint8_t osc_is_valid;
  543. };
  544. /**
  545. * struct target_if_spectral_param_state_info - Structure used to represent and
  546. * manage spectral information
  547. * (parameters and states)
  548. * @osps_lock: Lock to synchronize accesses to information
  549. * @osps_cache: Cacheable' information
  550. */
  551. struct target_if_spectral_param_state_info {
  552. qdf_spinlock_t osps_lock;
  553. struct target_if_spectral_cache osps_cache;
  554. /* XXX - Non-cacheable information goes here, in the future */
  555. };
  556. #endif /* ATH_PERF_PWR_OFFLOAD */
  557. struct vdev_spectral_configure_params;
  558. struct vdev_spectral_enable_params;
  559. /**
  560. * struct wmi_spectral_cmd_ops - structure used holding the operations
  561. * related to wmi commands on spectral parameters.
  562. * @wmi_spectral_configure_cmd_send:
  563. * @wmi_spectral_enable_cmd_send:
  564. */
  565. struct wmi_spectral_cmd_ops {
  566. QDF_STATUS (*wmi_spectral_configure_cmd_send)(
  567. void *wmi_hdl,
  568. struct vdev_spectral_configure_params *param);
  569. QDF_STATUS (*wmi_spectral_enable_cmd_send)(
  570. void *wmi_hdl,
  571. struct vdev_spectral_enable_params *param);
  572. };
  573. /**
  574. * struct target_if_spectral - main spectral structure
  575. * @pdev: Pointer to pdev
  576. * @spectral_ops: Target if internal Spectral low level operations table
  577. * @capability: Spectral capabilities structure
  578. * @spectral_lock: Lock used for internal Spectral operations
  579. * @spectral_curchan_radindex: Current channel spectral index
  580. * @spectral_extchan_radindex: Extension channel spectral index
  581. * @spectraldomain: Current Spectral domain
  582. * @spectral_proc_phyerr: Flags to process for PHY errors
  583. * @spectral_defaultparams: Default PHY params per Spectral stat
  584. * @spectral_stats: Spectral related stats
  585. * @events: Events structure
  586. * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel?
  587. * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI?
  588. * @sc_spectral_20_40_mode: Is AP in 20-40 mode?
  589. * @sc_spectral_noise_pwr_cal: Noise power cal required?
  590. * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA?
  591. * @upper_is_control: Upper segment is primary
  592. * @upper_is_extension: Upper segment is secondary
  593. * @lower_is_control: Lower segment is primary
  594. * @lower_is_extension: Lower segment is secondary
  595. * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral
  596. * mute test
  597. * @spectral_numbins: Number of bins
  598. * @spectral_fft_len: FFT length
  599. * @spectral_data_len: Total phyerror report length
  600. * @lb_edge_extrabins: Number of extra bins on left band edge
  601. * @rb_edge_extrabins: Number of extra bins on right band edge
  602. * @spectral_max_index_offset: Max FFT index offset (20 MHz mode)
  603. * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode)
  604. * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode)
  605. * @spectral_dc_index: At which index DC is present
  606. * @send_single_packet: Deprecated
  607. * @spectral_sent_msg: Indicates whether we send report to upper layers
  608. * @params: Spectral parameters
  609. * @last_capture_time: Indicates timestamp of previouse report
  610. * @num_spectral_data: Number of Spectral samples received in current session
  611. * @total_spectral_data: Total number of Spectral samples received
  612. * @max_rssi: Maximum RSSI
  613. * @detects_control_channel: NA
  614. * @detects_extension_channel: NA
  615. * @detects_below_dc: NA
  616. * @detects_above_dc: NA
  617. * @sc_scanning: Indicates active wifi scan
  618. * @sc_spectral_scan: Indicates active specral scan
  619. * @sc_spectral_full_scan: Deprecated
  620. * @scan_start_tstamp: Deprecated
  621. * @last_tstamp: Deprecated
  622. * @first_tstamp: Deprecated
  623. * @spectral_samp_count: Deprecated
  624. * @sc_spectral_samp_count: Deprecated
  625. * @noise_pwr_reports_reqd: Number of noise power reports required
  626. * @noise_pwr_reports_recv: Number of noise power reports received
  627. * @noise_pwr_reports_lock: Lock used for Noise power report processing
  628. * @noise_pwr_chain_ctl: Noise power report - control channel
  629. * @noise_pwr_chain_ext: Noise power report - extension channel
  630. * @chaninfo: Channel statistics
  631. * @tsf64: Latest TSF Value
  632. * @param_info: Offload architecture Spectral parameter cache information
  633. * @ch_width: Indicates Channel Width 20/40/80/160 MHz with values 0, 1, 2, 3
  634. * respectively
  635. * @diag_stats: Diagnostic statistics
  636. * @is_160_format: Indicates whether information provided by HW is in altered
  637. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  638. * @is_lb_edge_extrabins_format: Indicates whether information provided by
  639. * HW has 4 extra bins, at left band edge, for report mode 2
  640. * @is_rb_edge_extrabins_format: Indicates whether information provided
  641. * by HW has 4 extra bins, at right band edge, for report mode 2
  642. * @is_sec80_rssi_war_required: Indicates whether the software workaround is
  643. * required to obtain approximate combined RSSI for secondary 80Mhz segment
  644. * @simctx: Spectral Simulation context
  645. * @spectral_gen: Spectral hardware generation
  646. * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware
  647. * generation
  648. * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV
  649. * header, for the given hardware generation
  650. * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV
  651. * header, for the given hardware generation
  652. * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
  653. * generation
  654. * @nl_cb: Netlink callbacks
  655. * @use_nl_bcast: Whether to use Netlink broadcast/unicast
  656. * @send_phy_data: Send data to the applicaton layer
  657. * @inband_fftbin_size_adj: Whether to carry out FFT bin size adjustment for
  658. * in-band report format. This would be required on some chipsets under the
  659. * following circumstances: In report mode 2 only the in-band bins are DMA'ed.
  660. * Scatter/gather is used. However, the HW generates all bins, not just in-band,
  661. * and reports the number of bins accordingly. The subsystem arranging for the
  662. * DMA cannot change this value. On such chipsets the adjustment required at the
  663. * host driver is to check if report format is 2, and if so halve the number of
  664. * bins reported to get the number actually DMA'ed.
  665. */
  666. struct target_if_spectral {
  667. struct wlan_objmgr_pdev *pdev_obj;
  668. struct target_if_spectral_ops spectral_ops;
  669. struct spectral_caps capability;
  670. qdf_spinlock_t spectral_lock;
  671. int16_t spectral_curchan_radindex;
  672. int16_t spectral_extchan_radindex;
  673. uint32_t spectraldomain;
  674. uint32_t spectral_proc_phyerr;
  675. struct spectral_config spectral_defaultparams;
  676. struct target_if_spectral_stats spectral_stats;
  677. struct target_if_spectral_event *events;
  678. unsigned int sc_spectral_ext_chan_ok:1,
  679. sc_spectral_combined_rssi_ok:1,
  680. sc_spectral_20_40_mode:1,
  681. sc_spectral_noise_pwr_cal:1,
  682. sc_spectral_non_edma:1;
  683. int upper_is_control;
  684. int upper_is_extension;
  685. int lower_is_control;
  686. int lower_is_extension;
  687. uint8_t sc_spectraltest_ieeechan;
  688. int spectral_numbins;
  689. int spectral_fft_len;
  690. int spectral_data_len;
  691. /*
  692. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  693. * delivered. However, there can be additional bins reported for
  694. * AR900B version 2.0 and QCA9984 as described next:
  695. *
  696. * AR900B version 2.0: An additional tone is processed on the right
  697. * hand side in order to facilitate detection of radar pulses out to
  698. * the extreme band-edge of the channel frequency. Since the HW design
  699. * processes four tones at a time, this requires one additional Dword
  700. * to be added to the search FFT report.
  701. *
  702. * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary +
  703. * 1x-oversampled bins (in-band) per FFT, then 8 more bins
  704. * (4 more on left side and 4 more on right side)are added.
  705. */
  706. int lb_edge_extrabins;
  707. int rb_edge_extrabins;
  708. int spectral_max_index_offset;
  709. int spectral_upper_max_index_offset;
  710. int spectral_lower_max_index_offset;
  711. int spectral_dc_index;
  712. int send_single_packet;
  713. int spectral_sent_msg;
  714. int classify_scan;
  715. os_timer_t classify_timer;
  716. struct spectral_config params;
  717. struct spectral_classifier_params classifier_params;
  718. int last_capture_time;
  719. int num_spectral_data;
  720. int total_spectral_data;
  721. int max_rssi;
  722. int detects_control_channel;
  723. int detects_extension_channel;
  724. int detects_below_dc;
  725. int detects_above_dc;
  726. int sc_scanning;
  727. int sc_spectral_scan;
  728. int sc_spectral_full_scan;
  729. uint64_t scan_start_tstamp;
  730. uint32_t last_tstamp;
  731. uint32_t first_tstamp;
  732. uint32_t spectral_samp_count;
  733. uint32_t sc_spectral_samp_count;
  734. int noise_pwr_reports_reqd;
  735. int noise_pwr_reports_recv;
  736. qdf_spinlock_t noise_pwr_reports_lock;
  737. struct target_if_chain_noise_pwr_info
  738. *noise_pwr_chain_ctl[HOST_MAX_ANTENNA];
  739. struct target_if_chain_noise_pwr_info
  740. *noise_pwr_chain_ext[HOST_MAX_ANTENNA];
  741. uint64_t tsf64;
  742. #if ATH_PERF_PWR_OFFLOAD
  743. struct target_if_spectral_param_state_info param_info;
  744. #endif
  745. uint32_t ch_width;
  746. struct spectral_diag_stats diag_stats;
  747. bool is_160_format;
  748. bool is_lb_edge_extrabins_format;
  749. bool is_rb_edge_extrabins_format;
  750. bool is_sec80_rssi_war_required;
  751. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  752. void *simctx;
  753. #endif
  754. enum spectral_gen spectral_gen;
  755. uint8_t hdr_sig_exp;
  756. uint8_t tag_sscan_summary_exp;
  757. uint8_t tag_sscan_fft_exp;
  758. uint8_t tlvhdr_size;
  759. struct wmi_spectral_cmd_ops param_wmi_cmd_ops;
  760. struct spectral_nl_cb nl_cb;
  761. bool use_nl_bcast;
  762. int (*send_phy_data)(struct wlan_objmgr_pdev *pdev);
  763. u_int8_t fftbin_size_war;
  764. u_int8_t inband_fftbin_size_adj;
  765. };
  766. /**
  767. * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol
  768. * data format
  769. * @rssi: RSSI (except for secondary 80 segment)
  770. * @rssi_sec80: RSSI for secondary 80 segment
  771. * @lower_rssi: RSSI of lower band
  772. * @upper_rssi: RSSI of upper band
  773. * @chain_ctl_rssi: RSSI for control channel, for all antennas
  774. * @chain_ext_rssi: RSSI for extension channel, for all antennas
  775. * @bwinfo: bandwidth info
  776. * @data_len: length of FFT data (except for secondary 80 segment)
  777. * @data_len_sec80: length of FFT data for secondary 80 segment
  778. * @tstamp: timestamp
  779. * @last_tstamp: last time stamp
  780. * @max_mag: maximum magnitude (except for secondary 80 segment)
  781. * @max_mag_sec80: maximum magnitude for secondary 80 segment
  782. * @max_index: index of max magnitude (except for secondary 80 segment)
  783. * @max_index_sec80: index of max magnitude for secondary 80 segment
  784. * @max_exp: max exp
  785. * @peak: peak frequency (obsolete)
  786. * @pwr_count: number of FFT bins (except for secondary 80 segment)
  787. * @pwr_count_sec80: number of FFT bins in secondary 80 segment
  788. * @nb_lower: This is deprecated
  789. * @nb_upper: This is deprecated
  790. * @max_upper_index: index of max mag in upper band
  791. * @max_lower_index: index of max mag in lower band
  792. * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment)
  793. * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment
  794. * @freq: Center frequency of primary 20MHz channel in MHz
  795. * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz
  796. * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz
  797. * @freq_loading: spectral control duty cycles
  798. * @noise_floor: current noise floor (except for secondary 80 segment)
  799. * @noise_floor_sec80: current noise floor for secondary 80 segment
  800. * @interf_list: List of interfernce sources
  801. * @classifier_params: classifier parameters
  802. * @sc: classifier parameters
  803. */
  804. struct target_if_samp_msg_params {
  805. int8_t rssi;
  806. int8_t rssi_sec80;
  807. int8_t lower_rssi;
  808. int8_t upper_rssi;
  809. int8_t chain_ctl_rssi[HOST_MAX_ANTENNA];
  810. int8_t chain_ext_rssi[HOST_MAX_ANTENNA];
  811. uint16_t bwinfo;
  812. uint16_t datalen;
  813. uint16_t datalen_sec80;
  814. uint32_t tstamp;
  815. uint32_t last_tstamp;
  816. uint16_t max_mag;
  817. uint16_t max_mag_sec80;
  818. uint16_t max_index;
  819. uint16_t max_index_sec80;
  820. uint8_t max_exp;
  821. int peak;
  822. int pwr_count;
  823. int pwr_count_sec80;
  824. int8_t nb_lower;
  825. int8_t nb_upper;
  826. uint16_t max_lower_index;
  827. uint16_t max_upper_index;
  828. uint8_t *bin_pwr_data;
  829. uint8_t *bin_pwr_data_sec80;
  830. uint16_t freq;
  831. uint16_t vhtop_ch_freq_seg1;
  832. uint16_t vhtop_ch_freq_seg2;
  833. uint16_t freq_loading;
  834. int16_t noise_floor;
  835. int16_t noise_floor_sec80;
  836. struct interf_src_rsp interf_list;
  837. struct spectral_classifier_params classifier_params;
  838. struct ath_softc *sc;
  839. };
  840. #ifdef WLAN_CONV_SPECTRAL_ENABLE
  841. /**
  842. * target_if_spectral_dump_fft() - Dump Spectral FFT
  843. * @pfft: Pointer to Spectral Phyerr FFT
  844. * @fftlen: FFT length
  845. *
  846. * Return: Success or failure
  847. */
  848. int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen);
  849. /**
  850. * target_if_dbg_print_samp_param() - Print contents of SAMP struct
  851. * @p: Pointer to SAMP message
  852. *
  853. * Return: Void
  854. */
  855. void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p);
  856. /**
  857. * target_if_get_offset_swar_sec80() - Get offset for SWAR according to
  858. * the channel width
  859. * @channel_width: Channel width
  860. *
  861. * Return: Offset for SWAR
  862. */
  863. uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
  864. /**
  865. * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops
  866. * @tx_ops: Tx Ops
  867. *
  868. * Return: void
  869. */
  870. void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
  871. /**
  872. * target_if_spectral_create_samp_msg() - Create the spectral samp message
  873. * @spectral : Pointer to spectral internal structure
  874. * @params : spectral samp message parameters
  875. *
  876. * API to create the spectral samp message
  877. *
  878. * Return: void
  879. */
  880. void target_if_spectral_create_samp_msg(
  881. struct target_if_spectral *spectral,
  882. struct target_if_samp_msg_params *params);
  883. /**
  884. * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3
  885. * @pdev: Pointer to pdev object
  886. * @payload: Pointer to spectral report
  887. *
  888. * Process phyerror event for gen3
  889. *
  890. * Return: Success/Failure
  891. */
  892. int target_if_spectral_process_report_gen3(
  893. struct wlan_objmgr_pdev *pdev,
  894. void *buf);
  895. /**
  896. * target_if_process_phyerr_gen2() - Process PHY Error for gen2
  897. * @spectral: Pointer to Spectral object
  898. * @data: Pointer to phyerror event buffer
  899. * @datalen: Data length
  900. * @p_rfqual: RF quality info
  901. * @p_chaninfo: Channel info
  902. * @tsf64: 64 bit tsf timestamp
  903. * @acs_stats: ACS stats
  904. *
  905. * Process PHY Error for gen2
  906. *
  907. * Return: Success/Failure
  908. */
  909. int target_if_process_phyerr_gen2(
  910. struct target_if_spectral *spectral,
  911. uint8_t *data,
  912. uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
  913. struct target_if_spectral_chan_info *p_chaninfo,
  914. uint64_t tsf64,
  915. struct target_if_spectral_acs_stats *acs_stats);
  916. /**
  917. * target_if_spectral_send_intf_found_msg() - Indicate to application layer that
  918. * interference has been found
  919. * @pdev: Pointer to pdev
  920. * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found
  921. * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled
  922. *
  923. * Send message to application layer
  924. * indicating that interference has been found
  925. *
  926. * Return: None
  927. */
  928. void target_if_spectral_send_intf_found_msg(
  929. struct wlan_objmgr_pdev *pdev,
  930. uint16_t cw_int, uint32_t dcs_enabled);
  931. /**
  932. * target_if_stop_spectral_scan() - Stop spectral scan
  933. * @pdev: Pointer to pdev object
  934. *
  935. * API to stop the current on-going spectral scan
  936. *
  937. * Return: None
  938. */
  939. void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev);
  940. /**
  941. * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral
  942. * operations
  943. * @spectral: Pointer to Spectral target_if internal private data
  944. *
  945. * Spectral operates on pdev. However, in order to retrieve some WLAN
  946. * properties, a vdev is required. To facilitate this, the function returns the
  947. * first vdev in our pdev. The caller should release the reference to the vdev
  948. * once it is done using it.
  949. * TODO: If the framework later provides an API to obtain the first active
  950. * vdev, then it would be preferable to use this API.
  951. *
  952. * Return: Pointer to vdev on success, NULL on failure
  953. */
  954. struct wlan_objmgr_vdev *target_if_spectral_get_vdev(
  955. struct target_if_spectral *spectral);
  956. /**
  957. * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2
  958. * @phdr: Pointer to Spectral Phyerr Header
  959. *
  960. * Dump Spectral header
  961. *
  962. * Return: Success/Failure
  963. */
  964. int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr);
  965. /**
  966. * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI
  967. * for Secondary 80 segment
  968. * @spectral: Pointer to spectral object
  969. * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment
  970. *
  971. * Get approximate combined RSSI for Secondary 80 segment
  972. *
  973. * Return: Combined RSSI for secondary 80Mhz segment
  974. */
  975. int8_t target_if_get_combrssi_sec80_seg_gen2(
  976. struct target_if_spectral *spectral,
  977. struct spectral_search_fft_info_gen2 *p_sfft_sec80);
  978. /**
  979. * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2
  980. * @ptlv: Pointer to Spectral Phyerr TLV
  981. * @is_160_format: Indicates 160 format
  982. *
  983. * Dump Spectral TLV for gen2
  984. *
  985. * Return: Success/Failure
  986. */
  987. int target_if_spectral_dump_tlv_gen2(
  988. struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format);
  989. /**
  990. * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral
  991. * related PHY Error for gen2
  992. * @data: Pointer to phyerror buffer
  993. * @datalen: Data length
  994. * @is_160_format: Indicates 160 format
  995. *
  996. * Dump Spectral related PHY Error for gen2
  997. *
  998. * Return: Success/Failure
  999. */
  1000. int target_if_spectral_dump_phyerr_data_gen2(
  1001. uint8_t *data,
  1002. uint32_t datalen,
  1003. bool is_160_format);
  1004. /**
  1005. * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3
  1006. * @spectral: Pointer to Spectral object
  1007. * @p_fft_report: Pointer to fft report
  1008. * @p_sfft: Pointer to search fft report
  1009. *
  1010. * Dump FFT Report for gen3
  1011. *
  1012. * Return: Success/Failure
  1013. */
  1014. int target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
  1015. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1016. struct spectral_search_fft_info_gen3 *p_sfft);
  1017. /**
  1018. * target_if_dbg_print_samp_msg() - Print contents of SAMP Message
  1019. * @p: Pointer to SAMP message
  1020. *
  1021. * Print contents of SAMP Message
  1022. *
  1023. * Return: Void
  1024. */
  1025. void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg);
  1026. /**
  1027. * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3
  1028. * @p_fft_report: Pointer to fft report
  1029. * @p_sfft: Pointer to search fft report
  1030. *
  1031. * Process Search FFT Report for gen3
  1032. *
  1033. * Return: Success/Failure
  1034. */
  1035. int target_if_process_sfft_report_gen3(
  1036. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1037. struct spectral_search_fft_info_gen3 *p_fft_info);
  1038. /**
  1039. * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
  1040. * Spectral data
  1041. * @pdev: Pointer to pdev
  1042. *
  1043. * Return: Handle to target_if internal Spectral data on success, NULL on
  1044. * failure
  1045. */
  1046. static inline
  1047. struct target_if_spectral *get_target_if_spectral_handle_from_pdev(
  1048. struct wlan_objmgr_pdev *pdev)
  1049. {
  1050. struct target_if_spectral *spectral = NULL;
  1051. struct wlan_objmgr_psoc *psoc = NULL;
  1052. psoc = wlan_pdev_get_psoc(pdev);
  1053. spectral = (struct target_if_spectral *)
  1054. psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_target_handle(
  1055. pdev);
  1056. return spectral;
  1057. }
  1058. /**
  1059. * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a
  1060. * given vdev
  1061. * @pdev: Pointer to vdev
  1062. *
  1063. * Get the operating channel frequency of a given vdev
  1064. *
  1065. * Return: Operating channel frequency of a vdev
  1066. */
  1067. static inline
  1068. int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev)
  1069. {
  1070. struct wlan_objmgr_psoc *psoc = NULL;
  1071. psoc = wlan_vdev_get_psoc(vdev);
  1072. if (!psoc) {
  1073. spectral_err("psoc is NULL");
  1074. return -EINVAL;
  1075. }
  1076. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_chan_freq(
  1077. vdev);
  1078. }
  1079. /**
  1080. * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a
  1081. * given vdev
  1082. * @pdev: Pointer to vdev
  1083. *
  1084. * Get the operating channel bandwidth of a given vdev
  1085. *
  1086. * Return: channel bandwidth enumeration corresponding to the vdev
  1087. */
  1088. static inline
  1089. enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev)
  1090. {
  1091. struct wlan_objmgr_psoc *psoc = NULL;
  1092. psoc = wlan_vdev_get_psoc(vdev);
  1093. if (!psoc) {
  1094. spectral_err("psoc is NULL");
  1095. return CH_WIDTH_INVALID;
  1096. }
  1097. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_ch_width(
  1098. vdev);
  1099. }
  1100. /**
  1101. * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary
  1102. * 20 MHz channel for a given vdev
  1103. * @pdev: Pointer to vdev
  1104. *
  1105. * Get the frequency of secondary 20Mhz channel for a given vdev
  1106. *
  1107. * Return: Frequency of secondary 20Mhz channel for a given vdev
  1108. */
  1109. static inline
  1110. int target_if_vdev_get_sec20chan_freq_mhz(
  1111. struct wlan_objmgr_vdev *vdev,
  1112. uint16_t *sec20chan_freq)
  1113. {
  1114. struct wlan_objmgr_psoc *psoc = NULL;
  1115. psoc = wlan_vdev_get_psoc(vdev);
  1116. if (!psoc) {
  1117. spectral_err("psoc is NULL");
  1118. return -EINVAL;
  1119. }
  1120. return psoc->soc_cb.rx_ops.sptrl_rx_ops.
  1121. sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq);
  1122. }
  1123. /**
  1124. * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask
  1125. * @pdev: Pointer to pdev
  1126. * @spectral_rx_chainmask: Spectral Rx chainmask
  1127. *
  1128. * Return: None
  1129. */
  1130. static inline
  1131. void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev,
  1132. uint8_t spectral_rx_chainmask)
  1133. {
  1134. struct target_if_spectral *spectral = NULL;
  1135. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1136. spectral->params.ss_chn_mask = spectral_rx_chainmask;
  1137. }
  1138. /**
  1139. * target_if_spectral_process_phyerr() - Process Spectral PHY error
  1140. * @pdev: Pointer to pdev
  1141. * @data: PHY error data received from FW
  1142. * @datalen: Length of data
  1143. * @p_rfqual: Pointer to RF Quality information
  1144. * @p_chaninfo: Pointer to channel information
  1145. * @tsf: TSF time instance at which the Spectral sample was received
  1146. * @acs_stats: ACS stats
  1147. *
  1148. * Process Spectral PHY error by extracting necessary information from the data
  1149. * sent by FW, and send the extracted information to application layer.
  1150. *
  1151. * Return: None
  1152. */
  1153. static inline
  1154. void target_if_spectral_process_phyerr(
  1155. struct wlan_objmgr_pdev *pdev,
  1156. uint8_t *data, uint32_t datalen,
  1157. struct target_if_spectral_rfqual_info *p_rfqual,
  1158. struct target_if_spectral_chan_info *p_chaninfo,
  1159. uint64_t tsf64,
  1160. struct target_if_spectral_acs_stats *acs_stats)
  1161. {
  1162. struct target_if_spectral *spectral = NULL;
  1163. struct target_if_spectral_ops *p_sops = NULL;
  1164. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1165. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1166. p_sops->spectral_process_phyerr(spectral, data, datalen,
  1167. p_rfqual, p_chaninfo,
  1168. tsf64, acs_stats);
  1169. }
  1170. /**
  1171. * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled
  1172. * @arg: Pointer to handle for Spectral target_if internal private data
  1173. *
  1174. * Function to check whether Spectral is enabled
  1175. *
  1176. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1177. */
  1178. uint32_t target_if_sops_is_spectral_enabled(void *arg);
  1179. /**
  1180. * target_if_sops_is_spectral_active() - Get whether Spectral is active
  1181. * @arg: Pointer to handle for Spectral target_if internal private data
  1182. *
  1183. * Function to check whether Spectral is active
  1184. *
  1185. * Return: True if Spectral is active, false if Spectral is not active
  1186. */
  1187. uint32_t target_if_sops_is_spectral_active(void *arg);
  1188. /**
  1189. * target_if_sops_start_spectral_scan() - Start Spectral scan
  1190. * @arg: Pointer to handle for Spectral target_if internal private data
  1191. *
  1192. * Function to start spectral scan
  1193. *
  1194. * Return: 0 on success else failure
  1195. */
  1196. uint32_t target_if_sops_start_spectral_scan(void *arg);
  1197. /**
  1198. * target_if_sops_stop_spectral_scan() - Stop Spectral scan
  1199. * @arg: Pointer to handle for Spectral target_if internal private data
  1200. *
  1201. * Function to stop spectral scan
  1202. *
  1203. * Return: 0 in case of success, -1 on failure
  1204. */
  1205. uint32_t target_if_sops_stop_spectral_scan(void *arg);
  1206. /**
  1207. * target_if_spectral_get_extension_channel() - Get the current Extension
  1208. * channel (in MHz)
  1209. * @arg: Pointer to handle for Spectral target_if internal private data
  1210. *
  1211. * Return: Current Extension channel (in MHz) on success, 0 on failure or if
  1212. * extension channel is not present.
  1213. */
  1214. uint32_t target_if_spectral_get_extension_channel(void *arg);
  1215. /**
  1216. * target_if_spectral_get_current_channel() - Get the current channel (in MHz)
  1217. * @arg: Pointer to handle for Spectral target_if internal private data
  1218. *
  1219. * Return: Current channel (in MHz) on success, 0 on failure
  1220. */
  1221. uint32_t target_if_spectral_get_current_channel(void *arg);
  1222. /**
  1223. * target_if_spectral_reset_hw() - Reset the hardware
  1224. * @arg: Pointer to handle for Spectral target_if internal private data
  1225. *
  1226. * This is only a placeholder since it is not currently required in the offload
  1227. * case.
  1228. *
  1229. * Return: 0
  1230. */
  1231. uint32_t target_if_spectral_reset_hw(void *arg);
  1232. /**
  1233. * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
  1234. * Noisefloor history buffer
  1235. * @arg: Pointer to handle for Spectral target_if internal private data
  1236. * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
  1237. *
  1238. * This is only a placeholder since it is not currently required in the offload
  1239. * case.
  1240. *
  1241. * Return: 0
  1242. */
  1243. uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf);
  1244. /**
  1245. * target_if_spectral_get_ext_noisefloor() - Get the extension channel
  1246. * noisefloor
  1247. * @arg: Pointer to handle for Spectral target_if internal private data
  1248. *
  1249. * This is only a placeholder since it is not currently required in the offload
  1250. * case.
  1251. *
  1252. * Return: 0
  1253. */
  1254. int8_t target_if_spectral_get_ext_noisefloor(void *arg);
  1255. /**
  1256. * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
  1257. * @arg: Pointer to handle for Spectral target_if internal private data
  1258. *
  1259. * This is only a placeholder since it is not currently required in the offload
  1260. * case.
  1261. *
  1262. * Return: 0
  1263. */
  1264. int8_t target_if_spectral_get_ctl_noisefloor(void *arg);
  1265. /**
  1266. * target_if_spectral_get_capability() - Get whether a given Spectral hardware
  1267. * capability is available
  1268. * @arg: Pointer to handle for Spectral target_if internal private data
  1269. * @type: Spectral hardware capability type
  1270. *
  1271. * Return: True if the capability is available, false if the capability is not
  1272. * available
  1273. */
  1274. uint32_t target_if_spectral_get_capability(
  1275. void *arg, enum spectral_capability_type type);
  1276. /**
  1277. * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
  1278. * @arg: Pointer to handle for Spectral target_if internal private data
  1279. * @rxfilter: Rx filter to be used
  1280. *
  1281. * Note: This is only a placeholder function. It is not currently required since
  1282. * FW should be taking care of setting the required filters.
  1283. *
  1284. * Return: 0
  1285. */
  1286. uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter);
  1287. /**
  1288. * target_if_spectral_sops_configure_params() - Configure user supplied Spectral
  1289. * parameters
  1290. * @arg: Pointer to handle for Spectral target_if internal private data
  1291. * @params: Spectral parameters
  1292. *
  1293. * Return: 0 in case of success, -1 on failure
  1294. */
  1295. uint32_t target_if_spectral_sops_configure_params(
  1296. void *arg, struct spectral_config *params);
  1297. /**
  1298. * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
  1299. * @arg: Pointer to handle for Spectral target_if internal private data
  1300. *
  1301. * Note: This is only a placeholder function. It is not currently required since
  1302. * FW should be taking care of setting the required filters.
  1303. *
  1304. * Return: 0
  1305. */
  1306. uint32_t target_if_spectral_get_rxfilter(void *arg);
  1307. /**
  1308. * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
  1309. * functionality for the given pdev
  1310. * @pdev: Pointer to pdev object
  1311. *
  1312. * Return: None
  1313. */
  1314. void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
  1315. /**
  1316. * target_if_set_spectral_config() - Set spectral config
  1317. * @pdev: Pointer to pdev object
  1318. * @threshtype: config type
  1319. * @value: config value
  1320. *
  1321. * API to set spectral configurations
  1322. *
  1323. * Return: 0 in case of success, -1 on failure
  1324. */
  1325. int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
  1326. const uint32_t threshtype,
  1327. const uint32_t value);
  1328. /**
  1329. * target_if_pdev_spectral_init() - Initialize target_if Spectral
  1330. * functionality for the given pdev
  1331. * @pdev: Pointer to pdev object
  1332. *
  1333. * Return: On success, pointer to Spectral target_if internal private data, on
  1334. * failure, NULL
  1335. */
  1336. void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
  1337. /**
  1338. * target_if_spectral_sops_get_params() - Get user configured Spectral
  1339. * parameters
  1340. * @arg: Pointer to handle for Spectral target_if internal private data
  1341. * @params: Pointer to buffer into which Spectral parameters should be copied
  1342. *
  1343. * Return: 0 in case of success, -1 on failure
  1344. */
  1345. uint32_t target_if_spectral_sops_get_params(
  1346. void *arg, struct spectral_config *params);
  1347. /**
  1348. * target_if_init_spectral_capability() - Initialize Spectral capability
  1349. * @spectral: Pointer to Spectral target_if internal private data
  1350. *
  1351. * This is a workaround.
  1352. *
  1353. * Return: None
  1354. */
  1355. void target_if_init_spectral_capability(struct target_if_spectral *spectral);
  1356. /**
  1357. * target_if_start_spectral_scan() - Start spectral scan
  1358. * @pdev: Pointer to pdev object
  1359. *
  1360. * API to start spectral scan
  1361. *
  1362. * Return: 0 in case of success, -1 on failure
  1363. */
  1364. int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev);
  1365. /**
  1366. * target_if_get_spectral_config() - Get spectral configuration
  1367. * @pdev: Pointer to pdev object
  1368. * @param: Pointer to spectral_config structure in which the configuration
  1369. * should be returned
  1370. *
  1371. * API to get the current spectral configuration
  1372. *
  1373. * Return: 0 in case of success, -1 on failure
  1374. */
  1375. void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
  1376. struct spectral_config *param);
  1377. /**
  1378. * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
  1379. * parameters
  1380. * @spectral: Pointer to Spectral target_if internal private data
  1381. * @spectral_params: Pointer to Spectral parameters
  1382. *
  1383. * Enable use of desired Spectral parameters by configuring them into HW, and
  1384. * starting Spectral scan
  1385. *
  1386. * Return: 0 on success, 1 on failure
  1387. */
  1388. int target_if_spectral_scan_enable_params(
  1389. struct target_if_spectral *spectral, struct spectral_config *spectral_params);
  1390. /**
  1391. * target_if_is_spectral_active() - Get whether Spectral is active
  1392. * @pdev: Pointer to pdev object
  1393. *
  1394. * Return: True if Spectral is active, false if Spectral is not active
  1395. */
  1396. bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev);
  1397. /**
  1398. * target_if_is_spectral_enabled() - Get whether Spectral is enabled
  1399. * @pdev: Pointer to pdev object
  1400. *
  1401. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1402. */
  1403. bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev);
  1404. /**
  1405. * target_if_set_debug_level() - Set debug level for Spectral
  1406. * @pdev: Pointer to pdev object
  1407. * @debug_level: Debug level
  1408. *
  1409. * Return: 0 in case of success
  1410. */
  1411. int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev,
  1412. uint32_t debug_level);
  1413. /**
  1414. * target_if_get_debug_level() - Get debug level for Spectral
  1415. * @pdev: Pointer to pdev object
  1416. *
  1417. * Return: Current debug level
  1418. */
  1419. uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev);
  1420. /**
  1421. * target_if_get_spectral_capinfo() - Get Spectral capability information
  1422. * @pdev: Pointer to pdev object
  1423. * @outdata: Buffer into which data should be copied
  1424. *
  1425. * Return: void
  1426. */
  1427. void target_if_get_spectral_capinfo(
  1428. struct wlan_objmgr_pdev *pdev,
  1429. void *outdata);
  1430. /**
  1431. * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
  1432. * @pdev: Pointer to pdev object
  1433. * @outdata: Buffer into which data should be copied
  1434. *
  1435. * Return: void
  1436. */
  1437. void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
  1438. void *outdata);
  1439. /*
  1440. * target_if_spectral_send_tlv_to_host - target_if_spectral_send_tlv_to_host
  1441. * @spectral: Send the TLV information to Host
  1442. * @data: Pointer to the TLV
  1443. * @datalen: tlv length
  1444. *
  1445. * Return: Success/Failure
  1446. *
  1447. */
  1448. int target_if_spectral_send_tlv_to_host(
  1449. struct target_if_spectral *spectral,
  1450. uint8_t *data, uint32_t datalen);
  1451. void target_if_register_wmi_spectral_cmd_ops(
  1452. struct wlan_objmgr_pdev *pdev,
  1453. struct wmi_spectral_cmd_ops *cmd_ops);
  1454. #ifdef DIRECT_BUF_RX_ENABLE
  1455. /**
  1456. * target_if_consume_sfft_report_gen3() - Process fft report for gen3
  1457. * @spectral: Pointer to spectral object
  1458. * @report: Pointer to spectral report
  1459. *
  1460. * Process fft report for gen3
  1461. *
  1462. * Return: Success/Failure
  1463. */
  1464. int
  1465. target_if_consume_spectral_report_gen3(
  1466. struct target_if_spectral *spectral,
  1467. struct spectral_report *report);
  1468. #endif
  1469. #ifdef WIN32
  1470. #pragma pack(pop, target_if_spectral)
  1471. #endif
  1472. #ifdef __ATTRIB_PACK
  1473. #undef __ATTRIB_PACK
  1474. #endif
  1475. #endif /* WLAN_CONV_SPECTRAL_ENABLE */
  1476. #endif /* _TARGET_IF_SPECTRAL_H_ */