target_if_spectral.h 53 KB

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