target_if_spectral.h 51 KB

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