dp_htt.c 166 KB

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