target_if_spectral.h 64 KB

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