target_if_spectral.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857
  1. /*
  2. * Copyright (c) 2011,2017-2018 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. #define STATUS_PASS 1
  41. #define STATUS_FAIL 0
  42. #undef spectral_dbg_line
  43. #define spectral_dbg_line() \
  44. spectral_debug("----------------------------------------------------")
  45. #undef spectral_ops_not_registered
  46. #define spectral_ops_not_registered(str) \
  47. spectral_info("SPECTRAL : %s not registered\n", (str))
  48. #undef not_yet_implemented
  49. #define not_yet_implemented() \
  50. spectral_info("SPECTRAL : %s : %d Not yet implemented\n", \
  51. __func__, __LINE__)
  52. #define SPECTRAL_HT20_NUM_BINS 56
  53. #define SPECTRAL_HT20_FFT_LEN 56
  54. #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2)
  55. #define SPECTRAL_HT20_DATA_LEN 60
  56. #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3)
  57. #define SPECTRAL_HT40_TOTAL_NUM_BINS 128
  58. #define SPECTRAL_HT40_DATA_LEN 135
  59. #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3)
  60. #define SPECTRAL_HT40_FFT_LEN 128
  61. #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2)
  62. /*
  63. * Used for the SWAR to obtain approximate combined rssi
  64. * in secondary 80Mhz segment
  65. */
  66. #define OFFSET_CH_WIDTH_20 65
  67. #define OFFSET_CH_WIDTH_40 62
  68. #define OFFSET_CH_WIDTH_80 56
  69. #define OFFSET_CH_WIDTH_160 50
  70. #ifdef BIG_ENDIAN_HOST
  71. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \
  72. int j; \
  73. uint32_t *src, *dest; \
  74. src = (uint32_t *)(srcp); \
  75. dest = (uint32_t *)(destp); \
  76. for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \
  77. *(dest + j) = qdf_le32_to_cpu(*(src + j)); \
  78. } \
  79. } while (0)
  80. #else
  81. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \
  82. OS_MEMCPY((destp), (srcp), (len));
  83. #endif
  84. #define DUMMY_NF_VALUE (-123)
  85. /* 5 categories x (lower + upper) bands */
  86. #define MAX_INTERF 10
  87. #define HOST_MAX_ANTENNA 3
  88. /* Mask for time stamp from descriptor */
  89. #define SPECTRAL_TSMASK 0xFFFFFFFF
  90. #define SPECTRAL_SIGNATURE 0xdeadbeef
  91. /* START of spectral GEN II HW specific details */
  92. #define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb
  93. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2 0xF9
  94. #define TLV_TAG_ADC_REPORT_GEN2 0xFA
  95. #define TLV_TAG_SEARCH_FFT_REPORT_GEN2 0xFB
  96. /**
  97. * enum spectral_160mhz_report_delivery_state - 160 MHz state machine states
  98. * @SPECTRAL_REPORT_WAIT_PRIMARY80: Wait for primary80 report
  99. * @SPECTRAL_REPORT_RX_PRIMARY80: Receive primary 80 report
  100. * @SPECTRAL_REPORT_WAIT_SECONDARY80: Wait for secondory 80 report
  101. * @SPECTRAL_REPORT_RX_SECONDARY80: Receive secondary 80 report
  102. */
  103. enum spectral_160mhz_report_delivery_state {
  104. SPECTRAL_REPORT_WAIT_PRIMARY80,
  105. SPECTRAL_REPORT_RX_PRIMARY80,
  106. SPECTRAL_REPORT_WAIT_SECONDARY80,
  107. SPECTRAL_REPORT_RX_SECONDARY80,
  108. };
  109. /**
  110. * enum spectral_detector_id - Spectral detector id
  111. * @SPECTRAL_DETECTOR_PRIMARY: Primary detector
  112. * @SPECTRAL_DETECTOR_SECONDARY: Secondary detector
  113. * @SPECTRAL_DETECTOR_AGILE: Agile detector
  114. * @SPECTRAL_DETECTOR_INVALID: Invalid detector
  115. */
  116. enum spectral_detector_id {
  117. SPECTRAL_DETECTOR_PRIMARY,
  118. SPECTRAL_DETECTOR_SECONDARY,
  119. SPECTRAL_DETECTOR_AGILE,
  120. SPECTRAL_DETECTOR_INVALID,
  121. };
  122. /**
  123. * enum spectral_160mhz_report_delivery_event - 160 MHz state machine event
  124. * @SPECTRAL_REPORT_EVENT_DETECTORID0: Received detector id 0
  125. * @SPECTRAL_REPORT_EVENT_DETECTORID1: Received detector id 1
  126. * @SPECTRAL_REPORT_EVENT_DETECTORID_INVALID: Received invalid detector id
  127. */
  128. enum spectral_160mhz_report_delivery_event {
  129. SPECTRAL_REPORT_EVENT_DETECTORID0,
  130. SPECTRAL_REPORT_EVENT_DETECTORID1,
  131. SPECTRAL_REPORT_EVENT_DETECTORID_INVALID,
  132. };
  133. /**
  134. * struct spectral_search_fft_info_gen2 - spectral search fft report for gen2
  135. * @relpwr_db: Total bin power in db
  136. * @num_str_bins_ib: Number of strong bins
  137. * @base_pwr: Base power
  138. * @total_gain_info: Total gain
  139. * @fft_chn_idx: FFT chain on which report is originated
  140. * @avgpwr_db: Average power in db
  141. * @peak_mag: Peak power seen in the bins
  142. * @peak_inx: Index of bin holding peak power
  143. */
  144. struct spectral_search_fft_info_gen2 {
  145. uint32_t relpwr_db;
  146. uint32_t num_str_bins_ib;
  147. uint32_t base_pwr;
  148. uint32_t total_gain_info;
  149. uint32_t fft_chn_idx;
  150. uint32_t avgpwr_db;
  151. uint32_t peak_mag;
  152. int16_t peak_inx;
  153. };
  154. /*
  155. * XXX Check if we should be handling the endinness difference in some
  156. * other way opaque to the host
  157. */
  158. #ifdef BIG_ENDIAN_HOST
  159. /**
  160. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for big endian host
  161. * @signature: signature
  162. * @tag: tag
  163. * @length: length
  164. */
  165. struct spectral_phyerr_tlv_gen2 {
  166. uint8_t signature;
  167. uint8_t tag;
  168. uint16_t length;
  169. } __ATTRIB_PACK;
  170. #else
  171. /**
  172. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for little endian host
  173. * @length: length
  174. * @tag: tag
  175. * @signature: signature
  176. */
  177. struct spectral_phyerr_tlv_gen2 {
  178. uint16_t length;
  179. uint8_t tag;
  180. uint8_t signature;
  181. } __ATTRIB_PACK;
  182. #endif /* BIG_ENDIAN_HOST */
  183. /**
  184. * struct spectral_phyerr_hdr_gen2 - phyerr header for gen2 HW
  185. * @hdr_a: Header[0:31]
  186. * @hdr_b: Header[32:63]
  187. */
  188. struct spectral_phyerr_hdr_gen2 {
  189. uint32_t hdr_a;
  190. uint32_t hdr_b;
  191. };
  192. /*
  193. * Segment ID information for 80+80.
  194. *
  195. * If the HW micro-architecture specification extends this DWORD for other
  196. * purposes, then redefine+rename accordingly. For now, the specification
  197. * mentions only segment ID (though this doesn't require an entire DWORD)
  198. * without mention of any generic terminology for the DWORD, or any reservation.
  199. * We use nomenclature accordingly.
  200. */
  201. typedef uint32_t SPECTRAL_SEGID_INFO;
  202. /**
  203. * struct spectral_phyerr_fft_gen2 - fft info in phyerr event
  204. * @buf: fft report
  205. */
  206. struct spectral_phyerr_fft_gen2 {
  207. uint8_t buf[0];
  208. };
  209. /* END of spectral GEN II HW specific details */
  210. /* START of spectral GEN III HW specific details */
  211. #define get_bitfield(value, size, pos) \
  212. (((value) >> (pos)) & ((1 << (size)) - 1))
  213. #define unsigned_to_signed(value, width) \
  214. (((value) >= (1 << ((width) - 1))) ? \
  215. (value - (1 << (width))) : (value))
  216. #define SSCAN_REPORT_DETECTOR_ID_POS_GEN3 (29)
  217. #define SSCAN_REPORT_DETECTOR_ID_SIZE_GEN3 (2)
  218. #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA)
  219. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02)
  220. #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03)
  221. #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4)
  222. #define PHYERR_HDR_SIG_POS \
  223. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_sig))
  224. #define PHYERR_HDR_TAG_POS \
  225. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_tag))
  226. #define SPECTRAL_FFT_BINS_POS \
  227. (offsetof(struct spectral_phyerr_fft_report_gen3, buf))
  228. /**
  229. * struct phyerr_info - spectral search fft report for gen3
  230. * @data: handle to phyerror buffer
  231. * @datalen: length of phyerror bufer
  232. * @p_rfqual: rf quality matrices
  233. * @p_chaninfo: pointer to chaninfo
  234. * @tsf64: 64 bit TSF
  235. * @acs_stats: acs stats
  236. */
  237. struct phyerr_info {
  238. uint8_t *data;
  239. uint32_t datalen;
  240. struct target_if_spectral_rfqual_info *p_rfqual;
  241. struct target_if_spectral_chan_info *p_chaninfo;
  242. uint64_t tsf64;
  243. struct target_if_spectral_acs_stats *acs_stats;
  244. };
  245. /**
  246. * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3
  247. * @timestamp: Timestamp at which fft report was generated
  248. * @fft_detector_id: Which radio generated this report
  249. * @fft_num: The FFT count number. Set to 0 for short FFT.
  250. * @fft_radar_check: NA for spectral
  251. * @fft_peak_sidx: Index of bin with maximum power
  252. * @fft_chn_idx: Rx chain index
  253. * @fft_base_pwr_db: Base power in dB
  254. * @fft_total_gain_db: Total gain in dB
  255. * @fft_num_str_bins_ib: Number of strong bins in the report
  256. * @fft_peak_mag: Peak magnitude
  257. * @fft_avgpwr_db: Average power in dB
  258. * @fft_relpwr_db: Relative power in dB
  259. */
  260. struct spectral_search_fft_info_gen3 {
  261. uint32_t timestamp;
  262. uint32_t fft_detector_id;
  263. uint32_t fft_num;
  264. uint32_t fft_radar_check;
  265. int32_t fft_peak_sidx;
  266. uint32_t fft_chn_idx;
  267. uint32_t fft_base_pwr_db;
  268. uint32_t fft_total_gain_db;
  269. uint32_t fft_num_str_bins_ib;
  270. int32_t fft_peak_mag;
  271. uint32_t fft_avgpwr_db;
  272. uint32_t fft_relpwr_db;
  273. };
  274. /**
  275. * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event
  276. * @fft_timestamp: Timestamp at which fft report was generated
  277. * @fft_hdr_sig: signature
  278. * @fft_hdr_tag: tag
  279. * @fft_hdr_length: length
  280. * @hdr_a: Header[0:31]
  281. * @hdr_b: Header[32:63]
  282. * @hdr_c: Header[64:95]
  283. * @resv: Header[96:127]
  284. * @buf: fft bins
  285. */
  286. struct spectral_phyerr_fft_report_gen3 {
  287. uint32_t fft_timestamp;
  288. #ifdef BIG_ENDIAN_HOST
  289. uint8_t fft_hdr_sig;
  290. uint8_t fft_hdr_tag;
  291. uint16_t fft_hdr_length;
  292. #else
  293. uint16_t fft_hdr_length;
  294. uint8_t fft_hdr_tag;
  295. uint8_t fft_hdr_sig;
  296. #endif /* BIG_ENDIAN_HOST */
  297. uint32_t hdr_a;
  298. uint32_t hdr_b;
  299. uint32_t hdr_c;
  300. uint32_t resv;
  301. uint8_t buf[0];
  302. } __ATTRIB_PACK;
  303. /**
  304. * struct sscan_report_fields_gen3 - Fields of spectral report
  305. * @sscan_agc_total_gain: The AGC total gain in DB.
  306. * @inband_pwr_db: The in-band power of the signal in 1/2 DB steps
  307. * @sscan_gainchange: This bit is set to 1 if a gainchange occurred during
  308. * the spectral scan FFT. Software may choose to
  309. * disregard the results.
  310. */
  311. struct sscan_report_fields_gen3 {
  312. uint8_t sscan_agc_total_gain;
  313. int16_t inband_pwr_db;
  314. uint8_t sscan_gainchange;
  315. };
  316. /**
  317. * struct spectral_sscan_report_gen3 - spectral report in phyerr event
  318. * @sscan_timestamp: Timestamp at which fft report was generated
  319. * @sscan_hdr_sig: signature
  320. * @sscan_hdr_tag: tag
  321. * @sscan_hdr_length: length
  322. * @hdr_a: Header[0:31]
  323. * @resv: Header[32:63]
  324. * @hdr_b: Header[64:95]
  325. * @resv: Header[96:127]
  326. */
  327. struct spectral_sscan_report_gen3 {
  328. u_int32_t sscan_timestamp;
  329. #ifdef BIG_ENDIAN_HOST
  330. u_int8_t sscan_hdr_sig;
  331. u_int8_t sscan_hdr_tag;
  332. u_int16_t sscan_hdr_length;
  333. #else
  334. u_int16_t sscan_hdr_length;
  335. u_int8_t sscan_hdr_tag;
  336. u_int8_t sscan_hdr_sig;
  337. #endif /* BIG_ENDIAN_HOST */
  338. u_int32_t hdr_a;
  339. u_int32_t res1;
  340. u_int32_t hdr_b;
  341. u_int32_t res2;
  342. } __ATTRIB_PACK;
  343. #ifdef DIRECT_BUF_RX_ENABLE
  344. /**
  345. * struct Spectral_report - spectral report
  346. * @data: Report buffer
  347. * @noisefloor: Noise floor values
  348. */
  349. struct spectral_report {
  350. uint8_t *data;
  351. int32_t noisefloor[DBR_MAX_CHAINS];
  352. };
  353. #endif
  354. /* END of spectral GEN III HW specific details */
  355. typedef signed char pwr_dbm;
  356. /**
  357. * enum spectral_gen - spectral hw generation
  358. * @SPECTRAL_GEN1 : spectral hw gen 1
  359. * @SPECTRAL_GEN2 : spectral hw gen 2
  360. * @SPECTRAL_GEN3 : spectral hw gen 3
  361. */
  362. enum spectral_gen {
  363. SPECTRAL_GEN1,
  364. SPECTRAL_GEN2,
  365. SPECTRAL_GEN3,
  366. };
  367. #if ATH_PERF_PWR_OFFLOAD
  368. /**
  369. * enum target_if_spectral_info - Enumerations for specifying which spectral
  370. * information (among parameters and states)
  371. * is desired.
  372. * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active
  373. * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled
  374. * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params
  375. */
  376. enum target_if_spectral_info {
  377. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  378. TARGET_IF_SPECTRAL_INFO_ENABLED,
  379. TARGET_IF_SPECTRAL_INFO_PARAMS,
  380. };
  381. #endif /* ATH_PERF_PWR_OFFLOAD */
  382. /* forward declaration */
  383. struct target_if_spectral;
  384. /**
  385. * struct target_if_spectral_chan_info - Channel information
  386. * @center_freq1: center frequency 1 in MHz
  387. * @center_freq2: center frequency 2 in MHz -valid only for
  388. * 11ACVHT 80PLUS80 mode
  389. * @chan_width: channel width in MHz
  390. */
  391. struct target_if_spectral_chan_info {
  392. uint16_t center_freq1;
  393. uint16_t center_freq2;
  394. uint8_t chan_width;
  395. };
  396. /**
  397. * struct target_if_spectral_acs_stats - EACS stats from spectral samples
  398. * @nfc_ctl_rssi: Control chan rssi
  399. * @nfc_ext_rssi: Extension chan rssi
  400. * @ctrl_nf: Control chan Noise Floor
  401. * @ext_nf: Extension chan Noise Floor
  402. */
  403. struct target_if_spectral_acs_stats {
  404. int8_t nfc_ctl_rssi;
  405. int8_t nfc_ext_rssi;
  406. int8_t ctrl_nf;
  407. int8_t ext_nf;
  408. };
  409. /**
  410. * struct target_if_spectral_perchain_rssi_info - per chain rssi info
  411. * @rssi_pri20: Rssi of primary 20 Mhz
  412. * @rssi_sec20: Rssi of secondary 20 Mhz
  413. * @rssi_sec40: Rssi of secondary 40 Mhz
  414. * @rssi_sec80: Rssi of secondary 80 Mhz
  415. */
  416. struct target_if_spectral_perchain_rssi_info {
  417. int8_t rssi_pri20;
  418. int8_t rssi_sec20;
  419. int8_t rssi_sec40;
  420. int8_t rssi_sec80;
  421. };
  422. /**
  423. * struct target_if_spectral_rfqual_info - RF measurement information
  424. * @rssi_comb: RSSI Information
  425. * @pc_rssi_info: XXX : For now, we know we are getting information
  426. * for only 4 chains at max. For future extensions
  427. * use a define
  428. * @noise_floor: Noise floor information
  429. */
  430. struct target_if_spectral_rfqual_info {
  431. int8_t rssi_comb;
  432. struct target_if_spectral_perchain_rssi_info pc_rssi_info[4];
  433. int16_t noise_floor[4];
  434. };
  435. #define GET_TARGET_IF_SPECTRAL_OPS(spectral) \
  436. ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops)))
  437. /**
  438. * struct target_if_spectral_ops - spectral low level ops table
  439. * @get_tsf64: Get 64 bit TSF value
  440. * @get_capability: Get capability info
  441. * @set_rxfilter: Set rx filter
  442. * @get_rxfilter: Get rx filter
  443. * @is_spectral_active: Check whether icm is active
  444. * @is_spectral_enabled: Check whether spectral is enabled
  445. * @start_spectral_scan: Start spectral scan
  446. * @stop_spectral_scan: Stop spectral scan
  447. * @get_extension_channel: Get extension channel
  448. * @get_ctl_noisefloor: Get control noise floor
  449. * @get_ext_noisefloor: Get extension noise floor
  450. * @configure_spectral: Set spectral configurations
  451. * @get_spectral_config: Get spectral configurations
  452. * @get_ent_spectral_mask: Get spectral mask
  453. * @get_mac_address: Get mac address
  454. * @get_current_channel: Get current channel
  455. * @reset_hw: Reset HW
  456. * @get_chain_noise_floor: Get Channel noise floor
  457. * @spectral_process_phyerr: Process phyerr event
  458. * @process_spectral_report: Process spectral report
  459. */
  460. struct target_if_spectral_ops {
  461. uint64_t (*get_tsf64)(void *arg);
  462. uint32_t (*get_capability)(
  463. void *arg, enum spectral_capability_type type);
  464. uint32_t (*set_rxfilter)(void *arg, int rxfilter);
  465. uint32_t (*get_rxfilter)(void *arg);
  466. uint32_t (*is_spectral_active)(void *arg);
  467. uint32_t (*is_spectral_enabled)(void *arg);
  468. uint32_t (*start_spectral_scan)(void *arg);
  469. uint32_t (*stop_spectral_scan)(void *arg);
  470. uint32_t (*get_extension_channel)(void *arg);
  471. int8_t (*get_ctl_noisefloor)(void *arg);
  472. int8_t (*get_ext_noisefloor)(void *arg);
  473. uint32_t (*configure_spectral)(
  474. void *arg,
  475. struct spectral_config *params);
  476. uint32_t (*get_spectral_config)(
  477. void *arg,
  478. struct spectral_config *params);
  479. uint32_t (*get_ent_spectral_mask)(void *arg);
  480. uint32_t (*get_mac_address)(void *arg, char *addr);
  481. uint32_t (*get_current_channel)(void *arg);
  482. uint32_t (*reset_hw)(void *arg);
  483. uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf);
  484. int (*spectral_process_phyerr)(struct target_if_spectral *spectral,
  485. uint8_t *data, uint32_t datalen,
  486. struct target_if_spectral_rfqual_info *p_rfqual,
  487. struct target_if_spectral_chan_info *p_chaninfo,
  488. uint64_t tsf64,
  489. struct target_if_spectral_acs_stats *acs_stats);
  490. int (*process_spectral_report)(struct wlan_objmgr_pdev *pdev,
  491. void *payload);
  492. };
  493. /**
  494. * struct target_if_spectral_stats - spectral stats info
  495. * @num_spectral_detects: Total num. of spectral detects
  496. * @total_phy_errors: Total number of phyerrors
  497. * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets
  498. * @pri_phy_errors: Phyerrors in primary channel
  499. * @ext_phy_errors: Phyerrors in secondary channel
  500. * @dc_phy_errors: Phyerrors due to dc
  501. * @early_ext_phy_errors: Early secondary channel phyerrors
  502. * @bwinfo_errors: Bandwidth info errors
  503. * @datalen_discards: Invalid data length errors, seen in gen1 chipsets
  504. * @rssi_discards bw: Indicates reports dropped due to RSSI threshold
  505. * @last_reset_tstamp: Last reset time stamp
  506. */
  507. struct target_if_spectral_stats {
  508. uint32_t num_spectral_detects;
  509. uint32_t total_phy_errors;
  510. uint32_t owl_phy_errors;
  511. uint32_t pri_phy_errors;
  512. uint32_t ext_phy_errors;
  513. uint32_t dc_phy_errors;
  514. uint32_t early_ext_phy_errors;
  515. uint32_t bwinfo_errors;
  516. uint32_t datalen_discards;
  517. uint32_t rssi_discards;
  518. uint64_t last_reset_tstamp;
  519. };
  520. /**
  521. * struct target_if_spectral_event - spectral event structure
  522. * @se_ts: Original 15 bit recv timestamp
  523. * @se_full_ts: 64-bit full timestamp from interrupt time
  524. * @se_rssi: Rssi of spectral event
  525. * @se_bwinfo: Rssi of spectral event
  526. * @se_dur: Duration of spectral pulse
  527. * @se_chanindex: Channel of event
  528. * @se_list: List of spectral events
  529. */
  530. struct target_if_spectral_event {
  531. uint32_t se_ts;
  532. uint64_t se_full_ts;
  533. uint8_t se_rssi;
  534. uint8_t se_bwinfo;
  535. uint8_t se_dur;
  536. uint8_t se_chanindex;
  537. STAILQ_ENTRY(spectral_event) se_list;
  538. };
  539. /**
  540. * struct target_if_chain_noise_pwr_info - Noise power info for each channel
  541. * @rptcount: Count of reports in pwr array
  542. * @un_cal_nf: Uncalibrated noise floor
  543. * @factory_cal_nf: Noise floor as calibrated at the factory for module
  544. * @median_pwr: Median power (median of pwr array)
  545. * @pwr: Power reports
  546. */
  547. struct target_if_chain_noise_pwr_info {
  548. int rptcount;
  549. pwr_dbm un_cal_nf;
  550. pwr_dbm factory_cal_nf;
  551. pwr_dbm median_pwr;
  552. pwr_dbm pwr[];
  553. } __ATTRIB_PACK;
  554. /**
  555. * struct target_if_spectral_chan_stats - Channel information
  556. * @cycle_count: Cycle count
  557. * @channel_load: Channel load
  558. * @per: Period
  559. * @noisefloor: Noise floor
  560. * @comp_usablity: Computed usability
  561. * @maxregpower: Maximum allowed regulatary power
  562. * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
  563. * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz
  564. */
  565. struct target_if_spectral_chan_stats {
  566. int cycle_count;
  567. int channel_load;
  568. int per;
  569. int noisefloor;
  570. uint16_t comp_usablity;
  571. int8_t maxregpower;
  572. uint16_t comp_usablity_sec80;
  573. int8_t maxregpower_sec80;
  574. };
  575. #if ATH_PERF_PWR_OFFLOAD
  576. /**
  577. * struct target_if_spectral_cache - Cache used to minimize WMI operations
  578. * in offload architecture
  579. * @osc_spectral_enabled: Whether Spectral is enabled
  580. * @osc_spectral_active: Whether spectral is active
  581. * XXX: Ideally, we should NOT cache this
  582. * since the hardware can self clear the bit,
  583. * the firmware can possibly stop spectral due to
  584. * intermittent off-channel activity, etc
  585. * A WMI read command should be introduced to handle
  586. * this This will be discussed.
  587. * @osc_params: Spectral parameters
  588. * @osc_is_valid: Whether the cache is valid
  589. */
  590. struct target_if_spectral_cache {
  591. uint8_t osc_spectral_enabled;
  592. uint8_t osc_spectral_active;
  593. struct spectral_config osc_params;
  594. uint8_t osc_is_valid;
  595. };
  596. /**
  597. * struct target_if_spectral_param_state_info - Structure used to represent and
  598. * manage spectral information
  599. * (parameters and states)
  600. * @osps_lock: Lock to synchronize accesses to information
  601. * @osps_cache: Cacheable' information
  602. */
  603. struct target_if_spectral_param_state_info {
  604. qdf_spinlock_t osps_lock;
  605. struct target_if_spectral_cache osps_cache;
  606. /* XXX - Non-cacheable information goes here, in the future */
  607. };
  608. #endif /* ATH_PERF_PWR_OFFLOAD */
  609. struct vdev_spectral_configure_params;
  610. struct vdev_spectral_enable_params;
  611. /**
  612. * struct wmi_spectral_cmd_ops - structure used holding the operations
  613. * related to wmi commands on spectral parameters.
  614. * @wmi_spectral_configure_cmd_send:
  615. * @wmi_spectral_enable_cmd_send:
  616. */
  617. struct wmi_spectral_cmd_ops {
  618. QDF_STATUS (*wmi_spectral_configure_cmd_send)(
  619. void *wmi_hdl,
  620. struct vdev_spectral_configure_params *param);
  621. QDF_STATUS (*wmi_spectral_enable_cmd_send)(
  622. void *wmi_hdl,
  623. struct vdev_spectral_enable_params *param);
  624. };
  625. /**
  626. * struct target_if_spectral - main spectral structure
  627. * @pdev: Pointer to pdev
  628. * @spectral_ops: Target if internal Spectral low level operations table
  629. * @capability: Spectral capabilities structure
  630. * @spectral_lock: Lock used for internal Spectral operations
  631. * @spectral_curchan_radindex: Current channel spectral index
  632. * @spectral_extchan_radindex: Extension channel spectral index
  633. * @spectraldomain: Current Spectral domain
  634. * @spectral_proc_phyerr: Flags to process for PHY errors
  635. * @spectral_defaultparams: Default PHY params per Spectral stat
  636. * @spectral_stats: Spectral related stats
  637. * @events: Events structure
  638. * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel?
  639. * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI?
  640. * @sc_spectral_20_40_mode: Is AP in 20-40 mode?
  641. * @sc_spectral_noise_pwr_cal: Noise power cal required?
  642. * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA?
  643. * @upper_is_control: Upper segment is primary
  644. * @upper_is_extension: Upper segment is secondary
  645. * @lower_is_control: Lower segment is primary
  646. * @lower_is_extension: Lower segment is secondary
  647. * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral
  648. * mute test
  649. * @spectral_numbins: Number of bins
  650. * @spectral_fft_len: FFT length
  651. * @spectral_data_len: Total phyerror report length
  652. * @lb_edge_extrabins: Number of extra bins on left band edge
  653. * @rb_edge_extrabins: Number of extra bins on right band edge
  654. * @spectral_max_index_offset: Max FFT index offset (20 MHz mode)
  655. * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode)
  656. * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode)
  657. * @spectral_dc_index: At which index DC is present
  658. * @send_single_packet: Deprecated
  659. * @spectral_sent_msg: Indicates whether we send report to upper layers
  660. * @params: Spectral parameters
  661. * @last_capture_time: Indicates timestamp of previouse report
  662. * @num_spectral_data: Number of Spectral samples received in current session
  663. * @total_spectral_data: Total number of Spectral samples received
  664. * @max_rssi: Maximum RSSI
  665. * @detects_control_channel: NA
  666. * @detects_extension_channel: NA
  667. * @detects_below_dc: NA
  668. * @detects_above_dc: NA
  669. * @sc_scanning: Indicates active wifi scan
  670. * @sc_spectral_scan: Indicates active specral scan
  671. * @sc_spectral_full_scan: Deprecated
  672. * @scan_start_tstamp: Deprecated
  673. * @last_tstamp: Deprecated
  674. * @first_tstamp: Deprecated
  675. * @spectral_samp_count: Deprecated
  676. * @sc_spectral_samp_count: Deprecated
  677. * @noise_pwr_reports_reqd: Number of noise power reports required
  678. * @noise_pwr_reports_recv: Number of noise power reports received
  679. * @noise_pwr_reports_lock: Lock used for Noise power report processing
  680. * @noise_pwr_chain_ctl: Noise power report - control channel
  681. * @noise_pwr_chain_ext: Noise power report - extension channel
  682. * @chaninfo: Channel statistics
  683. * @tsf64: Latest TSF Value
  684. * @param_info: Offload architecture Spectral parameter cache information
  685. * @ch_width: Indicates Channel Width 20/40/80/160 MHz with values 0, 1, 2, 3
  686. * respectively
  687. * @diag_stats: Diagnostic statistics
  688. * @is_160_format: Indicates whether information provided by HW is in altered
  689. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  690. * @is_lb_edge_extrabins_format: Indicates whether information provided by
  691. * HW has 4 extra bins, at left band edge, for report mode 2
  692. * @is_rb_edge_extrabins_format: Indicates whether information provided
  693. * by HW has 4 extra bins, at right band edge, for report mode 2
  694. * @is_sec80_rssi_war_required: Indicates whether the software workaround is
  695. * required to obtain approximate combined RSSI for secondary 80Mhz segment
  696. * @simctx: Spectral Simulation context
  697. * @spectral_gen: Spectral hardware generation
  698. * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware
  699. * generation
  700. * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV
  701. * header, for the given hardware generation
  702. * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV
  703. * header, for the given hardware generation
  704. * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
  705. * generation
  706. * @nl_cb: Netlink callbacks
  707. * @use_nl_bcast: Whether to use Netlink broadcast/unicast
  708. * @send_phy_data: Send data to the applicaton layer
  709. * @inband_fftbin_size_adj: Whether to carry out FFT bin size adjustment for
  710. * in-band report format. This would be required on some chipsets under the
  711. * following circumstances: In report mode 2 only the in-band bins are DMA'ed.
  712. * Scatter/gather is used. However, the HW generates all bins, not just in-band,
  713. * and reports the number of bins accordingly. The subsystem arranging for the
  714. * DMA cannot change this value. On such chipsets the adjustment required at the
  715. * host driver is to check if report format is 2, and if so halve the number of
  716. * bins reported to get the number actually DMA'ed.
  717. */
  718. struct target_if_spectral {
  719. struct wlan_objmgr_pdev *pdev_obj;
  720. struct target_if_spectral_ops spectral_ops;
  721. struct spectral_caps capability;
  722. qdf_spinlock_t spectral_lock;
  723. int16_t spectral_curchan_radindex;
  724. int16_t spectral_extchan_radindex;
  725. uint32_t spectraldomain;
  726. uint32_t spectral_proc_phyerr;
  727. struct spectral_config spectral_defaultparams;
  728. struct target_if_spectral_stats spectral_stats;
  729. struct target_if_spectral_event *events;
  730. unsigned int sc_spectral_ext_chan_ok:1,
  731. sc_spectral_combined_rssi_ok:1,
  732. sc_spectral_20_40_mode:1,
  733. sc_spectral_noise_pwr_cal:1,
  734. sc_spectral_non_edma:1;
  735. int upper_is_control;
  736. int upper_is_extension;
  737. int lower_is_control;
  738. int lower_is_extension;
  739. uint8_t sc_spectraltest_ieeechan;
  740. int spectral_numbins;
  741. int spectral_fft_len;
  742. int spectral_data_len;
  743. /*
  744. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  745. * delivered. However, there can be additional bins reported for
  746. * AR900B version 2.0 and QCA9984 as described next:
  747. *
  748. * AR900B version 2.0: An additional tone is processed on the right
  749. * hand side in order to facilitate detection of radar pulses out to
  750. * the extreme band-edge of the channel frequency. Since the HW design
  751. * processes four tones at a time, this requires one additional Dword
  752. * to be added to the search FFT report.
  753. *
  754. * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary +
  755. * 1x-oversampled bins (in-band) per FFT, then 8 more bins
  756. * (4 more on left side and 4 more on right side)are added.
  757. */
  758. int lb_edge_extrabins;
  759. int rb_edge_extrabins;
  760. int spectral_max_index_offset;
  761. int spectral_upper_max_index_offset;
  762. int spectral_lower_max_index_offset;
  763. int spectral_dc_index;
  764. int send_single_packet;
  765. int spectral_sent_msg;
  766. int classify_scan;
  767. os_timer_t classify_timer;
  768. struct spectral_config params;
  769. struct spectral_classifier_params classifier_params;
  770. int last_capture_time;
  771. int num_spectral_data;
  772. int total_spectral_data;
  773. int max_rssi;
  774. int detects_control_channel;
  775. int detects_extension_channel;
  776. int detects_below_dc;
  777. int detects_above_dc;
  778. int sc_scanning;
  779. int sc_spectral_scan;
  780. int sc_spectral_full_scan;
  781. uint64_t scan_start_tstamp;
  782. uint32_t last_tstamp;
  783. uint32_t first_tstamp;
  784. uint32_t spectral_samp_count;
  785. uint32_t sc_spectral_samp_count;
  786. int noise_pwr_reports_reqd;
  787. int noise_pwr_reports_recv;
  788. qdf_spinlock_t noise_pwr_reports_lock;
  789. struct target_if_chain_noise_pwr_info
  790. *noise_pwr_chain_ctl[HOST_MAX_ANTENNA];
  791. struct target_if_chain_noise_pwr_info
  792. *noise_pwr_chain_ext[HOST_MAX_ANTENNA];
  793. uint64_t tsf64;
  794. #if ATH_PERF_PWR_OFFLOAD
  795. struct target_if_spectral_param_state_info param_info;
  796. #endif
  797. uint32_t ch_width;
  798. struct spectral_diag_stats diag_stats;
  799. bool is_160_format;
  800. bool is_lb_edge_extrabins_format;
  801. bool is_rb_edge_extrabins_format;
  802. bool is_sec80_rssi_war_required;
  803. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  804. void *simctx;
  805. #endif
  806. enum spectral_gen spectral_gen;
  807. uint8_t hdr_sig_exp;
  808. uint8_t tag_sscan_summary_exp;
  809. uint8_t tag_sscan_fft_exp;
  810. uint8_t tlvhdr_size;
  811. struct wmi_spectral_cmd_ops param_wmi_cmd_ops;
  812. struct spectral_nl_cb nl_cb;
  813. bool use_nl_bcast;
  814. int (*send_phy_data)(struct wlan_objmgr_pdev *pdev);
  815. u_int8_t fftbin_size_war;
  816. u_int8_t inband_fftbin_size_adj;
  817. enum spectral_160mhz_report_delivery_state state_160mhz_delivery;
  818. void *spectral_report_cache;
  819. };
  820. /**
  821. * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol
  822. * data format
  823. * @rssi: RSSI (except for secondary 80 segment)
  824. * @rssi_sec80: RSSI for secondary 80 segment
  825. * @lower_rssi: RSSI of lower band
  826. * @upper_rssi: RSSI of upper band
  827. * @chain_ctl_rssi: RSSI for control channel, for all antennas
  828. * @chain_ext_rssi: RSSI for extension channel, for all antennas
  829. * @bwinfo: bandwidth info
  830. * @data_len: length of FFT data (except for secondary 80 segment)
  831. * @data_len_sec80: length of FFT data for secondary 80 segment
  832. * @tstamp: timestamp
  833. * @last_tstamp: last time stamp
  834. * @max_mag: maximum magnitude (except for secondary 80 segment)
  835. * @max_mag_sec80: maximum magnitude for secondary 80 segment
  836. * @max_index: index of max magnitude (except for secondary 80 segment)
  837. * @max_index_sec80: index of max magnitude for secondary 80 segment
  838. * @max_exp: max exp
  839. * @peak: peak frequency (obsolete)
  840. * @pwr_count: number of FFT bins (except for secondary 80 segment)
  841. * @pwr_count_sec80: number of FFT bins in secondary 80 segment
  842. * @nb_lower: This is deprecated
  843. * @nb_upper: This is deprecated
  844. * @max_upper_index: index of max mag in upper band
  845. * @max_lower_index: index of max mag in lower band
  846. * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment)
  847. * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment
  848. * @freq: Center frequency of primary 20MHz channel in MHz
  849. * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz
  850. * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz
  851. * @freq_loading: spectral control duty cycles
  852. * @noise_floor: current noise floor (except for secondary 80 segment)
  853. * @noise_floor_sec80: current noise floor for secondary 80 segment
  854. * @interf_list: List of interfernce sources
  855. * @classifier_params: classifier parameters
  856. * @sc: classifier parameters
  857. */
  858. struct target_if_samp_msg_params {
  859. int8_t rssi;
  860. int8_t rssi_sec80;
  861. int8_t lower_rssi;
  862. int8_t upper_rssi;
  863. int8_t chain_ctl_rssi[HOST_MAX_ANTENNA];
  864. int8_t chain_ext_rssi[HOST_MAX_ANTENNA];
  865. uint16_t bwinfo;
  866. uint16_t datalen;
  867. uint16_t datalen_sec80;
  868. uint32_t tstamp;
  869. uint32_t last_tstamp;
  870. uint16_t max_mag;
  871. uint16_t max_mag_sec80;
  872. uint16_t max_index;
  873. uint16_t max_index_sec80;
  874. uint8_t max_exp;
  875. int peak;
  876. int pwr_count;
  877. int pwr_count_sec80;
  878. int8_t nb_lower;
  879. int8_t nb_upper;
  880. uint16_t max_lower_index;
  881. uint16_t max_upper_index;
  882. uint8_t *bin_pwr_data;
  883. uint8_t *bin_pwr_data_sec80;
  884. uint16_t freq;
  885. uint16_t vhtop_ch_freq_seg1;
  886. uint16_t vhtop_ch_freq_seg2;
  887. uint16_t freq_loading;
  888. int16_t noise_floor;
  889. int16_t noise_floor_sec80;
  890. struct interf_src_rsp interf_list;
  891. struct spectral_classifier_params classifier_params;
  892. struct ath_softc *sc;
  893. uint8_t agc_total_gain;
  894. uint8_t agc_total_gain_sec80;
  895. uint8_t gainchange;
  896. uint8_t gainchange_sec80;
  897. };
  898. #ifdef WLAN_CONV_SPECTRAL_ENABLE
  899. /**
  900. * target_if_spectral_dump_fft() - Dump Spectral FFT
  901. * @pfft: Pointer to Spectral Phyerr FFT
  902. * @fftlen: FFT length
  903. *
  904. * Return: Success or failure
  905. */
  906. int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen);
  907. /**
  908. * target_if_dbg_print_samp_param() - Print contents of SAMP struct
  909. * @p: Pointer to SAMP message
  910. *
  911. * Return: Void
  912. */
  913. void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p);
  914. /**
  915. * target_if_get_offset_swar_sec80() - Get offset for SWAR according to
  916. * the channel width
  917. * @channel_width: Channel width
  918. *
  919. * Return: Offset for SWAR
  920. */
  921. uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
  922. /**
  923. * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops
  924. * @tx_ops: Tx Ops
  925. *
  926. * Return: void
  927. */
  928. void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
  929. /**
  930. * target_if_spectral_create_samp_msg() - Create the spectral samp message
  931. * @spectral : Pointer to spectral internal structure
  932. * @params : spectral samp message parameters
  933. *
  934. * API to create the spectral samp message
  935. *
  936. * Return: void
  937. */
  938. void target_if_spectral_create_samp_msg(
  939. struct target_if_spectral *spectral,
  940. struct target_if_samp_msg_params *params);
  941. /**
  942. * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3
  943. * @pdev: Pointer to pdev object
  944. * @payload: Pointer to spectral report
  945. *
  946. * Process phyerror event for gen3
  947. *
  948. * Return: Success/Failure
  949. */
  950. int target_if_spectral_process_report_gen3(
  951. struct wlan_objmgr_pdev *pdev,
  952. void *buf);
  953. /**
  954. * target_if_process_phyerr_gen2() - Process PHY Error for gen2
  955. * @spectral: Pointer to Spectral object
  956. * @data: Pointer to phyerror event buffer
  957. * @datalen: Data length
  958. * @p_rfqual: RF quality info
  959. * @p_chaninfo: Channel info
  960. * @tsf64: 64 bit tsf timestamp
  961. * @acs_stats: ACS stats
  962. *
  963. * Process PHY Error for gen2
  964. *
  965. * Return: Success/Failure
  966. */
  967. int target_if_process_phyerr_gen2(
  968. struct target_if_spectral *spectral,
  969. uint8_t *data,
  970. uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
  971. struct target_if_spectral_chan_info *p_chaninfo,
  972. uint64_t tsf64,
  973. struct target_if_spectral_acs_stats *acs_stats);
  974. /**
  975. * target_if_spectral_send_intf_found_msg() - Indicate to application layer that
  976. * interference has been found
  977. * @pdev: Pointer to pdev
  978. * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found
  979. * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled
  980. *
  981. * Send message to application layer
  982. * indicating that interference has been found
  983. *
  984. * Return: None
  985. */
  986. void target_if_spectral_send_intf_found_msg(
  987. struct wlan_objmgr_pdev *pdev,
  988. uint16_t cw_int, uint32_t dcs_enabled);
  989. /**
  990. * target_if_stop_spectral_scan() - Stop spectral scan
  991. * @pdev: Pointer to pdev object
  992. *
  993. * API to stop the current on-going spectral scan
  994. *
  995. * Return: None
  996. */
  997. void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev);
  998. /**
  999. * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral
  1000. * operations
  1001. * @spectral: Pointer to Spectral target_if internal private data
  1002. *
  1003. * Spectral operates on pdev. However, in order to retrieve some WLAN
  1004. * properties, a vdev is required. To facilitate this, the function returns the
  1005. * first vdev in our pdev. The caller should release the reference to the vdev
  1006. * once it is done using it.
  1007. * TODO: If the framework later provides an API to obtain the first active
  1008. * vdev, then it would be preferable to use this API.
  1009. *
  1010. * Return: Pointer to vdev on success, NULL on failure
  1011. */
  1012. struct wlan_objmgr_vdev *target_if_spectral_get_vdev(
  1013. struct target_if_spectral *spectral);
  1014. /**
  1015. * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2
  1016. * @phdr: Pointer to Spectral Phyerr Header
  1017. *
  1018. * Dump Spectral header
  1019. *
  1020. * Return: Success/Failure
  1021. */
  1022. int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr);
  1023. /**
  1024. * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI
  1025. * for Secondary 80 segment
  1026. * @spectral: Pointer to spectral object
  1027. * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment
  1028. *
  1029. * Get approximate combined RSSI for Secondary 80 segment
  1030. *
  1031. * Return: Combined RSSI for secondary 80Mhz segment
  1032. */
  1033. int8_t target_if_get_combrssi_sec80_seg_gen2(
  1034. struct target_if_spectral *spectral,
  1035. struct spectral_search_fft_info_gen2 *p_sfft_sec80);
  1036. /**
  1037. * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2
  1038. * @ptlv: Pointer to Spectral Phyerr TLV
  1039. * @is_160_format: Indicates 160 format
  1040. *
  1041. * Dump Spectral TLV for gen2
  1042. *
  1043. * Return: Success/Failure
  1044. */
  1045. int target_if_spectral_dump_tlv_gen2(
  1046. struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format);
  1047. /**
  1048. * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral
  1049. * related PHY Error for gen2
  1050. * @data: Pointer to phyerror buffer
  1051. * @datalen: Data length
  1052. * @is_160_format: Indicates 160 format
  1053. *
  1054. * Dump Spectral related PHY Error for gen2
  1055. *
  1056. * Return: Success/Failure
  1057. */
  1058. int target_if_spectral_dump_phyerr_data_gen2(
  1059. uint8_t *data,
  1060. uint32_t datalen,
  1061. bool is_160_format);
  1062. /**
  1063. * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3
  1064. * @spectral: Pointer to Spectral object
  1065. * @p_fft_report: Pointer to fft report
  1066. * @p_sfft: Pointer to search fft report
  1067. *
  1068. * Dump FFT Report for gen3
  1069. *
  1070. * Return: Success/Failure
  1071. */
  1072. int target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
  1073. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1074. struct spectral_search_fft_info_gen3 *p_sfft);
  1075. /**
  1076. * target_if_dbg_print_samp_msg() - Print contents of SAMP Message
  1077. * @p: Pointer to SAMP message
  1078. *
  1079. * Print contents of SAMP Message
  1080. *
  1081. * Return: Void
  1082. */
  1083. void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg);
  1084. /**
  1085. * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3
  1086. * @p_fft_report: Pointer to fft report
  1087. * @p_sfft: Pointer to search fft report
  1088. *
  1089. * Process Search FFT Report for gen3
  1090. *
  1091. * Return: Success/Failure
  1092. */
  1093. int target_if_process_sfft_report_gen3(
  1094. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1095. struct spectral_search_fft_info_gen3 *p_fft_info);
  1096. /**
  1097. * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
  1098. * Spectral data
  1099. * @pdev: Pointer to pdev
  1100. *
  1101. * Return: Handle to target_if internal Spectral data on success, NULL on
  1102. * failure
  1103. */
  1104. static inline
  1105. struct target_if_spectral *get_target_if_spectral_handle_from_pdev(
  1106. struct wlan_objmgr_pdev *pdev)
  1107. {
  1108. struct target_if_spectral *spectral = NULL;
  1109. struct wlan_objmgr_psoc *psoc = NULL;
  1110. psoc = wlan_pdev_get_psoc(pdev);
  1111. spectral = (struct target_if_spectral *)
  1112. psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_target_handle(
  1113. pdev);
  1114. return spectral;
  1115. }
  1116. /**
  1117. * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a
  1118. * given vdev
  1119. * @pdev: Pointer to vdev
  1120. *
  1121. * Get the operating channel frequency of a given vdev
  1122. *
  1123. * Return: Operating channel frequency of a vdev
  1124. */
  1125. static inline
  1126. int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev)
  1127. {
  1128. struct wlan_objmgr_psoc *psoc = NULL;
  1129. psoc = wlan_vdev_get_psoc(vdev);
  1130. if (!psoc) {
  1131. spectral_err("psoc is NULL");
  1132. return -EINVAL;
  1133. }
  1134. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_chan_freq(
  1135. vdev);
  1136. }
  1137. /**
  1138. * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a
  1139. * given vdev
  1140. * @pdev: Pointer to vdev
  1141. *
  1142. * Get the operating channel bandwidth of a given vdev
  1143. *
  1144. * Return: channel bandwidth enumeration corresponding to the vdev
  1145. */
  1146. static inline
  1147. enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev)
  1148. {
  1149. struct wlan_objmgr_psoc *psoc = NULL;
  1150. psoc = wlan_vdev_get_psoc(vdev);
  1151. if (!psoc) {
  1152. spectral_err("psoc is NULL");
  1153. return CH_WIDTH_INVALID;
  1154. }
  1155. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_ch_width(
  1156. vdev);
  1157. }
  1158. /**
  1159. * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary
  1160. * 20 MHz channel for a given vdev
  1161. * @pdev: Pointer to vdev
  1162. *
  1163. * Get the frequency of secondary 20Mhz channel for a given vdev
  1164. *
  1165. * Return: Frequency of secondary 20Mhz channel for a given vdev
  1166. */
  1167. static inline
  1168. int target_if_vdev_get_sec20chan_freq_mhz(
  1169. struct wlan_objmgr_vdev *vdev,
  1170. uint16_t *sec20chan_freq)
  1171. {
  1172. struct wlan_objmgr_psoc *psoc = NULL;
  1173. psoc = wlan_vdev_get_psoc(vdev);
  1174. if (!psoc) {
  1175. spectral_err("psoc is NULL");
  1176. return -EINVAL;
  1177. }
  1178. return psoc->soc_cb.rx_ops.sptrl_rx_ops.
  1179. sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq);
  1180. }
  1181. /**
  1182. * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask
  1183. * @pdev: Pointer to pdev
  1184. * @spectral_rx_chainmask: Spectral Rx chainmask
  1185. *
  1186. * Return: None
  1187. */
  1188. static inline
  1189. void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev,
  1190. uint8_t spectral_rx_chainmask)
  1191. {
  1192. struct target_if_spectral *spectral = NULL;
  1193. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1194. spectral->params.ss_chn_mask = spectral_rx_chainmask;
  1195. }
  1196. /**
  1197. * target_if_spectral_process_phyerr() - Process Spectral PHY error
  1198. * @pdev: Pointer to pdev
  1199. * @data: PHY error data received from FW
  1200. * @datalen: Length of data
  1201. * @p_rfqual: Pointer to RF Quality information
  1202. * @p_chaninfo: Pointer to channel information
  1203. * @tsf: TSF time instance at which the Spectral sample was received
  1204. * @acs_stats: ACS stats
  1205. *
  1206. * Process Spectral PHY error by extracting necessary information from the data
  1207. * sent by FW, and send the extracted information to application layer.
  1208. *
  1209. * Return: None
  1210. */
  1211. static inline
  1212. void target_if_spectral_process_phyerr(
  1213. struct wlan_objmgr_pdev *pdev,
  1214. uint8_t *data, uint32_t datalen,
  1215. struct target_if_spectral_rfqual_info *p_rfqual,
  1216. struct target_if_spectral_chan_info *p_chaninfo,
  1217. uint64_t tsf64,
  1218. struct target_if_spectral_acs_stats *acs_stats)
  1219. {
  1220. struct target_if_spectral *spectral = NULL;
  1221. struct target_if_spectral_ops *p_sops = NULL;
  1222. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1223. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1224. p_sops->spectral_process_phyerr(spectral, data, datalen,
  1225. p_rfqual, p_chaninfo,
  1226. tsf64, acs_stats);
  1227. }
  1228. /**
  1229. * save_spectral_report_skb() - Save Spectral report skb
  1230. * @spectral: Pointer to Spectral
  1231. * @skb: Pointer to skb
  1232. *
  1233. * Save spectral report skb
  1234. *
  1235. * Return: void
  1236. */
  1237. static inline void
  1238. save_spectral_report_skb(struct target_if_spectral *spectral, void *skb) {
  1239. if (spectral->ch_width == CH_WIDTH_160MHZ)
  1240. spectral->spectral_report_cache = skb;
  1241. }
  1242. /**
  1243. * restore_spectral_report_skb() - Restore Spectral report skb
  1244. * @spectral: Pointer to Spectral
  1245. * @skb: Pointer to restore location
  1246. *
  1247. * Restore spectral report skb
  1248. *
  1249. * Return: void
  1250. */
  1251. static inline void
  1252. restore_spectral_report_skb(struct target_if_spectral *spectral, void **dest) {
  1253. if (spectral->ch_width == CH_WIDTH_160MHZ) {
  1254. QDF_ASSERT(spectral->spectral_report_cache);
  1255. *dest = spectral->spectral_report_cache;
  1256. }
  1257. }
  1258. /**
  1259. * clear_spectral_report_skb() - Clear Spectral report skb
  1260. * @spectral: Pointer to Spectral
  1261. *
  1262. * Clear spectral report skb
  1263. *
  1264. * Return: void
  1265. */
  1266. static inline void
  1267. clear_spectral_report_skb(struct target_if_spectral *spectral) {
  1268. if (spectral->ch_width == CH_WIDTH_160MHZ)
  1269. spectral->spectral_report_cache = NULL;
  1270. }
  1271. /**
  1272. * free_and_clear_spectral_report_skb() - Free and clear Spectral report skb
  1273. * @spectral: Pointer to Spectral
  1274. *
  1275. * Free and clear spectral report skb
  1276. *
  1277. * Return: void
  1278. */
  1279. static inline void
  1280. free_and_clear_spectral_report_skb(struct target_if_spectral *spectral) {
  1281. if (spectral->spectral_report_cache)
  1282. spectral->nl_cb.free_nbuff(spectral->pdev_obj);
  1283. spectral->spectral_report_cache = NULL;
  1284. }
  1285. /**
  1286. * init_160mhz_delivery_state_machine() - Initialize 160MHz Spectral
  1287. * state machine
  1288. * @spectral: Pointer to Spectral
  1289. *
  1290. * Initialize 160MHz Spectral state machine
  1291. *
  1292. * Return: void
  1293. */
  1294. static inline void
  1295. init_160mhz_delivery_state_machine(struct target_if_spectral *spectral) {
  1296. spectral->state_160mhz_delivery =
  1297. SPECTRAL_REPORT_WAIT_PRIMARY80;
  1298. spectral->spectral_report_cache = NULL;
  1299. }
  1300. /**
  1301. * deinit_160mhz_delivery_state_machine() - Deinitialize 160MHz Spectral
  1302. * state machine
  1303. * @spectral: Pointer to Spectral
  1304. *
  1305. * Deinitialize 160MHz Spectral state machine
  1306. *
  1307. * Return: void
  1308. */
  1309. static inline void
  1310. deinit_160mhz_delivery_state_machine(struct target_if_spectral *spectral) {
  1311. if (spectral->spectral_report_cache)
  1312. spectral->nl_cb.free_nbuff(spectral->pdev_obj);
  1313. spectral->spectral_report_cache = NULL;
  1314. }
  1315. /**
  1316. * reset_160mhz_delivery_state_machine() - Reset 160MHz Spectral state machine
  1317. * @spectral: Pointer to Spectral
  1318. *
  1319. * Reset 160MHz Spectral state machine
  1320. *
  1321. * Return: void
  1322. */
  1323. static inline void
  1324. reset_160mhz_delivery_state_machine(struct target_if_spectral *spectral) {
  1325. if (spectral->ch_width == CH_WIDTH_160MHZ) {
  1326. spectral->state_160mhz_delivery =
  1327. SPECTRAL_REPORT_WAIT_PRIMARY80;
  1328. free_and_clear_spectral_report_skb(spectral);
  1329. }
  1330. }
  1331. /**
  1332. * is_secondaryseg_expected() - Is waiting for secondary 80 report
  1333. * @spectral: Pointer to Spectral
  1334. *
  1335. * Return true if secondary 80 report expected and mode is 160 MHz
  1336. *
  1337. * Return: true or false
  1338. */
  1339. static inline
  1340. bool is_secondaryseg_expected(struct target_if_spectral *spectral)
  1341. {
  1342. return
  1343. ((spectral->ch_width == CH_WIDTH_160MHZ) &&
  1344. (spectral->state_160mhz_delivery == SPECTRAL_REPORT_WAIT_SECONDARY80));
  1345. }
  1346. /**
  1347. * is_primaryseg_expected() - Is waiting for primary 80 report
  1348. * @spectral: Pointer to Spectral
  1349. *
  1350. * Return true if mode is 160 Mhz and primary 80 report expected or
  1351. * mode is not 160 Mhz
  1352. *
  1353. * Return: true or false
  1354. */
  1355. static inline
  1356. bool is_primaryseg_expected(struct target_if_spectral *spectral)
  1357. {
  1358. return
  1359. ((spectral->ch_width != CH_WIDTH_160MHZ) ||
  1360. ((spectral->ch_width == CH_WIDTH_160MHZ) &&
  1361. (spectral->state_160mhz_delivery == SPECTRAL_REPORT_WAIT_PRIMARY80)));
  1362. }
  1363. /**
  1364. * is_primaryseg_rx_inprog() - Is primary 80 report processing is in progress
  1365. * @spectral: Pointer to Spectral
  1366. *
  1367. * Is primary 80 report processing is in progress
  1368. *
  1369. * Return: true or false
  1370. */
  1371. static inline
  1372. bool is_primaryseg_rx_inprog(struct target_if_spectral *spectral)
  1373. {
  1374. return
  1375. ((spectral->ch_width != CH_WIDTH_160MHZ) ||
  1376. ((spectral->ch_width == CH_WIDTH_160MHZ) &&
  1377. ((spectral->spectral_gen == SPECTRAL_GEN2) ||
  1378. ((spectral->spectral_gen == SPECTRAL_GEN3) &&
  1379. (spectral->state_160mhz_delivery == SPECTRAL_REPORT_RX_PRIMARY80)))));
  1380. }
  1381. /**
  1382. * is_secondaryseg_rx_inprog() - Is secondary80 report processing is in progress
  1383. * @spectral: Pointer to Spectral
  1384. *
  1385. * Is secondary 80 report processing is in progress
  1386. *
  1387. * Return: true or false
  1388. */
  1389. static inline
  1390. bool is_secondaryseg_rx_inprog(struct target_if_spectral *spectral)
  1391. {
  1392. return
  1393. ((spectral->ch_width == CH_WIDTH_160MHZ) &&
  1394. ((spectral->spectral_gen == SPECTRAL_GEN2) ||
  1395. ((spectral->spectral_gen == SPECTRAL_GEN3) &&
  1396. (spectral->state_160mhz_delivery == SPECTRAL_REPORT_RX_SECONDARY80))));
  1397. }
  1398. /**
  1399. * target_if_160mhz_delivery_state_change() - State transition for 160Mhz
  1400. * Spectral
  1401. * @spectral: Pointer to spectral object
  1402. * @detector_id: Detector id
  1403. *
  1404. * Move the states of state machine for 160MHz spectral scan report receive
  1405. *
  1406. * Return: QDF_STATUS
  1407. */
  1408. QDF_STATUS
  1409. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  1410. uint8_t detector_id);
  1411. /**
  1412. * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled
  1413. * @arg: Pointer to handle for Spectral target_if internal private data
  1414. *
  1415. * Function to check whether Spectral is enabled
  1416. *
  1417. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1418. */
  1419. uint32_t target_if_sops_is_spectral_enabled(void *arg);
  1420. /**
  1421. * target_if_sops_is_spectral_active() - Get whether Spectral is active
  1422. * @arg: Pointer to handle for Spectral target_if internal private data
  1423. *
  1424. * Function to check whether Spectral is active
  1425. *
  1426. * Return: True if Spectral is active, false if Spectral is not active
  1427. */
  1428. uint32_t target_if_sops_is_spectral_active(void *arg);
  1429. /**
  1430. * target_if_sops_start_spectral_scan() - Start Spectral scan
  1431. * @arg: Pointer to handle for Spectral target_if internal private data
  1432. *
  1433. * Function to start spectral scan
  1434. *
  1435. * Return: 0 on success else failure
  1436. */
  1437. uint32_t target_if_sops_start_spectral_scan(void *arg);
  1438. /**
  1439. * target_if_sops_stop_spectral_scan() - Stop Spectral scan
  1440. * @arg: Pointer to handle for Spectral target_if internal private data
  1441. *
  1442. * Function to stop spectral scan
  1443. *
  1444. * Return: 0 in case of success, -1 on failure
  1445. */
  1446. uint32_t target_if_sops_stop_spectral_scan(void *arg);
  1447. /**
  1448. * target_if_spectral_get_extension_channel() - Get the current Extension
  1449. * channel (in MHz)
  1450. * @arg: Pointer to handle for Spectral target_if internal private data
  1451. *
  1452. * Return: Current Extension channel (in MHz) on success, 0 on failure or if
  1453. * extension channel is not present.
  1454. */
  1455. uint32_t target_if_spectral_get_extension_channel(void *arg);
  1456. /**
  1457. * target_if_spectral_get_current_channel() - Get the current channel (in MHz)
  1458. * @arg: Pointer to handle for Spectral target_if internal private data
  1459. *
  1460. * Return: Current channel (in MHz) on success, 0 on failure
  1461. */
  1462. uint32_t target_if_spectral_get_current_channel(void *arg);
  1463. /**
  1464. * target_if_spectral_reset_hw() - Reset the hardware
  1465. * @arg: Pointer to handle for Spectral target_if internal private data
  1466. *
  1467. * This is only a placeholder since it is not currently required in the offload
  1468. * case.
  1469. *
  1470. * Return: 0
  1471. */
  1472. uint32_t target_if_spectral_reset_hw(void *arg);
  1473. /**
  1474. * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
  1475. * Noisefloor history buffer
  1476. * @arg: Pointer to handle for Spectral target_if internal private data
  1477. * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
  1478. *
  1479. * This is only a placeholder since it is not currently required in the offload
  1480. * case.
  1481. *
  1482. * Return: 0
  1483. */
  1484. uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf);
  1485. /**
  1486. * target_if_spectral_get_ext_noisefloor() - Get the extension channel
  1487. * noisefloor
  1488. * @arg: Pointer to handle for Spectral target_if internal private data
  1489. *
  1490. * This is only a placeholder since it is not currently required in the offload
  1491. * case.
  1492. *
  1493. * Return: 0
  1494. */
  1495. int8_t target_if_spectral_get_ext_noisefloor(void *arg);
  1496. /**
  1497. * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
  1498. * @arg: Pointer to handle for Spectral target_if internal private data
  1499. *
  1500. * This is only a placeholder since it is not currently required in the offload
  1501. * case.
  1502. *
  1503. * Return: 0
  1504. */
  1505. int8_t target_if_spectral_get_ctl_noisefloor(void *arg);
  1506. /**
  1507. * target_if_spectral_get_capability() - Get whether a given Spectral hardware
  1508. * capability is available
  1509. * @arg: Pointer to handle for Spectral target_if internal private data
  1510. * @type: Spectral hardware capability type
  1511. *
  1512. * Return: True if the capability is available, false if the capability is not
  1513. * available
  1514. */
  1515. uint32_t target_if_spectral_get_capability(
  1516. void *arg, enum spectral_capability_type type);
  1517. /**
  1518. * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
  1519. * @arg: Pointer to handle for Spectral target_if internal private data
  1520. * @rxfilter: Rx filter to be used
  1521. *
  1522. * Note: This is only a placeholder function. It is not currently required since
  1523. * FW should be taking care of setting the required filters.
  1524. *
  1525. * Return: 0
  1526. */
  1527. uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter);
  1528. /**
  1529. * target_if_spectral_sops_configure_params() - Configure user supplied Spectral
  1530. * parameters
  1531. * @arg: Pointer to handle for Spectral target_if internal private data
  1532. * @params: Spectral parameters
  1533. *
  1534. * Return: 0 in case of success, -1 on failure
  1535. */
  1536. uint32_t target_if_spectral_sops_configure_params(
  1537. void *arg, struct spectral_config *params);
  1538. /**
  1539. * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
  1540. * @arg: Pointer to handle for Spectral target_if internal private data
  1541. *
  1542. * Note: This is only a placeholder function. It is not currently required since
  1543. * FW should be taking care of setting the required filters.
  1544. *
  1545. * Return: 0
  1546. */
  1547. uint32_t target_if_spectral_get_rxfilter(void *arg);
  1548. /**
  1549. * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
  1550. * functionality for the given pdev
  1551. * @pdev: Pointer to pdev object
  1552. *
  1553. * Return: None
  1554. */
  1555. void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
  1556. /**
  1557. * target_if_set_spectral_config() - Set spectral config
  1558. * @pdev: Pointer to pdev object
  1559. * @threshtype: config type
  1560. * @value: config value
  1561. *
  1562. * API to set spectral configurations
  1563. *
  1564. * Return: 0 in case of success, -1 on failure
  1565. */
  1566. int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
  1567. const uint32_t threshtype,
  1568. const uint32_t value);
  1569. /**
  1570. * target_if_pdev_spectral_init() - Initialize target_if Spectral
  1571. * functionality for the given pdev
  1572. * @pdev: Pointer to pdev object
  1573. *
  1574. * Return: On success, pointer to Spectral target_if internal private data, on
  1575. * failure, NULL
  1576. */
  1577. void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
  1578. /**
  1579. * target_if_spectral_sops_get_params() - Get user configured Spectral
  1580. * parameters
  1581. * @arg: Pointer to handle for Spectral target_if internal private data
  1582. * @params: Pointer to buffer into which Spectral parameters should be copied
  1583. *
  1584. * Return: 0 in case of success, -1 on failure
  1585. */
  1586. uint32_t target_if_spectral_sops_get_params(
  1587. void *arg, struct spectral_config *params);
  1588. /**
  1589. * target_if_init_spectral_capability() - Initialize Spectral capability
  1590. * @spectral: Pointer to Spectral target_if internal private data
  1591. *
  1592. * This is a workaround.
  1593. *
  1594. * Return: None
  1595. */
  1596. void target_if_init_spectral_capability(struct target_if_spectral *spectral);
  1597. /**
  1598. * target_if_start_spectral_scan() - Start spectral scan
  1599. * @pdev: Pointer to pdev object
  1600. *
  1601. * API to start spectral scan
  1602. *
  1603. * Return: 0 in case of success, -1 on failure
  1604. */
  1605. int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev);
  1606. /**
  1607. * target_if_get_spectral_config() - Get spectral configuration
  1608. * @pdev: Pointer to pdev object
  1609. * @param: Pointer to spectral_config structure in which the configuration
  1610. * should be returned
  1611. *
  1612. * API to get the current spectral configuration
  1613. *
  1614. * Return: 0 in case of success, -1 on failure
  1615. */
  1616. void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
  1617. struct spectral_config *param);
  1618. /**
  1619. * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
  1620. * parameters
  1621. * @spectral: Pointer to Spectral target_if internal private data
  1622. * @spectral_params: Pointer to Spectral parameters
  1623. *
  1624. * Enable use of desired Spectral parameters by configuring them into HW, and
  1625. * starting Spectral scan
  1626. *
  1627. * Return: 0 on success, 1 on failure
  1628. */
  1629. int target_if_spectral_scan_enable_params(
  1630. struct target_if_spectral *spectral, struct spectral_config *spectral_params);
  1631. /**
  1632. * target_if_is_spectral_active() - Get whether Spectral is active
  1633. * @pdev: Pointer to pdev object
  1634. *
  1635. * Return: True if Spectral is active, false if Spectral is not active
  1636. */
  1637. bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev);
  1638. /**
  1639. * target_if_is_spectral_enabled() - Get whether Spectral is enabled
  1640. * @pdev: Pointer to pdev object
  1641. *
  1642. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1643. */
  1644. bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev);
  1645. /**
  1646. * target_if_set_debug_level() - Set debug level for Spectral
  1647. * @pdev: Pointer to pdev object
  1648. * @debug_level: Debug level
  1649. *
  1650. * Return: 0 in case of success
  1651. */
  1652. int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev,
  1653. uint32_t debug_level);
  1654. /**
  1655. * target_if_get_debug_level() - Get debug level for Spectral
  1656. * @pdev: Pointer to pdev object
  1657. *
  1658. * Return: Current debug level
  1659. */
  1660. uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev);
  1661. /**
  1662. * target_if_get_spectral_capinfo() - Get Spectral capability information
  1663. * @pdev: Pointer to pdev object
  1664. * @outdata: Buffer into which data should be copied
  1665. *
  1666. * Return: void
  1667. */
  1668. void target_if_get_spectral_capinfo(
  1669. struct wlan_objmgr_pdev *pdev,
  1670. void *outdata);
  1671. /**
  1672. * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
  1673. * @pdev: Pointer to pdev object
  1674. * @outdata: Buffer into which data should be copied
  1675. *
  1676. * Return: void
  1677. */
  1678. void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
  1679. void *outdata);
  1680. /*
  1681. * target_if_spectral_send_tlv_to_host - target_if_spectral_send_tlv_to_host
  1682. * @spectral: Send the TLV information to Host
  1683. * @data: Pointer to the TLV
  1684. * @datalen: tlv length
  1685. *
  1686. * Return: Success/Failure
  1687. *
  1688. */
  1689. int target_if_spectral_send_tlv_to_host(
  1690. struct target_if_spectral *spectral,
  1691. uint8_t *data, uint32_t datalen);
  1692. void target_if_register_wmi_spectral_cmd_ops(
  1693. struct wlan_objmgr_pdev *pdev,
  1694. struct wmi_spectral_cmd_ops *cmd_ops);
  1695. QDF_STATUS
  1696. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  1697. uint8_t detector_id);
  1698. #ifdef DIRECT_BUF_RX_ENABLE
  1699. /**
  1700. * target_if_consume_sfft_report_gen3() - Process fft report for gen3
  1701. * @spectral: Pointer to spectral object
  1702. * @report: Pointer to spectral report
  1703. *
  1704. * Process fft report for gen3
  1705. *
  1706. * Return: Success/Failure
  1707. */
  1708. int
  1709. target_if_consume_spectral_report_gen3(
  1710. struct target_if_spectral *spectral,
  1711. struct spectral_report *report);
  1712. #endif
  1713. #ifdef WIN32
  1714. #pragma pack(pop, target_if_spectral)
  1715. #endif
  1716. #ifdef __ATTRIB_PACK
  1717. #undef __ATTRIB_PACK
  1718. #endif
  1719. #endif /* WLAN_CONV_SPECTRAL_ENABLE */
  1720. #endif /* _TARGET_IF_SPECTRAL_H_ */