dp_tx.c 158 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "htt.h"
  20. #include "dp_htt.h"
  21. #include "hal_hw_headers.h"
  22. #include "dp_tx.h"
  23. #include "dp_tx_desc.h"
  24. #include "dp_peer.h"
  25. #include "dp_types.h"
  26. #include "hal_tx.h"
  27. #include "qdf_mem.h"
  28. #include "qdf_nbuf.h"
  29. #include "qdf_net_types.h"
  30. #include "qdf_module.h"
  31. #include <wlan_cfg.h>
  32. #include "dp_ipa.h"
  33. #if defined(MESH_MODE_SUPPORT) || defined(FEATURE_PERPKT_INFO)
  34. #include "if_meta_hdr.h"
  35. #endif
  36. #include "enet.h"
  37. #include "dp_internal.h"
  38. #ifdef ATH_SUPPORT_IQUE
  39. #include "dp_txrx_me.h"
  40. #endif
  41. #include "dp_hist.h"
  42. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  43. #include <dp_swlm.h>
  44. #endif
  45. #ifdef WIFI_MONITOR_SUPPORT
  46. #include <dp_mon.h>
  47. #endif
  48. #ifdef FEATURE_WDS
  49. #include "dp_txrx_wds.h"
  50. #endif
  51. #include "cdp_txrx_cmn_reg.h"
  52. #ifdef CONFIG_SAWF
  53. #include <dp_sawf.h>
  54. #endif
  55. /* Flag to skip CCE classify when mesh or tid override enabled */
  56. #define DP_TX_SKIP_CCE_CLASSIFY \
  57. (DP_TXRX_HLOS_TID_OVERRIDE_ENABLED | DP_TX_MESH_ENABLED)
  58. /* TODO Add support in TSO */
  59. #define DP_DESC_NUM_FRAG(x) 0
  60. /* disable TQM_BYPASS */
  61. #define TQM_BYPASS_WAR 0
  62. /* invalid peer id for reinject*/
  63. #define DP_INVALID_PEER 0XFFFE
  64. #define DP_RETRY_COUNT 7
  65. #ifdef QCA_DP_TX_FW_METADATA_V2
  66. #define DP_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)\
  67. HTT_TX_TCL_METADATA_V2_PDEV_ID_SET(_var, _val)
  68. #define DP_TX_TCL_METADATA_VALID_HTT_SET(_var, _val) \
  69. HTT_TX_TCL_METADATA_V2_VALID_HTT_SET(_var, _val)
  70. #define DP_TX_TCL_METADATA_TYPE_SET(_var, _val) \
  71. HTT_TX_TCL_METADATA_TYPE_V2_SET(_var, _val)
  72. #define DP_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val) \
  73. HTT_TX_TCL_METADATA_V2_HOST_INSPECTED_SET(_var, _val)
  74. #define DP_TX_TCL_METADATA_PEER_ID_SET(_var, _val) \
  75. HTT_TX_TCL_METADATA_V2_PEER_ID_SET(_var, _val)
  76. #define DP_TX_TCL_METADATA_VDEV_ID_SET(_var, _val) \
  77. HTT_TX_TCL_METADATA_V2_VDEV_ID_SET(_var, _val)
  78. #define DP_TCL_METADATA_TYPE_PEER_BASED \
  79. HTT_TCL_METADATA_V2_TYPE_PEER_BASED
  80. #define DP_TCL_METADATA_TYPE_VDEV_BASED \
  81. HTT_TCL_METADATA_V2_TYPE_VDEV_BASED
  82. #else
  83. #define DP_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)\
  84. HTT_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)
  85. #define DP_TX_TCL_METADATA_VALID_HTT_SET(_var, _val) \
  86. HTT_TX_TCL_METADATA_VALID_HTT_SET(_var, _val)
  87. #define DP_TX_TCL_METADATA_TYPE_SET(_var, _val) \
  88. HTT_TX_TCL_METADATA_TYPE_SET(_var, _val)
  89. #define DP_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val) \
  90. HTT_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val)
  91. #define DP_TX_TCL_METADATA_PEER_ID_SET(_var, _val) \
  92. HTT_TX_TCL_METADATA_PEER_ID_SET(_var, _val)
  93. #define DP_TX_TCL_METADATA_VDEV_ID_SET(_var, _val) \
  94. HTT_TX_TCL_METADATA_VDEV_ID_SET(_var, _val)
  95. #define DP_TCL_METADATA_TYPE_PEER_BASED \
  96. HTT_TCL_METADATA_TYPE_PEER_BASED
  97. #define DP_TCL_METADATA_TYPE_VDEV_BASED \
  98. HTT_TCL_METADATA_TYPE_VDEV_BASED
  99. #endif
  100. /*mapping between hal encrypt type and cdp_sec_type*/
  101. uint8_t sec_type_map[MAX_CDP_SEC_TYPE] = {HAL_TX_ENCRYPT_TYPE_NO_CIPHER,
  102. HAL_TX_ENCRYPT_TYPE_WEP_128,
  103. HAL_TX_ENCRYPT_TYPE_WEP_104,
  104. HAL_TX_ENCRYPT_TYPE_WEP_40,
  105. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC,
  106. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC,
  107. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128,
  108. HAL_TX_ENCRYPT_TYPE_WAPI,
  109. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256,
  110. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128,
  111. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256,
  112. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4};
  113. qdf_export_symbol(sec_type_map);
  114. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  115. /**
  116. * dp_update_tx_desc_stats - Update the increase or decrease in
  117. * outstanding tx desc count
  118. * values on pdev and soc
  119. * @vdev: DP pdev handle
  120. *
  121. * Return: void
  122. */
  123. static inline void
  124. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  125. {
  126. int32_t tx_descs_cnt =
  127. qdf_atomic_read(&pdev->num_tx_outstanding);
  128. if (pdev->tx_descs_max < tx_descs_cnt)
  129. pdev->tx_descs_max = tx_descs_cnt;
  130. qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
  131. pdev->tx_descs_max);
  132. }
  133. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  134. static inline void
  135. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  136. {
  137. }
  138. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  139. #ifdef QCA_TX_LIMIT_CHECK
  140. /**
  141. * dp_tx_limit_check - Check if allocated tx descriptors reached
  142. * soc max limit and pdev max limit
  143. * @vdev: DP vdev handle
  144. *
  145. * Return: true if allocated tx descriptors reached max configured value, else
  146. * false
  147. */
  148. static inline bool
  149. dp_tx_limit_check(struct dp_vdev *vdev)
  150. {
  151. struct dp_pdev *pdev = vdev->pdev;
  152. struct dp_soc *soc = pdev->soc;
  153. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  154. soc->num_tx_allowed) {
  155. dp_tx_info("queued packets are more than max tx, drop the frame");
  156. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  157. return true;
  158. }
  159. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  160. pdev->num_tx_allowed) {
  161. dp_tx_info("queued packets are more than max tx, drop the frame");
  162. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  163. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_outstand.num, 1);
  164. return true;
  165. }
  166. return false;
  167. }
  168. /**
  169. * dp_tx_exception_limit_check - Check if allocated tx exception descriptors
  170. * reached soc max limit
  171. * @vdev: DP vdev handle
  172. *
  173. * Return: true if allocated tx descriptors reached max configured value, else
  174. * false
  175. */
  176. static inline bool
  177. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  178. {
  179. struct dp_pdev *pdev = vdev->pdev;
  180. struct dp_soc *soc = pdev->soc;
  181. if (qdf_atomic_read(&soc->num_tx_exception) >=
  182. soc->num_msdu_exception_desc) {
  183. dp_info("exc packets are more than max drop the exc pkt");
  184. DP_STATS_INC(vdev, tx_i.dropped.exc_desc_na.num, 1);
  185. return true;
  186. }
  187. return false;
  188. }
  189. /**
  190. * dp_tx_outstanding_inc - Increment outstanding tx desc values on pdev and soc
  191. * @vdev: DP pdev handle
  192. *
  193. * Return: void
  194. */
  195. static inline void
  196. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  197. {
  198. struct dp_soc *soc = pdev->soc;
  199. qdf_atomic_inc(&pdev->num_tx_outstanding);
  200. qdf_atomic_inc(&soc->num_tx_outstanding);
  201. dp_update_tx_desc_stats(pdev);
  202. }
  203. /**
  204. * dp_tx_outstanding__dec - Decrement outstanding tx desc values on pdev and soc
  205. * @vdev: DP pdev handle
  206. *
  207. * Return: void
  208. */
  209. static inline void
  210. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  211. {
  212. struct dp_soc *soc = pdev->soc;
  213. qdf_atomic_dec(&pdev->num_tx_outstanding);
  214. qdf_atomic_dec(&soc->num_tx_outstanding);
  215. dp_update_tx_desc_stats(pdev);
  216. }
  217. #else //QCA_TX_LIMIT_CHECK
  218. static inline bool
  219. dp_tx_limit_check(struct dp_vdev *vdev)
  220. {
  221. return false;
  222. }
  223. static inline bool
  224. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  225. {
  226. return false;
  227. }
  228. static inline void
  229. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  230. {
  231. qdf_atomic_inc(&pdev->num_tx_outstanding);
  232. dp_update_tx_desc_stats(pdev);
  233. }
  234. static inline void
  235. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  236. {
  237. qdf_atomic_dec(&pdev->num_tx_outstanding);
  238. dp_update_tx_desc_stats(pdev);
  239. }
  240. #endif //QCA_TX_LIMIT_CHECK
  241. #ifdef WLAN_FEATURE_DP_TX_DESC_HISTORY
  242. static inline enum dp_tx_event_type dp_tx_get_event_type(uint32_t flags)
  243. {
  244. enum dp_tx_event_type type;
  245. if (flags & DP_TX_DESC_FLAG_FLUSH)
  246. type = DP_TX_DESC_FLUSH;
  247. else if (flags & DP_TX_DESC_FLAG_TX_COMP_ERR)
  248. type = DP_TX_COMP_UNMAP_ERR;
  249. else if (flags & DP_TX_DESC_FLAG_COMPLETED_TX)
  250. type = DP_TX_COMP_UNMAP;
  251. else
  252. type = DP_TX_DESC_UNMAP;
  253. return type;
  254. }
  255. static inline void
  256. dp_tx_desc_history_add(struct dp_soc *soc, dma_addr_t paddr,
  257. qdf_nbuf_t skb, uint32_t sw_cookie,
  258. enum dp_tx_event_type type)
  259. {
  260. struct dp_tx_desc_event *entry;
  261. uint32_t idx;
  262. if (qdf_unlikely(!soc->tx_tcl_history || !soc->tx_comp_history))
  263. return;
  264. switch (type) {
  265. case DP_TX_COMP_UNMAP:
  266. case DP_TX_COMP_UNMAP_ERR:
  267. case DP_TX_COMP_MSDU_EXT:
  268. idx = dp_history_get_next_index(&soc->tx_comp_history->index,
  269. DP_TX_COMP_HISTORY_SIZE);
  270. entry = &soc->tx_comp_history->entry[idx];
  271. break;
  272. case DP_TX_DESC_MAP:
  273. case DP_TX_DESC_UNMAP:
  274. case DP_TX_DESC_COOKIE:
  275. case DP_TX_DESC_FLUSH:
  276. idx = dp_history_get_next_index(&soc->tx_tcl_history->index,
  277. DP_TX_TCL_HISTORY_SIZE);
  278. entry = &soc->tx_tcl_history->entry[idx];
  279. break;
  280. default:
  281. dp_info_rl("Invalid dp_tx_event_type: %d", type);
  282. return;
  283. }
  284. entry->skb = skb;
  285. entry->paddr = paddr;
  286. entry->sw_cookie = sw_cookie;
  287. entry->type = type;
  288. entry->ts = qdf_get_log_timestamp();
  289. }
  290. static inline void
  291. dp_tx_tso_seg_history_add(struct dp_soc *soc,
  292. struct qdf_tso_seg_elem_t *tso_seg,
  293. qdf_nbuf_t skb, uint32_t sw_cookie,
  294. enum dp_tx_event_type type)
  295. {
  296. int i;
  297. for (i = 1; i < tso_seg->seg.num_frags; i++) {
  298. dp_tx_desc_history_add(soc, tso_seg->seg.tso_frags[i].paddr,
  299. skb, sw_cookie, type);
  300. }
  301. if (!tso_seg->next)
  302. dp_tx_desc_history_add(soc, tso_seg->seg.tso_frags[0].paddr,
  303. skb, 0xFFFFFFFF, type);
  304. }
  305. static inline void
  306. dp_tx_tso_history_add(struct dp_soc *soc, struct qdf_tso_info_t tso_info,
  307. qdf_nbuf_t skb, uint32_t sw_cookie,
  308. enum dp_tx_event_type type)
  309. {
  310. struct qdf_tso_seg_elem_t *curr_seg = tso_info.tso_seg_list;
  311. uint32_t num_segs = tso_info.num_segs;
  312. while (num_segs) {
  313. dp_tx_tso_seg_history_add(soc, curr_seg, skb, sw_cookie, type);
  314. curr_seg = curr_seg->next;
  315. num_segs--;
  316. }
  317. }
  318. #else
  319. static inline enum dp_tx_event_type dp_tx_get_event_type(uint32_t flags)
  320. {
  321. return DP_TX_DESC_INVAL_EVT;
  322. }
  323. static inline void
  324. dp_tx_desc_history_add(struct dp_soc *soc, dma_addr_t paddr,
  325. qdf_nbuf_t skb, uint32_t sw_cookie,
  326. enum dp_tx_event_type type)
  327. {
  328. }
  329. static inline void
  330. dp_tx_tso_seg_history_add(struct dp_soc *soc,
  331. struct qdf_tso_seg_elem_t *tso_seg,
  332. qdf_nbuf_t skb, uint32_t sw_cookie,
  333. enum dp_tx_event_type type)
  334. {
  335. }
  336. static inline void
  337. dp_tx_tso_history_add(struct dp_soc *soc, struct qdf_tso_info_t tso_info,
  338. qdf_nbuf_t skb, uint32_t sw_cookie,
  339. enum dp_tx_event_type type)
  340. {
  341. }
  342. #endif /* WLAN_FEATURE_DP_TX_DESC_HISTORY */
  343. static int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc);
  344. /**
  345. * dp_is_tput_high() - Check if throughput is high
  346. *
  347. * @soc - core txrx main context
  348. *
  349. * The current function is based of the RTPM tput policy variable where RTPM is
  350. * avoided based on throughput.
  351. */
  352. static inline int dp_is_tput_high(struct dp_soc *soc)
  353. {
  354. return dp_get_rtpm_tput_policy_requirement(soc);
  355. }
  356. #if defined(FEATURE_TSO)
  357. /**
  358. * dp_tx_tso_unmap_segment() - Unmap TSO segment
  359. *
  360. * @soc - core txrx main context
  361. * @seg_desc - tso segment descriptor
  362. * @num_seg_desc - tso number segment descriptor
  363. */
  364. static void dp_tx_tso_unmap_segment(
  365. struct dp_soc *soc,
  366. struct qdf_tso_seg_elem_t *seg_desc,
  367. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  368. {
  369. TSO_DEBUG("%s: Unmap the tso segment", __func__);
  370. if (qdf_unlikely(!seg_desc)) {
  371. DP_TRACE(ERROR, "%s %d TSO desc is NULL!",
  372. __func__, __LINE__);
  373. qdf_assert(0);
  374. } else if (qdf_unlikely(!num_seg_desc)) {
  375. DP_TRACE(ERROR, "%s %d TSO num desc is NULL!",
  376. __func__, __LINE__);
  377. qdf_assert(0);
  378. } else {
  379. bool is_last_seg;
  380. /* no tso segment left to do dma unmap */
  381. if (num_seg_desc->num_seg.tso_cmn_num_seg < 1)
  382. return;
  383. is_last_seg = (num_seg_desc->num_seg.tso_cmn_num_seg == 1) ?
  384. true : false;
  385. qdf_nbuf_unmap_tso_segment(soc->osdev,
  386. seg_desc, is_last_seg);
  387. num_seg_desc->num_seg.tso_cmn_num_seg--;
  388. }
  389. }
  390. /**
  391. * dp_tx_tso_desc_release() - Release the tso segment and tso_cmn_num_seg
  392. * back to the freelist
  393. *
  394. * @soc - soc device handle
  395. * @tx_desc - Tx software descriptor
  396. */
  397. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  398. struct dp_tx_desc_s *tx_desc)
  399. {
  400. TSO_DEBUG("%s: Free the tso descriptor", __func__);
  401. if (qdf_unlikely(!tx_desc->msdu_ext_desc->tso_desc)) {
  402. dp_tx_err("SO desc is NULL!");
  403. qdf_assert(0);
  404. } else if (qdf_unlikely(!tx_desc->msdu_ext_desc->tso_num_desc)) {
  405. dp_tx_err("TSO num desc is NULL!");
  406. qdf_assert(0);
  407. } else {
  408. struct qdf_tso_num_seg_elem_t *tso_num_desc =
  409. (struct qdf_tso_num_seg_elem_t *)tx_desc->
  410. msdu_ext_desc->tso_num_desc;
  411. /* Add the tso num segment into the free list */
  412. if (tso_num_desc->num_seg.tso_cmn_num_seg == 0) {
  413. dp_tso_num_seg_free(soc, tx_desc->pool_id,
  414. tx_desc->msdu_ext_desc->
  415. tso_num_desc);
  416. tx_desc->msdu_ext_desc->tso_num_desc = NULL;
  417. DP_STATS_INC(tx_desc->pdev, tso_stats.tso_comp, 1);
  418. }
  419. /* Add the tso segment into the free list*/
  420. dp_tx_tso_desc_free(soc,
  421. tx_desc->pool_id, tx_desc->msdu_ext_desc->
  422. tso_desc);
  423. tx_desc->msdu_ext_desc->tso_desc = NULL;
  424. }
  425. }
  426. #else
  427. static void dp_tx_tso_unmap_segment(
  428. struct dp_soc *soc,
  429. struct qdf_tso_seg_elem_t *seg_desc,
  430. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  431. {
  432. }
  433. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  434. struct dp_tx_desc_s *tx_desc)
  435. {
  436. }
  437. #endif
  438. /**
  439. * dp_tx_desc_release() - Release Tx Descriptor
  440. * @tx_desc : Tx Descriptor
  441. * @desc_pool_id: Descriptor Pool ID
  442. *
  443. * Deallocate all resources attached to Tx descriptor and free the Tx
  444. * descriptor.
  445. *
  446. * Return:
  447. */
  448. void
  449. dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id)
  450. {
  451. struct dp_pdev *pdev = tx_desc->pdev;
  452. struct dp_soc *soc;
  453. uint8_t comp_status = 0;
  454. qdf_assert(pdev);
  455. soc = pdev->soc;
  456. dp_tx_outstanding_dec(pdev);
  457. if (tx_desc->msdu_ext_desc) {
  458. if (tx_desc->frm_type == dp_tx_frm_tso)
  459. dp_tx_tso_desc_release(soc, tx_desc);
  460. if (tx_desc->flags & DP_TX_DESC_FLAG_ME)
  461. dp_tx_me_free_buf(tx_desc->pdev,
  462. tx_desc->msdu_ext_desc->me_buffer);
  463. dp_tx_ext_desc_free(soc, tx_desc->msdu_ext_desc, desc_pool_id);
  464. }
  465. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)
  466. qdf_atomic_dec(&soc->num_tx_exception);
  467. if (HAL_TX_COMP_RELEASE_SOURCE_TQM ==
  468. tx_desc->buffer_src)
  469. comp_status = hal_tx_comp_get_release_reason(&tx_desc->comp,
  470. soc->hal_soc);
  471. else
  472. comp_status = HAL_TX_COMP_RELEASE_REASON_FW;
  473. dp_tx_debug("Tx Completion Release desc %d status %d outstanding %d",
  474. tx_desc->id, comp_status,
  475. qdf_atomic_read(&pdev->num_tx_outstanding));
  476. dp_tx_desc_free(soc, tx_desc, desc_pool_id);
  477. return;
  478. }
  479. /**
  480. * dp_tx_htt_metadata_prepare() - Prepare HTT metadata for special frames
  481. * @vdev: DP vdev Handle
  482. * @nbuf: skb
  483. * @msdu_info: msdu_info required to create HTT metadata
  484. *
  485. * Prepares and fills HTT metadata in the frame pre-header for special frames
  486. * that should be transmitted using varying transmit parameters.
  487. * There are 2 VDEV modes that currently needs this special metadata -
  488. * 1) Mesh Mode
  489. * 2) DSRC Mode
  490. *
  491. * Return: HTT metadata size
  492. *
  493. */
  494. static uint8_t dp_tx_prepare_htt_metadata(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  495. struct dp_tx_msdu_info_s *msdu_info)
  496. {
  497. uint32_t *meta_data = msdu_info->meta_data;
  498. struct htt_tx_msdu_desc_ext2_t *desc_ext =
  499. (struct htt_tx_msdu_desc_ext2_t *) meta_data;
  500. uint8_t htt_desc_size;
  501. /* Size rounded of multiple of 8 bytes */
  502. uint8_t htt_desc_size_aligned;
  503. uint8_t *hdr = NULL;
  504. /*
  505. * Metadata - HTT MSDU Extension header
  506. */
  507. htt_desc_size = sizeof(struct htt_tx_msdu_desc_ext2_t);
  508. htt_desc_size_aligned = (htt_desc_size + 7) & ~0x7;
  509. if (vdev->mesh_vdev || msdu_info->is_tx_sniffer ||
  510. HTT_TX_MSDU_EXT2_DESC_FLAG_VALID_KEY_FLAGS_GET(msdu_info->
  511. meta_data[0])) {
  512. if (qdf_unlikely(qdf_nbuf_headroom(nbuf) <
  513. htt_desc_size_aligned)) {
  514. nbuf = qdf_nbuf_realloc_headroom(nbuf,
  515. htt_desc_size_aligned);
  516. if (!nbuf) {
  517. /*
  518. * qdf_nbuf_realloc_headroom won't do skb_clone
  519. * as skb_realloc_headroom does. so, no free is
  520. * needed here.
  521. */
  522. DP_STATS_INC(vdev,
  523. tx_i.dropped.headroom_insufficient,
  524. 1);
  525. qdf_print(" %s[%d] skb_realloc_headroom failed",
  526. __func__, __LINE__);
  527. return 0;
  528. }
  529. }
  530. /* Fill and add HTT metaheader */
  531. hdr = qdf_nbuf_push_head(nbuf, htt_desc_size_aligned);
  532. if (!hdr) {
  533. dp_tx_err("Error in filling HTT metadata");
  534. return 0;
  535. }
  536. qdf_mem_copy(hdr, desc_ext, htt_desc_size);
  537. } else if (vdev->opmode == wlan_op_mode_ocb) {
  538. /* Todo - Add support for DSRC */
  539. }
  540. return htt_desc_size_aligned;
  541. }
  542. /**
  543. * dp_tx_prepare_tso_ext_desc() - Prepare MSDU extension descriptor for TSO
  544. * @tso_seg: TSO segment to process
  545. * @ext_desc: Pointer to MSDU extension descriptor
  546. *
  547. * Return: void
  548. */
  549. #if defined(FEATURE_TSO)
  550. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  551. void *ext_desc)
  552. {
  553. uint8_t num_frag;
  554. uint32_t tso_flags;
  555. /*
  556. * Set tso_en, tcp_flags(NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN),
  557. * tcp_flag_mask
  558. *
  559. * Checksum enable flags are set in TCL descriptor and not in Extension
  560. * Descriptor (H/W ignores checksum_en flags in MSDU ext descriptor)
  561. */
  562. tso_flags = *(uint32_t *) &tso_seg->tso_flags;
  563. hal_tx_ext_desc_set_tso_flags(ext_desc, tso_flags);
  564. hal_tx_ext_desc_set_msdu_length(ext_desc, tso_seg->tso_flags.l2_len,
  565. tso_seg->tso_flags.ip_len);
  566. hal_tx_ext_desc_set_tcp_seq(ext_desc, tso_seg->tso_flags.tcp_seq_num);
  567. hal_tx_ext_desc_set_ip_id(ext_desc, tso_seg->tso_flags.ip_id);
  568. for (num_frag = 0; num_frag < tso_seg->num_frags; num_frag++) {
  569. uint32_t lo = 0;
  570. uint32_t hi = 0;
  571. qdf_assert_always((tso_seg->tso_frags[num_frag].paddr) &&
  572. (tso_seg->tso_frags[num_frag].length));
  573. qdf_dmaaddr_to_32s(
  574. tso_seg->tso_frags[num_frag].paddr, &lo, &hi);
  575. hal_tx_ext_desc_set_buffer(ext_desc, num_frag, lo, hi,
  576. tso_seg->tso_frags[num_frag].length);
  577. }
  578. return;
  579. }
  580. #else
  581. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  582. void *ext_desc)
  583. {
  584. return;
  585. }
  586. #endif
  587. #if defined(FEATURE_TSO)
  588. /**
  589. * dp_tx_free_tso_seg_list() - Loop through the tso segments
  590. * allocated and free them
  591. *
  592. * @soc: soc handle
  593. * @free_seg: list of tso segments
  594. * @msdu_info: msdu descriptor
  595. *
  596. * Return - void
  597. */
  598. static void dp_tx_free_tso_seg_list(
  599. struct dp_soc *soc,
  600. struct qdf_tso_seg_elem_t *free_seg,
  601. struct dp_tx_msdu_info_s *msdu_info)
  602. {
  603. struct qdf_tso_seg_elem_t *next_seg;
  604. while (free_seg) {
  605. next_seg = free_seg->next;
  606. dp_tx_tso_desc_free(soc,
  607. msdu_info->tx_queue.desc_pool_id,
  608. free_seg);
  609. free_seg = next_seg;
  610. }
  611. }
  612. /**
  613. * dp_tx_free_tso_num_seg_list() - Loop through the tso num segments
  614. * allocated and free them
  615. *
  616. * @soc: soc handle
  617. * @free_num_seg: list of tso number segments
  618. * @msdu_info: msdu descriptor
  619. * Return - void
  620. */
  621. static void dp_tx_free_tso_num_seg_list(
  622. struct dp_soc *soc,
  623. struct qdf_tso_num_seg_elem_t *free_num_seg,
  624. struct dp_tx_msdu_info_s *msdu_info)
  625. {
  626. struct qdf_tso_num_seg_elem_t *next_num_seg;
  627. while (free_num_seg) {
  628. next_num_seg = free_num_seg->next;
  629. dp_tso_num_seg_free(soc,
  630. msdu_info->tx_queue.desc_pool_id,
  631. free_num_seg);
  632. free_num_seg = next_num_seg;
  633. }
  634. }
  635. /**
  636. * dp_tx_unmap_tso_seg_list() - Loop through the tso segments
  637. * do dma unmap for each segment
  638. *
  639. * @soc: soc handle
  640. * @free_seg: list of tso segments
  641. * @num_seg_desc: tso number segment descriptor
  642. *
  643. * Return - void
  644. */
  645. static void dp_tx_unmap_tso_seg_list(
  646. struct dp_soc *soc,
  647. struct qdf_tso_seg_elem_t *free_seg,
  648. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  649. {
  650. struct qdf_tso_seg_elem_t *next_seg;
  651. if (qdf_unlikely(!num_seg_desc)) {
  652. DP_TRACE(ERROR, "TSO number seg desc is NULL!");
  653. return;
  654. }
  655. while (free_seg) {
  656. next_seg = free_seg->next;
  657. dp_tx_tso_unmap_segment(soc, free_seg, num_seg_desc);
  658. free_seg = next_seg;
  659. }
  660. }
  661. #ifdef FEATURE_TSO_STATS
  662. /**
  663. * dp_tso_get_stats_idx: Retrieve the tso packet id
  664. * @pdev - pdev handle
  665. *
  666. * Return: id
  667. */
  668. static uint32_t dp_tso_get_stats_idx(struct dp_pdev *pdev)
  669. {
  670. uint32_t stats_idx;
  671. stats_idx = (((uint32_t)qdf_atomic_inc_return(&pdev->tso_idx))
  672. % CDP_MAX_TSO_PACKETS);
  673. return stats_idx;
  674. }
  675. #else
  676. static int dp_tso_get_stats_idx(struct dp_pdev *pdev)
  677. {
  678. return 0;
  679. }
  680. #endif /* FEATURE_TSO_STATS */
  681. /**
  682. * dp_tx_free_remaining_tso_desc() - do dma unmap for tso segments if any,
  683. * free the tso segments descriptor and
  684. * tso num segments descriptor
  685. *
  686. * @soc: soc handle
  687. * @msdu_info: msdu descriptor
  688. * @tso_seg_unmap: flag to show if dma unmap is necessary
  689. *
  690. * Return - void
  691. */
  692. static void dp_tx_free_remaining_tso_desc(struct dp_soc *soc,
  693. struct dp_tx_msdu_info_s *msdu_info,
  694. bool tso_seg_unmap)
  695. {
  696. struct qdf_tso_info_t *tso_info = &msdu_info->u.tso_info;
  697. struct qdf_tso_seg_elem_t *free_seg = tso_info->tso_seg_list;
  698. struct qdf_tso_num_seg_elem_t *tso_num_desc =
  699. tso_info->tso_num_seg_list;
  700. /* do dma unmap for each segment */
  701. if (tso_seg_unmap)
  702. dp_tx_unmap_tso_seg_list(soc, free_seg, tso_num_desc);
  703. /* free all tso number segment descriptor though looks only have 1 */
  704. dp_tx_free_tso_num_seg_list(soc, tso_num_desc, msdu_info);
  705. /* free all tso segment descriptor */
  706. dp_tx_free_tso_seg_list(soc, free_seg, msdu_info);
  707. }
  708. /**
  709. * dp_tx_prepare_tso() - Given a jumbo msdu, prepare the TSO info
  710. * @vdev: virtual device handle
  711. * @msdu: network buffer
  712. * @msdu_info: meta data associated with the msdu
  713. *
  714. * Return: QDF_STATUS_SUCCESS success
  715. */
  716. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  717. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  718. {
  719. struct qdf_tso_seg_elem_t *tso_seg;
  720. int num_seg = qdf_nbuf_get_tso_num_seg(msdu);
  721. struct dp_soc *soc = vdev->pdev->soc;
  722. struct dp_pdev *pdev = vdev->pdev;
  723. struct qdf_tso_info_t *tso_info;
  724. struct qdf_tso_num_seg_elem_t *tso_num_seg;
  725. tso_info = &msdu_info->u.tso_info;
  726. tso_info->curr_seg = NULL;
  727. tso_info->tso_seg_list = NULL;
  728. tso_info->num_segs = num_seg;
  729. msdu_info->frm_type = dp_tx_frm_tso;
  730. tso_info->tso_num_seg_list = NULL;
  731. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  732. while (num_seg) {
  733. tso_seg = dp_tx_tso_desc_alloc(
  734. soc, msdu_info->tx_queue.desc_pool_id);
  735. if (tso_seg) {
  736. tso_seg->next = tso_info->tso_seg_list;
  737. tso_info->tso_seg_list = tso_seg;
  738. num_seg--;
  739. } else {
  740. dp_err_rl("Failed to alloc tso seg desc");
  741. DP_STATS_INC_PKT(vdev->pdev,
  742. tso_stats.tso_no_mem_dropped, 1,
  743. qdf_nbuf_len(msdu));
  744. dp_tx_free_remaining_tso_desc(soc, msdu_info, false);
  745. return QDF_STATUS_E_NOMEM;
  746. }
  747. }
  748. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  749. tso_num_seg = dp_tso_num_seg_alloc(soc,
  750. msdu_info->tx_queue.desc_pool_id);
  751. if (tso_num_seg) {
  752. tso_num_seg->next = tso_info->tso_num_seg_list;
  753. tso_info->tso_num_seg_list = tso_num_seg;
  754. } else {
  755. DP_TRACE(ERROR, "%s: Failed to alloc - Number of segs desc",
  756. __func__);
  757. dp_tx_free_remaining_tso_desc(soc, msdu_info, false);
  758. return QDF_STATUS_E_NOMEM;
  759. }
  760. msdu_info->num_seg =
  761. qdf_nbuf_get_tso_info(soc->osdev, msdu, tso_info);
  762. TSO_DEBUG(" %s: msdu_info->num_seg: %d", __func__,
  763. msdu_info->num_seg);
  764. if (!(msdu_info->num_seg)) {
  765. /*
  766. * Free allocated TSO seg desc and number seg desc,
  767. * do unmap for segments if dma map has done.
  768. */
  769. DP_TRACE(ERROR, "%s: Failed to get tso info", __func__);
  770. dp_tx_free_remaining_tso_desc(soc, msdu_info, true);
  771. return QDF_STATUS_E_INVAL;
  772. }
  773. dp_tx_tso_history_add(soc, msdu_info->u.tso_info,
  774. msdu, 0, DP_TX_DESC_MAP);
  775. tso_info->curr_seg = tso_info->tso_seg_list;
  776. tso_info->msdu_stats_idx = dp_tso_get_stats_idx(pdev);
  777. dp_tso_packet_update(pdev, tso_info->msdu_stats_idx,
  778. msdu, msdu_info->num_seg);
  779. dp_tso_segment_stats_update(pdev, tso_info->tso_seg_list,
  780. tso_info->msdu_stats_idx);
  781. dp_stats_tso_segment_histogram_update(pdev, msdu_info->num_seg);
  782. return QDF_STATUS_SUCCESS;
  783. }
  784. #else
  785. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  786. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  787. {
  788. return QDF_STATUS_E_NOMEM;
  789. }
  790. #endif
  791. QDF_COMPILE_TIME_ASSERT(dp_tx_htt_metadata_len_check,
  792. (DP_TX_MSDU_INFO_META_DATA_DWORDS * 4 >=
  793. sizeof(struct htt_tx_msdu_desc_ext2_t)));
  794. /**
  795. * dp_tx_prepare_ext_desc() - Allocate and prepare MSDU extension descriptor
  796. * @vdev: DP Vdev handle
  797. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  798. * @desc_pool_id: Descriptor Pool ID
  799. *
  800. * Return:
  801. */
  802. static
  803. struct dp_tx_ext_desc_elem_s *dp_tx_prepare_ext_desc(struct dp_vdev *vdev,
  804. struct dp_tx_msdu_info_s *msdu_info, uint8_t desc_pool_id)
  805. {
  806. uint8_t i;
  807. uint8_t cached_ext_desc[HAL_TX_EXT_DESC_WITH_META_DATA];
  808. struct dp_tx_seg_info_s *seg_info;
  809. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  810. struct dp_soc *soc = vdev->pdev->soc;
  811. /* Allocate an extension descriptor */
  812. msdu_ext_desc = dp_tx_ext_desc_alloc(soc, desc_pool_id);
  813. qdf_mem_zero(&cached_ext_desc[0], HAL_TX_EXT_DESC_WITH_META_DATA);
  814. if (!msdu_ext_desc) {
  815. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  816. return NULL;
  817. }
  818. if (msdu_info->exception_fw &&
  819. qdf_unlikely(vdev->mesh_vdev)) {
  820. qdf_mem_copy(&cached_ext_desc[HAL_TX_EXTENSION_DESC_LEN_BYTES],
  821. &msdu_info->meta_data[0],
  822. sizeof(struct htt_tx_msdu_desc_ext2_t));
  823. qdf_atomic_inc(&soc->num_tx_exception);
  824. msdu_ext_desc->flags |= DP_TX_EXT_DESC_FLAG_METADATA_VALID;
  825. }
  826. switch (msdu_info->frm_type) {
  827. case dp_tx_frm_sg:
  828. case dp_tx_frm_me:
  829. case dp_tx_frm_raw:
  830. seg_info = msdu_info->u.sg_info.curr_seg;
  831. /* Update the buffer pointers in MSDU Extension Descriptor */
  832. for (i = 0; i < seg_info->frag_cnt; i++) {
  833. hal_tx_ext_desc_set_buffer(&cached_ext_desc[0], i,
  834. seg_info->frags[i].paddr_lo,
  835. seg_info->frags[i].paddr_hi,
  836. seg_info->frags[i].len);
  837. }
  838. break;
  839. case dp_tx_frm_tso:
  840. dp_tx_prepare_tso_ext_desc(&msdu_info->u.tso_info.curr_seg->seg,
  841. &cached_ext_desc[0]);
  842. break;
  843. default:
  844. break;
  845. }
  846. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  847. cached_ext_desc, HAL_TX_EXT_DESC_WITH_META_DATA);
  848. hal_tx_ext_desc_sync(&cached_ext_desc[0],
  849. msdu_ext_desc->vaddr);
  850. return msdu_ext_desc;
  851. }
  852. /**
  853. * dp_tx_trace_pkt() - Trace TX packet at DP layer
  854. *
  855. * @skb: skb to be traced
  856. * @msdu_id: msdu_id of the packet
  857. * @vdev_id: vdev_id of the packet
  858. *
  859. * Return: None
  860. */
  861. #ifdef DP_DISABLE_TX_PKT_TRACE
  862. static void dp_tx_trace_pkt(struct dp_soc *soc,
  863. qdf_nbuf_t skb, uint16_t msdu_id,
  864. uint8_t vdev_id)
  865. {
  866. }
  867. #else
  868. static void dp_tx_trace_pkt(struct dp_soc *soc,
  869. qdf_nbuf_t skb, uint16_t msdu_id,
  870. uint8_t vdev_id)
  871. {
  872. if (dp_is_tput_high(soc))
  873. return;
  874. QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
  875. QDF_NBUF_CB_TX_DP_TRACE(skb) = 1;
  876. DPTRACE(qdf_dp_trace_ptr(skb,
  877. QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
  878. QDF_TRACE_DEFAULT_PDEV_ID,
  879. qdf_nbuf_data_addr(skb),
  880. sizeof(qdf_nbuf_data(skb)),
  881. msdu_id, vdev_id, 0));
  882. qdf_dp_trace_log_pkt(vdev_id, skb, QDF_TX, QDF_TRACE_DEFAULT_PDEV_ID);
  883. DPTRACE(qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
  884. QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
  885. msdu_id, QDF_TX));
  886. }
  887. #endif
  888. #ifdef WLAN_DP_FEATURE_MARK_ICMP_REQ_TO_FW
  889. /**
  890. * dp_tx_is_nbuf_marked_exception() - Check if the packet has been marked as
  891. * exception by the upper layer (OS_IF)
  892. * @soc: DP soc handle
  893. * @nbuf: packet to be transmitted
  894. *
  895. * Returns: 1 if the packet is marked as exception,
  896. * 0, if the packet is not marked as exception.
  897. */
  898. static inline int dp_tx_is_nbuf_marked_exception(struct dp_soc *soc,
  899. qdf_nbuf_t nbuf)
  900. {
  901. return QDF_NBUF_CB_TX_PACKET_TO_FW(nbuf);
  902. }
  903. #else
  904. static inline int dp_tx_is_nbuf_marked_exception(struct dp_soc *soc,
  905. qdf_nbuf_t nbuf)
  906. {
  907. return 0;
  908. }
  909. #endif
  910. /**
  911. * dp_tx_desc_prepare_single - Allocate and prepare Tx descriptor
  912. * @vdev: DP vdev handle
  913. * @nbuf: skb
  914. * @desc_pool_id: Descriptor pool ID
  915. * @meta_data: Metadata to the fw
  916. * @tx_exc_metadata: Handle that holds exception path metadata
  917. * Allocate and prepare Tx descriptor with msdu information.
  918. *
  919. * Return: Pointer to Tx Descriptor on success,
  920. * NULL on failure
  921. */
  922. static
  923. struct dp_tx_desc_s *dp_tx_prepare_desc_single(struct dp_vdev *vdev,
  924. qdf_nbuf_t nbuf, uint8_t desc_pool_id,
  925. struct dp_tx_msdu_info_s *msdu_info,
  926. struct cdp_tx_exception_metadata *tx_exc_metadata)
  927. {
  928. uint8_t align_pad;
  929. uint8_t is_exception = 0;
  930. uint8_t htt_hdr_size;
  931. struct dp_tx_desc_s *tx_desc;
  932. struct dp_pdev *pdev = vdev->pdev;
  933. struct dp_soc *soc = pdev->soc;
  934. if (dp_tx_limit_check(vdev))
  935. return NULL;
  936. /* Allocate software Tx descriptor */
  937. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  938. if (qdf_unlikely(!tx_desc)) {
  939. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  940. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_alloc_fail.num, 1);
  941. return NULL;
  942. }
  943. dp_tx_outstanding_inc(pdev);
  944. /* Initialize the SW tx descriptor */
  945. tx_desc->nbuf = nbuf;
  946. tx_desc->frm_type = dp_tx_frm_std;
  947. tx_desc->tx_encap_type = ((tx_exc_metadata &&
  948. (tx_exc_metadata->tx_encap_type != CDP_INVALID_TX_ENCAP_TYPE)) ?
  949. tx_exc_metadata->tx_encap_type : vdev->tx_encap_type);
  950. tx_desc->vdev_id = vdev->vdev_id;
  951. tx_desc->pdev = pdev;
  952. tx_desc->msdu_ext_desc = NULL;
  953. tx_desc->pkt_offset = 0;
  954. tx_desc->length = qdf_nbuf_headlen(nbuf);
  955. dp_tx_trace_pkt(soc, nbuf, tx_desc->id, vdev->vdev_id);
  956. if (qdf_unlikely(vdev->multipass_en)) {
  957. if (!dp_tx_multipass_process(soc, vdev, nbuf, msdu_info))
  958. goto failure;
  959. }
  960. /* Packets marked by upper layer (OS-IF) to be sent to FW */
  961. if (dp_tx_is_nbuf_marked_exception(soc, nbuf))
  962. is_exception = 1;
  963. /*
  964. * For special modes (vdev_type == ocb or mesh), data frames should be
  965. * transmitted using varying transmit parameters (tx spec) which include
  966. * transmit rate, power, priority, channel, channel bandwidth , nss etc.
  967. * These are filled in HTT MSDU descriptor and sent in frame pre-header.
  968. * These frames are sent as exception packets to firmware.
  969. *
  970. * HW requirement is that metadata should always point to a
  971. * 8-byte aligned address. So we add alignment pad to start of buffer.
  972. * HTT Metadata should be ensured to be multiple of 8-bytes,
  973. * to get 8-byte aligned start address along with align_pad added
  974. *
  975. * |-----------------------------|
  976. * | |
  977. * |-----------------------------| <-----Buffer Pointer Address given
  978. * | | ^ in HW descriptor (aligned)
  979. * | HTT Metadata | |
  980. * | | |
  981. * | | | Packet Offset given in descriptor
  982. * | | |
  983. * |-----------------------------| |
  984. * | Alignment Pad | v
  985. * |-----------------------------| <----- Actual buffer start address
  986. * | SKB Data | (Unaligned)
  987. * | |
  988. * | |
  989. * | |
  990. * | |
  991. * | |
  992. * |-----------------------------|
  993. */
  994. if (qdf_unlikely((msdu_info->exception_fw)) ||
  995. (vdev->opmode == wlan_op_mode_ocb) ||
  996. (tx_exc_metadata &&
  997. tx_exc_metadata->is_tx_sniffer)) {
  998. align_pad = ((unsigned long) qdf_nbuf_data(nbuf)) & 0x7;
  999. if (qdf_unlikely(qdf_nbuf_headroom(nbuf) < align_pad)) {
  1000. DP_STATS_INC(vdev,
  1001. tx_i.dropped.headroom_insufficient, 1);
  1002. goto failure;
  1003. }
  1004. if (qdf_nbuf_push_head(nbuf, align_pad) == NULL) {
  1005. dp_tx_err("qdf_nbuf_push_head failed");
  1006. goto failure;
  1007. }
  1008. htt_hdr_size = dp_tx_prepare_htt_metadata(vdev, nbuf,
  1009. msdu_info);
  1010. if (htt_hdr_size == 0)
  1011. goto failure;
  1012. tx_desc->length = qdf_nbuf_headlen(nbuf);
  1013. tx_desc->pkt_offset = align_pad + htt_hdr_size;
  1014. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1015. is_exception = 1;
  1016. tx_desc->length -= tx_desc->pkt_offset;
  1017. }
  1018. #if !TQM_BYPASS_WAR
  1019. if (is_exception || tx_exc_metadata)
  1020. #endif
  1021. {
  1022. /* Temporary WAR due to TQM VP issues */
  1023. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1024. qdf_atomic_inc(&soc->num_tx_exception);
  1025. }
  1026. return tx_desc;
  1027. failure:
  1028. dp_tx_desc_release(tx_desc, desc_pool_id);
  1029. return NULL;
  1030. }
  1031. /**
  1032. * dp_tx_prepare_desc() - Allocate and prepare Tx descriptor for multisegment frame
  1033. * @vdev: DP vdev handle
  1034. * @nbuf: skb
  1035. * @msdu_info: Info to be setup in MSDU descriptor and MSDU extension descriptor
  1036. * @desc_pool_id : Descriptor Pool ID
  1037. *
  1038. * Allocate and prepare Tx descriptor with msdu and fragment descritor
  1039. * information. For frames wth fragments, allocate and prepare
  1040. * an MSDU extension descriptor
  1041. *
  1042. * Return: Pointer to Tx Descriptor on success,
  1043. * NULL on failure
  1044. */
  1045. static struct dp_tx_desc_s *dp_tx_prepare_desc(struct dp_vdev *vdev,
  1046. qdf_nbuf_t nbuf, struct dp_tx_msdu_info_s *msdu_info,
  1047. uint8_t desc_pool_id)
  1048. {
  1049. struct dp_tx_desc_s *tx_desc;
  1050. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  1051. struct dp_pdev *pdev = vdev->pdev;
  1052. struct dp_soc *soc = pdev->soc;
  1053. if (dp_tx_limit_check(vdev))
  1054. return NULL;
  1055. /* Allocate software Tx descriptor */
  1056. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  1057. if (!tx_desc) {
  1058. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1059. return NULL;
  1060. }
  1061. dp_tx_tso_seg_history_add(soc, msdu_info->u.tso_info.curr_seg,
  1062. nbuf, tx_desc->id, DP_TX_DESC_COOKIE);
  1063. dp_tx_outstanding_inc(pdev);
  1064. /* Initialize the SW tx descriptor */
  1065. tx_desc->nbuf = nbuf;
  1066. tx_desc->frm_type = msdu_info->frm_type;
  1067. tx_desc->tx_encap_type = vdev->tx_encap_type;
  1068. tx_desc->vdev_id = vdev->vdev_id;
  1069. tx_desc->pdev = pdev;
  1070. tx_desc->pkt_offset = 0;
  1071. dp_tx_trace_pkt(soc, nbuf, tx_desc->id, vdev->vdev_id);
  1072. /* Handle scattered frames - TSO/SG/ME */
  1073. /* Allocate and prepare an extension descriptor for scattered frames */
  1074. msdu_ext_desc = dp_tx_prepare_ext_desc(vdev, msdu_info, desc_pool_id);
  1075. if (!msdu_ext_desc) {
  1076. dp_tx_info("Tx Extension Descriptor Alloc Fail");
  1077. goto failure;
  1078. }
  1079. #if TQM_BYPASS_WAR
  1080. /* Temporary WAR due to TQM VP issues */
  1081. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1082. qdf_atomic_inc(&soc->num_tx_exception);
  1083. #endif
  1084. if (qdf_unlikely(msdu_info->exception_fw))
  1085. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1086. tx_desc->msdu_ext_desc = msdu_ext_desc;
  1087. tx_desc->flags |= DP_TX_DESC_FLAG_FRAG;
  1088. msdu_ext_desc->tso_desc = msdu_info->u.tso_info.curr_seg;
  1089. msdu_ext_desc->tso_num_desc = msdu_info->u.tso_info.tso_num_seg_list;
  1090. tx_desc->dma_addr = msdu_ext_desc->paddr;
  1091. if (msdu_ext_desc->flags & DP_TX_EXT_DESC_FLAG_METADATA_VALID)
  1092. tx_desc->length = HAL_TX_EXT_DESC_WITH_META_DATA;
  1093. else
  1094. tx_desc->length = HAL_TX_EXTENSION_DESC_LEN_BYTES;
  1095. return tx_desc;
  1096. failure:
  1097. dp_tx_desc_release(tx_desc, desc_pool_id);
  1098. return NULL;
  1099. }
  1100. /**
  1101. * dp_tx_prepare_raw() - Prepare RAW packet TX
  1102. * @vdev: DP vdev handle
  1103. * @nbuf: buffer pointer
  1104. * @seg_info: Pointer to Segment info Descriptor to be prepared
  1105. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension
  1106. * descriptor
  1107. *
  1108. * Return:
  1109. */
  1110. static qdf_nbuf_t dp_tx_prepare_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1111. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  1112. {
  1113. qdf_nbuf_t curr_nbuf = NULL;
  1114. uint16_t total_len = 0;
  1115. qdf_dma_addr_t paddr;
  1116. int32_t i;
  1117. int32_t mapped_buf_num = 0;
  1118. struct dp_tx_sg_info_s *sg_info = &msdu_info->u.sg_info;
  1119. qdf_dot3_qosframe_t *qos_wh = (qdf_dot3_qosframe_t *) nbuf->data;
  1120. DP_STATS_INC_PKT(vdev, tx_i.raw.raw_pkt, 1, qdf_nbuf_len(nbuf));
  1121. /* Continue only if frames are of DATA type */
  1122. if (!DP_FRAME_IS_DATA(qos_wh)) {
  1123. DP_STATS_INC(vdev, tx_i.raw.invalid_raw_pkt_datatype, 1);
  1124. dp_tx_debug("Pkt. recd is of not data type");
  1125. goto error;
  1126. }
  1127. /* SWAR for HW: Enable WEP bit in the AMSDU frames for RAW mode */
  1128. if (vdev->raw_mode_war &&
  1129. (qos_wh->i_fc[0] & QDF_IEEE80211_FC0_SUBTYPE_QOS) &&
  1130. (qos_wh->i_qos[0] & IEEE80211_QOS_AMSDU))
  1131. qos_wh->i_fc[1] |= IEEE80211_FC1_WEP;
  1132. for (curr_nbuf = nbuf, i = 0; curr_nbuf;
  1133. curr_nbuf = qdf_nbuf_next(curr_nbuf), i++) {
  1134. /*
  1135. * Number of nbuf's must not exceed the size of the frags
  1136. * array in seg_info.
  1137. */
  1138. if (i >= DP_TX_MAX_NUM_FRAGS) {
  1139. dp_err_rl("nbuf cnt exceeds the max number of segs");
  1140. DP_STATS_INC(vdev, tx_i.raw.num_frags_overflow_err, 1);
  1141. goto error;
  1142. }
  1143. if (QDF_STATUS_SUCCESS !=
  1144. qdf_nbuf_map_nbytes_single(vdev->osdev,
  1145. curr_nbuf,
  1146. QDF_DMA_TO_DEVICE,
  1147. curr_nbuf->len)) {
  1148. dp_tx_err("%s dma map error ", __func__);
  1149. DP_STATS_INC(vdev, tx_i.raw.dma_map_error, 1);
  1150. goto error;
  1151. }
  1152. /* Update the count of mapped nbuf's */
  1153. mapped_buf_num++;
  1154. paddr = qdf_nbuf_get_frag_paddr(curr_nbuf, 0);
  1155. seg_info->frags[i].paddr_lo = paddr;
  1156. seg_info->frags[i].paddr_hi = ((uint64_t)paddr >> 32);
  1157. seg_info->frags[i].len = qdf_nbuf_len(curr_nbuf);
  1158. seg_info->frags[i].vaddr = (void *) curr_nbuf;
  1159. total_len += qdf_nbuf_len(curr_nbuf);
  1160. }
  1161. seg_info->frag_cnt = i;
  1162. seg_info->total_len = total_len;
  1163. seg_info->next = NULL;
  1164. sg_info->curr_seg = seg_info;
  1165. msdu_info->frm_type = dp_tx_frm_raw;
  1166. msdu_info->num_seg = 1;
  1167. return nbuf;
  1168. error:
  1169. i = 0;
  1170. while (nbuf) {
  1171. curr_nbuf = nbuf;
  1172. if (i < mapped_buf_num) {
  1173. qdf_nbuf_unmap_nbytes_single(vdev->osdev, curr_nbuf,
  1174. QDF_DMA_TO_DEVICE,
  1175. curr_nbuf->len);
  1176. i++;
  1177. }
  1178. nbuf = qdf_nbuf_next(nbuf);
  1179. qdf_nbuf_free(curr_nbuf);
  1180. }
  1181. return NULL;
  1182. }
  1183. /**
  1184. * dp_tx_raw_prepare_unset() - unmap the chain of nbufs belonging to RAW frame.
  1185. * @soc: DP soc handle
  1186. * @nbuf: Buffer pointer
  1187. *
  1188. * unmap the chain of nbufs that belong to this RAW frame.
  1189. *
  1190. * Return: None
  1191. */
  1192. static void dp_tx_raw_prepare_unset(struct dp_soc *soc,
  1193. qdf_nbuf_t nbuf)
  1194. {
  1195. qdf_nbuf_t cur_nbuf = nbuf;
  1196. do {
  1197. qdf_nbuf_unmap_nbytes_single(soc->osdev, cur_nbuf,
  1198. QDF_DMA_TO_DEVICE,
  1199. cur_nbuf->len);
  1200. cur_nbuf = qdf_nbuf_next(cur_nbuf);
  1201. } while (cur_nbuf);
  1202. }
  1203. #ifdef VDEV_PEER_PROTOCOL_COUNT
  1204. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1205. qdf_nbuf_t nbuf)
  1206. {
  1207. qdf_nbuf_t nbuf_local;
  1208. struct dp_vdev *vdev_local = vdev_hdl;
  1209. do {
  1210. if (qdf_likely(!((vdev_local)->peer_protocol_count_track)))
  1211. break;
  1212. nbuf_local = nbuf;
  1213. if (qdf_unlikely(((vdev_local)->tx_encap_type) ==
  1214. htt_cmn_pkt_type_raw))
  1215. break;
  1216. else if (qdf_unlikely(qdf_nbuf_is_nonlinear((nbuf_local))))
  1217. break;
  1218. else if (qdf_nbuf_is_tso((nbuf_local)))
  1219. break;
  1220. dp_vdev_peer_stats_update_protocol_cnt((vdev_local),
  1221. (nbuf_local),
  1222. NULL, 1, 0);
  1223. } while (0);
  1224. }
  1225. #endif
  1226. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  1227. /**
  1228. * dp_tx_update_stats() - Update soc level tx stats
  1229. * @soc: DP soc handle
  1230. * @tx_desc: TX descriptor reference
  1231. * @ring_id: TCL ring id
  1232. *
  1233. * Returns: none
  1234. */
  1235. void dp_tx_update_stats(struct dp_soc *soc,
  1236. struct dp_tx_desc_s *tx_desc,
  1237. uint8_t ring_id)
  1238. {
  1239. uint32_t stats_len = 0;
  1240. if (tx_desc->frm_type == dp_tx_frm_tso)
  1241. stats_len = tx_desc->msdu_ext_desc->tso_desc->seg.total_len;
  1242. else
  1243. stats_len = qdf_nbuf_len(tx_desc->nbuf);
  1244. DP_STATS_INC_PKT(soc, tx.egress[ring_id], 1, stats_len);
  1245. }
  1246. int
  1247. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  1248. struct dp_tx_desc_s *tx_desc,
  1249. uint8_t tid,
  1250. struct dp_tx_msdu_info_s *msdu_info,
  1251. uint8_t ring_id)
  1252. {
  1253. struct dp_swlm *swlm = &soc->swlm;
  1254. union swlm_data swlm_query_data;
  1255. struct dp_swlm_tcl_data tcl_data;
  1256. QDF_STATUS status;
  1257. int ret;
  1258. if (!swlm->is_enabled)
  1259. return msdu_info->skip_hp_update;
  1260. tcl_data.nbuf = tx_desc->nbuf;
  1261. tcl_data.tid = tid;
  1262. tcl_data.ring_id = ring_id;
  1263. if (tx_desc->frm_type == dp_tx_frm_tso) {
  1264. tcl_data.pkt_len =
  1265. tx_desc->msdu_ext_desc->tso_desc->seg.total_len;
  1266. } else {
  1267. tcl_data.pkt_len = qdf_nbuf_len(tx_desc->nbuf);
  1268. }
  1269. tcl_data.num_ll_connections = vdev->num_latency_critical_conn;
  1270. swlm_query_data.tcl_data = &tcl_data;
  1271. status = dp_swlm_tcl_pre_check(soc, &tcl_data);
  1272. if (QDF_IS_STATUS_ERROR(status)) {
  1273. dp_swlm_tcl_reset_session_data(soc, ring_id);
  1274. DP_STATS_INC(swlm, tcl[ring_id].coalesce_fail, 1);
  1275. return 0;
  1276. }
  1277. ret = dp_swlm_query_policy(soc, TCL_DATA, swlm_query_data);
  1278. if (ret) {
  1279. DP_STATS_INC(swlm, tcl[ring_id].coalesce_success, 1);
  1280. } else {
  1281. DP_STATS_INC(swlm, tcl[ring_id].coalesce_fail, 1);
  1282. }
  1283. return ret;
  1284. }
  1285. void
  1286. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  1287. int coalesce)
  1288. {
  1289. if (coalesce)
  1290. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1291. else
  1292. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  1293. }
  1294. static inline void
  1295. dp_tx_is_hp_update_required(uint32_t i, struct dp_tx_msdu_info_s *msdu_info)
  1296. {
  1297. if (((i + 1) < msdu_info->num_seg))
  1298. msdu_info->skip_hp_update = 1;
  1299. else
  1300. msdu_info->skip_hp_update = 0;
  1301. }
  1302. static inline void
  1303. dp_flush_tcp_hp(struct dp_soc *soc, uint8_t ring_id)
  1304. {
  1305. hal_ring_handle_t hal_ring_hdl =
  1306. dp_tx_get_hal_ring_hdl(soc, ring_id);
  1307. if (dp_tx_hal_ring_access_start(soc, hal_ring_hdl)) {
  1308. dp_err("Fillmore: SRNG access start failed");
  1309. return;
  1310. }
  1311. dp_tx_ring_access_end_wrapper(soc, hal_ring_hdl, 0);
  1312. }
  1313. static inline void
  1314. dp_tx_check_and_flush_hp(struct dp_soc *soc,
  1315. QDF_STATUS status,
  1316. struct dp_tx_msdu_info_s *msdu_info)
  1317. {
  1318. if (QDF_IS_STATUS_ERROR(status) && !msdu_info->skip_hp_update) {
  1319. dp_flush_tcp_hp(soc,
  1320. (msdu_info->tx_queue.ring_id & DP_TX_QUEUE_MASK));
  1321. }
  1322. }
  1323. #else
  1324. static inline void
  1325. dp_tx_is_hp_update_required(uint32_t i, struct dp_tx_msdu_info_s *msdu_info)
  1326. {
  1327. }
  1328. static inline void
  1329. dp_tx_check_and_flush_hp(struct dp_soc *soc,
  1330. QDF_STATUS status,
  1331. struct dp_tx_msdu_info_s *msdu_info)
  1332. {
  1333. }
  1334. #endif
  1335. #ifdef FEATURE_RUNTIME_PM
  1336. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1337. {
  1338. return qdf_atomic_read(&soc->rtpm_high_tput_flag);
  1339. }
  1340. /**
  1341. * dp_tx_ring_access_end_wrapper() - Wrapper for ring access end
  1342. * @soc: Datapath soc handle
  1343. * @hal_ring_hdl: HAL ring handle
  1344. * @coalesce: Coalesce the current write or not
  1345. *
  1346. * Wrapper for HAL ring access end for data transmission for
  1347. * FEATURE_RUNTIME_PM
  1348. *
  1349. * Returns: none
  1350. */
  1351. void
  1352. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1353. hal_ring_handle_t hal_ring_hdl,
  1354. int coalesce)
  1355. {
  1356. int ret;
  1357. /*
  1358. * Avoid runtime get and put APIs under high throughput scenarios.
  1359. */
  1360. if (dp_get_rtpm_tput_policy_requirement(soc)) {
  1361. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1362. return;
  1363. }
  1364. ret = hif_rtpm_get(HIF_RTPM_GET_ASYNC, HIF_RTPM_ID_DP);
  1365. if (QDF_IS_STATUS_SUCCESS(ret)) {
  1366. if (hif_system_pm_state_check(soc->hif_handle)) {
  1367. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1368. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1369. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1370. } else {
  1371. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1372. }
  1373. hif_rtpm_put(HIF_RTPM_PUT_ASYNC, HIF_RTPM_ID_DP);
  1374. } else {
  1375. dp_runtime_get(soc);
  1376. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1377. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1378. qdf_atomic_inc(&soc->tx_pending_rtpm);
  1379. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1380. dp_runtime_put(soc);
  1381. }
  1382. }
  1383. #else
  1384. #ifdef DP_POWER_SAVE
  1385. void
  1386. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1387. hal_ring_handle_t hal_ring_hdl,
  1388. int coalesce)
  1389. {
  1390. if (hif_system_pm_state_check(soc->hif_handle)) {
  1391. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1392. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1393. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1394. } else {
  1395. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1396. }
  1397. }
  1398. #endif
  1399. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1400. {
  1401. return 0;
  1402. }
  1403. #endif
  1404. /**
  1405. * dp_tx_get_tid() - Obtain TID to be used for this frame
  1406. * @vdev: DP vdev handle
  1407. * @nbuf: skb
  1408. *
  1409. * Extract the DSCP or PCP information from frame and map into TID value.
  1410. *
  1411. * Return: void
  1412. */
  1413. static void dp_tx_get_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1414. struct dp_tx_msdu_info_s *msdu_info)
  1415. {
  1416. uint8_t tos = 0, dscp_tid_override = 0;
  1417. uint8_t *hdr_ptr, *L3datap;
  1418. uint8_t is_mcast = 0;
  1419. qdf_ether_header_t *eh = NULL;
  1420. qdf_ethervlan_header_t *evh = NULL;
  1421. uint16_t ether_type;
  1422. qdf_llc_t *llcHdr;
  1423. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  1424. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1425. if (qdf_likely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1426. eh = (qdf_ether_header_t *)nbuf->data;
  1427. hdr_ptr = (uint8_t *)(eh->ether_dhost);
  1428. L3datap = hdr_ptr + sizeof(qdf_ether_header_t);
  1429. } else {
  1430. qdf_dot3_qosframe_t *qos_wh =
  1431. (qdf_dot3_qosframe_t *) nbuf->data;
  1432. msdu_info->tid = qos_wh->i_fc[0] & DP_FC0_SUBTYPE_QOS ?
  1433. qos_wh->i_qos[0] & DP_QOS_TID : 0;
  1434. return;
  1435. }
  1436. is_mcast = DP_FRAME_IS_MULTICAST(hdr_ptr);
  1437. ether_type = eh->ether_type;
  1438. llcHdr = (qdf_llc_t *)(nbuf->data + sizeof(qdf_ether_header_t));
  1439. /*
  1440. * Check if packet is dot3 or eth2 type.
  1441. */
  1442. if (DP_FRAME_IS_LLC(ether_type) && DP_FRAME_IS_SNAP(llcHdr)) {
  1443. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE +
  1444. sizeof(*llcHdr));
  1445. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1446. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t) +
  1447. sizeof(*llcHdr);
  1448. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE
  1449. + sizeof(*llcHdr) +
  1450. sizeof(qdf_net_vlanhdr_t));
  1451. } else {
  1452. L3datap = hdr_ptr + sizeof(qdf_ether_header_t) +
  1453. sizeof(*llcHdr);
  1454. }
  1455. } else {
  1456. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1457. evh = (qdf_ethervlan_header_t *) eh;
  1458. ether_type = evh->ether_type;
  1459. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t);
  1460. }
  1461. }
  1462. /*
  1463. * Find priority from IP TOS DSCP field
  1464. */
  1465. if (qdf_nbuf_is_ipv4_pkt(nbuf)) {
  1466. qdf_net_iphdr_t *ip = (qdf_net_iphdr_t *) L3datap;
  1467. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) {
  1468. /* Only for unicast frames */
  1469. if (!is_mcast) {
  1470. /* send it on VO queue */
  1471. msdu_info->tid = DP_VO_TID;
  1472. }
  1473. } else {
  1474. /*
  1475. * IP frame: exclude ECN bits 0-1 and map DSCP bits 2-7
  1476. * from TOS byte.
  1477. */
  1478. tos = ip->ip_tos;
  1479. dscp_tid_override = 1;
  1480. }
  1481. } else if (qdf_nbuf_is_ipv6_pkt(nbuf)) {
  1482. /* TODO
  1483. * use flowlabel
  1484. *igmpmld cases to be handled in phase 2
  1485. */
  1486. unsigned long ver_pri_flowlabel;
  1487. unsigned long pri;
  1488. ver_pri_flowlabel = *(unsigned long *) L3datap;
  1489. pri = (ntohl(ver_pri_flowlabel) & IPV6_FLOWINFO_PRIORITY) >>
  1490. DP_IPV6_PRIORITY_SHIFT;
  1491. tos = pri;
  1492. dscp_tid_override = 1;
  1493. } else if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf))
  1494. msdu_info->tid = DP_VO_TID;
  1495. else if (qdf_nbuf_is_ipv4_arp_pkt(nbuf)) {
  1496. /* Only for unicast frames */
  1497. if (!is_mcast) {
  1498. /* send ucast arp on VO queue */
  1499. msdu_info->tid = DP_VO_TID;
  1500. }
  1501. }
  1502. /*
  1503. * Assign all MCAST packets to BE
  1504. */
  1505. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1506. if (is_mcast) {
  1507. tos = 0;
  1508. dscp_tid_override = 1;
  1509. }
  1510. }
  1511. if (dscp_tid_override == 1) {
  1512. tos = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
  1513. msdu_info->tid = pdev->dscp_tid_map[vdev->dscp_tid_map_id][tos];
  1514. }
  1515. if (msdu_info->tid >= CDP_MAX_DATA_TIDS)
  1516. msdu_info->tid = CDP_MAX_DATA_TIDS - 1;
  1517. return;
  1518. }
  1519. /**
  1520. * dp_tx_classify_tid() - Obtain TID to be used for this frame
  1521. * @vdev: DP vdev handle
  1522. * @nbuf: skb
  1523. *
  1524. * Software based TID classification is required when more than 2 DSCP-TID
  1525. * mapping tables are needed.
  1526. * Hardware supports 2 DSCP-TID mapping tables for HKv1 and 48 for HKv2.
  1527. *
  1528. * Return: void
  1529. */
  1530. static inline void dp_tx_classify_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1531. struct dp_tx_msdu_info_s *msdu_info)
  1532. {
  1533. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1534. /*
  1535. * skip_sw_tid_classification flag will set in below cases-
  1536. * 1. vdev->dscp_tid_map_id < pdev->soc->num_hw_dscp_tid_map
  1537. * 2. hlos_tid_override enabled for vdev
  1538. * 3. mesh mode enabled for vdev
  1539. */
  1540. if (qdf_likely(vdev->skip_sw_tid_classification)) {
  1541. /* Update tid in msdu_info from skb priority */
  1542. if (qdf_unlikely(vdev->skip_sw_tid_classification
  1543. & DP_TXRX_HLOS_TID_OVERRIDE_ENABLED)) {
  1544. uint32_t tid = qdf_nbuf_get_priority(nbuf);
  1545. if (tid == DP_TX_INVALID_QOS_TAG)
  1546. return;
  1547. msdu_info->tid = tid;
  1548. return;
  1549. }
  1550. return;
  1551. }
  1552. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1553. }
  1554. #ifdef FEATURE_WLAN_TDLS
  1555. /**
  1556. * dp_tx_update_tdls_flags() - Update descriptor flags for TDLS frame
  1557. * @soc: datapath SOC
  1558. * @vdev: datapath vdev
  1559. * @tx_desc: TX descriptor
  1560. *
  1561. * Return: None
  1562. */
  1563. static void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1564. struct dp_vdev *vdev,
  1565. struct dp_tx_desc_s *tx_desc)
  1566. {
  1567. if (vdev) {
  1568. if (vdev->is_tdls_frame) {
  1569. tx_desc->flags |= DP_TX_DESC_FLAG_TDLS_FRAME;
  1570. vdev->is_tdls_frame = false;
  1571. }
  1572. }
  1573. }
  1574. static uint8_t dp_htt_tx_comp_get_status(struct dp_soc *soc, char *htt_desc)
  1575. {
  1576. uint8_t tx_status = HTT_TX_FW2WBM_TX_STATUS_MAX;
  1577. switch (soc->arch_id) {
  1578. case CDP_ARCH_TYPE_LI:
  1579. tx_status = HTT_TX_WBM_COMPLETION_V2_TX_STATUS_GET(htt_desc[0]);
  1580. break;
  1581. case CDP_ARCH_TYPE_BE:
  1582. tx_status = HTT_TX_WBM_COMPLETION_V3_TX_STATUS_GET(htt_desc[0]);
  1583. break;
  1584. default:
  1585. dp_err("Incorrect CDP_ARCH %d", soc->arch_id);
  1586. QDF_BUG(0);
  1587. }
  1588. return tx_status;
  1589. }
  1590. /**
  1591. * dp_non_std_htt_tx_comp_free_buff() - Free the non std tx packet buffer
  1592. * @soc: dp_soc handle
  1593. * @tx_desc: TX descriptor
  1594. * @vdev: datapath vdev handle
  1595. *
  1596. * Return: None
  1597. */
  1598. static void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1599. struct dp_tx_desc_s *tx_desc)
  1600. {
  1601. uint8_t tx_status = 0;
  1602. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  1603. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1604. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1605. DP_MOD_ID_TDLS);
  1606. if (qdf_unlikely(!vdev)) {
  1607. dp_err_rl("vdev is null!");
  1608. goto error;
  1609. }
  1610. hal_tx_comp_get_htt_desc(&tx_desc->comp, htt_tx_status);
  1611. tx_status = dp_htt_tx_comp_get_status(soc, htt_tx_status);
  1612. dp_debug("vdev_id: %d tx_status: %d", tx_desc->vdev_id, tx_status);
  1613. if (vdev->tx_non_std_data_callback.func) {
  1614. qdf_nbuf_set_next(nbuf, NULL);
  1615. vdev->tx_non_std_data_callback.func(
  1616. vdev->tx_non_std_data_callback.ctxt,
  1617. nbuf, tx_status);
  1618. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1619. return;
  1620. } else {
  1621. dp_err_rl("callback func is null");
  1622. }
  1623. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1624. error:
  1625. qdf_nbuf_unmap_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  1626. qdf_nbuf_free(nbuf);
  1627. }
  1628. /**
  1629. * dp_tx_msdu_single_map() - do nbuf map
  1630. * @vdev: DP vdev handle
  1631. * @tx_desc: DP TX descriptor pointer
  1632. * @nbuf: skb pointer
  1633. *
  1634. * For TDLS frame, use qdf_nbuf_map_single() to align with the unmap
  1635. * operation done in other component.
  1636. *
  1637. * Return: QDF_STATUS
  1638. */
  1639. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1640. struct dp_tx_desc_s *tx_desc,
  1641. qdf_nbuf_t nbuf)
  1642. {
  1643. if (qdf_likely(!(tx_desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)))
  1644. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1645. nbuf,
  1646. QDF_DMA_TO_DEVICE,
  1647. nbuf->len);
  1648. else
  1649. return qdf_nbuf_map_single(vdev->osdev, nbuf,
  1650. QDF_DMA_TO_DEVICE);
  1651. }
  1652. #else
  1653. static inline void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1654. struct dp_vdev *vdev,
  1655. struct dp_tx_desc_s *tx_desc)
  1656. {
  1657. }
  1658. static inline void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1659. struct dp_tx_desc_s *tx_desc)
  1660. {
  1661. }
  1662. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1663. struct dp_tx_desc_s *tx_desc,
  1664. qdf_nbuf_t nbuf)
  1665. {
  1666. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1667. nbuf,
  1668. QDF_DMA_TO_DEVICE,
  1669. nbuf->len);
  1670. }
  1671. #endif
  1672. static inline
  1673. qdf_dma_addr_t dp_tx_nbuf_map_regular(struct dp_vdev *vdev,
  1674. struct dp_tx_desc_s *tx_desc,
  1675. qdf_nbuf_t nbuf)
  1676. {
  1677. QDF_STATUS ret = QDF_STATUS_E_FAILURE;
  1678. ret = dp_tx_msdu_single_map(vdev, tx_desc, nbuf);
  1679. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret)))
  1680. return 0;
  1681. return qdf_nbuf_mapped_paddr_get(nbuf);
  1682. }
  1683. static inline
  1684. void dp_tx_nbuf_unmap_regular(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1685. {
  1686. qdf_nbuf_unmap_nbytes_single_paddr(soc->osdev,
  1687. desc->nbuf,
  1688. desc->dma_addr,
  1689. QDF_DMA_TO_DEVICE,
  1690. desc->length);
  1691. }
  1692. #if defined(QCA_DP_TX_NBUF_NO_MAP_UNMAP) && !defined(BUILD_X86)
  1693. static inline
  1694. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1695. struct dp_tx_desc_s *tx_desc,
  1696. qdf_nbuf_t nbuf)
  1697. {
  1698. if (qdf_likely(tx_desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  1699. qdf_nbuf_dma_clean_range((void *)nbuf->data,
  1700. (void *)(nbuf->data + nbuf->len));
  1701. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  1702. } else {
  1703. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1704. }
  1705. }
  1706. static inline
  1707. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1708. struct dp_tx_desc_s *desc)
  1709. {
  1710. if (qdf_unlikely(!(desc->flags & DP_TX_DESC_FLAG_SIMPLE)))
  1711. return dp_tx_nbuf_unmap_regular(soc, desc);
  1712. }
  1713. #else
  1714. static inline
  1715. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1716. struct dp_tx_desc_s *tx_desc,
  1717. qdf_nbuf_t nbuf)
  1718. {
  1719. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1720. }
  1721. static inline
  1722. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1723. struct dp_tx_desc_s *desc)
  1724. {
  1725. return dp_tx_nbuf_unmap_regular(soc, desc);
  1726. }
  1727. #endif
  1728. #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(FEATURE_PERPKT_INFO)
  1729. static inline
  1730. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1731. {
  1732. dp_tx_nbuf_unmap(soc, desc);
  1733. desc->flags |= DP_TX_DESC_FLAG_UNMAP_DONE;
  1734. }
  1735. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1736. {
  1737. if (qdf_likely(!(desc->flags & DP_TX_DESC_FLAG_UNMAP_DONE)))
  1738. dp_tx_nbuf_unmap(soc, desc);
  1739. }
  1740. #else
  1741. static inline
  1742. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1743. {
  1744. }
  1745. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1746. {
  1747. dp_tx_nbuf_unmap(soc, desc);
  1748. }
  1749. #endif
  1750. #ifdef MESH_MODE_SUPPORT
  1751. /**
  1752. * dp_tx_update_mesh_flags() - Update descriptor flags for mesh VAP
  1753. * @soc: datapath SOC
  1754. * @vdev: datapath vdev
  1755. * @tx_desc: TX descriptor
  1756. *
  1757. * Return: None
  1758. */
  1759. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1760. struct dp_vdev *vdev,
  1761. struct dp_tx_desc_s *tx_desc)
  1762. {
  1763. if (qdf_unlikely(vdev->mesh_vdev))
  1764. tx_desc->flags |= DP_TX_DESC_FLAG_MESH_MODE;
  1765. }
  1766. /**
  1767. * dp_mesh_tx_comp_free_buff() - Free the mesh tx packet buffer
  1768. * @soc: dp_soc handle
  1769. * @tx_desc: TX descriptor
  1770. * @vdev: datapath vdev handle
  1771. *
  1772. * Return: None
  1773. */
  1774. static inline void dp_mesh_tx_comp_free_buff(struct dp_soc *soc,
  1775. struct dp_tx_desc_s *tx_desc)
  1776. {
  1777. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1778. struct dp_vdev *vdev = NULL;
  1779. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW) {
  1780. qdf_nbuf_free(nbuf);
  1781. DP_STATS_INC(vdev, tx_i.mesh.completion_fw, 1);
  1782. } else {
  1783. vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1784. DP_MOD_ID_MESH);
  1785. if (vdev && vdev->osif_tx_free_ext)
  1786. vdev->osif_tx_free_ext((nbuf));
  1787. else
  1788. qdf_nbuf_free(nbuf);
  1789. if (vdev)
  1790. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  1791. }
  1792. }
  1793. #else
  1794. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1795. struct dp_vdev *vdev,
  1796. struct dp_tx_desc_s *tx_desc)
  1797. {
  1798. }
  1799. static inline void dp_mesh_tx_comp_free_buff(struct dp_soc *soc,
  1800. struct dp_tx_desc_s *tx_desc)
  1801. {
  1802. }
  1803. #endif
  1804. /**
  1805. * dp_tx_frame_is_drop() - checks if the packet is loopback
  1806. * @vdev: DP vdev handle
  1807. * @nbuf: skb
  1808. *
  1809. * Return: 1 if frame needs to be dropped else 0
  1810. */
  1811. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac)
  1812. {
  1813. struct dp_pdev *pdev = NULL;
  1814. struct dp_ast_entry *src_ast_entry = NULL;
  1815. struct dp_ast_entry *dst_ast_entry = NULL;
  1816. struct dp_soc *soc = NULL;
  1817. qdf_assert(vdev);
  1818. pdev = vdev->pdev;
  1819. qdf_assert(pdev);
  1820. soc = pdev->soc;
  1821. dst_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1822. (soc, dstmac, vdev->pdev->pdev_id);
  1823. src_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1824. (soc, srcmac, vdev->pdev->pdev_id);
  1825. if (dst_ast_entry && src_ast_entry) {
  1826. if (dst_ast_entry->peer_id ==
  1827. src_ast_entry->peer_id)
  1828. return 1;
  1829. }
  1830. return 0;
  1831. }
  1832. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) && \
  1833. defined(WLAN_MCAST_MLO)
  1834. /* MLO peer id for reinject*/
  1835. #define DP_MLO_MCAST_REINJECT_PEER_ID 0XFFFD
  1836. /* MLO vdev id inc offset */
  1837. #define DP_MLO_VDEV_ID_OFFSET 0x80
  1838. static inline void
  1839. dp_tx_bypass_reinjection(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  1840. {
  1841. if (!(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)) {
  1842. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1843. qdf_atomic_inc(&soc->num_tx_exception);
  1844. }
  1845. }
  1846. static inline void
  1847. dp_tx_update_mcast_param(uint16_t peer_id,
  1848. uint16_t *htt_tcl_metadata,
  1849. struct dp_vdev *vdev,
  1850. struct dp_tx_msdu_info_s *msdu_info)
  1851. {
  1852. if (peer_id == DP_MLO_MCAST_REINJECT_PEER_ID) {
  1853. *htt_tcl_metadata = 0;
  1854. DP_TX_TCL_METADATA_TYPE_SET(
  1855. *htt_tcl_metadata,
  1856. HTT_TCL_METADATA_V2_TYPE_GLOBAL_SEQ_BASED);
  1857. HTT_TX_TCL_METADATA_GLBL_SEQ_NO_SET(*htt_tcl_metadata,
  1858. msdu_info->gsn);
  1859. msdu_info->vdev_id = vdev->vdev_id + DP_MLO_VDEV_ID_OFFSET;
  1860. if (qdf_unlikely(vdev->nawds_enabled))
  1861. HTT_TX_TCL_METADATA_GLBL_SEQ_HOST_INSPECTED_SET(
  1862. *htt_tcl_metadata, 1);
  1863. } else {
  1864. msdu_info->vdev_id = vdev->vdev_id;
  1865. }
  1866. }
  1867. #else
  1868. static inline void
  1869. dp_tx_bypass_reinjection(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  1870. {
  1871. }
  1872. static inline void
  1873. dp_tx_update_mcast_param(uint16_t peer_id,
  1874. uint16_t *htt_tcl_metadata,
  1875. struct dp_vdev *vdev,
  1876. struct dp_tx_msdu_info_s *msdu_info)
  1877. {
  1878. }
  1879. #endif
  1880. /**
  1881. * dp_tx_send_msdu_single() - Setup descriptor and enqueue single MSDU to TCL
  1882. * @vdev: DP vdev handle
  1883. * @nbuf: skb
  1884. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  1885. * @meta_data: Metadata to the fw
  1886. * @tx_q: Tx queue to be used for this Tx frame
  1887. * @peer_id: peer_id of the peer in case of NAWDS frames
  1888. * @tx_exc_metadata: Handle that holds exception path metadata
  1889. *
  1890. * Return: NULL on success,
  1891. * nbuf when it fails to send
  1892. */
  1893. qdf_nbuf_t
  1894. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1895. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  1896. struct cdp_tx_exception_metadata *tx_exc_metadata)
  1897. {
  1898. struct dp_pdev *pdev = vdev->pdev;
  1899. struct dp_soc *soc = pdev->soc;
  1900. struct dp_tx_desc_s *tx_desc;
  1901. QDF_STATUS status;
  1902. struct dp_tx_queue *tx_q = &(msdu_info->tx_queue);
  1903. uint16_t htt_tcl_metadata = 0;
  1904. enum cdp_tx_sw_drop drop_code = TX_MAX_DROP;
  1905. uint8_t tid = msdu_info->tid;
  1906. struct cdp_tid_tx_stats *tid_stats = NULL;
  1907. qdf_dma_addr_t paddr;
  1908. /* Setup Tx descriptor for an MSDU, and MSDU extension descriptor */
  1909. tx_desc = dp_tx_prepare_desc_single(vdev, nbuf, tx_q->desc_pool_id,
  1910. msdu_info, tx_exc_metadata);
  1911. if (!tx_desc) {
  1912. dp_err_rl("Tx_desc prepare Fail vdev %pK queue %d",
  1913. vdev, tx_q->desc_pool_id);
  1914. drop_code = TX_DESC_ERR;
  1915. goto fail_return;
  1916. }
  1917. dp_tx_update_tdls_flags(soc, vdev, tx_desc);
  1918. if (qdf_unlikely(peer_id == DP_INVALID_PEER)) {
  1919. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1920. DP_TX_TCL_METADATA_HOST_INSPECTED_SET(htt_tcl_metadata, 1);
  1921. } else if (qdf_unlikely(peer_id != HTT_INVALID_PEER)) {
  1922. DP_TX_TCL_METADATA_TYPE_SET(htt_tcl_metadata,
  1923. DP_TCL_METADATA_TYPE_PEER_BASED);
  1924. DP_TX_TCL_METADATA_PEER_ID_SET(htt_tcl_metadata,
  1925. peer_id);
  1926. dp_tx_bypass_reinjection(soc, tx_desc);
  1927. } else
  1928. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1929. if (msdu_info->exception_fw)
  1930. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  1931. dp_tx_desc_update_fast_comp_flag(soc, tx_desc,
  1932. !pdev->enhanced_stats_en);
  1933. dp_tx_update_mesh_flags(soc, vdev, tx_desc);
  1934. paddr = dp_tx_nbuf_map(vdev, tx_desc, nbuf);
  1935. if (!paddr) {
  1936. /* Handle failure */
  1937. dp_err("qdf_nbuf_map failed");
  1938. DP_STATS_INC(vdev, tx_i.dropped.dma_error, 1);
  1939. drop_code = TX_DMA_MAP_ERR;
  1940. goto release_desc;
  1941. }
  1942. tx_desc->dma_addr = paddr;
  1943. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1944. tx_desc->id, DP_TX_DESC_MAP);
  1945. dp_tx_update_mcast_param(peer_id, &htt_tcl_metadata, vdev, msdu_info);
  1946. /* Enqueue the Tx MSDU descriptor to HW for transmit */
  1947. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  1948. htt_tcl_metadata,
  1949. tx_exc_metadata, msdu_info);
  1950. if (status != QDF_STATUS_SUCCESS) {
  1951. dp_tx_err_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  1952. tx_desc, tx_q->ring_id);
  1953. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1954. tx_desc->id, DP_TX_DESC_UNMAP);
  1955. dp_tx_nbuf_unmap(soc, tx_desc);
  1956. drop_code = TX_HW_ENQUEUE;
  1957. goto release_desc;
  1958. }
  1959. return NULL;
  1960. release_desc:
  1961. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1962. fail_return:
  1963. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1964. tid_stats = &pdev->stats.tid_stats.
  1965. tid_tx_stats[tx_q->ring_id][tid];
  1966. tid_stats->swdrop_cnt[drop_code]++;
  1967. return nbuf;
  1968. }
  1969. /**
  1970. * dp_tx_comp_free_buf() - Free nbuf associated with the Tx Descriptor
  1971. * @soc: Soc handle
  1972. * @desc: software Tx descriptor to be processed
  1973. *
  1974. * Return: none
  1975. */
  1976. void dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1977. {
  1978. qdf_nbuf_t nbuf = desc->nbuf;
  1979. enum dp_tx_event_type type = dp_tx_get_event_type(desc->flags);
  1980. /* nbuf already freed in vdev detach path */
  1981. if (!nbuf)
  1982. return;
  1983. /* If it is TDLS mgmt, don't unmap or free the frame */
  1984. if (desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)
  1985. return dp_non_std_htt_tx_comp_free_buff(soc, desc);
  1986. /* 0 : MSDU buffer, 1 : MLE */
  1987. if (desc->msdu_ext_desc) {
  1988. /* TSO free */
  1989. if (hal_tx_ext_desc_get_tso_enable(
  1990. desc->msdu_ext_desc->vaddr)) {
  1991. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  1992. desc->id, DP_TX_COMP_MSDU_EXT);
  1993. dp_tx_tso_seg_history_add(soc,
  1994. desc->msdu_ext_desc->tso_desc,
  1995. desc->nbuf, desc->id, type);
  1996. /* unmap eash TSO seg before free the nbuf */
  1997. dp_tx_tso_unmap_segment(soc,
  1998. desc->msdu_ext_desc->tso_desc,
  1999. desc->msdu_ext_desc->
  2000. tso_num_desc);
  2001. qdf_nbuf_free(nbuf);
  2002. return;
  2003. }
  2004. if (qdf_unlikely(desc->frm_type == dp_tx_frm_sg)) {
  2005. void *msdu_ext_desc = desc->msdu_ext_desc->vaddr;
  2006. qdf_dma_addr_t iova;
  2007. uint32_t frag_len;
  2008. uint32_t i;
  2009. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf,
  2010. QDF_DMA_TO_DEVICE,
  2011. qdf_nbuf_headlen(nbuf));
  2012. for (i = 1; i < DP_TX_MAX_NUM_FRAGS; i++) {
  2013. hal_tx_ext_desc_get_frag_info(msdu_ext_desc, i,
  2014. &iova,
  2015. &frag_len);
  2016. if (!iova || !frag_len)
  2017. break;
  2018. qdf_mem_unmap_page(soc->osdev, iova, frag_len,
  2019. QDF_DMA_TO_DEVICE);
  2020. }
  2021. qdf_nbuf_free(nbuf);
  2022. return;
  2023. }
  2024. }
  2025. /* If it's ME frame, dont unmap the cloned nbuf's */
  2026. if ((desc->flags & DP_TX_DESC_FLAG_ME) && qdf_nbuf_is_cloned(nbuf))
  2027. goto nbuf_free;
  2028. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf, desc->id, type);
  2029. dp_tx_unmap(soc, desc);
  2030. if (desc->flags & DP_TX_DESC_FLAG_MESH_MODE)
  2031. return dp_mesh_tx_comp_free_buff(soc, desc);
  2032. nbuf_free:
  2033. qdf_nbuf_free(nbuf);
  2034. }
  2035. /**
  2036. * dp_tx_sg_unmap_buf() - Unmap scatter gather fragments
  2037. * @soc: DP soc handle
  2038. * @nbuf: skb
  2039. * @msdu_info: MSDU info
  2040. *
  2041. * Return: None
  2042. */
  2043. static inline void
  2044. dp_tx_sg_unmap_buf(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2045. struct dp_tx_msdu_info_s *msdu_info)
  2046. {
  2047. uint32_t cur_idx;
  2048. struct dp_tx_seg_info_s *seg = msdu_info->u.sg_info.curr_seg;
  2049. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE,
  2050. qdf_nbuf_headlen(nbuf));
  2051. for (cur_idx = 1; cur_idx < seg->frag_cnt; cur_idx++)
  2052. qdf_mem_unmap_page(soc->osdev, (qdf_dma_addr_t)
  2053. (seg->frags[cur_idx].paddr_lo | ((uint64_t)
  2054. seg->frags[cur_idx].paddr_hi) << 32),
  2055. seg->frags[cur_idx].len,
  2056. QDF_DMA_TO_DEVICE);
  2057. }
  2058. /**
  2059. * dp_tx_send_msdu_multiple() - Enqueue multiple MSDUs
  2060. * @vdev: DP vdev handle
  2061. * @nbuf: skb
  2062. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  2063. *
  2064. * Prepare descriptors for multiple MSDUs (TSO segments) and enqueue to TCL
  2065. *
  2066. * Return: NULL on success,
  2067. * nbuf when it fails to send
  2068. */
  2069. #if QDF_LOCK_STATS
  2070. noinline
  2071. #else
  2072. #endif
  2073. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2074. struct dp_tx_msdu_info_s *msdu_info)
  2075. {
  2076. uint32_t i;
  2077. struct dp_pdev *pdev = vdev->pdev;
  2078. struct dp_soc *soc = pdev->soc;
  2079. struct dp_tx_desc_s *tx_desc;
  2080. bool is_cce_classified = false;
  2081. QDF_STATUS status;
  2082. uint16_t htt_tcl_metadata = 0;
  2083. struct dp_tx_queue *tx_q = &msdu_info->tx_queue;
  2084. struct cdp_tid_tx_stats *tid_stats = NULL;
  2085. uint8_t prep_desc_fail = 0, hw_enq_fail = 0;
  2086. if (msdu_info->frm_type == dp_tx_frm_me)
  2087. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2088. i = 0;
  2089. /* Print statement to track i and num_seg */
  2090. /*
  2091. * For each segment (maps to 1 MSDU) , prepare software and hardware
  2092. * descriptors using information in msdu_info
  2093. */
  2094. while (i < msdu_info->num_seg) {
  2095. /*
  2096. * Setup Tx descriptor for an MSDU, and MSDU extension
  2097. * descriptor
  2098. */
  2099. tx_desc = dp_tx_prepare_desc(vdev, nbuf, msdu_info,
  2100. tx_q->desc_pool_id);
  2101. if (!tx_desc) {
  2102. if (msdu_info->frm_type == dp_tx_frm_me) {
  2103. prep_desc_fail++;
  2104. dp_tx_me_free_buf(pdev,
  2105. (void *)(msdu_info->u.sg_info
  2106. .curr_seg->frags[0].vaddr));
  2107. if (prep_desc_fail == msdu_info->num_seg) {
  2108. /*
  2109. * Unmap is needed only if descriptor
  2110. * preparation failed for all segments.
  2111. */
  2112. qdf_nbuf_unmap(soc->osdev,
  2113. msdu_info->u.sg_info.
  2114. curr_seg->nbuf,
  2115. QDF_DMA_TO_DEVICE);
  2116. }
  2117. /*
  2118. * Free the nbuf for the current segment
  2119. * and make it point to the next in the list.
  2120. * For me, there are as many segments as there
  2121. * are no of clients.
  2122. */
  2123. qdf_nbuf_free(msdu_info->u.sg_info
  2124. .curr_seg->nbuf);
  2125. if (msdu_info->u.sg_info.curr_seg->next) {
  2126. msdu_info->u.sg_info.curr_seg =
  2127. msdu_info->u.sg_info
  2128. .curr_seg->next;
  2129. nbuf = msdu_info->u.sg_info
  2130. .curr_seg->nbuf;
  2131. }
  2132. i++;
  2133. continue;
  2134. }
  2135. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2136. dp_tx_tso_seg_history_add(
  2137. soc,
  2138. msdu_info->u.tso_info.curr_seg,
  2139. nbuf, 0, DP_TX_DESC_UNMAP);
  2140. dp_tx_tso_unmap_segment(soc,
  2141. msdu_info->u.tso_info.
  2142. curr_seg,
  2143. msdu_info->u.tso_info.
  2144. tso_num_seg_list);
  2145. if (msdu_info->u.tso_info.curr_seg->next) {
  2146. msdu_info->u.tso_info.curr_seg =
  2147. msdu_info->u.tso_info.curr_seg->next;
  2148. i++;
  2149. continue;
  2150. }
  2151. }
  2152. if (msdu_info->frm_type == dp_tx_frm_sg)
  2153. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2154. goto done;
  2155. }
  2156. if (msdu_info->frm_type == dp_tx_frm_me) {
  2157. tx_desc->msdu_ext_desc->me_buffer =
  2158. (struct dp_tx_me_buf_t *)msdu_info->
  2159. u.sg_info.curr_seg->frags[0].vaddr;
  2160. tx_desc->flags |= DP_TX_DESC_FLAG_ME;
  2161. }
  2162. if (is_cce_classified)
  2163. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  2164. htt_tcl_metadata = vdev->htt_tcl_metadata;
  2165. if (msdu_info->exception_fw) {
  2166. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  2167. }
  2168. dp_tx_is_hp_update_required(i, msdu_info);
  2169. /*
  2170. * For frames with multiple segments (TSO, ME), jump to next
  2171. * segment.
  2172. */
  2173. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2174. if (msdu_info->u.tso_info.curr_seg->next) {
  2175. msdu_info->u.tso_info.curr_seg =
  2176. msdu_info->u.tso_info.curr_seg->next;
  2177. /*
  2178. * If this is a jumbo nbuf, then increment the
  2179. * number of nbuf users for each additional
  2180. * segment of the msdu. This will ensure that
  2181. * the skb is freed only after receiving tx
  2182. * completion for all segments of an nbuf
  2183. */
  2184. qdf_nbuf_inc_users(nbuf);
  2185. /* Check with MCL if this is needed */
  2186. /* nbuf = msdu_info->u.tso_info.curr_seg->nbuf;
  2187. */
  2188. }
  2189. }
  2190. dp_tx_update_mcast_param(DP_INVALID_PEER,
  2191. &htt_tcl_metadata,
  2192. vdev,
  2193. msdu_info);
  2194. /*
  2195. * Enqueue the Tx MSDU descriptor to HW for transmit
  2196. */
  2197. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  2198. htt_tcl_metadata,
  2199. NULL, msdu_info);
  2200. dp_tx_check_and_flush_hp(soc, status, msdu_info);
  2201. if (status != QDF_STATUS_SUCCESS) {
  2202. dp_info_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  2203. tx_desc, tx_q->ring_id);
  2204. dp_tx_get_tid(vdev, nbuf, msdu_info);
  2205. tid_stats = &pdev->stats.tid_stats.
  2206. tid_tx_stats[tx_q->ring_id][msdu_info->tid];
  2207. tid_stats->swdrop_cnt[TX_HW_ENQUEUE]++;
  2208. if (msdu_info->frm_type == dp_tx_frm_me) {
  2209. hw_enq_fail++;
  2210. if (hw_enq_fail == msdu_info->num_seg) {
  2211. /*
  2212. * Unmap is needed only if enqueue
  2213. * failed for all segments.
  2214. */
  2215. qdf_nbuf_unmap(soc->osdev,
  2216. msdu_info->u.sg_info.
  2217. curr_seg->nbuf,
  2218. QDF_DMA_TO_DEVICE);
  2219. }
  2220. /*
  2221. * Free the nbuf for the current segment
  2222. * and make it point to the next in the list.
  2223. * For me, there are as many segments as there
  2224. * are no of clients.
  2225. */
  2226. qdf_nbuf_free(msdu_info->u.sg_info
  2227. .curr_seg->nbuf);
  2228. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2229. if (msdu_info->u.sg_info.curr_seg->next) {
  2230. msdu_info->u.sg_info.curr_seg =
  2231. msdu_info->u.sg_info
  2232. .curr_seg->next;
  2233. nbuf = msdu_info->u.sg_info
  2234. .curr_seg->nbuf;
  2235. } else
  2236. break;
  2237. i++;
  2238. continue;
  2239. }
  2240. /*
  2241. * For TSO frames, the nbuf users increment done for
  2242. * the current segment has to be reverted, since the
  2243. * hw enqueue for this segment failed
  2244. */
  2245. if (msdu_info->frm_type == dp_tx_frm_tso &&
  2246. msdu_info->u.tso_info.curr_seg) {
  2247. /*
  2248. * unmap and free current,
  2249. * retransmit remaining segments
  2250. */
  2251. dp_tx_comp_free_buf(soc, tx_desc);
  2252. i++;
  2253. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2254. continue;
  2255. }
  2256. if (msdu_info->frm_type == dp_tx_frm_sg)
  2257. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2258. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2259. goto done;
  2260. }
  2261. /*
  2262. * TODO
  2263. * if tso_info structure can be modified to have curr_seg
  2264. * as first element, following 2 blocks of code (for TSO and SG)
  2265. * can be combined into 1
  2266. */
  2267. /*
  2268. * For Multicast-Unicast converted packets,
  2269. * each converted frame (for a client) is represented as
  2270. * 1 segment
  2271. */
  2272. if ((msdu_info->frm_type == dp_tx_frm_sg) ||
  2273. (msdu_info->frm_type == dp_tx_frm_me)) {
  2274. if (msdu_info->u.sg_info.curr_seg->next) {
  2275. msdu_info->u.sg_info.curr_seg =
  2276. msdu_info->u.sg_info.curr_seg->next;
  2277. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2278. } else
  2279. break;
  2280. }
  2281. i++;
  2282. }
  2283. nbuf = NULL;
  2284. done:
  2285. return nbuf;
  2286. }
  2287. /**
  2288. * dp_tx_prepare_sg()- Extract SG info from NBUF and prepare msdu_info
  2289. * for SG frames
  2290. * @vdev: DP vdev handle
  2291. * @nbuf: skb
  2292. * @seg_info: Pointer to Segment info Descriptor to be prepared
  2293. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2294. *
  2295. * Return: NULL on success,
  2296. * nbuf when it fails to send
  2297. */
  2298. static qdf_nbuf_t dp_tx_prepare_sg(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2299. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  2300. {
  2301. uint32_t cur_frag, nr_frags, i;
  2302. qdf_dma_addr_t paddr;
  2303. struct dp_tx_sg_info_s *sg_info;
  2304. sg_info = &msdu_info->u.sg_info;
  2305. nr_frags = qdf_nbuf_get_nr_frags(nbuf);
  2306. if (QDF_STATUS_SUCCESS !=
  2307. qdf_nbuf_map_nbytes_single(vdev->osdev, nbuf,
  2308. QDF_DMA_TO_DEVICE,
  2309. qdf_nbuf_headlen(nbuf))) {
  2310. dp_tx_err("dma map error");
  2311. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2312. qdf_nbuf_free(nbuf);
  2313. return NULL;
  2314. }
  2315. paddr = qdf_nbuf_mapped_paddr_get(nbuf);
  2316. seg_info->frags[0].paddr_lo = paddr;
  2317. seg_info->frags[0].paddr_hi = ((uint64_t) paddr) >> 32;
  2318. seg_info->frags[0].len = qdf_nbuf_headlen(nbuf);
  2319. seg_info->frags[0].vaddr = (void *) nbuf;
  2320. for (cur_frag = 0; cur_frag < nr_frags; cur_frag++) {
  2321. if (QDF_STATUS_SUCCESS != qdf_nbuf_frag_map(vdev->osdev,
  2322. nbuf, 0,
  2323. QDF_DMA_TO_DEVICE,
  2324. cur_frag)) {
  2325. dp_tx_err("frag dma map error");
  2326. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2327. goto map_err;
  2328. }
  2329. paddr = qdf_nbuf_get_tx_frag_paddr(nbuf);
  2330. seg_info->frags[cur_frag + 1].paddr_lo = paddr;
  2331. seg_info->frags[cur_frag + 1].paddr_hi =
  2332. ((uint64_t) paddr) >> 32;
  2333. seg_info->frags[cur_frag + 1].len =
  2334. qdf_nbuf_get_frag_size(nbuf, cur_frag);
  2335. }
  2336. seg_info->frag_cnt = (cur_frag + 1);
  2337. seg_info->total_len = qdf_nbuf_len(nbuf);
  2338. seg_info->next = NULL;
  2339. sg_info->curr_seg = seg_info;
  2340. msdu_info->frm_type = dp_tx_frm_sg;
  2341. msdu_info->num_seg = 1;
  2342. return nbuf;
  2343. map_err:
  2344. /* restore paddr into nbuf before calling unmap */
  2345. qdf_nbuf_mapped_paddr_set(nbuf,
  2346. (qdf_dma_addr_t)(seg_info->frags[0].paddr_lo |
  2347. ((uint64_t)
  2348. seg_info->frags[0].paddr_hi) << 32));
  2349. qdf_nbuf_unmap_nbytes_single(vdev->osdev, nbuf,
  2350. QDF_DMA_TO_DEVICE,
  2351. seg_info->frags[0].len);
  2352. for (i = 1; i <= cur_frag; i++) {
  2353. qdf_mem_unmap_page(vdev->osdev, (qdf_dma_addr_t)
  2354. (seg_info->frags[i].paddr_lo | ((uint64_t)
  2355. seg_info->frags[i].paddr_hi) << 32),
  2356. seg_info->frags[i].len,
  2357. QDF_DMA_TO_DEVICE);
  2358. }
  2359. qdf_nbuf_free(nbuf);
  2360. return NULL;
  2361. }
  2362. /**
  2363. * dp_tx_add_tx_sniffer_meta_data()- Add tx_sniffer meta hdr info
  2364. * @vdev: DP vdev handle
  2365. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2366. * @ppdu_cookie: PPDU cookie that should be replayed in the ppdu completions
  2367. *
  2368. * Return: NULL on failure,
  2369. * nbuf when extracted successfully
  2370. */
  2371. static
  2372. void dp_tx_add_tx_sniffer_meta_data(struct dp_vdev *vdev,
  2373. struct dp_tx_msdu_info_s *msdu_info,
  2374. uint16_t ppdu_cookie)
  2375. {
  2376. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2377. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2378. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2379. HTT_TX_MSDU_EXT2_DESC_FLAG_SEND_AS_STANDALONE_SET
  2380. (msdu_info->meta_data[5], 1);
  2381. HTT_TX_MSDU_EXT2_DESC_FLAG_HOST_OPAQUE_VALID_SET
  2382. (msdu_info->meta_data[5], 1);
  2383. HTT_TX_MSDU_EXT2_DESC_HOST_OPAQUE_COOKIE_SET
  2384. (msdu_info->meta_data[6], ppdu_cookie);
  2385. msdu_info->exception_fw = 1;
  2386. msdu_info->is_tx_sniffer = 1;
  2387. }
  2388. #ifdef MESH_MODE_SUPPORT
  2389. /**
  2390. * dp_tx_extract_mesh_meta_data()- Extract mesh meta hdr info from nbuf
  2391. and prepare msdu_info for mesh frames.
  2392. * @vdev: DP vdev handle
  2393. * @nbuf: skb
  2394. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2395. *
  2396. * Return: NULL on failure,
  2397. * nbuf when extracted successfully
  2398. */
  2399. static
  2400. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2401. struct dp_tx_msdu_info_s *msdu_info)
  2402. {
  2403. struct meta_hdr_s *mhdr;
  2404. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2405. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2406. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2407. if (CB_FTYPE_MESH_TX_INFO != qdf_nbuf_get_tx_ftype(nbuf)) {
  2408. msdu_info->exception_fw = 0;
  2409. goto remove_meta_hdr;
  2410. }
  2411. msdu_info->exception_fw = 1;
  2412. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2413. meta_data->host_tx_desc_pool = 1;
  2414. meta_data->update_peer_cache = 1;
  2415. meta_data->learning_frame = 1;
  2416. if (!(mhdr->flags & METAHDR_FLAG_AUTO_RATE)) {
  2417. meta_data->power = mhdr->power;
  2418. meta_data->mcs_mask = 1 << mhdr->rate_info[0].mcs;
  2419. meta_data->nss_mask = 1 << mhdr->rate_info[0].nss;
  2420. meta_data->pream_type = mhdr->rate_info[0].preamble_type;
  2421. meta_data->retry_limit = mhdr->rate_info[0].max_tries;
  2422. meta_data->dyn_bw = 1;
  2423. meta_data->valid_pwr = 1;
  2424. meta_data->valid_mcs_mask = 1;
  2425. meta_data->valid_nss_mask = 1;
  2426. meta_data->valid_preamble_type = 1;
  2427. meta_data->valid_retries = 1;
  2428. meta_data->valid_bw_info = 1;
  2429. }
  2430. if (mhdr->flags & METAHDR_FLAG_NOENCRYPT) {
  2431. meta_data->encrypt_type = 0;
  2432. meta_data->valid_encrypt_type = 1;
  2433. meta_data->learning_frame = 0;
  2434. }
  2435. meta_data->valid_key_flags = 1;
  2436. meta_data->key_flags = (mhdr->keyix & 0x3);
  2437. remove_meta_hdr:
  2438. if (qdf_nbuf_pull_head(nbuf, sizeof(struct meta_hdr_s)) == NULL) {
  2439. dp_tx_err("qdf_nbuf_pull_head failed");
  2440. qdf_nbuf_free(nbuf);
  2441. return NULL;
  2442. }
  2443. msdu_info->tid = qdf_nbuf_get_priority(nbuf);
  2444. dp_tx_info("Meta hdr %0x %0x %0x %0x %0x %0x"
  2445. " tid %d to_fw %d",
  2446. msdu_info->meta_data[0],
  2447. msdu_info->meta_data[1],
  2448. msdu_info->meta_data[2],
  2449. msdu_info->meta_data[3],
  2450. msdu_info->meta_data[4],
  2451. msdu_info->meta_data[5],
  2452. msdu_info->tid, msdu_info->exception_fw);
  2453. return nbuf;
  2454. }
  2455. #else
  2456. static
  2457. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2458. struct dp_tx_msdu_info_s *msdu_info)
  2459. {
  2460. return nbuf;
  2461. }
  2462. #endif
  2463. /**
  2464. * dp_check_exc_metadata() - Checks if parameters are valid
  2465. * @tx_exc - holds all exception path parameters
  2466. *
  2467. * Returns true when all the parameters are valid else false
  2468. *
  2469. */
  2470. static bool dp_check_exc_metadata(struct cdp_tx_exception_metadata *tx_exc)
  2471. {
  2472. bool invalid_tid = (tx_exc->tid >= DP_MAX_TIDS && tx_exc->tid !=
  2473. HTT_INVALID_TID);
  2474. bool invalid_encap_type =
  2475. (tx_exc->tx_encap_type > htt_cmn_pkt_num_types &&
  2476. tx_exc->tx_encap_type != CDP_INVALID_TX_ENCAP_TYPE);
  2477. bool invalid_sec_type = (tx_exc->sec_type > cdp_num_sec_types &&
  2478. tx_exc->sec_type != CDP_INVALID_SEC_TYPE);
  2479. bool invalid_cookie = (tx_exc->is_tx_sniffer == 1 &&
  2480. tx_exc->ppdu_cookie == 0);
  2481. if (tx_exc->is_intrabss_fwd)
  2482. return true;
  2483. if (invalid_tid || invalid_encap_type || invalid_sec_type ||
  2484. invalid_cookie) {
  2485. return false;
  2486. }
  2487. return true;
  2488. }
  2489. #ifdef ATH_SUPPORT_IQUE
  2490. /**
  2491. * dp_tx_mcast_enhance() - Multicast enhancement on TX
  2492. * @vdev: vdev handle
  2493. * @nbuf: skb
  2494. *
  2495. * Return: true on success,
  2496. * false on failure
  2497. */
  2498. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2499. {
  2500. qdf_ether_header_t *eh;
  2501. /* Mcast to Ucast Conversion*/
  2502. if (qdf_likely(!vdev->mcast_enhancement_en))
  2503. return true;
  2504. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2505. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) &&
  2506. !DP_FRAME_IS_BROADCAST((eh)->ether_dhost)) {
  2507. dp_verbose_debug("Mcast frm for ME %pK", vdev);
  2508. qdf_nbuf_set_next(nbuf, NULL);
  2509. DP_STATS_INC_PKT(vdev, tx_i.mcast_en.mcast_pkt, 1,
  2510. qdf_nbuf_len(nbuf));
  2511. if (dp_tx_prepare_send_me(vdev, nbuf) ==
  2512. QDF_STATUS_SUCCESS) {
  2513. return false;
  2514. }
  2515. if (qdf_unlikely(vdev->igmp_mcast_enhanc_en > 0)) {
  2516. if (dp_tx_prepare_send_igmp_me(vdev, nbuf) ==
  2517. QDF_STATUS_SUCCESS) {
  2518. return false;
  2519. }
  2520. }
  2521. }
  2522. return true;
  2523. }
  2524. #else
  2525. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2526. {
  2527. return true;
  2528. }
  2529. #endif
  2530. /**
  2531. * dp_tx_per_pkt_vdev_id_check() - vdev id check for frame
  2532. * @nbuf: qdf_nbuf_t
  2533. * @vdev: struct dp_vdev *
  2534. *
  2535. * Allow packet for processing only if it is for peer client which is
  2536. * connected with same vap. Drop packet if client is connected to
  2537. * different vap.
  2538. *
  2539. * Return: QDF_STATUS
  2540. */
  2541. static inline QDF_STATUS
  2542. dp_tx_per_pkt_vdev_id_check(qdf_nbuf_t nbuf, struct dp_vdev *vdev)
  2543. {
  2544. struct dp_ast_entry *dst_ast_entry = NULL;
  2545. qdf_ether_header_t *eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2546. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) ||
  2547. DP_FRAME_IS_BROADCAST((eh)->ether_dhost))
  2548. return QDF_STATUS_SUCCESS;
  2549. qdf_spin_lock_bh(&vdev->pdev->soc->ast_lock);
  2550. dst_ast_entry = dp_peer_ast_hash_find_by_vdevid(vdev->pdev->soc,
  2551. eh->ether_dhost,
  2552. vdev->vdev_id);
  2553. /* If there is no ast entry, return failure */
  2554. if (qdf_unlikely(!dst_ast_entry)) {
  2555. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2556. return QDF_STATUS_E_FAILURE;
  2557. }
  2558. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2559. return QDF_STATUS_SUCCESS;
  2560. }
  2561. /**
  2562. * dp_tx_nawds_handler() - NAWDS handler
  2563. *
  2564. * @soc: DP soc handle
  2565. * @vdev_id: id of DP vdev handle
  2566. * @msdu_info: msdu_info required to create HTT metadata
  2567. * @nbuf: skb
  2568. *
  2569. * This API transfers the multicast frames with the peer id
  2570. * on NAWDS enabled peer.
  2571. * Return: none
  2572. */
  2573. static inline
  2574. void dp_tx_nawds_handler(struct dp_soc *soc, struct dp_vdev *vdev,
  2575. struct dp_tx_msdu_info_s *msdu_info,
  2576. qdf_nbuf_t nbuf, uint16_t sa_peer_id)
  2577. {
  2578. struct dp_peer *peer = NULL;
  2579. qdf_nbuf_t nbuf_clone = NULL;
  2580. uint16_t peer_id = DP_INVALID_PEER;
  2581. struct dp_txrx_peer *txrx_peer;
  2582. /* This check avoids pkt forwarding which is entered
  2583. * in the ast table but still doesn't have valid peerid.
  2584. */
  2585. if (sa_peer_id == HTT_INVALID_PEER)
  2586. return;
  2587. qdf_spin_lock_bh(&vdev->peer_list_lock);
  2588. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  2589. txrx_peer = dp_get_txrx_peer(peer);
  2590. if (!txrx_peer)
  2591. continue;
  2592. if (!txrx_peer->bss_peer && txrx_peer->nawds_enabled) {
  2593. peer_id = peer->peer_id;
  2594. if (!dp_peer_is_primary_link_peer(peer))
  2595. continue;
  2596. /* Multicast packets needs to be
  2597. * dropped in case of intra bss forwarding
  2598. */
  2599. if (sa_peer_id == txrx_peer->peer_id) {
  2600. dp_tx_debug("multicast packet");
  2601. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  2602. tx.nawds_mcast_drop,
  2603. 1);
  2604. continue;
  2605. }
  2606. nbuf_clone = qdf_nbuf_clone(nbuf);
  2607. if (!nbuf_clone) {
  2608. QDF_TRACE(QDF_MODULE_ID_DP,
  2609. QDF_TRACE_LEVEL_ERROR,
  2610. FL("nbuf clone failed"));
  2611. break;
  2612. }
  2613. nbuf_clone = dp_tx_send_msdu_single(vdev, nbuf_clone,
  2614. msdu_info, peer_id,
  2615. NULL);
  2616. if (nbuf_clone) {
  2617. dp_tx_debug("pkt send failed");
  2618. qdf_nbuf_free(nbuf_clone);
  2619. } else {
  2620. if (peer_id != DP_INVALID_PEER)
  2621. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  2622. tx.nawds_mcast,
  2623. 1, qdf_nbuf_len(nbuf));
  2624. }
  2625. }
  2626. }
  2627. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  2628. }
  2629. /**
  2630. * dp_tx_send_exception() - Transmit a frame on a given VAP in exception path
  2631. * @soc: DP soc handle
  2632. * @vdev_id: id of DP vdev handle
  2633. * @nbuf: skb
  2634. * @tx_exc_metadata: Handle that holds exception path meta data
  2635. *
  2636. * Entry point for Core Tx layer (DP_TX) invoked from
  2637. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2638. *
  2639. * Return: NULL on success,
  2640. * nbuf when it fails to send
  2641. */
  2642. qdf_nbuf_t
  2643. dp_tx_send_exception(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2644. qdf_nbuf_t nbuf,
  2645. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2646. {
  2647. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2648. qdf_ether_header_t *eh = NULL;
  2649. struct dp_tx_msdu_info_s msdu_info;
  2650. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2651. DP_MOD_ID_TX_EXCEPTION);
  2652. if (qdf_unlikely(!vdev))
  2653. goto fail;
  2654. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  2655. if (!tx_exc_metadata)
  2656. goto fail;
  2657. msdu_info.tid = tx_exc_metadata->tid;
  2658. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2659. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2660. QDF_MAC_ADDR_REF(nbuf->data));
  2661. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2662. if (qdf_unlikely(!dp_check_exc_metadata(tx_exc_metadata))) {
  2663. dp_tx_err("Invalid parameters in exception path");
  2664. goto fail;
  2665. }
  2666. /* Basic sanity checks for unsupported packets */
  2667. /* MESH mode */
  2668. if (qdf_unlikely(vdev->mesh_vdev)) {
  2669. dp_tx_err("Mesh mode is not supported in exception path");
  2670. goto fail;
  2671. }
  2672. /*
  2673. * Classify the frame and call corresponding
  2674. * "prepare" function which extracts the segment (TSO)
  2675. * and fragmentation information (for TSO , SG, ME, or Raw)
  2676. * into MSDU_INFO structure which is later used to fill
  2677. * SW and HW descriptors.
  2678. */
  2679. if (qdf_nbuf_is_tso(nbuf)) {
  2680. dp_verbose_debug("TSO frame %pK", vdev);
  2681. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2682. qdf_nbuf_len(nbuf));
  2683. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2684. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2685. qdf_nbuf_len(nbuf));
  2686. goto fail;
  2687. }
  2688. goto send_multiple;
  2689. }
  2690. /* SG */
  2691. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2692. struct dp_tx_seg_info_s seg_info = {0};
  2693. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info, &msdu_info);
  2694. if (!nbuf)
  2695. goto fail;
  2696. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  2697. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  2698. qdf_nbuf_len(nbuf));
  2699. goto send_multiple;
  2700. }
  2701. if (qdf_likely(tx_exc_metadata->is_tx_sniffer)) {
  2702. DP_STATS_INC_PKT(vdev, tx_i.sniffer_rcvd, 1,
  2703. qdf_nbuf_len(nbuf));
  2704. dp_tx_add_tx_sniffer_meta_data(vdev, &msdu_info,
  2705. tx_exc_metadata->ppdu_cookie);
  2706. }
  2707. /*
  2708. * Get HW Queue to use for this frame.
  2709. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2710. * dedicated for data and 1 for command.
  2711. * "queue_id" maps to one hardware ring.
  2712. * With each ring, we also associate a unique Tx descriptor pool
  2713. * to minimize lock contention for these resources.
  2714. */
  2715. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2716. if (qdf_likely(tx_exc_metadata->is_intrabss_fwd)) {
  2717. if (qdf_unlikely(vdev->nawds_enabled)) {
  2718. /*
  2719. * This is a multicast packet
  2720. */
  2721. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  2722. tx_exc_metadata->peer_id);
  2723. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  2724. 1, qdf_nbuf_len(nbuf));
  2725. }
  2726. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2727. DP_INVALID_PEER, NULL);
  2728. } else {
  2729. /*
  2730. * Check exception descriptors
  2731. */
  2732. if (dp_tx_exception_limit_check(vdev))
  2733. goto fail;
  2734. /* Single linear frame */
  2735. /*
  2736. * If nbuf is a simple linear frame, use send_single function to
  2737. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  2738. * SRNG. There is no need to setup a MSDU extension descriptor.
  2739. */
  2740. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2741. tx_exc_metadata->peer_id,
  2742. tx_exc_metadata);
  2743. }
  2744. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2745. return nbuf;
  2746. send_multiple:
  2747. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  2748. fail:
  2749. if (vdev)
  2750. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2751. dp_verbose_debug("pkt send failed");
  2752. return nbuf;
  2753. }
  2754. /**
  2755. * dp_tx_send_exception_vdev_id_check() - Transmit a frame on a given VAP
  2756. * in exception path in special case to avoid regular exception path chk.
  2757. * @soc: DP soc handle
  2758. * @vdev_id: id of DP vdev handle
  2759. * @nbuf: skb
  2760. * @tx_exc_metadata: Handle that holds exception path meta data
  2761. *
  2762. * Entry point for Core Tx layer (DP_TX) invoked from
  2763. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2764. *
  2765. * Return: NULL on success,
  2766. * nbuf when it fails to send
  2767. */
  2768. qdf_nbuf_t
  2769. dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc_hdl,
  2770. uint8_t vdev_id, qdf_nbuf_t nbuf,
  2771. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2772. {
  2773. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2774. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2775. DP_MOD_ID_TX_EXCEPTION);
  2776. if (qdf_unlikely(!vdev))
  2777. goto fail;
  2778. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  2779. == QDF_STATUS_E_FAILURE)) {
  2780. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  2781. goto fail;
  2782. }
  2783. /* Unref count as it will agin be taken inside dp_tx_exception */
  2784. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2785. return dp_tx_send_exception(soc_hdl, vdev_id, nbuf, tx_exc_metadata);
  2786. fail:
  2787. if (vdev)
  2788. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2789. dp_verbose_debug("pkt send failed");
  2790. return nbuf;
  2791. }
  2792. /**
  2793. * dp_tx_send_mesh() - Transmit mesh frame on a given VAP
  2794. * @soc: DP soc handle
  2795. * @vdev_id: DP vdev handle
  2796. * @nbuf: skb
  2797. *
  2798. * Entry point for Core Tx layer (DP_TX) invoked from
  2799. * hard_start_xmit in OSIF/HDD
  2800. *
  2801. * Return: NULL on success,
  2802. * nbuf when it fails to send
  2803. */
  2804. #ifdef MESH_MODE_SUPPORT
  2805. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2806. qdf_nbuf_t nbuf)
  2807. {
  2808. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2809. struct meta_hdr_s *mhdr;
  2810. qdf_nbuf_t nbuf_mesh = NULL;
  2811. qdf_nbuf_t nbuf_clone = NULL;
  2812. struct dp_vdev *vdev;
  2813. uint8_t no_enc_frame = 0;
  2814. nbuf_mesh = qdf_nbuf_unshare(nbuf);
  2815. if (!nbuf_mesh) {
  2816. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2817. "qdf_nbuf_unshare failed");
  2818. return nbuf;
  2819. }
  2820. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_MESH);
  2821. if (!vdev) {
  2822. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2823. "vdev is NULL for vdev_id %d", vdev_id);
  2824. return nbuf;
  2825. }
  2826. nbuf = nbuf_mesh;
  2827. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2828. if ((vdev->sec_type != cdp_sec_type_none) &&
  2829. (mhdr->flags & METAHDR_FLAG_NOENCRYPT))
  2830. no_enc_frame = 1;
  2831. if (mhdr->flags & METAHDR_FLAG_NOQOS)
  2832. qdf_nbuf_set_priority(nbuf, HTT_TX_EXT_TID_NON_QOS_MCAST_BCAST);
  2833. if ((mhdr->flags & METAHDR_FLAG_INFO_UPDATED) &&
  2834. !no_enc_frame) {
  2835. nbuf_clone = qdf_nbuf_clone(nbuf);
  2836. if (!nbuf_clone) {
  2837. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2838. "qdf_nbuf_clone failed");
  2839. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2840. return nbuf;
  2841. }
  2842. qdf_nbuf_set_tx_ftype(nbuf_clone, CB_FTYPE_MESH_TX_INFO);
  2843. }
  2844. if (nbuf_clone) {
  2845. if (!dp_tx_send(soc_hdl, vdev_id, nbuf_clone)) {
  2846. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2847. } else {
  2848. qdf_nbuf_free(nbuf_clone);
  2849. }
  2850. }
  2851. if (no_enc_frame)
  2852. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_MESH_TX_INFO);
  2853. else
  2854. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_INVALID);
  2855. nbuf = dp_tx_send(soc_hdl, vdev_id, nbuf);
  2856. if ((!nbuf) && no_enc_frame) {
  2857. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2858. }
  2859. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2860. return nbuf;
  2861. }
  2862. #else
  2863. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  2864. qdf_nbuf_t nbuf)
  2865. {
  2866. return dp_tx_send(soc, vdev_id, nbuf);
  2867. }
  2868. #endif
  2869. #ifdef QCA_DP_TX_NBUF_AND_NBUF_DATA_PREFETCH
  2870. static inline
  2871. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2872. {
  2873. if (nbuf) {
  2874. qdf_prefetch(&nbuf->len);
  2875. qdf_prefetch(&nbuf->data);
  2876. }
  2877. }
  2878. #else
  2879. static inline
  2880. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2881. {
  2882. }
  2883. #endif
  2884. /**
  2885. * dp_tx_send() - Transmit a frame on a given VAP
  2886. * @soc: DP soc handle
  2887. * @vdev_id: id of DP vdev handle
  2888. * @nbuf: skb
  2889. *
  2890. * Entry point for Core Tx layer (DP_TX) invoked from
  2891. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  2892. * cases
  2893. *
  2894. * Return: NULL on success,
  2895. * nbuf when it fails to send
  2896. */
  2897. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2898. qdf_nbuf_t nbuf)
  2899. {
  2900. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2901. uint16_t peer_id = HTT_INVALID_PEER;
  2902. /*
  2903. * doing a memzero is causing additional function call overhead
  2904. * so doing static stack clearing
  2905. */
  2906. struct dp_tx_msdu_info_s msdu_info = {0};
  2907. struct dp_vdev *vdev = NULL;
  2908. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  2909. return nbuf;
  2910. /*
  2911. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  2912. * this in per packet path.
  2913. *
  2914. * As in this path vdev memory is already protected with netdev
  2915. * tx lock
  2916. */
  2917. vdev = soc->vdev_id_map[vdev_id];
  2918. if (qdf_unlikely(!vdev))
  2919. return nbuf;
  2920. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2921. QDF_MAC_ADDR_REF(nbuf->data));
  2922. /*
  2923. * Set Default Host TID value to invalid TID
  2924. * (TID override disabled)
  2925. */
  2926. msdu_info.tid = HTT_TX_EXT_TID_INVALID;
  2927. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2928. if (qdf_unlikely(vdev->mesh_vdev)) {
  2929. qdf_nbuf_t nbuf_mesh = dp_tx_extract_mesh_meta_data(vdev, nbuf,
  2930. &msdu_info);
  2931. if (!nbuf_mesh) {
  2932. dp_verbose_debug("Extracting mesh metadata failed");
  2933. return nbuf;
  2934. }
  2935. nbuf = nbuf_mesh;
  2936. }
  2937. /*
  2938. * Get HW Queue to use for this frame.
  2939. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2940. * dedicated for data and 1 for command.
  2941. * "queue_id" maps to one hardware ring.
  2942. * With each ring, we also associate a unique Tx descriptor pool
  2943. * to minimize lock contention for these resources.
  2944. */
  2945. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2946. /*
  2947. * TCL H/W supports 2 DSCP-TID mapping tables.
  2948. * Table 1 - Default DSCP-TID mapping table
  2949. * Table 2 - 1 DSCP-TID override table
  2950. *
  2951. * If we need a different DSCP-TID mapping for this vap,
  2952. * call tid_classify to extract DSCP/ToS from frame and
  2953. * map to a TID and store in msdu_info. This is later used
  2954. * to fill in TCL Input descriptor (per-packet TID override).
  2955. */
  2956. dp_tx_classify_tid(vdev, nbuf, &msdu_info);
  2957. /*
  2958. * Classify the frame and call corresponding
  2959. * "prepare" function which extracts the segment (TSO)
  2960. * and fragmentation information (for TSO , SG, ME, or Raw)
  2961. * into MSDU_INFO structure which is later used to fill
  2962. * SW and HW descriptors.
  2963. */
  2964. if (qdf_nbuf_is_tso(nbuf)) {
  2965. dp_verbose_debug("TSO frame %pK", vdev);
  2966. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2967. qdf_nbuf_len(nbuf));
  2968. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2969. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2970. qdf_nbuf_len(nbuf));
  2971. return nbuf;
  2972. }
  2973. goto send_multiple;
  2974. }
  2975. /* SG */
  2976. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2977. if (qdf_nbuf_get_nr_frags(nbuf) > DP_TX_MAX_NUM_FRAGS - 1) {
  2978. if (qdf_unlikely(qdf_nbuf_linearize(nbuf)))
  2979. return nbuf;
  2980. } else {
  2981. struct dp_tx_seg_info_s seg_info = {0};
  2982. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info,
  2983. &msdu_info);
  2984. if (!nbuf)
  2985. return NULL;
  2986. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  2987. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  2988. qdf_nbuf_len(nbuf));
  2989. goto send_multiple;
  2990. }
  2991. }
  2992. if (qdf_unlikely(!dp_tx_mcast_enhance(vdev, nbuf)))
  2993. return NULL;
  2994. /* RAW */
  2995. if (qdf_unlikely(vdev->tx_encap_type == htt_cmn_pkt_type_raw)) {
  2996. struct dp_tx_seg_info_s seg_info = {0};
  2997. nbuf = dp_tx_prepare_raw(vdev, nbuf, &seg_info, &msdu_info);
  2998. if (!nbuf)
  2999. return NULL;
  3000. dp_verbose_debug("Raw frame %pK", vdev);
  3001. goto send_multiple;
  3002. }
  3003. if (qdf_unlikely(vdev->nawds_enabled)) {
  3004. qdf_ether_header_t *eh = (qdf_ether_header_t *)
  3005. qdf_nbuf_data(nbuf);
  3006. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  3007. uint16_t sa_peer_id = DP_INVALID_PEER;
  3008. if (!soc->ast_offload_support) {
  3009. struct dp_ast_entry *ast_entry = NULL;
  3010. qdf_spin_lock_bh(&soc->ast_lock);
  3011. ast_entry = dp_peer_ast_hash_find_by_pdevid
  3012. (soc,
  3013. (uint8_t *)(eh->ether_shost),
  3014. vdev->pdev->pdev_id);
  3015. if (ast_entry)
  3016. sa_peer_id = ast_entry->peer_id;
  3017. qdf_spin_unlock_bh(&soc->ast_lock);
  3018. }
  3019. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  3020. sa_peer_id);
  3021. }
  3022. peer_id = DP_INVALID_PEER;
  3023. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  3024. 1, qdf_nbuf_len(nbuf));
  3025. }
  3026. /* Single linear frame */
  3027. /*
  3028. * If nbuf is a simple linear frame, use send_single function to
  3029. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  3030. * SRNG. There is no need to setup a MSDU extension descriptor.
  3031. */
  3032. dp_tx_prefetch_nbuf_data(nbuf);
  3033. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info, peer_id, NULL);
  3034. return nbuf;
  3035. send_multiple:
  3036. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  3037. if (qdf_unlikely(nbuf && msdu_info.frm_type == dp_tx_frm_raw))
  3038. dp_tx_raw_prepare_unset(vdev->pdev->soc, nbuf);
  3039. return nbuf;
  3040. }
  3041. /**
  3042. * dp_tx_send_vdev_id_check() - Transmit a frame on a given VAP in special
  3043. * case to vaoid check in perpkt path.
  3044. * @soc: DP soc handle
  3045. * @vdev_id: id of DP vdev handle
  3046. * @nbuf: skb
  3047. *
  3048. * Entry point for Core Tx layer (DP_TX) invoked from
  3049. * hard_start_xmit in OSIF/HDD to transmit packet through dp_tx_send
  3050. * with special condition to avoid per pkt check in dp_tx_send
  3051. *
  3052. * Return: NULL on success,
  3053. * nbuf when it fails to send
  3054. */
  3055. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc_hdl,
  3056. uint8_t vdev_id, qdf_nbuf_t nbuf)
  3057. {
  3058. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3059. struct dp_vdev *vdev = NULL;
  3060. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  3061. return nbuf;
  3062. /*
  3063. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  3064. * this in per packet path.
  3065. *
  3066. * As in this path vdev memory is already protected with netdev
  3067. * tx lock
  3068. */
  3069. vdev = soc->vdev_id_map[vdev_id];
  3070. if (qdf_unlikely(!vdev))
  3071. return nbuf;
  3072. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  3073. == QDF_STATUS_E_FAILURE)) {
  3074. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  3075. return nbuf;
  3076. }
  3077. return dp_tx_send(soc_hdl, vdev_id, nbuf);
  3078. }
  3079. #ifdef UMAC_SUPPORT_PROXY_ARP
  3080. /**
  3081. * dp_tx_proxy_arp() - Tx proxy arp handler
  3082. * @vdev: datapath vdev handle
  3083. * @buf: sk buffer
  3084. *
  3085. * Return: status
  3086. */
  3087. static inline
  3088. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3089. {
  3090. if (vdev->osif_proxy_arp)
  3091. return vdev->osif_proxy_arp(vdev->osif_vdev, nbuf);
  3092. /*
  3093. * when UMAC_SUPPORT_PROXY_ARP is defined, we expect
  3094. * osif_proxy_arp has a valid function pointer assigned
  3095. * to it
  3096. */
  3097. dp_tx_err("valid function pointer for osif_proxy_arp is expected!!\n");
  3098. return QDF_STATUS_NOT_INITIALIZED;
  3099. }
  3100. #else
  3101. /**
  3102. * dp_tx_proxy_arp() - Tx proxy arp handler
  3103. * @vdev: datapath vdev handle
  3104. * @buf: sk buffer
  3105. *
  3106. * This function always return 0 when UMAC_SUPPORT_PROXY_ARP
  3107. * is not defined.
  3108. *
  3109. * Return: status
  3110. */
  3111. static inline
  3112. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3113. {
  3114. return QDF_STATUS_SUCCESS;
  3115. }
  3116. #endif
  3117. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  3118. #ifdef WLAN_MCAST_MLO
  3119. static bool
  3120. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3121. struct dp_tx_desc_s *tx_desc,
  3122. qdf_nbuf_t nbuf,
  3123. uint8_t reinject_reason)
  3124. {
  3125. if (reinject_reason == HTT_TX_FW2WBM_REINJECT_REASON_MLO_MCAST) {
  3126. if (soc->arch_ops.dp_tx_mcast_handler)
  3127. soc->arch_ops.dp_tx_mcast_handler(soc, vdev, nbuf);
  3128. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3129. return true;
  3130. }
  3131. return false;
  3132. }
  3133. #else /* WLAN_MCAST_MLO */
  3134. static inline bool
  3135. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3136. struct dp_tx_desc_s *tx_desc,
  3137. qdf_nbuf_t nbuf,
  3138. uint8_t reinject_reason)
  3139. {
  3140. return false;
  3141. }
  3142. #endif /* WLAN_MCAST_MLO */
  3143. #else
  3144. static inline bool
  3145. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3146. struct dp_tx_desc_s *tx_desc,
  3147. qdf_nbuf_t nbuf,
  3148. uint8_t reinject_reason)
  3149. {
  3150. return false;
  3151. }
  3152. #endif
  3153. /**
  3154. * dp_tx_reinject_handler() - Tx Reinject Handler
  3155. * @soc: datapath soc handle
  3156. * @vdev: datapath vdev handle
  3157. * @tx_desc: software descriptor head pointer
  3158. * @status : Tx completion status from HTT descriptor
  3159. * @reinject_reason : reinject reason from HTT descriptor
  3160. *
  3161. * This function reinjects frames back to Target.
  3162. * Todo - Host queue needs to be added
  3163. *
  3164. * Return: none
  3165. */
  3166. void dp_tx_reinject_handler(struct dp_soc *soc,
  3167. struct dp_vdev *vdev,
  3168. struct dp_tx_desc_s *tx_desc,
  3169. uint8_t *status,
  3170. uint8_t reinject_reason)
  3171. {
  3172. struct dp_peer *peer = NULL;
  3173. uint32_t peer_id = HTT_INVALID_PEER;
  3174. qdf_nbuf_t nbuf = tx_desc->nbuf;
  3175. qdf_nbuf_t nbuf_copy = NULL;
  3176. struct dp_tx_msdu_info_s msdu_info;
  3177. #ifdef WDS_VENDOR_EXTENSION
  3178. int is_mcast = 0, is_ucast = 0;
  3179. int num_peers_3addr = 0;
  3180. qdf_ether_header_t *eth_hdr = (qdf_ether_header_t *)(qdf_nbuf_data(nbuf));
  3181. struct ieee80211_frame_addr4 *wh = (struct ieee80211_frame_addr4 *)(qdf_nbuf_data(nbuf));
  3182. #endif
  3183. struct dp_txrx_peer *txrx_peer;
  3184. qdf_assert(vdev);
  3185. dp_tx_debug("Tx reinject path");
  3186. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  3187. qdf_nbuf_len(tx_desc->nbuf));
  3188. if (dp_tx_reinject_mlo_hdl(soc, vdev, tx_desc, nbuf, reinject_reason))
  3189. return;
  3190. #ifdef WDS_VENDOR_EXTENSION
  3191. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  3192. is_mcast = (IS_MULTICAST(wh->i_addr1)) ? 1 : 0;
  3193. } else {
  3194. is_mcast = (IS_MULTICAST(eth_hdr->ether_dhost)) ? 1 : 0;
  3195. }
  3196. is_ucast = !is_mcast;
  3197. qdf_spin_lock_bh(&vdev->peer_list_lock);
  3198. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3199. txrx_peer = dp_get_txrx_peer(peer);
  3200. if (!txrx_peer || txrx_peer->bss_peer)
  3201. continue;
  3202. /* Detect wds peers that use 3-addr framing for mcast.
  3203. * if there are any, the bss_peer is used to send the
  3204. * the mcast frame using 3-addr format. all wds enabled
  3205. * peers that use 4-addr framing for mcast frames will
  3206. * be duplicated and sent as 4-addr frames below.
  3207. */
  3208. if (!txrx_peer->wds_enabled ||
  3209. !txrx_peer->wds_ecm.wds_tx_mcast_4addr) {
  3210. num_peers_3addr = 1;
  3211. break;
  3212. }
  3213. }
  3214. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3215. #endif
  3216. if (qdf_unlikely(vdev->mesh_vdev)) {
  3217. DP_TX_FREE_SINGLE_BUF(vdev->pdev->soc, tx_desc->nbuf);
  3218. } else {
  3219. qdf_spin_lock_bh(&vdev->peer_list_lock);
  3220. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3221. txrx_peer = dp_get_txrx_peer(peer);
  3222. if (!txrx_peer)
  3223. continue;
  3224. if ((txrx_peer->peer_id != HTT_INVALID_PEER) &&
  3225. #ifdef WDS_VENDOR_EXTENSION
  3226. /*
  3227. * . if 3-addr STA, then send on BSS Peer
  3228. * . if Peer WDS enabled and accept 4-addr mcast,
  3229. * send mcast on that peer only
  3230. * . if Peer WDS enabled and accept 4-addr ucast,
  3231. * send ucast on that peer only
  3232. */
  3233. ((txrx_peer->bss_peer && num_peers_3addr && is_mcast) ||
  3234. (txrx_peer->wds_enabled &&
  3235. ((is_mcast && txrx_peer->wds_ecm.wds_tx_mcast_4addr) ||
  3236. (is_ucast &&
  3237. txrx_peer->wds_ecm.wds_tx_ucast_4addr))))) {
  3238. #else
  3239. (txrx_peer->bss_peer &&
  3240. (dp_tx_proxy_arp(vdev, nbuf) == QDF_STATUS_SUCCESS))) {
  3241. #endif
  3242. peer_id = DP_INVALID_PEER;
  3243. nbuf_copy = qdf_nbuf_copy(nbuf);
  3244. if (!nbuf_copy) {
  3245. dp_tx_debug("nbuf copy failed");
  3246. break;
  3247. }
  3248. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  3249. dp_tx_get_queue(vdev, nbuf,
  3250. &msdu_info.tx_queue);
  3251. nbuf_copy = dp_tx_send_msdu_single(vdev,
  3252. nbuf_copy,
  3253. &msdu_info,
  3254. peer_id,
  3255. NULL);
  3256. if (nbuf_copy) {
  3257. dp_tx_debug("pkt send failed");
  3258. qdf_nbuf_free(nbuf_copy);
  3259. }
  3260. }
  3261. }
  3262. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3263. }
  3264. qdf_nbuf_free(nbuf);
  3265. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3266. }
  3267. /**
  3268. * dp_tx_inspect_handler() - Tx Inspect Handler
  3269. * @soc: datapath soc handle
  3270. * @vdev: datapath vdev handle
  3271. * @tx_desc: software descriptor head pointer
  3272. * @status : Tx completion status from HTT descriptor
  3273. *
  3274. * Handles Tx frames sent back to Host for inspection
  3275. * (ProxyARP)
  3276. *
  3277. * Return: none
  3278. */
  3279. void dp_tx_inspect_handler(struct dp_soc *soc,
  3280. struct dp_vdev *vdev,
  3281. struct dp_tx_desc_s *tx_desc,
  3282. uint8_t *status)
  3283. {
  3284. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  3285. "%s Tx inspect path",
  3286. __func__);
  3287. DP_STATS_INC_PKT(vdev, tx_i.inspect_pkts, 1,
  3288. qdf_nbuf_len(tx_desc->nbuf));
  3289. DP_TX_FREE_SINGLE_BUF(soc, tx_desc->nbuf);
  3290. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3291. }
  3292. #ifdef MESH_MODE_SUPPORT
  3293. /**
  3294. * dp_tx_comp_fill_tx_completion_stats() - Fill per packet Tx completion stats
  3295. * in mesh meta header
  3296. * @tx_desc: software descriptor head pointer
  3297. * @ts: pointer to tx completion stats
  3298. * Return: none
  3299. */
  3300. static
  3301. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3302. struct hal_tx_completion_status *ts)
  3303. {
  3304. qdf_nbuf_t netbuf = tx_desc->nbuf;
  3305. if (!tx_desc->msdu_ext_desc) {
  3306. if (qdf_nbuf_pull_head(netbuf, tx_desc->pkt_offset) == NULL) {
  3307. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3308. "netbuf %pK offset %d",
  3309. netbuf, tx_desc->pkt_offset);
  3310. return;
  3311. }
  3312. }
  3313. }
  3314. #else
  3315. static
  3316. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3317. struct hal_tx_completion_status *ts)
  3318. {
  3319. }
  3320. #endif
  3321. #ifdef CONFIG_SAWF
  3322. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3323. struct dp_vdev *vdev,
  3324. struct dp_txrx_peer *txrx_peer,
  3325. struct dp_tx_desc_s *tx_desc,
  3326. struct hal_tx_completion_status *ts,
  3327. uint8_t tid)
  3328. {
  3329. dp_sawf_tx_compl_update_peer_stats(soc, vdev, txrx_peer, tx_desc,
  3330. ts, tid);
  3331. }
  3332. #else
  3333. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3334. struct dp_vdev *vdev,
  3335. struct dp_txrx_peer *txrx_peer,
  3336. struct dp_tx_desc_s *tx_desc,
  3337. struct hal_tx_completion_status *ts,
  3338. uint8_t tid)
  3339. {
  3340. }
  3341. #endif
  3342. #ifdef QCA_PEER_EXT_STATS
  3343. /*
  3344. * dp_tx_compute_tid_delay() - Compute per TID delay
  3345. * @stats: Per TID delay stats
  3346. * @tx_desc: Software Tx descriptor
  3347. *
  3348. * Compute the software enqueue and hw enqueue delays and
  3349. * update the respective histograms
  3350. *
  3351. * Return: void
  3352. */
  3353. static void dp_tx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  3354. struct dp_tx_desc_s *tx_desc)
  3355. {
  3356. struct cdp_delay_tx_stats *tx_delay = &stats->tx_delay;
  3357. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3358. uint32_t sw_enqueue_delay, fwhw_transmit_delay;
  3359. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3360. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3361. timestamp_hw_enqueue = qdf_ktime_to_ms(tx_desc->timestamp);
  3362. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3363. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3364. timestamp_hw_enqueue);
  3365. /*
  3366. * Update the Tx software enqueue delay and HW enque-Completion delay.
  3367. */
  3368. dp_hist_update_stats(&tx_delay->tx_swq_delay, sw_enqueue_delay);
  3369. dp_hist_update_stats(&tx_delay->hwtx_delay, fwhw_transmit_delay);
  3370. }
  3371. /*
  3372. * dp_tx_update_peer_delay_stats() - Update the peer delay stats
  3373. * @txrx_peer: DP peer context
  3374. * @tx_desc: Tx software descriptor
  3375. * @tid: Transmission ID
  3376. * @ring_id: Rx CPU context ID/CPU_ID
  3377. *
  3378. * Update the peer extended stats. These are enhanced other
  3379. * delay stats per msdu level.
  3380. *
  3381. * Return: void
  3382. */
  3383. static void dp_tx_update_peer_delay_stats(struct dp_txrx_peer *txrx_peer,
  3384. struct dp_tx_desc_s *tx_desc,
  3385. uint8_t tid, uint8_t ring_id)
  3386. {
  3387. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3388. struct dp_soc *soc = NULL;
  3389. struct dp_peer_delay_stats *delay_stats = NULL;
  3390. soc = pdev->soc;
  3391. if (qdf_likely(!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx)))
  3392. return;
  3393. delay_stats = txrx_peer->delay_stats;
  3394. qdf_assert(delay_stats);
  3395. qdf_assert(ring < CDP_MAX_TXRX_CTX);
  3396. /*
  3397. * For non-TID packets use the TID 9
  3398. */
  3399. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3400. tid = CDP_MAX_DATA_TIDS - 1;
  3401. dp_tx_compute_tid_delay(&delay_stats->delay_tid_stats[tid][ring_id],
  3402. tx_desc);
  3403. }
  3404. #else
  3405. static inline void dp_tx_update_peer_delay_stats(struct dp_txrx_peer *txrx_peer,
  3406. struct dp_tx_desc_s *tx_desc,
  3407. uint8_t tid, uint8_t ring_id)
  3408. {
  3409. }
  3410. #endif
  3411. #ifdef HW_TX_DELAY_STATS_ENABLE
  3412. /**
  3413. * dp_update_tx_delay_stats() - update the delay stats
  3414. * @vdev: vdev handle
  3415. * @delay: delay in ms or us based on the flag delay_in_us
  3416. * @tid: tid value
  3417. * @mode: type of tx delay mode
  3418. * @ring id: ring number
  3419. * @delay_in_us: flag to indicate whether the delay is in ms or us
  3420. *
  3421. * Return: none
  3422. */
  3423. static inline
  3424. void dp_update_tx_delay_stats(struct dp_vdev *vdev, uint32_t delay, uint8_t tid,
  3425. uint8_t mode, uint8_t ring_id, bool delay_in_us)
  3426. {
  3427. struct cdp_tid_tx_stats *tstats =
  3428. &vdev->stats.tid_tx_stats[ring_id][tid];
  3429. dp_update_delay_stats(tstats, NULL, delay, tid, mode, ring_id,
  3430. delay_in_us);
  3431. }
  3432. #else
  3433. static inline
  3434. void dp_update_tx_delay_stats(struct dp_vdev *vdev, uint32_t delay, uint8_t tid,
  3435. uint8_t mode, uint8_t ring_id, bool delay_in_us)
  3436. {
  3437. struct cdp_tid_tx_stats *tstats =
  3438. &vdev->pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
  3439. dp_update_delay_stats(tstats, NULL, delay, tid, mode, ring_id,
  3440. delay_in_us);
  3441. }
  3442. #endif
  3443. /**
  3444. * dp_tx_compute_delay() - Compute and fill in all timestamps
  3445. * to pass in correct fields
  3446. *
  3447. * @vdev: pdev handle
  3448. * @tx_desc: tx descriptor
  3449. * @tid: tid value
  3450. * @ring_id: TCL or WBM ring number for transmit path
  3451. * Return: none
  3452. */
  3453. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  3454. uint8_t tid, uint8_t ring_id)
  3455. {
  3456. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3457. uint32_t sw_enqueue_delay, fwhw_transmit_delay, interframe_delay;
  3458. uint32_t fwhw_transmit_delay_us;
  3459. if (qdf_likely(!vdev->pdev->delay_stats_flag) &&
  3460. qdf_likely(!dp_is_vdev_tx_delay_stats_enabled(vdev)))
  3461. return;
  3462. if (dp_is_vdev_tx_delay_stats_enabled(vdev)) {
  3463. fwhw_transmit_delay_us =
  3464. qdf_ktime_to_us(qdf_ktime_real_get()) -
  3465. qdf_ktime_to_us(tx_desc->timestamp);
  3466. /*
  3467. * Delay between packet enqueued to HW and Tx completion in us
  3468. */
  3469. dp_update_tx_delay_stats(vdev, fwhw_transmit_delay_us, tid,
  3470. CDP_DELAY_STATS_FW_HW_TRANSMIT,
  3471. ring_id, true);
  3472. /*
  3473. * For MCL, only enqueue to completion delay is required
  3474. * so return if the vdev flag is enabled.
  3475. */
  3476. return;
  3477. }
  3478. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3479. timestamp_hw_enqueue = qdf_ktime_to_ms(tx_desc->timestamp);
  3480. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3481. timestamp_hw_enqueue);
  3482. /*
  3483. * Delay between packet enqueued to HW and Tx completion in ms
  3484. */
  3485. dp_update_tx_delay_stats(vdev, fwhw_transmit_delay, tid,
  3486. CDP_DELAY_STATS_FW_HW_TRANSMIT, ring_id,
  3487. false);
  3488. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3489. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3490. interframe_delay = (uint32_t)(timestamp_ingress -
  3491. vdev->prev_tx_enq_tstamp);
  3492. /*
  3493. * Delay in software enqueue
  3494. */
  3495. dp_update_tx_delay_stats(vdev, sw_enqueue_delay, tid,
  3496. CDP_DELAY_STATS_SW_ENQ, ring_id,
  3497. false);
  3498. /*
  3499. * Update interframe delay stats calculated at hardstart receive point.
  3500. * Value of vdev->prev_tx_enq_tstamp will be 0 for 1st frame, so
  3501. * interframe delay will not be calculate correctly for 1st frame.
  3502. * On the other side, this will help in avoiding extra per packet check
  3503. * of !vdev->prev_tx_enq_tstamp.
  3504. */
  3505. dp_update_tx_delay_stats(vdev, interframe_delay, tid,
  3506. CDP_DELAY_STATS_TX_INTERFRAME, ring_id,
  3507. false);
  3508. vdev->prev_tx_enq_tstamp = timestamp_ingress;
  3509. }
  3510. #ifdef DISABLE_DP_STATS
  3511. static
  3512. inline void dp_update_no_ack_stats(qdf_nbuf_t nbuf,
  3513. struct dp_txrx_peer *txrx_peer)
  3514. {
  3515. }
  3516. #else
  3517. static inline void
  3518. dp_update_no_ack_stats(qdf_nbuf_t nbuf, struct dp_txrx_peer *txrx_peer)
  3519. {
  3520. enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
  3521. DPTRACE(qdf_dp_track_noack_check(nbuf, &subtype));
  3522. if (subtype != QDF_PROTO_INVALID)
  3523. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.no_ack_count[subtype],
  3524. 1);
  3525. }
  3526. #endif
  3527. #ifndef QCA_ENHANCED_STATS_SUPPORT
  3528. /**
  3529. * dp_tx_update_peer_extd_stats()- Update Tx extended path stats for peer
  3530. *
  3531. * @ts: Tx compltion status
  3532. * @txrx_peer: datapath txrx_peer handle
  3533. *
  3534. * Return: void
  3535. */
  3536. static inline void
  3537. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3538. struct dp_txrx_peer *txrx_peer)
  3539. {
  3540. uint8_t mcs, pkt_type, retry_threshold;
  3541. mcs = ts->mcs;
  3542. pkt_type = ts->pkt_type;
  3543. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3544. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3545. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A)));
  3546. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3547. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3548. ((mcs < (MAX_MCS_11A)) && (pkt_type == DOT11_A)));
  3549. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3550. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3551. ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3552. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3553. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3554. ((mcs < MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3555. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3556. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3557. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3558. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3559. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3560. ((mcs < MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3561. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3562. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3563. ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3564. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3565. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3566. ((mcs < MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3567. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3568. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3569. ((mcs >= (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3570. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3571. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3572. ((mcs < (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3573. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.sgi_count[ts->sgi], 1);
  3574. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.bw[ts->bw], 1);
  3575. DP_PEER_EXTD_STATS_UPD(txrx_peer, tx.last_ack_rssi, ts->ack_frame_rssi);
  3576. DP_PEER_EXTD_STATS_INC(txrx_peer,
  3577. tx.wme_ac_type[TID_TO_WME_AC(ts->tid)], 1);
  3578. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.stbc, 1, ts->stbc);
  3579. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.ldpc, 1, ts->ldpc);
  3580. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries, 1, ts->transmit_cnt > 1);
  3581. if (ts->first_msdu) {
  3582. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries_mpdu, 1,
  3583. ts->transmit_cnt > 1);
  3584. switch (ts->bw) {
  3585. case 0: /* 20Mhz */
  3586. case 1: /* 40Mhz */
  3587. case 2: /* 80Mhz */
  3588. retry_threshold = txrx_peer->mpdu_retry_threshold_1;
  3589. break;
  3590. default: /* 160Mhz */
  3591. retry_threshold = txrx_peer->mpdu_retry_threshold_2;
  3592. break;
  3593. }
  3594. if (!retry_threshold)
  3595. return;
  3596. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.mpdu_success_with_retries,
  3597. qdf_do_div(ts->transmit_cnt,
  3598. retry_threshold),
  3599. ts->transmit_cnt > retry_threshold);
  3600. }
  3601. }
  3602. #else
  3603. static inline void
  3604. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3605. struct dp_txrx_peer *txrx_peer)
  3606. {
  3607. }
  3608. #endif
  3609. /**
  3610. * dp_tx_update_peer_stats() - Update peer stats from Tx completion indications
  3611. * per wbm ring
  3612. *
  3613. * @tx_desc: software descriptor head pointer
  3614. * @ts: Tx completion status
  3615. * @peer: peer handle
  3616. * @ring_id: ring number
  3617. *
  3618. * Return: None
  3619. */
  3620. static inline void
  3621. dp_tx_update_peer_stats(struct dp_tx_desc_s *tx_desc,
  3622. struct hal_tx_completion_status *ts,
  3623. struct dp_txrx_peer *txrx_peer, uint8_t ring_id)
  3624. {
  3625. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3626. uint8_t tid = ts->tid;
  3627. uint32_t length;
  3628. struct cdp_tid_tx_stats *tid_stats;
  3629. if (!pdev)
  3630. return;
  3631. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3632. tid = CDP_MAX_DATA_TIDS - 1;
  3633. tid_stats = &pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
  3634. if (ts->release_src != HAL_TX_COMP_RELEASE_SOURCE_TQM) {
  3635. dp_err_rl("Release source:%d is not from TQM", ts->release_src);
  3636. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.release_src_not_tqm, 1);
  3637. return;
  3638. }
  3639. length = qdf_nbuf_len(tx_desc->nbuf);
  3640. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  3641. if (qdf_unlikely(pdev->delay_stats_flag) ||
  3642. qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(txrx_peer->vdev)))
  3643. dp_tx_compute_delay(txrx_peer->vdev, tx_desc, tid, ring_id);
  3644. if (ts->status < CDP_MAX_TX_TQM_STATUS) {
  3645. tid_stats->tqm_status_cnt[ts->status]++;
  3646. }
  3647. if (qdf_likely(ts->status == HAL_TX_TQM_RR_FRAME_ACKED)) {
  3648. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.retry_count, 1,
  3649. ts->transmit_cnt > 1);
  3650. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.multiple_retry_count,
  3651. 1, ts->transmit_cnt > 2);
  3652. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.ofdma, 1, ts->ofdma);
  3653. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.amsdu_cnt, 1,
  3654. ts->msdu_part_of_amsdu);
  3655. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.non_amsdu_cnt, 1,
  3656. !ts->msdu_part_of_amsdu);
  3657. txrx_peer->stats.per_pkt_stats.tx.last_tx_ts =
  3658. qdf_system_ticks();
  3659. dp_tx_update_peer_extd_stats(ts, txrx_peer);
  3660. return;
  3661. }
  3662. /*
  3663. * tx_failed is ideally supposed to be updated from HTT ppdu
  3664. * completion stats. But in IPQ807X/IPQ6018 chipsets owing to
  3665. * hw limitation there are no completions for failed cases.
  3666. * Hence updating tx_failed from data path. Please note that
  3667. * if tx_failed is fixed to be from ppdu, then this has to be
  3668. * removed
  3669. */
  3670. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  3671. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.failed_retry_count, 1,
  3672. ts->transmit_cnt > DP_RETRY_COUNT);
  3673. dp_update_no_ack_stats(tx_desc->nbuf, txrx_peer);
  3674. if (ts->status == HAL_TX_TQM_RR_REM_CMD_AGED) {
  3675. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.age_out, 1);
  3676. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_REM) {
  3677. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.dropped.fw_rem, 1,
  3678. length);
  3679. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_NOTX) {
  3680. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_notx, 1);
  3681. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TX) {
  3682. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_tx, 1);
  3683. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON1) {
  3684. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason1, 1);
  3685. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON2) {
  3686. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason2, 1);
  3687. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON3) {
  3688. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason3, 1);
  3689. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE) {
  3690. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3691. tx.dropped.fw_rem_queue_disable, 1);
  3692. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TILL_NONMATCHING) {
  3693. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3694. tx.dropped.fw_rem_no_match, 1);
  3695. } else if (ts->status == HAL_TX_TQM_RR_DROP_THRESHOLD) {
  3696. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3697. tx.dropped.drop_threshold, 1);
  3698. } else if (ts->status == HAL_TX_TQM_RR_LINK_DESC_UNAVAILABLE) {
  3699. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3700. tx.dropped.drop_link_desc_na, 1);
  3701. } else if (ts->status == HAL_TX_TQM_RR_DROP_OR_INVALID_MSDU) {
  3702. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3703. tx.dropped.invalid_drop, 1);
  3704. } else if (ts->status == HAL_TX_TQM_RR_MULTICAST_DROP) {
  3705. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3706. tx.dropped.mcast_vdev_drop, 1);
  3707. } else {
  3708. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.invalid_rr, 1);
  3709. }
  3710. }
  3711. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  3712. /**
  3713. * dp_tx_flow_pool_lock() - take flow pool lock
  3714. * @soc: core txrx main context
  3715. * @tx_desc: tx desc
  3716. *
  3717. * Return: None
  3718. */
  3719. static inline
  3720. void dp_tx_flow_pool_lock(struct dp_soc *soc,
  3721. struct dp_tx_desc_s *tx_desc)
  3722. {
  3723. struct dp_tx_desc_pool_s *pool;
  3724. uint8_t desc_pool_id;
  3725. desc_pool_id = tx_desc->pool_id;
  3726. pool = &soc->tx_desc[desc_pool_id];
  3727. qdf_spin_lock_bh(&pool->flow_pool_lock);
  3728. }
  3729. /**
  3730. * dp_tx_flow_pool_unlock() - release flow pool lock
  3731. * @soc: core txrx main context
  3732. * @tx_desc: tx desc
  3733. *
  3734. * Return: None
  3735. */
  3736. static inline
  3737. void dp_tx_flow_pool_unlock(struct dp_soc *soc,
  3738. struct dp_tx_desc_s *tx_desc)
  3739. {
  3740. struct dp_tx_desc_pool_s *pool;
  3741. uint8_t desc_pool_id;
  3742. desc_pool_id = tx_desc->pool_id;
  3743. pool = &soc->tx_desc[desc_pool_id];
  3744. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  3745. }
  3746. #else
  3747. static inline
  3748. void dp_tx_flow_pool_lock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3749. {
  3750. }
  3751. static inline
  3752. void dp_tx_flow_pool_unlock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3753. {
  3754. }
  3755. #endif
  3756. /**
  3757. * dp_tx_notify_completion() - Notify tx completion for this desc
  3758. * @soc: core txrx main context
  3759. * @vdev: datapath vdev handle
  3760. * @tx_desc: tx desc
  3761. * @netbuf: buffer
  3762. * @status: tx status
  3763. *
  3764. * Return: none
  3765. */
  3766. static inline void dp_tx_notify_completion(struct dp_soc *soc,
  3767. struct dp_vdev *vdev,
  3768. struct dp_tx_desc_s *tx_desc,
  3769. qdf_nbuf_t netbuf,
  3770. uint8_t status)
  3771. {
  3772. void *osif_dev;
  3773. ol_txrx_completion_fp tx_compl_cbk = NULL;
  3774. uint16_t flag = BIT(QDF_TX_RX_STATUS_DOWNLOAD_SUCC);
  3775. qdf_assert(tx_desc);
  3776. if (!vdev ||
  3777. !vdev->osif_vdev) {
  3778. return;
  3779. }
  3780. osif_dev = vdev->osif_vdev;
  3781. tx_compl_cbk = vdev->tx_comp;
  3782. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3783. flag |= BIT(QDF_TX_RX_STATUS_OK);
  3784. if (tx_compl_cbk)
  3785. tx_compl_cbk(netbuf, osif_dev, flag);
  3786. }
  3787. /** dp_tx_sojourn_stats_process() - Collect sojourn stats
  3788. * @pdev: pdev handle
  3789. * @tid: tid value
  3790. * @txdesc_ts: timestamp from txdesc
  3791. * @ppdu_id: ppdu id
  3792. *
  3793. * Return: none
  3794. */
  3795. #ifdef FEATURE_PERPKT_INFO
  3796. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3797. struct dp_txrx_peer *txrx_peer,
  3798. uint8_t tid,
  3799. uint64_t txdesc_ts,
  3800. uint32_t ppdu_id)
  3801. {
  3802. uint64_t delta_ms;
  3803. struct cdp_tx_sojourn_stats *sojourn_stats;
  3804. struct dp_peer *primary_link_peer = NULL;
  3805. struct dp_soc *link_peer_soc = NULL;
  3806. if (qdf_unlikely(!pdev->enhanced_stats_en))
  3807. return;
  3808. if (qdf_unlikely(tid == HTT_INVALID_TID ||
  3809. tid >= CDP_DATA_TID_MAX))
  3810. return;
  3811. if (qdf_unlikely(!pdev->sojourn_buf))
  3812. return;
  3813. primary_link_peer = dp_get_primary_link_peer_by_id(pdev->soc,
  3814. txrx_peer->peer_id,
  3815. DP_MOD_ID_TX_COMP);
  3816. if (qdf_unlikely(!primary_link_peer))
  3817. return;
  3818. sojourn_stats = (struct cdp_tx_sojourn_stats *)
  3819. qdf_nbuf_data(pdev->sojourn_buf);
  3820. link_peer_soc = primary_link_peer->vdev->pdev->soc;
  3821. sojourn_stats->cookie = (void *)
  3822. dp_monitor_peer_get_peerstats_ctx(link_peer_soc,
  3823. primary_link_peer);
  3824. delta_ms = qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3825. txdesc_ts;
  3826. qdf_ewma_tx_lag_add(&txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid],
  3827. delta_ms);
  3828. sojourn_stats->sum_sojourn_msdu[tid] = delta_ms;
  3829. sojourn_stats->num_msdus[tid] = 1;
  3830. sojourn_stats->avg_sojourn_msdu[tid].internal =
  3831. txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid].internal;
  3832. dp_wdi_event_handler(WDI_EVENT_TX_SOJOURN_STAT, pdev->soc,
  3833. pdev->sojourn_buf, HTT_INVALID_PEER,
  3834. WDI_NO_VAL, pdev->pdev_id);
  3835. sojourn_stats->sum_sojourn_msdu[tid] = 0;
  3836. sojourn_stats->num_msdus[tid] = 0;
  3837. sojourn_stats->avg_sojourn_msdu[tid].internal = 0;
  3838. dp_peer_unref_delete(primary_link_peer, DP_MOD_ID_TX_COMP);
  3839. }
  3840. #else
  3841. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3842. struct dp_txrx_peer *txrx_peer,
  3843. uint8_t tid,
  3844. uint64_t txdesc_ts,
  3845. uint32_t ppdu_id)
  3846. {
  3847. }
  3848. #endif
  3849. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  3850. /**
  3851. * dp_send_completion_to_pkt_capture() - send tx completion to packet capture
  3852. * @soc: dp_soc handle
  3853. * @desc: Tx Descriptor
  3854. * @ts: HAL Tx completion descriptor contents
  3855. *
  3856. * This function is used to send tx completion to packet capture
  3857. */
  3858. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  3859. struct dp_tx_desc_s *desc,
  3860. struct hal_tx_completion_status *ts)
  3861. {
  3862. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_TX_DATA, soc,
  3863. desc, ts->peer_id,
  3864. WDI_NO_VAL, desc->pdev->pdev_id);
  3865. }
  3866. #endif
  3867. /**
  3868. * dp_tx_comp_process_desc() - Process tx descriptor and free associated nbuf
  3869. * @soc: DP Soc handle
  3870. * @tx_desc: software Tx descriptor
  3871. * @ts : Tx completion status from HAL/HTT descriptor
  3872. *
  3873. * Return: none
  3874. */
  3875. void
  3876. dp_tx_comp_process_desc(struct dp_soc *soc,
  3877. struct dp_tx_desc_s *desc,
  3878. struct hal_tx_completion_status *ts,
  3879. struct dp_txrx_peer *txrx_peer)
  3880. {
  3881. uint64_t time_latency = 0;
  3882. uint16_t peer_id = DP_INVALID_PEER_ID;
  3883. /*
  3884. * m_copy/tx_capture modes are not supported for
  3885. * scatter gather packets
  3886. */
  3887. if (qdf_unlikely(!!desc->pdev->latency_capture_enable)) {
  3888. time_latency = (qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3889. qdf_ktime_to_ms(desc->timestamp));
  3890. }
  3891. dp_send_completion_to_pkt_capture(soc, desc, ts);
  3892. if (dp_tx_pkt_tracepoints_enabled())
  3893. qdf_trace_dp_packet(desc->nbuf, QDF_TX,
  3894. desc->msdu_ext_desc ?
  3895. desc->msdu_ext_desc->tso_desc : NULL,
  3896. qdf_ktime_to_ms(desc->timestamp));
  3897. if (!(desc->msdu_ext_desc)) {
  3898. dp_tx_enh_unmap(soc, desc);
  3899. if (txrx_peer)
  3900. peer_id = txrx_peer->peer_id;
  3901. if (QDF_STATUS_SUCCESS ==
  3902. dp_monitor_tx_add_to_comp_queue(soc, desc, ts, peer_id)) {
  3903. return;
  3904. }
  3905. if (QDF_STATUS_SUCCESS ==
  3906. dp_get_completion_indication_for_stack(soc,
  3907. desc->pdev,
  3908. txrx_peer, ts,
  3909. desc->nbuf,
  3910. time_latency)) {
  3911. dp_send_completion_to_stack(soc,
  3912. desc->pdev,
  3913. ts->peer_id,
  3914. ts->ppdu_id,
  3915. desc->nbuf);
  3916. return;
  3917. }
  3918. }
  3919. desc->flags |= DP_TX_DESC_FLAG_COMPLETED_TX;
  3920. dp_tx_comp_free_buf(soc, desc);
  3921. }
  3922. #ifdef DISABLE_DP_STATS
  3923. /**
  3924. * dp_tx_update_connectivity_stats() - update tx connectivity stats
  3925. * @soc: core txrx main context
  3926. * @tx_desc: tx desc
  3927. * @status: tx status
  3928. *
  3929. * Return: none
  3930. */
  3931. static inline
  3932. void dp_tx_update_connectivity_stats(struct dp_soc *soc,
  3933. struct dp_vdev *vdev,
  3934. struct dp_tx_desc_s *tx_desc,
  3935. uint8_t status)
  3936. {
  3937. }
  3938. #else
  3939. static inline
  3940. void dp_tx_update_connectivity_stats(struct dp_soc *soc,
  3941. struct dp_vdev *vdev,
  3942. struct dp_tx_desc_s *tx_desc,
  3943. uint8_t status)
  3944. {
  3945. void *osif_dev;
  3946. ol_txrx_stats_rx_fp stats_cbk;
  3947. uint8_t pkt_type;
  3948. qdf_assert(tx_desc);
  3949. if (!vdev ||
  3950. !vdev->osif_vdev ||
  3951. !vdev->stats_cb)
  3952. return;
  3953. osif_dev = vdev->osif_vdev;
  3954. stats_cbk = vdev->stats_cb;
  3955. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_HOST_FW_SENT, &pkt_type);
  3956. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3957. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_ACK_CNT,
  3958. &pkt_type);
  3959. }
  3960. #endif
  3961. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(CONFIG_SAWF)
  3962. QDF_STATUS
  3963. dp_tx_compute_hw_delay_us(struct hal_tx_completion_status *ts,
  3964. uint32_t delta_tsf,
  3965. uint32_t *delay_us)
  3966. {
  3967. uint32_t buffer_ts;
  3968. uint32_t delay;
  3969. if (!delay_us)
  3970. return QDF_STATUS_E_INVAL;
  3971. /* Tx_rate_stats_info_valid is 0 and tsf is invalid then */
  3972. if (!ts->valid)
  3973. return QDF_STATUS_E_INVAL;
  3974. /* buffer_timestamp is in units of 1024 us and is [31:13] of
  3975. * WBM_RELEASE_RING_4. After left shift 10 bits, it's
  3976. * valid up to 29 bits.
  3977. */
  3978. buffer_ts = ts->buffer_timestamp << 10;
  3979. delay = ts->tsf - buffer_ts - delta_tsf;
  3980. delay &= 0x1FFFFFFF; /* mask 29 BITS */
  3981. if (delay > 0x1000000) {
  3982. dp_info_rl("----------------------\n"
  3983. "Tx completion status:\n"
  3984. "----------------------\n"
  3985. "release_src = %d\n"
  3986. "ppdu_id = 0x%x\n"
  3987. "release_reason = %d\n"
  3988. "tsf = %u (0x%x)\n"
  3989. "buffer_timestamp = %u (0x%x)\n"
  3990. "delta_tsf = %u (0x%x)\n",
  3991. ts->release_src, ts->ppdu_id, ts->status,
  3992. ts->tsf, ts->tsf, ts->buffer_timestamp,
  3993. ts->buffer_timestamp, delta_tsf, delta_tsf);
  3994. return QDF_STATUS_E_FAILURE;
  3995. }
  3996. *delay_us = delay;
  3997. return QDF_STATUS_SUCCESS;
  3998. }
  3999. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4000. uint32_t delta_tsf)
  4001. {
  4002. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4003. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  4004. DP_MOD_ID_CDP);
  4005. if (!vdev) {
  4006. dp_err_rl("vdev %d does not exist", vdev_id);
  4007. return;
  4008. }
  4009. vdev->delta_tsf = delta_tsf;
  4010. dp_debug("vdev id %u delta_tsf %u", vdev_id, delta_tsf);
  4011. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4012. }
  4013. #endif
  4014. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  4015. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  4016. uint8_t vdev_id, bool enable)
  4017. {
  4018. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4019. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  4020. DP_MOD_ID_CDP);
  4021. if (!vdev) {
  4022. dp_err_rl("vdev %d does not exist", vdev_id);
  4023. return QDF_STATUS_E_FAILURE;
  4024. }
  4025. qdf_atomic_set(&vdev->ul_delay_report, enable);
  4026. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4027. return QDF_STATUS_SUCCESS;
  4028. }
  4029. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4030. uint32_t *val)
  4031. {
  4032. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4033. struct dp_vdev *vdev;
  4034. uint32_t delay_accum;
  4035. uint32_t pkts_accum;
  4036. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_CDP);
  4037. if (!vdev) {
  4038. dp_err_rl("vdev %d does not exist", vdev_id);
  4039. return QDF_STATUS_E_FAILURE;
  4040. }
  4041. if (!qdf_atomic_read(&vdev->ul_delay_report)) {
  4042. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4043. return QDF_STATUS_E_FAILURE;
  4044. }
  4045. /* Average uplink delay based on current accumulated values */
  4046. delay_accum = qdf_atomic_read(&vdev->ul_delay_accum);
  4047. pkts_accum = qdf_atomic_read(&vdev->ul_pkts_accum);
  4048. *val = delay_accum / pkts_accum;
  4049. dp_debug("uplink_delay %u delay_accum %u pkts_accum %u", *val,
  4050. delay_accum, pkts_accum);
  4051. /* Reset accumulated values to 0 */
  4052. qdf_atomic_set(&vdev->ul_delay_accum, 0);
  4053. qdf_atomic_set(&vdev->ul_pkts_accum, 0);
  4054. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4055. return QDF_STATUS_SUCCESS;
  4056. }
  4057. static void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  4058. struct hal_tx_completion_status *ts)
  4059. {
  4060. uint32_t ul_delay;
  4061. if (qdf_unlikely(!vdev)) {
  4062. dp_info_rl("vdev is null or delete in progrss");
  4063. return;
  4064. }
  4065. if (!qdf_atomic_read(&vdev->ul_delay_report))
  4066. return;
  4067. if (QDF_IS_STATUS_ERROR(dp_tx_compute_hw_delay_us(ts,
  4068. vdev->delta_tsf,
  4069. &ul_delay)))
  4070. return;
  4071. ul_delay /= 1000; /* in unit of ms */
  4072. qdf_atomic_add(ul_delay, &vdev->ul_delay_accum);
  4073. qdf_atomic_inc(&vdev->ul_pkts_accum);
  4074. }
  4075. #else /* !WLAN_FEATURE_TSF_UPLINK_DELAY */
  4076. static inline
  4077. void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  4078. struct hal_tx_completion_status *ts)
  4079. {
  4080. }
  4081. #endif /* WLAN_FEATURE_TSF_UPLINK_DELAY */
  4082. /**
  4083. * dp_tx_comp_process_tx_status() - Parse and Dump Tx completion status info
  4084. * @soc: DP soc handle
  4085. * @tx_desc: software descriptor head pointer
  4086. * @ts: Tx completion status
  4087. * @txrx_peer: txrx peer handle
  4088. * @ring_id: ring number
  4089. *
  4090. * Return: none
  4091. */
  4092. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  4093. struct dp_tx_desc_s *tx_desc,
  4094. struct hal_tx_completion_status *ts,
  4095. struct dp_txrx_peer *txrx_peer,
  4096. uint8_t ring_id)
  4097. {
  4098. uint32_t length;
  4099. qdf_ether_header_t *eh;
  4100. struct dp_vdev *vdev = NULL;
  4101. qdf_nbuf_t nbuf = tx_desc->nbuf;
  4102. enum qdf_dp_tx_rx_status dp_status;
  4103. if (!nbuf) {
  4104. dp_info_rl("invalid tx descriptor. nbuf NULL");
  4105. goto out;
  4106. }
  4107. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  4108. length = qdf_nbuf_len(nbuf);
  4109. dp_status = dp_tx_hw_to_qdf(ts->status);
  4110. DPTRACE(qdf_dp_trace_ptr(tx_desc->nbuf,
  4111. QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD,
  4112. QDF_TRACE_DEFAULT_PDEV_ID,
  4113. qdf_nbuf_data_addr(nbuf),
  4114. sizeof(qdf_nbuf_data(nbuf)),
  4115. tx_desc->id, ts->status, dp_status));
  4116. dp_tx_comp_debug("-------------------- \n"
  4117. "Tx Completion Stats: \n"
  4118. "-------------------- \n"
  4119. "ack_frame_rssi = %d \n"
  4120. "first_msdu = %d \n"
  4121. "last_msdu = %d \n"
  4122. "msdu_part_of_amsdu = %d \n"
  4123. "rate_stats valid = %d \n"
  4124. "bw = %d \n"
  4125. "pkt_type = %d \n"
  4126. "stbc = %d \n"
  4127. "ldpc = %d \n"
  4128. "sgi = %d \n"
  4129. "mcs = %d \n"
  4130. "ofdma = %d \n"
  4131. "tones_in_ru = %d \n"
  4132. "tsf = %d \n"
  4133. "ppdu_id = %d \n"
  4134. "transmit_cnt = %d \n"
  4135. "tid = %d \n"
  4136. "peer_id = %d\n"
  4137. "tx_status = %d\n",
  4138. ts->ack_frame_rssi, ts->first_msdu,
  4139. ts->last_msdu, ts->msdu_part_of_amsdu,
  4140. ts->valid, ts->bw, ts->pkt_type, ts->stbc,
  4141. ts->ldpc, ts->sgi, ts->mcs, ts->ofdma,
  4142. ts->tones_in_ru, ts->tsf, ts->ppdu_id,
  4143. ts->transmit_cnt, ts->tid, ts->peer_id,
  4144. ts->status);
  4145. /* Update SoC level stats */
  4146. DP_STATS_INCC(soc, tx.dropped_fw_removed, 1,
  4147. (ts->status == HAL_TX_TQM_RR_REM_CMD_REM));
  4148. if (!txrx_peer) {
  4149. dp_info_rl("peer is null or deletion in progress");
  4150. DP_STATS_INC_PKT(soc, tx.tx_invalid_peer, 1, length);
  4151. goto out;
  4152. }
  4153. vdev = txrx_peer->vdev;
  4154. dp_tx_update_connectivity_stats(soc, vdev, tx_desc, ts->status);
  4155. dp_tx_update_uplink_delay(soc, vdev, ts);
  4156. /* check tx complete notification */
  4157. if (qdf_nbuf_tx_notify_comp_get(nbuf))
  4158. dp_tx_notify_completion(soc, vdev, tx_desc,
  4159. nbuf, ts->status);
  4160. /* Update per-packet stats for mesh mode */
  4161. if (qdf_unlikely(vdev->mesh_vdev) &&
  4162. !(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW))
  4163. dp_tx_comp_fill_tx_completion_stats(tx_desc, ts);
  4164. /* Update peer level stats */
  4165. if (qdf_unlikely(txrx_peer->bss_peer &&
  4166. vdev->opmode == wlan_op_mode_ap)) {
  4167. if (ts->status != HAL_TX_TQM_RR_REM_CMD_REM) {
  4168. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.mcast, 1,
  4169. length);
  4170. if (txrx_peer->vdev->tx_encap_type ==
  4171. htt_cmn_pkt_type_ethernet &&
  4172. QDF_IS_ADDR_BROADCAST(eh->ether_dhost)) {
  4173. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4174. tx.bcast, 1,
  4175. length);
  4176. }
  4177. }
  4178. } else {
  4179. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.ucast, 1, length);
  4180. if (ts->status == HAL_TX_TQM_RR_FRAME_ACKED) {
  4181. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.tx_success,
  4182. 1, length);
  4183. if (qdf_unlikely(txrx_peer->in_twt)) {
  4184. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4185. tx.tx_success_twt,
  4186. 1, length);
  4187. }
  4188. }
  4189. }
  4190. dp_tx_update_peer_stats(tx_desc, ts, txrx_peer, ring_id);
  4191. dp_tx_update_peer_delay_stats(txrx_peer, tx_desc, ts->tid, ring_id);
  4192. dp_tx_update_peer_sawf_stats(soc, vdev, txrx_peer, tx_desc,
  4193. ts, ts->tid);
  4194. #ifdef QCA_SUPPORT_RDK_STATS
  4195. if (soc->peerstats_enabled)
  4196. dp_tx_sojourn_stats_process(vdev->pdev, txrx_peer, ts->tid,
  4197. qdf_ktime_to_ms(tx_desc->timestamp),
  4198. ts->ppdu_id);
  4199. #endif
  4200. out:
  4201. return;
  4202. }
  4203. #if defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT) && \
  4204. defined(QCA_ENHANCED_STATS_SUPPORT)
  4205. /*
  4206. * dp_tx_update_peer_basic_stats(): Update peer basic stats
  4207. * @txrx_peer: Datapath txrx_peer handle
  4208. * @length: Length of the packet
  4209. * @tx_status: Tx status from TQM/FW
  4210. * @update: enhanced flag value present in dp_pdev
  4211. *
  4212. * Return: none
  4213. */
  4214. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4215. uint32_t length, uint8_t tx_status,
  4216. bool update)
  4217. {
  4218. if ((!txrx_peer->hw_txrx_stats_en) || update) {
  4219. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4220. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4221. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4222. }
  4223. }
  4224. #elif defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT)
  4225. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4226. uint32_t length, uint8_t tx_status,
  4227. bool update)
  4228. {
  4229. if (!peer->hw_txrx_stats_en) {
  4230. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4231. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4232. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4233. }
  4234. }
  4235. #else
  4236. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4237. uint32_t length, uint8_t tx_status,
  4238. bool update)
  4239. {
  4240. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4241. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4242. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4243. }
  4244. #endif
  4245. /*
  4246. * dp_tx_prefetch_next_nbuf_data(): Prefetch nbuf and nbuf data
  4247. * @nbuf: skb buffer
  4248. *
  4249. * Return: none
  4250. */
  4251. #ifdef QCA_DP_RX_NBUF_AND_NBUF_DATA_PREFETCH
  4252. static inline
  4253. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4254. {
  4255. qdf_nbuf_t nbuf = NULL;
  4256. if (next)
  4257. nbuf = next->nbuf;
  4258. if (nbuf) {
  4259. /* prefetch skb->next and first few bytes of skb->cb */
  4260. qdf_prefetch(nbuf);
  4261. /* prefetch skb fields present in different cachelines */
  4262. qdf_prefetch(&nbuf->len);
  4263. qdf_prefetch(&nbuf->users);
  4264. }
  4265. }
  4266. #else
  4267. static inline
  4268. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4269. {
  4270. }
  4271. #endif
  4272. /**
  4273. * dp_tx_mcast_reinject_handler() - Tx reinjected multicast packets handler
  4274. * @soc: core txrx main context
  4275. * @desc: software descriptor
  4276. *
  4277. * Return: true when packet is reinjected
  4278. */
  4279. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) && \
  4280. defined(WLAN_MCAST_MLO)
  4281. static inline bool
  4282. dp_tx_mcast_reinject_handler(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  4283. {
  4284. struct dp_vdev *vdev = NULL;
  4285. if (desc->tx_status == HAL_TX_TQM_RR_MULTICAST_DROP) {
  4286. if (!soc->arch_ops.dp_tx_mcast_handler)
  4287. return false;
  4288. vdev = dp_vdev_get_ref_by_id(soc, desc->vdev_id,
  4289. DP_MOD_ID_REINJECT);
  4290. if (qdf_unlikely(!vdev)) {
  4291. dp_tx_comp_info_rl("Unable to get vdev ref %d",
  4292. desc->id);
  4293. return false;
  4294. }
  4295. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  4296. qdf_nbuf_len(desc->nbuf));
  4297. soc->arch_ops.dp_tx_mcast_handler(soc, vdev, desc->nbuf);
  4298. dp_tx_desc_release(desc, desc->pool_id);
  4299. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_REINJECT);
  4300. return true;
  4301. }
  4302. return false;
  4303. }
  4304. #else
  4305. static inline bool
  4306. dp_tx_mcast_reinject_handler(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  4307. {
  4308. return false;
  4309. }
  4310. #endif
  4311. /**
  4312. * dp_tx_comp_process_desc_list() - Tx complete software descriptor handler
  4313. * @soc: core txrx main context
  4314. * @comp_head: software descriptor head pointer
  4315. * @ring_id: ring number
  4316. *
  4317. * This function will process batch of descriptors reaped by dp_tx_comp_handler
  4318. * and release the software descriptors after processing is complete
  4319. *
  4320. * Return: none
  4321. */
  4322. static void
  4323. dp_tx_comp_process_desc_list(struct dp_soc *soc,
  4324. struct dp_tx_desc_s *comp_head, uint8_t ring_id)
  4325. {
  4326. struct dp_tx_desc_s *desc;
  4327. struct dp_tx_desc_s *next;
  4328. struct hal_tx_completion_status ts;
  4329. struct dp_txrx_peer *txrx_peer = NULL;
  4330. uint16_t peer_id = DP_INVALID_PEER;
  4331. dp_txrx_ref_handle txrx_ref_handle = NULL;
  4332. desc = comp_head;
  4333. while (desc) {
  4334. next = desc->next;
  4335. dp_tx_prefetch_next_nbuf_data(next);
  4336. if (peer_id != desc->peer_id) {
  4337. if (txrx_peer)
  4338. dp_txrx_peer_unref_delete(txrx_ref_handle,
  4339. DP_MOD_ID_TX_COMP);
  4340. peer_id = desc->peer_id;
  4341. txrx_peer =
  4342. dp_txrx_peer_get_ref_by_id(soc, peer_id,
  4343. &txrx_ref_handle,
  4344. DP_MOD_ID_TX_COMP);
  4345. }
  4346. if (dp_tx_mcast_reinject_handler(soc, desc)) {
  4347. desc = next;
  4348. continue;
  4349. }
  4350. if (qdf_likely(desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  4351. struct dp_pdev *pdev = desc->pdev;
  4352. if (qdf_likely(txrx_peer))
  4353. dp_tx_update_peer_basic_stats(txrx_peer,
  4354. desc->length,
  4355. desc->tx_status,
  4356. false);
  4357. qdf_assert(pdev);
  4358. dp_tx_outstanding_dec(pdev);
  4359. /*
  4360. * Calling a QDF WRAPPER here is creating signifcant
  4361. * performance impact so avoided the wrapper call here
  4362. */
  4363. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  4364. desc->id, DP_TX_COMP_UNMAP);
  4365. dp_tx_nbuf_unmap(soc, desc);
  4366. qdf_nbuf_free(desc->nbuf);
  4367. dp_tx_desc_free(soc, desc, desc->pool_id);
  4368. desc = next;
  4369. continue;
  4370. }
  4371. hal_tx_comp_get_status(&desc->comp, &ts, soc->hal_soc);
  4372. dp_tx_comp_process_tx_status(soc, desc, &ts, txrx_peer,
  4373. ring_id);
  4374. dp_tx_comp_process_desc(soc, desc, &ts, txrx_peer);
  4375. dp_tx_desc_release(desc, desc->pool_id);
  4376. desc = next;
  4377. }
  4378. if (txrx_peer)
  4379. dp_txrx_peer_unref_delete(txrx_ref_handle, DP_MOD_ID_TX_COMP);
  4380. }
  4381. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  4382. static inline
  4383. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4384. int max_reap_limit)
  4385. {
  4386. bool limit_hit = false;
  4387. limit_hit =
  4388. (num_reaped >= max_reap_limit) ? true : false;
  4389. if (limit_hit)
  4390. DP_STATS_INC(soc, tx.tx_comp_loop_pkt_limit_hit, 1);
  4391. return limit_hit;
  4392. }
  4393. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4394. {
  4395. return soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check;
  4396. }
  4397. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4398. {
  4399. struct wlan_cfg_dp_soc_ctxt *cfg = soc->wlan_cfg_ctx;
  4400. return cfg->tx_comp_loop_pkt_limit;
  4401. }
  4402. #else
  4403. static inline
  4404. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4405. int max_reap_limit)
  4406. {
  4407. return false;
  4408. }
  4409. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4410. {
  4411. return false;
  4412. }
  4413. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4414. {
  4415. return 0;
  4416. }
  4417. #endif
  4418. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  4419. static inline int
  4420. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4421. int *max_reap_limit)
  4422. {
  4423. return soc->arch_ops.dp_srng_test_and_update_nf_params(soc, dp_srng,
  4424. max_reap_limit);
  4425. }
  4426. #else
  4427. static inline int
  4428. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4429. int *max_reap_limit)
  4430. {
  4431. return 0;
  4432. }
  4433. #endif
  4434. #ifdef DP_TX_TRACKING
  4435. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  4436. {
  4437. if ((tx_desc->magic != DP_TX_MAGIC_PATTERN_INUSE) &&
  4438. (tx_desc->magic != DP_TX_MAGIC_PATTERN_FREE)) {
  4439. dp_err_rl("tx_desc %u is corrupted", tx_desc->id);
  4440. qdf_trigger_self_recovery(NULL, QDF_TX_DESC_LEAK);
  4441. }
  4442. }
  4443. #endif
  4444. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  4445. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  4446. uint32_t quota)
  4447. {
  4448. void *tx_comp_hal_desc;
  4449. void *last_prefetched_hw_desc = NULL;
  4450. struct dp_tx_desc_s *last_prefetched_sw_desc = NULL;
  4451. hal_soc_handle_t hal_soc;
  4452. uint8_t buffer_src;
  4453. struct dp_tx_desc_s *tx_desc = NULL;
  4454. struct dp_tx_desc_s *head_desc = NULL;
  4455. struct dp_tx_desc_s *tail_desc = NULL;
  4456. uint32_t num_processed = 0;
  4457. uint32_t count;
  4458. uint32_t num_avail_for_reap = 0;
  4459. bool force_break = false;
  4460. struct dp_srng *tx_comp_ring = &soc->tx_comp_ring[ring_id];
  4461. int max_reap_limit, ring_near_full;
  4462. DP_HIST_INIT();
  4463. more_data:
  4464. hal_soc = soc->hal_soc;
  4465. /* Re-initialize local variables to be re-used */
  4466. head_desc = NULL;
  4467. tail_desc = NULL;
  4468. count = 0;
  4469. max_reap_limit = dp_tx_comp_get_loop_pkt_limit(soc);
  4470. ring_near_full = dp_srng_test_and_update_nf_params(soc, tx_comp_ring,
  4471. &max_reap_limit);
  4472. if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, hal_ring_hdl))) {
  4473. dp_err("HAL RING Access Failed -- %pK", hal_ring_hdl);
  4474. return 0;
  4475. }
  4476. num_avail_for_reap = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, 0);
  4477. if (num_avail_for_reap >= quota)
  4478. num_avail_for_reap = quota;
  4479. dp_srng_dst_inv_cached_descs(soc, hal_ring_hdl, num_avail_for_reap);
  4480. last_prefetched_hw_desc = dp_srng_dst_prefetch(hal_soc, hal_ring_hdl,
  4481. num_avail_for_reap);
  4482. /* Find head descriptor from completion ring */
  4483. while (qdf_likely(num_avail_for_reap--)) {
  4484. tx_comp_hal_desc = dp_srng_dst_get_next(soc, hal_ring_hdl);
  4485. if (qdf_unlikely(!tx_comp_hal_desc))
  4486. break;
  4487. buffer_src = hal_tx_comp_get_buffer_source(hal_soc,
  4488. tx_comp_hal_desc);
  4489. /* If this buffer was not released by TQM or FW, then it is not
  4490. * Tx completion indication, assert */
  4491. if (qdf_unlikely(buffer_src !=
  4492. HAL_TX_COMP_RELEASE_SOURCE_TQM) &&
  4493. (qdf_unlikely(buffer_src !=
  4494. HAL_TX_COMP_RELEASE_SOURCE_FW))) {
  4495. uint8_t wbm_internal_error;
  4496. dp_err_rl(
  4497. "Tx comp release_src != TQM | FW but from %d",
  4498. buffer_src);
  4499. hal_dump_comp_desc(tx_comp_hal_desc);
  4500. DP_STATS_INC(soc, tx.invalid_release_source, 1);
  4501. /* When WBM sees NULL buffer_addr_info in any of
  4502. * ingress rings it sends an error indication,
  4503. * with wbm_internal_error=1, to a specific ring.
  4504. * The WBM2SW ring used to indicate these errors is
  4505. * fixed in HW, and that ring is being used as Tx
  4506. * completion ring. These errors are not related to
  4507. * Tx completions, and should just be ignored
  4508. */
  4509. wbm_internal_error = hal_get_wbm_internal_error(
  4510. hal_soc,
  4511. tx_comp_hal_desc);
  4512. if (wbm_internal_error) {
  4513. dp_err_rl("Tx comp wbm_internal_error!!");
  4514. DP_STATS_INC(soc, tx.wbm_internal_error[WBM_INT_ERROR_ALL], 1);
  4515. if (HAL_TX_COMP_RELEASE_SOURCE_REO ==
  4516. buffer_src)
  4517. dp_handle_wbm_internal_error(
  4518. soc,
  4519. tx_comp_hal_desc,
  4520. hal_tx_comp_get_buffer_type(
  4521. tx_comp_hal_desc));
  4522. } else {
  4523. dp_err_rl("Tx comp wbm_internal_error false");
  4524. DP_STATS_INC(soc, tx.non_wbm_internal_err, 1);
  4525. }
  4526. continue;
  4527. }
  4528. soc->arch_ops.tx_comp_get_params_from_hal_desc(soc,
  4529. tx_comp_hal_desc,
  4530. &tx_desc);
  4531. if (!tx_desc) {
  4532. dp_err("unable to retrieve tx_desc!");
  4533. QDF_BUG(0);
  4534. continue;
  4535. }
  4536. tx_desc->buffer_src = buffer_src;
  4537. /*
  4538. * If the release source is FW, process the HTT status
  4539. */
  4540. if (qdf_unlikely(buffer_src ==
  4541. HAL_TX_COMP_RELEASE_SOURCE_FW)) {
  4542. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  4543. hal_tx_comp_get_htt_desc(tx_comp_hal_desc,
  4544. htt_tx_status);
  4545. /* Collect hw completion contents */
  4546. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4547. &tx_desc->comp, 1);
  4548. soc->arch_ops.dp_tx_process_htt_completion(
  4549. soc,
  4550. tx_desc,
  4551. htt_tx_status,
  4552. ring_id);
  4553. } else {
  4554. tx_desc->tx_status =
  4555. hal_tx_comp_get_tx_status(tx_comp_hal_desc);
  4556. tx_desc->buffer_src = buffer_src;
  4557. /*
  4558. * If the fast completion mode is enabled extended
  4559. * metadata from descriptor is not copied
  4560. */
  4561. if (qdf_likely(tx_desc->flags &
  4562. DP_TX_DESC_FLAG_SIMPLE))
  4563. goto add_to_pool;
  4564. /*
  4565. * If the descriptor is already freed in vdev_detach,
  4566. * continue to next descriptor
  4567. */
  4568. if (qdf_unlikely
  4569. ((tx_desc->vdev_id == DP_INVALID_VDEV_ID) &&
  4570. !tx_desc->flags)) {
  4571. dp_tx_comp_info_rl("Descriptor freed in vdev_detach %d",
  4572. tx_desc->id);
  4573. DP_STATS_INC(soc, tx.tx_comp_exception, 1);
  4574. dp_tx_desc_check_corruption(tx_desc);
  4575. continue;
  4576. }
  4577. if (qdf_unlikely(tx_desc->pdev->is_pdev_down)) {
  4578. dp_tx_comp_info_rl("pdev in down state %d",
  4579. tx_desc->id);
  4580. tx_desc->flags |= DP_TX_DESC_FLAG_TX_COMP_ERR;
  4581. dp_tx_comp_free_buf(soc, tx_desc);
  4582. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  4583. goto next_desc;
  4584. }
  4585. if (!(tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED) ||
  4586. !(tx_desc->flags & DP_TX_DESC_FLAG_QUEUED_TX)) {
  4587. dp_tx_comp_alert("Txdesc invalid, flgs = %x,id = %d",
  4588. tx_desc->flags, tx_desc->id);
  4589. qdf_assert_always(0);
  4590. }
  4591. /* Collect hw completion contents */
  4592. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4593. &tx_desc->comp, 1);
  4594. add_to_pool:
  4595. DP_HIST_PACKET_COUNT_INC(tx_desc->pdev->pdev_id);
  4596. /* First ring descriptor on the cycle */
  4597. if (!head_desc) {
  4598. head_desc = tx_desc;
  4599. tail_desc = tx_desc;
  4600. }
  4601. tail_desc->next = tx_desc;
  4602. tx_desc->next = NULL;
  4603. tail_desc = tx_desc;
  4604. }
  4605. next_desc:
  4606. num_processed += !(count & DP_TX_NAPI_BUDGET_DIV_MASK);
  4607. /*
  4608. * Processed packet count is more than given quota
  4609. * stop to processing
  4610. */
  4611. count++;
  4612. dp_tx_prefetch_hw_sw_nbuf_desc(soc, hal_soc,
  4613. num_avail_for_reap,
  4614. hal_ring_hdl,
  4615. &last_prefetched_hw_desc,
  4616. &last_prefetched_sw_desc);
  4617. if (dp_tx_comp_loop_pkt_limit_hit(soc, count, max_reap_limit))
  4618. break;
  4619. }
  4620. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  4621. /* Process the reaped descriptors */
  4622. if (head_desc)
  4623. dp_tx_comp_process_desc_list(soc, head_desc, ring_id);
  4624. DP_STATS_INC(soc, tx.tx_comp[ring_id], count);
  4625. /*
  4626. * If we are processing in near-full condition, there are 3 scenario
  4627. * 1) Ring entries has reached critical state
  4628. * 2) Ring entries are still near high threshold
  4629. * 3) Ring entries are below the safe level
  4630. *
  4631. * One more loop will move te state to normal processing and yield
  4632. */
  4633. if (ring_near_full)
  4634. goto more_data;
  4635. if (dp_tx_comp_enable_eol_data_check(soc)) {
  4636. if (num_processed >= quota)
  4637. force_break = true;
  4638. if (!force_break &&
  4639. hal_srng_dst_peek_sync_locked(soc->hal_soc,
  4640. hal_ring_hdl)) {
  4641. DP_STATS_INC(soc, tx.hp_oos2, 1);
  4642. if (!hif_exec_should_yield(soc->hif_handle,
  4643. int_ctx->dp_intr_id))
  4644. goto more_data;
  4645. }
  4646. }
  4647. DP_TX_HIST_STATS_PER_PDEV();
  4648. return num_processed;
  4649. }
  4650. #ifdef FEATURE_WLAN_TDLS
  4651. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4652. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  4653. {
  4654. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4655. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  4656. DP_MOD_ID_TDLS);
  4657. if (!vdev) {
  4658. dp_err("vdev handle for id %d is NULL", vdev_id);
  4659. return NULL;
  4660. }
  4661. if (tx_spec & OL_TX_SPEC_NO_FREE)
  4662. vdev->is_tdls_frame = true;
  4663. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  4664. return dp_tx_send(soc_hdl, vdev_id, msdu_list);
  4665. }
  4666. #endif
  4667. /**
  4668. * dp_tx_vdev_attach() - attach vdev to dp tx
  4669. * @vdev: virtual device instance
  4670. *
  4671. * Return: QDF_STATUS_SUCCESS: success
  4672. * QDF_STATUS_E_RESOURCES: Error return
  4673. */
  4674. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  4675. {
  4676. int pdev_id;
  4677. /*
  4678. * Fill HTT TCL Metadata with Vdev ID and MAC ID
  4679. */
  4680. DP_TX_TCL_METADATA_TYPE_SET(vdev->htt_tcl_metadata,
  4681. DP_TCL_METADATA_TYPE_VDEV_BASED);
  4682. DP_TX_TCL_METADATA_VDEV_ID_SET(vdev->htt_tcl_metadata,
  4683. vdev->vdev_id);
  4684. pdev_id =
  4685. dp_get_target_pdev_id_for_host_pdev_id(vdev->pdev->soc,
  4686. vdev->pdev->pdev_id);
  4687. DP_TX_TCL_METADATA_PDEV_ID_SET(vdev->htt_tcl_metadata, pdev_id);
  4688. /*
  4689. * Set HTT Extension Valid bit to 0 by default
  4690. */
  4691. DP_TX_TCL_METADATA_VALID_HTT_SET(vdev->htt_tcl_metadata, 0);
  4692. dp_tx_vdev_update_search_flags(vdev);
  4693. return QDF_STATUS_SUCCESS;
  4694. }
  4695. #ifndef FEATURE_WDS
  4696. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  4697. {
  4698. return false;
  4699. }
  4700. #endif
  4701. /**
  4702. * dp_tx_vdev_update_search_flags() - Update vdev flags as per opmode
  4703. * @vdev: virtual device instance
  4704. *
  4705. * Return: void
  4706. *
  4707. */
  4708. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  4709. {
  4710. struct dp_soc *soc = vdev->pdev->soc;
  4711. /*
  4712. * Enable both AddrY (SA based search) and AddrX (Da based search)
  4713. * for TDLS link
  4714. *
  4715. * Enable AddrY (SA based search) only for non-WDS STA and
  4716. * ProxySTA VAP (in HKv1) modes.
  4717. *
  4718. * In all other VAP modes, only DA based search should be
  4719. * enabled
  4720. */
  4721. if (vdev->opmode == wlan_op_mode_sta &&
  4722. vdev->tdls_link_connected)
  4723. vdev->hal_desc_addr_search_flags =
  4724. (HAL_TX_DESC_ADDRX_EN | HAL_TX_DESC_ADDRY_EN);
  4725. else if ((vdev->opmode == wlan_op_mode_sta) &&
  4726. !dp_tx_da_search_override(vdev))
  4727. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRY_EN;
  4728. else
  4729. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRX_EN;
  4730. if (vdev->opmode == wlan_op_mode_sta && !vdev->tdls_link_connected)
  4731. vdev->search_type = soc->sta_mode_search_policy;
  4732. else
  4733. vdev->search_type = HAL_TX_ADDR_SEARCH_DEFAULT;
  4734. }
  4735. static inline bool
  4736. dp_is_tx_desc_flush_match(struct dp_pdev *pdev,
  4737. struct dp_vdev *vdev,
  4738. struct dp_tx_desc_s *tx_desc)
  4739. {
  4740. if (!(tx_desc && (tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED)))
  4741. return false;
  4742. /*
  4743. * if vdev is given, then only check whether desc
  4744. * vdev match. if vdev is NULL, then check whether
  4745. * desc pdev match.
  4746. */
  4747. return vdev ? (tx_desc->vdev_id == vdev->vdev_id) :
  4748. (tx_desc->pdev == pdev);
  4749. }
  4750. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4751. /**
  4752. * dp_tx_desc_flush() - release resources associated
  4753. * to TX Desc
  4754. *
  4755. * @dp_pdev: Handle to DP pdev structure
  4756. * @vdev: virtual device instance
  4757. * NULL: no specific Vdev is required and check all allcated TX desc
  4758. * on this pdev.
  4759. * Non-NULL: only check the allocated TX Desc associated to this Vdev.
  4760. *
  4761. * @force_free:
  4762. * true: flush the TX desc.
  4763. * false: only reset the Vdev in each allocated TX desc
  4764. * that associated to current Vdev.
  4765. *
  4766. * This function will go through the TX desc pool to flush
  4767. * the outstanding TX data or reset Vdev to NULL in associated TX
  4768. * Desc.
  4769. */
  4770. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4771. bool force_free)
  4772. {
  4773. uint8_t i;
  4774. uint32_t j;
  4775. uint32_t num_desc, page_id, offset;
  4776. uint16_t num_desc_per_page;
  4777. struct dp_soc *soc = pdev->soc;
  4778. struct dp_tx_desc_s *tx_desc = NULL;
  4779. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4780. if (!vdev && !force_free) {
  4781. dp_err("Reset TX desc vdev, Vdev param is required!");
  4782. return;
  4783. }
  4784. for (i = 0; i < MAX_TXDESC_POOLS; i++) {
  4785. tx_desc_pool = &soc->tx_desc[i];
  4786. if (!(tx_desc_pool->pool_size) ||
  4787. IS_TX_DESC_POOL_STATUS_INACTIVE(tx_desc_pool) ||
  4788. !(tx_desc_pool->desc_pages.cacheable_pages))
  4789. continue;
  4790. /*
  4791. * Add flow pool lock protection in case pool is freed
  4792. * due to all tx_desc is recycled when handle TX completion.
  4793. * this is not necessary when do force flush as:
  4794. * a. double lock will happen if dp_tx_desc_release is
  4795. * also trying to acquire it.
  4796. * b. dp interrupt has been disabled before do force TX desc
  4797. * flush in dp_pdev_deinit().
  4798. */
  4799. if (!force_free)
  4800. qdf_spin_lock_bh(&tx_desc_pool->flow_pool_lock);
  4801. num_desc = tx_desc_pool->pool_size;
  4802. num_desc_per_page =
  4803. tx_desc_pool->desc_pages.num_element_per_page;
  4804. for (j = 0; j < num_desc; j++) {
  4805. page_id = j / num_desc_per_page;
  4806. offset = j % num_desc_per_page;
  4807. if (qdf_unlikely(!(tx_desc_pool->
  4808. desc_pages.cacheable_pages)))
  4809. break;
  4810. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4811. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4812. /*
  4813. * Free TX desc if force free is
  4814. * required, otherwise only reset vdev
  4815. * in this TX desc.
  4816. */
  4817. if (force_free) {
  4818. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4819. dp_tx_comp_free_buf(soc, tx_desc);
  4820. dp_tx_desc_release(tx_desc, i);
  4821. } else {
  4822. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4823. }
  4824. }
  4825. }
  4826. if (!force_free)
  4827. qdf_spin_unlock_bh(&tx_desc_pool->flow_pool_lock);
  4828. }
  4829. }
  4830. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4831. /**
  4832. * dp_tx_desc_reset_vdev() - reset vdev to NULL in TX Desc
  4833. *
  4834. * @soc: Handle to DP soc structure
  4835. * @tx_desc: pointer of one TX desc
  4836. * @desc_pool_id: TX Desc pool id
  4837. */
  4838. static inline void
  4839. dp_tx_desc_reset_vdev(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc,
  4840. uint8_t desc_pool_id)
  4841. {
  4842. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  4843. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4844. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  4845. }
  4846. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4847. bool force_free)
  4848. {
  4849. uint8_t i, num_pool;
  4850. uint32_t j;
  4851. uint32_t num_desc, page_id, offset;
  4852. uint16_t num_desc_per_page;
  4853. struct dp_soc *soc = pdev->soc;
  4854. struct dp_tx_desc_s *tx_desc = NULL;
  4855. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4856. if (!vdev && !force_free) {
  4857. dp_err("Reset TX desc vdev, Vdev param is required!");
  4858. return;
  4859. }
  4860. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  4861. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4862. for (i = 0; i < num_pool; i++) {
  4863. tx_desc_pool = &soc->tx_desc[i];
  4864. if (!tx_desc_pool->desc_pages.cacheable_pages)
  4865. continue;
  4866. num_desc_per_page =
  4867. tx_desc_pool->desc_pages.num_element_per_page;
  4868. for (j = 0; j < num_desc; j++) {
  4869. page_id = j / num_desc_per_page;
  4870. offset = j % num_desc_per_page;
  4871. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4872. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4873. if (force_free) {
  4874. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4875. dp_tx_comp_free_buf(soc, tx_desc);
  4876. dp_tx_desc_release(tx_desc, i);
  4877. } else {
  4878. dp_tx_desc_reset_vdev(soc, tx_desc,
  4879. i);
  4880. }
  4881. }
  4882. }
  4883. }
  4884. }
  4885. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4886. /**
  4887. * dp_tx_vdev_detach() - detach vdev from dp tx
  4888. * @vdev: virtual device instance
  4889. *
  4890. * Return: QDF_STATUS_SUCCESS: success
  4891. * QDF_STATUS_E_RESOURCES: Error return
  4892. */
  4893. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  4894. {
  4895. struct dp_pdev *pdev = vdev->pdev;
  4896. /* Reset TX desc associated to this Vdev as NULL */
  4897. dp_tx_desc_flush(pdev, vdev, false);
  4898. return QDF_STATUS_SUCCESS;
  4899. }
  4900. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4901. /* Pools will be allocated dynamically */
  4902. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4903. int num_desc)
  4904. {
  4905. uint8_t i;
  4906. for (i = 0; i < num_pool; i++) {
  4907. qdf_spinlock_create(&soc->tx_desc[i].flow_pool_lock);
  4908. soc->tx_desc[i].status = FLOW_POOL_INACTIVE;
  4909. }
  4910. return QDF_STATUS_SUCCESS;
  4911. }
  4912. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4913. uint32_t num_desc)
  4914. {
  4915. return QDF_STATUS_SUCCESS;
  4916. }
  4917. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4918. {
  4919. }
  4920. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4921. {
  4922. uint8_t i;
  4923. for (i = 0; i < num_pool; i++)
  4924. qdf_spinlock_destroy(&soc->tx_desc[i].flow_pool_lock);
  4925. }
  4926. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4927. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4928. uint32_t num_desc)
  4929. {
  4930. uint8_t i, count;
  4931. /* Allocate software Tx descriptor pools */
  4932. for (i = 0; i < num_pool; i++) {
  4933. if (dp_tx_desc_pool_alloc(soc, i, num_desc)) {
  4934. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4935. FL("Tx Desc Pool alloc %d failed %pK"),
  4936. i, soc);
  4937. goto fail;
  4938. }
  4939. }
  4940. return QDF_STATUS_SUCCESS;
  4941. fail:
  4942. for (count = 0; count < i; count++)
  4943. dp_tx_desc_pool_free(soc, count);
  4944. return QDF_STATUS_E_NOMEM;
  4945. }
  4946. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4947. uint32_t num_desc)
  4948. {
  4949. uint8_t i;
  4950. for (i = 0; i < num_pool; i++) {
  4951. if (dp_tx_desc_pool_init(soc, i, num_desc)) {
  4952. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4953. FL("Tx Desc Pool init %d failed %pK"),
  4954. i, soc);
  4955. return QDF_STATUS_E_NOMEM;
  4956. }
  4957. }
  4958. return QDF_STATUS_SUCCESS;
  4959. }
  4960. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4961. {
  4962. uint8_t i;
  4963. for (i = 0; i < num_pool; i++)
  4964. dp_tx_desc_pool_deinit(soc, i);
  4965. }
  4966. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4967. {
  4968. uint8_t i;
  4969. for (i = 0; i < num_pool; i++)
  4970. dp_tx_desc_pool_free(soc, i);
  4971. }
  4972. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4973. /**
  4974. * dp_tx_tso_cmn_desc_pool_deinit() - de-initialize TSO descriptors
  4975. * @soc: core txrx main context
  4976. * @num_pool: number of pools
  4977. *
  4978. */
  4979. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool)
  4980. {
  4981. dp_tx_tso_desc_pool_deinit(soc, num_pool);
  4982. dp_tx_tso_num_seg_pool_deinit(soc, num_pool);
  4983. }
  4984. /**
  4985. * dp_tx_tso_cmn_desc_pool_free() - free TSO descriptors
  4986. * @soc: core txrx main context
  4987. * @num_pool: number of pools
  4988. *
  4989. */
  4990. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool)
  4991. {
  4992. dp_tx_tso_desc_pool_free(soc, num_pool);
  4993. dp_tx_tso_num_seg_pool_free(soc, num_pool);
  4994. }
  4995. /**
  4996. * dp_soc_tx_desc_sw_pools_free() - free all TX descriptors
  4997. * @soc: core txrx main context
  4998. *
  4999. * This function frees all tx related descriptors as below
  5000. * 1. Regular TX descriptors (static pools)
  5001. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  5002. * 3. TSO descriptors
  5003. *
  5004. */
  5005. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  5006. {
  5007. uint8_t num_pool;
  5008. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5009. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  5010. dp_tx_ext_desc_pool_free(soc, num_pool);
  5011. dp_tx_delete_static_pools(soc, num_pool);
  5012. }
  5013. /**
  5014. * dp_soc_tx_desc_sw_pools_deinit() - de-initialize all TX descriptors
  5015. * @soc: core txrx main context
  5016. *
  5017. * This function de-initializes all tx related descriptors as below
  5018. * 1. Regular TX descriptors (static pools)
  5019. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  5020. * 3. TSO descriptors
  5021. *
  5022. */
  5023. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  5024. {
  5025. uint8_t num_pool;
  5026. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5027. dp_tx_flow_control_deinit(soc);
  5028. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  5029. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  5030. dp_tx_deinit_static_pools(soc, num_pool);
  5031. }
  5032. /**
  5033. * dp_tso_attach() - TSO attach handler
  5034. * @txrx_soc: Opaque Dp handle
  5035. *
  5036. * Reserve TSO descriptor buffers
  5037. *
  5038. * Return: QDF_STATUS_E_FAILURE on failure or
  5039. * QDF_STATUS_SUCCESS on success
  5040. */
  5041. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  5042. uint8_t num_pool,
  5043. uint32_t num_desc)
  5044. {
  5045. if (dp_tx_tso_desc_pool_alloc(soc, num_pool, num_desc)) {
  5046. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  5047. return QDF_STATUS_E_FAILURE;
  5048. }
  5049. if (dp_tx_tso_num_seg_pool_alloc(soc, num_pool, num_desc)) {
  5050. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  5051. num_pool, soc);
  5052. return QDF_STATUS_E_FAILURE;
  5053. }
  5054. return QDF_STATUS_SUCCESS;
  5055. }
  5056. /**
  5057. * dp_tx_tso_cmn_desc_pool_init() - TSO cmn desc pool init
  5058. * @soc: DP soc handle
  5059. * @num_pool: Number of pools
  5060. * @num_desc: Number of descriptors
  5061. *
  5062. * Initialize TSO descriptor pools
  5063. *
  5064. * Return: QDF_STATUS_E_FAILURE on failure or
  5065. * QDF_STATUS_SUCCESS on success
  5066. */
  5067. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  5068. uint8_t num_pool,
  5069. uint32_t num_desc)
  5070. {
  5071. if (dp_tx_tso_desc_pool_init(soc, num_pool, num_desc)) {
  5072. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  5073. return QDF_STATUS_E_FAILURE;
  5074. }
  5075. if (dp_tx_tso_num_seg_pool_init(soc, num_pool, num_desc)) {
  5076. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  5077. num_pool, soc);
  5078. return QDF_STATUS_E_FAILURE;
  5079. }
  5080. return QDF_STATUS_SUCCESS;
  5081. }
  5082. /**
  5083. * dp_soc_tx_desc_sw_pools_alloc() - Allocate tx descriptor pool memory
  5084. * @soc: core txrx main context
  5085. *
  5086. * This function allocates memory for following descriptor pools
  5087. * 1. regular sw tx descriptor pools (static pools)
  5088. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  5089. * 3. TSO descriptor pools
  5090. *
  5091. * Return: QDF_STATUS_SUCCESS: success
  5092. * QDF_STATUS_E_RESOURCES: Error return
  5093. */
  5094. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  5095. {
  5096. uint8_t num_pool;
  5097. uint32_t num_desc;
  5098. uint32_t num_ext_desc;
  5099. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5100. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5101. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5102. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  5103. "%s Tx Desc Alloc num_pool = %d, descs = %d",
  5104. __func__, num_pool, num_desc);
  5105. if ((num_pool > MAX_TXDESC_POOLS) ||
  5106. (num_desc > WLAN_CFG_NUM_TX_DESC_MAX))
  5107. goto fail1;
  5108. if (dp_tx_alloc_static_pools(soc, num_pool, num_desc))
  5109. goto fail1;
  5110. if (dp_tx_ext_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5111. goto fail2;
  5112. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  5113. return QDF_STATUS_SUCCESS;
  5114. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5115. goto fail3;
  5116. return QDF_STATUS_SUCCESS;
  5117. fail3:
  5118. dp_tx_ext_desc_pool_free(soc, num_pool);
  5119. fail2:
  5120. dp_tx_delete_static_pools(soc, num_pool);
  5121. fail1:
  5122. return QDF_STATUS_E_RESOURCES;
  5123. }
  5124. /**
  5125. * dp_soc_tx_desc_sw_pools_init() - Initialise TX descriptor pools
  5126. * @soc: core txrx main context
  5127. *
  5128. * This function initializes the following TX descriptor pools
  5129. * 1. regular sw tx descriptor pools (static pools)
  5130. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  5131. * 3. TSO descriptor pools
  5132. *
  5133. * Return: QDF_STATUS_SUCCESS: success
  5134. * QDF_STATUS_E_RESOURCES: Error return
  5135. */
  5136. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  5137. {
  5138. uint8_t num_pool;
  5139. uint32_t num_desc;
  5140. uint32_t num_ext_desc;
  5141. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5142. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5143. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5144. if (dp_tx_init_static_pools(soc, num_pool, num_desc))
  5145. goto fail1;
  5146. if (dp_tx_ext_desc_pool_init(soc, num_pool, num_ext_desc))
  5147. goto fail2;
  5148. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  5149. return QDF_STATUS_SUCCESS;
  5150. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  5151. goto fail3;
  5152. dp_tx_flow_control_init(soc);
  5153. soc->process_tx_status = CONFIG_PROCESS_TX_STATUS;
  5154. return QDF_STATUS_SUCCESS;
  5155. fail3:
  5156. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  5157. fail2:
  5158. dp_tx_deinit_static_pools(soc, num_pool);
  5159. fail1:
  5160. return QDF_STATUS_E_RESOURCES;
  5161. }
  5162. /**
  5163. * dp_tso_soc_attach() - Allocate and initialize TSO descriptors
  5164. * @txrx_soc: dp soc handle
  5165. *
  5166. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5167. * QDF_STATUS_E_FAILURE
  5168. */
  5169. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc)
  5170. {
  5171. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5172. uint8_t num_pool;
  5173. uint32_t num_desc;
  5174. uint32_t num_ext_desc;
  5175. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5176. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5177. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5178. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5179. return QDF_STATUS_E_FAILURE;
  5180. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  5181. return QDF_STATUS_E_FAILURE;
  5182. return QDF_STATUS_SUCCESS;
  5183. }
  5184. /**
  5185. * dp_tso_soc_detach() - de-initialize and free the TSO descriptors
  5186. * @txrx_soc: dp soc handle
  5187. *
  5188. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5189. */
  5190. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc)
  5191. {
  5192. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5193. uint8_t num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5194. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  5195. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  5196. return QDF_STATUS_SUCCESS;
  5197. }