target_if_spectral.h 62 KB

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