target_if_spectral.h 73 KB

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