target_if_spectral.h 96 KB

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