target_if_spectral.h 62 KB

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