target_if_spectral.h 94 KB

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