target_if_spectral.h 61 KB

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