target_if_spectral.h 61 KB

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