target_if_spectral.h 87 KB

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