target_if_spectral.c 154 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635
  1. /*
  2. * Copyright (c) 2011,2017-2020 The Linux Foundation. All rights reserved.
  3. *
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <wlan_tgt_def_config.h>
  20. #include <hif.h>
  21. #include <target_type.h>
  22. #include <hif_hw_version.h>
  23. #include <wmi_unified_api.h>
  24. #include <target_if_spectral.h>
  25. #include <wlan_lmac_if_def.h>
  26. #include <wlan_osif_priv.h>
  27. #include <init_deinit_lmac.h>
  28. #include <reg_services_public_struct.h>
  29. #include <target_if_spectral_sim.h>
  30. #include <target_if.h>
  31. #include <qdf_module.h>
  32. #include <wlan_reg_services_api.h>
  33. #include <wlan_dfs_ucfg_api.h>
  34. /**
  35. * @spectral_ops - Spectral function table, holds the Spectral functions that
  36. * depend on whether the architecture is Direct Attach or Offload. This is used
  37. * to populate the actual Spectral function table present in the Spectral
  38. * module.
  39. */
  40. struct target_if_spectral_ops spectral_ops;
  41. int spectral_debug_level = DEBUG_SPECTRAL;
  42. struct spectral_tgt_ops ops_tgt;
  43. static void target_if_spectral_get_firstvdev_pdev(struct wlan_objmgr_pdev *pdev,
  44. void *obj, void *arg)
  45. {
  46. struct wlan_objmgr_vdev *vdev = obj;
  47. struct wlan_objmgr_vdev **first_vdev = arg;
  48. if (!(*first_vdev))
  49. *first_vdev = vdev;
  50. }
  51. struct wlan_objmgr_vdev *
  52. target_if_spectral_get_vdev(struct target_if_spectral *spectral,
  53. enum spectral_scan_mode smode)
  54. {
  55. struct wlan_objmgr_pdev *pdev = NULL;
  56. struct wlan_objmgr_vdev *first_vdev = NULL;
  57. qdf_assert_always(spectral);
  58. pdev = spectral->pdev_obj;
  59. qdf_assert_always(pdev);
  60. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  61. spectral_err("Invalid Spectral mode %u", smode);
  62. return NULL;
  63. }
  64. if (spectral->vdev_id[smode] != WLAN_INVALID_VDEV_ID) {
  65. first_vdev = wlan_objmgr_get_vdev_by_id_from_pdev(
  66. pdev, spectral->vdev_id[smode],
  67. WLAN_SPECTRAL_ID);
  68. return first_vdev;
  69. }
  70. if (wlan_objmgr_pdev_try_get_ref(pdev, WLAN_SPECTRAL_ID) !=
  71. QDF_STATUS_SUCCESS) {
  72. spectral_err("Unable to get pdev reference.");
  73. return NULL;
  74. }
  75. wlan_objmgr_pdev_iterate_obj_list(pdev, WLAN_VDEV_OP,
  76. target_if_spectral_get_firstvdev_pdev,
  77. &first_vdev, 0, WLAN_SPECTRAL_ID);
  78. wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID);
  79. if (!first_vdev)
  80. return NULL;
  81. if (wlan_objmgr_vdev_try_get_ref(first_vdev, WLAN_SPECTRAL_ID) !=
  82. QDF_STATUS_SUCCESS)
  83. first_vdev = NULL;
  84. return first_vdev;
  85. }
  86. /**
  87. * target_if_send_vdev_spectral_configure_cmd() - Send WMI command to configure
  88. * spectral parameters
  89. * @spectral: Pointer to Spectral target_if internal private data
  90. * @smode: Spectral scan mode
  91. * @param: Pointer to spectral_config giving the Spectral configuration
  92. *
  93. * Return: QDF_STATUS_SUCCESS on success, negative error code on failure
  94. */
  95. static int
  96. target_if_send_vdev_spectral_configure_cmd(struct target_if_spectral *spectral,
  97. enum spectral_scan_mode smode,
  98. struct spectral_config *param)
  99. {
  100. struct vdev_spectral_configure_params sparam;
  101. struct wlan_objmgr_psoc *psoc;
  102. struct wlan_objmgr_pdev *pdev = NULL;
  103. struct wlan_objmgr_vdev *vdev = NULL;
  104. struct target_if_psoc_spectral *psoc_spectral;
  105. qdf_assert_always(spectral && param);
  106. pdev = spectral->pdev_obj;
  107. qdf_assert_always(pdev);
  108. psoc = wlan_pdev_get_psoc(pdev);
  109. if (!psoc) {
  110. spectral_err("psoc is null");
  111. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  112. }
  113. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  114. if (!psoc_spectral) {
  115. spectral_err("psoc spectral object is null");
  116. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  117. }
  118. vdev = target_if_spectral_get_vdev(spectral, smode);
  119. if (!vdev)
  120. return QDF_STATUS_E_NOENT;
  121. qdf_mem_zero(&sparam, sizeof(sparam));
  122. sparam.vdev_id = wlan_vdev_get_id(vdev);
  123. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  124. sparam.count = param->ss_count;
  125. sparam.period = param->ss_period;
  126. sparam.spectral_pri = param->ss_spectral_pri;
  127. sparam.fft_size = param->ss_fft_size;
  128. sparam.gc_enable = param->ss_gc_ena;
  129. sparam.restart_enable = param->ss_restart_ena;
  130. sparam.noise_floor_ref = param->ss_noise_floor_ref;
  131. sparam.init_delay = param->ss_init_delay;
  132. sparam.nb_tone_thr = param->ss_nb_tone_thr;
  133. sparam.str_bin_thr = param->ss_str_bin_thr;
  134. sparam.wb_rpt_mode = param->ss_wb_rpt_mode;
  135. sparam.rssi_rpt_mode = param->ss_rssi_rpt_mode;
  136. sparam.rssi_thr = param->ss_rssi_thr;
  137. sparam.pwr_format = param->ss_pwr_format;
  138. sparam.rpt_mode = param->ss_rpt_mode;
  139. sparam.bin_scale = param->ss_bin_scale;
  140. sparam.dbm_adj = param->ss_dbm_adj;
  141. sparam.chn_mask = param->ss_chn_mask;
  142. sparam.mode = smode;
  143. sparam.center_freq1 = param->ss_frequency.cfreq1;
  144. sparam.center_freq2 = param->ss_frequency.cfreq2;
  145. sparam.chan_width = spectral->ch_width[smode];
  146. return psoc_spectral->wmi_ops.wmi_spectral_configure_cmd_send(
  147. GET_WMI_HDL_FROM_PDEV(pdev), &sparam);
  148. }
  149. /**
  150. * target_if_send_vdev_spectral_enable_cmd() - Send WMI command to
  151. * enable/disable Spectral
  152. * @spectral: Pointer to Spectral target_if internal private data
  153. * @smode: Spectral scan mode
  154. * @is_spectral_active_valid: Flag to indicate if spectral activate (trigger) is
  155. * valid
  156. * @is_spectral_active: Value of spectral activate
  157. * @is_spectral_enabled_valid: Flag to indicate if spectral enable is valid
  158. * @is_spectral_enabled: Value of spectral enable
  159. *
  160. * Return: QDF_STATUS_SUCCESS on success, negative error code on failure
  161. */
  162. static int
  163. target_if_send_vdev_spectral_enable_cmd(struct target_if_spectral *spectral,
  164. enum spectral_scan_mode smode,
  165. uint8_t is_spectral_active_valid,
  166. uint8_t is_spectral_active,
  167. uint8_t is_spectral_enabled_valid,
  168. uint8_t is_spectral_enabled)
  169. {
  170. struct vdev_spectral_enable_params param;
  171. struct wlan_objmgr_psoc *psoc;
  172. struct wlan_objmgr_pdev *pdev = NULL;
  173. struct wlan_objmgr_vdev *vdev = NULL;
  174. struct target_if_psoc_spectral *psoc_spectral;
  175. qdf_assert_always(spectral);
  176. pdev = spectral->pdev_obj;
  177. qdf_assert_always(pdev);
  178. psoc = wlan_pdev_get_psoc(pdev);
  179. if (!psoc) {
  180. spectral_err("psoc is null");
  181. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  182. }
  183. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  184. if (!psoc_spectral) {
  185. spectral_err("psoc spectral object is null");
  186. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  187. }
  188. vdev = target_if_spectral_get_vdev(spectral, smode);
  189. if (!vdev)
  190. return QDF_STATUS_E_NOENT;
  191. qdf_mem_zero(&param, sizeof(param));
  192. param.vdev_id = wlan_vdev_get_id(vdev);
  193. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  194. param.active_valid = is_spectral_active_valid;
  195. param.enabled_valid = is_spectral_enabled_valid;
  196. param.active = is_spectral_active;
  197. param.enabled = is_spectral_enabled;
  198. param.mode = smode;
  199. return psoc_spectral->wmi_ops.wmi_spectral_enable_cmd_send(
  200. GET_WMI_HDL_FROM_PDEV(pdev), &param);
  201. }
  202. /**
  203. * target_if_spectral_info_init_defaults() - Helper function to load defaults
  204. * for Spectral information (parameters and state) into cache.
  205. * @spectral: Pointer to Spectral target_if internal private data
  206. * @smode: Spectral scan mode
  207. *
  208. * It is assumed that the caller has obtained the requisite lock if applicable.
  209. * Note that this is currently treated as a temporary function. Ideally, we
  210. * would like to get defaults from the firmware.
  211. *
  212. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  213. */
  214. static QDF_STATUS
  215. target_if_spectral_info_init_defaults(struct target_if_spectral *spectral,
  216. enum spectral_scan_mode smode)
  217. {
  218. struct target_if_spectral_param_state_info *info;
  219. struct wlan_objmgr_vdev *vdev = NULL;
  220. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  221. spectral_err("Invalid Spectral mode %u", smode);
  222. return QDF_STATUS_E_FAILURE;
  223. }
  224. info = &spectral->param_info[smode];
  225. /* State */
  226. info->osps_cache.osc_spectral_active = SPECTRAL_SCAN_ACTIVE_DEFAULT;
  227. info->osps_cache.osc_spectral_enabled = SPECTRAL_SCAN_ENABLE_DEFAULT;
  228. /* Parameters */
  229. info->osps_cache.osc_params.ss_count = SPECTRAL_SCAN_COUNT_DEFAULT;
  230. if (spectral->spectral_gen == SPECTRAL_GEN3)
  231. info->osps_cache.osc_params.ss_period =
  232. SPECTRAL_SCAN_PERIOD_GEN_III_DEFAULT;
  233. else
  234. info->osps_cache.osc_params.ss_period =
  235. SPECTRAL_SCAN_PERIOD_GEN_II_DEFAULT;
  236. info->osps_cache.osc_params.ss_spectral_pri =
  237. SPECTRAL_SCAN_PRIORITY_DEFAULT;
  238. info->osps_cache.osc_params.ss_fft_size =
  239. SPECTRAL_SCAN_FFT_SIZE_DEFAULT;
  240. info->osps_cache.osc_params.ss_gc_ena = SPECTRAL_SCAN_GC_ENA_DEFAULT;
  241. info->osps_cache.osc_params.ss_restart_ena =
  242. SPECTRAL_SCAN_RESTART_ENA_DEFAULT;
  243. info->osps_cache.osc_params.ss_noise_floor_ref =
  244. SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT;
  245. info->osps_cache.osc_params.ss_init_delay =
  246. SPECTRAL_SCAN_INIT_DELAY_DEFAULT;
  247. info->osps_cache.osc_params.ss_nb_tone_thr =
  248. SPECTRAL_SCAN_NB_TONE_THR_DEFAULT;
  249. info->osps_cache.osc_params.ss_str_bin_thr =
  250. SPECTRAL_SCAN_STR_BIN_THR_DEFAULT;
  251. info->osps_cache.osc_params.ss_wb_rpt_mode =
  252. SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT;
  253. info->osps_cache.osc_params.ss_rssi_rpt_mode =
  254. SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT;
  255. info->osps_cache.osc_params.ss_rssi_thr =
  256. SPECTRAL_SCAN_RSSI_THR_DEFAULT;
  257. info->osps_cache.osc_params.ss_pwr_format =
  258. SPECTRAL_SCAN_PWR_FORMAT_DEFAULT;
  259. info->osps_cache.osc_params.ss_rpt_mode =
  260. SPECTRAL_SCAN_RPT_MODE_DEFAULT;
  261. info->osps_cache.osc_params.ss_bin_scale =
  262. SPECTRAL_SCAN_BIN_SCALE_DEFAULT;
  263. info->osps_cache.osc_params.ss_dbm_adj = SPECTRAL_SCAN_DBM_ADJ_DEFAULT;
  264. vdev = target_if_spectral_get_vdev(spectral, smode);
  265. if (!vdev)
  266. return QDF_STATUS_E_NOENT;
  267. info->osps_cache.osc_params.ss_chn_mask =
  268. wlan_vdev_mlme_get_rxchainmask(vdev);
  269. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  270. info->osps_cache.osc_params.ss_short_report =
  271. SPECTRAL_SCAN_SHORT_REPORT_DEFAULT;
  272. info->osps_cache.osc_params.ss_fft_period =
  273. SPECTRAL_SCAN_FFT_PERIOD_DEFAULT;
  274. info->osps_cache.osc_params.ss_frequency.cfreq1 =
  275. SPECTRAL_SCAN_FREQUENCY_DEFAULT;
  276. info->osps_cache.osc_params.ss_frequency.cfreq2 =
  277. SPECTRAL_SCAN_FREQUENCY_DEFAULT;
  278. /* The cache is now valid */
  279. info->osps_cache.osc_is_valid = 1;
  280. return QDF_STATUS_SUCCESS;
  281. }
  282. /**
  283. * target_if_log_read_spectral_active() - Helper function to log whether
  284. * spectral is active after reading cache
  285. * @function_name: Function name
  286. * @output: whether spectral is active or not
  287. *
  288. * Helper function to log whether spectral is active after reading cache
  289. *
  290. * Return: none
  291. */
  292. static void
  293. target_if_log_read_spectral_active(
  294. const char *function_name,
  295. unsigned char output)
  296. {
  297. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE. Returning val=%u",
  298. function_name, output);
  299. }
  300. /**
  301. * target_if_log_read_spectral_enabled() - Helper function to log whether
  302. * spectral is enabled after reading cache
  303. * @function_name: Function name
  304. * @output: whether spectral is enabled or not
  305. *
  306. * Helper function to log whether spectral is enabled after reading cache
  307. *
  308. * Return: none
  309. */
  310. static void
  311. target_if_log_read_spectral_enabled(
  312. const char *function_name,
  313. unsigned char output)
  314. {
  315. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ENABLED. Returning val=%u",
  316. function_name, output);
  317. }
  318. /**
  319. * target_if_log_read_spectral_enabled() - Helper function to log spectral
  320. * parameters after reading cache
  321. * @function_name: Function name
  322. * @pparam: Spectral parameters
  323. *
  324. * Helper function to log spectral parameters after reading cache
  325. *
  326. * Return: none
  327. */
  328. static void
  329. target_if_log_read_spectral_params(
  330. const char *function_name,
  331. struct spectral_config *pparam)
  332. {
  333. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_PARAMS. Returning following params:\nss_count = %u\nss_period = %u\nss_spectral_pri = %u\nss_fft_size = %u\nss_gc_ena = %u\nss_restart_ena = %u\nss_noise_floor_ref = %d\nss_init_delay = %u\nss_nb_tone_thr = %u\nss_str_bin_thr = %u\nss_wb_rpt_mode = %u\nss_rssi_rpt_mode = %u\nss_rssi_thr = %d\nss_pwr_format = %u\nss_rpt_mode = %u\nss_bin_scale = %u\nss_dbm_adj = %u\nss_chn_mask = %u\nss_frequency1=%u\nss_frequency2=%u\n",
  334. function_name,
  335. pparam->ss_count,
  336. pparam->ss_period,
  337. pparam->ss_spectral_pri,
  338. pparam->ss_fft_size,
  339. pparam->ss_gc_ena,
  340. pparam->ss_restart_ena,
  341. (int8_t)pparam->ss_noise_floor_ref,
  342. pparam->ss_init_delay,
  343. pparam->ss_nb_tone_thr,
  344. pparam->ss_str_bin_thr,
  345. pparam->ss_wb_rpt_mode,
  346. pparam->ss_rssi_rpt_mode,
  347. (int8_t)pparam->ss_rssi_thr,
  348. pparam->ss_pwr_format,
  349. pparam->ss_rpt_mode,
  350. pparam->ss_bin_scale,
  351. pparam->ss_dbm_adj,
  352. pparam->ss_chn_mask,
  353. pparam->ss_frequency.cfreq1,
  354. pparam->ss_frequency.cfreq2);
  355. }
  356. /**
  357. * target_if_log_read_spectral_active_catch_validate() - Helper function to
  358. * log whether spectral is active after intializing the cache
  359. * @function_name: Function name
  360. * @output: whether spectral is active or not
  361. *
  362. * Helper function to log whether spectral is active after intializing cache
  363. *
  364. * Return: none
  365. */
  366. static void
  367. target_if_log_read_spectral_active_catch_validate(
  368. const char *function_name,
  369. unsigned char output)
  370. {
  371. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE on initial cache validation\nReturning val=%u",
  372. function_name, output);
  373. }
  374. /**
  375. * target_if_log_read_spectral_enabled_catch_validate() - Helper function to
  376. * log whether spectral is enabled after intializing the cache
  377. * @function_name: Function name
  378. * @output: whether spectral is enabled or not
  379. *
  380. * Helper function to log whether spectral is enabled after intializing cache
  381. *
  382. * Return: none
  383. */
  384. static void
  385. target_if_log_read_spectral_enabled_catch_validate(
  386. const char *function_name,
  387. unsigned char output)
  388. {
  389. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ENABLED on initial cache validation\nReturning val=%u\n",
  390. function_name, output);
  391. }
  392. /**
  393. * target_if_log_read_spectral_params_catch_validate() - Helper function to
  394. * log spectral parameters after intializing the cache
  395. * @function_name: Function name
  396. * @pparam: Spectral parameters
  397. *
  398. * Helper function to log spectral parameters after intializing the cache
  399. *
  400. * Return: none
  401. */
  402. static void
  403. target_if_log_read_spectral_params_catch_validate(
  404. const char *function_name,
  405. struct spectral_config *pparam)
  406. {
  407. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_PARAMS on initial cache validation\nReturning following params:\nss_count = %u\nss_period = %u\nss_spectral_pri = %u\nss_fft_size = %u\nss_gc_ena = %u\nss_restart_ena = %u\nss_noise_floor_ref = %d\nss_init_delay = %u\nss_nb_tone_thr = %u\nss_str_bin_thr = %u\nss_wb_rpt_mode = %u\nss_rssi_rpt_mode = %u\nss_rssi_thr = %d\nss_pwr_format = %u\nss_rpt_mode = %u\nss_bin_scale = %u\nss_dbm_adj = %u\nss_chn_mask = %u",
  408. function_name,
  409. pparam->ss_count,
  410. pparam->ss_period,
  411. pparam->ss_spectral_pri,
  412. pparam->ss_fft_size,
  413. pparam->ss_gc_ena,
  414. pparam->ss_restart_ena,
  415. (int8_t)pparam->ss_noise_floor_ref,
  416. pparam->ss_init_delay,
  417. pparam->ss_nb_tone_thr,
  418. pparam->ss_str_bin_thr,
  419. pparam->ss_wb_rpt_mode,
  420. pparam->ss_rssi_rpt_mode,
  421. (int8_t)pparam->ss_rssi_thr,
  422. pparam->ss_pwr_format,
  423. pparam->ss_rpt_mode,
  424. pparam->ss_bin_scale,
  425. pparam->ss_dbm_adj, pparam->ss_chn_mask);
  426. }
  427. /**
  428. * target_if_spectral_info_read() - Read spectral information from the cache.
  429. * @spectral: Pointer to Spectral target_if internal private data
  430. * @smode: Spectral scan mode
  431. * @specifier: target_if_spectral_info enumeration specifying which
  432. * information is required
  433. * @output: Void output pointer into which the information will be read
  434. * @output_len: size of object pointed to by output pointer
  435. *
  436. * Read spectral parameters or the desired state information from the cache.
  437. *
  438. * Return: 0 on success, negative error code on failure
  439. */
  440. static int
  441. target_if_spectral_info_read(
  442. struct target_if_spectral *spectral,
  443. enum spectral_scan_mode smode,
  444. enum target_if_spectral_info specifier,
  445. void *output, int output_len)
  446. {
  447. /*
  448. * Note: This function is designed to be able to accommodate
  449. * WMI reads for defaults, non-cacheable information, etc
  450. * if required.
  451. */
  452. struct target_if_spectral_param_state_info *info;
  453. int is_cacheable = 0;
  454. int init_def_retval = 0;
  455. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  456. spectral_err("Invalid Spectral mode %u", smode);
  457. return -EINVAL;
  458. }
  459. info = &spectral->param_info[smode];
  460. if (!output)
  461. return -EINVAL;
  462. switch (specifier) {
  463. case TARGET_IF_SPECTRAL_INFO_ACTIVE:
  464. if (output_len != sizeof(info->osps_cache.osc_spectral_active))
  465. return -EINVAL;
  466. is_cacheable = 1;
  467. break;
  468. case TARGET_IF_SPECTRAL_INFO_ENABLED:
  469. if (output_len != sizeof(info->osps_cache.osc_spectral_enabled))
  470. return -EINVAL;
  471. is_cacheable = 1;
  472. break;
  473. case TARGET_IF_SPECTRAL_INFO_PARAMS:
  474. if (output_len != sizeof(info->osps_cache.osc_params))
  475. return -EINVAL;
  476. is_cacheable = 1;
  477. break;
  478. default:
  479. spectral_err("Unknown target_if_spectral_info specifier");
  480. return -EINVAL;
  481. }
  482. qdf_spin_lock(&info->osps_lock);
  483. if (is_cacheable) {
  484. if (info->osps_cache.osc_is_valid) {
  485. switch (specifier) {
  486. case TARGET_IF_SPECTRAL_INFO_ACTIVE:
  487. qdf_mem_copy(
  488. output,
  489. &info->osps_cache.osc_spectral_active,
  490. sizeof(info->osps_cache.osc_spectral_active));
  491. target_if_log_read_spectral_active(
  492. __func__,
  493. *((unsigned char *)output));
  494. break;
  495. case TARGET_IF_SPECTRAL_INFO_ENABLED:
  496. qdf_mem_copy(
  497. output,
  498. &info->osps_cache.osc_spectral_enabled,
  499. sizeof(
  500. info->osps_cache.osc_spectral_enabled));
  501. target_if_log_read_spectral_enabled(
  502. __func__,
  503. *((unsigned char *)output));
  504. break;
  505. case TARGET_IF_SPECTRAL_INFO_PARAMS:
  506. qdf_mem_copy(
  507. output,
  508. &info->osps_cache.osc_params,
  509. sizeof(info->osps_cache.osc_params));
  510. target_if_log_read_spectral_params(
  511. __func__,
  512. (struct spectral_config *)output);
  513. break;
  514. default:
  515. /* We can't reach this point */
  516. break;
  517. }
  518. qdf_spin_unlock(&info->osps_lock);
  519. return 0;
  520. }
  521. }
  522. /* Cache is invalid */
  523. /*
  524. * If WMI Reads are implemented to fetch defaults/non-cacheable info,
  525. * then the below implementation will change
  526. */
  527. init_def_retval =
  528. target_if_spectral_info_init_defaults(spectral, smode);
  529. if (init_def_retval != QDF_STATUS_SUCCESS) {
  530. qdf_spin_unlock(&info->osps_lock);
  531. if (init_def_retval == QDF_STATUS_E_NOENT)
  532. return -ENOENT;
  533. else
  534. return -EINVAL;
  535. }
  536. /* target_if_spectral_info_init_defaults() has set cache to valid */
  537. switch (specifier) {
  538. case TARGET_IF_SPECTRAL_INFO_ACTIVE:
  539. qdf_mem_copy(output,
  540. &info->osps_cache.osc_spectral_active,
  541. sizeof(info->osps_cache.osc_spectral_active));
  542. target_if_log_read_spectral_active_catch_validate(
  543. __func__,
  544. *((unsigned char *)output));
  545. break;
  546. case TARGET_IF_SPECTRAL_INFO_ENABLED:
  547. qdf_mem_copy(output,
  548. &info->osps_cache.osc_spectral_enabled,
  549. sizeof(info->osps_cache.osc_spectral_enabled));
  550. target_if_log_read_spectral_enabled_catch_validate(
  551. __func__,
  552. *((unsigned char *)output));
  553. break;
  554. case TARGET_IF_SPECTRAL_INFO_PARAMS:
  555. qdf_mem_copy(output,
  556. &info->osps_cache.osc_params,
  557. sizeof(info->osps_cache.osc_params));
  558. target_if_log_read_spectral_params_catch_validate(
  559. __func__,
  560. (struct spectral_config *)output);
  561. break;
  562. default:
  563. /* We can't reach this point */
  564. break;
  565. }
  566. qdf_spin_unlock(&info->osps_lock);
  567. return 0;
  568. }
  569. /**
  570. * target_if_log_write_spectral_active() - Helper function to log inputs and
  571. * return value of call to configure the Spectral 'active' configuration,
  572. * TARGET_IF_SPECTRAL_INFO_ACTIVE into firmware
  573. * @function_name: Function name in which this is called
  574. * @pval: whether spectral is active or not
  575. * @ret: return value of the firmware write function
  576. *
  577. * Return: none
  578. */
  579. static void
  580. target_if_log_write_spectral_active(
  581. const char *function_name,
  582. uint8_t pval,
  583. int ret)
  584. {
  585. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE with val=%u status=%d",
  586. function_name, pval, ret);
  587. }
  588. /**
  589. * target_if_log_write_spectral_enabled() - Helper function to log inputs and
  590. * return value of call to configure the Spectral 'enabled' configuration,
  591. * TARGET_IF_SPECTRAL_INFO_ENABLED into firmware
  592. * @function_name: Function name in which this is called
  593. * @pval: whether spectral is enabled or not
  594. * @ret: return value of the firmware write function
  595. *
  596. * Return: none
  597. */
  598. static void
  599. target_if_log_write_spectral_enabled(
  600. const char *function_name,
  601. uint8_t pval,
  602. int ret)
  603. {
  604. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_ENABLED with val=%u status=%d",
  605. function_name, pval, ret);
  606. }
  607. /**
  608. * target_if_log_write_spectral_params() - Helper function to log inputs and
  609. * return value of call to configure Spectral parameters,
  610. * TARGET_IF_SPECTRAL_INFO_PARAMS into firmware
  611. * @param: Spectral parameters
  612. * @function_name: Function name in which this is called
  613. * @ret: return value of the firmware write function
  614. *
  615. * Return: none
  616. */
  617. static void
  618. target_if_log_write_spectral_params(
  619. struct spectral_config *param,
  620. const char *function_name,
  621. int ret)
  622. {
  623. spectral_debug("%s: TARGET_IF_SPECTRAL_INFO_PARAMS. Params:\nss_count = %u\nss_period = %u\nss_spectral_pri = %u\nss_fft_size = %u\nss_gc_ena = %u\nss_restart_ena = %u\nss_noise_floor_ref = %d\nss_init_delay = %u\nss_nb_tone_thr = %u\nss_str_bin_thr = %u\nss_wb_rpt_mode = %u\nss_rssi_rpt_mode = %u\nss_rssi_thr = %d\nss_pwr_format = %u\nss_rpt_mode = %u\nss_bin_scale = %u\nss_dbm_adj = %u\nss_chn_mask = %u\nss_frequency1=%u\nss_frequency2=%u\nstatus = %d",
  624. function_name,
  625. param->ss_count,
  626. param->ss_period,
  627. param->ss_spectral_pri,
  628. param->ss_fft_size,
  629. param->ss_gc_ena,
  630. param->ss_restart_ena,
  631. (int8_t)param->ss_noise_floor_ref,
  632. param->ss_init_delay,
  633. param->ss_nb_tone_thr,
  634. param->ss_str_bin_thr,
  635. param->ss_wb_rpt_mode,
  636. param->ss_rssi_rpt_mode,
  637. (int8_t)param->ss_rssi_thr,
  638. param->ss_pwr_format,
  639. param->ss_rpt_mode,
  640. param->ss_bin_scale,
  641. param->ss_dbm_adj,
  642. param->ss_chn_mask,
  643. param->ss_frequency.cfreq1,
  644. param->ss_frequency.cfreq2,
  645. ret);
  646. }
  647. /**
  648. * target_if_spectral_info_write() - Write Spectral information to the
  649. * firmware, and update cache
  650. * @spectral: Pointer to Spectral target_if internal private data
  651. * @smode: Spectral scan mode
  652. * @specifier: target_if_spectral_info enumeration specifying which
  653. * information is involved
  654. * @input: void input pointer containing the information to be written
  655. * @input_len: size of object pointed to by input pointer
  656. *
  657. * Write Spectral parameters or the desired state information to
  658. * the firmware, and update cache
  659. *
  660. * Return: 0 on success, negative error code on failure
  661. */
  662. static int
  663. target_if_spectral_info_write(
  664. struct target_if_spectral *spectral,
  665. enum spectral_scan_mode smode,
  666. enum target_if_spectral_info specifier,
  667. void *input, int input_len)
  668. {
  669. struct target_if_spectral_param_state_info *info;
  670. int ret;
  671. uint8_t *pval = NULL;
  672. struct spectral_config *param = NULL;
  673. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  674. spectral_err("Invalid Spectral mode %u", smode);
  675. return -EINVAL;
  676. }
  677. info = &spectral->param_info[smode];
  678. if (!input)
  679. return -EINVAL;
  680. switch (specifier) {
  681. case TARGET_IF_SPECTRAL_INFO_ACTIVE:
  682. if (input_len != sizeof(info->osps_cache.osc_spectral_active))
  683. return -EINVAL;
  684. pval = (uint8_t *)input;
  685. qdf_spin_lock(&info->osps_lock);
  686. ret = target_if_send_vdev_spectral_enable_cmd(spectral, smode,
  687. 1, *pval, 0, 0);
  688. target_if_log_write_spectral_active(
  689. __func__,
  690. *pval,
  691. ret);
  692. if (ret < 0) {
  693. spectral_err("target_if_send_vdev_spectral_enable_cmd failed with error=%d",
  694. ret);
  695. qdf_spin_unlock(&info->osps_lock);
  696. return ret;
  697. }
  698. info->osps_cache.osc_spectral_active = *pval;
  699. /* The cache is now valid */
  700. info->osps_cache.osc_is_valid = 1;
  701. qdf_spin_unlock(&info->osps_lock);
  702. break;
  703. case TARGET_IF_SPECTRAL_INFO_ENABLED:
  704. if (input_len != sizeof(info->osps_cache.osc_spectral_enabled))
  705. return -EINVAL;
  706. pval = (uint8_t *)input;
  707. qdf_spin_lock(&info->osps_lock);
  708. ret = target_if_send_vdev_spectral_enable_cmd(spectral, smode,
  709. 0, 0, 1, *pval);
  710. target_if_log_write_spectral_enabled(
  711. __func__,
  712. *pval,
  713. ret);
  714. if (ret < 0) {
  715. spectral_err("target_if_send_vdev_spectral_enable_cmd failed with error=%d",
  716. ret);
  717. qdf_spin_unlock(&info->osps_lock);
  718. return ret;
  719. }
  720. info->osps_cache.osc_spectral_enabled = *pval;
  721. /* The cache is now valid */
  722. info->osps_cache.osc_is_valid = 1;
  723. qdf_spin_unlock(&info->osps_lock);
  724. break;
  725. case TARGET_IF_SPECTRAL_INFO_PARAMS:
  726. if (input_len != sizeof(info->osps_cache.osc_params))
  727. return -EINVAL;
  728. param = (struct spectral_config *)input;
  729. qdf_spin_lock(&info->osps_lock);
  730. ret = target_if_send_vdev_spectral_configure_cmd(spectral,
  731. smode, param);
  732. target_if_log_write_spectral_params(
  733. param,
  734. __func__,
  735. ret);
  736. if (ret < 0) {
  737. spectral_err("target_if_send_vdev_spectral_configure_cmd failed with error=%d",
  738. ret);
  739. qdf_spin_unlock(&info->osps_lock);
  740. return ret;
  741. }
  742. qdf_mem_copy(&info->osps_cache.osc_params,
  743. param, sizeof(info->osps_cache.osc_params));
  744. /* The cache is now valid */
  745. info->osps_cache.osc_is_valid = 1;
  746. qdf_spin_unlock(&info->osps_lock);
  747. break;
  748. default:
  749. spectral_err("Unknown target_if_spectral_info specifier");
  750. return -EINVAL;
  751. }
  752. return 0;
  753. }
  754. /**
  755. * target_if_spectral_get_tsf64() - Function to get the TSF value
  756. * @arg: Pointer to handle for Spectral target_if internal private data
  757. *
  758. * Get the last TSF received in WMI buffer
  759. *
  760. * Return: TSF value
  761. */
  762. static uint64_t
  763. target_if_spectral_get_tsf64(void *arg)
  764. {
  765. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  766. return spectral->tsf64;
  767. }
  768. /**
  769. * target_if_spectral_get_capability() - Function to get whether a
  770. * given Spectral hardware capability is available
  771. * @arg: Pointer to handle for Spectral target_if internal private data
  772. * @type: Spectral hardware capability type
  773. *
  774. * Get whether a given Spectral hardware capability is available
  775. *
  776. * Return: True if the capability is available, false if the capability is not
  777. * available
  778. */
  779. uint32_t
  780. target_if_spectral_get_capability(void *arg, enum spectral_capability_type type)
  781. {
  782. int status = STATUS_FAIL;
  783. switch (type) {
  784. case SPECTRAL_CAP_PHYDIAG:
  785. case SPECTRAL_CAP_RADAR:
  786. case SPECTRAL_CAP_SPECTRAL_SCAN:
  787. case SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN:
  788. status = STATUS_PASS;
  789. break;
  790. default:
  791. status = STATUS_FAIL;
  792. }
  793. return status;
  794. }
  795. /**
  796. * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start
  797. * @arg: Pointer to handle for Spectral target_if internal private data
  798. * @rxfilter: Rx filter to be used
  799. *
  800. * Note: This is only a placeholder function. It is not currently required since
  801. * FW should be taking care of setting the required filters.
  802. *
  803. * Return: 0
  804. */
  805. uint32_t
  806. target_if_spectral_set_rxfilter(void *arg, int rxfilter)
  807. {
  808. /*
  809. * Will not be required since enabling of spectral in firmware
  810. * will take care of this
  811. */
  812. return 0;
  813. }
  814. /**
  815. * target_if_spectral_get_rxfilter() - Get the current RX Filter settings
  816. * @arg: Pointer to handle for Spectral target_if internal private data
  817. *
  818. * Note: This is only a placeholder function. It is not currently required since
  819. * FW should be taking care of setting the required filters.
  820. *
  821. * Return: 0
  822. */
  823. uint32_t
  824. target_if_spectral_get_rxfilter(void *arg)
  825. {
  826. /*
  827. * Will not be required since enabling of spectral in firmware
  828. * will take care of this
  829. */
  830. return 0;
  831. }
  832. /**
  833. * target_if_sops_is_spectral_active() - Get whether Spectral is active
  834. * @arg: Pointer to handle for Spectral target_if internal private data
  835. * @smode: Spectral scan mode
  836. *
  837. * Function to check whether Spectral is active
  838. *
  839. * Return: True if Spectral is active, false if Spectral is not active
  840. */
  841. uint32_t
  842. target_if_sops_is_spectral_active(void *arg, enum spectral_scan_mode smode)
  843. {
  844. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  845. uint8_t val = 0;
  846. int ret;
  847. ret = target_if_spectral_info_read(
  848. spectral,
  849. smode,
  850. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  851. &val, sizeof(val));
  852. if (ret != 0) {
  853. /*
  854. * Could not determine if Spectral is active.
  855. * Return false as a safe value.
  856. * XXX: Consider changing the function prototype
  857. * to be able to indicate failure to fetch value.
  858. */
  859. return 0;
  860. }
  861. return val;
  862. }
  863. /**
  864. * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled
  865. * @arg: Pointer to handle for Spectral target_if internal private data
  866. * @smode: Spectral scan mode
  867. *
  868. * Function to check whether Spectral is enabled
  869. *
  870. * Return: True if Spectral is enabled, false if Spectral is not enabled
  871. */
  872. uint32_t
  873. target_if_sops_is_spectral_enabled(void *arg, enum spectral_scan_mode smode)
  874. {
  875. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  876. uint8_t val = 0;
  877. int ret;
  878. ret = target_if_spectral_info_read(
  879. spectral,
  880. smode,
  881. TARGET_IF_SPECTRAL_INFO_ENABLED,
  882. &val, sizeof(val));
  883. if (ret != 0) {
  884. /*
  885. * Could not determine if Spectral is enabled.
  886. * Return false as a safe value.
  887. * XXX: Consider changing the function prototype
  888. * to be able to indicate failure to fetch value.
  889. */
  890. return 0;
  891. }
  892. return val;
  893. }
  894. /**
  895. * target_if_sops_start_spectral_scan() - Start Spectral scan
  896. * @arg: Pointer to handle for Spectral target_if internal private data
  897. * @smode: Spectral scan mode
  898. * @err: Spectral error code
  899. *
  900. * Function to start spectral scan
  901. *
  902. * Return: 0 on success else failure
  903. */
  904. uint32_t
  905. target_if_sops_start_spectral_scan(void *arg, enum spectral_scan_mode smode,
  906. enum spectral_cp_error_code *err)
  907. {
  908. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  909. uint8_t val = 1;
  910. uint8_t enabled = 0;
  911. int ret;
  912. ret = target_if_spectral_info_read(
  913. spectral,
  914. smode,
  915. TARGET_IF_SPECTRAL_INFO_ENABLED,
  916. &enabled, sizeof(enabled));
  917. if (ret != 0) {
  918. /*
  919. * Could not determine if Spectral is enabled. Assume we need
  920. * to enable it
  921. */
  922. enabled = 0;
  923. }
  924. if (!enabled) {
  925. ret = target_if_spectral_info_write(
  926. spectral,
  927. smode,
  928. TARGET_IF_SPECTRAL_INFO_ENABLED,
  929. &val, sizeof(val));
  930. if (ret != 0)
  931. return ret;
  932. }
  933. ret = target_if_spectral_info_write(
  934. spectral,
  935. smode,
  936. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  937. &val, sizeof(val));
  938. if (ret != 0)
  939. return ret;
  940. return 0;
  941. }
  942. /**
  943. * target_if_sops_stop_spectral_scan() - Stop Spectral scan
  944. * @arg: Pointer to handle for Spectral target_if internal private data
  945. * @smode: Spectral scan mode
  946. *
  947. * Function to stop spectral scan
  948. *
  949. * Return: 0 on success else failure
  950. */
  951. uint32_t
  952. target_if_sops_stop_spectral_scan(void *arg, enum spectral_scan_mode smode)
  953. {
  954. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  955. uint8_t val = 0;
  956. int tempret, ret = 0;
  957. uint8_t enabled = 0;
  958. tempret = target_if_spectral_info_read(
  959. spectral,
  960. smode,
  961. TARGET_IF_SPECTRAL_INFO_ENABLED,
  962. &enabled, sizeof(enabled));
  963. if (tempret)
  964. /*
  965. * Could not determine if Spectral is enabled. Assume scan is
  966. * not in progress
  967. */
  968. enabled = 0;
  969. /* if scan is not enabled, no need to send stop to FW */
  970. if (!enabled)
  971. return -EPERM;
  972. tempret = target_if_spectral_info_write(
  973. spectral,
  974. smode,
  975. TARGET_IF_SPECTRAL_INFO_ACTIVE,
  976. &val, sizeof(val));
  977. if (tempret != 0)
  978. ret = tempret;
  979. tempret = target_if_spectral_info_write(
  980. spectral,
  981. smode,
  982. TARGET_IF_SPECTRAL_INFO_ENABLED,
  983. &val, sizeof(val));
  984. if (tempret != 0)
  985. ret = tempret;
  986. return ret;
  987. }
  988. /**
  989. * target_if_spectral_get_extension_channel() - Get the Extension channel
  990. * @arg: Pointer to handle for Spectral target_if internal private data
  991. * @smode: Spectral scan mode
  992. *
  993. * Function to get the current Extension channel (in MHz)
  994. *
  995. * Return: Current Extension channel (in MHz) on success, 0 on failure or if
  996. * extension channel is not present.
  997. */
  998. uint32_t
  999. target_if_spectral_get_extension_channel(void *arg,
  1000. enum spectral_scan_mode smode)
  1001. {
  1002. /*
  1003. * XXX: Once we expand to use cases where Spectral could be activated
  1004. * without a channel being set to VDEV, we need to consider returning a
  1005. * negative value in case of failure and having all callers handle this.
  1006. */
  1007. struct target_if_spectral *spectral = NULL;
  1008. struct wlan_objmgr_vdev *vdev = NULL;
  1009. uint16_t sec20chan_freq = 0;
  1010. qdf_assert_always(arg);
  1011. spectral = (struct target_if_spectral *)arg;
  1012. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1013. spectral_err("Invalid Spectral mode %u", smode);
  1014. return 0;
  1015. }
  1016. vdev = target_if_spectral_get_vdev(spectral, smode);
  1017. if (!vdev)
  1018. return 0;
  1019. if (target_if_vdev_get_sec20chan_freq_mhz(vdev, &sec20chan_freq) < 0) {
  1020. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1021. return 0;
  1022. }
  1023. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1024. return sec20chan_freq;
  1025. }
  1026. /**
  1027. * target_if_spectral_get_current_channel() - Get the current channel
  1028. * @arg: Pointer to handle for Spectral target_if internal private data
  1029. * @smode: Spectral scan mode
  1030. *
  1031. * Function to get the current channel (in MHz)
  1032. *
  1033. * Return: Current channel (in MHz) on success, 0 on failure
  1034. */
  1035. uint32_t
  1036. target_if_spectral_get_current_channel(void *arg, enum spectral_scan_mode smode)
  1037. {
  1038. /*
  1039. * XXX: Once we expand to use cases where Spectral could be activated
  1040. * without a channel being set to VDEV, we need to consider returning a
  1041. * negative value in case of failure and having all callers handle this.
  1042. */
  1043. struct target_if_spectral *spectral = NULL;
  1044. int16_t chan_freq = 0;
  1045. struct wlan_objmgr_vdev *vdev = NULL;
  1046. qdf_assert_always(arg);
  1047. spectral = (struct target_if_spectral *)arg;
  1048. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  1049. spectral_err("Invalid Spectral mode %u", smode);
  1050. return 0;
  1051. }
  1052. vdev = target_if_spectral_get_vdev(spectral, smode);
  1053. if (!vdev)
  1054. return 0;
  1055. chan_freq = target_if_vdev_get_chan_freq(vdev);
  1056. if (chan_freq < 0) {
  1057. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1058. return 0;
  1059. }
  1060. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  1061. return chan_freq;
  1062. }
  1063. /**
  1064. * target_if_spectral_reset_hw() - Reset the hardware
  1065. * @arg: Pointer to handle for Spectral target_if internal private data
  1066. *
  1067. * This is only a placeholder since it is not currently required in the offload
  1068. * case.
  1069. *
  1070. * Return: 0
  1071. */
  1072. uint32_t
  1073. target_if_spectral_reset_hw(void *arg)
  1074. {
  1075. not_yet_implemented();
  1076. return 0;
  1077. }
  1078. /**
  1079. * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from
  1080. * Noisefloor history buffer
  1081. * @arg: Pointer to handle for Spectral target_if internal private data
  1082. * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied
  1083. *
  1084. * This is only a placeholder since it is not currently required in the offload
  1085. * case.
  1086. *
  1087. * Return: 0
  1088. */
  1089. uint32_t
  1090. target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf)
  1091. {
  1092. not_yet_implemented();
  1093. return 0;
  1094. }
  1095. /**
  1096. * target_if_spectral_get_ext_noisefloor() - Get the extension channel
  1097. * noisefloor
  1098. * @arg: Pointer to handle for Spectral target_if internal private data
  1099. *
  1100. * This is only a placeholder since it is not currently required in the offload
  1101. * case.
  1102. *
  1103. * Return: 0
  1104. */
  1105. int8_t
  1106. target_if_spectral_get_ext_noisefloor(void *arg)
  1107. {
  1108. not_yet_implemented();
  1109. return 0;
  1110. }
  1111. /**
  1112. * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor
  1113. * @arg: Pointer to handle for Spectral target_if internal private data
  1114. *
  1115. * This is only a placeholder since it is not currently required in the offload
  1116. * case.
  1117. *
  1118. * Return: 0
  1119. */
  1120. int8_t
  1121. target_if_spectral_get_ctl_noisefloor(void *arg)
  1122. {
  1123. not_yet_implemented();
  1124. return 0;
  1125. }
  1126. /**
  1127. * target_if_spectral_sops_configure_params() - Configure user supplied Spectral
  1128. * parameters
  1129. * @arg: Pointer to handle for Spectral target_if internal private data
  1130. * @params: Spectral parameters
  1131. * @smode: Spectral scan mode
  1132. *
  1133. * Function to configure spectral parameters
  1134. *
  1135. * Return: 0 on success else failure
  1136. */
  1137. uint32_t
  1138. target_if_spectral_sops_configure_params(
  1139. void *arg, struct spectral_config *params,
  1140. enum spectral_scan_mode smode)
  1141. {
  1142. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  1143. return target_if_spectral_info_write(
  1144. spectral,
  1145. smode,
  1146. TARGET_IF_SPECTRAL_INFO_PARAMS,
  1147. params, sizeof(*params));
  1148. }
  1149. /**
  1150. * target_if_spectral_sops_get_params() - Get user configured Spectral
  1151. * parameters
  1152. * @arg: Pointer to handle for Spectral target_if internal private data
  1153. * @params: Pointer to buffer into which Spectral parameters should be copied
  1154. * @smode: Spectral scan mode
  1155. *
  1156. * Function to get the configured spectral parameters
  1157. *
  1158. * Return: 0 on success else failure
  1159. */
  1160. uint32_t
  1161. target_if_spectral_sops_get_params(void *arg, struct spectral_config *params,
  1162. enum spectral_scan_mode smode)
  1163. {
  1164. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  1165. return target_if_spectral_info_read(
  1166. spectral,
  1167. smode,
  1168. TARGET_IF_SPECTRAL_INFO_PARAMS,
  1169. params, sizeof(*params));
  1170. }
  1171. /**
  1172. * target_if_spectral_get_ent_mask() - Get enterprise mask
  1173. * @arg: Pointer to handle for Spectral target_if internal private data
  1174. *
  1175. * This is only a placeholder since it is not currently required in the offload
  1176. * case.
  1177. *
  1178. * Return: 0
  1179. */
  1180. static uint32_t
  1181. target_if_spectral_get_ent_mask(void *arg)
  1182. {
  1183. not_yet_implemented();
  1184. return 0;
  1185. }
  1186. /**
  1187. * target_if_spectral_get_macaddr() - Get radio MAC address
  1188. * @arg: Pointer to handle for Spectral target_if internal private data
  1189. * @addr: Pointer to buffer into which MAC address should be copied
  1190. *
  1191. * Function to get the MAC address of the pdev
  1192. *
  1193. * Return: 0 on success, -1 on failure
  1194. */
  1195. static uint32_t
  1196. target_if_spectral_get_macaddr(void *arg, char *addr)
  1197. {
  1198. uint8_t *myaddr = NULL;
  1199. struct target_if_spectral *spectral = (struct target_if_spectral *)arg;
  1200. struct wlan_objmgr_pdev *pdev = NULL;
  1201. pdev = spectral->pdev_obj;
  1202. wlan_pdev_obj_lock(pdev);
  1203. myaddr = wlan_pdev_get_hw_macaddr(pdev);
  1204. wlan_pdev_obj_unlock(pdev);
  1205. qdf_mem_copy(addr, myaddr, QDF_MAC_ADDR_SIZE);
  1206. return 0;
  1207. }
  1208. /**
  1209. * target_if_init_spectral_param_min_max() - Initialize Spectral parameter
  1210. * min and max values
  1211. *
  1212. * @param_min_max: Pointer to Spectral parameter min and max structure
  1213. * @gen: Spectral HW generation
  1214. * @target_type: Target type
  1215. *
  1216. * Initialize Spectral parameter min and max values
  1217. *
  1218. * Return: QDF_STATUS
  1219. */
  1220. static QDF_STATUS
  1221. target_if_init_spectral_param_min_max(
  1222. struct spectral_param_min_max *param_min_max,
  1223. enum spectral_gen gen, uint32_t target_type)
  1224. {
  1225. switch (gen) {
  1226. case SPECTRAL_GEN3:
  1227. param_min_max->fft_size_min = SPECTRAL_PARAM_FFT_SIZE_MIN_GEN3;
  1228. param_min_max->fft_size_max[CH_WIDTH_20MHZ] =
  1229. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT;
  1230. if (target_type == TARGET_TYPE_QCN9000 ||
  1231. target_type == TARGET_TYPE_QCA5018 ||
  1232. target_type == TARGET_TYPE_QCA6490) {
  1233. param_min_max->fft_size_max[CH_WIDTH_40MHZ] =
  1234. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000;
  1235. param_min_max->fft_size_max[CH_WIDTH_80MHZ] =
  1236. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000;
  1237. param_min_max->fft_size_max[CH_WIDTH_160MHZ] =
  1238. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000;
  1239. param_min_max->fft_size_max[CH_WIDTH_80P80MHZ] =
  1240. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_QCN9000;
  1241. } else {
  1242. param_min_max->fft_size_max[CH_WIDTH_40MHZ] =
  1243. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT;
  1244. param_min_max->fft_size_max[CH_WIDTH_80MHZ] =
  1245. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT;
  1246. param_min_max->fft_size_max[CH_WIDTH_160MHZ] =
  1247. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT;
  1248. param_min_max->fft_size_max[CH_WIDTH_80P80MHZ] =
  1249. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3_DEFAULT;
  1250. }
  1251. break;
  1252. case SPECTRAL_GEN2:
  1253. param_min_max->fft_size_min = SPECTRAL_PARAM_FFT_SIZE_MIN_GEN2;
  1254. param_min_max->fft_size_max[CH_WIDTH_20MHZ] =
  1255. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2;
  1256. param_min_max->fft_size_max[CH_WIDTH_40MHZ] =
  1257. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2;
  1258. param_min_max->fft_size_max[CH_WIDTH_80MHZ] =
  1259. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2;
  1260. param_min_max->fft_size_max[CH_WIDTH_80P80MHZ] =
  1261. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2;
  1262. param_min_max->fft_size_max[CH_WIDTH_160MHZ] =
  1263. SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2;
  1264. break;
  1265. default:
  1266. spectral_err("Invalid spectral generation %d", gen);
  1267. return QDF_STATUS_E_INVAL;
  1268. }
  1269. return QDF_STATUS_SUCCESS;
  1270. }
  1271. /**
  1272. * target_if_init_spectral_param_properties() - Initialize Spectral parameter
  1273. * properties
  1274. * @spectral: Pointer to Spectral target_if internal private data
  1275. *
  1276. * Initialize Spectral parameter properties
  1277. *
  1278. * Return: QDF_STATUS
  1279. */
  1280. static QDF_STATUS
  1281. target_if_init_spectral_param_properties(struct target_if_spectral *spectral)
  1282. {
  1283. enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
  1284. int param;
  1285. /* Initialize default values for properties.
  1286. * Default values are supported for all the parameters for all modes
  1287. * and allows different values for each mode for all the parameters .
  1288. */
  1289. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
  1290. for (param = 0; param < SPECTRAL_PARAM_MAX; param++) {
  1291. spectral->properties[smode][param].supported = true;
  1292. spectral->properties[smode][param].common_all_modes =
  1293. false;
  1294. }
  1295. }
  1296. /* Once FW advertisement is in place remove this hard coding */
  1297. smode = SPECTRAL_SCAN_MODE_NORMAL;
  1298. spectral->properties[SPECTRAL_SCAN_MODE_NORMAL]
  1299. [SPECTRAL_PARAM_FREQUENCY].supported = false;
  1300. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
  1301. spectral->properties[smode]
  1302. [SPECTRAL_PARAM_SPECT_PRI].common_all_modes = true;
  1303. spectral->properties[smode]
  1304. [SPECTRAL_PARAM_SCAN_PERIOD].common_all_modes = true;
  1305. spectral->properties[smode]
  1306. [SPECTRAL_PARAM_INIT_DELAY].common_all_modes = true;
  1307. }
  1308. return QDF_STATUS_SUCCESS;
  1309. }
  1310. QDF_STATUS
  1311. target_if_init_spectral_capability(struct target_if_spectral *spectral,
  1312. uint32_t target_type)
  1313. {
  1314. struct wlan_objmgr_psoc *psoc;
  1315. struct wlan_objmgr_pdev *pdev;
  1316. struct wlan_psoc_host_spectral_scaling_params *scaling_params;
  1317. uint8_t num_bin_scaling_params, param_idx, pdev_id;
  1318. struct target_psoc_info *tgt_psoc_info;
  1319. struct wlan_psoc_host_service_ext_param *ext_svc_param;
  1320. struct spectral_caps *pcap = &spectral->capability;
  1321. struct wlan_psoc_host_mac_phy_caps *mac_phy_cap_arr = NULL;
  1322. struct wlan_psoc_host_mac_phy_caps *mac_phy_cap = NULL;
  1323. struct wlan_psoc_host_chainmask_table *table;
  1324. int j;
  1325. uint32_t table_id;
  1326. pdev = spectral->pdev_obj;
  1327. psoc = wlan_pdev_get_psoc(pdev);
  1328. if (!psoc) {
  1329. spectral_err("psoc is null");
  1330. return QDF_STATUS_E_FAILURE;
  1331. }
  1332. tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
  1333. if (!tgt_psoc_info) {
  1334. spectral_err("target_psoc_info is null");
  1335. return QDF_STATUS_E_FAILURE;
  1336. }
  1337. ext_svc_param = target_psoc_get_service_ext_param(tgt_psoc_info);
  1338. num_bin_scaling_params = ext_svc_param->num_bin_scaling_params;
  1339. scaling_params = target_psoc_get_spectral_scaling_params(tgt_psoc_info);
  1340. pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  1341. /* XXX : Workaround: Set Spectral capability */
  1342. pcap = &spectral->capability;
  1343. pcap->phydiag_cap = 1;
  1344. pcap->radar_cap = 1;
  1345. pcap->spectral_cap = 1;
  1346. pcap->advncd_spectral_cap = 1;
  1347. pcap->hw_gen = spectral->spectral_gen;
  1348. if (spectral->spectral_gen >= SPECTRAL_GEN3) {
  1349. mac_phy_cap_arr = target_psoc_get_mac_phy_cap(tgt_psoc_info);
  1350. if (!mac_phy_cap_arr) {
  1351. spectral_err("mac phy cap array is null");
  1352. return QDF_STATUS_E_FAILURE;
  1353. }
  1354. mac_phy_cap = &mac_phy_cap_arr[pdev_id];
  1355. if (!mac_phy_cap) {
  1356. spectral_err("mac phy cap is null");
  1357. return QDF_STATUS_E_FAILURE;
  1358. }
  1359. table_id = mac_phy_cap->chainmask_table_id;
  1360. table = &ext_svc_param->chainmask_table[table_id];
  1361. if (!table) {
  1362. spectral_err("chainmask table not found");
  1363. return QDF_STATUS_E_FAILURE;
  1364. }
  1365. for (j = 0; j < table->num_valid_chainmasks; j++) {
  1366. pcap->agile_spectral_cap |=
  1367. table->cap_list[j].supports_aSpectral;
  1368. pcap->agile_spectral_cap_160 |=
  1369. table->cap_list[j].supports_aSpectral_160;
  1370. }
  1371. pcap->agile_spectral_cap_80p80 = pcap->agile_spectral_cap_160;
  1372. } else {
  1373. pcap->agile_spectral_cap = false;
  1374. pcap->agile_spectral_cap_160 = false;
  1375. pcap->agile_spectral_cap_80p80 = false;
  1376. }
  1377. if (scaling_params) {
  1378. for (param_idx = 0; param_idx < num_bin_scaling_params;
  1379. param_idx++) {
  1380. if (scaling_params[param_idx].pdev_id == pdev_id) {
  1381. pcap->is_scaling_params_populated = true;
  1382. pcap->formula_id =
  1383. scaling_params[param_idx].formula_id;
  1384. pcap->low_level_offset =
  1385. scaling_params[param_idx].low_level_offset;
  1386. pcap->high_level_offset =
  1387. scaling_params[param_idx].high_level_offset;
  1388. pcap->rssi_thr =
  1389. scaling_params[param_idx].rssi_thr;
  1390. pcap->default_agc_max_gain =
  1391. scaling_params[param_idx].default_agc_max_gain;
  1392. break;
  1393. }
  1394. }
  1395. }
  1396. pcap->num_detectors_20mhz = 1;
  1397. pcap->num_detectors_40mhz = 1;
  1398. pcap->num_detectors_80mhz = 1;
  1399. if (target_type == TARGET_TYPE_QCN9000 ||
  1400. target_type == TARGET_TYPE_QCA6490) {
  1401. pcap->num_detectors_160mhz = 1;
  1402. pcap->num_detectors_80p80mhz = 1;
  1403. } else {
  1404. pcap->num_detectors_160mhz = 2;
  1405. pcap->num_detectors_80p80mhz = 2;
  1406. }
  1407. return QDF_STATUS_SUCCESS;
  1408. }
  1409. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  1410. /**
  1411. * target_if_init_spectral_simulation_ops() - Initialize spectral target_if
  1412. * internal operations with functions related to spectral simulation
  1413. * @p_sops: spectral low level ops table
  1414. *
  1415. * Initialize spectral target_if internal operations with functions
  1416. * related to spectral simulation
  1417. *
  1418. * Return: None
  1419. */
  1420. static void
  1421. target_if_init_spectral_simulation_ops(struct target_if_spectral_ops *p_sops)
  1422. {
  1423. /*
  1424. * Spectral simulation is currently intended for platform transitions
  1425. * where underlying HW support may not be available for some time.
  1426. * Hence, we do not currently provide a runtime switch to turn the
  1427. * simulation on or off.
  1428. * In case of future requirements where runtime switches are required,
  1429. * this can be added. But it is suggested to use application layer
  1430. * simulation as far as possible in such cases, since the main
  1431. * use of record and replay of samples would concern higher
  1432. * level sample processing rather than lower level delivery.
  1433. */
  1434. p_sops->is_spectral_enabled = target_if_spectral_sops_sim_is_enabled;
  1435. p_sops->is_spectral_active = target_if_spectral_sops_sim_is_active;
  1436. p_sops->start_spectral_scan = target_if_spectral_sops_sim_start_scan;
  1437. p_sops->stop_spectral_scan = target_if_spectral_sops_sim_stop_scan;
  1438. p_sops->configure_spectral =
  1439. target_if_spectral_sops_sim_configure_params;
  1440. p_sops->get_spectral_config = target_if_spectral_sops_sim_get_params;
  1441. }
  1442. #else
  1443. /**
  1444. * target_if_init_spectral_simulation_ops() - Initialize spectral target_if
  1445. * internal operations
  1446. * @p_sops: spectral low level ops table
  1447. *
  1448. * Return: None
  1449. */
  1450. static void
  1451. target_if_init_spectral_simulation_ops(struct target_if_spectral_ops *p_sops)
  1452. {
  1453. p_sops->is_spectral_enabled = target_if_sops_is_spectral_enabled;
  1454. p_sops->is_spectral_active = target_if_sops_is_spectral_active;
  1455. p_sops->start_spectral_scan = target_if_sops_start_spectral_scan;
  1456. p_sops->stop_spectral_scan = target_if_sops_stop_spectral_scan;
  1457. p_sops->configure_spectral = target_if_spectral_sops_configure_params;
  1458. p_sops->get_spectral_config = target_if_spectral_sops_get_params;
  1459. }
  1460. #endif
  1461. /**
  1462. * target_if_init_spectral_ops_common() - Initialize Spectral target_if internal
  1463. * operations common to all Spectral chipset generations
  1464. *
  1465. * Initializes target_if_spectral_ops common to all chipset generations
  1466. *
  1467. * Return: None
  1468. */
  1469. static void
  1470. target_if_init_spectral_ops_common(void)
  1471. {
  1472. struct target_if_spectral_ops *p_sops = &spectral_ops;
  1473. p_sops->get_tsf64 = target_if_spectral_get_tsf64;
  1474. p_sops->get_capability = target_if_spectral_get_capability;
  1475. p_sops->set_rxfilter = target_if_spectral_set_rxfilter;
  1476. p_sops->get_rxfilter = target_if_spectral_get_rxfilter;
  1477. target_if_init_spectral_simulation_ops(p_sops);
  1478. p_sops->get_extension_channel =
  1479. target_if_spectral_get_extension_channel;
  1480. p_sops->get_ctl_noisefloor = target_if_spectral_get_ctl_noisefloor;
  1481. p_sops->get_ext_noisefloor = target_if_spectral_get_ext_noisefloor;
  1482. p_sops->get_ent_spectral_mask = target_if_spectral_get_ent_mask;
  1483. p_sops->get_mac_address = target_if_spectral_get_macaddr;
  1484. p_sops->get_current_channel = target_if_spectral_get_current_channel;
  1485. p_sops->reset_hw = target_if_spectral_reset_hw;
  1486. p_sops->get_chain_noise_floor =
  1487. target_if_spectral_get_chain_noise_floor;
  1488. }
  1489. /**
  1490. * target_if_init_spectral_ops_gen2() - Initialize Spectral target_if internal
  1491. * operations specific to Spectral chipset generation 2.
  1492. *
  1493. * Initializes target_if_spectral_ops specific to Spectral chipset generation 2.
  1494. *
  1495. * Return: None
  1496. */
  1497. static void
  1498. target_if_init_spectral_ops_gen2(void)
  1499. {
  1500. struct target_if_spectral_ops *p_sops = &spectral_ops;
  1501. p_sops->spectral_process_phyerr = target_if_process_phyerr_gen2;
  1502. }
  1503. /**
  1504. * target_if_init_spectral_ops_gen3() - Initialize Spectral target_if internal
  1505. * operations specific to Spectral chipset generation 3.
  1506. *
  1507. * Initializes target_if_spectral_ops specific to Spectral chipset generation 3.
  1508. *
  1509. * Return: None
  1510. */
  1511. static void
  1512. target_if_init_spectral_ops_gen3(void)
  1513. {
  1514. struct target_if_spectral_ops *p_sops = &spectral_ops;
  1515. p_sops->process_spectral_report =
  1516. target_if_spectral_process_report_gen3;
  1517. return;
  1518. }
  1519. /**
  1520. * target_if_init_spectral_ops() - Initialize target_if internal Spectral
  1521. * operations.
  1522. * @spectral: Pointer to Spectral target_if internal private data
  1523. *
  1524. * Initializes all function pointers in target_if_spectral_ops for
  1525. * all generations
  1526. *
  1527. * Return: None
  1528. */
  1529. static void
  1530. target_if_init_spectral_ops(struct target_if_spectral *spectral)
  1531. {
  1532. target_if_init_spectral_ops_common();
  1533. if (spectral->spectral_gen == SPECTRAL_GEN2)
  1534. target_if_init_spectral_ops_gen2();
  1535. else if (spectral->spectral_gen == SPECTRAL_GEN3)
  1536. target_if_init_spectral_ops_gen3();
  1537. else
  1538. spectral_err("Invalid Spectral generation");
  1539. }
  1540. /*
  1541. * Dummy Functions:
  1542. * These functions are initially registered to avoid any crashes due to
  1543. * invocation of spectral functions before they are registered.
  1544. */
  1545. static uint64_t
  1546. null_get_tsf64(void *arg)
  1547. {
  1548. spectral_ops_not_registered("get_tsf64");
  1549. return 0;
  1550. }
  1551. static uint32_t
  1552. null_get_capability(void *arg, enum spectral_capability_type type)
  1553. {
  1554. /*
  1555. * TODO : We should have conditional compilation to get the capability
  1556. * : We have not yet attahced ATH layer here, so there is no
  1557. * : way to check the HAL capbalities
  1558. */
  1559. spectral_ops_not_registered("get_capability");
  1560. /* TODO : For the time being, we are returning TRUE */
  1561. return true;
  1562. }
  1563. static uint32_t
  1564. null_set_rxfilter(void *arg, int rxfilter)
  1565. {
  1566. spectral_ops_not_registered("set_rxfilter");
  1567. return 1;
  1568. }
  1569. static uint32_t
  1570. null_get_rxfilter(void *arg)
  1571. {
  1572. spectral_ops_not_registered("get_rxfilter");
  1573. return 0;
  1574. }
  1575. static uint32_t
  1576. null_is_spectral_active(void *arg, enum spectral_scan_mode smode)
  1577. {
  1578. spectral_ops_not_registered("is_spectral_active");
  1579. return 1;
  1580. }
  1581. static uint32_t
  1582. null_is_spectral_enabled(void *arg, enum spectral_scan_mode smode)
  1583. {
  1584. spectral_ops_not_registered("is_spectral_enabled");
  1585. return 1;
  1586. }
  1587. static uint32_t
  1588. null_start_spectral_scan(void *arg, enum spectral_scan_mode smode,
  1589. enum spectral_cp_error_code *err)
  1590. {
  1591. spectral_ops_not_registered("start_spectral_scan");
  1592. return 1;
  1593. }
  1594. static uint32_t
  1595. null_stop_spectral_scan(void *arg, enum spectral_scan_mode smode)
  1596. {
  1597. spectral_ops_not_registered("stop_spectral_scan");
  1598. return 1;
  1599. }
  1600. static uint32_t
  1601. null_get_extension_channel(void *arg, enum spectral_scan_mode smode)
  1602. {
  1603. spectral_ops_not_registered("get_extension_channel");
  1604. return 1;
  1605. }
  1606. static int8_t
  1607. null_get_ctl_noisefloor(void *arg)
  1608. {
  1609. spectral_ops_not_registered("get_ctl_noisefloor");
  1610. return 1;
  1611. }
  1612. static int8_t
  1613. null_get_ext_noisefloor(void *arg)
  1614. {
  1615. spectral_ops_not_registered("get_ext_noisefloor");
  1616. return 0;
  1617. }
  1618. static uint32_t
  1619. null_configure_spectral(void *arg, struct spectral_config *params,
  1620. enum spectral_scan_mode smode)
  1621. {
  1622. spectral_ops_not_registered("configure_spectral");
  1623. return 0;
  1624. }
  1625. static uint32_t
  1626. null_get_spectral_config(void *arg, struct spectral_config *params,
  1627. enum spectral_scan_mode smode)
  1628. {
  1629. spectral_ops_not_registered("get_spectral_config");
  1630. return 0;
  1631. }
  1632. static uint32_t
  1633. null_get_ent_spectral_mask(void *arg)
  1634. {
  1635. spectral_ops_not_registered("get_ent_spectral_mask");
  1636. return 0;
  1637. }
  1638. static uint32_t
  1639. null_get_mac_address(void *arg, char *addr)
  1640. {
  1641. spectral_ops_not_registered("get_mac_address");
  1642. return 0;
  1643. }
  1644. static uint32_t
  1645. null_get_current_channel(void *arg, enum spectral_scan_mode smode)
  1646. {
  1647. spectral_ops_not_registered("get_current_channel");
  1648. return 0;
  1649. }
  1650. static uint32_t
  1651. null_reset_hw(void *arg)
  1652. {
  1653. spectral_ops_not_registered("get_current_channel");
  1654. return 0;
  1655. }
  1656. static uint32_t
  1657. null_get_chain_noise_floor(void *arg, int16_t *nf_buf)
  1658. {
  1659. spectral_ops_not_registered("get_chain_noise_floor");
  1660. return 0;
  1661. }
  1662. static int
  1663. null_spectral_process_phyerr(struct target_if_spectral *spectral,
  1664. uint8_t *data,
  1665. uint32_t datalen,
  1666. struct target_if_spectral_rfqual_info *p_rfqual,
  1667. struct target_if_spectral_chan_info *p_chaninfo,
  1668. uint64_t tsf64,
  1669. struct target_if_spectral_acs_stats *acs_stats)
  1670. {
  1671. spectral_ops_not_registered("spectral_process_phyerr");
  1672. return 0;
  1673. }
  1674. static int
  1675. null_process_spectral_report(struct wlan_objmgr_pdev *pdev,
  1676. void *payload)
  1677. {
  1678. spectral_ops_not_registered("process_spectral_report");
  1679. return 0;
  1680. }
  1681. /**
  1682. * target_if_spectral_init_dummy_function_table() -
  1683. * Initialize target_if internal
  1684. * Spectral operations to dummy functions
  1685. * @ps: Pointer to Spectral target_if internal private data
  1686. *
  1687. * Initialize all the function pointers in target_if_spectral_ops with
  1688. * dummy functions.
  1689. *
  1690. * Return: None
  1691. */
  1692. static void
  1693. target_if_spectral_init_dummy_function_table(struct target_if_spectral *ps)
  1694. {
  1695. struct target_if_spectral_ops *p_sops = GET_TARGET_IF_SPECTRAL_OPS(ps);
  1696. p_sops->get_tsf64 = null_get_tsf64;
  1697. p_sops->get_capability = null_get_capability;
  1698. p_sops->set_rxfilter = null_set_rxfilter;
  1699. p_sops->get_rxfilter = null_get_rxfilter;
  1700. p_sops->is_spectral_enabled = null_is_spectral_enabled;
  1701. p_sops->is_spectral_active = null_is_spectral_active;
  1702. p_sops->start_spectral_scan = null_start_spectral_scan;
  1703. p_sops->stop_spectral_scan = null_stop_spectral_scan;
  1704. p_sops->get_extension_channel = null_get_extension_channel;
  1705. p_sops->get_ctl_noisefloor = null_get_ctl_noisefloor;
  1706. p_sops->get_ext_noisefloor = null_get_ext_noisefloor;
  1707. p_sops->configure_spectral = null_configure_spectral;
  1708. p_sops->get_spectral_config = null_get_spectral_config;
  1709. p_sops->get_ent_spectral_mask = null_get_ent_spectral_mask;
  1710. p_sops->get_mac_address = null_get_mac_address;
  1711. p_sops->get_current_channel = null_get_current_channel;
  1712. p_sops->reset_hw = null_reset_hw;
  1713. p_sops->get_chain_noise_floor = null_get_chain_noise_floor;
  1714. p_sops->spectral_process_phyerr = null_spectral_process_phyerr;
  1715. p_sops->process_spectral_report = null_process_spectral_report;
  1716. }
  1717. /**
  1718. * target_if_spectral_register_funcs() - Initialize target_if internal Spectral
  1719. * operations
  1720. * @spectral: Pointer to Spectral target_if internal private data
  1721. * @p: Pointer to Spectral function table
  1722. *
  1723. * Return: None
  1724. */
  1725. static void
  1726. target_if_spectral_register_funcs(struct target_if_spectral *spectral,
  1727. struct target_if_spectral_ops *p)
  1728. {
  1729. struct target_if_spectral_ops *p_sops =
  1730. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1731. p_sops->get_tsf64 = p->get_tsf64;
  1732. p_sops->get_capability = p->get_capability;
  1733. p_sops->set_rxfilter = p->set_rxfilter;
  1734. p_sops->get_rxfilter = p->get_rxfilter;
  1735. p_sops->is_spectral_enabled = p->is_spectral_enabled;
  1736. p_sops->is_spectral_active = p->is_spectral_active;
  1737. p_sops->start_spectral_scan = p->start_spectral_scan;
  1738. p_sops->stop_spectral_scan = p->stop_spectral_scan;
  1739. p_sops->get_extension_channel = p->get_extension_channel;
  1740. p_sops->get_ctl_noisefloor = p->get_ctl_noisefloor;
  1741. p_sops->get_ext_noisefloor = p->get_ext_noisefloor;
  1742. p_sops->configure_spectral = p->configure_spectral;
  1743. p_sops->get_spectral_config = p->get_spectral_config;
  1744. p_sops->get_ent_spectral_mask = p->get_ent_spectral_mask;
  1745. p_sops->get_mac_address = p->get_mac_address;
  1746. p_sops->get_current_channel = p->get_current_channel;
  1747. p_sops->reset_hw = p->reset_hw;
  1748. p_sops->get_chain_noise_floor = p->get_chain_noise_floor;
  1749. p_sops->spectral_process_phyerr = p->spectral_process_phyerr;
  1750. p_sops->process_spectral_report = p->process_spectral_report;
  1751. }
  1752. /**
  1753. * target_if_spectral_clear_stats() - Clear Spectral stats
  1754. * @spectral: Pointer to Spectral target_if internal private data
  1755. *
  1756. * Function to clear spectral stats
  1757. *
  1758. * Return: None
  1759. */
  1760. static void
  1761. target_if_spectral_clear_stats(struct target_if_spectral *spectral)
  1762. {
  1763. struct target_if_spectral_ops *p_sops =
  1764. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1765. qdf_mem_zero(&spectral->spectral_stats,
  1766. sizeof(struct target_if_spectral_stats));
  1767. spectral->spectral_stats.last_reset_tstamp =
  1768. p_sops->get_tsf64(spectral);
  1769. }
  1770. /**
  1771. * target_if_spectral_check_hw_capability() - Check whether HW supports spectral
  1772. * @spectral: Pointer to Spectral target_if internal private data
  1773. *
  1774. * Function to check whether hardware supports spectral
  1775. *
  1776. * Return: True if HW supports Spectral, false if HW does not support Spectral
  1777. */
  1778. static int
  1779. target_if_spectral_check_hw_capability(struct target_if_spectral *spectral)
  1780. {
  1781. struct target_if_spectral_ops *p_sops = NULL;
  1782. struct spectral_caps *pcap = NULL;
  1783. int is_spectral_supported = true;
  1784. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  1785. pcap = &spectral->capability;
  1786. if (p_sops->get_capability(spectral, SPECTRAL_CAP_PHYDIAG) == false) {
  1787. is_spectral_supported = false;
  1788. spectral_info("SPECTRAL : No PHYDIAG support");
  1789. return is_spectral_supported;
  1790. }
  1791. pcap->phydiag_cap = 1;
  1792. if (p_sops->get_capability(spectral, SPECTRAL_CAP_RADAR) == false) {
  1793. is_spectral_supported = false;
  1794. spectral_info("SPECTRAL : No RADAR support");
  1795. return is_spectral_supported;
  1796. }
  1797. pcap->radar_cap = 1;
  1798. if (p_sops->get_capability(spectral,
  1799. SPECTRAL_CAP_SPECTRAL_SCAN) == false) {
  1800. is_spectral_supported = false;
  1801. spectral_info("SPECTRAL : No SPECTRAL SUPPORT");
  1802. return is_spectral_supported;
  1803. }
  1804. pcap->spectral_cap = 1;
  1805. if (p_sops->get_capability(spectral, SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN)
  1806. == false) {
  1807. spectral_info("SPECTRAL : No ADVANCED SPECTRAL SUPPORT");
  1808. } else {
  1809. pcap->advncd_spectral_cap = 1;
  1810. }
  1811. return is_spectral_supported;
  1812. }
  1813. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  1814. /**
  1815. * target_if_spectral_detach_simulation() - De-initialize Spectral
  1816. * Simulation functionality
  1817. * @spectral: Pointer to Spectral target_if internal private data
  1818. *
  1819. * Function to de-initialize Spectral Simulation functionality
  1820. *
  1821. * Return: None
  1822. */
  1823. static void
  1824. target_if_spectral_detach_simulation(struct target_if_spectral *spectral)
  1825. {
  1826. target_if_spectral_sim_detach(spectral);
  1827. }
  1828. #else
  1829. static void
  1830. target_if_spectral_detach_simulation(struct target_if_spectral *spectral)
  1831. {
  1832. }
  1833. #endif
  1834. /**
  1835. * target_if_spectral_detach() - De-initialize target_if Spectral
  1836. * @pdev: Pointer to pdev object
  1837. *
  1838. * Function to detach target_if spectral
  1839. *
  1840. * Return: None
  1841. */
  1842. static void
  1843. target_if_spectral_detach(struct target_if_spectral *spectral)
  1844. {
  1845. enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
  1846. spectral_info("spectral detach");
  1847. if (spectral) {
  1848. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  1849. qdf_spinlock_destroy
  1850. (&spectral->param_info[smode].osps_lock);
  1851. target_if_spectral_detach_simulation(spectral);
  1852. qdf_spinlock_destroy(&spectral->spectral_lock);
  1853. qdf_spinlock_destroy(&spectral->noise_pwr_reports_lock);
  1854. qdf_mem_free(spectral);
  1855. spectral = NULL;
  1856. }
  1857. }
  1858. #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION
  1859. /**
  1860. * target_if_spectral_attach_simulation() - Initialize Spectral Simulation
  1861. * functionality
  1862. * @spectral: Pointer to Spectral target_if internal private data
  1863. *
  1864. * Function to initialize spectral simulation functionality
  1865. *
  1866. * Return: 0 on success, negative error code on failure
  1867. */
  1868. static int
  1869. target_if_spectral_attach_simulation(struct target_if_spectral *spectral)
  1870. {
  1871. if (target_if_spectral_sim_attach(spectral)) {
  1872. qdf_mem_free(spectral);
  1873. return -EPERM;
  1874. }
  1875. return 0;
  1876. }
  1877. #else
  1878. static int
  1879. target_if_spectral_attach_simulation(struct target_if_spectral *spectral)
  1880. {
  1881. return 0;
  1882. }
  1883. #endif
  1884. /**
  1885. * target_if_spectral_len_adj_swar_init() - Initialize FFT bin length adjustment
  1886. * related info
  1887. * @swar: Pointer to Spectral FFT bin length adjustment SWAR params
  1888. * @target_type: Target type
  1889. *
  1890. * Function to Initialize parameters related to Spectral FFT bin
  1891. * length adjustment SWARs.
  1892. *
  1893. * Return: void
  1894. */
  1895. static void
  1896. target_if_spectral_len_adj_swar_init(struct spectral_fft_bin_len_adj_swar *swar,
  1897. uint32_t target_type)
  1898. {
  1899. if (target_type == TARGET_TYPE_QCA8074V2 ||
  1900. target_type == TARGET_TYPE_QCN9000 ||
  1901. target_type == TARGET_TYPE_QCN9100 ||
  1902. target_type == TARGET_TYPE_QCA5018 ||
  1903. target_type == TARGET_TYPE_QCA6750 ||
  1904. target_type == TARGET_TYPE_QCA6490)
  1905. swar->fftbin_size_war = SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE;
  1906. else if (target_type == TARGET_TYPE_QCA8074 ||
  1907. target_type == TARGET_TYPE_QCA6018 ||
  1908. target_type == TARGET_TYPE_QCA6390)
  1909. swar->fftbin_size_war = SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE;
  1910. else
  1911. swar->fftbin_size_war = SPECTRAL_FFTBIN_SIZE_NO_WAR;
  1912. if (target_type == TARGET_TYPE_QCA8074 ||
  1913. target_type == TARGET_TYPE_QCA8074V2 ||
  1914. target_type == TARGET_TYPE_QCA6018 ||
  1915. target_type == TARGET_TYPE_QCN9100 ||
  1916. target_type == TARGET_TYPE_QCA5018 ||
  1917. target_type == TARGET_TYPE_QCN9000 ||
  1918. target_type == TARGET_TYPE_QCA6490) {
  1919. swar->inband_fftbin_size_adj = 1;
  1920. swar->null_fftbin_adj = 1;
  1921. } else {
  1922. swar->inband_fftbin_size_adj = 0;
  1923. swar->null_fftbin_adj = 0;
  1924. }
  1925. if ((target_type == TARGET_TYPE_QCA8074V2) ||
  1926. (target_type == TARGET_TYPE_QCN9100))
  1927. swar->packmode_fftbin_size_adj = 1;
  1928. else
  1929. swar->packmode_fftbin_size_adj = 0;
  1930. }
  1931. /**
  1932. * target_if_spectral_report_params_init() - Initialize parameters which
  1933. * describes the structure of Spectral reports
  1934. *
  1935. * @rparams: Pointer to Spectral report parameter object
  1936. * @target_type: target type
  1937. *
  1938. * Function to Initialize parameters related to the structure of Spectral
  1939. * reports.
  1940. *
  1941. * Return: void
  1942. */
  1943. static void
  1944. target_if_spectral_report_params_init(
  1945. struct spectral_report_params *rparams,
  1946. uint32_t target_type)
  1947. {
  1948. enum spectral_scan_mode smode;
  1949. /* This entries are currently used by gen3 chipsets only. Hence
  1950. * initialization is done for gen3 alone. In future if other generations
  1951. * needs to use them they have to add proper initial values.
  1952. */
  1953. if (target_type == TARGET_TYPE_QCN9000 ||
  1954. target_type == TARGET_TYPE_QCA5018 ||
  1955. target_type == TARGET_TYPE_QCA6750 ||
  1956. target_type == TARGET_TYPE_QCA6490) {
  1957. rparams->version = SPECTRAL_REPORT_FORMAT_VERSION_2;
  1958. rparams->num_spectral_detectors =
  1959. NUM_SPECTRAL_DETECTORS_GEN3_V2;
  1960. smode = SPECTRAL_SCAN_MODE_NORMAL;
  1961. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  1962. rparams->fragmentation_160[smode] = false;
  1963. rparams->max_agile_ch_width = CH_WIDTH_80P80MHZ;
  1964. } else {
  1965. rparams->version = SPECTRAL_REPORT_FORMAT_VERSION_1;
  1966. rparams->num_spectral_detectors =
  1967. NUM_SPECTRAL_DETECTORS_GEN3_V1;
  1968. smode = SPECTRAL_SCAN_MODE_NORMAL;
  1969. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  1970. rparams->fragmentation_160[smode] = true;
  1971. rparams->max_agile_ch_width = CH_WIDTH_80MHZ;
  1972. }
  1973. switch (rparams->version) {
  1974. case SPECTRAL_REPORT_FORMAT_VERSION_1:
  1975. rparams->ssumaary_padding_bytes =
  1976. NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V1;
  1977. rparams->fft_report_hdr_len =
  1978. FFT_REPORT_HEADER_LENGTH_GEN3_V1;
  1979. break;
  1980. case SPECTRAL_REPORT_FORMAT_VERSION_2:
  1981. rparams->ssumaary_padding_bytes =
  1982. NUM_PADDING_BYTES_SSCAN_SUMARY_REPORT_GEN3_V2;
  1983. rparams->fft_report_hdr_len =
  1984. FFT_REPORT_HEADER_LENGTH_GEN3_V2;
  1985. break;
  1986. default:
  1987. qdf_assert_always(0);
  1988. }
  1989. rparams->detid_mode_table[SPECTRAL_DETECTOR_ID_0] =
  1990. SPECTRAL_SCAN_MODE_NORMAL;
  1991. if (target_type == TARGET_TYPE_QCN9000 ||
  1992. target_type == TARGET_TYPE_QCA6490) {
  1993. rparams->detid_mode_table[SPECTRAL_DETECTOR_ID_1] =
  1994. SPECTRAL_SCAN_MODE_AGILE;
  1995. rparams->detid_mode_table[SPECTRAL_DETECTOR_ID_2] =
  1996. SPECTRAL_SCAN_MODE_INVALID;
  1997. } else {
  1998. rparams->detid_mode_table[SPECTRAL_DETECTOR_ID_1] =
  1999. SPECTRAL_SCAN_MODE_NORMAL;
  2000. rparams->detid_mode_table[SPECTRAL_DETECTOR_ID_2] =
  2001. SPECTRAL_SCAN_MODE_AGILE;
  2002. }
  2003. }
  2004. /**
  2005. * target_if_spectral_timestamp_war_init() - Initialize Spectral timestamp WAR
  2006. * related info
  2007. * @twar: Pointer to Spectral timstamp WAR related info
  2008. *
  2009. * Function to Initialize parameters related to Spectral timestamp WAR
  2010. *
  2011. * Return: void
  2012. */
  2013. static void
  2014. target_if_spectral_timestamp_war_init(struct spectral_timestamp_war *twar)
  2015. {
  2016. enum spectral_scan_mode smode;
  2017. smode = SPECTRAL_SCAN_MODE_NORMAL;
  2018. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
  2019. twar->last_fft_timestamp[smode] = 0;
  2020. twar->timestamp_war_offset[smode] = 0;
  2021. }
  2022. twar->target_reset_count = 0;
  2023. }
  2024. /**
  2025. * target_if_pdev_spectral_init() - Initialize target_if Spectral
  2026. * functionality for the given pdev
  2027. * @pdev: Pointer to pdev object
  2028. *
  2029. * Function to initialize pointer to spectral target_if internal private data
  2030. *
  2031. * Return: On success, pointer to Spectral target_if internal private data, on
  2032. * failure, NULL
  2033. */
  2034. void *
  2035. target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev)
  2036. {
  2037. struct target_if_spectral_ops *p_sops = NULL;
  2038. struct target_if_spectral *spectral = NULL;
  2039. uint32_t target_type;
  2040. uint32_t target_revision;
  2041. struct wlan_objmgr_psoc *psoc;
  2042. struct wlan_lmac_if_target_tx_ops *tgt_tx_ops;
  2043. enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL;
  2044. QDF_STATUS status;
  2045. struct wlan_lmac_if_tx_ops *tx_ops;
  2046. if (!pdev) {
  2047. spectral_err("SPECTRAL: pdev is NULL!");
  2048. return NULL;
  2049. }
  2050. spectral = (struct target_if_spectral *)qdf_mem_malloc(
  2051. sizeof(struct target_if_spectral));
  2052. if (!spectral)
  2053. return spectral;
  2054. qdf_mem_zero(spectral, sizeof(struct target_if_spectral));
  2055. /* Store pdev in Spectral */
  2056. spectral->pdev_obj = pdev;
  2057. spectral->vdev_id[SPECTRAL_SCAN_MODE_NORMAL] = WLAN_INVALID_VDEV_ID;
  2058. spectral->vdev_id[SPECTRAL_SCAN_MODE_AGILE] = WLAN_INVALID_VDEV_ID;
  2059. psoc = wlan_pdev_get_psoc(pdev);
  2060. tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
  2061. if (!tx_ops) {
  2062. spectral_err("tx_ops is NULL");
  2063. qdf_mem_free(spectral);
  2064. return NULL;
  2065. }
  2066. tgt_tx_ops = &tx_ops->target_tx_ops;
  2067. if (tgt_tx_ops->tgt_get_tgt_type) {
  2068. target_type = tgt_tx_ops->tgt_get_tgt_type(psoc);
  2069. } else {
  2070. qdf_mem_free(spectral);
  2071. return NULL;
  2072. }
  2073. if (tgt_tx_ops->tgt_get_tgt_revision) {
  2074. target_revision = tgt_tx_ops->tgt_get_tgt_revision(psoc);
  2075. } else {
  2076. qdf_mem_free(spectral);
  2077. return NULL;
  2078. }
  2079. /* init the function ptr table */
  2080. target_if_spectral_init_dummy_function_table(spectral);
  2081. /* get spectral function table */
  2082. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  2083. /* TODO : Should this be called here of after ath_attach ? */
  2084. if (p_sops->get_capability(spectral, SPECTRAL_CAP_PHYDIAG))
  2085. spectral_info("HAL_CAP_PHYDIAG : Capable");
  2086. /* TODO: Need to fix the capablity check for RADAR */
  2087. if (p_sops->get_capability(spectral, SPECTRAL_CAP_RADAR))
  2088. spectral_info("HAL_CAP_RADAR : Capable");
  2089. /* TODO : Need to fix the capablity check for SPECTRAL */
  2090. /* TODO : Should this be called here of after ath_attach ? */
  2091. if (p_sops->get_capability(spectral, SPECTRAL_CAP_SPECTRAL_SCAN))
  2092. spectral_info("HAL_CAP_SPECTRAL_SCAN : Capable");
  2093. qdf_spinlock_create(&spectral->spectral_lock);
  2094. qdf_spinlock_create(&spectral->noise_pwr_reports_lock);
  2095. target_if_spectral_clear_stats(spectral);
  2096. if (target_type == TARGET_TYPE_QCA8074 ||
  2097. target_type == TARGET_TYPE_QCA8074V2 ||
  2098. target_type == TARGET_TYPE_QCA6018 ||
  2099. target_type == TARGET_TYPE_QCA5018 ||
  2100. target_type == TARGET_TYPE_QCA6390 ||
  2101. target_type == TARGET_TYPE_QCN9100 ||
  2102. target_type == TARGET_TYPE_QCA6490 ||
  2103. target_type == TARGET_TYPE_QCN9000 ||
  2104. target_type == TARGET_TYPE_QCA6750)
  2105. spectral->direct_dma_support = true;
  2106. target_if_spectral_len_adj_swar_init(&spectral->len_adj_swar,
  2107. target_type);
  2108. target_if_spectral_report_params_init(&spectral->rparams, target_type);
  2109. if ((target_type == TARGET_TYPE_QCA8074) ||
  2110. (target_type == TARGET_TYPE_QCA8074V2) ||
  2111. (target_type == TARGET_TYPE_QCA6018) ||
  2112. (target_type == TARGET_TYPE_QCA5018) ||
  2113. (target_type == TARGET_TYPE_QCN9100) ||
  2114. (target_type == TARGET_TYPE_QCN9000) ||
  2115. (target_type == TARGET_TYPE_QCA6290) ||
  2116. (target_type == TARGET_TYPE_QCA6390) ||
  2117. (target_type == TARGET_TYPE_QCA6490) ||
  2118. (target_type == TARGET_TYPE_QCA6750)) {
  2119. spectral->spectral_gen = SPECTRAL_GEN3;
  2120. spectral->hdr_sig_exp = SPECTRAL_PHYERR_SIGNATURE_GEN3;
  2121. spectral->tag_sscan_summary_exp =
  2122. TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3;
  2123. spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN3;
  2124. spectral->tlvhdr_size = SPECTRAL_PHYERR_TLVSIZE_GEN3;
  2125. } else {
  2126. spectral->spectral_gen = SPECTRAL_GEN2;
  2127. spectral->hdr_sig_exp = SPECTRAL_PHYERR_SIGNATURE_GEN2;
  2128. spectral->tag_sscan_summary_exp =
  2129. TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2;
  2130. spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN2;
  2131. spectral->tlvhdr_size = sizeof(struct spectral_phyerr_tlv_gen2);
  2132. }
  2133. status = target_if_init_spectral_param_min_max(
  2134. &spectral->param_min_max,
  2135. spectral->spectral_gen, target_type);
  2136. if (QDF_IS_STATUS_ERROR(status)) {
  2137. spectral_err("Failed to initialize parameter min max values");
  2138. goto fail;
  2139. }
  2140. target_if_init_spectral_param_properties(spectral);
  2141. /* Init spectral capability */
  2142. if (target_if_init_spectral_capability(spectral, target_type) !=
  2143. QDF_STATUS_SUCCESS) {
  2144. qdf_mem_free(spectral);
  2145. return NULL;
  2146. }
  2147. if (target_if_spectral_attach_simulation(spectral) < 0)
  2148. return NULL;
  2149. target_if_init_spectral_ops(spectral);
  2150. target_if_spectral_timestamp_war_init(&spectral->timestamp_war);
  2151. /* Spectral mode specific init */
  2152. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
  2153. spectral->params_valid[smode] = false;
  2154. qdf_spinlock_create(&spectral->param_info[smode].osps_lock);
  2155. spectral->param_info[smode].osps_cache.osc_is_valid = 0;
  2156. }
  2157. target_if_spectral_register_funcs(spectral, &spectral_ops);
  2158. if (target_if_spectral_check_hw_capability(spectral) == false) {
  2159. goto fail;
  2160. } else {
  2161. /*
  2162. * TODO: Once the driver architecture transitions to chipset
  2163. * versioning based checks, reflect this here.
  2164. */
  2165. spectral->is_160_format = false;
  2166. spectral->is_lb_edge_extrabins_format = false;
  2167. spectral->is_rb_edge_extrabins_format = false;
  2168. if (target_type == TARGET_TYPE_QCA9984 ||
  2169. target_type == TARGET_TYPE_QCA9888) {
  2170. spectral->is_160_format = true;
  2171. spectral->is_lb_edge_extrabins_format = true;
  2172. spectral->is_rb_edge_extrabins_format = true;
  2173. } else if ((target_type == TARGET_TYPE_AR900B) &&
  2174. (target_revision == AR900B_REV_2)) {
  2175. spectral->is_rb_edge_extrabins_format = true;
  2176. }
  2177. if (target_type == TARGET_TYPE_QCA9984 ||
  2178. target_type == TARGET_TYPE_QCA9888)
  2179. spectral->is_sec80_rssi_war_required = true;
  2180. spectral->use_nl_bcast = SPECTRAL_USE_NL_BCAST;
  2181. if (spectral->spectral_gen == SPECTRAL_GEN3)
  2182. init_160mhz_delivery_state_machine(spectral);
  2183. }
  2184. return spectral;
  2185. fail:
  2186. target_if_spectral_detach(spectral);
  2187. return NULL;
  2188. }
  2189. /**
  2190. * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral
  2191. * functionality for the given pdev
  2192. * @pdev: Pointer to pdev object
  2193. *
  2194. * Function to de-initialize pointer to spectral target_if internal private data
  2195. *
  2196. * Return: None
  2197. */
  2198. void
  2199. target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev)
  2200. {
  2201. struct target_if_spectral *spectral = NULL;
  2202. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  2203. if (!spectral) {
  2204. spectral_err("SPECTRAL : Module doesn't exist");
  2205. return;
  2206. }
  2207. target_if_spectral_detach(spectral);
  2208. return;
  2209. }
  2210. /**
  2211. * target_if_psoc_spectral_deinit() - De-initialize target_if Spectral
  2212. * functionality for the given psoc
  2213. * @psoc: Pointer to psoc object
  2214. *
  2215. * Function to de-initialize pointer to psoc spectral target_if internal
  2216. * private data
  2217. *
  2218. * Return: None
  2219. */
  2220. static void
  2221. target_if_psoc_spectral_deinit(struct wlan_objmgr_psoc *psoc)
  2222. {
  2223. struct target_if_psoc_spectral *psoc_spectral;
  2224. if (!psoc) {
  2225. spectral_err("psoc is null");
  2226. return;
  2227. }
  2228. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  2229. if (!psoc_spectral) {
  2230. spectral_err("Spectral target_if psoc object is null");
  2231. return;
  2232. }
  2233. qdf_mem_free(psoc_spectral);
  2234. }
  2235. /**
  2236. * target_if_psoc_spectral_init() - Initialize target_if Spectral
  2237. * functionality for the given psoc
  2238. * @psoc: Pointer to psoc object
  2239. *
  2240. * Function to initialize pointer to psoc spectral target_if internal
  2241. * private data
  2242. *
  2243. * Return: On success, pointer to Spectral psoc target_if internal
  2244. * private data, on failure, NULL
  2245. */
  2246. static void *
  2247. target_if_psoc_spectral_init(struct wlan_objmgr_psoc *psoc)
  2248. {
  2249. struct target_if_psoc_spectral *psoc_spectral = NULL;
  2250. if (!psoc) {
  2251. spectral_err("psoc is null");
  2252. goto fail;
  2253. }
  2254. psoc_spectral = (struct target_if_psoc_spectral *)qdf_mem_malloc(
  2255. sizeof(struct target_if_psoc_spectral));
  2256. if (!psoc_spectral) {
  2257. spectral_err("Spectral lmac psoc object allocation failed");
  2258. goto fail;
  2259. }
  2260. psoc_spectral->psoc_obj = psoc;
  2261. return psoc_spectral;
  2262. fail:
  2263. if (psoc_spectral)
  2264. target_if_psoc_spectral_deinit(psoc);
  2265. return psoc_spectral;
  2266. }
  2267. /* target_if_spectral_find_agile_width() - Given a channel width enum, find the
  2268. * corresponding translation for Agile channel width.
  2269. * @spectral: pointer to Spectral object
  2270. * @chwidth: operating channel width
  2271. * @is_80_80_agile: Indicates an 80+80 agile Scan request
  2272. *
  2273. * Return: The translated channel width enum.
  2274. */
  2275. static enum phy_ch_width
  2276. target_if_spectral_find_agile_width(struct target_if_spectral *spectral,
  2277. enum phy_ch_width chwidth,
  2278. bool is_80_80_agile)
  2279. {
  2280. enum phy_ch_width agile_width;
  2281. struct wlan_objmgr_pdev *pdev;
  2282. struct wlan_objmgr_psoc *psoc;
  2283. if (!spectral) {
  2284. spectral_err("Spectral object is null");
  2285. return CH_WIDTH_INVALID;
  2286. }
  2287. pdev = spectral->pdev_obj;
  2288. if (!pdev) {
  2289. spectral_err("pdev is null");
  2290. return CH_WIDTH_INVALID;
  2291. }
  2292. psoc = wlan_pdev_get_psoc(pdev);
  2293. if (!psoc) {
  2294. spectral_err("psoc is null");
  2295. return CH_WIDTH_INVALID;
  2296. }
  2297. switch (chwidth) {
  2298. case CH_WIDTH_20MHZ:
  2299. agile_width = CH_WIDTH_20MHZ;
  2300. break;
  2301. case CH_WIDTH_40MHZ:
  2302. agile_width = CH_WIDTH_40MHZ;
  2303. break;
  2304. case CH_WIDTH_80MHZ:
  2305. agile_width = CH_WIDTH_80MHZ;
  2306. break;
  2307. case CH_WIDTH_80P80MHZ:
  2308. if (wlan_psoc_nif_fw_ext_cap_get(psoc,
  2309. WLAN_SOC_RESTRICTED_80P80_SUPPORT) && !is_80_80_agile)
  2310. agile_width = CH_WIDTH_160MHZ;
  2311. else
  2312. agile_width = CH_WIDTH_80P80MHZ;
  2313. if (agile_width > spectral->rparams.max_agile_ch_width)
  2314. agile_width = spectral->rparams.max_agile_ch_width;
  2315. break;
  2316. case CH_WIDTH_160MHZ:
  2317. if (wlan_psoc_nif_fw_ext_cap_get(psoc,
  2318. WLAN_SOC_RESTRICTED_80P80_SUPPORT) && is_80_80_agile)
  2319. agile_width = CH_WIDTH_80P80MHZ;
  2320. else
  2321. agile_width = CH_WIDTH_160MHZ;
  2322. if (agile_width > spectral->rparams.max_agile_ch_width)
  2323. agile_width = spectral->rparams.max_agile_ch_width;
  2324. break;
  2325. default:
  2326. spectral_err("Invalid channel width %d", chwidth);
  2327. agile_width = CH_WIDTH_INVALID;
  2328. break;
  2329. }
  2330. return agile_width;
  2331. }
  2332. /**
  2333. * target_if_calculate_center_freq() - Helper routine to
  2334. * check whether given frequency is center frequency of a
  2335. * WLAN channel
  2336. *
  2337. * @spectral: Pointer to Spectral object
  2338. * @chan_freq: Center frequency of a WLAN channel
  2339. * @is_valid: Indicates whether given frequency is valid
  2340. *
  2341. * Return: QDF_STATUS
  2342. */
  2343. static QDF_STATUS
  2344. target_if_is_center_freq_of_any_chan(struct wlan_objmgr_pdev *pdev,
  2345. uint32_t chan_freq,
  2346. bool *is_valid)
  2347. {
  2348. struct regulatory_channel *cur_chan_list;
  2349. int i;
  2350. if (!pdev) {
  2351. spectral_err("pdev object is null");
  2352. return QDF_STATUS_E_FAILURE;
  2353. }
  2354. if (!is_valid) {
  2355. spectral_err("is valid argument is null");
  2356. return QDF_STATUS_E_FAILURE;
  2357. }
  2358. cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * sizeof(*cur_chan_list));
  2359. if (!cur_chan_list)
  2360. return QDF_STATUS_E_FAILURE;
  2361. if (wlan_reg_get_current_chan_list(
  2362. pdev, cur_chan_list) != QDF_STATUS_SUCCESS) {
  2363. spectral_err("Failed to get cur_chan list");
  2364. qdf_mem_free(cur_chan_list);
  2365. return QDF_STATUS_E_FAILURE;
  2366. }
  2367. *is_valid = false;
  2368. for (i = 0; i < NUM_CHANNELS; i++) {
  2369. uint32_t flags;
  2370. uint32_t center_freq;
  2371. flags = cur_chan_list[i].chan_flags;
  2372. center_freq = cur_chan_list[i].center_freq;
  2373. if (!(flags & REGULATORY_CHAN_DISABLED) &&
  2374. (center_freq == chan_freq)) {
  2375. *is_valid = true;
  2376. break;
  2377. }
  2378. }
  2379. qdf_mem_free(cur_chan_list);
  2380. return QDF_STATUS_SUCCESS;
  2381. }
  2382. /**
  2383. * target_if_calculate_center_freq() - Helper routine to
  2384. * find the center frequency of the agile span from a
  2385. * WLAN channel center frequency
  2386. *
  2387. * @spectral: Pointer to Spectral object
  2388. * @ch_width: Channel width array
  2389. * @chan_freq: Center frequency of a WLAN channel
  2390. * @center_freq: Pointer to center frequency
  2391. *
  2392. * Return: QDF_STATUS
  2393. */
  2394. static QDF_STATUS
  2395. target_if_calculate_center_freq(struct target_if_spectral *spectral,
  2396. enum phy_ch_width *ch_width,
  2397. uint16_t chan_freq,
  2398. uint16_t *center_freq)
  2399. {
  2400. enum phy_ch_width agile_ch_width;
  2401. if (!spectral) {
  2402. spectral_err("spectral target if object is null");
  2403. return QDF_STATUS_E_FAILURE;
  2404. }
  2405. if (!ch_width) {
  2406. spectral_err("Channel width array is null");
  2407. return QDF_STATUS_E_INVAL;
  2408. }
  2409. agile_ch_width = ch_width[SPECTRAL_SCAN_MODE_AGILE];
  2410. if (!center_freq) {
  2411. spectral_err("center_freq argument is null");
  2412. return QDF_STATUS_E_FAILURE;
  2413. }
  2414. if (agile_ch_width == CH_WIDTH_20MHZ) {
  2415. *center_freq = chan_freq;
  2416. } else {
  2417. uint16_t start_freq;
  2418. uint16_t end_freq;
  2419. const struct bonded_channel_freq *bonded_chan_ptr = NULL;
  2420. enum channel_state state;
  2421. state = wlan_reg_get_5g_bonded_channel_and_state_for_freq
  2422. (spectral->pdev_obj, chan_freq, agile_ch_width,
  2423. &bonded_chan_ptr);
  2424. if (state == CHANNEL_STATE_DISABLE ||
  2425. state == CHANNEL_STATE_INVALID) {
  2426. spectral_err("Channel state is disable or invalid");
  2427. return QDF_STATUS_E_FAILURE;
  2428. }
  2429. if (!bonded_chan_ptr) {
  2430. spectral_err("Bonded channel is not found");
  2431. return QDF_STATUS_E_FAILURE;
  2432. }
  2433. start_freq = bonded_chan_ptr->start_freq;
  2434. end_freq = bonded_chan_ptr->end_freq;
  2435. *center_freq = (start_freq + end_freq) >> 1;
  2436. }
  2437. return QDF_STATUS_SUCCESS;
  2438. }
  2439. /**
  2440. * target_if_validate_center_freq() - Helper routine to
  2441. * validate user provided agile center frequency
  2442. *
  2443. * @spectral: Pointer to Spectral object
  2444. * @ch_width: Channel width array
  2445. * @center_freq: User provided agile span center frequency
  2446. * @is_valid: Indicates whether agile span center frequency is valid
  2447. *
  2448. * Return: QDF_STATUS
  2449. */
  2450. static QDF_STATUS
  2451. target_if_validate_center_freq(struct target_if_spectral *spectral,
  2452. enum phy_ch_width *ch_width,
  2453. uint16_t center_freq,
  2454. bool *is_valid)
  2455. {
  2456. enum phy_ch_width agile_ch_width;
  2457. struct wlan_objmgr_pdev *pdev;
  2458. QDF_STATUS status;
  2459. if (!spectral) {
  2460. spectral_err("spectral target if object is null");
  2461. return QDF_STATUS_E_FAILURE;
  2462. }
  2463. if (!ch_width) {
  2464. spectral_err("channel width array is null");
  2465. return QDF_STATUS_E_INVAL;
  2466. }
  2467. agile_ch_width = ch_width[SPECTRAL_SCAN_MODE_AGILE];
  2468. if (!is_valid) {
  2469. spectral_err("is_valid argument is null");
  2470. return QDF_STATUS_E_FAILURE;
  2471. }
  2472. pdev = spectral->pdev_obj;
  2473. if (agile_ch_width == CH_WIDTH_20MHZ) {
  2474. status = target_if_is_center_freq_of_any_chan
  2475. (pdev, center_freq, is_valid);
  2476. if (QDF_IS_STATUS_ERROR(status))
  2477. return QDF_STATUS_E_FAILURE;
  2478. } else {
  2479. uint16_t start_freq;
  2480. uint16_t end_freq;
  2481. const struct bonded_channel_freq *bonded_chan_ptr = NULL;
  2482. bool is_chan;
  2483. status = target_if_is_center_freq_of_any_chan
  2484. (pdev, center_freq + FREQ_OFFSET_10MHZ,
  2485. &is_chan);
  2486. if (QDF_IS_STATUS_ERROR(status))
  2487. return QDF_STATUS_E_FAILURE;
  2488. if (is_chan) {
  2489. uint32_t calulated_center_freq;
  2490. enum channel_state st;
  2491. st = wlan_reg_get_5g_bonded_channel_and_state_for_freq
  2492. (pdev, center_freq + FREQ_OFFSET_10MHZ,
  2493. agile_ch_width,
  2494. &bonded_chan_ptr);
  2495. if (st == CHANNEL_STATE_DISABLE ||
  2496. st == CHANNEL_STATE_INVALID) {
  2497. spectral_err("Channel state disable/invalid");
  2498. return QDF_STATUS_E_FAILURE;
  2499. }
  2500. if (!bonded_chan_ptr) {
  2501. spectral_err("Bonded channel is not found");
  2502. return QDF_STATUS_E_FAILURE;
  2503. }
  2504. start_freq = bonded_chan_ptr->start_freq;
  2505. end_freq = bonded_chan_ptr->end_freq;
  2506. calulated_center_freq = (start_freq + end_freq) >> 1;
  2507. *is_valid = (center_freq == calulated_center_freq);
  2508. } else {
  2509. *is_valid = false;
  2510. }
  2511. }
  2512. return QDF_STATUS_SUCCESS;
  2513. }
  2514. /**
  2515. * target_if_is_agile_span_overlap_with_operating_span() - Helper routine to
  2516. * check whether agile span overlaps with current operating band.
  2517. *
  2518. * @spectral: Pointer to Spectral object
  2519. * @ch_width: Channel width array
  2520. * @center_freq: Agile span center frequency
  2521. * @is_overlapping: Indicates whether Agile span overlaps with operating span
  2522. *
  2523. * Helper routine to check whether agile span overlaps with current
  2524. * operating band.
  2525. *
  2526. * Return: QDF_STATUS
  2527. */
  2528. static QDF_STATUS
  2529. target_if_is_agile_span_overlap_with_operating_span
  2530. (struct target_if_spectral *spectral,
  2531. enum phy_ch_width *ch_width,
  2532. struct spectral_config_frequency *center_freq,
  2533. bool *is_overlapping)
  2534. {
  2535. enum phy_ch_width op_ch_width;
  2536. enum phy_ch_width agile_ch_width;
  2537. const struct bonded_channel_freq *bonded_chan_ptr = NULL;
  2538. struct wlan_objmgr_vdev *vdev;
  2539. struct wlan_objmgr_pdev *pdev;
  2540. int16_t chan_freq;
  2541. uint32_t op_start_freq;
  2542. uint32_t op_end_freq;
  2543. uint32_t agile_start_freq;
  2544. uint32_t agile_end_freq;
  2545. uint32_t cfreq2;
  2546. if (!spectral) {
  2547. spectral_err("Spectral object is NULL");
  2548. return QDF_STATUS_E_FAILURE;
  2549. }
  2550. pdev = spectral->pdev_obj;
  2551. if (!pdev) {
  2552. spectral_err("pdev object is NULL");
  2553. return QDF_STATUS_E_FAILURE;
  2554. }
  2555. if (!ch_width) {
  2556. spectral_err("channel width array is null");
  2557. return QDF_STATUS_E_FAILURE;
  2558. }
  2559. op_ch_width = ch_width[SPECTRAL_SCAN_MODE_NORMAL];
  2560. if (op_ch_width == CH_WIDTH_INVALID) {
  2561. spectral_err("Invalid channel width");
  2562. return QDF_STATUS_E_INVAL;
  2563. }
  2564. agile_ch_width = ch_width[SPECTRAL_SCAN_MODE_AGILE];
  2565. if (agile_ch_width == CH_WIDTH_INVALID) {
  2566. spectral_err("Invalid channel width");
  2567. return QDF_STATUS_E_INVAL;
  2568. }
  2569. if (!is_overlapping) {
  2570. spectral_err("Argument(is_overlapping) is NULL");
  2571. return QDF_STATUS_E_FAILURE;
  2572. }
  2573. *is_overlapping = false;
  2574. vdev = target_if_spectral_get_vdev(spectral, SPECTRAL_SCAN_MODE_AGILE);
  2575. if (!vdev) {
  2576. spectral_err("vdev is NULL");
  2577. return QDF_STATUS_E_FAILURE;
  2578. }
  2579. chan_freq = target_if_vdev_get_chan_freq(vdev);
  2580. cfreq2 = target_if_vdev_get_chan_freq_seg2(vdev);
  2581. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  2582. if (cfreq2 < 0) {
  2583. spectral_err("cfreq2 is invalid");
  2584. return QDF_STATUS_E_FAILURE;
  2585. }
  2586. if (op_ch_width == CH_WIDTH_20MHZ) {
  2587. op_start_freq = chan_freq - FREQ_OFFSET_10MHZ;
  2588. op_end_freq = chan_freq + FREQ_OFFSET_10MHZ;
  2589. } else {
  2590. enum channel_state state;
  2591. state = wlan_reg_get_5g_bonded_channel_and_state_for_freq
  2592. (pdev, chan_freq, op_ch_width, &bonded_chan_ptr);
  2593. if (state == CHANNEL_STATE_DISABLE ||
  2594. state == CHANNEL_STATE_INVALID) {
  2595. spectral_err("Channel state is disable or invalid");
  2596. return QDF_STATUS_E_FAILURE;
  2597. }
  2598. if (!bonded_chan_ptr) {
  2599. spectral_err("Bonded channel is not found");
  2600. return QDF_STATUS_E_FAILURE;
  2601. }
  2602. op_start_freq = bonded_chan_ptr->start_freq - FREQ_OFFSET_10MHZ;
  2603. op_end_freq = bonded_chan_ptr->end_freq - FREQ_OFFSET_10MHZ;
  2604. }
  2605. if (agile_ch_width == CH_WIDTH_80P80MHZ) {
  2606. agile_start_freq = center_freq->cfreq1 - FREQ_OFFSET_40MHZ;
  2607. agile_end_freq = center_freq->cfreq1 + FREQ_OFFSET_40MHZ;
  2608. if (agile_end_freq > op_start_freq &&
  2609. op_end_freq > agile_start_freq)
  2610. *is_overlapping = true;
  2611. agile_start_freq = center_freq->cfreq2 - FREQ_OFFSET_40MHZ;
  2612. agile_end_freq = center_freq->cfreq2 + FREQ_OFFSET_40MHZ;
  2613. if (agile_end_freq > op_start_freq &&
  2614. op_end_freq > agile_start_freq)
  2615. *is_overlapping = true;
  2616. } else {
  2617. agile_start_freq = center_freq->cfreq1 -
  2618. (wlan_reg_get_bw_value(agile_ch_width) >> 1);
  2619. agile_end_freq = center_freq->cfreq1 +
  2620. (wlan_reg_get_bw_value(agile_ch_width) >> 1);
  2621. if (agile_end_freq > op_start_freq &&
  2622. op_end_freq > agile_start_freq)
  2623. *is_overlapping = true;
  2624. }
  2625. if (op_ch_width == CH_WIDTH_80P80MHZ) {
  2626. uint32_t sec80_start_feq;
  2627. uint32_t sec80_end_freq;
  2628. sec80_start_feq = cfreq2 - FREQ_OFFSET_40MHZ;
  2629. sec80_end_freq = cfreq2 + FREQ_OFFSET_40MHZ;
  2630. if (agile_ch_width == CH_WIDTH_80P80MHZ) {
  2631. agile_start_freq =
  2632. center_freq->cfreq1 - FREQ_OFFSET_40MHZ;
  2633. agile_end_freq =
  2634. center_freq->cfreq1 + FREQ_OFFSET_40MHZ;
  2635. if (agile_end_freq > sec80_start_feq &&
  2636. sec80_end_freq > agile_start_freq)
  2637. *is_overlapping = true;
  2638. agile_start_freq =
  2639. center_freq->cfreq2 - FREQ_OFFSET_40MHZ;
  2640. agile_end_freq =
  2641. center_freq->cfreq2 + FREQ_OFFSET_40MHZ;
  2642. if (agile_end_freq > sec80_start_feq &&
  2643. sec80_end_freq > agile_start_freq)
  2644. *is_overlapping = true;
  2645. } else {
  2646. agile_start_freq = center_freq->cfreq1 -
  2647. (wlan_reg_get_bw_value(agile_ch_width) >> 1);
  2648. agile_end_freq = center_freq->cfreq1 +
  2649. (wlan_reg_get_bw_value(agile_ch_width) >> 1);
  2650. if (agile_end_freq > sec80_start_feq &&
  2651. sec80_end_freq > agile_start_freq)
  2652. *is_overlapping = true;
  2653. }
  2654. }
  2655. return QDF_STATUS_SUCCESS;
  2656. }
  2657. /**
  2658. * target_if_spectral_populate_chwidth() - Helper routine to
  2659. * populate channel width for different Spectral modes
  2660. *
  2661. * @spectral: Pointer to Spectral object
  2662. * @ch_width: Channel width array
  2663. * @is_80_80_agile: Indicates whether 80+80 agile scan is requested
  2664. *
  2665. * Helper routine to populate channel width for different Spectral modes
  2666. *
  2667. * Return: QDF_STATUS
  2668. */
  2669. static QDF_STATUS
  2670. target_if_spectral_populate_chwidth(struct target_if_spectral *spectral,
  2671. enum phy_ch_width *ch_width,
  2672. bool is_80_80_agile) {
  2673. struct wlan_objmgr_vdev *vdev;
  2674. enum spectral_scan_mode smode;
  2675. enum phy_ch_width vdev_ch_width;
  2676. smode = SPECTRAL_SCAN_MODE_NORMAL;
  2677. for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++)
  2678. ch_width[smode] = CH_WIDTH_INVALID;
  2679. if (!spectral) {
  2680. spectral_err("Spectral object is null");
  2681. return QDF_STATUS_E_INVAL;
  2682. }
  2683. vdev = target_if_spectral_get_vdev(spectral, SPECTRAL_SCAN_MODE_NORMAL);
  2684. if (!vdev) {
  2685. spectral_err("vdev is null");
  2686. return QDF_STATUS_E_FAILURE;
  2687. }
  2688. vdev_ch_width = target_if_vdev_get_ch_width(vdev);
  2689. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  2690. if (vdev_ch_width == CH_WIDTH_INVALID) {
  2691. spectral_err("Invalid channel width %d", vdev_ch_width);
  2692. return QDF_STATUS_E_FAILURE;
  2693. }
  2694. ch_width[SPECTRAL_SCAN_MODE_NORMAL] = vdev_ch_width;
  2695. ch_width[SPECTRAL_SCAN_MODE_AGILE] =
  2696. target_if_spectral_find_agile_width(spectral, vdev_ch_width,
  2697. is_80_80_agile);
  2698. return QDF_STATUS_SUCCESS;
  2699. }
  2700. /**
  2701. * target_if_spectral_is_valid_80p80_freq() - API to check whether given
  2702. * (cfreq1, cfreq2) pair forms a valid 80+80 combination
  2703. * @pdev: pointer to pdev
  2704. * @cfreq1: center frequency 1
  2705. * @cfreq2: center frequency 2
  2706. *
  2707. * API to check whether given (cfreq1, cfreq2) pair forms a valid 80+80
  2708. * combination
  2709. *
  2710. * Return: true or false
  2711. */
  2712. static bool
  2713. target_if_spectral_is_valid_80p80_freq(struct wlan_objmgr_pdev *pdev,
  2714. uint32_t cfreq1, uint32_t cfreq2)
  2715. {
  2716. struct ch_params ch_params;
  2717. enum channel_state chan_state1;
  2718. enum channel_state chan_state2;
  2719. struct wlan_objmgr_psoc *psoc;
  2720. qdf_assert_always(pdev);
  2721. psoc = wlan_pdev_get_psoc(pdev);
  2722. qdf_assert_always(psoc);
  2723. /* In restricted 80P80 MHz enabled, only one 80+80 MHz
  2724. * channel is supported with cfreq=5690 and cfreq=5775.
  2725. */
  2726. if (wlan_psoc_nif_fw_ext_cap_get(
  2727. psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT))
  2728. return CHAN_WITHIN_RESTRICTED_80P80(cfreq1, cfreq2);
  2729. ch_params.center_freq_seg1 = wlan_reg_freq_to_chan(pdev, cfreq2);
  2730. ch_params.mhz_freq_seg1 = cfreq2;
  2731. ch_params.ch_width = CH_WIDTH_80P80MHZ;
  2732. wlan_reg_set_channel_params_for_freq(pdev, cfreq1 - FREQ_OFFSET_10MHZ,
  2733. 0, &ch_params);
  2734. if (ch_params.ch_width != CH_WIDTH_80P80MHZ)
  2735. return false;
  2736. if (ch_params.mhz_freq_seg0 != cfreq1 ||
  2737. ch_params.mhz_freq_seg1 != cfreq2)
  2738. return false;
  2739. chan_state1 = wlan_reg_get_5g_bonded_channel_state_for_freq(
  2740. pdev,
  2741. ch_params.mhz_freq_seg0 - FREQ_OFFSET_10MHZ,
  2742. CH_WIDTH_80MHZ);
  2743. if ((chan_state1 == CHANNEL_STATE_DISABLE) ||
  2744. (chan_state1 == CHANNEL_STATE_INVALID))
  2745. return false;
  2746. chan_state2 = wlan_reg_get_5g_bonded_channel_state_for_freq(
  2747. pdev,
  2748. ch_params.mhz_freq_seg1 - FREQ_OFFSET_10MHZ,
  2749. CH_WIDTH_80MHZ);
  2750. if ((chan_state2 == CHANNEL_STATE_DISABLE) ||
  2751. (chan_state2 == CHANNEL_STATE_INVALID))
  2752. return false;
  2753. if (abs(ch_params.mhz_freq_seg0 - ch_params.mhz_freq_seg1) <=
  2754. FREQ_OFFSET_80MHZ)
  2755. return false;
  2756. return true;
  2757. }
  2758. /**
  2759. * _target_if_set_spectral_config() - Set spectral config
  2760. * @spectral: Pointer to spectral object
  2761. * @param: Spectral parameter id and value
  2762. * @smode: Spectral scan mode
  2763. * @err: Spectral error code
  2764. *
  2765. * API to set spectral configurations
  2766. *
  2767. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  2768. */
  2769. static QDF_STATUS
  2770. _target_if_set_spectral_config(struct target_if_spectral *spectral,
  2771. const struct spectral_cp_param *param,
  2772. const enum spectral_scan_mode smode,
  2773. enum spectral_cp_error_code *err)
  2774. {
  2775. struct spectral_config params;
  2776. struct target_if_spectral_ops *p_sops;
  2777. struct spectral_config *sparams;
  2778. QDF_STATUS status;
  2779. bool is_overlapping;
  2780. uint16_t agile_cfreq;
  2781. bool is_valid_chan;
  2782. struct spectral_param_min_max *param_min_max;
  2783. enum phy_ch_width ch_width[SPECTRAL_SCAN_MODE_MAX];
  2784. enum spectral_scan_mode m;
  2785. struct spectral_config_frequency center_freq = {0};
  2786. if (!err) {
  2787. spectral_err("Error code argument is null");
  2788. QDF_ASSERT(0);
  2789. return QDF_STATUS_E_FAILURE;
  2790. }
  2791. *err = SPECTRAL_SCAN_ERR_INVALID;
  2792. if (!param) {
  2793. spectral_err("Parameter object is null");
  2794. return QDF_STATUS_E_FAILURE;
  2795. }
  2796. if (!spectral) {
  2797. spectral_err("spectral object is NULL");
  2798. return QDF_STATUS_E_FAILURE;
  2799. }
  2800. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  2801. param_min_max = &spectral->param_min_max;
  2802. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  2803. spectral_err("Invalid Spectral mode %u", smode);
  2804. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  2805. return QDF_STATUS_E_FAILURE;
  2806. }
  2807. sparams = &spectral->params[smode];
  2808. m = SPECTRAL_SCAN_MODE_NORMAL;
  2809. for (; m < SPECTRAL_SCAN_MODE_MAX; m++)
  2810. ch_width[m] = CH_WIDTH_INVALID;
  2811. if (!spectral->params_valid[smode]) {
  2812. target_if_spectral_info_read(spectral,
  2813. smode,
  2814. TARGET_IF_SPECTRAL_INFO_PARAMS,
  2815. &spectral->params[smode],
  2816. sizeof(spectral->params[smode]));
  2817. spectral->params_valid[smode] = true;
  2818. }
  2819. switch (param->id) {
  2820. case SPECTRAL_PARAM_FFT_PERIOD:
  2821. sparams->ss_fft_period = param->value;
  2822. break;
  2823. case SPECTRAL_PARAM_SCAN_PERIOD:
  2824. sparams->ss_period = param->value;
  2825. break;
  2826. case SPECTRAL_PARAM_SCAN_COUNT:
  2827. sparams->ss_count = param->value;
  2828. break;
  2829. case SPECTRAL_PARAM_SHORT_REPORT:
  2830. sparams->ss_short_report = (!!param->value) ? true : false;
  2831. break;
  2832. case SPECTRAL_PARAM_SPECT_PRI:
  2833. sparams->ss_spectral_pri = (!!param->value) ? true : false;
  2834. break;
  2835. case SPECTRAL_PARAM_FFT_SIZE:
  2836. status = target_if_spectral_populate_chwidth
  2837. (spectral, ch_width, spectral->params
  2838. [SPECTRAL_SCAN_MODE_AGILE].ss_frequency.cfreq2 > 0);
  2839. if (QDF_IS_STATUS_ERROR(status))
  2840. return QDF_STATUS_E_FAILURE;
  2841. if ((param->value < param_min_max->fft_size_min) ||
  2842. (param->value > param_min_max->fft_size_max
  2843. [ch_width[smode]])) {
  2844. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2845. return QDF_STATUS_E_FAILURE;
  2846. }
  2847. sparams->ss_fft_size = param->value;
  2848. break;
  2849. case SPECTRAL_PARAM_GC_ENA:
  2850. sparams->ss_gc_ena = !!param->value;
  2851. break;
  2852. case SPECTRAL_PARAM_RESTART_ENA:
  2853. sparams->ss_restart_ena = !!param->value;
  2854. break;
  2855. case SPECTRAL_PARAM_NOISE_FLOOR_REF:
  2856. sparams->ss_noise_floor_ref = param->value;
  2857. break;
  2858. case SPECTRAL_PARAM_INIT_DELAY:
  2859. sparams->ss_init_delay = param->value;
  2860. break;
  2861. case SPECTRAL_PARAM_NB_TONE_THR:
  2862. sparams->ss_nb_tone_thr = param->value;
  2863. break;
  2864. case SPECTRAL_PARAM_STR_BIN_THR:
  2865. sparams->ss_str_bin_thr = param->value;
  2866. break;
  2867. case SPECTRAL_PARAM_WB_RPT_MODE:
  2868. sparams->ss_wb_rpt_mode = !!param->value;
  2869. break;
  2870. case SPECTRAL_PARAM_RSSI_RPT_MODE:
  2871. sparams->ss_rssi_rpt_mode = !!param->value;
  2872. break;
  2873. case SPECTRAL_PARAM_RSSI_THR:
  2874. sparams->ss_rssi_thr = param->value;
  2875. break;
  2876. case SPECTRAL_PARAM_PWR_FORMAT:
  2877. sparams->ss_pwr_format = !!param->value;
  2878. break;
  2879. case SPECTRAL_PARAM_RPT_MODE:
  2880. if ((param->value < SPECTRAL_PARAM_RPT_MODE_MIN) ||
  2881. (param->value > SPECTRAL_PARAM_RPT_MODE_MAX)) {
  2882. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2883. return QDF_STATUS_E_FAILURE;
  2884. }
  2885. sparams->ss_rpt_mode = param->value;
  2886. break;
  2887. case SPECTRAL_PARAM_BIN_SCALE:
  2888. sparams->ss_bin_scale = param->value;
  2889. break;
  2890. case SPECTRAL_PARAM_DBM_ADJ:
  2891. sparams->ss_dbm_adj = !!param->value;
  2892. break;
  2893. case SPECTRAL_PARAM_CHN_MASK:
  2894. sparams->ss_chn_mask = param->value;
  2895. break;
  2896. case SPECTRAL_PARAM_FREQUENCY:
  2897. status = target_if_spectral_populate_chwidth(
  2898. spectral, ch_width, param->freq.cfreq2 > 0);
  2899. if (QDF_IS_STATUS_ERROR(status)) {
  2900. spectral_err("Failed to populate channel width");
  2901. return QDF_STATUS_E_FAILURE;
  2902. }
  2903. if (ch_width[smode] != CH_WIDTH_80P80MHZ &&
  2904. param->freq.cfreq2) {
  2905. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2906. spectral_err("Non zero cfreq2 expected for 80p80 only");
  2907. return QDF_STATUS_E_INVAL;
  2908. }
  2909. if (ch_width[smode] == CH_WIDTH_80P80MHZ &&
  2910. !param->freq.cfreq2) {
  2911. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2912. spectral_err("Non zero cfreq2 expected for 80p80");
  2913. return QDF_STATUS_E_INVAL;
  2914. }
  2915. status = target_if_is_center_freq_of_any_chan
  2916. (spectral->pdev_obj, param->freq.cfreq1,
  2917. &is_valid_chan);
  2918. if (QDF_IS_STATUS_ERROR(status))
  2919. return QDF_STATUS_E_FAILURE;
  2920. if (is_valid_chan) {
  2921. status = target_if_calculate_center_freq(
  2922. spectral, ch_width,
  2923. param->freq.cfreq1,
  2924. &agile_cfreq);
  2925. if (QDF_IS_STATUS_ERROR(status)) {
  2926. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2927. return QDF_STATUS_E_FAILURE;
  2928. }
  2929. } else {
  2930. bool is_valid_agile_cfreq;
  2931. status = target_if_validate_center_freq
  2932. (spectral, ch_width, param->freq.cfreq1,
  2933. &is_valid_agile_cfreq);
  2934. if (QDF_IS_STATUS_ERROR(status))
  2935. return QDF_STATUS_E_FAILURE;
  2936. if (!is_valid_agile_cfreq) {
  2937. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2938. spectral_err("Invalid agile center frequency");
  2939. return QDF_STATUS_E_FAILURE;
  2940. }
  2941. agile_cfreq = param->freq.cfreq1;
  2942. }
  2943. center_freq.cfreq1 = agile_cfreq;
  2944. if (ch_width[smode] == CH_WIDTH_80P80MHZ) {
  2945. status = target_if_is_center_freq_of_any_chan
  2946. (spectral->pdev_obj, param->freq.cfreq2,
  2947. &is_valid_chan);
  2948. if (QDF_IS_STATUS_ERROR(status))
  2949. return QDF_STATUS_E_FAILURE;
  2950. if (is_valid_chan) {
  2951. status = target_if_calculate_center_freq(
  2952. spectral, ch_width,
  2953. param->freq.cfreq2,
  2954. &agile_cfreq);
  2955. if (QDF_IS_STATUS_ERROR(status)) {
  2956. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2957. return QDF_STATUS_E_FAILURE;
  2958. }
  2959. } else {
  2960. bool is_valid_agile_cfreq;
  2961. status = target_if_validate_center_freq
  2962. (spectral, ch_width, param->freq.cfreq2,
  2963. &is_valid_agile_cfreq);
  2964. if (QDF_IS_STATUS_ERROR(status))
  2965. return QDF_STATUS_E_FAILURE;
  2966. if (!is_valid_agile_cfreq) {
  2967. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2968. spectral_err("Invalid agile center frequency");
  2969. return QDF_STATUS_E_FAILURE;
  2970. }
  2971. agile_cfreq = param->freq.cfreq2;
  2972. }
  2973. center_freq.cfreq2 = agile_cfreq;
  2974. }
  2975. status = target_if_is_agile_span_overlap_with_operating_span
  2976. (spectral, ch_width,
  2977. &center_freq, &is_overlapping);
  2978. if (QDF_IS_STATUS_ERROR(status))
  2979. return QDF_STATUS_E_FAILURE;
  2980. if (is_overlapping) {
  2981. spectral_err("Agile freq %u, %u overlaps with operating span",
  2982. center_freq.cfreq1, center_freq.cfreq2);
  2983. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2984. return QDF_STATUS_E_FAILURE;
  2985. }
  2986. if (ch_width[smode] == CH_WIDTH_80P80MHZ) {
  2987. bool is_valid_80p80;
  2988. is_valid_80p80 = target_if_spectral_is_valid_80p80_freq(
  2989. spectral->pdev_obj,
  2990. center_freq.cfreq1,
  2991. center_freq.cfreq2);
  2992. if (!is_valid_80p80) {
  2993. spectral_err("Agile freq %u, %u is invalid 80+80 combination",
  2994. center_freq.cfreq1,
  2995. center_freq.cfreq2);
  2996. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  2997. return QDF_STATUS_E_FAILURE;
  2998. }
  2999. }
  3000. sparams->ss_frequency.cfreq1 = center_freq.cfreq1;
  3001. sparams->ss_frequency.cfreq2 = center_freq.cfreq2;
  3002. break;
  3003. }
  3004. p_sops->configure_spectral(spectral, sparams, smode);
  3005. /* only to validate the writes */
  3006. p_sops->get_spectral_config(spectral, &params, smode);
  3007. return QDF_STATUS_SUCCESS;
  3008. }
  3009. QDF_STATUS
  3010. target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev,
  3011. const struct spectral_cp_param *param,
  3012. const enum spectral_scan_mode smode,
  3013. enum spectral_cp_error_code *err)
  3014. {
  3015. enum spectral_scan_mode mode = SPECTRAL_SCAN_MODE_NORMAL;
  3016. struct target_if_spectral *spectral;
  3017. QDF_STATUS status;
  3018. if (!err) {
  3019. spectral_err("Error code argument is null");
  3020. QDF_ASSERT(0);
  3021. return QDF_STATUS_E_FAILURE;
  3022. }
  3023. *err = SPECTRAL_SCAN_ERR_INVALID;
  3024. if (!pdev) {
  3025. spectral_err("pdev object is NULL");
  3026. return QDF_STATUS_E_FAILURE;
  3027. }
  3028. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3029. if (!spectral) {
  3030. spectral_err("spectral object is NULL");
  3031. return QDF_STATUS_E_FAILURE;
  3032. }
  3033. if (!param) {
  3034. spectral_err("parameter object is NULL");
  3035. return QDF_STATUS_E_FAILURE;
  3036. }
  3037. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3038. spectral_err("Invalid Spectral mode %u", smode);
  3039. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3040. return QDF_STATUS_E_FAILURE;
  3041. }
  3042. if (!spectral->properties[smode][param->id].supported) {
  3043. spectral_err("Spectral parameter(%u) unsupported for mode %u",
  3044. param->id, smode);
  3045. *err = SPECTRAL_SCAN_ERR_PARAM_UNSUPPORTED;
  3046. return QDF_STATUS_E_FAILURE;
  3047. }
  3048. if (spectral->properties[smode][param->id].common_all_modes) {
  3049. spectral_warn("Setting Spectral parameter %u for all modes",
  3050. param->id);
  3051. for (; mode < SPECTRAL_SCAN_MODE_MAX; mode++) {
  3052. status = _target_if_set_spectral_config
  3053. (spectral, param, mode, err);
  3054. if (QDF_IS_STATUS_ERROR(status))
  3055. return QDF_STATUS_E_FAILURE;
  3056. }
  3057. return QDF_STATUS_SUCCESS;
  3058. }
  3059. return _target_if_set_spectral_config(spectral, param, smode, err);
  3060. }
  3061. /**
  3062. * target_if_get_fft_bin_count() - Get fft bin count for a given fft length
  3063. * @fft_len: FFT length
  3064. * @pdev: Pointer to pdev object
  3065. *
  3066. * API to get fft bin count for a given fft length
  3067. *
  3068. * Return: FFt bin count
  3069. */
  3070. static int
  3071. target_if_get_fft_bin_count(int fft_len)
  3072. {
  3073. int bin_count = 0;
  3074. switch (fft_len) {
  3075. case 5:
  3076. bin_count = 16;
  3077. break;
  3078. case 6:
  3079. bin_count = 32;
  3080. break;
  3081. case 7:
  3082. bin_count = 64;
  3083. break;
  3084. case 8:
  3085. bin_count = 128;
  3086. break;
  3087. case 9:
  3088. bin_count = 256;
  3089. break;
  3090. default:
  3091. break;
  3092. }
  3093. return bin_count;
  3094. }
  3095. /**
  3096. * target_if_init_upper_lower_flags() - Initializes control and extension
  3097. * segment flags
  3098. * @spectral: pointer to target if spectral object
  3099. * @smode: Spectral scan mode
  3100. *
  3101. * API to initialize the control and extension flags with the lower/upper
  3102. * segment based on the HT mode
  3103. *
  3104. * Return: FFt bin count
  3105. */
  3106. static void
  3107. target_if_init_upper_lower_flags(struct target_if_spectral *spectral,
  3108. enum spectral_scan_mode smode)
  3109. {
  3110. int current_channel = 0;
  3111. int ext_channel = 0;
  3112. struct target_if_spectral_ops *p_sops =
  3113. GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3114. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3115. spectral_err("Invalid Spectral mode %u", smode);
  3116. return;
  3117. }
  3118. current_channel = p_sops->get_current_channel(spectral, smode);
  3119. ext_channel = p_sops->get_extension_channel(spectral, smode);
  3120. if ((current_channel == 0) || (ext_channel == 0))
  3121. return;
  3122. if (spectral->sc_spectral_20_40_mode) {
  3123. /* HT40 mode */
  3124. if (ext_channel < current_channel) {
  3125. spectral->lower_is_extension = 1;
  3126. spectral->upper_is_control = 1;
  3127. spectral->lower_is_control = 0;
  3128. spectral->upper_is_extension = 0;
  3129. } else {
  3130. spectral->lower_is_extension = 0;
  3131. spectral->upper_is_control = 0;
  3132. spectral->lower_is_control = 1;
  3133. spectral->upper_is_extension = 1;
  3134. }
  3135. } else {
  3136. /* HT20 mode, lower is always control */
  3137. spectral->lower_is_extension = 0;
  3138. spectral->upper_is_control = 0;
  3139. spectral->lower_is_control = 1;
  3140. spectral->upper_is_extension = 0;
  3141. }
  3142. }
  3143. /**
  3144. * target_if_get_spectral_config() - Get spectral configuration
  3145. * @pdev: Pointer to pdev object
  3146. * @param: Pointer to spectral_config structure in which the configuration
  3147. * should be returned
  3148. * @smode: Spectral scan mode
  3149. *
  3150. * API to get the current spectral configuration
  3151. *
  3152. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  3153. */
  3154. QDF_STATUS
  3155. target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
  3156. struct spectral_config *param,
  3157. enum spectral_scan_mode smode)
  3158. {
  3159. struct target_if_spectral_ops *p_sops = NULL;
  3160. struct target_if_spectral *spectral = NULL;
  3161. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3162. if (!spectral) {
  3163. spectral_err("SPECTRAL : Module doesn't exist");
  3164. return QDF_STATUS_E_FAILURE;
  3165. }
  3166. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3167. if (!p_sops) {
  3168. spectral_err("p_sops is null");
  3169. return QDF_STATUS_E_FAILURE;
  3170. }
  3171. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3172. spectral_err("Invalid Spectral mode %u", smode);
  3173. return QDF_STATUS_E_FAILURE;
  3174. }
  3175. qdf_mem_zero(param, sizeof(struct spectral_config));
  3176. p_sops->get_spectral_config(spectral, param, smode);
  3177. return QDF_STATUS_SUCCESS;
  3178. }
  3179. /**
  3180. * target_if_spectral_scan_enable_params() - Enable use of desired Spectral
  3181. * parameters
  3182. * @spectral: Pointer to Spectral target_if internal private data
  3183. * @spectral_params: Pointer to Spectral parameters
  3184. * @smode: Spectral scan mode
  3185. * @err: Spectral error code
  3186. *
  3187. * Enable use of desired Spectral parameters by configuring them into HW, and
  3188. * starting Spectral scan
  3189. *
  3190. * Return: 0 on success, 1 on failure
  3191. */
  3192. int
  3193. target_if_spectral_scan_enable_params(struct target_if_spectral *spectral,
  3194. struct spectral_config *spectral_params,
  3195. enum spectral_scan_mode smode,
  3196. enum spectral_cp_error_code *err)
  3197. {
  3198. int extension_channel = 0;
  3199. int current_channel = 0;
  3200. struct target_if_spectral_ops *p_sops = NULL;
  3201. QDF_STATUS status;
  3202. struct wlan_objmgr_pdev *pdev;
  3203. struct wlan_objmgr_psoc *psoc;
  3204. if (!spectral) {
  3205. spectral_err("Spectral LMAC object is NULL");
  3206. return 1;
  3207. }
  3208. pdev = spectral->pdev_obj;
  3209. if (!pdev) {
  3210. spectral_err("pdev is null");
  3211. return QDF_STATUS_E_INVAL;
  3212. }
  3213. psoc = wlan_pdev_get_psoc(pdev);
  3214. if (!psoc) {
  3215. spectral_err("psoc is null");
  3216. return QDF_STATUS_E_INVAL;
  3217. }
  3218. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3219. spectral_err("Invalid Spectral mode %u", smode);
  3220. return 1;
  3221. }
  3222. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3223. if (!p_sops) {
  3224. spectral_err("p_sops is NULL");
  3225. return 1;
  3226. }
  3227. spectral->sc_spectral_noise_pwr_cal =
  3228. spectral_params->ss_spectral_pri ? 1 : 0;
  3229. /* check if extension channel is present */
  3230. extension_channel = p_sops->get_extension_channel(spectral, smode);
  3231. current_channel = p_sops->get_current_channel(spectral, smode);
  3232. status = target_if_spectral_populate_chwidth(
  3233. spectral, spectral->ch_width,
  3234. spectral->params[SPECTRAL_SCAN_MODE_AGILE].
  3235. ss_frequency.cfreq2 > 0);
  3236. if (QDF_IS_STATUS_ERROR(status)) {
  3237. spectral_err("Failed to get channel widths");
  3238. return 1;
  3239. }
  3240. if (spectral->capability.advncd_spectral_cap) {
  3241. spectral->lb_edge_extrabins = 0;
  3242. spectral->rb_edge_extrabins = 0;
  3243. if (spectral->is_lb_edge_extrabins_format &&
  3244. spectral->params[smode].ss_rpt_mode == 2) {
  3245. spectral->lb_edge_extrabins = 4;
  3246. }
  3247. if (spectral->is_rb_edge_extrabins_format &&
  3248. spectral->params[smode].ss_rpt_mode == 2) {
  3249. spectral->rb_edge_extrabins = 4;
  3250. }
  3251. if (spectral->ch_width[smode] == CH_WIDTH_20MHZ) {
  3252. spectral->sc_spectral_20_40_mode = 0;
  3253. spectral->spectral_numbins =
  3254. target_if_get_fft_bin_count(
  3255. spectral->params[smode].ss_fft_size);
  3256. spectral->spectral_fft_len =
  3257. target_if_get_fft_bin_count(
  3258. spectral->params[smode].ss_fft_size);
  3259. spectral->spectral_data_len =
  3260. target_if_get_fft_bin_count(
  3261. spectral->params[smode].ss_fft_size);
  3262. /*
  3263. * Initialize classifier params to be sent to user
  3264. * space classifier
  3265. */
  3266. spectral->classifier_params.lower_chan_in_mhz =
  3267. current_channel;
  3268. spectral->classifier_params.upper_chan_in_mhz = 0;
  3269. } else if (spectral->ch_width[smode] == CH_WIDTH_40MHZ) {
  3270. /* TODO : Remove this variable */
  3271. spectral->sc_spectral_20_40_mode = 1;
  3272. spectral->spectral_numbins =
  3273. target_if_get_fft_bin_count(
  3274. spectral->params[smode].ss_fft_size);
  3275. spectral->spectral_fft_len =
  3276. target_if_get_fft_bin_count(
  3277. spectral->params[smode].ss_fft_size);
  3278. spectral->spectral_data_len =
  3279. target_if_get_fft_bin_count(
  3280. spectral->params[smode].ss_fft_size);
  3281. /*
  3282. * Initialize classifier params to be sent to user
  3283. * space classifier
  3284. */
  3285. if (extension_channel < current_channel) {
  3286. spectral->classifier_params.lower_chan_in_mhz =
  3287. extension_channel;
  3288. spectral->classifier_params.upper_chan_in_mhz =
  3289. current_channel;
  3290. } else {
  3291. spectral->classifier_params.lower_chan_in_mhz =
  3292. current_channel;
  3293. spectral->classifier_params.upper_chan_in_mhz =
  3294. extension_channel;
  3295. }
  3296. } else if (spectral->ch_width[smode] == CH_WIDTH_80MHZ) {
  3297. /* Set the FFT Size */
  3298. /* TODO : Remove this variable */
  3299. spectral->sc_spectral_20_40_mode = 0;
  3300. spectral->spectral_numbins =
  3301. target_if_get_fft_bin_count(
  3302. spectral->params[smode].ss_fft_size);
  3303. spectral->spectral_fft_len =
  3304. target_if_get_fft_bin_count(
  3305. spectral->params[smode].ss_fft_size);
  3306. spectral->spectral_data_len =
  3307. target_if_get_fft_bin_count(
  3308. spectral->params[smode].ss_fft_size);
  3309. /*
  3310. * Initialize classifier params to be sent to user
  3311. * space classifier
  3312. */
  3313. spectral->classifier_params.lower_chan_in_mhz =
  3314. current_channel;
  3315. spectral->classifier_params.upper_chan_in_mhz = 0;
  3316. /*
  3317. * Initialize classifier params to be sent to user
  3318. * space classifier
  3319. */
  3320. if (extension_channel < current_channel) {
  3321. spectral->classifier_params.lower_chan_in_mhz =
  3322. extension_channel;
  3323. spectral->classifier_params.upper_chan_in_mhz =
  3324. current_channel;
  3325. } else {
  3326. spectral->classifier_params.lower_chan_in_mhz =
  3327. current_channel;
  3328. spectral->classifier_params.upper_chan_in_mhz =
  3329. extension_channel;
  3330. }
  3331. } else if (is_ch_width_160_or_80p80(
  3332. spectral->ch_width[smode])) {
  3333. /* Set the FFT Size */
  3334. /* The below applies to both 160 and 80+80 cases */
  3335. /* TODO : Remove this variable */
  3336. spectral->sc_spectral_20_40_mode = 0;
  3337. spectral->spectral_numbins =
  3338. target_if_get_fft_bin_count(
  3339. spectral->params[smode].ss_fft_size);
  3340. spectral->spectral_fft_len =
  3341. target_if_get_fft_bin_count(
  3342. spectral->params[smode].ss_fft_size);
  3343. spectral->spectral_data_len =
  3344. target_if_get_fft_bin_count(
  3345. spectral->params[smode].ss_fft_size);
  3346. /*
  3347. * Initialize classifier params to be sent to user
  3348. * space classifier
  3349. */
  3350. spectral->classifier_params.lower_chan_in_mhz =
  3351. current_channel;
  3352. spectral->classifier_params.upper_chan_in_mhz = 0;
  3353. /*
  3354. * Initialize classifier params to be sent to user
  3355. * space classifier
  3356. */
  3357. if (extension_channel < current_channel) {
  3358. spectral->classifier_params.lower_chan_in_mhz =
  3359. extension_channel;
  3360. spectral->classifier_params.upper_chan_in_mhz =
  3361. current_channel;
  3362. } else {
  3363. spectral->classifier_params.lower_chan_in_mhz =
  3364. current_channel;
  3365. spectral->classifier_params.upper_chan_in_mhz =
  3366. extension_channel;
  3367. }
  3368. }
  3369. if (spectral->spectral_numbins) {
  3370. spectral->spectral_numbins +=
  3371. spectral->lb_edge_extrabins;
  3372. spectral->spectral_numbins +=
  3373. spectral->rb_edge_extrabins;
  3374. }
  3375. if (spectral->spectral_fft_len) {
  3376. spectral->spectral_fft_len +=
  3377. spectral->lb_edge_extrabins;
  3378. spectral->spectral_fft_len +=
  3379. spectral->rb_edge_extrabins;
  3380. }
  3381. if (spectral->spectral_data_len) {
  3382. spectral->spectral_data_len +=
  3383. spectral->lb_edge_extrabins;
  3384. spectral->spectral_data_len +=
  3385. spectral->rb_edge_extrabins;
  3386. }
  3387. } else {
  3388. /*
  3389. * The decision to find 20/40 mode is found based on the
  3390. * presence of extension channel
  3391. * instead of channel width, as the channel width can
  3392. * dynamically change
  3393. */
  3394. if (extension_channel == 0) {
  3395. spectral->spectral_numbins = SPECTRAL_HT20_NUM_BINS;
  3396. spectral->spectral_dc_index = SPECTRAL_HT20_DC_INDEX;
  3397. spectral->spectral_fft_len = SPECTRAL_HT20_FFT_LEN;
  3398. spectral->spectral_data_len =
  3399. SPECTRAL_HT20_TOTAL_DATA_LEN;
  3400. /* only valid in 20-40 mode */
  3401. spectral->spectral_lower_max_index_offset = -1;
  3402. /* only valid in 20-40 mode */
  3403. spectral->spectral_upper_max_index_offset = -1;
  3404. spectral->spectral_max_index_offset =
  3405. spectral->spectral_fft_len + 2;
  3406. spectral->sc_spectral_20_40_mode = 0;
  3407. /*
  3408. * Initialize classifier params to be sent to user
  3409. * space classifier
  3410. */
  3411. spectral->classifier_params.lower_chan_in_mhz =
  3412. current_channel;
  3413. spectral->classifier_params.upper_chan_in_mhz = 0;
  3414. } else {
  3415. spectral->spectral_numbins =
  3416. SPECTRAL_HT40_TOTAL_NUM_BINS;
  3417. spectral->spectral_fft_len = SPECTRAL_HT40_FFT_LEN;
  3418. spectral->spectral_data_len =
  3419. SPECTRAL_HT40_TOTAL_DATA_LEN;
  3420. spectral->spectral_dc_index = SPECTRAL_HT40_DC_INDEX;
  3421. /* only valid in 20 mode */
  3422. spectral->spectral_max_index_offset = -1;
  3423. spectral->spectral_lower_max_index_offset =
  3424. spectral->spectral_fft_len + 2;
  3425. spectral->spectral_upper_max_index_offset =
  3426. spectral->spectral_fft_len + 5;
  3427. spectral->sc_spectral_20_40_mode = 1;
  3428. /*
  3429. * Initialize classifier params to be sent to user
  3430. * space classifier
  3431. */
  3432. if (extension_channel < current_channel) {
  3433. spectral->classifier_params.lower_chan_in_mhz =
  3434. extension_channel;
  3435. spectral->classifier_params.upper_chan_in_mhz =
  3436. current_channel;
  3437. } else {
  3438. spectral->classifier_params.lower_chan_in_mhz =
  3439. current_channel;
  3440. spectral->classifier_params.upper_chan_in_mhz =
  3441. extension_channel;
  3442. }
  3443. }
  3444. }
  3445. spectral->send_single_packet = 0;
  3446. spectral->classifier_params.spectral_20_40_mode =
  3447. spectral->sc_spectral_20_40_mode;
  3448. spectral->classifier_params.spectral_dc_index =
  3449. spectral->spectral_dc_index;
  3450. spectral->spectral_sent_msg = 0;
  3451. spectral->classify_scan = 0;
  3452. spectral->num_spectral_data = 0;
  3453. if (!p_sops->is_spectral_active(spectral, smode)) {
  3454. p_sops->configure_spectral(spectral, spectral_params, smode);
  3455. spectral->rparams.marker[smode].is_valid = false;
  3456. p_sops->start_spectral_scan(spectral, smode, err);
  3457. spectral->timestamp_war.timestamp_war_offset[smode] = 0;
  3458. spectral->timestamp_war.last_fft_timestamp[smode] = 0;
  3459. }
  3460. /* get current spectral configuration */
  3461. p_sops->get_spectral_config(spectral, &spectral->params[smode], smode);
  3462. target_if_init_upper_lower_flags(spectral, smode);
  3463. return 0;
  3464. }
  3465. /**
  3466. * target_if_is_aspectral_prohibited_by_adfs() - Is Agile Spectral prohibited by
  3467. * Agile DFS
  3468. * @psoc: Pointer to psoc
  3469. * @object: Pointer to pdev
  3470. * @arg: Pointer to flag which indicates whether Agile Spectral is prohibited
  3471. *
  3472. * This API checks whether Agile DFS is running on any of the pdevs. If so, it
  3473. * indicates that Agile Spectral scan is prohibited by Agile DFS.
  3474. *
  3475. * Return: void
  3476. */
  3477. static void
  3478. target_if_is_aspectral_prohibited_by_adfs(struct wlan_objmgr_psoc *psoc,
  3479. void *object, void *arg)
  3480. {
  3481. bool *is_aspectral_prohibited = arg;
  3482. struct wlan_objmgr_pdev *cur_pdev = object;
  3483. bool is_agile_dfs_enabled_cur_pdev = false;
  3484. QDF_STATUS status;
  3485. qdf_assert_always(is_aspectral_prohibited);
  3486. if (*is_aspectral_prohibited)
  3487. return;
  3488. qdf_assert_always(psoc);
  3489. qdf_assert_always(cur_pdev);
  3490. status = ucfg_dfs_get_agile_precac_enable
  3491. (cur_pdev,
  3492. &is_agile_dfs_enabled_cur_pdev);
  3493. if (QDF_IS_STATUS_ERROR(status)) {
  3494. spectral_err("Get agile precac failed, prohibiting aSpectral");
  3495. *is_aspectral_prohibited = true;
  3496. return;
  3497. }
  3498. if (is_agile_dfs_enabled_cur_pdev) {
  3499. spectral_err("aDFS is in progress on one of the pdevs");
  3500. *is_aspectral_prohibited = true;
  3501. }
  3502. }
  3503. /**
  3504. * target_if_get_curr_band() - Get current operating band of pdev
  3505. *
  3506. * @pdev: pointer to pdev object
  3507. *
  3508. * API to get current operating band of a given pdev.
  3509. *
  3510. * Return: if success enum reg_wifi_band, REG_BAND_UNKNOWN in case of failure
  3511. */
  3512. static enum reg_wifi_band
  3513. target_if_get_curr_band(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
  3514. {
  3515. struct wlan_objmgr_vdev *vdev;
  3516. int16_t chan_freq;
  3517. enum reg_wifi_band cur_band;
  3518. if (!pdev) {
  3519. spectral_err("pdev is NULL");
  3520. return REG_BAND_UNKNOWN;
  3521. }
  3522. if (vdev_id == WLAN_INVALID_VDEV_ID)
  3523. vdev = wlan_objmgr_pdev_get_first_vdev(pdev, WLAN_SPECTRAL_ID);
  3524. else
  3525. vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
  3526. WLAN_SPECTRAL_ID);
  3527. if (!vdev) {
  3528. spectral_debug("vdev is NULL");
  3529. return REG_BAND_UNKNOWN;
  3530. }
  3531. chan_freq = target_if_vdev_get_chan_freq(vdev);
  3532. cur_band = wlan_reg_freq_to_band(chan_freq);
  3533. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3534. return cur_band;
  3535. }
  3536. /**
  3537. * target_if_is_agile_scan_active_in_5g() - Is Agile Spectral scan active on
  3538. * any of the 5G pdevs
  3539. * @psoc: Pointer to psoc
  3540. * @object: Pointer to pdev
  3541. * @arg: Pointer to flag which indicates whether Agile Spectral scan is in
  3542. * progress in any 5G pdevs
  3543. *
  3544. * Return: void
  3545. */
  3546. static void
  3547. target_if_is_agile_scan_active_in_5g(struct wlan_objmgr_psoc *psoc,
  3548. void *object, void *arg)
  3549. {
  3550. enum reg_wifi_band band;
  3551. bool *is_agile_scan_inprog_5g_pdev = arg;
  3552. struct target_if_spectral *spectral;
  3553. struct wlan_objmgr_pdev *cur_pdev = object;
  3554. struct target_if_spectral_ops *p_sops;
  3555. if (*is_agile_scan_inprog_5g_pdev)
  3556. return;
  3557. spectral = get_target_if_spectral_handle_from_pdev(cur_pdev);
  3558. if (!spectral) {
  3559. spectral_err("target if spectral handle is NULL");
  3560. return;
  3561. }
  3562. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3563. band = target_if_get_curr_band(
  3564. cur_pdev, spectral->vdev_id[SPECTRAL_SCAN_MODE_AGILE]);
  3565. if (band == REG_BAND_UNKNOWN) {
  3566. spectral_debug("Failed to get current band");
  3567. return;
  3568. }
  3569. if (band == REG_BAND_5G &&
  3570. p_sops->is_spectral_active(spectral, SPECTRAL_SCAN_MODE_AGILE))
  3571. *is_agile_scan_inprog_5g_pdev = true;
  3572. }
  3573. /**
  3574. * target_if_is_agile_supported_cur_chmask() - Is Agile Spectral scan supported
  3575. * for current vdev rx chainmask.
  3576. *
  3577. * @spectral: Pointer to Spectral object
  3578. * @is_supported: Pointer to is_supported
  3579. *
  3580. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  3581. */
  3582. static QDF_STATUS
  3583. target_if_is_agile_supported_cur_chmask(struct target_if_spectral *spectral,
  3584. bool *is_supported)
  3585. {
  3586. struct wlan_objmgr_vdev *vdev;
  3587. uint8_t vdev_rxchainmask;
  3588. struct wlan_objmgr_psoc *psoc;
  3589. struct wlan_objmgr_pdev *pdev;
  3590. struct target_psoc_info *tgt_psoc_info;
  3591. struct wlan_psoc_host_service_ext_param *ext_svc_param;
  3592. struct wlan_psoc_host_mac_phy_caps *mac_phy_cap_arr = NULL;
  3593. struct wlan_psoc_host_mac_phy_caps *mac_phy_cap = NULL;
  3594. struct wlan_psoc_host_chainmask_table *table;
  3595. int j;
  3596. uint32_t table_id;
  3597. enum phy_ch_width ch_width;
  3598. uint8_t pdev_id;
  3599. if (!spectral) {
  3600. spectral_err("spectral target if object is null");
  3601. return QDF_STATUS_E_FAILURE;
  3602. }
  3603. if (!is_supported) {
  3604. spectral_err("is supported argument is null");
  3605. return QDF_STATUS_E_FAILURE;
  3606. }
  3607. if (spectral->spectral_gen <= SPECTRAL_GEN2) {
  3608. spectral_err("HW Agile mode is not supported up to gen 2");
  3609. return QDF_STATUS_E_FAILURE;
  3610. }
  3611. pdev = spectral->pdev_obj;
  3612. if (!pdev) {
  3613. spectral_err("pdev is null");
  3614. return QDF_STATUS_E_FAILURE;
  3615. }
  3616. psoc = wlan_pdev_get_psoc(pdev);
  3617. if (!psoc) {
  3618. spectral_err("psoc is null");
  3619. return QDF_STATUS_E_FAILURE;
  3620. }
  3621. vdev = target_if_spectral_get_vdev(spectral, SPECTRAL_SCAN_MODE_AGILE);
  3622. if (!vdev) {
  3623. spectral_err("First vdev is NULL");
  3624. return QDF_STATUS_E_FAILURE;
  3625. }
  3626. vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev);
  3627. if (!vdev_rxchainmask) {
  3628. spectral_err("vdev rx chainmask is zero");
  3629. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3630. return QDF_STATUS_E_FAILURE;
  3631. }
  3632. ch_width = target_if_vdev_get_ch_width(vdev);
  3633. if (ch_width == CH_WIDTH_INVALID) {
  3634. spectral_err("Invalid channel width");
  3635. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3636. return QDF_STATUS_E_FAILURE;
  3637. }
  3638. wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
  3639. tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
  3640. if (!tgt_psoc_info) {
  3641. spectral_err("target_psoc_info is null");
  3642. return QDF_STATUS_E_FAILURE;
  3643. }
  3644. ext_svc_param = target_psoc_get_service_ext_param(tgt_psoc_info);
  3645. if (!ext_svc_param) {
  3646. spectral_err("Extended service ready param null");
  3647. return QDF_STATUS_E_FAILURE;
  3648. }
  3649. pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  3650. mac_phy_cap_arr = target_psoc_get_mac_phy_cap(tgt_psoc_info);
  3651. if (!mac_phy_cap_arr) {
  3652. spectral_err("mac phy cap array is null");
  3653. return QDF_STATUS_E_FAILURE;
  3654. }
  3655. mac_phy_cap = &mac_phy_cap_arr[pdev_id];
  3656. if (!mac_phy_cap) {
  3657. spectral_err("mac phy cap is null");
  3658. return QDF_STATUS_E_FAILURE;
  3659. }
  3660. table_id = mac_phy_cap->chainmask_table_id;
  3661. table = &ext_svc_param->chainmask_table[table_id];
  3662. if (!table) {
  3663. spectral_err("chainmask table not found");
  3664. return QDF_STATUS_E_FAILURE;
  3665. }
  3666. for (j = 0; j < table->num_valid_chainmasks; j++) {
  3667. if (table->cap_list[j].chainmask == vdev_rxchainmask) {
  3668. if (ch_width <= CH_WIDTH_80MHZ)
  3669. *is_supported =
  3670. table->cap_list[j].supports_aSpectral;
  3671. else
  3672. *is_supported =
  3673. table->cap_list[j].supports_aSpectral_160;
  3674. break;
  3675. }
  3676. }
  3677. if (j == table->num_valid_chainmasks) {
  3678. spectral_err("vdev rx chainmask %u not found in table id = %u",
  3679. vdev_rxchainmask, table_id);
  3680. return QDF_STATUS_E_FAILURE;
  3681. }
  3682. return QDF_STATUS_SUCCESS;
  3683. }
  3684. QDF_STATUS
  3685. target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
  3686. uint8_t vdev_id,
  3687. const enum spectral_scan_mode smode,
  3688. enum spectral_cp_error_code *err)
  3689. {
  3690. struct target_if_spectral_ops *p_sops;
  3691. struct target_if_spectral *spectral;
  3692. struct wlan_objmgr_psoc *psoc;
  3693. enum reg_wifi_band band;
  3694. if (!err) {
  3695. spectral_err("Error code argument is null");
  3696. QDF_ASSERT(0);
  3697. return QDF_STATUS_E_FAILURE;
  3698. }
  3699. *err = SPECTRAL_SCAN_ERR_INVALID;
  3700. if (!pdev) {
  3701. spectral_err("pdev object is NUll");
  3702. return QDF_STATUS_E_FAILURE;
  3703. }
  3704. psoc = wlan_pdev_get_psoc(pdev);
  3705. if (!psoc) {
  3706. spectral_err("psoc is null");
  3707. return QDF_STATUS_E_FAILURE;
  3708. }
  3709. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3710. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3711. spectral_err("Invalid Spectral mode %u", smode);
  3712. return QDF_STATUS_E_FAILURE;
  3713. }
  3714. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3715. if (!spectral) {
  3716. spectral_err("Spectral LMAC object is NUll");
  3717. return QDF_STATUS_E_FAILURE;
  3718. }
  3719. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3720. if (!p_sops) {
  3721. spectral_err("p_sops is null");
  3722. return QDF_STATUS_E_FAILURE;
  3723. }
  3724. if (p_sops->is_spectral_active(spectral, smode)) {
  3725. spectral_err("spectral in progress in current pdev, mode %d",
  3726. smode);
  3727. return QDF_STATUS_E_FAILURE;
  3728. }
  3729. spectral->vdev_id[smode] = vdev_id;
  3730. if (smode == SPECTRAL_SCAN_MODE_AGILE) {
  3731. QDF_STATUS status;
  3732. bool is_supported = false;
  3733. status = target_if_is_agile_supported_cur_chmask(spectral,
  3734. &is_supported);
  3735. if (QDF_IS_STATUS_ERROR(status)) {
  3736. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3737. return QDF_STATUS_E_FAILURE;
  3738. }
  3739. if (!is_supported) {
  3740. spectral_err("aSpectral unsupported for cur chainmask");
  3741. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3742. return QDF_STATUS_E_FAILURE;
  3743. }
  3744. }
  3745. band = target_if_get_curr_band(spectral->pdev_obj, vdev_id);
  3746. if (band == REG_BAND_UNKNOWN) {
  3747. spectral_err("Failed to get current band");
  3748. return QDF_STATUS_E_FAILURE;
  3749. }
  3750. if ((band == REG_BAND_5G) && (smode == SPECTRAL_SCAN_MODE_AGILE)) {
  3751. struct target_psoc_info *tgt_hdl;
  3752. enum wmi_host_hw_mode_config_type mode;
  3753. bool is_agile_scan_inprog_5g_pdev;
  3754. tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
  3755. if (!tgt_hdl) {
  3756. target_if_err("target_psoc_info is null");
  3757. return QDF_STATUS_E_FAILURE;
  3758. }
  3759. mode = target_psoc_get_preferred_hw_mode(tgt_hdl);
  3760. switch (mode) {
  3761. case WMI_HOST_HW_MODE_SBS_PASSIVE:
  3762. case WMI_HOST_HW_MODE_SBS:
  3763. case WMI_HOST_HW_MODE_DBS_SBS:
  3764. case WMI_HOST_HW_MODE_DBS_OR_SBS:
  3765. is_agile_scan_inprog_5g_pdev = false;
  3766. wlan_objmgr_iterate_obj_list
  3767. (psoc, WLAN_PDEV_OP,
  3768. target_if_is_agile_scan_active_in_5g,
  3769. &is_agile_scan_inprog_5g_pdev, 0,
  3770. WLAN_SPECTRAL_ID);
  3771. break;
  3772. default:
  3773. is_agile_scan_inprog_5g_pdev = false;
  3774. break;
  3775. }
  3776. if (is_agile_scan_inprog_5g_pdev) {
  3777. spectral_err("Agile Scan in progress in one of the SBS 5G pdev");
  3778. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3779. return QDF_STATUS_E_FAILURE;
  3780. }
  3781. }
  3782. if (smode == SPECTRAL_SCAN_MODE_AGILE) {
  3783. bool is_aspectral_prohibited = false;
  3784. QDF_STATUS status;
  3785. status = wlan_objmgr_iterate_obj_list
  3786. (psoc, WLAN_PDEV_OP,
  3787. target_if_is_aspectral_prohibited_by_adfs,
  3788. &is_aspectral_prohibited, 0,
  3789. WLAN_SPECTRAL_ID);
  3790. if (QDF_IS_STATUS_ERROR(status)) {
  3791. spectral_err("Failed to iterate over pdevs");
  3792. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3793. return QDF_STATUS_E_FAILURE;
  3794. }
  3795. if (is_aspectral_prohibited) {
  3796. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3797. return QDF_STATUS_E_FAILURE;
  3798. }
  3799. }
  3800. if (!spectral->params_valid[smode]) {
  3801. target_if_spectral_info_read(spectral,
  3802. smode,
  3803. TARGET_IF_SPECTRAL_INFO_PARAMS,
  3804. &spectral->params[smode],
  3805. sizeof(spectral->params[smode]));
  3806. spectral->params_valid[smode] = true;
  3807. }
  3808. qdf_spin_lock(&spectral->spectral_lock);
  3809. if (smode == SPECTRAL_SCAN_MODE_AGILE) {
  3810. QDF_STATUS status;
  3811. bool is_overlapping;
  3812. enum phy_ch_width ch_width[SPECTRAL_SCAN_MODE_MAX];
  3813. enum spectral_scan_mode m;
  3814. enum phy_ch_width op_ch_width;
  3815. enum phy_ch_width agile_ch_width;
  3816. m = SPECTRAL_SCAN_MODE_NORMAL;
  3817. for (; m < SPECTRAL_SCAN_MODE_MAX; m++)
  3818. ch_width[m] = CH_WIDTH_INVALID;
  3819. status = target_if_spectral_populate_chwidth
  3820. (spectral, ch_width, spectral->params
  3821. [SPECTRAL_SCAN_MODE_AGILE].ss_frequency.cfreq2 > 0);
  3822. if (QDF_IS_STATUS_ERROR(status)) {
  3823. qdf_spin_unlock(&spectral->spectral_lock);
  3824. spectral_err("Failed to populate channel width");
  3825. return QDF_STATUS_E_FAILURE;
  3826. }
  3827. op_ch_width = ch_width[SPECTRAL_SCAN_MODE_NORMAL];
  3828. agile_ch_width = ch_width[SPECTRAL_SCAN_MODE_AGILE];
  3829. if (!spectral->params[smode].ss_frequency.cfreq1 ||
  3830. (agile_ch_width == CH_WIDTH_80P80MHZ &&
  3831. !spectral->params[smode].ss_frequency.cfreq2)) {
  3832. *err = SPECTRAL_SCAN_ERR_PARAM_NOT_INITIALIZED;
  3833. qdf_spin_unlock(&spectral->spectral_lock);
  3834. return QDF_STATUS_E_FAILURE;
  3835. }
  3836. status = target_if_is_agile_span_overlap_with_operating_span
  3837. (spectral, ch_width,
  3838. &spectral->params[smode].ss_frequency,
  3839. &is_overlapping);
  3840. if (QDF_IS_STATUS_ERROR(status)) {
  3841. qdf_spin_unlock(&spectral->spectral_lock);
  3842. return QDF_STATUS_E_FAILURE;
  3843. }
  3844. if (is_overlapping) {
  3845. *err = SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE;
  3846. qdf_spin_unlock(&spectral->spectral_lock);
  3847. return QDF_STATUS_E_FAILURE;
  3848. }
  3849. }
  3850. target_if_spectral_scan_enable_params(spectral,
  3851. &spectral->params[smode], smode,
  3852. err);
  3853. qdf_spin_unlock(&spectral->spectral_lock);
  3854. return QDF_STATUS_SUCCESS;
  3855. }
  3856. QDF_STATUS
  3857. target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev,
  3858. const enum spectral_scan_mode smode,
  3859. enum spectral_cp_error_code *err)
  3860. {
  3861. struct target_if_spectral_ops *p_sops;
  3862. struct target_if_spectral *spectral;
  3863. if (!err) {
  3864. spectral_err("Error code argument is null");
  3865. QDF_ASSERT(0);
  3866. return QDF_STATUS_E_FAILURE;
  3867. }
  3868. *err = SPECTRAL_SCAN_ERR_INVALID;
  3869. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3870. *err = SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED;
  3871. spectral_err("Invalid Spectral mode %u", smode);
  3872. return QDF_STATUS_E_FAILURE;
  3873. }
  3874. if (!pdev) {
  3875. spectral_err("pdev object is NUll ");
  3876. return QDF_STATUS_E_FAILURE;
  3877. }
  3878. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3879. if (!spectral) {
  3880. spectral_err("Spectral LMAC object is NUll ");
  3881. return QDF_STATUS_E_FAILURE;
  3882. }
  3883. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3884. qdf_spin_lock(&spectral->spectral_lock);
  3885. p_sops->stop_spectral_scan(spectral, smode);
  3886. if (spectral->classify_scan) {
  3887. /* TODO : Check if this logic is necessary */
  3888. spectral->detects_control_channel = 0;
  3889. spectral->detects_extension_channel = 0;
  3890. spectral->detects_above_dc = 0;
  3891. spectral->detects_below_dc = 0;
  3892. spectral->classify_scan = 0;
  3893. }
  3894. spectral->send_single_packet = 0;
  3895. spectral->sc_spectral_scan = 0;
  3896. spectral->vdev_id[smode] = WLAN_INVALID_VDEV_ID;
  3897. qdf_spin_unlock(&spectral->spectral_lock);
  3898. return QDF_STATUS_SUCCESS;
  3899. }
  3900. /**
  3901. * target_if_is_spectral_active() - Get whether Spectral is active
  3902. * @pdev: Pointer to pdev object
  3903. * @smode: Spectral scan mode
  3904. *
  3905. * API to get whether Spectral is active
  3906. *
  3907. * Return: True if Spectral is active, false if Spectral is not active
  3908. */
  3909. bool
  3910. target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev,
  3911. const enum spectral_scan_mode smode)
  3912. {
  3913. struct target_if_spectral *spectral = NULL;
  3914. struct target_if_spectral_ops *p_sops = NULL;
  3915. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3916. if (!spectral) {
  3917. spectral_err("SPECTRAL : Module doesn't exist");
  3918. return QDF_STATUS_E_FAILURE;
  3919. }
  3920. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3921. if (!p_sops) {
  3922. spectral_err("p_sops is null");
  3923. return QDF_STATUS_E_FAILURE;
  3924. }
  3925. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3926. spectral_err("Invalid Spectral mode %u", smode);
  3927. return QDF_STATUS_E_FAILURE;
  3928. }
  3929. return p_sops->is_spectral_active(spectral, smode);
  3930. }
  3931. /**
  3932. * target_if_is_spectral_enabled() - Get whether Spectral is enabled
  3933. * @pdev: Pointer to pdev object
  3934. * @smode: Spectral scan mode
  3935. *
  3936. * API to get whether Spectral is enabled
  3937. *
  3938. * Return: True if Spectral is enabled, false if Spectral is not enabled
  3939. */
  3940. bool
  3941. target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev,
  3942. enum spectral_scan_mode smode)
  3943. {
  3944. struct target_if_spectral *spectral = NULL;
  3945. struct target_if_spectral_ops *p_sops = NULL;
  3946. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3947. if (!spectral) {
  3948. spectral_err("SPECTRAL : Module doesn't exist");
  3949. return QDF_STATUS_E_FAILURE;
  3950. }
  3951. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  3952. if (!p_sops) {
  3953. spectral_err("p_sops is null");
  3954. return QDF_STATUS_E_FAILURE;
  3955. }
  3956. if (smode >= SPECTRAL_SCAN_MODE_MAX) {
  3957. spectral_err("Invalid Spectral mode %u", smode);
  3958. return QDF_STATUS_E_FAILURE;
  3959. }
  3960. return p_sops->is_spectral_enabled(spectral, smode);
  3961. }
  3962. #ifdef DIRECT_BUF_RX_DEBUG
  3963. /**
  3964. * target_if_spectral_do_dbr_ring_debug() - Start/Stop Spectral DMA ring debug
  3965. * @pdev: Pointer to pdev object
  3966. * @enable: Enable/Disable Spectral DMA ring debug
  3967. *
  3968. * Start/stop Spectral DMA ring debug based on @enable.
  3969. * Also save the state for future use.
  3970. *
  3971. * Return: QDF_STATUS of operation
  3972. */
  3973. static QDF_STATUS
  3974. target_if_spectral_do_dbr_ring_debug(struct wlan_objmgr_pdev *pdev, bool enable)
  3975. {
  3976. struct target_if_spectral *spectral;
  3977. struct wlan_lmac_if_tx_ops *tx_ops;
  3978. struct wlan_objmgr_psoc *psoc;
  3979. if (!pdev)
  3980. return QDF_STATUS_E_FAILURE;
  3981. psoc = wlan_pdev_get_psoc(pdev);
  3982. if (!psoc) {
  3983. spectral_err("psoc is null");
  3984. return QDF_STATUS_E_INVAL;
  3985. }
  3986. tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
  3987. if (!tx_ops) {
  3988. spectral_err("tx_ops is NULL");
  3989. return QDF_STATUS_E_INVAL;
  3990. }
  3991. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  3992. if (!spectral) {
  3993. spectral_err("Spectal LMAC object is NULL");
  3994. return QDF_STATUS_E_INVAL;
  3995. }
  3996. /* Save the state */
  3997. spectral->dbr_ring_debug = enable;
  3998. if (enable)
  3999. return tx_ops->dbr_tx_ops.direct_buf_rx_start_ring_debug(
  4000. pdev, 0, SPECTRAL_DBR_RING_DEBUG_SIZE);
  4001. else
  4002. return tx_ops->dbr_tx_ops.direct_buf_rx_stop_ring_debug(
  4003. pdev, 0);
  4004. return QDF_STATUS_SUCCESS;
  4005. }
  4006. /**
  4007. * target_if_spectral_do_dbr_buff_debug() - Start/Stop Spectral DMA buffer debug
  4008. * @pdev: Pointer to pdev object
  4009. * @enable: Enable/Disable Spectral DMA buffer debug
  4010. *
  4011. * Start/stop Spectral DMA buffer debug based on @enable.
  4012. * Also save the state for future use.
  4013. *
  4014. * Return: QDF_STATUS of operation
  4015. */
  4016. static QDF_STATUS
  4017. target_if_spectral_do_dbr_buff_debug(struct wlan_objmgr_pdev *pdev, bool enable)
  4018. {
  4019. struct target_if_spectral *spectral;
  4020. struct wlan_lmac_if_tx_ops *tx_ops;
  4021. struct wlan_objmgr_psoc *psoc;
  4022. if (!pdev)
  4023. return QDF_STATUS_E_FAILURE;
  4024. psoc = wlan_pdev_get_psoc(pdev);
  4025. if (!psoc) {
  4026. spectral_err("psoc is null");
  4027. return QDF_STATUS_E_INVAL;
  4028. }
  4029. tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
  4030. if (!tx_ops) {
  4031. spectral_err("tx_ops is NULL");
  4032. return QDF_STATUS_E_INVAL;
  4033. }
  4034. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4035. if (!spectral) {
  4036. spectral_err("Spectal LMAC object is NULL");
  4037. return QDF_STATUS_E_INVAL;
  4038. }
  4039. /* Save the state */
  4040. spectral->dbr_buff_debug = enable;
  4041. if (enable)
  4042. return tx_ops->dbr_tx_ops.direct_buf_rx_start_buffer_poisoning(
  4043. pdev, 0, MEM_POISON_SIGNATURE);
  4044. else
  4045. return tx_ops->dbr_tx_ops.direct_buf_rx_stop_buffer_poisoning(
  4046. pdev, 0);
  4047. }
  4048. /**
  4049. * target_if_spectral_check_and_do_dbr_buff_debug() - Start/Stop Spectral buffer
  4050. * debug based on the previous state
  4051. * @pdev: Pointer to pdev object
  4052. *
  4053. * Return: QDF_STATUS of operation
  4054. */
  4055. static QDF_STATUS
  4056. target_if_spectral_check_and_do_dbr_buff_debug(struct wlan_objmgr_pdev *pdev)
  4057. {
  4058. struct target_if_spectral *spectral;
  4059. if (!pdev) {
  4060. spectral_err("pdev is NULL!");
  4061. return QDF_STATUS_E_FAILURE;
  4062. }
  4063. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4064. if (!spectral) {
  4065. spectral_err("Spectal LMAC object is NULL");
  4066. return QDF_STATUS_E_INVAL;
  4067. }
  4068. if (spectral->dbr_buff_debug)
  4069. return target_if_spectral_do_dbr_buff_debug(pdev, true);
  4070. else
  4071. return target_if_spectral_do_dbr_buff_debug(pdev, false);
  4072. }
  4073. /**
  4074. * target_if_spectral_check_and_do_dbr_ring_debug() - Start/Stop Spectral ring
  4075. * debug based on the previous state
  4076. * @pdev: Pointer to pdev object
  4077. *
  4078. * Return: QDF_STATUS of operation
  4079. */
  4080. static QDF_STATUS
  4081. target_if_spectral_check_and_do_dbr_ring_debug(struct wlan_objmgr_pdev *pdev)
  4082. {
  4083. struct target_if_spectral *spectral;
  4084. if (!pdev) {
  4085. spectral_err("pdev is NULL!");
  4086. return QDF_STATUS_E_FAILURE;
  4087. }
  4088. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4089. if (!spectral) {
  4090. spectral_err("Spectal LMAC object is NULL");
  4091. return QDF_STATUS_E_INVAL;
  4092. }
  4093. if (spectral->dbr_ring_debug)
  4094. return target_if_spectral_do_dbr_ring_debug(pdev, true);
  4095. else
  4096. return target_if_spectral_do_dbr_ring_debug(pdev, false);
  4097. }
  4098. /**
  4099. * target_if_spectral_set_dma_debug() - Set DMA debug for Spectral
  4100. * @pdev: Pointer to pdev object
  4101. * @dma_debug_type: Type of Spectral DMA debug i.e., ring or buffer debug
  4102. * @debug_value: Value to be set for @dma_debug_type
  4103. *
  4104. * Set DMA debug for Spectral and start/stop Spectral DMA debug function
  4105. * based on @debug_value
  4106. *
  4107. * Return: QDF_STATUS of operation
  4108. */
  4109. static QDF_STATUS
  4110. target_if_spectral_set_dma_debug(
  4111. struct wlan_objmgr_pdev *pdev,
  4112. enum spectral_dma_debug dma_debug_type,
  4113. bool debug_value)
  4114. {
  4115. struct target_if_spectral_ops *p_sops;
  4116. struct wlan_objmgr_psoc *psoc;
  4117. struct wlan_lmac_if_tx_ops *tx_ops;
  4118. struct target_if_spectral *spectral;
  4119. if (!pdev)
  4120. return QDF_STATUS_E_FAILURE;
  4121. psoc = wlan_pdev_get_psoc(pdev);
  4122. if (!psoc) {
  4123. spectral_err("psoc is null");
  4124. return QDF_STATUS_E_INVAL;
  4125. }
  4126. tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
  4127. if (!tx_ops) {
  4128. spectral_err("tx_ops is NULL");
  4129. return QDF_STATUS_E_FAILURE;
  4130. }
  4131. if (!tx_ops->target_tx_ops.tgt_get_tgt_type) {
  4132. spectral_err("Unable to fetch target type");
  4133. return QDF_STATUS_E_FAILURE;
  4134. }
  4135. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4136. if (!spectral) {
  4137. spectral_err("Spectal LMAC object is NULL");
  4138. return QDF_STATUS_E_INVAL;
  4139. }
  4140. if (spectral->direct_dma_support) {
  4141. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  4142. if (p_sops->is_spectral_active(spectral,
  4143. SPECTRAL_SCAN_MODE_NORMAL) ||
  4144. p_sops->is_spectral_active(spectral,
  4145. SPECTRAL_SCAN_MODE_AGILE)) {
  4146. spectral_err("Altering DBR debug config isn't allowed during an ongoing scan");
  4147. return QDF_STATUS_E_FAILURE;
  4148. }
  4149. switch (dma_debug_type) {
  4150. case SPECTRAL_DMA_RING_DEBUG:
  4151. target_if_spectral_do_dbr_ring_debug(pdev, debug_value);
  4152. break;
  4153. case SPECTRAL_DMA_BUFFER_DEBUG:
  4154. target_if_spectral_do_dbr_buff_debug(pdev, debug_value);
  4155. break;
  4156. default:
  4157. spectral_err("Unsupported DMA debug type : %d",
  4158. dma_debug_type);
  4159. return QDF_STATUS_E_FAILURE;
  4160. }
  4161. }
  4162. return QDF_STATUS_SUCCESS;
  4163. }
  4164. #endif /* DIRECT_BUF_RX_DEBUG */
  4165. /**
  4166. * target_if_spectral_direct_dma_support() - Get Direct-DMA support
  4167. * @pdev: Pointer to pdev object
  4168. *
  4169. * Return: Whether Direct-DMA is supported on this radio
  4170. */
  4171. static bool
  4172. target_if_spectral_direct_dma_support(struct wlan_objmgr_pdev *pdev)
  4173. {
  4174. struct target_if_spectral *spectral;
  4175. if (!pdev) {
  4176. spectral_err("pdev is NULL!");
  4177. return false;
  4178. }
  4179. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4180. if (!spectral) {
  4181. spectral_err("Spectral LMAC object is NULL");
  4182. return false;
  4183. }
  4184. return spectral->direct_dma_support;
  4185. }
  4186. /**
  4187. * target_if_set_debug_level() - Set debug level for Spectral
  4188. * @pdev: Pointer to pdev object
  4189. * @debug_level: Debug level
  4190. *
  4191. * API to set the debug level for Spectral
  4192. *
  4193. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  4194. */
  4195. QDF_STATUS
  4196. target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, uint32_t debug_level)
  4197. {
  4198. spectral_debug_level = (DEBUG_SPECTRAL << debug_level);
  4199. return QDF_STATUS_SUCCESS;
  4200. }
  4201. /**
  4202. * target_if_get_debug_level() - Get debug level for Spectral
  4203. * @pdev: Pointer to pdev object
  4204. *
  4205. * API to get the debug level for Spectral
  4206. *
  4207. * Return: Current debug level
  4208. */
  4209. uint32_t
  4210. target_if_get_debug_level(struct wlan_objmgr_pdev *pdev)
  4211. {
  4212. return spectral_debug_level;
  4213. }
  4214. /**
  4215. * target_if_get_spectral_capinfo() - Get Spectral capability information
  4216. * @pdev: Pointer to pdev object
  4217. * @scaps: Buffer into which data should be copied
  4218. *
  4219. * API to get the spectral capability information
  4220. *
  4221. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  4222. */
  4223. QDF_STATUS
  4224. target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev,
  4225. struct spectral_caps *scaps)
  4226. {
  4227. struct target_if_spectral *spectral = NULL;
  4228. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4229. if (!spectral) {
  4230. spectral_err("SPECTRAL : Module doesn't exist");
  4231. return QDF_STATUS_E_FAILURE;
  4232. }
  4233. qdf_mem_copy(scaps, &spectral->capability,
  4234. sizeof(struct spectral_caps));
  4235. return QDF_STATUS_SUCCESS;
  4236. }
  4237. /**
  4238. * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics
  4239. * @pdev: Pointer to pdev object
  4240. * @stats: Buffer into which data should be copied
  4241. *
  4242. * API to get the spectral diagnostic statistics
  4243. *
  4244. * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
  4245. */
  4246. QDF_STATUS
  4247. target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
  4248. struct spectral_diag_stats *stats)
  4249. {
  4250. struct target_if_spectral *spectral = NULL;
  4251. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4252. if (!spectral) {
  4253. spectral_err("SPECTRAL : Module doesn't exist");
  4254. return QDF_STATUS_E_FAILURE;
  4255. }
  4256. qdf_mem_copy(stats, &spectral->diag_stats,
  4257. sizeof(struct spectral_diag_stats));
  4258. return QDF_STATUS_SUCCESS;
  4259. }
  4260. /**
  4261. * target_if_register_spectral_wmi_ops() - Register Spectral WMI operations
  4262. * @psoc: Pointer to psoc object
  4263. * @wmi_ops: Pointer to the structure having Spectral WMI operations
  4264. *
  4265. * API for registering Spectral WMI operations in
  4266. * spectral internal data structure
  4267. *
  4268. * Return: QDF_STATUS
  4269. */
  4270. static QDF_STATUS
  4271. target_if_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc,
  4272. struct spectral_wmi_ops *wmi_ops)
  4273. {
  4274. struct target_if_psoc_spectral *psoc_spectral;
  4275. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4276. if (!psoc_spectral) {
  4277. spectral_err("Spectral LMAC object is null");
  4278. return QDF_STATUS_E_INVAL;
  4279. }
  4280. psoc_spectral->wmi_ops = *wmi_ops;
  4281. return QDF_STATUS_SUCCESS;
  4282. }
  4283. /**
  4284. * target_if_register_spectral_tgt_ops() - Register Spectral target operations
  4285. * @psoc: Pointer to psoc object
  4286. * @tgt_ops: Pointer to the structure having Spectral target operations
  4287. *
  4288. * API for registering Spectral target operations in
  4289. * spectral internal data structure
  4290. *
  4291. * Return: QDF_STATUS
  4292. */
  4293. static QDF_STATUS
  4294. target_if_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc,
  4295. struct spectral_tgt_ops *tgt_ops)
  4296. {
  4297. if (!psoc) {
  4298. spectral_err("psoc is null");
  4299. return QDF_STATUS_E_INVAL;
  4300. }
  4301. ops_tgt = *tgt_ops;
  4302. return QDF_STATUS_SUCCESS;
  4303. }
  4304. /**
  4305. * target_if_register_netlink_cb() - Register Netlink callbacks
  4306. * @pdev: Pointer to pdev object
  4307. * @nl_cb: Netlink callbacks to register
  4308. *
  4309. * Return: void
  4310. */
  4311. static void
  4312. target_if_register_netlink_cb(
  4313. struct wlan_objmgr_pdev *pdev,
  4314. struct spectral_nl_cb *nl_cb)
  4315. {
  4316. struct target_if_spectral *spectral = NULL;
  4317. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4318. if (!spectral) {
  4319. spectral_err("SPECTRAL : Module doesn't exist");
  4320. return;
  4321. }
  4322. qdf_mem_copy(&spectral->nl_cb, nl_cb, sizeof(struct spectral_nl_cb));
  4323. if (spectral->use_nl_bcast)
  4324. spectral->send_phy_data = spectral->nl_cb.send_nl_bcast;
  4325. else
  4326. spectral->send_phy_data = spectral->nl_cb.send_nl_unicast;
  4327. }
  4328. /**
  4329. * target_if_use_nl_bcast() - Get whether to use broadcast/unicast while sending
  4330. * Netlink messages to the application layer
  4331. * @pdev: Pointer to pdev object
  4332. *
  4333. * Return: true for broadcast, false for unicast
  4334. */
  4335. static bool
  4336. target_if_use_nl_bcast(struct wlan_objmgr_pdev *pdev)
  4337. {
  4338. struct target_if_spectral *spectral = NULL;
  4339. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4340. if (!spectral) {
  4341. spectral_err("SPECTRAL : Module doesn't exist");
  4342. return false;
  4343. }
  4344. return spectral->use_nl_bcast;
  4345. }
  4346. /**
  4347. * target_if_deregister_netlink_cb() - De-register Netlink callbacks
  4348. * @pdev: Pointer to pdev object
  4349. *
  4350. * Return: void
  4351. */
  4352. static void
  4353. target_if_deregister_netlink_cb(struct wlan_objmgr_pdev *pdev)
  4354. {
  4355. struct target_if_spectral *spectral = NULL;
  4356. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4357. if (!spectral) {
  4358. spectral_err("SPECTRAL : Module doesn't exist");
  4359. return;
  4360. }
  4361. qdf_mem_zero(&spectral->nl_cb, sizeof(struct spectral_nl_cb));
  4362. }
  4363. static int
  4364. target_if_process_spectral_report(struct wlan_objmgr_pdev *pdev,
  4365. void *payload)
  4366. {
  4367. struct target_if_spectral *spectral = NULL;
  4368. struct target_if_spectral_ops *p_sops = NULL;
  4369. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4370. if (!spectral) {
  4371. spectral_err("SPECTRAL : Module doesn't exist");
  4372. return -EPERM;
  4373. }
  4374. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  4375. if (!p_sops) {
  4376. spectral_err("p_sops is null");
  4377. return -EPERM;
  4378. }
  4379. return p_sops->process_spectral_report(pdev, payload);
  4380. }
  4381. #ifdef DIRECT_BUF_RX_DEBUG
  4382. static inline void
  4383. target_if_sptrl_debug_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  4384. {
  4385. if (!tx_ops) {
  4386. spectral_err("tx_ops is NULL");
  4387. return;
  4388. }
  4389. tx_ops->sptrl_tx_ops.sptrlto_set_dma_debug =
  4390. target_if_spectral_set_dma_debug;
  4391. tx_ops->sptrl_tx_ops.sptrlto_check_and_do_dbr_ring_debug =
  4392. target_if_spectral_check_and_do_dbr_ring_debug;
  4393. tx_ops->sptrl_tx_ops.sptrlto_check_and_do_dbr_buff_debug =
  4394. target_if_spectral_check_and_do_dbr_buff_debug;
  4395. }
  4396. #else
  4397. static inline void
  4398. target_if_sptrl_debug_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  4399. {
  4400. }
  4401. #endif
  4402. #if defined(WLAN_CONV_SPECTRAL_ENABLE) && defined(SPECTRAL_MODULIZED_ENABLE)
  4403. /**
  4404. * target_if_spectral_wmi_unified_register_event_handler() - Wrapper function to
  4405. * register WMI event handler
  4406. * @psoc: Pointer to psoc object
  4407. * @event_id: Event id
  4408. * @handler_func: Handler function
  4409. * @rx_ctx: Context of WMI event processing
  4410. *
  4411. * Wrapper function to register WMI event handler
  4412. *
  4413. * Return: 0 for success else failure
  4414. */
  4415. static int
  4416. target_if_spectral_wmi_unified_register_event_handler(
  4417. struct wlan_objmgr_psoc *psoc,
  4418. wmi_conv_event_id event_id,
  4419. wmi_unified_event_handler handler_func,
  4420. uint8_t rx_ctx)
  4421. {
  4422. wmi_unified_t wmi_handle;
  4423. struct target_if_psoc_spectral *psoc_spectral;
  4424. if (!psoc) {
  4425. spectral_err("psoc is null");
  4426. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4427. }
  4428. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4429. if (!wmi_handle) {
  4430. spectral_err("WMI handle is null");
  4431. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4432. }
  4433. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4434. if (!psoc_spectral) {
  4435. spectral_err("spectral object is null");
  4436. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4437. }
  4438. return psoc_spectral->wmi_ops.wmi_unified_register_event_handler(
  4439. wmi_handle, event_id, handler_func, rx_ctx);
  4440. }
  4441. /**
  4442. * target_if_spectral_wmi_unified_unregister_event_handler() - Wrapper function
  4443. * to unregister WMI event handler
  4444. * @psoc: Pointer to psoc object
  4445. * @event_id: Event id
  4446. *
  4447. * Wrapper function to unregister WMI event handler
  4448. *
  4449. * Return: 0 for success else failure
  4450. */
  4451. static int
  4452. target_if_spectral_wmi_unified_unregister_event_handler(
  4453. struct wlan_objmgr_psoc *psoc,
  4454. wmi_conv_event_id event_id)
  4455. {
  4456. wmi_unified_t wmi_handle;
  4457. struct target_if_psoc_spectral *psoc_spectral;
  4458. if (!psoc) {
  4459. spectral_err("psoc is null");
  4460. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4461. }
  4462. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4463. if (!wmi_handle) {
  4464. spectral_err("WMI handle is null");
  4465. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4466. }
  4467. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4468. if (!psoc_spectral) {
  4469. spectral_err("spectral object is null");
  4470. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4471. }
  4472. return psoc_spectral->wmi_ops.wmi_unified_unregister_event_handler(
  4473. wmi_handle, event_id);
  4474. }
  4475. /**
  4476. * target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param() - Wrapper
  4477. * function to extract fixed parameters from start scan response event
  4478. * @psoc: Pointer to psoc object
  4479. * @evt_buf: Event buffer
  4480. * @param: Start scan response parameters
  4481. *
  4482. * Wrapper function to extract fixed parameters from start scan response event
  4483. *
  4484. * Return: QDF_STATUS
  4485. */
  4486. static QDF_STATUS
  4487. target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param(
  4488. struct wlan_objmgr_psoc *psoc,
  4489. uint8_t *evt_buf,
  4490. struct spectral_startscan_resp_params *param)
  4491. {
  4492. wmi_unified_t wmi_handle;
  4493. struct target_if_psoc_spectral *psoc_spectral;
  4494. if (!psoc) {
  4495. spectral_err("psoc is null");
  4496. return QDF_STATUS_E_INVAL;
  4497. }
  4498. if (!evt_buf) {
  4499. spectral_err("WMI event buffer is null");
  4500. return QDF_STATUS_E_INVAL;
  4501. }
  4502. if (!param) {
  4503. spectral_err("Spectral startscan response parameters is null");
  4504. return QDF_STATUS_E_INVAL;
  4505. }
  4506. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4507. if (!wmi_handle) {
  4508. spectral_err("WMI handle is null");
  4509. return QDF_STATUS_E_INVAL;
  4510. }
  4511. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4512. if (!psoc_spectral) {
  4513. spectral_err("spectral object is null");
  4514. return QDF_STATUS_E_FAILURE;
  4515. }
  4516. return psoc_spectral->wmi_ops.wmi_extract_pdev_sscan_fw_cmd_fixed_param(
  4517. wmi_handle, evt_buf, param);
  4518. }
  4519. /**
  4520. * target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index() - Wrapper
  4521. * function to extract start and end indices of primary 80 MHz, 5 MHz and
  4522. * secondary 80 MHz FFT bins
  4523. * @psoc: Pointer to psoc object
  4524. * @evt_buf: Event buffer
  4525. * @param: FFT bin start and end indices
  4526. *
  4527. * Wrapper function to extract start and end indices of primary 80 MHz, 5 MHz
  4528. * and secondary 80 MHz FFT bins
  4529. *
  4530. * Return: QDF_STATUS
  4531. */
  4532. static QDF_STATUS
  4533. target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index(
  4534. struct wlan_objmgr_psoc *psoc,
  4535. uint8_t *evt_buf,
  4536. struct spectral_fft_bin_markers_160_165mhz *param)
  4537. {
  4538. wmi_unified_t wmi_handle;
  4539. struct target_if_psoc_spectral *psoc_spectral;
  4540. if (!psoc) {
  4541. spectral_err("psoc is null");
  4542. return QDF_STATUS_E_INVAL;
  4543. }
  4544. if (!evt_buf) {
  4545. spectral_err("WMI event buffer is null");
  4546. return QDF_STATUS_E_INVAL;
  4547. }
  4548. if (!param) {
  4549. spectral_err("Spectral FFT bin markers is null");
  4550. return QDF_STATUS_E_INVAL;
  4551. }
  4552. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4553. if (!wmi_handle) {
  4554. spectral_err("WMI handle is null");
  4555. return QDF_STATUS_E_INVAL;
  4556. }
  4557. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4558. if (!psoc_spectral) {
  4559. spectral_err("spectral object is null");
  4560. return QDF_STATUS_E_FAILURE;
  4561. }
  4562. return psoc_spectral->wmi_ops.wmi_extract_pdev_sscan_fft_bin_index(
  4563. wmi_handle, evt_buf, param);
  4564. }
  4565. /**
  4566. * target_if_spectral_get_psoc_from_scn_handle() - Wrapper function to get psoc
  4567. * object from scn handle
  4568. * @scn: scn handle
  4569. *
  4570. * Wrapper function to get psoc object from scn handle
  4571. *
  4572. * Return: Pointer to psoc object
  4573. */
  4574. static struct wlan_objmgr_psoc *
  4575. target_if_spectral_get_psoc_from_scn_handle(ol_scn_t scn)
  4576. {
  4577. if (!scn) {
  4578. spectral_err("scn is null");
  4579. return NULL;
  4580. }
  4581. return ops_tgt.tgt_get_psoc_from_scn_hdl(scn);
  4582. }
  4583. #else
  4584. /**
  4585. * target_if_spectral_wmi_unified_register_event_handler() - Wrapper function to
  4586. * register WMI event handler
  4587. * @psoc: Pointer to psoc object
  4588. * @event_id: Event id
  4589. * @handler_func: Handler function
  4590. * @rx_ctx: Context of WMI event processing
  4591. *
  4592. * Wrapper function to register WMI event handler
  4593. *
  4594. * Return: 0 for success else failure
  4595. */
  4596. static int
  4597. target_if_spectral_wmi_unified_register_event_handler(
  4598. struct wlan_objmgr_psoc *psoc,
  4599. wmi_conv_event_id event_id,
  4600. wmi_unified_event_handler handler_func,
  4601. uint8_t rx_ctx)
  4602. {
  4603. wmi_unified_t wmi_handle;
  4604. if (!psoc) {
  4605. spectral_err("psoc is null");
  4606. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4607. }
  4608. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4609. if (!wmi_handle) {
  4610. spectral_err("WMI handle is null");
  4611. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4612. }
  4613. return wmi_unified_register_event_handler(wmi_handle, event_id,
  4614. handler_func, rx_ctx);
  4615. }
  4616. /**
  4617. * target_if_spectral_wmi_unified_unregister_event_handler() - Wrapper function
  4618. * to unregister WMI event handler
  4619. * @psoc: Pointer to psoc object
  4620. * @event_id: Event id
  4621. *
  4622. * Wrapper function to unregister WMI event handler
  4623. *
  4624. * Return: 0 for success else failure
  4625. */
  4626. static int
  4627. target_if_spectral_wmi_unified_unregister_event_handler(
  4628. struct wlan_objmgr_psoc *psoc,
  4629. wmi_conv_event_id event_id)
  4630. {
  4631. wmi_unified_t wmi_handle;
  4632. if (!psoc) {
  4633. spectral_err("psoc is null");
  4634. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4635. }
  4636. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4637. if (!wmi_handle) {
  4638. spectral_err("WMI handle is null");
  4639. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4640. }
  4641. return wmi_unified_unregister_event_handler(wmi_handle, event_id);
  4642. }
  4643. /**
  4644. * target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param() - Wrapper
  4645. * function to extract fixed parameters from start scan response event
  4646. * @psoc: Pointer to psoc object
  4647. * @evt_buf: Event buffer
  4648. * @param: Start scan response parameters
  4649. *
  4650. * Wrapper function to extract fixed parameters from start scan response event
  4651. *
  4652. * Return: QDF_STATUS
  4653. */
  4654. static QDF_STATUS
  4655. target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param(
  4656. struct wlan_objmgr_psoc *psoc,
  4657. uint8_t *evt_buf,
  4658. struct spectral_startscan_resp_params *param)
  4659. {
  4660. wmi_unified_t wmi_handle;
  4661. if (!psoc) {
  4662. spectral_err("psoc is null");
  4663. return QDF_STATUS_E_INVAL;
  4664. }
  4665. if (!evt_buf) {
  4666. spectral_err("WMI event buffer is null");
  4667. return QDF_STATUS_E_INVAL;
  4668. }
  4669. if (!param) {
  4670. spectral_err("Spectral startscan response parameters is null");
  4671. return QDF_STATUS_E_INVAL;
  4672. }
  4673. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4674. if (!wmi_handle) {
  4675. spectral_err("WMI handle is null");
  4676. return QDF_STATUS_E_INVAL;
  4677. }
  4678. return wmi_extract_pdev_sscan_fw_cmd_fixed_param(wmi_handle, evt_buf,
  4679. param);
  4680. }
  4681. /**
  4682. * target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index() - Wrapper
  4683. * function to extract start and end indices of primary 80 MHz, 5 MHz and
  4684. * secondary 80 MHz FFT bins
  4685. * @psoc: Pointer to psoc object
  4686. * @evt_buf: Event buffer
  4687. * @param: FFT bin start and end indices
  4688. *
  4689. * Wrapper function to extract start and end indices of primary 80 MHz, 5 MHz
  4690. * and secondary 80 MHz FFT bins
  4691. *
  4692. * Return: QDF_STATUS
  4693. */
  4694. static QDF_STATUS
  4695. target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index(
  4696. struct wlan_objmgr_psoc *psoc,
  4697. uint8_t *evt_buf,
  4698. struct spectral_fft_bin_markers_160_165mhz *param)
  4699. {
  4700. wmi_unified_t wmi_handle;
  4701. if (!psoc) {
  4702. spectral_err("psoc is null");
  4703. return QDF_STATUS_E_INVAL;
  4704. }
  4705. if (!evt_buf) {
  4706. spectral_err("WMI event buffer is null");
  4707. return QDF_STATUS_E_INVAL;
  4708. }
  4709. if (!param) {
  4710. spectral_err("Spectral FFT bin markers is null");
  4711. return QDF_STATUS_E_INVAL;
  4712. }
  4713. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4714. if (!wmi_handle) {
  4715. spectral_err("WMI handle is null");
  4716. return QDF_STATUS_E_INVAL;
  4717. }
  4718. return wmi_extract_pdev_sscan_fft_bin_index(wmi_handle, evt_buf, param);
  4719. }
  4720. /**
  4721. * target_if_spectral_get_psoc_from_scn_handle() - Wrapper function to get psoc
  4722. * object from scn handle
  4723. * @scn: scn handle
  4724. *
  4725. * Wrapper function to get psoc object from scn handle
  4726. *
  4727. * Return: Pointer to psoc object
  4728. */
  4729. static struct wlan_objmgr_psoc *
  4730. target_if_spectral_get_psoc_from_scn_handle(ol_scn_t scn)
  4731. {
  4732. if (!scn) {
  4733. spectral_err("scn is null");
  4734. return NULL;
  4735. }
  4736. return target_if_get_psoc_from_scn_hdl(scn);
  4737. }
  4738. #endif
  4739. /**
  4740. * target_if_spectral_fw_param_event_handler() - WMI event handler to
  4741. * process start scan response event
  4742. * @scn: Pointer to scn object
  4743. * @data_buf: Pointer to event buffer
  4744. * @data_len: Length of event buffer
  4745. *
  4746. * Return: 0 for success, else failure
  4747. */
  4748. static int
  4749. target_if_spectral_fw_param_event_handler(ol_scn_t scn, uint8_t *data_buf,
  4750. uint32_t data_len)
  4751. {
  4752. QDF_STATUS status;
  4753. struct wlan_objmgr_psoc *psoc;
  4754. struct wlan_objmgr_pdev *pdev;
  4755. struct wmi_unified *wmi_handle;
  4756. struct spectral_startscan_resp_params event_params = {0};
  4757. struct target_if_psoc_spectral *psoc_spectral;
  4758. struct target_if_spectral *spectral;
  4759. if (!scn) {
  4760. spectral_err("scn handle is null");
  4761. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4762. }
  4763. if (!data_buf) {
  4764. spectral_err("WMI event buffer null");
  4765. return qdf_status_to_os_return(QDF_STATUS_E_INVAL);
  4766. }
  4767. psoc = target_if_spectral_get_psoc_from_scn_handle(scn);
  4768. if (!psoc) {
  4769. spectral_err("psoc is null");
  4770. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4771. }
  4772. psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc);
  4773. if (!psoc_spectral) {
  4774. spectral_err("spectral object is null");
  4775. return QDF_STATUS_E_FAILURE;
  4776. }
  4777. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  4778. if (!wmi_handle) {
  4779. spectral_err("WMI handle is null");
  4780. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4781. }
  4782. status = target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param(
  4783. psoc, data_buf, &event_params);
  4784. if (QDF_IS_STATUS_ERROR(status)) {
  4785. spectral_err("unable to extract sscan fw fixed params");
  4786. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4787. }
  4788. pdev = wlan_objmgr_get_pdev_by_id(psoc, event_params.pdev_id,
  4789. WLAN_SPECTRAL_ID);
  4790. if (!pdev) {
  4791. spectral_err("pdev is null");
  4792. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4793. }
  4794. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4795. if (!spectral) {
  4796. spectral_err("spectral object is null");
  4797. wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID);
  4798. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4799. }
  4800. if (event_params.num_fft_bin_index == 1) {
  4801. status =
  4802. target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index(
  4803. psoc, data_buf,
  4804. &spectral->rparams.marker[event_params.smode]);
  4805. if (QDF_IS_STATUS_ERROR(status)) {
  4806. spectral_err("unable to extract sscan fw fixed params");
  4807. wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID);
  4808. return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
  4809. }
  4810. } else {
  4811. spectral->rparams.marker[event_params.smode].is_valid = false;
  4812. }
  4813. wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID);
  4814. return qdf_status_to_os_return(QDF_STATUS_SUCCESS);
  4815. }
  4816. static QDF_STATUS
  4817. target_if_spectral_register_events(struct wlan_objmgr_psoc *psoc)
  4818. {
  4819. int ret;
  4820. if (!psoc) {
  4821. spectral_err("psoc is null");
  4822. return QDF_STATUS_E_INVAL;
  4823. }
  4824. ret = target_if_spectral_wmi_unified_register_event_handler(
  4825. psoc,
  4826. wmi_pdev_sscan_fw_param_eventid,
  4827. target_if_spectral_fw_param_event_handler,
  4828. WMI_RX_UMAC_CTX);
  4829. if (ret)
  4830. spectral_debug("event handler not supported, ret=%d", ret);
  4831. return QDF_STATUS_SUCCESS;
  4832. }
  4833. static QDF_STATUS
  4834. target_if_spectral_unregister_events(struct wlan_objmgr_psoc *psoc)
  4835. {
  4836. int ret;
  4837. if (!psoc) {
  4838. spectral_err("psoc is null");
  4839. return QDF_STATUS_E_INVAL;
  4840. }
  4841. ret = target_if_spectral_wmi_unified_unregister_event_handler(
  4842. psoc, wmi_pdev_sscan_fw_param_eventid);
  4843. if (ret)
  4844. spectral_debug("Unregister WMI event handler failed, ret = %d",
  4845. ret);
  4846. return QDF_STATUS_SUCCESS;
  4847. }
  4848. void
  4849. target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  4850. {
  4851. tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_init =
  4852. target_if_pdev_spectral_init;
  4853. tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_deinit =
  4854. target_if_pdev_spectral_deinit;
  4855. tx_ops->sptrl_tx_ops.sptrlto_psoc_spectral_init =
  4856. target_if_psoc_spectral_init;
  4857. tx_ops->sptrl_tx_ops.sptrlto_psoc_spectral_deinit =
  4858. target_if_psoc_spectral_deinit;
  4859. tx_ops->sptrl_tx_ops.sptrlto_set_spectral_config =
  4860. target_if_set_spectral_config;
  4861. tx_ops->sptrl_tx_ops.sptrlto_get_spectral_config =
  4862. target_if_get_spectral_config;
  4863. tx_ops->sptrl_tx_ops.sptrlto_start_spectral_scan =
  4864. target_if_start_spectral_scan;
  4865. tx_ops->sptrl_tx_ops.sptrlto_stop_spectral_scan =
  4866. target_if_stop_spectral_scan;
  4867. tx_ops->sptrl_tx_ops.sptrlto_is_spectral_active =
  4868. target_if_is_spectral_active;
  4869. tx_ops->sptrl_tx_ops.sptrlto_is_spectral_enabled =
  4870. target_if_is_spectral_enabled;
  4871. tx_ops->sptrl_tx_ops.sptrlto_set_debug_level =
  4872. target_if_set_debug_level;
  4873. tx_ops->sptrl_tx_ops.sptrlto_get_debug_level =
  4874. target_if_get_debug_level;
  4875. tx_ops->sptrl_tx_ops.sptrlto_get_spectral_capinfo =
  4876. target_if_get_spectral_capinfo;
  4877. tx_ops->sptrl_tx_ops.sptrlto_get_spectral_diagstats =
  4878. target_if_get_spectral_diagstats;
  4879. tx_ops->sptrl_tx_ops.sptrlto_register_spectral_wmi_ops =
  4880. target_if_register_spectral_wmi_ops;
  4881. tx_ops->sptrl_tx_ops.sptrlto_register_spectral_tgt_ops =
  4882. target_if_register_spectral_tgt_ops;
  4883. tx_ops->sptrl_tx_ops.sptrlto_register_netlink_cb =
  4884. target_if_register_netlink_cb;
  4885. tx_ops->sptrl_tx_ops.sptrlto_use_nl_bcast =
  4886. target_if_use_nl_bcast;
  4887. tx_ops->sptrl_tx_ops.sptrlto_deregister_netlink_cb =
  4888. target_if_deregister_netlink_cb;
  4889. tx_ops->sptrl_tx_ops.sptrlto_process_spectral_report =
  4890. target_if_process_spectral_report;
  4891. tx_ops->sptrl_tx_ops.sptrlto_direct_dma_support =
  4892. target_if_spectral_direct_dma_support;
  4893. tx_ops->sptrl_tx_ops.sptrlto_register_events =
  4894. target_if_spectral_register_events;
  4895. tx_ops->sptrl_tx_ops.sptrlto_unregister_events =
  4896. target_if_spectral_unregister_events;
  4897. target_if_sptrl_debug_register_tx_ops(tx_ops);
  4898. }
  4899. qdf_export_symbol(target_if_sptrl_register_tx_ops);
  4900. void
  4901. target_if_spectral_send_intf_found_msg(struct wlan_objmgr_pdev *pdev,
  4902. uint16_t cw_int, uint32_t dcs_enabled)
  4903. {
  4904. struct spectral_samp_msg *msg = NULL;
  4905. struct target_if_spectral_ops *p_sops = NULL;
  4906. struct target_if_spectral *spectral = NULL;
  4907. spectral = get_target_if_spectral_handle_from_pdev(pdev);
  4908. if (!spectral) {
  4909. spectral_err("SPECTRAL : Module doesn't exist");
  4910. return;
  4911. }
  4912. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  4913. if (!p_sops) {
  4914. spectral_err("p_sops is null");
  4915. return;
  4916. }
  4917. msg = (struct spectral_samp_msg *)spectral->nl_cb.get_sbuff(
  4918. spectral->pdev_obj,
  4919. SPECTRAL_MSG_INTERFERENCE_NOTIFICATION,
  4920. SPECTRAL_MSG_BUF_NEW);
  4921. if (msg) {
  4922. msg->int_type = cw_int ?
  4923. SPECTRAL_DCS_INT_CW : SPECTRAL_DCS_INT_WIFI;
  4924. msg->dcs_enabled = dcs_enabled;
  4925. msg->signature = SPECTRAL_SIGNATURE;
  4926. p_sops->get_mac_address(spectral, msg->macaddr);
  4927. if (spectral->send_phy_data
  4928. (pdev,
  4929. SPECTRAL_MSG_INTERFERENCE_NOTIFICATION) == 0)
  4930. spectral->spectral_sent_msg++;
  4931. }
  4932. }
  4933. qdf_export_symbol(target_if_spectral_send_intf_found_msg);