target_if_spectral.h 73 KB

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