target_if_spectral.h 61 KB

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