target_if_spectral.h 66 KB

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