dp_tx.c 158 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951
  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_pm_runtime_get(soc->hif_handle,
  1365. RTPM_ID_DW_TX_HW_ENQUEUE, true);
  1366. switch (ret) {
  1367. case 0:
  1368. if (hif_system_pm_state_check(soc->hif_handle)) {
  1369. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1370. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1371. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1372. } else {
  1373. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1374. }
  1375. hif_pm_runtime_put(soc->hif_handle,
  1376. RTPM_ID_DW_TX_HW_ENQUEUE);
  1377. break;
  1378. /*
  1379. * If hif_pm_runtime_get returns -EBUSY or -EINPROGRESS,
  1380. * take the dp runtime refcount using dp_runtime_get,
  1381. * check link state,if up, write TX ring HP, else just set flush event.
  1382. * In dp_runtime_resume, wait until dp runtime refcount becomes
  1383. * zero or time out, then flush pending tx.
  1384. */
  1385. case -EBUSY:
  1386. case -EINPROGRESS:
  1387. dp_runtime_get(soc);
  1388. if (hif_pm_get_link_state(soc->hif_handle) ==
  1389. HIF_PM_LINK_STATE_UP) {
  1390. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1391. } else {
  1392. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1393. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1394. qdf_atomic_inc(&soc->tx_pending_rtpm);
  1395. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1396. }
  1397. dp_runtime_put(soc);
  1398. break;
  1399. default:
  1400. dp_runtime_get(soc);
  1401. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1402. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1403. qdf_atomic_inc(&soc->tx_pending_rtpm);
  1404. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1405. dp_runtime_put(soc);
  1406. }
  1407. }
  1408. #else
  1409. #ifdef DP_POWER_SAVE
  1410. void
  1411. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1412. hal_ring_handle_t hal_ring_hdl,
  1413. int coalesce)
  1414. {
  1415. if (hif_system_pm_state_check(soc->hif_handle)) {
  1416. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1417. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1418. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1419. } else {
  1420. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1421. }
  1422. }
  1423. #endif
  1424. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1425. {
  1426. return 0;
  1427. }
  1428. #endif
  1429. /**
  1430. * dp_tx_get_tid() - Obtain TID to be used for this frame
  1431. * @vdev: DP vdev handle
  1432. * @nbuf: skb
  1433. *
  1434. * Extract the DSCP or PCP information from frame and map into TID value.
  1435. *
  1436. * Return: void
  1437. */
  1438. static void dp_tx_get_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1439. struct dp_tx_msdu_info_s *msdu_info)
  1440. {
  1441. uint8_t tos = 0, dscp_tid_override = 0;
  1442. uint8_t *hdr_ptr, *L3datap;
  1443. uint8_t is_mcast = 0;
  1444. qdf_ether_header_t *eh = NULL;
  1445. qdf_ethervlan_header_t *evh = NULL;
  1446. uint16_t ether_type;
  1447. qdf_llc_t *llcHdr;
  1448. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  1449. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1450. if (qdf_likely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1451. eh = (qdf_ether_header_t *)nbuf->data;
  1452. hdr_ptr = (uint8_t *)(eh->ether_dhost);
  1453. L3datap = hdr_ptr + sizeof(qdf_ether_header_t);
  1454. } else {
  1455. qdf_dot3_qosframe_t *qos_wh =
  1456. (qdf_dot3_qosframe_t *) nbuf->data;
  1457. msdu_info->tid = qos_wh->i_fc[0] & DP_FC0_SUBTYPE_QOS ?
  1458. qos_wh->i_qos[0] & DP_QOS_TID : 0;
  1459. return;
  1460. }
  1461. is_mcast = DP_FRAME_IS_MULTICAST(hdr_ptr);
  1462. ether_type = eh->ether_type;
  1463. llcHdr = (qdf_llc_t *)(nbuf->data + sizeof(qdf_ether_header_t));
  1464. /*
  1465. * Check if packet is dot3 or eth2 type.
  1466. */
  1467. if (DP_FRAME_IS_LLC(ether_type) && DP_FRAME_IS_SNAP(llcHdr)) {
  1468. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE +
  1469. sizeof(*llcHdr));
  1470. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1471. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t) +
  1472. sizeof(*llcHdr);
  1473. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE
  1474. + sizeof(*llcHdr) +
  1475. sizeof(qdf_net_vlanhdr_t));
  1476. } else {
  1477. L3datap = hdr_ptr + sizeof(qdf_ether_header_t) +
  1478. sizeof(*llcHdr);
  1479. }
  1480. } else {
  1481. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1482. evh = (qdf_ethervlan_header_t *) eh;
  1483. ether_type = evh->ether_type;
  1484. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t);
  1485. }
  1486. }
  1487. /*
  1488. * Find priority from IP TOS DSCP field
  1489. */
  1490. if (qdf_nbuf_is_ipv4_pkt(nbuf)) {
  1491. qdf_net_iphdr_t *ip = (qdf_net_iphdr_t *) L3datap;
  1492. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) {
  1493. /* Only for unicast frames */
  1494. if (!is_mcast) {
  1495. /* send it on VO queue */
  1496. msdu_info->tid = DP_VO_TID;
  1497. }
  1498. } else {
  1499. /*
  1500. * IP frame: exclude ECN bits 0-1 and map DSCP bits 2-7
  1501. * from TOS byte.
  1502. */
  1503. tos = ip->ip_tos;
  1504. dscp_tid_override = 1;
  1505. }
  1506. } else if (qdf_nbuf_is_ipv6_pkt(nbuf)) {
  1507. /* TODO
  1508. * use flowlabel
  1509. *igmpmld cases to be handled in phase 2
  1510. */
  1511. unsigned long ver_pri_flowlabel;
  1512. unsigned long pri;
  1513. ver_pri_flowlabel = *(unsigned long *) L3datap;
  1514. pri = (ntohl(ver_pri_flowlabel) & IPV6_FLOWINFO_PRIORITY) >>
  1515. DP_IPV6_PRIORITY_SHIFT;
  1516. tos = pri;
  1517. dscp_tid_override = 1;
  1518. } else if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf))
  1519. msdu_info->tid = DP_VO_TID;
  1520. else if (qdf_nbuf_is_ipv4_arp_pkt(nbuf)) {
  1521. /* Only for unicast frames */
  1522. if (!is_mcast) {
  1523. /* send ucast arp on VO queue */
  1524. msdu_info->tid = DP_VO_TID;
  1525. }
  1526. }
  1527. /*
  1528. * Assign all MCAST packets to BE
  1529. */
  1530. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1531. if (is_mcast) {
  1532. tos = 0;
  1533. dscp_tid_override = 1;
  1534. }
  1535. }
  1536. if (dscp_tid_override == 1) {
  1537. tos = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
  1538. msdu_info->tid = pdev->dscp_tid_map[vdev->dscp_tid_map_id][tos];
  1539. }
  1540. if (msdu_info->tid >= CDP_MAX_DATA_TIDS)
  1541. msdu_info->tid = CDP_MAX_DATA_TIDS - 1;
  1542. return;
  1543. }
  1544. /**
  1545. * dp_tx_classify_tid() - Obtain TID to be used for this frame
  1546. * @vdev: DP vdev handle
  1547. * @nbuf: skb
  1548. *
  1549. * Software based TID classification is required when more than 2 DSCP-TID
  1550. * mapping tables are needed.
  1551. * Hardware supports 2 DSCP-TID mapping tables for HKv1 and 48 for HKv2.
  1552. *
  1553. * Return: void
  1554. */
  1555. static inline void dp_tx_classify_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1556. struct dp_tx_msdu_info_s *msdu_info)
  1557. {
  1558. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1559. /*
  1560. * skip_sw_tid_classification flag will set in below cases-
  1561. * 1. vdev->dscp_tid_map_id < pdev->soc->num_hw_dscp_tid_map
  1562. * 2. hlos_tid_override enabled for vdev
  1563. * 3. mesh mode enabled for vdev
  1564. */
  1565. if (qdf_likely(vdev->skip_sw_tid_classification)) {
  1566. /* Update tid in msdu_info from skb priority */
  1567. if (qdf_unlikely(vdev->skip_sw_tid_classification
  1568. & DP_TXRX_HLOS_TID_OVERRIDE_ENABLED)) {
  1569. uint32_t tid = qdf_nbuf_get_priority(nbuf);
  1570. if (tid == DP_TX_INVALID_QOS_TAG)
  1571. return;
  1572. msdu_info->tid = tid;
  1573. return;
  1574. }
  1575. return;
  1576. }
  1577. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1578. }
  1579. #ifdef FEATURE_WLAN_TDLS
  1580. /**
  1581. * dp_tx_update_tdls_flags() - Update descriptor flags for TDLS frame
  1582. * @soc: datapath SOC
  1583. * @vdev: datapath vdev
  1584. * @tx_desc: TX descriptor
  1585. *
  1586. * Return: None
  1587. */
  1588. static void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1589. struct dp_vdev *vdev,
  1590. struct dp_tx_desc_s *tx_desc)
  1591. {
  1592. if (vdev) {
  1593. if (vdev->is_tdls_frame) {
  1594. tx_desc->flags |= DP_TX_DESC_FLAG_TDLS_FRAME;
  1595. vdev->is_tdls_frame = false;
  1596. }
  1597. }
  1598. }
  1599. static uint8_t dp_htt_tx_comp_get_status(struct dp_soc *soc, char *htt_desc)
  1600. {
  1601. uint8_t tx_status = HTT_TX_FW2WBM_TX_STATUS_MAX;
  1602. switch (soc->arch_id) {
  1603. case CDP_ARCH_TYPE_LI:
  1604. tx_status = HTT_TX_WBM_COMPLETION_V2_TX_STATUS_GET(htt_desc[0]);
  1605. break;
  1606. case CDP_ARCH_TYPE_BE:
  1607. tx_status = HTT_TX_WBM_COMPLETION_V3_TX_STATUS_GET(htt_desc[0]);
  1608. break;
  1609. default:
  1610. dp_err("Incorrect CDP_ARCH %d", soc->arch_id);
  1611. QDF_BUG(0);
  1612. }
  1613. return tx_status;
  1614. }
  1615. /**
  1616. * dp_non_std_htt_tx_comp_free_buff() - Free the non std tx packet buffer
  1617. * @soc: dp_soc handle
  1618. * @tx_desc: TX descriptor
  1619. * @vdev: datapath vdev handle
  1620. *
  1621. * Return: None
  1622. */
  1623. static void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1624. struct dp_tx_desc_s *tx_desc)
  1625. {
  1626. uint8_t tx_status = 0;
  1627. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  1628. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1629. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1630. DP_MOD_ID_TDLS);
  1631. if (qdf_unlikely(!vdev)) {
  1632. dp_err_rl("vdev is null!");
  1633. goto error;
  1634. }
  1635. hal_tx_comp_get_htt_desc(&tx_desc->comp, htt_tx_status);
  1636. tx_status = dp_htt_tx_comp_get_status(soc, htt_tx_status);
  1637. dp_debug("vdev_id: %d tx_status: %d", tx_desc->vdev_id, tx_status);
  1638. if (vdev->tx_non_std_data_callback.func) {
  1639. qdf_nbuf_set_next(nbuf, NULL);
  1640. vdev->tx_non_std_data_callback.func(
  1641. vdev->tx_non_std_data_callback.ctxt,
  1642. nbuf, tx_status);
  1643. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1644. return;
  1645. } else {
  1646. dp_err_rl("callback func is null");
  1647. }
  1648. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1649. error:
  1650. qdf_nbuf_unmap_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  1651. qdf_nbuf_free(nbuf);
  1652. }
  1653. /**
  1654. * dp_tx_msdu_single_map() - do nbuf map
  1655. * @vdev: DP vdev handle
  1656. * @tx_desc: DP TX descriptor pointer
  1657. * @nbuf: skb pointer
  1658. *
  1659. * For TDLS frame, use qdf_nbuf_map_single() to align with the unmap
  1660. * operation done in other component.
  1661. *
  1662. * Return: QDF_STATUS
  1663. */
  1664. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1665. struct dp_tx_desc_s *tx_desc,
  1666. qdf_nbuf_t nbuf)
  1667. {
  1668. if (qdf_likely(!(tx_desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)))
  1669. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1670. nbuf,
  1671. QDF_DMA_TO_DEVICE,
  1672. nbuf->len);
  1673. else
  1674. return qdf_nbuf_map_single(vdev->osdev, nbuf,
  1675. QDF_DMA_TO_DEVICE);
  1676. }
  1677. #else
  1678. static inline void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1679. struct dp_vdev *vdev,
  1680. struct dp_tx_desc_s *tx_desc)
  1681. {
  1682. }
  1683. static inline void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1684. struct dp_tx_desc_s *tx_desc)
  1685. {
  1686. }
  1687. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1688. struct dp_tx_desc_s *tx_desc,
  1689. qdf_nbuf_t nbuf)
  1690. {
  1691. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1692. nbuf,
  1693. QDF_DMA_TO_DEVICE,
  1694. nbuf->len);
  1695. }
  1696. #endif
  1697. static inline
  1698. qdf_dma_addr_t dp_tx_nbuf_map_regular(struct dp_vdev *vdev,
  1699. struct dp_tx_desc_s *tx_desc,
  1700. qdf_nbuf_t nbuf)
  1701. {
  1702. QDF_STATUS ret = QDF_STATUS_E_FAILURE;
  1703. ret = dp_tx_msdu_single_map(vdev, tx_desc, nbuf);
  1704. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret)))
  1705. return 0;
  1706. return qdf_nbuf_mapped_paddr_get(nbuf);
  1707. }
  1708. static inline
  1709. void dp_tx_nbuf_unmap_regular(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1710. {
  1711. qdf_nbuf_unmap_nbytes_single_paddr(soc->osdev,
  1712. desc->nbuf,
  1713. desc->dma_addr,
  1714. QDF_DMA_TO_DEVICE,
  1715. desc->length);
  1716. }
  1717. #if defined(QCA_DP_TX_NBUF_NO_MAP_UNMAP) && !defined(BUILD_X86)
  1718. static inline
  1719. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1720. struct dp_tx_desc_s *tx_desc,
  1721. qdf_nbuf_t nbuf)
  1722. {
  1723. if (qdf_likely(tx_desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  1724. qdf_nbuf_dma_clean_range((void *)nbuf->data,
  1725. (void *)(nbuf->data + nbuf->len));
  1726. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  1727. } else {
  1728. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1729. }
  1730. }
  1731. static inline
  1732. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1733. struct dp_tx_desc_s *desc)
  1734. {
  1735. if (qdf_unlikely(!(desc->flags & DP_TX_DESC_FLAG_SIMPLE)))
  1736. return dp_tx_nbuf_unmap_regular(soc, desc);
  1737. }
  1738. #else
  1739. static inline
  1740. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1741. struct dp_tx_desc_s *tx_desc,
  1742. qdf_nbuf_t nbuf)
  1743. {
  1744. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1745. }
  1746. static inline
  1747. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1748. struct dp_tx_desc_s *desc)
  1749. {
  1750. return dp_tx_nbuf_unmap_regular(soc, desc);
  1751. }
  1752. #endif
  1753. #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(FEATURE_PERPKT_INFO)
  1754. static inline
  1755. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1756. {
  1757. dp_tx_nbuf_unmap(soc, desc);
  1758. desc->flags |= DP_TX_DESC_FLAG_UNMAP_DONE;
  1759. }
  1760. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1761. {
  1762. if (qdf_likely(!(desc->flags & DP_TX_DESC_FLAG_UNMAP_DONE)))
  1763. dp_tx_nbuf_unmap(soc, desc);
  1764. }
  1765. #else
  1766. static inline
  1767. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1768. {
  1769. }
  1770. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1771. {
  1772. dp_tx_nbuf_unmap(soc, desc);
  1773. }
  1774. #endif
  1775. #ifdef MESH_MODE_SUPPORT
  1776. /**
  1777. * dp_tx_update_mesh_flags() - Update descriptor flags for mesh VAP
  1778. * @soc: datapath SOC
  1779. * @vdev: datapath vdev
  1780. * @tx_desc: TX descriptor
  1781. *
  1782. * Return: None
  1783. */
  1784. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1785. struct dp_vdev *vdev,
  1786. struct dp_tx_desc_s *tx_desc)
  1787. {
  1788. if (qdf_unlikely(vdev->mesh_vdev))
  1789. tx_desc->flags |= DP_TX_DESC_FLAG_MESH_MODE;
  1790. }
  1791. /**
  1792. * dp_mesh_tx_comp_free_buff() - Free the mesh tx packet buffer
  1793. * @soc: dp_soc handle
  1794. * @tx_desc: TX descriptor
  1795. * @vdev: datapath vdev handle
  1796. *
  1797. * Return: None
  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. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1803. struct dp_vdev *vdev = NULL;
  1804. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW) {
  1805. qdf_nbuf_free(nbuf);
  1806. DP_STATS_INC(vdev, tx_i.mesh.completion_fw, 1);
  1807. } else {
  1808. vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1809. DP_MOD_ID_MESH);
  1810. if (vdev && vdev->osif_tx_free_ext)
  1811. vdev->osif_tx_free_ext((nbuf));
  1812. else
  1813. qdf_nbuf_free(nbuf);
  1814. if (vdev)
  1815. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  1816. }
  1817. }
  1818. #else
  1819. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1820. struct dp_vdev *vdev,
  1821. struct dp_tx_desc_s *tx_desc)
  1822. {
  1823. }
  1824. static inline void dp_mesh_tx_comp_free_buff(struct dp_soc *soc,
  1825. struct dp_tx_desc_s *tx_desc)
  1826. {
  1827. }
  1828. #endif
  1829. /**
  1830. * dp_tx_frame_is_drop() - checks if the packet is loopback
  1831. * @vdev: DP vdev handle
  1832. * @nbuf: skb
  1833. *
  1834. * Return: 1 if frame needs to be dropped else 0
  1835. */
  1836. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac)
  1837. {
  1838. struct dp_pdev *pdev = NULL;
  1839. struct dp_ast_entry *src_ast_entry = NULL;
  1840. struct dp_ast_entry *dst_ast_entry = NULL;
  1841. struct dp_soc *soc = NULL;
  1842. qdf_assert(vdev);
  1843. pdev = vdev->pdev;
  1844. qdf_assert(pdev);
  1845. soc = pdev->soc;
  1846. dst_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1847. (soc, dstmac, vdev->pdev->pdev_id);
  1848. src_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1849. (soc, srcmac, vdev->pdev->pdev_id);
  1850. if (dst_ast_entry && src_ast_entry) {
  1851. if (dst_ast_entry->peer_id ==
  1852. src_ast_entry->peer_id)
  1853. return 1;
  1854. }
  1855. return 0;
  1856. }
  1857. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) && \
  1858. defined(WLAN_MCAST_MLO)
  1859. /* MLO peer id for reinject*/
  1860. #define DP_MLO_MCAST_REINJECT_PEER_ID 0XFFFD
  1861. /* MLO vdev id inc offset */
  1862. #define DP_MLO_VDEV_ID_OFFSET 0x80
  1863. static inline void
  1864. dp_tx_bypass_reinjection(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  1865. {
  1866. if (!(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)) {
  1867. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1868. qdf_atomic_inc(&soc->num_tx_exception);
  1869. }
  1870. }
  1871. static inline void
  1872. dp_tx_update_mcast_param(uint16_t peer_id,
  1873. uint16_t *htt_tcl_metadata,
  1874. struct dp_vdev *vdev,
  1875. struct dp_tx_msdu_info_s *msdu_info)
  1876. {
  1877. if (peer_id == DP_MLO_MCAST_REINJECT_PEER_ID) {
  1878. *htt_tcl_metadata = 0;
  1879. DP_TX_TCL_METADATA_TYPE_SET(
  1880. *htt_tcl_metadata,
  1881. HTT_TCL_METADATA_V2_TYPE_GLOBAL_SEQ_BASED);
  1882. HTT_TX_TCL_METADATA_GLBL_SEQ_NO_SET(*htt_tcl_metadata,
  1883. msdu_info->gsn);
  1884. msdu_info->vdev_id = vdev->vdev_id + DP_MLO_VDEV_ID_OFFSET;
  1885. } else {
  1886. msdu_info->vdev_id = vdev->vdev_id;
  1887. }
  1888. }
  1889. #else
  1890. static inline void
  1891. dp_tx_bypass_reinjection(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  1892. {
  1893. }
  1894. static inline void
  1895. dp_tx_update_mcast_param(uint16_t peer_id,
  1896. uint16_t *htt_tcl_metadata,
  1897. struct dp_vdev *vdev,
  1898. struct dp_tx_msdu_info_s *msdu_info)
  1899. {
  1900. }
  1901. #endif
  1902. /**
  1903. * dp_tx_send_msdu_single() - Setup descriptor and enqueue single MSDU to TCL
  1904. * @vdev: DP vdev handle
  1905. * @nbuf: skb
  1906. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  1907. * @meta_data: Metadata to the fw
  1908. * @tx_q: Tx queue to be used for this Tx frame
  1909. * @peer_id: peer_id of the peer in case of NAWDS frames
  1910. * @tx_exc_metadata: Handle that holds exception path metadata
  1911. *
  1912. * Return: NULL on success,
  1913. * nbuf when it fails to send
  1914. */
  1915. qdf_nbuf_t
  1916. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1917. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  1918. struct cdp_tx_exception_metadata *tx_exc_metadata)
  1919. {
  1920. struct dp_pdev *pdev = vdev->pdev;
  1921. struct dp_soc *soc = pdev->soc;
  1922. struct dp_tx_desc_s *tx_desc;
  1923. QDF_STATUS status;
  1924. struct dp_tx_queue *tx_q = &(msdu_info->tx_queue);
  1925. uint16_t htt_tcl_metadata = 0;
  1926. enum cdp_tx_sw_drop drop_code = TX_MAX_DROP;
  1927. uint8_t tid = msdu_info->tid;
  1928. struct cdp_tid_tx_stats *tid_stats = NULL;
  1929. qdf_dma_addr_t paddr;
  1930. /* Setup Tx descriptor for an MSDU, and MSDU extension descriptor */
  1931. tx_desc = dp_tx_prepare_desc_single(vdev, nbuf, tx_q->desc_pool_id,
  1932. msdu_info, tx_exc_metadata);
  1933. if (!tx_desc) {
  1934. dp_err_rl("Tx_desc prepare Fail vdev %pK queue %d",
  1935. vdev, tx_q->desc_pool_id);
  1936. drop_code = TX_DESC_ERR;
  1937. goto fail_return;
  1938. }
  1939. dp_tx_update_tdls_flags(soc, vdev, tx_desc);
  1940. if (qdf_unlikely(peer_id == DP_INVALID_PEER)) {
  1941. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1942. DP_TX_TCL_METADATA_HOST_INSPECTED_SET(htt_tcl_metadata, 1);
  1943. } else if (qdf_unlikely(peer_id != HTT_INVALID_PEER)) {
  1944. DP_TX_TCL_METADATA_TYPE_SET(htt_tcl_metadata,
  1945. DP_TCL_METADATA_TYPE_PEER_BASED);
  1946. DP_TX_TCL_METADATA_PEER_ID_SET(htt_tcl_metadata,
  1947. peer_id);
  1948. dp_tx_bypass_reinjection(soc, tx_desc);
  1949. } else
  1950. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1951. if (msdu_info->exception_fw)
  1952. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  1953. dp_tx_desc_update_fast_comp_flag(soc, tx_desc,
  1954. !pdev->enhanced_stats_en);
  1955. dp_tx_update_mesh_flags(soc, vdev, tx_desc);
  1956. paddr = dp_tx_nbuf_map(vdev, tx_desc, nbuf);
  1957. if (!paddr) {
  1958. /* Handle failure */
  1959. dp_err("qdf_nbuf_map failed");
  1960. DP_STATS_INC(vdev, tx_i.dropped.dma_error, 1);
  1961. drop_code = TX_DMA_MAP_ERR;
  1962. goto release_desc;
  1963. }
  1964. tx_desc->dma_addr = paddr;
  1965. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1966. tx_desc->id, DP_TX_DESC_MAP);
  1967. dp_tx_update_mcast_param(peer_id, &htt_tcl_metadata, vdev, msdu_info);
  1968. /* Enqueue the Tx MSDU descriptor to HW for transmit */
  1969. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  1970. htt_tcl_metadata,
  1971. tx_exc_metadata, msdu_info);
  1972. if (status != QDF_STATUS_SUCCESS) {
  1973. dp_tx_err_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  1974. tx_desc, tx_q->ring_id);
  1975. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1976. tx_desc->id, DP_TX_DESC_UNMAP);
  1977. dp_tx_nbuf_unmap(soc, tx_desc);
  1978. drop_code = TX_HW_ENQUEUE;
  1979. goto release_desc;
  1980. }
  1981. return NULL;
  1982. release_desc:
  1983. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1984. fail_return:
  1985. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1986. tid_stats = &pdev->stats.tid_stats.
  1987. tid_tx_stats[tx_q->ring_id][tid];
  1988. tid_stats->swdrop_cnt[drop_code]++;
  1989. return nbuf;
  1990. }
  1991. /**
  1992. * dp_tx_comp_free_buf() - Free nbuf associated with the Tx Descriptor
  1993. * @soc: Soc handle
  1994. * @desc: software Tx descriptor to be processed
  1995. *
  1996. * Return: none
  1997. */
  1998. void dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1999. {
  2000. qdf_nbuf_t nbuf = desc->nbuf;
  2001. enum dp_tx_event_type type = dp_tx_get_event_type(desc->flags);
  2002. /* nbuf already freed in vdev detach path */
  2003. if (!nbuf)
  2004. return;
  2005. /* If it is TDLS mgmt, don't unmap or free the frame */
  2006. if (desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)
  2007. return dp_non_std_htt_tx_comp_free_buff(soc, desc);
  2008. /* 0 : MSDU buffer, 1 : MLE */
  2009. if (desc->msdu_ext_desc) {
  2010. /* TSO free */
  2011. if (hal_tx_ext_desc_get_tso_enable(
  2012. desc->msdu_ext_desc->vaddr)) {
  2013. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  2014. desc->id, DP_TX_COMP_MSDU_EXT);
  2015. dp_tx_tso_seg_history_add(soc,
  2016. desc->msdu_ext_desc->tso_desc,
  2017. desc->nbuf, desc->id, type);
  2018. /* unmap eash TSO seg before free the nbuf */
  2019. dp_tx_tso_unmap_segment(soc,
  2020. desc->msdu_ext_desc->tso_desc,
  2021. desc->msdu_ext_desc->
  2022. tso_num_desc);
  2023. qdf_nbuf_free(nbuf);
  2024. return;
  2025. }
  2026. if (qdf_unlikely(desc->frm_type == dp_tx_frm_sg)) {
  2027. void *msdu_ext_desc = desc->msdu_ext_desc->vaddr;
  2028. qdf_dma_addr_t iova;
  2029. uint32_t frag_len;
  2030. uint32_t i;
  2031. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf,
  2032. QDF_DMA_TO_DEVICE,
  2033. qdf_nbuf_headlen(nbuf));
  2034. for (i = 1; i < DP_TX_MAX_NUM_FRAGS; i++) {
  2035. hal_tx_ext_desc_get_frag_info(msdu_ext_desc, i,
  2036. &iova,
  2037. &frag_len);
  2038. if (!iova || !frag_len)
  2039. break;
  2040. qdf_mem_unmap_page(soc->osdev, iova, frag_len,
  2041. QDF_DMA_TO_DEVICE);
  2042. }
  2043. qdf_nbuf_free(nbuf);
  2044. return;
  2045. }
  2046. }
  2047. /* If it's ME frame, dont unmap the cloned nbuf's */
  2048. if ((desc->flags & DP_TX_DESC_FLAG_ME) && qdf_nbuf_is_cloned(nbuf))
  2049. goto nbuf_free;
  2050. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf, desc->id, type);
  2051. dp_tx_unmap(soc, desc);
  2052. if (desc->flags & DP_TX_DESC_FLAG_MESH_MODE)
  2053. return dp_mesh_tx_comp_free_buff(soc, desc);
  2054. nbuf_free:
  2055. qdf_nbuf_free(nbuf);
  2056. }
  2057. /**
  2058. * dp_tx_sg_unmap_buf() - Unmap scatter gather fragments
  2059. * @soc: DP soc handle
  2060. * @nbuf: skb
  2061. * @msdu_info: MSDU info
  2062. *
  2063. * Return: None
  2064. */
  2065. static inline void
  2066. dp_tx_sg_unmap_buf(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2067. struct dp_tx_msdu_info_s *msdu_info)
  2068. {
  2069. uint32_t cur_idx;
  2070. struct dp_tx_seg_info_s *seg = msdu_info->u.sg_info.curr_seg;
  2071. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE,
  2072. qdf_nbuf_headlen(nbuf));
  2073. for (cur_idx = 1; cur_idx < seg->frag_cnt; cur_idx++)
  2074. qdf_mem_unmap_page(soc->osdev, (qdf_dma_addr_t)
  2075. (seg->frags[cur_idx].paddr_lo | ((uint64_t)
  2076. seg->frags[cur_idx].paddr_hi) << 32),
  2077. seg->frags[cur_idx].len,
  2078. QDF_DMA_TO_DEVICE);
  2079. }
  2080. /**
  2081. * dp_tx_send_msdu_multiple() - Enqueue multiple MSDUs
  2082. * @vdev: DP vdev handle
  2083. * @nbuf: skb
  2084. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  2085. *
  2086. * Prepare descriptors for multiple MSDUs (TSO segments) and enqueue to TCL
  2087. *
  2088. * Return: NULL on success,
  2089. * nbuf when it fails to send
  2090. */
  2091. #if QDF_LOCK_STATS
  2092. noinline
  2093. #else
  2094. #endif
  2095. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2096. struct dp_tx_msdu_info_s *msdu_info)
  2097. {
  2098. uint32_t i;
  2099. struct dp_pdev *pdev = vdev->pdev;
  2100. struct dp_soc *soc = pdev->soc;
  2101. struct dp_tx_desc_s *tx_desc;
  2102. bool is_cce_classified = false;
  2103. QDF_STATUS status;
  2104. uint16_t htt_tcl_metadata = 0;
  2105. struct dp_tx_queue *tx_q = &msdu_info->tx_queue;
  2106. struct cdp_tid_tx_stats *tid_stats = NULL;
  2107. uint8_t prep_desc_fail = 0, hw_enq_fail = 0;
  2108. if (msdu_info->frm_type == dp_tx_frm_me)
  2109. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2110. i = 0;
  2111. /* Print statement to track i and num_seg */
  2112. /*
  2113. * For each segment (maps to 1 MSDU) , prepare software and hardware
  2114. * descriptors using information in msdu_info
  2115. */
  2116. while (i < msdu_info->num_seg) {
  2117. /*
  2118. * Setup Tx descriptor for an MSDU, and MSDU extension
  2119. * descriptor
  2120. */
  2121. tx_desc = dp_tx_prepare_desc(vdev, nbuf, msdu_info,
  2122. tx_q->desc_pool_id);
  2123. if (!tx_desc) {
  2124. if (msdu_info->frm_type == dp_tx_frm_me) {
  2125. prep_desc_fail++;
  2126. dp_tx_me_free_buf(pdev,
  2127. (void *)(msdu_info->u.sg_info
  2128. .curr_seg->frags[0].vaddr));
  2129. if (prep_desc_fail == msdu_info->num_seg) {
  2130. /*
  2131. * Unmap is needed only if descriptor
  2132. * preparation failed for all segments.
  2133. */
  2134. qdf_nbuf_unmap(soc->osdev,
  2135. msdu_info->u.sg_info.
  2136. curr_seg->nbuf,
  2137. QDF_DMA_TO_DEVICE);
  2138. }
  2139. /*
  2140. * Free the nbuf for the current segment
  2141. * and make it point to the next in the list.
  2142. * For me, there are as many segments as there
  2143. * are no of clients.
  2144. */
  2145. qdf_nbuf_free(msdu_info->u.sg_info
  2146. .curr_seg->nbuf);
  2147. if (msdu_info->u.sg_info.curr_seg->next) {
  2148. msdu_info->u.sg_info.curr_seg =
  2149. msdu_info->u.sg_info
  2150. .curr_seg->next;
  2151. nbuf = msdu_info->u.sg_info
  2152. .curr_seg->nbuf;
  2153. }
  2154. i++;
  2155. continue;
  2156. }
  2157. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2158. dp_tx_tso_seg_history_add(
  2159. soc,
  2160. msdu_info->u.tso_info.curr_seg,
  2161. nbuf, 0, DP_TX_DESC_UNMAP);
  2162. dp_tx_tso_unmap_segment(soc,
  2163. msdu_info->u.tso_info.
  2164. curr_seg,
  2165. msdu_info->u.tso_info.
  2166. tso_num_seg_list);
  2167. if (msdu_info->u.tso_info.curr_seg->next) {
  2168. msdu_info->u.tso_info.curr_seg =
  2169. msdu_info->u.tso_info.curr_seg->next;
  2170. i++;
  2171. continue;
  2172. }
  2173. }
  2174. if (msdu_info->frm_type == dp_tx_frm_sg)
  2175. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2176. goto done;
  2177. }
  2178. if (msdu_info->frm_type == dp_tx_frm_me) {
  2179. tx_desc->msdu_ext_desc->me_buffer =
  2180. (struct dp_tx_me_buf_t *)msdu_info->
  2181. u.sg_info.curr_seg->frags[0].vaddr;
  2182. tx_desc->flags |= DP_TX_DESC_FLAG_ME;
  2183. }
  2184. if (is_cce_classified)
  2185. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  2186. htt_tcl_metadata = vdev->htt_tcl_metadata;
  2187. if (msdu_info->exception_fw) {
  2188. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  2189. }
  2190. dp_tx_is_hp_update_required(i, msdu_info);
  2191. /*
  2192. * For frames with multiple segments (TSO, ME), jump to next
  2193. * segment.
  2194. */
  2195. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2196. if (msdu_info->u.tso_info.curr_seg->next) {
  2197. msdu_info->u.tso_info.curr_seg =
  2198. msdu_info->u.tso_info.curr_seg->next;
  2199. /*
  2200. * If this is a jumbo nbuf, then increment the
  2201. * number of nbuf users for each additional
  2202. * segment of the msdu. This will ensure that
  2203. * the skb is freed only after receiving tx
  2204. * completion for all segments of an nbuf
  2205. */
  2206. qdf_nbuf_inc_users(nbuf);
  2207. /* Check with MCL if this is needed */
  2208. /* nbuf = msdu_info->u.tso_info.curr_seg->nbuf;
  2209. */
  2210. }
  2211. }
  2212. dp_tx_update_mcast_param(DP_INVALID_PEER,
  2213. &htt_tcl_metadata,
  2214. vdev,
  2215. msdu_info);
  2216. /*
  2217. * Enqueue the Tx MSDU descriptor to HW for transmit
  2218. */
  2219. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  2220. htt_tcl_metadata,
  2221. NULL, msdu_info);
  2222. dp_tx_check_and_flush_hp(soc, status, msdu_info);
  2223. if (status != QDF_STATUS_SUCCESS) {
  2224. dp_info_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  2225. tx_desc, tx_q->ring_id);
  2226. dp_tx_get_tid(vdev, nbuf, msdu_info);
  2227. tid_stats = &pdev->stats.tid_stats.
  2228. tid_tx_stats[tx_q->ring_id][msdu_info->tid];
  2229. tid_stats->swdrop_cnt[TX_HW_ENQUEUE]++;
  2230. if (msdu_info->frm_type == dp_tx_frm_me) {
  2231. hw_enq_fail++;
  2232. if (hw_enq_fail == msdu_info->num_seg) {
  2233. /*
  2234. * Unmap is needed only if enqueue
  2235. * failed for all segments.
  2236. */
  2237. qdf_nbuf_unmap(soc->osdev,
  2238. msdu_info->u.sg_info.
  2239. curr_seg->nbuf,
  2240. QDF_DMA_TO_DEVICE);
  2241. }
  2242. /*
  2243. * Free the nbuf for the current segment
  2244. * and make it point to the next in the list.
  2245. * For me, there are as many segments as there
  2246. * are no of clients.
  2247. */
  2248. qdf_nbuf_free(msdu_info->u.sg_info
  2249. .curr_seg->nbuf);
  2250. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2251. if (msdu_info->u.sg_info.curr_seg->next) {
  2252. msdu_info->u.sg_info.curr_seg =
  2253. msdu_info->u.sg_info
  2254. .curr_seg->next;
  2255. nbuf = msdu_info->u.sg_info
  2256. .curr_seg->nbuf;
  2257. } else
  2258. break;
  2259. i++;
  2260. continue;
  2261. }
  2262. /*
  2263. * For TSO frames, the nbuf users increment done for
  2264. * the current segment has to be reverted, since the
  2265. * hw enqueue for this segment failed
  2266. */
  2267. if (msdu_info->frm_type == dp_tx_frm_tso &&
  2268. msdu_info->u.tso_info.curr_seg) {
  2269. /*
  2270. * unmap and free current,
  2271. * retransmit remaining segments
  2272. */
  2273. dp_tx_comp_free_buf(soc, tx_desc);
  2274. i++;
  2275. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2276. continue;
  2277. }
  2278. if (msdu_info->frm_type == dp_tx_frm_sg)
  2279. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2280. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2281. goto done;
  2282. }
  2283. /*
  2284. * TODO
  2285. * if tso_info structure can be modified to have curr_seg
  2286. * as first element, following 2 blocks of code (for TSO and SG)
  2287. * can be combined into 1
  2288. */
  2289. /*
  2290. * For Multicast-Unicast converted packets,
  2291. * each converted frame (for a client) is represented as
  2292. * 1 segment
  2293. */
  2294. if ((msdu_info->frm_type == dp_tx_frm_sg) ||
  2295. (msdu_info->frm_type == dp_tx_frm_me)) {
  2296. if (msdu_info->u.sg_info.curr_seg->next) {
  2297. msdu_info->u.sg_info.curr_seg =
  2298. msdu_info->u.sg_info.curr_seg->next;
  2299. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2300. } else
  2301. break;
  2302. }
  2303. i++;
  2304. }
  2305. nbuf = NULL;
  2306. done:
  2307. return nbuf;
  2308. }
  2309. /**
  2310. * dp_tx_prepare_sg()- Extract SG info from NBUF and prepare msdu_info
  2311. * for SG frames
  2312. * @vdev: DP vdev handle
  2313. * @nbuf: skb
  2314. * @seg_info: Pointer to Segment info Descriptor to be prepared
  2315. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2316. *
  2317. * Return: NULL on success,
  2318. * nbuf when it fails to send
  2319. */
  2320. static qdf_nbuf_t dp_tx_prepare_sg(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2321. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  2322. {
  2323. uint32_t cur_frag, nr_frags, i;
  2324. qdf_dma_addr_t paddr;
  2325. struct dp_tx_sg_info_s *sg_info;
  2326. sg_info = &msdu_info->u.sg_info;
  2327. nr_frags = qdf_nbuf_get_nr_frags(nbuf);
  2328. if (QDF_STATUS_SUCCESS !=
  2329. qdf_nbuf_map_nbytes_single(vdev->osdev, nbuf,
  2330. QDF_DMA_TO_DEVICE,
  2331. qdf_nbuf_headlen(nbuf))) {
  2332. dp_tx_err("dma map error");
  2333. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2334. qdf_nbuf_free(nbuf);
  2335. return NULL;
  2336. }
  2337. paddr = qdf_nbuf_mapped_paddr_get(nbuf);
  2338. seg_info->frags[0].paddr_lo = paddr;
  2339. seg_info->frags[0].paddr_hi = ((uint64_t) paddr) >> 32;
  2340. seg_info->frags[0].len = qdf_nbuf_headlen(nbuf);
  2341. seg_info->frags[0].vaddr = (void *) nbuf;
  2342. for (cur_frag = 0; cur_frag < nr_frags; cur_frag++) {
  2343. if (QDF_STATUS_SUCCESS != qdf_nbuf_frag_map(vdev->osdev,
  2344. nbuf, 0,
  2345. QDF_DMA_TO_DEVICE,
  2346. cur_frag)) {
  2347. dp_tx_err("frag dma map error");
  2348. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2349. goto map_err;
  2350. }
  2351. paddr = qdf_nbuf_get_tx_frag_paddr(nbuf);
  2352. seg_info->frags[cur_frag + 1].paddr_lo = paddr;
  2353. seg_info->frags[cur_frag + 1].paddr_hi =
  2354. ((uint64_t) paddr) >> 32;
  2355. seg_info->frags[cur_frag + 1].len =
  2356. qdf_nbuf_get_frag_size(nbuf, cur_frag);
  2357. }
  2358. seg_info->frag_cnt = (cur_frag + 1);
  2359. seg_info->total_len = qdf_nbuf_len(nbuf);
  2360. seg_info->next = NULL;
  2361. sg_info->curr_seg = seg_info;
  2362. msdu_info->frm_type = dp_tx_frm_sg;
  2363. msdu_info->num_seg = 1;
  2364. return nbuf;
  2365. map_err:
  2366. /* restore paddr into nbuf before calling unmap */
  2367. qdf_nbuf_mapped_paddr_set(nbuf,
  2368. (qdf_dma_addr_t)(seg_info->frags[0].paddr_lo |
  2369. ((uint64_t)
  2370. seg_info->frags[0].paddr_hi) << 32));
  2371. qdf_nbuf_unmap_nbytes_single(vdev->osdev, nbuf,
  2372. QDF_DMA_TO_DEVICE,
  2373. seg_info->frags[0].len);
  2374. for (i = 1; i <= cur_frag; i++) {
  2375. qdf_mem_unmap_page(vdev->osdev, (qdf_dma_addr_t)
  2376. (seg_info->frags[i].paddr_lo | ((uint64_t)
  2377. seg_info->frags[i].paddr_hi) << 32),
  2378. seg_info->frags[i].len,
  2379. QDF_DMA_TO_DEVICE);
  2380. }
  2381. qdf_nbuf_free(nbuf);
  2382. return NULL;
  2383. }
  2384. /**
  2385. * dp_tx_add_tx_sniffer_meta_data()- Add tx_sniffer meta hdr info
  2386. * @vdev: DP vdev handle
  2387. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2388. * @ppdu_cookie: PPDU cookie that should be replayed in the ppdu completions
  2389. *
  2390. * Return: NULL on failure,
  2391. * nbuf when extracted successfully
  2392. */
  2393. static
  2394. void dp_tx_add_tx_sniffer_meta_data(struct dp_vdev *vdev,
  2395. struct dp_tx_msdu_info_s *msdu_info,
  2396. uint16_t ppdu_cookie)
  2397. {
  2398. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2399. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2400. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2401. HTT_TX_MSDU_EXT2_DESC_FLAG_SEND_AS_STANDALONE_SET
  2402. (msdu_info->meta_data[5], 1);
  2403. HTT_TX_MSDU_EXT2_DESC_FLAG_HOST_OPAQUE_VALID_SET
  2404. (msdu_info->meta_data[5], 1);
  2405. HTT_TX_MSDU_EXT2_DESC_HOST_OPAQUE_COOKIE_SET
  2406. (msdu_info->meta_data[6], ppdu_cookie);
  2407. msdu_info->exception_fw = 1;
  2408. msdu_info->is_tx_sniffer = 1;
  2409. }
  2410. #ifdef MESH_MODE_SUPPORT
  2411. /**
  2412. * dp_tx_extract_mesh_meta_data()- Extract mesh meta hdr info from nbuf
  2413. and prepare msdu_info for mesh frames.
  2414. * @vdev: DP vdev handle
  2415. * @nbuf: skb
  2416. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2417. *
  2418. * Return: NULL on failure,
  2419. * nbuf when extracted successfully
  2420. */
  2421. static
  2422. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2423. struct dp_tx_msdu_info_s *msdu_info)
  2424. {
  2425. struct meta_hdr_s *mhdr;
  2426. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2427. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2428. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2429. if (CB_FTYPE_MESH_TX_INFO != qdf_nbuf_get_tx_ftype(nbuf)) {
  2430. msdu_info->exception_fw = 0;
  2431. goto remove_meta_hdr;
  2432. }
  2433. msdu_info->exception_fw = 1;
  2434. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2435. meta_data->host_tx_desc_pool = 1;
  2436. meta_data->update_peer_cache = 1;
  2437. meta_data->learning_frame = 1;
  2438. if (!(mhdr->flags & METAHDR_FLAG_AUTO_RATE)) {
  2439. meta_data->power = mhdr->power;
  2440. meta_data->mcs_mask = 1 << mhdr->rate_info[0].mcs;
  2441. meta_data->nss_mask = 1 << mhdr->rate_info[0].nss;
  2442. meta_data->pream_type = mhdr->rate_info[0].preamble_type;
  2443. meta_data->retry_limit = mhdr->rate_info[0].max_tries;
  2444. meta_data->dyn_bw = 1;
  2445. meta_data->valid_pwr = 1;
  2446. meta_data->valid_mcs_mask = 1;
  2447. meta_data->valid_nss_mask = 1;
  2448. meta_data->valid_preamble_type = 1;
  2449. meta_data->valid_retries = 1;
  2450. meta_data->valid_bw_info = 1;
  2451. }
  2452. if (mhdr->flags & METAHDR_FLAG_NOENCRYPT) {
  2453. meta_data->encrypt_type = 0;
  2454. meta_data->valid_encrypt_type = 1;
  2455. meta_data->learning_frame = 0;
  2456. }
  2457. meta_data->valid_key_flags = 1;
  2458. meta_data->key_flags = (mhdr->keyix & 0x3);
  2459. remove_meta_hdr:
  2460. if (qdf_nbuf_pull_head(nbuf, sizeof(struct meta_hdr_s)) == NULL) {
  2461. dp_tx_err("qdf_nbuf_pull_head failed");
  2462. qdf_nbuf_free(nbuf);
  2463. return NULL;
  2464. }
  2465. msdu_info->tid = qdf_nbuf_get_priority(nbuf);
  2466. dp_tx_info("Meta hdr %0x %0x %0x %0x %0x %0x"
  2467. " tid %d to_fw %d",
  2468. msdu_info->meta_data[0],
  2469. msdu_info->meta_data[1],
  2470. msdu_info->meta_data[2],
  2471. msdu_info->meta_data[3],
  2472. msdu_info->meta_data[4],
  2473. msdu_info->meta_data[5],
  2474. msdu_info->tid, msdu_info->exception_fw);
  2475. return nbuf;
  2476. }
  2477. #else
  2478. static
  2479. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2480. struct dp_tx_msdu_info_s *msdu_info)
  2481. {
  2482. return nbuf;
  2483. }
  2484. #endif
  2485. /**
  2486. * dp_check_exc_metadata() - Checks if parameters are valid
  2487. * @tx_exc - holds all exception path parameters
  2488. *
  2489. * Returns true when all the parameters are valid else false
  2490. *
  2491. */
  2492. static bool dp_check_exc_metadata(struct cdp_tx_exception_metadata *tx_exc)
  2493. {
  2494. bool invalid_tid = (tx_exc->tid >= DP_MAX_TIDS && tx_exc->tid !=
  2495. HTT_INVALID_TID);
  2496. bool invalid_encap_type =
  2497. (tx_exc->tx_encap_type > htt_cmn_pkt_num_types &&
  2498. tx_exc->tx_encap_type != CDP_INVALID_TX_ENCAP_TYPE);
  2499. bool invalid_sec_type = (tx_exc->sec_type > cdp_num_sec_types &&
  2500. tx_exc->sec_type != CDP_INVALID_SEC_TYPE);
  2501. bool invalid_cookie = (tx_exc->is_tx_sniffer == 1 &&
  2502. tx_exc->ppdu_cookie == 0);
  2503. if (tx_exc->is_intrabss_fwd)
  2504. return true;
  2505. if (invalid_tid || invalid_encap_type || invalid_sec_type ||
  2506. invalid_cookie) {
  2507. return false;
  2508. }
  2509. return true;
  2510. }
  2511. #ifdef ATH_SUPPORT_IQUE
  2512. /**
  2513. * dp_tx_mcast_enhance() - Multicast enhancement on TX
  2514. * @vdev: vdev handle
  2515. * @nbuf: skb
  2516. *
  2517. * Return: true on success,
  2518. * false on failure
  2519. */
  2520. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2521. {
  2522. qdf_ether_header_t *eh;
  2523. /* Mcast to Ucast Conversion*/
  2524. if (qdf_likely(!vdev->mcast_enhancement_en))
  2525. return true;
  2526. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2527. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) &&
  2528. !DP_FRAME_IS_BROADCAST((eh)->ether_dhost)) {
  2529. dp_verbose_debug("Mcast frm for ME %pK", vdev);
  2530. qdf_nbuf_set_next(nbuf, NULL);
  2531. DP_STATS_INC_PKT(vdev, tx_i.mcast_en.mcast_pkt, 1,
  2532. qdf_nbuf_len(nbuf));
  2533. if (dp_tx_prepare_send_me(vdev, nbuf) ==
  2534. QDF_STATUS_SUCCESS) {
  2535. return false;
  2536. }
  2537. if (qdf_unlikely(vdev->igmp_mcast_enhanc_en > 0)) {
  2538. if (dp_tx_prepare_send_igmp_me(vdev, nbuf) ==
  2539. QDF_STATUS_SUCCESS) {
  2540. return false;
  2541. }
  2542. }
  2543. }
  2544. return true;
  2545. }
  2546. #else
  2547. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2548. {
  2549. return true;
  2550. }
  2551. #endif
  2552. /**
  2553. * dp_tx_per_pkt_vdev_id_check() - vdev id check for frame
  2554. * @nbuf: qdf_nbuf_t
  2555. * @vdev: struct dp_vdev *
  2556. *
  2557. * Allow packet for processing only if it is for peer client which is
  2558. * connected with same vap. Drop packet if client is connected to
  2559. * different vap.
  2560. *
  2561. * Return: QDF_STATUS
  2562. */
  2563. static inline QDF_STATUS
  2564. dp_tx_per_pkt_vdev_id_check(qdf_nbuf_t nbuf, struct dp_vdev *vdev)
  2565. {
  2566. struct dp_ast_entry *dst_ast_entry = NULL;
  2567. qdf_ether_header_t *eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2568. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) ||
  2569. DP_FRAME_IS_BROADCAST((eh)->ether_dhost))
  2570. return QDF_STATUS_SUCCESS;
  2571. qdf_spin_lock_bh(&vdev->pdev->soc->ast_lock);
  2572. dst_ast_entry = dp_peer_ast_hash_find_by_vdevid(vdev->pdev->soc,
  2573. eh->ether_dhost,
  2574. vdev->vdev_id);
  2575. /* If there is no ast entry, return failure */
  2576. if (qdf_unlikely(!dst_ast_entry)) {
  2577. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2578. return QDF_STATUS_E_FAILURE;
  2579. }
  2580. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2581. return QDF_STATUS_SUCCESS;
  2582. }
  2583. /**
  2584. * dp_tx_nawds_handler() - NAWDS handler
  2585. *
  2586. * @soc: DP soc handle
  2587. * @vdev_id: id of DP vdev handle
  2588. * @msdu_info: msdu_info required to create HTT metadata
  2589. * @nbuf: skb
  2590. *
  2591. * This API transfers the multicast frames with the peer id
  2592. * on NAWDS enabled peer.
  2593. * Return: none
  2594. */
  2595. static inline
  2596. void dp_tx_nawds_handler(struct dp_soc *soc, struct dp_vdev *vdev,
  2597. struct dp_tx_msdu_info_s *msdu_info,
  2598. qdf_nbuf_t nbuf, uint16_t sa_peer_id)
  2599. {
  2600. struct dp_peer *peer = NULL;
  2601. qdf_nbuf_t nbuf_clone = NULL;
  2602. uint16_t peer_id = DP_INVALID_PEER;
  2603. struct dp_txrx_peer *txrx_peer;
  2604. /* This check avoids pkt forwarding which is entered
  2605. * in the ast table but still doesn't have valid peerid.
  2606. */
  2607. if (sa_peer_id == HTT_INVALID_PEER)
  2608. return;
  2609. qdf_spin_lock_bh(&vdev->peer_list_lock);
  2610. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  2611. txrx_peer = dp_get_txrx_peer(peer);
  2612. if (!txrx_peer)
  2613. continue;
  2614. if (!txrx_peer->bss_peer && txrx_peer->nawds_enabled) {
  2615. peer_id = peer->peer_id;
  2616. if (!dp_peer_is_primary_link_peer(peer))
  2617. continue;
  2618. /* Multicast packets needs to be
  2619. * dropped in case of intra bss forwarding
  2620. */
  2621. if (sa_peer_id == txrx_peer->peer_id) {
  2622. dp_tx_debug("multicast packet");
  2623. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  2624. tx.nawds_mcast_drop,
  2625. 1);
  2626. continue;
  2627. }
  2628. nbuf_clone = qdf_nbuf_clone(nbuf);
  2629. if (!nbuf_clone) {
  2630. QDF_TRACE(QDF_MODULE_ID_DP,
  2631. QDF_TRACE_LEVEL_ERROR,
  2632. FL("nbuf clone failed"));
  2633. break;
  2634. }
  2635. nbuf_clone = dp_tx_send_msdu_single(vdev, nbuf_clone,
  2636. msdu_info, peer_id,
  2637. NULL);
  2638. if (nbuf_clone) {
  2639. dp_tx_debug("pkt send failed");
  2640. qdf_nbuf_free(nbuf_clone);
  2641. } else {
  2642. if (peer_id != DP_INVALID_PEER)
  2643. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  2644. tx.nawds_mcast,
  2645. 1, qdf_nbuf_len(nbuf));
  2646. }
  2647. }
  2648. }
  2649. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  2650. }
  2651. /**
  2652. * dp_tx_send_exception() - Transmit a frame on a given VAP in exception path
  2653. * @soc: DP soc handle
  2654. * @vdev_id: id of DP vdev handle
  2655. * @nbuf: skb
  2656. * @tx_exc_metadata: Handle that holds exception path meta data
  2657. *
  2658. * Entry point for Core Tx layer (DP_TX) invoked from
  2659. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2660. *
  2661. * Return: NULL on success,
  2662. * nbuf when it fails to send
  2663. */
  2664. qdf_nbuf_t
  2665. dp_tx_send_exception(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2666. qdf_nbuf_t nbuf,
  2667. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2668. {
  2669. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2670. qdf_ether_header_t *eh = NULL;
  2671. struct dp_tx_msdu_info_s msdu_info;
  2672. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2673. DP_MOD_ID_TX_EXCEPTION);
  2674. if (qdf_unlikely(!vdev))
  2675. goto fail;
  2676. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  2677. if (!tx_exc_metadata)
  2678. goto fail;
  2679. msdu_info.tid = tx_exc_metadata->tid;
  2680. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2681. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2682. QDF_MAC_ADDR_REF(nbuf->data));
  2683. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2684. if (qdf_unlikely(!dp_check_exc_metadata(tx_exc_metadata))) {
  2685. dp_tx_err("Invalid parameters in exception path");
  2686. goto fail;
  2687. }
  2688. /* Basic sanity checks for unsupported packets */
  2689. /* MESH mode */
  2690. if (qdf_unlikely(vdev->mesh_vdev)) {
  2691. dp_tx_err("Mesh mode is not supported in exception path");
  2692. goto fail;
  2693. }
  2694. /*
  2695. * Classify the frame and call corresponding
  2696. * "prepare" function which extracts the segment (TSO)
  2697. * and fragmentation information (for TSO , SG, ME, or Raw)
  2698. * into MSDU_INFO structure which is later used to fill
  2699. * SW and HW descriptors.
  2700. */
  2701. if (qdf_nbuf_is_tso(nbuf)) {
  2702. dp_verbose_debug("TSO frame %pK", vdev);
  2703. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2704. qdf_nbuf_len(nbuf));
  2705. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2706. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2707. qdf_nbuf_len(nbuf));
  2708. goto fail;
  2709. }
  2710. goto send_multiple;
  2711. }
  2712. /* SG */
  2713. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2714. struct dp_tx_seg_info_s seg_info = {0};
  2715. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info, &msdu_info);
  2716. if (!nbuf)
  2717. goto fail;
  2718. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  2719. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  2720. qdf_nbuf_len(nbuf));
  2721. goto send_multiple;
  2722. }
  2723. if (qdf_likely(tx_exc_metadata->is_tx_sniffer)) {
  2724. DP_STATS_INC_PKT(vdev, tx_i.sniffer_rcvd, 1,
  2725. qdf_nbuf_len(nbuf));
  2726. dp_tx_add_tx_sniffer_meta_data(vdev, &msdu_info,
  2727. tx_exc_metadata->ppdu_cookie);
  2728. }
  2729. /*
  2730. * Get HW Queue to use for this frame.
  2731. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2732. * dedicated for data and 1 for command.
  2733. * "queue_id" maps to one hardware ring.
  2734. * With each ring, we also associate a unique Tx descriptor pool
  2735. * to minimize lock contention for these resources.
  2736. */
  2737. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2738. if (qdf_likely(tx_exc_metadata->is_intrabss_fwd)) {
  2739. if (qdf_unlikely(vdev->nawds_enabled)) {
  2740. /*
  2741. * This is a multicast packet
  2742. */
  2743. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  2744. tx_exc_metadata->peer_id);
  2745. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  2746. 1, qdf_nbuf_len(nbuf));
  2747. }
  2748. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2749. DP_INVALID_PEER, NULL);
  2750. } else {
  2751. /*
  2752. * Check exception descriptors
  2753. */
  2754. if (dp_tx_exception_limit_check(vdev))
  2755. goto fail;
  2756. /* Single linear frame */
  2757. /*
  2758. * If nbuf is a simple linear frame, use send_single function to
  2759. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  2760. * SRNG. There is no need to setup a MSDU extension descriptor.
  2761. */
  2762. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2763. tx_exc_metadata->peer_id,
  2764. tx_exc_metadata);
  2765. }
  2766. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2767. return nbuf;
  2768. send_multiple:
  2769. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  2770. fail:
  2771. if (vdev)
  2772. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2773. dp_verbose_debug("pkt send failed");
  2774. return nbuf;
  2775. }
  2776. /**
  2777. * dp_tx_send_exception_vdev_id_check() - Transmit a frame on a given VAP
  2778. * in exception path in special case to avoid regular exception path chk.
  2779. * @soc: DP soc handle
  2780. * @vdev_id: id of DP vdev handle
  2781. * @nbuf: skb
  2782. * @tx_exc_metadata: Handle that holds exception path meta data
  2783. *
  2784. * Entry point for Core Tx layer (DP_TX) invoked from
  2785. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2786. *
  2787. * Return: NULL on success,
  2788. * nbuf when it fails to send
  2789. */
  2790. qdf_nbuf_t
  2791. dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc_hdl,
  2792. uint8_t vdev_id, qdf_nbuf_t nbuf,
  2793. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2794. {
  2795. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2796. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2797. DP_MOD_ID_TX_EXCEPTION);
  2798. if (qdf_unlikely(!vdev))
  2799. goto fail;
  2800. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  2801. == QDF_STATUS_E_FAILURE)) {
  2802. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  2803. goto fail;
  2804. }
  2805. /* Unref count as it will agin be taken inside dp_tx_exception */
  2806. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2807. return dp_tx_send_exception(soc_hdl, vdev_id, nbuf, tx_exc_metadata);
  2808. fail:
  2809. if (vdev)
  2810. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2811. dp_verbose_debug("pkt send failed");
  2812. return nbuf;
  2813. }
  2814. /**
  2815. * dp_tx_send_mesh() - Transmit mesh frame on a given VAP
  2816. * @soc: DP soc handle
  2817. * @vdev_id: DP vdev handle
  2818. * @nbuf: skb
  2819. *
  2820. * Entry point for Core Tx layer (DP_TX) invoked from
  2821. * hard_start_xmit in OSIF/HDD
  2822. *
  2823. * Return: NULL on success,
  2824. * nbuf when it fails to send
  2825. */
  2826. #ifdef MESH_MODE_SUPPORT
  2827. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2828. qdf_nbuf_t nbuf)
  2829. {
  2830. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2831. struct meta_hdr_s *mhdr;
  2832. qdf_nbuf_t nbuf_mesh = NULL;
  2833. qdf_nbuf_t nbuf_clone = NULL;
  2834. struct dp_vdev *vdev;
  2835. uint8_t no_enc_frame = 0;
  2836. nbuf_mesh = qdf_nbuf_unshare(nbuf);
  2837. if (!nbuf_mesh) {
  2838. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2839. "qdf_nbuf_unshare failed");
  2840. return nbuf;
  2841. }
  2842. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_MESH);
  2843. if (!vdev) {
  2844. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2845. "vdev is NULL for vdev_id %d", vdev_id);
  2846. return nbuf;
  2847. }
  2848. nbuf = nbuf_mesh;
  2849. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2850. if ((vdev->sec_type != cdp_sec_type_none) &&
  2851. (mhdr->flags & METAHDR_FLAG_NOENCRYPT))
  2852. no_enc_frame = 1;
  2853. if (mhdr->flags & METAHDR_FLAG_NOQOS)
  2854. qdf_nbuf_set_priority(nbuf, HTT_TX_EXT_TID_NON_QOS_MCAST_BCAST);
  2855. if ((mhdr->flags & METAHDR_FLAG_INFO_UPDATED) &&
  2856. !no_enc_frame) {
  2857. nbuf_clone = qdf_nbuf_clone(nbuf);
  2858. if (!nbuf_clone) {
  2859. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2860. "qdf_nbuf_clone failed");
  2861. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2862. return nbuf;
  2863. }
  2864. qdf_nbuf_set_tx_ftype(nbuf_clone, CB_FTYPE_MESH_TX_INFO);
  2865. }
  2866. if (nbuf_clone) {
  2867. if (!dp_tx_send(soc_hdl, vdev_id, nbuf_clone)) {
  2868. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2869. } else {
  2870. qdf_nbuf_free(nbuf_clone);
  2871. }
  2872. }
  2873. if (no_enc_frame)
  2874. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_MESH_TX_INFO);
  2875. else
  2876. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_INVALID);
  2877. nbuf = dp_tx_send(soc_hdl, vdev_id, nbuf);
  2878. if ((!nbuf) && no_enc_frame) {
  2879. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2880. }
  2881. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2882. return nbuf;
  2883. }
  2884. #else
  2885. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  2886. qdf_nbuf_t nbuf)
  2887. {
  2888. return dp_tx_send(soc, vdev_id, nbuf);
  2889. }
  2890. #endif
  2891. #ifdef QCA_DP_TX_NBUF_AND_NBUF_DATA_PREFETCH
  2892. static inline
  2893. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2894. {
  2895. if (nbuf) {
  2896. qdf_prefetch(&nbuf->len);
  2897. qdf_prefetch(&nbuf->data);
  2898. }
  2899. }
  2900. #else
  2901. static inline
  2902. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2903. {
  2904. }
  2905. #endif
  2906. /**
  2907. * dp_tx_send() - Transmit a frame on a given VAP
  2908. * @soc: DP soc handle
  2909. * @vdev_id: id of DP vdev handle
  2910. * @nbuf: skb
  2911. *
  2912. * Entry point for Core Tx layer (DP_TX) invoked from
  2913. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  2914. * cases
  2915. *
  2916. * Return: NULL on success,
  2917. * nbuf when it fails to send
  2918. */
  2919. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2920. qdf_nbuf_t nbuf)
  2921. {
  2922. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2923. uint16_t peer_id = HTT_INVALID_PEER;
  2924. /*
  2925. * doing a memzero is causing additional function call overhead
  2926. * so doing static stack clearing
  2927. */
  2928. struct dp_tx_msdu_info_s msdu_info = {0};
  2929. struct dp_vdev *vdev = NULL;
  2930. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  2931. return nbuf;
  2932. /*
  2933. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  2934. * this in per packet path.
  2935. *
  2936. * As in this path vdev memory is already protected with netdev
  2937. * tx lock
  2938. */
  2939. vdev = soc->vdev_id_map[vdev_id];
  2940. if (qdf_unlikely(!vdev))
  2941. return nbuf;
  2942. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2943. QDF_MAC_ADDR_REF(nbuf->data));
  2944. /*
  2945. * Set Default Host TID value to invalid TID
  2946. * (TID override disabled)
  2947. */
  2948. msdu_info.tid = HTT_TX_EXT_TID_INVALID;
  2949. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2950. if (qdf_unlikely(vdev->mesh_vdev)) {
  2951. qdf_nbuf_t nbuf_mesh = dp_tx_extract_mesh_meta_data(vdev, nbuf,
  2952. &msdu_info);
  2953. if (!nbuf_mesh) {
  2954. dp_verbose_debug("Extracting mesh metadata failed");
  2955. return nbuf;
  2956. }
  2957. nbuf = nbuf_mesh;
  2958. }
  2959. /*
  2960. * Get HW Queue to use for this frame.
  2961. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2962. * dedicated for data and 1 for command.
  2963. * "queue_id" maps to one hardware ring.
  2964. * With each ring, we also associate a unique Tx descriptor pool
  2965. * to minimize lock contention for these resources.
  2966. */
  2967. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2968. /*
  2969. * TCL H/W supports 2 DSCP-TID mapping tables.
  2970. * Table 1 - Default DSCP-TID mapping table
  2971. * Table 2 - 1 DSCP-TID override table
  2972. *
  2973. * If we need a different DSCP-TID mapping for this vap,
  2974. * call tid_classify to extract DSCP/ToS from frame and
  2975. * map to a TID and store in msdu_info. This is later used
  2976. * to fill in TCL Input descriptor (per-packet TID override).
  2977. */
  2978. dp_tx_classify_tid(vdev, nbuf, &msdu_info);
  2979. /*
  2980. * Classify the frame and call corresponding
  2981. * "prepare" function which extracts the segment (TSO)
  2982. * and fragmentation information (for TSO , SG, ME, or Raw)
  2983. * into MSDU_INFO structure which is later used to fill
  2984. * SW and HW descriptors.
  2985. */
  2986. if (qdf_nbuf_is_tso(nbuf)) {
  2987. dp_verbose_debug("TSO frame %pK", vdev);
  2988. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2989. qdf_nbuf_len(nbuf));
  2990. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2991. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2992. qdf_nbuf_len(nbuf));
  2993. return nbuf;
  2994. }
  2995. goto send_multiple;
  2996. }
  2997. /* SG */
  2998. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2999. if (qdf_nbuf_get_nr_frags(nbuf) > DP_TX_MAX_NUM_FRAGS - 1) {
  3000. if (qdf_unlikely(qdf_nbuf_linearize(nbuf)))
  3001. return nbuf;
  3002. } else {
  3003. struct dp_tx_seg_info_s seg_info = {0};
  3004. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info,
  3005. &msdu_info);
  3006. if (!nbuf)
  3007. return NULL;
  3008. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  3009. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  3010. qdf_nbuf_len(nbuf));
  3011. goto send_multiple;
  3012. }
  3013. }
  3014. if (qdf_unlikely(!dp_tx_mcast_enhance(vdev, nbuf)))
  3015. return NULL;
  3016. /* RAW */
  3017. if (qdf_unlikely(vdev->tx_encap_type == htt_cmn_pkt_type_raw)) {
  3018. struct dp_tx_seg_info_s seg_info = {0};
  3019. nbuf = dp_tx_prepare_raw(vdev, nbuf, &seg_info, &msdu_info);
  3020. if (!nbuf)
  3021. return NULL;
  3022. dp_verbose_debug("Raw frame %pK", vdev);
  3023. goto send_multiple;
  3024. }
  3025. if (qdf_unlikely(vdev->nawds_enabled)) {
  3026. qdf_ether_header_t *eh = (qdf_ether_header_t *)
  3027. qdf_nbuf_data(nbuf);
  3028. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  3029. uint16_t sa_peer_id = DP_INVALID_PEER;
  3030. if (!soc->ast_offload_support) {
  3031. struct dp_ast_entry *ast_entry = NULL;
  3032. qdf_spin_lock_bh(&soc->ast_lock);
  3033. ast_entry = dp_peer_ast_hash_find_by_pdevid
  3034. (soc,
  3035. (uint8_t *)(eh->ether_shost),
  3036. vdev->pdev->pdev_id);
  3037. if (ast_entry)
  3038. sa_peer_id = ast_entry->peer_id;
  3039. qdf_spin_unlock_bh(&soc->ast_lock);
  3040. }
  3041. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  3042. sa_peer_id);
  3043. }
  3044. peer_id = DP_INVALID_PEER;
  3045. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  3046. 1, qdf_nbuf_len(nbuf));
  3047. }
  3048. /* Single linear frame */
  3049. /*
  3050. * If nbuf is a simple linear frame, use send_single function to
  3051. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  3052. * SRNG. There is no need to setup a MSDU extension descriptor.
  3053. */
  3054. dp_tx_prefetch_nbuf_data(nbuf);
  3055. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info, peer_id, NULL);
  3056. return nbuf;
  3057. send_multiple:
  3058. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  3059. if (qdf_unlikely(nbuf && msdu_info.frm_type == dp_tx_frm_raw))
  3060. dp_tx_raw_prepare_unset(vdev->pdev->soc, nbuf);
  3061. return nbuf;
  3062. }
  3063. /**
  3064. * dp_tx_send_vdev_id_check() - Transmit a frame on a given VAP in special
  3065. * case to vaoid check in perpkt path.
  3066. * @soc: DP soc handle
  3067. * @vdev_id: id of DP vdev handle
  3068. * @nbuf: skb
  3069. *
  3070. * Entry point for Core Tx layer (DP_TX) invoked from
  3071. * hard_start_xmit in OSIF/HDD to transmit packet through dp_tx_send
  3072. * with special condition to avoid per pkt check in dp_tx_send
  3073. *
  3074. * Return: NULL on success,
  3075. * nbuf when it fails to send
  3076. */
  3077. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc_hdl,
  3078. uint8_t vdev_id, qdf_nbuf_t nbuf)
  3079. {
  3080. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3081. struct dp_vdev *vdev = NULL;
  3082. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  3083. return nbuf;
  3084. /*
  3085. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  3086. * this in per packet path.
  3087. *
  3088. * As in this path vdev memory is already protected with netdev
  3089. * tx lock
  3090. */
  3091. vdev = soc->vdev_id_map[vdev_id];
  3092. if (qdf_unlikely(!vdev))
  3093. return nbuf;
  3094. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  3095. == QDF_STATUS_E_FAILURE)) {
  3096. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  3097. return nbuf;
  3098. }
  3099. return dp_tx_send(soc_hdl, vdev_id, nbuf);
  3100. }
  3101. #ifdef UMAC_SUPPORT_PROXY_ARP
  3102. /**
  3103. * dp_tx_proxy_arp() - Tx proxy arp handler
  3104. * @vdev: datapath vdev handle
  3105. * @buf: sk buffer
  3106. *
  3107. * Return: status
  3108. */
  3109. static inline
  3110. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3111. {
  3112. if (vdev->osif_proxy_arp)
  3113. return vdev->osif_proxy_arp(vdev->osif_vdev, nbuf);
  3114. /*
  3115. * when UMAC_SUPPORT_PROXY_ARP is defined, we expect
  3116. * osif_proxy_arp has a valid function pointer assigned
  3117. * to it
  3118. */
  3119. dp_tx_err("valid function pointer for osif_proxy_arp is expected!!\n");
  3120. return QDF_STATUS_NOT_INITIALIZED;
  3121. }
  3122. #else
  3123. /**
  3124. * dp_tx_proxy_arp() - Tx proxy arp handler
  3125. * @vdev: datapath vdev handle
  3126. * @buf: sk buffer
  3127. *
  3128. * This function always return 0 when UMAC_SUPPORT_PROXY_ARP
  3129. * is not defined.
  3130. *
  3131. * Return: status
  3132. */
  3133. static inline
  3134. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3135. {
  3136. return QDF_STATUS_SUCCESS;
  3137. }
  3138. #endif
  3139. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  3140. #ifdef WLAN_MCAST_MLO
  3141. static bool
  3142. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3143. struct dp_tx_desc_s *tx_desc,
  3144. qdf_nbuf_t nbuf,
  3145. uint8_t reinject_reason)
  3146. {
  3147. if (reinject_reason == HTT_TX_FW2WBM_REINJECT_REASON_MLO_MCAST) {
  3148. if (soc->arch_ops.dp_tx_mcast_handler)
  3149. soc->arch_ops.dp_tx_mcast_handler(soc, vdev, nbuf);
  3150. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3151. return true;
  3152. }
  3153. return false;
  3154. }
  3155. #else /* WLAN_MCAST_MLO */
  3156. static inline bool
  3157. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3158. struct dp_tx_desc_s *tx_desc,
  3159. qdf_nbuf_t nbuf,
  3160. uint8_t reinject_reason)
  3161. {
  3162. return false;
  3163. }
  3164. #endif /* WLAN_MCAST_MLO */
  3165. #else
  3166. static inline bool
  3167. dp_tx_reinject_mlo_hdl(struct dp_soc *soc, struct dp_vdev *vdev,
  3168. struct dp_tx_desc_s *tx_desc,
  3169. qdf_nbuf_t nbuf,
  3170. uint8_t reinject_reason)
  3171. {
  3172. return false;
  3173. }
  3174. #endif
  3175. /**
  3176. * dp_tx_reinject_handler() - Tx Reinject Handler
  3177. * @soc: datapath soc handle
  3178. * @vdev: datapath vdev handle
  3179. * @tx_desc: software descriptor head pointer
  3180. * @status : Tx completion status from HTT descriptor
  3181. * @reinject_reason : reinject reason from HTT descriptor
  3182. *
  3183. * This function reinjects frames back to Target.
  3184. * Todo - Host queue needs to be added
  3185. *
  3186. * Return: none
  3187. */
  3188. void dp_tx_reinject_handler(struct dp_soc *soc,
  3189. struct dp_vdev *vdev,
  3190. struct dp_tx_desc_s *tx_desc,
  3191. uint8_t *status,
  3192. uint8_t reinject_reason)
  3193. {
  3194. struct dp_peer *peer = NULL;
  3195. uint32_t peer_id = HTT_INVALID_PEER;
  3196. qdf_nbuf_t nbuf = tx_desc->nbuf;
  3197. qdf_nbuf_t nbuf_copy = NULL;
  3198. struct dp_tx_msdu_info_s msdu_info;
  3199. #ifdef WDS_VENDOR_EXTENSION
  3200. int is_mcast = 0, is_ucast = 0;
  3201. int num_peers_3addr = 0;
  3202. qdf_ether_header_t *eth_hdr = (qdf_ether_header_t *)(qdf_nbuf_data(nbuf));
  3203. struct ieee80211_frame_addr4 *wh = (struct ieee80211_frame_addr4 *)(qdf_nbuf_data(nbuf));
  3204. #endif
  3205. struct dp_txrx_peer *txrx_peer;
  3206. qdf_assert(vdev);
  3207. dp_tx_debug("Tx reinject path");
  3208. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  3209. qdf_nbuf_len(tx_desc->nbuf));
  3210. if (dp_tx_reinject_mlo_hdl(soc, vdev, tx_desc, nbuf, reinject_reason))
  3211. return;
  3212. #ifdef WDS_VENDOR_EXTENSION
  3213. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  3214. is_mcast = (IS_MULTICAST(wh->i_addr1)) ? 1 : 0;
  3215. } else {
  3216. is_mcast = (IS_MULTICAST(eth_hdr->ether_dhost)) ? 1 : 0;
  3217. }
  3218. is_ucast = !is_mcast;
  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 || txrx_peer->bss_peer)
  3223. continue;
  3224. /* Detect wds peers that use 3-addr framing for mcast.
  3225. * if there are any, the bss_peer is used to send the
  3226. * the mcast frame using 3-addr format. all wds enabled
  3227. * peers that use 4-addr framing for mcast frames will
  3228. * be duplicated and sent as 4-addr frames below.
  3229. */
  3230. if (!txrx_peer->wds_enabled ||
  3231. !txrx_peer->wds_ecm.wds_tx_mcast_4addr) {
  3232. num_peers_3addr = 1;
  3233. break;
  3234. }
  3235. }
  3236. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3237. #endif
  3238. if (qdf_unlikely(vdev->mesh_vdev)) {
  3239. DP_TX_FREE_SINGLE_BUF(vdev->pdev->soc, tx_desc->nbuf);
  3240. } else {
  3241. qdf_spin_lock_bh(&vdev->peer_list_lock);
  3242. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3243. txrx_peer = dp_get_txrx_peer(peer);
  3244. if (!txrx_peer)
  3245. continue;
  3246. if ((txrx_peer->peer_id != HTT_INVALID_PEER) &&
  3247. #ifdef WDS_VENDOR_EXTENSION
  3248. /*
  3249. * . if 3-addr STA, then send on BSS Peer
  3250. * . if Peer WDS enabled and accept 4-addr mcast,
  3251. * send mcast on that peer only
  3252. * . if Peer WDS enabled and accept 4-addr ucast,
  3253. * send ucast on that peer only
  3254. */
  3255. ((txrx_peer->bss_peer && num_peers_3addr && is_mcast) ||
  3256. (txrx_peer->wds_enabled &&
  3257. ((is_mcast && txrx_peer->wds_ecm.wds_tx_mcast_4addr) ||
  3258. (is_ucast &&
  3259. txrx_peer->wds_ecm.wds_tx_ucast_4addr))))) {
  3260. #else
  3261. (txrx_peer->bss_peer &&
  3262. (dp_tx_proxy_arp(vdev, nbuf) == QDF_STATUS_SUCCESS))) {
  3263. #endif
  3264. peer_id = DP_INVALID_PEER;
  3265. nbuf_copy = qdf_nbuf_copy(nbuf);
  3266. if (!nbuf_copy) {
  3267. dp_tx_debug("nbuf copy failed");
  3268. break;
  3269. }
  3270. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  3271. dp_tx_get_queue(vdev, nbuf,
  3272. &msdu_info.tx_queue);
  3273. nbuf_copy = dp_tx_send_msdu_single(vdev,
  3274. nbuf_copy,
  3275. &msdu_info,
  3276. peer_id,
  3277. NULL);
  3278. if (nbuf_copy) {
  3279. dp_tx_debug("pkt send failed");
  3280. qdf_nbuf_free(nbuf_copy);
  3281. }
  3282. }
  3283. }
  3284. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3285. }
  3286. qdf_nbuf_free(nbuf);
  3287. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3288. }
  3289. /**
  3290. * dp_tx_inspect_handler() - Tx Inspect Handler
  3291. * @soc: datapath soc handle
  3292. * @vdev: datapath vdev handle
  3293. * @tx_desc: software descriptor head pointer
  3294. * @status : Tx completion status from HTT descriptor
  3295. *
  3296. * Handles Tx frames sent back to Host for inspection
  3297. * (ProxyARP)
  3298. *
  3299. * Return: none
  3300. */
  3301. void dp_tx_inspect_handler(struct dp_soc *soc,
  3302. struct dp_vdev *vdev,
  3303. struct dp_tx_desc_s *tx_desc,
  3304. uint8_t *status)
  3305. {
  3306. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  3307. "%s Tx inspect path",
  3308. __func__);
  3309. DP_STATS_INC_PKT(vdev, tx_i.inspect_pkts, 1,
  3310. qdf_nbuf_len(tx_desc->nbuf));
  3311. DP_TX_FREE_SINGLE_BUF(soc, tx_desc->nbuf);
  3312. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3313. }
  3314. #ifdef MESH_MODE_SUPPORT
  3315. /**
  3316. * dp_tx_comp_fill_tx_completion_stats() - Fill per packet Tx completion stats
  3317. * in mesh meta header
  3318. * @tx_desc: software descriptor head pointer
  3319. * @ts: pointer to tx completion stats
  3320. * Return: none
  3321. */
  3322. static
  3323. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3324. struct hal_tx_completion_status *ts)
  3325. {
  3326. qdf_nbuf_t netbuf = tx_desc->nbuf;
  3327. if (!tx_desc->msdu_ext_desc) {
  3328. if (qdf_nbuf_pull_head(netbuf, tx_desc->pkt_offset) == NULL) {
  3329. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3330. "netbuf %pK offset %d",
  3331. netbuf, tx_desc->pkt_offset);
  3332. return;
  3333. }
  3334. }
  3335. }
  3336. #else
  3337. static
  3338. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3339. struct hal_tx_completion_status *ts)
  3340. {
  3341. }
  3342. #endif
  3343. #ifdef CONFIG_SAWF
  3344. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3345. struct dp_vdev *vdev,
  3346. struct dp_txrx_peer *txrx_peer,
  3347. struct dp_tx_desc_s *tx_desc,
  3348. struct hal_tx_completion_status *ts,
  3349. uint8_t tid)
  3350. {
  3351. dp_sawf_tx_compl_update_peer_stats(soc, vdev, txrx_peer, tx_desc,
  3352. ts, tid);
  3353. }
  3354. #else
  3355. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3356. struct dp_vdev *vdev,
  3357. struct dp_txrx_peer *txrx_peer,
  3358. struct dp_tx_desc_s *tx_desc,
  3359. struct hal_tx_completion_status *ts,
  3360. uint8_t tid)
  3361. {
  3362. }
  3363. #endif
  3364. #ifdef QCA_PEER_EXT_STATS
  3365. /*
  3366. * dp_tx_compute_tid_delay() - Compute per TID delay
  3367. * @stats: Per TID delay stats
  3368. * @tx_desc: Software Tx descriptor
  3369. *
  3370. * Compute the software enqueue and hw enqueue delays and
  3371. * update the respective histograms
  3372. *
  3373. * Return: void
  3374. */
  3375. static void dp_tx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  3376. struct dp_tx_desc_s *tx_desc)
  3377. {
  3378. struct cdp_delay_tx_stats *tx_delay = &stats->tx_delay;
  3379. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3380. uint32_t sw_enqueue_delay, fwhw_transmit_delay;
  3381. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3382. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3383. timestamp_hw_enqueue = qdf_ktime_to_ms(tx_desc->timestamp);
  3384. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3385. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3386. timestamp_hw_enqueue);
  3387. /*
  3388. * Update the Tx software enqueue delay and HW enque-Completion delay.
  3389. */
  3390. dp_hist_update_stats(&tx_delay->tx_swq_delay, sw_enqueue_delay);
  3391. dp_hist_update_stats(&tx_delay->hwtx_delay, fwhw_transmit_delay);
  3392. }
  3393. /*
  3394. * dp_tx_update_peer_delay_stats() - Update the peer delay stats
  3395. * @txrx_peer: DP peer context
  3396. * @tx_desc: Tx software descriptor
  3397. * @tid: Transmission ID
  3398. * @ring_id: Rx CPU context ID/CPU_ID
  3399. *
  3400. * Update the peer extended stats. These are enhanced other
  3401. * delay stats per msdu level.
  3402. *
  3403. * Return: void
  3404. */
  3405. static 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. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3410. struct dp_soc *soc = NULL;
  3411. struct dp_peer_delay_stats *delay_stats = NULL;
  3412. soc = pdev->soc;
  3413. if (qdf_likely(!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx)))
  3414. return;
  3415. delay_stats = txrx_peer->delay_stats;
  3416. qdf_assert(delay_stats);
  3417. qdf_assert(ring < CDP_MAX_TXRX_CTX);
  3418. /*
  3419. * For non-TID packets use the TID 9
  3420. */
  3421. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3422. tid = CDP_MAX_DATA_TIDS - 1;
  3423. dp_tx_compute_tid_delay(&delay_stats->delay_tid_stats[tid][ring_id],
  3424. tx_desc);
  3425. }
  3426. #else
  3427. static inline void dp_tx_update_peer_delay_stats(struct dp_txrx_peer *txrx_peer,
  3428. struct dp_tx_desc_s *tx_desc,
  3429. uint8_t tid, uint8_t ring_id)
  3430. {
  3431. }
  3432. #endif
  3433. #ifdef HW_TX_DELAY_STATS_ENABLE
  3434. /**
  3435. * dp_update_tx_delay_stats() - update the delay stats
  3436. * @vdev: vdev handle
  3437. * @delay: delay in ms or us based on the flag delay_in_us
  3438. * @tid: tid value
  3439. * @mode: type of tx delay mode
  3440. * @ring id: ring number
  3441. * @delay_in_us: flag to indicate whether the delay is in ms or us
  3442. *
  3443. * Return: none
  3444. */
  3445. static inline
  3446. void dp_update_tx_delay_stats(struct dp_vdev *vdev, uint32_t delay, uint8_t tid,
  3447. uint8_t mode, uint8_t ring_id, bool delay_in_us)
  3448. {
  3449. struct cdp_tid_tx_stats *tstats =
  3450. &vdev->stats.tid_tx_stats[ring_id][tid];
  3451. dp_update_delay_stats(tstats, NULL, delay, tid, mode, ring_id,
  3452. delay_in_us);
  3453. }
  3454. #else
  3455. static inline
  3456. void dp_update_tx_delay_stats(struct dp_vdev *vdev, uint32_t delay, uint8_t tid,
  3457. uint8_t mode, uint8_t ring_id, bool delay_in_us)
  3458. {
  3459. struct cdp_tid_tx_stats *tstats =
  3460. &vdev->pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
  3461. dp_update_delay_stats(tstats, NULL, delay, tid, mode, ring_id,
  3462. delay_in_us);
  3463. }
  3464. #endif
  3465. /**
  3466. * dp_tx_compute_delay() - Compute and fill in all timestamps
  3467. * to pass in correct fields
  3468. *
  3469. * @vdev: pdev handle
  3470. * @tx_desc: tx descriptor
  3471. * @tid: tid value
  3472. * @ring_id: TCL or WBM ring number for transmit path
  3473. * Return: none
  3474. */
  3475. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  3476. uint8_t tid, uint8_t ring_id)
  3477. {
  3478. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3479. uint32_t sw_enqueue_delay, fwhw_transmit_delay, interframe_delay;
  3480. uint32_t fwhw_transmit_delay_us;
  3481. if (qdf_likely(!vdev->pdev->delay_stats_flag) &&
  3482. qdf_likely(!dp_is_vdev_tx_delay_stats_enabled(vdev)))
  3483. return;
  3484. if (dp_is_vdev_tx_delay_stats_enabled(vdev)) {
  3485. fwhw_transmit_delay_us =
  3486. qdf_ktime_to_us(qdf_ktime_real_get()) -
  3487. qdf_ktime_to_us(tx_desc->timestamp);
  3488. /*
  3489. * Delay between packet enqueued to HW and Tx completion in us
  3490. */
  3491. dp_update_tx_delay_stats(vdev, fwhw_transmit_delay_us, tid,
  3492. CDP_DELAY_STATS_FW_HW_TRANSMIT,
  3493. ring_id, true);
  3494. /*
  3495. * For MCL, only enqueue to completion delay is required
  3496. * so return if the vdev flag is enabled.
  3497. */
  3498. return;
  3499. }
  3500. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3501. timestamp_hw_enqueue = qdf_ktime_to_ms(tx_desc->timestamp);
  3502. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3503. timestamp_hw_enqueue);
  3504. /*
  3505. * Delay between packet enqueued to HW and Tx completion in ms
  3506. */
  3507. dp_update_tx_delay_stats(vdev, fwhw_transmit_delay, tid,
  3508. CDP_DELAY_STATS_FW_HW_TRANSMIT, ring_id,
  3509. false);
  3510. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3511. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3512. interframe_delay = (uint32_t)(timestamp_ingress -
  3513. vdev->prev_tx_enq_tstamp);
  3514. /*
  3515. * Delay in software enqueue
  3516. */
  3517. dp_update_tx_delay_stats(vdev, sw_enqueue_delay, tid,
  3518. CDP_DELAY_STATS_SW_ENQ, ring_id,
  3519. false);
  3520. /*
  3521. * Update interframe delay stats calculated at hardstart receive point.
  3522. * Value of vdev->prev_tx_enq_tstamp will be 0 for 1st frame, so
  3523. * interframe delay will not be calculate correctly for 1st frame.
  3524. * On the other side, this will help in avoiding extra per packet check
  3525. * of !vdev->prev_tx_enq_tstamp.
  3526. */
  3527. dp_update_tx_delay_stats(vdev, interframe_delay, tid,
  3528. CDP_DELAY_STATS_TX_INTERFRAME, ring_id,
  3529. false);
  3530. vdev->prev_tx_enq_tstamp = timestamp_ingress;
  3531. }
  3532. #ifdef DISABLE_DP_STATS
  3533. static
  3534. inline void dp_update_no_ack_stats(qdf_nbuf_t nbuf,
  3535. struct dp_txrx_peer *txrx_peer)
  3536. {
  3537. }
  3538. #else
  3539. static inline void
  3540. dp_update_no_ack_stats(qdf_nbuf_t nbuf, struct dp_txrx_peer *txrx_peer)
  3541. {
  3542. enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
  3543. DPTRACE(qdf_dp_track_noack_check(nbuf, &subtype));
  3544. if (subtype != QDF_PROTO_INVALID)
  3545. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.no_ack_count[subtype],
  3546. 1);
  3547. }
  3548. #endif
  3549. #ifndef QCA_ENHANCED_STATS_SUPPORT
  3550. /**
  3551. * dp_tx_update_peer_extd_stats()- Update Tx extended path stats for peer
  3552. *
  3553. * @ts: Tx compltion status
  3554. * @txrx_peer: datapath txrx_peer handle
  3555. *
  3556. * Return: void
  3557. */
  3558. static inline void
  3559. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3560. struct dp_txrx_peer *txrx_peer)
  3561. {
  3562. uint8_t mcs, pkt_type;
  3563. mcs = ts->mcs;
  3564. pkt_type = ts->pkt_type;
  3565. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3566. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3567. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A)));
  3568. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3569. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3570. ((mcs < (MAX_MCS_11A)) && (pkt_type == DOT11_A)));
  3571. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3572. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3573. ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3574. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3575. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3576. ((mcs < MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3577. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3578. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3579. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3580. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3581. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3582. ((mcs < MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3583. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3584. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3585. ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3586. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3587. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3588. ((mcs < MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3589. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3590. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3591. ((mcs >= (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3592. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3593. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3594. ((mcs < (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3595. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.sgi_count[ts->sgi], 1);
  3596. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.bw[ts->bw], 1);
  3597. DP_PEER_EXTD_STATS_UPD(txrx_peer, tx.last_ack_rssi, ts->ack_frame_rssi);
  3598. DP_PEER_EXTD_STATS_INC(txrx_peer,
  3599. tx.wme_ac_type[TID_TO_WME_AC(ts->tid)], 1);
  3600. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.stbc, 1, ts->stbc);
  3601. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.ldpc, 1, ts->ldpc);
  3602. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries, 1, ts->transmit_cnt > 1);
  3603. if (ts->first_msdu) {
  3604. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries_mpdu, 1,
  3605. ts->transmit_cnt > 1);
  3606. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.mpdu_success_with_retries,
  3607. qdf_do_div(ts->transmit_cnt, DP_RETRY_COUNT),
  3608. ts->transmit_cnt > DP_RETRY_COUNT);
  3609. }
  3610. }
  3611. #else
  3612. static inline void
  3613. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3614. struct dp_txrx_peer *txrx_peer)
  3615. {
  3616. }
  3617. #endif
  3618. /**
  3619. * dp_tx_update_peer_stats() - Update peer stats from Tx completion indications
  3620. * per wbm ring
  3621. *
  3622. * @tx_desc: software descriptor head pointer
  3623. * @ts: Tx completion status
  3624. * @peer: peer handle
  3625. * @ring_id: ring number
  3626. *
  3627. * Return: None
  3628. */
  3629. static inline void
  3630. dp_tx_update_peer_stats(struct dp_tx_desc_s *tx_desc,
  3631. struct hal_tx_completion_status *ts,
  3632. struct dp_txrx_peer *txrx_peer, uint8_t ring_id)
  3633. {
  3634. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3635. uint8_t tid = ts->tid;
  3636. uint32_t length;
  3637. struct cdp_tid_tx_stats *tid_stats;
  3638. if (!pdev)
  3639. return;
  3640. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3641. tid = CDP_MAX_DATA_TIDS - 1;
  3642. tid_stats = &pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
  3643. if (ts->release_src != HAL_TX_COMP_RELEASE_SOURCE_TQM) {
  3644. dp_err("Release source is not from TQM");
  3645. return;
  3646. }
  3647. length = qdf_nbuf_len(tx_desc->nbuf);
  3648. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  3649. if (qdf_unlikely(pdev->delay_stats_flag) ||
  3650. qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(txrx_peer->vdev)))
  3651. dp_tx_compute_delay(txrx_peer->vdev, tx_desc, tid, ring_id);
  3652. if (ts->status < CDP_MAX_TX_TQM_STATUS) {
  3653. tid_stats->tqm_status_cnt[ts->status]++;
  3654. }
  3655. if (qdf_likely(ts->status == HAL_TX_TQM_RR_FRAME_ACKED)) {
  3656. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.retry_count, 1,
  3657. ts->transmit_cnt > 1);
  3658. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.multiple_retry_count,
  3659. 1, ts->transmit_cnt > 2);
  3660. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.ofdma, 1, ts->ofdma);
  3661. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.amsdu_cnt, 1,
  3662. ts->msdu_part_of_amsdu);
  3663. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.non_amsdu_cnt, 1,
  3664. !ts->msdu_part_of_amsdu);
  3665. txrx_peer->stats.per_pkt_stats.tx.last_tx_ts =
  3666. qdf_system_ticks();
  3667. dp_tx_update_peer_extd_stats(ts, txrx_peer);
  3668. return;
  3669. }
  3670. /*
  3671. * tx_failed is ideally supposed to be updated from HTT ppdu
  3672. * completion stats. But in IPQ807X/IPQ6018 chipsets owing to
  3673. * hw limitation there are no completions for failed cases.
  3674. * Hence updating tx_failed from data path. Please note that
  3675. * if tx_failed is fixed to be from ppdu, then this has to be
  3676. * removed
  3677. */
  3678. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  3679. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.failed_retry_count, 1,
  3680. ts->transmit_cnt > DP_RETRY_COUNT);
  3681. dp_update_no_ack_stats(tx_desc->nbuf, txrx_peer);
  3682. if (ts->status == HAL_TX_TQM_RR_REM_CMD_AGED) {
  3683. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.age_out, 1);
  3684. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_REM) {
  3685. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.dropped.fw_rem, 1,
  3686. length);
  3687. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_NOTX) {
  3688. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_notx, 1);
  3689. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TX) {
  3690. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_tx, 1);
  3691. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON1) {
  3692. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason1, 1);
  3693. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON2) {
  3694. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason2, 1);
  3695. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON3) {
  3696. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason3, 1);
  3697. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE) {
  3698. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3699. tx.dropped.fw_rem_queue_disable, 1);
  3700. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TILL_NONMATCHING) {
  3701. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3702. tx.dropped.fw_rem_no_match, 1);
  3703. } else if (ts->status == HAL_TX_TQM_RR_DROP_THRESHOLD) {
  3704. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3705. tx.dropped.drop_threshold, 1);
  3706. } else if (ts->status == HAL_TX_TQM_RR_LINK_DESC_UNAVAILABLE) {
  3707. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3708. tx.dropped.drop_link_desc_na, 1);
  3709. } else if (ts->status == HAL_TX_TQM_RR_DROP_OR_INVALID_MSDU) {
  3710. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3711. tx.dropped.invalid_drop, 1);
  3712. } else if (ts->status == HAL_TX_TQM_RR_MULTICAST_DROP) {
  3713. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3714. tx.dropped.mcast_vdev_drop, 1);
  3715. } else {
  3716. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.invalid_rr, 1);
  3717. }
  3718. }
  3719. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  3720. /**
  3721. * dp_tx_flow_pool_lock() - take flow pool lock
  3722. * @soc: core txrx main context
  3723. * @tx_desc: tx desc
  3724. *
  3725. * Return: None
  3726. */
  3727. static inline
  3728. void dp_tx_flow_pool_lock(struct dp_soc *soc,
  3729. struct dp_tx_desc_s *tx_desc)
  3730. {
  3731. struct dp_tx_desc_pool_s *pool;
  3732. uint8_t desc_pool_id;
  3733. desc_pool_id = tx_desc->pool_id;
  3734. pool = &soc->tx_desc[desc_pool_id];
  3735. qdf_spin_lock_bh(&pool->flow_pool_lock);
  3736. }
  3737. /**
  3738. * dp_tx_flow_pool_unlock() - release flow pool lock
  3739. * @soc: core txrx main context
  3740. * @tx_desc: tx desc
  3741. *
  3742. * Return: None
  3743. */
  3744. static inline
  3745. void dp_tx_flow_pool_unlock(struct dp_soc *soc,
  3746. struct dp_tx_desc_s *tx_desc)
  3747. {
  3748. struct dp_tx_desc_pool_s *pool;
  3749. uint8_t desc_pool_id;
  3750. desc_pool_id = tx_desc->pool_id;
  3751. pool = &soc->tx_desc[desc_pool_id];
  3752. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  3753. }
  3754. #else
  3755. static inline
  3756. void dp_tx_flow_pool_lock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3757. {
  3758. }
  3759. static inline
  3760. void dp_tx_flow_pool_unlock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3761. {
  3762. }
  3763. #endif
  3764. /**
  3765. * dp_tx_notify_completion() - Notify tx completion for this desc
  3766. * @soc: core txrx main context
  3767. * @vdev: datapath vdev handle
  3768. * @tx_desc: tx desc
  3769. * @netbuf: buffer
  3770. * @status: tx status
  3771. *
  3772. * Return: none
  3773. */
  3774. static inline void dp_tx_notify_completion(struct dp_soc *soc,
  3775. struct dp_vdev *vdev,
  3776. struct dp_tx_desc_s *tx_desc,
  3777. qdf_nbuf_t netbuf,
  3778. uint8_t status)
  3779. {
  3780. void *osif_dev;
  3781. ol_txrx_completion_fp tx_compl_cbk = NULL;
  3782. uint16_t flag = BIT(QDF_TX_RX_STATUS_DOWNLOAD_SUCC);
  3783. qdf_assert(tx_desc);
  3784. if (!vdev ||
  3785. !vdev->osif_vdev) {
  3786. return;
  3787. }
  3788. osif_dev = vdev->osif_vdev;
  3789. tx_compl_cbk = vdev->tx_comp;
  3790. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3791. flag |= BIT(QDF_TX_RX_STATUS_OK);
  3792. if (tx_compl_cbk)
  3793. tx_compl_cbk(netbuf, osif_dev, flag);
  3794. }
  3795. /** dp_tx_sojourn_stats_process() - Collect sojourn stats
  3796. * @pdev: pdev handle
  3797. * @tid: tid value
  3798. * @txdesc_ts: timestamp from txdesc
  3799. * @ppdu_id: ppdu id
  3800. *
  3801. * Return: none
  3802. */
  3803. #ifdef FEATURE_PERPKT_INFO
  3804. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3805. struct dp_txrx_peer *txrx_peer,
  3806. uint8_t tid,
  3807. uint64_t txdesc_ts,
  3808. uint32_t ppdu_id)
  3809. {
  3810. uint64_t delta_ms;
  3811. struct cdp_tx_sojourn_stats *sojourn_stats;
  3812. struct dp_peer *primary_link_peer = NULL;
  3813. struct dp_soc *link_peer_soc = NULL;
  3814. if (qdf_unlikely(!pdev->enhanced_stats_en))
  3815. return;
  3816. if (qdf_unlikely(tid == HTT_INVALID_TID ||
  3817. tid >= CDP_DATA_TID_MAX))
  3818. return;
  3819. if (qdf_unlikely(!pdev->sojourn_buf))
  3820. return;
  3821. primary_link_peer = dp_get_primary_link_peer_by_id(pdev->soc,
  3822. txrx_peer->peer_id,
  3823. DP_MOD_ID_TX_COMP);
  3824. if (qdf_unlikely(!primary_link_peer))
  3825. return;
  3826. sojourn_stats = (struct cdp_tx_sojourn_stats *)
  3827. qdf_nbuf_data(pdev->sojourn_buf);
  3828. link_peer_soc = primary_link_peer->vdev->pdev->soc;
  3829. sojourn_stats->cookie = (void *)
  3830. dp_monitor_peer_get_peerstats_ctx(link_peer_soc,
  3831. primary_link_peer);
  3832. delta_ms = qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3833. txdesc_ts;
  3834. qdf_ewma_tx_lag_add(&txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid],
  3835. delta_ms);
  3836. sojourn_stats->sum_sojourn_msdu[tid] = delta_ms;
  3837. sojourn_stats->num_msdus[tid] = 1;
  3838. sojourn_stats->avg_sojourn_msdu[tid].internal =
  3839. txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid].internal;
  3840. dp_wdi_event_handler(WDI_EVENT_TX_SOJOURN_STAT, pdev->soc,
  3841. pdev->sojourn_buf, HTT_INVALID_PEER,
  3842. WDI_NO_VAL, pdev->pdev_id);
  3843. sojourn_stats->sum_sojourn_msdu[tid] = 0;
  3844. sojourn_stats->num_msdus[tid] = 0;
  3845. sojourn_stats->avg_sojourn_msdu[tid].internal = 0;
  3846. dp_peer_unref_delete(primary_link_peer, DP_MOD_ID_TX_COMP);
  3847. }
  3848. #else
  3849. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3850. struct dp_txrx_peer *txrx_peer,
  3851. uint8_t tid,
  3852. uint64_t txdesc_ts,
  3853. uint32_t ppdu_id)
  3854. {
  3855. }
  3856. #endif
  3857. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  3858. /**
  3859. * dp_send_completion_to_pkt_capture() - send tx completion to packet capture
  3860. * @soc: dp_soc handle
  3861. * @desc: Tx Descriptor
  3862. * @ts: HAL Tx completion descriptor contents
  3863. *
  3864. * This function is used to send tx completion to packet capture
  3865. */
  3866. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  3867. struct dp_tx_desc_s *desc,
  3868. struct hal_tx_completion_status *ts)
  3869. {
  3870. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_TX_DATA, soc,
  3871. desc, ts->peer_id,
  3872. WDI_NO_VAL, desc->pdev->pdev_id);
  3873. }
  3874. #endif
  3875. /**
  3876. * dp_tx_comp_process_desc() - Process tx descriptor and free associated nbuf
  3877. * @soc: DP Soc handle
  3878. * @tx_desc: software Tx descriptor
  3879. * @ts : Tx completion status from HAL/HTT descriptor
  3880. *
  3881. * Return: none
  3882. */
  3883. void
  3884. dp_tx_comp_process_desc(struct dp_soc *soc,
  3885. struct dp_tx_desc_s *desc,
  3886. struct hal_tx_completion_status *ts,
  3887. struct dp_txrx_peer *txrx_peer)
  3888. {
  3889. uint64_t time_latency = 0;
  3890. uint16_t peer_id = DP_INVALID_PEER_ID;
  3891. /*
  3892. * m_copy/tx_capture modes are not supported for
  3893. * scatter gather packets
  3894. */
  3895. if (qdf_unlikely(!!desc->pdev->latency_capture_enable)) {
  3896. time_latency = (qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3897. qdf_ktime_to_ms(desc->timestamp));
  3898. }
  3899. dp_send_completion_to_pkt_capture(soc, desc, ts);
  3900. if (dp_tx_pkt_tracepoints_enabled())
  3901. qdf_trace_dp_packet(desc->nbuf, QDF_TX,
  3902. desc->msdu_ext_desc ?
  3903. desc->msdu_ext_desc->tso_desc : NULL,
  3904. qdf_ktime_to_ms(desc->timestamp));
  3905. if (!(desc->msdu_ext_desc)) {
  3906. dp_tx_enh_unmap(soc, desc);
  3907. if (txrx_peer)
  3908. peer_id = txrx_peer->peer_id;
  3909. if (QDF_STATUS_SUCCESS ==
  3910. dp_monitor_tx_add_to_comp_queue(soc, desc, ts, peer_id)) {
  3911. return;
  3912. }
  3913. if (QDF_STATUS_SUCCESS ==
  3914. dp_get_completion_indication_for_stack(soc,
  3915. desc->pdev,
  3916. txrx_peer, ts,
  3917. desc->nbuf,
  3918. time_latency)) {
  3919. dp_send_completion_to_stack(soc,
  3920. desc->pdev,
  3921. ts->peer_id,
  3922. ts->ppdu_id,
  3923. desc->nbuf);
  3924. return;
  3925. }
  3926. }
  3927. desc->flags |= DP_TX_DESC_FLAG_COMPLETED_TX;
  3928. dp_tx_comp_free_buf(soc, desc);
  3929. }
  3930. #ifdef DISABLE_DP_STATS
  3931. /**
  3932. * dp_tx_update_connectivity_stats() - update tx connectivity stats
  3933. * @soc: core txrx main context
  3934. * @tx_desc: tx desc
  3935. * @status: tx status
  3936. *
  3937. * Return: none
  3938. */
  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. }
  3946. #else
  3947. static inline
  3948. void dp_tx_update_connectivity_stats(struct dp_soc *soc,
  3949. struct dp_vdev *vdev,
  3950. struct dp_tx_desc_s *tx_desc,
  3951. uint8_t status)
  3952. {
  3953. void *osif_dev;
  3954. ol_txrx_stats_rx_fp stats_cbk;
  3955. uint8_t pkt_type;
  3956. qdf_assert(tx_desc);
  3957. if (!vdev ||
  3958. !vdev->osif_vdev ||
  3959. !vdev->stats_cb)
  3960. return;
  3961. osif_dev = vdev->osif_vdev;
  3962. stats_cbk = vdev->stats_cb;
  3963. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_HOST_FW_SENT, &pkt_type);
  3964. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3965. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_ACK_CNT,
  3966. &pkt_type);
  3967. }
  3968. #endif
  3969. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(CONFIG_SAWF)
  3970. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  3971. uint32_t delta_tsf)
  3972. {
  3973. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3974. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3975. DP_MOD_ID_CDP);
  3976. if (!vdev) {
  3977. dp_err_rl("vdev %d does not exist", vdev_id);
  3978. return;
  3979. }
  3980. vdev->delta_tsf = delta_tsf;
  3981. dp_debug("vdev id %u delta_tsf %u", vdev_id, delta_tsf);
  3982. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3983. }
  3984. #endif
  3985. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  3986. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  3987. uint8_t vdev_id, bool enable)
  3988. {
  3989. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3990. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3991. DP_MOD_ID_CDP);
  3992. if (!vdev) {
  3993. dp_err_rl("vdev %d does not exist", vdev_id);
  3994. return QDF_STATUS_E_FAILURE;
  3995. }
  3996. qdf_atomic_set(&vdev->ul_delay_report, enable);
  3997. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3998. return QDF_STATUS_SUCCESS;
  3999. }
  4000. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4001. uint32_t *val)
  4002. {
  4003. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4004. struct dp_vdev *vdev;
  4005. uint32_t delay_accum;
  4006. uint32_t pkts_accum;
  4007. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_CDP);
  4008. if (!vdev) {
  4009. dp_err_rl("vdev %d does not exist", vdev_id);
  4010. return QDF_STATUS_E_FAILURE;
  4011. }
  4012. if (!qdf_atomic_read(&vdev->ul_delay_report)) {
  4013. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4014. return QDF_STATUS_E_FAILURE;
  4015. }
  4016. /* Average uplink delay based on current accumulated values */
  4017. delay_accum = qdf_atomic_read(&vdev->ul_delay_accum);
  4018. pkts_accum = qdf_atomic_read(&vdev->ul_pkts_accum);
  4019. *val = delay_accum / pkts_accum;
  4020. dp_debug("uplink_delay %u delay_accum %u pkts_accum %u", *val,
  4021. delay_accum, pkts_accum);
  4022. /* Reset accumulated values to 0 */
  4023. qdf_atomic_set(&vdev->ul_delay_accum, 0);
  4024. qdf_atomic_set(&vdev->ul_pkts_accum, 0);
  4025. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  4026. return QDF_STATUS_SUCCESS;
  4027. }
  4028. static void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  4029. struct hal_tx_completion_status *ts)
  4030. {
  4031. uint32_t buffer_ts;
  4032. uint32_t delta_tsf;
  4033. uint32_t ul_delay;
  4034. /* Tx_rate_stats_info_valid is 0 and tsf is invalid then */
  4035. if (!ts->valid)
  4036. return;
  4037. if (qdf_unlikely(!vdev)) {
  4038. dp_info_rl("vdev is null or delete in progrss");
  4039. return;
  4040. }
  4041. if (!qdf_atomic_read(&vdev->ul_delay_report))
  4042. return;
  4043. delta_tsf = vdev->delta_tsf;
  4044. /* buffer_timestamp is in units of 1024 us and is [31:13] of
  4045. * WBM_RELEASE_RING_4. After left shift 10 bits, it's
  4046. * valid up to 29 bits.
  4047. */
  4048. buffer_ts = ts->buffer_timestamp << 10;
  4049. ul_delay = ts->tsf - buffer_ts - delta_tsf;
  4050. ul_delay &= 0x1FFFFFFF; /* mask 29 BITS */
  4051. if (ul_delay > 0x1000000) {
  4052. dp_info_rl("----------------------\n"
  4053. "Tx completion status:\n"
  4054. "----------------------\n"
  4055. "release_src = %d\n"
  4056. "ppdu_id = 0x%x\n"
  4057. "release_reason = %d\n"
  4058. "tsf = %u (0x%x)\n"
  4059. "buffer_timestamp = %u (0x%x)\n"
  4060. "delta_tsf = %u (0x%x)\n",
  4061. ts->release_src, ts->ppdu_id, ts->status,
  4062. ts->tsf, ts->tsf, ts->buffer_timestamp,
  4063. ts->buffer_timestamp, delta_tsf, delta_tsf);
  4064. return;
  4065. }
  4066. ul_delay /= 1000; /* in unit of ms */
  4067. qdf_atomic_add(ul_delay, &vdev->ul_delay_accum);
  4068. qdf_atomic_inc(&vdev->ul_pkts_accum);
  4069. }
  4070. #else /* !WLAN_FEATURE_TSF_UPLINK_DELAY */
  4071. static inline
  4072. void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  4073. struct hal_tx_completion_status *ts)
  4074. {
  4075. }
  4076. #endif /* WLAN_FEATURE_TSF_UPLINK_DELAY */
  4077. /**
  4078. * dp_tx_comp_process_tx_status() - Parse and Dump Tx completion status info
  4079. * @soc: DP soc handle
  4080. * @tx_desc: software descriptor head pointer
  4081. * @ts: Tx completion status
  4082. * @txrx_peer: txrx peer handle
  4083. * @ring_id: ring number
  4084. *
  4085. * Return: none
  4086. */
  4087. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  4088. struct dp_tx_desc_s *tx_desc,
  4089. struct hal_tx_completion_status *ts,
  4090. struct dp_txrx_peer *txrx_peer,
  4091. uint8_t ring_id)
  4092. {
  4093. uint32_t length;
  4094. qdf_ether_header_t *eh;
  4095. struct dp_vdev *vdev = NULL;
  4096. qdf_nbuf_t nbuf = tx_desc->nbuf;
  4097. enum qdf_dp_tx_rx_status dp_status;
  4098. if (!nbuf) {
  4099. dp_info_rl("invalid tx descriptor. nbuf NULL");
  4100. goto out;
  4101. }
  4102. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  4103. length = qdf_nbuf_len(nbuf);
  4104. dp_status = dp_tx_hw_to_qdf(ts->status);
  4105. DPTRACE(qdf_dp_trace_ptr(tx_desc->nbuf,
  4106. QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD,
  4107. QDF_TRACE_DEFAULT_PDEV_ID,
  4108. qdf_nbuf_data_addr(nbuf),
  4109. sizeof(qdf_nbuf_data(nbuf)),
  4110. tx_desc->id, ts->status, dp_status));
  4111. dp_tx_comp_debug("-------------------- \n"
  4112. "Tx Completion Stats: \n"
  4113. "-------------------- \n"
  4114. "ack_frame_rssi = %d \n"
  4115. "first_msdu = %d \n"
  4116. "last_msdu = %d \n"
  4117. "msdu_part_of_amsdu = %d \n"
  4118. "rate_stats valid = %d \n"
  4119. "bw = %d \n"
  4120. "pkt_type = %d \n"
  4121. "stbc = %d \n"
  4122. "ldpc = %d \n"
  4123. "sgi = %d \n"
  4124. "mcs = %d \n"
  4125. "ofdma = %d \n"
  4126. "tones_in_ru = %d \n"
  4127. "tsf = %d \n"
  4128. "ppdu_id = %d \n"
  4129. "transmit_cnt = %d \n"
  4130. "tid = %d \n"
  4131. "peer_id = %d\n"
  4132. "tx_status = %d\n",
  4133. ts->ack_frame_rssi, ts->first_msdu,
  4134. ts->last_msdu, ts->msdu_part_of_amsdu,
  4135. ts->valid, ts->bw, ts->pkt_type, ts->stbc,
  4136. ts->ldpc, ts->sgi, ts->mcs, ts->ofdma,
  4137. ts->tones_in_ru, ts->tsf, ts->ppdu_id,
  4138. ts->transmit_cnt, ts->tid, ts->peer_id,
  4139. ts->status);
  4140. /* Update SoC level stats */
  4141. DP_STATS_INCC(soc, tx.dropped_fw_removed, 1,
  4142. (ts->status == HAL_TX_TQM_RR_REM_CMD_REM));
  4143. if (!txrx_peer) {
  4144. dp_info_rl("peer is null or deletion in progress");
  4145. DP_STATS_INC_PKT(soc, tx.tx_invalid_peer, 1, length);
  4146. goto out;
  4147. }
  4148. vdev = txrx_peer->vdev;
  4149. dp_tx_update_connectivity_stats(soc, vdev, tx_desc, ts->status);
  4150. dp_tx_update_uplink_delay(soc, vdev, ts);
  4151. /* check tx complete notification */
  4152. if (qdf_nbuf_tx_notify_comp_get(nbuf))
  4153. dp_tx_notify_completion(soc, vdev, tx_desc,
  4154. nbuf, ts->status);
  4155. /* Update per-packet stats for mesh mode */
  4156. if (qdf_unlikely(vdev->mesh_vdev) &&
  4157. !(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW))
  4158. dp_tx_comp_fill_tx_completion_stats(tx_desc, ts);
  4159. /* Update peer level stats */
  4160. if (qdf_unlikely(txrx_peer->bss_peer &&
  4161. vdev->opmode == wlan_op_mode_ap)) {
  4162. if (ts->status != HAL_TX_TQM_RR_REM_CMD_REM) {
  4163. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.mcast, 1,
  4164. length);
  4165. if (txrx_peer->vdev->tx_encap_type ==
  4166. htt_cmn_pkt_type_ethernet &&
  4167. QDF_IS_ADDR_BROADCAST(eh->ether_dhost)) {
  4168. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4169. tx.bcast, 1,
  4170. length);
  4171. }
  4172. }
  4173. } else {
  4174. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.ucast, 1, length);
  4175. if (ts->status == HAL_TX_TQM_RR_FRAME_ACKED) {
  4176. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.tx_success,
  4177. 1, length);
  4178. if (qdf_unlikely(txrx_peer->in_twt)) {
  4179. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4180. tx.tx_success_twt,
  4181. 1, length);
  4182. }
  4183. }
  4184. }
  4185. dp_tx_update_peer_stats(tx_desc, ts, txrx_peer, ring_id);
  4186. dp_tx_update_peer_delay_stats(txrx_peer, tx_desc, ts->tid, ring_id);
  4187. dp_tx_update_peer_sawf_stats(soc, vdev, txrx_peer, tx_desc,
  4188. ts, ts->tid);
  4189. #ifdef QCA_SUPPORT_RDK_STATS
  4190. if (soc->peerstats_enabled)
  4191. dp_tx_sojourn_stats_process(vdev->pdev, txrx_peer, ts->tid,
  4192. qdf_ktime_to_ms(tx_desc->timestamp),
  4193. ts->ppdu_id);
  4194. #endif
  4195. out:
  4196. return;
  4197. }
  4198. #if defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT) && \
  4199. defined(QCA_ENHANCED_STATS_SUPPORT)
  4200. /*
  4201. * dp_tx_update_peer_basic_stats(): Update peer basic stats
  4202. * @txrx_peer: Datapath txrx_peer handle
  4203. * @length: Length of the packet
  4204. * @tx_status: Tx status from TQM/FW
  4205. * @update: enhanced flag value present in dp_pdev
  4206. *
  4207. * Return: none
  4208. */
  4209. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4210. uint32_t length, uint8_t tx_status,
  4211. bool update)
  4212. {
  4213. if ((!txrx_peer->hw_txrx_stats_en) || update) {
  4214. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4215. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4216. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4217. }
  4218. }
  4219. #elif defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT)
  4220. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4221. uint32_t length, uint8_t tx_status,
  4222. bool update)
  4223. {
  4224. if (!peer->hw_txrx_stats_en) {
  4225. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4226. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4227. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4228. }
  4229. }
  4230. #else
  4231. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4232. uint32_t length, uint8_t tx_status,
  4233. bool update)
  4234. {
  4235. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4236. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4237. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4238. }
  4239. #endif
  4240. /*
  4241. * dp_tx_prefetch_next_nbuf_data(): Prefetch nbuf and nbuf data
  4242. * @nbuf: skb buffer
  4243. *
  4244. * Return: none
  4245. */
  4246. #ifdef QCA_DP_RX_NBUF_AND_NBUF_DATA_PREFETCH
  4247. static inline
  4248. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4249. {
  4250. qdf_nbuf_t nbuf = NULL;
  4251. if (next)
  4252. nbuf = next->nbuf;
  4253. if (nbuf) {
  4254. /* prefetch skb->next and first few bytes of skb->cb */
  4255. qdf_prefetch(nbuf);
  4256. /* prefetch skb fields present in different cachelines */
  4257. qdf_prefetch(&nbuf->len);
  4258. qdf_prefetch(&nbuf->users);
  4259. }
  4260. }
  4261. #else
  4262. static inline
  4263. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4264. {
  4265. }
  4266. #endif
  4267. /**
  4268. * dp_tx_mcast_reinject_handler() - Tx reinjected multicast packets handler
  4269. * @soc: core txrx main context
  4270. * @desc: software descriptor
  4271. *
  4272. * Return: true when packet is reinjected
  4273. */
  4274. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) && \
  4275. defined(WLAN_MCAST_MLO)
  4276. static inline bool
  4277. dp_tx_mcast_reinject_handler(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  4278. {
  4279. struct dp_vdev *vdev = NULL;
  4280. if (desc->tx_status == HAL_TX_TQM_RR_MULTICAST_DROP) {
  4281. if (!soc->arch_ops.dp_tx_mcast_handler)
  4282. return false;
  4283. vdev = dp_vdev_get_ref_by_id(soc, desc->vdev_id,
  4284. DP_MOD_ID_REINJECT);
  4285. if (qdf_unlikely(!vdev)) {
  4286. dp_tx_comp_info_rl("Unable to get vdev ref %d",
  4287. desc->id);
  4288. return false;
  4289. }
  4290. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  4291. qdf_nbuf_len(desc->nbuf));
  4292. soc->arch_ops.dp_tx_mcast_handler(soc, vdev, desc->nbuf);
  4293. dp_tx_desc_release(desc, desc->pool_id);
  4294. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_REINJECT);
  4295. return true;
  4296. }
  4297. return false;
  4298. }
  4299. #else
  4300. static inline bool
  4301. dp_tx_mcast_reinject_handler(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  4302. {
  4303. return false;
  4304. }
  4305. #endif
  4306. /**
  4307. * dp_tx_comp_process_desc_list() - Tx complete software descriptor handler
  4308. * @soc: core txrx main context
  4309. * @comp_head: software descriptor head pointer
  4310. * @ring_id: ring number
  4311. *
  4312. * This function will process batch of descriptors reaped by dp_tx_comp_handler
  4313. * and release the software descriptors after processing is complete
  4314. *
  4315. * Return: none
  4316. */
  4317. static void
  4318. dp_tx_comp_process_desc_list(struct dp_soc *soc,
  4319. struct dp_tx_desc_s *comp_head, uint8_t ring_id)
  4320. {
  4321. struct dp_tx_desc_s *desc;
  4322. struct dp_tx_desc_s *next;
  4323. struct hal_tx_completion_status ts;
  4324. struct dp_txrx_peer *txrx_peer = NULL;
  4325. uint16_t peer_id = DP_INVALID_PEER;
  4326. dp_txrx_ref_handle txrx_ref_handle = NULL;
  4327. desc = comp_head;
  4328. while (desc) {
  4329. next = desc->next;
  4330. dp_tx_prefetch_next_nbuf_data(next);
  4331. if (peer_id != desc->peer_id) {
  4332. if (txrx_peer)
  4333. dp_txrx_peer_unref_delete(txrx_ref_handle,
  4334. DP_MOD_ID_TX_COMP);
  4335. peer_id = desc->peer_id;
  4336. txrx_peer =
  4337. dp_txrx_peer_get_ref_by_id(soc, peer_id,
  4338. &txrx_ref_handle,
  4339. DP_MOD_ID_TX_COMP);
  4340. }
  4341. if (dp_tx_mcast_reinject_handler(soc, desc)) {
  4342. desc = next;
  4343. continue;
  4344. }
  4345. if (qdf_likely(desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  4346. struct dp_pdev *pdev = desc->pdev;
  4347. if (qdf_likely(txrx_peer))
  4348. dp_tx_update_peer_basic_stats(txrx_peer,
  4349. desc->length,
  4350. desc->tx_status,
  4351. false);
  4352. qdf_assert(pdev);
  4353. dp_tx_outstanding_dec(pdev);
  4354. /*
  4355. * Calling a QDF WRAPPER here is creating signifcant
  4356. * performance impact so avoided the wrapper call here
  4357. */
  4358. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  4359. desc->id, DP_TX_COMP_UNMAP);
  4360. dp_tx_nbuf_unmap(soc, desc);
  4361. qdf_nbuf_free(desc->nbuf);
  4362. dp_tx_desc_free(soc, desc, desc->pool_id);
  4363. desc = next;
  4364. continue;
  4365. }
  4366. hal_tx_comp_get_status(&desc->comp, &ts, soc->hal_soc);
  4367. dp_tx_comp_process_tx_status(soc, desc, &ts, txrx_peer,
  4368. ring_id);
  4369. dp_tx_comp_process_desc(soc, desc, &ts, txrx_peer);
  4370. dp_tx_desc_release(desc, desc->pool_id);
  4371. desc = next;
  4372. }
  4373. if (txrx_peer)
  4374. dp_txrx_peer_unref_delete(txrx_ref_handle, DP_MOD_ID_TX_COMP);
  4375. }
  4376. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  4377. static inline
  4378. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4379. int max_reap_limit)
  4380. {
  4381. bool limit_hit = false;
  4382. limit_hit =
  4383. (num_reaped >= max_reap_limit) ? true : false;
  4384. if (limit_hit)
  4385. DP_STATS_INC(soc, tx.tx_comp_loop_pkt_limit_hit, 1);
  4386. return limit_hit;
  4387. }
  4388. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4389. {
  4390. return soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check;
  4391. }
  4392. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4393. {
  4394. struct wlan_cfg_dp_soc_ctxt *cfg = soc->wlan_cfg_ctx;
  4395. return cfg->tx_comp_loop_pkt_limit;
  4396. }
  4397. #else
  4398. static inline
  4399. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4400. int max_reap_limit)
  4401. {
  4402. return false;
  4403. }
  4404. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4405. {
  4406. return false;
  4407. }
  4408. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4409. {
  4410. return 0;
  4411. }
  4412. #endif
  4413. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  4414. static inline int
  4415. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4416. int *max_reap_limit)
  4417. {
  4418. return soc->arch_ops.dp_srng_test_and_update_nf_params(soc, dp_srng,
  4419. max_reap_limit);
  4420. }
  4421. #else
  4422. static inline int
  4423. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4424. int *max_reap_limit)
  4425. {
  4426. return 0;
  4427. }
  4428. #endif
  4429. #ifdef DP_TX_TRACKING
  4430. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  4431. {
  4432. if ((tx_desc->magic != DP_TX_MAGIC_PATTERN_INUSE) &&
  4433. (tx_desc->magic != DP_TX_MAGIC_PATTERN_FREE)) {
  4434. dp_err_rl("tx_desc %u is corrupted", tx_desc->id);
  4435. qdf_trigger_self_recovery(NULL, QDF_TX_DESC_LEAK);
  4436. }
  4437. }
  4438. #endif
  4439. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  4440. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  4441. uint32_t quota)
  4442. {
  4443. void *tx_comp_hal_desc;
  4444. void *last_prefetched_hw_desc = NULL;
  4445. struct dp_tx_desc_s *last_prefetched_sw_desc = NULL;
  4446. hal_soc_handle_t hal_soc;
  4447. uint8_t buffer_src;
  4448. struct dp_tx_desc_s *tx_desc = NULL;
  4449. struct dp_tx_desc_s *head_desc = NULL;
  4450. struct dp_tx_desc_s *tail_desc = NULL;
  4451. uint32_t num_processed = 0;
  4452. uint32_t count;
  4453. uint32_t num_avail_for_reap = 0;
  4454. bool force_break = false;
  4455. struct dp_srng *tx_comp_ring = &soc->tx_comp_ring[ring_id];
  4456. int max_reap_limit, ring_near_full;
  4457. DP_HIST_INIT();
  4458. more_data:
  4459. hal_soc = soc->hal_soc;
  4460. /* Re-initialize local variables to be re-used */
  4461. head_desc = NULL;
  4462. tail_desc = NULL;
  4463. count = 0;
  4464. max_reap_limit = dp_tx_comp_get_loop_pkt_limit(soc);
  4465. ring_near_full = dp_srng_test_and_update_nf_params(soc, tx_comp_ring,
  4466. &max_reap_limit);
  4467. if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, hal_ring_hdl))) {
  4468. dp_err("HAL RING Access Failed -- %pK", hal_ring_hdl);
  4469. return 0;
  4470. }
  4471. num_avail_for_reap = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, 0);
  4472. if (num_avail_for_reap >= quota)
  4473. num_avail_for_reap = quota;
  4474. dp_srng_dst_inv_cached_descs(soc, hal_ring_hdl, num_avail_for_reap);
  4475. last_prefetched_hw_desc = dp_srng_dst_prefetch(hal_soc, hal_ring_hdl,
  4476. num_avail_for_reap);
  4477. /* Find head descriptor from completion ring */
  4478. while (qdf_likely(num_avail_for_reap--)) {
  4479. tx_comp_hal_desc = dp_srng_dst_get_next(soc, hal_ring_hdl);
  4480. if (qdf_unlikely(!tx_comp_hal_desc))
  4481. break;
  4482. buffer_src = hal_tx_comp_get_buffer_source(hal_soc,
  4483. tx_comp_hal_desc);
  4484. /* If this buffer was not released by TQM or FW, then it is not
  4485. * Tx completion indication, assert */
  4486. if (qdf_unlikely(buffer_src !=
  4487. HAL_TX_COMP_RELEASE_SOURCE_TQM) &&
  4488. (qdf_unlikely(buffer_src !=
  4489. HAL_TX_COMP_RELEASE_SOURCE_FW))) {
  4490. uint8_t wbm_internal_error;
  4491. dp_err_rl(
  4492. "Tx comp release_src != TQM | FW but from %d",
  4493. buffer_src);
  4494. hal_dump_comp_desc(tx_comp_hal_desc);
  4495. DP_STATS_INC(soc, tx.invalid_release_source, 1);
  4496. /* When WBM sees NULL buffer_addr_info in any of
  4497. * ingress rings it sends an error indication,
  4498. * with wbm_internal_error=1, to a specific ring.
  4499. * The WBM2SW ring used to indicate these errors is
  4500. * fixed in HW, and that ring is being used as Tx
  4501. * completion ring. These errors are not related to
  4502. * Tx completions, and should just be ignored
  4503. */
  4504. wbm_internal_error = hal_get_wbm_internal_error(
  4505. hal_soc,
  4506. tx_comp_hal_desc);
  4507. if (wbm_internal_error) {
  4508. dp_err_rl("Tx comp wbm_internal_error!!");
  4509. DP_STATS_INC(soc, tx.wbm_internal_error[WBM_INT_ERROR_ALL], 1);
  4510. if (HAL_TX_COMP_RELEASE_SOURCE_REO ==
  4511. buffer_src)
  4512. dp_handle_wbm_internal_error(
  4513. soc,
  4514. tx_comp_hal_desc,
  4515. hal_tx_comp_get_buffer_type(
  4516. tx_comp_hal_desc));
  4517. } else {
  4518. dp_err_rl("Tx comp wbm_internal_error false");
  4519. DP_STATS_INC(soc, tx.non_wbm_internal_err, 1);
  4520. }
  4521. continue;
  4522. }
  4523. soc->arch_ops.tx_comp_get_params_from_hal_desc(soc,
  4524. tx_comp_hal_desc,
  4525. &tx_desc);
  4526. if (!tx_desc) {
  4527. dp_err("unable to retrieve tx_desc!");
  4528. QDF_BUG(0);
  4529. continue;
  4530. }
  4531. tx_desc->buffer_src = buffer_src;
  4532. /*
  4533. * If the release source is FW, process the HTT status
  4534. */
  4535. if (qdf_unlikely(buffer_src ==
  4536. HAL_TX_COMP_RELEASE_SOURCE_FW)) {
  4537. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  4538. hal_tx_comp_get_htt_desc(tx_comp_hal_desc,
  4539. htt_tx_status);
  4540. /* Collect hw completion contents */
  4541. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4542. &tx_desc->comp, 1);
  4543. soc->arch_ops.dp_tx_process_htt_completion(
  4544. soc,
  4545. tx_desc,
  4546. htt_tx_status,
  4547. ring_id);
  4548. } else {
  4549. tx_desc->tx_status =
  4550. hal_tx_comp_get_tx_status(tx_comp_hal_desc);
  4551. tx_desc->buffer_src = buffer_src;
  4552. /*
  4553. * If the fast completion mode is enabled extended
  4554. * metadata from descriptor is not copied
  4555. */
  4556. if (qdf_likely(tx_desc->flags &
  4557. DP_TX_DESC_FLAG_SIMPLE))
  4558. goto add_to_pool;
  4559. /*
  4560. * If the descriptor is already freed in vdev_detach,
  4561. * continue to next descriptor
  4562. */
  4563. if (qdf_unlikely
  4564. ((tx_desc->vdev_id == DP_INVALID_VDEV_ID) &&
  4565. !tx_desc->flags)) {
  4566. dp_tx_comp_info_rl("Descriptor freed in vdev_detach %d",
  4567. tx_desc->id);
  4568. DP_STATS_INC(soc, tx.tx_comp_exception, 1);
  4569. dp_tx_desc_check_corruption(tx_desc);
  4570. continue;
  4571. }
  4572. if (qdf_unlikely(tx_desc->pdev->is_pdev_down)) {
  4573. dp_tx_comp_info_rl("pdev in down state %d",
  4574. tx_desc->id);
  4575. tx_desc->flags |= DP_TX_DESC_FLAG_TX_COMP_ERR;
  4576. dp_tx_comp_free_buf(soc, tx_desc);
  4577. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  4578. goto next_desc;
  4579. }
  4580. if (!(tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED) ||
  4581. !(tx_desc->flags & DP_TX_DESC_FLAG_QUEUED_TX)) {
  4582. dp_tx_comp_alert("Txdesc invalid, flgs = %x,id = %d",
  4583. tx_desc->flags, tx_desc->id);
  4584. qdf_assert_always(0);
  4585. }
  4586. /* Collect hw completion contents */
  4587. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4588. &tx_desc->comp, 1);
  4589. add_to_pool:
  4590. DP_HIST_PACKET_COUNT_INC(tx_desc->pdev->pdev_id);
  4591. /* First ring descriptor on the cycle */
  4592. if (!head_desc) {
  4593. head_desc = tx_desc;
  4594. tail_desc = tx_desc;
  4595. }
  4596. tail_desc->next = tx_desc;
  4597. tx_desc->next = NULL;
  4598. tail_desc = tx_desc;
  4599. }
  4600. next_desc:
  4601. num_processed += !(count & DP_TX_NAPI_BUDGET_DIV_MASK);
  4602. /*
  4603. * Processed packet count is more than given quota
  4604. * stop to processing
  4605. */
  4606. count++;
  4607. dp_tx_prefetch_hw_sw_nbuf_desc(soc, hal_soc,
  4608. num_avail_for_reap,
  4609. hal_ring_hdl,
  4610. &last_prefetched_hw_desc,
  4611. &last_prefetched_sw_desc);
  4612. if (dp_tx_comp_loop_pkt_limit_hit(soc, count, max_reap_limit))
  4613. break;
  4614. }
  4615. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  4616. /* Process the reaped descriptors */
  4617. if (head_desc)
  4618. dp_tx_comp_process_desc_list(soc, head_desc, ring_id);
  4619. DP_STATS_INC(soc, tx.tx_comp[ring_id], count);
  4620. /*
  4621. * If we are processing in near-full condition, there are 3 scenario
  4622. * 1) Ring entries has reached critical state
  4623. * 2) Ring entries are still near high threshold
  4624. * 3) Ring entries are below the safe level
  4625. *
  4626. * One more loop will move te state to normal processing and yield
  4627. */
  4628. if (ring_near_full)
  4629. goto more_data;
  4630. if (dp_tx_comp_enable_eol_data_check(soc)) {
  4631. if (num_processed >= quota)
  4632. force_break = true;
  4633. if (!force_break &&
  4634. hal_srng_dst_peek_sync_locked(soc->hal_soc,
  4635. hal_ring_hdl)) {
  4636. DP_STATS_INC(soc, tx.hp_oos2, 1);
  4637. if (!hif_exec_should_yield(soc->hif_handle,
  4638. int_ctx->dp_intr_id))
  4639. goto more_data;
  4640. }
  4641. }
  4642. DP_TX_HIST_STATS_PER_PDEV();
  4643. return num_processed;
  4644. }
  4645. #ifdef FEATURE_WLAN_TDLS
  4646. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4647. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  4648. {
  4649. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4650. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  4651. DP_MOD_ID_TDLS);
  4652. if (!vdev) {
  4653. dp_err("vdev handle for id %d is NULL", vdev_id);
  4654. return NULL;
  4655. }
  4656. if (tx_spec & OL_TX_SPEC_NO_FREE)
  4657. vdev->is_tdls_frame = true;
  4658. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  4659. return dp_tx_send(soc_hdl, vdev_id, msdu_list);
  4660. }
  4661. #endif
  4662. /**
  4663. * dp_tx_vdev_attach() - attach vdev to dp tx
  4664. * @vdev: virtual device instance
  4665. *
  4666. * Return: QDF_STATUS_SUCCESS: success
  4667. * QDF_STATUS_E_RESOURCES: Error return
  4668. */
  4669. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  4670. {
  4671. int pdev_id;
  4672. /*
  4673. * Fill HTT TCL Metadata with Vdev ID and MAC ID
  4674. */
  4675. DP_TX_TCL_METADATA_TYPE_SET(vdev->htt_tcl_metadata,
  4676. DP_TCL_METADATA_TYPE_VDEV_BASED);
  4677. DP_TX_TCL_METADATA_VDEV_ID_SET(vdev->htt_tcl_metadata,
  4678. vdev->vdev_id);
  4679. pdev_id =
  4680. dp_get_target_pdev_id_for_host_pdev_id(vdev->pdev->soc,
  4681. vdev->pdev->pdev_id);
  4682. DP_TX_TCL_METADATA_PDEV_ID_SET(vdev->htt_tcl_metadata, pdev_id);
  4683. /*
  4684. * Set HTT Extension Valid bit to 0 by default
  4685. */
  4686. DP_TX_TCL_METADATA_VALID_HTT_SET(vdev->htt_tcl_metadata, 0);
  4687. dp_tx_vdev_update_search_flags(vdev);
  4688. return QDF_STATUS_SUCCESS;
  4689. }
  4690. #ifndef FEATURE_WDS
  4691. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  4692. {
  4693. return false;
  4694. }
  4695. #endif
  4696. /**
  4697. * dp_tx_vdev_update_search_flags() - Update vdev flags as per opmode
  4698. * @vdev: virtual device instance
  4699. *
  4700. * Return: void
  4701. *
  4702. */
  4703. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  4704. {
  4705. struct dp_soc *soc = vdev->pdev->soc;
  4706. /*
  4707. * Enable both AddrY (SA based search) and AddrX (Da based search)
  4708. * for TDLS link
  4709. *
  4710. * Enable AddrY (SA based search) only for non-WDS STA and
  4711. * ProxySTA VAP (in HKv1) modes.
  4712. *
  4713. * In all other VAP modes, only DA based search should be
  4714. * enabled
  4715. */
  4716. if (vdev->opmode == wlan_op_mode_sta &&
  4717. vdev->tdls_link_connected)
  4718. vdev->hal_desc_addr_search_flags =
  4719. (HAL_TX_DESC_ADDRX_EN | HAL_TX_DESC_ADDRY_EN);
  4720. else if ((vdev->opmode == wlan_op_mode_sta) &&
  4721. !dp_tx_da_search_override(vdev))
  4722. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRY_EN;
  4723. else
  4724. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRX_EN;
  4725. if (vdev->opmode == wlan_op_mode_sta && !vdev->tdls_link_connected)
  4726. vdev->search_type = soc->sta_mode_search_policy;
  4727. else
  4728. vdev->search_type = HAL_TX_ADDR_SEARCH_DEFAULT;
  4729. }
  4730. static inline bool
  4731. dp_is_tx_desc_flush_match(struct dp_pdev *pdev,
  4732. struct dp_vdev *vdev,
  4733. struct dp_tx_desc_s *tx_desc)
  4734. {
  4735. if (!(tx_desc && (tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED)))
  4736. return false;
  4737. /*
  4738. * if vdev is given, then only check whether desc
  4739. * vdev match. if vdev is NULL, then check whether
  4740. * desc pdev match.
  4741. */
  4742. return vdev ? (tx_desc->vdev_id == vdev->vdev_id) :
  4743. (tx_desc->pdev == pdev);
  4744. }
  4745. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4746. /**
  4747. * dp_tx_desc_flush() - release resources associated
  4748. * to TX Desc
  4749. *
  4750. * @dp_pdev: Handle to DP pdev structure
  4751. * @vdev: virtual device instance
  4752. * NULL: no specific Vdev is required and check all allcated TX desc
  4753. * on this pdev.
  4754. * Non-NULL: only check the allocated TX Desc associated to this Vdev.
  4755. *
  4756. * @force_free:
  4757. * true: flush the TX desc.
  4758. * false: only reset the Vdev in each allocated TX desc
  4759. * that associated to current Vdev.
  4760. *
  4761. * This function will go through the TX desc pool to flush
  4762. * the outstanding TX data or reset Vdev to NULL in associated TX
  4763. * Desc.
  4764. */
  4765. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4766. bool force_free)
  4767. {
  4768. uint8_t i;
  4769. uint32_t j;
  4770. uint32_t num_desc, page_id, offset;
  4771. uint16_t num_desc_per_page;
  4772. struct dp_soc *soc = pdev->soc;
  4773. struct dp_tx_desc_s *tx_desc = NULL;
  4774. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4775. if (!vdev && !force_free) {
  4776. dp_err("Reset TX desc vdev, Vdev param is required!");
  4777. return;
  4778. }
  4779. for (i = 0; i < MAX_TXDESC_POOLS; i++) {
  4780. tx_desc_pool = &soc->tx_desc[i];
  4781. if (!(tx_desc_pool->pool_size) ||
  4782. IS_TX_DESC_POOL_STATUS_INACTIVE(tx_desc_pool) ||
  4783. !(tx_desc_pool->desc_pages.cacheable_pages))
  4784. continue;
  4785. /*
  4786. * Add flow pool lock protection in case pool is freed
  4787. * due to all tx_desc is recycled when handle TX completion.
  4788. * this is not necessary when do force flush as:
  4789. * a. double lock will happen if dp_tx_desc_release is
  4790. * also trying to acquire it.
  4791. * b. dp interrupt has been disabled before do force TX desc
  4792. * flush in dp_pdev_deinit().
  4793. */
  4794. if (!force_free)
  4795. qdf_spin_lock_bh(&tx_desc_pool->flow_pool_lock);
  4796. num_desc = tx_desc_pool->pool_size;
  4797. num_desc_per_page =
  4798. tx_desc_pool->desc_pages.num_element_per_page;
  4799. for (j = 0; j < num_desc; j++) {
  4800. page_id = j / num_desc_per_page;
  4801. offset = j % num_desc_per_page;
  4802. if (qdf_unlikely(!(tx_desc_pool->
  4803. desc_pages.cacheable_pages)))
  4804. break;
  4805. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4806. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4807. /*
  4808. * Free TX desc if force free is
  4809. * required, otherwise only reset vdev
  4810. * in this TX desc.
  4811. */
  4812. if (force_free) {
  4813. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4814. dp_tx_comp_free_buf(soc, tx_desc);
  4815. dp_tx_desc_release(tx_desc, i);
  4816. } else {
  4817. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4818. }
  4819. }
  4820. }
  4821. if (!force_free)
  4822. qdf_spin_unlock_bh(&tx_desc_pool->flow_pool_lock);
  4823. }
  4824. }
  4825. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4826. /**
  4827. * dp_tx_desc_reset_vdev() - reset vdev to NULL in TX Desc
  4828. *
  4829. * @soc: Handle to DP soc structure
  4830. * @tx_desc: pointer of one TX desc
  4831. * @desc_pool_id: TX Desc pool id
  4832. */
  4833. static inline void
  4834. dp_tx_desc_reset_vdev(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc,
  4835. uint8_t desc_pool_id)
  4836. {
  4837. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  4838. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4839. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  4840. }
  4841. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4842. bool force_free)
  4843. {
  4844. uint8_t i, num_pool;
  4845. uint32_t j;
  4846. uint32_t num_desc, page_id, offset;
  4847. uint16_t num_desc_per_page;
  4848. struct dp_soc *soc = pdev->soc;
  4849. struct dp_tx_desc_s *tx_desc = NULL;
  4850. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4851. if (!vdev && !force_free) {
  4852. dp_err("Reset TX desc vdev, Vdev param is required!");
  4853. return;
  4854. }
  4855. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  4856. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4857. for (i = 0; i < num_pool; i++) {
  4858. tx_desc_pool = &soc->tx_desc[i];
  4859. if (!tx_desc_pool->desc_pages.cacheable_pages)
  4860. continue;
  4861. num_desc_per_page =
  4862. tx_desc_pool->desc_pages.num_element_per_page;
  4863. for (j = 0; j < num_desc; j++) {
  4864. page_id = j / num_desc_per_page;
  4865. offset = j % num_desc_per_page;
  4866. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4867. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4868. if (force_free) {
  4869. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4870. dp_tx_comp_free_buf(soc, tx_desc);
  4871. dp_tx_desc_release(tx_desc, i);
  4872. } else {
  4873. dp_tx_desc_reset_vdev(soc, tx_desc,
  4874. i);
  4875. }
  4876. }
  4877. }
  4878. }
  4879. }
  4880. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4881. /**
  4882. * dp_tx_vdev_detach() - detach vdev from dp tx
  4883. * @vdev: virtual device instance
  4884. *
  4885. * Return: QDF_STATUS_SUCCESS: success
  4886. * QDF_STATUS_E_RESOURCES: Error return
  4887. */
  4888. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  4889. {
  4890. struct dp_pdev *pdev = vdev->pdev;
  4891. /* Reset TX desc associated to this Vdev as NULL */
  4892. dp_tx_desc_flush(pdev, vdev, false);
  4893. return QDF_STATUS_SUCCESS;
  4894. }
  4895. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4896. /* Pools will be allocated dynamically */
  4897. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4898. int num_desc)
  4899. {
  4900. uint8_t i;
  4901. for (i = 0; i < num_pool; i++) {
  4902. qdf_spinlock_create(&soc->tx_desc[i].flow_pool_lock);
  4903. soc->tx_desc[i].status = FLOW_POOL_INACTIVE;
  4904. }
  4905. return QDF_STATUS_SUCCESS;
  4906. }
  4907. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4908. uint32_t num_desc)
  4909. {
  4910. return QDF_STATUS_SUCCESS;
  4911. }
  4912. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4913. {
  4914. }
  4915. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4916. {
  4917. uint8_t i;
  4918. for (i = 0; i < num_pool; i++)
  4919. qdf_spinlock_destroy(&soc->tx_desc[i].flow_pool_lock);
  4920. }
  4921. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4922. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4923. uint32_t num_desc)
  4924. {
  4925. uint8_t i, count;
  4926. /* Allocate software Tx descriptor pools */
  4927. for (i = 0; i < num_pool; i++) {
  4928. if (dp_tx_desc_pool_alloc(soc, i, num_desc)) {
  4929. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4930. FL("Tx Desc Pool alloc %d failed %pK"),
  4931. i, soc);
  4932. goto fail;
  4933. }
  4934. }
  4935. return QDF_STATUS_SUCCESS;
  4936. fail:
  4937. for (count = 0; count < i; count++)
  4938. dp_tx_desc_pool_free(soc, count);
  4939. return QDF_STATUS_E_NOMEM;
  4940. }
  4941. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4942. uint32_t num_desc)
  4943. {
  4944. uint8_t i;
  4945. for (i = 0; i < num_pool; i++) {
  4946. if (dp_tx_desc_pool_init(soc, i, num_desc)) {
  4947. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4948. FL("Tx Desc Pool init %d failed %pK"),
  4949. i, soc);
  4950. return QDF_STATUS_E_NOMEM;
  4951. }
  4952. }
  4953. return QDF_STATUS_SUCCESS;
  4954. }
  4955. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4956. {
  4957. uint8_t i;
  4958. for (i = 0; i < num_pool; i++)
  4959. dp_tx_desc_pool_deinit(soc, i);
  4960. }
  4961. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4962. {
  4963. uint8_t i;
  4964. for (i = 0; i < num_pool; i++)
  4965. dp_tx_desc_pool_free(soc, i);
  4966. }
  4967. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4968. /**
  4969. * dp_tx_tso_cmn_desc_pool_deinit() - de-initialize TSO descriptors
  4970. * @soc: core txrx main context
  4971. * @num_pool: number of pools
  4972. *
  4973. */
  4974. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool)
  4975. {
  4976. dp_tx_tso_desc_pool_deinit(soc, num_pool);
  4977. dp_tx_tso_num_seg_pool_deinit(soc, num_pool);
  4978. }
  4979. /**
  4980. * dp_tx_tso_cmn_desc_pool_free() - free TSO descriptors
  4981. * @soc: core txrx main context
  4982. * @num_pool: number of pools
  4983. *
  4984. */
  4985. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool)
  4986. {
  4987. dp_tx_tso_desc_pool_free(soc, num_pool);
  4988. dp_tx_tso_num_seg_pool_free(soc, num_pool);
  4989. }
  4990. /**
  4991. * dp_soc_tx_desc_sw_pools_free() - free all TX descriptors
  4992. * @soc: core txrx main context
  4993. *
  4994. * This function frees all tx related descriptors as below
  4995. * 1. Regular TX descriptors (static pools)
  4996. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  4997. * 3. TSO descriptors
  4998. *
  4999. */
  5000. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  5001. {
  5002. uint8_t num_pool;
  5003. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5004. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  5005. dp_tx_ext_desc_pool_free(soc, num_pool);
  5006. dp_tx_delete_static_pools(soc, num_pool);
  5007. }
  5008. /**
  5009. * dp_soc_tx_desc_sw_pools_deinit() - de-initialize all TX descriptors
  5010. * @soc: core txrx main context
  5011. *
  5012. * This function de-initializes all tx related descriptors as below
  5013. * 1. Regular TX descriptors (static pools)
  5014. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  5015. * 3. TSO descriptors
  5016. *
  5017. */
  5018. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  5019. {
  5020. uint8_t num_pool;
  5021. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5022. dp_tx_flow_control_deinit(soc);
  5023. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  5024. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  5025. dp_tx_deinit_static_pools(soc, num_pool);
  5026. }
  5027. /**
  5028. * dp_tso_attach() - TSO attach handler
  5029. * @txrx_soc: Opaque Dp handle
  5030. *
  5031. * Reserve TSO descriptor buffers
  5032. *
  5033. * Return: QDF_STATUS_E_FAILURE on failure or
  5034. * QDF_STATUS_SUCCESS on success
  5035. */
  5036. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  5037. uint8_t num_pool,
  5038. uint32_t num_desc)
  5039. {
  5040. if (dp_tx_tso_desc_pool_alloc(soc, num_pool, num_desc)) {
  5041. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  5042. return QDF_STATUS_E_FAILURE;
  5043. }
  5044. if (dp_tx_tso_num_seg_pool_alloc(soc, num_pool, num_desc)) {
  5045. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  5046. num_pool, soc);
  5047. return QDF_STATUS_E_FAILURE;
  5048. }
  5049. return QDF_STATUS_SUCCESS;
  5050. }
  5051. /**
  5052. * dp_tx_tso_cmn_desc_pool_init() - TSO cmn desc pool init
  5053. * @soc: DP soc handle
  5054. * @num_pool: Number of pools
  5055. * @num_desc: Number of descriptors
  5056. *
  5057. * Initialize TSO descriptor pools
  5058. *
  5059. * Return: QDF_STATUS_E_FAILURE on failure or
  5060. * QDF_STATUS_SUCCESS on success
  5061. */
  5062. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  5063. uint8_t num_pool,
  5064. uint32_t num_desc)
  5065. {
  5066. if (dp_tx_tso_desc_pool_init(soc, num_pool, num_desc)) {
  5067. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  5068. return QDF_STATUS_E_FAILURE;
  5069. }
  5070. if (dp_tx_tso_num_seg_pool_init(soc, num_pool, num_desc)) {
  5071. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  5072. num_pool, soc);
  5073. return QDF_STATUS_E_FAILURE;
  5074. }
  5075. return QDF_STATUS_SUCCESS;
  5076. }
  5077. /**
  5078. * dp_soc_tx_desc_sw_pools_alloc() - Allocate tx descriptor pool memory
  5079. * @soc: core txrx main context
  5080. *
  5081. * This function allocates memory for following descriptor pools
  5082. * 1. regular sw tx descriptor pools (static pools)
  5083. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  5084. * 3. TSO descriptor pools
  5085. *
  5086. * Return: QDF_STATUS_SUCCESS: success
  5087. * QDF_STATUS_E_RESOURCES: Error return
  5088. */
  5089. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  5090. {
  5091. uint8_t num_pool;
  5092. uint32_t num_desc;
  5093. uint32_t num_ext_desc;
  5094. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5095. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5096. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5097. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  5098. "%s Tx Desc Alloc num_pool = %d, descs = %d",
  5099. __func__, num_pool, num_desc);
  5100. if ((num_pool > MAX_TXDESC_POOLS) ||
  5101. (num_desc > WLAN_CFG_NUM_TX_DESC_MAX))
  5102. goto fail1;
  5103. if (dp_tx_alloc_static_pools(soc, num_pool, num_desc))
  5104. goto fail1;
  5105. if (dp_tx_ext_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5106. goto fail2;
  5107. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  5108. return QDF_STATUS_SUCCESS;
  5109. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5110. goto fail3;
  5111. return QDF_STATUS_SUCCESS;
  5112. fail3:
  5113. dp_tx_ext_desc_pool_free(soc, num_pool);
  5114. fail2:
  5115. dp_tx_delete_static_pools(soc, num_pool);
  5116. fail1:
  5117. return QDF_STATUS_E_RESOURCES;
  5118. }
  5119. /**
  5120. * dp_soc_tx_desc_sw_pools_init() - Initialise TX descriptor pools
  5121. * @soc: core txrx main context
  5122. *
  5123. * This function initializes the following TX descriptor pools
  5124. * 1. regular sw tx descriptor pools (static pools)
  5125. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  5126. * 3. TSO descriptor pools
  5127. *
  5128. * Return: QDF_STATUS_SUCCESS: success
  5129. * QDF_STATUS_E_RESOURCES: Error return
  5130. */
  5131. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  5132. {
  5133. uint8_t num_pool;
  5134. uint32_t num_desc;
  5135. uint32_t num_ext_desc;
  5136. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5137. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5138. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5139. if (dp_tx_init_static_pools(soc, num_pool, num_desc))
  5140. goto fail1;
  5141. if (dp_tx_ext_desc_pool_init(soc, num_pool, num_ext_desc))
  5142. goto fail2;
  5143. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  5144. return QDF_STATUS_SUCCESS;
  5145. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  5146. goto fail3;
  5147. dp_tx_flow_control_init(soc);
  5148. soc->process_tx_status = CONFIG_PROCESS_TX_STATUS;
  5149. return QDF_STATUS_SUCCESS;
  5150. fail3:
  5151. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  5152. fail2:
  5153. dp_tx_deinit_static_pools(soc, num_pool);
  5154. fail1:
  5155. return QDF_STATUS_E_RESOURCES;
  5156. }
  5157. /**
  5158. * dp_tso_soc_attach() - Allocate and initialize TSO descriptors
  5159. * @txrx_soc: dp soc handle
  5160. *
  5161. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5162. * QDF_STATUS_E_FAILURE
  5163. */
  5164. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc)
  5165. {
  5166. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5167. uint8_t num_pool;
  5168. uint32_t num_desc;
  5169. uint32_t num_ext_desc;
  5170. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5171. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5172. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5173. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5174. return QDF_STATUS_E_FAILURE;
  5175. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  5176. return QDF_STATUS_E_FAILURE;
  5177. return QDF_STATUS_SUCCESS;
  5178. }
  5179. /**
  5180. * dp_tso_soc_detach() - de-initialize and free the TSO descriptors
  5181. * @txrx_soc: dp soc handle
  5182. *
  5183. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5184. */
  5185. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc)
  5186. {
  5187. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5188. uint8_t num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5189. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  5190. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  5191. return QDF_STATUS_SUCCESS;
  5192. }