target_if_spectral.h 91 KB

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