target_if_spectral.h 77 KB

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