target_if_spectral.h 81 KB

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