target_if_spectral.h 85 KB

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