dp_htt.c 168 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <htt.h>
  19. #include <hal_hw_headers.h>
  20. #include <hal_api.h>
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "dp_internal.h"
  24. #include "dp_rx.h"
  25. #include "dp_rx_mon.h"
  26. #include "htt_stats.h"
  27. #include "htt_ppdu_stats.h"
  28. #include "dp_htt.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "cdp_txrx_cmn_struct.h"
  31. #ifdef FEATURE_PERPKT_INFO
  32. #include "dp_ratetable.h"
  33. #endif
  34. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  35. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  36. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  37. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  38. #define HTT_PID_BIT_MASK 0x3
  39. #define DP_EXT_MSG_LENGTH 2048
  40. #define HTT_HEADER_LEN 16
  41. #define HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN 16
  42. #define HTT_SHIFT_UPPER_TIMESTAMP 32
  43. #define HTT_MASK_UPPER_TIMESTAMP 0xFFFFFFFF00000000
  44. /*
  45. * dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap() - Get ppdu stats tlv
  46. * bitmap for sniffer mode
  47. * @bitmap: received bitmap
  48. *
  49. * Return: expected bitmap value, returns zero if doesn't match with
  50. * either 64-bit Tx window or 256-bit window tlv bitmap
  51. */
  52. int
  53. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap)
  54. {
  55. if (bitmap == (HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64))
  56. return HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64;
  57. else if (bitmap == (HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256))
  58. return HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256;
  59. return 0;
  60. }
  61. #ifdef FEATURE_PERPKT_INFO
  62. /*
  63. * dp_peer_find_by_id_valid - check if peer exists for given id
  64. * @soc: core DP soc context
  65. * @peer_id: peer id from peer object can be retrieved
  66. *
  67. * Return: true if peer exists of false otherwise
  68. */
  69. static
  70. bool dp_peer_find_by_id_valid(struct dp_soc *soc, uint16_t peer_id)
  71. {
  72. struct dp_peer *peer = dp_peer_get_ref_by_id(soc, peer_id,
  73. DP_MOD_ID_HTT);
  74. if (peer) {
  75. /*
  76. * Decrement the peer ref which is taken as part of
  77. * dp_peer_get_ref_by_id if PEER_LOCK_REF_PROTECT is enabled
  78. */
  79. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  80. return true;
  81. }
  82. return false;
  83. }
  84. /*
  85. * dp_peer_copy_delay_stats() - copy ppdu stats to peer delayed stats.
  86. * @peer: Datapath peer handle
  87. * @ppdu: User PPDU Descriptor
  88. * @cur_ppdu_id: PPDU_ID
  89. *
  90. * Return: None
  91. *
  92. * on Tx data frame, we may get delayed ba set
  93. * in htt_ppdu_stats_user_common_tlv. which mean we get Block Ack(BA) after we
  94. * request Block Ack Request(BAR). Successful msdu is received only after Block
  95. * Ack. To populate peer stats we need successful msdu(data frame).
  96. * So we hold the Tx data stats on delayed_ba for stats update.
  97. */
  98. static void
  99. dp_peer_copy_delay_stats(struct dp_peer *peer,
  100. struct cdp_tx_completion_ppdu_user *ppdu,
  101. uint32_t cur_ppdu_id)
  102. {
  103. struct dp_pdev *pdev;
  104. struct dp_vdev *vdev;
  105. if (peer->last_delayed_ba) {
  106. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  107. "BA not yet recv for prev delayed ppdu[%d] - cur ppdu[%d]",
  108. peer->last_delayed_ba_ppduid, cur_ppdu_id);
  109. vdev = peer->vdev;
  110. if (vdev) {
  111. pdev = vdev->pdev;
  112. pdev->stats.cdp_delayed_ba_not_recev++;
  113. }
  114. }
  115. peer->delayed_ba_ppdu_stats.ltf_size = ppdu->ltf_size;
  116. peer->delayed_ba_ppdu_stats.stbc = ppdu->stbc;
  117. peer->delayed_ba_ppdu_stats.he_re = ppdu->he_re;
  118. peer->delayed_ba_ppdu_stats.txbf = ppdu->txbf;
  119. peer->delayed_ba_ppdu_stats.bw = ppdu->bw;
  120. peer->delayed_ba_ppdu_stats.nss = ppdu->nss;
  121. peer->delayed_ba_ppdu_stats.preamble = ppdu->preamble;
  122. peer->delayed_ba_ppdu_stats.gi = ppdu->gi;
  123. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  124. peer->delayed_ba_ppdu_stats.ldpc = ppdu->ldpc;
  125. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  126. peer->delayed_ba_ppdu_stats.mpdu_tried_ucast = ppdu->mpdu_tried_ucast;
  127. peer->delayed_ba_ppdu_stats.mpdu_tried_mcast = ppdu->mpdu_tried_mcast;
  128. peer->delayed_ba_ppdu_stats.frame_ctrl = ppdu->frame_ctrl;
  129. peer->delayed_ba_ppdu_stats.qos_ctrl = ppdu->qos_ctrl;
  130. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  131. peer->delayed_ba_ppdu_stats.ru_start = ppdu->ru_start;
  132. peer->delayed_ba_ppdu_stats.ru_tones = ppdu->ru_tones;
  133. peer->delayed_ba_ppdu_stats.is_mcast = ppdu->is_mcast;
  134. peer->delayed_ba_ppdu_stats.user_pos = ppdu->user_pos;
  135. peer->delayed_ba_ppdu_stats.mu_group_id = ppdu->mu_group_id;
  136. peer->delayed_ba_ppdu_stats.mcs = ppdu->mcs;
  137. peer->last_delayed_ba = true;
  138. ppdu->debug_copied = true;
  139. }
  140. /*
  141. * dp_peer_copy_stats_to_bar() - copy delayed stats to ppdu stats.
  142. * @peer: Datapath peer handle
  143. * @ppdu: PPDU Descriptor
  144. *
  145. * Return: None
  146. *
  147. * For Tx BAR, PPDU stats TLV include Block Ack info. PPDU info
  148. * from Tx BAR frame not required to populate peer stats.
  149. * But we need successful MPDU and MSDU to update previous
  150. * transmitted Tx data frame. Overwrite ppdu stats with the previous
  151. * stored ppdu stats.
  152. */
  153. static void
  154. dp_peer_copy_stats_to_bar(struct dp_peer *peer,
  155. struct cdp_tx_completion_ppdu_user *ppdu)
  156. {
  157. ppdu->ltf_size = peer->delayed_ba_ppdu_stats.ltf_size;
  158. ppdu->stbc = peer->delayed_ba_ppdu_stats.stbc;
  159. ppdu->he_re = peer->delayed_ba_ppdu_stats.he_re;
  160. ppdu->txbf = peer->delayed_ba_ppdu_stats.txbf;
  161. ppdu->bw = peer->delayed_ba_ppdu_stats.bw;
  162. ppdu->nss = peer->delayed_ba_ppdu_stats.nss;
  163. ppdu->preamble = peer->delayed_ba_ppdu_stats.preamble;
  164. ppdu->gi = peer->delayed_ba_ppdu_stats.gi;
  165. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  166. ppdu->ldpc = peer->delayed_ba_ppdu_stats.ldpc;
  167. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  168. ppdu->mpdu_tried_ucast = peer->delayed_ba_ppdu_stats.mpdu_tried_ucast;
  169. ppdu->mpdu_tried_mcast = peer->delayed_ba_ppdu_stats.mpdu_tried_mcast;
  170. ppdu->frame_ctrl = peer->delayed_ba_ppdu_stats.frame_ctrl;
  171. ppdu->qos_ctrl = peer->delayed_ba_ppdu_stats.qos_ctrl;
  172. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  173. ppdu->ru_start = peer->delayed_ba_ppdu_stats.ru_start;
  174. ppdu->ru_tones = peer->delayed_ba_ppdu_stats.ru_tones;
  175. ppdu->is_mcast = peer->delayed_ba_ppdu_stats.is_mcast;
  176. ppdu->user_pos = peer->delayed_ba_ppdu_stats.user_pos;
  177. ppdu->mu_group_id = peer->delayed_ba_ppdu_stats.mu_group_id;
  178. ppdu->mcs = peer->delayed_ba_ppdu_stats.mcs;
  179. peer->last_delayed_ba = false;
  180. ppdu->debug_copied = true;
  181. }
  182. /*
  183. * dp_tx_rate_stats_update() - Update rate per-peer statistics
  184. * @peer: Datapath peer handle
  185. * @ppdu: PPDU Descriptor
  186. *
  187. * Return: None
  188. */
  189. static void
  190. dp_tx_rate_stats_update(struct dp_peer *peer,
  191. struct cdp_tx_completion_ppdu_user *ppdu)
  192. {
  193. uint32_t ratekbps = 0;
  194. uint64_t ppdu_tx_rate = 0;
  195. uint32_t rix;
  196. uint16_t ratecode = 0;
  197. if (!peer || !ppdu)
  198. return;
  199. if (ppdu->completion_status != HTT_PPDU_STATS_USER_STATUS_OK)
  200. return;
  201. ratekbps = dp_getrateindex(ppdu->gi,
  202. ppdu->mcs,
  203. ppdu->nss,
  204. ppdu->preamble,
  205. ppdu->bw,
  206. &rix,
  207. &ratecode);
  208. DP_STATS_UPD(peer, tx.last_tx_rate, ratekbps);
  209. if (!ratekbps)
  210. return;
  211. /* Calculate goodput in non-training period
  212. * In training period, don't do anything as
  213. * pending pkt is send as goodput.
  214. */
  215. if ((!peer->bss_peer) && (!ppdu->sa_is_training)) {
  216. ppdu->sa_goodput = ((ratekbps / CDP_NUM_KB_IN_MB) *
  217. (CDP_PERCENT_MACRO - ppdu->current_rate_per));
  218. }
  219. ppdu->rix = rix;
  220. ppdu->tx_ratekbps = ratekbps;
  221. ppdu->tx_ratecode = ratecode;
  222. peer->stats.tx.avg_tx_rate =
  223. dp_ath_rate_lpf(peer->stats.tx.avg_tx_rate, ratekbps);
  224. ppdu_tx_rate = dp_ath_rate_out(peer->stats.tx.avg_tx_rate);
  225. DP_STATS_UPD(peer, tx.rnd_avg_tx_rate, ppdu_tx_rate);
  226. if (peer->vdev) {
  227. /*
  228. * In STA mode:
  229. * We get ucast stats as BSS peer stats.
  230. *
  231. * In AP mode:
  232. * We get mcast stats as BSS peer stats.
  233. * We get ucast stats as assoc peer stats.
  234. */
  235. if (peer->vdev->opmode == wlan_op_mode_ap && peer->bss_peer) {
  236. peer->vdev->stats.tx.mcast_last_tx_rate = ratekbps;
  237. peer->vdev->stats.tx.mcast_last_tx_rate_mcs = ppdu->mcs;
  238. } else {
  239. peer->vdev->stats.tx.last_tx_rate = ratekbps;
  240. peer->vdev->stats.tx.last_tx_rate_mcs = ppdu->mcs;
  241. }
  242. }
  243. }
  244. /*
  245. * dp_tx_stats_update() - Update per-peer statistics
  246. * @pdev: Datapath pdev handle
  247. * @peer: Datapath peer handle
  248. * @ppdu: PPDU Descriptor
  249. * @ack_rssi: RSSI of last ack received
  250. *
  251. * Return: None
  252. */
  253. static void
  254. dp_tx_stats_update(struct dp_pdev *pdev, struct dp_peer *peer,
  255. struct cdp_tx_completion_ppdu_user *ppdu,
  256. uint32_t ack_rssi)
  257. {
  258. uint8_t preamble, mcs;
  259. uint16_t num_msdu;
  260. uint16_t num_mpdu;
  261. uint16_t mpdu_tried;
  262. uint16_t mpdu_failed;
  263. preamble = ppdu->preamble;
  264. mcs = ppdu->mcs;
  265. num_msdu = ppdu->num_msdu;
  266. num_mpdu = ppdu->mpdu_success;
  267. mpdu_tried = ppdu->mpdu_tried_ucast + ppdu->mpdu_tried_mcast;
  268. mpdu_failed = mpdu_tried - num_mpdu;
  269. /* If the peer statistics are already processed as part of
  270. * per-MSDU completion handler, do not process these again in per-PPDU
  271. * indications */
  272. if (pdev->soc->process_tx_status)
  273. return;
  274. if (ppdu->completion_status != HTT_PPDU_STATS_USER_STATUS_OK) {
  275. /*
  276. * All failed mpdu will be retried, so incrementing
  277. * retries mpdu based on mpdu failed. Even for
  278. * ack failure i.e for long retries we get
  279. * mpdu failed equal mpdu tried.
  280. */
  281. DP_STATS_INC(peer, tx.retries, mpdu_failed);
  282. DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
  283. return;
  284. }
  285. if (ppdu->is_ppdu_cookie_valid)
  286. DP_STATS_INC(peer, tx.num_ppdu_cookie_valid, 1);
  287. if (ppdu->mu_group_id <= MAX_MU_GROUP_ID &&
  288. ppdu->ppdu_type != HTT_PPDU_STATS_PPDU_TYPE_SU) {
  289. if (unlikely(!(ppdu->mu_group_id & (MAX_MU_GROUP_ID - 1))))
  290. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  291. "mu_group_id out of bound!!\n");
  292. else
  293. DP_STATS_UPD(peer, tx.mu_group_id[ppdu->mu_group_id],
  294. (ppdu->user_pos + 1));
  295. }
  296. if (ppdu->ppdu_type == HTT_PPDU_STATS_PPDU_TYPE_MU_OFDMA ||
  297. ppdu->ppdu_type == HTT_PPDU_STATS_PPDU_TYPE_MU_MIMO_OFDMA) {
  298. DP_STATS_UPD(peer, tx.ru_tones, ppdu->ru_tones);
  299. DP_STATS_UPD(peer, tx.ru_start, ppdu->ru_start);
  300. switch (ppdu->ru_tones) {
  301. case RU_26:
  302. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].num_msdu,
  303. num_msdu);
  304. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].num_mpdu,
  305. num_mpdu);
  306. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].mpdu_tried,
  307. mpdu_tried);
  308. break;
  309. case RU_52:
  310. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].num_msdu,
  311. num_msdu);
  312. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].num_mpdu,
  313. num_mpdu);
  314. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].mpdu_tried,
  315. mpdu_tried);
  316. break;
  317. case RU_106:
  318. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].num_msdu,
  319. num_msdu);
  320. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].num_mpdu,
  321. num_mpdu);
  322. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].mpdu_tried,
  323. mpdu_tried);
  324. break;
  325. case RU_242:
  326. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].num_msdu,
  327. num_msdu);
  328. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].num_mpdu,
  329. num_mpdu);
  330. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].mpdu_tried,
  331. mpdu_tried);
  332. break;
  333. case RU_484:
  334. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].num_msdu,
  335. num_msdu);
  336. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].num_mpdu,
  337. num_mpdu);
  338. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].mpdu_tried,
  339. mpdu_tried);
  340. break;
  341. case RU_996:
  342. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].num_msdu,
  343. num_msdu);
  344. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].num_mpdu,
  345. num_mpdu);
  346. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].mpdu_tried,
  347. mpdu_tried);
  348. break;
  349. }
  350. }
  351. /*
  352. * All failed mpdu will be retried, so incrementing
  353. * retries mpdu based on mpdu failed. Even for
  354. * ack failure i.e for long retries we get
  355. * mpdu failed equal mpdu tried.
  356. */
  357. DP_STATS_INC(peer, tx.retries, mpdu_failed);
  358. DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
  359. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].num_msdu,
  360. num_msdu);
  361. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].num_mpdu,
  362. num_mpdu);
  363. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].mpdu_tried,
  364. mpdu_tried);
  365. DP_STATS_INC_PKT(peer, tx.comp_pkt,
  366. num_msdu, (ppdu->success_bytes +
  367. ppdu->retry_bytes + ppdu->failed_bytes));
  368. DP_STATS_UPD(peer, tx.tx_rate, ppdu->tx_rate);
  369. DP_STATS_INC(peer, tx.sgi_count[ppdu->gi], num_msdu);
  370. DP_STATS_INC(peer, tx.bw[ppdu->bw], num_msdu);
  371. DP_STATS_INC(peer, tx.nss[ppdu->nss], num_msdu);
  372. if (ppdu->tid < CDP_DATA_TID_MAX)
  373. DP_STATS_INC(peer, tx.wme_ac_type[TID_TO_WME_AC(ppdu->tid)],
  374. num_msdu);
  375. DP_STATS_INCC(peer, tx.stbc, num_msdu, ppdu->stbc);
  376. DP_STATS_INCC(peer, tx.ldpc, num_msdu, ppdu->ldpc);
  377. if (!(ppdu->is_mcast) && ppdu->ack_rssi_valid)
  378. DP_STATS_UPD(peer, tx.last_ack_rssi, ack_rssi);
  379. DP_STATS_INCC(peer,
  380. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  381. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  382. DP_STATS_INCC(peer,
  383. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  384. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  385. DP_STATS_INCC(peer,
  386. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  387. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  388. DP_STATS_INCC(peer,
  389. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  390. ((mcs < (MAX_MCS_11B)) && (preamble == DOT11_B)));
  391. DP_STATS_INCC(peer,
  392. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  393. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  394. DP_STATS_INCC(peer,
  395. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  396. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  397. DP_STATS_INCC(peer,
  398. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  399. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  400. DP_STATS_INCC(peer,
  401. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  402. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  403. DP_STATS_INCC(peer,
  404. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  405. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  406. DP_STATS_INCC(peer,
  407. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  408. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  409. DP_STATS_INCC(peer, tx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
  410. DP_STATS_INCC(peer, tx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
  411. DP_STATS_INCC(peer, tx.pream_punct_cnt, 1, ppdu->pream_punct);
  412. dp_peer_stats_notify(pdev, peer);
  413. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  414. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  415. &peer->stats, ppdu->peer_id,
  416. UPDATE_PEER_STATS, pdev->pdev_id);
  417. #endif
  418. }
  419. #endif
  420. QDF_STATUS dp_rx_populate_cbf_hdr(struct dp_soc *soc,
  421. uint32_t mac_id,
  422. uint32_t event,
  423. qdf_nbuf_t mpdu,
  424. uint32_t msdu_timestamp)
  425. {
  426. uint32_t data_size, hdr_size, ppdu_id, align4byte;
  427. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  428. uint32_t *msg_word;
  429. if (!pdev)
  430. return QDF_STATUS_E_INVAL;
  431. ppdu_id = pdev->ppdu_info.com_info.ppdu_id;
  432. hdr_size = HTT_T2H_PPDU_STATS_IND_HDR_SIZE
  433. + qdf_offsetof(htt_ppdu_stats_rx_mgmtctrl_payload_tlv, payload);
  434. data_size = qdf_nbuf_len(mpdu);
  435. qdf_nbuf_push_head(mpdu, hdr_size);
  436. msg_word = (uint32_t *)qdf_nbuf_data(mpdu);
  437. /*
  438. * Populate the PPDU Stats Indication header
  439. */
  440. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_T2H_MSG_TYPE_PPDU_STATS_IND);
  441. HTT_T2H_PPDU_STATS_MAC_ID_SET(*msg_word, mac_id);
  442. HTT_T2H_PPDU_STATS_PDEV_ID_SET(*msg_word, pdev->pdev_id);
  443. align4byte = ((data_size +
  444. qdf_offsetof(htt_ppdu_stats_rx_mgmtctrl_payload_tlv, payload)
  445. + 3) >> 2) << 2;
  446. HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_SET(*msg_word, align4byte);
  447. msg_word++;
  448. HTT_T2H_PPDU_STATS_PPDU_ID_SET(*msg_word, ppdu_id);
  449. msg_word++;
  450. *msg_word = msdu_timestamp;
  451. msg_word++;
  452. /* Skip reserved field */
  453. msg_word++;
  454. /*
  455. * Populate MGMT_CTRL Payload TLV first
  456. */
  457. HTT_STATS_TLV_TAG_SET(*msg_word,
  458. HTT_PPDU_STATS_RX_MGMTCTRL_PAYLOAD_TLV);
  459. align4byte = ((data_size - sizeof(htt_tlv_hdr_t) +
  460. qdf_offsetof(htt_ppdu_stats_rx_mgmtctrl_payload_tlv, payload)
  461. + 3) >> 2) << 2;
  462. HTT_STATS_TLV_LENGTH_SET(*msg_word, align4byte);
  463. msg_word++;
  464. HTT_PPDU_STATS_RX_MGMTCTRL_TLV_FRAME_LENGTH_SET(
  465. *msg_word, data_size);
  466. msg_word++;
  467. dp_wdi_event_handler(event, soc, (void *)mpdu,
  468. HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
  469. qdf_nbuf_pull_head(mpdu, hdr_size);
  470. return QDF_STATUS_SUCCESS;
  471. }
  472. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  473. #include "dp_tx_capture.h"
  474. #else
  475. static inline void
  476. dp_process_ppdu_stats_update_failed_bitmap(struct dp_pdev *pdev,
  477. void *data,
  478. uint32_t ppdu_id,
  479. uint32_t size)
  480. {
  481. }
  482. #endif
  483. /*
  484. * htt_htc_pkt_alloc() - Allocate HTC packet buffer
  485. * @htt_soc: HTT SOC handle
  486. *
  487. * Return: Pointer to htc packet buffer
  488. */
  489. static struct dp_htt_htc_pkt *
  490. htt_htc_pkt_alloc(struct htt_soc *soc)
  491. {
  492. struct dp_htt_htc_pkt_union *pkt = NULL;
  493. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  494. if (soc->htt_htc_pkt_freelist) {
  495. pkt = soc->htt_htc_pkt_freelist;
  496. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  497. }
  498. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  499. if (!pkt)
  500. pkt = qdf_mem_malloc(sizeof(*pkt));
  501. if (!pkt)
  502. return NULL;
  503. htc_packet_set_magic_cookie(&(pkt->u.pkt.htc_pkt), 0);
  504. return &pkt->u.pkt; /* not actually a dereference */
  505. }
  506. /*
  507. * htt_htc_pkt_free() - Free HTC packet buffer
  508. * @htt_soc: HTT SOC handle
  509. */
  510. static void
  511. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  512. {
  513. struct dp_htt_htc_pkt_union *u_pkt =
  514. (struct dp_htt_htc_pkt_union *)pkt;
  515. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  516. htc_packet_set_magic_cookie(&(u_pkt->u.pkt.htc_pkt), 0);
  517. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  518. soc->htt_htc_pkt_freelist = u_pkt;
  519. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  520. }
  521. /*
  522. * htt_htc_pkt_pool_free() - Free HTC packet pool
  523. * @htt_soc: HTT SOC handle
  524. */
  525. void
  526. htt_htc_pkt_pool_free(struct htt_soc *soc)
  527. {
  528. struct dp_htt_htc_pkt_union *pkt, *next;
  529. pkt = soc->htt_htc_pkt_freelist;
  530. while (pkt) {
  531. next = pkt->u.next;
  532. qdf_mem_free(pkt);
  533. pkt = next;
  534. }
  535. soc->htt_htc_pkt_freelist = NULL;
  536. }
  537. /*
  538. * htt_htc_misc_pkt_list_trim() - trim misc list
  539. * @htt_soc: HTT SOC handle
  540. * @level: max no. of pkts in list
  541. */
  542. static void
  543. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  544. {
  545. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  546. int i = 0;
  547. qdf_nbuf_t netbuf;
  548. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  549. pkt = soc->htt_htc_pkt_misclist;
  550. while (pkt) {
  551. next = pkt->u.next;
  552. /* trim the out grown list*/
  553. if (++i > level) {
  554. netbuf =
  555. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  556. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  557. qdf_nbuf_free(netbuf);
  558. qdf_mem_free(pkt);
  559. pkt = NULL;
  560. if (prev)
  561. prev->u.next = NULL;
  562. }
  563. prev = pkt;
  564. pkt = next;
  565. }
  566. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  567. }
  568. /*
  569. * htt_htc_misc_pkt_list_add() - Add pkt to misc list
  570. * @htt_soc: HTT SOC handle
  571. * @dp_htt_htc_pkt: pkt to be added to list
  572. */
  573. static void
  574. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  575. {
  576. struct dp_htt_htc_pkt_union *u_pkt =
  577. (struct dp_htt_htc_pkt_union *)pkt;
  578. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  579. pkt->htc_pkt.Endpoint)
  580. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  581. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  582. if (soc->htt_htc_pkt_misclist) {
  583. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  584. soc->htt_htc_pkt_misclist = u_pkt;
  585. } else {
  586. soc->htt_htc_pkt_misclist = u_pkt;
  587. }
  588. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  589. /* only ce pipe size + tx_queue_depth could possibly be in use
  590. * free older packets in the misclist
  591. */
  592. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  593. }
  594. /**
  595. * DP_HTT_SEND_HTC_PKT() - Send htt packet from host
  596. * @soc : HTT SOC handle
  597. * @pkt: pkt to be send
  598. * @cmd : command to be recorded in dp htt logger
  599. * @buf : Pointer to buffer needs to be recored for above cmd
  600. *
  601. * Return: None
  602. */
  603. static inline QDF_STATUS DP_HTT_SEND_HTC_PKT(struct htt_soc *soc,
  604. struct dp_htt_htc_pkt *pkt,
  605. uint8_t cmd, uint8_t *buf)
  606. {
  607. QDF_STATUS status;
  608. htt_command_record(soc->htt_logger_handle, cmd, buf);
  609. status = htc_send_pkt(soc->htc_soc, &pkt->htc_pkt);
  610. if (status == QDF_STATUS_SUCCESS)
  611. htt_htc_misc_pkt_list_add(soc, pkt);
  612. else
  613. soc->stats.fail_count++;
  614. return status;
  615. }
  616. /*
  617. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  618. * @htt_soc: HTT SOC handle
  619. */
  620. static void
  621. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  622. {
  623. struct dp_htt_htc_pkt_union *pkt, *next;
  624. qdf_nbuf_t netbuf;
  625. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  626. pkt = soc->htt_htc_pkt_misclist;
  627. while (pkt) {
  628. next = pkt->u.next;
  629. if (htc_packet_get_magic_cookie(&(pkt->u.pkt.htc_pkt)) !=
  630. HTC_PACKET_MAGIC_COOKIE) {
  631. pkt = next;
  632. soc->stats.skip_count++;
  633. continue;
  634. }
  635. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  636. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  637. soc->stats.htc_pkt_free++;
  638. dp_htt_info("%pK: Pkt free count %d",
  639. soc->dp_soc, soc->stats.htc_pkt_free);
  640. qdf_nbuf_free(netbuf);
  641. qdf_mem_free(pkt);
  642. pkt = next;
  643. }
  644. soc->htt_htc_pkt_misclist = NULL;
  645. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  646. dp_info("HTC Packets, fail count = %d, skip count = %d",
  647. soc->stats.fail_count, soc->stats.skip_count);
  648. }
  649. /*
  650. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianness differ
  651. * @tgt_mac_addr: Target MAC
  652. * @buffer: Output buffer
  653. */
  654. static u_int8_t *
  655. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  656. {
  657. #ifdef BIG_ENDIAN_HOST
  658. /*
  659. * The host endianness is opposite of the target endianness.
  660. * To make u_int32_t elements come out correctly, the target->host
  661. * upload has swizzled the bytes in each u_int32_t element of the
  662. * message.
  663. * For byte-array message fields like the MAC address, this
  664. * upload swizzling puts the bytes in the wrong order, and needs
  665. * to be undone.
  666. */
  667. buffer[0] = tgt_mac_addr[3];
  668. buffer[1] = tgt_mac_addr[2];
  669. buffer[2] = tgt_mac_addr[1];
  670. buffer[3] = tgt_mac_addr[0];
  671. buffer[4] = tgt_mac_addr[7];
  672. buffer[5] = tgt_mac_addr[6];
  673. return buffer;
  674. #else
  675. /*
  676. * The host endianness matches the target endianness -
  677. * we can use the mac addr directly from the message buffer.
  678. */
  679. return tgt_mac_addr;
  680. #endif
  681. }
  682. /*
  683. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  684. * @soc: SOC handle
  685. * @status: Completion status
  686. * @netbuf: HTT buffer
  687. */
  688. static void
  689. dp_htt_h2t_send_complete_free_netbuf(
  690. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  691. {
  692. qdf_nbuf_free(netbuf);
  693. }
  694. /*
  695. * dp_htt_h2t_send_complete() - H2T completion handler
  696. * @context: Opaque context (HTT SOC handle)
  697. * @htc_pkt: HTC packet
  698. */
  699. static void
  700. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  701. {
  702. void (*send_complete_part2)(
  703. void *soc, QDF_STATUS status, qdf_nbuf_t msdu);
  704. struct htt_soc *soc = (struct htt_soc *) context;
  705. struct dp_htt_htc_pkt *htt_pkt;
  706. qdf_nbuf_t netbuf;
  707. send_complete_part2 = htc_pkt->pPktContext;
  708. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  709. /* process (free or keep) the netbuf that held the message */
  710. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  711. /*
  712. * adf sendcomplete is required for windows only
  713. */
  714. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  715. if (send_complete_part2) {
  716. send_complete_part2(
  717. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  718. }
  719. /* free the htt_htc_pkt / HTC_PACKET object */
  720. htt_htc_pkt_free(soc, htt_pkt);
  721. }
  722. /*
  723. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  724. * @htt_soc: HTT SOC handle
  725. *
  726. * Return: 0 on success; error code on failure
  727. */
  728. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  729. {
  730. struct dp_htt_htc_pkt *pkt;
  731. qdf_nbuf_t msg;
  732. uint32_t *msg_word;
  733. QDF_STATUS status;
  734. msg = qdf_nbuf_alloc(
  735. soc->osdev,
  736. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  737. /* reserve room for the HTC header */
  738. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  739. if (!msg)
  740. return QDF_STATUS_E_NOMEM;
  741. /*
  742. * Set the length of the message.
  743. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  744. * separately during the below call to qdf_nbuf_push_head.
  745. * The contribution from the HTC header is added separately inside HTC.
  746. */
  747. if (qdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES) == NULL) {
  748. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  749. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  750. __func__);
  751. return QDF_STATUS_E_FAILURE;
  752. }
  753. /* fill in the message contents */
  754. msg_word = (u_int32_t *) qdf_nbuf_data(msg);
  755. /* rewind beyond alignment pad to get to the HTC header reserved area */
  756. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  757. *msg_word = 0;
  758. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  759. pkt = htt_htc_pkt_alloc(soc);
  760. if (!pkt) {
  761. qdf_nbuf_free(msg);
  762. return QDF_STATUS_E_FAILURE;
  763. }
  764. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  765. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  766. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  767. qdf_nbuf_len(msg), soc->htc_endpoint,
  768. HTC_TX_PACKET_TAG_RTPM_PUT_RC);
  769. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  770. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_VERSION_REQ,
  771. NULL);
  772. if (status != QDF_STATUS_SUCCESS) {
  773. qdf_nbuf_free(msg);
  774. htt_htc_pkt_free(soc, pkt);
  775. }
  776. return status;
  777. }
  778. /*
  779. * htt_srng_setup() - Send SRNG setup message to target
  780. * @htt_soc: HTT SOC handle
  781. * @mac_id: MAC Id
  782. * @hal_srng: Opaque HAL SRNG pointer
  783. * @hal_ring_type: SRNG ring type
  784. *
  785. * Return: 0 on success; error code on failure
  786. */
  787. int htt_srng_setup(struct htt_soc *soc, int mac_id,
  788. hal_ring_handle_t hal_ring_hdl,
  789. int hal_ring_type)
  790. {
  791. struct dp_htt_htc_pkt *pkt;
  792. qdf_nbuf_t htt_msg;
  793. uint32_t *msg_word;
  794. struct hal_srng_params srng_params;
  795. qdf_dma_addr_t hp_addr, tp_addr;
  796. uint32_t ring_entry_size =
  797. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  798. int htt_ring_type, htt_ring_id;
  799. uint8_t *htt_logger_bufp;
  800. int target_pdev_id;
  801. int lmac_id = dp_get_lmac_id_for_pdev_id(soc->dp_soc, 0, mac_id);
  802. QDF_STATUS status;
  803. /* Sizes should be set in 4-byte words */
  804. ring_entry_size = ring_entry_size >> 2;
  805. htt_msg = qdf_nbuf_alloc(soc->osdev,
  806. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  807. /* reserve room for the HTC header */
  808. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  809. if (!htt_msg)
  810. goto fail0;
  811. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  812. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_ring_hdl);
  813. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_ring_hdl);
  814. switch (hal_ring_type) {
  815. case RXDMA_BUF:
  816. #ifdef QCA_HOST2FW_RXBUF_RING
  817. if (srng_params.ring_id ==
  818. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0)) {
  819. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  820. htt_ring_type = HTT_SW_TO_SW_RING;
  821. #ifdef IPA_OFFLOAD
  822. } else if (srng_params.ring_id ==
  823. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2)) {
  824. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  825. htt_ring_type = HTT_SW_TO_SW_RING;
  826. #endif
  827. #else
  828. if (srng_params.ring_id ==
  829. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  830. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  831. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  832. htt_ring_type = HTT_SW_TO_HW_RING;
  833. #endif
  834. } else if (srng_params.ring_id ==
  835. #ifdef IPA_OFFLOAD
  836. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  837. #else
  838. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  839. #endif
  840. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  841. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  842. htt_ring_type = HTT_SW_TO_HW_RING;
  843. } else {
  844. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  845. "%s: Ring %d currently not supported",
  846. __func__, srng_params.ring_id);
  847. goto fail1;
  848. }
  849. dp_info("ring_type %d ring_id %d htt_ring_id %d hp_addr 0x%llx tp_addr 0x%llx",
  850. hal_ring_type, srng_params.ring_id, htt_ring_id,
  851. (uint64_t)hp_addr,
  852. (uint64_t)tp_addr);
  853. break;
  854. case RXDMA_MONITOR_BUF:
  855. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  856. htt_ring_type = HTT_SW_TO_HW_RING;
  857. break;
  858. case RXDMA_MONITOR_STATUS:
  859. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  860. htt_ring_type = HTT_SW_TO_HW_RING;
  861. break;
  862. case RXDMA_MONITOR_DST:
  863. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  864. htt_ring_type = HTT_HW_TO_SW_RING;
  865. break;
  866. case RXDMA_MONITOR_DESC:
  867. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  868. htt_ring_type = HTT_SW_TO_HW_RING;
  869. break;
  870. case RXDMA_DST:
  871. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  872. htt_ring_type = HTT_HW_TO_SW_RING;
  873. break;
  874. default:
  875. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  876. "%s: Ring currently not supported", __func__);
  877. goto fail1;
  878. }
  879. /*
  880. * Set the length of the message.
  881. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  882. * separately during the below call to qdf_nbuf_push_head.
  883. * The contribution from the HTC header is added separately inside HTC.
  884. */
  885. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  886. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  887. "%s: Failed to expand head for SRING_SETUP msg",
  888. __func__);
  889. return QDF_STATUS_E_FAILURE;
  890. }
  891. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  892. /* rewind beyond alignment pad to get to the HTC header reserved area */
  893. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  894. /* word 0 */
  895. *msg_word = 0;
  896. htt_logger_bufp = (uint8_t *)msg_word;
  897. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  898. target_pdev_id =
  899. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, mac_id);
  900. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  901. (htt_ring_type == HTT_HW_TO_SW_RING))
  902. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, target_pdev_id);
  903. else
  904. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  905. dp_info("mac_id %d", mac_id);
  906. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  907. /* TODO: Discuss with FW on changing this to unique ID and using
  908. * htt_ring_type to send the type of ring
  909. */
  910. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  911. /* word 1 */
  912. msg_word++;
  913. *msg_word = 0;
  914. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  915. srng_params.ring_base_paddr & 0xffffffff);
  916. /* word 2 */
  917. msg_word++;
  918. *msg_word = 0;
  919. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  920. (uint64_t)srng_params.ring_base_paddr >> 32);
  921. /* word 3 */
  922. msg_word++;
  923. *msg_word = 0;
  924. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  925. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  926. (ring_entry_size * srng_params.num_entries));
  927. dp_info("entry_size %d", ring_entry_size);
  928. dp_info("num_entries %d", srng_params.num_entries);
  929. dp_info("ring_size %d", (ring_entry_size * srng_params.num_entries));
  930. if (htt_ring_type == HTT_SW_TO_HW_RING)
  931. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  932. *msg_word, 1);
  933. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  934. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  935. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  936. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  937. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  938. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  939. /* word 4 */
  940. msg_word++;
  941. *msg_word = 0;
  942. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  943. hp_addr & 0xffffffff);
  944. /* word 5 */
  945. msg_word++;
  946. *msg_word = 0;
  947. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  948. (uint64_t)hp_addr >> 32);
  949. /* word 6 */
  950. msg_word++;
  951. *msg_word = 0;
  952. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  953. tp_addr & 0xffffffff);
  954. /* word 7 */
  955. msg_word++;
  956. *msg_word = 0;
  957. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  958. (uint64_t)tp_addr >> 32);
  959. /* word 8 */
  960. msg_word++;
  961. *msg_word = 0;
  962. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  963. srng_params.msi_addr & 0xffffffff);
  964. /* word 9 */
  965. msg_word++;
  966. *msg_word = 0;
  967. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  968. (uint64_t)(srng_params.msi_addr) >> 32);
  969. /* word 10 */
  970. msg_word++;
  971. *msg_word = 0;
  972. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  973. qdf_cpu_to_le32(srng_params.msi_data));
  974. /* word 11 */
  975. msg_word++;
  976. *msg_word = 0;
  977. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  978. srng_params.intr_batch_cntr_thres_entries *
  979. ring_entry_size);
  980. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  981. srng_params.intr_timer_thres_us >> 3);
  982. /* word 12 */
  983. msg_word++;
  984. *msg_word = 0;
  985. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  986. /* TODO: Setting low threshold to 1/8th of ring size - see
  987. * if this needs to be configurable
  988. */
  989. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  990. srng_params.low_threshold);
  991. }
  992. /* "response_required" field should be set if a HTT response message is
  993. * required after setting up the ring.
  994. */
  995. pkt = htt_htc_pkt_alloc(soc);
  996. if (!pkt)
  997. goto fail1;
  998. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  999. SET_HTC_PACKET_INFO_TX(
  1000. &pkt->htc_pkt,
  1001. dp_htt_h2t_send_complete_free_netbuf,
  1002. qdf_nbuf_data(htt_msg),
  1003. qdf_nbuf_len(htt_msg),
  1004. soc->htc_endpoint,
  1005. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1006. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1007. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  1008. htt_logger_bufp);
  1009. if (status != QDF_STATUS_SUCCESS) {
  1010. qdf_nbuf_free(htt_msg);
  1011. htt_htc_pkt_free(soc, pkt);
  1012. }
  1013. return status;
  1014. fail1:
  1015. qdf_nbuf_free(htt_msg);
  1016. fail0:
  1017. return QDF_STATUS_E_FAILURE;
  1018. }
  1019. #ifdef QCA_SUPPORT_FULL_MON
  1020. /**
  1021. * htt_h2t_full_mon_cfg() - Send full monitor configuarion msg to FW
  1022. *
  1023. * @htt_soc: HTT Soc handle
  1024. * @pdev_id: Radio id
  1025. * @dp_full_mon_config: enabled/disable configuration
  1026. *
  1027. * Return: Success when HTT message is sent, error on failure
  1028. */
  1029. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  1030. uint8_t pdev_id,
  1031. enum dp_full_mon_config config)
  1032. {
  1033. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  1034. struct dp_htt_htc_pkt *pkt;
  1035. qdf_nbuf_t htt_msg;
  1036. uint32_t *msg_word;
  1037. uint8_t *htt_logger_bufp;
  1038. htt_msg = qdf_nbuf_alloc(soc->osdev,
  1039. HTT_MSG_BUF_SIZE(
  1040. HTT_RX_FULL_MONITOR_MODE_SETUP_SZ),
  1041. /* reserve room for the HTC header */
  1042. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  1043. 4,
  1044. TRUE);
  1045. if (!htt_msg)
  1046. return QDF_STATUS_E_FAILURE;
  1047. /*
  1048. * Set the length of the message.
  1049. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  1050. * separately during the below call to qdf_nbuf_push_head.
  1051. * The contribution from the HTC header is added separately inside HTC.
  1052. */
  1053. if (!qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ)) {
  1054. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1055. "%s: Failed to expand head for RX Ring Cfg msg",
  1056. __func__);
  1057. goto fail1;
  1058. }
  1059. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  1060. /* rewind beyond alignment pad to get to the HTC header reserved area */
  1061. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  1062. /* word 0 */
  1063. *msg_word = 0;
  1064. htt_logger_bufp = (uint8_t *)msg_word;
  1065. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE);
  1066. HTT_RX_FULL_MONITOR_MODE_OPERATION_PDEV_ID_SET(
  1067. *msg_word, DP_SW2HW_MACID(pdev_id));
  1068. msg_word++;
  1069. *msg_word = 0;
  1070. /* word 1 */
  1071. if (config == DP_FULL_MON_ENABLE) {
  1072. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  1073. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, true);
  1074. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, true);
  1075. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  1076. } else if (config == DP_FULL_MON_DISABLE) {
  1077. /* As per MAC team's suggestion, While disbaling full monitor
  1078. * mode, Set 'en' bit to true in full monitor mode register.
  1079. */
  1080. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  1081. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, false);
  1082. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, false);
  1083. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  1084. }
  1085. pkt = htt_htc_pkt_alloc(soc);
  1086. if (!pkt) {
  1087. qdf_err("HTC packet allocation failed");
  1088. goto fail1;
  1089. }
  1090. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1091. SET_HTC_PACKET_INFO_TX(
  1092. &pkt->htc_pkt,
  1093. dp_htt_h2t_send_complete_free_netbuf,
  1094. qdf_nbuf_data(htt_msg),
  1095. qdf_nbuf_len(htt_msg),
  1096. soc->htc_endpoint,
  1097. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1098. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1099. qdf_info("config: %d", config);
  1100. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  1101. htt_logger_bufp);
  1102. return QDF_STATUS_SUCCESS;
  1103. fail1:
  1104. qdf_nbuf_free(htt_msg);
  1105. return QDF_STATUS_E_FAILURE;
  1106. }
  1107. #else
  1108. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  1109. uint8_t pdev_id,
  1110. enum dp_full_mon_config config)
  1111. {
  1112. return 0;
  1113. }
  1114. #endif
  1115. /*
  1116. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  1117. * config message to target
  1118. * @htt_soc: HTT SOC handle
  1119. * @pdev_id: WIN- PDEV Id, MCL- mac id
  1120. * @hal_srng: Opaque HAL SRNG pointer
  1121. * @hal_ring_type: SRNG ring type
  1122. * @ring_buf_size: SRNG buffer size
  1123. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  1124. * Return: 0 on success; error code on failure
  1125. */
  1126. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  1127. hal_ring_handle_t hal_ring_hdl,
  1128. int hal_ring_type, int ring_buf_size,
  1129. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  1130. {
  1131. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  1132. struct dp_htt_htc_pkt *pkt;
  1133. qdf_nbuf_t htt_msg;
  1134. uint32_t *msg_word;
  1135. struct hal_srng_params srng_params;
  1136. uint32_t htt_ring_type, htt_ring_id;
  1137. uint32_t tlv_filter;
  1138. uint8_t *htt_logger_bufp;
  1139. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
  1140. uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
  1141. int target_pdev_id;
  1142. QDF_STATUS status;
  1143. htt_msg = qdf_nbuf_alloc(soc->osdev,
  1144. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  1145. /* reserve room for the HTC header */
  1146. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  1147. if (!htt_msg)
  1148. goto fail0;
  1149. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  1150. switch (hal_ring_type) {
  1151. case RXDMA_BUF:
  1152. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  1153. htt_ring_type = HTT_SW_TO_HW_RING;
  1154. break;
  1155. case RXDMA_MONITOR_BUF:
  1156. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  1157. htt_ring_type = HTT_SW_TO_HW_RING;
  1158. break;
  1159. case RXDMA_MONITOR_STATUS:
  1160. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  1161. htt_ring_type = HTT_SW_TO_HW_RING;
  1162. break;
  1163. case RXDMA_MONITOR_DST:
  1164. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  1165. htt_ring_type = HTT_HW_TO_SW_RING;
  1166. break;
  1167. case RXDMA_MONITOR_DESC:
  1168. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  1169. htt_ring_type = HTT_SW_TO_HW_RING;
  1170. break;
  1171. case RXDMA_DST:
  1172. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  1173. htt_ring_type = HTT_HW_TO_SW_RING;
  1174. break;
  1175. default:
  1176. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1177. "%s: Ring currently not supported", __func__);
  1178. goto fail1;
  1179. }
  1180. /*
  1181. * Set the length of the message.
  1182. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  1183. * separately during the below call to qdf_nbuf_push_head.
  1184. * The contribution from the HTC header is added separately inside HTC.
  1185. */
  1186. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  1187. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1188. "%s: Failed to expand head for RX Ring Cfg msg",
  1189. __func__);
  1190. goto fail1; /* failure */
  1191. }
  1192. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  1193. /* rewind beyond alignment pad to get to the HTC header reserved area */
  1194. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  1195. /* word 0 */
  1196. htt_logger_bufp = (uint8_t *)msg_word;
  1197. *msg_word = 0;
  1198. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  1199. /*
  1200. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  1201. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  1202. */
  1203. target_pdev_id =
  1204. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, pdev_id);
  1205. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  1206. htt_ring_type == HTT_SW_TO_HW_RING)
  1207. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  1208. target_pdev_id);
  1209. /* TODO: Discuss with FW on changing this to unique ID and using
  1210. * htt_ring_type to send the type of ring
  1211. */
  1212. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  1213. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  1214. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  1215. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  1216. htt_tlv_filter->offset_valid);
  1217. if (mon_drop_th > 0)
  1218. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1219. 1);
  1220. else
  1221. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1222. 0);
  1223. /* word 1 */
  1224. msg_word++;
  1225. *msg_word = 0;
  1226. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  1227. ring_buf_size);
  1228. /* word 2 */
  1229. msg_word++;
  1230. *msg_word = 0;
  1231. if (htt_tlv_filter->enable_fp) {
  1232. /* TYPE: MGMT */
  1233. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1234. FP, MGMT, 0000,
  1235. (htt_tlv_filter->fp_mgmt_filter &
  1236. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1237. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1238. FP, MGMT, 0001,
  1239. (htt_tlv_filter->fp_mgmt_filter &
  1240. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1241. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1242. FP, MGMT, 0010,
  1243. (htt_tlv_filter->fp_mgmt_filter &
  1244. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1245. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1246. FP, MGMT, 0011,
  1247. (htt_tlv_filter->fp_mgmt_filter &
  1248. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1249. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1250. FP, MGMT, 0100,
  1251. (htt_tlv_filter->fp_mgmt_filter &
  1252. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1253. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1254. FP, MGMT, 0101,
  1255. (htt_tlv_filter->fp_mgmt_filter &
  1256. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1257. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1258. FP, MGMT, 0110,
  1259. (htt_tlv_filter->fp_mgmt_filter &
  1260. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1261. /* reserved */
  1262. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  1263. MGMT, 0111,
  1264. (htt_tlv_filter->fp_mgmt_filter &
  1265. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1266. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1267. FP, MGMT, 1000,
  1268. (htt_tlv_filter->fp_mgmt_filter &
  1269. FILTER_MGMT_BEACON) ? 1 : 0);
  1270. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1271. FP, MGMT, 1001,
  1272. (htt_tlv_filter->fp_mgmt_filter &
  1273. FILTER_MGMT_ATIM) ? 1 : 0);
  1274. }
  1275. if (htt_tlv_filter->enable_md) {
  1276. /* TYPE: MGMT */
  1277. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1278. MD, MGMT, 0000,
  1279. (htt_tlv_filter->md_mgmt_filter &
  1280. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1281. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1282. MD, MGMT, 0001,
  1283. (htt_tlv_filter->md_mgmt_filter &
  1284. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1285. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1286. MD, MGMT, 0010,
  1287. (htt_tlv_filter->md_mgmt_filter &
  1288. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1289. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1290. MD, MGMT, 0011,
  1291. (htt_tlv_filter->md_mgmt_filter &
  1292. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1293. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1294. MD, MGMT, 0100,
  1295. (htt_tlv_filter->md_mgmt_filter &
  1296. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1297. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1298. MD, MGMT, 0101,
  1299. (htt_tlv_filter->md_mgmt_filter &
  1300. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1301. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1302. MD, MGMT, 0110,
  1303. (htt_tlv_filter->md_mgmt_filter &
  1304. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1305. /* reserved */
  1306. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  1307. MGMT, 0111,
  1308. (htt_tlv_filter->md_mgmt_filter &
  1309. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1310. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1311. MD, MGMT, 1000,
  1312. (htt_tlv_filter->md_mgmt_filter &
  1313. FILTER_MGMT_BEACON) ? 1 : 0);
  1314. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1315. MD, MGMT, 1001,
  1316. (htt_tlv_filter->md_mgmt_filter &
  1317. FILTER_MGMT_ATIM) ? 1 : 0);
  1318. }
  1319. if (htt_tlv_filter->enable_mo) {
  1320. /* TYPE: MGMT */
  1321. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1322. MO, MGMT, 0000,
  1323. (htt_tlv_filter->mo_mgmt_filter &
  1324. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1325. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1326. MO, MGMT, 0001,
  1327. (htt_tlv_filter->mo_mgmt_filter &
  1328. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1329. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1330. MO, MGMT, 0010,
  1331. (htt_tlv_filter->mo_mgmt_filter &
  1332. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1333. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1334. MO, MGMT, 0011,
  1335. (htt_tlv_filter->mo_mgmt_filter &
  1336. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1337. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1338. MO, MGMT, 0100,
  1339. (htt_tlv_filter->mo_mgmt_filter &
  1340. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1341. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1342. MO, MGMT, 0101,
  1343. (htt_tlv_filter->mo_mgmt_filter &
  1344. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1345. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1346. MO, MGMT, 0110,
  1347. (htt_tlv_filter->mo_mgmt_filter &
  1348. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1349. /* reserved */
  1350. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  1351. MGMT, 0111,
  1352. (htt_tlv_filter->mo_mgmt_filter &
  1353. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1354. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1355. MO, MGMT, 1000,
  1356. (htt_tlv_filter->mo_mgmt_filter &
  1357. FILTER_MGMT_BEACON) ? 1 : 0);
  1358. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1359. MO, MGMT, 1001,
  1360. (htt_tlv_filter->mo_mgmt_filter &
  1361. FILTER_MGMT_ATIM) ? 1 : 0);
  1362. }
  1363. /* word 3 */
  1364. msg_word++;
  1365. *msg_word = 0;
  1366. if (htt_tlv_filter->enable_fp) {
  1367. /* TYPE: MGMT */
  1368. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1369. FP, MGMT, 1010,
  1370. (htt_tlv_filter->fp_mgmt_filter &
  1371. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1372. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1373. FP, MGMT, 1011,
  1374. (htt_tlv_filter->fp_mgmt_filter &
  1375. FILTER_MGMT_AUTH) ? 1 : 0);
  1376. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1377. FP, MGMT, 1100,
  1378. (htt_tlv_filter->fp_mgmt_filter &
  1379. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1380. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1381. FP, MGMT, 1101,
  1382. (htt_tlv_filter->fp_mgmt_filter &
  1383. FILTER_MGMT_ACTION) ? 1 : 0);
  1384. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1385. FP, MGMT, 1110,
  1386. (htt_tlv_filter->fp_mgmt_filter &
  1387. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1388. /* reserved*/
  1389. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  1390. MGMT, 1111,
  1391. (htt_tlv_filter->fp_mgmt_filter &
  1392. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1393. }
  1394. if (htt_tlv_filter->enable_md) {
  1395. /* TYPE: MGMT */
  1396. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1397. MD, MGMT, 1010,
  1398. (htt_tlv_filter->md_mgmt_filter &
  1399. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1400. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1401. MD, MGMT, 1011,
  1402. (htt_tlv_filter->md_mgmt_filter &
  1403. FILTER_MGMT_AUTH) ? 1 : 0);
  1404. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1405. MD, MGMT, 1100,
  1406. (htt_tlv_filter->md_mgmt_filter &
  1407. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1408. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1409. MD, MGMT, 1101,
  1410. (htt_tlv_filter->md_mgmt_filter &
  1411. FILTER_MGMT_ACTION) ? 1 : 0);
  1412. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1413. MD, MGMT, 1110,
  1414. (htt_tlv_filter->md_mgmt_filter &
  1415. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1416. }
  1417. if (htt_tlv_filter->enable_mo) {
  1418. /* TYPE: MGMT */
  1419. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1420. MO, MGMT, 1010,
  1421. (htt_tlv_filter->mo_mgmt_filter &
  1422. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1423. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1424. MO, MGMT, 1011,
  1425. (htt_tlv_filter->mo_mgmt_filter &
  1426. FILTER_MGMT_AUTH) ? 1 : 0);
  1427. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1428. MO, MGMT, 1100,
  1429. (htt_tlv_filter->mo_mgmt_filter &
  1430. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1431. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1432. MO, MGMT, 1101,
  1433. (htt_tlv_filter->mo_mgmt_filter &
  1434. FILTER_MGMT_ACTION) ? 1 : 0);
  1435. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1436. MO, MGMT, 1110,
  1437. (htt_tlv_filter->mo_mgmt_filter &
  1438. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1439. /* reserved*/
  1440. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1441. MGMT, 1111,
  1442. (htt_tlv_filter->mo_mgmt_filter &
  1443. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1444. }
  1445. /* word 4 */
  1446. msg_word++;
  1447. *msg_word = 0;
  1448. if (htt_tlv_filter->enable_fp) {
  1449. /* TYPE: CTRL */
  1450. /* reserved */
  1451. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1452. CTRL, 0000,
  1453. (htt_tlv_filter->fp_ctrl_filter &
  1454. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1455. /* reserved */
  1456. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1457. CTRL, 0001,
  1458. (htt_tlv_filter->fp_ctrl_filter &
  1459. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1460. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1461. CTRL, 0010,
  1462. (htt_tlv_filter->fp_ctrl_filter &
  1463. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1464. /* reserved */
  1465. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1466. CTRL, 0011,
  1467. (htt_tlv_filter->fp_ctrl_filter &
  1468. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1469. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1470. CTRL, 0100,
  1471. (htt_tlv_filter->fp_ctrl_filter &
  1472. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1473. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1474. CTRL, 0101,
  1475. (htt_tlv_filter->fp_ctrl_filter &
  1476. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1477. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1478. CTRL, 0110,
  1479. (htt_tlv_filter->fp_ctrl_filter &
  1480. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1481. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1482. CTRL, 0111,
  1483. (htt_tlv_filter->fp_ctrl_filter &
  1484. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1485. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1486. CTRL, 1000,
  1487. (htt_tlv_filter->fp_ctrl_filter &
  1488. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1489. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1490. CTRL, 1001,
  1491. (htt_tlv_filter->fp_ctrl_filter &
  1492. FILTER_CTRL_BA) ? 1 : 0);
  1493. }
  1494. if (htt_tlv_filter->enable_md) {
  1495. /* TYPE: CTRL */
  1496. /* reserved */
  1497. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1498. CTRL, 0000,
  1499. (htt_tlv_filter->md_ctrl_filter &
  1500. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1501. /* reserved */
  1502. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1503. CTRL, 0001,
  1504. (htt_tlv_filter->md_ctrl_filter &
  1505. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1506. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1507. CTRL, 0010,
  1508. (htt_tlv_filter->md_ctrl_filter &
  1509. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1510. /* reserved */
  1511. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1512. CTRL, 0011,
  1513. (htt_tlv_filter->md_ctrl_filter &
  1514. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1515. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1516. CTRL, 0100,
  1517. (htt_tlv_filter->md_ctrl_filter &
  1518. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1519. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1520. CTRL, 0101,
  1521. (htt_tlv_filter->md_ctrl_filter &
  1522. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1523. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1524. CTRL, 0110,
  1525. (htt_tlv_filter->md_ctrl_filter &
  1526. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1527. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1528. CTRL, 0111,
  1529. (htt_tlv_filter->md_ctrl_filter &
  1530. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1531. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1532. CTRL, 1000,
  1533. (htt_tlv_filter->md_ctrl_filter &
  1534. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1535. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1536. CTRL, 1001,
  1537. (htt_tlv_filter->md_ctrl_filter &
  1538. FILTER_CTRL_BA) ? 1 : 0);
  1539. }
  1540. if (htt_tlv_filter->enable_mo) {
  1541. /* TYPE: CTRL */
  1542. /* reserved */
  1543. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1544. CTRL, 0000,
  1545. (htt_tlv_filter->mo_ctrl_filter &
  1546. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1547. /* reserved */
  1548. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1549. CTRL, 0001,
  1550. (htt_tlv_filter->mo_ctrl_filter &
  1551. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1552. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1553. CTRL, 0010,
  1554. (htt_tlv_filter->mo_ctrl_filter &
  1555. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1556. /* reserved */
  1557. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1558. CTRL, 0011,
  1559. (htt_tlv_filter->mo_ctrl_filter &
  1560. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1561. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1562. CTRL, 0100,
  1563. (htt_tlv_filter->mo_ctrl_filter &
  1564. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1565. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1566. CTRL, 0101,
  1567. (htt_tlv_filter->mo_ctrl_filter &
  1568. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1569. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1570. CTRL, 0110,
  1571. (htt_tlv_filter->mo_ctrl_filter &
  1572. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1573. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1574. CTRL, 0111,
  1575. (htt_tlv_filter->mo_ctrl_filter &
  1576. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1577. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1578. CTRL, 1000,
  1579. (htt_tlv_filter->mo_ctrl_filter &
  1580. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1581. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1582. CTRL, 1001,
  1583. (htt_tlv_filter->mo_ctrl_filter &
  1584. FILTER_CTRL_BA) ? 1 : 0);
  1585. }
  1586. /* word 5 */
  1587. msg_word++;
  1588. *msg_word = 0;
  1589. if (htt_tlv_filter->enable_fp) {
  1590. /* TYPE: CTRL */
  1591. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1592. CTRL, 1010,
  1593. (htt_tlv_filter->fp_ctrl_filter &
  1594. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1595. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1596. CTRL, 1011,
  1597. (htt_tlv_filter->fp_ctrl_filter &
  1598. FILTER_CTRL_RTS) ? 1 : 0);
  1599. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1600. CTRL, 1100,
  1601. (htt_tlv_filter->fp_ctrl_filter &
  1602. FILTER_CTRL_CTS) ? 1 : 0);
  1603. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1604. CTRL, 1101,
  1605. (htt_tlv_filter->fp_ctrl_filter &
  1606. FILTER_CTRL_ACK) ? 1 : 0);
  1607. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1608. CTRL, 1110,
  1609. (htt_tlv_filter->fp_ctrl_filter &
  1610. FILTER_CTRL_CFEND) ? 1 : 0);
  1611. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1612. CTRL, 1111,
  1613. (htt_tlv_filter->fp_ctrl_filter &
  1614. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1615. /* TYPE: DATA */
  1616. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1617. DATA, MCAST,
  1618. (htt_tlv_filter->fp_data_filter &
  1619. FILTER_DATA_MCAST) ? 1 : 0);
  1620. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1621. DATA, UCAST,
  1622. (htt_tlv_filter->fp_data_filter &
  1623. FILTER_DATA_UCAST) ? 1 : 0);
  1624. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1625. DATA, NULL,
  1626. (htt_tlv_filter->fp_data_filter &
  1627. FILTER_DATA_NULL) ? 1 : 0);
  1628. }
  1629. if (htt_tlv_filter->enable_md) {
  1630. /* TYPE: CTRL */
  1631. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1632. CTRL, 1010,
  1633. (htt_tlv_filter->md_ctrl_filter &
  1634. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1635. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1636. CTRL, 1011,
  1637. (htt_tlv_filter->md_ctrl_filter &
  1638. FILTER_CTRL_RTS) ? 1 : 0);
  1639. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1640. CTRL, 1100,
  1641. (htt_tlv_filter->md_ctrl_filter &
  1642. FILTER_CTRL_CTS) ? 1 : 0);
  1643. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1644. CTRL, 1101,
  1645. (htt_tlv_filter->md_ctrl_filter &
  1646. FILTER_CTRL_ACK) ? 1 : 0);
  1647. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1648. CTRL, 1110,
  1649. (htt_tlv_filter->md_ctrl_filter &
  1650. FILTER_CTRL_CFEND) ? 1 : 0);
  1651. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1652. CTRL, 1111,
  1653. (htt_tlv_filter->md_ctrl_filter &
  1654. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1655. /* TYPE: DATA */
  1656. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1657. DATA, MCAST,
  1658. (htt_tlv_filter->md_data_filter &
  1659. FILTER_DATA_MCAST) ? 1 : 0);
  1660. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1661. DATA, UCAST,
  1662. (htt_tlv_filter->md_data_filter &
  1663. FILTER_DATA_UCAST) ? 1 : 0);
  1664. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1665. DATA, NULL,
  1666. (htt_tlv_filter->md_data_filter &
  1667. FILTER_DATA_NULL) ? 1 : 0);
  1668. }
  1669. if (htt_tlv_filter->enable_mo) {
  1670. /* TYPE: CTRL */
  1671. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1672. CTRL, 1010,
  1673. (htt_tlv_filter->mo_ctrl_filter &
  1674. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1675. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1676. CTRL, 1011,
  1677. (htt_tlv_filter->mo_ctrl_filter &
  1678. FILTER_CTRL_RTS) ? 1 : 0);
  1679. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1680. CTRL, 1100,
  1681. (htt_tlv_filter->mo_ctrl_filter &
  1682. FILTER_CTRL_CTS) ? 1 : 0);
  1683. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1684. CTRL, 1101,
  1685. (htt_tlv_filter->mo_ctrl_filter &
  1686. FILTER_CTRL_ACK) ? 1 : 0);
  1687. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1688. CTRL, 1110,
  1689. (htt_tlv_filter->mo_ctrl_filter &
  1690. FILTER_CTRL_CFEND) ? 1 : 0);
  1691. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1692. CTRL, 1111,
  1693. (htt_tlv_filter->mo_ctrl_filter &
  1694. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1695. /* TYPE: DATA */
  1696. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1697. DATA, MCAST,
  1698. (htt_tlv_filter->mo_data_filter &
  1699. FILTER_DATA_MCAST) ? 1 : 0);
  1700. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1701. DATA, UCAST,
  1702. (htt_tlv_filter->mo_data_filter &
  1703. FILTER_DATA_UCAST) ? 1 : 0);
  1704. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1705. DATA, NULL,
  1706. (htt_tlv_filter->mo_data_filter &
  1707. FILTER_DATA_NULL) ? 1 : 0);
  1708. }
  1709. /* word 6 */
  1710. msg_word++;
  1711. *msg_word = 0;
  1712. tlv_filter = 0;
  1713. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1714. htt_tlv_filter->mpdu_start);
  1715. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1716. htt_tlv_filter->msdu_start);
  1717. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1718. htt_tlv_filter->packet);
  1719. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1720. htt_tlv_filter->msdu_end);
  1721. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1722. htt_tlv_filter->mpdu_end);
  1723. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1724. htt_tlv_filter->packet_header);
  1725. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1726. htt_tlv_filter->attention);
  1727. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1728. htt_tlv_filter->ppdu_start);
  1729. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1730. htt_tlv_filter->ppdu_end);
  1731. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1732. htt_tlv_filter->ppdu_end_user_stats);
  1733. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1734. PPDU_END_USER_STATS_EXT,
  1735. htt_tlv_filter->ppdu_end_user_stats_ext);
  1736. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1737. htt_tlv_filter->ppdu_end_status_done);
  1738. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1739. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1740. htt_tlv_filter->header_per_msdu);
  1741. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1742. msg_word++;
  1743. *msg_word = 0;
  1744. if (htt_tlv_filter->offset_valid) {
  1745. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1746. htt_tlv_filter->rx_packet_offset);
  1747. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1748. htt_tlv_filter->rx_header_offset);
  1749. msg_word++;
  1750. *msg_word = 0;
  1751. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1752. htt_tlv_filter->rx_mpdu_end_offset);
  1753. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1754. htt_tlv_filter->rx_mpdu_start_offset);
  1755. msg_word++;
  1756. *msg_word = 0;
  1757. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1758. htt_tlv_filter->rx_msdu_end_offset);
  1759. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1760. htt_tlv_filter->rx_msdu_start_offset);
  1761. msg_word++;
  1762. *msg_word = 0;
  1763. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1764. htt_tlv_filter->rx_attn_offset);
  1765. msg_word++;
  1766. *msg_word = 0;
  1767. } else {
  1768. msg_word += 4;
  1769. *msg_word = 0;
  1770. }
  1771. if (mon_drop_th > 0)
  1772. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1773. mon_drop_th);
  1774. /* "response_required" field should be set if a HTT response message is
  1775. * required after setting up the ring.
  1776. */
  1777. pkt = htt_htc_pkt_alloc(soc);
  1778. if (!pkt)
  1779. goto fail1;
  1780. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1781. SET_HTC_PACKET_INFO_TX(
  1782. &pkt->htc_pkt,
  1783. dp_htt_h2t_send_complete_free_netbuf,
  1784. qdf_nbuf_data(htt_msg),
  1785. qdf_nbuf_len(htt_msg),
  1786. soc->htc_endpoint,
  1787. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1788. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1789. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1790. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1791. htt_logger_bufp);
  1792. if (status != QDF_STATUS_SUCCESS) {
  1793. qdf_nbuf_free(htt_msg);
  1794. htt_htc_pkt_free(soc, pkt);
  1795. }
  1796. return status;
  1797. fail1:
  1798. qdf_nbuf_free(htt_msg);
  1799. fail0:
  1800. return QDF_STATUS_E_FAILURE;
  1801. }
  1802. #if defined(HTT_STATS_ENABLE)
  1803. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1804. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1805. {
  1806. uint32_t pdev_id;
  1807. uint32_t *msg_word = NULL;
  1808. uint32_t msg_remain_len = 0;
  1809. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1810. /*COOKIE MSB*/
  1811. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1812. /* stats message length + 16 size of HTT header*/
  1813. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1814. (uint32_t)DP_EXT_MSG_LENGTH);
  1815. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1816. msg_word, msg_remain_len,
  1817. WDI_NO_VAL, pdev_id);
  1818. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1819. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1820. }
  1821. /* Need to be freed here as WDI handler will
  1822. * make a copy of pkt to send data to application
  1823. */
  1824. qdf_nbuf_free(htt_msg);
  1825. return QDF_STATUS_SUCCESS;
  1826. }
  1827. #else
  1828. static inline QDF_STATUS
  1829. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1830. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1831. {
  1832. return QDF_STATUS_E_NOSUPPORT;
  1833. }
  1834. #endif
  1835. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1836. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer
  1837. * @pdev: dp pdev handle
  1838. * @msg_word: HTT msg
  1839. * @msg_len: Length of HTT msg sent
  1840. *
  1841. * Return: none
  1842. */
  1843. static inline void
  1844. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1845. uint32_t msg_len)
  1846. {
  1847. struct htt_dbgfs_cfg dbgfs_cfg;
  1848. int done = 0;
  1849. /* send 5th word of HTT msg to upper layer */
  1850. dbgfs_cfg.msg_word = (msg_word + 4);
  1851. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1852. /* stats message length + 16 size of HTT header*/
  1853. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1854. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1855. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1856. (msg_len - HTT_HEADER_LEN));
  1857. /* Get TLV Done bit from 4th msg word */
  1858. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1859. if (done) {
  1860. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1861. dp_htt_err("%pK: Failed to set event for debugfs htt stats"
  1862. , pdev->soc);
  1863. }
  1864. }
  1865. #else
  1866. static inline void
  1867. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1868. uint32_t msg_len)
  1869. {
  1870. }
  1871. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1872. /**
  1873. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1874. * @htt_stats: htt stats info
  1875. *
  1876. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1877. * contains sub messages which are identified by a TLV header.
  1878. * In this function we will process the stream of T2H messages and read all the
  1879. * TLV contained in the message.
  1880. *
  1881. * THe following cases have been taken care of
  1882. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1883. * In this case the buffer will contain multiple tlvs.
  1884. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1885. * Only one tlv will be contained in the HTT message and this tag
  1886. * will extend onto the next buffer.
  1887. * Case 3: When the buffer is the continuation of the previous message
  1888. * Case 4: tlv length is 0. which will indicate the end of message
  1889. *
  1890. * return: void
  1891. */
  1892. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1893. struct dp_soc *soc)
  1894. {
  1895. htt_tlv_tag_t tlv_type = 0xff;
  1896. qdf_nbuf_t htt_msg = NULL;
  1897. uint32_t *msg_word;
  1898. uint8_t *tlv_buf_head = NULL;
  1899. uint8_t *tlv_buf_tail = NULL;
  1900. uint32_t msg_remain_len = 0;
  1901. uint32_t tlv_remain_len = 0;
  1902. uint32_t *tlv_start;
  1903. int cookie_val = 0;
  1904. int cookie_msb = 0;
  1905. int pdev_id;
  1906. bool copy_stats = false;
  1907. struct dp_pdev *pdev;
  1908. /* Process node in the HTT message queue */
  1909. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1910. != NULL) {
  1911. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1912. cookie_val = *(msg_word + 1);
  1913. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1914. *(msg_word +
  1915. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1916. if (cookie_val) {
  1917. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1918. == QDF_STATUS_SUCCESS) {
  1919. continue;
  1920. }
  1921. }
  1922. cookie_msb = *(msg_word + 2);
  1923. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1924. pdev = soc->pdev_list[pdev_id];
  1925. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1926. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1927. htt_stats->msg_len);
  1928. qdf_nbuf_free(htt_msg);
  1929. continue;
  1930. }
  1931. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1932. copy_stats = true;
  1933. /* read 5th word */
  1934. msg_word = msg_word + 4;
  1935. msg_remain_len = qdf_min(htt_stats->msg_len,
  1936. (uint32_t) DP_EXT_MSG_LENGTH);
  1937. /* Keep processing the node till node length is 0 */
  1938. while (msg_remain_len) {
  1939. /*
  1940. * if message is not a continuation of previous message
  1941. * read the tlv type and tlv length
  1942. */
  1943. if (!tlv_buf_head) {
  1944. tlv_type = HTT_STATS_TLV_TAG_GET(
  1945. *msg_word);
  1946. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1947. *msg_word);
  1948. }
  1949. if (tlv_remain_len == 0) {
  1950. msg_remain_len = 0;
  1951. if (tlv_buf_head) {
  1952. qdf_mem_free(tlv_buf_head);
  1953. tlv_buf_head = NULL;
  1954. tlv_buf_tail = NULL;
  1955. }
  1956. goto error;
  1957. }
  1958. if (!tlv_buf_head)
  1959. tlv_remain_len += HTT_TLV_HDR_LEN;
  1960. if ((tlv_remain_len <= msg_remain_len)) {
  1961. /* Case 3 */
  1962. if (tlv_buf_head) {
  1963. qdf_mem_copy(tlv_buf_tail,
  1964. (uint8_t *)msg_word,
  1965. tlv_remain_len);
  1966. tlv_start = (uint32_t *)tlv_buf_head;
  1967. } else {
  1968. /* Case 1 */
  1969. tlv_start = msg_word;
  1970. }
  1971. if (copy_stats)
  1972. dp_htt_stats_copy_tag(pdev,
  1973. tlv_type,
  1974. tlv_start);
  1975. else
  1976. dp_htt_stats_print_tag(pdev,
  1977. tlv_type,
  1978. tlv_start);
  1979. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1980. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1981. dp_peer_update_inactive_time(pdev,
  1982. tlv_type,
  1983. tlv_start);
  1984. msg_remain_len -= tlv_remain_len;
  1985. msg_word = (uint32_t *)
  1986. (((uint8_t *)msg_word) +
  1987. tlv_remain_len);
  1988. tlv_remain_len = 0;
  1989. if (tlv_buf_head) {
  1990. qdf_mem_free(tlv_buf_head);
  1991. tlv_buf_head = NULL;
  1992. tlv_buf_tail = NULL;
  1993. }
  1994. } else { /* tlv_remain_len > msg_remain_len */
  1995. /* Case 2 & 3 */
  1996. if (!tlv_buf_head) {
  1997. tlv_buf_head = qdf_mem_malloc(
  1998. tlv_remain_len);
  1999. if (!tlv_buf_head) {
  2000. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2001. QDF_TRACE_LEVEL_ERROR,
  2002. "Alloc failed");
  2003. goto error;
  2004. }
  2005. tlv_buf_tail = tlv_buf_head;
  2006. }
  2007. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  2008. msg_remain_len);
  2009. tlv_remain_len -= msg_remain_len;
  2010. tlv_buf_tail += msg_remain_len;
  2011. }
  2012. }
  2013. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  2014. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  2015. }
  2016. qdf_nbuf_free(htt_msg);
  2017. }
  2018. return;
  2019. error:
  2020. qdf_nbuf_free(htt_msg);
  2021. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  2022. != NULL)
  2023. qdf_nbuf_free(htt_msg);
  2024. }
  2025. void htt_t2h_stats_handler(void *context)
  2026. {
  2027. struct dp_soc *soc = (struct dp_soc *)context;
  2028. struct htt_stats_context htt_stats;
  2029. uint32_t *msg_word;
  2030. qdf_nbuf_t htt_msg = NULL;
  2031. uint8_t done;
  2032. uint32_t rem_stats;
  2033. if (!soc) {
  2034. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2035. "soc is NULL");
  2036. return;
  2037. }
  2038. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  2039. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2040. "soc: 0x%pK, init_done: %d", soc,
  2041. qdf_atomic_read(&soc->cmn_init_done));
  2042. return;
  2043. }
  2044. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  2045. qdf_nbuf_queue_init(&htt_stats.msg);
  2046. /* pull one completed stats from soc->htt_stats_msg and process */
  2047. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2048. if (!soc->htt_stats.num_stats) {
  2049. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2050. return;
  2051. }
  2052. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  2053. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  2054. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  2055. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2056. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  2057. /*
  2058. * Done bit signifies that this is the last T2H buffer in the
  2059. * stream of HTT EXT STATS message
  2060. */
  2061. if (done)
  2062. break;
  2063. }
  2064. rem_stats = --soc->htt_stats.num_stats;
  2065. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2066. /* If there are more stats to process, schedule stats work again.
  2067. * Scheduling prior to processing ht_stats to queue with early
  2068. * index
  2069. */
  2070. if (rem_stats)
  2071. qdf_sched_work(0, &soc->htt_stats.work);
  2072. dp_process_htt_stat_msg(&htt_stats, soc);
  2073. }
  2074. /*
  2075. * dp_get_ppdu_info_user_index: Find and allocate a per-user descriptor for a PPDU,
  2076. * if a new peer id arrives in a PPDU
  2077. * pdev: DP pdev handle
  2078. * @peer_id : peer unique identifier
  2079. * @ppdu_info: per ppdu tlv structure
  2080. *
  2081. * return:user index to be populated
  2082. */
  2083. #ifdef FEATURE_PERPKT_INFO
  2084. static uint8_t dp_get_ppdu_info_user_index(struct dp_pdev *pdev,
  2085. uint16_t peer_id,
  2086. struct ppdu_info *ppdu_info)
  2087. {
  2088. uint8_t user_index = 0;
  2089. struct cdp_tx_completion_ppdu *ppdu_desc;
  2090. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2091. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2092. while ((user_index + 1) <= ppdu_info->last_user) {
  2093. ppdu_user_desc = &ppdu_desc->user[user_index];
  2094. if (ppdu_user_desc->peer_id != peer_id) {
  2095. user_index++;
  2096. continue;
  2097. } else {
  2098. /* Max users possible is 8 so user array index should
  2099. * not exceed 7
  2100. */
  2101. qdf_assert_always(user_index <= (ppdu_desc->max_users - 1));
  2102. return user_index;
  2103. }
  2104. }
  2105. ppdu_info->last_user++;
  2106. /* Max users possible is 8 so last user should not exceed 8 */
  2107. qdf_assert_always(ppdu_info->last_user <= ppdu_desc->max_users);
  2108. return ppdu_info->last_user - 1;
  2109. }
  2110. /*
  2111. * dp_process_ppdu_stats_common_tlv: Process htt_ppdu_stats_common_tlv
  2112. * pdev: DP pdev handle
  2113. * @tag_buf: buffer containing the tlv htt_ppdu_stats_common_tlv
  2114. * @ppdu_info: per ppdu tlv structure
  2115. *
  2116. * return:void
  2117. */
  2118. static void dp_process_ppdu_stats_common_tlv(struct dp_pdev *pdev,
  2119. uint32_t *tag_buf, struct ppdu_info *ppdu_info)
  2120. {
  2121. uint16_t frame_type;
  2122. uint16_t frame_ctrl;
  2123. uint16_t freq;
  2124. struct dp_soc *soc = NULL;
  2125. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2126. uint64_t ppdu_start_timestamp;
  2127. uint32_t *start_tag_buf;
  2128. start_tag_buf = tag_buf;
  2129. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2130. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  2131. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RING_ID_SCH_CMD_ID);
  2132. ppdu_info->sched_cmdid =
  2133. HTT_PPDU_STATS_COMMON_TLV_SCH_CMDID_GET(*tag_buf);
  2134. ppdu_desc->num_users =
  2135. HTT_PPDU_STATS_COMMON_TLV_NUM_USERS_GET(*tag_buf);
  2136. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2137. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(QTYPE_FRM_TYPE);
  2138. frame_type = HTT_PPDU_STATS_COMMON_TLV_FRM_TYPE_GET(*tag_buf);
  2139. ppdu_desc->htt_frame_type = frame_type;
  2140. frame_ctrl = ppdu_desc->frame_ctrl;
  2141. ppdu_desc->bar_ppdu_id = ppdu_info->ppdu_id;
  2142. switch (frame_type) {
  2143. case HTT_STATS_FTYPE_TIDQ_DATA_SU:
  2144. case HTT_STATS_FTYPE_TIDQ_DATA_MU:
  2145. case HTT_STATS_FTYPE_SGEN_QOS_NULL:
  2146. /*
  2147. * for management packet, frame type come as DATA_SU
  2148. * need to check frame_ctrl before setting frame_type
  2149. */
  2150. if (HTT_GET_FRAME_CTRL_TYPE(frame_ctrl) <= FRAME_CTRL_TYPE_CTRL)
  2151. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2152. else
  2153. ppdu_desc->frame_type = CDP_PPDU_FTYPE_DATA;
  2154. break;
  2155. case HTT_STATS_FTYPE_SGEN_MU_BAR:
  2156. case HTT_STATS_FTYPE_SGEN_BAR:
  2157. ppdu_desc->frame_type = CDP_PPDU_FTYPE_BAR;
  2158. break;
  2159. default:
  2160. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2161. break;
  2162. }
  2163. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(FES_DUR_US);
  2164. ppdu_desc->tx_duration = *tag_buf;
  2165. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_L32_US);
  2166. ppdu_desc->ppdu_start_timestamp = *tag_buf;
  2167. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(CHAN_MHZ_PHY_MODE);
  2168. freq = HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_GET(*tag_buf);
  2169. if (freq != ppdu_desc->channel) {
  2170. soc = pdev->soc;
  2171. ppdu_desc->channel = freq;
  2172. pdev->operating_channel.freq = freq;
  2173. if (soc && soc->cdp_soc.ol_ops->freq_to_channel)
  2174. pdev->operating_channel.num =
  2175. soc->cdp_soc.ol_ops->freq_to_channel(soc->ctrl_psoc,
  2176. pdev->pdev_id,
  2177. freq);
  2178. if (soc && soc->cdp_soc.ol_ops->freq_to_band)
  2179. pdev->operating_channel.band =
  2180. soc->cdp_soc.ol_ops->freq_to_band(soc->ctrl_psoc,
  2181. pdev->pdev_id,
  2182. freq);
  2183. }
  2184. ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
  2185. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RESV_NUM_UL_BEAM);
  2186. ppdu_desc->phy_ppdu_tx_time_us =
  2187. HTT_PPDU_STATS_COMMON_TLV_PHY_PPDU_TX_TIME_US_GET(*tag_buf);
  2188. ppdu_desc->beam_change =
  2189. HTT_PPDU_STATS_COMMON_TLV_BEAM_CHANGE_GET(*tag_buf);
  2190. ppdu_desc->doppler =
  2191. HTT_PPDU_STATS_COMMON_TLV_DOPPLER_INDICATION_GET(*tag_buf);
  2192. ppdu_desc->spatial_reuse =
  2193. HTT_PPDU_STATS_COMMON_TLV_SPATIAL_REUSE_GET(*tag_buf);
  2194. dp_tx_capture_htt_frame_counter(pdev, frame_type);
  2195. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_U32_US);
  2196. ppdu_start_timestamp = *tag_buf;
  2197. ppdu_desc->ppdu_start_timestamp |= ((ppdu_start_timestamp <<
  2198. HTT_SHIFT_UPPER_TIMESTAMP) &
  2199. HTT_MASK_UPPER_TIMESTAMP);
  2200. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2201. ppdu_desc->tx_duration;
  2202. /* Ack time stamp is same as end time stamp*/
  2203. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2204. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2205. ppdu_desc->tx_duration;
  2206. ppdu_desc->bar_ppdu_start_timestamp = ppdu_desc->ppdu_start_timestamp;
  2207. ppdu_desc->bar_ppdu_end_timestamp = ppdu_desc->ppdu_end_timestamp;
  2208. ppdu_desc->bar_tx_duration = ppdu_desc->tx_duration;
  2209. /* Ack time stamp is same as end time stamp*/
  2210. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2211. }
  2212. /*
  2213. * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
  2214. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
  2215. * @ppdu_info: per ppdu tlv structure
  2216. *
  2217. * return:void
  2218. */
  2219. static void dp_process_ppdu_stats_user_common_tlv(
  2220. struct dp_pdev *pdev, uint32_t *tag_buf,
  2221. struct ppdu_info *ppdu_info)
  2222. {
  2223. uint16_t peer_id;
  2224. struct cdp_tx_completion_ppdu *ppdu_desc;
  2225. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2226. uint8_t curr_user_index = 0;
  2227. struct dp_peer *peer;
  2228. struct dp_vdev *vdev;
  2229. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2230. ppdu_desc =
  2231. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2232. tag_buf++;
  2233. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2234. curr_user_index =
  2235. dp_get_ppdu_info_user_index(pdev,
  2236. peer_id, ppdu_info);
  2237. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2238. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2239. ppdu_desc->vdev_id =
  2240. HTT_PPDU_STATS_USER_COMMON_TLV_VAP_ID_GET(*tag_buf);
  2241. ppdu_user_desc->peer_id = peer_id;
  2242. tag_buf++;
  2243. if (HTT_PPDU_STATS_USER_COMMON_TLV_DELAYED_BA_GET(*tag_buf)) {
  2244. ppdu_user_desc->delayed_ba = 1;
  2245. ppdu_desc->delayed_ba = 1;
  2246. }
  2247. if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
  2248. ppdu_user_desc->is_mcast = true;
  2249. ppdu_user_desc->mpdu_tried_mcast =
  2250. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2251. ppdu_user_desc->num_mpdu = ppdu_user_desc->mpdu_tried_mcast;
  2252. } else {
  2253. ppdu_user_desc->mpdu_tried_ucast =
  2254. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2255. }
  2256. ppdu_user_desc->is_seq_num_valid =
  2257. HTT_PPDU_STATS_USER_COMMON_TLV_IS_SQNUM_VALID_IN_BUFFER_GET(*tag_buf);
  2258. tag_buf++;
  2259. ppdu_user_desc->qos_ctrl =
  2260. HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
  2261. ppdu_user_desc->frame_ctrl =
  2262. HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
  2263. ppdu_desc->frame_ctrl = ppdu_user_desc->frame_ctrl;
  2264. if (ppdu_user_desc->delayed_ba)
  2265. ppdu_user_desc->mpdu_success = 0;
  2266. tag_buf += 3;
  2267. if (HTT_PPDU_STATS_IS_OPAQUE_VALID_GET(*tag_buf)) {
  2268. ppdu_user_desc->ppdu_cookie =
  2269. HTT_PPDU_STATS_HOST_OPAQUE_COOKIE_GET(*tag_buf);
  2270. ppdu_user_desc->is_ppdu_cookie_valid = 1;
  2271. }
  2272. /* returning earlier causes other feilds unpopulated */
  2273. if (peer_id == DP_SCAN_PEER_ID) {
  2274. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2275. DP_MOD_ID_TX_PPDU_STATS);
  2276. if (!vdev)
  2277. return;
  2278. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2279. QDF_MAC_ADDR_SIZE);
  2280. dp_vdev_unref_delete(pdev->soc, vdev, DP_MOD_ID_TX_PPDU_STATS);
  2281. } else {
  2282. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2283. DP_MOD_ID_TX_PPDU_STATS);
  2284. if (!peer) {
  2285. /*
  2286. * fw sends peer_id which is about to removed but
  2287. * it was already removed in host.
  2288. * eg: for disassoc, fw send ppdu stats
  2289. * with peer id equal to previously associated
  2290. * peer's peer_id but it was removed
  2291. */
  2292. vdev = dp_vdev_get_ref_by_id(pdev->soc,
  2293. ppdu_desc->vdev_id,
  2294. DP_MOD_ID_TX_PPDU_STATS);
  2295. if (!vdev)
  2296. return;
  2297. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2298. vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2299. dp_vdev_unref_delete(pdev->soc, vdev,
  2300. DP_MOD_ID_TX_PPDU_STATS);
  2301. return;
  2302. }
  2303. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2304. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2305. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2306. }
  2307. }
  2308. /**
  2309. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  2310. * @pdev: DP pdev handle
  2311. * @tag_buf: T2H message buffer carrying the user rate TLV
  2312. * @ppdu_info: per ppdu tlv structure
  2313. *
  2314. * return:void
  2315. */
  2316. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  2317. uint32_t *tag_buf,
  2318. struct ppdu_info *ppdu_info)
  2319. {
  2320. uint16_t peer_id;
  2321. struct cdp_tx_completion_ppdu *ppdu_desc;
  2322. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2323. uint8_t curr_user_index = 0;
  2324. struct dp_vdev *vdev;
  2325. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2326. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2327. tag_buf++;
  2328. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2329. curr_user_index =
  2330. dp_get_ppdu_info_user_index(pdev,
  2331. peer_id, ppdu_info);
  2332. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2333. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2334. if (peer_id == DP_SCAN_PEER_ID) {
  2335. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2336. DP_MOD_ID_TX_PPDU_STATS);
  2337. if (!vdev)
  2338. return;
  2339. dp_vdev_unref_delete(pdev->soc, vdev,
  2340. DP_MOD_ID_TX_PPDU_STATS);
  2341. }
  2342. ppdu_user_desc->peer_id = peer_id;
  2343. ppdu_user_desc->tid =
  2344. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  2345. tag_buf += 1;
  2346. ppdu_user_desc->user_pos =
  2347. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  2348. ppdu_user_desc->mu_group_id =
  2349. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2350. tag_buf += 1;
  2351. ppdu_user_desc->ru_start =
  2352. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2353. ppdu_user_desc->ru_tones =
  2354. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2355. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2356. ppdu_desc->usr_ru_tones_sum += ppdu_user_desc->ru_tones;
  2357. tag_buf += 2;
  2358. ppdu_user_desc->ppdu_type =
  2359. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2360. tag_buf++;
  2361. ppdu_user_desc->tx_rate = *tag_buf;
  2362. ppdu_user_desc->ltf_size =
  2363. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2364. ppdu_user_desc->stbc =
  2365. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2366. ppdu_user_desc->he_re =
  2367. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2368. ppdu_user_desc->txbf =
  2369. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2370. ppdu_user_desc->bw =
  2371. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2372. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2373. ppdu_desc->usr_nss_sum += ppdu_user_desc->nss;
  2374. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2375. ppdu_user_desc->preamble =
  2376. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2377. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2378. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2379. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2380. }
  2381. /*
  2382. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2383. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2384. * pdev: DP PDEV handle
  2385. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2386. * @ppdu_info: per ppdu tlv structure
  2387. *
  2388. * return:void
  2389. */
  2390. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2391. struct dp_pdev *pdev, uint32_t *tag_buf,
  2392. struct ppdu_info *ppdu_info)
  2393. {
  2394. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2395. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2396. struct cdp_tx_completion_ppdu *ppdu_desc;
  2397. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2398. uint8_t curr_user_index = 0;
  2399. uint16_t peer_id;
  2400. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2401. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2402. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2403. tag_buf++;
  2404. peer_id =
  2405. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2406. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2407. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2408. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2409. ppdu_user_desc->peer_id = peer_id;
  2410. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2411. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2412. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2413. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2414. (void *)ppdu_user_desc,
  2415. ppdu_info->ppdu_id,
  2416. size);
  2417. }
  2418. /*
  2419. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2420. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2421. * soc: DP SOC handle
  2422. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2423. * @ppdu_info: per ppdu tlv structure
  2424. *
  2425. * return:void
  2426. */
  2427. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2428. struct dp_pdev *pdev, uint32_t *tag_buf,
  2429. struct ppdu_info *ppdu_info)
  2430. {
  2431. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2432. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2433. struct cdp_tx_completion_ppdu *ppdu_desc;
  2434. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2435. uint8_t curr_user_index = 0;
  2436. uint16_t peer_id;
  2437. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2438. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2439. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2440. tag_buf++;
  2441. peer_id =
  2442. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2443. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2444. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2445. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2446. ppdu_user_desc->peer_id = peer_id;
  2447. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2448. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2449. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2450. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2451. (void *)ppdu_user_desc,
  2452. ppdu_info->ppdu_id,
  2453. size);
  2454. }
  2455. /*
  2456. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2457. * htt_ppdu_stats_user_cmpltn_common_tlv
  2458. * soc: DP SOC handle
  2459. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2460. * @ppdu_info: per ppdu tlv structure
  2461. *
  2462. * return:void
  2463. */
  2464. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2465. struct dp_pdev *pdev, uint32_t *tag_buf,
  2466. struct ppdu_info *ppdu_info)
  2467. {
  2468. uint16_t peer_id;
  2469. struct cdp_tx_completion_ppdu *ppdu_desc;
  2470. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2471. uint8_t curr_user_index = 0;
  2472. uint8_t bw_iter;
  2473. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2474. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2475. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2476. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2477. tag_buf++;
  2478. peer_id =
  2479. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2480. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2481. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2482. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2483. ppdu_user_desc->peer_id = peer_id;
  2484. ppdu_user_desc->completion_status =
  2485. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2486. *tag_buf);
  2487. ppdu_user_desc->tid =
  2488. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2489. tag_buf++;
  2490. if (qdf_likely(ppdu_user_desc->completion_status ==
  2491. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2492. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2493. ppdu_user_desc->usr_ack_rssi = dp_stats_buf->ack_rssi;
  2494. ppdu_user_desc->ack_rssi_valid = 1;
  2495. } else {
  2496. ppdu_user_desc->ack_rssi_valid = 0;
  2497. }
  2498. tag_buf++;
  2499. ppdu_user_desc->mpdu_success =
  2500. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2501. ppdu_user_desc->mpdu_failed =
  2502. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2503. ppdu_user_desc->mpdu_success;
  2504. tag_buf++;
  2505. ppdu_user_desc->long_retries =
  2506. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2507. ppdu_user_desc->short_retries =
  2508. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2509. ppdu_user_desc->retry_msdus =
  2510. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2511. ppdu_user_desc->is_ampdu =
  2512. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2513. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2514. ppdu_desc->resp_type =
  2515. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RESP_TYPE_GET(*tag_buf);
  2516. ppdu_desc->mprot_type =
  2517. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPROT_TYPE_GET(*tag_buf);
  2518. ppdu_desc->rts_success =
  2519. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_SUCCESS_GET(*tag_buf);
  2520. ppdu_desc->rts_failure =
  2521. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_FAILURE_GET(*tag_buf);
  2522. ppdu_user_desc->pream_punct =
  2523. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PREAM_PUNC_TX_GET(*tag_buf);
  2524. ppdu_info->compltn_common_tlv++;
  2525. /*
  2526. * MU BAR may send request to n users but we may received ack only from
  2527. * m users. To have count of number of users respond back, we have a
  2528. * separate counter bar_num_users per PPDU that get increment for every
  2529. * htt_ppdu_stats_user_cmpltn_common_tlv
  2530. */
  2531. ppdu_desc->bar_num_users++;
  2532. tag_buf++;
  2533. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2534. ppdu_user_desc->rssi_chain[bw_iter] =
  2535. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2536. tag_buf++;
  2537. }
  2538. ppdu_user_desc->sa_tx_antenna =
  2539. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2540. tag_buf++;
  2541. ppdu_user_desc->sa_is_training =
  2542. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2543. if (ppdu_user_desc->sa_is_training) {
  2544. ppdu_user_desc->sa_goodput =
  2545. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2546. }
  2547. tag_buf++;
  2548. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2549. ppdu_user_desc->sa_max_rates[bw_iter] =
  2550. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2551. }
  2552. tag_buf += CDP_NUM_SA_BW;
  2553. ppdu_user_desc->current_rate_per =
  2554. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2555. }
  2556. /*
  2557. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2558. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2559. * pdev: DP PDEV handle
  2560. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2561. * @ppdu_info: per ppdu tlv structure
  2562. *
  2563. * return:void
  2564. */
  2565. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2566. struct dp_pdev *pdev, uint32_t *tag_buf,
  2567. struct ppdu_info *ppdu_info)
  2568. {
  2569. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2570. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2571. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2572. struct cdp_tx_completion_ppdu *ppdu_desc;
  2573. uint8_t curr_user_index = 0;
  2574. uint16_t peer_id;
  2575. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2576. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2577. tag_buf++;
  2578. peer_id =
  2579. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2580. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2581. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2582. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2583. ppdu_user_desc->peer_id = peer_id;
  2584. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2585. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2586. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2587. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2588. }
  2589. /*
  2590. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2591. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2592. * pdev: DP PDEV handle
  2593. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2594. * @ppdu_info: per ppdu tlv structure
  2595. *
  2596. * return:void
  2597. */
  2598. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2599. struct dp_pdev *pdev, uint32_t *tag_buf,
  2600. struct ppdu_info *ppdu_info)
  2601. {
  2602. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2603. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2604. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2605. struct cdp_tx_completion_ppdu *ppdu_desc;
  2606. uint8_t curr_user_index = 0;
  2607. uint16_t peer_id;
  2608. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2609. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2610. tag_buf++;
  2611. peer_id =
  2612. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2613. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2614. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2615. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2616. ppdu_user_desc->peer_id = peer_id;
  2617. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2618. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2619. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2620. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2621. }
  2622. /*
  2623. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2624. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2625. * pdev: DP PDE handle
  2626. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2627. * @ppdu_info: per ppdu tlv structure
  2628. *
  2629. * return:void
  2630. */
  2631. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2632. struct dp_pdev *pdev, uint32_t *tag_buf,
  2633. struct ppdu_info *ppdu_info)
  2634. {
  2635. uint16_t peer_id;
  2636. struct cdp_tx_completion_ppdu *ppdu_desc;
  2637. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2638. uint8_t curr_user_index = 0;
  2639. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2640. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2641. tag_buf += 2;
  2642. peer_id =
  2643. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2644. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2645. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2646. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2647. if (!ppdu_user_desc->ack_ba_tlv) {
  2648. ppdu_user_desc->ack_ba_tlv = 1;
  2649. } else {
  2650. pdev->stats.ack_ba_comes_twice++;
  2651. return;
  2652. }
  2653. ppdu_user_desc->peer_id = peer_id;
  2654. tag_buf++;
  2655. /* not to update ppdu_desc->tid from this TLV */
  2656. ppdu_user_desc->num_mpdu =
  2657. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2658. ppdu_user_desc->num_msdu =
  2659. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2660. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2661. tag_buf++;
  2662. ppdu_user_desc->start_seq =
  2663. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2664. *tag_buf);
  2665. tag_buf++;
  2666. ppdu_user_desc->success_bytes = *tag_buf;
  2667. /* increase ack ba tlv counter on successful mpdu */
  2668. if (ppdu_user_desc->num_mpdu)
  2669. ppdu_info->ack_ba_tlv++;
  2670. if (ppdu_user_desc->ba_size == 0) {
  2671. ppdu_user_desc->ba_seq_no = ppdu_user_desc->start_seq;
  2672. ppdu_user_desc->ba_bitmap[0] = 1;
  2673. ppdu_user_desc->ba_size = 1;
  2674. }
  2675. }
  2676. /*
  2677. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2678. * htt_ppdu_stats_user_common_array_tlv
  2679. * pdev: DP PDEV handle
  2680. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2681. * @ppdu_info: per ppdu tlv structure
  2682. *
  2683. * return:void
  2684. */
  2685. static void dp_process_ppdu_stats_user_common_array_tlv(
  2686. struct dp_pdev *pdev, uint32_t *tag_buf,
  2687. struct ppdu_info *ppdu_info)
  2688. {
  2689. uint32_t peer_id;
  2690. struct cdp_tx_completion_ppdu *ppdu_desc;
  2691. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2692. uint8_t curr_user_index = 0;
  2693. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2694. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2695. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2696. tag_buf++;
  2697. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2698. tag_buf += 3;
  2699. peer_id =
  2700. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2701. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2702. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2703. "Invalid peer");
  2704. return;
  2705. }
  2706. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2707. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2708. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2709. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2710. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2711. tag_buf++;
  2712. ppdu_user_desc->success_msdus =
  2713. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2714. ppdu_user_desc->retry_bytes =
  2715. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2716. tag_buf++;
  2717. ppdu_user_desc->failed_msdus =
  2718. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2719. }
  2720. /*
  2721. * dp_process_ppdu_stats_flush_tlv: Process
  2722. * htt_ppdu_stats_flush_tlv
  2723. * @pdev: DP PDEV handle
  2724. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2725. * @ppdu_info: per ppdu tlv structure
  2726. *
  2727. * return:void
  2728. */
  2729. static void
  2730. dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2731. uint32_t *tag_buf,
  2732. struct ppdu_info *ppdu_info)
  2733. {
  2734. struct cdp_tx_completion_ppdu *ppdu_desc;
  2735. uint32_t peer_id;
  2736. uint8_t tid;
  2737. struct dp_peer *peer;
  2738. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2739. qdf_nbuf_data(ppdu_info->nbuf);
  2740. ppdu_desc->is_flush = 1;
  2741. tag_buf++;
  2742. ppdu_desc->drop_reason = *tag_buf;
  2743. tag_buf++;
  2744. ppdu_desc->num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2745. ppdu_desc->num_mpdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MPDU_GET(*tag_buf);
  2746. ppdu_desc->flow_type = HTT_PPDU_STATS_FLUSH_TLV_FLOW_TYPE_GET(*tag_buf);
  2747. tag_buf++;
  2748. peer_id = HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2749. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2750. ppdu_desc->num_users = 1;
  2751. ppdu_desc->user[0].peer_id = peer_id;
  2752. ppdu_desc->user[0].tid = tid;
  2753. ppdu_desc->queue_type =
  2754. HTT_PPDU_STATS_FLUSH_TLV_QUEUE_TYPE_GET(*tag_buf);
  2755. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2756. DP_MOD_ID_TX_PPDU_STATS);
  2757. if (!peer)
  2758. goto add_ppdu_to_sched_list;
  2759. if (ppdu_desc->drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2760. DP_STATS_INC(peer,
  2761. tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2762. ppdu_desc->num_msdu);
  2763. }
  2764. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2765. add_ppdu_to_sched_list:
  2766. ppdu_info->done = 1;
  2767. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2768. pdev->list_depth--;
  2769. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2770. ppdu_info_list_elem);
  2771. pdev->sched_comp_list_depth++;
  2772. }
  2773. /**
  2774. * dp_process_ppdu_stats_sch_cmd_status_tlv: Process schedule command status tlv
  2775. * Here we are not going to process the buffer.
  2776. * @pdev: DP PDEV handle
  2777. * @ppdu_info: per ppdu tlv structure
  2778. *
  2779. * return:void
  2780. */
  2781. static void
  2782. dp_process_ppdu_stats_sch_cmd_status_tlv(struct dp_pdev *pdev,
  2783. struct ppdu_info *ppdu_info)
  2784. {
  2785. struct cdp_tx_completion_ppdu *ppdu_desc;
  2786. struct dp_peer *peer;
  2787. uint8_t num_users;
  2788. uint8_t i;
  2789. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2790. qdf_nbuf_data(ppdu_info->nbuf);
  2791. num_users = ppdu_desc->bar_num_users;
  2792. for (i = 0; i < num_users; i++) {
  2793. if (ppdu_desc->user[i].user_pos == 0) {
  2794. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2795. /* update phy mode for bar frame */
  2796. ppdu_desc->phy_mode =
  2797. ppdu_desc->user[i].preamble;
  2798. ppdu_desc->user[0].mcs = ppdu_desc->user[i].mcs;
  2799. break;
  2800. }
  2801. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_CTRL) {
  2802. ppdu_desc->frame_ctrl =
  2803. ppdu_desc->user[i].frame_ctrl;
  2804. break;
  2805. }
  2806. }
  2807. }
  2808. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2809. ppdu_desc->delayed_ba) {
  2810. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2811. for (i = 0; i < ppdu_desc->num_users; i++) {
  2812. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2813. uint64_t start_tsf;
  2814. uint64_t end_tsf;
  2815. uint32_t ppdu_id;
  2816. ppdu_id = ppdu_desc->ppdu_id;
  2817. peer = dp_peer_get_ref_by_id
  2818. (pdev->soc, ppdu_desc->user[i].peer_id,
  2819. DP_MOD_ID_TX_PPDU_STATS);
  2820. /**
  2821. * This check is to make sure peer is not deleted
  2822. * after processing the TLVs.
  2823. */
  2824. if (!peer)
  2825. continue;
  2826. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2827. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2828. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2829. /**
  2830. * save delayed ba user info
  2831. */
  2832. if (ppdu_desc->user[i].delayed_ba) {
  2833. dp_peer_copy_delay_stats(peer,
  2834. &ppdu_desc->user[i],
  2835. ppdu_id);
  2836. peer->last_delayed_ba_ppduid = ppdu_id;
  2837. delay_ppdu->ppdu_start_timestamp = start_tsf;
  2838. delay_ppdu->ppdu_end_timestamp = end_tsf;
  2839. }
  2840. ppdu_desc->user[i].peer_last_delayed_ba =
  2841. peer->last_delayed_ba;
  2842. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2843. if (ppdu_desc->user[i].delayed_ba &&
  2844. !ppdu_desc->user[i].debug_copied) {
  2845. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2846. QDF_TRACE_LEVEL_INFO_MED,
  2847. "%s: %d ppdu_id[%d] bar_ppdu_id[%d] num_users[%d] usr[%d] htt_frame_type[%d]\n",
  2848. __func__, __LINE__,
  2849. ppdu_desc->ppdu_id,
  2850. ppdu_desc->bar_ppdu_id,
  2851. ppdu_desc->num_users,
  2852. i,
  2853. ppdu_desc->htt_frame_type);
  2854. }
  2855. }
  2856. }
  2857. /*
  2858. * when frame type is BAR and STATS_COMMON_TLV is set
  2859. * copy the store peer delayed info to BAR status
  2860. */
  2861. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2862. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2863. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2864. uint64_t start_tsf;
  2865. uint64_t end_tsf;
  2866. peer = dp_peer_get_ref_by_id
  2867. (pdev->soc,
  2868. ppdu_desc->user[i].peer_id,
  2869. DP_MOD_ID_TX_PPDU_STATS);
  2870. /**
  2871. * This check is to make sure peer is not deleted
  2872. * after processing the TLVs.
  2873. */
  2874. if (!peer)
  2875. continue;
  2876. if (ppdu_desc->user[i].completion_status !=
  2877. HTT_PPDU_STATS_USER_STATUS_OK) {
  2878. dp_peer_unref_delete(peer,
  2879. DP_MOD_ID_TX_PPDU_STATS);
  2880. continue;
  2881. }
  2882. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2883. start_tsf = delay_ppdu->ppdu_start_timestamp;
  2884. end_tsf = delay_ppdu->ppdu_end_timestamp;
  2885. if (peer->last_delayed_ba) {
  2886. dp_peer_copy_stats_to_bar(peer,
  2887. &ppdu_desc->user[i]);
  2888. ppdu_desc->ppdu_id =
  2889. peer->last_delayed_ba_ppduid;
  2890. ppdu_desc->ppdu_start_timestamp = start_tsf;
  2891. ppdu_desc->ppdu_end_timestamp = end_tsf;
  2892. }
  2893. ppdu_desc->user[i].peer_last_delayed_ba =
  2894. peer->last_delayed_ba;
  2895. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2896. }
  2897. }
  2898. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2899. pdev->list_depth--;
  2900. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2901. ppdu_info_list_elem);
  2902. pdev->sched_comp_list_depth++;
  2903. }
  2904. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2905. /*
  2906. * dp_deliver_mgmt_frm: Process
  2907. * @pdev: DP PDEV handle
  2908. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2909. *
  2910. * return: void
  2911. */
  2912. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2913. {
  2914. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2915. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2916. nbuf, HTT_INVALID_PEER,
  2917. WDI_NO_VAL, pdev->pdev_id);
  2918. } else {
  2919. if (!pdev->bpr_enable)
  2920. qdf_nbuf_free(nbuf);
  2921. }
  2922. }
  2923. #endif
  2924. /*
  2925. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2926. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2927. * @pdev: DP PDEV handle
  2928. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2929. * @length: tlv_length
  2930. *
  2931. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2932. */
  2933. static QDF_STATUS
  2934. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2935. qdf_nbuf_t tag_buf,
  2936. uint32_t ppdu_id)
  2937. {
  2938. uint32_t *nbuf_ptr;
  2939. uint8_t trim_size;
  2940. size_t head_size;
  2941. struct cdp_tx_mgmt_comp_info *ptr_mgmt_comp_info;
  2942. uint32_t *msg_word;
  2943. uint32_t tsf_hdr;
  2944. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2945. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2946. return QDF_STATUS_SUCCESS;
  2947. /*
  2948. * get timestamp from htt_t2h_ppdu_stats_ind_hdr_t
  2949. */
  2950. msg_word = (uint32_t *)qdf_nbuf_data(tag_buf);
  2951. msg_word = msg_word + 2;
  2952. tsf_hdr = *msg_word;
  2953. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2954. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2955. qdf_nbuf_data(tag_buf));
  2956. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2957. return QDF_STATUS_SUCCESS;
  2958. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2959. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2960. if (pdev->tx_capture_enabled) {
  2961. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  2962. if (qdf_unlikely(qdf_nbuf_headroom(tag_buf) < head_size)) {
  2963. qdf_err("Fail to get headroom h_sz %zu h_avail %d\n",
  2964. head_size, qdf_nbuf_headroom(tag_buf));
  2965. qdf_assert_always(0);
  2966. return QDF_STATUS_E_NOMEM;
  2967. }
  2968. ptr_mgmt_comp_info = (struct cdp_tx_mgmt_comp_info *)
  2969. qdf_nbuf_push_head(tag_buf, head_size);
  2970. qdf_assert_always(ptr_mgmt_comp_info);
  2971. ptr_mgmt_comp_info->ppdu_id = ppdu_id;
  2972. ptr_mgmt_comp_info->is_sgen_pkt = true;
  2973. ptr_mgmt_comp_info->tx_tsf = tsf_hdr;
  2974. } else {
  2975. head_size = sizeof(ppdu_id);
  2976. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(tag_buf, head_size);
  2977. *nbuf_ptr = ppdu_id;
  2978. }
  2979. if (pdev->bpr_enable) {
  2980. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2981. tag_buf, HTT_INVALID_PEER,
  2982. WDI_NO_VAL, pdev->pdev_id);
  2983. }
  2984. dp_deliver_mgmt_frm(pdev, tag_buf);
  2985. return QDF_STATUS_E_ALREADY;
  2986. }
  2987. /**
  2988. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2989. *
  2990. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2991. * size of corresponding data structure, pad the remaining bytes with zeros
  2992. * and continue processing the TLVs
  2993. *
  2994. * @pdev: DP pdev handle
  2995. * @tag_buf: TLV buffer
  2996. * @tlv_expected_size: Expected size of Tag
  2997. * @tlv_len: TLV length received from FW
  2998. *
  2999. * Return: Pointer to updated TLV
  3000. */
  3001. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  3002. uint32_t *tag_buf,
  3003. uint16_t tlv_expected_size,
  3004. uint16_t tlv_len)
  3005. {
  3006. uint32_t *tlv_desc = tag_buf;
  3007. qdf_assert_always(tlv_len != 0);
  3008. if (tlv_len < tlv_expected_size) {
  3009. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  3010. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  3011. tlv_desc = pdev->ppdu_tlv_buf;
  3012. }
  3013. return tlv_desc;
  3014. }
  3015. /**
  3016. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  3017. * @pdev: DP pdev handle
  3018. * @tag_buf: TLV buffer
  3019. * @tlv_len: length of tlv
  3020. * @ppdu_info: per ppdu tlv structure
  3021. *
  3022. * return: void
  3023. */
  3024. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  3025. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  3026. {
  3027. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  3028. uint16_t tlv_expected_size;
  3029. uint32_t *tlv_desc;
  3030. switch (tlv_type) {
  3031. case HTT_PPDU_STATS_COMMON_TLV:
  3032. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  3033. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3034. tlv_expected_size, tlv_len);
  3035. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  3036. break;
  3037. case HTT_PPDU_STATS_USR_COMMON_TLV:
  3038. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  3039. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3040. tlv_expected_size, tlv_len);
  3041. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  3042. ppdu_info);
  3043. break;
  3044. case HTT_PPDU_STATS_USR_RATE_TLV:
  3045. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  3046. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3047. tlv_expected_size, tlv_len);
  3048. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  3049. ppdu_info);
  3050. break;
  3051. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  3052. tlv_expected_size =
  3053. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  3054. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3055. tlv_expected_size, tlv_len);
  3056. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  3057. pdev, tlv_desc, ppdu_info);
  3058. break;
  3059. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  3060. tlv_expected_size =
  3061. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  3062. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3063. tlv_expected_size, tlv_len);
  3064. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  3065. pdev, tlv_desc, ppdu_info);
  3066. break;
  3067. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  3068. tlv_expected_size =
  3069. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  3070. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3071. tlv_expected_size, tlv_len);
  3072. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  3073. pdev, tlv_desc, ppdu_info);
  3074. break;
  3075. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  3076. tlv_expected_size =
  3077. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  3078. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3079. tlv_expected_size, tlv_len);
  3080. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  3081. pdev, tlv_desc, ppdu_info);
  3082. break;
  3083. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  3084. tlv_expected_size =
  3085. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  3086. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3087. tlv_expected_size, tlv_len);
  3088. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  3089. pdev, tlv_desc, ppdu_info);
  3090. break;
  3091. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  3092. tlv_expected_size =
  3093. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  3094. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3095. tlv_expected_size, tlv_len);
  3096. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  3097. pdev, tlv_desc, ppdu_info);
  3098. break;
  3099. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  3100. tlv_expected_size =
  3101. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  3102. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3103. tlv_expected_size, tlv_len);
  3104. dp_process_ppdu_stats_user_common_array_tlv(
  3105. pdev, tlv_desc, ppdu_info);
  3106. break;
  3107. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  3108. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  3109. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3110. tlv_expected_size, tlv_len);
  3111. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev, tlv_desc,
  3112. ppdu_info);
  3113. break;
  3114. case HTT_PPDU_STATS_SCH_CMD_STATUS_TLV:
  3115. dp_process_ppdu_stats_sch_cmd_status_tlv(pdev, ppdu_info);
  3116. break;
  3117. default:
  3118. break;
  3119. }
  3120. }
  3121. #ifdef WLAN_ATF_ENABLE
  3122. static void
  3123. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3124. struct cdp_tx_completion_ppdu *ppdu_desc,
  3125. struct cdp_tx_completion_ppdu_user *user)
  3126. {
  3127. uint32_t nss_ru_width_sum = 0;
  3128. if (!pdev || !ppdu_desc || !user)
  3129. return;
  3130. if (!pdev->dp_atf_stats_enable)
  3131. return;
  3132. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_DATA)
  3133. return;
  3134. nss_ru_width_sum = ppdu_desc->usr_nss_sum * ppdu_desc->usr_ru_tones_sum;
  3135. if (!nss_ru_width_sum)
  3136. nss_ru_width_sum = 1;
  3137. /**
  3138. * For SU-MIMO PPDU phy Tx time is same for the single user.
  3139. * For MU-MIMO phy Tx time is calculated per user as below
  3140. * user phy tx time =
  3141. * Entire PPDU duration * MU Ratio * OFDMA Ratio
  3142. * MU Ratio = usr_nss / Sum_of_nss_of_all_users
  3143. * OFDMA_ratio = usr_ru_width / Sum_of_ru_width_of_all_users
  3144. * usr_ru_widt = ru_end – ru_start + 1
  3145. */
  3146. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) {
  3147. user->phy_tx_time_us = ppdu_desc->phy_ppdu_tx_time_us;
  3148. } else {
  3149. user->phy_tx_time_us = (ppdu_desc->phy_ppdu_tx_time_us *
  3150. user->nss * user->ru_tones) / nss_ru_width_sum;
  3151. }
  3152. }
  3153. #else
  3154. static void
  3155. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3156. struct cdp_tx_completion_ppdu *ppdu_desc,
  3157. struct cdp_tx_completion_ppdu_user *user)
  3158. {
  3159. }
  3160. #endif
  3161. /**
  3162. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  3163. * @pdev: DP pdev handle
  3164. * @ppdu_info: per PPDU TLV descriptor
  3165. *
  3166. * return: void
  3167. */
  3168. void
  3169. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  3170. struct ppdu_info *ppdu_info)
  3171. {
  3172. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3173. struct dp_peer *peer = NULL;
  3174. uint32_t tlv_bitmap_expected;
  3175. uint32_t tlv_bitmap_default;
  3176. uint16_t i;
  3177. uint32_t num_users;
  3178. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3179. qdf_nbuf_data(ppdu_info->nbuf);
  3180. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_BAR)
  3181. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  3182. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3183. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3184. pdev->tx_capture_enabled) {
  3185. if (ppdu_info->is_ampdu)
  3186. tlv_bitmap_expected =
  3187. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3188. ppdu_info->tlv_bitmap);
  3189. }
  3190. tlv_bitmap_default = tlv_bitmap_expected;
  3191. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  3192. num_users = ppdu_desc->bar_num_users;
  3193. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  3194. } else {
  3195. num_users = ppdu_desc->num_users;
  3196. }
  3197. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  3198. for (i = 0; i < num_users; i++) {
  3199. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  3200. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  3201. peer = dp_peer_get_ref_by_id(pdev->soc,
  3202. ppdu_desc->user[i].peer_id,
  3203. DP_MOD_ID_TX_PPDU_STATS);
  3204. /**
  3205. * This check is to make sure peer is not deleted
  3206. * after processing the TLVs.
  3207. */
  3208. if (!peer)
  3209. continue;
  3210. ppdu_desc->user[i].is_bss_peer = peer->bss_peer;
  3211. /*
  3212. * different frame like DATA, BAR or CTRL has different
  3213. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  3214. * receive other tlv in-order/sequential from fw.
  3215. * Since ACK_BA_STATUS TLV come from Hardware it is
  3216. * asynchronous So we need to depend on some tlv to confirm
  3217. * all tlv is received for a ppdu.
  3218. * So we depend on both SCHED_CMD_STATUS_TLV and
  3219. * ACK_BA_STATUS_TLV. for failure packet we won't get
  3220. * ACK_BA_STATUS_TLV.
  3221. */
  3222. if (!(ppdu_info->tlv_bitmap &
  3223. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)) ||
  3224. (!(ppdu_info->tlv_bitmap &
  3225. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)) &&
  3226. (ppdu_desc->user[i].completion_status ==
  3227. HTT_PPDU_STATS_USER_STATUS_OK))) {
  3228. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3229. continue;
  3230. }
  3231. /**
  3232. * Update tx stats for data frames having Qos as well as
  3233. * non-Qos data tid
  3234. */
  3235. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  3236. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID) ||
  3237. (ppdu_desc->htt_frame_type ==
  3238. HTT_STATS_FTYPE_SGEN_QOS_NULL) ||
  3239. ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) &&
  3240. (ppdu_desc->num_mpdu > 1))) &&
  3241. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  3242. dp_tx_stats_update(pdev, peer,
  3243. &ppdu_desc->user[i],
  3244. ppdu_desc->ack_rssi);
  3245. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  3246. }
  3247. dp_ppdu_desc_user_phy_tx_time_update(pdev, ppdu_desc,
  3248. &ppdu_desc->user[i]);
  3249. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3250. tlv_bitmap_expected = tlv_bitmap_default;
  3251. }
  3252. }
  3253. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  3254. /**
  3255. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  3256. * to upper layer
  3257. * @pdev: DP pdev handle
  3258. * @ppdu_info: per PPDU TLV descriptor
  3259. *
  3260. * return: void
  3261. */
  3262. static
  3263. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  3264. struct ppdu_info *ppdu_info)
  3265. {
  3266. struct ppdu_info *s_ppdu_info = NULL;
  3267. struct ppdu_info *ppdu_info_next = NULL;
  3268. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3269. qdf_nbuf_t nbuf;
  3270. uint32_t time_delta = 0;
  3271. bool starved = 0;
  3272. bool matched = 0;
  3273. bool recv_ack_ba_done = 0;
  3274. if (ppdu_info->tlv_bitmap &
  3275. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3276. ppdu_info->done)
  3277. recv_ack_ba_done = 1;
  3278. pdev->last_sched_cmdid = ppdu_info->sched_cmdid;
  3279. s_ppdu_info = TAILQ_FIRST(&pdev->sched_comp_ppdu_list);
  3280. TAILQ_FOREACH_SAFE(s_ppdu_info, &pdev->sched_comp_ppdu_list,
  3281. ppdu_info_list_elem, ppdu_info_next) {
  3282. if (s_ppdu_info->tsf_l32 > ppdu_info->tsf_l32)
  3283. time_delta = (MAX_TSF_32 - s_ppdu_info->tsf_l32) +
  3284. ppdu_info->tsf_l32;
  3285. else
  3286. time_delta = ppdu_info->tsf_l32 - s_ppdu_info->tsf_l32;
  3287. if (!s_ppdu_info->done && !recv_ack_ba_done) {
  3288. if (time_delta < MAX_SCHED_STARVE) {
  3289. dp_info("pdev[%d] ppdu_id[%d] sched_cmdid[%d] TLV_B[0x%x] TSF[%u] D[%d]",
  3290. pdev->pdev_id,
  3291. s_ppdu_info->ppdu_id,
  3292. s_ppdu_info->sched_cmdid,
  3293. s_ppdu_info->tlv_bitmap,
  3294. s_ppdu_info->tsf_l32,
  3295. s_ppdu_info->done);
  3296. break;
  3297. }
  3298. starved = 1;
  3299. }
  3300. pdev->delivered_sched_cmdid = s_ppdu_info->sched_cmdid;
  3301. TAILQ_REMOVE(&pdev->sched_comp_ppdu_list, s_ppdu_info,
  3302. ppdu_info_list_elem);
  3303. pdev->sched_comp_list_depth--;
  3304. nbuf = s_ppdu_info->nbuf;
  3305. qdf_assert_always(nbuf);
  3306. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3307. qdf_nbuf_data(nbuf);
  3308. ppdu_desc->tlv_bitmap = s_ppdu_info->tlv_bitmap;
  3309. if (starved) {
  3310. dp_err("ppdu starved fc[0x%x] h_ftype[%d] tlv_bitmap[0x%x] cs[%d]\n",
  3311. ppdu_desc->frame_ctrl,
  3312. ppdu_desc->htt_frame_type,
  3313. ppdu_desc->tlv_bitmap,
  3314. ppdu_desc->user[0].completion_status);
  3315. starved = 0;
  3316. }
  3317. if (ppdu_info->ppdu_id == s_ppdu_info->ppdu_id &&
  3318. ppdu_info->sched_cmdid == s_ppdu_info->sched_cmdid)
  3319. matched = 1;
  3320. dp_ppdu_desc_user_stats_update(pdev, s_ppdu_info);
  3321. qdf_mem_free(s_ppdu_info);
  3322. /**
  3323. * Deliver PPDU stats only for valid (acked) data
  3324. * frames if sniffer mode is not enabled.
  3325. * If sniffer mode is enabled, PPDU stats
  3326. * for all frames including mgmt/control
  3327. * frames should be delivered to upper layer
  3328. */
  3329. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  3330. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3331. pdev->soc,
  3332. nbuf, HTT_INVALID_PEER,
  3333. WDI_NO_VAL,
  3334. pdev->pdev_id);
  3335. } else {
  3336. if (ppdu_desc->num_mpdu != 0 &&
  3337. ppdu_desc->num_users != 0 &&
  3338. ppdu_desc->frame_ctrl &
  3339. HTT_FRAMECTRL_DATATYPE) {
  3340. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3341. pdev->soc,
  3342. nbuf, HTT_INVALID_PEER,
  3343. WDI_NO_VAL,
  3344. pdev->pdev_id);
  3345. } else {
  3346. qdf_nbuf_free(nbuf);
  3347. }
  3348. }
  3349. if (matched)
  3350. break;
  3351. }
  3352. return;
  3353. }
  3354. #endif
  3355. /**
  3356. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  3357. * desc for new ppdu id
  3358. * @pdev: DP pdev handle
  3359. * @ppdu_id: PPDU unique identifier
  3360. * @tlv_type: TLV type received
  3361. * @tsf_l32: timestamp received along with ppdu stats indication header
  3362. * @max_users: Maximum user for that particular ppdu
  3363. *
  3364. * return: ppdu_info per ppdu tlv structure
  3365. */
  3366. static
  3367. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  3368. uint8_t tlv_type, uint32_t tsf_l32,
  3369. uint8_t max_users)
  3370. {
  3371. struct ppdu_info *ppdu_info = NULL;
  3372. struct ppdu_info *s_ppdu_info = NULL;
  3373. struct ppdu_info *ppdu_info_next = NULL;
  3374. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3375. uint32_t size = 0;
  3376. struct cdp_tx_completion_ppdu *tmp_ppdu_desc = NULL;
  3377. struct cdp_tx_completion_ppdu_user *tmp_user;
  3378. uint32_t time_delta;
  3379. /*
  3380. * Find ppdu_id node exists or not
  3381. */
  3382. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  3383. ppdu_info_list_elem, ppdu_info_next) {
  3384. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  3385. if (ppdu_info->tsf_l32 > tsf_l32)
  3386. time_delta = (MAX_TSF_32 -
  3387. ppdu_info->tsf_l32) + tsf_l32;
  3388. else
  3389. time_delta = tsf_l32 - ppdu_info->tsf_l32;
  3390. if (time_delta > WRAP_DROP_TSF_DELTA) {
  3391. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3392. ppdu_info, ppdu_info_list_elem);
  3393. pdev->list_depth--;
  3394. pdev->stats.ppdu_wrap_drop++;
  3395. tmp_ppdu_desc =
  3396. (struct cdp_tx_completion_ppdu *)
  3397. qdf_nbuf_data(ppdu_info->nbuf);
  3398. tmp_user = &tmp_ppdu_desc->user[0];
  3399. dp_htt_tx_stats_info("S_PID [%d] S_TSF[%u] TLV_BITMAP[0x%x] [CMPLTN - %d ACK_BA - %d] CS[%d] - R_PID[%d] R_TSF[%u] R_TLV_TAG[0x%x]\n",
  3400. ppdu_info->ppdu_id,
  3401. ppdu_info->tsf_l32,
  3402. ppdu_info->tlv_bitmap,
  3403. tmp_user->completion_status,
  3404. ppdu_info->compltn_common_tlv,
  3405. ppdu_info->ack_ba_tlv,
  3406. ppdu_id, tsf_l32, tlv_type);
  3407. qdf_nbuf_free(ppdu_info->nbuf);
  3408. ppdu_info->nbuf = NULL;
  3409. qdf_mem_free(ppdu_info);
  3410. } else {
  3411. break;
  3412. }
  3413. }
  3414. }
  3415. /*
  3416. * check if it is ack ba tlv and if it is not there in ppdu info
  3417. * list then check it in sched completion ppdu list
  3418. */
  3419. if (!ppdu_info &&
  3420. tlv_type == HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) {
  3421. TAILQ_FOREACH(s_ppdu_info,
  3422. &pdev->sched_comp_ppdu_list,
  3423. ppdu_info_list_elem) {
  3424. if (s_ppdu_info && (s_ppdu_info->ppdu_id == ppdu_id)) {
  3425. if (s_ppdu_info->tsf_l32 > tsf_l32)
  3426. time_delta = (MAX_TSF_32 -
  3427. s_ppdu_info->tsf_l32) +
  3428. tsf_l32;
  3429. else
  3430. time_delta = tsf_l32 -
  3431. s_ppdu_info->tsf_l32;
  3432. if (time_delta < WRAP_DROP_TSF_DELTA) {
  3433. ppdu_info = s_ppdu_info;
  3434. break;
  3435. }
  3436. } else {
  3437. /*
  3438. * ACK BA STATUS TLV comes sequential order
  3439. * if we received ack ba status tlv for second
  3440. * ppdu and first ppdu is still waiting for
  3441. * ACK BA STATUS TLV. Based on fw comment
  3442. * we won't receive it tlv later. So we can
  3443. * set ppdu info done.
  3444. */
  3445. if (s_ppdu_info)
  3446. s_ppdu_info->done = 1;
  3447. }
  3448. }
  3449. }
  3450. if (ppdu_info) {
  3451. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  3452. /**
  3453. * if we get tlv_type that is already been processed
  3454. * for ppdu, that means we got a new ppdu with same
  3455. * ppdu id. Hence Flush the older ppdu
  3456. * for MUMIMO and OFDMA, In a PPDU we have
  3457. * multiple user with same tlv types. tlv bitmap is
  3458. * used to check whether SU or MU_MIMO/OFDMA
  3459. */
  3460. if (!(ppdu_info->tlv_bitmap &
  3461. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  3462. return ppdu_info;
  3463. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3464. qdf_nbuf_data(ppdu_info->nbuf);
  3465. /**
  3466. * apart from ACK BA STATUS TLV rest all comes in order
  3467. * so if tlv type not ACK BA STATUS TLV we can deliver
  3468. * ppdu_info
  3469. */
  3470. if ((tlv_type ==
  3471. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3472. (ppdu_desc->htt_frame_type ==
  3473. HTT_STATS_FTYPE_SGEN_MU_BAR))
  3474. return ppdu_info;
  3475. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3476. } else {
  3477. return ppdu_info;
  3478. }
  3479. }
  3480. /**
  3481. * Flush the head ppdu descriptor if ppdu desc list reaches max
  3482. * threshold
  3483. */
  3484. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  3485. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  3486. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3487. ppdu_info, ppdu_info_list_elem);
  3488. pdev->list_depth--;
  3489. pdev->stats.ppdu_drop++;
  3490. qdf_nbuf_free(ppdu_info->nbuf);
  3491. ppdu_info->nbuf = NULL;
  3492. qdf_mem_free(ppdu_info);
  3493. }
  3494. size = sizeof(struct cdp_tx_completion_ppdu) +
  3495. (max_users * sizeof(struct cdp_tx_completion_ppdu_user));
  3496. /*
  3497. * Allocate new ppdu_info node
  3498. */
  3499. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  3500. if (!ppdu_info)
  3501. return NULL;
  3502. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev, size,
  3503. 0, 4, TRUE);
  3504. if (!ppdu_info->nbuf) {
  3505. qdf_mem_free(ppdu_info);
  3506. return NULL;
  3507. }
  3508. ppdu_info->ppdu_desc =
  3509. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  3510. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf), size);
  3511. if (qdf_nbuf_put_tail(ppdu_info->nbuf, size) == NULL) {
  3512. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3513. "No tailroom for HTT PPDU");
  3514. qdf_nbuf_free(ppdu_info->nbuf);
  3515. ppdu_info->nbuf = NULL;
  3516. ppdu_info->last_user = 0;
  3517. qdf_mem_free(ppdu_info);
  3518. return NULL;
  3519. }
  3520. ppdu_info->ppdu_desc->max_users = max_users;
  3521. ppdu_info->tsf_l32 = tsf_l32;
  3522. /**
  3523. * No lock is needed because all PPDU TLVs are processed in
  3524. * same context and this list is updated in same context
  3525. */
  3526. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  3527. ppdu_info_list_elem);
  3528. pdev->list_depth++;
  3529. return ppdu_info;
  3530. }
  3531. /**
  3532. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  3533. * @pdev: DP pdev handle
  3534. * @htt_t2h_msg: HTT target to host message
  3535. *
  3536. * return: ppdu_info per ppdu tlv structure
  3537. */
  3538. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  3539. qdf_nbuf_t htt_t2h_msg)
  3540. {
  3541. uint32_t length;
  3542. uint32_t ppdu_id;
  3543. uint8_t tlv_type;
  3544. uint32_t tlv_length, tlv_bitmap_expected;
  3545. uint8_t *tlv_buf;
  3546. struct ppdu_info *ppdu_info = NULL;
  3547. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3548. uint8_t max_users = CDP_MU_MAX_USERS;
  3549. uint32_t tsf_l32;
  3550. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3551. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  3552. msg_word = msg_word + 1;
  3553. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  3554. msg_word = msg_word + 1;
  3555. tsf_l32 = (uint32_t)(*msg_word);
  3556. msg_word = msg_word + 2;
  3557. while (length > 0) {
  3558. tlv_buf = (uint8_t *)msg_word;
  3559. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  3560. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  3561. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  3562. pdev->stats.ppdu_stats_counter[tlv_type]++;
  3563. if (tlv_length == 0)
  3564. break;
  3565. tlv_length += HTT_TLV_HDR_LEN;
  3566. /**
  3567. * Not allocating separate ppdu descriptor for MGMT Payload
  3568. * TLV as this is sent as separate WDI indication and it
  3569. * doesn't contain any ppdu information
  3570. */
  3571. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  3572. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  3573. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  3574. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  3575. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  3576. (*(msg_word + 1));
  3577. msg_word =
  3578. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3579. length -= (tlv_length);
  3580. continue;
  3581. }
  3582. /*
  3583. * retrieve max_users if it's USERS_INFO,
  3584. * else, it's 1 for COMPLTN_FLUSH,
  3585. * else, use CDP_MU_MAX_USERS
  3586. */
  3587. if (tlv_type == HTT_PPDU_STATS_USERS_INFO_TLV) {
  3588. max_users =
  3589. HTT_PPDU_STATS_USERS_INFO_TLV_MAX_USERS_GET(*(msg_word + 1));
  3590. } else if (tlv_type == HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) {
  3591. max_users = 1;
  3592. }
  3593. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type,
  3594. tsf_l32, max_users);
  3595. if (!ppdu_info)
  3596. return NULL;
  3597. ppdu_info->ppdu_desc->bss_color =
  3598. pdev->rx_mon_recv_status.bsscolor;
  3599. ppdu_info->ppdu_id = ppdu_id;
  3600. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  3601. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  3602. /**
  3603. * Increment pdev level tlv count to monitor
  3604. * missing TLVs
  3605. */
  3606. pdev->tlv_count++;
  3607. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  3608. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3609. length -= (tlv_length);
  3610. }
  3611. if (!ppdu_info)
  3612. return NULL;
  3613. pdev->last_ppdu_id = ppdu_id;
  3614. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3615. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3616. pdev->tx_capture_enabled) {
  3617. if (ppdu_info->is_ampdu)
  3618. tlv_bitmap_expected =
  3619. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3620. ppdu_info->tlv_bitmap);
  3621. }
  3622. ppdu_desc = ppdu_info->ppdu_desc;
  3623. if (!ppdu_desc)
  3624. return NULL;
  3625. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  3626. HTT_PPDU_STATS_USER_STATUS_OK) {
  3627. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  3628. }
  3629. /*
  3630. * for frame type DATA and BAR, we update stats based on MSDU,
  3631. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  3632. * which comes out of order. successful mpdu also populated from
  3633. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  3634. * we store successful mpdu from both tlv and compare before delivering
  3635. * to make sure we received ACK BA STATUS TLV. For some self generated
  3636. * frame we won't get ack ba status tlv so no need to wait for
  3637. * ack ba status tlv.
  3638. */
  3639. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL &&
  3640. ppdu_desc->htt_frame_type != HTT_STATS_FTYPE_SGEN_QOS_NULL) {
  3641. /*
  3642. * most of the time bar frame will have duplicate ack ba
  3643. * status tlv
  3644. */
  3645. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  3646. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv))
  3647. return NULL;
  3648. /*
  3649. * For data frame, compltn common tlv should match ack ba status
  3650. * tlv and completion status. Reason we are checking first user
  3651. * for ofdma, completion seen at next MU BAR frm, for mimo
  3652. * only for first user completion will be immediate.
  3653. */
  3654. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  3655. (ppdu_desc->user[0].completion_status == 0 &&
  3656. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv)))
  3657. return NULL;
  3658. }
  3659. /**
  3660. * Once all the TLVs for a given PPDU has been processed,
  3661. * return PPDU status to be delivered to higher layer.
  3662. * tlv_bitmap_expected can't be available for different frame type.
  3663. * But SCHED CMD STATS TLV is the last TLV from the FW for a ppdu.
  3664. * apart from ACK BA TLV, FW sends other TLV in sequential order.
  3665. * flush tlv comes separate.
  3666. */
  3667. if ((ppdu_info->tlv_bitmap != 0 &&
  3668. (ppdu_info->tlv_bitmap &
  3669. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV))) ||
  3670. (ppdu_info->tlv_bitmap &
  3671. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV))) {
  3672. ppdu_info->done = 1;
  3673. return ppdu_info;
  3674. }
  3675. return NULL;
  3676. }
  3677. #endif /* FEATURE_PERPKT_INFO */
  3678. /**
  3679. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  3680. * @soc: DP SOC handle
  3681. * @pdev_id: pdev id
  3682. * @htt_t2h_msg: HTT message nbuf
  3683. *
  3684. * return:void
  3685. */
  3686. #if defined(WDI_EVENT_ENABLE)
  3687. #ifdef FEATURE_PERPKT_INFO
  3688. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3689. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3690. {
  3691. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  3692. struct ppdu_info *ppdu_info = NULL;
  3693. bool free_buf = true;
  3694. if (pdev_id >= MAX_PDEV_CNT)
  3695. return true;
  3696. pdev = soc->pdev_list[pdev_id];
  3697. if (!pdev)
  3698. return true;
  3699. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  3700. !pdev->mcopy_mode && !pdev->bpr_enable)
  3701. return free_buf;
  3702. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  3703. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  3704. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  3705. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  3706. QDF_STATUS_SUCCESS)
  3707. free_buf = false;
  3708. }
  3709. if (ppdu_info)
  3710. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3711. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  3712. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  3713. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  3714. return free_buf;
  3715. }
  3716. #else
  3717. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3718. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3719. {
  3720. return true;
  3721. }
  3722. #endif
  3723. #endif
  3724. /**
  3725. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3726. * @soc: DP SOC handle
  3727. * @htt_t2h_msg: HTT message nbuf
  3728. *
  3729. * return:void
  3730. */
  3731. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3732. qdf_nbuf_t htt_t2h_msg)
  3733. {
  3734. uint8_t done;
  3735. qdf_nbuf_t msg_copy;
  3736. uint32_t *msg_word;
  3737. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3738. msg_word = msg_word + 3;
  3739. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3740. /*
  3741. * HTT EXT stats response comes as stream of TLVs which span over
  3742. * multiple T2H messages.
  3743. * The first message will carry length of the response.
  3744. * For rest of the messages length will be zero.
  3745. *
  3746. * Clone the T2H message buffer and store it in a list to process
  3747. * it later.
  3748. *
  3749. * The original T2H message buffers gets freed in the T2H HTT event
  3750. * handler
  3751. */
  3752. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3753. if (!msg_copy) {
  3754. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3755. "T2H messge clone failed for HTT EXT STATS");
  3756. goto error;
  3757. }
  3758. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3759. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3760. /*
  3761. * Done bit signifies that this is the last T2H buffer in the stream of
  3762. * HTT EXT STATS message
  3763. */
  3764. if (done) {
  3765. soc->htt_stats.num_stats++;
  3766. qdf_sched_work(0, &soc->htt_stats.work);
  3767. }
  3768. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3769. return;
  3770. error:
  3771. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3772. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3773. != NULL) {
  3774. qdf_nbuf_free(msg_copy);
  3775. }
  3776. soc->htt_stats.num_stats = 0;
  3777. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3778. return;
  3779. }
  3780. /*
  3781. * htt_soc_attach_target() - SOC level HTT setup
  3782. * @htt_soc: HTT SOC handle
  3783. *
  3784. * Return: 0 on success; error code on failure
  3785. */
  3786. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3787. {
  3788. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3789. return htt_h2t_ver_req_msg(soc);
  3790. }
  3791. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3792. {
  3793. htt_soc->htc_soc = htc_soc;
  3794. }
  3795. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3796. {
  3797. return htt_soc->htc_soc;
  3798. }
  3799. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3800. {
  3801. int i;
  3802. int j;
  3803. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3804. struct htt_soc *htt_soc = NULL;
  3805. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3806. if (!htt_soc) {
  3807. dp_err("HTT attach failed");
  3808. return NULL;
  3809. }
  3810. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3811. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3812. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3813. break;
  3814. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3815. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3816. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3817. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3818. break;
  3819. }
  3820. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3821. }
  3822. if (i != MAX_PDEV_CNT) {
  3823. for (j = 0; j < i; j++) {
  3824. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  3825. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  3826. }
  3827. qdf_mem_free(htt_soc);
  3828. return NULL;
  3829. }
  3830. htt_soc->dp_soc = soc;
  3831. htt_soc->htc_soc = htc_handle;
  3832. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3833. return htt_soc;
  3834. }
  3835. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3836. /*
  3837. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3838. * @htt_soc: HTT SOC handle
  3839. * @msg_word: Pointer to payload
  3840. * @htt_t2h_msg: HTT msg nbuf
  3841. *
  3842. * Return: True if buffer should be freed by caller.
  3843. */
  3844. static bool
  3845. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3846. uint32_t *msg_word,
  3847. qdf_nbuf_t htt_t2h_msg)
  3848. {
  3849. u_int8_t pdev_id;
  3850. u_int8_t target_pdev_id;
  3851. bool free_buf;
  3852. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3853. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3854. target_pdev_id);
  3855. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3856. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3857. pdev_id);
  3858. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3859. htt_t2h_msg);
  3860. return free_buf;
  3861. }
  3862. #else
  3863. static bool
  3864. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3865. uint32_t *msg_word,
  3866. qdf_nbuf_t htt_t2h_msg)
  3867. {
  3868. return true;
  3869. }
  3870. #endif
  3871. #if defined(WDI_EVENT_ENABLE) && \
  3872. !defined(REMOVE_PKT_LOG)
  3873. /*
  3874. * dp_pktlog_msg_handler() - Pktlog msg handler
  3875. * @htt_soc: HTT SOC handle
  3876. * @msg_word: Pointer to payload
  3877. *
  3878. * Return: None
  3879. */
  3880. static void
  3881. dp_pktlog_msg_handler(struct htt_soc *soc,
  3882. uint32_t *msg_word)
  3883. {
  3884. uint8_t pdev_id;
  3885. uint8_t target_pdev_id;
  3886. uint32_t *pl_hdr;
  3887. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3888. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3889. target_pdev_id);
  3890. pl_hdr = (msg_word + 1);
  3891. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3892. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3893. pdev_id);
  3894. }
  3895. #else
  3896. static void
  3897. dp_pktlog_msg_handler(struct htt_soc *soc,
  3898. uint32_t *msg_word)
  3899. {
  3900. }
  3901. #endif
  3902. /*
  3903. * time_allow_print() - time allow print
  3904. * @htt_ring_tt: ringi_id array of timestamps
  3905. * @ring_id: ring_id (index)
  3906. *
  3907. * Return: 1 for successfully saving timestamp in array
  3908. * and 0 for timestamp falling within 2 seconds after last one
  3909. */
  3910. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3911. {
  3912. unsigned long tstamp;
  3913. unsigned long delta;
  3914. tstamp = qdf_get_system_timestamp();
  3915. if (!htt_ring_tt)
  3916. return 0; //unable to print backpressure messages
  3917. if (htt_ring_tt[ring_id] == -1) {
  3918. htt_ring_tt[ring_id] = tstamp;
  3919. return 1;
  3920. }
  3921. delta = tstamp - htt_ring_tt[ring_id];
  3922. if (delta >= 2000) {
  3923. htt_ring_tt[ring_id] = tstamp;
  3924. return 1;
  3925. }
  3926. return 0;
  3927. }
  3928. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3929. u_int8_t pdev_id, u_int8_t ring_id,
  3930. u_int16_t hp_idx, u_int16_t tp_idx,
  3931. u_int32_t bkp_time, char *ring_stype)
  3932. {
  3933. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3934. msg_type, pdev_id, ring_stype);
  3935. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3936. ring_id, hp_idx, tp_idx, bkp_time);
  3937. }
  3938. /*
  3939. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3940. * @msg_word: htt packet context
  3941. * @htt_soc: HTT SOC handle
  3942. *
  3943. * Return: after attempting to print stats
  3944. */
  3945. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3946. {
  3947. u_int8_t ring_type;
  3948. u_int8_t pdev_id;
  3949. uint8_t target_pdev_id;
  3950. u_int8_t ring_id;
  3951. u_int16_t hp_idx;
  3952. u_int16_t tp_idx;
  3953. u_int32_t bkp_time;
  3954. enum htt_t2h_msg_type msg_type;
  3955. struct dp_soc *dpsoc;
  3956. struct dp_pdev *pdev;
  3957. struct dp_htt_timestamp *radio_tt;
  3958. if (!soc)
  3959. return;
  3960. dpsoc = (struct dp_soc *)soc->dp_soc;
  3961. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3962. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3963. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3964. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3965. target_pdev_id);
  3966. if (pdev_id >= MAX_PDEV_CNT) {
  3967. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  3968. return;
  3969. }
  3970. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3971. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3972. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3973. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3974. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3975. radio_tt = &soc->pdevid_tt[pdev_id];
  3976. switch (ring_type) {
  3977. case HTT_SW_RING_TYPE_UMAC:
  3978. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3979. return;
  3980. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3981. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  3982. break;
  3983. case HTT_SW_RING_TYPE_LMAC:
  3984. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3985. return;
  3986. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3987. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3988. break;
  3989. default:
  3990. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3991. bkp_time, "UNKNOWN");
  3992. break;
  3993. }
  3994. dp_print_ring_stats(pdev);
  3995. dp_print_napi_stats(pdev->soc);
  3996. }
  3997. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  3998. /*
  3999. * dp_offload_ind_handler() - offload msg handler
  4000. * @htt_soc: HTT SOC handle
  4001. * @msg_word: Pointer to payload
  4002. *
  4003. * Return: None
  4004. */
  4005. static void
  4006. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  4007. {
  4008. u_int8_t pdev_id;
  4009. u_int8_t target_pdev_id;
  4010. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  4011. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  4012. target_pdev_id);
  4013. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  4014. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  4015. pdev_id);
  4016. }
  4017. #else
  4018. static void
  4019. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  4020. {
  4021. }
  4022. #endif
  4023. /*
  4024. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  4025. * @context: Opaque context (HTT SOC handle)
  4026. * @pkt: HTC packet
  4027. */
  4028. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  4029. {
  4030. struct htt_soc *soc = (struct htt_soc *) context;
  4031. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  4032. u_int32_t *msg_word;
  4033. enum htt_t2h_msg_type msg_type;
  4034. bool free_buf = true;
  4035. /* check for successful message reception */
  4036. if (pkt->Status != QDF_STATUS_SUCCESS) {
  4037. if (pkt->Status != QDF_STATUS_E_CANCELED)
  4038. soc->stats.htc_err_cnt++;
  4039. qdf_nbuf_free(htt_t2h_msg);
  4040. return;
  4041. }
  4042. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  4043. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  4044. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  4045. htt_event_record(soc->htt_logger_handle,
  4046. msg_type, (uint8_t *)msg_word);
  4047. switch (msg_type) {
  4048. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  4049. {
  4050. dp_htt_bkp_event_alert(msg_word, soc);
  4051. break;
  4052. }
  4053. case HTT_T2H_MSG_TYPE_PEER_MAP:
  4054. {
  4055. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4056. u_int8_t *peer_mac_addr;
  4057. u_int16_t peer_id;
  4058. u_int16_t hw_peer_id;
  4059. u_int8_t vdev_id;
  4060. u_int8_t is_wds;
  4061. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  4062. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  4063. hw_peer_id =
  4064. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  4065. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  4066. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  4067. (u_int8_t *) (msg_word+1),
  4068. &mac_addr_deswizzle_buf[0]);
  4069. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4070. QDF_TRACE_LEVEL_INFO,
  4071. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4072. peer_id, vdev_id);
  4073. /*
  4074. * check if peer already exists for this peer_id, if so
  4075. * this peer map event is in response for a wds peer add
  4076. * wmi command sent during wds source port learning.
  4077. * in this case just add the ast entry to the existing
  4078. * peer ast_list.
  4079. */
  4080. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  4081. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  4082. vdev_id, peer_mac_addr, 0,
  4083. is_wds);
  4084. break;
  4085. }
  4086. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  4087. {
  4088. u_int16_t peer_id;
  4089. u_int8_t vdev_id;
  4090. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  4091. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  4092. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  4093. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4094. vdev_id, mac_addr, 0,
  4095. DP_PEER_WDS_COUNT_INVALID);
  4096. break;
  4097. }
  4098. case HTT_T2H_MSG_TYPE_SEC_IND:
  4099. {
  4100. u_int16_t peer_id;
  4101. enum cdp_sec_type sec_type;
  4102. int is_unicast;
  4103. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  4104. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  4105. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  4106. /* point to the first part of the Michael key */
  4107. msg_word++;
  4108. dp_rx_sec_ind_handler(
  4109. soc->dp_soc, peer_id, sec_type, is_unicast,
  4110. msg_word, msg_word + 2);
  4111. break;
  4112. }
  4113. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  4114. {
  4115. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  4116. htt_t2h_msg);
  4117. break;
  4118. }
  4119. case HTT_T2H_MSG_TYPE_PKTLOG:
  4120. {
  4121. dp_pktlog_msg_handler(soc, msg_word);
  4122. break;
  4123. }
  4124. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  4125. {
  4126. /*
  4127. * HTC maintains runtime pm count for H2T messages that
  4128. * have a response msg from FW. This count ensures that
  4129. * in the case FW does not sent out the response or host
  4130. * did not process this indication runtime_put happens
  4131. * properly in the cleanup path.
  4132. */
  4133. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  4134. htc_pm_runtime_put(soc->htc_soc);
  4135. else
  4136. soc->stats.htt_ver_req_put_skip++;
  4137. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  4138. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  4139. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  4140. "target uses HTT version %d.%d; host uses %d.%d",
  4141. soc->tgt_ver.major, soc->tgt_ver.minor,
  4142. HTT_CURRENT_VERSION_MAJOR,
  4143. HTT_CURRENT_VERSION_MINOR);
  4144. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  4145. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4146. QDF_TRACE_LEVEL_WARN,
  4147. "*** Incompatible host/target HTT versions!");
  4148. }
  4149. /* abort if the target is incompatible with the host */
  4150. qdf_assert(soc->tgt_ver.major ==
  4151. HTT_CURRENT_VERSION_MAJOR);
  4152. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  4153. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4154. QDF_TRACE_LEVEL_INFO_LOW,
  4155. "*** Warning: host/target HTT versions"
  4156. " are different, though compatible!");
  4157. }
  4158. break;
  4159. }
  4160. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  4161. {
  4162. uint16_t peer_id;
  4163. uint8_t tid;
  4164. uint8_t win_sz;
  4165. uint16_t status;
  4166. struct dp_peer *peer;
  4167. /*
  4168. * Update REO Queue Desc with new values
  4169. */
  4170. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  4171. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  4172. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  4173. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  4174. DP_MOD_ID_HTT);
  4175. /*
  4176. * Window size needs to be incremented by 1
  4177. * since fw needs to represent a value of 256
  4178. * using just 8 bits
  4179. */
  4180. if (peer) {
  4181. status = dp_addba_requestprocess_wifi3(
  4182. (struct cdp_soc_t *)soc->dp_soc,
  4183. peer->mac_addr.raw, peer->vdev->vdev_id,
  4184. 0, tid, 0, win_sz + 1, 0xffff);
  4185. /*
  4186. * If PEER_LOCK_REF_PROTECT enbled dec ref
  4187. * which is inc by dp_peer_get_ref_by_id
  4188. */
  4189. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4190. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4191. QDF_TRACE_LEVEL_INFO,
  4192. FL("PeerID %d BAW %d TID %d stat %d"),
  4193. peer_id, win_sz, tid, status);
  4194. } else {
  4195. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4196. QDF_TRACE_LEVEL_ERROR,
  4197. FL("Peer not found peer id %d"),
  4198. peer_id);
  4199. }
  4200. break;
  4201. }
  4202. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  4203. {
  4204. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  4205. break;
  4206. }
  4207. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  4208. {
  4209. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4210. u_int8_t *peer_mac_addr;
  4211. u_int16_t peer_id;
  4212. u_int16_t hw_peer_id;
  4213. u_int8_t vdev_id;
  4214. bool is_wds;
  4215. u_int16_t ast_hash;
  4216. struct dp_ast_flow_override_info ast_flow_info;
  4217. qdf_mem_set(&ast_flow_info, 0,
  4218. sizeof(struct dp_ast_flow_override_info));
  4219. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  4220. hw_peer_id =
  4221. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  4222. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  4223. peer_mac_addr =
  4224. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4225. &mac_addr_deswizzle_buf[0]);
  4226. is_wds =
  4227. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  4228. ast_hash =
  4229. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  4230. /*
  4231. * Update 4 ast_index per peer, ast valid mask
  4232. * and TID flow valid mask.
  4233. * AST valid mask is 3 bit field corresponds to
  4234. * ast_index[3:1]. ast_index 0 is always valid.
  4235. */
  4236. ast_flow_info.ast_valid_mask =
  4237. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  4238. ast_flow_info.ast_idx[0] = hw_peer_id;
  4239. ast_flow_info.ast_flow_mask[0] =
  4240. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  4241. ast_flow_info.ast_idx[1] =
  4242. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  4243. ast_flow_info.ast_flow_mask[1] =
  4244. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  4245. ast_flow_info.ast_idx[2] =
  4246. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  4247. ast_flow_info.ast_flow_mask[2] =
  4248. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  4249. ast_flow_info.ast_idx[3] =
  4250. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  4251. ast_flow_info.ast_flow_mask[3] =
  4252. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  4253. /*
  4254. * TID valid mask is applicable only
  4255. * for HI and LOW priority flows.
  4256. * tid_valid_mas is 8 bit field corresponds
  4257. * to TID[7:0]
  4258. */
  4259. ast_flow_info.tid_valid_low_pri_mask =
  4260. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  4261. ast_flow_info.tid_valid_hi_pri_mask =
  4262. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  4263. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4264. QDF_TRACE_LEVEL_INFO,
  4265. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4266. peer_id, vdev_id);
  4267. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  4268. hw_peer_id, vdev_id,
  4269. peer_mac_addr, ast_hash,
  4270. is_wds);
  4271. /*
  4272. * Update ast indexes for flow override support
  4273. * Applicable only for non wds peers
  4274. */
  4275. dp_peer_ast_index_flow_queue_map_create(
  4276. soc->dp_soc, is_wds,
  4277. peer_id, peer_mac_addr,
  4278. &ast_flow_info);
  4279. break;
  4280. }
  4281. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  4282. {
  4283. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4284. u_int8_t *mac_addr;
  4285. u_int16_t peer_id;
  4286. u_int8_t vdev_id;
  4287. u_int8_t is_wds;
  4288. u_int32_t free_wds_count;
  4289. peer_id =
  4290. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  4291. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  4292. mac_addr =
  4293. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4294. &mac_addr_deswizzle_buf[0]);
  4295. is_wds =
  4296. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  4297. free_wds_count =
  4298. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  4299. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4300. QDF_TRACE_LEVEL_INFO,
  4301. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  4302. peer_id, vdev_id);
  4303. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4304. vdev_id, mac_addr,
  4305. is_wds, free_wds_count);
  4306. break;
  4307. }
  4308. case HTT_T2H_MSG_TYPE_RX_DELBA:
  4309. {
  4310. uint16_t peer_id;
  4311. uint8_t tid;
  4312. uint8_t win_sz;
  4313. QDF_STATUS status;
  4314. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  4315. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  4316. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  4317. status = dp_rx_delba_ind_handler(
  4318. soc->dp_soc,
  4319. peer_id, tid, win_sz);
  4320. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4321. QDF_TRACE_LEVEL_INFO,
  4322. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  4323. peer_id, win_sz, tid, status);
  4324. break;
  4325. }
  4326. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  4327. {
  4328. uint16_t num_entries;
  4329. uint32_t cmem_ba_lo;
  4330. uint32_t cmem_ba_hi;
  4331. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  4332. cmem_ba_lo = *(msg_word + 1);
  4333. cmem_ba_hi = *(msg_word + 2);
  4334. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  4335. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  4336. num_entries, cmem_ba_lo, cmem_ba_hi);
  4337. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  4338. cmem_ba_lo, cmem_ba_hi);
  4339. break;
  4340. }
  4341. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  4342. {
  4343. dp_offload_ind_handler(soc, msg_word);
  4344. break;
  4345. }
  4346. default:
  4347. break;
  4348. };
  4349. /* Free the indication buffer */
  4350. if (free_buf)
  4351. qdf_nbuf_free(htt_t2h_msg);
  4352. }
  4353. /*
  4354. * dp_htt_h2t_full() - Send full handler (called from HTC)
  4355. * @context: Opaque context (HTT SOC handle)
  4356. * @pkt: HTC packet
  4357. *
  4358. * Return: enum htc_send_full_action
  4359. */
  4360. static enum htc_send_full_action
  4361. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  4362. {
  4363. return HTC_SEND_FULL_KEEP;
  4364. }
  4365. /*
  4366. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  4367. * @context: Opaque context (HTT SOC handle)
  4368. * @nbuf: nbuf containing T2H message
  4369. * @pipe_id: HIF pipe ID
  4370. *
  4371. * Return: QDF_STATUS
  4372. *
  4373. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  4374. * will be used for packet log and other high-priority HTT messages. Proper
  4375. * HTC connection to be added later once required FW changes are available
  4376. */
  4377. static QDF_STATUS
  4378. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  4379. {
  4380. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  4381. HTC_PACKET htc_pkt;
  4382. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  4383. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  4384. htc_pkt.Status = QDF_STATUS_SUCCESS;
  4385. htc_pkt.pPktContext = (void *)nbuf;
  4386. dp_htt_t2h_msg_handler(context, &htc_pkt);
  4387. return rc;
  4388. }
  4389. /*
  4390. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  4391. * @htt_soc: HTT SOC handle
  4392. *
  4393. * Return: QDF_STATUS
  4394. */
  4395. static QDF_STATUS
  4396. htt_htc_soc_attach(struct htt_soc *soc)
  4397. {
  4398. struct htc_service_connect_req connect;
  4399. struct htc_service_connect_resp response;
  4400. QDF_STATUS status;
  4401. struct dp_soc *dpsoc = soc->dp_soc;
  4402. qdf_mem_zero(&connect, sizeof(connect));
  4403. qdf_mem_zero(&response, sizeof(response));
  4404. connect.pMetaData = NULL;
  4405. connect.MetaDataLength = 0;
  4406. connect.EpCallbacks.pContext = soc;
  4407. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  4408. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  4409. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  4410. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  4411. connect.EpCallbacks.EpRecvRefill = NULL;
  4412. /* N/A, fill is done by HIF */
  4413. connect.EpCallbacks.RecvRefillWaterMark = 1;
  4414. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  4415. /*
  4416. * Specify how deep to let a queue get before htc_send_pkt will
  4417. * call the EpSendFull function due to excessive send queue depth.
  4418. */
  4419. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  4420. /* disable flow control for HTT data message service */
  4421. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  4422. /* connect to control service */
  4423. connect.service_id = HTT_DATA_MSG_SVC;
  4424. status = htc_connect_service(soc->htc_soc, &connect, &response);
  4425. if (status != QDF_STATUS_SUCCESS)
  4426. return status;
  4427. soc->htc_endpoint = response.Endpoint;
  4428. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  4429. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  4430. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  4431. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  4432. return QDF_STATUS_SUCCESS; /* success */
  4433. }
  4434. /*
  4435. * htt_soc_initialize() - SOC level HTT initialization
  4436. * @htt_soc: Opaque htt SOC handle
  4437. * @ctrl_psoc: Opaque ctrl SOC handle
  4438. * @htc_soc: SOC level HTC handle
  4439. * @hal_soc: Opaque HAL SOC handle
  4440. * @osdev: QDF device
  4441. *
  4442. * Return: HTT handle on success; NULL on failure
  4443. */
  4444. void *
  4445. htt_soc_initialize(struct htt_soc *htt_soc,
  4446. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  4447. HTC_HANDLE htc_soc,
  4448. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  4449. {
  4450. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  4451. soc->osdev = osdev;
  4452. soc->ctrl_psoc = ctrl_psoc;
  4453. soc->htc_soc = htc_soc;
  4454. soc->hal_soc = hal_soc_hdl;
  4455. if (htt_htc_soc_attach(soc))
  4456. goto fail2;
  4457. return soc;
  4458. fail2:
  4459. return NULL;
  4460. }
  4461. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  4462. {
  4463. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  4464. htt_htc_misc_pkt_pool_free(htt_handle);
  4465. htt_htc_pkt_pool_free(htt_handle);
  4466. }
  4467. /*
  4468. * htt_soc_htc_prealloc() - HTC memory prealloc
  4469. * @htt_soc: SOC level HTT handle
  4470. *
  4471. * Return: QDF_STATUS_SUCCESS on Success or
  4472. * QDF_STATUS_E_NOMEM on allocation failure
  4473. */
  4474. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  4475. {
  4476. int i;
  4477. soc->htt_htc_pkt_freelist = NULL;
  4478. /* pre-allocate some HTC_PACKET objects */
  4479. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  4480. struct dp_htt_htc_pkt_union *pkt;
  4481. pkt = qdf_mem_malloc(sizeof(*pkt));
  4482. if (!pkt)
  4483. return QDF_STATUS_E_NOMEM;
  4484. htt_htc_pkt_free(soc, &pkt->u.pkt);
  4485. }
  4486. return QDF_STATUS_SUCCESS;
  4487. }
  4488. /*
  4489. * htt_soc_detach() - Free SOC level HTT handle
  4490. * @htt_hdl: HTT SOC handle
  4491. */
  4492. void htt_soc_detach(struct htt_soc *htt_hdl)
  4493. {
  4494. int i;
  4495. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  4496. for (i = 0; i < MAX_PDEV_CNT; i++) {
  4497. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  4498. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  4499. }
  4500. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  4501. qdf_mem_free(htt_handle);
  4502. }
  4503. /**
  4504. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  4505. * @pdev: DP PDEV handle
  4506. * @stats_type_upload_mask: stats type requested by user
  4507. * @config_param_0: extra configuration parameters
  4508. * @config_param_1: extra configuration parameters
  4509. * @config_param_2: extra configuration parameters
  4510. * @config_param_3: extra configuration parameters
  4511. * @mac_id: mac number
  4512. *
  4513. * return: QDF STATUS
  4514. */
  4515. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  4516. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  4517. uint32_t config_param_1, uint32_t config_param_2,
  4518. uint32_t config_param_3, int cookie_val, int cookie_msb,
  4519. uint8_t mac_id)
  4520. {
  4521. struct htt_soc *soc = pdev->soc->htt_handle;
  4522. struct dp_htt_htc_pkt *pkt;
  4523. qdf_nbuf_t msg;
  4524. uint32_t *msg_word;
  4525. uint8_t pdev_mask = 0;
  4526. uint8_t *htt_logger_bufp;
  4527. int mac_for_pdev;
  4528. int target_pdev_id;
  4529. QDF_STATUS status;
  4530. msg = qdf_nbuf_alloc(
  4531. soc->osdev,
  4532. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  4533. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4534. if (!msg)
  4535. return QDF_STATUS_E_NOMEM;
  4536. /*TODO:Add support for SOC stats
  4537. * Bit 0: SOC Stats
  4538. * Bit 1: Pdev stats for pdev id 0
  4539. * Bit 2: Pdev stats for pdev id 1
  4540. * Bit 3: Pdev stats for pdev id 2
  4541. */
  4542. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4543. target_pdev_id =
  4544. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4545. pdev_mask = 1 << target_pdev_id;
  4546. /*
  4547. * Set the length of the message.
  4548. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4549. * separately during the below call to qdf_nbuf_push_head.
  4550. * The contribution from the HTC header is added separately inside HTC.
  4551. */
  4552. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  4553. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4554. "Failed to expand head for HTT_EXT_STATS");
  4555. qdf_nbuf_free(msg);
  4556. return QDF_STATUS_E_FAILURE;
  4557. }
  4558. dp_htt_tx_stats_info("%pK: cookie <-> %d\n config_param_0 %u\n"
  4559. "config_param_1 %u\n config_param_2 %u\n"
  4560. "config_param_4 %u\n -------------",
  4561. pdev->soc, cookie_val,
  4562. config_param_0,
  4563. config_param_1, config_param_2, config_param_3);
  4564. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4565. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4566. htt_logger_bufp = (uint8_t *)msg_word;
  4567. *msg_word = 0;
  4568. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  4569. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  4570. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  4571. /* word 1 */
  4572. msg_word++;
  4573. *msg_word = 0;
  4574. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  4575. /* word 2 */
  4576. msg_word++;
  4577. *msg_word = 0;
  4578. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  4579. /* word 3 */
  4580. msg_word++;
  4581. *msg_word = 0;
  4582. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  4583. /* word 4 */
  4584. msg_word++;
  4585. *msg_word = 0;
  4586. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  4587. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  4588. /* word 5 */
  4589. msg_word++;
  4590. /* word 6 */
  4591. msg_word++;
  4592. *msg_word = 0;
  4593. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  4594. /* word 7 */
  4595. msg_word++;
  4596. *msg_word = 0;
  4597. /* Currently Using last 2 bits for pdev_id
  4598. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  4599. */
  4600. cookie_msb = (cookie_msb | pdev->pdev_id);
  4601. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  4602. pkt = htt_htc_pkt_alloc(soc);
  4603. if (!pkt) {
  4604. qdf_nbuf_free(msg);
  4605. return QDF_STATUS_E_NOMEM;
  4606. }
  4607. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4608. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4609. dp_htt_h2t_send_complete_free_netbuf,
  4610. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4611. soc->htc_endpoint,
  4612. /* tag for FW response msg not guaranteed */
  4613. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4614. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4615. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  4616. htt_logger_bufp);
  4617. if (status != QDF_STATUS_SUCCESS) {
  4618. qdf_nbuf_free(msg);
  4619. htt_htc_pkt_free(soc, pkt);
  4620. }
  4621. return status;
  4622. }
  4623. /**
  4624. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  4625. * HTT message to pass to FW
  4626. * @pdev: DP PDEV handle
  4627. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4628. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4629. *
  4630. * tuple_mask[1:0]:
  4631. * 00 - Do not report 3 tuple hash value
  4632. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4633. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4634. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4635. *
  4636. * return: QDF STATUS
  4637. */
  4638. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4639. uint32_t tuple_mask, uint8_t mac_id)
  4640. {
  4641. struct htt_soc *soc = pdev->soc->htt_handle;
  4642. struct dp_htt_htc_pkt *pkt;
  4643. qdf_nbuf_t msg;
  4644. uint32_t *msg_word;
  4645. uint8_t *htt_logger_bufp;
  4646. int mac_for_pdev;
  4647. int target_pdev_id;
  4648. msg = qdf_nbuf_alloc(
  4649. soc->osdev,
  4650. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4651. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4652. if (!msg)
  4653. return QDF_STATUS_E_NOMEM;
  4654. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4655. target_pdev_id =
  4656. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4657. /*
  4658. * Set the length of the message.
  4659. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4660. * separately during the below call to qdf_nbuf_push_head.
  4661. * The contribution from the HTC header is added separately inside HTC.
  4662. */
  4663. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4664. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4665. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4666. qdf_nbuf_free(msg);
  4667. return QDF_STATUS_E_FAILURE;
  4668. }
  4669. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  4670. pdev->soc, tuple_mask, target_pdev_id);
  4671. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4672. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4673. htt_logger_bufp = (uint8_t *)msg_word;
  4674. *msg_word = 0;
  4675. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4676. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4677. msg_word++;
  4678. *msg_word = 0;
  4679. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4680. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4681. pkt = htt_htc_pkt_alloc(soc);
  4682. if (!pkt) {
  4683. qdf_nbuf_free(msg);
  4684. return QDF_STATUS_E_NOMEM;
  4685. }
  4686. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4687. SET_HTC_PACKET_INFO_TX(
  4688. &pkt->htc_pkt,
  4689. dp_htt_h2t_send_complete_free_netbuf,
  4690. qdf_nbuf_data(msg),
  4691. qdf_nbuf_len(msg),
  4692. soc->htc_endpoint,
  4693. /* tag for no FW response msg */
  4694. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4695. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4696. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4697. htt_logger_bufp);
  4698. return QDF_STATUS_SUCCESS;
  4699. }
  4700. /* This macro will revert once proper HTT header will define for
  4701. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4702. * */
  4703. #if defined(WDI_EVENT_ENABLE)
  4704. /**
  4705. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  4706. * @pdev: DP PDEV handle
  4707. * @stats_type_upload_mask: stats type requested by user
  4708. * @mac_id: Mac id number
  4709. *
  4710. * return: QDF STATUS
  4711. */
  4712. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4713. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4714. {
  4715. struct htt_soc *soc = pdev->soc->htt_handle;
  4716. struct dp_htt_htc_pkt *pkt;
  4717. qdf_nbuf_t msg;
  4718. uint32_t *msg_word;
  4719. uint8_t pdev_mask;
  4720. QDF_STATUS status;
  4721. msg = qdf_nbuf_alloc(
  4722. soc->osdev,
  4723. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4724. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4725. if (!msg) {
  4726. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  4727. , pdev->soc);
  4728. qdf_assert(0);
  4729. return QDF_STATUS_E_NOMEM;
  4730. }
  4731. /*TODO:Add support for SOC stats
  4732. * Bit 0: SOC Stats
  4733. * Bit 1: Pdev stats for pdev id 0
  4734. * Bit 2: Pdev stats for pdev id 1
  4735. * Bit 3: Pdev stats for pdev id 2
  4736. */
  4737. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4738. mac_id);
  4739. /*
  4740. * Set the length of the message.
  4741. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4742. * separately during the below call to qdf_nbuf_push_head.
  4743. * The contribution from the HTC header is added separately inside HTC.
  4744. */
  4745. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4746. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  4747. , pdev->soc);
  4748. qdf_nbuf_free(msg);
  4749. return QDF_STATUS_E_FAILURE;
  4750. }
  4751. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4752. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4753. *msg_word = 0;
  4754. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4755. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4756. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4757. stats_type_upload_mask);
  4758. pkt = htt_htc_pkt_alloc(soc);
  4759. if (!pkt) {
  4760. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  4761. qdf_assert(0);
  4762. qdf_nbuf_free(msg);
  4763. return QDF_STATUS_E_NOMEM;
  4764. }
  4765. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4766. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4767. dp_htt_h2t_send_complete_free_netbuf,
  4768. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4769. soc->htc_endpoint,
  4770. /* tag for no FW response msg */
  4771. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4772. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4773. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4774. (uint8_t *)msg_word);
  4775. if (status != QDF_STATUS_SUCCESS) {
  4776. qdf_nbuf_free(msg);
  4777. htt_htc_pkt_free(soc, pkt);
  4778. }
  4779. return status;
  4780. }
  4781. #endif
  4782. void
  4783. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4784. uint32_t *tag_buf)
  4785. {
  4786. struct dp_peer *peer = NULL;
  4787. switch (tag_type) {
  4788. case HTT_STATS_PEER_DETAILS_TAG:
  4789. {
  4790. htt_peer_details_tlv *dp_stats_buf =
  4791. (htt_peer_details_tlv *)tag_buf;
  4792. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4793. }
  4794. break;
  4795. case HTT_STATS_PEER_STATS_CMN_TAG:
  4796. {
  4797. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4798. (htt_peer_stats_cmn_tlv *)tag_buf;
  4799. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4800. DP_MOD_ID_HTT);
  4801. if (peer && !peer->bss_peer) {
  4802. peer->stats.tx.inactive_time =
  4803. dp_stats_buf->inactive_time;
  4804. qdf_event_set(&pdev->fw_peer_stats_event);
  4805. }
  4806. if (peer)
  4807. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4808. }
  4809. break;
  4810. default:
  4811. qdf_err("Invalid tag_type");
  4812. }
  4813. }
  4814. /**
  4815. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  4816. * @pdev: DP pdev handle
  4817. * @fse_setup_info: FST setup parameters
  4818. *
  4819. * Return: Success when HTT message is sent, error on failure
  4820. */
  4821. QDF_STATUS
  4822. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4823. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4824. {
  4825. struct htt_soc *soc = pdev->soc->htt_handle;
  4826. struct dp_htt_htc_pkt *pkt;
  4827. qdf_nbuf_t msg;
  4828. u_int32_t *msg_word;
  4829. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4830. uint8_t *htt_logger_bufp;
  4831. u_int32_t *key;
  4832. QDF_STATUS status;
  4833. msg = qdf_nbuf_alloc(
  4834. soc->osdev,
  4835. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4836. /* reserve room for the HTC header */
  4837. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4838. if (!msg)
  4839. return QDF_STATUS_E_NOMEM;
  4840. /*
  4841. * Set the length of the message.
  4842. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4843. * separately during the below call to qdf_nbuf_push_head.
  4844. * The contribution from the HTC header is added separately inside HTC.
  4845. */
  4846. if (!qdf_nbuf_put_tail(msg,
  4847. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4848. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4849. return QDF_STATUS_E_FAILURE;
  4850. }
  4851. /* fill in the message contents */
  4852. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4853. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4854. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4855. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4856. htt_logger_bufp = (uint8_t *)msg_word;
  4857. *msg_word = 0;
  4858. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4859. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4860. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4861. msg_word++;
  4862. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4863. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4864. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4865. fse_setup_info->ip_da_sa_prefix);
  4866. msg_word++;
  4867. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4868. fse_setup_info->base_addr_lo);
  4869. msg_word++;
  4870. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4871. fse_setup_info->base_addr_hi);
  4872. key = (u_int32_t *)fse_setup_info->hash_key;
  4873. fse_setup->toeplitz31_0 = *key++;
  4874. fse_setup->toeplitz63_32 = *key++;
  4875. fse_setup->toeplitz95_64 = *key++;
  4876. fse_setup->toeplitz127_96 = *key++;
  4877. fse_setup->toeplitz159_128 = *key++;
  4878. fse_setup->toeplitz191_160 = *key++;
  4879. fse_setup->toeplitz223_192 = *key++;
  4880. fse_setup->toeplitz255_224 = *key++;
  4881. fse_setup->toeplitz287_256 = *key++;
  4882. fse_setup->toeplitz314_288 = *key;
  4883. msg_word++;
  4884. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4885. msg_word++;
  4886. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4887. msg_word++;
  4888. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4889. msg_word++;
  4890. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4891. msg_word++;
  4892. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4893. msg_word++;
  4894. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4895. msg_word++;
  4896. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4897. msg_word++;
  4898. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4899. msg_word++;
  4900. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4901. msg_word++;
  4902. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4903. fse_setup->toeplitz314_288);
  4904. pkt = htt_htc_pkt_alloc(soc);
  4905. if (!pkt) {
  4906. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4907. qdf_assert(0);
  4908. qdf_nbuf_free(msg);
  4909. return QDF_STATUS_E_RESOURCES; /* failure */
  4910. }
  4911. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4912. SET_HTC_PACKET_INFO_TX(
  4913. &pkt->htc_pkt,
  4914. dp_htt_h2t_send_complete_free_netbuf,
  4915. qdf_nbuf_data(msg),
  4916. qdf_nbuf_len(msg),
  4917. soc->htc_endpoint,
  4918. /* tag for no FW response msg */
  4919. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4920. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4921. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4922. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4923. htt_logger_bufp);
  4924. if (status == QDF_STATUS_SUCCESS) {
  4925. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4926. fse_setup_info->pdev_id);
  4927. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4928. (void *)fse_setup_info->hash_key,
  4929. fse_setup_info->hash_key_len);
  4930. } else {
  4931. qdf_nbuf_free(msg);
  4932. htt_htc_pkt_free(soc, pkt);
  4933. }
  4934. return status;
  4935. }
  4936. /**
  4937. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  4938. * add/del a flow in HW
  4939. * @pdev: DP pdev handle
  4940. * @fse_op_info: Flow entry parameters
  4941. *
  4942. * Return: Success when HTT message is sent, error on failure
  4943. */
  4944. QDF_STATUS
  4945. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4946. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4947. {
  4948. struct htt_soc *soc = pdev->soc->htt_handle;
  4949. struct dp_htt_htc_pkt *pkt;
  4950. qdf_nbuf_t msg;
  4951. u_int32_t *msg_word;
  4952. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4953. uint8_t *htt_logger_bufp;
  4954. QDF_STATUS status;
  4955. msg = qdf_nbuf_alloc(
  4956. soc->osdev,
  4957. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4958. /* reserve room for the HTC header */
  4959. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4960. if (!msg)
  4961. return QDF_STATUS_E_NOMEM;
  4962. /*
  4963. * Set the length of the message.
  4964. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4965. * separately during the below call to qdf_nbuf_push_head.
  4966. * The contribution from the HTC header is added separately inside HTC.
  4967. */
  4968. if (!qdf_nbuf_put_tail(msg,
  4969. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4970. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4971. qdf_nbuf_free(msg);
  4972. return QDF_STATUS_E_FAILURE;
  4973. }
  4974. /* fill in the message contents */
  4975. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4976. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4977. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4978. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4979. htt_logger_bufp = (uint8_t *)msg_word;
  4980. *msg_word = 0;
  4981. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4982. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4983. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4984. msg_word++;
  4985. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4986. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4987. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4988. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4989. msg_word++;
  4990. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4991. *msg_word,
  4992. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4993. msg_word++;
  4994. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4995. *msg_word,
  4996. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4997. msg_word++;
  4998. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4999. *msg_word,
  5000. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  5001. msg_word++;
  5002. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  5003. *msg_word,
  5004. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  5005. msg_word++;
  5006. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  5007. *msg_word,
  5008. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  5009. msg_word++;
  5010. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  5011. *msg_word,
  5012. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  5013. msg_word++;
  5014. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  5015. *msg_word,
  5016. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  5017. msg_word++;
  5018. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  5019. *msg_word,
  5020. qdf_htonl(
  5021. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  5022. msg_word++;
  5023. HTT_RX_FSE_SOURCEPORT_SET(
  5024. *msg_word,
  5025. fse_op_info->rx_flow->flow_tuple_info.src_port);
  5026. HTT_RX_FSE_DESTPORT_SET(
  5027. *msg_word,
  5028. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  5029. msg_word++;
  5030. HTT_RX_FSE_L4_PROTO_SET(
  5031. *msg_word,
  5032. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  5033. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  5034. HTT_RX_FSE_OPERATION_SET(*msg_word,
  5035. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  5036. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  5037. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  5038. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  5039. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  5040. }
  5041. pkt = htt_htc_pkt_alloc(soc);
  5042. if (!pkt) {
  5043. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  5044. qdf_assert(0);
  5045. qdf_nbuf_free(msg);
  5046. return QDF_STATUS_E_RESOURCES; /* failure */
  5047. }
  5048. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  5049. SET_HTC_PACKET_INFO_TX(
  5050. &pkt->htc_pkt,
  5051. dp_htt_h2t_send_complete_free_netbuf,
  5052. qdf_nbuf_data(msg),
  5053. qdf_nbuf_len(msg),
  5054. soc->htc_endpoint,
  5055. /* tag for no FW response msg */
  5056. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  5057. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  5058. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  5059. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  5060. htt_logger_bufp);
  5061. if (status == QDF_STATUS_SUCCESS) {
  5062. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  5063. fse_op_info->pdev_id);
  5064. } else {
  5065. qdf_nbuf_free(msg);
  5066. htt_htc_pkt_free(soc, pkt);
  5067. }
  5068. return status;
  5069. }
  5070. /**
  5071. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  5072. * @pdev: DP pdev handle
  5073. * @fse_op_info: Flow entry parameters
  5074. *
  5075. * Return: Success when HTT message is sent, error on failure
  5076. */
  5077. QDF_STATUS
  5078. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  5079. struct dp_htt_rx_fisa_cfg *fisa_config)
  5080. {
  5081. struct htt_soc *soc = pdev->soc->htt_handle;
  5082. struct dp_htt_htc_pkt *pkt;
  5083. qdf_nbuf_t msg;
  5084. u_int32_t *msg_word;
  5085. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  5086. uint8_t *htt_logger_bufp;
  5087. uint32_t len;
  5088. QDF_STATUS status;
  5089. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5090. msg = qdf_nbuf_alloc(soc->osdev,
  5091. len,
  5092. /* reserve room for the HTC header */
  5093. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  5094. 4,
  5095. TRUE);
  5096. if (!msg)
  5097. return QDF_STATUS_E_NOMEM;
  5098. /*
  5099. * Set the length of the message.
  5100. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  5101. * separately during the below call to qdf_nbuf_push_head.
  5102. * The contribution from the HTC header is added separately inside HTC.
  5103. */
  5104. if (!qdf_nbuf_put_tail(msg,
  5105. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  5106. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  5107. qdf_nbuf_free(msg);
  5108. return QDF_STATUS_E_FAILURE;
  5109. }
  5110. /* fill in the message contents */
  5111. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  5112. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5113. /* rewind beyond alignment pad to get to the HTC header reserved area */
  5114. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  5115. htt_logger_bufp = (uint8_t *)msg_word;
  5116. *msg_word = 0;
  5117. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  5118. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  5119. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  5120. msg_word++;
  5121. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  5122. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  5123. msg_word++;
  5124. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  5125. pkt = htt_htc_pkt_alloc(soc);
  5126. if (!pkt) {
  5127. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  5128. qdf_assert(0);
  5129. qdf_nbuf_free(msg);
  5130. return QDF_STATUS_E_RESOURCES; /* failure */
  5131. }
  5132. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  5133. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  5134. dp_htt_h2t_send_complete_free_netbuf,
  5135. qdf_nbuf_data(msg),
  5136. qdf_nbuf_len(msg),
  5137. soc->htc_endpoint,
  5138. /* tag for no FW response msg */
  5139. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  5140. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  5141. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  5142. htt_logger_bufp);
  5143. if (status == QDF_STATUS_SUCCESS) {
  5144. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  5145. fisa_config->pdev_id);
  5146. } else {
  5147. qdf_nbuf_free(msg);
  5148. htt_htc_pkt_free(soc, pkt);
  5149. }
  5150. return status;
  5151. }