target_if_spectral.h 106 KB

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