target_if_spectral_phyerr.c 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177
  1. /*
  2. * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  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. if (_len <= 0) {
  72. spectral_err("buffer len is %d, too short", _len);
  73. return;
  74. }
  75. for (i = 0; i < _len; i++) {
  76. mod = i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE;
  77. if (!mod) {
  78. if (i) {
  79. qdf_assert_always(loc < sizeof(hexdump_line));
  80. loc += snprintf(&hexdump_line[loc],
  81. sizeof(hexdump_line) - loc,
  82. " %s", ascii);
  83. spectral_debug("%s", hexdump_line);
  84. qdf_mem_zero(hexdump_line,
  85. sizeof(hexdump_line));
  86. loc = 0;
  87. }
  88. }
  89. qdf_assert_always(loc < sizeof(hexdump_line));
  90. loc += snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc,
  91. " %02x", pc[i]);
  92. if ((pc[i] < 0x20) || (pc[i] > 0x7e))
  93. ascii[mod] = '.';
  94. else
  95. ascii[mod] = pc[i];
  96. ascii[(mod) + 1] = '\0';
  97. }
  98. while ((i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE) != 0) {
  99. qdf_assert_always(loc < sizeof(hexdump_line));
  100. loc += snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc,
  101. " ");
  102. i++;
  103. }
  104. qdf_assert_always(loc < sizeof(hexdump_line));
  105. snprintf(&hexdump_line[loc], sizeof(hexdump_line) - loc, " %s", ascii);
  106. spectral_debug("%s", hexdump_line);
  107. }
  108. /**
  109. * target_if_print_buf() - Prints given buffer for given length
  110. * @pbuf: Pointer to buffer
  111. * @len: length
  112. *
  113. * Prints given buffer for given length
  114. *
  115. * Return: void
  116. */
  117. static void
  118. target_if_print_buf(uint8_t *pbuf, int len)
  119. {
  120. int i = 0;
  121. for (i = 0; i < len; i++) {
  122. spectral_debug("%02X ", pbuf[i]);
  123. if (i % 32 == 31)
  124. spectral_debug("\n");
  125. }
  126. }
  127. int
  128. target_if_spectral_dump_fft(uint8_t *pfft, int fftlen)
  129. {
  130. int i = 0;
  131. /*
  132. * TODO : Do not delete the following print
  133. * The scripts used to validate Spectral depend on this Print
  134. */
  135. spectral_debug("SPECTRAL : FFT Length is 0x%x (%d)", fftlen, fftlen);
  136. spectral_debug("fft_data # ");
  137. for (i = 0; i < fftlen; i++)
  138. spectral_debug("%d ", pfft[i]);
  139. spectral_debug("\n");
  140. return 0;
  141. }
  142. QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral)
  143. {
  144. struct crash_inject param;
  145. struct wlan_objmgr_pdev *pdev;
  146. struct wlan_objmgr_psoc *psoc;
  147. struct target_if_psoc_spectral *psoc_spectral;
  148. if (!spectral) {
  149. spectral_err("Spectral LMAC object is null");
  150. return QDF_STATUS_E_INVAL;
  151. }
  152. pdev = spectral->pdev_obj;
  153. if (!pdev) {
  154. spectral_err("pdev is null");
  155. return QDF_STATUS_E_FAILURE;
  156. }
  157. psoc = wlan_pdev_get_psoc(pdev);
  158. if (!psoc) {
  159. spectral_err("psoc is null");
  160. return QDF_STATUS_E_FAILURE;
  161. }
  162. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  163. if (!psoc_spectral) {
  164. spectral_err("spectral psoc object is null");
  165. return QDF_STATUS_E_FAILURE;
  166. }
  167. qdf_mem_set(&param, sizeof(param), 0);
  168. param.type = 1; //RECOVERY_SIM_ASSERT
  169. return psoc_spectral->wmi_ops.wmi_spectral_crash_inject(
  170. GET_WMI_HDL_FROM_PDEV(spectral->pdev_obj), &param);
  171. }
  172. #ifdef OPTIMIZED_SAMP_MESSAGE
  173. void
  174. target_if_dbg_print_samp_msg(struct spectral_samp_msg *ss_msg)
  175. {
  176. int span, det;
  177. struct samp_detector_info *det_info;
  178. struct samp_freq_span_info *span_info;
  179. spectral_dbg_line();
  180. spectral_debug("Spectral Message");
  181. spectral_dbg_line();
  182. spectral_debug("Signature : 0x%x", ss_msg->signature);
  183. spectral_debug("Freq : %u", ss_msg->pri20_freq);
  184. spectral_debug("sscan width : %d", ss_msg->sscan_bw);
  185. spectral_debug("sscan cfreq1 : %u", ss_msg->sscan_cfreq1);
  186. spectral_debug("sscan cfreq2 : %u", ss_msg->sscan_cfreq2);
  187. spectral_debug("bin power count : %d", ss_msg->bin_pwr_count);
  188. spectral_debug("Number of spans : %d", ss_msg->num_freq_spans);
  189. spectral_dbg_line();
  190. for (span = 0; span < ss_msg->num_freq_spans; span++) {
  191. span_info = &ss_msg->freq_span_info[span];
  192. spectral_debug("-------- Span ID : %d --------", span);
  193. spectral_debug("Number of detectors : %d",
  194. span_info->num_detectors);
  195. spectral_dbg_line();
  196. for (det = 0; det < span_info->num_detectors; det++) {
  197. det_info = &span_info->detector_info[det];
  198. spectral_debug("------ Detector ID : %d ------", det);
  199. spectral_dbg_line();
  200. spectral_debug("RSSI : %d", det_info->rssi);
  201. spectral_debug("Timestamp : %u",
  202. det_info->timestamp);
  203. spectral_debug("Start bin index : %d",
  204. det_info->start_bin_idx);
  205. spectral_debug("End bin index : %d",
  206. det_info->end_bin_idx);
  207. spectral_debug("Start frequency : %d",
  208. det_info->start_frequency);
  209. spectral_debug("End frequency : %d",
  210. det_info->end_frequency);
  211. spectral_dbg_line();
  212. }
  213. }
  214. }
  215. #else
  216. void
  217. target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p)
  218. {
  219. spectral_debug("\nSAMP Packet : -------------------- START --------------------");
  220. spectral_debug("Freq = %d", p->freq);
  221. spectral_debug("RSSI = %d", p->rssi);
  222. spectral_debug("Bin Count = %d", p->pwr_count);
  223. spectral_debug("Timestamp = %d", p->tstamp);
  224. spectral_debug("SAMP Packet : -------------------- END -----------------------");
  225. }
  226. void
  227. target_if_dbg_print_samp_msg(struct spectral_samp_msg *ss_msg)
  228. {
  229. int i = 0;
  230. struct spectral_samp_data *p = &ss_msg->samp_data;
  231. struct spectral_classifier_params *pc = &p->classifier_params;
  232. struct interf_src_rsp *pi = &p->interf_list;
  233. spectral_dbg_line();
  234. spectral_debug("Spectral Message");
  235. spectral_dbg_line();
  236. spectral_debug("Signature : 0x%x", ss_msg->signature);
  237. spectral_debug("Freq : %d", ss_msg->freq);
  238. spectral_debug("Freq load : %d", ss_msg->freq_loading);
  239. spectral_debug("Intfnc type : %d", ss_msg->int_type);
  240. spectral_dbg_line();
  241. spectral_debug("Spectral Data info");
  242. spectral_dbg_line();
  243. spectral_debug("data length : %d", p->spectral_data_len);
  244. spectral_debug("rssi : %d", p->spectral_rssi);
  245. spectral_debug("combined rssi : %d", p->spectral_combined_rssi);
  246. spectral_debug("upper rssi : %d", p->spectral_upper_rssi);
  247. spectral_debug("lower rssi : %d", p->spectral_lower_rssi);
  248. spectral_debug("bw info : %d", p->spectral_bwinfo);
  249. spectral_debug("timestamp : %d", p->spectral_tstamp);
  250. spectral_debug("max index : %d", p->spectral_max_index);
  251. spectral_debug("max exp : %d", p->spectral_max_exp);
  252. spectral_debug("max mag : %d", p->spectral_max_mag);
  253. spectral_debug("last timstamp : %d", p->spectral_last_tstamp);
  254. spectral_debug("upper max idx : %d", p->spectral_upper_max_index);
  255. spectral_debug("lower max idx : %d", p->spectral_lower_max_index);
  256. spectral_debug("bin power count : %d", p->bin_pwr_count);
  257. spectral_dbg_line();
  258. spectral_debug("Classifier info");
  259. spectral_dbg_line();
  260. spectral_debug("20/40 Mode : %d", pc->spectral_20_40_mode);
  261. spectral_debug("dc index : %d", pc->spectral_dc_index);
  262. spectral_debug("dc in MHz : %d", pc->spectral_dc_in_mhz);
  263. spectral_debug("upper channel : %d", pc->upper_chan_in_mhz);
  264. spectral_debug("lower channel : %d", pc->lower_chan_in_mhz);
  265. spectral_dbg_line();
  266. spectral_debug("Interference info");
  267. spectral_dbg_line();
  268. spectral_debug("inter count : %d", pi->count);
  269. for (i = 0; i < pi->count; i++) {
  270. spectral_debug("inter type : %d",
  271. pi->interf[i].interf_type);
  272. spectral_debug("min freq : %d",
  273. pi->interf[i].interf_min_freq);
  274. spectral_debug("max freq : %d",
  275. pi->interf[i].interf_max_freq);
  276. }
  277. }
  278. #endif /* OPTIMIZED_SAMP_MESSAGE */
  279. uint32_t
  280. target_if_get_offset_swar_sec80(uint32_t channel_width)
  281. {
  282. uint32_t offset = 0;
  283. switch (channel_width) {
  284. case CH_WIDTH_20MHZ:
  285. offset = OFFSET_CH_WIDTH_20;
  286. break;
  287. case CH_WIDTH_40MHZ:
  288. offset = OFFSET_CH_WIDTH_40;
  289. break;
  290. case CH_WIDTH_80MHZ:
  291. offset = OFFSET_CH_WIDTH_80;
  292. break;
  293. case CH_WIDTH_160MHZ:
  294. case CH_WIDTH_80P80MHZ:
  295. offset = OFFSET_CH_WIDTH_160;
  296. break;
  297. default:
  298. offset = OFFSET_CH_WIDTH_80;
  299. break;
  300. }
  301. return offset;
  302. }
  303. /**
  304. * target_if_dump_summary_report_gen2() - Dump Spectral Summary Report for gen2
  305. * @ptlv: Pointer to Spectral Phyerr TLV
  306. * @tlvlen: length
  307. * @is_160_format: Indicates whether information provided by HW is in altered
  308. * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards)
  309. *
  310. * Dump Spectral Summary Report for gen2
  311. *
  312. * Return: Success/Failure
  313. */
  314. static int
  315. target_if_dump_summary_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv,
  316. int tlvlen, bool is_160_format)
  317. {
  318. /*
  319. * For simplicity, everything is defined as uint32_t (except one).
  320. * Proper code will later use the right sizes.
  321. */
  322. /*
  323. * For easy comparison between MDK team and OS team, the MDK script
  324. * variable names have been used
  325. */
  326. uint32_t agc_mb_gain;
  327. uint32_t sscan_gidx;
  328. uint32_t agc_total_gain;
  329. uint32_t recent_rfsat;
  330. uint32_t ob_flag;
  331. uint32_t nb_mask;
  332. uint32_t peak_mag;
  333. int16_t peak_inx;
  334. uint32_t ss_summary_A = 0;
  335. uint32_t ss_summary_B = 0;
  336. uint32_t ss_summary_C = 0;
  337. uint32_t ss_summary_D = 0;
  338. uint32_t ss_summary_E = 0;
  339. struct spectral_phyerr_hdr_gen2 *phdr =
  340. (struct spectral_phyerr_hdr_gen2 *)(
  341. (uint8_t *)ptlv +
  342. sizeof(struct spectral_phyerr_tlv_gen2));
  343. spectral_debug("SPECTRAL : SPECTRAL SUMMARY REPORT");
  344. if (is_160_format) {
  345. if (tlvlen != 20) {
  346. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  347. tlvlen);
  348. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  349. return -EPERM;
  350. }
  351. /* Doing copy as the contents may not be aligned */
  352. qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int));
  353. qdf_mem_copy(&ss_summary_B,
  354. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  355. sizeof(int));
  356. qdf_mem_copy(&ss_summary_C,
  357. (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)),
  358. sizeof(int));
  359. qdf_mem_copy(&ss_summary_D,
  360. (uint8_t *)((uint8_t *)phdr + 3 * sizeof(int)),
  361. sizeof(int));
  362. qdf_mem_copy(&ss_summary_E,
  363. (uint8_t *)((uint8_t *)phdr + 4 * sizeof(int)),
  364. sizeof(int));
  365. /*
  366. * The following is adapted from MDK scripts for
  367. * easier comparability
  368. */
  369. recent_rfsat = ((ss_summary_A >> 8) & 0x1);
  370. sscan_gidx = (ss_summary_A & 0xff);
  371. spectral_debug("sscan_gidx=%d, is_recent_rfsat=%d",
  372. sscan_gidx, recent_rfsat);
  373. /* First segment */
  374. agc_mb_gain = ((ss_summary_B >> 10) & 0x7f);
  375. agc_total_gain = (ss_summary_B & 0x3ff);
  376. nb_mask = ((ss_summary_C >> 22) & 0xff);
  377. ob_flag = ((ss_summary_B >> 17) & 0x1);
  378. peak_inx = (ss_summary_C & 0xfff);
  379. if (peak_inx > 2047)
  380. peak_inx = peak_inx - 4096;
  381. peak_mag = ((ss_summary_C >> 12) & 0x3ff);
  382. spectral_debug("agc_total_gain_segid0 = 0x%.2x, agc_mb_gain_segid0=%d",
  383. agc_total_gain, agc_mb_gain);
  384. spectral_debug("nb_mask_segid0 = 0x%.2x, ob_flag_segid0=%d, peak_index_segid0=%d, peak_mag_segid0=%d",
  385. nb_mask, ob_flag, peak_inx, peak_mag);
  386. /* Second segment */
  387. agc_mb_gain = ((ss_summary_D >> 10) & 0x7f);
  388. agc_total_gain = (ss_summary_D & 0x3ff);
  389. nb_mask = ((ss_summary_E >> 22) & 0xff);
  390. ob_flag = ((ss_summary_D >> 17) & 0x1);
  391. peak_inx = (ss_summary_E & 0xfff);
  392. if (peak_inx > 2047)
  393. peak_inx = peak_inx - 4096;
  394. peak_mag = ((ss_summary_E >> 12) & 0x3ff);
  395. spectral_debug("agc_total_gain_segid1 = 0x%.2x, agc_mb_gain_segid1=%d",
  396. agc_total_gain, agc_mb_gain);
  397. spectral_debug("nb_mask_segid1 = 0x%.2x, ob_flag_segid1=%d, peak_index_segid1=%d, peak_mag_segid1=%d",
  398. nb_mask, ob_flag, peak_inx, peak_mag);
  399. } else {
  400. if (tlvlen != 8) {
  401. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  402. tlvlen);
  403. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  404. return -EPERM;
  405. }
  406. /* Doing copy as the contents may not be aligned */
  407. qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int));
  408. qdf_mem_copy(&ss_summary_B,
  409. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  410. sizeof(int));
  411. nb_mask = ((ss_summary_B >> 22) & 0xff);
  412. ob_flag = ((ss_summary_B >> 30) & 0x1);
  413. peak_inx = (ss_summary_B & 0xfff);
  414. if (peak_inx > 2047)
  415. peak_inx = peak_inx - 4096;
  416. peak_mag = ((ss_summary_B >> 12) & 0x3ff);
  417. agc_mb_gain = ((ss_summary_A >> 24) & 0x7f);
  418. agc_total_gain = (ss_summary_A & 0x3ff);
  419. sscan_gidx = ((ss_summary_A >> 16) & 0xff);
  420. recent_rfsat = ((ss_summary_B >> 31) & 0x1);
  421. 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",
  422. nb_mask, ob_flag, peak_inx, peak_mag,
  423. agc_mb_gain, agc_total_gain, sscan_gidx,
  424. recent_rfsat);
  425. }
  426. return 0;
  427. }
  428. /**
  429. * target_if_process_sfft_report_gen2() - Process Search FFT Report
  430. * @ptlv: Pointer to Spectral Phyerr TLV
  431. * @tlvlen: length
  432. * @p_fft_info: Pointer to search fft info
  433. *
  434. * Dump Spectral Summary Report for gen2
  435. *
  436. * Return: Success/Failure
  437. */
  438. static int
  439. target_if_process_sfft_report_gen2(
  440. struct spectral_phyerr_tlv_gen2 *ptlv,
  441. int tlvlen,
  442. struct spectral_search_fft_info_gen2 *p_fft_info)
  443. {
  444. /*
  445. * For simplicity, everything is defined as uint32_t (except one).
  446. * Proper code will later use the right sizes.
  447. */
  448. /*
  449. * For easy comparison between MDK team and OS team, the MDK script
  450. * variable names have been used
  451. */
  452. uint32_t relpwr_db;
  453. uint32_t num_str_bins_ib;
  454. uint32_t base_pwr;
  455. uint32_t total_gain_info;
  456. uint32_t fft_chn_idx;
  457. int16_t peak_inx;
  458. uint32_t avgpwr_db;
  459. uint32_t peak_mag;
  460. uint32_t fft_summary_A = 0;
  461. uint32_t fft_summary_B = 0;
  462. uint8_t *tmp = (uint8_t *)ptlv;
  463. struct spectral_phyerr_hdr_gen2 *phdr =
  464. (struct spectral_phyerr_hdr_gen2 *)(
  465. tmp +
  466. sizeof(struct spectral_phyerr_tlv_gen2));
  467. /* Relook this */
  468. if (tlvlen < 8) {
  469. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  470. tlvlen);
  471. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  472. return -EPERM;
  473. }
  474. /* Doing copy as the contents may not be aligned */
  475. qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int));
  476. qdf_mem_copy(&fft_summary_B,
  477. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  478. sizeof(int));
  479. relpwr_db = ((fft_summary_B >> 26) & 0x3f);
  480. num_str_bins_ib = fft_summary_B & 0xff;
  481. base_pwr = ((fft_summary_A >> 14) & 0x1ff);
  482. total_gain_info = ((fft_summary_A >> 23) & 0x1ff);
  483. fft_chn_idx = ((fft_summary_A >> 12) & 0x3);
  484. peak_inx = fft_summary_A & 0xfff;
  485. if (peak_inx > 2047)
  486. peak_inx = peak_inx - 4096;
  487. avgpwr_db = ((fft_summary_B >> 18) & 0xff);
  488. peak_mag = ((fft_summary_B >> 8) & 0x3ff);
  489. /* Populate the Search FFT Info */
  490. if (p_fft_info) {
  491. p_fft_info->relpwr_db = relpwr_db;
  492. p_fft_info->num_str_bins_ib = num_str_bins_ib;
  493. p_fft_info->base_pwr = base_pwr;
  494. p_fft_info->total_gain_info = total_gain_info;
  495. p_fft_info->fft_chn_idx = fft_chn_idx;
  496. p_fft_info->peak_inx = peak_inx;
  497. p_fft_info->avgpwr_db = avgpwr_db;
  498. p_fft_info->peak_mag = peak_mag;
  499. }
  500. return 0;
  501. }
  502. /**
  503. * target_if_dump_adc_report_gen2() - Dump ADC Reports for gen2
  504. * @ptlv: Pointer to Spectral Phyerr TLV
  505. * @tlvlen: length
  506. *
  507. * Dump ADC Reports for gen2
  508. *
  509. * Return: Success/Failure
  510. */
  511. static int
  512. target_if_dump_adc_report_gen2(
  513. struct spectral_phyerr_tlv_gen2 *ptlv, int tlvlen)
  514. {
  515. int i;
  516. uint32_t *pdata;
  517. uint32_t data;
  518. /*
  519. * For simplicity, everything is defined as uint32_t (except one).
  520. * Proper code will later use the right sizes.
  521. */
  522. uint32_t samp_fmt;
  523. uint32_t chn_idx;
  524. uint32_t recent_rfsat;
  525. uint32_t agc_mb_gain;
  526. uint32_t agc_total_gain;
  527. uint32_t adc_summary = 0;
  528. uint8_t *ptmp = (uint8_t *)ptlv;
  529. spectral_debug("SPECTRAL : ADC REPORT");
  530. /* Relook this */
  531. if (tlvlen < 4) {
  532. spectral_err("Unexpected TLV length %d for ADC Report! Hexdump follows",
  533. tlvlen);
  534. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  535. return -EPERM;
  536. }
  537. qdf_mem_copy(&adc_summary, (uint8_t *)(ptlv + 4), sizeof(int));
  538. samp_fmt = ((adc_summary >> 28) & 0x1);
  539. chn_idx = ((adc_summary >> 24) & 0x3);
  540. recent_rfsat = ((adc_summary >> 23) & 0x1);
  541. agc_mb_gain = ((adc_summary >> 16) & 0x7f);
  542. agc_total_gain = adc_summary & 0x3ff;
  543. spectral_debug("samp_fmt= %u, chn_idx= %u, recent_rfsat= %u, agc_mb_gain=%u agc_total_gain=%u",
  544. samp_fmt, chn_idx, recent_rfsat, agc_mb_gain,
  545. agc_total_gain);
  546. for (i = 0; i < (tlvlen / 4); i++) {
  547. pdata = (uint32_t *)(ptmp + 4 + i * 4);
  548. data = *pdata;
  549. /* Interpreting capture format 1 */
  550. if (1) {
  551. uint8_t i1;
  552. uint8_t q1;
  553. uint8_t i2;
  554. uint8_t q2;
  555. int8_t si1;
  556. int8_t sq1;
  557. int8_t si2;
  558. int8_t sq2;
  559. i1 = data & 0xff;
  560. q1 = (data >> 8) & 0xff;
  561. i2 = (data >> 16) & 0xff;
  562. q2 = (data >> 24) & 0xff;
  563. if (i1 > 127)
  564. si1 = i1 - 256;
  565. else
  566. si1 = i1;
  567. if (q1 > 127)
  568. sq1 = q1 - 256;
  569. else
  570. sq1 = q1;
  571. if (i2 > 127)
  572. si2 = i2 - 256;
  573. else
  574. si2 = i2;
  575. if (q2 > 127)
  576. sq2 = q2 - 256;
  577. else
  578. sq2 = q2;
  579. spectral_debug("SPECTRAL ADC : Interpreting capture format 1");
  580. spectral_debug("adc_data_format_1 # %d %d %d",
  581. 2 * i, si1, sq1);
  582. spectral_debug("adc_data_format_1 # %d %d %d",
  583. 2 * i + 1, si2, sq2);
  584. }
  585. /* Interpreting capture format 0 */
  586. if (1) {
  587. uint16_t i1;
  588. uint16_t q1;
  589. int16_t si1;
  590. int16_t sq1;
  591. i1 = data & 0xffff;
  592. q1 = (data >> 16) & 0xffff;
  593. if (i1 > 32767)
  594. si1 = i1 - 65536;
  595. else
  596. si1 = i1;
  597. if (q1 > 32767)
  598. sq1 = q1 - 65536;
  599. else
  600. sq1 = q1;
  601. spectral_debug("SPECTRAL ADC : Interpreting capture format 0");
  602. spectral_debug("adc_data_format_2 # %d %d %d",
  603. i, si1, sq1);
  604. }
  605. }
  606. spectral_debug("\n");
  607. return 0;
  608. }
  609. /**
  610. * target_if_dump_sfft_report_gen2() - Process Search FFT Report for gen2
  611. * @ptlv: Pointer to Spectral Phyerr TLV
  612. * @tlvlen: length
  613. * @is_160_format: Indicates 160 format
  614. *
  615. * Process Search FFT Report for gen2
  616. *
  617. * Return: Success/Failure
  618. */
  619. static int
  620. target_if_dump_sfft_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv,
  621. int tlvlen, bool is_160_format)
  622. {
  623. int i;
  624. uint32_t fft_mag;
  625. /*
  626. * For simplicity, everything is defined as uint32_t (except one).
  627. * Proper code will later use the right sizes.
  628. */
  629. /*
  630. * For easy comparison between MDK team and OS team, the MDK script
  631. * variable names have been used
  632. */
  633. uint32_t relpwr_db;
  634. uint32_t num_str_bins_ib;
  635. uint32_t base_pwr;
  636. uint32_t total_gain_info;
  637. uint32_t fft_chn_idx;
  638. int16_t peak_inx;
  639. uint32_t avgpwr_db;
  640. uint32_t peak_mag;
  641. uint8_t segid;
  642. uint32_t fft_summary_A = 0;
  643. uint32_t fft_summary_B = 0;
  644. uint32_t fft_summary_C = 0;
  645. uint8_t *tmp = (uint8_t *)ptlv;
  646. struct spectral_phyerr_hdr_gen2 *phdr =
  647. (struct spectral_phyerr_hdr_gen2 *)(
  648. tmp +
  649. sizeof(struct spectral_phyerr_tlv_gen2));
  650. uint32_t segid_skiplen = 0;
  651. if (is_160_format)
  652. segid_skiplen = sizeof(SPECTRAL_SEGID_INFO);
  653. spectral_debug("SPECTRAL : SEARCH FFT REPORT");
  654. /* Relook this */
  655. if (tlvlen < (8 + segid_skiplen)) {
  656. spectral_err("Unexpected TLV length %d for Spectral Summary Report! Hexdump follows",
  657. tlvlen);
  658. target_if_print_buf((uint8_t *)ptlv, tlvlen + 4);
  659. return -EPERM;
  660. }
  661. /* Doing copy as the contents may not be aligned */
  662. qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int));
  663. qdf_mem_copy(&fft_summary_B,
  664. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  665. sizeof(int));
  666. if (is_160_format)
  667. qdf_mem_copy(&fft_summary_C,
  668. (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)),
  669. sizeof(int));
  670. relpwr_db = ((fft_summary_B >> 26) & 0x3f);
  671. num_str_bins_ib = fft_summary_B & 0xff;
  672. base_pwr = ((fft_summary_A >> 14) & 0x1ff);
  673. total_gain_info = ((fft_summary_A >> 23) & 0x1ff);
  674. fft_chn_idx = ((fft_summary_A >> 12) & 0x3);
  675. peak_inx = fft_summary_A & 0xfff;
  676. if (peak_inx > 2047)
  677. peak_inx = peak_inx - 4096;
  678. avgpwr_db = ((fft_summary_B >> 18) & 0xff);
  679. peak_mag = ((fft_summary_B >> 8) & 0x3ff);
  680. spectral_debug("Header A = 0x%x Header B = 0x%x",
  681. phdr->hdr_a, phdr->hdr_b);
  682. 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",
  683. base_pwr, total_gain_info, relpwr_db, num_str_bins_ib,
  684. fft_chn_idx, peak_inx, avgpwr_db, peak_mag);
  685. if (is_160_format) {
  686. segid = fft_summary_C & 0x1;
  687. spectral_debug("Segment ID: %hhu", segid);
  688. }
  689. spectral_debug("FFT bins:");
  690. for (i = 0; i < (tlvlen - 8 - segid_skiplen); i++) {
  691. fft_mag = ((uint8_t *)ptlv)[12 + segid_skiplen + i];
  692. spectral_debug("%d %d, ", i, fft_mag);
  693. }
  694. spectral_debug("\n");
  695. return 0;
  696. }
  697. #ifndef OPTIMIZED_SAMP_MESSAGE
  698. #ifdef SPECTRAL_DEBUG_SAMP_MSG
  699. /**
  700. * target_if_spectral_log_SAMP_param() - Log SAMP parameters
  701. * @params: Reference to target_if_samp_msg_params
  702. *
  703. * API to log spectral SAMP message parameters
  704. *
  705. * Return: None
  706. */
  707. static void
  708. target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params)
  709. {
  710. target_if_dbg_print_samp_param(params);
  711. }
  712. #else
  713. static void
  714. target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params)
  715. {
  716. }
  717. #endif
  718. #endif /* OPTIMIZED_SAMP_MESSAGE */
  719. #ifdef OPTIMIZED_SAMP_MESSAGE
  720. /**
  721. * target_if_spectral_unify_cfreq_format() - Unify the cfreq representations.
  722. * @spectral: Pointer to target_if spectral internal structure
  723. * @cfreq1: cfreq1 value received in the Spectral report
  724. * @cfreq2: cfreq2 value received in the Spectral report
  725. * @pri20_freq: Primary 20MHz frequency of operation
  726. * @ch_width: channel width. If the center frequencies are of operating channel,
  727. * pass the operating channel width, else pass the sscan channel width.
  728. * @smode: Spectral scan mode
  729. *
  730. * This API converts the cfreq1 and cfreq2 representations as follows.
  731. * For a contiguous channel, cfreq1 will represent the center of the entire
  732. * span and cfreq2 will be 0. For a discontiguous channel like 80p80, cfreq1
  733. * will represent the center of primary segment whereas cfreq2 will
  734. * represent the center of secondary segment.
  735. *
  736. * Return: Success/Failure
  737. */
  738. static QDF_STATUS
  739. target_if_spectral_unify_cfreq_format(struct target_if_spectral *spectral,
  740. uint32_t *cfreq1, uint32_t *cfreq2,
  741. uint32_t pri20_freq,
  742. enum phy_ch_width ch_width,
  743. enum spectral_scan_mode smode)
  744. {
  745. uint32_t reported_cfreq1, reported_cfreq2;
  746. struct wlan_objmgr_psoc *psoc;
  747. if (!spectral) {
  748. spectral_err_rl("Spectral LMAC object is null");
  749. return QDF_STATUS_E_NULL_VALUE;
  750. }
  751. if (!spectral->pdev_obj) {
  752. spectral_err_rl("Spectral PDEV is null");
  753. return QDF_STATUS_E_NULL_VALUE;
  754. }
  755. psoc = wlan_pdev_get_psoc(spectral->pdev_obj);
  756. if (!psoc) {
  757. spectral_err_rl("psoc is null");
  758. return QDF_STATUS_E_NULL_VALUE;
  759. }
  760. reported_cfreq1 = *cfreq1;
  761. reported_cfreq2 = *cfreq2;
  762. if (ch_width == CH_WIDTH_160MHZ &&
  763. spectral->rparams.fragmentation_160[smode]) {
  764. /* cfreq should be 0 for 160MHz as it is contiguous */
  765. *cfreq2 = 0;
  766. /**
  767. * For gen3 chipsets that use fragmentation, cfreq1 is center of
  768. * pri80, and cfreq2 is center of sec80. Averaging them gives
  769. * the center of the 160MHz span.
  770. * Whereas gen2 chipsets report the center of the 160MHz span in
  771. * cfreq2 itself.
  772. */
  773. if (spectral->spectral_gen == SPECTRAL_GEN3)
  774. *cfreq1 = (reported_cfreq1 + reported_cfreq2) >> 1;
  775. else
  776. *cfreq1 = reported_cfreq2;
  777. } else if (ch_width == CH_WIDTH_80P80MHZ &&
  778. wlan_psoc_nif_fw_ext_cap_get(
  779. psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT)) {
  780. /* In restricted 80p80 case */
  781. const struct bonded_channel_freq
  782. *bonded_chan_ptr = NULL;
  783. enum channel_state state;
  784. /* Get the 80MHz channel containing the pri20 freq */
  785. state =
  786. wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode
  787. (spectral->pdev_obj, pri20_freq, CH_WIDTH_80MHZ,
  788. &bonded_chan_ptr, REG_CURRENT_PWR_MODE,
  789. NO_SCHANS_PUNC);
  790. if (state == CHANNEL_STATE_DISABLE ||
  791. state == CHANNEL_STATE_INVALID) {
  792. spectral_err_rl("Channel state is disable or invalid");
  793. return QDF_STATUS_E_FAILURE;
  794. }
  795. if (!bonded_chan_ptr) {
  796. spectral_err_rl("Bonded channel is not found");
  797. return QDF_STATUS_E_FAILURE;
  798. }
  799. /* cfreq1 is the center of the pri80 segment */
  800. *cfreq1 = (bonded_chan_ptr->start_freq +
  801. bonded_chan_ptr->end_freq) >> 1;
  802. /**
  803. * cfreq2 is 85MHz away from cfreq1. Whether it is
  804. * higher or lower depends on pri20_freq's relationship
  805. * with the reported center frequency.
  806. */
  807. if (pri20_freq < reported_cfreq1)
  808. *cfreq2 = *cfreq1 + FREQ_OFFSET_85MHZ;
  809. else
  810. *cfreq2 = *cfreq1 - FREQ_OFFSET_85MHZ;
  811. } else {
  812. /* All other cases are reporting the cfreq properly */
  813. *cfreq1 = reported_cfreq1;
  814. *cfreq2 = reported_cfreq2;
  815. }
  816. return QDF_STATUS_SUCCESS;
  817. }
  818. /**
  819. * target_if_populate_det_start_end_freqs() - Populate the start and end
  820. * frequencies, on per-detector level.
  821. * @spectral: Pointer to target_if spectral internal structure
  822. * @smode: Spectral scan mode
  823. *
  824. * Populate the start and end frequencies, on per-detector level.
  825. *
  826. * Return: Success/Failure
  827. */
  828. static QDF_STATUS
  829. target_if_populate_det_start_end_freqs(struct target_if_spectral *spectral,
  830. enum spectral_scan_mode smode)
  831. {
  832. struct per_session_report_info *rpt_info;
  833. struct per_session_det_map *det_map;
  834. struct per_session_dest_det_info *dest_det_info;
  835. enum phy_ch_width ch_width;
  836. struct sscan_detector_list *detector_list;
  837. bool is_fragmentation_160;
  838. uint8_t det;
  839. uint32_t cfreq;
  840. uint32_t start_end_freq_arr[2];
  841. if (!spectral) {
  842. spectral_err_rl("Spectral LMAC object is null");
  843. return QDF_STATUS_E_NULL_VALUE;
  844. }
  845. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  846. spectral_err_rl("Invalid Spectral mode");
  847. return QDF_STATUS_E_FAILURE;
  848. }
  849. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  850. ch_width = spectral->report_info[smode].sscan_bw;
  851. is_fragmentation_160 = spectral->rparams.fragmentation_160[smode];
  852. rpt_info = &spectral->report_info[smode];
  853. qdf_spin_lock_bh(&spectral->detector_list_lock);
  854. detector_list = &spectral->detector_list[smode][ch_width];
  855. for (det = 0; det < detector_list->num_detectors; det++) {
  856. qdf_spin_lock_bh(&spectral->session_det_map_lock);
  857. det_map = &spectral->det_map
  858. [detector_list->detectors[det]];
  859. dest_det_info = &det_map->dest_det_info[0];
  860. switch (det) {
  861. case 0:
  862. if (ch_width == CH_WIDTH_160MHZ &&
  863. is_fragmentation_160) {
  864. if (rpt_info->pri20_freq <
  865. rpt_info->sscan_cfreq1)
  866. cfreq = rpt_info->sscan_cfreq1 -
  867. FREQ_OFFSET_40MHZ;
  868. else
  869. cfreq = rpt_info->sscan_cfreq1 +
  870. FREQ_OFFSET_40MHZ;
  871. } else
  872. cfreq = rpt_info->sscan_cfreq1;
  873. break;
  874. case 1:
  875. if (ch_width == CH_WIDTH_160MHZ &&
  876. is_fragmentation_160) {
  877. if (rpt_info->pri20_freq <
  878. rpt_info->sscan_cfreq1)
  879. cfreq = rpt_info->sscan_cfreq1 +
  880. FREQ_OFFSET_40MHZ;
  881. else
  882. cfreq = rpt_info->sscan_cfreq1 -
  883. FREQ_OFFSET_40MHZ;
  884. } else
  885. cfreq = rpt_info->sscan_cfreq2;
  886. break;
  887. default:
  888. qdf_spin_unlock_bh(&spectral->session_det_map_lock);
  889. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  890. qdf_spin_unlock_bh(
  891. &spectral->session_report_info_lock);
  892. return QDF_STATUS_E_FAILURE;
  893. }
  894. /* Set start and end frequencies */
  895. target_if_spectral_set_start_end_freq(cfreq,
  896. ch_width,
  897. is_fragmentation_160,
  898. start_end_freq_arr);
  899. dest_det_info->start_freq = start_end_freq_arr[0];
  900. dest_det_info->end_freq = start_end_freq_arr[1];
  901. qdf_spin_unlock_bh(&spectral->session_det_map_lock);
  902. }
  903. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  904. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  905. return QDF_STATUS_SUCCESS;
  906. }
  907. QDF_STATUS
  908. target_if_populate_fft_bins_info(struct target_if_spectral *spectral,
  909. enum spectral_scan_mode smode)
  910. {
  911. struct per_session_det_map *det_map;
  912. struct per_session_dest_det_info *dest_det_info;
  913. enum phy_ch_width ch_width;
  914. struct sscan_detector_list *detector_list;
  915. bool is_fragmentation_160;
  916. uint8_t spectral_fft_size;
  917. uint8_t rpt_mode;
  918. uint32_t num_fft_bins;
  919. uint16_t start_bin;
  920. uint8_t det;
  921. if (!spectral) {
  922. spectral_err_rl("Spectral LMAC object is null");
  923. return QDF_STATUS_E_NULL_VALUE;
  924. }
  925. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  926. spectral_err_rl("Invalid Spectral mode");
  927. return QDF_STATUS_E_FAILURE;
  928. }
  929. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  930. ch_width = spectral->report_info[smode].sscan_bw;
  931. is_fragmentation_160 = spectral->rparams.fragmentation_160[smode];
  932. spectral_fft_size = spectral->params[smode].ss_fft_size;
  933. rpt_mode = spectral->params[smode].ss_rpt_mode;
  934. num_fft_bins =
  935. target_if_spectral_get_num_fft_bins(spectral_fft_size,
  936. rpt_mode);
  937. if (num_fft_bins < 0) {
  938. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  939. spectral_err_rl("Invalid number of FFT bins %d",
  940. num_fft_bins);
  941. return QDF_STATUS_E_FAILURE;
  942. }
  943. qdf_spin_lock_bh(&spectral->detector_list_lock);
  944. detector_list = &spectral->detector_list[smode][ch_width];
  945. for (det = 0; det < detector_list->num_detectors; det++) {
  946. uint16_t lb_extrabins_offset = 0;
  947. qdf_spin_lock_bh(&spectral->session_det_map_lock);
  948. det_map = &spectral->det_map
  949. [detector_list->detectors[det]];
  950. dest_det_info = &det_map->dest_det_info[0];
  951. dest_det_info->lb_extrabins_num = spectral->lb_edge_extrabins;
  952. dest_det_info->rb_extrabins_num = spectral->rb_edge_extrabins;
  953. switch (det) {
  954. case 0:
  955. if (ch_width == CH_WIDTH_160MHZ &&
  956. is_fragmentation_160 &&
  957. spectral->report_info[smode].pri20_freq >
  958. spectral->report_info[smode].sscan_cfreq1) {
  959. start_bin = num_fft_bins;
  960. lb_extrabins_offset =
  961. dest_det_info->lb_extrabins_num +
  962. dest_det_info->rb_extrabins_num;
  963. } else {
  964. start_bin = 0;
  965. }
  966. break;
  967. case 1:
  968. if (ch_width == CH_WIDTH_160MHZ &&
  969. is_fragmentation_160 &&
  970. spectral->report_info[smode].pri20_freq >
  971. spectral->report_info[smode].sscan_cfreq1)
  972. start_bin = 0;
  973. else {
  974. start_bin = num_fft_bins;
  975. lb_extrabins_offset =
  976. dest_det_info->lb_extrabins_num +
  977. dest_det_info->rb_extrabins_num;
  978. }
  979. break;
  980. default:
  981. qdf_spin_unlock_bh(&spectral->session_det_map_lock);
  982. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  983. qdf_spin_unlock_bh(
  984. &spectral->session_report_info_lock);
  985. return QDF_STATUS_E_FAILURE;
  986. }
  987. dest_det_info->dest_start_bin_idx = start_bin;
  988. dest_det_info->dest_end_bin_idx =
  989. dest_det_info->dest_start_bin_idx;
  990. if (num_fft_bins > 0)
  991. dest_det_info->dest_end_bin_idx += (num_fft_bins - 1);
  992. if (dest_det_info->lb_extrabins_num) {
  993. if (is_ch_width_160_or_80p80(ch_width)) {
  994. dest_det_info->lb_extrabins_start_idx =
  995. 2 * num_fft_bins +
  996. lb_extrabins_offset;
  997. } else {
  998. dest_det_info->lb_extrabins_start_idx =
  999. num_fft_bins;
  1000. }
  1001. }
  1002. if (dest_det_info->rb_extrabins_num)
  1003. dest_det_info->rb_extrabins_start_idx =
  1004. dest_det_info->lb_extrabins_start_idx +
  1005. dest_det_info->lb_extrabins_num;
  1006. dest_det_info->src_start_bin_idx = 0;
  1007. qdf_spin_unlock_bh(&spectral->session_det_map_lock);
  1008. }
  1009. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  1010. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1011. return QDF_STATUS_SUCCESS;
  1012. }
  1013. /**
  1014. * target_if_update_session_info_from_report_ctx() - Update per-session
  1015. * information from the consume report context. This includes populating start
  1016. * and end bin indices, and set the start and end frequency per-detector.
  1017. * @spectral: Pointer to target_if spectral internal structure
  1018. * @fft_bin_size: Size of 1 FFT bin (in bytes)
  1019. * @cfreq1: Center frequency of Detector 1
  1020. * @cfreq2: Center frequency of Detector 2
  1021. * @smode: Spectral scan mode
  1022. *
  1023. * Update per-session information from the consume report context.
  1024. *
  1025. * Return: Success/Failure
  1026. */
  1027. static QDF_STATUS
  1028. target_if_update_session_info_from_report_ctx(
  1029. struct target_if_spectral *spectral,
  1030. uint8_t fft_bin_size,
  1031. uint32_t cfreq1, uint32_t cfreq2,
  1032. enum spectral_scan_mode smode)
  1033. {
  1034. struct target_if_spectral_ops *p_sops;
  1035. struct per_session_report_info *rpt_info;
  1036. struct per_session_det_map *det_map;
  1037. struct per_session_dest_det_info *dest_det_info;
  1038. enum phy_ch_width ch_width;
  1039. struct wlan_objmgr_psoc *psoc;
  1040. bool is_fragmentation_160;
  1041. uint32_t start_end_freq_arr[2];
  1042. QDF_STATUS ret;
  1043. bool is_session_info_expected;
  1044. if (!spectral) {
  1045. spectral_err_rl("Spectral LMAC object is null");
  1046. return QDF_STATUS_E_NULL_VALUE;
  1047. }
  1048. ret = spectral_is_session_info_expected_from_target(
  1049. spectral->pdev_obj,
  1050. &is_session_info_expected);
  1051. if (QDF_IS_STATUS_ERROR(ret)) {
  1052. spectral_err_rl("Failed to check if session info is expected");
  1053. return ret;
  1054. }
  1055. /* If FW sends this information, use it, no need to get it from here */
  1056. if (is_session_info_expected)
  1057. return QDF_STATUS_SUCCESS;
  1058. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1059. spectral_err_rl("Invalid Spectral mode");
  1060. return QDF_STATUS_E_FAILURE;
  1061. }
  1062. if (!spectral->pdev_obj) {
  1063. spectral_err_rl("Spectral PDEV is null");
  1064. return QDF_STATUS_E_NULL_VALUE;
  1065. }
  1066. psoc = wlan_pdev_get_psoc(spectral->pdev_obj);
  1067. if (!psoc) {
  1068. spectral_err_rl("psoc is null");
  1069. return QDF_STATUS_E_NULL_VALUE;
  1070. }
  1071. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1072. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  1073. rpt_info = &spectral->report_info[smode];
  1074. ch_width = rpt_info->sscan_bw;
  1075. is_fragmentation_160 = spectral->rparams.fragmentation_160[smode];
  1076. rpt_info->pri20_freq = p_sops->get_current_channel(spectral, smode);
  1077. rpt_info->cfreq1 = cfreq1;
  1078. rpt_info->cfreq2 = cfreq2;
  1079. if (spectral_debug_level & DEBUG_SPECTRAL4)
  1080. spectral_debug("Before conversion: cfreq1: %u cfreq2: %u",
  1081. rpt_info->cfreq1, rpt_info->cfreq2);
  1082. ret = target_if_spectral_unify_cfreq_format(
  1083. spectral, &rpt_info->cfreq1, &rpt_info->cfreq2,
  1084. rpt_info->pri20_freq, rpt_info->operating_bw, smode);
  1085. if (QDF_IS_STATUS_ERROR(ret)) {
  1086. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1087. spectral_err_rl("Unable to unify cfreq1/cfreq2");
  1088. return QDF_STATUS_E_FAILURE;
  1089. }
  1090. if (spectral_debug_level & DEBUG_SPECTRAL4)
  1091. spectral_debug("After conversion: cfreq1: %d cfreq2: %d",
  1092. rpt_info->cfreq1, rpt_info->cfreq2);
  1093. /* For Agile mode, sscan_cfreq1 and sscan_cfreq2 are populated
  1094. * during Spectral start scan
  1095. */
  1096. if (smode == SPECTRAL_SCAN_MODE_NORMAL) {
  1097. rpt_info->sscan_cfreq1 = rpt_info->cfreq1;
  1098. rpt_info->sscan_cfreq2 = rpt_info->cfreq2;
  1099. }
  1100. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1101. if (ch_width == CH_WIDTH_80P80MHZ && wlan_psoc_nif_fw_ext_cap_get(
  1102. psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT)) {
  1103. /* Restricted 80p80 */
  1104. struct spectral_fft_bin_markers_160_165mhz *marker;
  1105. struct sscan_detector_list *detector_list;
  1106. marker = &spectral->rparams.marker[smode];
  1107. if (!marker->is_valid)
  1108. return QDF_STATUS_E_FAILURE;
  1109. /**
  1110. * Restricted 80p80 on Pine has only 1 detector for
  1111. * normal/agile spectral scan. So, detector_list will
  1112. * have only one detector
  1113. */
  1114. qdf_spin_lock_bh(&spectral->detector_list_lock);
  1115. detector_list = &spectral->detector_list[smode][ch_width];
  1116. qdf_spin_lock_bh(&spectral->session_det_map_lock);
  1117. det_map = &spectral->det_map[detector_list->detectors[0]];
  1118. dest_det_info = &det_map->dest_det_info[0];
  1119. dest_det_info->dest_start_bin_idx = marker->start_pri80;
  1120. dest_det_info->dest_end_bin_idx =
  1121. dest_det_info->dest_start_bin_idx +
  1122. marker->num_pri80 - 1;
  1123. dest_det_info->src_start_bin_idx = marker->start_pri80 *
  1124. fft_bin_size;
  1125. /* Set start and end frequencies */
  1126. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  1127. target_if_spectral_set_start_end_freq(rpt_info->sscan_cfreq1,
  1128. ch_width,
  1129. is_fragmentation_160,
  1130. start_end_freq_arr);
  1131. dest_det_info->start_freq = start_end_freq_arr[0];
  1132. dest_det_info->end_freq = start_end_freq_arr[1];
  1133. dest_det_info = &det_map->dest_det_info[1];
  1134. dest_det_info->dest_start_bin_idx = marker->start_sec80;
  1135. dest_det_info->dest_end_bin_idx =
  1136. dest_det_info->dest_start_bin_idx +
  1137. marker->num_sec80 - 1;
  1138. dest_det_info->src_start_bin_idx = marker->start_sec80 *
  1139. fft_bin_size;
  1140. /* Set start and end frequencies */
  1141. target_if_spectral_set_start_end_freq(rpt_info->sscan_cfreq2,
  1142. ch_width,
  1143. is_fragmentation_160,
  1144. start_end_freq_arr);
  1145. dest_det_info->start_freq = start_end_freq_arr[0];
  1146. dest_det_info->end_freq = start_end_freq_arr[1];
  1147. dest_det_info = &det_map->dest_det_info[2];
  1148. dest_det_info->dest_start_bin_idx = marker->start_5mhz;
  1149. dest_det_info->dest_end_bin_idx =
  1150. dest_det_info->dest_start_bin_idx +
  1151. marker->num_5mhz - 1;
  1152. dest_det_info->src_start_bin_idx = marker->start_5mhz *
  1153. fft_bin_size;
  1154. /* Set start and end frequencies */
  1155. dest_det_info->start_freq =
  1156. min(det_map->dest_det_info[0].end_freq,
  1157. det_map->dest_det_info[1].end_freq);
  1158. dest_det_info->end_freq =
  1159. max(det_map->dest_det_info[0].start_freq,
  1160. det_map->dest_det_info[1].start_freq);
  1161. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1162. qdf_spin_unlock_bh(&spectral->session_det_map_lock);
  1163. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  1164. } else {
  1165. ret = target_if_populate_fft_bins_info(spectral, smode);
  1166. if (QDF_IS_STATUS_ERROR(ret)) {
  1167. spectral_err_rl("Error in populating fft bins info");
  1168. return QDF_STATUS_E_FAILURE;
  1169. }
  1170. ret = target_if_populate_det_start_end_freqs(spectral, smode);
  1171. if (QDF_IS_STATUS_ERROR(ret)) {
  1172. spectral_err_rl("Failed to populate start/end freqs");
  1173. return QDF_STATUS_E_FAILURE;
  1174. }
  1175. }
  1176. return QDF_STATUS_SUCCESS;
  1177. }
  1178. #endif /* OPTIMIZED_SAMP_MESSAGE */
  1179. #ifdef OPTIMIZED_SAMP_MESSAGE
  1180. /**
  1181. * target_if_spectral_populate_samp_params_gen2() - Populate the SAMP params
  1182. * for gen2. SAMP params are to be used for populating SAMP msg.
  1183. * @spectral: Pointer to spectral object
  1184. * @phyerr_info: Pointer to processed phyerr info
  1185. * @params: Pointer to Spectral SAMP message fields to be populated
  1186. *
  1187. * Populate the SAMP params for gen2, which will be used to populate SAMP msg.
  1188. *
  1189. * Return: Success/Failure
  1190. */
  1191. static QDF_STATUS
  1192. target_if_spectral_populate_samp_params_gen2(
  1193. struct target_if_spectral *spectral,
  1194. struct spectral_process_phyerr_info_gen2 *phyerr_info,
  1195. struct target_if_samp_msg_params *params)
  1196. {
  1197. uint8_t chn_idx_highest_enabled;
  1198. uint8_t chn_idx_lowest_enabled;
  1199. int8_t control_rssi;
  1200. int8_t extension_rssi;
  1201. struct target_if_spectral_rfqual_info *p_rfqual;
  1202. struct spectral_search_fft_info_gen2 *p_sfft;
  1203. struct spectral_phyerr_fft_gen2 *pfft;
  1204. struct target_if_spectral_acs_stats *acs_stats;
  1205. enum phy_ch_width ch_width;
  1206. enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
  1207. if (!spectral) {
  1208. spectral_err_rl("Spectral LMAC object is null");
  1209. return QDF_STATUS_E_NULL_VALUE;
  1210. }
  1211. if (!phyerr_info) {
  1212. spectral_err_rl("Pointer to phyerr info is null");
  1213. return QDF_STATUS_E_NULL_VALUE;
  1214. }
  1215. if (!params) {
  1216. spectral_err_rl("SAMP msg params structure is null");
  1217. return QDF_STATUS_E_NULL_VALUE;
  1218. }
  1219. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  1220. ch_width = spectral->report_info[smode].sscan_bw;
  1221. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1222. acs_stats = phyerr_info->acs_stats;
  1223. pfft = phyerr_info->pfft;
  1224. p_sfft = phyerr_info->p_sfft;
  1225. p_rfqual = phyerr_info->p_rfqual;
  1226. params->hw_detector_id = phyerr_info->seg_id;
  1227. params->rssi = p_rfqual->rssi_comb;
  1228. if (spectral->is_sec80_rssi_war_required && phyerr_info->seg_id == 1)
  1229. params->rssi = target_if_get_combrssi_sec80_seg_gen2(spectral,
  1230. p_sfft);
  1231. chn_idx_highest_enabled =
  1232. ((spectral->params[smode].ss_chn_mask & 0x8) ? 3 :
  1233. (spectral->params[smode].ss_chn_mask & 0x4) ? 2 :
  1234. (spectral->params[smode].ss_chn_mask & 0x2) ? 1 : 0);
  1235. chn_idx_lowest_enabled =
  1236. ((spectral->params[smode].ss_chn_mask & 0x1) ? 0 :
  1237. (spectral->params[smode].ss_chn_mask & 0x2) ? 1 :
  1238. (spectral->params[smode].ss_chn_mask & 0x4) ? 2 : 3);
  1239. control_rssi =
  1240. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20;
  1241. extension_rssi =
  1242. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20;
  1243. if (spectral->upper_is_control)
  1244. params->upper_rssi = control_rssi;
  1245. else
  1246. params->upper_rssi = extension_rssi;
  1247. if (spectral->lower_is_control)
  1248. params->lower_rssi = control_rssi;
  1249. else
  1250. params->lower_rssi = extension_rssi;
  1251. if (spectral->sc_spectral_noise_pwr_cal) {
  1252. int idx;
  1253. for (idx = 0; idx < HOST_MAX_ANTENNA; idx++) {
  1254. params->chain_ctl_rssi[idx] =
  1255. p_rfqual->pc_rssi_info[idx].rssi_pri20;
  1256. params->chain_ext_rssi[idx] =
  1257. p_rfqual->pc_rssi_info[idx].rssi_sec20;
  1258. }
  1259. }
  1260. params->timestamp = (phyerr_info->tsf64 & SPECTRAL_TSMASK);
  1261. params->max_mag = p_sfft->peak_mag;
  1262. params->max_index = p_sfft->peak_inx;
  1263. /*
  1264. * For VHT80_80/VHT160, the noise floor for primary
  1265. * 80MHz segment is populated with the lowest enabled
  1266. * antenna chain and the noise floor for secondary 80MHz segment
  1267. * is populated with the highest enabled antenna chain.
  1268. * For modes upto VHT80, the noise floor is populated with the
  1269. * one corresponding to the highest enabled antenna chain.
  1270. */
  1271. if (is_ch_width_160_or_80p80(ch_width) && phyerr_info->seg_id == 0)
  1272. params->noise_floor =
  1273. p_rfqual->noise_floor[chn_idx_lowest_enabled];
  1274. else
  1275. params->noise_floor =
  1276. p_rfqual->noise_floor[chn_idx_highest_enabled];
  1277. acs_stats->ctrl_nf = params->noise_floor;
  1278. acs_stats->ext_nf = params->noise_floor;
  1279. acs_stats->nfc_ctl_rssi = control_rssi;
  1280. acs_stats->nfc_ext_rssi = extension_rssi;
  1281. params->bin_pwr_data = (uint8_t *)pfft;
  1282. return QDF_STATUS_SUCCESS;
  1283. }
  1284. int
  1285. target_if_process_phyerr_gen2(struct target_if_spectral *spectral,
  1286. uint8_t *data,
  1287. uint32_t datalen,
  1288. struct target_if_spectral_rfqual_info *p_rfqual,
  1289. struct target_if_spectral_chan_info *p_chaninfo,
  1290. uint64_t tsf64,
  1291. struct target_if_spectral_acs_stats *acs_stats)
  1292. {
  1293. /*
  1294. * XXX : The classifier do not use all the members of the SAMP
  1295. * message data format.
  1296. * The classifier only depends upon the following parameters
  1297. *
  1298. * 1. Frequency
  1299. * 2. Spectral RSSI
  1300. * 3. Bin Power Count
  1301. * 4. Bin Power values
  1302. * 5. Spectral Timestamp
  1303. * 6. MAC Address
  1304. *
  1305. * This function prepares the params structure and populates it
  1306. * with relevant values, this is in turn passed to
  1307. * spectral_fill_samp_msg()
  1308. * to prepare fully formatted Spectral SAMP message
  1309. *
  1310. * XXX : Need to verify
  1311. * 1. Order of FFT bin values
  1312. *
  1313. */
  1314. struct target_if_samp_msg_params params;
  1315. struct spectral_search_fft_info_gen2 search_fft_info;
  1316. struct spectral_search_fft_info_gen2 *p_sfft = &search_fft_info;
  1317. struct spectral_search_fft_info_gen2 search_fft_info_sec80;
  1318. struct spectral_search_fft_info_gen2 *p_sfft_sec80 =
  1319. &search_fft_info_sec80;
  1320. uint32_t segid_skiplen = 0;
  1321. struct spectral_phyerr_tlv_gen2 *ptlv = NULL;
  1322. struct spectral_phyerr_tlv_gen2 *ptlv_sec80 = NULL;
  1323. struct spectral_phyerr_fft_gen2 *pfft = NULL;
  1324. struct spectral_phyerr_fft_gen2 *pfft_sec80 = NULL;
  1325. struct spectral_process_phyerr_info_gen2 process_phyerr_fields;
  1326. struct spectral_process_phyerr_info_gen2 *phyerr_info =
  1327. &process_phyerr_fields;
  1328. uint8_t segid = 0;
  1329. uint8_t segid_sec80;
  1330. enum phy_ch_width ch_width;
  1331. QDF_STATUS ret;
  1332. struct target_if_spectral_ops *p_sops;
  1333. if (!spectral) {
  1334. spectral_err_rl("Spectral LMAC object is null");
  1335. return -EPERM;
  1336. }
  1337. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1338. /* Drop the sample if Spectral is not active */
  1339. if (!p_sops->is_spectral_active(spectral,
  1340. SPECTRAL_SCAN_MODE_NORMAL)) {
  1341. spectral_info_rl("Spectral scan is not active");
  1342. goto fail_no_print;
  1343. }
  1344. if (!data) {
  1345. spectral_err_rl("Phyerror event buffer is null");
  1346. goto fail;
  1347. }
  1348. if (!p_rfqual) {
  1349. spectral_err_rl("RF quality information is null");
  1350. goto fail;
  1351. }
  1352. if (!p_chaninfo) {
  1353. spectral_err_rl("Channel information is null");
  1354. goto fail;
  1355. }
  1356. if (!acs_stats) {
  1357. spectral_err_rl("ACS stats pointer is null");
  1358. goto fail;
  1359. }
  1360. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  1361. ch_width = spectral->report_info[SPECTRAL_SCAN_MODE_NORMAL].sscan_bw;
  1362. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  1363. ptlv = (struct spectral_phyerr_tlv_gen2 *)data;
  1364. if (spectral->is_160_format)
  1365. segid_skiplen = sizeof(SPECTRAL_SEGID_INFO);
  1366. pfft = (struct spectral_phyerr_fft_gen2 *)(
  1367. data +
  1368. sizeof(struct spectral_phyerr_tlv_gen2) +
  1369. sizeof(struct spectral_phyerr_hdr_gen2) +
  1370. segid_skiplen);
  1371. /*
  1372. * XXX Extend SPECTRAL_DPRINTK() to use spectral_debug_level,
  1373. * and use this facility inside spectral_dump_phyerr_data()
  1374. * and supporting functions.
  1375. */
  1376. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  1377. target_if_spectral_dump_phyerr_data_gen2(
  1378. data, datalen,
  1379. spectral->is_160_format);
  1380. if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1381. /*
  1382. * EV# 118023: We tentatively disable the below print
  1383. * and provide stats instead.
  1384. */
  1385. spectral->diag_stats.spectral_mismatch++;
  1386. goto fail;
  1387. }
  1388. qdf_mem_zero(&params, sizeof(params));
  1389. if (ptlv->tag == TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  1390. if (spectral->is_160_format) {
  1391. segid = *((SPECTRAL_SEGID_INFO *)(
  1392. (uint8_t *)ptlv +
  1393. sizeof(struct spectral_phyerr_tlv_gen2) +
  1394. sizeof(struct spectral_phyerr_hdr_gen2)));
  1395. if (segid != 0) {
  1396. struct spectral_diag_stats *p_diag_stats =
  1397. &spectral->diag_stats;
  1398. p_diag_stats->spectral_vhtseg1id_mismatch++;
  1399. goto fail;
  1400. }
  1401. }
  1402. target_if_process_sfft_report_gen2(ptlv, ptlv->length,
  1403. p_sfft);
  1404. ret = target_if_update_session_info_from_report_ctx(
  1405. spectral, FFT_BIN_SIZE_1BYTE,
  1406. p_chaninfo->center_freq1,
  1407. p_chaninfo->center_freq2,
  1408. SPECTRAL_SCAN_MODE_NORMAL);
  1409. if (QDF_IS_STATUS_ERROR(ret)) {
  1410. spectral_err_rl("Failed to update per-session info");
  1411. goto fail;
  1412. }
  1413. phyerr_info->p_rfqual = p_rfqual;
  1414. phyerr_info->p_sfft = p_sfft;
  1415. phyerr_info->pfft = pfft;
  1416. phyerr_info->acs_stats = acs_stats;
  1417. phyerr_info->tsf64 = tsf64;
  1418. phyerr_info->seg_id = segid;
  1419. ret = target_if_spectral_populate_samp_params_gen2(spectral,
  1420. phyerr_info,
  1421. &params);
  1422. if (QDF_IS_STATUS_ERROR(ret)) {
  1423. spectral_err_rl("Failed to populate SAMP params");
  1424. goto fail;
  1425. }
  1426. ret = target_if_spectral_fill_samp_msg(spectral, &params);
  1427. if (QDF_IS_STATUS_ERROR(ret)) {
  1428. spectral_err_rl("Failed to fill the SAMP msg");
  1429. goto fail;
  1430. }
  1431. if (spectral->is_160_format &&
  1432. is_ch_width_160_or_80p80(ch_width)) {
  1433. /*
  1434. * We expect to see one more Search FFT report, and it
  1435. * should be equal in size to the current one.
  1436. */
  1437. if (datalen < (
  1438. 2 * (sizeof(struct spectral_phyerr_tlv_gen2) +
  1439. ptlv->length))) {
  1440. struct spectral_diag_stats *p_diag_stats =
  1441. &spectral->diag_stats;
  1442. p_diag_stats->spectral_sec80_sfft_insufflen++;
  1443. goto fail;
  1444. }
  1445. ptlv_sec80 = (struct spectral_phyerr_tlv_gen2 *)(
  1446. data +
  1447. sizeof(struct spectral_phyerr_tlv_gen2) +
  1448. ptlv->length);
  1449. if (ptlv_sec80->signature !=
  1450. SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1451. spectral->diag_stats.spectral_mismatch++;
  1452. goto fail;
  1453. }
  1454. if (ptlv_sec80->tag != TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  1455. spectral->diag_stats.spectral_no_sec80_sfft++;
  1456. goto fail;
  1457. }
  1458. segid_sec80 = *((SPECTRAL_SEGID_INFO *)(
  1459. (uint8_t *)ptlv_sec80 +
  1460. sizeof(struct spectral_phyerr_tlv_gen2) +
  1461. sizeof(struct spectral_phyerr_hdr_gen2)));
  1462. if (segid_sec80 != 1) {
  1463. struct spectral_diag_stats *p_diag_stats =
  1464. &spectral->diag_stats;
  1465. p_diag_stats->spectral_vhtseg2id_mismatch++;
  1466. goto fail;
  1467. }
  1468. target_if_process_sfft_report_gen2(ptlv_sec80,
  1469. ptlv_sec80->length,
  1470. p_sfft_sec80);
  1471. pfft_sec80 = (struct spectral_phyerr_fft_gen2 *)(
  1472. ((uint8_t *)ptlv_sec80) +
  1473. sizeof(struct spectral_phyerr_tlv_gen2) +
  1474. sizeof(struct spectral_phyerr_hdr_gen2) +
  1475. segid_skiplen);
  1476. qdf_mem_zero(&params, sizeof(params));
  1477. phyerr_info->p_rfqual = p_rfqual;
  1478. phyerr_info->p_sfft = p_sfft_sec80;
  1479. phyerr_info->pfft = pfft_sec80;
  1480. phyerr_info->acs_stats = acs_stats;
  1481. phyerr_info->tsf64 = tsf64;
  1482. phyerr_info->seg_id = segid_sec80;
  1483. ret = target_if_spectral_populate_samp_params_gen2(
  1484. spectral, phyerr_info,
  1485. &params);
  1486. if (QDF_IS_STATUS_ERROR(ret)) {
  1487. spectral_err_rl("Failed to populate SAMP params");
  1488. goto fail;
  1489. }
  1490. ret = target_if_spectral_fill_samp_msg(spectral,
  1491. &params);
  1492. if (QDF_IS_STATUS_ERROR(ret)) {
  1493. spectral_err_rl("Failed to fill the SAMP msg");
  1494. goto fail;
  1495. }
  1496. }
  1497. }
  1498. if (spectral_debug_level & DEBUG_SPECTRAL4)
  1499. spectral_debug_level = DEBUG_SPECTRAL;
  1500. return 0;
  1501. fail:
  1502. spectral_err_rl("Error while processing Spectral report");
  1503. fail_no_print:
  1504. if (spectral_debug_level & DEBUG_SPECTRAL4)
  1505. spectral_debug_level = DEBUG_SPECTRAL;
  1506. free_samp_msg_skb(spectral, SPECTRAL_SCAN_MODE_NORMAL);
  1507. return -EPERM;
  1508. }
  1509. #else
  1510. int
  1511. target_if_process_phyerr_gen2(struct target_if_spectral *spectral,
  1512. uint8_t *data,
  1513. uint32_t datalen,
  1514. struct target_if_spectral_rfqual_info *p_rfqual,
  1515. struct target_if_spectral_chan_info *p_chaninfo,
  1516. uint64_t tsf64,
  1517. struct target_if_spectral_acs_stats *acs_stats)
  1518. {
  1519. /*
  1520. * XXX : The classifier do not use all the members of the SAMP
  1521. * message data format.
  1522. * The classifier only depends upon the following parameters
  1523. *
  1524. * 1. Frequency (freq, msg->freq)
  1525. * 2. Spectral RSSI (spectral_rssi,
  1526. * msg->samp_data.spectral_rssi)
  1527. * 3. Bin Power Count (bin_pwr_count,
  1528. * msg->samp_data.bin_pwr_count)
  1529. * 4. Bin Power values (bin_pwr, msg->samp_data.bin_pwr[0]
  1530. * 5. Spectral Timestamp (spectral_tstamp,
  1531. * msg->samp_data.spectral_tstamp)
  1532. * 6. MAC Address (macaddr, msg->macaddr)
  1533. *
  1534. * This function prepares the params structure and populates it
  1535. * with
  1536. * relevant values, this is in turn passed to
  1537. * spectral_create_samp_msg()
  1538. * to prepare fully formatted Spectral SAMP message
  1539. *
  1540. * XXX : Need to verify
  1541. * 1. Order of FFT bin values
  1542. *
  1543. */
  1544. struct target_if_samp_msg_params params;
  1545. struct spectral_search_fft_info_gen2 search_fft_info;
  1546. struct spectral_search_fft_info_gen2 *p_sfft = &search_fft_info;
  1547. struct spectral_search_fft_info_gen2 search_fft_info_sec80;
  1548. struct spectral_search_fft_info_gen2 *p_sfft_sec80 =
  1549. &search_fft_info_sec80;
  1550. uint32_t segid_skiplen = 0;
  1551. int8_t rssi_up = 0;
  1552. int8_t rssi_low = 0;
  1553. int8_t chn_idx_highest_enabled = 0;
  1554. int8_t chn_idx_lowest_enabled = 0;
  1555. uint8_t control_rssi = 0;
  1556. uint8_t extension_rssi = 0;
  1557. uint8_t combined_rssi = 0;
  1558. uint32_t tstamp = 0;
  1559. struct target_if_spectral_ops *p_sops =
  1560. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1561. struct spectral_phyerr_tlv_gen2 *ptlv =
  1562. (struct spectral_phyerr_tlv_gen2 *)data;
  1563. struct spectral_phyerr_tlv_gen2 *ptlv_sec80 = NULL;
  1564. struct spectral_phyerr_fft_gen2 *pfft = NULL;
  1565. struct spectral_phyerr_fft_gen2 *pfft_sec80 = NULL;
  1566. uint8_t segid = 0;
  1567. uint8_t segid_sec80 = 0;
  1568. enum phy_ch_width ch_width =
  1569. spectral->ch_width[SPECTRAL_SCAN_MODE_NORMAL];
  1570. if (spectral->is_160_format)
  1571. segid_skiplen = sizeof(SPECTRAL_SEGID_INFO);
  1572. pfft = (struct spectral_phyerr_fft_gen2 *)(
  1573. data +
  1574. sizeof(struct spectral_phyerr_tlv_gen2) +
  1575. sizeof(struct spectral_phyerr_hdr_gen2) +
  1576. segid_skiplen);
  1577. /*
  1578. * XXX Extend SPECTRAL_DPRINTK() to use spectral_debug_level,
  1579. * and use this facility inside spectral_dump_phyerr_data()
  1580. * and supporting functions.
  1581. */
  1582. if (spectral_debug_level & DEBUG_SPECTRAL2)
  1583. target_if_spectral_dump_phyerr_data_gen2(
  1584. data, datalen,
  1585. spectral->is_160_format);
  1586. if (spectral_debug_level & DEBUG_SPECTRAL4) {
  1587. target_if_spectral_dump_phyerr_data_gen2(
  1588. data, datalen,
  1589. spectral->is_160_format);
  1590. spectral_debug_level = DEBUG_SPECTRAL;
  1591. }
  1592. if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1593. /*
  1594. * EV# 118023: We tentatively disable the below print
  1595. * and provide stats instead.
  1596. */
  1597. spectral->diag_stats.spectral_mismatch++;
  1598. return -EPERM;
  1599. }
  1600. OS_MEMZERO(&params, sizeof(params));
  1601. /* Gen 2 only supports normal Spectral scan currently */
  1602. params.smode = SPECTRAL_SCAN_MODE_NORMAL;
  1603. if (ptlv->tag == TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  1604. if (spectral->is_160_format) {
  1605. segid = *((SPECTRAL_SEGID_INFO *)(
  1606. (uint8_t *)ptlv +
  1607. sizeof(struct spectral_phyerr_tlv_gen2) +
  1608. sizeof(struct spectral_phyerr_hdr_gen2)));
  1609. if (segid != 0) {
  1610. struct spectral_diag_stats *p_diag_stats =
  1611. &spectral->diag_stats;
  1612. p_diag_stats->spectral_vhtseg1id_mismatch++;
  1613. return -EPERM;
  1614. }
  1615. }
  1616. target_if_process_sfft_report_gen2(ptlv, ptlv->length,
  1617. &search_fft_info);
  1618. tstamp = p_sops->get_tsf64(spectral) & SPECTRAL_TSMASK;
  1619. combined_rssi = p_rfqual->rssi_comb;
  1620. if (spectral->upper_is_control)
  1621. rssi_up = control_rssi;
  1622. else
  1623. rssi_up = extension_rssi;
  1624. if (spectral->lower_is_control)
  1625. rssi_low = control_rssi;
  1626. else
  1627. rssi_low = extension_rssi;
  1628. params.rssi = p_rfqual->rssi_comb;
  1629. params.lower_rssi = rssi_low;
  1630. params.upper_rssi = rssi_up;
  1631. if (spectral->sc_spectral_noise_pwr_cal) {
  1632. params.chain_ctl_rssi[0] =
  1633. p_rfqual->pc_rssi_info[0].rssi_pri20;
  1634. params.chain_ctl_rssi[1] =
  1635. p_rfqual->pc_rssi_info[1].rssi_pri20;
  1636. params.chain_ctl_rssi[2] =
  1637. p_rfqual->pc_rssi_info[2].rssi_pri20;
  1638. params.chain_ext_rssi[0] =
  1639. p_rfqual->pc_rssi_info[0].rssi_sec20;
  1640. params.chain_ext_rssi[1] =
  1641. p_rfqual->pc_rssi_info[1].rssi_sec20;
  1642. params.chain_ext_rssi[2] =
  1643. p_rfqual->pc_rssi_info[2].rssi_sec20;
  1644. }
  1645. /*
  1646. * XXX : This actually depends on the programmed chain mask
  1647. * This value decides the per-chain enable mask to select
  1648. * the input ADC for search FTT.
  1649. * For modes upto VHT80, if more than one chain is
  1650. * enabled, the max valid chain
  1651. * is used. LSB corresponds to chain zero.
  1652. * For VHT80_80 and VHT160, the lowest enabled chain is
  1653. * used for primary
  1654. * detection and highest enabled chain is used for
  1655. * secondary detection.
  1656. *
  1657. * XXX : The current algorithm do not use these control and
  1658. * extension channel
  1659. * Instead, it just relies on the combined RSSI values
  1660. * only.
  1661. * For fool-proof detection algorithm, we should take
  1662. * these RSSI values in to account.
  1663. * This is marked for future enhancements.
  1664. */
  1665. chn_idx_highest_enabled =
  1666. ((spectral->params[params.smode].ss_chn_mask & 0x8) ? 3 :
  1667. (spectral->params[params.smode].ss_chn_mask & 0x4) ? 2 :
  1668. (spectral->params[params.smode].ss_chn_mask & 0x2) ? 1 : 0);
  1669. chn_idx_lowest_enabled =
  1670. ((spectral->params[params.smode].ss_chn_mask & 0x1) ? 0 :
  1671. (spectral->params[params.smode].ss_chn_mask & 0x2) ? 1 :
  1672. (spectral->params[params.smode].ss_chn_mask & 0x4) ? 2 : 3);
  1673. control_rssi = (uint8_t)
  1674. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20;
  1675. extension_rssi = (uint8_t)
  1676. p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20;
  1677. params.bwinfo = 0;
  1678. params.tstamp = 0;
  1679. params.max_mag = p_sfft->peak_mag;
  1680. params.max_index = p_sfft->peak_inx;
  1681. params.max_exp = 0;
  1682. params.peak = 0;
  1683. params.bin_pwr_data = (uint8_t *)pfft;
  1684. params.freq = p_sops->get_current_channel(spectral,
  1685. params.smode);
  1686. params.freq_loading = 0;
  1687. params.interf_list.count = 0;
  1688. params.max_lower_index = 0;
  1689. params.max_upper_index = 0;
  1690. params.nb_lower = 0;
  1691. params.nb_upper = 0;
  1692. /*
  1693. * For modes upto VHT80, the noise floor is populated with the
  1694. * one corresponding
  1695. * to the highest enabled antenna chain
  1696. */
  1697. params.noise_floor =
  1698. p_rfqual->noise_floor[chn_idx_highest_enabled];
  1699. params.datalen = ptlv->length;
  1700. params.pwr_count = ptlv->length -
  1701. sizeof(struct spectral_phyerr_hdr_gen2) - segid_skiplen;
  1702. params.tstamp = (tsf64 & SPECTRAL_TSMASK);
  1703. acs_stats->ctrl_nf = params.noise_floor;
  1704. acs_stats->ext_nf = params.noise_floor;
  1705. acs_stats->nfc_ctl_rssi = control_rssi;
  1706. acs_stats->nfc_ext_rssi = extension_rssi;
  1707. if (spectral->is_160_format &&
  1708. is_ch_width_160_or_80p80(ch_width)) {
  1709. /*
  1710. * We expect to see one more Search FFT report, and it
  1711. * should be equal in size to the current one.
  1712. */
  1713. if (datalen < (
  1714. 2 * (
  1715. sizeof(struct spectral_phyerr_tlv_gen2) +
  1716. ptlv->length))) {
  1717. struct spectral_diag_stats *p_diag_stats =
  1718. &spectral->diag_stats;
  1719. p_diag_stats->spectral_sec80_sfft_insufflen++;
  1720. return -EPERM;
  1721. }
  1722. ptlv_sec80 = (struct spectral_phyerr_tlv_gen2 *)(
  1723. data +
  1724. sizeof(struct spectral_phyerr_tlv_gen2) +
  1725. ptlv->length);
  1726. if (ptlv_sec80->signature !=
  1727. SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1728. spectral->diag_stats.spectral_mismatch++;
  1729. return -EPERM;
  1730. }
  1731. if (ptlv_sec80->tag != TLV_TAG_SEARCH_FFT_REPORT_GEN2) {
  1732. spectral->diag_stats.spectral_no_sec80_sfft++;
  1733. return -EPERM;
  1734. }
  1735. segid_sec80 = *((SPECTRAL_SEGID_INFO *)(
  1736. (uint8_t *)ptlv_sec80 +
  1737. sizeof(struct spectral_phyerr_tlv_gen2) +
  1738. sizeof(struct spectral_phyerr_hdr_gen2)));
  1739. if (segid_sec80 != 1) {
  1740. struct spectral_diag_stats *p_diag_stats =
  1741. &spectral->diag_stats;
  1742. p_diag_stats->spectral_vhtseg2id_mismatch++;
  1743. return -EPERM;
  1744. }
  1745. params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1;
  1746. params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2;
  1747. target_if_process_sfft_report_gen2(
  1748. ptlv_sec80,
  1749. ptlv_sec80->length,
  1750. &search_fft_info_sec80);
  1751. pfft_sec80 = (struct spectral_phyerr_fft_gen2 *)(
  1752. ((uint8_t *)ptlv_sec80) +
  1753. sizeof(struct spectral_phyerr_tlv_gen2) +
  1754. sizeof(struct spectral_phyerr_hdr_gen2) +
  1755. segid_skiplen);
  1756. /* XXX: Confirm. TBD at SoD. */
  1757. params.rssi_sec80 = p_rfqual->rssi_comb;
  1758. if (spectral->is_sec80_rssi_war_required)
  1759. params.rssi_sec80 =
  1760. target_if_get_combrssi_sec80_seg_gen2
  1761. (spectral, &search_fft_info_sec80);
  1762. /* XXX: Determine dynamically. TBD at SoD. */
  1763. /*
  1764. * For VHT80_80/VHT160, the noise floor for primary
  1765. * 80MHz segment is populated with the
  1766. * lowest enabled antenna chain and the noise floor for
  1767. * secondary 80MHz segment is populated
  1768. * with the highest enabled antenna chain
  1769. */
  1770. params.noise_floor_sec80 =
  1771. p_rfqual->noise_floor[chn_idx_highest_enabled];
  1772. params.noise_floor =
  1773. p_rfqual->noise_floor[chn_idx_lowest_enabled];
  1774. params.max_mag_sec80 = p_sfft_sec80->peak_mag;
  1775. params.max_index_sec80 = p_sfft_sec80->peak_inx;
  1776. /* XXX Does this definition of datalen *still hold? */
  1777. params.datalen_sec80 = ptlv_sec80->length;
  1778. params.pwr_count_sec80 =
  1779. ptlv_sec80->length -
  1780. sizeof(struct spectral_phyerr_hdr_gen2) -
  1781. segid_skiplen;
  1782. params.bin_pwr_data_sec80 = (uint8_t *)pfft_sec80;
  1783. }
  1784. qdf_mem_copy(&params.classifier_params,
  1785. &spectral->classifier_params,
  1786. sizeof(struct spectral_classifier_params));
  1787. target_if_spectral_log_SAMP_param(&params);
  1788. target_if_spectral_create_samp_msg(spectral, &params);
  1789. }
  1790. return 0;
  1791. }
  1792. #endif /* OPTIMIZED_SAMP_MESSAGE */
  1793. int
  1794. target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr)
  1795. {
  1796. uint32_t a = 0;
  1797. uint32_t b = 0;
  1798. qdf_mem_copy(&a, (uint8_t *)phdr, sizeof(int));
  1799. qdf_mem_copy(&b,
  1800. (uint8_t *)((uint8_t *)phdr + sizeof(int)),
  1801. sizeof(int));
  1802. spectral_debug("SPECTRAL : HEADER A 0x%x (%d)", a, a);
  1803. spectral_debug("SPECTRAL : HEADER B 0x%x (%d)", b, b);
  1804. return 0;
  1805. }
  1806. int8_t
  1807. target_if_get_combrssi_sec80_seg_gen2(
  1808. struct target_if_spectral *spectral,
  1809. struct spectral_search_fft_info_gen2 *p_sfft_sec80)
  1810. {
  1811. uint32_t avgpwr_db = 0;
  1812. uint32_t total_gain_db = 0;
  1813. uint32_t offset = 0;
  1814. int8_t comb_rssi = 0;
  1815. /* Obtain required parameters for algorithm from search FFT report */
  1816. avgpwr_db = p_sfft_sec80->avgpwr_db;
  1817. total_gain_db = p_sfft_sec80->total_gain_info;
  1818. /* Calculate offset */
  1819. offset = target_if_get_offset_swar_sec80(
  1820. spectral->ch_width[SPECTRAL_SCAN_MODE_NORMAL]);
  1821. /* Calculate RSSI */
  1822. comb_rssi = ((avgpwr_db - total_gain_db) + offset);
  1823. return comb_rssi;
  1824. }
  1825. int
  1826. target_if_spectral_dump_tlv_gen2(
  1827. struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format)
  1828. {
  1829. int ret = 0;
  1830. /*
  1831. * TODO : Do not delete the following print
  1832. * The scripts used to validate Spectral depend on this Print
  1833. */
  1834. spectral_debug("SPECTRAL : TLV Length is 0x%x (%d)",
  1835. ptlv->length, ptlv->length);
  1836. switch (ptlv->tag) {
  1837. case TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2:
  1838. ret =
  1839. target_if_dump_summary_report_gen2(
  1840. ptlv, ptlv->length, is_160_format);
  1841. break;
  1842. case TLV_TAG_SEARCH_FFT_REPORT_GEN2:
  1843. ret =
  1844. target_if_dump_sfft_report_gen2(ptlv, ptlv->length,
  1845. is_160_format);
  1846. break;
  1847. case TLV_TAG_ADC_REPORT_GEN2:
  1848. ret = target_if_dump_adc_report_gen2(ptlv, ptlv->length);
  1849. break;
  1850. default:
  1851. spectral_warn("INVALID TLV");
  1852. ret = -1;
  1853. break;
  1854. }
  1855. return ret;
  1856. }
  1857. int
  1858. target_if_spectral_dump_phyerr_data_gen2(uint8_t *data, uint32_t datalen,
  1859. bool is_160_format)
  1860. {
  1861. struct spectral_phyerr_tlv_gen2 *ptlv = NULL;
  1862. uint32_t bytes_processed = 0;
  1863. uint32_t bytes_remaining = datalen;
  1864. uint32_t curr_tlv_complete_size = 0;
  1865. if (datalen < sizeof(struct spectral_phyerr_tlv_gen2)) {
  1866. spectral_err("Total PHY error data length %u too short to contain any TLVs",
  1867. datalen);
  1868. return -EPERM;
  1869. }
  1870. while (bytes_processed < datalen) {
  1871. if (bytes_remaining < sizeof(struct spectral_phyerr_tlv_gen2)) {
  1872. spectral_err("Remaining PHY error data length %u too short to contain a TLV",
  1873. bytes_remaining);
  1874. return -EPERM;
  1875. }
  1876. ptlv = (struct spectral_phyerr_tlv_gen2 *)(data +
  1877. bytes_processed);
  1878. if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) {
  1879. spectral_err("Invalid signature 0x%x!",
  1880. ptlv->signature);
  1881. return -EPERM;
  1882. }
  1883. curr_tlv_complete_size =
  1884. sizeof(struct spectral_phyerr_tlv_gen2) +
  1885. ptlv->length;
  1886. if (curr_tlv_complete_size > bytes_remaining) {
  1887. spectral_err("TLV size %d greater than number of bytes remaining %d",
  1888. curr_tlv_complete_size, bytes_remaining);
  1889. return -EPERM;
  1890. }
  1891. if (target_if_spectral_dump_tlv_gen2(ptlv, is_160_format) == -1)
  1892. return -EPERM;
  1893. bytes_processed += curr_tlv_complete_size;
  1894. bytes_remaining = datalen - bytes_processed;
  1895. }
  1896. return 0;
  1897. }
  1898. QDF_STATUS
  1899. target_if_spectral_copy_fft_bins(struct target_if_spectral *spectral,
  1900. const void *src_fft_buf,
  1901. void *dest_fft_buf,
  1902. uint32_t fft_bin_count,
  1903. uint32_t *bytes_copied,
  1904. uint16_t pwr_format)
  1905. {
  1906. uint16_t idx, dword_idx, fft_bin_idx;
  1907. uint8_t num_bins_per_dword, hw_fft_bin_width_bits;
  1908. uint32_t num_dwords;
  1909. uint16_t fft_bin_val;
  1910. struct spectral_report_params *rparams;
  1911. const uint32_t *dword_ptr;
  1912. uint32_t dword;
  1913. uint8_t *fft_bin_buf;
  1914. *bytes_copied = 0;
  1915. if (!spectral) {
  1916. spectral_err("spectral lmac object is NULL");
  1917. return QDF_STATUS_E_NULL_VALUE;
  1918. }
  1919. if (!src_fft_buf) {
  1920. spectral_err("source fft bin buffer is NULL");
  1921. return QDF_STATUS_E_NULL_VALUE;
  1922. }
  1923. if (!dest_fft_buf) {
  1924. spectral_err("destination fft bin buffer is NULL");
  1925. return QDF_STATUS_E_NULL_VALUE;
  1926. }
  1927. rparams = &spectral->rparams;
  1928. num_bins_per_dword = SPECTRAL_DWORD_SIZE / rparams->hw_fft_bin_width;
  1929. num_dwords = fft_bin_count / num_bins_per_dword;
  1930. hw_fft_bin_width_bits = rparams->hw_fft_bin_width * QDF_CHAR_BIT;
  1931. fft_bin_idx = 0;
  1932. dword_ptr = src_fft_buf;
  1933. fft_bin_buf = dest_fft_buf;
  1934. for (dword_idx = 0; dword_idx < num_dwords; dword_idx++) {
  1935. dword = *dword_ptr++; /* Read a DWORD */
  1936. for (idx = 0; idx < num_bins_per_dword; idx++) {
  1937. /**
  1938. * If we use QDF_GET_BITS, when hw_fft_bin_width_bits is
  1939. * 32, on certain platforms, we could end up doing a
  1940. * 32-bit left shift operation on 32-bit constant
  1941. * integer '1'. As per C standard, result of shifting an
  1942. * operand by a count greater than or equal to width
  1943. * (in bits) of the operand is undefined.
  1944. * If we use QDF_GET_BITS_64, we can avoid that.
  1945. */
  1946. fft_bin_val = (uint16_t)QDF_GET_BITS64(
  1947. dword,
  1948. idx * hw_fft_bin_width_bits,
  1949. hw_fft_bin_width_bits);
  1950. fft_bin_buf[fft_bin_idx++] =
  1951. clamp_fft_bin_value(fft_bin_val, pwr_format);
  1952. }
  1953. }
  1954. *bytes_copied = num_dwords * SPECTRAL_DWORD_SIZE;
  1955. return QDF_STATUS_SUCCESS;
  1956. }
  1957. #ifdef DIRECT_BUF_RX_ENABLE
  1958. /**
  1959. * target_if_get_spectral_mode() - Get Spectral scan mode corresponding to a
  1960. * detector id
  1961. * @detector_id: detector id in the Spectral report
  1962. * @rparams: pointer to report params object
  1963. *
  1964. * Helper API to get Spectral scan mode from the detector ID. This mapping is
  1965. * target specific.
  1966. *
  1967. * Return: Spectral scan mode
  1968. */
  1969. static enum spectral_scan_mode
  1970. target_if_get_spectral_mode(enum spectral_detector_id detector_id,
  1971. struct spectral_report_params *rparams)
  1972. {
  1973. if (detector_id >= SPECTRAL_DETECTOR_ID_MAX) {
  1974. spectral_err_rl("Invalid detector id %d", detector_id);
  1975. return SPECTRAL_SCAN_MODE_INVALID;
  1976. }
  1977. return rparams->detid_mode_table[detector_id];
  1978. }
  1979. /**
  1980. * target_if_spectral_get_bin_count_after_len_adj() - Get number of FFT bins in
  1981. * Spectral FFT report
  1982. * @fft_bin_len: FFT bin length reported by target
  1983. * @rpt_mode: Spectral report mode
  1984. * @swar: Spectral FFT bin length adjustments SWAR parameters
  1985. * @fft_bin_size: Size of one FFT bin in bytes
  1986. *
  1987. * Get actual number of FFT bins in the FFT report after adjusting the length
  1988. * by applying the SWARs for getting correct length.
  1989. *
  1990. * Return: FFT bin count
  1991. */
  1992. static size_t
  1993. target_if_spectral_get_bin_count_after_len_adj(
  1994. size_t fft_bin_len, uint8_t rpt_mode,
  1995. struct spectral_fft_bin_len_adj_swar *swar,
  1996. size_t *fft_bin_size)
  1997. {
  1998. size_t fft_bin_count = fft_bin_len;
  1999. if (rpt_mode == 1 && swar->null_fftbin_adj) {
  2000. /*
  2001. * No FFT bins are expected. Explicitly set FFT bin
  2002. * count to 0.
  2003. */
  2004. fft_bin_count = 0;
  2005. *fft_bin_size = 0;
  2006. } else {
  2007. /*
  2008. * Divide fft bin length by appropriate factor depending
  2009. * on the value of fftbin_size_war.
  2010. */
  2011. switch (swar->fftbin_size_war) {
  2012. case SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE:
  2013. fft_bin_count >>= 2;
  2014. *fft_bin_size = 4;
  2015. break;
  2016. case SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE:
  2017. fft_bin_count >>= 1;
  2018. *fft_bin_size = 2;
  2019. /* Ideally we should be dividing fft bin length
  2020. * by 2. Due to a HW bug, actual length is two
  2021. * times the expected length.
  2022. */
  2023. if (swar->packmode_fftbin_size_adj)
  2024. fft_bin_count >>= 1;
  2025. break;
  2026. case SPECTRAL_FFTBIN_SIZE_NO_WAR:
  2027. *fft_bin_size = 1;
  2028. /* No length adjustment */
  2029. break;
  2030. default:
  2031. return 0;
  2032. }
  2033. if (rpt_mode == 2 && swar->inband_fftbin_size_adj)
  2034. fft_bin_count >>= 1;
  2035. }
  2036. return fft_bin_count;
  2037. }
  2038. #ifndef OPTIMIZED_SAMP_MESSAGE
  2039. /**
  2040. * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3
  2041. * @p_fft_report: Pointer to fft report
  2042. * @p_sfft: Pointer to search fft report
  2043. * @rparams: pointer to report params object
  2044. *
  2045. * Process Search FFT Report for gen3
  2046. *
  2047. * Return: Success/Failure
  2048. */
  2049. static int
  2050. target_if_process_sfft_report_gen3(
  2051. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  2052. struct spectral_search_fft_info_gen3 *p_sfft,
  2053. struct spectral_report_params *rparams)
  2054. {
  2055. int32_t peak_sidx = 0;
  2056. int32_t peak_mag;
  2057. if (!p_fft_report || !p_sfft || !rparams) {
  2058. spectral_err("null params: p_fft_report %pK p_sfft %pK rparams %pK",
  2059. p_fft_report, p_sfft, rparams);
  2060. return 1;
  2061. }
  2062. /*
  2063. * For simplicity, everything is defined as uint32_t (except one).
  2064. * Proper code will later use the right sizes.
  2065. */
  2066. /*
  2067. * For easy comparison between MDK team and OS team, the MDK script
  2068. * variable names have been used
  2069. */
  2070. /* Populate the Search FFT Info */
  2071. p_sfft->timestamp = p_fft_report->fft_timestamp;
  2072. p_sfft->fft_detector_id = get_bitfield(p_fft_report->hdr_a,
  2073. 2, 0);
  2074. p_sfft->fft_num = get_bitfield(p_fft_report->hdr_a, 3, 2);
  2075. switch (rparams->version) {
  2076. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  2077. p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a,
  2078. 12, 5);
  2079. peak_sidx = get_bitfield(p_fft_report->hdr_a, 11, 17);
  2080. p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_a, 3, 28);
  2081. p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b,
  2082. 9, 0);
  2083. p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b,
  2084. 8, 9);
  2085. break;
  2086. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  2087. p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a,
  2088. 14, 5);
  2089. peak_sidx = get_bitfield(p_fft_report->hdr_a, 11, 19);
  2090. p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_b, 3, 0);
  2091. p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b,
  2092. 9, 3);
  2093. p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b,
  2094. 8, 12);
  2095. break;
  2096. default:
  2097. spectral_err_rl("Invalid spectral report format: %d",
  2098. rparams->version);
  2099. return 1;
  2100. }
  2101. p_sfft->fft_peak_sidx = unsigned_to_signed(peak_sidx, 11);
  2102. p_sfft->fft_num_str_bins_ib = get_bitfield(p_fft_report->hdr_c,
  2103. 8, 0);
  2104. peak_mag = get_bitfield(p_fft_report->hdr_c, 10, 8);
  2105. p_sfft->fft_peak_mag = unsigned_to_signed(peak_mag, 10);
  2106. p_sfft->fft_avgpwr_db = get_bitfield(p_fft_report->hdr_c,
  2107. 7, 18);
  2108. p_sfft->fft_relpwr_db = get_bitfield(p_fft_report->hdr_c,
  2109. 7, 25);
  2110. return 0;
  2111. }
  2112. #endif
  2113. /**
  2114. * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3
  2115. * @spectral: Pointer to Spectral object
  2116. * @smode: Spectral scan mode
  2117. * @p_fft_report: Pointer to fft report
  2118. * @p_sfft: Pointer to search fft report
  2119. *
  2120. * Dump FFT Report for gen3
  2121. *
  2122. * Return: void
  2123. */
  2124. static void
  2125. target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
  2126. enum spectral_scan_mode smode,
  2127. struct spectral_phyerr_fft_report_gen3 *p_fft_report,
  2128. struct spectral_search_fft_info_gen3 *p_sfft)
  2129. {
  2130. size_t fft_hdr_length;
  2131. size_t report_len;
  2132. size_t fft_bin_len;
  2133. size_t fft_bin_count;
  2134. size_t fft_bin_size;
  2135. size_t fft_bin_len_inband_tfer = 0;
  2136. uint8_t tag, signature;
  2137. if (!spectral) {
  2138. spectral_err_rl("spectral pointer is null.");
  2139. return;
  2140. }
  2141. /* There won't be FFT report/bins in report mode 0, so return */
  2142. if (!spectral->params[smode].ss_rpt_mode)
  2143. return;
  2144. fft_hdr_length = get_bitfield(
  2145. p_fft_report->fft_hdr_lts,
  2146. SPECTRAL_REPORT_LTS_HDR_LENGTH_SIZE_GEN3,
  2147. SPECTRAL_REPORT_LTS_HDR_LENGTH_POS_GEN3) * 4;
  2148. tag = get_bitfield(p_fft_report->fft_hdr_lts,
  2149. SPECTRAL_REPORT_LTS_TAG_SIZE_GEN3,
  2150. SPECTRAL_REPORT_LTS_TAG_POS_GEN3);
  2151. signature = get_bitfield(p_fft_report->fft_hdr_lts,
  2152. SPECTRAL_REPORT_LTS_SIGNATURE_SIZE_GEN3,
  2153. SPECTRAL_REPORT_LTS_SIGNATURE_POS_GEN3);
  2154. report_len = (fft_hdr_length + 8);
  2155. fft_bin_len = fft_hdr_length - spectral->rparams.fft_report_hdr_len;
  2156. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  2157. fft_bin_len,
  2158. spectral->params[smode].ss_rpt_mode,
  2159. &spectral->len_adj_swar, &fft_bin_size);
  2160. if ((spectral->params[smode].ss_rpt_mode == 2) &&
  2161. spectral->len_adj_swar.inband_fftbin_size_adj)
  2162. fft_bin_len_inband_tfer = fft_bin_len >> 1;
  2163. spectral_debug("Spectral FFT Report");
  2164. spectral_debug("fft_timestamp = 0x%x", p_fft_report->fft_timestamp);
  2165. spectral_debug("fft_hdr_length = %zu(32 bit words)",
  2166. fft_hdr_length >> 2);
  2167. spectral_debug("fft_hdr_tag = 0x%x", tag);
  2168. spectral_debug("fft_hdr_sig = 0x%x", signature);
  2169. spectral_debug("Length field in search fft report is %zu(0x%zx) bytes",
  2170. fft_hdr_length, fft_hdr_length);
  2171. spectral_debug("Total length of search fft report is %zu(0x%zx) bytes",
  2172. report_len, report_len);
  2173. spectral_debug("Target reported fftbins in report is %zu(0x%zx)",
  2174. fft_bin_len, fft_bin_len);
  2175. if ((spectral->params[smode].ss_rpt_mode == 1) &&
  2176. spectral->len_adj_swar.null_fftbin_adj)
  2177. spectral_debug("WAR: Considering number of FFT bins as 0");
  2178. else if ((spectral->params[smode].ss_rpt_mode == 2) &&
  2179. spectral->len_adj_swar.inband_fftbin_size_adj) {
  2180. spectral_debug("FW fftbins actually transferred (in-band report mode) %zu(0x%zx)",
  2181. fft_bin_len_inband_tfer,
  2182. fft_bin_len_inband_tfer);
  2183. }
  2184. spectral_debug("Actual number of fftbins in report is %zu(0x%zx)",
  2185. fft_bin_count, fft_bin_count);
  2186. spectral_debug("fft_detector_id = %u", p_sfft->fft_detector_id);
  2187. spectral_debug("fft_num = %u", p_sfft->fft_num);
  2188. spectral_debug("fft_radar_check = %u", p_sfft->fft_radar_check);
  2189. spectral_debug("fft_peak_sidx = %d", p_sfft->fft_peak_sidx);
  2190. spectral_debug("fft_chn_idx = %u", p_sfft->fft_chn_idx);
  2191. spectral_debug("fft_base_pwr_db = %u", p_sfft->fft_base_pwr_db);
  2192. spectral_debug("fft_total_gain_db = %u", p_sfft->fft_total_gain_db);
  2193. spectral_debug("fft_num_str_bins_ib = %u", p_sfft->fft_num_str_bins_ib);
  2194. spectral_debug("fft_peak_mag = %d", p_sfft->fft_peak_mag);
  2195. spectral_debug("fft_avgpwr_db = %u", p_sfft->fft_avgpwr_db);
  2196. spectral_debug("fft_relpwr_db = %u", p_sfft->fft_relpwr_db);
  2197. if (fft_bin_count > 0) {
  2198. uint8_t *fft_bin_buf;
  2199. uint32_t bytes_copied;
  2200. QDF_STATUS status;
  2201. fft_bin_buf = qdf_mem_malloc(fft_bin_count);
  2202. if (!fft_bin_buf) {
  2203. spectral_err_rl("memory allocation failed");
  2204. return;
  2205. }
  2206. status = target_if_spectral_copy_fft_bins(
  2207. spectral, &p_fft_report->buf,
  2208. fft_bin_buf, fft_bin_count, &bytes_copied,
  2209. spectral->params[smode].ss_pwr_format);
  2210. if (QDF_IS_STATUS_ERROR(status)) {
  2211. spectral_err_rl("Unable to populate FFT bins");
  2212. qdf_mem_free(fft_bin_buf);
  2213. return;
  2214. }
  2215. spectral_debug("FFT bin buffer size = %zu", fft_bin_count);
  2216. spectral_debug("FFT bins:");
  2217. target_if_spectral_hexdump(fft_bin_buf, fft_bin_count);
  2218. qdf_mem_free(fft_bin_buf);
  2219. }
  2220. }
  2221. #endif
  2222. #ifdef OPTIMIZED_SAMP_MESSAGE
  2223. QDF_STATUS
  2224. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  2225. enum spectral_scan_mode smode,
  2226. uint8_t detector_id) {
  2227. QDF_STATUS status = QDF_STATUS_SUCCESS;
  2228. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  2229. spectral_err_rl("Invalid Spectral mode %d", smode);
  2230. return QDF_STATUS_E_INVAL;
  2231. }
  2232. if (!is_ch_width_160_or_80p80(spectral->report_info[smode].sscan_bw)) {
  2233. spectral_err_rl("Scan BW %d is not 160/80p80 for mode %d",
  2234. spectral->report_info[smode].sscan_bw, smode);
  2235. return QDF_STATUS_E_FAILURE;
  2236. }
  2237. switch (spectral->state_160mhz_delivery[smode]) {
  2238. case SPECTRAL_REPORT_WAIT_PRIMARY80:
  2239. if (detector_id == SPECTRAL_DETECTOR_ID_0)
  2240. spectral->state_160mhz_delivery[smode] =
  2241. SPECTRAL_REPORT_WAIT_SECONDARY80;
  2242. else {
  2243. status = QDF_STATUS_E_FAILURE;
  2244. spectral->diag_stats.spectral_vhtseg1id_mismatch++;
  2245. }
  2246. break;
  2247. case SPECTRAL_REPORT_WAIT_SECONDARY80:
  2248. if (detector_id == SPECTRAL_DETECTOR_ID_1)
  2249. spectral->state_160mhz_delivery[smode] =
  2250. SPECTRAL_REPORT_WAIT_PRIMARY80;
  2251. else {
  2252. spectral->state_160mhz_delivery[smode] =
  2253. SPECTRAL_REPORT_WAIT_PRIMARY80;
  2254. status = QDF_STATUS_E_FAILURE;
  2255. spectral->diag_stats.spectral_vhtseg2id_mismatch++;
  2256. }
  2257. break;
  2258. default:
  2259. break;
  2260. }
  2261. return status;
  2262. }
  2263. #else
  2264. QDF_STATUS
  2265. target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral,
  2266. enum spectral_scan_mode smode,
  2267. uint8_t detector_id) {
  2268. QDF_STATUS status = QDF_STATUS_SUCCESS;
  2269. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  2270. spectral_err_rl("Invalid Spectral mode %d", smode);
  2271. return QDF_STATUS_E_INVAL;
  2272. }
  2273. if (!is_ch_width_160_or_80p80(spectral->ch_width[smode])) {
  2274. spectral_err_rl("Scan BW %d is not 160/80p80 for mode %d",
  2275. spectral->ch_width[smode], smode);
  2276. return QDF_STATUS_E_FAILURE;
  2277. }
  2278. switch (spectral->state_160mhz_delivery[smode]) {
  2279. case SPECTRAL_REPORT_WAIT_PRIMARY80:
  2280. if (detector_id == SPECTRAL_DETECTOR_ID_0)
  2281. spectral->state_160mhz_delivery[smode] =
  2282. SPECTRAL_REPORT_RX_PRIMARY80;
  2283. else {
  2284. status = QDF_STATUS_E_FAILURE;
  2285. spectral->diag_stats.spectral_vhtseg1id_mismatch++;
  2286. }
  2287. break;
  2288. case SPECTRAL_REPORT_WAIT_SECONDARY80:
  2289. if (detector_id == SPECTRAL_DETECTOR_ID_1)
  2290. spectral->state_160mhz_delivery[smode] =
  2291. SPECTRAL_REPORT_RX_SECONDARY80;
  2292. else {
  2293. spectral->state_160mhz_delivery[smode] =
  2294. SPECTRAL_REPORT_WAIT_PRIMARY80;
  2295. status = QDF_STATUS_E_FAILURE;
  2296. spectral->diag_stats.spectral_vhtseg2id_mismatch++;
  2297. }
  2298. break;
  2299. case SPECTRAL_REPORT_RX_SECONDARY80:
  2300. /* We don't care about detector id in this state. */
  2301. reset_160mhz_delivery_state_machine(spectral, smode);
  2302. break;
  2303. case SPECTRAL_REPORT_RX_PRIMARY80:
  2304. /* We don't care about detector id in this state */
  2305. spectral->state_160mhz_delivery[smode] =
  2306. SPECTRAL_REPORT_WAIT_SECONDARY80;
  2307. break;
  2308. default:
  2309. break;
  2310. }
  2311. return status;
  2312. }
  2313. #endif /* OPTIMIZED_SAMP_MESSAGE */
  2314. #ifdef DIRECT_BUF_RX_ENABLE
  2315. /**
  2316. * target_if_get_detector_id_sscan_summary_report_gen3() - Get Spectral detector
  2317. * ID from Spectral summary report
  2318. * @data: Pointer to Spectral summary report
  2319. *
  2320. * Return: Detector ID
  2321. */
  2322. static uint8_t
  2323. target_if_get_detector_id_sscan_summary_report_gen3(uint8_t *data) {
  2324. struct spectral_sscan_summary_report_gen3 *psscan_summary_report;
  2325. uint8_t detector_id;
  2326. qdf_assert_always(data);
  2327. psscan_summary_report =
  2328. (struct spectral_sscan_summary_report_gen3 *)data;
  2329. detector_id = get_bitfield(
  2330. psscan_summary_report->hdr_a,
  2331. SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3,
  2332. SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_POS_GEN3);
  2333. return detector_id;
  2334. }
  2335. #ifndef OPTIMIZED_SAMP_MESSAGE
  2336. /**
  2337. * target_if_consume_sscan_summary_report_gen3() - Consume Spectral summary
  2338. * report
  2339. * @data: Pointer to Spectral summary report
  2340. * @fields: Pointer to structure to be populated with extracted fields
  2341. * @rparams: Pointer to structure with Spectral report params
  2342. *
  2343. * Consume Spectral summary report for gen3
  2344. *
  2345. * Return: void
  2346. */
  2347. static void
  2348. target_if_consume_sscan_summary_report_gen3(
  2349. uint8_t *data,
  2350. struct sscan_report_fields_gen3 *fields,
  2351. struct spectral_report_params *rparams) {
  2352. struct spectral_sscan_summary_report_gen3 *psscan_summary_report;
  2353. qdf_assert_always(data);
  2354. qdf_assert_always(fields);
  2355. qdf_assert_always(rparams);
  2356. psscan_summary_report =
  2357. (struct spectral_sscan_summary_report_gen3 *)data;
  2358. fields->sscan_agc_total_gain = get_bitfield(
  2359. psscan_summary_report->hdr_a,
  2360. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3,
  2361. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3);
  2362. fields->inband_pwr_db = get_bitfield(
  2363. psscan_summary_report->hdr_a,
  2364. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3,
  2365. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3);
  2366. fields->sscan_pri80 = get_bitfield(
  2367. psscan_summary_report->hdr_a,
  2368. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3,
  2369. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3);
  2370. switch (rparams->version) {
  2371. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  2372. fields->sscan_gainchange = get_bitfield(
  2373. psscan_summary_report->hdr_b,
  2374. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3_V1,
  2375. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3_V1);
  2376. break;
  2377. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  2378. fields->sscan_gainchange = get_bitfield(
  2379. psscan_summary_report->hdr_c,
  2380. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_SIZE_GEN3_V2,
  2381. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_POS_GEN3_V2);
  2382. break;
  2383. default:
  2384. qdf_assert_always(0);
  2385. }
  2386. }
  2387. #endif
  2388. /**
  2389. * target_if_verify_sig_and_tag_gen3() - Verify tag and signature
  2390. * of spectral report
  2391. * @spectral: Pointer to spectral object
  2392. * @data: Pointer to spectral summary report
  2393. * @exp_tag: iexpected tag value
  2394. *
  2395. * Process fft report for gen3
  2396. *
  2397. * Return: SUCCESS/FAILURE
  2398. */
  2399. static int
  2400. target_if_verify_sig_and_tag_gen3(struct target_if_spectral *spectral,
  2401. uint8_t *data, uint8_t exp_tag)
  2402. {
  2403. uint8_t tag = 0;
  2404. uint8_t signature = 0;
  2405. uint32_t lts;
  2406. lts = *((uint32_t *)(data + SPECTRAL_PHYERR_HDR_LTS_POS));
  2407. /* Peek into the data to figure out whether
  2408. * 1) Signature matches the expected value
  2409. * 2) What is inside the package (TAG ID is used for finding this)
  2410. */
  2411. tag = get_bitfield(lts,
  2412. SPECTRAL_REPORT_LTS_TAG_SIZE_GEN3,
  2413. SPECTRAL_REPORT_LTS_TAG_POS_GEN3);
  2414. signature = get_bitfield(lts,
  2415. SPECTRAL_REPORT_LTS_SIGNATURE_SIZE_GEN3,
  2416. SPECTRAL_REPORT_LTS_SIGNATURE_POS_GEN3);
  2417. if (signature != SPECTRAL_PHYERR_SIGNATURE_GEN3) {
  2418. spectral->diag_stats.spectral_mismatch++;
  2419. return -EINVAL;
  2420. }
  2421. if (tag != exp_tag) {
  2422. spectral->diag_stats.spectral_mismatch++;
  2423. return -EINVAL;
  2424. }
  2425. return 0;
  2426. }
  2427. static uint8_t
  2428. target_if_spectral_get_lowest_chn_idx(uint8_t chainmask)
  2429. {
  2430. uint8_t idx;
  2431. for (idx = 0; idx < DBR_MAX_CHAINS; idx++) {
  2432. if (chainmask & 0x1)
  2433. break;
  2434. chainmask >>= 1;
  2435. }
  2436. return idx;
  2437. }
  2438. #ifdef DIRECT_BUF_RX_DEBUG
  2439. static void target_if_spectral_check_buffer_poisoning(
  2440. struct target_if_spectral *spectral,
  2441. struct spectral_report *report,
  2442. int num_fft_bins, enum spectral_scan_mode smode)
  2443. {
  2444. uint32_t *data;
  2445. size_t len;
  2446. size_t words_to_check =
  2447. sizeof(struct spectral_sscan_summary_report_gen3) >> 2;
  2448. bool poisoned_words_found = false;
  2449. if (!spectral) {
  2450. spectral_err_rl("Spectral LMAC object is null");
  2451. return;
  2452. }
  2453. if (!spectral->dbr_buff_debug)
  2454. return;
  2455. if (!report) {
  2456. spectral_err_rl("Spectral report is null");
  2457. return;
  2458. }
  2459. /* Add search FFT report */
  2460. if (spectral->params[smode].ss_rpt_mode > 0)
  2461. words_to_check +=
  2462. sizeof(struct spectral_phyerr_fft_report_gen3) >> 2;
  2463. /* Now add the number of FFT bins */
  2464. if (spectral->params[smode].ss_rpt_mode > 1) {
  2465. /* Caller should take care to pass correct number of FFT bins */
  2466. if (spectral->len_adj_swar.fftbin_size_war ==
  2467. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE)
  2468. words_to_check += num_fft_bins;
  2469. else if (spectral->len_adj_swar.fftbin_size_war ==
  2470. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE)
  2471. words_to_check += (num_fft_bins >> 1);
  2472. }
  2473. data = (uint32_t *)report->data;
  2474. for (len = 0; len < words_to_check; ++len) {
  2475. if (*data == MEM_POISON_SIGNATURE) {
  2476. spectral_err("Pattern(%x) found in Spectral search FFT report at position %zu in the buffer %pK",
  2477. MEM_POISON_SIGNATURE,
  2478. (len << 2), report->data);
  2479. poisoned_words_found = true;
  2480. break;
  2481. }
  2482. ++data;
  2483. }
  2484. /* Crash the FW even if one word is poisoned */
  2485. if (poisoned_words_found) {
  2486. spectral_err("Pattern(%x) found in Spectral report, Hex dump of the sfft follows",
  2487. MEM_POISON_SIGNATURE);
  2488. target_if_spectral_hexdump((unsigned char *)report->data,
  2489. words_to_check << 2);
  2490. spectral_err("Asserting the FW");
  2491. target_if_spectral_fw_hang(spectral);
  2492. }
  2493. }
  2494. #ifdef OPTIMIZED_SAMP_MESSAGE
  2495. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  2496. uint8_t *buf, uint32_t current_ts,
  2497. uint8_t detector_id)
  2498. {
  2499. if (!spectral) {
  2500. spectral_err_rl("Spectral LMAC object is null");
  2501. return;
  2502. }
  2503. if (detector_id >= MAX_DETECTORS_PER_PDEV) {
  2504. spectral_err_rl("Spectral detector_id %d exceeds range",
  2505. detector_id);
  2506. return;
  2507. }
  2508. if (!spectral->dbr_buff_debug)
  2509. return;
  2510. if (spectral->prev_tstamp[detector_id]) {
  2511. if (current_ts == spectral->prev_tstamp[detector_id]) {
  2512. spectral_err("Spectral timestamp(%u) in the current buffer(%pK) is equal to the previous timestamp, same report DMAed twice? Asserting the FW",
  2513. current_ts, buf);
  2514. target_if_spectral_fw_hang(spectral);
  2515. }
  2516. }
  2517. spectral->prev_tstamp[detector_id] = current_ts;
  2518. }
  2519. #else
  2520. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  2521. uint8_t *buf, uint32_t current_ts)
  2522. {
  2523. if (!spectral) {
  2524. spectral_err_rl("Spectral LMAC object is null");
  2525. return;
  2526. }
  2527. if (!spectral->dbr_buff_debug)
  2528. return;
  2529. if (spectral->prev_tstamp) {
  2530. if (current_ts == spectral->prev_tstamp) {
  2531. spectral_err("Spectral timestamp(%u) in the current buffer(%pK) is equal to the previous timestamp, same report DMAed twice? Asserting the FW",
  2532. current_ts, buf);
  2533. target_if_spectral_fw_hang(spectral);
  2534. }
  2535. }
  2536. spectral->prev_tstamp = current_ts;
  2537. }
  2538. #endif /* OPTIMIZED_SAMP_MESSAGE */
  2539. #else
  2540. static void target_if_spectral_check_buffer_poisoning(
  2541. struct target_if_spectral *spectral,
  2542. struct spectral_report *report,
  2543. int num_fft_bins, enum spectral_scan_mode smode)
  2544. {
  2545. }
  2546. #ifdef OPTIMIZED_SAMP_MESSAGE
  2547. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  2548. uint8_t *buf, uint32_t current_ts,
  2549. uint8_t detector_id)
  2550. {
  2551. }
  2552. #else
  2553. static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
  2554. uint8_t *buf, uint32_t current_ts)
  2555. {
  2556. }
  2557. #endif /* OPTIMIZED_SAMP_MESSAGE */
  2558. #endif
  2559. /**
  2560. * target_if_spectral_get_adjusted_timestamp() - Adjust Spectral time
  2561. * stamp to account for reset in time stamp due to target reset
  2562. * @twar: Spectral time stamp WAR related information
  2563. * @raw_timestamp: Spectral time stamp reported by target
  2564. * @reset_delay: Reset delay at target
  2565. * @smode: Spectral scan mode
  2566. *
  2567. * Correct time stamp to account for reset in time stamp due to target reset
  2568. *
  2569. * Return: Adjusted time stamp
  2570. */
  2571. static uint32_t
  2572. target_if_spectral_get_adjusted_timestamp(struct spectral_timestamp_war *twar,
  2573. uint32_t raw_timestamp,
  2574. uint32_t reset_delay,
  2575. enum spectral_scan_mode smode) {
  2576. qdf_assert_always(smode < SPECTRAL_SCAN_MODE_MAX);
  2577. if (reset_delay) {
  2578. enum spectral_scan_mode m =
  2579. SPECTRAL_SCAN_MODE_NORMAL;
  2580. /* Adjust the offset for all the Spectral modes.
  2581. * Target will be sending the non zero reset delay for
  2582. * the first Spectral report after reset. This delay is
  2583. * common for all the Spectral modes.
  2584. */
  2585. for (; m < SPECTRAL_SCAN_MODE_MAX; m++)
  2586. twar->timestamp_war_offset[m] += (reset_delay +
  2587. twar->last_fft_timestamp[m]);
  2588. twar->target_reset_count++;
  2589. }
  2590. twar->last_fft_timestamp[smode] = raw_timestamp;
  2591. return raw_timestamp + twar->timestamp_war_offset[smode];
  2592. }
  2593. #ifdef BIG_ENDIAN_HOST
  2594. QDF_STATUS target_if_byte_swap_spectral_headers_gen3(
  2595. struct target_if_spectral *spectral,
  2596. void *data)
  2597. {
  2598. int i;
  2599. uint32_t *ptr32;
  2600. size_t words32;
  2601. if (!data || !spectral) {
  2602. spectral_err_rl("null params: data %pK, spectral %pK.",
  2603. data, spectral);
  2604. return QDF_STATUS_E_NULL_VALUE;
  2605. }
  2606. ptr32 = (uint32_t *)data;
  2607. /* Summary Report */
  2608. words32 = sizeof(struct spectral_sscan_summary_report_gen3) >> 2;
  2609. for (i = 0; i < words32; ++i) {
  2610. *ptr32 = qdf_le32_to_cpu(*ptr32);
  2611. ++ptr32;
  2612. }
  2613. /* No need to swap the padding bytes */
  2614. ptr32 += (spectral->rparams.ssummary_padding_bytes >> 2);
  2615. /* Search FFT Report */
  2616. words32 = sizeof(struct spectral_phyerr_fft_report_gen3) >> 2;
  2617. for (i = 0; i < words32; ++i) {
  2618. *ptr32 = qdf_le32_to_cpu(*ptr32);
  2619. ++ptr32;
  2620. }
  2621. return QDF_STATUS_SUCCESS;
  2622. }
  2623. QDF_STATUS target_if_byte_swap_spectral_fft_bins_gen3(
  2624. const struct spectral_report_params *rparams,
  2625. void *bin_pwr_data, size_t num_fftbins)
  2626. {
  2627. uint16_t dword_idx, num_dwords;
  2628. uint8_t num_bins_per_dword;
  2629. uint32_t *dword_ptr;
  2630. if (!bin_pwr_data || !rparams) {
  2631. spectral_err_rl("null params, bin_pwr_data %pK, rparams %pK.",
  2632. bin_pwr_data, rparams);
  2633. return QDF_STATUS_E_NULL_VALUE;
  2634. }
  2635. num_bins_per_dword = SPECTRAL_DWORD_SIZE / rparams->hw_fft_bin_width;
  2636. num_dwords = num_fftbins / num_bins_per_dword;
  2637. dword_ptr = (uint32_t *)bin_pwr_data;
  2638. for (dword_idx = 0; dword_idx < num_dwords; dword_idx++) {
  2639. /* Read a DWORD, byteswap it, and copy it back */
  2640. *dword_ptr = qdf_le32_to_cpu(*dword_ptr);
  2641. ++dword_ptr;
  2642. }
  2643. return QDF_STATUS_SUCCESS;
  2644. }
  2645. #endif /* BIG_ENDIAN_HOST */
  2646. #ifdef OPTIMIZED_SAMP_MESSAGE
  2647. /**
  2648. * target_if_consume_sscan_summary_report_gen3() - Consume Spectral summary
  2649. * report
  2650. * @data: Pointer to Spectral summary report
  2651. * @fields: Pointer to structure to be populated with extracted fields
  2652. * @spectral: Pointer to spectral object
  2653. *
  2654. * Consume Spectral summary report for gen3
  2655. *
  2656. * Return: Success/Failure
  2657. */
  2658. static QDF_STATUS
  2659. target_if_consume_sscan_summary_report_gen3(
  2660. uint8_t **data,
  2661. struct sscan_report_fields_gen3 *fields,
  2662. struct target_if_spectral *spectral)
  2663. {
  2664. struct spectral_sscan_summary_report_gen3 *psscan_summary_report;
  2665. struct spectral_sscan_summary_report_padding_gen3_v2 *padding;
  2666. bool scan_radio_blanking;
  2667. if (!data) {
  2668. spectral_err_rl("Summary report buffer is null");
  2669. return QDF_STATUS_E_NULL_VALUE;
  2670. }
  2671. if (!fields) {
  2672. spectral_err_rl("Invalid pointer to Summary report fields");
  2673. return QDF_STATUS_E_NULL_VALUE;
  2674. }
  2675. if (!spectral) {
  2676. spectral_err_rl("Spectral LMAC object is null");
  2677. return QDF_STATUS_E_NULL_VALUE;
  2678. }
  2679. /* Validate Spectral scan summary report */
  2680. if (target_if_verify_sig_and_tag_gen3(
  2681. spectral, *data,
  2682. TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3) != 0) {
  2683. spectral_err_rl("Wrong tag/sig in sscan summary");
  2684. return QDF_STATUS_E_FAILURE;
  2685. }
  2686. fields->sscan_detector_id =
  2687. target_if_get_detector_id_sscan_summary_report_gen3(*data);
  2688. if (fields->sscan_detector_id >=
  2689. spectral->rparams.num_spectral_detectors) {
  2690. spectral->diag_stats.spectral_invalid_detector_id++;
  2691. spectral_err_rl("Invalid detector id %u, expected is 0 to %u",
  2692. fields->sscan_detector_id,
  2693. spectral->rparams.num_spectral_detectors);
  2694. return QDF_STATUS_E_FAILURE;
  2695. }
  2696. psscan_summary_report =
  2697. (struct spectral_sscan_summary_report_gen3 *)*data;
  2698. fields->sscan_agc_total_gain = get_bitfield(
  2699. psscan_summary_report->hdr_a,
  2700. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3,
  2701. SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3);
  2702. fields->inband_pwr_db = get_bitfield(
  2703. psscan_summary_report->hdr_a,
  2704. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3,
  2705. SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3);
  2706. fields->sscan_pri80 = get_bitfield(
  2707. psscan_summary_report->hdr_a,
  2708. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3,
  2709. SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3);
  2710. switch (spectral->rparams.version) {
  2711. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  2712. fields->sscan_gainchange = get_bitfield(
  2713. psscan_summary_report->hdr_b,
  2714. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3_V1,
  2715. SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3_V1);
  2716. break;
  2717. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  2718. fields->sscan_gainchange = get_bitfield(
  2719. psscan_summary_report->hdr_c,
  2720. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_SIZE_GEN3_V2,
  2721. SSCAN_SUMMARY_REPORT_HDR_C_GAINCHANGE_POS_GEN3_V2);
  2722. break;
  2723. default:
  2724. spectral_err_rl("Invalid spectral version: %d.",
  2725. spectral->rparams.version);
  2726. return QDF_STATUS_E_INVAL;
  2727. }
  2728. /* Advance buf pointer to the search fft report */
  2729. *data += sizeof(struct spectral_sscan_summary_report_gen3);
  2730. if (!spectral->rparams.ssummary_padding_bytes)
  2731. return QDF_STATUS_SUCCESS;
  2732. scan_radio_blanking =
  2733. wlan_pdev_nif_feat_ext_cap_get(spectral->pdev_obj,
  2734. WLAN_PDEV_FEXT_SCAN_BLANKING_EN);
  2735. padding = (struct spectral_sscan_summary_report_padding_gen3_v2 *)*data;
  2736. if (scan_radio_blanking) {
  2737. uint32_t blanking_tag;
  2738. uint8_t blanking_tag_size;
  2739. uint8_t blanking_tag_pos;
  2740. blanking_tag_size =
  2741. SSCAN_SUMMARY_REPORT_PAD_HDR_A_BLANKING_SIZE_GEN3_V2;
  2742. blanking_tag_pos =
  2743. SSCAN_SUMMARY_REPORT_PAD_HDR_A_BLANKING_POS_GEN3_V2;
  2744. blanking_tag = get_bitfield(padding->hdr_a, blanking_tag_size,
  2745. blanking_tag_pos);
  2746. if (blanking_tag ==
  2747. SSCAN_SUMMARY_REPORT_PAD_HDR_A_BLANKING_TAG_GEN3_V2)
  2748. fields->blanking_status = 1;
  2749. else
  2750. fields->blanking_status = 0;
  2751. }
  2752. *data += sizeof(struct spectral_sscan_summary_report_padding_gen3_v2);
  2753. return QDF_STATUS_SUCCESS;
  2754. }
  2755. /**
  2756. * target_if_process_sfft_report_gen3() - Validate and Process Search
  2757. * FFT Report for gen3
  2758. * @data: Pointer to Spectral FFT report
  2759. * @p_sfft: Pointer to search fft report
  2760. * @spectral: Pointer to spectral object
  2761. * @sscan_detector_id: Spectral detector id extracted from Summary report
  2762. * @reset_delay: Time taken for warm reset in usec
  2763. *
  2764. * Validate and Process Search FFT Report for gen3
  2765. *
  2766. * Return: Success/Failure
  2767. */
  2768. static QDF_STATUS
  2769. target_if_process_sfft_report_gen3(
  2770. uint8_t *data,
  2771. struct spectral_search_fft_info_gen3 *p_sfft,
  2772. struct target_if_spectral *spectral,
  2773. enum spectral_detector_id sscan_detector_id,
  2774. uint32_t reset_delay)
  2775. {
  2776. struct spectral_phyerr_fft_report_gen3 *p_fft_report;
  2777. int32_t peak_sidx = 0;
  2778. int32_t peak_mag;
  2779. int fft_hdr_length = 0;
  2780. struct target_if_spectral_ops *p_sops;
  2781. enum spectral_scan_mode spectral_mode;
  2782. QDF_STATUS ret;
  2783. if (!data) {
  2784. spectral_err_rl("FFT report buffer is null");
  2785. return QDF_STATUS_E_NULL_VALUE;
  2786. }
  2787. if (!p_sfft) {
  2788. spectral_err_rl("Invalid pointer to Search FFT report info");
  2789. return QDF_STATUS_E_NULL_VALUE;
  2790. }
  2791. if (!spectral) {
  2792. spectral_err_rl("Spectral LMAC object is null");
  2793. return QDF_STATUS_E_NULL_VALUE;
  2794. }
  2795. /*
  2796. * For easy comparison between MDK team and OS team, the MDK script
  2797. * variable names have been used
  2798. */
  2799. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  2800. /* Validate Spectral search FFT report */
  2801. if (target_if_verify_sig_and_tag_gen3(
  2802. spectral, data, TLV_TAG_SEARCH_FFT_REPORT_GEN3) != 0) {
  2803. spectral_err_rl("Unexpected tag/sig in sfft, detid= %u",
  2804. sscan_detector_id);
  2805. return QDF_STATUS_E_FAILURE;
  2806. }
  2807. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  2808. fft_hdr_length = get_bitfield(
  2809. p_fft_report->fft_hdr_lts,
  2810. SPECTRAL_REPORT_LTS_HDR_LENGTH_SIZE_GEN3,
  2811. SPECTRAL_REPORT_LTS_HDR_LENGTH_POS_GEN3) * 4;
  2812. if (fft_hdr_length < 16) {
  2813. spectral_err("Wrong TLV length %u, detector id = %d",
  2814. fft_hdr_length, sscan_detector_id);
  2815. return QDF_STATUS_E_FAILURE;
  2816. }
  2817. p_sfft->fft_detector_id = get_bitfield(
  2818. p_fft_report->hdr_a,
  2819. FFT_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3,
  2820. FFT_REPORT_HDR_A_DETECTOR_ID_POS_GEN3);
  2821. /* It is expected to have same detector id for
  2822. * summary and fft report
  2823. */
  2824. if (sscan_detector_id != p_sfft->fft_detector_id) {
  2825. spectral_err_rl("Different detid in ssummary(%u) and sfft(%u)",
  2826. sscan_detector_id, p_sfft->fft_detector_id);
  2827. return QDF_STATUS_E_FAILURE;
  2828. }
  2829. if (p_sfft->fft_detector_id >
  2830. spectral->rparams.num_spectral_detectors) {
  2831. spectral->diag_stats.spectral_invalid_detector_id++;
  2832. spectral_err("Invalid detector id %u, expected is 0 to %u",
  2833. p_sfft->fft_detector_id,
  2834. spectral->rparams.num_spectral_detectors);
  2835. return QDF_STATUS_E_FAILURE;
  2836. }
  2837. spectral_mode = target_if_get_spectral_mode(p_sfft->fft_detector_id,
  2838. &spectral->rparams);
  2839. if (spectral_mode >= SPECTRAL_SCAN_MODE_MAX) {
  2840. spectral_err_rl("No valid Spectral mode for detector id %u",
  2841. p_sfft->fft_detector_id);
  2842. return QDF_STATUS_E_FAILURE;
  2843. }
  2844. /* Populate the Search FFT Info */
  2845. p_sfft->timestamp = p_fft_report->fft_timestamp;
  2846. p_sfft->last_raw_timestamp = spectral->timestamp_war.
  2847. last_fft_timestamp[spectral_mode];
  2848. p_sfft->adjusted_timestamp = target_if_spectral_get_adjusted_timestamp(
  2849. &spectral->timestamp_war,
  2850. p_sfft->timestamp,
  2851. reset_delay,
  2852. spectral_mode);
  2853. /* Timestamp verification */
  2854. target_if_spectral_verify_ts(spectral, data,
  2855. p_sfft->adjusted_timestamp,
  2856. p_sfft->fft_detector_id);
  2857. p_sfft->fft_num = get_bitfield(p_fft_report->hdr_a,
  2858. FFT_REPORT_HDR_A_FFT_NUM_SIZE_GEN3,
  2859. FFT_REPORT_HDR_A_FFT_NUM_POS_GEN3);
  2860. switch (spectral->rparams.version) {
  2861. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  2862. p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a,
  2863. FFT_REPORT_HDR_A_RADAR_CHECK_SIZE_GEN3_V1,
  2864. FFT_REPORT_HDR_A_RADAR_CHECK_POS_GEN3_V1);
  2865. peak_sidx = get_bitfield(
  2866. p_fft_report->hdr_a,
  2867. FFT_REPORT_HDR_A_PEAK_INDEX_SIZE_GEN3_V1,
  2868. FFT_REPORT_HDR_A_PEAK_INDEX_POS_GEN3_V1);
  2869. p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_a,
  2870. FFT_REPORT_HDR_A_CHAIN_INDEX_SIZE_GEN3_V1,
  2871. FFT_REPORT_HDR_A_CHAIN_INDEX_POS_GEN3_V1);
  2872. p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b,
  2873. FFT_REPORT_HDR_B_BASE_PWR_SIZE_GEN3_V1,
  2874. FFT_REPORT_HDR_B_BASE_PWR_POS_GEN3_V1);
  2875. p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b,
  2876. FFT_REPORT_HDR_B_TOTAL_GAIN_SIZE_GEN3_V1,
  2877. FFT_REPORT_HDR_B_TOTAL_GAIN_POS_GEN3_V1);
  2878. break;
  2879. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  2880. p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a,
  2881. FFT_REPORT_HDR_A_RADAR_CHECK_SIZE_GEN3_V2,
  2882. FFT_REPORT_HDR_A_RADAR_CHECK_POS_GEN3_V2);
  2883. peak_sidx = get_bitfield(
  2884. p_fft_report->hdr_a,
  2885. FFT_REPORT_HDR_A_PEAK_INDEX_SIZE_GEN3_V2,
  2886. FFT_REPORT_HDR_A_PEAK_INDEX_POS_GEN3_V2);
  2887. p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_b,
  2888. FFT_REPORT_HDR_B_CHAIN_INDEX_SIZE_GEN3_V2,
  2889. FFT_REPORT_HDR_B_CHAIN_INDEX_POS_GEN3_V2);
  2890. p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b,
  2891. FFT_REPORT_HDR_B_BASE_PWR_SIZE_GEN3_V2,
  2892. FFT_REPORT_HDR_B_BASE_PWR_POS_GEN3_V2);
  2893. p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b,
  2894. FFT_REPORT_HDR_B_TOTAL_GAIN_SIZE_GEN3_V2,
  2895. FFT_REPORT_HDR_B_TOTAL_GAIN_POS_GEN3_V2);
  2896. break;
  2897. default:
  2898. spectral_err_rl("Invalid spectral version: %d.",
  2899. spectral->rparams.version);
  2900. return QDF_STATUS_E_INVAL;
  2901. }
  2902. p_sfft->fft_peak_sidx = unsigned_to_signed(peak_sidx,
  2903. FFT_REPORT_HDR_A_PEAK_INDEX_SIZE_GEN3_V1);
  2904. p_sfft->fft_num_str_bins_ib = get_bitfield(p_fft_report->hdr_c,
  2905. FFT_REPORT_HDR_C_NUM_STRONG_BINS_SIZE_GEN3,
  2906. FFT_REPORT_HDR_C_NUM_STRONG_BINS_POS_GEN3);
  2907. peak_mag = get_bitfield(p_fft_report->hdr_c,
  2908. FFT_REPORT_HDR_C_PEAK_MAGNITUDE_SIZE_GEN3,
  2909. FFT_REPORT_HDR_C_PEAK_MAGNITUDE_POS_GEN3);
  2910. p_sfft->fft_peak_mag = unsigned_to_signed(peak_mag,
  2911. FFT_REPORT_HDR_C_PEAK_MAGNITUDE_SIZE_GEN3);
  2912. p_sfft->fft_avgpwr_db = get_bitfield(p_fft_report->hdr_c,
  2913. FFT_REPORT_HDR_C_AVG_PWR_SIZE_GEN3,
  2914. FFT_REPORT_HDR_C_AVG_PWR_POS_GEN3);
  2915. p_sfft->fft_relpwr_db = get_bitfield(p_fft_report->hdr_c,
  2916. FFT_REPORT_HDR_C_RELATIVE_PWR_SIZE_GEN3,
  2917. FFT_REPORT_HDR_C_RELATIVE_PWR_POS_GEN3);
  2918. p_sfft->fft_bin_count =
  2919. target_if_spectral_get_bin_count_after_len_adj(
  2920. fft_hdr_length - spectral->rparams.fft_report_hdr_len,
  2921. spectral->params[spectral_mode].ss_rpt_mode,
  2922. &spectral->len_adj_swar,
  2923. (size_t *)&p_sfft->fft_bin_size);
  2924. p_sfft->bin_pwr_data = (uint8_t *)p_fft_report + SPECTRAL_FFT_BINS_POS;
  2925. /* Apply byte-swap on the FFT bins.
  2926. * NOTE: Until this point, bytes of the FFT bins could be in
  2927. * reverse order on a big-endian machine. If the consumers
  2928. * of FFT bins expects bytes in the correct order,
  2929. * they should use them only after this point.
  2930. */
  2931. if (p_sops->byte_swap_fft_bins) {
  2932. ret = p_sops->byte_swap_fft_bins(&spectral->rparams,
  2933. &p_sfft->bin_pwr_data,
  2934. p_sfft->fft_bin_count);
  2935. if (QDF_IS_STATUS_ERROR(ret)) {
  2936. spectral_err_rl("Byte-swap on the FFT bins failed");
  2937. return QDF_STATUS_E_FAILURE;
  2938. }
  2939. }
  2940. return QDF_STATUS_SUCCESS;
  2941. }
  2942. /**
  2943. * target_if_spectral_populate_samp_params_gen3() - Populate the SAMP params
  2944. * for gen3. SAMP params are to be used for populating SAMP msg.
  2945. * @spectral: Pointer to spectral object
  2946. * @p_sfft: Fields extracted from FFT report
  2947. * @sscan_fields: Fields extracted from Summary report
  2948. * @report: Pointer to spectral report
  2949. * @params: Pointer to Spectral SAMP message fields to be populated
  2950. *
  2951. * Populate the SAMP params for gen3, which will be used to populate SAMP msg.
  2952. *
  2953. * Return: Success/Failure
  2954. */
  2955. static QDF_STATUS
  2956. target_if_spectral_populate_samp_params_gen3(
  2957. struct target_if_spectral *spectral,
  2958. struct spectral_search_fft_info_gen3 *p_sfft,
  2959. struct sscan_report_fields_gen3 *sscan_fields,
  2960. struct spectral_report *report,
  2961. struct target_if_samp_msg_params *params)
  2962. {
  2963. enum spectral_scan_mode spectral_mode;
  2964. uint8_t chn_idx_lowest_enabled;
  2965. struct wlan_objmgr_vdev *vdev;
  2966. uint8_t vdev_rxchainmask;
  2967. if (!p_sfft) {
  2968. spectral_err_rl("Invalid pointer to Search FFT report info");
  2969. return QDF_STATUS_E_NULL_VALUE;
  2970. }
  2971. if (!spectral) {
  2972. spectral_err_rl("Spectral LMAC object is null");
  2973. return QDF_STATUS_E_NULL_VALUE;
  2974. }
  2975. if (!sscan_fields) {
  2976. spectral_err_rl("Invalid pointer to Summary report fields");
  2977. return QDF_STATUS_E_NULL_VALUE;
  2978. }
  2979. if (!report) {
  2980. spectral_err_rl("Spectral report is null");
  2981. return QDF_STATUS_E_NULL_VALUE;
  2982. }
  2983. if (!params) {
  2984. spectral_err_rl("SAMP msg params structure is null");
  2985. return QDF_STATUS_E_NULL_VALUE;
  2986. }
  2987. /* RSSI is in 1/2 dBm steps, Convert it to dBm scale */
  2988. params->rssi = (sscan_fields->inband_pwr_db) >> 1;
  2989. params->hw_detector_id = p_sfft->fft_detector_id;
  2990. params->raw_timestamp = p_sfft->timestamp;
  2991. params->last_raw_timestamp = p_sfft->last_raw_timestamp;
  2992. params->timestamp = p_sfft->adjusted_timestamp;
  2993. params->reset_delay = report->reset_delay;
  2994. params->max_mag = p_sfft->fft_peak_mag;
  2995. spectral_mode = target_if_get_spectral_mode(params->hw_detector_id,
  2996. &spectral->rparams);
  2997. vdev = target_if_spectral_get_vdev(spectral, spectral_mode);
  2998. if (!vdev) {
  2999. spectral_debug("First vdev is NULL");
  3000. return QDF_STATUS_E_FAILURE;
  3001. }
  3002. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  3003. if (vdev_rxchainmask == 0) {
  3004. spectral_err("Vdev rxchainmask is zero.");
  3005. return QDF_STATUS_E_FAILURE;
  3006. }
  3007. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3008. chn_idx_lowest_enabled =
  3009. target_if_spectral_get_lowest_chn_idx(vdev_rxchainmask);
  3010. if (chn_idx_lowest_enabled >= DBR_MAX_CHAINS) {
  3011. spectral_err("Invalid chain index, detector id = %u",
  3012. params->hw_detector_id);
  3013. return QDF_STATUS_E_FAILURE;
  3014. }
  3015. params->noise_floor = report->noisefloor[chn_idx_lowest_enabled];
  3016. params->agc_total_gain = sscan_fields->sscan_agc_total_gain;
  3017. params->gainchange = sscan_fields->sscan_gainchange;
  3018. params->blanking_status = sscan_fields->blanking_status;
  3019. params->pri80ind = sscan_fields->sscan_pri80;
  3020. params->bin_pwr_data = p_sfft->bin_pwr_data;
  3021. return QDF_STATUS_SUCCESS;
  3022. }
  3023. int
  3024. target_if_consume_spectral_report_gen3(
  3025. struct target_if_spectral *spectral,
  3026. struct spectral_report *report)
  3027. {
  3028. /*
  3029. * XXX : The classifier do not use all the members of the SAMP
  3030. * message data format.
  3031. * The classifier only depends upon the following parameters
  3032. *
  3033. * 1. Frequency
  3034. * 2. Spectral RSSI
  3035. * 3. Bin Power Count
  3036. * 4. Bin Power values
  3037. * 5. Spectral Timestamp
  3038. * 6. MAC Address
  3039. *
  3040. * This function processes the Spectral summary and FFT reports
  3041. * and passes the processed information
  3042. * target_if_spectral_fill_samp_msg()
  3043. * to prepare fully formatted Spectral SAMP message
  3044. *
  3045. * XXX : Need to verify
  3046. * 1. Order of FFT bin values
  3047. *
  3048. */
  3049. struct target_if_samp_msg_params params = {0};
  3050. struct spectral_search_fft_info_gen3 search_fft_info;
  3051. struct spectral_search_fft_info_gen3 *p_sfft = &search_fft_info;
  3052. struct target_if_spectral_ops *p_sops;
  3053. struct spectral_phyerr_fft_report_gen3 *p_fft_report;
  3054. uint8_t *data;
  3055. struct sscan_report_fields_gen3 sscan_report_fields = {0};
  3056. QDF_STATUS ret;
  3057. enum spectral_scan_mode spectral_mode = SPECTRAL_SCAN_MODE_INVALID;
  3058. bool finite_scan = false;
  3059. int det = 0;
  3060. struct sscan_detector_list *det_list;
  3061. struct spectral_data_stats *spectral_dp_stats;
  3062. bool print_fail_msg = true;
  3063. if (!spectral) {
  3064. spectral_err_rl("Spectral LMAC object is null");
  3065. print_fail_msg = false;
  3066. goto fail;
  3067. }
  3068. qdf_spin_lock_bh(&spectral->spectral_lock);
  3069. spectral_dp_stats = &spectral->data_stats;
  3070. spectral_dp_stats->consume_spectral_calls++;
  3071. if (!report) {
  3072. spectral_err_rl("Spectral report is null");
  3073. print_fail_msg = false;
  3074. goto fail_unlock;
  3075. }
  3076. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3077. data = report->data;
  3078. /* Apply byte-swap on the headers */
  3079. if (p_sops->byte_swap_headers) {
  3080. ret = p_sops->byte_swap_headers(spectral, data);
  3081. if (QDF_IS_STATUS_ERROR(ret)) {
  3082. spectral_err_rl("Byte-swap on Spectral headers failed");
  3083. goto fail_unlock;
  3084. }
  3085. }
  3086. /* Validate and Process Spectral scan summary report */
  3087. ret = target_if_consume_sscan_summary_report_gen3(&data,
  3088. &sscan_report_fields,
  3089. spectral);
  3090. if (QDF_IS_STATUS_ERROR(ret)) {
  3091. spectral_err_rl("Failed to process Spectral summary report");
  3092. goto fail_unlock;
  3093. }
  3094. spectral_mode = target_if_get_spectral_mode(
  3095. sscan_report_fields.sscan_detector_id,
  3096. &spectral->rparams);
  3097. if (spectral_mode >= SPECTRAL_SCAN_MODE_MAX) {
  3098. spectral_err_rl("No valid Spectral mode for detector id %u",
  3099. sscan_report_fields.sscan_detector_id);
  3100. goto fail_unlock;
  3101. }
  3102. /* Drop the sample if Spectral is not active for the current mode */
  3103. if (!p_sops->is_spectral_active(spectral, spectral_mode)) {
  3104. spectral_info_rl("Spectral scan is not active");
  3105. print_fail_msg = false;
  3106. goto fail_unlock;
  3107. }
  3108. /* Validate and Process the search FFT report */
  3109. ret = target_if_process_sfft_report_gen3(
  3110. data, p_sfft,
  3111. spectral,
  3112. sscan_report_fields.sscan_detector_id,
  3113. report->reset_delay);
  3114. if (QDF_IS_STATUS_ERROR(ret)) {
  3115. spectral_err_rl("Failed to process search FFT report");
  3116. goto fail_unlock;
  3117. }
  3118. qdf_spin_lock_bh(&spectral->detector_list_lock);
  3119. det_list = &spectral->detector_list[spectral_mode]
  3120. [spectral->report_info[spectral_mode].sscan_bw];
  3121. for (det = 0; det < det_list->num_detectors; det++) {
  3122. if (p_sfft->fft_detector_id == det_list->detectors[det])
  3123. break;
  3124. if (det == det_list->num_detectors - 1) {
  3125. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  3126. spectral_info("Incorrect det id %d for given scan mode and channel width",
  3127. p_sfft->fft_detector_id);
  3128. print_fail_msg = false;
  3129. goto fail_unlock;
  3130. }
  3131. }
  3132. qdf_spin_unlock_bh(&spectral->detector_list_lock);
  3133. ret = target_if_update_session_info_from_report_ctx(
  3134. spectral,
  3135. p_sfft->fft_bin_size,
  3136. report->cfreq1, report->cfreq2,
  3137. spectral_mode);
  3138. if (QDF_IS_STATUS_ERROR(ret)) {
  3139. spectral_err_rl("Failed to update per-session info");
  3140. goto fail_unlock;
  3141. }
  3142. qdf_spin_lock_bh(&spectral->session_report_info_lock);
  3143. /* Check FFT report are in order for 160 MHz and 80p80 */
  3144. if (is_ch_width_160_or_80p80(
  3145. spectral->report_info[spectral_mode].sscan_bw) &&
  3146. spectral->rparams.fragmentation_160[spectral_mode]) {
  3147. ret = target_if_160mhz_delivery_state_change(
  3148. spectral, spectral_mode,
  3149. p_sfft->fft_detector_id);
  3150. if (ret != QDF_STATUS_SUCCESS) {
  3151. qdf_spin_unlock_bh(
  3152. &spectral->session_report_info_lock);
  3153. goto fail_unlock;
  3154. }
  3155. }
  3156. qdf_spin_unlock_bh(&spectral->session_report_info_lock);
  3157. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  3158. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  3159. target_if_dump_fft_report_gen3(spectral, spectral_mode,
  3160. p_fft_report, p_sfft);
  3161. target_if_spectral_check_buffer_poisoning(spectral, report,
  3162. p_sfft->fft_bin_count,
  3163. spectral_mode);
  3164. /* Populate SAMP params */
  3165. ret = target_if_spectral_populate_samp_params_gen3(
  3166. spectral, p_sfft,
  3167. &sscan_report_fields,
  3168. report, &params);
  3169. if (QDF_IS_STATUS_ERROR(ret)) {
  3170. spectral_err_rl("Failed to populate SAMP params");
  3171. goto fail_unlock;
  3172. }
  3173. /* Fill SAMP message */
  3174. ret = target_if_spectral_fill_samp_msg(spectral, &params);
  3175. if (QDF_IS_STATUS_ERROR(ret)) {
  3176. spectral_err_rl("Failed to fill the SAMP msg");
  3177. goto fail_unlock;
  3178. }
  3179. qdf_spin_unlock_bh(&spectral->spectral_lock);
  3180. ret = target_if_spectral_is_finite_scan(spectral, spectral_mode,
  3181. &finite_scan);
  3182. if (QDF_IS_STATUS_ERROR(ret)) {
  3183. spectral_err_rl("Failed to check scan is finite");
  3184. goto fail;
  3185. }
  3186. if (finite_scan) {
  3187. ret = target_if_spectral_finite_scan_update(spectral,
  3188. spectral_mode);
  3189. if (QDF_IS_STATUS_ERROR(ret)) {
  3190. spectral_err_rl("Failed to update scan count");
  3191. goto fail;
  3192. }
  3193. }
  3194. return 0;
  3195. fail_unlock:
  3196. qdf_spin_unlock_bh(&spectral->spectral_lock);
  3197. fail:
  3198. if (print_fail_msg)
  3199. spectral_err_rl("Error while processing Spectral report");
  3200. if (spectral_mode != SPECTRAL_SCAN_MODE_INVALID)
  3201. reset_160mhz_delivery_state_machine(spectral, spectral_mode);
  3202. return -EPERM;
  3203. }
  3204. #else
  3205. int
  3206. target_if_consume_spectral_report_gen3(
  3207. struct target_if_spectral *spectral,
  3208. struct spectral_report *report)
  3209. {
  3210. /*
  3211. * XXX : The classifier do not use all the members of the SAMP
  3212. * message data format.
  3213. * The classifier only depends upon the following parameters
  3214. *
  3215. * 1. Frequency (freq, msg->freq)
  3216. * 2. Spectral RSSI (spectral_rssi,
  3217. * msg->samp_data.spectral_rssi)
  3218. * 3. Bin Power Count (bin_pwr_count,
  3219. * msg->samp_data.bin_pwr_count)
  3220. * 4. Bin Power values (bin_pwr, msg->samp_data.bin_pwr[0]
  3221. * 5. Spectral Timestamp (spectral_tstamp,
  3222. * msg->samp_data.spectral_tstamp)
  3223. * 6. MAC Address (macaddr, msg->macaddr)
  3224. *
  3225. * This function prepares the params structure and populates it
  3226. * with
  3227. * relevant values, this is in turn passed to
  3228. * spectral_create_samp_msg()
  3229. * to prepare fully formatted Spectral SAMP message
  3230. *
  3231. * XXX : Need to verify
  3232. * 1. Order of FFT bin values
  3233. *
  3234. */
  3235. struct target_if_samp_msg_params params = {0};
  3236. struct spectral_search_fft_info_gen3 search_fft_info;
  3237. struct spectral_search_fft_info_gen3 *p_sfft = &search_fft_info;
  3238. int8_t chn_idx_lowest_enabled = 0;
  3239. int fft_hdr_length = 0;
  3240. int report_len = 0;
  3241. size_t fft_bin_count;
  3242. size_t fft_bin_size;
  3243. struct target_if_spectral_ops *p_sops =
  3244. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3245. struct spectral_phyerr_fft_report_gen3 *p_fft_report;
  3246. int8_t rssi;
  3247. uint8_t *data = report->data;
  3248. struct wlan_objmgr_vdev *vdev;
  3249. uint8_t vdev_rxchainmask;
  3250. struct sscan_report_fields_gen3 sscan_report_fields = {0};
  3251. enum spectral_detector_id detector_id;
  3252. QDF_STATUS ret;
  3253. enum spectral_scan_mode spectral_mode = SPECTRAL_SCAN_MODE_INVALID;
  3254. uint8_t *temp;
  3255. bool finite_scan = false;
  3256. /* Apply byte-swap on the headers */
  3257. if (p_sops->byte_swap_headers) {
  3258. ret = p_sops->byte_swap_headers(spectral, data);
  3259. if (QDF_IS_STATUS_ERROR(ret)) {
  3260. spectral_err_rl("Byte-swap on Spectral headers failed");
  3261. goto fail;
  3262. }
  3263. }
  3264. /* Process Spectral scan summary report */
  3265. if (target_if_verify_sig_and_tag_gen3(
  3266. spectral, data,
  3267. TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3) != 0) {
  3268. spectral_err_rl("Wrong tag/sig in sscan summary");
  3269. goto fail;
  3270. }
  3271. detector_id = target_if_get_detector_id_sscan_summary_report_gen3(data);
  3272. if (detector_id >= spectral->rparams.num_spectral_detectors) {
  3273. spectral->diag_stats.spectral_invalid_detector_id++;
  3274. spectral_err("Invalid detector id %u, expected is 0/1/2",
  3275. detector_id);
  3276. goto fail;
  3277. }
  3278. spectral_mode = target_if_get_spectral_mode(detector_id,
  3279. &spectral->rparams);
  3280. if (spectral_mode >= SPECTRAL_SCAN_MODE_MAX) {
  3281. spectral_err_rl("No valid Spectral mode for detector id %u",
  3282. detector_id);
  3283. goto fail;
  3284. }
  3285. /* Drop the sample if Spectral is not active for the current mode */
  3286. if (!p_sops->is_spectral_active(spectral, spectral_mode)) {
  3287. spectral_info_rl("Spectral scan is not active");
  3288. goto fail_no_print;
  3289. }
  3290. ret = target_if_spectral_is_finite_scan(spectral, spectral_mode,
  3291. &finite_scan);
  3292. if (QDF_IS_STATUS_ERROR(ret)) {
  3293. spectral_err_rl("Failed to check scan is finite");
  3294. goto fail;
  3295. }
  3296. if (finite_scan) {
  3297. ret = target_if_spectral_finite_scan_update(spectral,
  3298. spectral_mode);
  3299. if (QDF_IS_STATUS_ERROR(ret)) {
  3300. spectral_err_rl("Failed to update scan count");
  3301. goto fail;
  3302. }
  3303. }
  3304. target_if_consume_sscan_summary_report_gen3(data, &sscan_report_fields,
  3305. &spectral->rparams);
  3306. /* Advance buf pointer to the search fft report */
  3307. data += sizeof(struct spectral_sscan_summary_report_gen3);
  3308. data += spectral->rparams.ssummary_padding_bytes;
  3309. params.vhtop_ch_freq_seg1 = report->cfreq1;
  3310. params.vhtop_ch_freq_seg2 = report->cfreq2;
  3311. if (is_primaryseg_expected(spectral, spectral_mode)) {
  3312. /* RSSI is in 1/2 dBm steps, Convert it to dBm scale */
  3313. rssi = (sscan_report_fields.inband_pwr_db) >> 1;
  3314. params.agc_total_gain =
  3315. sscan_report_fields.sscan_agc_total_gain;
  3316. params.gainchange = sscan_report_fields.sscan_gainchange;
  3317. params.pri80ind = sscan_report_fields.sscan_pri80;
  3318. /* Process Spectral search FFT report */
  3319. if (target_if_verify_sig_and_tag_gen3(
  3320. spectral, data,
  3321. TLV_TAG_SEARCH_FFT_REPORT_GEN3) != 0) {
  3322. spectral_err_rl("Unexpected tag/sig in sfft, detid= %u",
  3323. detector_id);
  3324. goto fail;
  3325. }
  3326. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  3327. fft_hdr_length = get_bitfield(
  3328. p_fft_report->fft_hdr_lts,
  3329. SPECTRAL_REPORT_LTS_HDR_LENGTH_SIZE_GEN3,
  3330. SPECTRAL_REPORT_LTS_HDR_LENGTH_POS_GEN3) * 4;
  3331. if (fft_hdr_length < 16) {
  3332. spectral_err("Wrong TLV length %u, detector id = %d",
  3333. fft_hdr_length, detector_id);
  3334. goto fail;
  3335. }
  3336. report_len = (fft_hdr_length + 8);
  3337. target_if_process_sfft_report_gen3(p_fft_report, p_sfft,
  3338. &spectral->rparams);
  3339. /* It is expected to have same detector id for
  3340. * summary and fft report
  3341. */
  3342. if (detector_id != p_sfft->fft_detector_id) {
  3343. spectral_err_rl
  3344. ("Different detid in ssummary(%u) and sfft(%u)",
  3345. detector_id, p_sfft->fft_detector_id);
  3346. goto fail;
  3347. }
  3348. if (detector_id > spectral->rparams.num_spectral_detectors) {
  3349. spectral->diag_stats.spectral_invalid_detector_id++;
  3350. spectral_err("Invalid detector id %u, expected is 0/2",
  3351. detector_id);
  3352. goto fail;
  3353. }
  3354. params.smode = spectral_mode;
  3355. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  3356. fft_hdr_length - spectral->rparams.fft_report_hdr_len,
  3357. spectral->params[spectral_mode].ss_rpt_mode,
  3358. &spectral->len_adj_swar, &fft_bin_size);
  3359. params.last_raw_timestamp = spectral->timestamp_war.
  3360. last_fft_timestamp[spectral_mode];
  3361. params.reset_delay = report->reset_delay;
  3362. params.raw_timestamp = p_sfft->timestamp;
  3363. params.tstamp = target_if_spectral_get_adjusted_timestamp(
  3364. &spectral->timestamp_war,
  3365. p_sfft->timestamp, report->reset_delay,
  3366. spectral_mode);
  3367. params.timestamp_war_offset = spectral->timestamp_war.
  3368. timestamp_war_offset[spectral_mode];
  3369. params.target_reset_count = spectral->timestamp_war.
  3370. target_reset_count;
  3371. /* Take care of state transitions for 160 MHz and 80p80 */
  3372. if (is_ch_width_160_or_80p80(spectral->ch_width
  3373. [spectral_mode]) && spectral->rparams.
  3374. fragmentation_160[spectral_mode]) {
  3375. ret = target_if_160mhz_delivery_state_change(
  3376. spectral, spectral_mode,
  3377. detector_id);
  3378. if (ret != QDF_STATUS_SUCCESS)
  3379. goto fail;
  3380. }
  3381. params.rssi = rssi;
  3382. vdev = target_if_spectral_get_vdev(spectral, spectral_mode);
  3383. if (!vdev) {
  3384. spectral_debug("First vdev is NULL");
  3385. reset_160mhz_delivery_state_machine(
  3386. spectral, spectral_mode);
  3387. return -EPERM;
  3388. }
  3389. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  3390. if (vdev_rxchainmask == 0) {
  3391. spectral_err("Vdev rxchainmask is zero.");
  3392. goto fail;
  3393. }
  3394. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3395. chn_idx_lowest_enabled =
  3396. target_if_spectral_get_lowest_chn_idx(vdev_rxchainmask);
  3397. if (chn_idx_lowest_enabled >= DBR_MAX_CHAINS) {
  3398. spectral_err("Invalid chain index, detector id = %u",
  3399. detector_id);
  3400. goto fail;
  3401. }
  3402. params.max_mag = p_sfft->fft_peak_mag;
  3403. params.freq = p_sops->get_current_channel(spectral,
  3404. spectral_mode);
  3405. params.agile_freq1 = spectral->params[SPECTRAL_SCAN_MODE_AGILE].
  3406. ss_frequency.cfreq1;
  3407. params.agile_freq2 = spectral->params[SPECTRAL_SCAN_MODE_AGILE].
  3408. ss_frequency.cfreq2;
  3409. params.noise_floor =
  3410. report->noisefloor[chn_idx_lowest_enabled];
  3411. temp = (uint8_t *)p_fft_report + SPECTRAL_FFT_BINS_POS;
  3412. if (is_ch_width_160_or_80p80(spectral->ch_width
  3413. [spectral_mode]) && !spectral->rparams.
  3414. fragmentation_160[spectral_mode]) {
  3415. struct wlan_objmgr_psoc *psoc;
  3416. struct spectral_fft_bin_markers_160_165mhz *marker;
  3417. if (!spectral->pdev_obj) {
  3418. spectral_err("pdev is null");
  3419. goto fail;
  3420. }
  3421. psoc = wlan_pdev_get_psoc(spectral->pdev_obj);
  3422. if (!psoc) {
  3423. spectral_err("psoc is null");
  3424. goto fail;
  3425. }
  3426. params.agc_total_gain_sec80 =
  3427. sscan_report_fields.sscan_agc_total_gain;
  3428. params.gainchange_sec80 =
  3429. sscan_report_fields.sscan_gainchange;
  3430. params.raw_timestamp_sec80 = p_sfft->timestamp;
  3431. params.rssi_sec80 = rssi;
  3432. params.noise_floor_sec80 =
  3433. report->noisefloor[chn_idx_lowest_enabled];
  3434. params.max_mag_sec80 = p_sfft->fft_peak_mag;
  3435. params.datalen = fft_hdr_length * 2;
  3436. params.datalen_sec80 = fft_hdr_length * 2;
  3437. marker = &spectral->rparams.marker[spectral_mode];
  3438. if (!marker->is_valid) {
  3439. /* update stats */
  3440. goto fail_no_print;
  3441. }
  3442. params.bin_pwr_data = temp +
  3443. marker->start_pri80 * fft_bin_size;
  3444. params.pwr_count = marker->num_pri80;
  3445. params.bin_pwr_data_sec80 = temp +
  3446. marker->start_sec80 * fft_bin_size;
  3447. params.pwr_count_sec80 = marker->num_sec80;
  3448. if (spectral->ch_width[spectral_mode] ==
  3449. CH_WIDTH_80P80MHZ && wlan_psoc_nif_fw_ext_cap_get(
  3450. psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT)) {
  3451. params.bin_pwr_data_5mhz = temp +
  3452. marker->start_5mhz * fft_bin_size;
  3453. params.pwr_count_5mhz = marker->num_5mhz;
  3454. }
  3455. } else {
  3456. params.bin_pwr_data = temp;
  3457. params.pwr_count = fft_bin_count;
  3458. params.datalen = (fft_hdr_length * 4);
  3459. }
  3460. /* Apply byte-swap on the FFT bins.
  3461. * NOTE: Until this point, bytes of the FFT bins could be in
  3462. * reverse order on a big-endian machine. If the consumers
  3463. * of FFT bins expects bytes in the correct order,
  3464. * they should use them only after this point.
  3465. */
  3466. if (p_sops->byte_swap_fft_bins) {
  3467. ret = p_sops->byte_swap_fft_bins(
  3468. &spectral->rparams,
  3469. temp, fft_bin_count);
  3470. if (QDF_IS_STATUS_ERROR(ret)) {
  3471. spectral_err_rl("Byte-swap on the FFT bins failed");
  3472. goto fail;
  3473. }
  3474. }
  3475. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  3476. target_if_dump_fft_report_gen3(spectral, spectral_mode,
  3477. p_fft_report, p_sfft);
  3478. target_if_spectral_verify_ts(spectral, report->data,
  3479. params.tstamp);
  3480. } else if (is_secondaryseg_expected(spectral, spectral_mode)) {
  3481. /* RSSI is in 1/2 dBm steps, Convert it to dBm scale */
  3482. rssi = (sscan_report_fields.inband_pwr_db) >> 1;
  3483. params.agc_total_gain_sec80 =
  3484. sscan_report_fields.sscan_agc_total_gain;
  3485. params.gainchange_sec80 = sscan_report_fields.sscan_gainchange;
  3486. params.pri80ind_sec80 = sscan_report_fields.sscan_pri80;
  3487. /* Process Spectral search FFT report */
  3488. if (target_if_verify_sig_and_tag_gen3(
  3489. spectral, data,
  3490. TLV_TAG_SEARCH_FFT_REPORT_GEN3) != 0) {
  3491. spectral_err_rl("Unexpected tag/sig in sfft, detid= %u",
  3492. detector_id);
  3493. goto fail;
  3494. }
  3495. p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)data;
  3496. fft_hdr_length = get_bitfield(
  3497. p_fft_report->fft_hdr_lts,
  3498. SPECTRAL_REPORT_LTS_HDR_LENGTH_SIZE_GEN3,
  3499. SPECTRAL_REPORT_LTS_HDR_LENGTH_POS_GEN3) * 4;
  3500. if (fft_hdr_length < 16) {
  3501. spectral_err("Wrong TLV length %u, detector id = %u",
  3502. fft_hdr_length, detector_id);
  3503. goto fail;
  3504. }
  3505. report_len = (fft_hdr_length + 8);
  3506. target_if_process_sfft_report_gen3(p_fft_report, p_sfft,
  3507. &spectral->rparams);
  3508. /* It is expected to have same detector id for
  3509. * summary and fft report
  3510. */
  3511. if (detector_id != p_sfft->fft_detector_id) {
  3512. spectral_err_rl
  3513. ("Different detid in ssummary(%u) and sfft(%u)",
  3514. detector_id, p_sfft->fft_detector_id);
  3515. goto fail;
  3516. }
  3517. if (detector_id > spectral->rparams.num_spectral_detectors) {
  3518. spectral->diag_stats.spectral_invalid_detector_id++;
  3519. spectral_err("Invalid detector id %u, expected is 1",
  3520. detector_id);
  3521. goto fail;
  3522. }
  3523. params.smode = spectral_mode;
  3524. fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
  3525. fft_hdr_length - spectral->rparams.fft_report_hdr_len,
  3526. spectral->params[spectral_mode].ss_rpt_mode,
  3527. &spectral->len_adj_swar, &fft_bin_size);
  3528. params.raw_timestamp_sec80 = p_sfft->timestamp;
  3529. /* Take care of state transitions for 160 MHz and 80p80 */
  3530. if (is_ch_width_160_or_80p80(spectral->ch_width
  3531. [spectral_mode]) && spectral->rparams.
  3532. fragmentation_160[spectral_mode]) {
  3533. ret = target_if_160mhz_delivery_state_change(
  3534. spectral, spectral_mode,
  3535. detector_id);
  3536. if (ret != QDF_STATUS_SUCCESS)
  3537. goto fail;
  3538. }
  3539. params.rssi_sec80 = rssi;
  3540. vdev = target_if_spectral_get_vdev(spectral, spectral_mode);
  3541. if (!vdev) {
  3542. spectral_info("First vdev is NULL");
  3543. reset_160mhz_delivery_state_machine
  3544. (spectral, spectral_mode);
  3545. return -EPERM;
  3546. }
  3547. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  3548. if (vdev_rxchainmask == 0) {
  3549. spectral_err("Vdev rxchainmask is zero.");
  3550. goto fail;
  3551. }
  3552. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3553. chn_idx_lowest_enabled =
  3554. target_if_spectral_get_lowest_chn_idx(vdev_rxchainmask);
  3555. if (chn_idx_lowest_enabled >= DBR_MAX_CHAINS) {
  3556. spectral_err("Invalid chain index");
  3557. goto fail;
  3558. }
  3559. /* Need to change this as per FW team's inputs */
  3560. params.noise_floor_sec80 =
  3561. report->noisefloor[chn_idx_lowest_enabled];
  3562. params.max_mag_sec80 = p_sfft->fft_peak_mag;
  3563. /* params.max_index_sec80 = p_sfft->peak_inx; */
  3564. /* XXX Does this definition of datalen *still hold? */
  3565. params.datalen_sec80 = fft_hdr_length * 4;
  3566. params.pwr_count_sec80 = fft_bin_count;
  3567. params.bin_pwr_data_sec80 =
  3568. (uint8_t *)((uint8_t *)p_fft_report +
  3569. SPECTRAL_FFT_BINS_POS);
  3570. /* Apply byte-swap on the FFT bins.
  3571. * NOTE: Until this point, bytes of the FFT bins could be in
  3572. * reverse order on a big-endian machine. If the consumers
  3573. * of FFT bins expects bytes in the correct order,
  3574. * they should use them only after this point.
  3575. */
  3576. if (p_sops->byte_swap_fft_bins) {
  3577. ret = p_sops->byte_swap_fft_bins(
  3578. &spectral->rparams,
  3579. params.bin_pwr_data_sec80,
  3580. fft_bin_count);
  3581. if (QDF_IS_STATUS_ERROR(ret)) {
  3582. spectral_err_rl("Byte-swap on the FFT bins failed");
  3583. goto fail;
  3584. }
  3585. }
  3586. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4))
  3587. target_if_dump_fft_report_gen3(spectral, spectral_mode,
  3588. p_fft_report, p_sfft);
  3589. } else {
  3590. spectral_err("Spectral state machine in undefined state");
  3591. goto fail;
  3592. }
  3593. target_if_spectral_check_buffer_poisoning(spectral, report,
  3594. fft_bin_count, spectral_mode);
  3595. qdf_mem_copy(&params.classifier_params,
  3596. &spectral->classifier_params,
  3597. sizeof(struct spectral_classifier_params));
  3598. target_if_spectral_log_SAMP_param(&params);
  3599. target_if_spectral_create_samp_msg(spectral, &params);
  3600. return 0;
  3601. fail:
  3602. spectral_err_rl("Error while processing Spectral report");
  3603. fail_no_print:
  3604. if (spectral_mode != SPECTRAL_SCAN_MODE_INVALID)
  3605. reset_160mhz_delivery_state_machine(spectral, spectral_mode);
  3606. return -EPERM;
  3607. }
  3608. #endif /* OPTIMIZED_SAMP_MESSAGE */
  3609. int target_if_spectral_process_report_gen3(
  3610. struct wlan_objmgr_pdev *pdev,
  3611. void *buf)
  3612. {
  3613. int ret = 0;
  3614. struct direct_buf_rx_data *payload = buf;
  3615. struct target_if_spectral *spectral;
  3616. struct spectral_report report = {0};
  3617. int samp_msg_index;
  3618. struct spectral_data_stats *spectral_dp_stats;
  3619. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3620. if (!spectral) {
  3621. spectral_err("Spectral target object is null");
  3622. return -EINVAL;
  3623. }
  3624. spectral_dp_stats = &spectral->data_stats;
  3625. spectral_dp_stats->spectral_rx_events++;
  3626. report.data = payload->vaddr;
  3627. if (payload->meta_data_valid) {
  3628. qdf_mem_copy(report.noisefloor, payload->meta_data.noisefloor,
  3629. qdf_min(sizeof(report.noisefloor),
  3630. sizeof(payload->meta_data.noisefloor)));
  3631. report.reset_delay = payload->meta_data.reset_delay;
  3632. report.cfreq1 = payload->meta_data.cfreq1;
  3633. report.cfreq2 = payload->meta_data.cfreq2;
  3634. report.ch_width = payload->meta_data.ch_width;
  3635. }
  3636. if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4)) {
  3637. spectral_debug("Printing the spectral phyerr buffer for debug");
  3638. spectral_debug("Datalength of buffer = 0x%zx(%zd) bufptr = 0x%pK",
  3639. payload->dbr_len,
  3640. payload->dbr_len,
  3641. payload->vaddr);
  3642. target_if_spectral_hexdump((unsigned char *)payload->vaddr,
  3643. 1024);
  3644. }
  3645. samp_msg_index = spectral->spectral_sent_msg;
  3646. ret = target_if_consume_spectral_report_gen3(spectral, &report);
  3647. /* Reset debug level when SAMP msg is sent successfully or on error */
  3648. if ((spectral_debug_level & DEBUG_SPECTRAL4) &&
  3649. (ret != 0 || spectral->spectral_sent_msg == samp_msg_index + 1))
  3650. spectral_debug_level = DEBUG_SPECTRAL;
  3651. return ret;
  3652. }
  3653. #else
  3654. int target_if_spectral_process_report_gen3(
  3655. struct wlan_objmgr_pdev *pdev,
  3656. void *buf)
  3657. {
  3658. spectral_err("Direct dma support is not enabled");
  3659. return -EINVAL;
  3660. }
  3661. #endif
  3662. qdf_export_symbol(target_if_spectral_process_report_gen3);
  3663. /* END of spectral GEN III HW specific functions */
  3664. #endif /* WLAN_CONV_SPECTRAL_ENABLE */