target_if_spectral.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. /*
  2. * Copyright (c) 2011,2017 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 WIN32
  29. #pragma pack(push, target_if_spectral, 1)
  30. #define __ATTRIB_PACK
  31. #else
  32. #ifndef __ATTRIB_PACK
  33. #define __ATTRIB_PACK __attribute__ ((packed))
  34. #endif
  35. #endif
  36. #define spectral_log(level, args...) \
  37. QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args)
  38. #define spectral_logfl(level, format, args...) \
  39. spectral_log(level, FL(format), ## args)
  40. #define spectral_fatal(format, args...) \
  41. spectral_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
  42. #define spectral_err(format, args...) \
  43. spectral_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
  44. #define spectral_warn(format, args...) \
  45. spectral_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
  46. #define spectral_info(format, args...) \
  47. spectral_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
  48. #define spectral_debug(format, args...) \
  49. spectral_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
  50. #define STATUS_PASS 1
  51. #define STATUS_FAIL 0
  52. #define line() \
  53. qdf_print("----------------------------------------------------\n")
  54. #define SPECTRAL_TODO(str) \
  55. qdf_print(KERN_INFO "SPECTRAL : %s (%s : %d)\n", \
  56. (str), __func__, __LINE__)
  57. #define spectral_ops_not_registered(str) \
  58. qdf_print(KERN_INFO "SPECTRAL : %s not registered\n", (str))
  59. #define not_yet_implemented() \
  60. qdf_print("SPECTRAL : %s : %d Not yet implemented\n", \
  61. __func__, __LINE__)
  62. #define SPECTRAL_HT20_NUM_BINS 56
  63. #define SPECTRAL_HT20_FFT_LEN 56
  64. #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2)
  65. #define SPECTRAL_HT20_DATA_LEN 60
  66. #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3)
  67. #define SPECTRAL_HT40_TOTAL_NUM_BINS 128
  68. #define SPECTRAL_HT40_DATA_LEN 135
  69. #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3)
  70. #define SPECTRAL_HT40_FFT_LEN 128
  71. #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2)
  72. /* Used for the SWAR to obtain approximate combined rssi
  73. * in secondary 80Mhz segment
  74. */
  75. #define OFFSET_CH_WIDTH_20 65
  76. #define OFFSET_CH_WIDTH_40 62
  77. #define OFFSET_CH_WIDTH_80 56
  78. #define OFFSET_CH_WIDTH_160 50
  79. #ifdef BIG_ENDIAN_HOST
  80. #define SPECTRAL_MSG_COPY_CHAR_ARRAY(destp, srcp, len) do { \
  81. int j; \
  82. u_int32_t *src, *dest; \
  83. src = (u_int32_t *)(srcp); \
  84. dest = (u_int32_t *)(destp); \
  85. for (j = 0; j < roundup((len), sizeof(u_int32_t)) / 4; j++) { \
  86. *(dest + j) = qdf_le32_to_cpu(*(src + j)); \
  87. } \
  88. } while (0)
  89. #else
  90. #define SPECTRAL_MSG_COPY_CHAR_ARRAY(destp, srcp, len) \
  91. OS_MEMCPY((destp), (srcp), (len));
  92. #endif
  93. /* 5 categories x (lower + upper) bands */
  94. #define MAX_INTERF 10
  95. #define ATH_HOST_MAX_ANTENNA 3
  96. /* Mask for time stamp from descriptor */
  97. #define SPECTRAL_TSMASK 0xFFFFFFFF
  98. #define SPECTRAL_SIGNATURE 0xdeadbeef
  99. #define MAX_SPECTRAL_PAYLOAD 1500
  100. #ifndef NETLINK_ATHEROS
  101. #define NETLINK_ATHEROS (NETLINK_GENERIC + 1)
  102. #endif
  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. * struct spectral_search_fft_info_gen2 - spectral search fft report for gen2
  110. * @relpwr_db: Total bin power in db
  111. * @num_str_bins_ib: Number of strong bins
  112. * @base_pwr: Base power
  113. * @total_gain_info: Total gain
  114. * @fft_chn_idx: FFT chain on which report is originated
  115. * @avgpwr_db: Average power in db
  116. * @peak_mag: Peak power seen in the bins
  117. * @peak_inx: Index of bin holding peak power
  118. */
  119. typedef struct spectral_search_fft_info_gen2 {
  120. uint32_t relpwr_db;
  121. uint32_t num_str_bins_ib;
  122. uint32_t base_pwr;
  123. uint32_t total_gain_info;
  124. uint32_t fft_chn_idx;
  125. uint32_t avgpwr_db;
  126. uint32_t peak_mag;
  127. int16_t peak_inx;
  128. } SPECTRAL_SEARCH_FFT_INFO_GEN2;
  129. /* XXX Check if we should be handling the endinness difference in some
  130. * other way opaque to the host
  131. */
  132. #ifdef BIG_ENDIAN_HOST
  133. /**
  134. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for big endian host
  135. * @signature: signature
  136. * @tag: tag
  137. * @length: length
  138. */
  139. typedef struct spectral_phyerr_tlv_gen2 {
  140. u_int8_t signature;
  141. u_int8_t tag;
  142. u_int16_t length;
  143. } __ATTRIB_PACK SPECTRAL_PHYERR_TLV_GEN2;
  144. #else
  145. /**
  146. * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for little endian host
  147. * @length: length
  148. * @tag: tag
  149. * @signature: signature
  150. */
  151. typedef struct spectral_phyerr_tlv_gen2 {
  152. u_int16_t length;
  153. u_int8_t tag;
  154. u_int8_t signature;
  155. } __ATTRIB_PACK SPECTRAL_PHYERR_TLV_GEN2;
  156. #endif /* BIG_ENDIAN_HOST */
  157. /**
  158. * struct spectral_phyerr_hdr_gen2 - phyerr header for gen2 HW
  159. * @hdr_a: Header[0:31]
  160. * @hdr_b: Header[32:63]
  161. */
  162. typedef struct spectral_phyerr_hdr_gen2 {
  163. u_int32_t hdr_a;
  164. u_int32_t hdr_b;
  165. } SPECTRAL_PHYERR_HDR_GEN2;
  166. /* Segment ID information for 80+80.
  167. *
  168. * If the HW micro-architecture specification extends this DWORD for other
  169. * purposes, then redefine+rename accordingly. For now, the specification
  170. * mentions only segment ID (though this doesn't require an entire DWORD)
  171. * without mention of any generic terminology for the DWORD, or any reservation.
  172. * We use nomenclature accordingly.
  173. */
  174. typedef u_int32_t SPECTRAL_SEGID_INFO;
  175. /**
  176. * struct spectral_phyerr_fft_gen2 - fft info in phyerr event
  177. * @buf: fft report
  178. */
  179. typedef struct spectral_phyerr_fft_gen2 {
  180. u_int8_t buf[0];
  181. } SPECTRAL_PHYERR_FFT_GEN2;
  182. /* END of spectral GEN II HW specific details */
  183. /* START of spectral GEN III HW specific details */
  184. #define get_bitfield(value, size, pos) \
  185. (((value) >> (pos)) & ((1 << (size)) - 1))
  186. #define unsigned_to_signed(value, width) \
  187. (((value) >= (1 << ((width) - 1))) ? \
  188. (value - (1 << (width))) : (value))
  189. #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA)
  190. #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02)
  191. #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03)
  192. #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4)
  193. #define PHYERR_HDR_SIG_POS \
  194. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_sig))
  195. #define PHYERR_HDR_TAG_POS \
  196. (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_tag))
  197. #define SPECTRAL_FFT_BINS_POS \
  198. (offsetof(struct spectral_phyerr_fft_report_gen3, buf))
  199. /**
  200. * struct phyerr_info - spectral search fft report for gen3
  201. * @data: handle to phyerror buffer
  202. * @datalen: length of phyerror bufer
  203. * @p_rfqual: rf quality matrices
  204. * @p_chaninfo: pointer to chaninfo
  205. * @tsf64: 64 bit TSF
  206. * @acs_stats: acs stats
  207. */
  208. struct phyerr_info {
  209. u_int8_t *data;
  210. u_int32_t datalen;
  211. struct target_if_spectral_rfqual_info *p_rfqual;
  212. struct target_if_spectral_chan_info *p_chaninfo;
  213. u_int64_t tsf64;
  214. struct target_if_spectral_acs_stats *acs_stats;
  215. };
  216. /**
  217. * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3
  218. * @timestamp: Timestamp at which fft report was generated
  219. * @fft_detector_id: Which radio generated this report
  220. * @fft_num: The FFT count number. Set to 0 for short FFT.
  221. * @fft_radar_check: NA for spectral
  222. * @fft_peak_sidx: Index of bin with maximum power
  223. * @fft_chn_idx: Rx chain index
  224. * @fft_base_pwr_db: Base power in dB
  225. * @fft_total_gain_db: Total gain in dB
  226. * @fft_num_str_bins_ib: Number of strong bins in the report
  227. * @fft_peak_mag: Peak magnitude
  228. * @fft_avgpwr_db: Average power in dB
  229. * @fft_relpwr_db: Relative power in dB
  230. */
  231. struct spectral_search_fft_info_gen3 {
  232. uint32_t timestamp;
  233. uint32_t fft_detector_id;
  234. uint32_t fft_num;
  235. uint32_t fft_radar_check;
  236. int32_t fft_peak_sidx;
  237. uint32_t fft_chn_idx;
  238. uint32_t fft_base_pwr_db;
  239. uint32_t fft_total_gain_db;
  240. uint32_t fft_num_str_bins_ib;
  241. int32_t fft_peak_mag;
  242. uint32_t fft_avgpwr_db;
  243. uint32_t fft_relpwr_db;
  244. };
  245. /**
  246. * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event
  247. * @fft_timestamp: Timestamp at which fft report was generated
  248. * @fft_hdr_sig: signature
  249. * @fft_hdr_tag: tag
  250. * @fft_hdr_length: length
  251. * @hdr_a: Header[0:31]
  252. * @hdr_b: Header[32:63]
  253. * @hdr_c: Header[64:95]
  254. * @resv: Header[96:127]
  255. * @buf: fft bins
  256. */
  257. struct spectral_phyerr_fft_report_gen3 {
  258. u_int32_t fft_timestamp;
  259. #ifdef BIG_ENDIAN_HOST
  260. u_int8_t fft_hdr_sig;
  261. u_int8_t fft_hdr_tag;
  262. u_int16_t fft_hdr_length;
  263. #else
  264. u_int16_t fft_hdr_length;
  265. u_int8_t fft_hdr_tag;
  266. u_int8_t fft_hdr_sig;
  267. #endif /* BIG_ENDIAN_HOST */
  268. u_int32_t hdr_a;
  269. u_int32_t hdr_b;
  270. u_int32_t hdr_c;
  271. u_int32_t resv;
  272. u_int8_t buf[0];
  273. } __ATTRIB_PACK;
  274. /* END of spectral GEN III HW specific details */
  275. typedef signed char pwr_dbm;
  276. /**
  277. * enum spectral_gen - spectral hw generation
  278. * @SPECTRAL_GEN1 : spectral hw gen 1
  279. * @SPECTRAL_GEN2 : spectral hw gen 2
  280. * @SPECTRAL_GEN3 : spectral hw gen 3
  281. */
  282. enum spectral_gen {
  283. SPECTRAL_GEN1,
  284. SPECTRAL_GEN2,
  285. SPECTRAL_GEN3,
  286. };
  287. #if ATH_PERF_PWR_OFFLOAD
  288. /**
  289. * enum ol_spectral_info_spec - Enumerations for specifying which spectral
  290. * information (among parameters and states)
  291. * is desired.
  292. * @OL_SPECTRAL_INFO_SPEC_ACTIVE: Indicated whether spectral is active
  293. * @OL_SPECTRAL_INFO_SPEC_ENABLED: Indicated whether spectral is enabled
  294. * @OL_SPECTRAL_INFO_SPEC_PARAMS: Config params
  295. */
  296. enum ol_spectral_info_spec {
  297. OL_SPECTRAL_INFO_SPEC_ACTIVE,
  298. OL_SPECTRAL_INFO_SPEC_ENABLED,
  299. OL_SPECTRAL_INFO_SPEC_PARAMS,
  300. };
  301. #endif /* ATH_PERF_PWR_OFFLOAD */
  302. /* forward declaration */
  303. struct target_if_spectral;
  304. /**
  305. * struct target_if_spectral_chan_info - Channel information
  306. * @center_freq1: center frequency 1 in MHz
  307. * @center_freq2: center frequency 2 in MHz -valid only for
  308. * 11ACVHT 80PLUS80 mode
  309. * @chan_width: channel width in MHz
  310. */
  311. struct target_if_spectral_chan_info {
  312. u_int16_t center_freq1;
  313. u_int16_t center_freq2;
  314. u_int8_t chan_width;
  315. };
  316. /**
  317. * struct target_if_spectral_acs_stats - EACS stats from spectral samples
  318. * @nfc_ctl_rssi: Control chan rssi
  319. * @nfc_ext_rssi: Extension chan rssi
  320. * @ctrl_nf: Control chan Noise Floor
  321. * @ext_nf: Extension chan Noise Floor
  322. */
  323. struct target_if_spectral_acs_stats {
  324. int8_t nfc_ctl_rssi;
  325. int8_t nfc_ext_rssi;
  326. int8_t ctrl_nf;
  327. int8_t ext_nf;
  328. };
  329. /**
  330. * struct target_if_spectral_perchain_rssi_info - per chain rssi info
  331. * @rssi_pri20: Rssi of primary 20 Mhz
  332. * @rssi_sec20: Rssi of secondary 20 Mhz
  333. * @rssi_sec40: Rssi of secondary 40 Mhz
  334. * @rssi_sec80: Rssi of secondary 80 Mhz
  335. */
  336. struct target_if_spectral_perchain_rssi_info {
  337. int8_t rssi_pri20;
  338. int8_t rssi_sec20;
  339. int8_t rssi_sec40;
  340. int8_t rssi_sec80;
  341. };
  342. /**
  343. * struct target_if_spectral_rfqual_info - RF measurement information
  344. * @rssi_comb: RSSI Information
  345. * @pc_rssi_info: XXX : For now, we know we are getting information
  346. * for only 4 chains at max. For future extensions
  347. * use a define
  348. * @noise_floor: Noise floor information
  349. */
  350. struct target_if_spectral_rfqual_info {
  351. int8_t rssi_comb;
  352. struct target_if_spectral_perchain_rssi_info pc_rssi_info[4];
  353. int16_t noise_floor[4];
  354. };
  355. #define GET_TIF_SPECTRAL_OPS(spectral) \
  356. ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops)))
  357. /**
  358. * struct target_if_spectral_ops - spectral low level ops table
  359. * @get_tsf64: Get 64 bit TSF value
  360. * @get_capability: Get capability info
  361. * @set_rxfilter: Set rx filter
  362. * @get_rxfilter: Get rx filter
  363. * @is_spectral_active: Check whether icm is active
  364. * @is_spectral_enabled: Check whether spectral is enabled
  365. * @start_spectral_scan: Start spectral scan
  366. * @stop_spectral_scan: Stop spectral scan
  367. * @get_extension_channel: Get extension channel
  368. * @get_ctl_noisefloor: Get control noise floor
  369. * @get_ext_noisefloor: Get extension noise floor
  370. * @configure_spectral: Set spectral configurations
  371. * @get_spectral_config: Get spectral configurations
  372. * @get_ent_spectral_mask: Get spectral mask
  373. * @get_mac_address: Get mac address
  374. * @get_current_channel: Get current channel
  375. * @reset_hw: Reset HW
  376. * @get_chain_noise_floor: Get Channel noise floor
  377. * @spectral_process_phyerr: Process phyerr event
  378. */
  379. struct target_if_spectral_ops {
  380. u_int64_t (*get_tsf64)(void *arg);
  381. u_int32_t (*get_capability)(void *arg, SPECTRAL_CAPABILITY_TYPE type);
  382. u_int32_t (*set_rxfilter)(void *arg, int rxfilter);
  383. u_int32_t (*get_rxfilter)(void *arg);
  384. u_int32_t (*is_spectral_active)(void *arg);
  385. u_int32_t (*is_spectral_enabled)(void *arg);
  386. u_int32_t (*start_spectral_scan)(void *arg);
  387. u_int32_t (*stop_spectral_scan)(void *arg);
  388. u_int32_t (*get_extension_channel)(void *arg);
  389. int8_t (*get_ctl_noisefloor)(void *arg);
  390. int8_t (*get_ext_noisefloor)(void *arg);
  391. u_int32_t (*configure_spectral)(
  392. void *arg,
  393. struct spectral_config *params);
  394. u_int32_t (*get_spectral_config)(
  395. void *arg,
  396. struct spectral_config *params);
  397. u_int32_t (*get_ent_spectral_mask)(void *arg);
  398. u_int32_t (*get_mac_address)(void *arg, char *addr);
  399. u_int32_t (*get_current_channel)(void *arg);
  400. u_int32_t (*reset_hw)(void *arg);
  401. u_int32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf);
  402. int (*spectral_process_phyerr)(struct target_if_spectral *spectral,
  403. u_int8_t *data, u_int32_t datalen,
  404. struct target_if_spectral_rfqual_info *p_rfqual,
  405. struct target_if_spectral_chan_info *p_chaninfo,
  406. u_int64_t tsf64,
  407. struct target_if_spectral_acs_stats *acs_stats);
  408. };
  409. /**
  410. * struct target_if_spectral_stats - spectral stats info
  411. * @num_spectral_detects: Total num. of spectral detects
  412. * @total_phy_errors: Total number of phyerrors
  413. * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets
  414. * @pri_phy_errors: Phyerrors in primary channel
  415. * @ext_phy_errors: Phyerrors in secondary channel
  416. * @dc_phy_errors: Phyerrors due to dc
  417. * @early_ext_phy_errors: Early secondary channel phyerrors
  418. * @bwinfo_errors: Bandwidth info errors
  419. * @datalen_discards: Invalid data length errors, seen in gen1 chipsets
  420. * @rssi_discards bw: Indicates reports dropped due to RSSI threshold
  421. * @last_reset_tstamp: Last reset time stamp
  422. */
  423. struct target_if_spectral_stats {
  424. u_int32_t num_spectral_detects;
  425. u_int32_t total_phy_errors;
  426. u_int32_t owl_phy_errors;
  427. u_int32_t pri_phy_errors;
  428. u_int32_t ext_phy_errors;
  429. u_int32_t dc_phy_errors;
  430. u_int32_t early_ext_phy_errors;
  431. u_int32_t bwinfo_errors;
  432. u_int32_t datalen_discards;
  433. u_int32_t rssi_discards;
  434. u_int64_t last_reset_tstamp;
  435. };
  436. /**
  437. * struct target_if_spectral_event - spectral event structure
  438. * @se_ts: Original 15 bit recv timestamp
  439. * @se_full_ts: 64-bit full timestamp from interrupt time
  440. * @se_rssi: Rssi of spectral event
  441. * @se_bwinfo: Rssi of spectral event
  442. * @se_dur: Duration of spectral pulse
  443. * @se_chanindex: Channel of event
  444. * @se_list: List of spectral events
  445. */
  446. struct target_if_spectral_event {
  447. u_int32_t se_ts;
  448. u_int64_t se_full_ts;
  449. u_int8_t se_rssi;
  450. u_int8_t se_bwinfo;
  451. u_int8_t se_dur;
  452. u_int8_t se_chanindex;
  453. STAILQ_ENTRY(spectral_event) se_list;
  454. };
  455. /**
  456. * struct target_if_chain_noise_pwr_info - Noise power info for each channel
  457. * @rptcount: Count of reports in pwr array
  458. * @un_cal_nf: Uncalibrated noise floor
  459. * @factory_cal_nf: Noise floor as calibrated at the factory for module
  460. * @median_pwr: Median power (median of pwr array)
  461. * @pwr: Power reports
  462. */
  463. struct target_if_chain_noise_pwr_info {
  464. int rptcount;
  465. pwr_dbm un_cal_nf;
  466. pwr_dbm factory_cal_nf;
  467. pwr_dbm median_pwr;
  468. pwr_dbm pwr[];
  469. } __ATTRIB_PACK;
  470. /**
  471. * struct target_if_spectral_chan_stats - Channel information
  472. * @cycle_count: Cycle count
  473. * @channel_load: Channel load
  474. * @per: Period
  475. * @noisefloor: Noise floor
  476. * @comp_usablity: Computed usability
  477. * @maxregpower: Maximum allowed regulatary power
  478. * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
  479. * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz
  480. */
  481. struct target_if_spectral_chan_stats {
  482. int cycle_count;
  483. int channel_load;
  484. int per;
  485. int noisefloor;
  486. u_int16_t comp_usablity;
  487. int8_t maxregpower;
  488. u_int16_t comp_usablity_sec80;
  489. int8_t maxregpower_sec80;
  490. };
  491. #if ATH_PERF_PWR_OFFLOAD
  492. /* Locking operations
  493. * We have a separate set of definitions for offload to accommodate
  494. * offload specific changes in the future.
  495. */
  496. #define OL_SPECTRAL_LOCK_INIT(_lock) qdf_spinlock_create((_lock))
  497. #define OL_SPECTRAL_LOCK_DESTROY(_lock) qdf_spinlock_destroy((_lock))
  498. #define OL_SPECTRAL_LOCK(_lock) qdf_spin_lock((_lock))
  499. #define OL_SPECTRAL_UNLOCK(_lock) qdf_spin_unlock((_lock))
  500. /**
  501. * struct target_if_spectral_cache - Cache used to minimize WMI operations
  502. * in offload architecture
  503. * @osc_spectral_enabled: Whether Spectral is enabled
  504. * @osc_spectral_active: Whether spectral is active
  505. * XXX: Ideally, we should NOT cache this
  506. * since the hardware can self clear the bit,
  507. * the firmware can possibly stop spectral due to
  508. * intermittent off-channel activity, etc
  509. * A WMI read command should be introduced to handle
  510. * this This will be discussed.
  511. * @osc_params: Spectral parameters
  512. * @osc_is_valid: Whether the cache is valid
  513. */
  514. struct target_if_spectral_cache {
  515. u_int8_t osc_spectral_enabled;
  516. u_int8_t osc_spectral_active;
  517. struct spectral_config osc_params;
  518. u_int8_t osc_is_valid;
  519. };
  520. /**
  521. * struct target_if_spectral_param_state_info - Structure used to represent and
  522. * manage spectral information
  523. * (parameters and states)
  524. * @osps_lock: Lock to synchronize accesses to information
  525. * @osps_cache: Cacheable' information
  526. */
  527. struct target_if_spectral_param_state_info {
  528. qdf_spinlock_t osps_lock;
  529. struct target_if_spectral_cache osps_cache;
  530. /* XXX - Non-cacheable information goes here, in the future */
  531. };
  532. #endif /* ATH_PERF_PWR_OFFLOAD */
  533. struct vdev_spectral_configure_params;
  534. struct vdev_spectral_enable_params;
  535. /**
  536. * struct wmi_spectral_cmd_ops - structure used holding the operations
  537. * related to wmi commands on spectral parameters.
  538. * @wmi_spectral_configure_cmd_send:
  539. * @wmi_spectral_enable_cmd_send:
  540. */
  541. struct wmi_spectral_cmd_ops {
  542. QDF_STATUS (*wmi_spectral_configure_cmd_send)(
  543. void *wmi_hdl,
  544. struct vdev_spectral_configure_params *param);
  545. QDF_STATUS (*wmi_spectral_enable_cmd_send)(
  546. void *wmi_hdl,
  547. struct vdev_spectral_enable_params *param);
  548. };
  549. /**
  550. * struct target_if_spectral - main spectral structure
  551. * @pdev: Pointer to pdev
  552. * @spectral_ops: Target if internal Spectral low level operations table
  553. * @capability: Spectral capabilities structure
  554. * @ath_spectral_lock: Lock used for internal Spectral operations
  555. * @spectral_curchan_radindex: Current channel spectral index
  556. * @spectral_extchan_radindex: Extension channel spectral index
  557. * @spectraldomain: Current Spectral domain
  558. * @spectral_proc_phyerr: Flags to process for PHY errors
  559. * @spectral_defaultparams: Default PHY params per Spectral stat
  560. * @ath_spectral_stats: Spectral related stats
  561. * @events: Events structure
  562. * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel?
  563. * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI?
  564. * @sc_spectral_20_40_mode: Is AP in 20-40 mode?
  565. * @sc_spectral_noise_pwr_cal: Noise power cal required?
  566. * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA?
  567. * @upper_is_control: Upper segment is primary
  568. * @upper_is_extension: Upper segment is secondary
  569. * @lower_is_control: Lower segment is primary
  570. * @lower_is_extension: Lower segment is secondary
  571. * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral
  572. * mute test
  573. * @spectral_numbins: Number of bins
  574. * @spectral_fft_len: FFT length
  575. * @spectral_data_len: Total phyerror report length
  576. * @lb_edge_extrabins: Number of extra bins on left band edge
  577. * @rb_edge_extrabins: Number of extra bins on right band edge
  578. * @spectral_max_index_offset: Max FFT index offset (20 MHz mode)
  579. * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode)
  580. * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode)
  581. * @spectral_dc_index: At which index DC is present
  582. * @send_single_packet: Deprecated
  583. * @spectral_sent_msg: Indicates whether we send report to upper layers
  584. * @params: Spectral parameters
  585. * @last_capture_time: Indicates timestamp of previouse report
  586. * @num_spectral_data: Number of Spectral samples received in current session
  587. * @total_spectral_data: Total number of Spectral samples received
  588. * @max_rssi: Maximum RSSI
  589. * @detects_control_channel: NA
  590. * @detects_extension_channel: NA
  591. * @detects_below_dc: NA
  592. * @detects_above_dc: NA
  593. * @sc_scanning: Indicates active wifi scan
  594. * @sc_spectral_scan: Indicates active specral scan
  595. * @sc_spectral_full_scan: Deprecated
  596. * @scan_start_tstamp: Deprecated
  597. * @last_tstamp: Deprecated
  598. * @first_tstamp: Deprecated
  599. * @spectral_samp_count: Deprecated
  600. * @sc_spectral_samp_count: Deprecated
  601. * @noise_pwr_reports_reqd: Number of noise power reports required
  602. * @noise_pwr_reports_recv: Number of noise power reports received
  603. * @noise_pwr_reports_lock: Lock used for Noise power report processing
  604. * @noise_pwr_chain_ctl: Noise power report - control channel
  605. * @noise_pwr_chain_ext: Noise power report - extension channel
  606. * @chaninfo: Channel statistics
  607. * @tsf64: Latest TSF Value
  608. * @ol_info: Offload architecture Spectral parameter cache information
  609. * @ch_width: Indicates Channel Width 20/40/80/160 MHz with values 0, 1, 2, 3
  610. * respectively
  611. * @diag_stats: Diagnostic statistics
  612. * @is_160_format: Indicates whether information provided by HW is in altered
  613. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  614. * @is_lb_edge_extrabins_format: Indicates whether information provided by
  615. * HW has 4 extra bins, at left band edge, for report mode 2
  616. * @is_rb_edge_extrabins_format: Indicates whether information provided
  617. * by HW has 4 extra bins, at right band edge, for report mode 2
  618. * @is_sec80_rssi_war_required: Indicates whether the software workaround is
  619. * required to obtain approximate combined RSSI for secondary 80Mhz segment
  620. * @simctx: Spectral Simulation context
  621. * @spectral_gen: Spectral hardware generation
  622. * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware
  623. * generation
  624. * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV
  625. * header, for the given hardware generation
  626. * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV
  627. * header, for the given hardware generation
  628. * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware
  629. * generation
  630. */
  631. struct target_if_spectral {
  632. struct wlan_objmgr_pdev *pdev_obj;
  633. struct target_if_spectral_ops spectral_ops;
  634. struct spectral_caps capability;
  635. qdf_spinlock_t ath_spectral_lock;
  636. int16_t spectral_curchan_radindex;
  637. int16_t spectral_extchan_radindex;
  638. u_int32_t spectraldomain;
  639. u_int32_t spectral_proc_phyerr;
  640. struct spectral_config spectral_defaultparams;
  641. struct target_if_spectral_stats ath_spectral_stats;
  642. struct target_if_spectral_event *events;
  643. unsigned int sc_spectral_ext_chan_ok:1,
  644. sc_spectral_combined_rssi_ok:1,
  645. sc_spectral_20_40_mode:1,
  646. sc_spectral_noise_pwr_cal:1,
  647. sc_spectral_non_edma:1;
  648. int upper_is_control;
  649. int upper_is_extension;
  650. int lower_is_control;
  651. int lower_is_extension;
  652. u_int8_t sc_spectraltest_ieeechan;
  653. struct sock *spectral_sock;
  654. struct sk_buff *spectral_skb;
  655. struct nlmsghdr *spectral_nlh;
  656. u_int32_t spectral_pid;
  657. STAILQ_HEAD(, target_if_spectral_skb_event) spectral_skbq;
  658. qdf_spinlock_t spectral_skbqlock;
  659. int spectral_numbins;
  660. int spectral_fft_len;
  661. int spectral_data_len;
  662. /* For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
  663. * delivered. However, there can be additional bins reported for
  664. * AR900B version 2.0 and QCA9984 as described next:
  665. *
  666. * AR900B version 2.0: An additional tone is processed on the right
  667. * hand side in order to facilitate detection of radar pulses out to
  668. * the extreme band-edge of the channel frequency. Since the HW design
  669. * processes four tones at a time, this requires one additional Dword
  670. * to be added to the search FFT report.
  671. *
  672. * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary +
  673. * 1x-oversampled bins (in-band) per FFT, then 8 more bins
  674. * (4 more on left side and 4 more on right side)are added.
  675. */
  676. int lb_edge_extrabins;
  677. int rb_edge_extrabins;
  678. int spectral_max_index_offset;
  679. int spectral_upper_max_index_offset;
  680. int spectral_lower_max_index_offset;
  681. int spectral_dc_index;
  682. int send_single_packet;
  683. int spectral_sent_msg;
  684. int classify_scan;
  685. os_timer_t classify_timer;
  686. struct spectral_config params;
  687. struct spectral_classifier_params classifier_params;
  688. int last_capture_time;
  689. int num_spectral_data;
  690. int total_spectral_data;
  691. int max_rssi;
  692. int detects_control_channel;
  693. int detects_extension_channel;
  694. int detects_below_dc;
  695. int detects_above_dc;
  696. int sc_scanning;
  697. int sc_spectral_scan;
  698. int sc_spectral_full_scan;
  699. u_int64_t scan_start_tstamp;
  700. u_int32_t last_tstamp;
  701. u_int32_t first_tstamp;
  702. u_int32_t spectral_samp_count;
  703. u_int32_t sc_spectral_samp_count;
  704. int noise_pwr_reports_reqd;
  705. int noise_pwr_reports_recv;
  706. qdf_spinlock_t noise_pwr_reports_lock;
  707. struct target_if_chain_noise_pwr_info
  708. *noise_pwr_chain_ctl[ATH_HOST_MAX_ANTENNA];
  709. struct target_if_chain_noise_pwr_info
  710. *noise_pwr_chain_ext[ATH_HOST_MAX_ANTENNA];
  711. u_int64_t tsf64;
  712. #if ATH_PERF_PWR_OFFLOAD
  713. struct target_if_spectral_param_state_info ol_info;
  714. #endif
  715. u_int32_t ch_width;
  716. struct spectral_diag_stats diag_stats;
  717. bool is_160_format;
  718. bool is_lb_edge_extrabins_format;
  719. bool is_rb_edge_extrabins_format;
  720. bool is_sec80_rssi_war_required;
  721. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  722. void *simctx;
  723. #endif
  724. enum spectral_gen spectral_gen;
  725. u_int8_t hdr_sig_exp;
  726. u_int8_t tag_sscan_summary_exp;
  727. u_int8_t tag_sscan_fft_exp;
  728. u_int8_t tlvhdr_size;
  729. struct wmi_spectral_cmd_ops param_wmi_cmd_ops;
  730. };
  731. /**
  732. * struct target_if_spectral_skb_event - Used to broadcast FFT report to
  733. * applications
  734. * @sp_skb: Pointer to skb
  735. * @sp_nlh: Pointer to nl message header
  736. * @spectral_skb_list: Linked list to manipulate the reports
  737. */
  738. struct target_if_spectral_skb_event {
  739. struct sk_buff *sp_skb;
  740. struct nlmsghdr *sp_nlh;
  741. STAILQ_ENTRY(target_if_spectral_skb_event) spectral_skb_list;
  742. };
  743. /* TODO:COMMENTS */
  744. struct target_if_samp_msg_params {
  745. int8_t rssi;
  746. int8_t rssi_sec80;
  747. int8_t lower_rssi;
  748. int8_t upper_rssi;
  749. int8_t chain_ctl_rssi[ATH_HOST_MAX_ANTENNA];
  750. int8_t chain_ext_rssi[ATH_HOST_MAX_ANTENNA];
  751. uint16_t bwinfo;
  752. uint16_t datalen;
  753. uint16_t datalen_sec80;
  754. uint32_t tstamp;
  755. uint32_t last_tstamp;
  756. uint16_t max_mag;
  757. uint16_t max_mag_sec80;
  758. uint16_t max_index;
  759. uint16_t max_index_sec80;
  760. uint8_t max_exp;
  761. int peak;
  762. int pwr_count;
  763. int pwr_count_sec80;
  764. int8_t nb_lower;
  765. int8_t nb_upper;
  766. uint16_t max_lower_index;
  767. uint16_t max_upper_index;
  768. u_int8_t *bin_pwr_data;
  769. u_int8_t *bin_pwr_data_sec80;
  770. u_int16_t freq;
  771. u_int16_t vhtop_ch_freq_seg1;
  772. u_int16_t vhtop_ch_freq_seg2;
  773. u_int16_t freq_loading;
  774. int16_t noise_floor;
  775. int16_t noise_floor_sec80;
  776. struct INTERF_SRC_RSP interf_list;
  777. SPECTRAL_CLASSIFIER_PARAMS classifier_params;
  778. struct ath_softc *sc;
  779. };
  780. /* NETLINK related declarations */
  781. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  782. #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
  783. void spectral_nl_data_ready(struct sock *sk, int len);
  784. #else
  785. void spectral_nl_data_ready(struct sk_buff *skb);
  786. #endif /* VERSION CHECK */
  787. #endif /* SPECTRAL_USE_NETLINK_SOCKETS defined */
  788. #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
  789. void target_if_spectral_nl_data_ready(struct sock *sk, int len);
  790. #else
  791. void target_if_spectral_nl_data_ready(struct sk_buff *skb);
  792. #endif
  793. int target_if_spectral_dump_fft(u_int8_t *pfft, int fftlen);
  794. void target_if_dbg_print_SAMP_param(struct target_if_samp_msg_params *p);
  795. uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width);
  796. void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
  797. extern struct net init_net;
  798. int target_if_spectral_init_netlink(struct target_if_spectral *spectral);
  799. int target_if_spectral_destroy_netlink(struct target_if_spectral *spectral);
  800. void target_if_spectral_unicast_msg(struct target_if_spectral *spectral);
  801. void target_if_spectral_bcast_msg(struct target_if_spectral *spectral);
  802. void target_if_spectral_prep_skb(struct target_if_spectral *spectral);
  803. void target_if_spectral_skb_dequeue(unsigned long data);
  804. void target_if_spectral_create_samp_msg(
  805. struct target_if_spectral *spectral,
  806. struct target_if_samp_msg_params *params);
  807. int spectral_process_phyerr_gen3(
  808. struct target_if_spectral *spectral,
  809. u_int8_t *data,
  810. u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
  811. struct target_if_spectral_chan_info *p_chaninfo,
  812. u_int64_t tsf64,
  813. struct target_if_spectral_acs_stats *acs_stats);
  814. int spectral_process_phyerr_gen2(
  815. struct target_if_spectral *spectral,
  816. u_int8_t *data,
  817. u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual,
  818. struct target_if_spectral_chan_info *p_chaninfo,
  819. u_int64_t tsf64,
  820. struct target_if_spectral_acs_stats *acs_stats);
  821. void target_if_spectral_send_intf_found_msg(
  822. struct wlan_objmgr_pdev *pdev,
  823. u_int16_t cw_int, u_int32_t dcs_enabled);
  824. void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev);
  825. struct wlan_objmgr_vdev *target_if_spectral_get_vdev(
  826. struct target_if_spectral *spectral);
  827. int spectral_dump_header_gen2(SPECTRAL_PHYERR_HDR_GEN2 *phdr);
  828. int8_t get_combined_rssi_sec80_segment_gen2(
  829. struct target_if_spectral *spectral,
  830. SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_sfft_sec80);
  831. int spectral_dump_tlv_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, bool is_160_format);
  832. int spectral_dump_phyerr_data_gen2(
  833. u_int8_t *data,
  834. u_int32_t datalen,
  835. bool is_160_format);
  836. int spectral_dump_fft_report_gen3(
  837. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  838. struct spectral_search_fft_info_gen3 *p_sfft);
  839. void target_if_dbg_print_SAMP_msg(SPECTRAL_SAMP_MSG *pmsg);
  840. /* START of spectral GEN III HW specific function declarations */
  841. /* [FIXME] fix the declaration */
  842. int process_search_fft_report_gen3(
  843. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  844. struct spectral_search_fft_info_gen3 *p_fft_info);
  845. /* END of spectral GEN III HW specific function declarations */
  846. /**
  847. * target_if_send_phydata() - Send Spectral PHY data over netlink
  848. * @pdev: Pointer to pdev
  849. * @sock: Netlink socket to use
  850. * @nbuf: Network buffer containing PHY data to send
  851. *
  852. * Return: 0 on success, negative value on failure
  853. */
  854. static inline uint32_t target_if_send_phydata(
  855. struct wlan_objmgr_pdev *pdev,
  856. struct sock *sock, qdf_nbuf_t nbuf)
  857. {
  858. struct wlan_objmgr_psoc *psoc = NULL;
  859. psoc = wlan_pdev_get_psoc(pdev);
  860. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_send_phydata(pdev,
  861. sock, nbuf);
  862. }
  863. /**
  864. * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal
  865. * Spectral data
  866. * @pdev: Pointer to pdev
  867. *
  868. * Return: Handle to target_if internal Spectral data on success, NULL on
  869. * failure
  870. */
  871. static inline
  872. struct target_if_spectral *get_target_if_spectral_handle_from_pdev(
  873. struct wlan_objmgr_pdev *pdev)
  874. {
  875. struct target_if_spectral *spectral = NULL;
  876. struct wlan_objmgr_psoc *psoc = NULL;
  877. psoc = wlan_pdev_get_psoc(pdev);
  878. spectral = (struct target_if_spectral *)
  879. psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_target_handle(
  880. pdev);
  881. return spectral;
  882. }
  883. static inline
  884. int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev)
  885. {
  886. struct wlan_objmgr_psoc *psoc = NULL;
  887. psoc = wlan_vdev_get_psoc(vdev);
  888. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_chan_freq(
  889. vdev);
  890. }
  891. static inline
  892. enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev)
  893. {
  894. struct wlan_objmgr_psoc *psoc = NULL;
  895. psoc = wlan_vdev_get_psoc(vdev);
  896. return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_ch_width(
  897. vdev);
  898. }
  899. static inline
  900. int target_if_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
  901. uint16_t *sec20chan_freq)
  902. {
  903. struct wlan_objmgr_psoc *psoc = NULL;
  904. psoc = wlan_vdev_get_psoc(vdev);
  905. return psoc->soc_cb.rx_ops.sptrl_rx_ops.
  906. sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq);
  907. }
  908. /**
  909. * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask
  910. * @pdev: Pointer to pdev
  911. * @spectral_rx_chainmask: Spectral Rx chainmask
  912. *
  913. * Return: None
  914. */
  915. static inline
  916. void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev,
  917. u_int8_t spectral_rx_chainmask)
  918. {
  919. struct target_if_spectral *spectral = NULL;
  920. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  921. spectral->params.ss_chn_mask = spectral_rx_chainmask;
  922. }
  923. /**
  924. * target_if_spectral_process_phyerr() - Process Spectral PHY error
  925. * @pdev: Pointer to pdev
  926. * @data: PHY error data received from FW
  927. * @datalen: Length of data
  928. * @p_rfqual: Pointer to RF Quality information
  929. * @p_chaninfo: Pointer to channel information
  930. * @tsf: TSF time instance at which the Spectral sample was received
  931. * @acs_stats: ACS stats
  932. *
  933. * Process Spectral PHY error by extracting necessary information from the data
  934. * sent by FW, and send the extracted information to application layer.
  935. *
  936. * Return: None
  937. */
  938. static inline
  939. void target_if_spectral_process_phyerr(
  940. struct wlan_objmgr_pdev *pdev,
  941. u_int8_t *data, u_int32_t datalen,
  942. struct target_if_spectral_rfqual_info *p_rfqual,
  943. struct target_if_spectral_chan_info *p_chaninfo,
  944. u_int64_t tsf64,
  945. struct target_if_spectral_acs_stats *acs_stats)
  946. {
  947. struct target_if_spectral *spectral = NULL;
  948. struct target_if_spectral_ops *p_sops = NULL;
  949. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  950. p_sops = GET_TIF_SPECTRAL_OPS(spectral);
  951. p_sops->spectral_process_phyerr(spectral, data, datalen,
  952. p_rfqual, p_chaninfo,
  953. tsf64, acs_stats);
  954. }
  955. /**
  956. * tgt_if_is_spectral_enabled() - Get whether Spectral is enabled
  957. * @arg: Pointer to handle for Spectral target_if internal private data
  958. *
  959. * Return: True if Spectral is enabled, false if Spectral is not enabled
  960. */
  961. u_int32_t tgt_if_is_spectral_enabled(void *arg);
  962. /**
  963. * tgt_if_is_spectral_active() - Get whether Spectral is active
  964. * @arg: Pointer to handle for Spectral target_if internal private data
  965. *
  966. * Return: True if Spectral is active, false if Spectral is not active
  967. */
  968. u_int32_t tgt_if_is_spectral_active(void *arg);
  969. /**
  970. * tgt_if_start_spectral_scan() - Start Spectral scan
  971. * @arg: Pointer to handle for Spectral target_if internal private data
  972. *
  973. * Return: 1 on success, 0 on failure
  974. */
  975. u_int32_t tgt_if_start_spectral_scan(void *arg);
  976. /**
  977. * tgt_if_stop_spectral_scan() - Stop Spectral scan
  978. * @arg: Pointer to handle for Spectral target_if internal private data
  979. *
  980. * Return: 1 on success, 0 on failure
  981. */
  982. u_int32_t tgt_if_stop_spectral_scan(void *arg);
  983. /**
  984. * target_if_spectral_get_extension_channel() - Get the current Extension
  985. * channel (in MHz)
  986. * @arg: Pointer to handle for Spectral target_if internal private data
  987. *
  988. * Return: Current Extension channel (in MHz) on success, 0 on failure or if
  989. * extension channel is not present.
  990. */
  991. u_int32_t target_if_spectral_get_extension_channel(void *arg);
  992. /**
  993. * target_if_spectral_get_current_channel() - Get the current channel (in MHz)
  994. * @arg: Pointer to handle for Spectral target_if internal private data
  995. *
  996. * Return: Current channel (in MHz) on success, 0 on failure
  997. */
  998. u_int32_t target_if_spectral_get_current_channel(void *arg);
  999. /**
  1000. * target_if_spectral_reset_hw() - Reset the hardware
  1001. * @arg: Pointer to handle for Spectral target_if internal private data
  1002. *
  1003. * This is only a placeholder since it is not currently required in the offload
  1004. * case.
  1005. *
  1006. * Return: 0
  1007. */
  1008. u_int32_t target_if_spectral_reset_hw(void *arg);
  1009. /**
  1010. * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
  1011. * Noisefloor history buffer
  1012. * @arg: Pointer to handle for Spectral target_if internal private data
  1013. * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
  1014. *
  1015. * This is only a placeholder since it is not currently required in the offload
  1016. * case.
  1017. *
  1018. * Return: 0
  1019. */
  1020. u_int32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf);
  1021. /**
  1022. * target_if_spectral_get_ext_noisefloor() - Get the extension channel
  1023. * noisefloor
  1024. * @arg: Pointer to handle for Spectral target_if internal private data
  1025. *
  1026. * This is only a placeholder since it is not currently required in the offload
  1027. * case.
  1028. *
  1029. * Return: 0
  1030. */
  1031. int8_t target_if_spectral_get_ext_noisefloor(void *arg);
  1032. /**
  1033. * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
  1034. * @arg: Pointer to handle for Spectral target_if internal private data
  1035. *
  1036. * This is only a placeholder since it is not currently required in the offload
  1037. * case.
  1038. *
  1039. * Return: 0
  1040. */
  1041. int8_t target_if_spectral_get_ctl_noisefloor(void *arg);
  1042. /**
  1043. * target_if_spectral_get_capability() - Get whether a given Spectral hardware
  1044. * capability is available
  1045. * @arg: Pointer to handle for Spectral target_if internal private data
  1046. * @type: Spectral hardware capability type
  1047. *
  1048. * Return: True if the capability is available, false if the capability is not
  1049. * available
  1050. */
  1051. u_int32_t target_if_spectral_get_capability(
  1052. void *arg, SPECTRAL_CAPABILITY_TYPE type);
  1053. /**
  1054. * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
  1055. * @arg: Pointer to handle for Spectral target_if internal private data
  1056. * @rxfilter: Rx filter to be used
  1057. *
  1058. * Note: This is only a placeholder function. It is not currently required since
  1059. * FW should be taking care of setting the required filters.
  1060. *
  1061. * Return: 0
  1062. */
  1063. u_int32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter);
  1064. /**
  1065. * target_if_spectral_configure_params() - Configure user supplied Spectral
  1066. * parameters
  1067. * @arg: Pointer to handle for Spectral target_if internal private data
  1068. * @params: Spectral parameters
  1069. *
  1070. * Return: 1 on success, 0 on failure.
  1071. */
  1072. u_int32_t target_if_spectral_configure_params(
  1073. void *arg, struct spectral_config *params);
  1074. /**
  1075. * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
  1076. * @arg: Pointer to handle for Spectral target_if internal private data
  1077. *
  1078. * Note: This is only a placeholder function. It is not currently required since
  1079. * FW should be taking care of setting the required filters.
  1080. *
  1081. * Return: 0
  1082. */
  1083. u_int32_t target_if_spectral_get_rxfilter(void *arg);
  1084. /**
  1085. * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
  1086. * functionality for the given pdev
  1087. * @pdev: Pointer to pdev object
  1088. *
  1089. * Return: None
  1090. */
  1091. void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev);
  1092. /**
  1093. * target_if_set_spectral_config() - Set spectral config
  1094. * @pdev: Pointer to pdev object
  1095. * @threshtype: config type
  1096. * @value: config value
  1097. *
  1098. * API to set spectral configurations
  1099. *
  1100. * Return: 1 on success, 0 on failure
  1101. */
  1102. int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
  1103. const u_int32_t threshtype,
  1104. const u_int32_t value);
  1105. /**
  1106. * target_if_pdev_spectral_init() - Initialize target_if Spectral
  1107. * functionality for the given pdev
  1108. * @pdev: Pointer to pdev object
  1109. *
  1110. * Return: On success, pointer to Spectral target_if internal private data, on
  1111. * failure, NULL
  1112. */
  1113. void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev);
  1114. /**
  1115. * target_if_spectral_get_params() - Get user configured Spectral parameters
  1116. * @arg: Pointer to handle for Spectral target_if internal private data
  1117. * @params: Pointer to buffer into which Spectral parameters should be copied
  1118. *
  1119. * Return: 1 on success, 0 on failure.
  1120. */
  1121. u_int32_t target_if_spectral_get_params(
  1122. void *arg, struct spectral_config *params);
  1123. /**
  1124. * init_spectral_capability() - Initialize Spectral capability
  1125. * @spectral: Pointer to Spectral target_if internal private data
  1126. *
  1127. * This is a workaround.
  1128. *
  1129. * Return: None
  1130. */
  1131. void init_spectral_capability(
  1132. struct target_if_spectral *spectral);
  1133. /**
  1134. * target_if_start_spectral_scan() - Start spectral scan
  1135. * @pdev: Pointer to pdev object
  1136. *
  1137. * API to start spectral scan
  1138. *
  1139. * Return: 0 in case of success, -1 on failure
  1140. */
  1141. int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev);
  1142. /**
  1143. * target_if_get_spectral_config() - Get spectral configuration
  1144. * @pdev: Pointer to pdev object
  1145. * @param: Pointer to spectral_config structure in which the configuration
  1146. * should be returned
  1147. *
  1148. * API to get the current spectral configuration
  1149. *
  1150. * Return: 1 on success, 0 on failure.
  1151. */
  1152. void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
  1153. struct spectral_config *param);
  1154. /**
  1155. * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
  1156. * parameters
  1157. * @spectral: Pointer to Spectral target_if internal private data
  1158. * @spectral_params: Pointer to Spectral parameters
  1159. *
  1160. * Enable use of desired Spectral parameters by configuring them into HW, and
  1161. * starting Spectral scan
  1162. *
  1163. * Return: 0 on success, 1 on failure
  1164. */
  1165. int target_if_spectral_scan_enable_params(
  1166. struct target_if_spectral *spectral, struct spectral_config *spectral_params);
  1167. /**
  1168. * target_if_is_spectral_active() - Get whether Spectral is active
  1169. * @pdev: Pointer to pdev object
  1170. *
  1171. * Return: True if Spectral is active, false if Spectral is not active
  1172. */
  1173. bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev);
  1174. /**
  1175. * target_if_is_spectral_enabled() - Get whether Spectral is enabled
  1176. * @pdev: Pointer to pdev object
  1177. *
  1178. * Return: True if Spectral is enabled, false if Spectral is not enabled
  1179. */
  1180. bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev);
  1181. /**
  1182. * target_if_set_debug_level() - Set debug level for Spectral
  1183. * @pdev: Pointer to pdev object
  1184. * @debug_level: Debug level
  1185. *
  1186. * Return: 0 in case of success
  1187. */
  1188. int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev,
  1189. u_int32_t debug_level);
  1190. /**
  1191. * target_if_get_debug_level() - Get debug level for Spectral
  1192. * @pdev: Pointer to pdev object
  1193. *
  1194. * Return: Current debug level
  1195. */
  1196. u_int32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev);
  1197. /**
  1198. * target_if_get_spectral_capinfo() - Get Spectral capability information
  1199. * @pdev: Pointer to pdev object
  1200. * @outdata: Buffer into which data should be copied
  1201. *
  1202. * Return: void
  1203. */
  1204. void target_if_get_spectral_capinfo(
  1205. struct wlan_objmgr_pdev *pdev,
  1206. void *outdata);
  1207. /**
  1208. * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
  1209. * @pdev: Pointer to pdev object
  1210. * @outdata: Buffer into which data should be copied
  1211. *
  1212. * Return: void
  1213. */
  1214. void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
  1215. void *outdata);
  1216. /*
  1217. * target_if_spectral_send_tlv_to_host - target_if_spectral_send_tlv_to_host
  1218. * @spectral: Send the TLV information to Host
  1219. * @data: Pointer to the TLV
  1220. * @datalen: tlv length
  1221. *
  1222. * Return: Success/Failure
  1223. *
  1224. */
  1225. int target_if_spectral_send_tlv_to_host(
  1226. struct target_if_spectral *spectral,
  1227. u_int8_t *data, u_int32_t datalen);
  1228. void target_if_register_wmi_spectral_cmd_ops(
  1229. struct wlan_objmgr_pdev *pdev,
  1230. struct wmi_spectral_cmd_ops *cmd_ops);
  1231. #ifdef WIN32
  1232. #pragma pack(pop, target_if_spectral)
  1233. #endif
  1234. #ifdef __ATTRIB_PACK
  1235. #undef __ATTRIB_PACK
  1236. #endif
  1237. #endif /* _TARGET_IF_SPECTRAL_H_ */