target_if_spectral.h 105 KB

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