target_if_spectral.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333
  1. /*
  2. * Copyright (c) 2011,2017-2020 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. #include <wmi_unified_param.h>
  41. #define FREQ_OFFSET_10MHZ (10)
  42. #define FREQ_OFFSET_40MHZ (40)
  43. #define FREQ_OFFSET_80MHZ (80)
  44. #ifndef SPECTRAL_USE_NL_BCAST
  45. #define SPECTRAL_USE_NL_BCAST (0)
  46. #endif
  47. #define STATUS_PASS 1
  48. #define STATUS_FAIL 0
  49. #undef spectral_dbg_line
  50. #define spectral_dbg_line() \
  51. spectral_debug("----------------------------------------------------")
  52. #undef spectral_ops_not_registered
  53. #define spectral_ops_not_registered(str) \
  54. spectral_info("SPECTRAL : %s not registered\n", (str))
  55. #undef not_yet_implemented
  56. #define not_yet_implemented() \
  57. spectral_info("SPECTRAL : %s : %d Not yet implemented\n", \
  58. __func__, __LINE__)
  59. #define SPECTRAL_HT20_NUM_BINS 56
  60. #define SPECTRAL_HT20_FFT_LEN 56
  61. #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2)
  62. #define SPECTRAL_HT20_DATA_LEN 60
  63. #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3)
  64. #define SPECTRAL_HT40_TOTAL_NUM_BINS 128
  65. #define SPECTRAL_HT40_DATA_LEN 135
  66. #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3)
  67. #define SPECTRAL_HT40_FFT_LEN 128
  68. #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2)
  69. /*
  70. * Used for the SWAR to obtain approximate combined rssi
  71. * in secondary 80Mhz segment
  72. */
  73. #define OFFSET_CH_WIDTH_20 65
  74. #define OFFSET_CH_WIDTH_40 62
  75. #define OFFSET_CH_WIDTH_80 56
  76. #define OFFSET_CH_WIDTH_160 50
  77. /* Min and max for relevant Spectral params */
  78. #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN2 (1)
  79. #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2 (9)
  80. #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN3 (5)
  81. #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT (9)
  82. #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000 (10)
  83. #define SPECTRAL_PARAM_RPT_MODE_MIN (0)
  84. #define SPECTRAL_PARAM_RPT_MODE_MAX (3)
  85. /* DBR ring debug size for Spectral */
  86. #define SPECTRAL_DBR_RING_DEBUG_SIZE 512
  87. #ifdef BIG_ENDIAN_HOST
  88. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \
  89. int j; \
  90. uint32_t *src, *dest; \
  91. src = (uint32_t *)(srcp); \
  92. dest = (uint32_t *)(destp); \
  93. for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \
  94. *(dest + j) = qdf_le32_to_cpu(*(src + j)); \
  95. } \
  96. } while (0)
  97. #else
  98. #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \
  99. OS_MEMCPY((destp), (srcp), (len));
  100. #endif
  101. #define DUMMY_NF_VALUE (-123)
  102. /* 5 categories x (lower + upper) bands */
  103. #define MAX_INTERF 10
  104. #define HOST_MAX_ANTENNA 3
  105. /* Mask for time stamp from descriptor */
  106. #define SPECTRAL_TSMASK 0xFFFFFFFF
  107. #define SPECTRAL_SIGNATURE 0xdeadbeef
  108. /* Signature to write onto spectral buffer and then later validate */
  109. #define MEM_POISON_SIGNATURE (htobe32(0xdeadbeef))
  110. /* START of spectral GEN II HW specific details */
  111. #define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb
  112. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2 0xF9
  113. #define TLV_TAG_ADC_REPORT_GEN2 0xFA
  114. #define TLV_TAG_SEARCH_FFT_REPORT_GEN2 0xFB
  115. /**
  116. * enum spectral_160mhz_report_delivery_state - 160 MHz state machine states
  117. * @SPECTRAL_REPORT_WAIT_PRIMARY80: Wait for primary80 report
  118. * @SPECTRAL_REPORT_RX_PRIMARY80: Receive primary 80 report
  119. * @SPECTRAL_REPORT_WAIT_SECONDARY80: Wait for secondory 80 report
  120. * @SPECTRAL_REPORT_RX_SECONDARY80: Receive secondary 80 report
  121. */
  122. enum spectral_160mhz_report_delivery_state {
  123. SPECTRAL_REPORT_WAIT_PRIMARY80,
  124. SPECTRAL_REPORT_RX_PRIMARY80,
  125. SPECTRAL_REPORT_WAIT_SECONDARY80,
  126. SPECTRAL_REPORT_RX_SECONDARY80,
  127. };
  128. /**
  129. * enum spectral_detector_id - Spectral detector id
  130. * @SPECTRAL_DETECTOR_ID_0: Spectral detector 0
  131. * @SPECTRAL_DETECTOR_ID_1: Spectral detector 1
  132. * @SPECTRAL_DETECTOR_ID_2: Spectral detector 2
  133. * @SPECTRAL_DETECTOR_ID_MAX: Max Spectral detector ID
  134. * @SPECTRAL_DETECTOR_ID_INVALID: Invalid Spectral detector ID
  135. */
  136. enum spectral_detector_id {
  137. SPECTRAL_DETECTOR_ID_0,
  138. SPECTRAL_DETECTOR_ID_1,
  139. SPECTRAL_DETECTOR_ID_2,
  140. SPECTRAL_DETECTOR_ID_MAX,
  141. SPECTRAL_DETECTOR_ID_INVALID = 0xff,
  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_SUMMARY_REPORT_HDR_A_DETECTOR_ID_POS_GEN3 (29)
  227. #define SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3 (2)
  228. #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3 (0)
  229. #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3 (8)
  230. #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3 (18)
  231. #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3 (10)
  232. #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3 (31)
  233. #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3 (1)
  234. #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3_V1 (30)
  235. #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3_V1 (1)
  236. #define SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_POS_GEN3_V2 (16)
  237. #define SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_SIZE_GEN3_V2 (1)
  238. #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA)
  239. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02)
  240. #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03)
  241. #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4)
  242. #define NUM_SPECTRAL_DETECTORS_GEN3_V1 (3)
  243. #define NUM_SPECTRAL_DETECTORS_GEN3_V2 (2)
  244. #define FFT_REPORT_HEADER_LENGTH_GEN3_V2 (24)
  245. #define FFT_REPORT_HEADER_LENGTH_GEN3_V1 (16)
  246. #define NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V1 (0)
  247. #define NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V2 (16)
  248. #define PHYERR_HDR_SIG_POS \
  249. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_sig))
  250. #define PHYERR_HDR_TAG_POS \
  251. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_tag))
  252. #define SPECTRAL_FFT_BINS_POS \
  253. (offsetof(struct spectral_phyerr_fft_report_gen3, buf))
  254. /**
  255. * struct phyerr_info - spectral search fft report for gen3
  256. * @data: handle to phyerror buffer
  257. * @datalen: length of phyerror bufer
  258. * @p_rfqual: rf quality matrices
  259. * @p_chaninfo: pointer to chaninfo
  260. * @tsf64: 64 bit TSF
  261. * @acs_stats: acs stats
  262. */
  263. struct phyerr_info {
  264. uint8_t *data;
  265. uint32_t datalen;
  266. struct target_if_spectral_rfqual_info *p_rfqual;
  267. struct target_if_spectral_chan_info *p_chaninfo;
  268. uint64_t tsf64;
  269. struct target_if_spectral_acs_stats *acs_stats;
  270. };
  271. /**
  272. * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3
  273. * @timestamp: Timestamp at which fft report was generated
  274. * @fft_detector_id: Which radio generated this report
  275. * @fft_num: The FFT count number. Set to 0 for short FFT.
  276. * @fft_radar_check: NA for spectral
  277. * @fft_peak_sidx: Index of bin with maximum power
  278. * @fft_chn_idx: Rx chain index
  279. * @fft_base_pwr_db: Base power in dB
  280. * @fft_total_gain_db: Total gain in dB
  281. * @fft_num_str_bins_ib: Number of strong bins in the report
  282. * @fft_peak_mag: Peak magnitude
  283. * @fft_avgpwr_db: Average power in dB
  284. * @fft_relpwr_db: Relative power in dB
  285. */
  286. struct spectral_search_fft_info_gen3 {
  287. uint32_t timestamp;
  288. uint32_t fft_detector_id;
  289. uint32_t fft_num;
  290. uint32_t fft_radar_check;
  291. int32_t fft_peak_sidx;
  292. uint32_t fft_chn_idx;
  293. uint32_t fft_base_pwr_db;
  294. uint32_t fft_total_gain_db;
  295. uint32_t fft_num_str_bins_ib;
  296. int32_t fft_peak_mag;
  297. uint32_t fft_avgpwr_db;
  298. uint32_t fft_relpwr_db;
  299. };
  300. /**
  301. * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event
  302. * @fft_timestamp: Timestamp at which fft report was generated
  303. * @fft_hdr_sig: signature
  304. * @fft_hdr_tag: tag
  305. * @fft_hdr_length: length
  306. * @hdr_a: Header[0:31]
  307. * @hdr_b: Header[32:63]
  308. * @hdr_c: Header[64:95]
  309. * @resv: Header[96:127]
  310. * @buf: fft bins
  311. */
  312. struct spectral_phyerr_fft_report_gen3 {
  313. uint32_t fft_timestamp;
  314. #ifdef BIG_ENDIAN_HOST
  315. uint8_t fft_hdr_sig;
  316. uint8_t fft_hdr_tag;
  317. uint16_t fft_hdr_length;
  318. #else
  319. uint16_t fft_hdr_length;
  320. uint8_t fft_hdr_tag;
  321. uint8_t fft_hdr_sig;
  322. #endif /* BIG_ENDIAN_HOST */
  323. uint32_t hdr_a;
  324. uint32_t hdr_b;
  325. uint32_t hdr_c;
  326. uint32_t resv;
  327. uint8_t buf[0];
  328. } __ATTRIB_PACK;
  329. /**
  330. * struct sscan_report_fields_gen3 - Fields of spectral report
  331. * @sscan_agc_total_gain: The AGC total gain in DB.
  332. * @inband_pwr_db: The in-band power of the signal in 1/2 DB steps
  333. * @sscan_gainchange: This bit is set to 1 if a gainchange occurred during
  334. * the spectral scan FFT. Software may choose to
  335. * disregard the results.
  336. * @sscan_pri80: This is set to 1 to indicate that the Spectral scan was
  337. * performed on the pri80 segment. Software may choose to
  338. * disregard the FFT sample if this is set to 1 but detector ID
  339. * does not correspond to the ID for the pri80 segment.
  340. */
  341. struct sscan_report_fields_gen3 {
  342. uint8_t sscan_agc_total_gain;
  343. int16_t inband_pwr_db;
  344. uint8_t sscan_gainchange;
  345. uint8_t sscan_pri80;
  346. };
  347. /**
  348. * struct spectral_sscan_summary_report_gen3 - Spectral summary report
  349. * event
  350. * @sscan_timestamp: Timestamp at which fft report was generated
  351. * @sscan_hdr_sig: signature
  352. * @sscan_hdr_tag: tag
  353. * @sscan_hdr_length: length
  354. * @hdr_a: Header[0:31]
  355. * @resv: Header[32:63]
  356. * @hdr_b: Header[64:95]
  357. * @hdr_c: Header[96:127]
  358. */
  359. struct spectral_sscan_summary_report_gen3 {
  360. u_int32_t sscan_timestamp;
  361. #ifdef BIG_ENDIAN_HOST
  362. u_int8_t sscan_hdr_sig;
  363. u_int8_t sscan_hdr_tag;
  364. u_int16_t sscan_hdr_length;
  365. #else
  366. u_int16_t sscan_hdr_length;
  367. u_int8_t sscan_hdr_tag;
  368. u_int8_t sscan_hdr_sig;
  369. #endif /* BIG_ENDIAN_HOST */
  370. u_int32_t hdr_a;
  371. u_int32_t res1;
  372. u_int32_t hdr_b;
  373. u_int32_t hdr_c;
  374. } __ATTRIB_PACK;
  375. #ifdef DIRECT_BUF_RX_ENABLE
  376. /**
  377. * struct Spectral_report - spectral report
  378. * @data: Report buffer
  379. * @noisefloor: Noise floor values
  380. * @reset_delay: Time taken for warm reset in us
  381. * @cfreq1: center frequency 1
  382. * @cfreq2: center frequency 2
  383. * @ch_width: channel width
  384. */
  385. struct spectral_report {
  386. uint8_t *data;
  387. int32_t noisefloor[DBR_MAX_CHAINS];
  388. uint32_t reset_delay;
  389. uint32_t cfreq1;
  390. uint32_t cfreq2;
  391. uint32_t ch_width;
  392. };
  393. #endif
  394. /* END of spectral GEN III HW specific details */
  395. typedef signed char pwr_dbm;
  396. /**
  397. * enum spectral_gen - spectral hw generation
  398. * @SPECTRAL_GEN1 : spectral hw gen 1
  399. * @SPECTRAL_GEN2 : spectral hw gen 2
  400. * @SPECTRAL_GEN3 : spectral hw gen 3
  401. */
  402. enum spectral_gen {
  403. SPECTRAL_GEN1,
  404. SPECTRAL_GEN2,
  405. SPECTRAL_GEN3,
  406. };
  407. /**
  408. * enum spectral_fftbin_size_war - spectral fft bin size war
  409. * @SPECTRAL_FFTBIN_SIZE_NO_WAR : No WAR applicable for Spectral FFT bin size
  410. * @SPECTRAL_FFTBIN_SIZE_2BYTE_TO_1BYTE : Spectral FFT bin size: Retain only
  411. * least significant byte from 2 byte
  412. * FFT bin transferred by HW
  413. * @SPECTRAL_FFTBIN_SIZE_4BYTE_TO_1BYTE : Spectral FFT bin size: Retain only
  414. * least significant byte from 4 byte
  415. * FFT bin transferred by HW
  416. */
  417. enum spectral_fftbin_size_war {
  418. SPECTRAL_FFTBIN_SIZE_NO_WAR = 0,
  419. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE = 1,
  420. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE = 2,
  421. };
  422. /**
  423. * enum spectral_report_format_version - This represents the report format
  424. * version number within each Spectral generation.
  425. * @SPECTRAL_REPORT_FORMAT_VERSION_1 : version 1
  426. * @SPECTRAL_REPORT_FORMAT_VERSION_2 : version 2
  427. */
  428. enum spectral_report_format_version {
  429. SPECTRAL_REPORT_FORMAT_VERSION_1,
  430. SPECTRAL_REPORT_FORMAT_VERSION_2,
  431. };
  432. /**
  433. * struct spectral_fft_bin_len_adj_swar - Encapsulate information required for
  434. * Spectral FFT bin length adjusting software WARS.
  435. * @inband_fftbin_size_adj: Whether to carry out FFT bin size adjustment for
  436. * in-band report format. This would be required on some chipsets under the
  437. * following circumstances: In report mode 2 only the in-band bins are DMA'ed.
  438. * Scatter/gather is used. However, the HW generates all bins, not just in-band,
  439. * and reports the number of bins accordingly. The subsystem arranging for the
  440. * DMA cannot change this value. On such chipsets the adjustment required at the
  441. * host driver is to check if report format is 2, and if so halve the number of
  442. * bins reported to get the number actually DMA'ed.
  443. * @null_fftbin_adj: Whether to remove NULL FFT bins for report mode (1) in
  444. * which only summary of metrics for each completed FFT + spectral scan summary
  445. * report are to be provided. This would be required on some chipsets under the
  446. * following circumstances: In report mode 1, HW reports a length corresponding
  447. * to all bins, and provides bins with value 0. This is because the subsystem
  448. * arranging for the FFT information does not arrange for DMA of FFT bin values
  449. * (as expected), but cannot arrange for a smaller length to be reported by HW.
  450. * In these circumstances, the driver would have to disregard the NULL bins and
  451. * report a bin count of 0 to higher layers.
  452. * @packmode_fftbin_size_adj: Pack mode in HW refers to packing of each Spectral
  453. * FFT bin into 2 bytes. But due to a bug HW reports 2 times the expected length
  454. * when packmode is enabled. This SWAR compensates this bug by dividing the
  455. * length with 2.
  456. * @fftbin_size_war: Type of FFT bin size SWAR
  457. */
  458. struct spectral_fft_bin_len_adj_swar {
  459. u_int8_t inband_fftbin_size_adj;
  460. u_int8_t null_fftbin_adj;
  461. uint8_t packmode_fftbin_size_adj;
  462. enum spectral_fftbin_size_war fftbin_size_war;
  463. };
  464. /**
  465. * struct spectral_report_params - Parameters related to format of Spectral
  466. * report.
  467. * @version: This represents the report format version number within each
  468. * Spectral generation.
  469. * @ssumaary_padding_bytes: Number of bytes of padding after Spectral summary
  470. * report
  471. * @fft_report_hdr_len: Number of bytes in the header of the FFT report. This
  472. * has to be subtracted from the length field of FFT report to find the length
  473. * of FFT bins.
  474. * @fragmentation_160: This indicates whether Spectral reports in 160/80p80 is
  475. * fragmented.
  476. * @max_agile_ch_width: Maximum agile BW supported by the target
  477. * @detid_mode_table: Detector ID to Spectral scan mode table
  478. * @num_spectral_detectors: Total number of Spectral detectors
  479. * @marker: Describes the boundaries of pri80, 5 MHz and sec80 bins
  480. */
  481. struct spectral_report_params {
  482. enum spectral_report_format_version version;
  483. uint8_t ssumaary_padding_bytes;
  484. uint8_t fft_report_hdr_len;
  485. bool fragmentation_160[SPECTRAL_SCAN_MODE_MAX];
  486. enum phy_ch_width max_agile_ch_width;
  487. enum spectral_scan_mode detid_mode_table[SPECTRAL_DETECTOR_ID_MAX];
  488. uint8_t num_spectral_detectors;
  489. struct spectral_fft_bin_markers_160_165mhz
  490. marker[SPECTRAL_SCAN_MODE_MAX];
  491. };
  492. /**
  493. * struct spectral_param_min_max - Spectral parameter minimum and maximum values
  494. * @fft_size_min: Minimum value of fft_size
  495. * @fft_size_max: Maximum value of fft_size for each BW
  496. */
  497. struct spectral_param_min_max {
  498. uint16_t fft_size_min;
  499. uint16_t fft_size_max[CH_WIDTH_MAX];
  500. };
  501. /**
  502. * struct spectral_timestamp_swar - Spectral time stamp WAR related parameters
  503. * @timestamp_war_offset: Offset to be added to correct timestamp
  504. * @target_reset_count: Number of times target exercised the reset routine
  505. * @last_fft_timestamp: last fft report timestamp
  506. */
  507. struct spectral_timestamp_war {
  508. uint32_t timestamp_war_offset[SPECTRAL_SCAN_MODE_MAX];
  509. uint64_t target_reset_count;
  510. uint32_t last_fft_timestamp[SPECTRAL_SCAN_MODE_MAX];
  511. };
  512. #if ATH_PERF_PWR_OFFLOAD
  513. /**
  514. * enum target_if_spectral_info - Enumerations for specifying which spectral
  515. * information (among parameters and states)
  516. * is desired.
  517. * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active
  518. * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled
  519. * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params
  520. */
  521. enum target_if_spectral_info {
  522. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  523. TARGET_IF_SPECTRAL_INFO_ENABLED,
  524. TARGET_IF_SPECTRAL_INFO_PARAMS,
  525. };
  526. #endif /* ATH_PERF_PWR_OFFLOAD */
  527. /* forward declaration */
  528. struct target_if_spectral;
  529. /**
  530. * struct target_if_spectral_chan_info - Channel information
  531. * @center_freq1: center frequency 1 in MHz
  532. * @center_freq2: center frequency 2 in MHz -valid only for
  533. * 11ACVHT 80PLUS80 mode
  534. * @chan_width: channel width in MHz
  535. */
  536. struct target_if_spectral_chan_info {
  537. uint16_t center_freq1;
  538. uint16_t center_freq2;
  539. uint8_t chan_width;
  540. };
  541. /**
  542. * struct target_if_spectral_acs_stats - EACS stats from spectral samples
  543. * @nfc_ctl_rssi: Control chan rssi
  544. * @nfc_ext_rssi: Extension chan rssi
  545. * @ctrl_nf: Control chan Noise Floor
  546. * @ext_nf: Extension chan Noise Floor
  547. */
  548. struct target_if_spectral_acs_stats {
  549. int8_t nfc_ctl_rssi;
  550. int8_t nfc_ext_rssi;
  551. int8_t ctrl_nf;
  552. int8_t ext_nf;
  553. };
  554. /**
  555. * struct target_if_spectral_perchain_rssi_info - per chain rssi info
  556. * @rssi_pri20: Rssi of primary 20 Mhz
  557. * @rssi_sec20: Rssi of secondary 20 Mhz
  558. * @rssi_sec40: Rssi of secondary 40 Mhz
  559. * @rssi_sec80: Rssi of secondary 80 Mhz
  560. */
  561. struct target_if_spectral_perchain_rssi_info {
  562. int8_t rssi_pri20;
  563. int8_t rssi_sec20;
  564. int8_t rssi_sec40;
  565. int8_t rssi_sec80;
  566. };
  567. /**
  568. * struct target_if_spectral_rfqual_info - RF measurement information
  569. * @rssi_comb: RSSI Information
  570. * @pc_rssi_info: XXX : For now, we know we are getting information
  571. * for only 4 chains at max. For future extensions
  572. * use a define
  573. * @noise_floor: Noise floor information
  574. */
  575. struct target_if_spectral_rfqual_info {
  576. int8_t rssi_comb;
  577. struct target_if_spectral_perchain_rssi_info pc_rssi_info[4];
  578. int16_t noise_floor[4];
  579. };
  580. #define GET_TARGET_IF_SPECTRAL_OPS(spectral) \
  581. ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops)))
  582. /**
  583. * struct target_if_spectral_ops - spectral low level ops table
  584. * @get_tsf64: Get 64 bit TSF value
  585. * @get_capability: Get capability info
  586. * @set_rxfilter: Set rx filter
  587. * @get_rxfilter: Get rx filter
  588. * @is_spectral_active: Check whether icm is active
  589. * @is_spectral_enabled: Check whether spectral is enabled
  590. * @start_spectral_scan: Start spectral scan
  591. * @stop_spectral_scan: Stop spectral scan
  592. * @get_extension_channel: Get extension channel
  593. * @get_ctl_noisefloor: Get control noise floor
  594. * @get_ext_noisefloor: Get extension noise floor
  595. * @configure_spectral: Set spectral configurations
  596. * @get_spectral_config: Get spectral configurations
  597. * @get_ent_spectral_mask: Get spectral mask
  598. * @get_mac_address: Get mac address
  599. * @get_current_channel: Get current channel
  600. * @reset_hw: Reset HW
  601. * @get_chain_noise_floor: Get Channel noise floor
  602. * @spectral_process_phyerr: Process phyerr event
  603. * @process_spectral_report: Process spectral report
  604. */
  605. struct target_if_spectral_ops {
  606. uint64_t (*get_tsf64)(void *arg);
  607. uint32_t (*get_capability)(
  608. void *arg, enum spectral_capability_type type);
  609. uint32_t (*set_rxfilter)(void *arg, int rxfilter);
  610. uint32_t (*get_rxfilter)(void *arg);
  611. uint32_t (*is_spectral_active)(void *arg,
  612. enum spectral_scan_mode smode);
  613. uint32_t (*is_spectral_enabled)(void *arg,
  614. enum spectral_scan_mode smode);
  615. uint32_t (*start_spectral_scan)(void *arg,
  616. enum spectral_scan_mode smode,
  617. enum spectral_cp_error_code *err);
  618. uint32_t (*stop_spectral_scan)(void *arg,
  619. enum spectral_scan_mode smode);
  620. uint32_t (*get_extension_channel)(void *arg,
  621. enum spectral_scan_mode smode);
  622. int8_t (*get_ctl_noisefloor)(void *arg);
  623. int8_t (*get_ext_noisefloor)(void *arg);
  624. uint32_t (*configure_spectral)(
  625. void *arg,
  626. struct spectral_config *params,
  627. enum spectral_scan_mode smode);
  628. uint32_t (*get_spectral_config)(
  629. void *arg,
  630. struct spectral_config *params,
  631. enum spectral_scan_mode smode);
  632. uint32_t (*get_ent_spectral_mask)(void *arg);
  633. uint32_t (*get_mac_address)(void *arg, char *addr);
  634. uint32_t (*get_current_channel)(void *arg,
  635. enum spectral_scan_mode smode);
  636. uint32_t (*reset_hw)(void *arg);
  637. uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf);
  638. int (*spectral_process_phyerr)(struct target_if_spectral *spectral,
  639. uint8_t *data, uint32_t datalen,
  640. struct target_if_spectral_rfqual_info *p_rfqual,
  641. struct target_if_spectral_chan_info *p_chaninfo,
  642. uint64_t tsf64,
  643. struct target_if_spectral_acs_stats *acs_stats);
  644. int (*process_spectral_report)(struct wlan_objmgr_pdev *pdev,
  645. void *payload);
  646. };
  647. /**
  648. * struct target_if_spectral_stats - spectral stats info
  649. * @num_spectral_detects: Total num. of spectral detects
  650. * @total_phy_errors: Total number of phyerrors
  651. * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets
  652. * @pri_phy_errors: Phyerrors in primary channel
  653. * @ext_phy_errors: Phyerrors in secondary channel
  654. * @dc_phy_errors: Phyerrors due to dc
  655. * @early_ext_phy_errors: Early secondary channel phyerrors
  656. * @bwinfo_errors: Bandwidth info errors
  657. * @datalen_discards: Invalid data length errors, seen in gen1 chipsets
  658. * @rssi_discards bw: Indicates reports dropped due to RSSI threshold
  659. * @last_reset_tstamp: Last reset time stamp
  660. */
  661. struct target_if_spectral_stats {
  662. uint32_t num_spectral_detects;
  663. uint32_t total_phy_errors;
  664. uint32_t owl_phy_errors;
  665. uint32_t pri_phy_errors;
  666. uint32_t ext_phy_errors;
  667. uint32_t dc_phy_errors;
  668. uint32_t early_ext_phy_errors;
  669. uint32_t bwinfo_errors;
  670. uint32_t datalen_discards;
  671. uint32_t rssi_discards;
  672. uint64_t last_reset_tstamp;
  673. };
  674. /**
  675. * struct target_if_spectral_event - spectral event structure
  676. * @se_ts: Original 15 bit recv timestamp
  677. * @se_full_ts: 64-bit full timestamp from interrupt time
  678. * @se_rssi: Rssi of spectral event
  679. * @se_bwinfo: Rssi of spectral event
  680. * @se_dur: Duration of spectral pulse
  681. * @se_chanindex: Channel of event
  682. * @se_list: List of spectral events
  683. */
  684. struct target_if_spectral_event {
  685. uint32_t se_ts;
  686. uint64_t se_full_ts;
  687. uint8_t se_rssi;
  688. uint8_t se_bwinfo;
  689. uint8_t se_dur;
  690. uint8_t se_chanindex;
  691. STAILQ_ENTRY(spectral_event) se_list;
  692. };
  693. /**
  694. * struct target_if_chain_noise_pwr_info - Noise power info for each channel
  695. * @rptcount: Count of reports in pwr array
  696. * @un_cal_nf: Uncalibrated noise floor
  697. * @factory_cal_nf: Noise floor as calibrated at the factory for module
  698. * @median_pwr: Median power (median of pwr array)
  699. * @pwr: Power reports
  700. */
  701. struct target_if_chain_noise_pwr_info {
  702. int rptcount;
  703. pwr_dbm un_cal_nf;
  704. pwr_dbm factory_cal_nf;
  705. pwr_dbm median_pwr;
  706. pwr_dbm pwr[];
  707. } __ATTRIB_PACK;
  708. /**
  709. * struct target_if_spectral_chan_stats - Channel information
  710. * @cycle_count: Cycle count
  711. * @channel_load: Channel load
  712. * @per: Period
  713. * @noisefloor: Noise floor
  714. * @comp_usablity: Computed usability
  715. * @maxregpower: Maximum allowed regulatary power
  716. * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
  717. * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz
  718. */
  719. struct target_if_spectral_chan_stats {
  720. int cycle_count;
  721. int channel_load;
  722. int per;
  723. int noisefloor;
  724. uint16_t comp_usablity;
  725. int8_t maxregpower;
  726. uint16_t comp_usablity_sec80;
  727. int8_t maxregpower_sec80;
  728. };
  729. #if ATH_PERF_PWR_OFFLOAD
  730. /**
  731. * struct target_if_spectral_cache - Cache used to minimize WMI operations
  732. * in offload architecture
  733. * @osc_spectral_enabled: Whether Spectral is enabled
  734. * @osc_spectral_active: Whether spectral is active
  735. * XXX: Ideally, we should NOT cache this
  736. * since the hardware can self clear the bit,
  737. * the firmware can possibly stop spectral due to
  738. * intermittent off-channel activity, etc
  739. * A WMI read command should be introduced to handle
  740. * this This will be discussed.
  741. * @osc_params: Spectral parameters
  742. * @osc_is_valid: Whether the cache is valid
  743. */
  744. struct target_if_spectral_cache {
  745. uint8_t osc_spectral_enabled;
  746. uint8_t osc_spectral_active;
  747. struct spectral_config osc_params;
  748. uint8_t osc_is_valid;
  749. };
  750. /**
  751. * struct target_if_spectral_param_state_info - Structure used to represent and
  752. * manage spectral information
  753. * (parameters and states)
  754. * @osps_lock: Lock to synchronize accesses to information
  755. * @osps_cache: Cacheable' information
  756. */
  757. struct target_if_spectral_param_state_info {
  758. qdf_spinlock_t osps_lock;
  759. struct target_if_spectral_cache osps_cache;
  760. /* XXX - Non-cacheable information goes here, in the future */
  761. };
  762. #endif /* ATH_PERF_PWR_OFFLOAD */
  763. struct vdev_spectral_configure_params;
  764. struct vdev_spectral_enable_params;
  765. /**
  766. * struct spectral_wmi_ops - structure used holding the operations
  767. * related to Spectral WMI
  768. * @wmi_spectral_configure_cmd_send: Configure Spectral parameters
  769. * @wmi_spectral_enable_cmd_send: Enable/Disable Spectral
  770. * @wmi_spectral_crash_inject: Inject FW crash
  771. * @wmi_extract_pdev_sscan_fw_cmd_fixed_param: Extract Fixed params from
  772. * start scan response event
  773. * @wmi_extract_pdev_sscan_fft_bin_index: Extract TLV which describes FFT
  774. * bin indices from start scan response event
  775. * @wmi_unified_register_event_handler: Register WMI event handler
  776. * @wmi_unified_unregister_event_handler: Unregister WMI event handler
  777. */
  778. struct spectral_wmi_ops {
  779. QDF_STATUS (*wmi_spectral_configure_cmd_send)(
  780. wmi_unified_t wmi_hdl,
  781. struct vdev_spectral_configure_params *param);
  782. QDF_STATUS (*wmi_spectral_enable_cmd_send)(
  783. wmi_unified_t wmi_hdl,
  784. struct vdev_spectral_enable_params *param);
  785. QDF_STATUS (*wmi_spectral_crash_inject)(
  786. wmi_unified_t wmi_handle, struct crash_inject *param);
  787. QDF_STATUS (*wmi_extract_pdev_sscan_fw_cmd_fixed_param)(
  788. wmi_unified_t wmi_handle, uint8_t *evt_buf,
  789. struct spectral_startscan_resp_params *param);
  790. QDF_STATUS (*wmi_extract_pdev_sscan_fft_bin_index)(
  791. wmi_unified_t wmi_handle, uint8_t *evt_buf,
  792. struct spectral_fft_bin_markers_160_165mhz *param);
  793. int (*wmi_unified_register_event_handler)(
  794. wmi_unified_t wmi_handle,
  795. wmi_conv_event_id event_id,
  796. wmi_unified_event_handler handler_func,
  797. uint8_t rx_ctx);
  798. int (*wmi_unified_unregister_event_handler)(wmi_unified_t wmi_handle,
  799. wmi_conv_event_id event_id);
  800. };
  801. /**
  802. * struct spectral_tgt_ops - structure used holding the operations
  803. * related to target operations
  804. * @tgt_get_psoc_from_scn_hdl: Function to get psoc from scn
  805. */
  806. struct spectral_tgt_ops {
  807. struct wlan_objmgr_psoc *(*tgt_get_psoc_from_scn_hdl)(void *scn_handle);
  808. };
  809. /**
  810. * struct spectral_param_properties - structure holding Spectral
  811. * parameter properties
  812. * @supported: Parameter is supported or not
  813. * @common_all_modes: Parameter should be common for all modes or not
  814. */
  815. struct spectral_param_properties {
  816. bool supported;
  817. bool common_all_modes;
  818. };
  819. /**
  820. * struct target_if_finite_spectral_scan_params - Parameters related to finite
  821. * Spectral scan
  822. * @finite_spectral_scan: Indicates the Spectrl scan is finite/infinite
  823. * @num_reports_expected: Number of Spectral reports expected from target for a
  824. * finite Spectral scan
  825. */
  826. struct target_if_finite_spectral_scan_params {
  827. bool finite_spectral_scan;
  828. uint32_t num_reports_expected;
  829. };
  830. /**
  831. * struct target_if_spectral - main spectral structure
  832. * @pdev: Pointer to pdev
  833. * @spectral_ops: Target if internal Spectral low level operations table
  834. * @capability: Spectral capabilities structure
  835. * @properties: Spectral parameter properties per mode
  836. * @spectral_lock: Lock used for internal Spectral operations
  837. * @vdev_id: VDEV id for all spectral modes
  838. * @spectral_curchan_radindex: Current channel spectral index
  839. * @spectral_extchan_radindex: Extension channel spectral index
  840. * @spectraldomain: Current Spectral domain
  841. * @spectral_proc_phyerr: Flags to process for PHY errors
  842. * @spectral_defaultparams: Default PHY params per Spectral stat
  843. * @spectral_stats: Spectral related stats
  844. * @events: Events structure
  845. * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel?
  846. * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI?
  847. * @sc_spectral_20_40_mode: Is AP in 20-40 mode?
  848. * @sc_spectral_noise_pwr_cal: Noise power cal required?
  849. * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA?
  850. * @upper_is_control: Upper segment is primary
  851. * @upper_is_extension: Upper segment is secondary
  852. * @lower_is_control: Lower segment is primary
  853. * @lower_is_extension: Lower segment is secondary
  854. * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral
  855. * mute test
  856. * @spectral_numbins: Number of bins
  857. * @spectral_fft_len: FFT length
  858. * @spectral_data_len: Total phyerror report length
  859. * @lb_edge_extrabins: Number of extra bins on left band edge
  860. * @rb_edge_extrabins: Number of extra bins on right band edge
  861. * @spectral_max_index_offset: Max FFT index offset (20 MHz mode)
  862. * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode)
  863. * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode)
  864. * @spectral_dc_index: At which index DC is present
  865. * @send_single_packet: Deprecated
  866. * @spectral_sent_msg: Indicates whether we send report to upper layers
  867. * @params: Spectral parameters
  868. * @last_capture_time: Indicates timestamp of previouse report
  869. * @num_spectral_data: Number of Spectral samples received in current session
  870. * @total_spectral_data: Total number of Spectral samples received
  871. * @max_rssi: Maximum RSSI
  872. * @detects_control_channel: NA
  873. * @detects_extension_channel: NA
  874. * @detects_below_dc: NA
  875. * @detects_above_dc: NA
  876. * @sc_scanning: Indicates active wifi scan
  877. * @sc_spectral_scan: Indicates active specral scan
  878. * @sc_spectral_full_scan: Deprecated
  879. * @scan_start_tstamp: Deprecated
  880. * @last_tstamp: Deprecated
  881. * @first_tstamp: Deprecated
  882. * @spectral_samp_count: Deprecated
  883. * @sc_spectral_samp_count: Deprecated
  884. * @noise_pwr_reports_reqd: Number of noise power reports required
  885. * @noise_pwr_reports_recv: Number of noise power reports received
  886. * @noise_pwr_reports_lock: Lock used for Noise power report processing
  887. * @noise_pwr_chain_ctl: Noise power report - control channel
  888. * @noise_pwr_chain_ext: Noise power report - extension channel
  889. * @chaninfo: Channel statistics
  890. * @tsf64: Latest TSF Value
  891. * @param_info: Offload architecture Spectral parameter cache information
  892. * @ch_width: Indicates Channel Width 20/40/80/160 MHz for each Spectral mode
  893. * @diag_stats: Diagnostic statistics
  894. * @is_160_format: Indicates whether information provided by HW is in altered
  895. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  896. * @is_lb_edge_extrabins_format: Indicates whether information provided by
  897. * HW has 4 extra bins, at left band edge, for report mode 2
  898. * @is_rb_edge_extrabins_format: Indicates whether information provided
  899. * by HW has 4 extra bins, at right band edge, for report mode 2
  900. * @is_sec80_rssi_war_required: Indicates whether the software workaround is
  901. * required to obtain approximate combined RSSI for secondary 80Mhz segment
  902. * @simctx: Spectral Simulation context
  903. * @spectral_gen: Spectral hardware generation
  904. * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware
  905. * generation
  906. * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV
  907. * header, for the given hardware generation
  908. * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV
  909. * header, for the given hardware generation
  910. * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
  911. * generation
  912. * @nl_cb: Netlink callbacks
  913. * @use_nl_bcast: Whether to use Netlink broadcast/unicast
  914. * @send_phy_data: Send data to the application layer for a particular msg type
  915. * @len_adj_swar: Spectral fft bin length adjustment SWAR related info
  916. * @timestamp_war: Spectral time stamp WAR related info
  917. * @dbr_ring_debug: Whether Spectral DBR ring debug is enabled
  918. * @dbr_buff_debug: Whether Spectral DBR buffer debug is enabled
  919. * @direct_dma_support: Whether Direct-DMA is supported on the current radio
  920. * @prev_tstamp: Timestamp of the previously received sample, which has to be
  921. * compared with the current tstamp to check descrepancy
  922. * @rparams: Parameters related to Spectral report structure
  923. * @param_min_max: Spectral parameter's minimum and maximum values
  924. * @finite_scan: Parameters for finite Spectral scan
  925. */
  926. struct target_if_spectral {
  927. struct wlan_objmgr_pdev *pdev_obj;
  928. struct target_if_spectral_ops spectral_ops;
  929. struct spectral_caps capability;
  930. struct spectral_param_properties
  931. properties[SPECTRAL_SCAN_MODE_MAX][SPECTRAL_PARAM_MAX];
  932. qdf_spinlock_t spectral_lock;
  933. uint8_t vdev_id[SPECTRAL_SCAN_MODE_MAX];
  934. int16_t spectral_curchan_radindex;
  935. int16_t spectral_extchan_radindex;
  936. uint32_t spectraldomain;
  937. uint32_t spectral_proc_phyerr;
  938. struct spectral_config spectral_defaultparams;
  939. struct target_if_spectral_stats spectral_stats;
  940. struct target_if_spectral_event *events;
  941. unsigned int sc_spectral_ext_chan_ok:1,
  942. sc_spectral_combined_rssi_ok:1,
  943. sc_spectral_20_40_mode:1,
  944. sc_spectral_noise_pwr_cal:1,
  945. sc_spectral_non_edma:1;
  946. int upper_is_control;
  947. int upper_is_extension;
  948. int lower_is_control;
  949. int lower_is_extension;
  950. uint8_t sc_spectraltest_ieeechan;
  951. int spectral_numbins;
  952. int spectral_fft_len;
  953. int spectral_data_len;
  954. /*
  955. * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  956. * delivered. However, there can be additional bins reported for
  957. * AR900B version 2.0 and QCA9984 as described next:
  958. *
  959. * AR900B version 2.0: An additional tone is processed on the right
  960. * hand side in order to facilitate detection of radar pulses out to
  961. * the extreme band-edge of the channel frequency. Since the HW design
  962. * processes four tones at a time, this requires one additional Dword
  963. * to be added to the search FFT report.
  964. *
  965. * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary +
  966. * 1x-oversampled bins (in-band) per FFT, then 8 more bins
  967. * (4 more on left side and 4 more on right side)are added.
  968. */
  969. int lb_edge_extrabins;
  970. int rb_edge_extrabins;
  971. int spectral_max_index_offset;
  972. int spectral_upper_max_index_offset;
  973. int spectral_lower_max_index_offset;
  974. int spectral_dc_index;
  975. int send_single_packet;
  976. int spectral_sent_msg;
  977. int classify_scan;
  978. qdf_timer_t classify_timer;
  979. struct spectral_config params[SPECTRAL_SCAN_MODE_MAX];
  980. bool params_valid[SPECTRAL_SCAN_MODE_MAX];
  981. struct spectral_classifier_params classifier_params;
  982. int last_capture_time;
  983. int num_spectral_data;
  984. int total_spectral_data;
  985. int max_rssi;
  986. int detects_control_channel;
  987. int detects_extension_channel;
  988. int detects_below_dc;
  989. int detects_above_dc;
  990. int sc_scanning;
  991. int sc_spectral_scan;
  992. int sc_spectral_full_scan;
  993. uint64_t scan_start_tstamp;
  994. uint32_t last_tstamp;
  995. uint32_t first_tstamp;
  996. uint32_t spectral_samp_count;
  997. uint32_t sc_spectral_samp_count;
  998. int noise_pwr_reports_reqd;
  999. int noise_pwr_reports_recv;
  1000. qdf_spinlock_t noise_pwr_reports_lock;
  1001. struct target_if_chain_noise_pwr_info
  1002. *noise_pwr_chain_ctl[HOST_MAX_ANTENNA];
  1003. struct target_if_chain_noise_pwr_info
  1004. *noise_pwr_chain_ext[HOST_MAX_ANTENNA];
  1005. uint64_t tsf64;
  1006. #if ATH_PERF_PWR_OFFLOAD
  1007. struct target_if_spectral_param_state_info
  1008. param_info[SPECTRAL_SCAN_MODE_MAX];
  1009. #endif
  1010. enum phy_ch_width ch_width[SPECTRAL_SCAN_MODE_MAX];
  1011. struct spectral_diag_stats diag_stats;
  1012. bool is_160_format;
  1013. bool is_lb_edge_extrabins_format;
  1014. bool is_rb_edge_extrabins_format;
  1015. bool is_sec80_rssi_war_required;
  1016. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  1017. void *simctx;
  1018. #endif
  1019. enum spectral_gen spectral_gen;
  1020. uint8_t hdr_sig_exp;
  1021. uint8_t tag_sscan_summary_exp;
  1022. uint8_t tag_sscan_fft_exp;
  1023. uint8_t tlvhdr_size;
  1024. struct spectral_nl_cb nl_cb;
  1025. bool use_nl_bcast;
  1026. int (*send_phy_data)(struct wlan_objmgr_pdev *pdev,
  1027. enum spectral_msg_type smsg_type);
  1028. struct spectral_fft_bin_len_adj_swar len_adj_swar;
  1029. struct spectral_timestamp_war timestamp_war;
  1030. enum spectral_160mhz_report_delivery_state
  1031. state_160mhz_delivery[SPECTRAL_SCAN_MODE_MAX];
  1032. bool dbr_ring_debug;
  1033. bool dbr_buff_debug;
  1034. bool direct_dma_support;
  1035. uint32_t prev_tstamp;
  1036. struct spectral_report_params rparams;
  1037. struct spectral_param_min_max param_min_max;
  1038. struct target_if_finite_spectral_scan_params
  1039. finite_scan[SPECTRAL_SCAN_MODE_MAX];
  1040. };
  1041. /**
  1042. * struct target_if_psoc_spectral - Target if psoc Spectral object
  1043. * @psoc_obj: psoc object
  1044. * @wmi_ops: Spectral WMI operations
  1045. */
  1046. struct target_if_psoc_spectral {
  1047. struct wlan_objmgr_psoc *psoc_obj;
  1048. struct spectral_wmi_ops wmi_ops;
  1049. };
  1050. /**
  1051. * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol
  1052. * data format
  1053. * @rssi: RSSI (except for secondary 80 segment)
  1054. * @rssi_sec80: RSSI for secondary 80 segment
  1055. * @lower_rssi: RSSI of lower band
  1056. * @upper_rssi: RSSI of upper band
  1057. * @chain_ctl_rssi: RSSI for control channel, for all antennas
  1058. * @chain_ext_rssi: RSSI for extension channel, for all antennas
  1059. * @bwinfo: bandwidth info
  1060. * @data_len: length of FFT data (except for secondary 80 segment)
  1061. * @data_len_sec80: length of FFT data for secondary 80 segment
  1062. * @tstamp: timestamp
  1063. * @last_tstamp: last time stamp
  1064. * @max_mag: maximum magnitude (except for secondary 80 segment)
  1065. * @max_mag_sec80: maximum magnitude for secondary 80 segment
  1066. * @max_index: index of max magnitude (except for secondary 80 segment)
  1067. * @max_index_sec80: index of max magnitude for secondary 80 segment
  1068. * @max_exp: max exp
  1069. * @peak: peak frequency (obsolete)
  1070. * @pwr_count: number of FFT bins (except for secondary 80 segment)
  1071. * @pwr_count_5mhz: number of FFT bins in extra 5 MHz in
  1072. * 165 MHz/restricted 80p80 mode
  1073. * @pwr_count_sec80: number of FFT bins in secondary 80 segment
  1074. * @nb_lower: This is deprecated
  1075. * @nb_upper: This is deprecated
  1076. * @max_upper_index: index of max mag in upper band
  1077. * @max_lower_index: index of max mag in lower band
  1078. * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment)
  1079. * @bin_pwr_data_5mhz: Contains FFT magnitudes for the extra 5 MHz
  1080. * in 165 MHz/restricted 80p80 mode
  1081. * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment
  1082. * @freq: Center frequency of primary 20MHz channel in MHz
  1083. * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz
  1084. * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz
  1085. * @agile_freq1: Center frequency in MHz of the entire span(for 80+80 MHz
  1086. * agile Scan it is primary 80 MHz span) across which
  1087. * Agile Spectral is carried out. Applicable only for Agile
  1088. * Spectral samples.
  1089. * @agile_freq2: Center frequency in MHz of the secondary 80 MHz span
  1090. * across which Agile Spectral is carried out. Applicable
  1091. * only for Agile Spectral samples in 80+80 MHz mode.
  1092. * @freq_loading: spectral control duty cycles
  1093. * @noise_floor: current noise floor (except for secondary 80 segment)
  1094. * @noise_floor_sec80: current noise floor for secondary 80 segment
  1095. * @interf_list: List of interfernce sources
  1096. * @classifier_params: classifier parameters
  1097. * @sc: classifier parameters
  1098. * @pri80ind: Indication from hardware that the sample was received on the
  1099. * primary 80 MHz segment. If this is set when smode =
  1100. * SPECTRAL_SCAN_MODE_AGILE, it indicates that Spectral was carried out on
  1101. * pri80 instead of the Agile frequency due to a channel switch - Software may
  1102. * choose to ignore the sample in this case.
  1103. * @pri80ind_sec80: Indication from hardware that the sample was received on the
  1104. * primary 80 MHz segment instead of the secondary 80 MHz segment due to a
  1105. * channel switch - Software may choose to ignore the sample if this is set.
  1106. * Applicable only if smode = SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz
  1107. * Spectral operation and if the chipset supports fragmented 160/80+80 MHz
  1108. * operation.
  1109. * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of 160MHz
  1110. * it will be primary 80 segment's timestamp as both primary & secondary
  1111. * segment's timestamps are expected to be almost equal
  1112. * @timestamp_war_offset: Offset calculated based on reset_delay and
  1113. * last_raw_stamp. It will be added to raw_timestamp to get tstamp.
  1114. * @raw_timestamp: FFT timestamp reported by HW on primary segment.
  1115. * @raw_timestamp_sec80: FFT timestamp reported by HW on secondary 80 segment.
  1116. * @reset_delay: Time gap between the last spectral report before reset and the
  1117. * end of reset.
  1118. * @target_reset_count: Indicates the the number of times the target went
  1119. * through reset routine after spectral was enabled.
  1120. */
  1121. struct target_if_samp_msg_params {
  1122. int8_t rssi;
  1123. int8_t rssi_sec80;
  1124. int8_t lower_rssi;
  1125. int8_t upper_rssi;
  1126. int8_t chain_ctl_rssi[HOST_MAX_ANTENNA];
  1127. int8_t chain_ext_rssi[HOST_MAX_ANTENNA];
  1128. uint16_t bwinfo;
  1129. uint16_t datalen;
  1130. uint16_t datalen_sec80;
  1131. uint32_t tstamp;
  1132. uint32_t last_tstamp;
  1133. uint16_t max_mag;
  1134. uint16_t max_mag_sec80;
  1135. uint16_t max_index;
  1136. uint16_t max_index_sec80;
  1137. uint8_t max_exp;
  1138. int peak;
  1139. int pwr_count;
  1140. int pwr_count_5mhz;
  1141. int pwr_count_sec80;
  1142. int8_t nb_lower;
  1143. int8_t nb_upper;
  1144. uint16_t max_lower_index;
  1145. uint16_t max_upper_index;
  1146. uint8_t *bin_pwr_data;
  1147. uint8_t *bin_pwr_data_5mhz;
  1148. uint8_t *bin_pwr_data_sec80;
  1149. uint16_t freq;
  1150. uint16_t vhtop_ch_freq_seg1;
  1151. uint16_t vhtop_ch_freq_seg2;
  1152. uint16_t agile_freq1;
  1153. uint16_t agile_freq2;
  1154. uint16_t freq_loading;
  1155. int16_t noise_floor;
  1156. int16_t noise_floor_sec80;
  1157. struct interf_src_rsp interf_list;
  1158. struct spectral_classifier_params classifier_params;
  1159. struct ath_softc *sc;
  1160. uint8_t agc_total_gain;
  1161. uint8_t agc_total_gain_sec80;
  1162. uint8_t gainchange;
  1163. uint8_t gainchange_sec80;
  1164. enum spectral_scan_mode smode;
  1165. uint8_t pri80ind;
  1166. uint8_t pri80ind_sec80;
  1167. uint32_t last_raw_timestamp;
  1168. uint32_t timestamp_war_offset;
  1169. uint32_t raw_timestamp;
  1170. uint32_t raw_timestamp_sec80;
  1171. uint32_t reset_delay;
  1172. uint32_t target_reset_count;
  1173. };
  1174. #ifdef WLAN_CONV_SPECTRAL_ENABLE
  1175. /**
  1176. * target_if_spectral_dump_fft() - Dump Spectral FFT
  1177. * @pfft: Pointer to Spectral Phyerr FFT
  1178. * @fftlen: FFT length
  1179. *
  1180. * Return: Success or failure
  1181. */
  1182. int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen);
  1183. /**
  1184. * target_if_dbg_print_samp_param() - Print contents of SAMP struct
  1185. * @p: Pointer to SAMP message
  1186. *
  1187. * Return: Void
  1188. */
  1189. void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p);
  1190. /**
  1191. * target_if_get_offset_swar_sec80() - Get offset for SWAR according to
  1192. * the channel width
  1193. * @channel_width: Channel width
  1194. *
  1195. * Return: Offset for SWAR
  1196. */
  1197. uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
  1198. /**
  1199. * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops
  1200. * @tx_ops: Tx Ops
  1201. *
  1202. * Return: void
  1203. */
  1204. void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
  1205. /**
  1206. * target_if_spectral_create_samp_msg() - Create the spectral samp message
  1207. * @spectral : Pointer to spectral internal structure
  1208. * @params : spectral samp message parameters
  1209. *
  1210. * API to create the spectral samp message
  1211. *
  1212. * Return: void
  1213. */
  1214. void target_if_spectral_create_samp_msg(
  1215. struct target_if_spectral *spectral,
  1216. struct target_if_samp_msg_params *params);
  1217. /**
  1218. * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3
  1219. * @pdev: Pointer to pdev object
  1220. * @payload: Pointer to spectral report
  1221. *
  1222. * Process phyerror event for gen3
  1223. *
  1224. * Return: Success/Failure
  1225. */
  1226. int target_if_spectral_process_report_gen3(
  1227. struct wlan_objmgr_pdev *pdev,
  1228. void *buf);
  1229. /**
  1230. * target_if_process_phyerr_gen2() - Process PHY Error for gen2
  1231. * @spectral: Pointer to Spectral object
  1232. * @data: Pointer to phyerror event buffer
  1233. * @datalen: Data length
  1234. * @p_rfqual: RF quality info
  1235. * @p_chaninfo: Channel info
  1236. * @tsf64: 64 bit tsf timestamp
  1237. * @acs_stats: ACS stats
  1238. *
  1239. * Process PHY Error for gen2
  1240. *
  1241. * Return: Success/Failure
  1242. */
  1243. int target_if_process_phyerr_gen2(
  1244. struct target_if_spectral *spectral,
  1245. uint8_t *data,
  1246. uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
  1247. struct target_if_spectral_chan_info *p_chaninfo,
  1248. uint64_t tsf64,
  1249. struct target_if_spectral_acs_stats *acs_stats);
  1250. /**
  1251. * target_if_spectral_send_intf_found_msg() - Indicate to application layer that
  1252. * interference has been found
  1253. * @pdev: Pointer to pdev
  1254. * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found
  1255. * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled
  1256. *
  1257. * Send message to application layer
  1258. * indicating that interference has been found
  1259. *
  1260. * Return: None
  1261. */
  1262. void target_if_spectral_send_intf_found_msg(
  1263. struct wlan_objmgr_pdev *pdev,
  1264. uint16_t cw_int, uint32_t dcs_enabled);
  1265. /**
  1266. * target_if_stop_spectral_scan() - Stop spectral scan
  1267. * @pdev: Pointer to pdev object
  1268. * @smode: Spectral scan mode
  1269. * @err: Pointer to error code
  1270. *
  1271. * API to stop the current on-going spectral scan
  1272. *
  1273. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  1274. */
  1275. QDF_STATUS target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev,
  1276. const enum spectral_scan_mode smode,
  1277. enum spectral_cp_error_code *err);
  1278. /**
  1279. * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral
  1280. * operations
  1281. * @spectral: Pointer to Spectral target_if internal private data
  1282. * @smode: spectral scan mode
  1283. *
  1284. * Spectral operates on pdev. However, in order to retrieve some WLAN
  1285. * properties, a vdev is required. To facilitate this, the function returns the
  1286. * first vdev in our pdev. The caller should release the reference to the vdev
  1287. * once it is done using it.
  1288. * TODO: If the framework later provides an API to obtain the first active
  1289. * vdev, then it would be preferable to use this API.
  1290. *
  1291. * Return: Pointer to vdev on success, NULL on failure
  1292. */
  1293. struct wlan_objmgr_vdev *target_if_spectral_get_vdev(
  1294. struct target_if_spectral *spectral,
  1295. enum spectral_scan_mode smode);
  1296. /**
  1297. * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2
  1298. * @phdr: Pointer to Spectral Phyerr Header
  1299. *
  1300. * Dump Spectral header
  1301. *
  1302. * Return: Success/Failure
  1303. */
  1304. int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr);
  1305. /**
  1306. * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI
  1307. * for Secondary 80 segment
  1308. * @spectral: Pointer to spectral object
  1309. * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment
  1310. *
  1311. * Get approximate combined RSSI for Secondary 80 segment
  1312. *
  1313. * Return: Combined RSSI for secondary 80Mhz segment
  1314. */
  1315. int8_t target_if_get_combrssi_sec80_seg_gen2(
  1316. struct target_if_spectral *spectral,
  1317. struct spectral_search_fft_info_gen2 *p_sfft_sec80);
  1318. /**
  1319. * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2
  1320. * @ptlv: Pointer to Spectral Phyerr TLV
  1321. * @is_160_format: Indicates 160 format
  1322. *
  1323. * Dump Spectral TLV for gen2
  1324. *
  1325. * Return: Success/Failure
  1326. */
  1327. int target_if_spectral_dump_tlv_gen2(
  1328. struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format);
  1329. /**
  1330. * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral
  1331. * related PHY Error for gen2
  1332. * @data: Pointer to phyerror buffer
  1333. * @datalen: Data length
  1334. * @is_160_format: Indicates 160 format
  1335. *
  1336. * Dump Spectral related PHY Error for gen2
  1337. *
  1338. * Return: Success/Failure
  1339. */
  1340. int target_if_spectral_dump_phyerr_data_gen2(
  1341. uint8_t *data,
  1342. uint32_t datalen,
  1343. bool is_160_format);
  1344. /**
  1345. * target_if_dbg_print_samp_msg() - Print contents of SAMP Message
  1346. * @p: Pointer to SAMP message
  1347. *
  1348. * Print contents of SAMP Message
  1349. *
  1350. * Return: Void
  1351. */
  1352. void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg);
  1353. /**
  1354. * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
  1355. * Spectral data
  1356. * @pdev: Pointer to pdev
  1357. *
  1358. * Return: Handle to target_if internal Spectral data on success, NULL on
  1359. * failure
  1360. */
  1361. static inline
  1362. struct target_if_spectral *get_target_if_spectral_handle_from_pdev(
  1363. struct wlan_objmgr_pdev *pdev)
  1364. {
  1365. struct target_if_spectral *spectral;
  1366. struct wlan_objmgr_psoc *psoc;
  1367. struct wlan_lmac_if_rx_ops *rx_ops;
  1368. if (!pdev) {
  1369. spectral_err("pdev is null");
  1370. return NULL;
  1371. }
  1372. psoc = wlan_pdev_get_psoc(pdev);
  1373. if (!psoc) {
  1374. spectral_err("psoc is null");
  1375. return NULL;
  1376. }
  1377. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1378. if (!rx_ops) {
  1379. spectral_err("rx_ops is null");
  1380. return NULL;
  1381. }
  1382. spectral = (struct target_if_spectral *)
  1383. rx_ops->sptrl_rx_ops.sptrlro_get_pdev_target_handle(pdev);
  1384. return spectral;
  1385. }
  1386. /**
  1387. * get_target_if_spectral_handle_from_psoc() - Get handle to psoc target_if
  1388. * internal Spectral data
  1389. * @psoc: Pointer to psoc
  1390. *
  1391. * Return: Handle to target_if psoc internal Spectral data on success, NULL on
  1392. * failure
  1393. */
  1394. static inline
  1395. struct target_if_psoc_spectral *get_target_if_spectral_handle_from_psoc(
  1396. struct wlan_objmgr_psoc *psoc)
  1397. {
  1398. struct wlan_lmac_if_rx_ops *rx_ops;
  1399. struct target_if_psoc_spectral *psoc_spectral;
  1400. if (!psoc) {
  1401. spectral_err("psoc is null");
  1402. return NULL;
  1403. }
  1404. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1405. if (!rx_ops) {
  1406. spectral_err("rx_ops is null");
  1407. return NULL;
  1408. }
  1409. psoc_spectral = (struct target_if_psoc_spectral *)
  1410. rx_ops->sptrl_rx_ops.sptrlro_get_psoc_target_handle(psoc);
  1411. return psoc_spectral;
  1412. }
  1413. /**
  1414. * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a
  1415. * given vdev
  1416. * @pdev: Pointer to vdev
  1417. *
  1418. * Get the operating channel frequency of a given vdev
  1419. *
  1420. * Return: Operating channel frequency of a vdev
  1421. */
  1422. static inline
  1423. int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev)
  1424. {
  1425. struct wlan_objmgr_psoc *psoc = NULL;
  1426. struct wlan_lmac_if_rx_ops *rx_ops;
  1427. psoc = wlan_vdev_get_psoc(vdev);
  1428. if (!psoc) {
  1429. spectral_err("psoc is NULL");
  1430. return -EINVAL;
  1431. }
  1432. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1433. if (!rx_ops) {
  1434. spectral_err("rx_ops is null");
  1435. return -EINVAL;
  1436. }
  1437. return rx_ops->sptrl_rx_ops.sptrlro_vdev_get_chan_freq(
  1438. vdev);
  1439. }
  1440. /**
  1441. * target_if_vdev_get_chan_freq_seg2() - Get center frequency of secondary 80 of
  1442. * given vdev
  1443. * @vdev: Pointer to vdev
  1444. *
  1445. * Get the center frequency of secondary 80 of given vdev
  1446. *
  1447. * Return: center frequency of secondary 80
  1448. */
  1449. static inline
  1450. int16_t target_if_vdev_get_chan_freq_seg2(struct wlan_objmgr_vdev *vdev)
  1451. {
  1452. struct wlan_objmgr_psoc *psoc = NULL;
  1453. struct wlan_lmac_if_rx_ops *rx_ops;
  1454. psoc = wlan_vdev_get_psoc(vdev);
  1455. if (!psoc) {
  1456. spectral_err("psoc is NULL");
  1457. return -EINVAL;
  1458. }
  1459. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1460. if (!rx_ops) {
  1461. spectral_err("rx_ops is null");
  1462. return -EINVAL;
  1463. }
  1464. return rx_ops->sptrl_rx_ops.sptrlro_vdev_get_chan_freq_seg2(vdev);
  1465. }
  1466. /**
  1467. * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a
  1468. * given vdev
  1469. * @pdev: Pointer to vdev
  1470. *
  1471. * Get the operating channel bandwidth of a given vdev
  1472. *
  1473. * Return: channel bandwidth enumeration corresponding to the vdev
  1474. */
  1475. static inline
  1476. enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev)
  1477. {
  1478. struct wlan_objmgr_psoc *psoc = NULL;
  1479. enum phy_ch_width ch_width;
  1480. struct wlan_lmac_if_rx_ops *rx_ops;
  1481. psoc = wlan_vdev_get_psoc(vdev);
  1482. if (!psoc) {
  1483. spectral_err("psoc is NULL");
  1484. return CH_WIDTH_INVALID;
  1485. }
  1486. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1487. if (!rx_ops) {
  1488. spectral_err("rx_ops is null");
  1489. return CH_WIDTH_INVALID;
  1490. }
  1491. ch_width = rx_ops->sptrl_rx_ops.sptrlro_vdev_get_ch_width(vdev);
  1492. if (ch_width == CH_WIDTH_160MHZ) {
  1493. int16_t cfreq2;
  1494. cfreq2 = target_if_vdev_get_chan_freq_seg2(vdev);
  1495. if (cfreq2 < 0) {
  1496. spectral_err("Invalid value for cfreq2 %d", cfreq2);
  1497. return CH_WIDTH_INVALID;
  1498. }
  1499. /* Use non zero cfreq2 to identify 80p80 */
  1500. if (cfreq2)
  1501. ch_width = CH_WIDTH_80P80MHZ;
  1502. }
  1503. return ch_width;
  1504. }
  1505. /**
  1506. * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary
  1507. * 20 MHz channel for a given vdev
  1508. * @pdev: Pointer to vdev
  1509. *
  1510. * Get the frequency of secondary 20Mhz channel for a given vdev
  1511. *
  1512. * Return: Frequency of secondary 20Mhz channel for a given vdev
  1513. */
  1514. static inline
  1515. int target_if_vdev_get_sec20chan_freq_mhz(
  1516. struct wlan_objmgr_vdev *vdev,
  1517. uint16_t *sec20chan_freq)
  1518. {
  1519. struct wlan_objmgr_psoc *psoc = NULL;
  1520. struct wlan_lmac_if_rx_ops *rx_ops;
  1521. psoc = wlan_vdev_get_psoc(vdev);
  1522. if (!psoc) {
  1523. spectral_err("psoc is NULL");
  1524. return -EINVAL;
  1525. }
  1526. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1527. if (!rx_ops) {
  1528. spectral_err("rx_ops is null");
  1529. return -EINVAL;
  1530. }
  1531. return rx_ops->sptrl_rx_ops.
  1532. sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq);
  1533. }
  1534. /**
  1535. * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask
  1536. * @pdev: Pointer to pdev
  1537. * @spectral_rx_chainmask: Spectral Rx chainmask
  1538. *
  1539. * Return: None
  1540. */
  1541. static inline
  1542. void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev,
  1543. uint8_t spectral_rx_chainmask)
  1544. {
  1545. struct wlan_objmgr_psoc *psoc = NULL;
  1546. struct target_if_spectral *spectral = NULL;
  1547. enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
  1548. struct wlan_lmac_if_rx_ops *rx_ops;
  1549. psoc = wlan_pdev_get_psoc(pdev);
  1550. if (!psoc) {
  1551. spectral_err("psoc is NULL");
  1552. return;
  1553. }
  1554. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  1555. if (!rx_ops) {
  1556. spectral_err("rx_ops is null");
  1557. return;
  1558. }
  1559. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1560. spectral_err("Invalid Spectral mode %u", smode);
  1561. return;
  1562. }
  1563. if (rx_ops->sptrl_rx_ops.
  1564. sptrlro_spectral_is_feature_disabled(psoc)) {
  1565. spectral_info("Spectral is disabled");
  1566. return;
  1567. }
  1568. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1569. if (!spectral) {
  1570. spectral_err("Spectral target if object is null");
  1571. return;
  1572. }
  1573. /* set chainmask for all the modes */
  1574. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  1575. spectral->params[smode].ss_chn_mask = spectral_rx_chainmask;
  1576. }
  1577. /**
  1578. * target_if_spectral_process_phyerr() - Process Spectral PHY error
  1579. * @pdev: Pointer to pdev
  1580. * @data: PHY error data received from FW
  1581. * @datalen: Length of data
  1582. * @p_rfqual: Pointer to RF Quality information
  1583. * @p_chaninfo: Pointer to channel information
  1584. * @tsf: TSF time instance at which the Spectral sample was received
  1585. * @acs_stats: ACS stats
  1586. *
  1587. * Process Spectral PHY error by extracting necessary information from the data
  1588. * sent by FW, and send the extracted information to application layer.
  1589. *
  1590. * Return: None
  1591. */
  1592. static inline
  1593. void target_if_spectral_process_phyerr(
  1594. struct wlan_objmgr_pdev *pdev,
  1595. uint8_t *data, uint32_t datalen,
  1596. struct target_if_spectral_rfqual_info *p_rfqual,
  1597. struct target_if_spectral_chan_info *p_chaninfo,
  1598. uint64_t tsf64,
  1599. struct target_if_spectral_acs_stats *acs_stats)
  1600. {
  1601. struct target_if_spectral *spectral = NULL;
  1602. struct target_if_spectral_ops *p_sops = NULL;
  1603. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1604. if (!spectral) {
  1605. spectral_err("Spectral target if object is null");
  1606. return;
  1607. }
  1608. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1609. p_sops->spectral_process_phyerr(spectral, data, datalen,
  1610. p_rfqual, p_chaninfo,
  1611. tsf64, acs_stats);
  1612. }
  1613. static QDF_STATUS
  1614. target_if_get_spectral_msg_type(enum spectral_scan_mode smode,
  1615. enum spectral_msg_type *msg_type) {
  1616. switch (smode) {
  1617. case SPECTRAL_SCAN_MODE_NORMAL:
  1618. *msg_type = SPECTRAL_MSG_NORMAL_MODE;
  1619. break;
  1620. case SPECTRAL_SCAN_MODE_AGILE:
  1621. *msg_type = SPECTRAL_MSG_AGILE_MODE;
  1622. break;
  1623. default:
  1624. spectral_err("Invalid spectral mode");
  1625. return QDF_STATUS_E_FAILURE;
  1626. }
  1627. return QDF_STATUS_SUCCESS;
  1628. }
  1629. static inline bool
  1630. is_ch_width_160_or_80p80(enum phy_ch_width ch_width)
  1631. {
  1632. return (ch_width == CH_WIDTH_160MHZ || ch_width == CH_WIDTH_80P80MHZ);
  1633. }
  1634. /**
  1635. * init_160mhz_delivery_state_machine() - Initialize 160MHz Spectral
  1636. * state machine
  1637. * @spectral: Pointer to Spectral
  1638. *
  1639. * Initialize 160MHz Spectral state machine
  1640. *
  1641. * Return: void
  1642. */
  1643. static inline void
  1644. init_160mhz_delivery_state_machine(struct target_if_spectral *spectral)
  1645. {
  1646. uint8_t smode;
  1647. smode = 0;
  1648. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  1649. spectral->state_160mhz_delivery[smode] =
  1650. SPECTRAL_REPORT_WAIT_PRIMARY80;
  1651. }
  1652. /**
  1653. * reset_160mhz_delivery_state_machine() - Reset 160MHz Spectral state machine
  1654. * @spectral: Pointer to Spectral
  1655. *
  1656. * Reset 160MHz Spectral state machine
  1657. *
  1658. * Return: void
  1659. */
  1660. static inline void
  1661. reset_160mhz_delivery_state_machine(struct target_if_spectral *spectral,
  1662. enum spectral_scan_mode smode)
  1663. {
  1664. enum spectral_msg_type smsg_type;
  1665. QDF_STATUS ret;
  1666. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1667. spectral_err_rl("Invalid Spectral mode %d", smode);
  1668. return;
  1669. }
  1670. if (is_ch_width_160_or_80p80(spectral->ch_width[smode])) {
  1671. spectral->state_160mhz_delivery[smode] =
  1672. SPECTRAL_REPORT_WAIT_PRIMARY80;
  1673. ret = target_if_get_spectral_msg_type(smode, &smsg_type);
  1674. if (QDF_IS_STATUS_ERROR(ret)) {
  1675. spectral_err("Failed to get spectral message type");
  1676. return;
  1677. }
  1678. spectral->nl_cb.free_sbuff(spectral->pdev_obj,
  1679. smsg_type);
  1680. }
  1681. }
  1682. /**
  1683. * is_secondaryseg_expected() - Is waiting for secondary 80 report
  1684. * @spectral: Pointer to Spectral
  1685. * @smode: Spectral scan mode
  1686. *
  1687. * Return true if secondary 80 report expected and mode is 160 MHz
  1688. *
  1689. * Return: true or false
  1690. */
  1691. static inline
  1692. bool is_secondaryseg_expected(struct target_if_spectral *spectral,
  1693. enum spectral_scan_mode smode)
  1694. {
  1695. return
  1696. (is_ch_width_160_or_80p80(spectral->ch_width[smode]) &&
  1697. spectral->rparams.fragmentation_160[smode] &&
  1698. (spectral->state_160mhz_delivery[smode] ==
  1699. SPECTRAL_REPORT_WAIT_SECONDARY80));
  1700. }
  1701. /**
  1702. * is_primaryseg_expected() - Is waiting for primary 80 report
  1703. * @spectral: Pointer to Spectral
  1704. * @smode: Spectral scan mode
  1705. *
  1706. * Return true if mode is 160 Mhz and primary 80 report expected or
  1707. * mode is not 160 Mhz
  1708. *
  1709. * Return: true or false
  1710. */
  1711. static inline
  1712. bool is_primaryseg_expected(struct target_if_spectral *spectral,
  1713. enum spectral_scan_mode smode)
  1714. {
  1715. return
  1716. (!is_ch_width_160_or_80p80(spectral->ch_width[smode]) ||
  1717. !spectral->rparams.fragmentation_160[smode] ||
  1718. (spectral->state_160mhz_delivery[smode] ==
  1719. SPECTRAL_REPORT_WAIT_PRIMARY80));
  1720. }
  1721. /**
  1722. * is_primaryseg_rx_inprog() - Is primary 80 report processing is in progress
  1723. * @spectral: Pointer to Spectral
  1724. * @smode: Spectral scan mode
  1725. *
  1726. * Is primary 80 report processing is in progress
  1727. *
  1728. * Return: true or false
  1729. */
  1730. static inline
  1731. bool is_primaryseg_rx_inprog(struct target_if_spectral *spectral,
  1732. enum spectral_scan_mode smode)
  1733. {
  1734. return
  1735. (!is_ch_width_160_or_80p80(spectral->ch_width[smode]) ||
  1736. spectral->spectral_gen == SPECTRAL_GEN2 ||
  1737. (spectral->spectral_gen == SPECTRAL_GEN3 &&
  1738. (!spectral->rparams.fragmentation_160[smode] ||
  1739. spectral->state_160mhz_delivery[smode] ==
  1740. SPECTRAL_REPORT_RX_PRIMARY80)));
  1741. }
  1742. /**
  1743. * is_secondaryseg_rx_inprog() - Is secondary80 report processing is in progress
  1744. * @spectral: Pointer to Spectral
  1745. * @smode: Spectral scan mode
  1746. *
  1747. * Is secondary 80 report processing is in progress
  1748. *
  1749. * Return: true or false
  1750. */
  1751. static inline
  1752. bool is_secondaryseg_rx_inprog(struct target_if_spectral *spectral,
  1753. enum spectral_scan_mode smode)
  1754. {
  1755. return
  1756. (is_ch_width_160_or_80p80(spectral->ch_width[smode]) &&
  1757. (spectral->spectral_gen == SPECTRAL_GEN2 ||
  1758. ((spectral->spectral_gen == SPECTRAL_GEN3) &&
  1759. (!spectral->rparams.fragmentation_160[smode] ||
  1760. spectral->state_160mhz_delivery[smode] ==
  1761. SPECTRAL_REPORT_RX_SECONDARY80))));
  1762. }
  1763. /**
  1764. * target_if_160mhz_delivery_state_change() - State transition for 160Mhz
  1765. * Spectral
  1766. * @spectral: Pointer to spectral object
  1767. * @smode: Spectral scan mode
  1768. * @detector_id: Detector id
  1769. *
  1770. * Move the states of state machine for 160MHz spectral scan report receive
  1771. *
  1772. * Return: QDF_STATUS
  1773. */
  1774. QDF_STATUS
  1775. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  1776. enum spectral_scan_mode smode,
  1777. uint8_t detector_id);
  1778. /**
  1779. * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled
  1780. * @arg: Pointer to handle for Spectral target_if internal private data
  1781. * @smode: Spectral scan mode
  1782. *
  1783. * Function to check whether Spectral is enabled
  1784. *
  1785. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1786. */
  1787. uint32_t target_if_sops_is_spectral_enabled(void *arg,
  1788. enum spectral_scan_mode smode);
  1789. /**
  1790. * target_if_sops_is_spectral_active() - Get whether Spectral is active
  1791. * @arg: Pointer to handle for Spectral target_if internal private data
  1792. * @smode: Spectral scan mode
  1793. *
  1794. * Function to check whether Spectral is active
  1795. *
  1796. * Return: True if Spectral is active, false if Spectral is not active
  1797. */
  1798. uint32_t target_if_sops_is_spectral_active(void *arg,
  1799. enum spectral_scan_mode smode);
  1800. /**
  1801. * target_if_sops_start_spectral_scan() - Start Spectral scan
  1802. * @arg: Pointer to handle for Spectral target_if internal private data
  1803. * @smode: Spectral scan mode
  1804. * @err: Pointer to error code
  1805. *
  1806. * Function to start spectral scan
  1807. *
  1808. * Return: 0 on success else failure
  1809. */
  1810. uint32_t target_if_sops_start_spectral_scan(void *arg,
  1811. enum spectral_scan_mode smode,
  1812. enum spectral_cp_error_code *err);
  1813. /**
  1814. * target_if_sops_stop_spectral_scan() - Stop Spectral scan
  1815. * @arg: Pointer to handle for Spectral target_if internal private data
  1816. * @smode: Spectral scan mode
  1817. *
  1818. * Function to stop spectral scan
  1819. *
  1820. * Return: 0 in case of success, -1 on failure
  1821. */
  1822. uint32_t target_if_sops_stop_spectral_scan(void *arg,
  1823. enum spectral_scan_mode smode);
  1824. /**
  1825. * target_if_spectral_get_extension_channel() - Get the current Extension
  1826. * channel (in MHz)
  1827. * @arg: Pointer to handle for Spectral target_if internal private data
  1828. * @smode: Spectral scan mode
  1829. *
  1830. * Return: Current Extension channel (in MHz) on success, 0 on failure or if
  1831. * extension channel is not present.
  1832. */
  1833. uint32_t
  1834. target_if_spectral_get_extension_channel(void *arg,
  1835. enum spectral_scan_mode smode);
  1836. /**
  1837. * target_if_spectral_get_current_channel() - Get the current channel (in MHz)
  1838. * @arg: Pointer to handle for Spectral target_if internal private data
  1839. * @smode: Spectral scan mode
  1840. *
  1841. * Return: Current channel (in MHz) on success, 0 on failure
  1842. */
  1843. uint32_t
  1844. target_if_spectral_get_current_channel(void *arg,
  1845. enum spectral_scan_mode smode);
  1846. /**
  1847. * target_if_spectral_reset_hw() - Reset the hardware
  1848. * @arg: Pointer to handle for Spectral target_if internal private data
  1849. *
  1850. * This is only a placeholder since it is not currently required in the offload
  1851. * case.
  1852. *
  1853. * Return: 0
  1854. */
  1855. uint32_t target_if_spectral_reset_hw(void *arg);
  1856. /**
  1857. * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
  1858. * Noisefloor history buffer
  1859. * @arg: Pointer to handle for Spectral target_if internal private data
  1860. * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
  1861. *
  1862. * This is only a placeholder since it is not currently required in the offload
  1863. * case.
  1864. *
  1865. * Return: 0
  1866. */
  1867. uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf);
  1868. /**
  1869. * target_if_spectral_get_ext_noisefloor() - Get the extension channel
  1870. * noisefloor
  1871. * @arg: Pointer to handle for Spectral target_if internal private data
  1872. *
  1873. * This is only a placeholder since it is not currently required in the offload
  1874. * case.
  1875. *
  1876. * Return: 0
  1877. */
  1878. int8_t target_if_spectral_get_ext_noisefloor(void *arg);
  1879. /**
  1880. * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
  1881. * @arg: Pointer to handle for Spectral target_if internal private data
  1882. *
  1883. * This is only a placeholder since it is not currently required in the offload
  1884. * case.
  1885. *
  1886. * Return: 0
  1887. */
  1888. int8_t target_if_spectral_get_ctl_noisefloor(void *arg);
  1889. /**
  1890. * target_if_spectral_get_capability() - Get whether a given Spectral hardware
  1891. * capability is available
  1892. * @arg: Pointer to handle for Spectral target_if internal private data
  1893. * @type: Spectral hardware capability type
  1894. *
  1895. * Return: True if the capability is available, false if the capability is not
  1896. * available
  1897. */
  1898. uint32_t target_if_spectral_get_capability(
  1899. void *arg, enum spectral_capability_type type);
  1900. /**
  1901. * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
  1902. * @arg: Pointer to handle for Spectral target_if internal private data
  1903. * @rxfilter: Rx filter to be used
  1904. *
  1905. * Note: This is only a placeholder function. It is not currently required since
  1906. * FW should be taking care of setting the required filters.
  1907. *
  1908. * Return: 0
  1909. */
  1910. uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter);
  1911. /**
  1912. * target_if_spectral_sops_configure_params() - Configure user supplied Spectral
  1913. * parameters
  1914. * @arg: Pointer to handle for Spectral target_if internal private data
  1915. * @params: Spectral parameters
  1916. * @smode: Spectral scan mode
  1917. *
  1918. * Return: 0 in case of success, -1 on failure
  1919. */
  1920. uint32_t target_if_spectral_sops_configure_params(
  1921. void *arg, struct spectral_config *params,
  1922. enum spectral_scan_mode smode);
  1923. /**
  1924. * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
  1925. * @arg: Pointer to handle for Spectral target_if internal private data
  1926. *
  1927. * Note: This is only a placeholder function. It is not currently required since
  1928. * FW should be taking care of setting the required filters.
  1929. *
  1930. * Return: 0
  1931. */
  1932. uint32_t target_if_spectral_get_rxfilter(void *arg);
  1933. /**
  1934. * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
  1935. * functionality for the given pdev
  1936. * @pdev: Pointer to pdev object
  1937. *
  1938. * Return: None
  1939. */
  1940. void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
  1941. /**
  1942. * target_if_set_spectral_config() - Set spectral config
  1943. * @pdev: Pointer to pdev object
  1944. * @param: Spectral parameter id and value
  1945. * @smode: Spectral scan mode
  1946. * @err: Pointer to Spectral error code
  1947. *
  1948. * API to set spectral configurations
  1949. *
  1950. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  1951. */
  1952. QDF_STATUS target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
  1953. const struct spectral_cp_param *param,
  1954. const enum spectral_scan_mode smode,
  1955. enum spectral_cp_error_code *err);
  1956. /**
  1957. * target_if_pdev_spectral_init() - Initialize target_if Spectral
  1958. * functionality for the given pdev
  1959. * @pdev: Pointer to pdev object
  1960. *
  1961. * Return: On success, pointer to Spectral target_if internal private data, on
  1962. * failure, NULL
  1963. */
  1964. void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
  1965. /**
  1966. * target_if_spectral_sops_get_params() - Get user configured Spectral
  1967. * parameters
  1968. * @arg: Pointer to handle for Spectral target_if internal private data
  1969. * @params: Pointer to buffer into which Spectral parameters should be copied
  1970. * @smode: Spectral scan mode
  1971. *
  1972. * Return: 0 in case of success, -1 on failure
  1973. */
  1974. uint32_t target_if_spectral_sops_get_params(
  1975. void *arg, struct spectral_config *params,
  1976. enum spectral_scan_mode smode);
  1977. /**
  1978. * target_if_init_spectral_capability() - Initialize Spectral capability
  1979. *
  1980. * @spectral: Pointer to Spectral target_if internal private data
  1981. * @target_type: target type
  1982. *
  1983. * This is a workaround.
  1984. *
  1985. * Return: QDF_STATUS
  1986. */
  1987. QDF_STATUS
  1988. target_if_init_spectral_capability(struct target_if_spectral *spectral,
  1989. uint32_t target_type);
  1990. /**
  1991. * target_if_start_spectral_scan() - Start spectral scan
  1992. * @pdev: Pointer to pdev object
  1993. * @vdev_id: VDEV id
  1994. * @smode: Spectral scan mode
  1995. * @err: Spectral error code
  1996. *
  1997. * API to start spectral scan
  1998. *
  1999. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  2000. */
  2001. QDF_STATUS target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
  2002. uint8_t vdev_id,
  2003. enum spectral_scan_mode smode,
  2004. enum spectral_cp_error_code *err);
  2005. /**
  2006. * target_if_get_spectral_config() - Get spectral configuration
  2007. * @pdev: Pointer to pdev object
  2008. * @param: Pointer to spectral_config structure in which the configuration
  2009. * should be returned
  2010. * @smode: Spectral scan mode
  2011. *
  2012. * API to get the current spectral configuration
  2013. *
  2014. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  2015. */
  2016. QDF_STATUS target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
  2017. struct spectral_config *param,
  2018. enum spectral_scan_mode smode);
  2019. /**
  2020. * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
  2021. * parameters
  2022. * @spectral: Pointer to Spectral target_if internal private data
  2023. * @spectral_params: Pointer to Spectral parameters
  2024. * @smode: Spectral scan mode
  2025. * @err: Spectral error code
  2026. *
  2027. * Enable use of desired Spectral parameters by configuring them into HW, and
  2028. * starting Spectral scan
  2029. *
  2030. * Return: 0 on success, 1 on failure
  2031. */
  2032. int target_if_spectral_scan_enable_params(
  2033. struct target_if_spectral *spectral,
  2034. struct spectral_config *spectral_params,
  2035. enum spectral_scan_mode smode,
  2036. enum spectral_cp_error_code *err);
  2037. /**
  2038. * target_if_is_spectral_active() - Get whether Spectral is active
  2039. * @pdev: Pointer to pdev object
  2040. * @smode: Spectral scan mode
  2041. *
  2042. * Return: True if Spectral is active, false if Spectral is not active
  2043. */
  2044. bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev,
  2045. enum spectral_scan_mode smode);
  2046. /**
  2047. * target_if_is_spectral_enabled() - Get whether Spectral is enabled
  2048. * @pdev: Pointer to pdev object
  2049. * @smode: Spectral scan mode
  2050. *
  2051. * Return: True if Spectral is enabled, false if Spectral is not enabled
  2052. */
  2053. bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev,
  2054. enum spectral_scan_mode smode);
  2055. /**
  2056. * target_if_set_debug_level() - Set debug level for Spectral
  2057. * @pdev: Pointer to pdev object
  2058. * @debug_level: Debug level
  2059. *
  2060. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  2061. *
  2062. */
  2063. QDF_STATUS target_if_set_debug_level(struct wlan_objmgr_pdev *pdev,
  2064. uint32_t debug_level);
  2065. /**
  2066. * target_if_get_debug_level() - Get debug level for Spectral
  2067. * @pdev: Pointer to pdev object
  2068. *
  2069. * Return: Current debug level
  2070. */
  2071. uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev);
  2072. /**
  2073. * target_if_get_spectral_capinfo() - Get Spectral capability information
  2074. * @pdev: Pointer to pdev object
  2075. * @scaps: Buffer into which data should be copied
  2076. *
  2077. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  2078. */
  2079. QDF_STATUS target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev,
  2080. struct spectral_caps *scaps);
  2081. /**
  2082. * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
  2083. * @pdev: Pointer to pdev object
  2084. * @stats: Buffer into which data should be copied
  2085. *
  2086. * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE
  2087. */
  2088. QDF_STATUS target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
  2089. struct spectral_diag_stats *stats);
  2090. QDF_STATUS
  2091. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  2092. enum spectral_scan_mode smode,
  2093. uint8_t detector_id);
  2094. #ifdef DIRECT_BUF_RX_ENABLE
  2095. /**
  2096. * target_if_consume_sfft_report_gen3() - Process fft report for gen3
  2097. * @spectral: Pointer to spectral object
  2098. * @report: Pointer to spectral report
  2099. *
  2100. * Process fft report for gen3
  2101. *
  2102. * Return: Success/Failure
  2103. */
  2104. int
  2105. target_if_consume_spectral_report_gen3(
  2106. struct target_if_spectral *spectral,
  2107. struct spectral_report *report);
  2108. #endif
  2109. /**
  2110. * target_if_spectral_fw_hang() - Crash the FW from Spectral module
  2111. * @spectral: Pointer to Spectral LMAC object
  2112. *
  2113. * Return: QDF_STATUS of operation
  2114. */
  2115. QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral);
  2116. /**
  2117. * target_if_spectral_finite_scan_update() - Update scan count for finite scan
  2118. * and stop Spectral scan when required
  2119. * @spectral: Pointer to Spectral target_if internal private data
  2120. * @smode: Spectral scan mode
  2121. *
  2122. * This API decrements the number of Spectral reports expected from target for
  2123. * a finite Spectral scan. When expected number of reports are received from
  2124. * target Spectral scan is stopped.
  2125. *
  2126. * Return: QDF_STATUS on success
  2127. */
  2128. QDF_STATUS
  2129. target_if_spectral_finite_scan_update(struct target_if_spectral *spectral,
  2130. enum spectral_scan_mode smode);
  2131. /**
  2132. * target_if_spectral_is_finite_scan() - Check Spectral scan is finite/infinite
  2133. * @spectral: Pointer to Spectral target_if internal private data
  2134. * @smode: Spectral scan mode
  2135. *
  2136. * API to check whether Spectral scan is finite/infinite for the give mode.
  2137. * A non zero scan count indicates that scan is finite. Scan count of 0
  2138. * indicates an infinite Spectral scan.
  2139. *
  2140. * Return: QDF_STATUS on success
  2141. */
  2142. QDF_STATUS
  2143. target_if_spectral_is_finite_scan(struct target_if_spectral *spectral,
  2144. enum spectral_scan_mode smode,
  2145. bool *finite_spectral_scan);
  2146. #ifdef WIN32
  2147. #pragma pack(pop, target_if_spectral)
  2148. #endif
  2149. #ifdef __ATTRIB_PACK
  2150. #undef __ATTRIB_PACK
  2151. #endif
  2152. #endif /* WLAN_CONV_SPECTRAL_ENABLE */
  2153. #endif /* _TARGET_IF_SPECTRAL_H_ */