target_if_spectral.h 79 KB

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