target_if_spectral.h 75 KB

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