dp_htt.c 165 KB

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