target_if_spectral.h 62 KB

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