target_if_spectral.h 62 KB

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