target_if_spectral_phyerr.c 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. /*
  2. * Copyright (c) 2011,2017-2020 The Linux Foundation. All rights reserved.
  3. *
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <osdep.h>
  20. #include <qdf_types.h>
  21. #include <qdf_module.h>
  22. #include <wlan_tgt_def_config.h>
  23. #include <hif.h>
  24. #include <hif_hw_version.h>
  25. #include <wmi_unified_api.h>
  26. #include <target_if_spectral.h>
  27. #include <wlan_lmac_if_def.h>
  28. #include <wlan_osif_priv.h>
  29. #include <reg_services_public_struct.h>
  30. #include <target_if.h>
  31. #ifdef DIRECT_BUF_RX_ENABLE
  32. #include <target_if_direct_buf_rx_api.h>
  33. #endif
  34. extern int spectral_debug_level;
  35. #ifdef WLAN_CONV_SPECTRAL_ENABLE
  36. #define SPECTRAL_HEXDUMP_OCTET_PRINT_SIZE (3)
  37. #define SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE (16)
  38. #define SPECTRAL_HEXDUMP_EXTRA_BUFFER_PER_LINE (16)
  39. /*
  40. * Provision for the expected hexdump line size as follows:
  41. *
  42. * Size per octet multiplied by number of octets per line
  43. * +
  44. * ASCII representation which is equivalent in print size to number of octets
  45. * per line
  46. * +
  47. * Some extra buffer
  48. */
  49. #define SPECTRAL_HEXDUMP_LINESIZE \
  50. ((SPECTRAL_HEXDUMP_OCTET_PRINT_SIZE * \
  51. SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE) + \
  52. SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE + \
  53. SPECTRAL_HEXDUMP_EXTRA_BUFFER_PER_LINE)
  54. /**
  55. * target_if_spectral_hexdump() - Print hexdump of the given buffer
  56. * @_buf: Pointer to buffer
  57. * @_len: Length of the buffer
  58. *
  59. * Print the hexdump of buffer upto given length. Print upto
  60. * SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE per line, followed by the ASCII
  61. * representation of these octets.
  62. */
  63. static inline void target_if_spectral_hexdump(unsigned char *_buf, int _len)
  64. {
  65. int i, mod;
  66. unsigned char ascii[SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE + 1];
  67. unsigned char *pc = (_buf);
  68. char hexdump_line[SPECTRAL_HEXDUMP_LINESIZE + 1];
  69. int loc = 0;
  70. qdf_mem_zero(hexdump_line, sizeof(hexdump_line));
  71. for (i = 0; i < _len; i++) {
  72. mod = i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE;
  73. if (!mod) {
  74. if (i) {
  75. qdf_assert_always(loc < sizeof(hexdump_line));
  76. loc += snprintf(&hexdump_line[loc],
  77. sizeof(hexdump_line) - loc,
  78. " %s", ascii);
  79. spectral_debug("%s", hexdump_line);
  80. qdf_mem_zero(hexdump_line,
  81. sizeof(hexdump_line));
  82. loc = 0;
  83. }
  84. }
  85. qdf_assert_always(loc < sizeof(hexdump_line));
  86. loc += snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc,
  87. " %02x", pc[i]);
  88. if ((pc[i] < 0x20) || (pc[i] > 0x7e))
  89. ascii[mod] = '.';
  90. else
  91. ascii[mod] = pc[i];
  92. ascii[(mod) + 1] = '\0';
  93. }
  94. while ((i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE) != 0) {
  95. qdf_assert_always(loc < sizeof(hexdump_line));
  96. loc += snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc,
  97. " ");
  98. i++;
  99. }
  100. qdf_assert_always(loc < sizeof(hexdump_line));
  101. snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc, " %s", ascii);
  102. spectral_debug("%s", hexdump_line);
  103. }
  104. /**
  105. * target_if_print_buf() - Prints given buffer for given length
  106. * @pbuf: Pointer to buffer
  107. * @len: length
  108. *
  109. * Prints given buffer for given length
  110. *
  111. * Return: void
  112. */
  113. static void
  114. target_if_print_buf(uint8_t *pbuf, int len)
  115. {
  116. int i = 0;
  117. for (i = 0; i < len; i++) {
  118. spectral_debug("%02X ", pbuf[i]);
  119. if (i % 32 == 31)
  120. spectral_debug("\n");
  121. }
  122. }
  123. int
  124. target_if_spectral_dump_fft(uint8_t *pfft, int fftlen)
  125. {
  126. int i = 0;
  127. /*
  128. * TODO : Do not delete the following print
  129. * The scripts used to validate Spectral depend on this Print
  130. */
  131. spectral_debug("SPECTRAL : FFT Length is 0x%x (%d)", fftlen, fftlen);
  132. spectral_debug("fft_data # ");
  133. for (i = 0; i < fftlen; i++)
  134. spectral_debug("%d ", pfft[i]);
  135. spectral_debug("\n");
  136. return 0;
  137. }
  138. QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral)
  139. {
  140. struct crash_inject param;
  141. if (!spectral) {
  142. spectral_err("Spectral LMAC object is null");
  143. return QDF_STATUS_E_INVAL;
  144. }
  145. qdf_mem_set(&param, sizeof(param), 0);
  146. param.type = 1; //RECOVERY_SIM_ASSERT
  147. return spectral->param_wmi_cmd_ops.wmi_spectral_crash_inject(
  148. GET_WMI_HDL_FROM_PDEV(spectral->pdev_obj), &param);
  149. }
  150. void
  151. target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p)
  152. {
  153. spectral_debug("\nSAMP Packet : -------------------- START --------------------");
  154. spectral_debug("Freq = %d", p->freq);
  155. spectral_debug("RSSI = %d", p->rssi);
  156. spectral_debug("Bin Count = %d", p->pwr_count);
  157. spectral_debug("Timestamp = %d", p->tstamp);
  158. spectral_debug("SAMP Packet : -------------------- END -----------------------");
  159. }
  160. void
  161. target_if_dbg_print_samp_msg(struct spectral_samp_msg *ss_msg)
  162. {
  163. int i = 0;
  164. struct spectral_samp_data *p = &ss_msg->samp_data;
  165. struct spectral_classifier_params *pc = &p->classifier_params;
  166. struct interf_src_rsp *pi = &p->interf_list;
  167. spectral_dbg_line();
  168. spectral_debug("Spectral Message");
  169. spectral_dbg_line();
  170. spectral_debug("Signature : 0x%x", ss_msg->signature);
  171. spectral_debug("Freq : %d", ss_msg->freq);
  172. spectral_debug("Freq load : %d", ss_msg->freq_loading);
  173. spectral_debug("Intfnc type : %d", ss_msg->int_type);
  174. spectral_dbg_line();
  175. spectral_debug("Spectral Data info");
  176. spectral_dbg_line();
  177. spectral_debug("data length : %d", p->spectral_data_len);
  178. spectral_debug("rssi : %d", p->spectral_rssi);
  179. spectral_debug("combined rssi : %d", p->spectral_combined_rssi);
  180. spectral_debug("upper rssi : %d", p->spectral_upper_rssi);
  181. spectral_debug("lower rssi : %d", p->spectral_lower_rssi);
  182. spectral_debug("bw info : %d", p->spectral_bwinfo);
  183. spectral_debug("timestamp : %d", p->spectral_tstamp);
  184. spectral_debug("max index : %d", p->spectral_max_index);
  185. spectral_debug("max exp : %d", p->spectral_max_exp);
  186. spectral_debug("max mag : %d", p->spectral_max_mag);
  187. spectral_debug("last timstamp : %d", p->spectral_last_tstamp);
  188. spectral_debug("upper max idx : %d", p->spectral_upper_max_index);
  189. spectral_debug("lower max idx : %d", p->spectral_lower_max_index);
  190. spectral_debug("bin power count : %d", p->bin_pwr_count);
  191. spectral_dbg_line();
  192. spectral_debug("Classifier info");
  193. spectral_dbg_line();
  194. spectral_debug("20/40 Mode : %d", pc->spectral_20_40_mode);
  195. spectral_debug("dc index : %d", pc->spectral_dc_index);
  196. spectral_debug("dc in MHz : %d", pc->spectral_dc_in_mhz);
  197. spectral_debug("upper channel : %d", pc->upper_chan_in_mhz);
  198. spectral_debug("lower channel : %d", pc->lower_chan_in_mhz);
  199. spectral_dbg_line();
  200. spectral_debug("Interference info");
  201. spectral_dbg_line();
  202. spectral_debug("inter count : %d", pi->count);
  203. for (i = 0; i < pi->count; i++) {
  204. spectral_debug("inter type : %d",
  205. pi->interf[i].interf_type);
  206. spectral_debug("min freq : %d",
  207. pi->interf[i].interf_min_freq);
  208. spectral_debug("max freq : %d",
  209. pi->interf[i].interf_max_freq);
  210. }
  211. }
  212. uint32_t
  213. target_if_get_offset_swar_sec80(uint32_t channel_width)
  214. {
  215. uint32_t offset = 0;
  216. switch (channel_width) {
  217. case CH_WIDTH_20MHZ:
  218. offset = OFFSET_CH_WIDTH_20;
  219. break;
  220. case CH_WIDTH_40MHZ:
  221. offset = OFFSET_CH_WIDTH_40;
  222. break;
  223. case CH_WIDTH_80MHZ:
  224. offset = OFFSET_CH_WIDTH_80;
  225. break;
  226. case CH_WIDTH_160MHZ:
  227. case CH_WIDTH_80P80MHZ:
  228. offset = OFFSET_CH_WIDTH_160;
  229. break;
  230. default:
  231. offset = OFFSET_CH_WIDTH_80;
  232. break;
  233. }
  234. return offset;
  235. }
  236. /**
  237. * target_if_dump_summary_report_gen2() - Dump Spectral Summary Report for gen2
  238. * @ptlv: Pointer to Spectral Phyerr TLV
  239. * @tlvlen: length
  240. * @is_160_format: Indicates whether information provided by HW is in altered
  241. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  242. *
  243. * Dump Spectral Summary Report for gen2
  244. *
  245. * Return: Success/Failure
  246. */
  247. static int
  248. target_if_dump_summary_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv,
  249. int tlvlen, bool is_160_format)
  250. {
  251. /*
  252. * For simplicity, everything is defined as uint32_t (except one).
  253. * Proper code will later use the right sizes.
  254. */
  255. /*
  256. * For easy comparision between MDK team and OS team, the MDK script
  257. * variable names have been used
  258. */
  259. uint32_t agc_mb_gain;
  260. uint32_t sscan_gidx;
  261. uint32_t agc_total_gain;
  262. uint32_t recent_rfsat;
  263. uint32_t ob_flag;
  264. uint32_t nb_mask;
  265. uint32_t peak_mag;
  266. int16_t peak_inx;
  267. uint32_t ss_summary_A = 0;
  268. uint32_t ss_summary_B = 0;
  269. uint32_t ss_summary_C = 0;
  270. uint32_t ss_summary_D = 0;
  271. uint32_t ss_summary_E = 0;
  272. struct spectral_phyerr_hdr_gen2 *phdr =
  273. (struct spectral_phyerr_hdr_gen2 *)(
  274. (uint8_t *)ptlv +
  275. sizeof(struct spectral_phyerr_tlv_gen2));
  276. spectral_debug("SPECTRAL : SPECTRAL SUMMARY REPORT");
  277. if (is_160_format) {
  278. if (tlvlen != 20) {
  279. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  280. tlvlen);
  281. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  282. return -EPERM;
  283. }
  284. /* Doing copy as the contents may not be aligned */
  285. qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int));
  286. qdf_mem_copy(&ss_summary_B,
  287. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  288. sizeof(int));
  289. qdf_mem_copy(&ss_summary_C,
  290. (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)),
  291. sizeof(int));
  292. qdf_mem_copy(&ss_summary_D,
  293. (uint8_t *)((uint8_t *)phdr + 3 * sizeof(int)),
  294. sizeof(int));
  295. qdf_mem_copy(&ss_summary_E,
  296. (uint8_t *)((uint8_t *)phdr + 4 * sizeof(int)),
  297. sizeof(int));
  298. /*
  299. * The following is adapted from MDK scripts for
  300. * easier comparability
  301. */
  302. recent_rfsat = ((ss_summary_A >> 8) & 0x1);
  303. sscan_gidx = (ss_summary_A & 0xff);
  304. spectral_debug("sscan_gidx=%d, is_recent_rfsat=%d",
  305. sscan_gidx, recent_rfsat);
  306. /* First segment */
  307. agc_mb_gain = ((ss_summary_B >> 10) & 0x7f);
  308. agc_total_gain = (ss_summary_B & 0x3ff);
  309. nb_mask = ((ss_summary_C >> 22) & 0xff);
  310. ob_flag = ((ss_summary_B >> 17) & 0x1);
  311. peak_inx = (ss_summary_C & 0xfff);
  312. if (peak_inx > 2047)
  313. peak_inx = peak_inx - 4096;
  314. peak_mag = ((ss_summary_C >> 12) & 0x3ff);
  315. spectral_debug("agc_total_gain_segid0 = 0x%.2x, agc_mb_gain_segid0=%d",
  316. agc_total_gain, agc_mb_gain);
  317. spectral_debug("nb_mask_segid0 = 0x%.2x, ob_flag_segid0=%d, peak_index_segid0=%d, peak_mag_segid0=%d",
  318. nb_mask, ob_flag, peak_inx, peak_mag);
  319. /* Second segment */
  320. agc_mb_gain = ((ss_summary_D >> 10) & 0x7f);
  321. agc_total_gain = (ss_summary_D & 0x3ff);
  322. nb_mask = ((ss_summary_E >> 22) & 0xff);
  323. ob_flag = ((ss_summary_D >> 17) & 0x1);
  324. peak_inx = (ss_summary_E & 0xfff);
  325. if (peak_inx > 2047)
  326. peak_inx = peak_inx - 4096;
  327. peak_mag = ((ss_summary_E >> 12) & 0x3ff);
  328. spectral_debug("agc_total_gain_segid1 = 0x%.2x, agc_mb_gain_segid1=%d",
  329. agc_total_gain, agc_mb_gain);
  330. spectral_debug("nb_mask_segid1 = 0x%.2x, ob_flag_segid1=%d, peak_index_segid1=%d, peak_mag_segid1=%d",
  331. nb_mask, ob_flag, peak_inx, peak_mag);
  332. } else {
  333. if (tlvlen != 8) {
  334. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  335. tlvlen);
  336. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  337. return -EPERM;
  338. }
  339. /* Doing copy as the contents may not be aligned */
  340. qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int));
  341. qdf_mem_copy(&ss_summary_B,
  342. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  343. sizeof(int));
  344. nb_mask = ((ss_summary_B >> 22) & 0xff);
  345. ob_flag = ((ss_summary_B >> 30) & 0x1);
  346. peak_inx = (ss_summary_B & 0xfff);
  347. if (peak_inx > 2047)
  348. peak_inx = peak_inx - 4096;
  349. peak_mag = ((ss_summary_B >> 12) & 0x3ff);
  350. agc_mb_gain = ((ss_summary_A >> 24) & 0x7f);
  351. agc_total_gain = (ss_summary_A & 0x3ff);
  352. sscan_gidx = ((ss_summary_A >> 16) & 0xff);
  353. recent_rfsat = ((ss_summary_B >> 31) & 0x1);
  354. spectral_debug("nb_mask = 0x%.2x, ob_flag=%d, peak_index=%d, peak_mag=%d, agc_mb_gain=%d, agc_total_gain=%d, sscan_gidx=%d, recent_rfsat=%d",
  355. nb_mask, ob_flag, peak_inx, peak_mag,
  356. agc_mb_gain, agc_total_gain, sscan_gidx,
  357. recent_rfsat);
  358. }
  359. return 0;
  360. }
  361. /**
  362. * target_if_process_sfft_report_gen2() - Process Search FFT Report
  363. * @ptlv: Pointer to Spectral Phyerr TLV
  364. * @tlvlen: length
  365. * @p_fft_info: Pointer to search fft info
  366. *
  367. * Dump Spectral Summary Report for gen2
  368. *
  369. * Return: Success/Failure
  370. */
  371. static int
  372. target_if_process_sfft_report_gen2(
  373. struct spectral_phyerr_tlv_gen2 *ptlv,
  374. int tlvlen,
  375. struct spectral_search_fft_info_gen2 *p_fft_info)
  376. {
  377. /*
  378. * For simplicity, everything is defined as uint32_t (except one).
  379. * Proper code will later use the right sizes.
  380. */
  381. /*
  382. * For easy comparision between MDK team and OS team, the MDK script
  383. * variable names have been used
  384. */
  385. uint32_t relpwr_db;
  386. uint32_t num_str_bins_ib;
  387. uint32_t base_pwr;
  388. uint32_t total_gain_info;
  389. uint32_t fft_chn_idx;
  390. int16_t peak_inx;
  391. uint32_t avgpwr_db;
  392. uint32_t peak_mag;
  393. uint32_t fft_summary_A = 0;
  394. uint32_t fft_summary_B = 0;
  395. uint8_t *tmp = (uint8_t *)ptlv;
  396. struct spectral_phyerr_hdr_gen2 *phdr =
  397. (struct spectral_phyerr_hdr_gen2 *)(
  398. tmp +
  399. sizeof(struct spectral_phyerr_tlv_gen2));
  400. /* Relook this */
  401. if (tlvlen < 8) {
  402. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  403. tlvlen);
  404. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  405. return -EPERM;
  406. }
  407. /* Doing copy as the contents may not be aligned */
  408. qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int));
  409. qdf_mem_copy(&fft_summary_B,
  410. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  411. sizeof(int));
  412. relpwr_db = ((fft_summary_B >> 26) & 0x3f);
  413. num_str_bins_ib = fft_summary_B & 0xff;
  414. base_pwr = ((fft_summary_A >> 14) & 0x1ff);
  415. total_gain_info = ((fft_summary_A >> 23) & 0x1ff);
  416. fft_chn_idx = ((fft_summary_A >> 12) & 0x3);
  417. peak_inx = fft_summary_A & 0xfff;
  418. if (peak_inx > 2047)
  419. peak_inx = peak_inx - 4096;
  420. avgpwr_db = ((fft_summary_B >> 18) & 0xff);
  421. peak_mag = ((fft_summary_B >> 8) & 0x3ff);
  422. /* Populate the Search FFT Info */
  423. if (p_fft_info) {
  424. p_fft_info->relpwr_db = relpwr_db;
  425. p_fft_info->num_str_bins_ib = num_str_bins_ib;
  426. p_fft_info->base_pwr = base_pwr;
  427. p_fft_info->total_gain_info = total_gain_info;
  428. p_fft_info->fft_chn_idx = fft_chn_idx;
  429. p_fft_info->peak_inx = peak_inx;
  430. p_fft_info->avgpwr_db = avgpwr_db;
  431. p_fft_info->peak_mag = peak_mag;
  432. }
  433. return 0;
  434. }
  435. /**
  436. * target_if_dump_adc_report_gen2() - Dump ADC Reports for gen2
  437. * @ptlv: Pointer to Spectral Phyerr TLV
  438. * @tlvlen: length
  439. *
  440. * Dump ADC Reports for gen2
  441. *
  442. * Return: Success/Failure
  443. */
  444. static int
  445. target_if_dump_adc_report_gen2(
  446. struct spectral_phyerr_tlv_gen2 *ptlv, int tlvlen)
  447. {
  448. int i;
  449. uint32_t *pdata;
  450. uint32_t data;
  451. /*
  452. * For simplicity, everything is defined as uint32_t (except one).
  453. * Proper code will later use the right sizes.
  454. */
  455. uint32_t samp_fmt;
  456. uint32_t chn_idx;
  457. uint32_t recent_rfsat;
  458. uint32_t agc_mb_gain;
  459. uint32_t agc_total_gain;
  460. uint32_t adc_summary = 0;
  461. uint8_t *ptmp = (uint8_t *)ptlv;
  462. spectral_debug("SPECTRAL : ADC REPORT");
  463. /* Relook this */
  464. if (tlvlen < 4) {
  465. spectral_err("Unexpected TLV length %d for ADC Report! Hexdump follows",
  466. tlvlen);
  467. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  468. return -EPERM;
  469. }
  470. qdf_mem_copy(&adc_summary, (uint8_t *)(ptlv + 4), sizeof(int));
  471. samp_fmt = ((adc_summary >> 28) & 0x1);
  472. chn_idx = ((adc_summary >> 24) & 0x3);
  473. recent_rfsat = ((adc_summary >> 23) & 0x1);
  474. agc_mb_gain = ((adc_summary >> 16) & 0x7f);
  475. agc_total_gain = adc_summary & 0x3ff;
  476. spectral_debug("samp_fmt= %u, chn_idx= %u, recent_rfsat= %u, agc_mb_gain=%u agc_total_gain=%u",
  477. samp_fmt, chn_idx, recent_rfsat, agc_mb_gain,
  478. agc_total_gain);
  479. for (i = 0; i < (tlvlen / 4); i++) {
  480. pdata = (uint32_t *)(ptmp + 4 + i * 4);
  481. data = *pdata;
  482. /* Interpreting capture format 1 */
  483. if (1) {
  484. uint8_t i1;
  485. uint8_t q1;
  486. uint8_t i2;
  487. uint8_t q2;
  488. int8_t si1;
  489. int8_t sq1;
  490. int8_t si2;
  491. int8_t sq2;
  492. i1 = data & 0xff;
  493. q1 = (data >> 8) & 0xff;
  494. i2 = (data >> 16) & 0xff;
  495. q2 = (data >> 24) & 0xff;
  496. if (i1 > 127)
  497. si1 = i1 - 256;
  498. else
  499. si1 = i1;
  500. if (q1 > 127)
  501. sq1 = q1 - 256;
  502. else
  503. sq1 = q1;
  504. if (i2 > 127)
  505. si2 = i2 - 256;
  506. else
  507. si2 = i2;
  508. if (q2 > 127)
  509. sq2 = q2 - 256;
  510. else
  511. sq2 = q2;
  512. spectral_debug("SPECTRAL ADC : Interpreting capture format 1");
  513. spectral_debug("adc_data_format_1 # %d %d %d",
  514. 2 * i, si1, sq1);
  515. spectral_debug("adc_data_format_1 # %d %d %d",
  516. 2 * i + 1, si2, sq2);
  517. }
  518. /* Interpreting capture format 0 */
  519. if (1) {
  520. uint16_t i1;
  521. uint16_t q1;
  522. int16_t si1;
  523. int16_t sq1;
  524. i1 = data & 0xffff;
  525. q1 = (data >> 16) & 0xffff;
  526. if (i1 > 32767)
  527. si1 = i1 - 65536;
  528. else
  529. si1 = i1;
  530. if (q1 > 32767)
  531. sq1 = q1 - 65536;
  532. else
  533. sq1 = q1;
  534. spectral_debug("SPECTRAL ADC : Interpreting capture format 0");
  535. spectral_debug("adc_data_format_2 # %d %d %d",
  536. i, si1, sq1);
  537. }
  538. }
  539. spectral_debug("\n");
  540. return 0;
  541. }
  542. /**
  543. * target_if_dump_sfft_report_gen2() - Process Search FFT Report for gen2
  544. * @ptlv: Pointer to Spectral Phyerr TLV
  545. * @tlvlen: length
  546. * @is_160_format: Indicates 160 format
  547. *
  548. * Process Search FFT Report for gen2
  549. *
  550. * Return: Success/Failure
  551. */
  552. static int
  553. target_if_dump_sfft_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv,
  554. int tlvlen, bool is_160_format)
  555. {
  556. int i;
  557. uint32_t fft_mag;
  558. /*
  559. * For simplicity, everything is defined as uint32_t (except one).
  560. * Proper code will later use the right sizes.
  561. */
  562. /*
  563. * For easy comparision between MDK team and OS team, the MDK script
  564. * variable names have been used
  565. */
  566. uint32_t relpwr_db;
  567. uint32_t num_str_bins_ib;
  568. uint32_t base_pwr;
  569. uint32_t total_gain_info;
  570. uint32_t fft_chn_idx;
  571. int16_t peak_inx;
  572. uint32_t avgpwr_db;
  573. uint32_t peak_mag;
  574. uint8_t segid;
  575. uint32_t fft_summary_A = 0;
  576. uint32_t fft_summary_B = 0;
  577. uint32_t fft_summary_C = 0;
  578. uint8_t *tmp = (uint8_t *)ptlv;
  579. struct spectral_phyerr_hdr_gen2 *phdr =
  580. (struct spectral_phyerr_hdr_gen2 *)(
  581. tmp +
  582. sizeof(struct spectral_phyerr_tlv_gen2));
  583. uint32_t segid_skiplen = 0;
  584. if (is_160_format)
  585. segid_skiplen = sizeof(SPECTRAL_SEGID_INFO);
  586. spectral_debug("SPECTRAL : SEARCH FFT REPORT");
  587. /* Relook this */
  588. if (tlvlen < (8 + segid_skiplen)) {
  589. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  590. tlvlen);
  591. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  592. return -EPERM;
  593. }
  594. /* Doing copy as the contents may not be aligned */
  595. qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int));
  596. qdf_mem_copy(&fft_summary_B,
  597. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  598. sizeof(int));
  599. if (is_160_format)
  600. qdf_mem_copy(&fft_summary_C,
  601. (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)),
  602. sizeof(int));
  603. relpwr_db = ((fft_summary_B >> 26) & 0x3f);
  604. num_str_bins_ib = fft_summary_B & 0xff;
  605. base_pwr = ((fft_summary_A >> 14) & 0x1ff);
  606. total_gain_info = ((fft_summary_A >> 23) & 0x1ff);
  607. fft_chn_idx = ((fft_summary_A >> 12) & 0x3);
  608. peak_inx = fft_summary_A & 0xfff;
  609. if (peak_inx > 2047)
  610. peak_inx = peak_inx - 4096;
  611. avgpwr_db = ((fft_summary_B >> 18) & 0xff);
  612. peak_mag = ((fft_summary_B >> 8) & 0x3ff);
  613. spectral_debug("Header A = 0x%x Header B = 0x%x",
  614. phdr->hdr_a, phdr->hdr_b);
  615. spectral_debug("Base Power= 0x%x, Total Gain= %d, relpwr_db=%d, num_str_bins_ib=%d fft_chn_idx=%d peak_inx=%d avgpwr_db=%d peak_mag=%d",
  616. base_pwr, total_gain_info, relpwr_db, num_str_bins_ib,
  617. fft_chn_idx, peak_inx, avgpwr_db, peak_mag);
  618. if (is_160_format) {
  619. segid = fft_summary_C & 0x1;
  620. spectral_debug("Segment ID: %hhu", segid);
  621. }
  622. spectral_debug("FFT bins:");
  623. for (i = 0; i < (tlvlen - 8 - segid_skiplen); i++) {
  624. fft_mag = ((uint8_t *)ptlv)[12 + segid_skiplen + i];
  625. spectral_debug("%d %d, ", i, fft_mag);
  626. }
  627. spectral_debug("\n");
  628. return 0;
  629. }
  630. #ifdef SPECTRAL_DEBUG_SAMP_MSG
  631. /**
  632. * target_if_spectral_log_SAMP_param() - Log SAMP parameters
  633. * @params: Reference to target_if_samp_msg_params
  634. *
  635. * API to log spectral SAMP message parameters
  636. *
  637. * Return: None
  638. */
  639. static void
  640. target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params)
  641. {
  642. target_if_dbg_print_samp_param(params);
  643. }
  644. #else
  645. static void
  646. target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params)
  647. {
  648. }
  649. #endif
  650. int
  651. target_if_process_phyerr_gen2(struct target_if_spectral *spectral,
  652. uint8_t *data,
  653. uint32_t datalen,
  654. struct target_if_spectral_rfqual_info *p_rfqual,
  655. struct target_if_spectral_chan_info *p_chaninfo,
  656. uint64_t tsf64,
  657. struct target_if_spectral_acs_stats *acs_stats)
  658. {
  659. /*
  660. * XXX : The classifier do not use all the members of the SAMP
  661. * message data format.
  662. * The classifier only depends upon the following parameters
  663. *
  664. * 1. Frequency (freq, msg->freq)
  665. * 2. Spectral RSSI (spectral_rssi,
  666. * msg->samp_data.spectral_rssi)
  667. * 3. Bin Power Count (bin_pwr_count,
  668. * msg->samp_data.bin_pwr_count)
  669. * 4. Bin Power values (bin_pwr, msg->samp_data.bin_pwr[0]
  670. * 5. Spectral Timestamp (spectral_tstamp,
  671. * msg->samp_data.spectral_tstamp)
  672. * 6. MAC Address (macaddr, msg->macaddr)
  673. *
  674. * This function prepares the params structure and populates it
  675. * with
  676. * relevant values, this is in turn passed to
  677. * spectral_create_samp_msg()
  678. * to prepare fully formatted Spectral SAMP message
  679. *
  680. * XXX : Need to verify
  681. * 1. Order of FFT bin values
  682. *
  683. */
  684. struct target_if_samp_msg_params params;
  685. struct spectral_search_fft_info_gen2 search_fft_info;
  686. struct spectral_search_fft_info_gen2 *p_sfft = &search_fft_info;
  687. struct spectral_search_fft_info_gen2 search_fft_info_sec80;
  688. struct spectral_search_fft_info_gen2 *p_sfft_sec80 =
  689. &search_fft_info_sec80;
  690. uint32_t segid_skiplen = 0;
  691. int8_t rssi_up = 0;
  692. int8_t rssi_low = 0;
  693. int8_t chn_idx_highest_enabled = 0;
  694. int8_t chn_idx_lowest_enabled = 0;
  695. uint8_t control_rssi = 0;
  696. uint8_t extension_rssi = 0;
  697. uint8_t combined_rssi = 0;
  698. uint32_t tstamp = 0;
  699. struct target_if_spectral_ops *p_sops =
  700. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  701. struct spectral_phyerr_tlv_gen2 *ptlv =
  702. (struct spectral_phyerr_tlv_gen2 *)data;
  703. struct spectral_phyerr_tlv_gen2 *ptlv_sec80 = NULL;
  704. struct spectral_phyerr_fft_gen2 *pfft = NULL;
  705. struct spectral_phyerr_fft_gen2 *pfft_sec80 = NULL;
  706. uint8_t segid = 0;
  707. uint8_t segid_sec80 = 0;
  708. enum phy_ch_width ch_width =
  709. spectral->ch_width[SPECTRAL_SCAN_MODE_NORMAL];
  710. if (spectral->is_160_format)
  711. segid_skiplen = sizeof(SPECTRAL_SEGID_INFO);
  712. pfft = (struct spectral_phyerr_fft_gen2 *)(
  713. data +
  714. sizeof(struct spectral_phyerr_tlv_gen2) +
  715. sizeof(struct spectral_phyerr_hdr_gen2) +
  716. segid_skiplen);
  717. /*
  718. * XXX Extend SPECTRAL_DPRINTK() to use spectral_debug_level,
  719. * and use this facility inside spectral_dump_phyerr_data()
  720. * and supporting functions.
  721. */
  722. if (spectral_debug_level & DEBUG_SPECTRAL2)
  723. target_if_spectral_dump_phyerr_data_gen2(
  724. data, datalen,
  725. spectral->is_160_format);
  726. if (spectral_debug_level & DEBUG_SPECTRAL4) {
  727. target_if_spectral_dump_phyerr_data_gen2(
  728. data, datalen,
  729. spectral->is_160_format);
  730. spectral_debug_level = DEBUG_SPECTRAL;
  731. }
  732. if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  733. /*
  734. * EV# 118023: We tentatively disable the below print
  735. * and provide stats instead.
  736. */
  737. spectral->diag_stats.spectral_mismatch++;
  738. return -EPERM;
  739. }
  740. OS_MEMZERO(&params, sizeof(params));
  741. /* Gen 2 only supports normal Spectral scan currently */
  742. params.smode = SPECTRAL_SCAN_MODE_NORMAL;
  743. if (ptlv->tag == TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  744. if (spectral->is_160_format) {
  745. segid = *((SPECTRAL_SEGID_INFO *)(
  746. (uint8_t *)ptlv +
  747. sizeof(struct spectral_phyerr_tlv_gen2) +
  748. sizeof(struct spectral_phyerr_hdr_gen2)));
  749. if (segid != 0) {
  750. struct spectral_diag_stats *p_diag_stats =
  751. &spectral->diag_stats;
  752. p_diag_stats->spectral_vhtseg1id_mismatch++;
  753. return -EPERM;
  754. }
  755. }
  756. target_if_process_sfft_report_gen2(ptlv, ptlv->length,
  757. &search_fft_info);
  758. tstamp = p_sops->get_tsf64(spectral) & SPECTRAL_TSMASK;
  759. combined_rssi = p_rfqual->rssi_comb;
  760. if (spectral->upper_is_control)
  761. rssi_up = control_rssi;
  762. else
  763. rssi_up = extension_rssi;
  764. if (spectral->lower_is_control)
  765. rssi_low = control_rssi;
  766. else
  767. rssi_low = extension_rssi;
  768. params.rssi = p_rfqual->rssi_comb;
  769. params.lower_rssi = rssi_low;
  770. params.upper_rssi = rssi_up;
  771. if (spectral->sc_spectral_noise_pwr_cal) {
  772. params.chain_ctl_rssi[0] =
  773. p_rfqual->pc_rssi_info[0].rssi_pri20;
  774. params.chain_ctl_rssi[1] =
  775. p_rfqual->pc_rssi_info[1].rssi_pri20;
  776. params.chain_ctl_rssi[2] =
  777. p_rfqual->pc_rssi_info[2].rssi_pri20;
  778. params.chain_ext_rssi[0] =
  779. p_rfqual->pc_rssi_info[0].rssi_sec20;
  780. params.chain_ext_rssi[1] =
  781. p_rfqual->pc_rssi_info[1].rssi_sec20;
  782. params.chain_ext_rssi[2] =
  783. p_rfqual->pc_rssi_info[2].rssi_sec20;
  784. }
  785. /*
  786. * XXX : This actually depends on the programmed chain mask
  787. * This value decides the per-chain enable mask to select
  788. * the input ADC for search FTT.
  789. * For modes upto VHT80, if more than one chain is
  790. * enabled, the max valid chain
  791. * is used. LSB corresponds to chain zero.
  792. * For VHT80_80 and VHT160, the lowest enabled chain is
  793. * used for primary
  794. * detection and highest enabled chain is used for
  795. * secondary detection.
  796. *
  797. * XXX : The current algorithm do not use these control and
  798. * extension channel
  799. * Instead, it just relies on the combined RSSI values
  800. * only.
  801. * For fool-proof detection algorithm, we should take
  802. * these RSSI values in to account.
  803. * This is marked for future enhancements.
  804. */
  805. chn_idx_highest_enabled =
  806. ((spectral->params[params.smode].ss_chn_mask & 0x8) ? 3 :
  807. (spectral->params[params.smode].ss_chn_mask & 0x4) ? 2 :
  808. (spectral->params[params.smode].ss_chn_mask & 0x2) ? 1 : 0);
  809. chn_idx_lowest_enabled =
  810. ((spectral->params[params.smode].ss_chn_mask & 0x1) ? 0 :
  811. (spectral->params[params.smode].ss_chn_mask & 0x2) ? 1 :
  812. (spectral->params[params.smode].ss_chn_mask & 0x4) ? 2 : 3);
  813. control_rssi = (uint8_t)
  814. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20;
  815. extension_rssi = (uint8_t)
  816. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20;
  817. params.bwinfo = 0;
  818. params.tstamp = 0;
  819. params.max_mag = p_sfft->peak_mag;
  820. params.max_index = p_sfft->peak_inx;
  821. params.max_exp = 0;
  822. params.peak = 0;
  823. params.bin_pwr_data = (uint8_t *)pfft;
  824. params.freq = p_sops->get_current_channel(spectral);
  825. params.freq_loading = 0;
  826. params.interf_list.count = 0;
  827. params.max_lower_index = 0;
  828. params.max_upper_index = 0;
  829. params.nb_lower = 0;
  830. params.nb_upper = 0;
  831. /*
  832. * For modes upto VHT80, the noise floor is populated with the
  833. * one corresponding
  834. * to the highest enabled antenna chain
  835. */
  836. params.noise_floor =
  837. p_rfqual->noise_floor[chn_idx_highest_enabled];
  838. params.datalen = ptlv->length;
  839. params.pwr_count = ptlv->length -
  840. sizeof(struct spectral_phyerr_hdr_gen2) - segid_skiplen;
  841. params.tstamp = (tsf64 & SPECTRAL_TSMASK);
  842. acs_stats->ctrl_nf = params.noise_floor;
  843. acs_stats->ext_nf = params.noise_floor;
  844. acs_stats->nfc_ctl_rssi = control_rssi;
  845. acs_stats->nfc_ext_rssi = extension_rssi;
  846. if (spectral->is_160_format &&
  847. is_ch_width_160_or_80p80(ch_width)) {
  848. /*
  849. * We expect to see one more Search FFT report, and it
  850. * should be equal in size to the current one.
  851. */
  852. if (datalen < (
  853. 2 * (
  854. sizeof(struct spectral_phyerr_tlv_gen2) +
  855. ptlv->length))) {
  856. struct spectral_diag_stats *p_diag_stats =
  857. &spectral->diag_stats;
  858. p_diag_stats->spectral_sec80_sfft_insufflen++;
  859. return -EPERM;
  860. }
  861. ptlv_sec80 = (struct spectral_phyerr_tlv_gen2 *)(
  862. data +
  863. sizeof(struct spectral_phyerr_tlv_gen2) +
  864. ptlv->length);
  865. if (ptlv_sec80->signature !=
  866. SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  867. spectral->diag_stats.spectral_mismatch++;
  868. return -EPERM;
  869. }
  870. if (ptlv_sec80->tag != TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  871. spectral->diag_stats.spectral_no_sec80_sfft++;
  872. return -EPERM;
  873. }
  874. segid_sec80 = *((SPECTRAL_SEGID_INFO *)(
  875. (uint8_t *)ptlv_sec80 +
  876. sizeof(struct spectral_phyerr_tlv_gen2) +
  877. sizeof(struct spectral_phyerr_hdr_gen2)));
  878. if (segid_sec80 != 1) {
  879. struct spectral_diag_stats *p_diag_stats =
  880. &spectral->diag_stats;
  881. p_diag_stats->spectral_vhtseg2id_mismatch++;
  882. return -EPERM;
  883. }
  884. params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1;
  885. params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2;
  886. target_if_process_sfft_report_gen2(
  887. ptlv_sec80,
  888. ptlv_sec80->length,
  889. &search_fft_info_sec80);
  890. pfft_sec80 = (struct spectral_phyerr_fft_gen2 *)(
  891. ((uint8_t *)ptlv_sec80) +
  892. sizeof(struct spectral_phyerr_tlv_gen2) +
  893. sizeof(struct spectral_phyerr_hdr_gen2) +
  894. segid_skiplen);
  895. /* XXX: Confirm. TBD at SoD. */
  896. params.rssi_sec80 = p_rfqual->rssi_comb;
  897. if (spectral->is_sec80_rssi_war_required)
  898. params.rssi_sec80 =
  899. target_if_get_combrssi_sec80_seg_gen2
  900. (spectral, &search_fft_info_sec80);
  901. /* XXX: Determine dynamically. TBD at SoD. */
  902. /*
  903. * For VHT80_80/VHT160, the noise floor for primary
  904. * 80MHz segment is populated with the
  905. * lowest enabled antenna chain and the noise floor for
  906. * secondary 80MHz segment is populated
  907. * with the highest enabled antenna chain
  908. */
  909. params.noise_floor_sec80 =
  910. p_rfqual->noise_floor[chn_idx_highest_enabled];
  911. params.noise_floor =
  912. p_rfqual->noise_floor[chn_idx_lowest_enabled];
  913. params.max_mag_sec80 = p_sfft_sec80->peak_mag;
  914. params.max_index_sec80 = p_sfft_sec80->peak_inx;
  915. /* XXX Does this definition of datalen *still hold? */
  916. params.datalen_sec80 = ptlv_sec80->length;
  917. params.pwr_count_sec80 =
  918. ptlv_sec80->length -
  919. sizeof(struct spectral_phyerr_hdr_gen2) -
  920. segid_skiplen;
  921. params.bin_pwr_data_sec80 = (uint8_t *)pfft_sec80;
  922. }
  923. qdf_mem_copy(&params.classifier_params,
  924. &spectral->classifier_params,
  925. sizeof(struct spectral_classifier_params));
  926. target_if_spectral_log_SAMP_param(&params);
  927. target_if_spectral_create_samp_msg(spectral, &params);
  928. }
  929. return 0;
  930. }
  931. int
  932. target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr)
  933. {
  934. uint32_t a = 0;
  935. uint32_t b = 0;
  936. qdf_mem_copy(&a, (uint8_t *)phdr, sizeof(int));
  937. qdf_mem_copy(&b,
  938. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  939. sizeof(int));
  940. spectral_debug("SPECTRAL : HEADER A 0x%x (%d)", a, a);
  941. spectral_debug("SPECTRAL : HEADER B 0x%x (%d)", b, b);
  942. return 0;
  943. }
  944. int8_t
  945. target_if_get_combrssi_sec80_seg_gen2(
  946. struct target_if_spectral *spectral,
  947. struct spectral_search_fft_info_gen2 *p_sfft_sec80)
  948. {
  949. uint32_t avgpwr_db = 0;
  950. uint32_t total_gain_db = 0;
  951. uint32_t offset = 0;
  952. int8_t comb_rssi = 0;
  953. /* Obtain required parameters for algorithm from search FFT report */
  954. avgpwr_db = p_sfft_sec80->avgpwr_db;
  955. total_gain_db = p_sfft_sec80->total_gain_info;
  956. /* Calculate offset */
  957. offset = target_if_get_offset_swar_sec80(
  958. spectral->ch_width[SPECTRAL_SCAN_MODE_NORMAL]);
  959. /* Calculate RSSI */
  960. comb_rssi = ((avgpwr_db - total_gain_db) + offset);
  961. return comb_rssi;
  962. }
  963. int
  964. target_if_spectral_dump_tlv_gen2(
  965. struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format)
  966. {
  967. int ret = 0;
  968. /*
  969. * TODO : Do not delete the following print
  970. * The scripts used to validate Spectral depend on this Print
  971. */
  972. spectral_debug("SPECTRAL : TLV Length is 0x%x (%d)",
  973. ptlv->length, ptlv->length);
  974. switch (ptlv->tag) {
  975. case TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2:
  976. ret =
  977. target_if_dump_summary_report_gen2(
  978. ptlv, ptlv->length, is_160_format);
  979. break;
  980. case TLV_TAG_SEARCH_FFT_REPORT_GEN2:
  981. ret =
  982. target_if_dump_sfft_report_gen2(ptlv, ptlv->length,
  983. is_160_format);
  984. break;
  985. case TLV_TAG_ADC_REPORT_GEN2:
  986. ret = target_if_dump_adc_report_gen2(ptlv, ptlv->length);
  987. break;
  988. default:
  989. spectral_warn("INVALID TLV");
  990. ret = -1;
  991. break;
  992. }
  993. return ret;
  994. }
  995. int
  996. target_if_spectral_dump_phyerr_data_gen2(uint8_t *data, uint32_t datalen,
  997. bool is_160_format)
  998. {
  999. struct spectral_phyerr_tlv_gen2 *ptlv = NULL;
  1000. uint32_t bytes_processed = 0;
  1001. uint32_t bytes_remaining = datalen;
  1002. uint32_t curr_tlv_complete_size = 0;
  1003. if (datalen < sizeof(struct spectral_phyerr_tlv_gen2)) {
  1004. spectral_err("Total PHY error data length %u too short to contain any TLVs",
  1005. datalen);
  1006. return -EPERM;
  1007. }
  1008. while (bytes_processed < datalen) {
  1009. if (bytes_remaining < sizeof(struct spectral_phyerr_tlv_gen2)) {
  1010. spectral_err("Remaining PHY error data length %u too short to contain a TLV",
  1011. bytes_remaining);
  1012. return -EPERM;
  1013. }
  1014. ptlv = (struct spectral_phyerr_tlv_gen2 *)(data +
  1015. bytes_processed);
  1016. if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1017. spectral_err("Invalid signature 0x%x!",
  1018. ptlv->signature);
  1019. return -EPERM;
  1020. }
  1021. curr_tlv_complete_size =
  1022. sizeof(struct spectral_phyerr_tlv_gen2) +
  1023. ptlv->length;
  1024. if (curr_tlv_complete_size > bytes_remaining) {
  1025. spectral_err("TLV size %d greater than number of bytes remaining %d",
  1026. curr_tlv_complete_size, bytes_remaining);
  1027. return -EPERM;
  1028. }
  1029. if (target_if_spectral_dump_tlv_gen2(ptlv, is_160_format) == -1)
  1030. return -EPERM;
  1031. bytes_processed += curr_tlv_complete_size;
  1032. bytes_remaining = datalen - bytes_processed;
  1033. }
  1034. return 0;
  1035. }
  1036. #ifdef DIRECT_BUF_RX_ENABLE
  1037. /**
  1038. * target_if_get_spectral_mode() - Get Spectral scan mode corresponding to a
  1039. * detector id
  1040. * @detector_id: detector id in the Spectral report
  1041. * @rparams: pointer to report params object
  1042. *
  1043. * Helper API to get Spectral scan mode from the detector ID. This mapping is
  1044. * target specific.
  1045. *
  1046. * Return: Spectral scan mode
  1047. */
  1048. static enum spectral_scan_mode
  1049. target_if_get_spectral_mode(enum spectral_detector_id detector_id,
  1050. struct spectral_report_params *rparams)
  1051. {
  1052. if (detector_id >= SPECTRAL_DETECTOR_ID_MAX) {
  1053. spectral_err_rl("Invalid detector id %d", detector_id);
  1054. return SPECTRAL_SCAN_MODE_INVALID;
  1055. }
  1056. return rparams->detid_mode_table[detector_id];
  1057. }
  1058. /**
  1059. * target_if_spectral_get_bin_count_after_len_adj() - Get number of FFT bins in
  1060. * Spectral FFT report
  1061. * @fft_bin_len: FFT bin length reported by target
  1062. * @rpt_mode: Spectral report mode
  1063. * @swar: Spectral FFT bin length adjustments SWAR parameters
  1064. * @fft_bin_size: Size of one FFT bin in bytes
  1065. *
  1066. * Get actual number of FFT bins in the FFT report after adjusting the length
  1067. * by applying the SWARs for getting correct length.
  1068. *
  1069. * Return: FFT bin count
  1070. */
  1071. static size_t
  1072. target_if_spectral_get_bin_count_after_len_adj(
  1073. size_t fft_bin_len, uint8_t rpt_mode,
  1074. struct spectral_fft_bin_len_adj_swar *swar,
  1075. size_t *fft_bin_size)
  1076. {
  1077. size_t fft_bin_count = fft_bin_len;
  1078. if (rpt_mode == 1 && swar->null_fftbin_adj) {
  1079. /*
  1080. * No FFT bins are expected. Explicitly set FFT bin
  1081. * count to 0.
  1082. */
  1083. fft_bin_count = 0;
  1084. *fft_bin_size = 0;
  1085. } else {
  1086. /*
  1087. * Divide fft bin length by appropriate factor depending
  1088. * on the value of fftbin_size_war.
  1089. */
  1090. switch (swar->fftbin_size_war) {
  1091. case SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE:
  1092. fft_bin_count >>= 2;
  1093. *fft_bin_size = 4;
  1094. break;
  1095. case SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE:
  1096. fft_bin_count >>= 1;
  1097. *fft_bin_size = 2;
  1098. /* Ideally we should be dividing fft bin length
  1099. * by 2. Due to a HW bug, actual length is two
  1100. * times the expected length.
  1101. */
  1102. if (swar->packmode_fftbin_size_adj)
  1103. fft_bin_count >>= 1;
  1104. break;
  1105. case SPECTRAL_FFTBIN_SIZE_NO_WAR:
  1106. *fft_bin_size = 1;
  1107. /* No length adjustment */
  1108. break;
  1109. default:
  1110. qdf_assert_always(0);
  1111. }
  1112. if (rpt_mode == 2 && swar->inband_fftbin_size_adj)
  1113. fft_bin_count >>= 1;
  1114. }
  1115. return fft_bin_count;
  1116. }
  1117. /**
  1118. * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3
  1119. * @p_fft_report: Pointer to fft report
  1120. * @p_sfft: Pointer to search fft report
  1121. *
  1122. * Process Search FFT Report for gen3
  1123. *
  1124. * Return: Success/Failure
  1125. */
  1126. static int
  1127. target_if_process_sfft_report_gen3(
  1128. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1129. struct spectral_search_fft_info_gen3 *p_sfft)
  1130. {
  1131. /*
  1132. * For simplicity, everything is defined as uint32_t (except one).
  1133. * Proper code will later use the right sizes.
  1134. */
  1135. /*
  1136. * For easy comparision between MDK team and OS team, the MDK script
  1137. * variable names have been used
  1138. */
  1139. int32_t peak_sidx;
  1140. int32_t peak_mag;
  1141. /* Populate the Search FFT Info */
  1142. if (p_sfft) {
  1143. p_sfft->timestamp = p_fft_report->fft_timestamp;
  1144. p_sfft->fft_detector_id = get_bitfield(p_fft_report->hdr_a,
  1145. 2, 0);
  1146. p_sfft->fft_num = get_bitfield(p_fft_report->hdr_a, 3, 2);
  1147. p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a,
  1148. 12, 5);
  1149. peak_sidx = get_bitfield(p_fft_report->hdr_a, 11, 17);
  1150. p_sfft->fft_peak_sidx = unsigned_to_signed(peak_sidx, 11);
  1151. p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_a, 3, 28);
  1152. p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b,
  1153. 9, 0);
  1154. p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b,
  1155. 8, 9);
  1156. p_sfft->fft_num_str_bins_ib = get_bitfield(p_fft_report->hdr_c,
  1157. 8, 0);
  1158. peak_mag = get_bitfield(p_fft_report->hdr_c, 10, 8);
  1159. p_sfft->fft_peak_mag = unsigned_to_signed(peak_mag, 10);
  1160. p_sfft->fft_avgpwr_db = get_bitfield(p_fft_report->hdr_c,
  1161. 7, 18);
  1162. p_sfft->fft_relpwr_db = get_bitfield(p_fft_report->hdr_c,
  1163. 7, 25);
  1164. }
  1165. return 0;
  1166. }
  1167. /**
  1168. * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3
  1169. * @spectral: Pointer to Spectral object
  1170. * @smode: Spectral scan mode
  1171. * @p_fft_report: Pointer to fft report
  1172. * @p_sfft: Pointer to search fft report
  1173. *
  1174. * Dump FFT Report for gen3
  1175. *
  1176. * Return: void
  1177. */
  1178. static void
  1179. target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
  1180. enum spectral_scan_mode smode,
  1181. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  1182. struct spectral_search_fft_info_gen3 *p_sfft)
  1183. {
  1184. size_t fft_hdr_length = (p_fft_report->fft_hdr_length * 4);
  1185. size_t report_len = (fft_hdr_length + 8);
  1186. size_t fft_bin_len;
  1187. size_t fft_bin_count;
  1188. size_t fft_bin_size;
  1189. size_t fft_bin_len_inband_tfer = 0;
  1190. uint8_t *fft_bin_buf = NULL;
  1191. fft_bin_len = fft_hdr_length - spectral->rparams.fft_report_hdr_len;
  1192. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  1193. fft_bin_len,
  1194. spectral->params[smode].ss_rpt_mode,
  1195. &spectral->len_adj_swar, &fft_bin_size);
  1196. if ((spectral->params[smode].ss_rpt_mode == 2) &&
  1197. spectral->len_adj_swar.inband_fftbin_size_adj)
  1198. fft_bin_len_inband_tfer = fft_bin_len >> 1;
  1199. spectral_debug("Spectral FFT Report");
  1200. spectral_debug("fft_timestamp = 0x%x", p_fft_report->fft_timestamp);
  1201. spectral_debug("fft_hdr_length = %u(32 bit words)",
  1202. p_fft_report->fft_hdr_length);
  1203. spectral_debug("fft_hdr_tag = 0x%x", p_fft_report->fft_hdr_tag);
  1204. spectral_debug("fft_hdr_sig = 0x%x", p_fft_report->fft_hdr_sig);
  1205. spectral_debug("Length field in search fft report is %zu(0x%zx) bytes",
  1206. fft_hdr_length, fft_hdr_length);
  1207. spectral_debug("Total length of search fft report is %zu(0x%zx) bytes",
  1208. report_len, report_len);
  1209. spectral_debug("Target reported fftbins in report is %zu(0x%zx)",
  1210. fft_bin_len, fft_bin_len);
  1211. if ((spectral->params[smode].ss_rpt_mode == 1) &&
  1212. spectral->len_adj_swar.null_fftbin_adj)
  1213. spectral_debug("WAR: Considering number of FFT bins as 0");
  1214. else if ((spectral->params[smode].ss_rpt_mode == 2) &&
  1215. spectral->len_adj_swar.inband_fftbin_size_adj) {
  1216. spectral_debug("FW fftbins actually transferred (in-band report mode) %zu(0x%zx)",
  1217. fft_bin_len_inband_tfer,
  1218. fft_bin_len_inband_tfer);
  1219. }
  1220. spectral_debug("Actual number of fftbins in report is %zu(0x%zx)",
  1221. fft_bin_count, fft_bin_count);
  1222. spectral_debug("fft_detector_id = %u", p_sfft->fft_detector_id);
  1223. spectral_debug("fft_num = %u", p_sfft->fft_num);
  1224. spectral_debug("fft_radar_check = %u", p_sfft->fft_radar_check);
  1225. spectral_debug("fft_peak_sidx = %d", p_sfft->fft_peak_sidx);
  1226. spectral_debug("fft_chn_idx = %u", p_sfft->fft_chn_idx);
  1227. spectral_debug("fft_base_pwr_db = %u", p_sfft->fft_base_pwr_db);
  1228. spectral_debug("fft_total_gain_db = %u", p_sfft->fft_total_gain_db);
  1229. spectral_debug("fft_num_str_bins_ib = %u", p_sfft->fft_num_str_bins_ib);
  1230. spectral_debug("fft_peak_mag = %d", p_sfft->fft_peak_mag);
  1231. spectral_debug("fft_avgpwr_db = %u", p_sfft->fft_avgpwr_db);
  1232. spectral_debug("fft_relpwr_db = %u", p_sfft->fft_relpwr_db);
  1233. if (fft_bin_count > 0) {
  1234. int idx;
  1235. spectral_debug("FFT bins:");
  1236. if (spectral->len_adj_swar.fftbin_size_war ==
  1237. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
  1238. uint32_t *binptr_32 = (uint32_t *)&p_fft_report->buf;
  1239. fft_bin_buf = (uint8_t *)qdf_mem_malloc(MAX_NUM_BINS);
  1240. for (idx = 0; idx < fft_bin_count; idx++)
  1241. fft_bin_buf[idx] = *(binptr_32++);
  1242. } else if (spectral->len_adj_swar.fftbin_size_war ==
  1243. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
  1244. uint16_t *binptr_16 = (uint16_t *)&p_fft_report->buf;
  1245. fft_bin_buf = (uint8_t *)qdf_mem_malloc(MAX_NUM_BINS);
  1246. for (idx = 0; idx < fft_bin_count; idx++)
  1247. fft_bin_buf[idx] = *(binptr_16++);
  1248. } else {
  1249. fft_bin_buf = (uint8_t *)&p_fft_report->buf;
  1250. }
  1251. target_if_spectral_hexdump(fft_bin_buf, fft_bin_count);
  1252. if ((spectral->len_adj_swar.fftbin_size_war !=
  1253. SPECTRAL_FFTBIN_SIZE_NO_WAR) && fft_bin_buf)
  1254. qdf_mem_free(fft_bin_buf);
  1255. }
  1256. }
  1257. #endif
  1258. QDF_STATUS
  1259. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  1260. enum spectral_scan_mode smode,
  1261. uint8_t detector_id) {
  1262. QDF_STATUS status = QDF_STATUS_SUCCESS;
  1263. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1264. spectral_err_rl("Invalid Spectral mode %d", smode);
  1265. return QDF_STATUS_E_INVAL;
  1266. }
  1267. if (!is_ch_width_160_or_80p80(spectral->ch_width[smode])) {
  1268. spectral_err_rl("Scan BW %d is not 160/80p80 for mode %d",
  1269. spectral->ch_width[smode], smode);
  1270. return QDF_STATUS_E_FAILURE;
  1271. }
  1272. switch (spectral->state_160mhz_delivery[smode]) {
  1273. case SPECTRAL_REPORT_WAIT_PRIMARY80:
  1274. if (detector_id == SPECTRAL_DETECTOR_ID_0)
  1275. spectral->state_160mhz_delivery[smode] =
  1276. SPECTRAL_REPORT_RX_PRIMARY80;
  1277. else {
  1278. status = QDF_STATUS_E_FAILURE;
  1279. spectral->diag_stats.spectral_vhtseg1id_mismatch++;
  1280. }
  1281. break;
  1282. case SPECTRAL_REPORT_WAIT_SECONDARY80:
  1283. if (detector_id == SPECTRAL_DETECTOR_ID_1)
  1284. spectral->state_160mhz_delivery[smode] =
  1285. SPECTRAL_REPORT_RX_SECONDARY80;
  1286. else {
  1287. spectral->state_160mhz_delivery[smode] =
  1288. SPECTRAL_REPORT_WAIT_PRIMARY80;
  1289. status = QDF_STATUS_E_FAILURE;
  1290. spectral->diag_stats.spectral_vhtseg2id_mismatch++;
  1291. }
  1292. break;
  1293. case SPECTRAL_REPORT_RX_SECONDARY80:
  1294. /* We don't care about detector id in this state. */
  1295. reset_160mhz_delivery_state_machine(spectral, smode);
  1296. break;
  1297. case SPECTRAL_REPORT_RX_PRIMARY80:
  1298. /* We don't care about detector id in this state */
  1299. spectral->state_160mhz_delivery[smode] =
  1300. SPECTRAL_REPORT_WAIT_SECONDARY80;
  1301. break;
  1302. default:
  1303. break;
  1304. }
  1305. return status;
  1306. }
  1307. #ifdef DIRECT_BUF_RX_ENABLE
  1308. /**
  1309. * target_if_get_detector_id_sscan_summary_report_gen3() - Get Spectral detector
  1310. * ID from Spectral summary report
  1311. * @data: Pointer to Spectral summary report
  1312. *
  1313. * Return: Detector ID
  1314. */
  1315. static uint8_t
  1316. target_if_get_detector_id_sscan_summary_report_gen3(uint8_t *data) {
  1317. struct spectral_sscan_summary_report_gen3 *psscan_summary_report;
  1318. uint8_t detector_id;
  1319. qdf_assert_always(data);
  1320. psscan_summary_report =
  1321. (struct spectral_sscan_summary_report_gen3 *)data;
  1322. detector_id = get_bitfield(
  1323. psscan_summary_report->hdr_a,
  1324. SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3,
  1325. SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_POS_GEN3);
  1326. return detector_id;
  1327. }
  1328. /**
  1329. * target_if_consume_sscan_summary_report_gen3() - Consume Spectral summary
  1330. * report
  1331. * @data: Pointer to Spectral summary report
  1332. * @fields: Pointer to structure to be populated with extracted fields
  1333. * @rparams: Pointer to structure with Spectral report params
  1334. *
  1335. * Consume Spectral summary report for gen3
  1336. *
  1337. * Return: void
  1338. */
  1339. static void
  1340. target_if_consume_sscan_summary_report_gen3(
  1341. uint8_t *data,
  1342. struct sscan_report_fields_gen3 *fields,
  1343. struct spectral_report_params *rparams) {
  1344. struct spectral_sscan_summary_report_gen3 *psscan_summary_report;
  1345. qdf_assert_always(data);
  1346. qdf_assert_always(fields);
  1347. qdf_assert_always(rparams);
  1348. psscan_summary_report =
  1349. (struct spectral_sscan_summary_report_gen3 *)data;
  1350. fields->sscan_agc_total_gain = get_bitfield(
  1351. psscan_summary_report->hdr_a,
  1352. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3,
  1353. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3);
  1354. fields->inband_pwr_db = get_bitfield(
  1355. psscan_summary_report->hdr_a,
  1356. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3,
  1357. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3);
  1358. fields->sscan_pri80 = get_bitfield(
  1359. psscan_summary_report->hdr_a,
  1360. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3,
  1361. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3);
  1362. switch (rparams->version) {
  1363. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  1364. fields->sscan_gainchange = get_bitfield(
  1365. psscan_summary_report->hdr_b,
  1366. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3_V1,
  1367. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3_V1);
  1368. break;
  1369. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  1370. fields->sscan_gainchange = get_bitfield(
  1371. psscan_summary_report->hdr_c,
  1372. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_SIZE_GEN3_V2,
  1373. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_POS_GEN3_V2);
  1374. break;
  1375. default:
  1376. qdf_assert_always(0);
  1377. }
  1378. }
  1379. /**
  1380. * target_if_verify_sig_and_tag_gen3() - Verify tag and signature
  1381. * of spectral report
  1382. * @spectral: Pointer to spectral object
  1383. * @data: Pointer to spectral summary report
  1384. * @exp_tag: iexpected tag value
  1385. *
  1386. * Process fft report for gen3
  1387. *
  1388. * Return: SUCCESS/FAILURE
  1389. */
  1390. static int
  1391. target_if_verify_sig_and_tag_gen3(struct target_if_spectral *spectral,
  1392. uint8_t *data, uint8_t exp_tag)
  1393. {
  1394. uint8_t tag = 0;
  1395. uint8_t signature = 0;
  1396. /* Peek into the data to figure out whether
  1397. * 1) Signature matches the expected value
  1398. * 2) What is inside the package (TAG ID is used for finding this)
  1399. */
  1400. tag = *(data + PHYERR_HDR_TAG_POS);
  1401. signature = *(data + PHYERR_HDR_SIG_POS);
  1402. if (signature != SPECTRAL_PHYERR_SIGNATURE_GEN3) {
  1403. spectral->diag_stats.spectral_mismatch++;
  1404. return -EINVAL;
  1405. }
  1406. if (tag != exp_tag) {
  1407. spectral->diag_stats.spectral_mismatch++;
  1408. return -EINVAL;
  1409. }
  1410. return 0;
  1411. }
  1412. static uint8_t
  1413. target_if_spectral_get_lowest_chn_idx(uint8_t chainmask)
  1414. {
  1415. uint8_t idx;
  1416. for (idx = 0; idx < DBR_MAX_CHAINS; idx++) {
  1417. if (chainmask & 0x1)
  1418. break;
  1419. chainmask >>= 1;
  1420. }
  1421. return idx;
  1422. }
  1423. #ifdef DIRECT_BUF_RX_DEBUG
  1424. static void target_if_spectral_check_buffer_poisoning(
  1425. struct target_if_spectral *spectral,
  1426. struct spectral_report *report,
  1427. int num_fft_bins, enum spectral_scan_mode smode)
  1428. {
  1429. uint32_t *data;
  1430. size_t len;
  1431. size_t words_to_check =
  1432. sizeof(struct spectral_sscan_summary_report_gen3) >> 2;
  1433. bool poisoned_words_found = false;
  1434. if (!spectral) {
  1435. spectral_err_rl("Spectral LMAC object is null");
  1436. return;
  1437. }
  1438. if (!spectral->dbr_buff_debug)
  1439. return;
  1440. if (!report) {
  1441. spectral_err_rl("Spectral report is null");
  1442. return;
  1443. }
  1444. /* Add search FFT report */
  1445. if (spectral->params[smode].ss_rpt_mode > 0)
  1446. words_to_check +=
  1447. sizeof(struct spectral_phyerr_fft_report_gen3) >> 2;
  1448. /* Now add the number of FFT bins */
  1449. if (spectral->params[smode].ss_rpt_mode > 1) {
  1450. /* Caller should take care to pass correct number of FFT bins */
  1451. if (spectral->len_adj_swar.fftbin_size_war ==
  1452. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE)
  1453. words_to_check += num_fft_bins;
  1454. else if (spectral->len_adj_swar.fftbin_size_war ==
  1455. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE)
  1456. words_to_check += (num_fft_bins >> 1);
  1457. }
  1458. data = (uint32_t *)report->data;
  1459. for (len = 0; len < words_to_check; ++len) {
  1460. if (*data == MEM_POISON_SIGNATURE) {
  1461. spectral_err("Pattern(%x) found in Spectral search FFT report at position %zu in the buffer %pK",
  1462. MEM_POISON_SIGNATURE,
  1463. (len << 2), report->data);
  1464. poisoned_words_found = true;
  1465. break;
  1466. }
  1467. ++data;
  1468. }
  1469. /* Crash the FW even if one word is poisoned */
  1470. if (poisoned_words_found) {
  1471. spectral_err("Pattern(%x) found in Spectral report, Hex dump of the sfft follows",
  1472. MEM_POISON_SIGNATURE);
  1473. target_if_spectral_hexdump((unsigned char *)report->data,
  1474. words_to_check << 2);
  1475. spectral_err("Asserting the FW");
  1476. target_if_spectral_fw_hang(spectral);
  1477. }
  1478. }
  1479. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  1480. uint8_t *buf, uint32_t current_ts)
  1481. {
  1482. if (!spectral) {
  1483. spectral_err_rl("Spectral LMAC object is null");
  1484. return;
  1485. }
  1486. if (!spectral->dbr_buff_debug)
  1487. return;
  1488. if (spectral->prev_tstamp) {
  1489. if (current_ts == spectral->prev_tstamp) {
  1490. spectral_err("Spectral timestamp(%u) in the current buffer(%pK) is equal to the previous timestamp, same report DMAed twice? Asserting the FW",
  1491. current_ts, buf);
  1492. target_if_spectral_fw_hang(spectral);
  1493. }
  1494. }
  1495. spectral->prev_tstamp = current_ts;
  1496. }
  1497. #else
  1498. static void target_if_spectral_check_buffer_poisoning(
  1499. struct target_if_spectral *spectral,
  1500. struct spectral_report *report,
  1501. int num_fft_bins, enum spectral_scan_mode smode)
  1502. {
  1503. }
  1504. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  1505. uint8_t *buf, uint32_t current_ts)
  1506. {
  1507. }
  1508. #endif
  1509. /**
  1510. * target_if_spectral_get_adjusted_timestamp() - Adjust Spectral time
  1511. * stamp to account for reset in time stamp due to target reset
  1512. * @twar: Spectral time stamp WAR related information
  1513. * @raw_timestamp: Spectral time stamp reported by target
  1514. * @reset_delay: Reset delay at target
  1515. * @smode: Spectral scan mode
  1516. *
  1517. * Correct time stamp to account for reset in time stamp due to target reset
  1518. *
  1519. * Return: Adjusted time stamp
  1520. */
  1521. static uint32_t
  1522. target_if_spectral_get_adjusted_timestamp(struct spectral_timestamp_war *twar,
  1523. uint32_t raw_timestamp,
  1524. uint32_t reset_delay,
  1525. enum spectral_scan_mode smode) {
  1526. qdf_assert_always(smode < SPECTRAL_SCAN_MODE_MAX);
  1527. if (reset_delay) {
  1528. enum spectral_scan_mode m =
  1529. SPECTRAL_SCAN_MODE_NORMAL;
  1530. /* Adjust the offset for all the Spectral modes.
  1531. * Target will be sending the non zero reset delay for
  1532. * the first Spectral report after reset. This delay is
  1533. * common for all the Spectral modes.
  1534. */
  1535. for (; m < SPECTRAL_SCAN_MODE_MAX; m++)
  1536. twar->timestamp_war_offset[m] += (reset_delay +
  1537. twar->last_fft_timestamp[m]);
  1538. twar->target_reset_count++;
  1539. }
  1540. twar->last_fft_timestamp[smode] = raw_timestamp;
  1541. return raw_timestamp + twar->timestamp_war_offset[smode];
  1542. }
  1543. int
  1544. target_if_consume_spectral_report_gen3(
  1545. struct target_if_spectral *spectral,
  1546. struct spectral_report *report)
  1547. {
  1548. /*
  1549. * XXX : The classifier do not use all the members of the SAMP
  1550. * message data format.
  1551. * The classifier only depends upon the following parameters
  1552. *
  1553. * 1. Frequency (freq, msg->freq)
  1554. * 2. Spectral RSSI (spectral_rssi,
  1555. * msg->samp_data.spectral_rssi)
  1556. * 3. Bin Power Count (bin_pwr_count,
  1557. * msg->samp_data.bin_pwr_count)
  1558. * 4. Bin Power values (bin_pwr, msg->samp_data.bin_pwr[0]
  1559. * 5. Spectral Timestamp (spectral_tstamp,
  1560. * msg->samp_data.spectral_tstamp)
  1561. * 6. MAC Address (macaddr, msg->macaddr)
  1562. *
  1563. * This function prepares the params structure and populates it
  1564. * with
  1565. * relevant values, this is in turn passed to
  1566. * spectral_create_samp_msg()
  1567. * to prepare fully formatted Spectral SAMP message
  1568. *
  1569. * XXX : Need to verify
  1570. * 1. Order of FFT bin values
  1571. *
  1572. */
  1573. struct target_if_samp_msg_params params = {0};
  1574. struct spectral_search_fft_info_gen3 search_fft_info;
  1575. struct spectral_search_fft_info_gen3 *p_sfft = &search_fft_info;
  1576. int8_t chn_idx_lowest_enabled = 0;
  1577. int fft_hdr_length = 0;
  1578. int report_len = 0;
  1579. size_t fft_bin_count;
  1580. size_t fft_bin_size;
  1581. struct target_if_spectral_ops *p_sops =
  1582. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1583. struct spectral_phyerr_fft_report_gen3 *p_fft_report;
  1584. int8_t rssi;
  1585. uint8_t *data = report->data;
  1586. struct wlan_objmgr_vdev *vdev;
  1587. uint8_t vdev_rxchainmask;
  1588. struct sscan_report_fields_gen3 sscan_report_fields = {0};
  1589. enum spectral_detector_id detector_id;
  1590. QDF_STATUS ret;
  1591. enum spectral_scan_mode spectral_mode = SPECTRAL_SCAN_MODE_INVALID;
  1592. /* Process Spectral scan summary report */
  1593. if (target_if_verify_sig_and_tag_gen3(
  1594. spectral, data,
  1595. TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3) != 0) {
  1596. spectral_err_rl("Wrong tag/sig in sscan summary");
  1597. goto fail;
  1598. }
  1599. detector_id = target_if_get_detector_id_sscan_summary_report_gen3(data);
  1600. if (detector_id >= spectral->rparams.num_spectral_detectors) {
  1601. spectral->diag_stats.spectral_invalid_detector_id++;
  1602. spectral_err("Invalid detector id %u, expected is 0/1/2",
  1603. detector_id);
  1604. goto fail;
  1605. }
  1606. spectral_mode = target_if_get_spectral_mode(detector_id,
  1607. &spectral->rparams);
  1608. if (spectral_mode == SPECTRAL_SCAN_MODE_INVALID) {
  1609. spectral_err_rl("No valid Spectral mode for detector id %u",
  1610. detector_id);
  1611. goto fail;
  1612. }
  1613. target_if_consume_sscan_summary_report_gen3(data, &sscan_report_fields,
  1614. &spectral->rparams);
  1615. /* Advance buf pointer to the search fft report */
  1616. data += sizeof(struct spectral_sscan_summary_report_gen3);
  1617. data += spectral->rparams.ssumaary_padding_bytes;
  1618. if (is_primaryseg_expected(spectral, spectral_mode)) {
  1619. /* RSSI is in 1/2 dBm steps, Covert it to dBm scale */
  1620. rssi = (sscan_report_fields.inband_pwr_db) >> 1;
  1621. params.agc_total_gain =
  1622. sscan_report_fields.sscan_agc_total_gain;
  1623. params.gainchange = sscan_report_fields.sscan_gainchange;
  1624. params.pri80ind = sscan_report_fields.sscan_pri80;
  1625. /* Process Spectral search FFT report */
  1626. if (target_if_verify_sig_and_tag_gen3(
  1627. spectral, data,
  1628. TLV_TAG_SEARCH_FFT_REPORT_GEN3) != 0) {
  1629. spectral_err_rl("Unexpected tag/sig in sfft, detid= %u",
  1630. detector_id);
  1631. goto fail;
  1632. }
  1633. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  1634. fft_hdr_length = p_fft_report->fft_hdr_length * 4;
  1635. if (fft_hdr_length < 16) {
  1636. spectral_err("Wrong TLV length %u, detector id = %d",
  1637. fft_hdr_length, detector_id);
  1638. goto fail;
  1639. }
  1640. report_len = (fft_hdr_length + 8);
  1641. target_if_process_sfft_report_gen3(p_fft_report, p_sfft);
  1642. /* It is expected to have same detector id for
  1643. * summary and fft report
  1644. */
  1645. if (detector_id != p_sfft->fft_detector_id) {
  1646. spectral_err_rl
  1647. ("Different detid in ssummary(%u) and sfft(%u)",
  1648. detector_id, p_sfft->fft_detector_id);
  1649. goto fail;
  1650. }
  1651. if (detector_id > spectral->rparams.num_spectral_detectors) {
  1652. spectral->diag_stats.spectral_invalid_detector_id++;
  1653. spectral_err("Invalid detector id %u, expected is 0/2",
  1654. detector_id);
  1655. goto fail;
  1656. }
  1657. params.smode = spectral_mode;
  1658. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  1659. fft_hdr_length - spectral->rparams.fft_report_hdr_len,
  1660. spectral->params[spectral_mode].ss_rpt_mode,
  1661. &spectral->len_adj_swar, &fft_bin_size);
  1662. params.last_raw_timestamp = spectral->timestamp_war.
  1663. last_fft_timestamp[spectral_mode];
  1664. params.reset_delay = report->reset_delay;
  1665. params.raw_timestamp = p_sfft->timestamp;
  1666. params.tstamp = target_if_spectral_get_adjusted_timestamp(
  1667. &spectral->timestamp_war,
  1668. p_sfft->timestamp, report->reset_delay,
  1669. spectral_mode);
  1670. params.timestamp_war_offset = spectral->timestamp_war.
  1671. timestamp_war_offset[spectral_mode];
  1672. params.target_reset_count = spectral->timestamp_war.
  1673. target_reset_count;
  1674. /* Take care of state transitions for 160 MHz and 80p80 */
  1675. if (is_ch_width_160_or_80p80(spectral->ch_width
  1676. [spectral_mode]) && spectral->rparams.
  1677. fragmentation_160[spectral_mode]) {
  1678. ret = target_if_160mhz_delivery_state_change(
  1679. spectral, spectral_mode,
  1680. detector_id);
  1681. if (ret != QDF_STATUS_SUCCESS)
  1682. goto fail;
  1683. }
  1684. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  1685. target_if_dump_fft_report_gen3(spectral, spectral_mode,
  1686. p_fft_report, p_sfft);
  1687. params.rssi = rssi;
  1688. vdev = target_if_spectral_get_vdev(spectral);
  1689. if (!vdev) {
  1690. spectral_info("First vdev is NULL");
  1691. reset_160mhz_delivery_state_machine(
  1692. spectral, spectral_mode);
  1693. return -EPERM;
  1694. }
  1695. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  1696. QDF_ASSERT(vdev_rxchainmask != 0);
  1697. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1698. chn_idx_lowest_enabled =
  1699. target_if_spectral_get_lowest_chn_idx(vdev_rxchainmask);
  1700. if (chn_idx_lowest_enabled >= DBR_MAX_CHAINS) {
  1701. spectral_err("Invalid chain index, detector id = %u",
  1702. detector_id);
  1703. goto fail;
  1704. }
  1705. params.max_mag = p_sfft->fft_peak_mag;
  1706. params.freq = p_sops->get_current_channel(spectral);
  1707. if (spectral_mode == SPECTRAL_SCAN_MODE_AGILE)
  1708. params.agile_freq =
  1709. spectral->params[spectral_mode].ss_frequency;
  1710. /*
  1711. * For modes upto VHT80, the noise floor is populated with
  1712. * the one corresponding
  1713. * to the highest enabled antenna chain
  1714. */
  1715. /* TODO: Fill proper values once FW provides them*/
  1716. params.noise_floor =
  1717. report->noisefloor[chn_idx_lowest_enabled];
  1718. params.datalen = (fft_hdr_length * 4);
  1719. params.bin_pwr_data = (uint8_t *)((uint8_t *)p_fft_report +
  1720. SPECTRAL_FFT_BINS_POS);
  1721. params.pwr_count = fft_bin_count;
  1722. if (is_ch_width_160_or_80p80(spectral->ch_width
  1723. [spectral_mode]) && !spectral->rparams.
  1724. fragmentation_160[spectral_mode]) {
  1725. params.agc_total_gain_sec80 =
  1726. sscan_report_fields.sscan_agc_total_gain;
  1727. params.gainchange_sec80 =
  1728. sscan_report_fields.sscan_gainchange;
  1729. params.raw_timestamp_sec80 = p_sfft->timestamp;
  1730. params.rssi_sec80 = rssi;
  1731. params.noise_floor_sec80 =
  1732. report->noisefloor[chn_idx_lowest_enabled];
  1733. params.max_mag_sec80 = p_sfft->fft_peak_mag;
  1734. params.datalen_sec80 = fft_hdr_length * 4;
  1735. params.pwr_count = fft_bin_count / 2;
  1736. params.pwr_count_sec80 = fft_bin_count / 2;
  1737. params.bin_pwr_data_sec80 =
  1738. (uint8_t *)((uint8_t *)p_fft_report +
  1739. SPECTRAL_FFT_BINS_POS + (fft_bin_count / 2) *
  1740. fft_bin_size);
  1741. }
  1742. target_if_spectral_verify_ts(spectral, report->data,
  1743. params.tstamp);
  1744. } else if (is_secondaryseg_expected(spectral, spectral_mode)) {
  1745. /* RSSI is in 1/2 dBm steps, Covert it to dBm scale */
  1746. rssi = (sscan_report_fields.inband_pwr_db) >> 1;
  1747. params.agc_total_gain_sec80 =
  1748. sscan_report_fields.sscan_agc_total_gain;
  1749. params.gainchange_sec80 = sscan_report_fields.sscan_gainchange;
  1750. params.pri80ind_sec80 = sscan_report_fields.sscan_pri80;
  1751. /* Process Spectral search FFT report */
  1752. if (target_if_verify_sig_and_tag_gen3(
  1753. spectral, data,
  1754. TLV_TAG_SEARCH_FFT_REPORT_GEN3) != 0) {
  1755. spectral_err_rl("Unexpected tag/sig in sfft, detid= %u",
  1756. detector_id);
  1757. goto fail;
  1758. }
  1759. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  1760. fft_hdr_length = p_fft_report->fft_hdr_length * 4;
  1761. if (fft_hdr_length < 16) {
  1762. spectral_err("Wrong TLV length %u, detector id = %u",
  1763. fft_hdr_length, detector_id);
  1764. goto fail;
  1765. }
  1766. report_len = (fft_hdr_length + 8);
  1767. target_if_process_sfft_report_gen3(p_fft_report, p_sfft);
  1768. /* It is expected to have same detector id for
  1769. * summary and fft report
  1770. */
  1771. if (detector_id != p_sfft->fft_detector_id) {
  1772. spectral_err_rl
  1773. ("Different detid in ssummary(%u) and sfft(%u)",
  1774. detector_id, p_sfft->fft_detector_id);
  1775. goto fail;
  1776. }
  1777. if (detector_id > spectral->rparams.num_spectral_detectors) {
  1778. spectral->diag_stats.spectral_invalid_detector_id++;
  1779. spectral_err("Invalid detector id %u, expected is 1",
  1780. detector_id);
  1781. goto fail;
  1782. }
  1783. params.smode = spectral_mode;
  1784. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  1785. fft_hdr_length - spectral->rparams.fft_report_hdr_len,
  1786. spectral->params[spectral_mode].ss_rpt_mode,
  1787. &spectral->len_adj_swar, &fft_bin_size);
  1788. params.raw_timestamp_sec80 = p_sfft->timestamp;
  1789. /* Take care of state transitions for 160 MHz and 80p80 */
  1790. if (is_ch_width_160_or_80p80(spectral->ch_width
  1791. [spectral_mode]) && spectral->rparams.
  1792. fragmentation_160[spectral_mode]) {
  1793. ret = target_if_160mhz_delivery_state_change(
  1794. spectral, spectral_mode,
  1795. detector_id);
  1796. if (ret != QDF_STATUS_SUCCESS)
  1797. goto fail;
  1798. }
  1799. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  1800. target_if_dump_fft_report_gen3(spectral, spectral_mode,
  1801. p_fft_report, p_sfft);
  1802. params.vhtop_ch_freq_seg1 = 0;
  1803. params.vhtop_ch_freq_seg2 = 0;
  1804. params.rssi_sec80 = rssi;
  1805. vdev = target_if_spectral_get_vdev(spectral);
  1806. if (!vdev) {
  1807. spectral_info("First vdev is NULL");
  1808. reset_160mhz_delivery_state_machine
  1809. (spectral, spectral_mode);
  1810. return -EPERM;
  1811. }
  1812. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  1813. QDF_ASSERT(vdev_rxchainmask != 0);
  1814. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1815. chn_idx_lowest_enabled =
  1816. target_if_spectral_get_lowest_chn_idx(vdev_rxchainmask);
  1817. if (chn_idx_lowest_enabled >= DBR_MAX_CHAINS) {
  1818. spectral_err("Invalid chain index");
  1819. goto fail;
  1820. }
  1821. /* Need to change this as per FW team's inputs */
  1822. params.noise_floor_sec80 =
  1823. report->noisefloor[chn_idx_lowest_enabled];
  1824. params.max_mag_sec80 = p_sfft->fft_peak_mag;
  1825. /* params.max_index_sec80 = p_sfft->peak_inx; */
  1826. /* XXX Does this definition of datalen *still hold? */
  1827. params.datalen_sec80 = fft_hdr_length * 4;
  1828. params.pwr_count_sec80 = fft_bin_count;
  1829. params.bin_pwr_data_sec80 =
  1830. (uint8_t *)((uint8_t *)p_fft_report +
  1831. SPECTRAL_FFT_BINS_POS);
  1832. } else {
  1833. spectral_err("Spectral state machine in undefined state");
  1834. goto fail;
  1835. }
  1836. target_if_spectral_check_buffer_poisoning(spectral, report,
  1837. fft_bin_count, spectral_mode);
  1838. qdf_mem_copy(&params.classifier_params,
  1839. &spectral->classifier_params,
  1840. sizeof(struct spectral_classifier_params));
  1841. target_if_spectral_log_SAMP_param(&params);
  1842. target_if_spectral_create_samp_msg(spectral, &params);
  1843. return 0;
  1844. fail:
  1845. spectral_err_rl("Error while processing Spectral report");
  1846. if (spectral_mode != SPECTRAL_SCAN_MODE_INVALID)
  1847. reset_160mhz_delivery_state_machine(spectral, spectral_mode);
  1848. return -EPERM;
  1849. }
  1850. int target_if_spectral_process_report_gen3(
  1851. struct wlan_objmgr_pdev *pdev,
  1852. void *buf)
  1853. {
  1854. int ret = 0;
  1855. struct direct_buf_rx_data *payload = buf;
  1856. struct target_if_spectral *spectral;
  1857. struct spectral_report report;
  1858. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  1859. if (!spectral) {
  1860. spectral_err("Spectral target object is null");
  1861. return -EINVAL;
  1862. }
  1863. report.data = payload->vaddr;
  1864. if (payload->meta_data_valid) {
  1865. qdf_mem_copy(report.noisefloor, payload->meta_data.noisefloor,
  1866. qdf_min(sizeof(report.noisefloor),
  1867. sizeof(payload->meta_data.noisefloor)));
  1868. report.reset_delay = payload->meta_data.reset_delay;
  1869. }
  1870. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4)) {
  1871. spectral_debug("Printing the spectral phyerr buffer for debug");
  1872. spectral_debug("Datalength of buffer = 0x%zx(%zd) bufptr = 0x%pK",
  1873. payload->dbr_len,
  1874. payload->dbr_len,
  1875. payload->vaddr);
  1876. target_if_spectral_hexdump((unsigned char *)payload->vaddr,
  1877. 1024);
  1878. }
  1879. ret = target_if_consume_spectral_report_gen3(spectral, &report);
  1880. if (spectral_debug_level & DEBUG_SPECTRAL4)
  1881. spectral_debug_level = DEBUG_SPECTRAL;
  1882. return ret;
  1883. }
  1884. #else
  1885. int target_if_spectral_process_report_gen3(
  1886. struct wlan_objmgr_pdev *pdev,
  1887. void *buf)
  1888. {
  1889. spectral_err("Direct dma support is not enabled");
  1890. return -EINVAL;
  1891. }
  1892. #endif
  1893. qdf_export_symbol(target_if_spectral_process_report_gen3);
  1894. /* END of spectral GEN III HW specific functions */
  1895. #endif /* WLAN_CONV_SPECTRAL_ENABLE */