target_if_spectral.h 51 KB

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